diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/FreeRTOS_Plus_POSIX_with_actor.sln b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/FreeRTOS_Plus_POSIX_with_actor.sln index 7f67bc7..4443b91 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/FreeRTOS_Plus_POSIX_with_actor.sln +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/FreeRTOS_Plus_POSIX_with_actor.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2050 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RTOSDemo", "WIN32.vcxproj", "{C686325E-3261-42F7-AEB1-DDE5280E1CEB}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RTOS_POSIX_Demo", "WIN32.vcxproj", "{C686325E-3261-42F7-AEB1-DDE5280E1CEB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -19,4 +19,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {18112148-F9F0-43E0-B713-B146289BDEF3} + EndGlobalSection EndGlobal diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/WIN32.vcxproj b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/WIN32.vcxproj index 76d8b13..e2b95db 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/WIN32.vcxproj +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/WIN32.vcxproj @@ -13,7 +13,6 @@ {C686325E-3261-42F7-AEB1-DDE5280E1CEB} RTOS_POSIX_Demo - 10.0.17763.0 @@ -132,7 +131,6 @@ - diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/WIN32.vcxproj.filters index c4ff3ea..60e3a44 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/WIN32.vcxproj.filters +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/WIN32.vcxproj.filters @@ -90,9 +90,6 @@ lib\FreeRTOS\Portable\MSVC-W - - lib\FreeRTOS - lib\FreeRTOS diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/FreeRTOS_POSIX.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/FreeRTOS_POSIX.h index ab39b69..d938709 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/FreeRTOS_POSIX.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/FreeRTOS_POSIX.h @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS POSIX V1.1.0 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -35,7 +35,7 @@ /* FreeRTOS+POSIX platform-specific configuration headers. */ #include "FreeRTOS_POSIX_portable.h" -#include "portable/FreeRTOS_POSIX_portable_default.h" +#include "FreeRTOS_POSIX_portable_default.h" /* FreeRTOS includes. */ #include "FreeRTOS.h" diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/FreeRTOS_POSIX_internal.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/FreeRTOS_POSIX_internal.h index 5282154..16f8036 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/FreeRTOS_POSIX_internal.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/FreeRTOS_POSIX_internal.h @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS POSIX V1.1.0 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -32,64 +32,98 @@ */ /* Amazon FreeRTOS includes. */ -#include "aws_doubly_linked_list.h" +#include "iot_doubly_linked_list.h" /** * @brief Mutex attribute object. */ -typedef struct pthread_mutexattr_internal -{ - int iType; /**< Mutex type. */ -} pthread_mutexattr_internal_t; +#if posixconfigENABLE_PTHREAD_MUTEXATTR_T == 1 + typedef struct pthread_mutexattr_internal + { + int iType; /**< Mutex type. */ + } pthread_mutexattr_internal_t; +#endif + +#if posixconfigENABLE_PTHREAD_MUTEX_T == 1 /** * @brief Mutex. */ -typedef struct pthread_mutex_internal -{ - BaseType_t xIsInitialized; /**< Set to pdTRUE if this mutex is initialized, pdFALSE otherwise. */ - StaticSemaphore_t xMutex; /**< FreeRTOS mutex. */ - TaskHandle_t xTaskOwner; /**< Owner; used for deadlock detection and permission checks. */ - pthread_mutexattr_internal_t xAttr; /**< Mutex attributes. */ -} pthread_mutex_internal_t; + typedef struct pthread_mutex_internal + { + BaseType_t xIsInitialized; /**< Set to pdTRUE if this mutex is initialized, pdFALSE otherwise. */ + StaticSemaphore_t xMutex; /**< FreeRTOS mutex. */ + TaskHandle_t xTaskOwner; /**< Owner; used for deadlock detection and permission checks. */ + pthread_mutexattr_internal_t xAttr; /**< Mutex attributes. */ + } pthread_mutex_internal_t; /** * @brief Compile-time initializer of pthread_mutex_internal_t. */ -#define FREERTOS_POSIX_MUTEX_INITIALIZER \ - ( &( ( pthread_mutex_internal_t ) \ - { \ - .xIsInitialized = pdFALSE, \ - .xMutex = { { 0 } }, \ - .xTaskOwner = NULL, \ - .xAttr = { .iType = 0 } \ - } \ - ) \ + #define FREERTOS_POSIX_MUTEX_INITIALIZER \ + ( ( ( pthread_mutex_internal_t ) \ + { \ + .xIsInitialized = pdFALSE, \ + .xMutex = { { 0 } }, \ + .xTaskOwner = NULL, \ + .xAttr = { .iType = 0 } \ + } \ + ) \ ) +#endif /* if posixconfigENABLE_PTHREAD_MUTEX_T == 1 */ + +#if posixconfigENABLE_PTHREAD_COND_T == 1 /** * @brief Condition variable. */ -typedef struct pthread_cond_internal -{ - BaseType_t xIsInitialized; /**< Set to pdTRUE if this condition variable is initialized, pdFALSE otherwise. */ - StaticSemaphore_t xCondMutex; /**< Prevents concurrent accesses to iWaitingThreads. */ - StaticSemaphore_t xCondWaitSemaphore; /**< Threads block on this semaphore in pthread_cond_wait. */ - int iWaitingThreads; /**< The number of threads currently waiting on this condition variable. */ -} pthread_cond_internal_t; + typedef struct pthread_cond_internal + { + BaseType_t xIsInitialized; /**< Set to pdTRUE if this condition variable is initialized, pdFALSE otherwise. */ + StaticSemaphore_t xCondWaitSemaphore; /**< Threads block on this semaphore in pthread_cond_wait. */ + unsigned iWaitingThreads; /**< The number of threads currently waiting on this condition variable. */ + } pthread_cond_internal_t; /** * @brief Compile-time initializer of pthread_cond_internal_t. */ -#define FREERTOS_POSIX_COND_INITIALIZER \ - ( &( ( pthread_cond_internal_t ) \ - { \ - .xIsInitialized = pdFALSE, \ - .xCondMutex = { { 0 } }, \ - .xCondWaitSemaphore = { { 0 } },\ - .iWaitingThreads = 0 \ - } \ - ) \ + + #define FREERTOS_POSIX_COND_INITIALIZER \ + ( ( ( pthread_cond_internal_t ) \ + { \ + .xIsInitialized = pdFALSE, \ + .xCondWaitSemaphore = { { 0 } }, \ + .iWaitingThreads = 0 \ + } \ + ) \ ) +#endif /* if posixconfigENABLE_PTHREAD_COND_T == 1 */ + +#if posixconfigENABLE_SEM_T == 1 + +/** + * @brief Semaphore type. + */ + typedef struct + { + StaticSemaphore_t xSemaphore; /**< FreeRTOS semaphore. */ + int value; /**< POSIX semaphore count. */ + } sem_internal_t; +#endif /* if posixconfigENABLE_SEM_T == 1 */ + +#if posixconfigENABLE_PTHREAD_BARRIER_T == 1 + +/** + * @brief Barrier object. + */ + typedef struct pthread_barrier_internal + { + unsigned uThreadCount; /**< Current number of threads that have entered barrier. */ + unsigned uThreshold; /**< The count argument of pthread_barrier_init. */ + StaticSemaphore_t xThreadCountSemaphore; /**< Prevents more than uThreshold threads from exiting pthread_barrier_wait at once. */ + StaticEventGroup_t xBarrierEventGroup; /**< FreeRTOS event group that blocks to wait on threads entering barrier. */ + } pthread_barrier_internal_t; +#endif /* if posixconfigENABLE_PTHREAD_BARRIER_T == 1 */ + #endif /* _FREERTOS_POSIX_INTERNAL_H_ */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/FreeRTOS_POSIX_types.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/FreeRTOS_POSIX_types.h new file mode 100755 index 0000000..3b45b8d --- /dev/null +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/FreeRTOS_POSIX_types.h @@ -0,0 +1,81 @@ +/* + * Amazon FreeRTOS POSIX V1.1.0 + * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://aws.amazon.com/freertos + * http://www.FreeRTOS.org + */ + +#ifndef _FREERTOS_POSIX_INTERNAL_TYPES_H_ +#define _FREERTOS_POSIX_INTERNAL_TYPES_H_ + +#include "FreeRTOS_POSIX_internal.h" + +/* + * sys/types.h defines a POSIX type when posixconfigENABLE_PTHREAD__T + * is not defined AND when posixconfigENABLE_PTHREAD__T is set to 1. + * FreeRTOS_POSIX_internal.h defines internal type ONLY when + * posixconfigENABLE_PTHREAD__T is set to 1. + * #else part below is to have a type defined, so the code compiles, when + * posixconfigENABLE_PTHREAD__T is not defined. + */ +#if posixconfigENABLE_PTHREAD_MUTEX_T == 1 + typedef pthread_mutex_internal_t PthreadMutexType_t; +#else + typedef void * PthreadMutexType_t; +#endif + +#if posixconfigENABLE_PTHREAD_COND_T == 1 + typedef pthread_cond_internal_t PthreadCondType_t; +#else + typedef void * PthreadCondType_t; +#endif + +#if posixconfigENABLE_SEM_T == 1 + typedef sem_internal_t PosixSemType_t; +#else + typedef void * PosixSemType_t; +#endif + +#if posixconfigENABLE_PTHREAD_MUTEXATTR_T == 1 + typedef struct pthread_mutexattr + { + uint32_t ulpthreadMutexAttrStorage; + } PthreadMutexAttrType_t; +#else + typedef void * PthreadMutexAttrType_t; +#endif + +#if posixconfigENABLE_PTHREAD_ATTR_T == 1 + typedef struct pthread_attr + { + uint32_t ulpthreadAttrStorage; + } PthreadAttrType_t; +#else + typedef void * PthreadAttrType_t; +#endif + +#if posixconfigENABLE_PTHREAD_BARRIER_T == 1 + typedef pthread_barrier_internal_t PthreadBarrierType_t; +#else + typedef void * PthreadBarrierType_t; +#endif + +#endif /* _FREERTOS_POSIX_INTERNAL_TYPES_H_ */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/FreeRTOS_POSIX_portable_default.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/FreeRTOS_POSIX_portable_default.h index 8b0a7cd..763b901 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/FreeRTOS_POSIX_portable_default.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/FreeRTOS_POSIX_portable_default.h @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS POSIX V1.1.0 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -32,21 +32,25 @@ #define _FREERTOS_POSIX_PORTABLE_DEFAULT_H_ /** - * @brief The FreeRTOS task name given to pthreads. + * @name The FreeRTOS task name given to pthreads. */ +/**@{ */ #ifndef posixconfigPTHREAD_TASK_NAME - #define posixconfigPTHREAD_TASK_NAME "pthread" + #define posixconfigPTHREAD_TASK_NAME "pthread" /**< Task name. */ #endif +/**@} */ /** - * @brief the FreeRTOS timer name given to POSIX timers. + * @name the FreeRTOS timer name given to POSIX timers. */ +/**@{ */ #ifndef posixconfigTIMER_NAME - #define posixconfigTIMER_NAME "timer" + #define posixconfigTIMER_NAME "timer" /**< Timer name. */ #endif +/**@} */ /** - * @defgroup Defaults for POSIX message queue implementation. + * @name Defaults for POSIX message queue implementation. */ /**@{ */ #ifndef posixconfigMQ_MAX_MESSAGES @@ -59,7 +63,7 @@ /**@} */ /** - * @defgroup POSIX implementation-dependent constants usually defined in limits.h. + * @name POSIX implementation-dependent constants usually defined in limits.h. * * They are defined here to provide portability between platforms. */ @@ -71,12 +75,12 @@ #define NAME_MAX 64 /**< Maximum number of bytes in a filename (not including terminating null). */ #endif #ifndef SEM_VALUE_MAX - #define SEM_VALUE_MAX 0xFFFFU /**< Maximum value of a sem_t. */ + #define SEM_VALUE_MAX 0x7FFFU /**< Maximum value of a sem_t. */ #endif /**@} */ /** - * @defgroup Enable typedefs of POSIX types. + * @name Enable typedefs of POSIX types. * * Set these values to 1 or 0 to enable or disable the typedefs, respectively. * These typedefs should only be disabled if they conflict with system typedefs. @@ -130,8 +134,11 @@ #ifndef posixconfigENABLE_ITIMERSPEC #define posixconfigENABLE_ITIMERSPEC 1 /**< struct itimerspec in time.h */ #endif -#ifndef posixconfigENABLE_TM - #define posixconfigENABLE_TM 1 /**< struct tm in time.h */ +#ifndef posixconfigENABLE_SEM_T + #define posixconfigENABLE_SEM_T 1 /**< struct sem_t in semaphore.h */ +#endif +#ifndef posixconfigENABLE_PTHREAD_BARRIER_T + #define posixconfigENABLE_PTHREAD_BARRIER_T 1 /**< pthread_barrier_t in sys/types.h */ #endif /**@} */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/espressif/esp32_devkitc_esp_wrover_kit/FreeRTOS_POSIX_portable.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/espressif/esp32_devkitc_esp_wrover_kit/FreeRTOS_POSIX_portable.h index 2686cc9..c187043 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/espressif/esp32_devkitc_esp_wrover_kit/FreeRTOS_POSIX_portable.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/espressif/esp32_devkitc_esp_wrover_kit/FreeRTOS_POSIX_portable.h @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS+POSIX V1.0.4 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -42,12 +42,19 @@ #define posixconfigENABLE_PTHREAD_MUTEXATTR_T 0 #define posixconfigENABLE_PTHREAD_T 0 #define posixconfigENABLE_TIME_T 0 -#define posixconfigENABLE_TIMER_T 0 #define posixconfigENABLE_TIMESPEC 0 #define posixconfigENABLE_ITIMERSPEC 0 -/* ESP-IDF already provides the header sched.h. Exclude them by - * activating the double inclusion guards. */ +/* ESP-IDF already provides the header sched.h. Exclude FreeRTOS+POSIX sched.h by + * defining its double inclusion guard. */ #define _FREERTOS_POSIX_SCHED_H_ +/* Use the FreeRTOS+POSIX time.h header instead of the ESP-IDF time.h. Disable + * ESP-IDF time.h by defining its double inclusion guard. */ +#define _TIME_H_ + +/* Disable the timer_t type defined by ESP-IDF. */ +#define __timer_t_defined +#include + #endif /* _FREERTOS_POSIX_PORTABLE_H_ */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/microchip/curiosity_pic32mzef/FreeRTOS_POSIX_portable.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/microchip/curiosity_pic32mzef/FreeRTOS_POSIX_portable.h index 5ff2a9c..d4d2db7 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/microchip/curiosity_pic32mzef/FreeRTOS_POSIX_portable.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/microchip/curiosity_pic32mzef/FreeRTOS_POSIX_portable.h @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.1 + * Amazon FreeRTOS+POSIX V1.0.4 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/nxp/lpc54018iotmodule/FreeRTOS_POSIX_portable.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/nxp/lpc54018iotmodule/FreeRTOS_POSIX_portable.h index 1976064..1022f4b 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/nxp/lpc54018iotmodule/FreeRTOS_POSIX_portable.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/nxp/lpc54018iotmodule/FreeRTOS_POSIX_portable.h @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS+POSIX V1.0.4 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/pc/windows/FreeRTOS_POSIX_portable.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/pc/windows/FreeRTOS_POSIX_portable.h index 1976064..1022f4b 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/pc/windows/FreeRTOS_POSIX_portable.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/pc/windows/FreeRTOS_POSIX_portable.h @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS+POSIX V1.0.4 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/st/stm32l475_discovery/FreeRTOS_POSIX_portable.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/st/stm32l475_discovery/FreeRTOS_POSIX_portable.h index 1976064..1022f4b 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/st/stm32l475_discovery/FreeRTOS_POSIX_portable.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/st/stm32l475_discovery/FreeRTOS_POSIX_portable.h @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS+POSIX V1.0.4 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/ti/cc3220_launchpad/FreeRTOS_POSIX_portable.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/ti/cc3220_launchpad/FreeRTOS_POSIX_portable.h index 1976064..1022f4b 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/ti/cc3220_launchpad/FreeRTOS_POSIX_portable.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/portable/ti/cc3220_launchpad/FreeRTOS_POSIX_portable.h @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS+POSIX V1.0.4 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_clock.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_clock.c index dcb397b..51e592a 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_clock.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_clock.c @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS POSIX V1.1.0 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -31,7 +31,6 @@ /* C standard library includes. */ #include #include -#include /* FreeRTOS+POSIX includes. */ #include "FreeRTOS_POSIX.h" @@ -39,13 +38,20 @@ #include "FreeRTOS_POSIX/time.h" #include "FreeRTOS_POSIX/utils.h" +/* Declaration of snprintf. The header stdio.h is not included because it + * includes conflicting symbols on some platforms. */ +extern int snprintf( char * s, + size_t n, + const char * format, + ... ); + /*-----------------------------------------------------------*/ clock_t clock( void ) { - /* Return the amount of time since the scheduler started that wasn't spent - * in the idle task. */ - return ( clock_t ) ( xTaskGetTickCount() - xTaskGetIdleTickCount() ); + /* This function is currently unsupported. It will always return -1. */ + + return ( clock_t ) -1; } /*-----------------------------------------------------------*/ @@ -57,6 +63,7 @@ int clock_getcpuclockid( pid_t pid, ( void ) pid; ( void ) clock_id; + /* This function is currently unsupported. It will always return EPERM. */ return EPERM; } @@ -84,7 +91,6 @@ int clock_gettime( clockid_t clock_id, struct timespec * tp ) { TimeOut_t xCurrentTime = { 0 }; - int iStatus = 0; /* Intermediate variable used to convert TimeOut_t to struct timespec. * Also used to detect overflow issues. It must be unsigned because the @@ -94,24 +100,21 @@ int clock_gettime( clockid_t clock_id, /* Silence warnings about unused parameters. */ ( void ) clock_id; - if( iStatus == 0 ) - { - /* Get the current tick count and overflow count. vTaskSetTimeOutState() - * is used to get these values because they are both static in tasks.c. */ - vTaskSetTimeOutState( &xCurrentTime ); + /* Get the current tick count and overflow count. vTaskSetTimeOutState() + * is used to get these values because they are both static in tasks.c. */ + vTaskSetTimeOutState( &xCurrentTime ); - /* Adjust the tick count for the number of times a TickType_t has overflowed. - * portMAX_DELAY should be the maximum value of a TickType_t. */ - ullTickCount = ( uint64_t ) ( xCurrentTime.xOverflowCount ) << ( sizeof( TickType_t ) * 8 ); + /* Adjust the tick count for the number of times a TickType_t has overflowed. + * portMAX_DELAY should be the maximum value of a TickType_t. */ + ullTickCount = ( uint64_t ) ( xCurrentTime.xOverflowCount ) << ( sizeof( TickType_t ) * 8 ); - /* Add the current tick count. */ - ullTickCount += xCurrentTime.xTimeOnEntering; + /* Add the current tick count. */ + ullTickCount += xCurrentTime.xTimeOnEntering; - /* Convert ullTickCount to timespec. */ - UTILS_NanosecondsToTimespec( ( int64_t ) ullTickCount * NANOSECONDS_PER_TICK, tp ); - } + /* Convert ullTickCount to timespec. */ + UTILS_NanosecondsToTimespec( ( int64_t ) ullTickCount * NANOSECONDS_PER_TICK, tp ); - return iStatus; + return 0; } /*-----------------------------------------------------------*/ @@ -123,6 +126,7 @@ int clock_nanosleep( clockid_t clock_id, { int iStatus = 0; TickType_t xSleepTime = 0; + struct timespec xCurrentTime = { 0 }; /* Silence warnings about unused parameters. */ ( void ) clock_id; @@ -135,13 +139,25 @@ int clock_nanosleep( clockid_t clock_id, iStatus = EINVAL; } + /* Get current time */ + if( ( iStatus == 0 ) && ( clock_gettime( CLOCK_REALTIME, &xCurrentTime ) != 0 ) ) + { + iStatus = EINVAL; + } + if( iStatus == 0 ) { /* Check for absolute time sleep. */ if( ( flags & TIMER_ABSTIME ) == TIMER_ABSTIME ) { + /* Get current time */ + if( clock_gettime( CLOCK_REALTIME, &xCurrentTime ) != 0 ) + { + iStatus = EINVAL; + } + /* Get number of ticks until absolute time. */ - if( UTILS_AbsoluteTimespecToTicks( rqtp, &xSleepTime ) == 0 ) + if( ( iStatus == 0 ) && ( UTILS_AbsoluteTimespecToDeltaTicks( rqtp, &xCurrentTime, &xSleepTime ) == 0 ) ) { /* Delay until absolute time if vTaskDelayUntil is available. */ #if ( INCLUDE_vTaskDelayUntil == 1 ) @@ -193,32 +209,6 @@ int clock_settime( clockid_t clock_id, /*-----------------------------------------------------------*/ -struct tm * localtime_r( const time_t * timer, - struct tm * result ) -{ - /* Silence warnings about unused parameters. */ - ( void ) timer; - ( void ) result; - - /* This function is only supported if the "custom" FreeRTOS+POSIX tm struct - * is used. */ - #if ( posixconfigENABLE_TM == 0 ) - errno = ENOTSUP; - - return NULL; - #else - - /* Zero the tm, then store the FreeRTOS tick count. The input parameter - * timer isn't used. */ - ( void ) memset( result, 0x00, sizeof( struct tm ) ); - result->tm_tick = ( time_t ) xTaskGetTickCount(); - - return result; - #endif -} - -/*-----------------------------------------------------------*/ - int nanosleep( const struct timespec * rqtp, struct timespec * rmtp ) { @@ -248,44 +238,3 @@ int nanosleep( const struct timespec * rqtp, } /*-----------------------------------------------------------*/ - -size_t strftime( char * s, - size_t maxsize, - const char * format, - const struct tm * timeptr ) -{ - int iStatus = 0; - size_t bytesPrinted = 0; - - /* Silence warnings about unused parameters. */ - ( void ) format; - - /* Print the time in the buffer. */ - iStatus = snprintf( s, maxsize, "%ld", ( long int ) timeptr->tm_tick ); - - /* Check for encoding and size errors. */ - if( ( iStatus > 0 ) && ( ( size_t ) iStatus < maxsize ) ) - { - bytesPrinted = ( size_t ) iStatus; - } - - return bytesPrinted; -} - -/*-----------------------------------------------------------*/ - -time_t time( time_t * tloc ) -{ - /* Read the current FreeRTOS tick count and convert it to seconds. */ - time_t xCurrentTime = ( time_t ) ( xTaskGetTickCount() / configTICK_RATE_HZ ); - - /* Set the output parameter if provided. */ - if( tloc != NULL ) - { - *tloc = xCurrentTime; - } - - return xCurrentTime; -} - -/*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_mqueue.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_mqueue.c index 49d394b..9f9079b 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_mqueue.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_mqueue.c @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS POSIX V1.1.0 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -142,7 +142,7 @@ static BaseType_t prvValidateQueueName( const char * const pcName, /** * @brief Guards access to the list of message queues. */ -static StaticSemaphore_t xQueueListMutex = { { 0 } }; +static StaticSemaphore_t xQueueListMutex = { { 0 }, .u = { 0 } }; /** * @brief Head of the linked list of queues. @@ -172,15 +172,23 @@ static int prvCalculateTickTimeout( long lMessageQueueFlags, } else { + struct timespec xCurrentTime = { 0 }; + /* Check that the given timespec is valid. */ if( UTILS_ValidateTimespec( pxAbsoluteTimeout ) == false ) { iStatus = EINVAL; } + /* Get current time */ + if( ( iStatus == 0 ) && ( clock_gettime( CLOCK_REALTIME, &xCurrentTime ) != 0 ) ) + { + iStatus = EINVAL; + } + /* Convert absolute timespec to ticks. */ if( ( iStatus == 0 ) && - ( UTILS_AbsoluteTimespecToTicks( pxAbsoluteTimeout, pxTimeoutTicks ) != 0 ) ) + ( UTILS_AbsoluteTimespecToDeltaTicks( pxAbsoluteTimeout, &xCurrentTime, pxTimeoutTicks ) != 0 ) ) { iStatus = ETIMEDOUT; } @@ -404,7 +412,7 @@ int mq_close( mqd_t mqdes ) if( prvFindQueueInList( NULL, NULL, mqdes ) == pdTRUE ) { /* Decrement the number of open descriptors. */ - if(pxMessageQueue->xOpenDescriptors > 0) + if( pxMessageQueue->xOpenDescriptors > 0 ) { pxMessageQueue->xOpenDescriptors--; } @@ -494,7 +502,7 @@ mqd_t mq_open( const char * name, /* Default mq_attr. */ struct mq_attr xQueueCreationAttr = { - .mq_flags = 0, + .mq_flags = 0, .mq_maxmsg = posixconfigMQ_MAX_MESSAGES, .mq_msgsize = posixconfigMQ_MAX_SIZE, .mq_curmsgs = 0 @@ -514,7 +522,7 @@ mqd_t mq_open( const char * name, xMessageQueue = ( mqd_t ) -1; } - /* Check attributes, if O_CREATE is specified and attr is given. */ + /* Check attributes, if given. */ if( xMessageQueue == NULL ) { if( ( oflag & O_CREAT ) && ( attr != NULL ) && ( ( attr->mq_maxmsg <= 0 ) || ( attr->mq_msgsize <= 0 ) ) ) diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread.c index 7d08f56..f34e9ec 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread.c @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS POSIX V1.1.0 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -30,6 +30,7 @@ /* C standard library includes. */ #include +#include /* FreeRTOS+POSIX includes. */ #include "FreeRTOS_POSIX.h" @@ -41,11 +42,16 @@ */ typedef struct pthread_attr_internal { - size_t xStackSize; /**< Stack size. */ - int iDetachState; /**< Detach state: joinable or detached. */ - struct sched_param xSchedParam; /**< Scheduler parameters. */ + uint16_t usStackSize; /**< Stack size. */ + uint16_t usSchedPriorityDetachState; /**< Schedule priority 15 bits (LSB) Detach state: 1 bits (MSB) */ } pthread_attr_internal_t; +#define pthreadDETACH_STATE_MASK 0x8000 +#define pthreadSCHED_PRIORITY_MASK 0x7FFF +#define pthreadDETACH_STATE_SHIFT 15 +#define pthreadGET_SCHED_PRIORITY( var ) ( ( var ) & ( pthreadSCHED_PRIORITY_MASK ) ) +#define pthreadIS_JOINABLE( var ) ( ( ( var ) & ( pthreadDETACH_STATE_MASK ) ) == pthreadDETACH_STATE_MASK ) + /** * @brief Thread object. */ @@ -85,9 +91,8 @@ static void prvRunThread( void * pxArg ); */ static const pthread_attr_internal_t xDefaultThreadAttributes = { - .xStackSize = PTHREAD_STACK_MIN, - .iDetachState = PTHREAD_CREATE_JOINABLE, - .xSchedParam = { .sched_priority = tskIDLE_PRIORITY } + .usStackSize = PTHREAD_STACK_MIN, + .usSchedPriorityDetachState = ( ( uint16_t ) tskIDLE_PRIORITY & pthreadSCHED_PRIORITY_MASK ) | ( PTHREAD_CREATE_JOINABLE << pthreadDETACH_STATE_SHIFT ), }; /*-----------------------------------------------------------*/ @@ -97,7 +102,7 @@ static void prvExitThread( void ) pthread_internal_t * pxThread = ( pthread_internal_t * ) pthread_self(); /* If this thread is joinable, wait for a call to pthread_join. */ - if( pxThread->xAttr.iDetachState == PTHREAD_CREATE_JOINABLE ) + if( pthreadIS_JOINABLE( pxThread->xAttr.usSchedPriorityDetachState ) ) { ( void ) xSemaphoreGive( ( SemaphoreHandle_t ) &pxThread->xJoinBarrier ); @@ -130,9 +135,9 @@ static void prvRunThread( void * pxArg ) int pthread_attr_destroy( pthread_attr_t * attr ) { - int iStatus = 0; - vPortFree( *attr ); - return iStatus; + ( void ) attr; + + return 0; } /*-----------------------------------------------------------*/ @@ -140,9 +145,16 @@ int pthread_attr_destroy( pthread_attr_t * attr ) int pthread_attr_getdetachstate( const pthread_attr_t * attr, int * detachstate ) { - pthread_attr_internal_t * pxAttr = ( pthread_attr_internal_t * ) ( *attr ); + pthread_attr_internal_t * pxAttr = ( pthread_attr_internal_t * ) ( attr ); - *detachstate = pxAttr->iDetachState; + if( pthreadIS_JOINABLE( pxAttr->usSchedPriorityDetachState ) ) + { + *detachstate = PTHREAD_CREATE_JOINABLE; + } + else + { + *detachstate = PTHREAD_CREATE_DETACHED; + } return 0; } @@ -152,9 +164,9 @@ int pthread_attr_getdetachstate( const pthread_attr_t * attr, int pthread_attr_getschedparam( const pthread_attr_t * attr, struct sched_param * param ) { - pthread_attr_internal_t * pxAttr = ( pthread_attr_internal_t * ) ( *attr ); + pthread_attr_internal_t * pxAttr = ( pthread_attr_internal_t * ) ( attr ); - *param = pxAttr->xSchedParam; + param->sched_priority = ( int ) ( pthreadGET_SCHED_PRIORITY( pxAttr->usSchedPriorityDetachState ) ); return 0; } @@ -164,9 +176,9 @@ int pthread_attr_getschedparam( const pthread_attr_t * attr, int pthread_attr_getstacksize( const pthread_attr_t * attr, size_t * stacksize ) { - pthread_attr_internal_t * pxAttr = ( pthread_attr_internal_t * ) ( *attr ); + pthread_attr_internal_t * pxAttr = ( pthread_attr_internal_t * ) ( attr ); - *stacksize = pxAttr->xStackSize; + *stacksize = ( size_t ) pxAttr->usStackSize; return 0; } @@ -175,24 +187,10 @@ int pthread_attr_getstacksize( const pthread_attr_t * attr, int pthread_attr_init( pthread_attr_t * attr ) { - int iStatus = 0; - - /* Allocate memory for a new thread attributes object. */ - *attr = pvPortMalloc( sizeof( pthread_attr_internal_t ) ); - - /* Check that thread attributes object was successfully allocated. */ - if( *attr == NULL ) - { - iStatus = ENOMEM; - } - /* Copy the default values into the new thread attributes object. */ - if( iStatus == 0 ) - { - *( ( pthread_attr_internal_t * ) ( *attr ) ) = xDefaultThreadAttributes; - } + *( ( pthread_attr_internal_t * ) ( attr ) ) = xDefaultThreadAttributes; - return iStatus; + return 0; } /*-----------------------------------------------------------*/ @@ -201,7 +199,7 @@ int pthread_attr_setdetachstate( pthread_attr_t * attr, int detachstate ) { int iStatus = 0; - pthread_attr_internal_t * pxAttr = ( pthread_attr_internal_t * ) ( *attr ); + pthread_attr_internal_t * pxAttr = ( pthread_attr_internal_t * ) ( attr ); if( ( detachstate != PTHREAD_CREATE_DETACHED ) && ( detachstate != PTHREAD_CREATE_JOINABLE ) ) { @@ -209,7 +207,9 @@ int pthread_attr_setdetachstate( pthread_attr_t * attr, } else { - pxAttr->iDetachState = detachstate; + /* clear and then set msb bit to detachstate) */ + pxAttr->usSchedPriorityDetachState &= ~pthreadDETACH_STATE_MASK; + pxAttr->usSchedPriorityDetachState |= ( ( uint16_t ) detachstate << pthreadDETACH_STATE_SHIFT ); } return iStatus; @@ -221,7 +221,7 @@ int pthread_attr_setschedparam( pthread_attr_t * attr, const struct sched_param * param ) { int iStatus = 0; - pthread_attr_internal_t * pxAttr = ( pthread_attr_internal_t * ) ( *attr ); + pthread_attr_internal_t * pxAttr = ( pthread_attr_internal_t * ) ( attr ); /* Check for NULL param. */ if( param == NULL ) @@ -240,7 +240,9 @@ int pthread_attr_setschedparam( pthread_attr_t * attr, /* Set the sched_param. */ if( iStatus == 0 ) { - pxAttr->xSchedParam = *param; + /* clear and then set 15 LSB to schedule priority) */ + pxAttr->usSchedPriorityDetachState &= ~pthreadSCHED_PRIORITY_MASK; + pxAttr->usSchedPriorityDetachState |= ( ( uint16_t ) param->sched_priority ); } return iStatus; @@ -248,11 +250,23 @@ int pthread_attr_setschedparam( pthread_attr_t * attr, /*-----------------------------------------------------------*/ +int pthread_attr_setschedpolicy( pthread_attr_t * attr, + int policy ) +{ + /* Silence warnings about unused parameters. */ + ( void ) attr; + ( void ) policy; + + return 0; +} + +/*-----------------------------------------------------------*/ + int pthread_attr_setstacksize( pthread_attr_t * attr, size_t stacksize ) { int iStatus = 0; - pthread_attr_internal_t * pxAttr = ( pthread_attr_internal_t * ) ( *attr ); + pthread_attr_internal_t * pxAttr = ( pthread_attr_internal_t * ) ( attr ); if( stacksize < PTHREAD_STACK_MIN ) { @@ -260,7 +274,7 @@ int pthread_attr_setstacksize( pthread_attr_t * attr, } else { - pxAttr->xStackSize = stacksize; + pxAttr->usStackSize = ( uint16_t ) stacksize; } return iStatus; @@ -275,6 +289,7 @@ int pthread_create( pthread_t * thread, { int iStatus = 0; pthread_internal_t * pxThread = NULL; + struct sched_param xSchedParam = { .sched_priority = tskIDLE_PRIORITY }; /* Allocate memory for new thread object. */ pxThread = ( pthread_internal_t * ) pvPortMalloc( sizeof( pthread_internal_t ) ); @@ -295,16 +310,20 @@ int pthread_create( pthread_t * thread, /* Otherwise, use provided attributes. */ else { - pxThread->xAttr = *( ( pthread_attr_internal_t * ) ( *attr ) ); + pxThread->xAttr = *( ( pthread_attr_internal_t * ) ( attr ) ); } + /* Get priority from attributes */ + xSchedParam.sched_priority = ( int ) pthreadGET_SCHED_PRIORITY( pxThread->xAttr.usSchedPriorityDetachState ); + /* Set argument and start routine. */ pxThread->xTaskArg = arg; pxThread->pvStartRoutine = startroutine; /* If this thread is joinable, create the synchronization mechanisms for * pthread_join. */ - if( pxThread->xAttr.iDetachState == PTHREAD_CREATE_JOINABLE ) + + if( pthreadIS_JOINABLE( pxThread->xAttr.usSchedPriorityDetachState ) ) { /* These calls will not fail when their arguments aren't NULL. */ ( void ) xSemaphoreCreateMutexStatic( &pxThread->xJoinMutex ); @@ -321,9 +340,9 @@ int pthread_create( pthread_t * thread, /* Create the FreeRTOS task that will run the pthread. */ if( xTaskCreate( prvRunThread, posixconfigPTHREAD_TASK_NAME, - ( uint16_t ) ( pxThread->xAttr.xStackSize / sizeof( StackType_t ) ), + ( uint16_t ) ( pxThread->xAttr.usStackSize / sizeof( StackType_t ) ), ( void * ) pxThread, - pxThread->xAttr.xSchedParam.sched_priority, + xSchedParam.sched_priority, &pxThread->xTaskHandle ) != pdPASS ) { /* Task creation failed, no memory. */ @@ -352,12 +371,13 @@ int pthread_getschedparam( pthread_t thread, int * policy, struct sched_param * param ) { + int iStatus = 0; pthread_internal_t * pxThread = ( pthread_internal_t * ) thread; *policy = SCHED_OTHER; - *param = pxThread->xAttr.xSchedParam; + param->sched_priority = ( int ) pthreadGET_SCHED_PRIORITY( pxThread->xAttr.usSchedPriorityDetachState ); - return 0; + return iStatus; } /*-----------------------------------------------------------*/ @@ -391,7 +411,7 @@ int pthread_join( pthread_t pthread, /* Make sure pthread is joinable. Otherwise, this function would block * forever waiting for an unjoinable thread. */ - if( pxThread->xAttr.iDetachState != PTHREAD_CREATE_JOINABLE ) + if( !pthreadIS_JOINABLE( pxThread->xAttr.usSchedPriorityDetachState ) ) { iStatus = EDEADLK; } @@ -468,18 +488,23 @@ int pthread_setschedparam( pthread_t thread, int policy, const struct sched_param * param ) { + int iStatus = 0; + pthread_internal_t * pxThread = ( pthread_internal_t * ) thread; /* Silence compiler warnings about unused parameters. */ ( void ) policy; - /* Copy the give sched_param. */ - pxThread->xAttr.xSchedParam = *param; + /* Copy the given sched_param. */ + iStatus = pthread_attr_setschedparam( ( pthread_attr_t * ) &pxThread->xAttr, param ); - /* Change the priority of the FreeRTOS task. */ - vTaskPrioritySet( pxThread->xTaskHandle, pxThread->xAttr.xSchedParam.sched_priority ); + if( iStatus == 0 ) + { + /* Change the priority of the FreeRTOS task. */ + vTaskPrioritySet( pxThread->xTaskHandle, param->sched_priority ); + } - return 0; + return iStatus; } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_barrier.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_barrier.c index 34179d7..6e14ef3 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_barrier.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_barrier.c @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS POSIX V1.1.0 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -36,41 +36,32 @@ #include "FreeRTOS_POSIX/errno.h" #include "FreeRTOS_POSIX/pthread.h" +#include "atomic.h" + /* + * @brief barrier max count + * * Barriers are implemented on FreeRTOS event groups, of which 8 bits are usable * when configUSE_16_BIT_TICKS is 1. Otherwise, 24 bits are usable. */ +/**@{ */ #if ( configUSE_16_BIT_TICKS == 1 ) - #define posixPTHREAD_BARRIER_MAX_COUNT ( 8 ) + #define posixPTHREAD_BARRIER_MAX_COUNT ( 8 ) #else - #define posixPTHREAD_BARRIER_MAX_COUNT ( 24 ) + #define posixPTHREAD_BARRIER_MAX_COUNT ( 24 ) #endif - -/** - * @brief Barrier object. - */ -typedef struct pthread_barrier_internal -{ - unsigned uThreadCount; /**< Current number of threads that have entered barrier. */ - unsigned uThreshold; /**< The count argument of pthread_barrier_init. */ - StaticSemaphore_t xThreadCountMutex; /**< Guards access to uThreadCount. */ - StaticSemaphore_t xThreadCountSemaphore; /**< Prevents more than uThreshold threads from exiting pthread_barrier_wait at once. */ - StaticEventGroup_t xBarrierEventGroup; /**< FreeRTOS event group that blocks to wait on threads entering barrier. */ -} pthread_barrier_internal_t; +/**@} */ /*-----------------------------------------------------------*/ int pthread_barrier_destroy( pthread_barrier_t * barrier ) { - pthread_barrier_internal_t * pxBarrier = ( pthread_barrier_internal_t * ) ( *barrier ); + pthread_barrier_internal_t * pxBarrier = ( pthread_barrier_internal_t * ) ( barrier ); /* Free all resources used by the barrier. */ ( void ) vEventGroupDelete( ( EventGroupHandle_t ) &pxBarrier->xBarrierEventGroup ); - ( void ) vSemaphoreDelete( ( SemaphoreHandle_t ) &pxBarrier->xThreadCountMutex ); ( void ) vSemaphoreDelete( ( SemaphoreHandle_t ) &pxBarrier->xThreadCountSemaphore ); - vPortFree( *barrier ); - return 0; } @@ -81,7 +72,7 @@ int pthread_barrier_init( pthread_barrier_t * barrier, unsigned count ) { int iStatus = 0; - pthread_barrier_internal_t * pxNewBarrier = NULL; + pthread_barrier_internal_t * pxNewBarrier = ( pthread_barrier_internal_t * ) ( barrier ); /* Silence warnings about unused parameters. */ ( void ) attr; @@ -103,18 +94,6 @@ int pthread_barrier_init( pthread_barrier_t * barrier, } } - /* Allocate memory for a new barrier. */ - if( iStatus == 0 ) - { - pxNewBarrier = pvPortMalloc( sizeof( pthread_barrier_internal_t ) ); - - if( pxNewBarrier == NULL ) - { - /* No memory. */ - iStatus = ENOMEM; - } - } - if( iStatus == 0 ) { /* Set the current thread count and threshold. */ @@ -125,19 +104,12 @@ int pthread_barrier_init( pthread_barrier_t * barrier, * argument isn't NULL. */ ( void ) xEventGroupCreateStatic( &pxNewBarrier->xBarrierEventGroup ); - /* Create the mutex that guards access to uThreadCount. This call - * will not fail when its argument isn't NULL. */ - ( void ) xSemaphoreCreateMutexStatic( &pxNewBarrier->xThreadCountMutex ); - /* Create the semaphore that prevents more than count threads from being * unblocked by a single successful pthread_barrier_wait. This semaphore * counts down from count and cannot decrement below 0. */ ( void ) xSemaphoreCreateCountingStatic( ( UBaseType_t ) count, /* Max count. */ ( UBaseType_t ) count, /* Initial count. */ &pxNewBarrier->xThreadCountSemaphore ); - - /* Set output parameter. */ - *barrier = pxNewBarrier; } return iStatus; @@ -149,7 +121,7 @@ int pthread_barrier_wait( pthread_barrier_t * barrier ) { int iStatus = 0; unsigned i = 0; /* Loop iterator. */ - pthread_barrier_internal_t * pxBarrier = ( pthread_barrier_internal_t * ) ( *barrier ); + pthread_barrier_internal_t * pxBarrier = ( pthread_barrier_internal_t * ) ( barrier ); unsigned uThreadNumber = 0; /* Decrement the number of threads waiting on this barrier. This will prevent more @@ -160,31 +132,20 @@ int pthread_barrier_wait( pthread_barrier_t * barrier ) */ ( void ) xSemaphoreTake( ( SemaphoreHandle_t ) &pxBarrier->xThreadCountSemaphore, portMAX_DELAY ); - /* Lock the mutex so that this thread can change uThreadCount. This call will - * never fail because it blocks forever.*/ - ( void ) xSemaphoreTake( ( SemaphoreHandle_t ) &pxBarrier->xThreadCountMutex, portMAX_DELAY ); - - /* Increment thread count. This is the order that this thread entered the - * barrier, i.e. uThreadNumber-1 threads entered the barrier before this one. */ - pxBarrier->uThreadCount++; - uThreadNumber = pxBarrier->uThreadCount; - configASSERT( uThreadNumber > 0 ); - - /* Unlock the thread count mutex to allow other threads to change thread count. - * This call will never fail because xThreadCountMutex is owned by this thread. */ - ( void ) xSemaphoreGive( ( SemaphoreHandle_t ) &pxBarrier->xThreadCountMutex ); + uThreadNumber = Atomic_Increment_u32( ( uint32_t * ) &pxBarrier->uThreadCount ); /* Set the bit in the event group representing this thread, then wait for the other * threads to set their bit. This call should wait forever until all threads have set * their bit, so the return value is ignored. */ ( void ) xEventGroupSync( ( EventGroupHandle_t ) &pxBarrier->xBarrierEventGroup, - 1 << ( uThreadNumber - 1 ), /* Which bit in the event group to set. */ + 1 << uThreadNumber, /* Which bit in the event group to set. */ ( 1 << pxBarrier->uThreshold ) - 1, /* Wait for all threads to set their bits. */ portMAX_DELAY ); /* The first thread to enter the barrier gets PTHREAD_BARRIER_SERIAL_THREAD as its * return value and resets xThreadCountSemaphore. */ - if( uThreadNumber == 1 ) + + if( uThreadNumber == 0 ) { iStatus = PTHREAD_BARRIER_SERIAL_THREAD; diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_cond.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_cond.c index 1830aae..f67d1da 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_cond.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_cond.c @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS POSIX V1.1.0 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -37,6 +37,8 @@ #include "FreeRTOS_POSIX/pthread.h" #include "FreeRTOS_POSIX/utils.h" +#include "atomic.h" + /** * @brief Initialize a PTHREAD_COND_INITIALIZER cond. * @@ -67,7 +69,6 @@ static void prvInitializeStaticCond( pthread_cond_internal_t * pxCond ) /* Set the members of the cond. The semaphore create calls will never fail * when their arguments aren't NULL. */ pxCond->xIsInitialized = pdTRUE; - ( void ) xSemaphoreCreateMutexStatic( &pxCond->xCondMutex ); ( void ) xSemaphoreCreateCountingStatic( INT_MAX, 0U, &pxCond->xCondWaitSemaphore ); pxCond->iWaitingThreads = 0; } @@ -77,32 +78,61 @@ static void prvInitializeStaticCond( pthread_cond_internal_t * pxCond ) } } +/** + * @brief Check "atomically" if iLocalWaitingThreads == pxCond->iWaitingThreads and decrement. + */ +static void prvTestAndDecrement( pthread_cond_t * pxCond, + unsigned iLocalWaitingThreads ) +{ + /* Test local copy of threads waiting is larger than zero. */ + while( iLocalWaitingThreads > 0 ) + { + /* Test-and-set. Atomically check whether the copy in memory has changed. + * And, if not decrease the copy of threads waiting in memory. */ + if( ATOMIC_COMPARE_AND_SWAP_SUCCESS == Atomic_CompareAndSwap_u32( ( uint32_t * ) &pxCond->iWaitingThreads, ( uint32_t ) iLocalWaitingThreads - 1, ( uint32_t ) iLocalWaitingThreads ) ) + { + /* Signal one succeeded. Break. */ + break; + } + + /* Local copy may be out dated. Reload, and retry. */ + iLocalWaitingThreads = pxCond->iWaitingThreads; + } +} + /*-----------------------------------------------------------*/ int pthread_cond_broadcast( pthread_cond_t * cond ) { - int i = 0; - pthread_cond_internal_t * pxCond = ( pthread_cond_internal_t * ) ( *cond ); + unsigned i = 0; + pthread_cond_internal_t * pxCond = ( pthread_cond_internal_t * ) ( cond ); /* If the cond is uninitialized, perform initialization. */ prvInitializeStaticCond( pxCond ); - /* Lock xCondMutex to protect access to iWaitingThreads. - * This call will never fail because it blocks forever. */ - ( void ) xSemaphoreTake( ( SemaphoreHandle_t ) &pxCond->xCondMutex, portMAX_DELAY ); + /* Local copy of number of threads waiting. */ + unsigned iLocalWaitingThreads = pxCond->iWaitingThreads; - /* Unblock all threads waiting on this condition variable. */ - for( i = 0; i < pxCond->iWaitingThreads; i++ ) + /* Test local copy of threads waiting is larger than zero. */ + while( iLocalWaitingThreads > 0 ) { - ( void ) xSemaphoreGive( ( SemaphoreHandle_t ) &pxCond->xCondWaitSemaphore ); + /* Test-and-set. Atomically check whether the copy in memory has changed. + * And, if not set the copy of threads waiting in memory to zero. */ + if( ATOMIC_COMPARE_AND_SWAP_SUCCESS == Atomic_CompareAndSwap_u32( ( uint32_t * ) &pxCond->iWaitingThreads, 0, ( uint32_t ) iLocalWaitingThreads ) ) + { + /* Unblock all. */ + for( i = 0; i < iLocalWaitingThreads; i++ ) + { + ( void ) xSemaphoreGive( ( SemaphoreHandle_t ) &pxCond->xCondWaitSemaphore ); + } + + break; + } + + /* Local copy is out dated. Reload, and retry. */ + iLocalWaitingThreads = pxCond->iWaitingThreads; } - /* All threads were unblocked, set waiting threads to 0. */ - pxCond->iWaitingThreads = 0; - - /* Release xCondMutex. */ - ( void ) xSemaphoreGive( ( SemaphoreHandle_t ) &pxCond->xCondMutex ); - return 0; } @@ -110,12 +140,10 @@ int pthread_cond_broadcast( pthread_cond_t * cond ) int pthread_cond_destroy( pthread_cond_t * cond ) { - pthread_cond_internal_t * pxCond = ( pthread_cond_internal_t * ) ( *cond ); + pthread_cond_internal_t * pxCond = ( pthread_cond_internal_t * ) ( cond ); /* Free all resources in use by the cond. */ - vSemaphoreDelete( ( SemaphoreHandle_t ) &pxCond->xCondMutex ); vSemaphoreDelete( ( SemaphoreHandle_t ) &pxCond->xCondWaitSemaphore ); - vPortFree( pxCond ); return 0; } @@ -126,13 +154,11 @@ int pthread_cond_init( pthread_cond_t * cond, const pthread_condattr_t * attr ) { int iStatus = 0; - pthread_cond_internal_t * pxCond = NULL; + pthread_cond_internal_t * pxCond = ( pthread_cond_internal_t * ) cond; /* Silence warnings about unused parameters. */ ( void ) attr; - pxCond = pvPortMalloc( sizeof( pthread_cond_internal_t ) ); - if( pxCond == NULL ) { iStatus = ENOMEM; @@ -143,12 +169,9 @@ int pthread_cond_init( pthread_cond_t * cond, /* Set the members of the cond. The semaphore create calls will never fail * when their arguments aren't NULL. */ pxCond->xIsInitialized = pdTRUE; - ( void ) xSemaphoreCreateMutexStatic( &pxCond->xCondMutex ); + ( void ) xSemaphoreCreateCountingStatic( INT_MAX, 0U, &pxCond->xCondWaitSemaphore ); pxCond->iWaitingThreads = 0; - - /* Set the output. */ - *cond = pxCond; } return iStatus; @@ -158,30 +181,30 @@ int pthread_cond_init( pthread_cond_t * cond, int pthread_cond_signal( pthread_cond_t * cond ) { - pthread_cond_internal_t * pxCond = ( pthread_cond_internal_t * ) ( *cond ); + pthread_cond_internal_t * pxCond = ( pthread_cond_internal_t * ) ( cond ); /* If the cond is uninitialized, perform initialization. */ prvInitializeStaticCond( pxCond ); - /* Check that at least one thread is waiting for a signal. */ - if( pxCond->iWaitingThreads > 0 ) - { - /* Lock xCondMutex to protect access to iWaitingThreads. - * This call will never fail because it blocks forever. */ - ( void ) xSemaphoreTake( ( SemaphoreHandle_t ) &pxCond->xCondMutex, portMAX_DELAY ); + /* Local copy of number of threads waiting. */ + unsigned iLocalWaitingThreads = pxCond->iWaitingThreads; - /* Check again that at least one thread is waiting for a signal after - * taking xCondMutex. If so, unblock it. */ - if( pxCond->iWaitingThreads > 0 ) + /* Test local copy of threads waiting is larger than zero. */ + while( iLocalWaitingThreads > 0 ) + { + /* Test-and-set. Atomically check whether the copy in memory has changed. + * And, if not decrease the copy of threads waiting in memory. */ + if( ATOMIC_COMPARE_AND_SWAP_SUCCESS == Atomic_CompareAndSwap_u32( ( uint32_t * ) &pxCond->iWaitingThreads, ( uint32_t ) iLocalWaitingThreads - 1, ( uint32_t ) iLocalWaitingThreads ) ) { + /* Unblock one. */ ( void ) xSemaphoreGive( ( SemaphoreHandle_t ) &pxCond->xCondWaitSemaphore ); - /* Decrease the number of waiting threads. */ - pxCond->iWaitingThreads--; + /* Signal one succeeded. Break. */ + break; } - /* Release xCondMutex. */ - ( void ) xSemaphoreGive( ( SemaphoreHandle_t ) &pxCond->xCondMutex ); + /* Local copy may be out dated. Reload, and retry. */ + iLocalWaitingThreads = pxCond->iWaitingThreads; } return 0; @@ -193,8 +216,9 @@ int pthread_cond_timedwait( pthread_cond_t * cond, pthread_mutex_t * mutex, const struct timespec * abstime ) { + unsigned iLocalWaitingThreads; int iStatus = 0; - pthread_cond_internal_t * pxCond = ( pthread_cond_internal_t * ) ( *cond ); + pthread_cond_internal_t * pxCond = ( pthread_cond_internal_t * ) ( cond ); TickType_t xDelay = portMAX_DELAY; /* If the cond is uninitialized, perform initialization. */ @@ -203,16 +227,26 @@ int pthread_cond_timedwait( pthread_cond_t * cond, /* Convert abstime to a delay in TickType_t if provided. */ if( abstime != NULL ) { - iStatus = UTILS_AbsoluteTimespecToTicks( abstime, &xDelay ); + struct timespec xCurrentTime = { 0 }; + + /* Get current time */ + if( clock_gettime( CLOCK_REALTIME, &xCurrentTime ) != 0 ) + { + iStatus = EINVAL; + } + else + { + iStatus = UTILS_AbsoluteTimespecToDeltaTicks( abstime, &xCurrentTime, &xDelay ); + } } /* Increase the counter of threads blocking on condition variable, then * unlock mutex. */ if( iStatus == 0 ) { - ( void ) xSemaphoreTake( ( SemaphoreHandle_t ) &pxCond->xCondMutex, portMAX_DELAY ); - pxCond->iWaitingThreads++; - ( void ) xSemaphoreGive( ( SemaphoreHandle_t ) &pxCond->xCondMutex ); + /* Atomically increments thread waiting by 1, and + * stores number of threads waiting before increment. */ + iLocalWaitingThreads = Atomic_Increment_u32( ( uint32_t * ) &pxCond->iWaitingThreads ); iStatus = pthread_mutex_unlock( mutex ); } @@ -232,11 +266,21 @@ int pthread_cond_timedwait( pthread_cond_t * cond, iStatus = ETIMEDOUT; ( void ) pthread_mutex_lock( mutex ); - ( void ) xSemaphoreTake( ( SemaphoreHandle_t ) &pxCond->xCondMutex, portMAX_DELAY ); - pxCond->iWaitingThreads--; - ( void ) xSemaphoreGive( ( SemaphoreHandle_t ) &pxCond->xCondMutex ); + /* Atomically decrements thread waiting by 1. + * If iLocalWaitingThreads is updated by other thread(s) in between, + * this implementation guarantees to decrement by 1 based on the + * value currently in pxCond->iWaitingThreads. */ + prvTestAndDecrement( pxCond, iLocalWaitingThreads + 1 ); } } + else + { + /* Atomically decrements thread waiting by 1. + * If iLocalWaitingThreads is updated by other thread(s) in between, + * this implementation guarantees to decrement by 1 based on the + * value currently in pxCond->iWaitingThreads. */ + prvTestAndDecrement( pxCond, iLocalWaitingThreads + 1 ); + } return iStatus; } @@ -247,4 +291,4 @@ int pthread_cond_wait( pthread_cond_t * cond, pthread_mutex_t * mutex ) { return pthread_cond_timedwait( cond, mutex, NULL ); -} +} \ No newline at end of file diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_mutex.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_mutex.c index 4b63974..0ea3aeb 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_mutex.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_mutex.c @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS POSIX V1.1.0 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -30,7 +30,7 @@ /* C standard library includes. */ #include -#include +#include /* FreeRTOS+POSIX includes. */ #include "FreeRTOS_POSIX.h" @@ -96,13 +96,12 @@ static void prvInitializeStaticMutex( pthread_mutex_internal_t * pxMutex ) int pthread_mutex_destroy( pthread_mutex_t * mutex ) { - pthread_mutex_internal_t * pxMutex = ( pthread_mutex_internal_t * ) ( *mutex ); + pthread_mutex_internal_t * pxMutex = ( pthread_mutex_internal_t * ) ( mutex ); /* Free resources in use by the mutex. */ if( pxMutex->xTaskOwner == NULL ) { vSemaphoreDelete( ( SemaphoreHandle_t ) &pxMutex->xMutex ); - vPortFree( pxMutex ); } return 0; @@ -114,10 +113,7 @@ int pthread_mutex_init( pthread_mutex_t * mutex, const pthread_mutexattr_t * attr ) { int iStatus = 0; - pthread_mutex_internal_t * pxMutex = NULL; - - /* Allocate memory for new mutex object. */ - pxMutex = ( pthread_mutex_internal_t * ) pvPortMalloc( sizeof( pthread_mutex_internal_t ) ); + pthread_mutex_internal_t * pxMutex = ( pthread_mutex_internal_t * ) mutex; if( pxMutex == NULL ) { @@ -127,8 +123,7 @@ int pthread_mutex_init( pthread_mutex_t * mutex, if( iStatus == 0 ) { - /* Clear the newly-allocated mutex. */ - ( void ) memset( pxMutex, 0x00, sizeof( pthread_mutex_internal_t ) ); + *pxMutex = FREERTOS_POSIX_MUTEX_INITIALIZER; /* No attributes given, use default attributes. */ if( attr == NULL ) @@ -138,7 +133,7 @@ int pthread_mutex_init( pthread_mutex_t * mutex, /* Otherwise, use provided attributes. */ else { - pxMutex->xAttr = *( ( pthread_mutexattr_internal_t * ) ( *attr ) ); + pxMutex->xAttr = *( ( pthread_mutexattr_internal_t * ) ( attr ) ); } /* Call the correct FreeRTOS mutex creation function based on mutex type. */ @@ -164,7 +159,6 @@ int pthread_mutex_init( pthread_mutex_t * mutex, { /* Mutex successfully created. */ pxMutex->xIsInitialized = pdTRUE; - *mutex = ( pthread_mutex_t ) pxMutex; } } @@ -184,7 +178,7 @@ int pthread_mutex_timedlock( pthread_mutex_t * mutex, const struct timespec * abstime ) { int iStatus = 0; - pthread_mutex_internal_t * pxMutex = ( pthread_mutex_internal_t * ) ( *mutex ); + pthread_mutex_internal_t * pxMutex = ( pthread_mutex_internal_t * ) ( mutex ); TickType_t xDelay = portMAX_DELAY; BaseType_t xFreeRTOSMutexTakeStatus = pdFALSE; @@ -197,7 +191,17 @@ int pthread_mutex_timedlock( pthread_mutex_t * mutex, /* Convert abstime to a delay in TickType_t if provided. */ if( abstime != NULL ) { - iStatus = UTILS_AbsoluteTimespecToTicks( abstime, &xDelay ); + struct timespec xCurrentTime = { 0 }; + + /* Get current time */ + if( clock_gettime( CLOCK_REALTIME, &xCurrentTime ) != 0 ) + { + iStatus = EINVAL; + } + else + { + iStatus = UTILS_AbsoluteTimespecToDeltaTicks( abstime, &xCurrentTime, &xDelay ); + } /* If abstime was in the past, still attempt to lock the mutex without * blocking, per POSIX spec. */ @@ -272,7 +276,7 @@ int pthread_mutex_trylock( pthread_mutex_t * mutex ) int pthread_mutex_unlock( pthread_mutex_t * mutex ) { int iStatus = 0; - pthread_mutex_internal_t * pxMutex = ( pthread_mutex_internal_t * ) ( *mutex ); + pthread_mutex_internal_t * pxMutex = ( pthread_mutex_internal_t * ) ( mutex ); /* If mutex in uninitialized, perform initialization. */ prvInitializeStaticMutex( pxMutex ); @@ -287,6 +291,10 @@ int pthread_mutex_unlock( pthread_mutex_t * mutex ) if( iStatus == 0 ) { + /* Suspend the scheduler so that + * mutex is unlocked AND owner is updated atomically */ + vTaskSuspendAll(); + /* Call the correct FreeRTOS mutex unlock function based on mutex type. */ if( pxMutex->xAttr.iType == PTHREAD_MUTEX_RECURSIVE ) { @@ -300,6 +308,9 @@ int pthread_mutex_unlock( pthread_mutex_t * mutex ) /* Update the owner of the mutex. A recursive mutex may still have an * owner, so it should be updated with xSemaphoreGetMutexHolder. */ pxMutex->xTaskOwner = xSemaphoreGetMutexHolder( ( SemaphoreHandle_t ) &pxMutex->xMutex ); + + /* Resume the scheduler */ + ( void ) xTaskResumeAll(); } return iStatus; @@ -309,8 +320,7 @@ int pthread_mutex_unlock( pthread_mutex_t * mutex ) int pthread_mutexattr_destroy( pthread_mutexattr_t * attr ) { - /* Free mutex attributes object. */ - vPortFree( *attr ); + ( void ) attr; return 0; } @@ -320,7 +330,7 @@ int pthread_mutexattr_destroy( pthread_mutexattr_t * attr ) int pthread_mutexattr_gettype( const pthread_mutexattr_t * attr, int * type ) { - pthread_mutexattr_internal_t * pxAttr = ( pthread_mutexattr_internal_t * ) ( *attr ); + pthread_mutexattr_internal_t * pxAttr = ( pthread_mutexattr_internal_t * ) ( attr ); *type = pxAttr->iType; @@ -331,24 +341,9 @@ int pthread_mutexattr_gettype( const pthread_mutexattr_t * attr, int pthread_mutexattr_init( pthread_mutexattr_t * attr ) { - int iStatus = 0; + *( ( pthread_mutexattr_internal_t * ) ( attr ) ) = xDefaultMutexAttributes; - /* Allocate memory for new mutex attributes object. */ - *attr = pvPortMalloc( sizeof( pthread_mutexattr_internal_t ) ); - - if( *attr == NULL ) - { - /* No memory. */ - iStatus = ENOMEM; - } - - /* Set the mutex attributes to default values. */ - if( iStatus == 0 ) - { - *( ( pthread_mutexattr_internal_t * ) ( *attr ) ) = xDefaultMutexAttributes; - } - - return iStatus; + return 0; } /*-----------------------------------------------------------*/ @@ -357,7 +352,7 @@ int pthread_mutexattr_settype( pthread_mutexattr_t * attr, int type ) { int iStatus = 0; - pthread_mutexattr_internal_t * pxAttr = ( pthread_mutexattr_internal_t * ) ( *attr ); + pthread_mutexattr_internal_t * pxAttr = ( pthread_mutexattr_internal_t * ) ( attr ); switch( type ) { diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_sched.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_sched.c index a8b6a3a..7916a99 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_sched.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_sched.c @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS POSIX V1.1.0 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -44,9 +44,21 @@ int sched_get_priority_max( int policy ) /*-----------------------------------------------------------*/ +int sched_get_priority_min( int policy ) +{ + /* Silence warnings about unused parameters. */ + ( void ) policy; + + return tskIDLE_PRIORITY; +} + +/*-----------------------------------------------------------*/ + int sched_yield( void ) { taskYIELD(); return 0; } + +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_semaphore.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_semaphore.c index 07f4cfe..cee43ca 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_semaphore.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_semaphore.c @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS POSIX V1.1.0 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -37,24 +37,17 @@ #include "FreeRTOS_POSIX/semaphore.h" #include "FreeRTOS_POSIX/utils.h" -/** - * @brief Semaphore type. - */ -typedef struct -{ - StaticSemaphore_t xSemaphore; /**< FreeRTOS semaphore. */ -} sem_internal_t; +#include "atomic.h" /*-----------------------------------------------------------*/ int sem_destroy( sem_t * sem ) { - sem_internal_t * pxSem = ( sem_internal_t * ) ( *sem ); + sem_internal_t * pxSem = ( sem_internal_t * ) ( sem ); /* Free the resources in use by the semaphore. */ vSemaphoreDelete( ( SemaphoreHandle_t ) &pxSem->xSemaphore ); - vPortFree( pxSem ); return 0; } @@ -64,10 +57,14 @@ int sem_destroy( sem_t * sem ) int sem_getvalue( sem_t * sem, int * sval ) { - sem_internal_t * pxSem = ( sem_internal_t * ) ( *sem ); + sem_internal_t * pxSem = ( sem_internal_t * ) ( sem ); - /* Get the semaphore count using the FreeRTOS API. */ - *sval = ( int ) uxSemaphoreGetCount( ( SemaphoreHandle_t ) &pxSem->xSemaphore ); + /* Get value does not need atomic operation, since -- Open Group + * states "the updated value represents an actual semaphore value that + * occurred at some unspecified time during the call, but it need not be the + * actual value of the semaphore when it is returned to the calling process." + */ + *sval = pxSem->value; return 0; } @@ -79,7 +76,7 @@ int sem_init( sem_t * sem, unsigned value ) { int iStatus = 0; - sem_internal_t * pxSem = NULL; + sem_internal_t * pxSem = ( sem_internal_t * ) ( sem ); /* Silence warnings about unused parameters. */ ( void ) pshared; @@ -91,24 +88,17 @@ int sem_init( sem_t * sem, iStatus = -1; } - /* Allocate memory for a new semaphore. */ + /* value is guaranteed to not exceed INT32_MAX, which is the default value of SEM_VALUE_MAX (0x7FFFU). */ + pxSem->value = ( int ) value; + + /* Create the FreeRTOS semaphore. + * This is only used to queue threads when no semaphore is available. + * Initializing with semaphore initial count zero. + * This call will not fail because the memory for the semaphore has already been allocated. + */ if( iStatus == 0 ) { - pxSem = pvPortMalloc( sizeof( sem_internal_t ) ); - - if( pxSem == NULL ) - { - errno = ENOSPC; - iStatus = -1; - } - } - - /* Create the FreeRTOS semaphore. This call will not fail because the - * memory for the semaphore has already been allocated. */ - if( iStatus == 0 ) - { - ( void ) xSemaphoreCreateCountingStatic( SEM_VALUE_MAX, value, &pxSem->xSemaphore ); - *sem = pxSem; + ( void ) xSemaphoreCreateCountingStatic( SEM_VALUE_MAX, 0, &pxSem->xSemaphore ); } return iStatus; @@ -118,10 +108,18 @@ int sem_init( sem_t * sem, int sem_post( sem_t * sem ) { - sem_internal_t * pxSem = ( sem_internal_t * ) ( *sem ); + sem_internal_t * pxSem = ( sem_internal_t * ) ( sem ); - /* Give the semaphore using the FreeRTOS API. */ - ( void ) xSemaphoreGive( ( SemaphoreHandle_t ) &pxSem->xSemaphore ); + int iPreviouValue = Atomic_Increment_u32( ( uint32_t * ) &pxSem->value ); + + /* If previous semaphore value is equal or larger than zero, there is no + * thread waiting for this semaphore. Otherwise (<0), call FreeRTOS interface + * to wake up a thread. */ + if( iPreviouValue < 0 ) + { + /* Give the semaphore using the FreeRTOS API. */ + ( void ) xSemaphoreGive( ( SemaphoreHandle_t ) &pxSem->xSemaphore ); + } return 0; } @@ -132,7 +130,7 @@ int sem_timedwait( sem_t * sem, const struct timespec * abstime ) { int iStatus = 0; - sem_internal_t * pxSem = ( sem_internal_t * ) ( *sem ); + sem_internal_t * pxSem = ( sem_internal_t * ) ( sem ); TickType_t xDelay = portMAX_DELAY; if( abstime != NULL ) @@ -146,7 +144,17 @@ int sem_timedwait( sem_t * sem, } else { - iStatus = UTILS_AbsoluteTimespecToTicks( abstime, &xDelay ); + struct timespec xCurrentTime = { 0 }; + + /* Get current time */ + if( clock_gettime( CLOCK_REALTIME, &xCurrentTime ) != 0 ) + { + iStatus = EINVAL; + } + else + { + iStatus = UTILS_AbsoluteTimespecToDeltaTicks( abstime, &xCurrentTime, &xDelay ); + } /* If abstime was in the past, still attempt to take the semaphore without * blocking, per POSIX spec. */ @@ -157,16 +165,37 @@ int sem_timedwait( sem_t * sem, } } - /* Take the semaphore using the FreeRTOS API. */ - if( xSemaphoreTake( ( SemaphoreHandle_t ) &pxSem->xSemaphore, - xDelay ) != pdTRUE ) + int iPreviousValue = Atomic_Decrement_u32( ( uint32_t * ) &pxSem->value ); + + /* If previous semaphore value is larger than zero, the thread entering this function call + * can take the semaphore without yielding. Else (<=0), calling into FreeRTOS API to yield. + */ + if( iPreviousValue > 0 ) { - errno = iStatus; - iStatus = -1; + /* Under no circumstance shall the function fail with a timeout if the semaphore can be locked immediately. */ + iStatus = 0; } else { - iStatus = 0; + /* Take the semaphore using the FreeRTOS API. */ + if( xSemaphoreTake( ( SemaphoreHandle_t ) &pxSem->xSemaphore, + xDelay ) != pdTRUE ) + { + if( iStatus == 0 ) + { + errno = ETIMEDOUT; + } + else + { + errno = iStatus; + } + + iStatus = -1; + } + else + { + iStatus = 0; + } } return iStatus; diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_timer.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_timer.c index 0b00804..f790e83 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_timer.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_timer.c @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS POSIX V1.1.0 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -42,13 +42,9 @@ /* FreeRTOS timer include. */ #include "timers.h" -/** - * #brief Timespec zero check macros. - */ -/**@{ */ +/* Timespec zero check macros. */ #define TIMESPEC_IS_ZERO( xTimespec ) ( xTimespec.tv_sec == 0 && xTimespec.tv_nsec == 0 ) /**< Check for 0. */ #define TIMESPEC_IS_NOT_ZERO( xTimespec ) ( !( TIMESPEC_IS_ZERO( xTimespec ) ) ) /**< Check for not 0. */ -/**@} */ /** * @brief Internal timer structure. @@ -66,7 +62,6 @@ void prvTimerCallback( TimerHandle_t xTimerHandle ) { timer_internal_t * pxTimer = ( timer_internal_t * ) pvTimerGetTimerID( xTimerHandle ); pthread_t xTimerNotificationThread; - pthread_attr_t xThreadAttributes; /* The value of the timer ID, set in timer_create, should not be NULL. */ configASSERT( pxTimer != NULL ); @@ -85,23 +80,11 @@ void prvTimerCallback( TimerHandle_t xTimerHandle ) /* Create the timer notification thread if requested. */ if( pxTimer->xTimerEvent.sigev_notify == SIGEV_THREAD ) { - /* By default, create a detached thread. But if the user has provided - * thread attributes, use the provided attributes. */ + /* if the user has provided thread attributes, create a thread + * with the provided attributes. Otherwise dispatch callback directly */ if( pxTimer->xTimerEvent.sigev_notify_attributes == NULL ) { - if( pthread_attr_init( &xThreadAttributes ) == 0 ) - { - if( pthread_attr_setdetachstate( &xThreadAttributes, - PTHREAD_CREATE_DETACHED ) == 0 ) - { - ( void ) pthread_create( &xTimerNotificationThread, - &xThreadAttributes, - ( void * ( * )( void * ) )pxTimer->xTimerEvent.sigev_notify_function, - pxTimer->xTimerEvent.sigev_value.sival_ptr ); - } - - ( void ) pthread_attr_destroy( &xThreadAttributes ); - } + ( *pxTimer->xTimerEvent.sigev_notify_function )( pxTimer->xTimerEvent.sigev_value ); } else { @@ -196,7 +179,9 @@ int timer_delete( timer_t timerid ) int timer_getoverrun( timer_t timerid ) { - ( void ) timerid; + /* Silence warnings about unused parameters. */ + ( void ) timerid; + return 0; } @@ -256,7 +241,29 @@ int timer_settime( timer_t timerid, /* Absolute timeout. */ if( ( flags & TIMER_ABSTIME ) == TIMER_ABSTIME ) { - ( void ) UTILS_AbsoluteTimespecToTicks( &value->it_value, &xNextTimerExpiration ); + struct timespec xCurrentTime = { 0 }; + + /* Get current time */ + if( clock_gettime( CLOCK_REALTIME, &xCurrentTime ) != 0 ) + { + iStatus = EINVAL; + } + else + { + iStatus = UTILS_AbsoluteTimespecToDeltaTicks( &value->it_value, &xCurrentTime, &xNextTimerExpiration ); + } + + /* Make sure xNextTimerExpiration is zero in case we got negative time difference */ + if( iStatus != 0 ) + { + xNextTimerExpiration = 0; + + if( iStatus == ETIMEDOUT ) + { + /* Set Status to 0 as absolute time is past is treated as expiry but not an error */ + iStatus = 0; + } + } } /* Relative timeout. */ else diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_unistd.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_unistd.c index 2f363e9..0d3d914 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_unistd.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_unistd.c @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS POSIX V1.1.0 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_utils.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_utils.c index 78a2384..c121587 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_utils.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_utils.c @@ -1,5 +1,5 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 + * Amazon FreeRTOS POSIX V1.1.0 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -30,6 +30,7 @@ /* C standard library includes. */ #include +#include /* FreeRTOS+POSIX includes. */ #include "FreeRTOS_POSIX.h" @@ -58,35 +59,34 @@ size_t UTILS_strnlen( const char * const pcString, /*-----------------------------------------------------------*/ -int UTILS_AbsoluteTimespecToTicks( const struct timespec * const pxAbsoluteTime, - TickType_t * const pxResult ) +int UTILS_AbsoluteTimespecToDeltaTicks( const struct timespec * const pxAbsoluteTime, + const struct timespec * const pxCurrentTime, + TickType_t * const pxResult ) { int iStatus = 0; - struct timespec xCurrentTime = { 0 }, xDifference = { 0 }; + struct timespec xDifference = { 0 }; /* Check parameters. */ - if( ( pxAbsoluteTime == NULL ) || ( pxResult == NULL ) ) + if( ( pxAbsoluteTime == NULL ) || ( pxCurrentTime == NULL ) || ( pxResult == NULL ) ) { iStatus = EINVAL; } - /* Get the current time. */ + /* Calculate the difference between the current time and absolute time. */ if( iStatus == 0 ) { - if( clock_gettime( CLOCK_REALTIME, &xCurrentTime ) != 0 ) - { - iStatus = errno; - } - } + iStatus = UTILS_TimespecSubtract( pxAbsoluteTime, pxCurrentTime, &xDifference ); - /* Calculate the difference between the current time and pxAbsoluteTime. */ - if( iStatus == 0 ) - { - if( UTILS_TimespecSubtract( &xDifference, pxAbsoluteTime, &xCurrentTime ) != 0 ) + if( iStatus == 1 ) { /* pxAbsoluteTime was in the past. */ iStatus = ETIMEDOUT; } + else if( iStatus == -1 ) + { + /* error */ + iStatus = EINVAL; + } } /* Convert the time difference to ticks. */ @@ -104,7 +104,7 @@ int UTILS_TimespecToTicks( const struct timespec * const pxTimespec, TickType_t * const pxResult ) { int iStatus = 0; - uint64_t ullTotalTicks = 0; + int64_t llTotalTicks = 0; long lNanoseconds = 0; /* Check parameters. */ @@ -112,7 +112,7 @@ int UTILS_TimespecToTicks( const struct timespec * const pxTimespec, { iStatus = EINVAL; } - else if( ( pxTimespec != NULL ) && ( UTILS_ValidateTimespec( pxTimespec ) == false ) ) + else if( ( iStatus == 0 ) && ( UTILS_ValidateTimespec( pxTimespec ) == false ) ) { iStatus = EINVAL; } @@ -120,7 +120,7 @@ int UTILS_TimespecToTicks( const struct timespec * const pxTimespec, if( iStatus == 0 ) { /* Convert timespec.tv_sec to ticks. */ - ullTotalTicks = ( uint64_t ) configTICK_RATE_HZ * ( uint64_t ) ( pxTimespec->tv_sec ); + llTotalTicks = ( int64_t ) configTICK_RATE_HZ * ( pxTimespec->tv_sec ); /* Convert timespec.tv_nsec to ticks. This value does not have to be checked * for overflow because a valid timespec has 0 <= tv_nsec < 1000000000 and @@ -129,10 +129,30 @@ int UTILS_TimespecToTicks( const struct timespec * const pxTimespec, ( long ) ( pxTimespec->tv_nsec % ( long ) NANOSECONDS_PER_TICK != 0 ); /* Add 1 to round up if needed. */ /* Add the nanoseconds to the total ticks. */ - ullTotalTicks += ( uint64_t ) lNanoseconds; + llTotalTicks += ( int64_t ) lNanoseconds; + + /* Check for overflow */ + if( llTotalTicks < 0 ) + { + iStatus = EINVAL; + } + else + { + /* check if TickType_t is 32 bit or 64 bit */ + uint32_t ulTickTypeSize = sizeof( TickType_t ); + + /* check for downcast overflow */ + if( ulTickTypeSize == sizeof( uint32_t ) ) + { + if( llTotalTicks > UINT_MAX ) + { + iStatus = EINVAL; + } + } + } /* Write result. */ - *pxResult = ( TickType_t ) ullTotalTicks; + *pxResult = ( TickType_t ) llTotalTicks; } return iStatus; @@ -162,71 +182,188 @@ void UTILS_NanosecondsToTimespec( int64_t llSource, /*-----------------------------------------------------------*/ -int UTILS_TimespecAdd( struct timespec * const pxResult, - const struct timespec * const x, - const struct timespec * const y ) +int UTILS_TimespecAdd( const struct timespec * const x, + const struct timespec * const y, + struct timespec * const pxResult ) { - int64_t llResult64 = 0; + int64_t llPartialSec = 0; + int iStatus = 0; /* Check parameters. */ if( ( pxResult == NULL ) || ( x == NULL ) || ( y == NULL ) ) { - return -1; + iStatus = -1; } - /* Perform addition. */ - llResult64 = ( ( ( int64_t ) ( x->tv_sec ) * NANOSECONDS_PER_SECOND ) + ( int64_t ) ( x->tv_nsec ) ) - + ( ( ( int64_t ) ( y->tv_sec ) * NANOSECONDS_PER_SECOND ) + ( int64_t ) ( y->tv_nsec ) ); + if( iStatus == 0 ) + { + /* Perform addition. */ + pxResult->tv_nsec = x->tv_nsec + y->tv_nsec; - /* Convert result to timespec. */ - UTILS_NanosecondsToTimespec( llResult64, pxResult ); + /* check for overflow in case nsec value was invalid */ + if( pxResult->tv_nsec < 0 ) + { + iStatus = 1; + } + else + { + llPartialSec = ( pxResult->tv_nsec ) / NANOSECONDS_PER_SECOND; + pxResult->tv_nsec = ( pxResult->tv_nsec ) % NANOSECONDS_PER_SECOND; + pxResult->tv_sec = x->tv_sec + y->tv_sec + llPartialSec; - return ( int ) ( llResult64 < 0LL ); + /* check for overflow */ + if( pxResult->tv_sec < 0 ) + { + iStatus = 1; + } + } + } + + return iStatus; } /*-----------------------------------------------------------*/ -int UTILS_TimespecAddNanoseconds( struct timespec * const pxResult, - const struct timespec * const x, - int64_t llNanoseconds ) +int UTILS_TimespecAddNanoseconds( const struct timespec * const x, + int64_t llNanoseconds, + struct timespec * const pxResult ) { - struct timespec y = { .tv_sec = ( time_t ) 0, .tv_nsec = 0L }; + int64_t llTotalNSec = 0; + int iStatus = 0; /* Check parameters. */ if( ( pxResult == NULL ) || ( x == NULL ) ) { - return -1; + iStatus = -1; } - /* Convert llNanoseconds to a timespec. */ - UTILS_NanosecondsToTimespec( llNanoseconds, &y ); + if( iStatus == 0 ) + { + /* add nano seconds */ + llTotalNSec = x->tv_nsec + llNanoseconds; - /* Perform addition. */ - return UTILS_TimespecAdd( pxResult, x, &y ); + /* check for nano seconds overflow */ + if( llTotalNSec < 0 ) + { + iStatus = 1; + } + else + { + pxResult->tv_nsec = llTotalNSec % NANOSECONDS_PER_SECOND; + pxResult->tv_sec = x->tv_sec + ( llTotalNSec / NANOSECONDS_PER_SECOND ); + + /* check for seconds overflow */ + if( pxResult->tv_sec < 0 ) + { + iStatus = 1; + } + } + } + + return iStatus; } /*-----------------------------------------------------------*/ -int UTILS_TimespecSubtract( struct timespec * const pxResult, - const struct timespec * const x, - const struct timespec * const y ) +int UTILS_TimespecSubtract( const struct timespec * const x, + const struct timespec * const y, + struct timespec * const pxResult ) { - int64_t llResult64 = 0; + int iCompareResult = 0; + int iStatus = 0; /* Check parameters. */ if( ( pxResult == NULL ) || ( x == NULL ) || ( y == NULL ) ) { - return -1; + iStatus = -1; } - /* Perform addition. */ - llResult64 = ( ( ( int64_t ) ( x->tv_sec ) * NANOSECONDS_PER_SECOND ) + ( int64_t ) ( x->tv_nsec ) ) - - ( ( ( int64_t ) ( y->tv_sec ) * NANOSECONDS_PER_SECOND ) + ( int64_t ) ( y->tv_nsec ) ); + if( iStatus == 0 ) + { + iCompareResult = UTILS_TimespecCompare( x, y ); - /* Convert result to timespec. */ - UTILS_NanosecondsToTimespec( llResult64, pxResult ); + /* if x < y then result would be negative, return 1 */ + if( iCompareResult == -1 ) + { + iStatus = 1; + } + else if( iCompareResult == 0 ) + { + /* if times are the same return zero */ + pxResult->tv_sec = 0; + pxResult->tv_nsec = 0; + } + else + { + /* If x > y Perform subtraction. */ + pxResult->tv_sec = x->tv_sec - y->tv_sec; + pxResult->tv_nsec = x->tv_nsec - y->tv_nsec; - return ( int ) ( llResult64 < 0LL ); + /* check if nano seconds value needs to borrow */ + if( pxResult->tv_nsec < 0 ) + { + /* Based on comparison, tv_sec > 0 */ + pxResult->tv_sec--; + pxResult->tv_nsec += ( long ) NANOSECONDS_PER_SECOND; + } + + /* if nano second is negative after borrow, it is an overflow error */ + if( pxResult->tv_nsec < 0 ) + { + iStatus = -1; + } + } + } + + return iStatus; +} + +/*-----------------------------------------------------------*/ + +int UTILS_TimespecCompare( const struct timespec * const x, + const struct timespec * const y ) +{ + int iStatus = 0; + + /* Check parameters */ + if( ( x == NULL ) && ( y == NULL ) ) + { + iStatus = 0; + } + else if( y == NULL ) + { + iStatus = 1; + } + else if( x == NULL ) + { + iStatus = -1; + } + else if( x->tv_sec > y->tv_sec ) + { + iStatus = 1; + } + else if( x->tv_sec < y->tv_sec ) + { + iStatus = -1; + } + else + { + /* seconds are equal compare nano seconds */ + if( x->tv_nsec > y->tv_nsec ) + { + iStatus = 1; + } + else if( x->tv_nsec < y->tv_nsec ) + { + iStatus = -1; + } + else + { + iStatus = 0; + } + } + + return iStatus; } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/errno.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/errno.h index b9fcc44..136e04b 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/errno.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/errno.h @@ -1,6 +1,6 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Amazon FreeRTOS POSIX V1.1.0 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -56,41 +56,39 @@ #undef ETIMEDOUT /** - * @brief posix_errno Definition of POSIX errnos. + * @name Definition of POSIX errnos. */ /**@{ */ -#define EPERM 1 /**< Operation not permitted. */ -#define ENOENT 2 /**< No such file or directory. */ -#define EBADF 9 /**< Bad file descriptor. */ -#define EAGAIN 11 /**< Resource unavailable, try again. */ -#define ENOMEM 12 /**< Not enough space. */ -#define EEXIST 17 /**< File exists. */ -#define EBUSY 16 /**< Device or resource busy. */ -#define EINVAL 22 /**< Invalid argument. */ -#define ENOSPC 28 /**< No space left on device. */ -#define ERANGE 34 /**< Result too large. */ -#define ENAMETOOLONG 36 /**< File name too long. */ -#define EDEADLK 45 /**< Resource deadlock would occur. */ -#define EOVERFLOW 75 /**< Value too large to be stored in data type. */ -#define ENOSYS 88 /**< Function not supported. */ -#define EMSGSIZE 90 /**< Message too long. */ -#define ENOTSUP 95 /**< Operation not supported. */ -#define ETIMEDOUT 116 /**< Connection timed out. */ +#define EPERM 1 /**< Operation not permitted. */ +#define ENOENT 2 /**< No such file or directory. */ +#define EBADF 9 /**< Bad file descriptor. */ +#define EAGAIN 11 /**< Resource unavailable, try again. */ +#define ENOMEM 12 /**< Not enough space. */ +#define EEXIST 17 /**< File exists. */ +#define EBUSY 16 /**< Device or resource busy. */ +#define EINVAL 22 /**< Invalid argument. */ +#define ENOSPC 28 /**< No space left on device. */ +#define ERANGE 34 /**< Result too large. */ +#define ENAMETOOLONG 36 /**< File name too long. */ +#define EDEADLK 45 /**< Resource deadlock would occur. */ +#define EOVERFLOW 75 /**< Value too large to be stored in data type. */ +#define ENOSYS 88 /**< Function not supported. */ +#define EMSGSIZE 90 /**< Message too long. */ +#define ENOTSUP 95 /**< Operation not supported. */ +#define ETIMEDOUT 116 /**< Connection timed out. */ /**@} */ /** * @name System Variable * - * @brief Define FreeRTOS+POSIX errno, if enabled. + * @brief Define FreeRTOS+POSIX errno, if enabled. * Set configUSE_POSIX_ERRNO to enable, and clear to disable. See FreeRTOS.h. * * @{ */ #if ( configUSE_POSIX_ERRNO == 1 ) extern int FreeRTOS_errno; - #ifndef errno - #define errno FreeRTOS_errno - #endif + #define errno FreeRTOS_errno #endif /**@} */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/fcntl.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/fcntl.h index c0400c4..1e921ce 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/fcntl.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/fcntl.h @@ -1,6 +1,6 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Amazon FreeRTOS POSIX V1.1.0 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -33,11 +33,10 @@ #ifndef _FREERTOS_POSIX_FCNTL_H_ #define _FREERTOS_POSIX_FCNTL_H_ -/** +/** * @name File creation flags for use in the oflag value to open() and openat(). - * - * @{ */ +/**@{ */ #define O_CLOEXEC 0x0001 /**< Close the file descriptor upon exec(). */ #define O_CREAT 0x0002 /**< Create file if it does not exist. */ #define O_DIRECTORY 0x0004 /**< Fail if file is a non-directory file. */ @@ -48,11 +47,10 @@ #define O_TTY_INIT 0x0080 /**< termios structure provides conforming behavior. */ /**@} */ -/** +/** * @name File status flags for open(), openat(), and fcntl(). - * - * @{ */ +/**@{ */ #define O_APPEND 0x0100 /**< Set append mode. */ #define O_DSYNC 0x0200 /**< Write according to synchronized I/O data integrity completion. */ #define O_NONBLOCK 0x0400 /**< Non-blocking mode. */ @@ -62,21 +60,20 @@ /** * @name Mask for file access modes. - * - * @{ */ +/**@{ */ #define O_ACCMODE 0xF000 +/**@} */ /** * @name File access modes for open(), openat(), and fcntl(). - * - * @{ */ -#define O_EXEC 0x1000 /**< Open for execute only (non-directory files). */ -#define O_RDONLY 0x2000 /**< Open for reading only. */ -#define O_RDWR 0xA000 /**< Open for reading and writing. */ -#define O_SEARCH 0x4000 /**< Open directory for search only. */ -#define O_WRONLY 0x8000 /**< Open for writing only. */ +/**@{ */ +#define O_EXEC 0x1000 /**< Open for execute only (non-directory files). */ +#define O_RDONLY 0x2000 /**< Open for reading only. */ +#define O_RDWR 0xA000 /**< Open for reading and writing. */ +#define O_SEARCH 0x4000 /**< Open directory for search only. */ +#define O_WRONLY 0x8000 /**< Open for writing only. */ /**@} */ #endif /* ifndef _FREERTOS_POSIX_FCNTL_H_ */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/mqueue.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/mqueue.h index 219e08d..7cbf01c 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/mqueue.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/mqueue.h @@ -1,6 +1,6 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Amazon FreeRTOS POSIX V1.1.0 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -59,10 +59,10 @@ struct mq_attr * * @retval 0 - Upon successful completion * @retval -1 - A error occurred. errno is also set. - * - * \sideeffect Possible errno values + * + * @sideeffect Possible errno values *
- * EBADF - The mqdes argument is not a valid message queue descriptor. + * EBADF - The mqdes argument is not a valid message queue descriptor. */ int mq_close( mqd_t mqdes ); @@ -70,11 +70,11 @@ int mq_close( mqd_t mqdes ); * @brief Get message queue attributes. * * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_getattr.html - * + * * @retval 0 - Upon successful completion * @retval -1 - A error occurred. errno is also set. * - * \sideeffect Possible errno values + * @sideeffect Possible errno values *
* DBADF - The mqdes argument is not a valid message queue descriptor. */ @@ -86,21 +86,21 @@ int mq_getattr( mqd_t mqdes, * * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_open.html * - * @note Supported name pattern: leading <slash> character in name is always required; - * the maximum length (excluding null-terminator) of the name argument can be NAME_MAX. - * The default value of NAME_MAX in FreeRTOS_POSIX_portable_default.h is 64, which can be + * @note Supported name pattern: leading <slash> character in name is always required; + * the maximum length (excluding null-terminator) of the name argument can be NAME_MAX. + * The default value of NAME_MAX in FreeRTOS_POSIX_portable_default.h is 64, which can be * overwritten by user. * @note mode argument is not supported. - * @note Supported oflags: O_RDWR, O_CREAT, O_EXCL, and O_NONBLOCK. + * @note Supported oflags: O_RDWR, O_CREAT, O_EXCL, and O_NONBLOCK. * * @retval Message queue descriptor -- Upon successful completion - * @retval (mqd_t) - 1 -- An error occurred. errno is also set. + * @retval (mqd_t) - 1 -- An error occurred. errno is also set. * - * \sideeffect Possible errno values + * @sideeffect Possible errno values *
- * EINVAL - name argument is invalid (not following name pattern), - * OR if O_CREAT is specified in oflag with attr argument not NULL and either mq_maxmsg or mq_msgsize is equal to or less than zero, - * OR either O_CREAT or O_EXCL is not set and a queue with the same name is unlinked but pending to be removed. + * EINVAL - name argument is invalid (not following name pattern), + * OR if O_CREAT is specified in oflag with attr argument not NULL and either mq_maxmsg or mq_msgsize is equal to or less than zero, + * OR either O_CREAT or O_EXCL is not set and a queue with the same name is unlinked but pending to be removed. *
* EEXIST - O_CREAT and O_EXCL are set and the named message queue already exists. *
@@ -119,18 +119,18 @@ mqd_t mq_open( const char * name, * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_receive.html * * @note msg_prio argument is not supported. Messages are not checked for corruption. - * - * @retval The length of the selected message in bytes - Upon successful completion. + * + * @retval The length of the selected message in bytes - Upon successful completion. * The message is removed from the queue * @retval -1 - An error occurred. errno is also set. * - * \sideeffect Possible errno values + * @sideeffect Possible errno values *
* EBADF - The mqdes argument is not a valid message queue descriptor open for reading. *
* EMSGSIZE - The specified message buffer size, msg_len, is less than the message size attribute of the message queue. *
- * ETIMEDOUT - The O_NONBLOCK flag was not set when the message queue was opened, + * ETIMEDOUT - The O_NONBLOCK flag was not set when the message queue was opened, * but no message arrived on the queue before the specified timeout expired. *
* EAGAIN - O_NONBLOCK was set in the message description associated with mqdes, and the specified message queue is empty. @@ -146,23 +146,22 @@ ssize_t mq_receive( mqd_t mqdes, * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_send.html * * @note msg_prio argument is not supported. - * + * * @retval 0 - Upon successful completion. - * @retval -1 - An error occurred. errno is also set. - * - * \sideeffect Possible errno values + * @retval -1 - An error occurred. errno is also set. + * + * @sideeffect Possible errno values *
* EBADF - The mqdes argument is not a valid message queue descriptor open for writing. *
- * EMSGSIZE - The specified message length, msg_len, exceeds the message size attribute of the message queue, + * EMSGSIZE - The specified message length, msg_len, exceeds the message size attribute of the message queue, * OR insufficient memory for the message to be sent. *
- * ETIMEDOUT - The O_NONBLOCK flag was not set when the message queue was opened, + * ETIMEDOUT - The O_NONBLOCK flag was not set when the message queue was opened, * but the timeout expired before the message could be added to the queue. *
- * EAGAIN - The O_NONBLOCK flag is set in the message queue description associated with mqdes, + * EAGAIN - The O_NONBLOCK flag is set in the message queue description associated with mqdes, * and the specified message queue is full. - * */ int mq_send( mqd_t mqdes, const char * msg_ptr, @@ -175,21 +174,21 @@ int mq_send( mqd_t mqdes, * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_timedreceive.html * * @note msg_prio argument is not supported. Messages are not checked for corruption. - * - * @retval The length of the selected message in bytes - Upon successful completion. + * + * @retval The length of the selected message in bytes - Upon successful completion. * The message is removed from the queue * @retval -1 - An error occurred. errno is also set. - * - * \sideeffect Possible errno values + * + * @sideeffect Possible errno values *
* EBADF - The mqdes argument is not a valid message queue descriptor open for reading. *
* EMSGSIZE - The specified message buffer size, msg_len, is less than the message size attribute of the message queue. *
- * EINVAL - The process or thread would have blocked, and the abstime parameter specified a nanoseconds field value + * EINVAL - The process or thread would have blocked, and the abstime parameter specified a nanoseconds field value * less than zero or greater than or equal to 1000 million. *
- * ETIMEDOUT - The O_NONBLOCK flag was not set when the message queue was opened, + * ETIMEDOUT - The O_NONBLOCK flag was not set when the message queue was opened, * but no message arrived on the queue before the specified timeout expired. *
* EAGAIN - O_NONBLOCK was set in the message description associated with mqdes, and the specified message queue is empty. @@ -206,26 +205,25 @@ ssize_t mq_timedreceive( mqd_t mqdes, * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_timedsend.html * * @note msg_prio argument is not supported. - * + * * @retval 0 - Upon successful completion. - * @retval -1 - An error occurred. errno is also set. - * - * \sideeffect Possible errno values + * @retval -1 - An error occurred. errno is also set. + * + * @sideeffect Possible errno values *
* EBADF - The mqdes argument is not a valid message queue descriptor open for writing. *
- * EMSGSIZE - The specified message length, msg_len, exceeds the message size attribute of the message queue, + * EMSGSIZE - The specified message length, msg_len, exceeds the message size attribute of the message queue, * OR insufficient memory for the message to be sent. *
- * EINVAL - The process or thread would have blocked, and the abstime parameter specified a nanoseconds field + * EINVAL - The process or thread would have blocked, and the abstime parameter specified a nanoseconds field * value less than zero or greater than or equal to 1000 million. *
- * ETIMEDOUT - The O_NONBLOCK flag was not set when the message queue was opened, + * ETIMEDOUT - The O_NONBLOCK flag was not set when the message queue was opened, * but the timeout expired before the message could be added to the queue. *
- * EAGAIN - The O_NONBLOCK flag is set in the message queue description associated with mqdes, + * EAGAIN - The O_NONBLOCK flag is set in the message queue description associated with mqdes, * and the specified message queue is full. - * */ int mq_timedsend( mqd_t mqdes, const char * msg_ptr, @@ -237,11 +235,11 @@ int mq_timedsend( mqd_t mqdes, * @brief Remove a message queue. * * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_unlink.html - * + * * @retval 0 - Upon successful completion. - * @retval -1 - An error occurred. errno is also set. - * - * \sideeffect Possible errno values + * @retval -1 - An error occurred. errno is also set. + * + * @sideeffect Possible errno values *
* EINVAL - name argument is invalid. Refer to requirements on name argument in mq_open(). *
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/pthread.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/pthread.h index 73b90aa..77f949a 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/pthread.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/pthread.h @@ -1,6 +1,6 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Amazon FreeRTOS POSIX V1.1.0 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -39,7 +39,7 @@ #include "FreeRTOS_POSIX/time.h" /** - * @brief pthread detach state. + * @name pthread detach state. */ /**@{ */ #define PTHREAD_CREATE_DETACHED 0 /**< Detached. */ @@ -47,15 +47,16 @@ /**@} */ /** - * @brief Returned to a single thread after a successful pthread_barrier_wait. + * @name Returned to a single thread after a successful pthread_barrier_wait. * - * POSIX specifies that "The constant PTHREAD_BARRIER_SERIAL_THREAD is defined in and its value shall be distinct from any other value returned by pthread_barrier_wait()." + * @brief POSIX specifies that "The constant PTHREAD_BARRIER_SERIAL_THREAD is defined in + * and its value shall be distinct from any other value returned by pthread_barrier_wait()." * So it's defined as negative to distinguish it from the errnos, which are positive. */ #define PTHREAD_BARRIER_SERIAL_THREAD ( -2 ) /** - * @brief Mutex types. + * @name Mutex types. */ /**@{ */ #ifndef PTHREAD_MUTEX_NORMAL @@ -73,15 +74,20 @@ /**@} */ /** - * @brief Compile-time initializers. + * @name Compile-time initializers. + * + * @brief To use PTHREAD_COND_INITIALIZER, posixconfigENABLE_PTHREAD_COND_T needs to be set to 1 + * in port specific POSIX config file. + * + * To use PTHREAD_MUTEX_INITIALIZER, posixconfigENABLE_PTHREAD_MUTEX_T needs to be set to 1 in + * port specific POSIX config file. */ /**@{ */ -#define PTHREAD_COND_INITIALIZER FREERTOS_POSIX_COND_INITIALIZER /**< pthread_cond_t. */ +#if posixconfigENABLE_PTHREAD_COND_T == 1 + #define PTHREAD_COND_INITIALIZER FREERTOS_POSIX_COND_INITIALIZER /**< pthread_cond_t. */ +#endif #if posixconfigENABLE_PTHREAD_MUTEX_T == 1 - /** - * @brief To use this initializer, posixconfigENABLE_PTHREAD_MUTEX_T needs to be set to 1 in FreeRTOS_POSIX_portable_default.h. - */ #define PTHREAD_MUTEX_INITIALIZER FREERTOS_POSIX_MUTEX_INITIALIZER /**< pthread_mutex_t. */ #endif @@ -91,8 +97,8 @@ * @brief Destroy the thread attributes object. * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_destroy.html - * - * @retval 0 - Upon successful completion + * + * @retval 0 - Upon successful completion. */ int pthread_attr_destroy( pthread_attr_t * attr ); @@ -101,8 +107,7 @@ int pthread_attr_destroy( pthread_attr_t * attr ); * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getdetachstate.html * - * @retval 0 - Upon successful completion - * + * @retval 0 - Upon successful completion. */ int pthread_attr_getdetachstate( const pthread_attr_t * attr, int * detachstate ); @@ -112,7 +117,7 @@ int pthread_attr_getdetachstate( const pthread_attr_t * attr, * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getschedparam.html * - * @retval 0 - Upon successful completion + * @retval 0 - Upon successful completion. */ int pthread_attr_getschedparam( const pthread_attr_t * attr, struct sched_param * param ); @@ -122,7 +127,7 @@ int pthread_attr_getschedparam( const pthread_attr_t * attr, * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getstacksize.html * - * @retval 0 - Upon successful completion + * @retval 0 - Upon successful completion. */ int pthread_attr_getstacksize( const pthread_attr_t * attr, size_t * stacksize ); @@ -132,10 +137,9 @@ int pthread_attr_getstacksize( const pthread_attr_t * attr, * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_init.html * - * @retval 0 - Upon successful completion - * @retval ENOMEM - Insufficient memory exists to initialize the thread attributes object. - * - * @note Currently, only stack size, sched param, and detach state attributes + * @retval 0 - Upon successful completion. + * + * @note Currently, only stack size, sched_param, and detach state attributes * are supported. Also see pthread_attr_get*() and pthread_attr_set*(). */ int pthread_attr_init( pthread_attr_t * attr ); @@ -146,7 +150,8 @@ int pthread_attr_init( pthread_attr_t * attr ); * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setdetachstate.html * * @retval 0 - Upon successful completion - * @retval EINVAL - The value of detachstate was not valid. Currently, supported detach states are -- PTHREAD_CREATE_DETACHED and PTHREAD_CREATE_JOINABLE. + * @retval EINVAL - The value of detachstate is not valid. Currently, supported detach states are -- + * PTHREAD_CREATE_DETACHED and PTHREAD_CREATE_JOINABLE. */ int pthread_attr_setdetachstate( pthread_attr_t * attr, int detachstate ); @@ -156,20 +161,32 @@ int pthread_attr_setdetachstate( pthread_attr_t * attr, * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setschedparam.html * - * @retval 0 - Upon successful completion - * @retval EINVAL - The value of param is not valid. - * @retval ENOTSUP - An attempt was made to set the attribute to an unsupported value. + * @retval 0 - Upon successful completion. + * @retval EINVAL - The value of param is not valid. + * @retval ENOTSUP - An attempt was made to set the attribute to an unsupported value. */ int pthread_attr_setschedparam( pthread_attr_t * attr, const struct sched_param * param ); +/** + * @brief Set the schedpolicy attribute. + * + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setschedpolicy.html + * + * @retval 0 - Upon successful completion. + * + * @warning This function is a stub and always returns 0. + */ +int pthread_attr_setschedpolicy( pthread_attr_t * attr, + int policy ); + /** * @brief Set stacksize attribute. * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setstacksize.html * - * @retval 0 - Upon successful completion - * @retval EINVAL - The value of stacksize is less than {PTHREAD_STACK_MIN} + * @retval 0 - Upon successful completion. + * @retval EINVAL - The value of stacksize is less than {PTHREAD_STACK_MIN}. */ int pthread_attr_setstacksize( pthread_attr_t * attr, size_t stacksize ); @@ -179,9 +196,9 @@ int pthread_attr_setstacksize( pthread_attr_t * attr, * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_barrier_destroy.html * - * @retval 0 - Upon successful completion - * - * @note This function does not validate whether there is any thread blocking on the barrier before destroying. + * @retval 0 - Upon successful completion. + * + * @note This function does not validate whether there is any thread blocking on the barrier before destroying. */ int pthread_barrier_destroy( pthread_barrier_t * barrier ); @@ -190,16 +207,17 @@ int pthread_barrier_destroy( pthread_barrier_t * barrier ); * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_barrier_init.html * - * @retval 0 - Upon successful completion + * @retval 0 - Upon successful completion. * @retval EINVAL - The value specified by count is equal to zero. * @retval ENOMEM - count cannot fit into FreeRTOS event group type OR insufficient memory exists to initialize the barrier. - * - * @note attr is ignored. - * - * @note pthread_barrier_init() is implemented with FreeRTOS event group. - * To ensure count fits in event group, count may be at most 8 when configUSE_16_BIT_TICKS is 1; it may be at most 24 otherwise. - * configUSE_16_BIT_TICKS is configured in application FreeRTOSConfig.h file, which defines how many bits tick count type has. - * See further details and limitation about event group and configUSE_16_BIT_TICKS in FreeRTOS site. + * + * @note attr is ignored. + * + * @note pthread_barrier_init() is implemented with FreeRTOS event group. + * To ensure count fits in event group, count may be at most 8 when configUSE_16_BIT_TICKS is 1; + * it may be at most 24 otherwise. configUSE_16_BIT_TICKS is configured in application FreeRTOSConfig.h + * file, which defines how many bits tick count type has. See further details and limitation about event + * group and configUSE_16_BIT_TICKS in FreeRTOS site. */ int pthread_barrier_init( pthread_barrier_t * barrier, const pthread_barrierattr_t * attr, @@ -211,7 +229,7 @@ int pthread_barrier_init( pthread_barrier_t * barrier, * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_barrier_wait.html * * @retval PTHREAD_BARRIER_SERIAL_THREAD - Upon successful completion, the first thread. - * @retval 0 - Upon successful completion, other thread(s). + * @retval 0 - Upon successful completion, other thread(s). */ int pthread_barrier_wait( pthread_barrier_t * barrier ); @@ -220,7 +238,7 @@ int pthread_barrier_wait( pthread_barrier_t * barrier ); * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_create.html * - * @retval 0 - Upon successful completion + * @retval 0 - Upon successful completion. * @retval EAGAIN - Insufficient memory for either thread structure or task creation. */ int pthread_create( pthread_t * thread, @@ -232,8 +250,8 @@ int pthread_create( pthread_t * thread, * @brief Broadcast a condition. * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_broadcast.html - * - * @retval 0 - Upon successful completion + * + * @retval 0 - Upon successful completion. */ int pthread_cond_broadcast( pthread_cond_t * cond ); @@ -242,7 +260,7 @@ int pthread_cond_broadcast( pthread_cond_t * cond ); * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_destroy.html * - * @retval 0 - Upon successful completion + * @retval 0 - Upon successful completion. */ int pthread_cond_destroy( pthread_cond_t * cond ); @@ -251,10 +269,10 @@ int pthread_cond_destroy( pthread_cond_t * cond ); * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_init.html * - * @retval 0 - Upon successful completion + * @retval 0 - Upon successful completion. * @retval ENOMEM - Insufficient memory exists to initialize the condition variable. * - * @note attr is ignored and treated as NULL. Default setting is always used. + * @note attr is ignored and treated as NULL. Default setting is always used. */ int pthread_cond_init( pthread_cond_t * cond, const pthread_condattr_t * attr ); @@ -264,7 +282,7 @@ int pthread_cond_init( pthread_cond_t * cond, * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_signal.html * - * @retval 0 - Upon successful completion + * @retval 0 - Upon successful completion. */ int pthread_cond_signal( pthread_cond_t * cond ); @@ -273,9 +291,10 @@ int pthread_cond_signal( pthread_cond_t * cond ); * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_timedwait.html * - * @retval 0 - Upon successful completion - * @retval EINVAL - The abstime argument passed in does not refer to an initialized structure OR - * the abstime parameter specified a nanoseconds field value less than zero or greater than or equal to 1000 million. + * @retval 0 - Upon successful completion. + * @retval EINVAL - The abstime argument passed in does not refer to an initialized structure OR + * the abstime parameter specified a nanoseconds field value less than zero or + * greater than or equal to 1000 million. * @retval ETIMEDOUT - The time specified by abstime to pthread_cond_timedwait() has passed. */ int pthread_cond_timedwait( pthread_cond_t * cond, @@ -287,7 +306,7 @@ int pthread_cond_timedwait( pthread_cond_t * cond, * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_wait.html * - * @retval 0 - Upon successful completion + * @retval 0 - Upon successful completion. */ int pthread_cond_wait( pthread_cond_t * cond, pthread_mutex_t * mutex ); @@ -296,9 +315,9 @@ int pthread_cond_wait( pthread_cond_t * cond, * @brief Compare thread IDs. * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_equal.html - * - * @retval 0 - t1 and t2 are both not NULL && equal - * @retval non-zero - otherwise + * + * @retval 0 - t1 and t2 are both not NULL && equal. + * @retval non-zero - otherwise. */ int pthread_equal( pthread_t t1, pthread_t t2 ); @@ -307,7 +326,7 @@ int pthread_equal( pthread_t t1, * @brief Thread termination. * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_exit.html - * + * * @retval void - this function cannot return to its caller. */ void pthread_exit( void * value_ptr ); @@ -316,10 +335,10 @@ void pthread_exit( void * value_ptr ); * @brief Dynamic thread scheduling parameters access. * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getschedparam.html - * - * @retval 0 - Upon successful completion * - * @note policy is always set to SCHED_OTHER by this function. + * @retval 0 - Upon successful completion. + * + * @note policy is always set to SCHED_OTHER by this function. */ int pthread_getschedparam( pthread_t thread, int * policy, @@ -329,11 +348,12 @@ int pthread_getschedparam( pthread_t thread, * @brief Wait for thread termination. * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_join.html - * - * @retval 0 - Upon successful completion - * @retval EDEADLK - The value specified by the thread argument to pthread_join() does not refer to - * a joinable thread OR multiple simultaneous calls to pthread_join() specifying the same target thread OR - * the value specified by the thread argument to pthread_join() refers to the calling thread. + * + * @retval 0 - Upon successful completion. + * @retval EDEADLK - The value specified by the thread argument to pthread_join() does not refer + * to a joinable thread OR multiple simultaneous calls to pthread_join() + * specifying the same target thread OR the value specified by the thread argument + * to pthread_join() refers to the calling thread. */ int pthread_join( pthread_t thread, void ** retval ); @@ -343,10 +363,9 @@ int pthread_join( pthread_t thread, * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_destroy.html * - * @retval 0 - Upon successful completion - * - * @note If there exists a thread holding this mutex, this function returns 0 with mutex not being destroyed. + * @retval 0 - Upon successful completion. * + * @note If there exists a thread holding this mutex, this function returns 0 with mutex not being destroyed. */ int pthread_mutex_destroy( pthread_mutex_t * mutex ); @@ -354,8 +373,8 @@ int pthread_mutex_destroy( pthread_mutex_t * mutex ); * @brief Initialize a mutex. * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_init.html - * - * @retval 0 - Upon successful completion + * + * @retval 0 - Upon successful completion. * @retval ENOMEM - Insufficient memory exists to initialize the mutex structure. * @retval EAGAIN - Unable to initialize the mutex structure member(s). */ @@ -366,11 +385,12 @@ int pthread_mutex_init( pthread_mutex_t * mutex, * @brief Lock a mutex. * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_lock.html - * - * @retval 0 - Upon successful completion - * @retval EINVAL - the abstime parameter specified a nanoseconds field value less than zero or greater than or equal to 1000 million. - * @retval EDEADLK - The mutex type is PTHREAD_MUTEX_ERRORCHECK and the current thread already owns the mutex. * + * @retval 0 - Upon successful completion. + * @retval EINVAL - the abstime parameter specified a nanoseconds field value less than zero + * or greater than or equal to 1000 million. + * @retval EDEADLK - The mutex type is PTHREAD_MUTEX_ERRORCHECK and the current thread already + * owns the mutex. */ int pthread_mutex_lock( pthread_mutex_t * mutex ); @@ -378,13 +398,13 @@ int pthread_mutex_lock( pthread_mutex_t * mutex ); * @brief Lock a mutex with timeout. * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_timedlock.html - * - * @retval 0 - Upon successful completion - * @retval EINVAL - The abstime argument passed in does not refer to an initialized structure OR - * the abstime parameter specified a nanoseconds field value less than zero or greater than or equal to 1000 million. + * + * @retval 0 - Upon successful completion. + * @retval EINVAL - The abstime argument passed in does not refer to an initialized structure OR + * the abstime parameter specified a nanoseconds field value less than zero or + * greater than or equal to 1000 million. * @retval EDEADLK - The mutex type is PTHREAD_MUTEX_ERRORCHECK and the current thread already owns the mutex. * @retval ETIMEDOUT - The mutex could not be locked before the specified timeout expired. - * */ int pthread_mutex_timedlock( pthread_mutex_t * mutex, const struct timespec * abstime ); @@ -394,11 +414,12 @@ int pthread_mutex_timedlock( pthread_mutex_t * mutex, * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_trylock.html * - * @retval 0 - Upon successful completion - * @retval EINVAL - the abstime parameter specified a nanoseconds field value less than zero or greater than or equal to 1000 million. - * @retval EDEADLK - The mutex type is PTHREAD_MUTEX_ERRORCHECK and the current thread already owns the mutex. + * @retval 0 - Upon successful completion. + * @retval EINVAL - the abstime parameter specified a nanoseconds field value less than zero + * or greater than or equal to 1000 million. + * @retval EDEADLK - The mutex type is PTHREAD_MUTEX_ERRORCHECK and the current thread already + * owns the mutex. * @retval EBUSY - The mutex could not be acquired because it was already locked. - * */ int pthread_mutex_trylock( pthread_mutex_t * mutex ); @@ -407,8 +428,9 @@ int pthread_mutex_trylock( pthread_mutex_t * mutex ); * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_unlock.html * - * @retval 0 - Upon successful completion - * @retval EPERM - The mutex type is PTHREAD_MUTEX_ERRORCHECK or PTHREAD_MUTEX_RECURSIVE, and the current thread does not own the mutex. + * @retval 0 - Upon successful completion. + * @retval EPERM - The mutex type is PTHREAD_MUTEX_ERRORCHECK or PTHREAD_MUTEX_RECURSIVE, and + * the current thread does not own the mutex. */ int pthread_mutex_unlock( pthread_mutex_t * mutex ); @@ -417,7 +439,7 @@ int pthread_mutex_unlock( pthread_mutex_t * mutex ); * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_destroy.html * - * @retval 0 - Upon successful completion + * @retval 0 - Upon successful completion. */ int pthread_mutexattr_destroy( pthread_mutexattr_t * attr ); @@ -425,8 +447,8 @@ int pthread_mutexattr_destroy( pthread_mutexattr_t * attr ); * @brief Get the mutex type attribute. * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_gettype.html - * - * @retval 0 - Upon successful completion + * + * @retval 0 - Upon successful completion. */ int pthread_mutexattr_gettype( const pthread_mutexattr_t * attr, int * type ); @@ -436,10 +458,10 @@ int pthread_mutexattr_gettype( const pthread_mutexattr_t * attr, * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_init.html * - * @retval 0 - Upon successful completion - * @retval ENOMEM - Insufficient memory exists to initialize the mutex attributes object. - * - * @note Currently, only the type attribute is supported. Also see pthread_mutexattr_settype() and pthread_mutexattr_gettype(). + * @retval 0 - Upon successful completion. + * + * @note Currently, only the type attribute is supported. Also see pthread_mutexattr_settype() + * and pthread_mutexattr_gettype(). */ int pthread_mutexattr_init( pthread_mutexattr_t * attr ); @@ -448,8 +470,8 @@ int pthread_mutexattr_init( pthread_mutexattr_t * attr ); * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_settype.html * - * @retval 0 - Upon successful completion - * @retval EINVAL - The value type is invalid. + * @retval 0 - Upon successful completion. + * @retval EINVAL - The value type is invalid. */ int pthread_mutexattr_settype( pthread_mutexattr_t * attr, int type ); @@ -468,9 +490,9 @@ pthread_t pthread_self( void ); * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_setschedparam.html * - * @retval 0 - Upon successful completion - * * @note policy is ignored; only priority (param.sched_priority) may be changed. + * + * @retval 0 - Upon successful completion. */ int pthread_setschedparam( pthread_t thread, int policy, diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/sched.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/sched.h index a37b0ef..5a72c44 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/sched.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/sched.h @@ -1,6 +1,6 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Amazon FreeRTOS POSIX V1.1.0 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -34,10 +34,10 @@ #define _FREERTOS_POSIX_SCHED_H_ /** - * @brief Scheduling Policies + * @name Scheduling Policies */ /**@{ */ -#define SCHED_OTHER 0 /**< Another scheduling policy. */ +#define SCHED_OTHER 0 /**< Another scheduling policy. */ /**@} */ /** @@ -50,19 +50,28 @@ struct sched_param }; /** - * @brief Get priority limit. + * @brief Get priority limit (max). * * http://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_get_priority_max.html * * @note policy is ignored. * - * @return the maxium priority value (0-based) system configuration allows. + * @return the maximum priority value (0-based) system configuration allows. *
- * e.g. if configMAX_PRIORITIES == 7, this function returns (configMAX_PRIORITIES - 1). - * configMAX_PRIORITIES is configured in appication FreeRTOSConfig.h file. + * e.g. if configMAX_PRIORITIES == 7, this function returns (configMAX_PRIORITIES - 1). + * configMAX_PRIORITIES is configured in application FreeRTOSConfig.h file. */ int sched_get_priority_max( int policy ); +/** + * @brief Get priority limit (min). + * + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_get_priority_min.html + * + * @note policy is ignored. + */ +int sched_get_priority_min( int policy ); + /** * @brief Yield the processor. * diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/semaphore.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/semaphore.h index 6ee312c..fa1da91 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/semaphore.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/semaphore.h @@ -1,6 +1,6 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Amazon FreeRTOS POSIX V1.1.0 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -35,11 +35,12 @@ /* FreeRTOS+POSIX includes. */ #include "FreeRTOS_POSIX/time.h" +#include "FreeRTOS_POSIX_types.h" /** * @brief Semaphore type. */ -typedef void * sem_t; +typedef PosixSemType_t sem_t; /** * @brief Destroy an unnamed semaphore. @@ -47,8 +48,8 @@ typedef void * sem_t; * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_destroy.html * * @retval 0 - upon successful completion - * - * @note Semaphore is destroyed regardless of whether there is any thread currently blocked on this semaphore. + * + * @note Semaphore is destroyed regardless of whether there is any thread currently blocked on this semaphore. */ int sem_destroy( sem_t * sem ); @@ -58,7 +59,7 @@ int sem_destroy( sem_t * sem ); * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_getvalue.html * * @retval 0 - Upon successful completion - * + * * @note If sem is locked, then the object to which sval points is set to zero. */ int sem_getvalue( sem_t * sem, @@ -70,16 +71,15 @@ int sem_getvalue( sem_t * sem, * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_init.html * * @note pshared is ignored. Semaphores will always be considered "shared". - * + * * @retval 0 - upon successful completion - * @retval -1 - otherwise. System error variable errno is also set in this case. - * - * \sideeffect Possible errno values + * @retval -1 - otherwise. System error variable errno is also set in this case. + * + * @sideeffect Possible errno values *
* EINVAL - The value argument exceeds {SEM_VALUE_MAX}. *
- * ENOSPC - A resource required to initialize the semaphore has been exhausted. - * + * ENOSPC - A resource required to initialize the semaphore has been exhausted. */ int sem_init( sem_t * sem, int pshared, @@ -98,17 +98,17 @@ int sem_post( sem_t * sem ); * @brief Lock a semaphore with timeout. * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_timedwait.html - * - * @retval 0 - upon successful completion - * @retval -1 - otherwise. System error variable errno is also set in this case. * - * \sideeffect Possible errno values + * @retval 0 - upon successful completion + * @retval -1 - otherwise. System error variable errno is also set in this case. + * + * @sideeffect Possible errno values *
- * EINVAL - parameter specified a nanoseconds field value less than zero or greater - * than or equal to 1000 million + * EINVAL - parameter specified a nanoseconds field value less than zero or greater + * than or equal to 1000 million *
* ETIMEDOUT - The semaphore could not be locked before the specified timeout expired. - * + * * @note Deadlock detection is not implemented. */ int sem_timedwait( sem_t * sem, @@ -118,11 +118,11 @@ int sem_timedwait( sem_t * sem, * @brief Lock a semaphore if available. * * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_trywait.html - * + * * @retval 0 - upon successful completion - * @retval -1 - otherwise. System error variable errno is also set in this case. - * - * \sideeffect Possible errno values + * @retval -1 - otherwise. System error variable errno is also set in this case. + * + * @sideeffect Possible errno values *
* EAGAIN - The semaphore was already locked, so it cannot be immediately locked by the sem_trywait() operation. */ @@ -134,8 +134,8 @@ int sem_trywait( sem_t * sem ); * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_wait.html * * @retval 0 - upon successful completion - * @retval -1 - otherwise. System error variable errno is also set in this case. - * + * @retval -1 - otherwise. System error variable errno is also set in this case. + * * @note Deadlock detection is not implemented. */ int sem_wait( sem_t * sem ); diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/signal.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/signal.h index 889873f..8f9cc6d 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/signal.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/signal.h @@ -1,6 +1,6 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Amazon FreeRTOS POSIX V1.1.0 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -38,7 +38,7 @@ #define _FREERTOS_POSIX_SIGNAL_H_ /** - * @brief Values of sigev_notify. + * @name Values of sigev_notify. */ /**@{ */ #define SIGEV_NONE 0 /**< No asynchronous notification is delivered when the event of interest occurs. */ @@ -60,11 +60,11 @@ union sigval */ struct sigevent { - int sigev_notify; /**< Notification type. A value of SIGEV_SIGNAL is not supported. */ - int sigev_signo; /**< Signal number. This member is ignored. */ - union sigval sigev_value; /**< Signal value. Only the sival_ptr member is used. */ - void ( * sigev_notify_function ) ( union sigval ); /**< Notification function. */ - pthread_attr_t * sigev_notify_attributes; /**< Notification attributes. */ + int sigev_notify; /**< Notification type. A value of SIGEV_SIGNAL is not supported. */ + int sigev_signo; /**< Signal number. This member is ignored. */ + union sigval sigev_value; /**< Signal value. Only the sival_ptr member is used. */ + void ( * sigev_notify_function )( union sigval ); /**< Notification function. */ + pthread_attr_t * sigev_notify_attributes; /**< Notification attributes. */ }; #endif /* ifndef _FREERTOS_POSIX_SIGNAL_H_ */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/sys/types.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/sys/types.h index 829d787..9cb3428 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/sys/types.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/sys/types.h @@ -1,6 +1,6 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Amazon FreeRTOS POSIX V1.1.0 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -36,126 +36,156 @@ /* C standard library includes. */ #include +/* FreeRTOS types include */ +#include "FreeRTOS_POSIX_types.h" + /** - * @brief Used for system times in clock ticks or CLOCKS_PER_SEC. + * @brief Used for system times in clock ticks or CLOCKS_PER_SEC. + * * Enabled/disabled by posixconfigENABLE_CLOCK_T. */ #if !defined( posixconfigENABLE_CLOCK_T ) || ( posixconfigENABLE_CLOCK_T == 1 ) - typedef uint32_t clock_t; + typedef uint32_t clock_t; #endif /** * @brief Used for clock ID type in the clock and timer functions. + * * Enabled/disabled by posixconfigENABLE_CLOCKID_T. */ #if !defined( posixconfigENABLE_CLOCKID_T ) || ( posixconfigENABLE_CLOCKID_T == 1 ) - typedef int clockid_t; + typedef int clockid_t; #endif /** * @brief Used for some file attributes. + * * Enabled/disabled by posixconfigENABLE_MODE_T. */ #if !defined( posixconfigENABLE_MODE_T ) || ( posixconfigENABLE_MODE_T == 1 ) - typedef int mode_t; + typedef int mode_t; #endif /** * @brief Used for process IDs and process group IDs. + * * Enabled/disabled by posixconfigENABLE_PID_T. */ #if !defined( posixconfigENABLE_PID_T ) || ( posixconfigENABLE_PID_T == 1 ) - typedef int pid_t; + typedef int pid_t; #endif /** * @brief Used to identify a thread attribute object. + * * Enabled/disabled by posixconfigENABLE_PTHREAD_ATTR_T. */ #if !defined( posixconfigENABLE_PTHREAD_ATTR_T ) || ( posixconfigENABLE_PTHREAD_ATTR_T == 1 ) - typedef void * pthread_attr_t; + typedef PthreadAttrType_t pthread_attr_t; #endif /** * @brief Used to identify a barrier. + * + * Enabled/disabled by posixconfigENABLE_PTHREAD_BARRIER_T. */ -typedef void * pthread_barrier_t; +#if !defined( posixconfigENABLE_PTHREAD_BARRIER_T ) || ( posixconfigENABLE_PTHREAD_BARRIER_T == 1 ) + typedef PthreadBarrierType_t pthread_barrier_t; +#endif /** * @brief Used to define a barrier attributes object. */ -typedef void * pthread_barrierattr_t; +typedef void * pthread_barrierattr_t; /** * @brief Used for condition variables. + * * Enabled/disabled by posixconfigENABLE_PTHREAD_COND_T. */ #if !defined( posixconfigENABLE_PTHREAD_COND_T ) || ( posixconfigENABLE_PTHREAD_COND_T == 1 ) - typedef void * pthread_cond_t; + typedef PthreadCondType_t pthread_cond_t; #endif /** * @brief Used to identify a condition attribute object. + * * Enabled/disabled by posixconfigENABLE_PTHREAD_CONDATTR_T. */ #if !defined( posixconfigENABLE_PTHREAD_CONDATTR_T ) || ( posixconfigENABLE_PTHREAD_CONDATTR_T == 1 ) - typedef void * pthread_condattr_t; + typedef void * pthread_condattr_t; #endif /** * @brief Used for mutexes. + * * Enabled/disabled by posixconfigENABLE_PTHREAD_MUTEX_T. */ #if !defined( posixconfigENABLE_PTHREAD_MUTEX_T ) || ( posixconfigENABLE_PTHREAD_MUTEX_T == 1 ) - typedef void * pthread_mutex_t; + typedef PthreadMutexType_t pthread_mutex_t; #endif /** * @brief Used to identify a mutex attribute object. + * * Enabled/disabled by posixconfigENABLE_PTHREAD_MUTEXATTR_T. */ #if !defined( posixconfigENABLE_PTHREAD_MUTEXATTR_T ) || ( posixconfigENABLE_PTHREAD_MUTEXATTR_T == 1 ) - typedef void * pthread_mutexattr_t; + typedef PthreadMutexAttrType_t pthread_mutexattr_t; #endif /** * @brief Used to identify a thread. - * Enabled/disabled by posixconfigENABLE_PTHREAD_T + * + * Enabled/disabled by posixconfigENABLE_PTHREAD_T. */ #if !defined( posixconfigENABLE_PTHREAD_T ) || ( posixconfigENABLE_PTHREAD_T == 1 ) - typedef void * pthread_t; + typedef void * pthread_t; #endif /** * @brief Used for a count of bytes or an error indication. + * * Enabled/disabled by posixconfigENABLE_SSIZE_T. */ #if !defined( posixconfigENABLE_SSIZE_T ) || ( posixconfigENABLE_SSIZE_T == 1 ) - typedef int ssize_t; + typedef int ssize_t; #endif /** * @brief Used for time in seconds. + * * Enabled/disabled by posixconfigENABLE_TIME_T. */ #if !defined( posixconfigENABLE_TIME_T ) || ( posixconfigENABLE_TIME_T == 1 ) - typedef int64_t time_t; + typedef int64_t time_t; #endif /** * @brief Used for timer ID returned by timer_create(). + * * Enabled/disabled by posixconfigENABLE_TIMER_T. */ #if !defined( posixconfigENABLE_TIMER_T ) || ( posixconfigENABLE_TIMER_T == 1 ) - typedef void * timer_t; + typedef void * timer_t; #endif /** * @brief Used for time in microseconds. + * * Enabled/disabled by posixconfigENABLE_USECONDS_T. */ #if !defined( posixconfigENABLE_USECONDS_T ) || ( posixconfigENABLE_USECONDS_T == 1 ) - typedef unsigned long useconds_t; + typedef unsigned long useconds_t; +#endif + +/** + * @brief Used for file sizes. + * + * Enabled/disabled by posixconfigENABLE_OFF_T. + */ +#if !defined( posixconfigENABLE_OFF_T ) || ( posixconfigENABLE_OFF_T == 1 ) + typedef long int off_t; #endif #endif /* ifndef _FREERTOS_POSIX_TYPES_H_ */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/time.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/time.h index 41fddb1..d04de0f 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/time.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/time.h @@ -1,6 +1,6 @@ /* - * Amazon FreeRTOS POSIX V1.0.0 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Amazon FreeRTOS POSIX V1.1.0 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -38,7 +38,7 @@ #include "FreeRTOS_POSIX/signal.h" /** - * @brief Unit conversion constants. + * @name Unit conversion constants. */ /**@{ */ #define MICROSECONDS_PER_SECOND ( 1000000LL ) /**< Microseconds per second. */ @@ -47,7 +47,7 @@ /**@} */ /** - * @brief Clock identifiers. + * @name Clock identifiers. */ /**@{ */ #define CLOCK_REALTIME 0 /**< The identifier of the system-wide clock measuring real time. */ @@ -55,21 +55,26 @@ /**@} */ /** - * @brief A number used to convert the value returned by the clock() function into seconds. + * @name A number used to convert the value returned by the clock() function into seconds. */ +/**@{ */ #define CLOCKS_PER_SEC ( ( clock_t ) configTICK_RATE_HZ ) +/**@} */ /** - * @brief Flag indicating time is absolute. + * @name Flag indicating time is absolute. * * For functions taking timer objects, this refers to the clock associated with the timer. */ -#define TIMER_ABSTIME 0x01 +/**@{ */ +#define TIMER_ABSTIME 0x01 +/**@} */ #if !defined( posixconfigENABLE_TIMESPEC ) || ( posixconfigENABLE_TIMESPEC == 1 ) - /** - * @brief represents an elapsed time - */ + +/** + * @brief represents an elapsed time + */ struct timespec { time_t tv_sec; /**< Seconds. */ @@ -78,9 +83,10 @@ #endif #if !defined( posixconfigENABLE_ITIMERSPEC ) || ( posixconfigENABLE_ITIMERSPEC == 1 ) - /** - * @brief timer - */ + +/** + * @brief timer + */ struct itimerspec { struct timespec it_interval; /**< Timer period. */ @@ -88,33 +94,14 @@ }; #endif -#if !defined( posixconfigENABLE_TM ) || ( posixconfigENABLE_TM == 1 ) - /** - * @brief calendar representation of time - */ - struct tm - { - time_t tm_tick; /**< FreeRTOS tick count. */ - int tm_sec; /**< Seconds [0,60]. Not used. */ - int tm_min; /**< Minutes [0,59]. Not used. */ - int tm_hour; /**< Hour [0,23]. Not used. */ - int tm_mday; /**< Day of month [1,31]. Not used. */ - int tm_mon; /**< Month of year [0,11]. Not used. */ - int tm_year; /**< Years since 1900. Not used. */ - int tm_wday; /**< Day of week [0,6] (Sunday=0). Not used. */ - int tm_yday; /**< Day of year [0,365]. Not used. */ - int tm_isdst; /**< Daylight Savings flag. Not used. */ - }; -#endif - /** * @brief Report CPU time used. * * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock.html * * @return The number of FreeRTOS ticks since the scheduler - * was started minus the ticks spent in the idle task. - * + * was started minus the ticks spent in the idle task. + * * @note This function does NOT report the number of ticks spent by the calling thread. */ clock_t clock( void ); @@ -125,7 +112,7 @@ clock_t clock( void ); * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getcpuclockid.html * * @retval EPERM - * + * * @note This function is currently unsupported. * */ @@ -152,9 +139,8 @@ int clock_getres( clockid_t clock_id, * * @note clock_id is ignored * @note this function does not check for overflows of time_t. - * - * @retval 0 - Upon successful completion. * + * @retval 0 - Upon successful completion. */ int clock_gettime( clockid_t clock_id, struct timespec * tp ); @@ -164,9 +150,9 @@ int clock_gettime( clockid_t clock_id, * * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_nanosleep.html * - * @note clock_id is ignored, as this function uses the FreeRTOS tick count as its clock. + * @note clock_id is ignored, as this function uses the FreeRTOS tick count as its clock. * @note flags is ignored, if INCLUDE_vTaskDelayUntil is 0. i.e. the FreeRTOS function vTaskDelayUntil isn't available. - * @note rmtp is also ignored, as signals are not implemented. + * @note rmtp is also ignored, as signals are not implemented. * * @retval 0 - Upon successful completion. * @retval EINVAL - The rqtp argument specified a nanosecond value less than zero or greater than or equal to 1000 million. @@ -181,32 +167,13 @@ int clock_nanosleep( clockid_t clock_id, * * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_settime.html * - * @retval -1 with errno set to EPERM. - * + * @retval -1 with errno set to EPERM. + * * @note This function is currently unsupported, as FreeRTOS does not provide a function to modify the tick count. */ int clock_settime( clockid_t clock_id, const struct timespec * tp ); -/** - * @brief Convert a time value to a broken-down local time. - * - * http://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime_r.html - * - * @note timer is ignored - * - * @note This function can only store the time as tm.tm_tick. All other members of - * the struct will be set to 0. - * - * @note In order to store tm.tm_tick in result, posixconfgENABLE_TM needs to be set to 1. - * See FreeRTOS_POSIX_portable_default.h for porting configurations. - * - * @return Upon successful completion, returns a pointer points to the object holding structure of type tm. - * @return If any error, rutrns NULL, with errno set to ENOTSUP. - */ -struct tm * localtime_r( const time_t * timer, - struct tm * result ); - /** * @brief High resolution sleep. * @@ -216,50 +183,23 @@ struct tm * localtime_r( const time_t * timer, * * @retval 0 - Upon successful completion. * @retval -1 - The rqtp argument is invalid OR the rqtp argument specified a nanosecond value less than zero or greater than or equal to 1000 million. - * + * */ int nanosleep( const struct timespec * rqtp, struct timespec * rmtp ); -/** - * @brief Convert date and time to a string. - * - * http://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html - * - * @note format is ignored. - * - * @retval the number of bytes placed into the array pointed to by s, - * if the total number of resulting bytes including the terminating null byte is not more than maxsize. - * @retval 0, otherwise. In this case, the array pointed to by s contains partially copied data. - */ -size_t strftime( char * s, - size_t maxsize, - const char * format, - const struct tm * timeptr ); - -/** - * @brief Get time. - * - * http://pubs.opengroup.org/onlinepubs/9699919799/functions/time.html - * - * @note This function returns the FreeRTOS tick count, not the seconds since UNIX epoch. - * - * @retval FreeRTOS tick count - upon successful completion - */ -time_t time( time_t * tloc ); - /** * @brief Create a per-process timer. * * http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_create.html * - * @note clock_id is ignored, as this function used the FreeRTOS tick count as its clock. + * @note clock_id is ignored, as this function used the FreeRTOS tick count as its clock. * @note evp.sigev_notify must be set to SIGEV_THREAD, since signals are currently not supported. - * + * * @retval 0 - Upon successful completion, with location referenced by timerid updated. - * @retval -1 - If an error occurs. errno is also set. - * - * \sideeffect Possible errno values + * @retval -1 - If an error occurs. errno is also set. + * + * @sideeffect Possible errno values *
* ENOTSUP - If evp is NULL OR evp->sigen_notify == SIGEV_SIGNAL. *
@@ -303,11 +243,11 @@ int timer_gettime( timer_t timerid, * http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_settime.html * * @retval 0 - Upon successful completion. - * @retval -1 - An error occured, errno is also set. - * - * \sideeffect Possible errno values + * @retval -1 - An error occurred, errno is also set. + * + * @sideeffect Possible errno values *
- * EINVAL - A value structure specified a nanosecond value less than zero or greater than or equal to 1000 million, + * EINVAL - A value structure specified a nanosecond value less than zero or greater than or equal to 1000 million, * AND the it_value member of that structure did not specify zero seconds and nanoseconds. */ int timer_settime( timer_t timerid, diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/unistd.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/unistd.h index ab44847..3b8af22 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/unistd.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/unistd.h @@ -1,6 +1,6 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Amazon FreeRTOS POSIX V1.1.0 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -33,16 +33,18 @@ #ifndef _FREERTOS_POSIX_UNISTD_H_ #define _FREERTOS_POSIX_UNISTD_H_ +#include "FreeRTOS_POSIX/sys/types.h" + /** * @brief Suspend execution for an interval of time. * * http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html - * - * @param[in] seconds The number of seconds to suspend execution. - * - * @retval 0 - Upon successful completion. * - * @note Return value of a positive number is not yet supported. + * @param[in] seconds The number of seconds to suspend execution. + * + * @retval 0 - Upon successful completion. + * + * @note Return value of a positive number is not yet supported. */ unsigned sleep( unsigned seconds ); @@ -52,7 +54,7 @@ unsigned sleep( unsigned seconds ); * This is a useful, non-POSIX function. * @param[in] usec The number of microseconds to suspend execution. * - * @retval 0 - Upon successful cocmpletion. + * @retval 0 - Upon successful completion. */ int usleep( useconds_t usec ); diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/utils.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/utils.h index ab4769b..c893a95 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/utils.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/utils.h @@ -1,6 +1,6 @@ /* - * Amazon FreeRTOS+POSIX V1.0.0 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Amazon FreeRTOS POSIX V1.1.0 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -55,20 +55,23 @@ size_t UTILS_strnlen( const char * const pcString, * * @param[in] pxAbsoluteTime A time in the future, specified as seconds and * nanoseconds since CLOCK_REALTIME's 0. + * @param[in] pxCurrentTime current time, specified as seconds and + * nanoseconds. * @param[out] pxResult Where the result of the conversion is stored. The result * is rounded up for fractional ticks. * * @return 0 on success. Otherwise, ETIMEDOUT if pxAbsoluteTime is in the past, * or EINVAL for invalid parameters. */ -int UTILS_AbsoluteTimespecToTicks( const struct timespec * const pxAbsoluteTime, - TickType_t * const pxResult ); +int UTILS_AbsoluteTimespecToDeltaTicks( const struct timespec * const pxAbsoluteTime, + const struct timespec * const pxCurrentTime, + TickType_t * const pxResult ); /** * @brief Converts a struct timespec to FreeRTOS ticks. * * @param[in] pxTimespec The timespec to convert. - * @param[out] pxResult Where the result of the conversion is stored. The result is rounded + * @param[out] Where the result of the conversion is stored. The result is rounded * up for fractional ticks. * * @return 0 on success. Otherwise, EINVAL for invalid parameters. @@ -90,51 +93,63 @@ void UTILS_NanosecondsToTimespec( int64_t llSource, /** * @brief Calculates pxResult = x + y. * - * @param[out] pxResult Where the result of the calculation is stored. * @param[in] x The first argument for addition. * @param[in] y The second argument for addition. + * @param[out] pxResult Where the result of the calculation is stored. * - * @return -1 if any argument was NULL; 1 if result is negative; otherwise, 0. + * @return -1 if any argument was NULL; 1 if result is negative (overflow); otherwise, 0. */ -int UTILS_TimespecAdd( struct timespec * const pxResult, - const struct timespec * const x, - const struct timespec * const y ); +int UTILS_TimespecAdd( const struct timespec * const x, + const struct timespec * const y, + struct timespec * const pxResult ); /** * @brief Calculates pxResult = x + ( struct timespec ) nanosec. * - * @param[out] pxResult Where the result of the calculation is stored. * @param[in] x The first argument for addition. * @param[in] llNanoseconds The second argument for addition. + * @param[out] pxResult Where the result of the calculation is stored. * * @return -1 if pxResult or x was NULL; 1 if result is negative; otherwise, 0. */ -int UTILS_TimespecAddNanoseconds( struct timespec * const pxResult, - const struct timespec * const x, - int64_t llNanoseconds ); +int UTILS_TimespecAddNanoseconds( const struct timespec * const x, + int64_t llNanoseconds, + struct timespec * const pxResult ); /** - * @brief Calculates pxResult = x - y. + * @brief Calculates pxResult = x - y. If the result is negative contents of + * pResult are undefined * - * @param[out] pxResult Where the result of the calculation is stored. * @param[in] x The first argument for subtraction. * @param[in] y The second argument for subtraction. + * @param[out] pxResult Where the result of the calculation is stored. * * @return -1 if any argument was NULL; 1 if result is negative; otherwise, 0. */ -int UTILS_TimespecSubtract( struct timespec * const pxResult, - const struct timespec * const x, - const struct timespec * const y ); +int UTILS_TimespecSubtract( const struct timespec * const x, + const struct timespec * const y, + struct timespec * const pxResult ); /** -* @brief Checks that a timespec conforms to POSIX. -* -* A valid timespec must have 0 <= tv_nsec < 1000000000. -* -* @param[in] pxTimespec The timespec to validate. -* -* @return true if the pxTimespec is valid, false otherwise. -*/ -bool UTILS_ValidateTimespec(const struct timespec * const pxTimespec); + * @brief Compare x == y. + * + * @param[in] x The first argument for comparison. + * @param[in] y The second argument for comparison. + * + * @return 0 if x == y; 1 if x > y; -1 if x < y or any argument was NULL + */ +int UTILS_TimespecCompare( const struct timespec * const x, + const struct timespec * const y ); + +/** + * @brief Checks that a timespec conforms to POSIX. + * + * A valid timespec must have 0 <= tv_nsec < 1000000000. + * + * @param[in] pxTimespec The timespec to validate. + * + * @return true if the pxTimespec is valid, false otherwise. + */ +bool UTILS_ValidateTimespec( const struct timespec * const pxTimespec ); #endif /* ifndef _FREERTOS_POSIX_UTILS_ */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/private/aws_doubly_linked_list.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/private/iot_doubly_linked_list.h similarity index 98% rename from FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/private/aws_doubly_linked_list.h rename to FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/private/iot_doubly_linked_list.h index ec912b4..338c539 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/private/aws_doubly_linked_list.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/private/iot_doubly_linked_list.h @@ -1,6 +1,6 @@ /* - * Amazon FreeRTOS - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Amazon FreeRTOS Common V1.0.0 + * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -23,9 +23,8 @@ * http://www.FreeRTOS.org */ - /** - * @file aws_doubly_linked_list.h + * @file iot_doubly_linked_list.h * @brief Doubly Linked List implementation. * * A generic implementation of circular Doubly Linked List which consists of a diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/posix_demo.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/posix_demo.c index 94f4030..63560c7 100755 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/posix_demo.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/posix_demo.c @@ -73,6 +73,7 @@ /* System headers. */ #include #include +#include /* Demo includes. */ #include "posix_demo.h" @@ -270,11 +271,14 @@ static void * prvDispatcherThread( void * pvArgs ) * * See the top of this file for detailed description. */ -void vStartPOSIXDemo( void ) +void vStartPOSIXDemo( void *pvParameters ) { int i = 0; int iStatus = 0; + /* Remove warnings about unused parameters. */ + ( void ) pvParameters; + /* Handles of the threads and related resources. */ DispatcherThreadResources_t pxDispatcher = { 0 }; WorkerThreadResources_t pxWorkers[ MQUEUE_NUMBER_OF_WORKERS ] = { { 0 } }; @@ -363,4 +367,8 @@ void vStartPOSIXDemo( void ) { printf( "Queues did not get initialized properly. Did not run demo. %s", LINE_BREAK ); } + + /* This task was created with the native xTaskCreate() API function, so + must not run off the end of its implementing thread. */ + vTaskDelete( NULL ); } diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c deleted file mode 100755 index 72f4828..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * FreeRTOS+CLI V1.0.4 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ - -/* Standard includes. */ -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" - -/* Utils includes. */ -#include "FreeRTOS_CLI.h" - -/* If the application writer needs to place the buffer used by the CLI at a -fixed address then set configAPPLICATION_PROVIDES_cOutputBuffer to 1 in -FreeRTOSConfig.h, then declare an array with the following name and size in -one of the application files: - char cOutputBuffer[ configCOMMAND_INT_MAX_OUTPUT_SIZE ]; -*/ -#ifndef configAPPLICATION_PROVIDES_cOutputBuffer - #define configAPPLICATION_PROVIDES_cOutputBuffer 0 -#endif - -typedef struct xCOMMAND_INPUT_LIST -{ - const CLI_Command_Definition_t *pxCommandLineDefinition; - struct xCOMMAND_INPUT_LIST *pxNext; -} CLI_Definition_List_Item_t; - -/* - * The callback function that is executed when "help" is entered. This is the - * only default command that is always present. - */ -static BaseType_t prvHelpCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); - -/* - * Return the number of parameters that follow the command name. - */ -static int8_t prvGetNumberOfParameters( const char *pcCommandString ); - -/* The definition of the "help" command. This command is always at the front -of the list of registered commands. */ -static const CLI_Command_Definition_t xHelpCommand = -{ - "help", - "\r\nhelp:\r\n Lists all the registered commands\r\n\r\n", - prvHelpCommand, - 0 -}; - -/* The definition of the list of commands. Commands that are registered are -added to this list. */ -static CLI_Definition_List_Item_t xRegisteredCommands = -{ - &xHelpCommand, /* The first command in the list is always the help command, defined in this file. */ - NULL /* The next pointer is initialised to NULL, as there are no other registered commands yet. */ -}; - -/* A buffer into which command outputs can be written is declared here, rather -than in the command console implementation, to allow multiple command consoles -to share the same buffer. For example, an application may allow access to the -command interpreter by UART and by Ethernet. Sharing a buffer is done purely -to save RAM. Note, however, that the command console itself is not re-entrant, -so only one command interpreter interface can be used at any one time. For that -reason, no attempt at providing mutual exclusion to the cOutputBuffer array is -attempted. - -configAPPLICATION_PROVIDES_cOutputBuffer is provided to allow the application -writer to provide their own cOutputBuffer declaration in cases where the -buffer needs to be placed at a fixed address (rather than by the linker). */ -#if( configAPPLICATION_PROVIDES_cOutputBuffer == 0 ) - static char cOutputBuffer[ configCOMMAND_INT_MAX_OUTPUT_SIZE ]; -#else - extern char cOutputBuffer[ configCOMMAND_INT_MAX_OUTPUT_SIZE ]; -#endif - - -/*-----------------------------------------------------------*/ - -BaseType_t FreeRTOS_CLIRegisterCommand( const CLI_Command_Definition_t * const pxCommandToRegister ) -{ -static CLI_Definition_List_Item_t *pxLastCommandInList = &xRegisteredCommands; -CLI_Definition_List_Item_t *pxNewListItem; -BaseType_t xReturn = pdFAIL; - - /* Check the parameter is not NULL. */ - configASSERT( pxCommandToRegister ); - - /* Create a new list item that will reference the command being registered. */ - pxNewListItem = ( CLI_Definition_List_Item_t * ) pvPortMalloc( sizeof( CLI_Definition_List_Item_t ) ); - configASSERT( pxNewListItem ); - - if( pxNewListItem != NULL ) - { - taskENTER_CRITICAL(); - { - /* Reference the command being registered from the newly created - list item. */ - pxNewListItem->pxCommandLineDefinition = pxCommandToRegister; - - /* The new list item will get added to the end of the list, so - pxNext has nowhere to point. */ - pxNewListItem->pxNext = NULL; - - /* Add the newly created list item to the end of the already existing - list. */ - pxLastCommandInList->pxNext = pxNewListItem; - - /* Set the end of list marker to the new list item. */ - pxLastCommandInList = pxNewListItem; - } - taskEXIT_CRITICAL(); - - xReturn = pdPASS; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -BaseType_t FreeRTOS_CLIProcessCommand( const char * const pcCommandInput, char * pcWriteBuffer, size_t xWriteBufferLen ) -{ -static const CLI_Definition_List_Item_t *pxCommand = NULL; -BaseType_t xReturn = pdTRUE; -const char *pcRegisteredCommandString; -size_t xCommandStringLength; - - /* Note: This function is not re-entrant. It must not be called from more - thank one task. */ - - if( pxCommand == NULL ) - { - /* Search for the command string in the list of registered commands. */ - for( pxCommand = &xRegisteredCommands; pxCommand != NULL; pxCommand = pxCommand->pxNext ) - { - pcRegisteredCommandString = pxCommand->pxCommandLineDefinition->pcCommand; - xCommandStringLength = strlen( pcRegisteredCommandString ); - - /* To ensure the string lengths match exactly, so as not to pick up - a sub-string of a longer command, check the byte after the expected - end of the string is either the end of the string or a space before - a parameter. */ - if( ( pcCommandInput[ xCommandStringLength ] == ' ' ) || ( pcCommandInput[ xCommandStringLength ] == 0x00 ) ) - { - if( strncmp( pcCommandInput, pcRegisteredCommandString, xCommandStringLength ) == 0 ) - { - /* The command has been found. Check it has the expected - number of parameters. If cExpectedNumberOfParameters is -1, - then there could be a variable number of parameters and no - check is made. */ - if( pxCommand->pxCommandLineDefinition->cExpectedNumberOfParameters >= 0 ) - { - if( prvGetNumberOfParameters( pcCommandInput ) != pxCommand->pxCommandLineDefinition->cExpectedNumberOfParameters ) - { - xReturn = pdFALSE; - } - } - - break; - } - } - } - } - - if( ( pxCommand != NULL ) && ( xReturn == pdFALSE ) ) - { - /* The command was found, but the number of parameters with the command - was incorrect. */ - strncpy( pcWriteBuffer, "Incorrect command parameter(s). Enter \"help\" to view a list of available commands.\r\n\r\n", xWriteBufferLen ); - pxCommand = NULL; - } - else if( pxCommand != NULL ) - { - /* Call the callback function that is registered to this command. */ - xReturn = pxCommand->pxCommandLineDefinition->pxCommandInterpreter( pcWriteBuffer, xWriteBufferLen, pcCommandInput ); - - /* If xReturn is pdFALSE, then no further strings will be returned - after this one, and pxCommand can be reset to NULL ready to search - for the next entered command. */ - if( xReturn == pdFALSE ) - { - pxCommand = NULL; - } - } - else - { - /* pxCommand was NULL, the command was not found. */ - strncpy( pcWriteBuffer, "Command not recognised. Enter 'help' to view a list of available commands.\r\n\r\n", xWriteBufferLen ); - xReturn = pdFALSE; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -char *FreeRTOS_CLIGetOutputBuffer( void ) -{ - return cOutputBuffer; -} -/*-----------------------------------------------------------*/ - -const char *FreeRTOS_CLIGetParameter( const char *pcCommandString, UBaseType_t uxWantedParameter, BaseType_t *pxParameterStringLength ) -{ -UBaseType_t uxParametersFound = 0; -const char *pcReturn = NULL; - - *pxParameterStringLength = 0; - - while( uxParametersFound < uxWantedParameter ) - { - /* Index the character pointer past the current word. If this is the start - of the command string then the first word is the command itself. */ - while( ( ( *pcCommandString ) != 0x00 ) && ( ( *pcCommandString ) != ' ' ) ) - { - pcCommandString++; - } - - /* Find the start of the next string. */ - while( ( ( *pcCommandString ) != 0x00 ) && ( ( *pcCommandString ) == ' ' ) ) - { - pcCommandString++; - } - - /* Was a string found? */ - if( *pcCommandString != 0x00 ) - { - /* Is this the start of the required parameter? */ - uxParametersFound++; - - if( uxParametersFound == uxWantedParameter ) - { - /* How long is the parameter? */ - pcReturn = pcCommandString; - while( ( ( *pcCommandString ) != 0x00 ) && ( ( *pcCommandString ) != ' ' ) ) - { - ( *pxParameterStringLength )++; - pcCommandString++; - } - - if( *pxParameterStringLength == 0 ) - { - pcReturn = NULL; - } - - break; - } - } - else - { - break; - } - } - - return pcReturn; -} -/*-----------------------------------------------------------*/ - -static BaseType_t prvHelpCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ) -{ -static const CLI_Definition_List_Item_t * pxCommand = NULL; -BaseType_t xReturn; - - ( void ) pcCommandString; - - if( pxCommand == NULL ) - { - /* Reset the pxCommand pointer back to the start of the list. */ - pxCommand = &xRegisteredCommands; - } - - /* Return the next command help string, before moving the pointer on to - the next command in the list. */ - strncpy( pcWriteBuffer, pxCommand->pxCommandLineDefinition->pcHelpString, xWriteBufferLen ); - pxCommand = pxCommand->pxNext; - - if( pxCommand == NULL ) - { - /* There are no more commands in the list, so there will be no more - strings to return after this one and pdFALSE should be returned. */ - xReturn = pdFALSE; - } - else - { - xReturn = pdTRUE; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -static int8_t prvGetNumberOfParameters( const char *pcCommandString ) -{ -int8_t cParameters = 0; -BaseType_t xLastCharacterWasSpace = pdFALSE; - - /* Count the number of space delimited words in pcCommandString. */ - while( *pcCommandString != 0x00 ) - { - if( ( *pcCommandString ) == ' ' ) - { - if( xLastCharacterWasSpace != pdTRUE ) - { - cParameters++; - xLastCharacterWasSpace = pdTRUE; - } - } - else - { - xLastCharacterWasSpace = pdFALSE; - } - - pcCommandString++; - } - - /* If the command string ended with spaces, then there will have been too - many parameters counted. */ - if( xLastCharacterWasSpace == pdTRUE ) - { - cParameters--; - } - - /* The value returned is one less than the number of space delimited words, - as the first word should be the command itself. */ - return cParameters; -} - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/FreeRTOS_CLI.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/FreeRTOS_CLI.h deleted file mode 100755 index 6281c12..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/FreeRTOS_CLI.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * FreeRTOS+CLI V1.0.4 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ - -#ifndef COMMAND_INTERPRETER_H -#define COMMAND_INTERPRETER_H - -/* The prototype to which callback functions used to process command line -commands must comply. pcWriteBuffer is a buffer into which the output from -executing the command can be written, xWriteBufferLen is the length, in bytes of -the pcWriteBuffer buffer, and pcCommandString is the entire string as input by -the user (from which parameters can be extracted).*/ -typedef BaseType_t (*pdCOMMAND_LINE_CALLBACK)( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString ); - -/* The structure that defines command line commands. A command line command -should be defined by declaring a const structure of this type. */ -typedef struct xCOMMAND_LINE_INPUT -{ - const char * const pcCommand; /* The command that causes pxCommandInterpreter to be executed. For example "help". Must be all lower case. */ - const char * const pcHelpString; /* String that describes how to use the command. Should start with the command itself, and end with "\r\n". For example "help: Returns a list of all the commands\r\n". */ - const pdCOMMAND_LINE_CALLBACK pxCommandInterpreter; /* A pointer to the callback function that will return the output generated by the command. */ - int8_t cExpectedNumberOfParameters; /* Commands expect a fixed number of parameters, which may be zero. */ -} CLI_Command_Definition_t; - -/* For backward compatibility. */ -#define xCommandLineInput CLI_Command_Definition_t - -/* - * Register the command passed in using the pxCommandToRegister parameter. - * Registering a command adds the command to the list of commands that are - * handled by the command interpreter. Once a command has been registered it - * can be executed from the command line. - */ -BaseType_t FreeRTOS_CLIRegisterCommand( const CLI_Command_Definition_t * const pxCommandToRegister ); - -/* - * Runs the command interpreter for the command string "pcCommandInput". Any - * output generated by running the command will be placed into pcWriteBuffer. - * xWriteBufferLen must indicate the size, in bytes, of the buffer pointed to - * by pcWriteBuffer. - * - * FreeRTOS_CLIProcessCommand should be called repeatedly until it returns pdFALSE. - * - * pcCmdIntProcessCommand is not reentrant. It must not be called from more - * than one task - or at least - by more than one task at a time. - */ -BaseType_t FreeRTOS_CLIProcessCommand( const char * const pcCommandInput, char * pcWriteBuffer, size_t xWriteBufferLen ); - -/*-----------------------------------------------------------*/ - -/* - * A buffer into which command outputs can be written is declared in the - * main command interpreter, rather than in the command console implementation, - * to allow application that provide access to the command console via multiple - * interfaces to share a buffer, and therefore save RAM. Note, however, that - * the command interpreter itself is not re-entrant, so only one command - * console interface can be used at any one time. For that reason, no attempt - * is made to provide any mutual exclusion mechanism on the output buffer. - * - * FreeRTOS_CLIGetOutputBuffer() returns the address of the output buffer. - */ -char *FreeRTOS_CLIGetOutputBuffer( void ); - -/* - * Return a pointer to the xParameterNumber'th word in pcCommandString. - */ -const char *FreeRTOS_CLIGetParameter( const char *pcCommandString, UBaseType_t uxWantedParameter, BaseType_t *pxParameterStringLength ); - -#endif /* COMMAND_INTERPRETER_H */ - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/History.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/History.txt deleted file mode 100755 index 01c95fe..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/History.txt +++ /dev/null @@ -1,32 +0,0 @@ -Changes between V1.0.3 and V1.0.4 released - - + Update to use stdint and the FreeRTOS specific typedefs that were - introduced in FreeRTOS V8.0.0. - -Changes between V1.0.2 and V1.0.3 released - - + Previously, and in line with good software engineering practice, the - FreeRTOS coding standard did not permit the use of char types that were - not explicitly qualified as either signed or unsigned. As a result char - pointers used to reference strings required casts, as did the use of any - standard string handling functions. The casts ensured compiler warnings - were not generated by compilers that defaulted unqualified char types to - be signed or compilers that defaulted unqualified char types to be - unsigned. As it has in later MISRA standards, this rule has now been - relaxed, and unqualified char types are now permitted, but only when: - 1) The char is used to point to a human readable text string. - 2) The char is used to hold a single ASCII character. - -Changes between V1.0.1 and V1.0.2 released 14/10/2013 - - + Changed double quotes (") to single quotes (') in the help string to - allow the strings to be used with JSON in FreeRTOS+Nabto. - -Changes between V1.0.0 and V1.0.1 released 05/07/2012 - - + Change the name of the structure used to map a function that implements - a CLI command to the string used to call the command from - xCommandLineInput to CLI_Command_Definition_t, as it was always intended - to be. A #define was added to map the old name to the new name for - reasons of backward compatibility. - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/LICENSE_INFORMATION.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/LICENSE_INFORMATION.txt deleted file mode 100755 index a8b0a6d..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/LICENSE_INFORMATION.txt +++ /dev/null @@ -1,19 +0,0 @@ -FreeRTOS+CLI is released under the following MIT license. - -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/readme.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/readme.txt deleted file mode 100755 index 801d535..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/readme.txt +++ /dev/null @@ -1,4 +0,0 @@ -Contains source and header files that implement FreeRTOS+CLI. See -http://www.FreeRTOS.org/cli for documentation and license information. - - \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-IO/LinkToDemo.url b/FreeRTOS-Plus/Source/FreeRTOS-Plus-IO/LinkToDemo.url deleted file mode 100755 index a7a7a27..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-IO/LinkToDemo.url +++ /dev/null @@ -1,5 +0,0 @@ -[InternetShortcut] -URL=http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_IO/Demo_Applications/LPCXpresso_LPC1769/NXP_LPC1769_Demo_Description.shtml -IDList= -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-IO/readme.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-IO/readme.txt deleted file mode 100755 index b685d51..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-IO/readme.txt +++ /dev/null @@ -1,7 +0,0 @@ -It is not possible to create an example FreeRTOS+IO project for the Windows -simulator. FreeRTOS+IO information can be found on http://www.FreeRTOS.org/IO. - -A featured demo that includes telnet like functionality, a web server, -a command line interface (using FreeRTOS+CLI) and a FAT file system is -described on -http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_IO/Demo_Applications/LPCXpresso_LPC1769/NXP_LPC1769_Demo_Description.shtml \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_ARP.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_ARP.c deleted file mode 100755 index 0792483..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_ARP.c +++ /dev/null @@ -1,653 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -/* Standard includes. */ -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "FreeRTOS_ARP.h" -#include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_DHCP.h" -#if( ipconfigUSE_LLMNR == 1 ) - #include "FreeRTOS_DNS.h" -#endif /* ipconfigUSE_LLMNR */ -#include "NetworkInterface.h" -#include "NetworkBufferManagement.h" - - -/* When the age of an entry in the ARP table reaches this value (it counts down -to zero, so this is an old entry) an ARP request will be sent to see if the -entry is still valid and can therefore be refreshed. */ -#define arpMAX_ARP_AGE_BEFORE_NEW_ARP_REQUEST ( 3 ) - -/* The time between gratuitous ARPs. */ -#ifndef arpGRATUITOUS_ARP_PERIOD - #define arpGRATUITOUS_ARP_PERIOD ( pdMS_TO_TICKS( 20000 ) ) -#endif - -/*-----------------------------------------------------------*/ - -/* - * Lookup an MAC address in the ARP cache from the IP address. - */ -static eARPLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, MACAddress_t * const pxMACAddress ); - -/*-----------------------------------------------------------*/ - -/* The ARP cache. */ -static ARPCacheRow_t xARPCache[ ipconfigARP_CACHE_ENTRIES ]; - -/* The time at which the last gratuitous ARP was sent. Gratuitous ARPs are used -to ensure ARP tables are up to date and to detect IP address conflicts. */ -static TickType_t xLastGratuitousARPTime = ( TickType_t ) 0; - -/* - * IP-clash detection is currently only used internally. When DHCP doesn't respond, the - * driver can try out a random LinkLayer IP address (169.254.x.x). It will send out a - * gratuitos ARP message and, after a period of time, check the variables here below: - */ -#if( ipconfigARP_USE_CLASH_DETECTION != 0 ) - /* Becomes non-zero if another device responded to a gratuitos ARP message. */ - BaseType_t xARPHadIPClash; - /* MAC-address of the other device containing the same IP-address. */ - MACAddress_t xARPClashMacAddress; -#endif /* ipconfigARP_USE_CLASH_DETECTION */ - -/* Part of the Ethernet and ARP headers are always constant when sending an IPv4 -ARP packet. This array defines the constant parts, allowing this part of the -packet to be filled in using a simple memcpy() instead of individual writes. */ -static const uint8_t xDefaultPartARPPacketHeader[] = -{ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* Ethernet destination address. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Ethernet source address. */ - 0x08, 0x06, /* Ethernet frame type (ipARP_FRAME_TYPE). */ - 0x00, 0x01, /* usHardwareType (ipARP_HARDWARE_TYPE_ETHERNET). */ - 0x08, 0x00, /* usProtocolType. */ - ipMAC_ADDRESS_LENGTH_BYTES, /* ucHardwareAddressLength. */ - ipIP_ADDRESS_LENGTH_BYTES, /* ucProtocolAddressLength. */ - 0x00, 0x01, /* usOperation (ipARP_REQUEST). */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* xSenderHardwareAddress. */ - 0x00, 0x00, 0x00, 0x00, /* ulSenderProtocolAddress. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* xTargetHardwareAddress. */ -}; - -/*-----------------------------------------------------------*/ - -eFrameProcessingResult_t eARPProcessPacket( ARPPacket_t * const pxARPFrame ) -{ -eFrameProcessingResult_t eReturn = eReleaseBuffer; -ARPHeader_t *pxARPHeader; -uint32_t ulTargetProtocolAddress, ulSenderProtocolAddress; - - pxARPHeader = &( pxARPFrame->xARPHeader ); - - /* The field ulSenderProtocolAddress is badly aligned, copy byte-by-byte. */ - memcpy( ( void *)&( ulSenderProtocolAddress ), ( void * )pxARPHeader->ucSenderProtocolAddress, sizeof( ulSenderProtocolAddress ) ); - /* The field ulTargetProtocolAddress is well-aligned, a 32-bits copy. */ - ulTargetProtocolAddress = pxARPHeader->ulTargetProtocolAddress; - - traceARP_PACKET_RECEIVED(); - - /* Don't do anything if the local IP address is zero because - that means a DHCP request has not completed. */ - if( *ipLOCAL_IP_ADDRESS_POINTER != 0UL ) - { - switch( pxARPHeader->usOperation ) - { - case ipARP_REQUEST : - /* The packet contained an ARP request. Was it for the IP - address of the node running this code? */ - if( ulTargetProtocolAddress == *ipLOCAL_IP_ADDRESS_POINTER ) - { - iptraceSENDING_ARP_REPLY( ulSenderProtocolAddress ); - - /* The request is for the address of this node. Add the - entry into the ARP cache, or refresh the entry if it - already exists. */ - vARPRefreshCacheEntry( &( pxARPHeader->xSenderHardwareAddress ), ulSenderProtocolAddress ); - - /* Generate a reply payload in the same buffer. */ - pxARPHeader->usOperation = ( uint16_t ) ipARP_REPLY; - if( ulTargetProtocolAddress == ulSenderProtocolAddress ) - { - /* A double IP address is detected! */ - /* Give the sources MAC address the value of the broadcast address, will be swapped later */ - memcpy( pxARPFrame->xEthernetHeader.xSourceAddress.ucBytes, xBroadcastMACAddress.ucBytes, sizeof( xBroadcastMACAddress ) ); - memset( pxARPHeader->xTargetHardwareAddress.ucBytes, '\0', sizeof( MACAddress_t ) ); - pxARPHeader->ulTargetProtocolAddress = 0UL; - } - else - { - memcpy( pxARPHeader->xTargetHardwareAddress.ucBytes, pxARPHeader->xSenderHardwareAddress.ucBytes, sizeof( MACAddress_t ) ); - pxARPHeader->ulTargetProtocolAddress = ulSenderProtocolAddress; - } - memcpy( pxARPHeader->xSenderHardwareAddress.ucBytes, ( void * ) ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( ( void* )pxARPHeader->ucSenderProtocolAddress, ( void* )ipLOCAL_IP_ADDRESS_POINTER, sizeof( pxARPHeader->ucSenderProtocolAddress ) ); - - eReturn = eReturnEthernetFrame; - } - break; - - case ipARP_REPLY : - iptracePROCESSING_RECEIVED_ARP_REPLY( ulTargetProtocolAddress ); - vARPRefreshCacheEntry( &( pxARPHeader->xSenderHardwareAddress ), ulSenderProtocolAddress ); - /* Process received ARP frame to see if there is a clash. */ - #if( ipconfigARP_USE_CLASH_DETECTION != 0 ) - { - if( ulSenderProtocolAddress == *ipLOCAL_IP_ADDRESS_POINTER ) - { - xARPHadIPClash = pdTRUE; - memcpy( xARPClashMacAddress.ucBytes, pxARPHeader->xSenderHardwareAddress.ucBytes, sizeof( xARPClashMacAddress.ucBytes ) ); - } - } - #endif /* ipconfigARP_USE_CLASH_DETECTION */ - break; - - default : - /* Invalid. */ - break; - } - } - - return eReturn; -} -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_ARP_REMOVE_ENTRY != 0 ) - - uint32_t ulARPRemoveCacheEntryByMac( const MACAddress_t * pxMACAddress ) - { - BaseType_t x; - uint32_t lResult = 0; - - /* For each entry in the ARP cache table. */ - for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) - { - if( ( memcmp( xARPCache[ x ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ) == 0 ) ) - { - lResult = xARPCache[ x ].ulIPAddress; - memset( &xARPCache[ x ], '\0', sizeof( xARPCache[ x ] ) ); - break; - } - } - - return lResult; - } - -#endif /* ipconfigUSE_ARP_REMOVE_ENTRY != 0 */ -/*-----------------------------------------------------------*/ - -void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, const uint32_t ulIPAddress ) -{ -BaseType_t x = 0; -BaseType_t xIpEntry = -1; -BaseType_t xMacEntry = -1; -BaseType_t xUseEntry = 0; -uint8_t ucMinAgeFound = 0U; - - #if( ipconfigARP_STORES_REMOTE_ADDRESSES == 0 ) - /* Only process the IP address if it is on the local network. - Unless: when '*ipLOCAL_IP_ADDRESS_POINTER' equals zero, the IP-address - and netmask are still unknown. */ - if( ( ( ulIPAddress & xNetworkAddressing.ulNetMask ) == ( ( *ipLOCAL_IP_ADDRESS_POINTER ) & xNetworkAddressing.ulNetMask ) ) || - ( *ipLOCAL_IP_ADDRESS_POINTER == 0ul ) ) - #else - /* If ipconfigARP_STORES_REMOTE_ADDRESSES is non-zero, IP addresses with - a different netmask will also be stored. After when replying to a UDP - message from a different netmask, the IP address can be looped up and a - reply sent. This option is useful for systems with multiple gateways, - the reply will surely arrive. If ipconfigARP_STORES_REMOTE_ADDRESSES is - zero the the gateway address is the only option. */ - if( pdTRUE ) - #endif - { - /* Start with the maximum possible number. */ - ucMinAgeFound--; - - /* For each entry in the ARP cache table. */ - for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) - { - /* Does this line in the cache table hold an entry for the IP - address being queried? */ - if( xARPCache[ x ].ulIPAddress == ulIPAddress ) - { - if( pxMACAddress == NULL ) - { - /* In case the parameter pxMACAddress is NULL, an entry will be reserved to - indicate that there is an outstanding ARP request, This entry will have - "ucValid == pdFALSE". */ - xIpEntry = x; - break; - } - - /* See if the MAC-address also matches. */ - if( memcmp( xARPCache[ x ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ) == 0 ) - { - /* This function will be called for each received packet - As this is by far the most common path the coding standard - is relaxed in this case and a return is permitted as an - optimisation. */ - xARPCache[ x ].ucAge = ( uint8_t ) ipconfigMAX_ARP_AGE; - xARPCache[ x ].ucValid = ( uint8_t ) pdTRUE; - return; - } - - /* Found an entry containing ulIPAddress, but the MAC address - doesn't match. Might be an entry with ucValid=pdFALSE, waiting - for an ARP reply. Still want to see if there is match with the - given MAC address.ucBytes. If found, either of the two entries - must be cleared. */ - xIpEntry = x; - } - else if( ( pxMACAddress != NULL ) && ( memcmp( xARPCache[ x ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ) == 0 ) ) - { - /* Found an entry with the given MAC-address, but the IP-address - is different. Continue looping to find a possible match with - ulIPAddress. */ - #if( ipconfigARP_STORES_REMOTE_ADDRESSES != 0 ) - /* If ARP stores the MAC address of IP addresses outside the - network, than the MAC address of the gateway should not be - overwritten. */ - BaseType_t bIsLocal[ 2 ]; - bIsLocal[ 0 ] = ( ( xARPCache[ x ].ulIPAddress & xNetworkAddressing.ulNetMask ) == ( ( *ipLOCAL_IP_ADDRESS_POINTER ) & xNetworkAddressing.ulNetMask ) ); - bIsLocal[ 1 ] = ( ( ulIPAddress & xNetworkAddressing.ulNetMask ) == ( ( *ipLOCAL_IP_ADDRESS_POINTER ) & xNetworkAddressing.ulNetMask ) ); - if( bIsLocal[ 0 ] == bIsLocal[ 1 ] ) - { - xMacEntry = x; - } - #else - xMacEntry = x; - #endif - } - /* _HT_ - Shouldn't we test for xARPCache[ x ].ucValid == pdFALSE here ? */ - else if( xARPCache[ x ].ucAge < ucMinAgeFound ) - { - /* As the table is traversed, remember the table row that - contains the oldest entry (the lowest age count, as ages are - decremented to zero) so the row can be re-used if this function - needs to add an entry that does not already exist. */ - ucMinAgeFound = xARPCache[ x ].ucAge; - xUseEntry = x; - } - } - - if( xMacEntry >= 0 ) - { - xUseEntry = xMacEntry; - - if( xIpEntry >= 0 ) - { - /* Both the MAC address as well as the IP address were found in - different locations: clear the entry which matches the - IP-address */ - memset( &xARPCache[ xIpEntry ], '\0', sizeof( xARPCache[ xIpEntry ] ) ); - } - } - else if( xIpEntry >= 0 ) - { - /* An entry containing the IP-address was found, but it had a different MAC address */ - xUseEntry = xIpEntry; - } - - /* If the entry was not found, we use the oldest entry and set the IPaddress */ - xARPCache[ xUseEntry ].ulIPAddress = ulIPAddress; - - if( pxMACAddress != NULL ) - { - memcpy( xARPCache[ xUseEntry ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ); - - iptraceARP_TABLE_ENTRY_CREATED( ulIPAddress, (*pxMACAddress) ); - /* And this entry does not need immediate attention */ - xARPCache[ xUseEntry ].ucAge = ( uint8_t ) ipconfigMAX_ARP_AGE; - xARPCache[ xUseEntry ].ucValid = ( uint8_t ) pdTRUE; - } - else if( xIpEntry < 0 ) - { - xARPCache[ xUseEntry ].ucAge = ( uint8_t ) ipconfigMAX_ARP_RETRANSMISSIONS; - xARPCache[ xUseEntry ].ucValid = ( uint8_t ) pdFALSE; - } - } -} -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_ARP_REVERSED_LOOKUP == 1 ) - eARPLookupResult_t eARPGetCacheEntryByMac( MACAddress_t * const pxMACAddress, uint32_t *pulIPAddress ) - { - BaseType_t x; - eARPLookupResult_t eReturn = eARPCacheMiss; - - /* Loop through each entry in the ARP cache. */ - for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) - { - /* Does this row in the ARP cache table hold an entry for the MAC - address being searched? */ - if( memcmp( pxMACAddress->ucBytes, xARPCache[ x ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) - { - *pulIPAddress = xARPCache[ x ].ulIPAddress; - eReturn = eARPCacheHit; - break; - } - } - - return eReturn; - } -#endif /* ipconfigUSE_ARP_REVERSED_LOOKUP */ - -/*-----------------------------------------------------------*/ - -eARPLookupResult_t eARPGetCacheEntry( uint32_t *pulIPAddress, MACAddress_t * const pxMACAddress ) -{ -eARPLookupResult_t eReturn; -uint32_t ulAddressToLookup; - -#if( ipconfigUSE_LLMNR == 1 ) - if( *pulIPAddress == ipLLMNR_IP_ADDR ) /* Is in network byte order. */ - { - /* The LLMNR IP-address has a fixed virtual MAC address. */ - memcpy( pxMACAddress->ucBytes, xLLMNR_MacAdress.ucBytes, sizeof( MACAddress_t ) ); - eReturn = eARPCacheHit; - } - else -#endif - if( ( *pulIPAddress == ipBROADCAST_IP_ADDRESS ) || /* Is it the general broadcast address 255.255.255.255? */ - ( *pulIPAddress == xNetworkAddressing.ulBroadcastAddress ) )/* Or a local broadcast address, eg 192.168.1.255? */ - { - /* This is a broadcast so uses the broadcast MAC address. */ - memcpy( pxMACAddress->ucBytes, xBroadcastMACAddress.ucBytes, sizeof( MACAddress_t ) ); - eReturn = eARPCacheHit; - } - else if( *ipLOCAL_IP_ADDRESS_POINTER == 0UL ) - { - /* The IP address has not yet been assigned, so there is nothing that - can be done. */ - eReturn = eCantSendPacket; - } - else - { - eReturn = eARPCacheMiss; - - if( ( *pulIPAddress & xNetworkAddressing.ulNetMask ) != ( ( *ipLOCAL_IP_ADDRESS_POINTER ) & xNetworkAddressing.ulNetMask ) ) - { -#if( ipconfigARP_STORES_REMOTE_ADDRESSES == 1 ) - eReturn = prvCacheLookup( *pulIPAddress, pxMACAddress ); - - if( eReturn == eARPCacheHit ) - { - /* The stack is configured to store 'remote IP addresses', i.e. addresses - belonging to a different the netmask. prvCacheLookup() returned a hit, so - the MAC address is known */ - } - else -#endif - { - /* The IP address is off the local network, so look up the - hardware address of the router, if any. */ - if( xNetworkAddressing.ulGatewayAddress != ( uint32_t )0u ) - { - ulAddressToLookup = xNetworkAddressing.ulGatewayAddress; - } - else - { - ulAddressToLookup = *pulIPAddress; - } - } - } - else - { - /* The IP address is on the local network, so lookup the requested - IP address directly. */ - ulAddressToLookup = *pulIPAddress; - } - - if( eReturn == eARPCacheMiss ) - { - if( ulAddressToLookup == 0UL ) - { - /* The address is not on the local network, and there is not a - router. */ - eReturn = eCantSendPacket; - } - else - { - eReturn = prvCacheLookup( ulAddressToLookup, pxMACAddress ); - - if( eReturn == eARPCacheMiss ) - { - /* It might be that the ARP has to go to the gateway. */ - *pulIPAddress = ulAddressToLookup; - } - } - } - } - - return eReturn; -} - -/*-----------------------------------------------------------*/ - -static eARPLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, MACAddress_t * const pxMACAddress ) -{ -BaseType_t x; -eARPLookupResult_t eReturn = eARPCacheMiss; - - /* Loop through each entry in the ARP cache. */ - for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) - { - /* Does this row in the ARP cache table hold an entry for the IP address - being queried? */ - if( xARPCache[ x ].ulIPAddress == ulAddressToLookup ) - { - /* A matching valid entry was found. */ - if( xARPCache[ x ].ucValid == ( uint8_t ) pdFALSE ) - { - /* This entry is waiting an ARP reply, so is not valid. */ - eReturn = eCantSendPacket; - } - else - { - /* A valid entry was found. */ - memcpy( pxMACAddress->ucBytes, xARPCache[ x ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ); - eReturn = eARPCacheHit; - } - break; - } - } - - return eReturn; -} -/*-----------------------------------------------------------*/ - -void vARPAgeCache( void ) -{ -BaseType_t x; -TickType_t xTimeNow; - - /* Loop through each entry in the ARP cache. */ - for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) - { - /* If the entry is valid (its age is greater than zero). */ - if( xARPCache[ x ].ucAge > 0U ) - { - /* Decrement the age value of the entry in this ARP cache table row. - When the age reaches zero it is no longer considered valid. */ - ( xARPCache[ x ].ucAge )--; - - /* If the entry is not yet valid, then it is waiting an ARP - reply, and the ARP request should be retransmitted. */ - if( xARPCache[ x ].ucValid == ( uint8_t ) pdFALSE ) - { - FreeRTOS_OutputARPRequest( xARPCache[ x ].ulIPAddress ); - } - else if( xARPCache[ x ].ucAge <= ( uint8_t ) arpMAX_ARP_AGE_BEFORE_NEW_ARP_REQUEST ) - { - /* This entry will get removed soon. See if the MAC address is - still valid to prevent this happening. */ - iptraceARP_TABLE_ENTRY_WILL_EXPIRE( xARPCache[ x ].ulIPAddress ); - FreeRTOS_OutputARPRequest( xARPCache[ x ].ulIPAddress ); - } - else - { - /* The age has just ticked down, with nothing to do. */ - } - - if( xARPCache[ x ].ucAge == 0u ) - { - /* The entry is no longer valid. Wipe it out. */ - iptraceARP_TABLE_ENTRY_EXPIRED( xARPCache[ x ].ulIPAddress ); - xARPCache[ x ].ulIPAddress = 0UL; - } - } - } - - xTimeNow = xTaskGetTickCount (); - - if( ( xLastGratuitousARPTime == ( TickType_t ) 0 ) || ( ( xTimeNow - xLastGratuitousARPTime ) > ( TickType_t ) arpGRATUITOUS_ARP_PERIOD ) ) - { - FreeRTOS_OutputARPRequest( *ipLOCAL_IP_ADDRESS_POINTER ); - xLastGratuitousARPTime = xTimeNow; - } -} -/*-----------------------------------------------------------*/ - -void vARPSendGratuitous( void ) -{ - /* Setting xLastGratuitousARPTime to 0 will force a gratuitous ARP the next - time vARPAgeCache() is called. */ - xLastGratuitousARPTime = ( TickType_t ) 0; - - /* Let the IP-task call vARPAgeCache(). */ - xSendEventToIPTask( eARPTimerEvent ); -} - -/*-----------------------------------------------------------*/ -void FreeRTOS_OutputARPRequest( uint32_t ulIPAddress ) -{ -NetworkBufferDescriptor_t *pxNetworkBuffer; - - /* This is called from the context of the IP event task, so a block time - must not be used. */ - pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( sizeof( ARPPacket_t ), ( TickType_t ) 0 ); - - if( pxNetworkBuffer != NULL ) - { - pxNetworkBuffer->ulIPAddress = ulIPAddress; - vARPGenerateRequestPacket( pxNetworkBuffer ); - - #if defined( ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - { - if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - { - BaseType_t xIndex; - - for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) - { - pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0u; - } - pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; - } - } - #endif - - xNetworkInterfaceOutput( pxNetworkBuffer, pdTRUE ); - } -} - -void vARPGenerateRequestPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer ) -{ -ARPPacket_t *pxARPPacket; - - pxARPPacket = ( ARPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - - /* memcpy the const part of the header information into the correct - location in the packet. This copies: - xEthernetHeader.ulDestinationAddress - xEthernetHeader.usFrameType; - xARPHeader.usHardwareType; - xARPHeader.usProtocolType; - xARPHeader.ucHardwareAddressLength; - xARPHeader.ucProtocolAddressLength; - xARPHeader.usOperation; - xARPHeader.xTargetHardwareAddress; - */ - memcpy( ( void * ) pxARPPacket, ( void * ) xDefaultPartARPPacketHeader, sizeof( xDefaultPartARPPacketHeader ) ); - memcpy( ( void * ) pxARPPacket->xEthernetHeader.xSourceAddress.ucBytes , ( void * ) ipLOCAL_MAC_ADDRESS, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); - memcpy( ( void * ) pxARPPacket->xARPHeader.xSenderHardwareAddress.ucBytes, ( void * ) ipLOCAL_MAC_ADDRESS, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); - - memcpy( ( void* )pxARPPacket->xARPHeader.ucSenderProtocolAddress, ( void* )ipLOCAL_IP_ADDRESS_POINTER, sizeof( pxARPPacket->xARPHeader.ucSenderProtocolAddress ) ); - pxARPPacket->xARPHeader.ulTargetProtocolAddress = pxNetworkBuffer->ulIPAddress; - - pxNetworkBuffer->xDataLength = sizeof( ARPPacket_t ); - - iptraceCREATING_ARP_REQUEST( pxNetworkBuffer->ulIPAddress ); -} -/*-----------------------------------------------------------*/ - -void FreeRTOS_ClearARP( void ) -{ - memset( xARPCache, '\0', sizeof( xARPCache ) ); -} -/*-----------------------------------------------------------*/ - -#if( ipconfigHAS_PRINTF != 0 ) || ( ipconfigHAS_DEBUG_PRINTF != 0 ) - - void FreeRTOS_PrintARPCache( void ) - { - BaseType_t x, xCount = 0; - - /* Loop through each entry in the ARP cache. */ - for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) - { - if( ( xARPCache[ x ].ulIPAddress != 0ul ) && ( xARPCache[ x ].ucAge > 0U ) ) - { - /* See if the MAC-address also matches, and we're all happy */ - FreeRTOS_printf( ( "Arp %2ld: %3u - %16lxip : %02x:%02x:%02x : %02x:%02x:%02x\n", - x, - xARPCache[ x ].ucAge, - xARPCache[ x ].ulIPAddress, - xARPCache[ x ].xMACAddress.ucBytes[0], - xARPCache[ x ].xMACAddress.ucBytes[1], - xARPCache[ x ].xMACAddress.ucBytes[2], - xARPCache[ x ].xMACAddress.ucBytes[3], - xARPCache[ x ].xMACAddress.ucBytes[4], - xARPCache[ x ].xMACAddress.ucBytes[5] ) ); - xCount++; - } - } - - FreeRTOS_printf( ( "Arp has %ld entries\n", xCount ) ); - } - -#endif /* ( ipconfigHAS_PRINTF != 0 ) || ( ipconfigHAS_DEBUG_PRINTF != 0 ) */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DHCP.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DHCP.c deleted file mode 100755 index 8fe04bb..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DHCP.c +++ /dev/null @@ -1,1011 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -/* Standard includes. */ -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_TCP_IP.h" -#include "FreeRTOS_DHCP.h" -#include "FreeRTOS_ARP.h" -#include "NetworkInterface.h" -#include "NetworkBufferManagement.h" - -/* Exclude the entire file if DHCP is not enabled. */ -#if( ipconfigUSE_DHCP != 0 ) - -#if ( ipconfigUSE_DHCP != 0 ) && ( ipconfigNETWORK_MTU < 586u ) - /* DHCP must be able to receive an options field of 312 bytes, the fixed - part of the DHCP packet is 240 bytes, and the IP/UDP headers take 28 bytes. */ - #error ipconfigNETWORK_MTU needs to be at least 586 to use DHCP -#endif - -/* Parameter widths in the DHCP packet. */ -#define dhcpCLIENT_HARDWARE_ADDRESS_LENGTH 16 -#define dhcpSERVER_HOST_NAME_LENGTH 64 -#define dhcpBOOT_FILE_NAME_LENGTH 128 - -/* Timer parameters */ -#ifndef dhcpINITIAL_DHCP_TX_PERIOD - #define dhcpINITIAL_TIMER_PERIOD ( pdMS_TO_TICKS( 250 ) ) - #define dhcpINITIAL_DHCP_TX_PERIOD ( pdMS_TO_TICKS( 5000 ) ) -#endif - -/* Codes of interest found in the DHCP options field. */ -#define dhcpZERO_PAD_OPTION_CODE ( 0u ) -#define dhcpSUBNET_MASK_OPTION_CODE ( 1u ) -#define dhcpGATEWAY_OPTION_CODE ( 3u ) -#define dhcpDNS_SERVER_OPTIONS_CODE ( 6u ) -#define dhcpDNS_HOSTNAME_OPTIONS_CODE ( 12u ) -#define dhcpREQUEST_IP_ADDRESS_OPTION_CODE ( 50u ) -#define dhcpLEASE_TIME_OPTION_CODE ( 51u ) -#define dhcpMESSAGE_TYPE_OPTION_CODE ( 53u ) -#define dhcpSERVER_IP_ADDRESS_OPTION_CODE ( 54u ) -#define dhcpPARAMETER_REQUEST_OPTION_CODE ( 55u ) -#define dhcpCLIENT_IDENTIFIER_OPTION_CODE ( 61u ) - -/* The four DHCP message types of interest. */ -#define dhcpMESSAGE_TYPE_DISCOVER ( 1 ) -#define dhcpMESSAGE_TYPE_OFFER ( 2 ) -#define dhcpMESSAGE_TYPE_REQUEST ( 3 ) -#define dhcpMESSAGE_TYPE_ACK ( 5 ) -#define dhcpMESSAGE_TYPE_NACK ( 6 ) - -/* Offsets into the transmitted DHCP options fields at which various parameters -are located. */ -#define dhcpCLIENT_IDENTIFIER_OFFSET ( 5 ) -#define dhcpREQUESTED_IP_ADDRESS_OFFSET ( 13 ) -#define dhcpDHCP_SERVER_IP_ADDRESS_OFFSET ( 19 ) - -/* Values used in the DHCP packets. */ -#define dhcpREQUEST_OPCODE ( 1 ) -#define dhcpREPLY_OPCODE ( 2 ) -#define dhcpADDRESS_TYPE_ETHERNET ( 1 ) -#define dhcpETHERNET_ADDRESS_LENGTH ( 6 ) - -/* If a lease time is not received, use the default of two days. */ -/* 48 hours in ticks. Can not use pdMS_TO_TICKS() as integer overflow can occur. */ -#define dhcpDEFAULT_LEASE_TIME ( ( 48UL * 60UL * 60UL ) * configTICK_RATE_HZ ) - -/* Don't allow the lease time to be too short. */ -#define dhcpMINIMUM_LEASE_TIME ( pdMS_TO_TICKS( 60000UL ) ) /* 60 seconds in ticks. */ - -/* Marks the end of the variable length options field in the DHCP packet. */ -#define dhcpOPTION_END_BYTE 0xffu - -/* Offset into a DHCP message at which the first byte of the options is -located. */ -#define dhcpFIRST_OPTION_BYTE_OFFSET ( 0xf0 ) - -/* When walking the variable length options field, the following value is used -to ensure the walk has not gone past the end of the valid options. 2 bytes is -made up of the length byte, and minimum one byte value. */ -#define dhcpMAX_OPTION_LENGTH_OF_INTEREST ( 2L ) - -/* Standard DHCP port numbers and magic cookie value. */ -#if( ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN ) - #define dhcpCLIENT_PORT 0x4400u - #define dhcpSERVER_PORT 0x4300u - #define dhcpCOOKIE 0x63538263ul - #define dhcpBROADCAST 0x0080u -#else - #define dhcpCLIENT_PORT 0x0044u - #define dhcpSERVER_PORT 0x0043u - #define dhcpCOOKIE 0x63825363ul - #define dhcpBROADCAST 0x8000u -#endif /* ipconfigBYTE_ORDER */ - -#include "pack_struct_start.h" -struct xDHCPMessage -{ - uint8_t ucOpcode; - uint8_t ucAddressType; - uint8_t ucAddressLength; - uint8_t ucHops; - uint32_t ulTransactionID; - uint16_t usElapsedTime; - uint16_t usFlags; - uint32_t ulClientIPAddress_ciaddr; - uint32_t ulYourIPAddress_yiaddr; - uint32_t ulServerIPAddress_siaddr; - uint32_t ulRelayAgentIPAddress_giaddr; - uint8_t ucClientHardwareAddress[ dhcpCLIENT_HARDWARE_ADDRESS_LENGTH ]; - uint8_t ucServerHostName[ dhcpSERVER_HOST_NAME_LENGTH ]; - uint8_t ucBootFileName[ dhcpBOOT_FILE_NAME_LENGTH ]; - uint32_t ulDHCPCookie; - uint8_t ucFirstOptionByte; -} -#include "pack_struct_end.h" -typedef struct xDHCPMessage DHCPMessage_t; - -/* DHCP state machine states. */ -typedef enum -{ - eWaitingSendFirstDiscover = 0, /* Initial state. Send a discover the first time it is called, and reset all timers. */ - eWaitingOffer, /* Either resend the discover, or, if the offer is forthcoming, send a request. */ - eWaitingAcknowledge, /* Either resend the request. */ - #if( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 ) - eGetLinkLayerAddress, /* When DHCP didn't respond, try to obtain a LinkLayer address 168.254.x.x. */ - #endif - eLeasedAddress, /* Resend the request at the appropriate time to renew the lease. */ - eNotUsingLeasedAddress /* DHCP failed, and a default IP address is being used. */ -} eDHCPState_t; - -/* Hold information in between steps in the DHCP state machine. */ -struct xDHCP_DATA -{ - uint32_t ulTransactionId; - uint32_t ulOfferedIPAddress; - uint32_t ulDHCPServerAddress; - uint32_t ulLeaseTime; - /* Hold information on the current timer state. */ - TickType_t xDHCPTxTime; - TickType_t xDHCPTxPeriod; - /* Try both without and with the broadcast flag */ - BaseType_t xUseBroadcast; - /* Maintains the DHCP state machine state. */ - eDHCPState_t eDHCPState; - /* The UDP socket used for all incoming and outgoing DHCP traffic. */ - Socket_t xDHCPSocket; -}; - -typedef struct xDHCP_DATA DHCPData_t; - -#if( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 ) - /* Define the Link Layer IP address: 169.254.x.x */ - #define LINK_LAYER_ADDRESS_0 169 - #define LINK_LAYER_ADDRESS_1 254 - - /* Define the netmask used: 255.255.0.0 */ - #define LINK_LAYER_NETMASK_0 255 - #define LINK_LAYER_NETMASK_1 255 - #define LINK_LAYER_NETMASK_2 0 - #define LINK_LAYER_NETMASK_3 0 -#endif - - -/* - * Generate a DHCP discover message and send it on the DHCP socket. - */ -static void prvSendDHCPDiscover( void ); - -/* - * Interpret message received on the DHCP socket. - */ -static BaseType_t prvProcessDHCPReplies( BaseType_t xExpectedMessageType ); - -/* - * Generate a DHCP request packet, and send it on the DHCP socket. - */ -static void prvSendDHCPRequest( void ); - -/* - * Prepare to start a DHCP transaction. This initialises some state variables - * and creates the DHCP socket if necessary. - */ -static void prvInitialiseDHCP( void ); - -/* - * Creates the part of outgoing DHCP messages that are common to all outgoing - * DHCP messages. - */ -static uint8_t *prvCreatePartDHCPMessage( struct freertos_sockaddr *pxAddress, BaseType_t xOpcode, const uint8_t * const pucOptionsArray, size_t *pxOptionsArraySize ); - -/* - * Create the DHCP socket, if it has not been created already. - */ -static void prvCreateDHCPSocket( void ); - -/* - * After DHCP has failed to answer, prepare everything to start searching - * for (trying-out) LinkLayer IP-addresses, using the random method: Send - * a gratuitous ARP request and wait if another device responds to it. - */ -#if( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 ) - static void prvPrepareLinkLayerIPLookUp( void ); -#endif - -/*-----------------------------------------------------------*/ - -/* The next DHCP transaction Id to be used. */ -static DHCPData_t xDHCPData; - -/*-----------------------------------------------------------*/ - -BaseType_t xIsDHCPSocket( Socket_t xSocket ) -{ -BaseType_t xReturn; - - if( xDHCPData.xDHCPSocket == xSocket ) - { - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -void vDHCPProcess( BaseType_t xReset ) -{ -BaseType_t xGivingUp = pdFALSE; -#if( ipconfigUSE_DHCP_HOOK != 0 ) - eDHCPCallbackAnswer_t eAnswer; -#endif /* ipconfigUSE_DHCP_HOOK */ - - /* Is DHCP starting over? */ - if( xReset != pdFALSE ) - { - xDHCPData.eDHCPState = eWaitingSendFirstDiscover; - } - - switch( xDHCPData.eDHCPState ) - { - case eWaitingSendFirstDiscover : - /* Ask the user if a DHCP discovery is required. */ - #if( ipconfigUSE_DHCP_HOOK != 0 ) - eAnswer = xApplicationDHCPHook( eDHCPPhasePreDiscover, xNetworkAddressing.ulDefaultIPAddress ); - if( eAnswer == eDHCPContinue ) - #endif /* ipconfigUSE_DHCP_HOOK */ - { - /* Initial state. Create the DHCP socket, timer, etc. if they - have not already been created. */ - prvInitialiseDHCP(); - - /* See if prvInitialiseDHCP() has creates a socket. */ - if( xDHCPData.xDHCPSocket == NULL ) - { - xGivingUp = pdTRUE; - break; - } - - *ipLOCAL_IP_ADDRESS_POINTER = 0UL; - - /* Send the first discover request. */ - if( xDHCPData.xDHCPSocket != NULL ) - { - xDHCPData.xDHCPTxTime = xTaskGetTickCount(); - prvSendDHCPDiscover( ); - xDHCPData.eDHCPState = eWaitingOffer; - } - } - #if( ipconfigUSE_DHCP_HOOK != 0 ) - else - { - if( eAnswer == eDHCPUseDefaults ) - { - memcpy( &xNetworkAddressing, &xDefaultAddressing, sizeof( xNetworkAddressing ) ); - } - - /* The user indicates that the DHCP process does not continue. */ - xGivingUp = pdTRUE; - } - #endif /* ipconfigUSE_DHCP_HOOK */ - break; - - case eWaitingOffer : - - xGivingUp = pdFALSE; - - /* Look for offers coming in. */ - if( prvProcessDHCPReplies( dhcpMESSAGE_TYPE_OFFER ) == pdPASS ) - { - #if( ipconfigUSE_DHCP_HOOK != 0 ) - /* Ask the user if a DHCP request is required. */ - eAnswer = xApplicationDHCPHook( eDHCPPhasePreRequest, xDHCPData.ulOfferedIPAddress ); - - if( eAnswer == eDHCPContinue ) - #endif /* ipconfigUSE_DHCP_HOOK */ - { - /* An offer has been made, the user wants to continue, - generate the request. */ - xDHCPData.xDHCPTxTime = xTaskGetTickCount(); - xDHCPData.xDHCPTxPeriod = dhcpINITIAL_DHCP_TX_PERIOD; - prvSendDHCPRequest( ); - xDHCPData.eDHCPState = eWaitingAcknowledge; - break; - } - - #if( ipconfigUSE_DHCP_HOOK != 0 ) - if( eAnswer == eDHCPUseDefaults ) - { - memcpy( &xNetworkAddressing, &xDefaultAddressing, sizeof( xNetworkAddressing ) ); - } - - /* The user indicates that the DHCP process does not continue. */ - xGivingUp = pdTRUE; - #endif /* ipconfigUSE_DHCP_HOOK */ - } - else if( ( xTaskGetTickCount() - xDHCPData.xDHCPTxTime ) > xDHCPData.xDHCPTxPeriod ) - { - /* It is time to send another Discover. Increase the time - period, and if it has not got to the point of giving up - send - another discovery. */ - xDHCPData.xDHCPTxPeriod <<= 1; - - if( xDHCPData.xDHCPTxPeriod <= ipconfigMAXIMUM_DISCOVER_TX_PERIOD ) - { - xDHCPData.ulTransactionId = ipconfigRAND32( ); - - if( 0 != xDHCPData.ulTransactionId ) - { - xDHCPData.xDHCPTxTime = xTaskGetTickCount( ); - xDHCPData.xUseBroadcast = !xDHCPData.xUseBroadcast; - prvSendDHCPDiscover( ); - FreeRTOS_debug_printf( ( "vDHCPProcess: timeout %lu ticks\n", xDHCPData.xDHCPTxPeriod ) ); - } - else - { - FreeRTOS_debug_printf( ( "vDHCPProcess: failed to generate a random Transaction ID\n" ) ); - } - } - else - { - FreeRTOS_debug_printf( ( "vDHCPProcess: giving up %lu > %lu ticks\n", xDHCPData.xDHCPTxPeriod, ipconfigMAXIMUM_DISCOVER_TX_PERIOD ) ); - - #if( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 ) - { - /* Only use a fake Ack if the default IP address == 0x00 - and the link local addressing is used. Start searching - a free LinkLayer IP-address. Next state will be - 'eGetLinkLayerAddress'. */ - prvPrepareLinkLayerIPLookUp(); - - /* Setting an IP address manually so set to not using - leased address mode. */ - xDHCPData.eDHCPState = eGetLinkLayerAddress; - } - #else - { - xGivingUp = pdTRUE; - } - #endif /* ipconfigDHCP_FALL_BACK_AUTO_IP */ - } - } - break; - - case eWaitingAcknowledge : - - /* Look for acks coming in. */ - if( prvProcessDHCPReplies( dhcpMESSAGE_TYPE_ACK ) == pdPASS ) - { - FreeRTOS_debug_printf( ( "vDHCPProcess: acked %lxip\n", FreeRTOS_ntohl( xDHCPData.ulOfferedIPAddress ) ) ); - - /* DHCP completed. The IP address can now be used, and the - timer set to the lease timeout time. */ - *ipLOCAL_IP_ADDRESS_POINTER = xDHCPData.ulOfferedIPAddress; - - /* Setting the 'local' broadcast address, something like - '192.168.1.255'. */ - xNetworkAddressing.ulBroadcastAddress = ( xDHCPData.ulOfferedIPAddress & xNetworkAddressing.ulNetMask ) | ~xNetworkAddressing.ulNetMask; - xDHCPData.eDHCPState = eLeasedAddress; - - iptraceDHCP_SUCCEDEED( xDHCPData.ulOfferedIPAddress ); - - /* DHCP failed, the default configured IP-address will be used - Now call vIPNetworkUpCalls() to send the network-up event and - start the ARP timer. */ - vIPNetworkUpCalls( ); - - /* Close socket to ensure packets don't queue on it. */ - vSocketClose( xDHCPData.xDHCPSocket ); - xDHCPData.xDHCPSocket = NULL; - - if( xDHCPData.ulLeaseTime == 0UL ) - { - xDHCPData.ulLeaseTime = dhcpDEFAULT_LEASE_TIME; - } - else if( xDHCPData.ulLeaseTime < dhcpMINIMUM_LEASE_TIME ) - { - xDHCPData.ulLeaseTime = dhcpMINIMUM_LEASE_TIME; - } - else - { - /* The lease time is already valid. */ - } - - /* Check for clashes. */ - vARPSendGratuitous(); - vIPReloadDHCPTimer( xDHCPData.ulLeaseTime ); - } - else - { - /* Is it time to send another Discover? */ - if( ( xTaskGetTickCount() - xDHCPData.xDHCPTxTime ) > xDHCPData.xDHCPTxPeriod ) - { - /* Increase the time period, and if it has not got to the - point of giving up - send another request. */ - xDHCPData.xDHCPTxPeriod <<= 1; - - if( xDHCPData.xDHCPTxPeriod <= ipconfigMAXIMUM_DISCOVER_TX_PERIOD ) - { - xDHCPData.xDHCPTxTime = xTaskGetTickCount(); - prvSendDHCPRequest( ); - } - else - { - /* Give up, start again. */ - xDHCPData.eDHCPState = eWaitingSendFirstDiscover; - } - } - } - break; - - #if( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 ) - case eGetLinkLayerAddress: - if( ( xTaskGetTickCount() - xDHCPData.xDHCPTxTime ) > xDHCPData.xDHCPTxPeriod ) - { - if( xARPHadIPClash == pdFALSE ) - { - /* ARP OK. proceed. */ - iptraceDHCP_SUCCEDEED( xDHCPData.ulOfferedIPAddress ); - - /* Auto-IP succeeded, the default configured IP-address will - be used. Now call vIPNetworkUpCalls() to send the - network-up event and start the ARP timer. */ - vIPNetworkUpCalls( ); - xDHCPData.eDHCPState = eNotUsingLeasedAddress; - } - else - { - /* ARP clashed - try another IP address. */ - prvPrepareLinkLayerIPLookUp(); - - /* Setting an IP address manually so set to not using leased - address mode. */ - xDHCPData.eDHCPState = eGetLinkLayerAddress; - } - } - break; - #endif /* ipconfigDHCP_FALL_BACK_AUTO_IP */ - - case eLeasedAddress : - - /* Resend the request at the appropriate time to renew the lease. */ - prvCreateDHCPSocket(); - - if( xDHCPData.xDHCPSocket != NULL ) - { - xDHCPData.xDHCPTxTime = xTaskGetTickCount(); - xDHCPData.xDHCPTxPeriod = dhcpINITIAL_DHCP_TX_PERIOD; - prvSendDHCPRequest( ); - xDHCPData.eDHCPState = eWaitingAcknowledge; - - /* From now on, we should be called more often */ - vIPReloadDHCPTimer( dhcpINITIAL_TIMER_PERIOD ); - } - break; - - case eNotUsingLeasedAddress: - - vIPSetDHCPTimerEnableState( pdFALSE ); - break; - - default: - break; - } - - if( xGivingUp != pdFALSE ) - { - /* xGivingUp became true either because of a time-out, or because - xApplicationDHCPHook() returned another value than 'eDHCPContinue', - meaning that the conversion is canceled from here. */ - - /* Revert to static IP address. */ - taskENTER_CRITICAL(); - { - *ipLOCAL_IP_ADDRESS_POINTER = xNetworkAddressing.ulDefaultIPAddress; - iptraceDHCP_REQUESTS_FAILED_USING_DEFAULT_IP_ADDRESS( xNetworkAddressing.ulDefaultIPAddress ); - } - taskEXIT_CRITICAL(); - - xDHCPData.eDHCPState = eNotUsingLeasedAddress; - vIPSetDHCPTimerEnableState( pdFALSE ); - - /* DHCP failed, the default configured IP-address will be used. Now - call vIPNetworkUpCalls() to send the network-up event and start the ARP - timer. */ - vIPNetworkUpCalls( ); - - /* Test if socket was indeed created. */ - if( xDHCPData.xDHCPSocket != NULL ) - { - /* Close socket to ensure packets don't queue on it. */ - vSocketClose( xDHCPData.xDHCPSocket ); - xDHCPData.xDHCPSocket = NULL; - } - } -} -/*-----------------------------------------------------------*/ - -static void prvCreateDHCPSocket( void ) -{ -struct freertos_sockaddr xAddress; -BaseType_t xReturn; -TickType_t xTimeoutTime = ( TickType_t ) 0; - - /* Create the socket, if it has not already been created. */ - if( xDHCPData.xDHCPSocket == NULL ) - { - xDHCPData.xDHCPSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP ); - if( xDHCPData.xDHCPSocket != FREERTOS_INVALID_SOCKET ) - { - - /* Ensure the Rx and Tx timeouts are zero as the DHCP executes in the - context of the IP task. */ - FreeRTOS_setsockopt( xDHCPData.xDHCPSocket, 0, FREERTOS_SO_RCVTIMEO, ( void * ) &xTimeoutTime, sizeof( TickType_t ) ); - FreeRTOS_setsockopt( xDHCPData.xDHCPSocket, 0, FREERTOS_SO_SNDTIMEO, ( void * ) &xTimeoutTime, sizeof( TickType_t ) ); - - /* Bind to the standard DHCP client port. */ - xAddress.sin_port = ( uint16_t ) dhcpCLIENT_PORT; - xReturn = vSocketBind( xDHCPData.xDHCPSocket, &xAddress, sizeof( xAddress ), pdFALSE ); - if( xReturn != 0 ) - { - /* Binding failed, close the socket again. */ - vSocketClose( xDHCPData.xDHCPSocket ); - xDHCPData.xDHCPSocket = NULL; - } - } - else - { - /* Change to NULL for easier testing. */ - xDHCPData.xDHCPSocket = NULL; - } - } -} -/*-----------------------------------------------------------*/ - -static void prvInitialiseDHCP( void ) -{ - /* Initialise the parameters that will be set by the DHCP process. Per - https://www.ietf.org/rfc/rfc2131.txt, Transaction ID should be a random - value chosen by the client. */ - xDHCPData.ulTransactionId = ipconfigRAND32(); - - /* Check for random number generator API failure. */ - if( 0 != xDHCPData.ulTransactionId ) - { - xDHCPData.xUseBroadcast = 0; - xDHCPData.ulOfferedIPAddress = 0UL; - xDHCPData.ulDHCPServerAddress = 0UL; - xDHCPData.xDHCPTxPeriod = dhcpINITIAL_DHCP_TX_PERIOD; - - /* Create the DHCP socket if it has not already been created. */ - prvCreateDHCPSocket(); - FreeRTOS_debug_printf( ( "prvInitialiseDHCP: start after %lu ticks\n", dhcpINITIAL_TIMER_PERIOD ) ); - vIPReloadDHCPTimer( dhcpINITIAL_TIMER_PERIOD ); - } -} -/*-----------------------------------------------------------*/ - -static BaseType_t prvProcessDHCPReplies( BaseType_t xExpectedMessageType ) -{ -uint8_t *pucUDPPayload, *pucLastByte; -struct freertos_sockaddr xClient; -uint32_t xClientLength = sizeof( xClient ); -int32_t lBytes; -DHCPMessage_t *pxDHCPMessage; -uint8_t *pucByte, ucOptionCode, ucLength; -uint32_t ulProcessed, ulParameter; -BaseType_t xReturn = pdFALSE; -const uint32_t ulMandatoryOptions = 2ul; /* DHCP server address, and the correct DHCP message type must be present in the options. */ - - lBytes = FreeRTOS_recvfrom( xDHCPData.xDHCPSocket, ( void * ) &pucUDPPayload, 0ul, FREERTOS_ZERO_COPY, &xClient, &xClientLength ); - - if( lBytes > 0 ) - { - /* Map a DHCP structure onto the received data. */ - pxDHCPMessage = ( DHCPMessage_t * ) ( pucUDPPayload ); - - /* Sanity check. */ - if( ( lBytes >= sizeof( DHCPMessage_t ) ) && - ( pxDHCPMessage->ulDHCPCookie == ( uint32_t ) dhcpCOOKIE ) && - ( pxDHCPMessage->ucOpcode == ( uint8_t ) dhcpREPLY_OPCODE ) && - ( pxDHCPMessage->ulTransactionID == FreeRTOS_htonl( xDHCPData.ulTransactionId ) ) ) - { - if( memcmp( ( void * ) &( pxDHCPMessage->ucClientHardwareAddress ), - ( void * ) ipLOCAL_MAC_ADDRESS, - sizeof( MACAddress_t ) ) == 0 ) - { - /* None of the essential options have been processed yet. */ - ulProcessed = 0ul; - - /* Walk through the options until the dhcpOPTION_END_BYTE byte - is found, taking care not to walk off the end of the options. */ - pucByte = &( pxDHCPMessage->ucFirstOptionByte ); - pucLastByte = &( pucUDPPayload[ lBytes - dhcpMAX_OPTION_LENGTH_OF_INTEREST ] ); - - while( pucByte < pucLastByte ) - { - ucOptionCode = pucByte[ 0 ]; - if( ucOptionCode == dhcpOPTION_END_BYTE ) - { - /* Ready, the last byte has been seen. */ - break; - } - if( ucOptionCode == dhcpZERO_PAD_OPTION_CODE ) - { - /* The value zero is used as a pad byte, - it is not followed by a length byte. */ - pucByte += 1; - continue; - } - - /* Stop if the response is malformed. */ - if( pucByte < pucLastByte - 1 ) - { - ucLength = pucByte[ 1 ]; - pucByte += 2; - - if( pucByte >= pucLastByte - ucLength ) - { - break; - } - } - else - { - break; - } - - /* In most cases, a 4-byte network-endian parameter follows, - just get it once here and use later. */ - if( ucLength >= sizeof( ulParameter ) ) - { - memcpy( ( void * ) &( ulParameter ), - ( void * ) pucByte, - ( size_t ) sizeof( ulParameter ) ); - } - else - { - ulParameter = 0; - } - - /* Option-specific handling. */ - switch( ucOptionCode ) - { - case dhcpMESSAGE_TYPE_OPTION_CODE : - - if( *pucByte == ( uint8_t ) xExpectedMessageType ) - { - /* The message type is the message type the - state machine is expecting. */ - ulProcessed++; - } - else if( *pucByte == ( uint8_t ) dhcpMESSAGE_TYPE_NACK ) - { - if( xExpectedMessageType == ( BaseType_t ) dhcpMESSAGE_TYPE_ACK ) - { - /* Start again. */ - xDHCPData.eDHCPState = eWaitingSendFirstDiscover; - } - } - else - { - /* Don't process other message types. */ - } - break; - - case dhcpSUBNET_MASK_OPTION_CODE : - - if( ucLength == sizeof( uint32_t ) ) - { - xNetworkAddressing.ulNetMask = ulParameter; - } - break; - - case dhcpGATEWAY_OPTION_CODE : - - if( ucLength == sizeof( uint32_t ) ) - { - /* ulProcessed is not incremented in this case - because the gateway is not essential. */ - xNetworkAddressing.ulGatewayAddress = ulParameter; - } - break; - - case dhcpDNS_SERVER_OPTIONS_CODE : - - /* ulProcessed is not incremented in this case - because the DNS server is not essential. Only the - first DNS server address is taken. */ - xNetworkAddressing.ulDNSServerAddress = ulParameter; - break; - - case dhcpSERVER_IP_ADDRESS_OPTION_CODE : - - if( ucLength == sizeof( uint32_t ) ) - { - if( xExpectedMessageType == ( BaseType_t ) dhcpMESSAGE_TYPE_OFFER ) - { - /* Offers state the replying server. */ - ulProcessed++; - xDHCPData.ulDHCPServerAddress = ulParameter; - } - else - { - /* The ack must come from the expected server. */ - if( xDHCPData.ulDHCPServerAddress == ulParameter ) - { - ulProcessed++; - } - } - } - break; - - case dhcpLEASE_TIME_OPTION_CODE : - - if( ucLength == sizeof( xDHCPData.ulLeaseTime ) ) - { - /* ulProcessed is not incremented in this case - because the lease time is not essential. */ - /* The DHCP parameter is in seconds, convert - to host-endian format. */ - xDHCPData.ulLeaseTime = FreeRTOS_ntohl( ulParameter ); - - /* Divide the lease time by two to ensure a - renew request is sent before the lease actually - expires. */ - xDHCPData.ulLeaseTime >>= 1UL; - - /* Multiply with configTICK_RATE_HZ to get clock - ticks. */ - xDHCPData.ulLeaseTime = configTICK_RATE_HZ * xDHCPData.ulLeaseTime; - } - break; - - default : - - /* Not interested in this field. */ - - break; - } - - /* Jump over the data to find the next option code. */ - if( ucLength == 0u ) - { - break; - } - else - { - pucByte += ucLength; - } - } - - /* Were all the mandatory options received? */ - if( ulProcessed >= ulMandatoryOptions ) - { - /* HT:endian: used to be network order */ - xDHCPData.ulOfferedIPAddress = pxDHCPMessage->ulYourIPAddress_yiaddr; - FreeRTOS_printf( ( "vDHCPProcess: offer %lxip\n", FreeRTOS_ntohl( xDHCPData.ulOfferedIPAddress ) ) ); - xReturn = pdPASS; - } - } - } - - FreeRTOS_ReleaseUDPPayloadBuffer( ( void * ) pucUDPPayload ); - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -static uint8_t *prvCreatePartDHCPMessage( struct freertos_sockaddr *pxAddress, BaseType_t xOpcode, const uint8_t * const pucOptionsArray, size_t *pxOptionsArraySize ) -{ -DHCPMessage_t *pxDHCPMessage; -size_t xRequiredBufferSize = sizeof( DHCPMessage_t ) + *pxOptionsArraySize; -uint8_t *pucUDPPayloadBuffer; - -#if( ipconfigDHCP_REGISTER_HOSTNAME == 1 ) - const char *pucHostName = pcApplicationHostnameHook (); - size_t xNameLength = strlen( pucHostName ); - uint8_t *pucPtr; - - xRequiredBufferSize += ( 2 + xNameLength ); -#endif - - /* Get a buffer. This uses a maximum delay, but the delay will be capped - to ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS so the return value still needs to - be test. */ - do - { - } while( ( pucUDPPayloadBuffer = ( uint8_t * ) FreeRTOS_GetUDPPayloadBuffer( xRequiredBufferSize, portMAX_DELAY ) ) == NULL ); - - pxDHCPMessage = ( DHCPMessage_t * ) pucUDPPayloadBuffer; - - /* Most fields need to be zero. */ - memset( ( void * ) pxDHCPMessage, 0x00, sizeof( DHCPMessage_t ) ); - - /* Create the message. */ - pxDHCPMessage->ucOpcode = ( uint8_t ) xOpcode; - pxDHCPMessage->ucAddressType = ( uint8_t ) dhcpADDRESS_TYPE_ETHERNET; - pxDHCPMessage->ucAddressLength = ( uint8_t ) dhcpETHERNET_ADDRESS_LENGTH; - pxDHCPMessage->ulTransactionID = FreeRTOS_htonl( xDHCPData.ulTransactionId ); - pxDHCPMessage->ulDHCPCookie = ( uint32_t ) dhcpCOOKIE; - if( xDHCPData.xUseBroadcast != pdFALSE ) - { - pxDHCPMessage->usFlags = ( uint16_t ) dhcpBROADCAST; - } - else - { - pxDHCPMessage->usFlags = 0u; - } - - memcpy( ( void * ) &( pxDHCPMessage->ucClientHardwareAddress[ 0 ] ), ( void * ) ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - - /* Copy in the const part of the options options. */ - memcpy( ( void * ) &( pucUDPPayloadBuffer[ dhcpFIRST_OPTION_BYTE_OFFSET ] ), ( void * ) pucOptionsArray, *pxOptionsArraySize ); - - #if( ipconfigDHCP_REGISTER_HOSTNAME == 1 ) - { - /* With this option, the hostname can be registered as well which makes - it easier to lookup a device in a router's list of DHCP clients. */ - - /* Point to where the OPTION_END was stored to add data. */ - pucPtr = &( pucUDPPayloadBuffer[ dhcpFIRST_OPTION_BYTE_OFFSET + ( *pxOptionsArraySize - 1 ) ] ); - pucPtr[ 0 ] = dhcpDNS_HOSTNAME_OPTIONS_CODE; - pucPtr[ 1 ] = ( uint8_t ) xNameLength; - memcpy( ( void *) ( pucPtr + 2 ), pucHostName, xNameLength ); - pucPtr[ 2 + xNameLength ] = dhcpOPTION_END_BYTE; - *pxOptionsArraySize += ( 2 + xNameLength ); - } - #endif - - /* Map in the client identifier. */ - memcpy( ( void * ) &( pucUDPPayloadBuffer[ dhcpFIRST_OPTION_BYTE_OFFSET + dhcpCLIENT_IDENTIFIER_OFFSET ] ), - ( void * ) ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - - /* Set the addressing. */ - pxAddress->sin_addr = ipBROADCAST_IP_ADDRESS; - pxAddress->sin_port = ( uint16_t ) dhcpSERVER_PORT; - - return pucUDPPayloadBuffer; -} -/*-----------------------------------------------------------*/ - -static void prvSendDHCPRequest( void ) -{ -uint8_t *pucUDPPayloadBuffer; -struct freertos_sockaddr xAddress; -static const uint8_t ucDHCPRequestOptions[] = -{ - /* Do not change the ordering without also changing - dhcpCLIENT_IDENTIFIER_OFFSET, dhcpREQUESTED_IP_ADDRESS_OFFSET and - dhcpDHCP_SERVER_IP_ADDRESS_OFFSET. */ - dhcpMESSAGE_TYPE_OPTION_CODE, 1, dhcpMESSAGE_TYPE_REQUEST, /* Message type option. */ - dhcpCLIENT_IDENTIFIER_OPTION_CODE, 6, 0, 0, 0, 0, 0, 0, /* Client identifier. */ - dhcpREQUEST_IP_ADDRESS_OPTION_CODE, 4, 0, 0, 0, 0, /* The IP address being requested. */ - dhcpSERVER_IP_ADDRESS_OPTION_CODE, 4, 0, 0, 0, 0, /* The IP address of the DHCP server. */ - dhcpOPTION_END_BYTE -}; -size_t xOptionsLength = sizeof( ucDHCPRequestOptions ); - - pucUDPPayloadBuffer = prvCreatePartDHCPMessage( &xAddress, dhcpREQUEST_OPCODE, ucDHCPRequestOptions, &xOptionsLength ); - - /* Copy in the IP address being requested. */ - memcpy( ( void * ) &( pucUDPPayloadBuffer[ dhcpFIRST_OPTION_BYTE_OFFSET + dhcpREQUESTED_IP_ADDRESS_OFFSET ] ), - ( void * ) &( xDHCPData.ulOfferedIPAddress ), sizeof( xDHCPData.ulOfferedIPAddress ) ); - - /* Copy in the address of the DHCP server being used. */ - memcpy( ( void * ) &( pucUDPPayloadBuffer[ dhcpFIRST_OPTION_BYTE_OFFSET + dhcpDHCP_SERVER_IP_ADDRESS_OFFSET ] ), - ( void * ) &( xDHCPData.ulDHCPServerAddress ), sizeof( xDHCPData.ulDHCPServerAddress ) ); - - FreeRTOS_debug_printf( ( "vDHCPProcess: reply %lxip\n", FreeRTOS_ntohl( xDHCPData.ulOfferedIPAddress ) ) ); - iptraceSENDING_DHCP_REQUEST(); - - if( FreeRTOS_sendto( xDHCPData.xDHCPSocket, pucUDPPayloadBuffer, ( sizeof( DHCPMessage_t ) + xOptionsLength ), FREERTOS_ZERO_COPY, &xAddress, sizeof( xAddress ) ) == 0 ) - { - /* The packet was not successfully queued for sending and must be - returned to the stack. */ - FreeRTOS_ReleaseUDPPayloadBuffer( pucUDPPayloadBuffer ); - } -} -/*-----------------------------------------------------------*/ - -static void prvSendDHCPDiscover( void ) -{ -uint8_t *pucUDPPayloadBuffer; -struct freertos_sockaddr xAddress; -static const uint8_t ucDHCPDiscoverOptions[] = -{ - /* Do not change the ordering without also changing dhcpCLIENT_IDENTIFIER_OFFSET. */ - dhcpMESSAGE_TYPE_OPTION_CODE, 1, dhcpMESSAGE_TYPE_DISCOVER, /* Message type option. */ - dhcpCLIENT_IDENTIFIER_OPTION_CODE, 6, 0, 0, 0, 0, 0, 0, /* Client identifier. */ - dhcpPARAMETER_REQUEST_OPTION_CODE, 3, dhcpSUBNET_MASK_OPTION_CODE, dhcpGATEWAY_OPTION_CODE, dhcpDNS_SERVER_OPTIONS_CODE, /* Parameter request option. */ - dhcpOPTION_END_BYTE -}; -size_t xOptionsLength = sizeof( ucDHCPDiscoverOptions ); - - pucUDPPayloadBuffer = prvCreatePartDHCPMessage( &xAddress, dhcpREQUEST_OPCODE, ucDHCPDiscoverOptions, &xOptionsLength ); - - FreeRTOS_debug_printf( ( "vDHCPProcess: discover\n" ) ); - iptraceSENDING_DHCP_DISCOVER(); - - if( FreeRTOS_sendto( xDHCPData.xDHCPSocket, pucUDPPayloadBuffer, ( sizeof( DHCPMessage_t ) + xOptionsLength ), FREERTOS_ZERO_COPY, &xAddress, sizeof( xAddress ) ) == 0 ) - { - /* The packet was not successfully queued for sending and must be - returned to the stack. */ - FreeRTOS_ReleaseUDPPayloadBuffer( pucUDPPayloadBuffer ); - } -} -/*-----------------------------------------------------------*/ - -#if( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 ) - - static void prvPrepareLinkLayerIPLookUp( void ) - { - uint8_t ucLinkLayerIPAddress[ 2 ]; - - /* After DHCP has failed to answer, prepare everything to start - trying-out LinkLayer IP-addresses, using the random method. */ - xDHCPData.xDHCPTxTime = xTaskGetTickCount(); - - ucLinkLayerIPAddress[ 0 ] = ( uint8_t )1 + ( uint8_t )( ipconfigRAND32() % 0xFDu ); /* get value 1..254 for IP-address 3rd byte of IP address to try. */ - ucLinkLayerIPAddress[ 1 ] = ( uint8_t )1 + ( uint8_t )( ipconfigRAND32() % 0xFDu ); /* get value 1..254 for IP-address 4th byte of IP address to try. */ - - xNetworkAddressing.ulGatewayAddress = FreeRTOS_htonl( 0xA9FE0203 ); - - /* prepare xDHCPData with data to test. */ - xDHCPData.ulOfferedIPAddress = - FreeRTOS_inet_addr_quick( LINK_LAYER_ADDRESS_0, LINK_LAYER_ADDRESS_1, ucLinkLayerIPAddress[ 0 ], ucLinkLayerIPAddress[ 1 ] ); - - xDHCPData.ulLeaseTime = dhcpDEFAULT_LEASE_TIME; /* don't care about lease time. just put anything. */ - - xNetworkAddressing.ulNetMask = - FreeRTOS_inet_addr_quick( LINK_LAYER_NETMASK_0, LINK_LAYER_NETMASK_1, LINK_LAYER_NETMASK_2, LINK_LAYER_NETMASK_3 ); - - /* DHCP completed. The IP address can now be used, and the - timer set to the lease timeout time. */ - *ipLOCAL_IP_ADDRESS_POINTER = xDHCPData.ulOfferedIPAddress; - - /* Setting the 'local' broadcast address, something like 192.168.1.255' */ - xNetworkAddressing.ulBroadcastAddress = ( xDHCPData.ulOfferedIPAddress & xNetworkAddressing.ulNetMask ) | ~xNetworkAddressing.ulNetMask; - - /* Close socket to ensure packets don't queue on it. not needed anymore as DHCP failed. but still need timer for ARP testing. */ - vSocketClose( xDHCPData.xDHCPSocket ); - xDHCPData.xDHCPSocket = NULL; - xDHCPData.xDHCPTxPeriod = pdMS_TO_TICKS( 3000ul + ( ipconfigRAND32() & 0x3fful ) ); /* do ARP test every (3 + 0-1024mS) seconds. */ - - xARPHadIPClash = pdFALSE; /* reset flag that shows if have ARP clash. */ - vARPSendGratuitous(); - } - -#endif /* ipconfigDHCP_FALL_BACK_AUTO_IP */ -/*-----------------------------------------------------------*/ - -#endif /* ipconfigUSE_DHCP != 0 */ - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DNS.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DNS.c deleted file mode 100755 index bb76b40..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DNS.c +++ /dev/null @@ -1,1424 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -/* Standard includes. */ -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "list.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_DNS.h" -#include "NetworkBufferManagement.h" -#include "NetworkInterface.h" -#include "IPTraceMacroDefaults.h" - -/* Exclude the entire file if DNS is not enabled. */ -#if( ipconfigUSE_DNS != 0 ) - -#if( ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN ) - #define dnsDNS_PORT 0x3500 - #define dnsONE_QUESTION 0x0100 - #define dnsOUTGOING_FLAGS 0x0001 /* Standard query. */ - #define dnsRX_FLAGS_MASK 0x0f80 /* The bits of interest in the flags field of incoming DNS messages. */ - #define dnsEXPECTED_RX_FLAGS 0x0080 /* Should be a response, without any errors. */ -#else - #define dnsDNS_PORT 0x0035 - #define dnsONE_QUESTION 0x0001 - #define dnsOUTGOING_FLAGS 0x0100 /* Standard query. */ - #define dnsRX_FLAGS_MASK 0x800f /* The bits of interest in the flags field of incoming DNS messages. */ - #define dnsEXPECTED_RX_FLAGS 0x8000 /* Should be a response, without any errors. */ - -#endif /* ipconfigBYTE_ORDER */ - -/* The maximum number of times a DNS request should be sent out if a response -is not received, before giving up. */ -#ifndef ipconfigDNS_REQUEST_ATTEMPTS - #define ipconfigDNS_REQUEST_ATTEMPTS 5 -#endif - -/* If the top two bits in the first character of a name field are set then the -name field is an offset to the string, rather than the string itself. */ -#define dnsNAME_IS_OFFSET ( ( uint8_t ) 0xc0 ) - -/* NBNS flags. */ -#define dnsNBNS_FLAGS_RESPONSE 0x8000 -#define dnsNBNS_FLAGS_OPCODE_MASK 0x7800 -#define dnsNBNS_FLAGS_OPCODE_QUERY 0x0000 -#define dnsNBNS_FLAGS_OPCODE_REGISTRATION 0x2800 - -/* Host types. */ -#define dnsTYPE_A_HOST 0x01 -#define dnsCLASS_IN 0x01 - -/* LLMNR constants. */ -#define dnsLLMNR_TTL_VALUE 300000 -#define dnsLLMNR_FLAGS_IS_REPONSE 0x8000 - -/* NBNS constants. */ -#define dnsNBNS_TTL_VALUE 3600 /* 1 hour valid */ -#define dnsNBNS_TYPE_NET_BIOS 0x0020 -#define dnsNBNS_CLASS_IN 0x01 -#define dnsNBNS_NAME_FLAGS 0x6000 -#define dnsNBNS_ENCODED_NAME_LENGTH 32 - -/* If the queried NBNS name matches with the device's name, -the query will be responded to with these flags: */ -#define dnsNBNS_QUERY_RESPONSE_FLAGS ( 0x8500 ) - -/* Flag DNS parsing errors in situations where an IPv4 address is the return -type. */ -#define dnsPARSE_ERROR 0UL - -/* - * Create a socket and bind it to the standard DNS port number. Return the - * the created socket - or NULL if the socket could not be created or bound. - */ -static Socket_t prvCreateDNSSocket( void ); - -/* - * Create the DNS message in the zero copy buffer passed in the first parameter. - */ -static size_t prvCreateDNSMessage( uint8_t *pucUDPPayloadBuffer, const char *pcHostName, TickType_t xIdentifier ); - -/* - * Simple routine that jumps over the NAME field of a resource record. - */ -static uint8_t *prvSkipNameField( uint8_t *pucByte, size_t xSourceLen ); - -/* - * Process a response packet from a DNS server. - */ -static uint32_t prvParseDNSReply( uint8_t *pucUDPPayloadBuffer, size_t xBufferLength, TickType_t xIdentifier ); - -/* - * Prepare and send a message to a DNS server. 'xReadTimeOut_ms' will be passed as - * zero, in case the user has supplied a call-back function. - */ -static uint32_t prvGetHostByName( const char *pcHostName, TickType_t xIdentifier, TickType_t xReadTimeOut_ms ); - -/* - * The NBNS and the LLMNR protocol share this reply function. - */ -#if( ( ipconfigUSE_NBNS == 1 ) || ( ipconfigUSE_LLMNR == 1 ) ) - static void prvReplyDNSMessage( NetworkBufferDescriptor_t *pxNetworkBuffer, BaseType_t lNetLength ); -#endif - -#if( ipconfigUSE_NBNS == 1 ) - static portINLINE void prvTreatNBNS( uint8_t *pucUDPPayloadBuffer, size_t xBufferLength, uint32_t ulIPAddress ); -#endif /* ipconfigUSE_NBNS */ - -#if( ipconfigUSE_DNS_CACHE == 1 ) - static uint8_t *prvReadNameField( uint8_t *pucByte, size_t xSourceLen, char *pcName, size_t xLen ); - static void prvProcessDNSCache( const char *pcName, uint32_t *pulIP, uint32_t ulTTL, BaseType_t xLookUp ); - - typedef struct xDNS_CACHE_TABLE_ROW - { - uint32_t ulIPAddress; /* The IP address of an ARP cache entry. */ - char pcName[ ipconfigDNS_CACHE_NAME_LENGTH ]; /* The name of the host */ - uint32_t ulTTL; /* Time-to-Live (in seconds) from the DNS server. */ - uint32_t ulTimeWhenAddedInSeconds; - } DNSCacheRow_t; - - static DNSCacheRow_t xDNSCache[ ipconfigDNS_CACHE_ENTRIES ]; -#endif /* ipconfigUSE_DNS_CACHE == 1 */ - -#if( ipconfigUSE_LLMNR == 1 ) - const MACAddress_t xLLMNR_MacAdress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; -#endif /* ipconfigUSE_LLMNR == 1 */ - -/*-----------------------------------------------------------*/ - -#include "pack_struct_start.h" -struct xDNSMessage -{ - uint16_t usIdentifier; - uint16_t usFlags; - uint16_t usQuestions; - uint16_t usAnswers; - uint16_t usAuthorityRRs; - uint16_t usAdditionalRRs; -} -#include "pack_struct_end.h" -typedef struct xDNSMessage DNSMessage_t; - -/* A DNS query consists of a header, as described in 'struct xDNSMessage' -It is followed by 1 or more queries, each one consisting of a name and a tail, -with two fields: type and class -*/ -#include "pack_struct_start.h" -struct xDNSTail -{ - uint16_t usType; - uint16_t usClass; -} -#include "pack_struct_end.h" -typedef struct xDNSTail DNSTail_t; - -/* DNS answer record header. */ -#include "pack_struct_start.h" -struct xDNSAnswerRecord -{ - uint16_t usType; - uint16_t usClass; - uint32_t ulTTL; - uint16_t usDataLength; -} -#include "pack_struct_end.h" -typedef struct xDNSAnswerRecord DNSAnswerRecord_t; - -#if( ipconfigUSE_LLMNR == 1 ) - - #include "pack_struct_start.h" - struct xLLMNRAnswer - { - uint8_t ucNameCode; - uint8_t ucNameOffset; /* The name is not repeated in the answer, only the offset is given with "0xc0 " */ - uint16_t usType; - uint16_t usClass; - uint32_t ulTTL; - uint16_t usDataLength; - uint32_t ulIPAddress; - } - #include "pack_struct_end.h" - typedef struct xLLMNRAnswer LLMNRAnswer_t; - -#endif /* ipconfigUSE_LLMNR == 1 */ - -#if( ipconfigUSE_NBNS == 1 ) - - #include "pack_struct_start.h" - struct xNBNSRequest - { - uint16_t usRequestId; - uint16_t usFlags; - uint16_t ulRequestCount; - uint16_t usAnswerRSS; - uint16_t usAuthRSS; - uint16_t usAdditionalRSS; - uint8_t ucNameSpace; - uint8_t ucName[ dnsNBNS_ENCODED_NAME_LENGTH ]; - uint8_t ucNameZero; - uint16_t usType; - uint16_t usClass; - } - #include "pack_struct_end.h" - typedef struct xNBNSRequest NBNSRequest_t; - - #include "pack_struct_start.h" - struct xNBNSAnswer - { - uint16_t usType; - uint16_t usClass; - uint32_t ulTTL; - uint16_t usDataLength; - uint16_t usNbFlags; /* NetBIOS flags 0x6000 : IP-address, big-endian */ - uint32_t ulIPAddress; - } - #include "pack_struct_end.h" - typedef struct xNBNSAnswer NBNSAnswer_t; - -#endif /* ipconfigUSE_NBNS == 1 */ - -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_DNS_CACHE == 1 ) - uint32_t FreeRTOS_dnslookup( const char *pcHostName ) - { - uint32_t ulIPAddress = 0UL; - prvProcessDNSCache( pcHostName, &ulIPAddress, 0, pdTRUE ); - return ulIPAddress; - } -#endif /* ipconfigUSE_DNS_CACHE == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigDNS_USE_CALLBACKS != 0 ) - - typedef struct xDNS_Callback { - TickType_t xRemaningTime; /* Timeout in ms */ - FOnDNSEvent pCallbackFunction; /* Function to be called when the address has been found or when a timeout has beeen reached */ - TimeOut_t xTimeoutState; - void *pvSearchID; - struct xLIST_ITEM xListItem; - char pcName[ 1 ]; - } DNSCallback_t; - - static List_t xCallbackList; - - /* Define FreeRTOS_gethostbyname() as a normal blocking call. */ - uint32_t FreeRTOS_gethostbyname( const char *pcHostName ) - { - return FreeRTOS_gethostbyname_a( pcHostName, ( FOnDNSEvent ) NULL, ( void* )NULL, 0 ); - } - /*-----------------------------------------------------------*/ - - /* Initialise the list of call-back structures. */ - void vDNSInitialise( void ); - void vDNSInitialise( void ) - { - vListInitialise( &xCallbackList ); - } - /*-----------------------------------------------------------*/ - - /* Iterate through the list of call-back structures and remove - old entries which have reached a timeout. - As soon as the list hase become empty, the DNS timer will be stopped - In case pvSearchID is supplied, the user wants to cancel a DNS request - */ - void vDNSCheckCallBack( void *pvSearchID ); - void vDNSCheckCallBack( void *pvSearchID ) - { - const ListItem_t *pxIterator; - const MiniListItem_t* xEnd = ( const MiniListItem_t* )listGET_END_MARKER( &xCallbackList ); - - vTaskSuspendAll(); - { - for( pxIterator = ( const ListItem_t * ) listGET_NEXT( xEnd ); - pxIterator != ( const ListItem_t * ) xEnd; - ) - { - DNSCallback_t *pxCallback = ( DNSCallback_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); - /* Move to the next item because we might remove this item */ - pxIterator = ( const ListItem_t * ) listGET_NEXT( pxIterator ); - if( ( pvSearchID != NULL ) && ( pvSearchID == pxCallback->pvSearchID ) ) - { - uxListRemove( &pxCallback->xListItem ); - vPortFree( pxCallback ); - } - else if( xTaskCheckForTimeOut( &pxCallback->xTimeoutState, &pxCallback->xRemaningTime ) != pdFALSE ) - { - pxCallback->pCallbackFunction( pxCallback->pcName, pxCallback->pvSearchID, 0 ); - uxListRemove( &pxCallback->xListItem ); - vPortFree( ( void * ) pxCallback ); - } - } - } - xTaskResumeAll(); - - if( listLIST_IS_EMPTY( &xCallbackList ) ) - { - vIPSetDnsTimerEnableState( pdFALSE ); - } - } - /*-----------------------------------------------------------*/ - - void FreeRTOS_gethostbyname_cancel( void *pvSearchID ) - { - /* _HT_ Should better become a new API call to have the IP-task remove the callback */ - vDNSCheckCallBack( pvSearchID ); - } - /*-----------------------------------------------------------*/ - - /* FreeRTOS_gethostbyname_a() was called along with callback parameters. - Store them in a list for later reference. */ - static void vDNSSetCallBack( const char *pcHostName, void *pvSearchID, FOnDNSEvent pCallbackFunction, TickType_t xTimeout, TickType_t xIdentifier ); - static void vDNSSetCallBack( const char *pcHostName, void *pvSearchID, FOnDNSEvent pCallbackFunction, TickType_t xTimeout, TickType_t xIdentifier ) - { - size_t lLength = strlen( pcHostName ); - DNSCallback_t *pxCallback = ( DNSCallback_t * )pvPortMalloc( sizeof( *pxCallback ) + lLength ); - - /* Translate from ms to number of clock ticks. */ - xTimeout /= portTICK_PERIOD_MS; - if( pxCallback != NULL ) - { - if( listLIST_IS_EMPTY( &xCallbackList ) ) - { - /* This is the first one, start the DNS timer to check for timeouts */ - vIPReloadDNSTimer( FreeRTOS_min_uint32( 1000U, xTimeout ) ); - } - strcpy( pxCallback->pcName, pcHostName ); - pxCallback->pCallbackFunction = pCallbackFunction; - pxCallback->pvSearchID = pvSearchID; - pxCallback->xRemaningTime = xTimeout; - vTaskSetTimeOutState( &pxCallback->xTimeoutState ); - listSET_LIST_ITEM_OWNER( &( pxCallback->xListItem ), ( void* ) pxCallback ); - listSET_LIST_ITEM_VALUE( &( pxCallback->xListItem ), xIdentifier ); - vTaskSuspendAll(); - { - vListInsertEnd( &xCallbackList, &pxCallback->xListItem ); - } - xTaskResumeAll(); - } - } - /*-----------------------------------------------------------*/ - - /* A DNS reply was received, see if there is any matching entry and - call the handler. */ - static void vDNSDoCallback( TickType_t xIdentifier, const char *pcName, uint32_t ulIPAddress ); - static void vDNSDoCallback( TickType_t xIdentifier, const char *pcName, uint32_t ulIPAddress ) - { - const ListItem_t *pxIterator; - const MiniListItem_t* xEnd = ( const MiniListItem_t* )listGET_END_MARKER( &xCallbackList ); - - vTaskSuspendAll(); - { - for( pxIterator = ( const ListItem_t * ) listGET_NEXT( xEnd ); - pxIterator != ( const ListItem_t * ) xEnd; - pxIterator = ( const ListItem_t * ) listGET_NEXT( pxIterator ) ) - { - if( listGET_LIST_ITEM_VALUE( pxIterator ) == xIdentifier ) - { - DNSCallback_t *pxCallback = ( DNSCallback_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); - pxCallback->pCallbackFunction( pcName, pxCallback->pvSearchID, ulIPAddress ); - uxListRemove( &pxCallback->xListItem ); - vPortFree( pxCallback ); - if( listLIST_IS_EMPTY( &xCallbackList ) ) - { - vIPSetDnsTimerEnableState( pdFALSE ); - } - break; - } - } - } - xTaskResumeAll(); - } - -#endif /* ipconfigDNS_USE_CALLBACKS != 0 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigDNS_USE_CALLBACKS == 0 ) -uint32_t FreeRTOS_gethostbyname( const char *pcHostName ) -#else -uint32_t FreeRTOS_gethostbyname_a( const char *pcHostName, FOnDNSEvent pCallback, void *pvSearchID, TickType_t xTimeout ) -#endif -{ -uint32_t ulIPAddress = 0UL; -TickType_t xReadTimeOut_ms = ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME; -TickType_t xIdentifier = 0; - - /* If the supplied hostname is IP address, convert it to uint32_t - and return. */ - #if( ipconfigINCLUDE_FULL_INET_ADDR == 1 ) - { - ulIPAddress = FreeRTOS_inet_addr( pcHostName ); - } - #endif /* ipconfigINCLUDE_FULL_INET_ADDR == 1 */ - - /* If a DNS cache is used then check the cache before issuing another DNS - request. */ - #if( ipconfigUSE_DNS_CACHE == 1 ) - { - if( ulIPAddress == 0UL ) - { - ulIPAddress = FreeRTOS_dnslookup( pcHostName ); - if( ulIPAddress != 0 ) - { - FreeRTOS_debug_printf( ( "FreeRTOS_gethostbyname: found '%s' in cache: %lxip\n", pcHostName, ulIPAddress ) ); - } - else - { - /* prvGetHostByName will be called to start a DNS lookup */ - } - } - } - #endif /* ipconfigUSE_DNS_CACHE == 1 */ - - /* Generate a unique identifier. */ - if( 0 == ulIPAddress ) - { - xIdentifier = ( TickType_t )ipconfigRAND32( ); - } - - #if( ipconfigDNS_USE_CALLBACKS != 0 ) - { - if( pCallback != NULL ) - { - if( ulIPAddress == 0UL ) - { - /* The user has provided a callback function, so do not block on recvfrom() */ - if( 0 != xIdentifier ) - { - xReadTimeOut_ms = 0; - vDNSSetCallBack( pcHostName, pvSearchID, pCallback, xTimeout, ( TickType_t )xIdentifier ); - } - } - else - { - /* The IP address is known, do the call-back now. */ - pCallback( pcHostName, pvSearchID, ulIPAddress ); - } - } - } - #endif - - if( ( ulIPAddress == 0UL ) && ( 0 != xIdentifier ) ) - { - ulIPAddress = prvGetHostByName( pcHostName, xIdentifier, xReadTimeOut_ms ); - } - - return ulIPAddress; -} -/*-----------------------------------------------------------*/ - -static uint32_t prvGetHostByName( const char *pcHostName, TickType_t xIdentifier, TickType_t xReadTimeOut_ms ) -{ -struct freertos_sockaddr xAddress; -Socket_t xDNSSocket; -uint32_t ulIPAddress = 0UL; -uint8_t *pucUDPPayloadBuffer; -uint32_t ulAddressLength = sizeof( struct freertos_sockaddr ); -BaseType_t xAttempt; -int32_t lBytes; -size_t xPayloadLength, xExpectedPayloadLength; -TickType_t xWriteTimeOut_ms = ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME; - -#if( ipconfigUSE_LLMNR == 1 ) - BaseType_t bHasDot = pdFALSE; -#endif /* ipconfigUSE_LLMNR == 1 */ - - /* If LLMNR is being used then determine if the host name includes a '.' - - if not then LLMNR can be used as the lookup method. */ - #if( ipconfigUSE_LLMNR == 1 ) - { - const char *pucPtr; - for( pucPtr = pcHostName; *pucPtr; pucPtr++ ) - { - if( *pucPtr == '.' ) - { - bHasDot = pdTRUE; - break; - } - } - } - #endif /* ipconfigUSE_LLMNR == 1 */ - - /* Two is added at the end for the count of characters in the first - subdomain part and the string end byte. */ - xExpectedPayloadLength = sizeof( DNSMessage_t ) + strlen( pcHostName ) + sizeof( uint16_t ) + sizeof( uint16_t ) + 2u; - - xDNSSocket = prvCreateDNSSocket(); - - if( xDNSSocket != NULL ) - { - FreeRTOS_setsockopt( xDNSSocket, 0, FREERTOS_SO_SNDTIMEO, ( void * ) &xWriteTimeOut_ms, sizeof( TickType_t ) ); - FreeRTOS_setsockopt( xDNSSocket, 0, FREERTOS_SO_RCVTIMEO, ( void * ) &xReadTimeOut_ms, sizeof( TickType_t ) ); - - for( xAttempt = 0; xAttempt < ipconfigDNS_REQUEST_ATTEMPTS; xAttempt++ ) - { - /* Get a buffer. This uses a maximum delay, but the delay will be - capped to ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS so the return value - still needs to be tested. */ - pucUDPPayloadBuffer = ( uint8_t * ) FreeRTOS_GetUDPPayloadBuffer( xExpectedPayloadLength, portMAX_DELAY ); - - if( pucUDPPayloadBuffer != NULL ) - { - /* Create the message in the obtained buffer. */ - xPayloadLength = prvCreateDNSMessage( pucUDPPayloadBuffer, pcHostName, xIdentifier ); - - iptraceSENDING_DNS_REQUEST(); - - /* Obtain the DNS server address. */ - FreeRTOS_GetAddressConfiguration( NULL, NULL, NULL, &ulIPAddress ); - - /* Send the DNS message. */ -#if( ipconfigUSE_LLMNR == 1 ) - if( bHasDot == pdFALSE ) - { - /* Use LLMNR addressing. */ - ( ( DNSMessage_t * ) pucUDPPayloadBuffer) -> usFlags = 0; - xAddress.sin_addr = ipLLMNR_IP_ADDR; /* Is in network byte order. */ - xAddress.sin_port = FreeRTOS_ntohs( ipLLMNR_PORT ); - } - else -#endif - { - /* Use DNS server. */ - xAddress.sin_addr = ulIPAddress; - xAddress.sin_port = dnsDNS_PORT; - } - - ulIPAddress = 0UL; - - if( FreeRTOS_sendto( xDNSSocket, pucUDPPayloadBuffer, xPayloadLength, FREERTOS_ZERO_COPY, &xAddress, sizeof( xAddress ) ) != 0 ) - { - /* Wait for the reply. */ - lBytes = FreeRTOS_recvfrom( xDNSSocket, &pucUDPPayloadBuffer, 0, FREERTOS_ZERO_COPY, &xAddress, &ulAddressLength ); - - if( lBytes > 0 ) - { - /* The reply was received. Process it. */ - ulIPAddress = prvParseDNSReply( pucUDPPayloadBuffer, lBytes, xIdentifier ); - - /* Finished with the buffer. The zero copy interface - is being used, so the buffer must be freed by the - task. */ - FreeRTOS_ReleaseUDPPayloadBuffer( ( void * ) pucUDPPayloadBuffer ); - - if( ulIPAddress != 0UL ) - { - /* All done. */ - break; - } - } - } - else - { - /* The message was not sent so the stack will not be - releasing the zero copy - it must be released here. */ - FreeRTOS_ReleaseUDPPayloadBuffer( ( void * ) pucUDPPayloadBuffer ); - } - } - } - - /* Finished with the socket. */ - FreeRTOS_closesocket( xDNSSocket ); - } - - return ulIPAddress; -} -/*-----------------------------------------------------------*/ - -static size_t prvCreateDNSMessage( uint8_t *pucUDPPayloadBuffer, const char *pcHostName, TickType_t xIdentifier ) -{ -DNSMessage_t *pxDNSMessageHeader; -uint8_t *pucStart, *pucByte; -DNSTail_t *pxTail; -static const DNSMessage_t xDefaultPartDNSHeader = -{ - 0, /* The identifier will be overwritten. */ - dnsOUTGOING_FLAGS, /* Flags set for standard query. */ - dnsONE_QUESTION, /* One question is being asked. */ - 0, /* No replies are included. */ - 0, /* No authorities. */ - 0 /* No additional authorities. */ -}; - - /* Copy in the const part of the header. */ - memcpy( ( void * ) pucUDPPayloadBuffer, ( void * ) &xDefaultPartDNSHeader, sizeof( xDefaultPartDNSHeader ) ); - - /* Write in a unique identifier. */ - pxDNSMessageHeader = ( DNSMessage_t * ) pucUDPPayloadBuffer; - pxDNSMessageHeader->usIdentifier = ( uint16_t ) xIdentifier; - - /* Create the resource record at the end of the header. First - find the end of the header. */ - pucStart = pucUDPPayloadBuffer + sizeof( xDefaultPartDNSHeader ); - - /* Leave a gap for the first length bytes. */ - pucByte = pucStart + 1; - - /* Copy in the host name. */ - strcpy( ( char * ) pucByte, pcHostName ); - - /* Mark the end of the string. */ - pucByte += strlen( pcHostName ); - *pucByte = 0x00u; - - /* Walk the string to replace the '.' characters with byte counts. - pucStart holds the address of the byte count. Walking the string - starts after the byte count position. */ - pucByte = pucStart; - - do - { - pucByte++; - - while( ( *pucByte != 0x00 ) && ( *pucByte != '.' ) ) - { - pucByte++; - } - - /* Fill in the byte count, then move the pucStart pointer up to - the found byte position. */ - *pucStart = ( uint8_t ) ( ( uint32_t ) pucByte - ( uint32_t ) pucStart ); - ( *pucStart )--; - - pucStart = pucByte; - - } while( *pucByte != 0x00 ); - - /* Finish off the record. */ - - pxTail = (DNSTail_t *)( pucByte + 1 ); - - vSetField16( pxTail, DNSTail_t, usType, dnsTYPE_A_HOST ); /* Type A: host */ - vSetField16( pxTail, DNSTail_t, usClass, dnsCLASS_IN ); /* 1: Class IN */ - - /* Return the total size of the generated message, which is the space from - the last written byte to the beginning of the buffer. */ - return ( ( uint32_t ) pucByte - ( uint32_t ) pucUDPPayloadBuffer + 1 ) + sizeof( *pxTail ); -} -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_DNS_CACHE == 1 ) - - static uint8_t *prvReadNameField( uint8_t *pucByte, size_t xSourceLen, char *pcName, size_t xDestLen ) - { - size_t xNameLen = 0; - BaseType_t xCount; - - if( 0 == xSourceLen ) - { - return NULL; - } - - /* Determine if the name is the fully coded name, or an offset to the name - elsewhere in the message. */ - if( ( *pucByte & dnsNAME_IS_OFFSET ) == dnsNAME_IS_OFFSET ) - { - /* Jump over the two byte offset. */ - if( xSourceLen > sizeof( uint16_t ) ) - { - pucByte += sizeof( uint16_t ); - } - else - { - pucByte = NULL; - } - } - else - { - /* pucByte points to the full name. Walk over the string. */ - while( ( NULL != pucByte ) && ( *pucByte != 0x00 ) && ( xSourceLen > 1 ) ) - { - /* If this is not the first time through the loop, then add a - separator in the output. */ - if( ( xNameLen > 0 ) && ( xNameLen < ( xDestLen - 1 ) ) ) - { - pcName[ xNameLen++ ] = '.'; - } - - /* Process the first/next sub-string. */ - for( xCount = *(pucByte++), xSourceLen--; - xCount-- && xSourceLen > 1; - pucByte++, xSourceLen-- ) - { - if( xNameLen < xDestLen - 1 ) - { - pcName[ xNameLen++ ] = *( ( char * )pucByte ); - } - else - { - /* DNS name is too big for the provided buffer. */ - pucByte = NULL; - break; - } - } - } - - /* Confirm that a fully formed name was found. */ - if( NULL != pucByte ) - { - if( 0x00 == *pucByte ) - { - pucByte++; - xSourceLen--; - pcName[ xNameLen++ ] = '\0'; - } - else - { - pucByte = NULL; - } - } - } - - return pucByte; - } -#endif /* ipconfigUSE_DNS_CACHE == 1 */ -/*-----------------------------------------------------------*/ - -static uint8_t *prvSkipNameField( uint8_t *pucByte, size_t xSourceLen ) -{ - size_t xChunkLength; - - if( 0 == xSourceLen ) - { - return NULL; - } - - /* Determine if the name is the fully coded name, or an offset to the name - elsewhere in the message. */ - if( ( *pucByte & dnsNAME_IS_OFFSET ) == dnsNAME_IS_OFFSET ) - { - /* Jump over the two byte offset. */ - if( xSourceLen > sizeof( uint16_t ) ) - { - pucByte += sizeof( uint16_t ); - } - else - { - pucByte = NULL; - } - } - else - { - /* pucByte points to the full name. Walk over the string. */ - while( ( *pucByte != 0x00 ) && ( xSourceLen > 1 ) ) - { - xChunkLength = *pucByte + 1; - - if( xSourceLen > xChunkLength ) - { - xSourceLen -= xChunkLength; - pucByte += xChunkLength; - } - else - { - pucByte = NULL; - break; - } - } - - /* Confirm that a fully formed name was found. */ - if( NULL != pucByte ) - { - if( 0x00 == *pucByte ) - { - pucByte++; - } - else - { - pucByte = NULL; - } - } - } - - return pucByte; -} -/*-----------------------------------------------------------*/ - -uint32_t ulDNSHandlePacket( NetworkBufferDescriptor_t *pxNetworkBuffer ) -{ -uint8_t *pucUDPPayloadBuffer; -size_t xPlayloadBufferLength; -DNSMessage_t *pxDNSMessageHeader; - - xPlayloadBufferLength = pxNetworkBuffer->xDataLength - sizeof( UDPPacket_t ); - if ( xPlayloadBufferLength < sizeof( DNSMessage_t ) ) - { - return pdFAIL; - } - - pucUDPPayloadBuffer = pxNetworkBuffer->pucEthernetBuffer + sizeof( UDPPacket_t ); - pxDNSMessageHeader = ( DNSMessage_t * ) pucUDPPayloadBuffer; - - if( pxNetworkBuffer->xDataLength > sizeof( UDPPacket_t ) ) - { - prvParseDNSReply( pucUDPPayloadBuffer, - xPlayloadBufferLength, - ( uint32_t )pxDNSMessageHeader->usIdentifier ); - } - - /* The packet was not consumed. */ - return pdFAIL; -} -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_NBNS == 1 ) - - uint32_t ulNBNSHandlePacket (NetworkBufferDescriptor_t *pxNetworkBuffer ) - { - UDPPacket_t *pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - uint8_t *pucUDPPayloadBuffer = pxNetworkBuffer->pucEthernetBuffer + sizeof( UDPPacket_t ); - - if( pxNetworkBuffer->xDataLength > sizeof( UDPPacket_t) ) - { - prvTreatNBNS( pucUDPPayloadBuffer, - pxNetworkBuffer->xDataLength - sizeof( UDPPacket_t ), - pxUDPPacket->xIPHeader.ulSourceIPAddress ); - } - - /* The packet was not consumed. */ - return pdFAIL; - } - -#endif /* ipconfigUSE_NBNS */ -/*-----------------------------------------------------------*/ - -static uint32_t prvParseDNSReply( uint8_t *pucUDPPayloadBuffer, size_t xBufferLength, TickType_t xIdentifier ) -{ -DNSMessage_t *pxDNSMessageHeader; -DNSAnswerRecord_t *pxDNSAnswerRecord; -uint32_t ulIPAddress = 0UL; -#if( ipconfigUSE_LLMNR == 1 ) - char *pcRequestedName = NULL; -#endif -uint8_t *pucByte; -size_t xSourceBytesRemaining; -uint16_t x, usDataLength, usQuestions; -#if( ipconfigUSE_LLMNR == 1 ) - uint16_t usType = 0, usClass = 0; -#endif -#if( ipconfigUSE_DNS_CACHE == 1 ) - char pcName[ ipconfigDNS_CACHE_NAME_LENGTH ] = ""; -#endif - - /* Ensure that the buffer is of at least minimal DNS message length. */ - if( xBufferLength < sizeof( DNSMessage_t ) ) - { - return dnsPARSE_ERROR; - } - else - { - xSourceBytesRemaining = xBufferLength; - } - - /* Parse the DNS message header. */ - pxDNSMessageHeader = ( DNSMessage_t * ) pucUDPPayloadBuffer; - - if( pxDNSMessageHeader->usIdentifier == ( uint16_t ) xIdentifier ) - { - /* Start at the first byte after the header. */ - pucByte = pucUDPPayloadBuffer + sizeof( DNSMessage_t ); - xSourceBytesRemaining -= sizeof( DNSMessage_t ); - - /* Skip any question records. */ - usQuestions = FreeRTOS_ntohs( pxDNSMessageHeader->usQuestions ); - for( x = 0; x < usQuestions; x++ ) - { - #if( ipconfigUSE_LLMNR == 1 ) - { - if( x == 0 ) - { - pcRequestedName = ( char * ) pucByte; - } - } - #endif - -#if( ipconfigUSE_DNS_CACHE == 1 ) - if( x == 0 ) - { - pucByte = prvReadNameField( pucByte, - xSourceBytesRemaining, - pcName, - sizeof( pcName ) ); - - /* Check for a malformed response. */ - if( NULL == pucByte ) - { - return dnsPARSE_ERROR; - } - else - { - xSourceBytesRemaining = ( pucUDPPayloadBuffer + xBufferLength ) - pucByte; - } - } - else -#endif /* ipconfigUSE_DNS_CACHE */ - { - /* Skip the variable length pcName field. */ - pucByte = prvSkipNameField( pucByte, - xSourceBytesRemaining ); - - /* Check for a malformed response. */ - if( NULL == pucByte ) - { - return dnsPARSE_ERROR; - } - else - { - xSourceBytesRemaining = pucUDPPayloadBuffer + xBufferLength - pucByte; - } - } - - /* Check the remaining buffer size. */ - if( xSourceBytesRemaining >= sizeof( uint32_t ) ) - { - #if( ipconfigUSE_LLMNR == 1 ) - { - /* usChar2u16 returns value in host endianness */ - usType = usChar2u16( pucByte ); - usClass = usChar2u16( pucByte + 2 ); - } - #endif /* ipconfigUSE_LLMNR */ - - /* Skip the type and class fields. */ - pucByte += sizeof( uint32_t ); - xSourceBytesRemaining -= sizeof( uint32_t ); - } - else - { - /* Malformed response. */ - return dnsPARSE_ERROR; - } - } - - /* Search through the answer records. */ - pxDNSMessageHeader->usAnswers = FreeRTOS_ntohs( pxDNSMessageHeader->usAnswers ); - - if( ( pxDNSMessageHeader->usFlags & dnsRX_FLAGS_MASK ) == dnsEXPECTED_RX_FLAGS ) - { - for( x = 0; x < pxDNSMessageHeader->usAnswers; x++ ) - { - pucByte = prvSkipNameField( pucByte, - xSourceBytesRemaining ); - - /* Check for a malformed response. */ - if( NULL == pucByte ) - { - return dnsPARSE_ERROR; - } - else - { - xSourceBytesRemaining = pucUDPPayloadBuffer + xBufferLength - pucByte; - } - - /* Is there enough data for an IPv4 A record answer and, if so, - is this an A record? */ - if( xSourceBytesRemaining >= sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t ) && - usChar2u16( pucByte ) == dnsTYPE_A_HOST ) - { - /* This is the required record type and is of sufficient size. */ - pxDNSAnswerRecord = ( DNSAnswerRecord_t * )pucByte; - - /* Sanity check the data length of an IPv4 answer. */ - if( FreeRTOS_ntohs( pxDNSAnswerRecord->usDataLength ) == sizeof( uint32_t ) ) - { - /* Copy the IP address out of the record. */ - memcpy( &ulIPAddress, - pucByte + sizeof( DNSAnswerRecord_t ), - sizeof( uint32_t ) ); - - #if( ipconfigUSE_DNS_CACHE == 1 ) - { - prvProcessDNSCache( pcName, &ulIPAddress, pxDNSAnswerRecord->ulTTL, pdFALSE ); - } - #endif /* ipconfigUSE_DNS_CACHE */ - #if( ipconfigDNS_USE_CALLBACKS != 0 ) - { - /* See if any asynchronous call was made to FreeRTOS_gethostbyname_a() */ - vDNSDoCallback( ( TickType_t ) pxDNSMessageHeader->usIdentifier, pcName, ulIPAddress ); - } - #endif /* ipconfigDNS_USE_CALLBACKS != 0 */ - } - - pucByte += sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t ); - xSourceBytesRemaining -= ( sizeof( DNSAnswerRecord_t ) + sizeof( uint32_t ) ); - break; - } - else if( xSourceBytesRemaining >= sizeof( DNSAnswerRecord_t ) ) - { - /* It's not an A record, so skip it. Get the header location - and then jump over the header. */ - pxDNSAnswerRecord = ( DNSAnswerRecord_t * )pucByte; - pucByte += sizeof( DNSAnswerRecord_t ); - xSourceBytesRemaining -= sizeof( DNSAnswerRecord_t ); - - /* Determine the length of the answer data from the header. */ - usDataLength = FreeRTOS_ntohs( pxDNSAnswerRecord->usDataLength ); - - /* Jump over the answer. */ - if( xSourceBytesRemaining >= usDataLength ) - { - pucByte += usDataLength; - xSourceBytesRemaining -= usDataLength; - } - else - { - /* Malformed response. */ - return dnsPARSE_ERROR; - } - } - } - } -#if( ipconfigUSE_LLMNR == 1 ) - else if( usQuestions && ( usType == dnsTYPE_A_HOST ) && ( usClass == dnsCLASS_IN ) ) - { - /* If this is not a reply to our DNS request, it might an LLMNR - request. */ - if( xApplicationDNSQueryHook ( ( pcRequestedName + 1 ) ) ) - { - int16_t usLength; - NetworkBufferDescriptor_t *pxNewBuffer = NULL; - NetworkBufferDescriptor_t *pxNetworkBuffer = pxUDPPayloadBuffer_to_NetworkBuffer( pucUDPPayloadBuffer ); - LLMNRAnswer_t *pxAnswer; - - if( ( xBufferAllocFixedSize == pdFALSE ) && ( pxNetworkBuffer != NULL ) ) - { - BaseType_t xDataLength = xBufferLength + sizeof( UDPHeader_t ) + sizeof( EthernetHeader_t ) + sizeof( IPHeader_t ); - - /* The field xDataLength was set to the length of the UDP payload. - The answer (reply) will be longer than the request, so the packet - must be duplicaed into a bigger buffer */ - pxNetworkBuffer->xDataLength = xDataLength; - pxNewBuffer = pxDuplicateNetworkBufferWithDescriptor( pxNetworkBuffer, xDataLength + 16 ); - if( pxNewBuffer != NULL ) - { - BaseType_t xOffset1, xOffset2; - - xOffset1 = ( BaseType_t ) ( pucByte - pucUDPPayloadBuffer ); - xOffset2 = ( BaseType_t ) ( ( ( uint8_t * ) pcRequestedName ) - pucUDPPayloadBuffer ); - - pxNetworkBuffer = pxNewBuffer; - pucUDPPayloadBuffer = pxNetworkBuffer->pucEthernetBuffer + ipUDP_PAYLOAD_OFFSET_IPv4; - - pucByte = pucUDPPayloadBuffer + xOffset1; - pcRequestedName = ( char * ) ( pucUDPPayloadBuffer + xOffset2 ); - pxDNSMessageHeader = ( DNSMessage_t * ) pucUDPPayloadBuffer; - - } - else - { - /* Just to indicate that the message may not be answered. */ - pxNetworkBuffer = NULL; - } - } - if( pxNetworkBuffer != NULL ) - { - pxAnswer = (LLMNRAnswer_t *)pucByte; - - /* We leave 'usIdentifier' and 'usQuestions' untouched */ - vSetField16( pxDNSMessageHeader, DNSMessage_t, usFlags, dnsLLMNR_FLAGS_IS_REPONSE ); /* Set the response flag */ - vSetField16( pxDNSMessageHeader, DNSMessage_t, usAnswers, 1 ); /* Provide a single answer */ - vSetField16( pxDNSMessageHeader, DNSMessage_t, usAuthorityRRs, 0 ); /* No authority */ - vSetField16( pxDNSMessageHeader, DNSMessage_t, usAdditionalRRs, 0 ); /* No additional info */ - - pxAnswer->ucNameCode = dnsNAME_IS_OFFSET; - pxAnswer->ucNameOffset = ( uint8_t )( pcRequestedName - ( char * ) pucUDPPayloadBuffer ); - - vSetField16( pxAnswer, LLMNRAnswer_t, usType, dnsTYPE_A_HOST ); /* Type A: host */ - vSetField16( pxAnswer, LLMNRAnswer_t, usClass, dnsCLASS_IN ); /* 1: Class IN */ - vSetField32( pxAnswer, LLMNRAnswer_t, ulTTL, dnsLLMNR_TTL_VALUE ); - vSetField16( pxAnswer, LLMNRAnswer_t, usDataLength, 4 ); - vSetField32( pxAnswer, LLMNRAnswer_t, ulIPAddress, FreeRTOS_ntohl( *ipLOCAL_IP_ADDRESS_POINTER ) ); - - usLength = ( int16_t ) ( sizeof( *pxAnswer ) + ( size_t ) ( pucByte - pucUDPPayloadBuffer ) ); - - prvReplyDNSMessage( pxNetworkBuffer, usLength ); - - if( pxNewBuffer != NULL ) - { - vReleaseNetworkBufferAndDescriptor( pxNewBuffer ); - } - } - } - } -#endif /* ipconfigUSE_LLMNR == 1 */ - } - - return ulIPAddress; -} -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_NBNS == 1 ) - - static void prvTreatNBNS( uint8_t *pucUDPPayloadBuffer, size_t xBufferLength, uint32_t ulIPAddress ) - { - uint16_t usFlags, usType, usClass; - uint8_t *pucSource, *pucTarget; - uint8_t ucByte; - uint8_t ucNBNSName[ 17 ]; - - /* Check for minimum buffer size. */ - if( xBufferLength < sizeof( NBNSRequest_t ) ) - { - return; - } - - /* Read the request flags in host endianness. */ - usFlags = usChar2u16( pucUDPPayloadBuffer + offsetof( NBNSRequest_t, usFlags ) ); - - if( ( usFlags & dnsNBNS_FLAGS_OPCODE_MASK ) == dnsNBNS_FLAGS_OPCODE_QUERY ) - { - usType = usChar2u16( pucUDPPayloadBuffer + offsetof( NBNSRequest_t, usType ) ); - usClass = usChar2u16( pucUDPPayloadBuffer + offsetof( NBNSRequest_t, usClass ) ); - - /* Not used for now */ - ( void )usClass; - /* For NBNS a name is 16 bytes long, written with capitals only. - Make sure that the copy is terminated with a zero. */ - pucTarget = ucNBNSName + sizeof(ucNBNSName ) - 2; - pucTarget[ 1 ] = '\0'; - - /* Start with decoding the last 2 bytes. */ - pucSource = pucUDPPayloadBuffer + ( offsetof( NBNSRequest_t, ucName ) + ( dnsNBNS_ENCODED_NAME_LENGTH - 2 ) ); - - for( ;; ) - { - ucByte = ( uint8_t ) ( ( ( pucSource[ 0 ] - 0x41 ) << 4 ) | ( pucSource[ 1 ] - 0x41 ) ); - - /* Make sure there are no trailing spaces in the name. */ - if( ( ucByte == ' ' ) && ( pucTarget[ 1 ] == '\0' ) ) - { - ucByte = '\0'; - } - - *pucTarget = ucByte; - - if( pucTarget == ucNBNSName ) - { - break; - } - - pucTarget -= 1; - pucSource -= 2; - } - - #if( ipconfigUSE_DNS_CACHE == 1 ) - { - if( ( usFlags & dnsNBNS_FLAGS_RESPONSE ) != 0 ) - { - /* If this is a response from another device, - add the name to the DNS cache */ - prvProcessDNSCache( ( char * ) ucNBNSName, &ulIPAddress, 0, pdFALSE ); - } - } - #else - { - /* Avoid compiler warnings. */ - ( void ) ulIPAddress; - } - #endif /* ipconfigUSE_DNS_CACHE */ - - if( ( ( usFlags & dnsNBNS_FLAGS_RESPONSE ) == 0 ) && - ( usType == dnsNBNS_TYPE_NET_BIOS ) && - ( xApplicationDNSQueryHook( ( const char * ) ucNBNSName ) != pdFALSE ) ) - { - uint16_t usLength; - DNSMessage_t *pxMessage; - NBNSAnswer_t *pxAnswer; - - /* Someone is looking for a device with ucNBNSName, - prepare a positive reply. */ - NetworkBufferDescriptor_t *pxNetworkBuffer = pxUDPPayloadBuffer_to_NetworkBuffer( pucUDPPayloadBuffer ); - - if( ( xBufferAllocFixedSize == pdFALSE ) && ( pxNetworkBuffer != NULL ) ) - { - NetworkBufferDescriptor_t *pxNewBuffer; - BaseType_t xDataLength = pxNetworkBuffer->xDataLength + sizeof( UDPHeader_t ) + - sizeof( EthernetHeader_t ) + sizeof( IPHeader_t ); - - /* The field xDataLength was set to the length of the UDP payload. - The answer (reply) will be longer than the request, so the packet - must be duplicated into a bigger buffer */ - pxNetworkBuffer->xDataLength = xDataLength; - pxNewBuffer = pxDuplicateNetworkBufferWithDescriptor( pxNetworkBuffer, xDataLength + 16 ); - if( pxNewBuffer != NULL ) - { - pucUDPPayloadBuffer = pxNewBuffer->pucEthernetBuffer + sizeof( UDPPacket_t ); - pxNetworkBuffer = pxNewBuffer; - } - else - { - /* Just prevent that a reply will be sent */ - pxNetworkBuffer = NULL; - } - } - - /* Should not occur: pucUDPPayloadBuffer is part of a xNetworkBufferDescriptor */ - if( pxNetworkBuffer != NULL ) - { - pxMessage = (DNSMessage_t *)pucUDPPayloadBuffer; - - /* As the fields in the structures are not word-aligned, we have to - copy the values byte-by-byte using macro's vSetField16() and vSetField32() */ - vSetField16( pxMessage, DNSMessage_t, usFlags, dnsNBNS_QUERY_RESPONSE_FLAGS ); /* 0x8500 */ - vSetField16( pxMessage, DNSMessage_t, usQuestions, 0 ); - vSetField16( pxMessage, DNSMessage_t, usAnswers, 1 ); - vSetField16( pxMessage, DNSMessage_t, usAuthorityRRs, 0 ); - vSetField16( pxMessage, DNSMessage_t, usAdditionalRRs, 0 ); - - pxAnswer = (NBNSAnswer_t *)( pucUDPPayloadBuffer + offsetof( NBNSRequest_t, usType ) ); - - vSetField16( pxAnswer, NBNSAnswer_t, usType, usType ); /* Type */ - vSetField16( pxAnswer, NBNSAnswer_t, usClass, dnsNBNS_CLASS_IN ); /* Class */ - vSetField32( pxAnswer, NBNSAnswer_t, ulTTL, dnsNBNS_TTL_VALUE ); - vSetField16( pxAnswer, NBNSAnswer_t, usDataLength, 6 ); /* 6 bytes including the length field */ - vSetField16( pxAnswer, NBNSAnswer_t, usNbFlags, dnsNBNS_NAME_FLAGS ); - vSetField32( pxAnswer, NBNSAnswer_t, ulIPAddress, FreeRTOS_ntohl( *ipLOCAL_IP_ADDRESS_POINTER ) ); - - usLength = ( uint16_t ) ( offsetof( NBNSRequest_t, usType ) + sizeof( NBNSAnswer_t ) ); - - prvReplyDNSMessage( pxNetworkBuffer, usLength ); - } - } - } - } - -#endif /* ipconfigUSE_NBNS */ -/*-----------------------------------------------------------*/ - -static Socket_t prvCreateDNSSocket( void ) -{ -Socket_t xSocket = NULL; -struct freertos_sockaddr xAddress; -BaseType_t xReturn; -TickType_t xTimeoutTime = pdMS_TO_TICKS( 200 ); - - /* This must be the first time this function has been called. Create - the socket. */ - xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP ); - - /* Auto bind the port. */ - xAddress.sin_port = 0u; - xReturn = FreeRTOS_bind( xSocket, &xAddress, sizeof( xAddress ) ); - - /* Check the bind was successful, and clean up if not. */ - if( xReturn != 0 ) - { - FreeRTOS_closesocket( xSocket ); - xSocket = NULL; - } - else - { - /* Set the send and receive timeouts. */ - FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_RCVTIMEO, ( void * ) &xTimeoutTime, sizeof( TickType_t ) ); - FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, ( void * ) &xTimeoutTime, sizeof( TickType_t ) ); - } - - return xSocket; -} -/*-----------------------------------------------------------*/ - -#if( ( ipconfigUSE_NBNS == 1 ) || ( ipconfigUSE_LLMNR == 1 ) ) - - static void prvReplyDNSMessage( NetworkBufferDescriptor_t *pxNetworkBuffer, BaseType_t lNetLength ) - { - UDPPacket_t *pxUDPPacket; - IPHeader_t *pxIPHeader; - UDPHeader_t *pxUDPHeader; - - pxUDPPacket = (UDPPacket_t *) pxNetworkBuffer->pucEthernetBuffer; - pxIPHeader = &pxUDPPacket->xIPHeader; - pxUDPHeader = &pxUDPPacket->xUDPHeader; - /* HT: started using defines like 'ipSIZE_OF_xxx' */ - pxIPHeader->usLength = FreeRTOS_htons( lNetLength + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_UDP_HEADER ); - /* HT:endian: should not be translated, copying from packet to packet */ - pxIPHeader->ulDestinationIPAddress = pxIPHeader->ulSourceIPAddress; - pxIPHeader->ulSourceIPAddress = *ipLOCAL_IP_ADDRESS_POINTER; - pxIPHeader->ucTimeToLive = ipconfigUDP_TIME_TO_LIVE; - pxIPHeader->usIdentification = FreeRTOS_htons( usPacketIdentifier ); - usPacketIdentifier++; - pxUDPHeader->usLength = FreeRTOS_htons( lNetLength + ipSIZE_OF_UDP_HEADER ); - vFlip_16( pxUDPPacket->xUDPHeader.usSourcePort, pxUDPPacket->xUDPHeader.usDestinationPort ); - - #if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - { - /* calculate the IP header checksum */ - pxIPHeader->usHeaderChecksum = 0x00; - pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0UL, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER ); - pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum ); - - /* calculate the UDP checksum for outgoing package */ - usGenerateProtocolChecksum( ( uint8_t* ) pxUDPPacket, lNetLength, pdTRUE ); - } - #endif - - /* Important: tell NIC driver how many bytes must be sent */ - pxNetworkBuffer->xDataLength = ( size_t ) ( lNetLength + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_UDP_HEADER + ipSIZE_OF_ETH_HEADER ); - - /* This function will fill in the eth addresses and send the packet */ - vReturnEthernetFrame( pxNetworkBuffer, pdFALSE ); - } - -#endif /* ipconfigUSE_NBNS == 1 || ipconfigUSE_LLMNR == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_DNS_CACHE == 1 ) - - static void prvProcessDNSCache( const char *pcName, uint32_t *pulIP, uint32_t ulTTL, BaseType_t xLookUp ) - { - BaseType_t x; - BaseType_t xFound = pdFALSE; - uint32_t ulCurrentTimeSeconds = ( xTaskGetTickCount() / portTICK_PERIOD_MS ) / 1000UL; - static BaseType_t xFreeEntry = 0; - - /* For each entry in the DNS cache table. */ - for( x = 0; x < ipconfigDNS_CACHE_ENTRIES; x++ ) - { - if( xDNSCache[ x ].pcName[ 0 ] == 0 ) - { - break; - } - - if( 0 == strcmp( xDNSCache[ x ].pcName, pcName ) ) - { - /* Is this function called for a lookup or to add/update an IP address? */ - if( xLookUp != pdFALSE ) - { - /* Confirm that the record is still fresh. */ - if( ulCurrentTimeSeconds < ( xDNSCache[ x ].ulTimeWhenAddedInSeconds + FreeRTOS_ntohl( xDNSCache[ x ].ulTTL ) ) ) - { - *pulIP = xDNSCache[ x ].ulIPAddress; - } - else - { - /* Age out the old cached record. */ - xDNSCache[ x ].pcName[ 0 ] = 0; - } - } - else - { - xDNSCache[ x ].ulIPAddress = *pulIP; - xDNSCache[ x ].ulTTL = ulTTL; - xDNSCache[ x ].ulTimeWhenAddedInSeconds = ulCurrentTimeSeconds; - } - - xFound = pdTRUE; - break; - } - } - - if( xFound == pdFALSE ) - { - if( xLookUp != pdFALSE ) - { - *pulIP = 0; - } - else - { - /* Add or update the item. */ - if( strlen( pcName ) < ipconfigDNS_CACHE_NAME_LENGTH ) - { - strcpy( xDNSCache[ xFreeEntry ].pcName, pcName ); - - xDNSCache[ xFreeEntry ].ulIPAddress = *pulIP; - xDNSCache[ xFreeEntry ].ulTTL = ulTTL; - xDNSCache[ xFreeEntry ].ulTimeWhenAddedInSeconds = ulCurrentTimeSeconds; - - xFreeEntry++; - if( xFreeEntry == ipconfigDNS_CACHE_ENTRIES ) - { - xFreeEntry = 0; - } - } - } - } - - if( ( xLookUp == 0 ) || ( *pulIP != 0 ) ) - { - FreeRTOS_debug_printf( ( "prvProcessDNSCache: %s: '%s' @ %lxip\n", xLookUp ? "look-up" : "add", pcName, FreeRTOS_ntohl( *pulIP ) ) ); - } - } - -#endif /* ipconfigUSE_DNS_CACHE */ - -#endif /* ipconfigUSE_DNS != 0 */ - -/*-----------------------------------------------------------*/ - -/* Provide access to private members for testing. */ -#ifdef AMAZON_FREERTOS_ENABLE_UNIT_TESTS - #include "aws_freertos_tcp_test_access_dns_define.h" -#endif - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c deleted file mode 100755 index 9fc2a07..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c +++ /dev/null @@ -1,2313 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -/* Standard includes. */ -#include -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "FreeRTOS_ARP.h" -#include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_TCP_IP.h" -#include "FreeRTOS_DHCP.h" -#include "NetworkInterface.h" -#include "NetworkBufferManagement.h" -#include "FreeRTOS_DNS.h" - - -/* Used to ensure the structure packing is having the desired effect. The -'volatile' is used to prevent compiler warnings about comparing a constant with -a constant. */ -#define ipEXPECTED_EthernetHeader_t_SIZE ( ( size_t ) 14 ) -#define ipEXPECTED_ARPHeader_t_SIZE ( ( size_t ) 28 ) -#define ipEXPECTED_IPHeader_t_SIZE ( ( size_t ) 20 ) -#define ipEXPECTED_IGMPHeader__SIZE ( ( size_t ) 8 ) -#define ipEXPECTED_ICMPHeader_t_SIZE ( ( size_t ) 8 ) -#define ipEXPECTED_UDPHeader_t_SIZE ( ( size_t ) 8 ) -#define ipEXPECTED_TCPHeader_t_SIZE ( ( size_t ) 20 ) - - -/* ICMP protocol definitions. */ -#define ipICMP_ECHO_REQUEST ( ( uint8_t ) 8 ) -#define ipICMP_ECHO_REPLY ( ( uint8_t ) 0 ) - - -/* Time delay between repeated attempts to initialise the network hardware. */ -#define ipINITIALISATION_RETRY_DELAY ( pdMS_TO_TICKS( 3000 ) ) - -/* Defines how often the ARP timer callback function is executed. The time is -shorted in the Windows simulator as simulated time is not real time. */ -#ifndef ipARP_TIMER_PERIOD_MS - #ifdef _WINDOWS_ - #define ipARP_TIMER_PERIOD_MS ( 500 ) /* For windows simulator builds. */ - #else - #define ipARP_TIMER_PERIOD_MS ( 10000 ) - #endif -#endif - -#ifndef iptraceIP_TASK_STARTING - #define iptraceIP_TASK_STARTING() do {} while( 0 ) -#endif - -#if( ( ipconfigUSE_TCP == 1 ) && !defined( ipTCP_TIMER_PERIOD_MS ) ) - /* When initialising the TCP timer, - give it an initial time-out of 1 second. */ - #define ipTCP_TIMER_PERIOD_MS ( 1000 ) -#endif - -/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1, then the Ethernet -driver will filter incoming packets and only pass the stack those packets it -considers need processing. In this case ipCONSIDER_FRAME_FOR_PROCESSING() can -be #defined away. If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 0 -then the Ethernet driver will pass all received packets to the stack, and the -stack must do the filtering itself. In this case ipCONSIDER_FRAME_FOR_PROCESSING -needs to call eConsiderFrameForProcessing. */ -#if ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES == 0 - #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) ) -#else - #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer -#endif - -/* The character used to fill ICMP echo requests, and therefore also the -character expected to fill ICMP echo replies. */ -#define ipECHO_DATA_FILL_BYTE 'x' - -#if( ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN ) - /* The bits in the two byte IP header field that make up the fragment offset value. */ - #define ipFRAGMENT_OFFSET_BIT_MASK ( ( uint16_t ) 0xff0f ) -#else - /* The bits in the two byte IP header field that make up the fragment offset value. */ - #define ipFRAGMENT_OFFSET_BIT_MASK ( ( uint16_t ) 0x0fff ) -#endif /* ipconfigBYTE_ORDER */ - -/* The maximum time the IP task is allowed to remain in the Blocked state if no -events are posted to the network event queue. */ -#ifndef ipconfigMAX_IP_TASK_SLEEP_TIME - #define ipconfigMAX_IP_TASK_SLEEP_TIME ( pdMS_TO_TICKS( 10000UL ) ) -#endif - -/* When a new TCP connection is established, the value of -'ulNextInitialSequenceNumber' will be used as the initial sequence number. It -is very important that at start-up, 'ulNextInitialSequenceNumber' contains a -random value. Also its value must be increased continuously in time, to prevent -a third party guessing the next sequence number and take-over a TCP connection. -It is advised to increment it by 1 ever 4us, which makes about 256 times -per ms: */ -#define ipINITIAL_SEQUENCE_NUMBER_FACTOR 256UL - -/* Returned as the (invalid) checksum when the protocol being checked is not -handled. The value is chosen simply to be easy to spot when debugging. */ -#define ipUNHANDLED_PROTOCOL 0x4321u - -/* Returned to indicate a valid checksum when the checksum does not need to be -calculated. */ -#define ipCORRECT_CRC 0xffffu - -/* Returned as the (invalid) checksum when the length of the data being checked -had an invalid length. */ -#define ipINVALID_LENGTH 0x1234u - -/*-----------------------------------------------------------*/ - -typedef struct xIP_TIMER -{ - uint32_t - bActive : 1, /* This timer is running and must be processed. */ - bExpired : 1; /* Timer has expired and a task must be processed. */ - TimeOut_t xTimeOut; - TickType_t ulRemainingTime; - TickType_t ulReloadTime; -} IPTimer_t; - -/* Used in checksum calculation. */ -typedef union _xUnion32 -{ - uint32_t u32; - uint16_t u16[ 2 ]; - uint8_t u8[ 4 ]; -} xUnion32; - -/* Used in checksum calculation. */ -typedef union _xUnionPtr -{ - uint32_t *u32ptr; - uint16_t *u16ptr; - uint8_t *u8ptr; -} xUnionPtr; - -/*-----------------------------------------------------------*/ - -/* - * The main TCP/IP stack processing task. This task receives commands/events - * from the network hardware drivers and tasks that are using sockets. It also - * maintains a set of protocol timers. - */ -static void prvIPTask( void *pvParameters ); - -/* - * Called when new data is available from the network interface. - */ -static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer ); - -/* - * Process incoming IP packets. - */ -static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * const pxIPPacket, NetworkBufferDescriptor_t * const pxNetworkBuffer ); - -#if ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) - /* - * Process incoming ICMP packets. - */ - static eFrameProcessingResult_t prvProcessICMPPacket( ICMPPacket_t * const pxICMPPacket ); -#endif /* ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) */ - -/* - * Turns around an incoming ping request to convert it into a ping reply. - */ -#if ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) - static eFrameProcessingResult_t prvProcessICMPEchoRequest( ICMPPacket_t * const pxICMPPacket ); -#endif /* ipconfigREPLY_TO_INCOMING_PINGS */ - -/* - * Processes incoming ping replies. The application callback function - * vApplicationPingReplyHook() is called with the results. - */ -#if ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) - static void prvProcessICMPEchoReply( ICMPPacket_t * const pxICMPPacket ); -#endif /* ipconfigSUPPORT_OUTGOING_PINGS */ - -/* - * Called to create a network connection when the stack is first started, or - * when the network connection is lost. - */ -static void prvProcessNetworkDownEvent( void ); - -/* - * Checks the ARP, DHCP and TCP timers to see if any periodic or timeout - * processing is required. - */ -static void prvCheckNetworkTimers( void ); - -/* - * Determine how long the IP task can sleep for, which depends on when the next - * periodic or timeout processing must be performed. - */ -static TickType_t prvCalculateSleepTime( void ); - -/* - * The network card driver has received a packet. In the case that it is part - * of a linked packet chain, walk through it to handle every message. - */ -static void prvHandleEthernetPacket( NetworkBufferDescriptor_t *pxBuffer ); - -/* - * Utility functions for the light weight IP timers. - */ -static void prvIPTimerStart( IPTimer_t *pxTimer, TickType_t xTime ); -static BaseType_t prvIPTimerCheck( IPTimer_t *pxTimer ); -static void prvIPTimerReload( IPTimer_t *pxTimer, TickType_t xTime ); - -static eFrameProcessingResult_t prvAllowIPPacket( const IPPacket_t * const pxIPPacket, - NetworkBufferDescriptor_t * const pxNetworkBuffer, UBaseType_t uxHeaderLength ); - -/*-----------------------------------------------------------*/ - -/* The queue used to pass events into the IP-task for processing. */ -QueueHandle_t xNetworkEventQueue = NULL; - -/*_RB_ Requires comment. */ -uint16_t usPacketIdentifier = 0U; - -/* For convenience, a MAC address of all 0xffs is defined const for quick -reference. */ -const MACAddress_t xBroadcastMACAddress = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }; - -/* Structure that stores the netmask, gateway address and DNS server addresses. */ -NetworkAddressingParameters_t xNetworkAddressing = { 0, 0, 0, 0, 0 }; - -/* Default values for the above struct in case DHCP -does not lead to a confirmed request. */ -NetworkAddressingParameters_t xDefaultAddressing = { 0, 0, 0, 0, 0 }; - -/* Used to ensure network down events cannot be missed when they cannot be -posted to the network event queue because the network event queue is already -full. */ -static BaseType_t xNetworkDownEventPending = pdFALSE; - -/* Stores the handle of the task that handles the stack. The handle is used -(indirectly) by some utility function to determine if the utility function is -being called by a task (in which case it is ok to block) or by the IP task -itself (in which case it is not ok to block). */ -static TaskHandle_t xIPTaskHandle = NULL; - -#if( ipconfigUSE_TCP != 0 ) - /* Set to a non-zero value if one or more TCP message have been processed - within the last round. */ - static BaseType_t xProcessedTCPMessage; -#endif - -/* Simple set to pdTRUE or pdFALSE depending on whether the network is up or -down (connected, not connected) respectively. */ -static BaseType_t xNetworkUp = pdFALSE; - -/* -A timer for each of the following processes, all of which need attention on a -regular basis: - 1. ARP, to check its table entries - 2. DPHC, to send requests and to renew a reservation - 3. TCP, to check for timeouts, resends - 4. DNS, to check for timeouts when looking-up a domain. - */ -static IPTimer_t xARPTimer; -#if( ipconfigUSE_DHCP != 0 ) - static IPTimer_t xDHCPTimer; -#endif -#if( ipconfigUSE_TCP != 0 ) - static IPTimer_t xTCPTimer; -#endif -#if( ipconfigDNS_USE_CALLBACKS != 0 ) - static IPTimer_t xDNSTimer; -#endif - -/* Set to pdTRUE when the IP task is ready to start processing packets. */ -static BaseType_t xIPTaskInitialised = pdFALSE; - -#if( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - /* Keep track of the lowest amount of space in 'xNetworkEventQueue'. */ - static UBaseType_t uxQueueMinimumSpace = ipconfigEVENT_QUEUE_LENGTH; -#endif - -/*-----------------------------------------------------------*/ - -static void prvIPTask( void *pvParameters ) -{ -IPStackEvent_t xReceivedEvent; -TickType_t xNextIPSleep; -FreeRTOS_Socket_t *pxSocket; -struct freertos_sockaddr xAddress; - - /* Just to prevent compiler warnings about unused parameters. */ - ( void ) pvParameters; - - /* A possibility to set some additional task properties. */ - iptraceIP_TASK_STARTING(); - - /* Generate a dummy message to say that the network connection has gone - down. This will cause this task to initialise the network interface. After - this it is the responsibility of the network interface hardware driver to - send this message if a previously connected network is disconnected. */ - FreeRTOS_NetworkDown(); - - #if( ipconfigUSE_TCP == 1 ) - { - /* Initialise the TCP timer. */ - prvIPTimerReload( &xTCPTimer, pdMS_TO_TICKS( ipTCP_TIMER_PERIOD_MS ) ); - } - #endif - - /* Initialisation is complete and events can now be processed. */ - xIPTaskInitialised = pdTRUE; - - FreeRTOS_debug_printf( ( "prvIPTask started\n" ) ); - - /* Loop, processing IP events. */ - for( ;; ) - { - ipconfigWATCHDOG_TIMER(); - - /* Check the ARP, DHCP and TCP timers to see if there is any periodic - or timeout processing to perform. */ - prvCheckNetworkTimers(); - - /* Calculate the acceptable maximum sleep time. */ - xNextIPSleep = prvCalculateSleepTime(); - - /* Wait until there is something to do. If the following call exits - * due to a time out rather than a message being received, set a - * 'NoEvent' value. */ - if ( xQueueReceive( xNetworkEventQueue, ( void * ) &xReceivedEvent, xNextIPSleep ) == pdFALSE ) - { - xReceivedEvent.eEventType = eNoEvent; - } - - #if( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - { - if( xReceivedEvent.eEventType != eNoEvent ) - { - UBaseType_t uxCount; - - uxCount = uxQueueSpacesAvailable( xNetworkEventQueue ); - if( uxQueueMinimumSpace > uxCount ) - { - uxQueueMinimumSpace = uxCount; - } - } - } - #endif /* ipconfigCHECK_IP_QUEUE_SPACE */ - - iptraceNETWORK_EVENT_RECEIVED( xReceivedEvent.eEventType ); - - switch( xReceivedEvent.eEventType ) - { - case eNetworkDownEvent : - /* Attempt to establish a connection. */ - xNetworkUp = pdFALSE; - prvProcessNetworkDownEvent(); - break; - - case eNetworkRxEvent: - /* The network hardware driver has received a new packet. A - pointer to the received buffer is located in the pvData member - of the received event structure. */ - prvHandleEthernetPacket( ( NetworkBufferDescriptor_t * ) ( xReceivedEvent.pvData ) ); - break; - - case eARPTimerEvent : - /* The ARP timer has expired, process the ARP cache. */ - vARPAgeCache(); - break; - - case eSocketBindEvent: - /* FreeRTOS_bind (a user API) wants the IP-task to bind a socket - to a port. The port number is communicated in the socket field - usLocalPort. vSocketBind() will actually bind the socket and the - API will unblock as soon as the eSOCKET_BOUND event is - triggered. */ - pxSocket = ( FreeRTOS_Socket_t * ) ( xReceivedEvent.pvData ); - xAddress.sin_addr = 0u; /* For the moment. */ - xAddress.sin_port = FreeRTOS_ntohs( pxSocket->usLocalPort ); - pxSocket->usLocalPort = 0u; - vSocketBind( pxSocket, &xAddress, sizeof( xAddress ), pdFALSE ); - - /* Before 'eSocketBindEvent' was sent it was tested that - ( xEventGroup != NULL ) so it can be used now to wake up the - user. */ - pxSocket->xEventBits |= eSOCKET_BOUND; - vSocketWakeUpUser( pxSocket ); - break; - - case eSocketCloseEvent : - /* The user API FreeRTOS_closesocket() has sent a message to the - IP-task to actually close a socket. This is handled in - vSocketClose(). As the socket gets closed, there is no way to - report back to the API, so the API won't wait for the result */ - vSocketClose( ( FreeRTOS_Socket_t * ) ( xReceivedEvent.pvData ) ); - break; - - case eStackTxEvent : - /* The network stack has generated a packet to send. A - pointer to the generated buffer is located in the pvData - member of the received event structure. */ - vProcessGeneratedUDPPacket( ( NetworkBufferDescriptor_t * ) ( xReceivedEvent.pvData ) ); - break; - - case eDHCPEvent: - /* The DHCP state machine needs processing. */ - #if( ipconfigUSE_DHCP == 1 ) - { - vDHCPProcess( pdFALSE ); - } - #endif /* ipconfigUSE_DHCP */ - break; - - case eSocketSelectEvent : - /* FreeRTOS_select() has got unblocked by a socket event, - vSocketSelect() will check which sockets actually have an event - and update the socket field xSocketBits. */ - #if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - { - vSocketSelect( ( SocketSelect_t * ) ( xReceivedEvent.pvData ) ); - } - #endif /* ipconfigSUPPORT_SELECT_FUNCTION == 1 */ - break; - - case eSocketSignalEvent : - #if( ipconfigSUPPORT_SIGNALS != 0 ) - { - /* Some task wants to signal the user of this socket in - order to interrupt a call to recv() or a call to select(). */ - FreeRTOS_SignalSocket( ( Socket_t ) xReceivedEvent.pvData ); - } - #endif /* ipconfigSUPPORT_SIGNALS */ - break; - - case eTCPTimerEvent : - #if( ipconfigUSE_TCP == 1 ) - { - /* Simply mark the TCP timer as expired so it gets processed - the next time prvCheckNetworkTimers() is called. */ - xTCPTimer.bExpired = pdTRUE_UNSIGNED; - } - #endif /* ipconfigUSE_TCP */ - break; - - case eTCPAcceptEvent: - /* The API FreeRTOS_accept() was called, the IP-task will now - check if the listening socket (communicated in pvData) actually - received a new connection. */ - #if( ipconfigUSE_TCP == 1 ) - { - pxSocket = ( FreeRTOS_Socket_t * ) ( xReceivedEvent.pvData ); - - if( xTCPCheckNewClient( pxSocket ) != pdFALSE ) - { - pxSocket->xEventBits |= eSOCKET_ACCEPT; - vSocketWakeUpUser( pxSocket ); - } - } - #endif /* ipconfigUSE_TCP */ - break; - - case eTCPNetStat: - /* FreeRTOS_netstat() was called to have the IP-task print an - overview of all sockets and their connections */ - #if( ( ipconfigUSE_TCP == 1 ) && ( ipconfigHAS_PRINTF == 1 ) ) - { - vTCPNetStat(); - } - #endif /* ipconfigUSE_TCP */ - break; - - default : - /* Should not get here. */ - break; - } - - if( xNetworkDownEventPending != pdFALSE ) - { - /* A network down event could not be posted to the network event - queue because the queue was full. Try posting again. */ - FreeRTOS_NetworkDown(); - } - } -} -/*-----------------------------------------------------------*/ - -BaseType_t xIsCallingFromIPTask( void ) -{ -BaseType_t xReturn; - - if( xTaskGetCurrentTaskHandle() == xIPTaskHandle ) - { - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -static void prvHandleEthernetPacket( NetworkBufferDescriptor_t *pxBuffer ) -{ - #if( ipconfigUSE_LINKED_RX_MESSAGES == 0 ) - { - /* When ipconfigUSE_LINKED_RX_MESSAGES is not set to 0 then only one - buffer will be sent at a time. This is the default way for +TCP to pass - messages from the MAC to the TCP/IP stack. */ - prvProcessEthernetPacket( pxBuffer ); - } - #else /* ipconfigUSE_LINKED_RX_MESSAGES */ - { - NetworkBufferDescriptor_t *pxNextBuffer; - - /* An optimisation that is useful when there is high network traffic. - Instead of passing received packets into the IP task one at a time the - network interface can chain received packets together and pass them into - the IP task in one go. The packets are chained using the pxNextBuffer - member. The loop below walks through the chain processing each packet - in the chain in turn. */ - do - { - /* Store a pointer to the buffer after pxBuffer for use later on. */ - pxNextBuffer = pxBuffer->pxNextBuffer; - - /* Make it NULL to avoid using it later on. */ - pxBuffer->pxNextBuffer = NULL; - - prvProcessEthernetPacket( pxBuffer ); - pxBuffer = pxNextBuffer; - - /* While there is another packet in the chain. */ - } while( pxBuffer != NULL ); - } - #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ -} -/*-----------------------------------------------------------*/ - -static TickType_t prvCalculateSleepTime( void ) -{ -TickType_t xMaximumSleepTime; - - /* Start with the maximum sleep time, then check this against the remaining - time in any other timers that are active. */ - xMaximumSleepTime = ipconfigMAX_IP_TASK_SLEEP_TIME; - - if( xARPTimer.bActive != pdFALSE_UNSIGNED ) - { - if( xARPTimer.ulRemainingTime < xMaximumSleepTime ) - { - xMaximumSleepTime = xARPTimer.ulReloadTime; - } - } - - #if( ipconfigUSE_DHCP == 1 ) - { - if( xDHCPTimer.bActive != pdFALSE_UNSIGNED ) - { - if( xDHCPTimer.ulRemainingTime < xMaximumSleepTime ) - { - xMaximumSleepTime = xDHCPTimer.ulRemainingTime; - } - } - } - #endif /* ipconfigUSE_DHCP */ - - #if( ipconfigUSE_TCP == 1 ) - { - if( xTCPTimer.ulRemainingTime < xMaximumSleepTime ) - { - xMaximumSleepTime = xTCPTimer.ulRemainingTime; - } - } - #endif - - #if( ipconfigDNS_USE_CALLBACKS != 0 ) - { - if( xDNSTimer.bActive != pdFALSE ) - { - if( xDNSTimer.ulRemainingTime < xMaximumSleepTime ) - { - xMaximumSleepTime = xDNSTimer.ulRemainingTime; - } - } - } - #endif - - return xMaximumSleepTime; -} -/*-----------------------------------------------------------*/ - -static void prvCheckNetworkTimers( void ) -{ - /* Is it time for ARP processing? */ - if( prvIPTimerCheck( &xARPTimer ) != pdFALSE ) - { - xSendEventToIPTask( eARPTimerEvent ); - } - - #if( ipconfigUSE_DHCP == 1 ) - { - /* Is it time for DHCP processing? */ - if( prvIPTimerCheck( &xDHCPTimer ) != pdFALSE ) - { - xSendEventToIPTask( eDHCPEvent ); - } - } - #endif /* ipconfigUSE_DHCP */ - - #if( ipconfigDNS_USE_CALLBACKS != 0 ) - { - extern void vDNSCheckCallBack( void *pvSearchID ); - - /* Is it time for DNS processing? */ - if( prvIPTimerCheck( &xDNSTimer ) != pdFALSE ) - { - vDNSCheckCallBack( NULL ); - } - } - #endif /* ipconfigDNS_USE_CALLBACKS */ - - #if( ipconfigUSE_TCP == 1 ) - { - BaseType_t xWillSleep; - TickType_t xNextTime; - BaseType_t xCheckTCPSockets; - - if( uxQueueMessagesWaiting( xNetworkEventQueue ) == 0u ) - { - xWillSleep = pdTRUE; - } - else - { - xWillSleep = pdFALSE; - } - - /* Sockets need to be checked if the TCP timer has expired. */ - xCheckTCPSockets = prvIPTimerCheck( &xTCPTimer ); - - /* Sockets will also be checked if there are TCP messages but the - message queue is empty (indicated by xWillSleep being true). */ - if( ( xProcessedTCPMessage != pdFALSE ) && ( xWillSleep != pdFALSE ) ) - { - xCheckTCPSockets = pdTRUE; - } - - if( xCheckTCPSockets != pdFALSE ) - { - /* Attend to the sockets, returning the period after which the - check must be repeated. */ - xNextTime = xTCPTimerCheck( xWillSleep ); - prvIPTimerStart( &xTCPTimer, xNextTime ); - xProcessedTCPMessage = 0; - } - } - #endif /* ipconfigUSE_TCP == 1 */ -} -/*-----------------------------------------------------------*/ - -static void prvIPTimerStart( IPTimer_t *pxTimer, TickType_t xTime ) -{ - vTaskSetTimeOutState( &pxTimer->xTimeOut ); - pxTimer->ulRemainingTime = xTime; - - if( xTime == ( TickType_t ) 0 ) - { - pxTimer->bExpired = pdTRUE_UNSIGNED; - } - else - { - pxTimer->bExpired = pdFALSE_UNSIGNED; - } - - pxTimer->bActive = pdTRUE_UNSIGNED; -} -/*-----------------------------------------------------------*/ - -static void prvIPTimerReload( IPTimer_t *pxTimer, TickType_t xTime ) -{ - pxTimer->ulReloadTime = xTime; - prvIPTimerStart( pxTimer, xTime ); -} -/*-----------------------------------------------------------*/ - -static BaseType_t prvIPTimerCheck( IPTimer_t *pxTimer ) -{ -BaseType_t xReturn; - - if( pxTimer->bActive == pdFALSE_UNSIGNED ) - { - /* The timer is not enabled. */ - xReturn = pdFALSE; - } - else - { - /* The timer might have set the bExpired flag already, if not, check the - value of xTimeOut against ulRemainingTime. */ - if( ( pxTimer->bExpired != pdFALSE_UNSIGNED ) || - ( xTaskCheckForTimeOut( &( pxTimer->xTimeOut ), &( pxTimer->ulRemainingTime ) ) != pdFALSE ) ) - { - prvIPTimerStart( pxTimer, pxTimer->ulReloadTime ); - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -void FreeRTOS_NetworkDown( void ) -{ -static const IPStackEvent_t xNetworkDownEvent = { eNetworkDownEvent, NULL }; -const TickType_t xDontBlock = ( TickType_t ) 0; - - /* Simply send the network task the appropriate event. */ - if( xSendEventStructToIPTask( &xNetworkDownEvent, xDontBlock ) != pdPASS ) - { - /* Could not send the message, so it is still pending. */ - xNetworkDownEventPending = pdTRUE; - } - else - { - /* Message was sent so it is not pending. */ - xNetworkDownEventPending = pdFALSE; - } - - iptraceNETWORK_DOWN(); -} -/*-----------------------------------------------------------*/ - -BaseType_t FreeRTOS_NetworkDownFromISR( void ) -{ -static const IPStackEvent_t xNetworkDownEvent = { eNetworkDownEvent, NULL }; -BaseType_t xHigherPriorityTaskWoken = pdFALSE; - - /* Simply send the network task the appropriate event. */ - if( xQueueSendToBackFromISR( xNetworkEventQueue, &xNetworkDownEvent, &xHigherPriorityTaskWoken ) != pdPASS ) - { - xNetworkDownEventPending = pdTRUE; - } - else - { - xNetworkDownEventPending = pdFALSE; - } - - iptraceNETWORK_DOWN(); - - return xHigherPriorityTaskWoken; -} -/*-----------------------------------------------------------*/ - -void *FreeRTOS_GetUDPPayloadBuffer( size_t xRequestedSizeBytes, TickType_t xBlockTimeTicks ) -{ -NetworkBufferDescriptor_t *pxNetworkBuffer; -void *pvReturn; - - /* Cap the block time. The reason for this is explained where - ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS is defined (assuming an official - FreeRTOSIPConfig.h header file is being used). */ - if( xBlockTimeTicks > ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ) - { - xBlockTimeTicks = ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS; - } - - /* Obtain a network buffer with the required amount of storage. */ - pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( sizeof( UDPPacket_t ) + xRequestedSizeBytes, xBlockTimeTicks ); - - if( pxNetworkBuffer != NULL ) - { - /* Set the actual packet size in case a bigger buffer was returned. */ - pxNetworkBuffer->xDataLength = sizeof( UDPPacket_t ) + xRequestedSizeBytes; - - /* Leave space for the UPD header. */ - pvReturn = ( void * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipUDP_PAYLOAD_OFFSET_IPv4 ] ); - } - else - { - pvReturn = NULL; - } - - return ( void * ) pvReturn; -} -/*-----------------------------------------------------------*/ - -NetworkBufferDescriptor_t *pxDuplicateNetworkBufferWithDescriptor( NetworkBufferDescriptor_t * const pxNetworkBuffer, - BaseType_t xNewLength ) -{ -NetworkBufferDescriptor_t * pxNewBuffer; - - /* This function is only used when 'ipconfigZERO_COPY_TX_DRIVER' is set to 1. - The transmit routine wants to have ownership of the network buffer - descriptor, because it will pass the buffer straight to DMA. */ - pxNewBuffer = pxGetNetworkBufferWithDescriptor( ( size_t ) xNewLength, ( TickType_t ) 0 ); - - if( pxNewBuffer != NULL ) - { - /* Set the actual packet size in case a bigger buffer than requested - was returned. */ - pxNewBuffer->xDataLength = xNewLength; - - /* Copy the original packet information. */ - pxNewBuffer->ulIPAddress = pxNetworkBuffer->ulIPAddress; - pxNewBuffer->usPort = pxNetworkBuffer->usPort; - pxNewBuffer->usBoundPort = pxNetworkBuffer->usBoundPort; - memcpy( pxNewBuffer->pucEthernetBuffer, pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength ); - } - - return pxNewBuffer; -} -/*-----------------------------------------------------------*/ - -#if( ipconfigZERO_COPY_TX_DRIVER != 0 ) || ( ipconfigZERO_COPY_RX_DRIVER != 0 ) - - NetworkBufferDescriptor_t *pxPacketBuffer_to_NetworkBuffer( const void *pvBuffer ) - { - uint8_t *pucBuffer; - NetworkBufferDescriptor_t *pxResult; - - if( pvBuffer == NULL ) - { - pxResult = NULL; - } - else - { - /* Obtain the network buffer from the zero copy pointer. */ - pucBuffer = ( uint8_t * ) pvBuffer; - - /* The input here is a pointer to a payload buffer. Subtract the - size of the header in the network buffer, usually 8 + 2 bytes. */ - pucBuffer -= ipBUFFER_PADDING; - - /* Here a pointer was placed to the network descriptor. As a - pointer is dereferenced, make sure it is well aligned. */ - if( ( ( ( uint32_t ) pucBuffer ) & ( sizeof( pucBuffer ) - ( size_t ) 1 ) ) == ( uint32_t ) 0 ) - { - pxResult = * ( ( NetworkBufferDescriptor_t ** ) pucBuffer ); - } - else - { - pxResult = NULL; - } - } - - return pxResult; - } - -#endif /* ipconfigZERO_COPY_TX_DRIVER != 0 */ -/*-----------------------------------------------------------*/ - -NetworkBufferDescriptor_t *pxUDPPayloadBuffer_to_NetworkBuffer( void *pvBuffer ) -{ -uint8_t *pucBuffer; -NetworkBufferDescriptor_t *pxResult; - - if( pvBuffer == NULL ) - { - pxResult = NULL; - } - else - { - /* Obtain the network buffer from the zero copy pointer. */ - pucBuffer = ( uint8_t * ) pvBuffer; - - /* The input here is a pointer to a payload buffer. Subtract - the total size of a UDP/IP header plus the size of the header in - the network buffer, usually 8 + 2 bytes. */ - pucBuffer -= ( sizeof( UDPPacket_t ) + ipBUFFER_PADDING ); - - /* Here a pointer was placed to the network descriptor, - As a pointer is dereferenced, make sure it is well aligned */ - if( ( ( ( uint32_t ) pucBuffer ) & ( sizeof( pucBuffer ) - 1 ) ) == 0 ) - { - /* The following statement may trigger a: - warning: cast increases required alignment of target type [-Wcast-align]. - It has been confirmed though that the alignment is suitable. */ - pxResult = * ( ( NetworkBufferDescriptor_t ** ) pucBuffer ); - } - else - { - pxResult = NULL; - } - } - - return pxResult; -} -/*-----------------------------------------------------------*/ - -void FreeRTOS_ReleaseUDPPayloadBuffer( void *pvBuffer ) -{ - vReleaseNetworkBufferAndDescriptor( pxUDPPayloadBuffer_to_NetworkBuffer( pvBuffer ) ); -} -/*-----------------------------------------------------------*/ - -/*_RB_ Should we add an error or assert if the task priorities are set such that the servers won't function as expected? */ -/*_HT_ There was a bug in FreeRTOS_TCP_IP.c that only occurred when the applications' priority was too high. - As that bug has been repaired, there is not an urgent reason to warn. - It is better though to use the advised priority scheme. */ -BaseType_t FreeRTOS_IPInit( const uint8_t ucIPAddress[ ipIP_ADDRESS_LENGTH_BYTES ], const uint8_t ucNetMask[ ipIP_ADDRESS_LENGTH_BYTES ], const uint8_t ucGatewayAddress[ ipIP_ADDRESS_LENGTH_BYTES ], const uint8_t ucDNSServerAddress[ ipIP_ADDRESS_LENGTH_BYTES ], const uint8_t ucMACAddress[ ipMAC_ADDRESS_LENGTH_BYTES ] ) -{ -BaseType_t xReturn = pdFALSE; - - /* This function should only be called once. */ - configASSERT( xIPIsNetworkTaskReady() == pdFALSE ); - configASSERT( xNetworkEventQueue == NULL ); - configASSERT( xIPTaskHandle == NULL ); - - /* Check structure packing is correct. */ - configASSERT( sizeof( EthernetHeader_t ) == ipEXPECTED_EthernetHeader_t_SIZE ); - configASSERT( sizeof( ARPHeader_t ) == ipEXPECTED_ARPHeader_t_SIZE ); - configASSERT( sizeof( IPHeader_t ) == ipEXPECTED_IPHeader_t_SIZE ); - configASSERT( sizeof( ICMPHeader_t ) == ipEXPECTED_ICMPHeader_t_SIZE ); - configASSERT( sizeof( UDPHeader_t ) == ipEXPECTED_UDPHeader_t_SIZE ); - - /* Attempt to create the queue used to communicate with the IP task. */ - xNetworkEventQueue = xQueueCreate( ( UBaseType_t ) ipconfigEVENT_QUEUE_LENGTH, ( UBaseType_t ) sizeof( IPStackEvent_t ) ); - configASSERT( xNetworkEventQueue ); - - if( xNetworkEventQueue != NULL ) - { - #if ( configQUEUE_REGISTRY_SIZE > 0 ) - { - /* A queue registry is normally used to assist a kernel aware - debugger. If one is in use then it will be helpful for the debugger - to show information about the network event queue. */ - vQueueAddToRegistry( xNetworkEventQueue, "NetEvnt" ); - } - #endif /* configQUEUE_REGISTRY_SIZE */ - - if( xNetworkBuffersInitialise() == pdPASS ) - { - /* Store the local IP and MAC address. */ - xNetworkAddressing.ulDefaultIPAddress = FreeRTOS_inet_addr_quick( ucIPAddress[ 0 ], ucIPAddress[ 1 ], ucIPAddress[ 2 ], ucIPAddress[ 3 ] ); - xNetworkAddressing.ulNetMask = FreeRTOS_inet_addr_quick( ucNetMask[ 0 ], ucNetMask[ 1 ], ucNetMask[ 2 ], ucNetMask[ 3 ] ); - xNetworkAddressing.ulGatewayAddress = FreeRTOS_inet_addr_quick( ucGatewayAddress[ 0 ], ucGatewayAddress[ 1 ], ucGatewayAddress[ 2 ], ucGatewayAddress[ 3 ] ); - xNetworkAddressing.ulDNSServerAddress = FreeRTOS_inet_addr_quick( ucDNSServerAddress[ 0 ], ucDNSServerAddress[ 1 ], ucDNSServerAddress[ 2 ], ucDNSServerAddress[ 3 ] ); - xNetworkAddressing.ulBroadcastAddress = ( xNetworkAddressing.ulDefaultIPAddress & xNetworkAddressing.ulNetMask ) | ~xNetworkAddressing.ulNetMask; - - memcpy( &xDefaultAddressing, &xNetworkAddressing, sizeof( xDefaultAddressing ) ); - - #if ipconfigUSE_DHCP == 1 - { - /* The IP address is not set until DHCP completes. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0x00UL; - } - #else - { - /* The IP address is set from the value passed in. */ - *ipLOCAL_IP_ADDRESS_POINTER = xNetworkAddressing.ulDefaultIPAddress; - - /* Added to prevent ARP flood to gateway. Ensure the - gateway is on the same subnet as the IP address. */ - configASSERT( ( ( *ipLOCAL_IP_ADDRESS_POINTER ) & xNetworkAddressing.ulNetMask ) == ( xNetworkAddressing.ulGatewayAddress & xNetworkAddressing.ulNetMask ) ); - } - #endif /* ipconfigUSE_DHCP == 1 */ - - /* The MAC address is stored in the start of the default packet - header fragment, which is used when sending UDP packets. */ - memcpy( ( void * ) ipLOCAL_MAC_ADDRESS, ( void * ) ucMACAddress, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); - - /* Prepare the sockets interface. */ - xReturn = vNetworkSocketsInit(); - - if( pdTRUE == xReturn ) - { - /* Create the task that processes Ethernet and stack events. */ - xReturn = xTaskCreate( prvIPTask, "IP-task", ( uint16_t )ipconfigIP_TASK_STACK_SIZE_WORDS, NULL, ( UBaseType_t )ipconfigIP_TASK_PRIORITY, &xIPTaskHandle ); - } - } - else - { - FreeRTOS_debug_printf( ( "FreeRTOS_IPInit: xNetworkBuffersInitialise() failed\n") ); - - /* Clean up. */ - vQueueDelete( xNetworkEventQueue ); - xNetworkEventQueue = NULL; - } - } - else - { - FreeRTOS_debug_printf( ( "FreeRTOS_IPInit: Network event queue could not be created\n") ); - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -void FreeRTOS_GetAddressConfiguration( uint32_t *pulIPAddress, uint32_t *pulNetMask, uint32_t *pulGatewayAddress, uint32_t *pulDNSServerAddress ) -{ - /* Return the address configuration to the caller. */ - - if( pulIPAddress != NULL ) - { - *pulIPAddress = *ipLOCAL_IP_ADDRESS_POINTER; - } - - if( pulNetMask != NULL ) - { - *pulNetMask = xNetworkAddressing.ulNetMask; - } - - if( pulGatewayAddress != NULL ) - { - *pulGatewayAddress = xNetworkAddressing.ulGatewayAddress; - } - - if( pulDNSServerAddress != NULL ) - { - *pulDNSServerAddress = xNetworkAddressing.ulDNSServerAddress; - } -} -/*-----------------------------------------------------------*/ - -void FreeRTOS_SetAddressConfiguration( const uint32_t *pulIPAddress, const uint32_t *pulNetMask, const uint32_t *pulGatewayAddress, const uint32_t *pulDNSServerAddress ) -{ - /* Update the address configuration. */ - - if( pulIPAddress != NULL ) - { - *ipLOCAL_IP_ADDRESS_POINTER = *pulIPAddress; - } - - if( pulNetMask != NULL ) - { - xNetworkAddressing.ulNetMask = *pulNetMask; - } - - if( pulGatewayAddress != NULL ) - { - xNetworkAddressing.ulGatewayAddress = *pulGatewayAddress; - } - - if( pulDNSServerAddress != NULL ) - { - xNetworkAddressing.ulDNSServerAddress = *pulDNSServerAddress; - } -} -/*-----------------------------------------------------------*/ - -#if ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) - - BaseType_t FreeRTOS_SendPingRequest( uint32_t ulIPAddress, size_t xNumberOfBytesToSend, TickType_t xBlockTimeTicks ) - { - NetworkBufferDescriptor_t *pxNetworkBuffer; - ICMPHeader_t *pxICMPHeader; - BaseType_t xReturn = pdFAIL; - static uint16_t usSequenceNumber = 0; - uint8_t *pucChar; - IPStackEvent_t xStackTxEvent = { eStackTxEvent, NULL }; - - if( (xNumberOfBytesToSend >= 1 ) && ( xNumberOfBytesToSend < ( ( ipconfigNETWORK_MTU - sizeof( IPHeader_t ) ) - sizeof( ICMPHeader_t ) ) ) && ( uxGetNumberOfFreeNetworkBuffers() >= 3 ) ) - { - pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( xNumberOfBytesToSend + sizeof( ICMPPacket_t ), xBlockTimeTicks ); - - if( pxNetworkBuffer != NULL ) - { - pxICMPHeader = ( ICMPHeader_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipIP_PAYLOAD_OFFSET ] ); - usSequenceNumber++; - - /* Fill in the basic header information. */ - pxICMPHeader->ucTypeOfMessage = ipICMP_ECHO_REQUEST; - pxICMPHeader->ucTypeOfService = 0; - pxICMPHeader->usIdentifier = usSequenceNumber; - pxICMPHeader->usSequenceNumber = usSequenceNumber; - - /* Find the start of the data. */ - pucChar = ( uint8_t * ) pxICMPHeader; - pucChar += sizeof( ICMPHeader_t ); - - /* Just memset the data to a fixed value. */ - memset( ( void * ) pucChar, ( int ) ipECHO_DATA_FILL_BYTE, xNumberOfBytesToSend ); - - /* The message is complete, IP and checksum's are handled by - vProcessGeneratedUDPPacket */ - pxNetworkBuffer->pucEthernetBuffer[ ipSOCKET_OPTIONS_OFFSET ] = FREERTOS_SO_UDPCKSUM_OUT; - pxNetworkBuffer->ulIPAddress = ulIPAddress; - pxNetworkBuffer->usPort = ipPACKET_CONTAINS_ICMP_DATA; - pxNetworkBuffer->xDataLength = xNumberOfBytesToSend + sizeof( ICMPHeader_t ); - - /* Send to the stack. */ - xStackTxEvent.pvData = pxNetworkBuffer; - - if( xSendEventStructToIPTask( &xStackTxEvent, xBlockTimeTicks) != pdPASS ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - iptraceSTACK_TX_EVENT_LOST( ipSTACK_TX_EVENT ); - } - else - { - xReturn = usSequenceNumber; - } - } - } - else - { - /* The requested number of bytes will not fit in the available space - in the network buffer. */ - } - - return xReturn; - } - -#endif /* ipconfigSUPPORT_OUTGOING_PINGS == 1 */ -/*-----------------------------------------------------------*/ - -BaseType_t xSendEventToIPTask( eIPEvent_t eEvent ) -{ -IPStackEvent_t xEventMessage; -const TickType_t xDontBlock = ( TickType_t ) 0; - - xEventMessage.eEventType = eEvent; - xEventMessage.pvData = ( void* )NULL; - - return xSendEventStructToIPTask( &xEventMessage, xDontBlock ); -} -/*-----------------------------------------------------------*/ - -BaseType_t xSendEventStructToIPTask( const IPStackEvent_t *pxEvent, TickType_t xTimeout ) -{ -BaseType_t xReturn, xSendMessage; - - if( ( xIPIsNetworkTaskReady() == pdFALSE ) && ( pxEvent->eEventType != eNetworkDownEvent ) ) - { - /* Only allow eNetworkDownEvent events if the IP task is not ready - yet. Not going to attempt to send the message so the send failed. */ - xReturn = pdFAIL; - } - else - { - xSendMessage = pdTRUE; - - #if( ipconfigUSE_TCP == 1 ) - { - if( pxEvent->eEventType == eTCPTimerEvent ) - { - /* TCP timer events are sent to wake the timer task when - xTCPTimer has expired, but there is no point sending them if the - IP task is already awake processing other message. */ - xTCPTimer.bExpired = pdTRUE_UNSIGNED; - - if( uxQueueMessagesWaiting( xNetworkEventQueue ) != 0u ) - { - /* Not actually going to send the message but this is not a - failure as the message didn't need to be sent. */ - xSendMessage = pdFALSE; - } - } - } - #endif /* ipconfigUSE_TCP */ - - if( xSendMessage != pdFALSE ) - { - /* The IP task cannot block itself while waiting for itself to - respond. */ - if( ( xIsCallingFromIPTask() == pdTRUE ) && ( xTimeout > ( TickType_t ) 0 ) ) - { - xTimeout = ( TickType_t ) 0; - } - - xReturn = xQueueSendToBack( xNetworkEventQueue, pxEvent, xTimeout ); - - if( xReturn == pdFAIL ) - { - /* A message should have been sent to the IP task, but wasn't. */ - FreeRTOS_debug_printf( ( "xSendEventStructToIPTask: CAN NOT ADD %d\n", pxEvent->eEventType ) ); - iptraceSTACK_TX_EVENT_LOST( pxEvent->eEventType ); - } - } - else - { - /* It was not necessary to send the message to process the event so - even though the message was not sent the call was successful. */ - xReturn = pdPASS; - } - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucEthernetBuffer ) -{ -eFrameProcessingResult_t eReturn; -const EthernetHeader_t *pxEthernetHeader; - - pxEthernetHeader = ( const EthernetHeader_t * ) pucEthernetBuffer; - - if( memcmp( ( void * ) ipLOCAL_MAC_ADDRESS, ( void * ) &( pxEthernetHeader->xDestinationAddress ), sizeof( MACAddress_t ) ) == 0 ) - { - /* The packet was directed to this node directly - process it. */ - eReturn = eProcessBuffer; - } - else if( memcmp( ( void * ) xBroadcastMACAddress.ucBytes, ( void * ) pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) - { - /* The packet was a broadcast - process it. */ - eReturn = eProcessBuffer; - } - else -#if( ipconfigUSE_LLMNR == 1 ) - if( memcmp( ( void * ) xLLMNR_MacAdress.ucBytes, ( void * ) pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) - { - /* The packet is a request for LLMNR - process it. */ - eReturn = eProcessBuffer; - } - else -#endif /* ipconfigUSE_LLMNR */ - { - /* The packet was not a broadcast, or for this node, just release - the buffer without taking any other action. */ - eReturn = eReleaseBuffer; - } - - #if( ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES == 1 ) - { - uint16_t usFrameType; - - if( eReturn == eProcessBuffer ) - { - usFrameType = pxEthernetHeader->usFrameType; - usFrameType = FreeRTOS_ntohs( usFrameType ); - - if( usFrameType <= 0x600U ) - { - /* Not an Ethernet II frame. */ - eReturn = eReleaseBuffer; - } - } - } - #endif /* ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES == 1 */ - - return eReturn; -} -/*-----------------------------------------------------------*/ - -static void prvProcessNetworkDownEvent( void ) -{ - /* Stop the ARP timer while there is no network. */ - xARPTimer.bActive = pdFALSE_UNSIGNED; - - #if ipconfigUSE_NETWORK_EVENT_HOOK == 1 - { - static BaseType_t xCallEventHook = pdFALSE; - - /* The first network down event is generated by the IP stack itself to - initialise the network hardware, so do not call the network down event - the first time through. */ - if( xCallEventHook == pdTRUE ) - { - vApplicationIPNetworkEventHook( eNetworkDown ); - } - xCallEventHook = pdTRUE; - } - #endif - - /* The network has been disconnected (or is being initialised for the first - time). Perform whatever hardware processing is necessary to bring it up - again, or wait for it to be available again. This is hardware dependent. */ - if( xNetworkInterfaceInitialise() != pdPASS ) - { - /* Ideally the network interface initialisation function will only - return when the network is available. In case this is not the case, - wait a while before retrying the initialisation. */ - vTaskDelay( ipINITIALISATION_RETRY_DELAY ); - FreeRTOS_NetworkDown(); - } - else - { - /* Set remaining time to 0 so it will become active immediately. */ - #if ipconfigUSE_DHCP == 1 - { - /* The network is not up until DHCP has completed. */ - vDHCPProcess( pdTRUE ); - xSendEventToIPTask( eDHCPEvent ); - } - #else - { - /* Perform any necessary 'network up' processing. */ - vIPNetworkUpCalls(); - } - #endif - } -} -/*-----------------------------------------------------------*/ - -void vIPNetworkUpCalls( void ) -{ - xNetworkUp = pdTRUE; - - #if( ipconfigUSE_NETWORK_EVENT_HOOK == 1 ) - { - vApplicationIPNetworkEventHook( eNetworkUp ); - } - #endif /* ipconfigUSE_NETWORK_EVENT_HOOK */ - - #if( ipconfigDNS_USE_CALLBACKS != 0 ) - { - /* The following function is declared in FreeRTOS_DNS.c and 'private' to - this library */ - extern void vDNSInitialise( void ); - vDNSInitialise(); - } - #endif /* ipconfigDNS_USE_CALLBACKS != 0 */ - - /* Set remaining time to 0 so it will become active immediately. */ - prvIPTimerReload( &xARPTimer, pdMS_TO_TICKS( ipARP_TIMER_PERIOD_MS ) ); -} -/*-----------------------------------------------------------*/ - -static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer ) -{ -EthernetHeader_t *pxEthernetHeader; -eFrameProcessingResult_t eReturned = eReleaseBuffer; - - configASSERT( pxNetworkBuffer ); - - /* Interpret the Ethernet frame. */ - if( pxNetworkBuffer->xDataLength >= sizeof( EthernetHeader_t ) ) - { - eReturned = ipCONSIDER_FRAME_FOR_PROCESSING( pxNetworkBuffer->pucEthernetBuffer ); - pxEthernetHeader = ( EthernetHeader_t * )( pxNetworkBuffer->pucEthernetBuffer ); - - if( eReturned == eProcessBuffer ) - { - /* Interpret the received Ethernet packet. */ - switch( pxEthernetHeader->usFrameType ) - { - case ipARP_FRAME_TYPE: - /* The Ethernet frame contains an ARP packet. */ - if( pxNetworkBuffer->xDataLength >= sizeof( ARPPacket_t ) ) - { - eReturned = eARPProcessPacket( ( ARPPacket_t * )pxNetworkBuffer->pucEthernetBuffer ); - } - else - { - eReturned = eReleaseBuffer; - } - break; - - case ipIPv4_FRAME_TYPE: - /* The Ethernet frame contains an IP packet. */ - if( pxNetworkBuffer->xDataLength >= sizeof( IPPacket_t ) ) - { - eReturned = prvProcessIPPacket( ( IPPacket_t * )pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer ); - } - else - { - eReturned = eReleaseBuffer; - } - break; - - default: - /* No other packet types are handled. Nothing to do. */ - eReturned = eReleaseBuffer; - break; - } - } - } - - /* Perform any actions that resulted from processing the Ethernet frame. */ - switch( eReturned ) - { - case eReturnEthernetFrame : - /* The Ethernet frame will have been updated (maybe it was - an ARP request or a PING request?) and should be sent back to - its source. */ - vReturnEthernetFrame( pxNetworkBuffer, pdTRUE ); - /* parameter pdTRUE: the buffer must be released once - the frame has been transmitted */ - break; - - case eFrameConsumed : - /* The frame is in use somewhere, don't release the buffer - yet. */ - break; - - default : - /* The frame is not being used anywhere, and the - NetworkBufferDescriptor_t structure containing the frame should - just be released back to the list of free buffers. */ - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - break; - } -} -/*-----------------------------------------------------------*/ - -static eFrameProcessingResult_t prvAllowIPPacket( const IPPacket_t * const pxIPPacket, - NetworkBufferDescriptor_t * const pxNetworkBuffer, UBaseType_t uxHeaderLength ) -{ -eFrameProcessingResult_t eReturn = eProcessBuffer; - -#if( ( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 0 ) || ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 0 ) ) - const IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); -#else - /* or else, the parameter won't be used and the function will be optimised - away */ - ( void ) pxIPPacket; -#endif - - #if( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 0 ) - { - /* In systems with a very small amount of RAM, it might be advantageous - to have incoming messages checked earlier, by the network card driver. - This method may decrease the usage of sparse network buffers. */ - uint32_t ulDestinationIPAddress = pxIPHeader->ulDestinationIPAddress; - - /* Ensure that the incoming packet is not fragmented (only outgoing - packets can be fragmented) as these are the only handled IP frames - currently. */ - if( ( pxIPHeader->usFragmentOffset & ipFRAGMENT_OFFSET_BIT_MASK ) != 0U ) - { - /* Can not handle, fragmented packet. */ - eReturn = eReleaseBuffer; - } - /* 0x45 means: IPv4 with an IP header of 5 x 4 = 20 bytes - * 0x47 means: IPv4 with an IP header of 7 x 4 = 28 bytes */ - else if( ( pxIPHeader->ucVersionHeaderLength < 0x45u ) || ( pxIPHeader->ucVersionHeaderLength > 0x4Fu ) ) - { - /* Can not handle, unknown or invalid header version. */ - eReturn = eReleaseBuffer; - } - /* Is the packet for this IP address? */ - else if( ( ulDestinationIPAddress != *ipLOCAL_IP_ADDRESS_POINTER ) && - /* Is it the global broadcast address 255.255.255.255 ? */ - ( ulDestinationIPAddress != ipBROADCAST_IP_ADDRESS ) && - /* Is it a specific broadcast address 192.168.1.255 ? */ - ( ulDestinationIPAddress != xNetworkAddressing.ulBroadcastAddress ) && - #if( ipconfigUSE_LLMNR == 1 ) - /* Is it the LLMNR multicast address? */ - ( ulDestinationIPAddress != ipLLMNR_IP_ADDR ) && - #endif - /* Or (during DHCP negotiation) we have no IP-address yet? */ - ( *ipLOCAL_IP_ADDRESS_POINTER != 0UL ) ) - { - /* Packet is not for this node, release it */ - eReturn = eReleaseBuffer; - } - } - #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ - - #if( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 0 ) - { - /* Some drivers of NIC's with checksum-offloading will enable the above - define, so that the checksum won't be checked again here */ - if (eReturn == eProcessBuffer ) - { - /* Is the IP header checksum correct? */ - if( ( pxIPHeader->ucProtocol != ( uint8_t ) ipPROTOCOL_ICMP ) && - ( usGenerateChecksum( 0UL, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ( size_t ) uxHeaderLength ) != ipCORRECT_CRC ) ) - { - /* Check sum in IP-header not correct. */ - eReturn = eReleaseBuffer; - } - /* Is the upper-layer checksum (TCP/UDP/ICMP) correct? */ - else if( usGenerateProtocolChecksum( ( uint8_t * )( pxNetworkBuffer->pucEthernetBuffer ), pxNetworkBuffer->xDataLength, pdFALSE ) != ipCORRECT_CRC ) - { - /* Protocol checksum not accepted. */ - eReturn = eReleaseBuffer; - } - } - } - #else - { - /* to avoid warning unused parameters */ - ( void ) pxNetworkBuffer; - ( void ) uxHeaderLength; - } - #endif /* ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 0 */ - - return eReturn; -} -/*-----------------------------------------------------------*/ - -static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * const pxIPPacket, NetworkBufferDescriptor_t * const pxNetworkBuffer ) -{ -eFrameProcessingResult_t eReturn; -IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); -UBaseType_t uxHeaderLength = ( UBaseType_t ) ( ( pxIPHeader->ucVersionHeaderLength & 0x0Fu ) << 2 ); -uint8_t ucProtocol; - - /* Bound the calculated header length: take away the Ethernet header size, - then check if the IP header is claiming to be longer than the remaining - total packet size. Also check for minimal header field length. */ - if( ( uxHeaderLength > ( pxNetworkBuffer->xDataLength - ipSIZE_OF_ETH_HEADER ) ) || - ( uxHeaderLength < ipSIZE_OF_IPv4_HEADER ) ) - { - return eReleaseBuffer; - } - - ucProtocol = pxIPPacket->xIPHeader.ucProtocol; - /* Check if the IP headers are acceptable and if it has our destination. */ - eReturn = prvAllowIPPacket( pxIPPacket, pxNetworkBuffer, uxHeaderLength ); - - if( eReturn == eProcessBuffer ) - { - if( uxHeaderLength > ipSIZE_OF_IPv4_HEADER ) - { - /* All structs of headers expect a IP header size of 20 bytes - * IP header options were included, we'll ignore them and cut them out - * Note: IP options are mostly use in Multi-cast protocols */ - const size_t optlen = ( ( size_t ) uxHeaderLength ) - ipSIZE_OF_IPv4_HEADER; - /* From: the previous start of UDP/ICMP/TCP data */ - uint8_t *pucSource = ( uint8_t* )(pxNetworkBuffer->pucEthernetBuffer + sizeof( EthernetHeader_t ) + uxHeaderLength); - /* To: the usual start of UDP/ICMP/TCP data at offset 20 from IP header */ - uint8_t *pucTarget = ( uint8_t* )(pxNetworkBuffer->pucEthernetBuffer + sizeof( EthernetHeader_t ) + ipSIZE_OF_IPv4_HEADER); - /* How many: total length minus the options and the lower headers */ - const size_t xMoveLen = pxNetworkBuffer->xDataLength - optlen - ipSIZE_OF_IPv4_HEADER - ipSIZE_OF_ETH_HEADER; - - memmove( pucTarget, pucSource, xMoveLen ); - pxNetworkBuffer->xDataLength -= optlen; - - /* Fix-up new version/header length field in IP packet. */ - pxIPHeader->ucVersionHeaderLength = ( pxIPHeader->ucVersionHeaderLength & 0xF0 ) | /* High nibble is the version. */ - ( ( ipSIZE_OF_IPv4_HEADER >> 2 ) & 0x0F ); /* Low nibble is the header size, in bytes, divided by four. */ - } - - /* Add the IP and MAC addresses to the ARP table if they are not - already there - otherwise refresh the age of the existing - entry. */ - if( ucProtocol != ( uint8_t ) ipPROTOCOL_UDP ) - { - /* Refresh the ARP cache with the IP/MAC-address of the received packet - * For UDP packets, this will be done later in xProcessReceivedUDPPacket() - * as soon as know that the message will be handled by someone - * This will prevent that the ARP cache will get overwritten - * with the IP-address of useless broadcast packets - */ - vARPRefreshCacheEntry( &( pxIPPacket->xEthernetHeader.xSourceAddress ), pxIPHeader->ulSourceIPAddress ); - } - switch( ucProtocol ) - { - case ipPROTOCOL_ICMP : - /* The IP packet contained an ICMP frame. Don't bother - checking the ICMP checksum, as if it is wrong then the - wrong data will also be returned, and the source of the - ping will know something went wrong because it will not - be able to validate what it receives. */ - #if ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) - { - if( pxNetworkBuffer->xDataLength >= sizeof( ICMPPacket_t ) ) - { - ICMPPacket_t *pxICMPPacket = ( ICMPPacket_t * )( pxNetworkBuffer->pucEthernetBuffer ); - if( pxIPHeader->ulDestinationIPAddress == *ipLOCAL_IP_ADDRESS_POINTER ) - { - eReturn = prvProcessICMPPacket( pxICMPPacket ); - } - } - else - { - eReturn = eReleaseBuffer; - } - } - #endif /* ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) */ - break; - - case ipPROTOCOL_UDP : - { - /* The IP packet contained a UDP frame. */ - UDPPacket_t *pxUDPPacket = ( UDPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuffer ); - - /* Only proceed if the payload length indicated in the header - appears to be valid. */ - if ( pxNetworkBuffer->xDataLength >= sizeof( UDPPacket_t ) ) - { - /* Ensure that downstream UDP packet handling has the lesser - * of: the actual network buffer Ethernet frame length, or - * the sender's UDP packet header payload length, minus the - * size of the UDP header. - * - * The size of the UDP packet structure in this implementation - * includes the size of the Ethernet header, the size of - * the IP header, and the size of the UDP header. - */ - - pxNetworkBuffer->xDataLength -= sizeof( UDPPacket_t ); - if( ( FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) - sizeof( UDPHeader_t ) ) < - pxNetworkBuffer->xDataLength ) - { - pxNetworkBuffer->xDataLength = FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) - sizeof( UDPHeader_t ); - } - - /* Fields in pxNetworkBuffer (usPort, ulIPAddress) are network order. */ - pxNetworkBuffer->usPort = pxUDPPacket->xUDPHeader.usSourcePort; - pxNetworkBuffer->ulIPAddress = pxUDPPacket->xIPHeader.ulSourceIPAddress; - - /* ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM: - * In some cases, the upper-layer checksum has been calculated - * by the NIC driver. - * - * Pass the packet payload to the UDP sockets implementation. */ - if( xProcessReceivedUDPPacket( pxNetworkBuffer, - pxUDPPacket->xUDPHeader.usDestinationPort ) == pdPASS ) - { - eReturn = eFrameConsumed; - } - } - else - { - eReturn = eReleaseBuffer; - } - } - break; - -#if ipconfigUSE_TCP == 1 - case ipPROTOCOL_TCP : - { - - if( xProcessReceivedTCPPacket( pxNetworkBuffer ) == pdPASS ) - { - eReturn = eFrameConsumed; - } - - /* Setting this variable will cause xTCPTimerCheck() - to be called just before the IP-task blocks. */ - xProcessedTCPMessage++; - } - break; -#endif - default : - /* Not a supported frame type. */ - break; - } - } - - return eReturn; -} -/*-----------------------------------------------------------*/ - -#if ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) - - static void prvProcessICMPEchoReply( ICMPPacket_t * const pxICMPPacket ) - { - ePingReplyStatus_t eStatus = eSuccess; - uint16_t usDataLength, usCount; - uint8_t *pucByte; - - /* Find the total length of the IP packet. */ - usDataLength = pxICMPPacket->xIPHeader.usLength; - usDataLength = FreeRTOS_ntohs( usDataLength ); - - /* Remove the length of the IP headers to obtain the length of the ICMP - message itself. */ - usDataLength = ( uint16_t ) ( ( ( uint32_t ) usDataLength ) - ipSIZE_OF_IPv4_HEADER ); - - /* Remove the length of the ICMP header, to obtain the length of - data contained in the ping. */ - usDataLength = ( uint16_t ) ( ( ( uint32_t ) usDataLength ) - ipSIZE_OF_ICMP_HEADER ); - - /* Checksum has already been checked before in prvProcessIPPacket */ - - /* Find the first byte of the data within the ICMP packet. */ - pucByte = ( uint8_t * ) pxICMPPacket; - pucByte += sizeof( ICMPPacket_t ); - - /* Check each byte. */ - for( usCount = 0; usCount < usDataLength; usCount++ ) - { - if( *pucByte != ipECHO_DATA_FILL_BYTE ) - { - eStatus = eInvalidData; - break; - } - - pucByte++; - } - - /* Call back into the application to pass it the result. */ - vApplicationPingReplyHook( eStatus, pxICMPPacket->xICMPHeader.usIdentifier ); - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) - - static eFrameProcessingResult_t prvProcessICMPEchoRequest( ICMPPacket_t * const pxICMPPacket ) - { - ICMPHeader_t *pxICMPHeader; - IPHeader_t *pxIPHeader; - uint16_t usRequest; - - pxICMPHeader = &( pxICMPPacket->xICMPHeader ); - pxIPHeader = &( pxICMPPacket->xIPHeader ); - - /* HT:endian: changed back */ - iptraceSENDING_PING_REPLY( pxIPHeader->ulSourceIPAddress ); - - /* The checksum can be checked here - but a ping reply should be - returned even if the checksum is incorrect so the other end can - tell that the ping was received - even if the ping reply contains - invalid data. */ - pxICMPHeader->ucTypeOfMessage = ( uint8_t ) ipICMP_ECHO_REPLY; - pxIPHeader->ulDestinationIPAddress = pxIPHeader->ulSourceIPAddress; - pxIPHeader->ulSourceIPAddress = *ipLOCAL_IP_ADDRESS_POINTER; - - /* Update the checksum because the ucTypeOfMessage member in the header - has been changed to ipICMP_ECHO_REPLY. This is faster than calling - usGenerateChecksum(). */ - - /* due to compiler warning "integer operation result is out of range" */ - - usRequest = ( uint16_t ) ( ( uint16_t )ipICMP_ECHO_REQUEST << 8 ); - - if( pxICMPHeader->usChecksum >= FreeRTOS_htons( 0xFFFFu - usRequest ) ) - { - pxICMPHeader->usChecksum = ( uint16_t ) - ( ( ( uint32_t ) pxICMPHeader->usChecksum ) + - FreeRTOS_htons( usRequest + 1UL ) ); - } - else - { - pxICMPHeader->usChecksum = ( uint16_t ) - ( ( ( uint32_t ) pxICMPHeader->usChecksum ) + - FreeRTOS_htons( usRequest ) ); - } - return eReturnEthernetFrame; - } - -#endif /* ipconfigREPLY_TO_INCOMING_PINGS == 1 */ -/*-----------------------------------------------------------*/ - -#if ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) - - static eFrameProcessingResult_t prvProcessICMPPacket( ICMPPacket_t * const pxICMPPacket ) - { - eFrameProcessingResult_t eReturn = eReleaseBuffer; - - iptraceICMP_PACKET_RECEIVED(); - switch( pxICMPPacket->xICMPHeader.ucTypeOfMessage ) - { - case ipICMP_ECHO_REQUEST : - #if ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) - { - eReturn = prvProcessICMPEchoRequest( pxICMPPacket ); - } - #endif /* ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) */ - break; - - case ipICMP_ECHO_REPLY : - #if ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) - { - prvProcessICMPEchoReply( pxICMPPacket ); - } - #endif /* ipconfigSUPPORT_OUTGOING_PINGS */ - break; - - default : - break; - } - - return eReturn; - } - -#endif /* ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) */ -/*-----------------------------------------------------------*/ - -uint16_t usGenerateProtocolChecksum( const uint8_t * const pucEthernetBuffer, size_t uxBufferLength, BaseType_t xOutgoingPacket ) -{ -uint32_t ulLength; -uint16_t usChecksum, *pusChecksum; -const IPPacket_t * pxIPPacket; -UBaseType_t uxIPHeaderLength; -ProtocolPacket_t *pxProtPack; -uint8_t ucProtocol; -#if( ipconfigHAS_DEBUG_PRINTF != 0 ) - const char *pcType; -#endif - - /* Check for minimum packet size. */ - if( uxBufferLength < sizeof( IPPacket_t ) ) - { - return ipINVALID_LENGTH; - } - - /* Parse the packet length. */ - pxIPPacket = ( const IPPacket_t * ) pucEthernetBuffer; - - /* Per https://tools.ietf.org/html/rfc791, the four-bit Internet Header - Length field contains the length of the internet header in 32-bit words. */ - uxIPHeaderLength = ( UBaseType_t ) ( sizeof( uint32_t ) * ( pxIPPacket->xIPHeader.ucVersionHeaderLength & 0x0Fu ) ); - - /* Check for minimum packet size. */ - if( uxBufferLength < sizeof( IPPacket_t ) + uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER ) - { - return ipINVALID_LENGTH; - } - if( uxBufferLength < FreeRTOS_ntohs( pxIPPacket->xIPHeader.usLength ) ) - { - return ipINVALID_LENGTH; - } - - /* Identify the next protocol. */ - ucProtocol = pxIPPacket->xIPHeader.ucProtocol; - - /* N.B., if this IP packet header includes Options, then the following - assignment results in a pointer into the protocol packet with the Ethernet - and IP headers incorrectly aligned. However, either way, the "third" - protocol (Layer 3 or 4) header will be aligned, which is the convenience - of this calculation. */ - pxProtPack = ( ProtocolPacket_t * ) ( pucEthernetBuffer + ( uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER ) ); - - /* Switch on the Layer 3/4 protocol. */ - if( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) - { - if( uxBufferLength < ( uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_UDP_HEADER ) ) - { - return ipINVALID_LENGTH; - } - - pusChecksum = ( uint16_t * ) ( &( pxProtPack->xUDPPacket.xUDPHeader.usChecksum ) ); - #if( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - pcType = "UDP"; - } - #endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ - } - else if( ucProtocol == ( uint8_t ) ipPROTOCOL_TCP ) - { - if( uxBufferLength < ( uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_TCP_HEADER ) ) - { - return ipINVALID_LENGTH; - } - - pusChecksum = ( uint16_t * ) ( &( pxProtPack->xTCPPacket.xTCPHeader.usChecksum ) ); - #if( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - pcType = "TCP"; - } - #endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ - } - else if( ( ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) || - ( ucProtocol == ( uint8_t ) ipPROTOCOL_IGMP ) ) - { - if( uxBufferLength < ( uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_ICMP_HEADER ) ) - { - return ipINVALID_LENGTH; - } - - pusChecksum = ( uint16_t * ) ( &( pxProtPack->xICMPPacket.xICMPHeader.usChecksum ) ); - #if( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - if( ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) - { - pcType = "ICMP"; - } - else - { - pcType = "IGMP"; - } - } - #endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ - } - else - { - /* Unhandled protocol, other than ICMP, IGMP, UDP, or TCP. */ - return ipUNHANDLED_PROTOCOL; - } - - /* The protocol and checksum field have been identified. Check the direction - of the packet. */ - if( xOutgoingPacket != pdFALSE ) - { - /* This is an outgoing packet. Before calculating the checksum, set it - to zero. */ - *( pusChecksum ) = 0u; - } - else if( ( *pusChecksum == 0u ) && ( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) ) - { - /* Sender hasn't set the checksum, no use to calculate it. */ - return ipCORRECT_CRC; - } - - ulLength = ( uint32_t ) - ( FreeRTOS_ntohs( pxIPPacket->xIPHeader.usLength ) - ( ( uint16_t ) uxIPHeaderLength ) ); /* normally minus 20 */ - - if( ( ulLength < sizeof( pxProtPack->xUDPPacket.xUDPHeader ) ) || - ( ulLength > ( uint32_t )( ipconfigNETWORK_MTU - uxIPHeaderLength ) ) ) - { - #if( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - FreeRTOS_debug_printf( ( "usGenerateProtocolChecksum[%s]: len invalid: %lu\n", pcType, ulLength ) ); - } - #endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ - - /* Again, in a 16-bit return value there is no space to indicate an - error. For incoming packets, 0x1234 will cause dropping of the packet. - For outgoing packets, there is a serious problem with the - format/length */ - return ipINVALID_LENGTH; - } - if( ucProtocol <= ( uint8_t ) ipPROTOCOL_IGMP ) - { - /* ICMP/IGMP do not have a pseudo header for CRC-calculation. */ - usChecksum = ( uint16_t ) - ( ~usGenerateChecksum( 0UL, - ( uint8_t * ) &( pxProtPack->xTCPPacket.xTCPHeader ), ( size_t ) ulLength ) ); - } - else - { - /* For UDP and TCP, sum the pseudo header, i.e. IP protocol + length - fields */ - usChecksum = ( uint16_t ) ( ulLength + ( ( uint16_t ) ucProtocol ) ); - - /* And then continue at the IPv4 source and destination addresses. */ - usChecksum = ( uint16_t ) - ( ~usGenerateChecksum( ( uint32_t ) usChecksum, ( uint8_t * )&( pxIPPacket->xIPHeader.ulSourceIPAddress ), - ( 2u * sizeof( pxIPPacket->xIPHeader.ulSourceIPAddress ) + ulLength ) ) ); - - /* Sum TCP header and data. */ - } - - if( xOutgoingPacket == pdFALSE ) - { - /* This is in incoming packet. If the CRC is correct, it should be zero. */ - if( usChecksum == 0u ) - { - usChecksum = ( uint16_t )ipCORRECT_CRC; - } - } - else - { - if( ( usChecksum == 0u ) && ( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) ) - { - /* In case of UDP, a calculated checksum of 0x0000 is transmitted - as 0xffff. A value of zero would mean that the checksum is not used. */ - #if( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - if( xOutgoingPacket != pdFALSE ) - { - FreeRTOS_debug_printf( ( "usGenerateProtocolChecksum[%s]: crc swap: %04X\n", pcType, usChecksum ) ); - } - } - #endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ - - usChecksum = ( uint16_t )0xffffu; - } - } - usChecksum = FreeRTOS_htons( usChecksum ); - - if( xOutgoingPacket != pdFALSE ) - { - *( pusChecksum ) = usChecksum; - } - #if( ipconfigHAS_DEBUG_PRINTF != 0 ) - else if( ( xOutgoingPacket == pdFALSE ) && ( usChecksum != ipCORRECT_CRC ) ) - { - FreeRTOS_debug_printf( ( "usGenerateProtocolChecksum[%s]: ID %04X: from %lxip to %lxip bad crc: %04X\n", - pcType, - FreeRTOS_ntohs( pxIPPacket->xIPHeader.usIdentification ), - FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulSourceIPAddress ), - FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulDestinationIPAddress ), - FreeRTOS_ntohs( *pusChecksum ) ) ); - } - #endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ - - return usChecksum; -} -/*-----------------------------------------------------------*/ - -/** - * This method generates a checksum for a given IPv4 header, per RFC791 (page 14). - * The checksum algorithm is decribed as: - * "[T]he 16 bit one's complement of the one's complement sum of all 16 bit words in the - * header. For purposes of computing the checksum, the value of the checksum field is zero." - * - * In a nutshell, that means that each 16-bit 'word' must be summed, after which - * the number of 'carries' (overflows) is added to the result. If that addition - * produces an overflow, that 'carry' must also be added to the final result. The final checksum - * should be the bitwise 'not' (ones-complement) of the result if the packet is - * meant to be transmitted, but this method simply returns the raw value, probably - * because when a packet is received, the checksum is verified by checking that - * ((received & calculated) == 0) without applying a bitwise 'not' to the 'calculated' checksum. - * - * This logic is optimized for microcontrollers which have limited resources, so the logic looks odd. - * It iterates over the full range of 16-bit words, but it does so by processing several 32-bit - * words at once whenever possible. Its first step is to align the memory pointer to a 32-bit boundary, - * after which it runs a fast loop to process multiple 32-bit words at once and adding their 'carries'. - * Finally, it finishes up by processing any remaining 16-bit words, and adding up all of the 'carries'. - * With 32-bit arithmetic, the number of 16-bit 'carries' produced by sequential additions can be found - * by looking at the 16 most-significant bits of the 32-bit integer, since a 32-bit int will continue - * counting up instead of overflowing after 16 bits. That is why the actual checksum calculations look like: - * union.u32 = ( uint32_t ) union.u16[ 0 ] + union.u16[ 1 ]; - * - * Arguments: - * ulSum: This argument provides a value to initialize the progressive summation - * of the header's values to. It is often 0, but protocols like TCP or UDP - * can have pseudo-header fields which need to be included in the checksum. - * pucNextData: This argument contains the address of the first byte which this - * method should process. The method's memory iterator is initialized to this value. - * uxDataLengthBytes: This argument contains the number of bytes that this method - * should process. - */ -uint16_t usGenerateChecksum( uint32_t ulSum, const uint8_t * pucNextData, size_t uxDataLengthBytes ) -{ -xUnion32 xSum2, xSum, xTerm; -xUnionPtr xSource; /* Points to first byte */ -xUnionPtr xLastSource; /* Points to last byte plus one */ -uint32_t ulAlignBits, ulCarry = 0ul; - - /* Small MCUs often spend up to 30% of the time doing checksum calculations - This function is optimised for 32-bit CPUs; Each time it will try to fetch - 32-bits, sums it with an accumulator and counts the number of carries. */ - - /* Swap the input (little endian platform only). */ - xSum.u32 = FreeRTOS_ntohs( ulSum ); - xTerm.u32 = 0ul; - - xSource.u8ptr = ( uint8_t * ) pucNextData; - ulAlignBits = ( ( ( uint32_t ) pucNextData ) & 0x03u ); /* gives 0, 1, 2, or 3 */ - - /* If byte (8-bit) aligned... */ - if( ( ( ulAlignBits & 1ul ) != 0ul ) && ( uxDataLengthBytes >= ( size_t ) 1 ) ) - { - xTerm.u8[ 1 ] = *( xSource.u8ptr ); - ( xSource.u8ptr )++; - uxDataLengthBytes--; - /* Now xSource is word (16-bit) aligned. */ - } - - /* If half-word (16-bit) aligned... */ - if( ( ( ulAlignBits == 1u ) || ( ulAlignBits == 2u ) ) && ( uxDataLengthBytes >= 2u ) ) - { - xSum.u32 += *(xSource.u16ptr); - ( xSource.u16ptr )++; - uxDataLengthBytes -= 2u; - /* Now xSource is word (32-bit) aligned. */ - } - - /* Word (32-bit) aligned, do the most part. */ - xLastSource.u32ptr = ( xSource.u32ptr + ( uxDataLengthBytes / 4u ) ) - 3u; - - /* In this loop, four 32-bit additions will be done, in total 16 bytes. - Indexing with constants (0,1,2,3) gives faster code than using - post-increments. */ - while( xSource.u32ptr < xLastSource.u32ptr ) - { - /* Use a secondary Sum2, just to see if the addition produced an - overflow. */ - xSum2.u32 = xSum.u32 + xSource.u32ptr[ 0 ]; - if( xSum2.u32 < xSum.u32 ) - { - ulCarry++; - } - - /* Now add the secondary sum to the major sum, and remember if there was - a carry. */ - xSum.u32 = xSum2.u32 + xSource.u32ptr[ 1 ]; - if( xSum2.u32 > xSum.u32 ) - { - ulCarry++; - } - - /* And do the same trick once again for indexes 2 and 3 */ - xSum2.u32 = xSum.u32 + xSource.u32ptr[ 2 ]; - if( xSum2.u32 < xSum.u32 ) - { - ulCarry++; - } - - xSum.u32 = xSum2.u32 + xSource.u32ptr[ 3 ]; - - if( xSum2.u32 > xSum.u32 ) - { - ulCarry++; - } - - /* And finally advance the pointer 4 * 4 = 16 bytes. */ - xSource.u32ptr += 4; - } - - /* Now add all carries. */ - xSum.u32 = ( uint32_t )xSum.u16[ 0 ] + xSum.u16[ 1 ] + ulCarry; - - uxDataLengthBytes %= 16u; - xLastSource.u8ptr = ( uint8_t * ) ( xSource.u8ptr + ( uxDataLengthBytes & ~( ( size_t ) 1 ) ) ); - - /* Half-word aligned. */ - while( xSource.u16ptr < xLastSource.u16ptr ) - { - /* At least one more short. */ - xSum.u32 += xSource.u16ptr[ 0 ]; - xSource.u16ptr++; - } - - if( ( uxDataLengthBytes & ( size_t ) 1 ) != 0u ) /* Maybe one more ? */ - { - xTerm.u8[ 0 ] = xSource.u8ptr[ 0 ]; - } - xSum.u32 += xTerm.u32; - - /* Now add all carries again. */ - xSum.u32 = ( uint32_t ) xSum.u16[ 0 ] + xSum.u16[ 1 ]; - - /* The previous summation might have given a 16-bit carry. */ - xSum.u32 = ( uint32_t ) xSum.u16[ 0 ] + xSum.u16[ 1 ]; - - if( ( ulAlignBits & 1u ) != 0u ) - { - /* Quite unlikely, but pucNextData might be non-aligned, which would - mean that a checksum is calculated starting at an odd position. */ - xSum.u32 = ( ( xSum.u32 & 0xffu ) << 8 ) | ( ( xSum.u32 & 0xff00u ) >> 8 ); - } - - /* swap the output (little endian platform only). */ - return FreeRTOS_htons( ( (uint16_t) xSum.u32 ) ); -} -/*-----------------------------------------------------------*/ - -void vReturnEthernetFrame( NetworkBufferDescriptor_t * pxNetworkBuffer, BaseType_t xReleaseAfterSend ) -{ -EthernetHeader_t *pxEthernetHeader; - -#if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - NetworkBufferDescriptor_t *pxNewBuffer; -#endif - - #if defined( ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - { - if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - { - BaseType_t xIndex; - - FreeRTOS_printf( ( "vReturnEthernetFrame: length %lu\n", ( uint32_t )pxNetworkBuffer->xDataLength ) ); - for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) - { - pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0u; - } - pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; - } - } - #endif - -#if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - - if( xReleaseAfterSend == pdFALSE ) - { - pxNewBuffer = pxDuplicateNetworkBufferWithDescriptor( pxNetworkBuffer, ( BaseType_t ) pxNetworkBuffer->xDataLength ); - xReleaseAfterSend = pdTRUE; - pxNetworkBuffer = pxNewBuffer; - } - - if( pxNetworkBuffer != NULL ) -#endif - { - pxEthernetHeader = ( EthernetHeader_t * ) ( pxNetworkBuffer->pucEthernetBuffer ); - - /* Swap source and destination MAC addresses. */ - memcpy( ( void * ) &( pxEthernetHeader->xDestinationAddress ), ( void * ) &( pxEthernetHeader->xSourceAddress ), sizeof( pxEthernetHeader->xDestinationAddress ) ); - memcpy( ( void * ) &( pxEthernetHeader->xSourceAddress) , ( void * ) ipLOCAL_MAC_ADDRESS, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); - - /* Send! */ - xNetworkInterfaceOutput( pxNetworkBuffer, xReleaseAfterSend ); - } -} -/*-----------------------------------------------------------*/ - -uint32_t FreeRTOS_GetIPAddress( void ) -{ - /* Returns the IP address of the NIC. */ - return *ipLOCAL_IP_ADDRESS_POINTER; -} -/*-----------------------------------------------------------*/ - -void FreeRTOS_SetIPAddress( uint32_t ulIPAddress ) -{ - /* Sets the IP address of the NIC. */ - *ipLOCAL_IP_ADDRESS_POINTER = ulIPAddress; -} -/*-----------------------------------------------------------*/ - -uint32_t FreeRTOS_GetGatewayAddress( void ) -{ - return xNetworkAddressing.ulGatewayAddress; -} -/*-----------------------------------------------------------*/ - -uint32_t FreeRTOS_GetDNSServerAddress( void ) -{ - return xNetworkAddressing.ulDNSServerAddress; -} -/*-----------------------------------------------------------*/ - -uint32_t FreeRTOS_GetNetmask( void ) -{ - return xNetworkAddressing.ulNetMask; -} -/*-----------------------------------------------------------*/ - -void FreeRTOS_UpdateMACAddress( const uint8_t ucMACAddress[ipMAC_ADDRESS_LENGTH_BYTES] ) -{ - /* Copy the MAC address at the start of the default packet header fragment. */ - memcpy( ( void * )ipLOCAL_MAC_ADDRESS, ( void * )ucMACAddress, ( size_t )ipMAC_ADDRESS_LENGTH_BYTES ); -} -/*-----------------------------------------------------------*/ - -const uint8_t * FreeRTOS_GetMACAddress( void ) -{ - return ipLOCAL_MAC_ADDRESS; -} -/*-----------------------------------------------------------*/ - -void FreeRTOS_SetNetmask ( uint32_t ulNetmask ) -{ - xNetworkAddressing.ulNetMask = ulNetmask; -} -/*-----------------------------------------------------------*/ - -void FreeRTOS_SetGatewayAddress ( uint32_t ulGatewayAddress ) -{ - xNetworkAddressing.ulGatewayAddress = ulGatewayAddress; -} -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_DHCP == 1 ) - void vIPSetDHCPTimerEnableState( BaseType_t xEnableState ) - { - if( xEnableState != pdFALSE ) - { - xDHCPTimer.bActive = pdTRUE_UNSIGNED; - } - else - { - xDHCPTimer.bActive = pdFALSE_UNSIGNED; - } - } -#endif /* ipconfigUSE_DHCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_DHCP == 1 ) - void vIPReloadDHCPTimer( uint32_t ulLeaseTime ) - { - prvIPTimerReload( &xDHCPTimer, ulLeaseTime ); - } -#endif /* ipconfigUSE_DHCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigDNS_USE_CALLBACKS == 1 ) - void vIPSetDnsTimerEnableState( BaseType_t xEnableState ) - { - if( xEnableState != 0 ) - { - xDNSTimer.bActive = pdTRUE; - } - else - { - xDNSTimer.bActive = pdFALSE; - } - } -#endif /* ipconfigUSE_DHCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigDNS_USE_CALLBACKS != 0 ) - void vIPReloadDNSTimer( uint32_t ulCheckTime ) - { - prvIPTimerReload( &xDNSTimer, ulCheckTime ); - } -#endif /* ipconfigDNS_USE_CALLBACKS != 0 */ -/*-----------------------------------------------------------*/ - -BaseType_t xIPIsNetworkTaskReady( void ) -{ - return xIPTaskInitialised; -} -/*-----------------------------------------------------------*/ - -BaseType_t FreeRTOS_IsNetworkUp( void ) -{ - return xNetworkUp; -} -/*-----------------------------------------------------------*/ - -#if( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - UBaseType_t uxGetMinimumIPQueueSpace( void ) - { - return uxQueueMinimumSpace; - } -#endif -/*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c deleted file mode 100755 index d6b05ac..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c +++ /dev/null @@ -1,3632 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -/* Standard includes. */ -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "FreeRTOS_DNS.h" -#include "NetworkBufferManagement.h" - -/* The ItemValue of the sockets xBoundSocketListItem member holds the socket's -port number. */ -#define socketSET_SOCKET_PORT( pxSocket, usPort ) listSET_LIST_ITEM_VALUE( ( &( ( pxSocket )->xBoundSocketListItem ) ), ( usPort ) ) -#define socketGET_SOCKET_PORT( pxSocket ) listGET_LIST_ITEM_VALUE( ( &( ( pxSocket )->xBoundSocketListItem ) ) ) - -/* Test if a socket it bound which means it is either included in -xBoundUDPSocketsList or xBoundTCPSocketsList */ -#define socketSOCKET_IS_BOUND( pxSocket ) ( listLIST_ITEM_CONTAINER( & ( pxSocket )->xBoundSocketListItem ) != NULL ) - -/* If FreeRTOS_sendto() is called on a socket that is not bound to a port -number then, depending on the FreeRTOSIPConfig.h settings, it might be that a -port number is automatically generated for the socket. Automatically generated -port numbers will be between socketAUTO_PORT_ALLOCATION_START_NUMBER and -0xffff. - -Per https://tools.ietf.org/html/rfc6056, "the dynamic ports consist of the range -49152-65535. However, ephemeral port selection algorithms should use the whole -range 1024-65535" excluding those already in use (inbound or outbound). */ -#if !defined( socketAUTO_PORT_ALLOCATION_START_NUMBER ) - #define socketAUTO_PORT_ALLOCATION_START_NUMBER ( ( uint16_t ) 0x0400 ) -#endif - -#define socketAUTO_PORT_ALLOCATION_MAX_NUMBER ( ( uint16_t ) 0xffff ) - -/* The number of octets that make up an IP address. */ -#define socketMAX_IP_ADDRESS_OCTETS 4u - -/* A block time of 0 simply means "don't block". */ -#define socketDONT_BLOCK ( ( TickType_t ) 0 ) - -#if( ( ipconfigUSE_TCP == 1 ) && !defined( ipTCP_TIMER_PERIOD_MS ) ) - #define ipTCP_TIMER_PERIOD_MS ( 1000 ) -#endif - -/* The next private port number to use when binding a client socket is stored in -the usNextPortToUse[] array - which has either 1 or two indexes depending on -whether TCP is being supported. */ -#if( ipconfigUSE_TCP == 1 ) - #define socketPROTOCOL_COUNT 2 -#else - #define socketPROTOCOL_COUNT 1 -#endif - -/* Indexes into the usNextPortToUse[] array for UDP and TCP sockets -respectively. */ -#define socketNEXT_UDP_PORT_NUMBER_INDEX 0 -#define socketNEXT_TCP_PORT_NUMBER_INDEX 1 - - -/*-----------------------------------------------------------*/ - -/* - * Allocate the next port number from the private allocation range. - * TCP and UDP each have their own series of port numbers - * ulProtocol is either ipPROTOCOL_UDP or ipPROTOCOL_TCP - */ -static uint16_t prvGetPrivatePortNumber( BaseType_t xProtocol ); - -/* - * Return the list item from within pxList that has an item value of - * xWantedItemValue. If there is no such list item return NULL. - */ -static const ListItem_t * pxListFindListItemWithValue( const List_t *pxList, TickType_t xWantedItemValue ); - -/* - * Return pdTRUE only if pxSocket is valid and bound, as far as can be - * determined. - */ -static BaseType_t prvValidSocket( FreeRTOS_Socket_t *pxSocket, BaseType_t xProtocol, BaseType_t xIsBound ); - -/* - * Before creating a socket, check the validity of the parameters used - * and find the size of the socket space, which is different for UDP and TCP - */ -static BaseType_t prvDetermineSocketSize( BaseType_t xDomain, BaseType_t xType, BaseType_t xProtocol, size_t *pxSocketSize ); - -#if( ipconfigUSE_TCP == 1 ) - /* - * Create a txStream or a rxStream, depending on the parameter 'xIsInputStream' - */ - static StreamBuffer_t *prvTCPCreateStream (FreeRTOS_Socket_t *pxSocket, BaseType_t xIsInputStream ); -#endif /* ipconfigUSE_TCP == 1 */ - -#if( ipconfigUSE_TCP == 1 ) - /* - * Called from FreeRTOS_send(): some checks which will be done before - * sending a TCP packed. - */ - static int32_t prvTCPSendCheck( FreeRTOS_Socket_t *pxSocket, size_t xDataLength ); -#endif /* ipconfigUSE_TCP */ - -#if( ipconfigUSE_TCP == 1 ) - /* - * When a child socket gets closed, make sure to update the child-count of the parent - */ - static void prvTCPSetSocketCount( FreeRTOS_Socket_t *pxSocketToDelete ); -#endif /* ipconfigUSE_TCP == 1 */ - -#if( ipconfigUSE_TCP == 1 ) - /* - * Called from FreeRTOS_connect(): make some checks and if allowed, send a - * message to the IP-task to start connecting to a remote socket - */ - static BaseType_t prvTCPConnectStart( FreeRTOS_Socket_t *pxSocket, struct freertos_sockaddr *pxAddress ); -#endif /* ipconfigUSE_TCP */ - -#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - - /* Executed by the IP-task, it will check all sockets belonging to a set */ - static FreeRTOS_Socket_t *prvFindSelectedSocket( SocketSelect_t *pxSocketSet ); - -#endif /* ipconfigSUPPORT_SELECT_FUNCTION == 1 */ -/*-----------------------------------------------------------*/ - -/* The list that contains mappings between sockets and port numbers. Accesses -to this list must be protected by critical sections of one kind or another. */ -List_t xBoundUDPSocketsList; - -#if ipconfigUSE_TCP == 1 - List_t xBoundTCPSocketsList; -#endif /* ipconfigUSE_TCP == 1 */ - -/*-----------------------------------------------------------*/ - -static BaseType_t prvValidSocket( FreeRTOS_Socket_t *pxSocket, BaseType_t xProtocol, BaseType_t xIsBound ) -{ -BaseType_t xReturn = pdTRUE; - - if( ( pxSocket == NULL ) || ( pxSocket == FREERTOS_INVALID_SOCKET ) ) - { - xReturn = pdFALSE; - } - else if( ( xIsBound != pdFALSE ) && ( socketSOCKET_IS_BOUND( pxSocket ) == pdFALSE ) ) - { - /* The caller expects the socket to be bound, but it isn't. */ - xReturn = pdFALSE; - } - else if( pxSocket->ucProtocol != ( uint8_t ) xProtocol ) - { - /* Socket has a wrong type (UDP != TCP). */ - xReturn = pdFALSE; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -BaseType_t vNetworkSocketsInit( void ) -{ - vListInitialise( &xBoundUDPSocketsList ); - - #if( ipconfigUSE_TCP == 1 ) - { - vListInitialise( &xBoundTCPSocketsList ); - } - #endif /* ipconfigUSE_TCP == 1 */ - - return pdTRUE; -} -/*-----------------------------------------------------------*/ - -static BaseType_t prvDetermineSocketSize( BaseType_t xDomain, BaseType_t xType, BaseType_t xProtocol, size_t *pxSocketSize ) -{ -BaseType_t xReturn = pdPASS; -FreeRTOS_Socket_t *pxSocket; - - /* Asserts must not appear before it has been determined that the network - task is ready - otherwise the asserts will fail. */ - if( xIPIsNetworkTaskReady() == pdFALSE ) - { - xReturn = pdFAIL; - } - else - { - /* Only Ethernet is currently supported. */ - configASSERT( xDomain == FREERTOS_AF_INET ); - - /* Check if the UDP socket-list has been initialised. */ - configASSERT( listLIST_IS_INITIALISED( &xBoundUDPSocketsList ) ); - #if( ipconfigUSE_TCP == 1 ) - { - /* Check if the TCP socket-list has been initialised. */ - configASSERT( listLIST_IS_INITIALISED( &xBoundTCPSocketsList ) ); - } - #endif /* ipconfigUSE_TCP == 1 */ - - if( xProtocol == FREERTOS_IPPROTO_UDP ) - { - if( xType != FREERTOS_SOCK_DGRAM ) - { - xReturn = pdFAIL; - configASSERT( xReturn ); - } - /* In case a UDP socket is created, do not allocate space for TCP data. */ - *pxSocketSize = ( sizeof( *pxSocket ) - sizeof( pxSocket->u ) ) + sizeof( pxSocket->u.xUDP ); - } -#if( ipconfigUSE_TCP == 1 ) - else if( xProtocol == FREERTOS_IPPROTO_TCP ) - { - if( xType != FREERTOS_SOCK_STREAM ) - { - xReturn = pdFAIL; - configASSERT( xReturn ); - } - - *pxSocketSize = ( sizeof( *pxSocket ) - sizeof( pxSocket->u ) ) + sizeof( pxSocket->u.xTCP ); - } -#endif /* ipconfigUSE_TCP == 1 */ - else - { - xReturn = pdFAIL; - configASSERT( xReturn ); - } - } - /* In case configASSERT() is not used */ - ( void )xDomain; - return xReturn; -} -/*-----------------------------------------------------------*/ - -/* FreeRTOS_socket() allocates and initiates a socket */ -Socket_t FreeRTOS_socket( BaseType_t xDomain, BaseType_t xType, BaseType_t xProtocol ) -{ -FreeRTOS_Socket_t *pxSocket; -size_t uxSocketSize; -EventGroupHandle_t xEventGroup; -Socket_t xReturn; - - if( prvDetermineSocketSize( xDomain, xType, xProtocol, &uxSocketSize ) == pdFAIL ) - { - xReturn = FREERTOS_INVALID_SOCKET; - } - else - { - /* Allocate the structure that will hold the socket information. The - size depends on the type of socket: UDP sockets need less space. A - define 'pvPortMallocSocket' will used to allocate the necessary space. - By default it points to the FreeRTOS function 'pvPortMalloc()'. */ - pxSocket = ( FreeRTOS_Socket_t * ) pvPortMallocSocket( uxSocketSize ); - - if( pxSocket == NULL ) - { - pxSocket = ( FreeRTOS_Socket_t * ) FREERTOS_INVALID_SOCKET; - iptraceFAILED_TO_CREATE_SOCKET(); - } - else if( ( xEventGroup = xEventGroupCreate() ) == NULL ) - { - vPortFreeSocket( pxSocket ); - pxSocket = ( FreeRTOS_Socket_t * ) FREERTOS_INVALID_SOCKET; - iptraceFAILED_TO_CREATE_EVENT_GROUP(); - } - else - { - /* Clear the entire space to avoid nulling individual entries */ - memset( pxSocket, '\0', uxSocketSize ); - - pxSocket->xEventGroup = xEventGroup; - - /* Initialise the socket's members. The semaphore will be created - if the socket is bound to an address, for now the pointer to the - semaphore is just set to NULL to show it has not been created. */ - if( xProtocol == FREERTOS_IPPROTO_UDP ) - { - vListInitialise( &( pxSocket->u.xUDP.xWaitingPacketsList ) ); - - #if( ipconfigUDP_MAX_RX_PACKETS > 0 ) - { - pxSocket->u.xUDP.uxMaxPackets = ( UBaseType_t ) ipconfigUDP_MAX_RX_PACKETS; - } - #endif /* ipconfigUDP_MAX_RX_PACKETS > 0 */ - } - - vListInitialiseItem( &( pxSocket->xBoundSocketListItem ) ); - listSET_LIST_ITEM_OWNER( &( pxSocket->xBoundSocketListItem ), ( void * ) pxSocket ); - - pxSocket->xReceiveBlockTime = ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME; - pxSocket->xSendBlockTime = ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME; - pxSocket->ucSocketOptions = ( uint8_t ) FREERTOS_SO_UDPCKSUM_OUT; - pxSocket->ucProtocol = ( uint8_t ) xProtocol; /* protocol: UDP or TCP */ - - #if( ipconfigUSE_TCP == 1 ) - { - if( xProtocol == FREERTOS_IPPROTO_TCP ) - { - /* StreamSize is expressed in number of bytes */ - /* Round up buffer sizes to nearest multiple of MSS */ - pxSocket->u.xTCP.usInitMSS = pxSocket->u.xTCP.usCurMSS = ipconfigTCP_MSS; - pxSocket->u.xTCP.uxRxStreamSize = ( size_t ) ipconfigTCP_RX_BUFFER_LENGTH; - pxSocket->u.xTCP.uxTxStreamSize = ( size_t ) FreeRTOS_round_up( ipconfigTCP_TX_BUFFER_LENGTH, ipconfigTCP_MSS ); - /* Use half of the buffer size of the TCP windows */ - #if ( ipconfigUSE_TCP_WIN == 1 ) - { - pxSocket->u.xTCP.uxRxWinSize = FreeRTOS_max_uint32( 1UL, ( uint32_t ) ( pxSocket->u.xTCP.uxRxStreamSize / 2 ) / ipconfigTCP_MSS ); - pxSocket->u.xTCP.uxTxWinSize = FreeRTOS_max_uint32( 1UL, ( uint32_t ) ( pxSocket->u.xTCP.uxTxStreamSize / 2 ) / ipconfigTCP_MSS ); - } - #else - { - pxSocket->u.xTCP.uxRxWinSize = 1u; - pxSocket->u.xTCP.uxTxWinSize = 1u; - } - #endif - /* The above values are just defaults, and can be overridden by - calling FreeRTOS_setsockopt(). No buffers will be allocated until a - socket is connected and data is exchanged. */ - } - } - #endif /* ipconfigUSE_TCP == 1 */ - } - - xReturn = ( Socket_t ) pxSocket; - } - - /* Remove compiler warnings in the case the configASSERT() is not defined. */ - ( void ) xDomain; - - return xReturn; -} -/*-----------------------------------------------------------*/ - -#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - - SocketSet_t FreeRTOS_CreateSocketSet( void ) - { - SocketSelect_t *pxSocketSet; - - pxSocketSet = ( SocketSelect_t * ) pvPortMalloc( sizeof( *pxSocketSet ) ); - - if( pxSocketSet != NULL ) - { - memset( pxSocketSet, '\0', sizeof( *pxSocketSet ) ); - pxSocketSet->xSelectGroup = xEventGroupCreate(); - - if( pxSocketSet->xSelectGroup == NULL ) - { - vPortFree( ( void* ) pxSocketSet ); - pxSocketSet = NULL; - } - } - - return ( SocketSet_t * ) pxSocketSet; - } - -#endif /* ipconfigSUPPORT_SELECT_FUNCTION == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - - void FreeRTOS_DeleteSocketSet( SocketSet_t xSocketSet ) - { - SocketSelect_t *pxSocketSet = ( SocketSelect_t*) xSocketSet; - - vEventGroupDelete( pxSocketSet->xSelectGroup ); - vPortFree( ( void* ) pxSocketSet ); - } - -#endif /* ipconfigSUPPORT_SELECT_FUNCTION == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - - /* Add a socket to a set */ - void FreeRTOS_FD_SET( Socket_t xSocket, SocketSet_t xSocketSet, EventBits_t xSelectBits ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - SocketSelect_t *pxSocketSet = ( SocketSelect_t * ) xSocketSet; - - configASSERT( pxSocket != NULL ); - configASSERT( xSocketSet != NULL ); - - /* Make sure we're not adding bits which are reserved for internal use, - such as eSELECT_CALL_IP */ - pxSocket->xSelectBits |= ( xSelectBits & eSELECT_ALL ); - - if( ( pxSocket->xSelectBits & eSELECT_ALL ) != 0 ) - { - /* Adding a socket to a socket set. */ - pxSocket->pxSocketSet = ( SocketSelect_t * ) xSocketSet; - - /* Now have the IP-task call vSocketSelect() to see if the set contains - any sockets which are 'ready' and set the proper bits. - By setting 'bApiCalled = false', vSocketSelect() knows that it was - not called from a user API */ - pxSocketSet->bApiCalled = pdFALSE; - prvFindSelectedSocket( pxSocketSet ); - } - } - -#endif /* ipconfigSUPPORT_SELECT_FUNCTION == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - /* Clear select bits for a socket - If the mask becomes 0, remove the socket from the set */ - void FreeRTOS_FD_CLR( Socket_t xSocket, SocketSet_t xSocketSet, EventBits_t xSelectBits ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - - configASSERT( pxSocket != NULL ); - configASSERT( xSocketSet != NULL ); - - pxSocket->xSelectBits &= ~( xSelectBits & eSELECT_ALL ); - if( ( pxSocket->xSelectBits & eSELECT_ALL ) != 0 ) - { - pxSocket->pxSocketSet = ( SocketSelect_t *)xSocketSet; - } - else - { - /* disconnect it from the socket set */ - pxSocket->pxSocketSet = ( SocketSelect_t *)NULL; - } - } - -#endif /* ipconfigSUPPORT_SELECT_FUNCTION == 1 */ -/*-----------------------------------------------------------*/ - - -#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - - /* Test if a socket belongs to a socket-set */ - EventBits_t FreeRTOS_FD_ISSET( Socket_t xSocket, SocketSet_t xSocketSet ) - { - EventBits_t xReturn; - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - - configASSERT( pxSocket != NULL ); - configASSERT( xSocketSet != NULL ); - - if( xSocketSet == ( SocketSet_t ) pxSocket->pxSocketSet ) - { - /* Make sure we're not adding bits which are reserved for internal - use. */ - xReturn = pxSocket->xSocketBits & eSELECT_ALL; - } - else - { - xReturn = 0; - } - - return xReturn; - } - -#endif /* ipconfigSUPPORT_SELECT_FUNCTION == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - - /* The select() statement: wait for an event to occur on any of the sockets - included in a socket set */ - BaseType_t FreeRTOS_select( SocketSet_t xSocketSet, TickType_t xBlockTimeTicks ) - { - TimeOut_t xTimeOut; - TickType_t xRemainingTime; - SocketSelect_t *pxSocketSet = ( SocketSelect_t*) xSocketSet; - BaseType_t xResult; - - configASSERT( xSocketSet != NULL ); - - /* Only in the first round, check for non-blocking */ - xRemainingTime = xBlockTimeTicks; - - /* Fetch the current time */ - vTaskSetTimeOutState( &xTimeOut ); - - for( ;; ) - { - /* Find a socket which might have triggered the bit - This function might return immediately or block for a limited time */ - xResult = ( BaseType_t ) xEventGroupWaitBits( pxSocketSet->xSelectGroup, eSELECT_ALL, pdFALSE, pdFALSE, xRemainingTime ); - - #if( ipconfigSUPPORT_SIGNALS != 0 ) - { - if( ( xResult & eSELECT_INTR ) != 0u ) - { - xEventGroupClearBits( pxSocketSet->xSelectGroup, eSELECT_INTR ); - FreeRTOS_debug_printf( ( "FreeRTOS_select: interrupted\n" ) ); - break; - } - } - #endif /* ipconfigSUPPORT_SIGNALS */ - - /* Have the IP-task find the socket which had an event */ - pxSocketSet->bApiCalled = pdTRUE; - prvFindSelectedSocket( pxSocketSet ); - - xResult = ( BaseType_t ) xEventGroupGetBits( pxSocketSet->xSelectGroup ); - - if( xResult != 0 ) - { - break; - } - - /* Has the timeout been reached? */ - if( xTaskCheckForTimeOut( &xTimeOut, &xRemainingTime ) != pdFALSE ) - { - break; - } - } - - return xResult; - } - -#endif /* ipconfigSUPPORT_SELECT_FUNCTION */ -/*-----------------------------------------------------------*/ - -#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - - /* Send a message to the IP-task to have it check all sockets belonging to - 'pxSocketSet' */ - static FreeRTOS_Socket_t *prvFindSelectedSocket( SocketSelect_t *pxSocketSet ) - { - IPStackEvent_t xSelectEvent; - FreeRTOS_Socket_t *xReturn; - - xSelectEvent.eEventType = eSocketSelectEvent; - xSelectEvent.pvData = ( void * ) pxSocketSet; - - /* while the IP-task works on the request, the API will block on - 'eSELECT_CALL_IP'. So clear it first. */ - xEventGroupClearBits( pxSocketSet->xSelectGroup, eSELECT_CALL_IP ); - - /* Now send the socket select event */ - if( xSendEventStructToIPTask( &xSelectEvent, ( TickType_t ) portMAX_DELAY ) == pdFAIL ) - { - /* Oops, we failed to wake-up the IP task. No use to wait for it. */ - FreeRTOS_debug_printf( ( "prvFindSelectedSocket: failed\n" ) ); - xReturn = NULL; - } - else - { - /* As soon as the IP-task is ready, it will set 'eSELECT_CALL_IP' to - wakeup the calling API */ - xEventGroupWaitBits( pxSocketSet->xSelectGroup, eSELECT_CALL_IP, pdTRUE, pdFALSE, portMAX_DELAY ); - - /* Return 'pxSocket' which is set by the IP-task */ - xReturn = pxSocketSet->pxSocket; - } - - return xReturn; - } - -#endif /* ipconfigSUPPORT_SELECT_FUNCTION == 1 */ -/*-----------------------------------------------------------*/ - -/* - * FreeRTOS_recvfrom: receive data from a bound socket - * In this library, the function can only be used with connectionsless sockets - * (UDP) - */ -int32_t FreeRTOS_recvfrom( Socket_t xSocket, void *pvBuffer, size_t xBufferLength, BaseType_t xFlags, struct freertos_sockaddr *pxSourceAddress, socklen_t *pxSourceAddressLength ) -{ -BaseType_t lPacketCount = 0; -NetworkBufferDescriptor_t *pxNetworkBuffer; -FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; -TickType_t xRemainingTime = ( TickType_t ) 0; /* Obsolete assignment, but some compilers output a warning if its not done. */ -BaseType_t xTimed = pdFALSE; -TimeOut_t xTimeOut; -int32_t lReturn; -EventBits_t xEventBits = ( EventBits_t ) 0; - - if( prvValidSocket( pxSocket, FREERTOS_IPPROTO_UDP, pdTRUE ) == pdFALSE ) - { - return -pdFREERTOS_ERRNO_EINVAL; - } - - lPacketCount = ( BaseType_t ) listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ); - - /* The function prototype is designed to maintain the expected Berkeley - sockets standard, but this implementation does not use all the parameters. */ - ( void ) pxSourceAddressLength; - - while( lPacketCount == 0 ) - { - if( xTimed == pdFALSE ) - { - /* Check to see if the socket is non blocking on the first - iteration. */ - xRemainingTime = pxSocket->xReceiveBlockTime; - - if( xRemainingTime == ( TickType_t ) 0 ) - { - #if( ipconfigSUPPORT_SIGNALS != 0 ) - { - /* Just check for the interrupt flag. */ - xEventBits = xEventGroupWaitBits( pxSocket->xEventGroup, eSOCKET_INTR, - pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, socketDONT_BLOCK ); - } - #endif /* ipconfigSUPPORT_SIGNALS */ - break; - } - - if( ( xFlags & FREERTOS_MSG_DONTWAIT ) != 0 ) - { - break; - } - - /* To ensure this part only executes once. */ - xTimed = pdTRUE; - - /* Fetch the current time. */ - vTaskSetTimeOutState( &xTimeOut ); - } - - /* Wait for arrival of data. While waiting, the IP-task may set the - 'eSOCKET_RECEIVE' bit in 'xEventGroup', if it receives data for this - socket, thus unblocking this API call. */ - xEventBits = xEventGroupWaitBits( pxSocket->xEventGroup, eSOCKET_RECEIVE | eSOCKET_INTR, - pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, xRemainingTime ); - - #if( ipconfigSUPPORT_SIGNALS != 0 ) - { - if( ( xEventBits & eSOCKET_INTR ) != 0 ) - { - if( ( xEventBits & eSOCKET_RECEIVE ) != 0 ) - { - /* Shouldn't have cleared the eSOCKET_RECEIVE flag. */ - xEventGroupSetBits( pxSocket->xEventGroup, eSOCKET_RECEIVE ); - } - break; - } - } - #else - { - ( void ) xEventBits; - } - #endif /* ipconfigSUPPORT_SIGNALS */ - - lPacketCount = ( BaseType_t ) listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ); - - if( lPacketCount != 0 ) - { - break; - } - - /* Has the timeout been reached ? */ - if( xTaskCheckForTimeOut( &xTimeOut, &xRemainingTime ) ) - { - break; - } - } /* while( lPacketCount == 0 ) */ - - if( lPacketCount != 0 ) - { - taskENTER_CRITICAL(); - { - /* The owner of the list item is the network buffer. */ - pxNetworkBuffer = ( NetworkBufferDescriptor_t * ) listGET_OWNER_OF_HEAD_ENTRY( &( pxSocket->u.xUDP.xWaitingPacketsList ) ); - - if( ( xFlags & FREERTOS_MSG_PEEK ) == 0 ) - { - /* Remove the network buffer from the list of buffers waiting to - be processed by the socket. */ - uxListRemove( &( pxNetworkBuffer->xBufferListItem ) ); - } - } - taskEXIT_CRITICAL(); - - /* The returned value is the data length, which may have been capped to - the receive buffer size. */ - lReturn = ( int32_t ) pxNetworkBuffer->xDataLength; - - if( pxSourceAddress != NULL ) - { - pxSourceAddress->sin_port = pxNetworkBuffer->usPort; - pxSourceAddress->sin_addr = pxNetworkBuffer->ulIPAddress; - } - - if( ( xFlags & FREERTOS_ZERO_COPY ) == 0 ) - { - /* The zero copy flag is not set. Truncate the length if it won't - fit in the provided buffer. */ - if( lReturn > ( int32_t ) xBufferLength ) - { - iptraceRECVFROM_DISCARDING_BYTES( ( xBufferLength - lReturn ) ); - lReturn = ( int32_t )xBufferLength; - } - - /* Copy the received data into the provided buffer, then release the - network buffer. */ - memcpy( pvBuffer, ( void * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipUDP_PAYLOAD_OFFSET_IPv4 ] ), ( size_t )lReturn ); - - if( ( xFlags & FREERTOS_MSG_PEEK ) == 0 ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - } - } - else - { - /* The zero copy flag was set. pvBuffer is not a buffer into which - the received data can be copied, but a pointer that must be set to - point to the buffer in which the received data has already been - placed. */ - *( ( void** ) pvBuffer ) = ( void * ) ( &( pxNetworkBuffer->pucEthernetBuffer[ ipUDP_PAYLOAD_OFFSET_IPv4 ] ) ); - } - - } -#if( ipconfigSUPPORT_SIGNALS != 0 ) - else if( ( xEventBits & eSOCKET_INTR ) != 0 ) - { - lReturn = -pdFREERTOS_ERRNO_EINTR; - iptraceRECVFROM_INTERRUPTED(); - } -#endif /* ipconfigSUPPORT_SIGNALS */ - else - { - lReturn = -pdFREERTOS_ERRNO_EWOULDBLOCK; - iptraceRECVFROM_TIMEOUT(); - } - - return lReturn; -} -/*-----------------------------------------------------------*/ - -int32_t FreeRTOS_sendto( Socket_t xSocket, const void *pvBuffer, size_t xTotalDataLength, BaseType_t xFlags, const struct freertos_sockaddr *pxDestinationAddress, socklen_t xDestinationAddressLength ) -{ -NetworkBufferDescriptor_t *pxNetworkBuffer; -IPStackEvent_t xStackTxEvent = { eStackTxEvent, NULL }; -TimeOut_t xTimeOut; -TickType_t xTicksToWait; -int32_t lReturn = 0; -FreeRTOS_Socket_t *pxSocket; - - pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - - /* The function prototype is designed to maintain the expected Berkeley - sockets standard, but this implementation does not use all the - parameters. */ - ( void ) xDestinationAddressLength; - configASSERT( pvBuffer ); - - if( xTotalDataLength <= ( size_t ) ipMAX_UDP_PAYLOAD_LENGTH ) - { - /* If the socket is not already bound to an address, bind it now. - Passing NULL as the address parameter tells FreeRTOS_bind() to select - the address to bind to. */ - if( ( socketSOCKET_IS_BOUND( pxSocket ) != pdFALSE ) || - ( FreeRTOS_bind( xSocket, NULL, 0u ) == 0 ) ) - { - xTicksToWait = pxSocket->xSendBlockTime; - - #if( ipconfigUSE_CALLBACKS != 0 ) - { - if( xIsCallingFromIPTask() != pdFALSE ) - { - /* If this send function is called from within a call-back - handler it may not block, otherwise chances would be big to - get a deadlock: the IP-task waiting for itself. */ - xTicksToWait = ( TickType_t )0; - } - } - #endif /* ipconfigUSE_CALLBACKS */ - - if( ( xFlags & FREERTOS_MSG_DONTWAIT ) != 0 ) - { - xTicksToWait = ( TickType_t ) 0; - } - - if( ( xFlags & FREERTOS_ZERO_COPY ) == 0 ) - { - /* Zero copy is not set, so obtain a network buffer into - which the payload will be copied. */ - vTaskSetTimeOutState( &xTimeOut ); - - /* Block until a buffer becomes available, or until a - timeout has been reached */ - pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( xTotalDataLength + sizeof( UDPPacket_t ), xTicksToWait ); - - if( pxNetworkBuffer != NULL ) - { - memcpy( ( void * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipUDP_PAYLOAD_OFFSET_IPv4 ] ), ( void * ) pvBuffer, xTotalDataLength ); - - if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdTRUE ) - { - /* The entire block time has been used up. */ - xTicksToWait = ( TickType_t ) 0; - } - } - } - else - { - /* When zero copy is used, pvBuffer is a pointer to the - payload of a buffer that has already been obtained from the - stack. Obtain the network buffer pointer from the buffer. */ - pxNetworkBuffer = pxUDPPayloadBuffer_to_NetworkBuffer( (void*)pvBuffer ); - } - - if( pxNetworkBuffer != NULL ) - { - pxNetworkBuffer->xDataLength = xTotalDataLength; - pxNetworkBuffer->usPort = pxDestinationAddress->sin_port; - pxNetworkBuffer->usBoundPort = ( uint16_t ) socketGET_SOCKET_PORT( pxSocket ); - pxNetworkBuffer->ulIPAddress = pxDestinationAddress->sin_addr; - - /* The socket options are passed to the IP layer in the - space that will eventually get used by the Ethernet header. */ - pxNetworkBuffer->pucEthernetBuffer[ ipSOCKET_OPTIONS_OFFSET ] = pxSocket->ucSocketOptions; - - /* Tell the networking task that the packet needs sending. */ - xStackTxEvent.pvData = pxNetworkBuffer; - - /* Ask the IP-task to send this packet */ - if( xSendEventStructToIPTask( &xStackTxEvent, xTicksToWait ) == pdPASS ) - { - /* The packet was successfully sent to the IP task. */ - lReturn = ( int32_t ) xTotalDataLength; - #if( ipconfigUSE_CALLBACKS == 1 ) - { - if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xUDP.pxHandleSent ) ) - { - pxSocket->u.xUDP.pxHandleSent( (Socket_t *)pxSocket, xTotalDataLength ); - } - } - #endif /* ipconfigUSE_CALLBACKS */ - } - else - { - /* If the buffer was allocated in this function, release - it. */ - if( ( xFlags & FREERTOS_ZERO_COPY ) == 0 ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - } - iptraceSTACK_TX_EVENT_LOST( ipSTACK_TX_EVENT ); - } - } - else - { - /* If errno was available, errno would be set to - FREERTOS_ENOPKTS. As it is, the function must return the - number of transmitted bytes, so the calling function knows - how much data was actually sent. */ - iptraceNO_BUFFER_FOR_SENDTO(); - } - } - else - { - iptraceSENDTO_SOCKET_NOT_BOUND(); - } - } - else - { - /* The data is longer than the available buffer space. */ - iptraceSENDTO_DATA_TOO_LONG(); - } - - return lReturn; -} /* Tested */ -/*-----------------------------------------------------------*/ - -/* - * FreeRTOS_bind() : binds a sockt to a local port number. If port 0 is - * provided, a system provided port number will be assigned. This function can - * be used for both UDP and TCP sockets. The actual binding will be performed - * by the IP-task to avoid mutual access to the bound-socket-lists - * (xBoundUDPSocketsList or xBoundTCPSocketsList). - */ -BaseType_t FreeRTOS_bind( Socket_t xSocket, struct freertos_sockaddr * pxAddress, socklen_t xAddressLength ) -{ -IPStackEvent_t xBindEvent; -FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; -BaseType_t xReturn = 0; - - ( void ) xAddressLength; - - if( ( pxSocket == NULL ) || ( pxSocket == FREERTOS_INVALID_SOCKET ) ) - { - xReturn = -pdFREERTOS_ERRNO_EINVAL; - } - /* Once a socket is bound to a port, it can not be bound to a different - port number */ - else if( socketSOCKET_IS_BOUND( pxSocket) != pdFALSE ) - { - /* The socket is already bound. */ - FreeRTOS_debug_printf( ( "vSocketBind: Socket already bound to %d\n", pxSocket->usLocalPort ) ); - xReturn = -pdFREERTOS_ERRNO_EINVAL; - } - else - { - /* Prepare a messages to the IP-task in order to perform the binding. - The desired port number will be passed in usLocalPort. */ - xBindEvent.eEventType = eSocketBindEvent; - xBindEvent.pvData = ( void * ) xSocket; - if( pxAddress != NULL ) - { - pxSocket->usLocalPort = FreeRTOS_ntohs( pxAddress->sin_port ); - } - else - { - /* Caller wants to bind to a random port number. */ - pxSocket->usLocalPort = 0u; - } - - /* portMAX_DELAY is used as a the time-out parameter, as binding *must* - succeed before the socket can be used. _RB_ The use of an infinite - block time needs be changed as it could result in the task hanging. */ - if( xSendEventStructToIPTask( &xBindEvent, ( TickType_t ) portMAX_DELAY ) == pdFAIL ) - { - /* Failed to wake-up the IP-task, no use to wait for it */ - FreeRTOS_debug_printf( ( "FreeRTOS_bind: send event failed\n" ) ); - xReturn = -pdFREERTOS_ERRNO_ECANCELED; - } - else - { - /* The IP-task will set the 'eSOCKET_BOUND' bit when it has done its - job. */ - xEventGroupWaitBits( pxSocket->xEventGroup, eSOCKET_BOUND, pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, portMAX_DELAY ); - if( socketSOCKET_IS_BOUND( pxSocket ) == pdFALSE ) - { - xReturn = -pdFREERTOS_ERRNO_EINVAL; - } - } - } - - return xReturn; -} - -/* - * vSocketBind(): internal version of bind() that should not be called directly. - * 'xInternal' is used for TCP sockets only: it allows to have several - * (connected) child sockets bound to the same server port. - */ -BaseType_t vSocketBind( FreeRTOS_Socket_t *pxSocket, struct freertos_sockaddr * pxAddress, size_t uxAddressLength, BaseType_t xInternal ) -{ -BaseType_t xReturn = 0; /* In Berkeley sockets, 0 means pass for bind(). */ -List_t *pxSocketList; -#if( ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND == 1 ) - struct freertos_sockaddr xAddress; -#endif /* ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND */ - -#if( ipconfigUSE_TCP == 1 ) - if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - pxSocketList = &xBoundTCPSocketsList; - } - else -#endif /* ipconfigUSE_TCP == 1 */ - { - pxSocketList = &xBoundUDPSocketsList; - } - - /* The function prototype is designed to maintain the expected Berkeley - sockets standard, but this implementation does not use all the parameters. */ - ( void ) uxAddressLength; - - configASSERT( pxSocket ); - configASSERT( pxSocket != FREERTOS_INVALID_SOCKET ); - - #if( ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND == 1 ) - { - /* pxAddress will be NULL if sendto() was called on a socket without the - socket being bound to an address. In this case, automatically allocate - an address and port to the socket. */ - if( pxAddress == NULL ) - { - pxAddress = &xAddress; - /* Put the port to zero to be assigned later. */ - pxAddress->sin_port = 0u; - } - } - #endif /* ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND == 1 */ - - /* Sockets must be bound before calling FreeRTOS_sendto() if - ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is not set to 1. */ - configASSERT( pxAddress ); - - if( pxAddress != NULL ) - { - if( pxAddress->sin_port == 0u ) - { - pxAddress->sin_port = prvGetPrivatePortNumber( ( BaseType_t )pxSocket->ucProtocol ); - if( 0 == pxAddress->sin_port ) - { - return -pdFREERTOS_ERRNO_EADDRNOTAVAIL; - } - } - - /* If vSocketBind() is called from the API FreeRTOS_bind() it has been - confirmed that the socket was not yet bound to a port. If it is called - from the IP-task, no such check is necessary. */ - - /* Check to ensure the port is not already in use. If the bind is - called internally, a port MAY be used by more than one socket. */ - if( ( ( xInternal == pdFALSE ) || ( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) ) && - ( pxListFindListItemWithValue( pxSocketList, ( TickType_t ) pxAddress->sin_port ) != NULL ) ) - { - FreeRTOS_debug_printf( ( "vSocketBind: %sP port %d in use\n", - pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_TCP ? "TC" : "UD", - FreeRTOS_ntohs( pxAddress->sin_port ) ) ); - xReturn = -pdFREERTOS_ERRNO_EADDRINUSE; - } - else - { - /* Allocate the port number to the socket. - This macro will set 'xBoundSocketListItem->xItemValue' */ - socketSET_SOCKET_PORT( pxSocket, pxAddress->sin_port ); - - /* And also store it in a socket field 'usLocalPort' in host-byte-order, - mostly used for logging and debugging purposes */ - pxSocket->usLocalPort = FreeRTOS_ntohs( pxAddress->sin_port ); - - /* Add the socket to the list of bound ports. */ - { - /* If the network driver can iterate through 'xBoundUDPSocketsList', - by calling xPortHasUDPSocket() then the IP-task must temporarily - suspend the scheduler to keep the list in a consistent state. */ - #if( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 ) - { - vTaskSuspendAll(); - } - #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ - - /* Add the socket to 'xBoundUDPSocketsList' or 'xBoundTCPSocketsList' */ - vListInsertEnd( pxSocketList, &( pxSocket->xBoundSocketListItem ) ); - - #if( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 ) - { - xTaskResumeAll(); - } - #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ - } - } - } - else - { - xReturn = -pdFREERTOS_ERRNO_EADDRNOTAVAIL; - FreeRTOS_debug_printf( ( "vSocketBind: Socket no addr\n" ) ); - } - - if( xReturn != 0 ) - { - iptraceBIND_FAILED( xSocket, ( FreeRTOS_ntohs( pxAddress->sin_port ) ) ); - } - - return xReturn; -} /* Tested */ -/*-----------------------------------------------------------*/ - -/* - * Close a socket and free the allocated space - * In case of a TCP socket: the connection will not be closed automatically - * Subsequent messages for the closed socket will be responded to with a RST - * The IP-task will actually close the socket, after receiving a 'eSocketCloseEvent' message - */ -BaseType_t FreeRTOS_closesocket( Socket_t xSocket ) -{ -BaseType_t xResult; -#if( ipconfigUSE_TCP == 1 ) && ( ipconfigUSE_CALLBACKS == 1 ) - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * )xSocket; -#endif -IPStackEvent_t xCloseEvent; -xCloseEvent.eEventType = eSocketCloseEvent; -xCloseEvent.pvData = ( void * ) xSocket; - - if( ( xSocket == NULL ) || ( xSocket == FREERTOS_INVALID_SOCKET ) ) - { - xResult = 0; - } - else - { - #if( ( ipconfigUSE_TCP == 1 ) && ( ipconfigUSE_CALLBACKS == 1 ) ) - { - if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - /* Make sure that IP-task won't call the user callback's anymore */ - pxSocket->u.xTCP.pxHandleConnected = NULL; - pxSocket->u.xTCP.pxHandleReceive = NULL; - pxSocket->u.xTCP.pxHandleSent = NULL; - } - } - #endif /* ( ( ipconfigUSE_TCP == 1 ) && ( ipconfigUSE_CALLBACKS == 1 ) ) */ - - /* Let the IP task close the socket to keep it synchronised with the - packet handling. */ - - /* Note when changing the time-out value below, it must be checked who is calling - this function. If it is called by the IP-task, a deadlock could occur. - The IP-task would only call it in case of a user call-back */ - if( xSendEventStructToIPTask( &xCloseEvent, ( TickType_t ) 0 ) == pdFAIL ) - { - FreeRTOS_debug_printf( ( "FreeRTOS_closesocket: failed\n" ) ); - xResult = -1; - } - else - { - xResult = 1; - } - } - - return xResult; -} - -/* This is the internal version of FreeRTOS_closesocket() - * It will be called by the IPtask only to avoid problems with synchronicity - */ -void *vSocketClose( FreeRTOS_Socket_t *pxSocket ) -{ -NetworkBufferDescriptor_t *pxNetworkBuffer; - - #if( ipconfigUSE_TCP == 1 ) - { - /* For TCP: clean up a little more. */ - if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - #if( ipconfigUSE_TCP_WIN == 1 ) - { - if( pxSocket->u.xTCP.pxAckMessage != NULL ) - { - vReleaseNetworkBufferAndDescriptor( pxSocket->u.xTCP.pxAckMessage ); - } - /* Free the resources which were claimed by the tcpWin member */ - vTCPWindowDestroy( &pxSocket->u.xTCP.xTCPWindow ); - } - #endif /* ipconfigUSE_TCP_WIN */ - - /* Free the input and output streams */ - if( pxSocket->u.xTCP.rxStream != NULL ) - { - vPortFreeLarge( pxSocket->u.xTCP.rxStream ); - } - - if( pxSocket->u.xTCP.txStream != NULL ) - { - vPortFreeLarge( pxSocket->u.xTCP.txStream ); - } - - /* In case this is a child socket, make sure the child-count of the - parent socket is decreased. */ - prvTCPSetSocketCount( pxSocket ); - } - } - #endif /* ipconfigUSE_TCP == 1 */ - - /* Socket must be unbound first, to ensure no more packets are queued on - it. */ - if( socketSOCKET_IS_BOUND( pxSocket ) != pdFALSE ) - { - /* If the network driver can iterate through 'xBoundUDPSocketsList', - by calling xPortHasUDPSocket(), then the IP-task must temporarily - suspend the scheduler to keep the list in a consistent state. */ - #if( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 ) - { - vTaskSuspendAll(); - } - #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ - - uxListRemove( &( pxSocket->xBoundSocketListItem ) ); - - #if( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 ) - { - xTaskResumeAll(); - } - #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ - } - - /* Now the socket is not bound the list of waiting packets can be - drained. */ - if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_UDP ) - { - while( listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ) > 0U ) - { - pxNetworkBuffer = ( NetworkBufferDescriptor_t * ) listGET_OWNER_OF_HEAD_ENTRY( &( pxSocket->u.xUDP.xWaitingPacketsList ) ); - uxListRemove( &( pxNetworkBuffer->xBufferListItem ) ); - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - } - } - - if( pxSocket->xEventGroup ) - { - vEventGroupDelete( pxSocket->xEventGroup ); - } - - #if( ipconfigUSE_TCP == 1 ) && ( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - FreeRTOS_debug_printf( ( "FreeRTOS_closesocket[%u to %lxip:%u]: buffers %lu socks %lu\n", - pxSocket->usLocalPort, - pxSocket->u.xTCP.ulRemoteIP, - pxSocket->u.xTCP.usRemotePort, - uxGetNumberOfFreeNetworkBuffers(), - listCURRENT_LIST_LENGTH( &xBoundTCPSocketsList ) ) ); - } - } - #endif /* ( ipconfigUSE_TCP == 1 ) && ( ipconfigHAS_DEBUG_PRINTF != 0 ) */ - - /* Anf finally, after all resources have been freed, free the socket space */ - vPortFreeSocket( pxSocket ); - - return 0; -} /* Tested */ - -/*-----------------------------------------------------------*/ - -#if ipconfigUSE_TCP == 1 - - /* - * When a child socket gets closed, make sure to update the child-count of the - * parent. When a listening parent socket is closed, make sure no child-sockets - * keep a pointer to it. - */ - static void prvTCPSetSocketCount( FreeRTOS_Socket_t *pxSocketToDelete ) - { - const ListItem_t *pxIterator; - const MiniListItem_t *pxEnd = ( const MiniListItem_t* )listGET_END_MARKER( &xBoundTCPSocketsList ); - FreeRTOS_Socket_t *pxOtherSocket; - uint16_t usLocalPort = pxSocketToDelete->usLocalPort; - - for( pxIterator = ( const ListItem_t * ) listGET_NEXT( pxEnd ); - pxIterator != ( const ListItem_t * ) pxEnd; - pxIterator = ( const ListItem_t * ) listGET_NEXT( pxIterator ) ) - { - pxOtherSocket = ( FreeRTOS_Socket_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); - if( ( pxOtherSocket->u.xTCP.ucTCPState == eTCP_LISTEN ) && - ( pxOtherSocket->usLocalPort == usLocalPort ) && - ( pxOtherSocket->u.xTCP.usChildCount ) ) - { - pxOtherSocket->u.xTCP.usChildCount--; - FreeRTOS_debug_printf( ( "Lost: Socket %u now has %u / %u child%s\n", - pxOtherSocket->usLocalPort, - pxOtherSocket->u.xTCP.usChildCount, - pxOtherSocket->u.xTCP.usBacklog, - pxOtherSocket->u.xTCP.usChildCount == 1u ? "" : "ren" ) ); - break; - } - } - } - -#endif /* ipconfigUSE_TCP == 1 */ - -/*-----------------------------------------------------------*/ - -BaseType_t FreeRTOS_setsockopt( Socket_t xSocket, int32_t lLevel, int32_t lOptionName, const void *pvOptionValue, size_t xOptionLength ) -{ -/* The standard Berkeley function returns 0 for success. */ -BaseType_t xReturn = -pdFREERTOS_ERRNO_EINVAL; -BaseType_t lOptionValue; -FreeRTOS_Socket_t *pxSocket; - - pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - - /* The function prototype is designed to maintain the expected Berkeley - sockets standard, but this implementation does not use all the parameters. */ - ( void ) lLevel; - ( void ) xOptionLength; - - configASSERT( xSocket ); - - switch( lOptionName ) - { - case FREERTOS_SO_RCVTIMEO : - /* Receive time out. */ - pxSocket->xReceiveBlockTime = *( ( TickType_t * ) pvOptionValue ); - xReturn = 0; - break; - - case FREERTOS_SO_SNDTIMEO : - pxSocket->xSendBlockTime = *( ( TickType_t * ) pvOptionValue ); - if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_UDP ) - { - /* The send time out is capped for the reason stated in the - comments where ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS is defined - in FreeRTOSIPConfig.h (assuming an official configuration file - is being used. */ - if( pxSocket->xSendBlockTime > ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ) - { - pxSocket->xSendBlockTime = ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS; - } - } - else - { - /* For TCP socket, it isn't necessary to limit the blocking time - because the FreeRTOS_send() function does not wait for a network - buffer to become available. */ - } - xReturn = 0; - break; - #if( ipconfigUDP_MAX_RX_PACKETS > 0 ) - case FREERTOS_SO_UDP_MAX_RX_PACKETS: - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_UDP ) - { - break; /* will return -pdFREERTOS_ERRNO_EINVAL */ - } - pxSocket->u.xUDP.uxMaxPackets = *( ( UBaseType_t * ) pvOptionValue ); - xReturn = 0; - break; - #endif /* ipconfigUDP_MAX_RX_PACKETS */ - - case FREERTOS_SO_UDPCKSUM_OUT : - /* Turn calculating of the UDP checksum on/off for this socket. */ - lOptionValue = ( BaseType_t ) pvOptionValue; - - if( lOptionValue == 0 ) - { - pxSocket->ucSocketOptions &= ( uint8_t ) ~FREERTOS_SO_UDPCKSUM_OUT; - } - else - { - pxSocket->ucSocketOptions |= ( uint8_t ) FREERTOS_SO_UDPCKSUM_OUT; - } - xReturn = 0; - break; - - #if( ipconfigUSE_CALLBACKS == 1 ) - #if( ipconfigUSE_TCP == 1 ) - case FREERTOS_SO_TCP_CONN_HANDLER: /* Set a callback for (dis)connection events */ - case FREERTOS_SO_TCP_RECV_HANDLER: /* Install a callback for receiving TCP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */ - case FREERTOS_SO_TCP_SENT_HANDLER: /* Install a callback for sending TCP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */ - #endif /* ipconfigUSE_TCP */ - case FREERTOS_SO_UDP_RECV_HANDLER: /* Install a callback for receiving UDP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */ - case FREERTOS_SO_UDP_SENT_HANDLER: /* Install a callback for sending UDP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */ - { - #if( ipconfigUSE_TCP == 1 ) - { - UBaseType_t uxProtocol; - if( ( lOptionName == FREERTOS_SO_UDP_RECV_HANDLER ) || - ( lOptionName == FREERTOS_SO_UDP_SENT_HANDLER ) ) - { - uxProtocol = ( UBaseType_t ) FREERTOS_IPPROTO_UDP; - } - else - { - uxProtocol = ( UBaseType_t ) FREERTOS_IPPROTO_TCP; - } - - if( pxSocket->ucProtocol != ( uint8_t ) uxProtocol ) - { - break; /* will return -pdFREERTOS_ERRNO_EINVAL */ - } - } - #else - { - /* No need to check if the socket has the right - protocol, because only UDP socket can be created. */ - } - #endif /* ipconfigUSE_TCP */ - - switch( lOptionName ) - { - #if ipconfigUSE_TCP == 1 - case FREERTOS_SO_TCP_CONN_HANDLER: - pxSocket->u.xTCP.pxHandleConnected = ((F_TCP_UDP_Handler_t *)pvOptionValue)->pxOnTCPConnected; - break; - case FREERTOS_SO_TCP_RECV_HANDLER: - pxSocket->u.xTCP.pxHandleReceive = ((F_TCP_UDP_Handler_t *)pvOptionValue)->pxOnTCPReceive; - break; - case FREERTOS_SO_TCP_SENT_HANDLER: - pxSocket->u.xTCP.pxHandleSent = ((F_TCP_UDP_Handler_t *)pvOptionValue)->pxOnTCPSent; - break; - #endif /* ipconfigUSE_TCP */ - case FREERTOS_SO_UDP_RECV_HANDLER: - pxSocket->u.xUDP.pxHandleReceive = ((F_TCP_UDP_Handler_t *)pvOptionValue)->pxOnUDPReceive; - break; - case FREERTOS_SO_UDP_SENT_HANDLER: - pxSocket->u.xUDP.pxHandleSent = ((F_TCP_UDP_Handler_t *)pvOptionValue)->pxOnUDPSent; - break; - default: - break; - } - } - - xReturn = 0; - break; - #endif /* ipconfigUSE_CALLBACKS */ - - #if( ipconfigUSE_TCP != 0 ) - #if( ipconfigSOCKET_HAS_USER_SEMAPHORE != 0 ) - /* Each socket has a semaphore on which the using task normally - sleeps. */ - case FREERTOS_SO_SET_SEMAPHORE: - { - pxSocket->pxUserSemaphore = *( ( SemaphoreHandle_t * ) pvOptionValue ); - xReturn = 0; - } - break; - #endif /* ipconfigSOCKET_HAS_USER_SEMAPHORE */ - - #if( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK != 0 ) - case FREERTOS_SO_WAKEUP_CALLBACK: - { - /* Each socket can have a callback function that is executed - when there is an event the socket's owner might want to - process. */ - pxSocket->pxUserWakeCallback = ( SocketWakeupCallback_t ) pvOptionValue; - xReturn = 0; - } - break; - #endif /* ipconfigSOCKET_HAS_USER_WAKE_CALLBACK */ - - case FREERTOS_SO_SNDBUF: /* Set the size of the send buffer, in units of MSS (TCP only) */ - case FREERTOS_SO_RCVBUF: /* Set the size of the receive buffer, in units of MSS (TCP only) */ - { - uint32_t ulNewValue; - - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - FreeRTOS_debug_printf( ( "Set SO_%sBUF: wrong socket type\n", - ( lOptionName == FREERTOS_SO_SNDBUF ) ? "SND" : "RCV" ) ); - break; /* will return -pdFREERTOS_ERRNO_EINVAL */ - } - - if( ( ( lOptionName == FREERTOS_SO_SNDBUF ) && ( pxSocket->u.xTCP.txStream != NULL ) ) || - ( ( lOptionName == FREERTOS_SO_RCVBUF ) && ( pxSocket->u.xTCP.rxStream != NULL ) ) ) - { - FreeRTOS_debug_printf( ( "Set SO_%sBUF: buffer already created\n", - ( lOptionName == FREERTOS_SO_SNDBUF ) ? "SND" : "RCV" ) ); - break; /* will return -pdFREERTOS_ERRNO_EINVAL */ - } - - ulNewValue = *( ( uint32_t * ) pvOptionValue ); - - if( lOptionName == FREERTOS_SO_SNDBUF ) - { - /* Round up to nearest MSS size */ - ulNewValue = FreeRTOS_round_up( ulNewValue, ( uint32_t ) pxSocket->u.xTCP.usInitMSS ); - pxSocket->u.xTCP.uxTxStreamSize = ulNewValue; - } - else - { - pxSocket->u.xTCP.uxRxStreamSize = ulNewValue; - } - } - xReturn = 0; - break; - - case FREERTOS_SO_WIN_PROPERTIES: /* Set all buffer and window properties in one call, parameter is pointer to WinProperties_t */ - { - WinProperties_t* pxProps; - - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - FreeRTOS_debug_printf( ( "Set SO_WIN_PROP: wrong socket type\n" ) ); - break; /* will return -pdFREERTOS_ERRNO_EINVAL */ - } - - if( ( pxSocket->u.xTCP.txStream != NULL ) || ( pxSocket->u.xTCP.rxStream != NULL ) ) - { - FreeRTOS_debug_printf( ( "Set SO_WIN_PROP: buffer already created\n" ) ); - break; /* will return -pdFREERTOS_ERRNO_EINVAL */ - } - - pxProps = ( ( WinProperties_t * ) pvOptionValue ); - FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDBUF, &( pxProps->lTxBufSize ), sizeof( pxProps->lTxBufSize ) ); - FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_RCVBUF, &( pxProps->lRxBufSize ), sizeof( pxProps->lRxBufSize ) ); - #if( ipconfigUSE_TCP_WIN == 1 ) - { - pxSocket->u.xTCP.uxRxWinSize = ( uint32_t )pxProps->lRxWinSize; /* Fixed value: size of the TCP reception window */ - pxSocket->u.xTCP.uxTxWinSize = ( uint32_t )pxProps->lTxWinSize; /* Fixed value: size of the TCP transmit window */ - } - #else - { - pxSocket->u.xTCP.uxRxWinSize = 1u; - pxSocket->u.xTCP.uxTxWinSize = 1u; - } - #endif - - /* In case the socket has already initialised its tcpWin, - adapt the window size parameters */ - if( pxSocket->u.xTCP.xTCPWindow.u.bits.bHasInit != pdFALSE_UNSIGNED ) - { - pxSocket->u.xTCP.xTCPWindow.xSize.ulRxWindowLength = pxSocket->u.xTCP.uxRxWinSize * pxSocket->u.xTCP.usInitMSS; - pxSocket->u.xTCP.xTCPWindow.xSize.ulTxWindowLength = pxSocket->u.xTCP.uxTxWinSize * pxSocket->u.xTCP.usInitMSS; - } - } - - xReturn = 0; - break; - - case FREERTOS_SO_REUSE_LISTEN_SOCKET: /* If true, the server-socket will turn into a connected socket */ - { - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - break; /* will return -pdFREERTOS_ERRNO_EINVAL */ - } - if( *( ( BaseType_t * ) pvOptionValue ) != 0 ) - { - pxSocket->u.xTCP.bits.bReuseSocket = pdTRUE_UNSIGNED; - } - else - { - pxSocket->u.xTCP.bits.bReuseSocket = pdFALSE_UNSIGNED; - } - } - xReturn = 0; - break; - - case FREERTOS_SO_CLOSE_AFTER_SEND: /* As soon as the last byte has been transmitted, finalise the connection */ - { - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - break; /* will return -pdFREERTOS_ERRNO_EINVAL */ - } - - if( *( ( BaseType_t * ) pvOptionValue ) != 0 ) - { - pxSocket->u.xTCP.bits.bCloseAfterSend = pdTRUE_UNSIGNED; - } - else - { - pxSocket->u.xTCP.bits.bCloseAfterSend = pdFALSE_UNSIGNED; - } - } - xReturn = 0; - break; - - case FREERTOS_SO_SET_FULL_SIZE: /* Refuse to send packets smaller than MSS */ - { - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - break; /* will return -pdFREERTOS_ERRNO_EINVAL */ - } - - if( *( ( BaseType_t * ) pvOptionValue ) != 0 ) - { - pxSocket->u.xTCP.xTCPWindow.u.bits.bSendFullSize = pdTRUE_UNSIGNED; - } - else - { - pxSocket->u.xTCP.xTCPWindow.u.bits.bSendFullSize = pdFALSE_UNSIGNED; - } - - if( ( pxSocket->u.xTCP.xTCPWindow.u.bits.bSendFullSize == pdFALSE_UNSIGNED ) && - ( pxSocket->u.xTCP.ucTCPState >= eESTABLISHED ) && - ( FreeRTOS_outstanding( pxSocket ) != 0 ) ) - { - pxSocket->u.xTCP.usTimeout = 1u; /* to set/clear bSendFullSize */ - xSendEventToIPTask( eTCPTimerEvent ); - } - } - xReturn = 0; - break; - - case FREERTOS_SO_STOP_RX: /* Refuse to receive more packts */ - { - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - break; /* will return -pdFREERTOS_ERRNO_EINVAL */ - } - - if( *( ( BaseType_t * ) pvOptionValue ) != 0 ) - { - pxSocket->u.xTCP.bits.bRxStopped = pdTRUE_UNSIGNED; - } - else - { - pxSocket->u.xTCP.bits.bRxStopped = pdFALSE_UNSIGNED; - } - - pxSocket->u.xTCP.bits.bWinChange = pdTRUE_UNSIGNED; - pxSocket->u.xTCP.usTimeout = 1u; /* to set/clear bRxStopped */ - xSendEventToIPTask( eTCPTimerEvent ); - } - xReturn = 0; - break; - - #endif /* ipconfigUSE_TCP == 1 */ - - default : - /* No other options are handled. */ - xReturn = -pdFREERTOS_ERRNO_ENOPROTOOPT; - break; - } - - return xReturn; -} /* Tested */ - -/*-----------------------------------------------------------*/ - -/* Find an available port number per https://tools.ietf.org/html/rfc6056. */ -static uint16_t prvGetPrivatePortNumber( BaseType_t xProtocol ) -{ -const uint16_t usEphemeralPortCount = - socketAUTO_PORT_ALLOCATION_MAX_NUMBER - socketAUTO_PORT_ALLOCATION_START_NUMBER + 1; -uint16_t usIterations = usEphemeralPortCount; -uint32_t ulRandomSeed = 0; -uint16_t usResult = 0; -BaseType_t xGotZeroOnce = pdFALSE; -const List_t *pxList; - -#if ipconfigUSE_TCP == 1 - if( xProtocol == ( BaseType_t ) FREERTOS_IPPROTO_TCP ) - { - pxList = &xBoundTCPSocketsList; - } - else -#endif - { - pxList = &xBoundUDPSocketsList; - } - - /* Avoid compiler warnings if ipconfigUSE_TCP is not defined. */ - ( void ) xProtocol; - - /* Find the next available port using the random seed as a starting - point. */ - do - { - /* Generate a random seed. */ - ulRandomSeed = ipconfigRAND32( ); - - /* Only proceed if the random number generator succeeded. */ - if( 0 == ulRandomSeed ) - { - if( pdFALSE == xGotZeroOnce ) - { - xGotZeroOnce = pdTRUE; - continue; - } - else - { - break; - } - } - - /* Map the random to a candidate port. */ - usResult = - socketAUTO_PORT_ALLOCATION_START_NUMBER + - ( ( ( uint16_t )ulRandomSeed ) % usEphemeralPortCount ); - - /* Check if there's already an open socket with the same protocol - and port. */ - if( NULL == pxListFindListItemWithValue( - pxList, - ( TickType_t )FreeRTOS_htons( usResult ) ) ) - { - usResult = FreeRTOS_htons( usResult ); - break; - } - else - { - usResult = 0; - } - - usIterations--; - } - while( usIterations > 0 ); - - return usResult; -} -/*-----------------------------------------------------------*/ - -/* pxListFindListItemWithValue: find a list item in a bound socket list -'xWantedItemValue' refers to a port number */ -static const ListItem_t * pxListFindListItemWithValue( const List_t *pxList, TickType_t xWantedItemValue ) -{ -const ListItem_t * pxResult = NULL; - - if( ( xIPIsNetworkTaskReady() != pdFALSE ) && ( pxList != NULL ) ) - { - const ListItem_t *pxIterator; - const MiniListItem_t *pxEnd = ( const MiniListItem_t* )listGET_END_MARKER( pxList ); - for( pxIterator = ( const ListItem_t * ) listGET_NEXT( pxEnd ); - pxIterator != ( const ListItem_t * ) pxEnd; - pxIterator = ( const ListItem_t * ) listGET_NEXT( pxIterator ) ) - { - if( listGET_LIST_ITEM_VALUE( pxIterator ) == xWantedItemValue ) - { - pxResult = pxIterator; - break; - } - } - } - - return pxResult; -} /* Tested */ - -/*-----------------------------------------------------------*/ - -FreeRTOS_Socket_t *pxUDPSocketLookup( UBaseType_t uxLocalPort ) -{ -const ListItem_t *pxListItem; -FreeRTOS_Socket_t *pxSocket = NULL; - - /* Looking up a socket is quite simple, find a match with the local port. - - See if there is a list item associated with the port number on the - list of bound sockets. */ - pxListItem = pxListFindListItemWithValue( &xBoundUDPSocketsList, ( TickType_t ) uxLocalPort ); - - if( pxListItem != NULL ) - { - /* The owner of the list item is the socket itself. */ - pxSocket = ( FreeRTOS_Socket_t * ) listGET_LIST_ITEM_OWNER( pxListItem ); - configASSERT( pxSocket != NULL ); - } - return pxSocket; -} - -/*-----------------------------------------------------------*/ - -#if ipconfigINCLUDE_FULL_INET_ADDR == 1 - - uint32_t FreeRTOS_inet_addr( const char * pcIPAddress ) - { - const uint32_t ulDecimalBase = 10u; - uint8_t ucOctet[ socketMAX_IP_ADDRESS_OCTETS ]; - const char *pcPointerOnEntering; - uint32_t ulReturn = 0UL, ulValue; - UBaseType_t uxOctetNumber; - BaseType_t xResult = pdPASS; - - for( uxOctetNumber = 0u; uxOctetNumber < socketMAX_IP_ADDRESS_OCTETS; uxOctetNumber++ ) - { - ulValue = 0ul; - pcPointerOnEntering = pcIPAddress; - - while( ( *pcIPAddress >= '0' ) && ( *pcIPAddress <= '9' ) ) - { - /* Move previous read characters into the next decimal - position. */ - ulValue *= ulDecimalBase; - - /* Add the binary value of the ascii character. */ - ulValue += ( ( uint32_t ) ( *pcIPAddress ) - ( uint32_t ) '0' ); - - /* Move to next character in the string. */ - pcIPAddress++; - } - - /* Check characters were read. */ - if( pcIPAddress == pcPointerOnEntering ) - { - xResult = pdFAIL; - } - - /* Check the value fits in an 8-bit number. */ - if( ulValue > 0xffUL ) - { - xResult = pdFAIL; - } - else - { - ucOctet[ uxOctetNumber ] = ( uint8_t ) ulValue; - - /* Check the next character is as expected. */ - if( uxOctetNumber < ( socketMAX_IP_ADDRESS_OCTETS - 1u ) ) - { - if( *pcIPAddress != '.' ) - { - xResult = pdFAIL; - } - else - { - /* Move past the dot. */ - pcIPAddress++; - } - } - } - - if( xResult == pdFAIL ) - { - /* No point going on. */ - break; - } - } - - if( *pcIPAddress != ( char ) 0 ) - { - /* Expected the end of the string. */ - xResult = pdFAIL; - } - - if( uxOctetNumber != socketMAX_IP_ADDRESS_OCTETS ) - { - /* Didn't read enough octets. */ - xResult = pdFAIL; - } - - if( xResult == pdPASS ) - { - ulReturn = FreeRTOS_inet_addr_quick( ucOctet[ 0 ], ucOctet[ 1 ], ucOctet[ 2 ], ucOctet[ 3 ] ); - } - - return ulReturn; - } - -#endif /* ipconfigINCLUDE_FULL_INET_ADDR */ - -/*-----------------------------------------------------------*/ - -/* Function to get the local address and IP port */ -size_t FreeRTOS_GetLocalAddress( Socket_t xSocket, struct freertos_sockaddr *pxAddress ) -{ -FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - - /* IP address of local machine. */ - pxAddress->sin_addr = *ipLOCAL_IP_ADDRESS_POINTER; - - /* Local port on this machine. */ - pxAddress->sin_port = FreeRTOS_htons( pxSocket->usLocalPort ); - - return sizeof( *pxAddress ); -} - -/*-----------------------------------------------------------*/ - -void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket ) -{ -/* _HT_ must work this out, now vSocketWakeUpUser will be called for any important - * event or transition */ - #if( ipconfigSOCKET_HAS_USER_SEMAPHORE == 1 ) - { - if( pxSocket->pxUserSemaphore != NULL ) - { - xSemaphoreGive( pxSocket->pxUserSemaphore ); - } - } - #endif /* ipconfigSOCKET_HAS_USER_SEMAPHORE */ - - #if( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK == 1 ) - { - if( pxSocket->pxUserWakeCallback != NULL ) - { - pxSocket->pxUserWakeCallback( pxSocket ); - } - } - #endif /* ipconfigSOCKET_HAS_USER_SEMAPHORE */ - - #if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - { - if( pxSocket->pxSocketSet != NULL ) - { - EventBits_t xSelectBits = ( pxSocket->xEventBits >> SOCKET_EVENT_BIT_COUNT ) & eSELECT_ALL; - if( xSelectBits != 0ul ) - { - pxSocket->xSocketBits |= xSelectBits; - xEventGroupSetBits( pxSocket->pxSocketSet->xSelectGroup, xSelectBits ); - } - } - - pxSocket->xEventBits &= eSOCKET_ALL; - } - #endif /* ipconfigSUPPORT_SELECT_FUNCTION */ - - if( ( pxSocket->xEventGroup != NULL ) && ( pxSocket->xEventBits != 0u ) ) - { - xEventGroupSetBits( pxSocket->xEventGroup, pxSocket->xEventBits ); - } - - pxSocket->xEventBits = 0ul; -} - -/*-----------------------------------------------------------*/ - -#if( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 ) - - /* This define makes it possible for network-card drivers to inspect - * UDP message and see if there is any UDP socket bound to a given port - * number. - * This is probably only usefull in systems with a minimum of RAM and - * when lots of anonymous broadcast messages come in - */ - BaseType_t xPortHasUDPSocket( uint16_t usPortNr ) - { - BaseType_t xFound = pdFALSE; - - vTaskSuspendAll(); - { - if( ( pxListFindListItemWithValue( &xBoundUDPSocketsList, ( TickType_t ) usPortNr ) != NULL ) ) - { - xFound = pdTRUE; - } - } - xTaskResumeAll(); - - return xFound; - } - -#endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ - -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - static BaseType_t bMayConnect( FreeRTOS_Socket_t *pxSocket ); - static BaseType_t bMayConnect( FreeRTOS_Socket_t *pxSocket ) - { - switch( pxSocket->u.xTCP.ucTCPState ) - { - case eCLOSED: - case eCLOSE_WAIT: return 0; - case eCONNECT_SYN: return -pdFREERTOS_ERRNO_EINPROGRESS; - default: return -pdFREERTOS_ERRNO_EAGAIN; - } - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - static BaseType_t prvTCPConnectStart( FreeRTOS_Socket_t *pxSocket, struct freertos_sockaddr *pxAddress ) - { - BaseType_t xResult = 0; - - if( prvValidSocket( pxSocket, FREERTOS_IPPROTO_TCP, pdFALSE ) == pdFALSE ) - { - /* Not a valid socket or wrong type */ - xResult = -pdFREERTOS_ERRNO_EBADF; - } - else if( FreeRTOS_issocketconnected( pxSocket ) > 0 ) - { - /* The socket is already connected. */ - xResult = -pdFREERTOS_ERRNO_EISCONN; - } - else if( socketSOCKET_IS_BOUND( pxSocket ) == pdFALSE ) - { - /* Bind the socket to the port that the client task will send from. - Non-standard, so the error returned is that returned by bind(). */ - xResult = FreeRTOS_bind( ( Socket_t ) pxSocket, NULL, 0u ); - } - - if( xResult == 0 ) - { - /* Check if it makes any sense to wait for a connect event, this condition - might change while sleeping, so it must be checked within each loop */ - xResult = bMayConnect( pxSocket ); /* -EINPROGRESS, -EAGAIN, or 0 for OK */ - - /* Start the connect procedure, kernel will start working on it */ - if( xResult == 0 ) - { - pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE_UNSIGNED; - pxSocket->u.xTCP.ucRepCount = 0u; - - FreeRTOS_debug_printf( ( "FreeRTOS_connect: %u to %lxip:%u\n", - pxSocket->usLocalPort, FreeRTOS_ntohl( pxAddress->sin_addr ), FreeRTOS_ntohs( pxAddress->sin_port ) ) ); - - /* Port on remote machine. */ - pxSocket->u.xTCP.usRemotePort = FreeRTOS_ntohs( pxAddress->sin_port ); - - /* IP address of remote machine. */ - pxSocket->u.xTCP.ulRemoteIP = FreeRTOS_ntohl( pxAddress->sin_addr ); - - /* (client) internal state: socket wants to send a connect. */ - vTCPStateChange( pxSocket, eCONNECT_SYN ); - - /* To start an active connect. */ - pxSocket->u.xTCP.usTimeout = 1u; - - if( xSendEventToIPTask( eTCPTimerEvent ) != pdPASS ) - { - xResult = -pdFREERTOS_ERRNO_ECANCELED; - } - } - } - - return xResult; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* - * FreeRTOS_connect: socket wants to connect to a remote port - */ - BaseType_t FreeRTOS_connect( Socket_t xClientSocket, struct freertos_sockaddr *pxAddress, socklen_t xAddressLength ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t* ) xClientSocket; - TickType_t xRemainingTime; - BaseType_t xTimed = pdFALSE; - BaseType_t xResult; - TimeOut_t xTimeOut; - - ( void ) xAddressLength; - - xResult = prvTCPConnectStart( pxSocket, pxAddress ); - - if( xResult == 0 ) - { - /* And wait for the result */ - for( ;; ) - { - if( xTimed == pdFALSE ) - { - /* Only in the first round, check for non-blocking */ - xRemainingTime = pxSocket->xReceiveBlockTime; - if( xRemainingTime == ( TickType_t )0 ) - { - /* Not yet connected, correct state, non-blocking. */ - xResult = -pdFREERTOS_ERRNO_EWOULDBLOCK; - break; - } - - /* Don't get here a second time. */ - xTimed = pdTRUE; - - /* Fetch the current time */ - vTaskSetTimeOutState( &xTimeOut ); - } - - /* Did it get connected while sleeping ? */ - xResult = FreeRTOS_issocketconnected( pxSocket ); - - /* Returns positive when connected, negative means an error */ - if( xResult < 0 ) - { - /* Return the error */ - break; - } - - if( xResult > 0 ) - { - /* Socket now connected, return a zero */ - xResult = 0; - break; - } - - /* Is it allowed to sleep more? */ - if( xTaskCheckForTimeOut( &xTimeOut, &xRemainingTime ) ) - { - xResult = -pdFREERTOS_ERRNO_ETIMEDOUT; - break; - } - - /* Go sleeping until we get any down-stream event */ - xEventGroupWaitBits( pxSocket->xEventGroup, eSOCKET_CONNECT, pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, xRemainingTime ); - } - } - - return xResult; - } -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* - * FreeRTOS_accept: can return a new connected socket - * if the server socket is in listen mode and receives a connection request - * The new socket will be bound already to the same port number as the listing - * socket. - */ - Socket_t FreeRTOS_accept( Socket_t xServerSocket, struct freertos_sockaddr *pxAddress, socklen_t *pxAddressLength ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xServerSocket; - FreeRTOS_Socket_t *pxClientSocket = NULL; - TickType_t xRemainingTime; - BaseType_t xTimed = pdFALSE, xAsk = pdFALSE; - TimeOut_t xTimeOut; - IPStackEvent_t xAskEvent; - - if( prvValidSocket( pxSocket, FREERTOS_IPPROTO_TCP, pdTRUE ) == pdFALSE ) - { - /* Not a valid socket or wrong type */ - pxClientSocket = ( FreeRTOS_Socket_t * ) FREERTOS_INVALID_SOCKET; - } - else if( ( pxSocket->u.xTCP.bits.bReuseSocket == pdFALSE_UNSIGNED ) && - ( pxSocket->u.xTCP.ucTCPState != eTCP_LISTEN ) ) - { - /* Parent socket is not in listening mode */ - pxClientSocket = ( FreeRTOS_Socket_t * ) FREERTOS_INVALID_SOCKET; - } - else - { - /* Loop will stop with breaks. */ - for( ; ; ) - { - /* Is there a new client? */ - vTaskSuspendAll(); - { - if( pxSocket->u.xTCP.bits.bReuseSocket == pdFALSE_UNSIGNED ) - { - pxClientSocket = pxSocket->u.xTCP.pxPeerSocket; - } - else - { - pxClientSocket = pxSocket; - } - if( pxClientSocket != NULL ) - { - pxSocket->u.xTCP.pxPeerSocket = NULL; - - /* Is it still not taken ? */ - if( pxClientSocket->u.xTCP.bits.bPassAccept != pdFALSE_UNSIGNED ) - { - pxClientSocket->u.xTCP.bits.bPassAccept = pdFALSE_UNSIGNED; - } - else - { - pxClientSocket = NULL; - } - } - } - xTaskResumeAll(); - - if( pxClientSocket != NULL ) - { - if( pxAddress != NULL ) - { - /* IP address of remote machine. */ - pxAddress->sin_addr = FreeRTOS_ntohl( pxClientSocket->u.xTCP.ulRemoteIP ); - - /* Port on remote machine. */ - pxAddress->sin_port = FreeRTOS_ntohs( pxClientSocket->u.xTCP.usRemotePort ); - } - if( pxAddressLength != NULL ) - { - *pxAddressLength = sizeof( *pxAddress ); - } - - if( pxSocket->u.xTCP.bits.bReuseSocket == pdFALSE_UNSIGNED ) - { - xAsk = pdTRUE; - } - } - - if( xAsk != pdFALSE ) - { - /* Ask to set an event in 'xEventGroup' as soon as a new - client gets connected for this listening socket. */ - xAskEvent.eEventType = eTCPAcceptEvent; - xAskEvent.pvData = ( void * ) pxSocket; - xSendEventStructToIPTask( &xAskEvent, portMAX_DELAY ); - } - - if( pxClientSocket != NULL ) - { - break; - } - - if( xTimed == pdFALSE ) - { - /* Only in the first round, check for non-blocking */ - xRemainingTime = pxSocket->xReceiveBlockTime; - if( xRemainingTime == ( TickType_t ) 0 ) - { - break; - } - - /* Don't get here a second time */ - xTimed = pdTRUE; - - /* Fetch the current time */ - vTaskSetTimeOutState( &xTimeOut ); - } - - /* Has the timeout been reached? */ - if( xTaskCheckForTimeOut( &xTimeOut, &xRemainingTime ) != pdFALSE ) - { - break; - } - - /* Go sleeping until we get any down-stream event */ - xEventGroupWaitBits( pxSocket->xEventGroup, eSOCKET_ACCEPT, pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, xRemainingTime ); - } - } - - return ( Socket_t ) pxClientSocket; - } -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* - * Read incoming data from a TCP socket - * Only after the last byte has been read, a close error might be returned - */ - BaseType_t FreeRTOS_recv( Socket_t xSocket, void *pvBuffer, size_t xBufferLength, BaseType_t xFlags ) - { - BaseType_t xByteCount; - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - TickType_t xRemainingTime; - BaseType_t xTimed = pdFALSE; - TimeOut_t xTimeOut; - EventBits_t xEventBits = ( EventBits_t ) 0; - - /* Check if the socket is valid, has type TCP and if it is bound to a - port. */ - if( prvValidSocket( pxSocket, FREERTOS_IPPROTO_TCP, pdTRUE ) == pdFALSE ) - { - xByteCount = -pdFREERTOS_ERRNO_EINVAL; - } - else - { - if( pxSocket->u.xTCP.rxStream != NULL ) - { - xByteCount = ( BaseType_t )uxStreamBufferGetSize ( pxSocket->u.xTCP.rxStream ); - } - else - { - xByteCount = 0; - } - - while( xByteCount == 0 ) - { - switch( pxSocket->u.xTCP.ucTCPState ) - { - case eCLOSED: - case eCLOSE_WAIT: /* (server + client) waiting for a connection termination request from the local user. */ - case eCLOSING: /* (server + client) waiting for a connection termination request acknowledgement from the remote TCP. */ - if( pxSocket->u.xTCP.bits.bMallocError != pdFALSE_UNSIGNED ) - { - /* The no-memory error has priority above the non-connected error. - Both are fatal and will elad to closing the socket. */ - xByteCount = -pdFREERTOS_ERRNO_ENOMEM; - } - else - { - xByteCount = -pdFREERTOS_ERRNO_ENOTCONN; - } - /* Call continue to break out of the switch and also the while - loop. */ - continue; - default: - break; - } - - if( xTimed == pdFALSE ) - { - /* Only in the first round, check for non-blocking. */ - xRemainingTime = pxSocket->xReceiveBlockTime; - - if( xRemainingTime == ( TickType_t ) 0 ) - { - #if( ipconfigSUPPORT_SIGNALS != 0 ) - { - /* Just check for the interrupt flag. */ - xEventBits = xEventGroupWaitBits( pxSocket->xEventGroup, eSOCKET_INTR, - pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, socketDONT_BLOCK ); - } - #endif /* ipconfigSUPPORT_SIGNALS */ - break; - } - - if( ( xFlags & FREERTOS_MSG_DONTWAIT ) != 0 ) - { - break; - } - - /* Don't get here a second time. */ - xTimed = pdTRUE; - - /* Fetch the current time. */ - vTaskSetTimeOutState( &xTimeOut ); - } - - /* Has the timeout been reached? */ - if( xTaskCheckForTimeOut( &xTimeOut, &xRemainingTime ) != pdFALSE ) - { - break; - } - - /* Block until there is a down-stream event. */ - xEventBits = xEventGroupWaitBits( pxSocket->xEventGroup, - eSOCKET_RECEIVE | eSOCKET_CLOSED | eSOCKET_INTR, - pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, xRemainingTime ); - #if( ipconfigSUPPORT_SIGNALS != 0 ) - { - if( ( xEventBits & eSOCKET_INTR ) != 0u ) - { - break; - } - } - #else - { - ( void ) xEventBits; - } - #endif /* ipconfigSUPPORT_SIGNALS */ - - if( pxSocket->u.xTCP.rxStream != NULL ) - { - xByteCount = ( BaseType_t ) uxStreamBufferGetSize ( pxSocket->u.xTCP.rxStream ); - } - else - { - xByteCount = 0; - } - } - - #if( ipconfigSUPPORT_SIGNALS != 0 ) - if( ( xEventBits & eSOCKET_INTR ) != 0 ) - { - if( ( xEventBits & ( eSOCKET_RECEIVE | eSOCKET_CLOSED ) ) != 0 ) - { - /* Shouldn't have cleared other flags. */ - xEventBits &= ~eSOCKET_INTR; - xEventGroupSetBits( pxSocket->xEventGroup, xEventBits ); - } - xByteCount = -pdFREERTOS_ERRNO_EINTR; - } - else - #endif /* ipconfigSUPPORT_SIGNALS */ - if( xByteCount > 0 ) - { - if( ( xFlags & FREERTOS_ZERO_COPY ) == 0 ) - { - xByteCount = ( BaseType_t ) uxStreamBufferGet( pxSocket->u.xTCP.rxStream, 0ul, ( uint8_t * ) pvBuffer, ( size_t ) xBufferLength, ( xFlags & FREERTOS_MSG_PEEK ) != 0 ); - if( pxSocket->u.xTCP.bits.bLowWater != pdFALSE_UNSIGNED ) - { - /* We had reached the low-water mark, now see if the flag - can be cleared */ - size_t uxFrontSpace = uxStreamBufferFrontSpace( pxSocket->u.xTCP.rxStream ); - - if( uxFrontSpace >= pxSocket->u.xTCP.uxEnoughSpace ) - { - pxSocket->u.xTCP.bits.bLowWater = pdFALSE_UNSIGNED; - pxSocket->u.xTCP.bits.bWinChange = pdTRUE_UNSIGNED; - pxSocket->u.xTCP.usTimeout = 1u; /* because bLowWater is cleared. */ - xSendEventToIPTask( eTCPTimerEvent ); - } - } - } - else - { - /* Zero-copy reception of data: pvBuffer is a pointer to a pointer. */ - xByteCount = ( BaseType_t ) uxStreamBufferGetPtr( pxSocket->u.xTCP.rxStream, (uint8_t **)pvBuffer ); - } - } - } /* prvValidSocket() */ - - return xByteCount; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - static int32_t prvTCPSendCheck( FreeRTOS_Socket_t *pxSocket, size_t xDataLength ) - { - int32_t xResult = 1; - - /* Is this a socket of type TCP and is it already bound to a port number ? */ - if( prvValidSocket( pxSocket, FREERTOS_IPPROTO_TCP, pdTRUE ) == pdFALSE ) - { - xResult = -pdFREERTOS_ERRNO_EINVAL; - } - else if( pxSocket->u.xTCP.bits.bMallocError != pdFALSE_UNSIGNED ) - { - xResult = -pdFREERTOS_ERRNO_ENOMEM; - } - else if( pxSocket->u.xTCP.ucTCPState == eCLOSED ) - { - xResult = -pdFREERTOS_ERRNO_ENOTCONN; - } - else if( pxSocket->u.xTCP.bits.bFinSent != pdFALSE_UNSIGNED ) - { - /* This TCP connection is closing already, the FIN flag has been sent. - Maybe it is still delivering or receiving data. - Return OK in order not to get closed/deleted too quickly */ - xResult = 0; - } - else if( xDataLength == 0ul ) - { - /* send() is being called to send zero bytes */ - xResult = 0; - } - else if( pxSocket->u.xTCP.txStream == NULL ) - { - /* Create the outgoing stream only when it is needed */ - prvTCPCreateStream( pxSocket, pdFALSE ); - - if( pxSocket->u.xTCP.txStream == NULL ) - { - xResult = -pdFREERTOS_ERRNO_ENOMEM; - } - } - - return xResult; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* Get a direct pointer to the circular transmit buffer. - '*pxLength' will contain the number of bytes that may be written. */ - uint8_t *FreeRTOS_get_tx_head( Socket_t xSocket, BaseType_t *pxLength ) - { - uint8_t *pucReturn; - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - StreamBuffer_t *pxBuffer = pxSocket->u.xTCP.txStream; - - if( pxBuffer != NULL ) - { - BaseType_t xSpace = ( BaseType_t ) uxStreamBufferGetSpace( pxBuffer ); - BaseType_t xRemain = ( BaseType_t ) ( pxBuffer->LENGTH - pxBuffer->uxHead ); - - *pxLength = FreeRTOS_min_BaseType( xSpace, xRemain ); - pucReturn = pxBuffer->ucArray + pxBuffer->uxHead; - } - else - { - *pxLength = 0; - pucReturn = NULL; - } - - return pucReturn; - } -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - /* - * Send data using a TCP socket. It is not necessary to have the socket - * connected already. Outgoing data will be stored and delivered as soon as - * the socket gets connected. - */ - BaseType_t FreeRTOS_send( Socket_t xSocket, const void *pvBuffer, size_t uxDataLength, BaseType_t xFlags ) - { - BaseType_t xByteCount; - BaseType_t xBytesLeft; - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - TickType_t xRemainingTime; - BaseType_t xTimed = pdFALSE; - TimeOut_t xTimeOut; - BaseType_t xCloseAfterSend; - - /* Prevent compiler warnings about unused parameters. The parameter - may be used in future versions. */ - ( void ) xFlags; - - xByteCount = ( BaseType_t ) prvTCPSendCheck( pxSocket, uxDataLength ); - - if( xByteCount > 0 ) - { - /* xBytesLeft is number of bytes to send, will count to zero. */ - xBytesLeft = ( BaseType_t ) uxDataLength; - - /* xByteCount is number of bytes that can be sent now. */ - xByteCount = ( BaseType_t ) uxStreamBufferGetSpace( pxSocket->u.xTCP.txStream ); - - /* While there are still bytes to be sent. */ - while( xBytesLeft > 0 ) - { - /* If txStream has space. */ - if( xByteCount > 0 ) - { - /* Don't send more than necessary. */ - if( xByteCount > xBytesLeft ) - { - xByteCount = xBytesLeft; - } - - /* Is the close-after-send flag set and is this really the - last transmission? */ - if( ( pxSocket->u.xTCP.bits.bCloseAfterSend != pdFALSE_UNSIGNED ) && ( xByteCount == xBytesLeft ) ) - { - xCloseAfterSend = pdTRUE; - } - else - { - xCloseAfterSend = pdFALSE; - } - - /* The flag 'bCloseAfterSend' can be set before sending data - using setsockopt() - - When the last data packet is being sent out, a FIN flag will - be included to let the peer know that no more data is to be - expected. The use of 'bCloseAfterSend' is not mandatory, it - is just a faster way of transferring files (e.g. when using - FTP). */ - if( xCloseAfterSend != pdFALSE ) - { - /* Now suspend the scheduler: sending the last data and - setting bCloseRequested must be done together */ - vTaskSuspendAll(); - pxSocket->u.xTCP.bits.bCloseRequested = pdTRUE_UNSIGNED; - } - - xByteCount = ( BaseType_t ) uxStreamBufferAdd( pxSocket->u.xTCP.txStream, 0ul, ( const uint8_t * ) pvBuffer, ( size_t ) xByteCount ); - - if( xCloseAfterSend != pdFALSE ) - { - /* Now when the IP-task transmits the data, it will also - see that bCloseRequested is true and include the FIN - flag to start closure of the connection. */ - xTaskResumeAll(); - } - - /* Send a message to the IP-task so it can work on this - socket. Data is sent, let the IP-task work on it. */ - pxSocket->u.xTCP.usTimeout = 1u; - - if( xIsCallingFromIPTask() == pdFALSE ) - { - /* Only send a TCP timer event when not called from the - IP-task. */ - xSendEventToIPTask( eTCPTimerEvent ); - } - - xBytesLeft -= xByteCount; - - if( xBytesLeft == 0 ) - { - break; - } - - /* As there are still bytes left to be sent, increase the - data pointer. */ - pvBuffer = ( void * ) ( ( ( const uint8_t * ) pvBuffer) + xByteCount ); - } - - /* Not all bytes have been sent. In case the socket is marked as - blocking sleep for a while. */ - if( xTimed == pdFALSE ) - { - /* Only in the first round, check for non-blocking. */ - xRemainingTime = pxSocket->xSendBlockTime; - - #if( ipconfigUSE_CALLBACKS != 0 ) - { - if( xIsCallingFromIPTask() != pdFALSE ) - { - /* If this send function is called from within a - call-back handler it may not block, otherwise - chances would be big to get a deadlock: the IP-task - waiting for itself. */ - xRemainingTime = ( TickType_t ) 0; - } - } - #endif /* ipconfigUSE_CALLBACKS */ - - if( xRemainingTime == ( TickType_t ) 0 ) - { - break; - } - - if( ( xFlags & FREERTOS_MSG_DONTWAIT ) != 0 ) - { - break; - } - - /* Don't get here a second time. */ - xTimed = pdTRUE; - - /* Fetch the current time. */ - vTaskSetTimeOutState( &xTimeOut ); - } - else - { - /* Has the timeout been reached? */ - if( xTaskCheckForTimeOut( &xTimeOut, &xRemainingTime ) != pdFALSE ) - { - break; - } - } - - /* Go sleeping until down-stream events are received. */ - xEventGroupWaitBits( pxSocket->xEventGroup, eSOCKET_SEND | eSOCKET_CLOSED, - pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, xRemainingTime ); - - xByteCount = ( BaseType_t ) uxStreamBufferGetSpace( pxSocket->u.xTCP.txStream ); - } - - /* How much was actually sent? */ - xByteCount = ( ( BaseType_t ) uxDataLength ) - xBytesLeft; - - if( xByteCount == 0 ) - { - if( pxSocket->u.xTCP.ucTCPState > eESTABLISHED ) - { - xByteCount = ( BaseType_t ) -pdFREERTOS_ERRNO_ENOTCONN; - } - else - { - if( ipconfigTCP_MAY_LOG_PORT( pxSocket->usLocalPort ) != pdFALSE ) - { - FreeRTOS_debug_printf( ( "FreeRTOS_send: %u -> %lxip:%d: no space\n", - pxSocket->usLocalPort, - pxSocket->u.xTCP.ulRemoteIP, - pxSocket->u.xTCP.usRemotePort ) ); - } - - xByteCount = ( BaseType_t ) -pdFREERTOS_ERRNO_ENOSPC; - } - } - } - - return xByteCount; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* - * Request to put a socket in listen mode - */ - BaseType_t FreeRTOS_listen( Socket_t xSocket, BaseType_t xBacklog ) - { - FreeRTOS_Socket_t *pxSocket; - BaseType_t xResult = 0; - - pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - - /* listen() is allowed for a valid TCP socket in Closed state and already - bound. */ - if( prvValidSocket( pxSocket, FREERTOS_IPPROTO_TCP, pdTRUE ) == pdFALSE ) - { - xResult = -pdFREERTOS_ERRNO_EOPNOTSUPP; - } - else if( ( pxSocket->u.xTCP.ucTCPState != eCLOSED ) && ( pxSocket->u.xTCP.ucTCPState != eCLOSE_WAIT ) ) - { - /* Socket is in a wrong state. */ - xResult = -pdFREERTOS_ERRNO_EOPNOTSUPP; - } - else - { - /* Backlog is interpreted here as "the maximum number of child - sockets. */ - pxSocket->u.xTCP.usBacklog = ( uint16_t )FreeRTOS_min_int32( ( int32_t ) 0xffff, ( int32_t ) xBacklog ); - - /* This cleaning is necessary only if a listening socket is being - reused as it might have had a previous connection. */ - if( pxSocket->u.xTCP.bits.bReuseSocket ) - { - if( pxSocket->u.xTCP.rxStream != NULL ) - { - vStreamBufferClear( pxSocket->u.xTCP.rxStream ); - } - - if( pxSocket->u.xTCP.txStream != NULL ) - { - vStreamBufferClear( pxSocket->u.xTCP.txStream ); - } - - memset( pxSocket->u.xTCP.xPacket.u.ucLastPacket, '\0', sizeof( pxSocket->u.xTCP.xPacket.u.ucLastPacket ) ); - memset( &pxSocket->u.xTCP.xTCPWindow, '\0', sizeof( pxSocket->u.xTCP.xTCPWindow ) ); - memset( &pxSocket->u.xTCP.bits, '\0', sizeof( pxSocket->u.xTCP.bits ) ); - - /* Now set the bReuseSocket flag again, because the bits have - just been cleared. */ - pxSocket->u.xTCP.bits.bReuseSocket = pdTRUE_UNSIGNED; - } - - vTCPStateChange( pxSocket, eTCP_LISTEN ); - } - - return xResult; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* shutdown - shut down part of a full-duplex connection */ - BaseType_t FreeRTOS_shutdown( Socket_t xSocket, BaseType_t xHow ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - BaseType_t xResult; - - if( prvValidSocket( pxSocket, FREERTOS_IPPROTO_TCP, pdTRUE ) == pdFALSE ) - { - /*_RB_ Is this comment correct? The socket is not of a type that - supports the listen() operation. */ - xResult = -pdFREERTOS_ERRNO_EOPNOTSUPP; - } - else if ( pxSocket->u.xTCP.ucTCPState != eESTABLISHED ) - { - /*_RB_ Is this comment correct? The socket is not of a type that - supports the listen() operation. */ - xResult = -pdFREERTOS_ERRNO_EOPNOTSUPP; - } - else - { - pxSocket->u.xTCP.bits.bUserShutdown = pdTRUE_UNSIGNED; - - /* Let the IP-task perform the shutdown of the connection. */ - pxSocket->u.xTCP.usTimeout = 1u; - xSendEventToIPTask( eTCPTimerEvent ); - xResult = 0; - } - (void) xHow; - - return xResult; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* - * A TCP timer has expired, now check all TCP sockets for: - * - Active connect - * - Send a delayed ACK - * - Send new data - * - Send a keep-alive packet - * - Check for timeout (in non-connected states only) - */ - TickType_t xTCPTimerCheck( BaseType_t xWillSleep ) - { - FreeRTOS_Socket_t *pxSocket; - TickType_t xShortest = pdMS_TO_TICKS( ( TickType_t ) ipTCP_TIMER_PERIOD_MS ); - TickType_t xNow = xTaskGetTickCount(); - static TickType_t xLastTime = 0u; - TickType_t xDelta = xNow - xLastTime; - ListItem_t* pxEnd = ( ListItem_t * ) listGET_END_MARKER( &xBoundTCPSocketsList ); - ListItem_t *pxIterator = ( ListItem_t * ) listGET_HEAD_ENTRY( &xBoundTCPSocketsList ); - - xLastTime = xNow; - - if( xDelta == 0u ) - { - xDelta = 1u; - } - - while( pxIterator != pxEnd ) - { - pxSocket = ( FreeRTOS_Socket_t * )listGET_LIST_ITEM_OWNER( pxIterator ); - pxIterator = ( ListItem_t * ) listGET_NEXT( pxIterator ); - - /* Sockets with 'tmout == 0' do not need any regular attention. */ - if( pxSocket->u.xTCP.usTimeout == 0u ) - { - continue; - } - - if( xDelta < ( TickType_t ) pxSocket->u.xTCP.usTimeout ) - { - pxSocket->u.xTCP.usTimeout = ( uint16_t ) ( ( ( TickType_t ) pxSocket->u.xTCP.usTimeout ) - xDelta ); - } - else - { - int rc ; - pxSocket->u.xTCP.usTimeout = 0u; - rc = xTCPSocketCheck( pxSocket ); - - /* Within this function, the socket might want to send a delayed - ack or send out data or whatever it needs to do. */ - if( rc < 0 ) - { - /* Continue because the socket was deleted. */ - continue; - } - } - - /* In xEventBits the driver may indicate that the socket has - important events for the user. These are only done just before the - IP-task goes to sleep. */ - if( pxSocket->xEventBits != 0u ) - { - if( xWillSleep != pdFALSE ) - { - /* The IP-task is about to go to sleep, so messages can be - sent to the socket owners. */ - vSocketWakeUpUser( pxSocket ); - } - else - { - /* Or else make sure this will be called again to wake-up - the sockets' owner. */ - xShortest = ( TickType_t ) 0; - } - } - - if( ( pxSocket->u.xTCP.usTimeout != 0u ) && ( xShortest > ( TickType_t ) pxSocket->u.xTCP.usTimeout ) ) - { - xShortest = ( TickType_t ) pxSocket->u.xTCP.usTimeout; - } - } - - return xShortest; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* - * TCP: as multiple sockets may be bound to the same local port number - * looking up a socket is a little more complex: - * Both a local port, and a remote port and IP address are being used - * For a socket in listening mode, the remote port and IP address are both 0 - */ - FreeRTOS_Socket_t *pxTCPSocketLookup( uint32_t ulLocalIP, UBaseType_t uxLocalPort, uint32_t ulRemoteIP, UBaseType_t uxRemotePort ) - { - ListItem_t *pxIterator; - FreeRTOS_Socket_t *pxResult = NULL, *pxListenSocket = NULL; - MiniListItem_t *pxEnd = ( MiniListItem_t* )listGET_END_MARKER( &xBoundTCPSocketsList ); - - /* Parameter not yet supported. */ - ( void ) ulLocalIP; - - for( pxIterator = ( ListItem_t * ) listGET_NEXT( pxEnd ); - pxIterator != ( ListItem_t * ) pxEnd; - pxIterator = ( ListItem_t * ) listGET_NEXT( pxIterator ) ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); - - if( pxSocket->usLocalPort == ( uint16_t ) uxLocalPort ) - { - if( pxSocket->u.xTCP.ucTCPState == eTCP_LISTEN ) - { - /* If this is a socket listening to uxLocalPort, remember it - in case there is no perfect match. */ - pxListenSocket = pxSocket; - } - else if( ( pxSocket->u.xTCP.usRemotePort == ( uint16_t ) uxRemotePort ) && ( pxSocket->u.xTCP.ulRemoteIP == ulRemoteIP ) ) - { - /* For sockets not in listening mode, find a match with - xLocalPort, ulRemoteIP AND xRemotePort. */ - pxResult = pxSocket; - break; - } - } - } - if( pxResult == NULL ) - { - /* An exact match was not found, maybe a listening socket was - found. */ - pxResult = pxListenSocket; - } - - return pxResult; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - const struct xSTREAM_BUFFER *FreeRTOS_get_rx_buf( Socket_t xSocket ) - { - FreeRTOS_Socket_t *pxSocket = (FreeRTOS_Socket_t *)xSocket; - - return pxSocket->u.xTCP.rxStream; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - static StreamBuffer_t *prvTCPCreateStream ( FreeRTOS_Socket_t *pxSocket, BaseType_t xIsInputStream ) - { - StreamBuffer_t *pxBuffer; - size_t uxLength; - size_t uxSize; - - /* Now that a stream is created, the maximum size is fixed before - creation, it could still be changed with setsockopt(). */ - if( xIsInputStream != pdFALSE ) - { - uxLength = pxSocket->u.xTCP.uxRxStreamSize; - - if( pxSocket->u.xTCP.uxLittleSpace == 0ul ) - { - pxSocket->u.xTCP.uxLittleSpace = ( 1ul * pxSocket->u.xTCP.uxRxStreamSize ) / 5u; /*_RB_ Why divide by 5? Can this be changed to a #define? */ - } - - if( pxSocket->u.xTCP.uxEnoughSpace == 0ul ) - { - pxSocket->u.xTCP.uxEnoughSpace = ( 4ul * pxSocket->u.xTCP.uxRxStreamSize ) / 5u; /*_RB_ Why multiply by 4? Maybe sock80_PERCENT?*/ - } - } - else - { - uxLength = pxSocket->u.xTCP.uxTxStreamSize; - } - - /* Add an extra 4 (or 8) bytes. */ - uxLength += sizeof( size_t ); - - /* And make the length a multiple of sizeof( size_t ). */ - uxLength &= ~( sizeof( size_t ) - 1u ); - - uxSize = sizeof( *pxBuffer ) - sizeof( pxBuffer->ucArray ) + uxLength; - - pxBuffer = ( StreamBuffer_t * )pvPortMallocLarge( uxSize ); - - if( pxBuffer == NULL ) - { - FreeRTOS_debug_printf( ( "prvTCPCreateStream: malloc failed\n" ) ); - pxSocket->u.xTCP.bits.bMallocError = pdTRUE_UNSIGNED; - vTCPStateChange( pxSocket, eCLOSE_WAIT ); - } - else - { - /* Clear the markers of the stream */ - memset( pxBuffer, '\0', sizeof( *pxBuffer ) - sizeof( pxBuffer->ucArray ) ); - pxBuffer->LENGTH = ( size_t ) uxLength ; - - if( xTCPWindowLoggingLevel != 0 ) - { - FreeRTOS_debug_printf( ( "prvTCPCreateStream: %cxStream created %lu bytes (total %lu)\n", xIsInputStream ? 'R' : 'T', uxLength, uxSize ) ); - } - - if( xIsInputStream != 0 ) - { - pxSocket->u.xTCP.rxStream = pxBuffer; - } - else - { - pxSocket->u.xTCP.txStream = pxBuffer; - } - } - - return pxBuffer; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* - * Add data to the RxStream. When uxOffset > 0, data has come in out-of-order - * and will be put in front of the head so it can not be popped by the user. - */ - int32_t lTCPAddRxdata( FreeRTOS_Socket_t *pxSocket, size_t uxOffset, const uint8_t *pcData, uint32_t ulByteCount ) - { - StreamBuffer_t *pxStream = pxSocket->u.xTCP.rxStream; - int32_t xResult; - #if( ipconfigUSE_CALLBACKS == 1 ) - BaseType_t bHasHandler = ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xTCP.pxHandleReceive ); - const uint8_t *pucBuffer = NULL; - #endif /* ipconfigUSE_CALLBACKS */ - - /* int32_t uxStreamBufferAdd( pxBuffer, uxOffset, pucData, aCount ) - if( pucData != NULL ) copy data the the buffer - if( pucData == NULL ) no copying, just advance rxHead - if( uxOffset != 0 ) Just store data which has come out-of-order - if( uxOffset == 0 ) Also advance rxHead */ - if( pxStream == NULL ) - { - pxStream = prvTCPCreateStream( pxSocket, pdTRUE ); - if( pxStream == NULL ) - { - return -1; - } - } - - #if( ipconfigUSE_CALLBACKS == 1 ) - { - if( ( bHasHandler != pdFALSE ) && ( uxStreamBufferGetSize( pxStream ) == 0u ) && ( uxOffset == 0ul ) && ( pcData != NULL ) ) - { - /* Data can be passed directly to the user */ - pucBuffer = pcData; - - /* Zero-copy for call-back: no need to add the bytes to the - stream, only the pointer will be advanced by uxStreamBufferAdd(). */ - pcData = NULL; - } - } - #endif /* ipconfigUSE_CALLBACKS */ - - xResult = ( int32_t ) uxStreamBufferAdd( pxStream, uxOffset, pcData, ( size_t ) ulByteCount ); - - #if( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - if( xResult != ( int32_t ) ulByteCount ) - { - FreeRTOS_debug_printf( ( "lTCPAddRxdata: at %ld: %ld/%lu bytes (tail %lu head %lu space %lu front %lu)\n", - uxOffset, xResult, ulByteCount, - pxStream->uxTail, - pxStream->uxHead, - uxStreamBufferFrontSpace( pxStream ), - pxStream->uxFront ) ); - } - } - #endif /* ipconfigHAS_DEBUG_PRINTF */ - - if( uxOffset == 0u ) - { - /* Data is being added to rxStream at the head (offs = 0) */ - #if( ipconfigUSE_CALLBACKS == 1 ) - if( bHasHandler != pdFALSE ) - { - /* The socket owner has installed an OnReceive handler. Pass the - Rx data, without copying from the rxStream, to the user. */ - for (;;) - { - uint8_t *ucReadPtr = NULL; - uint32_t ulCount; - if( pucBuffer != NULL ) - { - ucReadPtr = ( uint8_t * )pucBuffer; - ulCount = ulByteCount; - pucBuffer = NULL; - } - else - { - ulCount = ( uint32_t ) uxStreamBufferGetPtr( pxStream, &( ucReadPtr ) ); - } - - if( ulCount == 0ul ) - { - break; - } - - pxSocket->u.xTCP.pxHandleReceive( (Socket_t *)pxSocket, ( void* )ucReadPtr, ( size_t ) ulCount ); - uxStreamBufferGet( pxStream, 0ul, NULL, ( size_t ) ulCount, pdFALSE ); - } - } else - #endif /* ipconfigUSE_CALLBACKS */ - { - /* See if running out of space. */ - if( pxSocket->u.xTCP.bits.bLowWater == pdFALSE_UNSIGNED ) - { - size_t uxFrontSpace = uxStreamBufferFrontSpace( pxSocket->u.xTCP.rxStream ); - if( uxFrontSpace <= pxSocket->u.xTCP.uxLittleSpace ) - { - pxSocket->u.xTCP.bits.bLowWater = pdTRUE_UNSIGNED; - pxSocket->u.xTCP.bits.bWinChange = pdTRUE_UNSIGNED; - - /* bLowWater was reached, send the changed window size. */ - pxSocket->u.xTCP.usTimeout = 1u; - xSendEventToIPTask( eTCPTimerEvent ); - } - } - - /* New incoming data is available, wake up the user. User's - semaphores will be set just before the IP-task goes asleep. */ - pxSocket->xEventBits |= eSOCKET_RECEIVE; - - #if ipconfigSUPPORT_SELECT_FUNCTION == 1 - { - if( ( pxSocket->xSelectBits & eSELECT_READ ) != 0 ) - { - pxSocket->xEventBits |= ( eSELECT_READ << SOCKET_EVENT_BIT_COUNT ); - } - } - #endif - } - } - - return xResult; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* Function to get the remote address and IP port */ - BaseType_t FreeRTOS_GetRemoteAddress( Socket_t xSocket, struct freertos_sockaddr *pxAddress ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - BaseType_t xResult; - - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - xResult = -pdFREERTOS_ERRNO_EINVAL; - } - else - { - /* BSD style sockets communicate IP and port addresses in network - byte order. - - IP address of remote machine. */ - pxAddress->sin_addr = FreeRTOS_htonl ( pxSocket->u.xTCP.ulRemoteIP ); - - /* Port on remote machine. */ - pxAddress->sin_port = FreeRTOS_htons ( pxSocket->u.xTCP.usRemotePort ); - - xResult = ( BaseType_t ) sizeof( ( *pxAddress ) ); - } - - return xResult; - } - -#endif /* ipconfigUSE_TCP */ - -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* Returns the number of bytes that may be added to txStream */ - BaseType_t FreeRTOS_maywrite( Socket_t xSocket ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - BaseType_t xResult; - - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - xResult = -pdFREERTOS_ERRNO_EINVAL; - } - else if( pxSocket->u.xTCP.ucTCPState != eESTABLISHED ) - { - if( ( pxSocket->u.xTCP.ucTCPState < eCONNECT_SYN ) || ( pxSocket->u.xTCP.ucTCPState > eESTABLISHED ) ) - { - xResult = -1; - } - else - { - xResult = 0; - } - } - else if( pxSocket->u.xTCP.txStream == NULL ) - { - xResult = ( BaseType_t ) pxSocket->u.xTCP.uxTxStreamSize; - } - else - { - xResult = ( BaseType_t ) uxStreamBufferGetSpace( pxSocket->u.xTCP.txStream ); - } - - return xResult; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP ==1 ) - - BaseType_t FreeRTOS_tx_space( Socket_t xSocket ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - BaseType_t xReturn; - - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - xReturn = -pdFREERTOS_ERRNO_EINVAL; - } - else - { - if( pxSocket->u.xTCP.txStream != NULL ) - { - xReturn = ( BaseType_t ) uxStreamBufferGetSpace ( pxSocket->u.xTCP.txStream ); - } - else - { - xReturn = ( BaseType_t ) pxSocket->u.xTCP.uxTxStreamSize; - } - } - - return xReturn; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - BaseType_t FreeRTOS_tx_size( Socket_t xSocket ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - BaseType_t xReturn; - - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - xReturn = -pdFREERTOS_ERRNO_EINVAL; - } - else - { - if( pxSocket->u.xTCP.txStream != NULL ) - { - xReturn = ( BaseType_t ) uxStreamBufferGetSize ( pxSocket->u.xTCP.txStream ); - } - else - { - xReturn = 0; - } - } - - return xReturn; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* Returns pdTRUE if TCP socket is connected. */ - BaseType_t FreeRTOS_issocketconnected( Socket_t xSocket ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - BaseType_t xReturn = pdFALSE; - - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - xReturn = -pdFREERTOS_ERRNO_EINVAL; - } - else - { - if( pxSocket->u.xTCP.ucTCPState >= eESTABLISHED ) - { - if( pxSocket->u.xTCP.ucTCPState < eCLOSE_WAIT ) - { - xReturn = pdTRUE; - } - } - } - - return xReturn; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* returns the actual size of MSS being used */ - BaseType_t FreeRTOS_mss( Socket_t xSocket ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - BaseType_t xReturn; - - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - xReturn = -pdFREERTOS_ERRNO_EINVAL; - } - else - { - /* usCurMSS is declared as uint16_t to save space. FreeRTOS_mss() - will often be used in signed native-size expressions cast it to - BaseType_t. */ - xReturn = ( BaseType_t ) ( pxSocket->u.xTCP.usCurMSS ); - } - - return xReturn; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* HT: for internal use only: return the connection status */ - BaseType_t FreeRTOS_connstatus( Socket_t xSocket ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - BaseType_t xReturn; - - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - xReturn = -pdFREERTOS_ERRNO_EINVAL; - } - else - { - /* Cast it to BaseType_t */ - xReturn = ( BaseType_t ) ( pxSocket->u.xTCP.ucTCPState ); - } - - return xReturn; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - /* - * Returns the number of bytes which can be read. - */ - BaseType_t FreeRTOS_rx_size( Socket_t xSocket ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - BaseType_t xReturn; - - if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - xReturn = -pdFREERTOS_ERRNO_EINVAL; - } - else if( pxSocket->u.xTCP.rxStream != NULL ) - { - xReturn = ( BaseType_t ) uxStreamBufferGetSize( pxSocket->u.xTCP.rxStream ); - } - else - { - xReturn = 0; - } - - return xReturn; - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP == 1 ) - - void FreeRTOS_netstat( void ) - { - IPStackEvent_t xAskEvent; - - /* Ask the IP-task to call vTCPNetStat() - * to avoid accessing xBoundTCPSocketsList - */ - xAskEvent.eEventType = eTCPNetStat; - xAskEvent.pvData = ( void * ) NULL; - xSendEventStructToIPTask( &xAskEvent, 1000u ); - } - -#endif /* ipconfigUSE_TCP */ -/*-----------------------------------------------------------*/ - -#if( ( ipconfigHAS_PRINTF != 0 ) && ( ipconfigUSE_TCP == 1 ) ) - - void vTCPNetStat( void ) - { - /* Show a simple listing of all created sockets and their connections */ - ListItem_t *pxIterator; - BaseType_t count = 0; - - if( listLIST_IS_INITIALISED( &xBoundTCPSocketsList ) == pdFALSE ) - { - FreeRTOS_printf( ( "PLUS-TCP not initialized\n" ) ); - } - else - { - FreeRTOS_printf( ( "Prot Port IP-Remote : Port R/T Status Alive tmout Child\n" ) ); - for( pxIterator = ( ListItem_t * ) listGET_HEAD_ENTRY( &xBoundTCPSocketsList ); - pxIterator != ( ListItem_t * ) listGET_END_MARKER( &xBoundTCPSocketsList ); - pxIterator = ( ListItem_t * ) listGET_NEXT( pxIterator ) ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); - #if( ipconfigTCP_KEEP_ALIVE == 1 ) - TickType_t age = xTaskGetTickCount() - pxSocket->u.xTCP.xLastAliveTime; - #else - TickType_t age = 0u; - #endif - #if( ipconfigUSE_CALLBACKS == 1 ) - void *pxHandleReceive = (void*)pxSocket->u.xTCP.pxHandleReceive; - #else - void *pxHandleReceive = (void*)NULL; - #endif - char ucChildText[16] = ""; - if (pxSocket->u.xTCP.ucTCPState == eTCP_LISTEN) - { - const int32_t copied_len = snprintf( ucChildText, sizeof( ucChildText ), " %d/%d", - ( int ) pxSocket->u.xTCP.usChildCount, - ( int ) pxSocket->u.xTCP.usBacklog); - /* These should never evaluate to false since the buffers are both shorter than 5-6 characters (<=65535) */ - configASSERT( copied_len >= 0 ); - configASSERT( copied_len < sizeof( ucChildText ) ); - } - FreeRTOS_printf( ( "TCP %5d %-16lxip:%5d %d/%d %-13.13s %6lu %6u%s\n", - pxSocket->usLocalPort, /* Local port on this machine */ - pxSocket->u.xTCP.ulRemoteIP, /* IP address of remote machine */ - pxSocket->u.xTCP.usRemotePort, /* Port on remote machine */ - pxSocket->u.xTCP.rxStream != NULL, - pxSocket->u.xTCP.txStream != NULL, - FreeRTOS_GetTCPStateName( pxSocket->u.xTCP.ucTCPState ), - (age > 999999 ? 999999 : age), /* Format 'age' for printing */ - pxSocket->u.xTCP.usTimeout, - ucChildText ) ); - /* Remove compiler warnings if FreeRTOS_debug_printf() is not defined. */ - ( void ) pxHandleReceive; - count++; - } - - for( pxIterator = ( ListItem_t * ) listGET_HEAD_ENTRY( &xBoundUDPSocketsList ); - pxIterator != ( ListItem_t * ) listGET_END_MARKER( &xBoundUDPSocketsList ); - pxIterator = ( ListItem_t * ) listGET_NEXT( pxIterator ) ) - { - /* Local port on this machine */ - FreeRTOS_printf( ( "UDP Port %5u\n", - FreeRTOS_ntohs( listGET_LIST_ITEM_VALUE( pxIterator ) ) ) ); - count++; - } - - FreeRTOS_printf( ( "FreeRTOS_netstat: %lu sockets %lu < %lu < %d buffers free\n", - count, - uxGetMinimumFreeNetworkBuffers( ), - uxGetNumberOfFreeNetworkBuffers( ), - ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ) ); - } - } - -#endif /* ( ( ipconfigHAS_PRINTF != 0 ) && ( ipconfigUSE_TCP == 1 ) ) */ -/*-----------------------------------------------------------*/ - -#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - - void vSocketSelect( SocketSelect_t *pxSocketSet ) - { - BaseType_t xRound; - EventBits_t xSocketBits, xBitsToClear; - #if ipconfigUSE_TCP == 1 - BaseType_t xLastRound = 1; - #else - BaseType_t xLastRound = 0; - #endif - - /* These flags will be switched on after checking the socket status. */ - EventBits_t xGroupBits = 0; - pxSocketSet->pxSocket = NULL; - - for( xRound = 0; xRound <= xLastRound; xRound++ ) - { - const ListItem_t *pxIterator; - const MiniListItem_t *pxEnd; - if( xRound == 0 ) - { - pxEnd = ( const MiniListItem_t* )listGET_END_MARKER( &xBoundUDPSocketsList ); - } - #if ipconfigUSE_TCP == 1 - else - { - pxEnd = ( const MiniListItem_t* )listGET_END_MARKER( &xBoundTCPSocketsList ); - } - #endif /* ipconfigUSE_TCP == 1 */ - for( pxIterator = ( const ListItem_t * ) ( listGET_NEXT( pxEnd ) ); - pxIterator != ( const ListItem_t * ) pxEnd; - pxIterator = ( const ListItem_t * ) listGET_NEXT( pxIterator ) ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); - if( pxSocket->pxSocketSet != pxSocketSet ) - { - /* Socket does not belong to this select group. */ - continue; - } - xSocketBits = 0; - - #if( ipconfigUSE_TCP == 1 ) - if( pxSocket->ucProtocol == FREERTOS_IPPROTO_TCP ) - { - /* Check if the socket has already been accepted by the - owner. If not, it is useless to return it from a - select(). */ - BaseType_t bAccepted = pdFALSE; - - if( pxSocket->u.xTCP.bits.bPassQueued == pdFALSE_UNSIGNED ) - { - if( pxSocket->u.xTCP.bits.bPassAccept == pdFALSE_UNSIGNED ) - { - bAccepted = pdTRUE; - } - } - - /* Is the set owner interested in READ events? */ - if( ( pxSocket->xSelectBits & eSELECT_READ ) != 0 ) - { - if( pxSocket->u.xTCP.ucTCPState == eTCP_LISTEN ) - { - if( ( pxSocket->u.xTCP.pxPeerSocket != NULL ) && ( pxSocket->u.xTCP.pxPeerSocket->u.xTCP.bits.bPassAccept != 0 ) ) - { - xSocketBits |= eSELECT_READ; - } - } - else if( ( pxSocket->u.xTCP.bits.bReuseSocket != pdFALSE_UNSIGNED ) && ( pxSocket->u.xTCP.bits.bPassAccept != pdFALSE_UNSIGNED ) ) - { - /* This socket has the re-use flag. After connecting it turns into - aconnected socket. Set the READ event, so that accept() will be called. */ - xSocketBits |= eSELECT_READ; - } - else if( ( bAccepted != 0 ) && ( FreeRTOS_recvcount( pxSocket ) > 0 ) ) - { - xSocketBits |= eSELECT_READ; - } - } - /* Is the set owner interested in EXCEPTION events? */ - if( ( pxSocket->xSelectBits & eSELECT_EXCEPT ) != 0 ) - { - if( ( pxSocket->u.xTCP.ucTCPState == eCLOSE_WAIT ) || ( pxSocket->u.xTCP.ucTCPState == eCLOSED ) ) - { - xSocketBits |= eSELECT_EXCEPT; - } - } - - /* Is the set owner interested in WRITE events? */ - if( ( pxSocket->xSelectBits & eSELECT_WRITE ) != 0 ) - { - BaseType_t bMatch = pdFALSE; - - if( bAccepted != 0 ) - { - if( FreeRTOS_tx_space( pxSocket ) > 0 ) - { - bMatch = pdTRUE; - } - } - - if( bMatch == pdFALSE ) - { - if( ( pxSocket->u.xTCP.bits.bConnPrepared != pdFALSE_UNSIGNED ) && - ( pxSocket->u.xTCP.ucTCPState >= eESTABLISHED ) && - ( pxSocket->u.xTCP.bits.bConnPassed == pdFALSE_UNSIGNED ) ) - { - pxSocket->u.xTCP.bits.bConnPassed = pdTRUE_UNSIGNED; - bMatch = pdTRUE; - } - } - - if( bMatch != pdFALSE ) - { - xSocketBits |= eSELECT_WRITE; - } - } - } - else - #endif /* ipconfigUSE_TCP == 1 */ - { - /* Select events for UDP are simpler. */ - if( ( ( pxSocket->xSelectBits & eSELECT_READ ) != 0 ) && - ( listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ) > 0U ) ) - { - xSocketBits |= eSELECT_READ; - } - /* The WRITE and EXCEPT bits are not used for UDP */ - } /* if( pxSocket->ucProtocol == FREERTOS_IPPROTO_TCP ) */ - - /* Each socket keeps its own event flags, which are looked-up - by FreeRTOS_FD_ISSSET() */ - pxSocket->xSocketBits = xSocketBits; - - /* The ORed value will be used to set the bits in the event - group. */ - xGroupBits |= xSocketBits; - - } /* for( pxIterator ... ) */ - } /* for( xRound = 0; xRound <= xLastRound; xRound++ ) */ - - xBitsToClear = xEventGroupGetBits( pxSocketSet->xSelectGroup ); - - /* Now set the necessary bits. */ - xBitsToClear = ( xBitsToClear & ~xGroupBits ) & eSELECT_ALL; - - #if( ipconfigSUPPORT_SIGNALS != 0 ) - { - /* Maybe the socketset was signalled, but don't - clear the 'eSELECT_INTR' bit here, as it will be used - and cleared in FreeRTOS_select(). */ - xBitsToClear &= ( EventBits_t ) ~eSELECT_INTR; - } - #endif /* ipconfigSUPPORT_SIGNALS */ - - if( xBitsToClear != 0 ) - { - xEventGroupClearBits( pxSocketSet->xSelectGroup, xBitsToClear ); - } - - /* Now include eSELECT_CALL_IP to wakeup the caller. */ - xEventGroupSetBits( pxSocketSet->xSelectGroup, xGroupBits | eSELECT_CALL_IP ); - } - -#endif /* ipconfigSUPPORT_SELECT_FUNCTION == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigSUPPORT_SIGNALS != 0 ) - - /* Send a signal to the task which reads from this socket. */ - BaseType_t FreeRTOS_SignalSocket( Socket_t xSocket ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - BaseType_t xReturn; - - if( pxSocket == NULL ) - { - xReturn = -pdFREERTOS_ERRNO_EINVAL; - } - else - #if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - if( ( pxSocket->pxSocketSet != NULL ) && ( pxSocket->pxSocketSet->xSelectGroup != NULL ) ) - { - xEventGroupSetBits( pxSocket->pxSocketSet->xSelectGroup, eSELECT_INTR ); - xReturn = 0; - } - else - #endif /* ipconfigSUPPORT_SELECT_FUNCTION */ - if( pxSocket->xEventGroup != NULL ) - { - xEventGroupSetBits( pxSocket->xEventGroup, eSOCKET_INTR ); - xReturn = 0; - } - else - { - xReturn = -pdFREERTOS_ERRNO_EINVAL; - } - - return xReturn; - } - -#endif /* ipconfigSUPPORT_SIGNALS */ -/*-----------------------------------------------------------*/ - -#if( ipconfigSUPPORT_SIGNALS != 0 ) - - /* Send a signal to the task which reads from this socket (FromISR version). */ - BaseType_t FreeRTOS_SignalSocketFromISR( Socket_t xSocket, BaseType_t *pxHigherPriorityTaskWoken ) - { - FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket; - BaseType_t xReturn; - IPStackEvent_t xEvent; - extern QueueHandle_t xNetworkEventQueue; - - configASSERT( pxSocket != NULL ); - configASSERT( pxSocket->ucProtocol == FREERTOS_IPPROTO_TCP ); - configASSERT( pxSocket->xEventGroup ); - - xEvent.eEventType = eSocketSignalEvent; - xEvent.pvData = ( void * )pxSocket; - - /* The IP-task will call FreeRTOS_SignalSocket for this socket. */ - xReturn = xQueueSendToBackFromISR( xNetworkEventQueue, &xEvent, pxHigherPriorityTaskWoken ); - - return xReturn; - } - -#endif /* ipconfigSUPPORT_SIGNALS */ -/*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Stream_Buffer.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Stream_Buffer.c deleted file mode 100755 index 09067f0..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Stream_Buffer.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -/* Standard includes. */ -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" - -/* - * uxStreamBufferAdd( ) - * Adds data to a stream buffer. If uxOffset > 0, data will be written at - * an offset from uxHead while uxHead will not be moved yet. This possibility - * will be used when TCP data is received while earlier data is still missing. - * If 'pucData' equals NULL, the function is called to advance 'uxHead' only. - */ -size_t uxStreamBufferAdd( StreamBuffer_t *pxBuffer, size_t uxOffset, const uint8_t *pucData, size_t uxCount ) -{ -size_t uxSpace, uxNextHead, uxFirst; - - uxSpace = uxStreamBufferGetSpace( pxBuffer ); - - /* If uxOffset > 0, items can be placed in front of uxHead */ - if( uxSpace > uxOffset ) - { - uxSpace -= uxOffset; - } - else - { - uxSpace = 0u; - } - - /* The number of bytes that can be written is the minimum of the number of - bytes requested and the number available. */ - uxCount = FreeRTOS_min_uint32( uxSpace, uxCount ); - - if( uxCount != 0u ) - { - uxNextHead = pxBuffer->uxHead; - - if( uxOffset != 0u ) - { - /* ( uxOffset > 0 ) means: write in front if the uxHead marker */ - uxNextHead += uxOffset; - if( uxNextHead >= pxBuffer->LENGTH ) - { - uxNextHead -= pxBuffer->LENGTH; - } - } - - if( pucData != NULL ) - { - /* Calculate the number of bytes that can be added in the first - write - which may be less than the total number of bytes that need - to be added if the buffer will wrap back to the beginning. */ - uxFirst = FreeRTOS_min_uint32( pxBuffer->LENGTH - uxNextHead, uxCount ); - - /* Write as many bytes as can be written in the first write. */ - memcpy( ( void* ) ( pxBuffer->ucArray + uxNextHead ), pucData, uxFirst ); - - /* If the number of bytes written was less than the number that - could be written in the first write... */ - if( uxCount > uxFirst ) - { - /* ...then write the remaining bytes to the start of the - buffer. */ - memcpy( ( void * )pxBuffer->ucArray, pucData + uxFirst, uxCount - uxFirst ); - } - } - - if( uxOffset == 0u ) - { - /* ( uxOffset == 0 ) means: write at uxHead position */ - uxNextHead += uxCount; - if( uxNextHead >= pxBuffer->LENGTH ) - { - uxNextHead -= pxBuffer->LENGTH; - } - pxBuffer->uxHead = uxNextHead; - } - - if( xStreamBufferLessThenEqual( pxBuffer, pxBuffer->uxFront, uxNextHead ) != pdFALSE ) - { - /* Advance the front pointer */ - pxBuffer->uxFront = uxNextHead; - } - } - - return uxCount; -} -/*-----------------------------------------------------------*/ - -/* - * uxStreamBufferGet( ) - * 'uxOffset' can be used to read data located at a certain offset from 'lTail'. - * If 'pucData' equals NULL, the function is called to advance 'lTail' only. - * if 'xPeek' is pdTRUE, or if 'uxOffset' is non-zero, the 'lTail' pointer will - * not be advanced. - */ -size_t uxStreamBufferGet( StreamBuffer_t *pxBuffer, size_t uxOffset, uint8_t *pucData, size_t uxMaxCount, BaseType_t xPeek ) -{ -size_t uxSize, uxCount, uxFirst, uxNextTail; - - /* How much data is available? */ - uxSize = uxStreamBufferGetSize( pxBuffer ); - - if( uxSize > uxOffset ) - { - uxSize -= uxOffset; - } - else - { - uxSize = 0u; - } - - /* Use the minimum of the wanted bytes and the available bytes. */ - uxCount = FreeRTOS_min_uint32( uxSize, uxMaxCount ); - - if( uxCount > 0u ) - { - uxNextTail = pxBuffer->uxTail; - - if( uxOffset != 0u ) - { - uxNextTail += uxOffset; - if( uxNextTail >= pxBuffer->LENGTH ) - { - uxNextTail -= pxBuffer->LENGTH; - } - } - - if( pucData != NULL ) - { - /* Calculate the number of bytes that can be read - which may be - less than the number wanted if the data wraps around to the start of - the buffer. */ - uxFirst = FreeRTOS_min_uint32( pxBuffer->LENGTH - uxNextTail, uxCount ); - - /* Obtain the number of bytes it is possible to obtain in the first - read. */ - memcpy( pucData, pxBuffer->ucArray + uxNextTail, uxFirst ); - - /* If the total number of wanted bytes is greater than the number - that could be read in the first read... */ - if( uxCount > uxFirst ) - { - /*...then read the remaining bytes from the start of the buffer. */ - memcpy( pucData + uxFirst, pxBuffer->ucArray, uxCount - uxFirst ); - } - } - - if( ( xPeek == pdFALSE ) && ( uxOffset == 0UL ) ) - { - /* Move the tail pointer to effecively remove the data read from - the buffer. */ - uxNextTail += uxCount; - - if( uxNextTail >= pxBuffer->LENGTH ) - { - uxNextTail -= pxBuffer->LENGTH; - } - - pxBuffer->uxTail = uxNextTail; - } - } - - return uxCount; -} - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_TCP_IP.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_TCP_IP.c deleted file mode 100755 index 27e6484..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_TCP_IP.c +++ /dev/null @@ -1,3309 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -/* - * FreeRTOS_TCP_IP.c - * Module which handles the TCP connections for FreeRTOS+TCP. - * It depends on FreeRTOS_TCP_WIN.c, which handles the TCP windowing - * schemes. - * - * Endianness: in this module all ports and IP addresses are stored in - * host byte-order, except fields in the IP-packets - */ - -/* Standard includes. */ -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_TCP_IP.h" -#include "FreeRTOS_DHCP.h" -#include "NetworkInterface.h" -#include "NetworkBufferManagement.h" -#include "FreeRTOS_ARP.h" -#include "FreeRTOS_TCP_WIN.h" - - -/* Just make sure the contents doesn't get compiled if TCP is not enabled. */ -#if ipconfigUSE_TCP == 1 - -/* This compile-time test was moved to here because some macro's -were unknown within 'FreeRTOSIPConfigDefaults.h'. It tests whether -the defined MTU size can contain at least a complete TCP packet. */ - -#if ( ( ipconfigTCP_MSS + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER ) > ipconfigNETWORK_MTU ) - #error The ipconfigTCP_MSS setting in FreeRTOSIPConfig.h is too large. -#endif - -/* - * The meaning of the TCP flags: - */ -#define ipTCP_FLAG_FIN 0x0001u /* No more data from sender */ -#define ipTCP_FLAG_SYN 0x0002u /* Synchronize sequence numbers */ -#define ipTCP_FLAG_RST 0x0004u /* Reset the connection */ -#define ipTCP_FLAG_PSH 0x0008u /* Push function: please push buffered data to the recv application */ -#define ipTCP_FLAG_ACK 0x0010u /* Acknowledgment field is significant */ -#define ipTCP_FLAG_URG 0x0020u /* Urgent pointer field is significant */ -#define ipTCP_FLAG_ECN 0x0040u /* ECN-Echo */ -#define ipTCP_FLAG_CWR 0x0080u /* Congestion Window Reduced */ -#define ipTCP_FLAG_NS 0x0100u /* ECN-nonce concealment protection */ -#define ipTCP_FLAG_RSV 0x0E00u /* Reserved, keep 0 */ - -/* A mask to filter all protocol flags. */ -#define ipTCP_FLAG_CTRL 0x001Fu - -/* - * A few values of the TCP options: - */ -#define TCP_OPT_END 0u /* End of TCP options list */ -#define TCP_OPT_NOOP 1u /* "No-operation" TCP option */ -#define TCP_OPT_MSS 2u /* Maximum segment size TCP option */ -#define TCP_OPT_WSOPT 3u /* TCP Window Scale Option (3-byte long) */ -#define TCP_OPT_SACK_P 4u /* Advertize that SACK is permitted */ -#define TCP_OPT_SACK_A 5u /* SACK option with first/last */ -#define TCP_OPT_TIMESTAMP 8u /* Time-stamp option */ - -#define TCP_OPT_MSS_LEN 4u /* Length of TCP MSS option. */ -#define TCP_OPT_WSOPT_LEN 3u /* Length of TCP WSOPT option. */ - -#define TCP_OPT_TIMESTAMP_LEN 10 /* fixed length of the time-stamp option */ - -#ifndef ipconfigTCP_ACK_EARLIER_PACKET - #define ipconfigTCP_ACK_EARLIER_PACKET 1 -#endif - -/* - * The macro NOW_CONNECTED() is use to determine if the connection makes a - * transition from connected to non-connected and vice versa. - * NOW_CONNECTED() returns true when the status has one of these values: - * eESTABLISHED, eFIN_WAIT_1, eFIN_WAIT_2, eCLOSING, eLAST_ACK, eTIME_WAIT - * Technically the connection status is closed earlier, but the library wants - * to prevent that the socket will be deleted before the last ACK has been - * and thus causing a 'RST' packet on either side. - */ -#define NOW_CONNECTED( status )\ - ( ( status >= eESTABLISHED ) && ( status != eCLOSE_WAIT ) ) - -/* - * The highest 4 bits in the TCP offset byte indicate the total length of the - * TCP header, divided by 4. - */ -#define VALID_BITS_IN_TCP_OFFSET_BYTE ( 0xF0u ) - -/* - * Acknowledgements to TCP data packets may be delayed as long as more is being expected. - * A normal delay would be 200ms. Here a much shorter delay of 20 ms is being used to - * gain performance. - */ -#define DELAYED_ACK_SHORT_DELAY_MS ( 2 ) -#define DELAYED_ACK_LONGER_DELAY_MS ( 20 ) - -/* - * The MSS (Maximum Segment Size) will be taken as large as possible. However, packets with - * an MSS of 1460 bytes won't be transported through the internet. The MSS will be reduced - * to 1400 bytes. - */ -#define REDUCED_MSS_THROUGH_INTERNET ( 1400 ) - -/* - * When there are no TCP options, the TCP offset equals 20 bytes, which is stored as - * the number 5 (words) in the higher niblle of the TCP-offset byte. - */ -#define TCP_OFFSET_LENGTH_BITS ( 0xf0u ) -#define TCP_OFFSET_STANDARD_LENGTH ( 0x50u ) - -/* - * Each TCP socket is checked regularly to see if it can send data packets. - * By default, the maximum number of packets sent during one check is limited to 8. - * This amount may be further limited by setting the socket's TX window size. - */ -#if( !defined( SEND_REPEATED_COUNT ) ) - #define SEND_REPEATED_COUNT ( 8 ) -#endif /* !defined( SEND_REPEATED_COUNT ) */ - -/* - * Define a maximum perdiod of time (ms) to leave a TCP-socket unattended. - * When a TCP timer expires, retries and keep-alive messages will be checked. - */ -#ifndef tcpMAXIMUM_TCP_WAKEUP_TIME_MS - #define tcpMAXIMUM_TCP_WAKEUP_TIME_MS 20000u -#endif - -/* - * The names of the different TCP states may be useful in logging. - */ -#if( ( ipconfigHAS_DEBUG_PRINTF != 0 ) || ( ipconfigHAS_PRINTF != 0 ) ) - static const char *pcStateNames[] = { - "eCLOSED", - "eTCP_LISTEN", - "eCONNECT_SYN", - "eSYN_FIRST", - "eSYN_RECEIVED", - "eESTABLISHED", - "eFIN_WAIT_1", - "eFIN_WAIT_2", - "eCLOSE_WAIT", - "eCLOSING", - "eLAST_ACK", - "eTIME_WAIT", - "eUNKNOWN", -}; -#endif /* ( ipconfigHAS_DEBUG_PRINTF != 0 ) || ( ipconfigHAS_PRINTF != 0 ) */ - -/* - * Returns true if the socket must be checked. Non-active sockets are waiting - * for user action, either connect() or close(). - */ -static BaseType_t prvTCPSocketIsActive( UBaseType_t uxStatus ); - -/* - * Either sends a SYN or calls prvTCPSendRepeated (for regular messages). - */ -static int32_t prvTCPSendPacket( FreeRTOS_Socket_t *pxSocket ); - -/* - * Try to send a series of messages. - */ -static int32_t prvTCPSendRepeated( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t **ppxNetworkBuffer ); - -/* - * Return or send a packet to the other party. - */ -static void prvTCPReturnPacket( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t *pxNetworkBuffer, - uint32_t ulLen, BaseType_t xReleaseAfterSend ); - -/* - * Initialise the data structures which keep track of the TCP windowing system. - */ -static void prvTCPCreateWindow( FreeRTOS_Socket_t *pxSocket ); - -/* - * Let ARP look-up the MAC-address of the peer and initialise the first SYN - * packet. - */ -static BaseType_t prvTCPPrepareConnect( FreeRTOS_Socket_t *pxSocket ); - -#if( ipconfigHAS_DEBUG_PRINTF != 0 ) - /* - * For logging and debugging: make a string showing the TCP flags. - */ - static const char *prvTCPFlagMeaning( UBaseType_t xFlags); -#endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ - -/* - * Parse the TCP option(s) received, if present. - */ -static void prvCheckOptions( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t *pxNetworkBuffer ); - -/* - * Set the initial properties in the options fields, like the preferred - * value of MSS and whether SACK allowed. Will be transmitted in the state - * 'eCONNECT_SYN'. - */ -static UBaseType_t prvSetSynAckOptions( FreeRTOS_Socket_t *pxSocket, TCPPacket_t * pxTCPPacket ); - -/* - * For anti-hang protection and TCP keep-alive messages. Called in two places: - * after receiving a packet and after a state change. The socket's alive timer - * may be reset. - */ -static void prvTCPTouchSocket( FreeRTOS_Socket_t *pxSocket ); - -/* - * Prepare an outgoing message, if anything has to be sent. - */ -static int32_t prvTCPPrepareSend( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t **ppxNetworkBuffer, UBaseType_t uxOptionsLength ); - -/* - * Calculate when this socket needs to be checked to do (re-)transmissions. - */ -static TickType_t prvTCPNextTimeout( FreeRTOS_Socket_t *pxSocket ); - -/* - * The API FreeRTOS_send() adds data to the TX stream. Add - * this data to the windowing system to it can be transmitted. - */ -static void prvTCPAddTxData( FreeRTOS_Socket_t *pxSocket ); - -/* - * Called to handle the closure of a TCP connection. - */ -static BaseType_t prvTCPHandleFin( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t *pxNetworkBuffer ); - -/* - * Called from prvTCPHandleState(). Find the TCP payload data and check and - * return its length. - */ -static BaseType_t prvCheckRxData( NetworkBufferDescriptor_t *pxNetworkBuffer, uint8_t **ppucRecvData ); - -/* - * Called from prvTCPHandleState(). Check if the payload data may be accepted. - * If so, it will be added to the socket's reception queue. - */ -static BaseType_t prvStoreRxData( FreeRTOS_Socket_t *pxSocket, uint8_t *pucRecvData, - NetworkBufferDescriptor_t *pxNetworkBuffer, uint32_t ulReceiveLength ); - -/* - * Set the TCP options (if any) for the outgoing packet. - */ -static UBaseType_t prvSetOptions( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t *pxNetworkBuffer ); - -/* - * Called from prvTCPHandleState() as long as the TCP status is eSYN_RECEIVED to - * eCONNECT_SYN. - */ -static BaseType_t prvHandleSynReceived( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t **ppxNetworkBuffer, - uint32_t ulReceiveLength, UBaseType_t uxOptionsLength ); - -/* - * Called from prvTCPHandleState() as long as the TCP status is eESTABLISHED. - */ -static BaseType_t prvHandleEstablished( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t **ppxNetworkBuffer, - uint32_t ulReceiveLength, UBaseType_t uxOptionsLength ); - -/* - * Called from prvTCPHandleState(). There is data to be sent. - * If ipconfigUSE_TCP_WIN is defined, and if only an ACK must be sent, it will - * be checked if it would better be postponed for efficiency. - */ -static BaseType_t prvSendData( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t **ppxNetworkBuffer, - uint32_t ulReceiveLength, BaseType_t xSendLength ); - -/* - * The heart of all: check incoming packet for valid data and acks and do what - * is necessary in each state. - */ -static BaseType_t prvTCPHandleState( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t **ppxNetworkBuffer ); - -/* - * Reply to a peer with the RST flag on, in case a packet can not be handled. - */ -static BaseType_t prvTCPSendReset( NetworkBufferDescriptor_t *pxNetworkBuffer ); - -/* - * Set the initial value for MSS (Maximum Segment Size) to be used. - */ -static void prvSocketSetMSS( FreeRTOS_Socket_t *pxSocket ); - -/* - * Return either a newly created socket, or the current socket in a connected - * state (depends on the 'bReuseSocket' flag). - */ -static FreeRTOS_Socket_t *prvHandleListen( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t *pxNetworkBuffer ); - -/* - * After a listening socket receives a new connection, it may duplicate itself. - * The copying takes place in prvTCPSocketCopy. - */ -static BaseType_t prvTCPSocketCopy( FreeRTOS_Socket_t *pxNewSocket, FreeRTOS_Socket_t *pxSocket ); - -/* - * prvTCPStatusAgeCheck() will see if the socket has been in a non-connected - * state for too long. If so, the socket will be closed, and -1 will be - * returned. - */ -#if( ipconfigTCP_HANG_PROTECTION == 1 ) - static BaseType_t prvTCPStatusAgeCheck( FreeRTOS_Socket_t *pxSocket ); -#endif - -static NetworkBufferDescriptor_t *prvTCPBufferResize( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t *pxNetworkBuffer, - int32_t lDataLen, UBaseType_t uxOptionsLength ); - -#if( ( ipconfigHAS_DEBUG_PRINTF != 0 ) || ( ipconfigHAS_PRINTF != 0 ) ) - const char *FreeRTOS_GetTCPStateName( UBaseType_t ulState ); -#endif - -#if( ipconfigUSE_TCP_WIN != 0 ) - static uint8_t prvWinScaleFactor( FreeRTOS_Socket_t *pxSocket ); -#endif - -/* - * Generate a randomized TCP Initial Sequence Number per RFC. - */ -extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress, - uint16_t usSourcePort, - uint32_t ulDestinationAddress, - uint16_t usDestinationPort ); - -/*-----------------------------------------------------------*/ - -/* prvTCPSocketIsActive() returns true if the socket must be checked. - * Non-active sockets are waiting for user action, either connect() - * or close(). */ -static BaseType_t prvTCPSocketIsActive( UBaseType_t uxStatus ) -{ - switch( uxStatus ) - { - case eCLOSED: - case eCLOSE_WAIT: - case eFIN_WAIT_2: - case eCLOSING: - case eTIME_WAIT: - return pdFALSE; - default: - return pdTRUE; - } -} -/*-----------------------------------------------------------*/ - -#if( ipconfigTCP_HANG_PROTECTION == 1 ) - - static BaseType_t prvTCPStatusAgeCheck( FreeRTOS_Socket_t *pxSocket ) - { - BaseType_t xResult; - switch( pxSocket->u.xTCP.ucTCPState ) - { - case eESTABLISHED: - /* If the 'ipconfigTCP_KEEP_ALIVE' option is enabled, sockets in - state ESTABLISHED can be protected using keep-alive messages. */ - xResult = pdFALSE; - break; - case eCLOSED: - case eTCP_LISTEN: - case eCLOSE_WAIT: - /* These 3 states may last for ever, up to the owner. */ - xResult = pdFALSE; - break; - default: - /* All other (non-connected) states will get anti-hanging - protection. */ - xResult = pdTRUE; - break; - } - if( xResult != pdFALSE ) - { - /* How much time has past since the last active moment which is - defined as A) a state change or B) a packet has arrived. */ - TickType_t xAge = xTaskGetTickCount( ) - pxSocket->u.xTCP.xLastActTime; - - /* ipconfigTCP_HANG_PROTECTION_TIME is in units of seconds. */ - if( xAge > ( ipconfigTCP_HANG_PROTECTION_TIME * configTICK_RATE_HZ ) ) - { - #if( ipconfigHAS_DEBUG_PRINTF == 1 ) - { - FreeRTOS_debug_printf( ( "Inactive socket closed: port %u rem %lxip:%u status %s\n", - pxSocket->usLocalPort, - pxSocket->u.xTCP.ulRemoteIP, - pxSocket->u.xTCP.usRemotePort, - FreeRTOS_GetTCPStateName( ( UBaseType_t ) pxSocket->u.xTCP.ucTCPState ) ) ); - } - #endif /* ipconfigHAS_DEBUG_PRINTF */ - - /* Move to eCLOSE_WAIT, user may close the socket. */ - vTCPStateChange( pxSocket, eCLOSE_WAIT ); - - /* When 'bPassQueued' true, this socket is an orphan until it - gets connected. */ - if( pxSocket->u.xTCP.bits.bPassQueued != pdFALSE_UNSIGNED ) - { - if( pxSocket->u.xTCP.bits.bReuseSocket == pdFALSE_UNSIGNED ) - { - /* As it did not get connected, and the user can never - accept() it anymore, it will be deleted now. Called from - the IP-task, so it's safe to call the internal Close - function: vSocketClose(). */ - vSocketClose( pxSocket ); - } - /* Return a negative value to tell to inform the caller - xTCPTimerCheck() - that the socket got closed and may not be accessed anymore. */ - xResult = -1; - } - } - } - return xResult; - } - /*-----------------------------------------------------------*/ - -#endif - -/* - * As soon as a TCP socket timer expires, this function xTCPSocketCheck - * will be called (from xTCPTimerCheck) - * It can send a delayed ACK or new data - * Sequence of calling (normally) : - * IP-Task: - * xTCPTimerCheck() // Check all sockets ( declared in FreeRTOS_Sockets.c ) - * xTCPSocketCheck() // Either send a delayed ACK or call prvTCPSendPacket() - * prvTCPSendPacket() // Either send a SYN or call prvTCPSendRepeated ( regular messages ) - * prvTCPSendRepeated() // Send at most 8 messages on a row - * prvTCPReturnPacket() // Prepare for returning - * xNetworkInterfaceOutput() // Sends data to the NIC ( declared in portable/NetworkInterface/xxx ) - */ -BaseType_t xTCPSocketCheck( FreeRTOS_Socket_t *pxSocket ) -{ -BaseType_t xResult = 0; -BaseType_t xReady = pdFALSE; - - if( ( pxSocket->u.xTCP.ucTCPState >= eESTABLISHED ) && ( pxSocket->u.xTCP.txStream != NULL ) ) - { - /* The API FreeRTOS_send() might have added data to the TX stream. Add - this data to the windowing system to it can be transmitted. */ - prvTCPAddTxData( pxSocket ); - } - - #if ipconfigUSE_TCP_WIN == 1 - { - if( pxSocket->u.xTCP.pxAckMessage != NULL ) - { - /* The first task of this regular socket check is to send-out delayed - ACK's. */ - if( pxSocket->u.xTCP.bits.bUserShutdown == pdFALSE_UNSIGNED ) - { - /* Earlier data was received but not yet acknowledged. This - function is called when the TCP timer for the socket expires, the - ACK may be sent now. */ - if( pxSocket->u.xTCP.ucTCPState != eCLOSED ) - { - if( xTCPWindowLoggingLevel > 1 && ipconfigTCP_MAY_LOG_PORT( pxSocket->usLocalPort ) ) - { - FreeRTOS_debug_printf( ( "Send[%u->%u] del ACK %lu SEQ %lu (len %u)\n", - pxSocket->usLocalPort, - pxSocket->u.xTCP.usRemotePort, - pxSocket->u.xTCP.xTCPWindow.rx.ulCurrentSequenceNumber - pxSocket->u.xTCP.xTCPWindow.rx.ulFirstSequenceNumber, - pxSocket->u.xTCP.xTCPWindow.ulOurSequenceNumber - pxSocket->u.xTCP.xTCPWindow.tx.ulFirstSequenceNumber, - ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER ) ); - } - - prvTCPReturnPacket( pxSocket, pxSocket->u.xTCP.pxAckMessage, ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER, ipconfigZERO_COPY_TX_DRIVER ); - - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* The ownership has been passed to the SEND routine, - clear the pointer to it. */ - pxSocket->u.xTCP.pxAckMessage = NULL; - } - #endif /* ipconfigZERO_COPY_TX_DRIVER */ - } - if( prvTCPNextTimeout( pxSocket ) > 1 ) - { - /* Tell the code below that this function is ready. */ - xReady = pdTRUE; - } - } - else - { - /* The user wants to perform an active shutdown(), skip sending - the delayed ACK. The function prvTCPSendPacket() will send the - FIN along with the ACK's. */ - } - - if( pxSocket->u.xTCP.pxAckMessage != NULL ) - { - vReleaseNetworkBufferAndDescriptor( pxSocket->u.xTCP.pxAckMessage ); - pxSocket->u.xTCP.pxAckMessage = NULL; - } - } - } - #endif /* ipconfigUSE_TCP_WIN */ - - if( xReady == pdFALSE ) - { - /* The second task of this regular socket check is sending out data. */ - if( ( pxSocket->u.xTCP.ucTCPState >= eESTABLISHED ) || - ( pxSocket->u.xTCP.ucTCPState == eCONNECT_SYN ) ) - { - prvTCPSendPacket( pxSocket ); - } - - /* Set the time-out for the next wakeup for this socket. */ - prvTCPNextTimeout( pxSocket ); - - #if( ipconfigTCP_HANG_PROTECTION == 1 ) - { - /* In all (non-connected) states in which keep-alive messages can not be sent - the anti-hang protocol will close sockets that are 'hanging'. */ - xResult = prvTCPStatusAgeCheck( pxSocket ); - } - #endif - } - - return xResult; -} -/*-----------------------------------------------------------*/ - -/* - * prvTCPSendPacket() will be called when the socket time-out has been reached. - * It is only called by xTCPSocketCheck(). - */ -static int32_t prvTCPSendPacket( FreeRTOS_Socket_t *pxSocket ) -{ -int32_t lResult = 0; -UBaseType_t uxOptionsLength; -TCPPacket_t *pxTCPPacket; -NetworkBufferDescriptor_t *pxNetworkBuffer; - - if( pxSocket->u.xTCP.ucTCPState != eCONNECT_SYN ) - { - /* The connection is in s state other than SYN. */ - pxNetworkBuffer = NULL; - - /* prvTCPSendRepeated() will only create a network buffer if necessary, - i.e. when data must be sent to the peer. */ - lResult = prvTCPSendRepeated( pxSocket, &pxNetworkBuffer ); - - if( pxNetworkBuffer != NULL ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - } - } - else - { - if( pxSocket->u.xTCP.ucRepCount >= 3u ) - { - /* The connection is in the SYN status. The packet will be repeated - to most 3 times. When there is no response, the socket get the - status 'eCLOSE_WAIT'. */ - FreeRTOS_debug_printf( ( "Connect: giving up %lxip:%u\n", - pxSocket->u.xTCP.ulRemoteIP, /* IP address of remote machine. */ - pxSocket->u.xTCP.usRemotePort ) ); /* Port on remote machine. */ - vTCPStateChange( pxSocket, eCLOSE_WAIT ); - } - else if( ( pxSocket->u.xTCP.bits.bConnPrepared != pdFALSE_UNSIGNED ) || ( prvTCPPrepareConnect( pxSocket ) == pdTRUE ) ) - { - /* Or else, if the connection has been prepared, or can be prepared - now, proceed to send the packet with the SYN flag. - prvTCPPrepareConnect() prepares 'xPacket' and returns pdTRUE if - the Ethernet address of the peer or the gateway is found. */ - pxTCPPacket = ( TCPPacket_t * )pxSocket->u.xTCP.xPacket.u.ucLastPacket; - - /* About to send a SYN packet. Call prvSetSynAckOptions() to set - the proper options: The size of MSS and whether SACK's are - allowed. */ - uxOptionsLength = prvSetSynAckOptions( pxSocket, pxTCPPacket ); - - /* Return the number of bytes to be sent. */ - lResult = ( BaseType_t ) ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + uxOptionsLength ); - - /* Set the TCP offset field: ipSIZE_OF_TCP_HEADER equals 20 and - uxOptionsLength is always a multiple of 4. The complete expression - would be: - ucTCPOffset = ( ( ipSIZE_OF_TCP_HEADER + uxOptionsLength ) / 4 ) << 4 */ - pxTCPPacket->xTCPHeader.ucTCPOffset = ( uint8_t )( ( ipSIZE_OF_TCP_HEADER + uxOptionsLength ) << 2 ); - - /* Repeat Count is used for a connecting socket, to limit the number - of tries. */ - pxSocket->u.xTCP.ucRepCount++; - - /* Send the SYN message to make a connection. The messages is - stored in the socket field 'xPacket'. It will be wrapped in a - pseudo network buffer descriptor before it will be sent. */ - prvTCPReturnPacket( pxSocket, NULL, ( uint32_t ) lResult, pdFALSE ); - } - } - - /* Return the total number of bytes sent. */ - return lResult; -} -/*-----------------------------------------------------------*/ - -/* - * prvTCPSendRepeated will try to send a series of messages, as long as there is - * data to be sent and as long as the transmit window isn't full. - */ -static int32_t prvTCPSendRepeated( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t **ppxNetworkBuffer ) -{ -UBaseType_t uxIndex; -int32_t lResult = 0; -UBaseType_t uxOptionsLength = 0u; -int32_t xSendLength; - - for( uxIndex = 0u; uxIndex < ( UBaseType_t ) SEND_REPEATED_COUNT; uxIndex++ ) - { - /* prvTCPPrepareSend() might allocate a network buffer if there is data - to be sent. */ - xSendLength = prvTCPPrepareSend( pxSocket, ppxNetworkBuffer, uxOptionsLength ); - if( xSendLength <= 0 ) - { - break; - } - - /* And return the packet to the peer. */ - prvTCPReturnPacket( pxSocket, *ppxNetworkBuffer, ( uint32_t ) xSendLength, ipconfigZERO_COPY_TX_DRIVER ); - - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - *ppxNetworkBuffer = NULL; - } - #endif /* ipconfigZERO_COPY_TX_DRIVER */ - - lResult += xSendLength; - } - - /* Return the total number of bytes sent. */ - return lResult; -} -/*-----------------------------------------------------------*/ - -/* - * Return (or send) a packet the the peer. The data is stored in pxBuffer, - * which may either point to a real network buffer or to a TCP socket field - * called 'xTCP.xPacket'. A temporary xNetworkBuffer will be used to pass - * the data to the NIC. - */ -static void prvTCPReturnPacket( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t *pxNetworkBuffer, uint32_t ulLen, BaseType_t xReleaseAfterSend ) -{ -TCPPacket_t * pxTCPPacket; -IPHeader_t *pxIPHeader; -EthernetHeader_t *pxEthernetHeader; -uint32_t ulFrontSpace, ulSpace, ulSourceAddress, ulWinSize; -TCPWindow_t *pxTCPWindow; -NetworkBufferDescriptor_t xTempBuffer; -/* For sending, a pseudo network buffer will be used, as explained above. */ - - if( pxNetworkBuffer == NULL ) - { - pxNetworkBuffer = &xTempBuffer; - - #if( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) - { - xTempBuffer.pxNextBuffer = NULL; - } - #endif - xTempBuffer.pucEthernetBuffer = pxSocket->u.xTCP.xPacket.u.ucLastPacket; - xTempBuffer.xDataLength = sizeof( pxSocket->u.xTCP.xPacket.u.ucLastPacket ); - xReleaseAfterSend = pdFALSE; - } - - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - if( xReleaseAfterSend == pdFALSE ) - { - pxNetworkBuffer = pxDuplicateNetworkBufferWithDescriptor( pxNetworkBuffer, ( BaseType_t ) pxNetworkBuffer->xDataLength ); - if( pxNetworkBuffer == NULL ) - { - FreeRTOS_debug_printf( ( "prvTCPReturnPacket: duplicate failed\n" ) ); - } - xReleaseAfterSend = pdTRUE; - } - } - #endif /* ipconfigZERO_COPY_TX_DRIVER */ - - if( pxNetworkBuffer != NULL ) - { - pxTCPPacket = ( TCPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuffer ); - pxIPHeader = &pxTCPPacket->xIPHeader; - pxEthernetHeader = &pxTCPPacket->xEthernetHeader; - - /* Fill the packet, using hton translations. */ - if( pxSocket != NULL ) - { - /* Calculate the space in the RX buffer in order to advertise the - size of this socket's reception window. */ - pxTCPWindow = &( pxSocket->u.xTCP.xTCPWindow ); - - if( pxSocket->u.xTCP.rxStream != NULL ) - { - /* An RX stream was created already, see how much space is - available. */ - ulFrontSpace = ( uint32_t ) uxStreamBufferFrontSpace( pxSocket->u.xTCP.rxStream ); - } - else - { - /* No RX stream has been created, the full stream size is - available. */ - ulFrontSpace = ( uint32_t ) pxSocket->u.xTCP.uxRxStreamSize; - } - - /* Take the minimum of the RX buffer space and the RX window size. */ - ulSpace = FreeRTOS_min_uint32( pxSocket->u.xTCP.ulRxCurWinSize, pxTCPWindow->xSize.ulRxWindowLength ); - - if( ( pxSocket->u.xTCP.bits.bLowWater != pdFALSE_UNSIGNED ) || ( pxSocket->u.xTCP.bits.bRxStopped != pdFALSE_UNSIGNED ) ) - { - /* The low-water mark was reached, meaning there was little - space left. The socket will wait until the application has read - or flushed the incoming data, and 'zero-window' will be - advertised. */ - ulSpace = 0u; - } - - /* If possible, advertise an RX window size of at least 1 MSS, otherwise - the peer might start 'zero window probing', i.e. sending small packets - (1, 2, 4, 8... bytes). */ - if( ( ulSpace < pxSocket->u.xTCP.usCurMSS ) && ( ulFrontSpace >= pxSocket->u.xTCP.usCurMSS ) ) - { - ulSpace = pxSocket->u.xTCP.usCurMSS; - } - - /* Avoid overflow of the 16-bit win field. */ - #if( ipconfigUSE_TCP_WIN != 0 ) - { - ulWinSize = ( ulSpace >> pxSocket->u.xTCP.ucMyWinScaleFactor ); - } - #else - { - ulWinSize = ulSpace; - } - #endif - if( ulWinSize > 0xfffcUL ) - { - ulWinSize = 0xfffcUL; - } - - pxTCPPacket->xTCPHeader.usWindow = FreeRTOS_htons( ( uint16_t ) ulWinSize ); - - #if( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - if( ipconfigTCP_MAY_LOG_PORT( pxSocket->usLocalPort ) != pdFALSE ) - { - if( ( xTCPWindowLoggingLevel != 0 ) && ( pxSocket->u.xTCP.bits.bWinChange != pdFALSE_UNSIGNED ) ) - { - size_t uxFrontSpace; - - if(pxSocket->u.xTCP.rxStream != NULL) - { - uxFrontSpace = uxStreamBufferFrontSpace( pxSocket->u.xTCP.rxStream ) ; - } - else - { - uxFrontSpace = 0u; - } - - FreeRTOS_debug_printf( ( "%s: %lxip:%u: [%lu < %lu] winSize %ld\n", - pxSocket->u.xTCP.bits.bLowWater ? "STOP" : "GO ", - pxSocket->u.xTCP.ulRemoteIP, - pxSocket->u.xTCP.usRemotePort, - pxSocket->u.xTCP.bits.bLowWater ? pxSocket->u.xTCP.uxLittleSpace : uxFrontSpace, pxSocket->u.xTCP.uxEnoughSpace, - (int32_t) ( pxTCPWindow->rx.ulHighestSequenceNumber - pxTCPWindow->rx.ulCurrentSequenceNumber ) ) ); - } - } - } - #endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ - - /* The new window size has been advertised, switch off the flag. */ - pxSocket->u.xTCP.bits.bWinChange = pdFALSE_UNSIGNED; - - /* Later on, when deciding to delay an ACK, a precise estimate is needed - of the free RX space. At this moment, 'ulHighestRxAllowed' would be the - highest sequence number minus 1 that the socket will accept. */ - pxSocket->u.xTCP.ulHighestRxAllowed = pxTCPWindow->rx.ulCurrentSequenceNumber + ulSpace; - - #if( ipconfigTCP_KEEP_ALIVE == 1 ) - if( pxSocket->u.xTCP.bits.bSendKeepAlive != pdFALSE_UNSIGNED ) - { - /* Sending a keep-alive packet, send the current sequence number - minus 1, which will be recognised as a keep-alive packet an - responded to by acknowledging the last byte. */ - pxSocket->u.xTCP.bits.bSendKeepAlive = pdFALSE_UNSIGNED; - pxSocket->u.xTCP.bits.bWaitKeepAlive = pdTRUE_UNSIGNED; - - pxTCPPacket->xTCPHeader.ulSequenceNumber = pxSocket->u.xTCP.xTCPWindow.ulOurSequenceNumber - 1UL; - pxTCPPacket->xTCPHeader.ulSequenceNumber = FreeRTOS_htonl( pxTCPPacket->xTCPHeader.ulSequenceNumber ); - } - else - #endif - { - pxTCPPacket->xTCPHeader.ulSequenceNumber = FreeRTOS_htonl( pxSocket->u.xTCP.xTCPWindow.ulOurSequenceNumber ); - - if( ( pxTCPPacket->xTCPHeader.ucTCPFlags & ( uint8_t ) ipTCP_FLAG_FIN ) != 0u ) - { - /* Suppress FIN in case this packet carries earlier data to be - retransmitted. */ - uint32_t ulDataLen = ( uint32_t ) ( ulLen - ( ipSIZE_OF_TCP_HEADER + ipSIZE_OF_IPv4_HEADER ) ); - if( ( pxTCPWindow->ulOurSequenceNumber + ulDataLen ) != pxTCPWindow->tx.ulFINSequenceNumber ) - { - pxTCPPacket->xTCPHeader.ucTCPFlags &= ( ( uint8_t ) ~ipTCP_FLAG_FIN ); - FreeRTOS_debug_printf( ( "Suppress FIN for %lu + %lu < %lu\n", - pxTCPWindow->ulOurSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber, - ulDataLen, - pxTCPWindow->tx.ulFINSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber ) ); - } - } - } - - /* Tell which sequence number is expected next time */ - pxTCPPacket->xTCPHeader.ulAckNr = FreeRTOS_htonl( pxTCPWindow->rx.ulCurrentSequenceNumber ); - } - else - { - /* Sending data without a socket, probably replying with a RST flag - Just swap the two sequence numbers. */ - vFlip_32( pxTCPPacket->xTCPHeader.ulSequenceNumber, pxTCPPacket->xTCPHeader.ulAckNr ); - } - - pxIPHeader->ucTimeToLive = ( uint8_t ) ipconfigTCP_TIME_TO_LIVE; - pxIPHeader->usLength = FreeRTOS_htons( ulLen ); - if( ( pxSocket == NULL ) || ( *ipLOCAL_IP_ADDRESS_POINTER == 0ul ) ) - { - /* When pxSocket is NULL, this function is called by prvTCPSendReset() - and the IP-addresses must be swapped. - Also swap the IP-addresses in case the IP-tack doesn't have an - IP-address yet, i.e. when ( *ipLOCAL_IP_ADDRESS_POINTER == 0ul ). */ - ulSourceAddress = pxIPHeader->ulDestinationIPAddress; - } - else - { - ulSourceAddress = *ipLOCAL_IP_ADDRESS_POINTER; - } - pxIPHeader->ulDestinationIPAddress = pxIPHeader->ulSourceIPAddress; - pxIPHeader->ulSourceIPAddress = ulSourceAddress; - vFlip_16( pxTCPPacket->xTCPHeader.usSourcePort, pxTCPPacket->xTCPHeader.usDestinationPort ); - - /* Just an increasing number. */ - pxIPHeader->usIdentification = FreeRTOS_htons( usPacketIdentifier ); - usPacketIdentifier++; - pxIPHeader->usFragmentOffset = 0u; - - #if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - { - /* calculate the IP header checksum, in case the driver won't do that. */ - pxIPHeader->usHeaderChecksum = 0x00u; - pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0UL, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER ); - pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum ); - - /* calculate the TCP checksum for an outgoing packet. */ - usGenerateProtocolChecksum( (uint8_t*)pxTCPPacket, pxNetworkBuffer->xDataLength, pdTRUE ); - - /* A calculated checksum of 0 must be inverted as 0 means the checksum - is disabled. */ - if( pxTCPPacket->xTCPHeader.usChecksum == 0x00u ) - { - pxTCPPacket->xTCPHeader.usChecksum = 0xffffU; - } - } - #endif - - #if( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) - pxNetworkBuffer->pxNextBuffer = NULL; - #endif - - /* Important: tell NIC driver how many bytes must be sent. */ - pxNetworkBuffer->xDataLength = ulLen + ipSIZE_OF_ETH_HEADER; - - /* Fill in the destination MAC addresses. */ - memcpy( ( void * ) &( pxEthernetHeader->xDestinationAddress ), ( void * ) &( pxEthernetHeader->xSourceAddress ), - sizeof( pxEthernetHeader->xDestinationAddress ) ); - - /* The source MAC addresses is fixed to 'ipLOCAL_MAC_ADDRESS'. */ - memcpy( ( void * ) &( pxEthernetHeader->xSourceAddress) , ( void * ) ipLOCAL_MAC_ADDRESS, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); - - #if defined( ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - { - if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - { - BaseType_t xIndex; - - for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) - { - pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0u; - } - pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; - } - } - #endif - - /* Send! */ - xNetworkInterfaceOutput( pxNetworkBuffer, xReleaseAfterSend ); - - if( xReleaseAfterSend == pdFALSE ) - { - /* Swap-back some fields, as pxBuffer probably points to a socket field - containing the packet header. */ - vFlip_16( pxTCPPacket->xTCPHeader.usSourcePort, pxTCPPacket->xTCPHeader.usDestinationPort); - pxTCPPacket->xIPHeader.ulSourceIPAddress = pxTCPPacket->xIPHeader.ulDestinationIPAddress; - memcpy( pxEthernetHeader->xSourceAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); - } - else - { - /* Nothing to do: the buffer has been passed to DMA and will be released after use */ - } - } /* if( pxNetworkBuffer != NULL ) */ -} -/*-----------------------------------------------------------*/ - -/* - * The SYN event is very important: the sequence numbers, which have a kind of - * random starting value, are being synchronised. The sliding window manager - * (in FreeRTOS_TCP_WIN.c) needs to know them, along with the Maximum Segment - * Size (MSS) in use. - */ -static void prvTCPCreateWindow( FreeRTOS_Socket_t *pxSocket ) -{ - if( xTCPWindowLoggingLevel ) - FreeRTOS_debug_printf( ( "Limits (using): TCP Win size %lu Water %lu <= %lu <= %lu\n", - pxSocket->u.xTCP.uxRxWinSize * ipconfigTCP_MSS, - pxSocket->u.xTCP.uxLittleSpace , - pxSocket->u.xTCP.uxEnoughSpace, - pxSocket->u.xTCP.uxRxStreamSize ) ); - vTCPWindowCreate( - &pxSocket->u.xTCP.xTCPWindow, - ipconfigTCP_MSS * pxSocket->u.xTCP.uxRxWinSize, - ipconfigTCP_MSS * pxSocket->u.xTCP.uxTxWinSize, - pxSocket->u.xTCP.xTCPWindow.rx.ulCurrentSequenceNumber, - pxSocket->u.xTCP.xTCPWindow.ulOurSequenceNumber, - ( uint32_t ) pxSocket->u.xTCP.usInitMSS ); -} -/*-----------------------------------------------------------*/ - -/* - * Connecting sockets have a special state: eCONNECT_SYN. In this phase, - * the Ethernet address of the target will be found using ARP. In case the - * target IP address is not within the netmask, the hardware address of the - * gateway will be used. - */ -static BaseType_t prvTCPPrepareConnect( FreeRTOS_Socket_t *pxSocket ) -{ -TCPPacket_t *pxTCPPacket; -IPHeader_t *pxIPHeader; -eARPLookupResult_t eReturned; -uint32_t ulRemoteIP; -MACAddress_t xEthAddress; -BaseType_t xReturn = pdTRUE; -uint32_t ulInitialSequenceNumber = 0; - - #if( ipconfigHAS_PRINTF != 0 ) - { - /* Only necessary for nicer logging. */ - memset( xEthAddress.ucBytes, '\0', sizeof( xEthAddress.ucBytes ) ); - } - #endif /* ipconfigHAS_PRINTF != 0 */ - - ulRemoteIP = FreeRTOS_htonl( pxSocket->u.xTCP.ulRemoteIP ); - - /* Determine the ARP cache status for the requested IP address. */ - eReturned = eARPGetCacheEntry( &( ulRemoteIP ), &( xEthAddress ) ); - - switch( eReturned ) - { - case eARPCacheHit: /* An ARP table lookup found a valid entry. */ - break; /* We can now prepare the SYN packet. */ - case eARPCacheMiss: /* An ARP table lookup did not find a valid entry. */ - case eCantSendPacket: /* There is no IP address, or an ARP is still in progress. */ - default: - /* Count the number of times it couldn't find the ARP address. */ - pxSocket->u.xTCP.ucRepCount++; - - FreeRTOS_debug_printf( ( "ARP for %lxip (using %lxip): rc=%d %02X:%02X:%02X %02X:%02X:%02X\n", - pxSocket->u.xTCP.ulRemoteIP, - FreeRTOS_htonl( ulRemoteIP ), - eReturned, - xEthAddress.ucBytes[ 0 ], - xEthAddress.ucBytes[ 1 ], - xEthAddress.ucBytes[ 2 ], - xEthAddress.ucBytes[ 3 ], - xEthAddress.ucBytes[ 4 ], - xEthAddress.ucBytes[ 5 ] ) ); - - /* And issue a (new) ARP request */ - FreeRTOS_OutputARPRequest( ulRemoteIP ); - - xReturn = pdFALSE; - } - - if( xReturn != pdFALSE ) - { - /* Get a difficult-to-predict initial sequence number for this 4-tuple. */ - ulInitialSequenceNumber = ulApplicationGetNextSequenceNumber( *ipLOCAL_IP_ADDRESS_POINTER, - pxSocket->usLocalPort, - pxSocket->u.xTCP.ulRemoteIP, - pxSocket->u.xTCP.usRemotePort ); - - /* Check for a random number generation error. */ - if( 0 == ulInitialSequenceNumber ) - { - xReturn = pdFALSE; - } - } - - if( xReturn != pdFALSE ) - { - /* The MAC-address of the peer (or gateway) has been found, - now prepare the initial TCP packet and some fields in the socket. */ - pxTCPPacket = ( TCPPacket_t * )pxSocket->u.xTCP.xPacket.u.ucLastPacket; - pxIPHeader = &pxTCPPacket->xIPHeader; - - /* reset the retry counter to zero. */ - pxSocket->u.xTCP.ucRepCount = 0u; - - /* And remember that the connect/SYN data are prepared. */ - pxSocket->u.xTCP.bits.bConnPrepared = pdTRUE_UNSIGNED; - - /* Now that the Ethernet address is known, the initial packet can be - prepared. */ - memset( pxSocket->u.xTCP.xPacket.u.ucLastPacket, '\0', sizeof( pxSocket->u.xTCP.xPacket.u.ucLastPacket ) ); - - /* Write the Ethernet address in Source, because it will be swapped by - prvTCPReturnPacket(). */ - memcpy( &pxTCPPacket->xEthernetHeader.xSourceAddress, &xEthAddress, sizeof( xEthAddress ) ); - - /* 'ipIPv4_FRAME_TYPE' is already in network-byte-order. */ - pxTCPPacket->xEthernetHeader.usFrameType = ipIPv4_FRAME_TYPE; - - pxIPHeader->ucVersionHeaderLength = 0x45u; - pxIPHeader->usLength = FreeRTOS_htons( sizeof( TCPPacket_t ) - sizeof( pxTCPPacket->xEthernetHeader ) ); - pxIPHeader->ucTimeToLive = ( uint8_t ) ipconfigTCP_TIME_TO_LIVE; - - pxIPHeader->ucProtocol = ( uint8_t ) ipPROTOCOL_TCP; - - /* Addresses and ports will be stored swapped because prvTCPReturnPacket - will swap them back while replying. */ - pxIPHeader->ulDestinationIPAddress = *ipLOCAL_IP_ADDRESS_POINTER; - pxIPHeader->ulSourceIPAddress = FreeRTOS_htonl( pxSocket->u.xTCP.ulRemoteIP ); - - pxTCPPacket->xTCPHeader.usSourcePort = FreeRTOS_htons( pxSocket->u.xTCP.usRemotePort ); - pxTCPPacket->xTCPHeader.usDestinationPort = FreeRTOS_htons( pxSocket->usLocalPort ); - - /* We are actively connecting, so the peer's Initial Sequence Number (ISN) - isn't known yet. */ - pxSocket->u.xTCP.xTCPWindow.rx.ulCurrentSequenceNumber = 0ul; - - /* Start with ISN (Initial Sequence Number). */ - pxSocket->u.xTCP.xTCPWindow.ulOurSequenceNumber = ulInitialSequenceNumber; - - /* The TCP header size is 20 bytes, divided by 4 equals 5, which is put in - the high nibble of the TCP offset field. */ - pxTCPPacket->xTCPHeader.ucTCPOffset = 0x50u; - - /* Only set the SYN flag. */ - pxTCPPacket->xTCPHeader.ucTCPFlags = ipTCP_FLAG_SYN; - - /* Set the values of usInitMSS / usCurMSS for this socket. */ - prvSocketSetMSS( pxSocket ); - - /* For now this is also the advertised window size. */ - pxSocket->u.xTCP.ulRxCurWinSize = pxSocket->u.xTCP.usInitMSS; - - /* The initial sequence numbers at our side are known. Later - vTCPWindowInit() will be called to fill in the peer's sequence numbers, but - first wait for a SYN+ACK reply. */ - prvTCPCreateWindow( pxSocket ); - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -/* For logging and debugging: make a string showing the TCP flags -*/ -#if( ipconfigHAS_DEBUG_PRINTF != 0 ) - - static const char *prvTCPFlagMeaning( UBaseType_t xFlags) - { - static char retString[10]; - snprintf(retString, sizeof( retString ), "%c%c%c%c%c%c%c%c%c", - ( xFlags & ipTCP_FLAG_FIN ) ? 'F' : '.', /* 0x0001: No more data from sender */ - ( xFlags & ipTCP_FLAG_SYN ) ? 'S' : '.', /* 0x0002: Synchronize sequence numbers */ - ( xFlags & ipTCP_FLAG_RST ) ? 'R' : '.', /* 0x0004: Reset the connection */ - ( xFlags & ipTCP_FLAG_PSH ) ? 'P' : '.', /* 0x0008: Push function: please push buffered data to the recv application */ - ( xFlags & ipTCP_FLAG_ACK ) ? 'A' : '.', /* 0x0010: Acknowledgment field is significant */ - ( xFlags & ipTCP_FLAG_URG ) ? 'U' : '.', /* 0x0020: Urgent pointer field is significant */ - ( xFlags & ipTCP_FLAG_ECN ) ? 'E' : '.', /* 0x0040: ECN-Echo */ - ( xFlags & ipTCP_FLAG_CWR ) ? 'C' : '.', /* 0x0080: Congestion Window Reduced */ - ( xFlags & ipTCP_FLAG_NS ) ? 'N' : '.'); /* 0x0100: ECN-nonce concealment protection */ - return retString; - } - /*-----------------------------------------------------------*/ - -#endif /* ipconfigHAS_DEBUG_PRINTF */ - -/* - * Parse the TCP option(s) received, if present. It has already been verified - * that: ((pxTCPHeader->ucTCPOffset & 0xf0) > 0x50), meaning that the TP header - * is longer than the usual 20 (5 x 4) bytes. - */ -static void prvCheckOptions( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t *pxNetworkBuffer ) -{ -TCPPacket_t * pxTCPPacket; -TCPHeader_t * pxTCPHeader; -const unsigned char *pucPtr; -const unsigned char *pucLast; -TCPWindow_t *pxTCPWindow; -UBaseType_t uxNewMSS; - - pxTCPPacket = ( TCPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuffer ); - pxTCPHeader = &pxTCPPacket->xTCPHeader; - - /* A character pointer to iterate through the option data */ - pucPtr = pxTCPHeader->ucOptdata; - pucLast = pucPtr + (((pxTCPHeader->ucTCPOffset >> 4) - 5) << 2); - pxTCPWindow = &pxSocket->u.xTCP.xTCPWindow; - - /* Validate options size calculation. */ - if( pucLast > ( pxNetworkBuffer->pucEthernetBuffer + pxNetworkBuffer->xDataLength ) ) - { - return; - } - - /* The comparison with pucLast is only necessary in case the option data are - corrupted, we don't like to run into invalid memory and crash. */ - while( pucPtr < pucLast ) - { - UBaseType_t xRemainingOptionsBytes = pucLast - pucPtr; - - if( pucPtr[ 0 ] == TCP_OPT_END ) - { - /* End of options. */ - break; - } - if( pucPtr[ 0 ] == TCP_OPT_NOOP) - { - /* NOP option, inserted to make the length a multiple of 4. */ - pucPtr++; - continue; - } - - /* Any other well-formed option must be at least two bytes: the option - type byte followed by a length byte. */ - if( xRemainingOptionsBytes < 2 ) - { - break; - } -#if( ipconfigUSE_TCP_WIN != 0 ) - else if( pucPtr[ 0 ] == TCP_OPT_WSOPT ) - { - /* Confirm that the option fits in the remaining buffer space. */ - if( ( xRemainingOptionsBytes < TCP_OPT_WSOPT_LEN ) || ( pucPtr[ 1 ] != TCP_OPT_WSOPT_LEN ) ) - { - break; - } - - pxSocket->u.xTCP.ucPeerWinScaleFactor = pucPtr[ 2 ]; - pxSocket->u.xTCP.bits.bWinScaling = pdTRUE_UNSIGNED; - pucPtr += TCP_OPT_WSOPT_LEN; - } -#endif /* ipconfigUSE_TCP_WIN */ - else if( pucPtr[ 0 ] == TCP_OPT_MSS ) - { - /* Confirm that the option fits in the remaining buffer space. */ - if( ( xRemainingOptionsBytes < TCP_OPT_MSS_LEN ) || ( pucPtr[ 1 ] != TCP_OPT_MSS_LEN ) ) - { - break; - } - - /* An MSS option with the correct option length. FreeRTOS_htons() - is not needed here because usChar2u16() already returns a host - endian number. */ - uxNewMSS = usChar2u16( pucPtr + 2 ); - - if( pxSocket->u.xTCP.usInitMSS != uxNewMSS ) - { - /* Perform a basic check on the the new MSS. */ - if( uxNewMSS == 0 ) - { - break; - } - - FreeRTOS_debug_printf( ( "MSS change %u -> %lu\n", pxSocket->u.xTCP.usInitMSS, uxNewMSS ) ); - } - - if( pxSocket->u.xTCP.usInitMSS > uxNewMSS ) - { - /* our MSS was bigger than the MSS of the other party: adapt it. */ - pxSocket->u.xTCP.bits.bMssChange = pdTRUE_UNSIGNED; - if( ( pxTCPWindow != NULL ) && ( pxSocket->u.xTCP.usCurMSS > uxNewMSS ) ) - { - /* The peer advertises a smaller MSS than this socket was - using. Use that as well. */ - FreeRTOS_debug_printf( ( "Change mss %d => %lu\n", pxSocket->u.xTCP.usCurMSS, uxNewMSS ) ); - pxSocket->u.xTCP.usCurMSS = ( uint16_t ) uxNewMSS; - } - pxTCPWindow->xSize.ulRxWindowLength = ( ( uint32_t ) uxNewMSS ) * ( pxTCPWindow->xSize.ulRxWindowLength / ( ( uint32_t ) uxNewMSS ) ); - pxTCPWindow->usMSSInit = ( uint16_t ) uxNewMSS; - pxTCPWindow->usMSS = ( uint16_t ) uxNewMSS; - pxSocket->u.xTCP.usInitMSS = ( uint16_t ) uxNewMSS; - pxSocket->u.xTCP.usCurMSS = ( uint16_t ) uxNewMSS; - } - - #if( ipconfigUSE_TCP_WIN != 1 ) - /* Without scaled windows, MSS is the only interesting option. */ - break; - #else - /* Or else we continue to check another option: selective ACK. */ - pucPtr += TCP_OPT_MSS_LEN; - #endif /* ipconfigUSE_TCP_WIN != 1 */ - } - else - { - /* All other options have a length field, so that we easily - can skip past them. */ - unsigned char len = pucPtr[ 1 ]; - if( ( len < 2 ) || ( len > xRemainingOptionsBytes ) ) - { - /* If the length field is too small or too big, the options are malformed. - Don't process them further. */ - break; - } - - #if( ipconfigUSE_TCP_WIN == 1 ) - { - /* Selective ACK: the peer has received a packet but it is missing earlier - packets. At least this packet does not need retransmission anymore - ulTCPWindowTxSack( ) takes care of this administration. */ - if( pucPtr[0] == TCP_OPT_SACK_A ) - { - len -= 2; - pucPtr += 2; - - while( len >= 8 ) - { - uint32_t ulFirst = ulChar2u32( pucPtr ); - uint32_t ulLast = ulChar2u32( pucPtr + 4 ); - uint32_t ulCount = ulTCPWindowTxSack( &pxSocket->u.xTCP.xTCPWindow, ulFirst, ulLast ); - /* ulTCPWindowTxSack( ) returns the number of bytes which have been acked - starting from the head position. - Advance the tail pointer in txStream. */ - if( ( pxSocket->u.xTCP.txStream != NULL ) && ( ulCount > 0 ) ) - { - /* Just advancing the tail index, 'ulCount' bytes have been confirmed. */ - uxStreamBufferGet( pxSocket->u.xTCP.txStream, 0, NULL, ( size_t ) ulCount, pdFALSE ); - pxSocket->xEventBits |= eSOCKET_SEND; - - #if ipconfigSUPPORT_SELECT_FUNCTION == 1 - { - if( pxSocket->xSelectBits & eSELECT_WRITE ) - { - /* The field 'xEventBits' is used to store regular socket events (at most 8), - as well as 'select events', which will be left-shifted */ - pxSocket->xEventBits |= ( eSELECT_WRITE << SOCKET_EVENT_BIT_COUNT ); - } - } - #endif - - /* In case the socket owner has installed an OnSent handler, - call it now. */ - #if( ipconfigUSE_CALLBACKS == 1 ) - { - if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xTCP.pxHandleSent ) ) - { - pxSocket->u.xTCP.pxHandleSent( (Socket_t *)pxSocket, ulCount ); - } - } - #endif /* ipconfigUSE_CALLBACKS == 1 */ - } - pucPtr += 8; - len -= 8; - } - /* len should be 0 by now. */ - } - } - #endif /* ipconfigUSE_TCP_WIN == 1 */ - - pucPtr += len; - } - } -} -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN != 0 ) - - static uint8_t prvWinScaleFactor( FreeRTOS_Socket_t *pxSocket ) - { - size_t uxWinSize; - uint8_t ucFactor; - - /* 'xTCP.uxRxWinSize' is the size of the reception window in units of MSS. */ - uxWinSize = pxSocket->u.xTCP.uxRxWinSize * ( size_t ) pxSocket->u.xTCP.usInitMSS; - ucFactor = 0u; - while( uxWinSize > 0xfffful ) - { - /* Divide by two and increase the binary factor by 1. */ - uxWinSize >>= 1; - ucFactor++; - } - - FreeRTOS_debug_printf( ( "prvWinScaleFactor: uxRxWinSize %lu MSS %lu Factor %u\n", - pxSocket->u.xTCP.uxRxWinSize, - pxSocket->u.xTCP.usInitMSS, - ucFactor ) ); - - return ucFactor; - } - -#endif -/*-----------------------------------------------------------*/ - -/* - * When opening a TCP connection, while SYN's are being sent, the parties may - * communicate what MSS (Maximum Segment Size) they intend to use. MSS is the - * nett size of the payload, always smaller than MTU. -*/ -static UBaseType_t prvSetSynAckOptions( FreeRTOS_Socket_t *pxSocket, TCPPacket_t * pxTCPPacket ) -{ -TCPHeader_t *pxTCPHeader = &pxTCPPacket->xTCPHeader; -uint16_t usMSS = pxSocket->u.xTCP.usInitMSS; -UBaseType_t uxOptionsLength; - - /* We send out the TCP Maximum Segment Size option with our SYN[+ACK]. */ - - pxTCPHeader->ucOptdata[ 0 ] = ( uint8_t ) TCP_OPT_MSS; - pxTCPHeader->ucOptdata[ 1 ] = ( uint8_t ) TCP_OPT_MSS_LEN; - pxTCPHeader->ucOptdata[ 2 ] = ( uint8_t ) ( usMSS >> 8 ); - pxTCPHeader->ucOptdata[ 3 ] = ( uint8_t ) ( usMSS & 0xffu ); - - #if( ipconfigUSE_TCP_WIN != 0 ) - { - pxSocket->u.xTCP.ucMyWinScaleFactor = prvWinScaleFactor( pxSocket ); - - pxTCPHeader->ucOptdata[ 4 ] = TCP_OPT_NOOP; - pxTCPHeader->ucOptdata[ 5 ] = ( uint8_t ) ( TCP_OPT_WSOPT ); - pxTCPHeader->ucOptdata[ 6 ] = ( uint8_t ) ( TCP_OPT_WSOPT_LEN ); - pxTCPHeader->ucOptdata[ 7 ] = ( uint8_t ) pxSocket->u.xTCP.ucMyWinScaleFactor; - uxOptionsLength = 8u; - } - #else - { - uxOptionsLength = 4u; - } - #endif - - #if( ipconfigUSE_TCP_WIN == 0 ) - { - return uxOptionsLength; - } - #else - { - pxTCPHeader->ucOptdata[ uxOptionsLength + 0 ] = TCP_OPT_NOOP; - pxTCPHeader->ucOptdata[ uxOptionsLength + 1 ] = TCP_OPT_NOOP; - pxTCPHeader->ucOptdata[ uxOptionsLength + 2 ] = TCP_OPT_SACK_P; /* 4: Sack-Permitted Option. */ - pxTCPHeader->ucOptdata[ uxOptionsLength + 3 ] = 2; /* 2: length of this option. */ - uxOptionsLength += 4u; - - return uxOptionsLength; /* bytes, not words. */ - } - #endif /* ipconfigUSE_TCP_WIN == 0 */ -} - -/* - * For anti-hanging protection and TCP keep-alive messages. Called in two - * places: after receiving a packet and after a state change. The socket's - * alive timer may be reset. - */ -static void prvTCPTouchSocket( FreeRTOS_Socket_t *pxSocket ) -{ - #if( ipconfigTCP_HANG_PROTECTION == 1 ) - { - pxSocket->u.xTCP.xLastActTime = xTaskGetTickCount( ); - } - #endif - - #if( ipconfigTCP_KEEP_ALIVE == 1 ) - { - pxSocket->u.xTCP.bits.bWaitKeepAlive = pdFALSE_UNSIGNED; - pxSocket->u.xTCP.bits.bSendKeepAlive = pdFALSE_UNSIGNED; - pxSocket->u.xTCP.ucKeepRepCount = 0u; - pxSocket->u.xTCP.xLastAliveTime = xTaskGetTickCount(); - } - #endif - - ( void ) pxSocket; -} -/*-----------------------------------------------------------*/ - -/* - * Changing to a new state. Centralised here to do specific actions such as - * resetting the alive timer, calling the user's OnConnect handler to notify - * that a socket has got (dis)connected, and setting bit to unblock a call to - * FreeRTOS_select() - */ -void vTCPStateChange( FreeRTOS_Socket_t *pxSocket, enum eTCP_STATE eTCPState ) -{ -FreeRTOS_Socket_t *xParent = NULL; -BaseType_t bBefore = ( BaseType_t ) NOW_CONNECTED( pxSocket->u.xTCP.ucTCPState ); /* Was it connected ? */ -BaseType_t bAfter = ( BaseType_t ) NOW_CONNECTED( eTCPState ); /* Is it connected now ? */ -#if( ipconfigHAS_DEBUG_PRINTF != 0 ) - BaseType_t xPreviousState = ( BaseType_t ) pxSocket->u.xTCP.ucTCPState; -#endif -#if( ipconfigUSE_CALLBACKS == 1 ) - FreeRTOS_Socket_t *xConnected = NULL; -#endif - - /* Has the connected status changed? */ - if( bBefore != bAfter ) - { - /* Is the socket connected now ? */ - if( bAfter != pdFALSE ) - { - /* if bPassQueued is true, this socket is an orphan until it gets connected. */ - if( pxSocket->u.xTCP.bits.bPassQueued != pdFALSE_UNSIGNED ) - { - /* Now that it is connected, find it's parent. */ - if( pxSocket->u.xTCP.bits.bReuseSocket != pdFALSE_UNSIGNED ) - { - xParent = pxSocket; - } - else - { - xParent = pxSocket->u.xTCP.pxPeerSocket; - configASSERT( xParent != NULL ); - } - if( xParent != NULL ) - { - if( xParent->u.xTCP.pxPeerSocket == NULL ) - { - xParent->u.xTCP.pxPeerSocket = pxSocket; - } - - xParent->xEventBits |= eSOCKET_ACCEPT; - - #if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - { - /* Library support FreeRTOS_select(). Receiving a new - connection is being translated as a READ event. */ - if( ( xParent->xSelectBits & eSELECT_READ ) != 0 ) - { - xParent->xEventBits |= ( eSELECT_READ << SOCKET_EVENT_BIT_COUNT ); - } - } - #endif - - #if( ipconfigUSE_CALLBACKS == 1 ) - { - if( ( ipconfigIS_VALID_PROG_ADDRESS( xParent->u.xTCP.pxHandleConnected ) != pdFALSE ) && - ( xParent->u.xTCP.bits.bReuseSocket == pdFALSE_UNSIGNED ) ) - { - /* The listening socket does not become connected itself, in stead - a child socket is created. - Postpone a call the OnConnect event until the end of this function. */ - xConnected = xParent; - } - } - #endif - } - - /* Don't need to access the parent socket anymore, so the - reference 'pxPeerSocket' may be cleared. */ - pxSocket->u.xTCP.pxPeerSocket = NULL; - pxSocket->u.xTCP.bits.bPassQueued = pdFALSE_UNSIGNED; - - /* When true, this socket may be returned in a call to accept(). */ - pxSocket->u.xTCP.bits.bPassAccept = pdTRUE_UNSIGNED; - } - else - { - pxSocket->xEventBits |= eSOCKET_CONNECT; - - #if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - { - if( pxSocket->xSelectBits & eSELECT_WRITE ) - { - pxSocket->xEventBits |= ( eSELECT_WRITE << SOCKET_EVENT_BIT_COUNT ); - } - } - #endif - } - } - else /* bAfter == pdFALSE, connection is closed. */ - { - /* Notify/wake-up the socket-owner by setting a semaphore. */ - pxSocket->xEventBits |= eSOCKET_CLOSED; - - #if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - { - if( ( pxSocket->xSelectBits & eSELECT_EXCEPT ) != 0 ) - { - pxSocket->xEventBits |= ( eSELECT_EXCEPT << SOCKET_EVENT_BIT_COUNT ); - } - } - #endif - } - #if( ipconfigUSE_CALLBACKS == 1 ) - { - if( ( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xTCP.pxHandleConnected ) != pdFALSE ) && ( xConnected == NULL ) ) - { - /* The 'connected' state has changed, call the user handler. */ - xConnected = pxSocket; - } - } - #endif /* ipconfigUSE_CALLBACKS */ - - if( prvTCPSocketIsActive( ( UBaseType_t ) pxSocket->u.xTCP.ucTCPState ) == pdFALSE ) - { - /* Now the socket isn't in an active state anymore so it - won't need further attention of the IP-task. - Setting time-out to zero means that the socket won't get checked during - timer events. */ - pxSocket->u.xTCP.usTimeout = 0u; - } - } - else - { - if( eTCPState == eCLOSED ) - { - /* Socket goes to status eCLOSED because of a RST. - When nobody owns the socket yet, delete it. */ - if( ( pxSocket->u.xTCP.bits.bPassQueued != pdFALSE_UNSIGNED ) || - ( pxSocket->u.xTCP.bits.bPassAccept != pdFALSE_UNSIGNED ) ) - { - FreeRTOS_debug_printf( ( "vTCPStateChange: Closing socket\n" ) ); - if( pxSocket->u.xTCP.bits.bReuseSocket == pdFALSE_UNSIGNED ) - { - FreeRTOS_closesocket( pxSocket ); - } - } - } - } - - /* Fill in the new state. */ - pxSocket->u.xTCP.ucTCPState = ( uint8_t ) eTCPState; - - /* touch the alive timers because moving to another state. */ - prvTCPTouchSocket( pxSocket ); - - #if( ipconfigHAS_DEBUG_PRINTF == 1 ) - { - if( ( xTCPWindowLoggingLevel >= 0 ) && ( ipconfigTCP_MAY_LOG_PORT( pxSocket->usLocalPort ) != pdFALSE ) ) - FreeRTOS_debug_printf( ( "Socket %d -> %lxip:%u State %s->%s\n", - pxSocket->usLocalPort, - pxSocket->u.xTCP.ulRemoteIP, - pxSocket->u.xTCP.usRemotePort, - FreeRTOS_GetTCPStateName( ( UBaseType_t ) xPreviousState ), - FreeRTOS_GetTCPStateName( ( UBaseType_t ) eTCPState ) ) ); - } - #endif /* ipconfigHAS_DEBUG_PRINTF */ - - #if( ipconfigUSE_CALLBACKS == 1 ) - { - if( xConnected != NULL ) - { - /* The 'connected' state has changed, call the OnConnect handler of the parent. */ - xConnected->u.xTCP.pxHandleConnected( ( Socket_t * ) xConnected, bAfter ); - } - } - #endif - if( xParent != NULL ) - { - vSocketWakeUpUser( xParent ); - } -} -/*-----------------------------------------------------------*/ - -static NetworkBufferDescriptor_t *prvTCPBufferResize( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t *pxNetworkBuffer, - int32_t lDataLen, UBaseType_t uxOptionsLength ) -{ -NetworkBufferDescriptor_t *pxReturn; -int32_t lNeeded; -BaseType_t xResize; - - if( xBufferAllocFixedSize != pdFALSE ) - { - /* Network buffers are created with a fixed size and can hold the largest - MTU. */ - lNeeded = ( int32_t ) ipTOTAL_ETHERNET_FRAME_SIZE; - /* and therefore, the buffer won't be too small. - Only ask for a new network buffer in case none was supplied. */ - xResize = ( pxNetworkBuffer == NULL ); - } - else - { - /* Network buffers are created with a variable size. See if it must - grow. */ - lNeeded = FreeRTOS_max_int32( ( int32_t ) sizeof( pxSocket->u.xTCP.xPacket.u.ucLastPacket ), - ( int32_t ) ( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + uxOptionsLength ) + lDataLen ); - /* In case we were called from a TCP timer event, a buffer must be - created. Otherwise, test 'xDataLength' of the provided buffer. */ - xResize = ( pxNetworkBuffer == NULL ) || ( pxNetworkBuffer->xDataLength < (size_t)lNeeded ); - } - - if( xResize != pdFALSE ) - { - /* The caller didn't provide a network buffer or the provided buffer is - too small. As we must send-out a data packet, a buffer will be created - here. */ - pxReturn = pxGetNetworkBufferWithDescriptor( ( uint32_t ) lNeeded, 0u ); - - if( pxReturn != NULL ) - { - /* Set the actual packet size, in case the returned buffer is larger. */ - pxReturn->xDataLength = lNeeded; - - /* Copy the existing data to the new created buffer. */ - if( pxNetworkBuffer ) - { - /* Either from the previous buffer... */ - memcpy( pxReturn->pucEthernetBuffer, pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength ); - - /* ...and release it. */ - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - } - else - { - /* Or from the socket field 'xTCP.xPacket'. */ - memcpy( pxReturn->pucEthernetBuffer, pxSocket->u.xTCP.xPacket.u.ucLastPacket, sizeof( pxSocket->u.xTCP.xPacket.u.ucLastPacket ) ); - } - } - } - else - { - /* xResize is false, the network buffer provided was big enough. */ - pxReturn = pxNetworkBuffer; - - /* Thanks to Andrey Ivanov from swissEmbedded for reporting that the - xDataLength member must get the correct length too! */ - pxNetworkBuffer->xDataLength = ( size_t ) ( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + uxOptionsLength ) + ( size_t ) lDataLen; - } - - return pxReturn; -} -/*-----------------------------------------------------------*/ - -/* - * Prepare an outgoing message, in case anything has to be sent. - */ -static int32_t prvTCPPrepareSend( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t **ppxNetworkBuffer, UBaseType_t uxOptionsLength ) -{ -int32_t lDataLen; -uint8_t *pucEthernetBuffer, *pucSendData; -TCPPacket_t *pxTCPPacket; -size_t uxOffset; -uint32_t ulDataGot, ulDistance; -TCPWindow_t *pxTCPWindow; -NetworkBufferDescriptor_t *pxNewBuffer; -int32_t lStreamPos; - - if( ( *ppxNetworkBuffer ) != NULL ) - { - /* A network buffer descriptor was already supplied */ - pucEthernetBuffer = ( *ppxNetworkBuffer )->pucEthernetBuffer; - } - else - { - /* For now let it point to the last packet header */ - pucEthernetBuffer = pxSocket->u.xTCP.xPacket.u.ucLastPacket; - } - - pxTCPPacket = ( TCPPacket_t * ) ( pucEthernetBuffer ); - pxTCPWindow = &pxSocket->u.xTCP.xTCPWindow; - lDataLen = 0; - lStreamPos = 0; - pxTCPPacket->xTCPHeader.ucTCPFlags |= ipTCP_FLAG_ACK; - - if( pxSocket->u.xTCP.txStream != NULL ) - { - /* ulTCPWindowTxGet will return the amount of data which may be sent - along with the position in the txStream. - Why check for MSS > 1 ? - Because some TCP-stacks (like uIP) use it for flow-control. */ - if( pxSocket->u.xTCP.usCurMSS > 1u ) - { - lDataLen = ( int32_t ) ulTCPWindowTxGet( pxTCPWindow, pxSocket->u.xTCP.ulWindowSize, &lStreamPos ); - } - - if( lDataLen > 0 ) - { - /* Check if the current network buffer is big enough, if not, - resize it. */ - pxNewBuffer = prvTCPBufferResize( pxSocket, *ppxNetworkBuffer, lDataLen, uxOptionsLength ); - - if( pxNewBuffer != NULL ) - { - *ppxNetworkBuffer = pxNewBuffer; - pucEthernetBuffer = pxNewBuffer->pucEthernetBuffer; - pxTCPPacket = ( TCPPacket_t * ) ( pucEthernetBuffer ); - - pucSendData = pucEthernetBuffer + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + uxOptionsLength; - - /* Translate the position in txStream to an offset from the tail - marker. */ - uxOffset = uxStreamBufferDistance( pxSocket->u.xTCP.txStream, pxSocket->u.xTCP.txStream->uxTail, ( size_t ) lStreamPos ); - - /* Here data is copied from the txStream in 'peek' mode. Only - when the packets are acked, the tail marker will be updated. */ - ulDataGot = ( uint32_t ) uxStreamBufferGet( pxSocket->u.xTCP.txStream, uxOffset, pucSendData, ( size_t ) lDataLen, pdTRUE ); - - #if( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - if( ulDataGot != ( uint32_t ) lDataLen ) - { - FreeRTOS_debug_printf( ( "uxStreamBufferGet: pos %lu offs %lu only %lu != %lu\n", - lStreamPos, uxOffset, ulDataGot, lDataLen ) ); - } - } - #endif - - /* If the owner of the socket requests a closure, add the FIN - flag to the last packet. */ - if( ( pxSocket->u.xTCP.bits.bCloseRequested != pdFALSE_UNSIGNED ) && ( pxSocket->u.xTCP.bits.bFinSent == pdFALSE_UNSIGNED ) ) - { - ulDistance = ( uint32_t ) uxStreamBufferDistance( pxSocket->u.xTCP.txStream, ( size_t ) lStreamPos, pxSocket->u.xTCP.txStream->uxHead ); - - if( ulDistance == ulDataGot ) - { - #if (ipconfigHAS_DEBUG_PRINTF == 1) - { - /* the order of volatile accesses is undefined - so such workaround */ - size_t uxHead = pxSocket->u.xTCP.txStream->uxHead; - size_t uxMid = pxSocket->u.xTCP.txStream->uxMid; - size_t uxTail = pxSocket->u.xTCP.txStream->uxTail; - - FreeRTOS_debug_printf( ( "CheckClose %lu <= %lu (%lu <= %lu <= %lu)\n", ulDataGot, ulDistance, - uxTail, uxMid, uxHead ) ); - } - #endif - /* Although the socket sends a FIN, it will stay in - ESTABLISHED until all current data has been received or - delivered. */ - pxTCPPacket->xTCPHeader.ucTCPFlags |= ipTCP_FLAG_FIN; - pxTCPWindow->tx.ulFINSequenceNumber = pxTCPWindow->ulOurSequenceNumber + ( uint32_t ) lDataLen; - pxSocket->u.xTCP.bits.bFinSent = pdTRUE_UNSIGNED; - } - } - } - else - { - lDataLen = -1; - } - } - } - - if( ( lDataLen >= 0 ) && ( pxSocket->u.xTCP.ucTCPState == eESTABLISHED ) ) - { - /* See if the socket owner wants to shutdown this connection. */ - if( ( pxSocket->u.xTCP.bits.bUserShutdown != pdFALSE_UNSIGNED ) && - ( xTCPWindowTxDone( pxTCPWindow ) != pdFALSE ) ) - { - pxSocket->u.xTCP.bits.bUserShutdown = pdFALSE_UNSIGNED; - pxTCPPacket->xTCPHeader.ucTCPFlags |= ipTCP_FLAG_FIN; - pxSocket->u.xTCP.bits.bFinSent = pdTRUE_UNSIGNED; - pxSocket->u.xTCP.bits.bWinChange = pdTRUE_UNSIGNED; - pxTCPWindow->tx.ulFINSequenceNumber = pxTCPWindow->tx.ulCurrentSequenceNumber; - vTCPStateChange( pxSocket, eFIN_WAIT_1 ); - } - - #if( ipconfigTCP_KEEP_ALIVE != 0 ) - { - if( pxSocket->u.xTCP.ucKeepRepCount > 3u ) - { - FreeRTOS_debug_printf( ( "keep-alive: giving up %lxip:%u\n", - pxSocket->u.xTCP.ulRemoteIP, /* IP address of remote machine. */ - pxSocket->u.xTCP.usRemotePort ) ); /* Port on remote machine. */ - vTCPStateChange( pxSocket, eCLOSE_WAIT ); - lDataLen = -1; - } - if( ( lDataLen == 0 ) && ( pxSocket->u.xTCP.bits.bWinChange == pdFALSE_UNSIGNED ) ) - { - /* If there is no data to be sent, and no window-update message, - we might want to send a keep-alive message. */ - TickType_t xAge = xTaskGetTickCount( ) - pxSocket->u.xTCP.xLastAliveTime; - TickType_t xMax; - xMax = ( ( TickType_t ) ipconfigTCP_KEEP_ALIVE_INTERVAL * configTICK_RATE_HZ ); - if( pxSocket->u.xTCP.ucKeepRepCount ) - { - xMax = ( 3u * configTICK_RATE_HZ ); - } - if( xAge > xMax ) - { - pxSocket->u.xTCP.xLastAliveTime = xTaskGetTickCount( ); - if( xTCPWindowLoggingLevel ) - FreeRTOS_debug_printf( ( "keep-alive: %lxip:%u count %u\n", - pxSocket->u.xTCP.ulRemoteIP, - pxSocket->u.xTCP.usRemotePort, - pxSocket->u.xTCP.ucKeepRepCount ) ); - pxSocket->u.xTCP.bits.bSendKeepAlive = pdTRUE_UNSIGNED; - pxSocket->u.xTCP.usTimeout = ( ( uint16_t ) pdMS_TO_TICKS( 2500 ) ); - pxSocket->u.xTCP.ucKeepRepCount++; - } - } - } - #endif /* ipconfigTCP_KEEP_ALIVE */ - } - - /* Anything to send, a change of the advertised window size, or maybe send a - keep-alive message? */ - if( ( lDataLen > 0 ) || - ( pxSocket->u.xTCP.bits.bWinChange != pdFALSE_UNSIGNED ) || - ( pxSocket->u.xTCP.bits.bSendKeepAlive != pdFALSE_UNSIGNED ) ) - { - pxTCPPacket->xTCPHeader.ucTCPFlags &= ( ( uint8_t ) ~ipTCP_FLAG_PSH ); - pxTCPPacket->xTCPHeader.ucTCPOffset = ( uint8_t )( ( ipSIZE_OF_TCP_HEADER + uxOptionsLength ) << 2 ); - - pxTCPPacket->xTCPHeader.ucTCPFlags |= ( uint8_t ) ipTCP_FLAG_ACK; - - if( lDataLen != 0l ) - { - pxTCPPacket->xTCPHeader.ucTCPFlags |= ( uint8_t ) ipTCP_FLAG_PSH; - } - - lDataLen += ( int32_t ) ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + uxOptionsLength ); - } - - return lDataLen; -} -/*-----------------------------------------------------------*/ - -/* - * Calculate after how much time this socket needs to be checked again. - */ -static TickType_t prvTCPNextTimeout ( FreeRTOS_Socket_t *pxSocket ) -{ -TickType_t ulDelayMs = ( TickType_t ) tcpMAXIMUM_TCP_WAKEUP_TIME_MS; - - if( pxSocket->u.xTCP.ucTCPState == eCONNECT_SYN ) - { - /* The socket is actively connecting to a peer. */ - if( pxSocket->u.xTCP.bits.bConnPrepared ) - { - /* Ethernet address has been found, use progressive timeout for - active connect(). */ - if( pxSocket->u.xTCP.ucRepCount < 3u ) - { - ulDelayMs = ( 3000UL << ( pxSocket->u.xTCP.ucRepCount - 1u ) ); - } - else - { - ulDelayMs = 11000UL; - } - } - else - { - /* Still in the ARP phase: check every half second. */ - ulDelayMs = 500UL; - } - - FreeRTOS_debug_printf( ( "Connect[%lxip:%u]: next timeout %u: %lu ms\n", - pxSocket->u.xTCP.ulRemoteIP, pxSocket->u.xTCP.usRemotePort, - pxSocket->u.xTCP.ucRepCount, ulDelayMs ) ); - pxSocket->u.xTCP.usTimeout = ( uint16_t )pdMS_TO_MIN_TICKS( ulDelayMs ); - } - else if( pxSocket->u.xTCP.usTimeout == 0u ) - { - /* Let the sliding window mechanism decide what time-out is appropriate. */ - BaseType_t xResult = xTCPWindowTxHasData( &pxSocket->u.xTCP.xTCPWindow, pxSocket->u.xTCP.ulWindowSize, &ulDelayMs ); - if( ulDelayMs == 0u ) - { - if( xResult != ( BaseType_t )0 ) - { - ulDelayMs = 1UL; - } - else - { - ulDelayMs = tcpMAXIMUM_TCP_WAKEUP_TIME_MS; - } - } - else - { - /* ulDelayMs contains the time to wait before a re-transmission. */ - } - pxSocket->u.xTCP.usTimeout = ( uint16_t )pdMS_TO_MIN_TICKS( ulDelayMs ); - } - else - { - /* field '.usTimeout' has already been set (by the - keep-alive/delayed-ACK mechanism). */ - } - - /* Return the number of clock ticks before the timer expires. */ - return ( TickType_t ) pxSocket->u.xTCP.usTimeout; -} -/*-----------------------------------------------------------*/ - -static void prvTCPAddTxData( FreeRTOS_Socket_t *pxSocket ) -{ -int32_t lCount, lLength; - - /* A txStream has been created already, see if the socket has new data for - the sliding window. - - uxStreamBufferMidSpace() returns the distance between rxHead and rxMid. It contains new - Tx data which has not been passed to the sliding window yet. The oldest - data not-yet-confirmed can be found at rxTail. */ - lLength = ( int32_t ) uxStreamBufferMidSpace( pxSocket->u.xTCP.txStream ); - - if( lLength > 0 ) - { - /* All data between txMid and rxHead will now be passed to the sliding - window manager, so it can start transmitting them. - - Hand over the new data to the sliding window handler. It will be - split-up in chunks of 1460 bytes each (or less, depending on - ipconfigTCP_MSS). */ - lCount = lTCPWindowTxAdd( &pxSocket->u.xTCP.xTCPWindow, - ( uint32_t ) lLength, - ( int32_t ) pxSocket->u.xTCP.txStream->uxMid, - ( int32_t ) pxSocket->u.xTCP.txStream->LENGTH ); - - /* Move the rxMid pointer forward up to rxHead. */ - if( lCount > 0 ) - { - vStreamBufferMoveMid( pxSocket->u.xTCP.txStream, ( size_t ) lCount ); - } - } -} -/*-----------------------------------------------------------*/ - -/* - * prvTCPHandleFin() will be called to handle socket closure - * The Closure starts when either a FIN has been received and accepted, - * Or when the socket has sent a FIN flag to the peer - * Before being called, it has been checked that both reception and transmission - * are complete. - */ -static BaseType_t prvTCPHandleFin( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t *pxNetworkBuffer ) -{ -TCPPacket_t *pxTCPPacket = ( TCPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuffer ); -TCPHeader_t *pxTCPHeader = &pxTCPPacket->xTCPHeader; -uint8_t ucTCPFlags = pxTCPHeader->ucTCPFlags; -TCPWindow_t *pxTCPWindow = &pxSocket->u.xTCP.xTCPWindow; -BaseType_t xSendLength = 0; -uint32_t ulAckNr = FreeRTOS_ntohl( pxTCPHeader->ulAckNr ); - - if( ( ucTCPFlags & ipTCP_FLAG_FIN ) != 0u ) - { - pxTCPWindow->rx.ulCurrentSequenceNumber = pxTCPWindow->rx.ulFINSequenceNumber + 1u; - } - if( pxSocket->u.xTCP.bits.bFinSent == pdFALSE_UNSIGNED ) - { - /* We haven't yet replied with a FIN, do so now. */ - pxTCPWindow->tx.ulFINSequenceNumber = pxTCPWindow->tx.ulCurrentSequenceNumber; - pxSocket->u.xTCP.bits.bFinSent = pdTRUE_UNSIGNED; - } - else - { - /* We did send a FIN already, see if it's ACK'd. */ - if( ulAckNr == pxTCPWindow->tx.ulFINSequenceNumber + 1u ) - { - pxSocket->u.xTCP.bits.bFinAcked = pdTRUE_UNSIGNED; - } - } - - if( pxSocket->u.xTCP.bits.bFinAcked == pdFALSE_UNSIGNED ) - { - pxTCPWindow->tx.ulCurrentSequenceNumber = pxTCPWindow->tx.ulFINSequenceNumber; - pxTCPHeader->ucTCPFlags = ipTCP_FLAG_ACK | ipTCP_FLAG_FIN; - - /* And wait for the final ACK. */ - vTCPStateChange( pxSocket, eLAST_ACK ); - } - else - { - /* Our FIN has been ACK'd, the outgoing sequence number is now fixed. */ - pxTCPWindow->tx.ulCurrentSequenceNumber = pxTCPWindow->tx.ulFINSequenceNumber + 1u; - if( pxSocket->u.xTCP.bits.bFinRecv == pdFALSE_UNSIGNED ) - { - /* We have sent out a FIN but the peer hasn't replied with a FIN - yet. Do nothing for the moment. */ - pxTCPHeader->ucTCPFlags = 0u; - } - else - { - if( pxSocket->u.xTCP.bits.bFinLast == pdFALSE_UNSIGNED ) - { - /* This is the third of the three-way hand shake: the last - ACK. */ - pxTCPHeader->ucTCPFlags = ipTCP_FLAG_ACK; - } - else - { - /* The other party started the closure, so we just wait for the - last ACK. */ - pxTCPHeader->ucTCPFlags = 0u; - } - - /* And wait for the user to close this socket. */ - vTCPStateChange( pxSocket, eCLOSE_WAIT ); - } - } - - pxTCPWindow->ulOurSequenceNumber = pxTCPWindow->tx.ulCurrentSequenceNumber; - - if( pxTCPHeader->ucTCPFlags != 0u ) - { - xSendLength = ( BaseType_t ) ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + pxTCPWindow->ucOptionLength ); - } - - pxTCPHeader->ucTCPOffset = ( uint8_t ) ( ( ipSIZE_OF_TCP_HEADER + pxTCPWindow->ucOptionLength ) << 2 ); - - if( xTCPWindowLoggingLevel != 0 ) - { - FreeRTOS_debug_printf( ( "TCP: send FIN+ACK (ack %lu, cur/nxt %lu/%lu) ourSeqNr %lu | Rx %lu\n", - ulAckNr - pxTCPWindow->tx.ulFirstSequenceNumber, - pxTCPWindow->tx.ulCurrentSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber, - pxTCPWindow->ulNextTxSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber, - pxTCPWindow->ulOurSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber, - pxTCPWindow->rx.ulCurrentSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber ) ); - } - - return xSendLength; -} -/*-----------------------------------------------------------*/ - -/* - * prvCheckRxData(): called from prvTCPHandleState() - * - * The first thing that will be done is find the TCP payload data - * and check the length of this data. - */ -static BaseType_t prvCheckRxData( NetworkBufferDescriptor_t *pxNetworkBuffer, uint8_t **ppucRecvData ) -{ -TCPPacket_t *pxTCPPacket = ( TCPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuffer ); -TCPHeader_t *pxTCPHeader = &( pxTCPPacket->xTCPHeader ); -int32_t lLength, lTCPHeaderLength, lReceiveLength, lUrgentLength; - - /* Determine the length and the offset of the user-data sent to this - node. - - The size of the TCP header is given in a multiple of 4-byte words (single - byte, needs no ntoh() translation). A shift-right 2: is the same as - (offset >> 4) * 4. */ - lTCPHeaderLength = ( BaseType_t ) ( ( pxTCPHeader->ucTCPOffset & VALID_BITS_IN_TCP_OFFSET_BYTE ) >> 2 ); - - /* Let pucRecvData point to the first byte received. */ - *ppucRecvData = pxNetworkBuffer->pucEthernetBuffer + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER + lTCPHeaderLength; - - /* Calculate lReceiveLength - the length of the TCP data received. This is - equal to the total packet length minus: - ( LinkLayer length (14) + IP header length (20) + size of TCP header(20 +) ).*/ - lReceiveLength = ( ( int32_t ) pxNetworkBuffer->xDataLength ) - ( int32_t ) ipSIZE_OF_ETH_HEADER; - lLength = ( int32_t )FreeRTOS_htons( pxTCPPacket->xIPHeader.usLength ); - - if( lReceiveLength > lLength ) - { - /* More bytes were received than the reported length, often because of - padding bytes at the end. */ - lReceiveLength = lLength; - } - - /* Subtract the size of the TCP and IP headers and the actual data size is - known. */ - if( lReceiveLength > ( lTCPHeaderLength + ( int32_t ) ipSIZE_OF_IPv4_HEADER ) ) - { - lReceiveLength -= ( lTCPHeaderLength + ( int32_t ) ipSIZE_OF_IPv4_HEADER ); - } - else - { - lReceiveLength = 0; - } - - /* Urgent Pointer: - This field communicates the current value of the urgent pointer as a - positive offset from the sequence number in this segment. The urgent - pointer points to the sequence number of the octet following the urgent - data. This field is only be interpreted in segments with the URG control - bit set. */ - if( ( pxTCPHeader->ucTCPFlags & ipTCP_FLAG_URG ) != 0u ) - { - /* Although we ignore the urgent data, we have to skip it. */ - lUrgentLength = ( int32_t ) FreeRTOS_htons( pxTCPHeader->usUrgent ); - *ppucRecvData += lUrgentLength; - lReceiveLength -= FreeRTOS_min_int32( lReceiveLength, lUrgentLength ); - } - - return ( BaseType_t ) lReceiveLength; -} -/*-----------------------------------------------------------*/ - -/* - * prvStoreRxData(): called from prvTCPHandleState() - * - * The second thing is to do is check if the payload data may be accepted - * If so, they will be added to the reception queue. - */ -static BaseType_t prvStoreRxData( FreeRTOS_Socket_t *pxSocket, uint8_t *pucRecvData, - NetworkBufferDescriptor_t *pxNetworkBuffer, uint32_t ulReceiveLength ) -{ -TCPPacket_t *pxTCPPacket = ( TCPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuffer ); -TCPHeader_t *pxTCPHeader = &pxTCPPacket->xTCPHeader; -TCPWindow_t *pxTCPWindow = &pxSocket->u.xTCP.xTCPWindow; -uint32_t ulSequenceNumber, ulSpace; -int32_t lOffset, lStored; -BaseType_t xResult = 0; - - ulSequenceNumber = FreeRTOS_ntohl( pxTCPHeader->ulSequenceNumber ); - - if( ( ulReceiveLength > 0u ) && ( pxSocket->u.xTCP.ucTCPState >= eSYN_RECEIVED ) ) - { - /* See if way may accept the data contents and forward it to the socket - owner. - - If it can't be "accept"ed it may have to be stored and send a selective - ack (SACK) option to confirm it. In that case, xTCPWindowRxStore() will be - called later to store an out-of-order packet (in case lOffset is - negative). */ - if ( pxSocket->u.xTCP.rxStream ) - { - ulSpace = ( uint32_t )uxStreamBufferGetSpace ( pxSocket->u.xTCP.rxStream ); - } - else - { - ulSpace = ( uint32_t )pxSocket->u.xTCP.uxRxStreamSize; - } - - lOffset = lTCPWindowRxCheck( pxTCPWindow, ulSequenceNumber, ulReceiveLength, ulSpace ); - - if( lOffset >= 0 ) - { - /* New data has arrived and may be made available to the user. See - if the head marker in rxStream may be advanced, only if lOffset == 0. - In case the low-water mark is reached, bLowWater will be set - "low-water" here stands for "little space". */ - lStored = lTCPAddRxdata( pxSocket, ( uint32_t ) lOffset, pucRecvData, ulReceiveLength ); - - if( lStored != ( int32_t ) ulReceiveLength ) - { - FreeRTOS_debug_printf( ( "lTCPAddRxdata: stored %ld / %lu bytes??\n", lStored, ulReceiveLength ) ); - - /* Received data could not be stored. The socket's flag - bMallocError has been set. The socket now has the status - eCLOSE_WAIT and a RST packet will be sent back. */ - prvTCPSendReset( pxNetworkBuffer ); - xResult = -1; - } - } - - /* After a missing packet has come in, higher packets may be passed to - the user. */ - #if( ipconfigUSE_TCP_WIN == 1 ) - { - /* Now lTCPAddRxdata() will move the rxHead pointer forward - so data becomes available to the user immediately - In case the low-water mark is reached, bLowWater will be set. */ - if( ( xResult == 0 ) && ( pxTCPWindow->ulUserDataLength > 0 ) ) - { - lTCPAddRxdata( pxSocket, 0ul, NULL, pxTCPWindow->ulUserDataLength ); - pxTCPWindow->ulUserDataLength = 0; - } - } - #endif /* ipconfigUSE_TCP_WIN */ - } - else - { - pxTCPWindow->ucOptionLength = 0u; - } - - return xResult; -} -/*-----------------------------------------------------------*/ - -/* Set the TCP options (if any) for the outgoing packet. */ -static UBaseType_t prvSetOptions( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t *pxNetworkBuffer ) -{ -TCPPacket_t *pxTCPPacket = ( TCPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuffer ); -TCPHeader_t *pxTCPHeader = &pxTCPPacket->xTCPHeader; -TCPWindow_t *pxTCPWindow = &pxSocket->u.xTCP.xTCPWindow; -UBaseType_t uxOptionsLength = pxTCPWindow->ucOptionLength; - - #if( ipconfigUSE_TCP_WIN == 1 ) - if( uxOptionsLength != 0u ) - { - /* TCP options must be sent because a packet which is out-of-order - was received. */ - if( xTCPWindowLoggingLevel >= 0 ) - FreeRTOS_debug_printf( ( "SACK[%d,%d]: optlen %lu sending %lu - %lu\n", - pxSocket->usLocalPort, - pxSocket->u.xTCP.usRemotePort, - uxOptionsLength, - FreeRTOS_ntohl( pxTCPWindow->ulOptionsData[ 1 ] ) - pxSocket->u.xTCP.xTCPWindow.rx.ulFirstSequenceNumber, - FreeRTOS_ntohl( pxTCPWindow->ulOptionsData[ 2 ] ) - pxSocket->u.xTCP.xTCPWindow.rx.ulFirstSequenceNumber ) ); - memcpy( pxTCPHeader->ucOptdata, pxTCPWindow->ulOptionsData, ( size_t ) uxOptionsLength ); - - /* The header length divided by 4, goes into the higher nibble, - effectively a shift-left 2. */ - pxTCPHeader->ucTCPOffset = ( uint8_t )( ( ipSIZE_OF_TCP_HEADER + uxOptionsLength ) << 2 ); - } - else - #endif /* ipconfigUSE_TCP_WIN */ - if( ( pxSocket->u.xTCP.ucTCPState >= eESTABLISHED ) && ( pxSocket->u.xTCP.bits.bMssChange != pdFALSE_UNSIGNED ) ) - { - /* TCP options must be sent because the MSS has changed. */ - pxSocket->u.xTCP.bits.bMssChange = pdFALSE_UNSIGNED; - if( xTCPWindowLoggingLevel >= 0 ) - { - FreeRTOS_debug_printf( ( "MSS: sending %d\n", pxSocket->u.xTCP.usCurMSS ) ); - } - - pxTCPHeader->ucOptdata[ 0 ] = TCP_OPT_MSS; - pxTCPHeader->ucOptdata[ 1 ] = TCP_OPT_MSS_LEN; - pxTCPHeader->ucOptdata[ 2 ] = ( uint8_t ) ( ( pxSocket->u.xTCP.usCurMSS ) >> 8 ); - pxTCPHeader->ucOptdata[ 3 ] = ( uint8_t ) ( ( pxSocket->u.xTCP.usCurMSS ) & 0xffu ); - uxOptionsLength = 4u; - pxTCPHeader->ucTCPOffset = ( uint8_t )( ( ipSIZE_OF_TCP_HEADER + uxOptionsLength ) << 2 ); - } - - return uxOptionsLength; -} -/*-----------------------------------------------------------*/ - -/* - * prvHandleSynReceived(): called from prvTCPHandleState() - * - * Called from the states: eSYN_RECEIVED and eCONNECT_SYN - * If the flags received are correct, the socket will move to eESTABLISHED. - */ -static BaseType_t prvHandleSynReceived( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t **ppxNetworkBuffer, - uint32_t ulReceiveLength, UBaseType_t uxOptionsLength ) -{ -TCPPacket_t *pxTCPPacket = ( TCPPacket_t * ) ( (*ppxNetworkBuffer)->pucEthernetBuffer ); -TCPHeader_t *pxTCPHeader = &pxTCPPacket->xTCPHeader; -TCPWindow_t *pxTCPWindow = &pxSocket->u.xTCP.xTCPWindow; -uint8_t ucTCPFlags = pxTCPHeader->ucTCPFlags; -uint32_t ulSequenceNumber = FreeRTOS_ntohl( pxTCPHeader->ulSequenceNumber ); -BaseType_t xSendLength = 0; - - /* Either expect a ACK or a SYN+ACK. */ - uint16_t usExpect = ( uint16_t ) ipTCP_FLAG_ACK; - if( pxSocket->u.xTCP.ucTCPState == eCONNECT_SYN ) - { - usExpect |= ( uint16_t ) ipTCP_FLAG_SYN; - } - - if( ( ucTCPFlags & 0x17u ) != usExpect ) - { - /* eSYN_RECEIVED: flags 0010 expected, not 0002. */ - /* eSYN_RECEIVED: flags ACK expected, not SYN. */ - FreeRTOS_debug_printf( ( "%s: flags %04X expected, not %04X\n", - pxSocket->u.xTCP.ucTCPState == eSYN_RECEIVED ? "eSYN_RECEIVED" : "eCONNECT_SYN", - usExpect, ucTCPFlags ) ); - vTCPStateChange( pxSocket, eCLOSE_WAIT ); - pxTCPHeader->ucTCPFlags |= ipTCP_FLAG_RST; - xSendLength = ( BaseType_t ) ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + uxOptionsLength ); - pxTCPHeader->ucTCPOffset = ( uint8_t )( ( ipSIZE_OF_TCP_HEADER + uxOptionsLength ) << 2 ); - } - else - { - pxTCPWindow->usPeerPortNumber = pxSocket->u.xTCP.usRemotePort; - pxTCPWindow->usOurPortNumber = pxSocket->usLocalPort; - - if( pxSocket->u.xTCP.ucTCPState == eCONNECT_SYN ) - { - TCPPacket_t *pxLastTCPPacket = ( TCPPacket_t * ) ( pxSocket->u.xTCP.xPacket.u.ucLastPacket ); - - /* Clear the SYN flag in lastPacket. */ - pxLastTCPPacket->xTCPHeader.ucTCPFlags = ipTCP_FLAG_ACK; - - /* This socket was the one connecting actively so now perofmr the - synchronisation. */ - vTCPWindowInit( &pxSocket->u.xTCP.xTCPWindow, - ulSequenceNumber, pxSocket->u.xTCP.xTCPWindow.ulOurSequenceNumber, ( uint32_t ) pxSocket->u.xTCP.usCurMSS ); - pxTCPWindow->rx.ulCurrentSequenceNumber = pxTCPWindow->rx.ulHighestSequenceNumber = ulSequenceNumber + 1u; - pxTCPWindow->tx.ulCurrentSequenceNumber++; /* because we send a TCP_SYN [ | TCP_ACK ]; */ - pxTCPWindow->ulNextTxSequenceNumber++; - } - else if( ulReceiveLength == 0u ) - { - pxTCPWindow->rx.ulCurrentSequenceNumber = ulSequenceNumber; - } - - /* The SYN+ACK has been confirmed, increase the next sequence number by - 1. */ - pxTCPWindow->ulOurSequenceNumber = pxTCPWindow->tx.ulFirstSequenceNumber + 1u; - - #if( ipconfigUSE_TCP_WIN == 1 ) - { - FreeRTOS_debug_printf( ( "TCP: %s %d => %lxip:%d set ESTAB (scaling %u)\n", - pxSocket->u.xTCP.ucTCPState == eCONNECT_SYN ? "active" : "passive", - pxSocket->usLocalPort, - pxSocket->u.xTCP.ulRemoteIP, - pxSocket->u.xTCP.usRemotePort, - ( unsigned ) pxSocket->u.xTCP.bits.bWinScaling ) ); - } - #endif /* ipconfigUSE_TCP_WIN */ - - if( ( pxSocket->u.xTCP.ucTCPState == eCONNECT_SYN ) || ( ulReceiveLength != 0u ) ) - { - pxTCPHeader->ucTCPFlags = ipTCP_FLAG_ACK; - xSendLength = ( BaseType_t ) ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + uxOptionsLength ); - pxTCPHeader->ucTCPOffset = ( uint8_t ) ( ( ipSIZE_OF_TCP_HEADER + uxOptionsLength ) << 2 ); - } - #if( ipconfigUSE_TCP_WIN != 0 ) - { - if( pxSocket->u.xTCP.bits.bWinScaling == pdFALSE_UNSIGNED ) - { - /* The other party did not send a scaling factor. - A shifting factor in this side must be canceled. */ - pxSocket->u.xTCP.ucMyWinScaleFactor = 0; - pxSocket->u.xTCP.ucPeerWinScaleFactor = 0; - } - } - #endif /* ipconfigUSE_TCP_WIN */ - /* This was the third step of connecting: SYN, SYN+ACK, ACK so now the - connection is established. */ - vTCPStateChange( pxSocket, eESTABLISHED ); - } - - return xSendLength; -} -/*-----------------------------------------------------------*/ - -/* - * prvHandleEstablished(): called from prvTCPHandleState() - * - * Called if the status is eESTABLISHED. Data reception has been handled - * earlier. Here the ACK's from peer will be checked, and if a FIN is received, - * the code will check if it may be accepted, i.e. if all expected data has been - * completely received. - */ -static BaseType_t prvHandleEstablished( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t **ppxNetworkBuffer, - uint32_t ulReceiveLength, UBaseType_t uxOptionsLength ) -{ -TCPPacket_t *pxTCPPacket = ( TCPPacket_t * ) ( (*ppxNetworkBuffer)->pucEthernetBuffer ); -TCPHeader_t *pxTCPHeader = &pxTCPPacket->xTCPHeader; -TCPWindow_t *pxTCPWindow = &pxSocket->u.xTCP.xTCPWindow; -uint8_t ucTCPFlags = pxTCPHeader->ucTCPFlags; -uint32_t ulSequenceNumber = FreeRTOS_ntohl( pxTCPHeader->ulSequenceNumber ), ulCount; -BaseType_t xSendLength = 0, xMayClose = pdFALSE, bRxComplete, bTxDone; -int32_t lDistance, lSendResult; - - /* Remember the window size the peer is advertising. */ - pxSocket->u.xTCP.ulWindowSize = FreeRTOS_ntohs( pxTCPHeader->usWindow ); - #if( ipconfigUSE_TCP_WIN != 0 ) - { - pxSocket->u.xTCP.ulWindowSize = - ( pxSocket->u.xTCP.ulWindowSize << pxSocket->u.xTCP.ucPeerWinScaleFactor ); - } - #endif - - if( ( ucTCPFlags & ( uint8_t ) ipTCP_FLAG_ACK ) != 0u ) - { - ulCount = ulTCPWindowTxAck( pxTCPWindow, FreeRTOS_ntohl( pxTCPPacket->xTCPHeader.ulAckNr ) ); - - /* ulTCPWindowTxAck() returns the number of bytes which have been acked, - starting at 'tx.ulCurrentSequenceNumber'. Advance the tail pointer in - txStream. */ - if( ( pxSocket->u.xTCP.txStream != NULL ) && ( ulCount > 0u ) ) - { - /* Just advancing the tail index, 'ulCount' bytes have been - confirmed, and because there is new space in the txStream, the - user/owner should be woken up. */ - /* _HT_ : only in case the socket's waiting? */ - if( uxStreamBufferGet( pxSocket->u.xTCP.txStream, 0u, NULL, ( size_t ) ulCount, pdFALSE ) != 0u ) - { - pxSocket->xEventBits |= eSOCKET_SEND; - - #if ipconfigSUPPORT_SELECT_FUNCTION == 1 - { - if( ( pxSocket->xSelectBits & eSELECT_WRITE ) != 0 ) - { - pxSocket->xEventBits |= ( eSELECT_WRITE << SOCKET_EVENT_BIT_COUNT ); - } - } - #endif - /* In case the socket owner has installed an OnSent handler, - call it now. */ - #if( ipconfigUSE_CALLBACKS == 1 ) - { - if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xTCP.pxHandleSent ) ) - { - pxSocket->u.xTCP.pxHandleSent( (Socket_t *)pxSocket, ulCount ); - } - } - #endif /* ipconfigUSE_CALLBACKS == 1 */ - } - } - } - - /* If this socket has a stream for transmission, add the data to the - outgoing segment(s). */ - if( pxSocket->u.xTCP.txStream != NULL ) - { - prvTCPAddTxData( pxSocket ); - } - - pxSocket->u.xTCP.xTCPWindow.ulOurSequenceNumber = pxTCPWindow->tx.ulCurrentSequenceNumber; - - if( ( pxSocket->u.xTCP.bits.bFinAccepted != pdFALSE_UNSIGNED ) || ( ( ucTCPFlags & ( uint8_t ) ipTCP_FLAG_FIN ) != 0u ) ) - { - /* Peer is requesting to stop, see if we're really finished. */ - xMayClose = pdTRUE; - - /* Checks are only necessary if we haven't sent a FIN yet. */ - if( pxSocket->u.xTCP.bits.bFinSent == pdFALSE_UNSIGNED ) - { - /* xTCPWindowTxDone returns true when all Tx queues are empty. */ - bRxComplete = xTCPWindowRxEmpty( pxTCPWindow ); - bTxDone = xTCPWindowTxDone( pxTCPWindow ); - - if( ( bRxComplete == 0 ) || ( bTxDone == 0 ) ) - { - /* Refusing FIN: Rx incomp 1 optlen 4 tx done 1. */ - FreeRTOS_debug_printf( ( "Refusing FIN[%u,%u]: RxCompl %lu tx done %ld\n", - pxSocket->usLocalPort, - pxSocket->u.xTCP.usRemotePort, - bRxComplete, bTxDone ) ); - xMayClose = pdFALSE; - } - else - { - lDistance = ( int32_t ) ( ulSequenceNumber + ulReceiveLength - pxTCPWindow->rx.ulCurrentSequenceNumber ); - - if( lDistance > 1 ) - { - FreeRTOS_debug_printf( ( "Refusing FIN: Rx not complete %ld (cur %lu high %lu)\n", - lDistance, pxTCPWindow->rx.ulCurrentSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber, - pxTCPWindow->rx.ulHighestSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber ) ); - - xMayClose = pdFALSE; - } - } - } - - if( xTCPWindowLoggingLevel > 0 ) - { - FreeRTOS_debug_printf( ( "TCP: FIN received, mayClose = %ld (Rx %lu Len %ld, Tx %lu)\n", - xMayClose, ulSequenceNumber - pxSocket->u.xTCP.xTCPWindow.rx.ulFirstSequenceNumber, ulReceiveLength, - pxTCPWindow->tx.ulCurrentSequenceNumber - pxSocket->u.xTCP.xTCPWindow.tx.ulFirstSequenceNumber ) ); - } - - if( xMayClose != pdFALSE ) - { - pxSocket->u.xTCP.bits.bFinAccepted = pdTRUE_UNSIGNED; - xSendLength = prvTCPHandleFin( pxSocket, *ppxNetworkBuffer ); - } - } - - if( xMayClose == pdFALSE ) - { - pxTCPHeader->ucTCPFlags = ipTCP_FLAG_ACK; - - if( ulReceiveLength != 0u ) - { - xSendLength = ( BaseType_t ) ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + uxOptionsLength ); - /* TCP-offsett equals '( ( length / 4 ) << 4 )', resulting in a shift-left 2 */ - pxTCPHeader->ucTCPOffset = ( uint8_t )( ( ipSIZE_OF_TCP_HEADER + uxOptionsLength ) << 2 ); - - if( pxSocket->u.xTCP.bits.bFinSent != pdFALSE_UNSIGNED ) - { - pxTCPWindow->tx.ulCurrentSequenceNumber = pxTCPWindow->tx.ulFINSequenceNumber; - } - } - - /* Now get data to be transmitted. */ - /* _HT_ patch: since the MTU has be fixed at 1500 in stead of 1526, TCP - can not send-out both TCP options and also a full packet. Sending - options (SACK) is always more urgent than sending data, which can be - sent later. */ - if( uxOptionsLength == 0u ) - { - /* prvTCPPrepareSend might allocate a bigger network buffer, if - necessary. */ - lSendResult = prvTCPPrepareSend( pxSocket, ppxNetworkBuffer, uxOptionsLength ); - if( lSendResult > 0 ) - { - xSendLength = ( BaseType_t ) lSendResult; - } - } - } - - return xSendLength; -} -/*-----------------------------------------------------------*/ - -/* - * Called from prvTCPHandleState(). There is data to be sent. If - * ipconfigUSE_TCP_WIN is defined, and if only an ACK must be sent, it will be - * checked if it would better be postponed for efficiency. - */ -static BaseType_t prvSendData( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t **ppxNetworkBuffer, - uint32_t ulReceiveLength, BaseType_t xSendLength ) -{ -TCPPacket_t *pxTCPPacket = ( TCPPacket_t * ) ( (*ppxNetworkBuffer)->pucEthernetBuffer ); -TCPHeader_t *pxTCPHeader = &pxTCPPacket->xTCPHeader; -TCPWindow_t *pxTCPWindow = &pxSocket->u.xTCP.xTCPWindow; -/* Find out what window size we may advertised. */ -uint32_t ulFrontSpace; -int32_t lRxSpace; -#if( ipconfigUSE_TCP_WIN == 1 ) - #if( ipconfigTCP_ACK_EARLIER_PACKET == 0 ) - const int32_t lMinLength = 0; - #else - int32_t lMinLength; - #endif -#endif - pxSocket->u.xTCP.ulRxCurWinSize = pxTCPWindow->xSize.ulRxWindowLength - - ( pxTCPWindow->rx.ulHighestSequenceNumber - pxTCPWindow->rx.ulCurrentSequenceNumber ); - - /* Free space in rxStream. */ - if( pxSocket->u.xTCP.rxStream != NULL ) - { - ulFrontSpace = ( uint32_t ) uxStreamBufferFrontSpace( pxSocket->u.xTCP.rxStream ); - } - else - { - ulFrontSpace = ( uint32_t ) pxSocket->u.xTCP.uxRxStreamSize; - } - - pxSocket->u.xTCP.ulRxCurWinSize = FreeRTOS_min_uint32( ulFrontSpace, pxSocket->u.xTCP.ulRxCurWinSize ); - - /* Set the time-out field, so that we'll be called by the IP-task in case no - next message will be received. */ - lRxSpace = (int32_t)( pxSocket->u.xTCP.ulHighestRxAllowed - pxTCPWindow->rx.ulCurrentSequenceNumber ); - #if ipconfigUSE_TCP_WIN == 1 - { - - #if( ipconfigTCP_ACK_EARLIER_PACKET != 0 ) - { - lMinLength = ( ( int32_t ) 2 ) * ( ( int32_t ) pxSocket->u.xTCP.usCurMSS ); - } - #endif /* ipconfigTCP_ACK_EARLIER_PACKET */ - - /* In case we're receiving data continuously, we might postpone sending - an ACK to gain performance. */ - if( ( ulReceiveLength > 0 ) && /* Data was sent to this socket. */ - ( lRxSpace >= lMinLength ) && /* There is Rx space for more data. */ - ( pxSocket->u.xTCP.bits.bFinSent == pdFALSE_UNSIGNED ) && /* Not in a closure phase. */ - ( xSendLength == ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER ) ) && /* No Tx data or options to be sent. */ - ( pxSocket->u.xTCP.ucTCPState == eESTABLISHED ) && /* Connection established. */ - ( pxTCPHeader->ucTCPFlags == ipTCP_FLAG_ACK ) ) /* There are no other flags than an ACK. */ - { - if( pxSocket->u.xTCP.pxAckMessage != *ppxNetworkBuffer ) - { - /* There was still a delayed in queue, delete it. */ - if( pxSocket->u.xTCP.pxAckMessage != 0 ) - { - vReleaseNetworkBufferAndDescriptor( pxSocket->u.xTCP.pxAckMessage ); - } - - pxSocket->u.xTCP.pxAckMessage = *ppxNetworkBuffer; - } - if( ( ulReceiveLength < ( uint32_t ) pxSocket->u.xTCP.usCurMSS ) || /* Received a small message. */ - ( lRxSpace < ( int32_t ) ( 2U * pxSocket->u.xTCP.usCurMSS ) ) ) /* There are less than 2 x MSS space in the Rx buffer. */ - { - pxSocket->u.xTCP.usTimeout = ( uint16_t ) pdMS_TO_MIN_TICKS( DELAYED_ACK_SHORT_DELAY_MS ); - } - else - { - /* Normally a delayed ACK should wait 200 ms for a next incoming - packet. Only wait 20 ms here to gain performance. A slow ACK - for full-size message. */ - pxSocket->u.xTCP.usTimeout = ( uint16_t ) pdMS_TO_MIN_TICKS( DELAYED_ACK_LONGER_DELAY_MS ); - } - - if( ( xTCPWindowLoggingLevel > 1 ) && ( ipconfigTCP_MAY_LOG_PORT( pxSocket->usLocalPort ) != pdFALSE ) ) - { - FreeRTOS_debug_printf( ( "Send[%u->%u] del ACK %lu SEQ %lu (len %lu) tmout %u d %lu\n", - pxSocket->usLocalPort, - pxSocket->u.xTCP.usRemotePort, - pxTCPWindow->rx.ulCurrentSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber, - pxSocket->u.xTCP.xTCPWindow.ulOurSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber, - xSendLength, - pxSocket->u.xTCP.usTimeout, lRxSpace ) ); - } - - *ppxNetworkBuffer = NULL; - xSendLength = 0; - } - else if( pxSocket->u.xTCP.pxAckMessage != NULL ) - { - /* As an ACK is not being delayed, remove any earlier delayed ACK - message. */ - if( pxSocket->u.xTCP.pxAckMessage != *ppxNetworkBuffer ) - { - vReleaseNetworkBufferAndDescriptor( pxSocket->u.xTCP.pxAckMessage ); - } - - pxSocket->u.xTCP.pxAckMessage = NULL; - } - } - #else - { - /* Remove compiler warnings. */ - ( void ) ulReceiveLength; - ( void ) pxTCPHeader; - ( void ) lRxSpace; - } - #endif /* ipconfigUSE_TCP_WIN */ - - if( xSendLength != 0 ) - { - if( ( xTCPWindowLoggingLevel > 1 ) && ( ipconfigTCP_MAY_LOG_PORT( pxSocket->usLocalPort ) != pdFALSE ) ) - { - FreeRTOS_debug_printf( ( "Send[%u->%u] imm ACK %lu SEQ %lu (len %lu)\n", - pxSocket->usLocalPort, - pxSocket->u.xTCP.usRemotePort, - pxTCPWindow->rx.ulCurrentSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber, - pxTCPWindow->ulOurSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber, - xSendLength ) ); - } - - /* Set the parameter 'xReleaseAfterSend' to the value of - ipconfigZERO_COPY_TX_DRIVER. */ - prvTCPReturnPacket( pxSocket, *ppxNetworkBuffer, ( uint32_t ) xSendLength, ipconfigZERO_COPY_TX_DRIVER ); - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* The driver has taken ownership of the Network Buffer. */ - *ppxNetworkBuffer = NULL; - } - #endif - } - - return xSendLength; -} -/*-----------------------------------------------------------*/ - -/* - * prvTCPHandleState() - * is the most important function of this TCP stack - * We've tried to keep it (relatively short) by putting a lot of code in - * the static functions above: - * - * prvCheckRxData() - * prvStoreRxData() - * prvSetOptions() - * prvHandleSynReceived() - * prvHandleEstablished() - * prvSendData() - * - * As these functions are declared static, and they're called from one location - * only, most compilers will inline them, thus avoiding a call and return. - */ -static BaseType_t prvTCPHandleState( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t **ppxNetworkBuffer ) -{ -TCPPacket_t *pxTCPPacket = ( TCPPacket_t * ) ( (*ppxNetworkBuffer)->pucEthernetBuffer ); -TCPHeader_t *pxTCPHeader = &( pxTCPPacket->xTCPHeader ); -BaseType_t xSendLength = 0; -uint32_t ulReceiveLength; /* Number of bytes contained in the TCP message. */ -uint8_t *pucRecvData; -uint32_t ulSequenceNumber = FreeRTOS_ntohl (pxTCPHeader->ulSequenceNumber); - - /* uxOptionsLength: the size of the options to be sent (always a multiple of - 4 bytes) - 1. in the SYN phase, we shall communicate the MSS - 2. in case of a SACK, Selective ACK, ack a segment which comes in - out-of-order. */ -UBaseType_t uxOptionsLength = 0u; -uint8_t ucTCPFlags = pxTCPHeader->ucTCPFlags; -TCPWindow_t *pxTCPWindow = &( pxSocket->u.xTCP.xTCPWindow ); - - /* First get the length and the position of the received data, if any. - pucRecvData will point to the first byte of the TCP payload. */ - ulReceiveLength = ( uint32_t ) prvCheckRxData( *ppxNetworkBuffer, &pucRecvData ); - - if( pxSocket->u.xTCP.ucTCPState >= eESTABLISHED ) - { - if ( pxTCPWindow->rx.ulCurrentSequenceNumber == ulSequenceNumber + 1u ) - { - /* This is most probably a keep-alive message from peer. Setting - 'bWinChange' doesn't cause a window-size-change, the flag is used - here to force sending an immediate ACK. */ - pxSocket->u.xTCP.bits.bWinChange = pdTRUE_UNSIGNED; - } - } - - /* Keep track of the highest sequence number that might be expected within - this connection. */ - if( ( ( int32_t ) ( ulSequenceNumber + ulReceiveLength - pxTCPWindow->rx.ulHighestSequenceNumber ) ) > 0 ) - { - pxTCPWindow->rx.ulHighestSequenceNumber = ulSequenceNumber + ulReceiveLength; - } - - /* Storing data may result in a fatal error if malloc() fails. */ - if( prvStoreRxData( pxSocket, pucRecvData, *ppxNetworkBuffer, ulReceiveLength ) < 0 ) - { - xSendLength = -1; - } - else - { - uxOptionsLength = prvSetOptions( pxSocket, *ppxNetworkBuffer ); - - if( ( pxSocket->u.xTCP.ucTCPState == eSYN_RECEIVED ) && ( ( ucTCPFlags & ipTCP_FLAG_CTRL ) == ipTCP_FLAG_SYN ) ) - { - FreeRTOS_debug_printf( ( "eSYN_RECEIVED: ACK expected, not SYN: peer missed our SYN+ACK\n" ) ); - - /* In eSYN_RECEIVED a simple ACK is expected, but apparently the - 'SYN+ACK' didn't arrive. Step back to the previous state in which - a first incoming SYN is handled. The SYN was counted already so - decrease it first. */ - vTCPStateChange( pxSocket, eSYN_FIRST ); - } - - if( ( ( ucTCPFlags & ipTCP_FLAG_FIN ) != 0u ) && ( pxSocket->u.xTCP.bits.bFinRecv == pdFALSE_UNSIGNED ) ) - { - /* It's the first time a FIN has been received, remember its - sequence number. */ - pxTCPWindow->rx.ulFINSequenceNumber = ulSequenceNumber + ulReceiveLength; - pxSocket->u.xTCP.bits.bFinRecv = pdTRUE_UNSIGNED; - - /* Was peer the first one to send a FIN? */ - if( pxSocket->u.xTCP.bits.bFinSent == pdFALSE_UNSIGNED ) - { - /* If so, don't send the-last-ACK. */ - pxSocket->u.xTCP.bits.bFinLast = pdTRUE_UNSIGNED; - } - } - - switch (pxSocket->u.xTCP.ucTCPState) - { - case eCLOSED: /* (server + client) no connection state at all. */ - /* Nothing to do for a closed socket, except waiting for the - owner. */ - break; - - case eTCP_LISTEN: /* (server) waiting for a connection request from - any remote TCP and port. */ - /* The listen state was handled in xProcessReceivedTCPPacket(). - Should not come here. */ - break; - - case eSYN_FIRST: /* (server) Just received a SYN request for a server - socket. */ - { - /* A new socket has been created, reply with a SYN+ACK. - Acknowledge with seq+1 because the SYN is seen as pseudo data - with len = 1. */ - uxOptionsLength = prvSetSynAckOptions( pxSocket, pxTCPPacket ); - pxTCPHeader->ucTCPFlags = ipTCP_FLAG_SYN | ipTCP_FLAG_ACK; - - xSendLength = ( BaseType_t ) ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + uxOptionsLength ); - - /* Set the TCP offset field: ipSIZE_OF_TCP_HEADER equals 20 and - uxOptionsLength is a multiple of 4. The complete expression is: - ucTCPOffset = ( ( ipSIZE_OF_TCP_HEADER + uxOptionsLength ) / 4 ) << 4 */ - pxTCPHeader->ucTCPOffset = ( uint8_t )( ( ipSIZE_OF_TCP_HEADER + uxOptionsLength ) << 2 ); - vTCPStateChange( pxSocket, eSYN_RECEIVED ); - - pxTCPWindow->rx.ulCurrentSequenceNumber = pxTCPWindow->rx.ulHighestSequenceNumber = ulSequenceNumber + 1u; - pxTCPWindow->tx.ulCurrentSequenceNumber = pxTCPWindow->ulNextTxSequenceNumber = pxTCPWindow->tx.ulFirstSequenceNumber + 1u; /* because we send a TCP_SYN. */ - } - break; - - case eCONNECT_SYN: /* (client) also called SYN_SENT: we've just send a - SYN, expect a SYN+ACK and send a ACK now. */ - /* Fall through */ - case eSYN_RECEIVED: /* (server) we've had a SYN, replied with SYN+SCK - expect a ACK and do nothing. */ - xSendLength = prvHandleSynReceived( pxSocket, ppxNetworkBuffer, ulReceiveLength, uxOptionsLength ); - break; - - case eESTABLISHED: /* (server + client) an open connection, data - received can be delivered to the user. The normal - state for the data transfer phase of the connection - The closing states are also handled here with the - use of some flags. */ - xSendLength = prvHandleEstablished( pxSocket, ppxNetworkBuffer, ulReceiveLength, uxOptionsLength ); - break; - - case eLAST_ACK: /* (server + client) waiting for an acknowledgement - of the connection termination request previously - sent to the remote TCP (which includes an - acknowledgement of its connection termination - request). */ - /* Fall through */ - case eFIN_WAIT_1: /* (server + client) waiting for a connection termination request from the remote TCP, - * or an acknowledgement of the connection termination request previously sent. */ - /* Fall through */ - case eFIN_WAIT_2: /* (server + client) waiting for a connection termination request from the remote TCP. */ - xSendLength = prvTCPHandleFin( pxSocket, *ppxNetworkBuffer ); - break; - - case eCLOSE_WAIT: /* (server + client) waiting for a connection - termination request from the local user. Nothing to - do, connection is closed, wait for owner to close - this socket. */ - break; - - case eCLOSING: /* (server + client) waiting for a connection - termination request acknowledgement from the remote - TCP. */ - break; - - case eTIME_WAIT: /* (either server or client) waiting for enough time - to pass to be sure the remote TCP received the - acknowledgement of its connection termination - request. [According to RFC 793 a connection can stay - in TIME-WAIT for a maximum of four minutes known as - a MSL (maximum segment lifetime).] These states are - implemented implicitly by settings flags like - 'bFinSent', 'bFinRecv', and 'bFinAcked'. */ - break; - default: - break; - } - } - - if( xSendLength > 0 ) - { - xSendLength = prvSendData( pxSocket, ppxNetworkBuffer, ulReceiveLength, xSendLength ); - } - - return xSendLength; -} -/*-----------------------------------------------------------*/ - -static BaseType_t prvTCPSendReset( NetworkBufferDescriptor_t *pxNetworkBuffer ) -{ - #if( ipconfigIGNORE_UNKNOWN_PACKETS == 0 ) - { - TCPPacket_t *pxTCPPacket = ( TCPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuffer ); - const BaseType_t xSendLength = ( BaseType_t ) ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + 0u ); /* Plus 0 options. */ - - pxTCPPacket->xTCPHeader.ucTCPFlags = ipTCP_FLAG_ACK | ipTCP_FLAG_RST; - pxTCPPacket->xTCPHeader.ucTCPOffset = ( ipSIZE_OF_TCP_HEADER + 0u ) << 2; - - prvTCPReturnPacket( NULL, pxNetworkBuffer, ( uint32_t ) xSendLength, pdFALSE ); - } - #endif /* !ipconfigIGNORE_UNKNOWN_PACKETS */ - - /* Remove compiler warnings if ipconfigIGNORE_UNKNOWN_PACKETS == 1. */ - ( void ) pxNetworkBuffer; - - /* The packet was not consumed. */ - return pdFAIL; -} -/*-----------------------------------------------------------*/ - -static void prvSocketSetMSS( FreeRTOS_Socket_t *pxSocket ) -{ -uint32_t ulMSS = ipconfigTCP_MSS; - - if( ( ( FreeRTOS_ntohl( pxSocket->u.xTCP.ulRemoteIP ) ^ *ipLOCAL_IP_ADDRESS_POINTER ) & xNetworkAddressing.ulNetMask ) != 0ul ) - { - /* Data for this peer will pass through a router, and maybe through - the internet. Limit the MSS to 1400 bytes or less. */ - ulMSS = FreeRTOS_min_uint32( ( uint32_t ) REDUCED_MSS_THROUGH_INTERNET, ulMSS ); - } - - FreeRTOS_debug_printf( ( "prvSocketSetMSS: %lu bytes for %lxip:%u\n", ulMSS, pxSocket->u.xTCP.ulRemoteIP, pxSocket->u.xTCP.usRemotePort ) ); - - pxSocket->u.xTCP.usInitMSS = pxSocket->u.xTCP.usCurMSS = ( uint16_t ) ulMSS; -} -/*-----------------------------------------------------------*/ - -/* - * FreeRTOS_TCP_IP has only 2 public functions, this is the second one: - * xProcessReceivedTCPPacket() - * prvTCPHandleState() - * prvTCPPrepareSend() - * prvTCPReturnPacket() - * xNetworkInterfaceOutput() // Sends data to the NIC - * prvTCPSendRepeated() - * prvTCPReturnPacket() // Prepare for returning - * xNetworkInterfaceOutput() // Sends data to the NIC -*/ -BaseType_t xProcessReceivedTCPPacket( NetworkBufferDescriptor_t *pxNetworkBuffer ) -{ -FreeRTOS_Socket_t *pxSocket; -TCPPacket_t * pxTCPPacket = ( TCPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuffer ); -uint16_t ucTCPFlags; -uint32_t ulLocalIP; -uint16_t xLocalPort; -uint32_t ulRemoteIP; -uint16_t xRemotePort; -BaseType_t xResult = pdPASS; - - /* Check for a minimum packet size. */ - if( pxNetworkBuffer->xDataLength >= ( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER ) ) - { - ucTCPFlags = pxTCPPacket->xTCPHeader.ucTCPFlags; - ulLocalIP = FreeRTOS_htonl( pxTCPPacket->xIPHeader.ulDestinationIPAddress ); - xLocalPort = FreeRTOS_htons( pxTCPPacket->xTCPHeader.usDestinationPort ); - ulRemoteIP = FreeRTOS_htonl( pxTCPPacket->xIPHeader.ulSourceIPAddress ); - xRemotePort = FreeRTOS_htons( pxTCPPacket->xTCPHeader.usSourcePort ); - - /* Find the destination socket, and if not found: return a socket listing to - the destination PORT. */ - pxSocket = ( FreeRTOS_Socket_t * )pxTCPSocketLookup( ulLocalIP, xLocalPort, ulRemoteIP, xRemotePort ); - } - else - { - return pdFAIL; - } - - if( ( pxSocket == NULL ) || ( prvTCPSocketIsActive( ( UBaseType_t ) pxSocket->u.xTCP.ucTCPState ) == pdFALSE ) ) - { - /* A TCP messages is received but either there is no socket with the - given port number or the there is a socket, but it is in one of these - non-active states: eCLOSED, eCLOSE_WAIT, eFIN_WAIT_2, eCLOSING, or - eTIME_WAIT. */ - - FreeRTOS_debug_printf( ( "TCP: No active socket on port %d (%lxip:%d)\n", xLocalPort, ulRemoteIP, xRemotePort ) ); - - /* Send a RST to all packets that can not be handled. As a result - the other party will get a ECONN error. There are two exceptions: - 1) A packet that already has the RST flag set. - 2) A packet that only has the ACK flag set. - A packet with only the ACK flag set might be the last ACK in - a three-way hand-shake that closes a connection. */ - if( ( ( ucTCPFlags & ipTCP_FLAG_CTRL ) != ipTCP_FLAG_ACK ) && - ( ( ucTCPFlags & ipTCP_FLAG_RST ) == 0u ) ) - { - prvTCPSendReset( pxNetworkBuffer ); - } - - /* The packet can't be handled. */ - xResult = pdFAIL; - } - else - { - pxSocket->u.xTCP.ucRepCount = 0u; - - if( pxSocket->u.xTCP.ucTCPState == eTCP_LISTEN ) - { - /* The matching socket is in a listening state. Test if the peer - has set the SYN flag. */ - if( ( ucTCPFlags & ipTCP_FLAG_CTRL ) != ipTCP_FLAG_SYN ) - { - /* What happens: maybe after a reboot, a client doesn't know the - connection had gone. Send a RST in order to get a new connect - request. */ - #if( ipconfigHAS_DEBUG_PRINTF == 1 ) - { - FreeRTOS_debug_printf( ( "TCP: Server can't handle flags: %s from %lxip:%u to port %u\n", - prvTCPFlagMeaning( ( UBaseType_t ) ucTCPFlags ), ulRemoteIP, xRemotePort, xLocalPort ) ); - } - #endif /* ipconfigHAS_DEBUG_PRINTF */ - - if( ( ucTCPFlags & ipTCP_FLAG_RST ) == 0u ) - { - prvTCPSendReset( pxNetworkBuffer ); - } - xResult = pdFAIL; - } - else - { - /* prvHandleListen() will either return a newly created socket - (if bReuseSocket is false), otherwise it returns the current - socket which will later get connected. */ - pxSocket = prvHandleListen( pxSocket, pxNetworkBuffer ); - - if( pxSocket == NULL ) - { - xResult = pdFAIL; - } - } - } /* if( pxSocket->u.xTCP.ucTCPState == eTCP_LISTEN ). */ - else - { - /* This is not a socket in listening mode. Check for the RST - flag. */ - if( ( ucTCPFlags & ipTCP_FLAG_RST ) != 0u ) - { - /* The target socket is not in a listening state, any RST packet - will cause the socket to be closed. */ - FreeRTOS_debug_printf( ( "TCP: RST received from %lxip:%u for %u\n", ulRemoteIP, xRemotePort, xLocalPort ) ); - /* _HT_: should indicate that 'ECONNRESET' must be returned to the used during next API. */ - vTCPStateChange( pxSocket, eCLOSED ); - - /* The packet cannot be handled. */ - xResult = pdFAIL; - } - else if( ( ( ucTCPFlags & ipTCP_FLAG_CTRL ) == ipTCP_FLAG_SYN ) && ( pxSocket->u.xTCP.ucTCPState >= eESTABLISHED ) ) - { - /* SYN flag while this socket is already connected. */ - FreeRTOS_debug_printf( ( "TCP: SYN unexpected from %lxip:%u\n", ulRemoteIP, xRemotePort ) ); - - /* The packet cannot be handled. */ - xResult = pdFAIL; - } - else - { - /* Update the copy of the TCP header only (skipping eth and IP - headers). It might be used later on, whenever data must be sent - to the peer. */ - const BaseType_t lOffset = ( BaseType_t ) ( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER ); - memcpy( pxSocket->u.xTCP.xPacket.u.ucLastPacket + lOffset, pxNetworkBuffer->pucEthernetBuffer + lOffset, ipSIZE_OF_TCP_HEADER ); - } - } - } - - if( xResult != pdFAIL ) - { - /* Touch the alive timers because we received a message for this - socket. */ - prvTCPTouchSocket( pxSocket ); - - /* Parse the TCP option(s), if present. */ - /* _HT_ : if we're in the SYN phase, and peer does not send a MSS option, - then we MUST assume an MSS size of 536 bytes for backward compatibility. */ - - /* When there are no TCP options, the TCP offset equals 20 bytes, which is stored as - the number 5 (words) in the higher niblle of the TCP-offset byte. */ - if( ( pxTCPPacket->xTCPHeader.ucTCPOffset & TCP_OFFSET_LENGTH_BITS ) > TCP_OFFSET_STANDARD_LENGTH ) - { - prvCheckOptions( pxSocket, pxNetworkBuffer ); - } - - - #if( ipconfigUSE_TCP_WIN == 1 ) - { - pxSocket->u.xTCP.ulWindowSize = FreeRTOS_ntohs( pxTCPPacket->xTCPHeader.usWindow ); - pxSocket->u.xTCP.ulWindowSize = - ( pxSocket->u.xTCP.ulWindowSize << pxSocket->u.xTCP.ucPeerWinScaleFactor ); - } - #endif - - /* In prvTCPHandleState() the incoming messages will be handled - depending on the current state of the connection. */ - if( prvTCPHandleState( pxSocket, &pxNetworkBuffer ) > 0 ) - { - /* prvTCPHandleState() has sent a message, see if there are more to - be transmitted. */ - #if( ipconfigUSE_TCP_WIN == 1 ) - { - prvTCPSendRepeated( pxSocket, &pxNetworkBuffer ); - } - #endif /* ipconfigUSE_TCP_WIN */ - } - - if( pxNetworkBuffer != NULL ) - { - /* We must check if the buffer is unequal to NULL, because the - socket might keep a reference to it in case a delayed ACK must be - sent. */ - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - pxNetworkBuffer = NULL; - } - - /* And finally, calculate when this socket wants to be woken up. */ - prvTCPNextTimeout ( pxSocket ); - /* Return pdPASS to tell that the network buffer is 'consumed'. */ - xResult = pdPASS; - } - - /* pdPASS being returned means the buffer has been consumed. */ - return xResult; -} -/*-----------------------------------------------------------*/ - -static FreeRTOS_Socket_t *prvHandleListen( FreeRTOS_Socket_t *pxSocket, NetworkBufferDescriptor_t *pxNetworkBuffer ) -{ -TCPPacket_t * pxTCPPacket = ( TCPPacket_t * ) ( pxNetworkBuffer->pucEthernetBuffer ); -FreeRTOS_Socket_t *pxReturn = NULL; -uint32_t ulInitialSequenceNumber; - - /* Assume that a new Initial Sequence Number will be required. Request - it now in order to fail out if necessary. */ - ulInitialSequenceNumber = ulApplicationGetNextSequenceNumber( *ipLOCAL_IP_ADDRESS_POINTER, - pxSocket->usLocalPort, - pxTCPPacket->xIPHeader.ulSourceIPAddress, - pxTCPPacket->xTCPHeader.usSourcePort ); - - /* A pure SYN (without ACK) has come in, create a new socket to answer - it. */ - if( 0 != ulInitialSequenceNumber ) - { - if( pxSocket->u.xTCP.bits.bReuseSocket != pdFALSE_UNSIGNED ) - { - /* The flag bReuseSocket indicates that the same instance of the - listening socket should be used for the connection. */ - pxReturn = pxSocket; - pxSocket->u.xTCP.bits.bPassQueued = pdTRUE_UNSIGNED; - pxSocket->u.xTCP.pxPeerSocket = pxSocket; - } - else - { - /* The socket does not have the bReuseSocket flag set meaning create a - new socket when a connection comes in. */ - pxReturn = NULL; - - if( pxSocket->u.xTCP.usChildCount >= pxSocket->u.xTCP.usBacklog ) - { - FreeRTOS_printf( ( "Check: Socket %u already has %u / %u child%s\n", - pxSocket->usLocalPort, - pxSocket->u.xTCP.usChildCount, - pxSocket->u.xTCP.usBacklog, - pxSocket->u.xTCP.usChildCount == 1 ? "" : "ren" ) ); - prvTCPSendReset( pxNetworkBuffer ); - } - else - { - FreeRTOS_Socket_t *pxNewSocket = ( FreeRTOS_Socket_t * ) - FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP ); - - if( ( pxNewSocket == NULL ) || ( pxNewSocket == FREERTOS_INVALID_SOCKET ) ) - { - FreeRTOS_debug_printf( ( "TCP: Listen: new socket failed\n" ) ); - prvTCPSendReset( pxNetworkBuffer ); - } - else if( prvTCPSocketCopy( pxNewSocket, pxSocket ) != pdFALSE ) - { - /* The socket will be connected immediately, no time for the - owner to setsockopt's, therefore copy properties of the server - socket to the new socket. Only the binding might fail (due to - lack of resources). */ - pxReturn = pxNewSocket; - } - } - } - } - - if( ( 0 != ulInitialSequenceNumber ) && ( pxReturn != NULL ) ) - { - pxReturn->u.xTCP.usRemotePort = FreeRTOS_htons( pxTCPPacket->xTCPHeader.usSourcePort ); - pxReturn->u.xTCP.ulRemoteIP = FreeRTOS_htonl( pxTCPPacket->xIPHeader.ulSourceIPAddress ); - pxReturn->u.xTCP.xTCPWindow.ulOurSequenceNumber = ulInitialSequenceNumber; - - /* Here is the SYN action. */ - pxReturn->u.xTCP.xTCPWindow.rx.ulCurrentSequenceNumber = FreeRTOS_ntohl( pxTCPPacket->xTCPHeader.ulSequenceNumber ); - prvSocketSetMSS( pxReturn ); - - prvTCPCreateWindow( pxReturn ); - - vTCPStateChange( pxReturn, eSYN_FIRST ); - - /* Make a copy of the header up to the TCP header. It is needed later - on, whenever data must be sent to the peer. */ - memcpy( pxReturn->u.xTCP.xPacket.u.ucLastPacket, pxNetworkBuffer->pucEthernetBuffer, sizeof( pxReturn->u.xTCP.xPacket.u.ucLastPacket ) ); - } - return pxReturn; -} -/*-----------------------------------------------------------*/ - -/* - * Duplicates a socket after a listening socket receives a connection. - */ -static BaseType_t prvTCPSocketCopy( FreeRTOS_Socket_t *pxNewSocket, FreeRTOS_Socket_t *pxSocket ) -{ -struct freertos_sockaddr xAddress; - - pxNewSocket->xReceiveBlockTime = pxSocket->xReceiveBlockTime; - pxNewSocket->xSendBlockTime = pxSocket->xSendBlockTime; - pxNewSocket->ucSocketOptions = pxSocket->ucSocketOptions; - pxNewSocket->u.xTCP.uxRxStreamSize = pxSocket->u.xTCP.uxRxStreamSize; - pxNewSocket->u.xTCP.uxTxStreamSize = pxSocket->u.xTCP.uxTxStreamSize; - pxNewSocket->u.xTCP.uxLittleSpace = pxSocket->u.xTCP.uxLittleSpace; - pxNewSocket->u.xTCP.uxEnoughSpace = pxSocket->u.xTCP.uxEnoughSpace; - pxNewSocket->u.xTCP.uxRxWinSize = pxSocket->u.xTCP.uxRxWinSize; - pxNewSocket->u.xTCP.uxTxWinSize = pxSocket->u.xTCP.uxTxWinSize; - - #if( ipconfigSOCKET_HAS_USER_SEMAPHORE == 1 ) - { - pxNewSocket->pxUserSemaphore = pxSocket->pxUserSemaphore; - } - #endif /* ipconfigSOCKET_HAS_USER_SEMAPHORE */ - - #if( ipconfigUSE_CALLBACKS == 1 ) - { - /* In case call-backs are used, copy them from parent to child. */ - pxNewSocket->u.xTCP.pxHandleConnected = pxSocket->u.xTCP.pxHandleConnected; - pxNewSocket->u.xTCP.pxHandleReceive = pxSocket->u.xTCP.pxHandleReceive; - pxNewSocket->u.xTCP.pxHandleSent = pxSocket->u.xTCP.pxHandleSent; - } - #endif /* ipconfigUSE_CALLBACKS */ - - #if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - { - /* Child socket of listening sockets will inherit the Socket Set - Otherwise the owner has no chance of including it into the set. */ - if( pxSocket->pxSocketSet ) - { - pxNewSocket->pxSocketSet = pxSocket->pxSocketSet; - pxNewSocket->xSelectBits = pxSocket->xSelectBits | eSELECT_READ | eSELECT_EXCEPT; - } - } - #endif /* ipconfigSUPPORT_SELECT_FUNCTION */ - - /* And bind it to the same local port as its parent. */ - xAddress.sin_addr = *ipLOCAL_IP_ADDRESS_POINTER; - xAddress.sin_port = FreeRTOS_htons( pxSocket->usLocalPort ); - - #if( ipconfigTCP_HANG_PROTECTION == 1 ) - { - /* Only when there is anti-hanging protection, a socket may become an - orphan temporarily. Once this socket is really connected, the owner of - the server socket will be notified. */ - - /* When bPassQueued is true, the socket is an orphan until it gets - connected. */ - pxNewSocket->u.xTCP.bits.bPassQueued = pdTRUE_UNSIGNED; - pxNewSocket->u.xTCP.pxPeerSocket = pxSocket; - } - #else - { - /* A reference to the new socket may be stored and the socket is marked - as 'passable'. */ - - /* When bPassAccept is pdTRUE_UNSIGNED this socket may be returned in a call to - accept(). */ - pxNewSocket->u.xTCP.bits.bPassAccept = pdTRUE_UNSIGNED; - if(pxSocket->u.xTCP.pxPeerSocket == NULL ) - { - pxSocket->u.xTCP.pxPeerSocket = pxNewSocket; - } - } - #endif - - pxSocket->u.xTCP.usChildCount++; - - FreeRTOS_debug_printf( ( "Gain: Socket %u now has %u / %u child%s\n", - pxSocket->usLocalPort, - pxSocket->u.xTCP.usChildCount, - pxSocket->u.xTCP.usBacklog, - pxSocket->u.xTCP.usChildCount == 1u ? "" : "ren" ) ); - - /* Now bind the child socket to the same port as the listening socket. */ - if( vSocketBind ( pxNewSocket, &xAddress, sizeof( xAddress ), pdTRUE ) != 0 ) - { - FreeRTOS_debug_printf( ( "TCP: Listen: new socket bind error\n" ) ); - vSocketClose( pxNewSocket ); - return pdFALSE; - } - - return pdTRUE; -} -/*-----------------------------------------------------------*/ - -#if( ( ipconfigHAS_DEBUG_PRINTF != 0 ) || ( ipconfigHAS_PRINTF != 0 ) ) - - const char *FreeRTOS_GetTCPStateName( UBaseType_t ulState ) - { - if( ulState >= ( UBaseType_t ) ARRAY_SIZE( pcStateNames ) ) - { - ulState = ( UBaseType_t ) ARRAY_SIZE( pcStateNames ) - 1u; - } - return pcStateNames[ ulState ]; - } - -#endif /* ( ( ipconfigHAS_DEBUG_PRINTF != 0 ) || ( ipconfigHAS_PRINTF != 0 ) ) */ -/*-----------------------------------------------------------*/ - -/* - * In the API accept(), the user asks is there is a new client? As API's can - * not walk through the xBoundTCPSocketsList the IP-task will do this. - */ -BaseType_t xTCPCheckNewClient( FreeRTOS_Socket_t *pxSocket ) -{ -TickType_t xLocalPort = FreeRTOS_htons( pxSocket->usLocalPort ); -ListItem_t *pxIterator; -FreeRTOS_Socket_t *pxFound; -BaseType_t xResult = pdFALSE; - - /* Here xBoundTCPSocketsList can be accessed safely IP-task is the only one - who has access. */ - for( pxIterator = ( ListItem_t * ) listGET_HEAD_ENTRY( &xBoundTCPSocketsList ); - pxIterator != ( ListItem_t * ) listGET_END_MARKER( &xBoundTCPSocketsList ); - pxIterator = ( ListItem_t * ) listGET_NEXT( pxIterator ) ) - { - if( listGET_LIST_ITEM_VALUE( pxIterator ) == xLocalPort ) - { - pxFound = ( FreeRTOS_Socket_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); - if( ( pxFound->ucProtocol == FREERTOS_IPPROTO_TCP ) && ( pxFound->u.xTCP.bits.bPassAccept != pdFALSE_UNSIGNED ) ) - { - pxSocket->u.xTCP.pxPeerSocket = pxFound; - FreeRTOS_debug_printf( ( "xTCPCheckNewClient[0]: client on port %u\n", pxSocket->usLocalPort ) ); - xResult = pdTRUE; - break; - } - } - } - return xResult; -} -/*-----------------------------------------------------------*/ - -#endif /* ipconfigUSE_TCP == 1 */ - -/* Provide access to private members for testing. */ -#ifdef AMAZON_FREERTOS_ENABLE_UNIT_TESTS - #include "aws_freertos_tcp_test_access_tcp_define.h" -#endif - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_TCP_WIN.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_TCP_WIN.c deleted file mode 100755 index 953d9f2..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_TCP_WIN.c +++ /dev/null @@ -1,1981 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -/* - * FreeRTOS_TCP_WIN.c - * Module which handles the TCP windowing schemes for FreeRTOS+TCP. Many - * functions have two versions - one for FreeRTOS+TCP (full) and one for - * FreeRTOS+TCP (lite). - * - * In this module all ports and IP addresses and sequence numbers are - * being stored in host byte-order. - */ - -/* Standard includes. */ -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "NetworkBufferManagement.h" -#include "FreeRTOS_TCP_WIN.h" - -/* Constants used for Smoothed Round Trip Time (SRTT). */ -#define winSRTT_INCREMENT_NEW 2 -#define winSRTT_INCREMENT_CURRENT 6 -#define winSRTT_DECREMENT_NEW 1 -#define winSRTT_DECREMENT_CURRENT 7 -#define winSRTT_CAP_mS 50 - -#if( ipconfigUSE_TCP_WIN == 1 ) - - #define xTCPWindowRxNew( pxWindow, ulSequenceNumber, lCount ) xTCPWindowNew( pxWindow, ulSequenceNumber, lCount, pdTRUE ) - - #define xTCPWindowTxNew( pxWindow, ulSequenceNumber, lCount ) xTCPWindowNew( pxWindow, ulSequenceNumber, lCount, pdFALSE ) - - /* The code to send a single Selective ACK (SACK): - * NOP (0x01), NOP (0x01), SACK (0x05), LEN (0x0a), - * followed by a lower and a higher sequence number, - * where LEN is 2 + 2*4 = 10 bytes. */ - #if( ipconfigBYTE_ORDER == pdFREERTOS_BIG_ENDIAN ) - #define OPTION_CODE_SINGLE_SACK ( 0x0101050aUL ) - #else - #define OPTION_CODE_SINGLE_SACK ( 0x0a050101UL ) - #endif - - /* Normal retransmission: - * A packet will be retransmitted after a Retransmit Time-Out (RTO). - * Fast retransmission: - * When 3 packets with a higher sequence number have been acknowledged - * by the peer, it is very unlikely a current packet will ever arrive. - * It will be retransmitted far before the RTO. - */ - #define DUPLICATE_ACKS_BEFORE_FAST_RETRANSMIT ( 3u ) - - /* If there have been several retransmissions (4), decrease the - * size of the transmission window to at most 2 times MSS. - */ - #define MAX_TRANSMIT_COUNT_USING_LARGE_WINDOW ( 4u ) - -#endif /* configUSE_TCP_WIN */ -/*-----------------------------------------------------------*/ - -extern void vListInsertGeneric( List_t * const pxList, ListItem_t * const pxNewListItem, MiniListItem_t * const pxWhere ); - -/* - * All TCP sockets share a pool of segment descriptors (TCPSegment_t) - * Available descriptors are stored in the 'xSegmentList' - * When a socket owns a descriptor, it will either be stored in - * 'xTxSegments' or 'xRxSegments' - * As soon as a package has been confirmed, the descriptor will be returned - * to the segment pool - */ -#if( ipconfigUSE_TCP_WIN == 1 ) - static BaseType_t prvCreateSectors( void ); -#endif /* ipconfigUSE_TCP_WIN == 1 */ - -/* - * Find a segment with a given sequence number in the list of received - * segments: 'pxWindow->xRxSegments'. - */ -#if( ipconfigUSE_TCP_WIN == 1 ) - static TCPSegment_t *xTCPWindowRxFind( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber ); -#endif /* ipconfigUSE_TCP_WIN == 1 */ - -/* - * Allocate a new segment - * The socket will borrow all segments from a common pool: 'xSegmentList', - * which is a list of 'TCPSegment_t' - */ -#if( ipconfigUSE_TCP_WIN == 1 ) - static TCPSegment_t *xTCPWindowNew( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber, int32_t lCount, BaseType_t xIsForRx ); -#endif /* ipconfigUSE_TCP_WIN == 1 */ - -/* When the peer has a close request (FIN flag), the driver will check if - * there are missing packets in the Rx-queue - * It will accept the closure of the connection if both conditions are true: - * - the Rx-queue is empty - * - we've ACK'd the highest Rx sequence number seen - */ -#if( ipconfigUSE_TCP_WIN == 1 ) - BaseType_t xTCPWindowRxEmpty( TCPWindow_t *pxWindow ); -#endif /* ipconfigUSE_TCP_WIN == 1 */ - -/* - * Detaches and returns the head of a queue - */ -#if( ipconfigUSE_TCP_WIN == 1 ) - static TCPSegment_t *xTCPWindowGetHead( List_t *pxList ); -#endif /* ipconfigUSE_TCP_WIN == 1 */ - -/* - * Returns the head of a queue but it won't be detached - */ -#if( ipconfigUSE_TCP_WIN == 1 ) - static TCPSegment_t *xTCPWindowPeekHead( List_t *pxList ); -#endif /* ipconfigUSE_TCP_WIN == 1 */ - -/* - * Free entry pxSegment because it's not used anymore - * The ownership will be passed back to the segment pool - */ -#if( ipconfigUSE_TCP_WIN == 1 ) - static void vTCPWindowFree( TCPSegment_t *pxSegment ); -#endif /* ipconfigUSE_TCP_WIN == 1 */ - -/* - * A segment has been received with sequence number 'ulSequenceNumber', where - * 'ulCurrentSequenceNumber == ulSequenceNumber', which means that exactly this - * segment was expected. xTCPWindowRxConfirm() will check if there is already - * another segment with a sequence number between (ulSequenceNumber) and - * (ulSequenceNumber+xLength). Normally none will be found, because the next Rx - * segment should have a sequence number equal to '(ulSequenceNumber+xLength)'. - */ -#if( ipconfigUSE_TCP_WIN == 1 ) - static TCPSegment_t *xTCPWindowRxConfirm( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber, uint32_t ulLength ); -#endif /* ipconfigUSE_TCP_WIN == 1 */ - -/* - * FreeRTOS+TCP stores data in circular buffers. Calculate the next position to - * store. - */ -#if( ipconfigUSE_TCP_WIN == 1 ) - static int32_t lTCPIncrementTxPosition( int32_t lPosition, int32_t lMax, int32_t lCount ); -#endif /* ipconfigUSE_TCP_WIN == 1 */ - -/* - * This function will look if there is new transmission data. It will return - * true if there is data to be sent. - */ -#if( ipconfigUSE_TCP_WIN == 1 ) - static BaseType_t prvTCPWindowTxHasSpace( TCPWindow_t *pxWindow, uint32_t ulWindowSize ); -#endif /* ipconfigUSE_TCP_WIN == 1 */ - -/* - * An acknowledge was received. See if some outstanding data may be removed - * from the transmission queue(s). - */ -#if( ipconfigUSE_TCP_WIN == 1 ) - static uint32_t prvTCPWindowTxCheckAck( TCPWindow_t *pxWindow, uint32_t ulFirst, uint32_t ulLast ); -#endif /* ipconfigUSE_TCP_WIN == 1 */ - -/* - * A higher Tx block has been acknowledged. Now iterate through the xWaitQueue - * to find a possible condition for a FAST retransmission. - */ -#if( ipconfigUSE_TCP_WIN == 1 ) - static uint32_t prvTCPWindowFastRetransmit( TCPWindow_t *pxWindow, uint32_t ulFirst ); -#endif /* ipconfigUSE_TCP_WIN == 1 */ - -/*-----------------------------------------------------------*/ - -/* TCP segement pool. */ -#if( ipconfigUSE_TCP_WIN == 1 ) - static TCPSegment_t *xTCPSegments = NULL; -#endif /* ipconfigUSE_TCP_WIN == 1 */ - -/* List of free TCP segments. */ -#if( ipconfigUSE_TCP_WIN == 1 ) - static List_t xSegmentList; -#endif - -/* Logging verbosity level. */ -BaseType_t xTCPWindowLoggingLevel = 0; - -#if( ipconfigUSE_TCP_WIN == 1 ) - /* Some 32-bit arithmetic: comparing sequence numbers */ - static portINLINE BaseType_t xSequenceLessThanOrEqual( uint32_t a, uint32_t b ); - static portINLINE BaseType_t xSequenceLessThanOrEqual( uint32_t a, uint32_t b ) - { - /* Test if a <= b - Return true if the unsigned subtraction of (b-a) doesn't generate an - arithmetic overflow. */ - return ( ( b - a ) & 0x80000000UL ) == 0UL; - } -#endif /* ipconfigUSE_TCP_WIN */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - static portINLINE BaseType_t xSequenceLessThan( uint32_t a, uint32_t b ); - static portINLINE BaseType_t xSequenceLessThan( uint32_t a, uint32_t b ) - { - /* Test if a < b */ - return ( ( b - a - 1UL ) & 0x80000000UL ) == 0UL; - } -#endif /* ipconfigUSE_TCP_WIN */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - static portINLINE BaseType_t xSequenceGreaterThan( uint32_t a, uint32_t b ); - static portINLINE BaseType_t xSequenceGreaterThan( uint32_t a, uint32_t b ) - { - /* Test if a > b */ - return ( ( a - b - 1UL ) & 0x80000000UL ) == 0UL; - } -#endif /* ipconfigUSE_TCP_WIN */ - -/*-----------------------------------------------------------*/ -static portINLINE BaseType_t xSequenceGreaterThanOrEqual( uint32_t a, uint32_t b ); -static portINLINE BaseType_t xSequenceGreaterThanOrEqual( uint32_t a, uint32_t b ) -{ - /* Test if a >= b */ - return ( ( a - b ) & 0x80000000UL ) == 0UL; -} -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - static portINLINE void vListInsertFifo( List_t * const pxList, ListItem_t * const pxNewListItem ); - static portINLINE void vListInsertFifo( List_t * const pxList, ListItem_t * const pxNewListItem ) - { - vListInsertGeneric( pxList, pxNewListItem, &pxList->xListEnd ); - } -#endif -/*-----------------------------------------------------------*/ - -static portINLINE void vTCPTimerSet( TCPTimer_t *pxTimer ); -static portINLINE void vTCPTimerSet( TCPTimer_t *pxTimer ) -{ - pxTimer->ulBorn = xTaskGetTickCount ( ); -} -/*-----------------------------------------------------------*/ - -static portINLINE uint32_t ulTimerGetAge( TCPTimer_t *pxTimer ); -static portINLINE uint32_t ulTimerGetAge( TCPTimer_t *pxTimer ) -{ - return ( ( xTaskGetTickCount() - pxTimer->ulBorn ) * portTICK_PERIOD_MS ); -} -/*-----------------------------------------------------------*/ - -/* _HT_ GCC (using the settings that I'm using) checks for every public function if it is -preceded by a prototype. Later this prototype will be located in list.h? */ - -extern void vListInsertGeneric( List_t * const pxList, ListItem_t * const pxNewListItem, MiniListItem_t * const pxWhere ); - -void vListInsertGeneric( List_t * const pxList, ListItem_t * const pxNewListItem, MiniListItem_t * const pxWhere ) -{ - /* Insert a new list item into pxList, it does not sort the list, - but it puts the item just before xListEnd, so it will be the last item - returned by listGET_HEAD_ENTRY() */ - pxNewListItem->pxNext = (struct xLIST_ITEM * configLIST_VOLATILE)pxWhere; - pxNewListItem->pxPrevious = pxWhere->pxPrevious; - pxWhere->pxPrevious->pxNext = pxNewListItem; - pxWhere->pxPrevious = pxNewListItem; - - /* Remember which list the item is in. */ - pxNewListItem->pvContainer = ( void * ) pxList; /* If this line fails to build then ensure configENABLE_BACKWARD_COMPATIBILITY is set to 1 in FreeRTOSConfig.h. */ - - ( pxList->uxNumberOfItems )++; -} -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - static BaseType_t prvCreateSectors( void ) - { - BaseType_t xIndex, xReturn; - - /* Allocate space for 'xTCPSegments' and store them in 'xSegmentList'. */ - - vListInitialise( &xSegmentList ); - xTCPSegments = ( TCPSegment_t * ) pvPortMallocLarge( ipconfigTCP_WIN_SEG_COUNT * sizeof( xTCPSegments[ 0 ] ) ); - - if( xTCPSegments == NULL ) - { - FreeRTOS_debug_printf( ( "prvCreateSectors: malloc %lu failed\n", - ipconfigTCP_WIN_SEG_COUNT * sizeof( xTCPSegments[ 0 ] ) ) ); - - xReturn = pdFAIL; - } - else - { - /* Clear the allocated space. */ - memset( xTCPSegments, '\0', ipconfigTCP_WIN_SEG_COUNT * sizeof( xTCPSegments[ 0 ] ) ); - - for( xIndex = 0; xIndex < ipconfigTCP_WIN_SEG_COUNT; xIndex++ ) - { - /* Could call vListInitialiseItem here but all data has been - nulled already. Set the owner to a segment descriptor. */ - listSET_LIST_ITEM_OWNER( &( xTCPSegments[ xIndex ].xListItem ), ( void* ) &( xTCPSegments[ xIndex ] ) ); - listSET_LIST_ITEM_OWNER( &( xTCPSegments[ xIndex ].xQueueItem ), ( void* ) &( xTCPSegments[ xIndex ] ) ); - - /* And add it to the pool of available segments */ - vListInsertFifo( &xSegmentList, &( xTCPSegments[xIndex].xListItem ) ); - } - - xReturn = pdPASS; - } - - return xReturn; - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - static TCPSegment_t *xTCPWindowRxFind( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber ) - { - const ListItem_t *pxIterator; - const MiniListItem_t* pxEnd; - TCPSegment_t *pxSegment, *pxReturn = NULL; - - /* Find a segment with a given sequence number in the list of received - segments. */ - - pxEnd = ( const MiniListItem_t* )listGET_END_MARKER( &pxWindow->xRxSegments ); - - for( pxIterator = ( const ListItem_t * ) listGET_NEXT( pxEnd ); - pxIterator != ( const ListItem_t * ) pxEnd; - pxIterator = ( const ListItem_t * ) listGET_NEXT( pxIterator ) ) - { - pxSegment = ( TCPSegment_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); - - if( pxSegment->ulSequenceNumber == ulSequenceNumber ) - { - pxReturn = pxSegment; - break; - } - } - - return pxReturn; - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - static TCPSegment_t *xTCPWindowNew( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber, int32_t lCount, BaseType_t xIsForRx ) - { - TCPSegment_t *pxSegment; - ListItem_t * pxItem; - - /* Allocate a new segment. The socket will borrow all segments from a - common pool: 'xSegmentList', which is a list of 'TCPSegment_t' */ - if( listLIST_IS_EMPTY( &xSegmentList ) != pdFALSE ) - { - /* If the TCP-stack runs out of segments, you might consider - increasing 'ipconfigTCP_WIN_SEG_COUNT'. */ - FreeRTOS_debug_printf( ( "xTCPWindow%cxNew: Error: all segments occupied\n", xIsForRx ? 'R' : 'T' ) ); - pxSegment = NULL; - } - else - { - /* Pop the item at the head of the list. Semaphore protection is - not required as only the IP task will call these functions. */ - pxItem = ( ListItem_t * ) listGET_HEAD_ENTRY( &xSegmentList ); - pxSegment = ( TCPSegment_t * ) listGET_LIST_ITEM_OWNER( pxItem ); - - configASSERT( pxItem != NULL ); - configASSERT( pxSegment != NULL ); - - /* Remove the item from xSegmentList. */ - uxListRemove( pxItem ); - - /* Add it to either the connections' Rx or Tx queue. */ - vListInsertFifo( xIsForRx ? &pxWindow->xRxSegments : &pxWindow->xTxSegments, pxItem ); - - /* And set the segment's timer to zero */ - vTCPTimerSet( &pxSegment->xTransmitTimer ); - - pxSegment->u.ulFlags = 0; - pxSegment->u.bits.bIsForRx = ( xIsForRx != 0 ); - pxSegment->lMaxLength = lCount; - pxSegment->lDataLength = lCount; - pxSegment->ulSequenceNumber = ulSequenceNumber; - #if( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - static UBaseType_t xLowestLength = ipconfigTCP_WIN_SEG_COUNT; - UBaseType_t xLength = listCURRENT_LIST_LENGTH( &xSegmentList ); - - if( xLowestLength > xLength ) - { - xLowestLength = xLength; - } - } - #endif /* ipconfigHAS_DEBUG_PRINTF */ - } - - return pxSegment; - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - BaseType_t xTCPWindowRxEmpty( TCPWindow_t *pxWindow ) - { - BaseType_t xReturn; - - /* When the peer has a close request (FIN flag), the driver will check - if there are missing packets in the Rx-queue. It will accept the - closure of the connection if both conditions are true: - - the Rx-queue is empty - - the highest Rx sequence number has been ACK'ed */ - if( listLIST_IS_EMPTY( ( &pxWindow->xRxSegments ) ) == pdFALSE ) - { - /* Rx data has been stored while earlier packets were missing. */ - xReturn = pdFALSE; - } - else if( xSequenceGreaterThanOrEqual( pxWindow->rx.ulCurrentSequenceNumber, pxWindow->rx.ulHighestSequenceNumber ) != pdFALSE ) - { - /* No Rx packets are being stored and the highest sequence number - that has been received has been ACKed. */ - xReturn = pdTRUE; - } - else - { - FreeRTOS_debug_printf( ( "xTCPWindowRxEmpty: cur %lu highest %lu (empty)\n", - ( pxWindow->rx.ulCurrentSequenceNumber - pxWindow->rx.ulFirstSequenceNumber ), - ( pxWindow->rx.ulHighestSequenceNumber - pxWindow->rx.ulFirstSequenceNumber ) ) ); - xReturn = pdFALSE; - } - - return xReturn; - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - static TCPSegment_t *xTCPWindowGetHead( List_t *pxList ) - { - TCPSegment_t *pxSegment; - ListItem_t * pxItem; - - /* Detaches and returns the head of a queue. */ - if( listLIST_IS_EMPTY( pxList ) != pdFALSE ) - { - pxSegment = NULL; - } - else - { - pxItem = ( ListItem_t * ) listGET_HEAD_ENTRY( pxList ); - pxSegment = ( TCPSegment_t * ) listGET_LIST_ITEM_OWNER( pxItem ); - - uxListRemove( pxItem ); - } - - return pxSegment; - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - static TCPSegment_t *xTCPWindowPeekHead( List_t *pxList ) - { - ListItem_t *pxItem; - TCPSegment_t *pxReturn; - - /* Returns the head of a queue but it won't be detached. */ - if( listLIST_IS_EMPTY( pxList ) != pdFALSE ) - { - pxReturn = NULL; - } - else - { - pxItem = ( ListItem_t * ) listGET_HEAD_ENTRY( pxList ); - pxReturn = ( TCPSegment_t * ) listGET_LIST_ITEM_OWNER( pxItem ); - } - - return pxReturn; - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - static void vTCPWindowFree( TCPSegment_t *pxSegment ) - { - /* Free entry pxSegment because it's not used any more. The ownership - will be passed back to the segment pool. - - Unlink it from one of the queues, if any. */ - if( listLIST_ITEM_CONTAINER( &( pxSegment->xQueueItem ) ) != NULL ) - { - uxListRemove( &( pxSegment->xQueueItem ) ); - } - - pxSegment->ulSequenceNumber = 0u; - pxSegment->lDataLength = 0l; - pxSegment->u.ulFlags = 0u; - - /* Take it out of xRxSegments/xTxSegments */ - if( listLIST_ITEM_CONTAINER( &( pxSegment->xListItem ) ) != NULL ) - { - uxListRemove( &( pxSegment->xListItem ) ); - } - - /* Return it to xSegmentList */ - vListInsertFifo( &xSegmentList, &( pxSegment->xListItem ) ); - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - void vTCPWindowDestroy( TCPWindow_t *pxWindow ) - { - List_t * pxSegments; - BaseType_t xRound; - TCPSegment_t *pxSegment; - - /* Destroy a window. A TCP window doesn't serve any more. Return all - owned segments to the pool. In order to save code, it will make 2 rounds, - one to remove the segments from xRxSegments, and a second round to clear - xTxSegments*/ - for( xRound = 0; xRound < 2; xRound++ ) - { - if( xRound != 0 ) - { - pxSegments = &( pxWindow->xRxSegments ); - } - else - { - pxSegments = &( pxWindow->xTxSegments ); - } - - if( listLIST_IS_INITIALISED( pxSegments ) != pdFALSE ) - { - while( listCURRENT_LIST_LENGTH( pxSegments ) > 0U ) - { - pxSegment = ( TCPSegment_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxSegments ); - vTCPWindowFree( pxSegment ); - } - } - } - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -void vTCPWindowCreate( TCPWindow_t *pxWindow, uint32_t ulRxWindowLength, - uint32_t ulTxWindowLength, uint32_t ulAckNumber, uint32_t ulSequenceNumber, uint32_t ulMSS ) -{ - /* Create and initialize a window. */ - - #if( ipconfigUSE_TCP_WIN == 1 ) - { - if( xTCPSegments == NULL ) - { - prvCreateSectors(); - } - - vListInitialise( &pxWindow->xTxSegments ); - vListInitialise( &pxWindow->xRxSegments ); - - vListInitialise( &pxWindow->xPriorityQueue ); /* Priority queue: segments which must be sent immediately */ - vListInitialise( &pxWindow->xTxQueue ); /* Transmit queue: segments queued for transmission */ - vListInitialise( &pxWindow->xWaitQueue ); /* Waiting queue: outstanding segments */ - } - #endif /* ipconfigUSE_TCP_WIN == 1 */ - - if( xTCPWindowLoggingLevel != 0 ) - { - FreeRTOS_debug_printf( ( "vTCPWindowCreate: for WinLen = Rx/Tx: %lu/%lu\n", - ulRxWindowLength, ulTxWindowLength ) ); - } - - pxWindow->xSize.ulRxWindowLength = ulRxWindowLength; - pxWindow->xSize.ulTxWindowLength = ulTxWindowLength; - - vTCPWindowInit( pxWindow, ulAckNumber, ulSequenceNumber, ulMSS ); -} -/*-----------------------------------------------------------*/ - -void vTCPWindowInit( TCPWindow_t *pxWindow, uint32_t ulAckNumber, uint32_t ulSequenceNumber, uint32_t ulMSS ) -{ -const int32_t l500ms = 500; - - pxWindow->u.ulFlags = 0ul; - pxWindow->u.bits.bHasInit = pdTRUE_UNSIGNED; - - if( ulMSS != 0ul ) - { - if( pxWindow->usMSSInit != 0u ) - { - pxWindow->usMSSInit = ( uint16_t ) ulMSS; - } - - if( ( ulMSS < ( uint32_t ) pxWindow->usMSS ) || ( pxWindow->usMSS == 0u ) ) - { - pxWindow->xSize.ulRxWindowLength = ( pxWindow->xSize.ulRxWindowLength / ulMSS ) * ulMSS; - pxWindow->usMSS = ( uint16_t ) ulMSS; - } - } - - #if( ipconfigUSE_TCP_WIN == 0 ) - { - pxWindow->xTxSegment.lMaxLength = ( int32_t ) pxWindow->usMSS; - } - #endif /* ipconfigUSE_TCP_WIN == 1 */ - - /*Start with a timeout of 2 * 500 ms (1 sec). */ - pxWindow->lSRTT = l500ms; - - /* Just for logging, to print relative sequence numbers. */ - pxWindow->rx.ulFirstSequenceNumber = ulAckNumber; - - /* The segment asked for in the next transmission. */ - pxWindow->rx.ulCurrentSequenceNumber = ulAckNumber; - - /* The right-hand side of the receive window. */ - pxWindow->rx.ulHighestSequenceNumber = ulAckNumber; - - pxWindow->tx.ulFirstSequenceNumber = ulSequenceNumber; - - /* The segment asked for in next transmission. */ - pxWindow->tx.ulCurrentSequenceNumber = ulSequenceNumber; - - /* The sequence number given to the next outgoing byte to be added is - maintained by lTCPWindowTxAdd(). */ - pxWindow->ulNextTxSequenceNumber = ulSequenceNumber; - - /* The right-hand side of the transmit window. */ - pxWindow->tx.ulHighestSequenceNumber = ulSequenceNumber; - pxWindow->ulOurSequenceNumber = ulSequenceNumber; -} -/*-----------------------------------------------------------*/ - -/*============================================================================= - * - * ###### # # - * # # # # - * # # # # - * # # #### - * ###### ## - * # ## #### - * # # # # - * # # # # - * ### ## # # - * Rx functions - * - *=============================================================================*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - static TCPSegment_t *xTCPWindowRxConfirm( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber, uint32_t ulLength ) - { - TCPSegment_t *pxBest = NULL; - const ListItem_t *pxIterator; - uint32_t ulNextSequenceNumber = ulSequenceNumber + ulLength; - const MiniListItem_t* pxEnd = ( const MiniListItem_t* ) listGET_END_MARKER( &pxWindow->xRxSegments ); - TCPSegment_t *pxSegment; - - /* A segment has been received with sequence number 'ulSequenceNumber', - where 'ulCurrentSequenceNumber == ulSequenceNumber', which means that - exactly this segment was expected. xTCPWindowRxConfirm() will check if - there is already another segment with a sequence number between (ulSequenceNumber) - and (ulSequenceNumber+ulLength). Normally none will be found, because - the next RX segment should have a sequence number equal to - '(ulSequenceNumber+ulLength)'. */ - - /* Iterate through all RX segments that are stored: */ - for( pxIterator = ( const ListItem_t * ) listGET_NEXT( pxEnd ); - pxIterator != ( const ListItem_t * ) pxEnd; - pxIterator = ( const ListItem_t * ) listGET_NEXT( pxIterator ) ) - { - pxSegment = ( TCPSegment_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); - /* And see if there is a segment for which: - 'ulSequenceNumber' <= 'pxSegment->ulSequenceNumber' < 'ulNextSequenceNumber' - If there are more matching segments, the one with the lowest sequence number - shall be taken */ - if( ( xSequenceGreaterThanOrEqual( pxSegment->ulSequenceNumber, ulSequenceNumber ) != 0 ) && - ( xSequenceLessThan( pxSegment->ulSequenceNumber, ulNextSequenceNumber ) != 0 ) ) - { - if( ( pxBest == NULL ) || ( xSequenceLessThan( pxSegment->ulSequenceNumber, pxBest->ulSequenceNumber ) != 0 ) ) - { - pxBest = pxSegment; - } - } - } - - if( ( pxBest != NULL ) && - ( ( pxBest->ulSequenceNumber != ulSequenceNumber ) || ( pxBest->lDataLength != ( int32_t ) ulLength ) ) ) - { - FreeRTOS_flush_logging(); - FreeRTOS_debug_printf( ( "xTCPWindowRxConfirm[%u]: search %lu (+%ld=%lu) found %lu (+%ld=%lu)\n", - pxWindow->usPeerPortNumber, - ulSequenceNumber - pxWindow->rx.ulFirstSequenceNumber, - ulLength, - ulSequenceNumber + ulLength - pxWindow->rx.ulFirstSequenceNumber, - pxBest->ulSequenceNumber - pxWindow->rx.ulFirstSequenceNumber, - pxBest->lDataLength, - pxBest->ulSequenceNumber + ( ( uint32_t ) pxBest->lDataLength ) - pxWindow->rx.ulFirstSequenceNumber ) ); - } - - return pxBest; - } - -#endif /* ipconfgiUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - int32_t lTCPWindowRxCheck( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber, uint32_t ulLength, uint32_t ulSpace ) - { - uint32_t ulCurrentSequenceNumber, ulLast, ulSavedSequenceNumber; - int32_t lReturn, lDistance; - TCPSegment_t *pxFound; - - /* If lTCPWindowRxCheck( ) returns == 0, the packet will be passed - directly to user (segment is expected). If it returns a positive - number, an earlier packet is missing, but this packet may be stored. - If negative, the packet has already been stored, or it is out-of-order, - or there is not enough space. - - As a side-effect, pxWindow->ulUserDataLength will get set to non-zero, - if more Rx data may be passed to the user after this packet. */ - - ulCurrentSequenceNumber = pxWindow->rx.ulCurrentSequenceNumber; - - /* For Selective Ack (SACK), used when out-of-sequence data come in. */ - pxWindow->ucOptionLength = 0u; - - /* Non-zero if TCP-windows contains data which must be popped. */ - pxWindow->ulUserDataLength = 0ul; - - if( ulCurrentSequenceNumber == ulSequenceNumber ) - { - /* This is the packet with the lowest sequence number we're waiting - for. It can be passed directly to the rx stream. */ - if( ulLength > ulSpace ) - { - FreeRTOS_debug_printf( ( "lTCPWindowRxCheck: Refuse %lu bytes, due to lack of space (%lu)\n", ulLength, ulSpace ) ); - lReturn = -1; - } - else - { - ulCurrentSequenceNumber += ulLength; - - if( listCURRENT_LIST_LENGTH( &( pxWindow->xRxSegments ) ) != 0 ) - { - ulSavedSequenceNumber = ulCurrentSequenceNumber; - - /* Clean up all sequence received between ulSequenceNumber and ulSequenceNumber + ulLength since they are duplicated. - If the server is forced to retransmit packets several time in a row it might send a batch of concatenated packet for speed. - So we cannot rely on the packets between ulSequenceNumber and ulSequenceNumber + ulLength to be sequential and it is better to just - clean them out. */ - do - { - pxFound = xTCPWindowRxConfirm( pxWindow, ulSequenceNumber, ulLength ); - - if ( pxFound != NULL ) - { - /* Remove it because it will be passed to user directly. */ - vTCPWindowFree( pxFound ); - } - } while ( pxFound ); - - /* Check for following segments that are already in the - queue and increment ulCurrentSequenceNumber. */ - while( ( pxFound = xTCPWindowRxFind( pxWindow, ulCurrentSequenceNumber ) ) != NULL ) - { - ulCurrentSequenceNumber += ( uint32_t ) pxFound->lDataLength; - - /* As all packet below this one have been passed to the - user it can be discarded. */ - vTCPWindowFree( pxFound ); - } - - if( ulSavedSequenceNumber != ulCurrentSequenceNumber ) - { - /* After the current data-package, there is more data - to be popped. */ - pxWindow->ulUserDataLength = ulCurrentSequenceNumber - ulSavedSequenceNumber; - - if( xTCPWindowLoggingLevel >= 1 ) - { - FreeRTOS_debug_printf( ( "lTCPWindowRxCheck[%d,%d]: retran %lu (Found %lu bytes at %lu cnt %ld)\n", - pxWindow->usPeerPortNumber, pxWindow->usOurPortNumber, - ulSequenceNumber - pxWindow->rx.ulFirstSequenceNumber, - pxWindow->ulUserDataLength, - ulSavedSequenceNumber - pxWindow->rx.ulFirstSequenceNumber, - listCURRENT_LIST_LENGTH( &pxWindow->xRxSegments ) ) ); - } - } - } - - pxWindow->rx.ulCurrentSequenceNumber = ulCurrentSequenceNumber; - - /* Packet was expected, may be passed directly to the socket - buffer or application. Store the packet at offset 0. */ - lReturn = 0; - } - } - else if( ulCurrentSequenceNumber == ( ulSequenceNumber + 1UL ) ) - { - /* Looks like a TCP keep-alive message. Do not accept/store Rx data - ulUserDataLength = 0. Not packet out-of-sync. Just reply to it. */ - lReturn = -1; - } - else - { - /* The packet is not the one expected. See if it falls within the Rx - window so it can be stored. */ - - /* An "out-of-sequence" segment was received, must have missed one. - Prepare a SACK (Selective ACK). */ - ulLast = ulSequenceNumber + ulLength; - lDistance = ( int32_t ) ( ulLast - ulCurrentSequenceNumber ); - - if( lDistance <= 0 ) - { - /* An earlier has been received, must be a retransmission of a - packet that has been accepted already. No need to send out a - Selective ACK (SACK). */ - lReturn = -1; - } - else if( lDistance > ( int32_t ) ulSpace ) - { - /* The new segment is ahead of rx.ulCurrentSequenceNumber. The - sequence number of this packet is too far ahead, ignore it. */ - FreeRTOS_debug_printf( ( "lTCPWindowRxCheck: Refuse %lu+%lu bytes, due to lack of space (%lu)\n", lDistance, ulLength, ulSpace ) ); - lReturn = -1; - } - else - { - /* See if there is more data in a contiguous block to make the - SACK describe a longer range of data. */ - - /* TODO: SACK's may also be delayed for a short period - * This is useful because subsequent packets will be SACK'd with - * single one message - */ - while( ( pxFound = xTCPWindowRxFind( pxWindow, ulLast ) ) != NULL ) - { - ulLast += ( uint32_t ) pxFound->lDataLength; - } - - if( xTCPWindowLoggingLevel >= 1 ) - { - FreeRTOS_debug_printf( ( "lTCPWindowRxCheck[%d,%d]: seqnr %lu exp %lu (dist %ld) SACK to %lu\n", - pxWindow->usPeerPortNumber, pxWindow->usOurPortNumber, - ulSequenceNumber - pxWindow->rx.ulFirstSequenceNumber, - ulCurrentSequenceNumber - pxWindow->rx.ulFirstSequenceNumber, - ( BaseType_t ) ( ulSequenceNumber - ulCurrentSequenceNumber ), /* want this signed */ - ulLast - pxWindow->rx.ulFirstSequenceNumber ) ); - } - - /* Now prepare the SACK message. - Code OPTION_CODE_SINGLE_SACK already in network byte order. */ - pxWindow->ulOptionsData[0] = OPTION_CODE_SINGLE_SACK; - - /* First sequence number that we received. */ - pxWindow->ulOptionsData[1] = FreeRTOS_htonl( ulSequenceNumber ); - - /* Last + 1 */ - pxWindow->ulOptionsData[2] = FreeRTOS_htonl( ulLast ); - - /* Which make 12 (3*4) option bytes. */ - pxWindow->ucOptionLength = 3 * sizeof( pxWindow->ulOptionsData[ 0 ] ); - - pxFound = xTCPWindowRxFind( pxWindow, ulSequenceNumber ); - - if( pxFound != NULL ) - { - /* This out-of-sequence packet has been received for a - second time. It is already stored but do send a SACK - again. */ - lReturn = -1; - } - else - { - pxFound = xTCPWindowRxNew( pxWindow, ulSequenceNumber, ( int32_t ) ulLength ); - - if( pxFound == NULL ) - { - /* Can not send a SACK, because the segment cannot be - stored. */ - pxWindow->ucOptionLength = 0u; - - /* Needs to be stored but there is no segment - available. */ - lReturn = -1; - } - else - { - if( xTCPWindowLoggingLevel != 0 ) - { - FreeRTOS_debug_printf( ( "lTCPWindowRxCheck[%u,%u]: seqnr %lu (cnt %lu)\n", - pxWindow->usPeerPortNumber, pxWindow->usOurPortNumber, ulSequenceNumber - pxWindow->rx.ulFirstSequenceNumber, - listCURRENT_LIST_LENGTH( &pxWindow->xRxSegments ) ) ); - FreeRTOS_flush_logging( ); - } - - /* Return a positive value. The packet may be accepted - and stored but an earlier packet is still missing. */ - lReturn = ( int32_t ) ( ulSequenceNumber - ulCurrentSequenceNumber ); - } - } - } - } - - return lReturn; - } - -#endif /* ipconfgiUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -/*============================================================================= - * - * ######### # # - * # # # # # - * # # # - * # #### - * # ## - * # #### - * # # # - * # # # - * ##### # # - * - * Tx functions - * - *=============================================================================*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - static int32_t lTCPIncrementTxPosition( int32_t lPosition, int32_t lMax, int32_t lCount ) - { - /* +TCP stores data in circular buffers. Calculate the next position to - store. */ - lPosition += lCount; - if( lPosition >= lMax ) - { - lPosition -= lMax; - } - - return lPosition; - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - int32_t lTCPWindowTxAdd( TCPWindow_t *pxWindow, uint32_t ulLength, int32_t lPosition, int32_t lMax ) - { - int32_t lBytesLeft = ( int32_t ) ulLength, lToWrite; - int32_t lDone = 0; - TCPSegment_t *pxSegment = pxWindow->pxHeadSegment; - - /* Puts a message in the Tx-window (after buffer size has been - verified). */ - if( pxSegment != NULL ) - { - if( pxSegment->lDataLength < pxSegment->lMaxLength ) - { - if( ( pxSegment->u.bits.bOutstanding == pdFALSE_UNSIGNED ) && ( pxSegment->lDataLength != 0 ) ) - { - /* Adding data to a segment that was already in the TX queue. It - will be filled-up to a maximum of MSS (maximum segment size). */ - lToWrite = FreeRTOS_min_int32( lBytesLeft, pxSegment->lMaxLength - pxSegment->lDataLength ); - - pxSegment->lDataLength += lToWrite; - - if( pxSegment->lDataLength >= pxSegment->lMaxLength ) - { - /* This segment is full, don't add more bytes. */ - pxWindow->pxHeadSegment = NULL; - } - - lBytesLeft -= lToWrite; - - /* ulNextTxSequenceNumber is the sequence number of the next byte to - be stored for transmission. */ - pxWindow->ulNextTxSequenceNumber += ( uint32_t ) lToWrite; - - /* Increased the return value. */ - lDone += lToWrite; - - /* Some detailed logging, for those who're interested. */ - if( ( xTCPWindowLoggingLevel >= 2 ) && ( ipconfigTCP_MAY_LOG_PORT( pxWindow->usOurPortNumber ) != 0 ) ) - { - FreeRTOS_debug_printf( ( "lTCPWindowTxAdd: Add %4lu bytes for seqNr %lu len %4lu (nxt %lu) pos %lu\n", - ulLength, - pxSegment->ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber, - pxSegment->lDataLength, - pxWindow->ulNextTxSequenceNumber - pxWindow->tx.ulFirstSequenceNumber, - pxSegment->lStreamPos ) ); - FreeRTOS_flush_logging( ); - } - - /* Calculate the next position in the circular data buffer, knowing - its maximum length 'lMax'. */ - lPosition = lTCPIncrementTxPosition( lPosition, lMax, lToWrite ); - } - } - } - - while( lBytesLeft > 0 ) - { - /* The current transmission segment is full, create new segments as - needed. */ - pxSegment = xTCPWindowTxNew( pxWindow, pxWindow->ulNextTxSequenceNumber, pxWindow->usMSS ); - - if( pxSegment != NULL ) - { - /* Store as many as needed, but no more than the maximum - (MSS). */ - lToWrite = FreeRTOS_min_int32( lBytesLeft, pxSegment->lMaxLength ); - - pxSegment->lDataLength = lToWrite; - pxSegment->lStreamPos = lPosition; - lBytesLeft -= lToWrite; - lPosition = lTCPIncrementTxPosition( lPosition, lMax, lToWrite ); - pxWindow->ulNextTxSequenceNumber += ( uint32_t ) lToWrite; - lDone += lToWrite; - - /* Link this segment in the Tx-Queue. */ - vListInsertFifo( &( pxWindow->xTxQueue ), &( pxSegment->xQueueItem ) ); - - /* Let 'pxHeadSegment' point to this segment if there is still - space. */ - if( pxSegment->lDataLength < pxSegment->lMaxLength ) - { - pxWindow->pxHeadSegment = pxSegment; - } - else - { - pxWindow->pxHeadSegment = NULL; - } - - if( ipconfigTCP_MAY_LOG_PORT( pxWindow->usOurPortNumber ) != 0 ) - { - if( ( xTCPWindowLoggingLevel >= 3 ) || - ( ( xTCPWindowLoggingLevel >= 2 ) && ( pxWindow->pxHeadSegment != NULL ) ) ) - { - FreeRTOS_debug_printf( ( "lTCPWindowTxAdd: New %4ld bytes for seqNr %lu len %4lu (nxt %lu) pos %lu\n", - ulLength, - pxSegment->ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber, - pxSegment->lDataLength, - pxWindow->ulNextTxSequenceNumber - pxWindow->tx.ulFirstSequenceNumber, - pxSegment->lStreamPos ) ); - FreeRTOS_flush_logging( ); - } - } - } - else - { - /* A sever situation: running out of segments for transmission. - No more data can be sent at the moment. */ - if( lDone != 0 ) - { - FreeRTOS_debug_printf( ( "lTCPWindowTxAdd: Sorry all buffers full (cancel %ld bytes)\n", lBytesLeft ) ); - } - break; - } - } - - return lDone; - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - BaseType_t xTCPWindowTxDone( TCPWindow_t *pxWindow ) - { - return listLIST_IS_EMPTY( ( &pxWindow->xTxSegments) ); - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - static BaseType_t prvTCPWindowTxHasSpace( TCPWindow_t *pxWindow, uint32_t ulWindowSize ) - { - uint32_t ulTxOutstanding; - BaseType_t xHasSpace; - TCPSegment_t *pxSegment; - - /* This function will look if there is new transmission data. It will - return true if there is data to be sent. */ - - pxSegment = xTCPWindowPeekHead( &( pxWindow->xTxQueue ) ); - - if( pxSegment == NULL ) - { - xHasSpace = pdFALSE; - } - else - { - /* How much data is outstanding, i.e. how much data has been sent - but not yet acknowledged ? */ - if( pxWindow->tx.ulHighestSequenceNumber >= pxWindow->tx.ulCurrentSequenceNumber ) - { - ulTxOutstanding = pxWindow->tx.ulHighestSequenceNumber - pxWindow->tx.ulCurrentSequenceNumber; - } - else - { - ulTxOutstanding = 0UL; - } - - /* Subtract this from the peer's space. */ - ulWindowSize -= FreeRTOS_min_uint32( ulWindowSize, ulTxOutstanding ); - - /* See if the next segment may be sent. */ - if( ulWindowSize >= ( uint32_t ) pxSegment->lDataLength ) - { - xHasSpace = pdTRUE; - } - else - { - xHasSpace = pdFALSE; - } - - /* If 'xHasSpace', it looks like the peer has at least space for 1 - more new segment of size MSS. xSize.ulTxWindowLength is the self-imposed - limitation of the transmission window (in case of many resends it - may be decreased). */ - if( ( ulTxOutstanding != 0UL ) && ( pxWindow->xSize.ulTxWindowLength < ulTxOutstanding + ( ( uint32_t ) pxSegment->lDataLength ) ) ) - { - xHasSpace = pdFALSE; - } - } - - return xHasSpace; - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - BaseType_t xTCPWindowTxHasData( TCPWindow_t *pxWindow, uint32_t ulWindowSize, TickType_t *pulDelay ) - { - TCPSegment_t *pxSegment; - BaseType_t xReturn; - TickType_t ulAge, ulMaxAge; - - *pulDelay = 0u; - - if( listLIST_IS_EMPTY( &pxWindow->xPriorityQueue ) == pdFALSE ) - { - /* No need to look at retransmissions or new transmission as long as - there are priority segments. *pulDelay equals zero, meaning it must - be sent out immediately. */ - xReturn = pdTRUE; - } - else - { - pxSegment = xTCPWindowPeekHead( &( pxWindow->xWaitQueue ) ); - - if( pxSegment != NULL ) - { - /* There is an outstanding segment, see if it is time to resend - it. */ - ulAge = ulTimerGetAge( &pxSegment->xTransmitTimer ); - - /* After a packet has been sent for the first time, it will wait - '1 * lSRTT' ms for an ACK. A second time it will wait '2 * lSRTT' ms, - each time doubling the time-out */ - ulMaxAge = ( 1u << pxSegment->u.bits.ucTransmitCount ) * ( ( uint32_t ) pxWindow->lSRTT ); - - if( ulMaxAge > ulAge ) - { - /* A segment must be sent after this amount of msecs */ - *pulDelay = ulMaxAge - ulAge; - } - - xReturn = pdTRUE; - } - else - { - /* No priority segment, no outstanding data, see if there is new - transmission data. */ - pxSegment = xTCPWindowPeekHead( &pxWindow->xTxQueue ); - - /* See if it fits in the peer's reception window. */ - if( pxSegment == NULL ) - { - xReturn = pdFALSE; - } - else if( prvTCPWindowTxHasSpace( pxWindow, ulWindowSize ) == pdFALSE ) - { - /* Too many outstanding messages. */ - xReturn = pdFALSE; - } - else if( ( pxWindow->u.bits.bSendFullSize != pdFALSE_UNSIGNED ) && ( pxSegment->lDataLength < pxSegment->lMaxLength ) ) - { - /* 'bSendFullSize' is a special optimisation. If true, the - driver will only sent completely filled packets (of MSS - bytes). */ - xReturn = pdFALSE; - } - else - { - xReturn = pdTRUE; - } - } - } - - return xReturn; - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - uint32_t ulTCPWindowTxGet( TCPWindow_t *pxWindow, uint32_t ulWindowSize, int32_t *plPosition ) - { - TCPSegment_t *pxSegment; - uint32_t ulMaxTime; - uint32_t ulReturn = ~0UL; - - - /* Fetches data to be sent-out now. - - Priority messages: segments with a resend need no check current sliding - window size. */ - pxSegment = xTCPWindowGetHead( &( pxWindow->xPriorityQueue ) ); - pxWindow->ulOurSequenceNumber = pxWindow->tx.ulHighestSequenceNumber; - - if( pxSegment == NULL ) - { - /* Waiting messages: outstanding messages with a running timer - neither check peer's reception window size because these packets - have been sent earlier. */ - pxSegment = xTCPWindowPeekHead( &( pxWindow->xWaitQueue ) ); - - if( pxSegment != NULL ) - { - /* Do check the timing. */ - ulMaxTime = ( 1u << pxSegment->u.bits.ucTransmitCount ) * ( ( uint32_t ) pxWindow->lSRTT ); - - if( ulTimerGetAge( &pxSegment->xTransmitTimer ) > ulMaxTime ) - { - /* A normal (non-fast) retransmission. Move it from the - head of the waiting queue. */ - pxSegment = xTCPWindowGetHead( &( pxWindow->xWaitQueue ) ); - pxSegment->u.bits.ucDupAckCount = pdFALSE_UNSIGNED; - - /* Some detailed logging. */ - if( ( xTCPWindowLoggingLevel != 0 ) && ( ipconfigTCP_MAY_LOG_PORT( pxWindow->usOurPortNumber ) != 0 ) ) - { - FreeRTOS_debug_printf( ( "ulTCPWindowTxGet[%u,%u]: WaitQueue %ld bytes for sequence number %lu (%lX)\n", - pxWindow->usPeerPortNumber, - pxWindow->usOurPortNumber, - pxSegment->lDataLength, - pxSegment->ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber, - pxSegment->ulSequenceNumber ) ); - FreeRTOS_flush_logging( ); - } - } - else - { - pxSegment = NULL; - } - } - - if( pxSegment == NULL ) - { - /* New messages: sent-out for the first time. Check current - sliding window size of peer. */ - pxSegment = xTCPWindowPeekHead( &( pxWindow->xTxQueue ) ); - - if( pxSegment == NULL ) - { - /* No segments queued. */ - ulReturn = 0UL; - } - else if( ( pxWindow->u.bits.bSendFullSize != pdFALSE_UNSIGNED ) && ( pxSegment->lDataLength < pxSegment->lMaxLength ) ) - { - /* A segment has been queued but the driver waits until it - has a full size of MSS. */ - ulReturn = 0; - } - else if( prvTCPWindowTxHasSpace( pxWindow, ulWindowSize ) == pdFALSE ) - { - /* Peer has no more space at this moment. */ - ulReturn = 0; - } - else - { - /* Move it out of the Tx queue. */ - pxSegment = xTCPWindowGetHead( &( pxWindow->xTxQueue ) ); - - /* Don't let pxHeadSegment point to this segment any more, - so no more data will be added. */ - if( pxWindow->pxHeadSegment == pxSegment ) - { - pxWindow->pxHeadSegment = NULL; - } - - /* pxWindow->tx.highest registers the highest sequence - number in our transmission window. */ - pxWindow->tx.ulHighestSequenceNumber = pxSegment->ulSequenceNumber + ( ( uint32_t ) pxSegment->lDataLength ); - - /* ...and more detailed logging */ - if( ( xTCPWindowLoggingLevel >= 2 ) && ( ipconfigTCP_MAY_LOG_PORT( pxWindow->usOurPortNumber ) != pdFALSE ) ) - { - FreeRTOS_debug_printf( ( "ulTCPWindowTxGet[%u,%u]: XmitQueue %ld bytes for sequence number %lu (ws %lu)\n", - pxWindow->usPeerPortNumber, - pxWindow->usOurPortNumber, - pxSegment->lDataLength, - pxSegment->ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber, - ulWindowSize ) ); - FreeRTOS_flush_logging( ); - } - } - } - } - else - { - /* There is a priority segment. It doesn't need any checking for - space or timeouts. */ - if( xTCPWindowLoggingLevel != 0 ) - { - FreeRTOS_debug_printf( ( "ulTCPWindowTxGet[%u,%u]: PrioQueue %ld bytes for sequence number %lu (ws %lu)\n", - pxWindow->usPeerPortNumber, - pxWindow->usOurPortNumber, - pxSegment->lDataLength, - pxSegment->ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber, - ulWindowSize ) ); - FreeRTOS_flush_logging( ); - } - } - - /* See if it has already been determined to return 0. */ - if( ulReturn != 0UL ) - { - configASSERT( listLIST_ITEM_CONTAINER( &(pxSegment->xQueueItem ) ) == NULL ); - - /* Now that the segment will be transmitted, add it to the tail of - the waiting queue. */ - vListInsertFifo( &pxWindow->xWaitQueue, &pxSegment->xQueueItem ); - - /* And mark it as outstanding. */ - pxSegment->u.bits.bOutstanding = pdTRUE_UNSIGNED; - - /* Administer the transmit count, needed for fast - retransmissions. */ - ( pxSegment->u.bits.ucTransmitCount )++; - - /* If there have been several retransmissions (4), decrease the - size of the transmission window to at most 2 times MSS. */ - if( pxSegment->u.bits.ucTransmitCount == MAX_TRANSMIT_COUNT_USING_LARGE_WINDOW ) - { - if( pxWindow->xSize.ulTxWindowLength > ( 2U * pxWindow->usMSS ) ) - { - FreeRTOS_debug_printf( ( "ulTCPWindowTxGet[%u - %d]: Change Tx window: %lu -> %u\n", - pxWindow->usPeerPortNumber, pxWindow->usOurPortNumber, - pxWindow->xSize.ulTxWindowLength, 2 * pxWindow->usMSS ) ); - pxWindow->xSize.ulTxWindowLength = ( 2UL * pxWindow->usMSS ); - } - } - - /* Clear the transmit timer. */ - vTCPTimerSet( &( pxSegment->xTransmitTimer ) ); - - pxWindow->ulOurSequenceNumber = pxSegment->ulSequenceNumber; - - /* Inform the caller where to find the data within the queue. */ - *plPosition = pxSegment->lStreamPos; - - /* And return the length of the data segment */ - ulReturn = ( uint32_t ) pxSegment->lDataLength; - } - - return ulReturn; - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - static uint32_t prvTCPWindowTxCheckAck( TCPWindow_t *pxWindow, uint32_t ulFirst, uint32_t ulLast ) - { - uint32_t ulBytesConfirmed = 0u; - uint32_t ulSequenceNumber = ulFirst, ulDataLength; - const ListItem_t *pxIterator; - const MiniListItem_t *pxEnd = ( const MiniListItem_t* )listGET_END_MARKER( &pxWindow->xTxSegments ); - BaseType_t xDoUnlink; - TCPSegment_t *pxSegment; - /* An acknowledgement or a selective ACK (SACK) was received. See if some outstanding data - may be removed from the transmission queue(s). - All TX segments for which - ( ( ulSequenceNumber >= ulFirst ) && ( ulSequenceNumber < ulLast ) in a - contiguous block. Note that the segments are stored in xTxSegments in a - strict sequential order. */ - - /* SRTT[i] = (1-a) * SRTT[i-1] + a * RTT - - 0 < a < 1; usually a = 1/8 - - RTO = 2 * SRTT - - where: - RTT is Round Trip Time - SRTT is Smoothed RTT - RTO is Retransmit timeout - - A Smoothed RTT will increase quickly, but it is conservative when - becoming smaller. */ - - for( - pxIterator = ( const ListItem_t * ) listGET_NEXT( pxEnd ); - ( pxIterator != ( const ListItem_t * ) pxEnd ) && ( xSequenceLessThan( ulSequenceNumber, ulLast ) != 0 ); - ) - { - xDoUnlink = pdFALSE; - pxSegment = ( TCPSegment_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); - - /* Move to the next item because the current item might get - removed. */ - pxIterator = ( const ListItem_t * ) listGET_NEXT( pxIterator ); - - /* Continue if this segment does not fall within the ACK'd range. */ - if( xSequenceGreaterThan( ulSequenceNumber, pxSegment->ulSequenceNumber ) != pdFALSE ) - { - continue; - } - - /* Is it ready? */ - if( ulSequenceNumber != pxSegment->ulSequenceNumber ) - { - break; - } - - ulDataLength = ( uint32_t ) pxSegment->lDataLength; - - if( pxSegment->u.bits.bAcked == pdFALSE_UNSIGNED ) - { - if( xSequenceGreaterThan( pxSegment->ulSequenceNumber + ( uint32_t )ulDataLength, ulLast ) != pdFALSE ) - { - /* What happens? Only part of this segment was accepted, - probably due to WND limits - - AAAAAAA BBBBBBB << acked - aaaaaaa aaaa << sent */ - #if( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - uint32_t ulFirstSeq = pxSegment->ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber; - FreeRTOS_debug_printf( ( "prvTCPWindowTxCheckAck[%u.%u]: %lu - %lu Partial sequence number %lu - %lu\n", - pxWindow->usPeerPortNumber, - pxWindow->usOurPortNumber, - ulFirstSeq - pxWindow->tx.ulFirstSequenceNumber, - ulLast - pxWindow->tx.ulFirstSequenceNumber, - ulFirstSeq, ulFirstSeq + ulDataLength ) ); - } - #endif /* ipconfigHAS_DEBUG_PRINTF */ - break; - } - - /* This segment is fully ACK'd, set the flag. */ - pxSegment->u.bits.bAcked = pdTRUE_UNSIGNED; - - /* Calculate the RTT only if the segment was sent-out for the - first time and if this is the last ACK'd segment in a range. */ - if( ( pxSegment->u.bits.ucTransmitCount == 1 ) && ( ( pxSegment->ulSequenceNumber + ulDataLength ) == ulLast ) ) - { - int32_t mS = ( int32_t ) ulTimerGetAge( &( pxSegment->xTransmitTimer ) ); - - if( pxWindow->lSRTT >= mS ) - { - /* RTT becomes smaller: adapt slowly. */ - pxWindow->lSRTT = ( ( winSRTT_DECREMENT_NEW * mS ) + ( winSRTT_DECREMENT_CURRENT * pxWindow->lSRTT ) ) / ( winSRTT_DECREMENT_NEW + winSRTT_DECREMENT_CURRENT ); - } - else - { - /* RTT becomes larger: adapt quicker */ - pxWindow->lSRTT = ( ( winSRTT_INCREMENT_NEW * mS ) + ( winSRTT_INCREMENT_CURRENT * pxWindow->lSRTT ) ) / ( winSRTT_INCREMENT_NEW + winSRTT_INCREMENT_CURRENT ); - } - - /* Cap to the minimum of 50ms. */ - if( pxWindow->lSRTT < winSRTT_CAP_mS ) - { - pxWindow->lSRTT = winSRTT_CAP_mS; - } - } - - /* Unlink it from the 3 queues, but do not destroy it (yet). */ - xDoUnlink = pdTRUE; - } - - /* pxSegment->u.bits.bAcked is now true. Is it located at the left - side of the transmission queue? If so, it may be freed. */ - if( ulSequenceNumber == pxWindow->tx.ulCurrentSequenceNumber ) - { - if( ( xTCPWindowLoggingLevel >= 2 ) && ( ipconfigTCP_MAY_LOG_PORT( pxWindow->usOurPortNumber ) != pdFALSE ) ) - { - FreeRTOS_debug_printf( ( "prvTCPWindowTxCheckAck: %lu - %lu Ready sequence number %lu\n", - ulFirst - pxWindow->tx.ulFirstSequenceNumber, - ulLast - pxWindow->tx.ulFirstSequenceNumber, - pxSegment->ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber ) ); - } - - /* Increase the left-hand value of the transmission window. */ - pxWindow->tx.ulCurrentSequenceNumber += ulDataLength; - - /* This function will return the number of bytes that the tail - of txStream may be advanced. */ - ulBytesConfirmed += ulDataLength; - - /* All segments below tx.ulCurrentSequenceNumber may be freed. */ - vTCPWindowFree( pxSegment ); - - /* No need to unlink it any more. */ - xDoUnlink = pdFALSE; - } - - if( ( xDoUnlink != pdFALSE ) && ( listLIST_ITEM_CONTAINER( &( pxSegment->xQueueItem ) ) != NULL ) ) - { - /* Remove item from its queues. */ - uxListRemove( &pxSegment->xQueueItem ); - } - - ulSequenceNumber += ulDataLength; - } - - return ulBytesConfirmed; - } -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - static uint32_t prvTCPWindowFastRetransmit( TCPWindow_t *pxWindow, uint32_t ulFirst ) - { - const ListItem_t *pxIterator; - const MiniListItem_t* pxEnd; - TCPSegment_t *pxSegment; - uint32_t ulCount = 0UL; - - /* A higher Tx block has been acknowledged. Now iterate through the - xWaitQueue to find a possible condition for a FAST retransmission. */ - - pxEnd = ( const MiniListItem_t* ) listGET_END_MARKER( &( pxWindow->xWaitQueue ) ); - - for( pxIterator = ( const ListItem_t * ) listGET_NEXT( pxEnd ); - pxIterator != ( const ListItem_t * ) pxEnd; ) - { - /* Get the owner, which is a TCP segment. */ - pxSegment = ( TCPSegment_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); - - /* Hop to the next item before the current gets unlinked. */ - pxIterator = ( const ListItem_t * ) listGET_NEXT( pxIterator ); - - /* Fast retransmission: - When 3 packets with a higher sequence number have been acknowledged - by the peer, it is very unlikely a current packet will ever arrive. - It will be retransmitted far before the RTO. */ - if( ( pxSegment->u.bits.bAcked == pdFALSE_UNSIGNED ) && - ( xSequenceLessThan( pxSegment->ulSequenceNumber, ulFirst ) != pdFALSE ) && - ( ++( pxSegment->u.bits.ucDupAckCount ) == DUPLICATE_ACKS_BEFORE_FAST_RETRANSMIT ) ) - { - pxSegment->u.bits.ucTransmitCount = pdFALSE_UNSIGNED; - - /* Not clearing 'ucDupAckCount' yet as more SACK's might come in - which might lead to a second fast rexmit. */ - if( ( xTCPWindowLoggingLevel >= 0 ) && ( ipconfigTCP_MAY_LOG_PORT( pxWindow->usOurPortNumber ) != pdFALSE ) ) - { - FreeRTOS_debug_printf( ( "prvTCPWindowFastRetransmit: Requeue sequence number %lu < %lu\n", - pxSegment->ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber, - ulFirst - pxWindow->tx.ulFirstSequenceNumber ) ); - FreeRTOS_flush_logging( ); - } - - /* Remove it from xWaitQueue. */ - uxListRemove( &pxSegment->xQueueItem ); - - /* Add this segment to the priority queue so it gets - retransmitted immediately. */ - vListInsertFifo( &( pxWindow->xPriorityQueue ), &( pxSegment->xQueueItem ) ); - ulCount++; - } - } - - return ulCount; - } -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - uint32_t ulTCPWindowTxAck( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber ) - { - uint32_t ulFirstSequence, ulReturn; - - /* Receive a normal ACK. */ - - ulFirstSequence = pxWindow->tx.ulCurrentSequenceNumber; - - if( xSequenceLessThanOrEqual( ulSequenceNumber, ulFirstSequence ) != pdFALSE ) - { - ulReturn = 0UL; - } - else - { - ulReturn = prvTCPWindowTxCheckAck( pxWindow, ulFirstSequence, ulSequenceNumber ); - } - - return ulReturn; - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 1 ) - - uint32_t ulTCPWindowTxSack( TCPWindow_t *pxWindow, uint32_t ulFirst, uint32_t ulLast ) - { - uint32_t ulAckCount = 0UL; - uint32_t ulCurrentSequenceNumber = pxWindow->tx.ulCurrentSequenceNumber; - - /* Receive a SACK option. */ - ulAckCount = prvTCPWindowTxCheckAck( pxWindow, ulFirst, ulLast ); - prvTCPWindowFastRetransmit( pxWindow, ulFirst ); - - if( ( xTCPWindowLoggingLevel >= 1 ) && ( xSequenceGreaterThan( ulFirst, ulCurrentSequenceNumber ) != pdFALSE ) ) - { - FreeRTOS_debug_printf( ( "ulTCPWindowTxSack[%u,%u]: from %lu to %lu (ack = %lu)\n", - pxWindow->usPeerPortNumber, - pxWindow->usOurPortNumber, - ulFirst - pxWindow->tx.ulFirstSequenceNumber, - ulLast - pxWindow->tx.ulFirstSequenceNumber, - pxWindow->tx.ulCurrentSequenceNumber - pxWindow->tx.ulFirstSequenceNumber ) ); - FreeRTOS_flush_logging( ); - } - - return ulAckCount; - } - -#endif /* ipconfigUSE_TCP_WIN == 1 */ -/*-----------------------------------------------------------*/ - -/* -##### # ##### #### ###### -# # # # # # # # # # # - # # # # # # - # ### ##### # # # # # # - # # # # # # # # ##### - # # # # # # #### # # # - # # # # # # # # # # - # # # # #### # # # # - #### ##### # # # #### #### #### - # - ### -*/ -#if( ipconfigUSE_TCP_WIN == 0 ) - - int32_t lTCPWindowRxCheck( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber, uint32_t ulLength, uint32_t ulSpace ) - { - int32_t iReturn; - - /* Data was received at 'ulSequenceNumber'. See if it was expected - and if there is enough space to store the new data. */ - if( ( pxWindow->rx.ulCurrentSequenceNumber != ulSequenceNumber ) || ( ulSpace < ulLength ) ) - { - iReturn = -1; - } - else - { - pxWindow->rx.ulCurrentSequenceNumber += ( uint32_t ) ulLength; - iReturn = 0; - } - - return iReturn; - } - -#endif /* ipconfigUSE_TCP_WIN == 0 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 0 ) - - int32_t lTCPWindowTxAdd( TCPWindow_t *pxWindow, uint32_t ulLength, int32_t lPosition, int32_t lMax ) - { - TCPSegment_t *pxSegment = &( pxWindow->xTxSegment ); - int32_t lResult; - - /* Data is being scheduled for transmission. */ - - /* lMax would indicate the size of the txStream. */ - ( void ) lMax; - /* This is tiny TCP: there is only 1 segment for outgoing data. - As long as 'lDataLength' is unequal to zero, the segment is still occupied. */ - if( pxSegment->lDataLength > 0 ) - { - lResult = 0L; - } - else - { - if( ulLength > ( uint32_t ) pxSegment->lMaxLength ) - { - if( ( xTCPWindowLoggingLevel != 0 ) && ( ipconfigTCP_MAY_LOG_PORT( pxWindow->usOurPortNumber ) != pdFALSE ) ) - { - FreeRTOS_debug_printf( ( "lTCPWindowTxAdd: can only store %ld / %ld bytes\n", ulLength, pxSegment->lMaxLength ) ); - } - - ulLength = ( uint32_t ) pxSegment->lMaxLength; - } - - if( ( xTCPWindowLoggingLevel != 0 ) && ( ipconfigTCP_MAY_LOG_PORT( pxWindow->usOurPortNumber ) != pdFALSE ) ) - { - FreeRTOS_debug_printf( ( "lTCPWindowTxAdd: SeqNr %ld (%ld) Len %ld\n", - pxWindow->ulNextTxSequenceNumber - pxWindow->tx.ulFirstSequenceNumber, - pxWindow->tx.ulCurrentSequenceNumber - pxWindow->tx.ulFirstSequenceNumber, - ulLength ) ); - } - - /* The sequence number of the first byte in this packet. */ - pxSegment->ulSequenceNumber = pxWindow->ulNextTxSequenceNumber; - pxSegment->lDataLength = ( int32_t ) ulLength; - pxSegment->lStreamPos = lPosition; - pxSegment->u.ulFlags = 0UL; - vTCPTimerSet( &( pxSegment->xTransmitTimer ) ); - - /* Increase the sequence number of the next data to be stored for - transmission. */ - pxWindow->ulNextTxSequenceNumber += ulLength; - lResult = ( int32_t )ulLength; - } - - return lResult; - } - -#endif /* ipconfigUSE_TCP_WIN == 0 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 0 ) - - uint32_t ulTCPWindowTxGet( TCPWindow_t *pxWindow, uint32_t ulWindowSize, int32_t *plPosition ) - { - TCPSegment_t *pxSegment = &( pxWindow->xTxSegment ); - uint32_t ulLength = ( uint32_t ) pxSegment->lDataLength; - uint32_t ulMaxTime; - - if( ulLength != 0UL ) - { - /* _HT_ Still under investigation */ - ( void ) ulWindowSize; - - if( pxSegment->u.bits.bOutstanding != pdFALSE_UNSIGNED ) - { - /* As 'ucTransmitCount' has a minimum of 1, take 2 * RTT */ - ulMaxTime = ( ( uint32_t ) 1u << pxSegment->u.bits.ucTransmitCount ) * ( ( uint32_t ) pxWindow->lSRTT ); - - if( ulTimerGetAge( &( pxSegment->xTransmitTimer ) ) < ulMaxTime ) - { - ulLength = 0ul; - } - } - - if( ulLength != 0ul ) - { - pxSegment->u.bits.bOutstanding = pdTRUE_UNSIGNED; - pxSegment->u.bits.ucTransmitCount++; - vTCPTimerSet (&pxSegment->xTransmitTimer); - pxWindow->ulOurSequenceNumber = pxSegment->ulSequenceNumber; - *plPosition = pxSegment->lStreamPos; - } - } - - return ulLength; - } - -#endif /* ipconfigUSE_TCP_WIN == 0 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 0 ) - - BaseType_t xTCPWindowTxDone( TCPWindow_t *pxWindow ) - { - BaseType_t xReturn; - - /* Has the outstanding data been sent because user wants to shutdown? */ - if( pxWindow->xTxSegment.lDataLength == 0 ) - { - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - - return xReturn; - } - -#endif /* ipconfigUSE_TCP_WIN == 0 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 0 ) - - static BaseType_t prvTCPWindowTxHasSpace( TCPWindow_t *pxWindow, uint32_t ulWindowSize ); - static BaseType_t prvTCPWindowTxHasSpace( TCPWindow_t *pxWindow, uint32_t ulWindowSize ) - { - BaseType_t xReturn; - - if( ulWindowSize >= pxWindow->usMSSInit ) - { - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - - return xReturn; - } - -#endif /* ipconfigUSE_TCP_WIN == 0 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 0 ) - - BaseType_t xTCPWindowTxHasData( TCPWindow_t *pxWindow, uint32_t ulWindowSize, TickType_t *pulDelay ) - { - TCPSegment_t *pxSegment = &( pxWindow->xTxSegment ); - BaseType_t xReturn; - TickType_t ulAge, ulMaxAge; - - /* Check data to be sent. */ - *pulDelay = ( TickType_t ) 0; - if( pxSegment->lDataLength == 0 ) - { - /* Got nothing to send right now. */ - xReturn = pdFALSE; - } - else - { - if( pxSegment->u.bits.bOutstanding != pdFALSE_UNSIGNED ) - { - ulAge = ulTimerGetAge ( &pxSegment->xTransmitTimer ); - ulMaxAge = ( ( TickType_t ) 1u << pxSegment->u.bits.ucTransmitCount ) * ( ( uint32_t ) pxWindow->lSRTT ); - - if( ulMaxAge > ulAge ) - { - *pulDelay = ulMaxAge - ulAge; - } - - xReturn = pdTRUE; - } - else if( prvTCPWindowTxHasSpace( pxWindow, ulWindowSize ) == pdFALSE ) - { - /* Too many outstanding messages. */ - xReturn = pdFALSE; - } - else - { - xReturn = pdTRUE; - } - } - - return xReturn; - } - -#endif /* ipconfigUSE_TCP_WIN == 0 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 0 ) - - uint32_t ulTCPWindowTxAck( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber ) - { - TCPSegment_t *pxSegment = &( pxWindow->xTxSegment ); - uint32_t ulDataLength = ( uint32_t ) pxSegment->lDataLength; - - /* Receive a normal ACK */ - - if( ulDataLength != 0ul ) - { - if( ulSequenceNumber < ( pxWindow->tx.ulCurrentSequenceNumber + ulDataLength ) ) - { - if( ipconfigTCP_MAY_LOG_PORT( pxWindow->usOurPortNumber ) != pdFALSE ) - { - FreeRTOS_debug_printf( ( "win_tx_ack: acked %ld expc %ld len %ld\n", - ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber, - pxWindow->tx.ulCurrentSequenceNumber - pxWindow->tx.ulFirstSequenceNumber, - ulDataLength ) ); - } - - /* Nothing to send right now. */ - ulDataLength = 0ul; - } - else - { - pxWindow->tx.ulCurrentSequenceNumber += ulDataLength; - - if( ( xTCPWindowLoggingLevel != 0 ) && ( ipconfigTCP_MAY_LOG_PORT( pxWindow->usOurPortNumber ) != pdFALSE ) ) - { - FreeRTOS_debug_printf( ( "win_tx_ack: acked seqnr %ld len %ld\n", - ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber, - ulDataLength ) ); - } - - pxSegment->lDataLength = 0; - } - } - - return ulDataLength; - } - -#endif /* ipconfigUSE_TCP_WIN == 0 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 0 ) - - BaseType_t xTCPWindowRxEmpty( TCPWindow_t *pxWindow ) - { - /* Return true if 'ulCurrentSequenceNumber >= ulHighestSequenceNumber' - 'ulCurrentSequenceNumber' is the highest sequence number stored, - 'ulHighestSequenceNumber' is the highest sequence number seen. */ - return xSequenceGreaterThanOrEqual( pxWindow->rx.ulCurrentSequenceNumber, pxWindow->rx.ulHighestSequenceNumber ); - } - -#endif /* ipconfigUSE_TCP_WIN == 0 */ -/*-----------------------------------------------------------*/ - -#if( ipconfigUSE_TCP_WIN == 0 ) - - /* Destroy a window (always returns NULL) */ - void vTCPWindowDestroy( TCPWindow_t *pxWindow ) - { - /* As in tiny TCP there are no shared segments descriptors, there is - nothing to release. */ - ( void ) pxWindow; - } - -#endif /* ipconfigUSE_TCP_WIN == 0 */ -/*-----------------------------------------------------------*/ - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_UDP_IP.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_UDP_IP.c deleted file mode 100755 index f35551d..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_UDP_IP.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -/* Standard includes. */ -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_ARP.h" -#include "FreeRTOS_DHCP.h" -#include "NetworkInterface.h" -#include "NetworkBufferManagement.h" - -#if( ipconfigUSE_DNS == 1 ) - #include "FreeRTOS_DNS.h" -#endif - -/* The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - -/* Part of the Ethernet and IP headers are always constant when sending an IPv4 -UDP packet. This array defines the constant parts, allowing this part of the -packet to be filled in using a simple memcpy() instead of individual writes. */ -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; -/*-----------------------------------------------------------*/ - -void vProcessGeneratedUDPPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer ) -{ -UDPPacket_t *pxUDPPacket; -IPHeader_t *pxIPHeader; -eARPLookupResult_t eReturned; -uint32_t ulIPAddress = pxNetworkBuffer->ulIPAddress; - - /* Map the UDP packet onto the start of the frame. */ - pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - - /* Determine the ARP cache status for the requested IP address. */ - eReturned = eARPGetCacheEntry( &( ulIPAddress ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ) ); - - if( eReturned != eCantSendPacket ) - { - if( eReturned == eARPCacheHit ) - { - #if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - uint8_t ucSocketOptions; - #endif - iptraceSENDING_UDP_PACKET( pxNetworkBuffer->ulIPAddress ); - - /* Create short cuts to the data within the packet. */ - pxIPHeader = &( pxUDPPacket->xIPHeader ); - - #if ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) - /* Is it possible that the packet is not actually a UDP packet - after all, but an ICMP packet. */ - if( pxNetworkBuffer->usPort != ipPACKET_CONTAINS_ICMP_DATA ) - #endif /* ipconfigSUPPORT_OUTGOING_PINGS */ - { - UDPHeader_t *pxUDPHeader; - - pxUDPHeader = &( pxUDPPacket->xUDPHeader ); - - pxUDPHeader->usDestinationPort = pxNetworkBuffer->usPort; - pxUDPHeader->usSourcePort = pxNetworkBuffer->usBoundPort; - pxUDPHeader->usLength = ( uint16_t ) ( pxNetworkBuffer->xDataLength + sizeof( UDPHeader_t ) ); - pxUDPHeader->usLength = FreeRTOS_htons( pxUDPHeader->usLength ); - pxUDPHeader->usChecksum = 0u; - } - - /* memcpy() the constant parts of the header information into - the correct location within the packet. This fills in: - xEthernetHeader.xSourceAddress - xEthernetHeader.usFrameType - xIPHeader.ucVersionHeaderLength - xIPHeader.ucDifferentiatedServicesCode - xIPHeader.usLength - xIPHeader.usIdentification - xIPHeader.usFragmentOffset - xIPHeader.ucTimeToLive - xIPHeader.ucProtocol - and - xIPHeader.usHeaderChecksum - */ - /* Save options now, as they will be overwritten by memcpy */ - #if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - ucSocketOptions = pxNetworkBuffer->pucEthernetBuffer[ ipSOCKET_OPTIONS_OFFSET ]; - #endif - /* - * Offset the memcpy by the size of a MAC address to start at the packet's - * Ethernet header 'source' MAC address; the preceding 'destination' should not be altered. - */ - char *pxUdpSrcAddrOffset = ( char *) pxUDPPacket + sizeof( MACAddress_t ); - memcpy( pxUdpSrcAddrOffset, xDefaultPartUDPPacketHeader.ucBytes, sizeof( xDefaultPartUDPPacketHeader ) ); - - #if ipconfigSUPPORT_OUTGOING_PINGS == 1 - if( pxNetworkBuffer->usPort == ipPACKET_CONTAINS_ICMP_DATA ) - { - pxIPHeader->ucProtocol = ipPROTOCOL_ICMP; - pxIPHeader->usLength = ( uint16_t ) ( pxNetworkBuffer->xDataLength + sizeof( IPHeader_t ) ); - } - else - #endif /* ipconfigSUPPORT_OUTGOING_PINGS */ - { - pxIPHeader->usLength = ( uint16_t ) ( pxNetworkBuffer->xDataLength + sizeof( IPHeader_t ) + sizeof( UDPHeader_t ) ); - } - - /* The total transmit size adds on the Ethernet header. */ - pxNetworkBuffer->xDataLength = pxIPHeader->usLength + sizeof( EthernetHeader_t ); - pxIPHeader->usLength = FreeRTOS_htons( pxIPHeader->usLength ); - /* HT:endian: changed back to network endian */ - pxIPHeader->ulDestinationIPAddress = pxNetworkBuffer->ulIPAddress; - - #if( ipconfigUSE_LLMNR == 1 ) - { - /* LLMNR messages are typically used on a LAN and they're - * not supposed to cross routers */ - if( pxNetworkBuffer->ulIPAddress == ipLLMNR_IP_ADDR ) - { - pxIPHeader->ucTimeToLive = 0x01; - } - } - #endif - - #if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - { - pxIPHeader->usHeaderChecksum = 0u; - pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0UL, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER ); - pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum ); - - if( ( ucSocketOptions & ( uint8_t ) FREERTOS_SO_UDPCKSUM_OUT ) != 0u ) - { - usGenerateProtocolChecksum( (uint8_t*)pxUDPPacket, pxNetworkBuffer->xDataLength, pdTRUE ); - } - else - { - pxUDPPacket->xUDPHeader.usChecksum = 0u; - } - } - #endif - } - else if( eReturned == eARPCacheMiss ) - { - /* Add an entry to the ARP table with a null hardware address. - This allows the ARP timer to know that an ARP reply is - outstanding, and perform retransmissions if necessary. */ - vARPRefreshCacheEntry( NULL, ulIPAddress ); - - /* Generate an ARP for the required IP address. */ - iptracePACKET_DROPPED_TO_GENERATE_ARP( pxNetworkBuffer->ulIPAddress ); - pxNetworkBuffer->ulIPAddress = ulIPAddress; - vARPGenerateRequestPacket( pxNetworkBuffer ); - } - else - { - /* The lookup indicated that an ARP request has already been - sent out for the queried IP address. */ - eReturned = eCantSendPacket; - } - } - - if( eReturned != eCantSendPacket ) - { - /* The network driver is responsible for freeing the network buffer - after the packet has been sent. */ - - #if defined( ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - { - if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - { - BaseType_t xIndex; - - for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) - { - pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0u; - } - pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; - } - } - #endif - - xNetworkInterfaceOutput( pxNetworkBuffer, pdTRUE ); - } - else - { - /* The packet can't be sent (DHCP not completed?). Just drop the - packet. */ - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - } -} -/*-----------------------------------------------------------*/ - -BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t *pxNetworkBuffer, uint16_t usPort ) -{ -BaseType_t xReturn = pdPASS; -FreeRTOS_Socket_t *pxSocket; - -UDPPacket_t *pxUDPPacket = (UDPPacket_t *) pxNetworkBuffer->pucEthernetBuffer; - - /* Caller must check for minimum packet size. */ - pxSocket = pxUDPSocketLookup( usPort ); - - if( pxSocket ) - { - - /* When refreshing the ARP cache with received UDP packets we must be - careful; hundreds of broadcast messages may pass and if we're not - handling them, no use to fill the ARP cache with those IP addresses. */ - vARPRefreshCacheEntry( &( pxUDPPacket->xEthernetHeader.xSourceAddress ), pxUDPPacket->xIPHeader.ulSourceIPAddress ); - - #if( ipconfigUSE_CALLBACKS == 1 ) - { - /* Did the owner of this socket register a reception handler ? */ - if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xUDP.pxHandleReceive ) ) - { - struct freertos_sockaddr xSourceAddress, destinationAddress; - void *pcData = ( void * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipUDP_PAYLOAD_OFFSET_IPv4 ] ); - FOnUDPReceive_t xHandler = ( FOnUDPReceive_t ) pxSocket->u.xUDP.pxHandleReceive; - xSourceAddress.sin_port = pxNetworkBuffer->usPort; - xSourceAddress.sin_addr = pxNetworkBuffer->ulIPAddress; - destinationAddress.sin_port = usPort; - destinationAddress.sin_addr = pxUDPPacket->xIPHeader.ulDestinationIPAddress; - - if( xHandler( ( Socket_t * ) pxSocket, ( void* ) pcData, ( size_t ) pxNetworkBuffer->xDataLength, - &xSourceAddress, &destinationAddress ) ) - { - xReturn = pdFAIL; /* FAIL means that we did not consume or release the buffer */ - } - } - } - #endif /* ipconfigUSE_CALLBACKS */ - - #if( ipconfigUDP_MAX_RX_PACKETS > 0 ) - { - if( xReturn == pdPASS ) - { - if ( listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ) >= pxSocket->u.xUDP.uxMaxPackets ) - { - FreeRTOS_debug_printf( ( "xProcessReceivedUDPPacket: buffer full %ld >= %ld port %u\n", - listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ), - pxSocket->u.xUDP.uxMaxPackets, pxSocket->usLocalPort ) ); - xReturn = pdFAIL; /* we did not consume or release the buffer */ - } - } - } - #endif - - if( xReturn == pdPASS ) - { - vTaskSuspendAll(); - { - if( xReturn == pdPASS ) - { - taskENTER_CRITICAL(); - { - /* Add the network packet to the list of packets to be - processed by the socket. */ - vListInsertEnd( &( pxSocket->u.xUDP.xWaitingPacketsList ), &( pxNetworkBuffer->xBufferListItem ) ); - } - taskEXIT_CRITICAL(); - } - } - xTaskResumeAll(); - - /* Set the socket's receive event */ - if( pxSocket->xEventGroup != NULL ) - { - xEventGroupSetBits( pxSocket->xEventGroup, eSOCKET_RECEIVE ); - } - - #if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - { - if( ( pxSocket->pxSocketSet != NULL ) && ( ( pxSocket->xSelectBits & eSELECT_READ ) != 0 ) ) - { - xEventGroupSetBits( pxSocket->pxSocketSet->xSelectGroup, eSELECT_READ ); - } - } - #endif - - #if( ipconfigSOCKET_HAS_USER_SEMAPHORE == 1 ) - { - if( pxSocket->pxUserSemaphore != NULL ) - { - xSemaphoreGive( pxSocket->pxUserSemaphore ); - } - } - #endif - - #if( ipconfigUSE_DHCP == 1 ) - { - if( xIsDHCPSocket( pxSocket ) ) - { - xSendEventToIPTask( eDHCPEvent ); - } - } - #endif - } - } - else - { - /* There is no socket listening to the target port, but still it might - be for this node. */ - - #if( ipconfigUSE_LLMNR == 1 ) - /* a LLMNR request, check for the destination port. */ - if( ( usPort == FreeRTOS_ntohs( ipLLMNR_PORT ) ) || - ( pxUDPPacket->xUDPHeader.usSourcePort == FreeRTOS_ntohs( ipLLMNR_PORT ) ) ) - { - vARPRefreshCacheEntry( &( pxUDPPacket->xEthernetHeader.xSourceAddress ), pxUDPPacket->xIPHeader.ulSourceIPAddress ); - xReturn = ( BaseType_t )ulDNSHandlePacket( pxNetworkBuffer ); - } - else - #endif /* ipconfigUSE_LLMNR */ - - #if( ipconfigUSE_NBNS == 1 ) - /* a NetBIOS request, check for the destination port */ - if( ( usPort == FreeRTOS_ntohs( ipNBNS_PORT ) ) || - ( pxUDPPacket->xUDPHeader.usSourcePort == FreeRTOS_ntohs( ipNBNS_PORT ) ) ) - { - vARPRefreshCacheEntry( &( pxUDPPacket->xEthernetHeader.xSourceAddress ), pxUDPPacket->xIPHeader.ulSourceIPAddress ); - xReturn = ( BaseType_t )ulNBNSHandlePacket( pxNetworkBuffer ); - } - else - #endif /* ipconfigUSE_NBNS */ - { - xReturn = pdFAIL; - } - } - - return xReturn; -} -/*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/History.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/History.txt deleted file mode 100755 index ec66f0b..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/History.txt +++ /dev/null @@ -1,187 +0,0 @@ -Changes between 160919 and 180821 releases: - - + Multiple security improvements and fixes in packet parsing routines, DNS - caching, and TCP sequence number and ID generation. - + Disable NBNS and LLMNR by default. - + Add TCP hang protection by default. - - We thank Ori Karliner of Zimperium zLabs Team for reporting these issues. - - + Update FreeRTOS_gethostbyname() to allow an IP address to be passed in - - in which case it is just returned as a uint32_t. - + Introduce ipconfigSOCKET_HAS_USER_WAKE_CALLBACK to FreeRTOS_Sockets.c to - allow a user supposed callback function to be executed when socket events - occur in the same way that the socket semaphore is currently used. - + Update xNetworkBuffersInitialise() to ensure the semaphore created by the - function is not accessed until after the NULL check. - + Improve print messages output by the Win32 port layer version of - prvPrintAvailableNetworkInterfaces(). - -Changes between 160908 and 160919 releases: - - + Add a NULL check before attempting to close the DHCP socket. [Prior to - 160823 the IP task closed the DHCP socket by calling a public API function - - which checked for the socket being NULL. This was changed to call a - local private function, which did not have a NULL check, in place of the - public API function.] - + Various [internal only] naming changes to better comply with the FreeRTOS - naming conventions. - + Improvements to the Zynq network driver. DMA transmission buffers now use - a counting semaphore. When all TX-buffers are in-use, the IP-task will - block momentarily until a TX-buffer becomes available. - + Experimental implementation of the TCP window scaling protocol. The - scaling option will always be offered, at least with a factor 1. If the - TCP sliding window size becomes more than 64KB, the factor will increase - automatically. - + ipconfigETHERNET_MINIMUM_PACKET_BYTES is now applied for every protocol: - TCP, UDP, and ARP. - + Updated the Zynq project to use BufferAllocation_1.c rather than - BufferAllocation_2.c - which is a requirement with its current - configuration (due to the alignment requirements on the combined cache and - DMA configuration). - -Changes between 160823 and 160908 releases: - - + Use ipconfigZERO_COPY_TX_DRIVER as the xReleaseAfterSend() parameter where - prvTCPReturnPacket() is called in prvSendData() to prevent unnecessary - copying of data. - + Remove the use of the uxGetRxEventCount variable, which was used to give - priority to incoming messages, but could result in the IP task starving - application tasks of processing time. - -Changes between 160112 and 160823 releases - - NOTE: The 160908 release is a maintenance release for the 160112 single - interface labs release - not a release of the current development branch. - - + Various minor stability enhancements, including the ability to work with - configTICK_RATE_HZ set to less than 1KHz, closing DHCP sockets directly - rather than via FreeRTOS_closesocket(), and better handling of unknown - TCP packets before an IP address has been assigned. - + ipBUFFER_PADDING is now configurable through the ipconfigBUFFER_PADDING - constant to improve network buffer alignment handling capabilities (expert - users/driver writers only). - + Multiple improvements to the FTP server, including to how read only and - zero length files are handled. - + ipconfigFTP_HAS_USER_PROPERTIES_HOOK (to allow each user to have a - different root directory and access rights) and - ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK (to handle AJAX style data) - introduced, although these are not yet fully tested and the constant names - are likely to change. - + Introduce ipconfigHAS_TX_CRC_OFFLOADING. - + ipconfigUSE_DHCP_HOOK is now called ipconfigUSE_DHCP_HOOK, and the name - of the callback function has also changed. See the web documentation for - details. - + ipconfigTCP_RX_BUF_LEN is now ipconfigTCP_RX_BUFFER_LENGTH, and - ipconfigTCP_TX_BUF_LEN is now ipconfigTCP_TX_BUFFER_LENGTH, which is - actually how they have always been documented. - + Added example TFTP server capable of receiving (not sending) files. - Intended for bootloader type functionality. - + Various variable name changes for consistency (mainly ensuring UDP, TCP, - DNS, etc. always use the same case letters, and type prefixes are correct). - + Various minor edits to improve types used by internal variables. - + Simplified mapping of standard library functions to their Visual Studio - equivalents. - + Improve robustness of network drivers. - + Introduce pxResizeNetworkBufferWithDescriptor(). - + Removed obsolete FreeRTOSIPConfig.h constants from - FreeRTOSIPConfigDefaults.h. - + Added additional asserts() - predominantly to catch incorrect structure - packing. - -Changes between 160112 and 160111 releases - - + Updated the STM32 network driver so checksums are calculated by the - hardware. - + Implemented a simple "quit" command in the TCP command console. - -Changes between 150825 and 160111 releases - - + New device support: Demo applications and example drivers are provided - for Atmel SAM4E and ST STM32F4 microcontrollers. - + Various updates to improve compliance with the FreeRTOS coding standard. - + Added a command console example that uses TCP/IP for input and output (the - pre-existing command console example uses UDP/IP). - + Updated the UDP logging example so it will send log messages to the local - UDP broadcast address if a specific IP address is not provided. This - simplifies configuration, but note not all switches and routers will pass - broadcast messages. - + Add TCP echo client and TCP echo server examples to the Zynq demo. - + Minor updates to the Zynq network driver. - + Update the Zynq project to use version 2015.4 of the Xilinx SDK. - + Introduce FreeRTOS_SignalSocket(), which can be used to interrupt a task - that is blocked while reading from a socket ( FreeRTOS_recv[from] ). - + Make use of FreeRTOS_SignalSocket() in the FTP and HTTP servers. - + Major updates to the NTP client, although this is not included in any of - the pre-configured demo applications yet. - + Added support for DHCP zero pad option. - + Added uxGetMinimumIPQueueSpace(), a function to monitor the minimum amount - of space on the message queue. - + Better handling of zero length files in the FTP server. - + Fixed a bug reported by Andrey Ivanov from swissEmbedded that affects - users of 'ipconfigZERO_COPY_TX_DRIVER'. - - -Changes between 150825 150825 (?) - - + Added xApplicationDHCPUserHook() so a user defined hook will be - called at certain points in the DHCP process if - ipconfigDHCP_USES_USER_HOOK is set to 1. - + Added FreeRTOS_get_tx_head() to improve TCP zero copy behaviour - for - expert use only. - + RST is no longer sent if only the ACK flag is set. - + Previously, an immediate ACK was only sent when buffer space was - exhausted. Now, to improve performance, it is possible to send an - immediate ACK earlier - dependent on the ipconfigTCP_ACK_EARLIER_PACKET - setting. - + LLMNR and NBNS requests can now be sent to locate other devices - - previously these protocols would only be replied to, not generated. - + Added Auto-IP functionality (still in test) in case DHCP fails. Dependent - on the ipconfigDHCP_FALL_BACK_LINK_LAYER_ADDRESS and - ipconfigARP_USE_CLASH_DETECTION settings. - + Added NTP code and demo. - + FTP can now STOR and RETR zero-length files. - + Added LLMNR demo to Win32 demo - so now the Win32 responds to - "ping RTOSDemo". - -Changes between 141019 and 150825 - - + Added FTP server, which uses the new FreeRTOS+FAT component. - + Added basic HTTP server, which uses the new FreeRTOS+FAT component. - + Multiple definitions that are now common with FreeRTOS+FAT have been moved - into FreeRTOS's ProjDefs.h header file, and so prefixed with 'pd'. - + Introduced ipconfigZERO_COPY_TX_DRIVER, which defines who is responsible - for freeing a buffer sent to to the MAC driver for transmission, and - facilitates the development of zero copy drivers. - + Introduced the FREERTOS_MSG_DONTWAIT flag. The flag can be used as a - simpler and faster alternative to using FreeRTOS_setsockopt() to set the - send or receive timeout to 0. - + A few functions that were previously all lower case are now mixed case, as - lower case function names are only used when they are equivalent to a - a Berkeley sockets API function of the same name. - + Introduced uxGetMinimumFreeNetworkBuffers() to return the minimum number - of network buffers that have ever existed since the application started - executing. - + Introduce ipconfigETHERNET_MINIMUM_PACKET_BYTES to allow the application - writer to set their own minimum buffer size should the hardware not be - capable of padding under-sized Ethernet frames. - + vNetworkBufferRelease() renamed vReleaseNetworkBuffer() - just for - consistency with the names of other functions in the same file. - + Grouped DHCP status data into a structure. - + DHCP is now tried both with and without the broadcast flag. - + Replaced occurrences of configASSERT_VOID() with configASSERT(). - + ipconfigDNS_USE_CALLBACKS introduced to allow FreeRTOS_gethostbyname() to - be used without blocking. - + Fix: LLMNR and NBNS behaviour when the reply is in a larger buffer than the - request, and BufferAllocation_2 was used. - + Introduced ipMAX_IP_TASK_SLEEP_TIME to allow the application writer to - override the default value of 10 seconds. - + Fix: Correct error in *pxUDPPayloadBuffer_to_NetworkBuffer(). - + FreeRTOS_recv() now recognises the FREERTOS_ZERO_COPY flag, which, when - set, the void *pvBuffer parameter is interpreted as void **pvBuffer. - + FreeRTOS_listen() now returns an error code. Previously it always - returned 0. - + Fix: Previously if a listening socket was reused, and a connection - failed, the TCP/IP stack closed the socket, now the socket is correctly - left unclosed as it is owned by the application. - + Various other formatting and minor fix alterations. \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/LICENSE_INFORMATION.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/LICENSE_INFORMATION.txt deleted file mode 100755 index 04dc563..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/LICENSE_INFORMATION.txt +++ /dev/null @@ -1,19 +0,0 @@ -FreeRTOS+TCP is released under the following MIT license. - -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/ReadMe.url b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/ReadMe.url deleted file mode 100755 index 4174076..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/ReadMe.url +++ /dev/null @@ -1,5 +0,0 @@ -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 -[InternetShortcut] -URL=http://www.freertos.org/tcp -IDList= diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOSIPConfigDefaults.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOSIPConfigDefaults.h deleted file mode 100755 index f75efaa..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOSIPConfigDefaults.h +++ /dev/null @@ -1,560 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ - -#ifndef FREERTOS_DEFAULT_IP_CONFIG_H -#define FREERTOS_DEFAULT_IP_CONFIG_H - -/* The error numbers defined in this file will be moved to the core FreeRTOS -code in future versions of FreeRTOS - at which time the following header file -will be removed. */ -#include "FreeRTOS_errno_TCP.h" - -/* This file provides default values for configuration options that are missing -from the FreeRTOSIPConfig.h configuration header file. */ - - -/* Ensure defined configuration constants are using the most up to date naming. */ -#ifdef tcpconfigIP_TIME_TO_LIVE - #error now called: ipconfigTCP_TIME_TO_LIVE -#endif - -#ifdef updconfigIP_TIME_TO_LIVE - #error now called: ipconfigUDP_TIME_TO_LIVE -#endif - -#ifdef ipFILLER_SIZE - #error now called: ipconfigPACKET_FILLER_SIZE -#endif - -#ifdef dnsMAX_REQUEST_ATTEMPTS - #error now called: ipconfigDNS_REQUEST_ATTEMPTS -#endif - -#ifdef ipconfigUDP_TASK_PRIORITY - #error now called: ipconfigIP_TASK_PRIORITY -#endif - -#ifdef ipconfigUDP_TASK_STACK_SIZE_WORDS - #error now called: ipconfigIP_TASK_STACK_SIZE_WORDS -#endif - -#ifdef ipconfigDRIVER_INCLUDED_RX_IP_FILTERING - #error now called: ipconfigETHERNET_DRIVER_FILTERS_PACKETS -#endif - -#ifdef ipconfigMAX_SEND_BLOCK_TIME_TICKS - #error now called: ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS -#endif - -#ifdef ipconfigUSE_RECEIVE_CONNECT_CALLBACKS - #error now called: ipconfigUSE_CALLBACKS -#endif - -#ifdef ipconfigNUM_NETWORK_BUFFERS - #error now called: ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS -#endif - -#ifdef ipconfigTCP_HANG_PROT - #error now called: ipconfigTCP_HANG_PROTECTION -#endif - -#ifdef ipconfigTCP_HANG_PROT_TIME - #error now called: ipconfigTCP_HANG_PROTECTION_TIME -#endif - -#ifdef FreeRTOS_lprintf - #error now called: FreeRTOS_debug_printf -#endif - -#if ( ipconfigEVENT_QUEUE_LENGTH < ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 ) ) - #error The ipconfigEVENT_QUEUE_LENGTH parameter must be at least ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 -#endif - -#if ( ipconfigNETWORK_MTU < 46 ) - #error ipconfigNETWORK_MTU must be at least 46. -#endif - -#ifdef ipconfigBUFFER_ALLOC_FIXED_SIZE - #error ipconfigBUFFER_ALLOC_FIXED_SIZE was dropped and replaced by a const value, declared in BufferAllocation[12].c -#endif - -#ifdef ipconfigNIC_SEND_PASSES_DMA - #error now called: ipconfigZERO_COPY_TX_DRIVER -#endif - -#ifdef HAS_TX_CRC_OFFLOADING - /* _HT_ As these macro names have changed, throw an error - if they're still defined. */ - #error now called: ipconfigHAS_TX_CRC_OFFLOADING -#endif - -#ifdef HAS_RX_CRC_OFFLOADING - #error now called: ipconfigHAS_RX_CRC_OFFLOADING -#endif - -#ifdef ipconfigTCP_RX_BUF_LEN - #error ipconfigTCP_RX_BUF_LEN is now called ipconfigTCP_RX_BUFFER_LENGTH -#endif - -#ifdef ipconfigTCP_TX_BUF_LEN - #error ipconfigTCP_TX_BUF_LEN is now called ipconfigTCP_TX_BUFFER_LENGTH -#endif - -#ifdef ipconfigDHCP_USES_USER_HOOK - #error ipconfigDHCP_USES_USER_HOOK and its associated callback have been superceeded - see http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html#ipconfigUSE_DHCP_HOOK -#endif - -#ifndef ipconfigUSE_TCP - #define ipconfigUSE_TCP ( 1 ) -#endif - -#if ipconfigUSE_TCP - - /* Include support for TCP scaling windows */ - #ifndef ipconfigUSE_TCP_WIN - #define ipconfigUSE_TCP_WIN ( 1 ) - #endif - - #ifndef ipconfigTCP_WIN_SEG_COUNT - #define ipconfigTCP_WIN_SEG_COUNT ( 256 ) - #endif - - #ifndef ipconfigIGNORE_UNKNOWN_PACKETS - /* When non-zero, TCP will not send RST packets in reply to - TCP packets which are unknown, or out-of-order. */ - #define ipconfigIGNORE_UNKNOWN_PACKETS ( 0 ) - #endif -#endif - -/* - * For debuging/logging: check if the port number is used for telnet - * Some events will not be logged for telnet connections - * because it would produce logging about the transmission of the logging... - * This macro will only be used if FreeRTOS_debug_printf() is defined for logging - */ -#ifndef ipconfigTCP_MAY_LOG_PORT - #define ipconfigTCP_MAY_LOG_PORT(xPort) ( ( xPort ) != 23u ) -#endif - - -#ifndef ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME - #define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME portMAX_DELAY -#endif - -#ifndef ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME - #define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME portMAX_DELAY -#endif - -/* - * FreeRTOS debug logging routine (proposal) - * The macro will be called in the printf() style. Users can define - * their own logging routine as: - * - * #define FreeRTOS_debug_printf( MSG ) my_printf MSG - * - * The FreeRTOS_debug_printf() must be thread-safe but does not have to be - * interrupt-safe. - */ -#ifdef ipconfigHAS_DEBUG_PRINTF - #if( ipconfigHAS_DEBUG_PRINTF == 0 ) - #ifdef FreeRTOS_debug_printf - #error Do not define FreeRTOS_debug_print if ipconfigHAS_DEBUG_PRINTF is set to 0 - #endif /* ifdef FreeRTOS_debug_printf */ - #endif /* ( ipconfigHAS_DEBUG_PRINTF == 0 ) */ -#endif /* ifdef ipconfigHAS_DEBUG_PRINTF */ - -#ifndef FreeRTOS_debug_printf - #define FreeRTOS_debug_printf( MSG ) do{} while(0) - #define ipconfigHAS_DEBUG_PRINTF 0 -#endif - -/* - * FreeRTOS general logging routine (proposal) - * Used in some utility functions such as FreeRTOS_netstat() and FreeRTOS_PrintARPCache() - * - * #define FreeRTOS_printf( MSG ) my_printf MSG - * - * The FreeRTOS_printf() must be thread-safe but does not have to be interrupt-safe - */ -#ifdef ipconfigHAS_PRINTF - #if( ipconfigHAS_PRINTF == 0 ) - #ifdef FreeRTOS_printf - #error Do not define FreeRTOS_print if ipconfigHAS_PRINTF is set to 0 - #endif /* ifdef FreeRTOS_debug_printf */ - #endif /* ( ipconfigHAS_PRINTF == 0 ) */ -#endif /* ifdef ipconfigHAS_PRINTF */ - -#ifndef FreeRTOS_printf - #define FreeRTOS_printf( MSG ) do{} while(0) - #define ipconfigHAS_PRINTF 0 -#endif - -/* - * In cases where a lot of logging is produced, FreeRTOS_flush_logging( ) - * will be called to give the logging module a chance to flush the data - * An example of this is the netstat command, which produces many lines of logging - */ -#ifndef FreeRTOS_flush_logging - #define FreeRTOS_flush_logging( ) do{} while(0) -#endif - -/* Malloc functions. Within most applications of FreeRTOS, the couple - * pvPortMalloc()/vPortFree() will be used. - * If there is also SDRAM, the user may decide to use a different memory - * allocator: - * MallocLarge is used to allocate large TCP buffers (for Rx/Tx) - * MallocSocket is used to allocate the space for the sockets - */ -#ifndef pvPortMallocLarge - #define pvPortMallocLarge( x ) pvPortMalloc( x ) -#endif - -#ifndef vPortFreeLarge - #define vPortFreeLarge(ptr) vPortFree(ptr) -#endif - -#ifndef pvPortMallocSocket - #define pvPortMallocSocket( x ) pvPortMalloc( x ) -#endif - -#ifndef vPortFreeSocket - #define vPortFreeSocket(ptr) vPortFree(ptr) -#endif - -/* - * At several places within the library, random numbers are needed: - * - DHCP: For creating a DHCP transaction number - * - TCP: Set the Initial Sequence Number: this is the value of the first outgoing - * sequence number being used when connecting to a peer. - * Having a well randomised ISN is important to avoid spoofing - * - UDP/TCP: for setting the first port number to be used, in case a socket - * uses a 'random' or anonymous port number - */ -#ifndef ipconfigRAND32 - #define ipconfigRAND32() rand() -#endif -/* -------------------------------------------------------- - * End of: HT Added some macro defaults for the PLUS-UDP project - * -------------------------------------------------------- */ - -#ifndef ipconfigUSE_NETWORK_EVENT_HOOK - #define ipconfigUSE_NETWORK_EVENT_HOOK 0 -#endif - -#ifndef ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS - #define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( pdMS_TO_TICKS( 20 ) ) -#endif - -#ifndef ipconfigARP_CACHE_ENTRIES - #define ipconfigARP_CACHE_ENTRIES 10 -#endif - -#ifndef ipconfigMAX_ARP_RETRANSMISSIONS - #define ipconfigMAX_ARP_RETRANSMISSIONS ( 5u ) -#endif - -#ifndef ipconfigMAX_ARP_AGE - #define ipconfigMAX_ARP_AGE 150u -#endif - -#ifndef ipconfigUSE_ARP_REVERSED_LOOKUP - #define ipconfigUSE_ARP_REVERSED_LOOKUP 0 -#endif - -#ifndef ipconfigUSE_ARP_REMOVE_ENTRY - #define ipconfigUSE_ARP_REMOVE_ENTRY 0 -#endif - -#ifndef ipconfigINCLUDE_FULL_INET_ADDR - #define ipconfigINCLUDE_FULL_INET_ADDR 1 -#endif - -#ifndef ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS - #define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 45 -#endif - -#ifndef ipconfigEVENT_QUEUE_LENGTH - #define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 ) -#endif - -#ifndef ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND - #define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1 -#endif - -#ifndef ipconfigUDP_TIME_TO_LIVE - #define ipconfigUDP_TIME_TO_LIVE 128 -#endif - -#ifndef ipconfigTCP_TIME_TO_LIVE - #define ipconfigTCP_TIME_TO_LIVE 128 -#endif - -#ifndef ipconfigUDP_MAX_RX_PACKETS - /* Make postive to define the maximum number of packets which will be buffered - * for each UDP socket. - * Can be overridden with the socket option FREERTOS_SO_UDP_MAX_RX_PACKETS - */ - #define ipconfigUDP_MAX_RX_PACKETS 0u -#endif - -#ifndef ipconfigUSE_DHCP - #define ipconfigUSE_DHCP 1 -#endif - -#ifndef ipconfigUSE_DHCP_HOOK - #define ipconfigUSE_DHCP_HOOK 0 -#endif - -#ifndef ipconfigDHCP_FALL_BACK_AUTO_IP - /* - * Only applicable when DHCP is in use: - * If no DHCP server responds, use "Auto-IP" : the - * device will allocate a random LinkLayer IP address. - */ - #define ipconfigDHCP_FALL_BACK_AUTO_IP ( 0 ) -#endif - -#if( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 ) - #define ipconfigARP_USE_CLASH_DETECTION 1 -#endif - -#ifndef ipconfigARP_USE_CLASH_DETECTION - #define ipconfigARP_USE_CLASH_DETECTION 0 -#endif - -#ifndef ipconfigNETWORK_MTU - #define ipconfigNETWORK_MTU 1500 -#endif - -#ifndef ipconfigTCP_MSS - #define ipconfigTCP_MSS ( ipconfigNETWORK_MTU - ipSIZE_OF_IPv4_HEADER - ipSIZE_OF_TCP_HEADER ) -#endif - -/* Each TCP socket has circular stream buffers for Rx and Tx, which - * have a fixed maximum size. - * The defaults for these size are defined here, although - * they can be overridden at runtime by using the setsockopt() call */ -#ifndef ipconfigTCP_RX_BUFFER_LENGTH - #define ipconfigTCP_RX_BUFFER_LENGTH ( 4u * ipconfigTCP_MSS ) /* defaults to 5840 bytes */ -#endif - -/* Define the size of Tx stream buffer for TCP sockets */ -#ifndef ipconfigTCP_TX_BUFFER_LENGTH -# define ipconfigTCP_TX_BUFFER_LENGTH ( 4u * ipconfigTCP_MSS ) /* defaults to 5840 bytes */ -#endif - -#ifndef ipconfigMAXIMUM_DISCOVER_TX_PERIOD - #ifdef _WINDOWS_ - #define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( pdMS_TO_TICKS( 999 ) ) - #else - #define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( pdMS_TO_TICKS( 30000 ) ) - #endif /* _WINDOWS_ */ -#endif /* ipconfigMAXIMUM_DISCOVER_TX_PERIOD */ - -#ifndef ipconfigUSE_DNS - #define ipconfigUSE_DNS 1 -#endif - -#ifndef ipconfigDNS_REQUEST_ATTEMPTS - #define ipconfigDNS_REQUEST_ATTEMPTS 5 -#endif - -#ifndef ipconfigUSE_DNS_CACHE - #define ipconfigUSE_DNS_CACHE 0 -#endif - -#if( ipconfigUSE_DNS_CACHE != 0 ) - #ifndef ipconfigDNS_CACHE_NAME_LENGTH - /* Per https://tools.ietf.org/html/rfc1035, 253 is the maximum string length - of a DNS name. The following default accounts for a null terminator. */ - #define ipconfigDNS_CACHE_NAME_LENGTH 254 - #endif - - #ifndef ipconfigDNS_CACHE_ENTRIES - #define ipconfigDNS_CACHE_ENTRIES 1 - #endif -#endif /* ipconfigUSE_DNS_CACHE != 0 */ - -#ifndef ipconfigCHECK_IP_QUEUE_SPACE - #define ipconfigCHECK_IP_QUEUE_SPACE 0 -#endif - -#ifndef ipconfigUSE_LLMNR - /* Include support for LLMNR: Link-local Multicast Name Resolution (non-Microsoft) */ - #define ipconfigUSE_LLMNR ( 0 ) -#endif - -#if( !defined( ipconfigUSE_DNS ) ) - #if( ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) ) - /* LLMNR and NBNS depend on DNS because those protocols share a lot of code. */ - #error When either LLMNR or NBNS is used, ipconfigUSE_DNS must be defined - #endif -#endif - -#ifndef ipconfigREPLY_TO_INCOMING_PINGS - #define ipconfigREPLY_TO_INCOMING_PINGS 1 -#endif - -#ifndef ipconfigSUPPORT_OUTGOING_PINGS - #define ipconfigSUPPORT_OUTGOING_PINGS 0 -#endif - -#ifndef ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES - #define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1 -#endif - -#ifndef ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES - #define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1 -#endif - -#ifndef configINCLUDE_TRACE_RELATED_CLI_COMMANDS - #define ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS 0 -#else - #define ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS configINCLUDE_TRACE_RELATED_CLI_COMMANDS -#endif - -#ifndef ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM - #define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM ( 0 ) -#endif - -#ifndef ipconfigETHERNET_DRIVER_FILTERS_PACKETS - #define ipconfigETHERNET_DRIVER_FILTERS_PACKETS ( 0 ) -#endif - -#ifndef ipconfigWATCHDOG_TIMER - /* This macro will be called in every loop the IP-task makes. It may be - replaced by user-code that triggers a watchdog */ - #define ipconfigWATCHDOG_TIMER() -#endif - -#ifndef ipconfigUSE_CALLBACKS - #define ipconfigUSE_CALLBACKS ( 0 ) -#endif - -#if( ipconfigUSE_CALLBACKS != 0 ) - #ifndef ipconfigIS_VALID_PROG_ADDRESS - /* Replace this macro with a test returning non-zero if the memory pointer to by x - * is valid memory which can contain executable code - * In fact this is an extra safety measure: if a handler points to invalid memory, - * it will not be called - */ - #define ipconfigIS_VALID_PROG_ADDRESS(x) ( ( x ) != NULL ) - #endif -#endif - -#ifndef ipconfigHAS_INLINE_FUNCTIONS - #define ipconfigHAS_INLINE_FUNCTIONS ( 1 ) -#endif - -#ifndef portINLINE - #define portINLINE inline -#endif - -#ifndef ipconfigZERO_COPY_TX_DRIVER - /* When non-zero, the buffers passed to the SEND routine may be passed - to DMA. As soon as sending is ready, the buffers must be released by - calling vReleaseNetworkBufferAndDescriptor(), */ - #define ipconfigZERO_COPY_TX_DRIVER ( 0 ) -#endif - -#ifndef ipconfigZERO_COPY_RX_DRIVER - /* This define doesn't mean much to the driver, except that it makes - sure that pxPacketBuffer_to_NetworkBuffer() will be included. */ - #define ipconfigZERO_COPY_RX_DRIVER ( 0 ) -#endif - -#ifndef ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM - #define ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM 0 -#endif - -#ifndef ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM - #define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 0 -#endif - -#ifndef ipconfigDHCP_REGISTER_HOSTNAME - #define ipconfigDHCP_REGISTER_HOSTNAME 0 -#endif - -#ifndef ipconfigSOCKET_HAS_USER_SEMAPHORE - #define ipconfigSOCKET_HAS_USER_SEMAPHORE 0 -#endif - -#ifndef ipconfigSOCKET_HAS_USER_WAKE_CALLBACK - #define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK 0 -#endif - -#ifndef ipconfigSUPPORT_SELECT_FUNCTION - #define ipconfigSUPPORT_SELECT_FUNCTION 0 -#endif - -#ifndef ipconfigTCP_KEEP_ALIVE - #define ipconfigTCP_KEEP_ALIVE 0 -#endif - -#ifndef ipconfigDNS_USE_CALLBACKS - #define ipconfigDNS_USE_CALLBACKS 0 -#endif - -#ifndef ipconfigSUPPORT_SIGNALS - #define ipconfigSUPPORT_SIGNALS 0 -#endif - -#ifndef ipconfigUSE_NBNS - #define ipconfigUSE_NBNS 0 -#endif - -/* As an attack surface reduction for ports that listen for inbound -connections, hang protection can help reduce the impact of SYN floods. */ -#ifndef ipconfigTCP_HANG_PROTECTION - #define ipconfigTCP_HANG_PROTECTION 1 -#endif - -/* Non-activity timeout is expressed in seconds. */ -#ifndef ipconfigTCP_HANG_PROTECTION_TIME - #define ipconfigTCP_HANG_PROTECTION_TIME 30 -#endif - -#ifndef ipconfigTCP_IP_SANITY - #define ipconfigTCP_IP_SANITY 0 -#endif - -#ifndef ipconfigARP_STORES_REMOTE_ADDRESSES - #define ipconfigARP_STORES_REMOTE_ADDRESSES 0 -#endif - -#ifndef ipconfigBUFFER_PADDING - /* Expert option: define a value for 'ipBUFFER_PADDING'. - When 'ipconfigBUFFER_PADDING' equals 0, - 'ipBUFFER_PADDING' will get a default value of 8 + 2 bytes. */ - #define ipconfigBUFFER_PADDING 0 -#endif - -#ifndef ipconfigPACKET_FILLER_SIZE - #define ipconfigPACKET_FILLER_SIZE 2 -#endif - -#endif /* FREERTOS_DEFAULT_IP_CONFIG_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_ARP.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_ARP.h deleted file mode 100755 index 94d1cba..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_ARP.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -#ifndef FREERTOS_ARP_H -#define FREERTOS_ARP_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Application level configuration options. */ -#include "FreeRTOSIPConfig.h" -#include "FreeRTOSIPConfigDefaults.h" -#include "IPTraceMacroDefaults.h" - -/*-----------------------------------------------------------*/ -/* Miscellaneous structure and definitions. */ -/*-----------------------------------------------------------*/ - -typedef struct xARP_CACHE_TABLE_ROW -{ - uint32_t ulIPAddress; /* The IP address of an ARP cache entry. */ - MACAddress_t xMACAddress; /* The MAC address of an ARP cache entry. */ - uint8_t ucAge; /* A value that is periodically decremented but can also be refreshed by active communication. The ARP cache entry is removed if the value reaches zero. */ - uint8_t ucValid; /* pdTRUE: xMACAddress is valid, pdFALSE: waiting for ARP reply */ -} ARPCacheRow_t; - -typedef enum -{ - eARPCacheMiss = 0, /* 0 An ARP table lookup did not find a valid entry. */ - eARPCacheHit, /* 1 An ARP table lookup found a valid entry. */ - eCantSendPacket /* 2 There is no IP address, or an ARP is still in progress, so the packet cannot be sent. */ -} eARPLookupResult_t; - -typedef enum -{ - eNotFragment = 0, /* The IP packet being sent is not part of a fragment. */ - eFirstFragment, /* The IP packet being sent is the first in a set of fragmented packets. */ - eFollowingFragment /* The IP packet being sent is part of a set of fragmented packets. */ -} eIPFragmentStatus_t; - -/* - * If ulIPAddress is already in the ARP cache table then reset the age of the - * entry back to its maximum value. If ulIPAddress is not already in the ARP - * cache table then add it - replacing the oldest current entry if there is not - * a free space available. - */ -void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, const uint32_t ulIPAddress ); - -#if( ipconfigARP_USE_CLASH_DETECTION != 0 ) - /* Becomes non-zero if another device responded to a gratuitos ARP message. */ - extern BaseType_t xARPHadIPClash; - /* MAC-address of the other device containing the same IP-address. */ - extern MACAddress_t xARPClashMacAddress; -#endif /* ipconfigARP_USE_CLASH_DETECTION */ - -#if( ipconfigUSE_ARP_REMOVE_ENTRY != 0 ) - - /* - * In some rare cases, it might be useful to remove a ARP cache entry of a - * known MAC address to make sure it gets refreshed. - */ - uint32_t ulARPRemoveCacheEntryByMac( const MACAddress_t * pxMACAddress ); - -#endif /* ipconfigUSE_ARP_REMOVE_ENTRY != 0 */ - -/* - * Look for ulIPAddress in the ARP cache. If the IP address exists, copy the - * associated MAC address into pxMACAddress, refresh the ARP cache entry's - * age, and return eARPCacheHit. If the IP address does not exist in the ARP - * cache return eARPCacheMiss. If the packet cannot be sent for any reason - * (maybe DHCP is still in process, or the addressing needs a gateway but there - * isn't a gateway defined) then return eCantSendPacket. - */ -eARPLookupResult_t eARPGetCacheEntry( uint32_t *pulIPAddress, MACAddress_t * const pxMACAddress ); - -#if( ipconfigUSE_ARP_REVERSED_LOOKUP != 0 ) - - /* Lookup an IP-address if only the MAC-address is known */ - eARPLookupResult_t eARPGetCacheEntryByMac( MACAddress_t * const pxMACAddress, uint32_t *pulIPAddress ); - -#endif -/* - * Reduce the age count in each entry within the ARP cache. An entry is no - * longer considered valid and is deleted if its age reaches zero. - */ -void vARPAgeCache( void ); - -/* - * Send out an ARP request for the IP address contained in pxNetworkBuffer, and - * add an entry into the ARP table that indicates that an ARP reply is - * outstanding so re-transmissions can be generated. - */ -void vARPGenerateRequestPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer ); - -/* - * After DHCP is ready and when changing IP address, force a quick send of our new IP - * address - */ -void vARPSendGratuitous( void ); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif /* FREERTOS_ARP_H */ - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_DHCP.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_DHCP.h deleted file mode 100755 index 04d151f..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_DHCP.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -#ifndef FREERTOS_DHCP_H -#define FREERTOS_DHCP_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Application level configuration options. */ -#include "FreeRTOSIPConfig.h" -#include "IPTraceMacroDefaults.h" - -/* Used in the DHCP callback if ipconfigUSE_DHCP_HOOK is set to 1. */ -typedef enum eDHCP_PHASE -{ - eDHCPPhasePreDiscover, /* Driver is about to send a DHCP discovery. */ - eDHCPPhasePreRequest, /* Driver is about to request DHCP an IP address. */ -#if( ipconfigDHCP_SEND_DISCOVER_AFTER_AUTO_IP != 0 ) - eDHCPPhasePreLLA, /* Driver is about to try get an LLA address */ -#endif /* ipconfigDHCP_SEND_DISCOVER_AFTER_AUTO_IP */ -} eDHCPCallbackPhase_t; - -/* Used in the DHCP callback if ipconfigUSE_DHCP_HOOK is set to 1. */ -typedef enum eDHCP_ANSWERS -{ - eDHCPContinue, /* Continue the DHCP process */ - eDHCPUseDefaults, /* Stop DHCP and use the static defaults. */ - eDHCPStopNoChanges, /* Stop DHCP and continue with current settings. */ -} eDHCPCallbackAnswer_t; - -/* - * NOT A PUBLIC API FUNCTION. - */ -void vDHCPProcess( BaseType_t xReset ); - -/* Internal call: returns true if socket is the current DHCP socket */ -BaseType_t xIsDHCPSocket( Socket_t xSocket ); - -/* Prototype of the hook (or callback) function that must be provided by the -application if ipconfigUSE_DHCP_HOOK is set to 1. See the following URL for -usage information: -http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html#ipconfigUSE_DHCP_HOOK -*/ -eDHCPCallbackAnswer_t xApplicationDHCPHook( eDHCPCallbackPhase_t eDHCPPhase, uint32_t ulIPAddress ); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* FREERTOS_DHCP_H */ - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_DNS.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_DNS.h deleted file mode 100755 index 92e27a2..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_DNS.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -#ifndef FREERTOS_DNS_H -#define FREERTOS_DNS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Application level configuration options. */ -#include "FreeRTOSIPConfig.h" -#include "IPTraceMacroDefaults.h" - - -/* The Link-local Multicast Name Resolution (LLMNR) - * is included. - * Note that a special MAC address is required in addition to the NIC's actual - * MAC address: 01:00:5E:00:00:FC - * - * The target IP address will be 224.0.0.252 - */ -#if( ipconfigBYTE_ORDER == pdFREERTOS_BIG_ENDIAN ) - #define ipLLMNR_IP_ADDR 0xE00000FC -#else - #define ipLLMNR_IP_ADDR 0xFC0000E0 -#endif /* ipconfigBYTE_ORDER == pdFREERTOS_BIG_ENDIAN */ - -#define ipLLMNR_PORT 5355 /* Standard LLMNR port. */ -#define ipDNS_PORT 53 /* Standard DNS port. */ -#define ipDHCP_CLIENT 67 -#define ipDHCP_SERVER 68 -#define ipNBNS_PORT 137 /* NetBIOS Name Service. */ -#define ipNBDGM_PORT 138 /* Datagram Service, not included. */ - -/* - * The following function should be provided by the user and return true if it - * matches the domain name. - */ -extern BaseType_t xApplicationDNSQueryHook( const char *pcName ); - -/* - * LLMNR is very similar to DNS, so is handled by the DNS routines. - */ -uint32_t ulDNSHandlePacket( NetworkBufferDescriptor_t *pxNetworkBuffer ); - -#if( ipconfigUSE_LLMNR == 1 ) - extern const MACAddress_t xLLMNR_MacAdress; -#endif /* ipconfigUSE_LLMNR */ - -#if( ipconfigUSE_NBNS != 0 ) - - /* - * Inspect a NetBIOS Names-Service message. If the name matches with ours - * (xApplicationDNSQueryHook returns true) an answer will be sent back. - * Note that LLMNR is a better protocol for name services on a LAN as it is - * less polluted - */ - uint32_t ulNBNSHandlePacket (NetworkBufferDescriptor_t *pxNetworkBuffer ); - -#endif /* ipconfigUSE_NBNS */ - -#if( ipconfigUSE_DNS_CACHE != 0 ) - - uint32_t FreeRTOS_dnslookup( const char *pcHostName ); - -#endif /* ipconfigUSE_DNS_CACHE != 0 */ - -#if( ipconfigDNS_USE_CALLBACKS != 0 ) - - /* - * Users may define this type of function as a callback. - * It will be called when a DNS reply is received or when a timeout has been reached. - */ - typedef void (* FOnDNSEvent ) ( const char * /* pcName */, void * /* pvSearchID */, uint32_t /* ulIPAddress */ ); - - /* - * Asynchronous version of gethostbyname() - * xTimeout is in units of ms. - */ - uint32_t FreeRTOS_gethostbyname_a( const char *pcHostName, FOnDNSEvent pCallback, void *pvSearchID, TickType_t xTimeout ); - void FreeRTOS_gethostbyname_cancel( void *pvSearchID ); - -#endif - -/* - * FULL, UP-TO-DATE AND MAINTAINED REFERENCE DOCUMENTATION FOR ALL THESE - * FUNCTIONS IS AVAILABLE ON THE FOLLOWING URL: - * _TBD_ Add URL - */ -uint32_t FreeRTOS_gethostbyname( const char *pcHostName ); - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* FREERTOS_DNS_H */ - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_IP.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_IP.h deleted file mode 100755 index 28b23a5..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_IP.h +++ /dev/null @@ -1,328 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -#ifndef FREERTOS_IP_H -#define FREERTOS_IP_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Application level configuration options. */ -#include "FreeRTOSIPConfig.h" -#include "FreeRTOSIPConfigDefaults.h" -#include "IPTraceMacroDefaults.h" - -/* Some constants defining the sizes of several parts of a packet */ -#define ipSIZE_OF_ETH_HEADER 14u -#define ipSIZE_OF_IPv4_HEADER 20u -#define ipSIZE_OF_IGMP_HEADER 8u -#define ipSIZE_OF_ICMP_HEADER 8u -#define ipSIZE_OF_UDP_HEADER 8u -#define ipSIZE_OF_TCP_HEADER 20u - - -/* The number of octets in the MAC and IP addresses respectively. */ -#define ipMAC_ADDRESS_LENGTH_BYTES ( 6 ) -#define ipIP_ADDRESS_LENGTH_BYTES ( 4 ) - -/* IP protocol definitions. */ -#define ipPROTOCOL_ICMP ( 1 ) -#define ipPROTOCOL_IGMP ( 2 ) -#define ipPROTOCOL_TCP ( 6 ) -#define ipPROTOCOL_UDP ( 17 ) - -/* Dimensions the buffers that are filled by received Ethernet frames. */ -#define ipSIZE_OF_ETH_CRC_BYTES ( 4UL ) -#define ipSIZE_OF_ETH_OPTIONAL_802_1Q_TAG_BYTES ( 4UL ) -#define ipTOTAL_ETHERNET_FRAME_SIZE ( ( ( uint32_t ) ipconfigNETWORK_MTU ) + ( ( uint32_t ) ipSIZE_OF_ETH_HEADER ) + ipSIZE_OF_ETH_CRC_BYTES + ipSIZE_OF_ETH_OPTIONAL_802_1Q_TAG_BYTES ) - -/*_RB_ Comment may need updating. */ -/* Space left at the beginning of a network buffer storage area to store a -pointer back to the network buffer. Should be a multiple of 8 to ensure 8 byte -alignment is maintained on architectures that require it. - -In order to get a 32-bit alignment of network packets, an offset of 2 bytes -would be desirable, as defined by ipconfigPACKET_FILLER_SIZE. So the malloc'd -buffer will have the following contents: - uint32_t pointer; // word-aligned - uchar_8 filler[6]; - << ETH-header >> // half-word-aligned - uchar_8 dest[6]; // start of pucEthernetBuffer - uchar_8 dest[6]; - uchar16_t type; - << IP-header >> // word-aligned - uint8_t ucVersionHeaderLength; - etc - */ -#if( ipconfigBUFFER_PADDING != 0 ) - #define ipBUFFER_PADDING ipconfigBUFFER_PADDING -#else - #define ipBUFFER_PADDING ( 8u + ipconfigPACKET_FILLER_SIZE ) -#endif - -/* The structure used to store buffers and pass them around the network stack. -Buffers can be in use by the stack, in use by the network interface hardware -driver, or free (not in use). */ -typedef struct xNETWORK_BUFFER -{ - ListItem_t xBufferListItem; /* Used to reference the buffer form the free buffer list or a socket. */ - uint32_t ulIPAddress; /* Source or destination IP address, depending on usage scenario. */ - uint8_t *pucEthernetBuffer; /* Pointer to the start of the Ethernet frame. */ - size_t xDataLength; /* Starts by holding the total Ethernet frame length, then the UDP/TCP payload length. */ - uint16_t usPort; /* Source or destination port, depending on usage scenario. */ - uint16_t usBoundPort; /* The port to which a transmitting socket is bound. */ - #if( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) - struct xNETWORK_BUFFER *pxNextBuffer; /* Possible optimisation for expert users - requires network driver support. */ - #endif -} NetworkBufferDescriptor_t; - -#include "pack_struct_start.h" -struct xMAC_ADDRESS -{ - uint8_t ucBytes[ ipMAC_ADDRESS_LENGTH_BYTES ]; -} -#include "pack_struct_end.h" - -typedef struct xMAC_ADDRESS MACAddress_t; - -typedef enum eNETWORK_EVENTS -{ - eNetworkUp, /* The network is configured. */ - eNetworkDown /* The network connection has been lost. */ -} eIPCallbackEvent_t; - -typedef enum ePING_REPLY_STATUS -{ - eSuccess = 0, /* A correct reply has been received for an outgoing ping. */ - eInvalidChecksum, /* A reply was received for an outgoing ping but the checksum of the reply was incorrect. */ - eInvalidData /* A reply was received to an outgoing ping but the payload of the reply was not correct. */ -} ePingReplyStatus_t; - -typedef enum eNETWORK_ADDRESS_TYPE -{ - eNetWorkAddressTypeIPV4, - eNetWorkAddressTypeIPV6, - eNetWorkAddressTypeHostName -} eNetWorkAddressType_t; - -/* Endian related definitions. */ -#if( ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN ) - - /* FreeRTOS_htons / FreeRTOS_htonl: some platforms might have built-in versions - using a single instruction so allow these versions to be overridden. */ - #ifndef FreeRTOS_htons - #define FreeRTOS_htons( usIn ) ( (uint16_t) ( ( ( usIn ) << 8U ) | ( ( usIn ) >> 8U ) ) ) - #endif - - #ifndef FreeRTOS_htonl - #define FreeRTOS_htonl( ulIn ) \ - ( \ - ( uint32_t ) \ - ( \ - ( ( ( ( uint32_t ) ( ulIn ) ) ) << 24 ) | \ - ( ( ( ( uint32_t ) ( ulIn ) ) & 0x0000ff00UL ) << 8 ) | \ - ( ( ( ( uint32_t ) ( ulIn ) ) & 0x00ff0000UL ) >> 8 ) | \ - ( ( ( ( uint32_t ) ( ulIn ) ) ) >> 24 ) \ - ) \ - ) - #endif - -#else /* ipconfigBYTE_ORDER */ - - #define FreeRTOS_htons( x ) ( ( uint16_t ) ( x ) ) - #define FreeRTOS_htonl( x ) ( ( uint32_t ) ( x ) ) - -#endif /* ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN */ - -#define FreeRTOS_ntohs( x ) FreeRTOS_htons( x ) -#define FreeRTOS_ntohl( x ) FreeRTOS_htonl( x ) - -#if( ipconfigHAS_INLINE_FUNCTIONS == 1 ) - - static portINLINE int32_t FreeRTOS_max_int32 (int32_t a, int32_t b); - static portINLINE uint32_t FreeRTOS_max_uint32 (uint32_t a, uint32_t b); - static portINLINE int32_t FreeRTOS_min_int32 (int32_t a, int32_t b); - static portINLINE uint32_t FreeRTOS_min_uint32 (uint32_t a, uint32_t b); - static portINLINE uint32_t FreeRTOS_round_up (uint32_t a, uint32_t d); - static portINLINE uint32_t FreeRTOS_round_down (uint32_t a, uint32_t d); - static portINLINE BaseType_t FreeRTOS_min_BaseType (BaseType_t a, BaseType_t b); - static portINLINE BaseType_t FreeRTOS_max_BaseType (BaseType_t a, BaseType_t b); - static portINLINE UBaseType_t FreeRTOS_max_UBaseType (UBaseType_t a, UBaseType_t b); - static portINLINE UBaseType_t FreeRTOS_min_UBaseType (UBaseType_t a, UBaseType_t b); - - - static portINLINE int32_t FreeRTOS_max_int32 (int32_t a, int32_t b) { return a >= b ? a : b; } - static portINLINE uint32_t FreeRTOS_max_uint32 (uint32_t a, uint32_t b) { return a >= b ? a : b; } - static portINLINE int32_t FreeRTOS_min_int32 (int32_t a, int32_t b) { return a <= b ? a : b; } - static portINLINE uint32_t FreeRTOS_min_uint32 (uint32_t a, uint32_t b) { return a <= b ? a : b; } - static portINLINE uint32_t FreeRTOS_round_up (uint32_t a, uint32_t d) { return d * ( ( a + d - 1u ) / d ); } - static portINLINE uint32_t FreeRTOS_round_down (uint32_t a, uint32_t d) { return d * ( a / d ); } - - static portINLINE BaseType_t FreeRTOS_max_BaseType (BaseType_t a, BaseType_t b) { return a >= b ? a : b; } - static portINLINE UBaseType_t FreeRTOS_max_UBaseType (UBaseType_t a, UBaseType_t b) { return a >= b ? a : b; } - static portINLINE BaseType_t FreeRTOS_min_BaseType (BaseType_t a, BaseType_t b) { return a <= b ? a : b; } - static portINLINE UBaseType_t FreeRTOS_min_UBaseType (UBaseType_t a, UBaseType_t b) { return a <= b ? a : b; } - -#else - - #define FreeRTOS_max_int32(a,b) ( ( ( int32_t ) ( a ) ) >= ( ( int32_t ) ( b ) ) ? ( ( int32_t ) ( a ) ) : ( ( int32_t ) ( b ) ) ) - #define FreeRTOS_max_uint32(a,b) ( ( ( uint32_t ) ( a ) ) >= ( ( uint32_t ) ( b ) ) ? ( ( uint32_t ) ( a ) ) : ( ( uint32_t ) ( b ) ) ) - - #define FreeRTOS_min_int32(a,b) ( ( ( int32_t ) a ) <= ( ( int32_t ) b ) ? ( ( int32_t ) a ) : ( ( int32_t ) b ) ) - #define FreeRTOS_min_uint32(a,b) ( ( ( uint32_t ) a ) <= ( ( uint32_t ) b ) ? ( ( uint32_t ) a ) : ( ( uint32_t ) b ) ) - - /* Round-up: a = d * ( ( a + d - 1 ) / d ) */ - #define FreeRTOS_round_up(a,d) ( ( ( uint32_t ) ( d ) ) * ( ( ( ( uint32_t ) ( a ) ) + ( ( uint32_t ) ( d ) ) - 1UL ) / ( ( uint32_t ) ( d ) ) ) ) - #define FreeRTOS_round_down(a,d) ( ( ( uint32_t ) ( d ) ) * ( ( ( uint32_t ) ( a ) ) / ( ( uint32_t ) ( d ) ) ) ) - - #define FreeRTOS_ms_to_tick(ms) ( ( ms * configTICK_RATE_HZ + 500 ) / 1000 ) - - #define FreeRTOS_max_BaseType(a, b) ( ( ( BaseType_t ) ( a ) ) >= ( ( BaseType_t ) ( b ) ) ? ( ( BaseType_t ) ( a ) ) : ( ( BaseType_t ) ( b ) ) ) - #define FreeRTOS_max_UBaseType(a, b) ( ( ( UBaseType_t ) ( a ) ) >= ( ( UBaseType_t ) ( b ) ) ? ( ( UBaseType_t ) ( a ) ) : ( ( UBaseType_t ) ( b ) ) ) - #define FreeRTOS_min_BaseType(a, b) ( ( ( BaseType_t ) ( a ) ) <= ( ( BaseType_t ) ( b ) ) ? ( ( BaseType_t ) ( a ) ) : ( ( BaseType_t ) ( b ) ) ) - #define FreeRTOS_min_UBaseType(a, b) ( ( ( UBaseType_t ) ( a ) ) <= ( ( UBaseType_t ) ( b ) ) ? ( ( UBaseType_t ) ( a ) ) : ( ( UBaseType_t ) ( b ) ) ) - -#endif /* ipconfigHAS_INLINE_FUNCTIONS */ - -#define pdMS_TO_MIN_TICKS( xTimeInMs ) ( pdMS_TO_TICKS( ( xTimeInMs ) ) < ( ( TickType_t ) 1 ) ? ( ( TickType_t ) 1 ) : pdMS_TO_TICKS( ( xTimeInMs ) ) ) - -#ifndef pdTRUE_SIGNED - /* Temporary solution: eventually the defines below will appear in 'Source\include\projdefs.h' */ - #define pdTRUE_SIGNED pdTRUE - #define pdFALSE_SIGNED pdFALSE - #define pdTRUE_UNSIGNED ( ( UBaseType_t ) 1u ) - #define pdFALSE_UNSIGNED ( ( UBaseType_t ) 0u ) -#endif - -/* - * FULL, UP-TO-DATE AND MAINTAINED REFERENCE DOCUMENTATION FOR ALL THESE - * FUNCTIONS IS AVAILABLE ON THE FOLLOWING URL: - * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/FreeRTOS_TCP_API_Functions.html - */ -BaseType_t FreeRTOS_IPInit( const uint8_t ucIPAddress[ ipIP_ADDRESS_LENGTH_BYTES ], - const uint8_t ucNetMask[ ipIP_ADDRESS_LENGTH_BYTES ], - const uint8_t ucGatewayAddress[ ipIP_ADDRESS_LENGTH_BYTES ], - const uint8_t ucDNSServerAddress[ ipIP_ADDRESS_LENGTH_BYTES ], - const uint8_t ucMACAddress[ ipMAC_ADDRESS_LENGTH_BYTES ] ); - -void * FreeRTOS_GetUDPPayloadBuffer( size_t xRequestedSizeBytes, TickType_t xBlockTimeTicks ); -void FreeRTOS_GetAddressConfiguration( uint32_t *pulIPAddress, uint32_t *pulNetMask, uint32_t *pulGatewayAddress, uint32_t *pulDNSServerAddress ); -void FreeRTOS_SetAddressConfiguration( const uint32_t *pulIPAddress, const uint32_t *pulNetMask, const uint32_t *pulGatewayAddress, const uint32_t *pulDNSServerAddress ); -BaseType_t FreeRTOS_SendPingRequest( uint32_t ulIPAddress, size_t xNumberOfBytesToSend, TickType_t xBlockTimeTicks ); -void FreeRTOS_ReleaseUDPPayloadBuffer( void *pvBuffer ); -const uint8_t * FreeRTOS_GetMACAddress( void ); -void FreeRTOS_UpdateMACAddress( const uint8_t ucMACAddress[ipMAC_ADDRESS_LENGTH_BYTES] ); -void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent ); -void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifier ); -uint32_t FreeRTOS_GetIPAddress( void ); -void FreeRTOS_SetIPAddress( uint32_t ulIPAddress ); -void FreeRTOS_SetNetmask( uint32_t ulNetmask ); -void FreeRTOS_SetGatewayAddress( uint32_t ulGatewayAddress ); -uint32_t FreeRTOS_GetGatewayAddress( void ); -uint32_t FreeRTOS_GetDNSServerAddress( void ); -uint32_t FreeRTOS_GetNetmask( void ); -void FreeRTOS_OutputARPRequest( uint32_t ulIPAddress ); -BaseType_t FreeRTOS_IsNetworkUp( void ); - -#if( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - UBaseType_t uxGetMinimumIPQueueSpace( void ); -#endif - -/* - * Defined in FreeRTOS_Sockets.c - * //_RB_ Don't think this comment is correct. If this is for internal use only it should appear after all the public API functions and not start with FreeRTOS_. - * Socket has had activity, reset the timer so it will not be closed - * because of inactivity - */ -const char *FreeRTOS_GetTCPStateName( UBaseType_t ulState); - -/* _HT_ Temporary: show all valid ARP entries - */ -void FreeRTOS_PrintARPCache( void ); -void FreeRTOS_ClearARP( void ); - -#if( ipconfigDHCP_REGISTER_HOSTNAME == 1 ) - - /* DHCP has an option for clients to register their hostname. It doesn't - have much use, except that a device can be found in a router along with its - name. If this option is used the callback below must be provided by the - application writer to return a const string, denoting the device's name. */ - const char *pcApplicationHostnameHook( void ); - -#endif /* ipconfigDHCP_REGISTER_HOSTNAME */ - - -/* For backward compatibility define old structure names to the newer equivalent -structure name. */ -#ifndef ipconfigENABLE_BACKWARD_COMPATIBILITY - #define ipconfigENABLE_BACKWARD_COMPATIBILITY 1 -#endif - -#if( ipconfigENABLE_BACKWARD_COMPATIBILITY == 1 ) - #define xIPStackEvent_t IPStackEvent_t - #define xNetworkBufferDescriptor_t NetworkBufferDescriptor_t - #define xMACAddress_t MACAddress_t - #define xWinProperties_t WinProperties_t - #define xSocket_t Socket_t - #define xSocketSet_t SocketSet_t - #define ipSIZE_OF_IP_HEADER ipSIZE_OF_IPv4_HEADER - - /* Since August 2016, the public types and fields below have changed name: - abbreviations TCP/UDP are now written in capitals, and type names now end with "_t". */ - #define FOnConnected FOnConnected_t - #define FOnTcpReceive FOnTCPReceive_t - #define FOnTcpSent FOnTCPSent_t - #define FOnUdpReceive FOnUDPReceive_t - #define FOnUdpSent FOnUDPSent_t - - #define pOnTcpConnected pxOnTCPConnected - #define pOnTcpReceive pxOnTCPReceive - #define pOnTcpSent pxOnTCPSent - #define pOnUdpReceive pxOnUDPReceive - #define pOnUdpSent pxOnUDPSent - - #define FOnUdpSent FOnUDPSent_t - #define FOnTcpSent FOnTCPSent_t -#endif /* ipconfigENABLE_BACKWARD_COMPATIBILITY */ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* FREERTOS_IP_H */ - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_IP_Private.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_IP_Private.h deleted file mode 100755 index 3bcac62..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_IP_Private.h +++ /dev/null @@ -1,827 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -#ifndef FREERTOS_IP_PRIVATE_H -#define FREERTOS_IP_PRIVATE_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Application level configuration options. */ -#include "FreeRTOSIPConfig.h" -#include "FreeRTOSIPConfigDefaults.h" -#include "FreeRTOS_Sockets.h" -#include "IPTraceMacroDefaults.h" -#include "FreeRTOS_Stream_Buffer.h" -#if( ipconfigUSE_TCP == 1 ) - #include "FreeRTOS_TCP_WIN.h" - #include "FreeRTOS_TCP_IP.h" -#endif - -#include "event_groups.h" - -typedef struct xNetworkAddressingParameters -{ - uint32_t ulDefaultIPAddress; - uint32_t ulNetMask; - uint32_t ulGatewayAddress; - uint32_t ulDNSServerAddress; - uint32_t ulBroadcastAddress; -} NetworkAddressingParameters_t; - -extern BaseType_t xTCPWindowLoggingLevel; - -/*-----------------------------------------------------------*/ -/* Protocol headers. */ -/*-----------------------------------------------------------*/ - -#include "pack_struct_start.h" -struct xETH_HEADER -{ - MACAddress_t xDestinationAddress; /* 0 + 6 = 6 */ - MACAddress_t xSourceAddress; /* 6 + 6 = 12 */ - uint16_t usFrameType; /* 12 + 2 = 14 */ -} -#include "pack_struct_end.h" -typedef struct xETH_HEADER EthernetHeader_t; - -#include "pack_struct_start.h" -struct xARP_HEADER -{ - uint16_t usHardwareType; /* 0 + 2 = 2 */ - uint16_t usProtocolType; /* 2 + 2 = 4 */ - uint8_t ucHardwareAddressLength; /* 4 + 1 = 5 */ - uint8_t ucProtocolAddressLength; /* 5 + 1 = 6 */ - uint16_t usOperation; /* 6 + 2 = 8 */ - MACAddress_t xSenderHardwareAddress; /* 8 + 6 = 14 */ - uint8_t ucSenderProtocolAddress[ 4 ]; /* 14 + 4 = 18 */ - MACAddress_t xTargetHardwareAddress; /* 18 + 6 = 24 */ - uint32_t ulTargetProtocolAddress; /* 24 + 4 = 28 */ -} -#include "pack_struct_end.h" -typedef struct xARP_HEADER ARPHeader_t; - -#include "pack_struct_start.h" -struct xIP_HEADER -{ - uint8_t ucVersionHeaderLength; /* 0 + 1 = 1 */ - uint8_t ucDifferentiatedServicesCode; /* 1 + 1 = 2 */ - uint16_t usLength; /* 2 + 2 = 4 */ - uint16_t usIdentification; /* 4 + 2 = 6 */ - uint16_t usFragmentOffset; /* 6 + 2 = 8 */ - uint8_t ucTimeToLive; /* 8 + 1 = 9 */ - uint8_t ucProtocol; /* 9 + 1 = 10 */ - uint16_t usHeaderChecksum; /* 10 + 2 = 12 */ - uint32_t ulSourceIPAddress; /* 12 + 4 = 16 */ - uint32_t ulDestinationIPAddress; /* 16 + 4 = 20 */ -} -#include "pack_struct_end.h" -typedef struct xIP_HEADER IPHeader_t; - -#include "pack_struct_start.h" -struct xIGMP_HEADER -{ - uint8_t ucVersionType; /* 0 + 1 = 1 */ - uint8_t ucMaxResponseTime; /* 1 + 1 = 2 */ - uint16_t usChecksum; /* 2 + 2 = 4 */ - uint32_t usGroupAddress; /* 4 + 4 = 8 */ -} -#include "pack_struct_end.h" -typedef struct xIGMP_HEADER IGMPHeader_t; - -#include "pack_struct_start.h" -struct xICMP_HEADER -{ - uint8_t ucTypeOfMessage; /* 0 + 1 = 1 */ - uint8_t ucTypeOfService; /* 1 + 1 = 2 */ - uint16_t usChecksum; /* 2 + 2 = 4 */ - uint16_t usIdentifier; /* 4 + 2 = 6 */ - uint16_t usSequenceNumber; /* 6 + 2 = 8 */ -} -#include "pack_struct_end.h" -typedef struct xICMP_HEADER ICMPHeader_t; - -#include "pack_struct_start.h" -struct xUDP_HEADER -{ - uint16_t usSourcePort; /* 0 + 2 = 2 */ - uint16_t usDestinationPort; /* 2 + 2 = 4 */ - uint16_t usLength; /* 4 + 2 = 6 */ - uint16_t usChecksum; /* 6 + 2 = 8 */ -} -#include "pack_struct_end.h" -typedef struct xUDP_HEADER UDPHeader_t; - -#include "pack_struct_start.h" -struct xTCP_HEADER -{ - uint16_t usSourcePort; /* + 2 = 2 */ - uint16_t usDestinationPort; /* + 2 = 4 */ - uint32_t ulSequenceNumber; /* + 4 = 8 */ - uint32_t ulAckNr; /* + 4 = 12 */ - uint8_t ucTCPOffset; /* + 1 = 13 */ - uint8_t ucTCPFlags; /* + 1 = 14 */ - uint16_t usWindow; /* + 2 = 15 */ - uint16_t usChecksum; /* + 2 = 18 */ - uint16_t usUrgent; /* + 2 = 20 */ -#if ipconfigUSE_TCP == 1 - /* the option data is not a part of the TCP header */ - uint8_t ucOptdata[ipSIZE_TCP_OPTIONS]; /* + 12 = 32 */ -#endif -} -#include "pack_struct_end.h" -typedef struct xTCP_HEADER TCPHeader_t; - -#include "pack_struct_start.h" -struct xPSEUDO_HEADER -{ - uint32_t ulSourceAddress; - uint32_t ulDestinationAddress; - uint8_t ucZeros; - uint8_t ucProtocol; - uint16_t usUDPLength; -} -#include "pack_struct_end.h" -typedef struct xPSEUDO_HEADER PseudoHeader_t; - -/*-----------------------------------------------------------*/ -/* Nested protocol packets. */ -/*-----------------------------------------------------------*/ - -#include "pack_struct_start.h" -struct xARP_PACKET -{ - EthernetHeader_t xEthernetHeader; /* 0 + 14 = 14 */ - ARPHeader_t xARPHeader; /* 14 + 28 = 42 */ -} -#include "pack_struct_end.h" -typedef struct xARP_PACKET ARPPacket_t; - -#include "pack_struct_start.h" -struct xIP_PACKET -{ - EthernetHeader_t xEthernetHeader; - IPHeader_t xIPHeader; -} -#include "pack_struct_end.h" -typedef struct xIP_PACKET IPPacket_t; - -#include "pack_struct_start.h" -struct xICMP_PACKET -{ - EthernetHeader_t xEthernetHeader; - IPHeader_t xIPHeader; - ICMPHeader_t xICMPHeader; -} -#include "pack_struct_end.h" -typedef struct xICMP_PACKET ICMPPacket_t; - -#include "pack_struct_start.h" -struct xUDP_PACKET -{ - EthernetHeader_t xEthernetHeader; /* 0 + 14 = 14 */ - IPHeader_t xIPHeader; /* 14 + 20 = 34 */ - UDPHeader_t xUDPHeader; /* 34 + 8 = 42 */ -} -#include "pack_struct_end.h" -typedef struct xUDP_PACKET UDPPacket_t; - -#include "pack_struct_start.h" -struct xTCP_PACKET -{ - EthernetHeader_t xEthernetHeader; /* 0 + 14 = 14 */ - IPHeader_t xIPHeader; /* 14 + 20 = 34 */ - TCPHeader_t xTCPHeader; /* 34 + 32 = 66 */ -} -#include "pack_struct_end.h" -typedef struct xTCP_PACKET TCPPacket_t; - -typedef union XPROT_PACKET -{ - ARPPacket_t xARPPacket; - TCPPacket_t xTCPPacket; - UDPPacket_t xUDPPacket; - ICMPPacket_t xICMPPacket; -} ProtocolPacket_t; - - -/* The maximum UDP payload length. */ -#define ipMAX_UDP_PAYLOAD_LENGTH ( ( ipconfigNETWORK_MTU - ipSIZE_OF_IPv4_HEADER ) - ipSIZE_OF_UDP_HEADER ) - -typedef enum -{ - eReleaseBuffer = 0, /* Processing the frame did not find anything to do - just release the buffer. */ - eProcessBuffer, /* An Ethernet frame has a valid address - continue process its contents. */ - eReturnEthernetFrame, /* The Ethernet frame contains an ARP or ICMP packet that can be returned to its source. */ - eFrameConsumed /* Processing the Ethernet packet contents resulted in the payload being sent to the stack. */ -} eFrameProcessingResult_t; - -typedef enum -{ - eNoEvent = -1, - eNetworkDownEvent, /* 0: The network interface has been lost and/or needs [re]connecting. */ - eNetworkRxEvent, /* 1: The network interface has queued a received Ethernet frame. */ - eARPTimerEvent, /* 2: The ARP timer expired. */ - eStackTxEvent, /* 3: The software stack has queued a packet to transmit. */ - eDHCPEvent, /* 4: Process the DHCP state machine. */ - eTCPTimerEvent, /* 5: See if any TCP socket needs attention. */ - eTCPAcceptEvent, /* 6: Client API FreeRTOS_accept() waiting for client connections. */ - eTCPNetStat, /* 7: IP-task is asked to produce a netstat listing. */ - eSocketBindEvent, /* 8: Send a message to the IP-task to bind a socket to a port. */ - eSocketCloseEvent, /* 9: Send a message to the IP-task to close a socket. */ - eSocketSelectEvent, /*10: Send a message to the IP-task for select(). */ - eSocketSignalEvent, /*11: A socket must be signalled. */ -} eIPEvent_t; - -typedef struct IP_TASK_COMMANDS -{ - eIPEvent_t eEventType; - void *pvData; -} IPStackEvent_t; - -#define ipBROADCAST_IP_ADDRESS 0xffffffffUL - -/* Offset into the Ethernet frame that is used to temporarily store information -on the fragmentation status of the packet being sent. The value is important, -as it is past the location into which the destination address will get placed. */ -#define ipFRAGMENTATION_PARAMETERS_OFFSET ( 6 ) -#define ipSOCKET_OPTIONS_OFFSET ( 6 ) - -/* Only used when outgoing fragmentation is being used (FreeRTOSIPConfig.h -setting. */ -#define ipGET_UDP_PAYLOAD_OFFSET_FOR_FRAGMENT( usFragmentOffset ) ( ( ( usFragmentOffset ) == 0 ) ? ipUDP_PAYLOAD_OFFSET_IPv4 : ipIP_PAYLOAD_OFFSET ) - -/* The offset into a UDP packet at which the UDP data (payload) starts. */ -#define ipUDP_PAYLOAD_OFFSET_IPv4 ( sizeof( UDPPacket_t ) ) - -/* The offset into an IP packet into which the IP data (payload) starts. */ -#define ipIP_PAYLOAD_OFFSET ( sizeof( IPPacket_t ) ) - -#include "pack_struct_start.h" -struct xUDP_IP_FRAGMENT_PARAMETERS -{ - uint8_t ucSocketOptions; - uint8_t ucPadFor16BitAlignment; - uint16_t usFragmentedPacketOffset; - uint16_t usFragmentLength; - uint16_t usPayloadChecksum; -} -#include "pack_struct_end.h" -typedef struct xUDP_IP_FRAGMENT_PARAMETERS IPFragmentParameters_t; - -#if( ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN ) - - /* Ethernet frame types. */ - #define ipARP_FRAME_TYPE ( 0x0608U ) - #define ipIPv4_FRAME_TYPE ( 0x0008U ) - - /* ARP related definitions. */ - #define ipARP_PROTOCOL_TYPE ( 0x0008U ) - #define ipARP_HARDWARE_TYPE_ETHERNET ( 0x0100U ) - #define ipARP_REQUEST ( 0x0100U ) - #define ipARP_REPLY ( 0x0200U ) - -#else - - /* Ethernet frame types. */ - #define ipARP_FRAME_TYPE ( 0x0806U ) - #define ipIPv4_FRAME_TYPE ( 0x0800U ) - - /* ARP related definitions. */ - #define ipARP_PROTOCOL_TYPE ( 0x0800U ) - #define ipARP_HARDWARE_TYPE_ETHERNET ( 0x0001U ) - #define ipARP_REQUEST ( 0x0001 ) - #define ipARP_REPLY ( 0x0002 ) - -#endif /* ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN */ - - -/* For convenience, a MAC address of all zeros and another of all 0xffs are -defined const for quick reference. */ -extern const MACAddress_t xBroadcastMACAddress; /* all 0xff's */ -extern uint16_t usPacketIdentifier; - -/* Define a default UDP packet header (declared in FreeRTOS_UDP_IP.c) */ -typedef union xUDPPacketHeader -{ - uint8_t ucBytes[24]; - uint32_t ulWords[6]; -} UDPPacketHeader_t; -extern UDPPacketHeader_t xDefaultPartUDPPacketHeader; - -/* Structure that stores the netmask, gateway address and DNS server addresses. */ -extern NetworkAddressingParameters_t xNetworkAddressing; - -/* Structure that stores the defaults for netmask, gateway address and DNS. -These values will be copied to 'xNetworkAddressing' in case DHCP is not used, -and also in case DHCP does not lead to a confirmed request. */ -extern NetworkAddressingParameters_t xDefaultAddressing; - -/* True when BufferAllocation_1.c was included, false for BufferAllocation_2.c */ -extern const BaseType_t xBufferAllocFixedSize; - -/* Defined in FreeRTOS_Sockets.c */ -#if ( ipconfigUSE_TCP == 1 ) - extern List_t xBoundTCPSocketsList; -#endif - -/* The local IP address is accessed from within xDefaultPartUDPPacketHeader, -rather than duplicated in its own variable. */ -#define ipLOCAL_IP_ADDRESS_POINTER ( ( uint32_t * ) &( xDefaultPartUDPPacketHeader.ulWords[ 20u / sizeof(uint32_t) ] ) ) - -/* The local MAC address is accessed from within xDefaultPartUDPPacketHeader, -rather than duplicated in its own variable. */ -#define ipLOCAL_MAC_ADDRESS ( &xDefaultPartUDPPacketHeader.ucBytes[0] ) - -/* ICMP packets are sent using the same function as UDP packets. The port -number is used to distinguish between the two, as 0 is an invalid UDP port. */ -#define ipPACKET_CONTAINS_ICMP_DATA ( 0 ) - -/* For now, the lower 8 bits in 'xEventBits' will be reserved for the above -socket events. */ -#define SOCKET_EVENT_BIT_COUNT 8 - -#define vSetField16( pxBase, xType, xField, usValue ) \ -{ \ - ( ( uint8_t* )( pxBase ) ) [ offsetof( xType, xField ) + 0 ] = ( uint8_t ) ( ( usValue ) >> 8 ); \ - ( ( uint8_t* )( pxBase ) ) [ offsetof( xType, xField ) + 1 ] = ( uint8_t ) ( ( usValue ) & 0xff ); \ -} - -#define vSetField32( pxBase, xType, xField, ulValue ) \ -{ \ - ( (uint8_t*)( pxBase ) ) [ offsetof( xType, xField ) + 0 ] = ( uint8_t ) ( ( ulValue ) >> 24 ); \ - ( (uint8_t*)( pxBase ) ) [ offsetof( xType, xField ) + 1 ] = ( uint8_t ) ( ( ( ulValue ) >> 16 ) & 0xff ); \ - ( (uint8_t*)( pxBase ) ) [ offsetof( xType, xField ) + 2 ] = ( uint8_t ) ( ( ( ulValue ) >> 8 ) & 0xff ); \ - ( (uint8_t*)( pxBase ) ) [ offsetof( xType, xField ) + 3 ] = ( uint8_t ) ( ( ulValue ) & 0xff ); \ -} - -#define vFlip_16( left, right ) \ - do { \ - uint16_t tmp = (left); \ - (left) = (right); \ - (right) = tmp; \ - } while (0) - -#define vFlip_32( left, right ) \ - do { \ - uint32_t tmp = (left); \ - (left) = (right); \ - (right) = tmp; \ - } while (0) - -#ifndef ARRAY_SIZE - #define ARRAY_SIZE(x) (BaseType_t)(sizeof(x)/sizeof(x)[0]) -#endif - -/* - * A version of FreeRTOS_GetReleaseNetworkBuffer() that can be called from an - * interrupt. If a non zero value is returned, then the calling ISR should - * perform a context switch before exiting the ISR. - */ -BaseType_t FreeRTOS_ReleaseFreeNetworkBufferFromISR( void ); - -/* - * Create a message that contains a command to initialise the network interface. - * This is used during initialisation, and at any time the network interface - * goes down thereafter. The network interface hardware driver is responsible - * for sending the message that contains the network interface down command/ - * event. - * - * Only use the FreeRTOS_NetworkDownFromISR() version if the function is to be - * called from an interrupt service routine. If FreeRTOS_NetworkDownFromISR() - * returns a non-zero value then a context switch should be performed ebfore - * the interrupt is exited. - */ -void FreeRTOS_NetworkDown( void ); -BaseType_t FreeRTOS_NetworkDownFromISR( void ); - -/* - * Processes incoming ARP packets. - */ -eFrameProcessingResult_t eARPProcessPacket( ARPPacket_t * const pxARPFrame ); - -/* - * Inspect an Ethernet frame to see if it contains data that the stack needs to - * process. eProcessBuffer is returned if the frame should be processed by the - * stack. eReleaseBuffer is returned if the frame should be discarded. - */ -eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucEthernetBuffer ); - -/* - * Return the checksum generated over xDataLengthBytes from pucNextData. - */ -uint16_t usGenerateChecksum( uint32_t ulSum, const uint8_t * pucNextData, size_t uxDataLengthBytes ); - -/* Socket related private functions. */ - -/* - * The caller must ensure that pxNetworkBuffer->xDataLength is the UDP packet - * payload size (excluding packet headers) and that the packet in pucEthernetBuffer - * is at least the size of UDPPacket_t. - */ -BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t *pxNetworkBuffer, uint16_t usPort ); - -/* - * Initialize the socket list data structures for TCP and UDP. - */ -BaseType_t vNetworkSocketsInit( void ); - -/* - * Returns pdTRUE if the IP task has been created and is initialised. Otherwise - * returns pdFALSE. - */ -BaseType_t xIPIsNetworkTaskReady( void ); - -#if( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK == 1 ) - struct XSOCKET; - typedef void (*SocketWakeupCallback_t)( struct XSOCKET * pxSocket ); -#endif - -#if( ipconfigUSE_TCP == 1 ) - - /* - * Actually a user thing, but because xBoundTCPSocketsList, let it do by the - * IP-task - */ - void vTCPNetStat( void ); - - /* - * At least one socket needs to check for timeouts - */ - TickType_t xTCPTimerCheck( BaseType_t xWillSleep ); - - /* Every TCP socket has a buffer space just big enough to store - the last TCP header received. - As a reference of this field may be passed to DMA, force the - alignment to 8 bytes. */ - typedef union - { - struct - { - /* Increase the alignment of this union by adding a 64-bit variable. */ - uint64_t ullAlignmentWord; - } a; - struct - { - /* The next field only serves to give 'ucLastPacket' a correct - alignment of 8 + 2. See comments in FreeRTOS_IP.h */ - uint8_t ucFillPacket[ ipconfigPACKET_FILLER_SIZE ]; - uint8_t ucLastPacket[ sizeof( TCPPacket_t ) ]; - } u; - } LastTCPPacket_t; - - /* - * Note that the values of all short and long integers in these structs - * are being stored in the native-endian way - * Translation should take place when accessing any structure which defines - * network packets, such as IPHeader_t and TCPHeader_t - */ - typedef struct TCPSOCKET - { - uint32_t ulRemoteIP; /* IP address of remote machine */ - uint16_t usRemotePort; /* Port on remote machine */ - struct { - /* Most compilers do like bit-flags */ - uint32_t - bMssChange : 1, /* This socket has seen a change in MSS */ - bPassAccept : 1, /* when true, this socket may be returned in a call to accept() */ - bPassQueued : 1, /* when true, this socket is an orphan until it gets connected - * Why an orphan? Because it may not be returned in a accept() call until it - * gets the state eESTABLISHED */ - bReuseSocket : 1, /* When a listening socket gets a connection, do not create a new instance but keep on using it */ - bCloseAfterSend : 1,/* As soon as the last byte has been transmitted, finalise the connection - * Useful in e.g. FTP connections, where the last data bytes are sent along with the FIN flag */ - bUserShutdown : 1, /* User requesting a graceful shutdown */ - bCloseRequested : 1,/* Request to finalise the connection */ - bLowWater : 1, /* high-water level has been reached. Cleared as soon as 'rx-count < lo-water' */ - bWinChange : 1, /* The value of bLowWater has changed, must send a window update */ - bSendKeepAlive : 1, /* When this flag is true, a TCP keep-alive message must be send */ - bWaitKeepAlive : 1, /* When this flag is true, a TCP keep-alive reply is expected */ - bConnPrepared : 1, /* Connecting socket: Message has been prepared */ - #if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - bConnPassed : 1, /* Connecting socket: Socket has been passed in a successful select() */ - #endif /* ipconfigSUPPORT_SELECT_FUNCTION */ - bFinAccepted : 1, /* This socket has received (or sent) a FIN and accepted it */ - bFinSent : 1, /* We've sent out a FIN */ - bFinRecv : 1, /* We've received a FIN from our peer */ - bFinAcked : 1, /* Our FIN packet has been acked */ - bFinLast : 1, /* The last ACK (after FIN and FIN+ACK) has been sent or will be sent by the peer */ - bRxStopped : 1, /* Application asked to temporarily stop reception */ - bMallocError : 1, /* There was an error allocating a stream */ - bWinScaling : 1; /* A TCP-Window Scaling option was offered and accepted in the SYN phase. */ - } bits; - uint32_t ulHighestRxAllowed; - /* The highest sequence number that we can receive at any moment */ - uint16_t usTimeout; /* Time (in ticks) after which this socket needs attention */ - uint16_t usCurMSS; /* Current Maximum Segment Size */ - uint16_t usInitMSS; /* Initial maximum segment Size */ - uint16_t usChildCount; /* In case of a listening socket: number of connections on this port number */ - uint16_t usBacklog; /* In case of a listening socket: maximum number of concurrent connections on this port number */ - uint8_t ucRepCount; /* Send repeat count, for retransmissions - * This counter is separate from the xmitCount in the - * TCP win segments */ - uint8_t ucTCPState; /* TCP state: see eTCP_STATE */ - struct XSOCKET *pxPeerSocket; /* for server socket: child, for child socket: parent */ - #if( ipconfigTCP_KEEP_ALIVE == 1 ) - uint8_t ucKeepRepCount; - TickType_t xLastAliveTime; - #endif /* ipconfigTCP_KEEP_ALIVE */ - #if( ipconfigTCP_HANG_PROTECTION == 1 ) - TickType_t xLastActTime; - #endif /* ipconfigTCP_HANG_PROTECTION */ - size_t uxLittleSpace; - size_t uxEnoughSpace; - size_t uxRxStreamSize; - size_t uxTxStreamSize; - StreamBuffer_t *rxStream; - StreamBuffer_t *txStream; - #if( ipconfigUSE_TCP_WIN == 1 ) - NetworkBufferDescriptor_t *pxAckMessage; - #endif /* ipconfigUSE_TCP_WIN */ - /* Buffer space to store the last TCP header received. */ - LastTCPPacket_t xPacket; - uint8_t tcpflags; /* TCP flags */ - #if( ipconfigUSE_TCP_WIN != 0 ) - uint8_t ucMyWinScaleFactor; - uint8_t ucPeerWinScaleFactor; - #endif - #if( ipconfigUSE_CALLBACKS == 1 ) - FOnTCPReceive_t pxHandleReceive; /* - * In case of a TCP socket: - * typedef void (* FOnTCPReceive_t) (Socket_t xSocket, void *pData, size_t xLength ); - */ - FOnTCPSent_t pxHandleSent; - FOnConnected_t pxHandleConnected; /* Actually type: typedef void (* FOnConnected_t) (Socket_t xSocket, BaseType_t ulConnected ); */ - #endif /* ipconfigUSE_CALLBACKS */ - uint32_t ulWindowSize; /* Current Window size advertised by peer */ - uint32_t ulRxCurWinSize; /* Constantly changing: this is the current size available for data reception */ - size_t uxRxWinSize; /* Fixed value: size of the TCP reception window */ - size_t uxTxWinSize; /* Fixed value: size of the TCP transmit window */ - - TCPWindow_t xTCPWindow; - } IPTCPSocket_t; - -#endif /* ipconfigUSE_TCP */ - -typedef struct UDPSOCKET -{ - List_t xWaitingPacketsList; /* Incoming packets */ - #if( ipconfigUDP_MAX_RX_PACKETS > 0 ) - UBaseType_t uxMaxPackets; /* Protection: limits the number of packets buffered per socket */ - #endif /* ipconfigUDP_MAX_RX_PACKETS */ - #if( ipconfigUSE_CALLBACKS == 1 ) - FOnUDPReceive_t pxHandleReceive; /* - * In case of a UDP socket: - * typedef void (* FOnUDPReceive_t) (Socket_t xSocket, void *pData, size_t xLength, struct freertos_sockaddr *pxAddr ); - */ - FOnUDPSent_t pxHandleSent; - #endif /* ipconfigUSE_CALLBACKS */ -} IPUDPSocket_t; - -typedef enum eSOCKET_EVENT { - eSOCKET_RECEIVE = 0x0001, - eSOCKET_SEND = 0x0002, - eSOCKET_ACCEPT = 0x0004, - eSOCKET_CONNECT = 0x0008, - eSOCKET_BOUND = 0x0010, - eSOCKET_CLOSED = 0x0020, - eSOCKET_INTR = 0x0040, - eSOCKET_ALL = 0x007F, -} eSocketEvent_t; - -typedef struct XSOCKET -{ - EventBits_t xEventBits; - EventGroupHandle_t xEventGroup; - - ListItem_t xBoundSocketListItem; /* Used to reference the socket from a bound sockets list. */ - TickType_t xReceiveBlockTime; /* if recv[to] is called while no data is available, wait this amount of time. Unit in clock-ticks */ - TickType_t xSendBlockTime; /* if send[to] is called while there is not enough space to send, wait this amount of time. Unit in clock-ticks */ - - uint16_t usLocalPort; /* Local port on this machine */ - uint8_t ucSocketOptions; - uint8_t ucProtocol; /* choice of FREERTOS_IPPROTO_UDP/TCP */ - #if( ipconfigSOCKET_HAS_USER_SEMAPHORE == 1 ) - SemaphoreHandle_t pxUserSemaphore; - #endif /* ipconfigSOCKET_HAS_USER_SEMAPHORE */ - #if( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK == 1 ) - SocketWakeupCallback_t pxUserWakeCallback; - #endif /* ipconfigSOCKET_HAS_USER_WAKE_CALLBACK */ - - #if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - struct xSOCKET_SET *pxSocketSet; - /* User may indicate which bits are interesting for this socket. */ - EventBits_t xSelectBits; - /* These bits indicate the events which have actually occurred. - They are maintained by the IP-task */ - EventBits_t xSocketBits; - #endif /* ipconfigSUPPORT_SELECT_FUNCTION */ - /* TCP/UDP specific fields: */ - /* Before accessing any member of this structure, it should be confirmed */ - /* that the protocol corresponds with the type of structure */ - - union - { - IPUDPSocket_t xUDP; - #if( ipconfigUSE_TCP == 1 ) - IPTCPSocket_t xTCP; - /* Make sure that xTCP is 8-bytes aligned by - declaring a 64-bit variable in the same union */ - uint64_t ullTCPAlignment; - #endif /* ipconfigUSE_TCP */ - } u; -} FreeRTOS_Socket_t; - -#if( ipconfigUSE_TCP == 1 ) - /* - * Lookup a TCP socket, using a multiple matching: both port numbers and - * return IP address. - */ - FreeRTOS_Socket_t *pxTCPSocketLookup( uint32_t ulLocalIP, UBaseType_t uxLocalPort, uint32_t ulRemoteIP, UBaseType_t uxRemotePort ); - -#endif /* ipconfigUSE_TCP */ - -/* - * Look up a local socket by finding a match with the local port. - */ -FreeRTOS_Socket_t *pxUDPSocketLookup( UBaseType_t uxLocalPort ); - -/* - * Called when the application has generated a UDP packet to send. - */ -void vProcessGeneratedUDPPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer ); - -/* - * Calculate the upper-layer checksum - * Works both for UDP, ICMP and TCP packages - * bOut = true: checksum will be set in outgoing packets - * bOut = false: checksum will be calculated for incoming packets - * returning 0xffff means: checksum was correct - */ -uint16_t usGenerateProtocolChecksum( const uint8_t * const pucEthernetBuffer, size_t uxBufferLength, BaseType_t xOutgoingPacket ); - -/* - * An Ethernet frame has been updated (maybe it was an ARP request or a PING - * request?) and is to be sent back to its source. - */ -void vReturnEthernetFrame( NetworkBufferDescriptor_t * pxNetworkBuffer, BaseType_t xReleaseAfterSend ); - -/* - * The internal version of bind() - * If 'ulInternal' is true, it is called by the driver - * The TCP driver needs to bind a socket at the moment a listening socket - * creates a new connected socket - */ -BaseType_t vSocketBind( FreeRTOS_Socket_t *pxSocket, struct freertos_sockaddr * pxAddress, size_t uxAddressLength, BaseType_t xInternal ); - -/* - * Internal function to add streaming data to a TCP socket. If ulIn == true, - * data will be added to the rxStream, otherwise to the tXStream. Normally data - * will be written with ulOffset == 0, meaning: at the end of the FIFO. When - * packet come in out-of-order, an offset will be used to put it in front and - * the head will not change yet. - */ -int32_t lTCPAddRxdata(FreeRTOS_Socket_t *pxSocket, size_t uxOffset, const uint8_t *pcData, uint32_t ulByteCount); - -/* - * Currently called for any important event. - */ -void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket ); - -/* - * Some helping function, their meaning should be clear - */ -static portINLINE uint32_t ulChar2u32 (const uint8_t *apChr); -static portINLINE uint32_t ulChar2u32 (const uint8_t *apChr) -{ - return ( ( ( uint32_t )apChr[0] ) << 24) | - ( ( ( uint32_t )apChr[1] ) << 16) | - ( ( ( uint32_t )apChr[2] ) << 8) | - ( ( ( uint32_t )apChr[3] ) ); -} - -static portINLINE uint16_t usChar2u16 (const uint8_t *apChr); -static portINLINE uint16_t usChar2u16 (const uint8_t *apChr) -{ - return ( uint16_t ) - ( ( ( ( uint32_t )apChr[0] ) << 8) | - ( ( ( uint32_t )apChr[1] ) ) ); -} - -/* Check a single socket for retransmissions and timeouts */ -BaseType_t xTCPSocketCheck( FreeRTOS_Socket_t *pxSocket ); - -BaseType_t xTCPCheckNewClient( FreeRTOS_Socket_t *pxSocket ); - -/* Defined in FreeRTOS_Sockets.c - * Close a socket - */ -void *vSocketClose( FreeRTOS_Socket_t *pxSocket ); - -/* - * Send the event eEvent to the IP task event queue, using a block time of - * zero. Return pdPASS if the message was sent successfully, otherwise return - * pdFALSE. -*/ -BaseType_t xSendEventToIPTask( eIPEvent_t eEvent ); - -/* - * The same as above, but a struct as a parameter, containing: - * eIPEvent_t eEventType; - * void *pvData; - */ -BaseType_t xSendEventStructToIPTask( const IPStackEvent_t *pxEvent, TickType_t xTimeout ); - -/* - * Returns a pointer to the original NetworkBuffer from a pointer to a UDP - * payload buffer. - */ -NetworkBufferDescriptor_t *pxUDPPayloadBuffer_to_NetworkBuffer( void *pvBuffer ); - -#if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - /* - * For the case where the network driver passes a buffer directly to a DMA - * descriptor, this function can be used to translate a 'network buffer' to - * a 'network buffer descriptor'. - */ - NetworkBufferDescriptor_t *pxPacketBuffer_to_NetworkBuffer( const void *pvBuffer ); -#endif - -/* - * Internal: Sets a new state for a TCP socket and performs the necessary - * actions like calling a OnConnected handler to notify the socket owner. - */ -#if( ipconfigUSE_TCP == 1 ) - void vTCPStateChange( FreeRTOS_Socket_t *pxSocket, enum eTCP_STATE eTCPState ); -#endif /* ipconfigUSE_TCP */ - -/*_RB_ Should this be part of the public API? */ -void FreeRTOS_netstat( void ); - -/* Returns pdTRUE is this function is called from the IP-task */ -BaseType_t xIsCallingFromIPTask( void ); - -#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - -typedef struct xSOCKET_SET -{ - EventGroupHandle_t xSelectGroup; - BaseType_t bApiCalled; /* True if the API was calling the private vSocketSelect */ - FreeRTOS_Socket_t *pxSocket; -} SocketSelect_t; - -extern void vSocketSelect( SocketSelect_t *pxSocketSelect ); - -#endif /* ipconfigSUPPORT_SELECT_FUNCTION */ - -void vIPSetDHCPTimerEnableState( BaseType_t xEnableState ); -void vIPReloadDHCPTimer( uint32_t ulLeaseTime ); -#if( ipconfigDNS_USE_CALLBACKS != 0 ) - void vIPReloadDNSTimer( uint32_t ulCheckTime ); - void vIPSetDnsTimerEnableState( BaseType_t xEnableState ); -#endif - -/* Send the network-up event and start the ARP timer. */ -void vIPNetworkUpCalls( void ); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* FREERTOS_IP_PRIVATE_H */ - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_Sockets.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_Sockets.h deleted file mode 100755 index 657757d..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_Sockets.h +++ /dev/null @@ -1,393 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -#ifndef FREERTOS_SOCKETS_H -#define FREERTOS_SOCKETS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Standard includes. */ -#include - -/* Application level configuration options. */ -#include "FreeRTOSIPConfig.h" - -#ifndef FREERTOS_IP_CONFIG_H - #error FreeRTOSIPConfig.h has not been included yet -#endif - -/* Event bit definitions are required by the select functions. */ -#include "event_groups.h" - -#ifndef INC_FREERTOS_H - #error FreeRTOS.h must be included before FreeRTOS_Sockets.h. -#endif - -#ifndef INC_TASK_H - #ifndef TASK_H /* For compatibility with older FreeRTOS versions. */ - #error The FreeRTOS header file task.h must be included before FreeRTOS_Sockets.h. - #endif -#endif - -/* Assigned to an Socket_t variable when the socket is not valid, probably -because it could not be created. */ -#define FREERTOS_INVALID_SOCKET ( ( void * ) ~0U ) - -/* API function error values. As errno is supported, the FreeRTOS sockets -functions return error codes rather than just a pass or fail indication. */ -/* HT: Extended the number of error codes, gave them positive values and if possible -the corresponding found in errno.h -In case of an error, API's will still return negative numbers, e.g. - return -pdFREERTOS_ERRNO_EWOULDBLOCK; -in case an operation would block */ - -/* The following defines are obsolete, please use -pdFREERTOS_ERRNO_Exxx */ - -#define FREERTOS_SOCKET_ERROR ( -1 ) -#define FREERTOS_EWOULDBLOCK ( - pdFREERTOS_ERRNO_EWOULDBLOCK ) -#define FREERTOS_EINVAL ( - pdFREERTOS_ERRNO_EINVAL ) -#define FREERTOS_EADDRNOTAVAIL ( - pdFREERTOS_ERRNO_EADDRNOTAVAIL ) -#define FREERTOS_EADDRINUSE ( - pdFREERTOS_ERRNO_EADDRINUSE ) -#define FREERTOS_ENOBUFS ( - pdFREERTOS_ERRNO_ENOBUFS ) -#define FREERTOS_ENOPROTOOPT ( - pdFREERTOS_ERRNO_ENOPROTOOPT ) -#define FREERTOS_ECLOSED ( - pdFREERTOS_ERRNO_ENOTCONN ) - -/* Values for the parameters to FreeRTOS_socket(), inline with the Berkeley -standard. See the documentation of FreeRTOS_socket() for more information. */ -#define FREERTOS_AF_INET ( 2 ) -#define FREERTOS_AF_INET6 ( 10 ) -#define FREERTOS_SOCK_DGRAM ( 2 ) -#define FREERTOS_IPPROTO_UDP ( 17 ) - -#define FREERTOS_SOCK_STREAM ( 1 ) -#define FREERTOS_IPPROTO_TCP ( 6 ) -/* IP packet of type "Any local network" - * can be used in stead of TCP for testing with sockets in raw mode - */ -#define FREERTOS_IPPROTO_USR_LAN ( 63 ) - -/* A bit value that can be passed into the FreeRTOS_sendto() function as part of -the flags parameter. Setting the FREERTOS_ZERO_COPY in the flags parameter -indicates that the zero copy interface is being used. See the documentation for -FreeRTOS_sockets() for more information. */ -#define FREERTOS_ZERO_COPY ( 1 ) - -/* Values that can be passed in the option name parameter of calls to -FreeRTOS_setsockopt(). */ -#define FREERTOS_SO_RCVTIMEO ( 0 ) /* Used to set the receive time out. */ -#define FREERTOS_SO_SNDTIMEO ( 1 ) /* Used to set the send time out. */ -#define FREERTOS_SO_UDPCKSUM_OUT ( 2 ) /* Used to turn the use of the UDP checksum by a socket on or off. This also doubles as part of an 8-bit bitwise socket option. */ -#if( ipconfigSOCKET_HAS_USER_SEMAPHORE == 1 ) - #define FREERTOS_SO_SET_SEMAPHORE ( 3 ) /* Used to set a user's semaphore */ -#endif -#define FREERTOS_SO_SNDBUF ( 4 ) /* Set the size of the send buffer (TCP only) */ -#define FREERTOS_SO_RCVBUF ( 5 ) /* Set the size of the receive buffer (TCP only) */ - -#if ipconfigUSE_CALLBACKS == 1 - #define FREERTOS_SO_TCP_CONN_HANDLER ( 6 ) /* Install a callback for (dis) connection events. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */ - #define FREERTOS_SO_TCP_RECV_HANDLER ( 7 ) /* Install a callback for receiving TCP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */ - #define FREERTOS_SO_TCP_SENT_HANDLER ( 8 ) /* Install a callback for sending TCP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */ - #define FREERTOS_SO_UDP_RECV_HANDLER ( 9 ) /* Install a callback for receiving UDP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */ - #define FREERTOS_SO_UDP_SENT_HANDLER ( 10 ) /* Install a callback for sending UDP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */ -#endif /* ipconfigUSE_CALLBACKS */ - -#define FREERTOS_SO_REUSE_LISTEN_SOCKET ( 11 ) /* When a listening socket gets connected, do not create a new one but re-use it */ -#define FREERTOS_SO_CLOSE_AFTER_SEND ( 12 ) /* As soon as the last byte has been transmitted, finalise the connection */ -#define FREERTOS_SO_WIN_PROPERTIES ( 13 ) /* Set all buffer and window properties in one call, parameter is pointer to WinProperties_t */ -#define FREERTOS_SO_SET_FULL_SIZE ( 14 ) /* Refuse to send packets smaller than MSS */ - -#define FREERTOS_SO_STOP_RX ( 15 ) /* Temporarily hold up reception, used by streaming client */ - -#if( ipconfigUDP_MAX_RX_PACKETS > 0 ) - #define FREERTOS_SO_UDP_MAX_RX_PACKETS ( 16 ) /* This option helps to limit the maximum number of packets a UDP socket will buffer */ -#endif - -#if( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK == 1 ) - #define FREERTOS_SO_WAKEUP_CALLBACK ( 17 ) -#endif - - -#define FREERTOS_NOT_LAST_IN_FRAGMENTED_PACKET ( 0x80 ) /* For internal use only, but also part of an 8-bit bitwise value. */ -#define FREERTOS_FRAGMENTED_PACKET ( 0x40 ) /* For internal use only, but also part of an 8-bit bitwise value. */ - -/* Values for flag for FreeRTOS_shutdown(). */ -#define FREERTOS_SHUT_RD ( 0 ) /* Not really at this moment, just for compatibility of the interface */ -#define FREERTOS_SHUT_WR ( 1 ) -#define FREERTOS_SHUT_RDWR ( 2 ) - -/* Values for flag for FreeRTOS_recv(). */ -#define FREERTOS_MSG_OOB ( 2 ) /* process out-of-band data */ -#define FREERTOS_MSG_PEEK ( 4 ) /* peek at incoming message */ -#define FREERTOS_MSG_DONTROUTE ( 8 ) /* send without using routing tables */ -#define FREERTOS_MSG_DONTWAIT ( 16 ) /* Can be used with recvfrom(), sendto(), recv(), and send(). */ - -typedef struct xWIN_PROPS { - /* Properties of the Tx buffer and Tx window */ - int32_t lTxBufSize; /* Unit: bytes */ - int32_t lTxWinSize; /* Unit: MSS */ - - /* Properties of the Rx buffer and Rx window */ - int32_t lRxBufSize; /* Unit: bytes */ - int32_t lRxWinSize; /* Unit: MSS */ -} WinProperties_t; - -/* For compatibility with the expected Berkeley sockets naming. */ -#define socklen_t uint32_t - -/* For this limited implementation, only two members are required in the -Berkeley style sockaddr structure. */ -struct freertos_sockaddr -{ - /* _HT_ On 32- and 64-bit architectures, the addition of the two uint8_t - fields doesn't make the structure bigger, due to alignment. - The fields are inserted as a preparation for IPv6. */ - - /* sin_len and sin_family not used in the IPv4-only release. */ - uint8_t sin_len; /* length of this structure. */ - uint8_t sin_family; /* FREERTOS_AF_INET. */ - uint16_t sin_port; - uint32_t sin_addr; -}; - -#if ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN - - #define FreeRTOS_inet_addr_quick( ucOctet0, ucOctet1, ucOctet2, ucOctet3 ) \ - ( ( ( ( uint32_t ) ( ucOctet3 ) ) << 24UL ) | \ - ( ( ( uint32_t ) ( ucOctet2 ) ) << 16UL ) | \ - ( ( ( uint32_t ) ( ucOctet1 ) ) << 8UL ) | \ - ( ( uint32_t ) ( ucOctet0 ) ) ) - - #define FreeRTOS_inet_ntoa( ulIPAddress, pucBuffer ) \ - sprintf( ( char * ) ( pucBuffer ), "%u.%u.%u.%u", \ - ( ( unsigned ) ( ( ulIPAddress ) & 0xffUL ) ), \ - ( ( unsigned ) ( ( ( ulIPAddress ) >> 8 ) & 0xffUL ) ), \ - ( ( unsigned ) ( ( ( ulIPAddress ) >> 16 ) & 0xffUL ) ),\ - ( ( unsigned ) ( ( ulIPAddress ) >> 24 ) ) ) - -#else /* ipconfigBYTE_ORDER */ - - #define FreeRTOS_inet_addr_quick( ucOctet0, ucOctet1, ucOctet2, ucOctet3 ) \ - ( ( ( ( uint32_t ) ( ucOctet0 ) ) << 24UL ) | \ - ( ( ( uint32_t ) ( ucOctet1 ) ) << 16UL ) | \ - ( ( ( uint32_t ) ( ucOctet2 ) ) << 8UL ) | \ - ( ( uint32_t ) ( ucOctet3 ) ) ) - - #define FreeRTOS_inet_ntoa( ulIPAddress, pucBuffer ) \ - sprintf( ( char * ) ( pucBuffer ), "%u.%u.%u.%u", \ - ( ( unsigned ) ( ( ulIPAddress ) >> 24 ) ), \ - ( ( unsigned ) ( ( ( ulIPAddress ) >> 16 ) & 0xffUL ) ),\ - ( ( unsigned ) ( ( ( ulIPAddress ) >> 8 ) & 0xffUL ) ), \ - ( ( unsigned ) ( ( ulIPAddress ) & 0xffUL ) ) ) - -#endif /* ipconfigBYTE_ORDER */ - -/* The socket type itself. */ -typedef void *Socket_t; - -/* The SocketSet_t type is the equivalent to the fd_set type used by the -Berkeley API. */ -typedef void *SocketSet_t; - -/** - * FULL, UP-TO-DATE AND MAINTAINED REFERENCE DOCUMENTATION FOR ALL THESE - * FUNCTIONS IS AVAILABLE ON THE FOLLOWING URL: - * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/FreeRTOS_TCP_API_Functions.html - */ -Socket_t FreeRTOS_socket( BaseType_t xDomain, BaseType_t xType, BaseType_t xProtocol ); -int32_t FreeRTOS_recvfrom( Socket_t xSocket, void *pvBuffer, size_t xBufferLength, BaseType_t xFlags, struct freertos_sockaddr *pxSourceAddress, socklen_t *pxSourceAddressLength ); -int32_t FreeRTOS_sendto( Socket_t xSocket, const void *pvBuffer, size_t xTotalDataLength, BaseType_t xFlags, const struct freertos_sockaddr *pxDestinationAddress, socklen_t xDestinationAddressLength ); -BaseType_t FreeRTOS_bind( Socket_t xSocket, struct freertos_sockaddr *pxAddress, socklen_t xAddressLength ); - -/* function to get the local address and IP port */ -size_t FreeRTOS_GetLocalAddress( Socket_t xSocket, struct freertos_sockaddr *pxAddress ); - -/* Made available when ipconfigETHERNET_DRIVER_FILTERS_PACKETS is set to 1. */ -BaseType_t xPortHasUDPSocket( uint16_t usPortNr ); - -#if ipconfigUSE_TCP == 1 - -BaseType_t FreeRTOS_connect( Socket_t xClientSocket, struct freertos_sockaddr *pxAddress, socklen_t xAddressLength ); -BaseType_t FreeRTOS_listen( Socket_t xSocket, BaseType_t xBacklog ); -BaseType_t FreeRTOS_recv( Socket_t xSocket, void *pvBuffer, size_t xBufferLength, BaseType_t xFlags ); -BaseType_t FreeRTOS_send( Socket_t xSocket, const void *pvBuffer, size_t uxDataLength, BaseType_t xFlags ); -Socket_t FreeRTOS_accept( Socket_t xServerSocket, struct freertos_sockaddr *pxAddress, socklen_t *pxAddressLength ); -BaseType_t FreeRTOS_shutdown (Socket_t xSocket, BaseType_t xHow); - -#if( ipconfigSUPPORT_SIGNALS != 0 ) - /* Send a signal to the task which is waiting for a given socket. */ - BaseType_t FreeRTOS_SignalSocket( Socket_t xSocket ); - - /* Send a signal to the task which reads from this socket (FromISR - version). */ - BaseType_t FreeRTOS_SignalSocketFromISR( Socket_t xSocket, BaseType_t *pxHigherPriorityTaskWoken ); -#endif /* ipconfigSUPPORT_SIGNALS */ - -/* Return the remote address and IP port. */ -BaseType_t FreeRTOS_GetRemoteAddress( Socket_t xSocket, struct freertos_sockaddr *pxAddress ); - -/* returns pdTRUE if TCP socket is connected */ -BaseType_t FreeRTOS_issocketconnected( Socket_t xSocket ); - -/* returns the actual size of MSS being used */ -BaseType_t FreeRTOS_mss( Socket_t xSocket ); - -/* for internal use only: return the connection status */ -BaseType_t FreeRTOS_connstatus( Socket_t xSocket ); - -/* Returns the number of bytes that may be added to txStream */ -BaseType_t FreeRTOS_maywrite( Socket_t xSocket ); - -/* - * Two helper functions, mostly for testing - * rx_size returns the number of bytes available in the Rx buffer - * tx_space returns the free space in the Tx buffer - */ -BaseType_t FreeRTOS_rx_size( Socket_t xSocket ); -BaseType_t FreeRTOS_tx_space( Socket_t xSocket ); -BaseType_t FreeRTOS_tx_size( Socket_t xSocket ); - -/* Returns the number of outstanding bytes in txStream. */ -/* The function FreeRTOS_outstanding() was already implemented -FreeRTOS_tx_size(). */ -#define FreeRTOS_outstanding( xSocket ) FreeRTOS_tx_size( xSocket ) - -/* Returns the number of bytes in the socket's rxStream. */ -/* The function FreeRTOS_recvcount() was already implemented -FreeRTOS_rx_size(). */ -#define FreeRTOS_recvcount( xSocket ) FreeRTOS_rx_size( xSocket ) - -/* - * For advanced applications only: - * Get a direct pointer to the circular transmit buffer. - * '*pxLength' will contain the number of bytes that may be written. - */ -uint8_t *FreeRTOS_get_tx_head( Socket_t xSocket, BaseType_t *pxLength ); - -#endif /* ipconfigUSE_TCP */ - -/* - * Connect / disconnect handler for a TCP socket - * For example: - * static void vMyConnectHandler (Socket_t xSocket, BaseType_t ulConnected) - * { - * } - * F_TCP_UDP_Handler_t xHnd = { vMyConnectHandler }; - * FreeRTOS_setsockopt( sock, 0, FREERTOS_SO_TCP_CONN_HANDLER, ( void * ) &xHnd, sizeof( xHnd ) ); - */ - -typedef void (* FOnConnected_t )( Socket_t /* xSocket */, BaseType_t /* ulConnected */ ); - -/* - * Reception handler for a TCP socket - * A user-proved function will be called on reception of a message - * If the handler returns a positive number, the messages will not be stored - * For example: - * static BaseType_t xOnTCPReceive( Socket_t xSocket, void * pData, size_t xLength ) - * { - * // handle the message - * return 1; - * } - * F_TCP_UDP_Handler_t xHand = { xOnTCPReceive }; - * FreeRTOS_setsockopt( sock, 0, FREERTOS_SO_TCP_RECV_HANDLER, ( void * ) &xHand, sizeof( xHand ) ); - */ -typedef BaseType_t (* FOnTCPReceive_t )( Socket_t /* xSocket */, void * /* pData */, size_t /* xLength */ ); -typedef void (* FOnTCPSent_t )( Socket_t /* xSocket */, size_t /* xLength */ ); - -/* - * Reception handler for a UDP socket - * A user-proved function will be called on reception of a message - * If the handler returns a positive number, the messages will not be stored - */ -typedef BaseType_t (* FOnUDPReceive_t ) (Socket_t /* xSocket */, void * /* pData */, size_t /* xLength */, - const struct freertos_sockaddr * /* pxFrom */, const struct freertos_sockaddr * /* pxDest */ ); -typedef void (* FOnUDPSent_t )( Socket_t /* xSocket */, size_t /* xLength */ ); - - -typedef union xTCP_UDP_HANDLER -{ - FOnConnected_t pxOnTCPConnected; /* FREERTOS_SO_TCP_CONN_HANDLER */ - FOnTCPReceive_t pxOnTCPReceive; /* FREERTOS_SO_TCP_RECV_HANDLER */ - FOnTCPSent_t pxOnTCPSent; /* FREERTOS_SO_TCP_SENT_HANDLER */ - FOnUDPReceive_t pxOnUDPReceive; /* FREERTOS_SO_UDP_RECV_HANDLER */ - FOnUDPSent_t pxOnUDPSent; /* FREERTOS_SO_UDP_SENT_HANDLER */ -} F_TCP_UDP_Handler_t; - -BaseType_t FreeRTOS_setsockopt( Socket_t xSocket, int32_t lLevel, int32_t lOptionName, const void *pvOptionValue, size_t xOptionLength ); -BaseType_t FreeRTOS_closesocket( Socket_t xSocket ); -uint32_t FreeRTOS_gethostbyname( const char *pcHostName ); -uint32_t FreeRTOS_inet_addr( const char * pcIPAddress ); - -/* - * For the web server: borrow the circular Rx buffer for inspection - * HTML driver wants to see if a sequence of 13/10/13/10 is available - */ -const struct xSTREAM_BUFFER *FreeRTOS_get_rx_buf( Socket_t xSocket ); - -void FreeRTOS_netstat( void ); - -#if ipconfigSUPPORT_SELECT_FUNCTION == 1 - - /* For FD_SET and FD_CLR, a combination of the following bits can be used: */ - - typedef enum eSELECT_EVENT { - eSELECT_READ = 0x0001, - eSELECT_WRITE = 0x0002, - eSELECT_EXCEPT = 0x0004, - eSELECT_INTR = 0x0008, - eSELECT_ALL = 0x000F, - /* Reserved for internal use: */ - eSELECT_CALL_IP = 0x0010, - /* end */ - } eSelectEvent_t; - - SocketSet_t FreeRTOS_CreateSocketSet( void ); - void FreeRTOS_DeleteSocketSet( SocketSet_t xSocketSet ); - void FreeRTOS_FD_SET( Socket_t xSocket, SocketSet_t xSocketSet, EventBits_t xBitsToSet ); - void FreeRTOS_FD_CLR( Socket_t xSocket, SocketSet_t xSocketSet, EventBits_t xBitsToClear ); - EventBits_t FreeRTOS_FD_ISSET( Socket_t xSocket, SocketSet_t xSocketSet ); - BaseType_t FreeRTOS_select( SocketSet_t xSocketSet, TickType_t xBlockTimeTicks ); - -#endif /* ipconfigSUPPORT_SELECT_FUNCTION */ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif /* FREERTOS_SOCKETS_H */ - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_Stream_Buffer.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_Stream_Buffer.h deleted file mode 100755 index a220577..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_Stream_Buffer.h +++ /dev/null @@ -1,256 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -/* - * FreeRTOS_Stream_Buffer.h - * - * A cicular character buffer - * An implementation of a circular buffer without a length field - * If LENGTH defines the size of the buffer, a maximum of (LENGT-1) bytes can be stored - * In order to add or read data from the buffer, memcpy() will be called at most 2 times - */ - -#ifndef FREERTOS_STREAM_BUFFER_H -#define FREERTOS_STREAM_BUFFER_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct xSTREAM_BUFFER { - volatile size_t uxTail; /* next item to read */ - volatile size_t uxMid; /* iterator within the valid items */ - volatile size_t uxHead; /* next position store a new item */ - volatile size_t uxFront; /* iterator within the free space */ - size_t LENGTH; /* const value: number of reserved elements */ - uint8_t ucArray[ sizeof( size_t ) ]; -} StreamBuffer_t; - -static portINLINE void vStreamBufferClear( StreamBuffer_t *pxBuffer ); -static portINLINE void vStreamBufferClear( StreamBuffer_t *pxBuffer ) -{ - /* Make the circular buffer empty */ - pxBuffer->uxHead = 0u; - pxBuffer->uxTail = 0u; - pxBuffer->uxFront = 0u; - pxBuffer->uxMid = 0u; -} -/*-----------------------------------------------------------*/ - -static portINLINE size_t uxStreamBufferSpace( const StreamBuffer_t *pxBuffer, const size_t uxLower, const size_t uxUpper ); -static portINLINE size_t uxStreamBufferSpace( const StreamBuffer_t *pxBuffer, const size_t uxLower, const size_t uxUpper ) -{ -/* Returns the space between uxLower and uxUpper, which equals to the distance minus 1 */ -size_t uxCount; - - uxCount = pxBuffer->LENGTH + uxUpper - uxLower - 1u; - if( uxCount >= pxBuffer->LENGTH ) - { - uxCount -= pxBuffer->LENGTH; - } - - return uxCount; -} -/*-----------------------------------------------------------*/ - -static portINLINE size_t uxStreamBufferDistance( const StreamBuffer_t *pxBuffer, const size_t uxLower, const size_t uxUpper ); -static portINLINE size_t uxStreamBufferDistance( const StreamBuffer_t *pxBuffer, const size_t uxLower, const size_t uxUpper ) -{ -/* Returns the distance between uxLower and uxUpper */ -size_t uxCount; - - uxCount = pxBuffer->LENGTH + uxUpper - uxLower; - if ( uxCount >= pxBuffer->LENGTH ) - { - uxCount -= pxBuffer->LENGTH; - } - - return uxCount; -} -/*-----------------------------------------------------------*/ - -static portINLINE size_t uxStreamBufferGetSpace( const StreamBuffer_t *pxBuffer ); -static portINLINE size_t uxStreamBufferGetSpace( const StreamBuffer_t *pxBuffer ) -{ -/* Returns the number of items which can still be added to uxHead -before hitting on uxTail */ -size_t uxHead = pxBuffer->uxHead; -size_t uxTail = pxBuffer->uxTail; - - return uxStreamBufferSpace( pxBuffer, uxHead, uxTail ); -} -/*-----------------------------------------------------------*/ - -static portINLINE size_t uxStreamBufferFrontSpace( const StreamBuffer_t *pxBuffer ); -static portINLINE size_t uxStreamBufferFrontSpace( const StreamBuffer_t *pxBuffer ) -{ -/* Distance between uxFront and uxTail -or the number of items which can still be added to uxFront, -before hitting on uxTail */ - -size_t uxFront = pxBuffer->uxFront; -size_t uxTail = pxBuffer->uxTail; - - return uxStreamBufferSpace( pxBuffer, uxFront, uxTail ); -} -/*-----------------------------------------------------------*/ - -static portINLINE size_t uxStreamBufferGetSize( const StreamBuffer_t *pxBuffer ); -static portINLINE size_t uxStreamBufferGetSize( const StreamBuffer_t *pxBuffer ) -{ -/* Returns the number of items which can be read from uxTail -before reaching uxHead */ -size_t uxHead = pxBuffer->uxHead; -size_t uxTail = pxBuffer->uxTail; - - return uxStreamBufferDistance( pxBuffer, uxTail, uxHead ); -} -/*-----------------------------------------------------------*/ - -static portINLINE size_t uxStreamBufferMidSpace( const StreamBuffer_t *pxBuffer ); -static portINLINE size_t uxStreamBufferMidSpace( const StreamBuffer_t *pxBuffer ) -{ -/* Returns the distance between uxHead and uxMid */ -size_t uxHead = pxBuffer->uxHead; -size_t uxMid = pxBuffer->uxMid; - - return uxStreamBufferDistance( pxBuffer, uxMid, uxHead ); -} -/*-----------------------------------------------------------*/ - -static portINLINE void vStreamBufferMoveMid( StreamBuffer_t *pxBuffer, size_t uxCount ); -static portINLINE void vStreamBufferMoveMid( StreamBuffer_t *pxBuffer, size_t uxCount ) -{ -/* Increment uxMid, but no further than uxHead */ -size_t uxSize = uxStreamBufferMidSpace( pxBuffer ); - - if( uxCount > uxSize ) - { - uxCount = uxSize; - } - pxBuffer->uxMid += uxCount; - if( pxBuffer->uxMid >= pxBuffer->LENGTH ) - { - pxBuffer->uxMid -= pxBuffer->LENGTH; - } -} -/*-----------------------------------------------------------*/ -static portINLINE BaseType_t xStreamBufferIsEmpty( const StreamBuffer_t *pxBuffer ); -static portINLINE BaseType_t xStreamBufferIsEmpty( const StreamBuffer_t *pxBuffer ) -{ -BaseType_t xReturn; - - /* True if no item is available */ - if( pxBuffer->uxHead == pxBuffer->uxTail ) - { - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - return xReturn; -} -/*-----------------------------------------------------------*/ - -static portINLINE BaseType_t xStreamBufferIsFull( const StreamBuffer_t *pxBuffer ); -static portINLINE BaseType_t xStreamBufferIsFull( const StreamBuffer_t *pxBuffer ) -{ - /* True if the available space equals zero. */ - return ( BaseType_t ) ( uxStreamBufferGetSpace( pxBuffer ) == 0u ); -} -/*-----------------------------------------------------------*/ - -static portINLINE BaseType_t xStreamBufferLessThenEqual( const StreamBuffer_t *pxBuffer, const size_t uxLeft, const size_t uxRight ); -static portINLINE BaseType_t xStreamBufferLessThenEqual( const StreamBuffer_t *pxBuffer, const size_t uxLeft, const size_t uxRight ) -{ -BaseType_t xReturn; -size_t uxTail = pxBuffer->uxTail; - - /* Returns true if ( uxLeft < uxRight ) */ - if( ( uxLeft < uxTail ) ^ ( uxRight < uxTail ) ) - { - if( uxRight < uxTail ) - { - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - } - else - { - if( uxLeft <= uxRight ) - { - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - } - return xReturn; -} -/*-----------------------------------------------------------*/ - -static portINLINE size_t uxStreamBufferGetPtr( StreamBuffer_t *pxBuffer, uint8_t **ppucData ); -static portINLINE size_t uxStreamBufferGetPtr( StreamBuffer_t *pxBuffer, uint8_t **ppucData ) -{ -size_t uxNextTail = pxBuffer->uxTail; -size_t uxSize = uxStreamBufferGetSize( pxBuffer ); - - *ppucData = pxBuffer->ucArray + uxNextTail; - - return FreeRTOS_min_uint32( uxSize, pxBuffer->LENGTH - uxNextTail ); -} - -/* - * Add bytes to a stream buffer. - * - * pxBuffer - The buffer to which the bytes will be added. - * uxOffset - If uxOffset > 0, data will be written at an offset from uxHead - * while uxHead will not be moved yet. - * pucData - A pointer to the data to be added. - * uxCount - The number of bytes to add. - */ -size_t uxStreamBufferAdd( StreamBuffer_t *pxBuffer, size_t uxOffset, const uint8_t *pucData, size_t uxCount ); - -/* - * Read bytes from a stream buffer. - * - * pxBuffer - The buffer from which the bytes will be read. - * uxOffset - Can be used to read data located at a certain offset from 'uxTail'. - * pucData - A pointer to the buffer into which data will be read. - * uxMaxCount - The number of bytes to read. - * xPeek - If set to pdTRUE the data will remain in the buffer. - */ -size_t uxStreamBufferGet( StreamBuffer_t *pxBuffer, size_t uxOffset, uint8_t *pucData, size_t uxMaxCount, BaseType_t xPeek ); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* !defined( FREERTOS_STREAM_BUFFER_H ) */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_TCP_IP.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_TCP_IP.h deleted file mode 100755 index f792c8a..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_TCP_IP.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -#ifndef FREERTOS_TCP_IP_H -#define FREERTOS_TCP_IP_H - -#ifdef __cplusplus -extern "C" { -#endif - -BaseType_t xProcessReceivedTCPPacket( NetworkBufferDescriptor_t *pxNetworkBuffer ); - -typedef enum eTCP_STATE { - /* Comments about the TCP states are borrowed from the very useful - * Wiki page: - * http://en.wikipedia.org/wiki/Transmission_Control_Protocol */ - eCLOSED = 0u, /* 0 (server + client) no connection state at all. */ - eTCP_LISTEN, /* 1 (server) waiting for a connection request - from any remote TCP and port. */ - eCONNECT_SYN, /* 2 (client) internal state: socket wants to send - a connect */ - eSYN_FIRST, /* 3 (server) Just created, must ACK the SYN request. */ - eSYN_RECEIVED, /* 4 (server) waiting for a confirming connection request - acknowledgement after having both received and sent a connection request. */ - eESTABLISHED, /* 5 (server + client) an open connection, data received can be - delivered to the user. The normal state for the data transfer phase of the connection. */ - eFIN_WAIT_1, /* 6 (server + client) waiting for a connection termination request from the remote TCP, - or an acknowledgement of the connection termination request previously sent. */ - eFIN_WAIT_2, /* 7 (server + client) waiting for a connection termination request from the remote TCP. */ - eCLOSE_WAIT, /* 8 (server + client) waiting for a connection termination request from the local user. */ - eCLOSING, /* (server + client) waiting for a connection termination request acknowledgement from the remote TCP. */ - eLAST_ACK, /* 9 (server + client) waiting for an acknowledgement of the connection termination request - previously sent to the remote TCP - (which includes an acknowledgement of its connection termination request). */ - eTIME_WAIT, /* 10 (either server or client) waiting for enough time to pass to be sure the remote TCP received the - acknowledgement of its connection termination request. [According to RFC 793 a connection can - stay in TIME-WAIT for a maximum of four minutes known as a MSL (maximum segment lifetime).] */ -} eIPTCPState_t; - - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif /* FREERTOS_TCP_IP_H */ - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_TCP_WIN.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_TCP_WIN.h deleted file mode 100755 index 5019665..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_TCP_WIN.h +++ /dev/null @@ -1,210 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -/* - * FreeRTOS_TCP_WIN.c - * Module which handles the TCP windowing schemes for FreeRTOS-PLUS-TCP - */ - -#ifndef FREERTOS_TCP_WIN_H -#define FREERTOS_TCP_WIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -extern BaseType_t xTCPWindowLoggingLevel; - -typedef struct xTCPTimer -{ - uint32_t ulBorn; -} TCPTimer_t; - -typedef struct xTCP_SEGMENT -{ - uint32_t ulSequenceNumber; /* The sequence number of the first byte in this packet */ - int32_t lMaxLength; /* Maximum space, number of bytes which can be stored in this segment */ - int32_t lDataLength; /* Actual number of bytes */ - int32_t lStreamPos; /* reference to the [t|r]xStream of the socket */ - TCPTimer_t xTransmitTimer; /* saves a timestamp at the moment this segment gets transmitted (TX only) */ - union - { - struct - { - uint32_t - ucTransmitCount : 8,/* Number of times the segment has been transmitted, used to calculate the RTT */ - ucDupAckCount : 8, /* Counts the number of times that a higher segment was ACK'd. After 3 times a Fast Retransmission takes place */ - bOutstanding : 1, /* It the peer's turn, we're just waiting for an ACK */ - bAcked : 1, /* This segment has been acknowledged */ - bIsForRx : 1; /* pdTRUE if segment is used for reception */ - } bits; - uint32_t ulFlags; - } u; -#if( ipconfigUSE_TCP_WIN != 0 ) - struct xLIST_ITEM xQueueItem; /* TX only: segments can be linked in one of three queues: xPriorityQueue, xTxQueue, and xWaitQueue */ - struct xLIST_ITEM xListItem; /* With this item the segment can be connected to a list, depending on who is owning it */ -#endif -} TCPSegment_t; - -typedef struct xTCP_WINSIZE -{ - uint32_t ulRxWindowLength; - uint32_t ulTxWindowLength; -} TCPWinSize_t; - -/* - * If TCP time-stamps are being used, they will occupy 12 bytes in - * each packet, and thus the message space will become smaller - */ -/* Keep this as a multiple of 4 */ -#if( ipconfigUSE_TCP_WIN == 1 ) - #define ipSIZE_TCP_OPTIONS 16u -#else - #define ipSIZE_TCP_OPTIONS 12u -#endif - -/* - * Every TCP connection owns a TCP window for the administration of all packets - * It owns two sets of segment descriptors, incoming and outgoing - */ -typedef struct xTCP_WINDOW -{ - union - { - struct - { - uint32_t - bHasInit : 1, /* The window structure has been initialised */ - bSendFullSize : 1, /* May only send packets with a size equal to MSS (for optimisation) */ - bTimeStamps : 1; /* Socket is supposed to use TCP time-stamps. This depends on the */ - } bits; /* party which opens the connection */ - uint32_t ulFlags; - } u; - TCPWinSize_t xSize; - struct - { - uint32_t ulFirstSequenceNumber; /* Logging & debug: the first segment received/sent in this connection - * for Tx: initial send sequence number (ISS) - * for Rx: initial receive sequence number (IRS) */ - uint32_t ulCurrentSequenceNumber;/* Tx/Rx: the oldest sequence number not yet confirmed, also SND.UNA / RCV.NXT - * In other words: the sequence number of the left side of the sliding window */ - uint32_t ulFINSequenceNumber; /* The sequence number which carried the FIN flag */ - uint32_t ulHighestSequenceNumber;/* Sequence number of the right-most byte + 1 */ - } rx, tx; - uint32_t ulOurSequenceNumber; /* The SEQ number we're sending out */ - uint32_t ulUserDataLength; /* Number of bytes in Rx buffer which may be passed to the user, after having received a 'missing packet' */ - uint32_t ulNextTxSequenceNumber; /* The sequence number given to the next byte to be added for transmission */ - int32_t lSRTT; /* Smoothed Round Trip Time, it may increment quickly and it decrements slower */ - uint8_t ucOptionLength; /* Number of valid bytes in ulOptionsData[] */ -#if( ipconfigUSE_TCP_WIN == 1 ) - List_t xPriorityQueue; /* Priority queue: segments which must be sent immediately */ - List_t xTxQueue; /* Transmit queue: segments queued for transmission */ - List_t xWaitQueue; /* Waiting queue: outstanding segments */ - TCPSegment_t *pxHeadSegment; /* points to a segment which has not been transmitted and it's size is still growing (user data being added) */ - uint32_t ulOptionsData[ipSIZE_TCP_OPTIONS/sizeof(uint32_t)]; /* Contains the options we send out */ - List_t xTxSegments; /* A linked list of all transmission segments, sorted on sequence number */ - List_t xRxSegments; /* A linked list of reception segments, order depends on sequence of arrival */ -#else - /* For tiny TCP, there is only 1 outstanding TX segment */ - TCPSegment_t xTxSegment; /* Priority queue */ -#endif - uint16_t usOurPortNumber; /* Mostly for debugging/logging: our TCP port number */ - uint16_t usPeerPortNumber; /* debugging/logging: the peer's TCP port number */ - uint16_t usMSS; /* Current accepted MSS */ - uint16_t usMSSInit; /* MSS as configured by the socket owner */ -} TCPWindow_t; - - -/*============================================================================= - * - * Creation and destruction - * - *=============================================================================*/ - -/* Create and initialize a window */ -void vTCPWindowCreate( TCPWindow_t *pxWindow, uint32_t ulRxWindowLength, - uint32_t ulTxWindowLength, uint32_t ulAckNumber, uint32_t ulSequenceNumber, uint32_t ulMSS ); - -/* Destroy a window (always returns NULL) - * It will free some resources: a collection of segments */ -void vTCPWindowDestroy( TCPWindow_t *pxWindow ); - -/* Initialize a window */ -void vTCPWindowInit( TCPWindow_t *pxWindow, uint32_t ulAckNumber, uint32_t ulSequenceNumber, uint32_t ulMSS ); - -/*============================================================================= - * - * Rx functions - * - *=============================================================================*/ - -/* if true may be passed directly to user (segment expected and window is empty) - * But pxWindow->ackno should always be used to set "BUF->ackno" */ -int32_t lTCPWindowRxCheck( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber, uint32_t ulLength, uint32_t ulSpace ); - -/* When lTCPWindowRxCheck returned false, please call store for this unexpected data */ -BaseType_t xTCPWindowRxStore( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber, uint32_t ulLength ); - -/* This function will be called as soon as a FIN is received. It will return true - * if there are no 'open' reception segments */ -BaseType_t xTCPWindowRxEmpty( TCPWindow_t *pxWindow ); - -/* _HT_ Temporary function for testing/debugging - * Not used at this moment */ -void vTCPWinShowSegments( TCPWindow_t *pxWindow, BaseType_t bForRx ); - -/*============================================================================= - * - * Tx functions - * - *=============================================================================*/ - -/* Adds data to the Tx-window */ -int32_t lTCPWindowTxAdd( TCPWindow_t *pxWindow, uint32_t ulLength, int32_t lPosition, int32_t lMax ); - -/* Check data to be sent and calculate the time period we may sleep */ -BaseType_t xTCPWindowTxHasData( TCPWindow_t *pxWindow, uint32_t ulWindowSize, TickType_t *pulDelay ); - -/* See if anything is left to be sent - * Function will be called when a FIN has been received. Only when the TX window is clean, - * it will return pdTRUE */ -BaseType_t xTCPWindowTxDone( TCPWindow_t *pxWindow ); - -/* Fetches data to be sent. - * apPos will point to a location with the circular data buffer: txStream */ -uint32_t ulTCPWindowTxGet( TCPWindow_t *pxWindow, uint32_t ulWindowSize, int32_t *plPosition ); - -/* Receive a normal ACK */ -uint32_t ulTCPWindowTxAck( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber ); - -/* Receive a SACK option */ -uint32_t ulTCPWindowTxSack( TCPWindow_t *pxWindow, uint32_t ulFirst, uint32_t ulLast ); - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* FREERTOS_TCP_WIN_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_errno_TCP.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_errno_TCP.h deleted file mode 100755 index 71020bd..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_errno_TCP.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -#ifndef FREERTOS_ERRNO_TCP -#define FREERTOS_ERRNO_TCP - -/* The following definitions will be included in the core FreeRTOS code in -future versions of FreeRTOS - hence the 'pd' (ProjDefs) prefix - at which time -this file will be removed. */ - -/* The following errno values are used by FreeRTOS+ components, not FreeRTOS -itself. */ - -/* For future compatibility (see comment above), check the definitions have not -already been made. */ -#ifndef pdFREERTOS_ERRNO_NONE - #define pdFREERTOS_ERRNO_NONE 0 /* No errors */ - #define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ - #define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ - #define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ - #define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ - #define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ - #define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ - #define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ - #define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ - #define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ - #define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ - #define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ - #define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ - #define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ - #define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ - #define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ - #define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ - #define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ - #define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ - #define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ - #define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ - #define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ - #define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ - #define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ - #define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ - #define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ - #define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ - #define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ - #define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ - #define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ - #define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ - #define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ - #define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ - #define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ - #define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ - #define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ - #define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ - #define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ - #define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ - #define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ - - /* The following endian values are used by FreeRTOS+ components, not FreeRTOS - itself. */ - #define pdFREERTOS_LITTLE_ENDIAN 0 - #define pdFREERTOS_BIG_ENDIAN 1 - -#endif /* pdFREERTOS_ERRNO_NONE */ - -#endif /* FREERTOS_ERRNO_TCP */ - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/IPTraceMacroDefaults.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/IPTraceMacroDefaults.h deleted file mode 100755 index e9ad503..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/IPTraceMacroDefaults.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -/* This file provides default (empty) implementations for any IP trace macros -that are not defined by the user. See -http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Trace.html */ - -#ifndef UDP_TRACE_MACRO_DEFAULTS_H -#define UDP_TRACE_MACRO_DEFAULTS_H - -#ifndef iptraceNETWORK_DOWN - #define iptraceNETWORK_DOWN() -#endif - -#ifndef iptraceNETWORK_BUFFER_RELEASED - #define iptraceNETWORK_BUFFER_RELEASED( pxBufferAddress ) -#endif - -#ifndef iptraceNETWORK_BUFFER_OBTAINED - #define iptraceNETWORK_BUFFER_OBTAINED( pxBufferAddress ) -#endif - -#ifndef iptraceNETWORK_BUFFER_OBTAINED_FROM_ISR - #define iptraceNETWORK_BUFFER_OBTAINED_FROM_ISR( pxBufferAddress ) -#endif - -#ifndef iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER - #define iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER() -#endif - -#ifndef iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER_FROM_ISR - #define iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER_FROM_ISR() -#endif - -#ifndef iptraceCREATING_ARP_REQUEST - #define iptraceCREATING_ARP_REQUEST( ulIPAddress ) -#endif - -#ifndef iptraceARP_TABLE_ENTRY_WILL_EXPIRE - #define iptraceARP_TABLE_ENTRY_WILL_EXPIRE( ulIPAddress ) -#endif - -#ifndef iptraceARP_TABLE_ENTRY_EXPIRED - #define iptraceARP_TABLE_ENTRY_EXPIRED( ulIPAddress ) -#endif - -#ifndef iptraceARP_TABLE_ENTRY_CREATED - #define iptraceARP_TABLE_ENTRY_CREATED( ulIPAddress, ucMACAddress ) -#endif - -#ifndef iptraceSENDING_UDP_PACKET - #define iptraceSENDING_UDP_PACKET( ulIPAddress ) -#endif - -#ifndef iptracePACKET_DROPPED_TO_GENERATE_ARP - #define iptracePACKET_DROPPED_TO_GENERATE_ARP( ulIPAddress ) -#endif - -#ifndef iptraceICMP_PACKET_RECEIVED - #define iptraceICMP_PACKET_RECEIVED() -#endif - -#ifndef iptraceSENDING_PING_REPLY - #define iptraceSENDING_PING_REPLY( ulIPAddress ) -#endif - -#ifndef traceARP_PACKET_RECEIVED - #define traceARP_PACKET_RECEIVED() -#endif - -#ifndef iptracePROCESSING_RECEIVED_ARP_REPLY - #define iptracePROCESSING_RECEIVED_ARP_REPLY( ulIPAddress ) -#endif - -#ifndef iptraceSENDING_ARP_REPLY - #define iptraceSENDING_ARP_REPLY( ulIPAddress ) -#endif - -#ifndef iptraceFAILED_TO_CREATE_SOCKET - #define iptraceFAILED_TO_CREATE_SOCKET() -#endif - -#ifndef iptraceFAILED_TO_CREATE_EVENT_GROUP - #define iptraceFAILED_TO_CREATE_EVENT_GROUP() -#endif - -#ifndef iptraceRECVFROM_DISCARDING_BYTES - #define iptraceRECVFROM_DISCARDING_BYTES( xNumberOfBytesDiscarded ) -#endif - -#ifndef iptraceETHERNET_RX_EVENT_LOST - #define iptraceETHERNET_RX_EVENT_LOST() -#endif - -#ifndef iptraceSTACK_TX_EVENT_LOST - #define iptraceSTACK_TX_EVENT_LOST( xEvent ) -#endif - -#ifndef iptraceNETWORK_EVENT_RECEIVED - #define iptraceNETWORK_EVENT_RECEIVED( eEvent ) -#endif - -#ifndef iptraceBIND_FAILED - #define iptraceBIND_FAILED( xSocket, usPort ) -#endif - -#ifndef iptraceDHCP_REQUESTS_FAILED_USING_DEFAULT_IP_ADDRESS - #define iptraceDHCP_REQUESTS_FAILED_USING_DEFAULT_IP_ADDRESS( ulIPAddress ) -#endif - -#ifndef iptraceSENDING_DHCP_DISCOVER - #define iptraceSENDING_DHCP_DISCOVER() -#endif - -#ifndef iptraceSENDING_DHCP_REQUEST - #define iptraceSENDING_DHCP_REQUEST() -#endif - -#ifndef iptraceDHCP_SUCCEDEED - #define iptraceDHCP_SUCCEDEED( address ) -#endif - -#ifndef iptraceNETWORK_INTERFACE_TRANSMIT - #define iptraceNETWORK_INTERFACE_TRANSMIT() -#endif - -#ifndef iptraceNETWORK_INTERFACE_RECEIVE - #define iptraceNETWORK_INTERFACE_RECEIVE() -#endif - -#ifndef iptraceSENDING_DNS_REQUEST - #define iptraceSENDING_DNS_REQUEST() -#endif - -#ifndef iptraceWAITING_FOR_TX_DMA_DESCRIPTOR - #define iptraceWAITING_FOR_TX_DMA_DESCRIPTOR() -#endif - -#ifndef ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS - #define ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS 0 -#endif - -#ifndef iptraceFAILED_TO_NOTIFY_SELECT_GROUP - #define iptraceFAILED_TO_NOTIFY_SELECT_GROUP( xSocket ) -#endif - -#ifndef pvPortMallocSocket - #define pvPortMallocSocket(xSize) pvPortMalloc( ( xSize ) ) -#endif - -#ifndef iptraceRECVFROM_TIMEOUT - #define iptraceRECVFROM_TIMEOUT() -#endif - -#ifndef iptraceRECVFROM_INTERRUPTED - #define iptraceRECVFROM_INTERRUPTED() -#endif - -#ifndef iptraceNO_BUFFER_FOR_SENDTO - #define iptraceNO_BUFFER_FOR_SENDTO() -#endif - -#ifndef iptraceSENDTO_SOCKET_NOT_BOUND - #define iptraceSENDTO_SOCKET_NOT_BOUND() -#endif - -#ifndef iptraceSENDTO_DATA_TOO_LONG - #define iptraceSENDTO_DATA_TOO_LONG() -#endif - -#endif /* UDP_TRACE_MACRO_DEFAULTS_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/NetworkBufferManagement.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/NetworkBufferManagement.h deleted file mode 100755 index ededc40..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/NetworkBufferManagement.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - -#ifndef NETWORK_BUFFER_MANAGEMENT_H -#define NETWORK_BUFFER_MANAGEMENT_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* NOTE PUBLIC API FUNCTIONS. */ -BaseType_t xNetworkBuffersInitialise( void ); -NetworkBufferDescriptor_t *pxGetNetworkBufferWithDescriptor( size_t xRequestedSizeBytes, TickType_t xBlockTimeTicks ); -NetworkBufferDescriptor_t *pxNetworkBufferGetFromISR( size_t xRequestedSizeBytes ); -void vReleaseNetworkBufferAndDescriptor( NetworkBufferDescriptor_t * const pxNetworkBuffer ); -BaseType_t vNetworkBufferReleaseFromISR( NetworkBufferDescriptor_t * const pxNetworkBuffer ); -uint8_t *pucGetNetworkBuffer( size_t *pxRequestedSizeBytes ); -void vReleaseNetworkBuffer( uint8_t *pucEthernetBuffer ); - -/* Get the current number of free network buffers. */ -UBaseType_t uxGetNumberOfFreeNetworkBuffers( void ); - -/* Get the lowest number of free network buffers. */ -UBaseType_t uxGetMinimumFreeNetworkBuffers( void ); - -/* Copy a network buffer into a bigger buffer. */ -NetworkBufferDescriptor_t *pxDuplicateNetworkBufferWithDescriptor( NetworkBufferDescriptor_t * const pxNetworkBuffer, - BaseType_t xNewLength); - -/* Increase the size of a Network Buffer. -In case BufferAllocation_2.c is used, the new space must be allocated. */ -NetworkBufferDescriptor_t *pxResizeNetworkBufferWithDescriptor( NetworkBufferDescriptor_t * pxNetworkBuffer, - size_t xNewSizeBytes ); - -#if ipconfigTCP_IP_SANITY - /* - * Check if an address is a valid pointer to a network descriptor - * by looking it up in the array of network descriptors - */ - UBaseType_t bIsValidNetworkDescriptor (const NetworkBufferDescriptor_t * pxDesc); - BaseType_t prvIsFreeBuffer( const NetworkBufferDescriptor_t *pxDescr ); -#endif - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif /* NETWORK_BUFFER_MANAGEMENT_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/BufferManagement/BufferAllocation_1.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/BufferManagement/BufferAllocation_1.c deleted file mode 100755 index e1fa9a7..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/BufferManagement/BufferAllocation_1.c +++ /dev/null @@ -1,423 +0,0 @@ -/* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - http://aws.amazon.com/freertos - http://www.FreeRTOS.org -*/ - -/****************************************************************************** - * - * See the following web page for essential buffer allocation scheme usage and - * configuration details: - * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Ethernet_Buffer_Management.html - * - ******************************************************************************/ - -/* Standard includes. */ -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_IP_Private.h" -#include "NetworkInterface.h" -#include "NetworkBufferManagement.h" - -/* For an Ethernet interrupt to be able to obtain a network buffer there must -be at least this number of buffers available. */ -#define baINTERRUPT_BUFFER_GET_THRESHOLD ( 3 ) - -/* A list of free (available) NetworkBufferDescriptor_t structures. */ -static List_t xFreeBuffersList; - -/* Some statistics about the use of buffers. */ -static UBaseType_t uxMinimumFreeNetworkBuffers = 0u; - -/* Declares the pool of NetworkBufferDescriptor_t structures that are available -to the system. All the network buffers referenced from xFreeBuffersList exist -in this array. The array is not accessed directly except during initialisation, -when the xFreeBuffersList is filled (as all the buffers are free when the system -is booted). */ -static NetworkBufferDescriptor_t xNetworkBuffers[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ]; - -/* This constant is defined as true to let FreeRTOS_TCP_IP.c know that the -network buffers have constant size, large enough to hold the biggest Ethernet -packet. No resizing will be done. */ -const BaseType_t xBufferAllocFixedSize = pdTRUE; - -/* The semaphore used to obtain network buffers. */ -static SemaphoreHandle_t xNetworkBufferSemaphore = NULL; - -#if( ipconfigTCP_IP_SANITY != 0 ) - static char cIsLow = pdFALSE; - UBaseType_t bIsValidNetworkDescriptor( const NetworkBufferDescriptor_t * pxDesc ); -#else - static UBaseType_t bIsValidNetworkDescriptor( const NetworkBufferDescriptor_t * pxDesc ); -#endif /* ipconfigTCP_IP_SANITY */ - -static void prvShowWarnings( void ); - -/* The user can define their own ipconfigBUFFER_ALLOC_LOCK() and -ipconfigBUFFER_ALLOC_UNLOCK() macros, especially for use form an ISR. If these -are not defined then default them to call the normal enter/exit critical -section macros. */ -#if !defined( ipconfigBUFFER_ALLOC_LOCK ) - - #define ipconfigBUFFER_ALLOC_INIT( ) do {} while (0) - #define ipconfigBUFFER_ALLOC_LOCK_FROM_ISR() \ - UBaseType_t uxSavedInterruptStatus = ( UBaseType_t ) portSET_INTERRUPT_MASK_FROM_ISR(); \ - { - - #define ipconfigBUFFER_ALLOC_UNLOCK_FROM_ISR() \ - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); \ - } - - #define ipconfigBUFFER_ALLOC_LOCK() taskENTER_CRITICAL() - #define ipconfigBUFFER_ALLOC_UNLOCK() taskEXIT_CRITICAL() - -#endif /* ipconfigBUFFER_ALLOC_LOCK */ - -/*-----------------------------------------------------------*/ - -#if( ipconfigTCP_IP_SANITY != 0 ) - - /* HT: SANITY code will be removed as soon as the library is stable - * and and ready to become public - * Function below gives information about the use of buffers */ - #define WARN_LOW ( 2 ) - #define WARN_HIGH ( ( 5 * ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ) / 10 ) - -#endif /* ipconfigTCP_IP_SANITY */ - -/*-----------------------------------------------------------*/ - -#if( ipconfigTCP_IP_SANITY != 0 ) - - BaseType_t prvIsFreeBuffer( const NetworkBufferDescriptor_t *pxDescr ) - { - return ( bIsValidNetworkDescriptor( pxDescr ) != 0 ) && - ( listIS_CONTAINED_WITHIN( &xFreeBuffersList, &( pxDescr->xBufferListItem ) ) != 0 ); - } - /*-----------------------------------------------------------*/ - - static void prvShowWarnings( void ) - { - UBaseType_t uxCount = uxGetNumberOfFreeNetworkBuffers( ); - if( ( ( cIsLow == 0 ) && ( uxCount <= WARN_LOW ) ) || ( ( cIsLow != 0 ) && ( uxCount >= WARN_HIGH ) ) ) - { - cIsLow = !cIsLow; - FreeRTOS_debug_printf( ( "*** Warning *** %s %lu buffers left\n", cIsLow ? "only" : "now", uxCount ) ); - } - } - /*-----------------------------------------------------------*/ - - UBaseType_t bIsValidNetworkDescriptor( const NetworkBufferDescriptor_t * pxDesc ) - { - uint32_t offset = ( uint32_t ) ( ((const char *)pxDesc) - ((const char *)xNetworkBuffers) ); - if( ( offset >= sizeof( xNetworkBuffers ) ) || - ( ( offset % sizeof( xNetworkBuffers[0] ) ) != 0 ) ) - return pdFALSE; - return (UBaseType_t) (pxDesc - xNetworkBuffers) + 1; - } - /*-----------------------------------------------------------*/ - -#else - static UBaseType_t bIsValidNetworkDescriptor (const NetworkBufferDescriptor_t * pxDesc) - { - ( void ) pxDesc; - return ( UBaseType_t ) pdTRUE; - } - /*-----------------------------------------------------------*/ - - static void prvShowWarnings( void ) - { - } - /*-----------------------------------------------------------*/ - -#endif /* ipconfigTCP_IP_SANITY */ - -BaseType_t xNetworkBuffersInitialise( void ) -{ -BaseType_t xReturn, x; - - /* Only initialise the buffers and their associated kernel objects if they - have not been initialised before. */ - if( xNetworkBufferSemaphore == NULL ) - { - /* In case alternative locking is used, the mutexes can be initialised - here */ - ipconfigBUFFER_ALLOC_INIT(); - - xNetworkBufferSemaphore = xSemaphoreCreateCounting( ( UBaseType_t ) ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, ( UBaseType_t ) ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ); - configASSERT( xNetworkBufferSemaphore ); - - if( xNetworkBufferSemaphore != NULL ) - { - vListInitialise( &xFreeBuffersList ); - - /* Initialise all the network buffers. The buffer storage comes - from the network interface, and different hardware has different - requirements. */ - vNetworkInterfaceAllocateRAMToBuffers( xNetworkBuffers ); - for( x = 0; x < ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS; x++ ) - { - /* Initialise and set the owner of the buffer list items. */ - vListInitialiseItem( &( xNetworkBuffers[ x ].xBufferListItem ) ); - listSET_LIST_ITEM_OWNER( &( xNetworkBuffers[ x ].xBufferListItem ), &xNetworkBuffers[ x ] ); - - /* Currently, all buffers are available for use. */ - vListInsert( &xFreeBuffersList, &( xNetworkBuffers[ x ].xBufferListItem ) ); - } - - uxMinimumFreeNetworkBuffers = ( UBaseType_t ) ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS; - } - } - - if( xNetworkBufferSemaphore == NULL ) - { - xReturn = pdFAIL; - } - else - { - xReturn = pdPASS; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -NetworkBufferDescriptor_t *pxGetNetworkBufferWithDescriptor( size_t xRequestedSizeBytes, TickType_t xBlockTimeTicks ) -{ -NetworkBufferDescriptor_t *pxReturn = NULL; -BaseType_t xInvalid = pdFALSE; -UBaseType_t uxCount; - - /* The current implementation only has a single size memory block, so - the requested size parameter is not used (yet). */ - ( void ) xRequestedSizeBytes; - - if( xNetworkBufferSemaphore != NULL ) - { - /* If there is a semaphore available, there is a network buffer - available. */ - if( xSemaphoreTake( xNetworkBufferSemaphore, xBlockTimeTicks ) == pdPASS ) - { - /* Protect the structure as they are accessed from tasks and - interrupts. */ - ipconfigBUFFER_ALLOC_LOCK(); - { - pxReturn = ( NetworkBufferDescriptor_t * ) listGET_OWNER_OF_HEAD_ENTRY( &xFreeBuffersList ); - - if( ( bIsValidNetworkDescriptor( pxReturn ) != pdFALSE_UNSIGNED ) && - listIS_CONTAINED_WITHIN( &xFreeBuffersList, &( pxReturn->xBufferListItem ) ) ) - { - uxListRemove( &( pxReturn->xBufferListItem ) ); - } - else - { - xInvalid = pdTRUE; - } - } - ipconfigBUFFER_ALLOC_UNLOCK(); - - if( xInvalid == pdTRUE ) - { - /* _RB_ Can printf() be called from an interrupt? (comment - above says this can be called from an interrupt too) */ - /* _HT_ The function shall not be called from an ISR. Comment - was indeed misleading. Hopefully clear now? - So the printf()is OK here. */ - FreeRTOS_debug_printf( ( "pxGetNetworkBufferWithDescriptor: INVALID BUFFER: %p (valid %lu)\n", - pxReturn, bIsValidNetworkDescriptor( pxReturn ) ) ); - pxReturn = NULL; - } - else - { - /* Reading UBaseType_t, no critical section needed. */ - uxCount = listCURRENT_LIST_LENGTH( &xFreeBuffersList ); - - /* For stats, latch the lowest number of network buffers since - booting. */ - if( uxMinimumFreeNetworkBuffers > uxCount ) - { - uxMinimumFreeNetworkBuffers = uxCount; - } - - pxReturn->xDataLength = xRequestedSizeBytes; - - #if( ipconfigTCP_IP_SANITY != 0 ) - { - prvShowWarnings(); - } - #endif /* ipconfigTCP_IP_SANITY */ - - #if( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) - { - /* make sure the buffer is not linked */ - pxReturn->pxNextBuffer = NULL; - } - #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ - - if( xTCPWindowLoggingLevel > 3 ) - { - FreeRTOS_debug_printf( ( "BUF_GET[%ld]: %p (%p)\n", - bIsValidNetworkDescriptor( pxReturn ), - pxReturn, pxReturn->pucEthernetBuffer ) ); - } - } - iptraceNETWORK_BUFFER_OBTAINED( pxReturn ); - } - else - { - iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER(); - } - } - - return pxReturn; -} -/*-----------------------------------------------------------*/ - -NetworkBufferDescriptor_t *pxNetworkBufferGetFromISR( size_t xRequestedSizeBytes ) -{ -NetworkBufferDescriptor_t *pxReturn = NULL; - - /* The current implementation only has a single size memory block, so - the requested size parameter is not used (yet). */ - ( void ) xRequestedSizeBytes; - - /* If there is a semaphore available then there is a buffer available, but, - as this is called from an interrupt, only take a buffer if there are at - least baINTERRUPT_BUFFER_GET_THRESHOLD buffers remaining. This prevents, - to a certain degree at least, a rapidly executing interrupt exhausting - buffer and in so doing preventing tasks from continuing. */ - if( uxQueueMessagesWaitingFromISR( ( QueueHandle_t ) xNetworkBufferSemaphore ) > ( UBaseType_t ) baINTERRUPT_BUFFER_GET_THRESHOLD ) - { - if( xSemaphoreTakeFromISR( xNetworkBufferSemaphore, NULL ) == pdPASS ) - { - /* Protect the structure as it is accessed from tasks and interrupts. */ - ipconfigBUFFER_ALLOC_LOCK_FROM_ISR(); - { - pxReturn = ( NetworkBufferDescriptor_t * ) listGET_OWNER_OF_HEAD_ENTRY( &xFreeBuffersList ); - uxListRemove( &( pxReturn->xBufferListItem ) ); - } - ipconfigBUFFER_ALLOC_UNLOCK_FROM_ISR(); - - iptraceNETWORK_BUFFER_OBTAINED_FROM_ISR( pxReturn ); - } - } - - if( pxReturn == NULL ) - { - iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER_FROM_ISR(); - } - - return pxReturn; -} -/*-----------------------------------------------------------*/ - -BaseType_t vNetworkBufferReleaseFromISR( NetworkBufferDescriptor_t * const pxNetworkBuffer ) -{ -BaseType_t xHigherPriorityTaskWoken = pdFALSE; - - /* Ensure the buffer is returned to the list of free buffers before the - counting semaphore is 'given' to say a buffer is available. */ - ipconfigBUFFER_ALLOC_LOCK_FROM_ISR(); - { - vListInsertEnd( &xFreeBuffersList, &( pxNetworkBuffer->xBufferListItem ) ); - } - ipconfigBUFFER_ALLOC_UNLOCK_FROM_ISR(); - - xSemaphoreGiveFromISR( xNetworkBufferSemaphore, &xHigherPriorityTaskWoken ); - iptraceNETWORK_BUFFER_RELEASED( pxNetworkBuffer ); - - return xHigherPriorityTaskWoken; -} -/*-----------------------------------------------------------*/ - -void vReleaseNetworkBufferAndDescriptor( NetworkBufferDescriptor_t * const pxNetworkBuffer ) -{ -BaseType_t xListItemAlreadyInFreeList; - - if( bIsValidNetworkDescriptor( pxNetworkBuffer ) == pdFALSE_UNSIGNED ) - { - FreeRTOS_debug_printf( ( "vReleaseNetworkBufferAndDescriptor: Invalid buffer %p\n", pxNetworkBuffer ) ); - return ; - } - /* Ensure the buffer is returned to the list of free buffers before the - counting semaphore is 'given' to say a buffer is available. */ - ipconfigBUFFER_ALLOC_LOCK(); - { - { - xListItemAlreadyInFreeList = listIS_CONTAINED_WITHIN( &xFreeBuffersList, &( pxNetworkBuffer->xBufferListItem ) ); - - if( xListItemAlreadyInFreeList == pdFALSE ) - { - vListInsertEnd( &xFreeBuffersList, &( pxNetworkBuffer->xBufferListItem ) ); - } - } - } - ipconfigBUFFER_ALLOC_UNLOCK(); - - if( xListItemAlreadyInFreeList ) - { - FreeRTOS_debug_printf( ( "vReleaseNetworkBufferAndDescriptor: %p ALREADY RELEASED (now %lu)\n", - pxNetworkBuffer, uxGetNumberOfFreeNetworkBuffers( ) ) ); - } - if( xListItemAlreadyInFreeList == pdFALSE ) - { - xSemaphoreGive( xNetworkBufferSemaphore ); - prvShowWarnings(); - if( xTCPWindowLoggingLevel > 3 ) - FreeRTOS_debug_printf( ( "BUF_PUT[%ld]: %p (%p) (now %lu)\n", - bIsValidNetworkDescriptor( pxNetworkBuffer ), - pxNetworkBuffer, pxNetworkBuffer->pucEthernetBuffer, - uxGetNumberOfFreeNetworkBuffers( ) ) ); - } - iptraceNETWORK_BUFFER_RELEASED( pxNetworkBuffer ); -} -/*-----------------------------------------------------------*/ - -UBaseType_t uxGetMinimumFreeNetworkBuffers( void ) -{ - return uxMinimumFreeNetworkBuffers; -} -/*-----------------------------------------------------------*/ - -UBaseType_t uxGetNumberOfFreeNetworkBuffers( void ) -{ - return listCURRENT_LIST_LENGTH( &xFreeBuffersList ); -} - -NetworkBufferDescriptor_t *pxResizeNetworkBufferWithDescriptor( NetworkBufferDescriptor_t * pxNetworkBuffer, size_t xNewSizeBytes ) -{ - /* In BufferAllocation_1.c all network buffer are allocated with a - maximum size of 'ipTOTAL_ETHERNET_FRAME_SIZE'.No need to resize the - network buffer. */ - ( void ) xNewSizeBytes; - return pxNetworkBuffer; -} - -/*#endif */ /* ipconfigINCLUDE_TEST_CODE */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/BufferManagement/BufferAllocation_2.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/BufferManagement/BufferAllocation_2.c deleted file mode 100755 index 415aeb3..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/BufferManagement/BufferAllocation_2.c +++ /dev/null @@ -1,390 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ - -/****************************************************************************** - * - * See the following web page for essential buffer allocation scheme usage and - * configuration details: - * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Ethernet_Buffer_Management.html - * - ******************************************************************************/ - -/* THIS FILE SHOULD NOT BE USED IF THE PROJECT INCLUDES A MEMORY ALLOCATOR -THAT WILL FRAGMENT THE HEAP MEMORY. For example, heap_2 must not be used, -heap_4 can be used. */ - - -/* Standard includes. */ -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_IP_Private.h" -#include "NetworkInterface.h" -#include "NetworkBufferManagement.h" - -/* The obtained network buffer must be large enough to hold a packet that might -replace the packet that was requested to be sent. */ -#if ipconfigUSE_TCP == 1 - #define baMINIMAL_BUFFER_SIZE sizeof( TCPPacket_t ) -#else - #define baMINIMAL_BUFFER_SIZE sizeof( ARPPacket_t ) -#endif /* ipconfigUSE_TCP == 1 */ - -/*_RB_ This is too complex not to have an explanation. */ -#if defined( ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - #define ASSERT_CONCAT_(a, b) a##b - #define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b) - #define STATIC_ASSERT(e) \ - ;enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(e)) } - - STATIC_ASSERT( ipconfigETHERNET_MINIMUM_PACKET_BYTES <= baMINIMAL_BUFFER_SIZE ); -#endif - -/* A list of free (available) NetworkBufferDescriptor_t structures. */ -static List_t xFreeBuffersList; - -/* Some statistics about the use of buffers. */ -static size_t uxMinimumFreeNetworkBuffers; - -/* Declares the pool of NetworkBufferDescriptor_t structures that are available -to the system. All the network buffers referenced from xFreeBuffersList exist -in this array. The array is not accessed directly except during initialisation, -when the xFreeBuffersList is filled (as all the buffers are free when the system -is booted). */ -static NetworkBufferDescriptor_t xNetworkBufferDescriptors[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ]; - -/* This constant is defined as false to let FreeRTOS_TCP_IP.c know that the -network buffers have a variable size: resizing may be necessary */ -const BaseType_t xBufferAllocFixedSize = pdFALSE; - -/* The semaphore used to obtain network buffers. */ -static SemaphoreHandle_t xNetworkBufferSemaphore = NULL; - -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkBuffersInitialise( void ) -{ -BaseType_t xReturn, x; - - /* Only initialise the buffers and their associated kernel objects if they - have not been initialised before. */ - if( xNetworkBufferSemaphore == NULL ) - { - xNetworkBufferSemaphore = xSemaphoreCreateCounting( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ); - configASSERT( xNetworkBufferSemaphore ); - - if( xNetworkBufferSemaphore != NULL ) - { - #if ( configQUEUE_REGISTRY_SIZE > 0 ) - { - vQueueAddToRegistry( xNetworkBufferSemaphore, "NetBufSem" ); - } - #endif /* configQUEUE_REGISTRY_SIZE */ - - /* If the trace recorder code is included name the semaphore for viewing - in FreeRTOS+Trace. */ - #if( ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1 ) - { - extern QueueHandle_t xNetworkEventQueue; - vTraceSetQueueName( xNetworkEventQueue, "IPStackEvent" ); - vTraceSetQueueName( xNetworkBufferSemaphore, "NetworkBufferCount" ); - } - #endif /* ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1 */ - - vListInitialise( &xFreeBuffersList ); - - /* Initialise all the network buffers. No storage is allocated to - the buffers yet. */ - for( x = 0; x < ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS; x++ ) - { - /* Initialise and set the owner of the buffer list items. */ - xNetworkBufferDescriptors[ x ].pucEthernetBuffer = NULL; - vListInitialiseItem( &( xNetworkBufferDescriptors[ x ].xBufferListItem ) ); - listSET_LIST_ITEM_OWNER( &( xNetworkBufferDescriptors[ x ].xBufferListItem ), &xNetworkBufferDescriptors[ x ] ); - - /* Currently, all buffers are available for use. */ - vListInsert( &xFreeBuffersList, &( xNetworkBufferDescriptors[ x ].xBufferListItem ) ); - } - - uxMinimumFreeNetworkBuffers = ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS; - } - } - - if( xNetworkBufferSemaphore == NULL ) - { - xReturn = pdFAIL; - } - else - { - xReturn = pdPASS; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -uint8_t *pucGetNetworkBuffer( size_t *pxRequestedSizeBytes ) -{ -uint8_t *pucEthernetBuffer; -size_t xSize = *pxRequestedSizeBytes; - - if( xSize < baMINIMAL_BUFFER_SIZE ) - { - /* Buffers must be at least large enough to hold a TCP-packet with - headers, or an ARP packet, in case TCP is not included. */ - xSize = baMINIMAL_BUFFER_SIZE; - } - - /* Round up xSize to the nearest multiple of N bytes, - where N equals 'sizeof( size_t )'. */ - if( ( xSize & ( sizeof( size_t ) - 1u ) ) != 0u ) - { - xSize = ( xSize | ( sizeof( size_t ) - 1u ) ) + 1u; - } - *pxRequestedSizeBytes = xSize; - - /* Allocate a buffer large enough to store the requested Ethernet frame size - and a pointer to a network buffer structure (hence the addition of - ipBUFFER_PADDING bytes). */ - pucEthernetBuffer = ( uint8_t * ) pvPortMalloc( xSize + ipBUFFER_PADDING ); - configASSERT( pucEthernetBuffer ); - - if( pucEthernetBuffer != NULL ) - { - /* Enough space is left at the start of the buffer to place a pointer to - the network buffer structure that references this Ethernet buffer. - Return a pointer to the start of the Ethernet buffer itself. */ - pucEthernetBuffer += ipBUFFER_PADDING; - } - - return pucEthernetBuffer; -} -/*-----------------------------------------------------------*/ - -void vReleaseNetworkBuffer( uint8_t *pucEthernetBuffer ) -{ - /* There is space before the Ethernet buffer in which a pointer to the - network buffer that references this Ethernet buffer is stored. Remove the - space before freeing the buffer. */ - if( pucEthernetBuffer != NULL ) - { - pucEthernetBuffer -= ipBUFFER_PADDING; - vPortFree( ( void * ) pucEthernetBuffer ); - } -} -/*-----------------------------------------------------------*/ - -NetworkBufferDescriptor_t *pxGetNetworkBufferWithDescriptor( size_t xRequestedSizeBytes, TickType_t xBlockTimeTicks ) -{ -NetworkBufferDescriptor_t *pxReturn = NULL; -size_t uxCount; - - if( ( xRequestedSizeBytes != 0u ) && ( xRequestedSizeBytes < ( size_t ) baMINIMAL_BUFFER_SIZE ) ) - { - /* ARP packets can replace application packets, so the storage must be - at least large enough to hold an ARP. */ - xRequestedSizeBytes = baMINIMAL_BUFFER_SIZE; - } - - /* Add 2 bytes to xRequestedSizeBytes and round up xRequestedSizeBytes - to the nearest multiple of N bytes, where N equals 'sizeof( size_t )'. */ - xRequestedSizeBytes += 2u; - if( ( xRequestedSizeBytes & ( sizeof( size_t ) - 1u ) ) != 0u ) - { - xRequestedSizeBytes = ( xRequestedSizeBytes | ( sizeof( size_t ) - 1u ) ) + 1u; - } - - /* If there is a semaphore available, there is a network buffer available. */ - if( xSemaphoreTake( xNetworkBufferSemaphore, xBlockTimeTicks ) == pdPASS ) - { - /* Protect the structure as it is accessed from tasks and interrupts. */ - taskENTER_CRITICAL(); - { - pxReturn = ( NetworkBufferDescriptor_t * ) listGET_OWNER_OF_HEAD_ENTRY( &xFreeBuffersList ); - uxListRemove( &( pxReturn->xBufferListItem ) ); - } - taskEXIT_CRITICAL(); - - /* Reading UBaseType_t, no critical section needed. */ - uxCount = listCURRENT_LIST_LENGTH( &xFreeBuffersList ); - - if( uxMinimumFreeNetworkBuffers > uxCount ) - { - uxMinimumFreeNetworkBuffers = uxCount; - } - - /* Allocate storage of exactly the requested size to the buffer. */ - configASSERT( pxReturn->pucEthernetBuffer == NULL ); - if( xRequestedSizeBytes > 0 ) - { - /* Extra space is obtained so a pointer to the network buffer can - be stored at the beginning of the buffer. */ - pxReturn->pucEthernetBuffer = ( uint8_t * ) pvPortMalloc( xRequestedSizeBytes + ipBUFFER_PADDING ); - - if( pxReturn->pucEthernetBuffer == NULL ) - { - /* The attempt to allocate storage for the buffer payload failed, - so the network buffer structure cannot be used and must be - released. */ - vReleaseNetworkBufferAndDescriptor( pxReturn ); - pxReturn = NULL; - } - else - { - /* Store a pointer to the network buffer structure in the - buffer storage area, then move the buffer pointer on past the - stored pointer so the pointer value is not overwritten by the - application when the buffer is used. */ - *( ( NetworkBufferDescriptor_t ** ) ( pxReturn->pucEthernetBuffer ) ) = pxReturn; - pxReturn->pucEthernetBuffer += ipBUFFER_PADDING; - - /* Store the actual size of the allocated buffer, which may be - greater than the original requested size. */ - pxReturn->xDataLength = xRequestedSizeBytes; - - #if( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) - { - /* make sure the buffer is not linked */ - pxReturn->pxNextBuffer = NULL; - } - #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ - } - } - else - { - /* A descriptor is being returned without an associated buffer being - allocated. */ - } - } - - if( pxReturn == NULL ) - { - iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER(); - } - else - { - iptraceNETWORK_BUFFER_OBTAINED( pxReturn ); - } - - return pxReturn; -} -/*-----------------------------------------------------------*/ - -void vReleaseNetworkBufferAndDescriptor( NetworkBufferDescriptor_t * const pxNetworkBuffer ) -{ -BaseType_t xListItemAlreadyInFreeList; - - /* Ensure the buffer is returned to the list of free buffers before the - counting semaphore is 'given' to say a buffer is available. Release the - storage allocated to the buffer payload. THIS FILE SHOULD NOT BE USED - IF THE PROJECT INCLUDES A MEMORY ALLOCATOR THAT WILL FRAGMENT THE HEAP - MEMORY. For example, heap_2 must not be used, heap_4 can be used. */ - vReleaseNetworkBuffer( pxNetworkBuffer->pucEthernetBuffer ); - pxNetworkBuffer->pucEthernetBuffer = NULL; - - taskENTER_CRITICAL(); - { - xListItemAlreadyInFreeList = listIS_CONTAINED_WITHIN( &xFreeBuffersList, &( pxNetworkBuffer->xBufferListItem ) ); - - if( xListItemAlreadyInFreeList == pdFALSE ) - { - vListInsertEnd( &xFreeBuffersList, &( pxNetworkBuffer->xBufferListItem ) ); - } - } - taskEXIT_CRITICAL(); - - /* - * Update the network state machine, unless the program fails to release its 'xNetworkBufferSemaphore'. - * The program should only try to release its semaphore if 'xListItemAlreadyInFreeList' is false. - */ - if( xListItemAlreadyInFreeList == pdFALSE ) - { - if ( xSemaphoreGive( xNetworkBufferSemaphore ) == pdTRUE ) - { - iptraceNETWORK_BUFFER_RELEASED( pxNetworkBuffer ); - } - } - else - { - iptraceNETWORK_BUFFER_RELEASED( pxNetworkBuffer ); - } -} -/*-----------------------------------------------------------*/ - -/* - * Returns the number of free network buffers - */ -UBaseType_t uxGetNumberOfFreeNetworkBuffers( void ) -{ - return listCURRENT_LIST_LENGTH( &xFreeBuffersList ); -} -/*-----------------------------------------------------------*/ - -UBaseType_t uxGetMinimumFreeNetworkBuffers( void ) -{ - return uxMinimumFreeNetworkBuffers; -} -/*-----------------------------------------------------------*/ - -NetworkBufferDescriptor_t *pxResizeNetworkBufferWithDescriptor( NetworkBufferDescriptor_t * pxNetworkBuffer, size_t xNewSizeBytes ) -{ -size_t xOriginalLength; -uint8_t *pucBuffer; - - xOriginalLength = pxNetworkBuffer->xDataLength + ipBUFFER_PADDING; - xNewSizeBytes = xNewSizeBytes + ipBUFFER_PADDING; - - pucBuffer = pucGetNetworkBuffer( &( xNewSizeBytes ) ); - - if( pucBuffer == NULL ) - { - /* In case the allocation fails, return NULL. */ - pxNetworkBuffer = NULL; - } - else - { - pxNetworkBuffer->xDataLength = xNewSizeBytes; - if( xNewSizeBytes > xOriginalLength ) - { - xNewSizeBytes = xOriginalLength; - } - - memcpy( pucBuffer - ipBUFFER_PADDING, pxNetworkBuffer->pucEthernetBuffer - ipBUFFER_PADDING, xNewSizeBytes ); - vReleaseNetworkBuffer( pxNetworkBuffer->pucEthernetBuffer ); - pxNetworkBuffer->pucEthernetBuffer = pucBuffer; - } - - return pxNetworkBuffer; -} - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/GCC/pack_struct_end.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/GCC/pack_struct_end.h deleted file mode 100755 index ef125f6..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/GCC/pack_struct_end.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - http://aws.amazon.com/freertos - http://www.FreeRTOS.org -*/ - -/***************************************************************************** - * - * See the following URL for an explanation of this file: - * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Compiler_Porting.html - * - *****************************************************************************/ -__attribute__( (packed) ); - - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/GCC/pack_struct_start.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/GCC/pack_struct_start.h deleted file mode 100755 index 374efb0..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/GCC/pack_struct_start.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - http://aws.amazon.com/freertos - http://www.FreeRTOS.org -*/ - -/***************************************************************************** - * - * See the following URL for an explanation of this file: - * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Compiler_Porting.html - * - *****************************************************************************/ - -/* Nothing to do here. */ - - - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/IAR/pack_struct_start.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/IAR/pack_struct_start.h deleted file mode 100755 index 23168d5..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/IAR/pack_struct_start.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - http://aws.amazon.com/freertos - http://www.FreeRTOS.org -*/ - -/***************************************************************************** - * - * See the following URL for an explanation of this file: - * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Compiler_Porting.html - * - *****************************************************************************/ - -__packed - - - - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/MSVC/pack_struct_end.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/MSVC/pack_struct_end.h deleted file mode 100755 index 8dab699..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/MSVC/pack_struct_end.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - http://aws.amazon.com/freertos - http://www.FreeRTOS.org -*/ - -/***************************************************************************** - * - * See the following URL for an explanation of this file: - * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Compiler_Porting.html - * - *****************************************************************************/ - -; -#pragma pack( pop ) - - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/MSVC/pack_struct_start.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/MSVC/pack_struct_start.h deleted file mode 100755 index 9917e9c..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/MSVC/pack_struct_start.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - http://aws.amazon.com/freertos - http://www.FreeRTOS.org -*/ - -/***************************************************************************** - * - * See the following URL for an explanation of this file: - * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Compiler_Porting.html - * - *****************************************************************************/ - -#pragma pack( push, 1 ) - - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/Renesas/pack_struct_end.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/Renesas/pack_struct_end.h deleted file mode 100755 index 678f248..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/Renesas/pack_struct_end.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - http://aws.amazon.com/freertos - http://www.FreeRTOS.org -*/ - -/***************************************************************************** - * - * See the following URL for an explanation of this file: - * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Compiler_Porting.html - * - *****************************************************************************/ - - -#ifdef _SH - #ifdef __RENESAS__ - ; - #pragma unpack - #endif -#endif - - - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/Renesas/pack_struct_start.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/Renesas/pack_struct_start.h deleted file mode 100755 index 9bbd4ee..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/Renesas/pack_struct_start.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - http://aws.amazon.com/freertos - http://www.FreeRTOS.org -*/ - -/***************************************************************************** - * - * See the following URL for an explanation of this file: - * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Compiler_Porting.html - * - *****************************************************************************/ - - -#ifdef _SH - #ifdef __RENESAS__ - #pragma pack 1 - #endif -#endif - - - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/NetworkInterface.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/NetworkInterface.c deleted file mode 100755 index db1f376..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/NetworkInterface.c +++ /dev/null @@ -1,649 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.3 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - - -/* Standard includes. */ -#include -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "NetworkBufferManagement.h" -#include "NetworkInterface.h" - -/* Some files from the Atmel Software Framework */ -/*_RB_ The SAM4E portable layer has three different header files called gmac.h! */ -#include "instance/gmac.h" -#include -#include - -#ifndef BMSR_LINK_STATUS - #define BMSR_LINK_STATUS 0x0004 //!< Link status -#endif - -#ifndef PHY_LS_HIGH_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still high after 15 seconds of not - receiving packets. */ - #define PHY_LS_HIGH_CHECK_TIME_MS 15000 -#endif - -#ifndef PHY_LS_LOW_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still low every second. */ - #define PHY_LS_LOW_CHECK_TIME_MS 1000 -#endif - -/* Interrupt events to process. Currently only the Rx event is processed -although code for other events is included to allow for possible future -expansion. */ -#define EMAC_IF_RX_EVENT 1UL -#define EMAC_IF_TX_EVENT 2UL -#define EMAC_IF_ERR_EVENT 4UL -#define EMAC_IF_ALL_EVENT ( EMAC_IF_RX_EVENT | EMAC_IF_TX_EVENT | EMAC_IF_ERR_EVENT ) - -#define ETHERNET_CONF_PHY_ADDR BOARD_GMAC_PHY_ADDR - -#define HZ_PER_MHZ ( 1000000UL ) - -#ifndef EMAC_MAX_BLOCK_TIME_MS - #define EMAC_MAX_BLOCK_TIME_MS 100ul -#endif - -#if !defined( GMAC_USES_TX_CALLBACK ) || ( GMAC_USES_TX_CALLBACK != 1 ) - #error Please define GMAC_USES_TX_CALLBACK as 1 -#endif - -#if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - #warning The EMAC of SAM4E has fixed-size RX buffers so ZERO_COPY_RX is not possible -#endif - -/* Default the size of the stack used by the EMAC deferred handler task to 4x -the size of the stack used by the idle task - but allow this to be overridden in -FreeRTOSConfig.h as configMINIMAL_STACK_SIZE is a user definable constant. */ -#ifndef configEMAC_TASK_STACK_SIZE - #define configEMAC_TASK_STACK_SIZE ( 4 * configMINIMAL_STACK_SIZE ) -#endif - -/*-----------------------------------------------------------*/ - -/* - * Wait a fixed time for the link status to indicate the network is up. - */ -static BaseType_t xGMACWaitLS( TickType_t xMaxTime ); - -#if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 1 ) && ( ipconfigHAS_TX_CRC_OFFLOADING == 0 ) - void vGMACGenerateChecksum( uint8_t *apBuffer ); -#endif - -/* - * Called from the ASF GMAC driver. - */ -static void prvRxCallback( uint32_t ulStatus ); -static void prvTxCallback( uint32_t ulStatus, uint8_t *puc_buffer ); - -/* - * A deferred interrupt handler task that processes GMAC interrupts. - */ -static void prvEMACHandlerTask( void *pvParameters ); - -/* - * Initialise the ASF GMAC driver. - */ -static BaseType_t prvGMACInit( void ); - -/* - * Try to obtain an Rx packet from the hardware. - */ -static uint32_t prvEMACRxPoll( void ); - -/*-----------------------------------------------------------*/ - -/* Bit map of outstanding ETH interrupt events for processing. Currently only -the Rx interrupt is handled, although code is included for other events to -enable future expansion. */ -static volatile uint32_t ulISREvents; - -/* A copy of PHY register 1: 'PHY_REG_01_BMSR' */ -static uint32_t ulPHYLinkStatus = 0; -static volatile BaseType_t xGMACSwitchRequired; - -/* ethernet_phy_addr: the address of the PHY in use. -Atmel was a bit ambiguous about it so the address will be stored -in this variable, see ethernet_phy.c */ -extern int ethernet_phy_addr; - -/* LLMNR multicast address. */ -static const uint8_t llmnr_mac_address[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0xFC }; - -/* The GMAC object as defined by the ASF drivers. */ -static gmac_device_t gs_gmac_dev; - -/* MAC address to use. */ -extern const uint8_t ucMACAddress[ 6 ]; - -/* Holds the handle of the task used as a deferred interrupt processor. The -handle is used so direct notifications can be sent to the task for all EMAC/DMA -related interrupts. */ -TaskHandle_t xEMACTaskHandle = NULL; - -static QueueHandle_t xTxBufferQueue; -int tx_release_count[ 4 ]; - -/* xTXDescriptorSemaphore is a counting semaphore with -a maximum count of GMAC_TX_BUFFERS, which is the number of -DMA TX descriptors. */ -static SemaphoreHandle_t xTXDescriptorSemaphore = NULL; - -/*-----------------------------------------------------------*/ - -/* - * GMAC interrupt handler. - */ -void GMAC_Handler(void) -{ - xGMACSwitchRequired = pdFALSE; - - /* gmac_handler() may call prvRxCallback() which may change - the value of xGMACSwitchRequired. */ - gmac_handler( &gs_gmac_dev ); - - if( xGMACSwitchRequired != pdFALSE ) - { - portEND_SWITCHING_ISR( xGMACSwitchRequired ); - } -} -/*-----------------------------------------------------------*/ - -static void prvRxCallback( uint32_t ulStatus ) -{ - if( ( ( ulStatus & GMAC_RSR_REC ) != 0 ) && ( xEMACTaskHandle != NULL ) ) - { - /* let the prvEMACHandlerTask know that there was an RX event. */ - ulISREvents |= EMAC_IF_RX_EVENT; - /* Only an RX interrupt can wakeup prvEMACHandlerTask. */ - vTaskNotifyGiveFromISR( xEMACTaskHandle, ( BaseType_t * ) &xGMACSwitchRequired ); - } -} -/*-----------------------------------------------------------*/ - -static void prvTxCallback( uint32_t ulStatus, uint8_t *puc_buffer ) -{ - if( ( xTxBufferQueue != NULL ) && ( xEMACTaskHandle != NULL ) ) - { - /* let the prvEMACHandlerTask know that there was an RX event. */ - ulISREvents |= EMAC_IF_TX_EVENT; - - vTaskNotifyGiveFromISR( xEMACTaskHandle, ( BaseType_t * ) &xGMACSwitchRequired ); - xQueueSendFromISR( xTxBufferQueue, &puc_buffer, ( BaseType_t * ) &xGMACSwitchRequired ); - tx_release_count[ 2 ]++; - } -} -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceInitialise( void ) -{ -const TickType_t x5_Seconds = 5000UL; - - if( xEMACTaskHandle == NULL ) - { - prvGMACInit(); - - /* Wait at most 5 seconds for a Link Status in the PHY. */ - xGMACWaitLS( pdMS_TO_TICKS( x5_Seconds ) ); - - /* The handler task is created at the highest possible priority to - ensure the interrupt handler can return directly to it. */ - xTaskCreate( prvEMACHandlerTask, "EMAC", configEMAC_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, &xEMACTaskHandle ); - configASSERT( xEMACTaskHandle ); - } - - if( xTxBufferQueue == NULL ) - { - xTxBufferQueue = xQueueCreate( GMAC_TX_BUFFERS, sizeof( void * ) ); - configASSERT( xTxBufferQueue ); - } - - if( xTXDescriptorSemaphore == NULL ) - { - xTXDescriptorSemaphore = xSemaphoreCreateCounting( ( UBaseType_t ) GMAC_TX_BUFFERS, ( UBaseType_t ) GMAC_TX_BUFFERS ); - configASSERT( xTXDescriptorSemaphore ); - } - /* When returning non-zero, the stack will become active and - start DHCP (in configured) */ - return ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0; -} -/*-----------------------------------------------------------*/ - -BaseType_t xGetPhyLinkStatus( void ) -{ -BaseType_t xResult; - - /* This function returns true if the Link Status in the PHY is high. */ - if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) - { - xResult = pdTRUE; - } - else - { - xResult = pdFALSE; - } - - return xResult; -} -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescriptor, BaseType_t bReleaseAfterSend ) -{ -/* Do not wait too long for a free TX DMA buffer. */ -const TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 50u ); - - do { - if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) == 0 ) - { - /* Do not attempt to send packets as long as the Link Status is low. */ - break; - } - if( xTXDescriptorSemaphore == NULL ) - { - /* Semaphore has not been created yet? */ - break; - } - if( xSemaphoreTake( xTXDescriptorSemaphore, xBlockTimeTicks ) != pdPASS ) - { - /* Time-out waiting for a free TX descriptor. */ - tx_release_count[ 3 ]++; - break; - } - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* Confirm that the pxDescriptor may be kept by the driver. */ - configASSERT( bReleaseAfterSend != pdFALSE ); - } - #endif /* ipconfigZERO_COPY_TX_DRIVER */ - - gmac_dev_write( &gs_gmac_dev, (void *)pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength, prvTxCallback ); - - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* Confirm that the pxDescriptor may be kept by the driver. */ - bReleaseAfterSend = pdFALSE; - } - #endif /* ipconfigZERO_COPY_TX_DRIVER */ - /* Not interested in a call-back after TX. */ - iptraceNETWORK_INTERFACE_TRANSMIT(); - } while( 0 ); - - if( bReleaseAfterSend != pdFALSE ) - { - vReleaseNetworkBufferAndDescriptor( pxDescriptor ); - } - return pdTRUE; -} -/*-----------------------------------------------------------*/ - -static BaseType_t prvGMACInit( void ) -{ -uint32_t ncfgr; - - gmac_options_t gmac_option; - - memset( &gmac_option, '\0', sizeof( gmac_option ) ); - gmac_option.uc_copy_all_frame = 0; - gmac_option.uc_no_boardcast = 0; - memcpy( gmac_option.uc_mac_addr, ucMACAddress, sizeof( gmac_option.uc_mac_addr ) ); - - gs_gmac_dev.p_hw = GMAC; - gmac_dev_init( GMAC, &gs_gmac_dev, &gmac_option ); - - NVIC_SetPriority( GMAC_IRQn, configMAC_INTERRUPT_PRIORITY ); - NVIC_EnableIRQ( GMAC_IRQn ); - - /* Contact the Ethernet PHY and store it's address in 'ethernet_phy_addr' */ - ethernet_phy_init( GMAC, ETHERNET_CONF_PHY_ADDR, sysclk_get_cpu_hz() ); - - ethernet_phy_auto_negotiate( GMAC, ethernet_phy_addr ); - ethernet_phy_set_link( GMAC, ethernet_phy_addr, 1 ); - - /* The GMAC driver will call a hook prvRxCallback(), which - in turn will wake-up the task by calling vTaskNotifyGiveFromISR() */ - gmac_dev_set_rx_callback( &gs_gmac_dev, prvRxCallback ); - gmac_set_address( GMAC, 1, (uint8_t*)llmnr_mac_address ); - - ncfgr = GMAC_NCFGR_SPD | GMAC_NCFGR_FD; - - GMAC->GMAC_NCFGR = ( GMAC->GMAC_NCFGR & ~( GMAC_NCFGR_SPD | GMAC_NCFGR_FD ) ) | ncfgr; - - return 1; -} -/*-----------------------------------------------------------*/ - -static inline unsigned long ulReadMDIO( unsigned /*short*/ usAddress ) -{ -uint32_t ulValue, ulReturn; -int rc; - - gmac_enable_management( GMAC, 1 ); - rc = gmac_phy_read( GMAC, ethernet_phy_addr, usAddress, &ulValue ); - gmac_enable_management( GMAC, 0 ); - if( rc == GMAC_OK ) - { - ulReturn = ulValue; - } - else - { - ulReturn = 0UL; - } - - return ulReturn; -} -/*-----------------------------------------------------------*/ - -static BaseType_t xGMACWaitLS( TickType_t xMaxTime ) -{ -TickType_t xStartTime = xTaskGetTickCount(); -TickType_t xEndTime; -BaseType_t xReturn; -const TickType_t xShortTime = pdMS_TO_TICKS( 100UL ); - - for( ;; ) - { - xEndTime = xTaskGetTickCount(); - - if( ( xEndTime - xStartTime ) > xMaxTime ) - { - /* Wated more than xMaxTime, return. */ - xReturn = pdFALSE; - break; - } - - /* Check the link status again. */ - ulPHYLinkStatus = ulReadMDIO( PHY_REG_01_BMSR ); - - if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) - { - /* Link is up - return. */ - xReturn = pdTRUE; - break; - } - - /* Link is down - wait in the Blocked state for a short while (to allow - other tasks to execute) before checking again. */ - vTaskDelay( xShortTime ); - } - - FreeRTOS_printf( ( "xGMACWaitLS: %ld (PHY %d) freq %lu Mz\n", - xReturn, - ethernet_phy_addr, - sysclk_get_cpu_hz() / HZ_PER_MHZ ) ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -//#if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 1 ) && ( ipconfigHAS_TX_CRC_OFFLOADING == 0 ) - - void vGMACGenerateChecksum( uint8_t *apBuffer ) - { - ProtocolPacket_t *xProtPacket = (ProtocolPacket_t *)apBuffer; - - if ( xProtPacket->xTCPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) - { - IPHeader_t *pxIPHeader = &( xProtPacket->xTCPPacket.xIPHeader ); - - /* Calculate the IP header checksum. */ - pxIPHeader->usHeaderChecksum = 0x00; - pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0u, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER ); - pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum ); - - /* Calculate the TCP checksum for an outgoing packet. */ - usGenerateProtocolChecksum( ( uint8_t * ) apBuffer, pdTRUE ); - } - } - -//#endif -/*-----------------------------------------------------------*/ - -static uint32_t prvEMACRxPoll( void ) -{ -unsigned char *pucUseBuffer; -uint32_t ulReceiveCount, ulResult, ulReturnValue = 0; -static NetworkBufferDescriptor_t *pxNextNetworkBufferDescriptor = NULL; -const UBaseType_t xMinDescriptorsToLeave = 2UL; -const TickType_t xBlockTime = pdMS_TO_TICKS( 100UL ); -static IPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL }; - - for( ;; ) - { - /* If pxNextNetworkBufferDescriptor was not left pointing at a valid - descriptor then allocate one now. */ - if( ( pxNextNetworkBufferDescriptor == NULL ) && ( uxGetNumberOfFreeNetworkBuffers() > xMinDescriptorsToLeave ) ) - { - pxNextNetworkBufferDescriptor = pxGetNetworkBufferWithDescriptor( ipTOTAL_ETHERNET_FRAME_SIZE, xBlockTime ); - } - - if( pxNextNetworkBufferDescriptor != NULL ) - { - /* Point pucUseBuffer to the buffer pointed to by the descriptor. */ - pucUseBuffer = ( unsigned char* ) ( pxNextNetworkBufferDescriptor->pucEthernetBuffer - ipconfigPACKET_FILLER_SIZE ); - } - else - { - /* As long as pxNextNetworkBufferDescriptor is NULL, the incoming - messages will be flushed and ignored. */ - pucUseBuffer = NULL; - } - - /* Read the next packet from the hardware into pucUseBuffer. */ - ulResult = gmac_dev_read( &gs_gmac_dev, pucUseBuffer, ipTOTAL_ETHERNET_FRAME_SIZE, &ulReceiveCount ); - - if( ( ulResult != GMAC_OK ) || ( ulReceiveCount == 0 ) ) - { - /* No data from the hardware. */ - break; - } - - if( pxNextNetworkBufferDescriptor == NULL ) - { - /* Data was read from the hardware, but no descriptor was available - for it, so it will be dropped. */ - iptraceETHERNET_RX_EVENT_LOST(); - continue; - } - - iptraceNETWORK_INTERFACE_RECEIVE(); - pxNextNetworkBufferDescriptor->xDataLength = ( size_t ) ulReceiveCount; - xRxEvent.pvData = ( void * ) pxNextNetworkBufferDescriptor; - - /* Send the descriptor to the IP task for processing. */ - if( xSendEventStructToIPTask( &xRxEvent, xBlockTime ) != pdTRUE ) - { - /* The buffer could not be sent to the stack so must be released - again. */ - vReleaseNetworkBufferAndDescriptor( pxNextNetworkBufferDescriptor ); - iptraceETHERNET_RX_EVENT_LOST(); - FreeRTOS_printf( ( "prvEMACRxPoll: Can not queue return packet!\n" ) ); - } - - /* Now the buffer has either been passed to the IP-task, - or it has been released in the code above. */ - pxNextNetworkBufferDescriptor = NULL; - ulReturnValue++; - } - - return ulReturnValue; -} -/*-----------------------------------------------------------*/ - -void vCheckBuffersAndQueue( void ) -{ -static UBaseType_t uxLastMinBufferCount = 0; -#if( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - static UBaseType_t uxLastMinQueueSpace; -#endif -static UBaseType_t uxCurrentCount; - - #if( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - { - uxCurrentCount = uxGetMinimumIPQueueSpace(); - if( uxLastMinQueueSpace != uxCurrentCount ) - { - /* The logging produced below may be helpful - while tuning +TCP: see how many buffers are in use. */ - uxLastMinQueueSpace = uxCurrentCount; - FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); - } - } - #endif /* ipconfigCHECK_IP_QUEUE_SPACE */ - uxCurrentCount = uxGetMinimumFreeNetworkBuffers(); - if( uxLastMinBufferCount != uxCurrentCount ) - { - /* The logging produced below may be helpful - while tuning +TCP: see how many buffers are in use. */ - uxLastMinBufferCount = uxCurrentCount; - FreeRTOS_printf( ( "Network buffers: %lu lowest %lu\n", - uxGetNumberOfFreeNetworkBuffers(), uxCurrentCount ) ); - } - -} - -static void prvEMACHandlerTask( void *pvParameters ) -{ -TimeOut_t xPhyTime; -TickType_t xPhyRemTime; -UBaseType_t uxCount; -#if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - NetworkBufferDescriptor_t *pxBuffer; -#endif -uint8_t *pucBuffer; -BaseType_t xResult = 0; -uint32_t xStatus; -const TickType_t ulMaxBlockTime = pdMS_TO_TICKS( EMAC_MAX_BLOCK_TIME_MS ); - - /* Remove compiler warnings about unused parameters. */ - ( void ) pvParameters; - - configASSERT( xEMACTaskHandle ); - - vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); - - for( ;; ) - { - vCheckBuffersAndQueue(); - - if( ( ulISREvents & EMAC_IF_ALL_EVENT ) == 0 ) - { - /* No events to process now, wait for the next. */ - ulTaskNotifyTake( pdFALSE, ulMaxBlockTime ); - } - - if( ( ulISREvents & EMAC_IF_RX_EVENT ) != 0 ) - { - ulISREvents &= ~EMAC_IF_RX_EVENT; - - /* Wait for the EMAC interrupt to indicate that another packet has been - received. */ - xResult = prvEMACRxPoll(); - } - - if( ( ulISREvents & EMAC_IF_TX_EVENT ) != 0 ) - { - /* Future extension: code to release TX buffers if zero-copy is used. */ - ulISREvents &= ~EMAC_IF_TX_EVENT; - while( xQueueReceive( xTxBufferQueue, &pucBuffer, 0 ) != pdFALSE ) - { - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - pxBuffer = pxPacketBuffer_to_NetworkBuffer( pucBuffer ); - if( pxBuffer != NULL ) - { - vReleaseNetworkBufferAndDescriptor( pxBuffer ); - tx_release_count[ 0 ]++; - } - else - { - tx_release_count[ 1 ]++; - } - } - #else - { - tx_release_count[ 0 ]++; - } - #endif - uxCount = uxQueueMessagesWaiting( ( QueueHandle_t ) xTXDescriptorSemaphore ); - if( uxCount < GMAC_TX_BUFFERS ) - { - /* Tell the counting semaphore that one more TX descriptor is available. */ - xSemaphoreGive( xTXDescriptorSemaphore ); - } - } - } - - if( ( ulISREvents & EMAC_IF_ERR_EVENT ) != 0 ) - { - /* Future extension: logging about errors that occurred. */ - ulISREvents &= ~EMAC_IF_ERR_EVENT; - } - - if( xResult > 0 ) - { - /* A packet was received. No need to check for the PHY status now, - but set a timer to check it later on. */ - vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); - xResult = 0; - } - else if( xTaskCheckForTimeOut( &xPhyTime, &xPhyRemTime ) != pdFALSE ) - { - /* Check the link status again. */ - xStatus = ulReadMDIO( PHY_REG_01_BMSR ); - - if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != ( xStatus & BMSR_LINK_STATUS ) ) - { - ulPHYLinkStatus = xStatus; - FreeRTOS_printf( ( "prvEMACHandlerTask: PHY LS now %d\n", ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) ); - } - - vTaskSetTimeOutState( &xPhyTime ); - if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) - { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); - } - else - { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); - } - } - } -} -/*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/component/gmac.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/component/gmac.h deleted file mode 100755 index ae40ac9..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/component/gmac.h +++ /dev/null @@ -1,746 +0,0 @@ -/** - * \file - * - * Copyright (c) 2012 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef _SAM4E_GMAC_COMPONENT_ -#define _SAM4E_GMAC_COMPONENT_ - -/* ============================================================================= */ -/** SOFTWARE API DEFINITION FOR Gigabit Ethernet MAC */ -/* ============================================================================= */ -/** \addtogroup SAM4E_GMAC Gigabit Ethernet MAC */ -/*@{*/ - -#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) -/** \brief GmacSa hardware registers */ -typedef struct { - RwReg GMAC_SAB; /**< \brief (GmacSa Offset: 0x0) Specific Address 1 Bottom [31:0] Register */ - RwReg GMAC_SAT; /**< \brief (GmacSa Offset: 0x4) Specific Address 1 Top [47:32] Register */ -} GmacSa; -/** \brief Gmac hardware registers */ -#define GMACSA_NUMBER 4 -typedef struct { - RwReg GMAC_NCR; /**< \brief (Gmac Offset: 0x000) Network Control Register */ - RwReg GMAC_NCFGR; /**< \brief (Gmac Offset: 0x004) Network Configuration Register */ - RoReg GMAC_NSR; /**< \brief (Gmac Offset: 0x008) Network Status Register */ - RwReg GMAC_UR; /**< \brief (Gmac Offset: 0x00C) User Register */ - RwReg GMAC_DCFGR; /**< \brief (Gmac Offset: 0x010) DMA Configuration Register */ - RwReg GMAC_TSR; /**< \brief (Gmac Offset: 0x014) Transmit Status Register */ - RwReg GMAC_RBQB; /**< \brief (Gmac Offset: 0x018) Receive Buffer Queue Base Address */ - RwReg GMAC_TBQB; /**< \brief (Gmac Offset: 0x01C) Transmit Buffer Queue Base Address */ - RwReg GMAC_RSR; /**< \brief (Gmac Offset: 0x020) Receive Status Register */ - RoReg GMAC_ISR; /**< \brief (Gmac Offset: 0x024) Interrupt Status Register */ - WoReg GMAC_IER; /**< \brief (Gmac Offset: 0x028) Interrupt Enable Register */ - WoReg GMAC_IDR; /**< \brief (Gmac Offset: 0x02C) Interrupt Disable Register */ - RoReg GMAC_IMR; /**< \brief (Gmac Offset: 0x030) Interrupt Mask Register */ - RwReg GMAC_MAN; /**< \brief (Gmac Offset: 0x034) PHY Maintenance Register */ - RoReg GMAC_RPQ; /**< \brief (Gmac Offset: 0x038) Received Pause Quantum Register */ - RwReg GMAC_TPQ; /**< \brief (Gmac Offset: 0x03C) Transmit Pause Quantum Register */ - RwReg GMAC_TPSF; /**< \brief (Gmac Offset: 0x040) TX Partial Store and Forward Register */ - RwReg GMAC_RPSF; /**< \brief (Gmac Offset: 0x044) RX Partial Store and Forward Register */ - RoReg Reserved1[14]; - RwReg GMAC_HRB; /**< \brief (Gmac Offset: 0x080) Hash Register Bottom [31:0] */ - RwReg GMAC_HRT; /**< \brief (Gmac Offset: 0x084) Hash Register Top [63:32] */ - GmacSa GMAC_SA[GMACSA_NUMBER]; /**< \brief (Gmac Offset: 0x088) 1 .. 4 */ - RwReg GMAC_TIDM[4]; /**< \brief (Gmac Offset: 0x0A8) Type ID Match 1 Register */ - RwReg GMAC_WOL; /**< \brief (Gmac Offset: 0x0B8) Wake on LAN Register */ - RwReg GMAC_IPGS; /**< \brief (Gmac Offset: 0x0BC) IPG Stretch Register */ - RwReg GMAC_SVLAN; /**< \brief (Gmac Offset: 0x0C0) Stacked VLAN Register */ - RwReg GMAC_TPFCP; /**< \brief (Gmac Offset: 0x0C4) Transmit PFC Pause Register */ - RwReg GMAC_SAMB1; /**< \brief (Gmac Offset: 0x0C8) Specific Address 1 Mask Bottom [31:0] Register */ - RwReg GMAC_SAMT1; /**< \brief (Gmac Offset: 0x0CC) Specific Address 1 Mask Top [47:32] Register */ - RoReg Reserved2[12]; - RoReg GMAC_OTLO; /**< \brief (Gmac Offset: 0x100) Octets Transmitted [31:0] Register */ - RoReg GMAC_OTHI; /**< \brief (Gmac Offset: 0x104) Octets Transmitted [47:32] Register */ - RoReg GMAC_FT; /**< \brief (Gmac Offset: 0x108) Frames Transmitted Register */ - RoReg GMAC_BCFT; /**< \brief (Gmac Offset: 0x10C) Broadcast Frames Transmitted Register */ - RoReg GMAC_MFT; /**< \brief (Gmac Offset: 0x110) Multicast Frames Transmitted Register */ - RoReg GMAC_PFT; /**< \brief (Gmac Offset: 0x114) Pause Frames Transmitted Register */ - RoReg GMAC_BFT64; /**< \brief (Gmac Offset: 0x118) 64 Byte Frames Transmitted Register */ - RoReg GMAC_TBFT127; /**< \brief (Gmac Offset: 0x11C) 65 to 127 Byte Frames Transmitted Register */ - RoReg GMAC_TBFT255; /**< \brief (Gmac Offset: 0x120) 128 to 255 Byte Frames Transmitted Register */ - RoReg GMAC_TBFT511; /**< \brief (Gmac Offset: 0x124) 256 to 511 Byte Frames Transmitted Register */ - RoReg GMAC_TBFT1023; /**< \brief (Gmac Offset: 0x128) 512 to 1023 Byte Frames Transmitted Register */ - RoReg GMAC_TBFT1518; /**< \brief (Gmac Offset: 0x12C) 1024 to 1518 Byte Frames Transmitted Register */ - RoReg GMAC_GTBFT1518; /**< \brief (Gmac Offset: 0x130) Greater Than 1518 Byte Frames Transmitted Register */ - RoReg GMAC_TUR; /**< \brief (Gmac Offset: 0x134) Transmit Under Runs Register */ - RoReg GMAC_SCF; /**< \brief (Gmac Offset: 0x138) Single Collision Frames Register */ - RoReg GMAC_MCF; /**< \brief (Gmac Offset: 0x13C) Multiple Collision Frames Register */ - RoReg GMAC_EC; /**< \brief (Gmac Offset: 0x140) Excessive Collisions Register */ - RoReg GMAC_LC; /**< \brief (Gmac Offset: 0x144) Late Collisions Register */ - RoReg GMAC_DTF; /**< \brief (Gmac Offset: 0x148) Deferred Transmission Frames Register */ - RoReg GMAC_CSE; /**< \brief (Gmac Offset: 0x14C) Carrier Sense Errors Register */ - RoReg GMAC_ORLO; /**< \brief (Gmac Offset: 0x150) Octets Received [31:0] Received */ - RoReg GMAC_ORHI; /**< \brief (Gmac Offset: 0x154) Octets Received [47:32] Received */ - RoReg GMAC_FR; /**< \brief (Gmac Offset: 0x158) Frames Received Register */ - RoReg GMAC_BCFR; /**< \brief (Gmac Offset: 0x15C) Broadcast Frames Received Register */ - RoReg GMAC_MFR; /**< \brief (Gmac Offset: 0x160) Multicast Frames Received Register */ - RoReg GMAC_PFR; /**< \brief (Gmac Offset: 0x164) Pause Frames Received Register */ - RoReg GMAC_BFR64; /**< \brief (Gmac Offset: 0x168) 64 Byte Frames Received Register */ - RoReg GMAC_TBFR127; /**< \brief (Gmac Offset: 0x16C) 65 to 127 Byte Frames Received Register */ - RoReg GMAC_TBFR255; /**< \brief (Gmac Offset: 0x170) 128 to 255 Byte Frames Received Register */ - RoReg GMAC_TBFR511; /**< \brief (Gmac Offset: 0x174) 256 to 511Byte Frames Received Register */ - RoReg GMAC_TBFR1023; /**< \brief (Gmac Offset: 0x178) 512 to 1023 Byte Frames Received Register */ - RoReg GMAC_TBFR1518; /**< \brief (Gmac Offset: 0x17C) 1024 to 1518 Byte Frames Received Register */ - RoReg GMAC_TMXBFR; /**< \brief (Gmac Offset: 0x180) 1519 to Maximum Byte Frames Received Register */ - RoReg GMAC_UFR; /**< \brief (Gmac Offset: 0x184) Undersize Frames Received Register */ - RoReg GMAC_OFR; /**< \brief (Gmac Offset: 0x188) Oversize Frames Received Register */ - RoReg GMAC_JR; /**< \brief (Gmac Offset: 0x18C) Jabbers Received Register */ - RoReg GMAC_FCSE; /**< \brief (Gmac Offset: 0x190) Frame Check Sequence Errors Register */ - RoReg GMAC_LFFE; /**< \brief (Gmac Offset: 0x194) Length Field Frame Errors Register */ - RoReg GMAC_RSE; /**< \brief (Gmac Offset: 0x198) Receive Symbol Errors Register */ - RoReg GMAC_AE; /**< \brief (Gmac Offset: 0x19C) Alignment Errors Register */ - RoReg GMAC_RRE; /**< \brief (Gmac Offset: 0x1A0) Receive Resource Errors Register */ - RoReg GMAC_ROE; /**< \brief (Gmac Offset: 0x1A4) Receive Overrun Register */ - RoReg GMAC_IHCE; /**< \brief (Gmac Offset: 0x1A8) IP Header Checksum Errors Register */ - RoReg GMAC_TCE; /**< \brief (Gmac Offset: 0x1AC) TCP Checksum Errors Register */ - RoReg GMAC_UCE; /**< \brief (Gmac Offset: 0x1B0) UDP Checksum Errors Register */ - RoReg Reserved3[5]; - RwReg GMAC_TSSS; /**< \brief (Gmac Offset: 0x1C8) 1588 Timer Sync Strobe Seconds Register */ - RwReg GMAC_TSSN; /**< \brief (Gmac Offset: 0x1CC) 1588 Timer Sync Strobe Nanoseconds Register */ - RwReg GMAC_TS; /**< \brief (Gmac Offset: 0x1D0) 1588 Timer Seconds Register */ - RwReg GMAC_TN; /**< \brief (Gmac Offset: 0x1D4) 1588 Timer Nanoseconds Register */ - WoReg GMAC_TA; /**< \brief (Gmac Offset: 0x1D8) 1588 Timer Adjust Register */ - RwReg GMAC_TI; /**< \brief (Gmac Offset: 0x1DC) 1588 Timer Increment Register */ - RoReg GMAC_EFTS; /**< \brief (Gmac Offset: 0x1E0) PTP Event Frame Transmitted Seconds */ - RoReg GMAC_EFTN; /**< \brief (Gmac Offset: 0x1E4) PTP Event Frame Transmitted Nanoseconds */ - RoReg GMAC_EFRS; /**< \brief (Gmac Offset: 0x1E8) PTP Event Frame Received Seconds */ - RoReg GMAC_EFRN; /**< \brief (Gmac Offset: 0x1EC) PTP Event Frame Received Nanoseconds */ - RoReg GMAC_PEFTS; /**< \brief (Gmac Offset: 0x1F0) PTP Peer Event Frame Transmitted Seconds */ - RoReg GMAC_PEFTN; /**< \brief (Gmac Offset: 0x1F4) PTP Peer Event Frame Transmitted Nanoseconds */ - RoReg GMAC_PEFRS; /**< \brief (Gmac Offset: 0x1F8) PTP Peer Event Frame Received Seconds */ - RoReg GMAC_PEFRN; /**< \brief (Gmac Offset: 0x1FC) PTP Peer Event Frame Received Nanoseconds */ - RoReg Reserved4[128]; - RoReg GMAC_ISRPQ[7]; /**< \brief (Gmac Offset: 0x400) Interrupt Status Register Priority Queue */ - RoReg Reserved5[9]; - RwReg GMAC_TBQBAPQ[7]; /**< \brief (Gmac Offset: 0x440) Transmit Buffer Queue Base Address Priority Queue */ - RoReg Reserved6[9]; - RwReg GMAC_RBQBAPQ[7]; /**< \brief (Gmac Offset: 0x480) Receive Buffer Queue Base Address Priority Queue */ - RoReg Reserved7[1]; - RwReg GMAC_RBSRPQ[7]; /**< \brief (Gmac Offset: 0x4A0) Receive Buffer Size Register Priority Queue */ - RoReg Reserved8[17]; - RwReg GMAC_ST1RPQ[16]; /**< \brief (Gmac Offset: 0x500) Screening Type1 Register Priority Queue */ - RwReg GMAC_ST2RPQ[16]; /**< \brief (Gmac Offset: 0x540) Screening Type2 Register Priority Queue */ - RoReg Reserved9[32]; - WoReg GMAC_IERPQ[7]; /**< \brief (Gmac Offset: 0x600) Interrupt Enable Register Priority Queue */ - RoReg Reserved10[1]; - WoReg GMAC_IDRPQ[7]; /**< \brief (Gmac Offset: 0x620) Interrupt Disable Register Priority Queue */ - RoReg Reserved11[1]; - RwReg GMAC_IMRPQ[7]; /**< \brief (Gmac Offset: 0x640) Interrupt Mask Register Priority Queue */ -} Gmac; -#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ -/* -------- GMAC_NCR : (GMAC Offset: 0x000) Network Control Register -------- */ -#define GMAC_NCR_LB (0x1u << 0) /**< \brief (GMAC_NCR) Loop Back */ -#define GMAC_NCR_LBL (0x1u << 1) /**< \brief (GMAC_NCR) Loop Back Local */ -#define GMAC_NCR_RXEN (0x1u << 2) /**< \brief (GMAC_NCR) Receive Enable */ -#define GMAC_NCR_TXEN (0x1u << 3) /**< \brief (GMAC_NCR) Transmit Enable */ -#define GMAC_NCR_MPE (0x1u << 4) /**< \brief (GMAC_NCR) Management Port Enable */ -#define GMAC_NCR_CLRSTAT (0x1u << 5) /**< \brief (GMAC_NCR) Clear Statistics Registers */ -#define GMAC_NCR_INCSTAT (0x1u << 6) /**< \brief (GMAC_NCR) Increment Statistics Registers */ -#define GMAC_NCR_WESTAT (0x1u << 7) /**< \brief (GMAC_NCR) Write Enable for Statistics Registers */ -#define GMAC_NCR_BP (0x1u << 8) /**< \brief (GMAC_NCR) Back pressure */ -#define GMAC_NCR_TSTART (0x1u << 9) /**< \brief (GMAC_NCR) Start Transmission */ -#define GMAC_NCR_THALT (0x1u << 10) /**< \brief (GMAC_NCR) Transmit Halt */ -#define GMAC_NCR_TXPF (0x1u << 11) /**< \brief (GMAC_NCR) Transmit Pause Frame */ -#define GMAC_NCR_TXZQPF (0x1u << 12) /**< \brief (GMAC_NCR) Transmit Zero Quantum Pause Frame */ -#define GMAC_NCR_RDS (0x1u << 14) /**< \brief (GMAC_NCR) Read Snapshot */ -#define GMAC_NCR_SRTSM (0x1u << 15) /**< \brief (GMAC_NCR) Store Receive Time Stamp to Memory */ -#define GMAC_NCR_ENPBPR (0x1u << 16) /**< \brief (GMAC_NCR) Enable PFC Priority-based Pause Reception */ -#define GMAC_NCR_TXPBPF (0x1u << 17) /**< \brief (GMAC_NCR) Transmit PFC Priority-based Pause Frame */ -#define GMAC_NCR_FNP (0x1u << 18) /**< \brief (GMAC_NCR) Flush Next Packet */ -/* -------- GMAC_NCFGR : (GMAC Offset: 0x004) Network Configuration Register -------- */ -#define GMAC_NCFGR_SPD (0x1u << 0) /**< \brief (GMAC_NCFGR) Speed */ -#define GMAC_NCFGR_FD (0x1u << 1) /**< \brief (GMAC_NCFGR) Full Duplex */ -#define GMAC_NCFGR_DNVLAN (0x1u << 2) /**< \brief (GMAC_NCFGR) Discard Non-VLAN FRAMES */ -#define GMAC_NCFGR_JFRAME (0x1u << 3) /**< \brief (GMAC_NCFGR) Jumbo Frame Size */ -#define GMAC_NCFGR_CAF (0x1u << 4) /**< \brief (GMAC_NCFGR) Copy All Frames */ -#define GMAC_NCFGR_NBC (0x1u << 5) /**< \brief (GMAC_NCFGR) No Broadcast */ -#define GMAC_NCFGR_MTIHEN (0x1u << 6) /**< \brief (GMAC_NCFGR) Multicast Hash Enable */ -#define GMAC_NCFGR_UNIHEN (0x1u << 7) /**< \brief (GMAC_NCFGR) Unicast Hash Enable */ -#define GMAC_NCFGR_MAXFS (0x1u << 8) /**< \brief (GMAC_NCFGR) 1536 Maximum Frame Size */ -#define GMAC_NCFGR_GBE (0x1u << 10) /**< \brief (GMAC_NCFGR) Gigabit Mode Enable */ -#define GMAC_NCFGR_PIS (0x1u << 11) /**< \brief (GMAC_NCFGR) Physical Interface Select */ -#define GMAC_NCFGR_RTY (0x1u << 12) /**< \brief (GMAC_NCFGR) Retry Test */ -#define GMAC_NCFGR_PEN (0x1u << 13) /**< \brief (GMAC_NCFGR) Pause Enable */ -#define GMAC_NCFGR_RXBUFO_Pos 14 -#define GMAC_NCFGR_RXBUFO_Msk (0x3u << GMAC_NCFGR_RXBUFO_Pos) /**< \brief (GMAC_NCFGR) Receive Buffer Offset */ -#define GMAC_NCFGR_RXBUFO(value) ((GMAC_NCFGR_RXBUFO_Msk & ((value) << GMAC_NCFGR_RXBUFO_Pos))) -#define GMAC_NCFGR_LFERD (0x1u << 16) /**< \brief (GMAC_NCFGR) Length Field Error Frame Discard */ -#define GMAC_NCFGR_RFCS (0x1u << 17) /**< \brief (GMAC_NCFGR) Remove FCS */ -#define GMAC_NCFGR_CLK_Pos 18 -#define GMAC_NCFGR_CLK_Msk (0x7u << GMAC_NCFGR_CLK_Pos) /**< \brief (GMAC_NCFGR) MDC CLock Division */ -#define GMAC_NCFGR_CLK_MCK_8 (0x0u << 18) /**< \brief (GMAC_NCFGR) MCK divided by 8 (MCK up to 20 MHz) */ -#define GMAC_NCFGR_CLK_MCK_16 (0x1u << 18) /**< \brief (GMAC_NCFGR) MCK divided by 16 (MCK up to 40 MHz) */ -#define GMAC_NCFGR_CLK_MCK_32 (0x2u << 18) /**< \brief (GMAC_NCFGR) MCK divided by 32 (MCK up to 80 MHz) */ -#define GMAC_NCFGR_CLK_MCK_48 (0x3u << 18) /**< \brief (GMAC_NCFGR) MCK divided by 48 (MCK up to 120MHz) */ -#define GMAC_NCFGR_CLK_MCK_64 (0x4u << 18) /**< \brief (GMAC_NCFGR) MCK divided by 64 (MCK up to 160 MHz) */ -#define GMAC_NCFGR_CLK_MCK_96 (0x5u << 18) /**< \brief (GMAC_NCFGR) MCK divided by 96 (MCK up to 240 MHz) */ -#define GMAC_NCFGR_CLK_MCK_128 (0x6u << 18) /**< \brief (GMAC_NCFGR) MCK divided by 128 (MCK up to 320 MHz) */ -#define GMAC_NCFGR_CLK_MCK_224 (0x7u << 18) /**< \brief (GMAC_NCFGR) MCK divided by 224 (MCK up to 540 MHz) */ -#define GMAC_NCFGR_DBW_Pos 21 -#define GMAC_NCFGR_DBW_Msk (0x3u << GMAC_NCFGR_DBW_Pos) /**< \brief (GMAC_NCFGR) Data Bus Width */ -#define GMAC_NCFGR_DBW_DBW32 (0x0u << 21) /**< \brief (GMAC_NCFGR) 32-bit data bus width */ -#define GMAC_NCFGR_DBW_DBW64 (0x1u << 21) /**< \brief (GMAC_NCFGR) 64-bit data bus width */ -#define GMAC_NCFGR_DCPF (0x1u << 23) /**< \brief (GMAC_NCFGR) Disable Copy of Pause Frames */ -#define GMAC_NCFGR_RXCOEN (0x1u << 24) /**< \brief (GMAC_NCFGR) Receive Checksum Offload Enable */ -#define GMAC_NCFGR_EFRHD (0x1u << 25) /**< \brief (GMAC_NCFGR) Enable Frames Received in Half Duplex */ -#define GMAC_NCFGR_IRXFCS (0x1u << 26) /**< \brief (GMAC_NCFGR) Ignore RX FCS */ -#define GMAC_NCFGR_IPGSEN (0x1u << 28) /**< \brief (GMAC_NCFGR) IP Stretch Enable */ -#define GMAC_NCFGR_RXBP (0x1u << 29) /**< \brief (GMAC_NCFGR) Receive Bad Preamble */ -#define GMAC_NCFGR_IRXER (0x1u << 30) /**< \brief (GMAC_NCFGR) Ignore IPG rx_er */ -/* -------- GMAC_NSR : (GMAC Offset: 0x008) Network Status Register -------- */ -#define GMAC_NSR_MDIO (0x1u << 1) /**< \brief (GMAC_NSR) MDIO Input Status */ -#define GMAC_NSR_IDLE (0x1u << 2) /**< \brief (GMAC_NSR) PHY Management Logic Idle */ -/* -------- GMAC_UR : (GMAC Offset: 0x00C) User Register -------- */ -#define GMAC_UR_RGMII (0x1u << 0) /**< \brief (GMAC_UR) RGMII Mode */ -#define GMAC_UR_HDFC (0x1u << 6) /**< \brief (GMAC_UR) Half Duplex Flow Control */ -#define GMAC_UR_BPDG (0x1u << 7) /**< \brief (GMAC_UR) BPDG Bypass Deglitchers */ -/* -------- GMAC_DCFGR : (GMAC Offset: 0x010) DMA Configuration Register -------- */ -#define GMAC_DCFGR_FBLDO_Pos 0 -#define GMAC_DCFGR_FBLDO_Msk (0x1fu << GMAC_DCFGR_FBLDO_Pos) /**< \brief (GMAC_DCFGR) Fixed Burst Length for DMA Data Operations: */ -#define GMAC_DCFGR_FBLDO_SINGLE (0x1u << 0) /**< \brief (GMAC_DCFGR) 00001: Always use SINGLE AHB bursts */ -#define GMAC_DCFGR_FBLDO_INCR4 (0x4u << 0) /**< \brief (GMAC_DCFGR) 001xx: Attempt to use INCR4 AHB bursts (Default) */ -#define GMAC_DCFGR_FBLDO_INCR8 (0x8u << 0) /**< \brief (GMAC_DCFGR) 01xxx: Attempt to use INCR8 AHB bursts */ -#define GMAC_DCFGR_FBLDO_INCR16 (0x10u << 0) /**< \brief (GMAC_DCFGR) 1xxxx: Attempt to use INCR16 AHB bursts */ -#define GMAC_DCFGR_ESMA (0x1u << 6) /**< \brief (GMAC_DCFGR) Endian Swap Mode Enable for Management Descriptor Accesses */ -#define GMAC_DCFGR_ESPA (0x1u << 7) /**< \brief (GMAC_DCFGR) Endian Swap Mode Enable for Packet Data Accesses */ -#define GMAC_DCFGR_RXBMS_Pos 8 -#define GMAC_DCFGR_RXBMS_Msk (0x3u << GMAC_DCFGR_RXBMS_Pos) /**< \brief (GMAC_DCFGR) Receiver Packet Buffer Memory Size Select */ -#define GMAC_DCFGR_RXBMS_EIGHTH (0x0u << 8) /**< \brief (GMAC_DCFGR) 1 Kbyte Memory Size */ -#define GMAC_DCFGR_RXBMS_QUARTER (0x1u << 8) /**< \brief (GMAC_DCFGR) 2 Kbytes Memory Size */ -#define GMAC_DCFGR_RXBMS_HALF (0x2u << 8) /**< \brief (GMAC_DCFGR) 4 Kbytes Memory Size */ -#define GMAC_DCFGR_RXBMS_FULL (0x3u << 8) /**< \brief (GMAC_DCFGR) 8 Kbytes Memory Size */ -#define GMAC_DCFGR_TXPBMS (0x1u << 10) /**< \brief (GMAC_DCFGR) Transmitter Packet Buffer Memory Size Select */ -#define GMAC_DCFGR_TXCOEN (0x1u << 11) /**< \brief (GMAC_DCFGR) Transmitter Checksum Generation Offload Enable */ -#define GMAC_DCFGR_DRBS_Pos 16 -#define GMAC_DCFGR_DRBS_Msk (0xffu << GMAC_DCFGR_DRBS_Pos) /**< \brief (GMAC_DCFGR) DMA Receive Buffer Size */ -#define GMAC_DCFGR_DRBS(value) ((GMAC_DCFGR_DRBS_Msk & ((value) << GMAC_DCFGR_DRBS_Pos))) -#define GMAC_DCFGR_DDRP (0x1u << 24) /**< \brief (GMAC_DCFGR) DMA Discard Receive Packets */ -/* -------- GMAC_TSR : (GMAC Offset: 0x014) Transmit Status Register -------- */ -#define GMAC_TSR_UBR (0x1u << 0) /**< \brief (GMAC_TSR) Used Bit Read */ -#define GMAC_TSR_COL (0x1u << 1) /**< \brief (GMAC_TSR) Collision Occurred */ -#define GMAC_TSR_RLE (0x1u << 2) /**< \brief (GMAC_TSR) Retry Limit Exceeded */ -#define GMAC_TSR_TXGO (0x1u << 3) /**< \brief (GMAC_TSR) Transmit Go */ -#define GMAC_TSR_TFC (0x1u << 4) /**< \brief (GMAC_TSR) Transmit Frame Corruption due to AHB error */ -#define GMAC_TSR_TXCOMP (0x1u << 5) /**< \brief (GMAC_TSR) Transmit Complete */ -#define GMAC_TSR_UND (0x1u << 6) /**< \brief (GMAC_TSR) Transmit Under Run */ -#define GMAC_TSR_LCO (0x1u << 7) /**< \brief (GMAC_TSR) Late Collision Occurred */ -#define GMAC_TSR_HRESP (0x1u << 8) /**< \brief (GMAC_TSR) HRESP Not OK */ -/* -------- GMAC_RBQB : (GMAC Offset: 0x018) Receive Buffer Queue Base Address -------- */ -#define GMAC_RBQB_ADDR_Pos 2 -#define GMAC_RBQB_ADDR_Msk (0x3fffffffu << GMAC_RBQB_ADDR_Pos) /**< \brief (GMAC_RBQB) Receive buffer queue base address */ -#define GMAC_RBQB_ADDR(value) ((GMAC_RBQB_ADDR_Msk & ((value) << GMAC_RBQB_ADDR_Pos))) -/* -------- GMAC_TBQB : (GMAC Offset: 0x01C) Transmit Buffer Queue Base Address -------- */ -#define GMAC_TBQB_ADDR_Pos 2 -#define GMAC_TBQB_ADDR_Msk (0x3fffffffu << GMAC_TBQB_ADDR_Pos) /**< \brief (GMAC_TBQB) Transmit Buffer Queue Base Address */ -#define GMAC_TBQB_ADDR(value) ((GMAC_TBQB_ADDR_Msk & ((value) << GMAC_TBQB_ADDR_Pos))) -/* -------- GMAC_RSR : (GMAC Offset: 0x020) Receive Status Register -------- */ -#define GMAC_RSR_BNA (0x1u << 0) /**< \brief (GMAC_RSR) Buffer Not Available */ -#define GMAC_RSR_REC (0x1u << 1) /**< \brief (GMAC_RSR) Frame Received */ -#define GMAC_RSR_RXOVR (0x1u << 2) /**< \brief (GMAC_RSR) Receive Overrun */ -#define GMAC_RSR_HNO (0x1u << 3) /**< \brief (GMAC_RSR) HRESP Not OK */ -/* -------- GMAC_ISR : (GMAC Offset: 0x024) Interrupt Status Register -------- */ -#define GMAC_ISR_MFS (0x1u << 0) /**< \brief (GMAC_ISR) Management Frame Sent */ -#define GMAC_ISR_RCOMP (0x1u << 1) /**< \brief (GMAC_ISR) Receive Complete */ -#define GMAC_ISR_RXUBR (0x1u << 2) /**< \brief (GMAC_ISR) RX Used Bit Read */ -#define GMAC_ISR_TXUBR (0x1u << 3) /**< \brief (GMAC_ISR) TX Used Bit Read */ -#define GMAC_ISR_TUR (0x1u << 4) /**< \brief (GMAC_ISR) Transmit Under Run */ -#define GMAC_ISR_RLEX (0x1u << 5) /**< \brief (GMAC_ISR) Retry Limit Exceeded or Late Collision */ -#define GMAC_ISR_TFC (0x1u << 6) /**< \brief (GMAC_ISR) Transmit Frame Corruption due to AHB error */ -#define GMAC_ISR_TCOMP (0x1u << 7) /**< \brief (GMAC_ISR) Transmit Complete */ -#define GMAC_ISR_ROVR (0x1u << 10) /**< \brief (GMAC_ISR) Receive Overrun */ -#define GMAC_ISR_HRESP (0x1u << 11) /**< \brief (GMAC_ISR) HRESP Not OK */ -#define GMAC_ISR_PFNZ (0x1u << 12) /**< \brief (GMAC_ISR) Pause Frame with Non-zero Pause Quantum Received */ -#define GMAC_ISR_PTZ (0x1u << 13) /**< \brief (GMAC_ISR) Pause Time Zero */ -#define GMAC_ISR_PFTR (0x1u << 14) /**< \brief (GMAC_ISR) Pause Frame Transmitted */ -#define GMAC_ISR_EXINT (0x1u << 15) /**< \brief (GMAC_ISR) External Interrupt */ -#define GMAC_ISR_DRQFR (0x1u << 18) /**< \brief (GMAC_ISR) PTP Delay Request Frame Received */ -#define GMAC_ISR_SFR (0x1u << 19) /**< \brief (GMAC_ISR) PTP Sync Frame Received */ -#define GMAC_ISR_DRQFT (0x1u << 20) /**< \brief (GMAC_ISR) PTP Delay Request Frame Transmitted */ -#define GMAC_ISR_SFT (0x1u << 21) /**< \brief (GMAC_ISR) PTP Sync Frame Transmitted */ -#define GMAC_ISR_PDRQFR (0x1u << 22) /**< \brief (GMAC_ISR) PDelay Request Frame Received */ -#define GMAC_ISR_PDRSFR (0x1u << 23) /**< \brief (GMAC_ISR) PDelay Response Frame Received */ -#define GMAC_ISR_PDRQFT (0x1u << 24) /**< \brief (GMAC_ISR) PDelay Request Frame Transmitted */ -#define GMAC_ISR_PDRSFT (0x1u << 25) /**< \brief (GMAC_ISR) PDelay Response Frame Transmitted */ -#define GMAC_ISR_SRI (0x1u << 26) /**< \brief (GMAC_ISR) TSU Seconds Register Increment */ -#define GMAC_ISR_WOL (0x1u << 28) /**< \brief (GMAC_ISR) Wake On LAN */ -/* -------- GMAC_IER : (GMAC Offset: 0x028) Interrupt Enable Register -------- */ -#define GMAC_IER_MFS (0x1u << 0) /**< \brief (GMAC_IER) Management Frame Sent */ -#define GMAC_IER_RCOMP (0x1u << 1) /**< \brief (GMAC_IER) Receive Complete */ -#define GMAC_IER_RXUBR (0x1u << 2) /**< \brief (GMAC_IER) RX Used Bit Read */ -#define GMAC_IER_TXUBR (0x1u << 3) /**< \brief (GMAC_IER) TX Used Bit Read */ -#define GMAC_IER_TUR (0x1u << 4) /**< \brief (GMAC_IER) Transmit Under Run */ -#define GMAC_IER_RLEX (0x1u << 5) /**< \brief (GMAC_IER) Retry Limit Exceeded or Late Collision */ -#define GMAC_IER_TFC (0x1u << 6) /**< \brief (GMAC_IER) Transmit Frame Corruption due to AHB error */ -#define GMAC_IER_TCOMP (0x1u << 7) /**< \brief (GMAC_IER) Transmit Complete */ -#define GMAC_IER_ROVR (0x1u << 10) /**< \brief (GMAC_IER) Receive Overrun */ -#define GMAC_IER_HRESP (0x1u << 11) /**< \brief (GMAC_IER) HRESP Not OK */ -#define GMAC_IER_PFNZ (0x1u << 12) /**< \brief (GMAC_IER) Pause Frame with Non-zero Pause Quantum Received */ -#define GMAC_IER_PTZ (0x1u << 13) /**< \brief (GMAC_IER) Pause Time Zero */ -#define GMAC_IER_PFTR (0x1u << 14) /**< \brief (GMAC_IER) Pause Frame Transmitted */ -#define GMAC_IER_EXINT (0x1u << 15) /**< \brief (GMAC_IER) External Interrupt */ -#define GMAC_IER_DRQFR (0x1u << 18) /**< \brief (GMAC_IER) PTP Delay Request Frame Received */ -#define GMAC_IER_SFR (0x1u << 19) /**< \brief (GMAC_IER) PTP Sync Frame Received */ -#define GMAC_IER_DRQFT (0x1u << 20) /**< \brief (GMAC_IER) PTP Delay Request Frame Transmitted */ -#define GMAC_IER_SFT (0x1u << 21) /**< \brief (GMAC_IER) PTP Sync Frame Transmitted */ -#define GMAC_IER_PDRQFR (0x1u << 22) /**< \brief (GMAC_IER) PDelay Request Frame Received */ -#define GMAC_IER_PDRSFR (0x1u << 23) /**< \brief (GMAC_IER) PDelay Response Frame Received */ -#define GMAC_IER_PDRQFT (0x1u << 24) /**< \brief (GMAC_IER) PDelay Request Frame Transmitted */ -#define GMAC_IER_PDRSFT (0x1u << 25) /**< \brief (GMAC_IER) PDelay Response Frame Transmitted */ -#define GMAC_IER_SRI (0x1u << 26) /**< \brief (GMAC_IER) TSU Seconds Register Increment */ -#define GMAC_IER_WOL (0x1u << 28) /**< \brief (GMAC_IER) Wake On LAN */ -/* -------- GMAC_IDR : (GMAC Offset: 0x02C) Interrupt Disable Register -------- */ -#define GMAC_IDR_MFS (0x1u << 0) /**< \brief (GMAC_IDR) Management Frame Sent */ -#define GMAC_IDR_RCOMP (0x1u << 1) /**< \brief (GMAC_IDR) Receive Complete */ -#define GMAC_IDR_RXUBR (0x1u << 2) /**< \brief (GMAC_IDR) RX Used Bit Read */ -#define GMAC_IDR_TXUBR (0x1u << 3) /**< \brief (GMAC_IDR) TX Used Bit Read */ -#define GMAC_IDR_TUR (0x1u << 4) /**< \brief (GMAC_IDR) Transmit Under Run */ -#define GMAC_IDR_RLEX (0x1u << 5) /**< \brief (GMAC_IDR) Retry Limit Exceeded or Late Collision */ -#define GMAC_IDR_TFC (0x1u << 6) /**< \brief (GMAC_IDR) Transmit Frame Corruption due to AHB error */ -#define GMAC_IDR_TCOMP (0x1u << 7) /**< \brief (GMAC_IDR) Transmit Complete */ -#define GMAC_IDR_ROVR (0x1u << 10) /**< \brief (GMAC_IDR) Receive Overrun */ -#define GMAC_IDR_HRESP (0x1u << 11) /**< \brief (GMAC_IDR) HRESP Not OK */ -#define GMAC_IDR_PFNZ (0x1u << 12) /**< \brief (GMAC_IDR) Pause Frame with Non-zero Pause Quantum Received */ -#define GMAC_IDR_PTZ (0x1u << 13) /**< \brief (GMAC_IDR) Pause Time Zero */ -#define GMAC_IDR_PFTR (0x1u << 14) /**< \brief (GMAC_IDR) Pause Frame Transmitted */ -#define GMAC_IDR_EXINT (0x1u << 15) /**< \brief (GMAC_IDR) External Interrupt */ -#define GMAC_IDR_DRQFR (0x1u << 18) /**< \brief (GMAC_IDR) PTP Delay Request Frame Received */ -#define GMAC_IDR_SFR (0x1u << 19) /**< \brief (GMAC_IDR) PTP Sync Frame Received */ -#define GMAC_IDR_DRQFT (0x1u << 20) /**< \brief (GMAC_IDR) PTP Delay Request Frame Transmitted */ -#define GMAC_IDR_SFT (0x1u << 21) /**< \brief (GMAC_IDR) PTP Sync Frame Transmitted */ -#define GMAC_IDR_PDRQFR (0x1u << 22) /**< \brief (GMAC_IDR) PDelay Request Frame Received */ -#define GMAC_IDR_PDRSFR (0x1u << 23) /**< \brief (GMAC_IDR) PDelay Response Frame Received */ -#define GMAC_IDR_PDRQFT (0x1u << 24) /**< \brief (GMAC_IDR) PDelay Request Frame Transmitted */ -#define GMAC_IDR_PDRSFT (0x1u << 25) /**< \brief (GMAC_IDR) PDelay Response Frame Transmitted */ -#define GMAC_IDR_SRI (0x1u << 26) /**< \brief (GMAC_IDR) TSU Seconds Register Increment */ -#define GMAC_IDR_WOL (0x1u << 28) /**< \brief (GMAC_IDR) Wake On LAN */ -/* -------- GMAC_IMR : (GMAC Offset: 0x030) Interrupt Mask Register -------- */ -#define GMAC_IMR_MFS (0x1u << 0) /**< \brief (GMAC_IMR) Management Frame Sent */ -#define GMAC_IMR_RCOMP (0x1u << 1) /**< \brief (GMAC_IMR) Receive Complete */ -#define GMAC_IMR_RXUBR (0x1u << 2) /**< \brief (GMAC_IMR) RX Used Bit Read */ -#define GMAC_IMR_TXUBR (0x1u << 3) /**< \brief (GMAC_IMR) TX Used Bit Read */ -#define GMAC_IMR_TUR (0x1u << 4) /**< \brief (GMAC_IMR) Transmit Under Run */ -#define GMAC_IMR_RLEX (0x1u << 5) /**< \brief (GMAC_IMR) Retry Limit Exceeded or Late Collision */ -#define GMAC_IMR_TFC (0x1u << 6) /**< \brief (GMAC_IMR) Transmit Frame Corruption due to AHB error */ -#define GMAC_IMR_TCOMP (0x1u << 7) /**< \brief (GMAC_IMR) Transmit Complete */ -#define GMAC_IMR_ROVR (0x1u << 10) /**< \brief (GMAC_IMR) Receive Overrun */ -#define GMAC_IMR_HRESP (0x1u << 11) /**< \brief (GMAC_IMR) HRESP Not OK */ -#define GMAC_IMR_PFNZ (0x1u << 12) /**< \brief (GMAC_IMR) Pause Frame with Non-zero Pause Quantum Received */ -#define GMAC_IMR_PTZ (0x1u << 13) /**< \brief (GMAC_IMR) Pause Time Zero */ -#define GMAC_IMR_PFTR (0x1u << 14) /**< \brief (GMAC_IMR) Pause Frame Transmitted */ -#define GMAC_IMR_EXINT (0x1u << 15) /**< \brief (GMAC_IMR) External Interrupt */ -#define GMAC_IMR_DRQFR (0x1u << 18) /**< \brief (GMAC_IMR) PTP Delay Request Frame Received */ -#define GMAC_IMR_SFR (0x1u << 19) /**< \brief (GMAC_IMR) PTP Sync Frame Received */ -#define GMAC_IMR_DRQFT (0x1u << 20) /**< \brief (GMAC_IMR) PTP Delay Request Frame Transmitted */ -#define GMAC_IMR_SFT (0x1u << 21) /**< \brief (GMAC_IMR) PTP Sync Frame Transmitted */ -#define GMAC_IMR_PDRQFR (0x1u << 22) /**< \brief (GMAC_IMR) PDelay Request Frame Received */ -#define GMAC_IMR_PDRSFR (0x1u << 23) /**< \brief (GMAC_IMR) PDelay Response Frame Received */ -#define GMAC_IMR_PDRQFT (0x1u << 24) /**< \brief (GMAC_IMR) PDelay Request Frame Transmitted */ -#define GMAC_IMR_PDRSFT (0x1u << 25) /**< \brief (GMAC_IMR) PDelay Response Frame Transmitted */ -/* -------- GMAC_MAN : (GMAC Offset: 0x034) PHY Maintenance Register -------- */ -#define GMAC_MAN_DATA_Pos 0 -#define GMAC_MAN_DATA_Msk (0xffffu << GMAC_MAN_DATA_Pos) /**< \brief (GMAC_MAN) PHY Data */ -#define GMAC_MAN_DATA(value) ((GMAC_MAN_DATA_Msk & ((value) << GMAC_MAN_DATA_Pos))) -#define GMAC_MAN_WTN_Pos 16 -#define GMAC_MAN_WTN_Msk (0x3u << GMAC_MAN_WTN_Pos) /**< \brief (GMAC_MAN) Write Ten */ -#define GMAC_MAN_WTN(value) ((GMAC_MAN_WTN_Msk & ((value) << GMAC_MAN_WTN_Pos))) -#define GMAC_MAN_REGA_Pos 18 -#define GMAC_MAN_REGA_Msk (0x1fu << GMAC_MAN_REGA_Pos) /**< \brief (GMAC_MAN) Register Address */ -#define GMAC_MAN_REGA(value) ((GMAC_MAN_REGA_Msk & ((value) << GMAC_MAN_REGA_Pos))) -#define GMAC_MAN_PHYA_Pos 23 -#define GMAC_MAN_PHYA_Msk (0x1fu << GMAC_MAN_PHYA_Pos) /**< \brief (GMAC_MAN) PHY Address */ -#define GMAC_MAN_PHYA(value) ((GMAC_MAN_PHYA_Msk & ((value) << GMAC_MAN_PHYA_Pos))) -#define GMAC_MAN_OP_Pos 28 -#define GMAC_MAN_OP_Msk (0x3u << GMAC_MAN_OP_Pos) /**< \brief (GMAC_MAN) Operation */ -#define GMAC_MAN_OP(value) ((GMAC_MAN_OP_Msk & ((value) << GMAC_MAN_OP_Pos))) -#define GMAC_MAN_CLTTO (0x1u << 30) /**< \brief (GMAC_MAN) Clause 22 Operation */ -#define GMAC_MAN_WZO (0x1u << 31) /**< \brief (GMAC_MAN) Write ZERO */ -/* -------- GMAC_RPQ : (GMAC Offset: 0x038) Received Pause Quantum Register -------- */ -#define GMAC_RPQ_RPQ_Pos 0 -#define GMAC_RPQ_RPQ_Msk (0xffffu << GMAC_RPQ_RPQ_Pos) /**< \brief (GMAC_RPQ) Received Pause Quantum */ -/* -------- GMAC_TPQ : (GMAC Offset: 0x03C) Transmit Pause Quantum Register -------- */ -#define GMAC_TPQ_TPQ_Pos 0 -#define GMAC_TPQ_TPQ_Msk (0xffffu << GMAC_TPQ_TPQ_Pos) /**< \brief (GMAC_TPQ) Transmit Pause Quantum */ -#define GMAC_TPQ_TPQ(value) ((GMAC_TPQ_TPQ_Msk & ((value) << GMAC_TPQ_TPQ_Pos))) -/* -------- GMAC_TPSF : (GMAC Offset: 0x040) TX Partial Store and Forward Register -------- */ -#define GMAC_TPSF_TPB1ADR_Pos 0 -#define GMAC_TPSF_TPB1ADR_Msk (0xfffu << GMAC_TPSF_TPB1ADR_Pos) /**< \brief (GMAC_TPSF) tx_pbuf_addr-1:0 */ -#define GMAC_TPSF_TPB1ADR(value) ((GMAC_TPSF_TPB1ADR_Msk & ((value) << GMAC_TPSF_TPB1ADR_Pos))) -#define GMAC_TPSF_ENTXP (0x1u << 31) /**< \brief (GMAC_TPSF) Enable TX Partial Store and Forward Operation */ -/* -------- GMAC_RPSF : (GMAC Offset: 0x044) RX Partial Store and Forward Register -------- */ -#define GMAC_RPSF_RPB1ADR_Pos 0 -#define GMAC_RPSF_RPB1ADR_Msk (0xfffu << GMAC_RPSF_RPB1ADR_Pos) /**< \brief (GMAC_RPSF) rx_pbuf_addr-1:0 */ -#define GMAC_RPSF_RPB1ADR(value) ((GMAC_RPSF_RPB1ADR_Msk & ((value) << GMAC_RPSF_RPB1ADR_Pos))) -#define GMAC_RPSF_ENRXP (0x1u << 31) /**< \brief (GMAC_RPSF) Enable RX Partial Store and Forward Operation */ -/* -------- GMAC_HRB : (GMAC Offset: 0x080) Hash Register Bottom [31:0] -------- */ -#define GMAC_HRB_ADDR_Pos 0 -#define GMAC_HRB_ADDR_Msk (0xffffffffu << GMAC_HRB_ADDR_Pos) /**< \brief (GMAC_HRB) Hash Address */ -#define GMAC_HRB_ADDR(value) ((GMAC_HRB_ADDR_Msk & ((value) << GMAC_HRB_ADDR_Pos))) -/* -------- GMAC_HRT : (GMAC Offset: 0x084) Hash Register Top [63:32] -------- */ -#define GMAC_HRT_ADDR_Pos 0 -#define GMAC_HRT_ADDR_Msk (0xffffffffu << GMAC_HRT_ADDR_Pos) /**< \brief (GMAC_HRT) Hash Address */ -#define GMAC_HRT_ADDR(value) ((GMAC_HRT_ADDR_Msk & ((value) << GMAC_HRT_ADDR_Pos))) -/* -------- GMAC_SAB1 : (GMAC Offset: 0x088) Specific Address 1 Bottom [31:0] Register -------- */ -#define GMAC_SAB1_ADDR_Pos 0 -#define GMAC_SAB1_ADDR_Msk (0xffffffffu << GMAC_SAB1_ADDR_Pos) /**< \brief (GMAC_SAB1) Specific Address 1 */ -#define GMAC_SAB1_ADDR(value) ((GMAC_SAB1_ADDR_Msk & ((value) << GMAC_SAB1_ADDR_Pos))) -/* -------- GMAC_SAT1 : (GMAC Offset: 0x08C) Specific Address 1 Top [47:32] Register -------- */ -#define GMAC_SAT1_ADDR_Pos 0 -#define GMAC_SAT1_ADDR_Msk (0xffffu << GMAC_SAT1_ADDR_Pos) /**< \brief (GMAC_SAT1) Specific Address 1 */ -#define GMAC_SAT1_ADDR(value) ((GMAC_SAT1_ADDR_Msk & ((value) << GMAC_SAT1_ADDR_Pos))) -/* -------- GMAC_SAB2 : (GMAC Offset: 0x090) Specific Address 2 Bottom [31:0] Register -------- */ -#define GMAC_SAB2_ADDR_Pos 0 -#define GMAC_SAB2_ADDR_Msk (0xffffffffu << GMAC_SAB2_ADDR_Pos) /**< \brief (GMAC_SAB2) Specific Address 2 */ -#define GMAC_SAB2_ADDR(value) ((GMAC_SAB2_ADDR_Msk & ((value) << GMAC_SAB2_ADDR_Pos))) -/* -------- GMAC_SAT2 : (GMAC Offset: 0x094) Specific Address 2 Top [47:32] Register -------- */ -#define GMAC_SAT2_ADDR_Pos 0 -#define GMAC_SAT2_ADDR_Msk (0xffffu << GMAC_SAT2_ADDR_Pos) /**< \brief (GMAC_SAT2) Specific Address 2 */ -#define GMAC_SAT2_ADDR(value) ((GMAC_SAT2_ADDR_Msk & ((value) << GMAC_SAT2_ADDR_Pos))) -/* -------- GMAC_SAB3 : (GMAC Offset: 0x098) Specific Address 3 Bottom [31:0] Register -------- */ -#define GMAC_SAB3_ADDR_Pos 0 -#define GMAC_SAB3_ADDR_Msk (0xffffffffu << GMAC_SAB3_ADDR_Pos) /**< \brief (GMAC_SAB3) Specific Address 3 */ -#define GMAC_SAB3_ADDR(value) ((GMAC_SAB3_ADDR_Msk & ((value) << GMAC_SAB3_ADDR_Pos))) -/* -------- GMAC_SAT3 : (GMAC Offset: 0x09C) Specific Address 3 Top [47:32] Register -------- */ -#define GMAC_SAT3_ADDR_Pos 0 -#define GMAC_SAT3_ADDR_Msk (0xffffu << GMAC_SAT3_ADDR_Pos) /**< \brief (GMAC_SAT3) Specific Address 3 */ -#define GMAC_SAT3_ADDR(value) ((GMAC_SAT3_ADDR_Msk & ((value) << GMAC_SAT3_ADDR_Pos))) -/* -------- GMAC_SAB4 : (GMAC Offset: 0x0A0) Specific Address 4 Bottom [31:0] Register -------- */ -#define GMAC_SAB4_ADDR_Pos 0 -#define GMAC_SAB4_ADDR_Msk (0xffffffffu << GMAC_SAB4_ADDR_Pos) /**< \brief (GMAC_SAB4) Specific Address 4 */ -#define GMAC_SAB4_ADDR(value) ((GMAC_SAB4_ADDR_Msk & ((value) << GMAC_SAB4_ADDR_Pos))) -/* -------- GMAC_SAT4 : (GMAC Offset: 0x0A4) Specific Address 4 Top [47:32] Register -------- */ -#define GMAC_SAT4_ADDR_Pos 0 -#define GMAC_SAT4_ADDR_Msk (0xffffu << GMAC_SAT4_ADDR_Pos) /**< \brief (GMAC_SAT4) Specific Address 4 */ -#define GMAC_SAT4_ADDR(value) ((GMAC_SAT4_ADDR_Msk & ((value) << GMAC_SAT4_ADDR_Pos))) -/* -------- GMAC_TIDM[4] : (GMAC Offset: 0x0A8) Type ID Match 1 Register -------- */ -#define GMAC_TIDM_TID_Pos 0 -#define GMAC_TIDM_TID_Msk (0xffffu << GMAC_TIDM_TID_Pos) /**< \brief (GMAC_TIDM[4]) Type ID Match 1 */ -#define GMAC_TIDM_TID(value) ((GMAC_TIDM_TID_Msk & ((value) << GMAC_TIDM_TID_Pos))) -/* -------- GMAC_WOL : (GMAC Offset: 0x0B8) Wake on LAN Register -------- */ -#define GMAC_WOL_IP_Pos 0 -#define GMAC_WOL_IP_Msk (0xffffu << GMAC_WOL_IP_Pos) /**< \brief (GMAC_WOL) ARP Request IP Address */ -#define GMAC_WOL_IP(value) ((GMAC_WOL_IP_Msk & ((value) << GMAC_WOL_IP_Pos))) -#define GMAC_WOL_MAG (0x1u << 16) /**< \brief (GMAC_WOL) Magic Packet Event Enable */ -#define GMAC_WOL_ARP (0x1u << 17) /**< \brief (GMAC_WOL) ARP Request IP Address */ -#define GMAC_WOL_SA1 (0x1u << 18) /**< \brief (GMAC_WOL) Specific Address Register 1 Event Enable */ -#define GMAC_WOL_MTI (0x1u << 19) /**< \brief (GMAC_WOL) Multicast Hash Event Enable */ -/* -------- GMAC_IPGS : (GMAC Offset: 0x0BC) IPG Stretch Register -------- */ -#define GMAC_IPGS_FL_Pos 0 -#define GMAC_IPGS_FL_Msk (0xffffu << GMAC_IPGS_FL_Pos) /**< \brief (GMAC_IPGS) Frame Length */ -#define GMAC_IPGS_FL(value) ((GMAC_IPGS_FL_Msk & ((value) << GMAC_IPGS_FL_Pos))) -/* -------- GMAC_SVLAN : (GMAC Offset: 0x0C0) Stacked VLAN Register -------- */ -#define GMAC_SVLAN_VLAN_TYPE_Pos 0 -#define GMAC_SVLAN_VLAN_TYPE_Msk (0xffffu << GMAC_SVLAN_VLAN_TYPE_Pos) /**< \brief (GMAC_SVLAN) User Defined VLAN_TYPE Field */ -#define GMAC_SVLAN_VLAN_TYPE(value) ((GMAC_SVLAN_VLAN_TYPE_Msk & ((value) << GMAC_SVLAN_VLAN_TYPE_Pos))) -#define GMAC_SVLAN_ESVLAN (0x1u << 31) /**< \brief (GMAC_SVLAN) Enable Stacked VLAN Processing Mode */ -/* -------- GMAC_TPFCP : (GMAC Offset: 0x0C4) Transmit PFC Pause Register -------- */ -#define GMAC_TPFCP_PEV_Pos 0 -#define GMAC_TPFCP_PEV_Msk (0xffu << GMAC_TPFCP_PEV_Pos) /**< \brief (GMAC_TPFCP) Priority Enable Vector */ -#define GMAC_TPFCP_PEV(value) ((GMAC_TPFCP_PEV_Msk & ((value) << GMAC_TPFCP_PEV_Pos))) -#define GMAC_TPFCP_PQ_Pos 8 -#define GMAC_TPFCP_PQ_Msk (0xffu << GMAC_TPFCP_PQ_Pos) /**< \brief (GMAC_TPFCP) Pause Quantum */ -#define GMAC_TPFCP_PQ(value) ((GMAC_TPFCP_PQ_Msk & ((value) << GMAC_TPFCP_PQ_Pos))) -/* -------- GMAC_SAMB1 : (GMAC Offset: 0x0C8) Specific Address 1 Mask Bottom [31:0] Register -------- */ -#define GMAC_SAMB1_ADDR_Pos 0 -#define GMAC_SAMB1_ADDR_Msk (0xffffffffu << GMAC_SAMB1_ADDR_Pos) /**< \brief (GMAC_SAMB1) Specific Address 1 Mask */ -#define GMAC_SAMB1_ADDR(value) ((GMAC_SAMB1_ADDR_Msk & ((value) << GMAC_SAMB1_ADDR_Pos))) -/* -------- GMAC_SAMT1 : (GMAC Offset: 0x0CC) Specific Address 1 Mask Top [47:32] Register -------- */ -#define GMAC_SAMT1_ADDR_Pos 0 -#define GMAC_SAMT1_ADDR_Msk (0xffffu << GMAC_SAMT1_ADDR_Pos) /**< \brief (GMAC_SAMT1) Specific Address 1 Mask */ -#define GMAC_SAMT1_ADDR(value) ((GMAC_SAMT1_ADDR_Msk & ((value) << GMAC_SAMT1_ADDR_Pos))) -/* -------- GMAC_OTLO : (GMAC Offset: 0x100) Octets Transmitted [31:0] Register -------- */ -#define GMAC_OTLO_TXO_Pos 0 -#define GMAC_OTLO_TXO_Msk (0xffffffffu << GMAC_OTLO_TXO_Pos) /**< \brief (GMAC_OTLO) Transmitted Octets */ -/* -------- GMAC_OTHI : (GMAC Offset: 0x104) Octets Transmitted [47:32] Register -------- */ -#define GMAC_OTHI_TXO_Pos 0 -#define GMAC_OTHI_TXO_Msk (0xffffu << GMAC_OTHI_TXO_Pos) /**< \brief (GMAC_OTHI) Transmitted Octets */ -/* -------- GMAC_FT : (GMAC Offset: 0x108) Frames Transmitted Register -------- */ -#define GMAC_FT_FTX_Pos 0 -#define GMAC_FT_FTX_Msk (0xffffffffu << GMAC_FT_FTX_Pos) /**< \brief (GMAC_FT) Frames Transmitted without Error */ -/* -------- GMAC_BCFT : (GMAC Offset: 0x10C) Broadcast Frames Transmitted Register -------- */ -#define GMAC_BCFT_BFTX_Pos 0 -#define GMAC_BCFT_BFTX_Msk (0xffffffffu << GMAC_BCFT_BFTX_Pos) /**< \brief (GMAC_BCFT) Broadcast Frames Transmitted without Error */ -/* -------- GMAC_MFT : (GMAC Offset: 0x110) Multicast Frames Transmitted Register -------- */ -#define GMAC_MFT_MFTX_Pos 0 -#define GMAC_MFT_MFTX_Msk (0xffffffffu << GMAC_MFT_MFTX_Pos) /**< \brief (GMAC_MFT) Multicast Frames Transmitted without Error */ -/* -------- GMAC_PFT : (GMAC Offset: 0x114) Pause Frames Transmitted Register -------- */ -#define GMAC_PFT_PFTX_Pos 0 -#define GMAC_PFT_PFTX_Msk (0xffffu << GMAC_PFT_PFTX_Pos) /**< \brief (GMAC_PFT) Pause Frames Transmitted Register */ -/* -------- GMAC_BFT64 : (GMAC Offset: 0x118) 64 Byte Frames Transmitted Register -------- */ -#define GMAC_BFT64_NFTX_Pos 0 -#define GMAC_BFT64_NFTX_Msk (0xffffffffu << GMAC_BFT64_NFTX_Pos) /**< \brief (GMAC_BFT64) 64 Byte Frames Transmitted without Error */ -/* -------- GMAC_TBFT127 : (GMAC Offset: 0x11C) 65 to 127 Byte Frames Transmitted Register -------- */ -#define GMAC_TBFT127_NFTX_Pos 0 -#define GMAC_TBFT127_NFTX_Msk (0xffffffffu << GMAC_TBFT127_NFTX_Pos) /**< \brief (GMAC_TBFT127) 65 to 127 Byte Frames Transmitted without Error */ -/* -------- GMAC_TBFT255 : (GMAC Offset: 0x120) 128 to 255 Byte Frames Transmitted Register -------- */ -#define GMAC_TBFT255_NFTX_Pos 0 -#define GMAC_TBFT255_NFTX_Msk (0xffffffffu << GMAC_TBFT255_NFTX_Pos) /**< \brief (GMAC_TBFT255) 128 to 255 Byte Frames Transmitted without Error */ -/* -------- GMAC_TBFT511 : (GMAC Offset: 0x124) 256 to 511 Byte Frames Transmitted Register -------- */ -#define GMAC_TBFT511_NFTX_Pos 0 -#define GMAC_TBFT511_NFTX_Msk (0xffffffffu << GMAC_TBFT511_NFTX_Pos) /**< \brief (GMAC_TBFT511) 256 to 511 Byte Frames Transmitted without Error */ -/* -------- GMAC_TBFT1023 : (GMAC Offset: 0x128) 512 to 1023 Byte Frames Transmitted Register -------- */ -#define GMAC_TBFT1023_NFTX_Pos 0 -#define GMAC_TBFT1023_NFTX_Msk (0xffffffffu << GMAC_TBFT1023_NFTX_Pos) /**< \brief (GMAC_TBFT1023) 512 to 1023 Byte Frames Transmitted without Error */ -/* -------- GMAC_TBFT1518 : (GMAC Offset: 0x12C) 1024 to 1518 Byte Frames Transmitted Register -------- */ -#define GMAC_TBFT1518_NFTX_Pos 0 -#define GMAC_TBFT1518_NFTX_Msk (0xffffffffu << GMAC_TBFT1518_NFTX_Pos) /**< \brief (GMAC_TBFT1518) 1024 to 1518 Byte Frames Transmitted without Error */ -/* -------- GMAC_GTBFT1518 : (GMAC Offset: 0x130) Greater Than 1518 Byte Frames Transmitted Register -------- */ -#define GMAC_GTBFT1518_NFTX_Pos 0 -#define GMAC_GTBFT1518_NFTX_Msk (0xffffffffu << GMAC_GTBFT1518_NFTX_Pos) /**< \brief (GMAC_GTBFT1518) Greater than 1518 Byte Frames Transmitted without Error */ -/* -------- GMAC_TUR : (GMAC Offset: 0x134) Transmit Under Runs Register -------- */ -#define GMAC_TUR_TXUNR_Pos 0 -#define GMAC_TUR_TXUNR_Msk (0x3ffu << GMAC_TUR_TXUNR_Pos) /**< \brief (GMAC_TUR) Transmit Under Runs */ -/* -------- GMAC_SCF : (GMAC Offset: 0x138) Single Collision Frames Register -------- */ -#define GMAC_SCF_SCOL_Pos 0 -#define GMAC_SCF_SCOL_Msk (0x3ffffu << GMAC_SCF_SCOL_Pos) /**< \brief (GMAC_SCF) Single Collision */ -/* -------- GMAC_MCF : (GMAC Offset: 0x13C) Multiple Collision Frames Register -------- */ -#define GMAC_MCF_MCOL_Pos 0 -#define GMAC_MCF_MCOL_Msk (0x3ffffu << GMAC_MCF_MCOL_Pos) /**< \brief (GMAC_MCF) Multiple Collision */ -/* -------- GMAC_EC : (GMAC Offset: 0x140) Excessive Collisions Register -------- */ -#define GMAC_EC_XCOL_Pos 0 -#define GMAC_EC_XCOL_Msk (0x3ffu << GMAC_EC_XCOL_Pos) /**< \brief (GMAC_EC) Excessive Collisions */ -/* -------- GMAC_LC : (GMAC Offset: 0x144) Late Collisions Register -------- */ -#define GMAC_LC_LCOL_Pos 0 -#define GMAC_LC_LCOL_Msk (0x3ffu << GMAC_LC_LCOL_Pos) /**< \brief (GMAC_LC) Late Collisions */ -/* -------- GMAC_DTF : (GMAC Offset: 0x148) Deferred Transmission Frames Register -------- */ -#define GMAC_DTF_DEFT_Pos 0 -#define GMAC_DTF_DEFT_Msk (0x3ffffu << GMAC_DTF_DEFT_Pos) /**< \brief (GMAC_DTF) Deferred Transmission */ -/* -------- GMAC_CSE : (GMAC Offset: 0x14C) Carrier Sense Errors Register -------- */ -#define GMAC_CSE_CSR_Pos 0 -#define GMAC_CSE_CSR_Msk (0x3ffu << GMAC_CSE_CSR_Pos) /**< \brief (GMAC_CSE) Carrier Sense Error */ -/* -------- GMAC_ORLO : (GMAC Offset: 0x150) Octets Received [31:0] Received -------- */ -#define GMAC_ORLO_RXO_Pos 0 -#define GMAC_ORLO_RXO_Msk (0xffffffffu << GMAC_ORLO_RXO_Pos) /**< \brief (GMAC_ORLO) Received Octets */ -/* -------- GMAC_ORHI : (GMAC Offset: 0x154) Octets Received [47:32] Received -------- */ -#define GMAC_ORHI_RXO_Pos 0 -#define GMAC_ORHI_RXO_Msk (0xffffu << GMAC_ORHI_RXO_Pos) /**< \brief (GMAC_ORHI) Received Octets */ -/* -------- GMAC_FR : (GMAC Offset: 0x158) Frames Received Register -------- */ -#define GMAC_FR_FRX_Pos 0 -#define GMAC_FR_FRX_Msk (0xffffffffu << GMAC_FR_FRX_Pos) /**< \brief (GMAC_FR) Frames Received without Error */ -/* -------- GMAC_BCFR : (GMAC Offset: 0x15C) Broadcast Frames Received Register -------- */ -#define GMAC_BCFR_BFRX_Pos 0 -#define GMAC_BCFR_BFRX_Msk (0xffffffffu << GMAC_BCFR_BFRX_Pos) /**< \brief (GMAC_BCFR) Broadcast Frames Received without Error */ -/* -------- GMAC_MFR : (GMAC Offset: 0x160) Multicast Frames Received Register -------- */ -#define GMAC_MFR_MFRX_Pos 0 -#define GMAC_MFR_MFRX_Msk (0xffffffffu << GMAC_MFR_MFRX_Pos) /**< \brief (GMAC_MFR) Multicast Frames Received without Error */ -/* -------- GMAC_PFR : (GMAC Offset: 0x164) Pause Frames Received Register -------- */ -#define GMAC_PFR_PFRX_Pos 0 -#define GMAC_PFR_PFRX_Msk (0xffffu << GMAC_PFR_PFRX_Pos) /**< \brief (GMAC_PFR) Pause Frames Received Register */ -/* -------- GMAC_BFR64 : (GMAC Offset: 0x168) 64 Byte Frames Received Register -------- */ -#define GMAC_BFR64_NFRX_Pos 0 -#define GMAC_BFR64_NFRX_Msk (0xffffffffu << GMAC_BFR64_NFRX_Pos) /**< \brief (GMAC_BFR64) 64 Byte Frames Received without Error */ -/* -------- GMAC_TBFR127 : (GMAC Offset: 0x16C) 65 to 127 Byte Frames Received Register -------- */ -#define GMAC_TBFR127_NFRX_Pos 0 -#define GMAC_TBFR127_NFRX_Msk (0xffffffffu << GMAC_TBFR127_NFRX_Pos) /**< \brief (GMAC_TBFR127) 65 to 127 Byte Frames Received without Error */ -/* -------- GMAC_TBFR255 : (GMAC Offset: 0x170) 128 to 255 Byte Frames Received Register -------- */ -#define GMAC_TBFR255_NFRX_Pos 0 -#define GMAC_TBFR255_NFRX_Msk (0xffffffffu << GMAC_TBFR255_NFRX_Pos) /**< \brief (GMAC_TBFR255) 128 to 255 Byte Frames Received without Error */ -/* -------- GMAC_TBFR511 : (GMAC Offset: 0x174) 256 to 511Byte Frames Received Register -------- */ -#define GMAC_TBFR511_NFRX_Pos 0 -#define GMAC_TBFR511_NFRX_Msk (0xffffffffu << GMAC_TBFR511_NFRX_Pos) /**< \brief (GMAC_TBFR511) 256 to 511 Byte Frames Received without Error */ -/* -------- GMAC_TBFR1023 : (GMAC Offset: 0x178) 512 to 1023 Byte Frames Received Register -------- */ -#define GMAC_TBFR1023_NFRX_Pos 0 -#define GMAC_TBFR1023_NFRX_Msk (0xffffffffu << GMAC_TBFR1023_NFRX_Pos) /**< \brief (GMAC_TBFR1023) 512 to 1023 Byte Frames Received without Error */ -/* -------- GMAC_TBFR1518 : (GMAC Offset: 0x17C) 1024 to 1518 Byte Frames Received Register -------- */ -#define GMAC_TBFR1518_NFRX_Pos 0 -#define GMAC_TBFR1518_NFRX_Msk (0xffffffffu << GMAC_TBFR1518_NFRX_Pos) /**< \brief (GMAC_TBFR1518) 1024 to 1518 Byte Frames Received without Error */ -/* -------- GMAC_TMXBFR : (GMAC Offset: 0x180) 1519 to Maximum Byte Frames Received Register -------- */ -#define GMAC_TMXBFR_NFRX_Pos 0 -#define GMAC_TMXBFR_NFRX_Msk (0xffffffffu << GMAC_TMXBFR_NFRX_Pos) /**< \brief (GMAC_TMXBFR) 1519 to Maximum Byte Frames Received without Error */ -/* -------- GMAC_UFR : (GMAC Offset: 0x184) Undersize Frames Received Register -------- */ -#define GMAC_UFR_UFRX_Pos 0 -#define GMAC_UFR_UFRX_Msk (0x3ffu << GMAC_UFR_UFRX_Pos) /**< \brief (GMAC_UFR) Undersize Frames Received */ -/* -------- GMAC_OFR : (GMAC Offset: 0x188) Oversize Frames Received Register -------- */ -#define GMAC_OFR_OFRX_Pos 0 -#define GMAC_OFR_OFRX_Msk (0x3ffu << GMAC_OFR_OFRX_Pos) /**< \brief (GMAC_OFR) Oversized Frames Received */ -/* -------- GMAC_JR : (GMAC Offset: 0x18C) Jabbers Received Register -------- */ -#define GMAC_JR_JRX_Pos 0 -#define GMAC_JR_JRX_Msk (0x3ffu << GMAC_JR_JRX_Pos) /**< \brief (GMAC_JR) Jabbers Received */ -/* -------- GMAC_FCSE : (GMAC Offset: 0x190) Frame Check Sequence Errors Register -------- */ -#define GMAC_FCSE_FCKR_Pos 0 -#define GMAC_FCSE_FCKR_Msk (0x3ffu << GMAC_FCSE_FCKR_Pos) /**< \brief (GMAC_FCSE) Frame Check Sequence Errors */ -/* -------- GMAC_LFFE : (GMAC Offset: 0x194) Length Field Frame Errors Register -------- */ -#define GMAC_LFFE_LFER_Pos 0 -#define GMAC_LFFE_LFER_Msk (0x3ffu << GMAC_LFFE_LFER_Pos) /**< \brief (GMAC_LFFE) Length Field Frame Errors */ -/* -------- GMAC_RSE : (GMAC Offset: 0x198) Receive Symbol Errors Register -------- */ -#define GMAC_RSE_RXSE_Pos 0 -#define GMAC_RSE_RXSE_Msk (0x3ffu << GMAC_RSE_RXSE_Pos) /**< \brief (GMAC_RSE) Receive Symbol Errors */ -/* -------- GMAC_AE : (GMAC Offset: 0x19C) Alignment Errors Register -------- */ -#define GMAC_AE_AER_Pos 0 -#define GMAC_AE_AER_Msk (0x3ffu << GMAC_AE_AER_Pos) /**< \brief (GMAC_AE) Alignment Errors */ -/* -------- GMAC_RRE : (GMAC Offset: 0x1A0) Receive Resource Errors Register -------- */ -#define GMAC_RRE_RXRER_Pos 0 -#define GMAC_RRE_RXRER_Msk (0x3ffffu << GMAC_RRE_RXRER_Pos) /**< \brief (GMAC_RRE) Receive Resource Errors */ -/* -------- GMAC_ROE : (GMAC Offset: 0x1A4) Receive Overrun Register -------- */ -#define GMAC_ROE_RXOVR_Pos 0 -#define GMAC_ROE_RXOVR_Msk (0x3ffu << GMAC_ROE_RXOVR_Pos) /**< \brief (GMAC_ROE) Receive Overruns */ -/* -------- GMAC_IHCE : (GMAC Offset: 0x1A8) IP Header Checksum Errors Register -------- */ -#define GMAC_IHCE_HCKER_Pos 0 -#define GMAC_IHCE_HCKER_Msk (0xffu << GMAC_IHCE_HCKER_Pos) /**< \brief (GMAC_IHCE) IP Header Checksum Errors */ -/* -------- GMAC_TCE : (GMAC Offset: 0x1AC) TCP Checksum Errors Register -------- */ -#define GMAC_TCE_TCKER_Pos 0 -#define GMAC_TCE_TCKER_Msk (0xffu << GMAC_TCE_TCKER_Pos) /**< \brief (GMAC_TCE) TCP Checksum Errors */ -/* -------- GMAC_UCE : (GMAC Offset: 0x1B0) UDP Checksum Errors Register -------- */ -#define GMAC_UCE_UCKER_Pos 0 -#define GMAC_UCE_UCKER_Msk (0xffu << GMAC_UCE_UCKER_Pos) /**< \brief (GMAC_UCE) UDP Checksum Errors */ -/* -------- GMAC_TSSS : (GMAC Offset: 0x1C8) 1588 Timer Sync Strobe Seconds Register -------- */ -#define GMAC_TSSS_VTS_Pos 0 -#define GMAC_TSSS_VTS_Msk (0xffffffffu << GMAC_TSSS_VTS_Pos) /**< \brief (GMAC_TSSS) Value of Timer Seconds Register Capture */ -#define GMAC_TSSS_VTS(value) ((GMAC_TSSS_VTS_Msk & ((value) << GMAC_TSSS_VTS_Pos))) -/* -------- GMAC_TSSN : (GMAC Offset: 0x1CC) 1588 Timer Sync Strobe Nanoseconds Register -------- */ -#define GMAC_TSSN_VTN_Pos 0 -#define GMAC_TSSN_VTN_Msk (0x3fffffffu << GMAC_TSSN_VTN_Pos) /**< \brief (GMAC_TSSN) Value Timer Nanoseconds Register Capture */ -#define GMAC_TSSN_VTN(value) ((GMAC_TSSN_VTN_Msk & ((value) << GMAC_TSSN_VTN_Pos))) -/* -------- GMAC_TS : (GMAC Offset: 0x1D0) 1588 Timer Seconds Register -------- */ -#define GMAC_TS_TCS_Pos 0 -#define GMAC_TS_TCS_Msk (0xffffffffu << GMAC_TS_TCS_Pos) /**< \brief (GMAC_TS) Timer Count in Seconds */ -#define GMAC_TS_TCS(value) ((GMAC_TS_TCS_Msk & ((value) << GMAC_TS_TCS_Pos))) -/* -------- GMAC_TN : (GMAC Offset: 0x1D4) 1588 Timer Nanoseconds Register -------- */ -#define GMAC_TN_TNS_Pos 0 -#define GMAC_TN_TNS_Msk (0x3fffffffu << GMAC_TN_TNS_Pos) /**< \brief (GMAC_TN) Timer Count in Nanoseconds */ -#define GMAC_TN_TNS(value) ((GMAC_TN_TNS_Msk & ((value) << GMAC_TN_TNS_Pos))) -/* -------- GMAC_TA : (GMAC Offset: 0x1D8) 1588 Timer Adjust Register -------- */ -#define GMAC_TA_ITDT_Pos 0 -#define GMAC_TA_ITDT_Msk (0x3fffffffu << GMAC_TA_ITDT_Pos) /**< \brief (GMAC_TA) Increment/Decrement */ -#define GMAC_TA_ITDT(value) ((GMAC_TA_ITDT_Msk & ((value) << GMAC_TA_ITDT_Pos))) -#define GMAC_TA_ADJ (0x1u << 31) /**< \brief (GMAC_TA) Adjust 1588 Timer */ -/* -------- GMAC_TI : (GMAC Offset: 0x1DC) 1588 Timer Increment Register -------- */ -#define GMAC_TI_CNS_Pos 0 -#define GMAC_TI_CNS_Msk (0xffu << GMAC_TI_CNS_Pos) /**< \brief (GMAC_TI) Count Nanoseconds */ -#define GMAC_TI_CNS(value) ((GMAC_TI_CNS_Msk & ((value) << GMAC_TI_CNS_Pos))) -#define GMAC_TI_ACNS_Pos 8 -#define GMAC_TI_ACNS_Msk (0xffu << GMAC_TI_ACNS_Pos) /**< \brief (GMAC_TI) Alternative Count Nanoseconds */ -#define GMAC_TI_ACNS(value) ((GMAC_TI_ACNS_Msk & ((value) << GMAC_TI_ACNS_Pos))) -#define GMAC_TI_NIT_Pos 16 -#define GMAC_TI_NIT_Msk (0xffu << GMAC_TI_NIT_Pos) /**< \brief (GMAC_TI) Number of Increments */ -#define GMAC_TI_NIT(value) ((GMAC_TI_NIT_Msk & ((value) << GMAC_TI_NIT_Pos))) -/* -------- GMAC_EFTS : (GMAC Offset: 0x1E0) PTP Event Frame Transmitted Seconds -------- */ -#define GMAC_EFTS_RUD_Pos 0 -#define GMAC_EFTS_RUD_Msk (0xffffffffu << GMAC_EFTS_RUD_Pos) /**< \brief (GMAC_EFTS) Register Update */ -/* -------- GMAC_EFTN : (GMAC Offset: 0x1E4) PTP Event Frame Transmitted Nanoseconds -------- */ -#define GMAC_EFTN_RUD_Pos 0 -#define GMAC_EFTN_RUD_Msk (0x3fffffffu << GMAC_EFTN_RUD_Pos) /**< \brief (GMAC_EFTN) Register Update */ -/* -------- GMAC_EFRS : (GMAC Offset: 0x1E8) PTP Event Frame Received Seconds -------- */ -#define GMAC_EFRS_RUD_Pos 0 -#define GMAC_EFRS_RUD_Msk (0xffffffffu << GMAC_EFRS_RUD_Pos) /**< \brief (GMAC_EFRS) Register Update */ -/* -------- GMAC_EFRN : (GMAC Offset: 0x1EC) PTP Event Frame Received Nanoseconds -------- */ -#define GMAC_EFRN_RUD_Pos 0 -#define GMAC_EFRN_RUD_Msk (0x3fffffffu << GMAC_EFRN_RUD_Pos) /**< \brief (GMAC_EFRN) Register Update */ -/* -------- GMAC_PEFTS : (GMAC Offset: 0x1F0) PTP Peer Event Frame Transmitted Seconds -------- */ -#define GMAC_PEFTS_RUD_Pos 0 -#define GMAC_PEFTS_RUD_Msk (0xffffffffu << GMAC_PEFTS_RUD_Pos) /**< \brief (GMAC_PEFTS) Register Update */ -/* -------- GMAC_PEFTN : (GMAC Offset: 0x1F4) PTP Peer Event Frame Transmitted Nanoseconds -------- */ -#define GMAC_PEFTN_RUD_Pos 0 -#define GMAC_PEFTN_RUD_Msk (0x3fffffffu << GMAC_PEFTN_RUD_Pos) /**< \brief (GMAC_PEFTN) Register Update */ -/* -------- GMAC_PEFRS : (GMAC Offset: 0x1F8) PTP Peer Event Frame Received Seconds -------- */ -#define GMAC_PEFRS_RUD_Pos 0 -#define GMAC_PEFRS_RUD_Msk (0xffffffffu << GMAC_PEFRS_RUD_Pos) /**< \brief (GMAC_PEFRS) Register Update */ -/* -------- GMAC_PEFRN : (GMAC Offset: 0x1FC) PTP Peer Event Frame Received Nanoseconds -------- */ -#define GMAC_PEFRN_RUD_Pos 0 -#define GMAC_PEFRN_RUD_Msk (0x3fffffffu << GMAC_PEFRN_RUD_Pos) /**< \brief (GMAC_PEFRN) Register Update */ -/* -------- GMAC_ISRPQ[7] : (GMAC Offset: 0x400) Interrupt Status Register Priority Queue -------- */ -#define GMAC_ISRPQ_RCOMP (0x1u << 1) /**< \brief (GMAC_ISRPQ[7]) Receive Complete */ -#define GMAC_ISRPQ_RXUBR (0x1u << 2) /**< \brief (GMAC_ISRPQ[7]) RX Used Bit Read */ -#define GMAC_ISRPQ_RLEX (0x1u << 5) /**< \brief (GMAC_ISRPQ[7]) Retry Limit Exceeded or Late Collision */ -#define GMAC_ISRPQ_TFC (0x1u << 6) /**< \brief (GMAC_ISRPQ[7]) Transmit Frame Corruption due to AHB error */ -#define GMAC_ISRPQ_TCOMP (0x1u << 7) /**< \brief (GMAC_ISRPQ[7]) Transmit Complete */ -#define GMAC_ISRPQ_ROVR (0x1u << 10) /**< \brief (GMAC_ISRPQ[7]) Receive Overrun */ -#define GMAC_ISRPQ_HRESP (0x1u << 11) /**< \brief (GMAC_ISRPQ[7]) HRESP Not OK */ -/* -------- GMAC_TBQBAPQ[7] : (GMAC Offset: 0x440) Transmit Buffer Queue Base Address Priority Queue -------- */ -#define GMAC_TBQBAPQ_TXBQBA_Pos 2 -#define GMAC_TBQBAPQ_TXBQBA_Msk (0x3fu << GMAC_TBQBAPQ_TXBQBA_Pos) /**< \brief (GMAC_TBQBAPQ[7]) Transmit Buffer Queue Base Address */ -#define GMAC_TBQBAPQ_TXBQBA(value) ((GMAC_TBQBAPQ_TXBQBA_Msk & ((value) << GMAC_TBQBAPQ_TXBQBA_Pos))) -/* -------- GMAC_RBQBAPQ[7] : (GMAC Offset: 0x480) Receive Buffer Queue Base Address Priority Queue -------- */ -#define GMAC_RBQBAPQ_RXBQBA_Pos 2 -#define GMAC_RBQBAPQ_RXBQBA_Msk (0x3fu << GMAC_RBQBAPQ_RXBQBA_Pos) /**< \brief (GMAC_RBQBAPQ[7]) Receive Buffer Queue Base Address */ -#define GMAC_RBQBAPQ_RXBQBA(value) ((GMAC_RBQBAPQ_RXBQBA_Msk & ((value) << GMAC_RBQBAPQ_RXBQBA_Pos))) -/* -------- GMAC_RBSRPQ[7] : (GMAC Offset: 0x4A0) Receive Buffer Size Register Priority Queue -------- */ -#define GMAC_RBSRPQ_RBS_Pos 0 -#define GMAC_RBSRPQ_RBS_Msk (0xffffu << GMAC_RBSRPQ_RBS_Pos) /**< \brief (GMAC_RBSRPQ[7]) Receive Buffer Size */ -#define GMAC_RBSRPQ_RBS(value) ((GMAC_RBSRPQ_RBS_Msk & ((value) << GMAC_RBSRPQ_RBS_Pos))) -/* -------- GMAC_ST1RPQ[16] : (GMAC Offset: 0x500) Screening Type1 Register Priority Queue -------- */ -#define GMAC_ST1RPQ_QNB_Pos 0 -#define GMAC_ST1RPQ_QNB_Msk (0xfu << GMAC_ST1RPQ_QNB_Pos) /**< \brief (GMAC_ST1RPQ[16]) Que Number (0->7) */ -#define GMAC_ST1RPQ_QNB(value) ((GMAC_ST1RPQ_QNB_Msk & ((value) << GMAC_ST1RPQ_QNB_Pos))) -#define GMAC_ST1RPQ_DSTCM_Pos 4 -#define GMAC_ST1RPQ_DSTCM_Msk (0xffu << GMAC_ST1RPQ_DSTCM_Pos) /**< \brief (GMAC_ST1RPQ[16]) Differentiated Services or Traffic Class Match */ -#define GMAC_ST1RPQ_DSTCM(value) ((GMAC_ST1RPQ_DSTCM_Msk & ((value) << GMAC_ST1RPQ_DSTCM_Pos))) -#define GMAC_ST1RPQ_UDPM_Pos 12 -#define GMAC_ST1RPQ_UDPM_Msk (0xffffu << GMAC_ST1RPQ_UDPM_Pos) /**< \brief (GMAC_ST1RPQ[16]) UDP Port Match */ -#define GMAC_ST1RPQ_UDPM(value) ((GMAC_ST1RPQ_UDPM_Msk & ((value) << GMAC_ST1RPQ_UDPM_Pos))) -#define GMAC_ST1RPQ_DSTCE (0x1u << 28) /**< \brief (GMAC_ST1RPQ[16]) Differentiated Services or Traffic Class Match Enable */ -#define GMAC_ST1RPQ_UDPE (0x1u << 29) /**< \brief (GMAC_ST1RPQ[16]) UDP Port Match Enable */ -/* -------- GMAC_ST2RPQ[16] : (GMAC Offset: 0x540) Screening Type2 Register Priority Queue -------- */ -#define GMAC_ST2RPQ_QNB_Pos 0 -#define GMAC_ST2RPQ_QNB_Msk (0xfu << GMAC_ST2RPQ_QNB_Pos) /**< \brief (GMAC_ST2RPQ[16]) Que Number (0->7) */ -#define GMAC_ST2RPQ_QNB(value) ((GMAC_ST2RPQ_QNB_Msk & ((value) << GMAC_ST2RPQ_QNB_Pos))) -#define GMAC_ST2RPQ_VLANP_Pos 4 -#define GMAC_ST2RPQ_VLANP_Msk (0xfu << GMAC_ST2RPQ_VLANP_Pos) /**< \brief (GMAC_ST2RPQ[16]) VLAN Priority */ -#define GMAC_ST2RPQ_VLANP(value) ((GMAC_ST2RPQ_VLANP_Msk & ((value) << GMAC_ST2RPQ_VLANP_Pos))) -#define GMAC_ST2RPQ_VLANE (0x1u << 8) /**< \brief (GMAC_ST2RPQ[16]) VLAN Enable */ -/* -------- GMAC_IERPQ[7] : (GMAC Offset: 0x600) Interrupt Enable Register Priority Queue -------- */ -#define GMAC_IERPQ_RCOMP (0x1u << 1) /**< \brief (GMAC_IERPQ[7]) Receive Complete */ -#define GMAC_IERPQ_RXUBR (0x1u << 2) /**< \brief (GMAC_IERPQ[7]) RX Used Bit Read */ -#define GMAC_IERPQ_RLEX (0x1u << 5) /**< \brief (GMAC_IERPQ[7]) Retry Limit Exceeded or Late Collision */ -#define GMAC_IERPQ_TFC (0x1u << 6) /**< \brief (GMAC_IERPQ[7]) Transmit Frame Corruption due to AHB error */ -#define GMAC_IERPQ_TCOMP (0x1u << 7) /**< \brief (GMAC_IERPQ[7]) Transmit Complete */ -#define GMAC_IERPQ_ROVR (0x1u << 10) /**< \brief (GMAC_IERPQ[7]) Receive Overrun */ -#define GMAC_IERPQ_HRESP (0x1u << 11) /**< \brief (GMAC_IERPQ[7]) HRESP Not OK */ -/* -------- GMAC_IDRPQ[7] : (GMAC Offset: 0x620) Interrupt Disable Register Priority Queue -------- */ -#define GMAC_IDRPQ_RCOMP (0x1u << 1) /**< \brief (GMAC_IDRPQ[7]) Receive Complete */ -#define GMAC_IDRPQ_RXUBR (0x1u << 2) /**< \brief (GMAC_IDRPQ[7]) RX Used Bit Read */ -#define GMAC_IDRPQ_RLEX (0x1u << 5) /**< \brief (GMAC_IDRPQ[7]) Retry Limit Exceeded or Late Collision */ -#define GMAC_IDRPQ_TFC (0x1u << 6) /**< \brief (GMAC_IDRPQ[7]) Transmit Frame Corruption due to AHB error */ -#define GMAC_IDRPQ_TCOMP (0x1u << 7) /**< \brief (GMAC_IDRPQ[7]) Transmit Complete */ -#define GMAC_IDRPQ_ROVR (0x1u << 10) /**< \brief (GMAC_IDRPQ[7]) Receive Overrun */ -#define GMAC_IDRPQ_HRESP (0x1u << 11) /**< \brief (GMAC_IDRPQ[7]) HRESP Not OK */ -/* -------- GMAC_IMRPQ[7] : (GMAC Offset: 0x640) Interrupt Mask Register Priority Queue -------- */ -#define GMAC_IMRPQ_RCOMP (0x1u << 1) /**< \brief (GMAC_IMRPQ[7]) Receive Complete */ -#define GMAC_IMRPQ_RXUBR (0x1u << 2) /**< \brief (GMAC_IMRPQ[7]) RX Used Bit Read */ -#define GMAC_IMRPQ_RLEX (0x1u << 5) /**< \brief (GMAC_IMRPQ[7]) Retry Limit Exceeded or Late Collision */ -#define GMAC_IMRPQ_AHB (0x1u << 6) /**< \brief (GMAC_IMRPQ[7]) AHB Error */ -#define GMAC_IMRPQ_TCOMP (0x1u << 7) /**< \brief (GMAC_IMRPQ[7]) Transmit Complete */ -#define GMAC_IMRPQ_ROVR (0x1u << 10) /**< \brief (GMAC_IMRPQ[7]) Receive Overrun */ -#define GMAC_IMRPQ_HRESP (0x1u << 11) /**< \brief (GMAC_IMRPQ[7]) HRESP Not OK */ - -/*@}*/ - - -#endif /* _SAM4E_GMAC_COMPONENT_ */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/ethernet_phy.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/ethernet_phy.c deleted file mode 100755 index fc72c6a..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/ethernet_phy.c +++ /dev/null @@ -1,454 +0,0 @@ - /** - * \file - * - * \brief API driver for KSZ8051MNL PHY component. - * - * Copyright (c) 2013 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -/* Standard includes. */ -#include -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "FreeRTOSIPConfig.h" - -#include "ethernet_phy.h" -#include "instance/gmac.h" - -/// @cond 0 -/**INDENT-OFF**/ -#ifdef __cplusplus -extern "C" { -#endif -/**INDENT-ON**/ -/// @endcond - -/** - * \defgroup ksz8051mnl_ethernet_phy_group PHY component (KSZ8051MNL) - * - * Driver for the ksz8051mnl component. This driver provides access to the main - * features of the PHY. - * - * \section dependencies Dependencies - * This driver depends on the following modules: - * - \ref gmac_group Ethernet Media Access Controller (GMAC) module. - * - * @{ - */ - -SPhyProps phyProps; - -/* Max PHY number */ -#define ETH_PHY_MAX_ADDR 31 - -/* Ethernet PHY operation max retry count */ -#define ETH_PHY_RETRY_MAX 1000000 - -/* Ethernet PHY operation timeout */ -#define ETH_PHY_TIMEOUT 10 - -/** - * \brief Find a valid PHY Address ( from addrStart to 31 ). - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_phy_addr PHY address. - * \param uc_start_addr Start address of the PHY to be searched. - * - * \return 0xFF when no valid PHY address is found. - */ -int ethernet_phy_addr = 0; -static uint8_t ethernet_phy_find_valid(Gmac *p_gmac, uint8_t uc_phy_addr, - uint8_t uc_start_addr) -{ - uint32_t ul_value = 0; - uint8_t uc_cnt; - uint8_t uc_phy_address = uc_phy_addr; - - gmac_enable_management(p_gmac, true); -/* -#define GMII_OUI_MSB 0x0022 -#define GMII_OUI_LSB 0x05 - -PHYID1 = 0x0022 -PHYID2 = 0x1550 -0001_0101_0101_0000 = 0x1550 <= mask should be 0xFFF0 -*/ - /* Check the current PHY address */ - gmac_phy_read(p_gmac, uc_phy_addr, GMII_PHYID1, &ul_value); - - /* Find another one */ - if (ul_value != GMII_OUI_MSB) { - ethernet_phy_addr = 0xFF; - for (uc_cnt = uc_start_addr; uc_cnt <= ETH_PHY_MAX_ADDR; uc_cnt++) { - uc_phy_address = (uc_phy_address + 1) & 0x1F; - ul_value = 0; - gmac_phy_read(p_gmac, uc_phy_address, GMII_PHYID1, &ul_value); - if (ul_value == GMII_OUI_MSB) { - ethernet_phy_addr = uc_phy_address; - break; - } - } - } - - gmac_enable_management(p_gmac, false); - - if (ethernet_phy_addr != 0xFF) { - gmac_phy_read(p_gmac, uc_phy_address, GMII_BMSR, &ul_value); - } - return ethernet_phy_addr; -} - - -/** - * \brief Perform a HW initialization to the PHY and set up clocks. - * - * This should be called only once to initialize the PHY pre-settings. - * The PHY address is the reset status of CRS, RXD[3:0] (the emacPins' pullups). - * The COL pin is used to select MII mode on reset (pulled up for Reduced MII). - * The RXDV pin is used to select test mode on reset (pulled up for test mode). - * The above pins should be predefined for corresponding settings in resetPins. - * The GMAC peripheral pins are configured after the reset is done. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_phy_addr PHY address. - * \param ul_mck GMAC MCK. - * - * Return GMAC_OK if successfully, GMAC_TIMEOUT if timeout. - */ -uint8_t ethernet_phy_init(Gmac *p_gmac, uint8_t uc_phy_addr, uint32_t mck) -{ - uint8_t uc_rc = GMAC_TIMEOUT; - uint8_t uc_phy; - - ethernet_phy_reset(GMAC,uc_phy_addr); - - /* Configure GMAC runtime clock */ - uc_rc = gmac_set_mdc_clock(p_gmac, mck); - if (uc_rc != GMAC_OK) { - return 0; - } - - /* Check PHY Address */ - uc_phy = ethernet_phy_find_valid(p_gmac, uc_phy_addr, 0); - if (uc_phy == 0xFF) { - return 0; - } - if (uc_phy != uc_phy_addr) { - ethernet_phy_reset(p_gmac, uc_phy_addr); - } - phy_props.phy_chn = uc_phy; - return uc_phy; -} - - -/** - * \brief Get the Link & speed settings, and automatically set up the GMAC with the - * settings. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_phy_addr PHY address. - * \param uc_apply_setting_flag Set to 0 to not apply the PHY configurations, else to apply. - * - * Return GMAC_OK if successfully, GMAC_TIMEOUT if timeout. - */ -uint8_t ethernet_phy_set_link(Gmac *p_gmac, uint8_t uc_phy_addr, - uint8_t uc_apply_setting_flag) -{ - uint32_t ul_stat1; - uint32_t ul_stat2; - uint8_t uc_phy_address, uc_speed = true, uc_fd = true; - uint8_t uc_rc = GMAC_TIMEOUT; - - gmac_enable_management(p_gmac, true); - - uc_phy_address = uc_phy_addr; - - uc_rc = gmac_phy_read(p_gmac, uc_phy_address, GMII_BMSR, &ul_stat1); - if (uc_rc != GMAC_OK) { - /* Disable PHY management and start the GMAC transfer */ - gmac_enable_management(p_gmac, false); - - return uc_rc; - } - if ((ul_stat1 & GMII_LINK_STATUS) == 0) { - /* Disable PHY management and start the GMAC transfer */ - gmac_enable_management(p_gmac, false); - - return GMAC_INVALID; - } - - if (uc_apply_setting_flag == 0) { - /* Disable PHY management and start the GMAC transfer */ - gmac_enable_management(p_gmac, false); - - return uc_rc; - } - - /* Read advertisement */ - uc_rc = gmac_phy_read(p_gmac, uc_phy_address, GMII_ANAR, &ul_stat2); -phy_props.phy_stat1 = ul_stat1; -phy_props.phy_stat2 = ul_stat2; - if (uc_rc != GMAC_OK) { - /* Disable PHY management and start the GMAC transfer */ - gmac_enable_management(p_gmac, false); - - return uc_rc; - } - - if ((ul_stat1 & GMII_100BASE_TX_FD) && (ul_stat2 & GMII_100TX_FDX)) { - /* Set GMAC for 100BaseTX and Full Duplex */ - uc_speed = true; - uc_fd = true; - } else - if ((ul_stat1 & GMII_100BASE_T4_HD) && (ul_stat2 & GMII_100TX_HDX)) { - /* Set MII for 100BaseTX and Half Duplex */ - uc_speed = true; - uc_fd = false; - } else - if ((ul_stat1 & GMII_10BASE_T_FD) && (ul_stat2 & GMII_10_FDX)) { - /* Set MII for 10BaseT and Full Duplex */ - uc_speed = false; - uc_fd = true; - } else - if ((ul_stat1 & GMII_10BASE_T_HD) && (ul_stat2 & GMII_10_HDX)) { - /* Set MII for 10BaseT and Half Duplex */ - uc_speed = false; - uc_fd = false; - } - - gmac_set_speed(p_gmac, uc_speed); - gmac_enable_full_duplex(p_gmac, uc_fd); - - /* Start the GMAC transfers */ - gmac_enable_management(p_gmac, false); - return uc_rc; -} - -PhyProps_t phy_props; - -/** - * \brief Issue an auto negotiation of the PHY. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_phy_addr PHY address. - * - * Return GMAC_OK if successfully, GMAC_TIMEOUT if timeout. - */ -uint8_t ethernet_phy_auto_negotiate(Gmac *p_gmac, uint8_t uc_phy_addr) -{ - uint32_t ul_retry_max = ETH_PHY_RETRY_MAX; - uint32_t ul_value; - uint32_t ul_phy_anar; - uint32_t ul_retry_count = 0; - uint8_t uc_speed = 0; - uint8_t uc_fd=0; - uint8_t uc_rc = GMAC_TIMEOUT; - - gmac_enable_management(p_gmac, true); - - /* Set up control register */ - uc_rc = gmac_phy_read(p_gmac, uc_phy_addr, GMII_BMCR, &ul_value); - if (uc_rc != GMAC_OK) { - gmac_enable_management(p_gmac, false); -phy_props.phy_result = -1; - return uc_rc; - } - - ul_value &= ~(uint32_t)GMII_AUTONEG; /* Remove auto-negotiation enable */ - ul_value &= ~(uint32_t)(GMII_LOOPBACK | GMII_POWER_DOWN); - ul_value |= (uint32_t)GMII_ISOLATE; /* Electrically isolate PHY */ - uc_rc = gmac_phy_write(p_gmac, uc_phy_addr, GMII_BMCR, ul_value); - if (uc_rc != GMAC_OK) { - gmac_enable_management(p_gmac, false); -phy_props.phy_result = -2; - return uc_rc; - } - - /* - * Set the Auto_negotiation Advertisement Register. - * MII advertising for Next page. - * 100BaseTxFD and HD, 10BaseTFD and HD, IEEE 802.3. - */ - ul_phy_anar = GMII_100TX_FDX | GMII_100TX_HDX | GMII_10_FDX | GMII_10_HDX | - GMII_AN_IEEE_802_3; - uc_rc = gmac_phy_write(p_gmac, uc_phy_addr, GMII_ANAR, ul_phy_anar); - if (uc_rc != GMAC_OK) { - gmac_enable_management(p_gmac, false); -phy_props.phy_result = -3; - return uc_rc; - } - - /* Read & modify control register */ - uc_rc = gmac_phy_read(p_gmac, uc_phy_addr, GMII_BMCR, &ul_value); - if (uc_rc != GMAC_OK) { - gmac_enable_management(p_gmac, false); -phy_props.phy_result = -4; - return uc_rc; - } - - ul_value |= GMII_SPEED_SELECT | GMII_AUTONEG | GMII_DUPLEX_MODE; - uc_rc = gmac_phy_write(p_gmac, uc_phy_addr, GMII_BMCR, ul_value); - if (uc_rc != GMAC_OK) { - gmac_enable_management(p_gmac, false); -phy_props.phy_result = -5; - return uc_rc; - } - - /* Restart auto negotiation */ - ul_value |= (uint32_t)GMII_RESTART_AUTONEG; - ul_value &= ~(uint32_t)GMII_ISOLATE; - uc_rc = gmac_phy_write(p_gmac, uc_phy_addr, GMII_BMCR, ul_value); - if (uc_rc != GMAC_OK) { - gmac_enable_management(p_gmac, false); -phy_props.phy_result = -6; - return uc_rc; - } - - /* Check if auto negotiation is completed */ - while (1) { - uc_rc = gmac_phy_read(p_gmac, uc_phy_addr, GMII_BMSR, &ul_value); - if (uc_rc != GMAC_OK) { - gmac_enable_management(p_gmac, false); -phy_props.phy_result = -7; - return uc_rc; - } - /* Done successfully */ - if (ul_value & GMII_AUTONEG_COMP) { - break; - } - - /* Timeout check */ - if (ul_retry_max) { - if (++ul_retry_count >= ul_retry_max) { - gmac_enable_management(p_gmac, false); -phy_props.phy_result = -8; - return GMAC_TIMEOUT; - } - } - } - - /* Get the auto negotiate link partner base page */ - uc_rc = gmac_phy_read(p_gmac, uc_phy_addr, GMII_PCR1, &phy_props.phy_params); - if (uc_rc != GMAC_OK) { - gmac_enable_management(p_gmac, false); -phy_props.phy_result = -9; - return uc_rc; - } - - - /* Set up the GMAC link speed */ - if ((ul_phy_anar & phy_props.phy_params) & GMII_100TX_FDX) { - /* Set MII for 100BaseTX and Full Duplex */ - uc_speed = true; - uc_fd = true; - } else if ((ul_phy_anar & phy_props.phy_params) & GMII_10_FDX) { - /* Set MII for 10BaseT and Full Duplex */ - uc_speed = false; - uc_fd = true; - } else if ((ul_phy_anar & phy_props.phy_params) & GMII_100TX_HDX) { - /* Set MII for 100BaseTX and half Duplex */ - uc_speed = true; - uc_fd = false; - } else if ((ul_phy_anar & phy_props.phy_params) & GMII_10_HDX) { - /* Set MII for 10BaseT and half Duplex */ - uc_speed = false; - uc_fd = false; - } - - gmac_set_speed(p_gmac, uc_speed); - gmac_enable_full_duplex(p_gmac, uc_fd); - - /* Select Media Independent Interface type */ - gmac_select_mii_mode(p_gmac, ETH_PHY_MODE); - - gmac_enable_transmit(GMAC, true); - gmac_enable_receive(GMAC, true); - - gmac_enable_management(p_gmac, false); -phy_props.phy_result = 1; - return uc_rc; -} - -/** - * \brief Issue a SW reset to reset all registers of the PHY. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_phy_addr PHY address. - * - * \Return GMAC_OK if successfully, GMAC_TIMEOUT if timeout. - */ -uint8_t ethernet_phy_reset(Gmac *p_gmac, uint8_t uc_phy_addr) -{ - uint32_t ul_bmcr = GMII_RESET; - uint8_t uc_phy_address = uc_phy_addr; - uint32_t ul_timeout = ETH_PHY_TIMEOUT; - uint8_t uc_rc = GMAC_TIMEOUT; - - gmac_enable_management(p_gmac, true); - - ul_bmcr = GMII_RESET; - gmac_phy_write(p_gmac, uc_phy_address, GMII_BMCR, ul_bmcr); - - do { - gmac_phy_read(p_gmac, uc_phy_address, GMII_BMCR, &ul_bmcr); - ul_timeout--; - } while ((ul_bmcr & GMII_RESET) && ul_timeout); - - gmac_enable_management(p_gmac, false); - - if (!ul_timeout) { - uc_rc = GMAC_OK; - } - - return (uc_rc); -} - -/// @cond 0 -/**INDENT-OFF**/ -#ifdef __cplusplus -} -#endif -/**INDENT-ON**/ -/// @endcond - -/** - * \} - */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/ethernet_phy.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/ethernet_phy.h deleted file mode 100755 index 6729df0..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/ethernet_phy.h +++ /dev/null @@ -1,281 +0,0 @@ -/** - * \file - * - * \brief KSZ8051MNL (Ethernet PHY) driver for SAM. - * - * Copyright (c) 2013 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef ETHERNET_PHY_H_INCLUDED -#define ETHERNET_PHY_H_INCLUDED - -#include "compiler.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// IEEE defined Registers -#define GMII_BMCR 0x00 // Basic Control -#define GMII_BMSR 0x01 // Basic Status -#define GMII_PHYID1 0x02 // PHY Idendifier 1 -#define GMII_PHYID2 0x03 // PHY Idendifier 2 -#define GMII_ANAR 0x04 // Auto_Negotiation Advertisement -#define GMII_ANLPAR 0x05 // Auto_negotiation Link Partner Ability -#define GMII_ANER 0x06 // Auto-negotiation Expansion -#define GMII_ANNPR 0x07 // Auto-negotiation Next Page -#define GMII_ANLPNPAR 0x08 // Link Partner Next Page Ability -//#define GMII_1000BTCR 9 // 1000Base-T Control // Reserved -//#define GMII_1000BTSR 10 // 1000Base-T Status // Reserved -#define GMII_AFECR1 0x11 // AFE Control 1 -//#define GMII_ERDWR 12 // Extend Register - Data Write Register -//#define GMII_ERDRR 13 // Extend Register - Data Read Register -//14 reserved -#define GMII_RXERCR 0x15 // RXER Counter - - #define PHY_REG_01_BMSR 0x01 // Basic mode status register - #define PHY_REG_02_PHYSID1 0x02 // PHYS ID 1 - #define PHY_REG_03_PHYSID2 0x03 // PHYS ID 2 - #define PHY_REG_04_ADVERTISE 0x04 // Advertisement control reg - #define PHY_REG_05_LPA 0x05 // Link partner ability reg - #define PHY_REG_06_ANER 0x06 // 6 RW Auto-Negotiation Expansion Register - #define PHY_REG_07_ANNPTR 0x07 // 7 RW Auto-Negotiation Next Page TX - #define PHY_REG_08_RESERVED0 0x08 // 0x08..0x0Fh 8-15 RW RESERVED - - #define PHY_REG_10_PHYSTS 0x10 // 16 RO PHY Status Register - #define PHY_REG_11_MICR 0x11 // 17 RW MII Interrupt Control Register - #define PHY_REG_12_MISR 0x12 // 18 RO MII Interrupt Status Register - #define PHY_REG_13_RESERVED1 0x13 // 19 RW RESERVED - #define PHY_REG_14_FCSCR 0x14 // 20 RO False Carrier Sense Counter Register - #define PHY_REG_15_RECR 0x15 // 21 RO Receive Error Counter Register - #define PHY_REG_16_PCSR 0x16 // 22 RW PCS Sub-Layer Configuration and Status Register - #define PHY_REG_17_RBR 0x17 // 23 RW RMII and Bypass Register - #define PHY_REG_18_LEDCR 0x18 // 24 RW LED Direct Control Register - #define PHY_REG_19_PHYCR 0x19 // 25 RW PHY Control Register - #define PHY_REG_1A_10BTSCR 0x1A // 26 RW 10Base-T Status/Control Register - #define PHY_REG_1B_CDCTRL1 0x1B // 27 RW CD Test Control Register and BIST Extensions Register - #define PHY_REG_1B_INT_CTRL 0x1B // 27 RW KSZ8041NL interrupt control - #define PHY_REG_1C_RESERVED2 0x1C // 28 RW RESERVED - #define PHY_REG_1D_EDCR 0x1D // 29 RW Energy Detect Control Register - #define PHY_REG_1E_RESERVED3 0x1E // - #define PHY_REG_1F_RESERVED4 0x1F // 30-31 RW RESERVED - - #define PHY_REG_1E_PHYCR_1 0x1E // - #define PHY_REG_1F_PHYCR_2 0x1F // - - #define PHY_SPEED_10 1 - #define PHY_SPEED_100 2 - #define PHY_SPEED_AUTO (PHY_SPEED_10|PHY_SPEED_100) - - #define PHY_MDIX_DIRECT 1 - #define PHY_MDIX_CROSSED 2 - #define PHY_MDIX_AUTO (PHY_MDIX_CROSSED|PHY_MDIX_DIRECT) - - #define PHY_DUPLEX_HALF 1 - #define PHY_DUPLEX_FULL 2 - #define PHY_DUPLEX_AUTO (PHY_DUPLEX_FULL|PHY_DUPLEX_HALF) - - typedef struct _SPhyProps { - unsigned char speed; - unsigned char mdix; - unsigned char duplex; - unsigned char spare; - } SPhyProps; - - const char *phyPrintable (const SPhyProps *apProps); - - extern SPhyProps phyProps; - -#define GMII_OMSOR 0x16 // Operation Mode Strap Override -#define GMII_OMSSR 0x17 // Operation Mode Strap Status -#define GMII_ECR 0x18 // Expanded Control -//#define GMII_DPPSR 19 // Digital PMA/PCS Status -//20 reserved -//#define GMII_RXERCR 21 // RXER Counter Register -//22-26 reserved -#define GMII_ICSR 0x1B // Interrupt Control/Status -//#define GMII_DDC1R 28 // Digital Debug Control 1 Register -#define GMII_LCSR 0x1D // LinkMD Control/Status - -//29-30 reserved -#define GMII_PCR1 0x1E // PHY Control 1 -#define GMII_PCR2 0x1F // PHY Control 2 - -/* -//Extend Registers -#define GMII_CCR 256 // Common Control Register -#define GMII_SSR 257 // Strap Status Register -#define GMII_OMSOR 258 // Operation Mode Strap Override Register -#define GMII_OMSSR 259 // Operation Mode Strap Status Register -#define GMII_RCCPSR 260 // RGMII Clock and Control Pad Skew Register -#define GMII_RRDPSR 261 // RGMII RX Data Pad Skew Register -#define GMII_ATR 263 // Analog Test Register -*/ - - -// Bit definitions: GMII_BMCR 0x00 Basic Control -#define GMII_RESET (1 << 15) // 1= Software Reset; 0=Normal Operation -#define GMII_LOOPBACK (1 << 14) // 1=loopback Enabled; 0=Normal Operation -#define GMII_SPEED_SELECT (1 << 13) // 1=100Mbps; 0=10Mbps -#define GMII_AUTONEG (1 << 12) // Auto-negotiation Enable -#define GMII_POWER_DOWN (1 << 11) // 1=Power down 0=Normal operation -#define GMII_ISOLATE (1 << 10) // 1 = Isolates 0 = Normal operation -#define GMII_RESTART_AUTONEG (1 << 9) // 1 = Restart auto-negotiation 0 = Normal operation -#define GMII_DUPLEX_MODE (1 << 8) // 1 = Full duplex operation 0 = Normal operation -#define GMII_COLLISION_TEST (1 << 7) // 1 = Enable COL test; 0 = Disable COL test -//#define GMII_SPEED_SELECT_MSB (1 << 6) // Reserved -// Reserved 6 to 0 // Read as 0, ignore on write - -// Bit definitions: GMII_BMSR 0x01 Basic Status -#define GMII_100BASE_T4 (1 << 15) // 100BASE-T4 Capable -#define GMII_100BASE_TX_FD (1 << 14) // 100BASE-TX Full Duplex Capable -#define GMII_100BASE_T4_HD (1 << 13) // 100BASE-TX Half Duplex Capable -#define GMII_10BASE_T_FD (1 << 12) // 10BASE-T Full Duplex Capable -#define GMII_10BASE_T_HD (1 << 11) // 10BASE-T Half Duplex Capable -// Reserved 10 to79 // Read as 0, ignore on write -//#define GMII_EXTEND_STATUS (1 << 8) // 1 = Extend Status Information In Reg 15 -// Reserved 7 -#define GMII_MF_PREAMB_SUPPR (1 << 6) // MII Frame Preamble Suppression -#define GMII_AUTONEG_COMP (1 << 5) // Auto-negotiation Complete -#define GMII_REMOTE_FAULT (1 << 4) // Remote Fault -#define GMII_AUTONEG_ABILITY (1 << 3) // Auto Configuration Ability -#define GMII_LINK_STATUS (1 << 2) // Link Status -#define GMII_JABBER_DETECT (1 << 1) // Jabber Detect -#define GMII_EXTEND_CAPAB (1 << 0) // Extended Capability - - -// Bit definitions: GMII_PHYID1 0x02 PHY Idendifier 1 -// Bit definitions: GMII_PHYID2 0x03 PHY Idendifier 2 -#define GMII_LSB_MASK 0x3F -#define GMII_OUI_MSB 0x0022 -#define GMII_OUI_LSB 0x05 - - -// Bit definitions: GMII_ANAR 0x04 Auto_Negotiation Advertisement -// Bit definitions: GMII_ANLPAR 0x05 Auto_negotiation Link Partner Ability -#define GMII_NP (1 << 15) // Next page Indication -// Reserved 7 -#define GMII_RF (1 << 13) // Remote Fault -// Reserved 12 // Write as 0, ignore on read -#define GMII_PAUSE_MASK (3 << 11) // 0,0 = No Pause 1,0 = Asymmetric Pause(link partner) - // 0,1 = Symmetric Pause 1,1 = Symmetric&Asymmetric Pause(local device) -#define GMII_100T4 (1 << 9) // 100BASE-T4 Support -#define GMII_100TX_FDX (1 << 8) // 100BASE-TX Full Duplex Support -#define GMII_100TX_HDX (1 << 7) // 100BASE-TX Support -#define GMII_10_FDX (1 << 6) // 10BASE-T Full Duplex Support -#define GMII_10_HDX (1 << 5) // 10BASE-T Support -// Selector 4 to 0 // Protocol Selection Bits -#define GMII_AN_IEEE_802_3 0x0001 // [00001] = IEEE 802.3 - - -// Bit definitions: GMII_ANER 0x06 Auto-negotiation Expansion -// Reserved 15 to 5 // Read as 0, ignore on write -#define GMII_PDF (1 << 4) // Local Device Parallel Detection Fault -#define GMII_LP_NP_ABLE (1 << 3) // Link Partner Next Page Able -#define GMII_NP_ABLE (1 << 2) // Local Device Next Page Able -#define GMII_PAGE_RX (1 << 1) // New Page Received -#define GMII_LP_AN_ABLE (1 << 0) // Link Partner Auto-negotiation Able - -/** - * \brief Perform a HW initialization to the PHY and set up clocks. - * - * This should be called only once to initialize the PHY pre-settings. - * The PHY address is the reset status of CRS, RXD[3:0] (the GmacPins' pullups). - * The COL pin is used to select MII mode on reset (pulled up for Reduced MII). - * The RXDV pin is used to select test mode on reset (pulled up for test mode). - * The above pins should be predefined for corresponding settings in resetPins. - * The GMAC peripheral pins are configured after the reset is done. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_phy_addr PHY address. - * \param ul_mck GMAC MCK. - * - * Return GMAC_OK if successfully, GMAC_TIMEOUT if timeout. - */ -uint8_t ethernet_phy_init(Gmac *p_gmac, uint8_t uc_phy_addr, uint32_t ul_mck); - - -/** - * \brief Get the Link & speed settings, and automatically set up the GMAC with the - * settings. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_phy_addr PHY address. - * \param uc_apply_setting_flag Set to 0 to not apply the PHY configurations, else to apply. - * - * Return GMAC_OK if successfully, GMAC_TIMEOUT if timeout. - */ -uint8_t ethernet_phy_set_link(Gmac *p_gmac, uint8_t uc_phy_addr, - uint8_t uc_apply_setting_flag); - - -/** - * \brief Issue an auto negotiation of the PHY. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_phy_addr PHY address. - * - * Return GMAC_OK if successfully, GMAC_TIMEOUT if timeout. - */ -uint8_t ethernet_phy_auto_negotiate(Gmac *p_gmac, uint8_t uc_phy_addr); - -/** - * \brief Issue a SW reset to reset all registers of the PHY. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_phy_addr PHY address. - * - * \Return GMAC_OK if successfully, GMAC_TIMEOUT if timeout. - */ -uint8_t ethernet_phy_reset(Gmac *p_gmac, uint8_t uc_phy_addr); - -typedef struct xPHY_PROPS { - signed char phy_result; - uint32_t phy_params; - uint32_t phy_stat1; - uint32_t phy_stat2; - unsigned char phy_chn; -} PhyProps_t; -extern PhyProps_t phy_props; - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* #ifndef ETHERNET_PHY_H_INCLUDED */ - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/gmac.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/gmac.c deleted file mode 100755 index 5c21491..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/gmac.c +++ /dev/null @@ -1,945 +0,0 @@ - /** - * \file - * - * \brief GMAC (Ethernet MAC) driver for SAM. - * - * Copyright (c) 2013 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -/* Standard includes. */ -#include -#include -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" - -#include "FreeRTOSIPConfig.h" - -#include "compiler.h" -#include "instance/gmac.h" -#include "ethernet_phy.h" - -/// @cond 0 -/**INDENT-OFF**/ -#ifdef __cplusplus -extern "C" { -#endif -/**INDENT-ON**/ -/// @endcond - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (int)( sizeof(x) / sizeof(x)[0] ) -#endif -/** - * \defgroup gmac_group Ethernet Media Access Controller - * - * See \ref gmac_quickstart. - * - * Driver for the GMAC (Ethernet Media Access Controller). - * This file contains basic functions for the GMAC, with support for all modes, settings - * and clock speeds. - * - * \section dependencies Dependencies - * This driver does not depend on other modules. - * - * @{ - */ - -/** TX descriptor lists */ -COMPILER_ALIGNED(8) -static gmac_tx_descriptor_t gs_tx_desc[ GMAC_TX_BUFFERS ]; -#if( GMAC_USES_TX_CALLBACK != 0 ) -/** TX callback lists */ -static gmac_dev_tx_cb_t gs_tx_callback[ GMAC_TX_BUFFERS ]; -#endif -/** RX descriptors lists */ -COMPILER_ALIGNED(8) -static gmac_rx_descriptor_t gs_rx_desc[ GMAC_RX_BUFFERS ]; - -#if( ipconfigZERO_COPY_TX_DRIVER == 0 ) - /** Send Buffer. Section 3.6 of AMBA 2.0 spec states that burst should not cross the - * 1K Boundaries. Receive buffer manager write operations are burst of 2 words => 3 lsb bits - * of the address shall be set to 0. - */ - COMPILER_ALIGNED(8) - static uint8_t gs_uc_tx_buffer[ GMAC_TX_BUFFERS * GMAC_TX_UNITSIZE ]; -#endif /* ipconfigZERO_COPY_TX_DRIVER */ - -/** Receive Buffer */ -COMPILER_ALIGNED(8) -static uint8_t gs_uc_rx_buffer[ GMAC_RX_BUFFERS * GMAC_RX_UNITSIZE ]; - -/** - * GMAC device memory management struct. - */ -typedef struct gmac_dev_mem { - /* Pointer to allocated buffer for RX. The address should be 8-byte aligned - and the size should be GMAC_RX_UNITSIZE * wRxSize. */ - uint8_t *p_rx_buffer; - /* Pointer to allocated RX descriptor list. */ - gmac_rx_descriptor_t *p_rx_dscr; - /* RX size, in number of registered units (RX descriptors). */ - /* Increased size from 16- to 32-bits, because it's more efficient */ - uint32_t us_rx_size; - /* Pointer to allocated buffer for TX. The address should be 8-byte aligned - and the size should be GMAC_TX_UNITSIZE * wTxSize. */ - uint8_t *p_tx_buffer; - /* Pointer to allocated TX descriptor list. */ - gmac_tx_descriptor_t *p_tx_dscr; - /* TX size, in number of registered units (TX descriptors). */ - uint32_t us_tx_size; -} gmac_dev_mem_t; - -/** Return count in buffer */ -#define CIRC_CNT( head, tail, size ) ( ( ( head ) - ( tail ) ) % ( size ) ) - -/* - * Return space available, from 0 to size-1. - * Always leave one free char as a completely full buffer that has (head == tail), - * which is the same as empty. - */ -#define CIRC_SPACE( head, tail, size ) CIRC_CNT( ( tail ), ( ( head ) + 1 ), ( size ) ) - -/** Circular buffer is empty ? */ -#define CIRC_EMPTY( head, tail ) ( head == tail ) -/** Clear circular buffer */ -#define CIRC_CLEAR( head, tail ) do { ( head ) = 0; ( tail ) = 0; } while( 0 ) - -/** Increment head or tail */ -static __inline void circ_inc32( int32_t *lHeadOrTail, uint32_t ulSize ) -{ - ( *lHeadOrTail ) ++; - if( ( *lHeadOrTail ) >= ( int32_t )ulSize ) - { - ( *lHeadOrTail ) = 0; - } -} - -/** - * \brief Wait PHY operation to be completed. - * - * \param p_gmac HW controller address. - * \param ul_retry The retry times, 0 to wait forever until completeness. - * - * Return GMAC_OK if the operation is completed successfully. - */ -static uint8_t gmac_wait_phy(Gmac* p_gmac, const uint32_t ul_retry) -{ - volatile uint32_t ul_retry_count = 0; - const uint32_t xPHYPollDelay = pdMS_TO_TICKS( 1ul ); - - while (!gmac_is_phy_idle(p_gmac)) { - if (ul_retry == 0) { - continue; - } - - ul_retry_count++; - - if (ul_retry_count >= ul_retry) { - return GMAC_TIMEOUT; - } - - /* Block the task to allow other tasks to execute while the PHY - is not connected. */ - vTaskDelay( xPHYPollDelay ); - } - return GMAC_OK; -} - -/** - * \brief Disable transfer, reset registers and descriptor lists. - * - * \param p_dev Pointer to GMAC driver instance. - * - */ -static void gmac_reset_tx_mem(gmac_device_t* p_dev) -{ - Gmac *p_hw = p_dev->p_hw; - uint8_t *p_tx_buff = p_dev->p_tx_buffer; - gmac_tx_descriptor_t *p_td = p_dev->p_tx_dscr; - - uint32_t ul_index; - uint32_t ul_address; - - /* Disable TX */ - gmac_enable_transmit(p_hw, 0); - - /* Set up the TX descriptors */ - CIRC_CLEAR(p_dev->l_tx_head, p_dev->l_tx_tail); - for( ul_index = 0; ul_index < p_dev->ul_tx_list_size; ul_index++ ) - { - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - ul_address = (uint32_t) 0u; - } - #else - { - ul_address = (uint32_t) (&(p_tx_buff[ul_index * GMAC_TX_UNITSIZE])); - } - #endif /* ipconfigZERO_COPY_TX_DRIVER */ - p_td[ul_index].addr = ul_address; - p_td[ul_index].status.val = GMAC_TXD_USED; - } - p_td[p_dev->ul_tx_list_size - 1].status.val = - GMAC_TXD_USED | GMAC_TXD_WRAP; - - /* Set transmit buffer queue */ - gmac_set_tx_queue(p_hw, (uint32_t) p_td); -} - -/** - * \brief Disable receiver, reset registers and descriptor list. - * - * \param p_drv Pointer to GMAC Driver instance. - */ -static void gmac_reset_rx_mem(gmac_device_t* p_dev) -{ - Gmac *p_hw = p_dev->p_hw; - uint8_t *p_rx_buff = p_dev->p_rx_buffer; - gmac_rx_descriptor_t *pRd = p_dev->p_rx_dscr; - - uint32_t ul_index; - uint32_t ul_address; - - /* Disable RX */ - gmac_enable_receive(p_hw, 0); - - /* Set up the RX descriptors */ - p_dev->ul_rx_idx = 0; - for( ul_index = 0; ul_index < p_dev->ul_rx_list_size; ul_index++ ) - { - ul_address = (uint32_t) (&(p_rx_buff[ul_index * GMAC_RX_UNITSIZE])); - pRd[ul_index].addr.val = ul_address & GMAC_RXD_ADDR_MASK; - pRd[ul_index].status.val = 0; - } - pRd[p_dev->ul_rx_list_size - 1].addr.val |= GMAC_RXD_WRAP; - - /* Set receive buffer queue */ - gmac_set_rx_queue(p_hw, (uint32_t) pRd); -} - - -/** - * \brief Initialize the allocated buffer lists for GMAC driver to transfer data. - * Must be invoked after gmac_dev_init() but before RX/TX starts. - * - * \note If input address is not 8-byte aligned, the address is automatically - * adjusted and the list size is reduced by one. - * - * \param p_gmac Pointer to GMAC instance. - * \param p_gmac_dev Pointer to GMAC device instance. - * \param p_dev_mm Pointer to the GMAC memory management control block. - * \param p_tx_cb Pointer to allocated TX callback list. - * - * \return GMAC_OK or GMAC_PARAM. - */ -static uint8_t gmac_init_mem(Gmac* p_gmac, gmac_device_t* p_gmac_dev, - gmac_dev_mem_t* p_dev_mm -#if( GMAC_USES_TX_CALLBACK != 0 ) - , gmac_dev_tx_cb_t* p_tx_cb -#endif - ) -{ - if (p_dev_mm->us_rx_size <= 1 || p_dev_mm->us_tx_size <= 1 -#if( GMAC_USES_TX_CALLBACK != 0 ) - || p_tx_cb == NULL -#endif - ) { - return GMAC_PARAM; - } - - /* Assign RX buffers */ - if (((uint32_t) p_dev_mm->p_rx_buffer & 0x7) - || ((uint32_t) p_dev_mm->p_rx_dscr & 0x7)) { - p_dev_mm->us_rx_size--; - } - p_gmac_dev->p_rx_buffer = - (uint8_t *) ((uint32_t) p_dev_mm->p_rx_buffer & 0xFFFFFFF8); - p_gmac_dev->p_rx_dscr = - (gmac_rx_descriptor_t *) ((uint32_t) p_dev_mm->p_rx_dscr - & 0xFFFFFFF8); - p_gmac_dev->ul_rx_list_size = p_dev_mm->us_rx_size; - - /* Assign TX buffers */ - if (((uint32_t) p_dev_mm->p_tx_buffer & 0x7) - || ((uint32_t) p_dev_mm->p_tx_dscr & 0x7)) { - p_dev_mm->us_tx_size--; - } - p_gmac_dev->p_tx_buffer = - (uint8_t *) ((uint32_t) p_dev_mm->p_tx_buffer & 0xFFFFFFF8); - p_gmac_dev->p_tx_dscr = - (gmac_tx_descriptor_t *) ((uint32_t) p_dev_mm->p_tx_dscr - & 0xFFFFFFF8); - p_gmac_dev->ul_tx_list_size = p_dev_mm->us_tx_size; -#if( GMAC_USES_TX_CALLBACK != 0 ) - p_gmac_dev->func_tx_cb_list = p_tx_cb; -#endif - /* Reset TX & RX */ - gmac_reset_rx_mem(p_gmac_dev); - gmac_reset_tx_mem(p_gmac_dev); - - /* Enable Rx and Tx, plus the statistics register */ - gmac_enable_transmit(p_gmac, true); - gmac_enable_receive(p_gmac, true); - gmac_enable_statistics_write(p_gmac, true); - - /* Set up the interrupts for transmission and errors */ - gmac_enable_interrupt(p_gmac, - GMAC_IER_RXUBR | /* Enable receive used bit read interrupt. */ - GMAC_IER_TUR | /* Enable transmit underrun interrupt. */ - GMAC_IER_RLEX | /* Enable retry limit exceeded interrupt. */ - GMAC_IER_TFC | /* Enable transmit buffers exhausted in mid-frame interrupt. */ - GMAC_IER_TCOMP | /* Enable transmit complete interrupt. */ - GMAC_IER_ROVR | /* Enable receive overrun interrupt. */ - GMAC_IER_HRESP | /* Enable Hresp not OK interrupt. */ - GMAC_IER_PFNZ | /* Enable pause frame received interrupt. */ - GMAC_IER_PTZ); /* Enable pause time zero interrupt. */ - - return GMAC_OK; -} - -/** - * \brief Read the PHY register. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_phy_address PHY address. - * \param uc_address Register address. - * \param p_value Pointer to a 32-bit location to store read data. - * - * \Return GMAC_OK if successfully, GMAC_TIMEOUT if timeout. - */ -uint8_t gmac_phy_read(Gmac* p_gmac, uint8_t uc_phy_address, uint8_t uc_address, - uint32_t* p_value) -{ - gmac_maintain_phy(p_gmac, uc_phy_address, uc_address, 1, 0); - - if (gmac_wait_phy(p_gmac, MAC_PHY_RETRY_MAX) == GMAC_TIMEOUT) { - return GMAC_TIMEOUT; - } - *p_value = gmac_get_phy_data(p_gmac); - return GMAC_OK; -} - -/** - * \brief Write the PHY register. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_phy_address PHY Address. - * \param uc_address Register Address. - * \param ul_value Data to write, actually 16-bit data. - * - * \Return GMAC_OK if successfully, GMAC_TIMEOUT if timeout. - */ -uint8_t gmac_phy_write(Gmac* p_gmac, uint8_t uc_phy_address, - uint8_t uc_address, uint32_t ul_value) -{ - gmac_maintain_phy(p_gmac, uc_phy_address, uc_address, 0, ul_value); - - if (gmac_wait_phy(p_gmac, MAC_PHY_RETRY_MAX) == GMAC_TIMEOUT) { - return GMAC_TIMEOUT; - } - return GMAC_OK; -} - -/** - * \brief Initialize the GMAC driver. - * - * \param p_gmac Pointer to the GMAC instance. - * \param p_gmac_dev Pointer to the GMAC device instance. - * \param p_opt GMAC configure options. - */ -void gmac_dev_init(Gmac* p_gmac, gmac_device_t* p_gmac_dev, - gmac_options_t* p_opt) -{ - gmac_dev_mem_t gmac_dev_mm; - - /* Disable TX & RX and more */ - gmac_network_control(p_gmac, 0); - gmac_disable_interrupt(p_gmac, ~0u); - - - gmac_clear_statistics(p_gmac); - - /* Clear all status bits in the receive status register. */ - gmac_clear_rx_status(p_gmac, GMAC_RSR_RXOVR | GMAC_RSR_REC | GMAC_RSR_BNA); - - /* Clear all status bits in the transmit status register */ - gmac_clear_tx_status(p_gmac, GMAC_TSR_UBR | GMAC_TSR_COL | GMAC_TSR_RLE - | GMAC_TSR_TFC | GMAC_TSR_TXCOMP | GMAC_TSR_UND); - - /* Clear interrupts */ - gmac_get_interrupt_status(p_gmac); -#if !defined(ETHERNET_CONF_DATA_OFFSET) - /* Receive Buffer Offset - * Indicates the number of bytes by which the received data - * is offset from the start of the receive buffer - * which can be handy for alignment reasons */ - /* Note: FreeRTOS+TCP wants to have this offset set to 2 bytes */ - #error ETHERNET_CONF_DATA_OFFSET not defined, assuming 0 -#endif - /* Enable the copy of data into the buffers - ignore broadcasts, and not copy FCS. */ - - gmac_set_configure(p_gmac, - ( gmac_get_configure(p_gmac) & ~GMAC_NCFGR_RXBUFO_Msk ) | - GMAC_NCFGR_RFCS | /* Remove FCS, frame check sequence (last 4 bytes) */ - GMAC_NCFGR_PEN | /* Pause Enable */ - GMAC_NCFGR_RXBUFO( ETHERNET_CONF_DATA_OFFSET ) | - GMAC_RXD_RXCOEN ); - - /* - * GMAC_DCFGR_TXCOEN: (GMAC_DCFGR) Transmitter Checksum Generation Offload Enable. - * Note: tha SAM4E does have RX checksum offloading - * but TX checksum offloading has NOT been implemented. - * http://community.atmel.com/forum/sam4e-gmac-transmit-checksum-offload-enablesolved - */ - - gmac_set_dma(p_gmac, - gmac_get_dma(p_gmac) | GMAC_DCFGR_TXCOEN ); - - gmac_enable_copy_all(p_gmac, p_opt->uc_copy_all_frame); - gmac_disable_broadcast(p_gmac, p_opt->uc_no_boardcast); - - /* Fill in GMAC device memory management */ - gmac_dev_mm.p_rx_buffer = gs_uc_rx_buffer; - gmac_dev_mm.p_rx_dscr = gs_rx_desc; - gmac_dev_mm.us_rx_size = GMAC_RX_BUFFERS; - - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - gmac_dev_mm.p_tx_buffer = NULL; - } - #else - { - gmac_dev_mm.p_tx_buffer = gs_uc_tx_buffer; - } - #endif - gmac_dev_mm.p_tx_dscr = gs_tx_desc; - gmac_dev_mm.us_tx_size = GMAC_TX_BUFFERS; - - gmac_init_mem(p_gmac, p_gmac_dev, &gmac_dev_mm -#if( GMAC_USES_TX_CALLBACK != 0 ) - , gs_tx_callback -#endif - ); - - gmac_set_address(p_gmac, 0, p_opt->uc_mac_addr); -} - -/** - * \brief Frames can be read from the GMAC in multiple sections. - * - * Returns > 0 if a complete frame is available - * It also it cleans up incomplete older frames - */ - -static uint32_t gmac_dev_poll(gmac_device_t* p_gmac_dev) -{ - uint32_t ulReturn = 0; - int32_t ulIndex = p_gmac_dev->ul_rx_idx; - gmac_rx_descriptor_t *pxHead = &p_gmac_dev->p_rx_dscr[ulIndex]; - - /* Discard any incomplete frames */ - while ((pxHead->addr.val & GMAC_RXD_OWNERSHIP) && - (pxHead->status.val & GMAC_RXD_SOF) == 0) { - pxHead->addr.val &= ~(GMAC_RXD_OWNERSHIP); - circ_inc32 (&ulIndex, p_gmac_dev->ul_rx_list_size); - pxHead = &p_gmac_dev->p_rx_dscr[ulIndex]; - p_gmac_dev->ul_rx_idx = ulIndex; - #if( GMAC_STATS != 0 ) - { - gmacStats.incompCount++; - } - #endif - } - - while ((pxHead->addr.val & GMAC_RXD_OWNERSHIP) != 0) { - if ((pxHead->status.val & GMAC_RXD_EOF) != 0) { - /* Here a complete frame has been seen with SOF and EOF */ - ulReturn = pxHead->status.bm.len; - break; - } - circ_inc32 (&ulIndex, p_gmac_dev->ul_rx_list_size); - pxHead = &p_gmac_dev->p_rx_dscr[ulIndex]; - if ((pxHead->addr.val & GMAC_RXD_OWNERSHIP) == 0) { - /* CPU is not the owner (yet) */ - break; - } - if ((pxHead->status.val & GMAC_RXD_SOF) != 0) { - /* Strange, we found a new Start Of Frame - * discard previous segments */ - int32_t ulPrev = p_gmac_dev->ul_rx_idx; - pxHead = &p_gmac_dev->p_rx_dscr[ulPrev]; - do { - pxHead->addr.val &= ~(GMAC_RXD_OWNERSHIP); - circ_inc32 (&ulPrev, p_gmac_dev->ul_rx_list_size); - pxHead = &p_gmac_dev->p_rx_dscr[ulPrev]; - #if( GMAC_STATS != 0 ) - { - gmacStats.truncCount++; - } - #endif - } while (ulPrev != ulIndex); - p_gmac_dev->ul_rx_idx = ulIndex; - } - } - return ulReturn; -} - -/** - * \brief Frames can be read from the GMAC in multiple sections. - * Read ul_frame_size bytes from the GMAC receive buffers to pcTo. - * p_rcv_size is the size of the entire frame. Generally gmac_read - * will be repeatedly called until the sum of all the ul_frame_size equals - * the value of p_rcv_size. - * - * \param p_gmac_dev Pointer to the GMAC device instance. - * \param p_frame Address of the frame buffer. - * \param ul_frame_size Length of the frame. - * \param p_rcv_size Received frame size. - * - * \return GMAC_OK if receiving frame successfully, otherwise failed. - */ -uint32_t gmac_dev_read(gmac_device_t* p_gmac_dev, uint8_t* p_frame, - uint32_t ul_frame_size, uint32_t* p_rcv_size) -{ - int32_t nextIdx; /* A copy of the Rx-index 'ul_rx_idx' */ - int32_t bytesLeft = gmac_dev_poll (p_gmac_dev); - gmac_rx_descriptor_t *pxHead; - - if (bytesLeft == 0 ) - { - return GMAC_RX_NULL; - } - - /* gmac_dev_poll has confirmed that there is a complete frame at - * the current position 'ul_rx_idx' - */ - nextIdx = p_gmac_dev->ul_rx_idx; - - /* Read +2 bytes because buffers are aligned at -2 bytes */ - bytesLeft = min( bytesLeft + 2, ( int32_t )ul_frame_size ); - - /* The frame will be copied in 1 or 2 memcpy's */ - if( ( p_frame != NULL ) && ( bytesLeft != 0 ) ) - { - const uint8_t *source; - int32_t left; - int32_t toCopy; - - source = p_gmac_dev->p_rx_buffer + nextIdx * GMAC_RX_UNITSIZE; - left = bytesLeft; - toCopy = ( p_gmac_dev->ul_rx_list_size - nextIdx ) * GMAC_RX_UNITSIZE; - if(toCopy > left ) - { - toCopy = left; - } - memcpy (p_frame, source, toCopy); - left -= toCopy; - - if( left != 0ul ) - { - memcpy (p_frame + toCopy, (void*)p_gmac_dev->p_rx_buffer, left); - } - } - - do - { - pxHead = &p_gmac_dev->p_rx_dscr[nextIdx]; - pxHead->addr.val &= ~(GMAC_RXD_OWNERSHIP); - circ_inc32 (&nextIdx, p_gmac_dev->ul_rx_list_size); - } while ((pxHead->status.val & GMAC_RXD_EOF) == 0); - - p_gmac_dev->ul_rx_idx = nextIdx; - - *p_rcv_size = bytesLeft; - - return GMAC_OK; -} - - -extern void vGMACGenerateChecksum( uint8_t *apBuffer ); - -/** - * \brief Send ulLength bytes from pcFrom. This copies the buffer to one of the - * GMAC Tx buffers, and then indicates to the GMAC that the buffer is ready. - * If lEndOfFrame is true then the data being copied is the end of the frame - * and the frame can be transmitted. - * - * \param p_gmac_dev Pointer to the GMAC device instance. - * \param p_buffer Pointer to the data buffer. - * \param ul_size Length of the frame. - * \param func_tx_cb Transmit callback function. - * - * \return Length sent. - */ -uint32_t gmac_dev_write(gmac_device_t* p_gmac_dev, void *p_buffer, - uint32_t ul_size, gmac_dev_tx_cb_t func_tx_cb) -{ - - volatile gmac_tx_descriptor_t *p_tx_td; -#if( GMAC_USES_TX_CALLBACK != 0 ) - volatile gmac_dev_tx_cb_t *p_func_tx_cb; -#endif - - Gmac *p_hw = p_gmac_dev->p_hw; - -#if( GMAC_USES_TX_CALLBACK == 0 ) - ( void )func_tx_cb; -#endif - - /* Check parameter */ - if (ul_size > GMAC_TX_UNITSIZE) { - return GMAC_PARAM; - } - - /* Pointers to the current transmit descriptor */ - p_tx_td = &p_gmac_dev->p_tx_dscr[p_gmac_dev->l_tx_head]; - - /* If no free TxTd, buffer can't be sent, schedule the wakeup callback */ -// if (CIRC_SPACE(p_gmac_dev->l_tx_head, p_gmac_dev->l_tx_tail, -// p_gmac_dev->ul_tx_list_size) == 0) - { - if ((p_tx_td->status.val & GMAC_TXD_USED) == 0) - return GMAC_TX_BUSY; - } -#if( GMAC_USES_TX_CALLBACK != 0 ) - /* Pointers to the current Tx callback */ - p_func_tx_cb = &p_gmac_dev->func_tx_cb_list[p_gmac_dev->l_tx_head]; -#endif - - /* Set up/copy data to transmission buffer */ - if (p_buffer && ul_size) { - /* Driver manages the ring buffer */ - /* Calculating the checksum here is faster than calculating it from the GMAC buffer - * because withing p_buffer, it is well aligned */ - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* Zero-copy... */ - p_tx_td->addr = ( uint32_t ) p_buffer; - } - #else - { - /* Or memcopy... */ - memcpy((void *)p_tx_td->addr, p_buffer, ul_size); - } - #endif /* ipconfigZERO_COPY_TX_DRIVER */ - vGMACGenerateChecksum( ( uint8_t * ) p_tx_td->addr ); - } - -#if( GMAC_USES_TX_CALLBACK != 0 ) - /* Tx callback */ - *p_func_tx_cb = func_tx_cb; -#endif - - /* Update transmit descriptor status */ - - /* The buffer size defined is the length of ethernet frame, - so it's always the last buffer of the frame. */ - if( p_gmac_dev->l_tx_head == ( int32_t )( p_gmac_dev->ul_tx_list_size - 1 ) ) - { - /* No need to 'and' with GMAC_TXD_LEN_MASK because ul_size has been checked */ - p_tx_td->status.val = - ul_size | GMAC_TXD_LAST | GMAC_TXD_WRAP; - } else { - p_tx_td->status.val = - ul_size | GMAC_TXD_LAST; - } - - circ_inc32( &p_gmac_dev->l_tx_head, p_gmac_dev->ul_tx_list_size ); - - /* Now start to transmit if it is still not done */ - gmac_start_transmission(p_hw); - - return GMAC_OK; -} - -/** - * \brief Get current load of transmit. - * - * \param p_gmac_dev Pointer to the GMAC device instance. - * - * \return Current load of transmit. - */ -#if( GMAC_USES_TX_CALLBACK != 0 ) -/* Without defining GMAC_USES_TX_CALLBACK, l_tx_tail won't be updated */ -uint32_t gmac_dev_get_tx_load(gmac_device_t* p_gmac_dev) -{ - uint16_t us_head = p_gmac_dev->l_tx_head; - uint16_t us_tail = p_gmac_dev->l_tx_tail; - return CIRC_CNT(us_head, us_tail, p_gmac_dev->ul_tx_list_size); -} -#endif - -/** - * \brief Register/Clear RX callback. Callback will be invoked after the next received - * frame. - * - * When gmac_dev_read() returns GMAC_RX_NULL, the application task calls - * gmac_dev_set_rx_callback() to register func_rx_cb() callback and enters suspend state. - * The callback is in charge to resume the task once a new frame has been - * received. The next time gmac_dev_read() is called, it will be successful. - * - * This function is usually invoked from the RX callback itself with NULL - * callback, to unregister. Once the callback has resumed the application task, - * there is no need to invoke the callback again. - * - * \param p_gmac_dev Pointer to the GMAC device instance. - * \param func_tx_cb Receive callback function. - */ -void gmac_dev_set_rx_callback(gmac_device_t* p_gmac_dev, - gmac_dev_rx_cb_t func_rx_cb) -{ - Gmac *p_hw = p_gmac_dev->p_hw; - - if (func_rx_cb == NULL) { - gmac_disable_interrupt(p_hw, GMAC_IDR_RCOMP); - p_gmac_dev->func_rx_cb = NULL; - } else { - p_gmac_dev->func_rx_cb = func_rx_cb; - gmac_enable_interrupt(p_hw, GMAC_IER_RCOMP); - } -} - -/** - * \brief Register/Clear TX wakeup callback. - * - * When gmac_dev_write() returns GMAC_TX_BUSY (all transmit descriptor busy), the application - * task calls gmac_dev_set_tx_wakeup_callback() to register func_wakeup() callback and - * enters suspend state. The callback is in charge to resume the task once - * several transmit descriptors have been released. The next time gmac_dev_write() will be called, - * it shall be successful. - * - * This function is usually invoked with NULL callback from the TX wakeup - * callback itself, to unregister. Once the callback has resumed the - * application task, there is no need to invoke the callback again. - * - * \param p_gmac_dev Pointer to GMAC device instance. - * \param func_wakeup Pointer to wakeup callback function. - * \param uc_threshold Number of free transmit descriptor before wakeup callback invoked. - * - * \return GMAC_OK, GMAC_PARAM on parameter error. - */ -#if( GMAC_USES_WAKEUP_CALLBACK ) -uint8_t gmac_dev_set_tx_wakeup_callback(gmac_device_t* p_gmac_dev, - gmac_dev_wakeup_cb_t func_wakeup_cb, uint8_t uc_threshold) -{ - if (func_wakeup_cb == NULL) { - p_gmac_dev->func_wakeup_cb = NULL; - } else { - if (uc_threshold <= p_gmac_dev->ul_tx_list_size) { - p_gmac_dev->func_wakeup_cb = func_wakeup_cb; - p_gmac_dev->uc_wakeup_threshold = uc_threshold; - } else { - return GMAC_PARAM; - } - } - - return GMAC_OK; -} -#endif /* GMAC_USES_WAKEUP_CALLBACK */ - -/** - * \brief Reset TX & RX queue & statistics. - * - * \param p_gmac_dev Pointer to GMAC device instance. - */ -void gmac_dev_reset(gmac_device_t* p_gmac_dev) -{ - Gmac *p_hw = p_gmac_dev->p_hw; - - gmac_reset_rx_mem(p_gmac_dev); - gmac_reset_tx_mem(p_gmac_dev); - gmac_network_control(p_hw, GMAC_NCR_TXEN | GMAC_NCR_RXEN - | GMAC_NCR_WESTAT | GMAC_NCR_CLRSTAT); -} - -void gmac_dev_halt(Gmac* p_gmac); - -void gmac_dev_halt(Gmac* p_gmac) -{ - gmac_network_control(p_gmac, GMAC_NCR_WESTAT | GMAC_NCR_CLRSTAT); - gmac_disable_interrupt(p_gmac, ~0u); -} - - -/** - * \brief GMAC Interrupt handler. - * - * \param p_gmac_dev Pointer to GMAC device instance. - */ - -#if( GMAC_STATS != 0 ) - extern int logPrintf( const char *pcFormat, ... ); - - void gmac_show_irq_counts () - { - int index; - for (index = 0; index < ARRAY_SIZE(intPairs); index++) { - if (gmacStats.intStatus[intPairs[index].index]) { - logPrintf("%s : %6u\n", intPairs[index].name, gmacStats.intStatus[intPairs[index].index]); - } - } - } -#endif - -void gmac_handler(gmac_device_t* p_gmac_dev) -{ - Gmac *p_hw = p_gmac_dev->p_hw; - -#if( GMAC_USES_TX_CALLBACK != 0 ) - gmac_tx_descriptor_t *p_tx_td; - gmac_dev_tx_cb_t *p_tx_cb = NULL; - uint32_t ul_tx_status_flag; -#endif -#if( GMAC_STATS != 0 ) - int index; -#endif - - /* volatile */ uint32_t ul_isr; - /* volatile */ uint32_t ul_rsr; - /* volatile */ uint32_t ul_tsr; - - ul_isr = gmac_get_interrupt_status(p_hw); - ul_rsr = gmac_get_rx_status(p_hw); - ul_tsr = gmac_get_tx_status(p_hw); - -/* Why clear bits that are ignored anyway ? */ -/* ul_isr &= ~(gmac_get_interrupt_mask(p_hw) | 0xF8030300); */ - #if( GMAC_STATS != 0 ) - { - for (index = 0; index < ARRAY_SIZE(intPairs); index++) { - if (ul_isr & intPairs[index].mask) - gmacStats.intStatus[intPairs[index].index]++; - } - } - #endif /* GMAC_STATS != 0 */ - - /* RX packet */ - if ((ul_isr & GMAC_ISR_RCOMP) || (ul_rsr & (GMAC_RSR_REC|GMAC_RSR_RXOVR|GMAC_RSR_BNA))) { - /* Clear status */ - gmac_clear_rx_status(p_hw, ul_rsr); - - if (ul_isr & GMAC_ISR_RCOMP) - ul_rsr |= GMAC_RSR_REC; - /* Invoke callbacks which can be useful to wake op a task */ - if (p_gmac_dev->func_rx_cb) { - p_gmac_dev->func_rx_cb(ul_rsr); - } - } - - /* TX packet */ - if ((ul_isr & GMAC_ISR_TCOMP) || (ul_tsr & (GMAC_TSR_TXCOMP|GMAC_TSR_COL|GMAC_TSR_RLE|GMAC_TSR_UND))) { - -#if( GMAC_USES_TX_CALLBACK != 0 ) - ul_tx_status_flag = GMAC_TSR_TXCOMP; -#endif - /* A frame transmitted */ - - /* Check RLE */ - if (ul_tsr & GMAC_TSR_RLE) { - /* Status RLE & Number of discarded buffers */ -#if( GMAC_USES_TX_CALLBACK != 0 ) - ul_tx_status_flag = GMAC_TSR_RLE | CIRC_CNT(p_gmac_dev->l_tx_head, - p_gmac_dev->l_tx_tail, p_gmac_dev->ul_tx_list_size); - p_tx_cb = &p_gmac_dev->func_tx_cb_list[p_gmac_dev->l_tx_tail]; -#endif - gmac_reset_tx_mem(p_gmac_dev); - gmac_enable_transmit(p_hw, 1); - } - /* Clear status */ - gmac_clear_tx_status(p_hw, ul_tsr); - -#if( GMAC_USES_TX_CALLBACK != 0 ) - if (!CIRC_EMPTY(p_gmac_dev->l_tx_head, p_gmac_dev->l_tx_tail)) { - /* Check the buffers */ - do { - p_tx_td = &p_gmac_dev->p_tx_dscr[p_gmac_dev->l_tx_tail]; - p_tx_cb = &p_gmac_dev->func_tx_cb_list[p_gmac_dev->l_tx_tail]; - /* Any error? Exit if buffer has not been sent yet */ - if ((p_tx_td->status.val & GMAC_TXD_USED) == 0) { - break; - } - - /* Notify upper layer that a packet has been sent */ - if (*p_tx_cb) { - (*p_tx_cb) (ul_tx_status_flag, (void*)p_tx_td->addr); - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - p_tx_td->addr = 0ul; - } - #endif /* ipconfigZERO_COPY_TX_DRIVER */ - } - - circ_inc32(&p_gmac_dev->l_tx_tail, p_gmac_dev->ul_tx_list_size); - } while (CIRC_CNT(p_gmac_dev->l_tx_head, p_gmac_dev->l_tx_tail, - p_gmac_dev->ul_tx_list_size)); - } - - if (ul_tsr & GMAC_TSR_RLE) { - /* Notify upper layer RLE */ - if (*p_tx_cb) { - (*p_tx_cb) (ul_tx_status_flag, NULL); - } - } -#endif /* GMAC_USES_TX_CALLBACK */ - -#if( GMAC_USES_WAKEUP_CALLBACK ) - /* If a wakeup has been scheduled, notify upper layer that it can - send other packets, and the sending will be successful. */ - if ((CIRC_SPACE(p_gmac_dev->l_tx_head, p_gmac_dev->l_tx_tail, - p_gmac_dev->ul_tx_list_size) >= p_gmac_dev->uc_wakeup_threshold) - && p_gmac_dev->func_wakeup_cb) { - p_gmac_dev->func_wakeup_cb(); - } -#endif - } -} - -//@} - -/// @cond 0 -/**INDENT-OFF**/ -#ifdef __cplusplus -} -#endif -/**INDENT-ON**/ -/// @endcond diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/gmac.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/gmac.h deleted file mode 100755 index d741a2a..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/gmac.h +++ /dev/null @@ -1,1346 +0,0 @@ - /** - * \file - * - * \brief GMAC (Ethernet MAC) driver for SAM. - * - * Copyright (c) 2013 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef GMAC_H_INCLUDED -#define GMAC_H_INCLUDED - -#include "compiler.h" - -/// @cond 0 -/**INDENT-OFF**/ -#ifdef __cplusplus -extern "C" { -#endif -/**INDENT-ON**/ -/// @endcond - -/** The buffer addresses written into the descriptors must be aligned, so the - last few bits are zero. These bits have special meaning for the GMAC - peripheral and cannot be used as part of the address. */ -#define GMAC_RXD_ADDR_MASK 0xFFFFFFFC -#define GMAC_RXD_WRAP (1ul << 1) /**< Wrap bit */ -#define GMAC_RXD_OWNERSHIP (1ul << 0) /**< Ownership bit */ - -#define GMAC_RXD_BROADCAST (1ul << 31) /**< Broadcast detected */ -#define GMAC_RXD_MULTIHASH (1ul << 30) /**< Multicast hash match */ -#define GMAC_RXD_UNIHASH (1ul << 29) /**< Unicast hash match */ -#define GMAC_RXD_ADDR_FOUND (1ul << 27) /**< Specific address match found */ -#define GMAC_RXD_ADDR (3ul << 25) /**< Address match */ -#define GMAC_RXD_RXCOEN (1ul << 24) /**< RXCOEN related function */ -#define GMAC_RXD_TYPE (3ul << 22) /**< Type ID match */ -#define GMAC_RXD_VLAN (1ul << 21) /**< VLAN tag detected */ -#define GMAC_RXD_PRIORITY (1ul << 20) /**< Priority tag detected */ -#define GMAC_RXD_PRIORITY_MASK (3ul << 17) /**< VLAN priority */ -#define GMAC_RXD_CFI (1ul << 16) /**< Concatenation Format Indicator only if bit 21 is set */ -#define GMAC_RXD_EOF (1ul << 15) /**< End of frame */ -#define GMAC_RXD_SOF (1ul << 14) /**< Start of frame */ -#define GMAC_RXD_FCS (1ul << 13) /**< Frame check sequence */ -#define GMAC_RXD_OFFSET_MASK /**< Receive buffer offset */ -#define GMAC_RXD_LEN_MASK (0xFFF) /**< Length of frame including FCS (if selected) */ -#define GMAC_RXD_LENJUMBO_MASK (0x3FFF) /**< Jumbo frame length */ - -#define GMAC_TXD_USED (1ul << 31) /**< Frame is transmitted */ -#define GMAC_TXD_WRAP (1ul << 30) /**< Last descriptor */ -#define GMAC_TXD_ERROR (1ul << 29) /**< Retry limit exceeded, error */ -#define GMAC_TXD_UNDERRUN (1ul << 28) /**< Transmit underrun */ -#define GMAC_TXD_EXHAUSTED (1ul << 27) /**< Buffer exhausted */ -#define GMAC_TXD_LATE (1ul << 26) /**< Late collision,transmit error */ -#define GMAC_TXD_CHECKSUM_ERROR (7ul << 20) /**< Checksum error */ -#define GMAC_TXD_NOCRC (1ul << 16) /**< No CRC */ -#define GMAC_TXD_LAST (1ul << 15) /**< Last buffer in frame */ -#define GMAC_TXD_LEN_MASK (0x1FFF) /**< Length of buffer */ - -/** The MAC can support frame lengths up to 1536 bytes */ -#define GMAC_FRAME_LENTGH_MAX 1536 - -#define GMAC_RX_UNITSIZE 128 /**< Fixed size for RX buffer */ -#define GMAC_TX_UNITSIZE 1518 /**< Size for ETH frame length */ - -/** GMAC clock speed */ -#define GMAC_MCK_SPEED_240MHZ (240*1000*1000) -#define GMAC_MCK_SPEED_160MHZ (160*1000*1000) -#define GMAC_MCK_SPEED_120MHZ (120*1000*1000) -#define GMAC_MCK_SPEED_80MHZ (80*1000*1000) -#define GMAC_MCK_SPEED_40MHZ (40*1000*1000) -#define GMAC_MCK_SPEED_20MHZ (20*1000*1000) - -/** GMAC maintain code default value*/ -#define GMAC_MAN_CODE_VALUE (10) - -/** GMAC maintain start of frame default value*/ -#define GMAC_MAN_SOF_VALUE (1) - -/** GMAC maintain read/write*/ -#define GMAC_MAN_RW_TYPE (2) - -/** GMAC maintain read only*/ -#define GMAC_MAN_READ_ONLY (1) - -/** GMAC address length */ -#define GMAC_ADDR_LENGTH (6) - - -#define GMAC_DUPLEX_HALF 0 -#define GMAC_DUPLEX_FULL 1 - -#define GMAC_SPEED_10M 0 -#define GMAC_SPEED_100M 1 - -/** - * \brief Return codes for GMAC APIs. - */ -typedef enum { - GMAC_OK = 0, /** 0 Operation OK */ - GMAC_TIMEOUT = 1, /** 1 GMAC operation timeout */ - GMAC_TX_BUSY, /** 2 TX in progress */ - GMAC_RX_NULL, /** 3 No data received */ - GMAC_SIZE_TOO_SMALL, /** 4 Buffer size not enough */ - GMAC_PARAM, /** 5 Parameter error, TX packet invalid or RX size too small */ - GMAC_INVALID = 0xFF, /* Invalid */ -} gmac_status_t; - -/** - * \brief Media Independent Interface (MII) type. - */ -typedef enum { - GMAC_PHY_MII = 0, /** MII mode */ - GMAC_PHY_RMII = 1, /** Reduced MII mode */ - GMAC_PHY_INVALID = 0xFF, /* Invalid mode*/ -} gmac_mii_mode_t; - -/** Receive buffer descriptor struct */ -COMPILER_PACK_SET(8) -typedef struct gmac_rx_descriptor { - union gmac_rx_addr { - uint32_t val; - struct gmac_rx_addr_bm { - uint32_t b_ownership:1, /**< User clear, GMAC sets this to 1 once it has successfully written a frame to memory */ - b_wrap:1, /**< Marks last descriptor in receive buffer */ - addr_dw:30; /**< Address in number of DW */ - } bm; - } addr; /**< Address, Wrap & Ownership */ - union gmac_rx_status { - uint32_t val; - struct gmac_rx_status_bm { - uint32_t len:13, /** 0..12 Length of frame including FCS */ - b_fcs:1, /** 13 Receive buffer offset, bits 13:12 of frame length for jumbo frame */ - b_sof:1, /** 14 Start of frame */ - b_eof:1, /** 15 End of frame */ - b_cfi:1, /** 16 Concatenation Format Indicator */ - vlan_priority:3, /** 17..19 VLAN priority (if VLAN detected) */ - b_priority_detected:1, /** 20 Priority tag detected */ - b_vlan_detected:1, /** 21 VLAN tag detected */ - b_type_id_match:2, /** 22..23 Type ID match */ - b_checksumoffload:1, /** 24 Checksum offload specific function */ - b_addrmatch:2, /** 25..26 Address register match */ - b_ext_addr_match:1, /** 27 External address match found */ - reserved:1, /** 28 */ - b_uni_hash_match:1, /** 29 Unicast hash match */ - b_multi_hash_match:1, /** 30 Multicast hash match */ - b_boardcast_detect:1; /** 31 Global broadcast address detected */ - } bm; - } status; -} gmac_rx_descriptor_t; - -/** Transmit buffer descriptor struct */ -COMPILER_PACK_SET(8) -typedef struct gmac_tx_descriptor { - uint32_t addr; - union gmac_tx_status { - uint32_t val; - struct gmac_tx_status_bm { - uint32_t len:14, /** 0..13 Length of buffer */ - reserved:1, /** 14 */ - b_last_buffer:1, /** 15 Last buffer (in the current frame) */ - b_no_crc:1, /** 16 No CRC */ - reserved1:3, /** 17..19 */ - b_checksumoffload:3, /** 20..22 Transmit checksum generation offload errors */ - reserved2:3, /** 23..25 */ - b_lco:1, /** 26 Late collision, transmit error detected */ - b_exhausted:1, /** 27 Buffer exhausted in mid frame */ - b_underrun:1, /** 28 Transmit underrun */ - b_error:1, /** 29 Retry limit exceeded, error detected */ - b_wrap:1, /** 30 Marks last descriptor in TD list */ - b_used:1; /** 31 User clear, GMAC sets this to 1 once a frame has been successfully transmitted */ - } bm; - } status; -} gmac_tx_descriptor_t; - -COMPILER_PACK_RESET() - -/** - * \brief Input parameters when initializing the gmac module mode. - */ -typedef struct gmac_options { - /* Enable/Disable CopyAllFrame */ - uint8_t uc_copy_all_frame; - /* Enable/Disable NoBroadCast */ - uint8_t uc_no_boardcast; - /* MAC address */ - uint8_t uc_mac_addr[GMAC_ADDR_LENGTH]; -} gmac_options_t; - -/** RX callback */ -typedef void (*gmac_dev_tx_cb_t) (uint32_t ul_status); -/** Wakeup callback */ -typedef void (*gmac_dev_wakeup_cb_t) (void); - -/** - * GMAC driver structure. - */ -typedef struct gmac_device { - - /** Pointer to HW register base */ - Gmac *p_hw; - /** - * Pointer to allocated TX buffer. - * Section 3.6 of AMBA 2.0 spec states that burst should not cross - * 1K Boundaries. - * Receive buffer manager writes are burst of 2 words => 3 lsb bits - * of the address shall be set to 0. - */ - uint8_t *p_tx_buffer; - /** Pointer to allocated RX buffer */ - uint8_t *p_rx_buffer; - /** Pointer to Rx TDs (must be 8-byte aligned) */ - gmac_rx_descriptor_t *p_rx_dscr; - /** Pointer to Tx TDs (must be 8-byte aligned) */ - gmac_tx_descriptor_t *p_tx_dscr; - /** Optional callback to be invoked once a frame has been received */ - gmac_dev_tx_cb_t func_rx_cb; -#if( GMAC_USES_WAKEUP_CALLBACK ) - /** Optional callback to be invoked once several TDs have been released */ - gmac_dev_wakeup_cb_t func_wakeup_cb; -#endif -#if( GMAC_USES_TX_CALLBACK != 0 ) - /** Optional callback list to be invoked once TD has been processed */ - gmac_dev_tx_cb_t *func_tx_cb_list; -#endif - /** RX TD list size */ - uint32_t ul_rx_list_size; - /** RX index for current processing TD */ - uint32_t ul_rx_idx; - /** TX TD list size */ - uint32_t ul_tx_list_size; - /** Circular buffer head pointer by upper layer (buffer to be sent) */ - int32_t l_tx_head; - /** Circular buffer tail pointer incremented by handlers (buffer sent) */ - int32_t l_tx_tail; - - /** Number of free TD before wakeup callback is invoked */ - uint32_t uc_wakeup_threshold; -} gmac_device_t; - -/** - * \brief Write network control value. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_ncr Network control value. - */ -static inline void gmac_network_control(Gmac* p_gmac, uint32_t ul_ncr) -{ - p_gmac->GMAC_NCR = ul_ncr; -} - -/** - * \brief Get network control value. - * - * \param p_gmac Pointer to the GMAC instance. - */ - -static inline uint32_t gmac_get_network_control(Gmac* p_gmac) -{ - return p_gmac->GMAC_NCR; -} - -/** - * \brief Enable/Disable GMAC receive. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable GMAC receiver, else to enable it. - */ -static inline void gmac_enable_receive(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCR |= GMAC_NCR_RXEN; - } else { - p_gmac->GMAC_NCR &= ~GMAC_NCR_RXEN; - } -} - -/** - * \brief Enable/Disable GMAC transmit. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable GMAC transmit, else to enable it. - */ -static inline void gmac_enable_transmit(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCR |= GMAC_NCR_TXEN; - } else { - p_gmac->GMAC_NCR &= ~GMAC_NCR_TXEN; - } -} - -/** - * \brief Enable/Disable GMAC management. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable GMAC management, else to enable it. - */ -static inline void gmac_enable_management(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCR |= GMAC_NCR_MPE; - } else { - p_gmac->GMAC_NCR &= ~GMAC_NCR_MPE; - } -} - -/** - * \brief Clear all statistics registers. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_clear_statistics(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_CLRSTAT; -} - -/** - * \brief Increase all statistics registers. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_increase_statistics(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_INCSTAT; -} - -/** - * \brief Enable/Disable statistics registers writing. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable the statistics registers writing, else to enable it. - */ -static inline void gmac_enable_statistics_write(Gmac* p_gmac, - uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCR |= GMAC_NCR_WESTAT; - } else { - p_gmac->GMAC_NCR &= ~GMAC_NCR_WESTAT; - } -} - -/** - * \brief In half-duplex mode, forces collisions on all received frames. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable the back pressure, else to enable it. - */ -static inline void gmac_enable_back_pressure(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCR |= GMAC_NCR_BP; - } else { - p_gmac->GMAC_NCR &= ~GMAC_NCR_BP; - } -} - -/** - * \brief Start transmission. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_start_transmission(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_TSTART; -} - -/** - * \brief Halt transmission. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_halt_transmission(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_THALT; -} - -/** - * \brief Transmit pause frame. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_tx_pause_frame(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_TXPF; -} - -/** - * \brief Transmit zero quantum pause frame. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_tx_pause_zero_quantum_frame(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_TXZQPF; -} - -/** - * \brief Read snapshot. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_read_snapshot(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_RDS; -} - -/** - * \brief Store receivetime stamp to memory. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to normal operation, else to enable the store. - */ -static inline void gmac_store_rx_time_stamp(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCR |= GMAC_NCR_SRTSM; - } else { - p_gmac->GMAC_NCR &= ~GMAC_NCR_SRTSM; - } -} - -/** - * \brief Enable PFC priority-based pause reception. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 1 to set the reception, 0 to disable. - */ -static inline void gmac_enable_pfc_pause_frame(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCR |= GMAC_NCR_ENPBPR; - } else { - p_gmac->GMAC_NCR &= ~GMAC_NCR_ENPBPR; - } -} - -/** - * \brief Transmit PFC priority-based pause reception. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_transmit_pfc_pause_frame(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_TXPBPF; -} - -/** - * \brief Flush next packet. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_flush_next_packet(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_FNP; -} - -/** - * \brief Set up network configuration register. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_cfg Network configuration value. - */ -static inline void gmac_set_configure(Gmac* p_gmac, uint32_t ul_cfg) -{ - p_gmac->GMAC_NCFGR = ul_cfg; -} - -/** - * \brief Get network configuration. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Network configuration. - */ -static inline uint32_t gmac_get_configure(Gmac* p_gmac) -{ - return p_gmac->GMAC_NCFGR; -} - - -/* Get and set DMA Configuration Register */ -static inline void gmac_set_dma(Gmac* p_gmac, uint32_t ul_cfg) -{ - p_gmac->GMAC_DCFGR = ul_cfg; -} - -static inline uint32_t gmac_get_dma(Gmac* p_gmac) -{ - return p_gmac->GMAC_DCFGR; -} - -/** - * \brief Set speed. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_speed 1 to indicate 100Mbps, 0 to 10Mbps. - */ -static inline void gmac_set_speed(Gmac* p_gmac, uint8_t uc_speed) -{ - if (uc_speed) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_SPD; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_SPD; - } -} - -/** - * \brief Enable/Disable Full-Duplex mode. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable the Full-Duplex mode, else to enable it. - */ -static inline void gmac_enable_full_duplex(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_FD; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_FD; - } -} - -/** - * \brief Enable/Disable Copy(Receive) All Valid Frames. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable copying all valid frames, else to enable it. - */ -static inline void gmac_enable_copy_all(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_CAF; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_CAF; - } -} - -/** - * \brief Enable/Disable jumbo frames (up to 10240 bytes). - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable the jumbo frames, else to enable it. - */ -static inline void gmac_enable_jumbo_frames(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_JFRAME; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_JFRAME; - } -} - -/** - * \brief Disable/Enable broadcast receiving. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 1 to disable the broadcast, else to enable it. - */ -static inline void gmac_disable_broadcast(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_NBC; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_NBC; - } -} - -/** - * \brief Enable/Disable multicast hash. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable the multicast hash, else to enable it. - */ -static inline void gmac_enable_multicast_hash(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_UNIHEN; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_UNIHEN; - } -} - -/** - * \brief Enable/Disable big frames (over 1518, up to 1536). - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable big frames else to enable it. - */ -static inline void gmac_enable_big_frame(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_MAXFS; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_MAXFS; - } -} - -/** - * \brief Set MDC clock divider. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_mck GMAC MCK. - * - * \return GMAC_OK if successfully. - */ -static inline uint8_t gmac_set_mdc_clock(Gmac* p_gmac, uint32_t ul_mck) -{ - uint32_t ul_clk; - - if (ul_mck > GMAC_MCK_SPEED_240MHZ) { - return GMAC_INVALID; - } else if (ul_mck > GMAC_MCK_SPEED_160MHZ) { - ul_clk = GMAC_NCFGR_CLK_MCK_96; - } else if (ul_mck > GMAC_MCK_SPEED_120MHZ) { - ul_clk = GMAC_NCFGR_CLK_MCK_64; - } else if (ul_mck > GMAC_MCK_SPEED_80MHZ) { - ul_clk = GMAC_NCFGR_CLK_MCK_48; - } else if (ul_mck > GMAC_MCK_SPEED_40MHZ) { - ul_clk = GMAC_NCFGR_CLK_MCK_32; - } else if (ul_mck > GMAC_MCK_SPEED_20MHZ) { - ul_clk = GMAC_NCFGR_CLK_MCK_16; - } else { - ul_clk = GMAC_NCFGR_CLK_MCK_8; - } - ; - p_gmac->GMAC_NCFGR = (p_gmac->GMAC_NCFGR & ~GMAC_NCFGR_CLK_Msk) | ul_clk; - return GMAC_OK; -} - -/** - * \brief Enable/Disable retry test. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable the GMAC receiver, else to enable it. - */ -static inline void gmac_enable_retry_test(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_RTY; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_RTY; - } -} - -/** - * \brief Enable/Disable pause (when a valid pause frame is received). - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable pause frame, else to enable it. - */ -static inline void gmac_enable_pause_frame(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_PEN; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_PEN; - } -} - -/** - * \brief Set receive buffer offset to 0 ~ 3. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_set_rx_buffer_offset(Gmac* p_gmac, uint8_t uc_offset) -{ - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_RXBUFO_Msk; - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_RXBUFO(uc_offset); -} - -/** - * \brief Enable/Disable receive length field checking. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable receive length field checking, else to enable it. - */ -static inline void gmac_enable_rx_length_check(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_LFERD; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_LFERD; - } -} - -/** - * \brief Enable/Disable discarding FCS field of received frames. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable discarding FCS field of received frames, else to enable it. - */ -static inline void gmac_enable_discard_fcs(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_RFCS; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_RFCS; - } -} - - -/** - * \brief Enable/Disable frames to be received in half-duplex mode - * while transmitting. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable the received in half-duplex mode, else to enable it. - */ -static inline void gmac_enable_efrhd(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_EFRHD; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_EFRHD; - } -} - -/** - * \brief Enable/Disable ignore RX FCS. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable ignore RX FCS, else to enable it. - */ -static inline void gmac_enable_ignore_rx_fcs(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_IRXFCS; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_IRXFCS; - } -} - -/** - * \brief Get Network Status. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Network status. - */ -static inline uint32_t gmac_get_status(Gmac* p_gmac) -{ - return p_gmac->GMAC_NSR; -} - -/** - * \brief Get MDIO IN pin status. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return MDIO IN pin status. - */ -static inline uint8_t gmac_get_MDIO(Gmac* p_gmac) -{ - return ((p_gmac->GMAC_NSR & GMAC_NSR_MDIO) > 0); -} - -/** - * \brief Check if PHY is idle. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return 1 if PHY is idle. - */ -static inline uint8_t gmac_is_phy_idle(Gmac* p_gmac) -{ - return ((p_gmac->GMAC_NSR & GMAC_NSR_IDLE) > 0); -} - -/** - * \brief Return transmit status. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Transmit status. - */ -static inline uint32_t gmac_get_tx_status(Gmac* p_gmac) -{ - return p_gmac->GMAC_TSR; -} - -/** - * \brief Clear transmit status. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_status Transmit status. - */ -static inline void gmac_clear_tx_status(Gmac* p_gmac, uint32_t ul_status) -{ - p_gmac->GMAC_TSR = ul_status; -} - -/** - * \brief Return receive status. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline uint32_t gmac_get_rx_status(Gmac* p_gmac) -{ - return p_gmac->GMAC_RSR; -} - -/** - * \brief Clear receive status. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_status Receive status. - */ -static inline void gmac_clear_rx_status(Gmac* p_gmac, uint32_t ul_status) -{ - p_gmac->GMAC_RSR = ul_status; -} - -/** - * \brief Set Rx Queue. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_addr Rx queue address. - */ -static inline void gmac_set_rx_queue(Gmac* p_gmac, uint32_t ul_addr) -{ - p_gmac->GMAC_RBQB = GMAC_RBQB_ADDR_Msk & ul_addr; -} - -/** - * \brief Get Rx Queue Address. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Rx queue address. - */ -static inline uint32_t gmac_get_rx_queue(Gmac* p_gmac) -{ - return p_gmac->GMAC_RBQB; -} - -/** - * \brief Set Tx Queue. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_addr Tx queue address. - */ -static inline void gmac_set_tx_queue(Gmac* p_gmac, uint32_t ul_addr) -{ - p_gmac->GMAC_TBQB = GMAC_TBQB_ADDR_Msk & ul_addr; -} - -/** - * \brief Get Tx Queue. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Rx queue address. - */ -static inline uint32_t gmac_get_tx_queue(Gmac* p_gmac) -{ - return p_gmac->GMAC_TBQB; -} - -/** - * \brief Enable interrupt(s). - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_source Interrupt source(s) to be enabled. - */ -static inline void gmac_enable_interrupt(Gmac* p_gmac, uint32_t ul_source) -{ - p_gmac->GMAC_IER = ul_source; -} - -/** - * \brief Disable interrupt(s). - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_source Interrupt source(s) to be disabled. - */ -static inline void gmac_disable_interrupt(Gmac* p_gmac, uint32_t ul_source) -{ - p_gmac->GMAC_IDR = ul_source; -} - -/** - * \brief Return interrupt status. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Interrupt status. - */ -static inline uint32_t gmac_get_interrupt_status(Gmac* p_gmac) -{ - return p_gmac->GMAC_ISR; -} - -/** - * \brief Return interrupt mask. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Interrupt mask. - */ -static inline uint32_t gmac_get_interrupt_mask(Gmac* p_gmac) -{ - return p_gmac->GMAC_IMR; -} - -/** - * \brief Execute PHY maintenance command. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_phy_addr PHY address. - * \param uc_reg_addr Register address. - * \param uc_rw 1 to Read, 0 to write. - * \param us_data Data to be performed, write only. - */ -static inline void gmac_maintain_phy(Gmac* p_gmac, - uint8_t uc_phy_addr, uint8_t uc_reg_addr, uint8_t uc_rw, - uint16_t us_data) -{ - /* Wait until bus idle */ - while ((p_gmac->GMAC_NSR & GMAC_NSR_IDLE) == 0); - /* Write maintain register */ - p_gmac->GMAC_MAN = GMAC_MAN_WTN(GMAC_MAN_CODE_VALUE) - | GMAC_MAN_CLTTO - | GMAC_MAN_PHYA(uc_phy_addr) - | GMAC_MAN_REGA(uc_reg_addr) - | GMAC_MAN_OP((uc_rw ? GMAC_MAN_RW_TYPE : GMAC_MAN_READ_ONLY)) - | GMAC_MAN_DATA(us_data); -} - -/** - * \brief Get PHY maintenance data returned. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Get PHY data. - */ -static inline uint16_t gmac_get_phy_data(Gmac* p_gmac) -{ - /* Wait until bus idle */ - while ((p_gmac->GMAC_NSR & GMAC_NSR_IDLE) == 0); - /* Return data */ - return (uint16_t) (p_gmac->GMAC_MAN & GMAC_MAN_DATA_Msk); -} - -/** - * \brief Set Hash. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_hash_top Hash top. - * \param ul_hash_bottom Hash bottom. - */ -static inline void gmac_set_hash(Gmac* p_gmac, uint32_t ul_hash_top, - uint32_t ul_hash_bottom) -{ - p_gmac->GMAC_HRB = ul_hash_bottom; - p_gmac->GMAC_HRT = ul_hash_top; -} - -/** - * \brief Set 64 bits Hash. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ull_hash 64 bits hash value. - */ -static inline void gmac_set_hash64(Gmac* p_gmac, uint64_t ull_hash) -{ - p_gmac->GMAC_HRB = (uint32_t) ull_hash; - p_gmac->GMAC_HRT = (uint32_t) (ull_hash >> 32); -} - -/** - * \brief Set MAC Address. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_index GMAC specific address register index. - * \param p_mac_addr GMAC address. - */ -static inline void gmac_set_address(Gmac* p_gmac, uint8_t uc_index, - uint8_t* p_mac_addr) -{ - p_gmac->GMAC_SA[uc_index].GMAC_SAB = (p_mac_addr[3] << 24) - | (p_mac_addr[2] << 16) - | (p_mac_addr[1] << 8) - | (p_mac_addr[0]); - p_gmac->GMAC_SA[uc_index].GMAC_SAT = (p_mac_addr[5] << 8) - | (p_mac_addr[4]); -} - -/** - * \brief Set MAC Address via 2 dword. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_index GMAC specific address register index. - * \param ul_mac_top GMAC top address. - * \param ul_mac_bottom GMAC bottom address. - */ -static inline void gmac_set_address32(Gmac* p_gmac, uint8_t uc_index, - uint32_t ul_mac_top, uint32_t ul_mac_bottom) -{ - p_gmac->GMAC_SA[uc_index].GMAC_SAB = ul_mac_bottom; - p_gmac->GMAC_SA[uc_index].GMAC_SAT = ul_mac_top; -} - -/** - * \brief Set MAC Address via int64. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_index GMAC specific address register index. - * \param ull_mac 64-bit GMAC address. - */ -static inline void gmac_set_address64(Gmac* p_gmac, uint8_t uc_index, - uint64_t ull_mac) -{ - p_gmac->GMAC_SA[uc_index].GMAC_SAB = (uint32_t) ull_mac; - p_gmac->GMAC_SA[uc_index].GMAC_SAT = (uint32_t) (ull_mac >> 32); -} - -/** - * \brief Select media independent interface mode. - * - * \param p_gmac Pointer to the GMAC instance. - * \param mode Media independent interface mode. - */ -static inline void gmac_select_mii_mode(Gmac* p_gmac, gmac_mii_mode_t mode) -{ - switch (mode) { - case GMAC_PHY_MII: - case GMAC_PHY_RMII: - p_gmac->GMAC_UR |= GMAC_UR_RMIIMII; - break; - - default: - p_gmac->GMAC_UR &= ~GMAC_UR_RMIIMII; - break; - } -} - -uint8_t gmac_phy_read(Gmac* p_gmac, uint8_t uc_phy_address, uint8_t uc_address, - uint32_t* p_value); -uint8_t gmac_phy_write(Gmac* p_gmac, uint8_t uc_phy_address, - uint8_t uc_address, uint32_t ul_value); -void gmac_dev_init(Gmac* p_gmac, gmac_device_t* p_gmac_dev, - gmac_options_t* p_opt); -uint32_t gmac_dev_read(gmac_device_t* p_gmac_dev, uint8_t* p_frame, - uint32_t ul_frame_size, uint32_t* p_rcv_size); -uint32_t gmac_dev_write(gmac_device_t* p_gmac_dev, void *p_buffer, - uint32_t ul_size, gmac_dev_tx_cb_t func_tx_cb); -uint32_t gmac_dev_get_tx_load(gmac_device_t* p_gmac_dev); -void gmac_dev_set_rx_callback(gmac_device_t* p_gmac_dev, - gmac_dev_tx_cb_t func_rx_cb); -uint8_t gmac_dev_set_tx_wakeup_callback(gmac_device_t* p_gmac_dev, - gmac_dev_wakeup_cb_t func_wakeup, uint8_t uc_threshold); -void gmac_dev_reset(gmac_device_t* p_gmac_dev); -void gmac_handler(gmac_device_t* p_gmac_dev); - -/// @cond 0 -/**INDENT-OFF**/ -#ifdef __cplusplus -} -#endif -/**INDENT-ON**/ -/// @endcond - -/** - * \page gmac_quickstart Quickstart guide for GMAC driver. - * - * This is the quickstart guide for the \ref gmac_group "Ethernet MAC", - * with step-by-step instructions on how to configure and use the driver in a - * selection of use cases. - * - * The use cases contain several code fragments. The code fragments in the - * steps for setup can be copied into a custom initialization function, while - * the steps for usage can be copied into, e.g., the main application function. - * - * \section gmac_basic_use_case Basic use case - * In the basic use case, the GMAC driver are configured for: - * - PHY component KSZ8051MNL is used - * - GMAC uses MII mode - * - The number of receive buffer is 16 - * - The number of transfer buffer is 8 - * - MAC address is set to 00-04-25-1c-a0-02 - * - IP address is set to 192.168.0.2 - * - IP address is set to 192.168.0.2 - * - Gateway is set to 192.168.0.1 - * - Network mask is 255.255.255.0 - * - PHY operation max retry count is 1000000 - * - GMAC is configured to not support copy all frame and support broadcast - * - The data will be read from the ethernet - * - * \section gmac_basic_use_case_setup Setup steps - * - * \subsection gmac_basic_use_case_setup_prereq Prerequisites - * -# \ref sysclk_group "System Clock Management (sysclock)" - * -# \ref pmc_group "Power Management Controller (pmc)" - * -# \ref ksz8051mnl_ethernet_phy_group "PHY component (KSZ8051MNL)" - * - * \subsection gmac_basic_use_case_setup_code Example code - * Content of conf_eth.h - * \code - * #define GMAC_RX_BUFFERS 16 - * #define GMAC_TX_BUFFERS 8 - * #define MAC_PHY_RETRY_MAX 1000000 - * #define ETHERNET_CONF_ETHADDR0 0x00 - * #define ETHERNET_CONF_ETHADDR0 0x00 - * #define ETHERNET_CONF_ETHADDR1 0x04 - * #define ETHERNET_CONF_ETHADDR2 0x25 - * #define ETHERNET_CONF_ETHADDR3 0x1C - * #define ETHERNET_CONF_ETHADDR4 0xA0 - * #define ETHERNET_CONF_ETHADDR5 0x02 - * #define ETHERNET_CONF_IPADDR0 192 - * #define ETHERNET_CONF_IPADDR1 168 - * #define ETHERNET_CONF_IPADDR2 0 - * #define ETHERNET_CONF_IPADDR3 2 - * #define ETHERNET_CONF_GATEWAY_ADDR0 192 - * #define ETHERNET_CONF_GATEWAY_ADDR1 168 - * #define ETHERNET_CONF_GATEWAY_ADDR2 0 - * #define ETHERNET_CONF_GATEWAY_ADDR3 1 - * #define ETHERNET_CONF_NET_MASK0 255 - * #define ETHERNET_CONF_NET_MASK1 255 - * #define ETHERNET_CONF_NET_MASK2 255 - * #define ETHERNET_CONF_NET_MASK3 0 - * #define ETH_PHY_MODE ETH_PHY_MODE - * \endcode - * - * A specific gmac device and the receive data buffer must be defined; another ul_frm_size should be defined - * to trace the actual size of the data received. - * \code - * static gmac_device_t gs_gmac_dev; - * static volatile uint8_t gs_uc_eth_buffer[GMAC_FRAME_LENTGH_MAX]; - * - * uint32_t ul_frm_size; - * \endcode - * - * Add to application C-file: - * \code - * void gmac_init(void) - * { - * sysclk_init(); - * - * board_init(); - * - * pmc_enable_periph_clk(ID_GMAC); - * - * gmac_option.uc_copy_all_frame = 0; - * gmac_option.uc_no_boardcast = 0; - * memcpy(gmac_option.uc_mac_addr, gs_uc_mac_address, sizeof(gs_uc_mac_address)); - * gs_gmac_dev.p_hw = GMAC; - * - * gmac_dev_init(GMAC, &gs_gmac_dev, &gmac_option); - * - * NVIC_EnableIRQ(GMAC_IRQn); - * - * ethernet_phy_init(GMAC, BOARD_GMAC_PHY_ADDR, sysclk_get_cpu_hz()); - * - * ethernet_phy_auto_negotiate(GMAC, BOARD_GMAC_PHY_ADDR); - * - * ethernet_phy_set_link(GMAC, BOARD_GMAC_PHY_ADDR, 1); - * \endcode - * - * \subsection gmac_basic_use_case_setup_flow Workflow - * - Ensure that conf_eth.h is present and contains the - * following configuration symbol. This configuration file is used - * by the driver and should not be included by the application. - * -# Define the receiving buffer size used in the internal GMAC driver. - * The buffer size used for RX is GMAC_RX_BUFFERS * 128. - * If it was supposed receiving a large number of frame, the - * GMAC_RX_BUFFERS should be set higher. E.g., the application wants to accept - * a ping echo test of 2048, the GMAC_RX_BUFFERS should be set at least - * (2048/128)=16, and as there are additional frames coming, a preferred - * number is 24 depending on a normal Ethernet throughput. - * - \code - * #define GMAC_RX_BUFFERS 16 - * \endcode - * -# Define the transmitting buffer size used in the internal GMAC driver. - * The buffer size used for TX is GMAC_TX_BUFFERS * 1518. - * - \code - * #define GMAC_TX_BUFFERS 8 - * \endcode - * -# Define maximum retry time for a PHY read/write operation. - * - \code - * #define MAC_PHY_RETRY_MAX 1000000 - * \endcode - * -# Define the MAC address. 00:04:25:1C:A0:02 is the address reserved - * for ATMEL, application should always change this address to its' own. - * - \code - * #define ETHERNET_CONF_ETHADDR0 0x00 - * #define ETHERNET_CONF_ETHADDR1 0x04 - * #define ETHERNET_CONF_ETHADDR2 0x25 - * #define ETHERNET_CONF_ETHADDR3 0x1C - * #define ETHERNET_CONF_ETHADDR4 0xA0 - * #define ETHERNET_CONF_ETHADDR5 0x02 - * \endcode - * -# Define the IP address configration used in the application. When DHCP - * is enabled, this configuration is not effected. - * - \code - * #define ETHERNET_CONF_IPADDR0 192 - * #define ETHERNET_CONF_IPADDR1 168 - * #define ETHERNET_CONF_IPADDR2 0 - * #define ETHERNET_CONF_IPADDR3 2 - * #define ETHERNET_CONF_GATEWAY_ADDR0 192 - * #define ETHERNET_CONF_GATEWAY_ADDR1 168 - * #define ETHERNET_CONF_GATEWAY_ADDR2 0 - * #define ETHERNET_CONF_GATEWAY_ADDR3 1 - * #define ETHERNET_CONF_NET_MASK0 255 - * #define ETHERNET_CONF_NET_MASK1 255 - * #define ETHERNET_CONF_NET_MASK2 255 - * #define ETHERNET_CONF_NET_MASK3 0 - * \endcode - * -# Configure the PHY maintainance interface. - * - \code - * #define ETH_PHY_MODE GMAC_PHY_MII - * \endcode - * -# Enable the system clock: - * - \code sysclk_init(); \endcode - * -# Enable PIO configurations for GMAC: - * - \code board_init(); \endcode - * -# Enable PMC clock for GMAC: - * - \code pmc_enable_periph_clk(ID_GMAC); \endcode - * -# Set the GMAC options; it's set to copy all frame and support broadcast: - * - \code - * gmac_option.uc_copy_all_frame = 0; - * gmac_option.uc_no_boardcast = 0; - * memcpy(gmac_option.uc_mac_addr, gs_uc_mac_address, sizeof(gs_uc_mac_address)); - * gs_gmac_dev.p_hw = GMAC; - * \endcode - * -# Initialize GMAC device with the filled option: - * - \code - * gmac_dev_init(GMAC, &gs_gmac_dev, &gmac_option); - * \endcode - * -# Enable the interrupt service for GMAC: - * - \code - * NVIC_EnableIRQ(GMAC_IRQn); - * \endcode - * -# Initialize the PHY component: - * - \code - * ethernet_phy_init(GMAC, BOARD_GMAC_PHY_ADDR, sysclk_get_cpu_hz()); - * \endcode - * -# The link will be established based on auto negotiation. - * - \code - * ethernet_phy_auto_negotiate(GMAC, BOARD_GMAC_PHY_ADDR); - * \endcode - * -# Establish the ethernet link; the network can be worked from now on: - * - \code - * ethernet_phy_set_link(GMAC, BOARD_GMAC_PHY_ADDR, 1); - * \endcode - * - * \section gmac_basic_use_case_usage Usage steps - * \subsection gmac_basic_use_case_usage_code Example code - * Add to, e.g., main loop in application C-file: - * \code - * gmac_dev_read(&gs_gmac_dev, (uint8_t *) gs_uc_eth_buffer, sizeof(gs_uc_eth_buffer), &ul_frm_size)); - * \endcode - * - * \subsection gmac_basic_use_case_usage_flow Workflow - * -# Start reading the data from the ethernet: - * - \code gmac_dev_read(&gs_gmac_dev, (uint8_t *) gs_uc_eth_buffer, sizeof(gs_uc_eth_buffer), &ul_frm_size)); \endcode - */ - -# define GMAC_STATS 0 - -#if( GMAC_STATS != 0 ) - - /* Here below some code to study the types and - frequencies of GMAC interrupts. */ - #define GMAC_IDX_RXUBR 0 - #define GMAC_IDX_TUR 1 - #define GMAC_IDX_RLEX 2 - #define GMAC_IDX_TFC 3 - #define GMAC_IDX_RCOMP 4 - #define GMAC_IDX_TCOMP 5 - #define GMAC_IDX_ROVR 6 - #define GMAC_IDX_HRESP 7 - #define GMAC_IDX_PFNZ 8 - #define GMAC_IDX_PTZ 9 - - struct SGmacStats { - unsigned recvCount; - unsigned rovrCount; - unsigned bnaCount; - unsigned sendCount; - unsigned sovrCount; - unsigned incompCount; - unsigned truncCount; - - unsigned intStatus[10]; - }; - extern struct SGmacStats gmacStats; - - struct SIntPair { - const char *name; - unsigned mask; - int index; - }; - - #define MK_PAIR( NAME ) #NAME, GMAC_IER_##NAME, GMAC_IDX_##NAME - static const struct SIntPair intPairs[] = { - { MK_PAIR( RXUBR ) }, /* Enable receive used bit read interrupt. */ - { MK_PAIR( TUR ) }, /* Enable transmit underrun interrupt. */ - { MK_PAIR( RLEX ) }, /* Enable retry limit exceeded interrupt. */ - { MK_PAIR( TFC ) }, /* Enable transmit buffers exhausted in mid-frame interrupt. */ - { MK_PAIR( RCOMP ) }, /* Receive complete */ - { MK_PAIR( TCOMP ) }, /* Enable transmit complete interrupt. */ - { MK_PAIR( ROVR ) }, /* Enable receive overrun interrupt. */ - { MK_PAIR( HRESP ) }, /* Enable Hresp not OK interrupt. */ - { MK_PAIR( PFNZ ) }, /* Enable pause frame received interrupt. */ - { MK_PAIR( PTZ ) } /* Enable pause time zero interrupt. */ - }; - - void gmac_show_irq_counts (); - -#endif - -#endif /* GMAC_H_INCLUDED */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/instance/gmac.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/instance/gmac.h deleted file mode 100755 index dd29dfe..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/instance/gmac.h +++ /dev/null @@ -1,1349 +0,0 @@ - /** - * \file - * - * \brief GMAC (Ethernet MAC) driver for SAM. - * - * Copyright (c) 2013 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ - -#ifndef GMAC_H_INCLUDED -#define GMAC_H_INCLUDED - -#include "compiler.h" -#include "component/gmac.h" - -/// @cond 0 -/**INDENT-OFF**/ -#ifdef __cplusplus -extern "C" { -#endif -/**INDENT-ON**/ -/// @endcond - -/** The buffer addresses written into the descriptors must be aligned, so the - last few bits are zero. These bits have special meaning for the GMAC - peripheral and cannot be used as part of the address. */ -#define GMAC_RXD_ADDR_MASK 0xFFFFFFFC -#define GMAC_RXD_WRAP (1ul << 1) /**< Wrap bit */ -#define GMAC_RXD_OWNERSHIP (1ul << 0) /**< Ownership bit */ - -#define GMAC_RXD_BROADCAST (1ul << 31) /**< Broadcast detected */ -#define GMAC_RXD_MULTIHASH (1ul << 30) /**< Multicast hash match */ -#define GMAC_RXD_UNIHASH (1ul << 29) /**< Unicast hash match */ -#define GMAC_RXD_ADDR_FOUND (1ul << 27) /**< Specific address match found */ -#define GMAC_RXD_ADDR (3ul << 25) /**< Address match */ -#define GMAC_RXD_RXCOEN (1ul << 24) /**< RXCOEN related function */ -#define GMAC_RXD_TYPE (3ul << 22) /**< Type ID match */ -#define GMAC_RXD_VLAN (1ul << 21) /**< VLAN tag detected */ -#define GMAC_RXD_PRIORITY (1ul << 20) /**< Priority tag detected */ -#define GMAC_RXD_PRIORITY_MASK (3ul << 17) /**< VLAN priority */ -#define GMAC_RXD_CFI (1ul << 16) /**< Concatenation Format Indicator only if bit 21 is set */ -#define GMAC_RXD_EOF (1ul << 15) /**< End of frame */ -#define GMAC_RXD_SOF (1ul << 14) /**< Start of frame */ -#define GMAC_RXD_FCS (1ul << 13) /**< Frame check sequence */ -#define GMAC_RXD_OFFSET_MASK /**< Receive buffer offset */ -#define GMAC_RXD_LEN_MASK (0xFFF) /**< Length of frame including FCS (if selected) */ -#define GMAC_RXD_LENJUMBO_MASK (0x3FFF) /**< Jumbo frame length */ - -#define GMAC_TXD_USED (1ul << 31) /**< Frame is transmitted */ -#define GMAC_TXD_WRAP (1ul << 30) /**< Last descriptor */ -#define GMAC_TXD_ERROR (1ul << 29) /**< Retry limit exceeded, error */ -#define GMAC_TXD_UNDERRUN (1ul << 28) /**< Transmit underrun */ -#define GMAC_TXD_EXHAUSTED (1ul << 27) /**< Buffer exhausted */ -#define GMAC_TXD_LATE (1ul << 26) /**< Late collision,transmit error */ -#define GMAC_TXD_CHECKSUM_ERROR (7ul << 20) /**< Checksum error */ -#define GMAC_TXD_NOCRC (1ul << 16) /**< No CRC */ -#define GMAC_TXD_LAST (1ul << 15) /**< Last buffer in frame */ -#define GMAC_TXD_LEN_MASK (0x1FFF) /**< Length of buffer */ - -/** The MAC can support frame lengths up to 1536 bytes */ -#define GMAC_FRAME_LENTGH_MAX 1536 - -#define GMAC_RX_UNITSIZE 128 /**< Fixed size for RX buffer */ -#define GMAC_TX_UNITSIZE 1518 /**< Size for ETH frame length */ - -/** GMAC clock speed */ -#define GMAC_MCK_SPEED_240MHZ (240*1000*1000) -#define GMAC_MCK_SPEED_160MHZ (160*1000*1000) -#define GMAC_MCK_SPEED_120MHZ (120*1000*1000) -#define GMAC_MCK_SPEED_80MHZ (80*1000*1000) -#define GMAC_MCK_SPEED_40MHZ (40*1000*1000) -#define GMAC_MCK_SPEED_20MHZ (20*1000*1000) - -/** GMAC maintain code default value*/ -#define GMAC_MAN_CODE_VALUE (10) - -/** GMAC maintain start of frame default value*/ -#define GMAC_MAN_SOF_VALUE (1) - -/** GMAC maintain read/write*/ -#define GMAC_MAN_RW_TYPE (2) - -/** GMAC maintain read only*/ -#define GMAC_MAN_READ_ONLY (1) - -/** GMAC address length */ -#define GMAC_ADDR_LENGTH (6) - - -#define GMAC_DUPLEX_HALF 0 -#define GMAC_DUPLEX_FULL 1 - -#define GMAC_SPEED_10M 0 -#define GMAC_SPEED_100M 1 - -/** - * \brief Return codes for GMAC APIs. - */ -typedef enum { - GMAC_OK = 0, /** 0 Operation OK */ - GMAC_TIMEOUT = 1, /** 1 GMAC operation timeout */ - GMAC_TX_BUSY, /** 2 TX in progress */ - GMAC_RX_NULL, /** 3 No data received */ - GMAC_SIZE_TOO_SMALL, /** 4 Buffer size not enough */ - GMAC_PARAM, /** 5 Parameter error, TX packet invalid or RX size too small */ - GMAC_INVALID = 0xFF, /* Invalid */ -} gmac_status_t; - -/** - * \brief Media Independent Interface (MII) type. - */ -typedef enum { - GMAC_PHY_MII = 0, /** MII mode */ - GMAC_PHY_RMII = 1, /** Reduced MII mode */ - GMAC_PHY_INVALID = 0xFF, /* Invalid mode*/ -} gmac_mii_mode_t; - -/** Receive buffer descriptor struct */ -COMPILER_PACK_SET(8) -typedef struct gmac_rx_descriptor { - union gmac_rx_addr { - uint32_t val; - struct gmac_rx_addr_bm { - uint32_t b_ownership:1, /**< User clear, GMAC sets this to 1 once it has successfully written a frame to memory */ - b_wrap:1, /**< Marks last descriptor in receive buffer */ - addr_dw:30; /**< Address in number of DW */ - } bm; - } addr; /**< Address, Wrap & Ownership */ - union gmac_rx_status { - uint32_t val; - struct gmac_rx_status_bm { - uint32_t len:13, /** 0..12 Length of frame including FCS */ - b_fcs:1, /** 13 Receive buffer offset, bits 13:12 of frame length for jumbo frame */ - b_sof:1, /** 14 Start of frame */ - b_eof:1, /** 15 End of frame */ - b_cfi:1, /** 16 Concatenation Format Indicator */ - vlan_priority:3, /** 17..19 VLAN priority (if VLAN detected) */ - b_priority_detected:1, /** 20 Priority tag detected */ - b_vlan_detected:1, /** 21 VLAN tag detected */ - b_type_id_match:2, /** 22..23 Type ID match */ - b_checksumoffload:1, /** 24 Checksum offload specific function */ - b_addrmatch:2, /** 25..26 Address register match */ - b_ext_addr_match:1, /** 27 External address match found */ - reserved:1, /** 28 */ - b_uni_hash_match:1, /** 29 Unicast hash match */ - b_multi_hash_match:1, /** 30 Multicast hash match */ - b_boardcast_detect:1; /** 31 Global broadcast address detected */ - } bm; - } status; -} gmac_rx_descriptor_t; - -/** Transmit buffer descriptor struct */ -COMPILER_PACK_SET(8) -typedef struct gmac_tx_descriptor { - uint32_t addr; - union gmac_tx_status { - uint32_t val; - struct gmac_tx_status_bm { - uint32_t len:14, /** 0..13 Length of buffer */ - reserved:1, /** 14 */ - b_last_buffer:1, /** 15 Last buffer (in the current frame) */ - b_no_crc:1, /** 16 No CRC */ - reserved1:3, /** 17..19 */ - b_checksumoffload:3, /** 20..22 Transmit checksum generation offload errors */ - reserved2:3, /** 23..25 */ - b_lco:1, /** 26 Late collision, transmit error detected */ - b_exhausted:1, /** 27 Buffer exhausted in mid frame */ - b_underrun:1, /** 28 Transmit underrun */ - b_error:1, /** 29 Retry limit exceeded, error detected */ - b_wrap:1, /** 30 Marks last descriptor in TD list */ - b_used:1; /** 31 User clear, GMAC sets this to 1 once a frame has been successfully transmitted */ - } bm; - } status; -} gmac_tx_descriptor_t; - -COMPILER_PACK_RESET() - -/** - * \brief Input parameters when initializing the gmac module mode. - */ -typedef struct gmac_options { - /* Enable/Disable CopyAllFrame */ - uint8_t uc_copy_all_frame; - /* Enable/Disable NoBroadCast */ - uint8_t uc_no_boardcast; - /* MAC address */ - uint8_t uc_mac_addr[GMAC_ADDR_LENGTH]; -} gmac_options_t; - -/** TX callback */ -typedef void (*gmac_dev_tx_cb_t) (uint32_t ul_status, uint8_t *puc_buffer); -/** RX callback */ -typedef void (*gmac_dev_rx_cb_t) (uint32_t ul_status); -/** Wakeup callback */ -typedef void (*gmac_dev_wakeup_cb_t) (void); - -/** - * GMAC driver structure. - */ -typedef struct gmac_device { - - /** Pointer to HW register base */ - Gmac *p_hw; - /** - * Pointer to allocated TX buffer. - * Section 3.6 of AMBA 2.0 spec states that burst should not cross - * 1K Boundaries. - * Receive buffer manager writes are burst of 2 words => 3 lsb bits - * of the address shall be set to 0. - */ - uint8_t *p_tx_buffer; - /** Pointer to allocated RX buffer */ - uint8_t *p_rx_buffer; - /** Pointer to Rx TDs (must be 8-byte aligned) */ - gmac_rx_descriptor_t *p_rx_dscr; - /** Pointer to Tx TDs (must be 8-byte aligned) */ - gmac_tx_descriptor_t *p_tx_dscr; - /** Optional callback to be invoked once a frame has been received */ - gmac_dev_rx_cb_t func_rx_cb; -#if( GMAC_USES_WAKEUP_CALLBACK ) - /** Optional callback to be invoked once several TDs have been released */ - gmac_dev_wakeup_cb_t func_wakeup_cb; -#endif -#if( GMAC_USES_TX_CALLBACK != 0 ) - /** Optional callback list to be invoked once TD has been processed */ - gmac_dev_tx_cb_t *func_tx_cb_list; -#endif - /** RX TD list size */ - uint32_t ul_rx_list_size; - /** RX index for current processing TD */ - uint32_t ul_rx_idx; - /** TX TD list size */ - uint32_t ul_tx_list_size; - /** Circular buffer head pointer by upper layer (buffer to be sent) */ - int32_t l_tx_head; - /** Circular buffer tail pointer incremented by handlers (buffer sent) */ - int32_t l_tx_tail; - - /** Number of free TD before wakeup callback is invoked */ - uint32_t uc_wakeup_threshold; -} gmac_device_t; - -/** - * \brief Write network control value. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_ncr Network control value. - */ -static inline void gmac_network_control(Gmac* p_gmac, uint32_t ul_ncr) -{ - p_gmac->GMAC_NCR = ul_ncr; -} - -/** - * \brief Get network control value. - * - * \param p_gmac Pointer to the GMAC instance. - */ - -static inline uint32_t gmac_get_network_control(Gmac* p_gmac) -{ - return p_gmac->GMAC_NCR; -} - -/** - * \brief Enable/Disable GMAC receive. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable GMAC receiver, else to enable it. - */ -static inline void gmac_enable_receive(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCR |= GMAC_NCR_RXEN; - } else { - p_gmac->GMAC_NCR &= ~GMAC_NCR_RXEN; - } -} - -/** - * \brief Enable/Disable GMAC transmit. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable GMAC transmit, else to enable it. - */ -static inline void gmac_enable_transmit(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCR |= GMAC_NCR_TXEN; - } else { - p_gmac->GMAC_NCR &= ~GMAC_NCR_TXEN; - } -} - -/** - * \brief Enable/Disable GMAC management. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable GMAC management, else to enable it. - */ -static inline void gmac_enable_management(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCR |= GMAC_NCR_MPE; - } else { - p_gmac->GMAC_NCR &= ~GMAC_NCR_MPE; - } -} - -/** - * \brief Clear all statistics registers. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_clear_statistics(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_CLRSTAT; -} - -/** - * \brief Increase all statistics registers. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_increase_statistics(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_INCSTAT; -} - -/** - * \brief Enable/Disable statistics registers writing. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable the statistics registers writing, else to enable it. - */ -static inline void gmac_enable_statistics_write(Gmac* p_gmac, - uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCR |= GMAC_NCR_WESTAT; - } else { - p_gmac->GMAC_NCR &= ~GMAC_NCR_WESTAT; - } -} - -/** - * \brief In half-duplex mode, forces collisions on all received frames. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable the back pressure, else to enable it. - */ -static inline void gmac_enable_back_pressure(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCR |= GMAC_NCR_BP; - } else { - p_gmac->GMAC_NCR &= ~GMAC_NCR_BP; - } -} - -/** - * \brief Start transmission. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_start_transmission(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_TSTART; -} - -/** - * \brief Halt transmission. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_halt_transmission(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_THALT; -} - -/** - * \brief Transmit pause frame. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_tx_pause_frame(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_TXPF; -} - -/** - * \brief Transmit zero quantum pause frame. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_tx_pause_zero_quantum_frame(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_TXZQPF; -} - -/** - * \brief Read snapshot. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_read_snapshot(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_RDS; -} - -/** - * \brief Store receivetime stamp to memory. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to normal operation, else to enable the store. - */ -static inline void gmac_store_rx_time_stamp(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCR |= GMAC_NCR_SRTSM; - } else { - p_gmac->GMAC_NCR &= ~GMAC_NCR_SRTSM; - } -} - -/** - * \brief Enable PFC priority-based pause reception. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 1 to set the reception, 0 to disable. - */ -static inline void gmac_enable_pfc_pause_frame(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCR |= GMAC_NCR_ENPBPR; - } else { - p_gmac->GMAC_NCR &= ~GMAC_NCR_ENPBPR; - } -} - -/** - * \brief Transmit PFC priority-based pause reception. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_transmit_pfc_pause_frame(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_TXPBPF; -} - -/** - * \brief Flush next packet. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_flush_next_packet(Gmac* p_gmac) -{ - p_gmac->GMAC_NCR |= GMAC_NCR_FNP; -} - -/** - * \brief Set up network configuration register. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_cfg Network configuration value. - */ -static inline void gmac_set_configure(Gmac* p_gmac, uint32_t ul_cfg) -{ - p_gmac->GMAC_NCFGR = ul_cfg; -} - -/** - * \brief Get network configuration. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Network configuration. - */ -static inline uint32_t gmac_get_configure(Gmac* p_gmac) -{ - return p_gmac->GMAC_NCFGR; -} - - -/* Get and set DMA Configuration Register */ -static inline void gmac_set_dma(Gmac* p_gmac, uint32_t ul_cfg) -{ - p_gmac->GMAC_DCFGR = ul_cfg; -} - -static inline uint32_t gmac_get_dma(Gmac* p_gmac) -{ - return p_gmac->GMAC_DCFGR; -} - -/** - * \brief Set speed. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_speed 1 to indicate 100Mbps, 0 to 10Mbps. - */ -static inline void gmac_set_speed(Gmac* p_gmac, uint8_t uc_speed) -{ - if (uc_speed) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_SPD; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_SPD; - } -} - -/** - * \brief Enable/Disable Full-Duplex mode. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable the Full-Duplex mode, else to enable it. - */ -static inline void gmac_enable_full_duplex(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_FD; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_FD; - } -} - -/** - * \brief Enable/Disable Copy(Receive) All Valid Frames. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable copying all valid frames, else to enable it. - */ -static inline void gmac_enable_copy_all(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_CAF; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_CAF; - } -} - -/** - * \brief Enable/Disable jumbo frames (up to 10240 bytes). - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable the jumbo frames, else to enable it. - */ -static inline void gmac_enable_jumbo_frames(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_JFRAME; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_JFRAME; - } -} - -/** - * \brief Disable/Enable broadcast receiving. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 1 to disable the broadcast, else to enable it. - */ -static inline void gmac_disable_broadcast(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_NBC; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_NBC; - } -} - -/** - * \brief Enable/Disable multicast hash. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable the multicast hash, else to enable it. - */ -static inline void gmac_enable_multicast_hash(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_UNIHEN; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_UNIHEN; - } -} - -/** - * \brief Enable/Disable big frames (over 1518, up to 1536). - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable big frames else to enable it. - */ -static inline void gmac_enable_big_frame(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_MAXFS; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_MAXFS; - } -} - -/** - * \brief Set MDC clock divider. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_mck GMAC MCK. - * - * \return GMAC_OK if successfully. - */ -static inline uint8_t gmac_set_mdc_clock(Gmac* p_gmac, uint32_t ul_mck) -{ - uint32_t ul_clk; - - if (ul_mck > GMAC_MCK_SPEED_240MHZ) { - return GMAC_INVALID; - } else if (ul_mck > GMAC_MCK_SPEED_160MHZ) { - ul_clk = GMAC_NCFGR_CLK_MCK_96; - } else if (ul_mck > GMAC_MCK_SPEED_120MHZ) { - ul_clk = GMAC_NCFGR_CLK_MCK_64; - } else if (ul_mck > GMAC_MCK_SPEED_80MHZ) { - ul_clk = GMAC_NCFGR_CLK_MCK_48; - } else if (ul_mck > GMAC_MCK_SPEED_40MHZ) { - ul_clk = GMAC_NCFGR_CLK_MCK_32; - } else if (ul_mck > GMAC_MCK_SPEED_20MHZ) { - ul_clk = GMAC_NCFGR_CLK_MCK_16; - } else { - ul_clk = GMAC_NCFGR_CLK_MCK_8; - } - ; - p_gmac->GMAC_NCFGR = (p_gmac->GMAC_NCFGR & ~GMAC_NCFGR_CLK_Msk) | ul_clk; - return GMAC_OK; -} - -/** - * \brief Enable/Disable retry test. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable the GMAC receiver, else to enable it. - */ -static inline void gmac_enable_retry_test(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_RTY; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_RTY; - } -} - -/** - * \brief Enable/Disable pause (when a valid pause frame is received). - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable pause frame, else to enable it. - */ -static inline void gmac_enable_pause_frame(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_PEN; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_PEN; - } -} - -/** - * \brief Set receive buffer offset to 0 ~ 3. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline void gmac_set_rx_buffer_offset(Gmac* p_gmac, uint8_t uc_offset) -{ - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_RXBUFO_Msk; - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_RXBUFO(uc_offset); -} - -/** - * \brief Enable/Disable receive length field checking. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable receive length field checking, else to enable it. - */ -static inline void gmac_enable_rx_length_check(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_LFERD; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_LFERD; - } -} - -/** - * \brief Enable/Disable discarding FCS field of received frames. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable discarding FCS field of received frames, else to enable it. - */ -static inline void gmac_enable_discard_fcs(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_RFCS; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_RFCS; - } -} - - -/** - * \brief Enable/Disable frames to be received in half-duplex mode - * while transmitting. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable the received in half-duplex mode, else to enable it. - */ -static inline void gmac_enable_efrhd(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_EFRHD; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_EFRHD; - } -} - -/** - * \brief Enable/Disable ignore RX FCS. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_enable 0 to disable ignore RX FCS, else to enable it. - */ -static inline void gmac_enable_ignore_rx_fcs(Gmac* p_gmac, uint8_t uc_enable) -{ - if (uc_enable) { - p_gmac->GMAC_NCFGR |= GMAC_NCFGR_IRXFCS; - } else { - p_gmac->GMAC_NCFGR &= ~GMAC_NCFGR_IRXFCS; - } -} - -/** - * \brief Get Network Status. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Network status. - */ -static inline uint32_t gmac_get_status(Gmac* p_gmac) -{ - return p_gmac->GMAC_NSR; -} - -/** - * \brief Get MDIO IN pin status. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return MDIO IN pin status. - */ -static inline uint8_t gmac_get_MDIO(Gmac* p_gmac) -{ - return ((p_gmac->GMAC_NSR & GMAC_NSR_MDIO) > 0); -} - -/** - * \brief Check if PHY is idle. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return 1 if PHY is idle. - */ -static inline uint8_t gmac_is_phy_idle(Gmac* p_gmac) -{ - return ((p_gmac->GMAC_NSR & GMAC_NSR_IDLE) > 0); -} - -/** - * \brief Return transmit status. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Transmit status. - */ -static inline uint32_t gmac_get_tx_status(Gmac* p_gmac) -{ - return p_gmac->GMAC_TSR; -} - -/** - * \brief Clear transmit status. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_status Transmit status. - */ -static inline void gmac_clear_tx_status(Gmac* p_gmac, uint32_t ul_status) -{ - p_gmac->GMAC_TSR = ul_status; -} - -/** - * \brief Return receive status. - * - * \param p_gmac Pointer to the GMAC instance. - */ -static inline uint32_t gmac_get_rx_status(Gmac* p_gmac) -{ - return p_gmac->GMAC_RSR; -} - -/** - * \brief Clear receive status. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_status Receive status. - */ -static inline void gmac_clear_rx_status(Gmac* p_gmac, uint32_t ul_status) -{ - p_gmac->GMAC_RSR = ul_status; -} - -/** - * \brief Set Rx Queue. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_addr Rx queue address. - */ -static inline void gmac_set_rx_queue(Gmac* p_gmac, uint32_t ul_addr) -{ - p_gmac->GMAC_RBQB = GMAC_RBQB_ADDR_Msk & ul_addr; -} - -/** - * \brief Get Rx Queue Address. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Rx queue address. - */ -static inline uint32_t gmac_get_rx_queue(Gmac* p_gmac) -{ - return p_gmac->GMAC_RBQB; -} - -/** - * \brief Set Tx Queue. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_addr Tx queue address. - */ -static inline void gmac_set_tx_queue(Gmac* p_gmac, uint32_t ul_addr) -{ - p_gmac->GMAC_TBQB = GMAC_TBQB_ADDR_Msk & ul_addr; -} - -/** - * \brief Get Tx Queue. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Rx queue address. - */ -static inline uint32_t gmac_get_tx_queue(Gmac* p_gmac) -{ - return p_gmac->GMAC_TBQB; -} - -/** - * \brief Enable interrupt(s). - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_source Interrupt source(s) to be enabled. - */ -static inline void gmac_enable_interrupt(Gmac* p_gmac, uint32_t ul_source) -{ - p_gmac->GMAC_IER = ul_source; -} - -/** - * \brief Disable interrupt(s). - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_source Interrupt source(s) to be disabled. - */ -static inline void gmac_disable_interrupt(Gmac* p_gmac, uint32_t ul_source) -{ - p_gmac->GMAC_IDR = ul_source; -} - -/** - * \brief Return interrupt status. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Interrupt status. - */ -static inline uint32_t gmac_get_interrupt_status(Gmac* p_gmac) -{ - return p_gmac->GMAC_ISR; -} - -/** - * \brief Return interrupt mask. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Interrupt mask. - */ -static inline uint32_t gmac_get_interrupt_mask(Gmac* p_gmac) -{ - return p_gmac->GMAC_IMR; -} - -/** - * \brief Execute PHY maintenance command. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_phy_addr PHY address. - * \param uc_reg_addr Register address. - * \param uc_rw 1 to Read, 0 to write. - * \param us_data Data to be performed, write only. - */ -static inline void gmac_maintain_phy(Gmac* p_gmac, - uint8_t uc_phy_addr, uint8_t uc_reg_addr, uint8_t uc_rw, - uint16_t us_data) -{ - /* Wait until bus idle */ - while ((p_gmac->GMAC_NSR & GMAC_NSR_IDLE) == 0); - /* Write maintain register */ - p_gmac->GMAC_MAN = GMAC_MAN_WTN(GMAC_MAN_CODE_VALUE) - | GMAC_MAN_CLTTO - | GMAC_MAN_PHYA(uc_phy_addr) - | GMAC_MAN_REGA(uc_reg_addr) - | GMAC_MAN_OP((uc_rw ? GMAC_MAN_RW_TYPE : GMAC_MAN_READ_ONLY)) - | GMAC_MAN_DATA(us_data); -} - -/** - * \brief Get PHY maintenance data returned. - * - * \param p_gmac Pointer to the GMAC instance. - * - * \return Get PHY data. - */ -static inline uint16_t gmac_get_phy_data(Gmac* p_gmac) -{ - /* Wait until bus idle */ - while ((p_gmac->GMAC_NSR & GMAC_NSR_IDLE) == 0); - /* Return data */ - return (uint16_t) (p_gmac->GMAC_MAN & GMAC_MAN_DATA_Msk); -} - -/** - * \brief Set Hash. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ul_hash_top Hash top. - * \param ul_hash_bottom Hash bottom. - */ -static inline void gmac_set_hash(Gmac* p_gmac, uint32_t ul_hash_top, - uint32_t ul_hash_bottom) -{ - p_gmac->GMAC_HRB = ul_hash_bottom; - p_gmac->GMAC_HRT = ul_hash_top; -} - -/** - * \brief Set 64 bits Hash. - * - * \param p_gmac Pointer to the GMAC instance. - * \param ull_hash 64 bits hash value. - */ -static inline void gmac_set_hash64(Gmac* p_gmac, uint64_t ull_hash) -{ - p_gmac->GMAC_HRB = (uint32_t) ull_hash; - p_gmac->GMAC_HRT = (uint32_t) (ull_hash >> 32); -} - -/** - * \brief Set MAC Address. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_index GMAC specific address register index. - * \param p_mac_addr GMAC address. - */ -static inline void gmac_set_address(Gmac* p_gmac, uint8_t uc_index, - uint8_t* p_mac_addr) -{ - p_gmac->GMAC_SA[uc_index].GMAC_SAB = (p_mac_addr[3] << 24) - | (p_mac_addr[2] << 16) - | (p_mac_addr[1] << 8) - | (p_mac_addr[0]); - p_gmac->GMAC_SA[uc_index].GMAC_SAT = (p_mac_addr[5] << 8) - | (p_mac_addr[4]); -} - -/** - * \brief Set MAC Address via 2 dword. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_index GMAC specific address register index. - * \param ul_mac_top GMAC top address. - * \param ul_mac_bottom GMAC bottom address. - */ -static inline void gmac_set_address32(Gmac* p_gmac, uint8_t uc_index, - uint32_t ul_mac_top, uint32_t ul_mac_bottom) -{ - p_gmac->GMAC_SA[uc_index].GMAC_SAB = ul_mac_bottom; - p_gmac->GMAC_SA[uc_index].GMAC_SAT = ul_mac_top; -} - -/** - * \brief Set MAC Address via int64. - * - * \param p_gmac Pointer to the GMAC instance. - * \param uc_index GMAC specific address register index. - * \param ull_mac 64-bit GMAC address. - */ -static inline void gmac_set_address64(Gmac* p_gmac, uint8_t uc_index, - uint64_t ull_mac) -{ - p_gmac->GMAC_SA[uc_index].GMAC_SAB = (uint32_t) ull_mac; - p_gmac->GMAC_SA[uc_index].GMAC_SAT = (uint32_t) (ull_mac >> 32); -} - -/** - * \brief Select media independent interface mode. - * - * \param p_gmac Pointer to the GMAC instance. - * \param mode Media independent interface mode. - */ -static inline void gmac_select_mii_mode(Gmac* p_gmac, gmac_mii_mode_t mode) -{ - switch (mode) { - case GMAC_PHY_MII: - case GMAC_PHY_RMII: - p_gmac->GMAC_UR |= GMAC_UR_RMIIMII; - break; - - default: - p_gmac->GMAC_UR &= ~GMAC_UR_RMIIMII; - break; - } -} - -uint8_t gmac_phy_read(Gmac* p_gmac, uint8_t uc_phy_address, uint8_t uc_address, - uint32_t* p_value); -uint8_t gmac_phy_write(Gmac* p_gmac, uint8_t uc_phy_address, - uint8_t uc_address, uint32_t ul_value); -void gmac_dev_init(Gmac* p_gmac, gmac_device_t* p_gmac_dev, - gmac_options_t* p_opt); -uint32_t gmac_dev_read(gmac_device_t* p_gmac_dev, uint8_t* p_frame, - uint32_t ul_frame_size, uint32_t* p_rcv_size); -uint32_t gmac_dev_write(gmac_device_t* p_gmac_dev, void *p_buffer, - uint32_t ul_size, gmac_dev_tx_cb_t func_tx_cb); -uint32_t gmac_dev_get_tx_load(gmac_device_t* p_gmac_dev); -void gmac_dev_set_rx_callback(gmac_device_t* p_gmac_dev, - gmac_dev_rx_cb_t func_rx_cb); -uint8_t gmac_dev_set_tx_wakeup_callback(gmac_device_t* p_gmac_dev, - gmac_dev_wakeup_cb_t func_wakeup, uint8_t uc_threshold); -void gmac_dev_reset(gmac_device_t* p_gmac_dev); -void gmac_handler(gmac_device_t* p_gmac_dev); - -/// @cond 0 -/**INDENT-OFF**/ -#ifdef __cplusplus -} -#endif -/**INDENT-ON**/ -/// @endcond - -/** - * \page gmac_quickstart Quickstart guide for GMAC driver. - * - * This is the quickstart guide for the \ref gmac_group "Ethernet MAC", - * with step-by-step instructions on how to configure and use the driver in a - * selection of use cases. - * - * The use cases contain several code fragments. The code fragments in the - * steps for setup can be copied into a custom initialization function, while - * the steps for usage can be copied into, e.g., the main application function. - * - * \section gmac_basic_use_case Basic use case - * In the basic use case, the GMAC driver are configured for: - * - PHY component KSZ8051MNL is used - * - GMAC uses MII mode - * - The number of receive buffer is 16 - * - The number of transfer buffer is 8 - * - MAC address is set to 00-04-25-1c-a0-02 - * - IP address is set to 192.168.0.2 - * - IP address is set to 192.168.0.2 - * - Gateway is set to 192.168.0.1 - * - Network mask is 255.255.255.0 - * - PHY operation max retry count is 1000000 - * - GMAC is configured to not support copy all frame and support broadcast - * - The data will be read from the ethernet - * - * \section gmac_basic_use_case_setup Setup steps - * - * \subsection gmac_basic_use_case_setup_prereq Prerequisites - * -# \ref sysclk_group "System Clock Management (sysclock)" - * -# \ref pmc_group "Power Management Controller (pmc)" - * -# \ref ksz8051mnl_ethernet_phy_group "PHY component (KSZ8051MNL)" - * - * \subsection gmac_basic_use_case_setup_code Example code - * Content of conf_eth.h - * \code - * #define GMAC_RX_BUFFERS 16 - * #define GMAC_TX_BUFFERS 8 - * #define MAC_PHY_RETRY_MAX 1000000 - * #define ETHERNET_CONF_ETHADDR0 0x00 - * #define ETHERNET_CONF_ETHADDR0 0x00 - * #define ETHERNET_CONF_ETHADDR1 0x04 - * #define ETHERNET_CONF_ETHADDR2 0x25 - * #define ETHERNET_CONF_ETHADDR3 0x1C - * #define ETHERNET_CONF_ETHADDR4 0xA0 - * #define ETHERNET_CONF_ETHADDR5 0x02 - * #define ETHERNET_CONF_IPADDR0 192 - * #define ETHERNET_CONF_IPADDR1 168 - * #define ETHERNET_CONF_IPADDR2 0 - * #define ETHERNET_CONF_IPADDR3 2 - * #define ETHERNET_CONF_GATEWAY_ADDR0 192 - * #define ETHERNET_CONF_GATEWAY_ADDR1 168 - * #define ETHERNET_CONF_GATEWAY_ADDR2 0 - * #define ETHERNET_CONF_GATEWAY_ADDR3 1 - * #define ETHERNET_CONF_NET_MASK0 255 - * #define ETHERNET_CONF_NET_MASK1 255 - * #define ETHERNET_CONF_NET_MASK2 255 - * #define ETHERNET_CONF_NET_MASK3 0 - * #define ETH_PHY_MODE ETH_PHY_MODE - * \endcode - * - * A specific gmac device and the receive data buffer must be defined; another ul_frm_size should be defined - * to trace the actual size of the data received. - * \code - * static gmac_device_t gs_gmac_dev; - * static volatile uint8_t gs_uc_eth_buffer[GMAC_FRAME_LENTGH_MAX]; - * - * uint32_t ul_frm_size; - * \endcode - * - * Add to application C-file: - * \code - * void gmac_init(void) - * { - * sysclk_init(); - * - * board_init(); - * - * pmc_enable_periph_clk(ID_GMAC); - * - * gmac_option.uc_copy_all_frame = 0; - * gmac_option.uc_no_boardcast = 0; - * memcpy(gmac_option.uc_mac_addr, gs_uc_mac_address, sizeof(gs_uc_mac_address)); - * gs_gmac_dev.p_hw = GMAC; - * - * gmac_dev_init(GMAC, &gs_gmac_dev, &gmac_option); - * - * NVIC_EnableIRQ(GMAC_IRQn); - * - * ethernet_phy_init(GMAC, BOARD_GMAC_PHY_ADDR, sysclk_get_cpu_hz()); - * - * ethernet_phy_auto_negotiate(GMAC, BOARD_GMAC_PHY_ADDR); - * - * ethernet_phy_set_link(GMAC, BOARD_GMAC_PHY_ADDR, 1); - * \endcode - * - * \subsection gmac_basic_use_case_setup_flow Workflow - * - Ensure that conf_eth.h is present and contains the - * following configuration symbol. This configuration file is used - * by the driver and should not be included by the application. - * -# Define the receiving buffer size used in the internal GMAC driver. - * The buffer size used for RX is GMAC_RX_BUFFERS * 128. - * If it was supposed receiving a large number of frame, the - * GMAC_RX_BUFFERS should be set higher. E.g., the application wants to accept - * a ping echo test of 2048, the GMAC_RX_BUFFERS should be set at least - * (2048/128)=16, and as there are additional frames coming, a preferred - * number is 24 depending on a normal Ethernet throughput. - * - \code - * #define GMAC_RX_BUFFERS 16 - * \endcode - * -# Define the transmitting buffer size used in the internal GMAC driver. - * The buffer size used for TX is GMAC_TX_BUFFERS * 1518. - * - \code - * #define GMAC_TX_BUFFERS 8 - * \endcode - * -# Define maximum retry time for a PHY read/write operation. - * - \code - * #define MAC_PHY_RETRY_MAX 1000000 - * \endcode - * -# Define the MAC address. 00:04:25:1C:A0:02 is the address reserved - * for ATMEL, application should always change this address to its' own. - * - \code - * #define ETHERNET_CONF_ETHADDR0 0x00 - * #define ETHERNET_CONF_ETHADDR1 0x04 - * #define ETHERNET_CONF_ETHADDR2 0x25 - * #define ETHERNET_CONF_ETHADDR3 0x1C - * #define ETHERNET_CONF_ETHADDR4 0xA0 - * #define ETHERNET_CONF_ETHADDR5 0x02 - * \endcode - * -# Define the IP address configration used in the application. When DHCP - * is enabled, this configuration is not effected. - * - \code - * #define ETHERNET_CONF_IPADDR0 192 - * #define ETHERNET_CONF_IPADDR1 168 - * #define ETHERNET_CONF_IPADDR2 0 - * #define ETHERNET_CONF_IPADDR3 2 - * #define ETHERNET_CONF_GATEWAY_ADDR0 192 - * #define ETHERNET_CONF_GATEWAY_ADDR1 168 - * #define ETHERNET_CONF_GATEWAY_ADDR2 0 - * #define ETHERNET_CONF_GATEWAY_ADDR3 1 - * #define ETHERNET_CONF_NET_MASK0 255 - * #define ETHERNET_CONF_NET_MASK1 255 - * #define ETHERNET_CONF_NET_MASK2 255 - * #define ETHERNET_CONF_NET_MASK3 0 - * \endcode - * -# Configure the PHY maintainance interface. - * - \code - * #define ETH_PHY_MODE GMAC_PHY_MII - * \endcode - * -# Enable the system clock: - * - \code sysclk_init(); \endcode - * -# Enable PIO configurations for GMAC: - * - \code board_init(); \endcode - * -# Enable PMC clock for GMAC: - * - \code pmc_enable_periph_clk(ID_GMAC); \endcode - * -# Set the GMAC options; it's set to copy all frame and support broadcast: - * - \code - * gmac_option.uc_copy_all_frame = 0; - * gmac_option.uc_no_boardcast = 0; - * memcpy(gmac_option.uc_mac_addr, gs_uc_mac_address, sizeof(gs_uc_mac_address)); - * gs_gmac_dev.p_hw = GMAC; - * \endcode - * -# Initialize GMAC device with the filled option: - * - \code - * gmac_dev_init(GMAC, &gs_gmac_dev, &gmac_option); - * \endcode - * -# Enable the interrupt service for GMAC: - * - \code - * NVIC_EnableIRQ(GMAC_IRQn); - * \endcode - * -# Initialize the PHY component: - * - \code - * ethernet_phy_init(GMAC, BOARD_GMAC_PHY_ADDR, sysclk_get_cpu_hz()); - * \endcode - * -# The link will be established based on auto negotiation. - * - \code - * ethernet_phy_auto_negotiate(GMAC, BOARD_GMAC_PHY_ADDR); - * \endcode - * -# Establish the ethernet link; the network can be worked from now on: - * - \code - * ethernet_phy_set_link(GMAC, BOARD_GMAC_PHY_ADDR, 1); - * \endcode - * - * \section gmac_basic_use_case_usage Usage steps - * \subsection gmac_basic_use_case_usage_code Example code - * Add to, e.g., main loop in application C-file: - * \code - * gmac_dev_read(&gs_gmac_dev, (uint8_t *) gs_uc_eth_buffer, sizeof(gs_uc_eth_buffer), &ul_frm_size)); - * \endcode - * - * \subsection gmac_basic_use_case_usage_flow Workflow - * -# Start reading the data from the ethernet: - * - \code gmac_dev_read(&gs_gmac_dev, (uint8_t *) gs_uc_eth_buffer, sizeof(gs_uc_eth_buffer), &ul_frm_size)); \endcode - */ - -# define GMAC_STATS 0 - -#if( GMAC_STATS != 0 ) - - /* Here below some code to study the types and - frequencies of GMAC interrupts. */ - #define GMAC_IDX_RXUBR 0 - #define GMAC_IDX_TUR 1 - #define GMAC_IDX_RLEX 2 - #define GMAC_IDX_TFC 3 - #define GMAC_IDX_RCOMP 4 - #define GMAC_IDX_TCOMP 5 - #define GMAC_IDX_ROVR 6 - #define GMAC_IDX_HRESP 7 - #define GMAC_IDX_PFNZ 8 - #define GMAC_IDX_PTZ 9 - - struct SGmacStats { - unsigned recvCount; - unsigned rovrCount; - unsigned bnaCount; - unsigned sendCount; - unsigned sovrCount; - unsigned incompCount; - unsigned truncCount; - - unsigned intStatus[10]; - }; - extern struct SGmacStats gmacStats; - - struct SIntPair { - const char *name; - unsigned mask; - int index; - }; - - #define MK_PAIR( NAME ) #NAME, GMAC_IER_##NAME, GMAC_IDX_##NAME - static const struct SIntPair intPairs[] = { - { MK_PAIR( RXUBR ) }, /* Enable receive used bit read interrupt. */ - { MK_PAIR( TUR ) }, /* Enable transmit underrun interrupt. */ - { MK_PAIR( RLEX ) }, /* Enable retry limit exceeded interrupt. */ - { MK_PAIR( TFC ) }, /* Enable transmit buffers exhausted in mid-frame interrupt. */ - { MK_PAIR( RCOMP ) }, /* Receive complete */ - { MK_PAIR( TCOMP ) }, /* Enable transmit complete interrupt. */ - { MK_PAIR( ROVR ) }, /* Enable receive overrun interrupt. */ - { MK_PAIR( HRESP ) }, /* Enable Hresp not OK interrupt. */ - { MK_PAIR( PFNZ ) }, /* Enable pause frame received interrupt. */ - { MK_PAIR( PTZ ) } /* Enable pause time zero interrupt. */ - }; - - void gmac_show_irq_counts (); - -#endif - -#endif /* GMAC_H_INCLUDED */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Common/phyHandling.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Common/phyHandling.c deleted file mode 100755 index 62b3a95..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Common/phyHandling.c +++ /dev/null @@ -1,664 +0,0 @@ -/* - * Handling of Ethernet PHY's - * PHY's communicate with an EMAC either through - * a Media-Independent Interface (MII), or a Reduced Media-Independent Interface (RMII). - * The EMAC can poll for PHY ports on 32 different addresses. Each of the PHY ports - * shall be treated independently. - * - */ - -/* Standard includes. */ -#include -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" - -#include "phyHandling.h" - -#include "eventLogging.h" - -#define phyMIN_PHY_ADDRESS 0 -#define phyMAX_PHY_ADDRESS 31 - -#if defined( PHY_LS_HIGH_CHECK_TIME_MS ) || defined( PHY_LS_LOW_CHECK_TIME_MS ) - #warning please use the new defines with 'ipconfig' prefix -#endif - -#ifndef ipconfigPHY_LS_HIGH_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still high after 15 seconds of not - receiving packets. */ - #define ipconfigPHY_LS_HIGH_CHECK_TIME_MS 15000 -#endif - -#ifndef ipconfigPHY_LS_LOW_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still low every second. */ - #define ipconfigPHY_LS_LOW_CHECK_TIME_MS 1000 -#endif - -/* Naming and numbering of basic PHY registers. */ -#define phyREG_00_BMCR 0x00u /* Basic Mode Control Register. */ -#define phyREG_01_BMSR 0x01u /* Basic Mode Status Register. */ -#define phyREG_02_PHYSID1 0x02u /* PHYS ID 1 */ -#define phyREG_03_PHYSID2 0x03u /* PHYS ID 2 */ -#define phyREG_04_ADVERTISE 0x04u /* Advertisement control reg */ - -/* Naming and numbering of extended PHY registers. */ -#define PHYREG_10_PHYSTS 0x10u /* 16 PHY status register Offset */ -#define phyREG_19_PHYCR 0x19u /* 25 RW PHY Control Register */ -#define phyREG_1F_PHYSPCS 0x1Fu /* 31 RW PHY Special Control Status */ - -/* Bit fields for 'phyREG_00_BMCR', the 'Basic Mode Control Register'. */ -#define phyBMCR_FULL_DUPLEX 0x0100u /* Full duplex. */ -#define phyBMCR_AN_RESTART 0x0200u /* Auto negotiation restart. */ -#define phyBMCR_AN_ENABLE 0x1000u /* Enable auto negotiation. */ -#define phyBMCR_SPEED_100 0x2000u /* Select 100Mbps. */ -#define phyBMCR_RESET 0x8000u /* Reset the PHY. */ - -/* Bit fields for 'phyREG_19_PHYCR', the 'PHY Control Register'. */ -#define PHYCR_MDIX_EN 0x8000u /* Enable Auto MDIX. */ -#define PHYCR_MDIX_FORCE 0x4000u /* Force MDIX crossed. */ - -#define phyBMSR_AN_COMPLETE 0x0020u /* Auto-Negotiation process completed */ - -#define phyBMSR_LINK_STATUS 0x0004u - -#define phyPHYSTS_LINK_STATUS 0x0001u /* PHY Link mask */ -#define phyPHYSTS_SPEED_STATUS 0x0002u /* PHY Speed mask */ -#define phyPHYSTS_DUPLEX_STATUS 0x0004u /* PHY Duplex mask */ - -/* Bit fields for 'phyREG_1F_PHYSPCS - 001 = 10BASE-T half-duplex - 101 = 10BASE-T full-duplex - 010 = 100BASE-TX half-duplex - 110 = 100BASE-TX full-duplex -*/ -#define phyPHYSPCS_SPEED_MASK 0x000Cu -#define phyPHYSPCS_SPEED_10 0x0004u -#define phyPHYSPCS_FULL_DUPLEX 0x0010u - -/* - * Description of all capabilities that can be advertised to - * the peer (usually a switch or router). - */ -#define phyADVERTISE_CSMA 0x0001u /* Only selector supported. */ -#define phyADVERTISE_10HALF 0x0020u /* Try for 10mbps half-duplex. */ -#define phyADVERTISE_10FULL 0x0040u /* Try for 10mbps full-duplex. */ -#define phyADVERTISE_100HALF 0x0080u /* Try for 100mbps half-duplex. */ -#define phyADVERTISE_100FULL 0x0100u /* Try for 100mbps full-duplex. */ - -#define phyADVERTISE_ALL ( phyADVERTISE_10HALF | phyADVERTISE_10FULL | \ - phyADVERTISE_100HALF | phyADVERTISE_100FULL ) - -/* Send a reset commando to a set of PHY-ports. */ -static uint32_t xPhyReset( EthernetPhy_t *pxPhyObject, uint32_t ulPhyMask ); - -static BaseType_t xHas_1F_PHYSPCS( uint32_t ulPhyID ) -{ -BaseType_t xResult; - - switch( ulPhyID ) - { - case PHY_ID_LAN8720: - case PHY_ID_LAN8742A: - case PHY_ID_KSZ8041: -/* - case PHY_ID_KSZ8051: // same ID as 8041 - case PHY_ID_KSZ8081: // same ID as 8041 -*/ - case PHY_ID_KSZ8863: - default: - /* Most PHY's have a 1F_PHYSPCS */ - xResult = pdTRUE; - break; - case PHY_ID_DP83848I: - xResult = pdFALSE; - break; - } - return xResult; -} -/*-----------------------------------------------------------*/ - -static BaseType_t xHas_19_PHYCR( uint32_t ulPhyID ) -{ -BaseType_t xResult; - - switch( ulPhyID ) - { - case PHY_ID_LAN8742A: - case PHY_ID_DP83848I: - xResult = pdTRUE; - break; - default: - /* Most PHY's do not have a 19_PHYCR */ - xResult = pdFALSE; - break; - } - return xResult; -} -/*-----------------------------------------------------------*/ - -/* Initialise the struct and assign a PHY-read and -write function. */ -void vPhyInitialise( EthernetPhy_t *pxPhyObject, xApplicationPhyReadHook_t fnPhyRead, xApplicationPhyWriteHook_t fnPhyWrite ) -{ - memset( ( void * )pxPhyObject, '\0', sizeof( *pxPhyObject ) ); - - pxPhyObject->fnPhyRead = fnPhyRead; - pxPhyObject->fnPhyWrite = fnPhyWrite; -} -/*-----------------------------------------------------------*/ - -/* Discover all PHY's connected by polling 32 indexes ( zero-based ) */ -BaseType_t xPhyDiscover( EthernetPhy_t *pxPhyObject ) -{ -BaseType_t xPhyAddress; - - pxPhyObject->xPortCount = 0; - - for( xPhyAddress = phyMIN_PHY_ADDRESS; xPhyAddress <= phyMAX_PHY_ADDRESS; xPhyAddress++ ) - { - uint32_t ulLowerID; - - pxPhyObject->fnPhyRead( xPhyAddress, phyREG_03_PHYSID2, &ulLowerID ); - /* A valid PHY id can not be all zeros or all ones. */ - if( ( ulLowerID != ( uint16_t )~0u ) && ( ulLowerID != ( uint16_t )0u ) ) - { - uint32_t ulUpperID; - uint32_t ulPhyID; - - pxPhyObject->fnPhyRead( xPhyAddress, phyREG_02_PHYSID1, &ulUpperID ); - ulPhyID = ( ( ( uint32_t ) ulUpperID ) << 16 ) | ( ulLowerID & 0xFFF0 ); - - pxPhyObject->ucPhyIndexes[ pxPhyObject->xPortCount ] = xPhyAddress; - pxPhyObject->ulPhyIDs[ pxPhyObject->xPortCount ] = ulPhyID; - - pxPhyObject->xPortCount++; - - /* See if there is more storage space. */ - if( pxPhyObject->xPortCount == ipconfigPHY_MAX_PORTS ) - { - break; - } - } - } - if( pxPhyObject->xPortCount > 0 ) - { - FreeRTOS_printf( ( "PHY ID %lX\n", pxPhyObject->ulPhyIDs[ 0 ] ) ); - eventLogAdd( "PHY ID 0x%lX", pxPhyObject->ulPhyIDs[ 0 ] ); - } - - return pxPhyObject->xPortCount; -} -/*-----------------------------------------------------------*/ - -/* Send a reset commando to a set of PHY-ports. */ -static uint32_t xPhyReset( EthernetPhy_t *pxPhyObject, uint32_t ulPhyMask ) -{ -uint32_t ulDoneMask, ulConfig; -TickType_t xRemainingTime; -TimeOut_t xTimer; -BaseType_t xPhyIndex; - - /* A bit-mask ofPHY ports that are ready. */ - ulDoneMask = 0ul; - - /* Set the RESET bits high. */ - for( xPhyIndex = 0; xPhyIndex < pxPhyObject->xPortCount; xPhyIndex++ ) - { - BaseType_t xPhyAddress = pxPhyObject->ucPhyIndexes[ xPhyIndex ]; - - /* Read Control register. */ - pxPhyObject->fnPhyRead( xPhyAddress, phyREG_00_BMCR, &ulConfig ); - pxPhyObject->fnPhyWrite( xPhyAddress, phyREG_00_BMCR, ulConfig | phyBMCR_RESET ); - } - - xRemainingTime = ( TickType_t ) pdMS_TO_TICKS( 1000UL ); - vTaskSetTimeOutState( &xTimer ); - - /* The reset should last less than a second. */ - for( ;; ) - { - for( xPhyIndex = 0; xPhyIndex < pxPhyObject->xPortCount; xPhyIndex++ ) - { - BaseType_t xPhyAddress = pxPhyObject->ucPhyIndexes[ xPhyIndex ]; - - pxPhyObject->fnPhyRead( xPhyAddress, phyREG_00_BMCR, &ulConfig ); - if( ( ulConfig & phyBMCR_RESET ) == 0 ) - { - FreeRTOS_printf( ( "xPhyReset: phyBMCR_RESET %d ready\n", (int)xPhyIndex ) ); - ulDoneMask |= ( 1ul << xPhyIndex ); - } - } - if( ulDoneMask == ulPhyMask ) - { - break; - } - if( xTaskCheckForTimeOut( &xTimer, &xRemainingTime ) != pdFALSE ) - { - FreeRTOS_printf( ( "xPhyReset: phyBMCR_RESET timed out ( done 0x%02lX )\n", ulDoneMask ) ); - break; - } - } - - /* Clear the reset bits. */ - for( xPhyIndex = 0; xPhyIndex < pxPhyObject->xPortCount; xPhyIndex++ ) - { - BaseType_t xPhyAddress = pxPhyObject->ucPhyIndexes[ xPhyIndex ]; - - pxPhyObject->fnPhyRead( xPhyAddress, phyREG_00_BMCR, &ulConfig ); - pxPhyObject->fnPhyWrite( xPhyAddress, phyREG_00_BMCR, ulConfig & ~phyBMCR_RESET ); - } - - vTaskDelay( pdMS_TO_TICKS( 50ul ) ); - eventLogAdd( "PHY reset %d ports", (int)pxPhyObject->xPortCount ); - return ulDoneMask; -} -/*-----------------------------------------------------------*/ - -BaseType_t xPhyConfigure( EthernetPhy_t *pxPhyObject, const PhyProperties_t *pxPhyProperties ) -{ -uint32_t ulConfig, ulAdvertise; -BaseType_t xPhyIndex; - - if( pxPhyObject->xPortCount < 1 ) - { - FreeRTOS_printf( ( "xPhyResetAll: No PHY's detected.\n" ) ); - return -1; - } - - /* The expected ID for the 'LAN8742A' is 0x0007c130. */ - /* The expected ID for the 'LAN8720' is 0x0007c0f0. */ - /* The expected ID for the 'DP83848I' is 0x20005C90. */ - - /* Set advertise register. */ - if( ( pxPhyProperties->ucSpeed == ( uint8_t )PHY_SPEED_AUTO ) && ( pxPhyProperties->ucDuplex == ( uint8_t )PHY_DUPLEX_AUTO ) ) - { - ulAdvertise = phyADVERTISE_CSMA | phyADVERTISE_ALL; - /* Reset auto-negotiation capability. */ - } - else - { - ulAdvertise = phyADVERTISE_CSMA; - - if( pxPhyProperties->ucSpeed == ( uint8_t )PHY_SPEED_AUTO ) - { - if( pxPhyProperties->ucDuplex == ( uint8_t )PHY_DUPLEX_FULL ) - { - ulAdvertise |= phyADVERTISE_10FULL | phyADVERTISE_100FULL; - } - else - { - ulAdvertise |= phyADVERTISE_10HALF | phyADVERTISE_100HALF; - } - } - else if( pxPhyProperties->ucDuplex == ( uint8_t )PHY_DUPLEX_AUTO ) - { - if( pxPhyProperties->ucSpeed == ( uint8_t )PHY_SPEED_10 ) - { - ulAdvertise |= phyADVERTISE_10FULL | phyADVERTISE_10HALF; - } - else - { - ulAdvertise |= phyADVERTISE_100FULL | phyADVERTISE_100HALF; - } - } - else if( pxPhyProperties->ucSpeed == ( uint8_t )PHY_SPEED_100 ) - { - if( pxPhyProperties->ucDuplex == ( uint8_t )PHY_DUPLEX_FULL ) - { - ulAdvertise |= phyADVERTISE_100FULL; - } - else - { - ulAdvertise |= phyADVERTISE_100HALF; - } - } - else - { - if( pxPhyProperties->ucDuplex == ( uint8_t )PHY_DUPLEX_FULL ) - { - ulAdvertise |= phyADVERTISE_10FULL; - } - else - { - ulAdvertise |= phyADVERTISE_10HALF; - } - } - } - - /* Send a reset commando to a set of PHY-ports. */ - xPhyReset( pxPhyObject, xPhyGetMask( pxPhyObject ) ); - - for( xPhyIndex = 0; xPhyIndex < pxPhyObject->xPortCount; xPhyIndex++ ) - { - BaseType_t xPhyAddress = pxPhyObject->ucPhyIndexes[ xPhyIndex ]; - uint32_t ulPhyID = pxPhyObject->ulPhyIDs[ xPhyIndex ]; - - /* Write advertise register. */ - pxPhyObject->fnPhyWrite( xPhyAddress, phyREG_04_ADVERTISE, ulAdvertise ); - - /* - AN_EN AN1 AN0 Forced Mode - 0 0 0 10BASE-T, Half-Duplex - 0 0 1 10BASE-T, Full-Duplex - 0 1 0 100BASE-TX, Half-Duplex - 0 1 1 100BASE-TX, Full-Duplex - AN_EN AN1 AN0 Advertised Mode - 1 0 0 10BASE-T, Half/Full-Duplex - 1 0 1 100BASE-TX, Half/Full-Duplex - 1 1 0 10BASE-T Half-Duplex - 100BASE-TX, Half-Duplex - 1 1 1 10BASE-T, Half/Full-Duplex - 100BASE-TX, Half/Full-Duplex - */ - - /* Read Control register. */ - pxPhyObject->fnPhyRead( xPhyAddress, phyREG_00_BMCR, &ulConfig ); - - ulConfig &= ~( phyBMCR_SPEED_100 | phyBMCR_FULL_DUPLEX ); - - ulConfig |= phyBMCR_AN_ENABLE; - - if( pxPhyProperties->ucSpeed == ( uint8_t )PHY_SPEED_100 ) - { - ulConfig |= phyBMCR_SPEED_100; - } - else if( pxPhyProperties->ucSpeed == ( uint8_t )PHY_SPEED_10 ) - { - ulConfig &= ~phyBMCR_SPEED_100; - } - - if( pxPhyProperties->ucDuplex == ( uint8_t )PHY_DUPLEX_FULL ) - { - ulConfig |= phyBMCR_FULL_DUPLEX; - } - else if( pxPhyProperties->ucDuplex == ( uint8_t )PHY_DUPLEX_HALF ) - { - ulConfig &= ~phyBMCR_FULL_DUPLEX; - } - - if( xHas_19_PHYCR( ulPhyID ) ) - { - uint32_t ulPhyControl; - /* Read PHY Control register. */ - pxPhyObject->fnPhyRead( xPhyAddress, phyREG_19_PHYCR, &ulPhyControl ); - - /* Clear bits which might get set: */ - ulPhyControl &= ~( PHYCR_MDIX_EN|PHYCR_MDIX_FORCE ); - - if( pxPhyProperties->ucMDI_X == PHY_MDIX_AUTO ) - { - ulPhyControl |= PHYCR_MDIX_EN; - } - else if( pxPhyProperties->ucMDI_X == PHY_MDIX_CROSSED ) - { - /* Force direct link = Use crossed RJ45 cable. */ - ulPhyControl &= ~PHYCR_MDIX_FORCE; - } - else - { - /* Force crossed link = Use direct RJ45 cable. */ - ulPhyControl |= PHYCR_MDIX_FORCE; - } - /* update PHY Control Register. */ - pxPhyObject->fnPhyWrite( xPhyAddress, phyREG_19_PHYCR, ulPhyControl ); - } - - FreeRTOS_printf( ( "+TCP: advertise: %04lX config %04lX\n", ulAdvertise, ulConfig ) ); - eventLogAdd( "adv: %04lX config %04lX", ulAdvertise, ulConfig ); - } - - /* Keep these values for later use. */ - pxPhyObject->ulBCRValue = ulConfig; - pxPhyObject->ulACRValue = ulAdvertise; - - return 0; -} -/*-----------------------------------------------------------*/ - -BaseType_t xPhyFixedValue( EthernetPhy_t *pxPhyObject, uint32_t ulPhyMask ) -{ -BaseType_t xPhyIndex; -uint32_t ulValue, ulBitMask = ( uint32_t )1u; - - ulValue = ( uint32_t )0u; - - if( pxPhyObject->xPhyPreferences.ucDuplex == PHY_DUPLEX_FULL ) - { - ulValue |= phyBMCR_FULL_DUPLEX; - } - if( pxPhyObject->xPhyPreferences.ucSpeed == PHY_SPEED_100 ) - { - ulValue |= phyBMCR_SPEED_100; - } - - for( xPhyIndex = 0; xPhyIndex < pxPhyObject->xPortCount; xPhyIndex++, ulBitMask <<= 1 ) - { - if( ( ulPhyMask & ulBitMask ) != 0lu ) - { - BaseType_t xPhyAddress = pxPhyObject->ucPhyIndexes[ xPhyIndex ]; - - /* Enable Auto-Negotiation. */ - pxPhyObject->fnPhyWrite( xPhyAddress, phyREG_00_BMCR, ulValue ); - } - } - return 0; -} -/*-----------------------------------------------------------*/ - -BaseType_t xPhyStartAutoNegotiation( EthernetPhy_t *pxPhyObject, uint32_t ulPhyMask ) -{ -uint32_t xPhyIndex, ulDoneMask, ulBitMask; -uint32_t ulPHYLinkStatus, ulRegValue; -TickType_t xRemainingTime; -TimeOut_t xTimer; - - if( ulPhyMask == ( uint32_t )0u ) - { - return 0; - } - for( xPhyIndex = 0; xPhyIndex < pxPhyObject->xPortCount; xPhyIndex++ ) - { - if( ( ulPhyMask & ( 1lu << xPhyIndex ) ) != 0lu ) - { - BaseType_t xPhyAddress = pxPhyObject->ucPhyIndexes[ xPhyIndex ]; - - /* Enable Auto-Negotiation. */ - pxPhyObject->fnPhyWrite( xPhyAddress, phyREG_04_ADVERTISE, pxPhyObject->ulACRValue); - pxPhyObject->fnPhyWrite( xPhyAddress, phyREG_00_BMCR, pxPhyObject->ulBCRValue | phyBMCR_AN_RESTART ); - } - } -eventLogAdd( "AN start" ); - xRemainingTime = ( TickType_t ) pdMS_TO_TICKS( 3000UL ); - vTaskSetTimeOutState( &xTimer ); - ulDoneMask = 0; - /* Wait until the auto-negotiation will be completed */ - for( ;; ) - { - ulBitMask = ( uint32_t )1u; - for( xPhyIndex = 0; xPhyIndex < pxPhyObject->xPortCount; xPhyIndex++, ulBitMask <<= 1 ) - { - if( ( ulPhyMask & ulBitMask ) != 0lu ) - { - if( ( ulDoneMask & ulBitMask ) == 0lu ) - { - BaseType_t xPhyAddress = pxPhyObject->ucPhyIndexes[ xPhyIndex ]; - - pxPhyObject->fnPhyRead( xPhyAddress, phyREG_01_BMSR, &ulRegValue ); - if( ( ulRegValue & phyBMSR_AN_COMPLETE ) != 0 ) - { - ulDoneMask |= ulBitMask; - } - } - } - } - if( ulPhyMask == ulDoneMask ) - { - break; - } - if( xTaskCheckForTimeOut( &xTimer, &xRemainingTime ) != pdFALSE ) - { - FreeRTOS_printf( ( "xPhyReset: phyBMCR_RESET timed out ( done 0x%02lX )\n", ulDoneMask ) ); - eventLogAdd( "ANtimed out"); - break; - } - } -eventLogAdd( "AN done %02lX / %02lX", ulDoneMask, ulPhyMask ); - - if( ulDoneMask != ( uint32_t)0u ) - { - ulBitMask = ( uint32_t )1u; - pxPhyObject->ulLinkStatusMask &= ~( ulDoneMask ); - for( xPhyIndex = 0; xPhyIndex < pxPhyObject->xPortCount; xPhyIndex++, ulBitMask <<= 1 ) - { - BaseType_t xPhyAddress = pxPhyObject->ucPhyIndexes[ xPhyIndex ]; - uint32_t ulPhyID = pxPhyObject->ulPhyIDs[ xPhyIndex ]; - - if( ( ulDoneMask & ulBitMask ) == ( uint32_t )0u ) - { - continue; - } - - /* Clear the 'phyBMCR_AN_RESTART' bit. */ - pxPhyObject->fnPhyWrite( xPhyAddress, phyREG_00_BMCR, pxPhyObject->ulBCRValue ); - - pxPhyObject->fnPhyRead( xPhyAddress, phyREG_01_BMSR, &ulRegValue); - if( ( ulRegValue & phyBMSR_LINK_STATUS ) != 0 ) - { - ulPHYLinkStatus |= phyBMSR_LINK_STATUS; - pxPhyObject->ulLinkStatusMask |= ulBitMask; - } - else - { - ulPHYLinkStatus &= ~( phyBMSR_LINK_STATUS ); - } - - if( xHas_1F_PHYSPCS( ulPhyID ) ) - { - /* 31 RW PHY Special Control Status */ - uint32_t ulControlStatus; - - pxPhyObject->fnPhyRead( xPhyAddress, phyREG_1F_PHYSPCS, &ulControlStatus); - ulRegValue = 0; - if( ( ulControlStatus & phyPHYSPCS_FULL_DUPLEX ) != 0 ) - { - ulRegValue |= phyPHYSTS_DUPLEX_STATUS; - } - if( ( ulControlStatus & phyPHYSPCS_SPEED_MASK ) == phyPHYSPCS_SPEED_10 ) - { - ulRegValue |= phyPHYSTS_SPEED_STATUS; - } - - } - else - { - /* Read the result of the auto-negotiation. */ - pxPhyObject->fnPhyRead( xPhyAddress, PHYREG_10_PHYSTS, &ulRegValue); - } - - FreeRTOS_printf( ( ">> Autonego ready: %08lx: %s duplex %u mbit %s status\n", - ulRegValue, - ( ulRegValue & phyPHYSTS_DUPLEX_STATUS ) ? "full" : "half", - ( ulRegValue & phyPHYSTS_SPEED_STATUS ) ? 10 : 100, - ( ( ulPHYLinkStatus |= phyBMSR_LINK_STATUS ) != 0) ? "high" : "low" ) ); - eventLogAdd( "%s duplex %u mbit %s st", - ( ulRegValue & phyPHYSTS_DUPLEX_STATUS ) ? "full" : "half", - ( ulRegValue & phyPHYSTS_SPEED_STATUS ) ? 10 : 100, - ( ( ulPHYLinkStatus |= phyBMSR_LINK_STATUS ) != 0) ? "high" : "low" ); -{ - uint32_t regs[4]; - int i,j; - int address = 0x10; - for (i = 0; i < 4; i++) - { - for (j = 0; j < 4; j++) - { - pxPhyObject->fnPhyRead( xPhyAddress, address, regs + j ); - address++; - } - eventLogAdd("%04lX %04lX %04lX %04lX", - regs[0], regs[1], regs[2], regs[3]); - } -} - if( ( ulRegValue & phyPHYSTS_DUPLEX_STATUS ) != ( uint32_t )0u ) - { - pxPhyObject->xPhyProperties.ucDuplex = PHY_DUPLEX_FULL; - } - else - { - pxPhyObject->xPhyProperties.ucDuplex = PHY_DUPLEX_HALF; - } - - if( ( ulRegValue & phyPHYSTS_SPEED_STATUS ) != 0 ) - { - pxPhyObject->xPhyProperties.ucSpeed = PHY_SPEED_10; - } - else - { - pxPhyObject->xPhyProperties.ucSpeed = PHY_SPEED_100; - } - } - } /* if( ulDoneMask != ( uint32_t)0u ) */ - - return 0; -} -/*-----------------------------------------------------------*/ - -BaseType_t xPhyCheckLinkStatus( EthernetPhy_t *pxPhyObject, BaseType_t xHadReception ) -{ -uint32_t ulStatus, ulBitMask = 1u; -BaseType_t xPhyIndex; -BaseType_t xNeedCheck = pdFALSE; - - if( xHadReception > 0 ) - { - /* A packet was received. No need to check for the PHY status now, - but set a timer to check it later on. */ - vTaskSetTimeOutState( &( pxPhyObject->xLinkStatusTimer ) ); - pxPhyObject->xLinkStatusRemaining = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS ); - } - else if( xTaskCheckForTimeOut( &( pxPhyObject->xLinkStatusTimer ), &( pxPhyObject->xLinkStatusRemaining ) ) != pdFALSE ) - { - for( xPhyIndex = 0; xPhyIndex < pxPhyObject->xPortCount; xPhyIndex++, ulBitMask <<= 1 ) - { - BaseType_t xPhyAddress = pxPhyObject->ucPhyIndexes[ xPhyIndex ]; - - if( pxPhyObject->fnPhyRead( xPhyAddress, phyREG_01_BMSR, &ulStatus ) == 0 ) - { - if( !!( pxPhyObject->ulLinkStatusMask & ulBitMask ) != !!( ulStatus & phyBMSR_LINK_STATUS ) ) - { - if( ( ulStatus & phyBMSR_LINK_STATUS ) != 0 ) - { - pxPhyObject->ulLinkStatusMask |= ulBitMask; - } - else - { - pxPhyObject->ulLinkStatusMask &= ~( ulBitMask ); - } - FreeRTOS_printf( ( "xPhyCheckLinkStatus: PHY LS now %02lX\n", pxPhyObject->ulLinkStatusMask ) ); - eventLogAdd( "PHY LS now %02lX", pxPhyObject->ulLinkStatusMask ); - xNeedCheck = pdTRUE; - } - } - } - vTaskSetTimeOutState( &( pxPhyObject->xLinkStatusTimer ) ); - if( ( pxPhyObject->ulLinkStatusMask & phyBMSR_LINK_STATUS ) != 0 ) - { - pxPhyObject->xLinkStatusRemaining = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS ); - } - else - { - pxPhyObject->xLinkStatusRemaining = pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS ); - } - } - return xNeedCheck; -} -/*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/LPC17xx/NetworkInterface.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/LPC17xx/NetworkInterface.c deleted file mode 100755 index c9502fa..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/LPC17xx/NetworkInterface.c +++ /dev/null @@ -1,267 +0,0 @@ -/* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - http://aws.amazon.com/freertos - http://www.FreeRTOS.org -*/ - -/* Standard includes. */ -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* Hardware abstraction. */ -#include "FreeRTOS_IO.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_Sockets.h" -#include "NetworkBufferManagement.h" - -/* Driver includes. */ -#include "lpc17xx_emac.h" -#include "lpc17xx_pinsel.h" - -/* Demo includes. */ -#include "NetworkInterface.h" - -#if ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES != 1 - #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer -#else - #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) ) -#endif - -/* When a packet is ready to be sent, if it cannot be sent immediately then the -task performing the transmit will block for niTX_BUFFER_FREE_WAIT -milliseconds. It will do this a maximum of niMAX_TX_ATTEMPTS before giving -up. */ -#define niTX_BUFFER_FREE_WAIT ( pdMS_TO_TICKS( 2UL ) ) -#define niMAX_TX_ATTEMPTS ( 5 ) - -/* The length of the queue used to send interrupt status words from the -interrupt handler to the deferred handler task. */ -#define niINTERRUPT_QUEUE_LENGTH ( 10 ) - -/*-----------------------------------------------------------*/ - -/* - * A deferred interrupt handler task that processes - */ -static void prvEMACHandlerTask( void *pvParameters ); - -/*-----------------------------------------------------------*/ - -/* The queue used to communicate Ethernet events with the IP task. */ -extern QueueHandle_t xNetworkEventQueue; - -/* The semaphore used to wake the deferred interrupt handler task when an Rx -interrupt is received. */ -static SemaphoreHandle_t xEMACRxEventSemaphore = NULL; -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceInitialise( void ) -{ -EMAC_CFG_Type Emac_Config; -PINSEL_CFG_Type xPinConfig; -BaseType_t xStatus, xReturn; -extern uint8_t ucMACAddress[ 6 ]; - - /* Enable Ethernet Pins */ - boardCONFIGURE_ENET_PINS( xPinConfig ); - - Emac_Config.Mode = EMAC_MODE_AUTO; - Emac_Config.pbEMAC_Addr = ucMACAddress; - xStatus = EMAC_Init( &Emac_Config ); - - LPC_EMAC->IntEnable &= ~( EMAC_INT_TX_DONE ); - - if( xStatus != ERROR ) - { - vSemaphoreCreateBinary( xEMACRxEventSemaphore ); - configASSERT( xEMACRxEventSemaphore ); - - /* The handler task is created at the highest possible priority to - ensure the interrupt handler can return directly to it. */ - xTaskCreate( prvEMACHandlerTask, "EMAC", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL ); - - /* Enable the interrupt and set its priority to the minimum - interrupt priority. */ - NVIC_SetPriority( ENET_IRQn, configMAC_INTERRUPT_PRIORITY ); - NVIC_EnableIRQ( ENET_IRQn ); - - xReturn = pdPASS; - } - else - { - xReturn = pdFAIL; - } - - configASSERT( xStatus != ERROR ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer ) -{ -BaseType_t xReturn = pdFAIL; -int32_t x; -extern void EMAC_StartTransmitNextBuffer( uint32_t ulLength ); -extern void EMAC_SetNextPacketToSend( uint8_t * pucBuffer ); - - - /* Attempt to obtain access to a Tx buffer. */ - for( x = 0; x < niMAX_TX_ATTEMPTS; x++ ) - { - if( EMAC_CheckTransmitIndex() == TRUE ) - { - /* Will the data fit in the Tx buffer? */ - if( pxNetworkBuffer->xDataLength < EMAC_ETH_MAX_FLEN ) /*_RB_ The size needs to come from FreeRTOSIPConfig.h. */ - { - /* Assign the buffer to the Tx descriptor that is now known to - be free. */ - EMAC_SetNextPacketToSend( pxNetworkBuffer->pucBuffer ); - - /* The EMAC now owns the buffer. */ - pxNetworkBuffer->pucBuffer = NULL; - - /* Initiate the Tx. */ - EMAC_StartTransmitNextBuffer( pxNetworkBuffer->xDataLength ); - iptraceNETWORK_INTERFACE_TRANSMIT(); - - /* The Tx has been initiated. */ - xReturn = pdPASS; - } - break; - } - else - { - vTaskDelay( niTX_BUFFER_FREE_WAIT ); - } - } - - /* Finished with the network buffer. */ - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -void ENET_IRQHandler( void ) -{ -uint32_t ulInterruptCause; - - while( ( ulInterruptCause = LPC_EMAC->IntStatus ) != 0 ) - { - /* Clear the interrupt. */ - LPC_EMAC->IntClear = ulInterruptCause; - - /* Clear fatal error conditions. NOTE: The driver does not clear all - errors, only those actually experienced. For future reference, range - errors are not actually errors so can be ignored. */ - if( ( ulInterruptCause & EMAC_INT_TX_UNDERRUN ) != 0U ) - { - LPC_EMAC->Command |= EMAC_CR_TX_RES; - } - - /* Unblock the deferred interrupt handler task if the event was an - Rx. */ - if( ( ulInterruptCause & EMAC_INT_RX_DONE ) != 0UL ) - { - xSemaphoreGiveFromISR( xEMACRxEventSemaphore, NULL ); - } - } - - /* ulInterruptCause is used for convenience here. A context switch is - wanted, but coding portEND_SWITCHING_ISR( 1 ) would likely result in a - compiler warning. */ - portEND_SWITCHING_ISR( ulInterruptCause ); -} -/*-----------------------------------------------------------*/ - -static void prvEMACHandlerTask( void *pvParameters ) -{ -size_t xDataLength; -const uint16_t usCRCLength = 4; -NetworkBufferDescriptor_t *pxNetworkBuffer; -IPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL }; - -/* This is not included in the header file for some reason. */ -extern uint8_t *EMAC_NextPacketToRead( void ); - - ( void ) pvParameters; - configASSERT( xEMACRxEventSemaphore ); - - for( ;; ) - { - /* Wait for the EMAC interrupt to indicate that another packet has been - received. The while() loop is only needed if INCLUDE_vTaskSuspend is - set to 0 in FreeRTOSConfig.h. */ - while( xSemaphoreTake( xEMACRxEventSemaphore, portMAX_DELAY ) == pdFALSE ); - - /* At least one packet has been received. */ - while( EMAC_CheckReceiveIndex() != FALSE ) - { - /* Obtain the length, minus the CRC. The CRC is four bytes - but the length is already minus 1. */ - xDataLength = ( size_t ) EMAC_GetReceiveDataSize() - ( usCRCLength - 1U ); - - if( xDataLength > 0U ) - { - /* Obtain a network buffer to pass this data into the - stack. No storage is required as the network buffer - will point directly to the buffer that already holds - the received data. */ - pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( 0, ( TickType_t ) 0 ); - - if( pxNetworkBuffer != NULL ) - { - pxNetworkBuffer->pucBuffer = EMAC_NextPacketToRead(); - pxNetworkBuffer->xDataLength = xDataLength; - xRxEvent.pvData = ( void * ) pxNetworkBuffer; - - /* Data was received and stored. Send a message to the IP - task to let it know. */ - if( xSendEventStructToIPTask( &xRxEvent, ( TickType_t ) 0 ) == pdFAIL ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - iptraceETHERNET_RX_EVENT_LOST(); - } - } - else - { - iptraceETHERNET_RX_EVENT_LOST(); - } - - iptraceNETWORK_INTERFACE_RECEIVE(); - } - - /* Release the frame. */ - EMAC_UpdateRxConsumeIndex(); - } - } -} -/*-----------------------------------------------------------*/ - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/LPC18xx/NetworkInterface.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/LPC18xx/NetworkInterface.c deleted file mode 100755 index 3605513..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/LPC18xx/NetworkInterface.c +++ /dev/null @@ -1,1069 +0,0 @@ -/* - * FreeRTOS+TCP V2.0.3 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - - -/* Standard includes. */ -#include -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "NetworkBufferManagement.h" -#include "NetworkInterface.h" - -/* LPCOpen includes. */ -#include "chip.h" -#include "lpc_phy.h" - -/* The size of the stack allocated to the task that handles Rx packets. */ -#define nwRX_TASK_STACK_SIZE 140 - -#ifndef PHY_LS_HIGH_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still high after 15 seconds of not - receiving packets. */ - #define PHY_LS_HIGH_CHECK_TIME_MS 15000 -#endif - -#ifndef PHY_LS_LOW_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still low every second. */ - #define PHY_LS_LOW_CHECK_TIME_MS 1000 -#endif - -#ifndef configUSE_RMII - #define configUSE_RMII 1 -#endif - -#ifndef configNUM_RX_DESCRIPTORS - #error please define configNUM_RX_DESCRIPTORS in your FreeRTOSIPConfig.h -#endif - -#ifndef configNUM_TX_DESCRIPTORS - #error please define configNUM_TX_DESCRIPTORS in your FreeRTOSIPConfig.h -#endif - -#ifndef NETWORK_IRQHandler - #error NETWORK_IRQHandler must be defined to the name of the function that is installed in the interrupt vector table to handle Ethernet interrupts. -#endif - -#if !defined( MAC_FF_HMC ) - /* Hash for multicast. */ - #define MAC_FF_HMC ( 1UL << 2UL ) -#endif - -#ifndef iptraceEMAC_TASK_STARTING - #define iptraceEMAC_TASK_STARTING() do { } while( 0 ) -#endif - -/* Define the bits of .STATUS that indicate a reception error. */ -#define nwRX_STATUS_ERROR_BITS \ - ( RDES_CE /* CRC Error */ | \ - RDES_RE /* Receive Error */ | \ - RDES_DE /* Descriptor Error */ | \ - RDES_RWT /* Receive Watchdog Timeout */ | \ - RDES_LC /* Late Collision */ | \ - RDES_OE /* Overflow Error */ | \ - RDES_SAF /* Source Address Filter Fail */ | \ - RDES_AFM /* Destination Address Filter Fail */ | \ - RDES_LE /* Length Error */ ) - -/* Define the EMAC status bits that should trigger an interrupt. */ -#define nwDMA_INTERRUPT_MASK \ - ( DMA_IE_TIE /* Transmit interrupt enable */ | \ - DMA_IE_TSE /* Transmit stopped enable */ | \ - DMA_IE_OVE /* Overflow interrupt enable */ | \ - DMA_IE_RIE /* Receive interrupt enable */ | \ - DMA_IE_NIE /* Normal interrupt summary enable */ | \ - DMA_IE_AIE /* Abnormal interrupt summary enable */ | \ - DMA_IE_RUE /* Receive buffer unavailable enable */ | \ - DMA_IE_UNE /* Underflow interrupt enable. */ | \ - DMA_IE_TJE /* Transmit jabber timeout enable */ | \ - DMA_IE_RSE /* Received stopped enable */ | \ - DMA_IE_RWE /* Receive watchdog timeout enable */ | \ - DMA_IE_FBE )/* Fatal bus error enable */ - -/* Interrupt events to process. Currently only the RX/TX events are processed -although code for other events is included to allow for possible future -expansion. */ -#define EMAC_IF_RX_EVENT 1UL -#define EMAC_IF_TX_EVENT 2UL -#define EMAC_IF_ERR_EVENT 4UL -#define EMAC_IF_ALL_EVENT ( EMAC_IF_RX_EVENT | EMAC_IF_TX_EVENT | EMAC_IF_ERR_EVENT ) - - /* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1, then the Ethernet - driver will filter incoming packets and only pass the stack those packets it - considers need processing. */ - #if( ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES == 0 ) - #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer - #else - #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) ) - #endif - -#if( ipconfigZERO_COPY_RX_DRIVER == 0 ) || ( ipconfigZERO_COPY_TX_DRIVER == 0 ) - #warning It is adviced to enable both macros -#endif - -#ifndef configPLACE_IN_SECTION_RAM - #define configPLACE_IN_SECTION_RAM -/* - #define configPLACE_IN_SECTION_RAM __attribute__ ((section(".ramfunc"))) -*/ -#endif - -/*-----------------------------------------------------------*/ - -/* - * Delay function passed into the library. The implementation uses FreeRTOS - * calls so the scheduler must be started before the driver can be used. - */ -static void prvDelay( uint32_t ulMilliSeconds ); - -/* - * Initialises the Tx and Rx descriptors respectively. - */ -static void prvSetupTxDescriptors( void ); -static void prvSetupRxDescriptors( void ); - -/* - * A task that processes received frames. - */ -static void prvEMACHandlerTask( void *pvParameters ); - -/* - * Sets up the MAC with the results of an auto-negotiation. - */ -static BaseType_t prvSetLinkSpeed( void ); - -/* - * Generates a CRC for a MAC address that is then used to generate a hash index. - */ -static uint32_t prvGenerateCRC32( const uint8_t *ucAddress ); - -/* - * Generates a hash index when setting a filter to permit a MAC address. - */ -static uint32_t prvGetHashIndex( const uint8_t *ucAddress ); - -/* - * Update the hash table to allow a MAC address. - */ -static void prvAddMACAddress( const uint8_t* ucMacAddress ); - -/* - * Sometimes the DMA will report received data as being longer than the actual - * received from length. This function checks the reported length and corrects - * if if necessary. - */ -static void prvRemoveTrailingBytes( NetworkBufferDescriptor_t *pxDescriptor ); - -/*-----------------------------------------------------------*/ - -/* Bit map of outstanding ETH interrupt events for processing. Currently only -the Rx and Tx interrupt is handled, although code is included for other events -to enable future expansion. */ -static volatile uint32_t ulISREvents; - -/* A copy of PHY register 1: 'PHY_REG_01_BMSR' */ -static uint32_t ulPHYLinkStatus = 0; - -/* Tx descriptors and index. */ -static ENET_ENHTXDESC_T xDMATxDescriptors[ configNUM_TX_DESCRIPTORS ]; - -/* ulNextFreeTxDescriptor is declared volatile, because it is accessed from -to different tasks. */ -static volatile uint32_t ulNextFreeTxDescriptor; -static uint32_t ulTxDescriptorToClear; - -/* Rx descriptors and index. */ -static ENET_ENHRXDESC_T xDMARxDescriptors[ configNUM_RX_DESCRIPTORS ]; -static uint32_t ulNextRxDescriptorToProcess; - -/* Must be defined externally - the demo applications define this in main.c. */ -extern uint8_t ucMACAddress[ 6 ]; - -/* The handle of the task that processes Rx packets. The handle is required so -the task can be notified when new packets arrive. */ -static TaskHandle_t xRxHanderTask = NULL; - -#if( ipconfigUSE_LLMNR == 1 ) - static const uint8_t xLLMNR_MACAddress[] = { '\x01', '\x00', '\x5E', '\x00', '\x00', '\xFC' }; -#endif /* ipconfigUSE_LLMNR == 1 */ - -/* xTXDescriptorSemaphore is a counting semaphore with -a maximum count of ETH_TXBUFNB, which is the number of -DMA TX descriptors. */ -static SemaphoreHandle_t xTXDescriptorSemaphore = NULL; - -/*-----------------------------------------------------------*/ - - -BaseType_t xNetworkInterfaceInitialise( void ) -{ -BaseType_t xReturn = pdPASS; -static BaseType_t xHasInitialised = pdFALSE; - - if( xHasInitialised == pdFALSE ) - { - xHasInitialised = pdTRUE; - - /* The interrupt will be turned on when a link is established. */ - NVIC_DisableIRQ( ETHERNET_IRQn ); - - /* Disable receive and transmit DMA processes. */ - LPC_ETHERNET->DMA_OP_MODE &= ~( DMA_OM_ST | DMA_OM_SR ); - - /* Disable packet reception. */ - LPC_ETHERNET->MAC_CONFIG &= ~( MAC_CFG_RE | MAC_CFG_TE ); - - /* Call the LPCOpen function to initialise the hardware. */ - Chip_ENET_Init( LPC_ETHERNET ); - - /* Save MAC address. */ - Chip_ENET_SetADDR( LPC_ETHERNET, ucMACAddress ); - - /* Clear all MAC address hash entries. */ - LPC_ETHERNET->MAC_HASHTABLE_HIGH = 0; - LPC_ETHERNET->MAC_HASHTABLE_LOW = 0; - - #if( ipconfigUSE_LLMNR == 1 ) - { - prvAddMACAddress( xLLMNR_MACAddress ); - } - #endif /* ipconfigUSE_LLMNR == 1 */ - - /* Promiscuous flag (PR) and Receive All flag (RA) set to zero. The - registers MAC_HASHTABLE_[LOW|HIGH] will be loaded to allow certain - multi-cast addresses. */ - LPC_ETHERNET->MAC_FRAME_FILTER = MAC_FF_HMC; - - #if( configUSE_RMII == 1 ) - { - if( lpc_phy_init( pdTRUE, prvDelay ) != SUCCESS ) - { - xReturn = pdFAIL; - } - } - #else - { - #warning This path has not been tested. - if( lpc_phy_init( pdFALSE, prvDelay ) != SUCCESS ) - { - xReturn = pdFAIL; - } - } - #endif - - if( xReturn == pdPASS ) - { - if( xTXDescriptorSemaphore == NULL ) - { - /* Create a counting semaphore, with a value of 'configNUM_TX_DESCRIPTORS' - and a maximum of 'configNUM_TX_DESCRIPTORS'. */ - xTXDescriptorSemaphore = xSemaphoreCreateCounting( ( UBaseType_t ) configNUM_TX_DESCRIPTORS, ( UBaseType_t ) configNUM_TX_DESCRIPTORS ); - configASSERT( xTXDescriptorSemaphore ); - } - - /* Enable MAC interrupts. */ - LPC_ETHERNET->DMA_INT_EN = nwDMA_INTERRUPT_MASK; - - /* Auto-negotiate was already started. Wait for it to complete. */ - xReturn = prvSetLinkSpeed(); - - if( xReturn == pdPASS ) - { - /* Initialise the descriptors. */ - prvSetupTxDescriptors(); - prvSetupRxDescriptors(); - - /* Clear all interrupts. */ - LPC_ETHERNET->DMA_STAT = DMA_ST_ALL; - - /* Enable receive and transmit DMA processes. */ - LPC_ETHERNET->DMA_OP_MODE |= DMA_OM_ST | DMA_OM_SR; - - /* Set Receiver / Transmitter Enable. */ - LPC_ETHERNET->MAC_CONFIG |= MAC_CFG_RE | MAC_CFG_TE; - - /* Start receive polling. */ - LPC_ETHERNET->DMA_REC_POLL_DEMAND = 1; - - /* Enable interrupts in the NVIC. */ - NVIC_SetPriority( ETHERNET_IRQn, configMAC_INTERRUPT_PRIORITY ); - NVIC_EnableIRQ( ETHERNET_IRQn ); - } - /* Guard against the task being created more than once and the - descriptors being initialised more than once. */ - if( xRxHanderTask == NULL ) - { - xReturn = xTaskCreate( prvEMACHandlerTask, "EMAC", nwRX_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, &xRxHanderTask ); - configASSERT( xReturn ); - } - } - } - - /* Once prvEMACHandlerTask() has started, the variable - 'ulPHYLinkStatus' will be updated by that task. - The IP-task will keep on calling this function untill - it finally returns pdPASS. - Only then can the DHCP-procedure start (if configured). */ - if( ( ulPHYLinkStatus & PHY_LINK_CONNECTED ) != 0 ) - { - xReturn = pdPASS; - } - else - { - xReturn = pdFAIL; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -#define niBUFFER_1_PACKET_SIZE 1536 - -static __attribute__ ((section("._ramAHB32"))) uint8_t ucNetworkPackets[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS * niBUFFER_1_PACKET_SIZE ] __attribute__ ( ( aligned( 32 ) ) ); - -void vNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkBuffers[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ] ) -{ - -uint8_t *ucRAMBuffer = ucNetworkPackets; -uint32_t ul; - - for( ul = 0; ul < ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS; ul++ ) - { - pxNetworkBuffers[ ul ].pucEthernetBuffer = ucRAMBuffer + ipBUFFER_PADDING; - *( ( unsigned * ) ucRAMBuffer ) = ( unsigned ) ( &( pxNetworkBuffers[ ul ] ) ); - ucRAMBuffer += niBUFFER_1_PACKET_SIZE; - } -} -/*-----------------------------------------------------------*/ - -configPLACE_IN_SECTION_RAM -static void vClearTXBuffers() -{ -uint32_t ulLastDescriptor = ulNextFreeTxDescriptor; -size_t uxCount = ( ( size_t ) configNUM_TX_DESCRIPTORS ) - uxSemaphoreGetCount( xTXDescriptorSemaphore ); -#if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - NetworkBufferDescriptor_t *pxNetworkBuffer; - uint8_t *ucPayLoad; -#endif - - /* This function is called after a TX-completion interrupt. - It will release each Network Buffer used in xNetworkInterfaceOutput(). - 'uxCount' represents the number of descriptors given to DMA for transmission. - After sending a packet, the DMA will clear the 'TDES_OWN' bit. */ - while( ( uxCount > ( size_t ) 0u ) && ( ( xDMATxDescriptors[ ulTxDescriptorToClear ].CTRLSTAT & TDES_OWN ) == 0 ) ) - { - if( ( ulTxDescriptorToClear == ulLastDescriptor ) && ( uxCount != ( size_t ) configNUM_TX_DESCRIPTORS ) ) - { - break; - } - - - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - ucPayLoad = ( uint8_t * )xDMATxDescriptors[ ulTxDescriptorToClear ].B1ADD; - if( ucPayLoad != NULL ) - { - /* B1ADD points to a pucEthernetBuffer of a Network Buffer descriptor. */ - pxNetworkBuffer = pxPacketBuffer_to_NetworkBuffer( ucPayLoad ); - - configASSERT( pxNetworkBuffer != NULL ); - - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ) ; - xDMATxDescriptors[ ulTxDescriptorToClear ].B1ADD = ( uint32_t )0u; - } - } - #endif /* ipconfigZERO_COPY_TX_DRIVER */ - - /* Move onto the next descriptor, wrapping if necessary. */ - ulTxDescriptorToClear++; - if( ulTxDescriptorToClear >= configNUM_TX_DESCRIPTORS ) - { - ulTxDescriptorToClear = 0; - } - - uxCount--; - /* Tell the counting semaphore that one more TX descriptor is available. */ - xSemaphoreGive( xTXDescriptorSemaphore ); - } -} - -/*-----------------------------------------------------------*/ - -configPLACE_IN_SECTION_RAM -BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescriptor, BaseType_t bReleaseAfterSend ) -{ -BaseType_t xReturn = pdFAIL; -const TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 50 ); - - /* Attempt to obtain access to a Tx descriptor. */ - do - { - if( xTXDescriptorSemaphore == NULL ) - { - break; - } - if( xSemaphoreTake( xTXDescriptorSemaphore, xBlockTimeTicks ) != pdPASS ) - { - /* Time-out waiting for a free TX descriptor. */ - break; - } - - /* If the descriptor is still owned by the DMA it can't be used. */ - if( ( xDMATxDescriptors[ ulNextFreeTxDescriptor ].CTRLSTAT & TDES_OWN ) != 0 ) - { - /* The semaphore was taken, the TX DMA-descriptor is still not available. - Actually that should not occur, the 'TDES_OWN' was already confirmed low in vClearTXBuffers(). */ - xSemaphoreGive( xTXDescriptorSemaphore ); - } - else - { - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* bReleaseAfterSend should always be set when using the zero - copy driver. */ - configASSERT( bReleaseAfterSend != pdFALSE ); - - /* The DMA's descriptor to point directly to the data in the - network buffer descriptor. The data is not copied. */ - xDMATxDescriptors[ ulNextFreeTxDescriptor ].B1ADD = ( uint32_t ) pxDescriptor->pucEthernetBuffer; - - /* The DMA descriptor will 'own' this Network Buffer, - until it has been sent. So don't release it now. */ - bReleaseAfterSend = pdFALSE; - } - #else - { - /* The data is copied from the network buffer descriptor into - the DMA's descriptor. */ - memcpy( ( void * ) xDMATxDescriptors[ ulNextFreeTxDescriptor ].B1ADD, ( void * ) pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength ); - } - #endif - - xDMATxDescriptors[ ulNextFreeTxDescriptor ].BSIZE = ( uint32_t ) TDES_ENH_BS1( pxDescriptor->xDataLength ); - - /* This descriptor is given back to the DMA. */ - xDMATxDescriptors[ ulNextFreeTxDescriptor ].CTRLSTAT |= TDES_OWN; - - /* Ensure the DMA is polling Tx descriptors. */ - LPC_ETHERNET->DMA_TRANS_POLL_DEMAND = 1; - - iptraceNETWORK_INTERFACE_TRANSMIT(); - - /* Move onto the next descriptor, wrapping if necessary. */ - ulNextFreeTxDescriptor++; - if( ulNextFreeTxDescriptor >= configNUM_TX_DESCRIPTORS ) - { - ulNextFreeTxDescriptor = 0; - } - - /* The Tx has been initiated. */ - xReturn = pdPASS; - } - } while( 0 ); - - /* The buffer has been sent so can be released. */ - if( bReleaseAfterSend != pdFALSE ) - { - vReleaseNetworkBufferAndDescriptor( pxDescriptor ); - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -static void prvDelay( uint32_t ulMilliSeconds ) -{ - /* Ensure the scheduler was started before attempting to use the scheduler to - create a delay. */ - configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_RUNNING ); - - vTaskDelay( pdMS_TO_TICKS( ulMilliSeconds ) ); -} -/*-----------------------------------------------------------*/ - -static void prvSetupTxDescriptors( void ) -{ -BaseType_t x; - - /* Start with Tx descriptors clear. */ - memset( ( void * ) xDMATxDescriptors, 0, sizeof( xDMATxDescriptors ) ); - - /* Index to the next Tx descriptor to use. */ - ulNextFreeTxDescriptor = 0ul; - - /* Index to the next Tx descriptor to clear ( after transmission ). */ - ulTxDescriptorToClear = 0ul; - - for( x = 0; x < configNUM_TX_DESCRIPTORS; x++ ) - { - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* Nothing to do, B1ADD will be set when data is ready to transmit. - Currently the memset above will have set it to NULL. */ - } - #else - { - /* Allocate a buffer to the Tx descriptor. This is the most basic - way of creating a driver as the data is then copied into the - buffer. */ - xDMATxDescriptors[ x ].B1ADD = ( uint32_t ) pvPortMalloc( ipTOTAL_ETHERNET_FRAME_SIZE ); - - /* Use an assert to check the allocation as +TCP applications will - often not use a malloc() failed hook as the TCP stack will recover - from allocation failures. */ - configASSERT( xDMATxDescriptors[ x ].B1ADD ); - } - #endif - - /* Buffers hold an entire frame so all buffers are both the start and - end of a frame. */ - /* TDES_ENH_TCH Second Address Chained. */ - /* TDES_ENH_CIC(n) Checksum Insertion Control, tried but it does not work for the LPC18xx... */ - /* TDES_ENH_FS First Segment. */ - /* TDES_ENH_LS Last Segment. */ - /* TDES_ENH_IC Interrupt on Completion. */ - xDMATxDescriptors[ x ].CTRLSTAT = TDES_ENH_TCH | TDES_ENH_CIC( 3 ) | TDES_ENH_FS | TDES_ENH_LS | TDES_ENH_IC; - xDMATxDescriptors[ x ].B2ADD = ( uint32_t ) &xDMATxDescriptors[ x + 1 ]; - } - - xDMATxDescriptors[ configNUM_TX_DESCRIPTORS - 1 ].CTRLSTAT |= TDES_ENH_TER; - xDMATxDescriptors[ configNUM_TX_DESCRIPTORS - 1 ].B2ADD = ( uint32_t ) &xDMATxDescriptors[ 0 ]; - - /* Point the DMA to the base of the descriptor list. */ - LPC_ETHERNET->DMA_TRANS_DES_ADDR = ( uint32_t ) xDMATxDescriptors; -} -/*-----------------------------------------------------------*/ - -static void prvSetupRxDescriptors( void ) -{ -BaseType_t x; -#if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - NetworkBufferDescriptor_t *pxNetworkBuffer; -#endif - - /* Index to the next Rx descriptor to use. */ - ulNextRxDescriptorToProcess = 0; - - /* Clear RX descriptor list. */ - memset( ( void * ) xDMARxDescriptors, 0, sizeof( xDMARxDescriptors ) ); - - for( x = 0; x < configNUM_RX_DESCRIPTORS; x++ ) - { - /* Allocate a buffer of the largest possible frame size as it is not - known what size received frames will be. */ - - #if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( ipTOTAL_ETHERNET_FRAME_SIZE, 0 ); - - /* During start-up there should be enough Network Buffers available, - so it is safe to use configASSERT(). - In case this assert fails, please check: configNUM_RX_DESCRIPTORS, - ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, and in case BufferAllocation_2.c - is included, check the amount of available heap. */ - configASSERT( pxNetworkBuffer != NULL ); - - /* Pass the actual buffer to DMA. */ - xDMARxDescriptors[ x ].B1ADD = ( uint32_t ) pxNetworkBuffer->pucEthernetBuffer; - } - #else - { - /* All DMA descriptors are populated with permanent memory blocks. - Their contents will be copy to Network Buffers. */ - xDMARxDescriptors[ x ].B1ADD = ( uint32_t ) pvPortMalloc( ipTOTAL_ETHERNET_FRAME_SIZE ); - } - #endif /* ipconfigZERO_COPY_RX_DRIVER */ - - /* Use an assert to check the allocation as +TCP applications will often - not use a malloc failed hook as the TCP stack will recover from - allocation failures. */ - configASSERT( xDMARxDescriptors[ x ].B1ADD ); - - xDMARxDescriptors[ x ].B2ADD = ( uint32_t ) &( xDMARxDescriptors[ x + 1 ] ); - xDMARxDescriptors[ x ].CTRL = ( uint32_t ) RDES_ENH_BS1( ipTOTAL_ETHERNET_FRAME_SIZE ) | RDES_ENH_RCH; - - /* The descriptor is available for use by the DMA. */ - xDMARxDescriptors[ x ].STATUS = RDES_OWN; - } - - /* RDES_ENH_RER Receive End of Ring. */ - xDMARxDescriptors[ ( configNUM_RX_DESCRIPTORS - 1 ) ].CTRL |= RDES_ENH_RER; - xDMARxDescriptors[ configNUM_RX_DESCRIPTORS - 1 ].B2ADD = ( uint32_t ) &( xDMARxDescriptors[ 0 ] ); - - /* Point the DMA to the base of the descriptor list. */ - LPC_ETHERNET->DMA_REC_DES_ADDR = ( uint32_t ) xDMARxDescriptors; -} -/*-----------------------------------------------------------*/ -configPLACE_IN_SECTION_RAM -static void prvRemoveTrailingBytes( NetworkBufferDescriptor_t *pxDescriptor ) -{ -size_t xExpectedLength; -IPPacket_t *pxIPPacket; - - pxIPPacket = ( IPPacket_t * ) pxDescriptor->pucEthernetBuffer; - /* Look at the actual length of the packet, translate it to a host-endial notation. */ - xExpectedLength = sizeof( EthernetHeader_t ) + ( size_t ) FreeRTOS_htons( pxIPPacket->xIPHeader.usLength ); - - if( xExpectedLength == ( pxDescriptor->xDataLength + 4 ) ) - { - pxDescriptor->xDataLength -= 4; - } - else - { - if( pxDescriptor->xDataLength > xExpectedLength ) - { - pxDescriptor->xDataLength = ( size_t ) xExpectedLength; - } - } -} -/*-----------------------------------------------------------*/ -configPLACE_IN_SECTION_RAM -BaseType_t xGetPhyLinkStatus( void ) -{ -BaseType_t xReturn; - - if( ( ulPHYLinkStatus & PHY_LINK_CONNECTED ) == 0 ) - { - xReturn = pdFALSE; - } - else - { - xReturn = pdTRUE; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -configPLACE_IN_SECTION_RAM -static BaseType_t prvNetworkInterfaceInput() -{ -BaseType_t xResult = pdFALSE; -uint32_t ulStatus; -eFrameProcessingResult_t eResult; -const TickType_t xDescriptorWaitTime = pdMS_TO_TICKS( 250 ); -const UBaseType_t uxMinimumBuffersRemaining = 3UL; -uint16_t usLength; -NetworkBufferDescriptor_t *pxDescriptor; -#if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - NetworkBufferDescriptor_t *pxNewDescriptor; -#endif /* ipconfigZERO_COPY_RX_DRIVER */ -IPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL }; - - /* Process each descriptor that is not still in use by the DMA. */ - ulStatus = xDMARxDescriptors[ ulNextRxDescriptorToProcess ].STATUS; - if( ( ulStatus & RDES_OWN ) == 0 ) - { - /* Check packet for errors */ - if( ( ulStatus & nwRX_STATUS_ERROR_BITS ) != 0 ) - { - /* There is some reception error. */ - /* Clear error bits. */ - ulStatus &= ~( ( uint32_t )nwRX_STATUS_ERROR_BITS ); - } - else - { - xResult++; - - eResult = ipCONSIDER_FRAME_FOR_PROCESSING( ( const uint8_t * const ) ( xDMARxDescriptors[ ulNextRxDescriptorToProcess ].B1ADD ) ); - if( eResult == eProcessBuffer ) - { - if( ( ulPHYLinkStatus & PHY_LINK_CONNECTED ) == 0 ) - { - ulPHYLinkStatus |= PHY_LINK_CONNECTED; - FreeRTOS_printf( ( "prvEMACHandlerTask: PHY LS now %d (message received)\n", ( ulPHYLinkStatus & PHY_LINK_CONNECTED ) != 0 ) ); - } - - #if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - if( uxGetNumberOfFreeNetworkBuffers() > uxMinimumBuffersRemaining ) - { - pxNewDescriptor = pxGetNetworkBufferWithDescriptor( ipTOTAL_ETHERNET_FRAME_SIZE, xDescriptorWaitTime ); - } - else - { - /* Too risky to allocate a new Network Buffer. */ - pxNewDescriptor = NULL; - } - if( pxNewDescriptor != NULL ) - #else - if( uxGetNumberOfFreeNetworkBuffers() > uxMinimumBuffersRemaining ) - #endif /* ipconfigZERO_COPY_RX_DRIVER */ - { - #if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - const uint8_t *pucBuffer; - #endif - - /* Get the actual length. */ - usLength = RDES_FLMSK( ulStatus ); - - #if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - /* Replace the character buffer 'B1ADD'. */ - pucBuffer = ( const uint8_t * const ) ( xDMARxDescriptors[ ulNextRxDescriptorToProcess ].B1ADD ); - xDMARxDescriptors[ ulNextRxDescriptorToProcess ].B1ADD = ( uint32_t ) pxNewDescriptor->pucEthernetBuffer; - - /* 'B1ADD' contained the address of a 'pucEthernetBuffer' that - belongs to a Network Buffer. Find the original Network Buffer. */ - pxDescriptor = pxPacketBuffer_to_NetworkBuffer( pucBuffer ); - /* This zero-copy driver makes sure that every 'xDMARxDescriptors' contains - a reference to a Network Buffer at any time. - In case it runs out of Network Buffers, a DMA buffer won't be replaced, - and the received messages is dropped. */ - configASSERT( pxDescriptor != NULL ); - } - #else - { - /* Create a buffer of exactly the required length. */ - pxDescriptor = pxGetNetworkBufferWithDescriptor( usLength, xDescriptorWaitTime ); - } - #endif /* ipconfigZERO_COPY_RX_DRIVER */ - - if( pxDescriptor != NULL ) - { - pxDescriptor->xDataLength = ( size_t ) usLength; - #if( ipconfigZERO_COPY_RX_DRIVER == 0 ) - { - /* Copy the data into the allocated buffer. */ - memcpy( ( void * ) pxDescriptor->pucEthernetBuffer, ( void * ) xDMARxDescriptors[ ulNextRxDescriptorToProcess ].B1ADD, usLength ); - } - #endif /* ipconfigZERO_COPY_RX_DRIVER */ - /* It is possible that more data was copied than - actually makes up the frame. If this is the case - adjust the length to remove any trailing bytes. */ - prvRemoveTrailingBytes( pxDescriptor ); - - /* Pass the data to the TCP/IP task for processing. */ - xRxEvent.pvData = ( void * ) pxDescriptor; - if( xSendEventStructToIPTask( &xRxEvent, xDescriptorWaitTime ) == pdFALSE ) - { - /* Could not send the descriptor into the TCP/IP - stack, it must be released. */ - vReleaseNetworkBufferAndDescriptor( pxDescriptor ); - } - else - { - iptraceNETWORK_INTERFACE_RECEIVE(); - } - } - } - } - /* Got here because received data was sent to the IP task or the - data contained an error and was discarded. Give the descriptor - back to the DMA. */ - xDMARxDescriptors[ ulNextRxDescriptorToProcess ].STATUS = ulStatus | RDES_OWN; - - /* Move onto the next descriptor. */ - ulNextRxDescriptorToProcess++; - if( ulNextRxDescriptorToProcess >= configNUM_RX_DESCRIPTORS ) - { - ulNextRxDescriptorToProcess = 0; - } - - ulStatus = xDMARxDescriptors[ ulNextRxDescriptorToProcess ].STATUS; - } /* if( ( ulStatus & nwRX_STATUS_ERROR_BITS ) != 0 ) */ - } /* if( ( ulStatus & RDES_OWN ) == 0 ) */ - - /* Restart receive polling. */ - LPC_ETHERNET->DMA_REC_POLL_DEMAND = 1; - - return xResult; -} -/*-----------------------------------------------------------*/ - -configPLACE_IN_SECTION_RAM -void NETWORK_IRQHandler( void ) -{ -BaseType_t xHigherPriorityTaskWoken = pdFALSE; -uint32_t ulDMAStatus; -const uint32_t ulRxInterruptMask = - DMA_ST_RI | /* Receive interrupt */ - DMA_ST_RU; /* Receive buffer unavailable */ -const uint32_t ulTxInterruptMask = - DMA_ST_TI | /* Transmit interrupt */ - DMA_ST_TPS; /* Transmit process stopped */ - - configASSERT( xRxHanderTask ); - - /* Get pending interrupts. */ - ulDMAStatus = LPC_ETHERNET->DMA_STAT; - - /* RX group interrupt(s). */ - if( ( ulDMAStatus & ulRxInterruptMask ) != 0x00 ) - { - /* Remember that an RX event has happened. */ - ulISREvents |= EMAC_IF_RX_EVENT; - vTaskNotifyGiveFromISR( xRxHanderTask, &xHigherPriorityTaskWoken ); - } - - /* TX group interrupt(s). */ - if( ( ulDMAStatus & ulTxInterruptMask ) != 0x00 ) - { - /* Remember that a TX event has happened. */ - ulISREvents |= EMAC_IF_TX_EVENT; - vTaskNotifyGiveFromISR( xRxHanderTask, &xHigherPriorityTaskWoken ); - } - - /* Test for 'Abnormal interrupt summary'. */ - if( ( ulDMAStatus & DMA_ST_AIE ) != 0x00 ) - { - /* The trace macro must be written such that it can be called from - an interrupt. */ - iptraceETHERNET_RX_EVENT_LOST(); - } - - /* Clear pending interrupts */ - LPC_ETHERNET->DMA_STAT = ulDMAStatus; - - /* Context switch needed? */ - portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); -} -/*-----------------------------------------------------------*/ - -static BaseType_t prvSetLinkSpeed( void ) -{ -BaseType_t xReturn = pdFAIL; -TickType_t xTimeOnEntering; -uint32_t ulPhyStatus; -const TickType_t xAutoNegotiateDelay = pdMS_TO_TICKS( 5000UL ); - - /* Ensure polling does not starve lower priority tasks by temporarily - setting the priority of this task to that of the idle task. */ - vTaskPrioritySet( NULL, tskIDLE_PRIORITY ); - - xTimeOnEntering = xTaskGetTickCount(); - do - { - ulPhyStatus = lpcPHYStsPoll(); - if( ( ulPhyStatus & PHY_LINK_CONNECTED ) != 0x00 ) - { - /* Set interface speed and duplex. */ - if( ( ulPhyStatus & PHY_LINK_SPEED100 ) != 0x00 ) - { - Chip_ENET_SetSpeed( LPC_ETHERNET, 1 ); - } - else - { - Chip_ENET_SetSpeed( LPC_ETHERNET, 0 ); - } - - if( ( ulPhyStatus & PHY_LINK_FULLDUPLX ) != 0x00 ) - { - Chip_ENET_SetDuplex( LPC_ETHERNET, pdTRUE ); - } - else - { - Chip_ENET_SetDuplex( LPC_ETHERNET, pdFALSE ); - } - - xReturn = pdPASS; - break; - } - } while( ( xTaskGetTickCount() - xTimeOnEntering ) < xAutoNegotiateDelay ); - - /* Reset the priority of this task back to its original value. */ - vTaskPrioritySet( NULL, ipconfigIP_TASK_PRIORITY ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -static uint32_t prvGenerateCRC32( const uint8_t *ucAddress ) -{ -unsigned int j; -const uint32_t Polynomial = 0xEDB88320; -uint32_t crc = ~0ul; -const uint8_t *pucCurrent = ( const uint8_t * ) ucAddress; -const uint8_t *pucLast = pucCurrent + 6; - - /* Calculate normal CRC32 */ - while( pucCurrent < pucLast ) - { - crc ^= *( pucCurrent++ ); - for( j = 0; j < 8; j++ ) - { - if( ( crc & 1 ) != 0 ) - { - crc = (crc >> 1) ^ Polynomial; - } - else - { - crc >>= 1; - } - } - } - return ~crc; -} -/*-----------------------------------------------------------*/ - -static uint32_t prvGetHashIndex( const uint8_t *ucAddress ) -{ -uint32_t ulCrc = prvGenerateCRC32( ucAddress ); -uint32_t ulIndex = 0ul; -BaseType_t xCount = 6; - - /* Take the lowest 6 bits of the CRC32 and reverse them */ - while( xCount-- ) - { - ulIndex <<= 1; - ulIndex |= ( ulCrc & 1 ); - ulCrc >>= 1; - } - - /* This is the has value of 'ucAddress' */ - return ulIndex; -} -/*-----------------------------------------------------------*/ - -static void prvAddMACAddress( const uint8_t* ucMacAddress ) -{ -BaseType_t xIndex; - - xIndex = prvGetHashIndex( ucMacAddress ); - if( xIndex >= 32 ) - { - LPC_ETHERNET->MAC_HASHTABLE_HIGH |= ( 1u << ( xIndex - 32 ) ); - } - else - { - LPC_ETHERNET->MAC_HASHTABLE_LOW |= ( 1u << xIndex ); - } -} -/*-----------------------------------------------------------*/ - -configPLACE_IN_SECTION_RAM -static void prvEMACHandlerTask( void *pvParameters ) -{ -TimeOut_t xPhyTime; -TickType_t xPhyRemTime; -UBaseType_t uxLastMinBufferCount = 0; -UBaseType_t uxCurrentCount; -BaseType_t xResult = 0; -uint32_t ulStatus; -const TickType_t xBlockTime = pdMS_TO_TICKS( 5000ul ); - - /* Remove compiler warning about unused parameter. */ - ( void ) pvParameters; - - /* A possibility to set some additional task properties. */ - iptraceEMAC_TASK_STARTING(); - - vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); - - for( ;; ) - { - uxCurrentCount = uxGetMinimumFreeNetworkBuffers(); - if( uxLastMinBufferCount != uxCurrentCount ) - { - /* The logging produced below may be helpful - while tuning +TCP: see how many buffers are in use. */ - uxLastMinBufferCount = uxCurrentCount; - FreeRTOS_printf( ( "Network buffers: %lu lowest %lu\n", - uxGetNumberOfFreeNetworkBuffers(), uxCurrentCount ) ); - } - - #if( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - { - static UBaseType_t uxLastMinQueueSpace = 0; - - uxCurrentCount = uxGetMinimumIPQueueSpace(); - if( uxLastMinQueueSpace != uxCurrentCount ) - { - /* The logging produced below may be helpful - while tuning +TCP: see how many buffers are in use. */ - uxLastMinQueueSpace = uxCurrentCount; - FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); - } - } - #endif /* ipconfigCHECK_IP_QUEUE_SPACE */ - - ulTaskNotifyTake( pdTRUE, xBlockTime ); - - xResult = ( BaseType_t ) 0; - - if( ( ulISREvents & EMAC_IF_TX_EVENT ) != 0 ) - { - /* Code to release TX buffers if zero-copy is used. */ - ulISREvents &= ~EMAC_IF_TX_EVENT; - { - /* Check if DMA packets have been delivered. */ - vClearTXBuffers(); - } - } - - if( ( ulISREvents & EMAC_IF_RX_EVENT ) != 0 ) - { - ulISREvents &= ~EMAC_IF_RX_EVENT; - - xResult = prvNetworkInterfaceInput(); - if( xResult > 0 ) - { - while( prvNetworkInterfaceInput() > 0 ) - { - } - } - } - - if( xResult > 0 ) - { - /* A packet was received. No need to check for the PHY status now, - but set a timer to check it later on. */ - vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); - xResult = 0; - } - else if( xTaskCheckForTimeOut( &xPhyTime, &xPhyRemTime ) != pdFALSE ) - { - ulStatus = lpcPHYStsPoll(); - - if( ( ulPHYLinkStatus & PHY_LINK_CONNECTED ) != ( ulStatus & PHY_LINK_CONNECTED ) ) - { - ulPHYLinkStatus = ulStatus; - FreeRTOS_printf( ( "prvEMACHandlerTask: PHY LS now %d (polled PHY)\n", ( ulPHYLinkStatus & PHY_LINK_CONNECTED ) != 0 ) ); - } - - vTaskSetTimeOutState( &xPhyTime ); - if( ( ulPHYLinkStatus & PHY_LINK_CONNECTED ) != 0 ) - { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); - } - else - { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); - } - } - } -} -/*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/LPC18xx/ReadMe.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/LPC18xx/ReadMe.txt deleted file mode 100755 index cde8e0e..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/LPC18xx/ReadMe.txt +++ /dev/null @@ -1,3 +0,0 @@ -NetworkInterface.c: -Requires NXP's LPCOpen library and was developed on an LPC1830 and LPC1835 Xplorer -boards from NGX. \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/README_DRIVER_DISCLAIMER.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/README_DRIVER_DISCLAIMER.txt deleted file mode 100755 index d4dc868..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/README_DRIVER_DISCLAIMER.txt +++ /dev/null @@ -1,10 +0,0 @@ -Network drivers are provided as examples only, and do not form part of the -FreeRTOS+TCP stack itself. They: - - + May be based on driver code provided by the chip vendors, - + May not have been tested in all possible configurations, - + Will not necessarily be optimised. - + May have a dependency on a particular PHY part number. - + May not necessarily comply with any particular coding standard. - + May have dependencies on chip company libraries. - + May include other hardware board dependencies. diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/SH2A/NetworkInterface.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/SH2A/NetworkInterface.c deleted file mode 100755 index 64204f1..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/SH2A/NetworkInterface.c +++ /dev/null @@ -1,118 +0,0 @@ -/* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - http://aws.amazon.com/freertos - http://www.FreeRTOS.org -*/ - -/* Standard includes. */ -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_Sockets.h" -#include "NetworkBufferManagement.h" - -/* Hardware includes. */ -#include "hwEthernet.h" - -/* Demo includes. */ -#include "NetworkInterface.h" - -#if ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES != 1 - #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer -#else - #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) ) -#endif - -/* When a packet is ready to be sent, if it cannot be sent immediately then the -task performing the transmit will block for niTX_BUFFER_FREE_WAIT -milliseconds. It will do this a maximum of niMAX_TX_ATTEMPTS before giving -up. */ -#define niTX_BUFFER_FREE_WAIT ( ( TickType_t ) 2UL / portTICK_PERIOD_MS ) -#define niMAX_TX_ATTEMPTS ( 5 ) - -/* The length of the queue used to send interrupt status words from the -interrupt handler to the deferred handler task. */ -#define niINTERRUPT_QUEUE_LENGTH ( 10 ) - -/*-----------------------------------------------------------*/ - -/* - * A deferred interrupt handler task that processes - */ -extern void vEMACHandlerTask( void *pvParameters ); - -/*-----------------------------------------------------------*/ - -/* The queue used to communicate Ethernet events with the IP task. */ -extern QueueHandle_t xNetworkEventQueue; - -/* The semaphore used to wake the deferred interrupt handler task when an Rx -interrupt is received. */ -SemaphoreHandle_t xEMACRxEventSemaphore = NULL; -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceInitialise( void ) -{ -BaseType_t xStatus, xReturn; -extern uint8_t ucMACAddress[ 6 ]; - - /* Initialise the MAC. */ - vInitEmac(); - - while( lEMACWaitForLink() != pdPASS ) - { - vTaskDelay( 20 ); - } - - vSemaphoreCreateBinary( xEMACRxEventSemaphore ); - configASSERT( xEMACRxEventSemaphore ); - - /* The handler task is created at the highest possible priority to - ensure the interrupt handler can return directly to it. */ - xTaskCreate( vEMACHandlerTask, "EMAC", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL ); - xReturn = pdPASS; - - return xReturn; -} -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer ) -{ -extern void vEMACCopyWrite( uint8_t * pucBuffer, uint16_t usLength ); - - vEMACCopyWrite( pxNetworkBuffer->pucBuffer, pxNetworkBuffer->xDataLength ); - - /* Finished with the network buffer. */ - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - - return pdTRUE; -} -/*-----------------------------------------------------------*/ - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32F7xx/NetworkInterface.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32F7xx/NetworkInterface.c deleted file mode 100755 index a68ed11..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32F7xx/NetworkInterface.c +++ /dev/null @@ -1,1193 +0,0 @@ -/* - * Some constants, hardware definitions and comments taken from ST's HAL driver - * library, COPYRIGHT(c) 2015 STMicroelectronics. - */ - -/* - * FreeRTOS+TCP V2.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ - -/* Standard includes. */ -#include -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "FreeRTOS_DNS.h" -#include "NetworkBufferManagement.h" -#include "NetworkInterface.h" - -#include "phyHandling.h" - -/* ST includes. */ -#ifdef STM32F7xx - #include "stm32f7xx_hal.h" -#else - #include "stm32f4xx_hal.h" -#endif - -/* Interrupt events to process. Currently only the Rx event is processed -although code for other events is included to allow for possible future -expansion. */ -#define EMAC_IF_RX_EVENT 1UL -#define EMAC_IF_TX_EVENT 2UL -#define EMAC_IF_ERR_EVENT 4UL -#define EMAC_IF_ALL_EVENT ( EMAC_IF_RX_EVENT | EMAC_IF_TX_EVENT | EMAC_IF_ERR_EVENT ) - -#define ETH_DMA_ALL_INTS \ - ( ETH_DMA_IT_TST | ETH_DMA_IT_PMT | ETH_DMA_IT_MMC | ETH_DMA_IT_NIS | ETH_DMA_IT_ER | \ - ETH_DMA_IT_FBE | ETH_DMA_IT_RWT | ETH_DMA_IT_RPS | ETH_DMA_IT_RBU | ETH_DMA_IT_R | \ - ETH_DMA_IT_TU | ETH_DMA_IT_RO | ETH_DMA_IT_TJT | ETH_DMA_IT_TPS | ETH_DMA_IT_T ) - - - -#define ipFRAGMENT_OFFSET_BIT_MASK ( ( uint16_t ) 0x0fff ) /* The bits in the two byte IP header field that make up the fragment offset value. */ - -/* - * Most users will want a PHY that negotiates about - * the connection properties: speed, dmix and duplex. - * On some rare cases, you want to select what is being - * advertised, properties like MDIX and duplex. - */ - -#if !defined( ipconfigETHERNET_AN_ENABLE ) - /* Enable auto-negotiation */ - #define ipconfigETHERNET_AN_ENABLE 1 -#endif - -#if !defined( ipconfigETHERNET_AUTO_CROSS_ENABLE ) - #define ipconfigETHERNET_AUTO_CROSS_ENABLE 1 -#endif - -#if( ipconfigETHERNET_AN_ENABLE == 0 ) - /* - * The following three defines are only used in case there - * is no auto-negotiation. - */ - #if !defined( ipconfigETHERNET_CROSSED_LINK ) - #define ipconfigETHERNET_CROSSED_LINK 1 - #endif - - #if !defined( ipconfigETHERNET_USE_100MB ) - #define ipconfigETHERNET_USE_100MB 1 - #endif - - #if !defined( ipconfigETHERNET_USE_FULL_DUPLEX ) - #define ipconfigETHERNET_USE_FULL_DUPLEX 1 - #endif -#endif /* ipconfigETHERNET_AN_ENABLE == 0 */ - -/* Default the size of the stack used by the EMAC deferred handler task to twice -the size of the stack used by the idle task - but allow this to be overridden in -FreeRTOSConfig.h as configMINIMAL_STACK_SIZE is a user definable constant. */ -#ifndef configEMAC_TASK_STACK_SIZE - #define configEMAC_TASK_STACK_SIZE ( 2 * configMINIMAL_STACK_SIZE ) -#endif - -/* Two choices must be made: RMII versus MII, -and the index of the PHY in use ( between 0 and 31 ). */ -#ifndef ipconfigUSE_RMII - #ifdef STM32F7xx - #define ipconfigUSE_RMII 1 - #else - #define ipconfigUSE_RMII 0 - #endif /* STM32F7xx */ -#endif /* ipconfigUSE_RMII */ - -#ifndef ipconfigPHY_INDEX - #ifdef STM32F7xx - #define ipconfigPHY_INDEX 0 - #else - #define ipconfigPHY_INDEX 1 - #endif /* STM32F7xx */ -#endif /* ipconfigPHY_INDEX */ - - -/*-----------------------------------------------------------*/ - -/* - * A deferred interrupt handler task that processes - */ -static void prvEMACHandlerTask( void *pvParameters ); - -/* - * Force a negotiation with the Switch or Router and wait for LS. - */ -static void prvEthernetUpdateConfig( BaseType_t xForce ); - -/* - * See if there is a new packet and forward it to the IP-task. - */ -static BaseType_t prvNetworkInterfaceInput( void ); - -#if( ipconfigUSE_LLMNR != 0 ) - /* - * For LLMNR, an extra MAC-address must be configured to - * be able to receive the multicast messages. - */ - static void prvMACAddressConfig(ETH_HandleTypeDef *heth, uint32_t ulIndex, uint8_t *Addr); -#endif - -/* - * Check if a given packet should be accepted. - */ -static BaseType_t xMayAcceptPacket( uint8_t *pcBuffer ); - -/* - * Initialise the TX descriptors. - */ -static void prvDMATxDescListInit( void ); - -/* - * Initialise the RX descriptors. - */ -static void prvDMARxDescListInit( void ); - -/* After packets have been sent, the network -buffers will be released. */ -static void vClearTXBuffers( void ); - -/*-----------------------------------------------------------*/ - -/* Bit map of outstanding ETH interrupt events for processing. Currently only -the Rx interrupt is handled, although code is included for other events to -enable future expansion. */ -static volatile uint32_t ulISREvents; - -#if( ipconfigUSE_LLMNR == 1 ) - static const uint8_t xLLMNR_MACAddress[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0xFC }; -#endif - -static EthernetPhy_t xPhyObject; - -/* Ethernet handle. */ -static ETH_HandleTypeDef xETH; - -/* xTXDescriptorSemaphore is a counting semaphore with -a maximum count of ETH_TXBUFNB, which is the number of -DMA TX descriptors. */ -static SemaphoreHandle_t xTXDescriptorSemaphore = NULL; - -/* - * Note: it is adviced to define both - * - * #define ipconfigZERO_COPY_RX_DRIVER 1 - * #define ipconfigZERO_COPY_TX_DRIVER 1 - * - * The method using memcpy is slower and probaly uses more RAM memory. - * The possibility is left in the code just for comparison. - * - * It is adviced to define ETH_TXBUFNB at least 4. Note that no - * TX buffers are allocated in a zero-copy driver. - */ -/* MAC buffers: ---------------------------------------------------------*/ - -/* Put the DMA descriptors in '.first_data'. -This is important for STM32F7, which has an L1 data cache. -The first 64KB of the SRAM is not cached. */ - -/* Ethernet Rx MA Descriptor */ -__attribute__ ((aligned (32))) -__attribute__ ((section(".first_data"))) - ETH_DMADescTypeDef DMARxDscrTab[ ETH_RXBUFNB ]; - -#if( ipconfigZERO_COPY_RX_DRIVER == 0 ) - /* Ethernet Receive Buffer */ - __ALIGN_BEGIN uint8_t Rx_Buff[ ETH_RXBUFNB ][ ETH_RX_BUF_SIZE ] __ALIGN_END; -#endif - -/* Ethernet Tx DMA Descriptor */ -__attribute__ ((aligned (32))) -__attribute__ ((section(".first_data"))) - ETH_DMADescTypeDef DMATxDscrTab[ ETH_TXBUFNB ]; - -#if( ipconfigZERO_COPY_TX_DRIVER == 0 ) - /* Ethernet Transmit Buffer */ - __ALIGN_BEGIN uint8_t Tx_Buff[ ETH_TXBUFNB ][ ETH_TX_BUF_SIZE ] __ALIGN_END; -#endif - -#if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - /* DMATxDescToClear points to the next TX DMA descriptor - that must be cleared by vClearTXBuffers(). */ - static __IO ETH_DMADescTypeDef *DMATxDescToClear; -#endif - -/* ucMACAddress as it appears in main.c */ -extern const uint8_t ucMACAddress[ 6 ]; - -/* Holds the handle of the task used as a deferred interrupt processor. The -handle is used so direct notifications can be sent to the task for all EMAC/DMA -related interrupts. */ -static TaskHandle_t xEMACTaskHandle = NULL; - -/* For local use only: describe the PHY's properties: */ -const PhyProperties_t xPHYProperties = -{ - #if( ipconfigETHERNET_AN_ENABLE != 0 ) - .ucSpeed = PHY_SPEED_AUTO, - .ucDuplex = PHY_DUPLEX_AUTO, - #else - #if( ipconfigETHERNET_USE_100MB != 0 ) - .ucSpeed = PHY_SPEED_100, - #else - .ucSpeed = PHY_SPEED_10, - #endif - - #if( ipconfigETHERNET_USE_FULL_DUPLEX != 0 ) - .duplex = PHY_DUPLEX_FULL, - #else - .duplex = PHY_DUPLEX_HALF, - #endif - #endif - - #if( ipconfigETHERNET_AN_ENABLE != 0 ) && ( ipconfigETHERNET_AUTO_CROSS_ENABLE != 0 ) - .ucMDI_X = PHY_MDIX_AUTO, - #elif( ipconfigETHERNET_CROSSED_LINK != 0 ) - .ucMDI_X = PHY_MDIX_CROSSED, - #else - .ucMDI_X = PHY_MDIX_DIRECT, - #endif -}; - -/*-----------------------------------------------------------*/ - -void HAL_ETH_RxCpltCallback( ETH_HandleTypeDef *heth ) -{ -BaseType_t xHigherPriorityTaskWoken = pdFALSE; - - /* Ethernet RX-Complete callback function, elsewhere declared as weak. */ - ulISREvents |= EMAC_IF_RX_EVENT; - /* Wakeup the prvEMACHandlerTask. */ - if( xEMACTaskHandle != NULL ) - { - vTaskNotifyGiveFromISR( xEMACTaskHandle, &xHigherPriorityTaskWoken ); - portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); - } -} -/*-----------------------------------------------------------*/ - -void HAL_ETH_TxCpltCallback( ETH_HandleTypeDef *heth ) -{ -BaseType_t xHigherPriorityTaskWoken = pdFALSE; - - /* This call-back is only useful in case packets are being sent - zero-copy. Once they're sent, the buffers will be released - by the function vClearTXBuffers(). */ - ulISREvents |= EMAC_IF_TX_EVENT; - /* Wakeup the prvEMACHandlerTask. */ - if( xEMACTaskHandle != NULL ) - { - vTaskNotifyGiveFromISR( xEMACTaskHandle, &xHigherPriorityTaskWoken ); - portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); - } - -} -/*-----------------------------------------------------------*/ - -static void vClearTXBuffers() -{ -__IO ETH_DMADescTypeDef *txLastDescriptor = xETH.TxDesc; -size_t uxCount = ( ( UBaseType_t ) ETH_TXBUFNB ) - uxSemaphoreGetCount( xTXDescriptorSemaphore ); -#if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - NetworkBufferDescriptor_t *pxNetworkBuffer; - uint8_t *ucPayLoad; -#endif - - /* This function is called after a TX-completion interrupt. - It will release each Network Buffer used in xNetworkInterfaceOutput(). - 'uxCount' represents the number of descriptors given to DMA for transmission. - After sending a packet, the DMA will clear the 'ETH_DMATXDESC_OWN' bit. */ - while( ( uxCount > 0 ) && ( ( DMATxDescToClear->Status & ETH_DMATXDESC_OWN ) == 0 ) ) - { - if( ( DMATxDescToClear == txLastDescriptor ) && ( uxCount != ETH_TXBUFNB ) ) - { - break; - } - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - ucPayLoad = ( uint8_t * )DMATxDescToClear->Buffer1Addr; - - if( ucPayLoad != NULL ) - { - pxNetworkBuffer = pxPacketBuffer_to_NetworkBuffer( ucPayLoad ); - if( pxNetworkBuffer != NULL ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ) ; - } - DMATxDescToClear->Buffer1Addr = ( uint32_t )0u; - } - } - #endif /* ipconfigZERO_COPY_TX_DRIVER */ - - DMATxDescToClear = ( ETH_DMADescTypeDef * )( DMATxDescToClear->Buffer2NextDescAddr ); - - uxCount--; - /* Tell the counting semaphore that one more TX descriptor is available. */ - xSemaphoreGive( xTXDescriptorSemaphore ); - } -} -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceInitialise( void ) -{ -HAL_StatusTypeDef hal_eth_init_status; -BaseType_t xResult; - - if( xEMACTaskHandle == NULL ) - { - if( xTXDescriptorSemaphore == NULL ) - { - xTXDescriptorSemaphore = xSemaphoreCreateCounting( ( UBaseType_t ) ETH_TXBUFNB, ( UBaseType_t ) ETH_TXBUFNB ); - configASSERT( xTXDescriptorSemaphore ); - } - - /* Initialise ETH */ - - xETH.Instance = ETH; -//#warning Enable auto-nego again - xETH.Init.AutoNegotiation = ETH_AUTONEGOTIATION_ENABLE; -// xETH.Init.AutoNegotiation = ETH_AUTONEGOTIATION_DISABLE; - xETH.Init.Speed = ETH_SPEED_100M; - xETH.Init.DuplexMode = ETH_MODE_FULLDUPLEX; - xETH.Init.PhyAddress = ipconfigPHY_INDEX; - - xETH.Init.MACAddr = ( uint8_t *) ucMACAddress; - xETH.Init.RxMode = ETH_RXINTERRUPT_MODE; - - /* using the ETH_CHECKSUM_BY_HARDWARE option: - both the IP and the protocol checksums will be calculated - by the peripheral. */ - xETH.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE; - - #if( ipconfigUSE_RMII != 0 ) - { - xETH.Init.MediaInterface = ETH_MEDIA_INTERFACE_RMII; - } - #else - { - xETH.Init.MediaInterface = ETH_MEDIA_INTERFACE_MII; - } - #endif /* ipconfigUSE_RMII */ - - hal_eth_init_status = HAL_ETH_Init( &xETH ); - - /* Only for inspection by debugger. */ - ( void ) hal_eth_init_status; - - /* Set the TxDesc and RxDesc pointers. */ - xETH.TxDesc = DMATxDscrTab; - xETH.RxDesc = DMARxDscrTab; - - /* Make sure that all unused fields are cleared. */ - memset( &DMATxDscrTab, '\0', sizeof( DMATxDscrTab ) ); - memset( &DMARxDscrTab, '\0', sizeof( DMARxDscrTab ) ); - - /* Initialize Tx Descriptors list: Chain Mode */ - DMATxDescToClear = DMATxDscrTab; - - /* Initialise TX-descriptors. */ - prvDMATxDescListInit(); - - /* Initialise RX-descriptors. */ - prvDMARxDescListInit(); - - #if( ipconfigUSE_LLMNR != 0 ) - { - /* Program the LLMNR address at index 1. */ - prvMACAddressConfig( &xETH, ETH_MAC_ADDRESS1, ( uint8_t *) xLLMNR_MACAddress ); - } - #endif - - /* Force a negotiation with the Switch or Router and wait for LS. */ - prvEthernetUpdateConfig( pdTRUE ); - - /* The deferred interrupt handler task is created at the highest - possible priority to ensure the interrupt handler can return directly - to it. The task's handle is stored in xEMACTaskHandle so interrupts can - notify the task when there is something to process. */ - xTaskCreate( prvEMACHandlerTask, "EMAC", configEMAC_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, &xEMACTaskHandle ); - } /* if( xEMACTaskHandle == NULL ) */ - - if( xPhyObject.ulLinkStatusMask != 0 ) - { - xETH.Instance->DMAIER |= ETH_DMA_ALL_INTS; - xResult = pdPASS; - FreeRTOS_printf( ( "Link Status is high\n" ) ) ; - } - else - { - /* For now pdFAIL will be returned. But prvEMACHandlerTask() is running - and it will keep on checking the PHY and set 'ulLinkStatusMask' when necessary. */ - xResult = pdFAIL; - FreeRTOS_printf( ( "Link Status still low\n" ) ) ; - } - /* When returning non-zero, the stack will become active and - start DHCP (in configured) */ - return xResult; -} -/*-----------------------------------------------------------*/ - -static void prvDMATxDescListInit() -{ -ETH_DMADescTypeDef *pxDMADescriptor; -BaseType_t xIndex; - - /* Get the pointer on the first member of the descriptor list */ - pxDMADescriptor = DMATxDscrTab; - - /* Fill each DMA descriptor with the right values */ - for( xIndex = 0; xIndex < ETH_TXBUFNB; xIndex++, pxDMADescriptor++ ) - { - /* Set Second Address Chained bit */ - pxDMADescriptor->Status = ETH_DMATXDESC_TCH; - - #if( ipconfigZERO_COPY_TX_DRIVER == 0 ) - { - /* Set Buffer1 address pointer */ - pxDMADescriptor->Buffer1Addr = ( uint32_t )( Tx_Buff[ xIndex ] ); - } - #endif - - if( xETH.Init.ChecksumMode == ETH_CHECKSUM_BY_HARDWARE ) - { - /* Set the DMA Tx descriptors checksum insertion for TCP, UDP, and ICMP */ - pxDMADescriptor->Status |= ETH_DMATXDESC_CHECKSUMTCPUDPICMPFULL; - } - - /* Initialize the next descriptor with the Next Descriptor Polling Enable */ - if( xIndex < ETH_TXBUFNB - 1 ) - { - /* Set next descriptor address register with next descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = ( uint32_t ) ( pxDMADescriptor + 1 ); - } - else - { - /* For last descriptor, set next descriptor address register equal to the first descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = ( uint32_t ) DMATxDscrTab; - } - } - - /* Set Transmit Descriptor List Address Register */ - xETH.Instance->DMATDLAR = ( uint32_t ) DMATxDscrTab; -} -/*-----------------------------------------------------------*/ - -static void prvDMARxDescListInit() -{ -ETH_DMADescTypeDef *pxDMADescriptor; -BaseType_t xIndex; - /* - * RX-descriptors. - */ - - /* Get the pointer on the first member of the descriptor list */ - pxDMADescriptor = DMARxDscrTab; - - /* Fill each DMA descriptor with the right values */ - for( xIndex = 0; xIndex < ETH_RXBUFNB; xIndex++, pxDMADescriptor++ ) - { - - /* Set Buffer1 size and Second Address Chained bit */ - pxDMADescriptor->ControlBufferSize = ETH_DMARXDESC_RCH | (uint32_t)ETH_RX_BUF_SIZE; - - #if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - /* Set Buffer1 address pointer */ - NetworkBufferDescriptor_t *pxBuffer; - - pxBuffer = pxGetNetworkBufferWithDescriptor( ETH_RX_BUF_SIZE, 100ul ); - /* If the assert below fails, make sure that there are at least 'ETH_RXBUFNB' - Network Buffers available during start-up ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ) */ - configASSERT( pxBuffer != NULL ); - if( pxBuffer != NULL ) - { - pxDMADescriptor->Buffer1Addr = (uint32_t)pxBuffer->pucEthernetBuffer; - pxDMADescriptor->Status = ETH_DMARXDESC_OWN; - } - } - #else - { - /* Set Buffer1 address pointer */ - pxDMADescriptor->Buffer1Addr = ( uint32_t )( Rx_Buff[ xIndex ] ); - /* Set Own bit of the Rx descriptor Status */ - pxDMADescriptor->Status = ETH_DMARXDESC_OWN; - } - #endif - - /* Initialize the next descriptor with the Next Descriptor Polling Enable */ - if( xIndex < ETH_RXBUFNB - 1 ) - { - /* Set next descriptor address register with next descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = ( uint32_t )( pxDMADescriptor + 1 ); - } - else - { - /* For last descriptor, set next descriptor address register equal to the first descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = ( uint32_t ) DMARxDscrTab; - } - - } - /* Set Receive Descriptor List Address Register */ - xETH.Instance->DMARDLAR = ( uint32_t ) DMARxDscrTab; -} -/*-----------------------------------------------------------*/ - -static void prvMACAddressConfig(ETH_HandleTypeDef *heth, uint32_t ulIndex, uint8_t *Addr) -{ -uint32_t ulTempReg; - - /* Calculate the selected MAC address high register. */ - ulTempReg = 0x80000000ul | ( ( uint32_t ) Addr[ 5 ] << 8 ) | ( uint32_t ) Addr[ 4 ]; - - /* Load the selected MAC address high register. */ - ( *(__IO uint32_t *)( ( uint32_t ) ( ETH_MAC_ADDR_HBASE + ulIndex ) ) ) = ulTempReg; - - /* Calculate the selected MAC address low register. */ - ulTempReg = ( ( uint32_t ) Addr[ 3 ] << 24 ) | ( ( uint32_t ) Addr[ 2 ] << 16 ) | ( ( uint32_t ) Addr[ 1 ] << 8 ) | Addr[ 0 ]; - - /* Load the selected MAC address low register */ - ( *(__IO uint32_t *) ( ( uint32_t ) ( ETH_MAC_ADDR_LBASE + ulIndex ) ) ) = ulTempReg; -} -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescriptor, BaseType_t bReleaseAfterSend ) -{ -BaseType_t xReturn = pdFAIL; -uint32_t ulTransmitSize = 0; -__IO ETH_DMADescTypeDef *pxDmaTxDesc; -/* Do not wait too long for a free TX DMA buffer. */ -const TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 50u ); - - #if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 ) - { - ProtocolPacket_t *pxPacket; - - #if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - configASSERT( bReleaseAfterSend != 0 ); - } - #endif /* ipconfigZERO_COPY_RX_DRIVER */ - - /* If the peripheral must calculate the checksum, it wants - the protocol checksum to have a value of zero. */ - pxPacket = ( ProtocolPacket_t * ) ( pxDescriptor->pucEthernetBuffer ); - - if( pxPacket->xICMPPacket.xIPHeader.ucProtocol == ipPROTOCOL_ICMP ) - { - pxPacket->xICMPPacket.xICMPHeader.usChecksum = ( uint16_t )0u; - } - } - #endif - - /* Open a do {} while ( 0 ) loop to be able to call break. */ - do - { - if( xPhyObject.ulLinkStatusMask != 0 ) - { - if( xSemaphoreTake( xTXDescriptorSemaphore, xBlockTimeTicks ) != pdPASS ) - { - /* Time-out waiting for a free TX descriptor. */ - break; - } - - /* This function does the actual transmission of the packet. The packet is - contained in 'pxDescriptor' that is passed to the function. */ - pxDmaTxDesc = xETH.TxDesc; - - /* Is this buffer available? */ - configASSERT ( ( pxDmaTxDesc->Status & ETH_DMATXDESC_OWN ) == 0 ); - - { - /* Is this buffer available? */ - /* Get bytes in current buffer. */ - ulTransmitSize = pxDescriptor->xDataLength; - - if( ulTransmitSize > ETH_TX_BUF_SIZE ) - { - ulTransmitSize = ETH_TX_BUF_SIZE; - } - - #if( ipconfigZERO_COPY_TX_DRIVER == 0 ) - { - /* Copy the bytes. */ - memcpy( ( void * ) pxDmaTxDesc->Buffer1Addr, pxDescriptor->pucEthernetBuffer, ulTransmitSize ); - } - #else - { - /* Move the buffer. */ - pxDmaTxDesc->Buffer1Addr = ( uint32_t )pxDescriptor->pucEthernetBuffer; - /* The Network Buffer has been passed to DMA, no need to release it. */ - bReleaseAfterSend = pdFALSE_UNSIGNED; - } - #endif /* ipconfigZERO_COPY_TX_DRIVER */ - - /* Ask to set the IPv4 checksum. - Also need an Interrupt on Completion so that 'vClearTXBuffers()' will be called.. */ - pxDmaTxDesc->Status |= ETH_DMATXDESC_CIC_TCPUDPICMP_FULL | ETH_DMATXDESC_IC; - - /* Prepare transmit descriptors to give to DMA. */ - - /* Set LAST and FIRST segment */ - pxDmaTxDesc->Status |= ETH_DMATXDESC_FS | ETH_DMATXDESC_LS; - /* Set frame size */ - pxDmaTxDesc->ControlBufferSize = ( ulTransmitSize & ETH_DMATXDESC_TBS1 ); - /* Set Own bit of the Tx descriptor Status: gives the buffer back to ETHERNET DMA */ - pxDmaTxDesc->Status |= ETH_DMATXDESC_OWN; - - /* Point to next descriptor */ - xETH.TxDesc = ( ETH_DMADescTypeDef * ) ( xETH.TxDesc->Buffer2NextDescAddr ); - /* Ensure completion of memory access */ - __DSB(); - /* Resume DMA transmission*/ - xETH.Instance->DMATPDR = 0; - iptraceNETWORK_INTERFACE_TRANSMIT(); - xReturn = pdPASS; - } - } - else - { - /* The PHY has no Link Status, packet shall be dropped. */ - } - } while( 0 ); - /* The buffer has been sent so can be released. */ - if( bReleaseAfterSend != pdFALSE ) - { - vReleaseNetworkBufferAndDescriptor( pxDescriptor ); - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -static BaseType_t xMayAcceptPacket( uint8_t *pcBuffer ) -{ -const ProtocolPacket_t *pxProtPacket = ( const ProtocolPacket_t * )pcBuffer; - - switch( pxProtPacket->xTCPPacket.xEthernetHeader.usFrameType ) - { - case ipARP_FRAME_TYPE: - /* Check it later. */ - return pdTRUE; - case ipIPv4_FRAME_TYPE: - /* Check it here. */ - break; - default: - /* Refuse the packet. */ - return pdFALSE; - } - - #if( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 ) - { - const IPHeader_t *pxIPHeader = &(pxProtPacket->xTCPPacket.xIPHeader); - uint32_t ulDestinationIPAddress; - - /* Ensure that the incoming packet is not fragmented (only outgoing packets - * can be fragmented) as these are the only handled IP frames currently. */ - if( ( pxIPHeader->usFragmentOffset & FreeRTOS_ntohs( ipFRAGMENT_OFFSET_BIT_MASK ) ) != 0U ) - { - return pdFALSE; - } - /* HT: Might want to make the following configurable because - * most IP messages have a standard length of 20 bytes */ - - /* 0x45 means: IPv4 with an IP header of 5 x 4 = 20 bytes - * 0x47 means: IPv4 with an IP header of 7 x 4 = 28 bytes */ - if( pxIPHeader->ucVersionHeaderLength < 0x45 || pxIPHeader->ucVersionHeaderLength > 0x4F ) - { - return pdFALSE; - } - - ulDestinationIPAddress = pxIPHeader->ulDestinationIPAddress; - /* Is the packet for this node? */ - if( ( ulDestinationIPAddress != *ipLOCAL_IP_ADDRESS_POINTER ) && - /* Is it a broadcast address x.x.x.255 ? */ - ( ( FreeRTOS_ntohl( ulDestinationIPAddress ) & 0xff ) != 0xff ) && - #if( ipconfigUSE_LLMNR == 1 ) - ( ulDestinationIPAddress != ipLLMNR_IP_ADDR ) && - #endif - ( *ipLOCAL_IP_ADDRESS_POINTER != 0 ) ) { - FreeRTOS_printf( ( "Drop IP %lxip\n", FreeRTOS_ntohl( ulDestinationIPAddress ) ) ); - return pdFALSE; - } - - if( pxIPHeader->ucProtocol == ipPROTOCOL_UDP ) - { - uint16_t port = pxProtPacket->xUDPPacket.xUDPHeader.usDestinationPort; - - if( ( xPortHasUDPSocket( port ) == pdFALSE ) - #if ipconfigUSE_LLMNR == 1 - && ( port != FreeRTOS_ntohs( ipLLMNR_PORT ) ) - #endif - #if ipconfigUSE_NBNS == 1 - && ( port != FreeRTOS_ntohs( ipNBNS_PORT ) ) - #endif - #if ipconfigUSE_DNS == 1 - && ( pxProtPacket->xUDPPacket.xUDPHeader.usSourcePort != FreeRTOS_ntohs( ipDNS_PORT ) ) - #endif - ) { - /* Drop this packet, not for this device. */ - return pdFALSE; - } - } - } - #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ - return pdTRUE; -} -/*-----------------------------------------------------------*/ - -static BaseType_t prvNetworkInterfaceInput( void ) -{ -NetworkBufferDescriptor_t *pxCurDescriptor; -NetworkBufferDescriptor_t *pxNewDescriptor = NULL; -BaseType_t xReceivedLength, xAccepted; -__IO ETH_DMADescTypeDef *pxDMARxDescriptor; -xIPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL }; -const TickType_t xDescriptorWaitTime = pdMS_TO_TICKS( 250 ); -uint8_t *pucBuffer; - - pxDMARxDescriptor = xETH.RxDesc; - - if( ( pxDMARxDescriptor->Status & ETH_DMARXDESC_OWN) == 0 ) - { - /* Get the Frame Length of the received packet: substruct 4 bytes of the CRC */ - xReceivedLength = ( ( pxDMARxDescriptor->Status & ETH_DMARXDESC_FL ) >> ETH_DMARXDESC_FRAMELENGTHSHIFT ) - 4; - - pucBuffer = (uint8_t *) pxDMARxDescriptor->Buffer1Addr; - - /* Update the ETHERNET DMA global Rx descriptor with next Rx descriptor */ - /* Chained Mode */ - /* Selects the next DMA Rx descriptor list for next buffer to read */ - xETH.RxDesc = ( ETH_DMADescTypeDef* )pxDMARxDescriptor->Buffer2NextDescAddr; - } - else - { - xReceivedLength = 0; - } - - /* Obtain the size of the packet and put it into the "usReceivedLength" variable. */ - - /* get received frame */ - if( xReceivedLength > 0ul ) - { - /* In order to make the code easier and faster, only packets in a single buffer - will be accepted. This can be done by making the buffers large enough to - hold a complete Ethernet packet (1536 bytes). - Therefore, two sanity checks: */ - configASSERT( xReceivedLength <= ETH_RX_BUF_SIZE ); - - if( ( pxDMARxDescriptor->Status & ( ETH_DMARXDESC_CE | ETH_DMARXDESC_IPV4HCE | ETH_DMARXDESC_FT ) ) != ETH_DMARXDESC_FT ) - { - /* Not an Ethernet frame-type or a checmsum error. */ - xAccepted = pdFALSE; - } - else - { - /* See if this packet must be handled. */ - xAccepted = xMayAcceptPacket( pucBuffer ); - } - - if( xAccepted != pdFALSE ) - { - /* The packet wil be accepted, but check first if a new Network Buffer can - be obtained. If not, the packet will still be dropped. */ - pxNewDescriptor = pxGetNetworkBufferWithDescriptor( ETH_RX_BUF_SIZE, xDescriptorWaitTime ); - - if( pxNewDescriptor == NULL ) - { - /* A new descriptor can not be allocated now. This packet will be dropped. */ - xAccepted = pdFALSE; - } - } - #if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - /* Find out which Network Buffer was originally passed to the descriptor. */ - pxCurDescriptor = pxPacketBuffer_to_NetworkBuffer( pucBuffer ); - configASSERT( pxCurDescriptor != NULL ); - } - #else - { - /* In this mode, the two descriptors are the same. */ - pxCurDescriptor = pxNewDescriptor; - if( pxNewDescriptor != NULL ) - { - /* The packet is acepted and a new Network Buffer was created, - copy data to the Network Bufffer. */ - memcpy( pxNewDescriptor->pucEthernetBuffer, pucBuffer, xReceivedLength ); - } - } - #endif - - if( xAccepted != pdFALSE ) - { - pxCurDescriptor->xDataLength = xReceivedLength; - xRxEvent.pvData = ( void * ) pxCurDescriptor; - - /* Pass the data to the TCP/IP task for processing. */ - if( xSendEventStructToIPTask( &xRxEvent, xDescriptorWaitTime ) == pdFALSE ) - { - /* Could not send the descriptor into the TCP/IP stack, it - must be released. */ - vReleaseNetworkBufferAndDescriptor( pxCurDescriptor ); - iptraceETHERNET_RX_EVENT_LOST(); - } - else - { - iptraceNETWORK_INTERFACE_RECEIVE(); - } - } - - /* Release descriptors to DMA */ - #if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - /* Set Buffer1 address pointer */ - if( pxNewDescriptor != NULL ) - { - pxDMARxDescriptor->Buffer1Addr = (uint32_t)pxNewDescriptor->pucEthernetBuffer; - } - else - { - /* The packet was dropped and the same Network - Buffer will be used to receive a new packet. */ - } - } - #endif /* ipconfigZERO_COPY_RX_DRIVER */ - - /* Set Buffer1 size and Second Address Chained bit */ - pxDMARxDescriptor->ControlBufferSize = ETH_DMARXDESC_RCH | (uint32_t)ETH_RX_BUF_SIZE; - pxDMARxDescriptor->Status = ETH_DMARXDESC_OWN; - - /* Ensure completion of memory access */ - __DSB(); - /* When Rx Buffer unavailable flag is set clear it and resume - reception. */ - if( ( xETH.Instance->DMASR & ETH_DMASR_RBUS ) != 0 ) - { - /* Clear RBUS ETHERNET DMA flag. */ - xETH.Instance->DMASR = ETH_DMASR_RBUS; - - /* Resume DMA reception. */ - xETH.Instance->DMARPDR = 0; - } - } - - return ( xReceivedLength > 0 ); -} -/*-----------------------------------------------------------*/ - - -BaseType_t xSTM32_PhyRead( BaseType_t xAddress, BaseType_t xRegister, uint32_t *pulValue ) -{ -uint16_t usPrevAddress = xETH.Init.PhyAddress; -BaseType_t xResult; -HAL_StatusTypeDef xHALResult; - - xETH.Init.PhyAddress = xAddress; - xHALResult = HAL_ETH_ReadPHYRegister( &xETH, ( uint16_t )xRegister, pulValue ); - xETH.Init.PhyAddress = usPrevAddress; - - if( xHALResult == HAL_OK ) - { - xResult = 0; - } - else - { - xResult = -1; - } - return xResult; -} -/*-----------------------------------------------------------*/ - -BaseType_t xSTM32_PhyWrite( BaseType_t xAddress, BaseType_t xRegister, uint32_t ulValue ) -{ -uint16_t usPrevAddress = xETH.Init.PhyAddress; -BaseType_t xResult; -HAL_StatusTypeDef xHALResult; - - xETH.Init.PhyAddress = xAddress; - xHALResult = HAL_ETH_WritePHYRegister( &xETH, ( uint16_t )xRegister, ulValue ); - xETH.Init.PhyAddress = usPrevAddress; - - if( xHALResult == HAL_OK ) - { - xResult = 0; - } - else - { - xResult = -1; - } - return xResult; -} -/*-----------------------------------------------------------*/ - -void phy_test() -{ -BaseType_t xPhyCount; -BaseType_t xPhyIndex; - - vPhyInitialise( &xPhyObject, xSTM32_PhyRead, xSTM32_PhyWrite ); - xPhyCount = xPhyDiscover( &xPhyObject ); - FreeRTOS_printf( ( "PHY count %ld\n", xPhyCount ) ); - for( xPhyIndex = 0; xPhyIndex < xPhyCount; xPhyIndex++ ) - { - FreeRTOS_printf( ( "PHY[%d] at address %d ( 0x%08X )\n", - xPhyIndex, - xPhyObject.ucPhyIndexes[ xPhyIndex ], - xPhyObject.ulPhyIDs[ xPhyIndex ] ) ); - - } - -} - -void vMACBProbePhy( void ) -{ - vPhyInitialise( &xPhyObject, xSTM32_PhyRead, xSTM32_PhyWrite ); - xPhyDiscover( &xPhyObject ); - xPhyConfigure( &xPhyObject, &xPHYProperties ); -} -/*-----------------------------------------------------------*/ - -static void prvEthernetUpdateConfig( BaseType_t xForce ) -{ - FreeRTOS_printf( ( "prvEthernetUpdateConfig: LS mask %02X Force %d\n", - xPhyObject.ulLinkStatusMask, - ( int )xForce ) ); - - if( ( xForce != pdFALSE ) || ( xPhyObject.ulLinkStatusMask != 0 ) ) - { - /* Restart the auto-negotiation. */ - if( xETH.Init.AutoNegotiation != ETH_AUTONEGOTIATION_DISABLE ) - { - xPhyStartAutoNegotiation( &xPhyObject, xPhyGetMask( &xPhyObject ) ); - - /* Configure the MAC with the Duplex Mode fixed by the - auto-negotiation process. */ - if( xPhyObject.xPhyProperties.ucDuplex == PHY_DUPLEX_FULL ) - { - xETH.Init.DuplexMode = ETH_MODE_FULLDUPLEX; - } - else - { - xETH.Init.DuplexMode = ETH_MODE_HALFDUPLEX; - } - - /* Configure the MAC with the speed fixed by the - auto-negotiation process. */ - if( xPhyObject.xPhyProperties.ucSpeed == PHY_SPEED_10 ) - { - xETH.Init.Speed = ETH_SPEED_10M; - } - else - { - xETH.Init.Speed = ETH_SPEED_100M; - } - } - else /* AutoNegotiation Disable */ - { - /* Check parameters */ - assert_param( IS_ETH_SPEED( xETH.Init.Speed ) ); - assert_param( IS_ETH_DUPLEX_MODE( xETH.Init.DuplexMode ) ); - - if( xETH.Init.DuplexMode == ETH_MODE_FULLDUPLEX ) - { - xPhyObject.xPhyPreferences.ucDuplex = PHY_DUPLEX_HALF; - } - else - { - xPhyObject.xPhyPreferences.ucDuplex = PHY_DUPLEX_FULL; - } - - if( xETH.Init.Speed == ETH_SPEED_10M ) - { - xPhyObject.xPhyPreferences.ucSpeed = PHY_SPEED_10; - } - else - { - xPhyObject.xPhyPreferences.ucSpeed = PHY_SPEED_100; - } - - xPhyObject.xPhyPreferences.ucMDI_X = PHY_MDIX_AUTO; - - /* Use predefined (fixed) configuration. */ - xPhyFixedValue( &xPhyObject, xPhyGetMask( &xPhyObject ) ); - } - - /* ETHERNET MAC Re-Configuration */ - HAL_ETH_ConfigMAC( &xETH, (ETH_MACInitTypeDef *) NULL); - - /* Restart MAC interface */ - HAL_ETH_Start( &xETH); - } - else - { - /* Stop MAC interface */ - HAL_ETH_Stop( &xETH ); - } -} -/*-----------------------------------------------------------*/ - -BaseType_t xGetPhyLinkStatus( void ) -{ -BaseType_t xReturn; - - if( xPhyObject.ulLinkStatusMask != 0 ) - { - xReturn = pdPASS; - } - else - { - xReturn = pdFAIL; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -#define niBUFFER_1_PACKET_SIZE 1536 - -static __attribute__ ((section(".first_data"))) uint8_t ucNetworkPackets[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS * niBUFFER_1_PACKET_SIZE ] __attribute__ ( ( aligned( 32 ) ) ); - -void vNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkBuffers[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ] ) -{ - -uint8_t *ucRAMBuffer = ucNetworkPackets; -uint32_t ul; - - for( ul = 0; ul < ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS; ul++ ) - { - pxNetworkBuffers[ ul ].pucEthernetBuffer = ucRAMBuffer + ipBUFFER_PADDING; - *( ( unsigned * ) ucRAMBuffer ) = ( unsigned ) ( &( pxNetworkBuffers[ ul ] ) ); - ucRAMBuffer += niBUFFER_1_PACKET_SIZE; - } -} -/*-----------------------------------------------------------*/ - -static void prvEMACHandlerTask( void *pvParameters ) -{ -UBaseType_t uxLastMinBufferCount = 0; -#if( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) -UBaseType_t uxLastMinQueueSpace = 0; -#endif -UBaseType_t uxCurrentCount; -BaseType_t xResult; -const TickType_t ulMaxBlockTime = pdMS_TO_TICKS( 100UL ); - - /* Remove compiler warnings about unused parameters. */ - ( void ) pvParameters; - - for( ;; ) - { - xResult = 0; - uxCurrentCount = uxGetMinimumFreeNetworkBuffers(); - if( uxLastMinBufferCount != uxCurrentCount ) - { - /* The logging produced below may be helpful - while tuning +TCP: see how many buffers are in use. */ - uxLastMinBufferCount = uxCurrentCount; - FreeRTOS_printf( ( "Network buffers: %lu lowest %lu\n", - uxGetNumberOfFreeNetworkBuffers(), uxCurrentCount ) ); - } - - if( xTXDescriptorSemaphore != NULL ) - { - static UBaseType_t uxLowestSemCount = ( UBaseType_t ) ETH_TXBUFNB - 1; - - uxCurrentCount = uxSemaphoreGetCount( xTXDescriptorSemaphore ); - if( uxLowestSemCount > uxCurrentCount ) - { - uxLowestSemCount = uxCurrentCount; - FreeRTOS_printf( ( "TX DMA buffers: lowest %lu\n", uxLowestSemCount ) ); - } - - } - - #if( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - { - uxCurrentCount = uxGetMinimumIPQueueSpace(); - if( uxLastMinQueueSpace != uxCurrentCount ) - { - /* The logging produced below may be helpful - while tuning +TCP: see how many buffers are in use. */ - uxLastMinQueueSpace = uxCurrentCount; - FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); - } - } - #endif /* ipconfigCHECK_IP_QUEUE_SPACE */ - - if( ( ulISREvents & EMAC_IF_ALL_EVENT ) == 0 ) - { - /* No events to process now, wait for the next. */ - ulTaskNotifyTake( pdFALSE, ulMaxBlockTime ); - } - - if( ( ulISREvents & EMAC_IF_RX_EVENT ) != 0 ) - { - ulISREvents &= ~EMAC_IF_RX_EVENT; - - xResult = prvNetworkInterfaceInput(); - if( xResult > 0 ) - { - while( prvNetworkInterfaceInput() > 0 ) - { - } - } - } - - if( ( ulISREvents & EMAC_IF_TX_EVENT ) != 0 ) - { - /* Code to release TX buffers if zero-copy is used. */ - ulISREvents &= ~EMAC_IF_TX_EVENT; - /* Check if DMA packets have been delivered. */ - vClearTXBuffers(); - } - - if( ( ulISREvents & EMAC_IF_ERR_EVENT ) != 0 ) - { - /* Future extension: logging about errors that occurred. */ - ulISREvents &= ~EMAC_IF_ERR_EVENT; - } - if( xPhyCheckLinkStatus( &xPhyObject, xResult ) != 0 ) - { - /* Something has changed to a Link Status, need re-check. */ - prvEthernetUpdateConfig( pdFALSE ); - } - } -} -/*-----------------------------------------------------------*/ - -void ETH_IRQHandler( void ) -{ - HAL_ETH_IRQHandler( &xETH ); -} - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32F7xx/stm32f7xx_hal_eth.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32F7xx/stm32f7xx_hal_eth.c deleted file mode 100755 index 87b5407..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32F7xx/stm32f7xx_hal_eth.c +++ /dev/null @@ -1,1835 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f7xx_hal_eth.c - * @author MCD Application Team - * @version V1.3.2 - * @date 26-June-2015 - * @brief ETH HAL module driver. - * This file provides firmware functions to manage the following - * functionalities of the Ethernet (ETH) peripheral: - * + Initialization and de-initialization functions - * + IO operation functions - * + Peripheral Control functions - * + Peripheral State and Errors functions - * - @verbatim - ============================================================================== - ##### How to use this driver ##### - ============================================================================== - [..] - (#)Declare a ETH_HandleTypeDef handle structure, for example: - ETH_HandleTypeDef heth; - - (#)Fill parameters of Init structure in heth handle - - (#)Call HAL_ETH_Init() API to initialize the Ethernet peripheral (MAC, DMA, ...) - - (#)Initialize the ETH low level resources through the HAL_ETH_MspInit() API: - (##) Enable the Ethernet interface clock using - (+++) __HAL_RCC_ETHMAC_CLK_ENABLE(); - (+++) __HAL_RCC_ETHMACTX_CLK_ENABLE(); - (+++) __HAL_RCC_ETHMACRX_CLK_ENABLE(); - - (##) Initialize the related GPIO clocks - (##) Configure Ethernet pin-out - (##) Configure Ethernet NVIC interrupt (IT mode) - - (#)Initialize Ethernet DMA Descriptors in chain mode and point to allocated buffers: - (##) HAL_ETH_DMATxDescListInit(); for Transmission process - (##) HAL_ETH_DMARxDescListInit(); for Reception process - - (#)Enable MAC and DMA transmission and reception: - (##) HAL_ETH_Start(); - - (#)Prepare ETH DMA TX Descriptors and give the hand to ETH DMA to transfer - the frame to MAC TX FIFO: - (##) HAL_ETH_TransmitFrame(); - - (#)Poll for a received frame in ETH RX DMA Descriptors and get received - frame parameters - (##) HAL_ETH_GetReceivedFrame(); (should be called into an infinite loop) - - (#) Get a received frame when an ETH RX interrupt occurs: - (##) HAL_ETH_GetReceivedFrame_IT(); (called in IT mode only) - - (#) Communicate with external PHY device: - (##) Read a specific register from the PHY - HAL_ETH_ReadPHYRegister(); - (##) Write data to a specific RHY register: - HAL_ETH_WritePHYRegister(); - - (#) Configure the Ethernet MAC after ETH peripheral initialization - HAL_ETH_ConfigMAC(); all MAC parameters should be filled. - - (#) Configure the Ethernet DMA after ETH peripheral initialization - HAL_ETH_ConfigDMA(); all DMA parameters should be filled. - - -@- The PTP protocol and the DMA descriptors ring mode are not supported - in this driver - - @endverbatim - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f7xx_hal.h" - - -int lUDPLoggingPrintf( const char *pcFormatString, ... ); - -/** @addtogroup STM32F4xx_HAL_Driver - * @{ - */ - -/** @defgroup ETH ETH - * @brief ETH HAL module driver - * @{ - */ - -#if !defined( ARRAY_SIZE ) - #define ARRAY_SIZE( x ) ( sizeof ( x ) / sizeof ( x )[ 0 ] ) -#endif - -#ifdef HAL_ETH_MODULE_ENABLED - -#if defined(STM32F7xx) - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/** @defgroup ETH_Private_Constants ETH Private Constants - * @{ - */ -#define LINKED_STATE_TIMEOUT_VALUE ((uint32_t)2000) /* 2000 ms */ -#define AUTONEGO_COMPLETED_TIMEOUT_VALUE ((uint32_t)1000) /* 1000 ms */ - -/** - * @} - */ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ -/** @defgroup ETH_Private_Functions ETH Private Functions - * @{ - */ -static void ETH_MACDMAConfig(ETH_HandleTypeDef *heth, uint32_t err); -static void ETH_MACAddressConfig(ETH_HandleTypeDef *heth, uint32_t MacAddr, uint8_t *Addr); -static void ETH_MACReceptionEnable(ETH_HandleTypeDef *heth); -static void ETH_MACReceptionDisable(ETH_HandleTypeDef *heth); -static void ETH_MACTransmissionEnable(ETH_HandleTypeDef *heth); -static void ETH_MACTransmissionDisable(ETH_HandleTypeDef *heth); -static void ETH_DMATransmissionEnable(ETH_HandleTypeDef *heth); -static void ETH_DMATransmissionDisable(ETH_HandleTypeDef *heth); -static void ETH_DMAReceptionEnable(ETH_HandleTypeDef *heth); -static void ETH_DMAReceptionDisable(ETH_HandleTypeDef *heth); -static void ETH_FlushTransmitFIFO(ETH_HandleTypeDef *heth); - -/** - * @} - */ -/* Private functions ---------------------------------------------------------*/ - -/** @defgroup ETH_Exported_Functions ETH Exported Functions - * @{ - */ - -/** @defgroup ETH_Exported_Functions_Group1 Initialization and de-initialization functions - * @brief Initialization and Configuration functions - * - @verbatim - =============================================================================== - ##### Initialization and de-initialization functions ##### - =============================================================================== - [..] This section provides functions allowing to: - (+) Initialize and configure the Ethernet peripheral - (+) De-initialize the Ethernet peripheral - - @endverbatim - * @{ - */ -extern void vMACBProbePhy ( void ); - -/** - * @brief Initializes the Ethernet MAC and DMA according to default - * parameters. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth) -{ - uint32_t tmpreg = 0; - uint32_t hclk = 60000000; - uint32_t err = ETH_SUCCESS; - - /* Check the ETH peripheral state */ - if( heth == NULL ) - { - return HAL_ERROR; - } - - /* Check parameters */ - assert_param(IS_ETH_AUTONEGOTIATION(heth->Init.AutoNegotiation)); - assert_param(IS_ETH_RX_MODE(heth->Init.RxMode)); - assert_param(IS_ETH_CHECKSUM_MODE(heth->Init.ChecksumMode)); - assert_param(IS_ETH_MEDIA_INTERFACE(heth->Init.MediaInterface)); - - if( heth->State == HAL_ETH_STATE_RESET ) - { - /* Init the low level hardware : GPIO, CLOCK, NVIC. */ - HAL_ETH_MspInit( heth ); - } - - /* Enable SYSCFG Clock */ - __HAL_RCC_SYSCFG_CLK_ENABLE(); - - /* Select MII or RMII Mode*/ - SYSCFG->PMC &= ~(SYSCFG_PMC_MII_RMII_SEL); - SYSCFG->PMC |= (uint32_t)heth->Init.MediaInterface; - - /* Ethernet Software reset */ - /* Set the SWR bit: resets all MAC subsystem internal registers and logic */ - /* After reset all the registers holds their respective reset values */ - /* Also enable EDFE: Enhanced descriptor format enable. */ -// heth->Instance->DMABMR |= ETH_DMABMR_SR | ETH_DMABMR_EDE; - heth->Instance->DMABMR |= ETH_DMABMR_SR; - - /* Wait for software reset */ - while ((heth->Instance->DMABMR & ETH_DMABMR_SR) != (uint32_t)RESET) - { - } - - /*-------------------------------- MAC Initialization ----------------------*/ - /* Get the ETHERNET MACMIIAR value */ - tmpreg = heth->Instance->MACMIIAR; - /* Clear CSR Clock Range CR[2:0] bits */ - tmpreg &= ETH_MACMIIAR_CR_MASK; - - /* Get hclk frequency value (168,000,000) */ - hclk = HAL_RCC_GetHCLKFreq(); - - /* Set CR bits depending on hclk value */ - if( ( hclk >= 20000000 ) && ( hclk < 35000000 ) ) - { - /* CSR Clock Range between 20-35 MHz */ - tmpreg |= (uint32_t) ETH_MACMIIAR_CR_Div16; - } - else if( ( hclk >= 35000000 ) && ( hclk < 60000000 ) ) - { - /* CSR Clock Range between 35-60 MHz */ - tmpreg |= ( uint32_t ) ETH_MACMIIAR_CR_Div26; - } - else if((hclk >= 60000000 ) && ( hclk < 100000000 ) ) - { - /* CSR Clock Range between 60-100 MHz */ - tmpreg |= (uint32_t)ETH_MACMIIAR_CR_Div42; - } - else if((hclk >= 100000000 ) && ( hclk < 150000000)) - { - /* CSR Clock Range between 100-150 MHz */ - tmpreg |= (uint32_t)ETH_MACMIIAR_CR_Div62; - } - else /* ((hclk >= 150000000 ) && ( hclk <= 168000000)) */ - { - /* CSR Clock Range between 150-168 MHz */ - tmpreg |= (uint32_t)ETH_MACMIIAR_CR_Div102; - } - - /* Write to ETHERNET MAC MIIAR: Configure the ETHERNET CSR Clock Range */ - heth->Instance->MACMIIAR = (uint32_t)tmpreg; - - /* Initialise the MACB and set all PHY properties */ - vMACBProbePhy(); - - /* Config MAC and DMA */ - ETH_MACDMAConfig(heth, err); - - /* Set ETH HAL State to Ready */ - heth->State= HAL_ETH_STATE_READY; - - /* Return function status */ - return HAL_OK; -} - -/** - * @brief De-Initializes the ETH peripheral. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_DeInit(ETH_HandleTypeDef *heth) -{ - /* Set the ETH peripheral state to BUSY */ - heth->State = HAL_ETH_STATE_BUSY; - - /* De-Init the low level hardware : GPIO, CLOCK, NVIC. */ - HAL_ETH_MspDeInit( heth ); - - /* Set ETH HAL state to Disabled */ - heth->State= HAL_ETH_STATE_RESET; - - /* Release Lock */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -/** - * @brief Initializes the DMA Tx descriptors in chain mode. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param DMATxDescTab: Pointer to the first Tx desc list - * @param TxBuff: Pointer to the first TxBuffer list - * @param TxBuffCount: Number of the used Tx desc in the list - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_DMATxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADescTypeDef *pxDMATable, uint8_t *ucDataBuffer, uint32_t ulBufferCount) -{ - uint32_t i = 0; - ETH_DMADescTypeDef *pxDMADescriptor; - - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Set the ETH peripheral state to BUSY */ - heth->State = HAL_ETH_STATE_BUSY; - - /* Set the TxDesc pointer with the first one of the pxDMATable list */ - heth->TxDesc = pxDMATable; - - /* Fill each DMA descriptor with the right values */ - for( i=0; i < ulBufferCount; i++ ) - { - /* Get the pointer on the ith member of the descriptor list */ - pxDMADescriptor = pxDMATable + i; - - /* Set Second Address Chained bit */ - pxDMADescriptor->Status = ETH_DMATXDESC_TCH; - - pxDMADescriptor->ControlBufferSize = 0; - - /* Set Buffer1 address pointer */ - if( ucDataBuffer != NULL ) - { - pxDMADescriptor->Buffer1Addr = ( uint32_t )( &ucDataBuffer[ i * ETH_TX_BUF_SIZE ] ); - } - else - { - /* Buffer space is not provided because it uses zero-copy transmissions. */ - pxDMADescriptor->Buffer1Addr = ( uint32_t )0u; - } - - if (heth->Init.ChecksumMode == ETH_CHECKSUM_BY_HARDWARE) - { - /* Set the DMA Tx descriptors checksum insertion for TCP, UDP, and ICMP */ - pxDMADescriptor->Status |= ETH_DMATXDESC_CHECKSUMTCPUDPICMPFULL; - } - - /* Initialize the next descriptor with the Next Descriptor Polling Enable */ - if(i < ( ulBufferCount - 1 ) ) - { - /* Set next descriptor address register with next descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = ( uint32_t ) ( pxDMATable + i + 1 ); - } - else - { - /* For last descriptor, set next descriptor address register equal to the first descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = ( uint32_t ) pxDMATable; - } - } - - /* Set Transmit Descriptor List Address Register */ - heth->Instance->DMATDLAR = ( uint32_t ) pxDMATable; - - /* Set ETH HAL State to Ready */ - heth->State= HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -/** - * @brief Initializes the DMA Rx descriptors in chain mode. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param DMARxDescTab: Pointer to the first Rx desc list - * @param RxBuff: Pointer to the first RxBuffer list - * @param RxBuffCount: Number of the used Rx desc in the list - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_DMARxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADescTypeDef *pxDMATable, uint8_t *ucDataBuffer, uint32_t ulBufferCount) -{ - uint32_t i = 0; - ETH_DMADescTypeDef *pxDMADescriptor; - - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Set the ETH peripheral state to BUSY */ - heth->State = HAL_ETH_STATE_BUSY; - - /* Set the RxDesc pointer with the first one of the pxDMATable list */ - heth->RxDesc = pxDMATable; - - /* Fill each DMA descriptor with the right values */ - for(i=0; i < ulBufferCount; i++) - { - /* Get the pointer on the ith member of the descriptor list */ - pxDMADescriptor = pxDMATable+i; - - /* Set Own bit of the Rx descriptor Status */ - pxDMADescriptor->Status = ETH_DMARXDESC_OWN; - - /* Set Buffer1 size and Second Address Chained bit */ - pxDMADescriptor->ControlBufferSize = ETH_DMARXDESC_RCH | ETH_RX_BUF_SIZE; - - /* Set Buffer1 address pointer */ - if( ucDataBuffer != NULL ) - { - pxDMADescriptor->Buffer1Addr = ( uint32_t )( &ucDataBuffer[ i * ETH_RX_BUF_SIZE ] ); - } - else - { - /* Buffer space is not provided because it uses zero-copy reception. */ - pxDMADescriptor->Buffer1Addr = ( uint32_t )0u; - } - - if( heth->Init.RxMode == ETH_RXINTERRUPT_MODE ) - { - /* Enable Ethernet DMA Rx Descriptor interrupt */ - pxDMADescriptor->ControlBufferSize &= ~ETH_DMARXDESC_DIC; - } - - /* Initialize the next descriptor with the Next Descriptor Polling Enable */ - if(i < (ulBufferCount-1)) - { - /* Set next descriptor address register with next descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = (uint32_t)(pxDMATable+i+1); - } - else - { - /* For last descriptor, set next descriptor address register equal to the first descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = ( uint32_t ) pxDMATable; - } - } - - /* Set Receive Descriptor List Address Register */ - heth->Instance->DMARDLAR = ( uint32_t ) pxDMATable; - - /* Set ETH HAL State to Ready */ - heth->State= HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -/** - * @brief Initializes the ETH MSP. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -__weak void HAL_ETH_MspInit(ETH_HandleTypeDef *heth) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_ETH_MspInit could be implemented in the user file - */ -} - -/** - * @brief DeInitializes ETH MSP. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -__weak void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_ETH_MspDeInit could be implemented in the user file - */ -} - -/** - * @} - */ - -/** @defgroup ETH_Exported_Functions_Group2 IO operation functions - * @brief Data transfers functions - * - @verbatim - ============================================================================== - ##### IO operation functions ##### - ============================================================================== - [..] This section provides functions allowing to: - (+) Transmit a frame - HAL_ETH_TransmitFrame(); - (+) Receive a frame - HAL_ETH_GetReceivedFrame(); - HAL_ETH_GetReceivedFrame_IT(); - (+) Read from an External PHY register - HAL_ETH_ReadPHYRegister(); - (+) Write to an External PHY register - HAL_ETH_WritePHYRegister(); - - @endverbatim - - * @{ - */ - -/** - * @brief Sends an Ethernet frame. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param FrameLength: Amount of data to be sent - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_TransmitFrame(ETH_HandleTypeDef *heth, uint32_t FrameLength) -{ - uint32_t bufcount = 0, size = 0, i = 0; - __IO ETH_DMADescTypeDef *pxDmaTxDesc = heth->TxDesc; - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Set the ETH peripheral state to BUSY */ - heth->State = HAL_ETH_STATE_BUSY; - - if( FrameLength == 0 ) - { - /* Set ETH HAL state to READY */ - heth->State = HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - return HAL_ERROR; - } - - /* Check if the descriptor is owned by the ETHERNET DMA (when set) or CPU (when reset) */ - if( ( pxDmaTxDesc->Status & ETH_DMATXDESC_OWN ) != ( uint32_t ) RESET ) - { - /* OWN bit set */ - heth->State = HAL_ETH_STATE_BUSY_TX; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - return HAL_ERROR; - } - - /* Get the number of needed Tx buffers for the current frame, rounding up. */ - bufcount = ( FrameLength + ETH_TX_BUF_SIZE - 1 ) / ETH_TX_BUF_SIZE; - - if (bufcount == 1) - { - /* Set LAST and FIRST segment */ - pxDmaTxDesc->Status |= ETH_DMATXDESC_FS | ETH_DMATXDESC_LS; - /* Set frame size */ - pxDmaTxDesc->ControlBufferSize = ( FrameLength & ETH_DMATXDESC_TBS1 ); - /* Set Own bit of the Tx descriptor Status: gives the buffer back to ETHERNET DMA */ - pxDmaTxDesc->Status |= ETH_DMATXDESC_OWN; - /* Point to next descriptor */ - heth->TxDesc = ( ETH_DMADescTypeDef * ) ( heth->TxDesc->Buffer2NextDescAddr ); - } - else - { - for( i = 0; i < bufcount; i++ ) - { - /* Clear FIRST and LAST segment bits */ - uint32_t ulStatus = heth->TxDesc->Status & ~( ETH_DMATXDESC_FS | ETH_DMATXDESC_LS ); - - if( i == 0 ) - { - /* Setting the first segment bit */ - heth->TxDesc->Status = ulStatus | ETH_DMATXDESC_FS; - } - - /* Program size */ - if (i < (bufcount-1)) - { - heth->TxDesc->ControlBufferSize = (ETH_TX_BUF_SIZE & ETH_DMATXDESC_TBS1); - } - else - { - /* Setting the last segment bit */ - heth->TxDesc->Status = ulStatus | ETH_DMATXDESC_LS; - size = FrameLength - (bufcount-1)*ETH_TX_BUF_SIZE; - heth->TxDesc->ControlBufferSize = (size & ETH_DMATXDESC_TBS1); - } - - /* Set Own bit of the Tx descriptor Status: gives the buffer back to ETHERNET DMA */ - heth->TxDesc->Status |= ETH_DMATXDESC_OWN; - /* point to next descriptor */ - heth->TxDesc = (ETH_DMADescTypeDef *)( heth->TxDesc->Buffer2NextDescAddr ); - } - } - - __DSB(); - - /* When Tx Buffer unavailable flag is set: clear it and resume transmission */ - if( ( heth->Instance->DMASR & ETH_DMASR_TBUS ) != ( uint32_t )RESET ) - { - heth->Instance->DMACHTDR = ( uint32_t )pxDmaTxDesc; - - /* Clear TBUS ETHERNET DMA flag */ - heth->Instance->DMASR = ETH_DMASR_TBUS; - /* Resume DMA transmission*/ - heth->Instance->DMATPDR = 0; - } - - /* Set ETH HAL State to Ready */ - heth->State = HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -/** - * @brief Checks for received frames. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_GetReceivedFrame_IT( ETH_HandleTypeDef *heth ) -{ - return HAL_ETH_GetReceivedFrame( heth ); -} - -HAL_StatusTypeDef HAL_ETH_GetReceivedFrame( ETH_HandleTypeDef *heth ) -{ -uint32_t ulCounter = 0; -ETH_DMADescTypeDef *pxDescriptor = heth->RxDesc; -HAL_StatusTypeDef xResult = HAL_ERROR; - - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Check the ETH state to BUSY */ - heth->State = HAL_ETH_STATE_BUSY; - - /* Scan descriptors owned by CPU */ - while( ( ( pxDescriptor->Status & ETH_DMARXDESC_OWN ) == 0ul ) && ( ulCounter < ETH_RXBUFNB ) ) - { - uint32_t ulStatus = pxDescriptor->Status; - - /* Just for security. */ - ulCounter++; - - if( ( ulStatus & ( ETH_DMARXDESC_FS | ETH_DMARXDESC_LS ) ) == ( uint32_t )ETH_DMARXDESC_FS ) - { - /* First segment in frame, but not the last. */ - heth->RxFrameInfos.FSRxDesc = pxDescriptor; - heth->RxFrameInfos.LSRxDesc = ( ETH_DMADescTypeDef *)NULL; - heth->RxFrameInfos.SegCount = 1; - /* Point to next descriptor. */ - pxDescriptor = (ETH_DMADescTypeDef*) (pxDescriptor->Buffer2NextDescAddr); - heth->RxDesc = pxDescriptor; - } - else if( ( ulStatus & ( ETH_DMARXDESC_LS | ETH_DMARXDESC_FS ) ) == 0ul ) - { - /* This is an intermediate segment, not first, not last. */ - /* Increment segment count. */ - heth->RxFrameInfos.SegCount++; - /* Move to the next descriptor. */ - pxDescriptor = ( ETH_DMADescTypeDef * ) ( pxDescriptor->Buffer2NextDescAddr ); - heth->RxDesc = pxDescriptor; - } - /* Must be a last segment */ - else - { - /* This is the last segment. */ - /* Check if last segment is first segment: one segment contains the frame */ - if( heth->RxFrameInfos.SegCount == 0 ) - { - /* Remember the first segment. */ - heth->RxFrameInfos.FSRxDesc = pxDescriptor; - } - - /* Increment segment count */ - heth->RxFrameInfos.SegCount++; - - /* Remember the last segment. */ - heth->RxFrameInfos.LSRxDesc = pxDescriptor; - - /* Get the Frame Length of the received packet: substruct 4 bytes of the CRC */ - heth->RxFrameInfos.length = - ( ( ulStatus & ETH_DMARXDESC_FL ) >> ETH_DMARXDESC_FRAMELENGTHSHIFT ) - 4; - - /* Get the address of the buffer start address */ - heth->RxFrameInfos.buffer = heth->RxFrameInfos.FSRxDesc->Buffer1Addr; - - /* Point to next descriptor */ - heth->RxDesc = ( ETH_DMADescTypeDef * ) pxDescriptor->Buffer2NextDescAddr; - - /* Return OK status: a packet was received. */ - xResult = HAL_OK; - break; - } - } - - /* Set ETH HAL State to Ready */ - heth->State = HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return xResult; -} - -#if( STM32_ETHERNET_STATS != 0 ) - - volatile int rx_count, tx_count, int_count; - /** - * @brief This function handles ETH interrupt request. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval HAL status - */ - volatile int int_counts[32]; - volatile int tx_status[8]; - volatile unsigned sr_history[32]; - volatile int sr_head; - #define STM32_STAT_INC( x ) do { ( x )++; } while( 0 ) - -#else - #define STM32_STAT_INC( x ) do { } while( 0 ) -#endif /* STM32_ETHERNET_STATS */ - -#define ETH_DMA_ALL_INTS \ - ( ETH_DMA_IT_TST | ETH_DMA_IT_PMT | ETH_DMA_IT_MMC | ETH_DMA_IT_NIS | ETH_DMA_IT_AIS | ETH_DMA_IT_ER | \ - ETH_DMA_IT_FBE | ETH_DMA_IT_ET | ETH_DMA_IT_RWT | ETH_DMA_IT_RPS | ETH_DMA_IT_RBU | ETH_DMA_IT_R | \ - ETH_DMA_IT_TU | ETH_DMA_IT_RO | ETH_DMA_IT_TJT | ETH_DMA_IT_TPS | ETH_DMA_IT_T ) - -//#define ETH_DMA_ALL_INTS ETH_DMA_IT_RBU | ETH_DMA_FLAG_T | ETH_DMA_FLAG_AIS - -#define INT_MASK ( ( uint32_t ) ~ ( ETH_DMA_IT_TBU ) ) -void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth) -{ - uint32_t dmasr; - - STM32_STAT_INC( int_count ); - - dmasr = heth->Instance->DMASR & ETH_DMA_ALL_INTS; - heth->Instance->DMASR = dmasr; - -#if( STM32_ETHERNET_STATS != 0 ) - if( sr_head < ARRAY_SIZE( sr_history ) ) - { - sr_history[ sr_head++ ] = dmasr; - } - - { - int i; - for (i = 0; i < 32; i++) { - if (dmasr & (1u << i)) { - int_counts[i]++; - } - } - tx_status[ ( dmasr >> 20 ) & 0x07 ]++; - } -#endif - - /* Frame received */ - if( ( dmasr & ( ETH_DMA_FLAG_R | ETH_DMA_IT_RBU ) ) != 0 ) - { - /* Receive complete callback */ - HAL_ETH_RxCpltCallback( heth ); - STM32_STAT_INC( rx_count ); - } - /* Frame transmitted */ - if( ( dmasr & ( ETH_DMA_FLAG_T ) ) != 0 ) - { - /* Transfer complete callback */ - HAL_ETH_TxCpltCallback( heth ); - STM32_STAT_INC( tx_count ); - } - - /* ETH DMA Error */ - if( ( dmasr & ( ETH_DMA_FLAG_AIS ) ) != 0 ) - { - /* Ethernet Error callback */ - HAL_ETH_ErrorCallback( heth ); - } -} - -/** - * @brief Tx Transfer completed callbacks. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -__weak void HAL_ETH_TxCpltCallback(ETH_HandleTypeDef *heth) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_ETH_TxCpltCallback could be implemented in the user file - */ -} - -/** - * @brief Rx Transfer completed callbacks. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -__weak void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_ETH_TxCpltCallback could be implemented in the user file - */ -} - -/** - * @brief Ethernet transfer error callbacks - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -__weak void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_ETH_TxCpltCallback could be implemented in the user file - */ -} - -/** - * @brief Reads a PHY register - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param PHYReg: PHY register address, is the index of one of the 32 PHY register. - * This parameter can be one of the following values: - * PHY_BCR: Transceiver Basic Control Register, - * PHY_BSR: Transceiver Basic Status Register. - * More PHY register could be read depending on the used PHY - * @param RegValue: PHY register value - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_ReadPHYRegister(ETH_HandleTypeDef *heth, uint16_t PHYReg, uint32_t *RegValue) -{ -uint32_t tmpreg = 0; -uint32_t tickstart = 0; -HAL_StatusTypeDef xResult; - - /* Check parameters */ - assert_param(IS_ETH_PHY_ADDRESS(heth->Init.PhyAddress)); - - /* Check the ETH peripheral state */ - if( heth->State == HAL_ETH_STATE_BUSY_RD ) - { - xResult = HAL_BUSY; - } - else - { - __HAL_LOCK( heth ); - - /* Set ETH HAL State to BUSY_RD */ - heth->State = HAL_ETH_STATE_BUSY_RD; - - /* Get the ETHERNET MACMIIAR value */ - tmpreg = heth->Instance->MACMIIAR; - - /* Keep only the CSR Clock Range CR[2:0] bits value */ - tmpreg &= ~ETH_MACMIIAR_CR_MASK; - - /* Prepare the MII address register value */ - tmpreg |= ( ( ( uint32_t )heth->Init.PhyAddress << 11) & ETH_MACMIIAR_PA ); /* Set the PHY device address */ - tmpreg |= ( ( ( uint32_t )PHYReg << 6 ) & ETH_MACMIIAR_MR ); /* Set the PHY register address */ - tmpreg &= ~ETH_MACMIIAR_MW; /* Set the read mode */ - tmpreg |= ETH_MACMIIAR_MB; /* Set the MII Busy bit */ - - /* Write the result value into the MII Address register */ - heth->Instance->MACMIIAR = tmpreg; - - /* Get tick */ - tickstart = HAL_GetTick(); - - /* Check for the Busy flag */ - while( 1 ) - { - tmpreg = heth->Instance->MACMIIAR; - - if( ( tmpreg & ETH_MACMIIAR_MB ) == 0ul ) - { - /* Get MACMIIDR value */ - *RegValue = ( uint32_t ) heth->Instance->MACMIIDR; - xResult = HAL_OK; - break; - } - /* Check for the Timeout */ - if( ( HAL_GetTick( ) - tickstart ) > PHY_READ_TO ) - { - xResult = HAL_TIMEOUT; - break; - } - - } - - /* Set ETH HAL State to READY */ - heth->State = HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - } - - if( xResult != HAL_OK ) - { - lUDPLoggingPrintf( "ReadPHY: %d\n", xResult ); - } - /* Return function status */ - return xResult; -} - -/** - * @brief Writes to a PHY register. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param PHYReg: PHY register address, is the index of one of the 32 PHY register. - * This parameter can be one of the following values: - * PHY_BCR: Transceiver Control Register. - * More PHY register could be written depending on the used PHY - * @param RegValue: the value to write - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_WritePHYRegister(ETH_HandleTypeDef *heth, uint16_t PHYReg, uint32_t RegValue) -{ -uint32_t tmpreg = 0; -uint32_t tickstart = 0; -HAL_StatusTypeDef xResult; - - /* Check parameters */ - assert_param( IS_ETH_PHY_ADDRESS( heth->Init.PhyAddress ) ); - - /* Check the ETH peripheral state */ - if( heth->State == HAL_ETH_STATE_BUSY_WR ) - { - xResult = HAL_BUSY; - } - else - { - __HAL_LOCK( heth ); - - /* Set ETH HAL State to BUSY_WR */ - heth->State = HAL_ETH_STATE_BUSY_WR; - - /* Get the ETHERNET MACMIIAR value */ - tmpreg = heth->Instance->MACMIIAR; - - /* Keep only the CSR Clock Range CR[2:0] bits value */ - tmpreg &= ~ETH_MACMIIAR_CR_MASK; - - /* Prepare the MII register address value */ - tmpreg |= ( ( ( uint32_t ) heth->Init.PhyAddress << 11 ) & ETH_MACMIIAR_PA ); /* Set the PHY device address */ - tmpreg |= ( ( ( uint32_t ) PHYReg << 6 ) & ETH_MACMIIAR_MR ); /* Set the PHY register address */ - tmpreg |= ETH_MACMIIAR_MW; /* Set the write mode */ - tmpreg |= ETH_MACMIIAR_MB; /* Set the MII Busy bit */ - - /* Give the value to the MII data register */ - heth->Instance->MACMIIDR = ( uint16_t ) RegValue; - - /* Write the result value into the MII Address register */ - heth->Instance->MACMIIAR = tmpreg; - - /* Get tick */ - tickstart = HAL_GetTick(); - - /* Check for the Busy flag */ - while( 1 ) - { - tmpreg = heth->Instance->MACMIIAR; - - if( ( tmpreg & ETH_MACMIIAR_MB ) == 0ul ) - { - xResult = HAL_OK; - break; - } - /* Check for the Timeout */ - if( ( HAL_GetTick( ) - tickstart ) > PHY_WRITE_TO ) - { - xResult = HAL_TIMEOUT; - break; - } - } - - /* Set ETH HAL State to READY */ - heth->State = HAL_ETH_STATE_READY; - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - } - - if( xResult != HAL_OK ) - { - lUDPLoggingPrintf( "WritePHY: %d\n", xResult ); - } - /* Return function status */ - return xResult; -} - -/** - * @} - */ - -/** @defgroup ETH_Exported_Functions_Group3 Peripheral Control functions - * @brief Peripheral Control functions - * -@verbatim - =============================================================================== - ##### Peripheral Control functions ##### - =============================================================================== - [..] This section provides functions allowing to: - (+) Enable MAC and DMA transmission and reception. - HAL_ETH_Start(); - (+) Disable MAC and DMA transmission and reception. - HAL_ETH_Stop(); - (+) Set the MAC configuration in runtime mode - HAL_ETH_ConfigMAC(); - (+) Set the DMA configuration in runtime mode - HAL_ETH_ConfigDMA(); - -@endverbatim - * @{ - */ - - /** - * @brief Enables Ethernet MAC and DMA reception/transmission - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_Start( ETH_HandleTypeDef *heth ) -{ - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Set the ETH peripheral state to BUSY */ - heth->State = HAL_ETH_STATE_BUSY; - - /* Enable transmit state machine of the MAC for transmission on the MII */ - ETH_MACTransmissionEnable( heth ); - - /* Enable receive state machine of the MAC for reception from the MII */ - ETH_MACReceptionEnable( heth ); - - /* Flush Transmit FIFO */ - ETH_FlushTransmitFIFO( heth ); - - /* Start DMA transmission */ - ETH_DMATransmissionEnable( heth ); - - /* Start DMA reception */ - ETH_DMAReceptionEnable( heth ); - - /* Set the ETH state to READY*/ - heth->State= HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -/** - * @brief Stop Ethernet MAC and DMA reception/transmission - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_Stop(ETH_HandleTypeDef *heth) -{ - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Set the ETH peripheral state to BUSY */ - heth->State = HAL_ETH_STATE_BUSY; - - /* Stop DMA transmission */ - ETH_DMATransmissionDisable( heth ); - - /* Stop DMA reception */ - ETH_DMAReceptionDisable( heth ); - - /* Disable receive state machine of the MAC for reception from the MII */ - ETH_MACReceptionDisable( heth ); - - /* Flush Transmit FIFO */ - ETH_FlushTransmitFIFO( heth ); - - /* Disable transmit state machine of the MAC for transmission on the MII */ - ETH_MACTransmissionDisable( heth ); - - /* Set the ETH state*/ - heth->State = HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -static void prvWriteMACFCR( ETH_HandleTypeDef *heth, uint32_t ulValue) -{ - /* Enable the MAC transmission */ - heth->Instance->MACFCR = ulValue; - - /* Wait until the write operation will be taken into account: - at least four TX_CLK/RX_CLK clock cycles. - Read it back, wait a ms and */ - ( void ) heth->Instance->MACFCR; - - HAL_Delay( ETH_REG_WRITE_DELAY ); - - heth->Instance->MACFCR = ulValue; -} - -static void prvWriteDMAOMR( ETH_HandleTypeDef *heth, uint32_t ulValue) -{ - /* Enable the MAC transmission */ - heth->Instance->DMAOMR = ulValue; - - /* Wait until the write operation will be taken into account: - at least four TX_CLK/RX_CLK clock cycles. - Read it back, wait a ms and */ - ( void ) heth->Instance->DMAOMR; - - HAL_Delay( ETH_REG_WRITE_DELAY ); - - heth->Instance->DMAOMR = ulValue; -} - -static void prvWriteMACCR( ETH_HandleTypeDef *heth, uint32_t ulValue) -{ - /* Enable the MAC transmission */ - heth->Instance->MACCR = ulValue; - - /* Wait until the write operation will be taken into account: - at least four TX_CLK/RX_CLK clock cycles. - Read it back, wait a ms and */ - ( void ) heth->Instance->MACCR; - - HAL_Delay( ETH_REG_WRITE_DELAY ); - - heth->Instance->MACCR = ulValue; -} - -/** - * @brief Set ETH MAC Configuration. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param macconf: MAC Configuration structure - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_ConfigMAC(ETH_HandleTypeDef *heth, ETH_MACInitTypeDef *macconf) -{ - uint32_t tmpreg = 0; - - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Set the ETH peripheral state to BUSY */ - heth->State= HAL_ETH_STATE_BUSY; - - assert_param(IS_ETH_SPEED(heth->Init.Speed)); - assert_param(IS_ETH_DUPLEX_MODE(heth->Init.DuplexMode)); - - if (macconf != NULL) - { - /* Check the parameters */ - assert_param(IS_ETH_WATCHDOG(macconf->Watchdog)); - assert_param(IS_ETH_JABBER(macconf->Jabber)); - assert_param(IS_ETH_INTER_FRAME_GAP(macconf->InterFrameGap)); - assert_param(IS_ETH_CARRIER_SENSE(macconf->CarrierSense)); - assert_param(IS_ETH_RECEIVE_OWN(macconf->ReceiveOwn)); - assert_param(IS_ETH_LOOPBACK_MODE(macconf->LoopbackMode)); - assert_param(IS_ETH_CHECKSUM_OFFLOAD(macconf->ChecksumOffload)); - assert_param(IS_ETH_RETRY_TRANSMISSION(macconf->RetryTransmission)); - assert_param(IS_ETH_AUTOMATIC_PADCRC_STRIP(macconf->AutomaticPadCRCStrip)); - assert_param(IS_ETH_BACKOFF_LIMIT(macconf->BackOffLimit)); - assert_param(IS_ETH_DEFERRAL_CHECK(macconf->DeferralCheck)); - assert_param(IS_ETH_RECEIVE_ALL(macconf->ReceiveAll)); - assert_param(IS_ETH_SOURCE_ADDR_FILTER(macconf->SourceAddrFilter)); - assert_param(IS_ETH_CONTROL_FRAMES(macconf->PassControlFrames)); - assert_param(IS_ETH_BROADCAST_FRAMES_RECEPTION(macconf->BroadcastFramesReception)); - assert_param(IS_ETH_DESTINATION_ADDR_FILTER(macconf->DestinationAddrFilter)); - assert_param(IS_ETH_PROMISCUOUS_MODE(macconf->PromiscuousMode)); - assert_param(IS_ETH_MULTICAST_FRAMES_FILTER(macconf->MulticastFramesFilter)); - assert_param(IS_ETH_UNICAST_FRAMES_FILTER(macconf->UnicastFramesFilter)); - assert_param(IS_ETH_PAUSE_TIME(macconf->PauseTime)); - assert_param(IS_ETH_ZEROQUANTA_PAUSE(macconf->ZeroQuantaPause)); - assert_param(IS_ETH_PAUSE_LOW_THRESHOLD(macconf->PauseLowThreshold)); - assert_param(IS_ETH_UNICAST_PAUSE_FRAME_DETECT(macconf->UnicastPauseFrameDetect)); - assert_param(IS_ETH_RECEIVE_FLOWCONTROL(macconf->ReceiveFlowControl)); - assert_param(IS_ETH_TRANSMIT_FLOWCONTROL(macconf->TransmitFlowControl)); - assert_param(IS_ETH_VLAN_TAG_COMPARISON(macconf->VLANTagComparison)); - assert_param(IS_ETH_VLAN_TAG_IDENTIFIER(macconf->VLANTagIdentifier)); - - /*------------------------ ETHERNET MACCR Configuration --------------------*/ - /* Get the ETHERNET MACCR value */ - tmpreg = heth->Instance->MACCR; - /* Clear WD, PCE, PS, TE and RE bits */ - tmpreg &= ETH_MACCR_CLEAR_MASK; - - tmpreg |= (uint32_t)( - macconf->Watchdog | - macconf->Jabber | - macconf->InterFrameGap | - macconf->CarrierSense | - heth->Init.Speed | - macconf->ReceiveOwn | - macconf->LoopbackMode | - heth->Init.DuplexMode | - macconf->ChecksumOffload | - macconf->RetryTransmission | - macconf->AutomaticPadCRCStrip | - macconf->BackOffLimit | - macconf->DeferralCheck); - - /* Write to ETHERNET MACCR */ - prvWriteMACCR( heth, tmpreg ); - - /*----------------------- ETHERNET MACFFR Configuration --------------------*/ - /* Write to ETHERNET MACFFR */ - heth->Instance->MACFFR = (uint32_t)( - macconf->ReceiveAll | - macconf->SourceAddrFilter | - macconf->PassControlFrames | - macconf->BroadcastFramesReception | - macconf->DestinationAddrFilter | - macconf->PromiscuousMode | - macconf->MulticastFramesFilter | - macconf->UnicastFramesFilter); - - /* Wait until the write operation will be taken into account : - at least four TX_CLK/RX_CLK clock cycles */ - tmpreg = heth->Instance->MACFFR; - HAL_Delay(ETH_REG_WRITE_DELAY); - heth->Instance->MACFFR = tmpreg; - - /*--------------- ETHERNET MACHTHR and MACHTLR Configuration ---------------*/ - /* Write to ETHERNET MACHTHR */ - heth->Instance->MACHTHR = (uint32_t)macconf->HashTableHigh; - - /* Write to ETHERNET MACHTLR */ - heth->Instance->MACHTLR = (uint32_t)macconf->HashTableLow; - /*----------------------- ETHERNET MACFCR Configuration --------------------*/ - - /* Get the ETHERNET MACFCR value */ - tmpreg = heth->Instance->MACFCR; - /* Clear xx bits */ - tmpreg &= ETH_MACFCR_CLEAR_MASK; - - tmpreg |= (uint32_t)(( - macconf->PauseTime << 16) | - macconf->ZeroQuantaPause | - macconf->PauseLowThreshold | - macconf->UnicastPauseFrameDetect | - macconf->ReceiveFlowControl | - macconf->TransmitFlowControl); - - /* Write to ETHERNET MACFCR */ - prvWriteMACFCR( heth, tmpreg ); - - /*----------------------- ETHERNET MACVLANTR Configuration -----------------*/ - heth->Instance->MACVLANTR = (uint32_t)(macconf->VLANTagComparison | - macconf->VLANTagIdentifier); - - /* Wait until the write operation will be taken into account : - at least four TX_CLK/RX_CLK clock cycles */ - tmpreg = heth->Instance->MACVLANTR; - HAL_Delay(ETH_REG_WRITE_DELAY); - heth->Instance->MACVLANTR = tmpreg; - } - else /* macconf == NULL : here we just configure Speed and Duplex mode */ - { - /*------------------------ ETHERNET MACCR Configuration --------------------*/ - /* Get the ETHERNET MACCR value */ - tmpreg = heth->Instance->MACCR; - - /* Clear FES and DM bits */ - tmpreg &= ~((uint32_t)0x00004800); - - tmpreg |= (uint32_t)(heth->Init.Speed | heth->Init.DuplexMode); - - /* Write to ETHERNET MACCR */ - prvWriteMACCR( heth, tmpreg ); - } - - /* Set the ETH state to Ready */ - heth->State= HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -/** - * @brief Sets ETH DMA Configuration. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param dmaconf: DMA Configuration structure - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_ConfigDMA(ETH_HandleTypeDef *heth, ETH_DMAInitTypeDef *dmaconf) -{ - uint32_t tmpreg = 0; - - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Set the ETH peripheral state to BUSY */ - heth->State= HAL_ETH_STATE_BUSY; - - /* Check parameters */ - assert_param(IS_ETH_DROP_TCPIP_CHECKSUM_FRAME(dmaconf->DropTCPIPChecksumErrorFrame)); - assert_param(IS_ETH_RECEIVE_STORE_FORWARD(dmaconf->ReceiveStoreForward)); - assert_param(IS_ETH_FLUSH_RECEIVE_FRAME(dmaconf->FlushReceivedFrame)); - assert_param(IS_ETH_TRANSMIT_STORE_FORWARD(dmaconf->TransmitStoreForward)); - assert_param(IS_ETH_TRANSMIT_THRESHOLD_CONTROL(dmaconf->TransmitThresholdControl)); - assert_param(IS_ETH_FORWARD_ERROR_FRAMES(dmaconf->ForwardErrorFrames)); - assert_param(IS_ETH_FORWARD_UNDERSIZED_GOOD_FRAMES(dmaconf->ForwardUndersizedGoodFrames)); - assert_param(IS_ETH_RECEIVE_THRESHOLD_CONTROL(dmaconf->ReceiveThresholdControl)); - assert_param(IS_ETH_SECOND_FRAME_OPERATE(dmaconf->SecondFrameOperate)); - assert_param(IS_ETH_ADDRESS_ALIGNED_BEATS(dmaconf->AddressAlignedBeats)); - assert_param(IS_ETH_FIXED_BURST(dmaconf->FixedBurst)); - assert_param(IS_ETH_RXDMA_BURST_LENGTH(dmaconf->RxDMABurstLength)); - assert_param(IS_ETH_TXDMA_BURST_LENGTH(dmaconf->TxDMABurstLength)); - assert_param(IS_ETH_ENHANCED_DESCRIPTOR_FORMAT(dmaconf->EnhancedDescriptorFormat)); - assert_param(IS_ETH_DMA_DESC_SKIP_LENGTH(dmaconf->DescriptorSkipLength)); - assert_param(IS_ETH_DMA_ARBITRATION_ROUNDROBIN_RXTX(dmaconf->DMAArbitration)); - - /*----------------------- ETHERNET DMAOMR Configuration --------------------*/ - /* Get the ETHERNET DMAOMR value */ - tmpreg = heth->Instance->DMAOMR; - /* Clear xx bits */ - tmpreg &= ETH_DMAOMR_CLEAR_MASK; - - tmpreg |= (uint32_t)( - dmaconf->DropTCPIPChecksumErrorFrame | - dmaconf->ReceiveStoreForward | - dmaconf->FlushReceivedFrame | - dmaconf->TransmitStoreForward | - dmaconf->TransmitThresholdControl | - dmaconf->ForwardErrorFrames | - dmaconf->ForwardUndersizedGoodFrames | - dmaconf->ReceiveThresholdControl | - dmaconf->SecondFrameOperate); - - /* Write to ETHERNET DMAOMR */ - prvWriteDMAOMR( heth, tmpreg ); - - /*----------------------- ETHERNET DMABMR Configuration --------------------*/ - heth->Instance->DMABMR = (uint32_t)(dmaconf->AddressAlignedBeats | - dmaconf->FixedBurst | - dmaconf->RxDMABurstLength | /* !! if 4xPBL is selected for Tx or Rx it is applied for the other */ - dmaconf->TxDMABurstLength | - dmaconf->EnhancedDescriptorFormat | - (dmaconf->DescriptorSkipLength << 2) | - dmaconf->DMAArbitration | - ETH_DMABMR_USP); /* Enable use of separate PBL for Rx and Tx */ - - /* Wait until the write operation will be taken into account: - at least four TX_CLK/RX_CLK clock cycles */ - tmpreg = heth->Instance->DMABMR; - HAL_Delay(ETH_REG_WRITE_DELAY); - heth->Instance->DMABMR = tmpreg; - - /* Set the ETH state to Ready */ - heth->State= HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -/** - * @} - */ - -/** @defgroup ETH_Exported_Functions_Group4 Peripheral State functions - * @brief Peripheral State functions - * - @verbatim - =============================================================================== - ##### Peripheral State functions ##### - =============================================================================== - [..] - This subsection permits to get in run-time the status of the peripheral - and the data flow. - (+) Get the ETH handle state: - HAL_ETH_GetState(); - - - @endverbatim - * @{ - */ - -/** - * @brief Return the ETH HAL state - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval HAL state - */ -HAL_ETH_StateTypeDef HAL_ETH_GetState(ETH_HandleTypeDef *heth) -{ - /* Return ETH state */ - return heth->State; -} - -/** - * @} - */ - -/** - * @} - */ - -/** @addtogroup ETH_Private_Functions - * @{ - */ - -/** - * @brief Configures Ethernet MAC and DMA with default parameters. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param err: Ethernet Init error - * @retval HAL status - */ -static void ETH_MACDMAConfig(ETH_HandleTypeDef *heth, uint32_t err) -{ - ETH_MACInitTypeDef macinit; - ETH_DMAInitTypeDef dmainit; - uint32_t tmpreg = 0; - - if (err != ETH_SUCCESS) /* Auto-negotiation failed */ - { - /* Set Ethernet duplex mode to Full-duplex */ - heth->Init.DuplexMode = ETH_MODE_FULLDUPLEX; - - /* Set Ethernet speed to 100M */ - heth->Init.Speed = ETH_SPEED_100M; - } - - /* Ethernet MAC default initialization **************************************/ - macinit.Watchdog = ETH_WATCHDOG_ENABLE; - macinit.Jabber = ETH_JABBER_ENABLE; - macinit.InterFrameGap = ETH_INTERFRAMEGAP_96BIT; - macinit.CarrierSense = ETH_CARRIERSENCE_ENABLE; - macinit.ReceiveOwn = ETH_RECEIVEOWN_ENABLE; - macinit.LoopbackMode = ETH_LOOPBACKMODE_DISABLE; - if(heth->Init.ChecksumMode == ETH_CHECKSUM_BY_HARDWARE) - { - macinit.ChecksumOffload = ETH_CHECKSUMOFFLAOD_ENABLE; - } - else - { - macinit.ChecksumOffload = ETH_CHECKSUMOFFLAOD_DISABLE; - } - macinit.RetryTransmission = ETH_RETRYTRANSMISSION_DISABLE; - macinit.AutomaticPadCRCStrip = ETH_AUTOMATICPADCRCSTRIP_DISABLE; - macinit.BackOffLimit = ETH_BACKOFFLIMIT_10; - macinit.DeferralCheck = ETH_DEFFERRALCHECK_DISABLE; - macinit.ReceiveAll = ETH_RECEIVEAll_DISABLE; - macinit.SourceAddrFilter = ETH_SOURCEADDRFILTER_DISABLE; - macinit.PassControlFrames = ETH_PASSCONTROLFRAMES_BLOCKALL; - macinit.BroadcastFramesReception = ETH_BROADCASTFRAMESRECEPTION_ENABLE; - macinit.DestinationAddrFilter = ETH_DESTINATIONADDRFILTER_NORMAL; - macinit.PromiscuousMode = ETH_PROMISCUOUS_MODE_DISABLE; - macinit.MulticastFramesFilter = ETH_MULTICASTFRAMESFILTER_PERFECT; - macinit.UnicastFramesFilter = ETH_UNICASTFRAMESFILTER_PERFECT; - macinit.HashTableHigh = 0x0; - macinit.HashTableLow = 0x0; - macinit.PauseTime = 0x0; - macinit.ZeroQuantaPause = ETH_ZEROQUANTAPAUSE_DISABLE; - macinit.PauseLowThreshold = ETH_PAUSELOWTHRESHOLD_MINUS4; - macinit.UnicastPauseFrameDetect = ETH_UNICASTPAUSEFRAMEDETECT_DISABLE; - macinit.ReceiveFlowControl = ETH_RECEIVEFLOWCONTROL_DISABLE; - macinit.TransmitFlowControl = ETH_TRANSMITFLOWCONTROL_DISABLE; - macinit.VLANTagComparison = ETH_VLANTAGCOMPARISON_16BIT; - macinit.VLANTagIdentifier = 0x0; - - /*------------------------ ETHERNET MACCR Configuration --------------------*/ - /* Get the ETHERNET MACCR value */ - tmpreg = heth->Instance->MACCR; - /* Clear WD, PCE, PS, TE and RE bits */ - tmpreg &= ETH_MACCR_CLEAR_MASK; - /* Set the WD bit according to ETH Watchdog value */ - /* Set the JD: bit according to ETH Jabber value */ - /* Set the IFG bit according to ETH InterFrameGap value */ - /* Set the DCRS bit according to ETH CarrierSense value */ - /* Set the FES bit according to ETH Speed value */ - /* Set the DO bit according to ETH ReceiveOwn value */ - /* Set the LM bit according to ETH LoopbackMode value */ - /* Set the DM bit according to ETH Mode value */ - /* Set the IPCO bit according to ETH ChecksumOffload value */ - /* Set the DR bit according to ETH RetryTransmission value */ - /* Set the ACS bit according to ETH AutomaticPadCRCStrip value */ - /* Set the BL bit according to ETH BackOffLimit value */ - /* Set the DC bit according to ETH DeferralCheck value */ - tmpreg |= (uint32_t)(macinit.Watchdog | - macinit.Jabber | - macinit.InterFrameGap | - macinit.CarrierSense | - heth->Init.Speed | - macinit.ReceiveOwn | - macinit.LoopbackMode | - heth->Init.DuplexMode | - macinit.ChecksumOffload | - macinit.RetryTransmission | - macinit.AutomaticPadCRCStrip | - macinit.BackOffLimit | - macinit.DeferralCheck); - - /* Write to ETHERNET MACCR */ - prvWriteMACCR( heth, tmpreg ); - - /*----------------------- ETHERNET MACFFR Configuration --------------------*/ - /* Set the RA bit according to ETH ReceiveAll value */ - /* Set the SAF and SAIF bits according to ETH SourceAddrFilter value */ - /* Set the PCF bit according to ETH PassControlFrames value */ - /* Set the DBF bit according to ETH BroadcastFramesReception value */ - /* Set the DAIF bit according to ETH DestinationAddrFilter value */ - /* Set the PR bit according to ETH PromiscuousMode value */ - /* Set the PM, HMC and HPF bits according to ETH MulticastFramesFilter value */ - /* Set the HUC and HPF bits according to ETH UnicastFramesFilter value */ - /* Write to ETHERNET MACFFR */ - heth->Instance->MACFFR = (uint32_t)(macinit.ReceiveAll | - macinit.SourceAddrFilter | - macinit.PassControlFrames | - macinit.BroadcastFramesReception | - macinit.DestinationAddrFilter | - macinit.PromiscuousMode | - macinit.MulticastFramesFilter | - macinit.UnicastFramesFilter); - - /* Wait until the write operation will be taken into account: - at least four TX_CLK/RX_CLK clock cycles */ - tmpreg = heth->Instance->MACFFR; - HAL_Delay(ETH_REG_WRITE_DELAY); - heth->Instance->MACFFR = tmpreg; - - /*--------------- ETHERNET MACHTHR and MACHTLR Configuration --------------*/ - /* Write to ETHERNET MACHTHR */ - heth->Instance->MACHTHR = (uint32_t)macinit.HashTableHigh; - - /* Write to ETHERNET MACHTLR */ - heth->Instance->MACHTLR = (uint32_t)macinit.HashTableLow; - /*----------------------- ETHERNET MACFCR Configuration -------------------*/ - - /* Get the ETHERNET MACFCR value */ - tmpreg = heth->Instance->MACFCR; - /* Clear xx bits */ - tmpreg &= ETH_MACFCR_CLEAR_MASK; - - /* Set the PT bit according to ETH PauseTime value */ - /* Set the DZPQ bit according to ETH ZeroQuantaPause value */ - /* Set the PLT bit according to ETH PauseLowThreshold value */ - /* Set the UP bit according to ETH UnicastPauseFrameDetect value */ - /* Set the RFE bit according to ETH ReceiveFlowControl value */ - /* Set the TFE bit according to ETH TransmitFlowControl value */ - tmpreg |= (uint32_t)((macinit.PauseTime << 16) | - macinit.ZeroQuantaPause | - macinit.PauseLowThreshold | - macinit.UnicastPauseFrameDetect | - macinit.ReceiveFlowControl | - macinit.TransmitFlowControl); - - /* Write to ETHERNET MACFCR */ - prvWriteMACFCR( heth, tmpreg ); - - /*----------------------- ETHERNET MACVLANTR Configuration ----------------*/ - /* Set the ETV bit according to ETH VLANTagComparison value */ - /* Set the VL bit according to ETH VLANTagIdentifier value */ - heth->Instance->MACVLANTR = (uint32_t)(macinit.VLANTagComparison | - macinit.VLANTagIdentifier); - - /* Wait until the write operation will be taken into account: - at least four TX_CLK/RX_CLK clock cycles */ - tmpreg = heth->Instance->MACVLANTR; - HAL_Delay(ETH_REG_WRITE_DELAY); - heth->Instance->MACVLANTR = tmpreg; - - /* Ethernet DMA default initialization ************************************/ - dmainit.DropTCPIPChecksumErrorFrame = ETH_DROPTCPIPCHECKSUMERRORFRAME_ENABLE; - dmainit.ReceiveStoreForward = ETH_RECEIVESTOREFORWARD_ENABLE; - dmainit.FlushReceivedFrame = ETH_FLUSHRECEIVEDFRAME_ENABLE; - dmainit.TransmitStoreForward = ETH_TRANSMITSTOREFORWARD_ENABLE; - dmainit.TransmitThresholdControl = ETH_TRANSMITTHRESHOLDCONTROL_64BYTES; - dmainit.ForwardErrorFrames = ETH_FORWARDERRORFRAMES_DISABLE; - dmainit.ForwardUndersizedGoodFrames = ETH_FORWARDUNDERSIZEDGOODFRAMES_DISABLE; - dmainit.ReceiveThresholdControl = ETH_RECEIVEDTHRESHOLDCONTROL_64BYTES; - dmainit.SecondFrameOperate = ETH_SECONDFRAMEOPERARTE_ENABLE; - dmainit.AddressAlignedBeats = ETH_ADDRESSALIGNEDBEATS_ENABLE; - dmainit.FixedBurst = ETH_FIXEDBURST_ENABLE; - dmainit.RxDMABurstLength = ETH_RXDMABURSTLENGTH_32BEAT; - dmainit.TxDMABurstLength = ETH_TXDMABURSTLENGTH_32BEAT; - dmainit.EnhancedDescriptorFormat = ETH_DMAENHANCEDDESCRIPTOR_ENABLE; - dmainit.DescriptorSkipLength = 0x0; - dmainit.DMAArbitration = ETH_DMAARBITRATION_ROUNDROBIN_RXTX_1_1; - - /* Get the ETHERNET DMAOMR value */ - tmpreg = heth->Instance->DMAOMR; - /* Clear xx bits */ - tmpreg &= ETH_DMAOMR_CLEAR_MASK; - - /* Set the DT bit according to ETH DropTCPIPChecksumErrorFrame value */ - /* Set the RSF bit according to ETH ReceiveStoreForward value */ - /* Set the DFF bit according to ETH FlushReceivedFrame value */ - /* Set the TSF bit according to ETH TransmitStoreForward value */ - /* Set the TTC bit according to ETH TransmitThresholdControl value */ - /* Set the FEF bit according to ETH ForwardErrorFrames value */ - /* Set the FUF bit according to ETH ForwardUndersizedGoodFrames value */ - /* Set the RTC bit according to ETH ReceiveThresholdControl value */ - /* Set the OSF bit according to ETH SecondFrameOperate value */ - tmpreg |= (uint32_t)(dmainit.DropTCPIPChecksumErrorFrame | - dmainit.ReceiveStoreForward | - dmainit.FlushReceivedFrame | - dmainit.TransmitStoreForward | - dmainit.TransmitThresholdControl | - dmainit.ForwardErrorFrames | - dmainit.ForwardUndersizedGoodFrames | - dmainit.ReceiveThresholdControl | - dmainit.SecondFrameOperate); - - /* Write to ETHERNET DMAOMR */ - prvWriteDMAOMR( heth, tmpreg ); - - /*----------------------- ETHERNET DMABMR Configuration ------------------*/ - /* Set the AAL bit according to ETH AddressAlignedBeats value */ - /* Set the FB bit according to ETH FixedBurst value */ - /* Set the RPBL and 4*PBL bits according to ETH RxDMABurstLength value */ - /* Set the PBL and 4*PBL bits according to ETH TxDMABurstLength value */ - /* Set the Enhanced DMA descriptors bit according to ETH EnhancedDescriptorFormat value*/ - /* Set the DSL bit according to ETH DesciptorSkipLength value */ - /* Set the PR and DA bits according to ETH DMAArbitration value */ - heth->Instance->DMABMR = (uint32_t)(dmainit.AddressAlignedBeats | - dmainit.FixedBurst | - dmainit.RxDMABurstLength | /* !! if 4xPBL is selected for Tx or Rx it is applied for the other */ - dmainit.TxDMABurstLength | - dmainit.EnhancedDescriptorFormat | - (dmainit.DescriptorSkipLength << 2) | - dmainit.DMAArbitration | - ETH_DMABMR_USP); /* Enable use of separate PBL for Rx and Tx */ - - /* Wait until the write operation will be taken into account: - at least four TX_CLK/RX_CLK clock cycles */ - tmpreg = heth->Instance->DMABMR; - HAL_Delay(ETH_REG_WRITE_DELAY); - heth->Instance->DMABMR = tmpreg; - - if(heth->Init.RxMode == ETH_RXINTERRUPT_MODE) - { - /* Enable the Ethernet Rx Interrupt */ - __HAL_ETH_DMA_ENABLE_IT(( heth ), ETH_DMA_IT_NIS | ETH_DMA_IT_R); - } - - /* Initialize MAC address in ethernet MAC */ - ETH_MACAddressConfig(heth, ETH_MAC_ADDRESS0, heth->Init.MACAddr); -} - -/** - * @brief Configures the selected MAC address. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param MacAddr: The MAC address to configure - * This parameter can be one of the following values: - * @arg ETH_MAC_Address0: MAC Address0 - * @arg ETH_MAC_Address1: MAC Address1 - * @arg ETH_MAC_Address2: MAC Address2 - * @arg ETH_MAC_Address3: MAC Address3 - * @param Addr: Pointer to MAC address buffer data (6 bytes) - * @retval HAL status - */ -static void ETH_MACAddressConfig(ETH_HandleTypeDef *heth, uint32_t MacAddr, uint8_t *Addr) -{ - uint32_t tmpreg; - - /* Check the parameters */ - assert_param( IS_ETH_MAC_ADDRESS0123( MacAddr ) ); - - /* Calculate the selected MAC address high register */ - tmpreg = 0x80000000ul | ( ( uint32_t )Addr[ 5 ] << 8) | (uint32_t)Addr[ 4 ]; - /* Load the selected MAC address high register */ - ( * ( __IO uint32_t * ) ( ( uint32_t ) ( ETH_MAC_ADDR_HBASE + MacAddr ) ) ) = tmpreg; - /* Calculate the selected MAC address low register */ - tmpreg = ( ( uint32_t )Addr[ 3 ] << 24 ) | ( ( uint32_t )Addr[ 2 ] << 16 ) | ( ( uint32_t )Addr[ 1 ] << 8 ) | Addr[ 0 ]; - - /* Load the selected MAC address low register */ - ( * ( __IO uint32_t * ) ( ( uint32_t ) ( ETH_MAC_ADDR_LBASE + MacAddr ) ) ) = tmpreg; -} - -/** - * @brief Enables the MAC transmission. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_MACTransmissionEnable(ETH_HandleTypeDef *heth) -{ - uint32_t tmpreg = heth->Instance->MACCR | ETH_MACCR_TE; - - prvWriteMACCR( heth, tmpreg ); -} - -/** - * @brief Disables the MAC transmission. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_MACTransmissionDisable(ETH_HandleTypeDef *heth) -{ - uint32_t tmpreg = heth->Instance->MACCR & ~( ETH_MACCR_TE ); - - prvWriteMACCR( heth, tmpreg ); -} - -/** - * @brief Enables the MAC reception. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_MACReceptionEnable(ETH_HandleTypeDef *heth) -{ - __IO uint32_t tmpreg = heth->Instance->MACCR | ETH_MACCR_RE; - - prvWriteMACCR( heth, tmpreg ); -} - -/** - * @brief Disables the MAC reception. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_MACReceptionDisable(ETH_HandleTypeDef *heth) -{ - __IO uint32_t tmpreg = heth->Instance->MACCR & ~( ETH_MACCR_RE ); - - prvWriteMACCR( heth, tmpreg ); -} - -/** - * @brief Enables the DMA transmission. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_DMATransmissionEnable(ETH_HandleTypeDef *heth) -{ - /* Enable the DMA transmission */ - __IO uint32_t tmpreg = heth->Instance->DMAOMR | ETH_DMAOMR_ST; - - prvWriteDMAOMR( heth, tmpreg ); -} - -/** - * @brief Disables the DMA transmission. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_DMATransmissionDisable(ETH_HandleTypeDef *heth) -{ - /* Disable the DMA transmission */ - __IO uint32_t tmpreg = heth->Instance->DMAOMR & ~( ETH_DMAOMR_ST ); - - prvWriteDMAOMR( heth, tmpreg ); -} - -/** - * @brief Enables the DMA reception. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_DMAReceptionEnable(ETH_HandleTypeDef *heth) -{ - /* Enable the DMA reception */ - __IO uint32_t tmpreg = heth->Instance->DMAOMR | ETH_DMAOMR_SR; - - prvWriteDMAOMR( heth, tmpreg ); -} - -/** - * @brief Disables the DMA reception. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_DMAReceptionDisable(ETH_HandleTypeDef *heth) -{ - /* Disable the DMA reception */ - __IO uint32_t tmpreg = heth->Instance->DMAOMR & ~( ETH_DMAOMR_SR ); - - prvWriteDMAOMR( heth, tmpreg ); -} - -/** - * @brief Clears the ETHERNET transmit FIFO. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_FlushTransmitFIFO(ETH_HandleTypeDef *heth) -{ - /* Set the Flush Transmit FIFO bit */ - __IO uint32_t tmpreg = heth->Instance->DMAOMR | ETH_DMAOMR_FTF; - - prvWriteDMAOMR( heth, tmpreg ); -} - -/** - * @} - */ - -#endif /* STM32F7xx */ -#endif /* HAL_ETH_MODULE_ENABLED */ -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32F7xx/stm32f7xx_hal_eth.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32F7xx/stm32f7xx_hal_eth.h deleted file mode 100755 index 93c3ffc..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32F7xx/stm32f7xx_hal_eth.h +++ /dev/null @@ -1,2214 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f7xx_hal_eth.h - * @author MCD Application Team - * @version V1.2.2 - * @date 14-April-2017 - * @brief Header file of ETH HAL module. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2017 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F7xx_HAL_ETH_H -#define __STM32F7xx_HAL_ETH_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f7xx_hal_def.h" - -/** @addtogroup STM32F7xx_HAL_Driver - * @{ - */ - -/** @addtogroup ETH - * @{ - */ - -/** @addtogroup ETH_Private_Macros - * @{ - */ -#define IS_ETH_PHY_ADDRESS(ADDRESS) ((ADDRESS) <= 0x20) -#define IS_ETH_AUTONEGOTIATION(CMD) (((CMD) == ETH_AUTONEGOTIATION_ENABLE) || \ - ((CMD) == ETH_AUTONEGOTIATION_DISABLE)) -#define IS_ETH_SPEED(SPEED) (((SPEED) == ETH_SPEED_10M) || \ - ((SPEED) == ETH_SPEED_100M)) -#define IS_ETH_DUPLEX_MODE(MODE) (((MODE) == ETH_MODE_FULLDUPLEX) || \ - ((MODE) == ETH_MODE_HALFDUPLEX)) -#define IS_ETH_RX_MODE(MODE) (((MODE) == ETH_RXPOLLING_MODE) || \ - ((MODE) == ETH_RXINTERRUPT_MODE)) -#define IS_ETH_CHECKSUM_MODE(MODE) (((MODE) == ETH_CHECKSUM_BY_HARDWARE) || \ - ((MODE) == ETH_CHECKSUM_BY_SOFTWARE)) -#define IS_ETH_MEDIA_INTERFACE(MODE) (((MODE) == ETH_MEDIA_INTERFACE_MII) || \ - ((MODE) == ETH_MEDIA_INTERFACE_RMII)) -#define IS_ETH_WATCHDOG(CMD) (((CMD) == ETH_WATCHDOG_ENABLE) || \ - ((CMD) == ETH_WATCHDOG_DISABLE)) -#define IS_ETH_JABBER(CMD) (((CMD) == ETH_JABBER_ENABLE) || \ - ((CMD) == ETH_JABBER_DISABLE)) -#define IS_ETH_INTER_FRAME_GAP(GAP) (((GAP) == ETH_INTERFRAMEGAP_96BIT) || \ - ((GAP) == ETH_INTERFRAMEGAP_88BIT) || \ - ((GAP) == ETH_INTERFRAMEGAP_80BIT) || \ - ((GAP) == ETH_INTERFRAMEGAP_72BIT) || \ - ((GAP) == ETH_INTERFRAMEGAP_64BIT) || \ - ((GAP) == ETH_INTERFRAMEGAP_56BIT) || \ - ((GAP) == ETH_INTERFRAMEGAP_48BIT) || \ - ((GAP) == ETH_INTERFRAMEGAP_40BIT)) -#define IS_ETH_CARRIER_SENSE(CMD) (((CMD) == ETH_CARRIERSENCE_ENABLE) || \ - ((CMD) == ETH_CARRIERSENCE_DISABLE)) -#define IS_ETH_RECEIVE_OWN(CMD) (((CMD) == ETH_RECEIVEOWN_ENABLE) || \ - ((CMD) == ETH_RECEIVEOWN_DISABLE)) -#define IS_ETH_LOOPBACK_MODE(CMD) (((CMD) == ETH_LOOPBACKMODE_ENABLE) || \ - ((CMD) == ETH_LOOPBACKMODE_DISABLE)) -#define IS_ETH_CHECKSUM_OFFLOAD(CMD) (((CMD) == ETH_CHECKSUMOFFLAOD_ENABLE) || \ - ((CMD) == ETH_CHECKSUMOFFLAOD_DISABLE)) -#define IS_ETH_RETRY_TRANSMISSION(CMD) (((CMD) == ETH_RETRYTRANSMISSION_ENABLE) || \ - ((CMD) == ETH_RETRYTRANSMISSION_DISABLE)) -#define IS_ETH_AUTOMATIC_PADCRC_STRIP(CMD) (((CMD) == ETH_AUTOMATICPADCRCSTRIP_ENABLE) || \ - ((CMD) == ETH_AUTOMATICPADCRCSTRIP_DISABLE)) -#define IS_ETH_BACKOFF_LIMIT(LIMIT) (((LIMIT) == ETH_BACKOFFLIMIT_10) || \ - ((LIMIT) == ETH_BACKOFFLIMIT_8) || \ - ((LIMIT) == ETH_BACKOFFLIMIT_4) || \ - ((LIMIT) == ETH_BACKOFFLIMIT_1)) -#define IS_ETH_DEFERRAL_CHECK(CMD) (((CMD) == ETH_DEFFERRALCHECK_ENABLE) || \ - ((CMD) == ETH_DEFFERRALCHECK_DISABLE)) -#define IS_ETH_RECEIVE_ALL(CMD) (((CMD) == ETH_RECEIVEALL_ENABLE) || \ - ((CMD) == ETH_RECEIVEAll_DISABLE)) -#define IS_ETH_SOURCE_ADDR_FILTER(CMD) (((CMD) == ETH_SOURCEADDRFILTER_NORMAL_ENABLE) || \ - ((CMD) == ETH_SOURCEADDRFILTER_INVERSE_ENABLE) || \ - ((CMD) == ETH_SOURCEADDRFILTER_DISABLE)) -#define IS_ETH_CONTROL_FRAMES(PASS) (((PASS) == ETH_PASSCONTROLFRAMES_BLOCKALL) || \ - ((PASS) == ETH_PASSCONTROLFRAMES_FORWARDALL) || \ - ((PASS) == ETH_PASSCONTROLFRAMES_FORWARDPASSEDADDRFILTER)) -#define IS_ETH_BROADCAST_FRAMES_RECEPTION(CMD) (((CMD) == ETH_BROADCASTFRAMESRECEPTION_ENABLE) || \ - ((CMD) == ETH_BROADCASTFRAMESRECEPTION_DISABLE)) -#define IS_ETH_DESTINATION_ADDR_FILTER(FILTER) (((FILTER) == ETH_DESTINATIONADDRFILTER_NORMAL) || \ - ((FILTER) == ETH_DESTINATIONADDRFILTER_INVERSE)) -#define IS_ETH_PROMISCUOUS_MODE(CMD) (((CMD) == ETH_PROMISCUOUS_MODE_ENABLE) || \ - ((CMD) == ETH_PROMISCUOUS_MODE_DISABLE)) -#define IS_ETH_MULTICAST_FRAMES_FILTER(FILTER) (((FILTER) == ETH_MULTICASTFRAMESFILTER_PERFECTHASHTABLE) || \ - ((FILTER) == ETH_MULTICASTFRAMESFILTER_HASHTABLE) || \ - ((FILTER) == ETH_MULTICASTFRAMESFILTER_PERFECT) || \ - ((FILTER) == ETH_MULTICASTFRAMESFILTER_NONE)) -#define IS_ETH_UNICAST_FRAMES_FILTER(FILTER) (((FILTER) == ETH_UNICASTFRAMESFILTER_PERFECTHASHTABLE) || \ - ((FILTER) == ETH_UNICASTFRAMESFILTER_HASHTABLE) || \ - ((FILTER) == ETH_UNICASTFRAMESFILTER_PERFECT)) -#define IS_ETH_PAUSE_TIME(TIME) ((TIME) <= 0xFFFF) -#define IS_ETH_ZEROQUANTA_PAUSE(CMD) (((CMD) == ETH_ZEROQUANTAPAUSE_ENABLE) || \ - ((CMD) == ETH_ZEROQUANTAPAUSE_DISABLE)) -#define IS_ETH_PAUSE_LOW_THRESHOLD(THRESHOLD) (((THRESHOLD) == ETH_PAUSELOWTHRESHOLD_MINUS4) || \ - ((THRESHOLD) == ETH_PAUSELOWTHRESHOLD_MINUS28) || \ - ((THRESHOLD) == ETH_PAUSELOWTHRESHOLD_MINUS144) || \ - ((THRESHOLD) == ETH_PAUSELOWTHRESHOLD_MINUS256)) -#define IS_ETH_UNICAST_PAUSE_FRAME_DETECT(CMD) (((CMD) == ETH_UNICASTPAUSEFRAMEDETECT_ENABLE) || \ - ((CMD) == ETH_UNICASTPAUSEFRAMEDETECT_DISABLE)) -#define IS_ETH_RECEIVE_FLOWCONTROL(CMD) (((CMD) == ETH_RECEIVEFLOWCONTROL_ENABLE) || \ - ((CMD) == ETH_RECEIVEFLOWCONTROL_DISABLE)) -#define IS_ETH_TRANSMIT_FLOWCONTROL(CMD) (((CMD) == ETH_TRANSMITFLOWCONTROL_ENABLE) || \ - ((CMD) == ETH_TRANSMITFLOWCONTROL_DISABLE)) -#define IS_ETH_VLAN_TAG_COMPARISON(COMPARISON) (((COMPARISON) == ETH_VLANTAGCOMPARISON_12BIT) || \ - ((COMPARISON) == ETH_VLANTAGCOMPARISON_16BIT)) -#define IS_ETH_VLAN_TAG_IDENTIFIER(IDENTIFIER) ((IDENTIFIER) <= 0xFFFF) -#define IS_ETH_MAC_ADDRESS0123(ADDRESS) (((ADDRESS) == ETH_MAC_ADDRESS0) || \ - ((ADDRESS) == ETH_MAC_ADDRESS1) || \ - ((ADDRESS) == ETH_MAC_ADDRESS2) || \ - ((ADDRESS) == ETH_MAC_ADDRESS3)) -#define IS_ETH_MAC_ADDRESS123(ADDRESS) (((ADDRESS) == ETH_MAC_ADDRESS1) || \ - ((ADDRESS) == ETH_MAC_ADDRESS2) || \ - ((ADDRESS) == ETH_MAC_ADDRESS3)) -#define IS_ETH_MAC_ADDRESS_FILTER(FILTER) (((FILTER) == ETH_MAC_ADDRESSFILTER_SA) || \ - ((FILTER) == ETH_MAC_ADDRESSFILTER_DA)) -#define IS_ETH_MAC_ADDRESS_MASK(MASK) (((MASK) == ETH_MAC_ADDRESSMASK_BYTE6) || \ - ((MASK) == ETH_MAC_ADDRESSMASK_BYTE5) || \ - ((MASK) == ETH_MAC_ADDRESSMASK_BYTE4) || \ - ((MASK) == ETH_MAC_ADDRESSMASK_BYTE3) || \ - ((MASK) == ETH_MAC_ADDRESSMASK_BYTE2) || \ - ((MASK) == ETH_MAC_ADDRESSMASK_BYTE1)) -#define IS_ETH_DROP_TCPIP_CHECKSUM_FRAME(CMD) (((CMD) == ETH_DROPTCPIPCHECKSUMERRORFRAME_ENABLE) || \ - ((CMD) == ETH_DROPTCPIPCHECKSUMERRORFRAME_DISABLE)) -#define IS_ETH_RECEIVE_STORE_FORWARD(CMD) (((CMD) == ETH_RECEIVESTOREFORWARD_ENABLE) || \ - ((CMD) == ETH_RECEIVESTOREFORWARD_DISABLE)) -#define IS_ETH_FLUSH_RECEIVE_FRAME(CMD) (((CMD) == ETH_FLUSHRECEIVEDFRAME_ENABLE) || \ - ((CMD) == ETH_FLUSHRECEIVEDFRAME_DISABLE)) -#define IS_ETH_TRANSMIT_STORE_FORWARD(CMD) (((CMD) == ETH_TRANSMITSTOREFORWARD_ENABLE) || \ - ((CMD) == ETH_TRANSMITSTOREFORWARD_DISABLE)) -#define IS_ETH_TRANSMIT_THRESHOLD_CONTROL(THRESHOLD) (((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_64BYTES) || \ - ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_128BYTES) || \ - ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_192BYTES) || \ - ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_256BYTES) || \ - ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_40BYTES) || \ - ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_32BYTES) || \ - ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_24BYTES) || \ - ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_16BYTES)) -#define IS_ETH_FORWARD_ERROR_FRAMES(CMD) (((CMD) == ETH_FORWARDERRORFRAMES_ENABLE) || \ - ((CMD) == ETH_FORWARDERRORFRAMES_DISABLE)) -#define IS_ETH_FORWARD_UNDERSIZED_GOOD_FRAMES(CMD) (((CMD) == ETH_FORWARDUNDERSIZEDGOODFRAMES_ENABLE) || \ - ((CMD) == ETH_FORWARDUNDERSIZEDGOODFRAMES_DISABLE)) -#define IS_ETH_RECEIVE_THRESHOLD_CONTROL(THRESHOLD) (((THRESHOLD) == ETH_RECEIVEDTHRESHOLDCONTROL_64BYTES) || \ - ((THRESHOLD) == ETH_RECEIVEDTHRESHOLDCONTROL_32BYTES) || \ - ((THRESHOLD) == ETH_RECEIVEDTHRESHOLDCONTROL_96BYTES) || \ - ((THRESHOLD) == ETH_RECEIVEDTHRESHOLDCONTROL_128BYTES)) -#define IS_ETH_SECOND_FRAME_OPERATE(CMD) (((CMD) == ETH_SECONDFRAMEOPERARTE_ENABLE) || \ - ((CMD) == ETH_SECONDFRAMEOPERARTE_DISABLE)) -#define IS_ETH_ADDRESS_ALIGNED_BEATS(CMD) (((CMD) == ETH_ADDRESSALIGNEDBEATS_ENABLE) || \ - ((CMD) == ETH_ADDRESSALIGNEDBEATS_DISABLE)) -#define IS_ETH_FIXED_BURST(CMD) (((CMD) == ETH_FIXEDBURST_ENABLE) || \ - ((CMD) == ETH_FIXEDBURST_DISABLE)) -#define IS_ETH_RXDMA_BURST_LENGTH(LENGTH) (((LENGTH) == ETH_RXDMABURSTLENGTH_1BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_2BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_4BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_8BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_16BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_32BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_4BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_8BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_16BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_32BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_64BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_128BEAT)) -#define IS_ETH_TXDMA_BURST_LENGTH(LENGTH) (((LENGTH) == ETH_TXDMABURSTLENGTH_1BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_2BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_4BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_8BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_16BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_32BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_4BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_8BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_16BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_32BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_64BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_128BEAT)) -#define IS_ETH_DMA_DESC_SKIP_LENGTH(LENGTH) ((LENGTH) <= 0x1F) -#define IS_ETH_DMA_ARBITRATION_ROUNDROBIN_RXTX(RATIO) (((RATIO) == ETH_DMAARBITRATION_ROUNDROBIN_RXTX_1_1) || \ - ((RATIO) == ETH_DMAARBITRATION_ROUNDROBIN_RXTX_2_1) || \ - ((RATIO) == ETH_DMAARBITRATION_ROUNDROBIN_RXTX_3_1) || \ - ((RATIO) == ETH_DMAARBITRATION_ROUNDROBIN_RXTX_4_1) || \ - ((RATIO) == ETH_DMAARBITRATION_RXPRIORTX)) -#define IS_ETH_DMATXDESC_GET_FLAG(FLAG) (((FLAG) == ETH_DMATXDESC_OWN) || \ - ((FLAG) == ETH_DMATXDESC_IC) || \ - ((FLAG) == ETH_DMATXDESC_LS) || \ - ((FLAG) == ETH_DMATXDESC_FS) || \ - ((FLAG) == ETH_DMATXDESC_DC) || \ - ((FLAG) == ETH_DMATXDESC_DP) || \ - ((FLAG) == ETH_DMATXDESC_TTSE) || \ - ((FLAG) == ETH_DMATXDESC_TER) || \ - ((FLAG) == ETH_DMATXDESC_TCH) || \ - ((FLAG) == ETH_DMATXDESC_TTSS) || \ - ((FLAG) == ETH_DMATXDESC_IHE) || \ - ((FLAG) == ETH_DMATXDESC_ES) || \ - ((FLAG) == ETH_DMATXDESC_JT) || \ - ((FLAG) == ETH_DMATXDESC_FF) || \ - ((FLAG) == ETH_DMATXDESC_PCE) || \ - ((FLAG) == ETH_DMATXDESC_LCA) || \ - ((FLAG) == ETH_DMATXDESC_NC) || \ - ((FLAG) == ETH_DMATXDESC_LCO) || \ - ((FLAG) == ETH_DMATXDESC_EC) || \ - ((FLAG) == ETH_DMATXDESC_VF) || \ - ((FLAG) == ETH_DMATXDESC_CC) || \ - ((FLAG) == ETH_DMATXDESC_ED) || \ - ((FLAG) == ETH_DMATXDESC_UF) || \ - ((FLAG) == ETH_DMATXDESC_DB)) -#define IS_ETH_DMA_TXDESC_SEGMENT(SEGMENT) (((SEGMENT) == ETH_DMATXDESC_LASTSEGMENTS) || \ - ((SEGMENT) == ETH_DMATXDESC_FIRSTSEGMENT)) -#define IS_ETH_DMA_TXDESC_CHECKSUM(CHECKSUM) (((CHECKSUM) == ETH_DMATXDESC_CHECKSUMBYPASS) || \ - ((CHECKSUM) == ETH_DMATXDESC_CHECKSUMIPV4HEADER) || \ - ((CHECKSUM) == ETH_DMATXDESC_CHECKSUMTCPUDPICMPSEGMENT) || \ - ((CHECKSUM) == ETH_DMATXDESC_CHECKSUMTCPUDPICMPFULL)) -#define IS_ETH_DMATXDESC_BUFFER_SIZE(SIZE) ((SIZE) <= 0x1FFF) -#define IS_ETH_DMARXDESC_GET_FLAG(FLAG) (((FLAG) == ETH_DMARXDESC_OWN) || \ - ((FLAG) == ETH_DMARXDESC_AFM) || \ - ((FLAG) == ETH_DMARXDESC_ES) || \ - ((FLAG) == ETH_DMARXDESC_DE) || \ - ((FLAG) == ETH_DMARXDESC_SAF) || \ - ((FLAG) == ETH_DMARXDESC_LE) || \ - ((FLAG) == ETH_DMARXDESC_OE) || \ - ((FLAG) == ETH_DMARXDESC_VLAN) || \ - ((FLAG) == ETH_DMARXDESC_FS) || \ - ((FLAG) == ETH_DMARXDESC_LS) || \ - ((FLAG) == ETH_DMARXDESC_IPV4HCE) || \ - ((FLAG) == ETH_DMARXDESC_LC) || \ - ((FLAG) == ETH_DMARXDESC_FT) || \ - ((FLAG) == ETH_DMARXDESC_RWT) || \ - ((FLAG) == ETH_DMARXDESC_RE) || \ - ((FLAG) == ETH_DMARXDESC_DBE) || \ - ((FLAG) == ETH_DMARXDESC_CE) || \ - ((FLAG) == ETH_DMARXDESC_MAMPCE)) -#define IS_ETH_DMA_RXDESC_BUFFER(BUFFER) (((BUFFER) == ETH_DMARXDESC_BUFFER1) || \ - ((BUFFER) == ETH_DMARXDESC_BUFFER2)) -#define IS_ETH_PMT_GET_FLAG(FLAG) (((FLAG) == ETH_PMT_FLAG_WUFR) || \ - ((FLAG) == ETH_PMT_FLAG_MPR)) -#define IS_ETH_DMA_FLAG(FLAG) ((((FLAG) & (uint32_t)0xC7FE1800) == 0x00) && ((FLAG) != 0x00)) -#define IS_ETH_DMA_GET_FLAG(FLAG) (((FLAG) == ETH_DMA_FLAG_TST) || ((FLAG) == ETH_DMA_FLAG_PMT) || \ - ((FLAG) == ETH_DMA_FLAG_MMC) || ((FLAG) == ETH_DMA_FLAG_DATATRANSFERERROR) || \ - ((FLAG) == ETH_DMA_FLAG_READWRITEERROR) || ((FLAG) == ETH_DMA_FLAG_ACCESSERROR) || \ - ((FLAG) == ETH_DMA_FLAG_NIS) || ((FLAG) == ETH_DMA_FLAG_AIS) || \ - ((FLAG) == ETH_DMA_FLAG_ER) || ((FLAG) == ETH_DMA_FLAG_FBE) || \ - ((FLAG) == ETH_DMA_FLAG_ET) || ((FLAG) == ETH_DMA_FLAG_RWT) || \ - ((FLAG) == ETH_DMA_FLAG_RPS) || ((FLAG) == ETH_DMA_FLAG_RBU) || \ - ((FLAG) == ETH_DMA_FLAG_R) || ((FLAG) == ETH_DMA_FLAG_TU) || \ - ((FLAG) == ETH_DMA_FLAG_RO) || ((FLAG) == ETH_DMA_FLAG_TJT) || \ - ((FLAG) == ETH_DMA_FLAG_TBU) || ((FLAG) == ETH_DMA_FLAG_TPS) || \ - ((FLAG) == ETH_DMA_FLAG_T)) -#define IS_ETH_MAC_IT(IT) ((((IT) & (uint32_t)0xFFFFFDF1) == 0x00) && ((IT) != 0x00)) -#define IS_ETH_MAC_GET_IT(IT) (((IT) == ETH_MAC_IT_TST) || ((IT) == ETH_MAC_IT_MMCT) || \ - ((IT) == ETH_MAC_IT_MMCR) || ((IT) == ETH_MAC_IT_MMC) || \ - ((IT) == ETH_MAC_IT_PMT)) -#define IS_ETH_MAC_GET_FLAG(FLAG) (((FLAG) == ETH_MAC_FLAG_TST) || ((FLAG) == ETH_MAC_FLAG_MMCT) || \ - ((FLAG) == ETH_MAC_FLAG_MMCR) || ((FLAG) == ETH_MAC_FLAG_MMC) || \ - ((FLAG) == ETH_MAC_FLAG_PMT)) -#define IS_ETH_DMA_IT(IT) ((((IT) & (uint32_t)0xC7FE1800) == 0x00) && ((IT) != 0x00)) -#define IS_ETH_DMA_GET_IT(IT) (((IT) == ETH_DMA_IT_TST) || ((IT) == ETH_DMA_IT_PMT) || \ - ((IT) == ETH_DMA_IT_MMC) || ((IT) == ETH_DMA_IT_NIS) || \ - ((IT) == ETH_DMA_IT_AIS) || ((IT) == ETH_DMA_IT_ER) || \ - ((IT) == ETH_DMA_IT_FBE) || ((IT) == ETH_DMA_IT_ET) || \ - ((IT) == ETH_DMA_IT_RWT) || ((IT) == ETH_DMA_IT_RPS) || \ - ((IT) == ETH_DMA_IT_RBU) || ((IT) == ETH_DMA_IT_R) || \ - ((IT) == ETH_DMA_IT_TU) || ((IT) == ETH_DMA_IT_RO) || \ - ((IT) == ETH_DMA_IT_TJT) || ((IT) == ETH_DMA_IT_TBU) || \ - ((IT) == ETH_DMA_IT_TPS) || ((IT) == ETH_DMA_IT_T)) -#define IS_ETH_DMA_GET_OVERFLOW(OVERFLOW) (((OVERFLOW) == ETH_DMA_OVERFLOW_RXFIFOCOUNTER) || \ - ((OVERFLOW) == ETH_DMA_OVERFLOW_MISSEDFRAMECOUNTER)) -#define IS_ETH_MMC_IT(IT) (((((IT) & (uint32_t)0xFFDF3FFF) == 0x00) || (((IT) & (uint32_t)0xEFFDFF9F) == 0x00)) && \ - ((IT) != 0x00)) -#define IS_ETH_MMC_GET_IT(IT) (((IT) == ETH_MMC_IT_TGF) || ((IT) == ETH_MMC_IT_TGFMSC) || \ - ((IT) == ETH_MMC_IT_TGFSC) || ((IT) == ETH_MMC_IT_RGUF) || \ - ((IT) == ETH_MMC_IT_RFAE) || ((IT) == ETH_MMC_IT_RFCE)) -#define IS_ETH_ENHANCED_DESCRIPTOR_FORMAT(CMD) (((CMD) == ETH_DMAENHANCEDDESCRIPTOR_ENABLE) || \ - ((CMD) == ETH_DMAENHANCEDDESCRIPTOR_DISABLE)) - - -/** - * @} - */ - -/** @addtogroup ETH_Private_Defines - * @{ - */ -/* Delay to wait when writing to some Ethernet registers */ -#define ETH_REG_WRITE_DELAY ((uint32_t)0x00000001U) - -/* Ethernet Errors */ -#define ETH_SUCCESS ((uint32_t)0U) -#define ETH_ERROR ((uint32_t)1U) - -/* Ethernet DMA Tx descriptors Collision Count Shift */ -#define ETH_DMATXDESC_COLLISION_COUNTSHIFT ((uint32_t)3U) - -/* Ethernet DMA Tx descriptors Buffer2 Size Shift */ -#define ETH_DMATXDESC_BUFFER2_SIZESHIFT ((uint32_t)16U) - -/* Ethernet DMA Rx descriptors Frame Length Shift */ -#define ETH_DMARXDESC_FRAME_LENGTHSHIFT ((uint32_t)16U) - -/* Ethernet DMA Rx descriptors Buffer2 Size Shift */ -#define ETH_DMARXDESC_BUFFER2_SIZESHIFT ((uint32_t)16U) - -/* Ethernet DMA Rx descriptors Frame length Shift */ -#define ETH_DMARXDESC_FRAMELENGTHSHIFT ((uint32_t)16) - -/* Ethernet MAC address offsets */ -#define ETH_MAC_ADDR_HBASE (uint32_t)(ETH_MAC_BASE + (uint32_t)0x40U) /* Ethernet MAC address high offset */ -#define ETH_MAC_ADDR_LBASE (uint32_t)(ETH_MAC_BASE + (uint32_t)0x44U) /* Ethernet MAC address low offset */ - -/* Ethernet MACMIIAR register Mask */ -#define ETH_MACMIIAR_CR_MASK ((uint32_t)0xFFFFFFE3U) - -/* Ethernet MACCR register Mask */ -#define ETH_MACCR_CLEAR_MASK ((uint32_t)0xFF20810FU) - -/* Ethernet MACFCR register Mask */ -#define ETH_MACFCR_CLEAR_MASK ((uint32_t)0x0000FF41U) - -/* Ethernet DMAOMR register Mask */ -#define ETH_DMAOMR_CLEAR_MASK ((uint32_t)0xF8DE3F23U) - -/* Ethernet Remote Wake-up frame register length */ -#define ETH_WAKEUP_REGISTER_LENGTH 8U - -/* Ethernet Missed frames counter Shift */ -#define ETH_DMA_RX_OVERFLOW_MISSEDFRAMES_COUNTERSHIFT 17U - /** - * @} - */ - -/* Exported types ------------------------------------------------------------*/ -/** @defgroup ETH_Exported_Types ETH Exported Types - * @{ - */ - -/** - * @brief HAL State structures definition - */ -typedef enum -{ - HAL_ETH_STATE_RESET = 0x00U, /*!< Peripheral not yet Initialized or disabled */ - HAL_ETH_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */ - HAL_ETH_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */ - HAL_ETH_STATE_BUSY_TX = 0x12U, /*!< Data Transmission process is ongoing */ - HAL_ETH_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */ - HAL_ETH_STATE_BUSY_TX_RX = 0x32U, /*!< Data Transmission and Reception process is ongoing */ - HAL_ETH_STATE_BUSY_WR = 0x42U, /*!< Write process is ongoing */ - HAL_ETH_STATE_BUSY_RD = 0x82U, /*!< Read process is ongoing */ - HAL_ETH_STATE_TIMEOUT = 0x03U, /*!< Timeout state */ - HAL_ETH_STATE_ERROR = 0x04U /*!< Reception process is ongoing */ -}HAL_ETH_StateTypeDef; - -/** - * @brief ETH Init Structure definition - */ - -typedef struct -{ - uint32_t AutoNegotiation; /*!< Selects or not the AutoNegotiation mode for the external PHY - The AutoNegotiation allows an automatic setting of the Speed (10/100Mbps) - and the mode (half/full-duplex). - This parameter can be a value of @ref ETH_AutoNegotiation */ - - uint32_t Speed; /*!< Sets the Ethernet speed: 10/100 Mbps. - This parameter can be a value of @ref ETH_Speed */ - - uint32_t DuplexMode; /*!< Selects the MAC duplex mode: Half-Duplex or Full-Duplex mode - This parameter can be a value of @ref ETH_Duplex_Mode */ - - uint16_t PhyAddress; /*!< Ethernet PHY address. - This parameter must be a number between Min_Data = 0 and Max_Data = 32 */ - - uint8_t *MACAddr; /*!< MAC Address of used Hardware: must be pointer on an array of 6 bytes */ - - uint32_t RxMode; /*!< Selects the Ethernet Rx mode: Polling mode, Interrupt mode. - This parameter can be a value of @ref ETH_Rx_Mode */ - - uint32_t ChecksumMode; /*!< Selects if the checksum is check by hardware or by software. - This parameter can be a value of @ref ETH_Checksum_Mode */ - - uint32_t MediaInterface ; /*!< Selects the media-independent interface or the reduced media-independent interface. - This parameter can be a value of @ref ETH_Media_Interface */ - -} ETH_InitTypeDef; - - - /** - * @brief ETH MAC Configuration Structure definition - */ - -typedef struct -{ - uint32_t Watchdog; /*!< Selects or not the Watchdog timer - When enabled, the MAC allows no more then 2048 bytes to be received. - When disabled, the MAC can receive up to 16384 bytes. - This parameter can be a value of @ref ETH_Watchdog */ - - uint32_t Jabber; /*!< Selects or not Jabber timer - When enabled, the MAC allows no more then 2048 bytes to be sent. - When disabled, the MAC can send up to 16384 bytes. - This parameter can be a value of @ref ETH_Jabber */ - - uint32_t InterFrameGap; /*!< Selects the minimum IFG between frames during transmission. - This parameter can be a value of @ref ETH_Inter_Frame_Gap */ - - uint32_t CarrierSense; /*!< Selects or not the Carrier Sense. - This parameter can be a value of @ref ETH_Carrier_Sense */ - - uint32_t ReceiveOwn; /*!< Selects or not the ReceiveOwn, - ReceiveOwn allows the reception of frames when the TX_EN signal is asserted - in Half-Duplex mode. - This parameter can be a value of @ref ETH_Receive_Own */ - - uint32_t LoopbackMode; /*!< Selects or not the internal MAC MII Loopback mode. - This parameter can be a value of @ref ETH_Loop_Back_Mode */ - - uint32_t ChecksumOffload; /*!< Selects or not the IPv4 checksum checking for received frame payloads' TCP/UDP/ICMP headers. - This parameter can be a value of @ref ETH_Checksum_Offload */ - - uint32_t RetryTransmission; /*!< Selects or not the MAC attempt retries transmission, based on the settings of BL, - when a collision occurs (Half-Duplex mode). - This parameter can be a value of @ref ETH_Retry_Transmission */ - - uint32_t AutomaticPadCRCStrip; /*!< Selects or not the Automatic MAC Pad/CRC Stripping. - This parameter can be a value of @ref ETH_Automatic_Pad_CRC_Strip */ - - uint32_t BackOffLimit; /*!< Selects the BackOff limit value. - This parameter can be a value of @ref ETH_Back_Off_Limit */ - - uint32_t DeferralCheck; /*!< Selects or not the deferral check function (Half-Duplex mode). - This parameter can be a value of @ref ETH_Deferral_Check */ - - uint32_t ReceiveAll; /*!< Selects or not all frames reception by the MAC (No filtering). - This parameter can be a value of @ref ETH_Receive_All */ - - uint32_t SourceAddrFilter; /*!< Selects the Source Address Filter mode. - This parameter can be a value of @ref ETH_Source_Addr_Filter */ - - uint32_t PassControlFrames; /*!< Sets the forwarding mode of the control frames (including unicast and multicast PAUSE frames) - This parameter can be a value of @ref ETH_Pass_Control_Frames */ - - uint32_t BroadcastFramesReception; /*!< Selects or not the reception of Broadcast Frames. - This parameter can be a value of @ref ETH_Broadcast_Frames_Reception */ - - uint32_t DestinationAddrFilter; /*!< Sets the destination filter mode for both unicast and multicast frames. - This parameter can be a value of @ref ETH_Destination_Addr_Filter */ - - uint32_t PromiscuousMode; /*!< Selects or not the Promiscuous Mode - This parameter can be a value of @ref ETH_Promiscuous_Mode */ - - uint32_t MulticastFramesFilter; /*!< Selects the Multicast Frames filter mode: None/HashTableFilter/PerfectFilter/PerfectHashTableFilter. - This parameter can be a value of @ref ETH_Multicast_Frames_Filter */ - - uint32_t UnicastFramesFilter; /*!< Selects the Unicast Frames filter mode: HashTableFilter/PerfectFilter/PerfectHashTableFilter. - This parameter can be a value of @ref ETH_Unicast_Frames_Filter */ - - uint32_t HashTableHigh; /*!< This field holds the higher 32 bits of Hash table. - This parameter must be a number between Min_Data = 0x0 and Max_Data = 0xFFFFFFFF */ - - uint32_t HashTableLow; /*!< This field holds the lower 32 bits of Hash table. - This parameter must be a number between Min_Data = 0x0 and Max_Data = 0xFFFFFFFF */ - - uint32_t PauseTime; /*!< This field holds the value to be used in the Pause Time field in the transmit control frame. - This parameter must be a number between Min_Data = 0x0 and Max_Data = 0xFFFF */ - - uint32_t ZeroQuantaPause; /*!< Selects or not the automatic generation of Zero-Quanta Pause Control frames. - This parameter can be a value of @ref ETH_Zero_Quanta_Pause */ - - uint32_t PauseLowThreshold; /*!< This field configures the threshold of the PAUSE to be checked for - automatic retransmission of PAUSE Frame. - This parameter can be a value of @ref ETH_Pause_Low_Threshold */ - - uint32_t UnicastPauseFrameDetect; /*!< Selects or not the MAC detection of the Pause frames (with MAC Address0 - unicast address and unique multicast address). - This parameter can be a value of @ref ETH_Unicast_Pause_Frame_Detect */ - - uint32_t ReceiveFlowControl; /*!< Enables or disables the MAC to decode the received Pause frame and - disable its transmitter for a specified time (Pause Time) - This parameter can be a value of @ref ETH_Receive_Flow_Control */ - - uint32_t TransmitFlowControl; /*!< Enables or disables the MAC to transmit Pause frames (Full-Duplex mode) - or the MAC back-pressure operation (Half-Duplex mode) - This parameter can be a value of @ref ETH_Transmit_Flow_Control */ - - uint32_t VLANTagComparison; /*!< Selects the 12-bit VLAN identifier or the complete 16-bit VLAN tag for - comparison and filtering. - This parameter can be a value of @ref ETH_VLAN_Tag_Comparison */ - - uint32_t VLANTagIdentifier; /*!< Holds the VLAN tag identifier for receive frames */ - -} ETH_MACInitTypeDef; - - -/** - * @brief ETH DMA Configuration Structure definition - */ - -typedef struct -{ - uint32_t DropTCPIPChecksumErrorFrame; /*!< Selects or not the Dropping of TCP/IP Checksum Error Frames. - This parameter can be a value of @ref ETH_Drop_TCP_IP_Checksum_Error_Frame */ - - uint32_t ReceiveStoreForward; /*!< Enables or disables the Receive store and forward mode. - This parameter can be a value of @ref ETH_Receive_Store_Forward */ - - uint32_t FlushReceivedFrame; /*!< Enables or disables the flushing of received frames. - This parameter can be a value of @ref ETH_Flush_Received_Frame */ - - uint32_t TransmitStoreForward; /*!< Enables or disables Transmit store and forward mode. - This parameter can be a value of @ref ETH_Transmit_Store_Forward */ - - uint32_t TransmitThresholdControl; /*!< Selects or not the Transmit Threshold Control. - This parameter can be a value of @ref ETH_Transmit_Threshold_Control */ - - uint32_t ForwardErrorFrames; /*!< Selects or not the forward to the DMA of erroneous frames. - This parameter can be a value of @ref ETH_Forward_Error_Frames */ - - uint32_t ForwardUndersizedGoodFrames; /*!< Enables or disables the Rx FIFO to forward Undersized frames (frames with no Error - and length less than 64 bytes) including pad-bytes and CRC) - This parameter can be a value of @ref ETH_Forward_Undersized_Good_Frames */ - - uint32_t ReceiveThresholdControl; /*!< Selects the threshold level of the Receive FIFO. - This parameter can be a value of @ref ETH_Receive_Threshold_Control */ - - uint32_t SecondFrameOperate; /*!< Selects or not the Operate on second frame mode, which allows the DMA to process a second - frame of Transmit data even before obtaining the status for the first frame. - This parameter can be a value of @ref ETH_Second_Frame_Operate */ - - uint32_t AddressAlignedBeats; /*!< Enables or disables the Address Aligned Beats. - This parameter can be a value of @ref ETH_Address_Aligned_Beats */ - - uint32_t FixedBurst; /*!< Enables or disables the AHB Master interface fixed burst transfers. - This parameter can be a value of @ref ETH_Fixed_Burst */ - - uint32_t RxDMABurstLength; /*!< Indicates the maximum number of beats to be transferred in one Rx DMA transaction. - This parameter can be a value of @ref ETH_Rx_DMA_Burst_Length */ - - uint32_t TxDMABurstLength; /*!< Indicates the maximum number of beats to be transferred in one Tx DMA transaction. - This parameter can be a value of @ref ETH_Tx_DMA_Burst_Length */ - - uint32_t EnhancedDescriptorFormat; /*!< Enables the enhanced descriptor format. - This parameter can be a value of @ref ETH_DMA_Enhanced_descriptor_format */ - - uint32_t DescriptorSkipLength; /*!< Specifies the number of word to skip between two unchained descriptors (Ring mode) - This parameter must be a number between Min_Data = 0 and Max_Data = 32 */ - - uint32_t DMAArbitration; /*!< Selects the DMA Tx/Rx arbitration. - This parameter can be a value of @ref ETH_DMA_Arbitration */ -} ETH_DMAInitTypeDef; - - -/** - * @brief ETH DMA Descriptors data structure definition - */ - -typedef struct -{ - __IO uint32_t Status; /*!< Status */ - - uint32_t ControlBufferSize; /*!< Control and Buffer1, Buffer2 lengths */ - - uint32_t Buffer1Addr; /*!< Buffer1 address pointer */ - - uint32_t Buffer2NextDescAddr; /*!< Buffer2 or next descriptor address pointer */ - - /*!< Enhanced Ethernet DMA PTP Descriptors */ - uint32_t ExtendedStatus; /*!< Extended status for PTP receive descriptor */ - - uint32_t Reserved1; /*!< Reserved */ - - uint32_t TimeStampLow; /*!< Time Stamp Low value for transmit and receive */ - - uint32_t TimeStampHigh; /*!< Time Stamp High value for transmit and receive */ - -} ETH_DMADescTypeDef; - - -/** - * @brief Received Frame Informations structure definition - */ -typedef struct -{ - ETH_DMADescTypeDef *FSRxDesc; /*!< First Segment Rx Desc */ - - ETH_DMADescTypeDef *LSRxDesc; /*!< Last Segment Rx Desc */ - - uint32_t SegCount; /*!< Segment count */ - - uint32_t length; /*!< Frame length */ - - uint32_t buffer; /*!< Frame buffer */ - -} ETH_DMARxFrameInfos; - - -/** - * @brief ETH Handle Structure definition - */ - -typedef struct -{ - ETH_TypeDef *Instance; /*!< Register base address */ - - ETH_InitTypeDef Init; /*!< Ethernet Init Configuration */ - - uint32_t LinkStatus; /*!< Ethernet link status */ - - ETH_DMADescTypeDef *RxDesc; /*!< Rx descriptor to Get */ - - ETH_DMADescTypeDef *TxDesc; /*!< Tx descriptor to Set */ - - ETH_DMARxFrameInfos RxFrameInfos; /*!< last Rx frame infos */ - - __IO HAL_ETH_StateTypeDef State; /*!< ETH communication state */ - - HAL_LockTypeDef Lock; /*!< ETH Lock */ - -} ETH_HandleTypeDef; - - /** - * @} - */ - -/* Exported constants --------------------------------------------------------*/ -/** @defgroup ETH_Exported_Constants ETH Exported Constants - * @{ - */ - -/** @defgroup ETH_Buffers_setting ETH Buffers setting - * @{ - */ -#define ETH_MAX_PACKET_SIZE ((uint32_t)1524U) /*!< ETH_HEADER + ETH_EXTRA + ETH_VLAN_TAG + ETH_MAX_ETH_PAYLOAD + ETH_CRC */ -#define ETH_HEADER ((uint32_t)14U) /*!< 6 byte Dest addr, 6 byte Src addr, 2 byte length/type */ -#define ETH_CRC ((uint32_t)4U) /*!< Ethernet CRC */ -#define ETH_EXTRA ((uint32_t)2U) /*!< Extra bytes in some cases */ -#define ETH_VLAN_TAG ((uint32_t)4U) /*!< optional 802.1q VLAN Tag */ -#define ETH_MIN_ETH_PAYLOAD ((uint32_t)46U) /*!< Minimum Ethernet payload size */ -#define ETH_MAX_ETH_PAYLOAD ((uint32_t)1500U) /*!< Maximum Ethernet payload size */ -#define ETH_JUMBO_FRAME_PAYLOAD ((uint32_t)9000U) /*!< Jumbo frame payload size */ - - /* Ethernet driver receive buffers are organized in a chained linked-list, when - an Ethernet packet is received, the Rx-DMA will transfer the packet from RxFIFO - to the driver receive buffers memory. - - Depending on the size of the received Ethernet packet and the size of - each Ethernet driver receive buffer, the received packet can take one or more - Ethernet driver receive buffer. - - In below are defined the size of one Ethernet driver receive buffer ETH_RX_BUF_SIZE - and the total count of the driver receive buffers ETH_RXBUFNB. - - The configured value for ETH_RX_BUF_SIZE and ETH_RXBUFNB are only provided as - example, they can be reconfigured in the application layer to fit the application - needs */ - -/* Here we configure each Ethernet driver receive buffer to fit the Max size Ethernet - packet */ -#ifndef ETH_RX_BUF_SIZE - #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE -#endif - -/* 5 Ethernet driver receive buffers are used (in a chained linked list)*/ -#ifndef ETH_RXBUFNB - #define ETH_RXBUFNB ((uint32_t)5U) /* 5 Rx buffers of size ETH_RX_BUF_SIZE */ -#endif - - - /* Ethernet driver transmit buffers are organized in a chained linked-list, when - an Ethernet packet is transmitted, Tx-DMA will transfer the packet from the - driver transmit buffers memory to the TxFIFO. - - Depending on the size of the Ethernet packet to be transmitted and the size of - each Ethernet driver transmit buffer, the packet to be transmitted can take - one or more Ethernet driver transmit buffer. - - In below are defined the size of one Ethernet driver transmit buffer ETH_TX_BUF_SIZE - and the total count of the driver transmit buffers ETH_TXBUFNB. - - The configured value for ETH_TX_BUF_SIZE and ETH_TXBUFNB are only provided as - example, they can be reconfigured in the application layer to fit the application - needs */ - -/* Here we configure each Ethernet driver transmit buffer to fit the Max size Ethernet - packet */ -#ifndef ETH_TX_BUF_SIZE - #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE -#endif - -/* 5 Ethernet driver transmit buffers are used (in a chained linked list)*/ -#ifndef ETH_TXBUFNB - #define ETH_TXBUFNB ((uint32_t)5U) /* 5 Tx buffers of size ETH_TX_BUF_SIZE */ -#endif - - /** - * @} - */ - -/** @defgroup ETH_DMA_TX_Descriptor ETH DMA TX Descriptor - * @{ - */ - -/* - DMA Tx Descriptor - ----------------------------------------------------------------------------------------------- - TDES0 | OWN(31) | CTRL[30:26] | Reserved[25:24] | CTRL[23:20] | Reserved[19:17] | Status[16:0] | - ----------------------------------------------------------------------------------------------- - TDES1 | Reserved[31:29] | Buffer2 ByteCount[28:16] | Reserved[15:13] | Buffer1 ByteCount[12:0] | - ----------------------------------------------------------------------------------------------- - TDES2 | Buffer1 Address [31:0] | - ----------------------------------------------------------------------------------------------- - TDES3 | Buffer2 Address [31:0] / Next Descriptor Address [31:0] | - ----------------------------------------------------------------------------------------------- -*/ - -/** - * @brief Bit definition of TDES0 register: DMA Tx descriptor status register - */ -#define ETH_DMATXDESC_OWN ((uint32_t)0x80000000U) /*!< OWN bit: descriptor is owned by DMA engine */ -#define ETH_DMATXDESC_IC ((uint32_t)0x40000000U) /*!< Interrupt on Completion */ -#define ETH_DMATXDESC_LS ((uint32_t)0x20000000U) /*!< Last Segment */ -#define ETH_DMATXDESC_FS ((uint32_t)0x10000000U) /*!< First Segment */ -#define ETH_DMATXDESC_DC ((uint32_t)0x08000000U) /*!< Disable CRC */ -#define ETH_DMATXDESC_DP ((uint32_t)0x04000000U) /*!< Disable Padding */ -#define ETH_DMATXDESC_TTSE ((uint32_t)0x02000000U) /*!< Transmit Time Stamp Enable */ -#define ETH_DMATXDESC_CIC ((uint32_t)0x00C00000U) /*!< Checksum Insertion Control: 4 cases */ -#define ETH_DMATXDESC_CIC_BYPASS ((uint32_t)0x00000000U) /*!< Do Nothing: Checksum Engine is bypassed */ -#define ETH_DMATXDESC_CIC_IPV4HEADER ((uint32_t)0x00400000U) /*!< IPV4 header Checksum Insertion */ -#define ETH_DMATXDESC_CIC_TCPUDPICMP_SEGMENT ((uint32_t)0x00800000U) /*!< TCP/UDP/ICMP Checksum Insertion calculated over segment only */ -#define ETH_DMATXDESC_CIC_TCPUDPICMP_FULL ((uint32_t)0x00C00000U) /*!< TCP/UDP/ICMP Checksum Insertion fully calculated */ -#define ETH_DMATXDESC_TER ((uint32_t)0x00200000U) /*!< Transmit End of Ring */ -#define ETH_DMATXDESC_TCH ((uint32_t)0x00100000U) /*!< Second Address Chained */ -#define ETH_DMATXDESC_TTSS ((uint32_t)0x00020000U) /*!< Tx Time Stamp Status */ -#define ETH_DMATXDESC_IHE ((uint32_t)0x00010000U) /*!< IP Header Error */ -#define ETH_DMATXDESC_ES ((uint32_t)0x00008000U) /*!< Error summary: OR of the following bits: UE || ED || EC || LCO || NC || LCA || FF || JT */ -#define ETH_DMATXDESC_JT ((uint32_t)0x00004000U) /*!< Jabber Timeout */ -#define ETH_DMATXDESC_FF ((uint32_t)0x00002000U) /*!< Frame Flushed: DMA/MTL flushed the frame due to SW flush */ -#define ETH_DMATXDESC_PCE ((uint32_t)0x00001000U) /*!< Payload Checksum Error */ -#define ETH_DMATXDESC_LCA ((uint32_t)0x00000800U) /*!< Loss of Carrier: carrier lost during transmission */ -#define ETH_DMATXDESC_NC ((uint32_t)0x00000400U) /*!< No Carrier: no carrier signal from the transceiver */ -#define ETH_DMATXDESC_LCO ((uint32_t)0x00000200U) /*!< Late Collision: transmission aborted due to collision */ -#define ETH_DMATXDESC_EC ((uint32_t)0x00000100U) /*!< Excessive Collision: transmission aborted after 16 collisions */ -#define ETH_DMATXDESC_VF ((uint32_t)0x00000080U) /*!< VLAN Frame */ -#define ETH_DMATXDESC_CC ((uint32_t)0x00000078U) /*!< Collision Count */ -#define ETH_DMATXDESC_ED ((uint32_t)0x00000004U) /*!< Excessive Deferral */ -#define ETH_DMATXDESC_UF ((uint32_t)0x00000002U) /*!< Underflow Error: late data arrival from the memory */ -#define ETH_DMATXDESC_DB ((uint32_t)0x00000001U) /*!< Deferred Bit */ - -/** - * @brief Bit definition of TDES1 register - */ -#define ETH_DMATXDESC_TBS2 ((uint32_t)0x1FFF0000U) /*!< Transmit Buffer2 Size */ -#define ETH_DMATXDESC_TBS1 ((uint32_t)0x00001FFFU) /*!< Transmit Buffer1 Size */ - -/** - * @brief Bit definition of TDES2 register - */ -#define ETH_DMATXDESC_B1AP ((uint32_t)0xFFFFFFFFU) /*!< Buffer1 Address Pointer */ - -/** - * @brief Bit definition of TDES3 register - */ -#define ETH_DMATXDESC_B2AP ((uint32_t)0xFFFFFFFFU) /*!< Buffer2 Address Pointer */ - - /*--------------------------------------------------------------------------------------------- - TDES6 | Transmit Time Stamp Low [31:0] | - ----------------------------------------------------------------------------------------------- - TDES7 | Transmit Time Stamp High [31:0] | - ----------------------------------------------------------------------------------------------*/ - -/* Bit definition of TDES6 register */ - #define ETH_DMAPTPTXDESC_TTSL ((uint32_t)0xFFFFFFFFU) /* Transmit Time Stamp Low */ - -/* Bit definition of TDES7 register */ - #define ETH_DMAPTPTXDESC_TTSH ((uint32_t)0xFFFFFFFFU) /* Transmit Time Stamp High */ - -/** - * @} - */ -/** @defgroup ETH_DMA_RX_Descriptor ETH DMA RX Descriptor - * @{ - */ - -/* - DMA Rx Descriptor - -------------------------------------------------------------------------------------------------------------------- - RDES0 | OWN(31) | Status [30:0] | - --------------------------------------------------------------------------------------------------------------------- - RDES1 | CTRL(31) | Reserved[30:29] | Buffer2 ByteCount[28:16] | CTRL[15:14] | Reserved(13) | Buffer1 ByteCount[12:0] | - --------------------------------------------------------------------------------------------------------------------- - RDES2 | Buffer1 Address [31:0] | - --------------------------------------------------------------------------------------------------------------------- - RDES3 | Buffer2 Address [31:0] / Next Descriptor Address [31:0] | - --------------------------------------------------------------------------------------------------------------------- -*/ - -/** - * @brief Bit definition of RDES0 register: DMA Rx descriptor status register - */ -#define ETH_DMARXDESC_OWN ((uint32_t)0x80000000U) /*!< OWN bit: descriptor is owned by DMA engine */ -#define ETH_DMARXDESC_AFM ((uint32_t)0x40000000U) /*!< DA Filter Fail for the rx frame */ -#define ETH_DMARXDESC_FL ((uint32_t)0x3FFF0000U) /*!< Receive descriptor frame length */ -#define ETH_DMARXDESC_ES ((uint32_t)0x00008000U) /*!< Error summary: OR of the following bits: DE || OE || IPC || LC || RWT || RE || CE */ -#define ETH_DMARXDESC_DE ((uint32_t)0x00004000U) /*!< Descriptor error: no more descriptors for receive frame */ -#define ETH_DMARXDESC_SAF ((uint32_t)0x00002000U) /*!< SA Filter Fail for the received frame */ -#define ETH_DMARXDESC_LE ((uint32_t)0x00001000U) /*!< Frame size not matching with length field */ -#define ETH_DMARXDESC_OE ((uint32_t)0x00000800U) /*!< Overflow Error: Frame was damaged due to buffer overflow */ -#define ETH_DMARXDESC_VLAN ((uint32_t)0x00000400U) /*!< VLAN Tag: received frame is a VLAN frame */ -#define ETH_DMARXDESC_FS ((uint32_t)0x00000200U) /*!< First descriptor of the frame */ -#define ETH_DMARXDESC_LS ((uint32_t)0x00000100U) /*!< Last descriptor of the frame */ -#define ETH_DMARXDESC_IPV4HCE ((uint32_t)0x00000080U) /*!< IPC Checksum Error: Rx Ipv4 header checksum error */ -#define ETH_DMARXDESC_LC ((uint32_t)0x00000040U) /*!< Late collision occurred during reception */ -#define ETH_DMARXDESC_FT ((uint32_t)0x00000020U) /*!< Frame type - Ethernet, otherwise 802.3 */ -#define ETH_DMARXDESC_RWT ((uint32_t)0x00000010U) /*!< Receive Watchdog Timeout: watchdog timer expired during reception */ -#define ETH_DMARXDESC_RE ((uint32_t)0x00000008U) /*!< Receive error: error reported by MII interface */ -#define ETH_DMARXDESC_DBE ((uint32_t)0x00000004U) /*!< Dribble bit error: frame contains non int multiple of 8 bits */ -#define ETH_DMARXDESC_CE ((uint32_t)0x00000002U) /*!< CRC error */ -#define ETH_DMARXDESC_MAMPCE ((uint32_t)0x00000001U) /*!< Rx MAC Address/Payload Checksum Error: Rx MAC address matched/ Rx Payload Checksum Error */ - -/** - * @brief Bit definition of RDES1 register - */ -#define ETH_DMARXDESC_DIC ((uint32_t)0x80000000U) /*!< Disable Interrupt on Completion */ -#define ETH_DMARXDESC_RBS2 ((uint32_t)0x1FFF0000U) /*!< Receive Buffer2 Size */ -#define ETH_DMARXDESC_RER ((uint32_t)0x00008000U) /*!< Receive End of Ring */ -#define ETH_DMARXDESC_RCH ((uint32_t)0x00004000U) /*!< Second Address Chained */ -#define ETH_DMARXDESC_RBS1 ((uint32_t)0x00001FFFU) /*!< Receive Buffer1 Size */ - -/** - * @brief Bit definition of RDES2 register - */ -#define ETH_DMARXDESC_B1AP ((uint32_t)0xFFFFFFFFU) /*!< Buffer1 Address Pointer */ - -/** - * @brief Bit definition of RDES3 register - */ -#define ETH_DMARXDESC_B2AP ((uint32_t)0xFFFFFFFFU) /*!< Buffer2 Address Pointer */ - -/*--------------------------------------------------------------------------------------------------------------------- - RDES4 | Reserved[31:15] | Extended Status [14:0] | - --------------------------------------------------------------------------------------------------------------------- - RDES5 | Reserved[31:0] | - --------------------------------------------------------------------------------------------------------------------- - RDES6 | Receive Time Stamp Low [31:0] | - --------------------------------------------------------------------------------------------------------------------- - RDES7 | Receive Time Stamp High [31:0] | - --------------------------------------------------------------------------------------------------------------------*/ - -/* Bit definition of RDES4 register */ -#define ETH_DMAPTPRXDESC_PTPV ((uint32_t)0x00002000U) /* PTP Version */ -#define ETH_DMAPTPRXDESC_PTPFT ((uint32_t)0x00001000U) /* PTP Frame Type */ -#define ETH_DMAPTPRXDESC_PTPMT ((uint32_t)0x00000F00U) /* PTP Message Type */ -#define ETH_DMAPTPRXDESC_PTPMT_SYNC ((uint32_t)0x00000100U) /* SYNC message (all clock types) */ -#define ETH_DMAPTPRXDESC_PTPMT_FOLLOWUP ((uint32_t)0x00000200U) /* FollowUp message (all clock types) */ -#define ETH_DMAPTPRXDESC_PTPMT_DELAYREQ ((uint32_t)0x00000300U) /* DelayReq message (all clock types) */ -#define ETH_DMAPTPRXDESC_PTPMT_DELAYRESP ((uint32_t)0x00000400U) /* DelayResp message (all clock types) */ -#define ETH_DMAPTPRXDESC_PTPMT_PDELAYREQ_ANNOUNCE ((uint32_t)0x00000500U) /* PdelayReq message (peer-to-peer transparent clock) or Announce message (Ordinary or Boundary clock) */ -#define ETH_DMAPTPRXDESC_PTPMT_PDELAYRESP_MANAG ((uint32_t)0x00000600U) /* PdelayResp message (peer-to-peer transparent clock) or Management message (Ordinary or Boundary clock) */ -#define ETH_DMAPTPRXDESC_PTPMT_PDELAYRESPFOLLOWUP_SIGNAL ((uint32_t)0x00000700U) /* PdelayRespFollowUp message (peer-to-peer transparent clock) or Signaling message (Ordinary or Boundary clock) */ -#define ETH_DMAPTPRXDESC_IPV6PR ((uint32_t)0x00000080U) /* IPv6 Packet Received */ -#define ETH_DMAPTPRXDESC_IPV4PR ((uint32_t)0x00000040U) /* IPv4 Packet Received */ -#define ETH_DMAPTPRXDESC_IPCB ((uint32_t)0x00000020U) /* IP Checksum Bypassed */ -#define ETH_DMAPTPRXDESC_IPPE ((uint32_t)0x00000010U) /* IP Payload Error */ -#define ETH_DMAPTPRXDESC_IPHE ((uint32_t)0x00000008U) /* IP Header Error */ -#define ETH_DMAPTPRXDESC_IPPT ((uint32_t)0x00000007U) /* IP Payload Type */ -#define ETH_DMAPTPRXDESC_IPPT_UDP ((uint32_t)0x00000001U) /* UDP payload encapsulated in the IP datagram */ -#define ETH_DMAPTPRXDESC_IPPT_TCP ((uint32_t)0x00000002U) /* TCP payload encapsulated in the IP datagram */ -#define ETH_DMAPTPRXDESC_IPPT_ICMP ((uint32_t)0x00000003U) /* ICMP payload encapsulated in the IP datagram */ - -/* Bit definition of RDES6 register */ -#define ETH_DMAPTPRXDESC_RTSL ((uint32_t)0xFFFFFFFFU) /* Receive Time Stamp Low */ - -/* Bit definition of RDES7 register */ -#define ETH_DMAPTPRXDESC_RTSH ((uint32_t)0xFFFFFFFFU) /* Receive Time Stamp High */ -/** - * @} - */ - /** @defgroup ETH_AutoNegotiation ETH AutoNegotiation - * @{ - */ -#define ETH_AUTONEGOTIATION_ENABLE ((uint32_t)0x00000001U) -#define ETH_AUTONEGOTIATION_DISABLE ((uint32_t)0x00000000U) - -/** - * @} - */ -/** @defgroup ETH_Speed ETH Speed - * @{ - */ -#define ETH_SPEED_10M ((uint32_t)0x00000000U) -#define ETH_SPEED_100M ((uint32_t)0x00004000U) - -/** - * @} - */ -/** @defgroup ETH_Duplex_Mode ETH Duplex Mode - * @{ - */ -#define ETH_MODE_FULLDUPLEX ((uint32_t)0x00000800U) -#define ETH_MODE_HALFDUPLEX ((uint32_t)0x00000000U) -/** - * @} - */ -/** @defgroup ETH_Rx_Mode ETH Rx Mode - * @{ - */ -#define ETH_RXPOLLING_MODE ((uint32_t)0x00000000U) -#define ETH_RXINTERRUPT_MODE ((uint32_t)0x00000001U) -/** - * @} - */ - -/** @defgroup ETH_Checksum_Mode ETH Checksum Mode - * @{ - */ -#define ETH_CHECKSUM_BY_HARDWARE ((uint32_t)0x00000000U) -#define ETH_CHECKSUM_BY_SOFTWARE ((uint32_t)0x00000001U) -/** - * @} - */ - -/** @defgroup ETH_Media_Interface ETH Media Interface - * @{ - */ -#define ETH_MEDIA_INTERFACE_MII ((uint32_t)0x00000000U) -#define ETH_MEDIA_INTERFACE_RMII ((uint32_t)SYSCFG_PMC_MII_RMII_SEL) -/** - * @} - */ - -/** @defgroup ETH_Watchdog ETH Watchdog - * @{ - */ -#define ETH_WATCHDOG_ENABLE ((uint32_t)0x00000000U) -#define ETH_WATCHDOG_DISABLE ((uint32_t)0x00800000U) -/** - * @} - */ - -/** @defgroup ETH_Jabber ETH Jabber - * @{ - */ -#define ETH_JABBER_ENABLE ((uint32_t)0x00000000U) -#define ETH_JABBER_DISABLE ((uint32_t)0x00400000U) -/** - * @} - */ - -/** @defgroup ETH_Inter_Frame_Gap ETH Inter Frame Gap - * @{ - */ -#define ETH_INTERFRAMEGAP_96BIT ((uint32_t)0x00000000U) /*!< minimum IFG between frames during transmission is 96Bit */ -#define ETH_INTERFRAMEGAP_88BIT ((uint32_t)0x00020000U) /*!< minimum IFG between frames during transmission is 88Bit */ -#define ETH_INTERFRAMEGAP_80BIT ((uint32_t)0x00040000U) /*!< minimum IFG between frames during transmission is 80Bit */ -#define ETH_INTERFRAMEGAP_72BIT ((uint32_t)0x00060000U) /*!< minimum IFG between frames during transmission is 72Bit */ -#define ETH_INTERFRAMEGAP_64BIT ((uint32_t)0x00080000U) /*!< minimum IFG between frames during transmission is 64Bit */ -#define ETH_INTERFRAMEGAP_56BIT ((uint32_t)0x000A0000U) /*!< minimum IFG between frames during transmission is 56Bit */ -#define ETH_INTERFRAMEGAP_48BIT ((uint32_t)0x000C0000U) /*!< minimum IFG between frames during transmission is 48Bit */ -#define ETH_INTERFRAMEGAP_40BIT ((uint32_t)0x000E0000U) /*!< minimum IFG between frames during transmission is 40Bit */ -/** - * @} - */ - -/** @defgroup ETH_Carrier_Sense ETH Carrier Sense - * @{ - */ -#define ETH_CARRIERSENCE_ENABLE ((uint32_t)0x00000000U) -#define ETH_CARRIERSENCE_DISABLE ((uint32_t)0x00010000U) -/** - * @} - */ - -/** @defgroup ETH_Receive_Own ETH Receive Own - * @{ - */ -#define ETH_RECEIVEOWN_ENABLE ((uint32_t)0x00000000U) -#define ETH_RECEIVEOWN_DISABLE ((uint32_t)0x00002000U) -/** - * @} - */ - -/** @defgroup ETH_Loop_Back_Mode ETH Loop Back Mode - * @{ - */ -#define ETH_LOOPBACKMODE_ENABLE ((uint32_t)0x00001000U) -#define ETH_LOOPBACKMODE_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Checksum_Offload ETH Checksum Offload - * @{ - */ -#define ETH_CHECKSUMOFFLAOD_ENABLE ((uint32_t)0x00000400U) -#define ETH_CHECKSUMOFFLAOD_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Retry_Transmission ETH Retry Transmission - * @{ - */ -#define ETH_RETRYTRANSMISSION_ENABLE ((uint32_t)0x00000000U) -#define ETH_RETRYTRANSMISSION_DISABLE ((uint32_t)0x00000200U) -/** - * @} - */ - -/** @defgroup ETH_Automatic_Pad_CRC_Strip ETH Automatic Pad CRC Strip - * @{ - */ -#define ETH_AUTOMATICPADCRCSTRIP_ENABLE ((uint32_t)0x00000080U) -#define ETH_AUTOMATICPADCRCSTRIP_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Back_Off_Limit ETH Back Off Limit - * @{ - */ -#define ETH_BACKOFFLIMIT_10 ((uint32_t)0x00000000U) -#define ETH_BACKOFFLIMIT_8 ((uint32_t)0x00000020U) -#define ETH_BACKOFFLIMIT_4 ((uint32_t)0x00000040U) -#define ETH_BACKOFFLIMIT_1 ((uint32_t)0x00000060U) -/** - * @} - */ - -/** @defgroup ETH_Deferral_Check ETH Deferral Check - * @{ - */ -#define ETH_DEFFERRALCHECK_ENABLE ((uint32_t)0x00000010U) -#define ETH_DEFFERRALCHECK_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Receive_All ETH Receive All - * @{ - */ -#define ETH_RECEIVEALL_ENABLE ((uint32_t)0x80000000U) -#define ETH_RECEIVEAll_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Source_Addr_Filter ETH Source Addr Filter - * @{ - */ -#define ETH_SOURCEADDRFILTER_NORMAL_ENABLE ((uint32_t)0x00000200U) -#define ETH_SOURCEADDRFILTER_INVERSE_ENABLE ((uint32_t)0x00000300U) -#define ETH_SOURCEADDRFILTER_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Pass_Control_Frames ETH Pass Control Frames - * @{ - */ -#define ETH_PASSCONTROLFRAMES_BLOCKALL ((uint32_t)0x00000040U) /*!< MAC filters all control frames from reaching the application */ -#define ETH_PASSCONTROLFRAMES_FORWARDALL ((uint32_t)0x00000080U) /*!< MAC forwards all control frames to application even if they fail the Address Filter */ -#define ETH_PASSCONTROLFRAMES_FORWARDPASSEDADDRFILTER ((uint32_t)0x000000C0U) /*!< MAC forwards control frames that pass the Address Filter. */ -/** - * @} - */ - -/** @defgroup ETH_Broadcast_Frames_Reception ETH Broadcast Frames Reception - * @{ - */ -#define ETH_BROADCASTFRAMESRECEPTION_ENABLE ((uint32_t)0x00000000U) -#define ETH_BROADCASTFRAMESRECEPTION_DISABLE ((uint32_t)0x00000020U) -/** - * @} - */ - -/** @defgroup ETH_Destination_Addr_Filter ETH Destination Addr Filter - * @{ - */ -#define ETH_DESTINATIONADDRFILTER_NORMAL ((uint32_t)0x00000000U) -#define ETH_DESTINATIONADDRFILTER_INVERSE ((uint32_t)0x00000008U) -/** - * @} - */ - -/** @defgroup ETH_Promiscuous_Mode ETH Promiscuous Mode - * @{ - */ -#define ETH_PROMISCUOUS_MODE_ENABLE ((uint32_t)0x00000001U) -#define ETH_PROMISCUOUS_MODE_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Multicast_Frames_Filter ETH Multicast Frames Filter - * @{ - */ -#define ETH_MULTICASTFRAMESFILTER_PERFECTHASHTABLE ((uint32_t)0x00000404U) -#define ETH_MULTICASTFRAMESFILTER_HASHTABLE ((uint32_t)0x00000004U) -#define ETH_MULTICASTFRAMESFILTER_PERFECT ((uint32_t)0x00000000U) -#define ETH_MULTICASTFRAMESFILTER_NONE ((uint32_t)0x00000010U) -/** - * @} - */ - -/** @defgroup ETH_Unicast_Frames_Filter ETH Unicast Frames Filter - * @{ - */ -#define ETH_UNICASTFRAMESFILTER_PERFECTHASHTABLE ((uint32_t)0x00000402U) -#define ETH_UNICASTFRAMESFILTER_HASHTABLE ((uint32_t)0x00000002U) -#define ETH_UNICASTFRAMESFILTER_PERFECT ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Zero_Quanta_Pause ETH Zero Quanta Pause - * @{ - */ -#define ETH_ZEROQUANTAPAUSE_ENABLE ((uint32_t)0x00000000U) -#define ETH_ZEROQUANTAPAUSE_DISABLE ((uint32_t)0x00000080U) -/** - * @} - */ - -/** @defgroup ETH_Pause_Low_Threshold ETH Pause Low Threshold - * @{ - */ -#define ETH_PAUSELOWTHRESHOLD_MINUS4 ((uint32_t)0x00000000U) /*!< Pause time minus 4 slot times */ -#define ETH_PAUSELOWTHRESHOLD_MINUS28 ((uint32_t)0x00000010U) /*!< Pause time minus 28 slot times */ -#define ETH_PAUSELOWTHRESHOLD_MINUS144 ((uint32_t)0x00000020U) /*!< Pause time minus 144 slot times */ -#define ETH_PAUSELOWTHRESHOLD_MINUS256 ((uint32_t)0x00000030U) /*!< Pause time minus 256 slot times */ -/** - * @} - */ - -/** @defgroup ETH_Unicast_Pause_Frame_Detect ETH Unicast Pause Frame Detect - * @{ - */ -#define ETH_UNICASTPAUSEFRAMEDETECT_ENABLE ((uint32_t)0x00000008U) -#define ETH_UNICASTPAUSEFRAMEDETECT_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Receive_Flow_Control ETH Receive Flow Control - * @{ - */ -#define ETH_RECEIVEFLOWCONTROL_ENABLE ((uint32_t)0x00000004U) -#define ETH_RECEIVEFLOWCONTROL_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Transmit_Flow_Control ETH Transmit Flow Control - * @{ - */ -#define ETH_TRANSMITFLOWCONTROL_ENABLE ((uint32_t)0x00000002U) -#define ETH_TRANSMITFLOWCONTROL_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_VLAN_Tag_Comparison ETH VLAN Tag Comparison - * @{ - */ -#define ETH_VLANTAGCOMPARISON_12BIT ((uint32_t)0x00010000U) -#define ETH_VLANTAGCOMPARISON_16BIT ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_MAC_addresses ETH MAC addresses - * @{ - */ -#define ETH_MAC_ADDRESS0 ((uint32_t)0x00000000U) -#define ETH_MAC_ADDRESS1 ((uint32_t)0x00000008U) -#define ETH_MAC_ADDRESS2 ((uint32_t)0x00000010U) -#define ETH_MAC_ADDRESS3 ((uint32_t)0x00000018U) -/** - * @} - */ - -/** @defgroup ETH_MAC_addresses_filter_SA_DA ETH MAC addresses filter SA DA - * @{ - */ -#define ETH_MAC_ADDRESSFILTER_SA ((uint32_t)0x00000000U) -#define ETH_MAC_ADDRESSFILTER_DA ((uint32_t)0x00000008U) -/** - * @} - */ - -/** @defgroup ETH_MAC_addresses_filter_Mask_bytes ETH MAC addresses filter Mask bytes - * @{ - */ -#define ETH_MAC_ADDRESSMASK_BYTE6 ((uint32_t)0x20000000U) /*!< Mask MAC Address high reg bits [15:8] */ -#define ETH_MAC_ADDRESSMASK_BYTE5 ((uint32_t)0x10000000U) /*!< Mask MAC Address high reg bits [7:0] */ -#define ETH_MAC_ADDRESSMASK_BYTE4 ((uint32_t)0x08000000U) /*!< Mask MAC Address low reg bits [31:24] */ -#define ETH_MAC_ADDRESSMASK_BYTE3 ((uint32_t)0x04000000U) /*!< Mask MAC Address low reg bits [23:16] */ -#define ETH_MAC_ADDRESSMASK_BYTE2 ((uint32_t)0x02000000U) /*!< Mask MAC Address low reg bits [15:8] */ -#define ETH_MAC_ADDRESSMASK_BYTE1 ((uint32_t)0x01000000U) /*!< Mask MAC Address low reg bits [70] */ -/** - * @} - */ - -/** @defgroup ETH_MAC_Debug_flags ETH MAC Debug flags - * @{ - */ -#define ETH_MAC_TXFIFO_FULL ((uint32_t)0x02000000) /* Tx FIFO full */ -#define ETH_MAC_TXFIFONOT_EMPTY ((uint32_t)0x01000000) /* Tx FIFO not empty */ -#define ETH_MAC_TXFIFO_WRITE_ACTIVE ((uint32_t)0x00400000) /* Tx FIFO write active */ -#define ETH_MAC_TXFIFO_IDLE ((uint32_t)0x00000000) /* Tx FIFO read status: Idle */ -#define ETH_MAC_TXFIFO_READ ((uint32_t)0x00100000) /* Tx FIFO read status: Read (transferring data to the MAC transmitter) */ -#define ETH_MAC_TXFIFO_WAITING ((uint32_t)0x00200000) /* Tx FIFO read status: Waiting for TxStatus from MAC transmitter */ -#define ETH_MAC_TXFIFO_WRITING ((uint32_t)0x00300000) /* Tx FIFO read status: Writing the received TxStatus or flushing the TxFIFO */ -#define ETH_MAC_TRANSMISSION_PAUSE ((uint32_t)0x00080000) /* MAC transmitter in pause */ -#define ETH_MAC_TRANSMITFRAMECONTROLLER_IDLE ((uint32_t)0x00000000) /* MAC transmit frame controller: Idle */ -#define ETH_MAC_TRANSMITFRAMECONTROLLER_WAITING ((uint32_t)0x00020000) /* MAC transmit frame controller: Waiting for Status of previous frame or IFG/backoff period to be over */ -#define ETH_MAC_TRANSMITFRAMECONTROLLER_GENRATING_PCF ((uint32_t)0x00040000) /* MAC transmit frame controller: Generating and transmitting a Pause control frame (in full duplex mode) */ -#define ETH_MAC_TRANSMITFRAMECONTROLLER_TRANSFERRING ((uint32_t)0x00060000) /* MAC transmit frame controller: Transferring input frame for transmission */ -#define ETH_MAC_MII_TRANSMIT_ACTIVE ((uint32_t)0x00010000) /* MAC MII transmit engine active */ -#define ETH_MAC_RXFIFO_EMPTY ((uint32_t)0x00000000) /* Rx FIFO fill level: empty */ -#define ETH_MAC_RXFIFO_BELOW_THRESHOLD ((uint32_t)0x00000100) /* Rx FIFO fill level: fill-level below flow-control de-activate threshold */ -#define ETH_MAC_RXFIFO_ABOVE_THRESHOLD ((uint32_t)0x00000200) /* Rx FIFO fill level: fill-level above flow-control activate threshold */ -#define ETH_MAC_RXFIFO_FULL ((uint32_t)0x00000300) /* Rx FIFO fill level: full */ -#define ETH_MAC_READCONTROLLER_IDLE ((uint32_t)0x00000060) /* Rx FIFO read controller IDLE state */ -#define ETH_MAC_READCONTROLLER_READING_DATA ((uint32_t)0x00000060) /* Rx FIFO read controller Reading frame data */ -#define ETH_MAC_READCONTROLLER_READING_STATUS ((uint32_t)0x00000060) /* Rx FIFO read controller Reading frame status (or time-stamp) */ -#define ETH_MAC_READCONTROLLER_ FLUSHING ((uint32_t)0x00000060) /* Rx FIFO read controller Flushing the frame data and status */ -#define ETH_MAC_RXFIFO_WRITE_ACTIVE ((uint32_t)0x00000010) /* Rx FIFO write controller active */ -#define ETH_MAC_SMALL_FIFO_NOTACTIVE ((uint32_t)0x00000000) /* MAC small FIFO read / write controllers not active */ -#define ETH_MAC_SMALL_FIFO_READ_ACTIVE ((uint32_t)0x00000002) /* MAC small FIFO read controller active */ -#define ETH_MAC_SMALL_FIFO_WRITE_ACTIVE ((uint32_t)0x00000004) /* MAC small FIFO write controller active */ -#define ETH_MAC_SMALL_FIFO_RW_ACTIVE ((uint32_t)0x00000006) /* MAC small FIFO read / write controllers active */ -#define ETH_MAC_MII_RECEIVE_PROTOCOL_ACTIVE ((uint32_t)0x00000001) /* MAC MII receive protocol engine active */ -/** - * @} - */ - -/** @defgroup ETH_Drop_TCP_IP_Checksum_Error_Frame ETH Drop TCP IP Checksum Error Frame - * @{ - */ -#define ETH_DROPTCPIPCHECKSUMERRORFRAME_ENABLE ((uint32_t)0x00000000U) -#define ETH_DROPTCPIPCHECKSUMERRORFRAME_DISABLE ((uint32_t)0x04000000U) -/** - * @} - */ - -/** @defgroup ETH_Receive_Store_Forward ETH Receive Store Forward - * @{ - */ -#define ETH_RECEIVESTOREFORWARD_ENABLE ((uint32_t)0x02000000U) -#define ETH_RECEIVESTOREFORWARD_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Flush_Received_Frame ETH Flush Received Frame - * @{ - */ -#define ETH_FLUSHRECEIVEDFRAME_ENABLE ((uint32_t)0x00000000U) -#define ETH_FLUSHRECEIVEDFRAME_DISABLE ((uint32_t)0x01000000U) -/** - * @} - */ - -/** @defgroup ETH_Transmit_Store_Forward ETH Transmit Store Forward - * @{ - */ -#define ETH_TRANSMITSTOREFORWARD_ENABLE ((uint32_t)0x00200000U) -#define ETH_TRANSMITSTOREFORWARD_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Transmit_Threshold_Control ETH Transmit Threshold Control - * @{ - */ -#define ETH_TRANSMITTHRESHOLDCONTROL_64BYTES ((uint32_t)0x00000000U) /*!< threshold level of the MTL Transmit FIFO is 64 Bytes */ -#define ETH_TRANSMITTHRESHOLDCONTROL_128BYTES ((uint32_t)0x00004000U) /*!< threshold level of the MTL Transmit FIFO is 128 Bytes */ -#define ETH_TRANSMITTHRESHOLDCONTROL_192BYTES ((uint32_t)0x00008000U) /*!< threshold level of the MTL Transmit FIFO is 192 Bytes */ -#define ETH_TRANSMITTHRESHOLDCONTROL_256BYTES ((uint32_t)0x0000C000U) /*!< threshold level of the MTL Transmit FIFO is 256 Bytes */ -#define ETH_TRANSMITTHRESHOLDCONTROL_40BYTES ((uint32_t)0x00010000U) /*!< threshold level of the MTL Transmit FIFO is 40 Bytes */ -#define ETH_TRANSMITTHRESHOLDCONTROL_32BYTES ((uint32_t)0x00014000U) /*!< threshold level of the MTL Transmit FIFO is 32 Bytes */ -#define ETH_TRANSMITTHRESHOLDCONTROL_24BYTES ((uint32_t)0x00018000U) /*!< threshold level of the MTL Transmit FIFO is 24 Bytes */ -#define ETH_TRANSMITTHRESHOLDCONTROL_16BYTES ((uint32_t)0x0001C000U) /*!< threshold level of the MTL Transmit FIFO is 16 Bytes */ -/** - * @} - */ - -/** @defgroup ETH_Forward_Error_Frames ETH Forward Error Frames - * @{ - */ -#define ETH_FORWARDERRORFRAMES_ENABLE ((uint32_t)0x00000080U) -#define ETH_FORWARDERRORFRAMES_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Forward_Undersized_Good_Frames ETH Forward Undersized Good Frames - * @{ - */ -#define ETH_FORWARDUNDERSIZEDGOODFRAMES_ENABLE ((uint32_t)0x00000040U) -#define ETH_FORWARDUNDERSIZEDGOODFRAMES_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Receive_Threshold_Control ETH Receive Threshold Control - * @{ - */ -#define ETH_RECEIVEDTHRESHOLDCONTROL_64BYTES ((uint32_t)0x00000000U) /*!< threshold level of the MTL Receive FIFO is 64 Bytes */ -#define ETH_RECEIVEDTHRESHOLDCONTROL_32BYTES ((uint32_t)0x00000008U) /*!< threshold level of the MTL Receive FIFO is 32 Bytes */ -#define ETH_RECEIVEDTHRESHOLDCONTROL_96BYTES ((uint32_t)0x00000010U) /*!< threshold level of the MTL Receive FIFO is 96 Bytes */ -#define ETH_RECEIVEDTHRESHOLDCONTROL_128BYTES ((uint32_t)0x00000018U) /*!< threshold level of the MTL Receive FIFO is 128 Bytes */ -/** - * @} - */ - -/** @defgroup ETH_Second_Frame_Operate ETH Second Frame Operate - * @{ - */ -#define ETH_SECONDFRAMEOPERARTE_ENABLE ((uint32_t)0x00000004U) -#define ETH_SECONDFRAMEOPERARTE_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Address_Aligned_Beats ETH Address Aligned Beats - * @{ - */ -#define ETH_ADDRESSALIGNEDBEATS_ENABLE ((uint32_t)0x02000000U) -#define ETH_ADDRESSALIGNEDBEATS_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Fixed_Burst ETH Fixed Burst - * @{ - */ -#define ETH_FIXEDBURST_ENABLE ((uint32_t)0x00010000U) -#define ETH_FIXEDBURST_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_Rx_DMA_Burst_Length ETH Rx DMA Burst Length - * @{ - */ -#define ETH_RXDMABURSTLENGTH_1BEAT ((uint32_t)0x00020000U) /*!< maximum number of beats to be transferred in one RxDMA transaction is 1 */ -#define ETH_RXDMABURSTLENGTH_2BEAT ((uint32_t)0x00040000U) /*!< maximum number of beats to be transferred in one RxDMA transaction is 2 */ -#define ETH_RXDMABURSTLENGTH_4BEAT ((uint32_t)0x00080000U) /*!< maximum number of beats to be transferred in one RxDMA transaction is 4 */ -#define ETH_RXDMABURSTLENGTH_8BEAT ((uint32_t)0x00100000U) /*!< maximum number of beats to be transferred in one RxDMA transaction is 8 */ -#define ETH_RXDMABURSTLENGTH_16BEAT ((uint32_t)0x00200000U) /*!< maximum number of beats to be transferred in one RxDMA transaction is 16 */ -#define ETH_RXDMABURSTLENGTH_32BEAT ((uint32_t)0x00400000U) /*!< maximum number of beats to be transferred in one RxDMA transaction is 32 */ -#define ETH_RXDMABURSTLENGTH_4XPBL_4BEAT ((uint32_t)0x01020000U) /*!< maximum number of beats to be transferred in one RxDMA transaction is 4 */ -#define ETH_RXDMABURSTLENGTH_4XPBL_8BEAT ((uint32_t)0x01040000U) /*!< maximum number of beats to be transferred in one RxDMA transaction is 8 */ -#define ETH_RXDMABURSTLENGTH_4XPBL_16BEAT ((uint32_t)0x01080000U) /*!< maximum number of beats to be transferred in one RxDMA transaction is 16 */ -#define ETH_RXDMABURSTLENGTH_4XPBL_32BEAT ((uint32_t)0x01100000U) /*!< maximum number of beats to be transferred in one RxDMA transaction is 32 */ -#define ETH_RXDMABURSTLENGTH_4XPBL_64BEAT ((uint32_t)0x01200000U) /*!< maximum number of beats to be transferred in one RxDMA transaction is 64 */ -#define ETH_RXDMABURSTLENGTH_4XPBL_128BEAT ((uint32_t)0x01400000U) /*!< maximum number of beats to be transferred in one RxDMA transaction is 128 */ -/** - * @} - */ - -/** @defgroup ETH_Tx_DMA_Burst_Length ETH Tx DMA Burst Length - * @{ - */ -#define ETH_TXDMABURSTLENGTH_1BEAT ((uint32_t)0x00000100U) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 1 */ -#define ETH_TXDMABURSTLENGTH_2BEAT ((uint32_t)0x00000200U) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 2 */ -#define ETH_TXDMABURSTLENGTH_4BEAT ((uint32_t)0x00000400U) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 4 */ -#define ETH_TXDMABURSTLENGTH_8BEAT ((uint32_t)0x00000800U) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 8 */ -#define ETH_TXDMABURSTLENGTH_16BEAT ((uint32_t)0x00001000U) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 16 */ -#define ETH_TXDMABURSTLENGTH_32BEAT ((uint32_t)0x00002000U) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 32 */ -#define ETH_TXDMABURSTLENGTH_4XPBL_4BEAT ((uint32_t)0x01000100U) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 4 */ -#define ETH_TXDMABURSTLENGTH_4XPBL_8BEAT ((uint32_t)0x01000200U) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 8 */ -#define ETH_TXDMABURSTLENGTH_4XPBL_16BEAT ((uint32_t)0x01000400U) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 16 */ -#define ETH_TXDMABURSTLENGTH_4XPBL_32BEAT ((uint32_t)0x01000800U) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 32 */ -#define ETH_TXDMABURSTLENGTH_4XPBL_64BEAT ((uint32_t)0x01001000U) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 64 */ -#define ETH_TXDMABURSTLENGTH_4XPBL_128BEAT ((uint32_t)0x01002000U) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 128 */ -/** - * @} - */ - -/** @defgroup ETH_DMA_Enhanced_descriptor_format ETH DMA Enhanced descriptor format - * @{ - */ -#define ETH_DMAENHANCEDDESCRIPTOR_ENABLE ((uint32_t)0x00000080U) -#define ETH_DMAENHANCEDDESCRIPTOR_DISABLE ((uint32_t)0x00000000U) -/** - * @} - */ - -/** @defgroup ETH_DMA_Arbitration ETH DMA Arbitration - * @{ - */ -#define ETH_DMAARBITRATION_ROUNDROBIN_RXTX_1_1 ((uint32_t)0x00000000U) -#define ETH_DMAARBITRATION_ROUNDROBIN_RXTX_2_1 ((uint32_t)0x00004000U) -#define ETH_DMAARBITRATION_ROUNDROBIN_RXTX_3_1 ((uint32_t)0x00008000U) -#define ETH_DMAARBITRATION_ROUNDROBIN_RXTX_4_1 ((uint32_t)0x0000C000U) -#define ETH_DMAARBITRATION_RXPRIORTX ((uint32_t)0x00000002U) -/** - * @} - */ - -/** @defgroup ETH_DMA_Tx_descriptor_segment ETH DMA Tx descriptor segment - * @{ - */ -#define ETH_DMATXDESC_LASTSEGMENTS ((uint32_t)0x40000000U) /*!< Last Segment */ -#define ETH_DMATXDESC_FIRSTSEGMENT ((uint32_t)0x20000000U) /*!< First Segment */ -/** - * @} - */ - -/** @defgroup ETH_DMA_Tx_descriptor_Checksum_Insertion_Control ETH DMA Tx descriptor Checksum Insertion Control - * @{ - */ -#define ETH_DMATXDESC_CHECKSUMBYPASS ((uint32_t)0x00000000U) /*!< Checksum engine bypass */ -#define ETH_DMATXDESC_CHECKSUMIPV4HEADER ((uint32_t)0x00400000U) /*!< IPv4 header checksum insertion */ -#define ETH_DMATXDESC_CHECKSUMTCPUDPICMPSEGMENT ((uint32_t)0x00800000U) /*!< TCP/UDP/ICMP checksum insertion. Pseudo header checksum is assumed to be present */ -#define ETH_DMATXDESC_CHECKSUMTCPUDPICMPFULL ((uint32_t)0x00C00000U) /*!< TCP/UDP/ICMP checksum fully in hardware including pseudo header */ -/** - * @} - */ - -/** @defgroup ETH_DMA_Rx_descriptor_buffers ETH DMA Rx descriptor buffers - * @{ - */ -#define ETH_DMARXDESC_BUFFER1 ((uint32_t)0x00000000U) /*!< DMA Rx Desc Buffer1 */ -#define ETH_DMARXDESC_BUFFER2 ((uint32_t)0x00000001U) /*!< DMA Rx Desc Buffer2 */ -/** - * @} - */ - -/** @defgroup ETH_PMT_Flags ETH PMT Flags - * @{ - */ -#define ETH_PMT_FLAG_WUFFRPR ((uint32_t)0x80000000U) /*!< Wake-Up Frame Filter Register Pointer Reset */ -#define ETH_PMT_FLAG_WUFR ((uint32_t)0x00000040U) /*!< Wake-Up Frame Received */ -#define ETH_PMT_FLAG_MPR ((uint32_t)0x00000020U) /*!< Magic Packet Received */ -/** - * @} - */ - -/** @defgroup ETH_MMC_Tx_Interrupts ETH MMC Tx Interrupts - * @{ - */ -#define ETH_MMC_IT_TGF ((uint32_t)0x00200000U) /*!< When Tx good frame counter reaches half the maximum value */ -#define ETH_MMC_IT_TGFMSC ((uint32_t)0x00008000U) /*!< When Tx good multi col counter reaches half the maximum value */ -#define ETH_MMC_IT_TGFSC ((uint32_t)0x00004000U) /*!< When Tx good single col counter reaches half the maximum value */ -/** - * @} - */ - -/** @defgroup ETH_MMC_Rx_Interrupts ETH MMC Rx Interrupts - * @{ - */ -#define ETH_MMC_IT_RGUF ((uint32_t)0x10020000U) /*!< When Rx good unicast frames counter reaches half the maximum value */ -#define ETH_MMC_IT_RFAE ((uint32_t)0x10000040U) /*!< When Rx alignment error counter reaches half the maximum value */ -#define ETH_MMC_IT_RFCE ((uint32_t)0x10000020U) /*!< When Rx crc error counter reaches half the maximum value */ -/** - * @} - */ - -/** @defgroup ETH_MAC_Flags ETH MAC Flags - * @{ - */ -#define ETH_MAC_FLAG_TST ((uint32_t)0x00000200U) /*!< Time stamp trigger flag (on MAC) */ -#define ETH_MAC_FLAG_MMCT ((uint32_t)0x00000040U) /*!< MMC transmit flag */ -#define ETH_MAC_FLAG_MMCR ((uint32_t)0x00000020U) /*!< MMC receive flag */ -#define ETH_MAC_FLAG_MMC ((uint32_t)0x00000010U) /*!< MMC flag (on MAC) */ -#define ETH_MAC_FLAG_PMT ((uint32_t)0x00000008U) /*!< PMT flag (on MAC) */ -/** - * @} - */ - -/** @defgroup ETH_DMA_Flags ETH DMA Flags - * @{ - */ -#define ETH_DMA_FLAG_TST ((uint32_t)0x20000000U) /*!< Time-stamp trigger interrupt (on DMA) */ -#define ETH_DMA_FLAG_PMT ((uint32_t)0x10000000U) /*!< PMT interrupt (on DMA) */ -#define ETH_DMA_FLAG_MMC ((uint32_t)0x08000000U) /*!< MMC interrupt (on DMA) */ -#define ETH_DMA_FLAG_DATATRANSFERERROR ((uint32_t)0x00800000U) /*!< Error bits 0-Rx DMA, 1-Tx DMA */ -#define ETH_DMA_FLAG_READWRITEERROR ((uint32_t)0x01000000U) /*!< Error bits 0-write transfer, 1-read transfer */ -#define ETH_DMA_FLAG_ACCESSERROR ((uint32_t)0x02000000U) /*!< Error bits 0-data buffer, 1-desc. access */ -#define ETH_DMA_FLAG_NIS ((uint32_t)0x00010000U) /*!< Normal interrupt summary flag */ -#define ETH_DMA_FLAG_AIS ((uint32_t)0x00008000U) /*!< Abnormal interrupt summary flag */ -#define ETH_DMA_FLAG_ER ((uint32_t)0x00004000U) /*!< Early receive flag */ -#define ETH_DMA_FLAG_FBE ((uint32_t)0x00002000U) /*!< Fatal bus error flag */ -#define ETH_DMA_FLAG_ET ((uint32_t)0x00000400U) /*!< Early transmit flag */ -#define ETH_DMA_FLAG_RWT ((uint32_t)0x00000200U) /*!< Receive watchdog timeout flag */ -#define ETH_DMA_FLAG_RPS ((uint32_t)0x00000100U) /*!< Receive process stopped flag */ -#define ETH_DMA_FLAG_RBU ((uint32_t)0x00000080U) /*!< Receive buffer unavailable flag */ -#define ETH_DMA_FLAG_R ((uint32_t)0x00000040U) /*!< Receive flag */ -#define ETH_DMA_FLAG_TU ((uint32_t)0x00000020U) /*!< Underflow flag */ -#define ETH_DMA_FLAG_RO ((uint32_t)0x00000010U) /*!< Overflow flag */ -#define ETH_DMA_FLAG_TJT ((uint32_t)0x00000008U) /*!< Transmit jabber timeout flag */ -#define ETH_DMA_FLAG_TBU ((uint32_t)0x00000004U) /*!< Transmit buffer unavailable flag */ -#define ETH_DMA_FLAG_TPS ((uint32_t)0x00000002U) /*!< Transmit process stopped flag */ -#define ETH_DMA_FLAG_T ((uint32_t)0x00000001U) /*!< Transmit flag */ -/** - * @} - */ - -/** @defgroup ETH_MAC_Interrupts ETH MAC Interrupts - * @{ - */ -#define ETH_MAC_IT_TST ((uint32_t)0x00000200U) /*!< Time stamp trigger interrupt (on MAC) */ -#define ETH_MAC_IT_MMCT ((uint32_t)0x00000040U) /*!< MMC transmit interrupt */ -#define ETH_MAC_IT_MMCR ((uint32_t)0x00000020U) /*!< MMC receive interrupt */ -#define ETH_MAC_IT_MMC ((uint32_t)0x00000010U) /*!< MMC interrupt (on MAC) */ -#define ETH_MAC_IT_PMT ((uint32_t)0x00000008U) /*!< PMT interrupt (on MAC) */ -/** - * @} - */ - -/** @defgroup ETH_DMA_Interrupts ETH DMA Interrupts - * @{ - */ -#define ETH_DMA_IT_TST ((uint32_t)0x20000000U) /*!< Time-stamp trigger interrupt (on DMA) */ -#define ETH_DMA_IT_PMT ((uint32_t)0x10000000U) /*!< PMT interrupt (on DMA) */ -#define ETH_DMA_IT_MMC ((uint32_t)0x08000000U) /*!< MMC interrupt (on DMA) */ -#define ETH_DMA_IT_NIS ((uint32_t)0x00010000U) /*!< Normal interrupt summary */ -#define ETH_DMA_IT_AIS ((uint32_t)0x00008000U) /*!< Abnormal interrupt summary */ -#define ETH_DMA_IT_ER ((uint32_t)0x00004000U) /*!< Early receive interrupt */ -#define ETH_DMA_IT_FBE ((uint32_t)0x00002000U) /*!< Fatal bus error interrupt */ -#define ETH_DMA_IT_ET ((uint32_t)0x00000400U) /*!< Early transmit interrupt */ -#define ETH_DMA_IT_RWT ((uint32_t)0x00000200U) /*!< Receive watchdog timeout interrupt */ -#define ETH_DMA_IT_RPS ((uint32_t)0x00000100U) /*!< Receive process stopped interrupt */ -#define ETH_DMA_IT_RBU ((uint32_t)0x00000080U) /*!< Receive buffer unavailable interrupt */ -#define ETH_DMA_IT_R ((uint32_t)0x00000040U) /*!< Receive interrupt */ -#define ETH_DMA_IT_TU ((uint32_t)0x00000020U) /*!< Underflow interrupt */ -#define ETH_DMA_IT_RO ((uint32_t)0x00000010U) /*!< Overflow interrupt */ -#define ETH_DMA_IT_TJT ((uint32_t)0x00000008U) /*!< Transmit jabber timeout interrupt */ -#define ETH_DMA_IT_TBU ((uint32_t)0x00000004U) /*!< Transmit buffer unavailable interrupt */ -#define ETH_DMA_IT_TPS ((uint32_t)0x00000002U) /*!< Transmit process stopped interrupt */ -#define ETH_DMA_IT_T ((uint32_t)0x00000001U) /*!< Transmit interrupt */ -/** - * @} - */ - -/** @defgroup ETH_DMA_transmit_process_state ETH DMA transmit process state - * @{ - */ -#define ETH_DMA_TRANSMITPROCESS_STOPPED ((uint32_t)0x00000000U) /*!< Stopped - Reset or Stop Tx Command issued */ -#define ETH_DMA_TRANSMITPROCESS_FETCHING ((uint32_t)0x00100000U) /*!< Running - fetching the Tx descriptor */ -#define ETH_DMA_TRANSMITPROCESS_WAITING ((uint32_t)0x00200000U) /*!< Running - waiting for status */ -#define ETH_DMA_TRANSMITPROCESS_READING ((uint32_t)0x00300000U) /*!< Running - reading the data from host memory */ -#define ETH_DMA_TRANSMITPROCESS_SUSPENDED ((uint32_t)0x00600000U) /*!< Suspended - Tx Descriptor unavailable */ -#define ETH_DMA_TRANSMITPROCESS_CLOSING ((uint32_t)0x00700000U) /*!< Running - closing Rx descriptor */ - -/** - * @} - */ - - -/** @defgroup ETH_DMA_receive_process_state ETH DMA receive process state - * @{ - */ -#define ETH_DMA_RECEIVEPROCESS_STOPPED ((uint32_t)0x00000000U) /*!< Stopped - Reset or Stop Rx Command issued */ -#define ETH_DMA_RECEIVEPROCESS_FETCHING ((uint32_t)0x00020000U) /*!< Running - fetching the Rx descriptor */ -#define ETH_DMA_RECEIVEPROCESS_WAITING ((uint32_t)0x00060000U) /*!< Running - waiting for packet */ -#define ETH_DMA_RECEIVEPROCESS_SUSPENDED ((uint32_t)0x00080000U) /*!< Suspended - Rx Descriptor unavailable */ -#define ETH_DMA_RECEIVEPROCESS_CLOSING ((uint32_t)0x000A0000U) /*!< Running - closing descriptor */ -#define ETH_DMA_RECEIVEPROCESS_QUEUING ((uint32_t)0x000E0000U) /*!< Running - queuing the receive frame into host memory */ - -/** - * @} - */ - -/** @defgroup ETH_DMA_overflow ETH DMA overflow - * @{ - */ -#define ETH_DMA_OVERFLOW_RXFIFOCOUNTER ((uint32_t)0x10000000U) /*!< Overflow bit for FIFO overflow counter */ -#define ETH_DMA_OVERFLOW_MISSEDFRAMECOUNTER ((uint32_t)0x00010000U) /*!< Overflow bit for missed frame counter */ -/** - * @} - */ - -/** @defgroup ETH_EXTI_LINE_WAKEUP ETH EXTI LINE WAKEUP - * @{ - */ -#define ETH_EXTI_LINE_WAKEUP ((uint32_t)0x00080000U) /*!< External interrupt line 19 Connected to the ETH EXTI Line */ - -/** - * @} - */ - -/** - * @} - */ - -/* Exported macro ------------------------------------------------------------*/ -/** @defgroup ETH_Exported_Macros ETH Exported Macros - * @brief macros to handle interrupts and specific clock configurations - * @{ - */ - -/** @brief Reset ETH handle state - * @param __HANDLE__: specifies the ETH handle. - * @retval None - */ -#define __HAL_ETH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ETH_STATE_RESET) - -/** - * @brief Checks whether the specified Ethernet DMA Tx Desc flag is set or not. - * @param __HANDLE__: ETH Handle - * @param __FLAG__: specifies the flag of TDES0 to check. - * @retval the ETH_DMATxDescFlag (SET or RESET). - */ -#define __HAL_ETH_DMATXDESC_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->TxDesc->Status & (__FLAG__) == (__FLAG__)) - -/** - * @brief Checks whether the specified Ethernet DMA Rx Desc flag is set or not. - * @param __HANDLE__: ETH Handle - * @param __FLAG__: specifies the flag of RDES0 to check. - * @retval the ETH_DMATxDescFlag (SET or RESET). - */ -#define __HAL_ETH_DMARXDESC_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->RxDesc->Status & (__FLAG__) == (__FLAG__)) - -/** - * @brief Enables the specified DMA Rx Desc receive interrupt. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMARXDESC_ENABLE_IT(__HANDLE__) ((__HANDLE__)->RxDesc->ControlBufferSize &=(~(uint32_t)ETH_DMARXDESC_DIC)) - -/** - * @brief Disables the specified DMA Rx Desc receive interrupt. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMARXDESC_DISABLE_IT(__HANDLE__) ((__HANDLE__)->RxDesc->ControlBufferSize |= ETH_DMARXDESC_DIC) - -/** - * @brief Set the specified DMA Rx Desc Own bit. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMARXDESC_SET_OWN_BIT(__HANDLE__) ((__HANDLE__)->RxDesc->Status |= ETH_DMARXDESC_OWN) - -/** - * @brief Returns the specified Ethernet DMA Tx Desc collision count. - * @param __HANDLE__: ETH Handle - * @retval The Transmit descriptor collision counter value. - */ -#define __HAL_ETH_DMATXDESC_GET_COLLISION_COUNT(__HANDLE__) (((__HANDLE__)->TxDesc->Status & ETH_DMATXDESC_CC) >> ETH_DMATXDESC_COLLISION_COUNTSHIFT) - -/** - * @brief Set the specified DMA Tx Desc Own bit. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMATXDESC_SET_OWN_BIT(__HANDLE__) ((__HANDLE__)->TxDesc->Status |= ETH_DMATXDESC_OWN) - -/** - * @brief Enables the specified DMA Tx Desc Transmit interrupt. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMATXDESC_ENABLE_IT(__HANDLE__) ((__HANDLE__)->TxDesc->Status |= ETH_DMATXDESC_IC) - -/** - * @brief Disables the specified DMA Tx Desc Transmit interrupt. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMATXDESC_DISABLE_IT(__HANDLE__) ((__HANDLE__)->TxDesc->Status &= ~ETH_DMATXDESC_IC) - -/** - * @brief Selects the specified Ethernet DMA Tx Desc Checksum Insertion. - * @param __HANDLE__: ETH Handle - * @param __CHECKSUM__: specifies is the DMA Tx desc checksum insertion. - * This parameter can be one of the following values: - * @arg ETH_DMATXDESC_CHECKSUMBYPASS : Checksum bypass - * @arg ETH_DMATXDESC_CHECKSUMIPV4HEADER : IPv4 header checksum - * @arg ETH_DMATXDESC_CHECKSUMTCPUDPICMPSEGMENT : TCP/UDP/ICMP checksum. Pseudo header checksum is assumed to be present - * @arg ETH_DMATXDESC_CHECKSUMTCPUDPICMPFULL : TCP/UDP/ICMP checksum fully in hardware including pseudo header - * @retval None - */ -#define __HAL_ETH_DMATXDESC_CHECKSUM_INSERTION(__HANDLE__, __CHECKSUM__) ((__HANDLE__)->TxDesc->Status |= (__CHECKSUM__)) - -/** - * @brief Enables the DMA Tx Desc CRC. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMATXDESC_CRC_ENABLE(__HANDLE__) ((__HANDLE__)->TxDesc->Status &= ~ETH_DMATXDESC_DC) - -/** - * @brief Disables the DMA Tx Desc CRC. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMATXDESC_CRC_DISABLE(__HANDLE__) ((__HANDLE__)->TxDesc->Status |= ETH_DMATXDESC_DC) - -/** - * @brief Enables the DMA Tx Desc padding for frame shorter than 64 bytes. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMATXDESC_SHORT_FRAME_PADDING_ENABLE(__HANDLE__) ((__HANDLE__)->TxDesc->Status &= ~ETH_DMATXDESC_DP) - -/** - * @brief Disables the DMA Tx Desc padding for frame shorter than 64 bytes. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMATXDESC_SHORT_FRAME_PADDING_DISABLE(__HANDLE__) ((__HANDLE__)->TxDesc->Status |= ETH_DMATXDESC_DP) - -/** - * @brief Enables the specified Ethernet MAC interrupts. - * @param __HANDLE__ : ETH Handle - * @param __INTERRUPT__: specifies the Ethernet MAC interrupt sources to be - * enabled or disabled. - * This parameter can be any combination of the following values: - * @arg ETH_MAC_IT_TST : Time stamp trigger interrupt - * @arg ETH_MAC_IT_PMT : PMT interrupt - * @retval None - */ -#define __HAL_ETH_MAC_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MACIMR |= (__INTERRUPT__)) - -/** - * @brief Disables the specified Ethernet MAC interrupts. - * @param __HANDLE__ : ETH Handle - * @param __INTERRUPT__: specifies the Ethernet MAC interrupt sources to be - * enabled or disabled. - * This parameter can be any combination of the following values: - * @arg ETH_MAC_IT_TST : Time stamp trigger interrupt - * @arg ETH_MAC_IT_PMT : PMT interrupt - * @retval None - */ -#define __HAL_ETH_MAC_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MACIMR &= ~(__INTERRUPT__)) - -/** - * @brief Initiate a Pause Control Frame (Full-duplex only). - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_INITIATE_PAUSE_CONTROL_FRAME(__HANDLE__) ((__HANDLE__)->Instance->MACFCR |= ETH_MACFCR_FCBBPA) - -/** - * @brief Checks whether the Ethernet flow control busy bit is set or not. - * @param __HANDLE__: ETH Handle - * @retval The new state of flow control busy status bit (SET or RESET). - */ -#define __HAL_ETH_GET_FLOW_CONTROL_BUSY_STATUS(__HANDLE__) (((__HANDLE__)->Instance->MACFCR & ETH_MACFCR_FCBBPA) == ETH_MACFCR_FCBBPA) - -/** - * @brief Enables the MAC Back Pressure operation activation (Half-duplex only). - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_BACK_PRESSURE_ACTIVATION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MACFCR |= ETH_MACFCR_FCBBPA) - -/** - * @brief Disables the MAC BackPressure operation activation (Half-duplex only). - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_BACK_PRESSURE_ACTIVATION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MACFCR &= ~ETH_MACFCR_FCBBPA) - -/** - * @brief Checks whether the specified Ethernet MAC flag is set or not. - * @param __HANDLE__: ETH Handle - * @param __FLAG__: specifies the flag to check. - * This parameter can be one of the following values: - * @arg ETH_MAC_FLAG_TST : Time stamp trigger flag - * @arg ETH_MAC_FLAG_MMCT : MMC transmit flag - * @arg ETH_MAC_FLAG_MMCR : MMC receive flag - * @arg ETH_MAC_FLAG_MMC : MMC flag - * @arg ETH_MAC_FLAG_PMT : PMT flag - * @retval The state of Ethernet MAC flag. - */ -#define __HAL_ETH_MAC_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->MACSR &( __FLAG__)) == ( __FLAG__)) - -/** - * @brief Enables the specified Ethernet DMA interrupts. - * @param __HANDLE__ : ETH Handle - * @param __INTERRUPT__: specifies the Ethernet DMA interrupt sources to be - * enabled @ref ETH_DMA_Interrupts - * @retval None - */ -#define __HAL_ETH_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DMAIER |= (__INTERRUPT__)) - -/** - * @brief Disables the specified Ethernet DMA interrupts. - * @param __HANDLE__ : ETH Handle - * @param __INTERRUPT__: specifies the Ethernet DMA interrupt sources to be - * disabled. @ref ETH_DMA_Interrupts - * @retval None - */ -#define __HAL_ETH_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DMAIER &= ~(__INTERRUPT__)) - -/** - * @brief Clears the Ethernet DMA IT pending bit. - * @param __HANDLE__ : ETH Handle - * @param __INTERRUPT__: specifies the interrupt pending bit to clear. @ref ETH_DMA_Interrupts - * @retval None - */ -#define __HAL_ETH_DMA_CLEAR_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DMASR =(__INTERRUPT__)) - -/** - * @brief Checks whether the specified Ethernet DMA flag is set or not. -* @param __HANDLE__: ETH Handle - * @param __FLAG__: specifies the flag to check. @ref ETH_DMA_Flags - * @retval The new state of ETH_DMA_FLAG (SET or RESET). - */ -#define __HAL_ETH_DMA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->DMASR &( __FLAG__)) == ( __FLAG__)) - -/** - * @brief Checks whether the specified Ethernet DMA flag is set or not. - * @param __HANDLE__: ETH Handle - * @param __FLAG__: specifies the flag to clear. @ref ETH_DMA_Flags - * @retval The new state of ETH_DMA_FLAG (SET or RESET). - */ -#define __HAL_ETH_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->DMASR = (__FLAG__)) - -/** - * @brief Checks whether the specified Ethernet DMA overflow flag is set or not. - * @param __HANDLE__: ETH Handle - * @param __OVERFLOW__: specifies the DMA overflow flag to check. - * This parameter can be one of the following values: - * @arg ETH_DMA_OVERFLOW_RXFIFOCOUNTER : Overflow for FIFO Overflows Counter - * @arg ETH_DMA_OVERFLOW_MISSEDFRAMECOUNTER : Overflow for Buffer Unavailable Missed Frame Counter - * @retval The state of Ethernet DMA overflow Flag (SET or RESET). - */ -#define __HAL_ETH_GET_DMA_OVERFLOW_STATUS(__HANDLE__, __OVERFLOW__) (((__HANDLE__)->Instance->DMAMFBOCR & (__OVERFLOW__)) == (__OVERFLOW__)) - -/** - * @brief Set the DMA Receive status watchdog timer register value - * @param __HANDLE__: ETH Handle - * @param __VALUE__: DMA Receive status watchdog timer register value - * @retval None - */ -#define __HAL_ETH_SET_RECEIVE_WATCHDOG_TIMER(__HANDLE__, __VALUE__) ((__HANDLE__)->Instance->DMARSWTR = (__VALUE__)) - -/** - * @brief Enables any unicast packet filtered by the MAC address - * recognition to be a wake-up frame. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_GLOBAL_UNICAST_WAKEUP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR |= ETH_MACPMTCSR_GU) - -/** - * @brief Disables any unicast packet filtered by the MAC address - * recognition to be a wake-up frame. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_GLOBAL_UNICAST_WAKEUP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR &= ~ETH_MACPMTCSR_GU) - -/** - * @brief Enables the MAC Wake-Up Frame Detection. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_WAKEUP_FRAME_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR |= ETH_MACPMTCSR_WFE) - -/** - * @brief Disables the MAC Wake-Up Frame Detection. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_WAKEUP_FRAME_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR &= ~ETH_MACPMTCSR_WFE) - -/** - * @brief Enables the MAC Magic Packet Detection. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_MAGIC_PACKET_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR |= ETH_MACPMTCSR_MPE) - -/** - * @brief Disables the MAC Magic Packet Detection. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_MAGIC_PACKET_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR &= ~ETH_MACPMTCSR_WFE) - -/** - * @brief Enables the MAC Power Down. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_POWER_DOWN_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR |= ETH_MACPMTCSR_PD) - -/** - * @brief Disables the MAC Power Down. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_POWER_DOWN_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR &= ~ETH_MACPMTCSR_PD) - -/** - * @brief Checks whether the specified Ethernet PMT flag is set or not. - * @param __HANDLE__: ETH Handle. - * @param __FLAG__: specifies the flag to check. - * This parameter can be one of the following values: - * @arg ETH_PMT_FLAG_WUFFRPR : Wake-Up Frame Filter Register Pointer Reset - * @arg ETH_PMT_FLAG_WUFR : Wake-Up Frame Received - * @arg ETH_PMT_FLAG_MPR : Magic Packet Received - * @retval The new state of Ethernet PMT Flag (SET or RESET). - */ -#define __HAL_ETH_GET_PMT_FLAG_STATUS(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->MACPMTCSR &( __FLAG__)) == ( __FLAG__)) - -/** - * @brief Preset and Initialize the MMC counters to almost-full value: 0xFFFF_FFF0 (full - 16) - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_MMC_COUNTER_FULL_PRESET(__HANDLE__) ((__HANDLE__)->Instance->MMCCR |= (ETH_MMCCR_MCFHP | ETH_MMCCR_MCP)) - -/** - * @brief Preset and Initialize the MMC counters to almost-half value: 0x7FFF_FFF0 (half - 16) - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_MMC_COUNTER_HALF_PRESET(__HANDLE__) do{(__HANDLE__)->Instance->MMCCR &= ~ETH_MMCCR_MCFHP;\ - (__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_MCP;} while (0) - -/** - * @brief Enables the MMC Counter Freeze. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_MMC_COUNTER_FREEZE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_MCF) - -/** - * @brief Disables the MMC Counter Freeze. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_MMC_COUNTER_FREEZE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MMCCR &= ~ETH_MMCCR_MCF) - -/** - * @brief Enables the MMC Reset On Read. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_ETH_MMC_RESET_ONREAD_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_ROR) - -/** - * @brief Disables the MMC Reset On Read. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_ETH_MMC_RESET_ONREAD_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MMCCR &= ~ETH_MMCCR_ROR) - -/** - * @brief Enables the MMC Counter Stop Rollover. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_ETH_MMC_COUNTER_ROLLOVER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MMCCR &= ~ETH_MMCCR_CSR) - -/** - * @brief Disables the MMC Counter Stop Rollover. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_ETH_MMC_COUNTER_ROLLOVER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_CSR) - -/** - * @brief Resets the MMC Counters. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_MMC_COUNTERS_RESET(__HANDLE__) ((__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_CR) - -/** - * @brief Enables the specified Ethernet MMC Rx interrupts. - * @param __HANDLE__: ETH Handle. - * @param __INTERRUPT__: specifies the Ethernet MMC interrupt sources to be enabled or disabled. - * This parameter can be one of the following values: - * @arg ETH_MMC_IT_RGUF : When Rx good unicast frames counter reaches half the maximum value - * @arg ETH_MMC_IT_RFAE : When Rx alignment error counter reaches half the maximum value - * @arg ETH_MMC_IT_RFCE : When Rx crc error counter reaches half the maximum value - * @retval None - */ -#define __HAL_ETH_MMC_RX_IT_ENABLE(__HANDLE__, __INTERRUPT__) (__HANDLE__)->Instance->MMCRIMR &= ~((__INTERRUPT__) & 0xEFFFFFFF) -/** - * @brief Disables the specified Ethernet MMC Rx interrupts. - * @param __HANDLE__: ETH Handle. - * @param __INTERRUPT__: specifies the Ethernet MMC interrupt sources to be enabled or disabled. - * This parameter can be one of the following values: - * @arg ETH_MMC_IT_RGUF : When Rx good unicast frames counter reaches half the maximum value - * @arg ETH_MMC_IT_RFAE : When Rx alignment error counter reaches half the maximum value - * @arg ETH_MMC_IT_RFCE : When Rx crc error counter reaches half the maximum value - * @retval None - */ -#define __HAL_ETH_MMC_RX_IT_DISABLE(__HANDLE__, __INTERRUPT__) (__HANDLE__)->Instance->MMCRIMR |= ((__INTERRUPT__) & 0xEFFFFFFF) -/** - * @brief Enables the specified Ethernet MMC Tx interrupts. - * @param __HANDLE__: ETH Handle. - * @param __INTERRUPT__: specifies the Ethernet MMC interrupt sources to be enabled or disabled. - * This parameter can be one of the following values: - * @arg ETH_MMC_IT_TGF : When Tx good frame counter reaches half the maximum value - * @arg ETH_MMC_IT_TGFMSC: When Tx good multi col counter reaches half the maximum value - * @arg ETH_MMC_IT_TGFSC : When Tx good single col counter reaches half the maximum value - * @retval None - */ -#define __HAL_ETH_MMC_TX_IT_ENABLE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MMCRIMR &= ~ (__INTERRUPT__)) - -/** - * @brief Disables the specified Ethernet MMC Tx interrupts. - * @param __HANDLE__: ETH Handle. - * @param __INTERRUPT__: specifies the Ethernet MMC interrupt sources to be enabled or disabled. - * This parameter can be one of the following values: - * @arg ETH_MMC_IT_TGF : When Tx good frame counter reaches half the maximum value - * @arg ETH_MMC_IT_TGFMSC: When Tx good multi col counter reaches half the maximum value - * @arg ETH_MMC_IT_TGFSC : When Tx good single col counter reaches half the maximum value - * @retval None - */ -#define __HAL_ETH_MMC_TX_IT_DISABLE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MMCRIMR |= (__INTERRUPT__)) - -/** - * @brief Enables the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_ENABLE_IT() EXTI->IMR |= (ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Disables the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_DISABLE_IT() EXTI->IMR &= ~(ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Enable event on ETH External event line. - * @retval None. - */ -#define __HAL_ETH_WAKEUP_EXTI_ENABLE_EVENT() EXTI->EMR |= (ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Disable event on ETH External event line - * @retval None. - */ -#define __HAL_ETH_WAKEUP_EXTI_DISABLE_EVENT() EXTI->EMR &= ~(ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Get flag of the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_GET_FLAG() EXTI->PR & (ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Clear flag of the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_CLEAR_FLAG() EXTI->PR = (ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Enables rising edge trigger to the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_ENABLE_RISING_EDGE_TRIGGER() EXTI->RTSR |= ETH_EXTI_LINE_WAKEUP - -/** - * @brief Disables the rising edge trigger to the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_DISABLE_RISING_EDGE_TRIGGER() EXTI->RTSR &= ~(ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Enables falling edge trigger to the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_ENABLE_FALLING_EDGE_TRIGGER() EXTI->FTSR |= (ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Disables falling edge trigger to the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_DISABLE_FALLING_EDGE_TRIGGER() EXTI->FTSR &= ~(ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Enables rising/falling edge trigger to the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_ENABLE_FALLINGRISING_TRIGGER() EXTI->RTSR |= ETH_EXTI_LINE_WAKEUP;\ - EXTI->FTSR |= ETH_EXTI_LINE_WAKEUP - -/** - * @brief Disables rising/falling edge trigger to the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_DISABLE_FALLINGRISING_TRIGGER() EXTI->RTSR &= ~(ETH_EXTI_LINE_WAKEUP);\ - EXTI->FTSR &= ~(ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Generate a Software interrupt on selected EXTI line. - * @retval None. - */ -#define __HAL_ETH_WAKEUP_EXTI_GENERATE_SWIT() EXTI->SWIER|= ETH_EXTI_LINE_WAKEUP - -/** - * @} - */ -/* Exported functions --------------------------------------------------------*/ - -/** @addtogroup ETH_Exported_Functions - * @{ - */ - -/* Initialization and de-initialization functions ****************************/ - -/** @addtogroup ETH_Exported_Functions_Group1 - * @{ - */ -HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth); -HAL_StatusTypeDef HAL_ETH_DeInit(ETH_HandleTypeDef *heth); -void HAL_ETH_MspInit(ETH_HandleTypeDef *heth); -void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth); -HAL_StatusTypeDef HAL_ETH_DMATxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADescTypeDef *DMATxDescTab, uint8_t* TxBuff, uint32_t TxBuffCount); -HAL_StatusTypeDef HAL_ETH_DMARxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADescTypeDef *DMARxDescTab, uint8_t *RxBuff, uint32_t RxBuffCount); - -/** - * @} - */ -/* IO operation functions ****************************************************/ - -/** @addtogroup ETH_Exported_Functions_Group2 - * @{ - */ -HAL_StatusTypeDef HAL_ETH_TransmitFrame(ETH_HandleTypeDef *heth, uint32_t FrameLength); -HAL_StatusTypeDef HAL_ETH_GetReceivedFrame(ETH_HandleTypeDef *heth); -/* Communication with PHY functions*/ -HAL_StatusTypeDef HAL_ETH_ReadPHYRegister(ETH_HandleTypeDef *heth, uint16_t PHYReg, uint32_t *RegValue); -HAL_StatusTypeDef HAL_ETH_WritePHYRegister(ETH_HandleTypeDef *heth, uint16_t PHYReg, uint32_t RegValue); -/* Non-Blocking mode: Interrupt */ -HAL_StatusTypeDef HAL_ETH_GetReceivedFrame_IT(ETH_HandleTypeDef *heth); -void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth); -/* Callback in non blocking modes (Interrupt) */ -void HAL_ETH_TxCpltCallback(ETH_HandleTypeDef *heth); -void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth); -void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth); -/** - * @} - */ - -/* Peripheral Control functions **********************************************/ - -/** @addtogroup ETH_Exported_Functions_Group3 - * @{ - */ - -HAL_StatusTypeDef HAL_ETH_Start(ETH_HandleTypeDef *heth); -HAL_StatusTypeDef HAL_ETH_Stop(ETH_HandleTypeDef *heth); -HAL_StatusTypeDef HAL_ETH_ConfigMAC(ETH_HandleTypeDef *heth, ETH_MACInitTypeDef *macconf); -HAL_StatusTypeDef HAL_ETH_ConfigDMA(ETH_HandleTypeDef *heth, ETH_DMAInitTypeDef *dmaconf); -/** - * @} - */ - -/* Peripheral State functions ************************************************/ - -/** @addtogroup ETH_Exported_Functions_Group4 - * @{ - */ -HAL_ETH_StateTypeDef HAL_ETH_GetState(ETH_HandleTypeDef *heth); -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F7xx_HAL_ETH_H */ - - - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32Fxx/NetworkInterface.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32Fxx/NetworkInterface.c deleted file mode 100755 index ab0f676..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32Fxx/NetworkInterface.c +++ /dev/null @@ -1,1182 +0,0 @@ -/* - * Some constants, hardware definitions and comments taken from ST's HAL driver - * library, COPYRIGHT(c) 2015 STMicroelectronics. - */ - -/* - * FreeRTOS+TCP V2.0.3 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org - */ - - -/* Standard includes. */ -#include -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "FreeRTOS_DNS.h" -#include "NetworkBufferManagement.h" -#include "NetworkInterface.h" -#include "phyHandling.h" - -/* ST includes. */ -#ifdef STM32F7xx - #include "stm32f7xx_hal.h" -#else - #include "stm32f4xx_hal.h" -#endif - -/* Interrupt events to process. Currently only the Rx event is processed -although code for other events is included to allow for possible future -expansion. */ -#define EMAC_IF_RX_EVENT 1UL -#define EMAC_IF_TX_EVENT 2UL -#define EMAC_IF_ERR_EVENT 4UL -#define EMAC_IF_ALL_EVENT ( EMAC_IF_RX_EVENT | EMAC_IF_TX_EVENT | EMAC_IF_ERR_EVENT ) - -#define ETH_DMA_ALL_INTS \ - ( ETH_DMA_IT_TST | ETH_DMA_IT_PMT | ETH_DMA_IT_MMC | ETH_DMA_IT_NIS | ETH_DMA_IT_ER | \ - ETH_DMA_IT_FBE | ETH_DMA_IT_RWT | ETH_DMA_IT_RPS | ETH_DMA_IT_RBU | ETH_DMA_IT_R | \ - ETH_DMA_IT_TU | ETH_DMA_IT_RO | ETH_DMA_IT_TJT | ETH_DMA_IT_TPS | ETH_DMA_IT_T ) - - - -#define ipFRAGMENT_OFFSET_BIT_MASK ( ( uint16_t ) 0x0fff ) /* The bits in the two byte IP header field that make up the fragment offset value. */ - -/* - * Most users will want a PHY that negotiates about - * the connection properties: speed, dmix and duplex. - * On some rare cases, you want to select what is being - * advertised, properties like MDIX and duplex. - */ - -#if !defined( ipconfigETHERNET_AN_ENABLE ) - /* Enable auto-negotiation */ - #define ipconfigETHERNET_AN_ENABLE 1 -#endif - -#if !defined( ipconfigETHERNET_AUTO_CROSS_ENABLE ) - #define ipconfigETHERNET_AUTO_CROSS_ENABLE 1 -#endif - -#if( ipconfigETHERNET_AN_ENABLE == 0 ) - /* - * The following three defines are only used in case there - * is no auto-negotiation. - */ - #if !defined( ipconfigETHERNET_CROSSED_LINK ) - #define ipconfigETHERNET_CROSSED_LINK 1 - #endif - - #if !defined( ipconfigETHERNET_USE_100MB ) - #define ipconfigETHERNET_USE_100MB 1 - #endif - - #if !defined( ipconfigETHERNET_USE_FULL_DUPLEX ) - #define ipconfigETHERNET_USE_FULL_DUPLEX 1 - #endif -#endif /* ipconfigETHERNET_AN_ENABLE == 0 */ - -/* Default the size of the stack used by the EMAC deferred handler task to twice -the size of the stack used by the idle task - but allow this to be overridden in -FreeRTOSConfig.h as configMINIMAL_STACK_SIZE is a user definable constant. */ -#ifndef configEMAC_TASK_STACK_SIZE - #define configEMAC_TASK_STACK_SIZE ( 2 * configMINIMAL_STACK_SIZE ) -#endif - -/* Two choices must be made: RMII versus MII, -and the index of the PHY in use ( between 0 and 31 ). */ -#ifndef ipconfigUSE_RMII - #ifdef STM32F7xx - #define ipconfigUSE_RMII 1 - #else - #define ipconfigUSE_RMII 0 - #endif /* STM32F7xx */ -#endif /* ipconfigUSE_RMII */ - - - -/*-----------------------------------------------------------*/ - -/* - * A deferred interrupt handler task that processes - */ -static void prvEMACHandlerTask( void *pvParameters ); - -/* - * Force a negotiation with the Switch or Router and wait for LS. - */ -static void prvEthernetUpdateConfig( BaseType_t xForce ); - -/* - * See if there is a new packet and forward it to the IP-task. - */ -static BaseType_t prvNetworkInterfaceInput( void ); - -#if( ipconfigUSE_LLMNR != 0 ) - /* - * For LLMNR, an extra MAC-address must be configured to - * be able to receive the multicast messages. - */ - static void prvMACAddressConfig(ETH_HandleTypeDef *heth, uint32_t ulIndex, uint8_t *Addr); -#endif - -/* - * Check if a given packet should be accepted. - */ -static BaseType_t xMayAcceptPacket( uint8_t *pcBuffer ); - -/* - * Initialise the TX descriptors. - */ -static void prvDMATxDescListInit( void ); - -/* - * Initialise the RX descriptors. - */ -static void prvDMARxDescListInit( void ); - -/* After packets have been sent, the network -buffers will be released. */ -static void vClearTXBuffers( void ); - -/*-----------------------------------------------------------*/ - -/* Bit map of outstanding ETH interrupt events for processing. Currently only -the Rx interrupt is handled, although code is included for other events to -enable future expansion. */ -static volatile uint32_t ulISREvents; - -#if( ipconfigUSE_LLMNR == 1 ) - static const uint8_t xLLMNR_MACAddress[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0xFC }; -#endif - -static EthernetPhy_t xPhyObject; - -/* Ethernet handle. */ -static ETH_HandleTypeDef xETH; - -/* xTXDescriptorSemaphore is a counting semaphore with -a maximum count of ETH_TXBUFNB, which is the number of -DMA TX descriptors. */ -static SemaphoreHandle_t xTXDescriptorSemaphore = NULL; - -/* - * Note: it is adviced to define both - * - * #define ipconfigZERO_COPY_RX_DRIVER 1 - * #define ipconfigZERO_COPY_TX_DRIVER 1 - * - * The method using memcpy is slower and probaly uses more RAM memory. - * The possibility is left in the code just for comparison. - * - * It is adviced to define ETH_TXBUFNB at least 4. Note that no - * TX buffers are allocated in a zero-copy driver. - */ -/* MAC buffers: ---------------------------------------------------------*/ - -/* Put the DMA descriptors in '.first_data'. -This is important for STM32F7, which has an L1 data cache. -The first 64KB of the SRAM is not cached. */ - -/* Ethernet Rx MA Descriptor */ -__attribute__ ((aligned (32))) -__attribute__ ((section(".first_data"))) - ETH_DMADescTypeDef DMARxDscrTab[ ETH_RXBUFNB ]; - -#if( ipconfigZERO_COPY_RX_DRIVER == 0 ) - /* Ethernet Receive Buffer */ - __ALIGN_BEGIN uint8_t Rx_Buff[ ETH_RXBUFNB ][ ETH_RX_BUF_SIZE ] __ALIGN_END; -#endif - -/* Ethernet Tx DMA Descriptor */ -__attribute__ ((aligned (32))) -__attribute__ ((section(".first_data"))) - ETH_DMADescTypeDef DMATxDscrTab[ ETH_TXBUFNB ]; - -#if( ipconfigZERO_COPY_TX_DRIVER == 0 ) - /* Ethernet Transmit Buffer */ - __ALIGN_BEGIN uint8_t Tx_Buff[ ETH_TXBUFNB ][ ETH_TX_BUF_SIZE ] __ALIGN_END; -#endif - -#if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - /* DMATxDescToClear points to the next TX DMA descriptor - that must be cleared by vClearTXBuffers(). */ - static __IO ETH_DMADescTypeDef *DMATxDescToClear; -#endif - -/* ucMACAddress as it appears in main.c */ -extern const uint8_t ucMACAddress[ 6 ]; - -/* Holds the handle of the task used as a deferred interrupt processor. The -handle is used so direct notifications can be sent to the task for all EMAC/DMA -related interrupts. */ -static TaskHandle_t xEMACTaskHandle = NULL; - -/* For local use only: describe the PHY's properties: */ -const PhyProperties_t xPHYProperties = -{ - #if( ipconfigETHERNET_AN_ENABLE != 0 ) - .ucSpeed = PHY_SPEED_AUTO, - .ucDuplex = PHY_DUPLEX_AUTO, - #else - #if( ipconfigETHERNET_USE_100MB != 0 ) - .ucSpeed = PHY_SPEED_100, - #else - .ucSpeed = PHY_SPEED_10, - #endif - - #if( ipconfigETHERNET_USE_FULL_DUPLEX != 0 ) - .duplex = PHY_DUPLEX_FULL, - #else - .duplex = PHY_DUPLEX_HALF, - #endif - #endif - - #if( ipconfigETHERNET_AN_ENABLE != 0 ) && ( ipconfigETHERNET_AUTO_CROSS_ENABLE != 0 ) - .ucMDI_X = PHY_MDIX_AUTO, - #elif( ipconfigETHERNET_CROSSED_LINK != 0 ) - .ucMDI_X = PHY_MDIX_CROSSED, - #else - .ucMDI_X = PHY_MDIX_DIRECT, - #endif -}; - -/*-----------------------------------------------------------*/ - -void HAL_ETH_RxCpltCallback( ETH_HandleTypeDef *heth ) -{ -BaseType_t xHigherPriorityTaskWoken = pdFALSE; - - /* Ethernet RX-Complete callback function, elsewhere declared as weak. */ - ulISREvents |= EMAC_IF_RX_EVENT; - /* Wakeup the prvEMACHandlerTask. */ - if( xEMACTaskHandle != NULL ) - { - vTaskNotifyGiveFromISR( xEMACTaskHandle, &xHigherPriorityTaskWoken ); - portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); - } -} -/*-----------------------------------------------------------*/ - -void HAL_ETH_TxCpltCallback( ETH_HandleTypeDef *heth ) -{ -BaseType_t xHigherPriorityTaskWoken = pdFALSE; - - /* This call-back is only useful in case packets are being sent - zero-copy. Once they're sent, the buffers will be released - by the function vClearTXBuffers(). */ - ulISREvents |= EMAC_IF_TX_EVENT; - /* Wakeup the prvEMACHandlerTask. */ - if( xEMACTaskHandle != NULL ) - { - vTaskNotifyGiveFromISR( xEMACTaskHandle, &xHigherPriorityTaskWoken ); - portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); - } - -} -/*-----------------------------------------------------------*/ - -static void vClearTXBuffers() -{ -__IO ETH_DMADescTypeDef *txLastDescriptor = xETH.TxDesc; -size_t uxCount = ( ( UBaseType_t ) ETH_TXBUFNB ) - uxSemaphoreGetCount( xTXDescriptorSemaphore ); -#if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - NetworkBufferDescriptor_t *pxNetworkBuffer; - uint8_t *ucPayLoad; -#endif - - /* This function is called after a TX-completion interrupt. - It will release each Network Buffer used in xNetworkInterfaceOutput(). - 'uxCount' represents the number of descriptors given to DMA for transmission. - After sending a packet, the DMA will clear the 'ETH_DMATXDESC_OWN' bit. */ - while( ( uxCount > 0 ) && ( ( DMATxDescToClear->Status & ETH_DMATXDESC_OWN ) == 0 ) ) - { - if( ( DMATxDescToClear == txLastDescriptor ) && ( uxCount != ETH_TXBUFNB ) ) - { - break; - } - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - ucPayLoad = ( uint8_t * )DMATxDescToClear->Buffer1Addr; - - if( ucPayLoad != NULL ) - { - pxNetworkBuffer = pxPacketBuffer_to_NetworkBuffer( ucPayLoad ); - if( pxNetworkBuffer != NULL ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ) ; - } - DMATxDescToClear->Buffer1Addr = ( uint32_t )0u; - } - } - #endif /* ipconfigZERO_COPY_TX_DRIVER */ - - DMATxDescToClear = ( ETH_DMADescTypeDef * )( DMATxDescToClear->Buffer2NextDescAddr ); - - uxCount--; - /* Tell the counting semaphore that one more TX descriptor is available. */ - xSemaphoreGive( xTXDescriptorSemaphore ); - } -} -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceInitialise( void ) -{ -HAL_StatusTypeDef hal_eth_init_status; -BaseType_t xResult; - - if( xEMACTaskHandle == NULL ) - { - if( xTXDescriptorSemaphore == NULL ) - { - xTXDescriptorSemaphore = xSemaphoreCreateCounting( ( UBaseType_t ) ETH_TXBUFNB, ( UBaseType_t ) ETH_TXBUFNB ); - configASSERT( xTXDescriptorSemaphore ); - } - - /* Initialise ETH */ - - xETH.Instance = ETH; - xETH.Init.AutoNegotiation = ETH_AUTONEGOTIATION_ENABLE; - xETH.Init.Speed = ETH_SPEED_100M; - xETH.Init.DuplexMode = ETH_MODE_FULLDUPLEX; - /* Value of PhyAddress doesn't matter, will be probed for. */ - xETH.Init.PhyAddress = 0; - - xETH.Init.MACAddr = ( uint8_t *) ucMACAddress; - xETH.Init.RxMode = ETH_RXINTERRUPT_MODE; - - /* using the ETH_CHECKSUM_BY_HARDWARE option: - both the IP and the protocol checksums will be calculated - by the peripheral. */ - xETH.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE; - - #if( ipconfigUSE_RMII != 0 ) - { - xETH.Init.MediaInterface = ETH_MEDIA_INTERFACE_RMII; - } - #else - { - xETH.Init.MediaInterface = ETH_MEDIA_INTERFACE_MII; - } - #endif /* ipconfigUSE_RMII */ - - hal_eth_init_status = HAL_ETH_Init( &xETH ); - - /* Only for inspection by debugger. */ - ( void ) hal_eth_init_status; - - /* Set the TxDesc and RxDesc pointers. */ - xETH.TxDesc = DMATxDscrTab; - xETH.RxDesc = DMARxDscrTab; - - /* Make sure that all unused fields are cleared. */ - memset( &DMATxDscrTab, '\0', sizeof( DMATxDscrTab ) ); - memset( &DMARxDscrTab, '\0', sizeof( DMARxDscrTab ) ); - - /* Initialize Tx Descriptors list: Chain Mode */ - DMATxDescToClear = DMATxDscrTab; - - /* Initialise TX-descriptors. */ - prvDMATxDescListInit(); - - /* Initialise RX-descriptors. */ - prvDMARxDescListInit(); - - #if( ipconfigUSE_LLMNR != 0 ) - { - /* Program the LLMNR address at index 1. */ - prvMACAddressConfig( &xETH, ETH_MAC_ADDRESS1, ( uint8_t *) xLLMNR_MACAddress ); - } - #endif - - /* Force a negotiation with the Switch or Router and wait for LS. */ - prvEthernetUpdateConfig( pdTRUE ); - - /* The deferred interrupt handler task is created at the highest - possible priority to ensure the interrupt handler can return directly - to it. The task's handle is stored in xEMACTaskHandle so interrupts can - notify the task when there is something to process. */ - xTaskCreate( prvEMACHandlerTask, "EMAC", configEMAC_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, &xEMACTaskHandle ); - } /* if( xEMACTaskHandle == NULL ) */ - - if( xPhyObject.ulLinkStatusMask != 0 ) - { - xETH.Instance->DMAIER |= ETH_DMA_ALL_INTS; - xResult = pdPASS; - FreeRTOS_printf( ( "Link Status is high\n" ) ) ; - } - else - { - /* For now pdFAIL will be returned. But prvEMACHandlerTask() is running - and it will keep on checking the PHY and set 'ulLinkStatusMask' when necessary. */ - xResult = pdFAIL; - FreeRTOS_printf( ( "Link Status still low\n" ) ) ; - } - /* When returning non-zero, the stack will become active and - start DHCP (in configured) */ - return xResult; -} -/*-----------------------------------------------------------*/ - -static void prvDMATxDescListInit() -{ -ETH_DMADescTypeDef *pxDMADescriptor; -BaseType_t xIndex; - - /* Get the pointer on the first member of the descriptor list */ - pxDMADescriptor = DMATxDscrTab; - - /* Fill each DMA descriptor with the right values */ - for( xIndex = 0; xIndex < ETH_TXBUFNB; xIndex++, pxDMADescriptor++ ) - { - /* Set Second Address Chained bit */ - pxDMADescriptor->Status = ETH_DMATXDESC_TCH; - - #if( ipconfigZERO_COPY_TX_DRIVER == 0 ) - { - /* Set Buffer1 address pointer */ - pxDMADescriptor->Buffer1Addr = ( uint32_t )( Tx_Buff[ xIndex ] ); - } - #endif - - if( xETH.Init.ChecksumMode == ETH_CHECKSUM_BY_HARDWARE ) - { - /* Set the DMA Tx descriptors checksum insertion for TCP, UDP, and ICMP */ - pxDMADescriptor->Status |= ETH_DMATXDESC_CHECKSUMTCPUDPICMPFULL; - } - - /* Initialize the next descriptor with the Next Descriptor Polling Enable */ - if( xIndex < ETH_TXBUFNB - 1 ) - { - /* Set next descriptor address register with next descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = ( uint32_t ) ( pxDMADescriptor + 1 ); - } - else - { - /* For last descriptor, set next descriptor address register equal to the first descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = ( uint32_t ) DMATxDscrTab; - } - } - - /* Set Transmit Descriptor List Address Register */ - xETH.Instance->DMATDLAR = ( uint32_t ) DMATxDscrTab; -} -/*-----------------------------------------------------------*/ - -static void prvDMARxDescListInit() -{ -ETH_DMADescTypeDef *pxDMADescriptor; -BaseType_t xIndex; - /* - * RX-descriptors. - */ - - /* Get the pointer on the first member of the descriptor list */ - pxDMADescriptor = DMARxDscrTab; - - /* Fill each DMA descriptor with the right values */ - for( xIndex = 0; xIndex < ETH_RXBUFNB; xIndex++, pxDMADescriptor++ ) - { - - /* Set Buffer1 size and Second Address Chained bit */ - pxDMADescriptor->ControlBufferSize = ETH_DMARXDESC_RCH | (uint32_t)ETH_RX_BUF_SIZE; - - #if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - /* Set Buffer1 address pointer */ - NetworkBufferDescriptor_t *pxBuffer; - - pxBuffer = pxGetNetworkBufferWithDescriptor( ETH_RX_BUF_SIZE, 100ul ); - /* If the assert below fails, make sure that there are at least 'ETH_RXBUFNB' - Network Buffers available during start-up ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ) */ - configASSERT( pxBuffer != NULL ); - if( pxBuffer != NULL ) - { - pxDMADescriptor->Buffer1Addr = (uint32_t)pxBuffer->pucEthernetBuffer; - pxDMADescriptor->Status = ETH_DMARXDESC_OWN; - } - } - #else - { - /* Set Buffer1 address pointer */ - pxDMADescriptor->Buffer1Addr = ( uint32_t )( Rx_Buff[ xIndex ] ); - /* Set Own bit of the Rx descriptor Status */ - pxDMADescriptor->Status = ETH_DMARXDESC_OWN; - } - #endif - - /* Initialize the next descriptor with the Next Descriptor Polling Enable */ - if( xIndex < ETH_RXBUFNB - 1 ) - { - /* Set next descriptor address register with next descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = ( uint32_t )( pxDMADescriptor + 1 ); - } - else - { - /* For last descriptor, set next descriptor address register equal to the first descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = ( uint32_t ) DMARxDscrTab; - } - - } - /* Set Receive Descriptor List Address Register */ - xETH.Instance->DMARDLAR = ( uint32_t ) DMARxDscrTab; -} -/*-----------------------------------------------------------*/ - -static void prvMACAddressConfig(ETH_HandleTypeDef *heth, uint32_t ulIndex, uint8_t *Addr) -{ -uint32_t ulTempReg; - - /* Calculate the selected MAC address high register. */ - ulTempReg = 0x80000000ul | ( ( uint32_t ) Addr[ 5 ] << 8 ) | ( uint32_t ) Addr[ 4 ]; - - /* Load the selected MAC address high register. */ - ( *(__IO uint32_t *)( ( uint32_t ) ( ETH_MAC_ADDR_HBASE + ulIndex ) ) ) = ulTempReg; - - /* Calculate the selected MAC address low register. */ - ulTempReg = ( ( uint32_t ) Addr[ 3 ] << 24 ) | ( ( uint32_t ) Addr[ 2 ] << 16 ) | ( ( uint32_t ) Addr[ 1 ] << 8 ) | Addr[ 0 ]; - - /* Load the selected MAC address low register */ - ( *(__IO uint32_t *) ( ( uint32_t ) ( ETH_MAC_ADDR_LBASE + ulIndex ) ) ) = ulTempReg; -} -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescriptor, BaseType_t bReleaseAfterSend ) -{ -BaseType_t xReturn = pdFAIL; -uint32_t ulTransmitSize = 0; -__IO ETH_DMADescTypeDef *pxDmaTxDesc; -/* Do not wait too long for a free TX DMA buffer. */ -const TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 50u ); - - #if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 ) - { - ProtocolPacket_t *pxPacket; - - #if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - configASSERT( bReleaseAfterSend != 0 ); - } - #endif /* ipconfigZERO_COPY_RX_DRIVER */ - - /* If the peripheral must calculate the checksum, it wants - the protocol checksum to have a value of zero. */ - pxPacket = ( ProtocolPacket_t * ) ( pxDescriptor->pucEthernetBuffer ); - - if( pxPacket->xICMPPacket.xIPHeader.ucProtocol == ipPROTOCOL_ICMP ) - { - pxPacket->xICMPPacket.xICMPHeader.usChecksum = ( uint16_t )0u; - } - } - #endif - - /* Open a do {} while ( 0 ) loop to be able to call break. */ - do - { - if( xPhyObject.ulLinkStatusMask != 0 ) - { - if( xSemaphoreTake( xTXDescriptorSemaphore, xBlockTimeTicks ) != pdPASS ) - { - /* Time-out waiting for a free TX descriptor. */ - break; - } - - /* This function does the actual transmission of the packet. The packet is - contained in 'pxDescriptor' that is passed to the function. */ - pxDmaTxDesc = xETH.TxDesc; - - /* Is this buffer available? */ - configASSERT ( ( pxDmaTxDesc->Status & ETH_DMATXDESC_OWN ) == 0 ); - - { - /* Is this buffer available? */ - /* Get bytes in current buffer. */ - ulTransmitSize = pxDescriptor->xDataLength; - - if( ulTransmitSize > ETH_TX_BUF_SIZE ) - { - ulTransmitSize = ETH_TX_BUF_SIZE; - } - - #if( ipconfigZERO_COPY_TX_DRIVER == 0 ) - { - /* Copy the bytes. */ - memcpy( ( void * ) pxDmaTxDesc->Buffer1Addr, pxDescriptor->pucEthernetBuffer, ulTransmitSize ); - } - #else - { - /* Move the buffer. */ - pxDmaTxDesc->Buffer1Addr = ( uint32_t )pxDescriptor->pucEthernetBuffer; - /* The Network Buffer has been passed to DMA, no need to release it. */ - bReleaseAfterSend = pdFALSE_UNSIGNED; - } - #endif /* ipconfigZERO_COPY_TX_DRIVER */ - - /* Ask to set the IPv4 checksum. - Also need an Interrupt on Completion so that 'vClearTXBuffers()' will be called.. */ - pxDmaTxDesc->Status |= ETH_DMATXDESC_CIC_TCPUDPICMP_FULL | ETH_DMATXDESC_IC; - - /* Prepare transmit descriptors to give to DMA. */ - - /* Set LAST and FIRST segment */ - pxDmaTxDesc->Status |= ETH_DMATXDESC_FS | ETH_DMATXDESC_LS; - /* Set frame size */ - pxDmaTxDesc->ControlBufferSize = ( ulTransmitSize & ETH_DMATXDESC_TBS1 ); - /* Set Own bit of the Tx descriptor Status: gives the buffer back to ETHERNET DMA */ - pxDmaTxDesc->Status |= ETH_DMATXDESC_OWN; - - /* Point to next descriptor */ - xETH.TxDesc = ( ETH_DMADescTypeDef * ) ( xETH.TxDesc->Buffer2NextDescAddr ); - /* Ensure completion of memory access */ - __DSB(); - /* Resume DMA transmission*/ - xETH.Instance->DMATPDR = 0; - iptraceNETWORK_INTERFACE_TRANSMIT(); - xReturn = pdPASS; - } - } - else - { - /* The PHY has no Link Status, packet shall be dropped. */ - } - } while( 0 ); - /* The buffer has been sent so can be released. */ - if( bReleaseAfterSend != pdFALSE ) - { - vReleaseNetworkBufferAndDescriptor( pxDescriptor ); - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -static BaseType_t xMayAcceptPacket( uint8_t *pcBuffer ) -{ -const ProtocolPacket_t *pxProtPacket = ( const ProtocolPacket_t * )pcBuffer; - - switch( pxProtPacket->xTCPPacket.xEthernetHeader.usFrameType ) - { - case ipARP_FRAME_TYPE: - /* Check it later. */ - return pdTRUE; - case ipIPv4_FRAME_TYPE: - /* Check it here. */ - break; - default: - /* Refuse the packet. */ - return pdFALSE; - } - - #if( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 ) - { - const IPHeader_t *pxIPHeader = &(pxProtPacket->xTCPPacket.xIPHeader); - uint32_t ulDestinationIPAddress; - - /* Ensure that the incoming packet is not fragmented (only outgoing packets - * can be fragmented) as these are the only handled IP frames currently. */ - if( ( pxIPHeader->usFragmentOffset & FreeRTOS_ntohs( ipFRAGMENT_OFFSET_BIT_MASK ) ) != 0U ) - { - return pdFALSE; - } - /* HT: Might want to make the following configurable because - * most IP messages have a standard length of 20 bytes */ - - /* 0x45 means: IPv4 with an IP header of 5 x 4 = 20 bytes - * 0x47 means: IPv4 with an IP header of 7 x 4 = 28 bytes */ - if( pxIPHeader->ucVersionHeaderLength < 0x45 || pxIPHeader->ucVersionHeaderLength > 0x4F ) - { - return pdFALSE; - } - - ulDestinationIPAddress = pxIPHeader->ulDestinationIPAddress; - /* Is the packet for this node? */ - if( ( ulDestinationIPAddress != *ipLOCAL_IP_ADDRESS_POINTER ) && - /* Is it a broadcast address x.x.x.255 ? */ - ( ( FreeRTOS_ntohl( ulDestinationIPAddress ) & 0xff ) != 0xff ) && - #if( ipconfigUSE_LLMNR == 1 ) - ( ulDestinationIPAddress != ipLLMNR_IP_ADDR ) && - #endif - ( *ipLOCAL_IP_ADDRESS_POINTER != 0 ) ) { - FreeRTOS_printf( ( "Drop IP %lxip\n", FreeRTOS_ntohl( ulDestinationIPAddress ) ) ); - return pdFALSE; - } - - if( pxIPHeader->ucProtocol == ipPROTOCOL_UDP ) - { - uint16_t port = pxProtPacket->xUDPPacket.xUDPHeader.usDestinationPort; - - if( ( xPortHasUDPSocket( port ) == pdFALSE ) - #if ipconfigUSE_LLMNR == 1 - && ( port != FreeRTOS_ntohs( ipLLMNR_PORT ) ) - #endif - #if ipconfigUSE_NBNS == 1 - && ( port != FreeRTOS_ntohs( ipNBNS_PORT ) ) - #endif - #if ipconfigUSE_DNS == 1 - && ( pxProtPacket->xUDPPacket.xUDPHeader.usSourcePort != FreeRTOS_ntohs( ipDNS_PORT ) ) - #endif - ) { - /* Drop this packet, not for this device. */ - return pdFALSE; - } - } - } - #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ - return pdTRUE; -} -/*-----------------------------------------------------------*/ - -static BaseType_t prvNetworkInterfaceInput( void ) -{ -NetworkBufferDescriptor_t *pxCurDescriptor; -NetworkBufferDescriptor_t *pxNewDescriptor = NULL; -BaseType_t xReceivedLength, xAccepted; -__IO ETH_DMADescTypeDef *pxDMARxDescriptor; -xIPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL }; -const TickType_t xDescriptorWaitTime = pdMS_TO_TICKS( 250 ); -uint8_t *pucBuffer; - - pxDMARxDescriptor = xETH.RxDesc; - - if( ( pxDMARxDescriptor->Status & ETH_DMARXDESC_OWN) == 0 ) - { - /* Get the Frame Length of the received packet: substruct 4 bytes of the CRC */ - xReceivedLength = ( ( pxDMARxDescriptor->Status & ETH_DMARXDESC_FL ) >> ETH_DMARXDESC_FRAMELENGTHSHIFT ) - 4; - - pucBuffer = (uint8_t *) pxDMARxDescriptor->Buffer1Addr; - - /* Update the ETHERNET DMA global Rx descriptor with next Rx descriptor */ - /* Chained Mode */ - /* Selects the next DMA Rx descriptor list for next buffer to read */ - xETH.RxDesc = ( ETH_DMADescTypeDef* )pxDMARxDescriptor->Buffer2NextDescAddr; - } - else - { - xReceivedLength = 0; - } - - /* Obtain the size of the packet and put it into the "usReceivedLength" variable. */ - /* In order to make the code easier and faster, only packets in a single buffer - will be accepted. This can be done by making the buffers large enough to - hold a complete Ethernet packet (1536 bytes). */ - if( xReceivedLength > 0ul && xReceivedLength < ETH_RX_BUF_SIZE ) - { - if( ( pxDMARxDescriptor->Status & ( ETH_DMARXDESC_CE | ETH_DMARXDESC_IPV4HCE | ETH_DMARXDESC_FT ) ) != ETH_DMARXDESC_FT ) - { - /* Not an Ethernet frame-type or a checmsum error. */ - xAccepted = pdFALSE; - } - else - { - /* See if this packet must be handled. */ - xAccepted = xMayAcceptPacket( pucBuffer ); - } - - if( xAccepted != pdFALSE ) - { - /* The packet wil be accepted, but check first if a new Network Buffer can - be obtained. If not, the packet will still be dropped. */ - pxNewDescriptor = pxGetNetworkBufferWithDescriptor( ETH_RX_BUF_SIZE, xDescriptorWaitTime ); - - if( pxNewDescriptor == NULL ) - { - /* A new descriptor can not be allocated now. This packet will be dropped. */ - xAccepted = pdFALSE; - } - } - #if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - /* Find out which Network Buffer was originally passed to the descriptor. */ - pxCurDescriptor = pxPacketBuffer_to_NetworkBuffer( pucBuffer ); - configASSERT( pxCurDescriptor != NULL ); - } - #else - { - /* In this mode, the two descriptors are the same. */ - pxCurDescriptor = pxNewDescriptor; - if( pxNewDescriptor != NULL ) - { - /* The packet is acepted and a new Network Buffer was created, - copy data to the Network Bufffer. */ - memcpy( pxNewDescriptor->pucEthernetBuffer, pucBuffer, xReceivedLength ); - } - } - #endif - - if( xAccepted != pdFALSE ) - { - pxCurDescriptor->xDataLength = xReceivedLength; - xRxEvent.pvData = ( void * ) pxCurDescriptor; - - /* Pass the data to the TCP/IP task for processing. */ - if( xSendEventStructToIPTask( &xRxEvent, xDescriptorWaitTime ) == pdFALSE ) - { - /* Could not send the descriptor into the TCP/IP stack, it - must be released. */ - vReleaseNetworkBufferAndDescriptor( pxCurDescriptor ); - iptraceETHERNET_RX_EVENT_LOST(); - } - else - { - iptraceNETWORK_INTERFACE_RECEIVE(); - } - } - - /* Release descriptors to DMA */ - #if( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - /* Set Buffer1 address pointer */ - if( pxNewDescriptor != NULL ) - { - pxDMARxDescriptor->Buffer1Addr = (uint32_t)pxNewDescriptor->pucEthernetBuffer; - } - else - { - /* The packet was dropped and the same Network - Buffer will be used to receive a new packet. */ - } - } - #endif /* ipconfigZERO_COPY_RX_DRIVER */ - - /* Set Buffer1 size and Second Address Chained bit */ - pxDMARxDescriptor->ControlBufferSize = ETH_DMARXDESC_RCH | (uint32_t)ETH_RX_BUF_SIZE; - pxDMARxDescriptor->Status = ETH_DMARXDESC_OWN; - - /* Ensure completion of memory access */ - __DSB(); - /* When Rx Buffer unavailable flag is set clear it and resume - reception. */ - if( ( xETH.Instance->DMASR & ETH_DMASR_RBUS ) != 0 ) - { - /* Clear RBUS ETHERNET DMA flag. */ - xETH.Instance->DMASR = ETH_DMASR_RBUS; - - /* Resume DMA reception. */ - xETH.Instance->DMARPDR = 0; - } - } - - return ( xReceivedLength > 0 ); -} -/*-----------------------------------------------------------*/ - - -BaseType_t xSTM32_PhyRead( BaseType_t xAddress, BaseType_t xRegister, uint32_t *pulValue ) -{ -uint16_t usPrevAddress = xETH.Init.PhyAddress; -BaseType_t xResult; -HAL_StatusTypeDef xHALResult; - - xETH.Init.PhyAddress = xAddress; - xHALResult = HAL_ETH_ReadPHYRegister( &xETH, ( uint16_t )xRegister, pulValue ); - xETH.Init.PhyAddress = usPrevAddress; - - if( xHALResult == HAL_OK ) - { - xResult = 0; - } - else - { - xResult = -1; - } - return xResult; -} -/*-----------------------------------------------------------*/ - -BaseType_t xSTM32_PhyWrite( BaseType_t xAddress, BaseType_t xRegister, uint32_t ulValue ) -{ -uint16_t usPrevAddress = xETH.Init.PhyAddress; -BaseType_t xResult; -HAL_StatusTypeDef xHALResult; - - xETH.Init.PhyAddress = xAddress; - xHALResult = HAL_ETH_WritePHYRegister( &xETH, ( uint16_t )xRegister, ulValue ); - xETH.Init.PhyAddress = usPrevAddress; - - if( xHALResult == HAL_OK ) - { - xResult = 0; - } - else - { - xResult = -1; - } - return xResult; -} -/*-----------------------------------------------------------*/ - -void phy_test() -{ -BaseType_t xPhyCount; -BaseType_t xPhyIndex; - - vPhyInitialise( &xPhyObject, xSTM32_PhyRead, xSTM32_PhyWrite ); - xPhyCount = xPhyDiscover( &xPhyObject ); - FreeRTOS_printf( ( "PHY count %ld\n", xPhyCount ) ); - for( xPhyIndex = 0; xPhyIndex < xPhyCount; xPhyIndex++ ) - { - FreeRTOS_printf( ( "PHY[%d] at address %d ( 0x%08X )\n", - xPhyIndex, - xPhyObject.ucPhyIndexes[ xPhyIndex ], - xPhyObject.ulPhyIDs[ xPhyIndex ] ) ); - - } - -} - -void vMACBProbePhy( void ) -{ - vPhyInitialise( &xPhyObject, xSTM32_PhyRead, xSTM32_PhyWrite ); - xPhyDiscover( &xPhyObject ); - xPhyConfigure( &xPhyObject, &xPHYProperties ); -} -/*-----------------------------------------------------------*/ - -static void prvEthernetUpdateConfig( BaseType_t xForce ) -{ - FreeRTOS_printf( ( "prvEthernetUpdateConfig: LS mask %02lX Force %d\n", - xPhyObject.ulLinkStatusMask, - ( int )xForce ) ); - - if( ( xForce != pdFALSE ) || ( xPhyObject.ulLinkStatusMask != 0 ) ) - { - /* Restart the auto-negotiation. */ - if( xETH.Init.AutoNegotiation != ETH_AUTONEGOTIATION_DISABLE ) - { - xPhyStartAutoNegotiation( &xPhyObject, xPhyGetMask( &xPhyObject ) ); - - /* Configure the MAC with the Duplex Mode fixed by the - auto-negotiation process. */ - if( xPhyObject.xPhyProperties.ucDuplex == PHY_DUPLEX_FULL ) - { - xETH.Init.DuplexMode = ETH_MODE_FULLDUPLEX; - } - else - { - xETH.Init.DuplexMode = ETH_MODE_HALFDUPLEX; - } - - /* Configure the MAC with the speed fixed by the - auto-negotiation process. */ - if( xPhyObject.xPhyProperties.ucSpeed == PHY_SPEED_10 ) - { - xETH.Init.Speed = ETH_SPEED_10M; - } - else - { - xETH.Init.Speed = ETH_SPEED_100M; - } - } - else /* AutoNegotiation Disable */ - { - /* Check parameters */ - assert_param( IS_ETH_SPEED( xETH.Init.Speed ) ); - assert_param( IS_ETH_DUPLEX_MODE( xETH.Init.DuplexMode ) ); - - if( xETH.Init.DuplexMode == ETH_MODE_FULLDUPLEX ) - { - xPhyObject.xPhyPreferences.ucDuplex = PHY_DUPLEX_HALF; - } - else - { - xPhyObject.xPhyPreferences.ucDuplex = PHY_DUPLEX_FULL; - } - - if( xETH.Init.Speed == ETH_SPEED_10M ) - { - xPhyObject.xPhyPreferences.ucSpeed = PHY_SPEED_10; - } - else - { - xPhyObject.xPhyPreferences.ucSpeed = PHY_SPEED_100; - } - - xPhyObject.xPhyPreferences.ucMDI_X = PHY_MDIX_AUTO; - - /* Use predefined (fixed) configuration. */ - xPhyFixedValue( &xPhyObject, xPhyGetMask( &xPhyObject ) ); - } - - /* ETHERNET MAC Re-Configuration */ - HAL_ETH_ConfigMAC( &xETH, (ETH_MACInitTypeDef *) NULL); - - /* Restart MAC interface */ - HAL_ETH_Start( &xETH); - } - else - { - /* Stop MAC interface */ - HAL_ETH_Stop( &xETH ); - } -} -/*-----------------------------------------------------------*/ - -BaseType_t xGetPhyLinkStatus( void ) -{ -BaseType_t xReturn; - - if( xPhyObject.ulLinkStatusMask != 0 ) - { - xReturn = pdPASS; - } - else - { - xReturn = pdFAIL; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -/* Uncomment this in case BufferAllocation_1.c is used. */ - -/* -#define niBUFFER_1_PACKET_SIZE 1536 - -static __attribute__ ((section(".first_data"))) uint8_t ucNetworkPackets[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS * niBUFFER_1_PACKET_SIZE ] __attribute__ ( ( aligned( 32 ) ) ); - -void vNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkBuffers[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ] ) -{ - -uint8_t *ucRAMBuffer = ucNetworkPackets; -uint32_t ul; - - for( ul = 0; ul < ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS; ul++ ) - { - pxNetworkBuffers[ ul ].pucEthernetBuffer = ucRAMBuffer + ipBUFFER_PADDING; - *( ( unsigned * ) ucRAMBuffer ) = ( unsigned ) ( &( pxNetworkBuffers[ ul ] ) ); - ucRAMBuffer += niBUFFER_1_PACKET_SIZE; - } -} -*/ -/*-----------------------------------------------------------*/ - -static void prvEMACHandlerTask( void *pvParameters ) -{ -UBaseType_t uxLastMinBufferCount = 0; -#if( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) -UBaseType_t uxLastMinQueueSpace = 0; -#endif -UBaseType_t uxCurrentCount; -BaseType_t xResult; -const TickType_t ulMaxBlockTime = pdMS_TO_TICKS( 100UL ); - - /* Remove compiler warnings about unused parameters. */ - ( void ) pvParameters; - - for( ;; ) - { - xResult = 0; - uxCurrentCount = uxGetMinimumFreeNetworkBuffers(); - if( uxLastMinBufferCount != uxCurrentCount ) - { - /* The logging produced below may be helpful - while tuning +TCP: see how many buffers are in use. */ - uxLastMinBufferCount = uxCurrentCount; - FreeRTOS_printf( ( "Network buffers: %lu lowest %lu\n", - uxGetNumberOfFreeNetworkBuffers(), uxCurrentCount ) ); - } - - if( xTXDescriptorSemaphore != NULL ) - { - static UBaseType_t uxLowestSemCount = ( UBaseType_t ) ETH_TXBUFNB - 1; - - uxCurrentCount = uxSemaphoreGetCount( xTXDescriptorSemaphore ); - if( uxLowestSemCount > uxCurrentCount ) - { - uxLowestSemCount = uxCurrentCount; - FreeRTOS_printf( ( "TX DMA buffers: lowest %lu\n", uxLowestSemCount ) ); - } - - } - - #if( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - { - uxCurrentCount = uxGetMinimumIPQueueSpace(); - if( uxLastMinQueueSpace != uxCurrentCount ) - { - /* The logging produced below may be helpful - while tuning +TCP: see how many buffers are in use. */ - uxLastMinQueueSpace = uxCurrentCount; - FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); - } - } - #endif /* ipconfigCHECK_IP_QUEUE_SPACE */ - - if( ( ulISREvents & EMAC_IF_ALL_EVENT ) == 0 ) - { - /* No events to process now, wait for the next. */ - ulTaskNotifyTake( pdFALSE, ulMaxBlockTime ); - } - - if( ( ulISREvents & EMAC_IF_RX_EVENT ) != 0 ) - { - ulISREvents &= ~EMAC_IF_RX_EVENT; - - xResult = prvNetworkInterfaceInput(); - if( xResult > 0 ) - { - while( prvNetworkInterfaceInput() > 0 ) - { - } - } - } - - if( ( ulISREvents & EMAC_IF_TX_EVENT ) != 0 ) - { - /* Code to release TX buffers if zero-copy is used. */ - ulISREvents &= ~EMAC_IF_TX_EVENT; - /* Check if DMA packets have been delivered. */ - vClearTXBuffers(); - } - - if( ( ulISREvents & EMAC_IF_ERR_EVENT ) != 0 ) - { - /* Future extension: logging about errors that occurred. */ - ulISREvents &= ~EMAC_IF_ERR_EVENT; - } - if( xPhyCheckLinkStatus( &xPhyObject, xResult ) != 0 ) - { - /* Something has changed to a Link Status, need re-check. */ - prvEthernetUpdateConfig( pdFALSE ); - } - } -} -/*-----------------------------------------------------------*/ - -void ETH_IRQHandler( void ) -{ - HAL_ETH_IRQHandler( &xETH ); -} - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32Fxx/stm32f4xx_hal_eth.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32Fxx/stm32f4xx_hal_eth.c deleted file mode 100755 index 3e20acb..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32Fxx/stm32f4xx_hal_eth.c +++ /dev/null @@ -1,1833 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_hal_eth.c - * @author MCD Application Team - * @version V1.3.2 - * @date 26-June-2015 - * @brief ETH HAL module driver. - * This file provides firmware functions to manage the following - * functionalities of the Ethernet (ETH) peripheral: - * + Initialization and de-initialization functions - * + IO operation functions - * + Peripheral Control functions - * + Peripheral State and Errors functions - * - @verbatim - ============================================================================== - ##### How to use this driver ##### - ============================================================================== - [..] - (#)Declare a ETH_HandleTypeDef handle structure, for example: - ETH_HandleTypeDef heth; - - (#)Fill parameters of Init structure in heth handle - - (#)Call HAL_ETH_Init() API to initialize the Ethernet peripheral (MAC, DMA, ...) - - (#)Initialize the ETH low level resources through the HAL_ETH_MspInit() API: - (##) Enable the Ethernet interface clock using - (+++) __HAL_RCC_ETHMAC_CLK_ENABLE(); - (+++) __HAL_RCC_ETHMACTX_CLK_ENABLE(); - (+++) __HAL_RCC_ETHMACRX_CLK_ENABLE(); - - (##) Initialize the related GPIO clocks - (##) Configure Ethernet pin-out - (##) Configure Ethernet NVIC interrupt (IT mode) - - (#)Initialize Ethernet DMA Descriptors in chain mode and point to allocated buffers: - (##) HAL_ETH_DMATxDescListInit(); for Transmission process - (##) HAL_ETH_DMARxDescListInit(); for Reception process - - (#)Enable MAC and DMA transmission and reception: - (##) HAL_ETH_Start(); - - (#)Prepare ETH DMA TX Descriptors and give the hand to ETH DMA to transfer - the frame to MAC TX FIFO: - (##) HAL_ETH_TransmitFrame(); - - (#)Poll for a received frame in ETH RX DMA Descriptors and get received - frame parameters - (##) HAL_ETH_GetReceivedFrame(); (should be called into an infinite loop) - - (#) Get a received frame when an ETH RX interrupt occurs: - (##) HAL_ETH_GetReceivedFrame_IT(); (called in IT mode only) - - (#) Communicate with external PHY device: - (##) Read a specific register from the PHY - HAL_ETH_ReadPHYRegister(); - (##) Write data to a specific RHY register: - HAL_ETH_WritePHYRegister(); - - (#) Configure the Ethernet MAC after ETH peripheral initialization - HAL_ETH_ConfigMAC(); all MAC parameters should be filled. - - (#) Configure the Ethernet DMA after ETH peripheral initialization - HAL_ETH_ConfigDMA(); all DMA parameters should be filled. - - -@- The PTP protocol and the DMA descriptors ring mode are not supported - in this driver - - @endverbatim - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -int lUDPLoggingPrintf( const char *pcFormatString, ... ); - -/** @addtogroup STM32F4xx_HAL_Driver - * @{ - */ - -/** @defgroup ETH ETH - * @brief ETH HAL module driver - * @{ - */ - -#if !defined( ARRAY_SIZE ) - #define ARRAY_SIZE( x ) ( sizeof ( x ) / sizeof ( x )[ 0 ] ) -#endif - -#ifdef HAL_ETH_MODULE_ENABLED - -#if defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/** @defgroup ETH_Private_Constants ETH Private Constants - * @{ - */ -#define LINKED_STATE_TIMEOUT_VALUE ((uint32_t)2000) /* 2000 ms */ -#define AUTONEGO_COMPLETED_TIMEOUT_VALUE ((uint32_t)1000) /* 1000 ms */ - -/** - * @} - */ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ -/** @defgroup ETH_Private_Functions ETH Private Functions - * @{ - */ -static void ETH_MACDMAConfig(ETH_HandleTypeDef *heth, uint32_t err); -static void ETH_MACAddressConfig(ETH_HandleTypeDef *heth, uint32_t MacAddr, uint8_t *Addr); -static void ETH_MACReceptionEnable(ETH_HandleTypeDef *heth); -static void ETH_MACReceptionDisable(ETH_HandleTypeDef *heth); -static void ETH_MACTransmissionEnable(ETH_HandleTypeDef *heth); -static void ETH_MACTransmissionDisable(ETH_HandleTypeDef *heth); -static void ETH_DMATransmissionEnable(ETH_HandleTypeDef *heth); -static void ETH_DMATransmissionDisable(ETH_HandleTypeDef *heth); -static void ETH_DMAReceptionEnable(ETH_HandleTypeDef *heth); -static void ETH_DMAReceptionDisable(ETH_HandleTypeDef *heth); -static void ETH_FlushTransmitFIFO(ETH_HandleTypeDef *heth); - -/** - * @} - */ -/* Private functions ---------------------------------------------------------*/ - -/** @defgroup ETH_Exported_Functions ETH Exported Functions - * @{ - */ - -/** @defgroup ETH_Exported_Functions_Group1 Initialization and de-initialization functions - * @brief Initialization and Configuration functions - * - @verbatim - =============================================================================== - ##### Initialization and de-initialization functions ##### - =============================================================================== - [..] This section provides functions allowing to: - (+) Initialize and configure the Ethernet peripheral - (+) De-initialize the Ethernet peripheral - - @endverbatim - * @{ - */ -extern void vMACBProbePhy ( void ); - -/** - * @brief Initializes the Ethernet MAC and DMA according to default - * parameters. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth) -{ - uint32_t tmpreg = 0; - uint32_t hclk = 60000000; - uint32_t err = ETH_SUCCESS; - - /* Check the ETH peripheral state */ - if( heth == NULL ) - { - return HAL_ERROR; - } - - /* Check parameters */ - assert_param(IS_ETH_AUTONEGOTIATION(heth->Init.AutoNegotiation)); - assert_param(IS_ETH_RX_MODE(heth->Init.RxMode)); - assert_param(IS_ETH_CHECKSUM_MODE(heth->Init.ChecksumMode)); - assert_param(IS_ETH_MEDIA_INTERFACE(heth->Init.MediaInterface)); - - if( heth->State == HAL_ETH_STATE_RESET ) - { - /* Init the low level hardware : GPIO, CLOCK, NVIC. */ - HAL_ETH_MspInit( heth ); - } - - /* Enable SYSCFG Clock */ - __HAL_RCC_SYSCFG_CLK_ENABLE(); - - /* Select MII or RMII Mode*/ - SYSCFG->PMC &= ~(SYSCFG_PMC_MII_RMII_SEL); - SYSCFG->PMC |= (uint32_t)heth->Init.MediaInterface; - - /* Ethernet Software reset */ - /* Set the SWR bit: resets all MAC subsystem internal registers and logic */ - /* After reset all the registers holds their respective reset values */ - /* Also enable EDFE: Enhanced descriptor format enable. */ - heth->Instance->DMABMR |= ETH_DMABMR_SR | ETH_DMABMR_EDE; - - /* Wait for software reset */ - while ((heth->Instance->DMABMR & ETH_DMABMR_SR) != (uint32_t)RESET) - { - } - - /*-------------------------------- MAC Initialization ----------------------*/ - /* Get the ETHERNET MACMIIAR value */ - tmpreg = heth->Instance->MACMIIAR; - /* Clear CSR Clock Range CR[2:0] bits */ - tmpreg &= ETH_MACMIIAR_CR_MASK; - - /* Get hclk frequency value (168,000,000) */ - hclk = HAL_RCC_GetHCLKFreq(); - - /* Set CR bits depending on hclk value */ - if( ( hclk >= 20000000 ) && ( hclk < 35000000 ) ) - { - /* CSR Clock Range between 20-35 MHz */ - tmpreg |= (uint32_t) ETH_MACMIIAR_CR_Div16; - } - else if( ( hclk >= 35000000 ) && ( hclk < 60000000 ) ) - { - /* CSR Clock Range between 35-60 MHz */ - tmpreg |= ( uint32_t ) ETH_MACMIIAR_CR_Div26; - } - else if((hclk >= 60000000 ) && ( hclk < 100000000 ) ) - { - /* CSR Clock Range between 60-100 MHz */ - tmpreg |= (uint32_t)ETH_MACMIIAR_CR_Div42; - } - else if((hclk >= 100000000 ) && ( hclk < 150000000)) - { - /* CSR Clock Range between 100-150 MHz */ - tmpreg |= (uint32_t)ETH_MACMIIAR_CR_Div62; - } - else /* ((hclk >= 150000000 ) && ( hclk <= 168000000)) */ - { - /* CSR Clock Range between 150-168 MHz */ - tmpreg |= (uint32_t)ETH_MACMIIAR_CR_Div102; - } - - /* Write to ETHERNET MAC MIIAR: Configure the ETHERNET CSR Clock Range */ - heth->Instance->MACMIIAR = (uint32_t)tmpreg; - - /* Initialise the MACB and set all PHY properties */ - vMACBProbePhy(); - - /* Config MAC and DMA */ - ETH_MACDMAConfig(heth, err); - - /* Set ETH HAL State to Ready */ - heth->State= HAL_ETH_STATE_READY; - - /* Return function status */ - return HAL_OK; -} - -/** - * @brief De-Initializes the ETH peripheral. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_DeInit(ETH_HandleTypeDef *heth) -{ - /* Set the ETH peripheral state to BUSY */ - heth->State = HAL_ETH_STATE_BUSY; - - /* De-Init the low level hardware : GPIO, CLOCK, NVIC. */ - HAL_ETH_MspDeInit( heth ); - - /* Set ETH HAL state to Disabled */ - heth->State= HAL_ETH_STATE_RESET; - - /* Release Lock */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -/** - * @brief Initializes the DMA Tx descriptors in chain mode. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param DMATxDescTab: Pointer to the first Tx desc list - * @param TxBuff: Pointer to the first TxBuffer list - * @param TxBuffCount: Number of the used Tx desc in the list - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_DMATxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADescTypeDef *pxDMATable, uint8_t *ucDataBuffer, uint32_t ulBufferCount) -{ - uint32_t i = 0; - ETH_DMADescTypeDef *pxDMADescriptor; - - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Set the ETH peripheral state to BUSY */ - heth->State = HAL_ETH_STATE_BUSY; - - /* Set the TxDesc pointer with the first one of the pxDMATable list */ - heth->TxDesc = pxDMATable; - - /* Fill each DMA descriptor with the right values */ - for( i=0; i < ulBufferCount; i++ ) - { - /* Get the pointer on the ith member of the descriptor list */ - pxDMADescriptor = pxDMATable + i; - - /* Set Second Address Chained bit */ - pxDMADescriptor->Status = ETH_DMATXDESC_TCH; - - pxDMADescriptor->ControlBufferSize = 0; - - /* Set Buffer1 address pointer */ - if( ucDataBuffer != NULL ) - { - pxDMADescriptor->Buffer1Addr = ( uint32_t )( &ucDataBuffer[ i * ETH_TX_BUF_SIZE ] ); - } - else - { - /* Buffer space is not provided because it uses zero-copy transmissions. */ - pxDMADescriptor->Buffer1Addr = ( uint32_t )0u; - } - - if (heth->Init.ChecksumMode == ETH_CHECKSUM_BY_HARDWARE) - { - /* Set the DMA Tx descriptors checksum insertion for TCP, UDP, and ICMP */ - pxDMADescriptor->Status |= ETH_DMATXDESC_CHECKSUMTCPUDPICMPFULL; - } - - /* Initialize the next descriptor with the Next Descriptor Polling Enable */ - if(i < ( ulBufferCount - 1 ) ) - { - /* Set next descriptor address register with next descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = ( uint32_t ) ( pxDMATable + i + 1 ); - } - else - { - /* For last descriptor, set next descriptor address register equal to the first descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = ( uint32_t ) pxDMATable; - } - } - - /* Set Transmit Descriptor List Address Register */ - heth->Instance->DMATDLAR = ( uint32_t ) pxDMATable; - - /* Set ETH HAL State to Ready */ - heth->State= HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -/** - * @brief Initializes the DMA Rx descriptors in chain mode. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param DMARxDescTab: Pointer to the first Rx desc list - * @param RxBuff: Pointer to the first RxBuffer list - * @param RxBuffCount: Number of the used Rx desc in the list - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_DMARxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADescTypeDef *pxDMATable, uint8_t *ucDataBuffer, uint32_t ulBufferCount) -{ - uint32_t i = 0; - ETH_DMADescTypeDef *pxDMADescriptor; - - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Set the ETH peripheral state to BUSY */ - heth->State = HAL_ETH_STATE_BUSY; - - /* Set the RxDesc pointer with the first one of the pxDMATable list */ - heth->RxDesc = pxDMATable; - - /* Fill each DMA descriptor with the right values */ - for(i=0; i < ulBufferCount; i++) - { - /* Get the pointer on the ith member of the descriptor list */ - pxDMADescriptor = pxDMATable+i; - - /* Set Own bit of the Rx descriptor Status */ - pxDMADescriptor->Status = ETH_DMARXDESC_OWN; - - /* Set Buffer1 size and Second Address Chained bit */ - pxDMADescriptor->ControlBufferSize = ETH_DMARXDESC_RCH | ETH_RX_BUF_SIZE; - - /* Set Buffer1 address pointer */ - if( ucDataBuffer != NULL ) - { - pxDMADescriptor->Buffer1Addr = ( uint32_t )( &ucDataBuffer[ i * ETH_RX_BUF_SIZE ] ); - } - else - { - /* Buffer space is not provided because it uses zero-copy reception. */ - pxDMADescriptor->Buffer1Addr = ( uint32_t )0u; - } - - if( heth->Init.RxMode == ETH_RXINTERRUPT_MODE ) - { - /* Enable Ethernet DMA Rx Descriptor interrupt */ - pxDMADescriptor->ControlBufferSize &= ~ETH_DMARXDESC_DIC; - } - - /* Initialize the next descriptor with the Next Descriptor Polling Enable */ - if(i < (ulBufferCount-1)) - { - /* Set next descriptor address register with next descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = (uint32_t)(pxDMATable+i+1); - } - else - { - /* For last descriptor, set next descriptor address register equal to the first descriptor base address */ - pxDMADescriptor->Buffer2NextDescAddr = ( uint32_t ) pxDMATable; - } - } - - /* Set Receive Descriptor List Address Register */ - heth->Instance->DMARDLAR = ( uint32_t ) pxDMATable; - - /* Set ETH HAL State to Ready */ - heth->State= HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -/** - * @brief Initializes the ETH MSP. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -__weak void HAL_ETH_MspInit(ETH_HandleTypeDef *heth) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_ETH_MspInit could be implemented in the user file - */ -} - -/** - * @brief DeInitializes ETH MSP. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -__weak void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_ETH_MspDeInit could be implemented in the user file - */ -} - -/** - * @} - */ - -/** @defgroup ETH_Exported_Functions_Group2 IO operation functions - * @brief Data transfers functions - * - @verbatim - ============================================================================== - ##### IO operation functions ##### - ============================================================================== - [..] This section provides functions allowing to: - (+) Transmit a frame - HAL_ETH_TransmitFrame(); - (+) Receive a frame - HAL_ETH_GetReceivedFrame(); - HAL_ETH_GetReceivedFrame_IT(); - (+) Read from an External PHY register - HAL_ETH_ReadPHYRegister(); - (+) Write to an External PHY register - HAL_ETH_WritePHYRegister(); - - @endverbatim - - * @{ - */ - -/** - * @brief Sends an Ethernet frame. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param FrameLength: Amount of data to be sent - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_TransmitFrame(ETH_HandleTypeDef *heth, uint32_t FrameLength) -{ - uint32_t bufcount = 0, size = 0, i = 0; - __IO ETH_DMADescTypeDef *pxDmaTxDesc = heth->TxDesc; - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Set the ETH peripheral state to BUSY */ - heth->State = HAL_ETH_STATE_BUSY; - - if( FrameLength == 0 ) - { - /* Set ETH HAL state to READY */ - heth->State = HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - return HAL_ERROR; - } - - /* Check if the descriptor is owned by the ETHERNET DMA (when set) or CPU (when reset) */ - if( ( pxDmaTxDesc->Status & ETH_DMATXDESC_OWN ) != ( uint32_t ) RESET ) - { - /* OWN bit set */ - heth->State = HAL_ETH_STATE_BUSY_TX; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - return HAL_ERROR; - } - - /* Get the number of needed Tx buffers for the current frame, rounding up. */ - bufcount = ( FrameLength + ETH_TX_BUF_SIZE - 1 ) / ETH_TX_BUF_SIZE; - - if (bufcount == 1) - { - /* Set LAST and FIRST segment */ - pxDmaTxDesc->Status |= ETH_DMATXDESC_FS | ETH_DMATXDESC_LS; - /* Set frame size */ - pxDmaTxDesc->ControlBufferSize = ( FrameLength & ETH_DMATXDESC_TBS1 ); - /* Set Own bit of the Tx descriptor Status: gives the buffer back to ETHERNET DMA */ - pxDmaTxDesc->Status |= ETH_DMATXDESC_OWN; - /* Point to next descriptor */ - heth->TxDesc = ( ETH_DMADescTypeDef * ) ( heth->TxDesc->Buffer2NextDescAddr ); - } - else - { - for( i = 0; i < bufcount; i++ ) - { - /* Clear FIRST and LAST segment bits */ - uint32_t ulStatus = heth->TxDesc->Status & ~( ETH_DMATXDESC_FS | ETH_DMATXDESC_LS ); - - if( i == 0 ) - { - /* Setting the first segment bit */ - heth->TxDesc->Status = ulStatus | ETH_DMATXDESC_FS; - } - - /* Program size */ - if (i < (bufcount-1)) - { - heth->TxDesc->ControlBufferSize = (ETH_TX_BUF_SIZE & ETH_DMATXDESC_TBS1); - } - else - { - /* Setting the last segment bit */ - heth->TxDesc->Status = ulStatus | ETH_DMATXDESC_LS; - size = FrameLength - (bufcount-1)*ETH_TX_BUF_SIZE; - heth->TxDesc->ControlBufferSize = (size & ETH_DMATXDESC_TBS1); - } - - /* Set Own bit of the Tx descriptor Status: gives the buffer back to ETHERNET DMA */ - heth->TxDesc->Status |= ETH_DMATXDESC_OWN; - /* point to next descriptor */ - heth->TxDesc = (ETH_DMADescTypeDef *)( heth->TxDesc->Buffer2NextDescAddr ); - } - } - - __DSB(); - - /* When Tx Buffer unavailable flag is set: clear it and resume transmission */ - if( ( heth->Instance->DMASR & ETH_DMASR_TBUS ) != ( uint32_t )RESET ) - { - heth->Instance->DMACHTDR = ( uint32_t )pxDmaTxDesc; - - /* Clear TBUS ETHERNET DMA flag */ - heth->Instance->DMASR = ETH_DMASR_TBUS; - /* Resume DMA transmission*/ - heth->Instance->DMATPDR = 0; - } - - /* Set ETH HAL State to Ready */ - heth->State = HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -/** - * @brief Checks for received frames. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_GetReceivedFrame_IT( ETH_HandleTypeDef *heth ) -{ - return HAL_ETH_GetReceivedFrame( heth ); -} - -HAL_StatusTypeDef HAL_ETH_GetReceivedFrame( ETH_HandleTypeDef *heth ) -{ -uint32_t ulCounter = 0; -ETH_DMADescTypeDef *pxDescriptor = heth->RxDesc; -HAL_StatusTypeDef xResult = HAL_ERROR; - - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Check the ETH state to BUSY */ - heth->State = HAL_ETH_STATE_BUSY; - - /* Scan descriptors owned by CPU */ - while( ( ( pxDescriptor->Status & ETH_DMARXDESC_OWN ) == 0ul ) && ( ulCounter < ETH_RXBUFNB ) ) - { - uint32_t ulStatus = pxDescriptor->Status; - - /* Just for security. */ - ulCounter++; - - if( ( ulStatus & ( ETH_DMARXDESC_FS | ETH_DMARXDESC_LS ) ) == ( uint32_t )ETH_DMARXDESC_FS ) - { - /* First segment in frame, but not the last. */ - heth->RxFrameInfos.FSRxDesc = pxDescriptor; - heth->RxFrameInfos.LSRxDesc = ( ETH_DMADescTypeDef *)NULL; - heth->RxFrameInfos.SegCount = 1; - /* Point to next descriptor. */ - pxDescriptor = (ETH_DMADescTypeDef*) (pxDescriptor->Buffer2NextDescAddr); - heth->RxDesc = pxDescriptor; - } - else if( ( ulStatus & ( ETH_DMARXDESC_LS | ETH_DMARXDESC_FS ) ) == 0ul ) - { - /* This is an intermediate segment, not first, not last. */ - /* Increment segment count. */ - heth->RxFrameInfos.SegCount++; - /* Move to the next descriptor. */ - pxDescriptor = ( ETH_DMADescTypeDef * ) ( pxDescriptor->Buffer2NextDescAddr ); - heth->RxDesc = pxDescriptor; - } - /* Must be a last segment */ - else - { - /* This is the last segment. */ - /* Check if last segment is first segment: one segment contains the frame */ - if( heth->RxFrameInfos.SegCount == 0 ) - { - /* Remember the first segment. */ - heth->RxFrameInfos.FSRxDesc = pxDescriptor; - } - - /* Increment segment count */ - heth->RxFrameInfos.SegCount++; - - /* Remember the last segment. */ - heth->RxFrameInfos.LSRxDesc = pxDescriptor; - - /* Get the Frame Length of the received packet: substruct 4 bytes of the CRC */ - heth->RxFrameInfos.length = - ( ( ulStatus & ETH_DMARXDESC_FL ) >> ETH_DMARXDESC_FRAMELENGTHSHIFT ) - 4; - - /* Get the address of the buffer start address */ - heth->RxFrameInfos.buffer = heth->RxFrameInfos.FSRxDesc->Buffer1Addr; - - /* Point to next descriptor */ - heth->RxDesc = ( ETH_DMADescTypeDef * ) pxDescriptor->Buffer2NextDescAddr; - - /* Return OK status: a packet was received. */ - xResult = HAL_OK; - break; - } - } - - /* Set ETH HAL State to Ready */ - heth->State = HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return xResult; -} - -#if( STM32_ETHERNET_STATS != 0 ) - - volatile int rx_count, tx_count, int_count; - /** - * @brief This function handles ETH interrupt request. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval HAL status - */ - volatile int int_counts[32]; - volatile int tx_status[8]; - volatile unsigned sr_history[32]; - volatile int sr_head; - #define STM32_STAT_INC( x ) do { ( x )++; } while( 0 ) - -#else - #define STM32_STAT_INC( x ) do { } while( 0 ) -#endif /* STM32_ETHERNET_STATS */ - -#define ETH_DMA_ALL_INTS \ - ( ETH_DMA_IT_TST | ETH_DMA_IT_PMT | ETH_DMA_IT_MMC | ETH_DMA_IT_NIS | ETH_DMA_IT_AIS | ETH_DMA_IT_ER | \ - ETH_DMA_IT_FBE | ETH_DMA_IT_ET | ETH_DMA_IT_RWT | ETH_DMA_IT_RPS | ETH_DMA_IT_RBU | ETH_DMA_IT_R | \ - ETH_DMA_IT_TU | ETH_DMA_IT_RO | ETH_DMA_IT_TJT | ETH_DMA_IT_TPS | ETH_DMA_IT_T ) - -//#define ETH_DMA_ALL_INTS ETH_DMA_IT_RBU | ETH_DMA_FLAG_T | ETH_DMA_FLAG_AIS - -#define INT_MASK ( ( uint32_t ) ~ ( ETH_DMA_IT_TBU ) ) -void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth) -{ - uint32_t dmasr; - - STM32_STAT_INC( int_count ); - - dmasr = heth->Instance->DMASR & ETH_DMA_ALL_INTS; - heth->Instance->DMASR = dmasr; - -#if( STM32_ETHERNET_STATS != 0 ) - if( sr_head < ARRAY_SIZE( sr_history ) ) - { - sr_history[ sr_head++ ] = dmasr; - } - - { - int i; - for (i = 0; i < 32; i++) { - if (dmasr & (1u << i)) { - int_counts[i]++; - } - } - tx_status[ ( dmasr >> 20 ) & 0x07 ]++; - } -#endif - - /* Frame received */ - if( ( dmasr & ( ETH_DMA_FLAG_R | ETH_DMA_IT_RBU ) ) != 0 ) - { - /* Receive complete callback */ - HAL_ETH_RxCpltCallback( heth ); - STM32_STAT_INC( rx_count ); - } - /* Frame transmitted */ - if( ( dmasr & ( ETH_DMA_FLAG_T ) ) != 0 ) - { - /* Transfer complete callback */ - HAL_ETH_TxCpltCallback( heth ); - STM32_STAT_INC( tx_count ); - } - - /* ETH DMA Error */ - if( ( dmasr & ( ETH_DMA_FLAG_AIS ) ) != 0 ) - { - /* Ethernet Error callback */ - HAL_ETH_ErrorCallback( heth ); - } -} - -/** - * @brief Tx Transfer completed callbacks. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -__weak void HAL_ETH_TxCpltCallback(ETH_HandleTypeDef *heth) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_ETH_TxCpltCallback could be implemented in the user file - */ -} - -/** - * @brief Rx Transfer completed callbacks. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -__weak void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_ETH_TxCpltCallback could be implemented in the user file - */ -} - -/** - * @brief Ethernet transfer error callbacks - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -__weak void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_ETH_TxCpltCallback could be implemented in the user file - */ -} - -/** - * @brief Reads a PHY register - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param PHYReg: PHY register address, is the index of one of the 32 PHY register. - * This parameter can be one of the following values: - * PHY_BCR: Transceiver Basic Control Register, - * PHY_BSR: Transceiver Basic Status Register. - * More PHY register could be read depending on the used PHY - * @param RegValue: PHY register value - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_ReadPHYRegister(ETH_HandleTypeDef *heth, uint16_t PHYReg, uint32_t *RegValue) -{ -uint32_t tmpreg = 0; -uint32_t tickstart = 0; -HAL_StatusTypeDef xResult; - - /* Check parameters */ - assert_param(IS_ETH_PHY_ADDRESS(heth->Init.PhyAddress)); - - /* Check the ETH peripheral state */ - if( heth->State == HAL_ETH_STATE_BUSY_RD ) - { - xResult = HAL_BUSY; - } - else - { - __HAL_LOCK( heth ); - - /* Set ETH HAL State to BUSY_RD */ - heth->State = HAL_ETH_STATE_BUSY_RD; - - /* Get the ETHERNET MACMIIAR value */ - tmpreg = heth->Instance->MACMIIAR; - - /* Keep only the CSR Clock Range CR[2:0] bits value */ - tmpreg &= ~ETH_MACMIIAR_CR_MASK; - - /* Prepare the MII address register value */ - tmpreg |= ( ( ( uint32_t )heth->Init.PhyAddress << 11) & ETH_MACMIIAR_PA ); /* Set the PHY device address */ - tmpreg |= ( ( ( uint32_t )PHYReg << 6 ) & ETH_MACMIIAR_MR ); /* Set the PHY register address */ - tmpreg &= ~ETH_MACMIIAR_MW; /* Set the read mode */ - tmpreg |= ETH_MACMIIAR_MB; /* Set the MII Busy bit */ - - /* Write the result value into the MII Address register */ - heth->Instance->MACMIIAR = tmpreg; - - /* Get tick */ - tickstart = HAL_GetTick(); - - /* Check for the Busy flag */ - while( 1 ) - { - tmpreg = heth->Instance->MACMIIAR; - - if( ( tmpreg & ETH_MACMIIAR_MB ) == 0ul ) - { - /* Get MACMIIDR value */ - *RegValue = ( uint32_t ) heth->Instance->MACMIIDR; - xResult = HAL_OK; - break; - } - /* Check for the Timeout */ - if( ( HAL_GetTick( ) - tickstart ) > PHY_READ_TO ) - { - xResult = HAL_TIMEOUT; - break; - } - - } - - /* Set ETH HAL State to READY */ - heth->State = HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - } - - if( xResult != HAL_OK ) - { - lUDPLoggingPrintf( "ReadPHY: %d\n", xResult ); - } - /* Return function status */ - return xResult; -} - -/** - * @brief Writes to a PHY register. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param PHYReg: PHY register address, is the index of one of the 32 PHY register. - * This parameter can be one of the following values: - * PHY_BCR: Transceiver Control Register. - * More PHY register could be written depending on the used PHY - * @param RegValue: the value to write - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_WritePHYRegister(ETH_HandleTypeDef *heth, uint16_t PHYReg, uint32_t RegValue) -{ -uint32_t tmpreg = 0; -uint32_t tickstart = 0; -HAL_StatusTypeDef xResult; - - /* Check parameters */ - assert_param( IS_ETH_PHY_ADDRESS( heth->Init.PhyAddress ) ); - - /* Check the ETH peripheral state */ - if( heth->State == HAL_ETH_STATE_BUSY_WR ) - { - xResult = HAL_BUSY; - } - else - { - __HAL_LOCK( heth ); - - /* Set ETH HAL State to BUSY_WR */ - heth->State = HAL_ETH_STATE_BUSY_WR; - - /* Get the ETHERNET MACMIIAR value */ - tmpreg = heth->Instance->MACMIIAR; - - /* Keep only the CSR Clock Range CR[2:0] bits value */ - tmpreg &= ~ETH_MACMIIAR_CR_MASK; - - /* Prepare the MII register address value */ - tmpreg |= ( ( ( uint32_t ) heth->Init.PhyAddress << 11 ) & ETH_MACMIIAR_PA ); /* Set the PHY device address */ - tmpreg |= ( ( ( uint32_t ) PHYReg << 6 ) & ETH_MACMIIAR_MR ); /* Set the PHY register address */ - tmpreg |= ETH_MACMIIAR_MW; /* Set the write mode */ - tmpreg |= ETH_MACMIIAR_MB; /* Set the MII Busy bit */ - - /* Give the value to the MII data register */ - heth->Instance->MACMIIDR = ( uint16_t ) RegValue; - - /* Write the result value into the MII Address register */ - heth->Instance->MACMIIAR = tmpreg; - - /* Get tick */ - tickstart = HAL_GetTick(); - - /* Check for the Busy flag */ - while( 1 ) - { - tmpreg = heth->Instance->MACMIIAR; - - if( ( tmpreg & ETH_MACMIIAR_MB ) == 0ul ) - { - xResult = HAL_OK; - break; - } - /* Check for the Timeout */ - if( ( HAL_GetTick( ) - tickstart ) > PHY_WRITE_TO ) - { - xResult = HAL_TIMEOUT; - break; - } - } - - /* Set ETH HAL State to READY */ - heth->State = HAL_ETH_STATE_READY; - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - } - - if( xResult != HAL_OK ) - { - lUDPLoggingPrintf( "WritePHY: %d\n", xResult ); - } - /* Return function status */ - return xResult; -} - -/** - * @} - */ - -/** @defgroup ETH_Exported_Functions_Group3 Peripheral Control functions - * @brief Peripheral Control functions - * -@verbatim - =============================================================================== - ##### Peripheral Control functions ##### - =============================================================================== - [..] This section provides functions allowing to: - (+) Enable MAC and DMA transmission and reception. - HAL_ETH_Start(); - (+) Disable MAC and DMA transmission and reception. - HAL_ETH_Stop(); - (+) Set the MAC configuration in runtime mode - HAL_ETH_ConfigMAC(); - (+) Set the DMA configuration in runtime mode - HAL_ETH_ConfigDMA(); - -@endverbatim - * @{ - */ - - /** - * @brief Enables Ethernet MAC and DMA reception/transmission - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_Start( ETH_HandleTypeDef *heth ) -{ - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Set the ETH peripheral state to BUSY */ - heth->State = HAL_ETH_STATE_BUSY; - - /* Enable transmit state machine of the MAC for transmission on the MII */ - ETH_MACTransmissionEnable( heth ); - - /* Enable receive state machine of the MAC for reception from the MII */ - ETH_MACReceptionEnable( heth ); - - /* Flush Transmit FIFO */ - ETH_FlushTransmitFIFO( heth ); - - /* Start DMA transmission */ - ETH_DMATransmissionEnable( heth ); - - /* Start DMA reception */ - ETH_DMAReceptionEnable( heth ); - - /* Set the ETH state to READY*/ - heth->State= HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -/** - * @brief Stop Ethernet MAC and DMA reception/transmission - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_Stop(ETH_HandleTypeDef *heth) -{ - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Set the ETH peripheral state to BUSY */ - heth->State = HAL_ETH_STATE_BUSY; - - /* Stop DMA transmission */ - ETH_DMATransmissionDisable( heth ); - - /* Stop DMA reception */ - ETH_DMAReceptionDisable( heth ); - - /* Disable receive state machine of the MAC for reception from the MII */ - ETH_MACReceptionDisable( heth ); - - /* Flush Transmit FIFO */ - ETH_FlushTransmitFIFO( heth ); - - /* Disable transmit state machine of the MAC for transmission on the MII */ - ETH_MACTransmissionDisable( heth ); - - /* Set the ETH state*/ - heth->State = HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -static void prvWriteMACFCR( ETH_HandleTypeDef *heth, uint32_t ulValue) -{ - /* Enable the MAC transmission */ - heth->Instance->MACFCR = ulValue; - - /* Wait until the write operation will be taken into account: - at least four TX_CLK/RX_CLK clock cycles. - Read it back, wait a ms and */ - ( void ) heth->Instance->MACFCR; - - HAL_Delay( ETH_REG_WRITE_DELAY ); - - heth->Instance->MACFCR = ulValue; -} - -static void prvWriteDMAOMR( ETH_HandleTypeDef *heth, uint32_t ulValue) -{ - /* Enable the MAC transmission */ - heth->Instance->DMAOMR = ulValue; - - /* Wait until the write operation will be taken into account: - at least four TX_CLK/RX_CLK clock cycles. - Read it back, wait a ms and */ - ( void ) heth->Instance->DMAOMR; - - HAL_Delay( ETH_REG_WRITE_DELAY ); - - heth->Instance->DMAOMR = ulValue; -} - -static void prvWriteMACCR( ETH_HandleTypeDef *heth, uint32_t ulValue) -{ - /* Enable the MAC transmission */ - heth->Instance->MACCR = ulValue; - - /* Wait until the write operation will be taken into account: - at least four TX_CLK/RX_CLK clock cycles. - Read it back, wait a ms and */ - ( void ) heth->Instance->MACCR; - - HAL_Delay( ETH_REG_WRITE_DELAY ); - - heth->Instance->MACCR = ulValue; -} - -/** - * @brief Set ETH MAC Configuration. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param macconf: MAC Configuration structure - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_ConfigMAC(ETH_HandleTypeDef *heth, ETH_MACInitTypeDef *macconf) -{ - uint32_t tmpreg = 0; - - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Set the ETH peripheral state to BUSY */ - heth->State= HAL_ETH_STATE_BUSY; - - assert_param(IS_ETH_SPEED(heth->Init.Speed)); - assert_param(IS_ETH_DUPLEX_MODE(heth->Init.DuplexMode)); - - if (macconf != NULL) - { - /* Check the parameters */ - assert_param(IS_ETH_WATCHDOG(macconf->Watchdog)); - assert_param(IS_ETH_JABBER(macconf->Jabber)); - assert_param(IS_ETH_INTER_FRAME_GAP(macconf->InterFrameGap)); - assert_param(IS_ETH_CARRIER_SENSE(macconf->CarrierSense)); - assert_param(IS_ETH_RECEIVE_OWN(macconf->ReceiveOwn)); - assert_param(IS_ETH_LOOPBACK_MODE(macconf->LoopbackMode)); - assert_param(IS_ETH_CHECKSUM_OFFLOAD(macconf->ChecksumOffload)); - assert_param(IS_ETH_RETRY_TRANSMISSION(macconf->RetryTransmission)); - assert_param(IS_ETH_AUTOMATIC_PADCRC_STRIP(macconf->AutomaticPadCRCStrip)); - assert_param(IS_ETH_BACKOFF_LIMIT(macconf->BackOffLimit)); - assert_param(IS_ETH_DEFERRAL_CHECK(macconf->DeferralCheck)); - assert_param(IS_ETH_RECEIVE_ALL(macconf->ReceiveAll)); - assert_param(IS_ETH_SOURCE_ADDR_FILTER(macconf->SourceAddrFilter)); - assert_param(IS_ETH_CONTROL_FRAMES(macconf->PassControlFrames)); - assert_param(IS_ETH_BROADCAST_FRAMES_RECEPTION(macconf->BroadcastFramesReception)); - assert_param(IS_ETH_DESTINATION_ADDR_FILTER(macconf->DestinationAddrFilter)); - assert_param(IS_ETH_PROMISCUOUS_MODE(macconf->PromiscuousMode)); - assert_param(IS_ETH_MULTICAST_FRAMES_FILTER(macconf->MulticastFramesFilter)); - assert_param(IS_ETH_UNICAST_FRAMES_FILTER(macconf->UnicastFramesFilter)); - assert_param(IS_ETH_PAUSE_TIME(macconf->PauseTime)); - assert_param(IS_ETH_ZEROQUANTA_PAUSE(macconf->ZeroQuantaPause)); - assert_param(IS_ETH_PAUSE_LOW_THRESHOLD(macconf->PauseLowThreshold)); - assert_param(IS_ETH_UNICAST_PAUSE_FRAME_DETECT(macconf->UnicastPauseFrameDetect)); - assert_param(IS_ETH_RECEIVE_FLOWCONTROL(macconf->ReceiveFlowControl)); - assert_param(IS_ETH_TRANSMIT_FLOWCONTROL(macconf->TransmitFlowControl)); - assert_param(IS_ETH_VLAN_TAG_COMPARISON(macconf->VLANTagComparison)); - assert_param(IS_ETH_VLAN_TAG_IDENTIFIER(macconf->VLANTagIdentifier)); - - /*------------------------ ETHERNET MACCR Configuration --------------------*/ - /* Get the ETHERNET MACCR value */ - tmpreg = heth->Instance->MACCR; - /* Clear WD, PCE, PS, TE and RE bits */ - tmpreg &= ETH_MACCR_CLEAR_MASK; - - tmpreg |= (uint32_t)( - macconf->Watchdog | - macconf->Jabber | - macconf->InterFrameGap | - macconf->CarrierSense | - heth->Init.Speed | - macconf->ReceiveOwn | - macconf->LoopbackMode | - heth->Init.DuplexMode | - macconf->ChecksumOffload | - macconf->RetryTransmission | - macconf->AutomaticPadCRCStrip | - macconf->BackOffLimit | - macconf->DeferralCheck); - - /* Write to ETHERNET MACCR */ - prvWriteMACCR( heth, tmpreg ); - - /*----------------------- ETHERNET MACFFR Configuration --------------------*/ - /* Write to ETHERNET MACFFR */ - heth->Instance->MACFFR = (uint32_t)( - macconf->ReceiveAll | - macconf->SourceAddrFilter | - macconf->PassControlFrames | - macconf->BroadcastFramesReception | - macconf->DestinationAddrFilter | - macconf->PromiscuousMode | - macconf->MulticastFramesFilter | - macconf->UnicastFramesFilter); - - /* Wait until the write operation will be taken into account : - at least four TX_CLK/RX_CLK clock cycles */ - tmpreg = heth->Instance->MACFFR; - HAL_Delay(ETH_REG_WRITE_DELAY); - heth->Instance->MACFFR = tmpreg; - - /*--------------- ETHERNET MACHTHR and MACHTLR Configuration ---------------*/ - /* Write to ETHERNET MACHTHR */ - heth->Instance->MACHTHR = (uint32_t)macconf->HashTableHigh; - - /* Write to ETHERNET MACHTLR */ - heth->Instance->MACHTLR = (uint32_t)macconf->HashTableLow; - /*----------------------- ETHERNET MACFCR Configuration --------------------*/ - - /* Get the ETHERNET MACFCR value */ - tmpreg = heth->Instance->MACFCR; - /* Clear xx bits */ - tmpreg &= ETH_MACFCR_CLEAR_MASK; - - tmpreg |= (uint32_t)(( - macconf->PauseTime << 16) | - macconf->ZeroQuantaPause | - macconf->PauseLowThreshold | - macconf->UnicastPauseFrameDetect | - macconf->ReceiveFlowControl | - macconf->TransmitFlowControl); - - /* Write to ETHERNET MACFCR */ - prvWriteMACFCR( heth, tmpreg ); - - /*----------------------- ETHERNET MACVLANTR Configuration -----------------*/ - heth->Instance->MACVLANTR = (uint32_t)(macconf->VLANTagComparison | - macconf->VLANTagIdentifier); - - /* Wait until the write operation will be taken into account : - at least four TX_CLK/RX_CLK clock cycles */ - tmpreg = heth->Instance->MACVLANTR; - HAL_Delay(ETH_REG_WRITE_DELAY); - heth->Instance->MACVLANTR = tmpreg; - } - else /* macconf == NULL : here we just configure Speed and Duplex mode */ - { - /*------------------------ ETHERNET MACCR Configuration --------------------*/ - /* Get the ETHERNET MACCR value */ - tmpreg = heth->Instance->MACCR; - - /* Clear FES and DM bits */ - tmpreg &= ~((uint32_t)0x00004800); - - tmpreg |= (uint32_t)(heth->Init.Speed | heth->Init.DuplexMode); - - /* Write to ETHERNET MACCR */ - prvWriteMACCR( heth, tmpreg ); - } - - /* Set the ETH state to Ready */ - heth->State= HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -/** - * @brief Sets ETH DMA Configuration. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param dmaconf: DMA Configuration structure - * @retval HAL status - */ -HAL_StatusTypeDef HAL_ETH_ConfigDMA(ETH_HandleTypeDef *heth, ETH_DMAInitTypeDef *dmaconf) -{ - uint32_t tmpreg = 0; - - /* Process Locked */ - __HAL_LOCK( heth ); - - /* Set the ETH peripheral state to BUSY */ - heth->State= HAL_ETH_STATE_BUSY; - - /* Check parameters */ - assert_param(IS_ETH_DROP_TCPIP_CHECKSUM_FRAME(dmaconf->DropTCPIPChecksumErrorFrame)); - assert_param(IS_ETH_RECEIVE_STORE_FORWARD(dmaconf->ReceiveStoreForward)); - assert_param(IS_ETH_FLUSH_RECEIVE_FRAME(dmaconf->FlushReceivedFrame)); - assert_param(IS_ETH_TRANSMIT_STORE_FORWARD(dmaconf->TransmitStoreForward)); - assert_param(IS_ETH_TRANSMIT_THRESHOLD_CONTROL(dmaconf->TransmitThresholdControl)); - assert_param(IS_ETH_FORWARD_ERROR_FRAMES(dmaconf->ForwardErrorFrames)); - assert_param(IS_ETH_FORWARD_UNDERSIZED_GOOD_FRAMES(dmaconf->ForwardUndersizedGoodFrames)); - assert_param(IS_ETH_RECEIVE_THRESHOLD_CONTROL(dmaconf->ReceiveThresholdControl)); - assert_param(IS_ETH_SECOND_FRAME_OPERATE(dmaconf->SecondFrameOperate)); - assert_param(IS_ETH_ADDRESS_ALIGNED_BEATS(dmaconf->AddressAlignedBeats)); - assert_param(IS_ETH_FIXED_BURST(dmaconf->FixedBurst)); - assert_param(IS_ETH_RXDMA_BURST_LENGTH(dmaconf->RxDMABurstLength)); - assert_param(IS_ETH_TXDMA_BURST_LENGTH(dmaconf->TxDMABurstLength)); - assert_param(IS_ETH_ENHANCED_DESCRIPTOR_FORMAT(dmaconf->EnhancedDescriptorFormat)); - assert_param(IS_ETH_DMA_DESC_SKIP_LENGTH(dmaconf->DescriptorSkipLength)); - assert_param(IS_ETH_DMA_ARBITRATION_ROUNDROBIN_RXTX(dmaconf->DMAArbitration)); - - /*----------------------- ETHERNET DMAOMR Configuration --------------------*/ - /* Get the ETHERNET DMAOMR value */ - tmpreg = heth->Instance->DMAOMR; - /* Clear xx bits */ - tmpreg &= ETH_DMAOMR_CLEAR_MASK; - - tmpreg |= (uint32_t)( - dmaconf->DropTCPIPChecksumErrorFrame | - dmaconf->ReceiveStoreForward | - dmaconf->FlushReceivedFrame | - dmaconf->TransmitStoreForward | - dmaconf->TransmitThresholdControl | - dmaconf->ForwardErrorFrames | - dmaconf->ForwardUndersizedGoodFrames | - dmaconf->ReceiveThresholdControl | - dmaconf->SecondFrameOperate); - - /* Write to ETHERNET DMAOMR */ - prvWriteDMAOMR( heth, tmpreg ); - - /*----------------------- ETHERNET DMABMR Configuration --------------------*/ - heth->Instance->DMABMR = (uint32_t)(dmaconf->AddressAlignedBeats | - dmaconf->FixedBurst | - dmaconf->RxDMABurstLength | /* !! if 4xPBL is selected for Tx or Rx it is applied for the other */ - dmaconf->TxDMABurstLength | - dmaconf->EnhancedDescriptorFormat | - (dmaconf->DescriptorSkipLength << 2) | - dmaconf->DMAArbitration | - ETH_DMABMR_USP); /* Enable use of separate PBL for Rx and Tx */ - - /* Wait until the write operation will be taken into account: - at least four TX_CLK/RX_CLK clock cycles */ - tmpreg = heth->Instance->DMABMR; - HAL_Delay(ETH_REG_WRITE_DELAY); - heth->Instance->DMABMR = tmpreg; - - /* Set the ETH state to Ready */ - heth->State= HAL_ETH_STATE_READY; - - /* Process Unlocked */ - __HAL_UNLOCK( heth ); - - /* Return function status */ - return HAL_OK; -} - -/** - * @} - */ - -/** @defgroup ETH_Exported_Functions_Group4 Peripheral State functions - * @brief Peripheral State functions - * - @verbatim - =============================================================================== - ##### Peripheral State functions ##### - =============================================================================== - [..] - This subsection permits to get in run-time the status of the peripheral - and the data flow. - (+) Get the ETH handle state: - HAL_ETH_GetState(); - - - @endverbatim - * @{ - */ - -/** - * @brief Return the ETH HAL state - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval HAL state - */ -HAL_ETH_StateTypeDef HAL_ETH_GetState(ETH_HandleTypeDef *heth) -{ - /* Return ETH state */ - return heth->State; -} - -/** - * @} - */ - -/** - * @} - */ - -/** @addtogroup ETH_Private_Functions - * @{ - */ - -/** - * @brief Configures Ethernet MAC and DMA with default parameters. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param err: Ethernet Init error - * @retval HAL status - */ -static void ETH_MACDMAConfig(ETH_HandleTypeDef *heth, uint32_t err) -{ - ETH_MACInitTypeDef macinit; - ETH_DMAInitTypeDef dmainit; - uint32_t tmpreg = 0; - - if (err != ETH_SUCCESS) /* Auto-negotiation failed */ - { - /* Set Ethernet duplex mode to Full-duplex */ - heth->Init.DuplexMode = ETH_MODE_FULLDUPLEX; - - /* Set Ethernet speed to 100M */ - heth->Init.Speed = ETH_SPEED_100M; - } - - /* Ethernet MAC default initialization **************************************/ - macinit.Watchdog = ETH_WATCHDOG_ENABLE; - macinit.Jabber = ETH_JABBER_ENABLE; - macinit.InterFrameGap = ETH_INTERFRAMEGAP_96BIT; - macinit.CarrierSense = ETH_CARRIERSENCE_ENABLE; - macinit.ReceiveOwn = ETH_RECEIVEOWN_ENABLE; - macinit.LoopbackMode = ETH_LOOPBACKMODE_DISABLE; - if(heth->Init.ChecksumMode == ETH_CHECKSUM_BY_HARDWARE) - { - macinit.ChecksumOffload = ETH_CHECKSUMOFFLAOD_ENABLE; - } - else - { - macinit.ChecksumOffload = ETH_CHECKSUMOFFLAOD_DISABLE; - } - macinit.RetryTransmission = ETH_RETRYTRANSMISSION_DISABLE; - macinit.AutomaticPadCRCStrip = ETH_AUTOMATICPADCRCSTRIP_DISABLE; - macinit.BackOffLimit = ETH_BACKOFFLIMIT_10; - macinit.DeferralCheck = ETH_DEFFERRALCHECK_DISABLE; - macinit.ReceiveAll = ETH_RECEIVEAll_DISABLE; - macinit.SourceAddrFilter = ETH_SOURCEADDRFILTER_DISABLE; - macinit.PassControlFrames = ETH_PASSCONTROLFRAMES_BLOCKALL; - macinit.BroadcastFramesReception = ETH_BROADCASTFRAMESRECEPTION_ENABLE; - macinit.DestinationAddrFilter = ETH_DESTINATIONADDRFILTER_NORMAL; - macinit.PromiscuousMode = ETH_PROMISCUOUS_MODE_DISABLE; - macinit.MulticastFramesFilter = ETH_MULTICASTFRAMESFILTER_PERFECT; - macinit.UnicastFramesFilter = ETH_UNICASTFRAMESFILTER_PERFECT; - macinit.HashTableHigh = 0x0; - macinit.HashTableLow = 0x0; - macinit.PauseTime = 0x0; - macinit.ZeroQuantaPause = ETH_ZEROQUANTAPAUSE_DISABLE; - macinit.PauseLowThreshold = ETH_PAUSELOWTHRESHOLD_MINUS4; - macinit.UnicastPauseFrameDetect = ETH_UNICASTPAUSEFRAMEDETECT_DISABLE; - macinit.ReceiveFlowControl = ETH_RECEIVEFLOWCONTROL_DISABLE; - macinit.TransmitFlowControl = ETH_TRANSMITFLOWCONTROL_DISABLE; - macinit.VLANTagComparison = ETH_VLANTAGCOMPARISON_16BIT; - macinit.VLANTagIdentifier = 0x0; - - /*------------------------ ETHERNET MACCR Configuration --------------------*/ - /* Get the ETHERNET MACCR value */ - tmpreg = heth->Instance->MACCR; - /* Clear WD, PCE, PS, TE and RE bits */ - tmpreg &= ETH_MACCR_CLEAR_MASK; - /* Set the WD bit according to ETH Watchdog value */ - /* Set the JD: bit according to ETH Jabber value */ - /* Set the IFG bit according to ETH InterFrameGap value */ - /* Set the DCRS bit according to ETH CarrierSense value */ - /* Set the FES bit according to ETH Speed value */ - /* Set the DO bit according to ETH ReceiveOwn value */ - /* Set the LM bit according to ETH LoopbackMode value */ - /* Set the DM bit according to ETH Mode value */ - /* Set the IPCO bit according to ETH ChecksumOffload value */ - /* Set the DR bit according to ETH RetryTransmission value */ - /* Set the ACS bit according to ETH AutomaticPadCRCStrip value */ - /* Set the BL bit according to ETH BackOffLimit value */ - /* Set the DC bit according to ETH DeferralCheck value */ - tmpreg |= (uint32_t)(macinit.Watchdog | - macinit.Jabber | - macinit.InterFrameGap | - macinit.CarrierSense | - heth->Init.Speed | - macinit.ReceiveOwn | - macinit.LoopbackMode | - heth->Init.DuplexMode | - macinit.ChecksumOffload | - macinit.RetryTransmission | - macinit.AutomaticPadCRCStrip | - macinit.BackOffLimit | - macinit.DeferralCheck); - - /* Write to ETHERNET MACCR */ - prvWriteMACCR( heth, tmpreg ); - - /*----------------------- ETHERNET MACFFR Configuration --------------------*/ - /* Set the RA bit according to ETH ReceiveAll value */ - /* Set the SAF and SAIF bits according to ETH SourceAddrFilter value */ - /* Set the PCF bit according to ETH PassControlFrames value */ - /* Set the DBF bit according to ETH BroadcastFramesReception value */ - /* Set the DAIF bit according to ETH DestinationAddrFilter value */ - /* Set the PR bit according to ETH PromiscuousMode value */ - /* Set the PM, HMC and HPF bits according to ETH MulticastFramesFilter value */ - /* Set the HUC and HPF bits according to ETH UnicastFramesFilter value */ - /* Write to ETHERNET MACFFR */ - heth->Instance->MACFFR = (uint32_t)(macinit.ReceiveAll | - macinit.SourceAddrFilter | - macinit.PassControlFrames | - macinit.BroadcastFramesReception | - macinit.DestinationAddrFilter | - macinit.PromiscuousMode | - macinit.MulticastFramesFilter | - macinit.UnicastFramesFilter); - - /* Wait until the write operation will be taken into account: - at least four TX_CLK/RX_CLK clock cycles */ - tmpreg = heth->Instance->MACFFR; - HAL_Delay(ETH_REG_WRITE_DELAY); - heth->Instance->MACFFR = tmpreg; - - /*--------------- ETHERNET MACHTHR and MACHTLR Configuration --------------*/ - /* Write to ETHERNET MACHTHR */ - heth->Instance->MACHTHR = (uint32_t)macinit.HashTableHigh; - - /* Write to ETHERNET MACHTLR */ - heth->Instance->MACHTLR = (uint32_t)macinit.HashTableLow; - /*----------------------- ETHERNET MACFCR Configuration -------------------*/ - - /* Get the ETHERNET MACFCR value */ - tmpreg = heth->Instance->MACFCR; - /* Clear xx bits */ - tmpreg &= ETH_MACFCR_CLEAR_MASK; - - /* Set the PT bit according to ETH PauseTime value */ - /* Set the DZPQ bit according to ETH ZeroQuantaPause value */ - /* Set the PLT bit according to ETH PauseLowThreshold value */ - /* Set the UP bit according to ETH UnicastPauseFrameDetect value */ - /* Set the RFE bit according to ETH ReceiveFlowControl value */ - /* Set the TFE bit according to ETH TransmitFlowControl value */ - tmpreg |= (uint32_t)((macinit.PauseTime << 16) | - macinit.ZeroQuantaPause | - macinit.PauseLowThreshold | - macinit.UnicastPauseFrameDetect | - macinit.ReceiveFlowControl | - macinit.TransmitFlowControl); - - /* Write to ETHERNET MACFCR */ - prvWriteMACFCR( heth, tmpreg ); - - /*----------------------- ETHERNET MACVLANTR Configuration ----------------*/ - /* Set the ETV bit according to ETH VLANTagComparison value */ - /* Set the VL bit according to ETH VLANTagIdentifier value */ - heth->Instance->MACVLANTR = (uint32_t)(macinit.VLANTagComparison | - macinit.VLANTagIdentifier); - - /* Wait until the write operation will be taken into account: - at least four TX_CLK/RX_CLK clock cycles */ - tmpreg = heth->Instance->MACVLANTR; - HAL_Delay(ETH_REG_WRITE_DELAY); - heth->Instance->MACVLANTR = tmpreg; - - /* Ethernet DMA default initialization ************************************/ - dmainit.DropTCPIPChecksumErrorFrame = ETH_DROPTCPIPCHECKSUMERRORFRAME_ENABLE; - dmainit.ReceiveStoreForward = ETH_RECEIVESTOREFORWARD_ENABLE; - dmainit.FlushReceivedFrame = ETH_FLUSHRECEIVEDFRAME_ENABLE; - dmainit.TransmitStoreForward = ETH_TRANSMITSTOREFORWARD_ENABLE; - dmainit.TransmitThresholdControl = ETH_TRANSMITTHRESHOLDCONTROL_64BYTES; - dmainit.ForwardErrorFrames = ETH_FORWARDERRORFRAMES_DISABLE; - dmainit.ForwardUndersizedGoodFrames = ETH_FORWARDUNDERSIZEDGOODFRAMES_DISABLE; - dmainit.ReceiveThresholdControl = ETH_RECEIVEDTHRESHOLDCONTROL_64BYTES; - dmainit.SecondFrameOperate = ETH_SECONDFRAMEOPERARTE_ENABLE; - dmainit.AddressAlignedBeats = ETH_ADDRESSALIGNEDBEATS_ENABLE; - dmainit.FixedBurst = ETH_FIXEDBURST_ENABLE; - dmainit.RxDMABurstLength = ETH_RXDMABURSTLENGTH_32BEAT; - dmainit.TxDMABurstLength = ETH_TXDMABURSTLENGTH_32BEAT; - dmainit.EnhancedDescriptorFormat = ETH_DMAENHANCEDDESCRIPTOR_ENABLE; - dmainit.DescriptorSkipLength = 0x0; - dmainit.DMAArbitration = ETH_DMAARBITRATION_ROUNDROBIN_RXTX_1_1; - - /* Get the ETHERNET DMAOMR value */ - tmpreg = heth->Instance->DMAOMR; - /* Clear xx bits */ - tmpreg &= ETH_DMAOMR_CLEAR_MASK; - - /* Set the DT bit according to ETH DropTCPIPChecksumErrorFrame value */ - /* Set the RSF bit according to ETH ReceiveStoreForward value */ - /* Set the DFF bit according to ETH FlushReceivedFrame value */ - /* Set the TSF bit according to ETH TransmitStoreForward value */ - /* Set the TTC bit according to ETH TransmitThresholdControl value */ - /* Set the FEF bit according to ETH ForwardErrorFrames value */ - /* Set the FUF bit according to ETH ForwardUndersizedGoodFrames value */ - /* Set the RTC bit according to ETH ReceiveThresholdControl value */ - /* Set the OSF bit according to ETH SecondFrameOperate value */ - tmpreg |= (uint32_t)(dmainit.DropTCPIPChecksumErrorFrame | - dmainit.ReceiveStoreForward | - dmainit.FlushReceivedFrame | - dmainit.TransmitStoreForward | - dmainit.TransmitThresholdControl | - dmainit.ForwardErrorFrames | - dmainit.ForwardUndersizedGoodFrames | - dmainit.ReceiveThresholdControl | - dmainit.SecondFrameOperate); - - /* Write to ETHERNET DMAOMR */ - prvWriteDMAOMR( heth, tmpreg ); - - /*----------------------- ETHERNET DMABMR Configuration ------------------*/ - /* Set the AAL bit according to ETH AddressAlignedBeats value */ - /* Set the FB bit according to ETH FixedBurst value */ - /* Set the RPBL and 4*PBL bits according to ETH RxDMABurstLength value */ - /* Set the PBL and 4*PBL bits according to ETH TxDMABurstLength value */ - /* Set the Enhanced DMA descriptors bit according to ETH EnhancedDescriptorFormat value*/ - /* Set the DSL bit according to ETH DesciptorSkipLength value */ - /* Set the PR and DA bits according to ETH DMAArbitration value */ - heth->Instance->DMABMR = (uint32_t)(dmainit.AddressAlignedBeats | - dmainit.FixedBurst | - dmainit.RxDMABurstLength | /* !! if 4xPBL is selected for Tx or Rx it is applied for the other */ - dmainit.TxDMABurstLength | - dmainit.EnhancedDescriptorFormat | - (dmainit.DescriptorSkipLength << 2) | - dmainit.DMAArbitration | - ETH_DMABMR_USP); /* Enable use of separate PBL for Rx and Tx */ - - /* Wait until the write operation will be taken into account: - at least four TX_CLK/RX_CLK clock cycles */ - tmpreg = heth->Instance->DMABMR; - HAL_Delay(ETH_REG_WRITE_DELAY); - heth->Instance->DMABMR = tmpreg; - - if(heth->Init.RxMode == ETH_RXINTERRUPT_MODE) - { - /* Enable the Ethernet Rx Interrupt */ - __HAL_ETH_DMA_ENABLE_IT(( heth ), ETH_DMA_IT_NIS | ETH_DMA_IT_R); - } - - /* Initialize MAC address in ethernet MAC */ - ETH_MACAddressConfig(heth, ETH_MAC_ADDRESS0, heth->Init.MACAddr); -} - -/** - * @brief Configures the selected MAC address. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @param MacAddr: The MAC address to configure - * This parameter can be one of the following values: - * @arg ETH_MAC_Address0: MAC Address0 - * @arg ETH_MAC_Address1: MAC Address1 - * @arg ETH_MAC_Address2: MAC Address2 - * @arg ETH_MAC_Address3: MAC Address3 - * @param Addr: Pointer to MAC address buffer data (6 bytes) - * @retval HAL status - */ -static void ETH_MACAddressConfig(ETH_HandleTypeDef *heth, uint32_t MacAddr, uint8_t *Addr) -{ - uint32_t tmpreg; - - /* Check the parameters */ - assert_param( IS_ETH_MAC_ADDRESS0123( MacAddr ) ); - - /* Calculate the selected MAC address high register */ - tmpreg = 0x80000000ul | ( ( uint32_t )Addr[ 5 ] << 8) | (uint32_t)Addr[ 4 ]; - /* Load the selected MAC address high register */ - ( * ( __IO uint32_t * ) ( ( uint32_t ) ( ETH_MAC_ADDR_HBASE + MacAddr ) ) ) = tmpreg; - /* Calculate the selected MAC address low register */ - tmpreg = ( ( uint32_t )Addr[ 3 ] << 24 ) | ( ( uint32_t )Addr[ 2 ] << 16 ) | ( ( uint32_t )Addr[ 1 ] << 8 ) | Addr[ 0 ]; - - /* Load the selected MAC address low register */ - ( * ( __IO uint32_t * ) ( ( uint32_t ) ( ETH_MAC_ADDR_LBASE + MacAddr ) ) ) = tmpreg; -} - -/** - * @brief Enables the MAC transmission. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_MACTransmissionEnable(ETH_HandleTypeDef *heth) -{ - uint32_t tmpreg = heth->Instance->MACCR | ETH_MACCR_TE; - - prvWriteMACCR( heth, tmpreg ); -} - -/** - * @brief Disables the MAC transmission. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_MACTransmissionDisable(ETH_HandleTypeDef *heth) -{ - uint32_t tmpreg = heth->Instance->MACCR & ~( ETH_MACCR_TE ); - - prvWriteMACCR( heth, tmpreg ); -} - -/** - * @brief Enables the MAC reception. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_MACReceptionEnable(ETH_HandleTypeDef *heth) -{ - __IO uint32_t tmpreg = heth->Instance->MACCR | ETH_MACCR_RE; - - prvWriteMACCR( heth, tmpreg ); -} - -/** - * @brief Disables the MAC reception. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_MACReceptionDisable(ETH_HandleTypeDef *heth) -{ - __IO uint32_t tmpreg = heth->Instance->MACCR & ~( ETH_MACCR_RE ); - - prvWriteMACCR( heth, tmpreg ); -} - -/** - * @brief Enables the DMA transmission. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_DMATransmissionEnable(ETH_HandleTypeDef *heth) -{ - /* Enable the DMA transmission */ - __IO uint32_t tmpreg = heth->Instance->DMAOMR | ETH_DMAOMR_ST; - - prvWriteDMAOMR( heth, tmpreg ); -} - -/** - * @brief Disables the DMA transmission. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_DMATransmissionDisable(ETH_HandleTypeDef *heth) -{ - /* Disable the DMA transmission */ - __IO uint32_t tmpreg = heth->Instance->DMAOMR & ~( ETH_DMAOMR_ST ); - - prvWriteDMAOMR( heth, tmpreg ); -} - -/** - * @brief Enables the DMA reception. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_DMAReceptionEnable(ETH_HandleTypeDef *heth) -{ - /* Enable the DMA reception */ - __IO uint32_t tmpreg = heth->Instance->DMAOMR | ETH_DMAOMR_SR; - - prvWriteDMAOMR( heth, tmpreg ); -} - -/** - * @brief Disables the DMA reception. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_DMAReceptionDisable(ETH_HandleTypeDef *heth) -{ - /* Disable the DMA reception */ - __IO uint32_t tmpreg = heth->Instance->DMAOMR & ~( ETH_DMAOMR_SR ); - - prvWriteDMAOMR( heth, tmpreg ); -} - -/** - * @brief Clears the ETHERNET transmit FIFO. - * @param heth: pointer to a ETH_HandleTypeDef structure that contains - * the configuration information for ETHERNET module - * @retval None - */ -static void ETH_FlushTransmitFIFO(ETH_HandleTypeDef *heth) -{ - /* Set the Flush Transmit FIFO bit */ - __IO uint32_t tmpreg = heth->Instance->DMAOMR | ETH_DMAOMR_FTF; - - prvWriteDMAOMR( heth, tmpreg ); -} - -/** - * @} - */ - -#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ -#endif /* HAL_ETH_MODULE_ENABLED */ -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32Fxx/stm32f4xx_hal_eth.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32Fxx/stm32f4xx_hal_eth.h deleted file mode 100755 index 599a325..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/STM32Fxx/stm32f4xx_hal_eth.h +++ /dev/null @@ -1,2225 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_hal_eth.h - * @author MCD Application Team - * @version V1.3.2 - * @date 26-June-2015 - * @brief Header file of ETH HAL module. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2015 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4xx_HAL_ETH_H -#define __STM32F4xx_HAL_ETH_H - -#ifdef __cplusplus - extern "C" { -#endif - -#if defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal_def.h" - -/** @addtogroup STM32F4xx_HAL_Driver - * @{ - */ - -/** @addtogroup ETH - * @{ - */ - -/** @addtogroup ETH_Private_Macros - * @{ - */ -#define IS_ETH_PHY_ADDRESS(ADDRESS) ((ADDRESS) <= 0x20) -#define IS_ETH_AUTONEGOTIATION(CMD) (((CMD) == ETH_AUTONEGOTIATION_ENABLE) || \ - ((CMD) == ETH_AUTONEGOTIATION_DISABLE)) -#define IS_ETH_SPEED(SPEED) (((SPEED) == ETH_SPEED_10M) || \ - ((SPEED) == ETH_SPEED_100M)) -#define IS_ETH_DUPLEX_MODE(MODE) (((MODE) == ETH_MODE_FULLDUPLEX) || \ - ((MODE) == ETH_MODE_HALFDUPLEX)) -#define IS_ETH_DUPLEX_MODE(MODE) (((MODE) == ETH_MODE_FULLDUPLEX) || \ - ((MODE) == ETH_MODE_HALFDUPLEX)) -#define IS_ETH_RX_MODE(MODE) (((MODE) == ETH_RXPOLLING_MODE) || \ - ((MODE) == ETH_RXINTERRUPT_MODE)) -#define IS_ETH_RX_MODE(MODE) (((MODE) == ETH_RXPOLLING_MODE) || \ - ((MODE) == ETH_RXINTERRUPT_MODE)) -#define IS_ETH_RX_MODE(MODE) (((MODE) == ETH_RXPOLLING_MODE) || \ - ((MODE) == ETH_RXINTERRUPT_MODE)) -#define IS_ETH_CHECKSUM_MODE(MODE) (((MODE) == ETH_CHECKSUM_BY_HARDWARE) || \ - ((MODE) == ETH_CHECKSUM_BY_SOFTWARE)) -#define IS_ETH_MEDIA_INTERFACE(MODE) (((MODE) == ETH_MEDIA_INTERFACE_MII) || \ - ((MODE) == ETH_MEDIA_INTERFACE_RMII)) -#define IS_ETH_WATCHDOG(CMD) (((CMD) == ETH_WATCHDOG_ENABLE) || \ - ((CMD) == ETH_WATCHDOG_DISABLE)) -#define IS_ETH_JABBER(CMD) (((CMD) == ETH_JABBER_ENABLE) || \ - ((CMD) == ETH_JABBER_DISABLE)) -#define IS_ETH_INTER_FRAME_GAP(GAP) (((GAP) == ETH_INTERFRAMEGAP_96BIT) || \ - ((GAP) == ETH_INTERFRAMEGAP_88BIT) || \ - ((GAP) == ETH_INTERFRAMEGAP_80BIT) || \ - ((GAP) == ETH_INTERFRAMEGAP_72BIT) || \ - ((GAP) == ETH_INTERFRAMEGAP_64BIT) || \ - ((GAP) == ETH_INTERFRAMEGAP_56BIT) || \ - ((GAP) == ETH_INTERFRAMEGAP_48BIT) || \ - ((GAP) == ETH_INTERFRAMEGAP_40BIT)) -#define IS_ETH_CARRIER_SENSE(CMD) (((CMD) == ETH_CARRIERSENCE_ENABLE) || \ - ((CMD) == ETH_CARRIERSENCE_DISABLE)) -#define IS_ETH_RECEIVE_OWN(CMD) (((CMD) == ETH_RECEIVEOWN_ENABLE) || \ - ((CMD) == ETH_RECEIVEOWN_DISABLE)) -#define IS_ETH_LOOPBACK_MODE(CMD) (((CMD) == ETH_LOOPBACKMODE_ENABLE) || \ - ((CMD) == ETH_LOOPBACKMODE_DISABLE)) -#define IS_ETH_CHECKSUM_OFFLOAD(CMD) (((CMD) == ETH_CHECKSUMOFFLAOD_ENABLE) || \ - ((CMD) == ETH_CHECKSUMOFFLAOD_DISABLE)) -#define IS_ETH_RETRY_TRANSMISSION(CMD) (((CMD) == ETH_RETRYTRANSMISSION_ENABLE) || \ - ((CMD) == ETH_RETRYTRANSMISSION_DISABLE)) -#define IS_ETH_AUTOMATIC_PADCRC_STRIP(CMD) (((CMD) == ETH_AUTOMATICPADCRCSTRIP_ENABLE) || \ - ((CMD) == ETH_AUTOMATICPADCRCSTRIP_DISABLE)) -#define IS_ETH_BACKOFF_LIMIT(LIMIT) (((LIMIT) == ETH_BACKOFFLIMIT_10) || \ - ((LIMIT) == ETH_BACKOFFLIMIT_8) || \ - ((LIMIT) == ETH_BACKOFFLIMIT_4) || \ - ((LIMIT) == ETH_BACKOFFLIMIT_1)) -#define IS_ETH_DEFERRAL_CHECK(CMD) (((CMD) == ETH_DEFFERRALCHECK_ENABLE) || \ - ((CMD) == ETH_DEFFERRALCHECK_DISABLE)) -#define IS_ETH_RECEIVE_ALL(CMD) (((CMD) == ETH_RECEIVEALL_ENABLE) || \ - ((CMD) == ETH_RECEIVEAll_DISABLE)) -#define IS_ETH_SOURCE_ADDR_FILTER(CMD) (((CMD) == ETH_SOURCEADDRFILTER_NORMAL_ENABLE) || \ - ((CMD) == ETH_SOURCEADDRFILTER_INVERSE_ENABLE) || \ - ((CMD) == ETH_SOURCEADDRFILTER_DISABLE)) -#define IS_ETH_CONTROL_FRAMES(PASS) (((PASS) == ETH_PASSCONTROLFRAMES_BLOCKALL) || \ - ((PASS) == ETH_PASSCONTROLFRAMES_FORWARDALL) || \ - ((PASS) == ETH_PASSCONTROLFRAMES_FORWARDPASSEDADDRFILTER)) -#define IS_ETH_BROADCAST_FRAMES_RECEPTION(CMD) (((CMD) == ETH_BROADCASTFRAMESRECEPTION_ENABLE) || \ - ((CMD) == ETH_BROADCASTFRAMESRECEPTION_DISABLE)) -#define IS_ETH_DESTINATION_ADDR_FILTER(FILTER) (((FILTER) == ETH_DESTINATIONADDRFILTER_NORMAL) || \ - ((FILTER) == ETH_DESTINATIONADDRFILTER_INVERSE)) -#define IS_ETH_PROMISCUOUS_MODE(CMD) (((CMD) == ETH_PROMISCUOUS_MODE_ENABLE) || \ - ((CMD) == ETH_PROMISCUOUS_MODE_DISABLE)) -#define IS_ETH_MULTICAST_FRAMES_FILTER(FILTER) (((FILTER) == ETH_MULTICASTFRAMESFILTER_PERFECTHASHTABLE) || \ - ((FILTER) == ETH_MULTICASTFRAMESFILTER_HASHTABLE) || \ - ((FILTER) == ETH_MULTICASTFRAMESFILTER_PERFECT) || \ - ((FILTER) == ETH_MULTICASTFRAMESFILTER_NONE)) -#define IS_ETH_UNICAST_FRAMES_FILTER(FILTER) (((FILTER) == ETH_UNICASTFRAMESFILTER_PERFECTHASHTABLE) || \ - ((FILTER) == ETH_UNICASTFRAMESFILTER_HASHTABLE) || \ - ((FILTER) == ETH_UNICASTFRAMESFILTER_PERFECT)) -#define IS_ETH_PAUSE_TIME(TIME) ((TIME) <= 0xFFFF) -#define IS_ETH_ZEROQUANTA_PAUSE(CMD) (((CMD) == ETH_ZEROQUANTAPAUSE_ENABLE) || \ - ((CMD) == ETH_ZEROQUANTAPAUSE_DISABLE)) -#define IS_ETH_PAUSE_LOW_THRESHOLD(THRESHOLD) (((THRESHOLD) == ETH_PAUSELOWTHRESHOLD_MINUS4) || \ - ((THRESHOLD) == ETH_PAUSELOWTHRESHOLD_MINUS28) || \ - ((THRESHOLD) == ETH_PAUSELOWTHRESHOLD_MINUS144) || \ - ((THRESHOLD) == ETH_PAUSELOWTHRESHOLD_MINUS256)) -#define IS_ETH_UNICAST_PAUSE_FRAME_DETECT(CMD) (((CMD) == ETH_UNICASTPAUSEFRAMEDETECT_ENABLE) || \ - ((CMD) == ETH_UNICASTPAUSEFRAMEDETECT_DISABLE)) -#define IS_ETH_RECEIVE_FLOWCONTROL(CMD) (((CMD) == ETH_RECEIVEFLOWCONTROL_ENABLE) || \ - ((CMD) == ETH_RECEIVEFLOWCONTROL_DISABLE)) -#define IS_ETH_TRANSMIT_FLOWCONTROL(CMD) (((CMD) == ETH_TRANSMITFLOWCONTROL_ENABLE) || \ - ((CMD) == ETH_TRANSMITFLOWCONTROL_DISABLE)) -#define IS_ETH_VLAN_TAG_COMPARISON(COMPARISON) (((COMPARISON) == ETH_VLANTAGCOMPARISON_12BIT) || \ - ((COMPARISON) == ETH_VLANTAGCOMPARISON_16BIT)) -#define IS_ETH_VLAN_TAG_IDENTIFIER(IDENTIFIER) ((IDENTIFIER) <= 0xFFFF) -#define IS_ETH_MAC_ADDRESS0123(ADDRESS) (((ADDRESS) == ETH_MAC_ADDRESS0) || \ - ((ADDRESS) == ETH_MAC_ADDRESS1) || \ - ((ADDRESS) == ETH_MAC_ADDRESS2) || \ - ((ADDRESS) == ETH_MAC_ADDRESS3)) -#define IS_ETH_MAC_ADDRESS123(ADDRESS) (((ADDRESS) == ETH_MAC_ADDRESS1) || \ - ((ADDRESS) == ETH_MAC_ADDRESS2) || \ - ((ADDRESS) == ETH_MAC_ADDRESS3)) -#define IS_ETH_MAC_ADDRESS_FILTER(FILTER) (((FILTER) == ETH_MAC_ADDRESSFILTER_SA) || \ - ((FILTER) == ETH_MAC_ADDRESSFILTER_DA)) -#define IS_ETH_MAC_ADDRESS_MASK(MASK) (((MASK) == ETH_MAC_ADDRESSMASK_BYTE6) || \ - ((MASK) == ETH_MAC_ADDRESSMASK_BYTE5) || \ - ((MASK) == ETH_MAC_ADDRESSMASK_BYTE4) || \ - ((MASK) == ETH_MAC_ADDRESSMASK_BYTE3) || \ - ((MASK) == ETH_MAC_ADDRESSMASK_BYTE2) || \ - ((MASK) == ETH_MAC_ADDRESSMASK_BYTE1)) -#define IS_ETH_DROP_TCPIP_CHECKSUM_FRAME(CMD) (((CMD) == ETH_DROPTCPIPCHECKSUMERRORFRAME_ENABLE) || \ - ((CMD) == ETH_DROPTCPIPCHECKSUMERRORFRAME_DISABLE)) -#define IS_ETH_RECEIVE_STORE_FORWARD(CMD) (((CMD) == ETH_RECEIVESTOREFORWARD_ENABLE) || \ - ((CMD) == ETH_RECEIVESTOREFORWARD_DISABLE)) -#define IS_ETH_FLUSH_RECEIVE_FRAME(CMD) (((CMD) == ETH_FLUSHRECEIVEDFRAME_ENABLE) || \ - ((CMD) == ETH_FLUSHRECEIVEDFRAME_DISABLE)) -#define IS_ETH_TRANSMIT_STORE_FORWARD(CMD) (((CMD) == ETH_TRANSMITSTOREFORWARD_ENABLE) || \ - ((CMD) == ETH_TRANSMITSTOREFORWARD_DISABLE)) -#define IS_ETH_TRANSMIT_THRESHOLD_CONTROL(THRESHOLD) (((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_64BYTES) || \ - ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_128BYTES) || \ - ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_192BYTES) || \ - ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_256BYTES) || \ - ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_40BYTES) || \ - ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_32BYTES) || \ - ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_24BYTES) || \ - ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_16BYTES)) -#define IS_ETH_FORWARD_ERROR_FRAMES(CMD) (((CMD) == ETH_FORWARDERRORFRAMES_ENABLE) || \ - ((CMD) == ETH_FORWARDERRORFRAMES_DISABLE)) -#define IS_ETH_FORWARD_UNDERSIZED_GOOD_FRAMES(CMD) (((CMD) == ETH_FORWARDUNDERSIZEDGOODFRAMES_ENABLE) || \ - ((CMD) == ETH_FORWARDUNDERSIZEDGOODFRAMES_DISABLE)) -#define IS_ETH_RECEIVE_THRESHOLD_CONTROL(THRESHOLD) (((THRESHOLD) == ETH_RECEIVEDTHRESHOLDCONTROL_64BYTES) || \ - ((THRESHOLD) == ETH_RECEIVEDTHRESHOLDCONTROL_32BYTES) || \ - ((THRESHOLD) == ETH_RECEIVEDTHRESHOLDCONTROL_96BYTES) || \ - ((THRESHOLD) == ETH_RECEIVEDTHRESHOLDCONTROL_128BYTES)) -#define IS_ETH_SECOND_FRAME_OPERATE(CMD) (((CMD) == ETH_SECONDFRAMEOPERARTE_ENABLE) || \ - ((CMD) == ETH_SECONDFRAMEOPERARTE_DISABLE)) -#define IS_ETH_ADDRESS_ALIGNED_BEATS(CMD) (((CMD) == ETH_ADDRESSALIGNEDBEATS_ENABLE) || \ - ((CMD) == ETH_ADDRESSALIGNEDBEATS_DISABLE)) -#define IS_ETH_FIXED_BURST(CMD) (((CMD) == ETH_FIXEDBURST_ENABLE) || \ - ((CMD) == ETH_FIXEDBURST_DISABLE)) -#define IS_ETH_RXDMA_BURST_LENGTH(LENGTH) (((LENGTH) == ETH_RXDMABURSTLENGTH_1BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_2BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_4BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_8BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_16BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_32BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_4BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_8BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_16BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_32BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_64BEAT) || \ - ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_128BEAT)) -#define IS_ETH_TXDMA_BURST_LENGTH(LENGTH) (((LENGTH) == ETH_TXDMABURSTLENGTH_1BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_2BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_4BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_8BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_16BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_32BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_4BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_8BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_16BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_32BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_64BEAT) || \ - ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_128BEAT)) -#define IS_ETH_DMA_DESC_SKIP_LENGTH(LENGTH) ((LENGTH) <= 0x1F) -#define IS_ETH_DMA_ARBITRATION_ROUNDROBIN_RXTX(RATIO) (((RATIO) == ETH_DMAARBITRATION_ROUNDROBIN_RXTX_1_1) || \ - ((RATIO) == ETH_DMAARBITRATION_ROUNDROBIN_RXTX_2_1) || \ - ((RATIO) == ETH_DMAARBITRATION_ROUNDROBIN_RXTX_3_1) || \ - ((RATIO) == ETH_DMAARBITRATION_ROUNDROBIN_RXTX_4_1) || \ - ((RATIO) == ETH_DMAARBITRATION_RXPRIORTX)) -#define IS_ETH_DMATXDESC_GET_FLAG(FLAG) (((FLAG) == ETH_DMATXDESC_OWN) || \ - ((FLAG) == ETH_DMATXDESC_IC) || \ - ((FLAG) == ETH_DMATXDESC_LS) || \ - ((FLAG) == ETH_DMATXDESC_FS) || \ - ((FLAG) == ETH_DMATXDESC_DC) || \ - ((FLAG) == ETH_DMATXDESC_DP) || \ - ((FLAG) == ETH_DMATXDESC_TTSE) || \ - ((FLAG) == ETH_DMATXDESC_TER) || \ - ((FLAG) == ETH_DMATXDESC_TCH) || \ - ((FLAG) == ETH_DMATXDESC_TTSS) || \ - ((FLAG) == ETH_DMATXDESC_IHE) || \ - ((FLAG) == ETH_DMATXDESC_ES) || \ - ((FLAG) == ETH_DMATXDESC_JT) || \ - ((FLAG) == ETH_DMATXDESC_FF) || \ - ((FLAG) == ETH_DMATXDESC_PCE) || \ - ((FLAG) == ETH_DMATXDESC_LCA) || \ - ((FLAG) == ETH_DMATXDESC_NC) || \ - ((FLAG) == ETH_DMATXDESC_LCO) || \ - ((FLAG) == ETH_DMATXDESC_EC) || \ - ((FLAG) == ETH_DMATXDESC_VF) || \ - ((FLAG) == ETH_DMATXDESC_CC) || \ - ((FLAG) == ETH_DMATXDESC_ED) || \ - ((FLAG) == ETH_DMATXDESC_UF) || \ - ((FLAG) == ETH_DMATXDESC_DB)) -#define IS_ETH_DMA_TXDESC_SEGMENT(SEGMENT) (((SEGMENT) == ETH_DMATXDESC_LASTSEGMENTS) || \ - ((SEGMENT) == ETH_DMATXDESC_FIRSTSEGMENT)) -#define IS_ETH_DMA_TXDESC_CHECKSUM(CHECKSUM) (((CHECKSUM) == ETH_DMATXDESC_CHECKSUMBYPASS) || \ - ((CHECKSUM) == ETH_DMATXDESC_CHECKSUMIPV4HEADER) || \ - ((CHECKSUM) == ETH_DMATXDESC_CHECKSUMTCPUDPICMPSEGMENT) || \ - ((CHECKSUM) == ETH_DMATXDESC_CHECKSUMTCPUDPICMPFULL)) -#define IS_ETH_DMATXDESC_BUFFER_SIZE(SIZE) ((SIZE) <= 0x1FFF) -#define IS_ETH_DMARXDESC_GET_FLAG(FLAG) (((FLAG) == ETH_DMARXDESC_OWN) || \ - ((FLAG) == ETH_DMARXDESC_AFM) || \ - ((FLAG) == ETH_DMARXDESC_ES) || \ - ((FLAG) == ETH_DMARXDESC_DE) || \ - ((FLAG) == ETH_DMARXDESC_SAF) || \ - ((FLAG) == ETH_DMARXDESC_LE) || \ - ((FLAG) == ETH_DMARXDESC_OE) || \ - ((FLAG) == ETH_DMARXDESC_VLAN) || \ - ((FLAG) == ETH_DMARXDESC_FS) || \ - ((FLAG) == ETH_DMARXDESC_LS) || \ - ((FLAG) == ETH_DMARXDESC_IPV4HCE) || \ - ((FLAG) == ETH_DMARXDESC_LC) || \ - ((FLAG) == ETH_DMARXDESC_FT) || \ - ((FLAG) == ETH_DMARXDESC_RWT) || \ - ((FLAG) == ETH_DMARXDESC_RE) || \ - ((FLAG) == ETH_DMARXDESC_DBE) || \ - ((FLAG) == ETH_DMARXDESC_CE) || \ - ((FLAG) == ETH_DMARXDESC_MAMPCE)) -#define IS_ETH_DMA_RXDESC_BUFFER(BUFFER) (((BUFFER) == ETH_DMARXDESC_BUFFER1) || \ - ((BUFFER) == ETH_DMARXDESC_BUFFER2)) -#define IS_ETH_PMT_GET_FLAG(FLAG) (((FLAG) == ETH_PMT_FLAG_WUFR) || \ - ((FLAG) == ETH_PMT_FLAG_MPR)) -#define IS_ETH_DMA_FLAG(FLAG) ((((FLAG) & (uint32_t)0xC7FE1800) == 0x00) && ((FLAG) != 0x00)) -#define IS_ETH_DMA_GET_FLAG(FLAG) (((FLAG) == ETH_DMA_FLAG_TST) || ((FLAG) == ETH_DMA_FLAG_PMT) || \ - ((FLAG) == ETH_DMA_FLAG_MMC) || ((FLAG) == ETH_DMA_FLAG_DATATRANSFERERROR) || \ - ((FLAG) == ETH_DMA_FLAG_READWRITEERROR) || ((FLAG) == ETH_DMA_FLAG_ACCESSERROR) || \ - ((FLAG) == ETH_DMA_FLAG_NIS) || ((FLAG) == ETH_DMA_FLAG_AIS) || \ - ((FLAG) == ETH_DMA_FLAG_ER) || ((FLAG) == ETH_DMA_FLAG_FBE) || \ - ((FLAG) == ETH_DMA_FLAG_ET) || ((FLAG) == ETH_DMA_FLAG_RWT) || \ - ((FLAG) == ETH_DMA_FLAG_RPS) || ((FLAG) == ETH_DMA_FLAG_RBU) || \ - ((FLAG) == ETH_DMA_FLAG_R) || ((FLAG) == ETH_DMA_FLAG_TU) || \ - ((FLAG) == ETH_DMA_FLAG_RO) || ((FLAG) == ETH_DMA_FLAG_TJT) || \ - ((FLAG) == ETH_DMA_FLAG_TBU) || ((FLAG) == ETH_DMA_FLAG_TPS) || \ - ((FLAG) == ETH_DMA_FLAG_T)) -#define IS_ETH_MAC_IT(IT) ((((IT) & (uint32_t)0xFFFFFDF1) == 0x00) && ((IT) != 0x00)) -#define IS_ETH_MAC_GET_IT(IT) (((IT) == ETH_MAC_IT_TST) || ((IT) == ETH_MAC_IT_MMCT) || \ - ((IT) == ETH_MAC_IT_MMCR) || ((IT) == ETH_MAC_IT_MMC) || \ - ((IT) == ETH_MAC_IT_PMT)) -#define IS_ETH_MAC_GET_FLAG(FLAG) (((FLAG) == ETH_MAC_FLAG_TST) || ((FLAG) == ETH_MAC_FLAG_MMCT) || \ - ((FLAG) == ETH_MAC_FLAG_MMCR) || ((FLAG) == ETH_MAC_FLAG_MMC) || \ - ((FLAG) == ETH_MAC_FLAG_PMT)) -#define IS_ETH_DMA_IT(IT) ((((IT) & (uint32_t)0xC7FE1800) == 0x00) && ((IT) != 0x00)) -#define IS_ETH_DMA_GET_IT(IT) (((IT) == ETH_DMA_IT_TST) || ((IT) == ETH_DMA_IT_PMT) || \ - ((IT) == ETH_DMA_IT_MMC) || ((IT) == ETH_DMA_IT_NIS) || \ - ((IT) == ETH_DMA_IT_AIS) || ((IT) == ETH_DMA_IT_ER) || \ - ((IT) == ETH_DMA_IT_FBE) || ((IT) == ETH_DMA_IT_ET) || \ - ((IT) == ETH_DMA_IT_RWT) || ((IT) == ETH_DMA_IT_RPS) || \ - ((IT) == ETH_DMA_IT_RBU) || ((IT) == ETH_DMA_IT_R) || \ - ((IT) == ETH_DMA_IT_TU) || ((IT) == ETH_DMA_IT_RO) || \ - ((IT) == ETH_DMA_IT_TJT) || ((IT) == ETH_DMA_IT_TBU) || \ - ((IT) == ETH_DMA_IT_TPS) || ((IT) == ETH_DMA_IT_T)) -#define IS_ETH_DMA_GET_OVERFLOW(OVERFLOW) (((OVERFLOW) == ETH_DMA_OVERFLOW_RXFIFOCOUNTER) || \ - ((OVERFLOW) == ETH_DMA_OVERFLOW_MISSEDFRAMECOUNTER)) -#define IS_ETH_MMC_IT(IT) (((((IT) & (uint32_t)0xFFDF3FFF) == 0x00) || (((IT) & (uint32_t)0xEFFDFF9F) == 0x00)) && \ - ((IT) != 0x00)) -#define IS_ETH_MMC_GET_IT(IT) (((IT) == ETH_MMC_IT_TGF) || ((IT) == ETH_MMC_IT_TGFMSC) || \ - ((IT) == ETH_MMC_IT_TGFSC) || ((IT) == ETH_MMC_IT_RGUF) || \ - ((IT) == ETH_MMC_IT_RFAE) || ((IT) == ETH_MMC_IT_RFCE)) -#define IS_ETH_ENHANCED_DESCRIPTOR_FORMAT(CMD) (((CMD) == ETH_DMAENHANCEDDESCRIPTOR_ENABLE) || \ - ((CMD) == ETH_DMAENHANCEDDESCRIPTOR_DISABLE)) - - -/** - * @} - */ - -/** @addtogroup ETH_Private_Defines - * @{ - */ -/* Delay to wait when writing to some Ethernet registers */ -#define ETH_REG_WRITE_DELAY ((uint32_t)0x00000001) - -/* ETHERNET Errors */ -#define ETH_SUCCESS ((uint32_t)0) -#define ETH_ERROR ((uint32_t)1) - -/* ETHERNET DMA Tx descriptors Collision Count Shift */ -#define ETH_DMATXDESC_COLLISION_COUNTSHIFT ((uint32_t)3) - -/* ETHERNET DMA Tx descriptors Buffer2 Size Shift */ -#define ETH_DMATXDESC_BUFFER2_SIZESHIFT ((uint32_t)16) - -/* ETHERNET DMA Rx descriptors Frame Length Shift */ -#define ETH_DMARXDESC_FRAME_LENGTHSHIFT ((uint32_t)16) - -/* ETHERNET DMA Rx descriptors Buffer2 Size Shift */ -#define ETH_DMARXDESC_BUFFER2_SIZESHIFT ((uint32_t)16) - -/* ETHERNET DMA Rx descriptors Frame length Shift */ -#define ETH_DMARXDESC_FRAMELENGTHSHIFT ((uint32_t)16) - -/* ETHERNET MAC address offsets */ -#define ETH_MAC_ADDR_HBASE (uint32_t)(ETH_MAC_BASE + (uint32_t)0x40) /* ETHERNET MAC address high offset */ -#define ETH_MAC_ADDR_LBASE (uint32_t)(ETH_MAC_BASE + (uint32_t)0x44) /* ETHERNET MAC address low offset */ - -/* ETHERNET MACMIIAR register Mask */ -#define ETH_MACMIIAR_CR_MASK ((uint32_t)0xFFFFFFE3) - -/* ETHERNET MACCR register Mask */ -#define ETH_MACCR_CLEAR_MASK ((uint32_t)0xFF20810F) - -/* ETHERNET MACFCR register Mask */ -#define ETH_MACFCR_CLEAR_MASK ((uint32_t)0x0000FF41) - -/* ETHERNET DMAOMR register Mask */ -#define ETH_DMAOMR_CLEAR_MASK ((uint32_t)0xF8DE3F23) - -/* ETHERNET Remote Wake-up frame register length */ -#define ETH_WAKEUP_REGISTER_LENGTH 8 - -/* ETHERNET Missed frames counter Shift */ -#define ETH_DMA_RX_OVERFLOW_MISSEDFRAMES_COUNTERSHIFT 17 - /** - * @} - */ - -/* Exported types ------------------------------------------------------------*/ -/** @defgroup ETH_Exported_Types ETH Exported Types - * @{ - */ - -/** - * @brief HAL State structures definition - */ -typedef enum -{ - HAL_ETH_STATE_RESET = 0x00, /*!< Peripheral not yet Initialized or disabled */ - HAL_ETH_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ - HAL_ETH_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ - HAL_ETH_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ - HAL_ETH_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ - HAL_ETH_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */ - HAL_ETH_STATE_BUSY_WR = 0x42, /*!< Write process is ongoing */ - HAL_ETH_STATE_BUSY_RD = 0x82, /*!< Read process is ongoing */ - HAL_ETH_STATE_TIMEOUT = 0x03, /*!< Timeout state */ - HAL_ETH_STATE_ERROR = 0x04 /*!< Reception process is ongoing */ -}HAL_ETH_StateTypeDef; - -/** - * @brief ETH Init Structure definition - */ - -typedef struct -{ - uint32_t AutoNegotiation; /*!< Selects or not the AutoNegotiation mode for the external PHY - The AutoNegotiation allows an automatic setting of the Speed (10/100Mbps) - and the mode (half/full-duplex). - This parameter can be a value of @ref ETH_AutoNegotiation */ - - uint32_t Speed; /*!< Sets the Ethernet speed: 10/100 Mbps. - This parameter can be a value of @ref ETH_Speed */ - - uint32_t DuplexMode; /*!< Selects the MAC duplex mode: Half-Duplex or Full-Duplex mode - This parameter can be a value of @ref ETH_Duplex_Mode */ - - uint16_t PhyAddress; /*!< Ethernet PHY address. - This parameter must be a number between Min_Data = 0 and Max_Data = 32 */ - - uint8_t *MACAddr; /*!< MAC Address of used Hardware: must be pointer on an array of 6 bytes */ - - uint32_t RxMode; /*!< Selects the Ethernet Rx mode: Polling mode, Interrupt mode. - This parameter can be a value of @ref ETH_Rx_Mode */ - - uint32_t ChecksumMode; /*!< Selects if the checksum is check by hardware or by software. - This parameter can be a value of @ref ETH_Checksum_Mode */ - - uint32_t MediaInterface ; /*!< Selects the media-independent interface or the reduced media-independent interface. - This parameter can be a value of @ref ETH_Media_Interface */ - -} ETH_InitTypeDef; - - - /** - * @brief ETH MAC Configuration Structure definition - */ - -typedef struct -{ - uint32_t Watchdog; /*!< Selects or not the Watchdog timer - When enabled, the MAC allows no more then 2048 bytes to be received. - When disabled, the MAC can receive up to 16384 bytes. - This parameter can be a value of @ref ETH_Watchdog */ - - uint32_t Jabber; /*!< Selects or not Jabber timer - When enabled, the MAC allows no more then 2048 bytes to be sent. - When disabled, the MAC can send up to 16384 bytes. - This parameter can be a value of @ref ETH_Jabber */ - - uint32_t InterFrameGap; /*!< Selects the minimum IFG between frames during transmission. - This parameter can be a value of @ref ETH_Inter_Frame_Gap */ - - uint32_t CarrierSense; /*!< Selects or not the Carrier Sense. - This parameter can be a value of @ref ETH_Carrier_Sense */ - - uint32_t ReceiveOwn; /*!< Selects or not the ReceiveOwn, - ReceiveOwn allows the reception of frames when the TX_EN signal is asserted - in Half-Duplex mode. - This parameter can be a value of @ref ETH_Receive_Own */ - - uint32_t LoopbackMode; /*!< Selects or not the internal MAC MII Loopback mode. - This parameter can be a value of @ref ETH_Loop_Back_Mode */ - - uint32_t ChecksumOffload; /*!< Selects or not the IPv4 checksum checking for received frame payloads' TCP/UDP/ICMP headers. - This parameter can be a value of @ref ETH_Checksum_Offload */ - - uint32_t RetryTransmission; /*!< Selects or not the MAC attempt retries transmission, based on the settings of BL, - when a collision occurs (Half-Duplex mode). - This parameter can be a value of @ref ETH_Retry_Transmission */ - - uint32_t AutomaticPadCRCStrip; /*!< Selects or not the Automatic MAC Pad/CRC Stripping. - This parameter can be a value of @ref ETH_Automatic_Pad_CRC_Strip */ - - uint32_t BackOffLimit; /*!< Selects the BackOff limit value. - This parameter can be a value of @ref ETH_Back_Off_Limit */ - - uint32_t DeferralCheck; /*!< Selects or not the deferral check function (Half-Duplex mode). - This parameter can be a value of @ref ETH_Deferral_Check */ - - uint32_t ReceiveAll; /*!< Selects or not all frames reception by the MAC (No filtering). - This parameter can be a value of @ref ETH_Receive_All */ - - uint32_t SourceAddrFilter; /*!< Selects the Source Address Filter mode. - This parameter can be a value of @ref ETH_Source_Addr_Filter */ - - uint32_t PassControlFrames; /*!< Sets the forwarding mode of the control frames (including unicast and multicast PAUSE frames) - This parameter can be a value of @ref ETH_Pass_Control_Frames */ - - uint32_t BroadcastFramesReception; /*!< Selects or not the reception of Broadcast Frames. - This parameter can be a value of @ref ETH_Broadcast_Frames_Reception */ - - uint32_t DestinationAddrFilter; /*!< Sets the destination filter mode for both unicast and multicast frames. - This parameter can be a value of @ref ETH_Destination_Addr_Filter */ - - uint32_t PromiscuousMode; /*!< Selects or not the Promiscuous Mode - This parameter can be a value of @ref ETH_Promiscuous_Mode */ - - uint32_t MulticastFramesFilter; /*!< Selects the Multicast Frames filter mode: None/HashTableFilter/PerfectFilter/PerfectHashTableFilter. - This parameter can be a value of @ref ETH_Multicast_Frames_Filter */ - - uint32_t UnicastFramesFilter; /*!< Selects the Unicast Frames filter mode: HashTableFilter/PerfectFilter/PerfectHashTableFilter. - This parameter can be a value of @ref ETH_Unicast_Frames_Filter */ - - uint32_t HashTableHigh; /*!< This field holds the higher 32 bits of Hash table. - This parameter must be a number between Min_Data = 0x0 and Max_Data = 0xFFFFFFFF */ - - uint32_t HashTableLow; /*!< This field holds the lower 32 bits of Hash table. - This parameter must be a number between Min_Data = 0x0 and Max_Data = 0xFFFFFFFF */ - - uint32_t PauseTime; /*!< This field holds the value to be used in the Pause Time field in the transmit control frame. - This parameter must be a number between Min_Data = 0x0 and Max_Data = 0xFFFF */ - - uint32_t ZeroQuantaPause; /*!< Selects or not the automatic generation of Zero-Quanta Pause Control frames. - This parameter can be a value of @ref ETH_Zero_Quanta_Pause */ - - uint32_t PauseLowThreshold; /*!< This field configures the threshold of the PAUSE to be checked for - automatic retransmission of PAUSE Frame. - This parameter can be a value of @ref ETH_Pause_Low_Threshold */ - - uint32_t UnicastPauseFrameDetect; /*!< Selects or not the MAC detection of the Pause frames (with MAC Address0 - unicast address and unique multicast address). - This parameter can be a value of @ref ETH_Unicast_Pause_Frame_Detect */ - - uint32_t ReceiveFlowControl; /*!< Enables or disables the MAC to decode the received Pause frame and - disable its transmitter for a specified time (Pause Time) - This parameter can be a value of @ref ETH_Receive_Flow_Control */ - - uint32_t TransmitFlowControl; /*!< Enables or disables the MAC to transmit Pause frames (Full-Duplex mode) - or the MAC back-pressure operation (Half-Duplex mode) - This parameter can be a value of @ref ETH_Transmit_Flow_Control */ - - uint32_t VLANTagComparison; /*!< Selects the 12-bit VLAN identifier or the complete 16-bit VLAN tag for - comparison and filtering. - This parameter can be a value of @ref ETH_VLAN_Tag_Comparison */ - - uint32_t VLANTagIdentifier; /*!< Holds the VLAN tag identifier for receive frames */ - -} ETH_MACInitTypeDef; - - -/** - * @brief ETH DMA Configuration Structure definition - */ - -typedef struct -{ - uint32_t DropTCPIPChecksumErrorFrame; /*!< Selects or not the Dropping of TCP/IP Checksum Error Frames. - This parameter can be a value of @ref ETH_Drop_TCP_IP_Checksum_Error_Frame */ - - uint32_t ReceiveStoreForward; /*!< Enables or disables the Receive store and forward mode. - This parameter can be a value of @ref ETH_Receive_Store_Forward */ - - uint32_t FlushReceivedFrame; /*!< Enables or disables the flushing of received frames. - This parameter can be a value of @ref ETH_Flush_Received_Frame */ - - uint32_t TransmitStoreForward; /*!< Enables or disables Transmit store and forward mode. - This parameter can be a value of @ref ETH_Transmit_Store_Forward */ - - uint32_t TransmitThresholdControl; /*!< Selects or not the Transmit Threshold Control. - This parameter can be a value of @ref ETH_Transmit_Threshold_Control */ - - uint32_t ForwardErrorFrames; /*!< Selects or not the forward to the DMA of erroneous frames. - This parameter can be a value of @ref ETH_Forward_Error_Frames */ - - uint32_t ForwardUndersizedGoodFrames; /*!< Enables or disables the Rx FIFO to forward Undersized frames (frames with no Error - and length less than 64 bytes) including pad-bytes and CRC) - This parameter can be a value of @ref ETH_Forward_Undersized_Good_Frames */ - - uint32_t ReceiveThresholdControl; /*!< Selects the threshold level of the Receive FIFO. - This parameter can be a value of @ref ETH_Receive_Threshold_Control */ - - uint32_t SecondFrameOperate; /*!< Selects or not the Operate on second frame mode, which allows the DMA to process a second - frame of Transmit data even before obtaining the status for the first frame. - This parameter can be a value of @ref ETH_Second_Frame_Operate */ - - uint32_t AddressAlignedBeats; /*!< Enables or disables the Address Aligned Beats. - This parameter can be a value of @ref ETH_Address_Aligned_Beats */ - - uint32_t FixedBurst; /*!< Enables or disables the AHB Master interface fixed burst transfers. - This parameter can be a value of @ref ETH_Fixed_Burst */ - - uint32_t RxDMABurstLength; /*!< Indicates the maximum number of beats to be transferred in one Rx DMA transaction. - This parameter can be a value of @ref ETH_Rx_DMA_Burst_Length */ - - uint32_t TxDMABurstLength; /*!< Indicates the maximum number of beats to be transferred in one Tx DMA transaction. - This parameter can be a value of @ref ETH_Tx_DMA_Burst_Length */ - - uint32_t EnhancedDescriptorFormat; /*!< Enables the enhanced descriptor format. - This parameter can be a value of @ref ETH_DMA_Enhanced_descriptor_format */ - - uint32_t DescriptorSkipLength; /*!< Specifies the number of word to skip between two unchained descriptors (Ring mode) - This parameter must be a number between Min_Data = 0 and Max_Data = 32 */ - - uint32_t DMAArbitration; /*!< Selects the DMA Tx/Rx arbitration. - This parameter can be a value of @ref ETH_DMA_Arbitration */ -} ETH_DMAInitTypeDef; - - -/** - * @brief ETH DMA Descriptors data structure definition - */ - -typedef struct -{ - __IO uint32_t Status; /*!< Status */ - - uint32_t ControlBufferSize; /*!< Control and Buffer1, Buffer2 lengths */ - - uint32_t Buffer1Addr; /*!< Buffer1 address pointer */ - - uint32_t Buffer2NextDescAddr; /*!< Buffer2 or next descriptor address pointer */ - - /*!< Enhanced ETHERNET DMA PTP Descriptors */ - uint32_t ExtendedStatus; /*!< Extended status for PTP receive descriptor */ - - uint32_t Reserved1; /*!< Reserved */ - - uint32_t TimeStampLow; /*!< Time Stamp Low value for transmit and receive */ - - uint32_t TimeStampHigh; /*!< Time Stamp High value for transmit and receive */ - -} ETH_DMADescTypeDef; - - -/** - * @brief Received Frame Informations structure definition - */ -typedef struct -{ - ETH_DMADescTypeDef *FSRxDesc; /*!< First Segment Rx Desc */ - - ETH_DMADescTypeDef *LSRxDesc; /*!< Last Segment Rx Desc */ - - uint32_t SegCount; /*!< Segment count */ - - uint32_t length; /*!< Frame length */ - - uint32_t buffer; /*!< Frame buffer */ - -} ETH_DMARxFrameInfos; - - -/** - * @brief ETH Handle Structure definition - */ - -typedef struct -{ - ETH_TypeDef *Instance; /*!< Register base address */ - - ETH_InitTypeDef Init; /*!< Ethernet Init Configuration */ - - uint32_t LinkStatus; /*!< Ethernet link status */ - - ETH_DMADescTypeDef *RxDesc; /*!< Rx descriptor to Get */ - - ETH_DMADescTypeDef *TxDesc; /*!< Tx descriptor to Set */ - - ETH_DMARxFrameInfos RxFrameInfos; /*!< last Rx frame infos */ - - __IO HAL_ETH_StateTypeDef State; /*!< ETH communication state */ - - HAL_LockTypeDef Lock; /*!< ETH Lock */ - -} ETH_HandleTypeDef; - - /** - * @} - */ - -/* Exported constants --------------------------------------------------------*/ -/** @defgroup ETH_Exported_Constants ETH Exported Constants - * @{ - */ - -/** @defgroup ETH_Buffers_setting ETH Buffers setting - * @{ - */ -#define ETH_MAX_PACKET_SIZE (1536u) /*!< ETH_HEADER + ETH_EXTRA + ETH_VLAN_TAG + ETH_MAX_ETH_PAYLOAD + ETH_CRC */ -#define ETH_HEADER ((uint32_t)14) /*!< 6 byte Dest addr, 6 byte Src addr, 2 byte length/type */ -#define ETH_CRC ((uint32_t)4) /*!< Ethernet CRC */ -#define ETH_EXTRA ((uint32_t)2) /*!< Extra bytes in some cases */ -#define ETH_VLAN_TAG ((uint32_t)4) /*!< optional 802.1q VLAN Tag */ -#define ETH_MIN_ETH_PAYLOAD ((uint32_t)46) /*!< Minimum Ethernet payload size */ -#define ETH_MAX_ETH_PAYLOAD ((uint32_t)1500) /*!< Maximum Ethernet payload size */ -#define ETH_JUMBO_FRAME_PAYLOAD ((uint32_t)9000) /*!< Jumbo frame payload size */ - - /* Ethernet driver receive buffers are organized in a chained linked-list, when - an ethernet packet is received, the Rx-DMA will transfer the packet from RxFIFO - to the driver receive buffers memory. - - Depending on the size of the received ethernet packet and the size of - each ethernet driver receive buffer, the received packet can take one or more - ethernet driver receive buffer. - - In below are defined the size of one ethernet driver receive buffer ETH_RX_BUF_SIZE - and the total count of the driver receive buffers ETH_RXBUFNB. - - The configured value for ETH_RX_BUF_SIZE and ETH_RXBUFNB are only provided as - example, they can be reconfigured in the application layer to fit the application - needs */ - -/* Here we configure each Ethernet driver receive buffer to fit the Max size Ethernet - packet */ -#ifndef ETH_RX_BUF_SIZE - #error please define ETH_RX_BUF_SIZE - #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE -#endif - -/* 5 Ethernet driver receive buffers are used (in a chained linked list)*/ -#ifndef ETH_RXBUFNB - #define ETH_RXBUFNB ((uint32_t)5 /* 5 Rx buffers of size ETH_RX_BUF_SIZE */ -#endif - - - /* Ethernet driver transmit buffers are organized in a chained linked-list, when - an ethernet packet is transmitted, Tx-DMA will transfer the packet from the - driver transmit buffers memory to the TxFIFO. - - Depending on the size of the Ethernet packet to be transmitted and the size of - each ethernet driver transmit buffer, the packet to be transmitted can take - one or more ethernet driver transmit buffer. - - In below are defined the size of one ethernet driver transmit buffer ETH_TX_BUF_SIZE - and the total count of the driver transmit buffers ETH_TXBUFNB. - - The configured value for ETH_TX_BUF_SIZE and ETH_TXBUFNB are only provided as - example, they can be reconfigured in the application layer to fit the application - needs */ - -/* Here we configure each Ethernet driver transmit buffer to fit the Max size Ethernet - packet */ -#ifndef ETH_TX_BUF_SIZE - #error please define ETH_TX_BUF_SIZE - #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE -#endif - -/* 5 ethernet driver transmit buffers are used (in a chained linked list)*/ -#ifndef ETH_TXBUFNB - #define ETH_TXBUFNB ((uint32_t)5 /* 5 Tx buffers of size ETH_TX_BUF_SIZE */ -#endif - - /** - * @} - */ - -/** @defgroup ETH_DMA_TX_Descriptor ETH DMA TX Descriptor - * @{ - */ - -/* - DMA Tx Descriptor - ----------------------------------------------------------------------------------------------- - TDES0 | OWN(31) | CTRL[30:26] | Reserved[25:24] | CTRL[23:20] | Reserved[19:17] | Status[16:0] | - ----------------------------------------------------------------------------------------------- - TDES1 | Reserved[31:29] | Buffer2 ByteCount[28:16] | Reserved[15:13] | Buffer1 ByteCount[12:0] | - ----------------------------------------------------------------------------------------------- - TDES2 | Buffer1 Address [31:0] | - ----------------------------------------------------------------------------------------------- - TDES3 | Buffer2 Address [31:0] / Next Descriptor Address [31:0] | - ----------------------------------------------------------------------------------------------- -*/ - -/** - * @brief Bit definition of TDES0 register: DMA Tx descriptor status register - */ -#define ETH_DMATXDESC_OWN ((uint32_t)0x80000000) /*!< OWN bit: descriptor is owned by DMA engine */ -#define ETH_DMATXDESC_IC ((uint32_t)0x40000000) /*!< Interrupt on Completion */ -#define ETH_DMATXDESC_LS ((uint32_t)0x20000000) /*!< Last Segment */ -#define ETH_DMATXDESC_FS ((uint32_t)0x10000000) /*!< First Segment */ -#define ETH_DMATXDESC_DC ((uint32_t)0x08000000) /*!< Disable CRC */ -#define ETH_DMATXDESC_DP ((uint32_t)0x04000000) /*!< Disable Padding */ -#define ETH_DMATXDESC_TTSE ((uint32_t)0x02000000) /*!< Transmit Time Stamp Enable */ -#define ETH_DMATXDESC_CIC ((uint32_t)0x00C00000) /*!< Checksum Insertion Control: 4 cases */ -#define ETH_DMATXDESC_CIC_BYPASS ((uint32_t)0x00000000) /*!< Do Nothing: Checksum Engine is bypassed */ -#define ETH_DMATXDESC_CIC_IPV4HEADER ((uint32_t)0x00400000) /*!< IPV4 header Checksum Insertion */ -#define ETH_DMATXDESC_CIC_TCPUDPICMP_SEGMENT ((uint32_t)0x00800000) /*!< TCP/UDP/ICMP Checksum Insertion calculated over segment only */ -#define ETH_DMATXDESC_CIC_TCPUDPICMP_FULL ((uint32_t)0x00C00000) /*!< TCP/UDP/ICMP Checksum Insertion fully calculated */ -#define ETH_DMATXDESC_TER ((uint32_t)0x00200000) /*!< Transmit End of Ring */ -#define ETH_DMATXDESC_TCH ((uint32_t)0x00100000) /*!< Second Address Chained */ -#define ETH_DMATXDESC_TTSS ((uint32_t)0x00020000) /*!< Tx Time Stamp Status */ -#define ETH_DMATXDESC_IHE ((uint32_t)0x00010000) /*!< IP Header Error */ -#define ETH_DMATXDESC_ES ((uint32_t)0x00008000) /*!< Error summary: OR of the following bits: UE || ED || EC || LCO || NC || LCA || FF || JT */ -#define ETH_DMATXDESC_JT ((uint32_t)0x00004000) /*!< Jabber Timeout */ -#define ETH_DMATXDESC_FF ((uint32_t)0x00002000) /*!< Frame Flushed: DMA/MTL flushed the frame due to SW flush */ -#define ETH_DMATXDESC_PCE ((uint32_t)0x00001000) /*!< Payload Checksum Error */ -#define ETH_DMATXDESC_LCA ((uint32_t)0x00000800) /*!< Loss of Carrier: carrier lost during transmission */ -#define ETH_DMATXDESC_NC ((uint32_t)0x00000400) /*!< No Carrier: no carrier signal from the transceiver */ -#define ETH_DMATXDESC_LCO ((uint32_t)0x00000200) /*!< Late Collision: transmission aborted due to collision */ -#define ETH_DMATXDESC_EC ((uint32_t)0x00000100) /*!< Excessive Collision: transmission aborted after 16 collisions */ -#define ETH_DMATXDESC_VF ((uint32_t)0x00000080) /*!< VLAN Frame */ -#define ETH_DMATXDESC_CC ((uint32_t)0x00000078) /*!< Collision Count */ -#define ETH_DMATXDESC_ED ((uint32_t)0x00000004) /*!< Excessive Deferral */ -#define ETH_DMATXDESC_UF ((uint32_t)0x00000002) /*!< Underflow Error: late data arrival from the memory */ -#define ETH_DMATXDESC_DB ((uint32_t)0x00000001) /*!< Deferred Bit */ - -/** - * @brief Bit definition of TDES1 register - */ -#define ETH_DMATXDESC_TBS2 ((uint32_t)0x1FFF0000) /*!< Transmit Buffer2 Size */ -#define ETH_DMATXDESC_TBS1 ((uint32_t)0x00001FFF) /*!< Transmit Buffer1 Size */ - -/** - * @brief Bit definition of TDES2 register - */ -#define ETH_DMATXDESC_B1AP ((uint32_t)0xFFFFFFFF) /*!< Buffer1 Address Pointer */ - -/** - * @brief Bit definition of TDES3 register - */ -#define ETH_DMATXDESC_B2AP ((uint32_t)0xFFFFFFFF) /*!< Buffer2 Address Pointer */ - - /*--------------------------------------------------------------------------------------------- - TDES6 | Transmit Time Stamp Low [31:0] | - ----------------------------------------------------------------------------------------------- - TDES7 | Transmit Time Stamp High [31:0] | - ----------------------------------------------------------------------------------------------*/ - -/* Bit definition of TDES6 register */ - #define ETH_DMAPTPTXDESC_TTSL ((uint32_t)0xFFFFFFFF) /* Transmit Time Stamp Low */ - -/* Bit definition of TDES7 register */ - #define ETH_DMAPTPTXDESC_TTSH ((uint32_t)0xFFFFFFFF) /* Transmit Time Stamp High */ - -/** - * @} - */ -/** @defgroup ETH_DMA_RX_Descriptor ETH DMA RX Descriptor - * @{ - */ - -/* - DMA Rx Descriptor - -------------------------------------------------------------------------------------------------------------------- - RDES0 | OWN(31) | Status [30:0] | - --------------------------------------------------------------------------------------------------------------------- - RDES1 | CTRL(31) | Reserved[30:29] | Buffer2 ByteCount[28:16] | CTRL[15:14] | Reserved(13) | Buffer1 ByteCount[12:0] | - --------------------------------------------------------------------------------------------------------------------- - RDES2 | Buffer1 Address [31:0] | - --------------------------------------------------------------------------------------------------------------------- - RDES3 | Buffer2 Address [31:0] / Next Descriptor Address [31:0] | - --------------------------------------------------------------------------------------------------------------------- -*/ - -/** - * @brief Bit definition of RDES0 register: DMA Rx descriptor status register - */ -#define ETH_DMARXDESC_OWN ((uint32_t)0x80000000) /*!< OWN bit: descriptor is owned by DMA engine */ -#define ETH_DMARXDESC_AFM ((uint32_t)0x40000000) /*!< DA Filter Fail for the rx frame */ -#define ETH_DMARXDESC_FL ((uint32_t)0x3FFF0000) /*!< Receive descriptor frame length */ -#define ETH_DMARXDESC_ES ((uint32_t)0x00008000) /*!< Error summary: OR of the following bits: DE || OE || IPC || LC || RWT || RE || CE */ -#define ETH_DMARXDESC_DE ((uint32_t)0x00004000) /*!< Descriptor error: no more descriptors for receive frame */ -#define ETH_DMARXDESC_SAF ((uint32_t)0x00002000) /*!< SA Filter Fail for the received frame */ -#define ETH_DMARXDESC_LE ((uint32_t)0x00001000) /*!< Frame size not matching with length field */ -#define ETH_DMARXDESC_OE ((uint32_t)0x00000800) /*!< Overflow Error: Frame was damaged due to buffer overflow */ -#define ETH_DMARXDESC_VLAN ((uint32_t)0x00000400) /*!< VLAN Tag: received frame is a VLAN frame */ -#define ETH_DMARXDESC_FS ((uint32_t)0x00000200) /*!< First descriptor of the frame */ -#define ETH_DMARXDESC_LS ((uint32_t)0x00000100) /*!< Last descriptor of the frame */ -#define ETH_DMARXDESC_IPV4HCE ((uint32_t)0x00000080) /*!< IPC Checksum Error: Rx Ipv4 header checksum error */ -#define ETH_DMARXDESC_LC ((uint32_t)0x00000040) /*!< Late collision occurred during reception */ -#define ETH_DMARXDESC_FT ((uint32_t)0x00000020) /*!< Frame type - Ethernet, otherwise 802.3 */ -#define ETH_DMARXDESC_RWT ((uint32_t)0x00000010) /*!< Receive Watchdog Timeout: watchdog timer expired during reception */ -#define ETH_DMARXDESC_RE ((uint32_t)0x00000008) /*!< Receive error: error reported by MII interface */ -#define ETH_DMARXDESC_DBE ((uint32_t)0x00000004) /*!< Dribble bit error: frame contains non int multiple of 8 bits */ -#define ETH_DMARXDESC_CE ((uint32_t)0x00000002) /*!< CRC error */ -#define ETH_DMARXDESC_MAMPCE ((uint32_t)0x00000001) /*!< Rx MAC Address/Payload Checksum Error: Rx MAC address matched/ Rx Payload Checksum Error */ - -/** - * @brief Bit definition of RDES1 register - */ -#define ETH_DMARXDESC_DIC ((uint32_t)0x80000000) /*!< Disable Interrupt on Completion */ -#define ETH_DMARXDESC_RBS2 ((uint32_t)0x1FFF0000) /*!< Receive Buffer2 Size */ -#define ETH_DMARXDESC_RER ((uint32_t)0x00008000) /*!< Receive End of Ring */ -#define ETH_DMARXDESC_RCH ((uint32_t)0x00004000) /*!< Second Address Chained */ -#define ETH_DMARXDESC_RBS1 ((uint32_t)0x00001FFF) /*!< Receive Buffer1 Size */ - -/** - * @brief Bit definition of RDES2 register - */ -#define ETH_DMARXDESC_B1AP ((uint32_t)0xFFFFFFFF) /*!< Buffer1 Address Pointer */ - -/** - * @brief Bit definition of RDES3 register - */ -#define ETH_DMARXDESC_B2AP ((uint32_t)0xFFFFFFFF) /*!< Buffer2 Address Pointer */ - -/*--------------------------------------------------------------------------------------------------------------------- - RDES4 | Reserved[31:15] | Extended Status [14:0] | - --------------------------------------------------------------------------------------------------------------------- - RDES5 | Reserved[31:0] | - --------------------------------------------------------------------------------------------------------------------- - RDES6 | Receive Time Stamp Low [31:0] | - --------------------------------------------------------------------------------------------------------------------- - RDES7 | Receive Time Stamp High [31:0] | - --------------------------------------------------------------------------------------------------------------------*/ - -/* Bit definition of RDES4 register */ -#define ETH_DMAPTPRXDESC_PTPV ((uint32_t)0x00002000) /* PTP Version */ -#define ETH_DMAPTPRXDESC_PTPFT ((uint32_t)0x00001000) /* PTP Frame Type */ -#define ETH_DMAPTPRXDESC_PTPMT ((uint32_t)0x00000F00) /* PTP Message Type */ - #define ETH_DMAPTPRXDESC_PTPMT_SYNC ((uint32_t)0x00000100) /* SYNC message (all clock types) */ - #define ETH_DMAPTPRXDESC_PTPMT_FOLLOWUP ((uint32_t)0x00000200) /* FollowUp message (all clock types) */ - #define ETH_DMAPTPRXDESC_PTPMT_DELAYREQ ((uint32_t)0x00000300) /* DelayReq message (all clock types) */ - #define ETH_DMAPTPRXDESC_PTPMT_DELAYRESP ((uint32_t)0x00000400) /* DelayResp message (all clock types) */ - #define ETH_DMAPTPRXDESC_PTPMT_PDELAYREQ_ANNOUNCE ((uint32_t)0x00000500) /* PdelayReq message (peer-to-peer transparent clock) or Announce message (Ordinary or Boundary clock) */ - #define ETH_DMAPTPRXDESC_PTPMT_PDELAYRESP_MANAG ((uint32_t)0x00000600) /* PdelayResp message (peer-to-peer transparent clock) or Management message (Ordinary or Boundary clock) */ - #define ETH_DMAPTPRXDESC_PTPMT_PDELAYRESPFOLLOWUP_SIGNAL ((uint32_t)0x00000700) /* PdelayRespFollowUp message (peer-to-peer transparent clock) or Signaling message (Ordinary or Boundary clock) */ -#define ETH_DMAPTPRXDESC_IPV6PR ((uint32_t)0x00000080) /* IPv6 Packet Received */ -#define ETH_DMAPTPRXDESC_IPV4PR ((uint32_t)0x00000040) /* IPv4 Packet Received */ -#define ETH_DMAPTPRXDESC_IPCB ((uint32_t)0x00000020) /* IP Checksum Bypassed */ -#define ETH_DMAPTPRXDESC_IPPE ((uint32_t)0x00000010) /* IP Payload Error */ -#define ETH_DMAPTPRXDESC_IPHE ((uint32_t)0x00000008) /* IP Header Error */ -#define ETH_DMAPTPRXDESC_IPPT ((uint32_t)0x00000007) /* IP Payload Type */ - #define ETH_DMAPTPRXDESC_IPPT_UDP ((uint32_t)0x00000001) /* UDP payload encapsulated in the IP datagram */ - #define ETH_DMAPTPRXDESC_IPPT_TCP ((uint32_t)0x00000002) /* TCP payload encapsulated in the IP datagram */ - #define ETH_DMAPTPRXDESC_IPPT_ICMP ((uint32_t)0x00000003) /* ICMP payload encapsulated in the IP datagram */ - -/* Bit definition of RDES6 register */ -#define ETH_DMAPTPRXDESC_RTSL ((uint32_t)0xFFFFFFFF) /* Receive Time Stamp Low */ - -/* Bit definition of RDES7 register */ -#define ETH_DMAPTPRXDESC_RTSH ((uint32_t)0xFFFFFFFF) /* Receive Time Stamp High */ -/** - * @} - */ - /** @defgroup ETH_AutoNegotiation ETH AutoNegotiation - * @{ - */ -#define ETH_AUTONEGOTIATION_ENABLE ((uint32_t)0x00000001) -#define ETH_AUTONEGOTIATION_DISABLE ((uint32_t)0x00000000) - -/** - * @} - */ -/** @defgroup ETH_Speed ETH Speed - * @{ - */ -#define ETH_SPEED_10M ((uint32_t)0x00000000) -#define ETH_SPEED_100M ((uint32_t)0x00004000) - -/** - * @} - */ -/** @defgroup ETH_Duplex_Mode ETH Duplex Mode - * @{ - */ -#define ETH_MODE_FULLDUPLEX ((uint32_t)0x00000800) -#define ETH_MODE_HALFDUPLEX ((uint32_t)0x00000000) -/** - * @} - */ -/** @defgroup ETH_Rx_Mode ETH Rx Mode - * @{ - */ -#define ETH_RXPOLLING_MODE ((uint32_t)0x00000000) -#define ETH_RXINTERRUPT_MODE ((uint32_t)0x00000001) -/** - * @} - */ - -/** @defgroup ETH_Checksum_Mode ETH Checksum Mode - * @{ - */ -#define ETH_CHECKSUM_BY_HARDWARE ((uint32_t)0x00000000) -#define ETH_CHECKSUM_BY_SOFTWARE ((uint32_t)0x00000001) -/** - * @} - */ - -/** @defgroup ETH_Media_Interface ETH Media Interface - * @{ - */ -#define ETH_MEDIA_INTERFACE_MII ((uint32_t)0x00000000) -#define ETH_MEDIA_INTERFACE_RMII ((uint32_t)SYSCFG_PMC_MII_RMII_SEL) -/** - * @} - */ - -/** @defgroup ETH_Watchdog ETH Watchdog - * @{ - */ -#define ETH_WATCHDOG_ENABLE ((uint32_t)0x00000000) -#define ETH_WATCHDOG_DISABLE ((uint32_t)0x00800000) -/** - * @} - */ - -/** @defgroup ETH_Jabber ETH Jabber - * @{ - */ -#define ETH_JABBER_ENABLE ((uint32_t)0x00000000) -#define ETH_JABBER_DISABLE ((uint32_t)0x00400000) -/** - * @} - */ - -/** @defgroup ETH_Inter_Frame_Gap ETH Inter Frame Gap - * @{ - */ -#define ETH_INTERFRAMEGAP_96BIT ((uint32_t)0x00000000) /*!< minimum IFG between frames during transmission is 96Bit */ -#define ETH_INTERFRAMEGAP_88BIT ((uint32_t)0x00020000) /*!< minimum IFG between frames during transmission is 88Bit */ -#define ETH_INTERFRAMEGAP_80BIT ((uint32_t)0x00040000) /*!< minimum IFG between frames during transmission is 80Bit */ -#define ETH_INTERFRAMEGAP_72BIT ((uint32_t)0x00060000) /*!< minimum IFG between frames during transmission is 72Bit */ -#define ETH_INTERFRAMEGAP_64BIT ((uint32_t)0x00080000) /*!< minimum IFG between frames during transmission is 64Bit */ -#define ETH_INTERFRAMEGAP_56BIT ((uint32_t)0x000A0000) /*!< minimum IFG between frames during transmission is 56Bit */ -#define ETH_INTERFRAMEGAP_48BIT ((uint32_t)0x000C0000) /*!< minimum IFG between frames during transmission is 48Bit */ -#define ETH_INTERFRAMEGAP_40BIT ((uint32_t)0x000E0000) /*!< minimum IFG between frames during transmission is 40Bit */ -/** - * @} - */ - -/** @defgroup ETH_Carrier_Sense ETH Carrier Sense - * @{ - */ -#define ETH_CARRIERSENCE_ENABLE ((uint32_t)0x00000000) -#define ETH_CARRIERSENCE_DISABLE ((uint32_t)0x00010000) -/** - * @} - */ - -/** @defgroup ETH_Receive_Own ETH Receive Own - * @{ - */ -#define ETH_RECEIVEOWN_ENABLE ((uint32_t)0x00000000) -#define ETH_RECEIVEOWN_DISABLE ((uint32_t)0x00002000) -/** - * @} - */ - -/** @defgroup ETH_Loop_Back_Mode ETH Loop Back Mode - * @{ - */ -#define ETH_LOOPBACKMODE_ENABLE ((uint32_t)0x00001000) -#define ETH_LOOPBACKMODE_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Checksum_Offload ETH Checksum Offload - * @{ - */ -#define ETH_CHECKSUMOFFLAOD_ENABLE ((uint32_t)0x00000400) -#define ETH_CHECKSUMOFFLAOD_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Retry_Transmission ETH Retry Transmission - * @{ - */ -#define ETH_RETRYTRANSMISSION_ENABLE ((uint32_t)0x00000000) -#define ETH_RETRYTRANSMISSION_DISABLE ((uint32_t)0x00000200) -/** - * @} - */ - -/** @defgroup ETH_Automatic_Pad_CRC_Strip ETH Automatic Pad CRC Strip - * @{ - */ -#define ETH_AUTOMATICPADCRCSTRIP_ENABLE ((uint32_t)0x00000080) -#define ETH_AUTOMATICPADCRCSTRIP_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Back_Off_Limit ETH Back Off Limit - * @{ - */ -#define ETH_BACKOFFLIMIT_10 ((uint32_t)0x00000000) -#define ETH_BACKOFFLIMIT_8 ((uint32_t)0x00000020) -#define ETH_BACKOFFLIMIT_4 ((uint32_t)0x00000040) -#define ETH_BACKOFFLIMIT_1 ((uint32_t)0x00000060) -/** - * @} - */ - -/** @defgroup ETH_Deferral_Check ETH Deferral Check - * @{ - */ -#define ETH_DEFFERRALCHECK_ENABLE ((uint32_t)0x00000010) -#define ETH_DEFFERRALCHECK_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Receive_All ETH Receive All - * @{ - */ -#define ETH_RECEIVEALL_ENABLE ((uint32_t)0x80000000) -#define ETH_RECEIVEAll_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Source_Addr_Filter ETH Source Addr Filter - * @{ - */ -#define ETH_SOURCEADDRFILTER_NORMAL_ENABLE ((uint32_t)0x00000200) -#define ETH_SOURCEADDRFILTER_INVERSE_ENABLE ((uint32_t)0x00000300) -#define ETH_SOURCEADDRFILTER_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Pass_Control_Frames ETH Pass Control Frames - * @{ - */ -#define ETH_PASSCONTROLFRAMES_BLOCKALL ((uint32_t)0x00000040) /*!< MAC filters all control frames from reaching the application */ -#define ETH_PASSCONTROLFRAMES_FORWARDALL ((uint32_t)0x00000080) /*!< MAC forwards all control frames to application even if they fail the Address Filter */ -#define ETH_PASSCONTROLFRAMES_FORWARDPASSEDADDRFILTER ((uint32_t)0x000000C0) /*!< MAC forwards control frames that pass the Address Filter. */ -/** - * @} - */ - -/** @defgroup ETH_Broadcast_Frames_Reception ETH Broadcast Frames Reception - * @{ - */ -#define ETH_BROADCASTFRAMESRECEPTION_ENABLE ((uint32_t)0x00000000) -#define ETH_BROADCASTFRAMESRECEPTION_DISABLE ((uint32_t)0x00000020) -/** - * @} - */ - -/** @defgroup ETH_Destination_Addr_Filter ETH Destination Addr Filter - * @{ - */ -#define ETH_DESTINATIONADDRFILTER_NORMAL ((uint32_t)0x00000000) -#define ETH_DESTINATIONADDRFILTER_INVERSE ((uint32_t)0x00000008) -/** - * @} - */ - -/** @defgroup ETH_Promiscuous_Mode ETH Promiscuous Mode - * @{ - */ -#define ETH_PROMISCUOUS_MODE_ENABLE ((uint32_t)0x00000001) -#define ETH_PROMISCUOUS_MODE_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Multicast_Frames_Filter ETH Multicast Frames Filter - * @{ - */ -#define ETH_MULTICASTFRAMESFILTER_PERFECTHASHTABLE ((uint32_t)0x00000404) -#define ETH_MULTICASTFRAMESFILTER_HASHTABLE ((uint32_t)0x00000004) -#define ETH_MULTICASTFRAMESFILTER_PERFECT ((uint32_t)0x00000000) -#define ETH_MULTICASTFRAMESFILTER_NONE ((uint32_t)0x00000010) -/** - * @} - */ - -/** @defgroup ETH_Unicast_Frames_Filter ETH Unicast Frames Filter - * @{ - */ -#define ETH_UNICASTFRAMESFILTER_PERFECTHASHTABLE ((uint32_t)0x00000402) -#define ETH_UNICASTFRAMESFILTER_HASHTABLE ((uint32_t)0x00000002) -#define ETH_UNICASTFRAMESFILTER_PERFECT ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Zero_Quanta_Pause ETH Zero Quanta Pause - * @{ - */ -#define ETH_ZEROQUANTAPAUSE_ENABLE ((uint32_t)0x00000000) -#define ETH_ZEROQUANTAPAUSE_DISABLE ((uint32_t)0x00000080) -/** - * @} - */ - -/** @defgroup ETH_Pause_Low_Threshold ETH Pause Low Threshold - * @{ - */ -#define ETH_PAUSELOWTHRESHOLD_MINUS4 ((uint32_t)0x00000000) /*!< Pause time minus 4 slot times */ -#define ETH_PAUSELOWTHRESHOLD_MINUS28 ((uint32_t)0x00000010) /*!< Pause time minus 28 slot times */ -#define ETH_PAUSELOWTHRESHOLD_MINUS144 ((uint32_t)0x00000020) /*!< Pause time minus 144 slot times */ -#define ETH_PAUSELOWTHRESHOLD_MINUS256 ((uint32_t)0x00000030) /*!< Pause time minus 256 slot times */ -/** - * @} - */ - -/** @defgroup ETH_Unicast_Pause_Frame_Detect ETH Unicast Pause Frame Detect - * @{ - */ -#define ETH_UNICASTPAUSEFRAMEDETECT_ENABLE ((uint32_t)0x00000008) -#define ETH_UNICASTPAUSEFRAMEDETECT_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Receive_Flow_Control ETH Receive Flow Control - * @{ - */ -#define ETH_RECEIVEFLOWCONTROL_ENABLE ((uint32_t)0x00000004) -#define ETH_RECEIVEFLOWCONTROL_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Transmit_Flow_Control ETH Transmit Flow Control - * @{ - */ -#define ETH_TRANSMITFLOWCONTROL_ENABLE ((uint32_t)0x00000002) -#define ETH_TRANSMITFLOWCONTROL_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_VLAN_Tag_Comparison ETH VLAN Tag Comparison - * @{ - */ -#define ETH_VLANTAGCOMPARISON_12BIT ((uint32_t)0x00010000) -#define ETH_VLANTAGCOMPARISON_16BIT ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_MAC_addresses ETH MAC addresses - * @{ - */ -#define ETH_MAC_ADDRESS0 ((uint32_t)0x00000000) -#define ETH_MAC_ADDRESS1 ((uint32_t)0x00000008) -#define ETH_MAC_ADDRESS2 ((uint32_t)0x00000010) -#define ETH_MAC_ADDRESS3 ((uint32_t)0x00000018) -/** - * @} - */ - -/** @defgroup ETH_MAC_addresses_filter_SA_DA ETH MAC addresses filter SA DA - * @{ - */ -#define ETH_MAC_ADDRESSFILTER_SA ((uint32_t)0x00000000) -#define ETH_MAC_ADDRESSFILTER_DA ((uint32_t)0x00000008) -/** - * @} - */ - -/** @defgroup ETH_MAC_addresses_filter_Mask_bytes ETH MAC addresses filter Mask bytes - * @{ - */ -#define ETH_MAC_ADDRESSMASK_BYTE6 ((uint32_t)0x20000000) /*!< Mask MAC Address high reg bits [15:8] */ -#define ETH_MAC_ADDRESSMASK_BYTE5 ((uint32_t)0x10000000) /*!< Mask MAC Address high reg bits [7:0] */ -#define ETH_MAC_ADDRESSMASK_BYTE4 ((uint32_t)0x08000000) /*!< Mask MAC Address low reg bits [31:24] */ -#define ETH_MAC_ADDRESSMASK_BYTE3 ((uint32_t)0x04000000) /*!< Mask MAC Address low reg bits [23:16] */ -#define ETH_MAC_ADDRESSMASK_BYTE2 ((uint32_t)0x02000000) /*!< Mask MAC Address low reg bits [15:8] */ -#define ETH_MAC_ADDRESSMASK_BYTE1 ((uint32_t)0x01000000) /*!< Mask MAC Address low reg bits [70] */ -/** - * @} - */ - -/** @defgroup ETH_MAC_Debug_flags ETH MAC Debug flags - * @{ - */ -#define ETH_MAC_TXFIFO_FULL ((uint32_t)0x02000000) /* Tx FIFO full */ -#define ETH_MAC_TXFIFONOT_EMPTY ((uint32_t)0x01000000) /* Tx FIFO not empty */ -#define ETH_MAC_TXFIFO_WRITE_ACTIVE ((uint32_t)0x00400000) /* Tx FIFO write active */ -#define ETH_MAC_TXFIFO_IDLE ((uint32_t)0x00000000) /* Tx FIFO read status: Idle */ -#define ETH_MAC_TXFIFO_READ ((uint32_t)0x00100000) /* Tx FIFO read status: Read (transferring data to the MAC transmitter) */ -#define ETH_MAC_TXFIFO_WAITING ((uint32_t)0x00200000) /* Tx FIFO read status: Waiting for TxStatus from MAC transmitter */ -#define ETH_MAC_TXFIFO_WRITING ((uint32_t)0x00300000) /* Tx FIFO read status: Writing the received TxStatus or flushing the TxFIFO */ -#define ETH_MAC_TRANSMISSION_PAUSE ((uint32_t)0x00080000) /* MAC transmitter in pause */ -#define ETH_MAC_TRANSMITFRAMECONTROLLER_IDLE ((uint32_t)0x00000000) /* MAC transmit frame controller: Idle */ -#define ETH_MAC_TRANSMITFRAMECONTROLLER_WAITING ((uint32_t)0x00020000) /* MAC transmit frame controller: Waiting for Status of previous frame or IFG/backoff period to be over */ -#define ETH_MAC_TRANSMITFRAMECONTROLLER_GENRATING_PCF ((uint32_t)0x00040000) /* MAC transmit frame controller: Generating and transmitting a Pause control frame (in full duplex mode) */ -#define ETH_MAC_TRANSMITFRAMECONTROLLER_TRANSFERRING ((uint32_t)0x00060000) /* MAC transmit frame controller: Transferring input frame for transmission */ -#define ETH_MAC_MII_TRANSMIT_ACTIVE ((uint32_t)0x00010000) /* MAC MII transmit engine active */ -#define ETH_MAC_RXFIFO_EMPTY ((uint32_t)0x00000000) /* Rx FIFO fill level: empty */ -#define ETH_MAC_RXFIFO_BELOW_THRESHOLD ((uint32_t)0x00000100) /* Rx FIFO fill level: fill-level below flow-control de-activate threshold */ -#define ETH_MAC_RXFIFO_ABOVE_THRESHOLD ((uint32_t)0x00000200) /* Rx FIFO fill level: fill-level above flow-control activate threshold */ -#define ETH_MAC_RXFIFO_FULL ((uint32_t)0x00000300) /* Rx FIFO fill level: full */ -#define ETH_MAC_READCONTROLLER_IDLE ((uint32_t)0x00000060) /* Rx FIFO read controller IDLE state */ -#define ETH_MAC_READCONTROLLER_READING_DATA ((uint32_t)0x00000060) /* Rx FIFO read controller Reading frame data */ -#define ETH_MAC_READCONTROLLER_READING_STATUS ((uint32_t)0x00000060) /* Rx FIFO read controller Reading frame status (or time-stamp) */ -#define ETH_MAC_READCONTROLLER_ FLUSHING ((uint32_t)0x00000060) /* Rx FIFO read controller Flushing the frame data and status */ -#define ETH_MAC_RXFIFO_WRITE_ACTIVE ((uint32_t)0x00000010) /* Rx FIFO write controller active */ -#define ETH_MAC_SMALL_FIFO_NOTACTIVE ((uint32_t)0x00000000) /* MAC small FIFO read / write controllers not active */ -#define ETH_MAC_SMALL_FIFO_READ_ACTIVE ((uint32_t)0x00000002) /* MAC small FIFO read controller active */ -#define ETH_MAC_SMALL_FIFO_WRITE_ACTIVE ((uint32_t)0x00000004) /* MAC small FIFO write controller active */ -#define ETH_MAC_SMALL_FIFO_RW_ACTIVE ((uint32_t)0x00000006) /* MAC small FIFO read / write controllers active */ -#define ETH_MAC_MII_RECEIVE_PROTOCOL_ACTIVE ((uint32_t)0x00000001) /* MAC MII receive protocol engine active */ -/** - * @} - */ - -/** @defgroup ETH_Drop_TCP_IP_Checksum_Error_Frame ETH Drop TCP IP Checksum Error Frame - * @{ - */ -#define ETH_DROPTCPIPCHECKSUMERRORFRAME_ENABLE ((uint32_t)0x00000000) -#define ETH_DROPTCPIPCHECKSUMERRORFRAME_DISABLE ((uint32_t)0x04000000) -/** - * @} - */ - -/** @defgroup ETH_Receive_Store_Forward ETH Receive Store Forward - * @{ - */ -#define ETH_RECEIVESTOREFORWARD_ENABLE ((uint32_t)0x02000000) -#define ETH_RECEIVESTOREFORWARD_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Flush_Received_Frame ETH Flush Received Frame - * @{ - */ -#define ETH_FLUSHRECEIVEDFRAME_ENABLE ((uint32_t)0x00000000) -#define ETH_FLUSHRECEIVEDFRAME_DISABLE ((uint32_t)0x01000000) -/** - * @} - */ - -/** @defgroup ETH_Transmit_Store_Forward ETH Transmit Store Forward - * @{ - */ -#define ETH_TRANSMITSTOREFORWARD_ENABLE ((uint32_t)0x00200000) -#define ETH_TRANSMITSTOREFORWARD_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Transmit_Threshold_Control ETH Transmit Threshold Control - * @{ - */ -#define ETH_TRANSMITTHRESHOLDCONTROL_64BYTES ((uint32_t)0x00000000) /*!< threshold level of the MTL Transmit FIFO is 64 Bytes */ -#define ETH_TRANSMITTHRESHOLDCONTROL_128BYTES ((uint32_t)0x00004000) /*!< threshold level of the MTL Transmit FIFO is 128 Bytes */ -#define ETH_TRANSMITTHRESHOLDCONTROL_192BYTES ((uint32_t)0x00008000) /*!< threshold level of the MTL Transmit FIFO is 192 Bytes */ -#define ETH_TRANSMITTHRESHOLDCONTROL_256BYTES ((uint32_t)0x0000C000) /*!< threshold level of the MTL Transmit FIFO is 256 Bytes */ -#define ETH_TRANSMITTHRESHOLDCONTROL_40BYTES ((uint32_t)0x00010000) /*!< threshold level of the MTL Transmit FIFO is 40 Bytes */ -#define ETH_TRANSMITTHRESHOLDCONTROL_32BYTES ((uint32_t)0x00014000) /*!< threshold level of the MTL Transmit FIFO is 32 Bytes */ -#define ETH_TRANSMITTHRESHOLDCONTROL_24BYTES ((uint32_t)0x00018000) /*!< threshold level of the MTL Transmit FIFO is 24 Bytes */ -#define ETH_TRANSMITTHRESHOLDCONTROL_16BYTES ((uint32_t)0x0001C000) /*!< threshold level of the MTL Transmit FIFO is 16 Bytes */ -/** - * @} - */ - -/** @defgroup ETH_Forward_Error_Frames ETH Forward Error Frames - * @{ - */ -#define ETH_FORWARDERRORFRAMES_ENABLE ((uint32_t)0x00000080) -#define ETH_FORWARDERRORFRAMES_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Forward_Undersized_Good_Frames ETH Forward Undersized Good Frames - * @{ - */ -#define ETH_FORWARDUNDERSIZEDGOODFRAMES_ENABLE ((uint32_t)0x00000040) -#define ETH_FORWARDUNDERSIZEDGOODFRAMES_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Receive_Threshold_Control ETH Receive Threshold Control - * @{ - */ -#define ETH_RECEIVEDTHRESHOLDCONTROL_64BYTES ((uint32_t)0x00000000) /*!< threshold level of the MTL Receive FIFO is 64 Bytes */ -#define ETH_RECEIVEDTHRESHOLDCONTROL_32BYTES ((uint32_t)0x00000008) /*!< threshold level of the MTL Receive FIFO is 32 Bytes */ -#define ETH_RECEIVEDTHRESHOLDCONTROL_96BYTES ((uint32_t)0x00000010) /*!< threshold level of the MTL Receive FIFO is 96 Bytes */ -#define ETH_RECEIVEDTHRESHOLDCONTROL_128BYTES ((uint32_t)0x00000018) /*!< threshold level of the MTL Receive FIFO is 128 Bytes */ -/** - * @} - */ - -/** @defgroup ETH_Second_Frame_Operate ETH Second Frame Operate - * @{ - */ -#define ETH_SECONDFRAMEOPERARTE_ENABLE ((uint32_t)0x00000004) -#define ETH_SECONDFRAMEOPERARTE_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Address_Aligned_Beats ETH Address Aligned Beats - * @{ - */ -#define ETH_ADDRESSALIGNEDBEATS_ENABLE ((uint32_t)0x02000000) -#define ETH_ADDRESSALIGNEDBEATS_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Fixed_Burst ETH Fixed Burst - * @{ - */ -#define ETH_FIXEDBURST_ENABLE ((uint32_t)0x00010000) -#define ETH_FIXEDBURST_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_Rx_DMA_Burst_Length ETH Rx DMA Burst Length - * @{ - */ -#define ETH_RXDMABURSTLENGTH_1BEAT ((uint32_t)0x00020000) /*!< maximum number of beats to be transferred in one RxDMA transaction is 1 */ -#define ETH_RXDMABURSTLENGTH_2BEAT ((uint32_t)0x00040000) /*!< maximum number of beats to be transferred in one RxDMA transaction is 2 */ -#define ETH_RXDMABURSTLENGTH_4BEAT ((uint32_t)0x00080000) /*!< maximum number of beats to be transferred in one RxDMA transaction is 4 */ -#define ETH_RXDMABURSTLENGTH_8BEAT ((uint32_t)0x00100000) /*!< maximum number of beats to be transferred in one RxDMA transaction is 8 */ -#define ETH_RXDMABURSTLENGTH_16BEAT ((uint32_t)0x00200000) /*!< maximum number of beats to be transferred in one RxDMA transaction is 16 */ -#define ETH_RXDMABURSTLENGTH_32BEAT ((uint32_t)0x00400000) /*!< maximum number of beats to be transferred in one RxDMA transaction is 32 */ -#define ETH_RXDMABURSTLENGTH_4XPBL_4BEAT ((uint32_t)0x01020000) /*!< maximum number of beats to be transferred in one RxDMA transaction is 4 */ -#define ETH_RXDMABURSTLENGTH_4XPBL_8BEAT ((uint32_t)0x01040000) /*!< maximum number of beats to be transferred in one RxDMA transaction is 8 */ -#define ETH_RXDMABURSTLENGTH_4XPBL_16BEAT ((uint32_t)0x01080000) /*!< maximum number of beats to be transferred in one RxDMA transaction is 16 */ -#define ETH_RXDMABURSTLENGTH_4XPBL_32BEAT ((uint32_t)0x01100000) /*!< maximum number of beats to be transferred in one RxDMA transaction is 32 */ -#define ETH_RXDMABURSTLENGTH_4XPBL_64BEAT ((uint32_t)0x01200000) /*!< maximum number of beats to be transferred in one RxDMA transaction is 64 */ -#define ETH_RXDMABURSTLENGTH_4XPBL_128BEAT ((uint32_t)0x01400000) /*!< maximum number of beats to be transferred in one RxDMA transaction is 128 */ -/** - * @} - */ - -/** @defgroup ETH_Tx_DMA_Burst_Length ETH Tx DMA Burst Length - * @{ - */ -#define ETH_TXDMABURSTLENGTH_1BEAT ((uint32_t)0x00000100) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 1 */ -#define ETH_TXDMABURSTLENGTH_2BEAT ((uint32_t)0x00000200) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 2 */ -#define ETH_TXDMABURSTLENGTH_4BEAT ((uint32_t)0x00000400) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 4 */ -#define ETH_TXDMABURSTLENGTH_8BEAT ((uint32_t)0x00000800) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 8 */ -#define ETH_TXDMABURSTLENGTH_16BEAT ((uint32_t)0x00001000) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 16 */ -#define ETH_TXDMABURSTLENGTH_32BEAT ((uint32_t)0x00002000) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 32 */ -#define ETH_TXDMABURSTLENGTH_4XPBL_4BEAT ((uint32_t)0x01000100) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 4 */ -#define ETH_TXDMABURSTLENGTH_4XPBL_8BEAT ((uint32_t)0x01000200) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 8 */ -#define ETH_TXDMABURSTLENGTH_4XPBL_16BEAT ((uint32_t)0x01000400) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 16 */ -#define ETH_TXDMABURSTLENGTH_4XPBL_32BEAT ((uint32_t)0x01000800) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 32 */ -#define ETH_TXDMABURSTLENGTH_4XPBL_64BEAT ((uint32_t)0x01001000) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 64 */ -#define ETH_TXDMABURSTLENGTH_4XPBL_128BEAT ((uint32_t)0x01002000) /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 128 */ -/** - * @} - */ - -/** @defgroup ETH_DMA_Enhanced_descriptor_format ETH DMA Enhanced descriptor format - * @{ - */ -#define ETH_DMAENHANCEDDESCRIPTOR_ENABLE ((uint32_t)0x00000080) -#define ETH_DMAENHANCEDDESCRIPTOR_DISABLE ((uint32_t)0x00000000) -/** - * @} - */ - -/** @defgroup ETH_DMA_Arbitration ETH DMA Arbitration - * @{ - */ -#define ETH_DMAARBITRATION_ROUNDROBIN_RXTX_1_1 ((uint32_t)0x00000000) -#define ETH_DMAARBITRATION_ROUNDROBIN_RXTX_2_1 ((uint32_t)0x00004000) -#define ETH_DMAARBITRATION_ROUNDROBIN_RXTX_3_1 ((uint32_t)0x00008000) -#define ETH_DMAARBITRATION_ROUNDROBIN_RXTX_4_1 ((uint32_t)0x0000C000) -#define ETH_DMAARBITRATION_RXPRIORTX ((uint32_t)0x00000002) -/** - * @} - */ - -/** @defgroup ETH_DMA_Tx_descriptor_segment ETH DMA Tx descriptor segment - * @{ - */ -#define ETH_DMATXDESC_LASTSEGMENTS ((uint32_t)0x40000000) /*!< Last Segment */ -#define ETH_DMATXDESC_FIRSTSEGMENT ((uint32_t)0x20000000) /*!< First Segment */ -/** - * @} - */ - -/** @defgroup ETH_DMA_Tx_descriptor_Checksum_Insertion_Control ETH DMA Tx descriptor Checksum Insertion Control - * @{ - */ -#define ETH_DMATXDESC_CHECKSUMBYPASS ((uint32_t)0x00000000) /*!< Checksum engine bypass */ -#define ETH_DMATXDESC_CHECKSUMIPV4HEADER ((uint32_t)0x00400000) /*!< IPv4 header checksum insertion */ -#define ETH_DMATXDESC_CHECKSUMTCPUDPICMPSEGMENT ((uint32_t)0x00800000) /*!< TCP/UDP/ICMP checksum insertion. Pseudo header checksum is assumed to be present */ -#define ETH_DMATXDESC_CHECKSUMTCPUDPICMPFULL ((uint32_t)0x00C00000) /*!< TCP/UDP/ICMP checksum fully in hardware including pseudo header */ -/** - * @} - */ - -/** @defgroup ETH_DMA_Rx_descriptor_buffers ETH DMA Rx descriptor buffers - * @{ - */ -#define ETH_DMARXDESC_BUFFER1 ((uint32_t)0x00000000) /*!< DMA Rx Desc Buffer1 */ -#define ETH_DMARXDESC_BUFFER2 ((uint32_t)0x00000001) /*!< DMA Rx Desc Buffer2 */ -/** - * @} - */ - -/** @defgroup ETH_PMT_Flags ETH PMT Flags - * @{ - */ -#define ETH_PMT_FLAG_WUFFRPR ((uint32_t)0x80000000) /*!< Wake-Up Frame Filter Register Pointer Reset */ -#define ETH_PMT_FLAG_WUFR ((uint32_t)0x00000040) /*!< Wake-Up Frame Received */ -#define ETH_PMT_FLAG_MPR ((uint32_t)0x00000020) /*!< Magic Packet Received */ -/** - * @} - */ - -/** @defgroup ETH_MMC_Tx_Interrupts ETH MMC Tx Interrupts - * @{ - */ -#define ETH_MMC_IT_TGF ((uint32_t)0x00200000) /*!< When Tx good frame counter reaches half the maximum value */ -#define ETH_MMC_IT_TGFMSC ((uint32_t)0x00008000) /*!< When Tx good multi col counter reaches half the maximum value */ -#define ETH_MMC_IT_TGFSC ((uint32_t)0x00004000) /*!< When Tx good single col counter reaches half the maximum value */ -/** - * @} - */ - -/** @defgroup ETH_MMC_Rx_Interrupts ETH MMC Rx Interrupts - * @{ - */ -#define ETH_MMC_IT_RGUF ((uint32_t)0x10020000) /*!< When Rx good unicast frames counter reaches half the maximum value */ -#define ETH_MMC_IT_RFAE ((uint32_t)0x10000040) /*!< When Rx alignment error counter reaches half the maximum value */ -#define ETH_MMC_IT_RFCE ((uint32_t)0x10000020) /*!< When Rx crc error counter reaches half the maximum value */ -/** - * @} - */ - -/** @defgroup ETH_MAC_Flags ETH MAC Flags - * @{ - */ -#define ETH_MAC_FLAG_TST ((uint32_t)0x00000200) /*!< Time stamp trigger flag (on MAC) */ -#define ETH_MAC_FLAG_MMCT ((uint32_t)0x00000040) /*!< MMC transmit flag */ -#define ETH_MAC_FLAG_MMCR ((uint32_t)0x00000020) /*!< MMC receive flag */ -#define ETH_MAC_FLAG_MMC ((uint32_t)0x00000010) /*!< MMC flag (on MAC) */ -#define ETH_MAC_FLAG_PMT ((uint32_t)0x00000008) /*!< PMT flag (on MAC) */ -/** - * @} - */ - -/** @defgroup ETH_DMA_Flags ETH DMA Flags - * @{ - */ -#define ETH_DMA_FLAG_TST ((uint32_t)0x20000000) /*!< Time-stamp trigger interrupt (on DMA) */ -#define ETH_DMA_FLAG_PMT ((uint32_t)0x10000000) /*!< PMT interrupt (on DMA) */ -#define ETH_DMA_FLAG_MMC ((uint32_t)0x08000000) /*!< MMC interrupt (on DMA) */ -#define ETH_DMA_FLAG_DATATRANSFERERROR ((uint32_t)0x00800000) /*!< Error bits 0-Rx DMA, 1-Tx DMA */ -#define ETH_DMA_FLAG_READWRITEERROR ((uint32_t)0x01000000) /*!< Error bits 0-write transfer, 1-read transfer */ -#define ETH_DMA_FLAG_ACCESSERROR ((uint32_t)0x02000000) /*!< Error bits 0-data buffer, 1-desc. access */ -#define ETH_DMA_FLAG_NIS ((uint32_t)0x00010000) /*!< Normal interrupt summary flag */ -#define ETH_DMA_FLAG_AIS ((uint32_t)0x00008000) /*!< Abnormal interrupt summary flag */ -#define ETH_DMA_FLAG_ER ((uint32_t)0x00004000) /*!< Early receive flag */ -#define ETH_DMA_FLAG_FBE ((uint32_t)0x00002000) /*!< Fatal bus error flag */ -#define ETH_DMA_FLAG_ET ((uint32_t)0x00000400) /*!< Early transmit flag */ -#define ETH_DMA_FLAG_RWT ((uint32_t)0x00000200) /*!< Receive watchdog timeout flag */ -#define ETH_DMA_FLAG_RPS ((uint32_t)0x00000100) /*!< Receive process stopped flag */ -#define ETH_DMA_FLAG_RBU ((uint32_t)0x00000080) /*!< Receive buffer unavailable flag */ -#define ETH_DMA_FLAG_R ((uint32_t)0x00000040) /*!< Receive flag */ -#define ETH_DMA_FLAG_TU ((uint32_t)0x00000020) /*!< Underflow flag */ -#define ETH_DMA_FLAG_RO ((uint32_t)0x00000010) /*!< Overflow flag */ -#define ETH_DMA_FLAG_TJT ((uint32_t)0x00000008) /*!< Transmit jabber timeout flag */ -#define ETH_DMA_FLAG_TBU ((uint32_t)0x00000004) /*!< Transmit buffer unavailable flag */ -#define ETH_DMA_FLAG_TPS ((uint32_t)0x00000002) /*!< Transmit process stopped flag */ -#define ETH_DMA_FLAG_T ((uint32_t)0x00000001) /*!< Transmit flag */ -/** - * @} - */ - -/** @defgroup ETH_MAC_Interrupts ETH MAC Interrupts - * @{ - */ -#define ETH_MAC_IT_TST ((uint32_t)0x00000200) /*!< Time stamp trigger interrupt (on MAC) */ -#define ETH_MAC_IT_MMCT ((uint32_t)0x00000040) /*!< MMC transmit interrupt */ -#define ETH_MAC_IT_MMCR ((uint32_t)0x00000020) /*!< MMC receive interrupt */ -#define ETH_MAC_IT_MMC ((uint32_t)0x00000010) /*!< MMC interrupt (on MAC) */ -#define ETH_MAC_IT_PMT ((uint32_t)0x00000008) /*!< PMT interrupt (on MAC) */ -/** - * @} - */ - -/** @defgroup ETH_DMA_Interrupts ETH DMA Interrupts - * @{ - */ -#define ETH_DMA_IT_TST ((uint32_t)0x20000000) /*!< Time-stamp trigger interrupt (on DMA) */ -#define ETH_DMA_IT_PMT ((uint32_t)0x10000000) /*!< PMT interrupt (on DMA) */ -#define ETH_DMA_IT_MMC ((uint32_t)0x08000000) /*!< MMC interrupt (on DMA) */ -#define ETH_DMA_IT_NIS ((uint32_t)0x00010000) /*!< Normal interrupt summary */ -#define ETH_DMA_IT_AIS ((uint32_t)0x00008000) /*!< Abnormal interrupt summary */ -#define ETH_DMA_IT_ER ((uint32_t)0x00004000) /*!< Early receive interrupt */ -#define ETH_DMA_IT_FBE ((uint32_t)0x00002000) /*!< Fatal bus error interrupt */ -#define ETH_DMA_IT_ET ((uint32_t)0x00000400) /*!< Early transmit interrupt */ -#define ETH_DMA_IT_RWT ((uint32_t)0x00000200) /*!< Receive watchdog timeout interrupt */ -#define ETH_DMA_IT_RPS ((uint32_t)0x00000100) /*!< Receive process stopped interrupt */ -#define ETH_DMA_IT_RBU ((uint32_t)0x00000080) /*!< Receive buffer unavailable interrupt */ -#define ETH_DMA_IT_R ((uint32_t)0x00000040) /*!< Receive interrupt */ -#define ETH_DMA_IT_TU ((uint32_t)0x00000020) /*!< Underflow interrupt */ -#define ETH_DMA_IT_RO ((uint32_t)0x00000010) /*!< Overflow interrupt */ -#define ETH_DMA_IT_TJT ((uint32_t)0x00000008) /*!< Transmit jabber timeout interrupt */ -#define ETH_DMA_IT_TBU ((uint32_t)0x00000004) /*!< Transmit buffer unavailable interrupt */ -#define ETH_DMA_IT_TPS ((uint32_t)0x00000002) /*!< Transmit process stopped interrupt */ -#define ETH_DMA_IT_T ((uint32_t)0x00000001) /*!< Transmit interrupt */ -/** - * @} - */ - -/** @defgroup ETH_DMA_transmit_process_state ETH DMA transmit process state - * @{ - */ -#define ETH_DMA_TRANSMITPROCESS_STOPPED ((uint32_t)0x00000000) /*!< Stopped - Reset or Stop Tx Command issued */ -#define ETH_DMA_TRANSMITPROCESS_FETCHING ((uint32_t)0x00100000) /*!< Running - fetching the Tx descriptor */ -#define ETH_DMA_TRANSMITPROCESS_WAITING ((uint32_t)0x00200000) /*!< Running - waiting for status */ -#define ETH_DMA_TRANSMITPROCESS_READING ((uint32_t)0x00300000) /*!< Running - reading the data from host memory */ -#define ETH_DMA_TRANSMITPROCESS_SUSPENDED ((uint32_t)0x00600000) /*!< Suspended - Tx Descriptor unavailable */ -#define ETH_DMA_TRANSMITPROCESS_CLOSING ((uint32_t)0x00700000) /*!< Running - closing Rx descriptor */ - -/** - * @} - */ - - -/** @defgroup ETH_DMA_receive_process_state ETH DMA receive process state - * @{ - */ -#define ETH_DMA_RECEIVEPROCESS_STOPPED ((uint32_t)0x00000000) /*!< Stopped - Reset or Stop Rx Command issued */ -#define ETH_DMA_RECEIVEPROCESS_FETCHING ((uint32_t)0x00020000) /*!< Running - fetching the Rx descriptor */ -#define ETH_DMA_RECEIVEPROCESS_WAITING ((uint32_t)0x00060000) /*!< Running - waiting for packet */ -#define ETH_DMA_RECEIVEPROCESS_SUSPENDED ((uint32_t)0x00080000) /*!< Suspended - Rx Descriptor unavailable */ -#define ETH_DMA_RECEIVEPROCESS_CLOSING ((uint32_t)0x000A0000) /*!< Running - closing descriptor */ -#define ETH_DMA_RECEIVEPROCESS_QUEUING ((uint32_t)0x000E0000) /*!< Running - queuing the receive frame into host memory */ - -/** - * @} - */ - -/** @defgroup ETH_DMA_overflow ETH DMA overflow - * @{ - */ -#define ETH_DMA_OVERFLOW_RXFIFOCOUNTER ((uint32_t)0x10000000) /*!< Overflow bit for FIFO overflow counter */ -#define ETH_DMA_OVERFLOW_MISSEDFRAMECOUNTER ((uint32_t)0x00010000) /*!< Overflow bit for missed frame counter */ -/** - * @} - */ - -/** @defgroup ETH_EXTI_LINE_WAKEUP ETH EXTI LINE WAKEUP - * @{ - */ -#define ETH_EXTI_LINE_WAKEUP ((uint32_t)0x00080000) /*!< External interrupt line 19 Connected to the ETH EXTI Line */ - -/** - * @} - */ - -/** - * @} - */ - -/* Exported macro ------------------------------------------------------------*/ -/** @defgroup ETH_Exported_Macros ETH Exported Macros - * @brief macros to handle interrupts and specific clock configurations - * @{ - */ - -/** @brief Reset ETH handle state - * @param __HANDLE__: specifies the ETH handle. - * @retval None - */ -#define __HAL_ETH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ETH_STATE_RESET) - -/** - * @brief Checks whether the specified ETHERNET DMA Tx Desc flag is set or not. - * @param __HANDLE__: ETH Handle - * @param __FLAG__: specifies the flag of TDES0 to check. - * @retval the ETH_DMATxDescFlag (SET or RESET). - */ -#define __HAL_ETH_DMATXDESC_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->TxDesc->Status & (__FLAG__) == (__FLAG__)) - -/** - * @brief Checks whether the specified ETHERNET DMA Rx Desc flag is set or not. - * @param __HANDLE__: ETH Handle - * @param __FLAG__: specifies the flag of RDES0 to check. - * @retval the ETH_DMATxDescFlag (SET or RESET). - */ -#define __HAL_ETH_DMARXDESC_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->RxDesc->Status & (__FLAG__) == (__FLAG__)) - -/** - * @brief Enables the specified DMA Rx Desc receive interrupt. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMARXDESC_ENABLE_IT(__HANDLE__) ((__HANDLE__)->RxDesc->ControlBufferSize &=(~(uint32_t)ETH_DMARXDESC_DIC)) - -/** - * @brief Disables the specified DMA Rx Desc receive interrupt. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMARXDESC_DISABLE_IT(__HANDLE__) ((__HANDLE__)->RxDesc->ControlBufferSize |= ETH_DMARXDESC_DIC) - -/** - * @brief Set the specified DMA Rx Desc Own bit. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMARXDESC_SET_OWN_BIT(__HANDLE__) ((__HANDLE__)->RxDesc->Status |= ETH_DMARXDESC_OWN) - -/** - * @brief Returns the specified ETHERNET DMA Tx Desc collision count. - * @param __HANDLE__: ETH Handle - * @retval The Transmit descriptor collision counter value. - */ -#define __HAL_ETH_DMATXDESC_GET_COLLISION_COUNT(__HANDLE__) (((__HANDLE__)->TxDesc->Status & ETH_DMATXDESC_CC) >> ETH_DMATXDESC_COLLISION_COUNTSHIFT) - -/** - * @brief Set the specified DMA Tx Desc Own bit. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMATXDESC_SET_OWN_BIT(__HANDLE__) ((__HANDLE__)->TxDesc->Status |= ETH_DMATXDESC_OWN) - -/** - * @brief Enables the specified DMA Tx Desc Transmit interrupt. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMATXDESC_ENABLE_IT(__HANDLE__) ((__HANDLE__)->TxDesc->Status |= ETH_DMATXDESC_IC) - -/** - * @brief Disables the specified DMA Tx Desc Transmit interrupt. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMATXDESC_DISABLE_IT(__HANDLE__) ((__HANDLE__)->TxDesc->Status &= ~ETH_DMATXDESC_IC) - -/** - * @brief Selects the specified ETHERNET DMA Tx Desc Checksum Insertion. - * @param __HANDLE__: ETH Handle - * @param __CHECKSUM__: specifies is the DMA Tx desc checksum insertion. - * This parameter can be one of the following values: - * @arg ETH_DMATXDESC_CHECKSUMBYPASS : Checksum bypass - * @arg ETH_DMATXDESC_CHECKSUMIPV4HEADER : IPv4 header checksum - * @arg ETH_DMATXDESC_CHECKSUMTCPUDPICMPSEGMENT : TCP/UDP/ICMP checksum. Pseudo header checksum is assumed to be present - * @arg ETH_DMATXDESC_CHECKSUMTCPUDPICMPFULL : TCP/UDP/ICMP checksum fully in hardware including pseudo header - * @retval None - */ -#define __HAL_ETH_DMATXDESC_CHECKSUM_INSERTION(__HANDLE__, __CHECKSUM__) ((__HANDLE__)->TxDesc->Status |= (__CHECKSUM__)) - -/** - * @brief Enables the DMA Tx Desc CRC. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMATXDESC_CRC_ENABLE(__HANDLE__) ((__HANDLE__)->TxDesc->Status &= ~ETH_DMATXDESC_DC) - -/** - * @brief Disables the DMA Tx Desc CRC. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMATXDESC_CRC_DISABLE(__HANDLE__) ((__HANDLE__)->TxDesc->Status |= ETH_DMATXDESC_DC) - -/** - * @brief Enables the DMA Tx Desc padding for frame shorter than 64 bytes. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMATXDESC_SHORT_FRAME_PADDING_ENABLE(__HANDLE__) ((__HANDLE__)->TxDesc->Status &= ~ETH_DMATXDESC_DP) - -/** - * @brief Disables the DMA Tx Desc padding for frame shorter than 64 bytes. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_DMATXDESC_SHORT_FRAME_PADDING_DISABLE(__HANDLE__) ((__HANDLE__)->TxDesc->Status |= ETH_DMATXDESC_DP) - -/** - * @brief Enables the specified ETHERNET MAC interrupts. - * @param __HANDLE__ : ETH Handle - * @param __INTERRUPT__: specifies the ETHERNET MAC interrupt sources to be - * enabled or disabled. - * This parameter can be any combination of the following values: - * @arg ETH_MAC_IT_TST : Time stamp trigger interrupt - * @arg ETH_MAC_IT_PMT : PMT interrupt - * @retval None - */ -#define __HAL_ETH_MAC_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MACIMR |= (__INTERRUPT__)) - -/** - * @brief Disables the specified ETHERNET MAC interrupts. - * @param __HANDLE__ : ETH Handle - * @param __INTERRUPT__: specifies the ETHERNET MAC interrupt sources to be - * enabled or disabled. - * This parameter can be any combination of the following values: - * @arg ETH_MAC_IT_TST : Time stamp trigger interrupt - * @arg ETH_MAC_IT_PMT : PMT interrupt - * @retval None - */ -#define __HAL_ETH_MAC_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MACIMR &= ~(__INTERRUPT__)) - -/** - * @brief Initiate a Pause Control Frame (Full-duplex only). - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_INITIATE_PAUSE_CONTROL_FRAME(__HANDLE__) ((__HANDLE__)->Instance->MACFCR |= ETH_MACFCR_FCBBPA) - -/** - * @brief Checks whether the ETHERNET flow control busy bit is set or not. - * @param __HANDLE__: ETH Handle - * @retval The new state of flow control busy status bit (SET or RESET). - */ -#define __HAL_ETH_GET_FLOW_CONTROL_BUSY_STATUS(__HANDLE__) (((__HANDLE__)->Instance->MACFCR & ETH_MACFCR_FCBBPA) == ETH_MACFCR_FCBBPA) - -/** - * @brief Enables the MAC Back Pressure operation activation (Half-duplex only). - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_BACK_PRESSURE_ACTIVATION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MACFCR |= ETH_MACFCR_FCBBPA) - -/** - * @brief Disables the MAC BackPressure operation activation (Half-duplex only). - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_BACK_PRESSURE_ACTIVATION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MACFCR &= ~ETH_MACFCR_FCBBPA) - -/** - * @brief Checks whether the specified ETHERNET MAC flag is set or not. - * @param __HANDLE__: ETH Handle - * @param __FLAG__: specifies the flag to check. - * This parameter can be one of the following values: - * @arg ETH_MAC_FLAG_TST : Time stamp trigger flag - * @arg ETH_MAC_FLAG_MMCT : MMC transmit flag - * @arg ETH_MAC_FLAG_MMCR : MMC receive flag - * @arg ETH_MAC_FLAG_MMC : MMC flag - * @arg ETH_MAC_FLAG_PMT : PMT flag - * @retval The state of ETHERNET MAC flag. - */ -#define __HAL_ETH_MAC_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->MACSR &( __FLAG__)) == ( __FLAG__)) - -/** - * @brief Enables the specified ETHERNET DMA interrupts. - * @param __HANDLE__ : ETH Handle - * @param __INTERRUPT__: specifies the ETHERNET DMA interrupt sources to be - * enabled @ref ETH_DMA_Interrupts - * @retval None - */ -#define __HAL_ETH_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DMAIER |= (__INTERRUPT__)) - -/** - * @brief Disables the specified ETHERNET DMA interrupts. - * @param __HANDLE__ : ETH Handle - * @param __INTERRUPT__: specifies the ETHERNET DMA interrupt sources to be - * disabled. @ref ETH_DMA_Interrupts - * @retval None - */ -#define __HAL_ETH_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DMAIER &= ~(__INTERRUPT__)) - -/** - * @brief Clears the ETHERNET DMA IT pending bit. - * @param __HANDLE__ : ETH Handle - * @param __INTERRUPT__: specifies the interrupt pending bit to clear. @ref ETH_DMA_Interrupts - * @retval None - */ -#define __HAL_ETH_DMA_CLEAR_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DMASR =(__INTERRUPT__)) - -/** - * @brief Checks whether the specified ETHERNET DMA flag is set or not. -* @param __HANDLE__: ETH Handle - * @param __FLAG__: specifies the flag to check. @ref ETH_DMA_Flags - * @retval The new state of ETH_DMA_FLAG (SET or RESET). - */ -#define __HAL_ETH_DMA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->DMASR &( __FLAG__)) == ( __FLAG__)) - -/** - * @brief Checks whether the specified ETHERNET DMA flag is set or not. - * @param __HANDLE__: ETH Handle - * @param __FLAG__: specifies the flag to clear. @ref ETH_DMA_Flags - * @retval The new state of ETH_DMA_FLAG (SET or RESET). - */ -#define __HAL_ETH_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->DMASR = (__FLAG__)) - -/** - * @brief Checks whether the specified ETHERNET DMA overflow flag is set or not. - * @param __HANDLE__: ETH Handle - * @param __OVERFLOW__: specifies the DMA overflow flag to check. - * This parameter can be one of the following values: - * @arg ETH_DMA_OVERFLOW_RXFIFOCOUNTER : Overflow for FIFO Overflows Counter - * @arg ETH_DMA_OVERFLOW_MISSEDFRAMECOUNTER : Overflow for Buffer Unavailable Missed Frame Counter - * @retval The state of ETHERNET DMA overflow Flag (SET or RESET). - */ -#define __HAL_ETH_GET_DMA_OVERFLOW_STATUS(__HANDLE__, __OVERFLOW__) (((__HANDLE__)->Instance->DMAMFBOCR & (__OVERFLOW__)) == (__OVERFLOW__)) - -/** - * @brief Set the DMA Receive status watchdog timer register value - * @param __HANDLE__: ETH Handle - * @param __VALUE__: DMA Receive status watchdog timer register value - * @retval None - */ -#define __HAL_ETH_SET_RECEIVE_WATCHDOG_TIMER(__HANDLE__, __VALUE__) ((__HANDLE__)->Instance->DMARSWTR = (__VALUE__)) - -/** - * @brief Enables any unicast packet filtered by the MAC address - * recognition to be a wake-up frame. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_GLOBAL_UNICAST_WAKEUP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR |= ETH_MACPMTCSR_GU) - -/** - * @brief Disables any unicast packet filtered by the MAC address - * recognition to be a wake-up frame. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_GLOBAL_UNICAST_WAKEUP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR &= ~ETH_MACPMTCSR_GU) - -/** - * @brief Enables the MAC Wake-Up Frame Detection. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_WAKEUP_FRAME_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR |= ETH_MACPMTCSR_WFE) - -/** - * @brief Disables the MAC Wake-Up Frame Detection. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_WAKEUP_FRAME_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR &= ~ETH_MACPMTCSR_WFE) - -/** - * @brief Enables the MAC Magic Packet Detection. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_MAGIC_PACKET_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR |= ETH_MACPMTCSR_MPE) - -/** - * @brief Disables the MAC Magic Packet Detection. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_MAGIC_PACKET_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR &= ~ETH_MACPMTCSR_WFE) - -/** - * @brief Enables the MAC Power Down. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_POWER_DOWN_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR |= ETH_MACPMTCSR_PD) - -/** - * @brief Disables the MAC Power Down. - * @param __HANDLE__: ETH Handle - * @retval None - */ -#define __HAL_ETH_POWER_DOWN_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MACPMTCSR &= ~ETH_MACPMTCSR_PD) - -/** - * @brief Checks whether the specified ETHERNET PMT flag is set or not. - * @param __HANDLE__: ETH Handle. - * @param __FLAG__: specifies the flag to check. - * This parameter can be one of the following values: - * @arg ETH_PMT_FLAG_WUFFRPR : Wake-Up Frame Filter Register Pointer Reset - * @arg ETH_PMT_FLAG_WUFR : Wake-Up Frame Received - * @arg ETH_PMT_FLAG_MPR : Magic Packet Received - * @retval The new state of ETHERNET PMT Flag (SET or RESET). - */ -#define __HAL_ETH_GET_PMT_FLAG_STATUS(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->MACPMTCSR &( __FLAG__)) == ( __FLAG__)) - -/** - * @brief Preset and Initialize the MMC counters to almost-full value: 0xFFFF_FFF0 (full - 16) - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_MMC_COUNTER_FULL_PRESET(__HANDLE__) ((__HANDLE__)->Instance->MMCCR |= (ETH_MMCCR_MCFHP | ETH_MMCCR_MCP)) - -/** - * @brief Preset and Initialize the MMC counters to almost-half value: 0x7FFF_FFF0 (half - 16) - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_MMC_COUNTER_HALF_PRESET(__HANDLE__) do{(__HANDLE__)->Instance->MMCCR &= ~ETH_MMCCR_MCFHP;\ - (__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_MCP;} while (0) - -/** - * @brief Enables the MMC Counter Freeze. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_MMC_COUNTER_FREEZE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_MCF) - -/** - * @brief Disables the MMC Counter Freeze. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_MMC_COUNTER_FREEZE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MMCCR &= ~ETH_MMCCR_MCF) - -/** - * @brief Enables the MMC Reset On Read. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_ETH_MMC_RESET_ONREAD_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_ROR) - -/** - * @brief Disables the MMC Reset On Read. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_ETH_MMC_RESET_ONREAD_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MMCCR &= ~ETH_MMCCR_ROR) - -/** - * @brief Enables the MMC Counter Stop Rollover. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_ETH_MMC_COUNTER_ROLLOVER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->MMCCR &= ~ETH_MMCCR_CSR) - -/** - * @brief Disables the MMC Counter Stop Rollover. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_ETH_MMC_COUNTER_ROLLOVER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_CSR) - -/** - * @brief Resets the MMC Counters. - * @param __HANDLE__: ETH Handle. - * @retval None - */ -#define __HAL_ETH_MMC_COUNTERS_RESET(__HANDLE__) ((__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_CR) - -/** - * @brief Enables the specified ETHERNET MMC Rx interrupts. - * @param __HANDLE__: ETH Handle. - * @param __INTERRUPT__: specifies the ETHERNET MMC interrupt sources to be enabled or disabled. - * This parameter can be one of the following values: - * @arg ETH_MMC_IT_RGUF : When Rx good unicast frames counter reaches half the maximum value - * @arg ETH_MMC_IT_RFAE : When Rx alignment error counter reaches half the maximum value - * @arg ETH_MMC_IT_RFCE : When Rx crc error counter reaches half the maximum value - * @retval None - */ -#define __HAL_ETH_MMC_RX_IT_ENABLE(__HANDLE__, __INTERRUPT__) (__HANDLE__)->Instance->MMCRIMR &= ~((__INTERRUPT__) & 0xEFFFFFFF) -/** - * @brief Disables the specified ETHERNET MMC Rx interrupts. - * @param __HANDLE__: ETH Handle. - * @param __INTERRUPT__: specifies the ETHERNET MMC interrupt sources to be enabled or disabled. - * This parameter can be one of the following values: - * @arg ETH_MMC_IT_RGUF : When Rx good unicast frames counter reaches half the maximum value - * @arg ETH_MMC_IT_RFAE : When Rx alignment error counter reaches half the maximum value - * @arg ETH_MMC_IT_RFCE : When Rx crc error counter reaches half the maximum value - * @retval None - */ -#define __HAL_ETH_MMC_RX_IT_DISABLE(__HANDLE__, __INTERRUPT__) (__HANDLE__)->Instance->MMCRIMR |= ((__INTERRUPT__) & 0xEFFFFFFF) -/** - * @brief Enables the specified ETHERNET MMC Tx interrupts. - * @param __HANDLE__: ETH Handle. - * @param __INTERRUPT__: specifies the ETHERNET MMC interrupt sources to be enabled or disabled. - * This parameter can be one of the following values: - * @arg ETH_MMC_IT_TGF : When Tx good frame counter reaches half the maximum value - * @arg ETH_MMC_IT_TGFMSC: When Tx good multi col counter reaches half the maximum value - * @arg ETH_MMC_IT_TGFSC : When Tx good single col counter reaches half the maximum value - * @retval None - */ -#define __HAL_ETH_MMC_TX_IT_ENABLE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MMCRIMR &= ~ (__INTERRUPT__)) - -/** - * @brief Disables the specified ETHERNET MMC Tx interrupts. - * @param __HANDLE__: ETH Handle. - * @param __INTERRUPT__: specifies the ETHERNET MMC interrupt sources to be enabled or disabled. - * This parameter can be one of the following values: - * @arg ETH_MMC_IT_TGF : When Tx good frame counter reaches half the maximum value - * @arg ETH_MMC_IT_TGFMSC: When Tx good multi col counter reaches half the maximum value - * @arg ETH_MMC_IT_TGFSC : When Tx good single col counter reaches half the maximum value - * @retval None - */ -#define __HAL_ETH_MMC_TX_IT_DISABLE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MMCRIMR |= (__INTERRUPT__)) - -/** - * @brief Enables the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_ENABLE_IT() EXTI->IMR |= (ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Disables the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_DISABLE_IT() EXTI->IMR &= ~(ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Enable event on ETH External event line. - * @retval None. - */ -#define __HAL_ETH_WAKEUP_EXTI_ENABLE_EVENT() EXTI->EMR |= (ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Disable event on ETH External event line - * @retval None. - */ -#define __HAL_ETH_WAKEUP_EXTI_DISABLE_EVENT() EXTI->EMR &= ~(ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Get flag of the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_GET_FLAG() EXTI->PR & (ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Clear flag of the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_CLEAR_FLAG() EXTI->PR = (ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Enables rising edge trigger to the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_ENABLE_RISING_EDGE_TRIGGER() EXTI->RTSR |= ETH_EXTI_LINE_WAKEUP - -/** - * @brief Disables the rising edge trigger to the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_DISABLE_RISING_EDGE_TRIGGER() EXTI->RTSR &= ~(ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Enables falling edge trigger to the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_ENABLE_FALLING_EDGE_TRIGGER() EXTI->FTSR |= (ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Disables falling edge trigger to the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_DISABLE_FALLING_EDGE_TRIGGER() EXTI->FTSR &= ~(ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Enables rising/falling edge trigger to the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_ENABLE_FALLINGRISING_TRIGGER() EXTI->RTSR |= ETH_EXTI_LINE_WAKEUP;\ - EXTI->FTSR |= ETH_EXTI_LINE_WAKEUP - -/** - * @brief Disables rising/falling edge trigger to the ETH External interrupt line. - * @retval None - */ -#define __HAL_ETH_WAKEUP_EXTI_DISABLE_FALLINGRISING_TRIGGER() EXTI->RTSR &= ~(ETH_EXTI_LINE_WAKEUP);\ - EXTI->FTSR &= ~(ETH_EXTI_LINE_WAKEUP) - -/** - * @brief Generate a Software interrupt on selected EXTI line. - * @retval None. - */ -#define __HAL_ETH_WAKEUP_EXTI_GENERATE_SWIT() EXTI->SWIER|= ETH_EXTI_LINE_WAKEUP - -/** - * @} - */ -/* Exported functions --------------------------------------------------------*/ - -/** @addtogroup ETH_Exported_Functions - * @{ - */ - -/* Initialization and de-initialization functions ****************************/ - -/** @addtogroup ETH_Exported_Functions_Group1 - * @{ - */ -HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth); -HAL_StatusTypeDef HAL_ETH_DeInit(ETH_HandleTypeDef *heth); -void HAL_ETH_MspInit(ETH_HandleTypeDef *heth); -void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth); -HAL_StatusTypeDef HAL_ETH_DMATxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADescTypeDef *DMATxDescTab, uint8_t* TxBuff, uint32_t TxBuffCount); -HAL_StatusTypeDef HAL_ETH_DMARxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADescTypeDef *DMARxDescTab, uint8_t *RxBuff, uint32_t RxBuffCount); - -/** - * @} - */ -/* IO operation functions ****************************************************/ - -/** @addtogroup ETH_Exported_Functions_Group2 - * @{ - */ -HAL_StatusTypeDef HAL_ETH_TransmitFrame(ETH_HandleTypeDef *heth, uint32_t FrameLength); -HAL_StatusTypeDef HAL_ETH_GetReceivedFrame(ETH_HandleTypeDef *heth); -/* Communication with PHY functions*/ -HAL_StatusTypeDef HAL_ETH_ReadPHYRegister(ETH_HandleTypeDef *heth, uint16_t PHYReg, uint32_t *RegValue); -HAL_StatusTypeDef HAL_ETH_WritePHYRegister(ETH_HandleTypeDef *heth, uint16_t PHYReg, uint32_t RegValue); -/* Non-Blocking mode: Interrupt */ -HAL_StatusTypeDef HAL_ETH_GetReceivedFrame_IT(ETH_HandleTypeDef *heth); -void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth); -/* Callback in non blocking modes (Interrupt) */ -void HAL_ETH_TxCpltCallback(ETH_HandleTypeDef *heth); -void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth); -void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth); -/** - * @} - */ - -/* Peripheral Control functions **********************************************/ - -/** @addtogroup ETH_Exported_Functions_Group3 - * @{ - */ - -HAL_StatusTypeDef HAL_ETH_Start(ETH_HandleTypeDef *heth); -HAL_StatusTypeDef HAL_ETH_Stop(ETH_HandleTypeDef *heth); -HAL_StatusTypeDef HAL_ETH_ConfigMAC(ETH_HandleTypeDef *heth, ETH_MACInitTypeDef *macconf); -HAL_StatusTypeDef HAL_ETH_ConfigDMA(ETH_HandleTypeDef *heth, ETH_DMAInitTypeDef *dmaconf); -/** - * @} - */ - -/* Peripheral State functions ************************************************/ - -/** @addtogroup ETH_Exported_Functions_Group4 - * @{ - */ -HAL_ETH_StateTypeDef HAL_ETH_GetState(ETH_HandleTypeDef *heth); -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4xx_HAL_ETH_H */ - - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/WinPCap/FaultInjection.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/WinPCap/FaultInjection.c deleted file mode 100755 index 9ae5773..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/WinPCap/FaultInjection.c +++ /dev/null @@ -1,173 +0,0 @@ -#define xBUFFER_CACHE_SIZE 10 -#define xMAX_FAULT_INJECTION_RATE 15 -#define xMIN_FAULT_INJECTION_RATE 3 -#define xNUM_FAULT_TYPES 1 - -static NetworkBufferDescriptor_t *xNetworkBufferCache[ xBUFFER_CACHE_SIZE ] = { 0 }; - -#define xFAULT_LOG_SIZE 2048 -uint32_t ulInjectedFault[ xFAULT_LOG_SIZE ]; -uint32_t ulFaultLogIndex = 0; - -static BaseType_t prvCachePacket( NetworkBufferDescriptor_t *pxNetworkBufferIn ) -{ -BaseType_t x, xReturn = pdFALSE; - - for( x = 0; x < xBUFFER_CACHE_SIZE; x++ ) - { - if( xNetworkBufferCache[ x ] == NULL ) - { - xNetworkBufferCache[ x ] = pxNetworkBufferIn; - xReturn = pdTRUE; - break; - } - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -static NetworkBufferDescriptor_t *prvGetCachedPacket( void ) -{ -BaseType_t x; -NetworkBufferDescriptor_t *pxReturn = NULL; - - for( x = ( xBUFFER_CACHE_SIZE - 1 ); x >= 0; x-- ) - { - if( xNetworkBufferCache[ x ] != NULL ) - { - pxReturn = xNetworkBufferCache[ x ]; - xNetworkBufferCache[ x ] = NULL; - break; - } - } - - return pxReturn; -} -/*-----------------------------------------------------------*/ - -static NetworkBufferDescriptor_t *prvDuplicatePacket( NetworkBufferDescriptor_t * pxOriginalPacket, const uint8_t *pucPacketData ) -{ -NetworkBufferDescriptor_t *pxReturn; - - /* Obtain a new descriptor. */ - pxReturn = pxGetNetworkBufferWithDescriptor( pxOriginalPacket->xDataLength, 0 ); - - if( pxReturn != NULL ) - { - /* Copy in the packet data. */ - pxReturn->xDataLength = pxOriginalPacket->xDataLength; - memcpy( pxReturn->pucEthernetBuffer, pucPacketData, pxOriginalPacket->xDataLength ); - } - - return pxReturn; -} -/*-----------------------------------------------------------*/ - -static NetworkBufferDescriptor_t *prvRxFaultInjection( NetworkBufferDescriptor_t *pxNetworkBufferIn, const uint8_t *pucPacketData ) -{ -static uint32_t ulCallCount = 0, ulNextFaultCallCount = 0; -NetworkBufferDescriptor_t *pxReturn = pxNetworkBufferIn; -IPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL }; -uint32_t ulFault; - -return pxNetworkBufferIn; - - ulCallCount++; - - if( ulCallCount > ulNextFaultCallCount ) - { - ulNextFaultCallCount = ipconfigRAND32() % xMAX_FAULT_INJECTION_RATE; - if( ulNextFaultCallCount < xMIN_FAULT_INJECTION_RATE ) - { - ulNextFaultCallCount = xMIN_FAULT_INJECTION_RATE; - } - - ulCallCount = 0; - - ulFault = ipconfigRAND32() % xNUM_FAULT_TYPES; - - if( ulFaultLogIndex < xFAULT_LOG_SIZE ) - { - ulInjectedFault[ ulFaultLogIndex ] = ulFault; - ulFaultLogIndex++; - } - - switch( ulFault ) - { - case 0: - /* Just drop the packet. */ - vReleaseNetworkBufferAndDescriptor( pxNetworkBufferIn ); - pxReturn = NULL; - break; - - case 1: - /* Store the packet in the cache for later. */ - if( prvCachePacket( pxNetworkBufferIn ) == pdTRUE ) - { - /* The packet may get sent later, it is not being sent - now. */ - pxReturn = NULL; - } - break; - - case 2: - /* Send a cached packet. */ - pxReturn = prvGetCachedPacket(); - if( pxReturn != NULL ) - { - /* A cached packet was obtained so drop the original - packet. */ - vReleaseNetworkBufferAndDescriptor( pxNetworkBufferIn ); - } - else - { - /* Could not obtain a packet from the cache so just return - the packet that was passed in. */ - pxReturn = pxNetworkBufferIn; - } - break; - - case 4: - - /* Send a duplicate of the packet right away. */ - pxReturn = prvDuplicatePacket( pxNetworkBufferIn, pucPacketData ); - - /* Send the original packet to the stack. */ - xRxEvent.pvData = ( void * ) pxNetworkBufferIn; - if( xSendEventStructToIPTask( &xRxEvent, ( TickType_t ) 0 ) == pdFAIL ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBufferIn ); - } - break; - - case 5: - - /* Send both a cached packet and the current packet. */ - xRxEvent.pvData = ( void * ) prvGetCachedPacket(); - if( xRxEvent.pvData != NULL ) - { - if( xSendEventStructToIPTask( &xRxEvent, ( TickType_t ) 0 ) == pdFAIL ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBufferIn ); - } - } - break; - - case 6: - case 7: - case 8: - /* Store the packet in the cache for later. */ - if( prvCachePacket( pxNetworkBufferIn ) == pdTRUE ) - { - /* The packet may get sent later, it is not being sent - now. */ - pxReturn = NULL; - } - break; - } - } - - return pxReturn; -} -/*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/WinPCap/NetworkInterface.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/WinPCap/NetworkInterface.c deleted file mode 100755 index f273477..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/WinPCap/NetworkInterface.c +++ /dev/null @@ -1,634 +0,0 @@ -/* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - http://aws.amazon.com/freertos - http://www.FreeRTOS.org -*/ - -/* WinPCap includes. */ -#define HAVE_REMOTE -#include "pcap.h" - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_IP_Private.h" -#include "NetworkBufferManagement.h" - -/* Thread-safe circular buffers are being used to pass data to and from the PCAP -access functions. */ -#include "Win32-Extensions.h" -#include "FreeRTOS_Stream_Buffer.h" - -/* Sizes of the thread safe circular buffers used to pass data to and from the -WinPCAP Windows threads. */ -#define xSEND_BUFFER_SIZE 32768 -#define xRECV_BUFFER_SIZE 32768 - -/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1, then the Ethernet -driver will filter incoming packets and only pass the stack those packets it -considers need processing. */ -#if( ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES == 0 ) - #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer -#else - #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) ) -#endif - -/* Used to insert test code only. */ -#define niDISRUPT_PACKETS 0 - -/*-----------------------------------------------------------*/ - -/* - * Windows threads that are outside of the control of the FreeRTOS simulator are - * used to interface with the WinPCAP libraries. - */ -DWORD WINAPI prvWinPcapRecvThread( void *pvParam ); -DWORD WINAPI prvWinPcapSendThread( void *pvParam ); - -/* - * Print out a numbered list of network interfaces that are available on the - * host computer. - */ -static pcap_if_t * prvPrintAvailableNetworkInterfaces( void ); - -/* - * Open the network interface. The number of the interface to be opened is set - * by the configNETWORK_INTERFACE_TO_USE constant in FreeRTOSConfig.h. - */ -static void prvOpenSelectedNetworkInterface( pcap_if_t *pxAllNetworkInterfaces ); -static int prvOpenInterface( const char *pucName ); - -/* - * Configure the capture filter to allow blocking reads, and to filter out - * packets that are not of interest to this demo. - */ -static void prvConfigureCaptureBehaviour( void ); - -/* - * A function that simulates Ethernet interrupts by periodically polling the - * WinPCap interface for new data. - */ -static void prvInterruptSimulatorTask( void *pvParameters ); - -/* - * Create the buffers that are used to pass data between the FreeRTOS simulator - * and the Win32 threads that manage WinPCAP. - */ -static void prvCreateThreadSafeBuffers( void ); - -/* - * Utility function used to format print messages only. - */ -static const char *prvRemoveSpaces( char *pcBuffer, int aBuflen, const char *pcMessage ); - -/*-----------------------------------------------------------*/ - -/* Required by the WinPCap library. */ -static char cErrorBuffer[ PCAP_ERRBUF_SIZE ]; - -/* An event used to wake up the Win32 thread that sends data through the WinPCAP -library. */ -static void *pvSendEvent = NULL; - -/* _HT_ made the PCAP interface number configurable through the program's -parameters in order to test in different machines. */ -static BaseType_t xConfigNextworkInterfaceToUse = configNETWORK_INTERFACE_TO_USE; - -/* Handles to the Windows threads that handle the PCAP IO. */ -static HANDLE vWinPcapRecvThreadHandle = NULL; -static HANDLE vWinPcapSendThreadHandle = NULL;; - -/* The interface being used by WinPCap. */ -static pcap_t *pxOpenedInterfaceHandle = NULL; - -/* Circular buffers used by the PCAP Win32 threads. */ -static StreamBuffer_t *xSendBuffer = NULL; -static StreamBuffer_t *xRecvBuffer = NULL; - -/* The MAC address initially set to the constants defined in FreeRTOSConfig.h. */ -extern uint8_t ucMACAddress[ 6 ]; - -/* Logs the number of WinPCAP send failures, for viewing in the debugger only. */ -static volatile uint32_t ulWinPCAPSendFailures = 0; - -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceInitialise( void ) -{ -BaseType_t xReturn = pdFALSE; -pcap_if_t *pxAllNetworkInterfaces; - - /* Query the computer the simulation is being executed on to find the - network interfaces it has installed. */ - pxAllNetworkInterfaces = prvPrintAvailableNetworkInterfaces(); - - /* Open the network interface. The number of the interface to be opened is - set by the configNETWORK_INTERFACE_TO_USE constant in FreeRTOSConfig.h. - Calling this function will set the pxOpenedInterfaceHandle variable. If, - after calling this function, pxOpenedInterfaceHandle is equal to NULL, then - the interface could not be opened. */ - if( pxAllNetworkInterfaces != NULL ) - { - prvOpenSelectedNetworkInterface( pxAllNetworkInterfaces ); - } - - if( pxOpenedInterfaceHandle != NULL ) - { - xReturn = pdPASS; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -static void prvCreateThreadSafeBuffers( void ) -{ - /* The buffer used to pass data to be transmitted from a FreeRTOS task to - the Win32 thread that sends via the WinPCAP library. */ - if( xSendBuffer == NULL) - { - xSendBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xSendBuffer ) - sizeof( xSendBuffer->ucArray ) + xSEND_BUFFER_SIZE + 1 ); - configASSERT( xSendBuffer ); - memset( xSendBuffer, '\0', sizeof( *xSendBuffer ) - sizeof( xSendBuffer->ucArray ) ); - xSendBuffer->LENGTH = xSEND_BUFFER_SIZE + 1; - } - - /* The buffer used to pass received data from the Win32 thread that receives - via the WinPCAP library to the FreeRTOS task. */ - if( xRecvBuffer == NULL) - { - xRecvBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xRecvBuffer ) - sizeof( xRecvBuffer->ucArray ) + xRECV_BUFFER_SIZE + 1 ); - configASSERT( xRecvBuffer ); - memset( xRecvBuffer, '\0', sizeof( *xRecvBuffer ) - sizeof( xRecvBuffer->ucArray ) ); - xRecvBuffer->LENGTH = xRECV_BUFFER_SIZE + 1; - } -} -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer, BaseType_t bReleaseAfterSend ) -{ -size_t xSpace; - - iptraceNETWORK_INTERFACE_TRANSMIT(); - configASSERT( xIsCallingFromIPTask() == pdTRUE ); - - /* Both the length of the data being sent and the actual data being sent - are placed in the thread safe buffer used to pass data between the FreeRTOS - tasks and the Win32 thread that sends data via the WinPCAP library. Drop - the packet if there is insufficient space in the buffer to hold both. */ - xSpace = uxStreamBufferGetSpace( xSendBuffer ); - - if( ( pxNetworkBuffer->xDataLength <= ( ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER ) ) && - ( xSpace >= ( pxNetworkBuffer->xDataLength + sizeof( pxNetworkBuffer->xDataLength ) ) ) ) - { - /* First write in the length of the data, then write in the data - itself. */ - uxStreamBufferAdd( xSendBuffer, 0, ( const uint8_t * ) &( pxNetworkBuffer->xDataLength ), sizeof( pxNetworkBuffer->xDataLength ) ); - uxStreamBufferAdd( xSendBuffer, 0, ( const uint8_t * ) pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength ); - } - else - { - FreeRTOS_debug_printf( ( "xNetworkInterfaceOutput: send buffers full to store %lu\n", pxNetworkBuffer->xDataLength ) ); - } - - /* Kick the Tx task in either case in case it doesn't know the buffer is - full. */ - SetEvent( pvSendEvent ); - - /* The buffer has been sent so can be released. */ - if( bReleaseAfterSend != pdFALSE ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - } - - return pdPASS; -} -/*-----------------------------------------------------------*/ - -static pcap_if_t * prvPrintAvailableNetworkInterfaces( void ) -{ -pcap_if_t * pxAllNetworkInterfaces = NULL, *xInterface; -int32_t lInterfaceNumber = 1; -char cBuffer[ 512 ]; -static BaseType_t xInvalidInterfaceDetected = pdFALSE; - - if( xInvalidInterfaceDetected == pdFALSE ) - { - if( pcap_findalldevs_ex( PCAP_SRC_IF_STRING, NULL, &pxAllNetworkInterfaces, cErrorBuffer ) == -1 ) - { - printf( "Could not obtain a list of network interfaces\n%s\n", cErrorBuffer ); - pxAllNetworkInterfaces = NULL; - } - else - { - printf( "\r\n\r\nThe following network interfaces are available:\r\n\r\n" ); - } - - if( pxAllNetworkInterfaces != NULL ) - { - /* Print out the list of network interfaces. The first in the list - is interface '1', not interface '0'. */ - for( xInterface = pxAllNetworkInterfaces; xInterface != NULL; xInterface = xInterface->next ) - { - /* The descriptions of the devices can be full of spaces, clean them - a little. printf() can only be used here because the network is not - up yet - so no other network tasks will be running. */ - printf( "Interface %d - %s\n", lInterfaceNumber, prvRemoveSpaces( cBuffer, sizeof( cBuffer ), xInterface->name ) ); - printf( " (%s)\n", prvRemoveSpaces(cBuffer, sizeof( cBuffer ), xInterface->description ? xInterface->description : "No description" ) ); - printf( "\n" ); - lInterfaceNumber++; - } - } - - if( lInterfaceNumber == 1 ) - { - /* The interface number was never incremented, so the above for() loop - did not execute meaning no interfaces were found. */ - printf( " \nNo network interfaces were found.\n" ); - pxAllNetworkInterfaces = NULL; - } - - printf( "\r\nThe interface that will be opened is set by " ); - printf( "\"configNETWORK_INTERFACE_TO_USE\", which\r\nshould be defined in FreeRTOSConfig.h\r\n" ); - - if( ( xConfigNextworkInterfaceToUse < 0L ) || ( xConfigNextworkInterfaceToUse >= lInterfaceNumber ) ) - { - printf( "\r\nERROR: configNETWORK_INTERFACE_TO_USE is set to %d, which is an invalid value.\r\n", xConfigNextworkInterfaceToUse ); - printf( "Please set configNETWORK_INTERFACE_TO_USE to one of the interface numbers listed above,\r\n" ); - printf( "then re-compile and re-start the application. Only Ethernet (as opposed to WiFi)\r\n" ); - printf( "interfaces are supported.\r\n\r\nHALTING\r\n\r\n\r\n" ); - xInvalidInterfaceDetected = pdTRUE; - - if( pxAllNetworkInterfaces != NULL ) - { - /* Free the device list, as no devices are going to be opened. */ - pcap_freealldevs( pxAllNetworkInterfaces ); - pxAllNetworkInterfaces = NULL; - } - } - else - { - printf( "Attempting to open interface number %d.\n", xConfigNextworkInterfaceToUse ); - } - } - - return pxAllNetworkInterfaces; -} -/*-----------------------------------------------------------*/ - -static int prvOpenInterface( const char *pucName ) -{ -static char pucInterfaceName[ 256 ]; - - if( pucName != NULL ) - { - strncpy( pucInterfaceName, pucName, sizeof( pucInterfaceName ) ); - } - - pxOpenedInterfaceHandle = pcap_open( pucInterfaceName, /* The name of the selected interface. */ - ipTOTAL_ETHERNET_FRAME_SIZE, /* The size of the packet to capture. */ - PCAP_OPENFLAG_PROMISCUOUS, /* Open in promiscuous mode as the MAC and - IP address is going to be "simulated", and - not be the real MAC and IP address. This allows - traffic to the simulated IP address to be routed - to uIP, and traffic to the real IP address to be - routed to the Windows TCP/IP stack. */ - 100, - NULL, /* No authentication is required as this is - not a remote capture session. */ - cErrorBuffer - ); - - if ( pxOpenedInterfaceHandle == NULL ) - { - printf( "\n%s is not supported by WinPcap and cannot be opened\n", pucInterfaceName ); - return 1; - } - else - { - /* Configure the capture filter to allow blocking reads, and to filter - out packets that are not of interest to this demo. */ - prvConfigureCaptureBehaviour(); - } - return 0; -} -/*-----------------------------------------------------------*/ - -static void prvOpenSelectedNetworkInterface( pcap_if_t *pxAllNetworkInterfaces ) -{ -pcap_if_t *xInterface; -int32_t x; - - /* Walk the list of devices until the selected device is located. */ - xInterface = pxAllNetworkInterfaces; - if (0 == xConfigNextworkInterfaceToUse) { - while (NULL != xInterface) { - xInterface = xInterface->next; - if (0 == prvOpenInterface(xInterface->name)) { - break; - } - } - } - else { - for (x = 1L; x < xConfigNextworkInterfaceToUse; x++) - { - xInterface = xInterface->next; - } - /* Open the selected interface. */ - (void) prvOpenInterface(xInterface->name); - } - - /* The device list is no longer required. */ - pcap_freealldevs( pxAllNetworkInterfaces ); -} -/*-----------------------------------------------------------*/ - -static void prvConfigureCaptureBehaviour( void ) -{ -struct bpf_program xFilterCode; -uint32_t ulNetMask; - - /* Set up a filter so only the packets of interest are passed to the IP - stack. cErrorBuffer is used for convenience to create the string. Don't - confuse this with an error message. */ - sprintf( cErrorBuffer, "broadcast or multicast or ether host %x:%x:%x:%x:%x:%x", - ucMACAddress[0], ucMACAddress[1], ucMACAddress[2], ucMACAddress[3], ucMACAddress[4], ucMACAddress[5] ); - - ulNetMask = ( configNET_MASK3 << 24UL ) | ( configNET_MASK2 << 16UL ) | ( configNET_MASK1 << 8L ) | configNET_MASK0; - - if( pcap_compile( pxOpenedInterfaceHandle, &xFilterCode, cErrorBuffer, 1, ulNetMask ) < 0 ) - { - printf( "\nThe packet filter string is invalid\n" ); - } - else - { - if( pcap_setfilter( pxOpenedInterfaceHandle, &xFilterCode ) < 0 ) - { - printf( "\nAn error occurred setting the packet filter.\n" ); - } - } - - /* Create the buffers used to pass packets between the FreeRTOS simulator - and the Win32 threads that are handling WinPCAP. */ - prvCreateThreadSafeBuffers(); - - if( pvSendEvent == NULL ) - { - /* Create event used to signal the Win32 WinPCAP Tx thread. */ - pvSendEvent = CreateEvent( NULL, FALSE, TRUE, NULL ); - - /* Create the Win32 thread that handles WinPCAP Rx. */ - vWinPcapRecvThreadHandle = CreateThread( - NULL, /* Pointer to thread security attributes. */ - 0, /* Initial thread stack size, in bytes. */ - prvWinPcapRecvThread, /* Pointer to thread function. */ - NULL, /* Argument for new thread. */ - 0, /* Creation flags. */ - NULL ); - - /* Use the cores that are not used by the FreeRTOS tasks. */ - SetThreadAffinityMask( vWinPcapRecvThreadHandle, ~0x01u ); - - /* Create the Win32 thread that handlers WinPCAP Tx. */ - vWinPcapSendThreadHandle = CreateThread( - NULL, /* Pointer to thread security attributes. */ - 0, /* initial thread stack size, in bytes. */ - prvWinPcapSendThread, /* Pointer to thread function. */ - NULL, /* Argument for new thread. */ - 0, /* Creation flags. */ - NULL ); - - /* Use the cores that are not used by the FreeRTOS tasks. */ - SetThreadAffinityMask( vWinPcapSendThreadHandle, ~0x01u ); - - /* Create a task that simulates an interrupt in a real system. This will - block waiting for packets, then send a message to the IP task when data - is available. */ - xTaskCreate( prvInterruptSimulatorTask, "MAC_ISR", configMINIMAL_STACK_SIZE, NULL, configMAC_ISR_SIMULATOR_PRIORITY, NULL ); - } -} -/*-----------------------------------------------------------*/ - -/* WinPCAP function. */ -void pcap_callback( u_char *user, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data ) -{ - (void)user; - - /* THIS IS CALLED FROM A WINDOWS THREAD - DO NOT ATTEMPT ANY FREERTOS CALLS - OR TO PRINT OUT MESSAGES HERE. */ - - /* Pass data to the FreeRTOS simulator on a thread safe circular buffer. */ - if( ( pkt_header->caplen <= ( ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER ) ) && - ( uxStreamBufferGetSpace( xRecvBuffer ) >= ( ( ( size_t ) pkt_header->caplen ) + sizeof( *pkt_header ) ) ) ) - { - uxStreamBufferAdd( xRecvBuffer, 0, ( const uint8_t* ) pkt_header, sizeof( *pkt_header ) ); - uxStreamBufferAdd( xRecvBuffer, 0, ( const uint8_t* ) pkt_data, ( size_t ) pkt_header->caplen ); - } -} -/*-----------------------------------------------------------*/ - -DWORD WINAPI prvWinPcapRecvThread ( void *pvParam ) -{ - ( void ) pvParam; - - /* THIS IS A WINDOWS THREAD - DO NOT ATTEMPT ANY FREERTOS CALLS OR TO PRINT - OUT MESSAGES HERE. */ - - for( ;; ) - { - pcap_dispatch( pxOpenedInterfaceHandle, 1, pcap_callback, ( u_char * ) "mydata" ); - } -} -/*-----------------------------------------------------------*/ - -DWORD WINAPI prvWinPcapSendThread( void *pvParam ) -{ -size_t xLength; -uint8_t ucBuffer[ ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER ]; -static char cErrorMessage[ 1024 ]; -const DWORD xMaxMSToWait = 1000; - - /* THIS IS A WINDOWS THREAD - DO NOT ATTEMPT ANY FREERTOS CALLS OR TO PRINT - OUT MESSAGES HERE. */ - - /* Remove compiler warnings about unused parameters. */ - ( void ) pvParam; - - for( ;; ) - { - /* Wait until notified of something to send. */ - WaitForSingleObject( pvSendEvent, xMaxMSToWait ); - - /* Is there more than the length value stored in the circular buffer - used to pass data from the FreeRTOS simulator into this Win32 thread? */ - while( uxStreamBufferGetSize( xSendBuffer ) > sizeof( xLength ) ) - { - uxStreamBufferGet( xSendBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE ); - uxStreamBufferGet( xSendBuffer, 0, ( uint8_t* ) ucBuffer, xLength, pdFALSE ); - if( pcap_sendpacket( pxOpenedInterfaceHandle, ucBuffer, xLength ) != 0 ) - { - ulWinPCAPSendFailures++; - } - } - } -} -/*-----------------------------------------------------------*/ - -static void prvInterruptSimulatorTask( void *pvParameters ) -{ -struct pcap_pkthdr xHeader; -static struct pcap_pkthdr *pxHeader; -const uint8_t *pucPacketData; -uint8_t ucRecvBuffer[ ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER ]; -NetworkBufferDescriptor_t *pxNetworkBuffer; -IPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL }; -eFrameProcessingResult_t eResult; - - /* Remove compiler warnings about unused parameters. */ - ( void ) pvParameters; - - for( ;; ) - { - /* Does the circular buffer used to pass data from the Win32 thread that - handles WinPCAP Rx into the FreeRTOS simulator contain another packet? */ - if( uxStreamBufferGetSize( xRecvBuffer ) > sizeof( xHeader ) ) - { - /* Get the next packet. */ - uxStreamBufferGet( xRecvBuffer, 0, (uint8_t*)&xHeader, sizeof( xHeader ), pdFALSE ); - uxStreamBufferGet( xRecvBuffer, 0, (uint8_t*)ucRecvBuffer, ( size_t ) xHeader.len, pdFALSE ); - pucPacketData = ucRecvBuffer; - pxHeader = &xHeader; - - iptraceNETWORK_INTERFACE_RECEIVE(); - - /* Check for minimal size. */ - if( pxHeader->len >= sizeof( EthernetHeader_t ) ) - { - eResult = ipCONSIDER_FRAME_FOR_PROCESSING( pucPacketData ); - } - else - { - eResult = eReleaseBuffer; - } - - if( eResult == eProcessBuffer ) - { - /* Will the data fit into the frame buffer? */ - if( pxHeader->len <= ipTOTAL_ETHERNET_FRAME_SIZE ) - { - /* Obtain a buffer into which the data can be placed. This - is only an interrupt simulator, not a real interrupt, so it - is ok to call the task level function here, but note that - some buffer implementations cannot be called from a real - interrupt. */ - pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( pxHeader->len, 0 ); - - if( pxNetworkBuffer != NULL ) - { - memcpy( pxNetworkBuffer->pucEthernetBuffer, pucPacketData, pxHeader->len ); - pxNetworkBuffer->xDataLength = ( size_t ) pxHeader->len; - - #if( niDISRUPT_PACKETS == 1 ) - { - pxNetworkBuffer = vRxFaultInjection( pxNetworkBuffer, pucPacketData ); - } - #endif /* niDISRUPT_PACKETS */ - - if( pxNetworkBuffer != NULL ) - { - xRxEvent.pvData = ( void * ) pxNetworkBuffer; - - /* Data was received and stored. Send a message to - the IP task to let it know. */ - if( xSendEventStructToIPTask( &xRxEvent, ( TickType_t ) 0 ) == pdFAIL ) - { - /* The buffer could not be sent to the stack so - must be released again. This is only an - interrupt simulator, not a real interrupt, so it - is ok to use the task level function here, but - note no all buffer implementations will allow - this function to be executed from a real - interrupt. */ - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - iptraceETHERNET_RX_EVENT_LOST(); - } - } - else - { - /* The packet was already released or stored inside - vRxFaultInjection(). Don't release it here. */ - } - } - else - { - iptraceETHERNET_RX_EVENT_LOST(); - } - } - else - { - /* Log that a packet was dropped because it would have - overflowed the buffer, but there may be more buffers to - process. */ - } - } - } - else - { - /* There is no real way of simulating an interrupt. Make sure - other tasks can run. */ - vTaskDelay( configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ); - } - } -} -/*-----------------------------------------------------------*/ - -static const char *prvRemoveSpaces( char *pcBuffer, int aBuflen, const char *pcMessage ) -{ - char *pcTarget = pcBuffer; - - /* Utility function used to formap messages being printed only. */ - while( ( *pcMessage != 0 ) && ( pcTarget < ( pcBuffer + aBuflen - 1 ) ) ) - { - *( pcTarget++ ) = *pcMessage; - - if( isspace( *pcMessage ) != pdFALSE ) - { - while( isspace( *pcMessage ) != pdFALSE ) - { - pcMessage++; - } - } - else - { - pcMessage++; - } - } - - *pcTarget = '\0'; - - return pcBuffer; -} - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/NetworkInterface.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/NetworkInterface.c deleted file mode 100755 index 9ae46a8..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/NetworkInterface.c +++ /dev/null @@ -1,398 +0,0 @@ -/* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - http://aws.amazon.com/freertos - http://www.FreeRTOS.org -*/ - -/* Standard includes. */ -#include -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "NetworkBufferManagement.h" -#include "NetworkInterface.h" - -/* Xilinx library files. */ -#include -#include "Zynq/x_topology.h" -#include "Zynq/x_emacpsif.h" -#include "Zynq/x_emacpsif_hw.h" - -/* Provided memory configured as uncached. */ -#include "uncached_memory.h" - -#ifndef BMSR_LINK_STATUS - #define BMSR_LINK_STATUS 0x0004UL -#endif - -#ifndef PHY_LS_HIGH_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still high after 15 seconds of not - receiving packets. */ - #define PHY_LS_HIGH_CHECK_TIME_MS 15000 -#endif - -#ifndef PHY_LS_LOW_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still low every second. */ - #define PHY_LS_LOW_CHECK_TIME_MS 1000 -#endif - -/* The size of each buffer when BufferAllocation_1 is used: -http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Ethernet_Buffer_Management.html */ -#define niBUFFER_1_PACKET_SIZE 1536 - -/* Naming and numbering of PHY registers. */ -#define PHY_REG_01_BMSR 0x01 /* Basic mode status register */ - -#ifndef iptraceEMAC_TASK_STARTING - #define iptraceEMAC_TASK_STARTING() do { } while( 0 ) -#endif - -/* Default the size of the stack used by the EMAC deferred handler task to twice -the size of the stack used by the idle task - but allow this to be overridden in -FreeRTOSConfig.h as configMINIMAL_STACK_SIZE is a user definable constant. */ -#ifndef configEMAC_TASK_STACK_SIZE - #define configEMAC_TASK_STACK_SIZE ( 2 * configMINIMAL_STACK_SIZE ) -#endif - -/*-----------------------------------------------------------*/ - -/* - * Look for the link to be up every few milliseconds until either xMaxTime time - * has passed or a link is found. - */ -static BaseType_t prvGMACWaitLS( TickType_t xMaxTime ); - -/* - * A deferred interrupt handler for all MAC/DMA interrupt sources. - */ -static void prvEMACHandlerTask( void *pvParameters ); - -/*-----------------------------------------------------------*/ - -/* EMAC data/descriptions. */ -static xemacpsif_s xEMACpsif; -struct xtopology_t xXTopology = -{ - .emac_baseaddr = XPAR_PS7_ETHERNET_0_BASEADDR, - .emac_type = xemac_type_emacps, - .intc_baseaddr = 0x0, - .intc_emac_intr = 0x0, - .scugic_baseaddr = XPAR_PS7_SCUGIC_0_BASEADDR, - .scugic_emac_intr = 0x36, -}; - -XEmacPs_Config mac_config = -{ - .DeviceId = XPAR_PS7_ETHERNET_0_DEVICE_ID, /**< Unique ID of device */ - .BaseAddress = XPAR_PS7_ETHERNET_0_BASEADDR /**< Physical base address of IPIF registers */ -}; - -extern int phy_detected; - -/* A copy of PHY register 1: 'PHY_REG_01_BMSR' */ -static uint32_t ulPHYLinkStatus = 0; - -#if( ipconfigUSE_LLMNR == 1 ) - static const uint8_t xLLMNR_MACAddress[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0xFC }; -#endif - -/* ucMACAddress as it appears in main.c */ -extern const uint8_t ucMACAddress[ 6 ]; - -/* Holds the handle of the task used as a deferred interrupt processor. The -handle is used so direct notifications can be sent to the task for all EMAC/DMA -related interrupts. */ -TaskHandle_t xEMACTaskHandle = NULL; - -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceInitialise( void ) -{ -uint32_t ulLinkSpeed, ulDMAReg; -BaseType_t xStatus, xLinkStatus; -XEmacPs *pxEMAC_PS; -const TickType_t xWaitLinkDelay = pdMS_TO_TICKS( 7000UL ), xWaitRelinkDelay = pdMS_TO_TICKS( 1000UL ); - - /* Guard against the init function being called more than once. */ - if( xEMACTaskHandle == NULL ) - { - pxEMAC_PS = &( xEMACpsif.emacps ); - memset( &xEMACpsif, '\0', sizeof( xEMACpsif ) ); - - xStatus = XEmacPs_CfgInitialize( pxEMAC_PS, &mac_config, mac_config.BaseAddress); - if( xStatus != XST_SUCCESS ) - { - FreeRTOS_printf( ( "xEMACInit: EmacPs Configuration Failed....\n" ) ); - } - - /* Initialize the mac and set the MAC address. */ - XEmacPs_SetMacAddress( pxEMAC_PS, ( void * ) ucMACAddress, 1 ); - - #if( ipconfigUSE_LLMNR == 1 ) - { - /* Also add LLMNR multicast MAC address. */ - XEmacPs_SetMacAddress( pxEMAC_PS, ( void * )xLLMNR_MACAddress, 2 ); - } - #endif /* ipconfigUSE_LLMNR == 1 */ - - XEmacPs_SetMdioDivisor( pxEMAC_PS, MDC_DIV_224 ); - ulLinkSpeed = Phy_Setup( pxEMAC_PS ); - XEmacPs_SetOperatingSpeed( pxEMAC_PS, ulLinkSpeed); - - /* Setting the operating speed of the MAC needs a delay. */ - vTaskDelay( pdMS_TO_TICKS( 25UL ) ); - - ulDMAReg = XEmacPs_ReadReg( pxEMAC_PS->Config.BaseAddress, XEMACPS_DMACR_OFFSET); - - /* DISC_WHEN_NO_AHB: when set, the GEM DMA will automatically discard receive - packets from the receiver packet buffer memory when no AHB resource is available. */ - XEmacPs_WriteReg( pxEMAC_PS->Config.BaseAddress, XEMACPS_DMACR_OFFSET, - ulDMAReg | XEMACPS_DMACR_DISC_WHEN_NO_AHB_MASK); - - setup_isr( &xEMACpsif ); - init_dma( &xEMACpsif ); - start_emacps( &xEMACpsif ); - - prvGMACWaitLS( xWaitLinkDelay ); - - /* The deferred interrupt handler task is created at the highest - possible priority to ensure the interrupt handler can return directly - to it. The task's handle is stored in xEMACTaskHandle so interrupts can - notify the task when there is something to process. */ - xTaskCreate( prvEMACHandlerTask, "EMAC", configEMAC_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, &xEMACTaskHandle ); - } - else - { - /* Initialisation was already performed, just wait for the link. */ - prvGMACWaitLS( xWaitRelinkDelay ); - } - - /* Only return pdTRUE when the Link Status of the PHY is high, otherwise the - DHCP process and all other communication will fail. */ - xLinkStatus = xGetPhyLinkStatus(); - - return ( xLinkStatus != pdFALSE ); -} -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxBuffer, BaseType_t bReleaseAfterSend ) -{ - if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) - { - iptraceNETWORK_INTERFACE_TRANSMIT(); - emacps_send_message( &xEMACpsif, pxBuffer, bReleaseAfterSend ); - } - else if( bReleaseAfterSend != pdFALSE ) - { - /* No link. */ - vReleaseNetworkBufferAndDescriptor( pxBuffer ); - } - - return pdTRUE; -} -/*-----------------------------------------------------------*/ - -static inline unsigned long ulReadMDIO( unsigned ulRegister ) -{ -uint16_t usValue; - - XEmacPs_PhyRead( &( xEMACpsif.emacps ), phy_detected, ulRegister, &usValue ); - return usValue; -} -/*-----------------------------------------------------------*/ - -static BaseType_t prvGMACWaitLS( TickType_t xMaxTime ) -{ -TickType_t xStartTime, xEndTime; -const TickType_t xShortDelay = pdMS_TO_TICKS( 20UL ); -BaseType_t xReturn; - - xStartTime = xTaskGetTickCount(); - - for( ;; ) - { - xEndTime = xTaskGetTickCount(); - - if( xEndTime - xStartTime > xMaxTime ) - { - xReturn = pdFALSE; - break; - } - ulPHYLinkStatus = ulReadMDIO( PHY_REG_01_BMSR ); - - if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) - { - xReturn = pdTRUE; - break; - } - - vTaskDelay( xShortDelay ); - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -void vNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkBuffers[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ] ) -{ -static uint8_t ucNetworkPackets[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS * niBUFFER_1_PACKET_SIZE ] __attribute__ ( ( aligned( 32 ) ) ); -uint8_t *ucRAMBuffer = ucNetworkPackets; -uint32_t ul; - - for( ul = 0; ul < ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS; ul++ ) - { - pxNetworkBuffers[ ul ].pucEthernetBuffer = ucRAMBuffer + ipBUFFER_PADDING; - *( ( unsigned * ) ucRAMBuffer ) = ( unsigned ) ( &( pxNetworkBuffers[ ul ] ) ); - ucRAMBuffer += niBUFFER_1_PACKET_SIZE; - } -} -/*-----------------------------------------------------------*/ - -BaseType_t xGetPhyLinkStatus( void ) -{ -BaseType_t xReturn; - - if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) == 0 ) - { - xReturn = pdFALSE; - } - else - { - xReturn = pdTRUE; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -static void prvEMACHandlerTask( void *pvParameters ) -{ -TimeOut_t xPhyTime; -TickType_t xPhyRemTime; -UBaseType_t uxLastMinBufferCount = 0; -UBaseType_t uxCurrentCount; -BaseType_t xResult = 0; -uint32_t xStatus; -const TickType_t ulMaxBlockTime = pdMS_TO_TICKS( 100UL ); - - /* Remove compiler warnings about unused parameters. */ - ( void ) pvParameters; - - /* A possibility to set some additional task properties like calling - portTASK_USES_FLOATING_POINT() */ - iptraceEMAC_TASK_STARTING(); - - vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); - - for( ;; ) - { - uxCurrentCount = uxGetMinimumFreeNetworkBuffers(); - if( uxLastMinBufferCount != uxCurrentCount ) - { - /* The logging produced below may be helpful - while tuning +TCP: see how many buffers are in use. */ - uxLastMinBufferCount = uxCurrentCount; - FreeRTOS_printf( ( "Network buffers: %lu lowest %lu\n", - uxGetNumberOfFreeNetworkBuffers(), uxCurrentCount ) ); - } - - #if( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - { - static UBaseType_t uxLastMinQueueSpace = 0; - - uxCurrentCount = uxGetMinimumIPQueueSpace(); - if( uxLastMinQueueSpace != uxCurrentCount ) - { - /* The logging produced below may be helpful - while tuning +TCP: see how many buffers are in use. */ - uxLastMinQueueSpace = uxCurrentCount; - FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); - } - } - #endif /* ipconfigCHECK_IP_QUEUE_SPACE */ - - if( ( xEMACpsif.isr_events & EMAC_IF_ALL_EVENT ) == 0 ) - { - /* No events to process now, wait for the next. */ - ulTaskNotifyTake( pdFALSE, ulMaxBlockTime ); - } - - if( ( xEMACpsif.isr_events & EMAC_IF_RX_EVENT ) != 0 ) - { - xEMACpsif.isr_events &= ~EMAC_IF_RX_EVENT; - xResult = emacps_check_rx( &xEMACpsif ); - } - - if( ( xEMACpsif.isr_events & EMAC_IF_TX_EVENT ) != 0 ) - { - xEMACpsif.isr_events &= ~EMAC_IF_TX_EVENT; - emacps_check_tx( &xEMACpsif ); - } - - if( ( xEMACpsif.isr_events & EMAC_IF_ERR_EVENT ) != 0 ) - { - xEMACpsif.isr_events &= ~EMAC_IF_ERR_EVENT; - emacps_check_errors( &xEMACpsif ); - } - - if( xResult > 0 ) - { - /* A packet was received. No need to check for the PHY status now, - but set a timer to check it later on. */ - vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); - xResult = 0; - } - else if( xTaskCheckForTimeOut( &xPhyTime, &xPhyRemTime ) != pdFALSE ) - { - xStatus = ulReadMDIO( PHY_REG_01_BMSR ); - - if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != ( xStatus & BMSR_LINK_STATUS ) ) - { - ulPHYLinkStatus = xStatus; - FreeRTOS_printf( ( "prvEMACHandlerTask: PHY LS now %d\n", ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) ); - } - - vTaskSetTimeOutState( &xPhyTime ); - if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) - { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); - } - else - { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); - } - } - } -} -/*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/README.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/README.txt deleted file mode 100755 index f9e54bb..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/README.txt +++ /dev/null @@ -1,25 +0,0 @@ - - -NetworkInterface for Xilinx' Zynq - -Please include the following source files: - - $(PLUS_TCP_PATH)/portable/NetworkInterface/Zynq/NetworkInterface.c - $(PLUS_TCP_PATH)/portable/NetworkInterface/Zynq/x_emacpsif_dma.c - $(PLUS_TCP_PATH)/portable/NetworkInterface/Zynq/x_emacpsif_physpeed.c - $(PLUS_TCP_PATH)/portable/NetworkInterface/Zynq/x_emacpsif_hw.c - -And include the following source files from the Xilinx library: - - $(CPU_PATH)/$(PROCESSOR)/libsrc/emacps_v2_0/src/xemacps.c - $(CPU_PATH)/$(PROCESSOR)/libsrc/emacps_v2_0/src/xemacps_control.c - $(CPU_PATH)/$(PROCESSOR)/libsrc/emacps_v2_0/src/xemacps_g.c - $(CPU_PATH)/$(PROCESSOR)/libsrc/emacps_v2_0/src/xemacps_intr.c - - E.g. ps7_cortexa9_0/libsrc/emacps_v2_0/src/xemacps_intr.c - -The following source files are NOT used for the FreeRTOS+TCP interface: - - $(CPU_PATH)/$(PROCESSOR)/libsrc/emacps_v2_0/src/xemacps_bdring.c - $(CPU_PATH)/$(PROCESSOR)/libsrc/emacps_v2_0/src/xemacps_hw.c - $(CPU_PATH)/$(PROCESSOR)/libsrc/emacps_v2_0/src/xemacps_sinit.c diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/uncached_memory.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/uncached_memory.c deleted file mode 100755 index 1b55a9d..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/uncached_memory.c +++ /dev/null @@ -1,119 +0,0 @@ -#warning Temoporary file and a dependent on the Zynq network interface. - -/* - * uncached_memory.c - * - * This module will declare 1 MB of memory and switch off the caching for it. - * - * pucGetUncachedMemory( ulSize ) returns a trunc of this memory with a length - * rounded up to a multiple of 4 KB - * - * ucIsCachedMemory( pucBuffer ) returns non-zero if a given pointer is NOT - * within the range of the 1 MB non-cached memory. - * - */ - -/* - * After "_end", 1 MB of uncached memory will be allocated for DMA transfers. - * Both the DMA descriptors as well as all EMAC TX-buffers will be allocated in - * uncached memory. - */ - -#include "Zynq/x_emacpsif.h" -#include "Zynq/x_topology.h" -#include "xstatus.h" - -#include "xparameters.h" -#include "xparameters_ps.h" -#include "xil_exception.h" -#include "xil_mmu.h" - -#include "FreeRTOS.h" - -#include "uncached_memory.h" - -#include "Demo_Logging.h" - -#define UNCACHED_MEMORY_SIZE 0x100000ul - -#define DDR_MEMORY_END (XPAR_PS7_DDR_0_S_AXI_HIGHADDR+1) - -static void vInitialiseUncachedMemory( void ); - -static uint8_t *pucHeadOfMemory; -static uint32_t ulMemorySize; -static uint8_t *pucStartOfMemory = NULL; - -uint8_t ucIsCachedMemory( const uint8_t *pucBuffer ) -{ -uint8_t ucReturn; - - if( ( pucStartOfMemory != NULL ) && - ( pucBuffer >= pucStartOfMemory ) && - ( pucBuffer < ( pucStartOfMemory + UNCACHED_MEMORY_SIZE ) ) ) - { - ucReturn = pdFALSE; - } - else - { - ucReturn = pdTRUE; - } - - return ucReturn; -} - -uint8_t *pucGetUncachedMemory( uint32_t ulSize ) -{ -uint8_t *pucReturn; - - if( pucStartOfMemory == NULL ) - { - vInitialiseUncachedMemory( ); - } - if( ( pucStartOfMemory == NULL ) || ( ulSize > ulMemorySize ) ) - { - pucReturn = NULL; - } - else - { - uint32_t ulSkipSize; - - pucReturn = pucHeadOfMemory; - ulSkipSize = ( ulSize + 0x1000ul ) & ~0xffful; - pucHeadOfMemory += ulSkipSize; - ulMemorySize -= ulSkipSize; - } - - return pucReturn; -} - -extern u8 _end; - -static void vInitialiseUncachedMemory( ) -{ - /* At the end of program's space... */ - pucStartOfMemory = (uint8_t *) &_end; - /* - * Align the start address to 1 MB boundary. - */ - pucStartOfMemory = (uint8_t *)( ( ( uint32_t )pucStartOfMemory + UNCACHED_MEMORY_SIZE ) & ( ~( UNCACHED_MEMORY_SIZE - 1 ) ) ); - - if( ( ( u32 )pucStartOfMemory ) + UNCACHED_MEMORY_SIZE > DDR_MEMORY_END ) - { - vLoggingPrintf("vInitialiseUncachedMemory: Can not allocate uncached memory\n" ); - } - else - { - /* - * Some objects want to be stored in uncached memory. Hence the 1 MB - * address range that starts after "_end" is made uncached - * by setting appropriate attributes in the translation table. - */ - Xil_SetTlbAttributes( ( uint32_t )pucStartOfMemory, 0xc02 ); // addr, attr - - /* For experiments in the SDIO driver, make the remaining uncached memory public */ - pucHeadOfMemory = pucStartOfMemory; - ulMemorySize = UNCACHED_MEMORY_SIZE; - memset( pucStartOfMemory, '\0', UNCACHED_MEMORY_SIZE ); - } -} diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/uncached_memory.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/uncached_memory.h deleted file mode 100755 index 2b8b3b1..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/uncached_memory.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * uncached_memory.h - * - * This module will declare 1 MB of memory and switch off the caching for it. - * - * pucGetUncachedMemory( ulSize ) returns a trunc of this memory with a length - * rounded up to a multiple of 4 KB - * - * ucIsCachedMemory( pucBuffer ) returns non-zero if a given pointer is NOT - * within the range of the 1 MB non-cached memory. - * - */ - -#ifndef UNCACHEMEMORY_H - -#define UNCACHEMEMORY_H - -uint8_t *pucGetUncachedMemory( uint32_t ulSize ); - -uint8_t ucIsCachedMemory( const uint8_t *pucBuffer ); - -#endif /* UNCACHEMEMORY_H */ - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif.h deleted file mode 100755 index 2f1b0df..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2010-2013 Xilinx, Inc. All rights reserved. - * - * Xilinx, Inc. - * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A - * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS - * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR - * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION - * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE - * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. - * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO - * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO - * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE - * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. - * - */ - -#ifndef __NETIF_XEMACPSIF_H__ -#define __NETIF_XEMACPSIF_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#include "xstatus.h" -#include "sleep.h" -#include "xparameters.h" -#include "xparameters_ps.h" /* defines XPAR values */ -#include "xil_types.h" -#include "xil_assert.h" -#include "xil_io.h" -#include "xil_exception.h" -#include "xpseudo_asm.h" -#include "xil_cache.h" -#include "xil_printf.h" -#include "xuartps.h" -#include "xscugic.h" -#include "xemacps.h" /* defines XEmacPs API */ - -//#include "netif/xpqueue.h" -//#include "xlwipconfig.h" - -void xemacpsif_setmac(uint32_t index, uint8_t *addr); -uint8_t* xemacpsif_getmac(uint32_t index); -//int xemacpsif_init(struct netif *netif); -//int xemacpsif_input(struct netif *netif); -#ifdef NOTNOW_BHILL -unsigned get_IEEE_phy_speed(XLlTemac *xlltemacp); -#endif - -/* xaxiemacif_hw.c */ -void xemacps_error_handler(XEmacPs * Temac); - -struct xBD_TYPE { - uint32_t address; - uint32_t flags; -}; - -/* - * Missing declaration in 'src/xemacps_hw.h' : - * When set, the GEM DMA will automatically - * discard receive packets from the receiver packet - * buffer memory when no AHB resource is - * available. - * When low, then received packets will remain to be - * stored in the SRAM based packet buffer until - * AHB buffer resource next becomes available. - */ -#define XEMACPS_DMACR_DISC_WHEN_NO_AHB_MASK 0x01000000 - -#define EMAC_IF_RX_EVENT 1 -#define EMAC_IF_TX_EVENT 2 -#define EMAC_IF_ERR_EVENT 4 -#define EMAC_IF_ALL_EVENT 7 - -/* structure within each netif, encapsulating all information required for - * using a particular temac instance - */ -typedef struct { - XEmacPs emacps; - - /* pointers to memory holding buffer descriptors (used only with SDMA) */ - struct xBD_TYPE *rxSegments; - struct xBD_TYPE *txSegments; - - unsigned char *tx_space; - unsigned uTxUnitSize; - - char *remain_mem; - unsigned remain_siz; - - volatile int rxHead, rxTail; - volatile int txHead, txTail; - - volatile int txBusy; - - volatile uint32_t isr_events; - - unsigned int last_rx_frms_cntr; - -} xemacpsif_s; - -//extern xemacpsif_s xemacpsif; - -int is_tx_space_available(xemacpsif_s *emac); - -/* xaxiemacif_dma.c */ - -struct xNETWORK_BUFFER; - -int emacps_check_rx( xemacpsif_s *xemacpsif ); -void emacps_check_tx( xemacpsif_s *xemacpsif ); -int emacps_check_errors( xemacpsif_s *xemacps ); -void emacps_set_rx_buffers( xemacpsif_s *xemacpsif, u32 ulCount ); - -extern XStatus emacps_send_message(xemacpsif_s *xemacpsif, struct xNETWORK_BUFFER *pxBuffer, int iReleaseAfterSend ); -extern unsigned Phy_Setup( XEmacPs *xemacpsp ); -extern void setup_isr( xemacpsif_s *xemacpsif ); -extern XStatus init_dma( xemacpsif_s *xemacpsif ); -extern void start_emacps( xemacpsif_s *xemacpsif ); - -void EmacEnableIntr(void); -void EmacDisableIntr(void); - -XStatus init_axi_dma(xemacpsif_s *xemacpsif); -void process_sent_bds( xemacpsif_s *xemacpsif ); - -void emacps_send_handler(void *arg); -void emacps_recv_handler(void *arg); -void emacps_error_handler(void *arg,u8 Direction, u32 ErrorWord); -void HandleTxErrors(xemacpsif_s *xemacpsif); -XEmacPs_Config *xemacps_lookup_config(unsigned mac_base); - -void clean_dma_txdescs(xemacpsif_s *xemacpsif); -void resetrx_on_no_rxdata(xemacpsif_s *xemacpsif); - -#ifdef __cplusplus -} -#endif - -#endif /* __NETIF_XAXIEMACIF_H__ */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_dma.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_dma.c deleted file mode 100755 index c813989..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_dma.c +++ /dev/null @@ -1,625 +0,0 @@ -/* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - http://aws.amazon.com/freertos - http://www.FreeRTOS.org -*/ - -#include "Zynq/x_emacpsif.h" -#include "Zynq/x_topology.h" -#include "xstatus.h" - -#include "xparameters.h" -#include "xparameters_ps.h" -#include "xil_exception.h" -#include "xil_mmu.h" - -#include "FreeRTOS.h" -#include "task.h" -#include "timers.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "NetworkBufferManagement.h" - -#include "uncached_memory.h" - -/* Two defines used to set or clear the EMAC interrupt */ -#define INTC_BASE_ADDR XPAR_SCUGIC_CPU_BASEADDR -#define INTC_DIST_BASE_ADDR XPAR_SCUGIC_DIST_BASEADDR - - - -#if( ipconfigPACKET_FILLER_SIZE != 2 ) - #error Please define ipconfigPACKET_FILLER_SIZE as the value '2' -#endif -#define TX_OFFSET ipconfigPACKET_FILLER_SIZE - -/* Defined in NetworkInterface.c */ -extern TaskHandle_t xEMACTaskHandle; - -/* - pxDMA_tx_buffers: these are character arrays, each one is big enough to hold 1 MTU. - The actual TX buffers are located in uncached RAM. -*/ -static unsigned char *pxDMA_tx_buffers[ ipconfigNIC_N_TX_DESC ] = { NULL }; - -/* - pxDMA_rx_buffers: these are pointers to 'NetworkBufferDescriptor_t'. - Once a message has been received by the EMAC, the descriptor can be passed - immediately to the IP-task. -*/ -static NetworkBufferDescriptor_t *pxDMA_rx_buffers[ ipconfigNIC_N_RX_DESC ] = { NULL }; - -/* - The FreeRTOS+TCP port is using a fixed 'topology', which is declared in - ./portable/NetworkInterface/Zynq/NetworkInterface.c -*/ -extern struct xtopology_t xXTopology; - -static SemaphoreHandle_t xTXDescriptorSemaphore = NULL; - -/* - The FreeRTOS+TCP port does not make use of "src/xemacps_bdring.c". - In stead 'struct xemacpsif_s' has a "head" and a "tail" index. - "head" is the next index to be written, used. - "tail" is the next index to be read, freed. -*/ - -int is_tx_space_available( xemacpsif_s *xemacpsif ) -{ -size_t uxCount; - - if( xTXDescriptorSemaphore != NULL ) - { - uxCount = ( ( UBaseType_t ) ipconfigNIC_N_TX_DESC ) - uxSemaphoreGetCount( xTXDescriptorSemaphore ); - } - else - { - uxCount = ( UBaseType_t ) 0u; - } - - return uxCount; -} - -void emacps_check_tx( xemacpsif_s *xemacpsif ) -{ -int tail = xemacpsif->txTail; -int head = xemacpsif->txHead; -size_t uxCount = ( ( UBaseType_t ) ipconfigNIC_N_TX_DESC ) - uxSemaphoreGetCount( xTXDescriptorSemaphore ); - - /* uxCount is the number of TX descriptors that are in use by the DMA. */ - /* When done, "TXBUF_USED" will be set. */ - - while( ( uxCount > 0 ) && ( ( xemacpsif->txSegments[ tail ].flags & XEMACPS_TXBUF_USED_MASK ) != 0 ) ) - { - if( ( tail == head ) && ( uxCount != ipconfigNIC_N_TX_DESC ) ) - { - break; - } -#if( ipconfigZERO_COPY_TX_DRIVER != 0 ) -#warning ipconfigZERO_COPY_TX_DRIVER is defined - { - void *pvBuffer = pxDMA_tx_buffers[ tail ]; - NetworkBufferDescriptor_t *pxBuffer; - - if( pvBuffer != NULL ) - { - pxDMA_tx_buffers[ tail ] = NULL; - pxBuffer = pxPacketBuffer_to_NetworkBuffer( pvBuffer ); - if( pxBuffer != NULL ) - { - vReleaseNetworkBufferAndDescriptor( pxBuffer ); - } - else - { - FreeRTOS_printf( ( "emacps_check_tx: Can not find network buffer\n" ) ); - } - } - } -#endif - /* Clear all but the "used" and "wrap" bits. */ - if( tail < ipconfigNIC_N_TX_DESC - 1 ) - { - xemacpsif->txSegments[ tail ].flags = XEMACPS_TXBUF_USED_MASK; - } - else - { - xemacpsif->txSegments[ tail ].flags = XEMACPS_TXBUF_USED_MASK | XEMACPS_TXBUF_WRAP_MASK; - } - uxCount--; - /* Tell the counting semaphore that one more TX descriptor is available. */ - xSemaphoreGive( xTXDescriptorSemaphore ); - if( ++tail == ipconfigNIC_N_TX_DESC ) - { - tail = 0; - } - xemacpsif->txTail = tail; - } - - return; -} - -void emacps_send_handler(void *arg) -{ -xemacpsif_s *xemacpsif; -BaseType_t xHigherPriorityTaskWoken = pdFALSE; - - xemacpsif = (xemacpsif_s *)(arg); - - /* In this port for FreeRTOS+TCP, the EMAC interrupts will only set a bit in - "isr_events". The task in NetworkInterface will wake-up and do the necessary work. - */ - xemacpsif->isr_events |= EMAC_IF_TX_EVENT; - xemacpsif->txBusy = pdFALSE; - - if( xEMACTaskHandle != NULL ) - { - vTaskNotifyGiveFromISR( xEMACTaskHandle, &xHigherPriorityTaskWoken ); - } - - portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); -} - -static BaseType_t xValidLength( BaseType_t xLength ) -{ -BaseType_t xReturn; - - if( ( xLength >= ( BaseType_t ) sizeof( struct xARP_PACKET ) ) && ( ( ( uint32_t ) xLength ) <= ipTOTAL_ETHERNET_FRAME_SIZE ) ) - { - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - - return xReturn; -} - -XStatus emacps_send_message(xemacpsif_s *xemacpsif, NetworkBufferDescriptor_t *pxBuffer, int iReleaseAfterSend ) -{ -int head = xemacpsif->txHead; -int tail = xemacpsif->txTail; -int iHasSent = 0; -uint32_t ulBaseAddress = xemacpsif->emacps.Config.BaseAddress; -TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 5000u ); - - #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* This driver wants to own all network buffers which are to be transmitted. */ - configASSERT( iReleaseAfterSend != pdFALSE ); - } - #endif - - /* Open a do {} while ( 0 ) loop to be able to call break. */ - do - { - uint32_t ulFlags = 0; - - if( xValidLength( pxBuffer->xDataLength ) != pdTRUE ) - { - break; - } - - if( xTXDescriptorSemaphore == NULL ) - { - break; - } - - if( xSemaphoreTake( xTXDescriptorSemaphore, xBlockTimeTicks ) != pdPASS ) - { - FreeRTOS_printf( ( "emacps_send_message: Time-out waiting for TX buffer\n" ) ); - break; - } - -#if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - /* Pass the pointer (and its ownership) directly to DMA. */ - pxDMA_tx_buffers[ head ] = pxBuffer->pucEthernetBuffer; - if( ucIsCachedMemory( pxBuffer->pucEthernetBuffer ) != 0 ) - { - Xil_DCacheFlushRange( ( unsigned )pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength ); - } - /* Buffer has been transferred, do not release it. */ - iReleaseAfterSend = pdFALSE; -#else - if( pxDMA_tx_buffers[ head ] == NULL ) - { - FreeRTOS_printf( ( "emacps_send_message: pxDMA_tx_buffers[ %d ] == NULL\n", head ) ); - break; - } - /* Copy the message to unbuffered space in RAM. */ - memcpy( pxDMA_tx_buffers[ head ], pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength ); -#endif - /* Packets will be sent one-by-one, so for each packet - the TXBUF_LAST bit will be set. */ - ulFlags |= XEMACPS_TXBUF_LAST_MASK; - ulFlags |= ( pxBuffer->xDataLength & XEMACPS_TXBUF_LEN_MASK ); - if( head == ( ipconfigNIC_N_TX_DESC - 1 ) ) - { - ulFlags |= XEMACPS_TXBUF_WRAP_MASK; - } - - /* Copy the address of the buffer and set the flags. */ - xemacpsif->txSegments[ head ].address = ( uint32_t )pxDMA_tx_buffers[ head ]; - xemacpsif->txSegments[ head ].flags = ulFlags; - - iHasSent = pdTRUE; - if( ++head == ipconfigNIC_N_TX_DESC ) - { - head = 0; - } - /* Update the TX-head index. These variable are declared volatile so they will be - accessed as little as possible. */ - xemacpsif->txHead = head; - } while( pdFALSE ); - - if( iReleaseAfterSend != pdFALSE ) - { - vReleaseNetworkBufferAndDescriptor( pxBuffer ); - pxBuffer = NULL; - } - - /* Data Synchronization Barrier */ - dsb(); - - if( iHasSent != pdFALSE ) - { - /* Make STARTTX high */ - uint32_t ulValue = XEmacPs_ReadReg( ulBaseAddress, XEMACPS_NWCTRL_OFFSET); - /* Start transmit */ - xemacpsif->txBusy = pdTRUE; - XEmacPs_WriteReg( ulBaseAddress, XEMACPS_NWCTRL_OFFSET, ( ulValue | XEMACPS_NWCTRL_STARTTX_MASK ) ); - } - dsb(); - - return 0; -} - -void emacps_recv_handler(void *arg) -{ - xemacpsif_s *xemacpsif; - BaseType_t xHigherPriorityTaskWoken = pdFALSE; - - xemacpsif = (xemacpsif_s *)(arg); - xemacpsif->isr_events |= EMAC_IF_RX_EVENT; - - if( xEMACTaskHandle != NULL ) - { - vTaskNotifyGiveFromISR( xEMACTaskHandle, &xHigherPriorityTaskWoken ); - } - - portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); -} - -static NetworkBufferDescriptor_t *ethMsg = NULL; -static NetworkBufferDescriptor_t *ethLast = NULL; - -static void passEthMessages( void ) -{ -IPStackEvent_t xRxEvent; - - xRxEvent.eEventType = eNetworkRxEvent; - xRxEvent.pvData = ( void * ) ethMsg; - - if( xSendEventStructToIPTask( &xRxEvent, ( TickType_t ) 1000 ) != pdPASS ) - { - /* The buffer could not be sent to the stack so must be released again. - This is a deferred handler taskr, not a real interrupt, so it is ok to - use the task level function here. */ - do - { - NetworkBufferDescriptor_t *xNext = ethMsg->pxNextBuffer; - vReleaseNetworkBufferAndDescriptor( ethMsg ); - ethMsg = xNext; - } while( ethMsg != NULL ); - - iptraceETHERNET_RX_EVENT_LOST(); - FreeRTOS_printf( ( "passEthMessages: Can not queue return packet!\n" ) ); - } - - ethMsg = ethLast = NULL; -} - -int emacps_check_rx( xemacpsif_s *xemacpsif ) -{ -NetworkBufferDescriptor_t *pxBuffer, *pxNewBuffer; -int rx_bytes; -volatile int msgCount = 0; -int head = xemacpsif->rxHead; - - /* There seems to be an issue (SI# 692601), see comments below. */ - resetrx_on_no_rxdata(xemacpsif); - - /* This FreeRTOS+TCP driver shall be compiled with the option - "ipconfigUSE_LINKED_RX_MESSAGES" enabled. It allows the driver to send a - chain of RX messages within one message to the IP-task. */ - for( ;; ) - { - if( ( ( xemacpsif->rxSegments[ head ].address & XEMACPS_RXBUF_NEW_MASK ) == 0 ) || - ( pxDMA_rx_buffers[ head ] == NULL ) ) - { - break; - } - - pxNewBuffer = pxGetNetworkBufferWithDescriptor( ipTOTAL_ETHERNET_FRAME_SIZE, ( TickType_t ) 0 ); - if( pxNewBuffer == NULL ) - { - /* A packet has been received, but there is no replacement for this Network Buffer. - The packet will be dropped, and it Network Buffer will stay in place. */ - FreeRTOS_printf( ("emacps_check_rx: unable to allocate a Netwrok Buffer\n" ) ); - pxNewBuffer = ( NetworkBufferDescriptor_t * )pxDMA_rx_buffers[ head ]; - } - else - { - pxBuffer = ( NetworkBufferDescriptor_t * )pxDMA_rx_buffers[ head ]; - - /* Just avoiding to use or refer to the same buffer again */ - pxDMA_rx_buffers[ head ] = pxNewBuffer; - - /* - * Adjust the buffer size to the actual number of bytes received. - */ - rx_bytes = xemacpsif->rxSegments[ head ].flags & XEMACPS_RXBUF_LEN_MASK; - - pxBuffer->xDataLength = rx_bytes; - - if( ucIsCachedMemory( pxBuffer->pucEthernetBuffer ) != 0 ) - { - Xil_DCacheInvalidateRange( ( ( uint32_t )pxBuffer->pucEthernetBuffer ) - ipconfigPACKET_FILLER_SIZE, (unsigned)rx_bytes ); - } - - /* store it in the receive queue, where it'll be processed by a - different handler. */ - iptraceNETWORK_INTERFACE_RECEIVE(); - pxBuffer->pxNextBuffer = NULL; - - if( ethMsg == NULL ) - { - // Becomes the first message - ethMsg = pxBuffer; - } - else if( ethLast != NULL ) - { - // Add to the tail - ethLast->pxNextBuffer = pxBuffer; - } - - ethLast = pxBuffer; - msgCount++; - } - { - if( ucIsCachedMemory( pxNewBuffer->pucEthernetBuffer ) != 0 ) - { - Xil_DCacheInvalidateRange( ( ( uint32_t )pxNewBuffer->pucEthernetBuffer ) - ipconfigPACKET_FILLER_SIZE, (unsigned)ipTOTAL_ETHERNET_FRAME_SIZE ); - } - { - uint32_t addr = ( ( uint32_t )pxNewBuffer->pucEthernetBuffer ) & XEMACPS_RXBUF_ADD_MASK; - if( head == ( ipconfigNIC_N_RX_DESC - 1 ) ) - { - addr |= XEMACPS_RXBUF_WRAP_MASK; - } - /* Clearing 'XEMACPS_RXBUF_NEW_MASK' 0x00000001 *< Used bit.. */ - xemacpsif->rxSegments[ head ].address = addr; - xemacpsif->rxSegments[ head ].flags = 0; - } - } - - if( ++head == ipconfigNIC_N_RX_DESC ) - { - head = 0; - } - xemacpsif->rxHead = head; - } - - if( ethMsg != NULL ) - { - passEthMessages( ); - } - - return msgCount; -} - -void clean_dma_txdescs(xemacpsif_s *xemacpsif) -{ -int index; -unsigned char *ucTxBuffer; - - /* Clear all TX descriptors and assign uncached memory to each descriptor. - "tx_space" points to the first available TX buffer. */ - ucTxBuffer = xemacpsif->tx_space; - - for( index = 0; index < ipconfigNIC_N_TX_DESC; index++ ) - { - xemacpsif->txSegments[ index ].address = ( uint32_t )ucTxBuffer; - xemacpsif->txSegments[ index ].flags = XEMACPS_TXBUF_USED_MASK; -#if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - pxDMA_tx_buffers[ index ] = ( void* )NULL; -#else - pxDMA_tx_buffers[ index ] = ( void* )( ucTxBuffer + TX_OFFSET ); -#endif - ucTxBuffer += xemacpsif->uTxUnitSize; - } - xemacpsif->txSegments[ ipconfigNIC_N_TX_DESC - 1 ].flags = - XEMACPS_TXBUF_USED_MASK | XEMACPS_TXBUF_WRAP_MASK; -} - -XStatus init_dma(xemacpsif_s *xemacpsif) -{ - NetworkBufferDescriptor_t *pxBuffer; - - int iIndex; - UBaseType_t xRxSize; - UBaseType_t xTxSize; - struct xtopology_t *xtopologyp = &xXTopology; - - xRxSize = ipconfigNIC_N_RX_DESC * sizeof( xemacpsif->rxSegments[ 0 ] ); - - xTxSize = ipconfigNIC_N_TX_DESC * sizeof( xemacpsif->txSegments[ 0 ] ); - - /* Also round-up to 4KB */ - xemacpsif->uTxUnitSize = ( ipTOTAL_ETHERNET_FRAME_SIZE + 0x1000ul ) & ~0xffful; - /* - * We allocate 65536 bytes for RX BDs which can accommodate a - * maximum of 8192 BDs which is much more than any application - * will ever need. - */ - xemacpsif->rxSegments = ( struct xBD_TYPE * )( pucGetUncachedMemory ( xRxSize ) ); - xemacpsif->txSegments = ( struct xBD_TYPE * )( pucGetUncachedMemory ( xTxSize ) ); - xemacpsif->tx_space = ( unsigned char * )( pucGetUncachedMemory ( ipconfigNIC_N_TX_DESC * xemacpsif->uTxUnitSize ) ); - - /* These variables will be used in XEmacPs_Start (see src/xemacps.c). */ - xemacpsif->emacps.RxBdRing.BaseBdAddr = ( uint32_t ) xemacpsif->rxSegments; - xemacpsif->emacps.TxBdRing.BaseBdAddr = ( uint32_t ) xemacpsif->txSegments; - - if( xTXDescriptorSemaphore == NULL ) - { - xTXDescriptorSemaphore = xSemaphoreCreateCounting( ( UBaseType_t ) ipconfigNIC_N_TX_DESC, ( UBaseType_t ) ipconfigNIC_N_TX_DESC ); - configASSERT( xTXDescriptorSemaphore ); - } - /* - * Allocate RX descriptors, 1 RxBD at a time. - */ - for( iIndex = 0; iIndex < ipconfigNIC_N_RX_DESC; iIndex++ ) - { - pxBuffer = pxDMA_rx_buffers[ iIndex ]; - if( pxBuffer == NULL ) - { - pxBuffer = pxGetNetworkBufferWithDescriptor( ipTOTAL_ETHERNET_FRAME_SIZE, ( TickType_t ) 0 ); - if( pxBuffer == NULL ) - { - FreeRTOS_printf( ("Unable to allocate a network buffer in recv_handler\n" ) ); - return -1; - } - } - - xemacpsif->rxSegments[ iIndex ].flags = 0; - xemacpsif->rxSegments[ iIndex ].address = ( ( uint32_t )pxBuffer->pucEthernetBuffer ) & XEMACPS_RXBUF_ADD_MASK; - - pxDMA_rx_buffers[ iIndex ] = pxBuffer; - /* Make sure this memory is not in cache for now. */ - if( ucIsCachedMemory( pxBuffer->pucEthernetBuffer ) != 0 ) - { - Xil_DCacheInvalidateRange( ( ( uint32_t )pxBuffer->pucEthernetBuffer ) - ipconfigPACKET_FILLER_SIZE, - (unsigned)ipTOTAL_ETHERNET_FRAME_SIZE ); - } - } - - xemacpsif->rxSegments[ ipconfigNIC_N_RX_DESC - 1 ].address |= XEMACPS_RXBUF_WRAP_MASK; - - memset( xemacpsif->tx_space, '\0', ipconfigNIC_N_TX_DESC * xemacpsif->uTxUnitSize ); - - clean_dma_txdescs( xemacpsif ); - - { - uint32_t value; - value = XEmacPs_ReadReg( xemacpsif->emacps.Config.BaseAddress, XEMACPS_DMACR_OFFSET ); - - // 1xxxx: Attempt to use INCR16 AHB bursts - value = ( value & ~( XEMACPS_DMACR_BLENGTH_MASK ) ) | XEMACPS_DMACR_INCR16_AHB_BURST; -#if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 ) - value |= XEMACPS_DMACR_TCPCKSUM_MASK; -#else -#warning Are you sure the EMAC should not calculate outgoing checksums? - value &= ~XEMACPS_DMACR_TCPCKSUM_MASK; -#endif - XEmacPs_WriteReg( xemacpsif->emacps.Config.BaseAddress, XEMACPS_DMACR_OFFSET, value ); - } - { - uint32_t value; - value = XEmacPs_ReadReg( xemacpsif->emacps.Config.BaseAddress, XEMACPS_NWCFG_OFFSET ); - - /* Network buffers are 32-bit aligned + 2 bytes (because ipconfigPACKET_FILLER_SIZE = 2 ). - Now tell the EMAC that received messages should be stored at "address + 2". */ - value = ( value & ~XEMACPS_NWCFG_RXOFFS_MASK ) | 0x8000; - -#if( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM != 0 ) - value |= XEMACPS_NWCFG_RXCHKSUMEN_MASK; -#else -#warning Are you sure the EMAC should not calculate incoming checksums? - value &= ~XEMACPS_NWCFG_RXCHKSUMEN_MASK; -#endif - XEmacPs_WriteReg( xemacpsif->emacps.Config.BaseAddress, XEMACPS_NWCFG_OFFSET, value ); - } - - /* - * Connect the device driver handler that will be called when an - * interrupt for the device occurs, the handler defined above performs - * the specific interrupt processing for the device. - */ - XScuGic_RegisterHandler(INTC_BASE_ADDR, xtopologyp->scugic_emac_intr, - (Xil_ExceptionHandler)XEmacPs_IntrHandler, - (void *)&xemacpsif->emacps); - /* - * Enable the interrupt for emacps. - */ - EmacEnableIntr( ); - - return 0; -} - -/* - * resetrx_on_no_rxdata(): - * - * It is called at regular intervals through the API xemacpsif_resetrx_on_no_rxdata - * called by the user. - * The EmacPs has a HW bug (SI# 692601) on the Rx path for heavy Rx traffic. - * Under heavy Rx traffic because of the HW bug there are times when the Rx path - * becomes unresponsive. The workaround for it is to check for the Rx path for - * traffic (by reading the stats registers regularly). If the stats register - * does not increment for sometime (proving no Rx traffic), the function resets - * the Rx data path. - * - */ - -void resetrx_on_no_rxdata(xemacpsif_s *xemacpsif) -{ - unsigned long regctrl; - unsigned long tempcntr; - - tempcntr = XEmacPs_ReadReg( xemacpsif->emacps.Config.BaseAddress, XEMACPS_RXCNT_OFFSET ); - if ( ( tempcntr == 0 ) && ( xemacpsif->last_rx_frms_cntr == 0 ) ) - { - regctrl = XEmacPs_ReadReg(xemacpsif->emacps.Config.BaseAddress, - XEMACPS_NWCTRL_OFFSET); - regctrl &= (~XEMACPS_NWCTRL_RXEN_MASK); - XEmacPs_WriteReg(xemacpsif->emacps.Config.BaseAddress, - XEMACPS_NWCTRL_OFFSET, regctrl); - regctrl = XEmacPs_ReadReg(xemacpsif->emacps.Config.BaseAddress, XEMACPS_NWCTRL_OFFSET); - regctrl |= (XEMACPS_NWCTRL_RXEN_MASK); - XEmacPs_WriteReg(xemacpsif->emacps.Config.BaseAddress, XEMACPS_NWCTRL_OFFSET, regctrl); - } - xemacpsif->last_rx_frms_cntr = tempcntr; -} - -void EmacDisableIntr(void) -{ - XScuGic_DisableIntr(INTC_DIST_BASE_ADDR, xXTopology.scugic_emac_intr); -} - -void EmacEnableIntr(void) -{ - XScuGic_EnableIntr(INTC_DIST_BASE_ADDR, xXTopology.scugic_emac_intr); -} - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_hw.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_hw.c deleted file mode 100755 index be00f4f..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_hw.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (c) 2010-2013 Xilinx, Inc. All rights reserved. - * - * Xilinx, Inc. - * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A - * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS - * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR - * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION - * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE - * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. - * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO - * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO - * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE - * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. - * - */ - - -/* Standard includes. */ -#include -#include -#include - -#include "Zynq/x_emacpsif.h" - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" - -///* FreeRTOS+TCP includes. */ -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "NetworkBufferManagement.h" - -extern TaskHandle_t xEMACTaskHandle; - -/*** IMPORTANT: Define PEEP in xemacpsif.h and sys_arch_raw.c - *** to run it on a PEEP board - ***/ - -unsigned int link_speed = 100; - -void setup_isr( xemacpsif_s *xemacpsif ) -{ - /* - * Setup callbacks - */ - XEmacPs_SetHandler(&xemacpsif->emacps, XEMACPS_HANDLER_DMASEND, - (void *) emacps_send_handler, - (void *) xemacpsif); - - XEmacPs_SetHandler(&xemacpsif->emacps, XEMACPS_HANDLER_DMARECV, - (void *) emacps_recv_handler, - (void *) xemacpsif); - - XEmacPs_SetHandler(&xemacpsif->emacps, XEMACPS_HANDLER_ERROR, - (void *) emacps_error_handler, - (void *) xemacpsif); -} - -void start_emacps (xemacpsif_s *xemacps) -{ - /* start the temac */ - XEmacPs_Start(&xemacps->emacps); -} - -extern struct xtopology_t xXTopology; - -volatile int error_msg_count = 0; -volatile const char *last_err_msg = ""; - -struct xERROR_MSG { - void *arg; - u8 Direction; - u32 ErrorWord; -}; - -static struct xERROR_MSG xErrorList[ 8 ]; -static BaseType_t xErrorHead, xErrorTail; - -void emacps_error_handler(void *arg, u8 Direction, u32 ErrorWord) -{ - BaseType_t xHigherPriorityTaskWoken = pdFALSE; - xemacpsif_s *xemacpsif; - BaseType_t xNextHead = xErrorHead; - - xemacpsif = (xemacpsif_s *)(arg); - - if( ( Direction != XEMACPS_SEND ) || (ErrorWord != XEMACPS_TXSR_USEDREAD_MASK ) ) - { - if( ++xNextHead == ( sizeof( xErrorList ) / sizeof( xErrorList[ 0 ] ) ) ) - xNextHead = 0; - if( xNextHead != xErrorTail ) - { - - xErrorList[ xErrorHead ].arg = arg; - xErrorList[ xErrorHead ].Direction = Direction; - xErrorList[ xErrorHead ].ErrorWord = ErrorWord; - - xErrorHead = xNextHead; - - xemacpsif = (xemacpsif_s *)(arg); - xemacpsif->isr_events |= EMAC_IF_ERR_EVENT; - } - - if( xEMACTaskHandle != NULL ) - { - vTaskNotifyGiveFromISR( xEMACTaskHandle, &xHigherPriorityTaskWoken ); - } - - } - - portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); -} - -static void emacps_handle_error(void *arg, u8 Direction, u32 ErrorWord); - -int emacps_check_errors( xemacpsif_s *xemacps ) -{ -int xResult; - - ( void ) xemacps; - - if( xErrorHead == xErrorTail ) - { - xResult = 0; - } - else - { - xResult = 1; - emacps_handle_error( - xErrorList[ xErrorTail ].arg, - xErrorList[ xErrorTail ].Direction, - xErrorList[ xErrorTail ].ErrorWord ); - } - - return xResult; -} - -BaseType_t xNetworkInterfaceInitialise( void ); - -static void emacps_handle_error(void *arg, u8 Direction, u32 ErrorWord) -{ - xemacpsif_s *xemacpsif; - struct xtopology_t *xtopologyp; - XEmacPs *xemacps; - - xemacpsif = (xemacpsif_s *)(arg); - - xtopologyp = &xXTopology; - - xemacps = &xemacpsif->emacps; - - /* Do not appear to be used. */ - ( void ) xemacps; - ( void ) xtopologyp; - - last_err_msg = NULL; - - if( ErrorWord != 0 ) - { - switch (Direction) { - case XEMACPS_RECV: - if( ( ErrorWord & XEMACPS_RXSR_HRESPNOK_MASK ) != 0 ) - { - last_err_msg = "Receive DMA error"; - xNetworkInterfaceInitialise( ); - } - if( ( ErrorWord & XEMACPS_RXSR_RXOVR_MASK ) != 0 ) - { - last_err_msg = "Receive over run"; - emacps_recv_handler(arg); - } - if( ( ErrorWord & XEMACPS_RXSR_BUFFNA_MASK ) != 0 ) - { - last_err_msg = "Receive buffer not available"; - emacps_recv_handler(arg); - } - break; - case XEMACPS_SEND: - if( ( ErrorWord & XEMACPS_TXSR_HRESPNOK_MASK ) != 0 ) - { - last_err_msg = "Transmit DMA error"; - xNetworkInterfaceInitialise( ); - } - if( ( ErrorWord & XEMACPS_TXSR_URUN_MASK ) != 0 ) - { - last_err_msg = "Transmit under run"; - HandleTxErrors( xemacpsif ); - } - if( ( ErrorWord & XEMACPS_TXSR_BUFEXH_MASK ) != 0 ) - { - last_err_msg = "Transmit buffer exhausted"; - HandleTxErrors( xemacpsif ); - } - if( ( ErrorWord & XEMACPS_TXSR_RXOVR_MASK ) != 0 ) - { - last_err_msg = "Transmit retry excessed limits"; - HandleTxErrors( xemacpsif ); - } - if( ( ErrorWord & XEMACPS_TXSR_FRAMERX_MASK ) != 0 ) - { - last_err_msg = "Transmit collision"; - emacps_check_tx( xemacpsif ); - } - break; - } - } - // Break on this statement and inspect error_msg if you like - if( last_err_msg != NULL ) - { - error_msg_count++; - FreeRTOS_printf( ( "emacps_handle_error: %s\n", last_err_msg ) ); - } -} - -extern XEmacPs_Config mac_config; - -void HandleTxErrors(xemacpsif_s *xemacpsif) -{ - u32 netctrlreg; - - //taskENTER_CRITICAL() - { - netctrlreg = XEmacPs_ReadReg(xemacpsif->emacps.Config.BaseAddress, - XEMACPS_NWCTRL_OFFSET); - netctrlreg = netctrlreg & (~XEMACPS_NWCTRL_TXEN_MASK); - XEmacPs_WriteReg(xemacpsif->emacps.Config.BaseAddress, - XEMACPS_NWCTRL_OFFSET, netctrlreg); - - clean_dma_txdescs( xemacpsif ); - netctrlreg = XEmacPs_ReadReg(xemacpsif->emacps.Config.BaseAddress, - XEMACPS_NWCTRL_OFFSET); - netctrlreg = netctrlreg | (XEMACPS_NWCTRL_TXEN_MASK); - XEmacPs_WriteReg(xemacpsif->emacps.Config.BaseAddress, - XEMACPS_NWCTRL_OFFSET, netctrlreg); - } - //taskEXIT_CRITICAL( ); -} diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_hw.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_hw.h deleted file mode 100755 index 7b0e4fd..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_hw.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2010-2013 Xilinx, Inc. All rights reserved. - * - * Xilinx, Inc. - * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A - * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS - * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR - * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION - * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE - * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. - * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO - * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO - * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE - * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. - * - */ - -#ifndef __XEMACPSIF_HW_H_ -#define __XEMACPSIF_HW_H_ - -#include "Zynq/x_emacpsif.h" -//#include "lwip/netif.h" - -#ifdef __cplusplus -extern "C" { -#endif - -XEmacPs_Config * lookup_config(unsigned mac_base); - -//void init_emacps(xemacpsif_s *xemacpsif, struct netif *netif); - -int emacps_check_errors( xemacpsif_s *xemacps ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_physpeed.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_physpeed.c deleted file mode 100755 index 742ff8b..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_physpeed.c +++ /dev/null @@ -1,585 +0,0 @@ -/* - * Copyright (c) 2007-2008, Advanced Micro Devices, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Advanced Micro Devices, Inc. nor the names - * of its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Some portions copyright (c) 2010-2013 Xilinx, Inc. All rights reserved. - * - * Xilinx, Inc. - * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A - * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS - * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR - * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION - * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE - * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. - * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO - * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO - * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE - * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. - * - */ - -/* Standard includes. */ -#include -#include -#include - -#include "Zynq/x_emacpsif.h" -//#include "lwipopts.h" -#include "xparameters_ps.h" -#include "xparameters.h" - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -///* FreeRTOS+TCP includes. */ -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "NetworkBufferManagement.h" - -int phy_detected = 0; - -/*** IMPORTANT: Define PEEP in xemacpsif.h and sys_arch_raw.c - *** to run it on a PEEP board - ***/ - -/* Advertisement control register. */ -#define ADVERTISE_10HALF 0x0020 /* Try for 10mbps half-duplex */ -#define ADVERTISE_10FULL 0x0040 /* Try for 10mbps full-duplex */ -#define ADVERTISE_100HALF 0x0080 /* Try for 100mbps half-duplex */ -#define ADVERTISE_100FULL 0x0100 /* Try for 100mbps full-duplex */ - -#define ADVERTISE_100_AND_10 (ADVERTISE_10FULL | ADVERTISE_100FULL | \ - ADVERTISE_10HALF | ADVERTISE_100HALF) -#define ADVERTISE_100 (ADVERTISE_100FULL | ADVERTISE_100HALF) -#define ADVERTISE_10 (ADVERTISE_10FULL | ADVERTISE_10HALF) - -#define ADVERTISE_1000 0x0300 - - -//#define PHY_REG_00_BMCR 0x00 // Basic mode control register -//#define PHY_REG_01_BMSR 0x01 // Basic mode status register -//#define PHY_REG_02_PHYSID1 0x02 // PHYS ID 1 -//#define PHY_REG_03_PHYSID2 0x03 // PHYS ID 2 -//#define PHY_REG_04_ADVERTISE 0x04 // Advertisement control reg - -#define IEEE_CONTROL_REG_OFFSET 0 -#define IEEE_STATUS_REG_OFFSET 1 -#define IEEE_AUTONEGO_ADVERTISE_REG 4 -#define IEEE_PARTNER_ABILITIES_1_REG_OFFSET 5 -#define IEEE_1000_ADVERTISE_REG_OFFSET 9 -#define IEEE_PARTNER_ABILITIES_3_REG_OFFSET 10 -#define IEEE_COPPER_SPECIFIC_CONTROL_REG 16 -#define IEEE_SPECIFIC_STATUS_REG 17 -#define IEEE_COPPER_SPECIFIC_STATUS_REG_2 19 -#define IEEE_CONTROL_REG_MAC 21 -#define IEEE_PAGE_ADDRESS_REGISTER 22 - - -#define IEEE_CTRL_1GBPS_LINKSPEED_MASK 0x2040 -#define IEEE_CTRL_LINKSPEED_MASK 0x0040 -#define IEEE_CTRL_LINKSPEED_1000M 0x0040 -#define IEEE_CTRL_LINKSPEED_100M 0x2000 -#define IEEE_CTRL_LINKSPEED_10M 0x0000 -#define IEEE_CTRL_RESET_MASK 0x8000 -#define IEEE_CTRL_AUTONEGOTIATE_ENABLE 0x1000 -#if XPAR_GIGE_PCS_PMA_CORE_PRESENT == 1 -#define IEEE_CTRL_RESET 0x9140 -#define IEEE_CTRL_ISOLATE_DISABLE 0xFBFF -#endif -#define IEEE_STAT_AUTONEGOTIATE_CAPABLE 0x0008 -#define IEEE_STAT_AUTONEGOTIATE_COMPLETE 0x0020 -#define IEEE_STAT_AUTONEGOTIATE_RESTART 0x0200 -#define IEEE_STAT_1GBPS_EXTENSIONS 0x0100 -#define IEEE_AN1_ABILITY_MASK 0x1FE0 -#define IEEE_AN3_ABILITY_MASK_1GBPS 0x0C00 -#define IEEE_AN1_ABILITY_MASK_100MBPS 0x0380 -#define IEEE_AN1_ABILITY_MASK_10MBPS 0x0060 -#define IEEE_RGMII_TXRX_CLOCK_DELAYED_MASK 0x0030 - -#define IEEE_ASYMMETRIC_PAUSE_MASK 0x0800 -#define IEEE_PAUSE_MASK 0x0400 -#define IEEE_AUTONEG_ERROR_MASK 0x8000 - -#define PHY_DETECT_REG 1 -#define PHY_DETECT_MASK 0x1808 - -#define XEMACPS_GMII2RGMII_SPEED1000_FD 0x140 -#define XEMACPS_GMII2RGMII_SPEED100_FD 0x2100 -#define XEMACPS_GMII2RGMII_SPEED10_FD 0x100 -#define XEMACPS_GMII2RGMII_REG_NUM 0x10 - -/* Frequency setting */ -#define SLCR_LOCK_ADDR (XPS_SYS_CTRL_BASEADDR + 0x4) -#define SLCR_UNLOCK_ADDR (XPS_SYS_CTRL_BASEADDR + 0x8) -#define SLCR_GEM0_CLK_CTRL_ADDR (XPS_SYS_CTRL_BASEADDR + 0x140) -#define SLCR_GEM1_CLK_CTRL_ADDR (XPS_SYS_CTRL_BASEADDR + 0x144) -#ifdef PEEP -#define SLCR_GEM_10M_CLK_CTRL_VALUE 0x00103031 -#define SLCR_GEM_100M_CLK_CTRL_VALUE 0x00103001 -#define SLCR_GEM_1G_CLK_CTRL_VALUE 0x00103011 -#endif -#define SLCR_LOCK_KEY_VALUE 0x767B -#define SLCR_UNLOCK_KEY_VALUE 0xDF0D -#define SLCR_ADDR_GEM_RST_CTRL (XPS_SYS_CTRL_BASEADDR + 0x214) -#define EMACPS_SLCR_DIV_MASK 0xFC0FC0FF - -#define EMAC0_BASE_ADDRESS 0xE000B000 -#define EMAC1_BASE_ADDRESS 0xE000C000 - -static int detect_phy(XEmacPs *xemacpsp) -{ - u16 phy_reg; - u32 phy_addr; - - for (phy_addr = 31; phy_addr > 0; phy_addr--) { - XEmacPs_PhyRead(xemacpsp, phy_addr, PHY_DETECT_REG, - &phy_reg); - - if ((phy_reg != 0xFFFF) && - ((phy_reg & PHY_DETECT_MASK) == PHY_DETECT_MASK)) { - /* Found a valid PHY address */ - FreeRTOS_printf( ("XEmacPs detect_phy: PHY detected at address %d.\r\n", - phy_addr)); - FreeRTOS_printf( ("XEmacPs detect_phy: PHY detected.\n" ) ); - phy_detected = phy_addr; - return phy_addr; - } - } - - FreeRTOS_printf( ("XEmacPs detect_phy: No PHY detected. Assuming a PHY at address 0\n" ) ); - - /* default to zero */ - return 0; -} - -#ifdef PEEP -unsigned get_IEEE_phy_speed(XEmacPs *xemacpsp) -{ - - u16 control; - u16 status; - u16 partner_capabilities; - u16 partner_capabilities_1000; - u16 phylinkspeed; - u32 phy_addr = detect_phy(xemacpsp); - - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_1000_ADVERTISE_REG_OFFSET, - ADVERTISE_1000); - /* Advertise PHY speed of 100 and 10 Mbps */ - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_AUTONEGO_ADVERTISE_REG, - ADVERTISE_100_AND_10); - - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, - &control); - control |= (IEEE_CTRL_AUTONEGOTIATE_ENABLE | - IEEE_STAT_AUTONEGOTIATE_RESTART); - - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, control); - - /* Read PHY control and status registers is successful. */ - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, &control); - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_STATUS_REG_OFFSET, &status); - - if ((control & IEEE_CTRL_AUTONEGOTIATE_ENABLE) && (status & - IEEE_STAT_AUTONEGOTIATE_CAPABLE)) { - - while ( !(status & IEEE_STAT_AUTONEGOTIATE_COMPLETE) ) { - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_STATUS_REG_OFFSET, - &status); - } - - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_PARTNER_ABILITIES_1_REG_OFFSET, - &partner_capabilities); - - if (status & IEEE_STAT_1GBPS_EXTENSIONS) { - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_PARTNER_ABILITIES_3_REG_OFFSET, - &partner_capabilities_1000); - if (partner_capabilities_1000 & IEEE_AN3_ABILITY_MASK_1GBPS) - return 1000; - } - - if (partner_capabilities & IEEE_AN1_ABILITY_MASK_100MBPS) - return 100; - if (partner_capabilities & IEEE_AN1_ABILITY_MASK_10MBPS) - return 10; - - xil_printf("%s: unknown PHY link speed, setting TEMAC speed to be 10 Mbps\r\n", - __FUNCTION__); - return 10; - - } else { - - /* Update TEMAC speed accordingly */ - if (status & IEEE_STAT_1GBPS_EXTENSIONS) { - /* Get commanded link speed */ - phylinkspeed = control & IEEE_CTRL_1GBPS_LINKSPEED_MASK; - - switch (phylinkspeed) { - case (IEEE_CTRL_LINKSPEED_1000M): - return 1000; - case (IEEE_CTRL_LINKSPEED_100M): - return 100; - case (IEEE_CTRL_LINKSPEED_10M): - return 10; - default: - xil_printf("%s: unknown PHY link speed (%d), setting TEMAC speed to be 10 Mbps\r\n", - __FUNCTION__, phylinkspeed); - return 10; - } - - } else { - - return (control & IEEE_CTRL_LINKSPEED_MASK) ? 100 : 10; - - } - } -} - -#else /* Zynq */ -unsigned get_IEEE_phy_speed(XEmacPs *xemacpsp) -{ - u16 temp; - u16 control; - u16 status; - u16 partner_capabilities; -#if XPAR_GIGE_PCS_PMA_CORE_PRESENT == 1 - u32 phy_addr = XPAR_PCSPMA_SGMII_PHYADDR; -#else - u32 phy_addr = detect_phy(xemacpsp); -#endif - xil_printf("Start PHY autonegotiation \r\n"); - -#if XPAR_GIGE_PCS_PMA_CORE_PRESENT == 1 -#else - XEmacPs_PhyWrite(xemacpsp,phy_addr, IEEE_PAGE_ADDRESS_REGISTER, 2); - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_CONTROL_REG_MAC, &control); - control |= IEEE_RGMII_TXRX_CLOCK_DELAYED_MASK; - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_CONTROL_REG_MAC, control); - - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_PAGE_ADDRESS_REGISTER, 0); - - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_AUTONEGO_ADVERTISE_REG, &control); - control |= IEEE_ASYMMETRIC_PAUSE_MASK; - control |= IEEE_PAUSE_MASK; - control |= ADVERTISE_100; - control |= ADVERTISE_10; - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_AUTONEGO_ADVERTISE_REG, control); - - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_1000_ADVERTISE_REG_OFFSET, - &control); - control |= ADVERTISE_1000; - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_1000_ADVERTISE_REG_OFFSET, - control); - - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_PAGE_ADDRESS_REGISTER, 0); - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_COPPER_SPECIFIC_CONTROL_REG, - &control); - control |= (7 << 12); /* max number of gigabit attempts */ - control |= (1 << 11); /* enable downshift */ - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_COPPER_SPECIFIC_CONTROL_REG, - control); -#endif - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, &control); - control |= IEEE_CTRL_AUTONEGOTIATE_ENABLE; - control |= IEEE_STAT_AUTONEGOTIATE_RESTART; -#if XPAR_GIGE_PCS_PMA_CORE_PRESENT == 1 - control &= IEEE_CTRL_ISOLATE_DISABLE; -#endif - - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, control); - - -#if XPAR_GIGE_PCS_PMA_CORE_PRESENT == 1 -#else - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, &control); - control |= IEEE_CTRL_RESET_MASK; - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, control); - - while (1) { - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, &control); - if (control & IEEE_CTRL_RESET_MASK) - continue; - else - break; - } -#endif - xil_printf("Waiting for PHY to complete autonegotiation.\r\n"); - - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_STATUS_REG_OFFSET, &status); - while ( !(status & IEEE_STAT_AUTONEGOTIATE_COMPLETE) ) { - sleep(1); -#if XPAR_GIGE_PCS_PMA_CORE_PRESENT == 1 -#else - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_COPPER_SPECIFIC_STATUS_REG_2, - &temp); - if (temp & IEEE_AUTONEG_ERROR_MASK) { - xil_printf("Auto negotiation error \r\n"); - } -#endif - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_STATUS_REG_OFFSET, - &status); - } - - xil_printf("autonegotiation complete \r\n"); - -#if XPAR_GIGE_PCS_PMA_CORE_PRESENT == 1 -#else - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_SPECIFIC_STATUS_REG, &partner_capabilities); -#endif - -#if XPAR_GIGE_PCS_PMA_CORE_PRESENT == 1 - xil_printf("Waiting for Link to be up; Polling for SGMII core Reg \r\n"); - XEmacPs_PhyRead(xemacpsp, phy_addr, 5, &temp); - while(!(temp & 0x8000)) { - XEmacPs_PhyRead(xemacpsp, phy_addr, 5, &temp); - } - if((temp & 0x0C00) == 0x0800) { - XEmacPs_PhyRead(xemacpsp, phy_addr, 0, &temp); - return 1000; - } - else if((temp & 0x0C00) == 0x0400) { - XEmacPs_PhyRead(xemacpsp, phy_addr, 0, &temp); - return 100; - } - else if((temp & 0x0C00) == 0x0000) { - XEmacPs_PhyRead(xemacpsp, phy_addr, 0, &temp); - return 10; - } else { - xil_printf("get_IEEE_phy_speed(): Invalid speed bit value, Deafulting to Speed = 10 Mbps\r\n"); - XEmacPs_PhyRead(xemacpsp, phy_addr, 0, &temp); - XEmacPs_PhyWrite(xemacpsp, phy_addr, 0, 0x0100); - return 10; - } -#else - if ( ((partner_capabilities >> 14) & 3) == 2)/* 1000Mbps */ - return 1000; - else if ( ((partner_capabilities >> 14) & 3) == 1)/* 100Mbps */ - return 100; - else /* 10Mbps */ - return 10; -#endif -} -#endif - -unsigned configure_IEEE_phy_speed(XEmacPs *xemacpsp, unsigned speed) -{ - u16 control; - u32 phy_addr = detect_phy(xemacpsp); - - XEmacPs_PhyWrite(xemacpsp,phy_addr, IEEE_PAGE_ADDRESS_REGISTER, 2); - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_CONTROL_REG_MAC, &control); - control |= IEEE_RGMII_TXRX_CLOCK_DELAYED_MASK; - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_CONTROL_REG_MAC, control); - - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_PAGE_ADDRESS_REGISTER, 0); - - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_AUTONEGO_ADVERTISE_REG, &control); - control |= IEEE_ASYMMETRIC_PAUSE_MASK; - control |= IEEE_PAUSE_MASK; - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_AUTONEGO_ADVERTISE_REG, control); - - XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, &control); - control &= ~IEEE_CTRL_LINKSPEED_1000M; - control &= ~IEEE_CTRL_LINKSPEED_100M; - control &= ~IEEE_CTRL_LINKSPEED_10M; - - if (speed == 1000) { - control |= IEEE_CTRL_LINKSPEED_1000M; - } - - else if (speed == 100) { - control |= IEEE_CTRL_LINKSPEED_100M; - /* Dont advertise PHY speed of 1000 Mbps */ - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_1000_ADVERTISE_REG_OFFSET, 0); - /* Dont advertise PHY speed of 10 Mbps */ - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_AUTONEGO_ADVERTISE_REG, - ADVERTISE_100); - } - - else if (speed == 10) { - control |= IEEE_CTRL_LINKSPEED_10M; - /* Dont advertise PHY speed of 1000 Mbps */ - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_1000_ADVERTISE_REG_OFFSET, - 0); - /* Dont advertise PHY speed of 100 Mbps */ - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_AUTONEGO_ADVERTISE_REG, - ADVERTISE_10); - } - - XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, - control | IEEE_CTRL_RESET_MASK); - { - volatile int wait; - for (wait=0; wait < 100000; wait++); - } - return 0; -} - -static void SetUpSLCRDivisors(int mac_baseaddr, int speed) -{ - volatile u32 slcrBaseAddress; -#ifndef PEEP - u32 SlcrDiv0; - u32 SlcrDiv1=0; - u32 SlcrTxClkCntrl; -#endif - - *(volatile unsigned int *)(SLCR_UNLOCK_ADDR) = SLCR_UNLOCK_KEY_VALUE; - - if ((unsigned long)mac_baseaddr == EMAC0_BASE_ADDRESS) { - slcrBaseAddress = SLCR_GEM0_CLK_CTRL_ADDR; - } else { - slcrBaseAddress = SLCR_GEM1_CLK_CTRL_ADDR; - } -#ifdef PEEP - if (speed == 1000) { - *(volatile unsigned int *)(slcrBaseAddress) = - SLCR_GEM_1G_CLK_CTRL_VALUE; - } else if (speed == 100) { - *(volatile unsigned int *)(slcrBaseAddress) = - SLCR_GEM_100M_CLK_CTRL_VALUE; - } else { - *(volatile unsigned int *)(slcrBaseAddress) = - SLCR_GEM_10M_CLK_CTRL_VALUE; - } -#else - if (speed == 1000) { - if ((unsigned long)mac_baseaddr == EMAC0_BASE_ADDRESS) { -#ifdef XPAR_PS7_ETHERNET_0_ENET_SLCR_1000MBPS_DIV0 - SlcrDiv0 = XPAR_PS7_ETHERNET_0_ENET_SLCR_1000MBPS_DIV0; - SlcrDiv1 = XPAR_PS7_ETHERNET_0_ENET_SLCR_1000MBPS_DIV1; -#endif - } else { -#ifdef XPAR_PS7_ETHERNET_1_ENET_SLCR_1000MBPS_DIV0 - SlcrDiv0 = XPAR_PS7_ETHERNET_1_ENET_SLCR_1000MBPS_DIV0; - SlcrDiv1 = XPAR_PS7_ETHERNET_1_ENET_SLCR_1000MBPS_DIV1; -#endif - } - } else if (speed == 100) { - if ((unsigned long)mac_baseaddr == EMAC0_BASE_ADDRESS) { -#ifdef XPAR_PS7_ETHERNET_0_ENET_SLCR_100MBPS_DIV0 - SlcrDiv0 = XPAR_PS7_ETHERNET_0_ENET_SLCR_100MBPS_DIV0; - SlcrDiv1 = XPAR_PS7_ETHERNET_0_ENET_SLCR_100MBPS_DIV1; -#endif - } else { -#ifdef XPAR_PS7_ETHERNET_1_ENET_SLCR_100MBPS_DIV0 - SlcrDiv0 = XPAR_PS7_ETHERNET_1_ENET_SLCR_100MBPS_DIV0; - SlcrDiv1 = XPAR_PS7_ETHERNET_1_ENET_SLCR_100MBPS_DIV1; -#endif - } - } else { - if ((unsigned long)mac_baseaddr == EMAC0_BASE_ADDRESS) { -#ifdef XPAR_PS7_ETHERNET_0_ENET_SLCR_10MBPS_DIV0 - SlcrDiv0 = XPAR_PS7_ETHERNET_0_ENET_SLCR_10MBPS_DIV0; - SlcrDiv1 = XPAR_PS7_ETHERNET_0_ENET_SLCR_10MBPS_DIV1; -#endif - } else { -#ifdef XPAR_PS7_ETHERNET_1_ENET_SLCR_10MBPS_DIV0 - SlcrDiv0 = XPAR_PS7_ETHERNET_1_ENET_SLCR_10MBPS_DIV0; - SlcrDiv1 = XPAR_PS7_ETHERNET_1_ENET_SLCR_10MBPS_DIV1; -#endif - } - } - SlcrTxClkCntrl = *(volatile unsigned int *)(slcrBaseAddress); - SlcrTxClkCntrl &= EMACPS_SLCR_DIV_MASK; - SlcrTxClkCntrl |= (SlcrDiv1 << 20); - SlcrTxClkCntrl |= (SlcrDiv0 << 8); - *(volatile unsigned int *)(slcrBaseAddress) = SlcrTxClkCntrl; -#endif - *(volatile unsigned int *)(SLCR_LOCK_ADDR) = SLCR_LOCK_KEY_VALUE; - return; -} - - -unsigned link_speed; -unsigned Phy_Setup (XEmacPs *xemacpsp) -{ - unsigned long conv_present = 0; - unsigned long convspeeddupsetting = 0; - unsigned long convphyaddr = 0; - -#ifdef XPAR_GMII2RGMIICON_0N_ETH0_ADDR - convphyaddr = XPAR_GMII2RGMIICON_0N_ETH0_ADDR; - conv_present = 1; -#else -#ifdef XPAR_GMII2RGMIICON_0N_ETH1_ADDR - convphyaddr = XPAR_GMII2RGMIICON_0N_ETH1_ADDR; - conv_present = 1; -#endif -#endif - -#ifdef ipconfigNIC_LINKSPEED_AUTODETECT - link_speed = get_IEEE_phy_speed(xemacpsp); - if (link_speed == 1000) { - SetUpSLCRDivisors(xemacpsp->Config.BaseAddress,1000); - convspeeddupsetting = XEMACPS_GMII2RGMII_SPEED1000_FD; - } else if (link_speed == 100) { - SetUpSLCRDivisors(xemacpsp->Config.BaseAddress,100); - convspeeddupsetting = XEMACPS_GMII2RGMII_SPEED100_FD; - } else { - SetUpSLCRDivisors(xemacpsp->Config.BaseAddress,10); - convspeeddupsetting = XEMACPS_GMII2RGMII_SPEED10_FD; - } -#elif defined(ipconfigNIC_LINKSPEED1000) - SetUpSLCRDivisors(xemacpsp->Config.BaseAddress,1000); - link_speed = 1000; - configure_IEEE_phy_speed(xemacpsp, link_speed); - convspeeddupsetting = XEMACPS_GMII2RGMII_SPEED1000_FD; - sleep(1); -#elif defined(ipconfigNIC_LINKSPEED100) - SetUpSLCRDivisors(xemacpsp->Config.BaseAddress,100); - link_speed = 100; - configure_IEEE_phy_speed(xemacpsp, link_speed); - convspeeddupsetting = XEMACPS_GMII2RGMII_SPEED100_FD; - sleep(1); -#elif defined(ipconfigNIC_LINKSPEED10) - SetUpSLCRDivisors(xemacpsp->Config.BaseAddress,10); - link_speed = 10; - configure_IEEE_phy_speed(xemacpsp, link_speed); - convspeeddupsetting = XEMACPS_GMII2RGMII_SPEED10_FD; - sleep(1); -#endif - if (conv_present) { - XEmacPs_PhyWrite(xemacpsp, convphyaddr, - XEMACPS_GMII2RGMII_REG_NUM, convspeeddupsetting); - } - - xil_printf("link speed: %d\r\n", link_speed); - return link_speed; -} - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_topology.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_topology.h deleted file mode 100755 index 1d8fede..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_topology.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2007-2013 Xilinx, Inc. All rights reserved. - * - * Xilinx, Inc. - * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A - * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS - * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR - * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION - * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE - * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. - * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO - * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO - * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE - * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. - * - */ - -#ifndef __XTOPOLOGY_H_ -#define __XTOPOLOGY_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -enum xemac_types { xemac_type_unknown = -1, xemac_type_xps_emaclite, xemac_type_xps_ll_temac, xemac_type_axi_ethernet, xemac_type_emacps }; - -struct xtopology_t { - unsigned emac_baseaddr; - enum xemac_types emac_type; - unsigned intc_baseaddr; - unsigned intc_emac_intr; /* valid only for xemac_type_xps_emaclite */ - unsigned scugic_baseaddr; /* valid only for Zynq */ - unsigned scugic_emac_intr; /* valid only for GEM */ -}; - -extern int x_topology_n_emacs; -extern struct xtopology_t x_topology[]; - -int x_topology_find_index(unsigned base); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/include/phyHandling.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/include/phyHandling.h deleted file mode 100755 index e9126dc..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/include/phyHandling.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Handling of Ethernet PHY's - * PHY's communicate with an EMAC either through - * a Media-Independent Interface (MII), or a Reduced Media-Independent Interface (RMII). - * The EMAC can poll for PHY ports on 32 different addresses. Each of the PHY ports - * shall be treated independently. - * - */ - -#ifndef PHYHANDLING_H - -#define PHYHANDLING_H - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifndef ipconfigPHY_MAX_PORTS - /* There can be at most 32 PHY ports, but in most cases there are 4 or less. */ - #define ipconfigPHY_MAX_PORTS 4 -#endif - -/* A generic user-provided function that reads from the PHY-port at 'xAddress'( 0-based ). A 16-bit value shall be stored in - '*pusValue'. xRegister is the register number ( 0 .. 31 ). In fact all PHY registers are 16-bit. - Return non-zero in case the action failed. */ -typedef BaseType_t ( *xApplicationPhyReadHook_t )( BaseType_t xAddress, BaseType_t xRegister, uint32_t *pulValue ); - -/* A generic user-provided function that writes 'usValue' to the - PHY-port at 'xAddress' ( 0-based ). xRegister is the register number ( 0 .. 31 ). - Return non-zero in case the action failed. */ -typedef BaseType_t ( *xApplicationPhyWriteHook_t )( BaseType_t xAddress, BaseType_t xRegister, uint32_t ulValue ); - -typedef struct xPhyProperties -{ - uint8_t ucSpeed; - uint8_t ucMDI_X; /* MDI-X : Medium Dependent Interface - Crossover */ - uint8_t ucDuplex; - uint8_t ucSpare; -} PhyProperties_t; - -typedef struct xEthernetPhy -{ - xApplicationPhyReadHook_t fnPhyRead; - xApplicationPhyWriteHook_t fnPhyWrite; - uint32_t ulPhyIDs[ ipconfigPHY_MAX_PORTS ]; - uint8_t ucPhyIndexes[ ipconfigPHY_MAX_PORTS ]; - TimeOut_t xLinkStatusTimer; - TickType_t xLinkStatusRemaining; - BaseType_t xPortCount; - uint32_t ulBCRValue; - uint32_t ulACRValue; - uint32_t ulLinkStatusMask; - PhyProperties_t xPhyPreferences; - PhyProperties_t xPhyProperties; -} EthernetPhy_t; - -/* Some defines used internally here to indicate preferences about speed, MDIX -(wired direct or crossed), and duplex (half or full). */ - -/* Values for PhyProperties_t::ucSpeed : */ -#define PHY_SPEED_10 1 -#define PHY_SPEED_100 2 -#define PHY_SPEED_AUTO 3 - -/* Values for PhyProperties_t::ucMDI_X : */ -#define PHY_MDIX_DIRECT 1 -#define PHY_MDIX_CROSSED 2 -#define PHY_MDIX_AUTO 3 - -/* Values for PhyProperties_t::ucDuplex : */ -#define PHY_DUPLEX_HALF 1 -#define PHY_DUPLEX_FULL 2 -#define PHY_DUPLEX_AUTO 3 - -/* ID's of supported PHY's : */ -#define PHY_ID_LAN8742A 0x0007c130 -#define PHY_ID_LAN8720 0x0007c0f0 - -#define PHY_ID_KSZ8041 0x000010A1 -#define PHY_ID_KSZ8051 0x000010A1 -#define PHY_ID_KSZ8081 0x000010A1 - -#define PHY_ID_KSZ8863 0x00221430 - -#define PHY_ID_DP83848I 0x20005C90 - - -/* Initialise the struct and assign a PHY-read and -write function. */ -void vPhyInitialise( EthernetPhy_t *pxPhyObject, xApplicationPhyReadHook_t fnPhyRead, xApplicationPhyWriteHook_t fnPhyWrite ); - -/* Discover all PHY's connected by polling 32 indexes ( zero-based ) */ -BaseType_t xPhyDiscover( EthernetPhy_t *pxPhyObject ); - -/* Send a reset commando to the connected PHY ports and send configuration. */ -BaseType_t xPhyConfigure( EthernetPhy_t *pxPhyObject, const PhyProperties_t *pxPhyProperties ); - -/* Give a commando to start auto negotiation on a set of PHY port's. */ -BaseType_t xPhyStartAutoNegotiation( EthernetPhy_t *pxPhyObject, uint32_t ulPhyMask ); - -/* Do not use auto negotiation but use predefined values from 'pxPhyObject->xPhyPreferences'. */ -BaseType_t xPhyFixedValue( EthernetPhy_t *pxPhyObject, uint32_t ulPhyMask ); - -/* Check the current Link Status. -'xHadReception' : make this true if a packet has been received since the -last call to this function. */ -BaseType_t xPhyCheckLinkStatus( EthernetPhy_t *pxPhyObject, BaseType_t xHadReception ); - -static __inline uint32_t xPhyGetMask( EthernetPhy_t *pxPhyObject ) -{ - return ( ( ( uint32_t ) 1u ) << pxPhyObject-> xPortCount ) - 1; -} - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ksz8851snl/NetworkInterface.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ksz8851snl/NetworkInterface.c deleted file mode 100755 index e6085d0..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ksz8851snl/NetworkInterface.c +++ /dev/null @@ -1,1272 +0,0 @@ -/* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - http://aws.amazon.com/freertos - http://www.FreeRTOS.org -*/ - -/* Standard includes. */ -#include -#include -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP_Private.h" -#include "NetworkBufferManagement.h" -#include "NetworkInterface.h" - -#include "sam4e_xplained_pro.h" -#include "hr_gettime.h" -#include "conf_eth.h" -#include "ksz8851snl.h" -#include "ksz8851snl_reg.h" - -/* Some files from the Atmel Software Framework */ -#include -#include -#include - -/* - Sending a packet: - - 1) Called by UP-task, add buffer to the TX-list: - xNetworkInterfaceOutput() - tx_buffers[ us_tx_head ] = pxNetworkBuffer; - tx_busy[ us_tx_head ] = pdTRUE; - us_tx_head++; - - 2) Called by EMAC-Task: start SPI transfer - ksz8851snl_update() - if( ul_spi_pdc_status == SPI_PDC_IDLE ) - { - if( ( tx_busy[ us_tx_tail ] != pdFALSE ) && - ( us_pending_frame == 0 ) && - ( ul_had_intn_interrupt == 0 ) ) - { - // disable all interrupts. - ksz8851_reg_write( REG_INT_MASK, 0 ); - Bring KSZ8851SNL_CSN_GPIO low - ksz8851_fifo_write( pxNetworkBuffer->pucEthernetBuffer, xLength, xLength ); - ul_spi_pdc_status = SPI_PDC_TX_START; - tx_cur_buffer = pxNetworkBuffer; - } - } - 3) Wait for SPI RXBUFF interrupt - SPI_Handler() - if( ul_spi_pdc_status == SPI_PDC_TX_START ) - { - if( SPI_Status & SPI_SR_RXBUFF ) - { - ul_spi_pdc_status = SPI_PDC_TX_COMPLETE; - } - } - - 4) Called by EMAC-Task: finish SPI transfer - ksz8851snl_update() - if( ul_spi_pdc_status == SPI_PDC_TX_COMPLETE ) - { - ul_spi_pdc_status = SPI_PDC_IDLE; - Bring KSZ8851SNL_CSN_GPIO high - // TX step12: disable TXQ write access. - ksz8851_reg_clrbits( REG_RXQ_CMD, RXQ_START ); - // TX step12.1: enqueue frame in TXQ. - ksz8851_reg_setbits( REG_TXQ_CMD, TXQ_ENQUEUE ); - - // RX step13: enable INT_RX flag. - ksz8851_reg_write( REG_INT_MASK, INT_RX ); - - // Buffer sent, free the corresponding buffer and mark descriptor as owned by software. - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - - tx_buffers[ us_tx_tail ] = NULL; - tx_busy[ us_tx_tail ] = pdFALSE; - us_tx_tail++ - } - - Receiving a packet: - - 1) Wait for a INTN interrupt - INTN_Handler() - ul_had_intn_interrupt = 1 - vTaskNotifyGiveFromISR(); // Wake up the EMAC task - - 2) Called by EMAC-Task: check for new fragments and start SPI transfer - ksz8851snl_update() - if( ul_spi_pdc_status == SPI_PDC_IDLE ) - { - if( ( ul_had_intn_interrupt != 0 ) || ( us_pending_frame > 0 ) ) - { - if( us_pending_frame == 0 ) - { - us_pending_frame = ksz8851_reg_read(REG_RX_FRAME_CNT_THRES) >> 8; - if( us_pending_frame == 0 ) - { - break; - } - } - // RX step2: disable all interrupts. - ksz8851_reg_write( REG_INT_MASK, 0 ); - Check if there is a valid packet: REG_RX_FHR_STATUS - Read the length of the next fragment: REG_RX_FHR_BYTE_CNT - ul_spi_pdc_status = SPI_PDC_RX_START; - gpio_set_pin_low(KSZ8851SNL_CSN_GPIO); - // Start SPI data transfer - ksz8851_fifo_read( pxNetworkBuffer->pucEthernetBuffer, xReadLength ); - } - } - - 3) Wait for SPI RXBUFF interrupt - SPI_Handler() - if( ul_spi_pdc_status == SPI_PDC_RX_START: - { - if( ( ulCurrentSPIStatus & SPI_SR_RXBUFF ) != 0 ) - { - // Transfer complete, disable SPI RXBUFF interrupt. - spi_disable_interrupt( KSZ8851SNL_SPI, SPI_IDR_RXBUFF ); - - ul_spi_pdc_status = SPI_PDC_RX_COMPLETE; - } - } - } - - 4) Finish SPI transfer - ksz8851snl_update() - if( ul_spi_pdc_status == SPI_PDC_RX_COMPLETE ) - { - ul_spi_pdc_status = SPI_PDC_IDLE; - Bring KSZ8851SNL_CSN_GPIO high - // RX step21: end RXQ read access. - ksz8851_reg_clrbits(REG_RXQ_CMD, RXQ_START); - // RX step22-23: update frame count to be read. - us_pending_frame-- - // RX step24: enable INT_RX flag if transfer complete. - if( us_pending_frame == 0 ) - { - // Allow more RX interrupts. - ksz8851_reg_write( REG_INT_MASK, INT_RX ); - } - - // Mark descriptor ready to be read. - rx_ready[ rxHead ] = pdTRUE; - rxHead++ - } -*/ - -#define PHY_REG_00_BMCR 0x00 // Basic mode control register -#define PHY_REG_01_BMSR 0x01 // Basic mode status register -#define PHY_REG_02_PHYSID1 0x02 // PHYS ID 1 -#define PHY_REG_03_PHYSID2 0x03 // PHYS ID 2 -#define PHY_REG_04_ADVERTISE 0x04 // Advertisement control reg -#define PHY_REG_05_LPA 0x05 // Link partner ability reg -#define PHY_REG_06_ANER 0x06 // 6 RW Auto-Negotiation Expansion Register -#define PHY_REG_07_ANNPTR 0x07 // 7 RW Auto-Negotiation Next Page TX -#define PHY_REG_08_RESERVED0 0x08 // 0x08..0x0Fh 8-15 RW RESERVED - -#define BMSR_LINK_STATUS 0x0004 //!< Link status - -#ifndef PHY_LS_HIGH_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still high after 15 seconds of not - receiving packets. */ - #define PHY_LS_HIGH_CHECK_TIME_MS 15000 -#endif - -#ifndef PHY_LS_LOW_CHECK_TIME_MS - /* Check if the LinkSStatus in the PHY is still low every second. */ - #define PHY_LS_LOW_CHECK_TIME_MS 1000 -#endif - -/* Interrupt events to process. Currently only the Rx event is processed -although code for other events is included to allow for possible future -expansion. */ -#define EMAC_IF_RX_EVENT 1UL -#define EMAC_IF_TX_EVENT 2UL -#define EMAC_IF_ERR_EVENT 4UL -#define EMAC_IF_ALL_EVENT ( EMAC_IF_RX_EVENT | EMAC_IF_TX_EVENT | EMAC_IF_ERR_EVENT ) - -#define ETHERNET_CONF_PHY_ADDR BOARD_GMAC_PHY_ADDR - -#ifdef ipconfigHAS_TX_CRC_OFFLOADING - #undef ipconfigHAS_TX_CRC_OFFLOADING -#endif -/* Override this define because the KSZ8851 is programmed to set all outgoing CRC's */ -#define ipconfigHAS_TX_CRC_OFFLOADING 1 - -#ifndef EMAC_MAX_BLOCK_TIME_MS - #define EMAC_MAX_BLOCK_TIME_MS 100ul -#endif - -/* Default the size of the stack used by the EMAC deferred handler task to 4x -the size of the stack used by the idle task - but allow this to be overridden in -FreeRTOSConfig.h as configMINIMAL_STACK_SIZE is a user definable constant. */ -#ifndef configEMAC_TASK_STACK_SIZE - #define configEMAC_TASK_STACK_SIZE ( 6 * configMINIMAL_STACK_SIZE ) -#endif - -#define SPI_PDC_IDLE 0 -#define SPI_PDC_RX_START 1 -#define SPI_PDC_TX_ERROR 2 -#define SPI_PDC_RX_COMPLETE 3 -#define SPI_PDC_TX_START 4 -#define SPI_PDC_RX_ERROR 5 -#define SPI_PDC_TX_COMPLETE 6 - -/** - * ksz8851snl driver structure. - */ -typedef struct { - /** Set to 1 when owner is software (ready to read), 0 for Micrel. */ - uint32_t rx_ready[MICREL_RX_BUFFERS]; - /** Set to 1 when owner is Micrel, 0 for software. */ - uint32_t tx_busy[MICREL_TX_BUFFERS]; - /** RX NetworkBufferDescriptor_t pointer list */ - NetworkBufferDescriptor_t *rx_buffers[MICREL_RX_BUFFERS]; - /** TX NetworkBufferDescriptor_t pointer list */ - NetworkBufferDescriptor_t *tx_buffers[MICREL_TX_BUFFERS]; - NetworkBufferDescriptor_t *tx_cur_buffer; - - /** Circular buffer head pointer for packet received. */ - uint32_t us_rx_head; - /** Circular buffer tail pointer for packet to be read. */ - uint32_t us_rx_tail; - /** Circular buffer head pointer by upper layer (buffer to be sent). */ - uint32_t us_tx_head; - /** Circular buffer tail pointer incremented by handlers (buffer sent). */ - uint32_t us_tx_tail; - - uint32_t ul_total_tx; - uint32_t ul_total_rx; - uint32_t tx_space; - - /** Still experimental: hash table to allow certain multicast addresses. */ - uint16_t pusHashTable[ 4 ]; - - /* ul_spi_pdc_status has "SPI_PDC_xxx" values. */ - volatile uint32_t ul_spi_pdc_status; - - /* ul_had_intn_interrupt becomes true within the INTN interrupt. */ - volatile uint32_t ul_had_intn_interrupt; - - uint16_t us_pending_frame; -} xKSZ8851_Device_t; - -/* SPI PDC register base. -Declared in ASF\sam\components\ksz8851snl\ksz8851snl.c */ -extern Pdc *g_p_spi_pdc; - -/* Temporary buffer for PDC reception. -declared in ASF\sam\components\ksz8851snl\ksz8851snl.c */ -extern uint8_t tmpbuf[1536]; - -COMPILER_ALIGNED(8) -static xKSZ8851_Device_t xMicrelDevice; - -static TaskHandle_t xTransmitHandle; - -/*-----------------------------------------------------------*/ - -/* - * Wait a fixed time for the link status to indicate the network is up. - */ -static BaseType_t xGMACWaitLS( TickType_t xMaxTime ); - -/* - * A deferred interrupt handler task that processes GMAC interrupts. - */ -static void prvEMACHandlerTask( void *pvParameters ); - -/* - * Try to obtain an Rx packet from the hardware. - */ -static uint32_t prvEMACRxPoll( void ); - -static inline unsigned long ulReadMDIO( unsigned uAddress ); - -static void ksz8851snl_low_level_init( void ); - -static NetworkBufferDescriptor_t *ksz8851snl_low_level_input( void ); - -/*-----------------------------------------------------------*/ - -/* Bit map of outstanding ETH interrupt events for processing. Currently only -the Rx interrupt is handled, although code is included for other events to -enable future expansion. */ -static volatile uint32_t ulISREvents; - -/* A copy of PHY register 1: 'PHY_REG_01_BMSR' */ -static uint32_t ulPHYLinkStatus = 0; -static volatile BaseType_t xGMACSwitchRequired; - -static void ksz8851snl_update( void ); - -static void ksz8851snl_rx_init( void ); - -static void ksz8851snl_tx_init( void ); - -/* Holds the handle of the task used as a deferred interrupt processor. The -handle is used so direct notifications can be sent to the task for all EMAC/DMA -related interrupts. */ -TaskHandle_t xEMACTaskHandle = NULL; - - -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceInitialise( void ) -{ -const TickType_t x5_Seconds = 5000UL; - - if( xEMACTaskHandle == NULL ) - { - ksz8851snl_low_level_init(); - - /* Wait at most 5 seconds for a Link Status in the PHY. */ - xGMACWaitLS( pdMS_TO_TICKS( x5_Seconds ) ); - - /* The handler task is created at the highest possible priority to - ensure the interrupt handler can return directly to it. */ - xTaskCreate( prvEMACHandlerTask, "KSZ8851", configEMAC_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, &xEMACTaskHandle ); - configASSERT( xEMACTaskHandle ); - } - - /* When returning non-zero, the stack will become active and - start DHCP (in configured) */ - ulPHYLinkStatus = ulReadMDIO( PHY_REG_01_BMSR ); - - return ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0; -} -/*-----------------------------------------------------------*/ - -BaseType_t xGetPhyLinkStatus( void ) -{ -BaseType_t xResult; - - /* This function returns true if the Link Status in the PHY is high. */ - if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) - { - xResult = pdTRUE; - } - else - { - xResult = pdFALSE; - } - - return xResult; -} -/*-----------------------------------------------------------*/ - -BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer, BaseType_t bReleaseAfterSend ) -{ -BaseType_t xResult = pdFALSE; -int txHead = xMicrelDevice.us_tx_head; - - /* Make sure the next descriptor is free. */ - if( xMicrelDevice.tx_busy[ txHead ] != pdFALSE ) - { - /* All TX buffers busy. */ - } - else if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) == 0 ) - { - /* Output: LS low. */ - } - else - { - /* Pass the packet. */ - xMicrelDevice.tx_buffers[ txHead ] = pxNetworkBuffer; - /* The descriptor is now owned by Micrel. */ - xMicrelDevice.tx_busy[ txHead ] = pdTRUE; - - /* Move the head pointer. */ - if( ++txHead == MICREL_TX_BUFFERS ) - { - txHead = 0; - } - xMicrelDevice.us_tx_head = txHead; - if( xEMACTaskHandle != NULL ) - { - xTaskNotifyGive( xEMACTaskHandle ); - } - - #if( ipconfigZERO_COPY_TX_DRIVER != 1 ) - #warning Please ipconfigZERO_COPY_TX_DRIVER as 1 - #endif - configASSERT( bReleaseAfterSend != pdFALSE ); - xResult = pdTRUE; - } - if( ( xResult == pdFALSE ) && ( bReleaseAfterSend != pdFALSE ) ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - } - return xResult; -} -/*-----------------------------------------------------------*/ - -/* This Micrel has numbered it's PHY registers in a different way. -Translate the register index. */ -static int ks8851_phy_reg( int reg ) -{ - switch (reg) { - case PHY_REG_00_BMCR: - return REG_PHY_CNTL; // P1MBCR; - case PHY_REG_01_BMSR: - return REG_PHY_STATUS; - case PHY_REG_02_PHYSID1: - return REG_PHY_ID_LOW; - case PHY_REG_03_PHYSID2: - return REG_PHY_ID_HIGH; - case PHY_REG_04_ADVERTISE: - return REG_PHY_AUTO_NEGOTIATION; - case PHY_REG_05_LPA: - return REG_PHY_REMOTE_CAPABILITY; - } - - return 0x0; -} -/*-----------------------------------------------------------*/ - -static inline unsigned long ulReadMDIO( unsigned uAddress ) -{ -uint16_t usPHYStatus; -int ks8851_reg = ks8851_phy_reg( uAddress ); - - if( ks8851_reg != 0 ) - { - usPHYStatus = ksz8851_reg_read( ks8851_reg ); - } - else - { - /* Other addresses not yet implemented. */ - usPHYStatus = 0; - } - return usPHYStatus; -} -/*-----------------------------------------------------------*/ - -static BaseType_t xGMACWaitLS( TickType_t xMaxTime ) -{ -TickType_t xStartTime = xTaskGetTickCount(); -TickType_t xEndTime; -BaseType_t xReturn; -const TickType_t xShortTime = pdMS_TO_TICKS( 100UL ); -const uint32_t ulHz_Per_MHz = 1000000UL; - - for( ;; ) - { - xEndTime = xTaskGetTickCount(); - - if( ( xEndTime - xStartTime ) > xMaxTime ) - { - /* Wated more than xMaxTime, return. */ - xReturn = pdFALSE; - break; - } - - /* Check the link status again. */ - ulPHYLinkStatus = ulReadMDIO( PHY_REG_01_BMSR ); - - if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) - { - /* Link is up - return. */ - xReturn = pdTRUE; - break; - } - - /* Link is down - wait in the Blocked state for a short while (to allow - other tasks to execute) before checking again. */ - vTaskDelay( xShortTime ); - } - - FreeRTOS_printf( ( "xGMACWaitLS: %ld freq %lu Mz\n", - xReturn, - sysclk_get_cpu_hz() / ulHz_Per_MHz ) ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -static void vPioSetPinHigh(uint32_t ul_pin) -{ - Pio *p_pio = (Pio *)((uint32_t)PIOA + (PIO_DELTA * (ul_pin >> 5))); - // Value to be driven on the I/O line: 1. - p_pio->PIO_SODR = 1 << (ul_pin & 0x1F); -} - -/** - * \brief Handler for SPI interrupt. - */ -void SPI_Handler(void) -{ -BaseType_t xDoWakeup = pdFALSE; -BaseType_t xKSZTaskWoken = pdFALSE; -uint32_t ulCurrentSPIStatus; -uint32_t ulEnabledSPIStatus; - - ulCurrentSPIStatus = spi_read_status( KSZ8851SNL_SPI ); - ulEnabledSPIStatus = spi_read_interrupt_mask( KSZ8851SNL_SPI ); - ulCurrentSPIStatus &= ulEnabledSPIStatus; - spi_disable_interrupt( KSZ8851SNL_SPI, ulCurrentSPIStatus ); - - - switch( xMicrelDevice.ul_spi_pdc_status ) - { - case SPI_PDC_RX_START: - { - if( ( ulCurrentSPIStatus & SPI_SR_OVRES ) != 0 ) - { - pdc_disable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTDIS | PERIPH_PTCR_TXTDIS); - xMicrelDevice.ul_spi_pdc_status = SPI_PDC_RX_ERROR; - xDoWakeup = pdTRUE; - } - else - { - if( ( ulCurrentSPIStatus & SPI_SR_RXBUFF ) != 0 ) - { - xMicrelDevice.ul_spi_pdc_status = SPI_PDC_RX_COMPLETE; - xDoWakeup = pdTRUE; - } - } - } - break; - - case SPI_PDC_TX_START: - { - /* Middle of TX. */ - if( ( ulCurrentSPIStatus & SPI_SR_OVRES ) != 0 ) - { - pdc_disable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTDIS | PERIPH_PTCR_TXTDIS); - xMicrelDevice.ul_spi_pdc_status = SPI_PDC_TX_ERROR; - xDoWakeup = pdTRUE; - } - else - { - if( ( ulCurrentSPIStatus & SPI_SR_ENDRX ) != 0 ) - { - /* Enable RX complete interrupt. */ - spi_enable_interrupt( KSZ8851SNL_SPI, SPI_IER_RXBUFF ); - } - /* End of TX. */ - if( ( ulCurrentSPIStatus & SPI_END_OF_TX ) != 0 ) - { - xMicrelDevice.ul_spi_pdc_status = SPI_PDC_TX_COMPLETE; - xDoWakeup = pdTRUE; - } - } - } - break; - } /* switch( xMicrelDevice.ul_spi_pdc_status ) */ - - if( xDoWakeup != pdFALSE ) - { - if( xEMACTaskHandle != NULL ) - { - vTaskNotifyGiveFromISR( xEMACTaskHandle, ( BaseType_t * ) &xKSZTaskWoken ); - } - } - else - { - } - portEND_SWITCHING_ISR( xKSZTaskWoken ); -} -/*-----------------------------------------------------------*/ - -static void INTN_Handler(uint32_t id, uint32_t mask) -{ -BaseType_t xKSZTaskWoken = pdFALSE; - - if( ( id == INTN_ID ) && - ( mask == INTN_PIN_MSK ) ) - { - /* Clear the PIO interrupt flags. */ - pio_get_interrupt_status( INTN_PIO ); - - /* Set the INTN flag. */ - xMicrelDevice.ul_had_intn_interrupt++; - if( xEMACTaskHandle != NULL ) - { - vTaskNotifyGiveFromISR( xEMACTaskHandle, &( xKSZTaskWoken ) ); - } - } - portEND_SWITCHING_ISR( xKSZTaskWoken ); -} -/*-----------------------------------------------------------*/ - -/** - * \brief Populate the RX descriptor ring buffers with pbufs. - * - * \param p_ksz8851snl_dev Pointer to driver data structure. - */ -static void ksz8851snl_rx_populate_queue( void ) -{ - uint32_t ul_index = 0; - NetworkBufferDescriptor_t *pxNetworkBuffer; - - /* Set up the RX descriptors */ - for (ul_index = 0; ul_index < MICREL_RX_BUFFERS; ul_index++) { - if( xMicrelDevice.rx_buffers[ ul_index ] == NULL ) - { - /* Allocate a new NetworkBufferDescriptor_t with the maximum size. */ - pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( ipconfigNETWORK_MTU + 36, 100 ); - if( pxNetworkBuffer == NULL ) - { - FreeRTOS_printf( ( "ksz8851snl_rx_populate_queue: NetworkBufferDescriptor_t allocation failure\n" ) ); - configASSERT( 1 == 2 ); - } - - /* Make sure lwIP is well configured so one NetworkBufferDescriptor_t can contain the maximum packet size. */ - //LWIP_ASSERT("ksz8851snl_rx_populate_queue: NetworkBufferDescriptor_t size too small!", pbuf_clen(pxNetworkBuffer) <= 1); - - /* Save NetworkBufferDescriptor_t pointer to be sent to lwIP upper layer. */ - xMicrelDevice.rx_buffers[ ul_index ] = pxNetworkBuffer; - /* Pass it to Micrel for reception. */ - xMicrelDevice.rx_ready[ ul_index ] = pdFALSE; - } - } -} - -unsigned tx_space, wait_tx_space, tx_status, fhr_status; -unsigned rx_debug = 0; -/** - * \brief Update Micrel state machine and perform required actions. - * - * \param netif the lwIP network interface structure for this ethernetif. - */ -static void ksz8851snl_update() -{ - uint16_t txmir = 0; - -/* Check for free PDC. */ - switch( xMicrelDevice.ul_spi_pdc_status ) - { - case SPI_PDC_TX_ERROR: - { - uint32_t ulValue; - // /* TX step11: end TX transfer. */ - gpio_set_pin_high( KSZ8851SNL_CSN_GPIO ); - - vTaskDelay( 2 ); gpio_set_pin_low( KSZ8851SNL_CSN_GPIO ); - vTaskDelay( 1 ); gpio_set_pin_high( KSZ8851SNL_CSN_GPIO ); - vTaskDelay( 1 ); - - /* Disable asynchronous transfer mode. */ - xMicrelDevice.ul_spi_pdc_status = SPI_PDC_IDLE; - - /* TX step12: disable TXQ write access. */ - ksz8851_reg_clrbits( REG_RXQ_CMD, RXQ_START ); - - ulValue = ksz8851snl_reset_tx(); - - xMicrelDevice.tx_space = ksz8851_reg_read( REG_TX_MEM_INFO ) & TX_MEM_AVAILABLE_MASK; - - FreeRTOS_printf( ("SPI_PDC_TX_ERROR %02X\n", ulValue ) ); - } - break; - - case SPI_PDC_RX_ERROR: - { - uint32_t ulValue; - /* TX step11: end TX transfer. */ - gpio_set_pin_high( KSZ8851SNL_CSN_GPIO ); - - vTaskDelay( 2 ); gpio_set_pin_low( KSZ8851SNL_CSN_GPIO ); - vTaskDelay( 1 ); gpio_set_pin_high( KSZ8851SNL_CSN_GPIO ); - vTaskDelay( 1 ); - - /* Disable asynchronous transfer mode. */ - xMicrelDevice.ul_spi_pdc_status = SPI_PDC_IDLE; - - /* TX step12: disable TXQ write access. */ - ksz8851_reg_clrbits( REG_RXQ_CMD, RXQ_START ); - - //ulValue = ksz8851snl_reset_rx(); - ulValue = ksz8851snl_reinit(); - - xGMACWaitLS( pdMS_TO_TICKS( 5000UL ) ); - - FreeRTOS_printf( ("SPI_PDC_RX_ERROR %02X\n", ulValue ) ); - } - break; - } - switch( xMicrelDevice.ul_spi_pdc_status ) - { - case SPI_PDC_IDLE: - { - int txTail = xMicrelDevice.us_tx_tail; - - /* - * ========================== Handle RX ========================== - */ - if( ( xMicrelDevice.ul_had_intn_interrupt != 0 ) || ( xMicrelDevice.us_pending_frame > 0 ) ) - { - int rxHead = xMicrelDevice.us_rx_head; - NetworkBufferDescriptor_t *pxNetworkBuffer; -#warning try - xMicrelDevice.ul_had_intn_interrupt = 0; - - if( xMicrelDevice.us_pending_frame == 0 ) - { - uint16_t int_status; - /* RX step1: read interrupt status for INT_RX flag. */ - int_status = ksz8851_reg_read( REG_INT_STATUS ); - - - /* RX step2: disable all interrupts. */ - ksz8851_reg_write( REG_INT_MASK, 0 ); - - /* RX step3: clear INT_RX flag. */ - ksz8851_reg_setbits( REG_INT_STATUS, INT_RX ); - - /* RX step4-5: check for received frames. */ - xMicrelDevice.us_pending_frame = ksz8851_reg_read(REG_RX_FRAME_CNT_THRES) >> 8; - if( xMicrelDevice.us_pending_frame == 0 ) - { - /* RX step24: enable INT_RX flag. */ - ksz8851_reg_write(REG_INT_MASK, INT_RX); - return; - } - } -#warning try - xMicrelDevice.ul_had_intn_interrupt = 0; - - /* Now xMicrelDevice.us_pending_frame != 0 */ - - /* Don't break Micrel state machine, wait for a free descriptor first! */ - if( xMicrelDevice.rx_ready[ rxHead ] != pdFALSE ) - { - FreeRTOS_printf( ( "ksz8851snl_update: out of free descriptor! [tail=%u head=%u]\n", - xMicrelDevice.us_rx_tail, rxHead ) ); - return; - } - pxNetworkBuffer = xMicrelDevice.rx_buffers[ rxHead ]; - - if( pxNetworkBuffer == NULL ) - { - ksz8851snl_rx_populate_queue(); - FreeRTOS_printf( ( "ksz8851snl_update: no buffer set [head=%u]\n", rxHead ) ); - return; - } - - /* RX step6: get RX packet status. */ - fhr_status = ksz8851_reg_read( REG_RX_FHR_STATUS ); - if( ( ( fhr_status & RX_VALID ) == 0 ) || ( ( fhr_status & RX_ERRORS ) != 0 ) ) - { - ksz8851_reg_setbits(REG_RXQ_CMD, RXQ_CMD_FREE_PACKET); - FreeRTOS_printf( ( "ksz8851snl_update: RX packet error!\n" ) ); - - /* RX step4-5: check for received frames. */ - xMicrelDevice.us_pending_frame = ksz8851_reg_read(REG_RX_FRAME_CNT_THRES) >> 8; - if( xMicrelDevice.us_pending_frame == 0 ) - { - /* RX step24: enable INT_RX flag. */ - ksz8851_reg_write(REG_INT_MASK, INT_RX); - } - ulISREvents |= EMAC_IF_ERR_EVENT; - } - else - { - size_t xLength; - /* RX step7: read frame length. */ - xLength = ksz8851_reg_read(REG_RX_FHR_BYTE_CNT) & RX_BYTE_CNT_MASK; - - /* RX step8: Drop packet if len is invalid or no descriptor available. */ - if( xLength == 0 ) - { - ksz8851_reg_setbits( REG_RXQ_CMD, RXQ_CMD_FREE_PACKET ); - FreeRTOS_printf( ( "ksz8851snl_update: RX bad len!\n" ) ); - ulISREvents |= EMAC_IF_ERR_EVENT; - } - else - { - size_t xReadLength = xLength; - - xMicrelDevice.ul_total_rx++; - /* RX step9: reset RX frame pointer. */ - ksz8851_reg_clrbits(REG_RX_ADDR_PTR, ADDR_PTR_MASK); - - /* RX step10: start RXQ read access. */ - ksz8851_reg_setbits(REG_RXQ_CMD, RXQ_START); - /* RX step11-17: start asynchronous FIFO read operation. */ - xMicrelDevice.ul_spi_pdc_status = SPI_PDC_RX_START; - gpio_set_pin_low( KSZ8851SNL_CSN_GPIO ); - if( ( xReadLength & ( sizeof( size_t ) - 1 ) ) != 0 ) - { - xReadLength = ( xReadLength | ( sizeof( size_t ) - 1 ) ) + 1; - } - - /* Pass the buffer minus 2 bytes, see ksz8851snl.c: RXQ_TWOBYTE_OFFSET. */ - ksz8851_fifo_read( pxNetworkBuffer->pucEthernetBuffer - 2, xReadLength ); - /* Remove CRC and update buffer length. */ - xLength -= 4; - pxNetworkBuffer->xDataLength = xLength; - /* Wait for SPI interrupt to set status 'SPI_PDC_RX_COMPLETE'. */ - } - } - break; - } /* ul_had_intn_interrupt || us_pending_frame */ - /* - * ========================== Handle TX ========================== - */ - - /* Fetch next packet to be sent. */ - if( ( xMicrelDevice.tx_busy[ txTail ] != pdFALSE ) && - ( xMicrelDevice.us_pending_frame == 0 ) && - ( xMicrelDevice.ul_had_intn_interrupt == 0 ) ) - { - NetworkBufferDescriptor_t *pxNetworkBuffer = xMicrelDevice.tx_buffers[ txTail ]; - size_t xLength = pxNetworkBuffer->xDataLength; - int iIndex = xLength; - - xLength = 4 * ( ( xLength + 3 ) / 4 ); - while( iIndex < ( int ) xLength ) - { - pxNetworkBuffer->pucEthernetBuffer[ iIndex ] = '\0'; - iIndex++; - } - pxNetworkBuffer->xDataLength = xLength; - - /* TX step1: check if TXQ memory size is available for transmit. */ - txmir = ksz8851_reg_read( REG_TX_MEM_INFO ); - txmir = txmir & TX_MEM_AVAILABLE_MASK; - - if( txmir < ( xLength + 8 ) ) - { - if( wait_tx_space == pdFALSE ) - { - tx_status = ksz8851_reg_read( REG_TX_STATUS ); - fhr_status = ksz8851_reg_read( REG_RX_FHR_STATUS ); - wait_tx_space = pdTRUE; - } - //return; - rx_debug = 1; - tx_space = txmir; - } - else - { - tx_space = txmir; - - /* TX step2: disable all interrupts. */ - ksz8851_reg_write( REG_INT_MASK, 0 ); - - xMicrelDevice.tx_space -= xLength; - - /* TX step3: enable TXQ write access. */ - ksz8851_reg_setbits( REG_RXQ_CMD, RXQ_START ); - /* TX step4-8: perform FIFO write operation. */ - xMicrelDevice.ul_spi_pdc_status = SPI_PDC_TX_START; - xMicrelDevice.tx_cur_buffer = pxNetworkBuffer; - /* Bring SPI SS low. */ - gpio_set_pin_low( KSZ8851SNL_CSN_GPIO ); - xMicrelDevice.ul_total_tx++; - - ksz8851_fifo_write( pxNetworkBuffer->pucEthernetBuffer, xLength, xLength ); - } - } - } - break; /* SPI_PDC_IDLE */ - - case SPI_PDC_RX_COMPLETE: - { - int rxHead = xMicrelDevice.us_rx_head; - /* RX step18-19: pad with dummy data to keep dword alignment. */ - /* Packet lengths will be rounded up to a multiple of "sizeof size_t". */ -// xLength = xMicrelDevice.rx_buffers[ rxHead ]->xDataLength & 3; -// if( xLength != 0 ) -// { -// ksz8851_fifo_dummy( 4 - xLength ); -// } - - /* RX step20: end RX transfer. */ - gpio_set_pin_high( KSZ8851SNL_CSN_GPIO ); - - /* Disable asynchronous transfer mode. */ - xMicrelDevice.ul_spi_pdc_status = SPI_PDC_IDLE; - - /* RX step21: end RXQ read access. */ - ksz8851_reg_clrbits(REG_RXQ_CMD, RXQ_START); - - /* RX step22-23: update frame count to be read. */ - xMicrelDevice.us_pending_frame -= 1; - - /* RX step24: enable INT_RX flag if transfer complete. */ - if( xMicrelDevice.us_pending_frame == 0 ) - { - ksz8851_reg_write(REG_INT_MASK, INT_RX); - } - - /* Mark descriptor ready to be read. */ - xMicrelDevice.rx_ready[ rxHead ] = pdTRUE; - if( ++rxHead == MICREL_RX_BUFFERS ) - { - rxHead = 0; - } - xMicrelDevice.us_rx_head = rxHead; - if( rx_debug != 0 ) - { - uint32_t txmir; - rx_debug = 0; - txmir = ksz8851_reg_read( REG_TX_MEM_INFO ); - txmir = txmir & TX_MEM_AVAILABLE_MASK; - } - /* Tell prvEMACHandlerTask that RX packets are available. */ - ulISREvents |= EMAC_IF_RX_EVENT; - } /* case SPI_PDC_RX_COMPLETE */ - break; - - case SPI_PDC_TX_COMPLETE: - { - int txTail = xMicrelDevice.us_tx_tail; - NetworkBufferDescriptor_t *pxNetworkBuffer = xMicrelDevice.tx_buffers[ txTail ]; - - size_t xLength; - /* TX step9-10: pad with dummy data to keep dword alignment. */ - /* Not necessary: length is already a multiple of 4. */ - xLength = pxNetworkBuffer->xDataLength & 3; - if( xLength != 0 ) - { -// ksz8851_fifo_dummy( 4 - xLength ); - } - -// /* TX step11: end TX transfer. */ - gpio_set_pin_high( KSZ8851SNL_CSN_GPIO ); - - /* Disable asynchronous transfer mode. */ - xMicrelDevice.ul_spi_pdc_status = SPI_PDC_IDLE; - - /* TX step12: disable TXQ write access. */ - ksz8851_reg_clrbits( REG_RXQ_CMD, RXQ_START ); - - xMicrelDevice.tx_space = ksz8851_reg_read( REG_TX_MEM_INFO ) & TX_MEM_AVAILABLE_MASK; - - /* TX step12.1: enqueue frame in TXQ. */ - ksz8851_reg_setbits( REG_TXQ_CMD, TXQ_ENQUEUE ); - - /* RX step13: enable INT_RX flag. */ -// ksz8851_reg_write( REG_INT_MASK, INT_RX ); - /* Buffer sent, free the corresponding buffer and mark descriptor as owned by software. */ - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - - xMicrelDevice.tx_buffers[ txTail ] = NULL; - xMicrelDevice.tx_busy[ txTail ] = pdFALSE; - if( ++txTail == MICREL_TX_BUFFERS ) - { - txTail = 0; - } - - xMicrelDevice.us_tx_tail = txTail; - /* Experiment. */ - //xMicrelDevice.ul_had_intn_interrupt = 1; - if( xTransmitHandle != NULL ) - { - xTaskNotifyGive( xTransmitHandle ); - } -#warning moved downward - /* RX step13: enable INT_RX flag. */ - ksz8851_reg_write( REG_INT_MASK, INT_RX ); - /* Prevent the EMAC task from sleeping a single time. */ - ulISREvents |= EMAC_IF_TX_EVENT; - } /* case SPI_PDC_TX_COMPLETE */ - break; - } /* switch( xMicrelDevice.ul_spi_pdc_status ) */ -} - -/** - * \brief Set up the RX descriptor ring buffers. - * - * This function sets up the descriptor list used for RX packets. - * - */ -static void ksz8851snl_rx_init() -{ - uint32_t ul_index = 0; - - /* Init pointer index. */ - xMicrelDevice.us_rx_head = 0; - xMicrelDevice.us_rx_tail = 0; - - /* Set up the RX descriptors. */ - for (ul_index = 0; ul_index < MICREL_RX_BUFFERS; ul_index++) { - xMicrelDevice.rx_buffers[ul_index] = NULL; - xMicrelDevice.rx_ready[ul_index] = pdFALSE; - } - - /* Build RX buffer and descriptors. */ - ksz8851snl_rx_populate_queue(); -} - -/** - * \brief Set up the TX descriptor ring buffers. - * - * This function sets up the descriptor list used for TX packets. - * - */ -static void ksz8851snl_tx_init() -{ - uint32_t ul_index = 0; - - /* Init TX index pointer. */ - xMicrelDevice.us_tx_head = 0; - xMicrelDevice.us_tx_tail = 0; - - /* Set up the TX descriptors */ - for( ul_index = 0; ul_index < MICREL_TX_BUFFERS; ul_index++ ) - { - xMicrelDevice.tx_busy[ul_index] = pdFALSE; - } - xMicrelDevice.tx_space = 6144; -} - -/** - * \brief Initialize ksz8851snl ethernet controller. - * - * \note Called from ethernetif_init(). - * - * \param netif the lwIP network interface structure for this ethernetif. - */ -static void ksz8851snl_low_level_init( void ) -{ - ksz8851snl_rx_init(); - ksz8851snl_tx_init(); - - /* Enable NVIC interrupts. */ - NVIC_SetPriority(SPI_IRQn, INT_PRIORITY_SPI); - NVIC_EnableIRQ(SPI_IRQn); - - /* Initialize SPI link. */ - if( ksz8851snl_init() < 0 ) - { - FreeRTOS_printf( ( "ksz8851snl_low_level_init: failed to initialize the Micrel driver!\n" ) ); - configASSERT(0 == 1); - } - memset( xMicrelDevice.pusHashTable, 255, sizeof( xMicrelDevice.pusHashTable ) ); - ksz8851_reg_write( REG_MAC_HASH_0, FreeRTOS_htons( xMicrelDevice.pusHashTable[ 0 ] ) ); - ksz8851_reg_write( REG_MAC_HASH_2, FreeRTOS_htons( xMicrelDevice.pusHashTable[ 1 ] ) ); - ksz8851_reg_write( REG_MAC_HASH_4, FreeRTOS_htons( xMicrelDevice.pusHashTable[ 2 ] ) ); - ksz8851_reg_write( REG_MAC_HASH_6, FreeRTOS_htons( xMicrelDevice.pusHashTable[ 3 ] ) ); - - /* Initialize interrupt line INTN. */ - configure_intn( INTN_Handler ); -} - -/** - * \brief Use pre-allocated pbuf as DMA source and return the incoming packet. - * - * \param netif the lwIP network interface structure for this ethernetif. - * - * \return a pbuf filled with the received packet (including MAC header). - * 0 on memory error. - */ -static NetworkBufferDescriptor_t *ksz8851snl_low_level_input( void ) -{ -NetworkBufferDescriptor_t *pxNetworkBuffer = NULL; -int rxTail = xMicrelDevice.us_rx_tail; - - /* Check that descriptor is owned by software (ie packet received). */ - if( xMicrelDevice.rx_ready[ rxTail ] != pdFALSE ) - { - - /* Fetch pre-allocated buffer */ - pxNetworkBuffer = xMicrelDevice.rx_buffers[ rxTail ]; - - /* Remove this pbuf from its descriptor. */ - xMicrelDevice.rx_buffers[ rxTail ] = NULL; - - /* Clears rx_ready and sets rx_buffers. */ - ksz8851snl_rx_populate_queue(); - - if( ++rxTail == MICREL_RX_BUFFERS ) - { - rxTail = 0; - } - xMicrelDevice.us_rx_tail = rxTail; - } - - return pxNetworkBuffer; -} -/*-----------------------------------------------------------*/ - -static uint32_t prvEMACRxPoll( void ) -{ -NetworkBufferDescriptor_t *pxNetworkBuffer; -IPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL }; -uint32_t ulReturnValue = 0; - - for( ;; ) - { - /* Only for logging. */ - int rxTail = xMicrelDevice.us_rx_tail; - EthernetHeader_t *pxEthernetHeader; - - pxNetworkBuffer = ksz8851snl_low_level_input(); - - if( pxNetworkBuffer == NULL ) - { - break; - } - pxEthernetHeader = ( EthernetHeader_t * ) ( pxNetworkBuffer->pucEthernetBuffer ); - - if( ( pxEthernetHeader->usFrameType != ipIPv4_FRAME_TYPE ) && - ( pxEthernetHeader->usFrameType != ipARP_FRAME_TYPE ) ) - { - FreeRTOS_printf( ( "Frame type %02X received\n", pxEthernetHeader->usFrameType ) ); - } - ulReturnValue++; - - xRxEvent.pvData = ( void * )pxNetworkBuffer; - /* Send the descriptor to the IP task for processing. */ - if( xSendEventStructToIPTask( &xRxEvent, 100UL ) != pdTRUE ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - iptraceETHERNET_RX_EVENT_LOST(); - FreeRTOS_printf( ( "prvEMACRxPoll: Can not queue return packet!\n" ) ); - } - } - - return ulReturnValue; -} -/*-----------------------------------------------------------*/ - -static void prvEMACHandlerTask( void *pvParameters ) -{ -TimeOut_t xPhyTime; -TickType_t xPhyRemTime; -TickType_t xLoggingTime; -UBaseType_t uxLastMinBufferCount = 0; -UBaseType_t uxCurrentCount; -BaseType_t xResult = 0; -uint32_t xStatus; -const TickType_t ulMaxBlockTime = pdMS_TO_TICKS( EMAC_MAX_BLOCK_TIME_MS ); -#if( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - UBaseType_t uxLastMinQueueSpace = 0; -#endif - - /* Remove compiler warnings about unused parameters. */ - ( void ) pvParameters; - - configASSERT( xEMACTaskHandle ); - - vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); - xLoggingTime = xTaskGetTickCount(); - - for( ;; ) - { - uxCurrentCount = uxGetMinimumFreeNetworkBuffers(); - if( uxLastMinBufferCount != uxCurrentCount ) - { - /* The logging produced below may be helpful - while tuning +TCP: see how many buffers are in use. */ - uxLastMinBufferCount = uxCurrentCount; - FreeRTOS_printf( ( "Network buffers: %lu lowest %lu\n", - uxGetNumberOfFreeNetworkBuffers(), uxCurrentCount ) ); - } - - #if( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - { - uxCurrentCount = uxGetMinimumIPQueueSpace(); - if( uxLastMinQueueSpace != uxCurrentCount ) - { - /* The logging produced below may be helpful - while tuning +TCP: see how many buffers are in use. */ - uxLastMinQueueSpace = uxCurrentCount; - FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); - } - } - #endif /* ipconfigCHECK_IP_QUEUE_SPACE */ - - /* Run the state-machine of the ksz8851 driver. */ - ksz8851snl_update(); - - if( ( ulISREvents & EMAC_IF_ALL_EVENT ) == 0 ) - { - /* No events to process now, wait for the next. */ - ulTaskNotifyTake( pdTRUE, ulMaxBlockTime ); - } - - if( ( xTaskGetTickCount() - xLoggingTime ) > 10000 ) - { - xLoggingTime += 10000; - FreeRTOS_printf( ( "Now Tx/Rx %7d /%7d\n", - xMicrelDevice.ul_total_tx, xMicrelDevice.ul_total_rx ) ); - } - - if( ( ulISREvents & EMAC_IF_RX_EVENT ) != 0 ) - { - ulISREvents &= ~EMAC_IF_RX_EVENT; - - /* Wait for the EMAC interrupt to indicate that another packet has been - received. */ - xResult = prvEMACRxPoll(); - } - - if( ( ulISREvents & EMAC_IF_TX_EVENT ) != 0 ) - { - /* Future extension: code to release TX buffers if zero-copy is used. */ - ulISREvents &= ~EMAC_IF_TX_EVENT; - } - - if( ( ulISREvents & EMAC_IF_ERR_EVENT ) != 0 ) - { - /* Future extension: logging about errors that occurred. */ - ulISREvents &= ~EMAC_IF_ERR_EVENT; - } - - if( xResult > 0 ) - { - /* As long as packets are being received, assume that - the Link Status is high. */ - ulPHYLinkStatus |= BMSR_LINK_STATUS; - /* A packet was received. No need to check for the PHY status now, - but set a timer to check it later on. */ - vTaskSetTimeOutState( &xPhyTime ); - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); - xResult = 0; - } - else if( ( xTaskCheckForTimeOut( &xPhyTime, &xPhyRemTime ) != pdFALSE ) && - ( xMicrelDevice.ul_spi_pdc_status == SPI_PDC_IDLE ) ) - { - /* Check the link status again. */ - xStatus = ulReadMDIO( PHY_REG_01_BMSR ); - - if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != ( xStatus & BMSR_LINK_STATUS ) ) - { - ulPHYLinkStatus = xStatus; - FreeRTOS_printf( ( "prvEMACHandlerTask: PHY LS now %d\n", ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) ); - } - - vTaskSetTimeOutState( &xPhyTime ); - if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) - { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS ); - } - else - { - xPhyRemTime = pdMS_TO_TICKS( PHY_LS_LOW_CHECK_TIME_MS ); - } - } - } -} -/*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ksz8851snl/ksz8851snl.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ksz8851snl/ksz8851snl.c deleted file mode 100755 index 9a4001c..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ksz8851snl/ksz8851snl.c +++ /dev/null @@ -1,610 +0,0 @@ -/** - * - * \file - * - * \brief KS8851SNL driver for SAM. - * - * Copyright (c) 2013-2015 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -/* - * Support and FAQ: visit Atmel Support - */ - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" - -#include "spi_master.h" -#include "ksz8851snl.h" -#include "ksz8851snl_reg.h" -#include "delay.h" -#include "pio.h" -#include "pio_handler.h" -#include "pdc.h" -#include "conf_eth.h" - -/* Clock polarity. */ -#define SPI_CLK_POLARITY 0 - -/* Clock phase. */ -#define SPI_CLK_PHASE 1 - -/* SPI PDC register base. */ -Pdc *g_p_spi_pdc = 0; - -int lUDPLoggingPrintf( const char *pcFormatString, ... ); - -/* Temporary buffer for PDC reception. */ -uint8_t tmpbuf[1536] __attribute__ ((aligned (16))); - -union { - uint64_t ul[2]; - uint8_t uc[16]; -} cmdBuf, respBuf; - -void dbg_add_line( const char *pcFormat, ... ); - -static void spi_clear_ovres( void ); - -/** - * \brief Read register content, set bitmask and write back to register. - * - * \param reg the register address to modify. - * \param bits_to_set bitmask to apply. - */ -void ksz8851_reg_setbits(uint16_t reg, uint16_t bits_to_set) -{ - uint16_t temp; - - temp = ksz8851_reg_read(reg); - temp |= bits_to_set; - ksz8851_reg_write(reg, temp); -} - -/** - * \brief Read register content, clear bitmask and write back to register. - * - * \param reg the register address to modify. - * \param bits_to_set bitmask to apply. - */ -void ksz8851_reg_clrbits(uint16_t reg, uint16_t bits_to_clr) -{ - uint16_t temp; - - temp = ksz8851_reg_read(reg); - temp &= ~(uint32_t) bits_to_clr; - ksz8851_reg_write(reg, temp); -} - -/** - * \brief Configure the INTN interrupt. - */ -void configure_intn(void (*p_handler) (uint32_t, uint32_t)) -{ -// gpio_configure_pin(KSZ8851SNL_INTN_GPIO, PIO_INPUT); -// pio_set_input(PIOA, PIO_PA11_IDX, PIO_PULLUP); - - /* Configure PIO clock. */ - pmc_enable_periph_clk(INTN_ID); - - /* Adjust PIO debounce filter parameters, uses 10 Hz filter. */ - pio_set_debounce_filter(INTN_PIO, INTN_PIN_MSK, 10); - - /* Initialize PIO interrupt handlers, see PIO definition in board.h. */ - pio_handler_set(INTN_PIO, INTN_ID, INTN_PIN_MSK, - INTN_ATTR, p_handler); - - /* Enable NVIC interrupts. */ - NVIC_SetPriority(INTN_IRQn, INT_PRIORITY_PIO); - NVIC_EnableIRQ((IRQn_Type)INTN_ID); - - /* Enable PIO interrupts. */ - pio_enable_interrupt(INTN_PIO, INTN_PIN_MSK); -} - -/** - * \brief Read a register value. - * - * \param reg the register address to modify. - * - * \return the register value. - */ -uint16_t ksz8851_reg_read(uint16_t reg) -{ -pdc_packet_t g_pdc_spi_tx_packet; -pdc_packet_t g_pdc_spi_rx_packet; -uint16_t cmd = 0; -uint16_t res = 0; -int iTryCount = 3; - - while( iTryCount-- > 0 ) - { - uint32_t ulStatus; - - spi_clear_ovres(); - /* Move register address to cmd bits 9-2, make 32-bit address. */ - cmd = (reg << 2) & REG_ADDR_MASK; - - /* Last 2 bits still under "don't care bits" handled with byte enable. */ - /* Select byte enable for command. */ - if (reg & 2) { - /* Odd word address writes bytes 2 and 3 */ - cmd |= (0xc << 10); - } else { - /* Even word address write bytes 0 and 1 */ - cmd |= (0x3 << 10); - } - - /* Add command read code. */ - cmd |= CMD_READ; - cmdBuf.uc[0] = cmd >> 8; - cmdBuf.uc[1] = cmd & 0xff; - cmdBuf.uc[2] = CONFIG_SPI_MASTER_DUMMY; - cmdBuf.uc[3] = CONFIG_SPI_MASTER_DUMMY; - - /* Prepare PDC transfer. */ - g_pdc_spi_tx_packet.ul_addr = (uint32_t) cmdBuf.uc; - g_pdc_spi_tx_packet.ul_size = 4; - g_pdc_spi_rx_packet.ul_addr = (uint32_t) tmpbuf; - g_pdc_spi_rx_packet.ul_size = 4; - pdc_disable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTDIS | PERIPH_PTCR_TXTDIS); - pdc_tx_init(g_p_spi_pdc, &g_pdc_spi_tx_packet, NULL); - pdc_rx_init(g_p_spi_pdc, &g_pdc_spi_rx_packet, NULL); - gpio_set_pin_low(KSZ8851SNL_CSN_GPIO); - - spi_disable_interrupt( KSZ8851SNL_SPI, ~0ul ); - pdc_enable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTEN | PERIPH_PTCR_TXTEN); - for( ;; ) - { - ulStatus = spi_read_status( KSZ8851SNL_SPI ); - if( ( ulStatus & ( SPI_SR_OVRES | SPI_SR_ENDRX ) ) != 0 ) - { - break; - } - } - gpio_set_pin_high( KSZ8851SNL_CSN_GPIO ); - if( ( ulStatus & SPI_SR_OVRES ) == 0 ) - { - break; - } - pdc_disable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTDIS | PERIPH_PTCR_TXTDIS); - lUDPLoggingPrintf( "ksz8851_reg_read: SPI_SR_OVRES\n" ); - } - - res = (tmpbuf[3] << 8) | tmpbuf[2]; - return res; -} - -/** - * \brief Write a register value. - * - * \param reg the register address to modify. - * \param wrdata the new register value. - */ -void ksz8851_reg_write(uint16_t reg, uint16_t wrdata) -{ -pdc_packet_t g_pdc_spi_tx_packet; -pdc_packet_t g_pdc_spi_rx_packet; -uint16_t cmd = 0; -int iTryCount = 3; - - while( iTryCount-- > 0 ) - { - uint32_t ulStatus; - - - spi_clear_ovres(); - /* Move register address to cmd bits 9-2, make 32-bit address. */ - cmd = (reg << 2) & REG_ADDR_MASK; - - /* Last 2 bits still under "don't care bits" handled with byte enable. */ - /* Select byte enable for command. */ - if (reg & 2) { - /* Odd word address writes bytes 2 and 3 */ - cmd |= (0xc << 10); - } else { - /* Even word address write bytes 0 and 1 */ - cmd |= (0x3 << 10); - } - - /* Add command write code. */ - cmd |= CMD_WRITE; - cmdBuf.uc[0] = cmd >> 8; - cmdBuf.uc[1] = cmd & 0xff; - cmdBuf.uc[2] = wrdata & 0xff; - cmdBuf.uc[3] = wrdata >> 8; - - /* Prepare PDC transfer. */ - g_pdc_spi_tx_packet.ul_addr = (uint32_t) cmdBuf.uc; - g_pdc_spi_tx_packet.ul_size = 4; - g_pdc_spi_rx_packet.ul_addr = (uint32_t) tmpbuf; - g_pdc_spi_rx_packet.ul_size = 4; - pdc_disable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTDIS | PERIPH_PTCR_TXTDIS); - pdc_tx_init(g_p_spi_pdc, &g_pdc_spi_tx_packet, NULL); - pdc_rx_init(g_p_spi_pdc, &g_pdc_spi_rx_packet, NULL); - gpio_set_pin_low(KSZ8851SNL_CSN_GPIO); - - spi_disable_interrupt( KSZ8851SNL_SPI, ~0ul ); - - pdc_enable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTEN | PERIPH_PTCR_TXTEN); - for( ;; ) - { - ulStatus = spi_read_status( KSZ8851SNL_SPI ); - if( ( ulStatus & ( SPI_SR_OVRES | SPI_SR_ENDRX ) ) != 0 ) - { - break; - } - } - gpio_set_pin_high( KSZ8851SNL_CSN_GPIO ); - if( ( ulStatus & SPI_SR_OVRES ) == 0 ) - { - break; - } - pdc_disable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTDIS | PERIPH_PTCR_TXTDIS); - lUDPLoggingPrintf( "ksz8851_reg_write: SPI_SR_OVRES\n" ); - } -} - -static void spi_clear_ovres( void ) -{ -volatile uint32_t rc; - rc = KSZ8851SNL_SPI->SPI_RDR; - - spi_read_status( KSZ8851SNL_SPI ); -} - -/** - * \brief Read internal fifo buffer. - * - * \param buf the buffer to store the data from the fifo buffer. - * \param len the amount of data to read. - */ -void ksz8851_fifo_read(uint8_t *buf, uint32_t len) -{ - pdc_packet_t g_pdc_spi_tx_packet; - pdc_packet_t g_pdc_spi_rx_packet; - pdc_packet_t g_pdc_spi_tx_npacket; - pdc_packet_t g_pdc_spi_rx_npacket; - - memset( cmdBuf.uc, '\0', sizeof cmdBuf ); - cmdBuf.uc[0] = FIFO_READ; - spi_clear_ovres(); - - /* Prepare PDC transfer. */ - g_pdc_spi_tx_packet.ul_addr = (uint32_t) cmdBuf.uc; - g_pdc_spi_tx_packet.ul_size = 9; - g_pdc_spi_rx_packet.ul_addr = (uint32_t) respBuf.uc; - g_pdc_spi_rx_packet.ul_size = 9; - - g_pdc_spi_tx_npacket.ul_addr = (uint32_t) buf; - g_pdc_spi_tx_npacket.ul_size = len; - g_pdc_spi_rx_npacket.ul_addr = (uint32_t) buf; - g_pdc_spi_rx_npacket.ul_size = len; - pdc_disable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTDIS | PERIPH_PTCR_TXTDIS); - pdc_tx_init(g_p_spi_pdc, &g_pdc_spi_tx_packet, &g_pdc_spi_tx_npacket); - pdc_rx_init(g_p_spi_pdc, &g_pdc_spi_rx_packet, &g_pdc_spi_rx_npacket); - -spi_enable_interrupt(KSZ8851SNL_SPI, SPI_IER_RXBUFF | SPI_IER_OVRES); - - pdc_enable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTEN | PERIPH_PTCR_TXTEN); -} - -/** - * \brief Write internal fifo buffer. - * - * \param buf the buffer to send to the fifo buffer. - * \param ulActualLength the total amount of data to write. - * \param ulFIFOLength the size of the first pbuf to write from the pbuf chain. - */ -void ksz8851_fifo_write(uint8_t *buf, uint32_t ulActualLength, uint32_t ulFIFOLength) -{ - static uint8_t frameID = 0; - - pdc_packet_t g_pdc_spi_tx_packet; - pdc_packet_t g_pdc_spi_rx_packet; - pdc_packet_t g_pdc_spi_tx_npacket; - pdc_packet_t g_pdc_spi_rx_npacket; - - /* Prepare control word and byte count. */ - cmdBuf.uc[0] = FIFO_WRITE; - cmdBuf.uc[1] = frameID++ & 0x3f; - cmdBuf.uc[2] = 0; - cmdBuf.uc[3] = ulActualLength & 0xff; - cmdBuf.uc[4] = ulActualLength >> 8; - - spi_clear_ovres(); - - /* Prepare PDC transfer. */ - g_pdc_spi_tx_packet.ul_addr = (uint32_t) cmdBuf.uc; - g_pdc_spi_tx_packet.ul_size = 5; - - g_pdc_spi_rx_packet.ul_addr = (uint32_t) respBuf.uc; - g_pdc_spi_rx_packet.ul_size = 5; - - g_pdc_spi_tx_npacket.ul_addr = (uint32_t) buf; - g_pdc_spi_tx_npacket.ul_size = ulFIFOLength; - - g_pdc_spi_rx_npacket.ul_addr = (uint32_t) tmpbuf; - g_pdc_spi_rx_npacket.ul_size = ulFIFOLength; - - pdc_disable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTDIS | PERIPH_PTCR_TXTDIS); - pdc_tx_init(g_p_spi_pdc, &g_pdc_spi_tx_packet, &g_pdc_spi_tx_npacket); - #if( TX_USES_RECV == 1 ) - pdc_rx_init(g_p_spi_pdc, &g_pdc_spi_rx_packet, &g_pdc_spi_rx_npacket); - spi_enable_interrupt(KSZ8851SNL_SPI, SPI_IER_ENDRX | SPI_IER_OVRES); - pdc_enable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTEN | PERIPH_PTCR_TXTEN); - #else - spi_enable_interrupt(KSZ8851SNL_SPI, SPI_SR_TXBUFE | SPI_IER_OVRES); - pdc_enable_transfer(g_p_spi_pdc, PERIPH_PTCR_TXTEN); - #endif -} - -/** - * \brief Write dummy data to the internal fifo buffer. - * - * \param len the amount of dummy data to write. - */ -void ksz8851_fifo_dummy(uint32_t len) -{ - pdc_packet_t g_pdc_spi_tx_packet; - pdc_packet_t g_pdc_spi_rx_packet; - - /* Prepare PDC transfer. */ - g_pdc_spi_tx_packet.ul_addr = (uint32_t) tmpbuf; - g_pdc_spi_tx_packet.ul_size = len; - g_pdc_spi_rx_packet.ul_addr = (uint32_t) tmpbuf; - g_pdc_spi_rx_packet.ul_size = len; - pdc_disable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTDIS | PERIPH_PTCR_TXTDIS); - pdc_tx_init(g_p_spi_pdc, &g_pdc_spi_tx_packet, NULL); - pdc_rx_init(g_p_spi_pdc, &g_pdc_spi_rx_packet, NULL); - pdc_enable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTEN | PERIPH_PTCR_TXTEN); - - while (!(spi_read_status(KSZ8851SNL_SPI) & SPI_SR_ENDRX)) - ; -} - -void ksz8851snl_set_registers(void) -{ - /* Init step2-4: write QMU MAC address (low, middle then high). */ - ksz8851_reg_write(REG_MAC_ADDR_0, (ETHERNET_CONF_ETHADDR4 << 8) | ETHERNET_CONF_ETHADDR5); - ksz8851_reg_write(REG_MAC_ADDR_2, (ETHERNET_CONF_ETHADDR2 << 8) | ETHERNET_CONF_ETHADDR3); - ksz8851_reg_write(REG_MAC_ADDR_4, (ETHERNET_CONF_ETHADDR0 << 8) | ETHERNET_CONF_ETHADDR1); - - /* Init step5: enable QMU Transmit Frame Data Pointer Auto Increment. */ - ksz8851_reg_write(REG_TX_ADDR_PTR, ADDR_PTR_AUTO_INC); - - /* Init step6: configure QMU transmit control register. */ - ksz8851_reg_write(REG_TX_CTRL, - TX_CTRL_ICMP_CHECKSUM | - TX_CTRL_UDP_CHECKSUM | - TX_CTRL_TCP_CHECKSUM | - TX_CTRL_IP_CHECKSUM | - TX_CTRL_FLOW_ENABLE | - TX_CTRL_PAD_ENABLE | - TX_CTRL_CRC_ENABLE - ); - - /* Init step7: enable QMU Receive Frame Data Pointer Auto Increment. */ - ksz8851_reg_write(REG_RX_ADDR_PTR, ADDR_PTR_AUTO_INC); - - /* Init step8: configure QMU Receive Frame Threshold for one frame. */ - ksz8851_reg_write(REG_RX_FRAME_CNT_THRES, 1); - - /* Init step9: configure QMU receive control register1. */ - ksz8851_reg_write(REG_RX_CTRL1, - RX_CTRL_UDP_CHECKSUM | - RX_CTRL_TCP_CHECKSUM | - RX_CTRL_IP_CHECKSUM | - RX_CTRL_MAC_FILTER | - RX_CTRL_FLOW_ENABLE | - RX_CTRL_BROADCAST | - RX_CTRL_ALL_MULTICAST| - RX_CTRL_UNICAST); -// ksz8851_reg_write(REG_RX_CTRL1, -// RX_CTRL_UDP_CHECKSUM | -// RX_CTRL_TCP_CHECKSUM | -// RX_CTRL_IP_CHECKSUM | -// RX_CTRL_FLOW_ENABLE | -// RX_CTRL_PROMISCUOUS); - - ksz8851_reg_write(REG_RX_CTRL2, - RX_CTRL_IPV6_UDP_NOCHECKSUM | - RX_CTRL_UDP_LITE_CHECKSUM | - RX_CTRL_ICMP_CHECKSUM | - RX_CTRL_BURST_LEN_FRAME); - - -//#define RXQ_TWOBYTE_OFFSET (0x0200) /* Enable adding 2-byte before frame header for IP aligned with DWORD */ -#warning Remember to try the above option to get a 2-byte offset - - /* Init step11: configure QMU receive queue: trigger INT and auto-dequeue frame. */ - ksz8851_reg_write( REG_RXQ_CMD, RXQ_CMD_CNTL | RXQ_TWOBYTE_OFFSET ); - - /* Init step12: adjust SPI data output delay. */ - ksz8851_reg_write(REG_BUS_CLOCK_CTRL, BUS_CLOCK_166 | BUS_CLOCK_DIVIDEDBY_1); - - /* Init step13: restart auto-negotiation. */ - ksz8851_reg_setbits(REG_PORT_CTRL, PORT_AUTO_NEG_RESTART); - - /* Init step13.1: force link in half duplex if auto-negotiation failed. */ - if ((ksz8851_reg_read(REG_PORT_CTRL) & PORT_AUTO_NEG_RESTART) != PORT_AUTO_NEG_RESTART) - { - ksz8851_reg_clrbits(REG_PORT_CTRL, PORT_FORCE_FULL_DUPLEX); - } - - /* Init step14: clear interrupt status. */ - ksz8851_reg_write(REG_INT_STATUS, 0xFFFF); - - /* Init step15: set interrupt mask. */ - ksz8851_reg_write(REG_INT_MASK, INT_RX); - - /* Init step16: enable QMU Transmit. */ - ksz8851_reg_setbits(REG_TX_CTRL, TX_CTRL_ENABLE); - - /* Init step17: enable QMU Receive. */ - ksz8851_reg_setbits(REG_RX_CTRL1, RX_CTRL_ENABLE); -} -/** - * \brief KSZ8851SNL initialization function. - * - * \return 0 on success, 1 on communication error. - */ -uint32_t ksz8851snl_init(void) -{ -uint32_t count = 10; -uint16_t dev_id = 0; -uint8_t id_ok = 0; - - /* Configure the SPI peripheral. */ - spi_enable_clock(KSZ8851SNL_SPI); - spi_disable(KSZ8851SNL_SPI); - spi_reset(KSZ8851SNL_SPI); - spi_set_master_mode(KSZ8851SNL_SPI); - spi_disable_mode_fault_detect(KSZ8851SNL_SPI); - spi_set_peripheral_chip_select_value(KSZ8851SNL_SPI, ~(uint32_t)(1UL << KSZ8851SNL_CS_PIN)); -spi_set_fixed_peripheral_select(KSZ8851SNL_SPI); -//spi_disable_peripheral_select_decode(KSZ8851SNL_SPI); - - spi_set_clock_polarity(KSZ8851SNL_SPI, KSZ8851SNL_CS_PIN, SPI_CLK_POLARITY); - spi_set_clock_phase(KSZ8851SNL_SPI, KSZ8851SNL_CS_PIN, SPI_CLK_PHASE); - spi_set_bits_per_transfer(KSZ8851SNL_SPI, KSZ8851SNL_CS_PIN, - SPI_CSR_BITS_8_BIT); - spi_set_baudrate_div(KSZ8851SNL_SPI, KSZ8851SNL_CS_PIN, (sysclk_get_cpu_hz() / KSZ8851SNL_CLOCK_SPEED)); -// spi_set_transfer_delay(KSZ8851SNL_SPI, KSZ8851SNL_CS_PIN, CONFIG_SPI_MASTER_DELAY_BS, -// CONFIG_SPI_MASTER_DELAY_BCT); - - - spi_set_transfer_delay(KSZ8851SNL_SPI, KSZ8851SNL_CS_PIN, 0, 0); - - spi_enable(KSZ8851SNL_SPI); - - /* Get pointer to UART PDC register base. */ - g_p_spi_pdc = spi_get_pdc_base(KSZ8851SNL_SPI); - pdc_enable_transfer(g_p_spi_pdc, PERIPH_PTCR_RXTEN | PERIPH_PTCR_TXTEN); - - /* Control RSTN and CSN pin from the driver. */ - gpio_configure_pin(KSZ8851SNL_CSN_GPIO, KSZ8851SNL_CSN_FLAGS); - gpio_set_pin_high(KSZ8851SNL_CSN_GPIO); - gpio_configure_pin(KSZ8851SNL_RSTN_GPIO, KSZ8851SNL_RSTN_FLAGS); - - /* Reset the Micrel in a proper state. */ - while( count-- ) - { - /* Perform hardware reset with respect to the reset timing from the datasheet. */ - gpio_set_pin_low(KSZ8851SNL_RSTN_GPIO); - vTaskDelay(2); - gpio_set_pin_high(KSZ8851SNL_RSTN_GPIO); - vTaskDelay(2); - - /* Init step1: read chip ID. */ - dev_id = ksz8851_reg_read(REG_CHIP_ID); - if( ( dev_id & 0xFFF0 ) == CHIP_ID_8851_16 ) - { - id_ok = 1; - break; - } - } - if( id_ok != 0 ) - { - ksz8851snl_set_registers(); - } - - return id_ok ? 1 : -1; -} - -uint32_t ksz8851snl_reinit(void) -{ -uint32_t count = 10; -uint16_t dev_id = 0; -uint8_t id_ok = 0; - /* Reset the Micrel in a proper state. */ - while( count-- ) - { - /* Perform hardware reset with respect to the reset timing from the datasheet. */ - gpio_set_pin_low(KSZ8851SNL_RSTN_GPIO); - vTaskDelay(2); - gpio_set_pin_high(KSZ8851SNL_RSTN_GPIO); - vTaskDelay(2); - - /* Init step1: read chip ID. */ - dev_id = ksz8851_reg_read(REG_CHIP_ID); - if( ( dev_id & 0xFFF0 ) == CHIP_ID_8851_16 ) - { - id_ok = 1; - break; - } - } - if( id_ok != 0 ) - { - ksz8851snl_set_registers(); - } - - return id_ok ? 1 : -1; -} - -uint32_t ksz8851snl_reset_rx( void ) -{ -uint16_t usValue; - - usValue = ksz8851_reg_read(REG_RX_CTRL1); - - usValue &= ~( ( uint16_t ) RX_CTRL_ENABLE | RX_CTRL_FLUSH_QUEUE ); - - ksz8851_reg_write( REG_RX_CTRL1, usValue ); vTaskDelay( 2 ); - ksz8851_reg_write( REG_RX_CTRL1, usValue | RX_CTRL_FLUSH_QUEUE ); vTaskDelay( 1 ); - ksz8851_reg_write( REG_RX_CTRL1, usValue ); vTaskDelay( 1 ); - ksz8851_reg_write( REG_RX_CTRL1, usValue | RX_CTRL_ENABLE ); vTaskDelay( 1 ); - - return ( uint32_t )usValue; -} - -uint32_t ksz8851snl_reset_tx( void ) -{ -uint16_t usValue; - - usValue = ksz8851_reg_read( REG_TX_CTRL ); - - usValue &= ~( ( uint16_t ) TX_CTRL_ENABLE | TX_CTRL_FLUSH_QUEUE ); - - ksz8851_reg_write( REG_TX_CTRL, usValue ); vTaskDelay( 2 ); - ksz8851_reg_write( REG_TX_CTRL, usValue | TX_CTRL_FLUSH_QUEUE ); vTaskDelay( 1 ); - ksz8851_reg_write( REG_TX_CTRL, usValue ); vTaskDelay( 1 ); - ksz8851_reg_write( REG_TX_CTRL, usValue | TX_CTRL_ENABLE ); vTaskDelay( 1 ); - - return ( uint32_t )usValue; -} diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ksz8851snl/ksz8851snl.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ksz8851snl/ksz8851snl.h deleted file mode 100755 index 30b1cc5..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ksz8851snl/ksz8851snl.h +++ /dev/null @@ -1,67 +0,0 @@ -/** - * - * \file - * - * \brief KS8851SNL driver for SAM. - * - * Copyright (c) 2013-2015 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -/* - * Support and FAQ: visit Atmel Support - */ - -#ifndef KSZ8851SNL_H_INCLUDED -#define KSZ8851SNL_H_INCLUDED - -#include "gpio.h" - -void configure_intn(void (*p_handler) (uint32_t, uint32_t)); -void ksz8851_reg_setbits(uint16_t reg, uint16_t bits_to_set); -void ksz8851_reg_clrbits(uint16_t reg, uint16_t bits_to_clr); -void ksz8851_fifo_read(uint8_t *buf, uint32_t len); -void ksz8851_fifo_write(uint8_t *buf, uint32_t ulActualLength, uint32_t ulFIFOLength); -void ksz8851_fifo_dummy(uint32_t len); -void ksz8851_reg_write(uint16_t reg, uint16_t wrdata); -uint16_t ksz8851_reg_read(uint16_t reg); -uint32_t ksz8851snl_init(void); -uint32_t ksz8851snl_reinit(void); - -uint32_t ksz8851snl_reset_rx( void ); -uint32_t ksz8851snl_reset_tx( void ); - -#endif /* KSZ8851SNL_H_INCLUDED */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ksz8851snl/ksz8851snl_reg.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ksz8851snl/ksz8851snl_reg.h deleted file mode 100755 index 58ce6b0..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ksz8851snl/ksz8851snl_reg.h +++ /dev/null @@ -1,473 +0,0 @@ -/** - * - * \file - * - * \brief KS8851SNL registers definitions. - * - * Copyright (c) 2013-2015 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * \asf_license_stop - * - */ -/* - * Support and FAQ: visit Atmel Support - */ - -#ifndef KSZ8851SNL_REG_H_INCLUDED -#define KSZ8851SNL_REG_H_INCLUDED - -#define REG_ADDR_MASK (0x3F0) /* Register address mask */ -#define OPCODE_MASK (3 << 14) -#define CMD_READ (0 << 14) -#define CMD_WRITE (1 << 14) -#define FIFO_READ (0x80) -#define FIFO_WRITE (0xC0) - -/* - * MAC Registers - * (Offset 0x00 - 0x25) - */ -#define REG_BUS_ERROR_STATUS (0x06) /* BESR */ -#define BUS_ERROR_IBEC (0x8000) -#define BUS_ERROR_IBECV_MASK (0x7800) /* Default IPSec clock at 166Mhz */ - -#define REG_CHIP_CFG_STATUS (0x08) /* CCFG */ -#define LITTLE_ENDIAN_BUS_MODE (0x0400) /* Bus in little endian mode */ -#define EEPROM_PRESENCE (0x0200) /* External EEPROM is used */ -#define SPI_BUS_MODE (0x0100) /* In SPI bus mode */ -#define DATA_BUS_8BIT (0x0080) /* In 8-bit bus mode operation */ -#define DATA_BUS_16BIT (0x0040) /* In 16-bit bus mode operation */ -#define DATA_BUS_32BIT (0x0020) /* In 32-bit bus mode operation */ -#define MULTIPLEX_MODE (0x0010) /* Data and address bus are shared */ -#define CHIP_PACKAGE_128PIN (0x0008) /* 128-pin package */ -#define CHIP_PACKAGE_80PIN (0x0004) /* 80-pin package */ -#define CHIP_PACKAGE_48PIN (0x0002) /* 48-pin package */ -#define CHIP_PACKAGE_32PIN (0x0001) /* 32-pin package for SPI host interface only */ - -#define REG_MAC_ADDR_0 (0x10) /* MARL */ -#define REG_MAC_ADDR_1 (0x11) /* MARL */ -#define REG_MAC_ADDR_2 (0x12) /* MARM */ -#define REG_MAC_ADDR_3 (0x13) /* MARM */ -#define REG_MAC_ADDR_4 (0x14) /* MARH */ -#define REG_MAC_ADDR_5 (0x15) /* MARH */ - -#define REG_BUS_CLOCK_CTRL (0x20) /* OBCR */ -#define BUS_CLOCK_166 (0x0004) /* 166 MHz on-chip bus clock (defaul is 125MHz) */ -#define BUS_CLOCK_DIVIDEDBY_5 (0x0003) /* Bus clock devided by 5 */ -#define BUS_CLOCK_DIVIDEDBY_3 (0x0002) /* Bus clock devided by 3 */ -#define BUS_CLOCK_DIVIDEDBY_2 (0x0001) /* Bus clock devided by 2 */ -#define BUS_CLOCK_DIVIDEDBY_1 (0x0000) /* Bus clock devided by 1 */ -#define BUS_CLOCK_DIVIDED_MASK (0x0003) /* Bus clock devider mask */ - -#define BUS_SPEED_166_MHZ (0x0004) /* Set bus speed to 166 MHz */ -#define BUS_SPEED_125_MHZ (0x0000) /* Set bus speed to 125 MHz */ -#define BUS_SPEED_83_MHZ (0x0005) /* Set bus speed to 83 MHz (166/2)*/ -#define BUS_SPEED_62_5_MHZ (0x0001) /* Set bus speed to 62.5 MHz (125/2) */ -#define BUS_SPEED_53_3_MHZ (0x0006) /* Set bus speed to 53.3 MHz (166/3) */ -#define BUS_SPEED_41_7_MHZ (0x0002) /* Set bus speed to 41.67 MHz (125/3) */ -#define BUS_SPEED_33_2_MHZ (0x0007) /* Set bus speed to 33.2 MHz (166/5) */ -#define BUS_SPEED_25_MHZ (0x0003) /* Set bus speed to 25 MHz (125/5) */ - -#define REG_EEPROM_CTRL (0x22) /* EEPCR */ -#define EEPROM_ACCESS_ENABLE (0x0010) /* Enable software to access EEPROM through bit 3 to bit 0 */ -#define EEPROM_DATA_IN (0x0008) /* Data receive from EEPROM (EEDI pin) */ -#define EEPROM_DATA_OUT (0x0004) /* Data transmit to EEPROM (EEDO pin) */ -#define EEPROM_SERIAL_CLOCK (0x0002) /* Serial clock (EESK pin) */ -#define EEPROM_CHIP_SELECT (0x0001) /* EEPROM chip select (EECS pin) */ - -#define REG_MEM_BIST_INFO (0x24) /* MBIR */ -#define TX_MEM_TEST_FINISHED (0x1000) /* TX memeory BIST test finish */ -#define TX_MEM_TEST_FAILED (0x0800) /* TX memory BIST test fail */ -#define TX_MEM_TEST_FAILED_COUNT (0x0700) /* TX memory BIST test fail count */ -#define RX_MEM_TEST_FINISHED (0x0010) /* RX memory BIST test finish */ -#define RX_MEM_TEST_FAILED (0x0008) /* RX memory BIST test fail */ -#define RX_MEM_TEST_FAILED_COUNT (0x0003) /* RX memory BIST test fail count */ - -#define REG_RESET_CTRL (0x26) /* GRR */ -#define QMU_SOFTWARE_RESET (0x0002) /* QMU soft reset (clear TxQ, RxQ) */ -#define GLOBAL_SOFTWARE_RESET (0x0001) /* Global soft reset (PHY, MAC, QMU) */ - -/* - * Wake On Lan Control Registers - * (Offset 0x2A - 0x6B) - */ -#define REG_WOL_CTRL (0x2A) /* WFCR */ -#define WOL_MAGIC_ENABLE (0x0080) /* Enable the magic packet pattern detection */ -#define WOL_FRAME3_ENABLE (0x0008) /* Enable the wake up frame 3 pattern detection */ -#define WOL_FRAME2_ENABLE (0x0004) /* Enable the wake up frame 2 pattern detection */ -#define WOL_FRAME1_ENABLE (0x0002) /* Enable the wake up frame 1 pattern detection */ -#define WOL_FRAME0_ENABLE (0x0001) /* Enable the wake up frame 0 pattern detection */ - -#define REG_WOL_FRAME0_CRC0 (0x30) /* WF0CRC0 */ -#define REG_WOL_FRAME0_CRC1 (0x32) /* WF0CRC1 */ -#define REG_WOL_FRAME0_BYTE_MASK0 (0x34) /* WF0BM0 */ -#define REG_WOL_FRAME0_BYTE_MASK1 (0x36) /* WF0BM1 */ -#define REG_WOL_FRAME0_BYTE_MASK2 (0x38) /* WF0BM2 */ -#define REG_WOL_FRAME0_BYTE_MASK3 (0x3A) /* WF0BM3 */ - -#define REG_WOL_FRAME1_CRC0 (0x40) /* WF1CRC0 */ -#define REG_WOL_FRAME1_CRC1 (0x42) /* WF1CRC1 */ -#define REG_WOL_FRAME1_BYTE_MASK0 (0x44) /* WF1BM0 */ -#define REG_WOL_FRAME1_BYTE_MASK1 (0x46) /* WF1BM1 */ -#define REG_WOL_FRAME1_BYTE_MASK2 (0x48) /* WF1BM2 */ -#define REG_WOL_FRAME1_BYTE_MASK3 (0x4A) /* WF1BM3 */ - -#define REG_WOL_FRAME2_CRC0 (0x50) /* WF2CRC0 */ -#define REG_WOL_FRAME2_CRC1 (0x52) /* WF2CRC1 */ -#define REG_WOL_FRAME2_BYTE_MASK0 (0x54) /* WF2BM0 */ -#define REG_WOL_FRAME2_BYTE_MASK1 (0x56) /* WF2BM1 */ -#define REG_WOL_FRAME2_BYTE_MASK2 (0x58) /* WF2BM2 */ -#define REG_WOL_FRAME2_BYTE_MASK3 (0x5A) /* WF2BM3 */ - -#define REG_WOL_FRAME3_CRC0 (0x60) /* WF3CRC0 */ -#define REG_WOL_FRAME3_CRC1 (0x62) /* WF3CRC1 */ -#define REG_WOL_FRAME3_BYTE_MASK0 (0x64) /* WF3BM0 */ -#define REG_WOL_FRAME3_BYTE_MASK1 (0x66) /* WF3BM1 */ -#define REG_WOL_FRAME3_BYTE_MASK2 (0x68) /* WF3BM2 */ -#define REG_WOL_FRAME3_BYTE_MASK3 (0x6A) /* WF3BM3 */ - -/* - * Transmit/Receive Control Registers - * (Offset 0x70 - 0x9F) - */ - -/* Transmit Frame Header */ -#define REG_QDR_DUMMY (0x00) /* Dummy address to access QMU RxQ, TxQ */ -#define TX_CTRL_INTERRUPT_ON (0x8000) /* Transmit Interrupt on Completion */ - -#define REG_TX_CTRL (0x70) /* TXCR */ -#define TX_CTRL_ICMP_CHECKSUM (0x0100) /* Enable ICMP frame checksum generation */ -#define TX_CTRL_UDP_CHECKSUM (0x0080) /* Enable UDP frame checksum generation */ -#define TX_CTRL_TCP_CHECKSUM (0x0040) /* Enable TCP frame checksum generation */ -#define TX_CTRL_IP_CHECKSUM (0x0020) /* Enable IP frame checksum generation */ -#define TX_CTRL_FLUSH_QUEUE (0x0010) /* Clear transmit queue, reset tx frame pointer */ -#define TX_CTRL_FLOW_ENABLE (0x0008) /* Enable transmit flow control */ -#define TX_CTRL_PAD_ENABLE (0x0004) /* Eanble adding a padding to a packet shorter than 64 bytes */ -#define TX_CTRL_CRC_ENABLE (0x0002) /* Enable adding a CRC to the end of transmit frame */ -#define TX_CTRL_ENABLE (0x0001) /* Enable tranmsit */ - -#define REG_TX_STATUS (0x72) /* TXSR */ -#define TX_STAT_LATE_COL (0x2000) /* Tranmsit late collision occurs */ -#define TX_STAT_MAX_COL (0x1000) /* Tranmsit maximum collision is reached */ -#define TX_FRAME_ID_MASK (0x003F) /* Transmit frame ID mask */ -#define TX_STAT_ERRORS ( TX_STAT_MAX_COL | TX_STAT_LATE_COL ) - -#define REG_RX_CTRL1 (0x74) /* RXCR1 */ -#define RX_CTRL_FLUSH_QUEUE (0x8000) /* Clear receive queue, reset rx frame pointer */ -#define RX_CTRL_UDP_CHECKSUM (0x4000) /* Enable UDP frame checksum verification */ -#define RX_CTRL_TCP_CHECKSUM (0x2000) /* Enable TCP frame checksum verification */ -#define RX_CTRL_IP_CHECKSUM (0x1000) /* Enable IP frame checksum verification */ -#define RX_CTRL_MAC_FILTER (0x0800) /* Receive with address that pass MAC address filtering */ -#define RX_CTRL_FLOW_ENABLE (0x0400) /* Enable receive flow control */ -#define RX_CTRL_BAD_PACKET (0x0200) /* Eanble receive CRC error frames */ -#define RX_CTRL_MULTICAST (0x0100) /* Receive multicast frames that pass the CRC hash filtering */ -#define RX_CTRL_BROADCAST (0x0080) /* Receive all the broadcast frames */ -#define RX_CTRL_ALL_MULTICAST (0x0040) /* Receive all the multicast frames (including broadcast frames) */ -#define RX_CTRL_UNICAST (0x0020) /* Receive unicast frames that match the device MAC address */ -#define RX_CTRL_PROMISCUOUS (0x0010) /* Receive all incoming frames, regardless of frame's DA */ -#define RX_CTRL_STRIP_CRC (0x0008) /* Enable strip CRC on the received frames */ -#define RX_CTRL_INVERSE_FILTER (0x0002) /* Receive with address check in inverse filtering mode */ -#define RX_CTRL_ENABLE (0x0001) /* Enable receive */ - -/* Address filtering scheme mask */ -#define RX_CTRL_FILTER_MASK ( RX_CTRL_INVERSE_FILTER | RX_CTRL_PROMISCUOUS | RX_CTRL_MULTICAST | RX_CTRL_MAC_FILTER ) - -#define REG_RX_CTRL2 (0x76) /* RXCR2 */ -#define RX_CTRL_IPV6_UDP_NOCHECKSUM (0x0010) /* No checksum generation and verification if IPv6 UDP is fragment */ -#define RX_CTRL_IPV6_UDP_CHECKSUM (0x0008) /* Receive pass IPv6 UDP frame with UDP checksum is zero */ -#define RX_CTRL_UDP_LITE_CHECKSUM (0x0004) /* Enable UDP Lite frame checksum generation and verification */ -#define RX_CTRL_ICMP_CHECKSUM (0x0002) /* Enable ICMP frame checksum verification */ -#define RX_CTRL_BLOCK_MAC (0x0001) /* Receive drop frame if the SA is same as device MAC address */ -#define RX_CTRL_BURST_LEN_MASK (0x00e0) /* SRDBL SPI Receive Data Burst Length */ -#define RX_CTRL_BURST_LEN_4 (0x0000) -#define RX_CTRL_BURST_LEN_8 (0x0020) -#define RX_CTRL_BURST_LEN_16 (0x0040) -#define RX_CTRL_BURST_LEN_32 (0x0060) -#define RX_CTRL_BURST_LEN_FRAME (0x0080) - -#define REG_TX_MEM_INFO (0x78) /* TXMIR */ -#define TX_MEM_AVAILABLE_MASK (0x1FFF) /* The amount of memory available in TXQ */ - -#define REG_RX_FHR_STATUS (0x7C) /* RXFHSR */ -#define RX_VALID (0x8000) /* Frame in the receive packet memory is valid */ -#define RX_ICMP_ERROR (0x2000) /* ICMP checksum field doesn't match */ -#define RX_IP_ERROR (0x1000) /* IP checksum field doesn't match */ -#define RX_TCP_ERROR (0x0800) /* TCP checksum field doesn't match */ -#define RX_UDP_ERROR (0x0400) /* UDP checksum field doesn't match */ -#define RX_BROADCAST (0x0080) /* Received frame is a broadcast frame */ -#define RX_MULTICAST (0x0040) /* Received frame is a multicast frame */ -#define RX_UNICAST (0x0020) /* Received frame is a unicast frame */ -#define RX_PHY_ERROR (0x0010) /* Received frame has runt error */ -#define RX_FRAME_ETHER (0x0008) /* Received frame is an Ethernet-type frame */ -#define RX_TOO_LONG (0x0004) /* Received frame length exceeds max size 0f 2048 bytes */ -#define RX_RUNT_ERROR (0x0002) /* Received frame was demaged by a collision */ -#define RX_BAD_CRC (0x0001) /* Received frame has a CRC error */ -#define RX_ERRORS ( RX_BAD_CRC | RX_TOO_LONG | RX_RUNT_ERROR | RX_PHY_ERROR | \ - RX_ICMP_ERROR | RX_IP_ERROR | RX_TCP_ERROR | RX_UDP_ERROR ) - -#define REG_RX_FHR_BYTE_CNT (0x7E) /* RXFHBCR */ -#define RX_BYTE_CNT_MASK (0x0FFF) /* Received frame byte size mask */ - -#define REG_TXQ_CMD (0x80) /* TXQCR */ -#define TXQ_AUTO_ENQUEUE (0x0004) /* Enable enqueue tx frames from tx buffer automatically */ -#define TXQ_MEM_AVAILABLE_INT (0x0002) /* Enable generate interrupt when tx memory is available */ -#define TXQ_ENQUEUE (0x0001) /* Enable enqueue tx frames one frame at a time */ - -#define REG_RXQ_CMD (0x82) /* RXQCR */ -#define RXQ_STAT_TIME_INT (0x1000) /* RX interrupt is occured by timer duration */ -#define RXQ_STAT_BYTE_CNT_INT (0x0800) /* RX interrupt is occured by byte count threshold */ -#define RXQ_STAT_FRAME_CNT_INT (0x0400) /* RX interrupt is occured by frame count threshold */ -#define RXQ_TWOBYTE_OFFSET (0x0200) /* Enable adding 2-byte before frame header for IP aligned with DWORD */ -#define RXQ_TIME_INT (0x0080) /* Enable RX interrupt by timer duration */ -#define RXQ_BYTE_CNT_INT (0x0040) /* Enable RX interrupt by byte count threshold */ -#define RXQ_FRAME_CNT_INT (0x0020) /* Enable RX interrupt by frame count threshold */ -#define RXQ_AUTO_DEQUEUE (0x0010) /* Enable release rx frames from rx buffer automatically */ -#define RXQ_START (0x0008) /* Start QMU transfer operation */ -#define RXQ_CMD_FREE_PACKET (0x0001) /* Manual dequeue (release the current frame from RxQ) */ - -#define RXQ_CMD_CNTL (RXQ_FRAME_CNT_INT|RXQ_AUTO_DEQUEUE) - -#define REG_TX_ADDR_PTR (0x84) /* TXFDPR */ -#define REG_RX_ADDR_PTR (0x86) /* RXFDPR */ -#define ADDR_PTR_AUTO_INC (0x4000) /* Enable Frame data pointer increments automatically */ -#define ADDR_PTR_MASK (0x03ff) /* Address pointer mask */ - -#define REG_RX_TIME_THRES (0x8C) /* RXDTTR */ -#define RX_TIME_THRESHOLD_MASK (0xFFFF) /* Set receive timer duration threshold */ - -#define REG_RX_BYTE_CNT_THRES (0x8E) /* RXDBCTR */ -#define RX_BYTE_THRESHOLD_MASK (0xFFFF) /* Set receive byte count threshold */ - -#define REG_INT_MASK (0x90) /* IER */ -#define INT_PHY (0x8000) /* Enable link change interrupt */ -#define INT_TX (0x4000) /* Enable transmit done interrupt */ -#define INT_RX (0x2000) /* Enable receive interrupt */ -#define INT_RX_OVERRUN (0x0800) /* Enable receive overrun interrupt */ -#define INT_TX_STOPPED (0x0200) /* Enable transmit process stopped interrupt */ -#define INT_RX_STOPPED (0x0100) /* Enable receive process stopped interrupt */ -#define INT_TX_SPACE (0x0040) /* Enable transmit space available interrupt */ -#define INT_RX_WOL_FRAME (0x0020) /* Enable WOL on receive wake-up frame detect interrupt */ -#define INT_RX_WOL_MAGIC (0x0010) /* Enable WOL on receive magic packet detect interrupt */ -#define INT_RX_WOL_LINKUP (0x0008) /* Enable WOL on link up detect interrupt */ -#define INT_RX_WOL_ENERGY (0x0004) /* Enable WOL on energy detect interrupt */ -#define INT_RX_SPI_ERROR (0x0002) /* Enable receive SPI bus error interrupt */ -#define INT_RX_WOL_DELAY_ENERGY (0x0001) /* Enable WOL on delay energy detect interrupt */ -#define INT_MASK ( INT_RX | INT_TX | INT_PHY ) - -#define REG_INT_STATUS (0x92) /* ISR */ - -#define REG_RX_FRAME_CNT_THRES (0x9C) /* RXFCTFC */ -#define RX_FRAME_CNT_MASK (0xFF00) /* Received frame count mask */ -#define RX_FRAME_THRESHOLD_MASK (0x00FF) /* Set receive frame count threshold mask */ - -#define REG_TX_TOTAL_FRAME_SIZE (0x9E) /* TXNTFSR */ -#define TX_TOTAL_FRAME_SIZE_MASK (0xFFFF) /* Set next total tx frame size mask */ - -/* - * MAC Address Hash Table Control Registers - * (Offset 0xA0 - 0xA7) - */ -#define REG_MAC_HASH_0 (0xA0) /* MAHTR0 */ -#define REG_MAC_HASH_1 (0xA1) - -#define REG_MAC_HASH_2 (0xA2) /* MAHTR1 */ -#define REG_MAC_HASH_3 (0xA3) - -#define REG_MAC_HASH_4 (0xA4) /* MAHTR2 */ -#define REG_MAC_HASH_5 (0xA5) - -#define REG_MAC_HASH_6 (0xA6) /* MAHTR3 */ -#define REG_MAC_HASH_7 (0xA7) - -/* - * QMU Receive Queue Watermark Control Registers - * (Offset 0xB0 - 0xB5) - */ -#define REG_RX_LOW_WATERMARK (0xB0) /* FCLWR */ -#define RX_LOW_WATERMARK_MASK (0x0FFF) /* Set QMU RxQ low watermark mask */ - -#define REG_RX_HIGH_WATERMARK (0xB2) /* FCHWR */ -#define RX_HIGH_WATERMARK_MASK (0x0FFF) /* Set QMU RxQ high watermark mask */ - -#define REG_RX_OVERRUN_WATERMARK (0xB4) /* FCOWR */ -#define RX_OVERRUN_WATERMARK_MASK (0x0FFF) /* Set QMU RxQ overrun watermark mask */ - -/* - * Global Control Registers - * (Offset 0xC0 - 0xD3) - */ -#define REG_CHIP_ID (0xC0) /* CIDER */ -#define CHIP_ID_MASK (0xFFF0) /* Family ID and chip ID mask */ -#define REVISION_MASK (0x000E) /* Chip revision mask */ -#define CHIP_ID_SHIFT (4) -#define REVISION_SHIFT (1) -#define CHIP_ID_8851_16 (0x8870) /* KS8851-16/32MQL chip ID */ - -#define REG_LED_CTRL (0xC6) /* CGCR */ -#define LED_CTRL_SEL1 (0x8000) /* Select LED3/LED2/LED1/LED0 indication */ -#define LED_CTRL_SEL0 (0x0200) /* Select LED3/LED2/LED1/LED0 indication */ - -#define REG_IND_IACR (0xC8) /* IACR */ -#define TABLE_READ (0x1000) /* Indirect read */ -#define TABLE_MIB (0x0C00) /* Select MIB counter table */ -#define TABLE_ENTRY_MASK (0x001F) /* Set table entry to access */ - -#define REG_IND_DATA_LOW (0xD0) /* IADLR */ -#define REG_IND_DATA_HIGH (0xD2) /* IADHR */ - -/* - * Power Management Control Registers - * (Offset 0xD4 - 0xD7) - */ -#define REG_POWER_CNTL (0xD4) /* PMECR */ -#define PME_DELAY_ENABLE (0x4000) /* Enable the PME output pin assertion delay */ -#define PME_ACTIVE_HIGHT (0x1000) /* PME output pin is active high */ -#define PME_FROM_WKFRAME (0x0800) /* PME asserted when wake-up frame is detected */ -#define PME_FROM_MAGIC (0x0400) /* PME asserted when magic packet is detected */ -#define PME_FROM_LINKUP (0x0200) /* PME asserted when link up is detected */ -#define PME_FROM_ENERGY (0x0100) /* PME asserted when energy is detected */ -#define PME_EVENT_MASK (0x0F00) /* PME asserted event mask */ -#define WAKEUP_AUTO_ENABLE (0x0080) /* Enable auto wake-up in energy mode */ -#define WAKEUP_NORMAL_AUTO_ENABLE (0x0040) /* Enable auto goto normal mode from energy detecion mode */ -#define WAKEUP_FROM_WKFRAME (0x0020) /* Wake-up from wake-up frame event detected */ -#define WAKEUP_FROM_MAGIC (0x0010) /* Wake-up from magic packet event detected */ -#define WAKEUP_FROM_LINKUP (0x0008) /* Wake-up from link up event detected */ -#define WAKEUP_FROM_ENERGY (0x0004) /* Wake-up from energy event detected */ -#define WAKEUP_EVENT_MASK (0x003C) /* Wake-up event mask */ -#define POWER_STATE_D1 (0x0003) /* Power saving mode */ -#define POWER_STATE_D3 (0x0002) /* Power down mode */ -#define POWER_STATE_D2 (0x0001) /* Power detection mode */ -#define POWER_STATE_D0 (0x0000) /* Normal operation mode (default) */ -#define POWER_STATE_MASK (0x0003) /* Power management mode mask */ - -#define REG_WAKEUP_TIME (0xD6) /* GSWUTR */ -#define WAKEUP_TIME (0xFF00) /* Min time (sec) wake-uo after detected energy */ -#define GOSLEEP_TIME (0x00FF) /* Min time (sec) before goto sleep when in energy mode */ - -/* - * PHY Control Registers - * (Offset 0xD8 - 0xF9) - */ -#define REG_PHY_RESET (0xD8) /* PHYRR */ -#define PHY_RESET (0x0001) /* Reset PHY */ - -#define REG_PHY_CNTL (0xE4) /* P1MBCR */ -#define PHY_SPEED_100MBIT (0x2000) /* Force PHY 100Mbps */ -#define PHY_AUTO_NEG_ENABLE (0x1000) /* Enable PHY auto-negotiation */ -#define PHY_POWER_DOWN (0x0800) /* Set PHY power-down */ -#define PHY_AUTO_NEG_RESTART (0x0200) /* Restart PHY auto-negotiation */ -#define PHY_FULL_DUPLEX (0x0100) /* Force PHY in full duplex mode */ -#define PHY_HP_MDIX (0x0020) /* Set PHY in HP auto MDI-X mode */ -#define PHY_FORCE_MDIX (0x0010) /* Force MDI-X */ -#define PHY_AUTO_MDIX_DISABLE (0x0008) /* Disable auto MDI-X */ -#define PHY_TRANSMIT_DISABLE (0x0002) /* Disable PHY transmit */ -#define PHY_LED_DISABLE (0x0001) /* Disable PHY LED */ - -#define REG_PHY_STATUS (0xE6) /* P1MBSR */ -#define PHY_100BT4_CAPABLE (0x8000) /* 100 BASE-T4 capable */ -#define PHY_100BTX_FD_CAPABLE (0x4000) /* 100BASE-TX full duplex capable */ -#define PHY_100BTX_CAPABLE (0x2000) /* 100BASE-TX half duplex capable */ -#define PHY_10BT_FD_CAPABLE (0x1000) /* 10BASE-TX full duplex capable */ -#define PHY_10BT_CAPABLE (0x0800) /* 10BASE-TX half duplex capable */ -#define PHY_AUTO_NEG_ACKNOWLEDGE (0x0020) /* Auto-negotiation complete */ -#define PHY_AUTO_NEG_CAPABLE (0x0008) /* Auto-negotiation capable */ -#define PHY_LINK_UP (0x0004) /* PHY link is up */ -#define PHY_EXTENDED_CAPABILITY (0x0001) /* PHY extended register capable */ - -#define REG_PHY_ID_LOW (0xE8) /* PHY1ILR */ -#define REG_PHY_ID_HIGH (0xEA) /* PHY1IHR */ - -#define REG_PHY_AUTO_NEGOTIATION (0xEC) /* P1ANAR */ -#define PHY_AUTO_NEG_SYM_PAUSE (0x0400) /* Advertise pause capability */ -#define PHY_AUTO_NEG_100BTX_FD (0x0100) /* Advertise 100 full-duplex capability */ -#define PHY_AUTO_NEG_100BTX (0x0080) /* Advertise 100 half-duplex capability */ -#define PHY_AUTO_NEG_10BT_FD (0x0040) /* Advertise 10 full-duplex capability */ -#define PHY_AUTO_NEG_10BT (0x0020) /* Advertise 10 half-duplex capability */ -#define PHY_AUTO_NEG_SELECTOR (0x001F) /* Selector field mask */ -#define PHY_AUTO_NEG_802_3 (0x0001) /* 802.3 */ - -#define REG_PHY_REMOTE_CAPABILITY (0xEE) /* P1ANLPR */ -#define PHY_REMOTE_SYM_PAUSE (0x0400) /* Link partner pause capability */ -#define PHY_REMOTE_100BTX_FD (0x0100) /* Link partner 100 full-duplex capability */ -#define PHY_REMOTE_100BTX (0x0080) /* Link partner 100 half-duplex capability */ -#define PHY_REMOTE_10BT_FD (0x0040) /* Link partner 10 full-duplex capability */ -#define PHY_REMOTE_10BT (0x0020) /* Link partner 10 half-duplex capability */ - -#define REG_PORT_LINK_MD (0xF4) /* P1SCLMD */ -#define PORT_CABLE_10M_SHORT (0x8000) /* Cable length is less than 10m short */ -#define PORT_CABLE_STAT_FAILED (0x6000) /* Cable diagnostic test fail */ -#define PORT_CABLE_STAT_SHORT (0x4000) /* Short condition detected in the cable */ -#define PORT_CABLE_STAT_OPEN (0x2000) /* Open condition detected in the cable */ -#define PORT_CABLE_STAT_NORMAL (0x0000) /* Normal condition */ -#define PORT_CABLE_DIAG_RESULT (0x6000) /* Cable diagnostic test result mask */ -#define PORT_START_CABLE_DIAG (0x1000) /* Enable cable diagnostic test */ -#define PORT_FORCE_LINK (0x0800) /* Enable force link pass */ -#define PORT_POWER_SAVING (0x0400) /* Disable power saving */ -#define PORT_REMOTE_LOOPBACK (0x0200) /* Enable remote loopback at PHY */ -#define PORT_CABLE_FAULT_COUNTER (0x01FF) /* Cable length distance to the fault */ - -#define REG_PORT_CTRL (0xF6) /* P1CR */ -#define PORT_LED_OFF (0x8000) /* Turn off all the port LEDs (LED3/LED2/LED1/LED0) */ -#define PORT_TX_DISABLE (0x4000) /* Disable port transmit */ -#define PORT_AUTO_NEG_RESTART (0x2000) /* Restart auto-negotiation */ -#define PORT_POWER_DOWN (0x0800) /* Set port power-down */ -#define PORT_AUTO_MDIX_DISABLE (0x0400) /* Disable auto MDI-X */ -#define PORT_FORCE_MDIX (0x0200) /* Force MDI-X */ -#define PORT_AUTO_NEG_ENABLE (0x0080) /* Enable auto-negotiation */ -#define PORT_FORCE_100_MBIT (0x0040) /* Force PHY 100Mbps */ -#define PORT_FORCE_FULL_DUPLEX (0x0020) /* Force PHY in full duplex mode */ -#define PORT_AUTO_NEG_SYM_PAUSE (0x0010) /* Advertise pause capability */ -#define PORT_AUTO_NEG_100BTX_FD (0x0008) /* Advertise 100 full-duplex capability */ -#define PORT_AUTO_NEG_100BTX (0x0004) /* Advertise 100 half-duplex capability */ -#define PORT_AUTO_NEG_10BT_FD (0x0002) /* Advertise 10 full-duplex capability */ -#define PORT_AUTO_NEG_10BT (0x0001) /* Advertise 10 half-duplex capability */ - -#define REG_PORT_STATUS (0xF8) /* P1SR */ -#define PORT_HP_MDIX (0x8000) /* Set PHY in HP auto MDI-X mode */ -#define PORT_REVERSED_POLARITY (0x2000) /* Polarity is reversed */ -#define PORT_RX_FLOW_CTRL (0x1000) /* Reeive flow control feature is active */ -#define PORT_TX_FLOW_CTRL (0x0800) /* Transmit flow control feature is active */ -#define PORT_STAT_SPEED_100MBIT (0x0400) /* Link is 100Mbps */ -#define PORT_STAT_FULL_DUPLEX (0x0200) /* Link is full duplex mode */ -#define PORT_MDIX_STATUS (0x0080) /* Is MDI */ -#define PORT_AUTO_NEG_COMPLETE (0x0040) /* Auto-negotiation complete */ -#define PORT_STATUS_LINK_GOOD (0x0020) /* PHY link is up */ -#define PORT_REMOTE_SYM_PAUSE (0x0010) /* Link partner pause capability */ -#define PORT_REMOTE_100BTX_FD (0x0008) /* Link partner 100 full-duplex capability */ -#define PORT_REMOTE_100BTX (0x0004) /* Link partner 100 half-duplex capability */ -#define PORT_REMOTE_10BT_FD (0x0002) /* Link partner 10 full-duplex capability */ -#define PORT_REMOTE_10BT (0x0001) /* Link partner 10 half-duplex capability */ - -#endif /* KSZ8851SNL_REG_H_INCLUDED */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/readme.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/readme.txt deleted file mode 100755 index 65e5e2b..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/readme.txt +++ /dev/null @@ -1,18 +0,0 @@ -Contains the files that implement FreeRTOS+TCP. - -User documentation, including an API reference is available on: -http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/ - -A description of the source code organisation is available on: -http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Networking_Tutorial.html - -The porting guide is available on: -http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/FreeRTOS_TCP_Porting.html - -License information is available on: -http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/FreeRTOS_Plus_TCP_License.html - -At this time it is recommended to use BufferAllocation_2.c in which case it is -essential to use the heap_4.c memory allocation scheme: -http://www.FreeRTOS.org/a00111.html - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcHardwarePort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcHardwarePort.h deleted file mode 100755 index 1b47e69..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcHardwarePort.h +++ /dev/null @@ -1,478 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.5 - * Percepio AB, www.percepio.com - * - * trcHardwarePort.h - * - * The hardware abstraction layer for the trace recorder. - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_HARDWARE_PORT_H -#define TRC_HARDWARE_PORT_H - -#include "trcPortDefines.h" - - -#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NOT_SET) - #error "TRC_CFG_HARDWARE_PORT not selected - see trcConfig.h" -#endif - -/******************************************************************************* - * TRC_IRQ_PRIORITY_ORDER - * - * Macro which should be defined as an integer of 0 or 1. - * - * This should be 0 if lower IRQ priority values implies higher priority - * levels, such as on ARM Cortex M. If the opposite scheme is used, i.e., - * if higher IRQ priority values means higher priority, this should be 1. - * - * This setting is not critical. It is used only to sort and colorize the - * interrupts in priority order, in case you record interrupts using - * the vTraceStoreISRBegin and vTraceStoreISREnd routines. - * - ****************************************************************************** - * - * HWTC Macros - * - * These macros provides a hardware isolation layer representing the - * hardware timer/counter used for the event timestamping. - * - * TRC_HWTC_COUNT: How to read the current value of the timer/counter. - * - * TRC_HWTC_TYPE: Tells the type of timer/counter used for TRC_HWTC_COUNT: - * - * - TRC_FREE_RUNNING_32BIT_INCR: - * Free-running 32-bit timer/counter, counting upwards from 0. - * - * - TRC_FREE_RUNNING_32BIT_DECR - * Free-running 32-bit timer/counter, counting downwards from 0xFFFFFFFF. - * - * - TRC_OS_TIMER_INCR - * Periodic timer that drives the OS tick interrupt, counting upwards - * from 0 until (TRC_HWTC_PERIOD-1). - * - * - TRC_OS_TIMER_DECR - * Periodic timer that drives the OS tick interrupt, counting downwards - * from TRC_HWTC_PERIOD-1 until 0. - * - * - TRC_CUSTOM_TIMER_INCR - * A custom timer or counter independent of the OS tick, counting - * downwards from TRC_HWTC_PERIOD-1 until 0. (Currently only supported - * in streaming mode). - * - * - TRC_CUSTOM_TIMER_DECR - * A custom timer independent of the OS tick, counting downwards - * from TRC_HWTC_PERIOD-1 until 0. (Currently only supported - * in streaming mode). - * - * TRC_HWTC_PERIOD: The number of HWTC_COUNT ticks until the timer wraps - * around. If using TRC_FREE_RUNNING_32BIT_INCR/DECR, this should be 0. - * - * TRC_HWTC_FREQ_HZ: The clock rate of the TRC_HWTC_COUNT counter in Hz. If using - * TRC_OS_TIMER_INCR/DECR, this is should be TRC_HWTC_PERIOD * TRACE_TICK_RATE_HZ. - * If using a free-running timer, this is often TRACE_CPU_CLOCK_HZ (if running at - * the core clock rate). If using TRC_CUSTOM_TIMER_INCR/DECR, this should match - * the clock rate of your custom timer (i.e., TRC_HWTC_COUNT). If the default value - * of TRC_HWTC_FREQ_HZ is incorrect for your setup, you can override it by calling - * vTraceSetFrequency before calling vTraceEnable. - * - * TRC_HWTC_DIVISOR (used in snapshot mode only): - * In snapshot mode, the timestamp resolution is TRC_HWTC_FREQ_HZ/TRC_HWTC_DIVISOR. - * If the timer frequency is very high (hundreds of MHz), we recommend increasing - * the TRC_HWTC_DIVISOR prescaler, to reduce the bandwidth needed to store - * timestamps. This since extra "XTS" events are inserted if the time since the - * previous event exceeds a certain limit (255 or 65535 depending on event type). - * It is advised to keep the time between most events below 65535 native ticks - * (after division by TRC_HWTC_DIVISOR) to avoid frequent XTS events. - ******************************************************************************/ - -#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NOT_SET) - #error "TRC_CFG_HARDWARE_PORT not selected - see trcConfig.h" -#endif - -#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Win32) - /* This can be used as a template for any free-running 32-bit counter */ - #define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR - #define TRC_HWTC_COUNT (ulGetRunTimeCounterValue()) - #define TRC_HWTC_PERIOD 0 - #define TRC_HWTC_DIVISOR 1 - #define TRC_HWTC_FREQ_HZ 100000 - - #define TRC_IRQ_PRIORITY_ORDER 1 - - #define TRC_PORT_SPECIFIC_INIT() - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_HWIndependent) - /* Timestamping by OS tick only (typically 1 ms resolution) */ - #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR - #define TRC_HWTC_COUNT 0 - #define TRC_HWTC_PERIOD 1 - #define TRC_HWTC_DIVISOR 1 - #define TRC_HWTC_FREQ_HZ TRACE_TICK_RATE_HZ - - /* Set the meaning of IRQ priorities in ISR tracing - see above */ - #define TRC_IRQ_PRIORITY_ORDER NOT_SET - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_Cortex_M) - - #ifndef __CORTEX_M - #error "Can't find the CMSIS API. Please include your processor's header file in trcConfig.h" - #endif - - /************************************************************************** - * For Cortex-M3, M4 and M7, the DWT cycle counter is used for timestamping. - * For Cortex-M0 and M0+, the SysTick timer is used since DWT is not - * available. Systick timestamping can also be forced on Cortex-M3, M4 and - * M7 by defining the preprocessor directive TRC_CFG_ARM_CM_USE_SYSTICK, - * either directly below or in trcConfig.h. - * - * #define TRC_CFG_ARM_CM_USE_SYSTICK - **************************************************************************/ - - #if ((__CORTEX_M >= 0x03) && (! defined TRC_CFG_ARM_CM_USE_SYSTICK)) - - void prvTraceInitCortexM(void); - - #define TRC_REG_DEMCR (*(volatile uint32_t*)0xE000EDFC) - #define TRC_REG_DWT_CTRL (*(volatile uint32_t*)0xE0001000) - #define TRC_REG_DWT_CYCCNT (*(volatile uint32_t*)0xE0001004) - #define TRC_REG_DWT_EXCCNT (*(volatile uint32_t*)0xE000100C) - - #define TRC_REG_ITM_LOCKACCESS (*(volatile uint32_t*)0xE0001FB0) - #define TRC_ITM_LOCKACCESS_UNLOCK (0xC5ACCE55) - - /* Bit mask for TRCENA bit in DEMCR - Global enable for DWT and ITM */ - #define TRC_DEMCR_TRCENA (1 << 24) - - /* Bit mask for NOPRFCNT bit in DWT_CTRL. If 1, DWT_EXCCNT is not supported */ - #define TRC_DWT_CTRL_NOPRFCNT (1 << 24) - - /* Bit mask for NOCYCCNT bit in DWT_CTRL. If 1, DWT_CYCCNT is not supported */ - #define TRC_DWT_CTRL_NOCYCCNT (1 << 25) - - /* Bit mask for EXCEVTENA_ bit in DWT_CTRL. Set to 1 to enable DWT_EXCCNT */ - #define TRC_DWT_CTRL_EXCEVTENA (1 << 18) - - /* Bit mask for EXCEVTENA_ bit in DWT_CTRL. Set to 1 to enable DWT_CYCCNT */ - #define TRC_DWT_CTRL_CYCCNTENA (1) - - #define TRC_PORT_SPECIFIC_INIT() prvTraceInitCortexM() - - #define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR - #define TRC_HWTC_COUNT TRC_REG_DWT_CYCCNT - #define TRC_HWTC_PERIOD 0 - #define TRC_HWTC_DIVISOR 4 - #define TRC_HWTC_FREQ_HZ TRACE_CPU_CLOCK_HZ - #define TRC_IRQ_PRIORITY_ORDER 0 - - #else - - #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR - #define TRC_HWTC_COUNT (*((volatile uint32_t*)0xE000E018)) - #define TRC_HWTC_PERIOD ((*((volatile uint32_t*)0xE000E014)) + 1) - #define TRC_HWTC_DIVISOR 4 - #define TRC_HWTC_FREQ_HZ TRACE_CPU_CLOCK_HZ - #define TRC_IRQ_PRIORITY_ORDER 0 - - #endif - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Renesas_RX600) - - #include "iodefine.h" - - #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) - - #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR - #define TRC_HWTC_COUNT (CMT0.CMCNT) - - #elif (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) - - /* Decreasing counters better for Tickless Idle? */ - #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR - #define TRC_HWTC_COUNT (CMT0.CMCOR - CMT0.CMCNT) - - #endif - - #define TRC_HWTC_PERIOD (CMT0.CMCOR + 1) - #define TRC_HWTC_DIVISOR 1 - #define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) - #define TRC_IRQ_PRIORITY_ORDER 1 - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_MICROCHIP_PIC24_PIC32) - - #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR - #define TRC_HWTC_COUNT (TMR1) - #define TRC_HWTC_PERIOD (PR1 + 1) - #define TRC_HWTC_DIVISOR 1 - #define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) - #define TRC_IRQ_PRIORITY_ORDER 0 - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_TMS570_RM48) - - #define TRC_RTIFRC0 *((uint32_t *)0xFFFFFC10) - #define TRC_RTICOMP0 *((uint32_t *)0xFFFFFC50) - #define TRC_RTIUDCP0 *((uint32_t *)0xFFFFFC54) - - #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR - #define TRC_HWTC_COUNT (TRC_RTIFRC0 - (TRC_RTICOMP0 - TRC_RTIUDCP0)) - #define TRC_HWTC_PERIOD (TRC_RTIUDCP0) - #define TRC_HWTC_DIVISOR 1 - #define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) - #define TRC_IRQ_PRIORITY_ORDER 0 - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Atmel_AT91SAM7) - - /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */ - - #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR - #define TRC_HWTC_COUNT ((uint32_t)(AT91C_BASE_PITC->PITC_PIIR & 0xFFFFF)) - #define TRC_HWTC_PERIOD ((uint32_t)(AT91C_BASE_PITC->PITC_PIMR + 1)) - #define TRC_HWTC_DIVISOR 1 - #define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) - #define TRC_IRQ_PRIORITY_ORDER 1 - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Atmel_UC3A0) - - /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO*/ - - /* For Atmel AVR32 (AT32UC3A) */ - - #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR - #define TRC_HWTC_COUNT ((uint32_t)sysreg_read(AVR32_COUNT)) - #define TRC_HWTC_PERIOD ((uint32_t)(sysreg_read(AVR32_COMPARE) + 1)) - #define TRC_HWTC_DIVISOR 1 - #define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) - #define TRC_IRQ_PRIORITY_ORDER 1 - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NXP_LPC210X) - - /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */ - - /* Tested with LPC2106, but should work with most LPC21XX chips. */ - - #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR - #define TRC_HWTC_COUNT *((uint32_t *)0xE0004008 ) - #define TRC_HWTC_PERIOD *((uint32_t *)0xE0004018 ) - #define TRC_HWTC_DIVISOR 1 - #define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) - #define TRC_IRQ_PRIORITY_ORDER 0 - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_MSP430) - - /* UNOFFICIAL PORT - NOT YET VERIFIED */ - - #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR - #define TRC_HWTC_COUNT (TA0R) - #define TRC_HWTC_PERIOD (((uint16_t)TACCR0)+1) - #define TRC_HWTC_DIVISOR 1 - #define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) - #define TRC_IRQ_PRIORITY_ORDER 1 - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_PPC405) - - /* UNOFFICIAL PORT - NOT YET VERIFIED */ - - #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR - #define TRC_HWTC_COUNT mfspr(0x3db) - #define TRC_HWTC_PERIOD (TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ) - #define TRC_HWTC_DIVISOR 1 - #define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) - #define TRC_IRQ_PRIORITY_ORDER 0 - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_PPC440) - - /* UNOFFICIAL PORT */ - - /* This should work with most PowerPC chips */ - - #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR - #define TRC_HWTC_COUNT mfspr(0x016) - #define TRC_HWTC_PERIOD (TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ) - #define TRC_HWTC_DIVISOR 1 - #define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) - #define TRC_IRQ_PRIORITY_ORDER 0 - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_MICROBLAZE) - - /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */ - - /* This should work with most Microblaze configurations. - * It uses the AXI Timer 0 - the tick interrupt source. - * If an AXI Timer 0 peripheral is available on your hardware platform, no modifications are required. - */ - #include "xtmrctr_l.h" - - #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR - #define TRC_HWTC_COUNT XTmrCtr_GetTimerCounterReg( XPAR_TMRCTR_0_BASEADDR, 0 ) - #define TRC_HWTC_PERIOD (XTmrCtr_mGetLoadReg( XPAR_TMRCTR_0_BASEADDR, 0) + 1) - #define TRC_HWTC_DIVISOR 16 - #define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) - #define TRC_IRQ_PRIORITY_ORDER 0 - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Altera_NiosII) - - /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */ - - #include "system.h" - #include "sys/alt_timestamp.h" - - #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR - #define TRC_HWTC_COUNT (uint32_t)alt_timestamp() - #define TRC_HWTC_PERIOD 0xFFFFFFFF - #define TRC_HWTC_FREQ_HZ TIMESTAMP_TIMER_FREQ - #define TRC_HWTC_DIVISOR 1 - #define TRC_IRQ_PRIORITY_ORDER 0 - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_CORTEX_A9) - - /* INPUT YOUR PERIPHERAL BASE ADDRESS HERE */ - #define TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS 0xSOMETHING - - #define TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET 0x0600 - #define TRC_CA9_MPCORE_PRIVCTR_PERIOD_REG (*(volatile uint32_t*)(TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x00)) - #define TRC_CA9_MPCORE_PRIVCTR_COUNTER_REG (*(volatile uint32_t*)(TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x04)) - #define TRC_CA9_MPCORE_PRIVCTR_CONTROL_REG (*(volatile uint32_t*)(TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x08)) - - #define TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_MASK 0x0000FF00 - #define TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_SHIFT 8 - #define TRC_CA9_MPCORE_PRIVCTR_PRESCALER (((TRC_CA9_MPCORE_PRIVCTR_CONTROL_REG & TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_MASK) >> TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_SHIFT) + 1) - - #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR - #define TRC_HWTC_COUNT TRC_CA9_MPCORE_PRIVCTR_COUNTER_REG - #define TRC_HWTC_PERIOD (TRC_CA9_MPCORE_PRIVCTR_PERIOD_REG + 1) - - /**************************************************************************************** - NOTE: The private timer ticks with a very high frequency (half the core-clock usually), - depending on the prescaler used. If a low prescaler is used, the number of HW ticks between - the trace events gets large, and thereby inefficient to store (sometimes extra events are - needed). To improve efficiency, you may use the TRC_HWTC_DIVISOR as an additional prescaler. - *****************************************************************************************/ - #define TRC_HWTC_DIVISOR 1 - - #define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) - #define TRC_IRQ_PRIORITY_ORDER 0 - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_POWERPC_Z4) - - /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */ - - #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR - //#define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING - #define TRC_HWTC_COUNT PIT.TIMER[configTICK_PIT_CHANNEL].CVAL.R // must be the PIT channel used for the systick - #define TRC_HWTC_PERIOD ((configPIT_CLOCK_HZ / configTICK_RATE_HZ) - 1U) // TODO FIXME or maybe not -1? what's the right "period" value? - #define TRC_HWTC_FREQ_HZ configPIT_CLOCK_HZ - #define TRC_HWTC_DIVISOR 1 - #define TRC_IRQ_PRIORITY_ORDER 1 // higher IRQ priority values are more significant - -#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_APPLICATION_DEFINED) - - #if !( defined (TRC_HWTC_TYPE) && defined (TRC_HWTC_COUNT) && defined (TRC_HWTC_PERIOD) && defined (TRC_HWTC_FREQ_HZ) && defined (TRC_IRQ_PRIORITY_ORDER) ) - #error "The hardware port is not completely defined!" - #endif - -#elif (TRC_CFG_HARDWARE_PORT != TRC_HARDWARE_PORT_NOT_SET) - - #error "TRC_CFG_HARDWARE_PORT had unsupported value!" - #define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_NOT_SET - -#endif - -#ifndef TRC_HWTC_DIVISOR - #define TRC_HWTC_DIVISOR 1 -#endif - -#ifndef TRC_PORT_SPECIFIC_INIT - #define TRC_PORT_SPECIFIC_INIT() -#endif - -/* If Win32 port */ -#ifdef WIN32 - - #undef _WIN32_WINNT - #define _WIN32_WINNT 0x0600 - - /* Standard includes. */ - #include - #include - #include - - /*************************************************************************** - * The Win32 port by default saves the trace to file and then kills the - * program when the recorder is stopped, to facilitate quick, simple tests - * of the recorder. - ***************************************************************************/ - #define WIN32_PORT_SAVE_WHEN_STOPPED 1 - #define WIN32_PORT_EXIT_WHEN_STOPPED 1 - -#endif - -#if (TRC_CFG_HARDWARE_PORT != TRC_HARDWARE_PORT_NOT_SET) - - #ifndef TRC_HWTC_TYPE - #error "TRC_HWTC_TYPE is not set!" - #endif - - #ifndef TRC_HWTC_COUNT - #error "TRC_HWTC_COUNT is not set!" - #endif - - #ifndef TRC_HWTC_PERIOD - #error "TRC_HWTC_PERIOD is not set!" - #endif - - #ifndef TRC_HWTC_DIVISOR - #error "TRC_HWTC_DIVISOR is not set!" - #endif - - #ifndef TRC_IRQ_PRIORITY_ORDER - #error "TRC_IRQ_PRIORITY_ORDER is not set!" - #elif (TRC_IRQ_PRIORITY_ORDER != 0) && (TRC_IRQ_PRIORITY_ORDER != 1) - #error "TRC_IRQ_PRIORITY_ORDER has bad value!" - #endif - - #if (TRC_HWTC_DIVISOR < 1) - #error "TRC_HWTC_DIVISOR must be a non-zero positive value!" - #endif - - #ifndef TRC_HWTC_FREQ_HZ - #error "TRC_HWTC_FREQ_HZ not defined!" - #endif - -#endif - -#endif /*TRC_SNAPSHOT_HARDWARE_PORT_H*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h deleted file mode 100755 index f7f6ca0..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h +++ /dev/null @@ -1,2565 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.5 - * Percepio AB, www.percepio.com - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * FreeRTOS-specific definitions needed by the trace recorder - * - * - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_KERNEL_PORT_H -#define TRC_KERNEL_PORT_H - -#include "FreeRTOS.h" /* Defines configUSE_TRACE_FACILITY */ -#include "trcPortDefines.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define TRC_USE_TRACEALYZER_RECORDER configUSE_TRACE_FACILITY - -/*** FreeRTOS version codes **************************************************/ -#define FREERTOS_VERSION_NOT_SET 0 -#define TRC_FREERTOS_VERSION_7_3 1 /* v7.3 is earliest supported.*/ -#define TRC_FREERTOS_VERSION_7_4 2 -#define TRC_FREERTOS_VERSION_7_5_OR_7_6 3 -#define TRC_FREERTOS_VERSION_8_X 4 /* Any v8.x.x*/ -#define TRC_FREERTOS_VERSION_9_0_0 5 -#define TRC_FREERTOS_VERSION_9_0_1 6 -#define TRC_FREERTOS_VERSION_9_0_2 7 -#define TRC_FREERTOS_VERSION_10_0_0 8 /* If using FreeRTOS v10.0.0 or later version */ - -#define TRC_FREERTOS_VERSION_9_X 42 /* Not allowed anymore */ - -#if (TRC_CFG_FREERTOS_VERSION == TRC_FREERTOS_VERSION_9_X) -/* This setting for TRC_CFG_FREERTOS_VERSION is no longer allowed as v9.0.1 needs special handling. */ -#error "Please specify your exact FreeRTOS version in trcConfig.h, from the options listed above." -#endif - -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) -#define prvGetStreamBufferType(x) ((( StreamBuffer_t * )x )->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER) -#else -#define prvGetStreamBufferType(x) 0 -#endif - -/* Added mainly for our internal testing. This makes it easier to create test applications that - runs on multiple FreeRTOS versions. */ -#if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_8_X) - /* FreeRTOS v7.0 and later */ - #define STRING_CAST(x) ( (signed char*) x ) - #define TickType portTickType -#else - /* FreeRTOS v8.0 and later */ - #define STRING_CAST(x) x - #define TickType TickType_t -#endif - -#if (defined(TRC_USE_TRACEALYZER_RECORDER)) && (TRC_USE_TRACEALYZER_RECORDER == 1) - -/******************************************************************************* - * INCLUDE_xTaskGetCurrentTaskHandle must be set to 1 for tracing to work properly - ******************************************************************************/ -#undef INCLUDE_xTaskGetCurrentTaskHandle -#define INCLUDE_xTaskGetCurrentTaskHandle 1 - -#if (TRC_CFG_SCHEDULING_ONLY == 0) -/******************************************************************************* - * vTraceSetQueueName(void* object, const char* name) - * - * Parameter object: pointer to the Queue that shall be named - * Parameter name: the name to set (const string literal) - * - * Sets a name for Queue objects for display in Tracealyzer. - ******************************************************************************/ -void vTraceSetQueueName(void* object, const char* name); - -/******************************************************************************* - * vTraceSetSemaphoreName(void* object, const char* name) - * - * Parameter object: pointer to the Semaphore that shall be named - * Parameter name: the name to set (const string literal) - * - * Sets a name for Semaphore objects for display in Tracealyzer. - ******************************************************************************/ -void vTraceSetSemaphoreName(void* object, const char* name); - -/******************************************************************************* - * vTraceSetMutexName(void* object, const char* name) - * - * Parameter object: pointer to the Mutex that shall be named - * Parameter name: the name to set (const string literal) - * - * Sets a name for Semaphore objects for display in Tracealyzer. - ******************************************************************************/ -void vTraceSetMutexName(void* object, const char* name); - -#if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1) -/******************************************************************************* -* vTraceSetEventGroupName(void* object, const char* name) -* -* Parameter object: pointer to the EventGroup that shall be named -* Parameter name: the name to set (const string literal) -* -* Sets a name for EventGroup objects for display in Tracealyzer. -******************************************************************************/ -void vTraceSetEventGroupName(void* object, const char* name); -#else /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1) */ -#define vTraceSetEventGroupName(object, name) /* Do nothing */ -#endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1) */ - -#if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) -/******************************************************************************* -* vTraceSetStreamBufferName(void* object, const char* name) -* -* Parameter object: pointer to the StreamBuffer that shall be named -* Parameter name: the name to set (const string literal) -* -* Sets a name for StreamBuffer objects for display in Tracealyzer. -******************************************************************************/ -void vTraceSetStreamBufferName(void* object, const char* name); -#else /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) */ -#define vTraceSetStreamBufferName(object, name) /* Do nothing */ -#endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) */ - -#if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) -/******************************************************************************* - * vTraceSetMessageBufferName(void* object, const char* name) - * - * Parameter object: pointer to the MessageBuffer that shall be named - * Parameter name: the name to set (const string literal) - * - * Sets a name for MessageBuffer objects for display in Tracealyzer. - ******************************************************************************/ -void vTraceSetMessageBufferName(void* object, const char* name); -#else /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) */ -#define vTraceSetMessageBufferName(object, name) /* Do nothing */ -#endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) */ - -#else /* (TRC_CFG_SCHEDULING_ONLY == 0) */ - -#define vTraceSetQueueName(object, name) /* Do nothing */ -#define vTraceSetSemaphoreName(object, name) /* Do nothing */ -#define vTraceSetMutexName(object, name) /* Do nothing */ -#define vTraceSetEventGroupName(object, name) /* Do nothing */ -#define vTraceSetStreamBufferName(object, name) /* Do nothing */ -#define vTraceSetMessageBufferName(object, name) /* Do nothing */ - -#endif /* (TRC_CFG_SCHEDULING_ONLY == 0) */ - -/******************************************************************************* - * Note: Setting names for event groups is difficult to support, this has been - * excluded intentionally. This since we don't know if event_groups.c is - * included in the build, so referencing it from the recorder may cause errors. - ******************************************************************************/ - -/* Gives the currently executing task (wrapper for RTOS-specific function) */ -void* prvTraceGetCurrentTaskHandle(void); - -#if (((TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) && (TRC_CFG_INCLUDE_ISR_TRACING == 1)) || (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)) -/* Tells if the scheduler currently is suspended (task-switches can't occur) */ -unsigned char prvTraceIsSchedulerSuspended(void); - -/******************************************************************************* - * INCLUDE_xTaskGetSchedulerState must be set to 1 for tracing to work properly - ******************************************************************************/ -#undef INCLUDE_xTaskGetSchedulerState -#define INCLUDE_xTaskGetSchedulerState 1 - -#endif /* (((TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) && (TRC_CFG_INCLUDE_ISR_TRACING == 1)) || (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)) */ - -#define TRACE_KERNEL_VERSION 0x1AA1 -#define TRACE_TICK_RATE_HZ configTICK_RATE_HZ /* Defined in "FreeRTOS.h" */ -#define TRACE_CPU_CLOCK_HZ configCPU_CLOCK_HZ /* Defined in "FreeRTOSConfig.h" */ -#define TRACE_GET_CURRENT_TASK() prvTraceGetCurrentTaskHandle() - -#define TRACE_GET_OS_TICKS() (uiTraceTickCount) /* Streaming only */ - -/* If using dynamic allocation of snapshot trace buffer... */ -#define TRACE_MALLOC(size) pvPortMalloc(size) - -#if defined(configUSE_TIMERS) -#if (configUSE_TIMERS == 1) -#undef INCLUDE_xTimerGetTimerDaemonTaskHandle -#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1 -#endif /* configUSE_TIMERS == 1*/ -#endif /* configUSE_TIMERS */ - -/* For ARM Cortex-M devices - assumes the ARM CMSIS API is available */ -#if (defined (__CORTEX_M)) - #define TRACE_ALLOC_CRITICAL_SECTION() uint32_t __irq_status; - #define TRACE_ENTER_CRITICAL_SECTION() {__irq_status = __get_PRIMASK(); __set_PRIMASK(1);} /* PRIMASK disables ALL interrupts - allows for tracing in any ISR */ - #define TRACE_EXIT_CRITICAL_SECTION() {__set_PRIMASK(__irq_status);} -#endif - -#if ((TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_CORTEX_A9) || (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Renesas_RX600) || (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_MICROCHIP_PIC24_PIC32) || (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Altera_NiosII)) - #define TRACE_ALLOC_CRITICAL_SECTION() int __irq_status; - #define TRACE_ENTER_CRITICAL_SECTION() {__irq_status = portSET_INTERRUPT_MASK_FROM_ISR();} - #define TRACE_EXIT_CRITICAL_SECTION() {portCLEAR_INTERRUPT_MASK_FROM_ISR(__irq_status);} -#endif - -#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Win32) - /* In the Win32 port, there are no real interrupts, so we can use the normal critical sections */ - #define TRACE_ALLOC_CRITICAL_SECTION() - #define TRACE_ENTER_CRITICAL_SECTION() portENTER_CRITICAL() - #define TRACE_EXIT_CRITICAL_SECTION() portEXIT_CRITICAL() -#endif - -#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_POWERPC_Z4) -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) - /* FreeRTOS v8.0 or later */ - #define TRACE_ALLOC_CRITICAL_SECTION() UBaseType_t __irq_status; - #define TRACE_ENTER_CRITICAL_SECTION() {__irq_status = portSET_INTERRUPT_MASK_FROM_ISR();} - #define TRACE_EXIT_CRITICAL_SECTION() {portCLEAR_INTERRUPT_MASK_FROM_ISR(__irq_status);} -#else - /* FreeRTOS v7.x */ - #define TRACE_ALLOC_CRITICAL_SECTION() unsigned portBASE_TYPE __irq_status; - #define TRACE_ENTER_CRITICAL_SECTION() {__irq_status = portSET_INTERRUPT_MASK_FROM_ISR();} - #define TRACE_EXIT_CRITICAL_SECTION() {portCLEAR_INTERRUPT_MASK_FROM_ISR(__irq_status);} -#endif -#endif - -#ifndef TRACE_ENTER_CRITICAL_SECTION - #error "This hardware port has no definition for critical sections! See http://percepio.com/2014/10/27/how-to-define-critical-sections-for-the-recorder/" -#endif - - -#if (TRC_CFG_FREERTOS_VERSION == TRC_FREERTOS_VERSION_9_0_1) - /****************************************************************************** - * Fix for FreeRTOS v9.0.1 to correctly identify xQueuePeek events. - * - * In FreeRTOS v9.0.1, the below trace hooks are incorrectly used from three - * different functions. This as the earlier function xQueueGenericReceive - * has been replaced by xQueuePeek, xQueueSemaphoreTake and xQueueReceive. - * - * xQueueGenericReceive had a parameter "xJustPeeking", used by the trace hooks - * to tell between xQueuePeek events and others. This is no longer present, so - * we need another way to correctly identify peek events. Since all three - * functions call the same trace macros, the context of these macro is unknown. - * - * We therefore check the __LINE__ macro inside of the trace macros. This gives - * the line number of queue.c, where the macros are used. This can be used to - * tell if the context is xQueuePeek or another function. - * __LINE__ is a standard compiler feature since ancient times, so it should - * work on all common compilers. - * - * This might seem as a quite brittle and unusual solution, but works in this - * particular case and is only for FreeRTOS v9.0.1. - * Future versions of FreeRTOS should not need this fix, as we have submitted - * a correction of queue.c with individual trace macros for each function. - ******************************************************************************/ -#define isQueueReceiveHookActuallyPeek (__LINE__ > 1674) /* Half way between the closes trace points */ - -#elif (TRC_CFG_FREERTOS_VERSION <= TRC_FREERTOS_VERSION_9_0_0) -#define isQueueReceiveHookActuallyPeek xJustPeeking - -#elif (TRC_CFG_FREERTOS_VERSION > TRC_FREERTOS_VERSION_9_0_1) -#define isQueueReceiveHookActuallyPeek (__LINE__ < 0) /* instead of pdFALSE to fix a warning of "constant condition" */ - -#endif - -extern uint16_t CurrentFilterMask; - -extern uint16_t CurrentFilterGroup; - -uint8_t prvTraceGetQueueType(void* handle); - -uint16_t prvTraceGetTaskNumberLow16(void* handle); -uint16_t prvTraceGetTaskNumberHigh16(void* handle); -void prvTraceSetTaskNumberLow16(void* handle, uint16_t value); -void prvTraceSetTaskNumberHigh16(void* handle, uint16_t value); - -uint16_t prvTraceGetQueueNumberLow16(void* handle); -uint16_t prvTraceGetQueueNumberHigh16(void* handle); -void prvTraceSetQueueNumberLow16(void* handle, uint16_t value); -void prvTraceSetQueueNumberHigh16(void* handle, uint16_t value); - -#if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) -uint16_t prvTraceGetTimerNumberLow16(void* handle); -uint16_t prvTraceGetTimerNumberHigh16(void* handle); -void prvTraceSetTimerNumberLow16(void* handle, uint16_t value); -void prvTraceSetTimerNumberHigh16(void* handle, uint16_t value); -#endif /* (TRC_CFG_INCLUDE_TIMER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ - -#if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) -uint16_t prvTraceGetEventGroupNumberLow16(void* handle); -uint16_t prvTraceGetEventGroupNumberHigh16(void* handle); -void prvTraceSetEventGroupNumberLow16(void* handle, uint16_t value); -void prvTraceSetEventGroupNumberHigh16(void* handle, uint16_t value); -#endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ - -#if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) -uint16_t prvTraceGetStreamBufferNumberLow16(void* handle); -uint16_t prvTraceGetStreamBufferNumberHigh16(void* handle); -void prvTraceSetStreamBufferNumberLow16(void* handle, uint16_t value); -void prvTraceSetStreamBufferNumberHigh16(void* handle, uint16_t value); -#endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ - -#define TRACE_GET_TASK_FILTER(pxTask) prvTraceGetTaskNumberHigh16((void*)pxTask) -#define TRACE_SET_TASK_FILTER(pxTask, group) prvTraceSetTaskNumberHigh16((void*)pxTask, group) - -#define TRACE_GET_QUEUE_FILTER(pxObject) prvTraceGetQueueNumberHigh16((void*)pxObject) -#define TRACE_SET_QUEUE_FILTER(pxObject, group) prvTraceSetQueueNumberHigh16((void*)pxObject, group) - -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) -#define TRACE_GET_EVENTGROUP_FILTER(pxObject) prvTraceGetEventGroupNumberHigh16((void*)pxObject) -#define TRACE_SET_EVENTGROUP_FILTER(pxObject, group) prvTraceSetEventGroupNumberHigh16((void*)pxObject, group) -#else /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ -/* FreeRTOS versions before v10.0 does not support filtering for event groups */ -#define TRACE_GET_EVENTGROUP_FILTER(pxObject) 1 -#define TRACE_SET_EVENTGROUP_FILTER(pxObject, group) -#endif /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ - -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) -#define TRACE_GET_TIMER_FILTER(pxObject) prvTraceGetTimerNumberHigh16((void*)pxObject) -#define TRACE_SET_TIMER_FILTER(pxObject, group) prvTraceSetTimerNumberHigh16((void*)pxObject, group) -#else /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ -/* FreeRTOS versions before v10.0 does not support filtering for timers */ -#define TRACE_GET_TIMER_FILTER(pxObject) 1 -#define TRACE_SET_TIMER_FILTER(pxObject, group) -#endif /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ - -#define TRACE_GET_STREAMBUFFER_FILTER(pxObject) prvTraceGetStreamBufferNumberHigh16((void*)pxObject) -#define TRACE_SET_STREAMBUFFER_FILTER(pxObject, group) prvTraceSetStreamBufferNumberHigh16((void*)pxObject, group) - -/* We can only support filtering if FreeRTOS is at least v7.4 */ -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_4) -#define TRACE_GET_OBJECT_FILTER(CLASS, pxObject) TRACE_GET_##CLASS##_FILTER(pxObject) -#define TRACE_SET_OBJECT_FILTER(CLASS, pxObject, group) TRACE_SET_##CLASS##_FILTER(pxObject, group) -#else /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_4) */ -#define TRACE_GET_OBJECT_FILTER(CLASS, pxObject) 1 -#define TRACE_SET_OBJECT_FILTER(CLASS, pxObject, group) -#endif /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_4) */ - -/******************************************************************************/ -/*** Definitions for Snapshot mode ********************************************/ -/******************************************************************************/ -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) - -/*** The object classes *******************************************************/ - -#define TRACE_NCLASSES 9 -#define TRACE_CLASS_QUEUE ((traceObjectClass)0) -#define TRACE_CLASS_SEMAPHORE ((traceObjectClass)1) -#define TRACE_CLASS_MUTEX ((traceObjectClass)2) -#define TRACE_CLASS_TASK ((traceObjectClass)3) -#define TRACE_CLASS_ISR ((traceObjectClass)4) -#define TRACE_CLASS_TIMER ((traceObjectClass)5) -#define TRACE_CLASS_EVENTGROUP ((traceObjectClass)6) -#define TRACE_CLASS_STREAMBUFFER ((traceObjectClass)7) -#define TRACE_CLASS_MESSAGEBUFFER ((traceObjectClass)8) - -/*** Definitions for Object Table ********************************************/ -#define TRACE_KERNEL_OBJECT_COUNT ((TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER) + (TRC_CFG_NEVENTGROUP) + (TRC_CFG_NSTREAMBUFFER) + (TRC_CFG_NMESSAGEBUFFER)) - -/* Queue properties (except name): current number of message in queue */ -#define PropertyTableSizeQueue ((TRC_CFG_NAME_LEN_QUEUE) + 1) - -/* Semaphore properties (except name): state (signaled = 1, cleared = 0) */ -#define PropertyTableSizeSemaphore ((TRC_CFG_NAME_LEN_SEMAPHORE) + 1) - -/* Mutex properties (except name): owner (task handle, 0 = free) */ -#define PropertyTableSizeMutex ((TRC_CFG_NAME_LEN_MUTEX) + 1) - -/* Task properties (except name): Byte 0: Current priority - Byte 1: state (if already active) - Byte 2: legacy, not used - Byte 3: legacy, not used */ -#define PropertyTableSizeTask ((TRC_CFG_NAME_LEN_TASK) + 4) - -/* ISR properties: Byte 0: priority - Byte 1: state (if already active) */ -#define PropertyTableSizeISR ((TRC_CFG_NAME_LEN_ISR) + 2) - -/* TRC_CFG_NTIMER properties: Byte 0: state (unused for now) */ -#define PropertyTableSizeTimer ((TRC_CFG_NAME_LEN_TIMER) + 1) - -/* TRC_CFG_NEVENTGROUP properties: Byte 0-3: state (unused for now)*/ -#define PropertyTableSizeEventGroup ((TRC_CFG_NAME_LEN_EVENTGROUP) + 4) - -/* TRC_CFG_NSTREAMBUFFER properties: Byte 0-3: state (unused for now)*/ -#define PropertyTableSizeStreamBuffer ((TRC_CFG_NAME_LEN_STREAMBUFFER) + 4) - -/* TRC_CFG_NMESSAGEBUFFER properties: Byte 0-3: state (unused for now)*/ -#define PropertyTableSizeMessageBuffer ((TRC_CFG_NAME_LEN_MESSAGEBUFFER) + 4) - - -/* The layout of the byte array representing the Object Property Table */ -#define StartIndexQueue (0) -#define StartIndexSemaphore (StartIndexQueue + (TRC_CFG_NQUEUE) * PropertyTableSizeQueue) -#define StartIndexMutex (StartIndexSemaphore + (TRC_CFG_NSEMAPHORE) * PropertyTableSizeSemaphore) -#define StartIndexTask (StartIndexMutex + (TRC_CFG_NMUTEX) * PropertyTableSizeMutex) -#define StartIndexISR (StartIndexTask + (TRC_CFG_NTASK) * PropertyTableSizeTask) -#define StartIndexTimer (StartIndexISR + (TRC_CFG_NISR) * PropertyTableSizeISR) -#define StartIndexEventGroup (StartIndexTimer + (TRC_CFG_NTIMER) * PropertyTableSizeTimer) -#define StartIndexStreamBuffer (StartIndexEventGroup + (TRC_CFG_NEVENTGROUP) * PropertyTableSizeEventGroup) -#define StartIndexMessageBuffer (StartIndexStreamBuffer + (TRC_CFG_NSTREAMBUFFER) * PropertyTableSizeStreamBuffer) - -/* Number of bytes used by the object table */ -#define TRACE_OBJECT_TABLE_SIZE (StartIndexMessageBuffer + (TRC_CFG_NMESSAGEBUFFER) * PropertyTableSizeMessageBuffer) - -/* Flag to tell the context of tracePEND_FUNC_CALL_FROM_ISR */ -extern int uiInEventGroupSetBitsFromISR; - -/* Initialization of the object property table */ -void vTraceInitObjectPropertyTable(void); - -/* Initialization of the handle mechanism, see e.g, prvTraceGetObjectHandle */ -void vTraceInitObjectHandleStack(void); - -/* Returns the "Not enough handles" error message for the specified object class */ -const char* pszTraceGetErrorNotEnoughHandles(traceObjectClass objectclass); - -void* prvTraceGetCurrentTaskHandle(void); - -/****************************************************************************** - * TraceQueueClassTable - * Translates a FreeRTOS QueueType into trace objects classes (TRACE_CLASS_). - * Has one entry for each QueueType, gives TRACE_CLASS ID. - ******************************************************************************/ -extern traceObjectClass TraceQueueClassTable[5]; - - -/*** Event codes for snapshot mode - must match Tracealyzer config files ******/ - -#define NULL_EVENT (0x00UL) - -/******************************************************************************* - * EVENTGROUP_DIV - * - * Miscellaneous events. - ******************************************************************************/ -#define EVENTGROUP_DIV (NULL_EVENT + 1UL) /*0x01*/ -#define DIV_XPS (EVENTGROUP_DIV + 0UL) /*0x01*/ -#define DIV_TASK_READY (EVENTGROUP_DIV + 1UL) /*0x02*/ -#define DIV_NEW_TIME (EVENTGROUP_DIV + 2UL) /*0x03*/ - -/******************************************************************************* - * EVENTGROUP_TS - * - * Events for storing task-switches and interrupts. The RESUME events are - * generated if the task/interrupt is already marked active. - ******************************************************************************/ -#define EVENTGROUP_TS (EVENTGROUP_DIV + 3UL) /*0x04*/ -#define TS_ISR_BEGIN (EVENTGROUP_TS + 0UL) /*0x04*/ -#define TS_ISR_RESUME (EVENTGROUP_TS + 1UL) /*0x05*/ -#define TS_TASK_BEGIN (EVENTGROUP_TS + 2UL) /*0x06*/ -#define TS_TASK_RESUME (EVENTGROUP_TS + 3UL) /*0x07*/ - -/******************************************************************************* - * EVENTGROUP_OBJCLOSE_NAME - * - * About Close Events - * When an object is evicted from the object property table (object close), two - * internal events are stored (EVENTGROUP_OBJCLOSE_NAME and - * EVENTGROUP_OBJCLOSE_PROP), containing the handle-name mapping and object - * properties valid up to this point. - ******************************************************************************/ -#define EVENTGROUP_OBJCLOSE_NAME_TRCSUCCESS (EVENTGROUP_TS + 4UL) /*0x08*/ - -/******************************************************************************* - * EVENTGROUP_OBJCLOSE_PROP - * - * The internal event carrying properties of deleted objects - * The handle and object class of the closed object is not stored in this event, - * but is assumed to be the same as in the preceding CLOSE event. Thus, these - * two events must be generated from within a critical section. - * When queues are closed, arg1 is the "state" property (i.e., number of - * buffered messages/signals). - * When actors are closed, arg1 is priority, arg2 is handle of the "instance - * finish" event, and arg3 is event code of the "instance finish" event. - * In this case, the lower three bits is the object class of the instance finish - * handle. The lower three bits are not used (always zero) when queues are - * closed since the queue type is given in the previous OBJCLOSE_NAME event. - ******************************************************************************/ -#define EVENTGROUP_OBJCLOSE_PROP_TRCSUCCESS (EVENTGROUP_OBJCLOSE_NAME_TRCSUCCESS + 8UL) /*0x10*/ - -/******************************************************************************* - * EVENTGROUP_CREATE - * - * The events in this group are used to log Kernel object creations. - * The lower three bits in the event code gives the object class, i.e., type of - * create operation (task, queue, semaphore, etc). - ******************************************************************************/ -#define EVENTGROUP_CREATE_OBJ_TRCSUCCESS (EVENTGROUP_OBJCLOSE_PROP_TRCSUCCESS + 8UL) /*0x18*/ - -/******************************************************************************* - * EVENTGROUP_SEND - * - * The events in this group are used to log Send/Give events on queues, - * semaphores and mutexes The lower three bits in the event code gives the - * object class, i.e., what type of object that is operated on (queue, semaphore - * or mutex). - ******************************************************************************/ -#define EVENTGROUP_SEND_TRCSUCCESS (EVENTGROUP_CREATE_OBJ_TRCSUCCESS + 8UL) /*0x20*/ - -/******************************************************************************* - * EVENTGROUP_RECEIVE - * - * The events in this group are used to log Receive/Take events on queues, - * semaphores and mutexes. The lower three bits in the event code gives the - * object class, i.e., what type of object that is operated on (queue, semaphore - * or mutex). - ******************************************************************************/ -#define EVENTGROUP_RECEIVE_TRCSUCCESS (EVENTGROUP_SEND_TRCSUCCESS + 8UL) /*0x28*/ - -/* Send/Give operations, from ISR */ -#define EVENTGROUP_SEND_FROM_ISR_TRCSUCCESS \ - (EVENTGROUP_RECEIVE_TRCSUCCESS + 8UL) /*0x30*/ - -/* Receive/Take operations, from ISR */ -#define EVENTGROUP_RECEIVE_FROM_ISR_TRCSUCCESS \ - (EVENTGROUP_SEND_FROM_ISR_TRCSUCCESS + 8UL) /*0x38*/ - -/* "Failed" event type versions of above (timeout, failed allocation, etc) */ -#define EVENTGROUP_KSE_TRCFAILED \ - (EVENTGROUP_RECEIVE_FROM_ISR_TRCSUCCESS + 8UL) /*0x40*/ - -/* Failed create calls - memory allocation failed */ -#define EVENTGROUP_CREATE_OBJ_TRCFAILED (EVENTGROUP_KSE_TRCFAILED) /*0x40*/ - -/* Failed send/give - timeout! */ -#define EVENTGROUP_SEND_TRCFAILED (EVENTGROUP_CREATE_OBJ_TRCFAILED + 8UL) /*0x48*/ - -/* Failed receive/take - timeout! */ -#define EVENTGROUP_RECEIVE_TRCFAILED (EVENTGROUP_SEND_TRCFAILED + 8UL) /*0x50*/ - -/* Failed non-blocking send/give - queue full */ -#define EVENTGROUP_SEND_FROM_ISR_TRCFAILED (EVENTGROUP_RECEIVE_TRCFAILED + 8UL) /*0x58*/ - -/* Failed non-blocking receive/take - queue empty */ -#define EVENTGROUP_RECEIVE_FROM_ISR_TRCFAILED \ - (EVENTGROUP_SEND_FROM_ISR_TRCFAILED + 8UL) /*0x60*/ - -/* Events when blocking on receive/take */ -#define EVENTGROUP_RECEIVE_TRCBLOCK \ - (EVENTGROUP_RECEIVE_FROM_ISR_TRCFAILED + 8UL) /*0x68*/ - -/* Events when blocking on send/give */ -#define EVENTGROUP_SEND_TRCBLOCK (EVENTGROUP_RECEIVE_TRCBLOCK + 8UL) /*0x70*/ - -/* Events on queue peek (receive) */ -#define EVENTGROUP_PEEK_TRCSUCCESS (EVENTGROUP_SEND_TRCBLOCK + 8UL) /*0x78*/ - -/* Events on object delete (vTaskDelete or vQueueDelete) */ -#define EVENTGROUP_DELETE_OBJ_TRCSUCCESS (EVENTGROUP_PEEK_TRCSUCCESS + 8UL) /*0x80*/ - -/* Other events - object class is implied: TASK */ -#define EVENTGROUP_OTHERS (EVENTGROUP_DELETE_OBJ_TRCSUCCESS + 8UL) /*0x88*/ -#define TASK_DELAY_UNTIL (EVENTGROUP_OTHERS + 0UL) /*0x88*/ -#define TASK_DELAY (EVENTGROUP_OTHERS + 1UL) /*0x89*/ -#define TASK_SUSPEND (EVENTGROUP_OTHERS + 2UL) /*0x8A*/ -#define TASK_RESUME (EVENTGROUP_OTHERS + 3UL) /*0x8B*/ -#define TASK_RESUME_FROM_ISR (EVENTGROUP_OTHERS + 4UL) /*0x8C*/ -#define TASK_PRIORITY_SET (EVENTGROUP_OTHERS + 5UL) /*0x8D*/ -#define TASK_PRIORITY_INHERIT (EVENTGROUP_OTHERS + 6UL) /*0x8E*/ -#define TASK_PRIORITY_DISINHERIT (EVENTGROUP_OTHERS + 7UL) /*0x8F*/ - -#define EVENTGROUP_MISC_PLACEHOLDER (EVENTGROUP_OTHERS + 8UL) /*0x90*/ -#define PEND_FUNC_CALL (EVENTGROUP_MISC_PLACEHOLDER+0UL) /*0x90*/ -#define PEND_FUNC_CALL_FROM_ISR (EVENTGROUP_MISC_PLACEHOLDER+1UL) /*0x91*/ -#define PEND_FUNC_CALL_TRCFAILED (EVENTGROUP_MISC_PLACEHOLDER+2UL) /*0x92*/ -#define PEND_FUNC_CALL_FROM_ISR_TRCFAILED (EVENTGROUP_MISC_PLACEHOLDER+3UL) /*0x93*/ -#define MEM_MALLOC_SIZE (EVENTGROUP_MISC_PLACEHOLDER+4UL) /*0x94*/ -#define MEM_MALLOC_ADDR (EVENTGROUP_MISC_PLACEHOLDER+5UL) /*0x95*/ -#define MEM_FREE_SIZE (EVENTGROUP_MISC_PLACEHOLDER+6UL) /*0x96*/ -#define MEM_FREE_ADDR (EVENTGROUP_MISC_PLACEHOLDER+7UL) /*0x97*/ - -/* User events */ -#define EVENTGROUP_USEREVENT (EVENTGROUP_MISC_PLACEHOLDER + 8UL) /*0x98*/ -#define USER_EVENT (EVENTGROUP_USEREVENT + 0UL) - -/* Allow for 0-15 arguments (the number of args is added to event code) */ -#define USER_EVENT_LAST (EVENTGROUP_USEREVENT + 15UL) /*0xA7*/ - -/******************************************************************************* - * XTS Event - eXtended TimeStamp events - * The timestamps used in the recorder are "differential timestamps" (DTS), i.e. - * the time since the last stored event. The DTS fields are either 1 or 2 bytes - * in the other events, depending on the bytes available in the event struct. - * If the time since the last event (the DTS) is larger than allowed for by - * the DTS field of the current event, an XTS event is inserted immediately - * before the original event. The XTS event contains up to 3 additional bytes - * of the DTS value - the higher bytes of the true DTS value. The lower 1-2 - * bytes are stored in the normal DTS field. - * There are two types of XTS events, XTS8 and XTS16. An XTS8 event is stored - * when there is only room for 1 byte (8 bit) DTS data in the original event, - * which means a limit of 0xFF (255UL). The XTS16 is used when the original event - * has a 16 bit DTS field and thereby can handle values up to 0xFFFF (65535UL). - * - * Using a very high frequency time base can result in many XTS events. - * Preferably, the time between two OS ticks should fit in 16 bits, i.e., - * at most 65535. If your time base has a higher frequency, you can define - * the TRACE - ******************************************************************************/ - -#define EVENTGROUP_SYS (EVENTGROUP_USEREVENT + 16UL) /*0xA8*/ -#define XTS8 (EVENTGROUP_SYS + 0UL) /*0xA8*/ -#define XTS16 (EVENTGROUP_SYS + 1UL) /*0xA9*/ -#define EVENT_BEING_WRITTEN (EVENTGROUP_SYS + 2UL) /*0xAA*/ -#define RESERVED_DUMMY_CODE (EVENTGROUP_SYS + 3UL) /*0xAB*/ -#define LOW_POWER_BEGIN (EVENTGROUP_SYS + 4UL) /*0xAC*/ -#define LOW_POWER_END (EVENTGROUP_SYS + 5UL) /*0xAD*/ -#define XID (EVENTGROUP_SYS + 6UL) /*0xAE*/ -#define XTS16L (EVENTGROUP_SYS + 7UL) /*0xAF*/ - -#define EVENTGROUP_TIMER (EVENTGROUP_SYS + 8UL) /*0xB0*/ -#define TIMER_CREATE (EVENTGROUP_TIMER + 0UL) /*0xB0*/ -#define TIMER_START (EVENTGROUP_TIMER + 1UL) /*0xB1*/ -#define TIMER_RST (EVENTGROUP_TIMER + 2UL) /*0xB2*/ -#define TIMER_STOP (EVENTGROUP_TIMER + 3UL) /*0xB3*/ -#define TIMER_CHANGE_PERIOD (EVENTGROUP_TIMER + 4UL) /*0xB4*/ -#define TIMER_DELETE_OBJ (EVENTGROUP_TIMER + 5UL) /*0xB5*/ -#define TIMER_START_FROM_ISR (EVENTGROUP_TIMER + 6UL) /*0xB6*/ -#define TIMER_RESET_FROM_ISR (EVENTGROUP_TIMER + 7UL) /*0xB7*/ -#define TIMER_STOP_FROM_ISR (EVENTGROUP_TIMER + 8UL) /*0xB8*/ - -#define TIMER_CREATE_TRCFAILED (EVENTGROUP_TIMER + 9UL) /*0xB9*/ -#define TIMER_START_TRCFAILED (EVENTGROUP_TIMER + 10UL) /*0xBA*/ -#define TIMER_RESET_TRCFAILED (EVENTGROUP_TIMER + 11UL) /*0xBB*/ -#define TIMER_STOP_TRCFAILED (EVENTGROUP_TIMER + 12UL) /*0xBC*/ -#define TIMER_CHANGE_PERIOD_TRCFAILED (EVENTGROUP_TIMER + 13UL) /*0xBD*/ -#define TIMER_DELETE_TRCFAILED (EVENTGROUP_TIMER + 14UL) /*0xBE*/ -#define TIMER_START_FROM_ISR_TRCFAILED (EVENTGROUP_TIMER + 15UL) /*0xBF*/ -#define TIMER_RESET_FROM_ISR_TRCFAILED (EVENTGROUP_TIMER + 16UL) /*0xC0*/ -#define TIMER_STOP_FROM_ISR_TRCFAILED (EVENTGROUP_TIMER + 17UL) /*0xC1*/ - -#define EVENTGROUP_EG (EVENTGROUP_TIMER + 18UL) /*0xC2*/ -#define EVENT_GROUP_CREATE (EVENTGROUP_EG + 0UL) /*0xC2*/ -#define EVENT_GROUP_CREATE_TRCFAILED (EVENTGROUP_EG + 1UL) /*0xC3*/ -#define EVENT_GROUP_SYNC_TRCBLOCK (EVENTGROUP_EG + 2UL) /*0xC4*/ -#define EVENT_GROUP_SYNC_END (EVENTGROUP_EG + 3UL) /*0xC5*/ -#define EVENT_GROUP_WAIT_BITS_TRCBLOCK (EVENTGROUP_EG + 4UL) /*0xC6*/ -#define EVENT_GROUP_WAIT_BITS_END (EVENTGROUP_EG + 5UL) /*0xC7*/ -#define EVENT_GROUP_CLEAR_BITS (EVENTGROUP_EG + 6UL) /*0xC8*/ -#define EVENT_GROUP_CLEAR_BITS_FROM_ISR (EVENTGROUP_EG + 7UL) /*0xC9*/ -#define EVENT_GROUP_SET_BITS (EVENTGROUP_EG + 8UL) /*0xCA*/ -#define EVENT_GROUP_DELETE_OBJ (EVENTGROUP_EG + 9UL) /*0xCB*/ -#define EVENT_GROUP_SYNC_END_TRCFAILED (EVENTGROUP_EG + 10UL) /*0xCC*/ -#define EVENT_GROUP_WAIT_BITS_END_TRCFAILED (EVENTGROUP_EG + 11UL) /*0xCD*/ -#define EVENT_GROUP_SET_BITS_FROM_ISR (EVENTGROUP_EG + 12UL) /*0xCE*/ -#define EVENT_GROUP_SET_BITS_FROM_ISR_TRCFAILED (EVENTGROUP_EG + 13UL) /*0xCF*/ - -#define TASK_INSTANCE_FINISHED_NEXT_KSE (EVENTGROUP_EG + 14UL) /*0xD0*/ -#define TASK_INSTANCE_FINISHED_DIRECT (EVENTGROUP_EG + 15UL) /*0xD1*/ - -#define TRACE_TASK_NOTIFY_GROUP (EVENTGROUP_EG + 16UL) /*0xD2*/ -#define TRACE_TASK_NOTIFY (TRACE_TASK_NOTIFY_GROUP + 0UL) /*0xD2*/ -#define TRACE_TASK_NOTIFY_TAKE (TRACE_TASK_NOTIFY_GROUP + 1UL) /*0xD3*/ -#define TRACE_TASK_NOTIFY_TAKE_TRCBLOCK (TRACE_TASK_NOTIFY_GROUP + 2UL) /*0xD4*/ -#define TRACE_TASK_NOTIFY_TAKE_TRCFAILED (TRACE_TASK_NOTIFY_GROUP + 3UL) /*0xD5*/ -#define TRACE_TASK_NOTIFY_WAIT (TRACE_TASK_NOTIFY_GROUP + 4UL) /*0xD6*/ -#define TRACE_TASK_NOTIFY_WAIT_TRCBLOCK (TRACE_TASK_NOTIFY_GROUP + 5UL) /*0xD7*/ -#define TRACE_TASK_NOTIFY_WAIT_TRCFAILED (TRACE_TASK_NOTIFY_GROUP + 6UL) /*0xD8*/ -#define TRACE_TASK_NOTIFY_FROM_ISR (TRACE_TASK_NOTIFY_GROUP + 7UL) /*0xD9*/ -#define TRACE_TASK_NOTIFY_GIVE_FROM_ISR (TRACE_TASK_NOTIFY_GROUP + 8UL) /*0xDA*/ - -#define TIMER_EXPIRED (TRACE_TASK_NOTIFY_GROUP + 9UL) /* 0xDB */ - - /* Events on queue peek (receive) */ -#define EVENTGROUP_PEEK_TRCBLOCK (TRACE_TASK_NOTIFY_GROUP + 10UL) /*0xDC*/ -/* peek block on queue: 0xDC */ -/* peek block on semaphore: 0xDD */ -/* peek block on mutex: 0xDE */ - -/* Events on queue peek (receive) */ -#define EVENTGROUP_PEEK_TRCFAILED (EVENTGROUP_PEEK_TRCBLOCK + 3UL) /*0xDF*/ -/* peek failed on queue: 0xDF */ -/* peek failed on semaphore: 0xE0 */ -/* peek failed on mutex: 0xE1 */ - -#define EVENTGROUP_STREAMBUFFER_DIV (EVENTGROUP_PEEK_TRCFAILED + 3UL) /*0xE2*/ -#define TRACE_STREAMBUFFER_RESET (EVENTGROUP_STREAMBUFFER_DIV + 0) /*0xE2*/ -#define TRACE_MESSAGEBUFFER_RESET (EVENTGROUP_STREAMBUFFER_DIV + 1UL) /*0xE3*/ -#define TRACE_STREAMBUFFER_OBJCLOSE_NAME_TRCSUCCESS (EVENTGROUP_STREAMBUFFER_DIV + 2UL) /*0xE4*/ -#define TRACE_MESSAGEBUFFER_OBJCLOSE_NAME_TRCSUCCESS (EVENTGROUP_STREAMBUFFER_DIV + 3UL) /*0xE5*/ -#define TRACE_STREAMBUFFER_OBJCLOSE_PROP_TRCSUCCESS (EVENTGROUP_STREAMBUFFER_DIV + 4UL) /*0xE6*/ -#define TRACE_MESSAGEBUFFER_OBJCLOSE_PROP_TRCSUCCESS (EVENTGROUP_STREAMBUFFER_DIV + 5UL) /*0xE7*/ - -/* The following are using previously "lost" event codes */ -#define TRACE_STREAMBUFFER_CREATE_OBJ_TRCSUCCESS (EVENTGROUP_CREATE_OBJ_TRCSUCCESS + 4UL) /*0x1C*/ -#define TRACE_STREAMBUFFER_CREATE_OBJ_TRCFAILED (EVENTGROUP_CREATE_OBJ_TRCFAILED + 4UL) /*0x44*/ -#define TRACE_STREAMBUFFER_DELETE_OBJ_TRCSUCCESS (EVENTGROUP_DELETE_OBJ_TRCSUCCESS + 4UL) /*0x84*/ -#define TRACE_STREAMBUFFER_SEND_TRCSUCCESS (EVENTGROUP_SEND_TRCSUCCESS + 3UL) /*0x23*/ -#define TRACE_STREAMBUFFER_SEND_TRCBLOCK (EVENTGROUP_SEND_TRCBLOCK + 3UL) /*0x73*/ -#define TRACE_STREAMBUFFER_SEND_TRCFAILED (EVENTGROUP_SEND_TRCFAILED + 3UL) /*0x4B*/ -#define TRACE_STREAMBUFFER_RECEIVE_TRCSUCCESS (EVENTGROUP_RECEIVE_TRCSUCCESS + 3UL) /*0x2B*/ -#define TRACE_STREAMBUFFER_RECEIVE_TRCBLOCK (EVENTGROUP_RECEIVE_TRCBLOCK + 3UL) /*0x6B*/ -#define TRACE_STREAMBUFFER_RECEIVE_TRCFAILED (EVENTGROUP_RECEIVE_TRCFAILED + 3UL) /*0x53*/ -#define TRACE_STREAMBUFFER_SEND_FROM_ISR_TRCSUCCESS (EVENTGROUP_SEND_FROM_ISR_TRCSUCCESS + 3UL) /*0x33*/ -#define TRACE_STREAMBUFFER_SEND_FROM_ISR_TRCFAILED (EVENTGROUP_SEND_FROM_ISR_TRCFAILED + 3UL) /*0x5B*/ -#define TRACE_STREAMBUFFER_RECEIVE_FROM_ISR_TRCSUCCESS (EVENTGROUP_RECEIVE_FROM_ISR_TRCSUCCESS + 3UL) /*0x3B*/ -#define TRACE_STREAMBUFFER_RECEIVE_FROM_ISR_TRCFAILED (EVENTGROUP_RECEIVE_FROM_ISR_TRCFAILED + 3UL) /*0x63*/ - -/* The following are using previously "lost" event codes. These macros aren't even directly referenced, instead we do (equivalent STREAMBUFFER code) + 1. */ -#define TRACE_MESSAGEBUFFER_CREATE_OBJ_TRCSUCCESS (EVENTGROUP_CREATE_OBJ_TRCSUCCESS + 5UL) /*0x1D*/ -#define TRACE_MESSAGEBUFFER_CREATE_OBJ_TRCFAILED (EVENTGROUP_CREATE_OBJ_TRCFAILED + 5UL) /*0x45*/ -#define TRACE_MESSAGEBUFFER_DELETE_OBJ_TRCSUCCESS (EVENTGROUP_DELETE_OBJ_TRCSUCCESS + 5UL) /*0x85*/ -#define TRACE_MESSAGEBUFFER_SEND_TRCSUCCESS (EVENTGROUP_SEND_TRCSUCCESS + 4UL) /*0x24*/ -#define TRACE_MESSAGEBUFFER_SEND_TRCBLOCK (EVENTGROUP_SEND_TRCBLOCK + 4UL) /*0x74*/ -#define TRACE_MESSAGEBUFFER_SEND_TRCFAILED (EVENTGROUP_SEND_TRCFAILED + 4UL) /*0x4C*/ -#define TRACE_MESSAGEBUFFER_RECEIVE_TRCSUCCESS (EVENTGROUP_RECEIVE_TRCSUCCESS + 4UL) /*0x2C*/ -#define TRACE_MESSAGEBUFFER_RECEIVE_TRCBLOCK (EVENTGROUP_RECEIVE_TRCBLOCK + 4UL) /*0x6C*/ -#define TRACE_MESSAGEBUFFER_RECEIVE_TRCFAILED (EVENTGROUP_RECEIVE_TRCFAILED + 4UL) /*0x54*/ -#define TRACE_MESSAGEBUFFER_SEND_FROM_ISR_TRCSUCCESS (EVENTGROUP_SEND_FROM_ISR_TRCSUCCESS + 4UL) /*0x34*/ -#define TRACE_MESSAGEBUFFER_SEND_FROM_ISR_TRCFAILED (EVENTGROUP_SEND_FROM_ISR_TRCFAILED + 4UL) /*0x5C*/ -#define TRACE_MESSAGEBUFFER_RECEIVE_FROM_ISR_TRCSUCCESS (EVENTGROUP_RECEIVE_FROM_ISR_TRCSUCCESS + 4UL) /*0x3C*/ -#define TRACE_MESSAGEBUFFER_RECEIVE_FROM_ISR_TRCFAILED (EVENTGROUP_RECEIVE_FROM_ISR_TRCFAILED + 4UL) /*0x64*/ - -/* LAST EVENT (0xE7) */ - -/**************************** -* MACROS TO GET TRACE CLASS * -****************************/ -#define TRACE_GET_TRACE_CLASS_FROM_TASK_CLASS(kernelClass) (TRACE_CLASS_TASK) -#define TRACE_GET_TRACE_CLASS_FROM_TASK_OBJECT(pxObject) (TRACE_CLASS_TASK) - -#define TRACE_GET_TRACE_CLASS_FROM_QUEUE_CLASS(kernelClass) TraceQueueClassTable[kernelClass] -#define TRACE_GET_TRACE_CLASS_FROM_QUEUE_OBJECT(pxObject) TRACE_GET_TRACE_CLASS_FROM_QUEUE_CLASS(prvTraceGetQueueType(pxObject)) - -#define TRACE_GET_TRACE_CLASS_FROM_TIMER_CLASS(kernelClass) (TRACE_CLASS_TIMER) -#define TRACE_GET_TRACE_CLASS_FROM_TIMER_OBJECT(pxObject) (TRACE_CLASS_TIMER) - -#define TRACE_GET_TRACE_CLASS_FROM_EVENTGROUP_CLASS(kernelClass) (TRACE_CLASS_EVENTGROUP) -#define TRACE_GET_TRACE_CLASS_FROM_EVENTGROUP_OBJECT(pxObject) (TRACE_CLASS_EVENTGROUP) - -/* TRACE_GET_TRACE_CLASS_FROM_STREAMBUFFER_CLASS can only be accessed with a parameter indicating if it is a MessageBuffer */ -#define TRACE_GET_TRACE_CLASS_FROM_STREAMBUFFER_CLASS(xIsMessageBuffer) (xIsMessageBuffer == 1 ? TRACE_CLASS_MESSAGEBUFFER : TRACE_CLASS_STREAMBUFFER) -#define TRACE_GET_TRACE_CLASS_FROM_STREAMBUFFER_OBJECT(pxObject) (prvGetStreamBufferType(pxObject) == 1 ? TRACE_CLASS_MESSAGEBUFFER : TRACE_CLASS_STREAMBUFFER) - -/* Generic versions */ -#define TRACE_GET_CLASS_TRACE_CLASS(CLASS, kernelClass) TRACE_GET_TRACE_CLASS_FROM_##CLASS##_CLASS(kernelClass) -#define TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject) TRACE_GET_TRACE_CLASS_FROM_##CLASS##_OBJECT(pxObject) - -/****************************** -* MACROS TO GET OBJECT NUMBER * -******************************/ -#define TRACE_GET_TASK_NUMBER(pxTCB) (traceHandle)(prvTraceGetTaskNumberLow16(pxTCB)) -#define TRACE_SET_TASK_NUMBER(pxTCB) prvTraceSetTaskNumberLow16(pxTCB, prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(TASK, pxTCB))); - -#define TRACE_GET_QUEUE_NUMBER(queue) ( ( traceHandle ) prvTraceGetQueueNumberLow16(queue) ) -#define TRACE_SET_QUEUE_NUMBER(queue) prvTraceSetQueueNumberLow16(queue, (uint16_t)prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, queue))); - -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) -#define TRACE_GET_TIMER_NUMBER(tmr) ( ( traceHandle ) prvTraceGetTimerNumberLow16(tmr) ) -#define TRACE_SET_TIMER_NUMBER(tmr) prvTraceSetTimerNumberLow16(tmr, (uint16_t)prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(TIMER, tmr))); -#else /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ -#define TRACE_GET_TIMER_NUMBER(tmr) ( ( traceHandle ) ((Timer_t*)tmr)->uxTimerNumber ) -#define TRACE_SET_TIMER_NUMBER(tmr) ((Timer_t*)tmr)->uxTimerNumber = prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(TIMER, tmr)); -#endif /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ - -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) -#define TRACE_GET_EVENTGROUP_NUMBER(eg) ( ( traceHandle ) prvTraceGetEventGroupNumberLow16(eg) ) -#define TRACE_SET_EVENTGROUP_NUMBER(eg) prvTraceSetEventGroupNumberLow16(eg, (uint16_t)prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(EVENTGROUP, eg))); -#else /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ -#define TRACE_GET_EVENTGROUP_NUMBER(eg) ( ( traceHandle ) uxEventGroupGetNumber(eg) ) -#define TRACE_SET_EVENTGROUP_NUMBER(eg) ((EventGroup_t*)eg)->uxEventGroupNumber = prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(EVENTGROUP, eg)); -#endif /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ - - -#define TRACE_GET_STREAMBUFFER_NUMBER(sb) ( ( traceHandle ) prvTraceGetStreamBufferNumberLow16(sb) ) -#define TRACE_SET_STREAMBUFFER_NUMBER(sb) prvTraceSetStreamBufferNumberLow16(sb, (uint16_t)prvTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(STREAMBUFFER, sb))); - -/* Generic versions */ -#define TRACE_GET_OBJECT_NUMBER(CLASS, pxObject) TRACE_GET_##CLASS##_NUMBER(pxObject) -#define TRACE_SET_OBJECT_NUMBER(CLASS, pxObject) TRACE_SET_##CLASS##_NUMBER(pxObject) - -/****************************** -* MACROS TO GET EVENT CODES * -******************************/ -#define TRACE_GET_TASK_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_GET_CLASS_TRACE_CLASS(TASK, kernelClass)) -#define TRACE_GET_QUEUE_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_GET_CLASS_TRACE_CLASS(QUEUE, kernelClass)) -#define TRACE_GET_TIMER_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass) -- THIS IS NOT USED -- -#define TRACE_GET_EVENTGROUP_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass) -- THIS IS NOT USED -- -#define TRACE_GET_STREAMBUFFER_CLASS_EVENT_CODE(SERVICE, RESULT, isMessageBuffer) (uint8_t)(TRACE_STREAMBUFFER_##SERVICE##_##RESULT + (uint8_t)isMessageBuffer) - -#define TRACE_GET_TASK_OBJECT_EVENT_CODE(SERVICE, RESULT, pxTCB) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_CLASS_TASK) -#define TRACE_GET_QUEUE_OBJECT_EVENT_CODE(SERVICE, RESULT, pxObject) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, pxObject)) -#define TRACE_GET_TIMER_OBJECT_EVENT_CODE(SERVICE, RESULT, UNUSED) -- THIS IS NOT USED -- -#define TRACE_GET_EVENTGROUP_OBJECT_EVENT_CODE(SERVICE, RESULT, UNUSED) -- THIS IS NOT USED -- -#define TRACE_GET_STREAMBUFFER_OBJECT_EVENT_CODE(SERVICE, RESULT, pxObject) (uint8_t)(TRACE_STREAMBUFFER_##SERVICE##_##RESULT + prvGetStreamBufferType(pxObject)) - -/* Generic versions */ -#define TRACE_GET_CLASS_EVENT_CODE(SERVICE, RESULT, CLASS, kernelClass) TRACE_GET_##CLASS##_CLASS_EVENT_CODE(SERVICE, RESULT, kernelClass) -#define TRACE_GET_OBJECT_EVENT_CODE(SERVICE, RESULT, CLASS, pxObject) TRACE_GET_##CLASS##_OBJECT_EVENT_CODE(SERVICE, RESULT, pxObject) - -/****************************** -* SPECIAL MACROS FOR TASKS * -******************************/ -#define TRACE_GET_TASK_PRIORITY(pxTCB) ((uint8_t)pxTCB->uxPriority) -#define TRACE_GET_TASK_NAME(pxTCB) ((char*)pxTCB->pcTaskName) - -/*** The trace macros for snapshot mode **************************************/ - -/* A macro that will update the tick count when returning from tickless idle */ -#undef traceINCREASE_TICK_COUNT -#define traceINCREASE_TICK_COUNT( xCount ) - -/* Called for each task that becomes ready */ -#undef traceMOVED_TASK_TO_READY_STATE -#define traceMOVED_TASK_TO_READY_STATE( pxTCB ) \ - trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE(pxTCB); - -/* Called on each OS tick. Will call uiPortGetTimestamp to make sure it is called at least once every OS tick. */ -#undef traceTASK_INCREMENT_TICK - -#if (TRC_CFG_FREERTOS_VERSION <= TRC_FREERTOS_VERSION_7_4) - -#define traceTASK_INCREMENT_TICK( xTickCount ) \ - if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxMissedTicks == 0) { trcKERNEL_HOOKS_INCREMENT_TICK(); } \ - if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE) { trcKERNEL_HOOKS_NEW_TIME(DIV_NEW_TIME, xTickCount + 1); } - -#else - -#define traceTASK_INCREMENT_TICK( xTickCount ) \ - if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxPendedTicks == 0) { trcKERNEL_HOOKS_INCREMENT_TICK(); } \ - if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE) { trcKERNEL_HOOKS_NEW_TIME(DIV_NEW_TIME, xTickCount + 1); } - -#endif - -/* Called on each task-switch */ -#undef traceTASK_SWITCHED_IN -#define traceTASK_SWITCHED_IN() \ - trcKERNEL_HOOKS_TASK_SWITCH(TRACE_GET_CURRENT_TASK()); - -/* Called on vTaskCreate */ -#undef traceTASK_CREATE -#define traceTASK_CREATE(pxNewTCB) \ - if (pxNewTCB != NULL) \ - { \ - trcKERNEL_HOOKS_TASK_CREATE(TRACE_GET_OBJECT_EVENT_CODE(CREATE_OBJ, TRCSUCCESS, TASK, pxNewTCB), TASK, pxNewTCB); \ - } - -/* Called in vTaskCreate, if it fails (typically if the stack can not be allocated) */ -#undef traceTASK_CREATE_FAILED -#define traceTASK_CREATE_FAILED() \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(TRACE_GET_CLASS_EVENT_CODE(CREATE_OBJ, TRCFAILED, TASK, NOT_USED), 0); - -/* Called on vTaskDelete */ -#undef traceTASK_DELETE -#define traceTASK_DELETE( pxTaskToDelete ) \ - { TRACE_ALLOC_CRITICAL_SECTION(); \ - TRACE_ENTER_CRITICAL_SECTION(); \ - trcKERNEL_HOOKS_TASK_DELETE(TRACE_GET_OBJECT_EVENT_CODE(DELETE_OBJ, TRCSUCCESS, TASK, pxTaskToDelete), TRACE_GET_OBJECT_EVENT_CODE(OBJCLOSE_NAME, TRCSUCCESS, TASK, pxTaskToDelete), TRACE_GET_OBJECT_EVENT_CODE(OBJCLOSE_PROP, TRCSUCCESS, TASK, pxTaskToDelete), pxTaskToDelete); \ - TRACE_EXIT_CRITICAL_SECTION(); } - -#if (TRC_CFG_SCHEDULING_ONLY == 0) - -#if defined(configUSE_TICKLESS_IDLE) -#if (configUSE_TICKLESS_IDLE != 0) - -#undef traceLOW_POWER_IDLE_BEGIN -#define traceLOW_POWER_IDLE_BEGIN() \ - { \ - extern uint32_t trace_disable_timestamp; \ - prvTraceStoreLowPower(0); \ - trace_disable_timestamp = 1; \ - } - -#undef traceLOW_POWER_IDLE_END -#define traceLOW_POWER_IDLE_END() \ - { \ - extern uint32_t trace_disable_timestamp; \ - trace_disable_timestamp = 0; \ - prvTraceStoreLowPower(1); \ - } - -#endif /* (configUSE_TICKLESS_IDLE != 0) */ -#endif /* defined(configUSE_TICKLESS_IDLE) */ - -/* Called on vTaskSuspend */ -#undef traceTASK_SUSPEND -#define traceTASK_SUSPEND( pxTaskToSuspend ) \ - trcKERNEL_HOOKS_TASK_SUSPEND(TASK_SUSPEND, pxTaskToSuspend); - -/* Called from special case with timer only */ -#undef traceTASK_DELAY_SUSPEND -#define traceTASK_DELAY_SUSPEND( pxTaskToSuspend ) \ - trcKERNEL_HOOKS_TASK_SUSPEND(TASK_SUSPEND, pxTaskToSuspend); \ - trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(); - -/* Called on vTaskDelay - note the use of FreeRTOS variable xTicksToDelay */ -#undef traceTASK_DELAY -#define traceTASK_DELAY() \ - trcKERNEL_HOOKS_TASK_DELAY(TASK_DELAY, pxCurrentTCB, xTicksToDelay); \ - trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(); - -/* Called on vTaskDelayUntil - note the use of FreeRTOS variable xTimeToWake */ -#undef traceTASK_DELAY_UNTIL -#if TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 -#define traceTASK_DELAY_UNTIL(xTimeToWake) \ - trcKERNEL_HOOKS_TASK_DELAY(TASK_DELAY_UNTIL, pxCurrentTCB, xTimeToWake); \ - trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(); -#else /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */ -#define traceTASK_DELAY_UNTIL() \ - trcKERNEL_HOOKS_TASK_DELAY(TASK_DELAY_UNTIL, pxCurrentTCB, xTimeToWake); \ - trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(); -#endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */ - -/* Called in xQueueCreate, and thereby for all other object based on queues, such as semaphores. */ -#undef traceQUEUE_CREATE -#define traceQUEUE_CREATE( pxNewQueue ) \ - trcKERNEL_HOOKS_OBJECT_CREATE(TRACE_GET_OBJECT_EVENT_CODE(CREATE_OBJ, TRCSUCCESS, QUEUE, pxNewQueue), QUEUE, pxNewQueue); - -/* Called in xQueueCreate, if the queue creation fails */ -#undef traceQUEUE_CREATE_FAILED -#define traceQUEUE_CREATE_FAILED( queueType ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(TRACE_GET_CLASS_EVENT_CODE(CREATE_OBJ, TRCFAILED, QUEUE, queueType), 0); - -/* Called on vQueueDelete */ -#undef traceQUEUE_DELETE -#define traceQUEUE_DELETE( pxQueue ) \ - { TRACE_ALLOC_CRITICAL_SECTION(); \ - TRACE_ENTER_CRITICAL_SECTION(); \ - trcKERNEL_HOOKS_OBJECT_DELETE(TRACE_GET_OBJECT_EVENT_CODE(DELETE_OBJ, TRCSUCCESS, QUEUE, pxQueue), TRACE_GET_OBJECT_EVENT_CODE(OBJCLOSE_NAME, TRCSUCCESS, QUEUE, pxQueue), TRACE_GET_OBJECT_EVENT_CODE(OBJCLOSE_PROP, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \ - TRACE_EXIT_CRITICAL_SECTION(); } - -/* This macro is not necessary as of FreeRTOS v9.0.0 */ -#if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0) -/* Called in xQueueCreateMutex, and thereby also from xSemaphoreCreateMutex and xSemaphoreCreateRecursiveMutex */ -#undef traceCREATE_MUTEX -#define traceCREATE_MUTEX( pxNewQueue ) \ - trcKERNEL_HOOKS_OBJECT_CREATE(TRACE_GET_OBJECT_EVENT_CODE(CREATE_OBJ, TRCSUCCESS, QUEUE, pxNewQueue), QUEUE, pxNewQueue); - -/* Called in xQueueCreateMutex when the operation fails (when memory allocation fails) */ -#undef traceCREATE_MUTEX_FAILED -#define traceCREATE_MUTEX_FAILED() \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(TRACE_GET_CLASS_EVENT_CODE(CREATE_OBJ, TRCFAILED, QUEUE, queueQUEUE_TYPE_MUTEX), 0); -#endif /* (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0) */ - -/* Called when the Mutex can not be given, since not holder */ -#undef traceGIVE_MUTEX_RECURSIVE_FAILED -#define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCFAILED, QUEUE, pxMutex), QUEUE, pxMutex); - -/* Called when a message is sent to a queue */ /* CS IS NEW ! */ -#undef traceQUEUE_SEND -#define traceQUEUE_SEND( pxQueue ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \ - trcKERNEL_HOOKS_SET_OBJECT_STATE(QUEUE, pxQueue, TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, pxQueue) == TRACE_CLASS_MUTEX ? (uint8_t)0 : (uint8_t)(pxQueue->uxMessagesWaiting + 1)); - -/* Called when a message failed to be sent to a queue (timeout) */ -#undef traceQUEUE_SEND_FAILED -#define traceQUEUE_SEND_FAILED( pxQueue ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue); - -/* Called when the task is blocked due to a send operation on a full queue */ -#undef traceBLOCKING_ON_QUEUE_SEND -#define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCBLOCK, QUEUE, pxQueue), QUEUE, pxQueue); - -/* Called when a message is received from a queue */ -#undef traceQUEUE_RECEIVE -#define traceQUEUE_RECEIVE( pxQueue ) \ - if (isQueueReceiveHookActuallyPeek) \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \ - } \ - else \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \ - } \ - trcKERNEL_HOOKS_SET_OBJECT_STATE(QUEUE, pxQueue, TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, pxQueue) == TRACE_CLASS_MUTEX ? (uint8_t)TRACE_GET_TASK_NUMBER(TRACE_GET_CURRENT_TASK()) : (uint8_t)(pxQueue->uxMessagesWaiting - 1)); - -/* Called when a receive operation on a queue fails (timeout) */ -#undef traceQUEUE_RECEIVE_FAILED -#define traceQUEUE_RECEIVE_FAILED( pxQueue ) \ - if (isQueueReceiveHookActuallyPeek) \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue); \ - } \ - else \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue); \ - } - -/* Called when the task is blocked due to a receive operation on an empty queue */ -#undef traceBLOCKING_ON_QUEUE_RECEIVE -#define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) \ - if (isQueueReceiveHookActuallyPeek) \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCBLOCK, QUEUE, pxQueue), QUEUE, pxQueue); \ - } \ - else \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCBLOCK, QUEUE, pxQueue), QUEUE, pxQueue); \ - } \ - if (TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, pxQueue) != TRACE_CLASS_MUTEX) \ - { \ - trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(); \ - } - -/* Called on xQueuePeek */ -#undef traceQUEUE_PEEK -#define traceQUEUE_PEEK( pxQueue ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); - -/* Called on xQueuePeek fail/timeout (added in FreeRTOS v9.0.2) */ -#undef traceQUEUE_PEEK_FAILED -#define traceQUEUE_PEEK_FAILED( pxQueue ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue); - -/* Called on xQueuePeek blocking (added in FreeRTOS v9.0.2) */ -#undef traceBLOCKING_ON_QUEUE_PEEK -#define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(PEEK, TRCBLOCK, QUEUE, pxQueue), QUEUE, pxQueue); \ - if (TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, pxQueue) != TRACE_CLASS_MUTEX) \ - { \ - trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(); \ - } - -/* Called when a message is sent from interrupt context, e.g., using xQueueSendFromISR */ -#undef traceQUEUE_SEND_FROM_ISR -#define traceQUEUE_SEND_FROM_ISR( pxQueue ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(SEND_FROM_ISR, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \ - trcKERNEL_HOOKS_SET_OBJECT_STATE(QUEUE, pxQueue, (uint8_t)(pxQueue->uxMessagesWaiting + 1)); - -/* Called when a message send from interrupt context fails (since the queue was full) */ -#undef traceQUEUE_SEND_FROM_ISR_FAILED -#define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(SEND_FROM_ISR, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue); - -/* Called when a message is received in interrupt context, e.g., using xQueueReceiveFromISR */ -#undef traceQUEUE_RECEIVE_FROM_ISR -#define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE_FROM_ISR, TRCSUCCESS, QUEUE, pxQueue), QUEUE, pxQueue); \ - trcKERNEL_HOOKS_SET_OBJECT_STATE(QUEUE, pxQueue, (uint8_t)(pxQueue->uxMessagesWaiting - 1)); - -/* Called when a message receive from interrupt context fails (since the queue was empty) */ -#undef traceQUEUE_RECEIVE_FROM_ISR_FAILED -#define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE_FROM_ISR, TRCFAILED, QUEUE, pxQueue), QUEUE, pxQueue); - -#undef traceQUEUE_REGISTRY_ADD -#define traceQUEUE_REGISTRY_ADD(object, name) prvTraceSetObjectName(TRACE_GET_OBJECT_TRACE_CLASS(QUEUE, object), TRACE_GET_OBJECT_NUMBER(QUEUE, object), name); - -/* Called in vTaskPrioritySet */ -#undef traceTASK_PRIORITY_SET -#define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) \ - trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(TASK_PRIORITY_SET, pxTask, uxNewPriority); - -/* Called in vTaskPriorityInherit, which is called by Mutex operations */ -#undef traceTASK_PRIORITY_INHERIT -#define traceTASK_PRIORITY_INHERIT( pxTask, uxNewPriority ) \ - trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(TASK_PRIORITY_INHERIT, pxTask, uxNewPriority); - -/* Called in vTaskPriorityDisinherit, which is called by Mutex operations */ -#undef traceTASK_PRIORITY_DISINHERIT -#define traceTASK_PRIORITY_DISINHERIT( pxTask, uxNewPriority ) \ - trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(TASK_PRIORITY_DISINHERIT, pxTask, uxNewPriority); - -/* Called in vTaskResume */ -#undef traceTASK_RESUME -#define traceTASK_RESUME( pxTaskToResume ) \ - trcKERNEL_HOOKS_TASK_RESUME(TASK_RESUME, pxTaskToResume); - -/* Called in vTaskResumeFromISR */ -#undef traceTASK_RESUME_FROM_ISR -#define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) \ - trcKERNEL_HOOKS_TASK_RESUME_FROM_ISR(TASK_RESUME_FROM_ISR, pxTaskToResume); - - -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) - -#if (TRC_CFG_INCLUDE_MEMMANG_EVENTS == 1) - -extern void vTraceStoreMemMangEvent(uint32_t ecode, uint32_t address, int32_t size); - -/* MALLOC and FREE are always stored, no matter if they happen inside filtered task */ -#undef traceMALLOC -#define traceMALLOC( pvAddress, uiSize ) \ - if (pvAddress != 0) \ - vTraceStoreMemMangEvent(MEM_MALLOC_SIZE, ( uint32_t ) pvAddress, (int32_t)uiSize); - -#undef traceFREE -#define traceFREE( pvAddress, uiSize ) \ - vTraceStoreMemMangEvent(MEM_FREE_SIZE, ( uint32_t ) pvAddress, -((int32_t)uiSize)); - -#endif /* (TRC_CFG_INCLUDE_MEMMANG_EVENTS == 1) */ - -#if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1) - -/* Called in timer.c - xTimerCreate */ -#undef traceTIMER_CREATE -#define traceTIMER_CREATE(tmr) \ - trcKERNEL_HOOKS_OBJECT_CREATE(TIMER_CREATE, TIMER, tmr); - -#undef traceTIMER_CREATE_FAILED -#define traceTIMER_CREATE_FAILED() \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(TIMER_CREATE_TRCFAILED, 0); - -/* Note that xCommandID can never be tmrCOMMAND_EXECUTE_CALLBACK (-1) since the trace macro is not called in that case */ -#undef traceTIMER_COMMAND_SEND -#define traceTIMER_COMMAND_SEND(tmr, xCommandID, xOptionalValue, xReturn) \ - if (xCommandID > tmrCOMMAND_START_DONT_TRACE) \ - { \ - if (xCommandID == tmrCOMMAND_CHANGE_PERIOD) \ - { \ - if (xReturn == pdPASS) { \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TIMER_CHANGE_PERIOD, TIMER, tmr, xOptionalValue); \ - } \ - else \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TIMER_CHANGE_PERIOD_TRCFAILED, TIMER, tmr, xOptionalValue); \ - } \ - } \ - else if ((xCommandID == tmrCOMMAND_DELETE) && (xReturn == pdPASS)) \ - { \ - trcKERNEL_HOOKS_OBJECT_DELETE(TIMER_DELETE_OBJ, EVENTGROUP_OBJCLOSE_NAME_TRCSUCCESS + TRACE_GET_OBJECT_TRACE_CLASS(TIMER, tmr), EVENTGROUP_OBJCLOSE_PROP_TRCSUCCESS + TRACE_GET_OBJECT_TRACE_CLASS(TIMER, tmr), TIMER, tmr); \ - } \ - else \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENTGROUP_TIMER + (uint32_t)xCommandID + ((xReturn == pdPASS) ? 0 : (TIMER_CREATE_TRCFAILED - TIMER_CREATE)), TIMER, tmr, xOptionalValue); \ - }\ - } - -#undef traceTIMER_EXPIRED -#define traceTIMER_EXPIRED(tmr) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TIMER_EXPIRED, TIMER, tmr); - -#endif /* (TRC_CFG_INCLUDE_TIMER_EVENTS == 1) */ - -#if (TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS == 1) - -#undef tracePEND_FUNC_CALL -#define tracePEND_FUNC_CALL(func, arg1, arg2, ret) \ - if (ret == pdPASS){ \ - trcKERNEL_HOOKS_KERNEL_SERVICE(PEND_FUNC_CALL, TASK, xTimerGetTimerDaemonTaskHandle() ); \ - } \ - else \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE(PEND_FUNC_CALL_TRCFAILED, TASK, xTimerGetTimerDaemonTaskHandle() ); \ - } - -#undef tracePEND_FUNC_CALL_FROM_ISR -#define tracePEND_FUNC_CALL_FROM_ISR(func, arg1, arg2, ret) \ - if (! uiInEventGroupSetBitsFromISR) \ - prvTraceStoreKernelCall(PEND_FUNC_CALL_FROM_ISR, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTimerGetTimerDaemonTaskHandle()) ); \ - uiInEventGroupSetBitsFromISR = 0; - -#endif /* (TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS == 1) */ - -#endif /* (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) */ - -#if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1) - -#undef traceEVENT_GROUP_CREATE -#define traceEVENT_GROUP_CREATE(eg) \ - trcKERNEL_HOOKS_OBJECT_CREATE(EVENT_GROUP_CREATE, EVENTGROUP, eg); - -#undef traceEVENT_GROUP_CREATE_FAILED -#define traceEVENT_GROUP_CREATE_FAILED() \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(EVENT_GROUP_CREATE_TRCFAILED, 0); - -#undef traceEVENT_GROUP_DELETE -#define traceEVENT_GROUP_DELETE(eg) \ - { TRACE_ALLOC_CRITICAL_SECTION(); \ - TRACE_ENTER_CRITICAL_SECTION(); \ - trcKERNEL_HOOKS_OBJECT_DELETE(EVENT_GROUP_DELETE_OBJ, EVENTGROUP_OBJCLOSE_NAME_TRCSUCCESS + TRACE_GET_OBJECT_TRACE_CLASS(EVENTGROUP, eg), EVENTGROUP_OBJCLOSE_NAME_TRCSUCCESS + TRACE_GET_OBJECT_TRACE_CLASS(EVENTGROUP, eg), EVENTGROUP, eg); \ - TRACE_EXIT_CRITICAL_SECTION(); } - -#undef traceEVENT_GROUP_SYNC_BLOCK -#define traceEVENT_GROUP_SYNC_BLOCK(eg, bitsToSet, bitsToWaitFor) \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_SYNC_TRCBLOCK, EVENTGROUP, eg, bitsToWaitFor); - -#undef traceEVENT_GROUP_SYNC_END -#define traceEVENT_GROUP_SYNC_END(eg, bitsToSet, bitsToWaitFor, wasTimeout) \ - if (wasTimeout) \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_SYNC_END_TRCFAILED, EVENTGROUP, eg, bitsToWaitFor); \ - } \ - else \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_SYNC_END, EVENTGROUP, eg, bitsToWaitFor); \ - } - -#undef traceEVENT_GROUP_WAIT_BITS_BLOCK -#define traceEVENT_GROUP_WAIT_BITS_BLOCK(eg, bitsToWaitFor) \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_WAIT_BITS_TRCBLOCK, EVENTGROUP, eg, bitsToWaitFor); \ - trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(); - -#undef traceEVENT_GROUP_WAIT_BITS_END -#define traceEVENT_GROUP_WAIT_BITS_END(eg, bitsToWaitFor, wasTimeout) \ - if (wasTimeout) \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_WAIT_BITS_END_TRCFAILED, EVENTGROUP, eg, bitsToWaitFor); \ - } \ - else \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_WAIT_BITS_END, EVENTGROUP, eg, bitsToWaitFor); \ - } - -#undef traceEVENT_GROUP_CLEAR_BITS -#define traceEVENT_GROUP_CLEAR_BITS(eg, bitsToClear) \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_CLEAR_BITS, EVENTGROUP, eg, bitsToClear); - -#undef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR -#define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR(eg, bitsToClear) \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM_FROM_ISR(EVENT_GROUP_CLEAR_BITS_FROM_ISR, EVENTGROUP, eg, bitsToClear); - -#undef traceEVENT_GROUP_SET_BITS -#define traceEVENT_GROUP_SET_BITS(eg, bitsToSet) \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(EVENT_GROUP_SET_BITS, EVENTGROUP, eg, bitsToSet); - -#undef traceEVENT_GROUP_SET_BITS_FROM_ISR -#define traceEVENT_GROUP_SET_BITS_FROM_ISR(eg, bitsToSet) \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM_FROM_ISR(EVENT_GROUP_SET_BITS_FROM_ISR, EVENTGROUP, eg, bitsToSet); \ - uiInEventGroupSetBitsFromISR = 1; - -#endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1) */ - -#undef traceTASK_NOTIFY_TAKE -#if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0) -#define traceTASK_NOTIFY_TAKE() \ - if (pxCurrentTCB->eNotifyState == eNotified){ \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE, TASK, pxCurrentTCB, xTicksToWait); \ - } \ - else{ \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE_TRCFAILED, TASK, pxCurrentTCB, xTicksToWait); \ - } -#else /* TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0 */ -#define traceTASK_NOTIFY_TAKE() \ - if (pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED){ \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE, TASK, pxCurrentTCB, xTicksToWait); \ - }else{ \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE_TRCFAILED, TASK, pxCurrentTCB, xTicksToWait);} -#endif /* TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0 */ - -#undef traceTASK_NOTIFY_TAKE_BLOCK -#define traceTASK_NOTIFY_TAKE_BLOCK() \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(TRACE_TASK_NOTIFY_TAKE_TRCBLOCK, TASK, pxCurrentTCB, xTicksToWait); \ - trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(); - -#undef traceTASK_NOTIFY_WAIT -#if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0) -#define traceTASK_NOTIFY_WAIT() \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxCurrentTCB) & CurrentFilterMask) \ - { \ - if (pxCurrentTCB->eNotifyState == eNotified) \ - prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \ - else \ - prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT_TRCFAILED, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \ - } -#else /* TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0 */ -#define traceTASK_NOTIFY_WAIT() \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxCurrentTCB) & CurrentFilterMask) \ - { \ - if (pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED) \ - prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \ - else \ - prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT_TRCFAILED, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \ - } -#endif /* TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0 */ - -#undef traceTASK_NOTIFY_WAIT_BLOCK -#define traceTASK_NOTIFY_WAIT_BLOCK() \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxCurrentTCB) & CurrentFilterMask) \ - prvTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT_TRCBLOCK, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxCurrentTCB), xTicksToWait); \ - trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(); - -#undef traceTASK_NOTIFY -#define traceTASK_NOTIFY() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TASK, xTaskToNotify) & CurrentFilterMask) \ - prvTraceStoreKernelCall(TRACE_TASK_NOTIFY, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTaskToNotify)); - -#undef traceTASK_NOTIFY_FROM_ISR -#define traceTASK_NOTIFY_FROM_ISR() \ - if (TRACE_GET_OBJECT_FILTER(TASK, xTaskToNotify) & CurrentFilterMask) \ - prvTraceStoreKernelCall(TRACE_TASK_NOTIFY_FROM_ISR, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTaskToNotify)); - -#undef traceTASK_NOTIFY_GIVE_FROM_ISR -#define traceTASK_NOTIFY_GIVE_FROM_ISR() \ - if (TRACE_GET_OBJECT_FILTER(TASK, xTaskToNotify) & CurrentFilterMask) \ - prvTraceStoreKernelCall(TRACE_TASK_NOTIFY_GIVE_FROM_ISR, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(xTaskToNotify)); - -#if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) - -#undef traceSTREAM_BUFFER_CREATE -#define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) \ - trcKERNEL_HOOKS_OBJECT_CREATE(TRACE_GET_OBJECT_EVENT_CODE(CREATE_OBJ, TRCSUCCESS, STREAMBUFFER, pxStreamBuffer), STREAMBUFFER, pxStreamBuffer); - -#undef traceSTREAM_BUFFER_CREATE_FAILED -#define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(TRACE_GET_CLASS_EVENT_CODE(CREATE_OBJ, TRCFAILED, STREAMBUFFER, xIsMessageBuffer), 0); - -#undef traceSTREAM_BUFFER_CREATE_STATIC_FAILED -#define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ) \ - traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) - -#undef traceSTREAM_BUFFER_DELETE -#define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) \ - trcKERNEL_HOOKS_OBJECT_DELETE(TRACE_GET_OBJECT_EVENT_CODE(DELETE_OBJ, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), TRACE_GET_OBJECT_EVENT_CODE(OBJCLOSE_NAME, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), TRACE_GET_OBJECT_EVENT_CODE(OBJCLOSE_PROP, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); - -#undef traceSTREAM_BUFFER_RESET -#define traceSTREAM_BUFFER_RESET( xStreamBuffer ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(prvGetStreamBufferType(xStreamBuffer) > 0 ? TRACE_MESSAGEBUFFER_RESET : TRACE_STREAMBUFFER_RESET, STREAMBUFFER, xStreamBuffer); \ - trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, 0); - -#undef traceSTREAM_BUFFER_SEND -#define traceSTREAM_BUFFER_SEND( xStreamBuffer, xReturn ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \ - trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); - -#undef traceBLOCKING_ON_STREAM_BUFFER_SEND -#define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCBLOCK, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); - -#undef traceSTREAM_BUFFER_SEND_FAILED -#define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(SEND, TRCFAILED, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); - -#undef traceSTREAM_BUFFER_RECEIVE -#define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \ - trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); - - -#undef traceBLOCKING_ON_STREAM_BUFFER_RECEIVE -#define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCBLOCK, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); - -#undef traceSTREAM_BUFFER_RECEIVE_FAILED -#define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) \ - trcKERNEL_HOOKS_KERNEL_SERVICE(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE, TRCFAILED, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); - -#undef traceSTREAM_BUFFER_SEND_FROM_ISR -#define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xReturn ) \ - if( xReturn > ( size_t ) 0 ) \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(SEND_FROM_ISR, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \ - trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); \ - } \ - else \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(SEND_FROM_ISR, TRCFAILED, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \ - } - -#undef traceSTREAM_BUFFER_RECEIVE_FROM_ISR -#define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) \ - if( xReceivedLength > ( size_t ) 0 ) \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE_FROM_ISR, TRCSUCCESS, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \ - trcKERNEL_HOOKS_SET_OBJECT_STATE(STREAMBUFFER, xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); \ - } \ - else \ - { \ - trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(TRACE_GET_OBJECT_EVENT_CODE(RECEIVE_FROM_ISR, TRCFAILED, STREAMBUFFER, xStreamBuffer), STREAMBUFFER, xStreamBuffer); \ - } - -#endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) */ - -#endif /* (TRC_CFG_SCHEDULING_ONLY == 0) */ - -#endif /*#if TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT */ - -/******************************************************************************/ -/*** Definitions for Streaming mode *******************************************/ -/******************************************************************************/ -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) - -/******************************************************************************* -* vTraceStoreKernelObjectName -* -* Set the name for a kernel object (defined by its address). -******************************************************************************/ -void vTraceStoreKernelObjectName(void* object, const char* name); - -/******************************************************************************* -* prvIsNewTCB -* -* Tells if this task is already executing, or if there has been a task-switch. -* Assumed to be called within a trace hook in kernel context. -*******************************************************************************/ -uint32_t prvIsNewTCB(void* pNewTCB); - -#define TRACE_GET_CURRENT_TASK() prvTraceGetCurrentTaskHandle() - -/*************************************************************************/ -/* KERNEL SPECIFIC OBJECT CONFIGURATION */ -/*************************************************************************/ - -/******************************************************************************* - * The event codes - should match the offline config file. - ******************************************************************************/ - -/*** Event codes for streaming - should match the Tracealyzer config file *****/ -#define PSF_EVENT_NULL_EVENT 0x00 - -#define PSF_EVENT_TRACE_START 0x01 -#define PSF_EVENT_TS_CONFIG 0x02 -#define PSF_EVENT_OBJ_NAME 0x03 -#define PSF_EVENT_TASK_PRIORITY 0x04 -#define PSF_EVENT_TASK_PRIO_INHERIT 0x05 -#define PSF_EVENT_TASK_PRIO_DISINHERIT 0x06 -#define PSF_EVENT_DEFINE_ISR 0x07 - -#define PSF_EVENT_TASK_CREATE 0x10 -#define PSF_EVENT_QUEUE_CREATE 0x11 -#define PSF_EVENT_SEMAPHORE_BINARY_CREATE 0x12 -#define PSF_EVENT_MUTEX_CREATE 0x13 -#define PSF_EVENT_TIMER_CREATE 0x14 -#define PSF_EVENT_EVENTGROUP_CREATE 0x15 -#define PSF_EVENT_SEMAPHORE_COUNTING_CREATE 0x16 -#define PSF_EVENT_MUTEX_RECURSIVE_CREATE 0x17 -#define PSF_EVENT_STREAMBUFFER_CREATE 0x18 -#define PSF_EVENT_MESSAGEBUFFER_CREATE 0x19 - -#define PSF_EVENT_TASK_DELETE 0x20 -#define PSF_EVENT_QUEUE_DELETE 0x21 -#define PSF_EVENT_SEMAPHORE_DELETE 0x22 -#define PSF_EVENT_MUTEX_DELETE 0x23 -#define PSF_EVENT_TIMER_DELETE 0x24 -#define PSF_EVENT_EVENTGROUP_DELETE 0x25 -#define PSF_EVENT_STREAMBUFFER_DELETE 0x28 -#define PSF_EVENT_MESSAGEBUFFER_DELETE 0x29 - -#define PSF_EVENT_TASK_READY 0x30 -#define PSF_EVENT_NEW_TIME 0x31 -#define PSF_EVENT_NEW_TIME_SCHEDULER_SUSPENDED 0x32 -#define PSF_EVENT_ISR_BEGIN 0x33 -#define PSF_EVENT_ISR_RESUME 0x34 -#define PSF_EVENT_TS_BEGIN 0x35 -#define PSF_EVENT_TS_RESUME 0x36 -#define PSF_EVENT_TASK_ACTIVATE 0x37 - -#define PSF_EVENT_MALLOC 0x38 -#define PSF_EVENT_FREE 0x39 - -#define PSF_EVENT_LOWPOWER_BEGIN 0x3A -#define PSF_EVENT_LOWPOWER_END 0x3B - -#define PSF_EVENT_IFE_NEXT 0x3C -#define PSF_EVENT_IFE_DIRECT 0x3D - -#define PSF_EVENT_TASK_CREATE_FAILED 0x40 -#define PSF_EVENT_QUEUE_CREATE_FAILED 0x41 -#define PSF_EVENT_SEMAPHORE_BINARY_CREATE_FAILED 0x42 -#define PSF_EVENT_MUTEX_CREATE_FAILED 0x43 -#define PSF_EVENT_TIMER_CREATE_FAILED 0x44 -#define PSF_EVENT_EVENTGROUP_CREATE_FAILED 0x45 -#define PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED 0x46 -#define PSF_EVENT_MUTEX_RECURSIVE_CREATE_FAILED 0x47 -#define PSF_EVENT_STREAMBUFFER_CREATE_FAILED 0x49 -#define PSF_EVENT_MESSAGEBUFFER_CREATE_FAILED 0x4A - -#define PSF_EVENT_TIMER_DELETE_FAILED 0x48 - -#define PSF_EVENT_QUEUE_SEND 0x50 -#define PSF_EVENT_SEMAPHORE_GIVE 0x51 -#define PSF_EVENT_MUTEX_GIVE 0x52 - -#define PSF_EVENT_QUEUE_SEND_FAILED 0x53 -#define PSF_EVENT_SEMAPHORE_GIVE_FAILED 0x54 -#define PSF_EVENT_MUTEX_GIVE_FAILED 0x55 - -#define PSF_EVENT_QUEUE_SEND_BLOCK 0x56 -#define PSF_EVENT_SEMAPHORE_GIVE_BLOCK 0x57 -#define PSF_EVENT_MUTEX_GIVE_BLOCK 0x58 - -#define PSF_EVENT_QUEUE_SEND_FROMISR 0x59 -#define PSF_EVENT_SEMAPHORE_GIVE_FROMISR 0x5A - -#define PSF_EVENT_QUEUE_SEND_FROMISR_FAILED 0x5C -#define PSF_EVENT_SEMAPHORE_GIVE_FROMISR_FAILED 0x5D - -#define PSF_EVENT_QUEUE_RECEIVE 0x60 -#define PSF_EVENT_SEMAPHORE_TAKE 0x61 -#define PSF_EVENT_MUTEX_TAKE 0x62 - -#define PSF_EVENT_QUEUE_RECEIVE_FAILED 0x63 -#define PSF_EVENT_SEMAPHORE_TAKE_FAILED 0x64 -#define PSF_EVENT_MUTEX_TAKE_FAILED 0x65 - -#define PSF_EVENT_QUEUE_RECEIVE_BLOCK 0x66 -#define PSF_EVENT_SEMAPHORE_TAKE_BLOCK 0x67 -#define PSF_EVENT_MUTEX_TAKE_BLOCK 0x68 - -#define PSF_EVENT_QUEUE_RECEIVE_FROMISR 0x69 -#define PSF_EVENT_SEMAPHORE_TAKE_FROMISR 0x6A - -#define PSF_EVENT_QUEUE_RECEIVE_FROMISR_FAILED 0x6C -#define PSF_EVENT_SEMAPHORE_TAKE_FROMISR_FAILED 0x6D - -#define PSF_EVENT_QUEUE_PEEK 0x70 -#define PSF_EVENT_SEMAPHORE_PEEK 0x71 -#define PSF_EVENT_MUTEX_PEEK 0x72 - -#define PSF_EVENT_QUEUE_PEEK_FAILED 0x73 -#define PSF_EVENT_SEMAPHORE_PEEK_FAILED 0x74 -#define PSF_EVENT_MUTEX_PEEK_FAILED 0x75 - -#define PSF_EVENT_QUEUE_PEEK_BLOCK 0x76 -#define PSF_EVENT_SEMAPHORE_PEEK_BLOCK 0x77 -#define PSF_EVENT_MUTEX_PEEK_BLOCK 0x78 - -#define PSF_EVENT_TASK_DELAY_UNTIL 0x79 -#define PSF_EVENT_TASK_DELAY 0x7A -#define PSF_EVENT_TASK_SUSPEND 0x7B -#define PSF_EVENT_TASK_RESUME 0x7C -#define PSF_EVENT_TASK_RESUME_FROMISR 0x7D - -#define PSF_EVENT_TIMER_PENDFUNCCALL 0x80 -#define PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR 0x81 -#define PSF_EVENT_TIMER_PENDFUNCCALL_FAILED 0x82 -#define PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR_FAILED 0x83 - -#define PSF_EVENT_USER_EVENT 0x90 - -#define PSF_EVENT_TIMER_START 0xA0 -#define PSF_EVENT_TIMER_RESET 0xA1 -#define PSF_EVENT_TIMER_STOP 0xA2 -#define PSF_EVENT_TIMER_CHANGEPERIOD 0xA3 -#define PSF_EVENT_TIMER_START_FROMISR 0xA4 -#define PSF_EVENT_TIMER_RESET_FROMISR 0xA5 -#define PSF_EVENT_TIMER_STOP_FROMISR 0xA6 -#define PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR 0xA7 -#define PSF_EVENT_TIMER_START_FAILED 0xA8 -#define PSF_EVENT_TIMER_RESET_FAILED 0xA9 -#define PSF_EVENT_TIMER_STOP_FAILED 0xAA -#define PSF_EVENT_TIMER_CHANGEPERIOD_FAILED 0xAB -#define PSF_EVENT_TIMER_START_FROMISR_FAILED 0xAC -#define PSF_EVENT_TIMER_RESET_FROMISR_FAILED 0xAD -#define PSF_EVENT_TIMER_STOP_FROMISR_FAILED 0xAE -#define PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR_FAILED 0xAF - -#define PSF_EVENT_EVENTGROUP_SYNC 0xB0 -#define PSF_EVENT_EVENTGROUP_WAITBITS 0xB1 -#define PSF_EVENT_EVENTGROUP_CLEARBITS 0xB2 -#define PSF_EVENT_EVENTGROUP_CLEARBITS_FROMISR 0xB3 -#define PSF_EVENT_EVENTGROUP_SETBITS 0xB4 -#define PSF_EVENT_EVENTGROUP_SETBITS_FROMISR 0xB5 -#define PSF_EVENT_EVENTGROUP_SYNC_BLOCK 0xB6 -#define PSF_EVENT_EVENTGROUP_WAITBITS_BLOCK 0xB7 -#define PSF_EVENT_EVENTGROUP_SYNC_FAILED 0xB8 -#define PSF_EVENT_EVENTGROUP_WAITBITS_FAILED 0xB9 - -#define PSF_EVENT_QUEUE_SEND_FRONT 0xC0 -#define PSF_EVENT_QUEUE_SEND_FRONT_FAILED 0xC1 -#define PSF_EVENT_QUEUE_SEND_FRONT_BLOCK 0xC2 -#define PSF_EVENT_QUEUE_SEND_FRONT_FROMISR 0xC3 -#define PSF_EVENT_QUEUE_SEND_FRONT_FROMISR_FAILED 0xC4 -#define PSF_EVENT_MUTEX_GIVE_RECURSIVE 0xC5 -#define PSF_EVENT_MUTEX_GIVE_RECURSIVE_FAILED 0xC6 -#define PSF_EVENT_MUTEX_TAKE_RECURSIVE 0xC7 -#define PSF_EVENT_MUTEX_TAKE_RECURSIVE_FAILED 0xC8 - -#define PSF_EVENT_TASK_NOTIFY 0xC9 -#define PSF_EVENT_TASK_NOTIFY_TAKE 0xCA -#define PSF_EVENT_TASK_NOTIFY_TAKE_BLOCK 0xCB -#define PSF_EVENT_TASK_NOTIFY_TAKE_FAILED 0xCC -#define PSF_EVENT_TASK_NOTIFY_WAIT 0xCD -#define PSF_EVENT_TASK_NOTIFY_WAIT_BLOCK 0xCE -#define PSF_EVENT_TASK_NOTIFY_WAIT_FAILED 0xCF -#define PSF_EVENT_TASK_NOTIFY_FROM_ISR 0xD0 -#define PSF_EVENT_TASK_NOTIFY_GIVE_FROM_ISR 0xD1 - -#define PSF_EVENT_TIMER_EXPIRED 0xD2 - -#define PSF_EVENT_STREAMBUFFER_SEND 0xD3 -#define PSF_EVENT_STREAMBUFFER_SEND_BLOCK 0xD4 -#define PSF_EVENT_STREAMBUFFER_SEND_FAILED 0xD5 -#define PSF_EVENT_STREAMBUFFER_RECEIVE 0xD6 -#define PSF_EVENT_STREAMBUFFER_RECEIVE_BLOCK 0xD7 -#define PSF_EVENT_STREAMBUFFER_RECEIVE_FAILED 0xD8 -#define PSF_EVENT_STREAMBUFFER_SEND_FROM_ISR 0xD9 -#define PSF_EVENT_STREAMBUFFER_SEND_FROM_ISR_FAILED 0xDA -#define PSF_EVENT_STREAMBUFFER_RECEIVE_FROM_ISR 0xDB -#define PSF_EVENT_STREAMBUFFER_RECEIVE_FROM_ISR_FAILED 0xDC -#define PSF_EVENT_STREAMBUFFER_RESET 0xDD - -#define PSF_EVENT_MESSAGEBUFFER_SEND 0xDE -#define PSF_EVENT_MESSAGEBUFFER_SEND_BLOCK 0xDF -#define PSF_EVENT_MESSAGEBUFFER_SEND_FAILED 0xE0 -#define PSF_EVENT_MESSAGEBUFFER_RECEIVE 0xE1 -#define PSF_EVENT_MESSAGEBUFFER_RECEIVE_BLOCK 0xE2 -#define PSF_EVENT_MESSAGEBUFFER_RECEIVE_FAILED 0xE3 -#define PSF_EVENT_MESSAGEBUFFER_SEND_FROM_ISR 0xE4 -#define PSF_EVENT_MESSAGEBUFFER_SEND_FROM_ISR_FAILED 0xE5 -#define PSF_EVENT_MESSAGEBUFFER_RECEIVE_FROM_ISR 0xE6 -#define PSF_EVENT_MESSAGEBUFFER_RECEIVE_FROM_ISR_FAILED 0xE7 -#define PSF_EVENT_MESSAGEBUFFER_RESET 0xE8 - -/*** The trace macros for streaming ******************************************/ - -/* A macro that will update the tick count when returning from tickless idle */ -#undef traceINCREASE_TICK_COUNT -/* Note: This can handle time adjustments of max 2^32 ticks, i.e., 35 seconds at 120 MHz. Thus, tick-less idle periods longer than 2^32 ticks will appear "compressed" on the time line.*/ -#define traceINCREASE_TICK_COUNT( xCount ) { extern uint32_t uiTraceTickCount; uiTraceTickCount += xCount; } - -#if (TRC_CFG_INCLUDE_OSTICK_EVENTS == 1) -#define OS_TICK_EVENT(uxSchedulerSuspended, xTickCount) if (uxSchedulerSuspended == (unsigned portBASE_TYPE) pdFALSE) { prvTraceStoreEvent1(PSF_EVENT_NEW_TIME, (uint32_t)(xTickCount + 1)); } -#else -#define OS_TICK_EVENT(uxSchedulerSuspended, xTickCount) -#endif - -/* Called on each OS tick. Will call uiPortGetTimestamp to make sure it is called at least once every OS tick. */ -#undef traceTASK_INCREMENT_TICK -#if TRC_CFG_FREERTOS_VERSION <= TRC_FREERTOS_VERSION_7_4 -#define traceTASK_INCREMENT_TICK( xTickCount ) \ - if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxMissedTicks == 0) { extern uint32_t uiTraceTickCount; uiTraceTickCount++; } \ - OS_TICK_EVENT(uxSchedulerSuspended, xTickCount) -#else -#define traceTASK_INCREMENT_TICK( xTickCount ) \ - if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxPendedTicks == 0) { extern uint32_t uiTraceTickCount; uiTraceTickCount++; } \ - OS_TICK_EVENT(uxSchedulerSuspended, xTickCount) -#endif /* TRC_CFG_FREERTOS_VERSION <= TRC_FREERTOS_VERSION_7_4 */ - -/* Called on each task-switch */ -#undef traceTASK_SWITCHED_IN -#define traceTASK_SWITCHED_IN() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - { \ - if (prvIsNewTCB(pxCurrentTCB)) \ - { \ - prvTraceStoreEvent2(PSF_EVENT_TASK_ACTIVATE, (uint32_t)pxCurrentTCB, pxCurrentTCB->uxPriority); \ - } \ - } - -/* Called for each task that becomes ready */ -#if (TRC_CFG_INCLUDE_READY_EVENTS == 1) -#undef traceMOVED_TASK_TO_READY_STATE -#define traceMOVED_TASK_TO_READY_STATE( pxTCB ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \ - prvTraceStoreEvent1(PSF_EVENT_TASK_READY, (uint32_t)pxTCB); -#endif - -#undef traceTASK_CREATE -#if TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 -#define traceTASK_CREATE(pxNewTCB) \ - if (pxNewTCB != NULL) \ - { \ - prvTraceSaveSymbol(pxNewTCB, pxNewTCB->pcTaskName); \ - prvTraceSaveObjectData(pxNewTCB, pxNewTCB->uxPriority); \ - prvTraceStoreStringEvent(1, PSF_EVENT_OBJ_NAME, pxNewTCB->pcTaskName, pxNewTCB); \ - TRACE_SET_OBJECT_FILTER(TASK, pxNewTCB, CurrentFilterGroup); \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxNewTCB) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_TASK_CREATE, (uint32_t)pxNewTCB, pxNewTCB->uxPriority); \ - } -#else /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */ -#define traceTASK_CREATE(pxNewTCB) \ - if (pxNewTCB != NULL) \ - { \ - prvTraceSaveSymbol(pxNewTCB, (const char*)pcName); \ - prvTraceSaveObjectData(pxNewTCB, uxPriority); \ - prvTraceStoreStringEvent(1, PSF_EVENT_OBJ_NAME, (const char*)pcName, pxNewTCB); \ - TRACE_SET_OBJECT_FILTER(TASK, pxNewTCB, CurrentFilterGroup); \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxNewTCB) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_TASK_CREATE, (uint32_t)pxNewTCB, uxPriority); \ - } -#endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */ - -/* Called in vTaskCreate, if it fails (typically if the stack can not be allocated) */ -#undef traceTASK_CREATE_FAILED -#define traceTASK_CREATE_FAILED() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent0(PSF_EVENT_TASK_CREATE_FAILED); - -/* Called on vTaskDelete */ -#undef traceTASK_DELETE // We don't allow for filtering out "delete" events. They are important and not very frequent. Moreover, we can't exclude create events, so this should be symmetrical. -#define traceTASK_DELETE( pxTaskToDelete ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTaskToDelete) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_TASK_DELETE, (uint32_t)pxTaskToDelete, (pxTaskToDelete != NULL) ? (pxTaskToDelete->uxPriority) : 0); \ - prvTraceDeleteSymbol(pxTaskToDelete); \ - prvTraceDeleteObjectData(pxTaskToDelete); - -#if (TRC_CFG_SCHEDULING_ONLY == 0) - -#if (defined(configUSE_TICKLESS_IDLE) && configUSE_TICKLESS_IDLE != 0) - -#undef traceLOW_POWER_IDLE_BEGIN -#define traceLOW_POWER_IDLE_BEGIN() \ - { \ - prvTraceStoreEvent1(PSF_EVENT_LOWPOWER_BEGIN, xExpectedIdleTime); \ - } - -#undef traceLOW_POWER_IDLE_END -#define traceLOW_POWER_IDLE_END() \ - { \ - prvTraceStoreEvent0(PSF_EVENT_LOWPOWER_END); \ - } - -#endif /* (defined(configUSE_TICKLESS_IDLE) && configUSE_TICKLESS_IDLE != 0) */ - -/* Called on vTaskSuspend */ -#undef traceTASK_SUSPEND -#define traceTASK_SUSPEND( pxTaskToSuspend ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTaskToSuspend) & CurrentFilterMask) \ - prvTraceStoreEvent1(PSF_EVENT_TASK_SUSPEND, (uint32_t)pxTaskToSuspend); - -/* Called on vTaskDelay - note the use of FreeRTOS variable xTicksToDelay */ -#undef traceTASK_DELAY -#define traceTASK_DELAY() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent1(PSF_EVENT_TASK_DELAY, xTicksToDelay); - -/* Called on vTaskDelayUntil - note the use of FreeRTOS variable xTimeToWake */ -#undef traceTASK_DELAY_UNTIL -#if TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 -#define traceTASK_DELAY_UNTIL(xTimeToWake) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent1(PSF_EVENT_TASK_DELAY_UNTIL, (uint32_t)xTimeToWake); -#else /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */ -#define traceTASK_DELAY_UNTIL() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent1(PSF_EVENT_TASK_DELAY_UNTIL, (uint32_t)xTimeToWake); -#endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */ - -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0) -#define traceQUEUE_CREATE_HELPER() \ - case queueQUEUE_TYPE_MUTEX: \ - prvTraceStoreEvent1(PSF_EVENT_MUTEX_CREATE, (uint32_t)pxNewQueue); \ - break; \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - prvTraceStoreEvent1(PSF_EVENT_MUTEX_RECURSIVE_CREATE, (uint32_t)pxNewQueue); \ - break; -#else -#define traceQUEUE_CREATE_HELPER() -#endif /* (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0) */ - -/* Called in xQueueCreate, and thereby for all other object based on queues, such as semaphores. */ -#undef traceQUEUE_CREATE -#define traceQUEUE_CREATE( pxNewQueue )\ - TRACE_SET_OBJECT_FILTER(QUEUE, pxNewQueue, CurrentFilterGroup); \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - { \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxNewQueue) & CurrentFilterMask) \ - { \ - switch (pxNewQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent2(PSF_EVENT_QUEUE_CREATE, (uint32_t)pxNewQueue, uxQueueLength); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - prvTraceStoreEvent1(PSF_EVENT_SEMAPHORE_BINARY_CREATE, (uint32_t)pxNewQueue); \ - break; \ - traceQUEUE_CREATE_HELPER() \ - } \ - } \ - } - -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0) -#define traceQUEUE_CREATE_FAILED_HELPER() \ - case queueQUEUE_TYPE_MUTEX: \ - prvTraceStoreEvent1(PSF_EVENT_MUTEX_CREATE_FAILED, 0); \ - break; \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - prvTraceStoreEvent1(PSF_EVENT_MUTEX_RECURSIVE_CREATE_FAILED, 0); \ - break; -#else -#define traceQUEUE_CREATE_FAILED_HELPER() -#endif /* (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0) */ - -/* Called in xQueueCreate, if the queue creation fails */ -#undef traceQUEUE_CREATE_FAILED -#define traceQUEUE_CREATE_FAILED( queueType ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - { \ - switch (queueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent2(PSF_EVENT_QUEUE_CREATE_FAILED, 0, uxQueueLength); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - prvTraceStoreEvent1(PSF_EVENT_SEMAPHORE_BINARY_CREATE_FAILED, 0); \ - break; \ - traceQUEUE_CREATE_FAILED_HELPER() \ - } \ - } - -#undef traceQUEUE_DELETE // We don't allow for filtering out "delete" events. They are important and not very frequent. Moreover, we can't exclude create events, so this should be symmetrical. -#define traceQUEUE_DELETE( pxQueue ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - { \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \ - { \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent2(PSF_EVENT_QUEUE_DELETE, (uint32_t)pxQueue, (pxQueue != NULL) ? (pxQueue->uxMessagesWaiting) : 0); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - prvTraceStoreEvent2(PSF_EVENT_MUTEX_DELETE, (uint32_t)pxQueue, (pxQueue != NULL) ? (pxQueue->uxMessagesWaiting) : 0); \ - break; \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_DELETE, (uint32_t)pxQueue, (pxQueue != NULL) ? (pxQueue->uxMessagesWaiting) : 0); \ - break; \ - } \ - } \ - } \ - prvTraceDeleteSymbol(pxQueue); - -/* Called in xQueueCreateCountingSemaphore, if the queue creation fails */ -#undef traceCREATE_COUNTING_SEMAPHORE -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) -#define traceCREATE_COUNTING_SEMAPHORE() \ - TRACE_SET_OBJECT_FILTER(QUEUE, xHandle, CurrentFilterGroup); \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, xHandle) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE, (uint32_t)xHandle, uxMaxCount) -#elif (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_5_OR_7_6) -#define traceCREATE_COUNTING_SEMAPHORE() \ - TRACE_SET_OBJECT_FILTER(QUEUE, xHandle, CurrentFilterGroup); \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, xHandle) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE, (uint32_t)xHandle, uxInitialCount); -#elif (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_4) -#define traceCREATE_COUNTING_SEMAPHORE() \ - TRACE_SET_OBJECT_FILTER(QUEUE, xHandle, CurrentFilterGroup); \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, xHandle) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE, (uint32_t)xHandle, uxCountValue); -#else -#define traceCREATE_COUNTING_SEMAPHORE() \ - TRACE_SET_OBJECT_FILTER(QUEUE, pxHandle, CurrentFilterGroup); \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxHandle) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE, (uint32_t)pxHandle, uxCountValue); -#endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X */ - -#undef traceCREATE_COUNTING_SEMAPHORE_FAILED -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) -#define traceCREATE_COUNTING_SEMAPHORE_FAILED() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED, 0, uxMaxCount); -#elif (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_5_OR_7_6) -#define traceCREATE_COUNTING_SEMAPHORE_FAILED() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED, 0, uxInitialCount); -#elif (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_7_4) -#define traceCREATE_COUNTING_SEMAPHORE_FAILED() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED, 0, uxCountValue); -#else -#define traceCREATE_COUNTING_SEMAPHORE_FAILED() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED, 0, uxCountValue); -#endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X */ - - -/* This macro is not necessary as of FreeRTOS v9.0.0 */ -#if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0) -/* Called in xQueueCreateMutex, and thereby also from xSemaphoreCreateMutex and xSemaphoreCreateRecursiveMutex */ -#undef traceCREATE_MUTEX -#define traceCREATE_MUTEX( pxNewQueue ) \ - TRACE_SET_OBJECT_FILTER(QUEUE, pxNewQueue, CurrentFilterGroup); \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - { \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxNewQueue) & CurrentFilterMask) \ - { \ - switch (pxNewQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_MUTEX: \ - prvTraceStoreEvent1(PSF_EVENT_MUTEX_CREATE, (uint32_t)pxNewQueue); \ - break; \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - prvTraceStoreEvent1(PSF_EVENT_MUTEX_RECURSIVE_CREATE, (uint32_t)pxNewQueue); \ - break; \ - } \ - }\ - } - -/* Called in xQueueCreateMutex when the operation fails (when memory allocation fails) */ -#undef traceCREATE_MUTEX_FAILED -#define traceCREATE_MUTEX_FAILED() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent1(PSF_EVENT_MUTEX_CREATE_FAILED, 0); -#endif /* (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_9_0_0) */ - -/* Called when a message is sent to a queue */ /* CS IS NEW ! */ -#undef traceQUEUE_SEND -#define traceQUEUE_SEND( pxQueue ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND : PSF_EVENT_QUEUE_SEND_FRONT, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting + 1); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting + 1); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - prvTraceStoreEvent1(PSF_EVENT_MUTEX_GIVE, (uint32_t)pxQueue); \ - break; \ - } - -/* Called when a message failed to be sent to a queue (timeout) */ -#undef traceQUEUE_SEND_FAILED -#define traceQUEUE_SEND_FAILED( pxQueue ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_FAILED : PSF_EVENT_QUEUE_SEND_FRONT_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - prvTraceStoreEvent1(PSF_EVENT_MUTEX_GIVE_FAILED, (uint32_t)pxQueue); \ - break; \ - } - -/* Called when the task is blocked due to a send operation on a full queue */ -#undef traceBLOCKING_ON_QUEUE_SEND -#define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_BLOCK : PSF_EVENT_QUEUE_SEND_FRONT_BLOCK, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE_BLOCK, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - prvTraceStoreEvent1(PSF_EVENT_MUTEX_GIVE_BLOCK, (uint32_t)pxQueue); \ - break; \ - } - -/**************************************************************************/ -/* Makes sure xQueueGiveFromISR also has a xCopyPosition parameter */ -/**************************************************************************/ -/* Helpers needed to correctly expand names */ -#define TZ__CAT2(a,b) a ## b -#define TZ__CAT(a,b) TZ__CAT2(a, b) - -/* Expands name if this header is included... uxQueueType must be a macro that only exists in queue.c or whatever, and it must expand to nothing or to something that's valid in identifiers */ -#define xQueueGiveFromISR(a,b) TZ__CAT(xQueueGiveFromISR__, uxQueueType) (a,b) - -/* If in queue.c, the "uxQueueType" macro expands to "pcHead". queueSEND_TO_BACK is the value we need to send in */ -#define xQueueGiveFromISR__pcHead(__a, __b) MyWrapper(__a, __b, const BaseType_t xCopyPosition); \ -BaseType_t xQueueGiveFromISR(__a, __b) { return MyWrapper(xQueue, pxHigherPriorityTaskWoken, queueSEND_TO_BACK); } \ -BaseType_t MyWrapper(__a, __b, const BaseType_t xCopyPosition) - -/* If not in queue.c, "uxQueueType" isn't expanded */ -#define xQueueGiveFromISR__uxQueueType(__a, __b) xQueueGiveFromISR(__a,__b) - -/**************************************************************************/ -/* End of xQueueGiveFromISR fix */ -/**************************************************************************/ - -/* Called when a message is sent from interrupt context, e.g., using xQueueSendFromISR */ -#undef traceQUEUE_SEND_FROM_ISR -#define traceQUEUE_SEND_FROM_ISR( pxQueue ) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_FROMISR : PSF_EVENT_QUEUE_SEND_FRONT_FROMISR, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting + 1); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE_FROMISR, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting + 1); \ - break; \ - } - -/* Called when a message send from interrupt context fails (since the queue was full) */ -#undef traceQUEUE_SEND_FROM_ISR_FAILED -#define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_FROMISR_FAILED : PSF_EVENT_QUEUE_SEND_FRONT_FROMISR_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE_FROMISR_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - } - -/* Called when a message is received from a queue */ -#undef traceQUEUE_RECEIVE -#define traceQUEUE_RECEIVE( pxQueue ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - if (isQueueReceiveHookActuallyPeek) \ - prvTraceStoreEvent3(PSF_EVENT_QUEUE_PEEK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting - 1); \ - else\ - prvTraceStoreEvent3(PSF_EVENT_QUEUE_RECEIVE, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting - 1); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - if (isQueueReceiveHookActuallyPeek) \ - prvTraceStoreEvent3(PSF_EVENT_SEMAPHORE_PEEK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting - 1); \ - else \ - prvTraceStoreEvent3(PSF_EVENT_SEMAPHORE_TAKE, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting - 1); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - if (isQueueReceiveHookActuallyPeek) \ - prvTraceStoreEvent2(PSF_EVENT_MUTEX_PEEK, (uint32_t)pxQueue, xTicksToWait); \ - else \ - prvTraceStoreEvent2(PSF_EVENT_MUTEX_TAKE, (uint32_t)pxQueue, xTicksToWait); \ - break; \ - } - -/* Called when a receive operation on a queue fails (timeout) */ -#undef traceQUEUE_RECEIVE_FAILED -#define traceQUEUE_RECEIVE_FAILED( pxQueue ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent3(isQueueReceiveHookActuallyPeek ? PSF_EVENT_QUEUE_PEEK_FAILED : PSF_EVENT_QUEUE_RECEIVE_FAILED, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - prvTraceStoreEvent3(isQueueReceiveHookActuallyPeek ? PSF_EVENT_SEMAPHORE_PEEK_FAILED : PSF_EVENT_SEMAPHORE_TAKE_FAILED, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - prvTraceStoreEvent2(isQueueReceiveHookActuallyPeek ? PSF_EVENT_MUTEX_PEEK_FAILED : PSF_EVENT_MUTEX_TAKE_FAILED, (uint32_t)pxQueue, xTicksToWait); \ - break; \ - } - -/* Called when the task is blocked due to a receive operation on an empty queue */ -#undef traceBLOCKING_ON_QUEUE_RECEIVE -#define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent3(isQueueReceiveHookActuallyPeek ? PSF_EVENT_QUEUE_PEEK_BLOCK : PSF_EVENT_QUEUE_RECEIVE_BLOCK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - prvTraceStoreEvent3(isQueueReceiveHookActuallyPeek ? PSF_EVENT_SEMAPHORE_PEEK_BLOCK : PSF_EVENT_SEMAPHORE_TAKE_BLOCK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - prvTraceStoreEvent2(isQueueReceiveHookActuallyPeek ? PSF_EVENT_MUTEX_PEEK_BLOCK : PSF_EVENT_MUTEX_TAKE_BLOCK, (uint32_t)pxQueue, xTicksToWait); \ - break; \ - } - -#if (TRC_CFG_FREERTOS_VERSION > TRC_FREERTOS_VERSION_9_0_1) -/* Called when a peek operation on a queue fails (timeout) */ -#undef traceQUEUE_PEEK_FAILED -#define traceQUEUE_PEEK_FAILED( pxQueue ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent3(PSF_EVENT_QUEUE_PEEK_FAILED, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - prvTraceStoreEvent3(PSF_EVENT_SEMAPHORE_PEEK_FAILED, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - prvTraceStoreEvent2(PSF_EVENT_MUTEX_PEEK_FAILED, (uint32_t)pxQueue, xTicksToWait); \ - break; \ - } - -/* Called when the task is blocked due to a peek operation on an empty queue */ -#undef traceBLOCKING_ON_QUEUE_PEEK -#define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent3(PSF_EVENT_QUEUE_PEEK_BLOCK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - prvTraceStoreEvent3(PSF_EVENT_SEMAPHORE_PEEK_BLOCK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - prvTraceStoreEvent2(PSF_EVENT_MUTEX_PEEK_BLOCK, (uint32_t)pxQueue, xTicksToWait); \ - break; \ - } - -#endif /* (TRC_CFG_FREERTOS_VERSION > TRC_FREERTOS_VERSION_9_0_1) */ - -/* Called when a message is received in interrupt context, e.g., using xQueueReceiveFromISR */ -#undef traceQUEUE_RECEIVE_FROM_ISR -#define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent2(PSF_EVENT_QUEUE_RECEIVE_FROMISR, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting - 1); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_TAKE_FROMISR, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting - 1); \ - break; \ - } - -/* Called when a message receive from interrupt context fails (since the queue was empty) */ -#undef traceQUEUE_RECEIVE_FROM_ISR_FAILED -#define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent2(PSF_EVENT_QUEUE_RECEIVE_FROMISR_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - prvTraceStoreEvent2(PSF_EVENT_SEMAPHORE_TAKE_FROMISR_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - } - -/* Called on xQueuePeek */ -#undef traceQUEUE_PEEK -#define traceQUEUE_PEEK( pxQueue ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(QUEUE, pxQueue) & CurrentFilterMask) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - prvTraceStoreEvent3(PSF_EVENT_QUEUE_PEEK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - prvTraceStoreEvent3(PSF_EVENT_SEMAPHORE_PEEK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - prvTraceStoreEvent1(PSF_EVENT_MUTEX_PEEK, (uint32_t)pxQueue); \ - break; \ - } - -/* Called in vTaskPrioritySet */ -#undef traceTASK_PRIORITY_SET -#define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) \ - prvTraceSaveObjectData(pxTask, uxNewPriority); \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTask) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_TASK_PRIORITY, (uint32_t)pxTask, uxNewPriority); - -/* Called in vTaskPriorityInherit, which is called by Mutex operations */ -#undef traceTASK_PRIORITY_INHERIT -#define traceTASK_PRIORITY_INHERIT( pxTask, uxNewPriority ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTask) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_TASK_PRIO_INHERIT, (uint32_t)pxTask, uxNewPriority); - -/* Called in vTaskPriorityDisinherit, which is called by Mutex operations */ -#undef traceTASK_PRIORITY_DISINHERIT -#define traceTASK_PRIORITY_DISINHERIT( pxTask, uxNewPriority ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTask) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_TASK_PRIO_DISINHERIT, (uint32_t)pxTask, uxNewPriority); - -/* Called in vTaskResume */ -#undef traceTASK_RESUME -#define traceTASK_RESUME( pxTaskToResume ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTaskToResume) & CurrentFilterMask) \ - prvTraceStoreEvent1(PSF_EVENT_TASK_RESUME, (uint32_t)pxTaskToResume); - -/* Called in vTaskResumeFromISR */ -#undef traceTASK_RESUME_FROM_ISR -#define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTaskToResume) & CurrentFilterMask) \ - prvTraceStoreEvent1(PSF_EVENT_TASK_RESUME_FROMISR, (uint32_t)pxTaskToResume); - -#if (TRC_CFG_INCLUDE_MEMMANG_EVENTS == 1) - -#undef traceMALLOC -#define traceMALLOC( pvAddress, uiSize ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_MALLOC, (uint32_t)pvAddress, uiSize); - -#undef traceFREE -#define traceFREE( pvAddress, uiSize ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_FREE, (uint32_t)pvAddress, (uint32_t)(0 - uiSize)); /* "0 -" instead of just "-" to get rid of a warning... */ - -#endif /* (TRC_CFG_INCLUDE_MEMMANG_EVENTS == 1) */ - -#if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1) - -/* Called in timer.c - xTimerCreate */ -#undef traceTIMER_CREATE -#define traceTIMER_CREATE(tmr) \ - TRACE_SET_OBJECT_FILTER(TIMER, tmr, CurrentFilterGroup); \ - prvTraceSaveSymbol(tmr, tmr->pcTimerName); \ - prvTraceStoreStringEvent(1, PSF_EVENT_OBJ_NAME, tmr->pcTimerName, tmr); \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TIMER, tmr) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_TIMER_CREATE, (uint32_t)tmr, tmr->xTimerPeriodInTicks); - -#undef traceTIMER_CREATE_FAILED -#define traceTIMER_CREATE_FAILED() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent0(PSF_EVENT_TIMER_CREATE_FAILED); - -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) -#define traceTIMER_COMMAND_SEND_8_0_CASES(tmr) \ - case tmrCOMMAND_RESET: \ - prvTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_RESET : PSF_EVENT_TIMER_RESET_FAILED, (uint32_t)tmr, xOptionalValue); \ - break; \ - case tmrCOMMAND_START_FROM_ISR: \ - prvTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_START_FROMISR : PSF_EVENT_TIMER_START_FROMISR_FAILED, (uint32_t)tmr, xOptionalValue); \ - break; \ - case tmrCOMMAND_RESET_FROM_ISR: \ - prvTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_RESET_FROMISR : PSF_EVENT_TIMER_RESET_FROMISR_FAILED, (uint32_t)tmr, xOptionalValue); \ - break; \ - case tmrCOMMAND_STOP_FROM_ISR: \ - prvTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_STOP_FROMISR : PSF_EVENT_TIMER_STOP_FROMISR_FAILED, (uint32_t)tmr, xOptionalValue); \ - break; \ - case tmrCOMMAND_CHANGE_PERIOD_FROM_ISR: \ - prvTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR : PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR_FAILED, (uint32_t)tmr, xOptionalValue); \ - break; -#else /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X */ -#define traceTIMER_COMMAND_SEND_8_0_CASES(tmr) -#endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X */ - -/* Note that xCommandID can never be tmrCOMMAND_EXECUTE_CALLBACK (-1) since the trace macro is not called in that case */ -#undef traceTIMER_COMMAND_SEND -#define traceTIMER_COMMAND_SEND(tmr, xCommandID, xOptionalValue, xReturn) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TIMER, tmr) & CurrentFilterMask) \ - switch(xCommandID) \ - { \ - case tmrCOMMAND_START: \ - prvTraceStoreEvent1((xReturn == pdPASS) ? PSF_EVENT_TIMER_START : PSF_EVENT_TIMER_START_FAILED, (uint32_t)tmr); \ - break; \ - case tmrCOMMAND_STOP: \ - prvTraceStoreEvent1((xReturn == pdPASS) ? PSF_EVENT_TIMER_STOP : PSF_EVENT_TIMER_STOP_FAILED, (uint32_t)tmr); \ - break; \ - case tmrCOMMAND_CHANGE_PERIOD: \ - prvTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_CHANGEPERIOD : PSF_EVENT_TIMER_CHANGEPERIOD_FAILED, (uint32_t)tmr, xOptionalValue); \ - break; \ - case tmrCOMMAND_DELETE: \ - prvTraceStoreEvent1((xReturn == pdPASS) ? PSF_EVENT_TIMER_DELETE : PSF_EVENT_TIMER_DELETE_FAILED, (uint32_t)tmr); \ - break; \ - traceTIMER_COMMAND_SEND_8_0_CASES(tmr) \ - } - -#undef traceTIMER_EXPIRED -#define traceTIMER_EXPIRED(tmr) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TIMER, tmr) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_TIMER_EXPIRED, (uint32_t)tmr->pxCallbackFunction, (uint32_t)tmr->pvTimerID); - -#endif /* #if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1) */ - - -#if (TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS == 1) - -#undef tracePEND_FUNC_CALL -#define tracePEND_FUNC_CALL(func, arg1, arg2, ret) \ - prvTraceStoreEvent1((ret == pdPASS) ? PSF_EVENT_TIMER_PENDFUNCCALL : PSF_EVENT_TIMER_PENDFUNCCALL_FAILED, (uint32_t)func); - -#undef tracePEND_FUNC_CALL_FROM_ISR -#define tracePEND_FUNC_CALL_FROM_ISR(func, arg1, arg2, ret) \ - prvTraceStoreEvent1((ret == pdPASS) ? PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR : PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR_FAILED, (uint32_t)func); - -#endif /* (TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS == 1) */ - -#if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1) - -#undef traceEVENT_GROUP_CREATE -#define traceEVENT_GROUP_CREATE(eg) \ - TRACE_SET_OBJECT_FILTER(EVENTGROUP, eg, CurrentFilterGroup); \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \ - prvTraceStoreEvent1(PSF_EVENT_EVENTGROUP_CREATE, (uint32_t)eg); - -#undef traceEVENT_GROUP_DELETE -#define traceEVENT_GROUP_DELETE(eg) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \ - prvTraceStoreEvent1(PSF_EVENT_EVENTGROUP_DELETE, (uint32_t)eg); \ - prvTraceDeleteSymbol(eg); - -#undef traceEVENT_GROUP_CREATE_FAILED -#define traceEVENT_GROUP_CREATE_FAILED() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent0(PSF_EVENT_EVENTGROUP_CREATE_FAILED); - -#undef traceEVENT_GROUP_SYNC_BLOCK -#define traceEVENT_GROUP_SYNC_BLOCK(eg, bitsToSet, bitsToWaitFor) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_EVENTGROUP_SYNC_BLOCK, (uint32_t)eg, bitsToWaitFor); - -#undef traceEVENT_GROUP_SYNC_END -#define traceEVENT_GROUP_SYNC_END(eg, bitsToSet, bitsToWaitFor, wasTimeout) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \ - prvTraceStoreEvent2((wasTimeout != pdTRUE) ? PSF_EVENT_EVENTGROUP_SYNC : PSF_EVENT_EVENTGROUP_SYNC_FAILED, (uint32_t)eg, bitsToWaitFor); - -#undef traceEVENT_GROUP_WAIT_BITS_BLOCK -#define traceEVENT_GROUP_WAIT_BITS_BLOCK(eg, bitsToWaitFor) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_EVENTGROUP_WAITBITS_BLOCK, (uint32_t)eg, bitsToWaitFor); - -#undef traceEVENT_GROUP_WAIT_BITS_END -#define traceEVENT_GROUP_WAIT_BITS_END(eg, bitsToWaitFor, wasTimeout) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \ - prvTraceStoreEvent2((wasTimeout != pdTRUE) ? PSF_EVENT_EVENTGROUP_WAITBITS : PSF_EVENT_EVENTGROUP_WAITBITS_FAILED, (uint32_t)eg, bitsToWaitFor); - -#undef traceEVENT_GROUP_CLEAR_BITS -#define traceEVENT_GROUP_CLEAR_BITS(eg, bitsToClear) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_EVENTGROUP_CLEARBITS, (uint32_t)eg, bitsToClear); - -#undef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR -#define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR(eg, bitsToClear) \ - if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_EVENTGROUP_CLEARBITS_FROMISR, (uint32_t)eg, bitsToClear); - -#undef traceEVENT_GROUP_SET_BITS -#define traceEVENT_GROUP_SET_BITS(eg, bitsToSet) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_EVENTGROUP_SETBITS, (uint32_t)eg, bitsToSet); - -#undef traceEVENT_GROUP_SET_BITS_FROM_ISR -#define traceEVENT_GROUP_SET_BITS_FROM_ISR(eg, bitsToSet) \ - if (TRACE_GET_OBJECT_FILTER(EVENTGROUP, eg) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_EVENTGROUP_SETBITS_FROMISR, (uint32_t)eg, bitsToSet); - -#endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1) */ - -#undef traceTASK_NOTIFY_TAKE -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0) -#define traceTASK_NOTIFY_TAKE() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask){ \ - if (pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED) \ - prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_TAKE, (uint32_t)pxCurrentTCB, xTicksToWait); \ - else \ - prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_TAKE_FAILED, (uint32_t)pxCurrentTCB, xTicksToWait);} -#else /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */ -#define traceTASK_NOTIFY_TAKE() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask){ \ - if (pxCurrentTCB->eNotifyState == eNotified) \ - prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_TAKE, (uint32_t)pxCurrentTCB, xTicksToWait); \ - else \ - prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_TAKE_FAILED, (uint32_t)pxCurrentTCB, xTicksToWait);} -#endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */ - -#undef traceTASK_NOTIFY_TAKE_BLOCK -#define traceTASK_NOTIFY_TAKE_BLOCK() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_TAKE_BLOCK, (uint32_t)pxCurrentTCB, xTicksToWait); - -#undef traceTASK_NOTIFY_WAIT -#if (TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0) -#define traceTASK_NOTIFY_WAIT() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask){ \ - if (pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED) \ - prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_WAIT, (uint32_t)pxCurrentTCB, xTicksToWait); \ - else \ - prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_WAIT_FAILED, (uint32_t)pxCurrentTCB, xTicksToWait);} -#else /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */ -#define traceTASK_NOTIFY_WAIT() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask){ \ - if (pxCurrentTCB->eNotifyState == eNotified) \ - prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_WAIT, (uint32_t)pxCurrentTCB, xTicksToWait); \ - else \ - prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_WAIT_FAILED, (uint32_t)pxCurrentTCB, xTicksToWait);} -#endif /* TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_9_0_0 */ - -#undef traceTASK_NOTIFY_WAIT_BLOCK -#define traceTASK_NOTIFY_WAIT_BLOCK() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_WAIT_BLOCK, (uint32_t)pxCurrentTCB, xTicksToWait); - -#undef traceTASK_NOTIFY -#define traceTASK_NOTIFY() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TASK, xTaskToNotify) & CurrentFilterMask) \ - prvTraceStoreEvent1(PSF_EVENT_TASK_NOTIFY, (uint32_t)xTaskToNotify); - -#undef traceTASK_NOTIFY_FROM_ISR -#define traceTASK_NOTIFY_FROM_ISR() \ - if (TRACE_GET_OBJECT_FILTER(TASK, xTaskToNotify) & CurrentFilterMask) \ - prvTraceStoreEvent1(PSF_EVENT_TASK_NOTIFY_FROM_ISR, (uint32_t)xTaskToNotify); - -#undef traceTASK_NOTIFY_GIVE_FROM_ISR -#define traceTASK_NOTIFY_GIVE_FROM_ISR() \ - if (TRACE_GET_OBJECT_FILTER(TASK, xTaskToNotify) & CurrentFilterMask) \ - prvTraceStoreEvent1(PSF_EVENT_TASK_NOTIFY_GIVE_FROM_ISR, (uint32_t)xTaskToNotify); - -#undef traceQUEUE_REGISTRY_ADD -#define traceQUEUE_REGISTRY_ADD(object, name) \ - prvTraceSaveSymbol(object, (const char*)name); \ - prvTraceStoreStringEvent(1, PSF_EVENT_OBJ_NAME, name, object); - -#if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) - -#undef traceSTREAM_BUFFER_CREATE -#define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) \ - TRACE_SET_OBJECT_FILTER(STREAMBUFFER, pxStreamBuffer, CurrentFilterGroup); \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, pxStreamBuffer) & CurrentFilterMask) \ - prvTraceStoreEvent2(xIsMessageBuffer == 1 ? PSF_EVENT_MESSAGEBUFFER_CREATE : PSF_EVENT_STREAMBUFFER_CREATE, (uint32_t)pxStreamBuffer, xBufferSizeBytes); - -#undef traceSTREAM_BUFFER_CREATE_FAILED -#define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreEvent2(xIsMessageBuffer == 1 ? PSF_EVENT_MESSAGEBUFFER_CREATE_FAILED : PSF_EVENT_STREAMBUFFER_CREATE_FAILED, 0 , xBufferSizeBytes); - -#undef traceSTREAM_BUFFER_CREATE_STATIC_FAILED -#define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ) \ - traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) - -#undef traceSTREAM_BUFFER_DELETE -#define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, pxStreamBuffer) & CurrentFilterMask) \ - prvTraceStoreEvent2(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_DELETE : PSF_EVENT_STREAMBUFFER_DELETE, (uint32_t)xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); \ - prvTraceDeleteSymbol(xStreamBuffer); - -#undef traceSTREAM_BUFFER_RESET -#define traceSTREAM_BUFFER_RESET( xStreamBuffer ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \ - prvTraceStoreEvent2(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RESET : PSF_EVENT_STREAMBUFFER_RESET, (uint32_t)xStreamBuffer, 0); - -#undef traceSTREAM_BUFFER_SEND -#define traceSTREAM_BUFFER_SEND( xStreamBuffer, xReturn ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \ - prvTraceStoreEvent2(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND : PSF_EVENT_STREAMBUFFER_SEND, (uint32_t)xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); - -#undef traceBLOCKING_ON_STREAM_BUFFER_SEND -#define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \ - prvTraceStoreEvent1(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND_BLOCK : PSF_EVENT_STREAMBUFFER_SEND_BLOCK, (uint32_t)xStreamBuffer); - -#undef traceSTREAM_BUFFER_SEND_FAILED -#define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \ - prvTraceStoreEvent1(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND_FAILED : PSF_EVENT_STREAMBUFFER_SEND_FAILED, (uint32_t)xStreamBuffer); - -#undef traceSTREAM_BUFFER_RECEIVE -#define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \ - prvTraceStoreEvent2(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE: PSF_EVENT_STREAMBUFFER_RECEIVE, (uint32_t)xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); - -#undef traceBLOCKING_ON_STREAM_BUFFER_RECEIVE -#define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \ - prvTraceStoreEvent1(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE_BLOCK: PSF_EVENT_STREAMBUFFER_RECEIVE_BLOCK, (uint32_t)xStreamBuffer); - -#undef traceSTREAM_BUFFER_RECEIVE_FAILED -#define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \ - prvTraceStoreEvent1(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE_FAILED: PSF_EVENT_STREAMBUFFER_RECEIVE_FAILED, (uint32_t)xStreamBuffer); - -#undef traceSTREAM_BUFFER_SEND_FROM_ISR -#define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xReturn ) \ - if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \ - { \ - if ( xReturn > ( size_t ) 0 ) \ - { \ - prvTraceStoreEvent2(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND_FROM_ISR : PSF_EVENT_STREAMBUFFER_SEND_FROM_ISR, (uint32_t)xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); \ - } \ - else \ - { \ - prvTraceStoreEvent1(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_SEND_FROM_ISR_FAILED : PSF_EVENT_STREAMBUFFER_SEND_FROM_ISR_FAILED, (uint32_t)xStreamBuffer); \ - } \ - } - -#undef traceSTREAM_BUFFER_RECEIVE_FROM_ISR -#define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) \ -if (TRACE_GET_OBJECT_FILTER(STREAMBUFFER, xStreamBuffer) & CurrentFilterMask) \ - { \ - if ( xReceivedLength > ( size_t ) 0 ) \ - { \ - prvTraceStoreEvent2(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE_FROM_ISR : PSF_EVENT_STREAMBUFFER_RECEIVE_FROM_ISR, (uint32_t)xStreamBuffer, prvBytesInBuffer(xStreamBuffer)); \ - } \ - else \ - { \ - prvTraceStoreEvent1(prvGetStreamBufferType(xStreamBuffer) > 0 ? PSF_EVENT_MESSAGEBUFFER_RECEIVE_FROM_ISR_FAILED : PSF_EVENT_STREAMBUFFER_RECEIVE_FROM_ISR_FAILED, (uint32_t)xStreamBuffer); \ - } \ - } - -#endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1) */ - -#endif /* (TRC_CFG_SCHEDULING_ONLY == 0) */ - -#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */ - -#else /* (TRC_USE_TRACEALYZER_RECORDER == 1) */ - -/* When recorder is disabled */ -#define vTraceSetQueueName(object, name) -#define vTraceSetSemaphoreName(object, name) -#define vTraceSetMutexName(object, name) -#define vTraceSetEventGroupName(object, name) -#define vTraceSetStreamBufferName(object, name) -#define vTraceSetMessageBufferName(object, name) - -#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */ - -#ifdef __cplusplus -} -#endif - -#endif /* TRC_KERNEL_PORT_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcPortDefines.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcPortDefines.h deleted file mode 100755 index 30858c9..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcPortDefines.h +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.5 - * Percepio AB, www.percepio.com - * - * trcPortDefines.h - * - * Some common defines for the trace recorder. - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_PORTDEFINES_H -#define TRC_PORTDEFINES_H - -#define TRC_FREE_RUNNING_32BIT_INCR 1 -#define TRC_FREE_RUNNING_32BIT_DECR 2 -#define TRC_OS_TIMER_INCR 3 -#define TRC_OS_TIMER_DECR 4 -#define TRC_CUSTOM_TIMER_INCR 5 -#define TRC_CUSTOM_TIMER_DECR 6 - -/* Start options for vTraceEnable. */ -#define TRC_INIT 0 -#define TRC_START 1 -#define TRC_START_AWAIT_HOST 2 - -/* Command codes for TzCtrl task */ -#define CMD_SET_ACTIVE 1 /* Start (param1 = 1) or Stop (param1 = 0) */ - -/* The final command code, used to validate commands. */ -#define CMD_LAST_COMMAND 1 - -#define TRC_RECORDER_MODE_SNAPSHOT 0 -#define TRC_RECORDER_MODE_STREAMING 1 - -#define TRC_RECORDER_BUFFER_ALLOCATION_STATIC (0x00) -#define TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC (0x01) -#define TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM (0x02) - -/* Filter Groups */ -#define FilterGroup0 (uint16_t)0x0001 -#define FilterGroup1 (uint16_t)0x0002 -#define FilterGroup2 (uint16_t)0x0004 -#define FilterGroup3 (uint16_t)0x0008 -#define FilterGroup4 (uint16_t)0x0010 -#define FilterGroup5 (uint16_t)0x0020 -#define FilterGroup6 (uint16_t)0x0040 -#define FilterGroup7 (uint16_t)0x0080 -#define FilterGroup8 (uint16_t)0x0100 -#define FilterGroup9 (uint16_t)0x0200 -#define FilterGroup10 (uint16_t)0x0400 -#define FilterGroup11 (uint16_t)0x0800 -#define FilterGroup12 (uint16_t)0x1000 -#define FilterGroup13 (uint16_t)0x2000 -#define FilterGroup14 (uint16_t)0x4000 -#define FilterGroup15 (uint16_t)0x8000 - -/****************************************************************************** - * Supported ports - * - * TRC_HARDWARE_PORT_HWIndependent - * A hardware independent fallback option for event timestamping. Provides low - * resolution timestamps based on the OS tick. - * This may be used on the Win32 port, but may also be used on embedded hardware - * platforms. All time durations will be truncated to the OS tick frequency, - * typically 1 KHz. This means that a task or ISR that executes in less than - * 1 ms get an execution time of zero. - * - * TRC_HARDWARE_PORT_APPLICATION_DEFINED - * Allows for defining the port macros in other source code files. - * - * TRC_HARDWARE_PORT_Win32 - * "Accurate" timestamping based on the Windows performance counter for Win32 - * builds. Note that this gives the host machine time, not the kernel time. - * - * Hardware specific ports - * To get accurate timestamping, a hardware timer is necessary. Below are the - * available ports. Some of these are "unofficial", meaning that - * they have not yet been verified by Percepio but have been contributed by - * external developers. They should work, otherwise let us know by emailing - * support@percepio.com. Some work on any OS platform, while other are specific - * to a certain operating system. - *****************************************************************************/ - -/****** Port Name ************************************* Code ** Official ** OS Platform *********/ -#define TRC_HARDWARE_PORT_APPLICATION_DEFINED 98 /* - - */ -#define TRC_HARDWARE_PORT_NOT_SET 99 /* - - */ -#define TRC_HARDWARE_PORT_HWIndependent 0 /* Yes Any */ -#define TRC_HARDWARE_PORT_Win32 1 /* Yes FreeRTOS on Win32 */ -#define TRC_HARDWARE_PORT_Atmel_AT91SAM7 2 /* No Any */ -#define TRC_HARDWARE_PORT_Atmel_UC3A0 3 /* No Any */ -#define TRC_HARDWARE_PORT_ARM_Cortex_M 4 /* Yes Any */ -#define TRC_HARDWARE_PORT_Renesas_RX600 6 /* Yes Any */ -#define TRC_HARDWARE_PORT_MICROCHIP_PIC24_PIC32 7 /* Yes Any */ -#define TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_TMS570_RM48 8 /* Yes Any */ -#define TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_MSP430 9 /* No Any */ -#define TRC_HARDWARE_PORT_XILINX_PPC405 11 /* No FreeRTOS */ -#define TRC_HARDWARE_PORT_XILINX_PPC440 12 /* No FreeRTOS */ -#define TRC_HARDWARE_PORT_XILINX_MICROBLAZE 13 /* No Any */ -#define TRC_HARDWARE_PORT_NXP_LPC210X 14 /* No Any */ -#define TRC_HARDWARE_PORT_ARM_CORTEX_A9 15 /* Yes Any */ -#define TRC_HARDWARE_PORT_POWERPC_Z4 16 /* No FreeRTOS */ -#define TRC_HARDWARE_PORT_Altera_NiosII 17 /* No Any */ -#endif /*TRC_PORTDEFINES_H*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcRecorder.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcRecorder.h deleted file mode 100755 index 38e5ef7..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcRecorder.h +++ /dev/null @@ -1,1789 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.5 - * Percepio AB, www.percepio.com - * - * trcRecorder.h - * - * The public API of the trace recorder. - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_RECORDER_H -#define TRC_RECORDER_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -#include "trcConfig.h" -#include "trcPortDefines.h" - - -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) -typedef uint16_t traceString; -typedef uint8_t traceUBChannel; -typedef uint8_t traceObjectClass; - -#if (TRC_CFG_USE_16BIT_OBJECT_HANDLES == 1) -typedef uint16_t traceHandle; -#else -typedef uint8_t traceHandle; -#endif - -#include "trcHardwarePort.h" -#include "trcKernelPort.h" - -// Not available in snapshot mode -#define vTraceConsoleChannelPrintF(fmt, ...) - -#endif - -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) - -typedef const char* traceString; -typedef const void* traceHandle; - -#include "trcHardwarePort.h" -#include "trcStreamingPort.h" -#include "trcKernelPort.h" - -#endif - -#if (TRC_USE_TRACEALYZER_RECORDER == 1) - -/* The user event channel for recorder warnings, must be defined in trcKernelPort.c */ -extern traceString trcWarningChannel; - -#define TRACE_GET_LOW16(value) ((uint16_t)((value) & 0x0000FFFF)) -#define TRACE_GET_HIGH16(value) ((uint16_t)(((value) >> 16) & 0x0000FFFF)) -#define TRACE_SET_LOW16(current, value) (((current) & 0xFFFF0000) | (value)) -#define TRACE_SET_HIGH16(current, value) (((current) & 0x0000FFFF) | (((uint32_t)(value)) << 16)) - -/******************************************************************************/ -/*** Common API - both Snapshot and Streaming mode ****************************/ -/******************************************************************************/ - -/****************************************************************************** -* vTraceEnable(int startOption); -* -* Initializes and optionally starts the trace, depending on the start option. -* To use the trace recorder, the startup must call vTraceEnable before any RTOS -* calls are made (including "create" calls). Three start options are provided: -* -* TRC_START: Starts the tracing directly. In snapshot mode this allows for -* starting the trace at any point in your code, assuming vTraceEnable(TRC_INIT) -* has been called in the startup. -* Can also be used for streaming without Tracealyzer control, e.g. to a local -* flash file system (assuming such a "stream port", see trcStreamingPort.h). -* -* TRC_START_AWAIT_HOST: For streaming mode only. Initializes the trace recorder -* if necessary and waits for a Start command from Tracealyzer ("Start Recording" -* button). This call is intentionally blocking! By calling vTraceEnable with -* this option from the startup code, you start tracing at this point and capture -* the early events. -* -* TRC_INIT: Initializes the trace recorder, but does not start the tracing. -* In snapshot mode, this must be followed by a vTraceEnable(TRC_START) sometime -* later. -* -* Usage examples: -* -* Snapshot trace, from startup: -* -* vTraceEnable(TRC_START); -* -* -* Snapshot trace, from a later point: -* -* vTraceEnable(TRC_INIT); -* -* ... -* vTraceEnable(TRC_START); // e.g., in task context, at some relevant event -* -* Streaming trace, from startup: -* -* vTraceEnable(TRC_START_AWAIT_HOST); // Blocks! -* -* -* Streaming trace, from a later point: -* -* vTraceEnable(TRC_INIT); -* -* -******************************************************************************/ -void vTraceEnable(int startOption); - -/****************************************************************************** - * vTracePrintF - * - * Generates "User Events", with formatted text and data, similar to a "printf". - * User Events can be used for very efficient logging from your application code. - * It is very fast since the actual string formatting is done on the host side, - * when the trace is displayed. The execution time is just some microseconds on - * a 32-bit MCU. - * - * User Events are shown as yellow labels in the main trace view of $PNAME. - * - * An advantage of User Events is that data can be plotted in the "User Event - * Signal Plot" view, visualizing any data you log as User Events, discrete - * states or control system signals (e.g. system inputs or outputs). - * - * You may group User Events into User Event Channels. The yellow User Event - * labels show the logged string, preceded by the channel name within brackets. - * - * Example: - * - * "[MyChannel] Hello World!" - * - * The User Event Channels are shown in the View Filter, which makes it easy to - * select what User Events you wish to display. User Event Channels are created - * using xTraceRegisterString(). - * - * Example: - * - * traceString adc_uechannel = xTraceRegisterString("ADC User Events"); - * ... - * vTracePrintF(adc_uechannel, - * "ADC channel %d: %d volts", - * ch, adc_reading); - * - * The following format specifiers are supported in both modes: - * %d - signed integer. - * %u - unsigned integer. - * %X - hexadecimal, uppercase. - * %x - hexadecimal, lowercase. - * %s - string (see comment below) - * - * For integer formats (%d, %u, %x, %X) you may also use width and padding. - * If using -42 as data argument, two examples are: - * "%05d" -> "-0042" - * "%5d" -> " -42". - * - * String arguments are supported in both snapshot and streaming, but in streaming - * mode you need to use xTraceRegisterString and use the returned traceString as - * the argument. In snapshot you simply provide a char* as argument. - * - * Snapshot: vTracePrintF(myChn, "my string: %s", str); - * Streaming: vTracePrintF(myChn, "my string: %s", xTraceRegisterString(str)); - * - * In snapshot mode you can specify 8-bit or 16-bit arguments to reduce RAM usage: - * %hd -> 16 bit (h) signed integer (d). - * %bu -> 8 bit (b) unsigned integer (u). - * - * However, in streaming mode all data arguments are assumed to be 32 bit wide. - * Width specifiers (e.g. %hd) are accepted but ignored (%hd treated like %d). - * - * The maximum event size also differs between the modes. In streaming this is - * limited by a maximum payload size of 52 bytes, including format string and - * data arguments. So if using one data argument, the format string is limited - * to 48 byte, etc. If this is exceeded, the format string is truncated and you - * get a warning in Tracealyzer. - * - * In snapshot mode you are limited to maximum 15 arguments, that must not exceed - * 32 bytes in total (not counting the format string). If exceeded, the recorder - * logs an internal error (displayed when opening the trace) and stops recording. - ******************************************************************************/ -#if (TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) -void vTracePrintF(traceString chn, const char* fmt, ...); -#else -#define vTracePrintF(chn, ...) (void)chn -#endif - - /****************************************************************************** -* vTracePrint -* -* A faster version of vTracePrintF, that only allows for logging a string. -* -* Example: -* -* traceString chn = xTraceRegisterString("MyChannel"); -* ... -* vTracePrint(chn, "Hello World!"); -******************************************************************************/ -#if (TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) -void vTracePrint(traceString chn, const char* str); -#else -#define vTracePrint(chn, ...) (void)chn -#endif - - -/******************************************************************************* -* vTraceConsoleChannelPrintF -* -* Wrapper for vTracePrint, using the default channel. Can be used as a drop-in -* replacement for printf and similar functions, e.g. in a debug logging macro. -* -* Example: -* -* // Old: #define LogString debug_console_printf -* -* // New, log to Tracealyzer instead: -* #define LogString vTraceConsoleChannelPrintF -* ... -* LogString("My value is: %d", myValue); -******************************************************************************/ -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) -void vTraceConsoleChannelPrintF(const char* fmt, ...); -#endif - -/******************************************************************************* -* xTraceRegisterString -* -* Register strings in the recorder, e.g. for names of user event channels. -* -* Example: -* myEventHandle = xTraceRegisterString("MyUserEvent"); -* ... -* vTracePrintF(myEventHandle, "My value is: %d", myValue); -******************************************************************************/ -#if (TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) -traceString xTraceRegisterString(const char* name); -#else -#define xTraceRegisterString(x) (x) -#endif - -/******************************************************************************* - * vTraceSet...Name(void* object, const char* name) - * - * Parameter object: pointer to the kernel object that shall be named - * Parameter name: the name to set - * - * Kernel-specific functions for setting names of kernel objects, for display in - * Tracealyzer. - ******************************************************************************/ -/* See trcKernelPort.h for details (kernel-specific) */ - -/******************************************************************************* - * xTraceSetISRProperties - * - * Stores a name and priority level for an Interrupt Service Routine, to allow - * for better visualization. Returns a traceHandle used by vTraceStoreISRBegin. - * - * Example: - * #define PRIO_ISR_TIMER1 3 // the hardware priority of the interrupt - * ... - * traceHandle Timer1Handle = xTraceSetISRProperties("ISRTimer1", PRIO_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin(Timer1Handle); - * ... - * vTraceStoreISREnd(0); - * } - ******************************************************************************/ -traceHandle xTraceSetISRProperties(const char* name, uint8_t priority); - -/******************************************************************************* - * vTraceStoreISRBegin - * - * Registers the beginning of an Interrupt Service Routine, using a traceHandle - * provided by xTraceSetISRProperties. - * - * Example: - * #define PRIO_ISR_TIMER1 3 // the hardware priority of the interrupt - * ... - * traceHandle Timer1Handle = xTraceSetISRProperties("ISRTimer1", PRIO_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin(Timer1Handle); - * ... - * vTraceStoreISREnd(0); - * } - ******************************************************************************/ -void vTraceStoreISRBegin(traceHandle handle); - -/******************************************************************************* - * vTraceStoreISREnd - * - * Registers the end of an Interrupt Service Routine. - * - * The parameter pendingISR indicates if the interrupt has requested a - * task-switch (= 1), e.g., by signaling a semaphore. Otherwise (= 0) the - * interrupt is assumed to return to the previous context. - * - * Example: - * #define PRIO_OF_ISR_TIMER1 3 // the hardware priority of the interrupt - * traceHandle traceHandleIsrTimer1 = 0; // The ID set by the recorder - * ... - * traceHandleIsrTimer1 = xTraceSetISRProperties("ISRTimer1", PRIO_OF_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin(traceHandleIsrTimer1); - * ... - * vTraceStoreISREnd(0); - * } - ******************************************************************************/ -void vTraceStoreISREnd(int isTaskSwitchRequired); - -/******************************************************************************* - * vTraceInstanceFinishNow - * - * Creates an event that ends the current task instance at this very instant. - * This makes the viewer to splits the current fragment at this point and begin - * a new actor instance, even if no task-switch has occurred. - *****************************************************************************/ -void vTraceInstanceFinishedNow(void); - -/******************************************************************************* - * vTraceInstanceFinishedNext - * - * Marks the current "task instance" as finished on the next kernel call. - * - * If that kernel call is blocking, the instance ends after the blocking event - * and the corresponding return event is then the start of the next instance. - * If the kernel call is not blocking, the viewer instead splits the current - * fragment right before the kernel call, which makes this call the first event - * of the next instance. - *****************************************************************************/ -void vTraceInstanceFinishedNext(void); - -/******************************************************************************* - * xTraceGetLastError - * - * Returns the last error or warning as a string, or NULL if none. - *****************************************************************************/ -const char* xTraceGetLastError(void); - -/******************************************************************************* - * vTraceClearError - * - * Clears any errors. - *****************************************************************************/ -void vTraceClearError(void); - -/******************************************************************************* -* vTraceStop -* -* Stops the recording. Intended for snapshot mode or if streaming without -* Tracealyzer control (e.g., to a device file system). -******************************************************************************/ -void vTraceStop(void); - -/****************************************************************************** -* vTraceSetFrequency -* -* Registers the clock rate of the time source for the event timestamping. -* This is normally not required, but if the default value (TRC_HWTC_FREQ_HZ) -* should be incorrect for your setup, you can override it using this function. -* -* Must be called prior to vTraceEnable, and the time source is assumed to -* have a fixed clock frequency after the startup. -* -* Note that, in snapshot mode, the value is divided by the TRC_HWTC_DIVISOR. -* This is a software "prescaler" that is also applied on the timestamps. -*****************************************************************************/ -void vTraceSetFrequency(uint32_t frequency); - -/******************************************************************************* -* vTraceSetRecorderDataBuffer -* -* The trcConfig.h setting TRC_CFG_RECORDER_BUFFER_ALLOCATION allows for selecting -* custom allocation (TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM), which allows you to -* control where the recorder trace buffer is allocated. -* -* When custom allocation is selected, use TRC_ALLOC_CUSTOM_BUFFER to make the -* allocation (in global context) and then call vTraceSetRecorderDataBuffer to -* register the allocated buffer. This supports both snapshot and streaming, -* and has no effect if using other allocation modes than CUSTOM. -* -* NOTE: vTraceSetRecorderDataBuffer must be called before vTraceEnable. -******************************************************************************/ -#if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM) -void vTraceSetRecorderDataBuffer(void* pRecorderData); -#else -#define vTraceSetRecorderDataBuffer(pRecorderData) -#endif - - -/******************************************************************************* -* TRC_ALLOC_CUSTOM_BUFFER -* -* If using custom allocation of the trace buffer (i.e., your trcConfig.h has the -* setting TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM), this macro allows you to declare -* the trace buffer in a portable way that works both in snapshot and streaming. -* -* This macro has no effect if using another allocation mode, so you can easily -* switch between different recording modes and configurations, using the same -* initialization code. -* -* This translates to a single static allocation, on which you can apply linker -* directives to place it in a particular memory region. -* -* - Snapshot mode: "RecorderDataType " -* -* - Streaming mode: "char []", -* where is defined in trcStreamingConfig.h. -* -* Example: -* -* // GCC example: place myTraceBuffer in section .tz, defined in the .ld file. -* TRC_ALLOC_CUSTOM_BUFFER(myTraceBuffer) __attribute__((section(".tz"))); -* -* int main(void) -* { -* ... -* vTraceSetRecorderDataBuffer(&myTraceBuffer); // Note the "&" -* ... -* vTraceEnable(TRC_INIT); // Initialize the data structure -******************************************************************************/ -#if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM) - #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) - #define TRC_ALLOC_CUSTOM_BUFFER(bufname) RecorderDataType bufname; - #elif (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) - #ifdef TRC_CFG_RTT_BUFFER_SIZE_UP /* J-Link RTT */ - #define TRC_ALLOC_CUSTOM_BUFFER(bufname) char bufname [TRC_CFG_RTT_BUFFER_SIZE_UP]; /* Not static in this case, since declared in user code */ - #else - #define TRC_ALLOC_CUSTOM_BUFFER(bufname) char bufname [(TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT) * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE)]; - #endif - #endif -#else - #define TRC_ALLOC_CUSTOM_BUFFER(bufname) -#endif - -/****************************************************************************** -* xTraceIsRecordingEnabled -* -* Returns true (1) if the recorder is enabled (i.e. is recording), otherwise 0. -******************************************************************************/ -int xTraceIsRecordingEnabled(void); - -/******************************************************************************* -* vTraceSetFilterGroup -* -* Sets the "filter group" to assign when creating RTOS objects, such as tasks, -* queues, semaphores and mutexes. This together with vTraceSetFilterMask -* allows you to control what events that are recorded, based on the -* objects they refer to. -* -* There are 16 filter groups named FilterGroup0 .. FilterGroup15. -* -* Note: We don't recommend filtering out the Idle task, so make sure to call -* vTraceSetFilterGroup just before initializing the RTOS, in order to assign -* such "default" objects to the right Filter Group (typically group 0). -* -* Example: -* -* // Assign tasks T1 to FilterGroup0 (default) -* -* -* // Assign Q1 and Q2 to FilterGroup1 -* vTraceSetFilterGroup(FilterGroup1); -* -* -* -* // Assigns Q3 to FilterGroup2 -* vTraceSetFilterGroup(FilterGroup2); -* -* -* // Only include FilterGroup0 and FilterGroup2, exclude FilterGroup1 (Q1 and Q2) from the trace -* vTraceSetFilterMask( FilterGroup0 | FilterGroup2 ); -* -* // Assign the default RTOS objects (e.g. Idle task) to FilterGroup0 -* vTraceSetFilterGroup(FilterGroup0); -* -* -* Note that you may define your own names for the filter groups using -* preprocessor definitions, to make the code easier to understand. -* -* Example: -* -* #define BASE FilterGroup0 -* #define USB_EVENTS FilterGroup1 -* #define CAN_EVENTS FilterGroup2 -* -* Note that filtering per event type (regardless of object) is also available -* in trcConfig.h. -******************************************************************************/ -void vTraceSetFilterGroup(uint16_t filterGroup); - -/****************************************************************************** -* vTraceSetFilterMask -* -* Sets the "filter mask" that is used to filter the events by object. This can -* be used to reduce the trace data rate, i.e., if your streaming interface is -* a bottleneck or if you want longer snapshot traces without increasing the -* buffer size. -* -* Note: There are two kinds of filters in the recorder. The other filter type -* excludes all events of certain kinds (e.g., OS ticks). See trcConfig.h. -* -* The filtering is based on bitwise AND with the Filter Group ID, assigned -* to RTOS objects such as tasks, queues, semaphores and mutexes. -* This together with vTraceSetFilterGroup allows you to control what -* events that are recorded, based on the objects they refer to. -* -* See example for vTraceSetFilterGroup. -******************************************************************************/ -void vTraceSetFilterMask(uint16_t filterMask); - -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) - -/******************************************************************************/ -/*** Extended API for Snapshot mode *******************************************/ -/******************************************************************************/ - -/****************************************************************************** -* TRACE_STOP_HOOK - Hook Pointer Data Type -* -* Declares a data type for a call back function that will be invoked whenever -* the recorder is stopped. -* -* Snapshot mode only! -******************************************************************************/ -typedef void(*TRACE_STOP_HOOK)(void); - -/******************************************************************************* -* vTraceStopHookPtr -* -* Points to a call back function that is called from vTraceStop(). -* -* Snapshot mode only! -******************************************************************************/ -extern TRACE_STOP_HOOK vTraceStopHookPtr; - -/******************************************************************************* -* vTraceSetStopHook -* -* Sets a function to be called when the recorder is stopped. -* -* Snapshot mode only! -******************************************************************************/ -void vTraceSetStopHook(TRACE_STOP_HOOK stopHookFunction); - -/******************************************************************************* -* uiTraceStart -* -* [DEPRECATED] Use vTraceEnable instead. -* -* Starts the recorder. The recorder will not be started if an error has been -* indicated using prvTraceError, e.g. if any of the Nx constants in -* trcSnapshotConfig.h has a too small value (TRC_CFG_NTASK, TRC_CFG_NQUEUE, etc). -* -* Returns 1 if the recorder was started successfully. -* Returns 0 if the recorder start was prevented due to a previous internal -* error. In that case, check xTraceGetLastError to get the error message. -* Any error message is also presented when opening a trace file. -* -* Snapshot mode only! -******************************************************************************/ -uint32_t uiTraceStart(void); - -/******************************************************************************* -* vTraceStart -* -* [DEPRECATED] Use vTraceEnable instead. -* -* Starts the recorder. The recorder will not be started if an error has been -* indicated using prvTraceError, e.g. if any of the Nx constants in -* trcSnapshotConfig.h has a too small value (TRC_CFG_NTASK, TRC_CFG_NQUEUE, etc). -* -* Snapshot mode only! -******************************************************************************/ -void vTraceStart(void); - -/******************************************************************************* -* vTraceClear -* -* Resets the recorder. Only necessary if a restart is desired - this is not -* needed in the startup initialization. -* -* Snapshot mode only! -******************************************************************************/ -void vTraceClear(void); - - -/*****************************************************************************/ -/*** INTERNAL SNAPSHOT FUNCTIONS *********************************************/ -/*****************************************************************************/ - -#define TRC_UNUSED - -#ifndef TRC_CFG_INCLUDE_OBJECT_DELETE -#define TRC_CFG_INCLUDE_OBJECT_DELETE 0 -#endif - -#ifndef TRC_CFG_INCLUDE_READY_EVENTS -#define TRC_CFG_INCLUDE_READY_EVENTS 1 -#endif - -#ifndef TRC_CFG_INCLUDE_OSTICK_EVENTS -#define TRC_CFG_INCLUDE_OSTICK_EVENTS 0 -#endif - -/* This macro will create a task in the object table */ -#undef trcKERNEL_HOOKS_TASK_CREATE -#define trcKERNEL_HOOKS_TASK_CREATE(SERVICE, CLASS, pxTCB) \ - TRACE_SET_OBJECT_NUMBER(TASK, pxTCB); \ - TRACE_SET_OBJECT_FILTER(TASK, pxTCB, CurrentFilterGroup); \ - prvTraceSetObjectName(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_GET_TASK_NAME(pxTCB)); \ - prvTraceSetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_GET_TASK_PRIORITY(pxTCB)); \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \ - prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); - -/* This macro will remove the task and store it in the event buffer */ -#undef trcKERNEL_HOOKS_TASK_DELETE -#define trcKERNEL_HOOKS_TASK_DELETE(SERVICE, SERVICE_NAME, SERVICE_PROP, pxTCB) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \ - prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); \ - prvTraceStoreObjectNameOnCloseEvent(SERVICE_NAME, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_CLASS_TASK); \ - prvTraceStoreObjectPropertiesOnCloseEvent(SERVICE_PROP, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_CLASS_TASK); \ - prvTraceSetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_GET_TASK_PRIORITY(pxTCB)); \ - prvTraceSetObjectState(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TASK_STATE_INSTANCE_NOT_ACTIVE); \ - prvTraceFreeObjectHandle(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); - - -/* This macro will setup a task in the object table */ -#undef trcKERNEL_HOOKS_OBJECT_CREATE -#define trcKERNEL_HOOKS_OBJECT_CREATE(SERVICE, CLASS, pxObject)\ - TRACE_SET_OBJECT_NUMBER(CLASS, pxObject);\ - TRACE_SET_OBJECT_FILTER(CLASS, pxObject, CurrentFilterGroup); \ - prvMarkObjectAsUsed(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject));\ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \ - prvTraceStoreKernelCall(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject)); \ - prvTraceSetObjectState(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), 0); - -/* This macro will remove the object and store it in the event buffer */ -#undef trcKERNEL_HOOKS_OBJECT_DELETE -#define trcKERNEL_HOOKS_OBJECT_DELETE(SERVICE, SERVICE_NAME, SERVICE_PROP, CLASS, pxObject) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \ - prvTraceStoreKernelCall(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject)); \ - prvTraceStoreObjectNameOnCloseEvent(SERVICE_NAME, TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject)); \ - prvTraceStoreObjectPropertiesOnCloseEvent(SERVICE_PROP, TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject)); \ - prvTraceFreeObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject)); - -/* This macro will create a call to a kernel service with a certain result, with an object as parameter */ -#undef trcKERNEL_HOOKS_KERNEL_SERVICE -#define trcKERNEL_HOOKS_KERNEL_SERVICE(SERVICE, CLASS, pxObject) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \ - prvTraceStoreKernelCall(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject)); - -/* This macro will create a call to a kernel service with a certain result, with a null object as parameter */ -#undef trcKERNEL_HOOKS_KERNEL_SERVICE_NULL_OBJECT -#define trcKERNEL_HOOKS_KERNEL_SERVICE_NULL_OBJECT(SERVICE, TRACECLASS) \ - if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreKernelCall(SERVICE, TRACECLASS, 0); - -/* This macro will create a call to a kernel service with a certain result, with an object as parameter */ -#undef trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM -#define trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(SERVICE, CLASS, pxObject, param) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \ - prvTraceStoreKernelCallWithParam(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), (uint32_t)param); - -/* This macro will create a call to a kernel service with a certain result, with a null object and other value as parameter */ -#undef trcKERNEL_HOOKS_KERNEL_SERVICE_NULL_OBJECT_WITH_PARAM -#define trcKERNEL_HOOKS_KERNEL_SERVICE_NULL_OBJECT_WITH_PARAM(SERVICE, TRACECLASS, param) \ - if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreKernelCallWithParam(SERVICE, TRACECLASS, 0, param); - -/* This macro will create a call to a kernel service with a certain result, with an object as parameter */ -#undef trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY -#define trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(SERVICE, param) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceStoreKernelCallWithNumericParamOnly(SERVICE, (uint32_t)param); - -/* This macro will create a call to a kernel service with a certain result, with an object as parameter */ -#undef trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR -#define trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(SERVICE, CLASS, pxObject) \ - if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \ - prvTraceStoreKernelCall(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject)); - -/* This macro will create a call to a kernel service with a certain result, with an object as parameter */ -#undef trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM_FROM_ISR -#define trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM_FROM_ISR(SERVICE, CLASS, pxObject, param) \ - if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \ - prvTraceStoreKernelCallWithParam(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), (uint32_t)param); - -/* This macro will create a call to a kernel service with a certain result, with an object as parameter */ -#undef trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY_FROM_ISR -#define trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY_FROM_ISR(SERVICE, param) \ - prvTraceStoreKernelCallWithNumericParamOnly(SERVICE, (uint32_t)param); - -/* This macro will set the state for an object */ -#undef trcKERNEL_HOOKS_SET_OBJECT_STATE -#define trcKERNEL_HOOKS_SET_OBJECT_STATE(CLASS, pxObject, STATE) \ - prvTraceSetObjectState(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), (uint8_t)STATE); - -/* This macro will flag a certain task as a finished instance */ -#undef trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED -#define trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED() \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - prvTraceSetTaskInstanceFinished(TRACE_GET_TASK_NUMBER(TRACE_GET_CURRENT_TASK())); - -#if (TRC_CFG_INCLUDE_READY_EVENTS == 1) -/* This macro will create an event to indicate that a task became Ready */ -#undef trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE -#define trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE(pxTCB) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \ - prvTraceStoreTaskReady(TRACE_GET_TASK_NUMBER(pxTCB)); -#else /*(TRC_CFG_INCLUDE_READY_EVENTS == 1)*/ -#undef trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE -#define trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE(pxTCB) -#endif /*(TRC_CFG_INCLUDE_READY_EVENTS == 1)*/ - -/* This macro will update the internal tick counter and call prvTracePortGetTimeStamp(0) to update the internal counters */ -#undef trcKERNEL_HOOKS_INCREMENT_TICK -#define trcKERNEL_HOOKS_INCREMENT_TICK() \ - { \ - extern uint32_t uiTraceTickCount; \ - uiTraceTickCount++; \ - prvTracePortGetTimeStamp(0); \ - } - -#if (TRC_CFG_INCLUDE_OSTICK_EVENTS == 1) -/* This macro will create an event indicating that the OS tick count has increased */ -#undef trcKERNEL_HOOKS_NEW_TIME -#define trcKERNEL_HOOKS_NEW_TIME(SERVICE, xValue) \ - prvTraceStoreKernelCallWithNumericParamOnly(SERVICE, xValue); -#else /*(TRC_CFG_INCLUDE_OSTICK_EVENTS == 1)*/ -#undef trcKERNEL_HOOKS_NEW_TIME -#define trcKERNEL_HOOKS_NEW_TIME(SERVICE, xValue) -#endif /*(TRC_CFG_INCLUDE_OSTICK_EVENTS == 1)*/ - -/* This macro will create a task switch event to the currently executing task */ -#undef trcKERNEL_HOOKS_TASK_SWITCH -#define trcKERNEL_HOOKS_TASK_SWITCH( pxTCB ) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \ - prvTraceStoreTaskswitch(TRACE_GET_TASK_NUMBER(pxTCB)); - -/* This macro will create an event to indicate that the task has been suspended */ -#undef trcKERNEL_HOOKS_TASK_SUSPEND -#define trcKERNEL_HOOKS_TASK_SUSPEND(SERVICE, pxTCB) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \ - prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); \ - prvTraceSetTaskInstanceFinished((uint8_t)TRACE_GET_TASK_NUMBER(pxTCB)); - -/* This macro will create an event to indicate that a task has called a wait/delay function */ -#undef trcKERNEL_HOOKS_TASK_DELAY -#define trcKERNEL_HOOKS_TASK_DELAY(SERVICE, pxTCB, xValue) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \ - { \ - prvTraceStoreKernelCallWithNumericParamOnly(SERVICE, xValue); \ - prvTraceSetTaskInstanceFinished((uint8_t)TRACE_GET_TASK_NUMBER(pxTCB)); \ - } - -/* This macro will create an event to indicate that a task has gotten its priority changed */ -#undef trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE -#define trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(SERVICE, pxTCB, uxNewPriority) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \ - { \ - prvTraceStoreKernelCallWithParam(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), prvTraceGetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)));\ - prvTraceSetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), (uint8_t)uxNewPriority); \ - } - -/* This macro will create an event to indicate that the task has been resumed */ -#undef trcKERNEL_HOOKS_TASK_RESUME -#define trcKERNEL_HOOKS_TASK_RESUME(SERVICE, pxTCB) \ - if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \ - prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); - -#undef trcKERNEL_HOOKS_TASK_RESUME_FROM_ISR -#define trcKERNEL_HOOKS_TASK_RESUME_FROM_ISR(SERVICE, pxTCB) \ - if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \ - prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); - -#if !defined TRC_CFG_INCLUDE_READY_EVENTS || TRC_CFG_INCLUDE_READY_EVENTS == 1 - void prvTraceSetReadyEventsEnabled(int status); - void prvTraceStoreTaskReady(traceHandle handle); -#else - #define prvTraceSetReadyEventsEnabled(status) -#endif - -void prvTraceStoreLowPower(uint32_t flag); - -void prvTraceStoreTaskswitch(traceHandle task_handle); - - -#if (TRC_CFG_SCHEDULING_ONLY == 0) - -void prvTraceStoreKernelCall(uint32_t eventcode, traceObjectClass objectClass, uint32_t byteParam); - -void prvTraceStoreKernelCallWithNumericParamOnly(uint32_t evtcode, uint32_t param); - -void prvTraceStoreKernelCallWithParam(uint32_t evtcode, traceObjectClass objectClass, - uint32_t objectNumber, uint32_t param); -#else - -#define prvTraceStoreKernelCall(eventcode, objectClass, byteParam) {} -#define prvTraceStoreKernelCallWithNumericParamOnly(evtcode, param) {} -#define prvTraceStoreKernelCallWithParam(evtcode, objectClass, objectNumber, param) {} - -#endif - -void prvTraceSetTaskInstanceFinished(traceHandle handle); - -void prvTraceSetPriorityProperty(uint8_t objectclass, traceHandle id, uint8_t value); - -uint8_t prvTraceGetPriorityProperty(uint8_t objectclass, traceHandle id); - -void prvTraceSetObjectState(uint8_t objectclass, traceHandle id, uint8_t value); - -void prvMarkObjectAsUsed(traceObjectClass objectclass, traceHandle handle); - -void prvTraceStoreObjectNameOnCloseEvent(uint8_t evtcode, traceHandle handle, - traceObjectClass objectclass); - -void prvTraceStoreObjectPropertiesOnCloseEvent(uint8_t evtcode, traceHandle handle, - traceObjectClass objectclass); - -/* Internal constants for task state */ -#define TASK_STATE_INSTANCE_NOT_ACTIVE 0 -#define TASK_STATE_INSTANCE_ACTIVE 1 - - -#if (TRC_CFG_INCLUDE_ISR_TRACING == 0) - -#undef vTraceSetISRProperties -#define vTraceSetISRProperties(handle, name, priority) - -#undef vTraceStoreISRBegin -#define vTraceStoreISRBegin(x) (void)x - -#undef vTraceStoreISREnd -#define vTraceStoreISREnd(x) (void)x - -#undef xTraceSetISRProperties -#define xTraceSetISRProperties(name, priority) 0 - -#endif /*(TRC_CFG_INCLUDE_ISR_TRACING == 0)*/ - -/******************************************************************************* - * xTraceGetTraceBuffer - * - * Returns a pointer to the recorder data structure. Use this together with - * uiTraceGetTraceBufferSize if you wish to implement an own store/upload - * solution, e.g., in case a debugger connection is not available for uploading - * the data. - ******************************************************************************/ -void* xTraceGetTraceBuffer(void); - -/******************************************************************************* - * uiTraceGetTraceBufferSize - * - * Gets the size of the recorder data structure. For use together with - * vTraceGetTraceBuffer if you wish to implement an own store/upload solution, - * e.g., in case a debugger connection is not available for uploading the data. - ******************************************************************************/ -uint32_t uiTraceGetTraceBufferSize(void); - -#if (TRC_CFG_SCHEDULING_ONLY == 1) -#undef TRC_CFG_INCLUDE_USER_EVENTS -#define TRC_CFG_INCLUDE_USER_EVENTS 0 -#endif /*(TRC_CFG_SCHEDULING_ONLY == 1)*/ - -#if ((TRC_CFG_INCLUDE_USER_EVENTS == 1) && (TRC_CFG_SCHEDULING_ONLY == 0)) - -#if (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1) -traceUBChannel xTraceRegisterUBChannel(traceString channel, traceString formatStr); -void vTraceUBData(traceUBChannel channel, ...); -void vTraceUBEvent(traceUBChannel channel); -#endif /*(TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)*/ - -#else /*((TRC_CFG_INCLUDE_USER_EVENTS == 1) && (TRC_CFG_SCHEDULING_ONLY == 0))*/ - -#undef vTracePrint -#define vTracePrint(chn, ...) (void)chn -#undef vTracePrintF -#define vTracePrintF(chn, ...) (void)chn -#undef xTraceRegisterString -#define xTraceRegisterString(x) 0; (void)x; -#undef xTraceRegisterChannelFormat -#define xTraceRegisterChannelFormat(eventLabel, formatStr) 0 -#undef vTraceUBData -#define vTraceUBData(label, ...) {} -#undef vTraceChannelPrint -#define vTraceChannelPrint(label) {} - -#endif /*(TRC_CFG_INCLUDE_USER_EVENTS == 1)*/ - -#define NEventCodes 0x100 - -/* Our local critical sections for the recorder */ -#define trcCRITICAL_SECTION_BEGIN() {TRACE_ENTER_CRITICAL_SECTION(); recorder_busy++;} -#define trcCRITICAL_SECTION_END() {recorder_busy--; TRACE_EXIT_CRITICAL_SECTION();} - -#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_Cortex_M) - #define trcSR_ALLOC_CRITICAL_SECTION_ON_CORTEX_M_ONLY TRACE_ALLOC_CRITICAL_SECTION - #define trcCRITICAL_SECTION_BEGIN_ON_CORTEX_M_ONLY trcCRITICAL_SECTION_BEGIN - #define trcCRITICAL_SECTION_END_ON_CORTEX_M_ONLY trcCRITICAL_SECTION_END -#else - #define trcSR_ALLOC_CRITICAL_SECTION_ON_CORTEX_M_ONLY() {} - #define trcCRITICAL_SECTION_BEGIN_ON_CORTEX_M_ONLY() recorder_busy++; - #define trcCRITICAL_SECTION_END_ON_CORTEX_M_ONLY() recorder_busy--; -#endif - -/****************************************************************************** - * ObjectHandleStack - * This data-structure is used to provide a mechanism for 1-byte trace object - * handles. This way, only 1 byte is necessary instead of 4 bytes (a pointer) - * when storing a reference to an object. This allows for up to 255 objects of - * each object class active at any given moment. There can be more "historic" - * objects, that have been deleted - that number is only limited by the size of - * the symbol table. - * - * Note that handle zero (0) is not used, it is a code for an invalid handle. - * - * This data structure keeps track of the FREE handles, not the handles in use. - * This data structure contains one stack per object class. When a handle is - * allocated to an object, the next free handle is popped from the stack. When - * a handle is released (on object delete), it is pushed back on the stack. - * Note that there is no initialization code that pushed the free handles - * initially, that is not necessary due to the following optimization: - * - * The stack of handles (objectHandles) is initially all zeros. Since zero - * is not a valid handle, that is a signal of additional handles needed. - * If a zero is received when popping a new handle, it is replaced by the - * index of the popped handle instead. - *****************************************************************************/ -typedef struct -{ - /* For each object class, the index of the next handle to allocate */ - uint16_t indexOfNextAvailableHandle[ TRACE_NCLASSES ]; - - /* The lowest index of this class (constant) */ - uint16_t lowestIndexOfClass[ TRACE_NCLASSES ]; - - /* The highest index of this class (constant) */ - uint16_t highestIndexOfClass[ TRACE_NCLASSES ]; - - /* The highest use count for this class (for statistics) */ - uint16_t handleCountWaterMarksOfClass[ TRACE_NCLASSES ]; - - /* The free object handles - a set of stacks within this array */ - traceHandle objectHandles[ TRACE_KERNEL_OBJECT_COUNT ]; - -} objectHandleStackType; - -extern objectHandleStackType objectHandleStacks; - -/****************************************************************************** - * Object Property Table - * The Object Table contains name and other properties of the objects (tasks, - * queues, mutexes, etc). The below data structures defines the properties of - * each object class and are used to cast the byte buffer into a cleaner format. - * - * The values in the object table are continuously overwritten and always - * represent the current state. If a property is changed during runtime, the OLD - * value should be stored in the trace buffer, not the new value (since the new - * value is found in the Object Property Table). - * - * For close events this mechanism is the old names are stored in the symbol - * table), for "priority set" (the old priority is stored in the event data) - * and for "isActive", where the value decides if the task switch event type - * should be "new" or "resume". - ******************************************************************************/ - -typedef struct -{ - /* = NCLASSES */ - uint32_t NumberOfObjectClasses; - - uint32_t ObjectPropertyTableSizeInBytes; - - /* This is used to calculate the index in the dynamic object table - (handle - 1 - nofStaticObjects = index)*/ -#if (TRC_CFG_USE_16BIT_OBJECT_HANDLES == 1) - traceHandle NumberOfObjectsPerClass[2*((TRACE_NCLASSES+1)/2)]; -#else - traceHandle NumberOfObjectsPerClass[4*((TRACE_NCLASSES+3)/4)]; -#endif - - /* Allocation size rounded up to the closest multiple of 4 */ - uint8_t NameLengthPerClass[ 4*((TRACE_NCLASSES+3)/4) ]; - - uint8_t TotalPropertyBytesPerClass[ 4*((TRACE_NCLASSES+3)/4) ]; - - /* Allocation size rounded up to the closest multiple of 2 */ - uint16_t StartIndexOfClass[ 2*((TRACE_NCLASSES+1)/2) ]; - - /* The actual handles issued, should be Initiated to all zeros */ - uint8_t objbytes[ 4*((TRACE_OBJECT_TABLE_SIZE+3)/4) ]; -} ObjectPropertyTableType; - -/* Symbol table data structure */ -typedef struct -{ - /* = SYMBOL_HISTORY_TABLE_SIZE_IN_BYTES */ - uint32_t symTableSize; - - /* Entry 0 is reserved. Any reference to entry 0 implies NULL*/ - uint32_t nextFreeSymbolIndex; - - /* Size rounded up to closest multiple of 4, to avoid alignment issues*/ - uint8_t symbytes[4*(((TRC_CFG_SYMBOL_TABLE_SIZE)+3)/4)]; - - /* Used for lookups - Up to 64 linked lists within the symbol table - connecting all entries with the same 6 bit checksum. - This field holds the current list heads. Should be initiated to zeros */ - uint16_t latestEntryOfChecksum[64]; -} symbolTableType; - - -/******************************************************************************* - * The data structures of the different events, all 4 bytes long - ******************************************************************************/ - -typedef struct -{ - uint8_t type; - uint8_t objHandle; - uint16_t dts; /* differential timestamp - time since last event */ -} TSEvent, TREvent; - -typedef struct -{ - uint8_t type; - uint8_t dummy; - uint16_t dts; /* differential timestamp - time since last event */ -} LPEvent; - -typedef struct -{ - uint8_t type; - uint8_t objHandle; - uint16_t dts; /* differential timestamp - time since last event */ -} KernelCall; - -typedef struct -{ - uint8_t type; - uint8_t objHandle; - uint8_t param; - uint8_t dts; /* differential timestamp - time since last event */ -} KernelCallWithParamAndHandle; - -typedef struct -{ - uint8_t type; - uint8_t dts; /* differential timestamp - time since last event */ - uint16_t param; -} KernelCallWithParam16; - -typedef struct -{ - uint8_t type; - uint8_t objHandle; /* the handle of the closed object */ - uint16_t symbolIndex; /* the name of the closed object */ -} ObjCloseNameEvent; - -typedef struct -{ - uint8_t type; - uint8_t arg1; - uint8_t arg2; - uint8_t arg3; -} ObjClosePropEvent; - -typedef struct -{ - uint8_t type; - uint8_t unused1; - uint8_t unused2; - uint8_t dts; -} TaskInstanceStatusEvent; - -typedef struct -{ - uint8_t type; - uint8_t dts; - uint16_t payload; /* the name of the user event */ -} UserEvent; - -typedef struct -{ - uint8_t type; - - /* 8 bits extra for storing DTS, if it does not fit in ordinary event - (this one is always MSB if used) */ - uint8_t xts_8; - - /* 16 bits extra for storing DTS, if it does not fit in ordinary event. */ - uint16_t xts_16; -} XTSEvent; - -typedef struct -{ - uint8_t type; - - uint8_t xps_8; - uint16_t xps_16; -} XPSEvent; - -typedef struct{ - uint8_t type; - uint8_t dts; - uint16_t size; -} MemEventSize; - -typedef struct{ - uint8_t type; - uint8_t addr_high; - uint16_t addr_low; -} MemEventAddr; - -/******************************************************************************* - * The separate user event buffer structure. Can be enabled in trcConfig.h. - ******************************************************************************/ - -#if (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1) -typedef struct -{ - traceString name; - traceString defaultFormat; -} ChannelFormatPair; - -typedef struct -{ - uint16_t bufferID; - uint16_t version; - uint32_t wraparoundCounter; - uint32_t numberOfSlots; - uint32_t nextSlotToWrite; - uint8_t numberOfChannels; - uint8_t padding1; - uint8_t padding2; - uint8_t padding3; - ChannelFormatPair channels[(TRC_CFG_UB_CHANNELS)+1]; - uint8_t channelBuffer[((TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE) + 3) & 0xFFFFFFFC]; /* 1 byte per slot, with padding for 4 byte alignment */ - uint8_t dataBuffer[(TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE) * 4]; /* 4 bytes per slot */ - -} UserEventBuffer; -#endif - -/******************************************************************************* - * The main data structure, read by Tracealyzer from the RAM dump - ******************************************************************************/ - -typedef struct -{ - volatile uint8_t startmarker0; /* Volatile is important, see init code. */ - volatile uint8_t startmarker1; - volatile uint8_t startmarker2; - volatile uint8_t startmarker3; - volatile uint8_t startmarker4; - volatile uint8_t startmarker5; - volatile uint8_t startmarker6; - volatile uint8_t startmarker7; - volatile uint8_t startmarker8; - volatile uint8_t startmarker9; - volatile uint8_t startmarker10; - volatile uint8_t startmarker11; - - /* Used to determine Kernel and Endianess */ - uint16_t version; - - /* Currently 5 */ - uint8_t minor_version; - - /* This should be 0 if lower IRQ priority values implies higher priority - levels, such as on ARM Cortex M. If the opposite scheme is used, i.e., - if higher IRQ priority values means higher priority, this should be 1. */ - uint8_t irq_priority_order; - - /* sizeof(RecorderDataType) - just for control */ - uint32_t filesize; - - /* Current number of events recorded */ - uint32_t numEvents; - - /* The buffer size, in number of event records */ - uint32_t maxEvents; - - /* The event buffer index, where to write the next event */ - uint32_t nextFreeIndex; - - /* 1 if the buffer is full, 0 otherwise */ - uint32_t bufferIsFull; - - /* The frequency of the clock/timer/counter used as time base */ - uint32_t frequency; - - /* The absolute timestamp of the last stored event, in the native - timebase, modulo frequency! */ - uint32_t absTimeLastEvent; - - /* The number of seconds in total - lasts for 136 years */ - uint32_t absTimeLastEventSecond; - - /* 1 if the recorder has been started, 0 if not yet started or stopped. - This is a 32 bit variable due to alignment issues. */ - uint32_t recorderActive; - - /* If > 0, tells the maximum time between two traced ISRs that execute - back-to-back. If the time between vTraceStoreISREnd and a directly - following vTraceISRBegin is above isrTailchainingThreshold, we assume a - return to the previous context in between the ISRs, otherwise we assume - the have executed back-to-back and don't show any fragment of the previous - context in between. */ - uint32_t isrTailchainingThreshold; - - /* Not used, remains for compatibility and future use */ - uint8_t notused[24]; - - /* The amount of heap memory remaining at the last malloc or free event */ - uint32_t heapMemUsage; - - /* 0xF0F0F0F0 - for control only */ - int32_t debugMarker0; - - /* Set to value of TRC_CFG_USE_16BIT_OBJECT_HANDLES */ - uint32_t isUsing16bitHandles; - - /* The Object Property Table holds information about currently active - tasks, queues, and other recorded objects. This is updated on each - create call and includes object name and other properties. */ - ObjectPropertyTableType ObjectPropertyTable; - - /* 0xF1F1F1F1 - for control only */ - int32_t debugMarker1; - - /* The Symbol Table stores strings for User Events and is also used to - store names of deleted objects, which still may be in the trace but no - longer are available. */ - symbolTableType SymbolTable; - - /* For inclusion of float support, and for endian detection of floats. - The value should be (float)1 or (uint32_t)0 */ -#if (TRC_CFG_INCLUDE_FLOAT_SUPPORT == 1) - float exampleFloatEncoding; -#else - uint32_t exampleFloatEncoding; -#endif - /* This is non-zero if an internal error occurred in the recorder, e.g., if - one of the Nxxx constants was too small. The systemInfo string will then - contain an error message that is displayed when attempting to view the - trace file. */ - uint32_t internalErrorOccured; - - /* 0xF2F2F2F2 - for control only */ - int32_t debugMarker2; - - /* Error messages from the recorder. */ - char systemInfo[80]; - - /* 0xF3F3F3F3 - for control only */ - int32_t debugMarker3; - - /* The event data, in 4-byte records */ - uint8_t eventData[ (TRC_CFG_EVENT_BUFFER_SIZE) * 4 ]; - -#if (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1) - UserEventBuffer userEventBuffer; -#endif - - /* This should always be 0 */ - uint32_t endOfSecondaryBlocks; - - uint8_t endmarker0; - uint8_t endmarker1; - uint8_t endmarker2; - uint8_t endmarker3; - uint8_t endmarker4; - uint8_t endmarker5; - uint8_t endmarker6; - uint8_t endmarker7; - uint8_t endmarker8; - uint8_t endmarker9; - uint8_t endmarker10; - uint8_t endmarker11; -} RecorderDataType; - -extern RecorderDataType* RecorderDataPtr; - -/* Internal functions */ - -/* Signal an error. */ -void prvTraceError(const char* msg); - -/******************************************************************************* - * prvTracePortGetTimeStamp - * - * Returns the current time based on the HWTC macros which provide a hardware - * isolation layer towards the hardware timer/counter. - * - * The HWTC macros and prvTracePortGetTimeStamp is the main porting issue - * or the trace recorder library. Typically you should not need to change - * the code of prvTracePortGetTimeStamp if using the HWTC macros. - * - ******************************************************************************/ -void prvTracePortGetTimeStamp(uint32_t *puiTimestamp); - -traceHandle prvTraceGetObjectHandle(traceObjectClass objectclass); - -void prvTraceFreeObjectHandle(traceObjectClass objectclass, - traceHandle handle); - -/* Private function. Use the public functions in trcKernelPort.h */ -void prvTraceSetObjectName(traceObjectClass objectclass, - traceHandle handle, - const char* name); - -/* Internal macros */ - -#define TRACE_PROPERTY_NAME_GET(objectclass, objecthandle) \ -(const char*)(& RecorderDataPtr->ObjectPropertyTable.objbytes \ -[uiIndexOfObject(objecthandle, objectclass)]) - -#define TRACE_PROPERTY_OBJECT_STATE(objectclass, handle) \ -RecorderDataPtr->ObjectPropertyTable.objbytes[uiIndexOfObject(handle, objectclass) \ -+ RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[objectclass]] - -#define TRACE_PROPERTY_ACTOR_PRIORITY(objectclass, handle) \ -RecorderDataPtr->ObjectPropertyTable.objbytes[uiIndexOfObject(handle, objectclass) \ -+ RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[objectclass] + 1] - -/* DEBUG ASSERTS */ -#if defined TRC_CFG_USE_TRACE_ASSERT && TRC_CFG_USE_TRACE_ASSERT != 0 -#define TRACE_ASSERT(eval, msg, defRetVal) \ -if (!(eval)) \ -{ \ - prvTraceError("TRACE_ASSERT: " msg); \ - return defRetVal; \ -} -#else -#define TRACE_ASSERT(eval, msg, defRetVal) -#endif - -#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)*/ - -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) - -/****************************************************************************** - * Default values for STREAM PORT macros - * - * As a normal user, this is nothing you don't need to bother about. This is - * only important if you want to define your own custom streaming interface. - * - * You may override these in your own trcStreamingPort.h to create a custom - * stream port, and thereby stream the trace on any host-target interface. - * These default values are suitable for most cases, except the J-Link port. - ******************************************************************************/ - -/****************************************************************************** - * TRC_STREAM_PORT_USE_INTERNAL_BUFFER - * - * There are two kinds of stream ports, those that store the event to the - * internal buffer (with periodic flushing by the TzCtrl task) and those that - * write directly to the streaming interface. Most stream ports use the - * recorder's internal buffer, except for the SEGGER J-Link port (also uses a - * RAM buffer, but one defined in the SEGGER code). - * - * If the stream port (trcStreamingPort.h) defines this as zero (0), it is - * expected to transmit the data directly using TRC_STREAM_PORT_COMMIT_EVENT. - * Otherwise it is expected that the trace data is stored in the internal buffer - * and the TzCtrl task will then send the buffer pages when they become full. - ******************************************************************************/ -#ifndef TRC_STREAM_PORT_USE_INTERNAL_BUFFER -#define TRC_STREAM_PORT_USE_INTERNAL_BUFFER 1 -#endif - - /****************************************************************************** - * TRC_STREAM_PORT_ON_TRACE_BEGIN - * - * Defining any actions needed in the stream port when the recording is activated. - *******************************************************************************/ -#ifndef TRC_STREAM_PORT_ON_TRACE_BEGIN - #define TRC_STREAM_PORT_ON_TRACE_BEGIN() /* Do nothing */ -#endif - - /****************************************************************************** - * TRC_STREAM_PORT_ON_TRACE_BEGIN - * - * Defining any actions needed in the stream port when the tracing stops. - * Empty by default. - *******************************************************************************/ -#ifndef TRC_STREAM_PORT_ON_TRACE_END -#define TRC_STREAM_PORT_ON_TRACE_END() /* Do nothing */ -#endif - - /****************************************************************************** - * TRC_STREAM_PORT_ALLOCATE_EVENT - * - * This macro is used to allocate memory for each event record, just before - * assigning the record fields. - * Depending on "TRC_STREAM_PORT_USE_INTERNAL_BUFFER", this either allocates - * space in the paged event buffer, or on the local stack. In the latter case, - * the COMMIT event is used to write the data to the streaming interface. - ******************************************************************************/ -#ifndef TRC_STREAM_PORT_ALLOCATE_EVENT -#if (TRC_STREAM_PORT_USE_INTERNAL_BUFFER == 1) - #define TRC_STREAM_PORT_ALLOCATE_EVENT(_type, _ptrData, _size) _type* _ptrData; _ptrData = (_type*)prvPagedEventBufferGetWritePointer(_size); -#else - #define TRC_STREAM_PORT_ALLOCATE_EVENT(_type, _ptrData, _size) _type _tmpArray[_size / sizeof(_type)]; _type* _ptrData = _tmpArray; -#endif -#endif - - /****************************************************************************** - * TRC_STREAM_PORT_ALLOCATE_DYNAMIC_EVENT - * - * This macro is used to allocate memory for each event record, just before - * assigning the record fields. - * This has the same purpose as TRC_STREAM_PORT_ALLOCATE_EVENT and by default - * it has the same definition as TRC_STREAM_PORT_ALLOCATE_EVENT. This is used - * for events carrying variable-sized payload, such as strings. - * In the SEGGER RTT port, we need this in order to make a worst-case - * allocation on the stack. - ******************************************************************************/ -#ifndef TRC_STREAM_PORT_ALLOCATE_DYNAMIC_EVENT -#if (TRC_STREAM_PORT_USE_INTERNAL_BUFFER == 1) - #define TRC_STREAM_PORT_ALLOCATE_DYNAMIC_EVENT(_type, _ptrData, _size) TRC_STREAM_PORT_ALLOCATE_EVENT(_type, _ptrData, _size) /* We do the same thing as for non-dynamic event sizes */ -#else - #define TRC_STREAM_PORT_ALLOCATE_DYNAMIC_EVENT(_type, _ptrData, _size) _type _tmpArray[sizeof(largestEventType) / sizeof(_type)]; _type* _ptrData = _tmpArray; -#endif -#endif - - /****************************************************************************** - * TRC_STREAM_PORT_COMMIT_EVENT - * - * The COMMIT macro is used to write a single event record directly to the - * streaming inteface, without first storing the event in the internal buffer. - * This is currently only used in the SEGGER J-Link RTT port. - * - * This relies on the TRC_STREAM_PORT_WRITE_DATA macro, defined in by the - * stream port in trcStreamingPort.h. The COMMIT macro calls - * prvTraceWarning(TRC_STREAM_PORT_WRITE_DATA) if a non-zero value is returned - * from TRC_STREAM_PORT_WRITE_DATA. If zero (0) is returned, it is assumed - * that all data was successfully written. - * - * In ports using the internal buffer, this macro has no purpose as the events - * are written to the internal buffer instead. They are then flushed to the - * streaming interface in the TzCtrl task using TRC_STREAM_PORT_WRITE_DATA. - ******************************************************************************/ -#ifndef TRC_STREAM_PORT_COMMIT_EVENT -#if (TRC_STREAM_PORT_USE_INTERNAL_BUFFER == 1) - #define TRC_STREAM_PORT_COMMIT_EVENT(_ptrData, _size) /* Not used */ -#else - #define TRC_STREAM_PORT_COMMIT_EVENT(_ptrData, _size) \ - { \ - if (TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, 0) != 0)\ - prvTraceWarning(PSF_WARNING_STREAM_PORT_WRITE); \ - } -#endif -#endif - -/****************************************************************************** - * TRC_STREAM_PORT_READ_DATA (defined in trcStreamingPort.h) - * - * Defining how to read data from host (commands from Tracealyzer). - * - * If there is no direct interface to host (e.g., if streaming to a file - * system) this should be defined as 0. Instead use vTraceEnable(TRC_START) and - * vTraceStop() to control the recording from target. - * - * Parameters: - * - * - _ptrData: a pointer to a data buffer, where the received data shall be - * stored (TracealyzerCommandType*). - * - * - _size: the number of bytes to read (int). - * - * - _ptrBytesRead: a pointer to an integer (int), that should be assigned - * with the number of bytes that was received. - * - * Example: - * - * int32_t myRead(void* ptrData, uint32_t size, int32_t* ptrBytesRead); - * - * #define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) \ - * myRead(_ptrData, _size, _ptrBytesRead) - * - * Your "myRead" function should return 0 if successful, i.e. if at least some - * bytes were received. A non-zero value should be returned if the streaming - * interface returned an error (e.g. a closed socket), which results in the - * recorder calling prvTraceWarning with the error code - * PSF_WARNING_STREAM_PORT_WRITE. - * - * If developing your own custom stream port and using the default internal - * buffer, it is important that the _ptrBytesRead parameter is assigned - * correctly by "myRead", i.e. with the number of bytes actually written. - * Otherwise the data stream may get out of sync in case the streaming interface - * can't swallow all data at once. - ******************************************************************************/ -#ifndef TRC_STREAM_PORT_READ_DATA -#error "No definition for TRC_STREAM_PORT_READ_DATA (should be in trcStreamingPort.h)" -#endif - -/****************************************************************************** - * TRC_STREAM_PORT_WRITE_DATA (defined in trcStreamingPort.h) - * - * Defining how to write trace data to the streaming interface. - * - * Parameters: - * - * - _ptrData: a pointer (void*) to the data to write. - * - * - _size: the number of bytes to write (uint32_t). - * - * - _ptrBytesWritten: a pointer to an integer (int32_t), that should be - * assigned with the number of bytes actually written. - * - * Example: - * - * int32_t myWrite(void* ptrData, uint32_t size, int32_t* ptrBytesWritten); - * - * #define TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, _ptrBytesWritten) \ - * myWrite(_ptrData, _size, _ptrBytesWritten) - * - * Your "myWrite" function should return 0 if successful, i.e. if at least some - * bytes were sent. A non-zero value should be returned if the streaming interface - * returned an error (e.g. a closed socket), which results in the recorder calling - * prvTraceWarning with the error code PSF_WARNING_STREAM_PORT_WRITE. - * - * If developing your own custom stream port and using the default internal - * buffer, it is important that the _ptrBytesWritten parameter is assigned - * correctly by "myWrite", i.e. with the number of bytes actually written. - * Otherwise the data stream may get out of sync in case the streaming interface - * can't swallow all data at once. - * - * Assuming TRC_STREAM_PORT_USE_INTERNAL_BUFFER is 1 (default), the TzCtrl task - * will use this macro to send one buffer page at a time. In case all data can't - * be written at once (if _ptrBytesWritten is less than _size), the TzCtrl task - * is smart enough to make repeated calls (with updated parameters) in order to - * send the remaining data. - * - * However, if TRC_STREAM_PORT_USE_INTERNAL_BUFFER is 0, this is used from the - * COMMIT macro, directly in the "event functions". In that case, the - * _ptrBytesWritten parameter will be NULL and should be ignored by the write - * function. In this case, it is assumed that all data can be sent in a single - * call, otherwise the write function should return a non-zero error code. - ******************************************************************************/ -#ifndef TRC_STREAM_PORT_WRITE_DATA -#error "No definition for TRC_STREAM_PORT_WRITE_DATA (should be in trcStreamingPort.h)" -#endif - -/****************************************************************************** -* Data structure declaration, depending on TRC_CFG_RECORDER_BUFFER_ALLOCATION -*******************************************************************************/ -#if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_STATIC) - - /* Static allocation. */ - - /* If not defined in trcStreamingPort.h */ - #ifndef TRC_STREAM_PORT_ALLOCATE_FIELDS - #define TRC_STREAM_PORT_ALLOCATE_FIELDS() \ - char _TzTraceData[(TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT) * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE)]; - extern char _TzTraceData[(TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT) * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE)]; - #endif - - /* If not defined in trcStreamingPort.h */ - #ifndef TRC_STREAM_PORT_MALLOC - #define TRC_STREAM_PORT_MALLOC() /* Static allocation. Not used. */ - #endif -#else - /* For Dynamic or Custom Allocation mode */ - - /* If not defined in trcStreamingPort.h */ - #ifndef TRC_STREAM_PORT_ALLOCATE_FIELDS - #define TRC_STREAM_PORT_ALLOCATE_FIELDS() char* _TzTraceData = NULL; - extern char* _TzTraceData; - #endif - - /* If not defined in trcStreamingPort.h */ - #ifndef TRC_STREAM_PORT_MALLOC - #if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC) - #define TRC_STREAM_PORT_MALLOC() \ - _TzTraceData = TRC_PORT_MALLOC((TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT) * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE)); - extern char* _TzTraceData; - #else - #define TRC_STREAM_PORT_MALLOC() /* Custom allocation. Not used. */ - #endif - #endif -#endif - -#ifndef TRC_STREAM_PORT_INIT - #define TRC_STREAM_PORT_INIT() \ - TRC_STREAM_PORT_MALLOC(); /* Empty if static allocation mode */ \ - prvPagedEventBufferInit(_TzTraceData); -#endif - - -/* Signal an error. */ -void prvTraceError(int errCode); - -/* Signal an warning (does not stop the recorder). */ -void prvTraceWarning(int errCode); - -/******************************************************************************/ -/*** ERROR AND WARNING CODES (check using xTraceGetLastError) *****************/ -/******************************************************************************/ - -#define PSF_ERROR_NONE 0 -#define PSF_ERROR_EVENT_CODE_TOO_LARGE 1 -#define PSF_ERROR_ISR_NESTING_OVERFLOW 2 -#define PSF_ERROR_DWT_NOT_SUPPORTED 3 -#define PSF_ERROR_DWT_CYCCNT_NOT_SUPPORTED 4 -#define PSF_ERROR_TZCTRLTASK_NOT_CREATED 5 - -#define PSF_WARNING_SYMBOL_TABLE_SLOTS 101 -#define PSF_WARNING_SYMBOL_MAX_LENGTH 102 -#define PSF_WARNING_OBJECT_DATA_SLOTS 103 -#define PSF_WARNING_STRING_TOO_LONG 104 -#define PSF_WARNING_STREAM_PORT_READ 105 -#define PSF_WARNING_STREAM_PORT_WRITE 106 - -/******************************************************************************/ -/*** INTERNAL STREAMING FUNCTIONS *********************************************/ -/******************************************************************************/ - -/* Saves a symbol name (task name etc.) in symbol table */ -void prvTraceSaveSymbol(const void *address, const char *name); - -/* Deletes a symbol name (task name etc.) from symbol table */ -void prvTraceDeleteSymbol(void *address); - -/* Saves an object data entry (task base priority) in object data table */ -void prvTraceSaveObjectData(const void *address, uint32_t data); - -/* Removes an object data entry (task base priority) from object data table */ -void prvTraceDeleteObjectData(void *address); - -/* Store an event with zero parameters (event ID only) */ -void prvTraceStoreEvent0(uint16_t eventID); - -/* Store an event with one 32-bit parameter (pointer address or an int) */ -void prvTraceStoreEvent1(uint16_t eventID, - uint32_t param1); - -/* Store an event with two 32-bit parameters */ -void prvTraceStoreEvent2(uint16_t eventID, - uint32_t param1, - uint32_t param2); - -/* Store an event with three 32-bit parameters */ -void prvTraceStoreEvent3(uint16_t eventID, - uint32_t param1, - uint32_t param2, - uint32_t param3); - -/* Stores an event with 32-bit integer parameters */ -void prvTraceStoreEvent(int nParam, uint16_t EventID, ...); - -/* Stories an event with a string and 32-bit integer parameters */ -void prvTraceStoreStringEvent(int nArgs, uint16_t eventID, const char* str, ...); - -/* Initializes the paged event buffer used by certain stream ports */ -void prvPagedEventBufferInit(char* buffer); - -/* Retrieve a pointer to the paged event buffer */ -void* prvPagedEventBufferGetWritePointer(int sizeOfEvent); - -/* Transfer a full buffer page */ -uint32_t prvPagedEventBufferTransfer(void); - -/* The data structure for commands (a bit overkill) */ -typedef struct -{ - unsigned char cmdCode; - unsigned char param1; - unsigned char param2; - unsigned char param3; - unsigned char param4; - unsigned char param5; - unsigned char checksumLSB; - unsigned char checksumMSB; -} TracealyzerCommandType; - -/* Checks if the provided command is a valid command */ -int prvIsValidCommand(TracealyzerCommandType* cmd); - -/* Executed the received command (Start or Stop) */ -void prvProcessCommand(TracealyzerCommandType* cmd); - -#define vTraceSetStopHook(x) - -#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/ - -#else /* when TRC_USE_TRACEALYZER_RECORDER == 0 */ - -#define vTraceEnable(x) -#define xTraceRegisterString(x) 0; (void)x; -#define vTracePrint(chn, ...) (void)chn -#define vTracePrintF(chn, ...) (void)chn -#define vTraceInstanceFinishedNow() -#define vTraceInstanceFinishedNext() -#define vTraceStoreISRBegin(x) (void)x -#define vTraceStoreISREnd(x) (void)x -#define xTraceSetISRProperties(a, b) 0 -#define vTraceStoreKernelObjectName(a, b) -#define xTraceRegisterChannelFormat(eventLabel, formatStr) 0 -#define vTraceChannelPrint(label) -#define vTraceUBData(label, ...) - -#define vTraceSetFilterGroup(x) -#define vTraceSetFilterMask(x) - -#define prvTraceSetReadyEventsEnabled(status) - -#define vTraceExcludeTask(handle) - -#define uiTraceStart() (1) -#define vTraceStart() -#define vTraceStop() - -#ifndef vTraceSetRecorderDataBuffer -#define vTraceSetRecorderDataBuffer(pRecorderData) -#endif - -#define vTraceConsoleChannelPrintF(fmt, ...) - -#ifndef TRC_ALLOC_CUSTOM_BUFFER -#define TRC_ALLOC_CUSTOM_BUFFER(bufname) -#endif - -#define xTraceIsRecordingEnabled() (0) - -#define vTraceSetStopHook(x) - -#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/ - -#ifdef __cplusplus -} -#endif - -#endif /* TRC_RECORDER_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ReadMe.url b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ReadMe.url deleted file mode 100755 index d12e889..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ReadMe.url +++ /dev/null @@ -1,5 +0,0 @@ -[InternetShortcut] -URL=http://www.freertos.org/trace -IDList= -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcConfig.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcConfig.h deleted file mode 100755 index 3f89326..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcConfig.h +++ /dev/null @@ -1,301 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.4 - * Percepio AB, www.percepio.com - * - * trcConfig.h - * - * Main configuration parameters for the trace recorder library. - * More settings can be found in trcStreamingConfig.h and trcSnapshotConfig.h. - * - * Read more at http://percepio.com/2016/10/05/rtos-tracing/ - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_CONFIG_H -#define TRC_CONFIG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "trcPortDefines.h" - -/****************************************************************************** - * Include of processor header file - * - * Here you may need to include the header file for your processor. This is - * required at least for the ARM Cortex-M port, that uses the ARM CMSIS API. - * Try that in case of build problems. Otherwise, remove the #error line below. - *****************************************************************************/ -#error "Trace Recorder: Please include your processor's header file here and remove this line." - -/******************************************************************************* - * Configuration Macro: TRC_CFG_HARDWARE_PORT - * - * Specify what hardware port to use (i.e., the "timestamping driver"). - * - * All ARM Cortex-M MCUs are supported by "TRC_HARDWARE_PORT_ARM_Cortex_M". - * This port uses the DWT cycle counter for Cortex-M3/M4/M7 devices, which is - * available on most such devices. In case your device don't have DWT support, - * you will get an error message opening the trace. In that case, you may - * force the recorder to use SysTick timestamping instead, using this define: - * - * #define TRC_CFG_ARM_CM_USE_SYSTICK - * - * For ARM Cortex-M0/M0+ devices, SysTick mode is used automatically. - * - * See trcHardwarePort.h for available ports and information on how to - * define your own port, if not already present. - ******************************************************************************/ -#define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_NOT_SET - -/******************************************************************************* - * Configuration Macro: TRC_CFG_RECORDER_MODE - * - * Specify what recording mode to use. Snapshot means that the data is saved in - * an internal RAM buffer, for later upload. Streaming means that the data is - * transferred continuously to the host PC. - * - * For more information, see http://percepio.com/2016/10/05/rtos-tracing/ - * and the Tracealyzer User Manual. - * - * Values: - * TRC_RECORDER_MODE_SNAPSHOT - * TRC_RECORDER_MODE_STREAMING - ******************************************************************************/ -#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_SNAPSHOT - -/****************************************************************************** - * TRC_CFG_FREERTOS_VERSION - * - * Specify what version of FreeRTOS that is used (don't change unless using the - * trace recorder library with an older version of FreeRTOS). - * - * TRC_FREERTOS_VERSION_7_3 If using FreeRTOS v7.3.x - * TRC_FREERTOS_VERSION_7_4 If using FreeRTOS v7.4.x - * TRC_FREERTOS_VERSION_7_5_OR_7_6 If using FreeRTOS v7.5.0 - v7.6.0 - * TRC_FREERTOS_VERSION_8_X If using FreeRTOS v8.X.X - * TRC_FREERTOS_VERSION_9_0_0 If using FreeRTOS v9.0.0 - * TRC_FREERTOS_VERSION_9_0_1 If using FreeRTOS v9.0.1 - * TRC_FREERTOS_VERSION_9_0_2 If using FreeRTOS v9.0.2 - * TRC_FREERTOS_VERSION_10_0_0 If using FreeRTOS v10.0.0 or later - *****************************************************************************/ -#define TRC_CFG_FREERTOS_VERSION TRC_FREERTOS_VERSION_10_0_0 - -/******************************************************************************* - * TRC_CFG_SCHEDULING_ONLY - * - * Macro which should be defined as an integer value. - * - * If this setting is enabled (= 1), only scheduling events are recorded. - * If disabled (= 0), all events are recorded (unless filtered in other ways). - * - * Default value is 0 (= include additional events). - ******************************************************************************/ -#define TRC_CFG_SCHEDULING_ONLY 0 - - /****************************************************************************** - * TRC_CFG_INCLUDE_MEMMANG_EVENTS - * - * Macro which should be defined as either zero (0) or one (1). - * - * This controls if malloc and free calls should be traced. Set this to zero (0) - * to exclude malloc/free calls, or one (1) to include such events in the trace. - * - * Default value is 1. - *****************************************************************************/ -#define TRC_CFG_INCLUDE_MEMMANG_EVENTS 1 - - /****************************************************************************** - * TRC_CFG_INCLUDE_USER_EVENTS - * - * Macro which should be defined as either zero (0) or one (1). - * - * If this is zero (0), all code related to User Events is excluded in order - * to reduce code size. Any attempts of storing User Events are then silently - * ignored. - * - * User Events are application-generated events, like "printf" but for the - * trace log, generated using vTracePrint and vTracePrintF. - * The formatting is done on host-side, by Tracealyzer. User Events are - * therefore much faster than a console printf and can often be used - * in timing critical code without problems. - * - * Note: In streaming mode, User Events are used to provide error messages - * and warnings from the recorder (in case of incorrect configuration) for - * display in Tracealyzer. Disabling user events will also disable these - * warnings. You can however still catch them by calling xTraceGetLastError - * or by putting breakpoints in prvTraceError and prvTraceWarning. - * - * Default value is 1. - *****************************************************************************/ -#define TRC_CFG_INCLUDE_USER_EVENTS 1 - - /***************************************************************************** - * TRC_CFG_INCLUDE_ISR_TRACING - * - * Macro which should be defined as either zero (0) or one (1). - * - * If this is zero (0), the code for recording Interrupt Service Routines is - * excluded, in order to reduce code size. - * - * Default value is 1. - * - * Note: tracing ISRs requires that you insert calls to vTraceStoreISRBegin - * and vTraceStoreISREnd in your interrupt handlers. - *****************************************************************************/ -#define TRC_CFG_INCLUDE_ISR_TRACING 1 - - /***************************************************************************** - * TRC_CFG_INCLUDE_READY_EVENTS - * - * Macro which should be defined as either zero (0) or one (1). - * - * If one (1), events are recorded when tasks enter scheduling state "ready". - * This allows Tracealyzer to show the initial pending time before tasks enter - * the execution state, and present accurate response times. - * If zero (0), "ready events" are not created, which allows for recording - * longer traces in the same amount of RAM. - * - * Default value is 1. - *****************************************************************************/ -#define TRC_CFG_INCLUDE_READY_EVENTS 1 - - /***************************************************************************** - * TRC_CFG_INCLUDE_OSTICK_EVENTS - * - * Macro which should be defined as either zero (0) or one (1). - * - * If this is one (1), events will be generated whenever the OS clock is - * increased. If zero (0), OS tick events are not generated, which allows for - * recording longer traces in the same amount of RAM. - * - * Default value is 1. - *****************************************************************************/ -#define TRC_CFG_INCLUDE_OSTICK_EVENTS 1 - - /***************************************************************************** - * TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS - * - * Macro which should be defined as either zero (0) or one (1). - * - * If this is zero (0), the trace will exclude any "event group" events. - * - * Default value is 0 (excluded) since dependent on event_groups.c - *****************************************************************************/ -#define TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS 0 - - /***************************************************************************** - * TRC_CFG_INCLUDE_TIMER_EVENTS - * - * Macro which should be defined as either zero (0) or one (1). - * - * If this is zero (0), the trace will exclude any Timer events. - * - * Default value is 0 since dependent on timers.c - *****************************************************************************/ -#define TRC_CFG_INCLUDE_TIMER_EVENTS 0 - - /***************************************************************************** - * TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS - * - * Macro which should be defined as either zero (0) or one (1). - * - * If this is zero (0), the trace will exclude any "pending function call" - * events, such as xTimerPendFunctionCall(). - * - * Default value is 0 since dependent on timers.c - *****************************************************************************/ -#define TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS 0 - -/******************************************************************************* - * Configuration Macro: TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS - * - * Macro which should be defined as either zero (0) or one (1). - * - * If this is zero (0), the trace will exclude any stream buffer or message - * buffer events. - * - * Default value is 0 since dependent on stream_buffer.c (new in FreeRTOS v10) - ******************************************************************************/ -#define TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS 0 - -/******************************************************************************* - * Configuration Macro: TRC_CFG_RECORDER_BUFFER_ALLOCATION - * - * Specifies how the recorder buffer is allocated (also in case of streaming, in - * port using the recorder's internal temporary buffer) - * - * Values: - * TRC_RECORDER_BUFFER_ALLOCATION_STATIC - Static allocation (internal) - * TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC - Malloc in vTraceEnable - * TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM - Use vTraceSetRecorderDataBuffer - * - * Static and dynamic mode does the allocation for you, either in compile time - * (static) or in runtime (malloc). - * The custom mode allows you to control how and where the allocation is made, - * for details see TRC_ALLOC_CUSTOM_BUFFER and vTraceSetRecorderDataBuffer(). - ******************************************************************************/ -#define TRC_CFG_RECORDER_BUFFER_ALLOCATION TRC_RECORDER_BUFFER_ALLOCATION_STATIC - -/****************************************************************************** - * TRC_CFG_MAX_ISR_NESTING - * - * Defines how many levels of interrupt nesting the recorder can handle, in - * case multiple ISRs are traced and ISR nesting is possible. If this - * is exceeded, the particular ISR will not be traced and the recorder then - * logs an error message. This setting is used to allocate an internal stack - * for keeping track of the previous execution context (4 byte per entry). - * - * This value must be a non-zero positive constant, at least 1. - * - * Default value: 8 - *****************************************************************************/ -#define TRC_CFG_MAX_ISR_NESTING 8 - -/* Specific configuration, depending on Streaming/Snapshot mode */ -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) -#include "trcSnapshotConfig.h" -#elif (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) -#include "trcStreamingConfig.h" -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _TRC_CONFIG_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcSnapshotConfig.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcSnapshotConfig.h deleted file mode 100755 index ba9078c..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcSnapshotConfig.h +++ /dev/null @@ -1,377 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.4 - * Percepio AB, www.percepio.com - * - * trcSnapshotConfig.h - * - * Configuration parameters for trace recorder library in snapshot mode. - * Read more at http://percepio.com/2016/10/05/rtos-tracing/ - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_SNAPSHOT_CONFIG_H -#define TRC_SNAPSHOT_CONFIG_H - -#define TRC_SNAPSHOT_MODE_RING_BUFFER (0x01) -#define TRC_SNAPSHOT_MODE_STOP_WHEN_FULL (0x02) - -/****************************************************************************** - * TRC_CFG_SNAPSHOT_MODE - * - * Macro which should be defined as one of: - * - TRC_SNAPSHOT_MODE_RING_BUFFER - * - TRC_SNAPSHOT_MODE_STOP_WHEN_FULL - * Default is TRC_SNAPSHOT_MODE_RING_BUFFER. - * - * With TRC_CFG_SNAPSHOT_MODE set to TRC_SNAPSHOT_MODE_RING_BUFFER, the - * events are stored in a ring buffer, i.e., where the oldest events are - * overwritten when the buffer becomes full. This allows you to get the last - * events leading up to an interesting state, e.g., an error, without having - * to store the whole run since startup. - * - * When TRC_CFG_SNAPSHOT_MODE is TRC_SNAPSHOT_MODE_STOP_WHEN_FULL, the - * recording is stopped when the buffer becomes full. This is useful for - * recording events following a specific state, e.g., the startup sequence. - *****************************************************************************/ -#define TRC_CFG_SNAPSHOT_MODE TRC_SNAPSHOT_MODE_RING_BUFFER - -/******************************************************************************* - * TRC_CFG_EVENT_BUFFER_SIZE - * - * Macro which should be defined as an integer value. - * - * This defines the capacity of the event buffer, i.e., the number of records - * it may store. Most events use one record (4 byte), although some events - * require multiple 4-byte records. You should adjust this to the amount of RAM - * available in the target system. - * - * Default value is 1000, which means that 4000 bytes is allocated for the - * event buffer. - ******************************************************************************/ -#define TRC_CFG_EVENT_BUFFER_SIZE 1000 - -/******************************************************************************* - * TRC_CFG_NTASK, TRC_CFG_NISR, TRC_CFG_NQUEUE, TRC_CFG_NSEMAPHORE... - * - * A group of macros which should be defined as integer values, zero or larger. - * - * These define the capacity of the Object Property Table, i.e., the maximum - * number of objects active at any given point, within each object class (e.g., - * task, queue, semaphore, ...). - * - * If tasks or other objects are deleted in your system, this - * setting does not limit the total amount of objects created, only the number - * of objects that have been successfully created but not yet deleted. - * - * Using too small values will cause vTraceError to be called, which stores an - * error message in the trace that is shown when opening the trace file. The - * error message can also be retrieved using xTraceGetLastError. - * - * It can be wise to start with large values for these constants, - * unless you are very confident on these numbers. Then do a recording and - * check the actual usage by selecting View menu -> Trace Details -> - * Resource Usage -> Object Table. - ******************************************************************************/ -#define TRC_CFG_NTASK 15 -#define TRC_CFG_NISR 5 -#define TRC_CFG_NQUEUE 10 -#define TRC_CFG_NSEMAPHORE 10 -#define TRC_CFG_NMUTEX 10 -#define TRC_CFG_NTIMER 5 -#define TRC_CFG_NEVENTGROUP 5 -#define TRC_CFG_NSTREAMBUFFER 5 -#define TRC_CFG_NMESSAGEBUFFER 5 - -/****************************************************************************** - * TRC_CFG_INCLUDE_FLOAT_SUPPORT - * - * Macro which should be defined as either zero (0) or one (1). - * - * If this is zero (0), the support for logging floating point values in - * vTracePrintF is stripped out, in case floating point values are not used or - * supported by the platform used. - * - * Floating point values are only used in vTracePrintF and its subroutines, to - * allow for storing float (%f) or double (%lf) arguments. - * - * vTracePrintF can be used with integer and string arguments in either case. - * - * Default value is 0. - *****************************************************************************/ -#define TRC_CFG_INCLUDE_FLOAT_SUPPORT 0 - -/******************************************************************************* - * TRC_CFG_SYMBOL_TABLE_SIZE - * - * Macro which should be defined as an integer value. - * - * This defines the capacity of the symbol table, in bytes. This symbol table - * stores User Events labels and names of deleted tasks, queues, or other kernel - * objects. If you don't use User Events or delete any kernel - * objects you set this to a very low value. The minimum recommended value is 4. - * A size of zero (0) is not allowed since a zero-sized array may result in a - * 32-bit pointer, i.e., using 4 bytes rather than 0. - * - * Default value is 800. - ******************************************************************************/ -#define TRC_CFG_SYMBOL_TABLE_SIZE 800 - -#if (TRC_CFG_SYMBOL_TABLE_SIZE == 0) -#error "TRC_CFG_SYMBOL_TABLE_SIZE may not be zero!" -#endif - -/****************************************************************************** - * TRC_CFG_NAME_LEN_TASK, TRC_CFG_NAME_LEN_QUEUE, ... - * - * Macros that specify the maximum lengths (number of characters) for names of - * kernel objects, such as tasks and queues. If longer names are used, they will - * be truncated when stored in the recorder. - *****************************************************************************/ -#define TRC_CFG_NAME_LEN_TASK 15 -#define TRC_CFG_NAME_LEN_ISR 15 -#define TRC_CFG_NAME_LEN_QUEUE 15 -#define TRC_CFG_NAME_LEN_SEMAPHORE 15 -#define TRC_CFG_NAME_LEN_MUTEX 15 -#define TRC_CFG_NAME_LEN_TIMER 15 -#define TRC_CFG_NAME_LEN_EVENTGROUP 15 -#define TRC_CFG_NAME_LEN_STREAMBUFFER 15 -#define TRC_CFG_NAME_LEN_MESSAGEBUFFER 15 - -/****************************************************************************** - *** ADVANCED SETTINGS ******************************************************** - ****************************************************************************** - * The remaining settings are not necessary to modify but allows for optimizing - * the recorder setup for your specific needs, e.g., to exclude events that you - * are not interested in, in order to get longer traces. - *****************************************************************************/ - -/****************************************************************************** -* TRC_CFG_HEAP_SIZE_BELOW_16M -* -* An integer constant that can be used to reduce the buffer usage of memory -* allocation events (malloc/free). This value should be 1 if the heap size is -* below 16 MB (2^24 byte), and you can live with reported addresses showing the -* lower 24 bits only. If 0, you get the full 32-bit addresses. -* -* Default value is 0. -******************************************************************************/ -#define TRC_CFG_HEAP_SIZE_BELOW_16M 0 - -/****************************************************************************** - * TRC_CFG_USE_IMPLICIT_IFE_RULES - * - * Macro which should be defined as either zero (0) or one (1). - * Default is 1. - * - * Tracealyzer groups the events into "instances" based on Instance Finish - * Events (IFEs), produced either by default rules or calls to the recorder - * functions vTraceInstanceFinishedNow and vTraceInstanceFinishedNext. - * - * If TRC_CFG_USE_IMPLICIT_IFE_RULES is one (1), the default IFE rules is - * used, resulting in a "typical" grouping of events into instances. - * If these rules don't give appropriate instances in your case, you can - * override the default rules using vTraceInstanceFinishedNow/Next for one - * or several tasks. The default IFE rules are then disabled for those tasks. - * - * If TRC_CFG_USE_IMPLICIT_IFE_RULES is zero (0), the implicit IFE rules are - * disabled globally. You must then call vTraceInstanceFinishedNow or - * vTraceInstanceFinishedNext to manually group the events into instances, - * otherwise the tasks will appear a single long instance. - * - * The default IFE rules count the following events as "instance finished": - * - Task delay, delay until - * - Task suspend - * - Blocking on "input" operations, i.e., when the task is waiting for the - * next a message/signal/event. But only if this event is blocking. - * - * For details, see trcSnapshotKernelPort.h and look for references to the - * macro trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED. - *****************************************************************************/ -#define TRC_CFG_USE_IMPLICIT_IFE_RULES 1 - -/****************************************************************************** - * TRC_CFG_USE_16BIT_OBJECT_HANDLES - * - * Macro which should be defined as either zero (0) or one (1). - * - * If set to 0 (zero), the recorder uses 8-bit handles to identify kernel - * objects such as tasks and queues. This limits the supported number of - * concurrently active objects to 255 of each type (tasks, queues, mutexes, - * etc.) Note: 255, not 256, since handle 0 is reserved. - * - * If set to 1 (one), the recorder uses 16-bit handles to identify kernel - * objects such as tasks and queues. This limits the supported number of - * concurrent objects to 65535 of each type (object class). However, since the - * object property table is limited to 64 KB, the practical limit is about - * 3000 objects in total. - * - * Default is 0 (8-bit handles) - * - * NOTE: An object with handle above 255 will use an extra 4-byte record in - * the event buffer whenever the object is referenced. Moreover, some internal - * tables in the recorder gets slightly larger when using 16-bit handles. - *****************************************************************************/ -#define TRC_CFG_USE_16BIT_OBJECT_HANDLES 0 - -/****************************************************************************** - * TRC_CFG_USE_TRACE_ASSERT - * - * Macro which should be defined as either zero (0) or one (1). - * Default is 1. - * - * If this is one (1), the TRACE_ASSERT macro (used at various locations in the - * trace recorder) will verify that a relevant condition is true. - * If the condition is false, prvTraceError() will be called, which stops the - * recording and stores an error message that is displayed when opening the - * trace in Tracealyzer. - * - * This is used on several places in the recorder code for sanity checks on - * parameters. Can be switched off to reduce the footprint of the tracing, but - * we recommend to have it enabled initially. - *****************************************************************************/ -#define TRC_CFG_USE_TRACE_ASSERT 1 - -/******************************************************************************* - * TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER - * - * Macro which should be defined as an integer value. - * - * Set TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER to 1 to enable the - * separate user event buffer (UB). - * In this mode, user events are stored separately from other events, - * e.g., RTOS events. Thereby you can get a much longer history of - * user events as they don't need to share the buffer space with more - * frequent events. - * - * The UB is typically used with the snapshot ring-buffer mode, so the - * recording can continue when the main buffer gets full. And since the - * main buffer then overwrites the earliest events, Tracealyzer displays - * "Unknown Actor" instead of task scheduling for periods with UB data only. - * - * In UB mode, user events are structured as UB channels, which contains - * a channel name and a default format string. Register a UB channel using - * xTraceRegisterUBChannel. - * - * Events and data arguments are written using vTraceUBEvent and - * vTraceUBData. They are designed to provide efficient logging of - * repeating events, using the same format string within each channel. - * - * Examples: - * - * traceString chn1 = xTraceRegisterString("Channel 1"); - * traceString fmt1 = xTraceRegisterString("Event!"); - * traceUBChannel UBCh1 = xTraceRegisterUBChannel(chn1, fmt1); - * - * traceString chn2 = xTraceRegisterString("Channel 2"); - * traceString fmt2 = xTraceRegisterString("X: %d, Y: %d"); - * traceUBChannel UBCh2 = xTraceRegisterUBChannel(chn2, fmt2); - * - * // Result in "[Channel 1] Event!" - * vTraceUBEvent(UBCh1); - * - * // Result in "[Channel 2] X: 23, Y: 19" - * vTraceUBData(UBCh2, 23, 19); - * - * You can also use the other user event functions, like vTracePrintF. - * as they are then rerouted to the UB instead of the main event buffer. - * vTracePrintF then looks up the correct UB channel based on the - * provided channel name and format string, or creates a new UB channel - * if no match is found. The format string should therefore not contain - * "random" messages but mainly format specifiers. Random strings should - * be stored using %s and with the string as an argument. - * - * // Creates a new UB channel ("Channel 2", "%Z: %d") - * vTracePrintF(chn2, "%Z: %d", value1); - * - * // Finds the existing UB channel - * vTracePrintF(chn2, "%Z: %d", value2); - - ******************************************************************************/ -#define TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER 0 - -/******************************************************************************* - * TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE - * - * Macro which should be defined as an integer value. - * - * This defines the capacity of the user event buffer (UB), in number of slots. - * A single user event can use multiple slots, depending on the arguments. - * - * Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1. - ******************************************************************************/ -#define TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE 200 - -/******************************************************************************* - * TRC_CFG_UB_CHANNELS - * - * Macro which should be defined as an integer value. - * - * This defines the number of User Event Buffer Channels (UB channels). - * These are used to structure the events when using the separate user - * event buffer, and contains both a User Event Channel (the name) and - * a default format string for the channel. - * - * Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1. - ******************************************************************************/ -#define TRC_CFG_UB_CHANNELS 32 - -/******************************************************************************* - * TRC_CFG_ISR_TAILCHAINING_THRESHOLD - * - * Macro which should be defined as an integer value. - * - * If tracing multiple ISRs, this setting allows for accurate display of the - * context-switching also in cases when the ISRs execute in direct sequence. - * - * vTraceStoreISREnd normally assumes that the ISR returns to the previous - * context, i.e., a task or a preempted ISR. But if another traced ISR - * executes in direct sequence, Tracealyzer may incorrectly display a minimal - * fragment of the previous context in between the ISRs. - * - * By using TRC_CFG_ISR_TAILCHAINING_THRESHOLD you can avoid this. This is - * however a threshold value that must be measured for your specific setup. - * See http://percepio.com/2014/03/21/isr_tailchaining_threshold/ - * - * The default setting is 0, meaning "disabled" and that you may get an - * extra fragments of the previous context in between tail-chained ISRs. - * - * Note: This setting has separate definitions in trcSnapshotConfig.h and - * trcStreamingConfig.h, since it is affected by the recorder mode. - ******************************************************************************/ -#define TRC_CFG_ISR_TAILCHAINING_THRESHOLD 0 - -#endif /*TRC_SNAPSHOT_CONFIG_H*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcStreamingConfig.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcStreamingConfig.h deleted file mode 100755 index d3d088a..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcStreamingConfig.h +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.4 - * Percepio AB, www.percepio.com - * - * trcStreamingConfig.h - * - * Configuration parameters for the trace recorder library in streaming mode. - * Read more at http://percepio.com/2016/10/05/rtos-tracing/ - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_STREAMING_CONFIG_H -#define TRC_STREAMING_CONFIG_H - -#ifdef __cplusplus -extern "C" { -#endif - -/******************************************************************************* - * Configuration Macro: TRC_CFG_SYMBOL_TABLE_SLOTS - * - * The maximum number of symbols names that can be stored. This includes: - * - Task names - * - Named ISRs (vTraceSetISRProperties) - * - Named kernel objects (vTraceStoreKernelObjectName) - * - User event channels (xTraceRegisterString) - * - * If this value is too small, not all symbol names will be stored and the - * trace display will be affected. In that case, there will be warnings - * (as User Events) from TzCtrl task, that monitors this. - ******************************************************************************/ -#define TRC_CFG_SYMBOL_TABLE_SLOTS 40 - -/******************************************************************************* - * Configuration Macro: TRC_CFG_SYMBOL_MAX_LENGTH - * - * The maximum length of symbol names, including: - * - Task names - * - Named ISRs (vTraceSetISRProperties) - * - Named kernel objects (vTraceStoreKernelObjectName) - * - User event channel names (xTraceRegisterString) - * - * If longer symbol names are used, they will be truncated by the recorder, - * which will affect the trace display. In that case, there will be warnings - * (as User Events) from TzCtrl task, that monitors this. - ******************************************************************************/ -#define TRC_CFG_SYMBOL_MAX_LENGTH 25 - -/******************************************************************************* - * Configuration Macro: TRC_CFG_OBJECT_DATA_SLOTS - * - * The maximum number of object data entries (used for task priorities) that can - * be stored at the same time. Must be sufficient for all tasks, otherwise there - * will be warnings (as User Events) from TzCtrl task, that monitors this. - ******************************************************************************/ -#define TRC_CFG_OBJECT_DATA_SLOTS 40 - -/******************************************************************************* - * Configuration Macro: TRC_CFG_CTRL_TASK_STACK_SIZE - * - * The stack size of the TzCtrl task, that receive commands. - * We are aiming to remove this extra task in future versions. - ******************************************************************************/ -#define TRC_CFG_CTRL_TASK_STACK_SIZE (configMINIMAL_STACK_SIZE * 2) - -/******************************************************************************* - * Configuration Macro: TRC_CFG_CTRL_TASK_PRIORITY - * - * The priority of the TzCtrl task, that receive commands from Tracealyzer. - * Most stream ports also rely on the TzCtrl task to transmit the data from the - * internal buffer to the stream interface (all except for the J-Link port). - * For such ports, make sure the TzCtrl priority is high enough to ensure - * reliable periodic execution and transfer of the data. - ******************************************************************************/ -#define TRC_CFG_CTRL_TASK_PRIORITY 1 - -/******************************************************************************* - * Configuration Macro: TRC_CFG_CTRL_TASK_DELAY - * - * The delay between every loop of the TzCtrl task. A high delay will reduce the - * CPU load, but may cause missed events if the TzCtrl task is performing the - * trace transfer. - ******************************************************************************/ -#define TRC_CFG_CTRL_TASK_DELAY ((10 * configTICK_RATE_HZ) / 1000) - -/******************************************************************************* - * Configuration Macro: TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT - * - * Specifies the number of pages used by the paged event buffer. - * This may need to be increased if there are a lot of missed events. - * - * Note: not used by the J-Link RTT stream port (see trcStreamingPort.h instead) - ******************************************************************************/ -#define TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT 2 - -/******************************************************************************* - * Configuration Macro: TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE - * - * Specifies the size of each page in the paged event buffer. This can be tuned - * to match any internal low-level buffers used by the streaming interface, like - * the Ethernet MTU (Maximum Transmission Unit). - * - * Note: not used by the J-Link RTT stream port (see trcStreamingPort.h instead) - ******************************************************************************/ -#define TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE 2500 - -/******************************************************************************* - * TRC_CFG_ISR_TAILCHAINING_THRESHOLD - * - * Macro which should be defined as an integer value. - * - * If tracing multiple ISRs, this setting allows for accurate display of the - * context-switching also in cases when the ISRs execute in direct sequence. - * - * vTraceStoreISREnd normally assumes that the ISR returns to the previous - * context, i.e., a task or a preempted ISR. But if another traced ISR - * executes in direct sequence, Tracealyzer may incorrectly display a minimal - * fragment of the previous context in between the ISRs. - * - * By using TRC_CFG_ISR_TAILCHAINING_THRESHOLD you can avoid this. This is - * however a threshold value that must be measured for your specific setup. - * See http://percepio.com/2014/03/21/isr_tailchaining_threshold/ - * - * The default setting is 0, meaning "disabled" and that you may get an - * extra fragments of the previous context in between tail-chained ISRs. - * - * Note: This setting has separate definitions in trcSnapshotConfig.h and - * trcStreamingConfig.h, since it is affected by the recorder mode. - ******************************************************************************/ -#define TRC_CFG_ISR_TAILCHAINING_THRESHOLD 0 - -#ifdef __cplusplus -} -#endif - -#endif /* TRC_STREAMING_CONFIG_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/readme.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/readme.txt deleted file mode 100755 index 668e01c..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/readme.txt +++ /dev/null @@ -1,152 +0,0 @@ -------------------------------------------------------------------------------- - Tracealyzer for FreeRTOS - Trace Recorder Library v3.1.1 -------------------------------------------------------------------------------- - -Tracealyzer for FreeRTOS is a sophisticated tool for tracing and visualization -of FreeRTOS-based systems. Tracealyzer gives an unprecedented insight into the -runtime behavior, which speeds up debugging, validation and optimization. - -To learn more about this, see - - - Getting Started (videos etc): http://percepio.com/gettingstarted/tz-freertos/ - - - User Manual (incl. Recorder API): http://percepio.com/docs/FreeRTOS/manual - - - FAQ: http://percepio.com/category/faq/ - -In case you have any questions, don't hesitate to contact support@percepio.com - -------------------------------------------------------------------------------- - -Changes, v3.1.1 -> v3.1.2 - -- Fixed two bugs related to User Events, one in vTracePrintF and other in vTracePrint. - -- Fixed a build problem related to a single reference of the old FreeRTOS type "xTaskHandle", in trcKernelPort.c. - Changed to "TaskHandle_t", unless if using an older FreeRTOS kernel or the "compatibility mode". - -- Removed traceCREATE_MUTEX hook for FreeRTOS v9 or later (no longer required) - -- Updated the User Manual regarding snapshot trace via IAR Embedded Workbench. - -- Renamed vTraceGetTraceBuffer to xTraceGetTraceBuffer, since returning a pointer. - -------------------------------------------------------------------------------- - -Changes, v3.1.0 -> v3.1.1 - -After the major changes in the v3.1.0 trace recorder library, this update -corrects a number of minor issues. Only minor functional improvements. - -- You can now use TRC_ALLOC_CUSTOM_BUFFER to declare a trace buffer on a custom - location (using linker directives). - The related function vTraceSetRecorderDataBuffer has been promoted to the - Common API (previously only supported in snapshot mode, but custom allocation - is now generally supported also in streaming mode). - -- Removed TRC_CFG_USE_LINKER_PRAGMA. No longer necessary thanks to the custom - allocation mode. - -- Added support for timestamping from custom periodic timers, required for - accurate timestamping on Cortex-M0/M0+ devices when using tickless idle. - Only for streaming mode so far. See TRC_CUSTOM_TIMER_INCR / DECR. - -- ARM Cortex-M port: Made sure the DWT unit is initialized properly, in case - the debugger doesn't handle this. - -- ARM Cortex-M port: Added possibility to use Systick timestamping also on - Cortex-M3/M4/M7 devices (that otherwise use DWT timestamping by default). - To use this option, define the macro TRC_CFG_ARM_CM_USE_SYSTICK. - -- J-Link streaming: The default RTT buffer has been changed from 0 to 1. - -- J-Link streaming: The RTT buffer settings for buffer 1 and higher, are now - found in trcStreamingPort.h. Note: These settings don't apply to buffer 0. - -- vTracePrint has been optimized for better performance in string logging. - -- Minor performance improvement related to symbol table transfer in streaming mode. - -- Timer names now registered also in streaming mode. - -- Timer start and stop event are now traced. - -- Implemented support for queue registry (traceQUEUE_REGISTRY_ADD) also for streaming. - -- Fixed a bug related to repeated calls of vTraceEnable. - -- Fixed a bug where task-switches seemed to occur even though the scheduler was disabled. - -- Renamed HARDWARE_PORT_TEXAS_INSTRUMENTS_TMS570_RM48, added prefix TRC. - -- Fixed several language issues in the comments and documentation. - -- Fixed several minor issues and warnings from different compilers - (including PowerPC/gcc) and configurations. - -------------------------------------------------------------------------------- - -Changes, v3.0.9 -> v3.1.0 - -- Merge of previously separated snapshot and streaming recorders into a single - recorder supporting both streaming and snapshot as different modes. - -- New common API for supporting both streaming and snapshot modes. - -- New integration guide, see the User Manual. - -- Major improvement of API documentation in source files and User Manual. - -- New concept of "stream ports", giving a better structure defining streaming - interfaces, and restructured the J-Link and TCP/IP streaming as stream ports. - -- Added a stream port for USB CDC connections, with STM32 as example. - Since Tracealyzer now can receive serial data on Windows COM ports, this is - really easy to use. - -- Added a warning (#error) for cases where FreeRTOS tickless idle mode is used - together with timestamping using SysTick or other periodic interrupt timers, - Tracing with tickless idle requires an independent time source to correctly - capture the length of the idle periods. - -- Major changes in the recorder API. Important examples are: - - * Some configuration macros have changed names, e.g. for "hardware port". - Make sure to remove any old "trcConfig.h" files if upgrading from an - earlier version! - - * Recorder configuration in trcConfig.h has been minimized and now only - includes the important settings that are independent of recorder mode. - Advanced settings for each mode are found in trcSnapshotConfig.h and - trcStreamingConfig.h. - - * vTraceEnable replaces Trace_Init and vTraceInitTraceData, as well as - vTraceStart and uiTraceStart. - - * vTraceStop now part of the common API and thereby available also in - streaming. And since vTraceEnable can start the streaming directly - you have the option control the tracing from target, e.g., for - streaming to a device file system. - - * vTraceStoreKernelObjectName from old streaming recorder has been replaced - by vTraceSetQueueName, vTraceSetSemaphoreName, etc. - - * vTraceSetISRProperties now returns a "traceHandle" that should be passed as - parameter to vTraceStoreISRBegin and vTraceStoreISREnd. - - * xTraceRegisterString has replaced the old functions xTraceOpenLabel and - vTraceStoreUserEventChannelName. This now returns a "traceString" for use - as "channel" parameter in vTracePrintF, and in other places where strings - are stored. - - * Removed vTraceStoreISREndManual and vTraceStoreISREndAuto, use - vTraceStoreISREnd instead. - - * Renamed the functions for saving User Events in a separate buffer: - - xTraceRegisterChannelFormat -> xTraceRegisterUBChannel - - vTraceChannelPrintF -> vTraceUBData - - vTraceChannelUserEvent -> vTraceUBEvent - - -------------------------------------------------------------------------------- -Copyright Percepio AB, 2017. \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/Keil-uVision-Tracealyzer-ITM-Exporter.ini b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/Keil-uVision-Tracealyzer-ITM-Exporter.ini deleted file mode 100755 index c1dd7fc..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/Keil-uVision-Tracealyzer-ITM-Exporter.ini +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************ -* Percepio Tracealyzer - ITM Trace Exporter for Keil uVision -* Copyright (c) 2018, Percepio AB. -* https://percepio.com -************************************************************/ - -FUNC void tzSetEnable(int enable) -{ - if (enable == 1) - { - printf("Starting Tracealyzer recorder\n"); - - // Forward the ITM data to file - exec("ITMLOG 1 > .\\tracealyzer.psf"); - - // Send start command to Tracealyzer (not required if using vTraceEnable(TRC_START)) - exec("E CHAR tz_host_command_data = 1, 1, 0, 0, 0, 0, 0xFD, 0xFF"); - exec("tz_host_command_bytes_to_read = 8"); - } - else if (enable == 0) - { - printf("Stopping Tracealyzer recorder...\n"); - - // Send stop command to Tracealyzer, to stop writing ITM data. - exec("E CHAR tz_host_command_data = 1, 0, 0, 0, 0, 0, 0xFE, 0xFF"); - exec("tz_host_command_bytes_to_read = 8"); - - _sleep_(2000); // Wait a while to let all data be written the host file. - - // Stop forwarding the ITM data to file and close the file. - exec("ITMLOG 1 OFF"); - - printf("Tracealyzer recorder stopped.\n"); - - } - else printf("Usage: tzSetEnable(0 or 1), where 0 is disable (stops recorder) and 1 enable (starts recording)"); - -} - - -// The Tracealyzer ITM stream port for Keil µVision can be used in two ways. -// -// 1. Start tracing directly from startup. -// Make sure tzSetEnable(1) is called below and vTraceEnable(TRC_START) in your target startup. -// -// 2. Start the trace manually, using the "Start Recording" button in Keil µVision. -// In this case, comment out the below call to tzSetEnable and make sure you call vTraceEnable(TRC_INIT) in your target startup (not TRC_START). - -tzSetEnable(1); - -DEFINE BUTTON "Start Recording", "tzSetEnable(1)"; -DEFINE BUTTON "Stop Recording", "tzSetEnable(0)"; \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/Readme-ARM_ITM.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/Readme-ARM_ITM.txt deleted file mode 100755 index f0000ad..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/Readme-ARM_ITM.txt +++ /dev/null @@ -1,28 +0,0 @@ -Tracealyzer Stream Port for ARM Cortex-M ITM --------------------------------------------- -2018-05-04 - -This directory contains a "stream port" for the Tracealyzer recorder library, -i.e., the specific code needed to use a particular interface for streaming a -Tracealyzer RTOS trace. The stream port is defined by a set of macros in -trcStreamingPort.h, found in the "include" directory. - -This particular stream port targets ARM's ITM interface, which together with -a fast debug probe such as a Keil ULINKpro or ULINKplus provides excellent -performance. This stream port does not use any RAM buffer for the trace, but -writes the data directly to the ITM registers. This is very fast. - -To setup Keil uVision for ITM tracing with a Keil ULINKpro (or ULINKplus), -see Percepio Application Note PA-021 https://percepio.com/2018/05/04/keil-itm-support/ - -Learning more: - - Tracealyzer User Manual (Help -> User Manual) - - https://percepio.com/gettingstarted - - Percepio Application Note PA-021 https://percepio.com/2018/05/04/keil-itm-support/ - - About ITM trace, https://percepio.com/2016/06/09/arm-itm/ - - About the recorder and custom streaming, http://percepio.com/2016/10/05/rtos-tracing - -For questions, please contact support@percepio.com - -Percepio AB -www.percepio.com \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/include/trcStreamingPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/include/trcStreamingPort.h deleted file mode 100755 index f68d152..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/include/trcStreamingPort.h +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.5 - * Percepio AB, www.percepio.com - * - * trcStreamingPort.h - * - * The interface definitions for trace streaming ("stream ports"). - * This "stream port" sets up the recorder to use ARM ITM as streaming channel. - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_STREAMING_PORT_H -#define TRC_STREAMING_PORT_H - -#ifdef __cplusplus -extern "C" { -#endif - - -int32_t itm_write(void* ptrData, uint32_t size, int32_t* ptrBytesWritten); -int32_t read_from_host(void* ptrData, uint32_t size, int32_t* ptrBytesRead); - -/******************************************************************************* - * TRC_CFG_ITM_PORT - * - * Possible values: 0 - 31 - * - * What ITM port to use for the ITM software events. Make sure the IDE is - * configured for the same channel. - * - * Default: 1 (0 is typically terminal output and 31 is used by Keil) - * - ******************************************************************************/ -#define TRC_CFG_ITM_PORT 1 - -#if (TRC_CFG_ITM_PORT < 0) || (TRC_CFG_ITM_PORT > 31) -#error "Bad ITM port selected." -#endif - -// Not used for ITM - no RAM buffer... -#define TRC_STREAM_PORT_ALLOCATE_FIELDS() - -// Not used for ITM - assume the IDE configures the ITM setup -#define TRC_STREAM_PORT_INIT() - -/* Important for the ITM port - no RAM buffer, direct writes. In most other ports this can be skipped (default is 1) */ -#define TRC_STREAM_PORT_USE_INTERNAL_BUFFER 0 - -#define TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, _ptrBytesWritten) itm_write(_ptrData, _size, _ptrBytesWritten) - -#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) read_from_host(_ptrData, _size, _ptrBytesRead) - -#ifdef __cplusplus -} -#endif - -#endif /* TRC_STREAMING_PORT_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/trcStreamingPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/trcStreamingPort.c deleted file mode 100755 index 667e642..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/trcStreamingPort.c +++ /dev/null @@ -1,71 +0,0 @@ - -#include "trcRecorder.h" - -#if (TRC_USE_TRACEALYZER_RECORDER == 1) -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) - -static void itm_write_32(uint32_t data); - -volatile int32_t tz_host_command_bytes_to_read = 0; // This is set by the Tracealyzer host application (to the number of bytes written), after having written to tz_host_commands. Set to zero by the read function after the message in tz_host_commands has been read. -volatile char tz_host_command_data[32]; - -/* This reads "command" data from a RAM buffer, written by a host macro in the debugger */ -int32_t read_from_host(void* ptrData, uint32_t size, int32_t* ptrBytesRead) -{ - if ( tz_host_command_bytes_to_read > 0) - { - int i; - uint8_t * bytesBuffer = (uint8_t*) ptrData; - - if (ptrBytesRead != NULL) - *ptrBytesRead = (int32_t)tz_host_command_bytes_to_read; - - if (tz_host_command_bytes_to_read != size) - { - return -1; - } - - for (i=0; i < tz_host_command_bytes_to_read; i++) - { - bytesBuffer[i] = tz_host_command_data[i]; - } - - tz_host_command_bytes_to_read = 0; - } - - return 0; -} - -static void itm_write_32(uint32_t data) -{ - if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk) && // Trace enabled - (ITM->TCR & ITM_TCR_ITMENA_Msk) && // ITM enabled - (ITM->TER & (1UL << TRC_CFG_ITM_PORT))) // ITM port enabled - { - while (ITM->PORT[TRC_CFG_ITM_PORT].u32 == 0); // Block until room in ITM FIFO - This stream port is always in "blocking mode", since intended for high-speed ITM! - ITM->PORT[TRC_CFG_ITM_PORT].u32 = data; // Write the data - } -} - -/* This is assumed to execute from within the recorder, with interrupts disabled */ -int32_t itm_write(void* ptrData, uint32_t size, int32_t* ptrBytesWritten) -{ - uint32_t bytesWritten = 0; - uint32_t* ptr32 = (uint32_t*)ptrData; - - if (size % 4 != 0) return -2; - - while(bytesWritten < size) - { - itm_write_32(*ptr32); - ptr32++; - bytesWritten += 4; - } - - *ptrBytesWritten = bytesWritten; - - return 0; -} - -#endif -#endif diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/Readme-Streamport.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/Readme-Streamport.txt deleted file mode 100755 index c88517e..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/Readme-Streamport.txt +++ /dev/null @@ -1,19 +0,0 @@ -Tracealyzer Stream Port for Files -------------------------------------------------- - -This directory contains a "stream port" for the Tracealyzer recorder library, -i.e., the specific code needed to use a particular interface for streaming a -Tracealyzer RTOS trace. The stream port is defined by a set of macros in -trcStreamingPort.h, found in the "include" directory. - -This particular stream port is for streaming to a file via stdio.h (fwrite). - -To use this stream port, make sure that include/trcStreamingPort.h is found -by the compiler (i.e., add this folder to your project's include paths) and -add all included source files to your build. Make sure no other versions of -trcStreamingPort.h are included by mistake! - -See also http://percepio.com/2016/10/05/rtos-tracing. - -Percepio AB -www.percepio.com \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/include/trcStreamingPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/include/trcStreamingPort.h deleted file mode 100755 index e202159..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/include/trcStreamingPort.h +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.5 - * Percepio AB, www.percepio.com - * - * trcStreamingPort.h - * - * The interface definitions for trace streaming ("stream ports"). - * This "stream port" sets up the recorder to stream the trace to file. - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_STREAMING_PORT_H -#define TRC_STREAMING_PORT_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int32_t writeToFile(void* data, uint32_t size, int32_t *ptrBytesWritten); - -void closeFile(void); - -void openFile(char* fileName); - -/* This define will determine whether to use the internal PagedEventBuffer or not. -If file writing creates additional trace events (i.e. it uses semaphores or mutexes), -then the paged event buffer must be enabled to avoid infinite recursion. */ -#define TRC_STREAM_PORT_USE_INTERNAL_BUFFER 1 - -#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) 0 /* Does not read commands from Tz (yet) */ - -#define TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, _ptrBytesSent) writeToFile(_ptrData, _size, _ptrBytesSent) - -#if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC) -#define TRC_STREAM_PORT_MALLOC() \ - _TzTraceData = TRC_PORT_MALLOC((TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT) * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE)); -extern char* _TzTraceData; -#else -#define TRC_STREAM_PORT_MALLOC() /* Custom or static allocation. Not used. */ -#endif -#define TRC_STREAM_PORT_INIT() \ - TRC_STREAM_PORT_MALLOC(); \ - openFile("trace.psf") - -#define TRC_STREAM_PORT_ON_TRACE_END() closeFile() - -#ifdef __cplusplus -} -#endif - -#endif /* TRC_STREAMING_PORT_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/trcStreamingPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/trcStreamingPort.c deleted file mode 100755 index 09a388d..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/trcStreamingPort.c +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.5 - * Percepio AB, www.percepio.com - * - * trcStreamingPort.c - * - * Supporting functions for trace streaming, used by the "stream ports" - * for reading and writing data to the interface. - * Existing ports can easily be modified to fit another setup, e.g., a - * different TCP/IP stack, or to define your own stream port. - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#include "trcRecorder.h" - -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) -#if (TRC_USE_TRACEALYZER_RECORDER == 1) - -FILE* traceFile = NULL; - -void openFile(char* fileName) -{ - if (traceFile == NULL) - { - errno_t err = fopen_s(&traceFile, fileName, "wb"); - if (err != 0) - { - printf("Could not open trace file, error code %d.\n", err); - exit(-1); - } - else { - printf("Trace file created.\n"); - } - } -} - -int32_t writeToFile(void* data, uint32_t size, int32_t *ptrBytesWritten) -{ - int32_t written = 0; - if (traceFile != NULL) - { - written = fwrite(data, 1, size, traceFile); - } - else - { - written = 0; - } - - if (ptrBytesWritten != 0) - *ptrBytesWritten = written; - - if ((int32_t)size == written) - return 0; - else - return -1; -} - -void closeFile(void) -{ - if (traceFile != NULL) - { - fclose(traceFile); - traceFile = NULL; - printf("Trace file closed.\n"); - } -} - -#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/ -#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/Readme-Streamport.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/Readme-Streamport.txt deleted file mode 100755 index 0dcd159..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/Readme-Streamport.txt +++ /dev/null @@ -1,22 +0,0 @@ -Tracealyzer Stream Port for SEGGER J-Link ------------------------------------------ - -This directory contains a "stream port" for the Tracealyzer recorder library, -i.e., the specific code needed to use a particular interface for streaming a -Tracealyzer RTOS trace. The stream port is defined by a set of macros in -trcStreamingPort.h, found in the "include" directory. - -This particular stream port targets SEGGER J-Link debug probes, using the RTT -interface provided by SEGGER. - -To use this stream port, make sure that include/trcStreamingPort.h is found -by the compiler (i.e., add this folder to your project's include paths) and -add all included source files to your build. Make sure no other versions of -trcStreamingPort.h are included by mistake! - -Note that this stream port also contains SEGGER's RTT driver. - -See also http://percepio.com/2016/10/05/rtos-tracing. - -Percepio AB -www.percepio.com \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/SEGGER_RTT.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/SEGGER_RTT.c deleted file mode 100755 index b1b8d28..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/SEGGER_RTT.c +++ /dev/null @@ -1,1447 +0,0 @@ -/********************************************************************* -* SEGGER MICROCONTROLLER GmbH & Co. KG * -* Solutions for real time microcontroller applications * -********************************************************************** -* * -* (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG * -* * -* www.segger.com Support: support@segger.com * -* * -********************************************************************** -* * -* SEGGER RTT * Real Time Transfer for embedded targets * -* * -********************************************************************** -* * -* All rights reserved. * -* * -* * This software may in its unmodified form be freely redistributed * -* in source, linkable, or executable form. * -* * The source code may be modified, provided the source code * -* retains the above copyright notice, this list of conditions and * -* the following disclaimer. * -* * Modified versions of this software in source, executable, or * -* linkable form may not be distributed without prior consent of * -* SEGGER. * -* * This software may only be used for communication with SEGGER * -* J-Link debug probes. * -* * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * -* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * -* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * -* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * -* DAMAGE. * -* * -********************************************************************** -* * -* RTT version: 6.00e * -* * -********************************************************************** ----------------------------END-OF-HEADER------------------------------ -File : SEGGER_RTT.c -Purpose : Implementation of SEGGER real-time transfer (RTT) which - allows real-time communication on targets which support - debugger memory accesses while the CPU is running. -Revision: $Rev: 4079 $ - -Additional information: - Type "int" is assumed to be 32-bits in size - H->T Host to target communication - T->H Target to host communication - - RTT channel 0 is always present and reserved for Terminal usage. - Name is fixed to "Terminal" - - Effective buffer size: SizeOfBuffer - 1 - - WrOff == RdOff: Buffer is empty - WrOff == (RdOff - 1): Buffer is full - WrOff > RdOff: Free space includes wrap-around - WrOff < RdOff: Used space includes wrap-around - (WrOff == (SizeOfBuffer - 1)) && (RdOff == 0): - Buffer full and wrap-around after next byte - - ----------------------------------------------------------------------- -*/ - -#include "SEGGER_RTT.h" - -#include // for memcpy - -/********************************************************************* -* -* Configuration, default values -* -********************************************************************** -*/ - -#ifndef BUFFER_SIZE_UP - #define BUFFER_SIZE_UP 1024 // Size of the buffer for terminal output of target, up to host -#endif - -#ifndef BUFFER_SIZE_DOWN - #define BUFFER_SIZE_DOWN 16 // Size of the buffer for terminal input to target from host (Usually keyboard input) -#endif - -#ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS - #define SEGGER_RTT_MAX_NUM_UP_BUFFERS 2 // Number of up-buffers (T->H) available on this target -#endif - -#ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS - #define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS 2 // Number of down-buffers (H->T) available on this target -#endif - -#ifndef SEGGER_RTT_BUFFER_SECTION - #if defined(SEGGER_RTT_SECTION) - #define SEGGER_RTT_BUFFER_SECTION SEGGER_RTT_SECTION - #endif -#endif - -#ifndef SEGGER_RTT_ALIGNMENT - #define SEGGER_RTT_ALIGNMENT 0 -#endif - -#ifndef SEGGER_RTT_BUFFER_ALIGNMENT - #define SEGGER_RTT_BUFFER_ALIGNMENT 0 -#endif - -#ifndef SEGGER_RTT_MODE_DEFAULT - #define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP -#endif - -#ifndef SEGGER_RTT_LOCK - #define SEGGER_RTT_LOCK() -#endif - -#ifndef SEGGER_RTT_UNLOCK - #define SEGGER_RTT_UNLOCK() -#endif - -#ifndef STRLEN - #define STRLEN(a) strlen((a)) -#endif - -#ifndef MEMCPY - #define MEMCPY(pDest, pSrc, NumBytes) memcpy((pDest), (pSrc), (NumBytes)) -#endif - -#ifndef MIN - #define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif - -#ifndef MAX - #define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif -// -// For some environments, NULL may not be defined until certain headers are included -// -#ifndef NULL - #define NULL 0 -#endif - -/********************************************************************* -* -* Defines, fixed -* -********************************************************************** -*/ -#if (defined __ICCARM__) || (defined __ICCRX__) - #define RTT_PRAGMA(P) _Pragma(#P) -#endif - -#if SEGGER_RTT_ALIGNMENT || SEGGER_RTT_BUFFER_ALIGNMENT - #if (defined __GNUC__) - #define SEGGER_RTT_ALIGN(Var, Alignment) Var __attribute__ ((aligned (Alignment))) - #elif (defined __ICCARM__) || (defined __ICCRX__) - #define PRAGMA(A) _Pragma(#A) -#define SEGGER_RTT_ALIGN(Var, Alignment) RTT_PRAGMA(data_alignment=Alignment) \ - Var - #elif (defined __CC_ARM__) - #define SEGGER_RTT_ALIGN(Var, Alignment) Var __attribute__ ((aligned (Alignment))) - #else - #error "Alignment not supported for this compiler." - #endif -#else - #define SEGGER_RTT_ALIGN(Var, Alignment) Var -#endif - -#if defined(SEGGER_RTT_SECTION) || defined (SEGGER_RTT_BUFFER_SECTION) - #if (defined __GNUC__) - #define SEGGER_RTT_PUT_SECTION(Var, Section) __attribute__ ((section (Section))) Var - #elif (defined __ICCARM__) || (defined __ICCRX__) -#define SEGGER_RTT_PUT_SECTION(Var, Section) RTT_PRAGMA(location=Section) \ - Var - #elif (defined __CC_ARM__) - #define SEGGER_RTT_PUT_SECTION(Var, Section) __attribute__ ((section (Section), zero_init)) Var - #else - #error "Section placement not supported for this compiler." - #endif -#else - #define SEGGER_RTT_PUT_SECTION(Var, Section) Var -#endif - - -#if SEGGER_RTT_ALIGNMENT - #define SEGGER_RTT_CB_ALIGN(Var) SEGGER_RTT_ALIGN(Var, SEGGER_RTT_ALIGNMENT) -#else - #define SEGGER_RTT_CB_ALIGN(Var) Var -#endif - -#if SEGGER_RTT_BUFFER_ALIGNMENT - #define SEGGER_RTT_BUFFER_ALIGN(Var) SEGGER_RTT_ALIGN(Var, SEGGER_RTT_BUFFER_ALIGNMENT) -#else - #define SEGGER_RTT_BUFFER_ALIGN(Var) Var -#endif - - -#if defined(SEGGER_RTT_SECTION) - #define SEGGER_RTT_PUT_CB_SECTION(Var) SEGGER_RTT_PUT_SECTION(Var, SEGGER_RTT_SECTION) -#else - #define SEGGER_RTT_PUT_CB_SECTION(Var) Var -#endif - -#if defined(SEGGER_RTT_BUFFER_SECTION) - #define SEGGER_RTT_PUT_BUFFER_SECTION(Var) SEGGER_RTT_PUT_SECTION(Var, SEGGER_RTT_BUFFER_SECTION) -#else - #define SEGGER_RTT_PUT_BUFFER_SECTION(Var) Var -#endif - -/********************************************************************* -* -* Static const data -* -********************************************************************** -*/ - -static unsigned char _aTerminalId[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - -/********************************************************************* -* -* Static data -* -********************************************************************** -*/ -// -// RTT Control Block and allocate buffers for channel 0 -// -SEGGER_RTT_PUT_CB_SECTION(SEGGER_RTT_CB_ALIGN(SEGGER_RTT_CB _SEGGER_RTT)); - -SEGGER_RTT_PUT_BUFFER_SECTION(SEGGER_RTT_BUFFER_ALIGN(static char _acUpBuffer [BUFFER_SIZE_UP])); -SEGGER_RTT_PUT_BUFFER_SECTION(SEGGER_RTT_BUFFER_ALIGN(static char _acDownBuffer[BUFFER_SIZE_DOWN])); - -static char _ActiveTerminal; - -/********************************************************************* -* -* Static functions -* -********************************************************************** -*/ - -/********************************************************************* -* -* _DoInit() -* -* Function description -* Initializes the control block an buffers. -* May only be called via INIT() to avoid overriding settings. -* -*/ -#define INIT() do { \ - if (_SEGGER_RTT.acID[0] == '\0') { _DoInit(); } \ - } while (0) -static void _DoInit(void) { - SEGGER_RTT_CB* p; - // - // Initialize control block - // - p = &_SEGGER_RTT; - p->MaxNumUpBuffers = SEGGER_RTT_MAX_NUM_UP_BUFFERS; - p->MaxNumDownBuffers = SEGGER_RTT_MAX_NUM_DOWN_BUFFERS; - // - // Initialize up buffer 0 - // - p->aUp[0].sName = "Terminal"; - p->aUp[0].pBuffer = _acUpBuffer; - p->aUp[0].SizeOfBuffer = sizeof(_acUpBuffer); - p->aUp[0].RdOff = 0u; - p->aUp[0].WrOff = 0u; - p->aUp[0].Flags = SEGGER_RTT_MODE_DEFAULT; - // - // Initialize down buffer 0 - // - p->aDown[0].sName = "Terminal"; - p->aDown[0].pBuffer = _acDownBuffer; - p->aDown[0].SizeOfBuffer = sizeof(_acDownBuffer); - p->aDown[0].RdOff = 0u; - p->aDown[0].WrOff = 0u; - p->aDown[0].Flags = SEGGER_RTT_MODE_DEFAULT; - // - // Finish initialization of the control block. - // Copy Id string in three steps to make sure "SEGGER RTT" is not found - // in initializer memory (usually flash) by J-Link - // - strcpy(&p->acID[7], "RTT"); - strcpy(&p->acID[0], "SEGGER"); - p->acID[6] = ' '; -} - -/********************************************************************* -* -* _WriteBlocking() -* -* Function description -* Stores a specified number of characters in SEGGER RTT ring buffer -* and updates the associated write pointer which is periodically -* read by the host. -* The caller is responsible for managing the write chunk sizes as -* _WriteBlocking() will block until all data has been posted successfully. -* -* Parameters -* pRing Ring buffer to post to. -* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. -* NumBytes Number of bytes to be stored in the SEGGER RTT control block. -* -* Return value -* >= 0 - Number of bytes written into buffer. -*/ -static unsigned _WriteBlocking(SEGGER_RTT_BUFFER_UP* pRing, const char* pBuffer, unsigned NumBytes) { - unsigned NumBytesToWrite; - unsigned NumBytesWritten; - unsigned RdOff; - unsigned WrOff; - // - // Write data to buffer and handle wrap-around if necessary - // - NumBytesWritten = 0u; - WrOff = pRing->WrOff; - do { - RdOff = pRing->RdOff; // May be changed by host (debug probe) in the meantime - if (RdOff > WrOff) { - NumBytesToWrite = RdOff - WrOff - 1u; - } else { - NumBytesToWrite = pRing->SizeOfBuffer - (WrOff - RdOff + 1u); - } - NumBytesToWrite = MIN(NumBytesToWrite, (pRing->SizeOfBuffer - WrOff)); // Number of bytes that can be written until buffer wrap-around - NumBytesToWrite = MIN(NumBytesToWrite, NumBytes); - memcpy(pRing->pBuffer + WrOff, pBuffer, NumBytesToWrite); - NumBytesWritten += NumBytesToWrite; - pBuffer += NumBytesToWrite; - NumBytes -= NumBytesToWrite; - WrOff += NumBytesToWrite; - if (WrOff == pRing->SizeOfBuffer) { - WrOff = 0u; - } - pRing->WrOff = WrOff; - } while (NumBytes); - // - return NumBytesWritten; -} - -/********************************************************************* -* -* _WriteNoCheck() -* -* Function description -* Stores a specified number of characters in SEGGER RTT ring buffer -* and updates the associated write pointer which is periodically -* read by the host. -* It is callers responsibility to make sure data actually fits in buffer. -* -* Parameters -* pRing Ring buffer to post to. -* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. -* NumBytes Number of bytes to be stored in the SEGGER RTT control block. -* -* Notes -* (1) If there might not be enough space in the "Up"-buffer, call _WriteBlocking -*/ -static void _WriteNoCheck(SEGGER_RTT_BUFFER_UP* pRing, const char* pData, unsigned NumBytes) { - unsigned NumBytesAtOnce; - unsigned WrOff; - unsigned Rem; - - WrOff = pRing->WrOff; - Rem = pRing->SizeOfBuffer - WrOff; - if (Rem > NumBytes) { - // - // All data fits before wrap around - // - memcpy(pRing->pBuffer + WrOff, pData, NumBytes); - pRing->WrOff = WrOff + NumBytes; - } else { - // - // We reach the end of the buffer, so need to wrap around - // - NumBytesAtOnce = Rem; - memcpy(pRing->pBuffer + WrOff, pData, NumBytesAtOnce); - NumBytesAtOnce = NumBytes - Rem; - memcpy(pRing->pBuffer, pData + Rem, NumBytesAtOnce); - pRing->WrOff = NumBytesAtOnce; - } -} - -/********************************************************************* -* -* _PostTerminalSwitch() -* -* Function description -* Switch terminal to the given terminal ID. It is the caller's -* responsibility to ensure the terminal ID is correct and there is -* enough space in the buffer for this to complete successfully. -* -* Parameters -* pRing Ring buffer to post to. -* TerminalId Terminal ID to switch to. -*/ -static void _PostTerminalSwitch(SEGGER_RTT_BUFFER_UP* pRing, unsigned char TerminalId) { - char ac[2]; - - ac[0] = 0xFFu; - ac[1] = _aTerminalId[TerminalId]; // Caller made already sure that TerminalId does not exceed our terminal limit - _WriteBlocking(pRing, ac, 2u); -} - -/********************************************************************* -* -* _GetAvailWriteSpace() -* -* Function description -* Returns the number of bytes that can be written to the ring -* buffer without blocking. -* -* Parameters -* pRing Ring buffer to check. -* -* Return value -* Number of bytes that are free in the buffer. -*/ -static unsigned _GetAvailWriteSpace(SEGGER_RTT_BUFFER_UP* pRing) { - unsigned RdOff; - unsigned WrOff; - unsigned r; - // - // Avoid warnings regarding volatile access order. It's not a problem - // in this case, but dampen compiler enthusiasm. - // - RdOff = pRing->RdOff; - WrOff = pRing->WrOff; - if (RdOff <= WrOff) { - r = pRing->SizeOfBuffer - 1u - WrOff + RdOff; - } else { - r = RdOff - WrOff - 1u; - } - return r; -} - -/********************************************************************* -* -* Public code -* -********************************************************************** -*/ -/********************************************************************* -* -* SEGGER_RTT_ReadNoLock() -* -* Function description -* Reads characters from SEGGER real-time-terminal control block -* which have been previously stored by the host. -* Do not lock against interrupts and multiple access. -* -* Parameters -* BufferIndex Index of Down-buffer to be used (e.g. 0 for "Terminal"). -* pBuffer Pointer to buffer provided by target application, to copy characters from RTT-down-buffer to. -* BufferSize Size of the target application buffer. -* -* Return value -* Number of bytes that have been read. -*/ -unsigned SEGGER_RTT_ReadNoLock(unsigned BufferIndex, void* pData, unsigned BufferSize) { - unsigned NumBytesRem; - unsigned NumBytesRead; - unsigned RdOff; - unsigned WrOff; - unsigned char* pBuffer; - SEGGER_RTT_BUFFER_DOWN* pRing; - // - INIT(); - pRing = &_SEGGER_RTT.aDown[BufferIndex]; - pBuffer = (unsigned char*)pData; - RdOff = pRing->RdOff; - WrOff = pRing->WrOff; - NumBytesRead = 0u; - // - // Read from current read position to wrap-around of buffer, first - // - if (RdOff > WrOff) { - NumBytesRem = pRing->SizeOfBuffer - RdOff; - NumBytesRem = MIN(NumBytesRem, BufferSize); - memcpy(pBuffer, pRing->pBuffer + RdOff, NumBytesRem); - NumBytesRead += NumBytesRem; - pBuffer += NumBytesRem; - BufferSize -= NumBytesRem; - RdOff += NumBytesRem; - // - // Handle wrap-around of buffer - // - if (RdOff == pRing->SizeOfBuffer) { - RdOff = 0u; - } - } - // - // Read remaining items of buffer - // - NumBytesRem = WrOff - RdOff; - NumBytesRem = MIN(NumBytesRem, BufferSize); - if (NumBytesRem > 0u) { - memcpy(pBuffer, pRing->pBuffer + RdOff, NumBytesRem); - NumBytesRead += NumBytesRem; - pBuffer += NumBytesRem; - BufferSize -= NumBytesRem; - RdOff += NumBytesRem; - } - if (NumBytesRead) { - pRing->RdOff = RdOff; - } - // - return NumBytesRead; -} - -/********************************************************************* -* -* SEGGER_RTT_Read -* -* Function description -* Reads characters from SEGGER real-time-terminal control block -* which have been previously stored by the host. -* -* Parameters -* BufferIndex Index of Down-buffer to be used (e.g. 0 for "Terminal"). -* pBuffer Pointer to buffer provided by target application, to copy characters from RTT-down-buffer to. -* BufferSize Size of the target application buffer. -* -* Return value -* Number of bytes that have been read. -*/ -unsigned SEGGER_RTT_Read(unsigned BufferIndex, void* pBuffer, unsigned BufferSize) { - unsigned NumBytesRead; - // - SEGGER_RTT_LOCK(); - // - // Call the non-locking read function - // - NumBytesRead = SEGGER_RTT_ReadNoLock(BufferIndex, pBuffer, BufferSize); - // - // Finish up. - // - SEGGER_RTT_UNLOCK(); - // - return NumBytesRead; -} - -/********************************************************************* -* -* SEGGER_RTT_WriteWithOverwriteNoLock -* -* Function description -* Stores a specified number of characters in SEGGER RTT -* control block. -* SEGGER_RTT_WriteWithOverwriteNoLock does not lock the application -* and overwrites data if the data does not fit into the buffer. -* -* Parameters -* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). -* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. -* NumBytes Number of bytes to be stored in the SEGGER RTT control block. -* -* Notes -* (1) If there is not enough space in the "Up"-buffer, data is overwritten. -* (2) For performance reasons this function does not call Init() -* and may only be called after RTT has been initialized. -* Either by calling SEGGER_RTT_Init() or calling another RTT API function first. -* (3) Do not use SEGGER_RTT_WriteWithOverwriteNoLock if a J-Link -* connection reads RTT data. -*/ -void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) { - const char* pData; - SEGGER_RTT_BUFFER_UP* pRing; - unsigned Avail; - - pData = (const char *)pBuffer; - // - // Get "to-host" ring buffer and copy some elements into local variables. - // - pRing = &_SEGGER_RTT.aUp[BufferIndex]; - // - // Check if we will overwrite data and need to adjust the RdOff. - // - if (pRing->WrOff == pRing->RdOff) { - Avail = pRing->SizeOfBuffer - 1u; - } else if ( pRing->WrOff < pRing->RdOff) { - Avail = pRing->RdOff - pRing->WrOff - 1u; - } else { - Avail = pRing->RdOff - pRing->WrOff - 1u + pRing->SizeOfBuffer; - } - if (NumBytes > Avail) { - pRing->RdOff += (NumBytes - Avail); - while (pRing->RdOff >= pRing->SizeOfBuffer) { - pRing->RdOff -= pRing->SizeOfBuffer; - } - } - // - // Write all data, no need to check the RdOff, but possibly handle multiple wrap-arounds - // - Avail = pRing->SizeOfBuffer - pRing->WrOff; - do { - if (Avail > NumBytes) { - // - // Last round - // -#if 1 // memcpy() is good for large amounts of data, but the overhead is too big for small amounts. Use a simple byte loop instead. - char* pDst; - pDst = pRing->pBuffer + pRing->WrOff; - pRing->WrOff += NumBytes; - do { - *pDst++ = *pData++; - } while (--NumBytes); -#else - memcpy(pRing->pBuffer + WrOff, pData, NumBytes); - pRing->WrOff += NumBytes; -#endif - break; //Alternatively: NumBytes = 0; - } else { - // - // Wrap-around necessary, write until wrap-around and reset WrOff - // - memcpy(pRing->pBuffer + pRing->WrOff, pData, Avail); - pData += Avail; - pRing->WrOff = 0; - NumBytes -= Avail; - Avail = (pRing->SizeOfBuffer - 1); - } - } while (NumBytes); -} - -/********************************************************************* -* -* SEGGER_RTT_WriteSkipNoLock -* -* Function description -* Stores a specified number of characters in SEGGER RTT -* control block which is then read by the host. -* SEGGER_RTT_WriteSkipNoLock does not lock the application and -* skips all data, if the data does not fit into the buffer. -* -* Parameters -* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). -* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. -* NumBytes Number of bytes to be stored in the SEGGER RTT control block. -* -* Return value -* Number of bytes which have been stored in the "Up"-buffer. -* -* Notes -* (1) If there is not enough space in the "Up"-buffer, all data is dropped. -* (2) For performance reasons this function does not call Init() -* and may only be called after RTT has been initialized. -* Either by calling SEGGER_RTT_Init() or calling another RTT API function first. -*/ -unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) { - const char* pData; - SEGGER_RTT_BUFFER_UP* pRing; - unsigned Avail; - unsigned RdOff; - unsigned WrOff; - unsigned Rem; - - pData = (const char *)pBuffer; - // - // Get "to-host" ring buffer and copy some elements into local variables. - // - pRing = &_SEGGER_RTT.aUp[BufferIndex]; - RdOff = pRing->RdOff; - WrOff = pRing->WrOff; - // - // Handle the most common cases fastest. - // Which is: - // RdOff <= WrOff -> Space until wrap around is free. - // AND - // WrOff + NumBytes < SizeOfBuffer -> No Wrap around necessary. - // - // OR - // - // RdOff > WrOff -> Space until RdOff - 1 is free. - // AND - // WrOff + NumBytes < RdOff -> Data fits into buffer - // - if (RdOff <= WrOff) { - // - // Get space until WrOff will be at wrap around. - // - Avail = pRing->SizeOfBuffer - 1u - WrOff ; - if (Avail >= NumBytes) { -#if 1 // memcpy() is good for large amounts of data, but the overhead is too big for small amounts. Use a simple byte loop instead. - char* pDst; - pDst = pRing->pBuffer + WrOff; - WrOff += NumBytes; - do { - *pDst++ = *pData++; - } while (--NumBytes); - pRing->WrOff = WrOff + NumBytes; -#else - memcpy(pRing->pBuffer + WrOff, pData, NumBytes); - pRing->WrOff = WrOff + NumBytes; -#endif - return 1; - } - // - // If data did not fit into space until wrap around calculate complete space in buffer. - // - Avail += RdOff; - // - // If there is still no space for the whole of this output, don't bother. - // - if (Avail >= NumBytes) { - // - // OK, we have enough space in buffer. Copy in one or 2 chunks - // - Rem = pRing->SizeOfBuffer - WrOff; // Space until end of buffer - if (Rem > NumBytes) { - memcpy(pRing->pBuffer + WrOff, pData, NumBytes); - pRing->WrOff = WrOff + NumBytes; - } else { - // - // We reach the end of the buffer, so need to wrap around - // - memcpy(pRing->pBuffer + WrOff, pData, Rem); - memcpy(pRing->pBuffer, pData + Rem, NumBytes - Rem); - pRing->WrOff = NumBytes - Rem; - } - return 1; - } - } else { - Avail = RdOff - WrOff - 1u; - if (Avail >= NumBytes) { - memcpy(pRing->pBuffer + WrOff, pData, NumBytes); - pRing->WrOff = WrOff + NumBytes; - return 1; - } - } - // - // If we reach this point no data has been written - // - return 0; -} - -/********************************************************************* -* -* SEGGER_RTT_WriteNoLock -* -* Function description -* Stores a specified number of characters in SEGGER RTT -* control block which is then read by the host. -* SEGGER_RTT_WriteNoLock does not lock the application. -* -* Parameters -* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). -* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. -* NumBytes Number of bytes to be stored in the SEGGER RTT control block. -* -* Return value -* Number of bytes which have been stored in the "Up"-buffer. -* -* Notes -* (1) If there is not enough space in the "Up"-buffer, remaining characters of pBuffer are dropped. -* (2) For performance reasons this function does not call Init() -* and may only be called after RTT has been initialized. -* Either by calling SEGGER_RTT_Init() or calling another RTT API function first. -*/ -unsigned SEGGER_RTT_WriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) { - unsigned Status; - unsigned Avail; - const char* pData; - SEGGER_RTT_BUFFER_UP* pRing; - - pData = (const char *)pBuffer; - // - // Get "to-host" ring buffer. - // - pRing = &_SEGGER_RTT.aUp[BufferIndex]; - // - // How we output depends upon the mode... - // - switch (pRing->Flags) { - case SEGGER_RTT_MODE_NO_BLOCK_SKIP: - // - // If we are in skip mode and there is no space for the whole - // of this output, don't bother. - // - Avail = _GetAvailWriteSpace(pRing); - if (Avail < NumBytes) { - Status = 0u; - } else { - Status = NumBytes; - _WriteNoCheck(pRing, pData, NumBytes); - } - break; - case SEGGER_RTT_MODE_NO_BLOCK_TRIM: - // - // If we are in trim mode, trim to what we can output without blocking. - // - Avail = _GetAvailWriteSpace(pRing); - Status = Avail < NumBytes ? Avail : NumBytes; - _WriteNoCheck(pRing, pData, Status); - break; - case SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL: - // - // If we are in blocking mode, output everything. - // - Status = _WriteBlocking(pRing, pData, NumBytes); - break; - default: - Status = 0u; - break; - } - // - // Finish up. - // - return Status; -} - -/********************************************************************* -* -* SEGGER_RTT_Write -* -* Function description -* Stores a specified number of characters in SEGGER RTT -* control block which is then read by the host. -* -* Parameters -* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). -* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. -* NumBytes Number of bytes to be stored in the SEGGER RTT control block. -* -* Return value -* Number of bytes which have been stored in the "Up"-buffer. -* -* Notes -* (1) If there is not enough space in the "Up"-buffer, remaining characters of pBuffer are dropped. -*/ -unsigned SEGGER_RTT_Write(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) { - unsigned Status; - // - INIT(); - SEGGER_RTT_LOCK(); - // - // Call the non-locking write function - // - Status = SEGGER_RTT_WriteNoLock(BufferIndex, pBuffer, NumBytes); - // - // Finish up. - // - SEGGER_RTT_UNLOCK(); - // - return Status; -} - -/********************************************************************* -* -* SEGGER_RTT_WriteString -* -* Function description -* Stores string in SEGGER RTT control block. -* This data is read by the host. -* -* Parameters -* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). -* s Pointer to string. -* -* Return value -* Number of bytes which have been stored in the "Up"-buffer. -* -* Notes -* (1) If there is not enough space in the "Up"-buffer, depending on configuration, -* remaining characters may be dropped or RTT module waits until there is more space in the buffer. -* (2) String passed to this function has to be \0 terminated -* (3) \0 termination character is *not* stored in RTT buffer -*/ -unsigned SEGGER_RTT_WriteString(unsigned BufferIndex, const char* s) { - unsigned Len; - - Len = STRLEN(s); - return SEGGER_RTT_Write(BufferIndex, s, Len); -} - -/********************************************************************* -* -* SEGGER_RTT_GetKey -* -* Function description -* Reads one character from the SEGGER RTT buffer. -* Host has previously stored data there. -* -* Return value -* < 0 - No character available (buffer empty). -* >= 0 - Character which has been read. (Possible values: 0 - 255) -* -* Notes -* (1) This function is only specified for accesses to RTT buffer 0. -*/ -int SEGGER_RTT_GetKey(void) { - char c; - int r; - - r = (int)SEGGER_RTT_Read(0u, &c, 1u); - if (r == 1) { - r = (int)(unsigned char)c; - } else { - r = -1; - } - return r; -} - -/********************************************************************* -* -* SEGGER_RTT_WaitKey -* -* Function description -* Waits until at least one character is avaible in the SEGGER RTT buffer. -* Once a character is available, it is read and this function returns. -* -* Return value -* >=0 - Character which has been read. -* -* Notes -* (1) This function is only specified for accesses to RTT buffer 0 -* (2) This function is blocking if no character is present in RTT buffer -*/ -int SEGGER_RTT_WaitKey(void) { - int r; - - do { - r = SEGGER_RTT_GetKey(); - } while (r < 0); - return r; -} - -/********************************************************************* -* -* SEGGER_RTT_HasKey -* -* Function description -* Checks if at least one character for reading is available in the SEGGER RTT buffer. -* -* Return value -* == 0 - No characters are available to read. -* == 1 - At least one character is available. -* -* Notes -* (1) This function is only specified for accesses to RTT buffer 0 -*/ -int SEGGER_RTT_HasKey(void) { - unsigned RdOff; - int r; - - INIT(); - RdOff = _SEGGER_RTT.aDown[0].RdOff; - if (RdOff != _SEGGER_RTT.aDown[0].WrOff) { - r = 1; - } else { - r = 0; - } - return r; -} - -/********************************************************************* -* -* SEGGER_RTT_HasData -* -* Function description -* Check if there is data from the host in the given buffer. -* -* Return value: -* ==0: No data -* !=0: Data in buffer -* -*/ -unsigned SEGGER_RTT_HasData(unsigned BufferIndex) { - SEGGER_RTT_BUFFER_DOWN* pRing; - unsigned v; - - pRing = &_SEGGER_RTT.aDown[BufferIndex]; - v = pRing->WrOff; - return v - pRing->RdOff; -} - -/********************************************************************* -* -* SEGGER_RTT_AllocDownBuffer -* -* Function description -* Run-time configuration of the next down-buffer (H->T). -* The next buffer, which is not used yet is configured. -* This includes: Buffer address, size, name, flags, ... -* -* Parameters -* sName Pointer to a constant name string. -* pBuffer Pointer to a buffer to be used. -* BufferSize Size of the buffer. -* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message). -* -* Return value -* >= 0 - O.K. Buffer Index -* < 0 - Error -*/ -int SEGGER_RTT_AllocDownBuffer(const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) { - int BufferIndex; - - INIT(); - SEGGER_RTT_LOCK(); - BufferIndex = 0; - do { - if (_SEGGER_RTT.aDown[BufferIndex].pBuffer == NULL) { - break; - } - BufferIndex++; - } while (BufferIndex < _SEGGER_RTT.MaxNumDownBuffers); - if (BufferIndex < _SEGGER_RTT.MaxNumDownBuffers) { - _SEGGER_RTT.aDown[BufferIndex].sName = sName; - _SEGGER_RTT.aDown[BufferIndex].pBuffer = (char*)pBuffer; - _SEGGER_RTT.aDown[BufferIndex].SizeOfBuffer = BufferSize; - _SEGGER_RTT.aDown[BufferIndex].RdOff = 0u; - _SEGGER_RTT.aDown[BufferIndex].WrOff = 0u; - _SEGGER_RTT.aDown[BufferIndex].Flags = Flags; - } else { - BufferIndex = -1; - } - SEGGER_RTT_UNLOCK(); - return BufferIndex; -} - -/********************************************************************* -* -* SEGGER_RTT_AllocUpBuffer -* -* Function description -* Run-time configuration of the next up-buffer (T->H). -* The next buffer, which is not used yet is configured. -* This includes: Buffer address, size, name, flags, ... -* -* Parameters -* sName Pointer to a constant name string. -* pBuffer Pointer to a buffer to be used. -* BufferSize Size of the buffer. -* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message). -* -* Return value -* >= 0 - O.K. Buffer Index -* < 0 - Error -*/ -int SEGGER_RTT_AllocUpBuffer(const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) { - int BufferIndex; - - INIT(); - SEGGER_RTT_LOCK(); - BufferIndex = 0; - do { - if (_SEGGER_RTT.aUp[BufferIndex].pBuffer == NULL) { - break; - } - BufferIndex++; - } while (BufferIndex < _SEGGER_RTT.MaxNumUpBuffers); - if (BufferIndex < _SEGGER_RTT.MaxNumUpBuffers) { - _SEGGER_RTT.aUp[BufferIndex].sName = sName; - _SEGGER_RTT.aUp[BufferIndex].pBuffer = (char*)pBuffer; - _SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer = BufferSize; - _SEGGER_RTT.aUp[BufferIndex].RdOff = 0u; - _SEGGER_RTT.aUp[BufferIndex].WrOff = 0u; - _SEGGER_RTT.aUp[BufferIndex].Flags = Flags; - } else { - BufferIndex = -1; - } - SEGGER_RTT_UNLOCK(); - return BufferIndex; -} - -/********************************************************************* -* -* SEGGER_RTT_ConfigUpBuffer -* -* Function description -* Run-time configuration of a specific up-buffer (T->H). -* Buffer to be configured is specified by index. -* This includes: Buffer address, size, name, flags, ... -* -* Parameters -* BufferIndex Index of the buffer to configure. -* sName Pointer to a constant name string. -* pBuffer Pointer to a buffer to be used. -* BufferSize Size of the buffer. -* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message). -* -* Return value -* >= 0 - O.K. -* < 0 - Error -* -* Additional information -* Buffer 0 is configured on compile-time. -* May only be called once per buffer. -* Buffer name and flags can be reconfigured using the appropriate functions. -*/ -int SEGGER_RTT_ConfigUpBuffer(unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) { - int r; - - INIT(); - if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumUpBuffers) { - SEGGER_RTT_LOCK(); - if (BufferIndex > 0u) { - _SEGGER_RTT.aUp[BufferIndex].sName = sName; - _SEGGER_RTT.aUp[BufferIndex].pBuffer = (char*)pBuffer; - _SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer = BufferSize; - _SEGGER_RTT.aUp[BufferIndex].RdOff = 0u; - _SEGGER_RTT.aUp[BufferIndex].WrOff = 0u; - } - _SEGGER_RTT.aUp[BufferIndex].Flags = Flags; - SEGGER_RTT_UNLOCK(); - r = 0; - } else { - r = -1; - } - return r; -} - -/********************************************************************* -* -* SEGGER_RTT_ConfigDownBuffer -* -* Function description -* Run-time configuration of a specific down-buffer (H->T). -* Buffer to be configured is specified by index. -* This includes: Buffer address, size, name, flags, ... -* -* Parameters -* BufferIndex Index of the buffer to configure. -* sName Pointer to a constant name string. -* pBuffer Pointer to a buffer to be used. -* BufferSize Size of the buffer. -* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message). -* -* Return value -* >= 0 O.K. -* < 0 Error -* -* Additional information -* Buffer 0 is configured on compile-time. -* May only be called once per buffer. -* Buffer name and flags can be reconfigured using the appropriate functions. -*/ -int SEGGER_RTT_ConfigDownBuffer(unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) { - int r; - - INIT(); - if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumDownBuffers) { - SEGGER_RTT_LOCK(); - if (BufferIndex > 0u) { - _SEGGER_RTT.aDown[BufferIndex].sName = sName; - _SEGGER_RTT.aDown[BufferIndex].pBuffer = (char*)pBuffer; - _SEGGER_RTT.aDown[BufferIndex].SizeOfBuffer = BufferSize; - _SEGGER_RTT.aDown[BufferIndex].RdOff = 0u; - _SEGGER_RTT.aDown[BufferIndex].WrOff = 0u; - } - _SEGGER_RTT.aDown[BufferIndex].Flags = Flags; - SEGGER_RTT_UNLOCK(); - r = 0; - } else { - r = -1; - } - return r; -} - -/********************************************************************* -* -* SEGGER_RTT_SetNameUpBuffer -* -* Function description -* Run-time configuration of a specific up-buffer name (T->H). -* Buffer to be configured is specified by index. -* -* Parameters -* BufferIndex Index of the buffer to renamed. -* sName Pointer to a constant name string. -* -* Return value -* >= 0 O.K. -* < 0 Error -*/ -int SEGGER_RTT_SetNameUpBuffer(unsigned BufferIndex, const char* sName) { - int r; - - INIT(); - if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumUpBuffers) { - SEGGER_RTT_LOCK(); - _SEGGER_RTT.aUp[BufferIndex].sName = sName; - SEGGER_RTT_UNLOCK(); - r = 0; - } else { - r = -1; - } - return r; -} - -/********************************************************************* -* -* SEGGER_RTT_SetNameDownBuffer -* -* Function description -* Run-time configuration of a specific Down-buffer name (T->H). -* Buffer to be configured is specified by index. -* -* Parameters -* BufferIndex Index of the buffer to renamed. -* sName Pointer to a constant name string. -* -* Return value -* >= 0 O.K. -* < 0 Error -*/ -int SEGGER_RTT_SetNameDownBuffer(unsigned BufferIndex, const char* sName) { - int r; - - INIT(); - if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumDownBuffers) { - SEGGER_RTT_LOCK(); - _SEGGER_RTT.aDown[BufferIndex].sName = sName; - SEGGER_RTT_UNLOCK(); - r = 0; - } else { - r = -1; - } - return r; -} - -/********************************************************************* -* -* SEGGER_RTT_SetFlagsUpBuffer -* -* Function description -* Run-time configuration of specific up-buffer flags (T->H). -* Buffer to be configured is specified by index. -* -* Parameters -* BufferIndex Index of the buffer. -* Flags Flags to set for the buffer. -* -* Return value -* >= 0 O.K. -* < 0 Error -*/ -int SEGGER_RTT_SetFlagsUpBuffer(unsigned BufferIndex, unsigned Flags) { - int r; - - INIT(); - if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumUpBuffers) { - SEGGER_RTT_LOCK(); - _SEGGER_RTT.aUp[BufferIndex].Flags = Flags; - SEGGER_RTT_UNLOCK(); - r = 0; - } else { - r = -1; - } - return r; -} - -/********************************************************************* -* -* SEGGER_RTT_SetFlagsDownBuffer -* -* Function description -* Run-time configuration of specific Down-buffer flags (T->H). -* Buffer to be configured is specified by index. -* -* Parameters -* BufferIndex Index of the buffer to renamed. -* Flags Flags to set for the buffer. -* -* Return value -* >= 0 O.K. -* < 0 Error -*/ -int SEGGER_RTT_SetFlagsDownBuffer(unsigned BufferIndex, unsigned Flags) { - int r; - - INIT(); - if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumDownBuffers) { - SEGGER_RTT_LOCK(); - _SEGGER_RTT.aDown[BufferIndex].Flags = Flags; - SEGGER_RTT_UNLOCK(); - r = 0; - } else { - r = -1; - } - return r; -} - -/********************************************************************* -* -* SEGGER_RTT_Init -* -* Function description -* Initializes the RTT Control Block. -* Should be used in RAM targets, at start of the application. -* -*/ -void SEGGER_RTT_Init (void) { - _DoInit(); -} - -/********************************************************************* -* -* SEGGER_RTT_SetTerminal -* -* Function description -* Sets the terminal to be used for output on channel 0. -* -* Parameters -* TerminalId Index of the terminal. -* -* Return value -* >= 0 O.K. -* < 0 Error (e.g. if RTT is configured for non-blocking mode and there was no space in the buffer to set the new terminal Id) -*/ -int SEGGER_RTT_SetTerminal (char TerminalId) { - char ac[2]; - SEGGER_RTT_BUFFER_UP* pRing; - unsigned Avail; - int r; - // - INIT(); - // - r = 0; - ac[0] = 0xFFU; - if ((unsigned char)TerminalId < (unsigned char)sizeof(_aTerminalId)) { // We only support a certain number of channels - ac[1] = _aTerminalId[(unsigned char)TerminalId]; - pRing = &_SEGGER_RTT.aUp[0]; // Buffer 0 is always reserved for terminal I/O, so we can use index 0 here, fixed - SEGGER_RTT_LOCK(); // Lock to make sure that no other task is writing into buffer, while we are and number of free bytes in buffer does not change downwards after checking and before writing - if ((pRing->Flags & SEGGER_RTT_MODE_MASK) == SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL) { - _ActiveTerminal = TerminalId; - _WriteBlocking(pRing, ac, 2u); - } else { // Skipping mode or trim mode? => We cannot trim this command so handling is the same for both modes - Avail = _GetAvailWriteSpace(pRing); - if (Avail >= 2) { - _ActiveTerminal = TerminalId; // Only change active terminal in case of success - _WriteNoCheck(pRing, ac, 2u); - } else { - r = -1; - } - } - SEGGER_RTT_UNLOCK(); - } else { - r = -1; - } - return r; -} - -/********************************************************************* -* -* SEGGER_RTT_TerminalOut -* -* Function description -* Writes a string to the given terminal -* without changing the terminal for channel 0. -* -* Parameters -* TerminalId Index of the terminal. -* s String to be printed on the terminal. -* -* Return value -* >= 0 - Number of bytes written. -* < 0 - Error. -* -*/ -int SEGGER_RTT_TerminalOut (char TerminalId, const char* s) { - int Status; - unsigned FragLen; - unsigned Avail; - SEGGER_RTT_BUFFER_UP* pRing; - // - INIT(); - // - // Validate terminal ID. - // - if (TerminalId < (char)sizeof(_aTerminalId)) { // We only support a certain number of channels - // - // Get "to-host" ring buffer. - // - pRing = &_SEGGER_RTT.aUp[0]; - // - // Need to be able to change terminal, write data, change back. - // Compute the fixed and variable sizes. - // - FragLen = strlen(s); - // - // How we output depends upon the mode... - // - SEGGER_RTT_LOCK(); - Avail = _GetAvailWriteSpace(pRing); - switch (pRing->Flags & SEGGER_RTT_MODE_MASK) { - case SEGGER_RTT_MODE_NO_BLOCK_SKIP: - // - // If we are in skip mode and there is no space for the whole - // of this output, don't bother switching terminals at all. - // - if (Avail < (FragLen + 4u)) { - Status = 0; - } else { - _PostTerminalSwitch(pRing, TerminalId); - Status = (int)_WriteBlocking(pRing, s, FragLen); - _PostTerminalSwitch(pRing, _ActiveTerminal); - } - break; - case SEGGER_RTT_MODE_NO_BLOCK_TRIM: - // - // If we are in trim mode and there is not enough space for everything, - // trim the output but always include the terminal switch. If no room - // for terminal switch, skip that totally. - // - if (Avail < 4u) { - Status = -1; - } else { - _PostTerminalSwitch(pRing, TerminalId); - Status = (int)_WriteBlocking(pRing, s, (FragLen < (Avail - 4u)) ? FragLen : (Avail - 4u)); - _PostTerminalSwitch(pRing, _ActiveTerminal); - } - break; - case SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL: - // - // If we are in blocking mode, output everything. - // - _PostTerminalSwitch(pRing, TerminalId); - Status = (int)_WriteBlocking(pRing, s, FragLen); - _PostTerminalSwitch(pRing, _ActiveTerminal); - break; - default: - Status = -1; - break; - } - // - // Finish up. - // - SEGGER_RTT_UNLOCK(); - } else { - Status = -1; - } - return Status; -} - - -/*************************** End of file ****************************/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/SEGGER_RTT.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/SEGGER_RTT.h deleted file mode 100755 index f2bd1ee..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/SEGGER_RTT.h +++ /dev/null @@ -1,238 +0,0 @@ -/********************************************************************* -* SEGGER MICROCONTROLLER GmbH & Co. KG * -* Solutions for real time microcontroller applications * -********************************************************************** -* * -* (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG * -* * -* www.segger.com Support: support@segger.com * -* * -********************************************************************** -* * -* SEGGER RTT * Real Time Transfer for embedded targets * -* * -********************************************************************** -* * -* All rights reserved. * -* * -* * This software may in its unmodified form be freely redistributed * -* in source, linkable, or executable form. * -* * The source code may be modified, provided the source code * -* retains the above copyright notice, this list of conditions and * -* the following disclaimer. * -* * Modified versions of this software in source, executable, or * -* linkable form may not be distributed without prior consent of * -* SEGGER. * -* * This software may only be used for communication with SEGGER * -* J-Link debug probes. * -* * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * -* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * -* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * -* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * -* DAMAGE. * -* * -********************************************************************** -* * -* RTT version: 6.00e * -* * -********************************************************************** ----------------------------END-OF-HEADER------------------------------ -File : SEGGER_RTT.h -Purpose : Implementation of SEGGER real-time transfer which allows - real-time communication on targets which support debugger - memory accesses while the CPU is running. -Revision: $Rev: 4079 $ ----------------------------------------------------------------------- -*/ - -#ifndef SEGGER_RTT_H -#define SEGGER_RTT_H - -#include "SEGGER_RTT_Conf.h" - -/********************************************************************* -* -* Defines, fixed -* -********************************************************************** -*/ - -/********************************************************************* -* -* Types -* -********************************************************************** -*/ - -// -// Description for a circular buffer (also called "ring buffer") -// which is used as up-buffer (T->H) -// -typedef struct { - const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4" - char* pBuffer; // Pointer to start of buffer - unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty. - unsigned WrOff; // Position of next item to be written by either target. - volatile unsigned RdOff; // Position of next item to be read by host. Must be volatile since it may be modified by host. - unsigned Flags; // Contains configuration flags -} SEGGER_RTT_BUFFER_UP; - -// -// Description for a circular buffer (also called "ring buffer") -// which is used as down-buffer (H->T) -// -typedef struct { - const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4" - char* pBuffer; // Pointer to start of buffer - unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty. - volatile unsigned WrOff; // Position of next item to be written by host. Must be volatile since it may be modified by host. - unsigned RdOff; // Position of next item to be read by target (down-buffer). - unsigned Flags; // Contains configuration flags -} SEGGER_RTT_BUFFER_DOWN; - -// -// RTT control block which describes the number of buffers available -// as well as the configuration for each buffer -// -// -typedef struct { - char acID[16]; // Initialized to "SEGGER RTT" - int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2) - int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2) - SEGGER_RTT_BUFFER_UP aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host - SEGGER_RTT_BUFFER_DOWN aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target -} SEGGER_RTT_CB; - -/********************************************************************* -* -* Global data -* -********************************************************************** -*/ -extern SEGGER_RTT_CB _SEGGER_RTT; - -/********************************************************************* -* -* RTT API functions -* -********************************************************************** -*/ -#ifdef __cplusplus - extern "C" { -#endif -int SEGGER_RTT_AllocDownBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags); -int SEGGER_RTT_AllocUpBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags); -int SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags); -int SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags); -int SEGGER_RTT_GetKey (void); -unsigned SEGGER_RTT_HasData (unsigned BufferIndex); -int SEGGER_RTT_HasKey (void); -void SEGGER_RTT_Init (void); -unsigned SEGGER_RTT_Read (unsigned BufferIndex, void* pBuffer, unsigned BufferSize); -unsigned SEGGER_RTT_ReadNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize); -int SEGGER_RTT_SetNameDownBuffer (unsigned BufferIndex, const char* sName); -int SEGGER_RTT_SetNameUpBuffer (unsigned BufferIndex, const char* sName); -int SEGGER_RTT_SetFlagsDownBuffer (unsigned BufferIndex, unsigned Flags); -int SEGGER_RTT_SetFlagsUpBuffer (unsigned BufferIndex, unsigned Flags); -int SEGGER_RTT_WaitKey (void); -unsigned SEGGER_RTT_Write (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); -unsigned SEGGER_RTT_WriteNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); -unsigned SEGGER_RTT_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); -unsigned SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s); -void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); -// -// Function macro for performance optimization -// -#define SEGGER_RTT_HASDATA(n) (_SEGGER_RTT.aDown[n].WrOff - _SEGGER_RTT.aDown[n].RdOff) - -/********************************************************************* -* -* RTT "Terminal" API functions -* -********************************************************************** -*/ -int SEGGER_RTT_SetTerminal (char TerminalId); -int SEGGER_RTT_TerminalOut (char TerminalId, const char* s); - -/********************************************************************* -* -* RTT printf functions (require SEGGER_RTT_printf.c) -* -********************************************************************** -*/ -int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...); -#ifdef __cplusplus - } -#endif - -/********************************************************************* -* -* Defines -* -********************************************************************** -*/ - -// -// Operating modes. Define behavior if buffer is full (not enough space for entire message) -// -#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0U) // Skip. Do not block, output nothing. (Default) -#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1U) // Trim: Do not block, output as much as fits. -#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (2U) // Block: Wait until there is space in the buffer. -#define SEGGER_RTT_MODE_MASK (3U) - -// -// Control sequences, based on ANSI. -// Can be used to control color, and clear the screen -// -#define RTT_CTRL_RESET "" // Reset to default colors -#define RTT_CTRL_CLEAR "" // Clear screen, reposition cursor to top left - -#define RTT_CTRL_TEXT_BLACK "" -#define RTT_CTRL_TEXT_RED "" -#define RTT_CTRL_TEXT_GREEN "" -#define RTT_CTRL_TEXT_YELLOW "" -#define RTT_CTRL_TEXT_BLUE "" -#define RTT_CTRL_TEXT_MAGENTA "" -#define RTT_CTRL_TEXT_CYAN "" -#define RTT_CTRL_TEXT_WHITE "" - -#define RTT_CTRL_TEXT_BRIGHT_BLACK "" -#define RTT_CTRL_TEXT_BRIGHT_RED "" -#define RTT_CTRL_TEXT_BRIGHT_GREEN "" -#define RTT_CTRL_TEXT_BRIGHT_YELLOW "" -#define RTT_CTRL_TEXT_BRIGHT_BLUE "" -#define RTT_CTRL_TEXT_BRIGHT_MAGENTA "" -#define RTT_CTRL_TEXT_BRIGHT_CYAN "" -#define RTT_CTRL_TEXT_BRIGHT_WHITE "" - -#define RTT_CTRL_BG_BLACK "" -#define RTT_CTRL_BG_RED "" -#define RTT_CTRL_BG_GREEN "" -#define RTT_CTRL_BG_YELLOW "" -#define RTT_CTRL_BG_BLUE "" -#define RTT_CTRL_BG_MAGENTA "" -#define RTT_CTRL_BG_CYAN "" -#define RTT_CTRL_BG_WHITE "" - -#define RTT_CTRL_BG_BRIGHT_BLACK "" -#define RTT_CTRL_BG_BRIGHT_RED "" -#define RTT_CTRL_BG_BRIGHT_GREEN "" -#define RTT_CTRL_BG_BRIGHT_YELLOW "" -#define RTT_CTRL_BG_BRIGHT_BLUE "" -#define RTT_CTRL_BG_BRIGHT_MAGENTA "" -#define RTT_CTRL_BG_BRIGHT_CYAN "" -#define RTT_CTRL_BG_BRIGHT_WHITE "" - - -#endif - -/*************************** End of file ****************************/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/SEGGER_RTT_Conf.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/SEGGER_RTT_Conf.h deleted file mode 100755 index f3d906f..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/SEGGER_RTT_Conf.h +++ /dev/null @@ -1,259 +0,0 @@ -/********************************************************************* -* SEGGER MICROCONTROLLER GmbH & Co. KG * -* Solutions for real time microcontroller applications * -********************************************************************** -* * -* (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG * -* * -* www.segger.com Support: support@segger.com * -* * -********************************************************************** -* * -* SEGGER RTT * Real Time Transfer for embedded targets * -* * -********************************************************************** -* * -* All rights reserved. * -* * -* * This software may in its unmodified form be freely redistributed * -* in source, linkable, or executable form. * -* * The source code may be modified, provided the source code * -* retains the above copyright notice, this list of conditions and * -* the following disclaimer. * -* * Modified versions of this software in source, executable, or * -* linkable form may not be distributed without prior consent of * -* SEGGER. * -* * This software may only be used for communication with SEGGER * -* J-Link debug probes. * -* * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * -* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * -* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * -* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * -* DAMAGE. * -* * -********************************************************************** -* * -* RTT version: 6.00e * -* * -********************************************************************** ----------------------------------------------------------------------- -File : SEGGER_RTT_Conf.h -Purpose : Implementation of SEGGER real-time transfer (RTT) which - allows real-time communication on targets which support - debugger memory accesses while the CPU is running. -Revision: $Rev: 3892 $ ----------------------------END-OF-HEADER------------------------------ -*/ - -#ifndef SEGGER_RTT_CONF_H -#define SEGGER_RTT_CONF_H - -#ifdef __IAR_SYSTEMS_ICC__ - #include -#endif - -/********************************************************************* -* -* Defines, configurable -* -********************************************************************** -*/ - -#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (3) // Max. number of up-buffers (T->H) available on this target (Default: 3) -#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (3) // Max. number of down-buffers (H->T) available on this target (Default: 3) - -#define BUFFER_SIZE_UP (64) // Size of the buffer for terminal output of target, up to host (Default: 1k) -#define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16) - -#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64) - -#define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0) - -// -// Target is not allowed to perform other RTT operations while string still has not been stored completely. -// Otherwise we would probably end up with a mixed string in the buffer. -// If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here. -// -// SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4. -// Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches. -// When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly. -// (Higher priority = lower priority number) -// Default value for embOS: 128u -// Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) -// In case of doubt mask all interrupts: 1 << (8 - BASEPRI_PRIO_BITS) i.e. 1 << 5 when 3 bits are implemented in NVIC -// or define SEGGER_RTT_LOCK() to completely disable interrupts. -// - -#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20) - -/********************************************************************* -* -* RTT lock configuration for SEGGER Embedded Studio, -* Rowley CrossStudio and GCC -*/ -#if (defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__) - #ifdef __ARM_ARCH_6M__ - #define SEGGER_RTT_LOCK() { \ - unsigned int LockState; \ - __asm volatile ("mrs %0, primask \n\t" \ - "mov r1, $1 \n\t" \ - "msr primask, r1 \n\t" \ - : "=r" (LockState) \ - : \ - : "r1" \ - ); - - #define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" \ - : \ - : "r" (LockState) \ - : \ - ); \ - } - - #elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)) - #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY - #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) - #endif - #define SEGGER_RTT_LOCK() { \ - unsigned int LockState; \ - __asm volatile ("mrs %0, basepri \n\t" \ - "mov r1, %1 \n\t" \ - "msr basepri, r1 \n\t" \ - : "=r" (LockState) \ - : "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) \ - : "r1" \ - ); - - #define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" \ - : \ - : "r" (LockState) \ - : \ - ); \ - } - - #elif defined(__ARM_ARCH_7A__) - #define SEGGER_RTT_LOCK() { \ - unsigned int LockState; \ - __asm volatile ("mrs r1, CPSR \n\t" \ - "mov %0, r1 \n\t" \ - "orr r1, r1, #0xC0 \n\t" \ - "msr CPSR_c, r1 \n\t" \ - : "=r" (LockState) \ - : \ - : "r1" \ - ); - - #define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \ - "mrs r1, CPSR \n\t" \ - "bic r1, r1, #0xC0 \n\t" \ - "and r0, r0, #0xC0 \n\t" \ - "orr r1, r1, r0 \n\t" \ - "msr CPSR_c, r1 \n\t" \ - : \ - : "r" (LockState) \ - : "r0", "r1" \ - ); \ - } -#else - #define SEGGER_RTT_LOCK() - #define SEGGER_RTT_UNLOCK() - #endif -#endif - -/********************************************************************* -* -* RTT lock configuration for IAR EWARM -*/ -#ifdef __ICCARM__ - #if (defined (__ARM6M__) && (__CORE__ == __ARM6M__)) - #define SEGGER_RTT_LOCK() { \ - unsigned int LockState; \ - LockState = __get_PRIMASK(); \ - __set_PRIMASK(1); - - #define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \ - } - #elif ((defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || (defined (__ARM7M__) && (__CORE__ == __ARM7M__))) - #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY - #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) - #endif - #define SEGGER_RTT_LOCK() { \ - unsigned int LockState; \ - LockState = __get_BASEPRI(); \ - __set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY); - - #define SEGGER_RTT_UNLOCK() __set_BASEPRI(LockState); \ - } - #endif -#endif - -/********************************************************************* -* -* RTT lock configuration for IAR RX -*/ -#ifdef __ICCRX__ - #define SEGGER_RTT_LOCK() { \ - unsigned long LockState; \ - LockState = __get_interrupt_state(); \ - __disable_interrupt(); - - #define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \ - } -#endif - -/********************************************************************* -* -* RTT lock configuration for KEIL ARM -*/ -#ifdef __CC_ARM - #if (defined __TARGET_ARCH_6S_M) - #define SEGGER_RTT_LOCK() { \ - unsigned int LockState; \ - register unsigned char PRIMASK __asm( "primask"); \ - LockState = PRIMASK; \ - PRIMASK = 1u; \ - __schedule_barrier(); - - #define SEGGER_RTT_UNLOCK() PRIMASK = LockState; \ - __schedule_barrier(); \ - } - #elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M)) - #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY - #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) - #endif - #define SEGGER_RTT_LOCK() { \ - unsigned int LockState; \ - register unsigned char BASEPRI __asm( "basepri"); \ - LockState = BASEPRI; \ - BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \ - __schedule_barrier(); - - #define SEGGER_RTT_UNLOCK() BASEPRI = LockState; \ - __schedule_barrier(); \ - } - #endif -#endif - -/********************************************************************* -* -* RTT lock configuration fallback -*/ -#ifndef SEGGER_RTT_LOCK - #define SEGGER_RTT_LOCK() // Lock RTT (nestable) (i.e. disable interrupts) -#endif - -#ifndef SEGGER_RTT_UNLOCK - #define SEGGER_RTT_UNLOCK() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state) -#endif - -#endif -/*************************** End of file ****************************/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/trcStreamingPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/trcStreamingPort.h deleted file mode 100755 index be9c569..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/trcStreamingPort.h +++ /dev/null @@ -1,196 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.5 - * Percepio AB, www.percepio.com - * - * trcStreamingPort.h - * - * The interface definitions for trace streaming ("stream ports"). - * This "stream port" sets up the recorder to use SEGGER RTT as streaming channel. - * - * Note that this stream port is more complex than the typical case, since - * the J-Link interface uses a separate RAM buffer in SEGGER_RTT.c, instead - * of the default buffer included in the recorder core. The other stream ports - * offer more typical examples of how to define a custom streaming interface. - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_STREAMING_PORT_H -#define TRC_STREAMING_PORT_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/******************************************************************************* - * Configuration Macro: TRC_CFG_RTT_BUFFER_SIZE_UP - * - * Defines the size of the "up" RTT buffer (target -> host) to use for writing - * the trace data, for RTT buffer 1 or higher. - * - * This setting is ignored for RTT buffer 0, which can't be reconfigured - * in runtime and therefore hard-coded to use the defines in SEGGER_RTT_Conf.h. - * - * Default buffer size for Tracealyzer is 5000 bytes. - * - * If you have a stand-alone J-Link probe, the can be decreased to around 1 KB. - * But integrated J-Link OB interfaces are slower and needs about 5-10 KB, - * depending on the amount of data produced. - ******************************************************************************/ -#define TRC_CFG_RTT_BUFFER_SIZE_UP 5000 - -/******************************************************************************* - * Configuration Macro: TRC_CFG_RTT_BUFFER_SIZE_DOWN - * - * Defines the size of the "down" RTT buffer (host -> target) to use for reading - * commands from Tracealyzer, for RTT buffer 1 or higher. - * - * Default buffer size for Tracealyzer is 32 bytes. - * - * This setting is ignored for RTT buffer 0, which can't be reconfigured - * in runtime and therefore hard-coded to use the defines in SEGGER_RTT_Conf.h. - ******************************************************************************/ -#define TRC_CFG_RTT_BUFFER_SIZE_DOWN 32 - -/******************************************************************************* - * Configuration Macro: TRC_CFG_RTT_UP_BUFFER_INDEX - * - * Defines the RTT buffer to use for writing the trace data. Make sure that - * the PC application has the same setting (File->Settings). - * - * Default: 1 - * - * We don't recommend using RTT buffer 0, since mainly intended for terminals. - * If you prefer to use buffer 0, it must be configured in SEGGER_RTT_Conf.h. - ******************************************************************************/ -#define TRC_CFG_RTT_UP_BUFFER_INDEX 1 - -/******************************************************************************* - * Configuration Macro: TRC_CFG_RTT_DOWN_BUFFER_INDEX - * - * Defines the RTT buffer to use for reading the trace data. Make sure that - * the PC application has the same setting (File->Settings). - * - * Default: 1 - * - * We don't recommend using RTT buffer 0, since mainly intended for terminals. - * If you prefer to use buffer 0, it must be configured in SEGGER_RTT_Conf.h. - ******************************************************************************/ -#define TRC_CFG_RTT_DOWN_BUFFER_INDEX 1 - -/******************************************************************************* - * TRC_CFG_RTT_MODE - * This stream port for J-Link streaming relies on SEGGER RTT, that contains an - * internal RAM buffer read by the J-Link probes during execution. - * - * Possible values: - * - SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL - * - SEGGER_RTT_MODE_NO_BLOCK_SKIP (default) - * - * Using SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL ensure that you get a - * complete and valid trace. This may however cause blocking if your streaming - * interface isn't fast enough, which may disturb the real-time behavior. - * - * We therefore recommend SEGGER_RTT_MODE_NO_BLOCK_SKIP. In this mode, - * Tracealyzer will report lost events if the transfer is not - * fast enough. In that case, try increasing the size of the "up buffer". - ******************************************************************************/ -#define TRC_CFG_RTT_MODE SEGGER_RTT_MODE_NO_BLOCK_SKIP - -#include "SEGGER_RTT_Conf.h" -#include "SEGGER_RTT.h" - -#if (TRC_CFG_RTT_UP_BUFFER_INDEX >= SEGGER_RTT_MAX_NUM_UP_BUFFERS) -#error "TRC_CFG_RTT_UP_BUFFER_INDEX must be smaller than SEGGER_RTT_MAX_NUM_UP_BUFFERS" -#endif - -#if (TRC_CFG_RTT_DOWN_BUFFER_INDEX >= SEGGER_RTT_MAX_NUM_DOWN_BUFFERS) -#error "TRC_CFG_RTT_DOWN_BUFFER_INDEX must be smaller than SEGGER_RTT_MAX_NUM_DOWN_BUFFERS" -#endif - -/* If index is defined as 0, the internal RTT buffers will be used instead of this. */ -#if TRC_CFG_RTT_UP_BUFFER_INDEX == 0 -#define TRC_RTT_ALLOC_UP() static char* _TzTraceData = NULL; /* Not actually used. Ignore allocation method. */ -#define TRC_STREAM_PORT_MALLOC() /* Static allocation. Not used. */ -#else -#if TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_STATIC -#define TRC_RTT_ALLOC_UP() char _TzTraceData[TRC_CFG_RTT_BUFFER_SIZE_UP]; /* Static allocation */ -#define TRC_STREAM_PORT_MALLOC() /* Static allocation. Not used. */ -#endif -#if TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC -#define TRC_RTT_ALLOC_UP() char* _TzTraceData = NULL; /* Dynamic allocation */ -#define TRC_STREAM_PORT_MALLOC() _TzTraceData = TRC_PORT_MALLOC(TRC_CFG_RTT_BUFFER_SIZE_UP); -#endif -#if TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM -#define TRC_RTT_ALLOC_UP() char* _TzTraceData = NULL; /* Custom allocation, user needs to call vTraceSetRecorderDataBuffer before vTraceEnable, to assign this */ -#define TRC_STREAM_PORT_MALLOC() /* Not used in custom mode */ -#endif -#endif - -/* Down-buffer. If index is defined as 0, the internal RTT buffers will be used instead of this. */ \ -#if TRC_CFG_RTT_DOWN_BUFFER_INDEX == 0 -#define TRC_RTT_ALLOC_DOWN() static char* _TzCtrlData = NULL; /* Not actually used. Ignore allocation method. */ -#else -#define TRC_RTT_ALLOC_DOWN() static char _TzCtrlData[TRC_CFG_RTT_BUFFER_SIZE_DOWN]; /* Always static allocation, since usually small. */ -#endif - -#define TRC_STREAM_PORT_ALLOCATE_FIELDS() \ - TRC_RTT_ALLOC_UP() /* Macro that will result in proper UP buffer allocation */ \ - TRC_RTT_ALLOC_DOWN() /* Macro that will result in proper DOWN buffer allocation */ - -int32_t readFromRTT(void* ptrData, uint32_t size, int32_t* ptrBytesRead); - -int32_t writeToRTT(void* ptrData, uint32_t size, int32_t* ptrBytesWritten); - - -#define TRC_STREAM_PORT_INIT() \ - TRC_STREAM_PORT_MALLOC(); /*Dynamic allocation or empty if static */ \ - SEGGER_RTT_ConfigUpBuffer(TRC_CFG_RTT_UP_BUFFER_INDEX, "TzData", _TzTraceData, TRC_CFG_RTT_BUFFER_SIZE_UP, TRC_CFG_RTT_MODE ); \ - SEGGER_RTT_ConfigDownBuffer(TRC_CFG_RTT_DOWN_BUFFER_INDEX, "TzCtrl", _TzCtrlData, TRC_CFG_RTT_BUFFER_SIZE_DOWN, TRC_CFG_RTT_MODE); - -/* Important for the J-Link port, in most other ports this can be skipped (default is 1) */ -#define TRC_STREAM_PORT_USE_INTERNAL_BUFFER 0 - -#define TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, _ptrBytesWritten) writeToRTT(_ptrData, _size, _ptrBytesWritten) - -#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) readFromRTT(_ptrData, _size, _ptrBytesRead) - -#ifdef __cplusplus -} -#endif - -#endif /* TRC_STREAMING_PORT_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/trcStreamingPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/trcStreamingPort.c deleted file mode 100755 index 29b7b22..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/trcStreamingPort.c +++ /dev/null @@ -1,44 +0,0 @@ - -#include "trcRecorder.h" - -#if (TRC_USE_TRACEALYZER_RECORDER == 1) -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) - -int32_t readFromRTT(void* ptrData, uint32_t size, int32_t* ptrBytesRead) -{ - uint32_t bytesRead = 0; - - if (SEGGER_RTT_HASDATA(TRC_CFG_RTT_DOWN_BUFFER_INDEX)) - { - bytesRead = SEGGER_RTT_Read((TRC_CFG_RTT_DOWN_BUFFER_INDEX), (char*)ptrData, size); - - if (ptrBytesRead != NULL) - *ptrBytesRead = (int32_t)bytesRead; - - if (bytesRead != size) - { - return -1; - } - - } - - return 0; -} - -int32_t writeToRTT(void* ptrData, uint32_t size, int32_t* ptrBytesWritten) -{ - uint32_t bytesWritten = SEGGER_RTT_Write((TRC_CFG_RTT_UP_BUFFER_INDEX), (const char*)ptrData, size); - - if (ptrBytesWritten != NULL) - *ptrBytesWritten = (int32_t)bytesWritten; - - if (bytesWritten != size) - { - return -1; - } - - return 0; -} - -#endif -#endif diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/TCPIP/Readme-Streamport.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/TCPIP/Readme-Streamport.txt deleted file mode 100755 index 0239366..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/TCPIP/Readme-Streamport.txt +++ /dev/null @@ -1,22 +0,0 @@ -Tracealyzer Stream Port for TCP/IP (lwIP example) -------------------------------------------------- - -This directory contains a "stream port" for the Tracealyzer recorder library, -i.e., the specific code needed to use a particular interface for streaming a -Tracealyzer RTOS trace. The stream port is defined by a set of macros in -trcStreamingPort.h, found in the "include" directory. - -This particular stream port targets TCP/IP. This example assumes lwIP but is -easy to modify for other TCP/IP stacks. - -To use this stream port, make sure that include/trcStreamingPort.h is found -by the compiler (i.e., add this folder to your project's include paths) and -add all included source files to your build. Make sure no other versions of -trcStreamingPort.h are included by mistake! - -Note that lwIP is not included, but assumed to exist in the project already. - -See also http://percepio.com/2016/10/05/rtos-tracing. - -Percepio AB -www.percepio.com \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/TCPIP/include/trcStreamingPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/TCPIP/include/trcStreamingPort.h deleted file mode 100755 index 992e744..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/TCPIP/include/trcStreamingPort.h +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.5 - * Percepio AB, www.percepio.com - * - * trcStreamingPort.h - * - * The interface definitions for trace streaming ("stream ports"). - * This "stream port" sets up the recorder to use TCP/IP as streaming channel. - * The example is for lwIP. - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_STREAMING_PORT_H -#define TRC_STREAMING_PORT_H - -#ifdef __cplusplus -extern "C" { -#endif - -int32_t trcTcpRead(void* data, uint32_t size, int32_t *ptrBytesRead); - -int32_t trcTcpWrite(void* data, uint32_t size, int32_t *ptrBytesWritten); - -#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) trcTcpRead(_ptrData, _size, _ptrBytesRead) - -#define TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, _ptrBytesSent) trcTcpWrite(_ptrData, _size, _ptrBytesSent) - -#ifdef __cplusplus -} -#endif - -#endif /* TRC_STREAMING_PORT_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/TCPIP/trcStreamingPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/TCPIP/trcStreamingPort.c deleted file mode 100755 index 058e854..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/TCPIP/trcStreamingPort.c +++ /dev/null @@ -1,186 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.5 - * Percepio AB, www.percepio.com - * - * trcStreamingPort.c - * - * Supporting functions for trace streaming, used by the "stream ports" - * for reading and writing data to the interface. - * Existing ports can easily be modified to fit another setup, e.g., a - * different TCP/IP stack, or to define your own stream port. - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#include "trcRecorder.h" - -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) -#if (TRC_USE_TRACEALYZER_RECORDER == 1) - -/* TCP/IP includes - for lwIP in this case */ -#include "lwip/tcpip.h" -#include "lwip/sockets.h" - -int errno; - -#define TRC_TCPIP_PORT 12000 - -int sock = -1, new_sd = -1; -int flags = 0; -int remoteSize; -struct sockaddr_in address, remote; - -int32_t trcSocketSend( void* data, int32_t size, int32_t* bytesWritten ) -{ - if (new_sd < 0) - return -1; - - if (bytesWritten == NULL) - return -1; - - *bytesWritten = send( new_sd, data, size, 0 ); - if (*bytesWritten < 0) - { - /* EWOULDBLOCK may be expected when buffers are full */ - if (errno != 0 && errno != EWOULDBLOCK) - { - closesocket(new_sd); - new_sd = -1; - return -1; - } - else - *bytesWritten = 0; - } - - return 0; -} - -int32_t trcSocketReceive( void* data, int32_t size, int32_t* bytesRead ) -{ - if (new_sd < 0) - return -1; - - *bytesRead = recv( new_sd, data, size, 0 ); - if ( *bytesRead < 0 ) - { - /* EWOULDBLOCK may be expected when there is no data to receive */ - if (errno != 0 && errno != EWOULDBLOCK) - { - closesocket(new_sd); - new_sd = -1; - return -1; - } - else - *bytesRead = 0; - } - - return 0; -} - -int32_t trcSocketInitializeListener() -{ - if (sock >= 0) - return 0; - - sock = lwip_socket(AF_INET, SOCK_STREAM, 0); - - if (sock < 0) - return -1; - - address.sin_family = AF_INET; - address.sin_port = htons( TRC_TCPIP_PORT ); - address.sin_addr.s_addr = INADDR_ANY; - - if (bind(sock, (struct sockaddr *)&address, sizeof (address)) < 0) - { - closesocket(sock); - sock = -1; - return -1; - } - - if (lwip_listen(sock, 5) < 0) - { - closesocket(sock); - sock = -1; - return -1; - } - - return 0; -} - -int32_t trcSocketAccept() -{ - if (sock < 0) - return -1; - - if (new_sd >= 0) - return 0; - - remoteSize = sizeof( remote ); - new_sd = accept( sock, (struct sockaddr *)&remote, (socklen_t*)&remoteSize ); - - flags = fcntl( new_sd, F_GETFL, 0 ); - fcntl( new_sd, F_SETFL, flags | O_NONBLOCK ); - - if( new_sd < 0 ) - { - closesocket(new_sd); - new_sd = -1; - closesocket(sock); - sock = -1; - return -1; - } - - return 0; -} -/************** MODIFY THE ABOVE PART TO USE YOUR TPC/IP STACK ****************/ - -int32_t trcTcpWrite(void* data, uint32_t size, int32_t *ptrBytesWritten) -{ - return trcSocketSend(data, size, ptrBytesWritten); -} - -int32_t trcTcpRead(void* data, uint32_t size, int32_t *ptrBytesRead) -{ - trcSocketInitializeListener(); - - trcSocketAccept(); - - return trcSocketReceive(data, size, ptrBytesRead); -} - -#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/ -#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/USB_CDC/Readme-Streamport.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/USB_CDC/Readme-Streamport.txt deleted file mode 100755 index a231518..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/USB_CDC/Readme-Streamport.txt +++ /dev/null @@ -1,27 +0,0 @@ -Tracealyzer Stream Port for USB CDC (STM32 example) ---------------------------------------------------- - -This directory contains a "stream port" for the Tracealyzer recorder library, -i.e., the specific code needed to use a particular interface for streaming a -Tracealyzer RTOS trace. The stream port is defined by a set of macros in -trcStreamingPort.h, found in the "include" directory. - -This particular stream port targets USB CDC. This is an example for the STM32 USB -stack (from the STM32CubeMX code generation tool, v1.4.1) and has been tested on -a STM32F767ZI device on a Nucleo board. See this blog post: - -http://percepio.com/2017/02/03/usb-trace-streaming-st-nucleo-f767zi-board/ - -However, it should be straight-forward to modify this for other USB stacks. - -To use this stream port, make sure that include/trcStreamingPort.h is found -by the compiler (i.e., add this folder to your project's include paths) and -add all included source files to your build. Make sure no other versions of -trcStreamingPort.h are included by mistake! - -Note that the USB stack not included, but assumed to exist in the project already. - -See also http://percepio.com/2016/10/05/rtos-tracing. - -Percepio AB -www.percepio.com \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/USB_CDC/include/trcStreamingPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/USB_CDC/include/trcStreamingPort.h deleted file mode 100755 index 663e8b2..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/USB_CDC/include/trcStreamingPort.h +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.5 - * Percepio AB, www.percepio.com - * - * trcStreamingPort.h - * - * The interface definitions for trace streaming ("stream ports"). - * This "stream port" sets up the recorder to use USB CDC as streaming channel. - * The example is for STM32 using STM32Cube. - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_STREAMING_PORT_H -#define TRC_STREAMING_PORT_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Include files as needed, in this case it is files from STM32Cube FW_F7 V1.4.1 */ -#include "usb_device.h" -#include "usbd_cdc.h" -#include "usbd_CDC_if.h" -#include "usb_device.h" - -/* Tested on STM32 devices using Keil/CMSIS USB stack */ - -extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS; - -uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len); - -int32_t trcCDCReceive(void *data, uint32_t size, int32_t* NumBytes); - -int32_t trcCDCTransmit(void* data, uint32_t size, int32_t * noOfBytesSent ); - -#define TRC_STREAM_PORT_INIT() \ - MX_USB_DEVICE_Init(); \ - TRC_STREAM_PORT_MALLOC(); /*Dynamic allocation or empty if static */ - -#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) trcCDCReceive(_ptrData, _size, _ptrBytesRead) - -#define TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, _ptrBytesSent) trcCDCTransmit(_ptrData, _size, _ptrBytesSent) - - -#ifdef __cplusplus -} -#endif - -#endif /* TRC_STREAMING_PORT_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/USB_CDC/trcStreamingPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/USB_CDC/trcStreamingPort.c deleted file mode 100755 index 256c59b..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/USB_CDC/trcStreamingPort.c +++ /dev/null @@ -1,246 +0,0 @@ - -#include "trcRecorder.h" - -#if (TRC_USE_TRACEALYZER_RECORDER == 1) -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) - -#include "stdint.h" - -/* Include files as needed, in this case it is files from STM32Cube FW_F7 V1.4.1 */ -#include "usb_device.h" -#include "usbd_cdc.h" -#include "usbd_CDC_if.h" -#include "usb_device.h" - -#define BUFSIZE 64 - -typedef struct{ - uint32_t idx; - uint8_t data[BUFSIZE]; -}recBuf; - -/* Define size for the receive and transmit buffer over CDC */ -#define APP_RX_DATA_SIZE 8 -#define APP_TX_DATA_SIZE 64 - -/* Received Data over USB are stored in this buffer */ -uint8_t UserRxBufferFS[APP_RX_DATA_SIZE]; - -/* Send Data over USB CDC are stored in this buffer */ -uint8_t UserTxBufferFS[APP_TX_DATA_SIZE]; - -extern USBD_HandleTypeDef hUsbDeviceFS; - -extern PCD_HandleTypeDef hpcd_USB_OTG_FS; - -recBuf commandBuffer; - -static int8_t CDC_Init_FS (void); -static int8_t CDC_DeInit_FS (void); -static int8_t CDC_Control_FS (uint8_t cmd, uint8_t* pbuf, uint16_t length); -static int8_t CDC_Receive_FS (uint8_t* pbuf, uint32_t *Len); - -USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = -{ - CDC_Init_FS, - CDC_DeInit_FS, - CDC_Control_FS, - CDC_Receive_FS -}; - -/* Private functions ---------------------------------------------------------*/ -/** - * @brief CDC_Init_FS - * Initializes the CDC media low layer over the FS USB IP - * @param None - * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL - */ -static int8_t CDC_Init_FS(void) -{ - /* Set Application Buffers */ - USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); - USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS); - return (USBD_OK); -} - -/** - * @brief CDC_DeInit_FS - * DeInitializes the CDC media low layer - * @param None - * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL - */ -static int8_t CDC_DeInit_FS(void) -{ - return (USBD_OK); -} - -/** - * @brief CDC_Control_FS - * Manage the CDC class requests - * @param cmd: Command code - * @param pbuf: Buffer containing command data (request parameters) - * @param length: Number of data to be sent (in bytes) - * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL - */ -static int8_t CDC_Control_FS (uint8_t cmd, uint8_t* pbuf, uint16_t length) -{ - switch (cmd) - { - case CDC_SEND_ENCAPSULATED_COMMAND: - break; - - case CDC_GET_ENCAPSULATED_RESPONSE: - break; - - case CDC_SET_COMM_FEATURE: - break; - - case CDC_GET_COMM_FEATURE: - break; - - case CDC_CLEAR_COMM_FEATURE: - break; - - /*******************************************************************************/ - /* Line Coding Structure */ - /*-----------------------------------------------------------------------------*/ - /* Offset | Field | Size | Value | Description */ - /* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/ - /* 4 | bCharFormat | 1 | Number | Stop bits */ - /* 0 - 1 Stop bit */ - /* 1 - 1.5 Stop bits */ - /* 2 - 2 Stop bits */ - /* 5 | bParityType | 1 | Number | Parity */ - /* 0 - None */ - /* 1 - Odd */ - /* 2 - Even */ - /* 3 - Mark */ - /* 4 - Space */ - /* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */ - /*******************************************************************************/ - case CDC_SET_LINE_CODING: - break; - - case CDC_GET_LINE_CODING: - break; - - case CDC_SET_CONTROL_LINE_STATE: - break; - - case CDC_SEND_BREAK: - break; - - default: - break; - } - return (USBD_OK); -} - -/** - * @brief CDC_Receive_FS - * Data received over USB OUT endpoint are sent over CDC interface - * through this function. - * - * @note - * This function will block any OUT packet reception on USB endpoint - * until exiting this function. If you exit this function before transfer - * is complete on CDC interface (i.e. using DMA controller) it will result - * in receiving more data while previous ones are still not sent. - * - * @param Buf: Buffer of data to be received - * @param Len: Number of data received (in bytes) - * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL - */ -static int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len) -{ - for( uint32_t i=0;i<* Len;i++) - { - commandBuffer.data[commandBuffer.idx]=Buf[i]; - commandBuffer.idx++; - } - USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); - USBD_CDC_ReceivePacket(&hUsbDeviceFS); - - return (USBD_OK); -} - -/** - * @brief CDC_Transmit_FS - * Data send over USB IN endpoint are sent over CDC interface - * through this function. - * @note - * - * - * @param Buf: Buffer of data to be send - * @param Len: Number of data to be send (in bytes) - * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY - */ -uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len) -{ - uint8_t result = USBD_OK; - USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; - if (hcdc->TxState != 0){ - return USBD_BUSY; - } - USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); - result = USBD_CDC_TransmitPacket(&hUsbDeviceFS); - return result; -} - -/* The READ function, used in trcStreamingPort.h */ -int32_t trcCDCReceive(void *data, uint32_t size, int32_t* NumBytes) -{ - uint32_t i,diff; - - if(commandBuffer.idx>0) - { - if (size >= commandBuffer.idx) // more than what is stored, number of bytes will be .idx - { - memcpy(data,commandBuffer.data, commandBuffer.idx); - *NumBytes=commandBuffer.idx; - commandBuffer.idx=0; // Make the buffer ready for a new command - } - else //If some data in the buffer is not read - { - diff = commandBuffer.idx-size; - memcpy(data,commandBuffer.data, size); - for(i=0;i v4.1.5 - -- Fixed a bug in the ITM stream port, that required Port 0 to be enabled. -- Added missing include of stdio.h (needed by vTraceConsoleChannelPrintF). -- Moved standard includes from trcRecorder.h into the .c files needing them. - -------------------------------------------------------------------------------- - -Changes, v4.1.2 -> v4.1.4 - -- Fixed a compile error when certain FreeRTOS settings were used -- Disabled filter support for FreeRTOS v7.3 since it uses "char" for object id - -------------------------------------------------------------------------------- - -Changes, v4.1.0 -> v4.1.2 - -- Added vTraceConsoleChannelPrintF(...) - -------------------------------------------------------------------------------- - -Changes, v4.0.3 -> v4.1.0 - -- Improved performance of User Events -- Fixed handling of format strings ending with '%' -- Improved handling of creative user configuration macros - -------------------------------------------------------------------------------- - -Changes, v4.0.2 -> v4.0.3 - -- Minor fix for TCP/IP stream port. -- Corrected default RTT mode setting. - -------------------------------------------------------------------------------- - -Changes, v4.0.1 -> v4.0.2 - -- Memory allocation trace events now ignore filters. - -------------------------------------------------------------------------------- - -Changes, v4.0.0 -> v4.0.1 - -- Minor fixes to default values. - -------------------------------------------------------------------------------- - -Changes, v3.3.0 -> v4.0.0 - -- Fixed some issues with filters. - -------------------------------------------------------------------------------- - -Changes, v3.2.0 -> v3.3.0 - -- Added support for FreeRTOS v10, including the new object types Message Buffer - and Stream Buffer. - -- Improved the object-level filtering to also support Timer, Event Group, - Message Buffer and Stream Buffer objects. - -- Fixed a few remaining build problems with older FreeRTOS versions (v7.x). - -- vTraceStoreISRBegin now reports an error on invalid handles, i.e., if the - initialization of the handle (xTraceSetISRProperties) had not been made. - -------------------------------------------------------------------------------- - -Changes, v3.1.2 -> v3.2.0 - -- Added new filtering system - that works in both snapshot and streaming mode. - Filtering was previously not supported in streaming mode, but can be very - useful for slower streaming interfaces. By exluding irrelevant events, the - amount of data produced can be reduced a lot. - - * New functions vTraceSetFilterGroup and vTraceSetFilterMask allows for - excluding all events from specific objects (like a semaphore or queue). - - * Added new "generic" filters (preprocessor level) to trcConfig.h, that - exclude all events of a particular types. - - TRC_CFG_INCLUDE_NOTIFY_EVENTS - - TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS - - TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS - - TRC_CFG_INCLUDE_TIMER_EVENTS - - * Upgraded some previous filters from "Snapshot only" to the Common API - and thereby moved them from trcSnapshotConfig.h to trcConfig.h. - - TRC_CFG_SCHEDULING_ONLY - - TRC_CFG_INCLUDE_MEMMANG_EVENTS - - TRC_CFG_INCLUDE_USER_EVENTS - - TRC_CFG_INCLUDE_ISR_TRACING - - TRC_CFG_INCLUDE_READY_EVENTS - - TRC_CFG_INCLUDE_OSTICK_EVENTS - - * Removed the old filter system from trcSnapshotRecorder.c. - -- Improved streaming interface - Now only two (2) macros are needed to be - defined in most cases, read and write. This makes it a lot easier to make - custom stream ports. - - * Many definitions that were identical in most stream ports, have been - replaced by default definitions in the recorder core. If needed, they - can be overriden by custom definitions in trcStreamingPort.h. - - * Stream ports are now assumed to use recorder's internal event buffer. - Other stream ports that writes directly to the streaming interface - (like J-Link) should define TRC_STREAM_PORT_USE_INTERNAL_BUFFER - as zero (0) to make it work correctly. - - * Macro TRC_STREAM_PORT_PERIODIC_SEND_DATA has been replaced by - TRC_STREAM_PORT_WRITE_DATA. Together with TRC_STREAM_PORT_READ_DATA, - this is all that is necessary for a typical stream port. - - * Return values from the stream port macros READ_DATA and WRITE_DATA are - now checked. Expects 0 on success, anything else produces a warning - that can be retrived using xTraceGetLastError() and also seen in - Tracealyzer if a trace was produced. - - * Stream ports should no longer call prvPagedEventBufferInit explicitly - (e.g. in TRC_STREAM_PORT_ON_TRACE_BEGIN). This is now called - automatically if TRC_STREAM_PORT_USE_INTERNAL_BUFFER == 1. - - * Macros TRC_STREAM_PORT_ON_TRACE_BEGIN and TRC_STREAM_PORT_ON_TRACE_END - are now unused by default and don't need to be defined. - You can however use them to hook in some own function at these events. - -- Added two new stream ports - - * TCPIP-Win32: allows for testing the streaming on Windows ports of your - RTOS, using Winsock. - - * File: example of streaming to a local file system (tested on Windows, - but easy to modify). - -- Added support for FreeRTOS v9.0.1 - - * Replaced FreeRTOS version code TRC_FREERTOS_VERSION_9_X with - - TRC_FREERTOS_VERSION_9_0_0 - - TRC_FREERTOS_VERSION_9_0_1 - - * Using TRC_FREERTOS_VERSION_9_X is no longer allowed. - -- Added additional events for xQueuePeek, for blocking and timeouts events. - -- Added event for traceTIMER_EXPIRED, showing when the timer callback - function is called. - -- Improved diagnostics in streaming mode, in case of errors in the recorder. - - * Added prvTraceWarning() - registers a "warning" error code, without - stopping the recorder. Called if READ_DATA or WRITE_DATA returns a - non-zero value, and in several other cases where the recorder - configuration is incorrect (e.g., too small symbol table). - - * Added several new warning codes (PSF_WARNING_XYZ), corresponding to the - issues detected by prvCheckRecorderStatus. - - * Fixed duplicate definitions of warning messages, so the warnings reported - to Tracealyzer are the same as those provided in xTraceGetLastError(). - - * Added better explainations of warning/error messages in the body of - xTraceGetLastError (in streaming mode). - -- Added xTraceIsRecordingEnabled() to Common API. - -- Added "unofficial" hardware port for Altera Nios-II. - This is a user contribition, not yet verified by Percerpio. - -- Fixed bug in vTraceEnable - option TRC_START_AWAIT_HOST was ignored if already initialized. - -- Fixed a few remaining compiler warnings. - -- Changed order of some settings in trcConfig.h - moved advanced stuff to the - bottom. - -- Removed SEGGER_RTT_Printf.c from the J-Link stream port since not required - for Tracealyzer. - -------------------------------------------------------------------------------- - -Changes, v3.1.1 -> v3.1.2 -- Fixed two bugs related to User Events, one in vTracePrintF and other in vTracePrint. - -- Fixed a build problem related to a single reference of the old FreeRTOS type "xTaskHandle", in trcKernelPort.c. - Changed to "TaskHandle_t", unless if using an older FreeRTOS kernel or the "compatibility mode". - -- Removed traceCREATE_MUTEX hook for FreeRTOS v9 or later (no longer required) - -- Updated the User Manual regarding snapshot trace via IAR Embedded Workbench. - -- Renamed vTraceGetTraceBuffer to xTraceGetTraceBuffer, since returning a pointer. - -------------------------------------------------------------------------------- - -Changes, v3.1.0 -> v3.1.1 - -After the major changes in the v3.1.0 trace recorder library, this update -corrects a number of minor issues. Only minor functional improvements. - -- You can now use TRC_ALLOC_CUSTOM_BUFFER to declare a trace buffer on a custom - location (using linker directives). - The related function vTraceSetRecorderDataBuffer has been promoted to the - Common API (previously only supported in snapshot mode, but custom allocation - is now generally supported also in streaming mode). - -- Removed TRC_CFG_USE_LINKER_PRAGMA. No longer necessary thanks to the custom - allocation mode. - -- Added support for timestamping from custom periodic timers, required for - accurate timestamping on Cortex-M0/M0+ devices when using tickless idle. - Only for streaming mode so far. See TRC_CUSTOM_TIMER_INCR / DECR. - -- ARM Cortex-M port: Made sure the DWT unit is initialized properly, in case - the debugger doesn't handle this. - -- ARM Cortex-M port: Added possibility to use Systick timestamping also on - Cortex-M3/M4/M7 devices (that otherwise use DWT timestamping by default). - To use this option, define the macro TRC_CFG_ARM_CM_USE_SYSTICK. - -- J-Link streaming: The default RTT buffer has been changed from 0 to 1. - -- J-Link streaming: The RTT buffer settings for buffer 1 and higher, are now - found in trcStreamingPort.h. Note: These settings don't apply to buffer 0. - -- vTracePrint has been optimized for better performance in string logging. - -- Minor performance improvement related to symbol table transfer in streaming mode. - -- Timer names now registered also in streaming mode. - -- Timer start and stop event are now traced. - -- Implemented support for queue registry (traceQUEUE_REGISTRY_ADD) also for streaming. - -- Fixed a bug related to repeated calls of vTraceEnable. - -- Fixed a bug where task-switches seemed to occur even though the scheduler was disabled. - -- Renamed HARDWARE_PORT_TEXAS_INSTRUMENTS_TMS570_RM48, added prefix TRC. - -- Fixed several language issues in the comments and documentation. - -- Fixed several minor issues and warnings from different compilers - (including PowerPC/gcc) and configurations. - -------------------------------------------------------------------------------- - -Changes, v3.0.9 -> v3.1.0 - -- Merge of previously separated snapshot and streaming recorders into a single - recorder supporting both streaming and snapshot as different modes. - -- New common API for supporting both streaming and snapshot modes. - -- New integration guide, see the User Manual. - -- Major improvement of API documentation in source files and User Manual. - -- New concept of "stream ports", giving a better structure defining streaming - interfaces, and restructured the J-Link and TCP/IP streaming as stream ports. - -- Added a stream port for USB CDC connections, with STM32 as example. - Since Tracealyzer now can receive serial data on Windows COM ports, this is - really easy to use. - -- Added a warning (#error) for cases where FreeRTOS tickless idle mode is used - together with timestamping using SysTick or other periodic interrupt timers, - Tracing with tickless idle requires an independent time source to correctly - capture the length of the idle periods. - -- Major changes in the recorder API. Important examples are: - - * Some configuration macros have changed names, e.g. for "hardware port". - Make sure to remove any old "trcConfig.h" files if upgrading from an - earlier version! - - * Recorder configuration in trcConfig.h has been minimized and now only - includes the important settings that are independent of recorder mode. - Advanced settings for each mode are found in trcSnapshotConfig.h and - trcStreamingConfig.h. - - * vTraceEnable replaces Trace_Init and vTraceInitTraceData, as well as - vTraceStart and uiTraceStart. - - * vTraceStop now part of the common API and thereby available also in - streaming. And since vTraceEnable can start the streaming directly - you have the option control the tracing from target, e.g., for - streaming to a device file system. - - * vTraceStoreKernelObjectName from old streaming recorder has been replaced - by vTraceSetQueueName, vTraceSetSemaphoreName, etc. - - * vTraceSetISRProperties now returns a "traceHandle" that should be passed as - parameter to vTraceStoreISRBegin and vTraceStoreISREnd. - - * xTraceRegisterString has replaced the old functions xTraceOpenLabel and - vTraceStoreUserEventChannelName. This now returns a "traceString" for use - as "channel" parameter in vTracePrintF, and in other places where strings - are stored. - - * Removed vTraceStoreISREndManual and vTraceStoreISREndAuto, use - vTraceStoreISREnd instead. - - * Renamed the functions for saving User Events in a separate buffer: - - xTraceRegisterChannelFormat -> xTraceRegisterUBChannel - - vTraceChannelPrintF -> vTraceUBData - - vTraceChannelUserEvent -> vTraceUBEvent - - -------------------------------------------------------------------------------- -Copyright Percepio AB, 2018. \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c deleted file mode 100755 index a2b3140..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c +++ /dev/null @@ -1,833 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.5 - * Percepio AB, www.percepio.com - * - * trcKernelPort.c - * - * The FreeRTOS-specific parts of the trace recorder - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#include "FreeRTOS.h" - -#if (!defined(TRC_USE_TRACEALYZER_RECORDER) && configUSE_TRACE_FACILITY == 1) -#error Trace Recorder: You need to include trcRecorder.h at the end of your FreeRTOSConfig.h! -#endif - -#if (defined(TRC_USE_TRACEALYZER_RECORDER) && TRC_USE_TRACEALYZER_RECORDER == 1) - -#ifndef TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS - /* TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS is missing in trcConfig.h. */ -#error "TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS must be defined in trcConfig.h." -#endif - -#ifndef TRC_CFG_INCLUDE_TIMER_EVENTS - /* TRC_CFG_INCLUDE_TIMER_EVENTS is missing in trcConfig.h. */ -#error "TRC_CFG_INCLUDE_TIMER_EVENTS must be defined in trcConfig.h." -#endif - -#ifndef TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS - /* TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS is missing in trcConfig.h. */ -#error "TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS must be defined in trcConfig.h." -#endif - -#ifndef TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS - /* TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS is missing in trcConfig.h. Define this as 1 if using FreeRTOS v10 or later and like to trace stream buffer or message buffer events, otherwise 0. */ -#error "TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS must be defined in trcConfig.h." -#endif - -#if (configUSE_TICKLESS_IDLE != 0 && (TRC_HWTC_TYPE == TRC_OS_TIMER_INCR || TRC_HWTC_TYPE == TRC_OS_TIMER_DECR)) - /* - The below error message is to alert you on the following issue: - - The hardware port selected in trcConfig.h uses the operating system timer for the - timestamping, i.e., the periodic interrupt timer that drives the OS tick interrupt. - - When using "tickless idle" mode, the recorder needs an independent time source in - order to correctly record the durations of the idle times. Otherwise, the trace may appear - to have a different length than in reality, and the reported CPU load is also affected. - - You may override this warning by defining the TRC_CFG_ACKNOWLEDGE_TICKLESS_IDLE_WARNING - macro in your trcConfig.h file. But then the time scale may be incorrect during - tickless idle periods. - - To get this correct, override the default timestamping by setting TRC_CFG_HARDWARE_PORT - in trcConfig.h to TRC_HARDWARE_PORT_APPLICATION_DEFINED and define the HWTC macros - accordingly, using a free running counter or an independent periodic interrupt timer. - See trcHardwarePort.h for details. - - For ARM Cortex-M3, M4 and M7 MCUs this is not an issue, since the recorder uses the - DWT cycle counter for timestamping in these cases. - */ - - #ifndef TRC_CFG_ACKNOWLEDGE_TICKLESS_IDLE_WARNING - #error Trace Recorder: This timestamping mode is not recommended with Tickless Idle. - #endif -#endif /* (configUSE_TICKLESS_IDLE != 0 && (TRC_HWTC_TYPE == TRC_OS_TIMER_INCR || TRC_HWTC_TYPE == TRC_OS_TIMER_DECR)) */ - -#include "task.h" -#include "queue.h" - -#if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) -/* If the project does not include the FreeRTOS timers, TRC_CFG_INCLUDE_TIMER_EVENTS must be set to 0 */ -#include "timers.h" -#endif /* (TRC_CFG_INCLUDE_TIMER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) */ - -#if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) -/* If the project does not include the FreeRTOS event groups, TRC_CFG_INCLUDE_TIMER_EVENTS must be set to 0 */ -#include "event_groups.h" -#endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) */ - -#if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) -/* If the project does not include the FreeRTOS stream buffers, TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS must be set to 0 */ -#include "stream_buffer.h" -#endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ - -uint32_t prvTraceGetQueueNumber(void* handle); - -#if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_8_X) - -extern unsigned char ucQueueGetQueueNumber( xQueueHandle pxQueue ); -extern void vQueueSetQueueNumber( xQueueHandle pxQueue, unsigned char ucQueueNumber ); -extern unsigned char ucQueueGetQueueType( xQueueHandle pxQueue ); - -uint32_t prvTraceGetQueueNumber(void* handle) -{ - return (uint32_t)ucQueueGetQueueNumber(handle); -} -#else -uint32_t prvTraceGetQueueNumber(void* handle) -{ - return (uint32_t)uxQueueGetQueueNumber(handle); -} -#endif /* (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_8_X) */ - -uint8_t prvTraceGetQueueType(void* handle) -{ - // This is either declared in header file in FreeRTOS 8 and later, or as extern above - return ucQueueGetQueueType(handle); -} - -/* Tasks */ -uint16_t prvTraceGetTaskNumberLow16(void* handle) -{ - return TRACE_GET_LOW16(uxTaskGetTaskNumber(handle)); -} - -uint16_t prvTraceGetTaskNumberHigh16(void* handle) -{ - return TRACE_GET_HIGH16(uxTaskGetTaskNumber(handle)); -} - -void prvTraceSetTaskNumberLow16(void* handle, uint16_t value) -{ - vTaskSetTaskNumber(handle, TRACE_SET_LOW16(uxTaskGetTaskNumber(handle), value)); -} - -void prvTraceSetTaskNumberHigh16(void* handle, uint16_t value) -{ - vTaskSetTaskNumber(handle, TRACE_SET_HIGH16(uxTaskGetTaskNumber(handle), value)); -} - -uint16_t prvTraceGetQueueNumberLow16(void* handle) -{ - return TRACE_GET_LOW16(prvTraceGetQueueNumber(handle)); -} - -uint16_t prvTraceGetQueueNumberHigh16(void* handle) -{ - return TRACE_GET_HIGH16(prvTraceGetQueueNumber(handle)); -} - -void prvTraceSetQueueNumberLow16(void* handle, uint16_t value) -{ - vQueueSetQueueNumber(handle, TRACE_SET_LOW16(prvTraceGetQueueNumber(handle), value)); -} - -void prvTraceSetQueueNumberHigh16(void* handle, uint16_t value) -{ - vQueueSetQueueNumber(handle, TRACE_SET_HIGH16(prvTraceGetQueueNumber(handle), value)); -} - -#if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) - -uint16_t prvTraceGetTimerNumberLow16(void* handle) -{ - return TRACE_GET_LOW16(uxTimerGetTimerNumber(handle)); -} - -uint16_t prvTraceGetTimerNumberHigh16(void* handle) -{ - return TRACE_GET_HIGH16(uxTimerGetTimerNumber(handle)); -} - -void prvTraceSetTimerNumberLow16(void* handle, uint16_t value) -{ - vTimerSetTimerNumber(handle, TRACE_SET_LOW16(uxTimerGetTimerNumber(handle), value)); -} - -void prvTraceSetTimerNumberHigh16(void* handle, uint16_t value) -{ - vTimerSetTimerNumber(handle, TRACE_SET_HIGH16(uxTimerGetTimerNumber(handle), value)); -} -#endif /* (TRC_CFG_INCLUDE_TIMER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ - -#if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) - -uint16_t prvTraceGetEventGroupNumberLow16(void* handle) -{ - return TRACE_GET_LOW16(uxEventGroupGetNumber(handle)); -} - -uint16_t prvTraceGetEventGroupNumberHigh16(void* handle) -{ - return TRACE_GET_HIGH16(uxEventGroupGetNumber(handle)); -} - -void prvTraceSetEventGroupNumberLow16(void* handle, uint16_t value) -{ - vEventGroupSetNumber(handle, TRACE_SET_LOW16(uxEventGroupGetNumber(handle), value)); -} - -void prvTraceSetEventGroupNumberHigh16(void* handle, uint16_t value) -{ - vEventGroupSetNumber(handle, TRACE_SET_HIGH16(uxEventGroupGetNumber(handle), value)); -} -#endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ - -#if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) - -uint16_t prvTraceGetStreamBufferNumberLow16(void* handle) -{ - return TRACE_GET_LOW16(uxStreamBufferGetStreamBufferNumber(handle)); -} - -uint16_t prvTraceGetStreamBufferNumberHigh16(void* handle) -{ - return TRACE_GET_HIGH16(uxStreamBufferGetStreamBufferNumber(handle)); -} - -void prvTraceSetStreamBufferNumberLow16(void* handle, uint16_t value) -{ - vStreamBufferSetStreamBufferNumber(handle, TRACE_SET_LOW16(uxStreamBufferGetStreamBufferNumber(handle), value)); -} - -void prvTraceSetStreamBufferNumberHigh16(void* handle, uint16_t value) -{ - vStreamBufferSetStreamBufferNumber(handle, TRACE_SET_HIGH16(uxStreamBufferGetStreamBufferNumber(handle), value)); -} -#endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ - -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) - -static void* pCurrentTCB = NULL; -#if (defined(configENABLE_BACKWARD_COMPATIBILITY) && configENABLE_BACKWARD_COMPATIBILITY == 0) -/* We're explicitly not using compatibility mode */ -static TaskHandle_t HandleTzCtrl = NULL; /* TzCtrl task TCB */ -#else -/* We're using compatibility mode, or we're running an old kernel */ -static xTaskHandle HandleTzCtrl = NULL; /* TzCtrl task TCB */ -#endif - -#if defined(configSUPPORT_STATIC_ALLOCATION) -#if (configSUPPORT_STATIC_ALLOCATION == 1) -static StackType_t stackTzCtrl[TRC_CFG_CTRL_TASK_STACK_SIZE]; -static StaticTask_t tcbTzCtrl; -#endif -#endif - -/* Monitored by TzCtrl task, that give warnings as User Events */ -extern volatile uint32_t NoRoomForSymbol; -extern volatile uint32_t NoRoomForObjectData; -extern volatile uint32_t LongestSymbolName; -extern volatile uint32_t MaxBytesTruncated; - -/* Keeps track of previous values, to only react on changes. */ -static uint32_t NoRoomForSymbol_last = 0; -static uint32_t NoRoomForObjectData_last = 0; -static uint32_t LongestSymbolName_last = 0; -static uint32_t MaxBytesTruncated_last = 0; - -/* User Event Channel for giving warnings regarding NoRoomForSymbol etc. */ -traceString trcWarningChannel; - -#define TRC_PORT_MALLOC(size) pvPortMalloc(size) - -TRC_STREAM_PORT_ALLOCATE_FIELDS() - -/* Called by TzCtrl task periodically (Normally every 100 ms) */ -static void prvCheckRecorderStatus(void); - -extern void prvTraceWarning(int errCode); - -/* The TzCtrl task - receives commands from Tracealyzer (start/stop) */ -static portTASK_FUNCTION( TzCtrl, pvParameters ); - -/******************************************************************************* - * vTraceEnable - * - * Function that enables the tracing and creates the control task. It will halt - * execution until a Start command has been received if haltUntilStart is true. - * - ******************************************************************************/ -void vTraceEnable(int startOption) -{ - int32_t bytes = 0; - int32_t status; - extern uint32_t RecorderEnabled; - TracealyzerCommandType msg; - - /* Only do this first time...*/ - if (HandleTzCtrl == NULL) - { - TRC_STREAM_PORT_INIT(); - - /* Note: Requires that TRC_CFG_INCLUDE_USER_EVENTS is 1. */ - trcWarningChannel = xTraceRegisterString("Warnings from Recorder"); - - /* Creates the TzCtrl task - receives trace commands (start, stop, ...) */ - #if defined(configSUPPORT_STATIC_ALLOCATION) && (configSUPPORT_STATIC_ALLOCATION == 1) - HandleTzCtrl = xTaskCreateStatic(TzCtrl, STRING_CAST("TzCtrl"), TRC_CFG_CTRL_TASK_STACK_SIZE, NULL, TRC_CFG_CTRL_TASK_PRIORITY, stackTzCtrl, &tcbTzCtrl); - #else - xTaskCreate( TzCtrl, STRING_CAST("TzCtrl"), TRC_CFG_CTRL_TASK_STACK_SIZE, NULL, TRC_CFG_CTRL_TASK_PRIORITY, &HandleTzCtrl ); - #endif - - if (HandleTzCtrl == NULL) - { - prvTraceError(PSF_ERROR_TZCTRLTASK_NOT_CREATED); - } - } - - if (startOption == TRC_START_AWAIT_HOST) - { - /* We keep trying to read commands until the recorder has been started */ - do - { - bytes = 0; - - status = TRC_STREAM_PORT_READ_DATA(&msg, sizeof(TracealyzerCommandType), (int32_t*)&bytes); - - if (status != 0) - { - prvTraceWarning(PSF_WARNING_STREAM_PORT_READ); - } - - if ((status == 0) && (bytes == sizeof(TracealyzerCommandType))) - { - if (prvIsValidCommand(&msg)) - { - if (msg.cmdCode == CMD_SET_ACTIVE && msg.param1 == 1) - { - /* On start, init and reset the timestamping */ - TRC_PORT_SPECIFIC_INIT(); - } - - prvProcessCommand(&msg); - } - } - } - while (RecorderEnabled == 0); - } - else if (startOption == TRC_START) - { - /* We start streaming directly - this assumes that the interface is ready! */ - TRC_PORT_SPECIFIC_INIT(); - - msg.cmdCode = CMD_SET_ACTIVE; - msg.param1 = 1; - prvProcessCommand(&msg); - } - else - { - /* On TRC_INIT */ - TRC_PORT_SPECIFIC_INIT(); - } -} - -#if (TRC_CFG_SCHEDULING_ONLY == 0) -/******************************************************************************* - * vTraceSetQueueName(void* object, const char* name) - * - * Parameter object: pointer to the Queue that shall be named - * Parameter name: the name to set (const string literal) - * - * Sets a name for Queue objects for display in Tracealyzer. - ******************************************************************************/ -void vTraceSetQueueName(void* object, const char* name) -{ - vTraceStoreKernelObjectName(object, name); -} - -/******************************************************************************* - * vTraceSetSemaphoreName(void* object, const char* name) - * - * Parameter object: pointer to the Semaphore that shall be named - * Parameter name: the name to set (const string literal) - * - * Sets a name for Semaphore objects for display in Tracealyzer. - ******************************************************************************/ -void vTraceSetSemaphoreName(void* object, const char* name) -{ - vTraceStoreKernelObjectName(object, name); -} - -/******************************************************************************* - * vTraceSetMutexName(void* object, const char* name) - * - * Parameter object: pointer to the Mutex that shall be named - * Parameter name: the name to set (const string literal) - * - * Sets a name for Mutex objects for display in Tracealyzer. - ******************************************************************************/ -void vTraceSetMutexName(void* object, const char* name) -{ - vTraceStoreKernelObjectName(object, name); -} - -#if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) -/******************************************************************************* -* vTraceSetEventGroupName(void* object, const char* name) -* -* Parameter object: pointer to the vTraceSetEventGroupName that shall be named -* Parameter name: the name to set (const string literal) -* -* Sets a name for EventGroup objects for display in Tracealyzer. -******************************************************************************/ -void vTraceSetEventGroupName(void* object, const char* name) -{ - vTraceStoreKernelObjectName(object, name); -} -#endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) */ - -#if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) -/******************************************************************************* -* vTraceSetStreamBufferName(void* object, const char* name) -* -* Parameter object: pointer to the StreamBuffer that shall be named -* Parameter name: the name to set (const string literal) -* -* Sets a name for StreamBuffer objects for display in Tracealyzer. -******************************************************************************/ -void vTraceSetStreamBufferName(void* object, const char* name) -{ - vTraceStoreKernelObjectName(object, name); -} - -/******************************************************************************* -* vTraceSetMessageBufferName(void* object, const char* name) -* -* Parameter object: pointer to the MessageBuffer that shall be named -* Parameter name: the name to set (const string literal) -* -* Sets a name for MessageBuffer objects for display in Tracealyzer. -******************************************************************************/ -void vTraceSetMessageBufferName(void* object, const char* name) -{ - vTraceStoreKernelObjectName(object, name); -} -#endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ - -#endif /* (TRC_CFG_SCHEDULING_ONLY == 0) */ - -/******************************************************************************* - * prvGetCurrentTaskHandle - * - * Function that returns the handle to the currently executing task. - * - ******************************************************************************/ -void* prvTraceGetCurrentTaskHandle(void) -{ - return xTaskGetCurrentTaskHandle(); -} - -/******************************************************************************* - * prvIsNewTCB - * - * Tells if this task is already executing, or if there has been a task-switch. - * Assumed to be called within a trace hook in kernel context. - ******************************************************************************/ -uint32_t prvIsNewTCB(void* pNewTCB) -{ - if (pCurrentTCB != pNewTCB) - { - pCurrentTCB = pNewTCB; - return 1; - } - return 0; -} - -/******************************************************************************* - * prvTraceIsSchedulerSuspended - * - * Returns true if the RTOS scheduler currently is disabled, thus preventing any - * task-switches from occurring. Only called from vTraceStoreISREnd. - ******************************************************************************/ -unsigned char prvTraceIsSchedulerSuspended(void) -{ - /* Assumed to be available in FreeRTOS. According to the FreeRTOS docs, - INCLUDE_xTaskGetSchedulerState or configUSE_TIMERS must be set to 1 in - FreeRTOSConfig.h for this function to be available. */ - - return xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED; -} - - -/******************************************************************************* - * prvCheckRecorderStatus - * - * Called by TzCtrl task periodically (every 100 ms - seems reasonable). - * Checks a number of diagnostic variables and give warnings as user events, - * in most cases including a suggested solution. - ******************************************************************************/ -static void prvCheckRecorderStatus(void) -{ - if (NoRoomForSymbol > NoRoomForSymbol_last) - { - if (NoRoomForSymbol > 0) - { - prvTraceWarning(PSF_WARNING_SYMBOL_TABLE_SLOTS); - } - NoRoomForSymbol_last = NoRoomForSymbol; - } - - if (NoRoomForObjectData > NoRoomForObjectData_last) - { - if (NoRoomForObjectData > 0) - { - prvTraceWarning(PSF_WARNING_OBJECT_DATA_SLOTS); - } - NoRoomForObjectData_last = NoRoomForObjectData; - } - - if (LongestSymbolName > LongestSymbolName_last) - { - if (LongestSymbolName > (TRC_CFG_SYMBOL_MAX_LENGTH)) - { - prvTraceWarning(PSF_WARNING_SYMBOL_MAX_LENGTH); - } - LongestSymbolName_last = LongestSymbolName; - } - - if (MaxBytesTruncated > MaxBytesTruncated_last) - { - if (MaxBytesTruncated > 0) - { - prvTraceWarning(PSF_WARNING_STRING_TOO_LONG); - } - MaxBytesTruncated_last = MaxBytesTruncated; - } -} - -/******************************************************************************* - * TzCtrl - * - * Task for sending the trace data from the internal buffer to the stream - * interface (assuming TRC_STREAM_PORT_USE_INTERNAL_BUFFER == 1) and for - * receiving commands from Tracealyzer. Also does some diagnostics. - ******************************************************************************/ -static portTASK_FUNCTION( TzCtrl, pvParameters ) -{ - TracealyzerCommandType msg; - int32_t bytes = 0; - int32_t status = 0; - (void)pvParameters; - - while (1) - { - do - { - /* Listen for new commands */ - bytes = 0; - status = TRC_STREAM_PORT_READ_DATA(&msg, sizeof(TracealyzerCommandType), (int32_t*)&bytes); - - if (status != 0) - { - prvTraceWarning(PSF_WARNING_STREAM_PORT_READ); - } - - if ((status == 0) && (bytes == sizeof(TracealyzerCommandType))) - { - if (prvIsValidCommand(&msg)) - { - prvProcessCommand(&msg); /* Start or Stop currently... */ - } - } - -/* If the internal buffer is disabled, the COMMIT macro instead sends the data directly - from the "event functions" (using TRC_STREAM_PORT_WRITE_DATA). */ -#if (TRC_STREAM_PORT_USE_INTERNAL_BUFFER == 1) - /* If there is a buffer page, this sends it to the streaming interface using TRC_STREAM_PORT_WRITE_DATA. */ - bytes = prvPagedEventBufferTransfer(); -#endif - - /* If there was data sent or received (bytes != 0), loop around and repeat, if there is more data to send or receive. - Otherwise, step out of this loop and sleep for a while. */ - - } while (bytes != 0); - - prvCheckRecorderStatus(); - - vTaskDelay(TRC_CFG_CTRL_TASK_DELAY); - } -} - -#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/ - - -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) - -/* Internal flag to tell the context of tracePEND_FUNC_CALL_FROM_ISR */ -int uiInEventGroupSetBitsFromISR = 0; - -/****************************************************************************** - * TraceQueueClassTable - * Translates a FreeRTOS QueueType into trace objects classes (TRACE_CLASS_). - * Has one entry for each QueueType, gives TRACE_CLASS ID. - ******************************************************************************/ -traceObjectClass TraceQueueClassTable[5] = { - TRACE_CLASS_QUEUE, - TRACE_CLASS_MUTEX, - TRACE_CLASS_SEMAPHORE, - TRACE_CLASS_SEMAPHORE, - TRACE_CLASS_MUTEX -}; - -#if (TRC_CFG_SCHEDULING_ONLY == 0) -/******************************************************************************* - * vTraceSetQueueName(void* object, const char* name) - * - * Parameter object: pointer to the Queue that shall be named - * Parameter name: the name to set (const string literal) - * - * Sets a name for Queue objects for display in Tracealyzer. - ******************************************************************************/ -void vTraceSetQueueName(void* object, const char* name) -{ - prvTraceSetObjectName(TRACE_CLASS_QUEUE, TRACE_GET_OBJECT_NUMBER(QUEUE, object), name); -} - -/******************************************************************************* - * vTraceSetSemaphoreName(void* object, const char* name) - * - * Parameter object: pointer to the Semaphore that shall be named - * Parameter name: the name to set (const string literal) - * - * Sets a name for Semaphore objects for display in Tracealyzer. - ******************************************************************************/ -void vTraceSetSemaphoreName(void* object, const char* name) -{ - prvTraceSetObjectName(TRACE_CLASS_SEMAPHORE, TRACE_GET_OBJECT_NUMBER(QUEUE, object), name); -} - -/******************************************************************************* - * vTraceSetMutexName(void* object, const char* name) - * - * Parameter object: pointer to the Mutex that shall be named - * Parameter name: the name to set (const string literal) - * - * Sets a name for Semaphore objects for display in Tracealyzer. - ******************************************************************************/ -void vTraceSetMutexName(void* object, const char* name) -{ - prvTraceSetObjectName(TRACE_CLASS_MUTEX, TRACE_GET_OBJECT_NUMBER(QUEUE, object), name); -} - -#if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) -/******************************************************************************* -* vTraceSetEventGroupName(void* object, const char* name) -* -* Parameter object: pointer to the EventGroup that shall be named -* Parameter name: the name to set (const string literal) -* -* Sets a name for EventGroup objects for display in Tracealyzer. -******************************************************************************/ -void vTraceSetEventGroupName(void* object, const char* name) -{ - prvTraceSetObjectName(TRACE_CLASS_EVENTGROUP, TRACE_GET_OBJECT_NUMBER(EVENTGROUP, object), name); -} -#endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) */ - -#if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) -/******************************************************************************* -* vTraceSetStreamBufferName(void* object, const char* name) -* -* Parameter object: pointer to the StreamBuffer that shall be named -* Parameter name: the name to set (const string literal) -* -* Sets a name for StreamBuffer objects for display in Tracealyzer. -******************************************************************************/ -void vTraceSetStreamBufferName(void* object, const char* name) -{ - prvTraceSetObjectName(TRACE_CLASS_STREAMBUFFER, TRACE_GET_OBJECT_NUMBER(STREAMBUFFER, object), name); -} - -/******************************************************************************* -* vTraceSetMessageBufferName(void* object, const char* name) -* -* Parameter object: pointer to the MessageBuffer that shall be named -* Parameter name: the name to set (const string literal) -* -* Sets a name for MessageBuffer objects for display in Tracealyzer. -******************************************************************************/ -void vTraceSetMessageBufferName(void* object, const char* name) -{ - prvTraceSetObjectName(TRACE_CLASS_MESSAGEBUFFER, TRACE_GET_OBJECT_NUMBER(STREAMBUFFER, object), name); -} -#endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */ - -#endif /* (TRC_CFG_SCHEDULING_ONLY == 0) */ - -void* prvTraceGetCurrentTaskHandle() -{ - return xTaskGetCurrentTaskHandle(); -} - -/* Initialization of the object property table */ -void vTraceInitObjectPropertyTable() -{ - RecorderDataPtr->ObjectPropertyTable.NumberOfObjectClasses = TRACE_NCLASSES; - RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[0] = TRC_CFG_NQUEUE; - RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[1] = TRC_CFG_NSEMAPHORE; - RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[2] = TRC_CFG_NMUTEX; - RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[3] = TRC_CFG_NTASK; - RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[4] = TRC_CFG_NISR; - RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[5] = TRC_CFG_NTIMER; - RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[6] = TRC_CFG_NEVENTGROUP; - RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[7] = TRC_CFG_NSTREAMBUFFER; - RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[8] = TRC_CFG_NMESSAGEBUFFER; - RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[0] = TRC_CFG_NAME_LEN_QUEUE; - RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[1] = TRC_CFG_NAME_LEN_SEMAPHORE; - RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[2] = TRC_CFG_NAME_LEN_MUTEX; - RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[3] = TRC_CFG_NAME_LEN_TASK; - RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[4] = TRC_CFG_NAME_LEN_ISR; - RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[5] = TRC_CFG_NAME_LEN_TIMER; - RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[6] = TRC_CFG_NAME_LEN_EVENTGROUP; - RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[7] = TRC_CFG_NAME_LEN_STREAMBUFFER; - RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[8] = TRC_CFG_NAME_LEN_MESSAGEBUFFER; - RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[0] = PropertyTableSizeQueue; - RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[1] = PropertyTableSizeSemaphore; - RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[2] = PropertyTableSizeMutex; - RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[3] = PropertyTableSizeTask; - RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[4] = PropertyTableSizeISR; - RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[5] = PropertyTableSizeTimer; - RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[6] = PropertyTableSizeEventGroup; - RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[7] = PropertyTableSizeStreamBuffer; - RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[8] = PropertyTableSizeMessageBuffer; - RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[0] = StartIndexQueue; - RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[1] = StartIndexSemaphore; - RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[2] = StartIndexMutex; - RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[3] = StartIndexTask; - RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[4] = StartIndexISR; - RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[5] = StartIndexTimer; - RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[6] = StartIndexEventGroup; - RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[7] = StartIndexStreamBuffer; - RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[8] = StartIndexMessageBuffer; - RecorderDataPtr->ObjectPropertyTable.ObjectPropertyTableSizeInBytes = TRACE_OBJECT_TABLE_SIZE; -} - -/* Initialization of the handle mechanism, see e.g, prvTraceGetObjectHandle */ -void vTraceInitObjectHandleStack() -{ - objectHandleStacks.indexOfNextAvailableHandle[0] = objectHandleStacks.lowestIndexOfClass[0] = 0; - objectHandleStacks.indexOfNextAvailableHandle[1] = objectHandleStacks.lowestIndexOfClass[1] = (TRC_CFG_NQUEUE); - objectHandleStacks.indexOfNextAvailableHandle[2] = objectHandleStacks.lowestIndexOfClass[2] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE); - objectHandleStacks.indexOfNextAvailableHandle[3] = objectHandleStacks.lowestIndexOfClass[3] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX); - objectHandleStacks.indexOfNextAvailableHandle[4] = objectHandleStacks.lowestIndexOfClass[4] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK); - objectHandleStacks.indexOfNextAvailableHandle[5] = objectHandleStacks.lowestIndexOfClass[5] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR); - objectHandleStacks.indexOfNextAvailableHandle[6] = objectHandleStacks.lowestIndexOfClass[6] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER); - objectHandleStacks.indexOfNextAvailableHandle[7] = objectHandleStacks.lowestIndexOfClass[7] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER) + (TRC_CFG_NEVENTGROUP); - objectHandleStacks.indexOfNextAvailableHandle[8] = objectHandleStacks.lowestIndexOfClass[8] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER) + (TRC_CFG_NEVENTGROUP) + (TRC_CFG_NSTREAMBUFFER); - - objectHandleStacks.highestIndexOfClass[0] = (TRC_CFG_NQUEUE) - 1; - objectHandleStacks.highestIndexOfClass[1] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) - 1; - objectHandleStacks.highestIndexOfClass[2] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) - 1; - objectHandleStacks.highestIndexOfClass[3] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) - 1; - objectHandleStacks.highestIndexOfClass[4] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) - 1; - objectHandleStacks.highestIndexOfClass[5] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER) - 1; - objectHandleStacks.highestIndexOfClass[6] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER) + (TRC_CFG_NEVENTGROUP) - 1; - objectHandleStacks.highestIndexOfClass[7] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER) + (TRC_CFG_NEVENTGROUP) + (TRC_CFG_NSTREAMBUFFER) - 1; - objectHandleStacks.highestIndexOfClass[8] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER) + (TRC_CFG_NEVENTGROUP) + (TRC_CFG_NSTREAMBUFFER) + (TRC_CFG_NMESSAGEBUFFER) - 1; -} - -/* Returns the "Not enough handles" error message for this object class */ -const char* pszTraceGetErrorNotEnoughHandles(traceObjectClass objectclass) -{ - switch(objectclass) - { - case TRACE_CLASS_TASK: - return "Not enough TASK handles - increase TRC_CFG_NTASK in trcSnapshotConfig.h"; - case TRACE_CLASS_ISR: - return "Not enough ISR handles - increase TRC_CFG_NISR in trcSnapshotConfig.h"; - case TRACE_CLASS_SEMAPHORE: - return "Not enough SEMAPHORE handles - increase TRC_CFG_NSEMAPHORE in trcSnapshotConfig.h"; - case TRACE_CLASS_MUTEX: - return "Not enough MUTEX handles - increase TRC_CFG_NMUTEX in trcSnapshotConfig.h"; - case TRACE_CLASS_QUEUE: - return "Not enough QUEUE handles - increase TRC_CFG_NQUEUE in trcSnapshotConfig.h"; - case TRACE_CLASS_TIMER: - return "Not enough TIMER handles - increase TRC_CFG_NTIMER in trcSnapshotConfig.h"; - case TRACE_CLASS_EVENTGROUP: - return "Not enough EVENTGROUP handles - increase TRC_CFG_NEVENTGROUP in trcSnapshotConfig.h"; - case TRACE_CLASS_STREAMBUFFER: - return "Not enough STREAMBUFFER handles - increase TRC_CFG_NSTREAMBUFFER in trcSnapshotConfig.h"; - case TRACE_CLASS_MESSAGEBUFFER: - return "Not enough MESSAGEBUFFER handles - increase TRC_CFG_NMESSAGEBUFFER in trcSnapshotConfig.h"; - default: - return "pszTraceGetErrorHandles: Invalid objectclass!"; - } -} - -/******************************************************************************* - * prvTraceIsSchedulerSuspended - * - * Returns true if the RTOS scheduler currently is disabled, thus preventing any - * task-switches from occurring. Only called from vTraceStoreISREnd. - ******************************************************************************/ -#if (TRC_CFG_INCLUDE_ISR_TRACING == 1) -unsigned char prvTraceIsSchedulerSuspended(void) -{ - /* Assumed to be available in FreeRTOS. According to the FreeRTOS docs, - INCLUDE_xTaskGetSchedulerState or configUSE_TIMERS must be set to 1 in - FreeRTOSConfig.h for this function to be available. */ - - return xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED; -} -#endif - -#endif /* Snapshot mode */ - -#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c deleted file mode 100755 index 2f82ab0..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c +++ /dev/null @@ -1,3105 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.5 - * Percepio AB, www.percepio.com - * - * trcSnapshotRecorder.c - * - * The generic core of the trace recorder's snapshot mode. - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#include "trcRecorder.h" - -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) - -#if (TRC_USE_TRACEALYZER_RECORDER == 1) - -#include -#include -#include - -#if ((TRC_HWTC_TYPE == TRC_CUSTOM_TIMER_INCR) || (TRC_HWTC_TYPE == TRC_CUSTOM_TIMER_DECR)) - #error "CUSTOM timestamping mode is not (yet) supported in snapshot mode!" -#endif - -/* DO NOT CHANGE */ -#define TRACE_MINOR_VERSION 5 -#if (TRC_CFG_INCLUDE_ISR_TRACING == 1) -static traceHandle isrstack[TRC_CFG_MAX_ISR_NESTING]; -int32_t isPendingContextSwitch = 0; -#endif /* (TRC_CFG_INCLUDE_ISR_TRACING == 1) */ - -#if !defined TRC_CFG_INCLUDE_READY_EVENTS || TRC_CFG_INCLUDE_READY_EVENTS == 1 -static int readyEventsEnabled = 1; -#endif /*!defined TRC_CFG_INCLUDE_READY_EVENTS || TRC_CFG_INCLUDE_READY_EVENTS == 1*/ - -/******************************************************************************* - * uiTraceTickCount - * - * This variable is should be updated by the Kernel tick interrupt. This does - * not need to be modified when developing a new timer port. It is preferred to - * keep any timer port changes in the HWTC macro definitions, which typically - * give sufficient flexibility. - ******************************************************************************/ -uint32_t uiTraceTickCount = 0; - -uint32_t trace_disable_timestamp = 0; - -static uint32_t last_timestamp = 0; - -/* Flag that shows if inside a critical section of the recorder */ -volatile int recorder_busy = 0; - -/* Holds the value set by vTraceSetFrequency */ -uint32_t timestampFrequency = 0; - -/* The last error message of the recorder. NULL if no error message. */ -const char* traceErrorMessage = NULL; - -int8_t nISRactive = 0; - -traceHandle handle_of_last_logged_task = 0; - -/* Called when the recorder is stopped, set by vTraceSetStopHook. */ -TRACE_STOP_HOOK vTraceStopHookPtr = (TRACE_STOP_HOOK)0; - -uint16_t CurrentFilterMask = 0xFFFF; - -uint16_t CurrentFilterGroup = FilterGroup0; - -extern int8_t nISRactive; - -extern traceHandle handle_of_last_logged_task; - -/*************** Private Functions *******************************************/ -static void prvStrncpy(char* dst, const char* src, uint32_t maxLength); -static uint8_t prvTraceGetObjectState(uint8_t objectclass, traceHandle id); -static void prvTraceGetChecksum(const char *pname, uint8_t* pcrc, uint8_t* plength); -static void* prvTraceNextFreeEventBufferSlot(void); -static uint16_t prvTraceGetDTS(uint16_t param_maxDTS); -static traceString prvTraceOpenSymbol(const char* name, traceString userEventChannel); -static void prvTraceUpdateCounters(void); - -void vTraceStoreMemMangEvent(uint32_t ecode, uint32_t address, int32_t signed_size); - -#if (TRC_CFG_SNAPSHOT_MODE == TRC_SNAPSHOT_MODE_RING_BUFFER) -static void prvCheckDataToBeOverwrittenForMultiEntryEvents(uint8_t nEntries); -#endif - -static traceString prvTraceCreateSymbolTableEntry(const char* name, - uint8_t crc6, - uint8_t len, - traceString channel); - -static traceString prvTraceLookupSymbolTableEntry(const char* name, - uint8_t crc6, - uint8_t len, - traceString channel); - - -#if (TRC_CFG_INCLUDE_ISR_TRACING == 0) -/* ISR tracing is turned off */ -void prvTraceIncreaseISRActive(void); -void prvTraceDecreaseISRActive(void); -#endif /*(TRC_CFG_INCLUDE_ISR_TRACING == 0)*/ - -#if (TRC_CFG_USE_16BIT_OBJECT_HANDLES == 1) -static uint8_t prvTraceGet8BitHandle(traceHandle handle); -#else -#define prvTraceGet8BitHandle(x) ((uint8_t)x) -#endif - - -#if (TRC_CFG_INCLUDE_MEMMANG_EVENTS == 1) && (TRC_CFG_SCHEDULING_ONLY == 0) -static uint32_t heapMemUsage = 0; -#endif - -#if (TRC_CFG_SCHEDULING_ONLY == 0) -static uint32_t prvTraceGetParam(uint32_t, uint32_t); -#endif - -/******************************************************************************* - * prvTraceInitTraceData - * - * Allocates and initializes the recorder data structure, based on the constants - * in trcConfig.h. This allows for allocating the data on the heap, instead of - * using a static declaration. - ******************************************************************************/ -static void prvTraceInitTraceData(void); - -/******************************************************************************* - * prvTracePortGetTimeStamp - * - * Returns the current time based on the HWTC macros which provide a hardware - * isolation layer towards the hardware timer/counter. - * - * The HWTC macros and prvTracePortGetTimeStamp is the main porting issue - * or the trace recorder library. Typically you should not need to change - * the code of prvTracePortGetTimeStamp if using the HWTC macros. - * - ******************************************************************************/ -void prvTracePortGetTimeStamp(uint32_t *puiTimestamp); - -static void prvTraceTaskInstanceFinish(int8_t direct); - -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)) -static void vTracePrintF_Helper(traceString eventLabel, const char* formatStr, va_list vl); - -#if (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1) -static void vTraceUBData_Helper(traceUBChannel channelPair, va_list vl); -static void prvTraceUBHelper1(traceUBChannel channel, traceString eventLabel, traceString formatLabel, va_list vl); -static void prvTraceUBHelper2(traceUBChannel channel, uint32_t* data, uint32_t noOfSlots); -#endif /*(TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)*/ -#endif /* ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)) */ - -/********* Public Functions **************************************************/ - -uint16_t uiIndexOfObject(traceHandle objecthandle, uint8_t objectclass); - -/******************************************************************************* - * prvTraceError - * - * Called by various parts in the recorder. Stops the recorder and stores a - * pointer to an error message, which is printed by the monitor task. - ******************************************************************************/ -void prvTraceError(const char* msg); - -/****************************************************************************** -* vTraceEnable(int startOption) - snapshot mode -* -* Initializes and optionally starts the trace, depending on the start option. -* To use the trace recorder, the startup must call vTraceEnable before any RTOS -* calls are made (including "create" calls). Three start options are provided: -* -* TRC_START: Starts the tracing directly. In snapshot mode this allows for -* starting the trace at any point in your code, assuming vTraceEnable(TRC_INIT) -* has been called in the startup. -* Can also be used for streaming without Tracealyzer control, e.g. to a local -* flash file system (assuming such a "stream port", see trcStreamingPort.h). -* -* TRC_INIT: Initializes the trace recorder, but does not start the tracing. -* In snapshot mode, this must be followed by a vTraceEnable(TRC_START) sometime -* later. -* -* Usage examples, in snapshot mode: -* -* Snapshot trace, from startup: -* -* vTraceEnable(TRC_START); -* -* -* Snapshot trace, from a later point: -* -* vTraceEnable(TRC_INIT); -* -* ... -* vTraceEnable(TRC_START); // e.g., in task context, at some relevant event -* -* -* Note: See other implementation of vTraceEnable in trcStreamingRecorder.c -******************************************************************************/ -void vTraceEnable(int startOption) -{ - prvTraceInitTraceData(); - - if (startOption == TRC_START) - { - vTraceStart(); - } - else if (startOption == TRC_START_AWAIT_HOST) - { - prvTraceError("vTraceEnable(TRC_START_AWAIT_HOST) not allowed in Snapshot mode"); - } - else if (startOption != TRC_INIT) - { - prvTraceError("Unexpected argument to vTraceEnable (snapshot mode)"); - } -} - -/******************************************************************************* - * vTraceSetRecorderDataBuffer - * - * If custom allocation is used, this function must be called so the recorder - * library knows where to save the trace data. - ******************************************************************************/ -#if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM) -void vTraceSetRecorderDataBuffer(void* pRecorderData) -{ - TRACE_ASSERT(pRecorderData != NULL, "vTraceSetRecorderDataBuffer, pRecorderData == NULL", TRC_UNUSED); - RecorderDataPtr = pRecorderData; -} -#endif - -/******************************************************************************* - * vTraceSetStopHook - * - * Sets a function to be called when the recorder is stopped. This can be used - * to save the trace to a file system, if available. This is only implemented - * for snapshot mode. - ******************************************************************************/ -void vTraceSetStopHook(TRACE_STOP_HOOK stopHookFunction) -{ - vTraceStopHookPtr = stopHookFunction; -} - -/******************************************************************************* - * vTraceClear - * - * Resets the recorder. Only necessary if a restart is desired - this is not - * needed in the startup initialization. - ******************************************************************************/ -void vTraceClear(void) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - trcCRITICAL_SECTION_BEGIN(); - RecorderDataPtr->absTimeLastEventSecond = 0; - RecorderDataPtr->absTimeLastEvent = 0; - RecorderDataPtr->nextFreeIndex = 0; - RecorderDataPtr->numEvents = 0; - RecorderDataPtr->bufferIsFull = 0; - traceErrorMessage = NULL; - RecorderDataPtr->internalErrorOccured = 0; - (void)memset(RecorderDataPtr->eventData, 0, RecorderDataPtr->maxEvents * 4); - handle_of_last_logged_task = 0; - trcCRITICAL_SECTION_END(); -} - -/******************************************************************************* - * uiTraceStart - * - * Starts the recorder. The recorder will not be started if an error has been - * indicated using prvTraceError, e.g. if any of the Nx constants in trcConfig.h - * has a too small value (TRC_CFG_NTASK, TRC_CFG_NQUEUE, etc). - * - * Returns 1 if the recorder was started successfully. - * Returns 0 if the recorder start was prevented due to a previous internal - * error. In that case, check xTraceGetLastError to get the error message. - * Any error message is also presented when opening a trace file. - * - * This function is obsolete, but has been saved for backwards compatibility. - * We recommend using vTraceEnable instead. - ******************************************************************************/ -uint32_t uiTraceStart(void) -{ - traceHandle handle; - TRACE_ALLOC_CRITICAL_SECTION(); - - handle = 0; - - if (RecorderDataPtr == NULL) - { - TRACE_ASSERT(RecorderDataPtr != NULL, "Recorder not initialized. Use vTraceEnable() instead!", 0); - return 0; - } - - if (RecorderDataPtr->recorderActive == 1) - return 1; /* Already running */ - - if (traceErrorMessage == NULL) - { - trcCRITICAL_SECTION_BEGIN(); - RecorderDataPtr->recorderActive = 1; - - handle = TRACE_GET_TASK_NUMBER(TRACE_GET_CURRENT_TASK()); - if (handle == 0) - { - /* This occurs if the scheduler is not yet started. - This creates a dummy "(startup)" task entry internally in the - recorder */ - handle = prvTraceGetObjectHandle(TRACE_CLASS_TASK); - prvTraceSetObjectName(TRACE_CLASS_TASK, handle, "(startup)"); - - prvTraceSetPriorityProperty(TRACE_CLASS_TASK, handle, 0); - } - - prvTraceStoreTaskswitch(handle); /* Register the currently running task */ - trcCRITICAL_SECTION_END(); - } - - return RecorderDataPtr->recorderActive; -} - -/******************************************************************************* - * vTraceStart - * - * Starts the recorder. The recorder will not be started if an error has been - * indicated using prvTraceError, e.g. if any of the Nx constants in trcConfig.h - * has a too small value (TRC_CFG_NTASK, TRC_CFG_NQUEUE, etc). - * - * This function is obsolete, but has been saved for backwards compatibility. - * We recommend using vTraceEnable instead. - ******************************************************************************/ -void vTraceStart(void) -{ - (void)uiTraceStart(); -} - -/******************************************************************************* - * vTraceStop - * - * Stops the recorder. The recording can be resumed by calling vTraceStart. - * This does not reset the recorder. Use vTraceClear if that is desired. - ******************************************************************************/ -void vTraceStop(void) -{ - if (RecorderDataPtr != NULL) - { - RecorderDataPtr->recorderActive = 0; - } - - if (vTraceStopHookPtr != (TRACE_STOP_HOOK)0) - { - (*vTraceStopHookPtr)(); /* An application call-back function. */ - } -} - -/******************************************************************************* -* xTraceIsRecordingEnabled -* Returns true (1) if the recorder is enabled (i.e. is recording), otherwise 0. -******************************************************************************/ -int xTraceIsRecordingEnabled(void) -{ - if (RecorderDataPtr != NULL) - { - return (int)RecorderDataPtr->recorderActive; - } - else - { - return 0; - } -} - -/******************************************************************************* - * xTraceGetLastError - * - * Gives the last error message, if any. NULL if no error message is stored. - * Any error message is also presented when opening a trace file. - ******************************************************************************/ -const char* xTraceGetLastError(void) -{ - return traceErrorMessage; -} - -/******************************************************************************* -* vTraceClearError -* -* Removes any previous error message generated by recorder calling prvTraceError. -* By calling this function, it may be possible to start/restart the trace -* despite errors in the recorder, but there is no guarantee that the trace -* recorder will work correctly in that case, depending on the type of error. -******************************************************************************/ -void vTraceClearError(void) -{ - traceErrorMessage = NULL; - if (RecorderDataPtr != NULL) - { - RecorderDataPtr->internalErrorOccured = 0; - } -} - -/******************************************************************************* - * xTraceGetTraceBuffer - * - * Returns a pointer to the recorder data structure. Use this together with - * uiTraceGetTraceBufferSize if you wish to implement an own store/upload - * solution, e.g., in case a debugger connection is not available for uploading - * the data. - ******************************************************************************/ -void* xTraceGetTraceBuffer(void) -{ - return RecorderDataPtr; -} - -/******************************************************************************* - * uiTraceGetTraceBufferSize - * - * Gets the size of the recorder data structure. For use together with - * vTraceGetTraceBuffer if you wish to implement an own store/upload solution, - * e.g., in case a debugger connection is not available for uploading the data. - ******************************************************************************/ -uint32_t uiTraceGetTraceBufferSize(void) -{ - return sizeof(RecorderDataType); -} - -/****************************************************************************** - * prvTraceTaskInstanceFinish - * - * Private common function for the vTraceTaskInstanceFinishXXX functions. - *****************************************************************************/ -static void prvTraceTaskInstanceFinish(int8_t direct) -{ - TaskInstanceStatusEvent* tis; - uint8_t dts45; - - TRACE_ALLOC_CRITICAL_SECTION(); - - trcCRITICAL_SECTION_BEGIN(); - if (RecorderDataPtr->recorderActive && handle_of_last_logged_task) - { - dts45 = (uint8_t)prvTraceGetDTS(0xFF); - tis = (TaskInstanceStatusEvent*) prvTraceNextFreeEventBufferSlot(); - if (tis != NULL) - { - if (direct == 0) - tis->type = TASK_INSTANCE_FINISHED_NEXT_KSE; - else - tis->type = TASK_INSTANCE_FINISHED_DIRECT; - - tis->dts = dts45; - prvTraceUpdateCounters(); - } - } - trcCRITICAL_SECTION_END(); -} - -/****************************************************************************** - * vTraceInstanceFinishedNext(void) - * - * Marks the current task instance as finished on the next kernel call. - * - * If that kernel call is blocking, the instance ends after the blocking event - * and the corresponding return event is then the start of the next instance. - * If the kernel call is not blocking, the viewer instead splits the current - * fragment right before the kernel call, which makes this call the first event - * of the next instance. - * - * See also TRC_CFG_USE_IMPLICIT_IFE_RULES in trcConfig.h - * - * Example: - * - * while(1) - * { - * xQueueReceive(CommandQueue, &command, timeoutDuration); - * processCommand(command); - * vTraceInstanceFinishedNext(); - * } - *****************************************************************************/ -void vTraceInstanceFinishedNext(void) -{ - prvTraceTaskInstanceFinish(0); -} - -/****************************************************************************** - * vTraceInstanceFinishedNow(void) - * - * Marks the current task instance as finished at this very instant. - * This makes the viewer to splits the current fragment at this point and begin - * a new actor instance. - * - * See also TRC_CFG_USE_IMPLICIT_IFE_RULES in trcConfig.h - * - * Example: - * - * This example will generate two instances for each loop iteration. - * The first instance ends at vTraceInstanceFinishedNow(), while the second - * instance ends at the next xQueueReceive call. - * - * while (1) - * { - * xQueueReceive(CommandQueue, &command, timeoutDuration); - * ProcessCommand(command); - * vTraceInstanceFinishedNow(); - * DoSometingElse(); - * vTraceInstanceFinishedNext(); - * } - *****************************************************************************/ -void vTraceInstanceFinishedNow(void) -{ - prvTraceTaskInstanceFinish(1); -} - -/******************************************************************************* - * Interrupt recording functions - ******************************************************************************/ - -#if (TRC_CFG_INCLUDE_ISR_TRACING == 1) - -/******************************************************************************* - * xTraceSetISRProperties - * - * Stores a name and priority level for an Interrupt Service Routine, to allow - * for better visualization. Returns a traceHandle used by vTraceStoreISRBegin. - * - * Example: - * #define PRIO_ISR_TIMER1 3 // the hardware priority of the interrupt - * ... - * traceHandle Timer1Handle = xTraceSetISRProperties("ISRTimer1", PRIO_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin(Timer1Handle); - * ... - * vTraceStoreISREnd(0); - * } - ******************************************************************************/ - traceHandle xTraceSetISRProperties(const char* name, uint8_t priority) -{ - static traceHandle handle = 0; - TRACE_ASSERT(RecorderDataPtr != NULL, "Recorder not initialized, call vTraceEnable() first!", (traceHandle)0); - TRACE_ASSERT(handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[TRACE_CLASS_ISR], "xTraceSetISRProperties: Invalid value for handle", 0); - TRACE_ASSERT(name != NULL, "xTraceSetISRProperties: name == NULL", 0); - - handle++; - - prvTraceSetObjectName(TRACE_CLASS_ISR, handle, name); - prvTraceSetPriorityProperty(TRACE_CLASS_ISR, handle, priority); - - return handle; -} - -/******************************************************************************* - * vTraceStoreISRBegin - * - * Registers the beginning of an Interrupt Service Routine, using a traceHandle - * provided by xTraceSetISRProperties. - * - * Example: - * #define PRIO_ISR_TIMER1 3 // the hardware priority of the interrupt - * ... - * traceHandle Timer1Handle = xTraceSetISRProperties("ISRTimer1", PRIO_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin(Timer1Handle); - * ... - * vTraceStoreISREnd(0); - * } - ******************************************************************************/ -void vTraceStoreISRBegin(traceHandle handle) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - if (recorder_busy) - { - /************************************************************************* - * This occurs if an ISR calls a trace function, preempting a previous - * trace call that is being processed in a different ISR or task. - * If this occurs, there is probably a problem in the definition of the - * recorder's internal critical sections (TRACE_ENTER_CRITICAL_SECTION and - * TRACE_EXIT_CRITICAL_SECTION). They must disable the RTOS tick interrupt - * and any other ISRs that calls the trace recorder directly or via - * traced kernel functions. The ARM port disables all interrupts using the - * PRIMASK register to avoid this issue. - *************************************************************************/ - prvTraceError("vTraceStoreISRBegin - recorder busy! See code comment."); - return; - } - trcCRITICAL_SECTION_BEGIN(); - - if (RecorderDataPtr->recorderActive && handle_of_last_logged_task) - { - uint16_t dts4; - - TRACE_ASSERT(handle != 0, "vTraceStoreISRBegin: Invalid ISR handle (NULL)", TRC_UNUSED); - TRACE_ASSERT(handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[TRACE_CLASS_ISR], "vTraceStoreISRBegin: Invalid ISR handle (> NISR)", TRC_UNUSED); - - dts4 = (uint16_t)prvTraceGetDTS(0xFFFF); - - if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */ - { - if (nISRactive < TRC_CFG_MAX_ISR_NESTING) - { - TSEvent* ts; - uint8_t hnd8 = prvTraceGet8BitHandle(handle); - isrstack[nISRactive] = handle; - nISRactive++; - ts = (TSEvent*)prvTraceNextFreeEventBufferSlot(); - if (ts != NULL) - { - ts->type = TS_ISR_BEGIN; - ts->dts = dts4; - ts->objHandle = hnd8; - prvTraceUpdateCounters(); - } - } - else - { - /* This should not occur unless something is very wrong */ - prvTraceError("Too many nested interrupts!"); - } - } - } - trcCRITICAL_SECTION_END(); -} - -/******************************************************************************* - * vTraceStoreISREnd - * - * Registers the end of an Interrupt Service Routine. - * - * The parameter pendingISR indicates if the interrupt has requested a - * task-switch (= 1), e.g., by signaling a semaphore. Otherwise (= 0) the - * interrupt is assumed to return to the previous context. - * - * Example: - * #define PRIO_OF_ISR_TIMER1 3 // the hardware priority of the interrupt - * traceHandle traceHandleIsrTimer1 = 0; // The ID set by the recorder - * ... - * traceHandleIsrTimer1 = xTraceSetISRProperties("ISRTimer1", PRIO_OF_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin(traceHandleIsrTimer1); - * ... - * vTraceStoreISREnd(0); - * } - ******************************************************************************/ -void vTraceStoreISREnd(int pendingISR) -{ - TSEvent* ts; - uint16_t dts5; - uint8_t hnd8 = 0, type = 0; - - TRACE_ALLOC_CRITICAL_SECTION(); - - if (! RecorderDataPtr->recorderActive || ! handle_of_last_logged_task) - { - return; - } - - if (recorder_busy) - { - /************************************************************************* - * This occurs if an ISR calls a trace function, preempting a previous - * trace call that is being processed in a different ISR or task. - * If this occurs, there is probably a problem in the definition of the - * recorder's internal critical sections (TRACE_ENTER_CRITICAL_SECTION and - * TRACE_EXIT_CRITICAL_SECTION). They must disable the RTOS tick interrupt - * and any other ISRs that calls the trace recorder directly or via - * traced kernel functions. The ARM port disables all interrupts using the - * PRIMASK register to avoid this issue. - *************************************************************************/ - prvTraceError("vTraceStoreISREnd - recorder busy! See code comment."); - return; - } - - if (nISRactive == 0) - { - prvTraceError("Unmatched call to vTraceStoreISREnd (nISRactive == 0, expected > 0)"); - return; - } - - trcCRITICAL_SECTION_BEGIN(); - isPendingContextSwitch |= pendingISR; /* Is there a pending context switch right now? */ - nISRactive--; - if (nISRactive > 0) - { - /* Return to another ISR */ - type = TS_ISR_RESUME; - hnd8 = prvTraceGet8BitHandle(isrstack[nISRactive - 1]); /* isrstack[nISRactive] is the handle of the ISR we're currently exiting. isrstack[nISRactive - 1] is the handle of the ISR that was executing previously. */ - } - else if ((isPendingContextSwitch == 0) || (prvTraceIsSchedulerSuspended())) - { - /* Return to interrupted task, if no context switch will occur in between. */ - type = TS_TASK_RESUME; - hnd8 = prvTraceGet8BitHandle(handle_of_last_logged_task); - } - - if (type != 0) - { - dts5 = (uint16_t)prvTraceGetDTS(0xFFFF); - ts = (TSEvent*)prvTraceNextFreeEventBufferSlot(); - if (ts != NULL) - { - ts->type = type; - ts->objHandle = hnd8; - ts->dts = dts5; - prvTraceUpdateCounters(); - } - } - - trcCRITICAL_SECTION_END(); -} - -#else - -/* ISR tracing is turned off */ -void prvTraceIncreaseISRActive(void) -{ - if (RecorderDataPtr->recorderActive && handle_of_last_logged_task) - nISRactive++; -} - -void prvTraceDecreaseISRActive(void) -{ - if (RecorderDataPtr->recorderActive && handle_of_last_logged_task) - nISRactive--; -} -#endif /* (TRC_CFG_INCLUDE_ISR_TRACING == 1)*/ - - -/********************************************************************************/ -/* User Event functions */ -/********************************************************************************/ - -#define MAX_ARG_SIZE (4+32) - -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)) -static uint8_t writeInt8(void * buffer, uint8_t i, uint8_t value) -{ - TRACE_ASSERT(buffer != NULL, "writeInt8: buffer == NULL", 0); - - if (i >= MAX_ARG_SIZE) - { - return 255; - } - - ((uint8_t*)buffer)[i] = value; - - if (i + 1 > MAX_ARG_SIZE) - { - return 255; - } - - return ((uint8_t) (i + 1)); -} -#endif - -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)) -static uint8_t writeInt16(void * buffer, uint8_t i, uint16_t value) -{ - TRACE_ASSERT(buffer != NULL, "writeInt16: buffer == NULL", 0); - - /* Align to multiple of 2 */ - while ((i % 2) != 0) - { - if (i >= MAX_ARG_SIZE) - { - return 255; - } - - ((uint8_t*)buffer)[i] = 0; - i++; - } - - if (i + 2 > MAX_ARG_SIZE) - { - return 255; - } - - ((uint16_t*)buffer)[i/2] = value; - - return ((uint8_t) (i + 2)); -} -#endif - -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)) -static uint8_t writeInt32(void * buffer, uint8_t i, uint32_t value) -{ - TRACE_ASSERT(buffer != NULL, "writeInt32: buffer == NULL", 0); - - /* A 32 bit value should begin at an even 4-byte address */ - while ((i % 4) != 0) - { - if (i >= MAX_ARG_SIZE) - { - return 255; - } - - ((uint8_t*)buffer)[i] = 0; - i++; - } - - if (i + 4 > MAX_ARG_SIZE) - { - return 255; - } - - ((uint32_t*)buffer)[i/4] = value; - - return ((uint8_t) (i + 4)); -} -#endif - -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) && (TRC_CFG_INCLUDE_FLOAT_SUPPORT)) -static uint8_t writeFloat(void * buffer, uint8_t i, float value) -{ - TRACE_ASSERT(buffer != NULL, "writeFloat: buffer == NULL", 0); - - /* A 32 bit value should begin at an even 4-byte address */ - while ((i % 4) != 0) - { - if (i >= MAX_ARG_SIZE) - { - return 255; - } - - ((uint8_t*)buffer)[i] = 0; - i++; - } - - if (i + 4 > MAX_ARG_SIZE) - { - return 255; - } - - ((float*)buffer)[i/4] = value; - - return i + 4; -} -#endif - -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) && (TRC_CFG_INCLUDE_FLOAT_SUPPORT)) -static uint8_t writeDouble(void * buffer, uint8_t i, double value) -{ - uint32_t * dest; - uint32_t * src = (uint32_t*)&value; - - TRACE_ASSERT(buffer != NULL, "writeDouble: buffer == NULL", 0); - - /* The double is written as two 32 bit values, and should begin at an even - 4-byte address (to avoid having to align with 8 byte) */ - while (i % 4 != 0) - { - if (i >= MAX_ARG_SIZE) - { - return 255; - } - - ((uint8_t*)buffer)[i] = 0; - i++; - } - - if (i + 8 > MAX_ARG_SIZE) - { - return 255; - } - - dest = &(((uint32_t *)buffer)[i/4]); - - dest[0] = src[0]; - dest[1] = src[1]; - - return i + 8; -} -#endif - -/******************************************************************************* - * prvTraceUserEventFormat - * - * Parses the format string and stores the arguments in the buffer. - ******************************************************************************/ -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)) -static uint8_t prvTraceUserEventFormat(const char* formatStr, va_list vl, uint8_t* buffer, uint8_t byteOffset) -{ - uint16_t formatStrIndex = 0; - uint8_t argCounter = 0; - uint8_t i = byteOffset; - - while (formatStr[formatStrIndex] != '\0') - { - if (formatStr[formatStrIndex] == '%') - { - argCounter++; - - if (argCounter > 15) - { - prvTraceError("vTracePrintF - Too many arguments, max 15 allowed!"); - return 0; - } - - formatStrIndex++; - - while ((formatStr[formatStrIndex] >= '0' && formatStr[formatStrIndex] <= '9') || formatStr[formatStrIndex] == '#' || formatStr[formatStrIndex] == '.') - formatStrIndex++; - - if (formatStr[formatStrIndex] != '\0') - { - switch (formatStr[formatStrIndex]) - { - case 'd': i = writeInt32( buffer, - i, - (uint32_t)va_arg(vl, uint32_t)); - break; - case 'x': - case 'X': - case 'u': i = writeInt32( buffer, - i, - (uint32_t)va_arg(vl, uint32_t)); - break; - case 's': i = writeInt16( buffer, - i, - xTraceRegisterString((char*)va_arg(vl, char*))); - break; - -#if (TRC_CFG_INCLUDE_FLOAT_SUPPORT) - /* Yes, "double" as type also in the float - case. This since "float" is promoted into "double" - by the va_arg stuff. */ - case 'f': i = writeFloat( buffer, - i, - (float)va_arg(vl, double)); - break; -#else - /* No support for floats, but attempt to store a float user event - avoid a possible crash due to float reference. Instead store the - data on uint_32 format (will not be displayed anyway). This is just - to keep va_arg and i consistent. */ - - case 'f': i = writeInt32( buffer, - i, - (uint32_t)va_arg(vl, double)); - break; -#endif - case 'l': - formatStrIndex++; - switch (formatStr[formatStrIndex]) - { -#if (TRC_CFG_INCLUDE_FLOAT_SUPPORT) - case 'f': i = writeDouble(buffer, - i, - (double)va_arg(vl, double)); - break; -#else - /* No support for floats, but attempt to store a float user event - avoid a possible crash due to float reference. Instead store the - data on uint_32 format (will not be displayed anyway). This is just - to keep va_arg and i consistent. */ - case 'f': i = writeInt32( buffer, /* In this case, the value will not be shown anyway */ - i, - (uint32_t)va_arg(vl, double)); - - i = writeInt32( buffer, /* Do it twice, to write in total 8 bytes */ - i, - (uint32_t)va_arg(vl, double)); - break; -#endif - - } - break; - case 'h': - formatStrIndex++; - switch (formatStr[formatStrIndex]) - { - case 'd': i = writeInt16( buffer, - i, - (uint16_t)va_arg(vl, uint32_t)); - break; - case 'u': i = writeInt16( buffer, - i, - (uint16_t)va_arg(vl, uint32_t)); - break; - } - break; - case 'b': - formatStrIndex++; - switch (formatStr[formatStrIndex]) - { - case 'd': i = writeInt8( buffer, - i, - (uint8_t)va_arg(vl, uint32_t)); - break; - - case 'u': i = writeInt8( buffer, - i, - (uint8_t)va_arg(vl, uint32_t)); - break; - } - break; - } - } - else - break; - } - formatStrIndex++; - if (i == 255) - { - prvTraceError("vTracePrintF - Too large arguments, max 32 byte allowed!"); - return 0; - } - } - return (uint8_t)(i+3)/4; -} -#endif - -/******************************************************************************* - * prvTraceClearChannelBuffer - * - * Clears a number of items in the channel buffer, starting from nextSlotToWrite. - ******************************************************************************/ -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) && (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)) -static void prvTraceClearChannelBuffer(uint32_t count) -{ - uint32_t slots; - - TRACE_ASSERT((TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE) >= count, - "prvTraceClearChannelBuffer: TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE is too small to handle this event.", TRC_UNUSED); - - /* Check if we're close to the end of the buffer */ - if (RecorderDataPtr->userEventBuffer.nextSlotToWrite + count > (TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE)) - { - slots = (TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE) - RecorderDataPtr->userEventBuffer.nextSlotToWrite; /* Number of slots before end of buffer */ - (void)memset(&RecorderDataPtr->userEventBuffer.channelBuffer[RecorderDataPtr->userEventBuffer.nextSlotToWrite], 0, slots); - (void)memset(&RecorderDataPtr->userEventBuffer.channelBuffer[0], 0, (count - slots)); - } - else - (void)memset(&RecorderDataPtr->userEventBuffer.channelBuffer[RecorderDataPtr->userEventBuffer.nextSlotToWrite], 0, count); -} -#endif - -/******************************************************************************* - * prvTraceCopyToDataBuffer - * - * Copies a number of items to the data buffer, starting from nextSlotToWrite. - ******************************************************************************/ -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) && (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)) -static void prvTraceCopyToDataBuffer(uint32_t* data, uint32_t count) -{ - uint32_t slots; - - TRACE_ASSERT(data != NULL, - "prvTraceCopyToDataBuffer: data == NULL.", TRC_UNUSED); - TRACE_ASSERT(count <= (TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE), - "prvTraceCopyToDataBuffer: TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE is too small to handle this event.", TRC_UNUSED); - /* Check if we're close to the end of the buffer */ - if (RecorderDataPtr->userEventBuffer.nextSlotToWrite + count > (TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE)) - { - slots = (TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE) - RecorderDataPtr->userEventBuffer.nextSlotToWrite; /* Number of slots before end of buffer */ - (void)memcpy(&RecorderDataPtr->userEventBuffer.dataBuffer[RecorderDataPtr->userEventBuffer.nextSlotToWrite * 4], data, slots * 4); - (void)memcpy(&RecorderDataPtr->userEventBuffer.dataBuffer[0], data + slots, (count - slots) * 4); - } - else - { - (void)memcpy(&RecorderDataPtr->userEventBuffer.dataBuffer[RecorderDataPtr->userEventBuffer.nextSlotToWrite * 4], data, count * 4); - } -} -#endif - -/******************************************************************************* - * prvTraceUBHelper1 - * - * Calls on prvTraceUserEventFormat() to do the actual formatting, then goes on - * to the next helper function. - ******************************************************************************/ -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) && (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)) -static void prvTraceUBHelper1(traceUBChannel channel, traceString eventLabel, traceString formatLabel, va_list vl) -{ - uint32_t data[(3 + MAX_ARG_SIZE) / 4]; - uint8_t byteOffset = 4; /* Need room for timestamp */ - uint8_t noOfSlots; - - if (channel == 0) - { - /* We are dealing with an unknown channel format pair */ - byteOffset = (uint8_t)(byteOffset + 4); /* Also need room for channel and format */ - ((uint16_t*)data)[2] = eventLabel; - ((uint16_t*)data)[3] = formatLabel; - } - - noOfSlots = prvTraceUserEventFormat((char*)&(RecorderDataPtr->SymbolTable.symbytes[formatLabel+4]), vl, (uint8_t*)data, byteOffset); - - prvTraceUBHelper2(channel, data, noOfSlots); -} -#endif - -/******************************************************************************* - * prvTraceUBHelper2 - * - * This function simply copies the data buffer to the actual user event buffer. - ******************************************************************************/ -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) && (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)) -static void prvTraceUBHelper2(traceUBChannel channel, uint32_t* data, uint32_t noOfSlots) -{ - static uint32_t old_timestamp = 0; - uint32_t old_nextSlotToWrite = 0; - - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ASSERT((TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE) >= noOfSlots, "prvTraceUBHelper2: TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE is too small to handle this event.", TRC_UNUSED); - - trcCRITICAL_SECTION_BEGIN(); - /* Store the timestamp */ - prvTracePortGetTimeStamp(data); - - if (*data < old_timestamp) - { - RecorderDataPtr->userEventBuffer.wraparoundCounter++; - } - - old_timestamp = *data; - - /* Start by erasing any information in the channel buffer */ - prvTraceClearChannelBuffer(noOfSlots); - - prvTraceCopyToDataBuffer(data, noOfSlots); /* Will wrap around the data if necessary */ - - old_nextSlotToWrite = RecorderDataPtr->userEventBuffer.nextSlotToWrite; /* Save the index that we want to write the channel data at when we're done */ - RecorderDataPtr->userEventBuffer.nextSlotToWrite = (RecorderDataPtr->userEventBuffer.nextSlotToWrite + noOfSlots) % (TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE); /* Make sure we never end up outside the buffer */ - - /* Write to the channel buffer to indicate that this user event is ready to be used */ - if (channel != 0) - { - RecorderDataPtr->userEventBuffer.channelBuffer[old_nextSlotToWrite] = channel; - } - else - { - /* 0xFF indicates that this is not a normal channel id */ - RecorderDataPtr->userEventBuffer.channelBuffer[old_nextSlotToWrite] = (traceUBChannel)0xFF; - } - trcCRITICAL_SECTION_END(); -} -#endif - -/******************************************************************************* - * xTraceRegisterUBChannel - * - * Registers a channel for Separated User Events, i.e., those stored in the - * separate user event buffer. - * - * Note: Only available if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is enabled in - * trcSnapshotConfig.h - ******************************************************************************/ -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) && (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)) -traceUBChannel xTraceRegisterUBChannel(traceString channel, traceString formatStr) -{ - uint8_t i; - traceUBChannel retVal = 0; - - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ASSERT(formatStr != 0, "xTraceRegisterChannelFormat: formatStr == 0", (traceUBChannel)0); - - trcCRITICAL_SECTION_BEGIN(); - for (i = 1; i <= (TRC_CFG_UB_CHANNELS); i++) /* Size of the channels buffer is TRC_CFG_UB_CHANNELS + 1. Index 0 is unused. */ - { - if(RecorderDataPtr->userEventBuffer.channels[i].name == 0 && RecorderDataPtr->userEventBuffer.channels[i].defaultFormat == 0) - { - /* Found empty slot */ - RecorderDataPtr->userEventBuffer.channels[i].name = channel; - RecorderDataPtr->userEventBuffer.channels[i].defaultFormat = formatStr; - retVal = (traceUBChannel)i; - break; - } - - if (RecorderDataPtr->userEventBuffer.channels[i].name == channel && RecorderDataPtr->userEventBuffer.channels[i].defaultFormat == formatStr) - { - /* Found a match */ - retVal = (traceUBChannel)i; - break; - } - } - trcCRITICAL_SECTION_END(); - - return retVal; -} -#endif - -/****************************************************************************** - * vTraceUBData - * - * Slightly faster version of vTracePrintF() due to no lookups. - * - * Note: This is only available if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is - * enabled in trcSnapshotConfig.h - ******************************************************************************/ -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) && (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)) -void vTraceUBData(traceUBChannel channelPair, ...) -{ - va_list vl; - - TRACE_ASSERT(channelPair != 0, "vTraceUBData: Not a valid traceUBChannel!", TRC_UNUSED); - - va_start(vl, channelPair); - vTraceUBData_Helper(channelPair, vl); - va_end(vl); -} -#endif - -/* Extracts the channel name and format string from the traceUBChannel, then calls prvTraceUBHelper1. */ -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) && (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)) -void vTraceUBData_Helper(traceUBChannel channelPair, va_list vl) -{ - traceString channel; - traceString formatStr; - - TRACE_ASSERT(channelPair != 0, "vTraceUBData_Helper: channelPair == 0", TRC_UNUSED); - TRACE_ASSERT(channelPair <= (TRC_CFG_UB_CHANNELS), "vTraceUBData_Helper: ", TRC_UNUSED); - - channel = RecorderDataPtr->userEventBuffer.channels[channelPair].name; - formatStr = RecorderDataPtr->userEventBuffer.channels[channelPair].defaultFormat; - - prvTraceUBHelper1(channelPair, channel, formatStr, vl); -} -#endif - -/****************************************************************************** - * vTraceUBEvent - * - * Slightly faster version of ... due to no lookups. - ******************************************************************************/ -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) && (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)) -void vTraceUBEvent(traceUBChannel channelPair) -{ - uint32_t data[(3 + MAX_ARG_SIZE) / 4]; - - TRACE_ASSERT(channelPair != 0, "vTraceUBEvent: channelPair == 0", TRC_UNUSED); - TRACE_ASSERT(channelPair <= (TRC_CFG_UB_CHANNELS), "vTraceUBEvent: ", TRC_UNUSED); - - prvTraceUBHelper2(channelPair, data, 1); /* Only need one slot for timestamp */ -} -#endif - -/****************************************************************************** - * vTracePrintF - * - * Generates User Event with formatted text and data, similar to a "printf". - * It is very fast compared to a normal "printf" since this function only - * stores the arguments. The actual formatting is done - * on the host PC when the trace is displayed in the viewer tool. - * - * User Event labels are created using xTraceRegisterString. - * Example: - * - * traceString adc_uechannel = xTraceRegisterString("ADC User Events"); - * ... - * vTracePrintF(adc_uechannel, - * "ADC channel %d: %lf volts", - * ch, (double)adc_reading/(double)scale); - * - * This can be combined into one line, if desired, but this is slower: - * - * vTracePrintF(xTraceRegisterString("ADC User Events"), - * "ADC channel %d: %lf volts", - * ch, (double)adc_reading/(double)scale); - * - * Calling xTraceRegisterString multiple times will not create duplicate entries, but - * it is of course faster to just do it once, and then keep the handle for later - * use. If you don't have any data arguments, only a text label/string, it is - * better to use vTracePrint - it is faster. - * - * Format specifiers supported: - * %d - 32 bit signed integer - * %u - 32 bit unsigned integer - * %f - 32 bit float - * %s - string (is copied to the recorder symbol table) - * %hd - 16 bit signed integer - * %hu - 16 bit unsigned integer - * %bd - 8 bit signed integer - * %bu - 8 bit unsigned integer - * %lf - double-precision float (Note! See below...) - * - * Up to 15 data arguments are allowed, with a total size of maximum 32 byte. - * In case this is exceeded, the user event is changed into an error message. - * - * The data is stored in trace buffer, and is packed to allow storing multiple - * smaller data entries in the same 4-byte record, e.g., four 8-bit values. - * A string requires two bytes, as the symbol table is limited to 64K. Storing - * a double (%lf) uses two records, so this is quite costly. Use float (%f) - * unless the higher precision is really necessary. - * - * Note that the double-precision float (%lf) assumes a 64 bit double - * representation. This does not seem to be the case on e.g. PIC24 and PIC32. - * Before using a %lf argument on a 16-bit MCU, please verify that - * "sizeof(double)" actually gives 8 as expected. If not, use %f instead. - ******************************************************************************/ -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)) -void vTracePrintF(traceString eventLabel, const char* formatStr, ...) -{ - va_list vl; - - va_start(vl, formatStr); - vTracePrintF_Helper(eventLabel, formatStr, vl); - va_end(vl); -} -#endif - -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)) -void vTracePrintF_Helper(traceString eventLabel, const char* formatStr, va_list vl) -{ -#if (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 0) - uint32_t noOfSlots; - UserEvent* ue1; - uint32_t tempDataBuffer[(3 + MAX_ARG_SIZE) / 4]; - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ASSERT(formatStr != NULL, "vTracePrintF_Helper: formatStr == NULL", TRC_UNUSED); - - trcCRITICAL_SECTION_BEGIN(); - - if (RecorderDataPtr->recorderActive && handle_of_last_logged_task) - { - /* First, write the "primary" user event entry in the local buffer, but - let the event type be "EVENT_BEING_WRITTEN" for now...*/ - - ue1 = (UserEvent*)(&tempDataBuffer[0]); - - ue1->type = EVENT_BEING_WRITTEN; /* Update this as the last step */ - - noOfSlots = prvTraceUserEventFormat(formatStr, vl, (uint8_t*)tempDataBuffer, 4); - - /* Store the format string, with a reference to the channel symbol */ - ue1->payload = prvTraceOpenSymbol(formatStr, eventLabel); - - ue1->dts = (uint8_t)prvTraceGetDTS(0xFF); - - /* prvTraceGetDTS might stop the recorder in some cases... */ - if (RecorderDataPtr->recorderActive) - { - - /* If the data does not fit in the remaining main buffer, wrap around to - 0 if allowed, otherwise stop the recorder and quit). */ - if (RecorderDataPtr->nextFreeIndex + noOfSlots > RecorderDataPtr->maxEvents) - { - #if (TRC_CFG_SNAPSHOT_MODE == TRC_SNAPSHOT_MODE_RING_BUFFER) - (void)memset(& RecorderDataPtr->eventData[RecorderDataPtr->nextFreeIndex * 4], - 0, - (RecorderDataPtr->maxEvents - RecorderDataPtr->nextFreeIndex)*4); - RecorderDataPtr->nextFreeIndex = 0; - RecorderDataPtr->bufferIsFull = 1; - #else - - /* Stop recorder, since the event data will not fit in the - buffer and not circular buffer in this case... */ - vTraceStop(); - #endif - } - - /* Check if recorder has been stopped (i.e., vTraceStop above) */ - if (RecorderDataPtr->recorderActive) - { - /* Check that the buffer to be overwritten does not contain any user - events that would be partially overwritten. If so, they must be "killed" - by replacing the user event and following data with NULL events (i.e., - using a memset to zero).*/ - #if (TRC_CFG_SNAPSHOT_MODE == TRC_SNAPSHOT_MODE_RING_BUFFER) - prvCheckDataToBeOverwrittenForMultiEntryEvents((uint8_t)noOfSlots); - #endif - /* Copy the local buffer to the main buffer */ - (void)memcpy(& RecorderDataPtr->eventData[RecorderDataPtr->nextFreeIndex * 4], - tempDataBuffer, - noOfSlots * 4); - - /* Update the event type, i.e., number of data entries following the - main USER_EVENT entry (Note: important that this is after the memcpy, - but within the critical section!)*/ - RecorderDataPtr->eventData[RecorderDataPtr->nextFreeIndex * 4] = - (uint8_t) ( USER_EVENT + noOfSlots - 1 ); - - /* Update the main buffer event index (already checked that it fits in - the buffer, so no need to check for wrapping)*/ - - RecorderDataPtr->nextFreeIndex += noOfSlots; - RecorderDataPtr->numEvents += noOfSlots; - - if (RecorderDataPtr->nextFreeIndex >= (TRC_CFG_EVENT_BUFFER_SIZE)) - { - #if (TRC_CFG_SNAPSHOT_MODE == TRC_SNAPSHOT_MODE_RING_BUFFER) - /* We have reached the end, but this is a ring buffer. Start from the beginning again. */ - RecorderDataPtr->bufferIsFull = 1; - RecorderDataPtr->nextFreeIndex = 0; - #else - /* We have reached the end so we stop. */ - vTraceStop(); - #endif - } - } - - #if (TRC_CFG_SNAPSHOT_MODE == TRC_SNAPSHOT_MODE_RING_BUFFER) - /* Make sure the next entry is cleared correctly */ - prvCheckDataToBeOverwrittenForMultiEntryEvents(1); - #endif - - } - } - trcCRITICAL_SECTION_END(); - -#elif (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1) - /* Use the separate user event buffer */ - traceString formatLabel; - traceUBChannel channel; - - if (RecorderDataPtr->recorderActive && handle_of_last_logged_task) - { - formatLabel = xTraceRegisterString(formatStr); - - channel = xTraceRegisterUBChannel(eventLabel, formatLabel); - - prvTraceUBHelper1(channel, eventLabel, formatLabel, vl); - } -#endif -} -#endif - -/****************************************************************************** - * vTracePrint - * - * Basic user event - * - * Generates a User Event with a text label. The label is created/looked up - * in the symbol table using xTraceRegisterString. - ******************************************************************************/ -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)) -void vTracePrint(traceString chn, const char* str) -{ -#if (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 0) - UserEvent* ue; - uint8_t dts1; - TRACE_ALLOC_CRITICAL_SECTION(); - - trcCRITICAL_SECTION_BEGIN(); - if (RecorderDataPtr->recorderActive && handle_of_last_logged_task) - { - dts1 = (uint8_t)prvTraceGetDTS(0xFF); - ue = (UserEvent*) prvTraceNextFreeEventBufferSlot(); - if (ue != NULL) - { - ue->dts = dts1; - ue->type = USER_EVENT; - ue->payload = prvTraceOpenSymbol(str, chn); - prvTraceUpdateCounters(); - } - } - trcCRITICAL_SECTION_END(); - -#elif (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1) - traceUBChannel channel; - uint32_t noOfSlots = 1; - uint32_t tempDataBuffer[(3 + MAX_ARG_SIZE) / 4]; - if (RecorderDataPtr->recorderActive && handle_of_last_logged_task) - { - traceString trcStr = prvTraceOpenSymbol(str, chn); - channel = xTraceRegisterUBChannel(chn, trcStr); - - if (channel == 0) - { - /* We are dealing with an unknown channel format pair */ - noOfSlots++; /* Also need room for channel and format */ - ((uint16_t*)tempDataBuffer)[2] = chn; - ((uint16_t*)tempDataBuffer)[3] = trcStr; - } - - prvTraceUBHelper2(channel, tempDataBuffer, noOfSlots); - } -#endif -} -#endif - -/******************************************************************************* - * xTraceRegisterString - * - * Register strings in the recorder, e.g. for names of user event channels. - * - * Example: - * myEventHandle = xTraceRegisterString("MyUserEvent"); - * ... - * vTracePrintF(myEventHandle, "My value is: %d", myValue); - ******************************************************************************/ -#if ((TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)) -traceString xTraceRegisterString(const char* label) -{ - TRACE_ASSERT(label != NULL, "xTraceRegisterString: label == NULL", (traceString)0); - TRACE_ASSERT(RecorderDataPtr != NULL, "Recorder not initialized, call vTraceEnable() first!", (traceHandle)0); - return prvTraceOpenSymbol(label, 0); -} -#endif - - -#if ((!defined TRC_CFG_INCLUDE_READY_EVENTS) || (TRC_CFG_INCLUDE_READY_EVENTS == 1)) - -void prvTraceSetReadyEventsEnabled(int status) -{ - readyEventsEnabled = status; -} - -/******************************************************************************* - * prvTraceStoreTaskReady - * - * This function stores a ready state for the task handle sent in as parameter. - ******************************************************************************/ -void prvTraceStoreTaskReady(traceHandle handle) -{ - uint16_t dts3; - TREvent* tr; - uint8_t hnd8; - - TRACE_ALLOC_CRITICAL_SECTION(); - - if (handle == 0) - { - /* On FreeRTOS v7.3.0, this occurs when creating tasks due to a bad - placement of the trace macro. In that case, the events are ignored. */ - return; - } - - if (! readyEventsEnabled) - { - /* When creating tasks, ready events are also created. If creating - a "hidden" (not traced) task, we must therefore disable recording - of ready events to avoid an undesired ready event... */ - return; - } - - TRACE_ASSERT(handle <= (TRC_CFG_NTASK), "prvTraceStoreTaskReady: Invalid value for handle", TRC_UNUSED); - - if (recorder_busy) - { - /************************************************************************* - * This occurs if an ISR calls a trace function, preempting a previous - * trace call that is being processed in a different ISR or task. - * If this occurs, there is probably a problem in the definition of the - * recorder's internal critical sections (TRACE_ENTER_CRITICAL_SECTION and - * TRACE_EXIT_CRITICAL_SECTION). They must disable the RTOS tick interrupt - * and any other ISRs that calls the trace recorder directly or via - * traced kernel functions. The ARM port disables all interrupts using the - * PRIMASK register to avoid this issue. - *************************************************************************/ - prvTraceError("Recorder busy - high priority ISR using syscall? (1)"); - return; - } - - trcCRITICAL_SECTION_BEGIN(); - if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */ - { - dts3 = (uint16_t)prvTraceGetDTS(0xFFFF); - hnd8 = prvTraceGet8BitHandle(handle); - tr = (TREvent*)prvTraceNextFreeEventBufferSlot(); - if (tr != NULL) - { - tr->type = DIV_TASK_READY; - tr->dts = dts3; - tr->objHandle = hnd8; - prvTraceUpdateCounters(); - } - } - trcCRITICAL_SECTION_END(); -} -#endif - -/******************************************************************************* - * prvTraceStoreLowPower - * - * This function stores a low power state. - ******************************************************************************/ -void prvTraceStoreLowPower(uint32_t flag) -{ - uint16_t dts; - LPEvent* lp; - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ASSERT(flag <= 1, "prvTraceStoreLowPower: Invalid flag value", TRC_UNUSED); - - if (recorder_busy) - { - /************************************************************************* - * This occurs if an ISR calls a trace function, preempting a previous - * trace call that is being processed in a different ISR or task. - * If this occurs, there is probably a problem in the definition of the - * recorder's internal critical sections (TRACE_ENTER_CRITICAL_SECTION and - * TRACE_EXIT_CRITICAL_SECTION). They must disable the RTOS tick interrupt - * and any other ISRs that calls the trace recorder directly or via - * traced kernel functions. The ARM port disables all interrupts using the - * PRIMASK register to avoid this issue. - *************************************************************************/ - prvTraceError("Recorder busy - high priority ISR using syscall? (1)"); - return; - } - - trcCRITICAL_SECTION_BEGIN(); - if (RecorderDataPtr->recorderActive) - { - dts = (uint16_t)prvTraceGetDTS(0xFFFF); - lp = (LPEvent*)prvTraceNextFreeEventBufferSlot(); - if (lp != NULL) - { - lp->type = (uint8_t) (LOW_POWER_BEGIN + ( uint8_t ) flag); /* BEGIN or END depending on flag */ - lp->dts = dts; - prvTraceUpdateCounters(); - } - } - trcCRITICAL_SECTION_END(); -} - -/******************************************************************************* - * vTraceStoreMemMangEvent - * - * This function stores malloc and free events. Each call requires two records, - * for size and address respectively. The event code parameter (ecode) is applied - * to the first record (size) and the following address record gets event - * code "ecode + 1", so make sure this is respected in the event code table. - * Note: On "free" calls, the signed_size parameter should be negative. - ******************************************************************************/ -#if (TRC_CFG_INCLUDE_MEMMANG_EVENTS == 1) -#if (TRC_CFG_SCHEDULING_ONLY == 0) -void vTraceStoreMemMangEvent(uint32_t ecode, uint32_t address, int32_t signed_size) -{ - uint8_t dts1; - MemEventSize * ms; - MemEventAddr * ma; - uint16_t size_low; - uint16_t addr_low; - uint8_t addr_high; - uint32_t size; - TRACE_ALLOC_CRITICAL_SECTION(); - - if (RecorderDataPtr == NULL) - { - /* Occurs in vTraceInitTraceData, if using dynamic allocation. */ - return; - } - - if (signed_size < 0) - size = (uint32_t)(- signed_size); - else - size = (uint32_t)(signed_size); - - trcCRITICAL_SECTION_BEGIN(); - - heapMemUsage = heapMemUsage + (uint32_t)signed_size; - - if (RecorderDataPtr->recorderActive) - { - dts1 = (uint8_t)prvTraceGetDTS(0xFF); - size_low = (uint16_t)prvTraceGetParam(0xFFFF, size); - ms = (MemEventSize *)prvTraceNextFreeEventBufferSlot(); - - if (ms != NULL) - { - ms->dts = dts1; - ms->type = NULL_EVENT; /* Updated when all events are written */ - ms->size = size_low; - prvTraceUpdateCounters(); - - /* Storing a second record with address (signals "failed" if null) */ - #if (TRC_CFG_HEAP_SIZE_BELOW_16M) - /* If the heap address range is within 16 MB, i.e., the upper 8 bits - of addresses are constant, this optimization avoids storing an extra - event record by ignoring the upper 8 bit of the address */ - addr_low = address & 0xFFFF; - addr_high = (address >> 16) & 0xFF; - #else - /* The whole 32 bit address is stored using a second event record - for the upper 16 bit */ - addr_low = (uint16_t)prvTraceGetParam(0xFFFF, address); - addr_high = 0; - #endif - - ma = (MemEventAddr *) prvTraceNextFreeEventBufferSlot(); - if (ma != NULL) - { - ma->addr_low = addr_low; - ma->addr_high = addr_high; - ma->type = (uint8_t) (ecode + 1); /* Note this! */ - ms->type = (uint8_t) ecode; - prvTraceUpdateCounters(); - RecorderDataPtr->heapMemUsage = heapMemUsage; - } - } - } - trcCRITICAL_SECTION_END(); -} -#endif /* TRC_CFG_SCHEDULING_ONLY */ -#endif - -/******************************************************************************* - * prvTraceStoreKernelCall - * - * This is the main integration point for storing kernel calls, and - * is called by the hooks in trcKernelHooks.h (see trcKernelPort.h for event codes). - ******************************************************************************/ -#if (TRC_CFG_SCHEDULING_ONLY == 0) -void prvTraceStoreKernelCall(uint32_t ecode, traceObjectClass objectClass, uint32_t objectNumber) -{ - KernelCall * kse; - uint16_t dts1; - uint8_t hnd8; - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ASSERT(ecode < 0xFF, "prvTraceStoreKernelCall: ecode >= 0xFF", TRC_UNUSED); - TRACE_ASSERT(objectClass < TRACE_NCLASSES, "prvTraceStoreKernelCall: objectClass >= TRACE_NCLASSES", TRC_UNUSED); - TRACE_ASSERT(objectNumber <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectClass], "prvTraceStoreKernelCall: Invalid value for objectNumber", TRC_UNUSED); - - if (recorder_busy) - { - /************************************************************************* - * This occurs if an ISR calls a trace function, preempting a previous - * trace call that is being processed in a different ISR or task. - * If this occurs, there is probably a problem in the definition of the - * recorder's internal critical sections (TRACE_ENTER_CRITICAL_SECTION and - * TRACE_EXIT_CRITICAL_SECTION). They must disable the RTOS tick interrupt - * and any other ISRs that calls the trace recorder directly or via - * traced kernel functions. The ARM port disables all interrupts using the - * PRIMASK register to avoid this issue. - *************************************************************************/ - prvTraceError("Recorder busy - high priority ISR using syscall? (2)"); - return; - } - - if (handle_of_last_logged_task == 0) - { - return; - } - - trcCRITICAL_SECTION_BEGIN(); - if (RecorderDataPtr->recorderActive) - { - dts1 = (uint16_t)prvTraceGetDTS(0xFFFF); - hnd8 = prvTraceGet8BitHandle((traceHandle)objectNumber); - kse = (KernelCall*) prvTraceNextFreeEventBufferSlot(); - if (kse != NULL) - { - kse->dts = dts1; - kse->type = (uint8_t)ecode; - kse->objHandle = hnd8; - prvTraceUpdateCounters(); - } - } - trcCRITICAL_SECTION_END(); -} -#endif /* TRC_CFG_SCHEDULING_ONLY */ - -/******************************************************************************* - * prvTraceStoreKernelCallWithParam - * - * Used for storing kernel calls with a handle and a numeric parameter. If the - * numeric parameter does not fit in one byte, and extra XPS event is inserted - * before the kernel call event containing the three upper bytes. - ******************************************************************************/ -#if (TRC_CFG_SCHEDULING_ONLY == 0) -void prvTraceStoreKernelCallWithParam(uint32_t evtcode, - traceObjectClass objectClass, - uint32_t objectNumber, - uint32_t param) -{ - KernelCallWithParamAndHandle * kse; - uint8_t dts2; - uint8_t hnd8; - uint8_t p8; - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ASSERT(evtcode < 0xFF, "prvTraceStoreKernelCallWithParam: evtcode >= 0xFF", TRC_UNUSED); - TRACE_ASSERT(objectClass < TRACE_NCLASSES, "prvTraceStoreKernelCallWithParam: objectClass >= TRACE_NCLASSES", TRC_UNUSED); - TRACE_ASSERT(objectNumber <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectClass], "prvTraceStoreKernelCallWithParam: Invalid value for objectNumber", TRC_UNUSED); - - if (recorder_busy) - { - /************************************************************************* - * This occurs if an ISR calls a trace function, preempting a previous - * trace call that is being processed in a different ISR or task. - * If this occurs, there is probably a problem in the definition of the - * recorder's internal critical sections (TRACE_ENTER_CRITICAL_SECTION and - * TRACE_EXIT_CRITICAL_SECTION). They must disable the RTOS tick interrupt - * and any other ISRs that calls the trace recorder directly or via - * traced kernel functions. The ARM port disables all interrupts using the - * PRIMASK register to avoid this issue. - *************************************************************************/ - prvTraceError("Recorder busy - high priority ISR using syscall? (3)"); - return; - } - - trcCRITICAL_SECTION_BEGIN(); - if (RecorderDataPtr->recorderActive && handle_of_last_logged_task) - { - dts2 = (uint8_t)prvTraceGetDTS(0xFF); - p8 = (uint8_t) prvTraceGetParam(0xFF, param); - hnd8 = prvTraceGet8BitHandle((traceHandle)objectNumber); - kse = (KernelCallWithParamAndHandle*) prvTraceNextFreeEventBufferSlot(); - if (kse != NULL) - { - kse->dts = dts2; - kse->type = (uint8_t)evtcode; - kse->objHandle = hnd8; - kse->param = p8; - prvTraceUpdateCounters(); - } - } - trcCRITICAL_SECTION_END(); -} -#endif /* TRC_CFG_SCHEDULING_ONLY */ - - -/******************************************************************************* - * prvTraceGetParam - * - * Used for storing extra bytes for kernel calls with numeric parameters. - * - * May only be called within a critical section! - ******************************************************************************/ -#if (TRC_CFG_SCHEDULING_ONLY == 0) -static uint32_t prvTraceGetParam(uint32_t param_max, uint32_t param) -{ - XPSEvent* xps; - - TRACE_ASSERT(param_max == 0xFF || param_max == 0xFFFF, - "prvTraceGetParam: Invalid value for param_max", param); - - if (param <= param_max) - { - return param; - } - else - { - xps = (XPSEvent*) prvTraceNextFreeEventBufferSlot(); - if (xps != NULL) - { - xps->type = DIV_XPS; - xps->xps_8 = (uint8_t)((param & (0xFF00 & ~param_max)) >> 8); - xps->xps_16 = (uint16_t)((param & (0xFFFF0000 & ~param_max)) >> 16); - prvTraceUpdateCounters(); - } - - return param & param_max; - } -} -#endif - -/******************************************************************************* - * prvTraceStoreKernelCallWithNumericParamOnly - * - * Used for storing kernel calls with numeric parameters only. This is - * only used for traceTASK_DELAY and traceDELAY_UNTIL at the moment. - ******************************************************************************/ -#if (TRC_CFG_SCHEDULING_ONLY == 0) -void prvTraceStoreKernelCallWithNumericParamOnly(uint32_t evtcode, uint32_t param) -{ - KernelCallWithParam16 * kse; - uint8_t dts6; - uint16_t restParam; - TRACE_ALLOC_CRITICAL_SECTION(); - - restParam = 0; - - TRACE_ASSERT(evtcode < 0xFF, "prvTraceStoreKernelCallWithNumericParamOnly: Invalid value for evtcode", TRC_UNUSED); - - if (recorder_busy) - { - /************************************************************************* - * This occurs if an ISR calls a trace function, preempting a previous - * trace call that is being processed in a different ISR or task. - * If this occurs, there is probably a problem in the definition of the - * recorder's internal critical sections (TRACE_ENTER_CRITICAL_SECTION and - * TRACE_EXIT_CRITICAL_SECTION). They must disable the RTOS tick interrupt - * and any other ISRs that calls the trace recorder directly or via - * traced kernel functions. The ARM port disables all interrupts using the - * PRIMASK register to avoid this issue. - *************************************************************************/ - prvTraceError("Recorder busy - high priority ISR using syscall? (4)"); - return; - } - - trcCRITICAL_SECTION_BEGIN(); - if (RecorderDataPtr->recorderActive && handle_of_last_logged_task) - { - dts6 = (uint8_t)prvTraceGetDTS(0xFF); - restParam = (uint16_t)prvTraceGetParam(0xFFFF, param); - kse = (KernelCallWithParam16*) prvTraceNextFreeEventBufferSlot(); - if (kse != NULL) - { - kse->dts = dts6; - kse->type = (uint8_t)evtcode; - kse->param = restParam; - prvTraceUpdateCounters(); - } - } - trcCRITICAL_SECTION_END(); -} -#endif /* TRC_CFG_SCHEDULING_ONLY */ - -/******************************************************************************* - * prvTraceStoreTaskswitch - * Called by the scheduler from the SWITCHED_OUT hook, and by uiTraceStart. - * At this point interrupts are assumed to be disabled! - ******************************************************************************/ -void prvTraceStoreTaskswitch(traceHandle task_handle) -{ - uint16_t dts3; - TSEvent* ts; - uint8_t hnd8; -#if (TRC_CFG_INCLUDE_ISR_TRACING == 1) - extern int32_t isPendingContextSwitch; -#endif - trcSR_ALLOC_CRITICAL_SECTION_ON_CORTEX_M_ONLY(); - - TRACE_ASSERT(task_handle <= (TRC_CFG_NTASK), - "prvTraceStoreTaskswitch: Invalid value for task_handle", TRC_UNUSED); - - trcCRITICAL_SECTION_BEGIN_ON_CORTEX_M_ONLY(); - - if ((task_handle != handle_of_last_logged_task) && (RecorderDataPtr->recorderActive)) - { -#if (TRC_CFG_INCLUDE_ISR_TRACING == 1) - isPendingContextSwitch = 0; -#endif - - dts3 = (uint16_t)prvTraceGetDTS(0xFFFF); - handle_of_last_logged_task = task_handle; - hnd8 = prvTraceGet8BitHandle(handle_of_last_logged_task); - ts = (TSEvent*)prvTraceNextFreeEventBufferSlot(); - - if (ts != NULL) - { - if (prvTraceGetObjectState(TRACE_CLASS_TASK, - handle_of_last_logged_task) == TASK_STATE_INSTANCE_ACTIVE) - { - ts->type = TS_TASK_RESUME; - } - else - { - ts->type = TS_TASK_BEGIN; - } - - ts->dts = dts3; - ts->objHandle = hnd8; - - prvTraceSetObjectState(TRACE_CLASS_TASK, - handle_of_last_logged_task, - TASK_STATE_INSTANCE_ACTIVE); - - prvTraceUpdateCounters(); - } - } - - trcCRITICAL_SECTION_END_ON_CORTEX_M_ONLY(); -} - -/******************************************************************************* - * prvTraceStoreObjectNameOnCloseEvent - * - * Updates the symbol table with the name of this object from the dynamic - * objects table and stores a "close" event, holding the mapping between handle - * and name (a symbol table handle). The stored name-handle mapping is thus the - * "old" one, valid up until this point. - ******************************************************************************/ -void prvTraceStoreObjectNameOnCloseEvent(uint8_t evtcode, traceHandle handle, - traceObjectClass objectclass) -{ - ObjCloseNameEvent * ce; - const char * name; - traceString idx; - - TRACE_ASSERT(objectclass < TRACE_NCLASSES, - "prvTraceStoreObjectNameOnCloseEvent: objectclass >= TRACE_NCLASSES", TRC_UNUSED); - TRACE_ASSERT(handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], - "prvTraceStoreObjectNameOnCloseEvent: Invalid value for handle", TRC_UNUSED); - - if (RecorderDataPtr->recorderActive) - { - uint8_t hnd8 = prvTraceGet8BitHandle(handle); - name = TRACE_PROPERTY_NAME_GET(objectclass, handle); - idx = prvTraceOpenSymbol(name, 0); - - // Interrupt disable not necessary, already done in trcHooks.h macro - ce = (ObjCloseNameEvent*) prvTraceNextFreeEventBufferSlot(); - if (ce != NULL) - { - ce->type = (uint8_t) evtcode; - ce->objHandle = hnd8; - ce->symbolIndex = idx; - prvTraceUpdateCounters(); - } - } -} - -void prvTraceStoreObjectPropertiesOnCloseEvent(uint8_t evtcode, traceHandle handle, - traceObjectClass objectclass) -{ - ObjClosePropEvent * pe; - - TRACE_ASSERT(objectclass < TRACE_NCLASSES, - "prvTraceStoreObjectPropertiesOnCloseEvent: objectclass >= TRACE_NCLASSES", TRC_UNUSED); - TRACE_ASSERT(handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], - "prvTraceStoreObjectPropertiesOnCloseEvent: Invalid value for handle", TRC_UNUSED); - - if (RecorderDataPtr->recorderActive) - { - // Interrupt disable not necessary, already done in trcHooks.h macro - pe = (ObjClosePropEvent*) prvTraceNextFreeEventBufferSlot(); - if (pe != NULL) - { - if (objectclass == TRACE_CLASS_TASK) - { - pe->arg1 = TRACE_PROPERTY_ACTOR_PRIORITY(objectclass, handle); - } - else - { - pe->arg1 = TRACE_PROPERTY_OBJECT_STATE(objectclass, handle); - } - pe->type = evtcode; - prvTraceUpdateCounters(); - } - } -} - -void prvTraceSetPriorityProperty(uint8_t objectclass, traceHandle id, uint8_t value) -{ - TRACE_ASSERT(objectclass < TRACE_NCLASSES, - "prvTraceSetPriorityProperty: objectclass >= TRACE_NCLASSES", TRC_UNUSED); - TRACE_ASSERT(id <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], - "prvTraceSetPriorityProperty: Invalid value for id", TRC_UNUSED); - - TRACE_PROPERTY_ACTOR_PRIORITY(objectclass, id) = value; -} - -uint8_t prvTraceGetPriorityProperty(uint8_t objectclass, traceHandle id) -{ - TRACE_ASSERT(objectclass < TRACE_NCLASSES, - "prvTraceGetPriorityProperty: objectclass >= TRACE_NCLASSES", 0); - TRACE_ASSERT(id <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], - "prvTraceGetPriorityProperty: Invalid value for id", 0); - - return TRACE_PROPERTY_ACTOR_PRIORITY(objectclass, id); -} - -void prvTraceSetObjectState(uint8_t objectclass, traceHandle id, uint8_t value) -{ - TRACE_ASSERT(objectclass < TRACE_NCLASSES, - "prvTraceSetObjectState: objectclass >= TRACE_NCLASSES", TRC_UNUSED); - TRACE_ASSERT(id <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], - "prvTraceSetObjectState: Invalid value for id", TRC_UNUSED); - - TRACE_PROPERTY_OBJECT_STATE(objectclass, id) = value; -} - -uint8_t prvTraceGetObjectState(uint8_t objectclass, traceHandle id) -{ - TRACE_ASSERT(objectclass < TRACE_NCLASSES, - "prvTraceGetObjectState: objectclass >= TRACE_NCLASSES", 0); - TRACE_ASSERT(id <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], - "prvTraceGetObjectState: Invalid value for id", 0); - - return TRACE_PROPERTY_OBJECT_STATE(objectclass, id); -} - -void prvTraceSetTaskInstanceFinished(traceHandle handle) -{ - TRACE_ASSERT(handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[TRACE_CLASS_TASK], - "prvTraceSetTaskInstanceFinished: Invalid value for handle", TRC_UNUSED); - -#if (TRC_CFG_USE_IMPLICIT_IFE_RULES == 1) - TRACE_PROPERTY_OBJECT_STATE(TRACE_CLASS_TASK, handle) = 0; -#endif -} - -/******************************************************************************* - * Static data initializations - ******************************************************************************/ - -/* A set of stacks that keeps track of available object handles for each class. -The stacks are empty initially, meaning that allocation of new handles will be -based on a counter (for each object class). Any delete operation will -return the handle to the corresponding stack, for reuse on the next allocate.*/ -objectHandleStackType objectHandleStacks = { { 0 }, { 0 }, { 0 }, { 0 }, { 0 } }; - -/* Initial TRC_HWTC_COUNT value, for detecting if the time-stamping source is -enabled. If using the OS periodic timer for time-stamping, this might not -have been configured on the earliest events during the startup. */ -uint32_t init_hwtc_count; - -/******************************************************************************* - * RecorderData - * - * The main data structure in snapshot mode, when using the default static memory - * allocation (TRC_RECORDER_BUFFER_ALLOCATION_STATIC). The recorder uses a pointer - * RecorderDataPtr to access the data, to also allow for dynamic or custom data - * allocation (see TRC_CFG_RECORDER_BUFFER_ALLOCATION). - ******************************************************************************/ -#if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_STATIC) -RecorderDataType RecorderData; -#endif - -/******************************************************************************* - * RecorderDataPtr - * - * Pointer to the main data structure, when in snapshot mode. - ******************************************************************************/ -RecorderDataType* RecorderDataPtr = NULL; - -/* This version of the function dynamically allocates the trace data */ -void prvTraceInitTraceData() -{ - - if (RecorderDataPtr == NULL) - { -#if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_STATIC) - RecorderDataPtr = &RecorderData; -#elif (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC) - RecorderDataPtr = (RecorderDataType*)TRACE_MALLOC(sizeof(RecorderDataType)); - if (! RecorderDataPtr) - { - prvTraceError("Failed allocating recorder buffer!"); - return; - } -#elif (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM) - if (! RecorderDataPtr) - { - prvTraceError("Recorder data pointer not set! Use vTraceSetRecorderDataBuffer()."); - return; - } -#endif - } - else - { - if (RecorderDataPtr->startmarker0 == 1) - { - /* Already initialized */ - return; - } - } - - init_hwtc_count = TRC_HWTC_COUNT; - - (void)memset(RecorderDataPtr, 0, sizeof(RecorderDataType)); - - RecorderDataPtr->version = TRACE_KERNEL_VERSION; - RecorderDataPtr->minor_version = TRACE_MINOR_VERSION; - RecorderDataPtr->irq_priority_order = TRC_IRQ_PRIORITY_ORDER; - RecorderDataPtr->filesize = sizeof(RecorderDataType); - RecorderDataPtr->maxEvents = (TRC_CFG_EVENT_BUFFER_SIZE); - RecorderDataPtr->debugMarker0 = (int32_t) 0xF0F0F0F0; - RecorderDataPtr->isUsing16bitHandles = TRC_CFG_USE_16BIT_OBJECT_HANDLES; - RecorderDataPtr->isrTailchainingThreshold = TRC_CFG_ISR_TAILCHAINING_THRESHOLD; - - /* This function is kernel specific */ - vTraceInitObjectPropertyTable(); - - RecorderDataPtr->debugMarker1 = (int32_t)0xF1F1F1F1; - RecorderDataPtr->SymbolTable.symTableSize = (TRC_CFG_SYMBOL_TABLE_SIZE); - RecorderDataPtr->SymbolTable.nextFreeSymbolIndex = 1; -#if (TRC_CFG_INCLUDE_FLOAT_SUPPORT == 1) - RecorderDataPtr->exampleFloatEncoding = 1.0f; /* otherwise already zero */ -#endif - RecorderDataPtr->debugMarker2 = (int32_t)0xF2F2F2F2; - prvStrncpy(RecorderDataPtr->systemInfo, "Trace Recorder Demo", 80); - RecorderDataPtr->debugMarker3 = (int32_t)0xF3F3F3F3; - RecorderDataPtr->endmarker0 = 0x0A; - RecorderDataPtr->endmarker1 = 0x0B; - RecorderDataPtr->endmarker2 = 0x0C; - RecorderDataPtr->endmarker3 = 0x0D; - RecorderDataPtr->endmarker4 = 0x71; - RecorderDataPtr->endmarker5 = 0x72; - RecorderDataPtr->endmarker6 = 0x73; - RecorderDataPtr->endmarker7 = 0x74; - RecorderDataPtr->endmarker8 = 0xF1; - RecorderDataPtr->endmarker9 = 0xF2; - RecorderDataPtr->endmarker10 = 0xF3; - RecorderDataPtr->endmarker11 = 0xF4; - -#if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER - RecorderDataPtr->userEventBuffer.bufferID = 1; - RecorderDataPtr->userEventBuffer.version = 0; - RecorderDataPtr->userEventBuffer.numberOfSlots = (TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE); - RecorderDataPtr->userEventBuffer.numberOfChannels = (TRC_CFG_UB_CHANNELS) + 1; -#endif - - /* Kernel specific initialization of the objectHandleStacks variable */ - vTraceInitObjectHandleStack(); - - - /* Finally, the 12-byte "start markers" are initialized, allowing for - Tracealyzer to find the trace data in a larger RAM dump. - - The start and end markers must be unique, but without proper precautions there - might be a risk of accidental duplicates of the start/end markers, e.g., due to - compiler optimizations. - - The below initialization of the start marker is therefore made in reverse order - and the fields are volatile to ensure this assignment order. This to avoid any - chance of accidental duplicates of this elsewhere in memory. - - Moreover, the fields are set byte-by-byte to avoid endian issues.*/ - - RecorderDataPtr->startmarker11 = 0xF4; - RecorderDataPtr->startmarker10 = 0xF3; - RecorderDataPtr->startmarker9 = 0xF2; - RecorderDataPtr->startmarker8 = 0xF1; - RecorderDataPtr->startmarker7 = 0x74; - RecorderDataPtr->startmarker6 = 0x73; - RecorderDataPtr->startmarker5 = 0x72; - RecorderDataPtr->startmarker4 = 0x71; - RecorderDataPtr->startmarker3 = 0x04; - RecorderDataPtr->startmarker2 = 0x03; - RecorderDataPtr->startmarker1 = 0x02; - RecorderDataPtr->startmarker0 = 0x01; - - if (traceErrorMessage != NULL) - { - // An error was detected before vTraceEnable was called, make sure this is stored in the trace data. - prvStrncpy(RecorderDataPtr->systemInfo, traceErrorMessage, 80); - RecorderDataPtr->internalErrorOccured = 1; - vTraceStop(); - } - - - -#ifdef TRC_PORT_SPECIFIC_INIT - TRC_PORT_SPECIFIC_INIT(); -#endif -} - - -void* prvTraceNextFreeEventBufferSlot(void) -{ - if (! RecorderDataPtr->recorderActive) - { - /* If an XTS or XPS event prior to the main event has filled the buffer - before saving the main event, and store mode is "stop when full". */ - return NULL; - } - - if (RecorderDataPtr->nextFreeIndex >= (TRC_CFG_EVENT_BUFFER_SIZE)) - { - prvTraceError("Attempt to index outside event buffer!"); - return NULL; - } - return (void*)(&RecorderDataPtr->eventData[RecorderDataPtr->nextFreeIndex*4]); -} - -uint16_t uiIndexOfObject(traceHandle objecthandle, uint8_t objectclass) -{ - TRACE_ASSERT(objectclass < TRACE_NCLASSES, - "uiIndexOfObject: Invalid value for objectclass", 0); - TRACE_ASSERT(objecthandle > 0 && objecthandle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], - "uiIndexOfObject: Invalid value for objecthandle", 0); - - if ((objectclass < TRACE_NCLASSES) && (objecthandle > 0) && - (objecthandle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass])) - { - return (uint16_t)(RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[objectclass] + - (RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[objectclass] * (objecthandle-1))); - } - - prvTraceError("Object table lookup with invalid object handle or object class!"); - return 0; -} - -traceHandle prvTraceGetObjectHandle(traceObjectClass objectclass) -{ - traceHandle handle; - static int indexOfHandle; - - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ASSERT(RecorderDataPtr != NULL, "Recorder not initialized, call vTraceEnable() first!", (traceHandle)0); - - TRACE_ASSERT(objectclass < TRACE_NCLASSES, - "prvTraceGetObjectHandle: Invalid value for objectclass", (traceHandle)0); - - trcCRITICAL_SECTION_BEGIN(); - indexOfHandle = objectHandleStacks.indexOfNextAvailableHandle[objectclass]; - if (objectHandleStacks.objectHandles[indexOfHandle] == 0) - { - /* Zero is used to indicate a never before used handle, i.e., - new slots in the handle stack. The handle slot needs to - be initialized here (starts at 1). */ - objectHandleStacks.objectHandles[indexOfHandle] = - (traceHandle)(1 + indexOfHandle - - objectHandleStacks.lowestIndexOfClass[objectclass]); - } - - handle = objectHandleStacks.objectHandles[indexOfHandle]; - - if (objectHandleStacks.indexOfNextAvailableHandle[objectclass] - > objectHandleStacks.highestIndexOfClass[objectclass]) - { - prvTraceError(pszTraceGetErrorNotEnoughHandles(objectclass)); - handle = 0; - } - else - { - int hndCount; - objectHandleStacks.indexOfNextAvailableHandle[objectclass]++; - - hndCount = objectHandleStacks.indexOfNextAvailableHandle[objectclass] - - objectHandleStacks.lowestIndexOfClass[objectclass]; - - if (hndCount > - objectHandleStacks.handleCountWaterMarksOfClass[objectclass]) - { - objectHandleStacks.handleCountWaterMarksOfClass[objectclass] = - (traceHandle)hndCount; - } - } - trcCRITICAL_SECTION_END(); - - return handle; -} - -void prvTraceFreeObjectHandle(traceObjectClass objectclass, traceHandle handle) -{ - int indexOfHandle; - - TRACE_ASSERT(objectclass < TRACE_NCLASSES, - "prvTraceFreeObjectHandle: Invalid value for objectclass", TRC_UNUSED); - TRACE_ASSERT(handle > 0 && handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], - "prvTraceFreeObjectHandle: Invalid value for handle", TRC_UNUSED); - - /* Check that there is room to push the handle on the stack */ - if ((objectHandleStacks.indexOfNextAvailableHandle[objectclass] - 1) < - objectHandleStacks.lowestIndexOfClass[objectclass]) - { - /* Error */ - prvTraceError("Attempt to free more handles than allocated!"); - } - else - { - objectHandleStacks.indexOfNextAvailableHandle[objectclass]--; - indexOfHandle = objectHandleStacks.indexOfNextAvailableHandle[objectclass]; - objectHandleStacks.objectHandles[indexOfHandle] = handle; - } -} - -/******************************************************************************* - * prvMarkObjectAsUsed - * - * Sets an "is used flag" on object creation, using the first byte of the name - * field. This allows for counting the number of used Object Table slots, even - * if no names have been set. - ******************************************************************************/ -void prvMarkObjectAsUsed(traceObjectClass objectclass, traceHandle handle) -{ - uint16_t idx = uiIndexOfObject(handle, objectclass); - RecorderDataPtr->ObjectPropertyTable.objbytes[idx] = 1; -} - -/******************************************************************************* - * prvStrncpy - * - * Private string copy function, to improve portability between compilers. - ******************************************************************************/ -static void prvStrncpy(char* dst, const char* src, uint32_t maxLength) -{ - uint32_t i; - for (i = 0; i < maxLength; i++) - { - dst[i] = src[i]; - if (src[i] == 0) - break; - } -} - -/******************************************************************************* - * prvTraceSetObjectName - * - * Registers the names of queues, semaphores and other kernel objects in the - * recorder's Object Property Table, at the given handle and object class. - ******************************************************************************/ -void prvTraceSetObjectName(traceObjectClass objectclass, - traceHandle handle, - const char* name) -{ - static uint16_t idx; - - TRACE_ASSERT(name != NULL, "prvTraceSetObjectName: name == NULL", TRC_UNUSED); - - if (objectclass >= TRACE_NCLASSES) - { - prvTraceError("Illegal object class in prvTraceSetObjectName"); - return; - } - - if (handle == 0) - { - prvTraceError("Illegal handle (0) in prvTraceSetObjectName."); - return; - } - - if (handle > RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass]) - { - /* ERROR */ - prvTraceError(pszTraceGetErrorNotEnoughHandles(objectclass)); - } - else - { - idx = uiIndexOfObject(handle, objectclass); - - if (traceErrorMessage == NULL) - { - prvStrncpy((char*)&(RecorderDataPtr->ObjectPropertyTable.objbytes[idx]), - name, - RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[ objectclass ]); - } - } -} - -traceString prvTraceOpenSymbol(const char* name, traceString userEventChannel) -{ - uint16_t result; - uint8_t len; - uint8_t crc; - TRACE_ALLOC_CRITICAL_SECTION(); - - len = 0; - crc = 0; - - TRACE_ASSERT(name != NULL, "prvTraceOpenSymbol: name == NULL", (traceString)0); - - prvTraceGetChecksum(name, &crc, &len); - - trcCRITICAL_SECTION_BEGIN(); - result = prvTraceLookupSymbolTableEntry(name, crc, len, userEventChannel); - if (!result) - { - result = prvTraceCreateSymbolTableEntry(name, crc, len, userEventChannel); - } - trcCRITICAL_SECTION_END(); - - return result; -} - - -/****************************************************************************** -* vTraceSetFrequency -* -* Registers the clock rate of the time source for the event timestamping. -* This is normally not required, but if the default value (TRC_HWTC_FREQ_HZ) -* should be incorrect for your setup, you can override it using this function. -* -* Must be called prior to vTraceEnable, and the time source is assumed to -* have a fixed clock frequency after the startup. -* -* Note that, in snapshot mode, the value is divided by the TRC_HWTC_DIVISOR. -* This is a software "prescaler" that is also applied on the timestamps. -*****************************************************************************/ -void vTraceSetFrequency(uint32_t frequency) -{ - timestampFrequency = frequency; -} - -/******************************************************************************* - * Supporting functions - ******************************************************************************/ - -/******************************************************************************* - * prvTraceError - * - * Called by various parts in the recorder. Stops the recorder and stores a - * pointer to an error message, which is printed by the monitor task. - * If you are not using the monitor task, you may use xTraceGetLastError() - * from your application to check if the recorder is OK. - * - * Note: If a recorder error is registered before vTraceStart is called, the - * trace start will be aborted. This can occur if any of the Nxxxx constants - * (e.g., TRC_CFG_NTASK) in trcConfig.h is too small. - ******************************************************************************/ -void prvTraceError(const char* msg) -{ - /* Stop the recorder */ - if (RecorderDataPtr != NULL) - { - vTraceStop(); - } - - /* If first error only... */ - if (traceErrorMessage == NULL) - { - traceErrorMessage = (char*)(intptr_t) msg; - if (RecorderDataPtr != NULL) - { - prvStrncpy(RecorderDataPtr->systemInfo, traceErrorMessage, 80); - RecorderDataPtr->internalErrorOccured = 1; - } - } -} - -void vTraceSetFilterMask(uint16_t filterMask) -{ - CurrentFilterMask = filterMask; -} - -void vTraceSetFilterGroup(uint16_t filterGroup) -{ - CurrentFilterGroup = filterGroup; -} - -/****************************************************************************** - * prvCheckDataToBeOverwrittenForMultiEntryEvents - * - * This checks if the next event to be overwritten is a multi-entry user event, - * i.e., a USER_EVENT followed by data entries. - * Such data entries do not have an event code at byte 0, as other events. - * All 4 bytes are user data, so the first byte of such data events must - * not be interpreted as type field. The number of data entries following - * a USER_EVENT is given in the event code of the USER_EVENT. - * Therefore, when overwriting a USER_EVENT (when using in ring-buffer mode) - * any data entries following must be replaced with NULL events (code 0). - * - * This is assumed to execute within a critical section... - *****************************************************************************/ - -#if (TRC_CFG_SNAPSHOT_MODE == TRC_SNAPSHOT_MODE_RING_BUFFER) -void prvCheckDataToBeOverwrittenForMultiEntryEvents(uint8_t nofEntriesToCheck) -{ - /* Generic "int" type is desired - should be 16 bit variable on 16 bit HW */ - unsigned int i = 0; - unsigned int e = 0; - - TRACE_ASSERT(nofEntriesToCheck != 0, - "prvCheckDataToBeOverwrittenForMultiEntryEvents: nofEntriesToCheck == 0", TRC_UNUSED); - - while (i < nofEntriesToCheck) - { - e = RecorderDataPtr->nextFreeIndex + i; - if ((RecorderDataPtr->eventData[e*4] > USER_EVENT) && - (RecorderDataPtr->eventData[e*4] < USER_EVENT + 16)) - { - uint8_t nDataEvents = (uint8_t)(RecorderDataPtr->eventData[e*4] - USER_EVENT); - if ((e + nDataEvents) < RecorderDataPtr->maxEvents) - { - (void)memset(& RecorderDataPtr->eventData[e*4], 0, (size_t) (4 + 4 * nDataEvents)); - } - } - else if (RecorderDataPtr->eventData[e*4] == DIV_XPS) - { - if ((e + 1) < RecorderDataPtr->maxEvents) - { - /* Clear 8 bytes */ - (void)memset(& RecorderDataPtr->eventData[e*4], 0, 4 + 4); - } - else - { - /* Clear 8 bytes, 4 first and 4 last */ - (void)memset(& RecorderDataPtr->eventData[0], 0, 4); - (void)memset(& RecorderDataPtr->eventData[e*4], 0, 4); - } - } - i++; - } -} -#endif - -/******************************************************************************* - * prvTraceUpdateCounters - * - * Updates the index of the event buffer. - ******************************************************************************/ -void prvTraceUpdateCounters(void) -{ - if (RecorderDataPtr->recorderActive == 0) - { - return; - } - - RecorderDataPtr->numEvents++; - - RecorderDataPtr->nextFreeIndex++; - - if (RecorderDataPtr->nextFreeIndex >= (TRC_CFG_EVENT_BUFFER_SIZE)) - { -#if (TRC_CFG_SNAPSHOT_MODE == TRC_SNAPSHOT_MODE_RING_BUFFER) - RecorderDataPtr->bufferIsFull = 1; - RecorderDataPtr->nextFreeIndex = 0; -#else - vTraceStop(); -#endif - } - -#if (TRC_CFG_SNAPSHOT_MODE == TRC_SNAPSHOT_MODE_RING_BUFFER) - prvCheckDataToBeOverwrittenForMultiEntryEvents(1); -#endif -} - -/****************************************************************************** - * prvTraceGetDTS - * - * Returns a differential timestamp (DTS), i.e., the time since - * last event, and creates an XTS event if the DTS does not fit in the - * number of bits given. The XTS event holds the MSB bytes of the DTS. - * - * The parameter param_maxDTS should be 0xFF for 8-bit dts or 0xFFFF for - * events with 16-bit dts fields. - *****************************************************************************/ -uint16_t prvTraceGetDTS(uint16_t param_maxDTS) -{ - static uint32_t old_timestamp = 0; - XTSEvent* xts = 0; - uint32_t dts = 0; - uint32_t timestamp = 0; - - TRACE_ASSERT(param_maxDTS == 0xFF || param_maxDTS == 0xFFFF, "prvTraceGetDTS: Invalid value for param_maxDTS", 0); - - - if (RecorderDataPtr->frequency == 0) - { - if (timestampFrequency != 0) - { - /* If to override default TRC_HWTC_FREQ_HZ value with value set by vTraceSetFrequency */ - RecorderDataPtr->frequency = timestampFrequency / (TRC_HWTC_DIVISOR); - } - else if (init_hwtc_count != (TRC_HWTC_COUNT)) - { - /* If using default value and timer has been started. - Note: If the default frequency value set here would be incorrect, e.g., - if the timer has actually not been configured yet, override this - with vTraceSetFrequency. - */ - RecorderDataPtr->frequency = (TRC_HWTC_FREQ_HZ) / (TRC_HWTC_DIVISOR); - } - /* If no override (vTraceSetFrequency) and timer inactive -> no action */ - } - - /************************************************************************** - * The below statements read the timestamp from the timer port module. - * If necessary, whole seconds are extracted using division while the rest - * comes from the modulo operation. - **************************************************************************/ - - prvTracePortGetTimeStamp(×tamp); - - /*************************************************************************** - * Since dts is unsigned the result will be correct even if timestamp has - * wrapped around. - ***************************************************************************/ - dts = timestamp - old_timestamp; - old_timestamp = timestamp; - - if (RecorderDataPtr->frequency > 0) - { - /* Check if dts > 1 second */ - if (dts > RecorderDataPtr->frequency) - { - /* More than 1 second has passed */ - RecorderDataPtr->absTimeLastEventSecond += dts / RecorderDataPtr->frequency; - /* The part that is not an entire second is added to absTimeLastEvent */ - RecorderDataPtr->absTimeLastEvent += dts % RecorderDataPtr->frequency; - } - else - { - RecorderDataPtr->absTimeLastEvent += dts; - } - - /* Check if absTimeLastEvent >= 1 second */ - if (RecorderDataPtr->absTimeLastEvent >= RecorderDataPtr->frequency) - { - /* RecorderDataPtr->absTimeLastEvent is more than or equal to 1 second, but always less than 2 seconds */ - RecorderDataPtr->absTimeLastEventSecond++; - RecorderDataPtr->absTimeLastEvent -= RecorderDataPtr->frequency; - /* RecorderDataPtr->absTimeLastEvent is now less than 1 second */ - } - } - else - { - /* Special case if the recorder has not yet started (frequency may be uninitialized, i.e., zero) */ - RecorderDataPtr->absTimeLastEvent = timestamp; - } - - /* If the dts (time since last event) does not fit in event->dts (only 8 or 16 bits) */ - if (dts > param_maxDTS) - { - /* Create an XTS event (eXtended TimeStamp) containing the higher dts bits*/ - xts = (XTSEvent*) prvTraceNextFreeEventBufferSlot(); - - if (xts != NULL) - { - if (param_maxDTS == 0xFFFF) - { - xts->type = XTS16; - xts->xts_16 = (uint16_t)((dts / 0x10000) & 0xFFFF); - xts->xts_8 = 0; - } - else if (param_maxDTS == 0xFF) - { - xts->type = XTS8; - xts->xts_16 = (uint16_t)((dts / 0x100) & 0xFFFF); - xts->xts_8 = (uint8_t)((dts / 0x1000000) & 0xFF); - } - else - { - prvTraceError("Bad param_maxDTS in prvTraceGetDTS"); - } - prvTraceUpdateCounters(); - } - } - - return (uint16_t)dts & param_maxDTS; -} - -/******************************************************************************* - * prvTraceLookupSymbolTableEntry - * - * Find an entry in the symbol table, return 0 if not present. - * - * The strings are stored in a byte pool, with four bytes of "meta-data" for - * every string. - * byte 0-1: index of next entry with same checksum (for fast lookup). - * byte 2-3: reference to a symbol table entry, a label for vTracePrintF - * format strings only (the handle of the destination channel). - * byte 4..(4 + length): the string (object name or user event label), with - * zero-termination - ******************************************************************************/ -traceString prvTraceLookupSymbolTableEntry(const char* name, - uint8_t crc6, - uint8_t len, - traceString chn) -{ - uint16_t i = RecorderDataPtr->SymbolTable.latestEntryOfChecksum[ crc6 ]; - - TRACE_ASSERT(name != NULL, "prvTraceLookupSymbolTableEntry: name == NULL", (traceString)0); - TRACE_ASSERT(len != 0, "prvTraceLookupSymbolTableEntry: len == 0", (traceString)0); - - while (i != 0) - { - if (RecorderDataPtr->SymbolTable.symbytes[i + 2] == (chn & 0x00FF)) - { - if (RecorderDataPtr->SymbolTable.symbytes[i + 3] == (chn / 0x100)) - { - if (RecorderDataPtr->SymbolTable.symbytes[i + 4 + len] == '\0') - { - if (strncmp((char*)(& RecorderDataPtr->SymbolTable.symbytes[i + 4]), name, len) == 0) - { - break; /* found */ - } - } - } - } - i = (uint16_t)(RecorderDataPtr->SymbolTable.symbytes[i] + (RecorderDataPtr->SymbolTable.symbytes[i + 1] * 0x100)); - } - return i; -} - -/******************************************************************************* - * prvTraceCreateSymbolTableEntry - * - * Creates an entry in the symbol table, independent if it exists already. - * - * The strings are stored in a byte pool, with four bytes of "meta-data" for - * every string. - * byte 0-1: index of next entry with same checksum (for fast lookup). - * byte 2-3: reference to a symbol table entry, a label for vTracePrintF - * format strings only (the handle of the destination channel). - * byte 4..(4 + length): the string (object name or user event label), with - * zero-termination - ******************************************************************************/ -uint16_t prvTraceCreateSymbolTableEntry(const char* name, - uint8_t crc6, - uint8_t len, - traceString channel) -{ - uint16_t ret = 0; - - TRACE_ASSERT(name != NULL, "prvTraceCreateSymbolTableEntry: name == NULL", 0); - TRACE_ASSERT(len != 0, "prvTraceCreateSymbolTableEntry: len == 0", 0); - - if (RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + len + 4 >= (TRC_CFG_SYMBOL_TABLE_SIZE)) - { - prvTraceError("Symbol table full. Increase TRC_CFG_SYMBOL_TABLE_SIZE in trcConfig.h"); - ret = 0; - } - else - { - - RecorderDataPtr->SymbolTable.symbytes - [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex] = - (uint8_t)(RecorderDataPtr->SymbolTable.latestEntryOfChecksum[ crc6 ] & 0x00FF); - - RecorderDataPtr->SymbolTable.symbytes - [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 1] = - (uint8_t)(RecorderDataPtr->SymbolTable.latestEntryOfChecksum[ crc6 ] / 0x100); - - RecorderDataPtr->SymbolTable.symbytes - [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 2] = - (uint8_t)(channel & 0x00FF); - - RecorderDataPtr->SymbolTable.symbytes - [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 3] = - (uint8_t)(channel / 0x100); - - /* set name (bytes 4...4+len-1) */ - prvStrncpy((char*)&(RecorderDataPtr->SymbolTable.symbytes - [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 4]), name, len); - - /* Set zero termination (at offset 4+len) */ - RecorderDataPtr->SymbolTable.symbytes - [RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 4 + len] = '\0'; - - /* store index of entry (for return value, and as head of LL[crc6]) */ - RecorderDataPtr->SymbolTable.latestEntryOfChecksum - [ crc6 ] = (uint16_t)RecorderDataPtr->SymbolTable.nextFreeSymbolIndex; - - RecorderDataPtr->SymbolTable.nextFreeSymbolIndex += (uint32_t) (len + 5); - - ret = (uint16_t)(RecorderDataPtr->SymbolTable.nextFreeSymbolIndex - (uint8_t)(len + 5)); - } - - return ret; -} - - -/******************************************************************************* - * prvTraceGetChecksum - * - * Calculates a simple 6-bit checksum from a string, used to index the string - * for fast symbol table lookup. - ******************************************************************************/ -void prvTraceGetChecksum(const char *pname, uint8_t* pcrc, uint8_t* plength) -{ - unsigned char c; - int length = 1; /* Should be 1 to account for '\0' */ - int crc = 0; - - TRACE_ASSERT(pname != NULL, "prvTraceGetChecksum: pname == NULL", TRC_UNUSED); - TRACE_ASSERT(pcrc != NULL, "prvTraceGetChecksum: pcrc == NULL", TRC_UNUSED); - TRACE_ASSERT(plength != NULL, "prvTraceGetChecksum: plength == NULL", TRC_UNUSED); - - if (pname != (const char *) 0) - { - for (; (c = (unsigned char) *pname++) != '\0';) - { - crc += c; - length++; - } - } - *pcrc = (uint8_t)(crc & 0x3F); - *plength = (uint8_t)length; -} - -#if (TRC_CFG_USE_16BIT_OBJECT_HANDLES == 1) - -static void prvTraceStoreXID(traceHandle handle); - -/****************************************************************************** - * prvTraceStoreXID - * - * Stores an XID (eXtended IDentifier) event. - * This is used if an object/task handle is larger than 255. - * The parameter "handle" is the full (16 bit) handle, assumed to be 256 or - * larger. Handles below 256 should not use this function. - * - * NOTE: this function MUST be called from within a critical section. - *****************************************************************************/ -static void prvTraceStoreXID(traceHandle handle) -{ - XPSEvent* xid; - - TRACE_ASSERT(handle >= 256, "prvTraceStoreXID: Handle < 256", TRC_UNUSED); - - xid = (XPSEvent*)prvTraceNextFreeEventBufferSlot(); - - if (xid != NULL) - { - xid->type = XID; - - /* This function is (only) used when traceHandle is 16 bit... */ - xid->xps_16 = handle; - - prvTraceUpdateCounters(); - } -} - -static uint8_t prvTraceGet8BitHandle(traceHandle handle) -{ - if (handle > 255) - { - prvTraceStoreXID(handle); - /* The full handle (16 bit) is stored in the XID event. - This code (255) is used instead of zero (which is an error code).*/ - return 255; - } - return (uint8_t)(handle & 0xFF); -} -#endif /*(TRC_CFG_USE_16BIT_OBJECT_HANDLES == 1)*/ - - -/* If using DWT timestamping (default on ARM Cortex-M3, M4 and M7), make sure the DWT unit is initialized. */ -#ifndef TRC_CFG_ARM_CM_USE_SYSTICK -#if ((TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_Cortex_M) && (defined (__CORTEX_M) && (__CORTEX_M >= 0x03))) -void prvTraceInitCortexM() -{ - /* Ensure that the DWT registers are unlocked and can be modified. */ - TRC_REG_ITM_LOCKACCESS = TRC_ITM_LOCKACCESS_UNLOCK; - - /* Make sure DWT is enabled, if supported */ - TRC_REG_DEMCR |= TRC_DEMCR_TRCENA; - - do{ - /* Verify that DWT is supported */ - if (TRC_REG_DEMCR == 0) - { - /* This function is called on Cortex-M3, M4 and M7 devices to initialize - the DWT unit, assumed present. The DWT cycle counter is used for timestamping. - - If the below error is produced, the DWT unit does not seem to be available. - - In that case, define the macro TRC_CFG_ARM_CM_USE_SYSTICK in your build - to use SysTick timestamping instead, or define your own timestamping by - setting TRC_CFG_HARDWARE_PORT to TRC_HARDWARE_PORT_APPLICATION_DEFINED - and make the necessary definitions, as explained in trcHardwarePort.h.*/ - - prvTraceError("DWT unit not available, see code comment."); - break; - } - - /* Verify that DWT_CYCCNT is supported */ - if (TRC_REG_DWT_CTRL & TRC_DWT_CTRL_NOCYCCNT) - { - /* This function is called on Cortex-M3, M4 and M7 devices to initialize - the DWT unit, assumed present. The DWT cycle counter is used for timestamping. - - If the below error is produced, the cycle counter does not seem to be available. - - In that case, define the macro TRC_CFG_ARM_CM_USE_SYSTICK in your build - to use SysTick timestamping instead, or define your own timestamping by - setting TRC_CFG_HARDWARE_PORT to TRC_HARDWARE_PORT_APPLICATION_DEFINED - and make the necessary definitions, as explained in trcHardwarePort.h.*/ - - prvTraceError("DWT_CYCCNT not available, see code comment."); - break; - } - - /* Reset the cycle counter */ - TRC_REG_DWT_CYCCNT = 0; - - /* Enable the cycle counter */ - TRC_REG_DWT_CTRL |= TRC_DWT_CTRL_CYCCNTENA; - - }while(0); /* breaks above jump here */ -} -#endif -#endif - -/****************************************************************************** - * prvTracePortGetTimeStamp - * - * Returns the current time based on the HWTC macros which provide a hardware - * isolation layer towards the hardware timer/counter. - * - * The HWTC macros and prvTracePortGetTimeStamp is the main porting issue - * or the trace recorder library. Typically you should not need to change - * the code of prvTracePortGetTimeStamp if using the HWTC macros. - * - ******************************************************************************/ -void prvTracePortGetTimeStamp(uint32_t *pTimestamp) -{ - static uint32_t last_hwtc_count = 0; - uint32_t hwtc_count = 0; - -#if TRC_HWTC_TYPE == TRC_OS_TIMER_INCR || TRC_HWTC_TYPE == TRC_OS_TIMER_DECR - /* systick based timer */ - static uint32_t last_traceTickCount = 0; - uint32_t traceTickCount = 0; -#else /*TRC_HWTC_TYPE == TRC_OS_TIMER_INCR || TRC_HWTC_TYPE == TRC_OS_TIMER_DECR*/ - /* Free running timer */ - static uint32_t last_hwtc_rest = 0; - uint32_t diff = 0; - uint32_t diff_scaled = 0; -#endif /*TRC_HWTC_TYPE == TRC_OS_TIMER_INCR || TRC_HWTC_TYPE == TRC_OS_TIMER_DECR*/ - - if (trace_disable_timestamp == 1) - { - if (pTimestamp) - *pTimestamp = last_timestamp; - return; - } - - /* Retrieve TRC_HWTC_COUNT only once since the same value should be used all throughout this function. */ -#if (TRC_HWTC_TYPE == TRC_OS_TIMER_INCR || TRC_HWTC_TYPE == TRC_FREE_RUNNING_32BIT_INCR) - /* Get the increasing tick count */ - hwtc_count = (TRC_HWTC_COUNT); -#elif (TRC_HWTC_TYPE == TRC_OS_TIMER_DECR || TRC_HWTC_TYPE == TRC_FREE_RUNNING_32BIT_DECR) - /* Convert decreasing tick count into increasing tick count */ - hwtc_count = (TRC_HWTC_PERIOD) - (TRC_HWTC_COUNT); -#else - #error "TRC_HWTC_TYPE has unexpected value" -#endif - -#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Win32) - /* The Win32 port uses ulGetRunTimeCounterValue for timestamping, which in turn - uses QueryPerformanceCounter. That function is not always reliable when used over - multiple threads. We must therefore handle rare cases where the timestamp is less - than the previous. In practice, this should "never" roll over since the - performance counter is 64 bit wide. */ - - if (last_hwtc_count > hwtc_count) - { - hwtc_count = last_hwtc_count; - } -#endif - -#if (TRC_HWTC_TYPE == TRC_OS_TIMER_INCR || TRC_HWTC_TYPE == TRC_OS_TIMER_DECR) - /* Timestamping is based on a timer that wraps at TRC_HWTC_PERIOD */ - if (last_traceTickCount - uiTraceTickCount - 1 < 0x80000000) - { - /* This means last_traceTickCount is higher than uiTraceTickCount, - so we have previously compensated for a missed tick. - Therefore we use the last stored value because that is more accurate. */ - traceTickCount = last_traceTickCount; - } - else - { - /* Business as usual */ - traceTickCount = uiTraceTickCount; - } - - /* Check for overflow. May occur if the update of uiTraceTickCount has been - delayed due to disabled interrupts. */ - if (traceTickCount == last_traceTickCount && hwtc_count < last_hwtc_count) - { - /* A trace tick has occurred but not been executed by the kernel, so we compensate manually. */ - traceTickCount++; - } - - /* Check if the return address is OK, then we perform the calculation. */ - if (pTimestamp) - { - /* Get timestamp from trace ticks. Scale down the period to avoid unwanted overflows. */ - last_timestamp = traceTickCount * ((TRC_HWTC_PERIOD) / (TRC_HWTC_DIVISOR)); - /* Increase timestamp by (hwtc_count + "lost hardware ticks from scaling down period") / TRC_HWTC_DIVISOR. */ - last_timestamp += (hwtc_count + traceTickCount * ((TRC_HWTC_PERIOD) % (TRC_HWTC_DIVISOR))) / (TRC_HWTC_DIVISOR); - } - /* Store the previous value */ - last_traceTickCount = traceTickCount; - -#else /*(TRC_HWTC_TYPE == TRC_OS_TIMER_INCR || TRC_HWTC_TYPE == TRC_OS_TIMER_DECR)*/ - - /* Timestamping is based on a free running timer */ - /* This part handles free running clocks that can be scaled down to avoid too large DTS values. - Without this, the scaled timestamp will incorrectly wrap at (2^32 / TRC_HWTC_DIVISOR) ticks. - The scaled timestamp returned from this function is supposed to go from 0 -> 2^32, which in real time would represent (0 -> 2^32 * TRC_HWTC_DIVISOR) ticks. */ - - /* First we see how long time has passed since the last timestamp call, and we also add the ticks that was lost when we scaled down the last time. */ - diff = (hwtc_count - last_hwtc_count) + last_hwtc_rest; - - /* Scale down the diff */ - diff_scaled = diff / (TRC_HWTC_DIVISOR); - - /* Find out how many ticks were lost when scaling down, so we can add them the next time */ - last_hwtc_rest = diff % (TRC_HWTC_DIVISOR); - - /* We increase the scaled timestamp by the scaled amount */ - last_timestamp += diff_scaled; -#endif /*(TRC_HWTC_TYPE == TRC_OS_TIMER_INCR || TRC_HWTC_TYPE == TRC_OS_TIMER_DECR)*/ - - /* Is anyone interested in the results? */ - if (pTimestamp) - *pTimestamp = last_timestamp; - - /* Store the previous value */ - last_hwtc_count = hwtc_count; -} - -#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/ - -#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcStreamingRecorder.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcStreamingRecorder.c deleted file mode 100755 index 2946a7e..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcStreamingRecorder.c +++ /dev/null @@ -1,1896 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v4.1.5 - * Percepio AB, www.percepio.com - * - * trcStreamingRecorder.c - * - * The generic core of the trace recorder's streaming mode. - * - * Terms of Use - * This file is part of the trace recorder library (RECORDER), which is the - * intellectual property of Percepio AB (PERCEPIO) and provided under a - * license as follows. - * The RECORDER may be used free of charge for the purpose of recording data - * intended for analysis in PERCEPIO products. It may not be used or modified - * for other purposes without explicit permission from PERCEPIO. - * You may distribute the RECORDER in its original source code form, assuming - * this text (terms of use, disclaimer, copyright notice) is unchanged. You are - * allowed to distribute the RECORDER with minor modifications intended for - * configuration or porting of the RECORDER, e.g., to allow using it on a - * specific processor, processor family or with a specific communication - * interface. Any such modifications should be documented directly below - * this comment block. - * - * Disclaimer - * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty - * as to its use or performance. PERCEPIO does not and cannot warrant the - * performance or results you may obtain by using the RECORDER or documentation. - * PERCEPIO make no warranties, express or implied, as to noninfringement of - * third party rights, merchantability, or fitness for any particular purpose. - * In no event will PERCEPIO, its technology partners, or distributors be liable - * to you for any consequential, incidental or special damages, including any - * lost profits or lost savings, even if a representative of PERCEPIO has been - * advised of the possibility of such damages, or for any claim by any third - * party. Some jurisdictions do not allow the exclusion or limitation of - * incidental, consequential or special damages, or the exclusion of implied - * warranties or limitations on how long an implied warranty may last, so the - * above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2018. - * www.percepio.com - ******************************************************************************/ - -#include "trcRecorder.h" - -#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) - -#if (TRC_USE_TRACEALYZER_RECORDER == 1) - -#include -#include - -typedef struct{ - uint16_t EventID; - uint16_t EventCount; - uint32_t TS; -} BaseEvent; - -typedef struct{ - BaseEvent base; - uint32_t param1; -} EventWithParam_1; - -typedef struct{ - BaseEvent base; - uint32_t param1; - uint32_t param2; -} EventWithParam_2; - -typedef struct{ - BaseEvent base; - uint32_t param1; - uint32_t param2; - uint32_t param3; -} EventWithParam_3; - -/* Used in event functions with variable number of parameters. */ -typedef struct -{ - BaseEvent base; - uint32_t data[15]; /* maximum payload size */ -} largestEventType; - -typedef struct{ - uint32_t psf; - uint16_t version; - uint16_t platform; - uint32_t options; - uint16_t symbolSize; - uint16_t symbolCount; - uint16_t objectDataSize; - uint16_t objectDataCount; -} PSFHeaderInfo; - - -/* The size of each slot in the Symbol Table */ -#define SYMBOL_TABLE_SLOT_SIZE (sizeof(uint32_t) + (((TRC_CFG_SYMBOL_MAX_LENGTH)+(sizeof(uint32_t)-1))/sizeof(uint32_t))*sizeof(uint32_t)) - -#define OBJECT_DATA_SLOT_SIZE (sizeof(uint32_t) + sizeof(uint32_t)) - -/* The total size of the Symbol Table */ -#define SYMBOL_TABLE_BUFFER_SIZE ((TRC_CFG_SYMBOL_TABLE_SLOTS) * SYMBOL_TABLE_SLOT_SIZE) - -/* The total size of the Object Data Table */ -#define OBJECT_DATA_TABLE_BUFFER_SIZE ((TRC_CFG_OBJECT_DATA_SLOTS) * OBJECT_DATA_SLOT_SIZE) - -/* The Symbol Table type - just a byte array */ -typedef struct{ - union - { - uint32_t pSymbolTableBufferUINT32[SYMBOL_TABLE_BUFFER_SIZE / sizeof(uint32_t)]; - uint8_t pSymbolTableBufferUINT8[SYMBOL_TABLE_BUFFER_SIZE]; - } SymbolTableBuffer; -} SymbolTable; - -/* The Object Data Table type - just a byte array */ -typedef struct{ - union - { - uint32_t pObjectDataTableBufferUINT32[OBJECT_DATA_TABLE_BUFFER_SIZE / sizeof(uint32_t)]; - uint8_t pObjectDataTableBufferUINT8[OBJECT_DATA_TABLE_BUFFER_SIZE]; - } ObjectDataTableBuffer; -} ObjectDataTable; - -typedef struct{ - uint16_t Status; /* 16 bit to avoid implicit padding (warnings) */ - uint16_t BytesRemaining; - char* WritePointer; -} PageType; - -/* Code used for "task address" when no task has started. (NULL = idle task) */ -#define HANDLE_NO_TASK 2 - -#define PAGE_STATUS_FREE 0 -#define PAGE_STATUS_WRITE 1 -#define PAGE_STATUS_READ 2 - -#define PSF_ASSERT(_assert, _err) if (! (_assert)){ prvTraceError(_err); return; } - -/* Part of the PSF format - encodes the number of 32-bit params in an event */ -#define PARAM_COUNT(n) ((n & 0xF) << 12) - -/* The Symbol Table instance - keeps names of tasks and other named objects. */ -static SymbolTable symbolTable = { { { 0 } } }; - -/* This points to the first unused entry in the symbol table. */ -static uint32_t firstFreeSymbolTableIndex = 0; - -/* The Object Data Table instance - keeps initial priorities of tasks. */ -static ObjectDataTable objectDataTable = { { { 0 } } }; - -/* This points to the first unused entry in the object data table. */ -static uint32_t firstFreeObjectDataTableIndex = 0; - -/* Keeps track of ISR nesting */ -static uint32_t ISR_stack[TRC_CFG_MAX_ISR_NESTING]; - -/* Keeps track of ISR nesting */ -static int8_t ISR_stack_index = -1; - -/* Any error that occurred in the recorder (also creates User Event) */ -static int errorCode = 0; - -/* Counts the number of trace sessions (not yet used) */ -static uint32_t SessionCounter = 0u; - -/* Master switch for recording (0 => Disabled, 1 => Enabled) */ -uint32_t RecorderEnabled = 0u; - -/* Used to determine endian of data (big/little) */ -static uint32_t PSFEndianessIdentifier = 0x50534600; - -/* Used to interpret the data format */ -static uint16_t FormatVersion = 0x0004; - -/* The number of events stored. Used as event sequence number. */ -static uint32_t eventCounter = 0; - -/* Remembers if an earlier ISR in a sequence of adjacent ISRs has triggered a task switch. -In that case, vTraceStoreISREnd does not store a return to the previously executing task. */ -int32_t isPendingContextSwitch = 0; - -uint32_t uiTraceTickCount = 0; -uint32_t timestampFrequency = 0; -uint32_t DroppedEventCounter = 0; -uint32_t TotalBytesRemaining_LowWaterMark = (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT) * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE); -uint32_t TotalBytesRemaining = (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT) * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE); - -PageType PageInfo[TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT]; - -char* EventBuffer = NULL; - -/******************************************************************************* - * NoRoomForSymbol - * - * Incremented on prvTraceSaveSymbol if no room for saving the symbol name. This - * is used for storing the names of: - * - Tasks - * - Named ISRs (xTraceSetISRProperties) - * - Named kernel objects (vTraceStoreKernelObjectName) - * - User event channels (xTraceRegisterString) - * - * This variable should be zero. If not, it shows the number of missing slots so - * far. In that case, increment SYMBOL_TABLE_SLOTS with (at least) this value. - ******************************************************************************/ -volatile uint32_t NoRoomForSymbol = 0; - -/******************************************************************************* - * NoRoomForObjectData - * - * Incremented on prvTraceSaveObjectData if no room for saving the object data, - * i.e., the base priorities of tasks. There must be one slot for each task. - * If not, this variable will show the difference. - * - * This variable should be zero. If not, it shows the number of missing slots so - * far. In that case, increment OBJECT_DATA_SLOTS with (at least) this value. - ******************************************************************************/ -volatile uint32_t NoRoomForObjectData = 0; - -/******************************************************************************* - * LongestSymbolName - * - * Updated in prvTraceSaveSymbol. Should not exceed TRC_CFG_SYMBOL_MAX_LENGTH, - * otherwise symbol names will be truncated. In that case, set - * TRC_CFG_SYMBOL_MAX_LENGTH to (at least) this value. - ******************************************************************************/ -volatile uint32_t LongestSymbolName = 0; - -/******************************************************************************* - * MaxBytesTruncated - * - * Set in prvTraceStoreStringEvent if the total data payload exceeds 60 bytes, - * including data arguments and the string. For user events, that is 52 bytes - * for string and data arguments. In that is exceeded, the event is truncated - * (usually only the string, unless more than 15 parameters) and this variable - * holds the maximum number of truncated bytes, from any event. - ******************************************************************************/ -volatile uint32_t MaxBytesTruncated = 0; - -uint16_t CurrentFilterMask = 0xFFFF; - -uint16_t CurrentFilterGroup = FilterGroup0; - -/* Internal common function for storing string events */ -static void prvTraceStoreStringEventHelper( int nArgs, - uint16_t eventID, - traceString userEvtChannel, - int len, - const char* str, - va_list* vl); - -/* Not static to avoid warnings from SysGCC/PPC */ -void prvTraceStoreSimpleStringEventHelper(traceString userEvtChannel, - const char* str); - - -/* Stores the header information on Start */ -static void prvTraceStoreHeader(void); - -/* Stores the symbol table on Start */ -static void prvTraceStoreSymbolTable(void); - -/* Stores the object table on Start */ -static void prvTraceStoreObjectDataTable(void); - -/* Store the Timestamp Config on Start */ -static void prvTraceStoreTSConfig(void); - -/* Store the current warnings */ -static void prvTraceStoreWarnings(void); - -/* Internal function for starting/stopping the recorder. */ -static void prvSetRecorderEnabled(uint32_t isEnabled); - -/* Mark the page read as complete. */ -static void prvPageReadComplete(int pageIndex); - -/* Retrieve a buffer page to write to. */ -static int prvAllocateBufferPage(int prevPage); - -/* Get the current buffer page index (return value) and the number -of valid bytes in the buffer page (bytesUsed). */ -static int prvGetBufferPage(int32_t* bytesUsed); - -/* Performs timestamping using definitions in trcHardwarePort.h */ -static uint32_t prvGetTimestamp32(void); - -/* Signal an error. */ -void prvTraceError(int errCode); - -/* Signal an warning (does not stop the recorder). */ -void prvTraceWarning(int errCode); - -/****************************************************************************** - * vTraceInstanceFinishedNow - * - * Creates an event that ends the current task instance at this very instant. - * This makes the viewer to splits the current fragment at this point and begin - * a new actor instance, even if no task-switch has occurred. - *****************************************************************************/ -void vTraceInstanceFinishedNow(void) -{ - prvTraceStoreEvent0(PSF_EVENT_IFE_DIRECT); -} - -/****************************************************************************** - * vTraceInstanceFinishedNext - * - * Marks the current "task instance" as finished on the next kernel call. - * - * If that kernel call is blocking, the instance ends after the blocking event - * and the corresponding return event is then the start of the next instance. - * If the kernel call is not blocking, the viewer instead splits the current - * fragment right before the kernel call, which makes this call the first event - * of the next instance. - *****************************************************************************/ -void vTraceInstanceFinishedNext(void) -{ - prvTraceStoreEvent0(PSF_EVENT_IFE_NEXT); -} - -/******************************************************************************* - * vTraceStoreKernelObjectName - * - * Parameter object: pointer to the Event Group that shall be named - * Parameter name: the name to set (const string literal) - * - * Sets a name for a kernel object for display in Tracealyzer. - ******************************************************************************/ -void vTraceStoreKernelObjectName(void* object, const char* name) -{ - /* Always save in symbol table, if the recording has not yet started */ - prvTraceSaveSymbol(object, name); - - prvTraceStoreStringEvent(1, PSF_EVENT_OBJ_NAME, name, (uint32_t)object); -} - - -/****************************************************************************** -* vTraceSetFrequency -* -* Registers the clock rate of the time source for the event timestamping. -* This is normally not required, but if the default value (TRC_HWTC_FREQ_HZ) -* should be incorrect for your setup, you can override it using this function. -* -* Must be called prior to vTraceEnable, and the time source is assumed to -* have a fixed clock frequency after the startup. -*****************************************************************************/ -void vTraceSetFrequency(uint32_t frequency) -{ - timestampFrequency = frequency; -} - -#if (TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) - -/******************************************************************************* -* xTraceRegisterString -* -* Stores a name for a user event channel, returns the handle. -******************************************************************************/ -traceString xTraceRegisterString(const char* name) -{ - prvTraceSaveSymbol((const void*)name, name); - - /* Always save in symbol table, if the recording has not yet started */ - prvTraceStoreStringEvent(1, PSF_EVENT_OBJ_NAME, (const char*)name, (uint32_t)name); - - return (traceString)name; -} - -/****************************************************************************** - * vTracePrint - * - * Generates "User Events", with unformatted text. - * - * User Events can be used for very efficient application logging, and are shown - * as yellow labels in the main trace view. - * - * You may group User Events into User Event Channels. The yellow User Event - * labels shows the logged string, preceded by the channel name within - * brackets. For example: - * - * "[MyChannel] Hello World!" - * - * The User Event Channels are shown in the View Filter, which makes it easy to - * select what User Events you wish to display. User Event Channels are created - * using xTraceRegisterString(). - * - * Example: - * - * traceString chn = xTraceRegisterString("MyChannel"); - * ... - * vTracePrint(chn, "Hello World!"); - * - ******************************************************************************/ -void vTracePrint(traceString chn, const char* str) -{ - prvTraceStoreSimpleStringEventHelper(chn, str); -} - - -/******************************************************************************* -* vTraceConsoleChannelPrintF -* -* Wrapper for vTracePrint, using the default channel. Can be used as a drop-in -* replacement for printf and similar functions, e.g. in a debug logging macro. -* -* Example: -* -* // Old: #define LogString debug_console_printf -* -* // New, log to Tracealyzer instead: -* #define LogString vTraceConsoleChannelPrintF -* ... -* LogString("My value is: %d", myValue); -******************************************************************************/ -void vTraceConsoleChannelPrintF(const char* fmt, ...) -{ - va_list vl; - char tempBuf[60]; - static traceString consoleChannel = NULL; - - if (consoleChannel == NULL) - consoleChannel = xTraceRegisterString("Debug Console"); - - va_start(vl, fmt); - vsnprintf(tempBuf, 60, fmt, vl); - vTracePrint(consoleChannel, tempBuf); - va_end(vl); -} - -/****************************************************************************** - * vTracePrintF - * - * Generates "User Events", with formatted text and data, similar to a "printf". - * It is very fast since the actual formatting is done on the host side when the - * trace is displayed. - * - * User Events can be used for very efficient application logging, and are shown - * as yellow labels in the main trace view. - * An advantage of User Events is that data can be plotted in the "User Event - * Signal Plot" view, visualizing any data you log as User Events, discrete - * states or control system signals (e.g. system inputs or outputs). - * - * You may group User Events into User Event Channels. The yellow User Event - * labels show the logged string, preceded by the channel name within brackets. - * - * Example: - * - * "[MyChannel] Hello World!" - * - * The User Event Channels are shown in the View Filter, which makes it easy to - * select what User Events you wish to display. User Event Channels are created - * using xTraceRegisterString(). - * - * Example: - * - * traceString adc_uechannel = xTraceRegisterString("ADC User Events"); - * ... - * vTracePrintF(adc_uechannel, - * "ADC channel %d: %d volts", - * ch, adc_reading); - * - * All data arguments are assumed to be 32 bit wide. The following formats are - * supported: - * %d - signed integer. The following width and padding format is supported: "%05d" -> "-0042" and "%5d" -> " -42" - * %u - unsigned integer. The following width and padding format is supported: "%05u" -> "00042" and "%5u" -> " 42" - * %X - hexadecimal (uppercase). The following width and padding format is supported: "%04X" -> "002A" and "%4X" -> " 2A" - * %x - hexadecimal (lowercase). The following width and padding format is supported: "%04x" -> "002a" and "%4x" -> " 2a" - * %s - string (currently, this must be an earlier stored symbol name) - * - * Up to 15 data arguments are allowed, with a total size of maximum 60 byte - * including 8 byte for the base event fields and the format string. So with - * one data argument, the maximum string length is 48 chars. If this is exceeded - * the string is truncated (4 bytes at a time). - * - ******************************************************************************/ -void vTracePrintF(traceString chn, const char* fmt, ...) -{ - va_list vl; - int i = 0; - - int nArgs = 0; - - /* Count the number of arguments in the format string (e.g., %d) */ - for (i = 0; (fmt[i] != 0) && (i < 52); i++) - { - if (fmt[i] == '%') - { - if (fmt[i + 1] != 0 && fmt[i + 1] != '%') - { - nArgs++; /* Found an argument */ - } - - i++; /* Move past format specifier or non-argument '%' */ - } - } - - va_start(vl, fmt); - - if (chn != NULL) - { - prvTraceStoreStringEventHelper(nArgs, (uint16_t)(PSF_EVENT_USER_EVENT + nArgs + 1), chn, i, fmt, &vl); - } - else - { - prvTraceStoreStringEventHelper(nArgs, (uint16_t)(PSF_EVENT_USER_EVENT + nArgs), chn, i, fmt, &vl); - } - va_end(vl); -} -#endif /* (TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) */ - -/******************************************************************************* - * xTraceSetISRProperties - * - * Stores a name and priority level for an Interrupt Service Routine, to allow - * for better visualization. Returns a traceHandle used by vTraceStoreISRBegin. - * - * Example: - * #define PRIO_ISR_TIMER1 3 // the hardware priority of the interrupt - * ... - * traceHandle Timer1Handle = xTraceSetISRProperties("ISRTimer1", PRIO_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin(Timer1Handle); - * ... - * vTraceStoreISREnd(0); - * } - * - ******************************************************************************/ -traceHandle xTraceSetISRProperties(const char* name, uint8_t priority) -{ - /* Save object data in object data table */ - prvTraceSaveObjectData((const void*)name, priority); - - /* Note: "name" is used both as a string argument, and the address as ID */ - prvTraceStoreStringEvent(2, PSF_EVENT_DEFINE_ISR, name, name, priority); - - /* Always save in symbol table, if the recording has not yet started */ - prvTraceSaveSymbol((const void*)name, name); - - return (traceHandle)name; -} - -/******************************************************************************* - * vTraceStoreISRBegin - * - * Registers the beginning of an Interrupt Service Routine, using a traceHandle - * provided by xTraceSetISRProperties. - * - * Example: - * #define PRIO_ISR_TIMER1 3 // the hardware priority of the interrupt - * ... - * traceHandle Timer1Handle = xTraceSetISRProperties("ISRTimer1", PRIO_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin(Timer1Handle); - * ... - * vTraceStoreISREnd(0); - * } - * - ******************************************************************************/ -void vTraceStoreISRBegin(traceHandle handle) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - - /* We are at the start of a possible ISR chain. - No context switches should have been triggered now. */ - if (ISR_stack_index == -1) - isPendingContextSwitch = 0; - - if (ISR_stack_index < (TRC_CFG_MAX_ISR_NESTING) - 1) - { - ISR_stack_index++; - ISR_stack[ISR_stack_index] = (uint32_t)handle; -#if (TRC_CFG_INCLUDE_ISR_TRACING == 1) - prvTraceStoreEvent1(PSF_EVENT_ISR_BEGIN, (uint32_t)handle); -#endif - TRACE_EXIT_CRITICAL_SECTION(); - } - else - { - TRACE_EXIT_CRITICAL_SECTION(); - prvTraceError(PSF_ERROR_ISR_NESTING_OVERFLOW); - } -} - -/******************************************************************************* - * vTraceStoreISREnd - * - * Registers the end of an Interrupt Service Routine. - * - * The parameter pendingISR indicates if the interrupt has requested a - * task-switch (= 1), e.g., by signaling a semaphore. Otherwise (= 0) the - * interrupt is assumed to return to the previous context. - * - * Example: - * #define PRIO_OF_ISR_TIMER1 3 // the hardware priority of the interrupt - * traceHandle traceHandleIsrTimer1 = 0; // The ID set by the recorder - * ... - * traceHandleIsrTimer1 = xTraceSetISRProperties("ISRTimer1", PRIO_OF_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin(traceHandleIsrTimer1); - * ... - * vTraceStoreISREnd(0); - * } - * - ******************************************************************************/ -void vTraceStoreISREnd(int isTaskSwitchRequired) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - - (void)ISR_stack; - - /* Is there a pending task-switch? (perhaps from an earlier ISR) */ - isPendingContextSwitch |= isTaskSwitchRequired; - - if (ISR_stack_index > 0) - { - ISR_stack_index--; - -#if (TRC_CFG_INCLUDE_ISR_TRACING == 1) - /* Store return to interrupted ISR (if nested ISRs)*/ - prvTraceStoreEvent1(PSF_EVENT_ISR_RESUME, (uint32_t)ISR_stack[ISR_stack_index]); -#endif - } - else - { - ISR_stack_index--; - - /* Store return to interrupted task, if no context switch will occur in between. */ - if ((isPendingContextSwitch == 0) || (prvTraceIsSchedulerSuspended())) - { -#if (TRC_CFG_INCLUDE_ISR_TRACING == 1) - prvTraceStoreEvent1(PSF_EVENT_TS_RESUME, (uint32_t)TRACE_GET_CURRENT_TASK()); -#endif - } - } - - TRACE_EXIT_CRITICAL_SECTION(); -} - - -/******************************************************************************* - * xTraceGetLastError - * - * Returns the last error or warning, as a string, or NULL if none. - *****************************************************************************/ -const char* xTraceGetLastError(void) -{ - /* Note: the error messages are short, in order to fit in a User Event. - Instead, the users can read more in the below comments.*/ - - switch (errorCode) - { - - case PSF_WARNING_SYMBOL_TABLE_SLOTS: - /* There was not enough symbol table slots for storing symbol names. - The number of missing slots is counted by NoRoomForSymbol. Inspect this - variable and increase TRC_CFG_SYMBOL_TABLE_SLOTS by at least that value. */ - - return "Exceeded SYMBOL_TABLE_SLOTS (see xTraceGetLastError)"; - - case PSF_WARNING_SYMBOL_MAX_LENGTH: - /* A symbol name exceeded TRC_CFG_SYMBOL_MAX_LENGTH in length. - Make sure the symbol names are at most TRC_CFG_SYMBOL_MAX_LENGTH, - or inspect LongestSymbolName and increase TRC_CFG_SYMBOL_MAX_LENGTH - to at least this value. */ - - return "Exceeded SYMBOL_MAX_LENGTH (see xTraceGetLastError)"; - - case PSF_WARNING_OBJECT_DATA_SLOTS: - /* There was not enough symbol object table slots for storing object - properties, such as task priorites. The number of missing slots is - counted by NoRoomForObjectData. Inspect this variable and increase - TRC_CFG_OBJECT_DATA_SLOTS by at least that value. */ - - return "Exceeded OBJECT_DATA_SLOTS (see xTraceGetLastError)"; - - case PSF_WARNING_STRING_TOO_LONG: - /* Some string argument was longer than the maximum payload size - and has been truncated by "MaxBytesTruncated" bytes. - - This may happen for the following functions: - - vTracePrint - - vTracePrintF - - vTraceStoreKernelObjectName - - xTraceRegisterString - - vTraceSetISRProperties - - A PSF event may store maximum 60 bytes payload, including data - arguments and string characters. For User Events, also the User - Event Channel (4 bytes) must be squeezed in, if a channel is - specified (can be NULL). */ - - return "String too long (see xTraceGetLastError)"; - - case PSF_WARNING_STREAM_PORT_READ: - /* TRC_STREAM_PORT_READ_DATA is expected to return 0 when completed successfully. - This means there is an error in the communication with host/Tracealyzer. */ - - return "TRC_STREAM_PORT_READ_DATA returned error (!= 0)."; - - case PSF_WARNING_STREAM_PORT_WRITE: - /* TRC_STREAM_PORT_WRITE_DATA is expected to return 0 when completed successfully. - This means there is an error in the communication with host/Tracealyzer. */ - - return "TRC_STREAM_PORT_WRITE_DATA returned error (!= 0)."; - - case PSF_ERROR_EVENT_CODE_TOO_LARGE: - /* The highest allowed event code is 4095, anything higher is an unexpected error. - Please contact support@percepio.com for assistance.*/ - - return "Invalid event code (see xTraceGetLastError)"; - - case PSF_ERROR_ISR_NESTING_OVERFLOW: - /* Nesting of ISR trace calls exceeded the limit (TRC_CFG_MAX_ISR_NESTING). - If this is unlikely, make sure that you call vTraceStoreISRExit in the end - of all ISR handlers. Or increase TRC_CFG_MAX_ISR_NESTING. */ - - return "Exceeded ISR nesting (see xTraceGetLastError)"; - - case PSF_ERROR_DWT_NOT_SUPPORTED: - /* On ARM Cortex-M only - failed to initialize DWT Cycle Counter since not supported by this chip. - DWT timestamping is selected automatically for ART Cortex-M3, M4 and higher, based on the __CORTEX_M - macro normally set by ARM's CMSIS library, since typically available. You can however select - SysTick timestamping instead by defining adding "#define TRC_CFG_ARM_CM_USE_SYSTICK".*/ - - return "DWT not supported (see xTraceGetLastError)"; - - case PSF_ERROR_DWT_CYCCNT_NOT_SUPPORTED: - /* On ARM Cortex-M only - failed to initialize DWT Cycle Counter since not supported by this chip. - DWT timestamping is selected automatically for ART Cortex-M3, M4 and higher, based on the __CORTEX_M - macro normally set by ARM's CMSIS library, since typically available. You can however select - SysTick timestamping instead by defining adding "#define TRC_CFG_ARM_CM_USE_SYSTICK".*/ - - return "DWT_CYCCNT not supported (see xTraceGetLastError)"; - - case PSF_ERROR_TZCTRLTASK_NOT_CREATED: - /* vTraceEnable failed creating the trace control task (TzCtrl) - incorrect parameters (priority?) - or insufficient heap size? */ - return "Could not create TzCtrl (see xTraceGetLastError)"; - - } - - return NULL; -} - -/******************************************************************************* - * vTraceClearError - * - * Clears any errors. - *****************************************************************************/ -void vTraceClearError(void) -{ - NoRoomForSymbol = 0; - LongestSymbolName = 0; - NoRoomForObjectData = 0; - MaxBytesTruncated = 0; - errorCode = PSF_ERROR_NONE; -} - -/******************************************************************************* - * vTraceStop - * - * Stops the tracing. - *****************************************************************************/ -void vTraceStop(void) -{ - prvSetRecorderEnabled(0); -} - -/******************************************************************************* - * vTraceSetRecorderDataBuffer - * - * If custom allocation is used, this function must be called so the recorder - * library knows where to save the trace data. - ******************************************************************************/ -#if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM) - -extern char* _TzTraceData; - -void vTraceSetRecorderDataBuffer(void* pRecorderData) -{ - _TzTraceData = pRecorderData; -} -#endif - - -/******************************************************************************* -* xTraceIsRecordingEnabled -* Returns true (1) if the recorder is enabled (i.e. is recording), otherwise 0. -******************************************************************************/ -int xTraceIsRecordingEnabled(void) -{ - return (int)RecorderEnabled; -} - -void vTraceSetFilterMask(uint16_t filterMask) -{ - CurrentFilterMask = filterMask; -} - -void vTraceSetFilterGroup(uint16_t filterGroup) -{ - CurrentFilterGroup = filterGroup; -} - - -/******************************************************************************/ -/*** INTERNAL FUNCTIONS *******************************************************/ -/******************************************************************************/ - -/* Internal function for starting/stopping the recorder. */ -static void prvSetRecorderEnabled(uint32_t isEnabled) -{ - void* currentTask; - - TRACE_ALLOC_CRITICAL_SECTION(); - - if (RecorderEnabled == isEnabled) - { - return; - } - - currentTask = TRACE_GET_CURRENT_TASK(); - - TRACE_ENTER_CRITICAL_SECTION(); - - RecorderEnabled = isEnabled; - - if (currentTask == NULL) - { - currentTask = (void*)HANDLE_NO_TASK; - } - - if (RecorderEnabled) - { - TRC_STREAM_PORT_ON_TRACE_BEGIN(); - - #if (TRC_STREAM_PORT_USE_INTERNAL_BUFFER == 1) - prvPagedEventBufferInit(_TzTraceData); - #endif - - eventCounter = 0; - ISR_stack_index = -1; - prvTraceStoreHeader(); - prvTraceStoreSymbolTable(); - prvTraceStoreObjectDataTable(); - prvTraceStoreEvent3( PSF_EVENT_TRACE_START, - (uint32_t)TRACE_GET_OS_TICKS(), - (uint32_t)currentTask, - SessionCounter++); - prvTraceStoreTSConfig(); - prvTraceStoreWarnings(); - } - else - { - TRC_STREAM_PORT_ON_TRACE_END(); - } - - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Stores the symbol table on Start */ -static void prvTraceStoreSymbolTable(void) -{ - uint32_t i = 0; - uint32_t j = 0; - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - for (i = 0; i < (sizeof(SymbolTable) / sizeof(uint32_t)); i += (SYMBOL_TABLE_SLOT_SIZE / sizeof(uint32_t))) - { - TRC_STREAM_PORT_ALLOCATE_EVENT(uint32_t, data, SYMBOL_TABLE_SLOT_SIZE); - if (data != NULL) - { - for (j = 0; j < (SYMBOL_TABLE_SLOT_SIZE / sizeof(uint32_t)); j++) - { - data[j] = symbolTable.SymbolTableBuffer.pSymbolTableBufferUINT32[i+j]; - } - TRC_STREAM_PORT_COMMIT_EVENT(data, SYMBOL_TABLE_SLOT_SIZE); - } - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Stores the object table on Start */ -static void prvTraceStoreObjectDataTable(void) -{ - uint32_t i = 0; - uint32_t j = 0; - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - for (i = 0; i < (sizeof(ObjectDataTable) / sizeof(uint32_t)); i += (OBJECT_DATA_SLOT_SIZE / sizeof(uint32_t))) - { - TRC_STREAM_PORT_ALLOCATE_EVENT(uint32_t, data, OBJECT_DATA_SLOT_SIZE); - if (data != NULL) - { - for (j = 0; j < (OBJECT_DATA_SLOT_SIZE / sizeof(uint32_t)); j++) - { - data[j] = objectDataTable.ObjectDataTableBuffer.pObjectDataTableBufferUINT32[i+j]; - } - TRC_STREAM_PORT_COMMIT_EVENT(data, OBJECT_DATA_SLOT_SIZE); - } - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Stores the header information on Start */ -static void prvTraceStoreHeader(void) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - TRC_STREAM_PORT_ALLOCATE_EVENT(PSFHeaderInfo, header, sizeof(PSFHeaderInfo)); - if (header != NULL) - { - header->psf = PSFEndianessIdentifier; - header->version = FormatVersion; - header->platform = TRACE_KERNEL_VERSION; - header->options = 0; - /* Lowest bit used for TRC_IRQ_PRIORITY_ORDER */ - header->options = header->options | (TRC_IRQ_PRIORITY_ORDER << 0); - header->symbolSize = SYMBOL_TABLE_SLOT_SIZE; - header->symbolCount = (TRC_CFG_SYMBOL_TABLE_SLOTS); - header->objectDataSize = 8; - header->objectDataCount = (TRC_CFG_OBJECT_DATA_SLOTS); - TRC_STREAM_PORT_COMMIT_EVENT(header, sizeof(PSFHeaderInfo)); - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Store the current warnings */ -static void prvTraceStoreWarnings(void) -{ - if (RecorderEnabled) - { - const char* errStr = xTraceGetLastError(); - - if (errStr != NULL) - { - vTracePrint(trcWarningChannel, errStr); - } - } -} - -/* Store an event with zero parameters (event ID only) */ -void prvTraceStoreEvent0(uint16_t eventID) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - PSF_ASSERT(eventID < 4096, PSF_ERROR_EVENT_CODE_TOO_LARGE); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - eventCounter++; - - { - TRC_STREAM_PORT_ALLOCATE_EVENT(BaseEvent, event, sizeof(BaseEvent)); - if (event != NULL) - { - event->EventID = eventID | PARAM_COUNT(0); - event->EventCount = (uint16_t)eventCounter; - event->TS = prvGetTimestamp32(); - TRC_STREAM_PORT_COMMIT_EVENT(event, sizeof(BaseEvent)); - } - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Store an event with one 32-bit parameter (pointer address or an int) */ -void prvTraceStoreEvent1(uint16_t eventID, uint32_t param1) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - PSF_ASSERT(eventID < 4096, PSF_ERROR_EVENT_CODE_TOO_LARGE); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - eventCounter++; - - { - TRC_STREAM_PORT_ALLOCATE_EVENT(EventWithParam_1, event, sizeof(EventWithParam_1)); - if (event != NULL) - { - event->base.EventID = eventID | PARAM_COUNT(1); - event->base.EventCount = (uint16_t)eventCounter; - event->base.TS = prvGetTimestamp32(); - event->param1 = (uint32_t)param1; - TRC_STREAM_PORT_COMMIT_EVENT(event, sizeof(EventWithParam_1)); - } - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Store an event with two 32-bit parameters */ -void prvTraceStoreEvent2(uint16_t eventID, uint32_t param1, uint32_t param2) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - PSF_ASSERT(eventID < 4096, PSF_ERROR_EVENT_CODE_TOO_LARGE); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - eventCounter++; - - { - TRC_STREAM_PORT_ALLOCATE_EVENT(EventWithParam_2, event, sizeof(EventWithParam_2)); - if (event != NULL) - { - event->base.EventID = eventID | PARAM_COUNT(2); - event->base.EventCount = (uint16_t)eventCounter; - event->base.TS = prvGetTimestamp32(); - event->param1 = (uint32_t)param1; - event->param2 = param2; - TRC_STREAM_PORT_COMMIT_EVENT(event, sizeof(EventWithParam_2)); - } - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Store an event with three 32-bit parameters */ -void prvTraceStoreEvent3( uint16_t eventID, - uint32_t param1, - uint32_t param2, - uint32_t param3) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - PSF_ASSERT(eventID < 4096, PSF_ERROR_EVENT_CODE_TOO_LARGE); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - eventCounter++; - - { - TRC_STREAM_PORT_ALLOCATE_EVENT(EventWithParam_3, event, sizeof(EventWithParam_3)); - if (event != NULL) - { - event->base.EventID = eventID | PARAM_COUNT(3); - event->base.EventCount = (uint16_t)eventCounter; - event->base.TS = prvGetTimestamp32(); - event->param1 = (uint32_t)param1; - event->param2 = param2; - event->param3 = param3; - TRC_STREAM_PORT_COMMIT_EVENT(event, sizeof(EventWithParam_3)); - } - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Stores an event with 32-bit integer parameters */ -void prvTraceStoreEvent(int nParam, uint16_t eventID, ...) -{ - va_list vl; - int i; - TRACE_ALLOC_CRITICAL_SECTION(); - - PSF_ASSERT(eventID < 4096, PSF_ERROR_EVENT_CODE_TOO_LARGE); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - int eventSize = (int)sizeof(BaseEvent) + nParam * (int)sizeof(uint32_t); - - eventCounter++; - - { - TRC_STREAM_PORT_ALLOCATE_DYNAMIC_EVENT(largestEventType, event, eventSize); - if (event != NULL) - { - event->base.EventID = eventID | (uint16_t)PARAM_COUNT(nParam); - event->base.EventCount = (uint16_t)eventCounter; - event->base.TS = prvGetTimestamp32(); - - va_start(vl, eventID); - for (i = 0; i < nParam; i++) - { - uint32_t* tmp = (uint32_t*) &(event->data[i]); - *tmp = va_arg(vl, uint32_t); - } - va_end(vl); - - TRC_STREAM_PORT_COMMIT_EVENT(event, (uint32_t)eventSize); - } - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Stories an event with a string and 32-bit integer parameters */ -void prvTraceStoreStringEvent(int nArgs, uint16_t eventID, const char* str, ...) -{ - int len; - va_list vl; - - for (len = 0; (str[len] != 0) && (len < 52); len++); /* empty loop */ - - va_start(vl, str); - prvTraceStoreStringEventHelper(nArgs, eventID, NULL, len, str, &vl); - va_end(vl); -} - -/* Internal common function for storing string events */ -static void prvTraceStoreStringEventHelper(int nArgs, - uint16_t eventID, - traceString userEvtChannel, - int len, - const char* str, - va_list* vl) -{ - int nWords; - int nStrWords; - int i; - int offset = 0; - TRACE_ALLOC_CRITICAL_SECTION(); - - PSF_ASSERT(eventID < 4096, PSF_ERROR_EVENT_CODE_TOO_LARGE); - - /* The string length in multiples of 32 bit words (+1 for null character) */ - nStrWords = (len+1+3)/4; - - /* If a user event channel is specified, add in the list */ - if (userEvtChannel) - nArgs++; - - offset = nArgs * 4; - - /* The total number of 32-bit words needed for the whole payload */ - nWords = nStrWords + nArgs; - - if (nWords > 15) /* if attempting to store more than 60 byte (= max) */ - { - /* Truncate event if too large. The string characters are stored - last, so usually only the string is truncated, unless there a lot - of parameters... */ - - /* Diagnostics ... */ - uint32_t bytesTruncated = (uint32_t)(nWords - 15) * 4; - - if (bytesTruncated > MaxBytesTruncated) - { - MaxBytesTruncated = bytesTruncated; - } - - nWords = 15; - len = 15 * 4 - offset; - } - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - int eventSize = (int)sizeof(BaseEvent) + nWords * (int)sizeof(uint32_t); - - eventCounter++; - - { - TRC_STREAM_PORT_ALLOCATE_DYNAMIC_EVENT(largestEventType, event, eventSize); - if (event != NULL) - { - uint32_t* data32; - uint8_t* data8; - event->base.EventID = (eventID) | (uint16_t)PARAM_COUNT(nWords); - event->base.EventCount = (uint16_t)eventCounter; - event->base.TS = prvGetTimestamp32(); - - /* 32-bit write-pointer for the data argument */ - data32 = (uint32_t*) &(event->data[0]); - - for (i = 0; i < nArgs; i++) - { - if ((userEvtChannel != NULL) && (i == 0)) - { - /* First, add the User Event Channel if not NULL */ - data32[i] = (uint32_t)userEvtChannel; - } - else - { - /* Add data arguments... */ - data32[i] = va_arg(*vl, uint32_t); - } - } - data8 = (uint8_t*)&(event->data[0]); - for (i = 0; i < len; i++) - { - data8[offset + i] = str[i]; - } - - if (len < (15 * 4 - offset)) - data8[offset + len] = 0; /* Only truncate if we don't fill up the buffer completely */ - TRC_STREAM_PORT_COMMIT_EVENT(event, (uint32_t)eventSize); - } - } - } - - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Internal common function for storing string events without additional arguments */ -void prvTraceStoreSimpleStringEventHelper(traceString userEvtChannel, - const char* str) -{ - int len; - int nWords; - int nStrWords; - int i; - int nArgs = 0; - int offset = 0; - uint16_t eventID = PSF_EVENT_USER_EVENT; - TRACE_ALLOC_CRITICAL_SECTION(); - - PSF_ASSERT(eventID < 4096, PSF_ERROR_EVENT_CODE_TOO_LARGE); - - for (len = 0; (str[len] != 0) && (len < 52); len++); /* empty loop */ - - /* The string length in multiples of 32 bit words (+1 for null character) */ - nStrWords = (len+1+3)/4; - - /* If a user event channel is specified, add in the list */ - if (userEvtChannel) - { - nArgs++; - eventID++; - } - - offset = nArgs * 4; - - /* The total number of 32-bit words needed for the whole payload */ - nWords = nStrWords + nArgs; - - if (nWords > 15) /* if attempting to store more than 60 byte (= max) */ - { - /* Truncate event if too large. The string characters are stored - last, so usually only the string is truncated, unless there a lot - of parameters... */ - - /* Diagnostics ... */ - uint32_t bytesTruncated = (uint32_t)(nWords - 15) * 4; - - if (bytesTruncated > MaxBytesTruncated) - { - MaxBytesTruncated = bytesTruncated; - } - - nWords = 15; - len = 15 * 4 - offset; - } - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - int eventSize = (int)sizeof(BaseEvent) + nWords * (int)sizeof(uint32_t); - - eventCounter++; - - { - TRC_STREAM_PORT_ALLOCATE_DYNAMIC_EVENT(largestEventType, event, eventSize); - if (event != NULL) - { - uint32_t* data32; - uint8_t* data8; - event->base.EventID = (eventID) | (uint16_t)PARAM_COUNT(nWords); - event->base.EventCount = (uint16_t)eventCounter; - event->base.TS = prvGetTimestamp32(); - - /* 32-bit write-pointer for the data argument */ - data32 = (uint32_t*) &(event->data[0]); - - if (userEvtChannel != NULL) - { - /* First, add the User Event Channel if not NULL */ - data32[0] = (uint32_t)userEvtChannel; - } - - data8 = (uint8_t*) &(event->data[0]); - for (i = 0; i < len; i++) - { - data8[offset + i] = str[i]; - } - - if (len < (15 * 4 - offset)) - data8[offset + len] = 0; /* Only truncate if we don't fill up the buffer completely */ - TRC_STREAM_PORT_COMMIT_EVENT(event, (uint32_t)eventSize); - } - } - } - - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Saves a symbol name (task name etc.) in symbol table */ -void prvTraceSaveSymbol(const void *address, const char *name) -{ - uint32_t i; - uint32_t foundSlot; - uint32_t *ptrAddress; - uint8_t *ptrSymbol; - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - - foundSlot = firstFreeSymbolTableIndex; - - /* First look for previous entries using this address */ - for (i = 0; i < firstFreeSymbolTableIndex; i += SYMBOL_TABLE_SLOT_SIZE) - { - /* We access the symbol table via the union member pSymbolTableBufferUINT32 to avoid strict-aliasing issues */ - ptrAddress = &symbolTable.SymbolTableBuffer.pSymbolTableBufferUINT32[i / sizeof(uint32_t)]; - if (*ptrAddress == (uint32_t)address) - { - foundSlot = i; - break; - } - } - - if (foundSlot < SYMBOL_TABLE_BUFFER_SIZE) - { - /* We access the symbol table via the union member pSymbolTableBufferUINT32 to avoid strict-aliasing issues */ - symbolTable.SymbolTableBuffer.pSymbolTableBufferUINT32[foundSlot / sizeof(uint32_t)] = (uint32_t)address; - - /* We access the symbol table via the union member pSymbolTableBufferUINT8 to avoid strict-aliasing issues */ - ptrSymbol = &symbolTable.SymbolTableBuffer.pSymbolTableBufferUINT8[foundSlot + sizeof(uint32_t)]; - for (i = 0; i < (TRC_CFG_SYMBOL_MAX_LENGTH); i++) - { - ptrSymbol[i] = (uint8_t)name[i]; /* We do this first to ensure we also get the 0 termination, if there is one */ - - if (name[i] == 0) - break; - } - - /* Check the length of "name", if longer than SYMBOL_MAX_LENGTH */ - while ((name[i] != 0) && i < 128) - { - i++; - } - - /* Remember the longest symbol name, for diagnostic purposes */ - if (i > LongestSymbolName) - { - LongestSymbolName = i; - } - - /* Is this the last entry in the symbol table? */ - if (foundSlot == firstFreeSymbolTableIndex) - { - firstFreeSymbolTableIndex += SYMBOL_TABLE_SLOT_SIZE; - } - } - else - { - NoRoomForSymbol++; - } - - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Deletes a symbol name (task name etc.) from symbol table */ -void prvTraceDeleteSymbol(void *address) -{ - uint32_t i, j; - uint32_t *ptr, *lastEntryPtr; - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - - for (i = 0; i < firstFreeSymbolTableIndex; i += SYMBOL_TABLE_SLOT_SIZE) - { - /* We access the symbol table via the union member pSymbolTableBufferUINT32 to avoid strict-aliasing issues */ - ptr = &symbolTable.SymbolTableBuffer.pSymbolTableBufferUINT32[i / sizeof(uint32_t)]; - if (*ptr == (uint32_t)address) - { - /* See if we have another entry in the table, and that this isn't already the last entry */ - if (firstFreeSymbolTableIndex > SYMBOL_TABLE_SLOT_SIZE && i != (firstFreeSymbolTableIndex - SYMBOL_TABLE_SLOT_SIZE)) - { - /* Another entry is available, get pointer to the last one */ - /* We access the symbol table via the union member pSymbolTableBufferUINT32 to avoid strict-aliasing issues */ - lastEntryPtr = &symbolTable.SymbolTableBuffer.pSymbolTableBufferUINT32[(firstFreeSymbolTableIndex - SYMBOL_TABLE_SLOT_SIZE) / sizeof(uint32_t)]; - - /* Copy last entry to this position */ - for (j = 0; j < (SYMBOL_TABLE_SLOT_SIZE) / sizeof(uint32_t); j++) - { - ptr[j] = lastEntryPtr[j]; - } - - /* For good measure we also zero out the original position */ - *lastEntryPtr = 0; - } - else - *ptr = 0; /* No other entry found, or this is the last entry */ - - /* Lower index */ - firstFreeSymbolTableIndex -= SYMBOL_TABLE_SLOT_SIZE; - - break; - } - } - - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Saves an object data entry (current task priority) in object data table */ -void prvTraceSaveObjectData(const void *address, uint32_t data) -{ - uint32_t i; - uint32_t foundSlot; - uint32_t *ptr; - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - - foundSlot = firstFreeObjectDataTableIndex; - - /* First look for previous entries using this address */ - for (i = 0; i < firstFreeObjectDataTableIndex; i += OBJECT_DATA_SLOT_SIZE) - { - /* We access the data table via the union member pObjectDataTableBufferUINT32 to avoid strict-aliasing issues */ - ptr = &objectDataTable.ObjectDataTableBuffer.pObjectDataTableBufferUINT32[i / sizeof(uint32_t)]; - if (*ptr == (uint32_t)address) - { - foundSlot = i; - break; - } - } - - if (foundSlot < OBJECT_DATA_TABLE_BUFFER_SIZE) - { - /* We access the data table via the union member pObjectDataTableBufferUINT32 to avoid strict-aliasing issues */ - objectDataTable.ObjectDataTableBuffer.pObjectDataTableBufferUINT32[foundSlot / sizeof(uint32_t)] = (uint32_t)address; - objectDataTable.ObjectDataTableBuffer.pObjectDataTableBufferUINT32[foundSlot / sizeof(uint32_t) + 1] = data; - - /* Is this the last entry in the object data table? */ - if (foundSlot == firstFreeObjectDataTableIndex) - { - firstFreeObjectDataTableIndex += OBJECT_DATA_SLOT_SIZE; - } - } - else - { - NoRoomForObjectData++; - } - - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Removes an object data entry (task base priority) from object data table */ -void prvTraceDeleteObjectData(void *address) -{ - uint32_t i, j; - uint32_t *ptr, *lastEntryPtr; - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - - for (i = 0; i < firstFreeObjectDataTableIndex; i += OBJECT_DATA_SLOT_SIZE) - { - /* We access the data table via the union member pObjectDataTableBufferUINT32 to avoid strict-aliasing issues */ - ptr = &objectDataTable.ObjectDataTableBuffer.pObjectDataTableBufferUINT32[i / sizeof(uint32_t)]; - if (*ptr == (uint32_t)address) - { - /* See if we have another entry in the table, and that this isn't already the last entry */ - if (firstFreeObjectDataTableIndex > OBJECT_DATA_SLOT_SIZE && i != (firstFreeObjectDataTableIndex - OBJECT_DATA_SLOT_SIZE)) - { - /* Another entry is available, get pointer to the last one */ - /* We access the data table via the union member pObjectDataTableBufferUINT32 to avoid strict-aliasing issues */ - lastEntryPtr = &objectDataTable.ObjectDataTableBuffer.pObjectDataTableBufferUINT32[(firstFreeObjectDataTableIndex - OBJECT_DATA_SLOT_SIZE) / sizeof(uint32_t)]; - - /* Copy last entry to this position */ - for (j = 0; j < (OBJECT_DATA_SLOT_SIZE) / sizeof(uint32_t); j++) - { - ptr[j] = lastEntryPtr[j]; - } - - /* For good measure we also zero out the original position */ - *lastEntryPtr = 0; - } - else - *ptr = 0; /* No other entry found, or this is the last entry */ - - /* Lower index */ - firstFreeObjectDataTableIndex -= OBJECT_DATA_SLOT_SIZE; - - break; - } - } - - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Checks if the provided command is a valid command */ -int prvIsValidCommand(TracealyzerCommandType* cmd) -{ - uint16_t checksum = (uint16_t)(0xFFFF - ( cmd->cmdCode + - cmd->param1 + - cmd->param2 + - cmd->param3 + - cmd->param4 + - cmd->param5)); - - if (cmd->checksumMSB != (unsigned char)(checksum >> 8)) - return 0; - - if (cmd->checksumLSB != (unsigned char)(checksum & 0xFF)) - return 0; - - if (cmd->cmdCode > CMD_LAST_COMMAND) - return 0; - - return 1; -} - -/* Executed the received command (Start or Stop) */ -void prvProcessCommand(TracealyzerCommandType* cmd) -{ - switch(cmd->cmdCode) - { - case CMD_SET_ACTIVE: - prvSetRecorderEnabled(cmd->param1); - break; - default: - break; - } -} - -/* Called on warnings, when the recording can continue. */ -void prvTraceWarning(int errCode) -{ - if (!errorCode) - { - errorCode = errCode; - prvTraceStoreWarnings(); - } -} - -/* Called on critical errors in the recorder. Stops the recorder! */ -void prvTraceError(int errCode) -{ - if (! errorCode) - { - errorCode = errCode; - prvTraceStoreWarnings(); - vTracePrintF(trcWarningChannel, "Recorder stopped in prvTraceError()"); - - prvSetRecorderEnabled(0); - } -} - -/* If using DWT timestamping (default on ARM Cortex-M3, M4 and M7), make sure the DWT unit is initialized. */ -#ifndef TRC_CFG_ARM_CM_USE_SYSTICK -#if ((TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_Cortex_M) && (defined (__CORTEX_M) && (__CORTEX_M >= 0x03))) - -void prvTraceInitCortexM() -{ - /* Make sure the DWT registers are unlocked, in case the debugger doesn't do this. */ - TRC_REG_ITM_LOCKACCESS = TRC_ITM_LOCKACCESS_UNLOCK; - - /* Make sure DWT is enabled is enabled, if supported */ - TRC_REG_DEMCR |= TRC_DEMCR_TRCENA; - - do - { - /* Verify that DWT is supported */ - if (TRC_REG_DEMCR == 0) - { - /* This function is called on Cortex-M3, M4 and M7 devices to initialize - the DWT unit, assumed present. The DWT cycle counter is used for timestamping. - - If the below error is produced, the DWT unit does not seem to be available. - - In that case, define the macro TRC_CFG_ARM_CM_USE_SYSTICK in your build - to use SysTick timestamping instead, or define your own timestamping by - setting TRC_CFG_HARDWARE_PORT to TRC_HARDWARE_PORT_APPLICATION_DEFINED - and make the necessary definitions, as explained in trcHardwarePort.h.*/ - - prvTraceError(PSF_ERROR_DWT_NOT_SUPPORTED); - break; - } - - /* Verify that DWT_CYCCNT is supported */ - if (TRC_REG_DWT_CTRL & TRC_DWT_CTRL_NOCYCCNT) - { - /* This function is called on Cortex-M3, M4 and M7 devices to initialize - the DWT unit, assumed present. The DWT cycle counter is used for timestamping. - - If the below error is produced, the cycle counter does not seem to be available. - - In that case, define the macro TRC_CFG_ARM_CM_USE_SYSTICK in your build - to use SysTick timestamping instead, or define your own timestamping by - setting TRC_CFG_HARDWARE_PORT to TRC_HARDWARE_PORT_APPLICATION_DEFINED - and make the necessary definitions, as explained in trcHardwarePort.h.*/ - - prvTraceError(PSF_ERROR_DWT_CYCCNT_NOT_SUPPORTED); - break; - } - - /* Reset the cycle counter */ - TRC_REG_DWT_CYCCNT = 0; - - /* Enable the cycle counter */ - TRC_REG_DWT_CTRL |= TRC_DWT_CTRL_CYCCNTENA; - - } while(0); /* breaks above jump here */ -} -#endif -#endif - -/* Performs timestamping using definitions in trcHardwarePort.h */ -static uint32_t prvGetTimestamp32(void) -{ -#if ((TRC_HWTC_TYPE == TRC_FREE_RUNNING_32BIT_INCR) || (TRC_HWTC_TYPE == TRC_FREE_RUNNING_32BIT_DECR)) - return TRC_HWTC_COUNT; -#endif - -#if ((TRC_HWTC_TYPE == TRC_CUSTOM_TIMER_INCR) || (TRC_HWTC_TYPE == TRC_CUSTOM_TIMER_DECR)) - return TRC_HWTC_COUNT; -#endif - -#if ((TRC_HWTC_TYPE == TRC_OS_TIMER_INCR) || (TRC_HWTC_TYPE == TRC_OS_TIMER_DECR)) - uint32_t ticks = TRACE_GET_OS_TICKS(); - return ((TRC_HWTC_COUNT) & 0x00FFFFFFU) + ((ticks & 0x000000FFU) << 24); -#endif -} - -/* Store the Timestamp Config event */ -static void prvTraceStoreTSConfig(void) -{ - /* If not overridden using vTraceSetFrequency, use default value */ - if (timestampFrequency == 0) - { - timestampFrequency = TRC_HWTC_FREQ_HZ; - } - - #if (TRC_HWTC_TYPE == TRC_CUSTOM_TIMER_INCR || TRC_HWTC_TYPE == TRC_CUSTOM_TIMER_DECR) - - prvTraceStoreEvent(5, - PSF_EVENT_TS_CONFIG, - (uint32_t)timestampFrequency, - (uint32_t)(TRACE_TICK_RATE_HZ), - (uint32_t)(TRC_HWTC_TYPE), - (uint32_t)(TRC_CFG_ISR_TAILCHAINING_THRESHOLD), - (uint32_t)(TRC_HWTC_PERIOD)); - - #else - - prvTraceStoreEvent(4, - PSF_EVENT_TS_CONFIG, - (uint32_t)timestampFrequency, - (uint32_t)(TRACE_TICK_RATE_HZ), - (uint32_t)(TRC_HWTC_TYPE), - (uint32_t)(TRC_CFG_ISR_TAILCHAINING_THRESHOLD)); - #endif -} - -/* Retrieve a buffer page to write to. */ -static int prvAllocateBufferPage(int prevPage) -{ - int index; - int count = 0; - - index = (prevPage + 1) % (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT); - - while((PageInfo[index].Status != PAGE_STATUS_FREE) && (count ++ < (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT))) - { - index = (index + 1) % (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT); - } - - if (PageInfo[index].Status == PAGE_STATUS_FREE) - { - return index; - } - - return -1; -} - -/* Mark the page read as complete. */ -static void prvPageReadComplete(int pageIndex) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - PageInfo[pageIndex].BytesRemaining = (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE); - PageInfo[pageIndex].WritePointer = &EventBuffer[pageIndex * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE)]; - PageInfo[pageIndex].Status = PAGE_STATUS_FREE; - - TotalBytesRemaining += (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE); - - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Get the current buffer page index and remaining number of bytes. */ -static int prvGetBufferPage(int32_t* bytesUsed) -{ - static int8_t lastPage = -1; - int count = 0; - int8_t index = (int8_t) ((lastPage + 1) % (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT)); - - while((PageInfo[index].Status != PAGE_STATUS_READ) && (count++ < (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT))) - { - index = (int8_t)((index + 1) % (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT)); - } - - if (PageInfo[index].Status == PAGE_STATUS_READ) - { - *bytesUsed = (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE) - PageInfo[index].BytesRemaining; - lastPage = index; - return index; - } - - *bytesUsed = 0; - - return -1; -} - -/******************************************************************************* - * uint32_t prvPagedEventBufferTransfer(void) - * - * Transfers one buffer page of trace data, if a full page is available, using - * the macro TRC_STREAM_PORT_WRITE_DATA as defined in trcStreamingPort.h. - * - * This function is intended to be called the periodic TzCtrl task with a suitable - * delay (e.g. 10-100 ms). - * - * Returns the number of bytes sent. If non-zero, it is good to call this - * again, in order to send any additional data waiting in the buffer. - * If zero, wait a while before calling again. - * - * In case of errors from the streaming interface, it registers a warning - * (PSF_WARNING_STREAM_PORT_WRITE) provided by xTraceGetLastError(). - * - *******************************************************************************/ -uint32_t prvPagedEventBufferTransfer(void) -{ - int8_t pageToTransfer = -1; - int32_t bytesTransferredTotal = 0; - int32_t bytesTransferredNow = 0; - int32_t bytesToTransfer; - - pageToTransfer = (int8_t)prvGetBufferPage(&bytesToTransfer); - - /* bytesToTransfer now contains the number of "valid" bytes in the buffer page, that should be transmitted. - There might be some unused junk bytes in the end, that must be ignored. */ - - if (pageToTransfer > -1) - { - while (1) /* Keep going until we have transferred all that we intended to */ - { - if (TRC_STREAM_PORT_WRITE_DATA( - &EventBuffer[pageToTransfer * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE) + bytesTransferredTotal], - (uint32_t)(bytesToTransfer - bytesTransferredTotal), - &bytesTransferredNow) == 0) - { - /* Write was successful. Update the number of transferred bytes. */ - bytesTransferredTotal += bytesTransferredNow; - - if (bytesTransferredTotal == bytesToTransfer) - { - /* All bytes have been transferred. Mark the buffer page as "Read Complete" (so it can be written to) and return OK. */ - prvPageReadComplete(pageToTransfer); - return (uint32_t)bytesTransferredTotal; - } - } - else - { - /* Some error from the streaming interface... */ - prvTraceWarning(PSF_WARNING_STREAM_PORT_WRITE); - return 0; - } - } - } - return 0; -} - -/******************************************************************************* - * void* prvPagedEventBufferGetWritePointer(int sizeOfEvent) - * - * Returns a pointer to an available location in the buffer able to store the - * requested size. - * - * Return value: The pointer. - * - * Parameters: - * - sizeOfEvent: The size of the event that is to be placed in the buffer. - * -*******************************************************************************/ -void* prvPagedEventBufferGetWritePointer(int sizeOfEvent) -{ - void* ret; - static int currentWritePage = -1; - - if (currentWritePage == -1) - { - currentWritePage = prvAllocateBufferPage(currentWritePage); - if (currentWritePage == -1) - { - DroppedEventCounter++; - return NULL; - } - } - - if (PageInfo[currentWritePage].BytesRemaining - sizeOfEvent < 0) - { - PageInfo[currentWritePage].Status = PAGE_STATUS_READ; - - TotalBytesRemaining -= PageInfo[currentWritePage].BytesRemaining; // Last trailing bytes - - if (TotalBytesRemaining < TotalBytesRemaining_LowWaterMark) - TotalBytesRemaining_LowWaterMark = TotalBytesRemaining; - - currentWritePage = prvAllocateBufferPage(currentWritePage); - if (currentWritePage == -1) - { - DroppedEventCounter++; - return NULL; - } - } - ret = PageInfo[currentWritePage].WritePointer; - PageInfo[currentWritePage].WritePointer += sizeOfEvent; - PageInfo[currentWritePage].BytesRemaining = (uint16_t)(PageInfo[currentWritePage].BytesRemaining -sizeOfEvent); - - TotalBytesRemaining = (TotalBytesRemaining-(uint16_t)sizeOfEvent); - - if (TotalBytesRemaining < TotalBytesRemaining_LowWaterMark) - TotalBytesRemaining_LowWaterMark = TotalBytesRemaining; - - return ret; -} - -/******************************************************************************* - * void prvPagedEventBufferInit(char* buffer) - * - * Assigns the buffer to use and initializes the PageInfo structure. - * - * Return value: void - * - * Parameters: - * - char* buffer: pointer to the trace data buffer, allocated by the caller. - * -*******************************************************************************/ -void prvPagedEventBufferInit(char* buffer) -{ - int i; - TRACE_ALLOC_CRITICAL_SECTION(); - - EventBuffer = buffer; - - TRACE_ENTER_CRITICAL_SECTION(); - for (i = 0; i < (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT); i++) - { - PageInfo[i].BytesRemaining = (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE); - PageInfo[i].WritePointer = &EventBuffer[i * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE)]; - PageInfo[i].Status = PAGE_STATUS_FREE; - } - TRACE_EXIT_CRITICAL_SECTION(); - -} - -#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/ - -#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/See also FreeRTOS+TCP.url b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/See also FreeRTOS+TCP.url deleted file mode 100755 index 6617b60..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/See also FreeRTOS+TCP.url +++ /dev/null @@ -1,5 +0,0 @@ -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 -[InternetShortcut] -URL=http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/index.html -IDList= diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/readme.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/readme.txt deleted file mode 100755 index bc35bc3..0000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/readme.txt +++ /dev/null @@ -1,4 +0,0 @@ -FreeRTOS+UDP was removed in FreeRTOS V10.1.0 as it was replaced by FreeRTOS+TCP, -which was brought into the main download in FreeRTOS V10.0.0. FreeRTOS+TCP can -be configured as a UDP only stack, and FreeRTOS+UDP does not contain the patches -applied to FreeRTOS+TCP. \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/CREDITS.txt b/FreeRTOS-Plus/Source/Reliance-Edge/CREDITS.txt deleted file mode 100755 index 7b2f608..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/CREDITS.txt +++ /dev/null @@ -1,21 +0,0 @@ -Reliance Edge Credits -===================== - -This is a list (or partial list) of people who have made non-trivial or -noteworthy contributions to the Reliance Edge project. It is sorted by name. -Entries are formatted as below: - -Real Name (githubaccount) -Short description of how Real Name contributed to Reliance Edge. - -The real name may be withheld by request and the GitHub account name might be -missing if the contributor does not use GitHub. - -Credits -------- - -Jean-Christophe Dubois (jcdubois) -Created a user-space Linux port of Reliance Edge, ported the open-source host -tools (including the formatter and image builder) to Linux, and created a FUSE -(File System in User Space) implementation for Reliance Edge. - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/LICENSE.txt b/FreeRTOS-Plus/Source/Reliance-Edge/LICENSE.txt deleted file mode 100755 index 1f963da..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/LICENSE.txt +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program 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. - - This program 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-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/README.md b/FreeRTOS-Plus/Source/Reliance-Edge/README.md deleted file mode 100755 index 0c2e228..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/README.md +++ /dev/null @@ -1,123 +0,0 @@ -# Reliance Edge - -Reliance Edge is a small, portable, highly reliable power-fail safe file system -for resource-constrained embedded systems like microcontrollers. It is written -in C and provides a familiar POSIX-like file system API, making it easy to use -in your application; or an alternate minimalist API if your application has -simple storage needs. Reliance Edge is highly configurable and can be tuned to -the precise needs of your application. - -## Getting Help - -You will find this section later in our readme as well - but we wanted to tell -you up front: DATALIGHT WANTS TO HEAR FROM YOU! Whether it's just to make -comments about the product, to suggest new features, or to tell us what you -don't like - reach out! All comments and inquiries can be directed to -. - -## Documentation - -The complete documentation for Reliance Edge is distributed separately. It -includes an API reference and detailed discussions of various aspects of using -Reliance Edge, including porting, building, configuring, and testing. This -complete documentation, called the _Developer's Guide_, can be obtained for free -from here: - - - -In addition this README, see doc/release_notes.md for a list of updates -to Reliance Edge and a list of known issues. There is also a quick-start -guide in the doc/ directory that describes step-by-step how to compile -and run Reliance Edge in a simulated Windows environment. - -## Why Use Reliance Edge? - -Reliance Edge is ideal for small embedded systems with data storage -requirements, especially if there is a chance of sudden power loss or other -system failures. Compared to "raw" disk access, using a file system like -Reliance Edge removes the burden of tracking which sectors belong to which -objects, and allows data to be updated more reliably. Compared to the FAT file -system, using Reliance Edge eliminates the possibility that file system data -will be left in an inconsistent state, corrupting the disk; Reliance Edge does -not need a fsck/CHKDSK utility. Compared to journaling file systems, Reliance -Edge has less overhead and results in less storage media wear for longer device -lifetimes. - -Reliance Edge uses a unique transactional model that not only prevents file -system corruption but also allows a set of changes to be made in an atomic "all -or nothing" fashion. This is very useful for applications that make sets of -interrelated changes. By using the features of Reliance Edge, a set of changes -can be incorporated into a single atomic transaction, which is committed in its -entirety or not at all even if interrupted by power loss; this means the -application does not need code to recover from partially-finished updates. - -## Hardware - -The typical hardware for Reliance Edge is a 32-bit microcontroller, but other -targets are possible. In its typical configurations, Reliance Edge needs at -least 4 KB to 5 KB of RAM, 11 to 18 KB of code space (on the ROM or NOR flash), -and 500 to 700 bytes of stack. - -Reliance Edge is not designed for high-end embedded systems that run complicated -operating systems like Linux or Windows Embedded Compact. Embedded systems of -that variety are better served by other file systems, like Datalight's -[Reliance Nitro](http://www.datalight.com/products/embedded-file-systems/reliance-nitro). - -## Getting Reliance Edge Working - -Before you can use Reliance Edge, it must be ported and configured. At a -minimum, porting includes filling-in functions so that Reliance Edge can issue -commands to your storage medium; depending on your needs, other functions may -need to be filled in as well. These functions reside in a subdirectory in the -os/ directory; see os/stub/ for a blank set of functions. Configuring includes -creating a project directory (start by copying projects/newproj) and creating -the two configuration files (redconf.h/redconf.c) using the Reliance Edge -Configuration Utility (which can be downloaded from -). - -These topics are covered in much greater detail in the _Developer's Guide_, -linked above. - -## Using Reliance Edge - -Using Reliance Edge is a simple matter of including the primary Reliance Edge -application header in your application (either include/redposix.h or -include/redfse.h) and compiling and linking against Reliance Edge binaries. -The Reliance Edge driver must be initialized before it is used (via the -red\_init() or RedFseInit() functions) and then volumes can be mounted and file -and directory functions invoked. The Reliance Edge API is documented in the -_Developer's Guide_ (linked above) and also via comments in the source code. - -## Licensing - -Reliance Edge is an open-source project licensed under the GNU General Public -License v2 (GPLv2). Businesses and individuals that for commercial or other -reasons cannot comply with the terms of the GPLv2 license may obtain a -commercial license before incorporating Reliance Edge into proprietary software -for distribution in any form. Visit -for more information. The commercial distribution also includes extra tests and -tools not distributed with the GPLv2 version. - -See LICENSE.txt for the full license terms of this distribution of the product. - -## Getting Help - -If you need assistance using Reliance Edge, and you have already consulted the -_Developer's Guide_, contact . - -In the near future, a community forum or message board will be set up to -facilitate discussion of Reliance Edge and allow users to get help from -Datalight and from each other. In the meantime, please use the email address -given above. - -## Contributing - -Contributions to Reliance Edge are welcome. Our policy is that Datalight must -own the copyright of all code incorporated into Reliance Edge; if contributing a -significant amount of code, you will be asked to file a copyright assignment -agreement. See CONTRIBUTING.txt for further details and contribution -guidelines. - -To report bugs, please create a GitHub issue or contact -. - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/README.txt b/FreeRTOS-Plus/Source/Reliance-Edge/README.txt deleted file mode 100755 index 106d923..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/README.txt +++ /dev/null @@ -1,140 +0,0 @@ - - -RELIANCE EDGE - - -Reliance Edge is a small, portable, highly reliable power-fail safe file -system for resource-constrained embedded systems like microcontrollers. -It is written in C and provides a familiar POSIX-like file system API, -making it easy to use in your application; or an alternate minimalist -API if your application has simple storage needs. Reliance Edge is -highly configurable and can be tuned to the precise needs of your -application. - - -Getting Help - -You will find this section later in our readme as well - but we wanted -to tell you up front: DATALIGHT WANTS TO HEAR FROM YOU! Whether it's -just to make comments about the product, to suggest new features, or to -tell us what you don't like - reach out! All comments and inquiries can -be directed to RelianceEdgeSupport@datalight.com. - - -Documentation - -The complete documentation for Reliance Edge is distributed separately. -It includes an API reference and detailed discussions of various aspects -of using Reliance Edge, including porting, building, configuring, and -testing. This complete documentation, called the _Developer's Guide_, -can be obtained for free from here: - -http://www.datalight.com/reliance-edge - -In addition this README, see doc/release_notes.md for a list of updates -to Reliance Edge and a list of known issues. There is also a quick-start -guide in the doc/ directory that describes step-by-step how to compile -and run Reliance Edge in a simulated Windows environment. - - -Why Use Reliance Edge? - -Reliance Edge is ideal for small embedded systems with data storage -requirements, especially if there is a chance of sudden power loss or -other system failures. Compared to "raw" disk access, using a file -system like Reliance Edge removes the burden of tracking which sectors -belong to which objects, and allows data to be updated more reliably. -Compared to the FAT file system, using Reliance Edge eliminates the -possibility that file system data will be left in an inconsistent state, -corrupting the disk; Reliance Edge does not need a fsck/CHKDSK utility. -Compared to journaling file systems, Reliance Edge has less overhead and -results in less storage media wear for longer device lifetimes. - -Reliance Edge uses a unique transactional model that not only prevents -file system corruption but also allows a set of changes to be made in an -atomic "all or nothing" fashion. This is very useful for applications -that make sets of interrelated changes. By using the features of -Reliance Edge, a set of changes can be incorporated into a single atomic -transaction, which is committed in its entirety or not at all even if -interrupted by power loss; this means the application does not need code -to recover from partially-finished updates. - - -Hardware - -The typical hardware for Reliance Edge is a 32-bit microcontroller, but -other targets are possible. In its typical configurations, Reliance Edge -needs at least 4 KB to 5 KB of RAM, 11 to 18 KB of code space (on the -ROM or NOR flash), and 500 to 700 bytes of stack. - -Reliance Edge is not designed for high-end embedded systems that run -complicated operating systems like Linux or Windows Embedded Compact. -Embedded systems of that variety are better served by other file -systems, like Datalight's Reliance Nitro. - - -Getting Reliance Edge Working - -Before you can use Reliance Edge, it must be ported and configured. At a -minimum, porting includes filling-in functions so that Reliance Edge can -issue commands to your storage medium; depending on your needs, other -functions may need to be filled in as well. These functions reside in a -subdirectory in the os/ directory; see os/stub/ for a blank set of -functions. Configuring includes creating a project directory (start by -copying projects/newproj) and creating the two configuration files -(redconf.h/redconf.c) using the Reliance Edge Configuration Utility -(which can be downloaded from http://www.datalight.com/reliance-edge). - -These topics are covered in much greater detail in the _Developer's -Guide_, linked above. - - -Using Reliance Edge - -Using Reliance Edge is a simple matter of including the primary Reliance -Edge application header in your application (either include/redposix.h -or include/redfse.h) and compiling and linking against Reliance Edge -binaries. The Reliance Edge driver must be initialized before it is used -(via the red_init() or RedFseInit() functions) and then volumes can be -mounted and file and directory functions invoked. The Reliance Edge API -is documented in the _Developer's Guide_ (linked above) and also via -comments in the source code. - - -Licensing - -Reliance Edge is an open-source project licensed under the GNU General -Public License v2 (GPLv2). Businesses and individuals that for -commercial or other reasons cannot comply with the terms of the GPLv2 -license may obtain a commercial license before incorporating Reliance -Edge into proprietary software for distribution in any form. Visit -http://www.datalight.com/reliance-edge for more information. The -commercial distribution also includes extra tests and tools not -distributed with the GPLv2 version. - -See LICENSE.txt for the full license terms of this distribution of the -product. - - -Getting Help - -If you need assistance using Reliance Edge, and you have already -consulted the _Developer's Guide_, contact -RelianceEdgeSupport@datalight.com. - -In the near future, a community forum or message board will be set up to -facilitate discussion of Reliance Edge and allow users to get help from -Datalight and from each other. In the meantime, please use the email -address given above. - - -Contributing - -Contributions to Reliance Edge are welcome. Our policy is that Datalight -must own the copyright of all code incorporated into Reliance Edge; if -contributing a significant amount of code, you will be asked to file a -copyright assignment agreement. See CONTRIBUTING.txt for further details -and contribution guidelines. - -To report bugs, please create a GitHub issue or contact -RelianceEdgeSupport@datalight.com. diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/blockio.c b/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/blockio.c deleted file mode 100755 index 897143d..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/blockio.c +++ /dev/null @@ -1,198 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements block device I/O using logical blocks as the units. - - The OS block device implementations operate on sectors. The core does I/O - in terms of logical blocks: this module translates from logical blocks to - sectors. - - If bBlockIoRetries is greater than 0 for the current volume, then this - module will retry block device calls on failure up to the configured number - of times. This behavior caters to the type of unreliable hardware and - drivers that are sometimes found in the IoT world, where one operation may - fail but the next may still succeed. -*/ -#include -#include - - -/** @brief Read a range of logical blocks. - - @param bVolNum The volume whose block device is being read from. - @param ulBlockStart The first block to read. - @param ulBlockCount The number of blocks to read. - @param pBuffer The buffer to populate with the data read. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EINVAL Invalid parameters. -*/ -REDSTATUS RedIoRead( - uint8_t bVolNum, - uint32_t ulBlockStart, - uint32_t ulBlockCount, - void *pBuffer) -{ - REDSTATUS ret = 0; - - if( (bVolNum >= REDCONF_VOLUME_COUNT) - || (ulBlockStart >= gaRedVolume[bVolNum].ulBlockCount) - || ((gaRedVolume[bVolNum].ulBlockCount - ulBlockStart) < ulBlockCount) - || (ulBlockCount == 0U) - || (pBuffer == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - uint8_t bSectorShift = gaRedVolume[bVolNum].bBlockSectorShift; - uint64_t ullSectorStart = (uint64_t)ulBlockStart << bSectorShift; - uint32_t ulSectorCount = ulBlockCount << bSectorShift; - uint8_t bRetryIdx; - - REDASSERT(bSectorShift < 32U); - REDASSERT((ulSectorCount >> bSectorShift) == ulBlockCount); - - for(bRetryIdx = 0U; bRetryIdx <= gpRedVolConf->bBlockIoRetries; bRetryIdx++) - { - ret = RedOsBDevRead(bVolNum, ullSectorStart, ulSectorCount, pBuffer); - - if(ret == 0) - { - break; - } - } - } - - CRITICAL_ASSERT(ret == 0); - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Write a range of logical blocks. - - @param bVolNum The volume whose block device is being written to. - @param ulBlockStart The first block to write. - @param ulBlockCount The number of blocks to write. - @param pBuffer The buffer containing the data to write. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EINVAL Invalid parameters. -*/ -REDSTATUS RedIoWrite( - uint8_t bVolNum, - uint32_t ulBlockStart, - uint32_t ulBlockCount, - const void *pBuffer) -{ - REDSTATUS ret = 0; - - if( (bVolNum >= REDCONF_VOLUME_COUNT) - || (ulBlockStart >= gaRedVolume[bVolNum].ulBlockCount) - || ((gaRedVolume[bVolNum].ulBlockCount - ulBlockStart) < ulBlockCount) - || (ulBlockCount == 0U) - || (pBuffer == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - uint8_t bSectorShift = gaRedVolume[bVolNum].bBlockSectorShift; - uint64_t ullSectorStart = (uint64_t)ulBlockStart << bSectorShift; - uint32_t ulSectorCount = ulBlockCount << bSectorShift; - uint8_t bRetryIdx; - - REDASSERT(bSectorShift < 32U); - REDASSERT((ulSectorCount >> bSectorShift) == ulBlockCount); - - for(bRetryIdx = 0U; bRetryIdx <= gpRedVolConf->bBlockIoRetries; bRetryIdx++) - { - ret = RedOsBDevWrite(bVolNum, ullSectorStart, ulSectorCount, pBuffer); - - if(ret == 0) - { - break; - } - } - } - - CRITICAL_ASSERT(ret == 0); - - return ret; -} - - -/** @brief Flush any caches beneath the file system. - - @param bVolNum The volume number of the volume whose block device is being - flushed. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bVolNum is an invalid volume number. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedIoFlush( - uint8_t bVolNum) -{ - REDSTATUS ret = 0; - - if(bVolNum >= REDCONF_VOLUME_COUNT) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - uint8_t bRetryIdx; - - for(bRetryIdx = 0U; bRetryIdx <= gpRedVolConf->bBlockIoRetries; bRetryIdx++) - { - ret = RedOsBDevFlush(bVolNum); - - if(ret == 0) - { - break; - } - } - } - - CRITICAL_ASSERT(ret == 0); - - return ret; -} -#endif /* REDCONF_READ_ONLY == 0 */ - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/buffer.c b/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/buffer.c deleted file mode 100755 index 17717e0..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/buffer.c +++ /dev/null @@ -1,1212 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements the block device buffering system. - - This module implements the block buffer cache. It has a number of block - sized buffers which are used to store data from a given block (identified - by both block number and volume number: this cache is shared among all - volumes). Block buffers may be either dirty or clean. Most I/O passes - through this module. When a buffer is needed for a block which is not in - the cache, a "victim" is selected via a simple LRU scheme. -*/ -#include -#include - - -#if DINDIR_POINTERS > 0U - #define INODE_META_BUFFERS 3U /* Inode, double indirect, indirect */ -#elif REDCONF_INDIRECT_POINTERS > 0U - #define INODE_META_BUFFERS 2U /* Inode, indirect */ -#elif REDCONF_DIRECT_POINTERS == INODE_ENTRIES - #define INODE_META_BUFFERS 1U /* Inode only */ -#endif - -#define INODE_BUFFERS (INODE_META_BUFFERS + 1U) /* Add data buffer */ - -#if REDCONF_IMAP_EXTERNAL == 1 - #define IMAP_BUFFERS 1U -#else - #define IMAP_BUFFERS 0U -#endif - -#if (REDCONF_READ_ONLY == 1) || (REDCONF_API_FSE == 1) - /* Read, write, truncate, lookup: One inode all the way down, plus imap. - */ - #define MINIMUM_BUFFER_COUNT (INODE_BUFFERS + IMAP_BUFFERS) -#elif REDCONF_API_POSIX == 1 - #if REDCONF_API_POSIX_RENAME == 1 - #if REDCONF_RENAME_ATOMIC == 1 - /* Two parent directories all the way down. Source and destination inode - buffer. One inode buffer for cyclic rename detection. Imap. The - parent inode buffers are released before deleting the destination - inode, so that does not increase the minimum. - */ - #define MINIMUM_BUFFER_COUNT (INODE_BUFFERS + INODE_BUFFERS + 3U + IMAP_BUFFERS) - #else - /* Two parent directories all the way down. Source inode buffer. One - inode buffer for cyclic rename detection. Imap. - */ - #define MINIMUM_BUFFER_COUNT (INODE_BUFFERS + INODE_BUFFERS + 2U + IMAP_BUFFERS) - #endif - #else - /* Link/create: Needs a parent inode all the way down, an extra inode - buffer, and an imap buffer. - - Unlink is the same, since the parent inode buffers are released before - the inode is deleted. - */ - #define MINIMUM_BUFFER_COUNT (INODE_BUFFERS + 1U + IMAP_BUFFERS) - #endif -#endif - -#if REDCONF_BUFFER_COUNT < MINIMUM_BUFFER_COUNT -#error "REDCONF_BUFFER_COUNT is too low for the configuration" -#endif - - -/* A note on the typecasts in the below macros: Operands to bitwise operators - are subject to the "usual arithmetic conversions". This means that the - flags, which have uint16_t values, are promoted to int. MISRA-C:2012 R10.1 - forbids using signed integers in bitwise operations, so we cast to uint32_t - to avoid the integer promotion, then back to uint16_t to reflect the actual - type. -*/ -#define BFLAG_META_MASK (uint16_t)((uint32_t)BFLAG_META_MASTER | BFLAG_META_IMAP | BFLAG_META_INODE | BFLAG_META_INDIR | BFLAG_META_DINDIR) -#define BFLAG_MASK (uint16_t)((uint32_t)BFLAG_DIRTY | BFLAG_NEW | BFLAG_META_MASK) - - -/* An invalid block number. Used to indicate buffers which are not currently - in use. -*/ -#define BBLK_INVALID UINT32_MAX - - -/** @brief Metadata stored for each block buffer. - - To make better use of CPU caching when searching the BUFFERHEAD array, this - structure should be kept small. -*/ -typedef struct -{ - uint32_t ulBlock; /**< Block number the buffer is associated with; BBLK_INVALID if unused. */ - uint8_t bVolNum; /**< Volume the block resides on. */ - uint8_t bRefCount; /**< Number of references. */ - uint16_t uFlags; /**< Buffer flags: mask of BFLAG_* values. */ -} BUFFERHEAD; - - -/** @brief State information for the block buffer module. -*/ -typedef struct -{ - /** Number of buffers which are referenced (have a bRefCount > 0). - */ - uint16_t uNumUsed; - - /** MRU array. Each element of the array stores a buffer index; each buffer - index appears in the array once and only once. The first element of the - array is the most-recently-used (MRU) buffer, followed by the next most - recently used, and so on, till the last element, which is the least- - recently-used (LRU) buffer. - */ - uint8_t abMRU[REDCONF_BUFFER_COUNT]; - - /** Buffer heads, storing metadata for each buffer. - */ - BUFFERHEAD aHead[REDCONF_BUFFER_COUNT]; - - /** Array of memory for the block buffers themselves. - - Force 64-bit alignment of the aabBuffer array to ensure that it is safe - to cast buffer pointers to node structure pointers. - */ - ALIGNED_2D_BYTE_ARRAY(b, aabBuffer, REDCONF_BUFFER_COUNT, REDCONF_BLOCK_SIZE); -} BUFFERCTX; - - -static bool BufferIsValid(const uint8_t *pbBuffer, uint16_t uFlags); -static bool BufferToIdx(const void *pBuffer, uint8_t *pbIdx); -#if REDCONF_READ_ONLY == 0 -static REDSTATUS BufferWrite(uint8_t bIdx); -static REDSTATUS BufferFinalize(uint8_t *pbBuffer, uint16_t uFlags); -#endif -static void BufferMakeLRU(uint8_t bIdx); -static void BufferMakeMRU(uint8_t bIdx); -static bool BufferFind(uint32_t ulBlock, uint8_t *pbIdx); - -#ifdef REDCONF_ENDIAN_SWAP -static void BufferEndianSwap(const void *pBuffer, uint16_t uFlags); -static void BufferEndianSwapHeader(NODEHEADER *pHeader); -static void BufferEndianSwapMaster(MASTERBLOCK *pMaster); -static void BufferEndianSwapMetaRoot(METAROOT *pMetaRoot); -static void BufferEndianSwapInode(INODE *pInode); -static void BufferEndianSwapIndir(INDIR *pIndir); -#endif - - -static BUFFERCTX gBufCtx; - - -/** @brief Initialize the buffers. -*/ -void RedBufferInit(void) -{ - uint8_t bIdx; - - RedMemSet(&gBufCtx, 0U, sizeof(gBufCtx)); - - for(bIdx = 0U; bIdx < REDCONF_BUFFER_COUNT; bIdx++) - { - /* When the buffers have been freshly initialized, acquire the buffers - in the order in which they appear in the array. - */ - gBufCtx.abMRU[bIdx] = (uint8_t)((REDCONF_BUFFER_COUNT - bIdx) - 1U); - gBufCtx.aHead[bIdx].ulBlock = BBLK_INVALID; - } -} - - -/** @brief Acquire a buffer. - - @param ulBlock Block number to acquire. - @param uFlags BFLAG_ values for the operation. - @param ppBuffer On success, populated with the acquired buffer. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EINVAL Invalid parameters. - @retval -RED_EBUSY All buffers are referenced. -*/ -REDSTATUS RedBufferGet( - uint32_t ulBlock, - uint16_t uFlags, - void **ppBuffer) -{ - REDSTATUS ret = 0; - uint8_t bIdx; - - if((ulBlock >= gpRedVolume->ulBlockCount) || ((uFlags & BFLAG_MASK) != uFlags) || (ppBuffer == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - if(BufferFind(ulBlock, &bIdx)) - { - /* Error if the buffer exists and BFLAG_NEW was specified, since - the new flag is used when a block is newly allocated/created, so - the block was previously free and and there should never be an - existing buffer for a free block. - - Error if the buffer exists but does not have the same type as - was requested. - */ - if( ((uFlags & BFLAG_NEW) != 0U) - || ((uFlags & BFLAG_META_MASK) != (gBufCtx.aHead[bIdx].uFlags & BFLAG_META_MASK))) - { - CRITICAL_ERROR(); - ret = -RED_EFUBAR; - } - } - else if(gBufCtx.uNumUsed == REDCONF_BUFFER_COUNT) - { - /* The MINIMUM_BUFFER_COUNT is supposed to ensure that no operation - ever runs out of buffers, so this should never happen. - */ - CRITICAL_ERROR(); - ret = -RED_EBUSY; - } - else - { - BUFFERHEAD *pHead; - - /* Search for the least recently used buffer which is not - referenced. - */ - for(bIdx = (uint8_t)(REDCONF_BUFFER_COUNT - 1U); bIdx > 0U; bIdx--) - { - if(gBufCtx.aHead[gBufCtx.abMRU[bIdx]].bRefCount == 0U) - { - break; - } - } - - bIdx = gBufCtx.abMRU[bIdx]; - pHead = &gBufCtx.aHead[bIdx]; - - if(pHead->bRefCount == 0U) - { - /* If the LRU buffer is valid and dirty, write it out before - repurposing it. - */ - if(((pHead->uFlags & BFLAG_DIRTY) != 0U) && (pHead->ulBlock != BBLK_INVALID)) - { - #if REDCONF_READ_ONLY == 1 - CRITICAL_ERROR(); - ret = -RED_EFUBAR; - #else - ret = BufferWrite(bIdx); - #endif - } - } - else - { - /* All the buffers are used, which should have been caught by - checking gBufCtx.uNumUsed. - */ - CRITICAL_ERROR(); - ret = -RED_EBUSY; - } - - if(ret == 0) - { - if((uFlags & BFLAG_NEW) == 0U) - { - /* Invalidate the LRU buffer. If the read fails, we do not - want the buffer head to continue to refer to the old - block number, since the read, even if it fails, may have - partially overwritten the buffer data (consider the case - where block size exceeds sector size, and some but not - all of the sectors are read successfully), and if the - buffer were to be used subsequently with its partially - erroneous contents, bad things could happen. - */ - pHead->ulBlock = BBLK_INVALID; - - ret = RedIoRead(gbRedVolNum, ulBlock, 1U, gBufCtx.b.aabBuffer[bIdx]); - - if((ret == 0) && ((uFlags & BFLAG_META) != 0U)) - { - if(!BufferIsValid(gBufCtx.b.aabBuffer[bIdx], uFlags)) - { - /* A corrupt metadata node is usually a critical - error. The master block is an exception since - it might be invalid because the volume is not - mounted; that condition is expected and should - not result in an assertion. - */ - CRITICAL_ASSERT((uFlags & BFLAG_META_MASTER) == BFLAG_META_MASTER); - ret = -RED_EIO; - } - } - - #ifdef REDCONF_ENDIAN_SWAP - if(ret == 0) - { - BufferEndianSwap(gBufCtx.b.aabBuffer[bIdx], uFlags); - } - #endif - } - else - { - RedMemSet(gBufCtx.b.aabBuffer[bIdx], 0U, REDCONF_BLOCK_SIZE); - } - } - - if(ret == 0) - { - pHead->bVolNum = gbRedVolNum; - pHead->ulBlock = ulBlock; - pHead->uFlags = 0U; - } - } - - /* Reference the buffer, update its flags, and promote it to MRU. This - happens both when BufferFind() found an existing buffer for the - block and when the LRU buffer was repurposed to create a buffer for - the block. - */ - if(ret == 0) - { - BUFFERHEAD *pHead = &gBufCtx.aHead[bIdx]; - - pHead->bRefCount++; - - if(pHead->bRefCount == 1U) - { - gBufCtx.uNumUsed++; - } - - /* BFLAG_NEW tells this function to zero the buffer instead of - reading it from disk; it has no meaning later on, and thus is - not saved. - */ - pHead->uFlags |= (uFlags & (~BFLAG_NEW)); - - BufferMakeMRU(bIdx); - - *ppBuffer = gBufCtx.b.aabBuffer[bIdx]; - } - } - - return ret; -} - - -/** @brief Release a buffer. - - @param pBuffer The buffer to release. - */ -void RedBufferPut( - const void *pBuffer) -{ - uint8_t bIdx; - - if(!BufferToIdx(pBuffer, &bIdx)) - { - REDERROR(); - } - else - { - REDASSERT(gBufCtx.aHead[bIdx].bRefCount > 0U); - gBufCtx.aHead[bIdx].bRefCount--; - - if(gBufCtx.aHead[bIdx].bRefCount == 0U) - { - REDASSERT(gBufCtx.uNumUsed > 0U); - gBufCtx.uNumUsed--; - } - } -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Flush all buffers for the active volume in the given range of blocks. - - @param ulBlockStart Starting block number to flush. - @param ulBlockCount Count of blocks, starting at @p ulBlockStart, to flush. - Must not be zero. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EINVAL Invalid parameters. -*/ -REDSTATUS RedBufferFlush( - uint32_t ulBlockStart, - uint32_t ulBlockCount) -{ - REDSTATUS ret = 0; - - if( (ulBlockStart >= gpRedVolume->ulBlockCount) - || ((gpRedVolume->ulBlockCount - ulBlockStart) < ulBlockCount) - || (ulBlockCount == 0U)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - uint8_t bIdx; - - for(bIdx = 0U; bIdx < REDCONF_BUFFER_COUNT; bIdx++) - { - BUFFERHEAD *pHead = &gBufCtx.aHead[bIdx]; - - if( (pHead->bVolNum == gbRedVolNum) - && (pHead->ulBlock != BBLK_INVALID) - && ((pHead->uFlags & BFLAG_DIRTY) != 0U) - && (pHead->ulBlock >= ulBlockStart) - && (pHead->ulBlock < (ulBlockStart + ulBlockCount))) - { - ret = BufferWrite(bIdx); - - if(ret == 0) - { - pHead->uFlags &= (~BFLAG_DIRTY); - } - else - { - break; - } - } - } - } - - return ret; -} - - -/** @brief Mark a buffer dirty - - @param pBuffer The buffer to mark dirty. -*/ -void RedBufferDirty( - const void *pBuffer) -{ - uint8_t bIdx; - - if(!BufferToIdx(pBuffer, &bIdx)) - { - REDERROR(); - } - else - { - REDASSERT(gBufCtx.aHead[bIdx].bRefCount > 0U); - - gBufCtx.aHead[bIdx].uFlags |= BFLAG_DIRTY; - } -} - - -/** @brief Branch a buffer, marking it dirty and assigning a new block number. - - @param pBuffer The buffer to branch. - @param ulBlockNew The new block number for the buffer. -*/ -void RedBufferBranch( - const void *pBuffer, - uint32_t ulBlockNew) -{ - uint8_t bIdx; - - if( !BufferToIdx(pBuffer, &bIdx) - || (ulBlockNew >= gpRedVolume->ulBlockCount)) - { - REDERROR(); - } - else - { - BUFFERHEAD *pHead = &gBufCtx.aHead[bIdx]; - - REDASSERT(pHead->bRefCount > 0U); - REDASSERT((pHead->uFlags & BFLAG_DIRTY) == 0U); - - pHead->uFlags |= BFLAG_DIRTY; - pHead->ulBlock = ulBlockNew; - } -} - - -#if (REDCONF_API_POSIX == 1) || FORMAT_SUPPORTED -/** @brief Discard a buffer, releasing it and marking it invalid. - - @param pBuffer The buffer to discard. -*/ -void RedBufferDiscard( - const void *pBuffer) -{ - uint8_t bIdx; - - if(!BufferToIdx(pBuffer, &bIdx)) - { - REDERROR(); - } - else - { - REDASSERT(gBufCtx.aHead[bIdx].bRefCount == 1U); - REDASSERT(gBufCtx.uNumUsed > 0U); - - gBufCtx.aHead[bIdx].bRefCount = 0U; - gBufCtx.aHead[bIdx].ulBlock = BBLK_INVALID; - - gBufCtx.uNumUsed--; - - BufferMakeLRU(bIdx); - } -} -#endif -#endif /* REDCONF_READ_ONLY == 0 */ - - -/** @brief Discard a range of buffers, marking them invalid. - - @param ulBlockStart The starting block number to discard - @param ulBlockCount The number of blocks, starting at @p ulBlockStart, to - discard. Must not be zero. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL Invalid parameters. - @retval -RED_EBUSY A block in the desired range is referenced. -*/ -REDSTATUS RedBufferDiscardRange( - uint32_t ulBlockStart, - uint32_t ulBlockCount) -{ - REDSTATUS ret = 0; - - if( (ulBlockStart >= gpRedVolume->ulBlockCount) - || ((gpRedVolume->ulBlockCount - ulBlockStart) < ulBlockCount) - || (ulBlockCount == 0U)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - uint8_t bIdx; - - for(bIdx = 0U; bIdx < REDCONF_BUFFER_COUNT; bIdx++) - { - BUFFERHEAD *pHead = &gBufCtx.aHead[bIdx]; - - if( (pHead->bVolNum == gbRedVolNum) - && (pHead->ulBlock != BBLK_INVALID) - && (pHead->ulBlock >= ulBlockStart) - && (pHead->ulBlock < (ulBlockStart + ulBlockCount))) - { - if(pHead->bRefCount == 0U) - { - pHead->ulBlock = BBLK_INVALID; - - BufferMakeLRU(bIdx); - } - else - { - /* This should never happen. There are three general cases - when this function is used: - - 1) Discarding every block, as happens during unmount - and at the end of format. There should no longer be - any referenced buffers at those points. - 2) Discarding a block which has become free. All - buffers for such blocks should be put or branched - beforehand. - 3) Discarding of blocks that were just written straight - to disk, leaving stale data in the buffer. The write - code should never reference buffers for these blocks, - since they would not be needed or used. - */ - CRITICAL_ERROR(); - ret = -RED_EBUSY; - break; - } - } - } - } - - return ret; -} - - -/** Determine whether a metadata buffer is valid. - - This includes checking its signature, CRC, and sequence number. - - @param pbBuffer Pointer to the metadata buffer to validate. - @param uFlags The buffer flags provided by the caller. Used to determine - the expected signature. - - @return Whether the metadata buffer is valid. - - @retval true The metadata buffer is valid. - @retval false The metadata buffer is invalid. -*/ -static bool BufferIsValid( - const uint8_t *pbBuffer, - uint16_t uFlags) -{ - bool fValid; - - if((pbBuffer == NULL) || ((uFlags & BFLAG_MASK) != uFlags)) - { - REDERROR(); - fValid = false; - } - else - { - NODEHEADER buf; - uint16_t uMetaFlags = uFlags & BFLAG_META_MASK; - - /* Casting pbBuffer to (NODEHEADER *) would run afoul MISRA-C:2012 - R11.3, so instead copy the fields out. - */ - RedMemCpy(&buf.ulSignature, &pbBuffer[NODEHEADER_OFFSET_SIG], sizeof(buf.ulSignature)); - RedMemCpy(&buf.ulCRC, &pbBuffer[NODEHEADER_OFFSET_CRC], sizeof(buf.ulCRC)); - RedMemCpy(&buf.ullSequence, &pbBuffer[NODEHEADER_OFFSET_SEQ], sizeof(buf.ullSequence)); - - #ifdef REDCONF_ENDIAN_SWAP - buf.ulCRC = RedRev32(buf.ulCRC); - buf.ulSignature = RedRev32(buf.ulSignature); - buf.ullSequence = RedRev64(buf.ullSequence); - #endif - - /* Make sure the signature is correct for the type of metadata block - requested by the caller. - */ - switch(buf.ulSignature) - { - case META_SIG_MASTER: - fValid = (uMetaFlags == BFLAG_META_MASTER); - break; - #if REDCONF_IMAP_EXTERNAL == 1 - case META_SIG_IMAP: - fValid = (uMetaFlags == BFLAG_META_IMAP); - break; - #endif - case META_SIG_INODE: - fValid = (uMetaFlags == BFLAG_META_INODE); - break; - #if DINDIR_POINTERS > 0U - case META_SIG_DINDIR: - fValid = (uMetaFlags == BFLAG_META_DINDIR); - break; - #endif - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - case META_SIG_INDIR: - fValid = (uMetaFlags == BFLAG_META_INDIR); - break; - #endif - default: - fValid = false; - break; - } - - if(fValid) - { - uint32_t ulComputedCrc; - - /* Check for disk corruption by comparing the stored CRC with one - computed from the data. - - Also check the sequence number: if it is greater than the - current sequence number, the block is from a previous format - or the disk is writing blocks out of order. During mount, - before the metaroots have been read, the sequence number will - be unknown, and the check is skipped. - */ - ulComputedCrc = RedCrcNode(pbBuffer); - if(buf.ulCRC != ulComputedCrc) - { - fValid = false; - } - else if(gpRedVolume->fMounted && (buf.ullSequence >= gpRedVolume->ullSequence)) - { - fValid = false; - } - else - { - /* Buffer is valid. No action, fValid is already true. - */ - } - } - } - - return fValid; -} - - -/** @brief Derive the index of the buffer. - - @param pBuffer The buffer to derive the index of. - @param pbIdx On success, populated with the index of the buffer. - - @return Boolean indicating result. - - @retval true Success. - @retval false Failure. @p pBuffer is not a valid buffer pointer. -*/ -static bool BufferToIdx( - const void *pBuffer, - uint8_t *pbIdx) -{ - bool fRet = false; - - if((pBuffer != NULL) && (pbIdx != NULL)) - { - uint8_t bIdx; - - /* pBuffer should be a pointer to one of the block buffers. - - A good compiler should optimize this loop into a bounds check and an - alignment check, although GCC has been observed to not do so; if the - number of buffers is small, it should not make much difference. The - alternative is to use pointer comparisons, but this both deviates - from MISRA-C:2012 and involves undefined behavior. - */ - for(bIdx = 0U; bIdx < REDCONF_BUFFER_COUNT; bIdx++) - { - if(pBuffer == &gBufCtx.b.aabBuffer[bIdx][0U]) - { - break; - } - } - - if( (bIdx < REDCONF_BUFFER_COUNT) - && (gBufCtx.aHead[bIdx].ulBlock != BBLK_INVALID) - && (gBufCtx.aHead[bIdx].bVolNum == gbRedVolNum)) - { - *pbIdx = bIdx; - fRet = true; - } - } - - return fRet; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Write out a dirty buffer. - - @param bIdx The index of the buffer to write. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EINVAL Invalid parameters. -*/ -static REDSTATUS BufferWrite( - uint8_t bIdx) -{ - REDSTATUS ret = 0; - - if(bIdx < REDCONF_BUFFER_COUNT) - { - const BUFFERHEAD *pHead = &gBufCtx.aHead[bIdx]; - - REDASSERT((pHead->uFlags & BFLAG_DIRTY) != 0U); - - if((pHead->uFlags & BFLAG_META) != 0U) - { - ret = BufferFinalize(gBufCtx.b.aabBuffer[bIdx], pHead->uFlags); - } - - if(ret == 0) - { - ret = RedIoWrite(pHead->bVolNum, pHead->ulBlock, 1U, gBufCtx.b.aabBuffer[bIdx]); - - #ifdef REDCONF_ENDIAN_SWAP - BufferEndianSwap(gBufCtx.b.aabBuffer[bIdx], pHead->uFlags); - #endif - } - } - else - { - REDERROR(); - ret = -RED_EINVAL; - } - - return ret; -} - - -/** @brief Finalize a metadata buffer. - - This updates the CRC and the sequence number. It also sets the signature, - though this is only truly needed if the buffer is new. - - @param pbBuffer Pointer to the metadata buffer to finalize. - @param uFlags The associated buffer flags. Used to determine the expected - signature. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL Invalid parameter; or maximum sequence number reached. -*/ -static REDSTATUS BufferFinalize( - uint8_t *pbBuffer, - uint16_t uFlags) -{ - REDSTATUS ret = 0; - - if((pbBuffer == NULL) || ((uFlags & BFLAG_MASK) != uFlags)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - uint32_t ulSignature; - - switch(uFlags & BFLAG_META_MASK) - { - case BFLAG_META_MASTER: - ulSignature = META_SIG_MASTER; - break; - #if REDCONF_IMAP_EXTERNAL == 1 - case BFLAG_META_IMAP: - ulSignature = META_SIG_IMAP; - break; - #endif - case BFLAG_META_INODE: - ulSignature = META_SIG_INODE; - break; - #if DINDIR_POINTERS > 0U - case BFLAG_META_DINDIR: - ulSignature = META_SIG_DINDIR; - break; - #endif - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - case BFLAG_META_INDIR: - ulSignature = META_SIG_INDIR; - break; - #endif - default: - ulSignature = 0U; - break; - } - - if(ulSignature == 0U) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - uint64_t ullSeqNum = gpRedVolume->ullSequence; - - ret = RedVolSeqNumIncrement(); - if(ret == 0) - { - uint32_t ulCrc; - - RedMemCpy(&pbBuffer[NODEHEADER_OFFSET_SIG], &ulSignature, sizeof(ulSignature)); - RedMemCpy(&pbBuffer[NODEHEADER_OFFSET_SEQ], &ullSeqNum, sizeof(ullSeqNum)); - - #ifdef REDCONF_ENDIAN_SWAP - BufferEndianSwap(pbBuffer, uFlags); - #endif - - ulCrc = RedCrcNode(pbBuffer); - #ifdef REDCONF_ENDIAN_SWAP - ulCrc = RedRev32(ulCrc); - #endif - RedMemCpy(&pbBuffer[NODEHEADER_OFFSET_CRC], &ulCrc, sizeof(ulCrc)); - } - } - } - - return ret; -} -#endif /* REDCONF_READ_ONLY == 0 */ - - -#ifdef REDCONF_ENDIAN_SWAP -/** @brief Swap the byte order of a metadata buffer - - Does nothing if the buffer is not a metadata node. Also does nothing for - meta roots, which don't go through the buffers anyways. - - @param pBuffer Pointer to the metadata buffer to swap - @param uFlags The associated buffer flags. Used to determin the type of - metadata node. -*/ -static void BufferEndianSwap( - void *pBuffer, - uint16_t uFlags) -{ - if((pBuffer == NULL) || ((uFlags & BFLAG_MASK) != uFlags)) - { - REDERROR(); - } - else if((uFlags & BFLAG_META_MASK) != 0) - { - BufferEndianSwapHeader(pBuffer); - - switch(uFlags & BFLAG_META_MASK) - { - case BFLAG_META_MASTER: - BufferEndianSwapMaster(pBuffer); - break; - case BFLAG_META_INODE: - BufferEndianSwapInode(pBuffer); - break; - #if DINDIR_POINTERS > 0U - case BFLAG_META_DINDIR: - BufferEndianSwapIndir(pBuffer); - break; - #endif - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - case BFLAG_META_INDIR: - BufferEndianSwapIndir(pBuffer); - break; - #endif - default: - break; - } - } - else - { - /* File data buffers do not need to be swapped. - */ - } -} - - -/** @brief Swap the byte order of a metadata node header - - @param pHeader Pointer to the metadata node header to swap -*/ -static void BufferEndianSwapHeader( - NODEHEADER *pHeader) -{ - if(pHeader == NULL) - { - REDERROR(); - } - else - { - pHeader->ulSignature = RedRev32(pHeader->ulSignature); - pHeader->ulCRC = RedRev32(pHeader->ulCRC); - pHeader->ullSequence = RedRev64(pHeader->ullSequence); - } -} - - -/** @brief Swap the byte order of a master block - - @param pMaster Pointer to the master block to swap -*/ -static void BufferEndianSwapMaster( - MASTERBLOCK *pMaster) -{ - if(pMaster == NULL) - { - REDERROR(); - } - else - { - pMaster->ulVersion = RedRev32(pMaster->ulVersion); - pMaster->ulFormatTime = RedRev32(pMaster->ulFormatTime); - pMaster->ulInodeCount = RedRev32(pMaster->ulInodeCount); - pMaster->ulBlockCount = RedRev32(pMaster->ulBlockCount); - pMaster->uMaxNameLen = RedRev16(pMaster->uMaxNameLen); - pMaster->uDirectPointers = RedRev16(pMaster->uDirectPointers); - pMaster->uIndirectPointers = RedRev16(pMaster->uIndirectPointers); - } -} - - -/** @brief Swap the byte order of an inode - - @param pInode Pointer to the inode to swap -*/ -static void BufferEndianSwapInode( - INODE *pInode) -{ - if(pInode == NULL) - { - REDERROR(); - } - else - { - uint32_t ulIdx; - - pInode->ullSize = RedRev64(pInode->ullSize); - - #if REDCONF_INODE_BLOCKS == 1 - pInode->ulBlocks = RedRev32(pInode->ulBlocks); - #endif - - #if REDCONF_INODE_TIMESTAMPS == 1 - pInode->ulATime = RedRev32(pInode->ulATime); - pInode->ulMTime = RedRev32(pInode->ulMTime); - pInode->ulCTime = RedRev32(pInode->ulCTime); - #endif - - pInode->uMode = RedRev16(pInode->uMode); - - #if (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_LINK == 1) - pInode->uNLink = RedRev16(pInode->uNLink); - #endif - - #if REDCONF_API_POSIX == 1 - pInode->ulPInode = RedRev32(pInode->ulPInode); - #endif - - for(ulIdx = 0; ulIdx < INODE_ENTRIES; ulIdx++) - { - pInode->aulEntries[ulIdx] = RedRev32(pInode->aulEntries[ulIdx]); - } - } -} - - -#if REDCONF_DIRECT_POINTERS < INODE_ENTRIES -/** @brief Swap the byte order of an indirect or double indirect node - - @param pIndir Pointer to the node to swap -*/ -static void BufferEndianSwapIndir( - INDIR *pIndir) -{ - if(pIndir == NULL) - { - REDERROR(); - } - else - { - uint32_t ulIdx; - - pIndir->ulInode = RedRev32(pIndir->ulInode); - - for(ulIdx = 0; ulIdx < INDIR_ENTRIES; ulIdx++) - { - pIndir->aulEntries[ulIdx] = RedRev32(pIndir->aulEntries[ulIdx]); - } - } -} - -#endif /* REDCONF_DIRECT_POINTERS < INODE_ENTRIES */ -#endif /* #ifdef REDCONF_ENDIAN_SWAP */ - - -/** @brief Mark a buffer as least recently used. - - @param bIdx The index of the buffer to make LRU. -*/ -static void BufferMakeLRU( - uint8_t bIdx) -{ - if(bIdx >= REDCONF_BUFFER_COUNT) - { - REDERROR(); - } - else if(bIdx != gBufCtx.abMRU[REDCONF_BUFFER_COUNT - 1U]) - { - uint8_t bMruIdx; - - /* Find the current position of the buffer in the MRU array. We do not - need to check the last slot, since we already know from the above - check that the index is not there. - */ - for(bMruIdx = 0U; bMruIdx < (REDCONF_BUFFER_COUNT - 1U); bMruIdx++) - { - if(bIdx == gBufCtx.abMRU[bMruIdx]) - { - break; - } - } - - if(bMruIdx < (REDCONF_BUFFER_COUNT - 1U)) - { - /* Move the buffer index to the back of the MRU array, making it - the LRU buffer. - */ - RedMemMove(&gBufCtx.abMRU[bMruIdx], &gBufCtx.abMRU[bMruIdx + 1U], REDCONF_BUFFER_COUNT - ((uint32_t)bMruIdx + 1U)); - gBufCtx.abMRU[REDCONF_BUFFER_COUNT - 1U] = bIdx; - } - else - { - REDERROR(); - } - } - else - { - /* Buffer already LRU, nothing to do. - */ - } -} - - -/** @brief Mark a buffer as most recently used. - - @param bIdx The index of the buffer to make MRU. -*/ -static void BufferMakeMRU( - uint8_t bIdx) -{ - if(bIdx >= REDCONF_BUFFER_COUNT) - { - REDERROR(); - } - else if(bIdx != gBufCtx.abMRU[0U]) - { - uint8_t bMruIdx; - - /* Find the current position of the buffer in the MRU array. We do not - need to check the first slot, since we already know from the above - check that the index is not there. - */ - for(bMruIdx = 1U; bMruIdx < REDCONF_BUFFER_COUNT; bMruIdx++) - { - if(bIdx == gBufCtx.abMRU[bMruIdx]) - { - break; - } - } - - if(bMruIdx < REDCONF_BUFFER_COUNT) - { - /* Move the buffer index to the front of the MRU array, making it - the MRU buffer. - */ - RedMemMove(&gBufCtx.abMRU[1U], &gBufCtx.abMRU[0U], bMruIdx); - gBufCtx.abMRU[0U] = bIdx; - } - else - { - REDERROR(); - } - } - else - { - /* Buffer already MRU, nothing to do. - */ - } -} - - -/** @brief Find a block in the buffers. - - @param ulBlock The block number to find. - @param pbIdx If the block is buffered (true is returned), populated with - the index of the buffer. - - @return Boolean indicating whether or not the block is buffered. - - @retval true @p ulBlock is buffered, and its index has been stored in - @p pbIdx. - @retval false @p ulBlock is not buffered. -*/ -static bool BufferFind( - uint32_t ulBlock, - uint8_t *pbIdx) -{ - bool ret = false; - - if((ulBlock >= gpRedVolume->ulBlockCount) || (pbIdx == NULL)) - { - REDERROR(); - } - else - { - uint8_t bIdx; - - for(bIdx = 0U; bIdx < REDCONF_BUFFER_COUNT; bIdx++) - { - const BUFFERHEAD *pHead = &gBufCtx.aHead[bIdx]; - - if((pHead->bVolNum == gbRedVolNum) && (pHead->ulBlock == ulBlock)) - { - *pbIdx = bIdx; - ret = true; - break; - } - } - } - - return ret; -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/core.c b/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/core.c deleted file mode 100755 index 4e61ba3..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/core.c +++ /dev/null @@ -1,1921 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements the entry-points to the core file system. -*/ -#include -#include -#include - - -/* Minimum number of blocks needed for metadata on any volume: the master - block (1), the two metaroots (2), and one doubly-allocated inode (2), - resulting in 1 + 2 + 2 = 5. -*/ -#define MINIMUM_METADATA_BLOCKS (5U) - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) -static REDSTATUS CoreCreate(uint32_t ulPInode, const char *pszName, bool fDir, uint32_t *pulInode); -#endif -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_LINK == 1) -static REDSTATUS CoreLink(uint32_t ulPInode, const char *pszName, uint32_t ulInode); -#endif -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) && ((REDCONF_API_POSIX_UNLINK == 1) || (REDCONF_API_POSIX_RMDIR == 1)) -static REDSTATUS CoreUnlink(uint32_t ulPInode, const char *pszName); -#endif -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_RENAME == 1) -static REDSTATUS CoreRename(uint32_t ulSrcPInode, const char *pszSrcName, uint32_t ulDstPInode, const char *pszDstName); -#endif -#if REDCONF_READ_ONLY == 0 -static REDSTATUS CoreFileWrite(uint32_t ulInode, uint64_t ullStart, uint32_t *pulLen, const void *pBuffer); -#endif -#if TRUNCATE_SUPPORTED -static REDSTATUS CoreFileTruncate(uint32_t ulInode, uint64_t ullSize); -#endif - - -VOLUME gaRedVolume[REDCONF_VOLUME_COUNT]; -static COREVOLUME gaCoreVol[REDCONF_VOLUME_COUNT]; - -const VOLCONF * CONST_IF_ONE_VOLUME gpRedVolConf = &gaRedVolConf[0U]; -VOLUME * CONST_IF_ONE_VOLUME gpRedVolume = &gaRedVolume[0U]; -COREVOLUME * CONST_IF_ONE_VOLUME gpRedCoreVol = &gaCoreVol[0U]; -METAROOT *gpRedMR = &gaCoreVol[0U].aMR[0U]; - -CONST_IF_ONE_VOLUME uint8_t gbRedVolNum = 0; - - -/** @brief Initialize the Reliance Edge file system driver. - - Prepares the Reliance Edge file system driver to be used. Must be the first - Reliance Edge function to be invoked: no volumes can be mounted until the - driver has been initialized. - - If this function is called when the Reliance Edge driver is already - initialized, the behavior is undefined. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -REDSTATUS RedCoreInit(void) -{ - REDSTATUS ret = 0; - uint8_t bVolNum; - #if REDCONF_OUTPUT == 1 - static uint8_t bSignedOn = 0U; /* Whether the sign on has been printed. */ - - if(bSignedOn == 0U) - { - RedSignOn(); - bSignedOn = 1U; - } - #else - /* Call RedSignOn() even when output is disabled, to force the copyright - text to be referenced and pulled into the program data. - */ - RedSignOn(); - #endif - - RedMemSet(gaRedVolume, 0U, sizeof(gaRedVolume)); - RedMemSet(gaCoreVol, 0U, sizeof(gaCoreVol)); - - RedBufferInit(); - - for(bVolNum = 0U; bVolNum < REDCONF_VOLUME_COUNT; bVolNum++) - { - VOLUME *pVol = &gaRedVolume[bVolNum]; - COREVOLUME *pCoreVol = &gaCoreVol[bVolNum]; - const VOLCONF *pVolConf = &gaRedVolConf[bVolNum]; - - if( (pVolConf->ulSectorSize < SECTOR_SIZE_MIN) - || ((REDCONF_BLOCK_SIZE % pVolConf->ulSectorSize) != 0U) - || (pVolConf->ulInodeCount == 0U)) - { - ret = -RED_EINVAL; - } - #if REDCONF_API_POSIX == 1 - else if(pVolConf->pszPathPrefix == NULL) - { - ret = -RED_EINVAL; - } - else - { - #if REDCONF_VOLUME_COUNT > 1U - uint8_t bCmpVol; - - /* Ensure there are no duplicate path prefixes. Check against all - previous volumes, which are already verified. - */ - for(bCmpVol = 0U; bCmpVol < bVolNum; bCmpVol++) - { - const char *pszCmpPathPrefix = gaRedVolConf[bCmpVol].pszPathPrefix; - - if(RedStrCmp(pVolConf->pszPathPrefix, pszCmpPathPrefix) == 0) - { - ret = -RED_EINVAL; - break; - } - } - #endif - } - #endif - - if(ret == 0) - { - pVol->bBlockSectorShift = 0U; - while((pVolConf->ulSectorSize << pVol->bBlockSectorShift) < REDCONF_BLOCK_SIZE) - { - pVol->bBlockSectorShift++; - } - - /* This should always be true since the block size is confirmed to - be a power of two (checked at compile time) and above we ensured - that (REDCONF_BLOCK_SIZE % pVolConf->ulSectorSize) == 0. - */ - REDASSERT((pVolConf->ulSectorSize << pVol->bBlockSectorShift) == REDCONF_BLOCK_SIZE); - - pVol->ulBlockCount = (uint32_t)(pVolConf->ullSectorCount >> pVol->bBlockSectorShift); - - if(pVol->ulBlockCount < MINIMUM_METADATA_BLOCKS) - { - ret = -RED_EINVAL; - } - else - { - #if REDCONF_READ_ONLY == 0 - pVol->ulTransMask = REDCONF_TRANSACT_DEFAULT; - #endif - - pVol->ullMaxInodeSize = INODE_SIZE_MAX; - - /* To understand the following code, note that the fixed- - location metadata is located at the start of the disk, in - the following order: - - - Master block (1 block) - - Metaroots (2 blocks) - - External imap blocks (variable * 2 blocks) - - Inode blocks (pVolConf->ulInodeCount * 2 blocks) - */ - - /* The imap needs bits for all inode and allocable blocks. If - that bitmap will fit into the metaroot, the inline imap is - used and there are no imap nodes on disk. The minus 3 is - there since the imap does not include bits for the master - block or metaroots. - */ - pCoreVol->fImapInline = (pVol->ulBlockCount - 3U) <= METAROOT_ENTRIES; - - if(pCoreVol->fImapInline) - { - #if REDCONF_IMAP_INLINE == 1 - pCoreVol->ulInodeTableStartBN = 3U; - #else - ret = -RED_EINVAL; - #endif - } - else - { - #if REDCONF_IMAP_EXTERNAL == 1 - pCoreVol->ulImapStartBN = 3U; - - /* The imap does not include bits for itself, so add two to - the number of imap entries for the two blocks of each - imap node. This allows us to divide up the remaining - space, making sure to round up so all data blocks are - covered. - */ - pCoreVol->ulImapNodeCount = - ((pVol->ulBlockCount - 3U) + ((IMAPNODE_ENTRIES + 2U) - 1U)) / (IMAPNODE_ENTRIES + 2U); - - pCoreVol->ulInodeTableStartBN = pCoreVol->ulImapStartBN + (pCoreVol->ulImapNodeCount * 2U); - #else - ret = -RED_EINVAL; - #endif - } - } - } - - if(ret == 0) - { - pCoreVol->ulFirstAllocableBN = pCoreVol->ulInodeTableStartBN + (pVolConf->ulInodeCount * 2U); - - if(pCoreVol->ulFirstAllocableBN > pVol->ulBlockCount) - { - /* We can get here if there is not enough space for the number - of configured inodes. - */ - ret = -RED_EINVAL; - } - else - { - pVol->ulBlocksAllocable = pVol->ulBlockCount - pCoreVol->ulFirstAllocableBN; - } - } - - if(ret != 0) - { - break; - } - } - - /* Make sure the configured endianness is correct. - */ - if(ret == 0) - { - uint16_t uValue = 0xFF00U; - uint8_t abBytes[2U]; - - RedMemCpy(abBytes, &uValue, sizeof(abBytes)); - - #if REDCONF_ENDIAN_BIG == 1 - if(abBytes[0U] != 0xFFU) - #else - if(abBytes[0U] != 0x00U) - #endif - { - ret = -RED_EINVAL; - } - } - - if(ret == 0) - { - ret = RedOsClockInit(); - - #if REDCONF_TASK_COUNT > 1U - if(ret == 0) - { - ret = RedOsMutexInit(); - - if(ret != 0) - { - (void)RedOsClockUninit(); - } - } - #endif - } - - return ret; -} - - -/** @brief Uninitialize the Reliance Edge file system driver. - - Tears down the Reliance Edge file system driver. Cannot be used until all - Reliance Edge volumes are unmounted. A subsequent call to RedCoreInit() - will initialize the driver again. - - The behavior of calling this function when the core is already uninitialized - is undefined. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBUSY At least one volume is still mounted. -*/ -REDSTATUS RedCoreUninit(void) -{ - REDSTATUS ret; - - #if REDCONF_TASK_COUNT > 1U - ret = RedOsMutexUninit(); - - if(ret == 0) - #endif - { - ret = RedOsClockUninit(); - } - - return ret; -} - - -/** @brief Set the current volume. - - All core APIs operate on the current volume. This call must precede all - core accesses. - - @param bVolNum The volume number to access. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bVolNum is an invalid volume number. -*/ -REDSTATUS RedCoreVolSetCurrent( - uint8_t bVolNum) -{ - REDSTATUS ret; - - if(bVolNum >= REDCONF_VOLUME_COUNT) - { - ret = -RED_EINVAL; - } - else - { - #if REDCONF_VOLUME_COUNT > 1U - gbRedVolNum = bVolNum; - gpRedVolConf = &gaRedVolConf[bVolNum]; - gpRedVolume = &gaRedVolume[bVolNum]; - gpRedCoreVol = &gaCoreVol[bVolNum]; - gpRedMR = &gpRedCoreVol->aMR[gpRedCoreVol->bCurMR]; - #endif - - ret = 0; - } - - return ret; -} - - -#if FORMAT_SUPPORTED -/** @brief Format a file system volume. - - Uses the statically defined volume configuration. After calling this - function, the volume needs to be mounted -- see RedCoreVolMount(). - - An error is returned if the volume is mounted. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBUSY Volume is mounted. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedCoreVolFormat(void) -{ - return RedVolFormat(); -} -#endif /* FORMAT_SUPPORTED */ - - -/** @brief Mount a file system volume. - - Prepares the file system volume to be accessed. Mount will fail if the - volume has never been formatted, or if the on-disk format is inconsistent - with the compile-time configuration. - - If the volume is already mounted, the behavior is undefined. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO Volume not formatted, improperly formatted, or corrupt. -*/ -REDSTATUS RedCoreVolMount(void) -{ - return RedVolMount(); -} - - -/** @brief Unmount a file system volume. - - This function discards the in-memory state for the file system and marks it - as unmounted. Subsequent attempts to access the volume will fail until the - volume is mounted again. - - If unmount automatic transaction points are enabled, this function will - commit a transaction point prior to unmounting. If unmount automatic - transaction points are disabled, this function will unmount without - transacting, effectively discarding the working state. - - If the volume is already unmounted, the behavior is undefined. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO I/O error during unmount automatic transaction point. -*/ -REDSTATUS RedCoreVolUnmount(void) -{ - REDSTATUS ret = 0; - - #if REDCONF_READ_ONLY == 0 - if(!gpRedVolume->fReadOnly && ((gpRedVolume->ulTransMask & RED_TRANSACT_UMOUNT) != 0U)) - { - ret = RedVolTransact(); - } - #endif - - if(ret == 0) - { - ret = RedBufferDiscardRange(0U, gpRedVolume->ulBlockCount); - } - - if(ret == 0) - { - ret = RedOsBDevClose(gbRedVolNum); - } - - if(ret == 0) - { - gpRedVolume->fMounted = false; - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Commit a transaction point. - - Reliance Edge is a transactional file system. All modifications, of both - metadata and filedata, are initially working state. A transaction point - is a process whereby the working state atomically becomes the committed - state, replacing the previous committed state. Whenever Reliance Edge is - mounted, including after power loss, the state of the file system after - mount is the most recent committed state. Nothing from the committed - state is ever missing, and nothing from the working state is ever included. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL The volume is not mounted. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EROFS The file system volume is read-only. -*/ -REDSTATUS RedCoreVolTransact(void) -{ - REDSTATUS ret; - - if(!gpRedVolume->fMounted) - { - ret = -RED_EINVAL; - } - else if(gpRedVolume->fReadOnly) - { - ret = -RED_EROFS; - } - else - { - ret = RedVolTransact(); - } - - return ret; -} -#endif /* REDCONF_READ_ONLY == 0 */ - - -#if REDCONF_API_POSIX == 1 -/** @brief Query file system status information. - - @param pStatFS The buffer to populate with volume information. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval -RED_EINVAL Volume is not mounted; or @p pStatFS is `NULL`. -*/ -REDSTATUS RedCoreVolStat( - REDSTATFS *pStatFS) -{ - REDSTATUS ret; - - if((pStatFS == NULL) || (!gpRedVolume->fMounted)) - { - ret = -RED_EINVAL; - } - else - { - RedMemSet(pStatFS, 0U, sizeof(*pStatFS)); - - pStatFS->f_bsize = REDCONF_BLOCK_SIZE; - pStatFS->f_frsize = REDCONF_BLOCK_SIZE; - pStatFS->f_blocks = gpRedVolume->ulBlockCount; - #if RESERVED_BLOCKS > 0U - pStatFS->f_bfree = (gpRedMR->ulFreeBlocks > RESERVED_BLOCKS) ? (gpRedMR->ulFreeBlocks - RESERVED_BLOCKS) : 0U; - #else - pStatFS->f_bfree = gpRedMR->ulFreeBlocks; - #endif - pStatFS->f_bavail = pStatFS->f_bfree; - pStatFS->f_files = gpRedVolConf->ulInodeCount; - pStatFS->f_ffree = gpRedMR->ulFreeInodes; - pStatFS->f_favail = gpRedMR->ulFreeInodes; - - pStatFS->f_flag = RED_ST_NOSUID; - #if REDCONF_READ_ONLY == 0 - if(gpRedVolume->fReadOnly) - #endif - { - pStatFS->f_flag |= RED_ST_RDONLY; - } - - pStatFS->f_namemax = REDCONF_NAME_MAX; - pStatFS->f_maxfsize = INODE_SIZE_MAX; - pStatFS->f_dev = gbRedVolNum; - - ret = 0; - } - - return ret; -} -#endif /* REDCONF_API_POSIX == 1 */ - - -#if (REDCONF_READ_ONLY == 0) && ((REDCONF_API_POSIX == 1) || (REDCONF_API_FSE_TRANSMASKSET == 1)) -/** @brief Update the transaction mask. - - The following events are available when using the FSE API: - - - #RED_TRANSACT_UMOUNT - - #RED_TRANSACT_WRITE - - #RED_TRANSACT_TRUNCATE - - #RED_TRANSACT_VOLFULL - - The following events are available when using the POSIX-like API: - - - #RED_TRANSACT_UMOUNT - - #RED_TRANSACT_CREAT - - #RED_TRANSACT_UNLINK - - #RED_TRANSACT_MKDIR - - #RED_TRANSACT_RENAME - - #RED_TRANSACT_LINK - - #RED_TRANSACT_CLOSE - - #RED_TRANSACT_WRITE - - #RED_TRANSACT_FSYNC - - #RED_TRANSACT_TRUNCATE - - #RED_TRANSACT_VOLFULL - - The #RED_TRANSACT_MANUAL macro (by itself) may be used to disable all - automatic transaction events. The #RED_TRANSACT_MASK macro is a bitmask of - all transaction flags, excluding those representing excluded functionality. - - Attempting to enable events for excluded functionality will result in an - error. - - @param ulEventMask A bitwise-OR'd mask of automatic transaction events to - be set as the current transaction mode. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL The volume is not mounted; or @p ulEventMask contains - invalid bits. - @retval -RED_EROFS The file system volume is read-only. -*/ -REDSTATUS RedCoreTransMaskSet( - uint32_t ulEventMask) -{ - REDSTATUS ret; - - if(!gpRedVolume->fMounted || ((ulEventMask & RED_TRANSACT_MASK) != ulEventMask)) - { - ret = -RED_EINVAL; - } - else if(gpRedVolume->fReadOnly) - { - ret = -RED_EROFS; - } - else - { - gpRedVolume->ulTransMask = ulEventMask; - ret = 0; - } - - return ret; -} -#endif - - -#if (REDCONF_API_POSIX == 1) || (REDCONF_API_FSE_TRANSMASKGET == 1) -/** @brief Read the transaction mask. - - If the volume is read-only, the returned event mask is always zero. - - @param pulEventMask Populated with a bitwise-OR'd mask of automatic - transaction events which represent the current - transaction mode for the volume. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL The volume is not mounted; or @p pulEventMask is `NULL`. -*/ -REDSTATUS RedCoreTransMaskGet( - uint32_t *pulEventMask) -{ - REDSTATUS ret; - - if(!gpRedVolume->fMounted || (pulEventMask == NULL)) - { - ret = -RED_EINVAL; - } - else - { - #if REDCONF_READ_ONLY == 1 - *pulEventMask = 0U; - #else - *pulEventMask = gpRedVolume->ulTransMask; - #endif - ret = 0; - } - - return ret; -} -#endif - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) -/** @brief Create a file or directory. - - @param ulPInode The inode number of the parent directory. - @param pszName A null-terminated name for the new inode. - @param fDir Whether to create a directory (true) or file (false). - @param pulInode On successful return, populated with the inode number of the - new file or directory. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL The volume is not mounted; or @p pszName is not - a valid name; or @p pulInode is `NULL`. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EROFS The file system volume is read-only. - @retval -RED_ENOTDIR @p ulPInode is not a directory. - @retval -RED_EBADF @p ulPInode is not a valid inode. - @retval -RED_ENOSPC There is not enough space on the volume to - createthe new directory entry; or the directory - is full. - @retval -RED_ENFILE No available inode slots. - @retval -RED_ENAMETOOLONG @p pszName is too long. - @retval -RED_EEXIST @p pszName already exists in @p ulPInode. -*/ -REDSTATUS RedCoreCreate( - uint32_t ulPInode, - const char *pszName, - bool fDir, - uint32_t *pulInode) -{ - REDSTATUS ret; - - if(!gpRedVolume->fMounted) - { - ret = -RED_EINVAL; - } - else if(gpRedVolume->fReadOnly) - { - ret = -RED_EROFS; - } - else - { - ret = CoreCreate(ulPInode, pszName, fDir, pulInode); - - if( (ret == -RED_ENOSPC) - && ((gpRedVolume->ulTransMask & RED_TRANSACT_VOLFULL) != 0U) - && (gpRedCoreVol->ulAlmostFreeBlocks > 0U)) - { - ret = RedVolTransact(); - - if(ret == 0) - { - ret = CoreCreate(ulPInode, pszName, fDir, pulInode); - } - } - - if(ret == 0) - { - if(fDir && ((gpRedVolume->ulTransMask & RED_TRANSACT_MKDIR) != 0U)) - { - ret = RedVolTransact(); - } - else if(!fDir && ((gpRedVolume->ulTransMask & RED_TRANSACT_CREAT) != 0U)) - { - ret = RedVolTransact(); - } - else - { - /* No automatic transaction for this operation. - */ - } - } - } - - return ret; -} - - -/** @brief Create a file or directory. - - @param ulPInode The inode number of the parent directory. - @param pszName A null-terminated name for the new inode. - @param fDir Whether to create a directory (true) or file (false). - @param pulInode On successful return, populated with the inode number of the - new file or directory. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EROFS The file system volume is read-only. - @retval -RED_ENOTDIR @p ulPInode is not a directory. - @retval -RED_EBADF @p ulPInode is not a valid inode. - @retval -RED_ENOSPC There is not enough space on the volume to - create the new directory entry; or the directory - is full. - @retval -RED_ENFILE No available inode slots. - @retval -RED_ENAMETOOLONG @p pszName is too long. - @retval -RED_EEXIST @p pszName already exists in @p ulPInode. -*/ -static REDSTATUS CoreCreate( - uint32_t ulPInode, - const char *pszName, - bool fDir, - uint32_t *pulInode) -{ - REDSTATUS ret; - - if(pulInode == NULL) - { - ret = -RED_EINVAL; - } - else if(gpRedVolume->fReadOnly) - { - ret = -RED_EROFS; - } - else - { - CINODE pino; - - pino.ulInode = ulPInode; - ret = RedInodeMount(&pino, FTYPE_DIR, false); - - if(ret == 0) - { - CINODE ino; - - ino.ulInode = INODE_INVALID; - ret = RedInodeCreate(&ino, ulPInode, fDir ? RED_S_IFDIR : RED_S_IFREG); - - if(ret == 0) - { - ret = RedInodeBranch(&pino); - - if(ret == 0) - { - ret = RedDirEntryCreate(&pino, pszName, ino.ulInode); - } - - if(ret == 0) - { - *pulInode = ino.ulInode; - } - else - { - REDSTATUS ret2; - - ret2 = RedInodeFree(&ino); - CRITICAL_ASSERT(ret2 == 0); - } - - RedInodePut(&ino, 0U); - } - - RedInodePut(&pino, (ret == 0) ? (uint8_t)(IPUT_UPDATE_MTIME | IPUT_UPDATE_CTIME) : 0U); - } - } - - return ret; -} -#endif /* (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) */ - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_LINK == 1) -/** @brief Create a hard link. - - This creates an additional name (link) for @p ulInode. The new name refers - to the same file with the same contents. If a name is deleted, but the - underlying file has other names, the file continues to exist. The link - count (accessible via RedCoreStat()) indicates the number of names that a - file has. All of a file's names are on equal footing: there is nothing - special about the original name. - - If @p ulInode names a directory, the operation will fail. - - @param ulPInode The inode number of the parent directory. - @param pszName The null-terminated name for the new link. - @param ulInode The inode to create a hard link to. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulPInode is not a valid inode; or @p ulInode - is not a valid inode. - @retval -RED_EEXIST @p pszName resolves to an existing file. - @retval -RED_EINVAL The volume is not mounted; or @p pszName is - `NULL`. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EMLINK Creating the link would exceed the maximum link - count of @p ulInode. - @retval -RED_ENAMETOOLONG Attempting to create a link with a name that - exceeds the maximum name length. - @retval -RED_ENOSPC There is insufficient free space to expand the - directory that would contain the link. - @retval -RED_ENOTDIR @p ulPInode is not a directory. - @retval -RED_EPERM @p ulInode is a directory. - @retval -RED_EROFS The requested link requires writing in a - directory on a read-only file system. -*/ -REDSTATUS RedCoreLink( - uint32_t ulPInode, - const char *pszName, - uint32_t ulInode) -{ - REDSTATUS ret; - - if(!gpRedVolume->fMounted) - { - ret = -RED_EINVAL; - } - else if(gpRedVolume->fReadOnly) - { - ret = -RED_EROFS; - } - else - { - ret = CoreLink(ulPInode, pszName, ulInode); - - if( (ret == -RED_ENOSPC) - && ((gpRedVolume->ulTransMask & RED_TRANSACT_VOLFULL) != 0U) - && (gpRedCoreVol->ulAlmostFreeBlocks > 0U)) - { - ret = RedVolTransact(); - - if(ret == 0) - { - ret = CoreLink(ulPInode, pszName, ulInode); - } - } - - if((ret == 0) && ((gpRedVolume->ulTransMask & RED_TRANSACT_LINK) != 0U)) - { - ret = RedVolTransact(); - } - } - - return ret; -} - - -/** @brief Create a hard link. - - @param ulPInode The inode number of the parent directory. - @param pszName The null-terminated name for the new link. - @param ulInode The inode to create a hard link to. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulPInode is not a valid inode; or @p ulInode - is not a valid inode. - @retval -RED_EEXIST @p pszName resolves to an existing file. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EMLINK Creating the link would exceed the maximum link - count of @p ulInode. - @retval -RED_ENAMETOOLONG Attempting to create a link with a name that - exceeds the maximum name length. - @retval -RED_ENOSPC There is insufficient free space to expand the - directory that would contain the link. - @retval -RED_ENOTDIR @p ulPInode is not a directory. - @retval -RED_EPERM @p ulInode is a directory. - @retval -RED_EROFS The requested link requires writing in a - directory on a read-only file system. -*/ -static REDSTATUS CoreLink( - uint32_t ulPInode, - const char *pszName, - uint32_t ulInode) -{ - REDSTATUS ret; - - if(gpRedVolume->fReadOnly) - { - ret = -RED_EROFS; - } - else - { - CINODE pino; - - pino.ulInode = ulPInode; - ret = RedInodeMount(&pino, FTYPE_DIR, false); - - if(ret == 0) - { - CINODE ino; - - ino.ulInode = ulInode; - ret = RedInodeMount(&ino, FTYPE_FILE, false); - - /* POSIX specifies EPERM as the errno thrown when link() is given a - directory. Switch the errno returned if EISDIR was the return - value. - */ - if(ret == -RED_EISDIR) - { - ret = -RED_EPERM; - } - - if(ret == 0) - { - if(ino.pInodeBuf->uNLink == UINT16_MAX) - { - ret = -RED_EMLINK; - } - else - { - ret = RedInodeBranch(&pino); - } - - if(ret == 0) - { - ret = RedInodeBranch(&ino); - } - - if(ret == 0) - { - ret = RedDirEntryCreate(&pino, pszName, ino.ulInode); - } - - if(ret == 0) - { - ino.pInodeBuf->uNLink++; - } - - RedInodePut(&ino, (ret == 0) ? IPUT_UPDATE_CTIME : 0U); - } - - RedInodePut(&pino, (ret == 0) ? (uint8_t)(IPUT_UPDATE_MTIME | IPUT_UPDATE_CTIME) : 0U); - } - } - - return ret; -} -#endif /* (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_LINK == 1) */ - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) && ((REDCONF_API_POSIX_UNLINK == 1) || (REDCONF_API_POSIX_RMDIR == 1)) -/** @brief Delete a file or directory. - - The given name is deleted and the link count of the corresponding inode is - decremented. If the link count falls to zero (no remaining hard links), - the inode will be deleted. - - If the path names a directory which is not empty, the unlink will fail. - - If the deletion frees data in the committed state, it will not return to - free space until after a transaction point. Similarly, if the inode was - part of the committed state, the inode slot will not be available until - after a transaction point. - - This function can fail when the disk is full. To fix this, transact and - try again: Reliance Edge guarantees that it is possible to delete at least - one file or directory after a transaction point. If disk full automatic - transactions are enabled, this will happen automatically. - - @param ulPInode The inode number of the parent directory. - @param pszName The null-terminated name of the file or directory to - delete. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulPInode is not a valid inode. - @retval -RED_EINVAL The volume is not mounted; or @p pszName is - `NULL`. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENAMETOOLONG @p pszName is too long. - @retval -RED_ENOENT @p pszName does not name an existing file or - directory. - @retval -RED_ENOTDIR @p ulPInode is not a directory. - @retval -RED_ENOSPC The file system does not have enough space to - modify the parent directory to perform the - deletion. - @retval -RED_ENOTEMPTY The inode refered to by @p pszName is a - directory which is not empty. -*/ -REDSTATUS RedCoreUnlink( - uint32_t ulPInode, - const char *pszName) -{ - REDSTATUS ret; - - if(!gpRedVolume->fMounted) - { - ret = -RED_EINVAL; - } - else if(gpRedVolume->fReadOnly) - { - ret = -RED_EROFS; - } - else - { - ret = CoreUnlink(ulPInode, pszName); - - if( (ret == -RED_ENOSPC) - && ((gpRedVolume->ulTransMask & RED_TRANSACT_VOLFULL) != 0U) - && (gpRedCoreVol->ulAlmostFreeBlocks > 0U)) - { - ret = RedVolTransact(); - - if(ret == 0) - { - ret = CoreUnlink(ulPInode, pszName); - } - } - - if((ret == 0) && ((gpRedVolume->ulTransMask & RED_TRANSACT_UNLINK) != 0U)) - { - ret = RedVolTransact(); - } - } - - return ret; -} - - -/** @brief Delete a file or directory. - - @param ulPInode The inode number of the parent directory. - @param pszName The null-terminated name of the file or directory to - delete. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulPInode is not a valid inode. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENAMETOOLONG @p pszName is too long. - @retval -RED_ENOENT @p pszName does not name an existing file or - directory. - @retval -RED_ENOTDIR @p ulPInode is not a directory. - @retval -RED_ENOSPC The file system does not have enough space to - modify the parent directory to perform the - deletion. - @retval -RED_ENOTEMPTY The inode refered to by @p pszName is a - directory which is not empty. -*/ -static REDSTATUS CoreUnlink( - uint32_t ulPInode, - const char *pszName) -{ - REDSTATUS ret; - - if(gpRedVolume->fReadOnly) - { - ret = -RED_EROFS; - } - else - { - CINODE pino; - - pino.ulInode = ulPInode; - ret = RedInodeMount(&pino, FTYPE_DIR, false); - - if(ret == 0) - { - uint32_t ulDeleteIdx; - uint32_t ulInode; - - ret = RedDirEntryLookup(&pino, pszName, &ulDeleteIdx, &ulInode); - - if(ret == 0) - { - ret = RedInodeBranch(&pino); - } - - if(ret == 0) - { - CINODE ino; - - ino.ulInode = ulInode; - ret = RedInodeMount(&ino, FTYPE_EITHER, false); - - if(ret == 0) - { - if(ino.fDirectory && (ino.pInodeBuf->ullSize > 0U)) - { - ret = -RED_ENOTEMPTY; - } - else - { - #if RESERVED_BLOCKS > 0U - gpRedCoreVol->fUseReservedBlocks = true; - #endif - - ret = RedDirEntryDelete(&pino, ulDeleteIdx); - - #if RESERVED_BLOCKS > 0U - gpRedCoreVol->fUseReservedBlocks = false; - #endif - - if(ret == 0) - { - /* If the inode is deleted, buffers are needed to - read all of the indirects and free the data - blocks. Before doing that, to reduce the - minimum number of buffers needed to complete the - unlink, release the parent directory inode - buffers which are no longer needed. - */ - RedInodePutCoord(&pino); - - ret = RedInodeLinkDec(&ino); - CRITICAL_ASSERT(ret == 0); - } - } - - RedInodePut(&ino, (ret == 0) ? IPUT_UPDATE_CTIME : 0U); - } - } - - RedInodePut(&pino, (ret == 0) ? (uint8_t)(IPUT_UPDATE_MTIME | IPUT_UPDATE_CTIME) : 0U); - } - } - - return ret; -} -#endif /* (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) && ((REDCONF_API_POSIX_UNLINK == 1) || (REDCONF_API_POSIX_RMDIR == 1)) */ - - -#if REDCONF_API_POSIX == 1 -/** @brief Look up the inode number of a file or directory. - - @param ulPInode The inode number of the parent directory. - @param pszName The null-terminated name of the file or directory to look - up. - @param pulInode On successful return, populated with the inode number named - by @p pszName. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulPInode is not a valid inode. - @retval -RED_EINVAL The volume is not mounted; @p pszName is `NULL`; or - @p pulInode is `NULL`. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOENT @p pszName does not name an existing file or directory. - @retval -RED_ENOTDIR @p ulPInode is not a directory. -*/ -REDSTATUS RedCoreLookup( - uint32_t ulPInode, - const char *pszName, - uint32_t *pulInode) -{ - REDSTATUS ret; - - if((pulInode == NULL) || !gpRedVolume->fMounted) - { - ret = -RED_EINVAL; - } - else - { - CINODE ino; - - ino.ulInode = ulPInode; - ret = RedInodeMount(&ino, FTYPE_DIR, false); - - if(ret == 0) - { - ret = RedDirEntryLookup(&ino, pszName, NULL, pulInode); - - RedInodePut(&ino, 0U); - } - } - - return ret; -} -#endif /* REDCONF_API_POSIX == 1 */ - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_RENAME == 1) -/** @brief Rename a file or directory. - - If @p pszDstName names an existing file or directory, the behavior depends - on the configuration. If #REDCONF_RENAME_ATOMIC is false, and if the - destination name exists, this function always fails with -RED_EEXIST. - - If #REDCONF_RENAME_ATOMIC is true, and if the new name exists, then in one - atomic operation, the destination name is unlinked and the source name is - renamed to the destination name. Both names must be of the same type (both - files or both directories). As with RedCoreUnlink(), if the destination - name is a directory, it must be empty. The major exception to this - behavior is that if both names are links to the same inode, then the rename - does nothing and both names continue to exist. - - If the rename deletes the old destination, it may free data in the - committed state, which will not return to free space until after a - transaction point. Similarly, if the deleted inode was part of the - committed state, the inode slot will not be available until after a - transaction point. - - @param ulSrcPInode The inode number of the parent directory of the file or - directory to rename. - @param pszSrcName The name of the file or directory to rename. - @param ulDstPInode The new parent directory inode number of the file or - directory after the rename. - @param pszDstName The new name of the file or directory after the rename. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulSrcPInode is not a valid inode number; or - @p ulDstPInode is not a valid inode number. - @retval -RED_EEXIST #REDCONF_RENAME_POSIX is false and the - destination name exists. - @retval -RED_EINVAL The volume is not mounted; @p pszSrcName is - `NULL`; or @p pszDstName is `NULL`. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EISDIR The destination name exists and is a directory, - and the source name is a non-directory. - @retval -RED_ENAMETOOLONG Either @p pszSrcName or @p pszDstName is longer - than #REDCONF_NAME_MAX. - @retval -RED_ENOENT The source name is not an existing entry; or - either @p pszSrcName or @p pszDstName point to - an empty string. - @retval -RED_ENOTDIR @p ulSrcPInode is not a directory; or - @p ulDstPInode is not a directory; or the source - name is a directory and the destination name is - a file. - @retval -RED_ENOTEMPTY The destination name is a directory which is not - empty. - @retval -RED_ENOSPC The file system does not have enough space to - extend the @p ulDstPInode directory. - @retval -RED_EROFS The directory to be removed resides on a - read-only file system. -*/ -REDSTATUS RedCoreRename( - uint32_t ulSrcPInode, - const char *pszSrcName, - uint32_t ulDstPInode, - const char *pszDstName) -{ - REDSTATUS ret; - - if(!gpRedVolume->fMounted) - { - ret = -RED_EINVAL; - } - else if(gpRedVolume->fReadOnly) - { - ret = -RED_EROFS; - } - else - { - ret = CoreRename(ulSrcPInode, pszSrcName, ulDstPInode, pszDstName); - - if( (ret == -RED_ENOSPC) - && ((gpRedVolume->ulTransMask & RED_TRANSACT_VOLFULL) != 0U) - && (gpRedCoreVol->ulAlmostFreeBlocks > 0U)) - { - ret = RedVolTransact(); - - if(ret == 0) - { - ret = CoreRename(ulSrcPInode, pszSrcName, ulDstPInode, pszDstName); - } - } - - if((ret == 0) && ((gpRedVolume->ulTransMask & RED_TRANSACT_RENAME) != 0U)) - { - ret = RedVolTransact(); - } - } - - return ret; -} - - -/** @brief Rename a file or directory. - - @param ulSrcPInode The inode number of the parent directory of the file or - directory to rename. - @param pszSrcName The name of the file or directory to rename. - @param ulDstPInode The new parent directory inode number of the file or - directory after the rename. - @param pszDstName The new name of the file or directory after the rename. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulSrcPInode is not a valid inode number; or - @p ulDstPInode is not a valid inode number. - @retval -RED_EEXIST #REDCONF_RENAME_POSIX is false and the - destination name exists. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EISDIR The destination name exists and is a directory, - and the source name is a non-directory. - @retval -RED_ENAMETOOLONG Either @p pszSrcName or @p pszDstName is longer - than #REDCONF_NAME_MAX. - @retval -RED_ENOENT The source name is not an existing entry; or - either @p pszSrcName or @p pszDstName point to - an empty string. - @retval -RED_ENOTDIR @p ulSrcPInode is not a directory; or - @p ulDstPInode is not a directory; or the source - name is a directory and the destination name is - a file. - @retval -RED_ENOTEMPTY The destination name is a directory which is not - empty. - @retval -RED_ENOSPC The file system does not have enough space to - extend the @p ulDstPInode directory. - @retval -RED_EROFS The directory to be removed resides on a - read-only file system. -*/ -static REDSTATUS CoreRename( - uint32_t ulSrcPInode, - const char *pszSrcName, - uint32_t ulDstPInode, - const char *pszDstName) -{ - REDSTATUS ret; - - if(gpRedVolume->fReadOnly) - { - ret = -RED_EROFS; - } - else - { - bool fUpdateTimestamps = false; - CINODE SrcPInode; - - SrcPInode.ulInode = ulSrcPInode; - ret = RedInodeMount(&SrcPInode, FTYPE_DIR, true); - - if(ret == 0) - { - CINODE DstPInode; - CINODE *pDstPInode; - - if(ulSrcPInode == ulDstPInode) - { - pDstPInode = &SrcPInode; - } - else - { - pDstPInode = &DstPInode; - DstPInode.ulInode = ulDstPInode; - ret = RedInodeMount(pDstPInode, FTYPE_DIR, true); - } - - if(ret == 0) - { - /* Initialize these to zero so we can unconditionally put them, - even if RedDirEntryRename() fails before mounting them. - */ - CINODE SrcInode = {0U}; - CINODE DstInode = {0U}; - - ret = RedDirEntryRename(&SrcPInode, pszSrcName, &SrcInode, pDstPInode, pszDstName, &DstInode); - - #if REDCONF_RENAME_ATOMIC == 1 - if((ret == 0) && (DstInode.ulInode != INODE_INVALID) && (DstInode.ulInode != SrcInode.ulInode)) - { - /* If the inode is deleted, buffers are needed to read all - of the indirects and free the data blocks. Before doing - that, to reduce the minimum number of buffers needed to - complete the rename, release parent directory inode - buffers which are no longer needed. - */ - RedInodePutCoord(&SrcPInode); - RedInodePutCoord(pDstPInode); - - ret = RedInodeLinkDec(&DstInode); - CRITICAL_ASSERT(ret == 0); - } - - if((ret == 0) && (DstInode.ulInode != SrcInode.ulInode)) - #else - if(ret == 0) - #endif - { - fUpdateTimestamps = true; - } - - #if REDCONF_RENAME_ATOMIC == 1 - RedInodePut(&DstInode, 0U); - #endif - - /* POSIX says updating ctime for the source inode is optional, - but searching around it looks like this is common for Linux - and other Unix file systems. - */ - RedInodePut(&SrcInode, fUpdateTimestamps ? IPUT_UPDATE_CTIME : 0U); - RedInodePut(pDstPInode, fUpdateTimestamps ? (uint8_t)(IPUT_UPDATE_MTIME | IPUT_UPDATE_CTIME) : 0U); - } - } - - RedInodePut(&SrcPInode, fUpdateTimestamps ? (uint8_t)(IPUT_UPDATE_MTIME | IPUT_UPDATE_CTIME) : 0U); - } - - return ret; -} -#endif /* (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_RENAME == 1) */ - - -#if REDCONF_API_POSIX == 1 -/** @brief Get the status of a file or directory. - - See the ::REDSTAT type for the details of the information returned. - - @param ulInode The inode number of the file or directory whose information - is to be retrieved. - @param pStat Pointer to a ::REDSTAT buffer to populate. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulInode is not a valid inode. - @retval -RED_EINVAL The volume is not mounted; @p pStat is `NULL`. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedCoreStat( - uint32_t ulInode, - REDSTAT *pStat) -{ - REDSTATUS ret; - - if(!gpRedVolume->fMounted || (pStat == NULL)) - { - ret = -RED_EINVAL; - } - else - { - CINODE ino; - - ino.ulInode = ulInode; - ret = RedInodeMount(&ino, FTYPE_EITHER, false); - if(ret == 0) - { - RedMemSet(pStat, 0U, sizeof(*pStat)); - - pStat->st_dev = gbRedVolNum; - pStat->st_ino = ulInode; - pStat->st_mode = ino.pInodeBuf->uMode; - #if REDCONF_API_POSIX_LINK == 1 - pStat->st_nlink = ino.pInodeBuf->uNLink; - #else - pStat->st_nlink = 1U; - #endif - pStat->st_size = ino.pInodeBuf->ullSize; - #if REDCONF_INODE_TIMESTAMPS == 1 - pStat->st_atime = ino.pInodeBuf->ulATime; - pStat->st_mtime = ino.pInodeBuf->ulMTime; - pStat->st_ctime = ino.pInodeBuf->ulCTime; - #endif - #if REDCONF_INODE_BLOCKS == 1 - pStat->st_blocks = ino.pInodeBuf->ulBlocks; - #endif - - RedInodePut(&ino, 0U); - } - } - - return ret; -} -#endif /* REDCONF_API_POSIX == 1 */ - - -#if REDCONF_API_FSE == 1 -/** @brief Get the size of a file. - - @param ulInode The inode number of the file whose size is to be retrieved. - @param pullSize On successful exit, populated with the file size. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulInode is not a valid inode. - @retval -RED_EINVAL The volume is not mounted; @p pullSize is `NULL`. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EISDIR @p ulInode is a directory inode. -*/ -REDSTATUS RedCoreFileSizeGet( - uint32_t ulInode, - uint64_t *pullSize) -{ - REDSTATUS ret; - - if(!gpRedVolume->fMounted || (pullSize == NULL)) - { - ret = -RED_EINVAL; - } - else - { - CINODE ino; - - ino.ulInode = ulInode; - ret = RedInodeMount(&ino, FTYPE_FILE, false); - if(ret == 0) - { - *pullSize = ino.pInodeBuf->ullSize; - - RedInodePut(&ino, 0U); - } - } - - return ret; -} -#endif /* REDCONF_API_FSE == 1 */ - - -/** @brief Read from a file. - - Data which has not yet been written, but which is before the end-of-file - (sparse data), shall read as zeroes. A short read -- where the number of - bytes read is less than requested -- indicates that the requested read was - partially or, if zero bytes were read, entirely beyond the end-of-file. - - If @p ullStart is at or beyond the maximum file size, it is treated like - any other read entirely beyond the end-of-file: no data is read and - @p pulLen is populated with zero. - - @param ulInode The inode number of the file to read. - @param ullStart The file offset to read from. - @param pulLen On entry, contains the number of bytes to read; on - successful exit, contains the number of bytes actually - read. - @param pBuffer The buffer to populate with the data read. Must be big - enough for the read request. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulInode is not a valid inode number. - @retval -RED_EINVAL The volume is not mounted; or @p pBuffer is `NULL`. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EISDIR The inode is a directory inode. -*/ -REDSTATUS RedCoreFileRead( - uint32_t ulInode, - uint64_t ullStart, - uint32_t *pulLen, - void *pBuffer) -{ - REDSTATUS ret; - - if(!gpRedVolume->fMounted || (pulLen == NULL)) - { - ret = -RED_EINVAL; - } - else - { - #if (REDCONF_ATIME == 1) && (REDCONF_READ_ONLY == 0) - bool fUpdateAtime = (*pulLen > 0U) && !gpRedVolume->fReadOnly; - #else - bool fUpdateAtime = false; - #endif - CINODE ino; - - ino.ulInode = ulInode; - ret = RedInodeMount(&ino, FTYPE_FILE, fUpdateAtime); - if(ret == 0) - { - ret = RedInodeDataRead(&ino, ullStart, pulLen, pBuffer); - - #if (REDCONF_ATIME == 1) && (REDCONF_READ_ONLY == 0) - RedInodePut(&ino, ((ret == 0) && fUpdateAtime) ? IPUT_UPDATE_ATIME : 0U); - #else - RedInodePut(&ino, 0U); - #endif - } - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Write to a file. - - If the write extends beyond the end-of-file, the file size will be - increased. - - A short write -- where the number of bytes written is less than requested - -- indicates either that the file system ran out of space but was still - able to write some of the request; or that the request would have caused - the file to exceed the maximum file size, but some of the data could be - written prior to the file size limit. - - If an error is returned, either none of the data was written or a critical - error occurred (like an I/O error) and the file system volume will be - read-only. - - @param ulInode The file number of the file to write. - @param ullStart The file offset to write at. - @param pulLen On entry, the number of bytes to write; on successful exit, - the number of bytes actually written. - @param pBuffer The buffer containing the data to be written. Must big - enough for the write request. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulInode is not a valid file number. - @retval -RED_EFBIG No data can be written to the given file offset since - the resulting file size would exceed the maximum file - size. - @retval -RED_EINVAL The volume is not mounted; or @p pBuffer is `NULL`. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EISDIR The inode is a directory inode. - @retval -RED_ENOSPC No data can be written because there is insufficient - free space. - @retval -RED_EROFS The file system volume is read-only. -*/ -REDSTATUS RedCoreFileWrite( - uint32_t ulInode, - uint64_t ullStart, - uint32_t *pulLen, - const void *pBuffer) -{ - REDSTATUS ret; - - if(!gpRedVolume->fMounted) - { - ret = -RED_EINVAL; - } - else if(gpRedVolume->fReadOnly) - { - ret = -RED_EROFS; - } - else - { - ret = CoreFileWrite(ulInode, ullStart, pulLen, pBuffer); - - if( (ret == -RED_ENOSPC) - && ((gpRedVolume->ulTransMask & RED_TRANSACT_VOLFULL) != 0U) - && (gpRedCoreVol->ulAlmostFreeBlocks > 0U)) - { - ret = RedVolTransact(); - - if(ret == 0) - { - ret = CoreFileWrite(ulInode, ullStart, pulLen, pBuffer); - } - } - - if((ret == 0) && ((gpRedVolume->ulTransMask & RED_TRANSACT_WRITE) != 0U)) - { - ret = RedVolTransact(); - } - } - - return ret; -} - - -/** @brief Write to a file. - - @param ulInode The file number of the file to write. - @param ullStart The file offset to write at. - @param pulLen On entry, the number of bytes to write; on successful exit, - the number of bytes actually written. - @param pBuffer The buffer containing the data to be written. Must big - enough for the write request. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulInode is not a valid file number. - @retval -RED_EFBIG No data can be written to the given file offset since - the resulting file size would exceed the maximum file - size. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EISDIR The inode is a directory inode. - @retval -RED_ENOSPC No data can be written because there is insufficient - free space. - @retval -RED_EROFS The file system volume is read-only. -*/ -static REDSTATUS CoreFileWrite( - uint32_t ulInode, - uint64_t ullStart, - uint32_t *pulLen, - const void *pBuffer) -{ - REDSTATUS ret; - - if(gpRedVolume->fReadOnly) - { - ret = -RED_EROFS; - } - else - { - CINODE ino; - - ino.ulInode = ulInode; - ret = RedInodeMount(&ino, FTYPE_FILE, true); - if(ret == 0) - { - ret = RedInodeDataWrite(&ino, ullStart, pulLen, pBuffer); - - RedInodePut(&ino, (ret == 0) ? (uint8_t)(IPUT_UPDATE_MTIME | IPUT_UPDATE_CTIME) : 0U); - } - } - - return ret; -} -#endif /* REDCONF_READ_ONLY == 0 */ - - -#if TRUNCATE_SUPPORTED -/** @brief Set the file size. - - Allows the file size to be increased, decreased, or to remain the same. If - the file size is increased, the new area is sparse (will read as zeroes). - If the file size is decreased, the data beyond the new end-of-file will - return to free space once it is no longer part of the committed state - (either immediately or after the next transaction point). - - @param ulInode The inode of the file to truncate. - @param ullSize The new file size, in bytes. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulInode is not a valid inode number. - @retval -RED_EFBIG @p ullSize exceeds the maximum file size. - @retval -RED_EINVAL The volume is not mounted. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EISDIR The inode is a directory inode. - @retval -RED_ENOSPC Insufficient free space to perform the truncate. - @retval -RED_EROFS The file system volume is read-only. -*/ -REDSTATUS RedCoreFileTruncate( - uint32_t ulInode, - uint64_t ullSize) -{ - REDSTATUS ret; - - if(!gpRedVolume->fMounted) - { - ret = -RED_EINVAL; - } - else if(gpRedVolume->fReadOnly) - { - ret = -RED_EROFS; - } - else - { - ret = CoreFileTruncate(ulInode, ullSize); - - if( (ret == -RED_ENOSPC) - && ((gpRedVolume->ulTransMask & RED_TRANSACT_VOLFULL) != 0U) - && (gpRedCoreVol->ulAlmostFreeBlocks > 0U)) - { - ret = RedVolTransact(); - - if(ret == 0) - { - ret = CoreFileTruncate(ulInode, ullSize); - } - } - - if((ret == 0) && ((gpRedVolume->ulTransMask & RED_TRANSACT_TRUNCATE) != 0U)) - { - ret = RedVolTransact(); - } - } - - return ret; -} - - -/** @brief Set the file size. - - @param ulInode The inode of the file to truncate. - @param ullSize The new file size, in bytes. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulInode is not a valid inode number. - @retval -RED_EFBIG @p ullSize exceeds the maximum file size. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EISDIR The inode is a directory inode. - @retval -RED_ENOSPC Insufficient free space to perform the truncate. - @retval -RED_EROFS The file system volume is read-only. -*/ -static REDSTATUS CoreFileTruncate( - uint32_t ulInode, - uint64_t ullSize) -{ - REDSTATUS ret; - - if(gpRedVolume->fReadOnly) - { - ret = -RED_EROFS; - } - else - { - CINODE ino; - - ino.ulInode = ulInode; - ret = RedInodeMount(&ino, FTYPE_FILE, true); - if(ret == 0) - { - #if RESERVED_BLOCKS > 0U - gpRedCoreVol->fUseReservedBlocks = (ullSize < ino.pInodeBuf->ullSize); - #endif - - ret = RedInodeDataTruncate(&ino, ullSize); - - #if RESERVED_BLOCKS > 0U - gpRedCoreVol->fUseReservedBlocks = false; - #endif - - RedInodePut(&ino, (ret == 0) ? (uint8_t)(IPUT_UPDATE_MTIME | IPUT_UPDATE_CTIME) : 0U); - } - } - - return ret; -} -#endif /* TRUNCATE_SUPPORTED */ - - -#if (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_READDIR == 1) -/** @brief Read from a directory. - - If files are added to the directory after it is opened, the new files may - or may not be returned by this function. If files are deleted, the deleted - files will not be returned. - - @param ulInode The directory inode to read from. - @param pulPos A token which stores the position within the directory. To - read from the beginning of the directory, populate with - zero. - @param pszName Pointer to a buffer which must be big enough to store a - maximum size name, including a null terminator. On - successful exit, populated with the name of the next - directory entry. - @param pulInode On successful return, populated with the inode number of the - next directory entry. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulInode is not a valid inode number. - @retval -RED_EINVAL The volume is not mounted. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOENT There are no more entries in the directory. - @retval -RED_ENOTDIR @p ulInode refers to a file. -*/ -REDSTATUS RedCoreDirRead( - uint32_t ulInode, - uint32_t *pulPos, - char *pszName, - uint32_t *pulInode) -{ - REDSTATUS ret; - - if(!gpRedVolume->fMounted) - { - ret = -RED_EINVAL; - } - else - { - CINODE ino; - - ino.ulInode = ulInode; - ret = RedInodeMount(&ino, FTYPE_DIR, false); - - if(ret == 0) - { - ret = RedDirEntryRead(&ino, pulPos, pszName, pulInode); - - #if (REDCONF_ATIME == 1) && (REDCONF_READ_ONLY == 0) - if((ret == 0) && !gpRedVolume->fReadOnly) - { - ret = RedInodeBranch(&ino); - } - - RedInodePut(&ino, ((ret == 0) && !gpRedVolume->fReadOnly) ? IPUT_UPDATE_ATIME : 0U); - #else - RedInodePut(&ino, 0U); - #endif - } - } - - return ret; -} -#endif /* (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_READDIR == 1) */ - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/dir.c b/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/dir.c deleted file mode 100755 index 06fdac1..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/dir.c +++ /dev/null @@ -1,958 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements directory operations. -*/ -#include - -#if REDCONF_API_POSIX == 1 - -#include - - -#define DIR_INDEX_INVALID UINT32_MAX - -#if (REDCONF_NAME_MAX % 4U) != 0U -#define DIRENT_PADDING (4U - (REDCONF_NAME_MAX % 4U)) -#else -#define DIRENT_PADDING (0U) -#endif -#define DIRENT_SIZE (4U + REDCONF_NAME_MAX + DIRENT_PADDING) -#define DIRENTS_PER_BLOCK (REDCONF_BLOCK_SIZE / DIRENT_SIZE) -#define DIRENTS_MAX (uint32_t)REDMIN(UINT32_MAX, UINT64_SUFFIX(1) * INODE_DATA_BLOCKS * DIRENTS_PER_BLOCK) - - -/** @brief On-disk directory entry. -*/ -typedef struct -{ - /** The inode number that the directory entry points at. If the directory - entry is available, this holds INODE_INVALID. - */ - uint32_t ulInode; - - /** The name of the directory entry. For names shorter than - REDCONF_NAME_MAX, unused bytes in the array are zeroed. For names of - the maximum length, the string is not null terminated. - */ - char acName[REDCONF_NAME_MAX]; - - #if DIRENT_PADDING > 0U - /** Unused padding so that ulInode is always aligned on a four-byte - boundary. - */ - uint8_t abPadding[DIRENT_PADDING]; - #endif -} DIRENT; - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_RENAME == 1) -static REDSTATUS DirCyclicRenameCheck(uint32_t ulSrcInode, const CINODE *pDstPInode); -#endif -#if REDCONF_READ_ONLY == 0 -static REDSTATUS DirEntryWrite(CINODE *pPInode, uint32_t ulIdx, uint32_t ulInode, const char *pszName, uint32_t ulNameLen); -static uint64_t DirEntryIndexToOffset(uint32_t ulIdx); -#endif -static uint32_t DirOffsetToEntryIndex(uint64_t ullOffset); - - -#if REDCONF_READ_ONLY == 0 -/** @brief Create a new entry in a directory. - - @param pPInode A pointer to the cached inode structure of the directory - to which the new entry will be added. - @param pszName The name to be given to the new entry, terminated by a - null or a path separator. - @param ulInode The inode number the new name will point at. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC There is not enough space on the volume to - create the new directory entry; or the directory - is full. - @retval -RED_ENOTDIR @p pPInode is not a directory. - @retval -RED_ENAMETOOLONG @p pszName is too long. - @retval -RED_EEXIST @p pszName already exists in @p ulPInode. - @retval -RED_EINVAL @p pPInode is not a mounted dirty cached inode - structure; or @p pszName is not a valid name. -*/ -REDSTATUS RedDirEntryCreate( - CINODE *pPInode, - const char *pszName, - uint32_t ulInode) -{ - REDSTATUS ret; - - if(!CINODE_IS_DIRTY(pPInode) || (pszName == NULL) || !INODE_IS_VALID(ulInode)) - { - ret = -RED_EINVAL; - } - else if(!pPInode->fDirectory) - { - ret = -RED_ENOTDIR; - } - else - { - uint32_t ulNameLen = RedNameLen(pszName); - - if(ulNameLen == 0U) - { - ret = -RED_EINVAL; - } - else if(ulNameLen > REDCONF_NAME_MAX) - { - ret = -RED_ENAMETOOLONG; - } - else - { - uint32_t ulEntryIdx; - - ret = RedDirEntryLookup(pPInode, pszName, &ulEntryIdx, NULL); - if(ret == 0) - { - ret = -RED_EEXIST; - } - else if(ret == -RED_ENOENT) - { - if(ulEntryIdx == DIR_INDEX_INVALID) - { - ret = -RED_ENOSPC; - } - else - { - ret = 0; - } - } - else - { - /* Unexpected error, no action. - */ - } - - if(ret == 0) - { - ret = DirEntryWrite(pPInode, ulEntryIdx, ulInode, pszName, ulNameLen); - } - } - } - - return ret; -} -#endif /* REDCONF_READ_ONLY == 0 */ - - -#if DELETE_SUPPORTED -/** @brief Delete an existing directory entry. - - @param pPInode A pointer to the cached inode structure of the directory - containing the entry to be deleted. - @param ulDeleteIdx Position within the directory of the entry to be - deleted. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC The file system does not have enough space to modify - the parent directory to perform the deletion. - @retval -RED_ENOTDIR @p pPInode is not a directory. - @retval -RED_EINVAL @p pPInode is not a mounted dirty cached inode - structure; or @p ulIdx is out of range. -*/ -REDSTATUS RedDirEntryDelete( - CINODE *pPInode, - uint32_t ulDeleteIdx) -{ - REDSTATUS ret = 0; - - if(!CINODE_IS_DIRTY(pPInode) || (ulDeleteIdx >= DIRENTS_MAX)) - { - ret = -RED_EINVAL; - } - else if(!pPInode->fDirectory) - { - ret = -RED_ENOTDIR; - } - else if((DirEntryIndexToOffset(ulDeleteIdx) + DIRENT_SIZE) == pPInode->pInodeBuf->ullSize) - { - /* Start searching one behind the index to be deleted. - */ - uint32_t ulTruncIdx = ulDeleteIdx - 1U; - bool fDone = false; - - /* We are deleting the last dirent in the directory, so search - backwards to find the last populated dirent, allowing us to truncate - the directory to that point. - */ - while((ret == 0) && (ulTruncIdx != UINT32_MAX) && !fDone) - { - ret = RedInodeDataSeekAndRead(pPInode, ulTruncIdx / DIRENTS_PER_BLOCK); - - if(ret == 0) - { - const DIRENT *pDirents = CAST_CONST_DIRENT_PTR(pPInode->pbData); - uint32_t ulBlockIdx = ulTruncIdx % DIRENTS_PER_BLOCK; - - do - { - if(pDirents[ulBlockIdx].ulInode != INODE_INVALID) - { - fDone = true; - break; - } - - ulTruncIdx--; - ulBlockIdx--; - } while(ulBlockIdx != UINT32_MAX); - } - else if(ret == -RED_ENODATA) - { - ret = 0; - - REDASSERT((ulTruncIdx % DIRENTS_PER_BLOCK) == 0U); - ulTruncIdx -= DIRENTS_PER_BLOCK; - } - else - { - /* Unexpected error, loop will terminate; nothing else - to be done. - */ - } - } - - /* Currently ulTruncIdx represents the last valid dirent index, or - UINT32_MAX if the directory is now empty. Increment it so that it - represents the first invalid entry, which will be truncated. - */ - ulTruncIdx++; - - /* Truncate the directory, deleting the requested entry and any empty - dirents at the end of the directory. - */ - if(ret == 0) - { - ret = RedInodeDataTruncate(pPInode, DirEntryIndexToOffset(ulTruncIdx)); - } - } - else - { - /* The dirent to delete is not the last entry in the directory, so just - zero it. - */ - ret = DirEntryWrite(pPInode, ulDeleteIdx, INODE_INVALID, "", 0U); - } - - return ret; -} -#endif /* DELETE_SUPPORTED */ - - -/** @brief Perform a case-sensitive search of a directory for a given name. - - If found, then position of the entry within the directory and the inode - number it points to are returned. As an optimization for directory entry - creation, in the case where the requested entry does not exist, the position - of the first available (unused) entry is returned. - - @param pPInode A pointer to the cached inode structure of the directory - to search. - @param pszName The name of the desired entry, terminated by either a - null or a path separator. - @param pulEntryIdx On successful return, meaning that the desired entry - exists, populated with the position of the entry. If - returning an -RED_ENOENT error, populated with the - position of the first available entry, or set to - DIR_INDEX_INVALID if the directory is full. Optional. - @param pulInode On successful return, populated with the inode number - that the name points to. Optional; may be `NULL`. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOENT @p pszName does not name an existing file or - directory. - @retval -RED_ENOTDIR @p pPInode is not a directory. - @retval -RED_EINVAL @p pPInode is not a mounted cached inode - structure; or @p pszName is not a valid name; or - @p pulEntryIdx is `NULL`. - @retval -RED_ENAMETOOLONG @p pszName is too long. -*/ -REDSTATUS RedDirEntryLookup( - CINODE *pPInode, - const char *pszName, - uint32_t *pulEntryIdx, - uint32_t *pulInode) -{ - REDSTATUS ret = 0; - - if(!CINODE_IS_MOUNTED(pPInode) || (pszName == NULL)) - { - ret = -RED_EINVAL; - } - else if(!pPInode->fDirectory) - { - ret = -RED_ENOTDIR; - } - else - { - uint32_t ulNameLen = RedNameLen(pszName); - - if(ulNameLen == 0U) - { - ret = -RED_EINVAL; - } - else if(ulNameLen > REDCONF_NAME_MAX) - { - ret = -RED_ENAMETOOLONG; - } - else - { - uint32_t ulIdx = 0U; - uint32_t ulDirentCount = DirOffsetToEntryIndex(pPInode->pInodeBuf->ullSize); - uint32_t ulFreeIdx = DIR_INDEX_INVALID; /* Index of first free dirent. */ - - /* Loop over the directory blocks, searching each block for a - dirent that matches the given name. - */ - while((ret == 0) && (ulIdx < ulDirentCount)) - { - ret = RedInodeDataSeekAndRead(pPInode, ulIdx / DIRENTS_PER_BLOCK); - - if(ret == 0) - { - const DIRENT *pDirents = CAST_CONST_DIRENT_PTR(pPInode->pbData); - uint32_t ulBlockLastIdx = REDMIN(DIRENTS_PER_BLOCK, ulDirentCount - ulIdx); - uint32_t ulBlockIdx; - - for(ulBlockIdx = 0U; ulBlockIdx < ulBlockLastIdx; ulBlockIdx++) - { - const DIRENT *pDirent = &pDirents[ulBlockIdx]; - - if(pDirent->ulInode != INODE_INVALID) - { - /* The name in the dirent will not be null - terminated if it is of the maximum length, so - use a bounded string compare and then make sure - there is nothing more to the name. - */ - if( (RedStrNCmp(pDirent->acName, pszName, ulNameLen) == 0) - && ((ulNameLen == REDCONF_NAME_MAX) || (pDirent->acName[ulNameLen] == '\0'))) - { - /* Found a matching dirent, stop and return its - information. - */ - if(pulInode != NULL) - { - *pulInode = pDirent->ulInode; - - #ifdef REDCONF_ENDIAN_SWAP - *pulInode = RedRev32(*pulInode); - #endif - } - - ulIdx += ulBlockIdx; - break; - } - } - else if(ulFreeIdx == DIR_INDEX_INVALID) - { - ulFreeIdx = ulIdx + ulBlockIdx; - } - else - { - /* The directory entry is free, but we already found a free one, so there's - nothing to do here. - */ - } - } - - if(ulBlockIdx < ulBlockLastIdx) - { - /* If we broke out of the for loop, we found a matching - dirent and can stop the search. - */ - break; - } - - ulIdx += ulBlockLastIdx; - } - else if(ret == -RED_ENODATA) - { - if(ulFreeIdx == DIR_INDEX_INVALID) - { - ulFreeIdx = ulIdx; - } - - ret = 0; - ulIdx += DIRENTS_PER_BLOCK; - } - else - { - /* Unexpected error, let the loop terminate, no action - here. - */ - } - } - - if(ret == 0) - { - /* If we made it all the way to the end of the directory - without stopping, then the given name does not exist in the - directory. - */ - if(ulIdx == ulDirentCount) - { - /* If the directory had no sparse dirents, then the first - free dirent is beyond the end of the directory. If the - directory is already the maximum size, then there is no - free dirent. - */ - if((ulFreeIdx == DIR_INDEX_INVALID) && (ulDirentCount < DIRENTS_MAX)) - { - ulFreeIdx = ulDirentCount; - } - - ulIdx = ulFreeIdx; - - ret = -RED_ENOENT; - } - - if(pulEntryIdx != NULL) - { - *pulEntryIdx = ulIdx; - } - } - } - } - - return ret; -} - - -#if (REDCONF_API_POSIX_READDIR == 1) || (REDCONF_CHECKER == 1) -/** @brief Read the next entry from a directory, given a starting index. - - @param pPInode A pointer to the cached inode structure of the directory to - read from. - @param pulIdx On entry, the directory index to start reading from. On - successful return, populated with the directory index to use - for subsequent reads. On -RED_ENOENT return, populated with - the directory index immediately following the last valid - one. - @param pszName On successful return, populated with the name of the next - directory entry. Buffer must be at least - REDCONF_NAME_MAX + 1 in size, to store the maximum name - length plus a null terminator. - @param pulInode On successful return, populated with the inode number - pointed at by the next directory entry. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOENT There are no more entries in the directory. - @retval -RED_ENOTDIR @p pPInode is not a directory. - @retval -RED_EINVAL @p pPInode is not a mounted cached inode structure; - or @p pszName is `NULL`; or @p pulIdx is `NULL`; or - @p pulInode is `NULL`. -*/ -REDSTATUS RedDirEntryRead( - CINODE *pPInode, - uint32_t *pulIdx, - char *pszName, - uint32_t *pulInode) -{ - REDSTATUS ret = 0; - - if(!CINODE_IS_MOUNTED(pPInode) || (pulIdx == NULL) || (pszName == NULL) || (pulInode == NULL)) - { - ret = -RED_EINVAL; - } - else if(!pPInode->fDirectory) - { - ret = -RED_ENOTDIR; - } - else - { - uint32_t ulIdx = *pulIdx; - uint32_t ulDirentCount = DirOffsetToEntryIndex(pPInode->pInodeBuf->ullSize); - - /* Starting either at the beginning of the directory or where we left - off, loop over the directory blocks, searching each block for a - non-sparse dirent to return as the next entry in the directory. - */ - while((ret == 0) && (ulIdx < ulDirentCount)) - { - uint32_t ulBlockOffset = ulIdx / DIRENTS_PER_BLOCK; - - ret = RedInodeDataSeekAndRead(pPInode, ulBlockOffset); - - if(ret == 0) - { - const DIRENT *pDirents = CAST_CONST_DIRENT_PTR(pPInode->pbData); - uint32_t ulBlockLastIdx = REDMIN(DIRENTS_PER_BLOCK, ulDirentCount - (ulBlockOffset * DIRENTS_PER_BLOCK)); - uint32_t ulBlockIdx; - - for(ulBlockIdx = ulIdx % DIRENTS_PER_BLOCK; ulBlockIdx < ulBlockLastIdx; ulBlockIdx++) - { - if(pDirents[ulBlockIdx].ulInode != INODE_INVALID) - { - *pulIdx = ulIdx + 1U; - RedStrNCpy(pszName, pDirents[ulBlockIdx].acName, REDCONF_NAME_MAX); - pszName[REDCONF_NAME_MAX] = '\0'; - - *pulInode = pDirents[ulBlockIdx].ulInode; - - #ifdef REDCONF_ENDIAN_SWAP - *pulInode = RedRev32(*pulInode); - #endif - break; - } - - ulIdx++; - } - - if(ulBlockIdx < ulBlockLastIdx) - { - REDASSERT(ulIdx <= ulDirentCount); - break; - } - } - else if(ret == -RED_ENODATA) - { - ulIdx += DIRENTS_PER_BLOCK - (ulIdx % DIRENTS_PER_BLOCK); - ret = 0; - } - else - { - /* Unexpected error, loop will terminate; nothing else to do. - */ - } - - REDASSERT(ulIdx <= ulDirentCount); - } - - if((ret == 0) && (ulIdx >= ulDirentCount)) - { - *pulIdx = ulDirentCount; - ret = -RED_ENOENT; - } - } - - return ret; -} -#endif - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_RENAME == 1) -/** Rename a directory entry. - - @param pSrcPInode The inode of the directory containing @p pszSrcName. - @param pszSrcName The name of the directory entry to be renamed. - @param pSrcInode On successful return, populated with the inode of the - source entry. - @param pDstPInode The inode of the directory in which @p pszDstName will - be created or replaced. - @param pszDstName The name of the directory entry to be created or - replaced. - @param pDstInode On successful return, if the destination previously - existed, populated with the inode previously pointed to - by the destination. This may be the same as the source - inode. If the destination did not exist, populated with - INODE_INVALID. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EEXIST #REDCONF_RENAME_ATOMIC is false and the - destination name exists. - @retval -RED_EINVAL @p pSrcPInode is not a mounted dirty cached - inode structure; or @p pSrcInode is `NULL`; or - @p pszSrcName is not a valid name; or - @p pDstPInode is not a mounted dirty cached - inode structure; or @p pDstInode is `NULL`; or - @p pszDstName is not a valid name. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EISDIR The destination name exists and is a directory, - and the source name is a non-directory. - @retval -RED_ENAMETOOLONG Either @p pszSrcName or @p pszDstName is longer - than #REDCONF_NAME_MAX. - @retval -RED_ENOENT The source name is not an existing entry; or - either @p pszSrcName or @p pszDstName point to - an empty string. - @retval -RED_ENOTDIR @p pSrcPInode is not a directory; or - @p pDstPInode is not a directory; or the source - name is a directory and the destination name is - a file. - @retval -RED_ENOTEMPTY The destination name is a directory which is not - empty. - @retval -RED_ENOSPC The file system does not have enough space to - extend the @p ulDstPInode directory. - @retval -RED_EROFS The directory to be removed resides on a - read-only file system. -*/ -REDSTATUS RedDirEntryRename( - CINODE *pSrcPInode, - const char *pszSrcName, - CINODE *pSrcInode, - CINODE *pDstPInode, - const char *pszDstName, - CINODE *pDstInode) -{ - REDSTATUS ret; - - if( !CINODE_IS_DIRTY(pSrcPInode) - || (pszSrcName == NULL) - || (pSrcInode == NULL) - || !CINODE_IS_DIRTY(pDstPInode) - || (pszDstName == NULL) - || (pDstInode == NULL)) - { - ret = -RED_EINVAL; - } - else if(!pSrcPInode->fDirectory || !pDstPInode->fDirectory) - { - ret = -RED_ENOTDIR; - } - else - { - uint32_t ulDstIdx = 0U; /* Init'd to quiet warnings. */ - uint32_t ulSrcIdx; - - /* Look up the source and destination names. - */ - ret = RedDirEntryLookup(pSrcPInode, pszSrcName, &ulSrcIdx, &pSrcInode->ulInode); - - if(ret == 0) - { - ret = RedDirEntryLookup(pDstPInode, pszDstName, &ulDstIdx, &pDstInode->ulInode); - - if(ret == -RED_ENOENT) - { - if(ulDstIdx == DIR_INDEX_INVALID) - { - ret = -RED_ENOSPC; - } - else - { - #if REDCONF_RENAME_ATOMIC == 1 - pDstInode->ulInode = INODE_INVALID; - #endif - ret = 0; - } - } - #if REDCONF_RENAME_ATOMIC == 0 - else if(ret == 0) - { - ret = -RED_EEXIST; - } - else - { - /* Nothing to do here, just propagate the error. - */ - } - #endif - } - - #if REDCONF_RENAME_ATOMIC == 1 - /* If both names point to the same inode, POSIX says to do nothing to - either name. - */ - if((ret == 0) && (pSrcInode->ulInode != pDstInode->ulInode)) - #else - if(ret == 0) - #endif - { - ret = RedInodeMount(pSrcInode, FTYPE_EITHER, true); - - #if REDCONF_RENAME_ATOMIC == 1 - if((ret == 0) && (pDstInode->ulInode != INODE_INVALID)) - { - /* Source and destination must be the same type (file/dir). - */ - ret = RedInodeMount(pDstInode, pSrcInode->fDirectory ? FTYPE_DIR : FTYPE_FILE, true); - - /* If renaming directories, the destination must be empty. - */ - if((ret == 0) && pDstInode->fDirectory && (pDstInode->pInodeBuf->ullSize > 0U)) - { - ret = -RED_ENOTEMPTY; - } - } - #endif - - /* If we are renaming a directory, make sure the rename isn't - cyclic (e.g., renaming "foo" into "foo/bar"). - */ - if((ret == 0) && pSrcInode->fDirectory) - { - ret = DirCyclicRenameCheck(pSrcInode->ulInode, pDstPInode); - } - - if(ret == 0) - { - ret = DirEntryWrite(pDstPInode, ulDstIdx, pSrcInode->ulInode, pszDstName, RedNameLen(pszDstName)); - } - - if(ret == 0) - { - ret = RedDirEntryDelete(pSrcPInode, ulSrcIdx); - - if(ret == -RED_ENOSPC) - { - REDSTATUS ret2; - - /* If there was not enough space to branch the parent - directory inode and data block containin the source - entry, revert destination directory entry to its - previous state. - */ - #if REDCONF_RENAME_ATOMIC == 1 - if(pDstInode->ulInode != INODE_INVALID) - { - ret2 = DirEntryWrite(pDstPInode, ulDstIdx, pDstInode->ulInode, pszDstName, RedNameLen(pszDstName)); - } - else - #endif - { - ret2 = RedDirEntryDelete(pDstPInode, ulDstIdx); - } - - if(ret2 != 0) - { - ret = ret2; - CRITICAL_ERROR(); - } - } - } - - if(ret == 0) - { - pSrcInode->pInodeBuf->ulPInode = pDstPInode->ulInode; - } - } - } - - return ret; -} - - -/** @brief Check for a cyclic rename. - - A cyclic rename is renaming a directory into a subdirectory of itself. For - example, renaming "a" into "a/b/c/d" is cyclic. These renames must not be - allowed since they would corrupt the directory tree. - - @param ulSrcInode The inode number of the directory being renamed. - @param pDstPInode A pointer to the cached inode structure of the directory - into which the source is being renamed. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EINVAL The rename is cyclic; or invalid parameters. - @retval -RED_ENOTDIR @p pDstPInode is not a directory. -*/ -static REDSTATUS DirCyclicRenameCheck( - uint32_t ulSrcInode, - const CINODE *pDstPInode) -{ - REDSTATUS ret = 0; - - if(!INODE_IS_VALID(ulSrcInode) || !CINODE_IS_MOUNTED(pDstPInode)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else if(ulSrcInode == pDstPInode->ulInode) - { - ret = -RED_EINVAL; - } - else if(!pDstPInode->fDirectory) - { - ret = -RED_ENOTDIR; - } - else - { - CINODE NextParent; - /* Used to prevent infinite loop in case of corrupted directory - structure. - */ - uint32_t ulIteration = 0U; - - NextParent.ulInode = pDstPInode->pInodeBuf->ulPInode; - - while( (NextParent.ulInode != ulSrcInode) - && (NextParent.ulInode != INODE_ROOTDIR) - && (NextParent.ulInode != INODE_INVALID) - && (ulIteration < gpRedVolConf->ulInodeCount)) - { - ret = RedInodeMount(&NextParent, FTYPE_DIR, false); - if(ret != 0) - { - break; - } - - NextParent.ulInode = NextParent.pInodeBuf->ulPInode; - - RedInodePut(&NextParent, 0U); - - ulIteration++; - } - - if((ret == 0) && (ulIteration == gpRedVolConf->ulInodeCount)) - { - CRITICAL_ERROR(); - ret = -RED_EFUBAR; - } - - if((ret == 0) && (ulSrcInode == NextParent.ulInode)) - { - ret = -RED_EINVAL; - } - } - - return ret; -} -#endif /* (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_RENAME == 1) */ - - -#if REDCONF_READ_ONLY == 0 -/** @brief Update the contents of a directory entry. - - @param pPInode A pointer to the cached inode structure of the directory - whose entry is being written. - @param ulIdx The index of the directory entry to write. - @param ulInode The inode number the directory entry is to point at. - @param pszName The name of the directory entry. - @param ulNameLen The length of @p pszName. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC There is not enough space on the volume to write the - directory entry. - @retval -RED_ENOTDIR @p pPInode is not a directory. - @retval -RED_EINVAL Invalid parameters. -*/ -static REDSTATUS DirEntryWrite( - CINODE *pPInode, - uint32_t ulIdx, - uint32_t ulInode, - const char *pszName, - uint32_t ulNameLen) -{ - REDSTATUS ret; - - if( !CINODE_IS_DIRTY(pPInode) - || (ulIdx >= DIRENTS_MAX) - || (!INODE_IS_VALID(ulInode) && (ulInode != INODE_INVALID)) - || (pszName == NULL) - || (ulNameLen > REDCONF_NAME_MAX) - || ((ulNameLen == 0U) != (ulInode == INODE_INVALID))) - { - REDERROR(); - ret = -RED_EINVAL; - } - else if(!pPInode->fDirectory) - { - ret = -RED_ENOTDIR; - } - else - { - uint64_t ullOffset = DirEntryIndexToOffset(ulIdx); - uint32_t ulLen = DIRENT_SIZE; - static DIRENT de; - - RedMemSet(&de, 0U, sizeof(de)); - - de.ulInode = ulInode; - - #ifdef REDCONF_ENDIAN_SWAP - de.ulInode = RedRev32(de.ulInode); - #endif - - RedStrNCpy(de.acName, pszName, ulNameLen); - - ret = RedInodeDataWrite(pPInode, ullOffset, &ulLen, &de); - } - - return ret; -} - - -/** @brief Convert a directory entry index to a byte offset. - - @param ulIdx Directory entry index. - - @return Byte offset in the directory corresponding with ulIdx. -*/ -static uint64_t DirEntryIndexToOffset( - uint32_t ulIdx) -{ - uint32_t ulBlock = ulIdx / DIRENTS_PER_BLOCK; - uint32_t ulOffsetInBlock = ulIdx % DIRENTS_PER_BLOCK; - uint64_t ullOffset; - - REDASSERT(ulIdx < DIRENTS_MAX); - - ullOffset = (uint64_t)ulBlock << BLOCK_SIZE_P2; - ullOffset += (uint64_t)ulOffsetInBlock * DIRENT_SIZE; - - return ullOffset; -} -#endif /* REDCONF_READ_ONLY == 0 */ - - -/** @brief Convert a byte offset to a directory entry index. - - @param ullOffset Byte offset in the directory. - - @return Directory entry index corresponding with @p ullOffset. -*/ -static uint32_t DirOffsetToEntryIndex( - uint64_t ullOffset) -{ - uint32_t ulIdx; - - REDASSERT(ullOffset < INODE_SIZE_MAX); - REDASSERT(((uint32_t)(ullOffset & (REDCONF_BLOCK_SIZE - 1U)) % DIRENT_SIZE) == 0U); - - /* Avoid doing any 64-bit divides. - */ - ulIdx = (uint32_t)(ullOffset >> BLOCK_SIZE_P2) * DIRENTS_PER_BLOCK; - ulIdx += (uint32_t)(ullOffset & (REDCONF_BLOCK_SIZE - 1U)) / DIRENT_SIZE; - - return ulIdx; -} - - -#endif /* REDCONF_API_POSIX == 1 */ - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/format.c b/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/format.c deleted file mode 100755 index e237ab5..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/format.c +++ /dev/null @@ -1,235 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements the Reliance Edge file system formatter. -*/ -#include -#include -#include - -#if FORMAT_SUPPORTED - - -/** @brief Format a file system volume. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBUSY Volume is mounted. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedVolFormat(void) -{ - REDSTATUS ret; - - if(gpRedVolume->fMounted) - { - ret = -RED_EBUSY; - } - else - { - ret = RedOsBDevOpen(gbRedVolNum, BDEV_O_RDWR); - } - - if(ret == 0) - { - MASTERBLOCK *pMB; - REDSTATUS ret2; - - /* Overwrite the master block with zeroes, so that if formatting is - interrupted, the volume will not be mountable. - */ - ret = RedBufferGet(BLOCK_NUM_MASTER, BFLAG_NEW | BFLAG_DIRTY, CAST_VOID_PTR_PTR(&pMB)); - - if(ret == 0) - { - ret = RedBufferFlush(BLOCK_NUM_MASTER, 1U); - - RedBufferDiscard(pMB); - } - - if(ret == 0) - { - ret = RedIoFlush(gbRedVolNum); - } - - #if REDCONF_IMAP_EXTERNAL == 1 - if((ret == 0) && !gpRedCoreVol->fImapInline) - { - uint32_t ulImapBlock; - uint32_t ulImapBlockLimit = gpRedCoreVol->ulImapStartBN + (gpRedCoreVol->ulImapNodeCount * 2U); - uint16_t uImapFlags = (uint16_t)((uint32_t)BFLAG_META_IMAP | BFLAG_NEW | BFLAG_DIRTY); - - /* Technically it is only necessary to create one copy of each imap - node (the copy the metaroot points at), but creating them both - avoids headaches during disk image analysis from stale imaps - left over from previous formats. - */ - for(ulImapBlock = gpRedCoreVol->ulImapStartBN; ulImapBlock < ulImapBlockLimit; ulImapBlock++) - { - IMAPNODE *pImap; - - ret = RedBufferGet(ulImapBlock, uImapFlags, CAST_VOID_PTR_PTR(&pImap)); - if(ret != 0) - { - break; - } - - RedBufferPut(pImap); - } - } - #endif - - /* Write the first metaroot. - */ - if(ret == 0) - { - RedMemSet(gpRedMR, 0U, sizeof(*gpRedMR)); - - gpRedMR->ulFreeBlocks = gpRedVolume->ulBlocksAllocable; - #if REDCONF_API_POSIX == 1 - gpRedMR->ulFreeInodes = gpRedVolConf->ulInodeCount; - #endif - gpRedMR->ulAllocNextBlock = gpRedCoreVol->ulFirstAllocableBN; - - /* The branched flag is typically set automatically when bits in - the imap change. It is set here explicitly because the imap has - only been initialized, not changed. - */ - gpRedCoreVol->fBranched = true; - - ret = RedVolTransact(); - } - - #if REDCONF_API_POSIX == 1 - /* Create the root directory. - */ - if(ret == 0) - { - CINODE rootdir; - - rootdir.ulInode = INODE_ROOTDIR; - ret = RedInodeCreate(&rootdir, INODE_INVALID, RED_S_IFDIR); - - if(ret == 0) - { - RedInodePut(&rootdir, 0U); - } - } - #endif - - #if REDCONF_API_FSE == 1 - /* The FSE API does not support creating or deletes files, so all the - inodes are created during setup. - */ - if(ret == 0) - { - uint32_t ulInodeIdx; - - for(ulInodeIdx = 0U; ulInodeIdx < gpRedVolConf->ulInodeCount; ulInodeIdx++) - { - CINODE ino; - - ino.ulInode = INODE_FIRST_FREE + ulInodeIdx; - ret = RedInodeCreate(&ino, INODE_INVALID, RED_S_IFREG); - - if(ret == 0) - { - RedInodePut(&ino, 0U); - } - } - } - #endif - - /* Write the second metaroot. - */ - if(ret == 0) - { - ret = RedVolTransact(); - } - - /* Populate and write out the master block. - */ - if(ret == 0) - { - ret = RedBufferGet(BLOCK_NUM_MASTER, (uint16_t)((uint32_t)BFLAG_META_MASTER | BFLAG_NEW | BFLAG_DIRTY), CAST_VOID_PTR_PTR(&pMB)); - } - - if(ret == 0) - { - pMB->ulVersion = RED_DISK_LAYOUT_VERSION; - RedStrNCpy(pMB->acBuildNum, RED_BUILD_NUMBER, sizeof(pMB->acBuildNum)); - pMB->ulFormatTime = RedOsClockGetTime(); - pMB->ulInodeCount = gpRedVolConf->ulInodeCount; - pMB->ulBlockCount = gpRedVolume->ulBlockCount; - pMB->uMaxNameLen = REDCONF_NAME_MAX; - pMB->uDirectPointers = REDCONF_DIRECT_POINTERS; - pMB->uIndirectPointers = REDCONF_INDIRECT_POINTERS; - pMB->bBlockSizeP2 = BLOCK_SIZE_P2; - - #if REDCONF_API_POSIX == 1 - pMB->bFlags |= MBFLAG_API_POSIX; - #endif - #if REDCONF_INODE_TIMESTAMPS == 1 - pMB->bFlags |= MBFLAG_INODE_TIMESTAMPS; - #endif - #if REDCONF_INODE_BLOCKS == 1 - pMB->bFlags |= MBFLAG_INODE_BLOCKS; - #endif - #if (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_LINK == 1) - pMB->bFlags |= MBFLAG_INODE_NLINK; - #endif - - ret = RedBufferFlush(BLOCK_NUM_MASTER, 1U); - - RedBufferPut(pMB); - } - - if(ret == 0) - { - ret = RedIoFlush(gbRedVolNum); - } - - ret2 = RedOsBDevClose(gbRedVolNum); - if(ret == 0) - { - ret = ret2; - } - } - - /* Discard the buffers so a subsequent format will not run into blocks it - does not expect. - */ - if(ret == 0) - { - ret = RedBufferDiscardRange(0U, gpRedVolume->ulBlockCount); - } - - return ret; -} - - -#endif /* FORMAT_SUPPORTED */ - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/imap.c b/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/imap.c deleted file mode 100755 index 23bd508..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/imap.c +++ /dev/null @@ -1,349 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements allocation routines. - - This module implements routines for working with the imap, a bitmap which - tracks which blocks are allocated or free. Some of the functionality is - delegated to imapinline.c and imapextern.c. -*/ -#include -#include - - -/** @brief Get the allocation bit of a block from either metaroot. - - Will pass the call down either to the inline imap or to the external imap - implementation, whichever is appropriate for the current volume. - - @param bMR The metaroot index: either 0 or 1. - @param ulBlock The block number to query. - @param pfAllocated On successful return, populated with the allocation bit - of the block. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bMR is out of range; or @p ulBlock is out of range; - or @p pfAllocated is `NULL`. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedImapBlockGet( - uint8_t bMR, - uint32_t ulBlock, - bool *pfAllocated) -{ - REDSTATUS ret; - - if( (bMR > 1U) - || (ulBlock < gpRedCoreVol->ulInodeTableStartBN) - || (ulBlock >= gpRedVolume->ulBlockCount) - || (pfAllocated == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - #if (REDCONF_IMAP_INLINE == 1) && (REDCONF_IMAP_EXTERNAL == 1) - if(gpRedCoreVol->fImapInline) - { - ret = RedImapIBlockGet(bMR, ulBlock, pfAllocated); - } - else - { - ret = RedImapEBlockGet(bMR, ulBlock, pfAllocated); - } - #elif REDCONF_IMAP_INLINE == 1 - ret = RedImapIBlockGet(bMR, ulBlock, pfAllocated); - #else - ret = RedImapEBlockGet(bMR, ulBlock, pfAllocated); - #endif - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Set the allocation bit of a block in the working metaroot. - - Will pass the call down either to the inline imap or to the external imap - implementation, whichever is appropriate for the current volume. - - @param ulBlock The block number to allocate or free. - @param fAllocated Whether to allocate the block (true) or free it (false). - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p ulBlock is out of range; or @p ulBlock is allocable - and @p fAllocated is 1. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedImapBlockSet( - uint32_t ulBlock, - bool fAllocated) -{ - REDSTATUS ret; - - if( (ulBlock < gpRedCoreVol->ulInodeTableStartBN) - || (ulBlock >= gpRedVolume->ulBlockCount)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else if( (ulBlock >= gpRedCoreVol->ulFirstAllocableBN) - && ( (fAllocated && (gpRedMR->ulFreeBlocks == 0U)) - || ((!fAllocated) && (gpRedMR->ulFreeBlocks >= gpRedVolume->ulBlocksAllocable)))) - { - /* Attempting either to free more blocks than are allocable, or - allocate a block when there are none available. This could indicate - metadata corruption. - */ - CRITICAL_ERROR(); - ret = -RED_EFUBAR; - } - else - { - #if (REDCONF_IMAP_INLINE == 1) && (REDCONF_IMAP_EXTERNAL == 1) - if(gpRedCoreVol->fImapInline) - { - ret = RedImapIBlockSet(ulBlock, fAllocated); - } - else - { - ret = RedImapEBlockSet(ulBlock, fAllocated); - } - #elif REDCONF_IMAP_INLINE == 1 - ret = RedImapIBlockSet(ulBlock, fAllocated); - #else - ret = RedImapEBlockSet(ulBlock, fAllocated); - #endif - - /* Any change to the allocation state of a block indicates that the - volume is now branched. - */ - gpRedCoreVol->fBranched = true; - } - - /* If a block was marked as no longer in use, discard it from the buffers. - */ - if((ret == 0) && (!fAllocated)) - { - ret = RedBufferDiscardRange(ulBlock, 1U); - CRITICAL_ASSERT(ret == 0); - } - - /* Adjust the free/almost free block count if the block was allocable. - Discard the block if required. - */ - if((ret == 0) && (ulBlock >= gpRedCoreVol->ulFirstAllocableBN)) - { - if(fAllocated) - { - gpRedMR->ulFreeBlocks--; - } - else - { - bool fWasAllocated; - - /* Whether the block became free or almost free depends on its - previous allocation state. If it was used, then it is now - almost free. Otherwise, it was new and is now free. - */ - ret = RedImapBlockGet(1U - gpRedCoreVol->bCurMR, ulBlock, &fWasAllocated); - CRITICAL_ASSERT(ret == 0); - - if(ret == 0) - { - if(fWasAllocated) - { - gpRedCoreVol->ulAlmostFreeBlocks++; - } - else - { - gpRedMR->ulFreeBlocks++; - } - } - } - } - - return ret; -} - - -/** @brief Allocate one block. - - @param pulBlock On successful return, populated with the allocated block - number. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p pulBlock is `NULL`. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC Insufficient free space to perform the allocation. -*/ -REDSTATUS RedImapAllocBlock( - uint32_t *pulBlock) -{ - REDSTATUS ret; - - if(pulBlock == NULL) - { - REDERROR(); - ret = -RED_EINVAL; - } - else if(gpRedMR->ulFreeBlocks == 0U) - { - ret = -RED_ENOSPC; - } - else - { - uint32_t ulStopBlock = gpRedMR->ulAllocNextBlock; - bool fAllocated = false; - - do - { - ALLOCSTATE state; - - ret = RedImapBlockState(gpRedMR->ulAllocNextBlock, &state); - CRITICAL_ASSERT(ret == 0); - - if(ret == 0) - { - if(state == ALLOCSTATE_FREE) - { - ret = RedImapBlockSet(gpRedMR->ulAllocNextBlock, true); - CRITICAL_ASSERT(ret == 0); - - *pulBlock = gpRedMR->ulAllocNextBlock; - fAllocated = true; - } - - /* Increment the next block number, wrapping it when the end of - the volume is reached. - */ - gpRedMR->ulAllocNextBlock++; - if(gpRedMR->ulAllocNextBlock == gpRedVolume->ulBlockCount) - { - gpRedMR->ulAllocNextBlock = gpRedCoreVol->ulFirstAllocableBN; - } - } - } - while((ret == 0) && !fAllocated && (gpRedMR->ulAllocNextBlock != ulStopBlock)); - - if((ret == 0) && !fAllocated) - { - /* The free block count was already determined to be non-zero, no - error occurred while looking for free blocks, but no free blocks - were found. This indicates metadata corruption. - */ - CRITICAL_ERROR(); - ret = -RED_EFUBAR; - } - } - - return ret; -} -#endif /* REDCONF_READ_ONLY == 0 */ - - -/** @brief Get the allocation state of a block. - - Takes into account the allocation bits from both metaroots, and returns one - of four possible allocation state values: - - - ::ALLOCSTATE_FREE Free and may be allocated; writeable. - - ::ALLOCSTATE_USED In-use and transacted; not writeable. - - ::ALLOCSTATE_NEW In-use but not transacted; writeable. - - ::ALLOCSTATE_AFREE Will become free after a transaction; not writeable. - - @param ulBlock The block number to query. - @param pState On successful return, populated with the state of the block. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p ulBlock is out of range; or @p pState is `NULL`. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedImapBlockState( - uint32_t ulBlock, - ALLOCSTATE *pState) -{ - REDSTATUS ret; - - if( (ulBlock < gpRedCoreVol->ulInodeTableStartBN) - || (ulBlock >= gpRedVolume->ulBlockCount) - || (pState == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - bool fBitCurrent; - - ret = RedImapBlockGet(gpRedCoreVol->bCurMR, ulBlock, &fBitCurrent); - - if(ret == 0) - { - bool fBitOld; - - ret = RedImapBlockGet(1U - gpRedCoreVol->bCurMR, ulBlock, &fBitOld); - - if(ret == 0) - { - if(fBitCurrent) - { - if(fBitOld) - { - *pState = ALLOCSTATE_USED; - } - else - { - *pState = ALLOCSTATE_NEW; - } - } - else - { - if(fBitOld) - { - *pState = ALLOCSTATE_AFREE; - } - else - { - *pState = ALLOCSTATE_FREE; - } - } - } - } - } - - return ret; -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/imapextern.c b/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/imapextern.c deleted file mode 100755 index 4ce7371..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/imapextern.c +++ /dev/null @@ -1,316 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements routines for the external imap. - - The external imap is used on volumes that are too big for the imap bitmap - to be stored entirely in the metaroot, so instead the bitmap is stored in - imap nodes on disk, and the metaroot bitmap is used to toggle between imap - nodes. -*/ -#include - -#if REDCONF_IMAP_EXTERNAL == 1 - -#include - - -#if REDCONF_READ_ONLY == 0 -static REDSTATUS ImapNodeBranch(uint32_t ulImapNode, IMAPNODE **ppImap); -static bool ImapNodeIsBranched(uint32_t ulImapNode); -#endif - - -/** @brief Get the allocation bit of a block from the imap as it exists in - either metaroot. - - @param bMR The metaroot index: either 0 or 1. - @param ulBlock The block number to query. - @param pfAllocated On successful exit, populated with the allocation bit - of the block. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bMR is out of range; or @p ulBlock is out of range; - or @p pfAllocated is `NULL`. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedImapEBlockGet( - uint8_t bMR, - uint32_t ulBlock, - bool *pfAllocated) -{ - REDSTATUS ret; - - if( gpRedCoreVol->fImapInline - || (bMR > 1U) - || (ulBlock < gpRedCoreVol->ulInodeTableStartBN) - || (ulBlock >= gpRedVolume->ulBlockCount) - || (pfAllocated == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - uint32_t ulOffset = ulBlock - gpRedCoreVol->ulInodeTableStartBN; - uint32_t ulImapNode = ulOffset / IMAPNODE_ENTRIES; - uint8_t bMRToRead = bMR; - IMAPNODE *pImap; - - #if REDCONF_READ_ONLY == 0 - /* If the imap node is not branched, then both copies of the imap are - identical. If the old metaroot copy is requested, use the current - copy instead, since it is more likely to be buffered. - */ - if(bMR == (1U - gpRedCoreVol->bCurMR)) - { - if(!ImapNodeIsBranched(ulImapNode)) - { - bMRToRead = 1U - bMR; - } - } - #endif - - ret = RedBufferGet(RedImapNodeBlock(bMRToRead, ulImapNode), BFLAG_META_IMAP, CAST_VOID_PTR_PTR(&pImap)); - - if(ret == 0) - { - *pfAllocated = RedBitGet(pImap->abEntries, ulOffset % IMAPNODE_ENTRIES); - - RedBufferPut(pImap); - } - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Set the allocation bit of a block in the working-state imap. - - @param ulBlock The block number to allocate or free. - @param fAllocated Whether to allocate the block (true) or free it (false). - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p ulBlock is out of range. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedImapEBlockSet( - uint32_t ulBlock, - bool fAllocated) -{ - REDSTATUS ret; - - if( gpRedCoreVol->fImapInline - || (ulBlock < gpRedCoreVol->ulInodeTableStartBN) - || (ulBlock >= gpRedVolume->ulBlockCount)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - uint32_t ulOffset = ulBlock - gpRedCoreVol->ulInodeTableStartBN; - uint32_t ulImapNode = ulOffset / IMAPNODE_ENTRIES; - IMAPNODE *pImap; - - ret = ImapNodeBranch(ulImapNode, &pImap); - - if(ret == 0) - { - uint32_t ulImapEntry = ulOffset % IMAPNODE_ENTRIES; - - if(RedBitGet(pImap->abEntries, ulImapEntry) == fAllocated) - { - /* The driver shouldn't ever set a bit in the imap to its - current value. That shouldn't ever be needed, and it - indicates that the driver is doing unnecessary I/O, or - that the imap is corrupt. - */ - CRITICAL_ERROR(); - ret = -RED_EFUBAR; - } - else if(fAllocated) - { - RedBitSet(pImap->abEntries, ulImapEntry); - } - else - { - RedBitClear(pImap->abEntries, ulImapEntry); - } - - RedBufferPut(pImap); - } - } - - return ret; -} - - -/** @brief Branch an imap node and get a buffer for it. - - If the imap node is already branched, it can be overwritten in its current - location, and this function just gets it buffered dirty. If the node is not - already branched, the metaroot must be updated to toggle the imap node to - its alternate location, thereby preserving the committed state copy of the - imap node. - - @param ulImapNode The imap node to branch and buffer. - @param ppImap On successful return, populated with the imap node - buffer, which will be marked dirty. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p ulImapNode is out of range; or @p ppImap is `NULL`. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS ImapNodeBranch( - uint32_t ulImapNode, - IMAPNODE **ppImap) -{ - REDSTATUS ret; - - if((ulImapNode >= gpRedCoreVol->ulImapNodeCount) || (ppImap == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else if(ImapNodeIsBranched(ulImapNode)) - { - /* Imap node is already branched, so just get it buffered dirty. - */ - ret = RedBufferGet(RedImapNodeBlock(gpRedCoreVol->bCurMR, ulImapNode), BFLAG_META_IMAP | BFLAG_DIRTY, CAST_VOID_PTR_PTR(ppImap)); - } - else - { - uint32_t ulBlockCurrent; - uint32_t ulBlockOld; - - /* The metaroot currently points to the committed state imap node. - Toggle the metaroot to point at the alternate, writeable location. - */ - if(RedBitGet(gpRedMR->abEntries, ulImapNode)) - { - RedBitClear(gpRedMR->abEntries, ulImapNode); - } - else - { - RedBitSet(gpRedMR->abEntries, ulImapNode); - } - - ulBlockCurrent = RedImapNodeBlock(gpRedCoreVol->bCurMR, ulImapNode); - ulBlockOld = RedImapNodeBlock(1U - gpRedCoreVol->bCurMR, ulImapNode); - - ret = RedBufferDiscardRange(ulBlockCurrent, 1U); - - /* Buffer the committed copy then reassign the block number to the - writeable location. This also dirties the buffer. - */ - if(ret == 0) - { - ret = RedBufferGet(ulBlockOld, BFLAG_META_IMAP, CAST_VOID_PTR_PTR(ppImap)); - - if(ret == 0) - { - RedBufferBranch(*ppImap, ulBlockCurrent); - } - } - } - - return ret; -} - - -/** @brief Determine whether an imap node is branched. - - If the imap node is branched, it can be overwritten in its current location. - - @param ulImapNode The imap node to examine. - - @return Whether the imap node is branched. -*/ -static bool ImapNodeIsBranched( - uint32_t ulImapNode) -{ - bool fNodeBitSetInMetaroot0 = RedBitGet(gpRedCoreVol->aMR[0U].abEntries, ulImapNode); - bool fNodeBitSetInMetaroot1 = RedBitGet(gpRedCoreVol->aMR[1U].abEntries, ulImapNode); - - /* If the imap node is not branched, both metaroots will point to the same - copy of the node. - */ - return fNodeBitSetInMetaroot0 != fNodeBitSetInMetaroot1; -} -#endif /* REDCONF_READ_ONLY == 0 */ - - -/** @brief Calculate the block number of the imap node location indicated by the - given metaroot. - - An imap node has two locations on disk. A bit in the metaroot bitmap - indicates which location is the valid one, according to that metaroot. This - function returns the block number of the imap node which is valid in the - given metaroot. - - @param bMR Which metaroot to examine. - @param ulImapNode The imap node for which to calculate the block number. - - @return Block number of the imap node, as indicated by the given metaroot. -*/ -uint32_t RedImapNodeBlock( - uint8_t bMR, - uint32_t ulImapNode) -{ - uint32_t ulBlock; - - REDASSERT(ulImapNode < gpRedCoreVol->ulImapNodeCount); - - ulBlock = gpRedCoreVol->ulImapStartBN + (ulImapNode * 2U); - - if(bMR > 1U) - { - REDERROR(); - } - else if(RedBitGet(gpRedCoreVol->aMR[bMR].abEntries, ulImapNode)) - { - /* Bit is set, so point ulBlock at the second copy of the node. - */ - ulBlock++; - } - else - { - /* ulBlock already points at the first copy of the node. - */ - } - - return ulBlock; -} - -#endif /* REDCONF_IMAP_EXTERNAL == 1 */ - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/imapinline.c b/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/imapinline.c deleted file mode 100755 index 5e556ba..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/imapinline.c +++ /dev/null @@ -1,133 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements routines for the inline imap. - - The inline imap is used on volumes that are small enough for the imap bitmap - to be entirely contained within the metaroot. -*/ -#include - -#if REDCONF_IMAP_INLINE == 1 - -#include - - -/** @brief Get the allocation bit of a block from either metaroot. - - @param bMR The metaroot index: either 0 or 1. - @param ulBlock The block number to query. - @param pfAllocated On successful return, populated with the allocation bit - of the block. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bMR is out of range; or @p ulBlock is out of range; - @p pfAllocated is `NULL`; or the current volume does not - use the inline imap. -*/ -REDSTATUS RedImapIBlockGet( - uint8_t bMR, - uint32_t ulBlock, - bool *pfAllocated) -{ - REDSTATUS ret; - - if( (!gpRedCoreVol->fImapInline) - || (bMR > 1U) - || (ulBlock < gpRedCoreVol->ulInodeTableStartBN) - || (ulBlock >= gpRedVolume->ulBlockCount) - || (pfAllocated == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - *pfAllocated = RedBitGet(gpRedCoreVol->aMR[bMR].abEntries, ulBlock - gpRedCoreVol->ulInodeTableStartBN); - ret = 0; - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Set the allocation bit of a block in the working metaroot. - - @param ulBlock The block number to allocate or free. - @param fAllocated Whether to allocate the block (true) or free it (false). - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p ulBlock is out of range; or the current volume does - not use the inline imap. -*/ -REDSTATUS RedImapIBlockSet( - uint32_t ulBlock, - bool fAllocated) -{ - REDSTATUS ret; - - if( (!gpRedCoreVol->fImapInline) - || (ulBlock < gpRedCoreVol->ulInodeTableStartBN) - || (ulBlock >= gpRedVolume->ulBlockCount)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - uint32_t ulOffset = ulBlock - gpRedCoreVol->ulInodeTableStartBN; - - if(RedBitGet(gpRedMR->abEntries, ulOffset) == fAllocated) - { - /* The driver shouldn't ever set a bit in the imap to its current - value. This is more of a problem with the external imap, but it - is checked here for consistency. - */ - CRITICAL_ERROR(); - ret = -RED_EFUBAR; - } - else if(fAllocated) - { - RedBitSet(gpRedMR->abEntries, ulOffset); - ret = 0; - } - else - { - RedBitClear(gpRedMR->abEntries, ulOffset); - ret = 0; - } - } - - return ret; -} -#endif - -#endif /* REDCONF_IMAP_INLINE == 1 */ - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/inode.c b/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/inode.c deleted file mode 100755 index 9ff5341..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/inode.c +++ /dev/null @@ -1,1120 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements inode functions. -*/ -#include -#include - - -#if REDCONF_READ_ONLY == 0 -static REDSTATUS InodeIsBranched(uint32_t ulInode, bool *pfIsBranched); -#endif -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) -static REDSTATUS InodeFindFree(uint32_t *pulInode); -#endif -#if REDCONF_READ_ONLY == 0 -static REDSTATUS InodeGetWriteableCopy(uint32_t ulInode, uint8_t *pbWhich); -#endif -static REDSTATUS InodeGetCurrentCopy(uint32_t ulInode, uint8_t *pbWhich); -#if REDCONF_READ_ONLY == 0 -static REDSTATUS InodeBitSet(uint32_t ulInode, uint8_t bWhich, bool fAllocated); -#endif -static uint32_t InodeBlock(uint32_t ulInode, uint8_t bWhich); - - -/** @brief Mount an existing inode. - - Will populate all fields of the cached inode structure, except those which - are populated during seek. - - @param pInode A pointer to the cached inode structure. The - pInode->ulInode field must already be initialized with the - inode number to mount. All other fields will be discarded. - @param type The expected inode type. - @param fBranch Whether to branch the inode. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL Invalid parameters. - @retval -RED_EROFS @p fBranch is true but the driver is read-only. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EBADF The inode number is free; or the inode number is not - valid. - @retval -RED_EISDIR @p type is ::FTYPE_FILE and the inode is a directory. - @retval -RED_ENOTDIR @p type is ::FTYPE_DIR and the inode is a file. -*/ -REDSTATUS RedInodeMount( - CINODE *pInode, - FTYPE type, - bool fBranch) -{ - REDSTATUS ret = 0; - - if(pInode == NULL) - { - ret = -RED_EINVAL; - } - else if(!INODE_IS_VALID(pInode->ulInode)) - { - ret = -RED_EBADF; - } - #if REDCONF_API_FSE == 1 - else if(type == FTYPE_DIR) - { - REDERROR(); - ret = -RED_EINVAL; - } - #endif - #if REDCONF_READ_ONLY == 1 - else if(fBranch) - { - REDERROR(); - ret = -RED_EROFS; - } - #endif - else - { - uint32_t ulInode = pInode->ulInode; - uint8_t bWhich = 0U; /* Init'd to quiet warnings. */ - - RedMemSet(pInode, 0U, sizeof(*pInode)); - pInode->ulInode = ulInode; - - ret = InodeGetCurrentCopy(pInode->ulInode, &bWhich); - - if(ret == 0) - { - ret = RedBufferGet(InodeBlock(pInode->ulInode, bWhich), BFLAG_META_INODE, CAST_VOID_PTR_PTR(&pInode->pInodeBuf)); - } - - #if REDCONF_READ_ONLY == 0 - if(ret == 0) - { - ret = InodeIsBranched(pInode->ulInode, &pInode->fBranched); - } - #endif - - if(ret == 0) - { - if(RED_S_ISREG(pInode->pInodeBuf->uMode)) - { - #if REDCONF_API_POSIX == 1 - pInode->fDirectory = false; - - if(type == FTYPE_DIR) - { - ret = -RED_ENOTDIR; - } - #endif - } - #if REDCONF_API_POSIX == 1 - else if(RED_S_ISDIR(pInode->pInodeBuf->uMode)) - { - pInode->fDirectory = true; - - if(type == FTYPE_FILE) - { - ret = -RED_EISDIR; - } - } - #endif - else - { - /* Missing or unsupported inode type. - */ - CRITICAL_ERROR(); - ret = -RED_EFUBAR; - } - } - - #if REDCONF_READ_ONLY == 0 - if((ret == 0) && fBranch) - { - ret = RedInodeBranch(pInode); - } - #endif - - if(ret != 0) - { - RedInodePut(pInode, 0U); - } - } - - return ret; -} - - -#if (REDCONF_READ_ONLY == 0) && ((REDCONF_API_POSIX == 1) || FORMAT_SUPPORTED) -/** @brief Create an inode. - - @param pInode Pointer to the cached inode structure. If pInode->ulInode - is #INODE_INVALID, a free inode will be found; otherwise, - pInode->ulInode will be the inode number (an error will be - returned if it is not free). - @param ulPInode The parent inode number. - @param uMode The inode mode. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF pInode->ulInode is an invalid inode number other than - #INODE_INVALID. - @retval -RED_EINVAL Invalid parameters. - @retval -RED_EEXIST Tried to create an inode with an inode number that is - already in use. - @retval -RED_ENFILE All inode slots are already in use. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedInodeCreate( - CINODE *pInode, - uint32_t ulPInode, - uint16_t uMode) -{ - REDSTATUS ret; - - #if REDCONF_API_POSIX == 1 - /* ulPInode must be a valid inode number, unless we are creating the root - directory, in which case ulPInode must be INODE_INVALID (the root - directory has no parent). - */ - if( (pInode == NULL) - || (!INODE_IS_VALID(ulPInode) && ((ulPInode != INODE_INVALID) || (pInode->ulInode != INODE_ROOTDIR)))) - #else - if(pInode == NULL) - #endif - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - uint32_t ulInode = pInode->ulInode; - - RedMemSet(pInode, 0U, sizeof(*pInode)); - - #if REDCONF_API_POSIX == 1 - if(ulInode == INODE_INVALID) - { - /* Caller requested that an inode number be allocated. Search for - an unused inode number, error if there isn't one. - */ - ret = InodeFindFree(&pInode->ulInode); - } - else - #endif - { - /* Caller requested creation of a specific inode number. Make sure - it's valid and doesn't already exist. - */ - if(INODE_IS_VALID(ulInode)) - { - bool fFree; - - ret = RedInodeIsFree(ulInode, &fFree); - if(ret == 0) - { - if(fFree) - { - pInode->ulInode = ulInode; - } - else - { - ret = -RED_EEXIST; - } - } - } - else - { - ret = -RED_EBADF; - } - } - - if(ret == 0) - { - uint8_t bWriteableWhich; - - ret = InodeGetWriteableCopy(pInode->ulInode, &bWriteableWhich); - - if(ret == 0) - { - ret = RedBufferGet(InodeBlock(pInode->ulInode, bWriteableWhich), - (uint16_t)((uint32_t)BFLAG_META_INODE | BFLAG_DIRTY | BFLAG_NEW), CAST_VOID_PTR_PTR(&pInode->pInodeBuf)); - - if(ret == 0) - { - /* Mark the inode block as allocated. - */ - ret = InodeBitSet(pInode->ulInode, bWriteableWhich, true); - - if(ret != 0) - { - RedBufferPut(pInode->pInodeBuf); - } - } - } - } - - if(ret == 0) - { - #if REDCONF_INODE_TIMESTAMPS == 1 - uint32_t ulNow = RedOsClockGetTime(); - - pInode->pInodeBuf->ulATime = ulNow; - pInode->pInodeBuf->ulMTime = ulNow; - pInode->pInodeBuf->ulCTime = ulNow; - #endif - - pInode->pInodeBuf->uMode = uMode; - - #if REDCONF_API_POSIX == 1 - #if REDCONF_API_POSIX_LINK == 1 - pInode->pInodeBuf->uNLink = 1U; - #endif - pInode->pInodeBuf->ulPInode = ulPInode; - #else - (void)ulPInode; - #endif - - pInode->fBranched = true; - pInode->fDirty = true; - - #if REDCONF_API_POSIX == 1 - gpRedMR->ulFreeInodes--; - #endif - } - } - - return ret; -} -#endif /* (REDCONF_READ_ONLY == 0) && ((REDCONF_API_POSIX == 1) || FORMAT_SUPPORTED) */ - - -#if DELETE_SUPPORTED -/** @brief Delete an inode. - - @param pInode Pointer to the cached inode structure. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF The inode is free. - @retval -RED_EINVAL @p pInode is `NULL`; or pInode->pBuffer is `NULL`. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedInodeDelete( - CINODE *pInode) -{ - REDSTATUS ret = 0; - - if(!CINODE_IS_MOUNTED(pInode)) - { - ret = -RED_EINVAL; - } - else - { - if(pInode->pInodeBuf->ullSize != 0U) - { - ret = RedInodeDataTruncate(pInode, UINT64_SUFFIX(0)); - } - - if(ret == 0) - { - ret = RedInodeFree(pInode); - } - } - - return ret; -} - - -/** @brief Decrement an inode link count and delete the inode if the link count - falls to zero. - - @param pInode A pointer to the cached inode structure. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p pInode is not a mounted cachde inode. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedInodeLinkDec( - CINODE *pInode) -{ - REDSTATUS ret; - - if(!CINODE_IS_MOUNTED(pInode)) - { - ret = -RED_EINVAL; - } - #if REDCONF_API_POSIX_LINK == 1 - else if(pInode->pInodeBuf->uNLink > 1U) - { - ret = RedInodeBranch(pInode); - - if(ret == 0) - { - pInode->pInodeBuf->uNLink--; - } - } - #endif - else - { - ret = RedInodeDelete(pInode); - } - - return ret; -} -#endif /* DELETE_SUPPORTED */ - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) -/** @brief Free an inode. - - @param pInode Pointer to the cached inode structure. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF The inode is free. - @retval -RED_EINVAL @p pInode is `NULL`; or pInode->pBuffer is `NULL`. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedInodeFree( - CINODE *pInode) -{ - REDSTATUS ret; - - if(!CINODE_IS_MOUNTED(pInode)) - { - ret = -RED_EINVAL; - } - else - { - bool fSlot0Allocated; - - RedBufferDiscard(pInode->pInodeBuf); - pInode->pInodeBuf = NULL; - - /* Determine which of the two slots for the inode is currently - allocated, and free that slot. - */ - ret = RedInodeBitGet(gpRedCoreVol->bCurMR, pInode->ulInode, 0U, &fSlot0Allocated); - - if(ret == 0) - { - bool fSlot1Allocated; - - ret = RedInodeBitGet(gpRedCoreVol->bCurMR, pInode->ulInode, 1U, &fSlot1Allocated); - - if(ret == 0) - { - if(fSlot0Allocated) - { - if(fSlot1Allocated) - { - /* Both inode slots should never be allocated at - the same time. - */ - CRITICAL_ERROR(); - ret = -RED_EFUBAR; - } - else - { - ret = InodeBitSet(pInode->ulInode, 0U, false); - } - } - else - { - if(!fSlot1Allocated) - { - /* The inode in unallocated, which should have been - caught when it was mounted. - */ - CRITICAL_ERROR(); - ret = -RED_EBADF; - } - else - { - ret = InodeBitSet(pInode->ulInode, 1U, false); - } - } - } - } - - pInode->ulInode = INODE_INVALID; - - if(ret == 0) - { - if(gpRedMR->ulFreeInodes >= gpRedVolConf->ulInodeCount) - { - CRITICAL_ERROR(); - ret = -RED_EFUBAR; - } - else - { - gpRedMR->ulFreeInodes++; - } - } - } - - return ret; -} -#endif /* (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) */ - - -/** @brief Put the cached inode structure. - - This puts all of the buffers in the ::CINODE structure. Also updates inode - timestamp fields if requested. - - @param pInode The cached inode structure. - @param bTimeFields The inode timestamp fields to update. -*/ -void RedInodePut( - CINODE *pInode, - uint8_t bTimeFields) -{ - if(pInode == NULL) - { - REDERROR(); - } - else - { - RedInodePutCoord(pInode); - - if(pInode->pInodeBuf != NULL) - { - #if (REDCONF_READ_ONLY == 0) && (REDCONF_INODE_TIMESTAMPS == 1) - if((bTimeFields & IPUT_UPDATE_MASK) != 0U) - { - if(!pInode->fBranched || !pInode->fDirty) - { - REDERROR(); - } - else - { - uint32_t ulNow = RedOsClockGetTime(); - - #if REDCONF_ATIME == 1 - if((bTimeFields & IPUT_UPDATE_ATIME) != 0U) - { - pInode->pInodeBuf->ulATime = ulNow; - } - #endif - - if((bTimeFields & IPUT_UPDATE_MTIME) != 0U) - { - pInode->pInodeBuf->ulMTime = ulNow; - } - - if((bTimeFields & IPUT_UPDATE_CTIME) != 0U) - { - pInode->pInodeBuf->ulCTime = ulNow; - } - } - } - #else - (void)bTimeFields; - #endif - - RedBufferPut(pInode->pInodeBuf); - pInode->pInodeBuf = NULL; - } - } -} - - -/** @brief Put all buffers in the cached inode structure except for the inode - node buffer. - - @param pInode A pointer to the cached inode structure. -*/ -void RedInodePutCoord( - CINODE *pInode) -{ - if(pInode == NULL) - { - REDERROR(); - } - else - { - RedInodePutData(pInode); - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - RedInodePutIndir(pInode); - #endif - #if DINDIR_POINTERS > 0U - RedInodePutDindir(pInode); - #endif - } -} - - -#if DINDIR_POINTERS > 0U -/** @brief Put the double indirect buffer. - - @param pInode A pointer to the cached inode structure. -*/ -void RedInodePutDindir( - CINODE *pInode) -{ - if(pInode == NULL) - { - REDERROR(); - } - else if(pInode->pDindir != NULL) - { - RedBufferPut(pInode->pDindir); - pInode->pDindir = NULL; - } - else - { - /* No double indirect buffer, nothing to put. - */ - } -} -#endif - - -#if REDCONF_DIRECT_POINTERS < INODE_ENTRIES -/** @brief Put the indirect buffer. - - @param pInode A pointer to the cached inode structure. -*/ -void RedInodePutIndir( - CINODE *pInode) -{ - if(pInode == NULL) - { - REDERROR(); - } - else if(pInode->pIndir != NULL) - { - RedBufferPut(pInode->pIndir); - pInode->pIndir = NULL; - } - else - { - /* No indirect buffer, nothing to put. - */ - } -} -#endif - - -/** @brief Put the inode data buffer. - - @param pInode A pointer to the cached inode structure. -*/ -void RedInodePutData( - CINODE *pInode) -{ - if(pInode == NULL) - { - REDERROR(); - } - else if(pInode->pbData != NULL) - { - RedBufferPut(pInode->pbData); - pInode->pbData = NULL; - } - else - { - /* No data buffer, nothing to put. - */ - } -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Determine if an inode is branched. - - @param ulInode The inode number to examine. - @param pfIsBranched On successful return, populated with whether the inode - is branched. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p pInode is `NULL`; or @p ulInode is not a valid inode - number. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS InodeIsBranched( - uint32_t ulInode, - bool *pfIsBranched) -{ - REDSTATUS ret; - - if(!INODE_IS_VALID(ulInode) || (pfIsBranched == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - ALLOCSTATE state; - - ret = RedImapBlockState(InodeBlock(ulInode, 0U), &state); - - if(ret == 0) - { - if(state == ALLOCSTATE_NEW) - { - *pfIsBranched = true; - } - else - { - ret = RedImapBlockState(InodeBlock(ulInode, 1U), &state); - - if(ret == 0) - { - if(state == ALLOCSTATE_NEW) - { - *pfIsBranched = true; - } - else - { - *pfIsBranched = false; - } - } - } - } - } - - return ret; -} - - -/** @brief Branch an inode. - - A branched inode is one in which the allocation state for one copy is free - or almost free, and the other copy is in the new state. The copy which is - in the new state is the writeable copy, which is also buffered and dirty. - - @param pInode Pointer to the cached inode structure which has already been - mounted. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL Invalid parameters. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedInodeBranch( - CINODE *pInode) -{ - REDSTATUS ret; - - if(!CINODE_IS_MOUNTED(pInode)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else if(!pInode->fBranched) - { - uint8_t bWhich; - - ret = InodeGetWriteableCopy(pInode->ulInode, &bWhich); - - if(ret == 0) - { - RedBufferBranch(pInode->pInodeBuf, InodeBlock(pInode->ulInode, bWhich)); - pInode->fBranched = true; - pInode->fDirty = true; - } - - /* Toggle the inode slots: the old slot block becomes almost free - (still used by the committed state) and the new slot block becomes - new. - */ - if(ret == 0) - { - ret = InodeBitSet(pInode->ulInode, 1U - bWhich, false); - } - - if(ret == 0) - { - ret = InodeBitSet(pInode->ulInode, bWhich, true); - } - - CRITICAL_ASSERT(ret == 0); - } - else - { - RedBufferDirty(pInode->pInodeBuf); - pInode->fDirty = true; - ret = 0; - } - - return ret; -} -#endif /* REDCONF_READ_ONLY == 0 */ - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) -/** @brief Find a free inode number. - - @param pulInode On successful return, populated with a free inode number. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p pulInode is `NULL`. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENFILE No available inode numbers. -*/ -static REDSTATUS InodeFindFree( - uint32_t *pulInode) -{ - REDSTATUS ret; - - if(pulInode == NULL) - { - REDERROR(); - ret = -RED_EINVAL; - } - else if(gpRedMR->ulFreeInodes == 0U) - { - ret = -RED_ENFILE; - } - else - { - uint32_t ulInode; - - ret = 0; - - for(ulInode = INODE_FIRST_FREE; ulInode < (INODE_FIRST_VALID + gpRedVolConf->ulInodeCount); ulInode++) - { - bool fFree; - - ret = RedInodeIsFree(ulInode, &fFree); - - if((ret != 0) || fFree) - { - break; - } - } - - if(ret == 0) - { - if(ulInode < (INODE_FIRST_VALID + gpRedVolConf->ulInodeCount)) - { - *pulInode = ulInode; - } - else - { - /* If gpRedMR->ulFreeInodes > 0, we should have found an inode. - */ - CRITICAL_ERROR(); - ret = -RED_ENFILE; - } - } - } - - return ret; -} -#endif - - -#if ((REDCONF_READ_ONLY == 0) && ((REDCONF_API_POSIX == 1) || FORMAT_SUPPORTED)) || (REDCONF_CHECKER == 1) -/** @brief Determine whether an inode number is available. - - @param ulInode The node number to examine. - @param pfFree On successful return, populated with whether the inode - number is available (true) or in use (false). - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p pfFree is `NULL`; or @p ulInode is not a valid inode - number. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedInodeIsFree( - uint32_t ulInode, - bool *pfFree) -{ - REDSTATUS ret; - - if(pfFree == NULL) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - bool fSlot0Allocated; - - *pfFree = false; - - ret = RedInodeBitGet(gpRedCoreVol->bCurMR, ulInode, 0U, &fSlot0Allocated); - if((ret == 0) && !fSlot0Allocated) - { - bool fSlot1Allocated; - - ret = RedInodeBitGet(gpRedCoreVol->bCurMR, ulInode, 1U, &fSlot1Allocated); - if((ret == 0) && !fSlot1Allocated) - { - *pfFree = true; - } - } - } - - return ret; -} -#endif - - -#if REDCONF_READ_ONLY == 0 -/** @brief Determine which copy of the inode is currently writeable. - - @param ulInode The inode number to examine. - @param pbWhich On successful return, populated with which copy of the inode - (either 0 or 1) is writeable. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p pbWhich is `NULL`; or ulInode is not a valid inode - number. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS InodeGetWriteableCopy( - uint32_t ulInode, - uint8_t *pbWhich) -{ - REDSTATUS ret; - - if(pbWhich == NULL) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - bool fSlot0Allocated; - - /* The writeable inode slot is the one which is free in the committed - state, so query the committed state metaroot. - */ - ret = RedInodeBitGet(1U - gpRedCoreVol->bCurMR, ulInode, 0U, &fSlot0Allocated); - - if(ret == 0) - { - if(!fSlot0Allocated) - { - *pbWhich = 0U; - } - else - { - bool fSlot1Allocated; - - ret = RedInodeBitGet(1U - gpRedCoreVol->bCurMR, ulInode, 1U, &fSlot1Allocated); - - if(ret == 0) - { - if(!fSlot1Allocated) - { - *pbWhich = 1U; - } - else - { - /* Both inode slots were allocated, which should never - happen. - */ - CRITICAL_ERROR(); - ret = -RED_EFUBAR; - } - } - } - } - } - - return ret; -} -#endif - - -/** @brief Determine which copy of the inode is current. - - @param ulInode The inode number to examine. - @param pbWhich On successful return, populated with which copy of the inode - (either 0 or 1) is current. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulInode is an unallocated inode number. - @retval -RED_EINVAL @p pbWhich is `NULL`; or ulInode is not a valid inode - number. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS InodeGetCurrentCopy( - uint32_t ulInode, - uint8_t *pbWhich) -{ - REDSTATUS ret; - - if(pbWhich == NULL) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - bool fSlot0Allocated; - - /* The current inode slot is the one which is allocated in the working - state metaroot. - */ - ret = RedInodeBitGet(gpRedCoreVol->bCurMR, ulInode, 0U, &fSlot0Allocated); - if(ret == 0) - { - if(fSlot0Allocated) - { - *pbWhich = 0U; - } - else - { - bool fSlot1Allocated; - - ret = RedInodeBitGet(gpRedCoreVol->bCurMR, ulInode, 1U, &fSlot1Allocated); - if(ret == 0) - { - if(fSlot1Allocated) - { - *pbWhich = 1U; - } - else - { - /* Neither slot for this inode was allocated, so the - inode is actually free. - */ - ret = -RED_EBADF; - } - } - } - } - } - - return ret; -} - - -/** @brief Get whether a copy of an inode is allocated. - - @param bMR The metaroot index: either 0 or 1. - @param ulInode The inode number. - @param bWhich Which copy of the inode to get. - @param pfAllocated On successful return, populated with whether the given - copy of the inode is allocated. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bMR is not 1 or 0; @p ulInode is not a valid inode - number; or @p bWhich is not 1 or 0; or @p pfAllocated is - `NULL`. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedInodeBitGet( - uint8_t bMR, - uint32_t ulInode, - uint8_t bWhich, - bool *pfAllocated) -{ - REDSTATUS ret; - - if(!INODE_IS_VALID(ulInode) || (bWhich > 1U)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - ret = RedImapBlockGet(bMR, InodeBlock(ulInode, bWhich), pfAllocated); - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Set whether a copy of an inode is allocated. - - @param ulInode The inode number. - @param bWhich Which copy of the inode to set. - @param fAllocated If true, the inode is set to allocated; if false, the - inode is set to free. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p ulInode is not a valid inode number; or @p bWhich is - not 1 or 0. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS InodeBitSet( - uint32_t ulInode, - uint8_t bWhich, - bool fAllocated) -{ - REDSTATUS ret; - - if(!INODE_IS_VALID(ulInode) || (bWhich > 1U)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - ret = RedImapBlockSet(InodeBlock(ulInode, bWhich), fAllocated); - } - - return ret; -} -#endif - - -/** @brief Determine the block number of an inode. - - @param ulInode The inode number. - @param bWhich Which copy of the inode. - - @return The block number of the inode. -*/ -static uint32_t InodeBlock( - uint32_t ulInode, - uint8_t bWhich) -{ - REDASSERT(INODE_IS_VALID(ulInode)); - REDASSERT(bWhich <= 1U); - - return gpRedCoreVol->ulInodeTableStartBN + ((ulInode - INODE_FIRST_VALID) * 2U) + bWhich; -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/inodedata.c b/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/inodedata.c deleted file mode 100755 index a5b9762..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/inodedata.c +++ /dev/null @@ -1,1917 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements inode I/O functions. -*/ -#include -#include - - -/* This value is used to initialize the uIndirEntry and uDindirEntry members of - the CINODE structure. After seeking, a value of COORD_ENTRY_INVALID in - uIndirEntry indicates that there is no indirect node in the path through the - file metadata structure, and a value of COORD_ENTRY_INVALID in uDindirEntry - indicates that there is no double indirect node. -*/ -#define COORD_ENTRY_INVALID (UINT16_MAX) - -/* This enumeration is used by the BranchBlock() and BranchBlockCost() - functions to determine which blocks of the file metadata structure need to - be branched, and which to ignore. DINDIR requires requires branching the - double indirect only, INDIR requires branching the double indirect - (if present) and the indirect, and FILE_DATA requires branching the indirect - and double indirect (if present) and the file data block. -*/ -typedef enum -{ - BRANCHDEPTH_DINDIR = 0U, - BRANCHDEPTH_INDIR = 1U, - BRANCHDEPTH_FILE_DATA = 2U, - BRANCHDEPTH_MAX = BRANCHDEPTH_FILE_DATA -} BRANCHDEPTH; - - -#if REDCONF_READ_ONLY == 0 -#if DELETE_SUPPORTED || TRUNCATE_SUPPORTED -static REDSTATUS Shrink(CINODE *pInode, uint64_t ullSize); -#if DINDIR_POINTERS > 0U -static REDSTATUS TruncDindir(CINODE *pInode, bool *pfFreed); -#endif -#if REDCONF_DIRECT_POINTERS < INODE_ENTRIES -static REDSTATUS TruncIndir(CINODE *pInode, bool *pfFreed); -#endif -static REDSTATUS TruncDataBlock(const CINODE *pInode, uint32_t *pulBlock, bool fPropagate); -#endif -static REDSTATUS ExpandPrepare(CINODE *pInode); -#endif -static void SeekCoord(CINODE *pInode, uint32_t ulBlock); -static REDSTATUS ReadUnaligned(CINODE *pInode, uint64_t ullStart, uint32_t ulLen, uint8_t *pbBuffer); -static REDSTATUS ReadAligned(CINODE *pInode, uint32_t ulBlockStart, uint32_t ulBlockCount, uint8_t *pbBuffer); -#if REDCONF_READ_ONLY == 0 -static REDSTATUS WriteUnaligned(CINODE *pInode, uint64_t ullStart, uint32_t ulLen, const uint8_t *pbBuffer); -static REDSTATUS WriteAligned(CINODE *pInode, uint32_t ulBlockStart, uint32_t *pulBlockCount, const uint8_t *pbBuffer); -#endif -static REDSTATUS GetExtent(CINODE *pInode, uint32_t ulBlockStart, uint32_t *pulExtentStart, uint32_t *pulExtentLen); -#if REDCONF_READ_ONLY == 0 -static REDSTATUS BranchBlock(CINODE *pInode, BRANCHDEPTH depth, bool fBuffer); -static REDSTATUS BranchOneBlock(uint32_t *pulBlock, void **ppBuffer, uint16_t uBFlag); -static REDSTATUS BranchBlockCost(const CINODE *pInode, BRANCHDEPTH depth, uint32_t *pulCost); -static uint32_t FreeBlockCount(void); -#endif - - -/** @brief Read data from an inode. - - @param pInode A pointer to the cached inode structure of the inode from - which to read. - @param ullStart The file offset at which to read. - @param pulLen On input, the number of bytes to attempt to read. On - successful return, populated with the number of bytes - actually read. - @param pBuffer The buffer to read into. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EINVAL @p pInode is not a mounted cached inode pointer; or - @p pulLen is `NULL`; or @p pBuffer is `NULL`. -*/ -REDSTATUS RedInodeDataRead( - CINODE *pInode, - uint64_t ullStart, - uint32_t *pulLen, - void *pBuffer) -{ - REDSTATUS ret = 0; - - if(!CINODE_IS_MOUNTED(pInode) || (pulLen == NULL) || (pBuffer == NULL)) - { - ret = -RED_EINVAL; - } - else if(ullStart >= pInode->pInodeBuf->ullSize) - { - *pulLen = 0U; - } - else if(*pulLen == 0U) - { - /* Do nothing, just return success. - */ - } - else - { - uint8_t *pbBuffer = CAST_VOID_PTR_TO_UINT8_PTR(pBuffer); - uint32_t ulReadIndex = 0U; - uint32_t ulLen = *pulLen; - uint32_t ulRemaining; - - /* Reading beyond the end of the file is not allowed. If the requested - read extends beyond the end of the file, truncate the read length so - that the read stops at the end of the file. - */ - if((pInode->pInodeBuf->ullSize - ullStart) < ulLen) - { - ulLen = (uint32_t)(pInode->pInodeBuf->ullSize - ullStart); - } - - ulRemaining = ulLen; - - /* Unaligned partial block at start. - */ - if((ullStart & (REDCONF_BLOCK_SIZE - 1U)) != 0U) - { - uint32_t ulBytesInFirstBlock = REDCONF_BLOCK_SIZE - (uint32_t)(ullStart & (REDCONF_BLOCK_SIZE - 1U)); - uint32_t ulThisRead = REDMIN(ulRemaining, ulBytesInFirstBlock); - - ret = ReadUnaligned(pInode, ullStart, ulThisRead, pbBuffer); - - if(ret == 0) - { - ulReadIndex += ulThisRead; - ulRemaining -= ulThisRead; - } - } - - /* Whole blocks. - */ - if((ret == 0) && (ulRemaining >= REDCONF_BLOCK_SIZE)) - { - uint32_t ulBlockOffset = (uint32_t)((ullStart + ulReadIndex) >> BLOCK_SIZE_P2); - uint32_t ulBlockCount = ulRemaining >> BLOCK_SIZE_P2; - - REDASSERT(((ullStart + ulReadIndex) & (REDCONF_BLOCK_SIZE - 1U)) == 0U); - - ret = ReadAligned(pInode, ulBlockOffset, ulBlockCount, &pbBuffer[ulReadIndex]); - - if(ret == 0) - { - ulReadIndex += ulBlockCount << BLOCK_SIZE_P2; - ulRemaining -= ulBlockCount << BLOCK_SIZE_P2; - } - } - - /* Aligned partial block at end. - */ - if((ret == 0) && (ulRemaining > 0U)) - { - REDASSERT(ulRemaining < REDCONF_BLOCK_SIZE); - REDASSERT(((ullStart + ulReadIndex) & (REDCONF_BLOCK_SIZE - 1U)) == 0U); - - ret = ReadUnaligned(pInode, ullStart + ulReadIndex, ulRemaining, &pbBuffer[ulReadIndex]); - } - - if(ret == 0) - { - *pulLen = ulLen; - } - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Write to an inode. - - @param pInode A pointer to the cached inode structure of the inode into - which to write. - @param ullStart The file offset at which to write. - @param pulLen On input, the number of bytes to attempt to write. On - successful return, populated with the number of bytes - actually written. - @param pBuffer The buffer to write from. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EFBIG @p ullStart is greater than the maximum file size; or - @p ullStart is equal to the maximum file size and the - write length is non-zero. - @retval -RED_EINVAL @p pInode is not a mounted cached inode pointer; or - @p pulLen is `NULL`; or @p pBuffer is `NULL`. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC No data can be written because there is insufficient - free space. -*/ -REDSTATUS RedInodeDataWrite( - CINODE *pInode, - uint64_t ullStart, - uint32_t *pulLen, - const void *pBuffer) -{ - REDSTATUS ret = 0; - - if(!CINODE_IS_DIRTY(pInode) || (pulLen == NULL) || (pBuffer == NULL)) - { - ret = -RED_EINVAL; - } - else if((ullStart > INODE_SIZE_MAX) || ((ullStart == INODE_SIZE_MAX) && (*pulLen > 0U))) - { - ret = -RED_EFBIG; - } - else if(*pulLen == 0U) - { - /* Do nothing, just return success. - */ - } - else - { - const uint8_t *pbBuffer = CAST_VOID_PTR_TO_CONST_UINT8_PTR(pBuffer); - uint32_t ulWriteIndex = 0U; - uint32_t ulLen = *pulLen; - uint32_t ulRemaining; - - if((INODE_SIZE_MAX - ullStart) < ulLen) - { - ulLen = (uint32_t)(INODE_SIZE_MAX - ullStart); - } - - ulRemaining = ulLen; - - /* If the write is beyond the current end of the file, and the current - end of the file is not block-aligned, then there may be some data - that needs to be zeroed in the last block. - */ - if(ullStart > pInode->pInodeBuf->ullSize) - { - ret = ExpandPrepare(pInode); - } - - /* Partial block at start. - */ - if((ret == 0) && (((ullStart & (REDCONF_BLOCK_SIZE - 1U)) != 0U) || (ulRemaining < REDCONF_BLOCK_SIZE))) - { - uint32_t ulBytesInFirstBlock = REDCONF_BLOCK_SIZE - (uint32_t)(ullStart & (REDCONF_BLOCK_SIZE - 1U)); - uint32_t ulThisWrite = REDMIN(ulRemaining, ulBytesInFirstBlock); - - ret = WriteUnaligned(pInode, ullStart, ulThisWrite, pbBuffer); - - if(ret == 0) - { - ulWriteIndex += ulThisWrite; - ulRemaining -= ulThisWrite; - } - } - - /* Whole blocks. - */ - if((ret == 0) && (ulRemaining >= REDCONF_BLOCK_SIZE)) - { - uint32_t ulBlockOffset = (uint32_t)((ullStart + ulWriteIndex) >> BLOCK_SIZE_P2); - uint32_t ulBlockCount = ulRemaining >> BLOCK_SIZE_P2; - uint32_t ulBlocksWritten = ulBlockCount; - - REDASSERT(((ullStart + ulWriteIndex) & (REDCONF_BLOCK_SIZE - 1U)) == 0U); - - ret = WriteAligned(pInode, ulBlockOffset, &ulBlocksWritten, &pbBuffer[ulWriteIndex]); - - if((ret == -RED_ENOSPC) && (ulWriteIndex > 0U)) - { - ulBlocksWritten = 0U; - ret = 0; - } - - if(ret == 0) - { - ulWriteIndex += ulBlocksWritten << BLOCK_SIZE_P2; - ulRemaining -= ulBlocksWritten << BLOCK_SIZE_P2; - - if(ulBlocksWritten < ulBlockCount) - { - ulRemaining = 0U; - } - } - } - - /* Partial block at end. - */ - if((ret == 0) && (ulRemaining > 0U)) - { - REDASSERT(ulRemaining < REDCONF_BLOCK_SIZE); - REDASSERT(((ullStart + ulWriteIndex) & (REDCONF_BLOCK_SIZE - 1U)) == 0U); - REDASSERT(ulWriteIndex > 0U); - - ret = WriteUnaligned(pInode, ullStart + ulWriteIndex, ulRemaining, &pbBuffer[ulWriteIndex]); - - if(ret == -RED_ENOSPC) - { - ret = 0; - } - else if(ret == 0) - { - ulWriteIndex += ulRemaining; - - REDASSERT(ulWriteIndex == ulLen); - } - else - { - /* Unexpected error, return it. - */ - } - } - - if(ret == 0) - { - *pulLen = ulWriteIndex; - - if((ullStart + ulWriteIndex) > pInode->pInodeBuf->ullSize) - { - pInode->pInodeBuf->ullSize = ullStart + ulWriteIndex; - } - } - } - - return ret; -} - - -#if DELETE_SUPPORTED || TRUNCATE_SUPPORTED -/** @brief Change the size of an inode. - - @param pInode A pointer to the cached inode structure. - @praam ullSize The new file size for the inode. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EFBIG @p ullSize is greater than the maximum file size. - @retval -RED_EINVAL @p pInode is not a mounted cached inode pointer. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC Insufficient free space to perform the truncate. -*/ -REDSTATUS RedInodeDataTruncate( - CINODE *pInode, - uint64_t ullSize) -{ - REDSTATUS ret = 0; - - /* The inode does not need to be dirtied when it is being deleted, because - the inode buffer will be discarded without ever being written to disk. - Thus, we only check to see if it's mounted here. - */ - if(!CINODE_IS_MOUNTED(pInode)) - { - ret = -RED_EINVAL; - } - else if(ullSize > INODE_SIZE_MAX) - { - ret = -RED_EFBIG; - } - else - { - if(ullSize > pInode->pInodeBuf->ullSize) - { - ret = ExpandPrepare(pInode); - } - else if(ullSize < pInode->pInodeBuf->ullSize) - { - ret = Shrink(pInode, ullSize); - } - else - { - /* Size is staying the same, nothing to do. - */ - } - - if(ret == 0) - { - pInode->pInodeBuf->ullSize = ullSize; - } - } - - return ret; -} - - -/** @brief Free all file data beyond a specified point. - - @param pInode A pointer to the cached inode structure. - @param ullSize The point beyond which to free all file data. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC Insufficient free space to perform the truncate. - @retval -RED_EINVAL Invalid parameters. -*/ -static REDSTATUS Shrink( - CINODE *pInode, - uint64_t ullSize) -{ - REDSTATUS ret = 0; - - /* pInode->fDirty is checked explicitly here, instead of using the - CINODE_IS_DIRTY() macro, to avoid a duplicate mount check. - */ - if(!CINODE_IS_MOUNTED(pInode) || ((ullSize > 0U) && !pInode->fDirty)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - uint32_t ulTruncBlock = (uint32_t)((ullSize + REDCONF_BLOCK_SIZE - 1U) >> BLOCK_SIZE_P2); - - RedInodePutData(pInode); - - #if REDCONF_DIRECT_POINTERS > 0U - while(ulTruncBlock < REDCONF_DIRECT_POINTERS) - { - ret = TruncDataBlock(pInode, &pInode->pInodeBuf->aulEntries[ulTruncBlock], true); - - if(ret != 0) - { - break; - } - - ulTruncBlock++; - } - #endif - - #if REDCONF_INDIRECT_POINTERS > 0U - while((ret == 0) && (ulTruncBlock < (REDCONF_DIRECT_POINTERS + INODE_INDIR_BLOCKS))) - { - ret = RedInodeDataSeek(pInode, ulTruncBlock); - - if((ret == 0) || (ret == -RED_ENODATA)) - { - bool fFreed; - - ret = TruncIndir(pInode, &fFreed); - - if(ret == 0) - { - if(fFreed) - { - pInode->pInodeBuf->aulEntries[pInode->uInodeEntry] = BLOCK_SPARSE; - } - - /* The next seek will go to the beginning of the next - indirect. - */ - ulTruncBlock += (INDIR_ENTRIES - pInode->uIndirEntry); - } - } - } - #endif - - #if DINDIR_POINTERS > 0U - while((ret == 0) && (ulTruncBlock < INODE_DATA_BLOCKS)) - { - ret = RedInodeDataSeek(pInode, ulTruncBlock); - - if((ret == 0) || (ret == -RED_ENODATA)) - { - bool fFreed; - - /* TruncDindir() invokes seek as it goes along, which will - update the entry values (possibly all three of these); - make a copy so we can compute things correctly after. - */ - uint16_t uOrigInodeEntry = pInode->uInodeEntry; - uint16_t uOrigDindirEntry = pInode->uDindirEntry; - uint16_t uOrigIndirEntry = pInode->uIndirEntry; - - ret = TruncDindir(pInode, &fFreed); - - if(ret == 0) - { - if(fFreed) - { - pInode->pInodeBuf->aulEntries[uOrigInodeEntry] = BLOCK_SPARSE; - } - - /* The next seek will go to the beginning of the next - double indirect. - */ - ulTruncBlock += (DINDIR_DATA_BLOCKS - (uOrigDindirEntry * INDIR_ENTRIES)) - uOrigIndirEntry; - } - } - } - #endif - } - - return ret; -} - - -#if DINDIR_POINTERS > 0U -/** @brief Truncate a double indirect. - - @param pInode A pointer to the cached inode, whose coordinates indicate - the truncation boundary. - @param pfFreed On successful return, populated with whether the double - indirect node was freed. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC Insufficient free space to perform the truncate. - @retval -RED_EINVAL Invalid parameters. -*/ -static REDSTATUS TruncDindir( - CINODE *pInode, - bool *pfFreed) -{ - REDSTATUS ret = 0; - - if(!CINODE_IS_MOUNTED(pInode) || (pfFreed == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else if(pInode->pDindir == NULL) - { - *pfFreed = false; - } - else - { - bool fBranch = false; - uint16_t uEntry; - - /* The double indirect is definitely going to be branched (instead of - deleted) if any of its indirect pointers which are entirely prior to - the truncation boundary are non-sparse. - */ - for(uEntry = 0U; !fBranch && (uEntry < pInode->uDindirEntry); uEntry++) - { - fBranch = pInode->pDindir->aulEntries[uEntry] != BLOCK_SPARSE; - } - - /* Unless we already know for a fact that the double indirect is going - to be branched, examine the contents of the indirect pointer which - straddles the truncation boundary. If the indirect is going to be - deleted, we know this indirect pointer is going away, and that might - mean the double indirect is going to be deleted also. - */ - if(!fBranch && (pInode->pDindir->aulEntries[pInode->uDindirEntry] != BLOCK_SPARSE)) - { - for(uEntry = 0U; !fBranch && (uEntry < pInode->uIndirEntry); uEntry++) - { - fBranch = pInode->pIndir->aulEntries[uEntry] != BLOCK_SPARSE; - } - } - - if(fBranch) - { - ret = BranchBlock(pInode, BRANCHDEPTH_DINDIR, false); - } - - if(ret == 0) - { - uint32_t ulBlock = pInode->ulLogicalBlock; - uint16_t uStart = pInode->uDindirEntry; /* pInode->uDindirEntry will change. */ - - for(uEntry = uStart; uEntry < INDIR_ENTRIES; uEntry++) - { - /* Seek so that TruncIndir() has the correct indirect - buffer and indirect entry. - */ - ret = RedInodeDataSeek(pInode, ulBlock); - - if(ret == -RED_ENODATA) - { - ret = 0; - } - - if((ret == 0) && (pInode->ulIndirBlock != BLOCK_SPARSE)) - { - bool fIndirFreed; - - ret = TruncIndir(pInode, &fIndirFreed); - - if(ret == 0) - { - /* All of the indirects after the one which straddles - the truncation boundary should definitely end up - deleted. - */ - REDASSERT((uEntry == uStart) || fIndirFreed); - - /* If the double indirect is being freed, all of the - indirects should be freed too. - */ - REDASSERT(fIndirFreed || fBranch); - - if(fBranch && fIndirFreed) - { - pInode->pDindir->aulEntries[uEntry] = BLOCK_SPARSE; - } - } - } - - if(ret != 0) - { - break; - } - - ulBlock += (INDIR_ENTRIES - pInode->uIndirEntry); - } - - if(ret == 0) - { - *pfFreed = !fBranch; - - if(!fBranch) - { - RedInodePutDindir(pInode); - - ret = RedImapBlockSet(pInode->ulDindirBlock, false); - } - } - } - } - - return ret; -} -#endif /* DINDIR_POINTERS > 0U */ - - -#if REDCONF_DIRECT_POINTERS < INODE_ENTRIES -/** @brief Truncate a indirect. - - @param pInode A pointer to the cached inode, whose coordinates indicate - the truncation boundary. - @param pfFreed On successful return, populated with whether the indirect - node was freed. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC Insufficient free space to perform the truncate. - @retval -RED_EINVAL Invalid parameters. -*/ -static REDSTATUS TruncIndir( - CINODE *pInode, - bool *pfFreed) -{ - REDSTATUS ret = 0; - - if(!CINODE_IS_MOUNTED(pInode) || (pfFreed == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else if(pInode->pIndir == NULL) - { - *pfFreed = false; - } - else - { - bool fBranch = false; - uint16_t uEntry; - - /* Scan the range of entries which are not being truncated. If there - is anything there, then the indirect will not be empty after the - truncate, so it is branched and modified instead of deleted. - */ - for(uEntry = 0U; !fBranch && (uEntry < pInode->uIndirEntry); uEntry++) - { - fBranch = pInode->pIndir->aulEntries[uEntry] != BLOCK_SPARSE; - } - - if(fBranch) - { - ret = BranchBlock(pInode, BRANCHDEPTH_INDIR, false); - } - - if(ret == 0) - { - for(uEntry = pInode->uIndirEntry; uEntry < INDIR_ENTRIES; uEntry++) - { - ret = TruncDataBlock(pInode, &pInode->pIndir->aulEntries[uEntry], fBranch); - - if(ret != 0) - { - break; - } - } - - if(ret == 0) - { - *pfFreed = !fBranch; - - if(!fBranch) - { - RedInodePutIndir(pInode); - - ret = RedImapBlockSet(pInode->ulIndirBlock, false); - } - } - } - } - - return ret; -} -#endif /* REDCONF_DIRECT_POINTERS < INODE_ENTRIES */ - - -/** @brief Truncate a file data block. - - @param pInode A pointer to the cached inode structure. - @param pulBlock On entry, contains the block to be truncated. On - successful return, if @p fPropagate is true, populated - with BLOCK_SPARSE, otherwise unmodified. - @param fPropagate Whether the parent node is being branched. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EINVAL Invalid parameters. -*/ -static REDSTATUS TruncDataBlock( - const CINODE *pInode, - uint32_t *pulBlock, - bool fPropagate) -{ - REDSTATUS ret = 0; - - if(!CINODE_IS_MOUNTED(pInode) || (pulBlock == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else if(*pulBlock != BLOCK_SPARSE) - { - ret = RedImapBlockSet(*pulBlock, false); - - #if REDCONF_INODE_BLOCKS == 1 - if(ret == 0) - { - if(pInode->pInodeBuf->ulBlocks == 0U) - { - CRITICAL_ERROR(); - ret = -RED_EFUBAR; - } - else - { - pInode->pInodeBuf->ulBlocks--; - } - } - #endif - - if((ret == 0) && fPropagate) - { - *pulBlock = BLOCK_SPARSE; - } - } - else - { - /* Data block is sparse, nothing to truncate. - */ - } - - return ret; -} -#endif /* DELETE_SUPPORTED || TRUNCATE_SUPPORTED */ - - -/** @brief Prepare to increase the file size. - - When the inode size is increased, a sparse region is created. It is - possible that a prior shrink operation to an unaligned size left stale data - beyond the end of the file in the last data block. That data is not zeroed - while shrinking the inode in order to transfer the disk full burden from the - shrink operation to the expand operation. - - @param pInode A pointer to the cached inode structure. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC Insufficient free space to perform the truncate. - @retval -RED_EINVAL Invalid parameters. -*/ -static REDSTATUS ExpandPrepare( - CINODE *pInode) -{ - REDSTATUS ret = 0; - - if(!CINODE_IS_DIRTY(pInode)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - uint32_t ulOldSizeByteInBlock = (uint32_t)(pInode->pInodeBuf->ullSize & (REDCONF_BLOCK_SIZE - 1U)); - - if(ulOldSizeByteInBlock != 0U) - { - ret = RedInodeDataSeek(pInode, (uint32_t)(pInode->pInodeBuf->ullSize >> BLOCK_SIZE_P2)); - - if(ret == -RED_ENODATA) - { - ret = 0; - } - else if(ret == 0) - { - ret = BranchBlock(pInode, BRANCHDEPTH_FILE_DATA, true); - - if(ret == 0) - { - RedMemSet(&pInode->pbData[ulOldSizeByteInBlock], 0U, REDCONF_BLOCK_SIZE - ulOldSizeByteInBlock); - } - } - else - { - REDERROR(); - } - } - } - - return ret; -} -#endif /* REDCONF_READ_ONLY == 0 */ - - -/** @brief Seek to a given position within an inode, then buffer the data block. - - On successful return, pInode->pbData will be populated with a buffer - corresponding to the @p ulBlock block offset. - - @param pInode A pointer to the cached inode structure. - @param ulBlock The block offset to seek to and buffer. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_ENODATA The block offset is sparse. - @retval -RED_EINVAL @p ulBlock is too large. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedInodeDataSeekAndRead( - CINODE *pInode, - uint32_t ulBlock) -{ - REDSTATUS ret; - - ret = RedInodeDataSeek(pInode, ulBlock); - - if((ret == 0) && (pInode->pbData == NULL)) - { - REDASSERT(pInode->ulDataBlock != BLOCK_SPARSE); - - ret = RedBufferGet(pInode->ulDataBlock, 0U, CAST_VOID_PTR_PTR(&pInode->pbData)); - } - - return ret; -} - - -/** @brief Seek to a given position within an inode. - - On successful return, pInode->ulDataBlock will be populated with the - physical block number corresponding to the @p ulBlock block offset. - - Note: Callers of this function depend on its parameter checking. - - @param pInode A pointer to the cached inode structure. - @param ulBlock The block offset to seek to. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_ENODATA The block offset is sparse. - @retval -RED_EINVAL @p ulBlock is too large; or @p pInode is not a - mounted cached inode pointer. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedInodeDataSeek( - CINODE *pInode, - uint32_t ulBlock) -{ - REDSTATUS ret = 0; - - if(!CINODE_IS_MOUNTED(pInode) || (ulBlock >= INODE_DATA_BLOCKS)) - { - ret = -RED_EINVAL; - } - else - { - SeekCoord(pInode, ulBlock); - - #if DINDIR_POINTERS > 0U - if(pInode->uDindirEntry != COORD_ENTRY_INVALID) - { - if(pInode->ulDindirBlock == BLOCK_SPARSE) - { - /* If the double indirect is unallocated, so is the indirect. - */ - pInode->ulIndirBlock = BLOCK_SPARSE; - } - else - { - if(pInode->pDindir == NULL) - { - ret = RedBufferGet(pInode->ulDindirBlock, BFLAG_META_DINDIR, CAST_VOID_PTR_PTR(&pInode->pDindir)); - } - - if(ret == 0) - { - pInode->ulIndirBlock = pInode->pDindir->aulEntries[pInode->uDindirEntry]; - } - } - } - #endif - - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - if((ret == 0) && (pInode->uIndirEntry != COORD_ENTRY_INVALID)) - { - if(pInode->ulIndirBlock == BLOCK_SPARSE) - { - /* If the indirect is unallocated, so is the data block. - */ - pInode->ulDataBlock = BLOCK_SPARSE; - } - else - { - if(pInode->pIndir == NULL) - { - ret = RedBufferGet(pInode->ulIndirBlock, BFLAG_META_INDIR, CAST_VOID_PTR_PTR(&pInode->pIndir)); - } - - if(ret == 0) - { - pInode->ulDataBlock = pInode->pIndir->aulEntries[pInode->uIndirEntry]; - } - } - } - #endif - - if((ret == 0) && (pInode->ulDataBlock == BLOCK_SPARSE)) - { - ret = -RED_ENODATA; - } - } - - return ret; -} - - -/** @brief Seek to the coordinates. - - Compute the new coordinates, and put any buffers which are not needed or are - no longer appropriate. - - @param pInode A pointer to the cached inode structure. - @param ulBlock The block offset to seek to. -*/ -static void SeekCoord( - CINODE *pInode, - uint32_t ulBlock) -{ - if(!CINODE_IS_MOUNTED(pInode) || (ulBlock >= INODE_DATA_BLOCKS)) - { - REDERROR(); - } - else if((pInode->ulLogicalBlock != ulBlock) || !pInode->fCoordInited) - { - RedInodePutData(pInode); - pInode->ulLogicalBlock = ulBlock; - - #if REDCONF_DIRECT_POINTERS > 0U - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - if(ulBlock < REDCONF_DIRECT_POINTERS) - #endif - { - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - RedInodePutCoord(pInode); - #endif - - pInode->uInodeEntry = (uint16_t)ulBlock; - pInode->ulDataBlock = pInode->pInodeBuf->aulEntries[pInode->uInodeEntry]; - - #if DINDIR_POINTERS > 0U - pInode->uDindirEntry = COORD_ENTRY_INVALID; - #endif - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - pInode->uIndirEntry = COORD_ENTRY_INVALID; - #endif - } - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - else - #endif - #endif - #if REDCONF_INDIRECT_POINTERS > 0U - #if REDCONF_INDIRECT_POINTERS < INODE_ENTRIES - if(ulBlock < (INODE_INDIR_BLOCKS + REDCONF_DIRECT_POINTERS)) - #endif - { - uint32_t ulIndirRangeOffset = ulBlock - REDCONF_DIRECT_POINTERS; - uint16_t uInodeEntry = (uint16_t)((ulIndirRangeOffset / INDIR_ENTRIES) + REDCONF_DIRECT_POINTERS); - uint16_t uIndirEntry = (uint16_t)(ulIndirRangeOffset % INDIR_ENTRIES); - - #if DINDIR_POINTERS > 0U - RedInodePutDindir(pInode); - #endif - - /* If the inode entry is not changing, then the previous indirect - is still the correct one. Otherwise, the old indirect will be - released and the new one will be read later. - */ - if((pInode->uInodeEntry != uInodeEntry) || !pInode->fCoordInited) - { - RedInodePutIndir(pInode); - - pInode->uInodeEntry = uInodeEntry; - - pInode->ulIndirBlock = pInode->pInodeBuf->aulEntries[pInode->uInodeEntry]; - } - - #if DINDIR_POINTERS > 0U - pInode->uDindirEntry = COORD_ENTRY_INVALID; - #endif - pInode->uIndirEntry = uIndirEntry; - - /* At this point, the following pInode members are needed but not - yet populated: - - - pIndir - - ulDataBlock - */ - } - #if DINDIR_POINTERS > 0U - else - #endif - #endif - #if DINDIR_POINTERS > 0U - { - uint32_t ulDindirRangeOffset = (ulBlock - REDCONF_DIRECT_POINTERS) - INODE_INDIR_BLOCKS; - uint16_t uInodeEntry = (uint16_t)((ulDindirRangeOffset / DINDIR_DATA_BLOCKS) + REDCONF_DIRECT_POINTERS + REDCONF_INDIRECT_POINTERS); - uint32_t ulDindirNodeOffset = ulDindirRangeOffset % DINDIR_DATA_BLOCKS; - uint16_t uDindirEntry = (uint16_t)(ulDindirNodeOffset / INDIR_ENTRIES); - uint16_t uIndirEntry = (uint16_t)(ulDindirNodeOffset % INDIR_ENTRIES); - - /* If the inode entry is not changing, then the previous double - indirect is still the correct one. Otherwise, the old double - indirect will be released and the new one will be read later. - */ - if((pInode->uInodeEntry != uInodeEntry) || !pInode->fCoordInited) - { - RedInodePutIndir(pInode); - RedInodePutDindir(pInode); - - pInode->uInodeEntry = uInodeEntry; - - pInode->ulDindirBlock = pInode->pInodeBuf->aulEntries[pInode->uInodeEntry]; - } - /* If neither the inode entry nor double indirect entry are - changing, then the previous indirect is still the correct one. - Otherwise, it old indirect will be released and the new one will - be read later. - */ - else if(pInode->uDindirEntry != uDindirEntry) - { - RedInodePutIndir(pInode); - } - else - { - /* Data buffer has already been put, nothing to do. - */ - } - - pInode->uDindirEntry = uDindirEntry; - pInode->uIndirEntry = uIndirEntry; - - /* At this point, the following pInode members are needed but not - yet populated: - - - pDindir - - pIndir - - ulIndirBlock - - ulDataBlock - */ - } - #elif (REDCONF_DIRECT_POINTERS > 0U) && (REDCONF_INDIRECT_POINTERS > 0U) - else - { - /* There are no double indirects, so the block should have been in - the direct or indirect range. - */ - REDERROR(); - } - #endif - - pInode->fCoordInited = true; - } - else - { - /* Seeking to the current position, nothing to do. - */ - } -} - - -/** @brief Read an unaligned portion of a block. - - @param pInode A pointer to the cached inode structure. - @param ullStart The file offset at which to read. - @param ulLen The number of bytes to read. - @param pbBuffer The buffer to read into. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EINVAL Invalid parameters. -*/ -static REDSTATUS ReadUnaligned( - CINODE *pInode, - uint64_t ullStart, - uint32_t ulLen, - uint8_t *pbBuffer) -{ - REDSTATUS ret; - - /* This read should not cross a block boundary. - */ - if( ((ullStart >> BLOCK_SIZE_P2) != (((ullStart + ulLen) - 1U) >> BLOCK_SIZE_P2)) - || (pbBuffer == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - ret = RedInodeDataSeekAndRead(pInode, (uint32_t)(ullStart >> BLOCK_SIZE_P2)); - - if(ret == 0) - { - RedMemCpy(pbBuffer, &pInode->pbData[ullStart & (REDCONF_BLOCK_SIZE - 1U)], ulLen); - } - else if(ret == -RED_ENODATA) - { - /* Sparse block, return zeroed data. - */ - RedMemSet(pbBuffer, 0U, ulLen); - ret = 0; - } - else - { - /* No action, just return the error. - */ - } - } - - return ret; -} - - -/** @brief Read one or more whole blocks. - - @param pInode A pointer to the cached inode structure. - @param ulBlockStart The file block offset at which to read. - @param ulBlockCount The number of blocks to read. - @param pbBuffer The buffer to read into. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EINVAL Invalid parameters. -*/ -static REDSTATUS ReadAligned( - CINODE *pInode, - uint32_t ulBlockStart, - uint32_t ulBlockCount, - uint8_t *pbBuffer) -{ - REDSTATUS ret = 0; - - if(pbBuffer == NULL) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - uint32_t ulBlockIndex = 0U; - - /* Read the data from disk one contiguous extent at a time. - */ - while((ret == 0) && (ulBlockIndex < ulBlockCount)) - { - uint32_t ulExtentStart; - uint32_t ulExtentLen = ulBlockCount - ulBlockIndex; - - ret = GetExtent(pInode, ulBlockStart + ulBlockIndex, &ulExtentStart, &ulExtentLen); - - if(ret == 0) - { - #if REDCONF_READ_ONLY == 0 - /* Before reading directly from disk, flush any dirty file data - buffers in the range to avoid reading stale data. - */ - ret = RedBufferFlush(ulExtentStart, ulExtentLen); - - if(ret == 0) - #endif - { - ret = RedIoRead(gbRedVolNum, ulExtentStart, ulExtentLen, &pbBuffer[ulBlockIndex << BLOCK_SIZE_P2]); - - if(ret == 0) - { - ulBlockIndex += ulExtentLen; - } - } - } - else if(ret == -RED_ENODATA) - { - /* Sparse block, return zeroed data. - */ - RedMemSet(&pbBuffer[ulBlockIndex << BLOCK_SIZE_P2], 0U, REDCONF_BLOCK_SIZE); - ulBlockIndex++; - ret = 0; - } - else - { - /* An unexpected error occurred; the loop will terminate. - */ - } - } - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Write an unaligned portion of a block. - - @param pInode A pointer to the cached inode structure. - @param ullStart The file offset at which to write. - @param ulLen The number of bytes to write. - @param pbBuffer The buffer to write from. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC No data can be written because there is insufficient - free space. - @retval -RED_EINVAL Invalid parameters. -*/ -static REDSTATUS WriteUnaligned( - CINODE *pInode, - uint64_t ullStart, - uint32_t ulLen, - const uint8_t *pbBuffer) -{ - REDSTATUS ret; - - /* This write should not cross a block boundary. - */ - if( ((ullStart >> BLOCK_SIZE_P2) != (((ullStart + ulLen) - 1U) >> BLOCK_SIZE_P2)) - || (pbBuffer == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - ret = RedInodeDataSeek(pInode, (uint32_t)(ullStart >> BLOCK_SIZE_P2)); - - if((ret == 0) || (ret == -RED_ENODATA)) - { - ret = BranchBlock(pInode, BRANCHDEPTH_FILE_DATA, true); - - if(ret == 0) - { - RedMemCpy(&pInode->pbData[ullStart & (REDCONF_BLOCK_SIZE - 1U)], pbBuffer, ulLen); - } - } - } - - return ret; -} - - -/** @brief Write one or more whole blocks. - - @param pInode A pointer to the cached inode structure. - @param ulBlockStart The file block offset at which to write. - @param pulBlockCount On entry, the number of blocks to attempt to write. - On successful return, the number of blocks actually - written. - @param pbBuffer The buffer to write from. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC No data can be written because there is insufficient - free space. - @retval -RED_EINVAL Invalid parameters. -*/ -static REDSTATUS WriteAligned( - CINODE *pInode, - uint32_t ulBlockStart, - uint32_t *pulBlockCount, - const uint8_t *pbBuffer) -{ - REDSTATUS ret = 0; - - if((pulBlockCount == NULL) || (pbBuffer == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - bool fFull = false; - uint32_t ulBlockCount = *pulBlockCount; - uint32_t ulBlockIndex; - - /* Branch all of the file data blocks in advance. - */ - for(ulBlockIndex = 0U; (ulBlockIndex < ulBlockCount) && !fFull; ulBlockIndex++) - { - ret = RedInodeDataSeek(pInode, ulBlockStart + ulBlockIndex); - - if((ret == 0) || (ret == -RED_ENODATA)) - { - ret = BranchBlock(pInode, BRANCHDEPTH_FILE_DATA, false); - - if(ret == -RED_ENOSPC) - { - if(ulBlockIndex > 0U) - { - ret = 0; - } - - fFull = true; - } - } - - if(ret != 0) - { - break; - } - } - - ulBlockCount = ulBlockIndex; - ulBlockIndex = 0U; - - if(fFull) - { - ulBlockCount--; - } - - /* Write the data to disk one contiguous extent at a time. - */ - while((ret == 0) && (ulBlockIndex < ulBlockCount)) - { - uint32_t ulExtentStart; - uint32_t ulExtentLen = ulBlockCount - ulBlockIndex; - - ret = GetExtent(pInode, ulBlockStart + ulBlockIndex, &ulExtentStart, &ulExtentLen); - - if(ret == 0) - { - ret = RedIoWrite(gbRedVolNum, ulExtentStart, ulExtentLen, &pbBuffer[ulBlockIndex << BLOCK_SIZE_P2]); - - if(ret == 0) - { - /* If there is any buffered file data for the extent we - just wrote, those buffers are now stale. - */ - ret = RedBufferDiscardRange(ulExtentStart, ulExtentLen); - } - - if(ret == 0) - { - ulBlockIndex += ulExtentLen; - } - } - } - - if(ret == 0) - { - *pulBlockCount = ulBlockCount; - } - } - - return ret; -} -#endif /* REDCONF_READ_ONLY == 0 */ - - -/** @brief Get the physical block number and count of contiguous blocks given a - starting logical block number. - - @param pInode A pointer to the cached inode structure. - @param ulBlockStart The file block offset for the start of the extent. - @param pulExtentStart On successful return, the starting physical block - number of the contiguous extent. - @param pulExtentLen On entry, the maximum length of the extent; on - successful return, the length of the contiguous - extent. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENODATA The block offset is sparse. - @retval -RED_EINVAL Invalid parameters. -*/ -static REDSTATUS GetExtent( - CINODE *pInode, - uint32_t ulBlockStart, - uint32_t *pulExtentStart, - uint32_t *pulExtentLen) -{ - REDSTATUS ret; - - if((pulExtentStart == NULL) || (pulExtentLen == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - ret = RedInodeDataSeek(pInode, ulBlockStart); - - if(ret == 0) - { - uint32_t ulExtentLen = *pulExtentLen; - uint32_t ulFirstBlock = pInode->ulDataBlock; - uint32_t ulRunLen = 1U; - - while((ret == 0) && (ulRunLen < ulExtentLen)) - { - ret = RedInodeDataSeek(pInode, ulBlockStart + ulRunLen); - - /* The extent ends when we find a sparse data block or when the - data block is not contiguous with the preceding data block. - */ - if((ret == -RED_ENODATA) || ((ret == 0) && (pInode->ulDataBlock != (ulFirstBlock + ulRunLen)))) - { - ret = 0; - break; - } - - ulRunLen++; - } - - if(ret == 0) - { - *pulExtentStart = ulFirstBlock; - *pulExtentLen = ulRunLen; - } - } - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Allocate or branch the file metadata path and data block if necessary. - - Optionally, can stop allocating/branching at a certain depth. - - @param pInode A pointer to the cached inode structure. - @param depth A BRANCHDEPTH_ value indicating the lowest depth to branch. - @param fBuffer Whether to buffer the data block. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC No data can be written because there is insufficient - free space. -*/ -static REDSTATUS BranchBlock( - CINODE *pInode, - BRANCHDEPTH depth, - bool fBuffer) -{ - REDSTATUS ret; - uint32_t ulCost = 0U; /* Init'd to quiet warnings. */ - - ret = BranchBlockCost(pInode, depth, &ulCost); - - if((ret == 0) && (ulCost > FreeBlockCount())) - { - ret = -RED_ENOSPC; - } - - if(ret == 0) - { - #if DINDIR_POINTERS > 0U - if(pInode->uDindirEntry != COORD_ENTRY_INVALID) - { - ret = BranchOneBlock(&pInode->ulDindirBlock, CAST_VOID_PTR_PTR(&pInode->pDindir), BFLAG_META_DINDIR); - - if(ret == 0) - { - /* In case we just created the double indirect. - */ - pInode->pDindir->ulInode = pInode->ulInode; - - pInode->pInodeBuf->aulEntries[pInode->uInodeEntry] = pInode->ulDindirBlock; - } - } - - if(ret == 0) - #endif - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - { - if((pInode->uIndirEntry != COORD_ENTRY_INVALID) && (depth >= BRANCHDEPTH_INDIR)) - { - ret = BranchOneBlock(&pInode->ulIndirBlock, CAST_VOID_PTR_PTR(&pInode->pIndir), BFLAG_META_INDIR); - - if(ret == 0) - { - /* In case we just created the indirect. - */ - pInode->pIndir->ulInode = pInode->ulInode; - - #if DINDIR_POINTERS > 0U - if(pInode->uDindirEntry != COORD_ENTRY_INVALID) - { - pInode->pDindir->aulEntries[pInode->uDindirEntry] = pInode->ulIndirBlock; - } - else - #endif - { - pInode->pInodeBuf->aulEntries[pInode->uInodeEntry] = pInode->ulIndirBlock; - } - } - } - } - - if(ret == 0) - #endif - { - if(depth == BRANCHDEPTH_FILE_DATA) - { - #if REDCONF_INODE_BLOCKS == 1 - bool fAllocedNew = (pInode->ulDataBlock == BLOCK_SPARSE); - #endif - void **ppBufPtr = (fBuffer || (pInode->pbData != NULL)) ? CAST_VOID_PTR_PTR(&pInode->pbData) : NULL; - - ret = BranchOneBlock(&pInode->ulDataBlock, ppBufPtr, 0U); - - if(ret == 0) - { - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - if(pInode->uIndirEntry != COORD_ENTRY_INVALID) - { - pInode->pIndir->aulEntries[pInode->uIndirEntry] = pInode->ulDataBlock; - } - else - #endif - { - pInode->pInodeBuf->aulEntries[pInode->uInodeEntry] = pInode->ulDataBlock; - } - - #if REDCONF_INODE_BLOCKS == 1 - if(fAllocedNew) - { - if(pInode->pInodeBuf->ulBlocks < INODE_DATA_BLOCKS) - { - pInode->pInodeBuf->ulBlocks++; - } - else - { - CRITICAL_ERROR(); - ret = -RED_EFUBAR; - } - } - #endif - } - } - } - - CRITICAL_ASSERT(ret == 0); - } - - return ret; -} - - -/** @brief Branch a block. - - The block can be a double indirect, indirect, or file data block. - - The caller should have already handled the disk full implications of - branching this block. - - @param pulBlock On entry, the current block number, which may be - BLOCK_SPARSE if the block is to be newly allocated. On - successful return, populated with the new block number, - which may be the same as the original block number if it - was not BLOCK_SPARSE and the block was already branched. - @param ppBuffer If NULL, indicates that the caller does not want to buffer - the branched block. If non-NULL, the caller does want the - branched block buffered, and the following is true: On - entry, the current buffer for the block, if there is one, or - NULL if there is no buffer. On successful exit, populated - with a buffer for the block, which will be dirty. If the - block number is initially BLOCK_SPARSE, there should be no - buffer for the block. - @param uBFlag The buffer type flags: BFLAG_META_DINDIR, BFLAG_META_INDIR, - or zero for file data. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EINVAL Invalid parameters. -*/ -static REDSTATUS BranchOneBlock( - uint32_t *pulBlock, - void **ppBuffer, - uint16_t uBFlag) -{ - REDSTATUS ret = 0; - - if(pulBlock == NULL) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - ALLOCSTATE state = ALLOCSTATE_FREE; - uint32_t ulPrevBlock = *pulBlock; - - if(ulPrevBlock != BLOCK_SPARSE) - { - ret = RedImapBlockState(ulPrevBlock, &state); - } - - if(ret == 0) - { - if(state == ALLOCSTATE_NEW) - { - /* Block is already branched, so simply get it buffered dirty - if requested. - */ - if(ppBuffer != NULL) - { - if(*ppBuffer != NULL) - { - RedBufferDirty(*ppBuffer); - } - else - { - ret = RedBufferGet(ulPrevBlock, uBFlag | BFLAG_DIRTY, ppBuffer); - } - } - } - else - { - /* Block does not exist or is committed state, so allocate a - new block for the branch. - */ - ret = RedImapAllocBlock(pulBlock); - - if(ret == 0) - { - if(ulPrevBlock == BLOCK_SPARSE) - { - /* Block did not exist previously, so just get it - buffered if requested. - */ - if(ppBuffer != NULL) - { - if(*ppBuffer != NULL) - { - /* How could there be an existing buffer when - the block did not exist? - */ - REDERROR(); - ret = -RED_EINVAL; - } - else - { - ret = RedBufferGet(*pulBlock, (uint16_t)((uint32_t)uBFlag | BFLAG_NEW | BFLAG_DIRTY), ppBuffer); - } - } - } - else - { - /* Branch the buffer for the committed state block to - the newly allocated location. - */ - if(ppBuffer != NULL) - { - if(*ppBuffer == NULL) - { - ret = RedBufferGet(ulPrevBlock, uBFlag, ppBuffer); - } - - if(ret == 0) - { - RedBufferBranch(*ppBuffer, *pulBlock); - } - } - - /* Mark the committed state block almost free. - */ - if(ret == 0) - { - ret = RedImapBlockSet(ulPrevBlock, false); - } - } - } - } - } - } - - return ret; -} - - -/** @brief Compute the free space cost of branching a block. - - The caller must first use RedInodeDataSeek() to the block to be branched. - - @param pInode A pointer to the cached inode structure, whose coordinates - indicate the block to be branched. - @param depth A BRANCHDEPTH_ value indicating how much of the file - metadata structure needs to be branched. - @param pulCost On successful return, populated with the number of blocks - that must be allocated from free space in order to branch - the given block. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EINVAL Invalid parameters. -*/ -static REDSTATUS BranchBlockCost( - const CINODE *pInode, - BRANCHDEPTH depth, - uint32_t *pulCost) -{ - REDSTATUS ret = 0; - - if(!CINODE_IS_MOUNTED(pInode) || !pInode->fCoordInited || (depth > BRANCHDEPTH_MAX) || (pulCost == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else - { - ALLOCSTATE state; - - /* ulCost is initialized to the maximum number of blocks that could - be branched, and decremented for every block we determine does not - need to be branched. - */ - #if DINDIR_POINTERS > 0U - uint32_t ulCost = 3U; - #elif REDCONF_DIRECT_POINTERS < INODE_ENTRIES - uint32_t ulCost = 2U; - #else - uint32_t ulCost = 1U; - #endif - - #if DINDIR_POINTERS > 0U - if(pInode->uDindirEntry != COORD_ENTRY_INVALID) - { - if(pInode->ulDindirBlock != BLOCK_SPARSE) - { - ret = RedImapBlockState(pInode->ulDindirBlock, &state); - - if((ret == 0) && (state == ALLOCSTATE_NEW)) - { - /* Double indirect already branched. - */ - ulCost--; - } - } - } - else - { - /* At this inode offset there are no double indirects. - */ - ulCost--; - } - - if(ret == 0) - #endif - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - { - if((pInode->uIndirEntry != COORD_ENTRY_INVALID) && (depth >= BRANCHDEPTH_INDIR)) - { - if(pInode->ulIndirBlock != BLOCK_SPARSE) - { - ret = RedImapBlockState(pInode->ulIndirBlock, &state); - - if((ret == 0) && (state == ALLOCSTATE_NEW)) - { - /* Indirect already branched. - */ - ulCost--; - } - } - } - else - { - /* Either not branching this deep, or at this inode offset - there are no indirects. - */ - ulCost--; - } - } - - if(ret == 0) - #endif - { - if(depth == BRANCHDEPTH_FILE_DATA) - { - if(pInode->ulDataBlock != BLOCK_SPARSE) - { - ret = RedImapBlockState(pInode->ulDataBlock, &state); - - if((ret == 0) && (state == ALLOCSTATE_NEW)) - { - /* File data block already branched. - */ - ulCost--; - - /* If the file data block is branched, then its parent - nodes should be branched as well. - */ - REDASSERT(ulCost == 0U); - } - } - } - else - { - /* Not branching this deep. - */ - ulCost--; - } - } - - if(ret == 0) - { - *pulCost = ulCost; - } - } - - return ret; -} - - -/** @brief Yields the number of currently available free blocks. - - Accounts for reserved blocks, subtracting the number of reserved blocks if - they are unavailable. - - @return Number of currently available free blocks. -*/ -static uint32_t FreeBlockCount(void) -{ - uint32_t ulFreeBlocks = gpRedMR->ulFreeBlocks; - - #if RESERVED_BLOCKS > 0U - if(!gpRedCoreVol->fUseReservedBlocks) - { - if(ulFreeBlocks >= RESERVED_BLOCKS) - { - ulFreeBlocks -= RESERVED_BLOCKS; - } - else - { - ulFreeBlocks = 0U; - } - } - #endif - - return ulFreeBlocks; -} -#endif /* REDCONF_READ_ONLY == 0 */ - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/volume.c b/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/volume.c deleted file mode 100755 index 55e02d0..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/driver/volume.c +++ /dev/null @@ -1,540 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements core volume operations. -*/ -#include -#include - - -static bool MetarootIsValid(METAROOT *pMR, bool *pfSectorCRCIsValid); -#ifdef REDCONF_ENDIAN_SWAP -static void MetaRootEndianSwap(METAROOT *pMetaRoot); -#endif - - -/** @brief Mount a file system volume. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO Volume not formatted, improperly formatted, or corrupt. -*/ -REDSTATUS RedVolMount(void) -{ - REDSTATUS ret; - - #if REDCONF_READ_ONLY == 0 - ret = RedOsBDevOpen(gbRedVolNum, BDEV_O_RDWR); - #else - ret = RedOsBDevOpen(gbRedVolNum, BDEV_O_RDONLY); - #endif - - if(ret == 0) - { - ret = RedVolMountMaster(); - - if(ret == 0) - { - ret = RedVolMountMetaroot(); - } - - if(ret != 0) - { - /* If we fail to mount, invalidate the buffers to prevent any - confusion that could be caused by stale or corrupt metadata. - */ - (void)RedBufferDiscardRange(0U, gpRedVolume->ulBlockCount); - (void)RedOsBDevClose(gbRedVolNum); - } - } - - return ret; -} - - -/** @brief Mount the master block. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO Master block missing, corrupt, or inconsistent with the - compile-time driver settings. -*/ -REDSTATUS RedVolMountMaster(void) -{ - REDSTATUS ret; - MASTERBLOCK *pMB; - - /* Read the master block, to ensure that the disk was formatted with - Reliance Edge. - */ - ret = RedBufferGet(BLOCK_NUM_MASTER, BFLAG_META_MASTER, CAST_VOID_PTR_PTR(&pMB)); - - if(ret == 0) - { - /* Verify that the driver was compiled with the same settings that - the disk was formatted with. If not, the user has made a - mistake: either the driver settings are wrong, or the disk needs - to be reformatted. - */ - if( (pMB->ulVersion != RED_DISK_LAYOUT_VERSION) - || (pMB->ulInodeCount != gpRedVolConf->ulInodeCount) - || (pMB->ulBlockCount != gpRedVolume->ulBlockCount) - || (pMB->uMaxNameLen != REDCONF_NAME_MAX) - || (pMB->uDirectPointers != REDCONF_DIRECT_POINTERS) - || (pMB->uIndirectPointers != REDCONF_INDIRECT_POINTERS) - || (pMB->bBlockSizeP2 != BLOCK_SIZE_P2) - || (((pMB->bFlags & MBFLAG_API_POSIX) != 0U) != (REDCONF_API_POSIX == 1)) - || (((pMB->bFlags & MBFLAG_INODE_TIMESTAMPS) != 0U) != (REDCONF_INODE_TIMESTAMPS == 1)) - || (((pMB->bFlags & MBFLAG_INODE_BLOCKS) != 0U) != (REDCONF_INODE_BLOCKS == 1))) - { - ret = -RED_EIO; - } - #if REDCONF_API_POSIX == 1 - else if(((pMB->bFlags & MBFLAG_INODE_NLINK) != 0U) != (REDCONF_API_POSIX_LINK == 1)) - { - ret = -RED_EIO; - } - #else - else if((pMB->bFlags & MBFLAG_INODE_NLINK) != 0U) - { - ret = -RED_EIO; - } - #endif - else - { - /* Master block configuration is valid. - - Save the sequence number of the master block in the volume, - since we need it later (see RedVolMountMetaroot()) and we do - not want to re-buffer the master block. - */ - gpRedVolume->ullSequence = pMB->hdr.ullSequence; - } - - RedBufferPut(pMB); - } - - return ret; -} - - -/** @brief Mount the latest metaroot. - - This function also populates the volume contexts. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO Both metaroots are missing or corrupt. -*/ -REDSTATUS RedVolMountMetaroot(void) -{ - REDSTATUS ret; - - ret = RedIoRead(gbRedVolNum, BLOCK_NUM_FIRST_METAROOT, 1U, &gpRedCoreVol->aMR[0U]); - - if(ret == 0) - { - ret = RedIoRead(gbRedVolNum, BLOCK_NUM_FIRST_METAROOT + 1U, 1U, &gpRedCoreVol->aMR[1U]); - } - - /* Determine which metaroot is the most recent copy that was written - completely. - */ - if(ret == 0) - { - uint8_t bMR = UINT8_MAX; - bool fSectorCRCIsValid; - - if(MetarootIsValid(&gpRedCoreVol->aMR[0U], &fSectorCRCIsValid)) - { - bMR = 0U; - - #ifdef REDCONF_ENDIAN_SWAP - MetaRootEndianSwap(&gpRedCoreVol->aMR[0U]); - #endif - } - else if(gpRedVolConf->fAtomicSectorWrite && !fSectorCRCIsValid) - { - ret = -RED_EIO; - } - else - { - /* Metaroot is not valid, so it is ignored and there's nothing - to do here. - */ - } - - if(ret == 0) - { - if(MetarootIsValid(&gpRedCoreVol->aMR[1U], &fSectorCRCIsValid)) - { - #ifdef REDCONF_ENDIAN_SWAP - MetaRootEndianSwap(&gpRedCoreVol->aMR[1U]); - #endif - - if((bMR != 0U) || (gpRedCoreVol->aMR[1U].hdr.ullSequence > gpRedCoreVol->aMR[0U].hdr.ullSequence)) - { - bMR = 1U; - } - } - else if(gpRedVolConf->fAtomicSectorWrite && !fSectorCRCIsValid) - { - ret = -RED_EIO; - } - else - { - /* Metaroot is not valid, so it is ignored and there's nothing - to do here. - */ - } - } - - if(ret == 0) - { - if(bMR == UINT8_MAX) - { - /* Neither metaroot was valid. - */ - ret = -RED_EIO; - } - else - { - gpRedCoreVol->bCurMR = bMR; - gpRedMR = &gpRedCoreVol->aMR[bMR]; - } - } - } - - if(ret == 0) - { - /* Normally the metaroot contains the highest sequence number, but the - master block is the last block written during format, so on a - freshly formatted volume the master block sequence number (stored in - gpRedVolume->ullSequence) will be higher than that in the metaroot. - */ - if(gpRedMR->hdr.ullSequence > gpRedVolume->ullSequence) - { - gpRedVolume->ullSequence = gpRedMR->hdr.ullSequence; - } - - /* gpRedVolume->ullSequence stores the *next* sequence number; to avoid - giving the next node written to disk the same sequence number as the - metaroot, increment it here. - */ - ret = RedVolSeqNumIncrement(); - } - - if(ret == 0) - { - gpRedVolume->fMounted = true; - #if REDCONF_READ_ONLY == 0 - gpRedVolume->fReadOnly = false; - #endif - - #if RESERVED_BLOCKS > 0U - gpRedCoreVol->fUseReservedBlocks = false; - #endif - gpRedCoreVol->ulAlmostFreeBlocks = 0U; - - gpRedCoreVol->aMR[1U - gpRedCoreVol->bCurMR] = *gpRedMR; - gpRedCoreVol->bCurMR = 1U - gpRedCoreVol->bCurMR; - gpRedMR = &gpRedCoreVol->aMR[gpRedCoreVol->bCurMR]; - } - - return ret; -} - - -/** @brief Determine whether the metaroot is valid. - - @param pMR The metaroot buffer. - @param pfSectorCRCIsValid Populated with whether the first sector of the - metaroot buffer is valid. - - @return Whether the metaroot is valid. - - @retval true The metaroot buffer is valid. - @retval false The metaroot buffer is invalid. -*/ -static bool MetarootIsValid( - METAROOT *pMR, - bool *pfSectorCRCIsValid) -{ - bool fRet = false; - - if(pfSectorCRCIsValid == NULL) - { - REDERROR(); - } - else if(pMR == NULL) - { - REDERROR(); - *pfSectorCRCIsValid = false; - } - #ifdef REDCONF_ENDIAN_SWAP - else if(RedRev32(pMR->hdr.ulSignature) != META_SIG_METAROOT) - #else - else if(pMR->hdr.ulSignature != META_SIG_METAROOT) - #endif - { - *pfSectorCRCIsValid = false; - } - else - { - const uint8_t *pbMR = CAST_VOID_PTR_TO_CONST_UINT8_PTR(pMR); - uint32_t ulSectorCRC = pMR->ulSectorCRC; - uint32_t ulCRC; - - #ifdef REDCONF_ENDIAN_SWAP - ulSectorCRC = RedRev32(ulSectorCRC); - #endif - - /* The sector CRC was zero when the CRC was computed during the - transaction, so it must be zero here. - */ - pMR->ulSectorCRC = 0U; - - ulCRC = RedCrc32Update(0U, &pbMR[8U], gpRedVolConf->ulSectorSize - 8U); - - fRet = ulCRC == ulSectorCRC; - *pfSectorCRCIsValid = fRet; - - if(fRet) - { - if(gpRedVolConf->ulSectorSize < REDCONF_BLOCK_SIZE) - { - ulCRC = RedCrc32Update(ulCRC, &pbMR[gpRedVolConf->ulSectorSize], REDCONF_BLOCK_SIZE - gpRedVolConf->ulSectorSize); - } - - #ifdef REDCONF_ENDIAN_SWAP - ulCRC = RedRev32(ulCRC); - #endif - - fRet = ulCRC == pMR->hdr.ulCRC; - } - } - - return fRet; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Commit a transaction point. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedVolTransact(void) -{ - REDSTATUS ret = 0; - - REDASSERT(!gpRedVolume->fReadOnly); /* Should be checked by caller. */ - - if(gpRedCoreVol->fBranched) - { - gpRedMR->ulFreeBlocks += gpRedCoreVol->ulAlmostFreeBlocks; - gpRedCoreVol->ulAlmostFreeBlocks = 0U; - - ret = RedBufferFlush(0U, gpRedVolume->ulBlockCount); - - if(ret == 0) - { - gpRedMR->hdr.ulSignature = META_SIG_METAROOT; - gpRedMR->hdr.ullSequence = gpRedVolume->ullSequence; - - ret = RedVolSeqNumIncrement(); - } - - if(ret == 0) - { - const uint8_t *pbMR = CAST_VOID_PTR_TO_CONST_UINT8_PTR(gpRedMR); - uint32_t ulSectorCRC; - - #ifdef REDCONF_ENDIAN_SWAP - MetaRootEndianSwap(gpRedMR); - #endif - - gpRedMR->ulSectorCRC = 0U; - - ulSectorCRC = RedCrc32Update(0U, &pbMR[8U], gpRedVolConf->ulSectorSize - 8U); - - if(gpRedVolConf->ulSectorSize < REDCONF_BLOCK_SIZE) - { - gpRedMR->hdr.ulCRC = RedCrc32Update(ulSectorCRC, &pbMR[gpRedVolConf->ulSectorSize], REDCONF_BLOCK_SIZE - gpRedVolConf->ulSectorSize); - } - else - { - gpRedMR->hdr.ulCRC = ulSectorCRC; - } - - gpRedMR->ulSectorCRC = ulSectorCRC; - - #ifdef REDCONF_ENDIAN_SWAP - gpRedMR->hdr.ulCRC = RedRev32(gpRedMR->hdr.ulCRC); - gpRedMR->ulSectorCRC = RedRev32(gpRedMR->ulSectorCRC); - #endif - - /* Flush the block device before writing the metaroot, so that all - previously written blocks are guaranteed to be on the media before - the metaroot is written. Otherwise, if the block device reorders - the writes, the metaroot could reach the media before metadata it - points at, creating a window for disk corruption if power is lost. - */ - ret = RedIoFlush(gbRedVolNum); - } - - if(ret == 0) - { - ret = RedIoWrite(gbRedVolNum, BLOCK_NUM_FIRST_METAROOT + gpRedCoreVol->bCurMR, 1U, gpRedMR); - - #ifdef REDCONF_ENDIAN_SWAP - MetaRootEndianSwap(gpRedMR); - #endif - } - - /* Flush the block device to force the metaroot write to the media. This - guarantees the transaction point is really complete before we return. - */ - if(ret == 0) - { - ret = RedIoFlush(gbRedVolNum); - } - - /* Toggle to the other metaroot buffer. The working state and committed - state metaroot buffers exchange places. - */ - if(ret == 0) - { - uint8_t bNextMR = 1U - gpRedCoreVol->bCurMR; - - gpRedCoreVol->aMR[bNextMR] = *gpRedMR; - gpRedCoreVol->bCurMR = bNextMR; - - gpRedMR = &gpRedCoreVol->aMR[gpRedCoreVol->bCurMR]; - - gpRedCoreVol->fBranched = false; - } - - CRITICAL_ASSERT(ret == 0); - } - - return ret; -} -#endif - - -#ifdef REDCONF_ENDIAN_SWAP -static void MetaRootEndianSwap( - METAROOT *pMetaRoot) -{ - if(pMetaRoot == NULL) - { - REDERROR(); - } - else - { - pMetaRoot->ulSectorCRC = RedRev32(pMetaRoot->ulSectorCRC); - pMetaRoot->ulFreeBlocks = RedRev32(pMetaRoot->ulFreeBlocks); - #if REDCONF_API_POSIX == 1 - pMetaRoot->ulFreeInodes = RedRev32(pMetaRoot->ulFreeInodes); - #endif - pMetaRoot->ulAllocNextBlock = RedRev32(pMetaRoot->ulAllocNextBlock); - } -} -#endif - - -/** @brief Process a critical file system error. - - @param pszFileName The file in which the error occurred. - @param ulLineNum The line number at which the error occurred. -*/ -void RedVolCriticalError( - const char *pszFileName, - uint32_t ulLineNum) -{ - #if REDCONF_OUTPUT == 1 - #if REDCONF_READ_ONLY == 0 - if(!gpRedVolume->fReadOnly) - { - RedOsOutputString("Critical file system error in Reliance Edge, setting volume to READONLY\n"); - } - else - #endif - { - RedOsOutputString("Critical file system error in Reliance Edge (volume already READONLY)\n"); - } - #endif - - #if REDCONF_READ_ONLY == 0 - gpRedVolume->fReadOnly = true; - #endif - - #if REDCONF_ASSERTS == 1 - RedOsAssertFail(pszFileName, ulLineNum); - #else - (void)pszFileName; - (void)ulLineNum; - #endif -} - - -/** @brief Increment the sequence number. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL Cannot increment sequence number: maximum value reached. - This should not ever happen. -*/ -REDSTATUS RedVolSeqNumIncrement(void) -{ - REDSTATUS ret; - - if(gpRedVolume->ullSequence == UINT64_MAX) - { - /* In practice this should never, ever happen; to get here, there would - need to be UINT64_MAX disk writes, which would take eons: longer - than the lifetime of any product or storage media. If this assert - fires and the current year is still written with four digits, - suspect memory corruption. - */ - CRITICAL_ERROR(); - ret = -RED_EFUBAR; - } - else - { - gpRedVolume->ullSequence++; - ret = 0; - } - - return ret; -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/include/redcore.h b/FreeRTOS-Plus/Source/Reliance-Edge/core/include/redcore.h deleted file mode 100755 index 031117f..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/include/redcore.h +++ /dev/null @@ -1,257 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file -*/ -#ifndef REDCORE_H -#define REDCORE_H - - -#include -#include -#include "rednodes.h" -#include "redcoremacs.h" -#include "redcorevol.h" - - -#define META_SIG_MASTER (0x5453414DU) /* 'MAST' */ -#define META_SIG_METAROOT (0x4154454DU) /* 'META' */ -#define META_SIG_IMAP (0x50414D49U) /* 'IMAP' */ -#define META_SIG_INODE (0x444F4E49U) /* 'INOD' */ -#define META_SIG_DINDIR (0x494C4244U) /* 'DBLI' */ -#define META_SIG_INDIR (0x49444E49U) /* 'INDI' */ - - -REDSTATUS RedIoRead(uint8_t bVolNum, uint32_t ulBlockStart, uint32_t ulBlockCount, void *pBuffer); -#if REDCONF_READ_ONLY == 0 -REDSTATUS RedIoWrite(uint8_t bVolNum, uint32_t ulBlockStart, uint32_t ulBlockCount, const void *pBuffer); -REDSTATUS RedIoFlush(uint8_t bVolNum); -#endif - - -/** Indicates a block buffer is dirty (its contents are different than the - contents of the corresponding block on disk); or, when passed into - RedBufferGet(), indicates that the buffer should be marked dirty. -*/ -#define BFLAG_DIRTY ((uint16_t) 0x0001U) - -/** Tells RedBufferGet() that the buffer is for a newly allocated block, and its - contents should be zeroed instead of being read from disk. Always used in - combination with BFLAG_DIRTY. -*/ -#define BFLAG_NEW ((uint16_t) 0x0002U) - -/** Indicates that a block buffer is a master block (MASTERBLOCK) metadata node. -*/ -#define BFLAG_META_MASTER ((uint16_t)(0x0004U | BFLAG_META)) - -/** Indicates that a block buffer is an imap (IMAPNODE) metadata node. -*/ -#define BFLAG_META_IMAP ((uint16_t)(0x0008U | BFLAG_META)) - -/** Indicates that a block buffer is an inode (INODE) metadata node. -*/ -#define BFLAG_META_INODE ((uint16_t)(0x0010U | BFLAG_META)) - -/** Indicates that a block buffer is an indirect (INDIR) metadata node. -*/ -#define BFLAG_META_INDIR ((uint16_t)(0x0020U | BFLAG_META)) - -/** Indicates that a block buffer is a double indirect (DINDIR) metadata node. -*/ -#define BFLAG_META_DINDIR ((uint16_t)(0x0040U | BFLAG_META)) - -/** Indicates that a block buffer is a metadata node. Callers of RedBufferGet() - should not use this flag; instead, use one of the BFLAG_META_* flags. -*/ -#define BFLAG_META ((uint16_t) 0x8000U) - - -void RedBufferInit(void); -REDSTATUS RedBufferGet(uint32_t ulBlock, uint16_t uFlags, void **ppBuffer); -void RedBufferPut(const void *pBuffer); -#if REDCONF_READ_ONLY == 0 -REDSTATUS RedBufferFlush(uint32_t ulBlockStart, uint32_t ulBlockCount); -void RedBufferDirty(const void *pBuffer); -void RedBufferBranch(const void *pBuffer, uint32_t ulBlockNew); -#if (REDCONF_API_POSIX == 1) || FORMAT_SUPPORTED -void RedBufferDiscard(const void *pBuffer); -#endif -#endif -REDSTATUS RedBufferDiscardRange(uint32_t ulBlockStart, uint32_t ulBlockCount); - - -/** @brief Allocation state of a block. -*/ -typedef enum -{ - ALLOCSTATE_FREE, /**< Free and may be allocated; writeable. */ - ALLOCSTATE_USED, /**< In-use and transacted; not writeable. */ - ALLOCSTATE_NEW, /**< In-use but not transacted; writeable. */ - ALLOCSTATE_AFREE /**< Will become free after a transaction; not writeable. */ -} ALLOCSTATE; - -REDSTATUS RedImapBlockGet(uint8_t bMR, uint32_t ulBlock, bool *pfAllocated); -#if REDCONF_READ_ONLY == 0 -REDSTATUS RedImapBlockSet(uint32_t ulBlock, bool fAllocated); -REDSTATUS RedImapAllocBlock(uint32_t *pulBlock); -#endif -REDSTATUS RedImapBlockState(uint32_t ulBlock, ALLOCSTATE *pState); - -#if REDCONF_IMAP_INLINE == 1 -REDSTATUS RedImapIBlockGet(uint8_t bMR, uint32_t ulBlock, bool *pfAllocated); -REDSTATUS RedImapIBlockSet(uint32_t ulBlock, bool fAllocated); -#endif - -#if REDCONF_IMAP_EXTERNAL == 1 -REDSTATUS RedImapEBlockGet(uint8_t bMR, uint32_t ulBlock, bool *pfAllocated); -REDSTATUS RedImapEBlockSet(uint32_t ulBlock, bool fAllocated); -uint32_t RedImapNodeBlock(uint8_t bMR, uint32_t ulImapNode); -#endif - - -/** @brief Cached inode structure. -*/ -typedef struct -{ - uint32_t ulInode; /**< The inode number of the cached inode. */ - #if REDCONF_API_POSIX == 1 - bool fDirectory; /**< True if the inode is a directory. */ - #endif - #if REDCONF_READ_ONLY == 0 - bool fBranched; /**< True if the inode is branched (writeable). */ - bool fDirty; /**< True if the inode buffer is dirty. */ - #endif - bool fCoordInited; /**< True after the first seek. */ - - INODE *pInodeBuf; /**< Pointer to the inode buffer. */ - #if DINDIR_POINTERS > 0U - DINDIR *pDindir; /**< Pointer to the double indirect node buffer. */ - #endif - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - INDIR *pIndir; /**< Pointer to the indirect node buffer. */ - #endif - uint8_t *pbData; /**< Pointer to the data block buffer. */ - - /* All the members below this point are part of the seek coordinates; see - RedInodeDataSeek(). - */ - uint32_t ulLogicalBlock; /**< Logical block offset into the inode. */ - #if DINDIR_POINTERS > 0U - uint32_t ulDindirBlock; /**< Physical block number of the double indirect node. */ - #endif - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - uint32_t ulIndirBlock; /**< Physical block number of the indirect node. */ - #endif - uint32_t ulDataBlock; /**< Physical block number of the file data block. */ - - uint16_t uInodeEntry; /**< Which inode entry to traverse to reach ulLogicalBlock. */ - #if DINDIR_POINTERS > 0U - uint16_t uDindirEntry; /**< Which double indirect entry to traverse to reach ulLogicalBlock. */ - #endif - #if REDCONF_DIRECT_POINTERS < INODE_ENTRIES - uint16_t uIndirEntry; /**< Which indirect entry to traverse to reach ulLogicalBlock. */ - #endif -} CINODE; - -#define CINODE_IS_MOUNTED(pInode) (((pInode) != NULL) && INODE_IS_VALID((pInode)->ulInode) && ((pInode)->pInodeBuf != NULL)) -#define CINODE_IS_DIRTY(pInode) (CINODE_IS_MOUNTED(pInode) && (pInode)->fDirty) - - -#define IPUT_UPDATE_ATIME (0x01U) -#define IPUT_UPDATE_MTIME (0x02U) -#define IPUT_UPDATE_CTIME (0x04U) -#define IPUT_UPDATE_MASK (IPUT_UPDATE_ATIME|IPUT_UPDATE_MTIME|IPUT_UPDATE_CTIME) - - -REDSTATUS RedInodeMount(CINODE *pInode, FTYPE type, bool fBranch); -#if REDCONF_READ_ONLY == 0 -REDSTATUS RedInodeBranch(CINODE *pInode); -#endif -#if (REDCONF_READ_ONLY == 0) && ((REDCONF_API_POSIX == 1) || FORMAT_SUPPORTED) -REDSTATUS RedInodeCreate(CINODE *pInode, uint32_t ulPInode, uint16_t uMode); -#endif -#if DELETE_SUPPORTED -REDSTATUS RedInodeDelete(CINODE *pInode); -REDSTATUS RedInodeLinkDec(CINODE *pInode); -#endif -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) -REDSTATUS RedInodeFree(CINODE *pInode); -#endif -void RedInodePut(CINODE *pInode, uint8_t bTimeFields); -void RedInodePutCoord(CINODE *pInode); -#if DINDIR_POINTERS > 0U -void RedInodePutDindir(CINODE *pInode); -#endif -#if REDCONF_DIRECT_POINTERS < INODE_ENTRIES -void RedInodePutIndir(CINODE *pInode); -#endif -void RedInodePutData(CINODE *pInode); -#if ((REDCONF_READ_ONLY == 0) && ((REDCONF_API_POSIX == 1) || FORMAT_SUPPORTED)) || (REDCONF_CHECKER == 1) -REDSTATUS RedInodeIsFree(uint32_t ulInode, bool *pfFree); -#endif -REDSTATUS RedInodeBitGet(uint8_t bMR, uint32_t ulInode, uint8_t bWhich, bool *pfAllocated); - -REDSTATUS RedInodeDataRead(CINODE *pInode, uint64_t ullStart, uint32_t *pulLen, void *pBuffer); -#if REDCONF_READ_ONLY == 0 -REDSTATUS RedInodeDataWrite(CINODE *pInode, uint64_t ullStart, uint32_t *pulLen, const void *pBuffer); -#if DELETE_SUPPORTED || TRUNCATE_SUPPORTED -REDSTATUS RedInodeDataTruncate(CINODE *pInode, uint64_t ullSize); -#endif -#endif -REDSTATUS RedInodeDataSeekAndRead(CINODE *pInode, uint32_t ulBlock); -REDSTATUS RedInodeDataSeek(CINODE *pInode, uint32_t ulBlock); - -#if REDCONF_API_POSIX == 1 -#if REDCONF_READ_ONLY == 0 -REDSTATUS RedDirEntryCreate(CINODE *pPInode, const char *pszName, uint32_t ulInode); -#endif -#if DELETE_SUPPORTED -REDSTATUS RedDirEntryDelete(CINODE *pPInode, uint32_t ulDeleteIdx); -#endif -REDSTATUS RedDirEntryLookup(CINODE *pPInode, const char *pszName, uint32_t *pulEntryIdx, uint32_t *pulInode); -#if (REDCONF_API_POSIX_READDIR == 1) || (REDCONF_CHECKER == 1) -REDSTATUS RedDirEntryRead(CINODE *pPInode, uint32_t *pulIdx, char *pszName, uint32_t *pulInode); -#endif -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_RENAME == 1) -REDSTATUS RedDirEntryRename(CINODE *pSrcPInode, const char *pszSrcName, CINODE *pSrcInode, CINODE *pDstPInode, const char *pszDstName, CINODE *pDstInode); -#endif -#endif - -REDSTATUS RedVolMount(void); -REDSTATUS RedVolMountMaster(void); -REDSTATUS RedVolMountMetaroot(void); -#if REDCONF_READ_ONLY == 0 -REDSTATUS RedVolTransact(void); -#endif -void RedVolCriticalError(const char *pszFileName, uint32_t ulLineNum); -REDSTATUS RedVolSeqNumIncrement(void); - -#if FORMAT_SUPPORTED -REDSTATUS RedVolFormat(void); -#endif - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/include/redcoremacs.h b/FreeRTOS-Plus/Source/Reliance-Edge/core/include/redcoremacs.h deleted file mode 100755 index 2d1a433..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/include/redcoremacs.h +++ /dev/null @@ -1,92 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file -*/ -#ifndef REDCOREMACS_H -#define REDCOREMACS_H - - -#define BLOCK_NUM_MASTER (0UL) /* Block number of the master block. */ -#define BLOCK_NUM_FIRST_METAROOT (1UL) /* Block number of the first metaroot. */ - -#define BLOCK_SPARSE (0U) - -#define DINDIR_POINTERS ((INODE_ENTRIES - REDCONF_DIRECT_POINTERS) - REDCONF_INDIRECT_POINTERS) -#define DINDIR_DATA_BLOCKS (INDIR_ENTRIES * INDIR_ENTRIES) - -#define INODE_INDIR_BLOCKS (REDCONF_INDIRECT_POINTERS * INDIR_ENTRIES) -#define INODE_DINDIR_BLOCKS (DINDIR_POINTERS * DINDIR_DATA_BLOCKS) -#define INODE_DATA_BLOCKS (REDCONF_DIRECT_POINTERS + INODE_INDIR_BLOCKS + INODE_DINDIR_BLOCKS) -#define INODE_SIZE_MAX (UINT64_SUFFIX(1) * REDCONF_BLOCK_SIZE * INODE_DATA_BLOCKS) - - -/* First inode number that can be allocated. -*/ -#if REDCONF_API_POSIX == 1 -#define INODE_FIRST_FREE (INODE_FIRST_VALID + 1U) -#else -#define INODE_FIRST_FREE (INODE_FIRST_VALID) -#endif - -/** @brief Determine if an inode number is valid. -*/ -#define INODE_IS_VALID(INODENUM) (((INODENUM) >= INODE_FIRST_VALID) && ((INODENUM) < (INODE_FIRST_VALID + gpRedVolConf->ulInodeCount))) - - -/* The number of blocks reserved to allow a truncate or delete operation to - complete when the disk is otherwise full. - - The more expensive of the two operations is delete, which has to actually - write to a file data block to remove the directory entry. -*/ -#if REDCONF_READ_ONLY == 1 - #define RESERVED_BLOCKS 0U -#elif (REDCONF_API_POSIX == 1) && ((REDCONF_API_POSIX_UNLINK == 1) || (REDCONF_API_POSIX_RMDIR == 1)) - #if DINDIR_POINTERS > 0U - #define RESERVED_BLOCKS 3U - #elif REDCONF_INDIRECT_POINTERS > 0U - #define RESERVED_BLOCKS 2U - #else - #define RESERVED_BLOCKS 1U - #endif -#elif ((REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_FTRUNCATE == 1)) || ((REDCONF_API_FSE == 1) && (REDCONF_API_FSE_TRUNCATE == 1)) - #if DINDIR_POINTERS > 0U - #define RESERVED_BLOCKS 2U - #elif REDCONF_INDIRECT_POINTERS > 0U - #define RESERVED_BLOCKS 1U - #else - #define RESERVED_BLOCKS 0U - #endif -#else - #define RESERVED_BLOCKS 0U -#endif - - -#define CRITICAL_ASSERT(EXP) ((EXP) ? (void)0 : CRITICAL_ERROR()) -#define CRITICAL_ERROR() RedVolCriticalError(__FILE__, __LINE__) - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/include/redcorevol.h b/FreeRTOS-Plus/Source/Reliance-Edge/core/include/redcorevol.h deleted file mode 100755 index 2b9ea7b..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/include/redcorevol.h +++ /dev/null @@ -1,95 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file -*/ -#ifndef REDCOREVOL_H -#define REDCOREVOL_H - - -/** @brief Per-volume run-time data specific to the core. -*/ -typedef struct -{ - /** Whether this volume uses the inline imap (true) or external imap - (false). Computed at initialization time based on the block count. - */ - bool fImapInline; - -#if REDCONF_IMAP_EXTERNAL == 1 - /** First block number of the on-disk imap. Valid only when fImapInline - is false. - */ - uint32_t ulImapStartBN; - - /** The number of double-allocated imap nodes that make up the imap. - */ - uint32_t ulImapNodeCount; -#endif - - /** Block number where the inode table starts. - */ - uint32_t ulInodeTableStartBN; - - /** First block number that can be allocated. - */ - uint32_t ulFirstAllocableBN; - - /** The two metaroot structures, committed and working state. - */ - METAROOT aMR[2U]; - - /** The index of the current metaroot; must be 0 or 1. - */ - uint8_t bCurMR; - - /** Whether the volume has been branched or not. - */ - bool fBranched; - - /** The number of blocks which will become free after the next transaction. - */ - uint32_t ulAlmostFreeBlocks; - - #if RESERVED_BLOCKS > 0U - /** Whether to use the blocks reserved for operations that create free - space. - */ - bool fUseReservedBlocks; - #endif -} COREVOLUME; - -/* Pointer to the core volume currently being accessed; populated during - RedCoreVolSetCurrent(). -*/ -extern COREVOLUME * CONST_IF_ONE_VOLUME gpRedCoreVol; - -/* Pointer to the metaroot currently being accessed; populated during - RedCoreVolSetCurrent() and RedCoreVolTransact(). -*/ -extern METAROOT *gpRedMR; - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/core/include/rednodes.h b/FreeRTOS-Plus/Source/Reliance-Edge/core/include/rednodes.h deleted file mode 100755 index 34bc406..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/core/include/rednodes.h +++ /dev/null @@ -1,195 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file -*/ -#ifndef REDNODES_H -#define REDNODES_H - - -#define NODEHEADER_SIZE (16U) -#define NODEHEADER_OFFSET_SIG (0U) -#define NODEHEADER_OFFSET_CRC (4U) -#define NODEHEADER_OFFSET_SEQ (8U) - -/** @brief Common header for all metadata nodes. -*/ -typedef struct -{ - uint32_t ulSignature; /**< Value which uniquely identifies the metadata node type. */ - uint32_t ulCRC; /**< CRC-32 checksum of the node contents, starting after the CRC. */ - uint64_t ullSequence; /**< Current sequence number at the time the node was written to disk. */ -} NODEHEADER; - - -/** Flag set in the master block when REDCONF_API_POSIX == 1. */ -#define MBFLAG_API_POSIX (0x01U) - -/** Flag set in the master block when REDCONF_INODE_TIMESTAMPS == 1. */ -#define MBFLAG_INODE_TIMESTAMPS (0x02U) - -/** Flag set in the master block when REDCONF_INODE_BLOCKS == 1. */ -#define MBFLAG_INODE_BLOCKS (0x04U) - -/** Flag set in the master block when (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_LINK == 1). */ -#define MBFLAG_INODE_NLINK (0x08U) - - -/** @brief Node which identifies the volume and stores static volume information. -*/ -typedef struct -{ - NODEHEADER hdr; /**< Common node header. */ - - uint32_t ulVersion; /**< On-disk layout version number. */ - char acBuildNum[8U]; /**< Build number of the product (not null terminated). */ - uint32_t ulFormatTime; /**< Date and time the volume was formatted. */ - uint32_t ulInodeCount; /**< Compile-time configured number of inodes. */ - uint32_t ulBlockCount; /**< Compile-time configured number of logical blocks. */ - uint16_t uMaxNameLen; /**< Compile-time configured maximum file name length. */ - uint16_t uDirectPointers; /**< Compile-time configured number of direct pointers per inode. */ - uint16_t uIndirectPointers; /**< Compile-time configured number of indirect pointers per inode. */ - uint8_t bBlockSizeP2; /**< Compile-time configured block size, expressed as a power of two. */ - uint8_t bFlags; /**< Compile-time booleans which affect on-disk structures. */ -} MASTERBLOCK; - - -#if REDCONF_API_POSIX == 1 -#define METAROOT_HEADER_SIZE (NODEHEADER_SIZE + 16U) /* Size in bytes of the metaroot header fields. */ -#else -#define METAROOT_HEADER_SIZE (NODEHEADER_SIZE + 12U) /* Size in bytes of the metaroot header fields. */ -#endif -#define METAROOT_ENTRY_BYTES (REDCONF_BLOCK_SIZE - METAROOT_HEADER_SIZE) /* Number of bytes remaining in the metaroot block for entries. */ -#define METAROOT_ENTRIES (METAROOT_ENTRY_BYTES * 8U) - -/** @brief Metadata root node; each volume has two. -*/ -typedef struct -{ - NODEHEADER hdr; /**< Common node header. */ - - uint32_t ulSectorCRC; /**< CRC-32 checksum of the first sector. */ - uint32_t ulFreeBlocks; /**< Number of allocable blocks that are free. */ - #if REDCONF_API_POSIX == 1 - uint32_t ulFreeInodes; /**< Number of inode slots that are free. */ - #endif - uint32_t ulAllocNextBlock; /**< Forward allocation pointer. */ - - /** Imap bitmap. With inline imaps, this is the imap bitmap that indicates - which inode blocks are used and which allocable blocks are used. - Otherwise, this bitmap toggles nodes in the external imap between one - of two possible block locations. - */ - uint8_t abEntries[METAROOT_ENTRY_BYTES]; -} METAROOT; - - -#if REDCONF_IMAP_EXTERNAL == 1 -#define IMAPNODE_HEADER_SIZE (NODEHEADER_SIZE) /* Size in bytes of the imap node header fields. */ -#define IMAPNODE_ENTRY_BYTES (REDCONF_BLOCK_SIZE - IMAPNODE_HEADER_SIZE) /* Number of bytes remaining in the imap node for entries. */ -#define IMAPNODE_ENTRIES (IMAPNODE_ENTRY_BYTES * 8U) - -/** @brief One node of the external imap. -*/ -typedef struct -{ - NODEHEADER hdr; /**< Common node header. */ - - /** Bitmap which indicates which inode blocks are used and which allocable - blocks are used. - */ - uint8_t abEntries[IMAPNODE_ENTRY_BYTES]; -} IMAPNODE; -#endif - - -#define INODE_HEADER_SIZE (NODEHEADER_SIZE + 8U + ((REDCONF_INODE_BLOCKS == 1) ? 4U : 0U) + \ - ((REDCONF_INODE_TIMESTAMPS == 1) ? 12U : 0U) + 4U + ((REDCONF_API_POSIX == 1) ? 4U : 0U)) -#define INODE_ENTRIES ((REDCONF_BLOCK_SIZE - INODE_HEADER_SIZE) / 4U) - -#if (REDCONF_DIRECT_POINTERS < 0) || (REDCONF_DIRECT_POINTERS > (INODE_ENTRIES - REDCONF_INDIRECT_POINTERS)) - #error "Configuration error: invalid value of REDCONF_DIRECT_POINTERS" -#endif -#if (REDCONF_INDIRECT_POINTERS < 0) || (REDCONF_INDIRECT_POINTERS > (INODE_ENTRIES - REDCONF_DIRECT_POINTERS)) - #error "Configuration error: invalid value of REDCONF_INDIRECT_POINTERS" -#endif - -/** @brief Stores metadata for a file or directory. -*/ -typedef struct -{ - NODEHEADER hdr; /**< Common node header. */ - - uint64_t ullSize; /**< Size of the inode, in bytes. */ -#if REDCONF_INODE_BLOCKS == 1 - uint32_t ulBlocks; /**< Total number file data blocks allocated to the inode. */ -#endif -#if REDCONF_INODE_TIMESTAMPS == 1 - uint32_t ulATime; /**< Time of last access (seconds since January 1, 1970). */ - uint32_t ulMTime; /**< Time of last modification (seconds since January 1, 1970). */ - uint32_t ulCTime; /**< Time of last status change (seconds since January 1, 1970). */ -#endif - uint16_t uMode; /**< Inode type (file or directory) and permissions (reserved). */ -#if (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_LINK == 1) - uint16_t uNLink; /**< Link count, number of names pointing to the inode. */ -#else - uint8_t abPadding[2]; /**< Padding to 32-bit align the next member. */ -#endif -#if REDCONF_API_POSIX == 1 - uint32_t ulPInode; /**< Parent inode number. Only guaranteed to be accurate for directories. */ -#endif - - /** Block numbers for lower levels of the file metadata structure. Some - fraction of these entries are for direct pointers (file data block - numbers), some for indirect pointers, some for double-indirect - pointers; the number allocated to each is static but user-configurable. - For all types, an array slot is zero if the range is sparse or beyond - the end of file. - */ - uint32_t aulEntries[INODE_ENTRIES]; -} INODE; - - -#define INDIR_HEADER_SIZE (NODEHEADER_SIZE + 4U) -#define INDIR_ENTRIES ((REDCONF_BLOCK_SIZE - INDIR_HEADER_SIZE) / 4U) - -/** @brief Node for storing block pointers. -*/ -typedef struct -{ - NODEHEADER hdr; /**< Common node header. */ - - uint32_t ulInode; /**< Inode which owns this indirect or double indirect. */ - - /** For indirect nodes, stores block numbers of file data. For double - indirect nodes, stores block numbers of indirect nodes. An array - slot is zero if the corresponding block or indirect range is beyond - the end of file or entirely sparse. - */ - uint32_t aulEntries[INDIR_ENTRIES]; -} INDIR, DINDIR; - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/doc/coding_style.txt b/FreeRTOS-Plus/Source/Reliance-Edge/doc/coding_style.txt deleted file mode 100755 index 569c04e..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/doc/coding_style.txt +++ /dev/null @@ -1,389 +0,0 @@ -Datalight Coding Style -====================== - -This is a description of the Datalight Coding Style intended for third parties -who want to contribute code to Reliance Edge. This document is derived from the -DDSS Coding Guidelines, but only contains a subset of the content which is most -likely to be relevant to third party contributors. - -Reliance Edge complies with the MISRA-C:2012 coding guidelines, which includes -many rules that affect coding style. Unfortunately the MISRA-C:2012 document is -not freely available, and is much too long to be effectively summarized, but if -you are familiar with the rules, adhere to them. A few important rules of -thumb: avoid the goto and continue keywords; avoid using more than one break -in a loop; and avoid having more than one return from a function (single point -of exit); default cases in every switch statement; avoid recursion; and make -generous use of parentheses. Outside of the file system driver, in tests and -host tools, the MISRA-C rules are relaxed. - -Beyond MISRA-C, Datalight has a standard coding style. Most aspects of this -style are matters of preference, but when contributing code to Datalight an -effort should be made to use this style for the sake of consistency. - -Below is an example function, which illustrates several key points of Datalight -Coding Style: - -/** @brief One-sentence description of what this function does. - - Additional description. - - @param ulFirstParameter Description of the parameter. - @param pszPointer Description of the parameter. - - @return Describe the return value. - - @retval true Optional description of specific return value. - @retval false Optional description of specific return value. -*/ -bool ExampleFunction( - uint32_t ulFirstParameter, - char *pszPointer) -{ - bool fStatus = true; - - /* This is a single-line comment. - */ - if(ulFirstParameter > 0U) - { - /* This is a multi-line comment. Filler text: Lorem ipsum dolor sit - amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt - ut labore et dolore magna aliqua. - */ - FunctionCall(); - - while(fStatus) - { - fStatus = AnotherFunction(ulFirstParameter, pszPointer); - } - } - - return fStatus; -} - -Tab Stop Conventions --------------------- - -In all C code (.c/.h), use a tab width of four spaces, and use soft tabs (in -other words, tabs are expanded to spaces). In Makefiles, use hard tabs and a -tab width of 8. - -Naming ------- - -Datalight uses CamelCase for functions and variables. Type names are generally -UPPERCASE, except for standard types like uint32_t. Preprocessor macros are -UPPERCASE, with words separated by underscores (for example, INODE_INVALID). - -Doxygen Documentation ---------------------- - -Doxygen is used to document functions (including static functions), along with -types, structures, files, etc. For Doxygen tags, use '@' instead of a backslash -(thus "@param" not "\param"). - -Function Declarations ---------------------- - -Multi-line function declarations are preferred, as they tend to be more -readable. Use the following form: - -static bool ExampleFunctionDeclaration( - uint32_t ulFirstParameter, - char *pszPointer, - uint8_t **ppbBuffer) -{ - uint16_t uLocalVar; /* descriptive comment */ - uint8_t *pbBuffer = NULL; /* descriptive comment */ - - Function body... -} - -The following guidelines should be used: - -- Align both the data-type and the variable names, for parameters and locals, at - the same level if practical. -- For pointer types, the '*' belongs to the variable name---it's not part of the - data-type, so keep it with the variable name. -- If useful, single line comments may be used to describe local variables (not - a requirement). -- For functions with no parameters, the "void" declaration does not need to be - on a separate line. -- Generally each variable should be declared on a separate line. This promotes - readability, and facilitates having a comment for each variable. - -Function declarations should be spaced apart by two blank lines between the -closing brace which ends a function and the Doxygen comment which starts the -next. - -Curly Braces ------------- - -Datalight lines up all curly braces vertically. As per MISRA-C, curly braces -are never omitted, even if the braces contain only a single statement. - -For consistency, even structure declarations and initializations should use the -same style, with the curly braces lined up vertically. One exception is for -structure initializations where both the opening and closing curly braces can -fit on the same line. If so, do it. - -Code Comments -------------- - -Datalight uses the standard C style /* comments */. C++ style comments (//) are -never used. The Datalight standard comment style is shown below. This style -applies to all general comments within the code. - -/* This is a single-line comment. -*/ -if(ulFirstParameter > 0U) -{ - /* This is a multi-line comment. Filler text: Lorem ipsum dolor sit amet, - consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore - et dolore magna aliqua. - */ - while(fStatus) - { - } -} - -Note the characteristics: - -- The /* and */ align with the natural 4 character indentation. -- The comment text is exactly indented another 4 characters. -- The comment text starts on the same line as the opening /*. -- The terminating */ is on its own line. -- There is usually a single blank line preceding the comment, however if the - preceding line is an opening curly brace, then an extra blank line is not - necessary. -- There is usually no blank line after the comment, but rather the closing */ - "attaches" the comment to the code about which the comment refers. -- These comments should always fit with the standard 80 character margin. - -Comments where the /* and */ are on the same line may be used in a few places: - -- For variable or parameter descriptions, where the comment fits on the same - line as the declaration. -- For structure member declarations, where the comment fits on the same line as - the declaration. -- For macros or preprocessor logic, where the comment fits on the same line. - -It is OK for such comments to exceed the 80 character margin by a small amount, -if necessary, as this sometimes promotes code readability. - -Indentation Style ------------------ - -The general paradigm used in Datalight code is that curly braces line up -vertically, and everything in between them is indented. This should include all -comments, labels, and preprocessor symbols. The only things which are aligned -at the left-most columns are: - -- Symbols, variables, declarations, and preprocessor logic which are at the - module-scope (outside of a function) -- Comments which are outside of a function -- Function declarations -- Function open and closing curly braces - -Typically comments are always lined up directly with the code to which they -apply. - -Labels (when used; gotos are disallowed in driver code) are lined up two -characters to the left of the code they reside in, to make them stand out, while -as the same time, still remaining subservient to the level of curly braces in -which they reside. For example: - -bool ExampleLabelUsage(void) -{ - MutexLock(); - - Lots of complicated code... - - Unlock: - - MutexUnlock(); - - return fSuccess; -} - -Preprocessor logic, such as controlling features which are conditionally -compiled in or out, should not disrupt the flow of the code, but rather should -be indented in similar fashion to the code it controls, but positioned two -characters to the left. For example, consider the following code snippet. The -preprocessor conditions are both indented relative to the outer curly braces, -but do not disrupt the normal code flow. - -int32_t red_statvfs( - const char *pszVolume, - REDSTATFS *pStatvfs) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - uint8_t bVolNum; - - ret = RedPathSplit(pszVolume, &bVolNum, NULL); - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(bVolNum); - } - #endif - - if(ret == 0) - { - ret = RedCoreVolStat(pStatvfs); - } - - PosixLeave(); - } - - return PosixReturn(ret); -} - -Note that, like anything else between curly brackets, the contents of a switch -statement are indented: - -switch(ulSignature) -{ - case META_SIG_MASTER: - fValid = (uFlags == BFLAG_META_MASTER); - break; - case META_SIG_IMAP: - fValid = (uFlags == BFLAG_META_IMAP); - break; - case META_SIG_INODE: - fValid = (uFlags == BFLAG_META_INODE); - break; - case META_SIG_DINDIR: - fValid = (uFlags == BFLAG_META_DINDIR); - break; - case META_SIG_INDIR: - fValid = (uFlags == BFLAG_META_INDIR); - break; - default: - fValid = false; - break; -} - -Maximum Line Length -------------------- - -The maximum line length for code need not be rigidly limited to the traditional -80 characters. Nevertheless the line lengths should be kept reasonable. -Anything longer than 100 to 120 characters should probably be broken up. The -most important consideration is readability---fitting on the screen is important -for readability, but equally important is facilitating an easy understanding of -the logical code flow. - -There are a few exceptions on both sides of the issue. Generally comments -should be limited to 80 characters always. Some lines of code may exceed the -120 character length by a large margin, if it makes the code more understandable -and maintainable. This is especially true when dealing with code that generates -output which needs to be lined up. - -Regardless of everything else, no lines should exceed 250 characters because -some editors cannot handle anything larger. - -Maximum Display Output Line Length ----------------------------------- - -Any code which displays TTY style output, whether on a screen or a terminal, -should be constructed so the output is readable and wraps properly on an 80 -character wide display. This primarily applies to the "standard" output from -various tests and tools as well as syntax output for those tests and tools; -debug output can violate this rule. - -Preprocessor Notation ---------------------- - -Don't use preprocessor notation where the # is separated from the keyword by one -or more white spaces. For example, don't do: - -#ifndef SYMBOL1 -# define SYMBOL1 -#endif - -Instead, do: - -#ifndef SYMBOL1 - #define SYMBOL1 -#endif - -Hexadecimal Notation --------------------- - -Use uppercase for any alphabetic hexadecimal digits, and lower case for the -notational element. For example: - -#define HEXNUM 0x123abd /* Bad */ -#define HEXNUM 0X123ABD /* Bad */ -#define HEXNUM 0x123ABD /* Good */ - -Hungarian Notation ------------------- - -Datalight uses Hungarian notation. The following type prefixes are used: - -Type Prefix | Meaning ------------ | ------- -c | char -uc | unsigned char -i | int -n | unsigned int or size_t -b | uint8_t -u | uint16_t -ul | uint32_t -ull | uint64_t -sz | array of char that will be null-terminated -f | bool -h | A handle -fn | A function (always used with the "p" modifier) - -There is no official Hungarian for int8_t, int16_t, int32_t, or int64_t, -although some code uses unofficial variants (like "ll" for int64_t). - -The following modifiers may be used in combination with the type prefixes -defined above, or in combination with other types: - -Modifier | Meaning --------- | ------- -a | An array -p | A pointer -g | A global variable - -Notes: - -- There is no standard Hungarian for structure declarations, however the use of - the "a" and "p" modifiers is completely appropriate (and expected). -- For those data types which do not have any standard defined Hungarian prefix, - using none is preferable to misusing another prefix which would lead to - confusion. -- The "p" pointer modifier must be used such that a variable which is a pointer - to a pointer uses multiple "p" prefixes. A general rule-of-thumb is that the - variable name should have the same number of "p" prefixes as the declaration - has asterisks. This allows pointer expressions to be easily decoded using - cancellation. - -Variable Scope --------------- - -Declare a variable in the narrowest scope in which it is meaningful. -Unnecessarily declaring all variables at the beginning of a function, where they -may be physically far from where they are actually used, makes the code harder -to maintain. - -When multiple blocks of code share a variable, but not its value, declare the -variable separately for each code block. - -For example, if two separate blocks contain loops indexed by a variable ulIndex -declare it separately in each block rather than declaring it once in a wider -scope and using it in both places. - -Using distinct declarations in the two blocks allows the compiler to check for -failure to initialize the variable in the second block. If there is a single -declaration, the (now meaningless) value left over from the first block can be -used erroneously in the second block. - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/doc/release_notes.md b/FreeRTOS-Plus/Source/Reliance-Edge/doc/release_notes.md deleted file mode 100755 index 2a3d937..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/doc/release_notes.md +++ /dev/null @@ -1,135 +0,0 @@ -# Reliance Edge Release Notes - -This file contains a list of updates made to Reliance Edge over the course of -recent releases and a list of known issues. - -## Release History and Changes - -### Reliance Edge v2.0, January 2017 - -- Added support for Linux as a host environment - - All "host" projects may now be built in either Windows or Linux using the - `make` command. The formatter and image builder are built, and the checker - and image copier are also built in the commercial kit. - - An additional host tool has been added for Linux only: `redfuse`. It is a - File System in User Space (FUSE) implementation, allowing a Reliance Edge - volume to be mounted directly on Linux for easy access. It is built from - the host project folder using the command `make redfuse`. - - The OS-specific API test (commercial kit only) is now ported to run on Linux - for the purpose of verifying the FUSE implementation. -- Fixed a bug that could leave a directory in an invalid state after removing - files. For example, an affected directory might report a non-zero length even - after all files had been deleted. -- Fixed a bug that would leave the driver in a bad state if a mount operation - failed due to missing or corrupt metaroot blocks. - -### Reliance Edge v1.1 (Beta), November 2016 - -- Added support for a discard (trim) interface in the commercial kit. While - discards are not integral to the behavior of the filesystem, they allow - certain types of Flash drivers and media to perform at optimal speed and - efficiency. The commercial version of Reliance Edge now allows the user to - implement this interface for compatible storage media. - - This change added new fields to the configuration files redconf.h and - redconf.c. The configuration utility has been updated to version 1.1 and - existing configuration files must be updated using the updated utility. -- The configuration utility now has keyboard shortcuts for opening and saving - the configuration. -- The configuration utility now adds version macros to easily identify when an - outdated configuration file is used with Reliance Edge or vice versa. - -### Reliance Edge v1.0.4, July 2016 - -- Added ARM mbed and ARM mbed OS support in the commercial kit, with an example - projects for ARM mbed OS on the NXP FRDM-K64F board. -- Some minor deficiencies in the POSIX-like API test suite have been addressed. - -### Reliance Edge v1.0.3, June 2016 - -- Added support for static memory allocation configuration in FreeRTOS - version 9. No common code changes. - -### Reliance Edge v1.0.2, February 2016 - -#### Common Code Changes -- A new per-volume configuration option has been added: users can specify a - number of times to retry a block device read, write or flush operation before - returning a failure. The configuration tool has been updated to version 1.0.2 - with this change. - - This added a new field to the volume configuration in redconf.c: existing - redconf.c files from v1.0.1 and earlier must be updated to work with v1.0.2. - Open redconf.h and redconf.c with the configuration tool, enable - "Retry block device I/O on failure" for any volumes if desired, and save the - redconf files. - -#### FreeRTOS Port Changes -- Added support for the STM32 HAL SD card driver in the FreeRTOS block device - interface. Two boards are supported out-of-the-box: the STM324xG-EVAL and the - STM32F746NG-Discovery. A sample project is included for the STM324xG-EVAL. - -#### MQX Port Changes -- Fixed a bug which prevented Reliance Edge from compiling if the File System - Essentials API was selected in the configuration. -- Fixed a bug which would have returned an uninitialized value from - `RedOsBDevFlush()` for block devices that support flushing. - -### Reliance Edge v1.0.1, October 2015 - -- Added MQX RTOS support in the commercial kit, with example projects for - the Kinetis Design Studio. -- Bug fix in the F_DRIVER implementation of the FreeRTOS block device service. - -### Reliance Edge v1.0, July 2015 - -#### Common Code Changes - -- First release of commercial kit and MISRA C:2012 Design Assurance Package. - The commercial kit includes many new tools and tests which were not previously - available. -- Overhauled parsing of command-line parameters to be consistent for all tools - and tests. Command-line tools now use Unix-style short and long options (such - as `-H` and `--help`) instead of DOS-style switches (such as `/?`). -- Renamed all os/\*/include/ostypes.h headers to os/\*/include/redostypes.h, so - that all headers use the product prefix. If you created a port using v0.9, - this header needs to be renamed and its header guard (#ifndef OSTYPES_H etc.) - should also be updated. -- Add a new header for OS-specific MISRA C:2012 deviation macros, located at - os/\*/include/redosdeviations.h. If you created a port using v0.9, copy the - template from os/stub/include/redosdeviations.h into the include directory. -- Eliminated support for sector sizes less than 256. If using a smaller sector - size (say for a RAM disk), this must now be emulated in the implementation of - the block device OS service. -- Added RedFseFormat() as an optional FSE API, allowing FSE applications to - format the volume at run-time. - - This added a new macro to redconf.h: existing redconf.h files from v0.9 must - be updated to work with v1.0. Open redconf.h with the configuration tool, - ignore the warning about the missing macro, and save it. -- Internal restructuring has renamed the macros for the string and memory - functions used in redconf.h. An existing redconf.h file from v0.9 will need - to be updated; for a file containing the old names, the new config tool will - default to using the (slow) Reliance Edge string/memory functions; to use the - C library or custom versions, this will need to be selected in the - configuration utility. -- Fix a bug which would result in an error when attempting to create a name with - one or more trailing path separators (such as `red_mkdir("/foo/bar/")`). -- Fix a bug where an open handle for an inode on one volume would prevent the - same inode number from being deleted on a different volume. - -#### FreeRTOS Port Changes - -- The implementation of the timestamp OS service no longer requires that - `configUSE_TIMERS` be set to `1`. - -### Reliance Edge v0.9 (Beta), April 2015 - -First public release. - -## Known Issues - -### Visual Studio 2005 - -The Reliance Edge Win32 port (used for the host tools and the Win32 test -project) cannot be compiled by Visual Studio 2005. This is not going to be -fixed since VS2005 is an old toolset. Newer versions of Visual Studio, starting -with Visual Studio 2008, work just fine. - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/doc/release_notes.txt b/FreeRTOS-Plus/Source/Reliance-Edge/doc/release_notes.txt deleted file mode 100755 index 341eb5d..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/doc/release_notes.txt +++ /dev/null @@ -1,156 +0,0 @@ - - -RELIANCE EDGE RELEASE NOTES - - -This file contains a list of updates made to Reliance Edge over the -course of recent releases and a list of known issues. - - -Release History and Changes - -Reliance Edge v2.0, January 2017 - -- Added support for Linux as a host environment -- All "host" projects may now be built in either Windows or Linux - using the make command. The formatter and image builder are built, - and the checker and image copier are also built in the - commercial kit. -- An additional host tool has been added for Linux only: redfuse. It - is a File System in User Space (FUSE) implementation, allowing a - Reliance Edge volume to be mounted directly on Linux for - easy access. It is built from the host project folder using the - command make redfuse. -- The OS-specific API test (commercial kit only) is now ported to run - on Linux for the purpose of verifying the FUSE implementation. -- Fixed a bug that could leave a directory in an invalid state after - removing files. For example, an affected directory might report a - non-zero length even after all files had been deleted. -- Fixed a bug that would leave the driver in a bad state if a mount - operation failed due to missing or corrupt metaroot blocks. - -Reliance Edge v1.1 (Beta), November 2016 - -- Added support for a discard (trim) interface in the commercial kit. - While discards are not integral to the behavior of the filesystem, - they allow certain types of Flash drivers and media to perform at - optimal speed and efficiency. The commercial version of Reliance - Edge now allows the user to implement this interface for compatible - storage media. -- This change added new fields to the configuration files redconf.h - and redconf.c. The configuration utility has been updated to version - 1.1 and existing configuration files must be updated using the - updated utility. -- The configuration utility now has keyboard shortcuts for opening and - saving the configuration. -- The configuration utility now adds version macros to easily identify - when an outdated configuration file is used with Reliance Edge or - vice versa. - -Reliance Edge v1.0.4, July 2016 - -- Added ARM mbed and ARM mbed OS support in the commercial kit, with - an example projects for ARM mbed OS on the NXP FRDM-K64F board. -- Some minor deficiencies in the POSIX-like API test suite have - been addressed. - -Reliance Edge v1.0.3, June 2016 - -- Added support for static memory allocation configuration in FreeRTOS - version 9. No common code changes. - -Reliance Edge v1.0.2, February 2016 - -Common Code Changes - -- A new per-volume configuration option has been added: users can - specify a number of times to retry a block device read, write or - flush operation before returning a failure. The configuration tool - has been updated to version 1.0.2 with this change. -- This added a new field to the volume configuration in redconf.c: - existing redconf.c files from v1.0.1 and earlier must be updated to - work with v1.0.2. Open redconf.h and redconf.c with the - configuration tool, enable "Retry block device I/O on failure" for - any volumes if desired, and save the redconf files. - -FreeRTOS Port Changes - -- Added support for the STM32 HAL SD card driver in the FreeRTOS block - device interface. Two boards are supported out-of-the-box: the - STM324xG-EVAL and the STM32F746NG-Discovery. A sample project is - included for the STM324xG-EVAL. - -MQX Port Changes - -- Fixed a bug which prevented Reliance Edge from compiling if the File - System Essentials API was selected in the configuration. -- Fixed a bug which would have returned an uninitialized value from - RedOsBDevFlush() for block devices that support flushing. - -Reliance Edge v1.0.1, October 2015 - -- Added MQX RTOS support in the commercial kit, with example projects - for the Kinetis Design Studio. -- Bug fix in the F_DRIVER implementation of the FreeRTOS block - device service. - -Reliance Edge v1.0, July 2015 - -Common Code Changes - -- First release of commercial kit and MISRA C:2012 Design - Assurance Package. The commercial kit includes many new tools and - tests which were not previously available. -- Overhauled parsing of command-line parameters to be consistent for - all tools and tests. Command-line tools now use Unix-style short and - long options (such as -H and --help) instead of DOS-style switches - (such as /?). -- Renamed all os/*/include/ostypes.h headers to - os/*/include/redostypes.h, so that all headers use the - product prefix. If you created a port using v0.9, this header needs - to be renamed and its header guard (#ifndef OSTYPES_H etc.) should - also be updated. -- Add a new header for OS-specific MISRA C:2012 deviation macros, - located at os/*/include/redosdeviations.h. If you created a port - using v0.9, copy the template from os/stub/include/redosdeviations.h - into the include directory. -- Eliminated support for sector sizes less than 256. If using a - smaller sector size (say for a RAM disk), this must now be emulated - in the implementation of the block device OS service. -- Added RedFseFormat() as an optional FSE API, allowing FSE - applications to format the volume at run-time. -- This added a new macro to redconf.h: existing redconf.h files from - v0.9 must be updated to work with v1.0. Open redconf.h with the - configuration tool, ignore the warning about the missing macro, and - save it. -- Internal restructuring has renamed the macros for the string and - memory functions used in redconf.h. An existing redconf.h file from - v0.9 will need to be updated; for a file containing the old names, - the new config tool will default to using the (slow) Reliance Edge - string/memory functions; to use the C library or custom versions, - this will need to be selected in the configuration utility. -- Fix a bug which would result in an error when attempting to create a - name with one or more trailing path separators (such as - red_mkdir("/foo/bar/")). -- Fix a bug where an open handle for an inode on one volume would - prevent the same inode number from being deleted on a - different volume. - -FreeRTOS Port Changes - -- The implementation of the timestamp OS service no longer requires - that configUSE_TIMERS be set to 1. - -Reliance Edge v0.9 (Beta), April 2015 - -First public release. - - -Known Issues - -Visual Studio 2005 - -The Reliance Edge Win32 port (used for the host tools and the Win32 test -project) cannot be compiled by Visual Studio 2005. This is not going to -be fixed since VS2005 is an old toolset. Newer versions of Visual -Studio, starting with Visual Studio 2008, work just fine. diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/fse/fse.c b/FreeRTOS-Plus/Source/Reliance-Edge/fse/fse.c deleted file mode 100755 index 1e629e5..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/fse/fse.c +++ /dev/null @@ -1,690 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implementation of the Reliance Edge FSE API. -*/ -#include - -#if REDCONF_API_FSE == 1 - -/** @defgroup red_group_fse The File System Essentials Interface - @{ -*/ - -#include -#include -#include - - -static REDSTATUS FseEnter(uint8_t bVolNum); -static void FseLeave(void); - - -static bool gfFseInited; /* Whether driver is initialized. */ - - -/** @brief Initialize the Reliance Edge file system driver. - - Prepares the Reliance Edge file system driver to be used. Must be the first - Reliance Edge function to be invoked: no volumes can be mounted until the - driver has been initialized. - - If this function is called when the Reliance Edge driver is already - initialized, it does nothing and returns success. - - This function is not thread safe: attempting to initialize from multiple - threads could leave things in a bad state. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -REDSTATUS RedFseInit(void) -{ - REDSTATUS ret; - - if(gfFseInited) - { - ret = 0; - } - else - { - ret = RedCoreInit(); - - if(ret == 0) - { - gfFseInited = true; - } - } - - return ret; -} - - -/** @brief Uninitialize the Reliance Edge file system driver. - - Tears down the Reliance Edge file system driver. Cannot be used until all - Reliance Edge volumes are unmounted. A subsequent call to RedFseInit() - will initialize the driver again. - - If this function is called when the Reliance Edge driver is already - uninitialized, it does nothing and returns success. - - This function is not thread safe: attempting to uninitialize from multiple - threads could leave things in a bad state. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBUSY At least one volume is still mounted. -*/ -REDSTATUS RedFseUninit(void) -{ - REDSTATUS ret = 0; - - if(!gfFseInited) - { - ret = 0; - } - else - { - uint8_t bVolNum; - - #if REDCONF_TASK_COUNT > 1U - RedOsMutexAcquire(); - #endif - - for(bVolNum = 0U; bVolNum < REDCONF_VOLUME_COUNT; bVolNum++) - { - if(gaRedVolume[bVolNum].fMounted) - { - ret = -RED_EBUSY; - break; - } - } - - if(ret == 0) - { - gfFseInited = false; - } - - #if REDCONF_TASK_COUNT > 1U - RedOsMutexRelease(); - #endif - - if(ret == 0) - { - ret = RedCoreUninit(); - } - } - - return ret; -} - - -/** @brief Mount a file system volume. - - Prepares the file system volume to be accessed. Mount will fail if the - volume has never been formatted, or if the on-disk format is inconsistent - with the compile-time configuration. - - If the volume is already mounted, this function does nothing and returns - success. - - @param bVolNum The volume number of the volume to be mounted. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bVolNum is an invalid volume number; or the driver is - uninitialized. - @retval -RED_EIO Volume not formatted, improperly formatted, or corrupt. -*/ -REDSTATUS RedFseMount( - uint8_t bVolNum) -{ - REDSTATUS ret; - - ret = FseEnter(bVolNum); - - if(ret == 0) - { - if(!gpRedVolume->fMounted) - { - ret = RedCoreVolMount(); - } - - FseLeave(); - } - - return ret; -} - - -/** @brief Unmount a file system volume. - - This function discards the in-memory state for the file system and marks it - as unmounted. Subsequent attempts to access the volume will fail until the - volume is mounted again. - - If unmount automatic transaction points are enabled, this function will - commit a transaction point prior to unmounting. If unmount automatic - transaction points are disabled, this function will unmount without - transacting, effectively discarding the working state. - - Before unmounting, this function will wait for any active file system - thread to complete by acquiring the FS mutex. The volume will be marked as - unmounted before the FS mutex is released, so subsequent FS threads will - possibly block and then see an error when attempting to access a volume - which is unmounting or unmounted. - - If the volume is already unmounted, this function does nothing and returns - success. - - @param bVolNum The volume number of the volume to be unmounted. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bVolNum is an invalid volume number; or the driver is - uninitialized. - @retval -RED_EIO I/O error during unmount automatic transaction point. -*/ -REDSTATUS RedFseUnmount( - uint8_t bVolNum) -{ - REDSTATUS ret; - - ret = FseEnter(bVolNum); - - if(ret == 0) - { - if(gpRedVolume->fMounted) - { - ret = RedCoreVolUnmount(); - } - - FseLeave(); - } - - return ret; -} - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_FSE_FORMAT == 1) -/** @brief Format a file system volume. - - Uses the statically defined volume configuration. After calling this - function, the volume needs to be mounted -- see RedFseMount(). - - An error is returned if the volume is mounted. - - @param bVolNum The volume number of the volume to be formatted. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBUSY The volume is mounted. - @retval -RED_EINVAL @p bVolNum is an invalid volume number; or the driver is - uninitialized. - @retval -RED_EIO I/O error formatting the volume. -*/ -REDSTATUS RedFseFormat( - uint8_t bVolNum) -{ - REDSTATUS ret; - - ret = FseEnter(bVolNum); - - if(ret == 0) - { - ret = RedCoreVolFormat(); - - FseLeave(); - } - - return ret; -} -#endif - - -/** @brief Read from a file. - - Data which has not yet been written, but which is before the end-of-file - (sparse data), shall read as zeroes. A short read -- where the number of - bytes read is less than requested -- indicates that the requested read was - partially or, if zero bytes were read, entirely beyond the end-of-file. - - If @p ullFileOffset is at or beyond the maximum file size, it is treated - like any other read entirely beyond the end-of-file: no data is read and - zero is returned. - - @param bVolNum The volume number of the file to read. - @param ulFileNum The file number of the file to read. - @param ullFileOffset The file offset to read from. - @param ulLength The number of bytes to read. - @param pBuffer The buffer to populate with the data read. Must be - at least ulLength bytes in size. - - @return The number of bytes read (nonnegative) or a negated ::REDSTATUS - code indicating the operation result (negative). - - @retval >=0 The number of bytes read from the file. - @retval -RED_EBADF @p ulFileNum is not a valid file number. - @retval -RED_EINVAL @p bVolNum is an invalid volume number or not mounted; - or @p pBuffer is `NULL`; or @p ulLength exceeds - INT32_MAX and cannot be returned properly. - @retval -RED_EIO A disk I/O error occurred. -*/ -int32_t RedFseRead( - uint8_t bVolNum, - uint32_t ulFileNum, - uint64_t ullFileOffset, - uint32_t ulLength, - void *pBuffer) -{ - int32_t ret; - - if(ulLength > (uint32_t)INT32_MAX) - { - ret = -RED_EINVAL; - } - else - { - ret = FseEnter(bVolNum); - } - - if(ret == 0) - { - uint32_t ulReadLen = ulLength; - - ret = RedCoreFileRead(ulFileNum, ullFileOffset, &ulReadLen, pBuffer); - - FseLeave(); - - if(ret == 0) - { - ret = (int32_t)ulReadLen; - } - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Write to a file. - - If the write extends beyond the end-of-file, the file size will be - increased. - - A short write -- where the number of bytes written is less than requested - -- indicates either that the file system ran out of space but was still - able to write some of the request; or that the request would have caused - the file to exceed the maximum file size, but some of the data could be - written prior to the file size limit. - - If an error is returned (negative return), either none of the data was - written or a critical error occurred (like an I/O error) and the file - system volume will be read-only. - - @param bVolNum The volume number of the file to write. - @param ulFileNum The file number of the file to write. - @param ullFileOffset The file offset to write at. - @param ulLength The number of bytes to write. - @param pBuffer The buffer containing the data to be written. Must - be at least ulLength bytes in size. - - @return The number of bytes written (nonnegative) or a negated ::REDSTATUS - code indicating the operation result (negative). - - @retval >0 The number of bytes written to the file. - @retval -RED_EBADF @p ulFileNum is not a valid file number. - @retval -RED_EFBIG No data can be written to the given file offset since - the resulting file size would exceed the maximum file - size. - @retval -RED_EINVAL @p bVolNum is an invalid volume number or not mounted; - or @p pBuffer is `NULL`; or @p ulLength exceeds - INT32_MAX and cannot be returned properly. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC No data can be written because there is insufficient - free space. - @retval -RED_EROFS The file system volume is read-only. -*/ -int32_t RedFseWrite( - uint8_t bVolNum, - uint32_t ulFileNum, - uint64_t ullFileOffset, - uint32_t ulLength, - const void *pBuffer) -{ - int32_t ret; - - if(ulLength > (uint32_t)INT32_MAX) - { - ret = -RED_EINVAL; - } - else - { - ret = FseEnter(bVolNum); - } - - if(ret == 0) - { - uint32_t ulWriteLen = ulLength; - - ret = RedCoreFileWrite(ulFileNum, ullFileOffset, &ulWriteLen, pBuffer); - - FseLeave(); - - if(ret == 0) - { - ret = (int32_t)ulWriteLen; - } - } - - return ret; -} -#endif - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_FSE_TRUNCATE == 1) -/** @brief Truncate a file (set the file size). - - Allows the file size to be increased, decreased, or to remain the same. If - the file size is increased, the new area is sparse (will read as zeroes). - If the file size is decreased, the data beyond the new end-of-file will - return to free space once it is no longer part of the committed state - (either immediately or after the next transaction point). - - This function can fail when the disk is full if @p ullNewFileSize is - non-zero. If decreasing the file size, this can be fixed by transacting and - trying again: Reliance Edge guarantees that it is possible to perform a - truncate of at least one file that decreases the file size after a - transaction point. If disk full transactions are enabled, this will happen - automatically. - - @param bVolNum The volume number of the file to truncate. - @param ulFileNum The file number of the file to truncate. - @param ullNewFileSize The new file size, in bytes. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulFileNum is not a valid file number. - @retval -RED_EFBIG @p ullNewFileSize exceeds the maximum file size. - @retval -RED_EINVAL @p bVolNum is an invalid volume number or not mounted. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOSPC Insufficient free space to perform the truncate. - @retval -RED_EROFS The file system volume is read-only. -*/ -REDSTATUS RedFseTruncate( - uint8_t bVolNum, - uint32_t ulFileNum, - uint64_t ullNewFileSize) -{ - REDSTATUS ret; - - ret = FseEnter(bVolNum); - - if(ret == 0) - { - ret = RedCoreFileTruncate(ulFileNum, ullNewFileSize); - - FseLeave(); - } - - return ret; -} -#endif - - -/** @brief Retrieve the size of a file. - - @param bVolNum The volume number of the file whose size is being read. - @param ulFileNum The file number of the file whose size is being read. - - @return The size of the file (nonnegative) or a negated ::REDSTATUS code - indicating the operation result (negative). - - @retval >=0 The size of the file. - @retval -RED_EBADF @p ulFileNum is not a valid file number. - @retval -RED_EINVAL @p bVolNum is an invalid volume number or not mounted. - @retval -RED_EIO A disk I/O error occurred. -*/ -int64_t RedFseSizeGet( - uint8_t bVolNum, - uint32_t ulFileNum) -{ - int64_t ret; - - ret = FseEnter(bVolNum); - - if(ret == 0) - { - uint64_t ullSize; - - ret = RedCoreFileSizeGet(ulFileNum, &ullSize); - - FseLeave(); - - if(ret == 0) - { - /* Unless there is an on-disk format change, the maximum file size - is guaranteed to be less than INT64_MAX, and so it can be safely - returned in an int64_t. - */ - REDASSERT(ullSize < (uint64_t)INT64_MAX); - - ret = (int64_t)ullSize; - } - } - - return ret; -} - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_FSE_TRANSMASKSET == 1) -/** @brief Update the transaction mask. - - The following events are available: - - - #RED_TRANSACT_UMOUNT - - #RED_TRANSACT_WRITE - - #RED_TRANSACT_TRUNCATE - - #RED_TRANSACT_VOLFULL - - The #RED_TRANSACT_MANUAL macro (by itself) may be used to disable all - automatic transaction events. The #RED_TRANSACT_MASK macro is a bitmask of - all transaction flags, excluding those representing excluded functionality. - - Attempting to enable events for excluded functionality will result in an - error. - - @param bVolNum The volume number of the volume whose transaction mask - is being changed. - @param ulEventMask A bitwise-OR'd mask of automatic transaction events to - be set as the current transaction mode. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bVolNum is an invalid volume number or not mounted; - or @p ulEventMask contains invalid bits. - @retval -RED_EROFS The file system volume is read-only. -*/ -REDSTATUS RedFseTransMaskSet( - uint8_t bVolNum, - uint32_t ulEventMask) -{ - REDSTATUS ret; - - ret = FseEnter(bVolNum); - - if(ret == 0) - { - ret = RedCoreTransMaskSet(ulEventMask); - - FseLeave(); - } - - return ret; -} -#endif - - -#if REDCONF_API_FSE_TRANSMASKGET == 1 -/** @brief Read the transaction mask. - - If the volume is read-only, the returned event mask is always zero. - - @param bVolNum The volume number of the volume whose transaction mask - is being retrieved. - @param pulEventMask Populated with a bitwise-OR'd mask of automatic - transaction events which represent the current - transaction mode for the volume. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bVolNum is an invalid volume number or not mounted; - or @p pulEventMask is `NULL`. -*/ -REDSTATUS RedFseTransMaskGet( - uint8_t bVolNum, - uint32_t *pulEventMask) -{ - REDSTATUS ret; - - ret = FseEnter(bVolNum); - - if(ret == 0) - { - ret = RedCoreTransMaskGet(pulEventMask); - - FseLeave(); - } - - return ret; -} -#endif - - -#if REDCONF_READ_ONLY == 0 -/** @brief Commit a transaction point. - - Reliance Edge is a transactional file system. All modifications, of both - metadata and filedata, are initially working state. A transaction point - is a process whereby the working state atomically becomes the committed - state, replacing the previous committed state. Whenever Reliance Edge is - mounted, including after power loss, the state of the file system after - mount is the most recent committed state. Nothing from the committed - state is ever missing, and nothing from the working state is ever included. - - @param bVolNum The volume number of the volume to transact. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bVolNum is an invalid volume number or not mounted. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EROFS The file system volume is read-only. -*/ -REDSTATUS RedFseTransact( - uint8_t bVolNum) -{ - REDSTATUS ret; - - ret = FseEnter(bVolNum); - - if(ret == 0) - { - ret = RedCoreVolTransact(); - - FseLeave(); - } - - return ret; -} -#endif - -/** @} */ - -/** @brief Enter the file system driver. - - @param bVolNum The volume to be accessed. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL The file system driver is uninitialized; or @p bVolNum - is not a valid volume number. -*/ -static REDSTATUS FseEnter( - uint8_t bVolNum) -{ - REDSTATUS ret; - - if(gfFseInited) - { - #if REDCONF_TASK_COUNT > 1U - RedOsMutexAcquire(); - #endif - - /* This also serves to range-check the volume number (even in single - volume configurations). - */ - ret = RedCoreVolSetCurrent(bVolNum); - - #if REDCONF_TASK_COUNT > 1U - if(ret != 0) - { - RedOsMutexRelease(); - } - #endif - } - else - { - ret = -RED_EINVAL; - } - - return ret; -} - - -/** @brief Leave the file system driver. -*/ -static void FseLeave(void) -{ - REDASSERT(gfFseInited); - - #if REDCONF_TASK_COUNT > 1U - RedOsMutexRelease(); - #endif -} - - -#endif /* REDCONF_API_FSE == 1 */ - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redapimacs.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redapimacs.h deleted file mode 100755 index 0871b4b..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redapimacs.h +++ /dev/null @@ -1,112 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Defines macros used to interact with the Reliance Edge API. -*/ -#ifndef REDAPIMACS_H -#define REDAPIMACS_H - - -/** Clear all events: manual transactions only. */ -#define RED_TRANSACT_MANUAL 0x00000000U - -/** Transact prior to unmounting in red_umount() or RedFseUnmount(). */ -#define RED_TRANSACT_UMOUNT 0x00000001U - -/** Transact after a successful red_open() which created a file. */ -#define RED_TRANSACT_CREAT 0x00000002U - -/** Transact after a successful red_unlink() or red_rmdir(). */ -#define RED_TRANSACT_UNLINK 0x00000004U - -/** Transact after a successful red_mkdir(). */ -#define RED_TRANSACT_MKDIR 0x00000008U - -/** Transact after a successful red_rename(). */ -#define RED_TRANSACT_RENAME 0x00000010U - -/** Transact after a successful red_link(). */ -#define RED_TRANSACT_LINK 0x00000020U - -/** Transact after a successful red_close(). */ -#define RED_TRANSACT_CLOSE 0x00000040U - -/** Transact after a successful red_write() or RedFseWrite(). */ -#define RED_TRANSACT_WRITE 0x00000080U - -/** Transact after a successful red_fsync(). */ -#define RED_TRANSACT_FSYNC 0x00000100U - -/** Transact after a successful red_ftruncate(), RedFseTruncate(), or red_open() with RED_O_TRUNC that actually truncates. */ -#define RED_TRANSACT_TRUNCATE 0x00000200U - -/** Transact to free space in disk full situations. */ -#define RED_TRANSACT_VOLFULL 0x00000400U - -#if REDCONF_READ_ONLY == 1 - -/** Mask of all supported automatic transaction events. */ -#define RED_TRANSACT_MASK 0U - -#elif REDCONF_API_POSIX == 1 - -/** @brief Mask of all supported automatic transaction events. -*/ -#define RED_TRANSACT_MASK \ -( \ - RED_TRANSACT_UMOUNT | \ - RED_TRANSACT_CREAT | \ - ((REDCONF_API_POSIX_UNLINK == 1) ? RED_TRANSACT_UNLINK : 0U) | \ - ((REDCONF_API_POSIX_MKDIR == 1) ? RED_TRANSACT_MKDIR : 0U) | \ - ((REDCONF_API_POSIX_RENAME == 1) ? RED_TRANSACT_RENAME : 0U) | \ - ((REDCONF_API_POSIX_LINK == 1) ? RED_TRANSACT_LINK : 0U) | \ - RED_TRANSACT_CLOSE | \ - RED_TRANSACT_WRITE | \ - RED_TRANSACT_FSYNC | \ - ((REDCONF_API_POSIX_FTRUNCATE == 1) ? RED_TRANSACT_TRUNCATE : 0U) | \ - RED_TRANSACT_VOLFULL \ -) - -#else /* REDCONF_API_FSE == 1 */ - -/** @brief Mask of all supported automatic transaction events. -*/ -#define RED_TRANSACT_MASK \ -( \ - RED_TRANSACT_UMOUNT | \ - RED_TRANSACT_WRITE | \ - ((REDCONF_API_FSE_TRUNCATE == 1) ? RED_TRANSACT_TRUNCATE : 0U) | \ - RED_TRANSACT_VOLFULL \ -) - -#endif /* REDCONF_READ_ONLY */ - -#if (REDCONF_TRANSACT_DEFAULT & RED_TRANSACT_MASK) != REDCONF_TRANSACT_DEFAULT -#error "Configuration error: invalid value of REDCONF_TRANSACT_DEFAULT" -#endif - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redconfigchk.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redconfigchk.h deleted file mode 100755 index 8576a42..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redconfigchk.h +++ /dev/null @@ -1,349 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Compile-time validity checks for the REDCONF macros. -*/ -#ifndef REDCONFIGCHK_H -#define REDCONFIGCHK_H - -#ifdef RED_CONFIG_MINCOMPAT_VER - #if (RED_VERSION_VAL & 0xFFFFFF00U) < (RED_CONFIG_MINCOMPAT_VER & 0xFFFFFF00U) - /* This indicates that your configuration files were generated by a - version of the Reliance Edge Configuration Utility that is designed - for a more recent version of Reliance Edge and is no longer compatible - with this version. You can update to the most recent version of - Reliance Edge or contact RelianceEdgeSupport@datalight.com to obtain - the correct legacy version of the Configuration Utility. - */ - #error "Your configuration is not compatible with this version of Reliance Edge. Please download the latest version of Reliance Edge or recreate your configuration with an older version of the Configuration Utility." - #endif -#endif - -#ifndef REDCONF_READ_ONLY - #error "Configuration error: REDCONF_READ_ONLY must be defined." -#endif -#ifndef REDCONF_API_POSIX - #error "Configuration error: REDCONF_API_POSIX must be defined." -#endif -#ifndef REDCONF_API_FSE - #error "Configuration error: REDCONF_API_FSE must be defined." -#endif - -#if REDCONF_API_POSIX == 1 - #ifndef REDCONF_API_POSIX_FORMAT - #error "Configuration error: REDCONF_API_POSIX_FORMAT must be defined." - #endif - #ifndef REDCONF_API_POSIX_UNLINK - #error "Configuration error: REDCONF_API_POSIX_UNLINK must be defined." - #endif - #ifndef REDCONF_API_POSIX_MKDIR - #error "Configuration error: REDCONF_API_POSIX_MKDIR must be defined." - #endif - #ifndef REDCONF_API_POSIX_RMDIR - #error "Configuration error: REDCONF_API_POSIX_RMDIR must be defined." - #endif - #ifndef REDCONF_API_POSIX_RENAME - #error "Configuration error: REDCONF_API_POSIX_RENAME must be defined." - #endif - #ifndef REDCONF_API_POSIX_LINK - #error "Configuration error: REDCONF_API_POSIX_LINK must be defined." - #endif - #ifndef REDCONF_API_POSIX_FTRUNCATE - #error "Configuration error: REDCONF_API_POSIX_FTRUNCATE must be defined." - #endif - #ifndef REDCONF_API_POSIX_READDIR - #error "Configuration error: REDCONF_API_POSIX_READDIR must be defined." - #endif - #ifndef REDCONF_NAME_MAX - #error "Configuration error: REDCONF_NAME_MAX must be defined." - #endif - #ifndef REDCONF_PATH_SEPARATOR - #error "Configuration error: REDCONF_PATH_SEPARATOR must be defined." - #endif - #ifndef REDCONF_RENAME_ATOMIC - #error "Configuration error: REDCONF_RENAME_ATOMIC must be defined." - #endif - #ifndef REDCONF_HANDLE_COUNT - #error "Configuration error: REDCONF_HANDLE_COUNT must be defined." - #endif -#endif -#if REDCONF_API_FSE == 1 - #ifndef REDCONF_API_FSE_FORMAT - #error "Configuration error: REDCONF_API_FSE_FORMAT must be defined." - #endif - #ifndef REDCONF_API_FSE_TRUNCATE - #error "Configuration error: REDCONF_API_FSE_TRUNCATE must be defined." - #endif - #ifndef REDCONF_API_FSE_TRANSMASKSET - #error "Configuration error: REDCONF_API_FSE_TRANSMASKSET must be defined." - #endif - #ifndef REDCONF_API_FSE_TRANSMASKGET - #error "Configuration error: REDCONF_API_FSE_TRANSMASKGET must be defined." - #endif -#endif - -#ifndef REDCONF_TASK_COUNT - #error "Configuration error: REDCONF_TASK_COUNT must be defined." -#endif -#ifndef REDCONF_ENDIAN_BIG - #error "Configuration error: REDCONF_ENDIAN_BIG must be defined." -#endif -#ifndef REDCONF_ALIGNMENT_SIZE - #error "Configuration error: REDCONF_ALIGNMENT_SIZE must be defined." -#endif -#ifndef REDCONF_CRC_ALGORITHM - #error "Configuration error: REDCONF_CRC_ALGORITHM must be defined." -#endif -#ifndef REDCONF_INODE_TIMESTAMPS - #error "Configuration error: REDCONF_INODE_TIMESTAMPS must be defined." -#endif -#ifndef REDCONF_ATIME - #error "Configuration error: REDCONF_ATIME must be defined." -#endif -#ifndef REDCONF_DIRECT_POINTERS - #error "Configuration error: REDCONF_DIRECT_POINTERS must be defined." -#endif -#ifndef REDCONF_INDIRECT_POINTERS - #error "Configuration error: REDCONF_INDIRECT_POINTERS must be defined." -#endif -#ifndef REDCONF_INODE_BLOCKS - #error "Configuration error: REDCONF_INODE_BLOCKS must be defined." -#endif -#ifndef REDCONF_IMAP_EXTERNAL - #error "Configuration error: REDCONF_IMAP_EXTERNAL must be defined." -#endif -#ifndef REDCONF_IMAP_INLINE - #error "Configuration error: REDCONF_IMAP_INLINE must be defined." -#endif -#ifndef REDCONF_OUTPUT - #error "Configuration error: REDCONF_OUTPUT must be defined." -#endif -#ifndef REDCONF_ASSERTS - #error "Configuration error: REDCONF_ASSERTS must be defined." -#endif -#ifndef REDCONF_TRANSACT_DEFAULT - #error "Configuration error: REDCONF_TRANSACT_DEFAULT must be defined." -#endif -#ifndef REDCONF_BUFFER_COUNT - #error "Configuration error: REDCONF_BUFFER_COUNT must be defined." -#endif -#ifndef REDCONF_BLOCK_SIZE - #error "Configuration error: REDCONF_BLOCK_SIZE must be defined." -#endif -#ifndef REDCONF_VOLUME_COUNT - #error "Configuration error: REDCONF_VOLUME_COUNT must be defined." -#endif -#ifndef REDCONF_DISCARDS - /* Reliance Edge 1.0.5 and below did not have REDCONF_DISCARDS. You can - fix this error by downloading the latest version of the Configuration - Utility (assuming you are using the latest version of Reliance Edge) - from http://www.datalight.com/reliance-edge, loading your redconf.c - and redconf.h files, and saving them again, replacing the original - files. - */ - #error "Configuration error: your redconf.h is not compatible. Update your redconf files with a compatible version of the configuration utility." -#endif -#ifndef REDCONF_IMAGE_BUILDER - #error "Configuration error: REDCONF_IMAGE_BUILDER must be defined." -#endif -#ifndef REDCONF_CHECKER - #error "Configuration error: REDCONF_CHECKER must be defined." -#endif - - -#if (REDCONF_READ_ONLY != 0) && (REDCONF_READ_ONLY != 1) - #error "Configuration error: REDCONF_READ_ONLY must be either 0 or 1" -#endif - -#if (REDCONF_API_POSIX != 0) && (REDCONF_API_POSIX != 1) - #error "Configuration error: REDCONF_API_POSIX must be either 0 or 1." -#endif -#if (REDCONF_API_FSE != 0) && (REDCONF_API_FSE != 1) - #error "Configuration error: REDCONF_API_FSE must be either 0 or 1." -#endif - -#if (REDCONF_API_FSE == 0) && (REDCONF_API_POSIX == 0) - #error "Configuration error: either REDCONF_API_FSE or REDCONF_API_POSIX must be set to 1." -#endif - -#if REDCONF_API_POSIX == 1 - #if REDCONF_API_FSE != 0 - #error "Configuration error: REDCONF_API_FSE must be 0 if REDCONF_API_POSIX is 1" - #endif - - #if (REDCONF_API_POSIX_FORMAT != 0) && (REDCONF_API_POSIX_FORMAT != 1) - #error "Configuration error: REDCONF_API_POSIX_FORMAT must be either 0 or 1." - #endif - - #if (REDCONF_API_POSIX_UNLINK != 0) && (REDCONF_API_POSIX_UNLINK != 1) - #error "Configuration error: REDCONF_API_POSIX_UNLINK must be either 0 or 1." - #endif - - #if (REDCONF_API_POSIX_MKDIR != 0) && (REDCONF_API_POSIX_MKDIR != 1) - #error "Configuration error: REDCONF_API_POSIX_MKDIR must be either 0 or 1." - #endif - - #if (REDCONF_API_POSIX_RMDIR != 0) && (REDCONF_API_POSIX_RMDIR != 1) - #error "Configuration error: REDCONF_API_POSIX_RMDIR must be either 0 or 1." - #endif - - #if (REDCONF_API_POSIX_RENAME != 0) && (REDCONF_API_POSIX_RENAME != 1) - #error "Configuration error: REDCONF_API_POSIX_RENAME must be either 0 or 1." - #endif - - #if (REDCONF_API_POSIX_LINK != 0) && (REDCONF_API_POSIX_LINK != 1) - #error "Configuration error: REDCONF_API_POSIX_LINK must be either 0 or 1." - #endif - - #if (REDCONF_API_POSIX_FTRUNCATE != 0) && (REDCONF_API_POSIX_FTRUNCATE != 1) - #error "Configuration error: REDCONF_API_POSIX_FTRUNCATE must be either 0 or 1." - #endif - - #if (REDCONF_API_POSIX_READDIR != 0) && (REDCONF_API_POSIX_READDIR != 1) - #error "Configuration error: REDCONF_API_POSIX_READDIR must be either 0 or 1." - #endif - - #if (REDCONF_NAME_MAX < 1U) || (REDCONF_NAME_MAX > (REDCONF_BLOCK_SIZE - 4U)) - #error "Configuration error: invalid value of REDCONF_NAME_MAX" - #endif - - #if (REDCONF_PATH_SEPARATOR < 1) || (REDCONF_PATH_SEPARATOR > 127) - #error "Configuration error: invalid value of REDCONF_PATH_SEPARATOR" - #endif - - #if (REDCONF_RENAME_ATOMIC != 0) && (REDCONF_RENAME_ATOMIC != 1) - #error "Configuration error: REDCONF_RENAME_ATOMIC must be either 0 or 1." - #endif - - #if (REDCONF_HANDLE_COUNT < 1U) || (REDCONF_HANDLE_COUNT > 4096U) - #error "Configuration error: invalid value of REDCONF_HANDLE_COUNT" - #endif -#endif -#if REDCONF_API_FSE == 1 - #if (REDCONF_API_FSE_FORMAT != 0) && (REDCONF_API_FSE_FORMAT != 1) - #error "Configuration error: REDCONF_API_FSE_FORMAT must be either 0 or 1." - #endif - - #if (REDCONF_API_FSE_TRUNCATE != 0) && (REDCONF_API_FSE_TRUNCATE != 1) - #error "Configuration error: REDCONF_API_FSE_TRUNCATE must be either 0 or 1." - #endif - - #if (REDCONF_API_FSE_TRANSMASKSET != 0) && (REDCONF_API_FSE_TRANSMASKSET != 1) - #error "Configuration error: REDCONF_API_FSE_TRANSMASKSET must be either 0 or 1." - #endif - - #if (REDCONF_API_FSE_TRANSMASKGET != 0) && (REDCONF_API_FSE_TRANSMASKGET != 1) - #error "Configuration error: REDCONF_API_FSE_TRANSMASKGET must be either 0 or 1." - #endif -#endif - -#if REDCONF_TASK_COUNT < 1U - #error "Configuration error: invalid value of REDCONF_TASK_COUNT" -#endif - -#if (REDCONF_ENDIAN_BIG != 0) && (REDCONF_ENDIAN_BIG != 1) - #error "Configuration error: REDCONF_ENDIAN_BIG must be either 0 or 1." -#endif - -#if (REDCONF_ALIGNMENT_SIZE != 1U) && (REDCONF_ALIGNMENT_SIZE != 2U) && (REDCONF_ALIGNMENT_SIZE != 4U) && (REDCONF_ALIGNMENT_SIZE != 8U) - #error "Configuration error: invalid value REDCONF_ALIGNMENT_SIZE" -#endif - -/* REDCONF_CRC_ALGORITHM checked in crc.c -*/ - -#if (REDCONF_INODE_TIMESTAMPS != 0) && (REDCONF_INODE_TIMESTAMPS != 1) - #error "Configuration error: REDCONF_INODE_TIMESTAMPS must be either 0 or 1." -#endif - -#if (REDCONF_ATIME != 0) && (REDCONF_ATIME != 1) - #error "Configuration error: REDCONF_ATIME must be either 0 or 1." -#endif - -#if (REDCONF_INODE_TIMESTAMPS == 0) && (REDCONF_ATIME == 1) - #error "Configuration error: REDCONF_ATIME must be 0 when REDCONF_INODE_TIMESTAMPS is 0." -#endif - -/* REDCONF_DIRECT_POINTERS and REDCONF_INDIRECT_POINTERS checked in rednodes.h -*/ - -#if (REDCONF_INODE_BLOCKS != 0) && (REDCONF_INODE_BLOCKS != 1) - #error "Configuration error: REDCONF_INODE_BLOCKS must be either 0 or 1." -#endif - -/* Further validity checking of imap specs done in RelCoreInit() -*/ -#if (REDCONF_IMAP_EXTERNAL != 0) && (REDCONF_IMAP_EXTERNAL != 1) - #error "Configuration error: REDCONF_IMAP_EXTERNAL must be either 0 or 1." -#endif -#if (REDCONF_IMAP_INLINE != 0) && (REDCONF_IMAP_INLINE != 1) - #error "Configuration error: REDCONF_IMAP_INLINE must be either 0 or 1." -#endif -#if (REDCONF_IMAP_INLINE == 0) && (REDCONF_IMAP_EXTERNAL == 0) - #error "Configuration error: At least one of REDCONF_IMAP_INLINE and REDCONF_IMAP_EXTERNAL must be set" -#endif - -#if (REDCONF_OUTPUT != 0) && (REDCONF_OUTPUT != 1) - #error "Configuration error: REDCONF_OUTPUT must be either 0 or 1." -#endif - -#if (REDCONF_ASSERTS != 0) && (REDCONF_ASSERTS != 1) - #error "Configuration error: REDCONF_ASSERTS must be either 0 or 1." -#endif - -/* REDCONF_BLOCK_SIZE checked in redmacs.h -*/ - -#if (REDCONF_VOLUME_COUNT < 1U) || (REDCONF_VOLUME_COUNT > 255U) - #error "REDCONF_VOLUME_COUNT must be an integer between 1 and 255" -#endif - -#if (REDCONF_DISCARDS != 0) && (REDCONF_DISCARDS != 1) - #error "Configuration error: REDCONF_DISCARDS must be either 0 or 1." -#endif - -/* REDCONF_BUFFER_COUNT lower limit checked in buffer.c -*/ -#if REDCONF_BUFFER_COUNT > 255U - #error "REDCONF_BUFFER_COUNT cannot be greater than 255" -#endif - -#if (REDCONF_IMAGE_BUILDER != 0) && (REDCONF_IMAGE_BUILDER != 1) - #error "Configuration error: REDCONF_IMAGE_BUILDER must be either 0 or 1." -#endif - -#if (REDCONF_CHECKER != 0) && (REDCONF_CHECKER != 1) - #error "Configuration error: REDCONF_CHECKER must be either 0 or 1." -#endif - - -#if (REDCONF_DISCARDS == 1) && (RED_KIT == RED_KIT_GPL) - #error "REDCONF_DISCARDS not supported in Reliance Edge under GPL. Contact sales@datalight.com to upgrade." -#endif - - -#endif - - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redcoreapi.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redcoreapi.h deleted file mode 100755 index 40ddbbb..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redcoreapi.h +++ /dev/null @@ -1,97 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file -*/ -#ifndef REDCOREAPI_H -#define REDCOREAPI_H - - -#include - - -REDSTATUS RedCoreInit(void); -REDSTATUS RedCoreUninit(void); - -REDSTATUS RedCoreVolSetCurrent(uint8_t bVolNum); - -#if FORMAT_SUPPORTED -REDSTATUS RedCoreVolFormat(void); -#endif -#if REDCONF_CHECKER == 1 -REDSTATUS RedCoreVolCheck(void); -#endif -REDSTATUS RedCoreVolMount(void); -REDSTATUS RedCoreVolUnmount(void); -#if REDCONF_READ_ONLY == 0 -REDSTATUS RedCoreVolTransact(void); -#endif -#if REDCONF_API_POSIX == 1 -REDSTATUS RedCoreVolStat(REDSTATFS *pStatFS); -#endif - -#if (REDCONF_READ_ONLY == 0) && ((REDCONF_API_POSIX == 1) || (REDCONF_API_FSE_TRANSMASKSET == 1)) -REDSTATUS RedCoreTransMaskSet(uint32_t ulEventMask); -#endif -#if (REDCONF_API_POSIX == 1) || (REDCONF_API_FSE_TRANSMASKGET == 1) -REDSTATUS RedCoreTransMaskGet(uint32_t *pulEventMask); -#endif - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) -REDSTATUS RedCoreCreate(uint32_t ulPInode, const char *pszName, bool fDir, uint32_t *pulInode); -#endif -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_LINK == 1) -REDSTATUS RedCoreLink(uint32_t ulPInode, const char *pszName, uint32_t ulInode); -#endif -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) && ((REDCONF_API_POSIX_UNLINK == 1) || (REDCONF_API_POSIX_RMDIR == 1)) -REDSTATUS RedCoreUnlink(uint32_t ulPInode, const char *pszName); -#endif -#if REDCONF_API_POSIX == 1 -REDSTATUS RedCoreLookup(uint32_t ulPInode, const char *pszName, uint32_t *pulInode); -#endif -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_RENAME == 1) -REDSTATUS RedCoreRename(uint32_t ulSrcPInode, const char *pszSrcName, uint32_t ulDstPInode, const char *pszDstName); -#endif -#if REDCONF_API_POSIX == 1 -REDSTATUS RedCoreStat(uint32_t ulInode, REDSTAT *pStat); -#endif -#if REDCONF_API_FSE == 1 -REDSTATUS RedCoreFileSizeGet(uint32_t ulInode, uint64_t *pullSize); -#endif - -REDSTATUS RedCoreFileRead(uint32_t ulInode, uint64_t ullStart, uint32_t *pulLen, void *pBuffer); -#if REDCONF_READ_ONLY == 0 -REDSTATUS RedCoreFileWrite(uint32_t ulInode, uint64_t ullStart, uint32_t *pulLen, const void *pBuffer); -#endif -#if TRUNCATE_SUPPORTED -REDSTATUS RedCoreFileTruncate(uint32_t ulInode, uint64_t ullSize); -#endif - -#if (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_READDIR == 1) -REDSTATUS RedCoreDirRead(uint32_t ulInode, uint32_t *pulPos, char *pszName, uint32_t *pulInode); -#endif - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/reddeviations.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/reddeviations.h deleted file mode 100755 index 1726be6..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/reddeviations.h +++ /dev/null @@ -1,224 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief This header contains macros which deviate from MISRA C:2012 -*/ -#ifndef REDDEVIATIONS_H -#define REDDEVIATIONS_H - - -/** @brief Append a suffix to a constant so that it is an unsigned 64-bit value. - - Usages of this macro deviate from MISRA C:2012 Rule 1.2 (advisory). The - rule prohibits the use of language extensions. The ULL suffix became part - of the C standard with C99. Since this code base adheres to C89, use of - this suffix is a language extension. Reliance Edge needs to deal with - 64-bit quantities, which by convention are explicitly suffixed. In at - least one case, with the INODE_SIZE_MAX macro, the code needs a way to force - a constant to be 64-bits even though its value is not so large that it would - be automatically promoted to 64-bits. Thus the need for this macro and the - deviation. In practice, the ULL suffix has proven to be a nearly universal - extension among C89 compilers. - - As rule 19.2 is advisory, a deviation record is not required. This notice - is the only record of the deviation. PC-Lint does not issue an error for - this deviation so there is no error inhibition option. - - Usages of this macro also deviate from MISRA C:2012 Rule 20.10 (advisory). - The rule prohibits use of the ## preprocessor operator. The code is not - obscure, and the operator is used only once, so this is deemed to be safe. - - As rule 20.10 is advisory, a deviation record is not required. This notice - is the only record of the deviation. - - Consistent use of this macro, even in non MISRA C code, is encouraged to - make it easier to search for 64-bit values. - -*/ -#define UINT64_SUFFIX(number) (number##ULL) - - -/** @brief Append a suffix to a constant so that it is a signed 64-bit value. - - Usages of this macro deviate from MISRA C:2012 Rule 1.2 (advisory). See the - description of UINT64_SUFFIX() for details. - - Usages of this macro deviate from MISRA C:2012 Rule 20.10 (advisory). See - the description of UINT64_SUFFIX() for details. -*/ -#define INT64_SUFFIX(number) (number##LL) - - -/** @brief Cast a pointer to a const uint8_t pointer. - - All usages of this macro deviate from MISRA C:2012 Rule 11.5 (advisory). - Because there are no alignment requirements for a uint8_t pointer, this is - safe. However, it is technically a deviation from the rule. - - As Rule 11.5 is advisory, a deviation record is not required. This notice - and the PC-Lint error inhibition option are the only records of the - deviation. -*/ -#define CAST_VOID_PTR_TO_CONST_UINT8_PTR(PTR) ((const uint8_t *)(PTR)) - - -/** @brief Cast a pointer to a uint8_t pointer. - - All usages of this macro deviate from MISRA C:2012 Rule 11.5 (advisory). - Because there are no alignment requirements for a uint8_t pointer, this is - safe. However, it is technically a deviation from the rule. - - As Rule 11.5 is advisory, a deviation record is not required. This notice - and the PC-Lint error inhibition option are the only records of the - deviation. -*/ -#define CAST_VOID_PTR_TO_UINT8_PTR(PTR) ((uint8_t *)(PTR)) - - -/** @brief Cast a pointer to a const uint32_t pointer. - - Usages of this macro may deviate from MISRA C:2012 Rule 11.5 (advisory). - It is only used in cases where the pointer is known to be aligned, and thus - it is safe to do so. - - As Rule 11.5 is advisory, a deviation record is not required. This notice - and the PC-Lint error inhibition option are the only records of the - deviation. - - Usages of this macro may deviate from MISRA C:2012 Rule 11.3 (required). - As Rule 11.3 is required, a separate deviation record is required. - - Regarding the cast to (const void *): this is there to placate some - compilers which emit warnings when a type with lower alignment requirements - (such as const uint8_t *) is cast to a type with higher alignment - requirements. In the places where this macro is used, the pointer is - checked to be of sufficient alignment. -*/ -#define CAST_CONST_UINT32_PTR(PTR) ((const uint32_t *)(const void *)(PTR)) - - -/** @brief Cast a pointer to a pointer to (void **). - - Usages of this macro deviate from MISRA C:2012 Rule 11.3 (required). - It is only used for populating a node structure pointer with a buffer - pointer. Buffer pointers are 8-byte aligned, thus it is safe to do so. - - As Rule 11.3 is required, a separate deviation record is required. -*/ -#define CAST_VOID_PTR_PTR(PTRPTR) ((void **)(PTRPTR)) - - -/** @brief Create a two-dimensional byte array which is safely aligned. - - Usages of this macro deviate from MISRA C:2012 Rule 19.2 (advisory). - A union is required to force alignment of the block buffers, which are used - to access metadata nodes, which must be safely aligned for 64-bit types. - - As rule 19.2 is advisory, a deviation record is not required. This notice - and the PC-Lint error inhibition option are the only records of the - deviation. -*/ -#define ALIGNED_2D_BYTE_ARRAY(un, nam, size1, size2) \ - union \ - { \ - uint8_t nam[size1][size2]; \ - uint64_t DummyAlign; \ - } un - - -/** @brief Determine whether RedMemMove() must copy memory in the forward - direction, instead of in the reverse. - - In order to copy between overlapping memory regions, RedMemMove() must copy - forward if the destination memory is lower, and backward if the destination - memory is higher. Failure to do so would yield incorrect results. - - The only way to make this determination without gross inefficiency is to - use pointer comparison. Pointer comparisons are undefined unless both - pointers point within the same object or array (or one element past the end - of the array); see section 6.3.8 of ANSI C89. While RedMemMove() is - normally only used when memory regions overlap, which would not result in - undefined behavior, it (like memmove()) is supposed to work even for non- - overlapping regions, which would make this function invoke undefined - behavior. Experience has shown the pointer comparisons of this sort behave - intuitively on common platforms, even though the behavior is undefined. For - those platforms where this is not the case, this implementation of memmove() - should be replaced with an alternate one. - - Usages of this macro deviate from MISRA-C:2012 Rule 18.3 (required). As - Rule 18.3 is required, a separate deviation record is required. -*/ -#define MEMMOVE_MUST_COPY_FORWARD(dest, src) ((dest) < (src)) - - -/** @brief Cast a pointer to a (const DIRENT *). - - Usages of this macro deviate from MISRA-C:2012 Rule 11.3 (required). - It is used for populating a directory entry structure pointer with a - buffer pointer. Buffer pointers are 8-byte aligned, and DIRENT only - requires 4-byte alignment, thus the typecast is safe. - - As Rule 11.3 is required, a separate deviation record is required. -*/ -#define CAST_CONST_DIRENT_PTR(PTR) ((const DIRENT *)(PTR)) - - -/** @brief Determine whether a pointer is aligned. - - A pointer is aligned if its address is an even multiple of - ::REDCONF_ALIGNMENT_SIZE. - - This is used in the slice-by-8 RedCrc32Update() function, which needs to - know whether a pointer is aligned, since the slice-by-8 algorithm needs to - access the memory in an aligned fashion, and if the pointer is not aligned, - this can result in faults or suboptimal performance (depending on platform). - - There is no way to perform this check without deviating from MISRA C rules - against casting pointers to integer types. Usage of this macro deviates - from MISRA C:2012 Rule 11.4 (advisory). The main rationale the rule cites - against converting pointers to integers is that the chosen integer type may - not be able to represent the pointer; this is a non-issue here since we use - uintptr_t. The text says the rule still applies when using uintptr_t due to - concern about unaligned pointers, but that is not an issue here since the - integer value of the pointer is not saved and not converted back into a - pointer and dereferenced. The result of casting a pointer to a sufficiently - large integer is implementation-defined, but macros similar to this one have - been used by Datalight for a long time in a wide variety of environments and - they have always worked as expected. - - As Rule 11.4 is advisory, a deviation record is not required. This notice - and the PC-Lint error inhibition option are the only records of the - deviation. - - @note PC-Lint also thinks this macro as it is used below violates Rule 11.6 - (required). This is a false positive, since Rule 11.6 only applies to - void pointers. Below, we use it on a pointer-to-object (uint8_t *), - which is covered by Rule 11.4. -*/ -#define IS_ALIGNED_PTR(ptr) (((uintptr_t)(ptr) & (REDCONF_ALIGNMENT_SIZE - 1U)) == 0U) - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/rederrno.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/rederrno.h deleted file mode 100755 index 9f462f7..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/rederrno.h +++ /dev/null @@ -1,114 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Error values for Reliance Edge APIs -*/ -#ifndef REDERRNO_H -#define REDERRNO_H - - -/** @brief Return type for Reliance Edge error values. -*/ -typedef int32_t REDSTATUS; - - -/* The errno numbers are the same as Linux. -*/ - -/** Operation not permitted. */ -#define RED_EPERM 1 - -/** No such file or directory. */ -#define RED_ENOENT 2 - -/** I/O error. */ -#define RED_EIO 5 - -/** Bad file number. */ -#define RED_EBADF 9 - -/** Out of memory */ -#define RED_ENOMEM 12 - -/** Device or resource busy. */ -#define RED_EBUSY 16 - -/** File exists. */ -#define RED_EEXIST 17 - -/** Cross-device link. */ -#define RED_EXDEV 18 - -/** Not a directory. */ -#define RED_ENOTDIR 20 - -/** Is a directory. */ -#define RED_EISDIR 21 - -/** Invalid argument. */ -#define RED_EINVAL 22 - -/** File table overflow. */ -#define RED_ENFILE 23 - -/** Too many open files. */ -#define RED_EMFILE 24 - -/** File too large. */ -#define RED_EFBIG 27 - -/** No space left on device. */ -#define RED_ENOSPC 28 - -/** Read-only file system. */ -#define RED_EROFS 30 - -/** Too many links. */ -#define RED_EMLINK 31 - -/** Math result not representable. */ -#define RED_ERANGE 34 - -/** File name too long. */ -#define RED_ENAMETOOLONG 36 - -/** Function not implemented. */ -#define RED_ENOSYS 38 - -/** Directory not empty. */ -#define RED_ENOTEMPTY 39 - -/** No data available. */ -#define RED_ENODATA 61 - -/** Too many users. */ -#define RED_EUSERS 87 - -/** Nothing will be okay ever again. */ -#define RED_EFUBAR RED_EINVAL - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redexclude.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redexclude.h deleted file mode 100755 index c62adb9..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redexclude.h +++ /dev/null @@ -1,53 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file -*/ -#ifndef REDEXCLUDE_H -#define REDEXCLUDE_H - - -#define DELETE_SUPPORTED \ - ( \ - (REDCONF_READ_ONLY == 0) \ - && ( (REDCONF_API_POSIX == 1) \ - && ( (REDCONF_API_POSIX_RMDIR == 1) \ - || (REDCONF_API_POSIX_UNLINK == 1) \ - || ((REDCONF_API_POSIX_RENAME == 1) && (REDCONF_RENAME_ATOMIC == 1))))) - -#define TRUNCATE_SUPPORTED \ - ( \ - (REDCONF_READ_ONLY == 0) \ - && ( ((REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_FTRUNCATE == 1)) \ - || ((REDCONF_API_FSE == 1) && (REDCONF_API_FSE_TRUNCATE == 1)))) - -#define FORMAT_SUPPORTED \ - ( \ - (REDCONF_READ_ONLY == 0) \ - && ( ((REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_FORMAT == 1)) \ - || ((REDCONF_API_FSE == 1) && (REDCONF_API_FSE_FORMAT == 1)) \ - || (REDCONF_IMAGE_BUILDER == 1))) - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redfs.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redfs.h deleted file mode 100755 index 7392157..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redfs.h +++ /dev/null @@ -1,46 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file -*/ -#ifndef REDFS_H -#define REDFS_H - - -#include -#include "redver.h" -#include "redconfigchk.h" -#include -#include "rederrno.h" -#include "reddeviations.h" -#include "redmacs.h" -#include "redapimacs.h" -#include "redutils.h" -#include "redosserv.h" -#include "redmisc.h" -#include "redexclude.h" - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redfse.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redfse.h deleted file mode 100755 index 83234f0..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redfse.h +++ /dev/null @@ -1,105 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Interface for the Reliance Edge FSE API. - - The FSE (File Systems Essentials) API is a minimalist file system API - intended for simple use cases with a fixed number of statically-defined - files. It does not support creating or deleting files dynamically. Files - are referenced by a fixed file number, rather than by name; there are no - file names and no directories. There are also no file handles: files are - not opened or closed, and file offsets are given explicitly. - - If the FSE API is too limited to meet the needs of your application, - consider using the more feature-rich POSIX-like file system API instead. -*/ -#ifndef REDFSE_H -#define REDFSE_H - -/* This header is intended for application use; some applications are written - in C++. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#if REDCONF_API_FSE == 1 - -#include -#include "redapimacs.h" -#include "rederrno.h" - - -/** @brief First valid file number. - - This macro can be used to statically define file numbers for given files, - as in the below example: - - ~~~{.c} - #define LOG_FILE (RED_FILENUM_FIRST_VALID) - #define DATABASE_FILE (RED_FILENUM_FIRST_VALID + 1U) - #define ICON1_FILE (RED_FILENUM_FIRST_VALID + 2U) - #define ICON2_FILE (RED_FILENUM_FIRST_VALID + 3U) - ~~~ -*/ -#define RED_FILENUM_FIRST_VALID (2U) - - -REDSTATUS RedFseInit(void); -REDSTATUS RedFseUninit(void); -REDSTATUS RedFseMount(uint8_t bVolNum); -REDSTATUS RedFseUnmount(uint8_t bVolNum); -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_FSE_FORMAT == 1) -REDSTATUS RedFseFormat(uint8_t bVolNum); -#endif -int32_t RedFseRead(uint8_t bVolNum, uint32_t ulFileNum, uint64_t ullFileOffset, uint32_t ulLength, void *pBuffer); -#if REDCONF_READ_ONLY == 0 -int32_t RedFseWrite(uint8_t bVolNum, uint32_t ulFileNum, uint64_t ullFileOffset, uint32_t ulLength, const void *pBuffer); -#endif -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_FSE_TRUNCATE == 1) -REDSTATUS RedFseTruncate(uint8_t bVolNum, uint32_t ulFileNum, uint64_t ullNewFileSize); -#endif -int64_t RedFseSizeGet(uint8_t bVolNum, uint32_t ulFileNum); -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_FSE_TRANSMASKSET == 1) -REDSTATUS RedFseTransMaskSet(uint8_t bVolNum, uint32_t ulEventMask); -#endif -#if REDCONF_API_FSE_TRANSMASKGET == 1 -REDSTATUS RedFseTransMaskGet(uint8_t bVolNum, uint32_t *pulEventMask); -#endif -#if REDCONF_READ_ONLY == 0 -REDSTATUS RedFseTransact(uint8_t bVolNum); -#endif - -#endif /* REDCONF_API_FSE == 1 */ - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redgetopt.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redgetopt.h deleted file mode 100755 index 96257c7..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redgetopt.h +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * Copyright (c) 2000 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dieter Baron and Thomas Klausner. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/** @file - @brief Interfaces for getopt() and getopt_long() work-alike functions. - - This code was taken from FreeBSD and slightly modified, mostly to rename - symbols with external linkage to avoid naming conflicts in systems where - there are real getopt()/getopt_long() implementations. Changed to use - fixed-width types to allow code using these interfaces to be consistent - with the rest of the product. -*/ -#ifndef REDGETOPT_H -#define REDGETOPT_H - - -#define red_no_argument 0 -#define red_required_argument 1 -#define red_optional_argument 2 - - -/** @brief Specifies a long option. -*/ -typedef struct -{ - /* name of long option */ - const char *name; - /* - * one of red_no_argument, red_required_argument, and red_optional_argument: - * whether option takes an argument - */ - int32_t has_arg; - /* if not NULL, set *flag to val when option found */ - int32_t *flag; - /* if flag not NULL, value to set *flag to; else return value */ - int32_t val; -} REDOPTION; - - -int32_t RedGetopt(int32_t nargc, char * const *nargv, const char *options); -int32_t RedGetoptLong(int32_t nargc, char * const *nargv, const char *options, const REDOPTION *long_options, int32_t *idx); - - -extern const char *red_optarg; -extern int32_t red_optind; -extern int32_t red_opterr; -extern int32_t red_optopt; -extern int32_t red_optreset; - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redmacs.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redmacs.h deleted file mode 100755 index 3b9d358..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redmacs.h +++ /dev/null @@ -1,103 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file -*/ -#ifndef REDMACS_H -#define REDMACS_H - - -#ifndef NULL -#define NULL ((void *)0) -#endif - -#ifndef UINT8_MAX -#define UINT8_MAX (0xFFU) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (0xFFFFU) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (0xFFFFFFFFU) -#endif -#ifndef UINT64_MAX -#define UINT64_MAX UINT64_SUFFIX(0xFFFFFFFFFFFFFFFF) -#endif -#ifndef INT32_MAX -#define INT32_MAX (0x7FFFFFFF) -#endif -#ifndef INT64_MAX -#define INT64_MAX INT64_SUFFIX(0x7FFFFFFFFFFFFFFF) -#endif - -#ifndef true -#define true (1) -#endif -#ifndef false -#define false (0) -#endif - -#define SECTOR_SIZE_MIN (256U) - -#if REDCONF_BLOCK_SIZE == 256U -#define BLOCK_SIZE_P2 8U -#elif REDCONF_BLOCK_SIZE == 512U -#define BLOCK_SIZE_P2 9U -#elif REDCONF_BLOCK_SIZE == 1024U -#define BLOCK_SIZE_P2 10U -#elif REDCONF_BLOCK_SIZE == 2048U -#define BLOCK_SIZE_P2 11U -#elif REDCONF_BLOCK_SIZE == 4096U -#define BLOCK_SIZE_P2 12U -#elif REDCONF_BLOCK_SIZE == 8192U -#define BLOCK_SIZE_P2 13U -#elif REDCONF_BLOCK_SIZE == 16384U -#define BLOCK_SIZE_P2 14U -#elif REDCONF_BLOCK_SIZE == 32768U -#define BLOCK_SIZE_P2 15U -#elif REDCONF_BLOCK_SIZE == 65536U -#define BLOCK_SIZE_P2 16U -#else -#error "REDCONF_BLOCK_SIZE must be a power of two value between 256 and 65536" -#endif - -#define REDMIN(a, b) (((a) < (b)) ? (a) : (b)) - -#define INODE_INVALID (0U) /* General-purpose invalid inode number (must be zero). */ -#define INODE_FIRST_VALID (2U) /* First valid inode number. */ -#define INODE_ROOTDIR (INODE_FIRST_VALID) /* Inode number of the root directory. */ - -/* Expands to a "const" qualifier when the volume count is one, otherwise - expands to nothing. This is useful for variables that never change in - single-volume configurations but do change in multi-volume configurations. -*/ -#if REDCONF_VOLUME_COUNT == 1U - #define CONST_IF_ONE_VOLUME const -#else - #define CONST_IF_ONE_VOLUME -#endif - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redmisc.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redmisc.h deleted file mode 100755 index 018ba04..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redmisc.h +++ /dev/null @@ -1,48 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file -*/ -#ifndef REDMISC_H -#define REDMISC_H - - -/** @brief Type of an inode or handle. - - Used to indicate the actual or expected type of an inode or handle. -*/ -typedef enum -{ - FTYPE_FILE, /**< Type is file. */ - FTYPE_DIR, /**< Type is directory. */ - - /** Type is either file or directory: used only to indicate an expected - type, never as an actual type. - */ - FTYPE_EITHER -} FTYPE; - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redosserv.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redosserv.h deleted file mode 100755 index 14d41d5..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redosserv.h +++ /dev/null @@ -1,86 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file -*/ -#ifndef REDOSSERV_H -#define REDOSSERV_H - - -#include - - -/** @brief Type of access requested when opening a block device. -*/ -typedef enum -{ - BDEV_O_RDONLY, /**< Open block device for read access. */ - BDEV_O_WRONLY, /**< Open block device for write access. */ - BDEV_O_RDWR /**< Open block device for read and write access. */ -} BDEVOPENMODE; - -REDSTATUS RedOsBDevOpen(uint8_t bVolNum, BDEVOPENMODE mode); -REDSTATUS RedOsBDevClose(uint8_t bVolNum); -REDSTATUS RedOsBDevRead(uint8_t bVolNum, uint64_t ullSectorStart, uint32_t ulSectorCount, void *pBuffer); - -#if REDCONF_READ_ONLY == 0 -REDSTATUS RedOsBDevWrite(uint8_t bVolNum, uint64_t ullSectorStart, uint32_t ulSectorCount, const void *pBuffer); -REDSTATUS RedOsBDevFlush(uint8_t bVolNum); -#endif - -/* Non-standard API: for host machines only. -*/ -REDSTATUS RedOsBDevConfig(uint8_t bVolNum, const char *pszBDevSpec); - - -#if REDCONF_TASK_COUNT > 1U -REDSTATUS RedOsMutexInit(void); -REDSTATUS RedOsMutexUninit(void); -void RedOsMutexAcquire(void); -void RedOsMutexRelease(void); -#endif -#if (REDCONF_TASK_COUNT > 1U) && (REDCONF_API_POSIX == 1) -uint32_t RedOsTaskId(void); -#endif - -REDSTATUS RedOsClockInit(void); -REDSTATUS RedOsClockUninit(void); -uint32_t RedOsClockGetTime(void); - -REDSTATUS RedOsTimestampInit(void); -REDSTATUS RedOsTimestampUninit(void); -REDTIMESTAMP RedOsTimestamp(void); -uint64_t RedOsTimePassed(REDTIMESTAMP tsSince); - -#if REDCONF_OUTPUT == 1 -void RedOsOutputString(const char *pszString); -#endif - -#if REDCONF_ASSERTS == 1 -void RedOsAssertFail(const char *pszFileName, uint32_t ulLineNum); -#endif - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redpath.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redpath.h deleted file mode 100755 index 06f7c36..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redpath.h +++ /dev/null @@ -1,38 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Interfaces of path utilities for the POSIX-like API layer. -*/ -#ifndef REDPATH_H -#define REDPATH_H - - -REDSTATUS RedPathSplit(const char *pszPath, uint8_t *pbVolNum, const char **ppszLocalPath); -REDSTATUS RedPathLookup(const char *pszLocalPath, uint32_t *pulInode); -REDSTATUS RedPathToName(const char *pszLocalPath, uint32_t *pulPInode, const char **ppszName); - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redposix.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redposix.h deleted file mode 100755 index 4de7150..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redposix.h +++ /dev/null @@ -1,196 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Interface for the Reliance Edge POSIX-like API. - - The POSIX-like file system API is the primary file system API for - Reliance Edge, which supports the full functionality of the file system. - This API aims to be compatible with POSIX where reasonable, but it is - simplified considerably to meet the needs of resource-constrained embedded - systems. The API has also been extended to provide access to the unique - features of Reliance Edge, and to cover areas (like mountins and formatting) - which do not have APIs in the POSIX specification. -*/ -#ifndef REDPOSIX_H -#define REDPOSIX_H - -/* This header is intended for application use; some applications are written - in C++. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#if REDCONF_API_POSIX == 1 - -#include -#include "redapimacs.h" -#include "rederrno.h" -#include "redstat.h" - -/** Open for reading only. */ -#define RED_O_RDONLY 0x00000001U - -/** Open for writing only. */ -#define RED_O_WRONLY 0x00000002U - -/** Open for reading and writing. */ -#define RED_O_RDWR 0x00000004U - -/** File offset for all writes is end-of-file. */ -#define RED_O_APPEND 0x00000008U - -/** Create the file. */ -#define RED_O_CREAT 0x00000010U - -/** Error if path already exists. */ -#define RED_O_EXCL 0x00000020U - -/** Truncate file to size zero. */ -#define RED_O_TRUNC 0x00000040U - - -/** @brief Last file system error (errno). - - Under normal circumstances, each task using the file system has an - independent `red_errno` value. Applications do not need to worry about - one task obliterating an error value that another task needed to read. The - value is initially zero. When one of the POSIX-like APIs return an - indication of error, `red_errno` is set to an error value. - - In some circumstances, `red_errno` will be a global errno location which - is shared by multiple tasks. If the calling task is not registered as a - file system user and all of the task slots are full, there can be no - task-specific errno, so the global errno is used. Likewise, if the file - system driver is uninitialized, there are no registered file system users - and `red_errno` always refers to the global errno. Under these - circumstances, multiple tasks manipulating `red_errno` could be - problematic. When the task count is set to one, `red_errno` always refers - to the global errno. - - Note that `red_errno` is usable as an lvalue; i.e., in addition to reading - the error value, the error value can be set: - - ~~~{.c} - red_errno = 0; - ~~~ -*/ -#define red_errno (*red_errnoptr()) - - -/** @brief Positions from which to seek within a file. -*/ -typedef enum -{ - /* 0/1/2 are the traditional values for SET/CUR/END, respectively. Prior - to the release of Unix System V in 1983, the SEEK_* symbols did not - exist and C programs hard-coded the 0/1/2 values with those meanings. - */ - RED_SEEK_SET = 0, /**< Set file offset to given offset. */ - RED_SEEK_CUR = 1, /**< Set file offset to current offset plus signed offset. */ - RED_SEEK_END = 2 /**< Set file offset to EOF plus signed offset. */ -} REDWHENCE; - - -#if REDCONF_API_POSIX_READDIR == 1 -/** @brief Opaque directory handle. -*/ -typedef struct sREDHANDLE REDDIR; - - -/** @brief Directory entry information. -*/ -typedef struct -{ - uint32_t d_ino; /**< File serial number (inode number). */ - char d_name[REDCONF_NAME_MAX+1U]; /**< Name of entry. */ - REDSTAT d_stat; /**< File information (POSIX extension). */ -} REDDIRENT; -#endif - - -int32_t red_init(void); -int32_t red_uninit(void); -int32_t red_mount(const char *pszVolume); -int32_t red_umount(const char *pszVolume); -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_FORMAT == 1) -int32_t red_format(const char *pszVolume); -#endif -#if REDCONF_READ_ONLY == 0 -int32_t red_transact(const char *pszVolume); -#endif -#if REDCONF_READ_ONLY == 0 -int32_t red_settransmask(const char *pszVolume, uint32_t ulEventMask); -#endif -int32_t red_gettransmask(const char *pszVolume, uint32_t *pulEventMask); -int32_t red_statvfs(const char *pszVolume, REDSTATFS *pStatvfs); -int32_t red_open(const char *pszPath, uint32_t ulOpenMode); -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_UNLINK == 1) -int32_t red_unlink(const char *pszPath); -#endif -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_MKDIR == 1) -int32_t red_mkdir(const char *pszPath); -#endif -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_RMDIR == 1) -int32_t red_rmdir(const char *pszPath); -#endif -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_RENAME == 1) -int32_t red_rename(const char *pszOldPath, const char *pszNewPath); -#endif -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_LINK == 1) -int32_t red_link(const char *pszPath, const char *pszHardLink); -#endif -int32_t red_close(int32_t iFildes); -int32_t red_read(int32_t iFildes, void *pBuffer, uint32_t ulLength); -#if REDCONF_READ_ONLY == 0 -int32_t red_write(int32_t iFildes, const void *pBuffer, uint32_t ulLength); -#endif -#if REDCONF_READ_ONLY == 0 -int32_t red_fsync(int32_t iFildes); -#endif -int64_t red_lseek(int32_t iFildes, int64_t llOffset, REDWHENCE whence); -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_FTRUNCATE == 1) -int32_t red_ftruncate(int32_t iFildes, uint64_t ullSize); -#endif -int32_t red_fstat(int32_t iFildes, REDSTAT *pStat); -#if REDCONF_API_POSIX_READDIR == 1 -REDDIR *red_opendir(const char *pszPath); -REDDIRENT *red_readdir(REDDIR *pDirStream); -void red_rewinddir(REDDIR *pDirStream); -int32_t red_closedir(REDDIR *pDirStream); -#endif -REDSTATUS *red_errnoptr(void); - -#endif /* REDCONF_API_POSIX */ - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redstat.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redstat.h deleted file mode 100755 index dbbdca3..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redstat.h +++ /dev/null @@ -1,94 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file -*/ -#ifndef REDSTAT_H -#define REDSTAT_H - - -/** Mode bit for a directory. */ -#define RED_S_IFDIR 0x4000U - -/** Mode bit for a regular file. */ -#define RED_S_IFREG 0x8000U - -/** @brief Test for a directory. -*/ -#define RED_S_ISDIR(m) (((m) & RED_S_IFDIR) != 0U) - -/** @brief Test for a regular file. -*/ -#define RED_S_ISREG(m) (((m) & RED_S_IFREG) != 0U) - - -/** File system is read-only. */ -#define RED_ST_RDONLY 0x00000001U - -/** File system ignores suid and sgid bits. */ -#define RED_ST_NOSUID 0x00000002U - - -/** @brief Status information on an inode. -*/ -typedef struct -{ - uint8_t st_dev; /**< Volume number of volume containing file. */ - uint32_t st_ino; /**< File serial number (inode number). */ - uint16_t st_mode; /**< Mode of file. */ - uint16_t st_nlink; /**< Number of hard links to the file. */ - uint64_t st_size; /**< File size in bytes. */ - #if REDCONF_INODE_TIMESTAMPS == 1 - uint32_t st_atime; /**< Time of last access (seconds since 01-01-1970). */ - uint32_t st_mtime; /**< Time of last data modification (seconds since 01-01-1970). */ - uint32_t st_ctime; /**< Time of last status change (seconds since 01-01-1970). */ - #endif - #if REDCONF_INODE_BLOCKS == 1 - uint32_t st_blocks; /**< Number of blocks allocated for this object. */ - #endif -} REDSTAT; - - -/** @brief Status information on a file system volume. -*/ -typedef struct -{ - uint32_t f_bsize; /**< File system block size. */ - uint32_t f_frsize; /**< Fundamental file system block size. */ - uint32_t f_blocks; /**< Total number of blocks on file system in units of f_frsize. */ - uint32_t f_bfree; /**< Total number of free blocks. */ - uint32_t f_bavail; /**< Number of free blocks available to non-privileged process. */ - uint32_t f_files; /**< Total number of file serial numbers. */ - uint32_t f_ffree; /**< Total number of free file serial numbers. */ - uint32_t f_favail; /**< Number of file serial numbers available to non-privileged process. */ - uint32_t f_fsid; /**< File system ID (useless, populated with zero). */ - uint32_t f_flag; /**< Bit mask of f_flag values. Includes read-only file system flag. */ - uint32_t f_namemax; /**< Maximum filename length. */ - uint64_t f_maxfsize; /**< Maximum file size (POSIX extension). */ - uint32_t f_dev; /**< Volume number (POSIX extension). */ -} REDSTATFS; - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redtests.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redtests.h deleted file mode 100755 index 6cd7769..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redtests.h +++ /dev/null @@ -1,265 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Prototypes for Reliance Edge test entry points. -*/ -#ifndef REDTESTS_H -#define REDTESTS_H - -#include -#include "redtestutils.h" -#include "redver.h" - -/* This macro is only defined by the error injection project. -*/ -#ifdef REDCONF_ERROR_INJECTION -#include -#endif - -#define FSSTRESS_SUPPORTED \ - ( ((RED_KIT == RED_KIT_GPL) || (RED_KIT == RED_KIT_SANDBOX)) \ - && (REDCONF_OUTPUT == 1) && (REDCONF_READ_ONLY == 0) && (REDCONF_PATH_SEPARATOR == '/') \ - && (REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_UNLINK == 1) && (REDCONF_API_POSIX_MKDIR == 1) \ - && (REDCONF_API_POSIX_RMDIR == 1) && (REDCONF_API_POSIX_RENAME == 1) && (REDCONF_API_POSIX_LINK == 1) \ - && (REDCONF_API_POSIX_FTRUNCATE == 1) && (REDCONF_API_POSIX_READDIR == 1)) - -#define FSE_STRESS_TEST_SUPPORTED \ - ( ((RED_KIT == RED_KIT_COMMERCIAL) || (RED_KIT == RED_KIT_SANDBOX)) \ - && (REDCONF_OUTPUT == 1) && (REDCONF_READ_ONLY == 0) && (REDCONF_API_FSE == 1) \ - && (REDCONF_API_FSE_FORMAT == 1) && (REDCONF_API_FSE_TRANSMASKSET == 1) && (REDCONF_API_FSE_TRANSMASKGET == 1) \ - && (REDCONF_API_FSE_TRUNCATE == 1)) - -#define POSIX_API_TEST_SUPPORTED \ - ( ((RED_KIT == RED_KIT_COMMERCIAL) || (RED_KIT == RED_KIT_SANDBOX)) \ - && (REDCONF_OUTPUT == 1) && (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) \ - && (REDCONF_API_POSIX_FORMAT == 1) && (REDCONF_API_POSIX_UNLINK == 1)) - -#define FSE_API_TEST_SUPPORTED \ - ( ((RED_KIT == RED_KIT_COMMERCIAL) || (RED_KIT == RED_KIT_SANDBOX)) \ - && (REDCONF_OUTPUT == 1) && (REDCONF_READ_ONLY == 0) && (REDCONF_API_FSE == 1) \ - && (REDCONF_API_FSE_FORMAT == 1)) - -#define STOCH_POSIX_TEST_SUPPORTED \ - ( ((RED_KIT == RED_KIT_COMMERCIAL) || (RED_KIT == RED_KIT_SANDBOX)) \ - && (REDCONF_OUTPUT == 1) && (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) \ - && (REDCONF_API_POSIX_FORMAT == 1) && (REDCONF_API_POSIX_READDIR == 1) \ - && (REDCONF_API_POSIX_MKDIR == 1) && (REDCONF_API_POSIX_RMDIR == 1) && (REDCONF_API_POSIX_UNLINK == 1) \ - && (REDCONF_API_POSIX_RENAME == 1)) - -#define FSIOTEST_SUPPORTED \ - ( ((RED_KIT == RED_KIT_COMMERCIAL) || (RED_KIT == RED_KIT_SANDBOX)) \ - && (REDCONF_OUTPUT == 1) && (REDCONF_API_POSIX == 1)) - -#define BDEVTEST_SUPPORTED \ - ( ((RED_KIT == RED_KIT_COMMERCIAL) || (RED_KIT == RED_KIT_SANDBOX)) \ - && (REDCONF_OUTPUT == 1) && (REDCONF_READ_ONLY == 0)) - -#define DISKFULL_TEST_SUPPORTED \ - ( ((RED_KIT == RED_KIT_COMMERCIAL) || (RED_KIT == RED_KIT_SANDBOX)) \ - && (REDCONF_OUTPUT == 1) && (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX == 1) \ - && (REDCONF_API_POSIX_FORMAT == 1) && (REDCONF_API_POSIX_FTRUNCATE == 1)) - - -typedef enum -{ - PARAMSTATUS_OK, /* Parameters were good; continue. */ - PARAMSTATUS_BAD, /* Parameters were bad; stop. */ - PARAMSTATUS_HELP /* Help request; not an error, but stop. */ -} PARAMSTATUS; - - -#if FSSTRESS_SUPPORTED -typedef struct -{ - bool fNoCleanup; /**< --no-cleanup */ - uint32_t ulLoops; /**< --loops */ - uint32_t ulNops; /**< --nops */ - bool fNamePad; /**< --namepad */ - uint32_t ulSeed; /**< --seed */ - bool fVerbose; /**< --verbose */ -} FSSTRESSPARAM; - -PARAMSTATUS FsstressParseParams(int argc, char *argv[], FSSTRESSPARAM *pParam, uint8_t *pbVolNum, const char **ppszDevice); -void FsstressDefaultParams(FSSTRESSPARAM *pParam); -int FsstressStart(const FSSTRESSPARAM *pParam); -#endif - -#if STOCH_POSIX_TEST_SUPPORTED -typedef struct -{ - const char *pszVolume; /**< Volume path prefix. */ - uint32_t ulIterations; /**< --iterations */ - uint32_t ulFileListMax; /**< --files */ - uint32_t ulDirListMax; /**< --dirs */ - uint32_t ulOpenFileListMax; /**< --open-files */ - uint32_t ulOpenDirListMax; /**< --open-dirs */ - uint32_t ulRandomSeed; /**< --seed */ -} STOCHPOSIXPARAM; - -PARAMSTATUS RedStochPosixParseParams(int argc, char *argv[], STOCHPOSIXPARAM *pParam, uint8_t *pbVolNum, const char **ppszDevice); -void RedStochPosixDefaultParams(STOCHPOSIXPARAM *pParam); -int RedStochPosixStart(const STOCHPOSIXPARAM *pParam); -#endif - -#if FSE_STRESS_TEST_SUPPORTED -typedef struct -{ - uint8_t bVolNum; /**< Volume number. */ - uint32_t ulFileCount; /**< --files */ - uint32_t ulMaxFileSize; /**< --max */ - uint32_t ulMaxOpSize; /**< --buffer-size */ - uint32_t ulNops; /**< --nops */ - uint32_t ulLoops; /**< --loops */ - uint32_t ulSampleRate; /**< --sample-rate */ - uint64_t ullSeed; /**< --seed */ -} FSESTRESSPARAM; - -PARAMSTATUS FseStressParseParams(int argc, char *argv[], FSESTRESSPARAM *pParam, uint8_t *pbVolNum, const char **ppszDevice); -void FseStressDefaultParams(FSESTRESSPARAM *pParam); -int FseStressStart(const FSESTRESSPARAM *pParam); -#endif - -#if POSIX_API_TEST_SUPPORTED -typedef struct -{ - const char *pszVolume; /**< Volume path prefix. */ - bool fQuick; /**< --quick */ - bool fQuitOnFailure; /**< --quit-on-failure */ - bool fDebugErrors; /**< --debug */ -} POSIXTESTPARAM; - -PARAMSTATUS RedPosixTestParseParams(int argc, char *argv[], POSIXTESTPARAM *pParam, uint8_t *pbVolNum, const char **ppszDevice); -void RedPosixTestDefaultParams(POSIXTESTPARAM *pParam); -int RedPosixTestStart(const POSIXTESTPARAM *pParam); -#endif - - -#if POSIX_API_TEST_SUPPORTED -typedef struct -{ - const char *pszVolume; /**< Volume path prefix. */ - bool fQuick; /**< --quick */ - bool fVerbose; /**< --verbose */ - bool fQuitOnFailure; /**< --quit-on-failure */ - bool fDebugErrors; /**< --debug */ -} OSAPITESTPARAM; - -PARAMSTATUS RedOsApiTestParseParams(int argc, char *argv[], OSAPITESTPARAM *pParam, const char **ppszDevice); -void RedOsApiTestDefaultParams(OSAPITESTPARAM *pParam); -int RedOsApiTestStart(const OSAPITESTPARAM *pParam); -#endif - - -#if FSE_API_TEST_SUPPORTED -typedef struct -{ - uint8_t bVolNum; /**< Volume number. */ - bool fQuitOnFailure; /**< --quit-on-failure */ - bool fDebugErrors; /**< --debug */ -} FSETESTPARAM; - -PARAMSTATUS RedFseTestParseParams(int argc, char *argv[], FSETESTPARAM *pParam, uint8_t *pbVolNum, const char **ppszDevice); -void RedFseTestDefaultParams(FSETESTPARAM *pParam); -int RedFseTestStart(const FSETESTPARAM *pParam); -#endif - -#if FSIOTEST_SUPPORTED -typedef enum -{ - TESTFS_RELEDGE, /* Datalight Reliance Edge */ - TESTFS_FATFS, /* ChaN's FatFs */ - TESTFS_FATSL /* FreeRTOS+FAT SL */ -} TESTFS; - -typedef struct -{ - TESTFS testfs; /**< --fs */ - const char *pszVolume; /**< Volume path prefix. */ - bool fSeqRead; /**< --seq=r */ - bool fSeqWrite; /**< --seq=w */ - bool fSeqRewrite; /**< --seq=e */ - bool fRandomRead; /**< --rand=r */ - bool fRandomWrite; /**< --rand=w */ - bool fMixedWrite; /**< --mixed */ - bool fScanTest; /**< --scan */ - uint32_t ulFSBlockSize; /**< --block-size */ - uint32_t ulMaxFileSize; /**< --max */ - uint32_t ulRandomReadPasses; /**< --rand-pass=r:w (r part) */ - uint32_t ulRandomWritePasses; /**< --rand-pass=r:w (w part) */ - uint32_t ulMixedWritePasses; /**< --mixed-pass */ - int32_t iFlushOnWriteRatio; /**< --rand-fow */ - uint32_t ulBufferMin; /**< --start */ - uint32_t ulBufferSize; /**< --buffer-size */ - bool fWriteVerify; /**< --verify */ - uint32_t ulSampleRate; /**< --sample-rate */ - uint32_t ulScanCount; /**< --scan-files */ - uint64_t ullSeed; /**< --seed */ -} FSIOTESTPARAM; - -PARAMSTATUS FSIOTestParseParams(int argc, char *argv[], FSIOTESTPARAM *pParam, uint8_t *pbVolNum, const char **ppszDevice); -void FSIOTestDefaultParams(FSIOTESTPARAM *pParam); -int FSIOTestStart(const FSIOTESTPARAM *pParam); -#endif - -#if BDEVTEST_SUPPORTED -typedef struct -{ - uint8_t bDrvNum; /**< Volume number (for sector size/count). */ - bool fSeqWrite; /**< --seq:w */ - bool fSeqRead; /**< --seq:r */ - bool fRandWrite; /**< --rand:w */ - bool fRandRead; /**< --rand:r */ - uint32_t ulSampleSecs; /**< --sample-rate */ - uint32_t ulPasses; /**< --passes */ - uint32_t ulMinIOSectors; /**< --count=min[:max] (min part) */ - uint32_t ulMaxIOSectors; /**< --count=min[:max] (max part) */ - uint32_t ulMaxSizeKB; /**< --max */ - uint32_t ulTestSeconds; /**< --time */ - bool fVerify; /**< --verify */ - bool fAsyncWrites; /**< --async */ - uint64_t ullSeed; /**< --seed */ -} BDEVTESTPARAM; - -PARAMSTATUS BDevTestParseParams(int argc, char *argv[], BDEVTESTPARAM *pParam, uint8_t *pbVolNum, const char **ppszDevice); -void BDevTestDefaultParams(BDEVTESTPARAM *pParam); -int BDevTestStart(const BDEVTESTPARAM *pParam); -#endif - -#if DISKFULL_TEST_SUPPORTED -typedef struct -{ - const char *pszVolume; /**< Volume path prefix. */ - bool fQuitOnFailure; /**< --quit-on-failure */ - bool fDebugErrors; /**< --debug */ -} DISKFULLTESTPARAM; - -PARAMSTATUS DiskFullTestParseParams(int argc, char *argv[], DISKFULLTESTPARAM *pParam, uint8_t *pbVolNum, const char **ppszDevice); -void DiskFullTestDefaultParams(DISKFULLTESTPARAM *pParam); -int DiskFullTestStart(const DISKFULLTESTPARAM *pParam); -#endif - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redtestutils.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redtestutils.h deleted file mode 100755 index ca5e740..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redtestutils.h +++ /dev/null @@ -1,71 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Reliance Edge utilities only needed for tests. -*/ -#ifndef REDTESTUTILS_H -#define REDTESTUTILS_H - - -#define ISDIGIT(c) (((c) >= '0') && ((c) <= '9')) - - -void RedRandSeed(uint64_t ullSeed); -uint64_t RedRand64(uint64_t *pullSeed); -uint32_t RedRand32(uint32_t *pulSeed); - -char *RedRatio(char *pBuffer, uint32_t ulBufferLen, uint64_t ullDividend, uint64_t ullDivisor, uint32_t ulDecPlaces); -uint64_t RedMulDiv64(uint64_t ullBase, uint32_t ulMultiplier, uint64_t ullDivisor); -uint64_t RedUint64DivMod32(uint64_t ullDividend, uint32_t ulDivisor, uint32_t *pulRemainder); -uint64_t RedUint64DivMod64(uint64_t ullDividend, uint64_t ullDivisor, uint64_t *pullRemainder); - -char *RedScaleBytes(uint32_t ulByteValue, char *pszBuffer, uint32_t ulBufferSize); -char *RedScaleKB(uint32_t ulKBValue, char *pszBuffer, uint32_t ulBufferSize); -uint32_t RedGetKBPerSecond(uint64_t ullKB, uint32_t ulMS); -uint32_t RedGetKBPerSecondSectors(uint32_t ulBytesPerSector, uint64_t ullSectors, uint64_t ullUS); - -int32_t RedAtoI(const char *pszNum); -const char *RedHtoUL(const char *pszNum, uint32_t *pulNum); -const char *RedHtoULL(const char *pszNum, uint64_t *pullNum); -const char *RedNtoUL(const char *pszNum, uint32_t *pulNum); -const char *RedNtoULL(const char *pszNum, uint64_t *pullNum); -const char *RedSizeToUL(const char *pszNum, uint32_t *pulResult); - -int32_t RedStrICmp(const char *pszStr1, const char *pszStr2); -int32_t RedStrNICmp(const char *pszStr1, const char *pszStr2, uint32_t ulLen); -char RedToLower(char c); - -#include - -#if REDCONF_OUTPUT == 1 -void RedPrintf(const char *pszFormat, ...); -void RedVPrintf(const char *pszFormat, va_list arglist); -#endif -int32_t RedSNPrintf(char *pcBuffer, uint32_t ulBufferLen, const char *pszFormat, ...); -int32_t RedVSNPrintf(char *pcBuffer, uint32_t ulBufferLen, const char *pszFormat, va_list arglist); - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redtoolcmn.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redtoolcmn.h deleted file mode 100755 index a89096e..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redtoolcmn.h +++ /dev/null @@ -1,37 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Interfaces for common-code utilities for tools and tests. -*/ -#ifndef REDTOOLCMN_H -#define REDTOOLCMN_H - - -uint8_t RedFindVolumeNumber(const char *pszVolume); -bool RedConfirmOperation(const char *pszMessage); - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redtools.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redtools.h deleted file mode 100755 index f80ffb1..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redtools.h +++ /dev/null @@ -1,183 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -#ifndef REDTOOLS_H -#define REDTOOLS_H - - -#ifdef _WIN32 - #include - #define HOST_PATH_MAX MAX_PATH -#else - #include - #define HOST_PATH_MAX PATH_MAX -#endif - - -#if REDCONF_IMAGE_BUILDER == 1 - -#define MACRO_NAME_MAX_LEN 32 - -typedef struct -{ - uint8_t bVolNumber; - const char *pszInputDir; - const char *pszOutputFile; - #if REDCONF_API_POSIX == 1 - const char *pszVolName; - #else - const char *pszMapFile; - const char *pszDefineFile; - bool fNowarn; - #endif -} IMGBLDPARAM; - - -void ImgbldParseParams(int argc, char *argv [], IMGBLDPARAM *pParam); -int ImgbldStart(IMGBLDPARAM *pParam); - - -typedef struct -{ - #if REDCONF_API_POSIX == 1 - char asOutFilePath[HOST_PATH_MAX]; - #else - uint32_t ulOutFileIndex; - #endif - char asInFilePath[HOST_PATH_MAX]; -} FILEMAPPING; - - -extern void *gpCopyBuffer; -extern uint32_t gulCopyBufferSize; - - -/* Implemented in ibposix.c -*/ -#if REDCONF_API_POSIX == 1 -REDSTATUS IbPosixCopyDir(const char *pszVolName, const char *pszInDir); -int IbPosixCreateDir(const char *pszVolName, const char *pszFullPath, const char *pszBasePath); -int IbConvertPath(const char *pszVolName, const char *pszFullPath, const char *pszBasePath, char *szOutPath); -#endif - - -/* Implemented in ibfse.c -*/ -#if REDCONF_API_FSE == 1 -typedef struct sFILELISTENTRY FILELISTENTRY; -struct sFILELISTENTRY -{ - FILEMAPPING fileMapping; - FILELISTENTRY *pNext; -}; - - -void FreeFileList(FILELISTENTRY **ppsFileList); - -int IbFseGetFileList(const char *pszPath, const char *pszIndirPath, FILELISTENTRY **ppFileListHead); -int IbFseOutputDefines(FILELISTENTRY *pFileList, const IMGBLDPARAM *pOptions); -int IbFseCopyFiles(int volNum, const FILELISTENTRY *pFileList); -#endif - - -/* Implemented in os-specific space (ibwin.c and iblinux.c) -*/ -#if REDCONF_API_POSIX == 1 -int IbPosixCopyDirRecursive(const char *pszVolName, const char *pszInDir); -#endif -#if REDCONF_API_FSE == 1 -int IbFseBuildFileList(const char *pszDirPath, FILELISTENTRY **ppFileListHead); -#endif -#if REDCONF_API_FSE == 1 -int IbSetRelativePath(char *pszPath, const char *pszParentPath); -#endif -bool IsRegularFile(const char *pszPath); - - -/* Implemented in ibcommon.c -*/ -int IbCopyFile(int volNum, const FILEMAPPING *pFileMapping); -int IbCheckFileExists(const char *pszPath, bool *pfExists); - - -/* Implemented separately in ibfse.c and ibposix.c -*/ -int IbApiInit(void); -int IbApiUninit(void); -int IbWriteFile(int volNum, const FILEMAPPING *pFileMapping, uint64_t ullOffset, void *pData, uint32_t ulDataLen); - -#endif /* IMAGE_BUILDER */ - -/* For image copier tool -*/ - -#ifdef _WIN32 - #define HOST_PSEP '\\' - #if !__STDC__ - #define snprintf _snprintf - #define stat _stat - #define S_IFDIR _S_IFDIR - #define rmdir _rmdir - #endif -#else - #define HOST_PSEP '/' -#endif - -typedef struct -{ - uint8_t bVolNumber; - const char *pszOutputDir; - const char *pszBDevSpec; - #if REDCONF_API_POSIX == 1 - const char *pszVolName; - #endif - bool fNoWarn; -} IMGCOPYPARAM; - -typedef struct -{ - #if REDCONF_API_POSIX == 1 - const char *pszVolume; /* Volume path prefix. */ - uint32_t ulVolPrefixLen; /* strlen(COPIER::pszVolume) */ - #else - uint8_t bVolNum; /* Volume number. */ - #endif - const char *pszOutputDir; /* Output directory path. */ - bool fNoWarn; /* If true, no warning to overwrite. */ - uint8_t *pbCopyBuffer; /* Buffer for copying file data. */ -} COPIER; - - -void ImgcopyParseParams(int argc, char *argv [], IMGCOPYPARAM *pParam); -int ImgcopyStart(IMGCOPYPARAM *pParam); - -/* Implemented separately in imgcopywin.c and imgcopylinux.c. These functions - print an error message and abort on failure. -*/ -void ImgcopyMkdir(const char *pszDir); -void ImgcopyRecursiveRmdir(const char *pszDir); - - -#endif /* REDTOOLS_H */ - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redutils.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redutils.h deleted file mode 100755 index 35f8d2c..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redutils.h +++ /dev/null @@ -1,71 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file -*/ -#ifndef REDUTILS_H -#define REDUTILS_H - - -#if REDCONF_ASSERTS == 1 -#define REDERROR() RedOsAssertFail(__FILE__, __LINE__) -#define REDASSERT(EXP) ((EXP) ? (void)0 : REDERROR()) -#else -#define REDERROR() ((void)0) -#define REDASSERT(EXP) ((void)0) -#endif - - -void RedMemCpy(void *pDest, const void *pSrc, uint32_t ulLen); -void RedMemMove(void *pDest, const void *pSrc, uint32_t ulLen); -void RedMemSet(void *pDest, uint8_t bVal, uint32_t ulLen); -int32_t RedMemCmp(const void *pMem1, const void *pMem2, uint32_t ulLen); - -uint32_t RedStrLen(const char *pszStr); -int32_t RedStrCmp(const char *pszStr1, const char *pszStr2); -int32_t RedStrNCmp(const char *pszStr1, const char *pszStr2, uint32_t ulLen); -void RedStrNCpy(char *pszDst, const char *pszSrc, uint32_t ulLen); - -uint32_t RedCrc32Update(uint32_t ulInitCrc32, const void *pBuffer, uint32_t ulLength); -uint32_t RedCrcNode(const void *pBuffer); - -#if REDCONF_API_POSIX == 1 -uint32_t RedNameLen(const char *pszName); -#endif - -bool RedBitGet(const uint8_t *pbBitmap, uint32_t ulBit); -void RedBitSet(uint8_t *pbBitmap, uint32_t ulBit); -void RedBitClear(uint8_t *pbBitmap, uint32_t ulBit); - -#ifdef REDCONF_ENDIAN_SWAP -uint64_t RedRev64(uint64_t ullToRev); -uint32_t RedRev32(uint32_t ulToRev); -uint16_t RedRev16(uint16_t uToRev); -#endif - -void RedSignOn(void); - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redver.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redver.h deleted file mode 100755 index 28793a6..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redver.h +++ /dev/null @@ -1,111 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Macros for version numbers, build number, and product information. -*/ -#ifndef REDVER_H -#define REDVER_H - - -/** @brief Consecutive number assigned to each automated build. - - -*/ -#define RED_BUILD_NUMBER "700" - -#define RED_KIT_GPL 0U /* Open source GPL kit. */ -#define RED_KIT_COMMERCIAL 1U /* Commercially-licensed kit. */ -#define RED_KIT_SANDBOX 2U /* Not a kit: developer sandbox. */ - -/** @brief Indicates the Reliance Edge kit. - - -*/ -#define RED_KIT RED_KIT_GPL - - -/** @brief Version number to display in output. -*/ -#define RED_VERSION "v2.0" - -/** @brief Version number in hex. - - The most significant byte is the major version number, etc. -*/ -#define RED_VERSION_VAL 0x02000000U - -/** @brief On-disk version number. - - This is incremented only when the on-disk layout is updated in such a way - which is incompatible with previously released versions of the file system. -*/ -#define RED_DISK_LAYOUT_VERSION 1U - - -/** @brief Base name of the file system product. -*/ -#define RED_PRODUCT_BASE_NAME "Reliance Edge" - - -/* Specifies whether the product is in alpha stage, beta stage, or neither. -*/ -#if 0 - #if 0 - #define ALPHABETA " (Alpha)" - #else - #define ALPHABETA " (Beta)" - #endif -#else - #define ALPHABETA "" -#endif - -/** @brief Full product name and version. -*/ -#define RED_PRODUCT_NAME "Datalight " RED_PRODUCT_BASE_NAME " " RED_VERSION " Build " RED_BUILD_NUMBER ALPHABETA - - -/** @brief Product copyright. -*/ -#define RED_PRODUCT_LEGAL "Copyright (c) 2014-2017 Datalight, Inc. All Rights Reserved Worldwide." - - -/** @brief Product patents. -*/ -#define RED_PRODUCT_PATENT "Patents: US#7284101." - - -/** @brief Product edition. -*/ -#if RED_KIT == RED_KIT_GPL -#define RED_PRODUCT_EDITION "Open-Source GPLv2 Edition -- Compiled " __DATE__ " at " __TIME__ -#elif RED_KIT == RED_KIT_COMMERCIAL -#define RED_PRODUCT_EDITION "Commercial Edition -- Compiled " __DATE__ " at " __TIME__ -#else -#define RED_PRODUCT_EDITION "Developer Sandbox -- Compiled " __DATE__ " at " __TIME__ -#endif - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/include/redvolume.h b/FreeRTOS-Plus/Source/Reliance-Edge/include/redvolume.h deleted file mode 100755 index 266cf5e..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/include/redvolume.h +++ /dev/null @@ -1,141 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file -*/ -#ifndef REDVOLUME_H -#define REDVOLUME_H - - -/** @brief Per-volume configuration structure. - - Contains the configuration values that may differ between volumes. Must be - declared in an array in redconf.c in the Reliance Edge project directory and - statically initialized with values representing the volume configuration of - the target system. -*/ -typedef struct -{ - /** The sector size for the block device underlying the volume: the basic - unit for reading and writing to the storage media. Commonly ranges - between 512 and 4096, but any power-of-two value not greater than the - block size will work. - */ - uint32_t ulSectorSize; - - /** The number of sectors in this file system volume. - */ - uint64_t ullSectorCount; - - /** Whether a sector write on the block device underlying the volume is - atomic. It is atomic if when the sector write is interrupted, the - contents of the sector are guaranteed to be either all of the new data, - or all of the old data. If unsure, leave as false. - */ - bool fAtomicSectorWrite; - - /** This is the maximum number of inodes (files and directories). This - number includes the root directory inode (inode 2; created during - format), but does not include inodes 0 or 1, which do not exist on - disk. The number of inodes cannot be less than 1. - */ - uint32_t ulInodeCount; - - /** This is the maximum number of times a block device I/O operation will - be retried. If a block device read, write, or flush fails, Reliance - Edge will try again up to this number of times until the operation is - successful. Set this to 0 to disable retries. - */ - uint8_t bBlockIoRetries; - - #if REDCONF_API_POSIX == 1 - /** The path prefix for the volume; for example, "VOL1:", "FlashDisk", etc. - */ - const char *pszPathPrefix; - #endif -} VOLCONF; - -extern const VOLCONF gaRedVolConf[REDCONF_VOLUME_COUNT]; -extern const VOLCONF * CONST_IF_ONE_VOLUME gpRedVolConf; - - -/** @brief Per-volume run-time data. -*/ -typedef struct -{ - /** Whether the volume is currently mounted. - */ - bool fMounted; - - #if REDCONF_READ_ONLY == 0 - /** Whether the volume is read-only. - */ - bool fReadOnly; - - /** The active automatic transaction mask. - */ - uint32_t ulTransMask; - #endif - - /** The power of 2 difference between sector size and block size. - */ - uint8_t bBlockSectorShift; - - /** The number of logical blocks in this file system volume. The unit here - is the global block size. - */ - uint32_t ulBlockCount; - - /** The total number of allocable blocks; Also the maximum count of free - blocks. - */ - uint32_t ulBlocksAllocable; - - /** The maximum number of bytes that an inode is capable of addressing. - */ - uint64_t ullMaxInodeSize; - - /** The current metadata sequence number. This value is included in all - metadata nodes and incremented every time a metadata node is written. - It is assumed to never wrap around. - */ - uint64_t ullSequence; -} VOLUME; - -/* Array of VOLUME structures, populated at during RedCoreInit(). -*/ -extern VOLUME gaRedVolume[REDCONF_VOLUME_COUNT]; - -/* Volume number currently being accessed; populated during - RedCoreVolSetCurrent(). -*/ -extern CONST_IF_ONE_VOLUME uint8_t gbRedVolNum; - -/* Pointer to the volume currently being accessed; populated during - RedCoreVolSetCurrent(). -*/ -extern VOLUME * CONST_IF_ONE_VOLUME gpRedVolume; - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/include/redosdeviations.h b/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/include/redosdeviations.h deleted file mode 100755 index cfde3a7..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/include/redosdeviations.h +++ /dev/null @@ -1,244 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Macros to encapsulate MISRA C:2012 deviations in OS-specific code. -*/ -#ifndef REDOSDEVIATIONS_H -#define REDOSDEVIATIONS_H - - -#if REDCONF_OUTPUT == 1 -/* Needed for PRINT_ASSERT() and OUTPUT_CHARACTER(). -*/ -#include -#endif - - -#if (REDCONF_ASSERTS == 1) && (REDCONF_OUTPUT == 1) -/** Print a formatted message for an assertion. - - Usages of this macro deviate from MISRA C:2012 Rule 21.6 (required). Using - printf() is the most convenient way to output this information; and the risk - of "unspecified, undefined and implementation-defined" behavior causing - problems (as cited in the rationale for the rule) is small. The driver does - not depend on this string being outputted correctly. Furthermore, use of - printf() disappears when either asserts or output are disabled. - - As Rule 21.6 is required, a separate deviation record is required. -*/ -#define PRINT_ASSERT(file, line) \ - printf("Assertion failed in \"%s\" at line %u\n\r", ((file) == NULL) ? "" : (file), (unsigned)(line)) -#endif - - -/** Cast a value to unsigned long. - - Usages of this macro deviate from MISRA C:2012 Directive 4.6. This macro is - used in two places to cast a uint64_t value (used by the block device - abstraction for sector numbers) to unsigned long, since third-party code - which is not under the control of this project uses unsigned long for sector - numbers. The cast is guaranteed to not lose any information, since when the - disk is opened the sector count is verified to be less than or equal to an - unsigned long value. The text of the directive mentions that "it might be - desirable not to apply this guideline when interfacing with ... code outside - the project's control", which describes the situation for this deviation. - - As Directive 4.6 is advisory, a deviation record is not required. This - notice is the only record of the deviation. -*/ -#define CAST_ULONG(ull) ((unsigned long)(ull)) - - -/** Cast a const-qualified pointer to a pointer which is *not* const-qualified. - - Usages of this macro deviate from MISRA C:2012 Rule 11.8. This macro is - used in exactly one place in order to cope with a poorly designed - third-party interface. Reliance Edge, at every level of the stack, uses - const-qualified pointers for buffers used in write operations, since the - data is read from the buffer, and the buffer does not need to be modified - (consistent with Rule 8.13). One of the third-party block device interfaces - that Reliance Edge interfaces with does not follow this convention: it uses - an unqualified pointer for the buffer parameter of its sector write - function. This forces the need for the cast to avoid warnings. The - implementation of the sector write function is provided by the user, so it - is to be hoped that the buffer is not actually modified. - - As Rule 11.8 is required, a separate deviation record is required. -*/ -#define CAST_AWAY_CONST(type, ptr) ((type *)(ptr)) - - -/** Allocate zero-initialized (cleared) memory. - - All usages of this macro deviate from MISRA C:2012 Directive 4.12 (required) - and Rule 21.3 (required). In the context of the single place it is actually - used, this macro also deviates from Rule 22.1 (required). - - This macro is used in the FreeRTOS block device code in order to allocate a - RAM disk, when that implementation of the block device is selected. The - primary rationale for all these deviations is that a) the RAM disk cannot be - allocated statically (since the volume information is stored in a - structure), and b) the RAM disk is primarily intended as a temporary testing - tool for users who want to try out Reliance Edge before the real storage - media is available. In most real systems, Reliance Edge is used with - non-volatile storage like SD/MMC or eMMC, not with RAM disks. - - Rule 22.1 states that all resources which are allocated must also be - explicitly freed. The RAM disk is allocated and never freed, deviating from - that rule. This is done because the data in the RAM disk is emulating a - non-volatile storage medium, and thus needs to persist even after the block - device is closed, to allow the file system to be ormatted and then mounted, - or unmounted and remounted in the course of a test. Thus the memory will - remain allocated until the target device is rebooted. This is assumed to be - acceptable for the primary purpose of the RAM disk, which is preliminary - testing. - - As Directive 4.12, Rule 21.3, and Rule 22.1 are all required, separate - deviation records are required. -*/ -#define ALLOCATE_CLEARED_MEMORY(nelem, elsize) calloc(nelem, elsize) - - -#if REDCONF_OUTPUT == 1 -/** Output a character to a serial port or other display device. - - Usages of this macro deviate from MISRA C:2012 Rule 21.6 (required). - FreeRTOS does not include a standard method of printing characters, so - putchar() is the most convenient and portable way to accomplish the task. - The risk of "unspecified, undefined and implementation-defined" behavior - causing problems (as cited in the rationale for the rule) is small. The - driver does not depend on the character being outputted correctly. - Furthermore, use of putchar() disappears when output is disabled. - - As Rule 21.6 is required, a separate deviation record is required. -*/ -#define OUTPUT_CHARACTER(ch) (void)putchar(ch) -#endif - - -#if (REDCONF_TASK_COUNT > 1U) && (REDCONF_API_POSIX == 1) -/** Cast a TaskHandle_t (a pointer type) to uintptr_t. - - Usage of this macro deivate from MISRA-C:2012 Rule 11.4 (advisory). This - macro is used for the FreeRTOS version of RedOsTaskId(). Some RTOSes - natively use an integer for task IDs; others use pointers. RedOsTaskId() - uses integers, FreeRTOS uses pointers; to reconcile this difference, the - pointer must be cast to integer. This is fairly safe, since the resulting - integer is never cast back to a pointer; and although the integer - representation of a pointer is implementation-defined, the representation is - irrelevant provided that unique pointers are converted to unique integers. - - As Rule 11.4 is advisory, a deviation record is not required. This notice - is the only record of the deviation. -*/ -#define CAST_TASK_PTR_TO_UINTPTR(taskptr) ((uintptr_t)(taskptr)) -#endif - - -/** Ignore the return value of a function (cast to void) - - Usages of this macro deviate from MISRA C:2012 Directive 4.7, which states - that error information must be checked immediately after a function returns - potential error information. - - If asserts and output are enabled, then this macro is used to document that - the return value of printf() is ignored. A failure of printf() does not - impact the filesystem core, nor is there anything the filesystem can do to - respond to such an error (especially since it occurs within an assert). - Thus, the most reasonable action is to ignore the error. - - In the STM32 SDIO block device implementation, errors are also ignored in an - IRQ interrupt handler. This is the most reasonable action to take for two - reasons: (a) it would be dangerous to spend processor time responding to the - error inside the IRQ handler; (b) it has been verified that the same error - is propegated to the DiskRead/Write method, which does return the error to - the core. - - In the Atmel SD/MMC block device implementation, error information from - sd_mmc_read_capacity() is ignored. This is a reasonable action because all - of the possible error conditions were eliminated by a previous check. - sd_mmc_read_capacity() fails under the same conditions as - sd_mmc_test_unit_ready(), which was checked ealier in the same function. - - In the mutex module, error information returned from the mutex release - function is ignored when asserts are disabled. This is a reasonable action - because the mutex release function (xSemaphoreGive) is documented only to - fail if the mutex was not obtained correctly, which can be demonstrably - avoided. - - As Directive 4.7 is required, a separate deviation record is required. -*/ -#define IGNORE_ERRORS(fn) ((void) (fn)) - - -/** @brief Determine whether a pointer is aligned on a 32-bit boundary. - - This is used to determine whether a data buffer meets the requirements of - the underlying block device implementation. When transferring data via - DMA (Direct Memory Access) on an STM32 device, the data buffer must be cast - as a uint32 pointer, and unexpected behavior may occur if the buffer is not - aligned correctly. - - There is no way to perform this check without deviating from MISRA C rules - against casting pointers to integer types. Usage of this macro deviates - from MISRA C:2012 Rule 11.4 (advisory). The main rationale the rule cites - against converting pointers to integers is that the chosen integer type may - not be able to represent the pointer; this is a non-issue here since we use - uintptr_t. The text says the rule still applies when using uintptr_t due to - concern about unaligned pointers, but that is not an issue here since the - integer value of the pointer is not saved and not converted back into a - pointer and dereferenced. The result of casting a pointer to a sufficiently - large integer is implementation-defined, but macros similar to this one have - been used by Datalight for a long time in a wide variety of environments and - they have always worked as expected. - - This deviation only occurs when using the STM32 SDIO block device - implementation. - - As Rule 11.4 is advisory, a deviation record is not required. This notice - is the only record of deviation. -*/ -#define IS_UINT32_ALIGNED_PTR(ptr) (((uintptr_t)(ptr) & (sizeof(uint32_t) - 1U)) == 0U) - - -/** @brief Cast a 32-bit aligned void pointer to a uint32 pointer. - - Usages of this macro deviate from MISRA C:2012 Rule 11.5 (advisory). A - cast from a void pointer to an object pointer is discouraged because of - potential alignment issues. However, this macro is only used to cast - pointers that have already been tested to be 32-bit aligned, so the - operation will be safe. - - This deviation only occurs when using the STM32 SDIO block device - implementation. - - As rule 11.5 is advisory, a deviation record is not required. This notice - is the only record of the deviation. -*/ -#define CAST_UINT32_PTR(ptr) ((uint32_t *) (ptr)) - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/include/redostypes.h b/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/include/redostypes.h deleted file mode 100755 index 1f15b42..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/include/redostypes.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Defines OS-specific types for use in common code. -*/ -#ifndef REDOSTYPES_H -#define REDOSTYPES_H - - -/** @brief Implementation-defined timestamp type. - - This can be an integer, a structure, or a pointer: anything that is - convenient for the implementation. Since the underlying type is not fixed, - common code should treat this as an opaque type. -*/ -typedef uint32_t REDTIMESTAMP; - - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osassert.c b/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osassert.c deleted file mode 100755 index 9822caf..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osassert.c +++ /dev/null @@ -1,56 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements assertion handling. -*/ -#include - -#if REDCONF_ASSERTS == 1 - -#include - - -/** @brief Invoke the native assertion handler. - - @param pszFileName Null-terminated string containing the name of the file - where the assertion fired. - @param ulLineNum Line number in @p pszFileName where the assertion - fired. -*/ -void RedOsAssertFail( - const char *pszFileName, - uint32_t ulLineNum) -{ - #if REDCONF_OUTPUT == 1 - IGNORE_ERRORS(PRINT_ASSERT(pszFileName, ulLineNum)); - #endif - - while(true) - { - } -} - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osbdev.c b/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osbdev.c deleted file mode 100755 index bb42087..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osbdev.c +++ /dev/null @@ -1,1553 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements block device I/O. -*/ -#include - -#include -#include -#include - - -/*------------------------------------------------------------------------------ - Porting Note: - - Several example implementations of this module for FreeRTOS are available. - If you are lucky, you can use one of these implementations; otherwise, these - can serve as examples of how to implement this service. -------------------------------------------------------------------------------*/ - -/** @brief The F_DRIVER example implementation. - - This implementation is designed to reuse an existing block device driver - that was written for FreeRTOS+FAT SL. If you have such a driver, with - little work it can be "dropped in" and used for Reliance Edge. The only - customization required is that gpfnRedOsBDevInit needs to be defined and - pointed at the F_DRIVERINIT function. This can be done in this module or in - another C file. - - The disadantage of using the FreeRTOS F_DRIVER functions is that they only - support single-sector reads and writes. Reliance Edge will issue - multi-sector requests, and servicing these one sector at a time will - significantly slow down the file system. -*/ -#define BDEV_F_DRIVER (0U) - -/** @brief The FatFs example implementation. - - This implementation is designed to reuse an existing block device driver - that was written for FatFs. If you have such a driver, it can be linked - in and used immediately. The FatFs `diskio.h` header must be in the include - directory path. -*/ -#define BDEV_FATFS (1U) - -/** @brief The Atmel Studio Framework SD/MMC driver example implementation. - - This implementation uses a modified version of the open source SD/MMC driver - included in the Atmel Studio Framework (ASF) and will work as-is for many - varieties of Atmel hardware. This example assumes relatively minor - modifications to the ASF SD/MMC driver to make it support multi-sector read - and write requests, which greatly improves performance. The modified driver - is distributed with Reliance Edge and is included in FreeRTOS Atmel projects - (such as in projects/freertos/atmel/sam4e-ek/src/ASF). - - This example can easily be modified to work with an unmodified version of - the ASF SD/MMC driver. Simply replace sd_mmc_mem_2_ram_multi() and - sd_mmc_ram_2_mem_multi() with sd_mmc_mem_2_ram() and sd_mmc_ram_2_mem() - respectively, and add a for loop to loop over each sector in the request. - However, as described in the manual, there are considerable performance - advantages to issuing real multi-sector requests, so using the modified - driver is recommended. -*/ -#define BDEV_ATMEL_SDMMC (2U) - -/** @brief The ST Microelectronics STM32 SDIO driver example implementation. - - This implementation accesses the microSD card through the BSP utilities - provided as part of the STM32Cube package, used with the STM32 HAL drivers. - The STM3240G-EVAL and STM32F746NG-Discovery boards are currently supported. -*/ -#define BDEV_STM32_SDIO (3U) - -/** @brief The RAM disk example implementation. - - This implementation uses a RAM disk. It will allow you to compile and test - Reliance Edge even if your storage driver is not yet ready. On typical - target hardware, the amount of spare RAM will be limited so generally only - very small disks will be available. -*/ -#define BDEV_RAM_DISK (4U) - -/** @brief Pick which example implementation is compiled. - - Must be one of: - - #BDEV_F_DRIVER - - #BDEV_FATFS - - #BDEV_ATMEL_SDMMC - - #BDEV_STM32_SDIO - - #BDEV_RAM_DISK -*/ -#define BDEV_EXAMPLE_IMPLEMENTATION BDEV_RAM_DISK - - -static REDSTATUS DiskOpen(uint8_t bVolNum, BDEVOPENMODE mode); -static REDSTATUS DiskClose(uint8_t bVolNum); -static REDSTATUS DiskRead(uint8_t bVolNum, uint64_t ullSectorStart, uint32_t ulSectorCount, void *pBuffer); -#if REDCONF_READ_ONLY == 0 -static REDSTATUS DiskWrite(uint8_t bVolNum, uint64_t ullSectorStart, uint32_t ulSectorCount, const void *pBuffer); -static REDSTATUS DiskFlush(uint8_t bVolNum); -#endif - - -/** @brief Initialize a block device. - - This function is called when the file system needs access to a block - device. - - Upon successful return, the block device should be fully initialized and - ready to service read/write/flush/close requests. - - The behavior of calling this function on a block device which is already - open is undefined. - - @param bVolNum The volume number of the volume whose block device is being - initialized. - @param mode The open mode, indicating the type of access required. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bVolNum is an invalid volume number. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedOsBDevOpen( - uint8_t bVolNum, - BDEVOPENMODE mode) -{ - REDSTATUS ret; - - if(bVolNum >= REDCONF_VOLUME_COUNT) - { - ret = -RED_EINVAL; - } - else - { - ret = DiskOpen(bVolNum, mode); - } - - return ret; -} - - -/** @brief Uninitialize a block device. - - This function is called when the file system no longer needs access to a - block device. If any resource were allocated by RedOsBDevOpen() to service - block device requests, they should be freed at this time. - - Upon successful return, the block device must be in such a state that it - can be opened again. - - The behavior of calling this function on a block device which is already - closed is undefined. - - @param bVolNum The volume number of the volume whose block device is being - uninitialized. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bVolNum is an invalid volume number. -*/ -REDSTATUS RedOsBDevClose( - uint8_t bVolNum) -{ - REDSTATUS ret; - - if(bVolNum >= REDCONF_VOLUME_COUNT) - { - ret = -RED_EINVAL; - } - else - { - ret = DiskClose(bVolNum); - } - - return ret; -} - - -/** @brief Read sectors from a physical block device. - - The behavior of calling this function is undefined if the block device is - closed or if it was opened with ::BDEV_O_WRONLY. - - @param bVolNum The volume number of the volume whose block device - is being read from. - @param ullSectorStart The starting sector number. - @param ulSectorCount The number of sectors to read. - @param pBuffer The buffer into which to read the sector data. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bVolNum is an invalid volume number, @p pBuffer is - `NULL`, or @p ullStartSector and/or @p ulSectorCount - refer to an invalid range of sectors. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedOsBDevRead( - uint8_t bVolNum, - uint64_t ullSectorStart, - uint32_t ulSectorCount, - void *pBuffer) -{ - REDSTATUS ret = 0; - - if( (bVolNum >= REDCONF_VOLUME_COUNT) - || (ullSectorStart >= gaRedVolConf[bVolNum].ullSectorCount) - || ((gaRedVolConf[bVolNum].ullSectorCount - ullSectorStart) < ulSectorCount) - || (pBuffer == NULL)) - { - ret = -RED_EINVAL; - } - else - { - ret = DiskRead(bVolNum, ullSectorStart, ulSectorCount, pBuffer); - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Write sectors to a physical block device. - - The behavior of calling this function is undefined if the block device is - closed or if it was opened with ::BDEV_O_RDONLY. - - @param bVolNum The volume number of the volume whose block device - is being written to. - @param ullSectorStart The starting sector number. - @param ulSectorCount The number of sectors to write. - @param pBuffer The buffer from which to write the sector data. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bVolNum is an invalid volume number, @p pBuffer is - `NULL`, or @p ullStartSector and/or @p ulSectorCount - refer to an invalid range of sectors. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedOsBDevWrite( - uint8_t bVolNum, - uint64_t ullSectorStart, - uint32_t ulSectorCount, - const void *pBuffer) -{ - REDSTATUS ret = 0; - - if( (bVolNum >= REDCONF_VOLUME_COUNT) - || (ullSectorStart >= gaRedVolConf[bVolNum].ullSectorCount) - || ((gaRedVolConf[bVolNum].ullSectorCount - ullSectorStart) < ulSectorCount) - || (pBuffer == NULL)) - { - ret = -RED_EINVAL; - } - else - { - ret = DiskWrite(bVolNum, ullSectorStart, ulSectorCount, pBuffer); - } - - return ret; -} - - -/** @brief Flush any caches beneath the file system. - - This function must synchronously flush all software and hardware caches - beneath the file system, ensuring that all sectors written previously are - committed to permanent storage. - - If the environment has no caching beneath the file system, the - implementation of this function can do nothing and return success. - - The behavior of calling this function is undefined if the block device is - closed or if it was opened with ::BDEV_O_RDONLY. - - @param bVolNum The volume number of the volume whose block device is being - flushed. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p bVolNum is an invalid volume number. - @retval -RED_EIO A disk I/O error occurred. -*/ -REDSTATUS RedOsBDevFlush( - uint8_t bVolNum) -{ - REDSTATUS ret; - - if(bVolNum >= REDCONF_VOLUME_COUNT) - { - ret = -RED_EINVAL; - } - else - { - ret = DiskFlush(bVolNum); - } - - return ret; -} -#endif /* REDCONF_READ_ONLY == 0 */ - - -#if BDEV_EXAMPLE_IMPLEMENTATION == BDEV_F_DRIVER - -#include - - -/* This must be declared and initialized elsewere (e.g., in project code) to - point at the initialization function for the F_DRIVER block device. -*/ -extern const F_DRIVERINIT gpfnRedOsBDevInit; - -static F_DRIVER *gapFDriver[REDCONF_VOLUME_COUNT]; - - -/** @brief Initialize a disk. - - @param bVolNum The volume number of the volume whose block device is being - initialized. - @param mode The open mode, indicating the type of access required. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS DiskOpen( - uint8_t bVolNum, - BDEVOPENMODE mode) -{ - REDSTATUS ret; - - (void)mode; - - if((gpfnRedOsBDevInit == NULL) || (gapFDriver[bVolNum] != NULL)) - { - ret = -RED_EINVAL; - } - else - { - F_DRIVER *pDriver; - - pDriver = gpfnRedOsBDevInit(bVolNum); - if(pDriver != NULL) - { - F_PHY geom; - int iErr; - - /* Validate that the geometry is consistent with the volume - configuration. - */ - iErr = pDriver->getphy(pDriver, &geom); - if(iErr == 0) - { - if( (geom.bytes_per_sector != gaRedVolConf[bVolNum].ulSectorSize) - || (geom.number_of_sectors < gaRedVolConf[bVolNum].ullSectorCount)) - { - ret = -RED_EINVAL; - } - else - { - gapFDriver[bVolNum] = pDriver; - ret = 0; - } - } - else - { - ret = -RED_EIO; - } - - if(ret != 0) - { - pDriver->release(pDriver); - } - } - else - { - ret = -RED_EIO; - } - } - - return ret; -} - - -/** @brief Uninitialize a disk. - - @param bVolNum The volume number of the volume whose block device is being - uninitialized. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -static REDSTATUS DiskClose( - uint8_t bVolNum) -{ - REDSTATUS ret; - - if(gapFDriver[bVolNum] == NULL) - { - ret = -RED_EINVAL; - } - else - { - gapFDriver[bVolNum]->release(gapFDriver[bVolNum]); - gapFDriver[bVolNum] = NULL; - - ret = 0; - } - - return ret; -} - - -/** @brief Read sectors from a disk. - - @param bVolNum The volume number of the volume whose block device - is being read from. - @param ullSectorStart The starting sector number. - @param ulSectorCount The number of sectors to read. - @param pBuffer The buffer into which to read the sector data. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS DiskRead( - uint8_t bVolNum, - uint64_t ullSectorStart, - uint32_t ulSectorCount, - void *pBuffer) -{ - REDSTATUS ret = 0; - F_DRIVER *pDriver = gapFDriver[bVolNum]; - - if(pDriver == NULL) - { - ret = -RED_EINVAL; - } - else - { - uint8_t *pbBuffer = CAST_VOID_PTR_TO_UINT8_PTR(pBuffer); - uint32_t ulSectorSize = gaRedVolConf[bVolNum].ulSectorSize; - uint32_t ulSectorIdx; - int iErr; - - for(ulSectorIdx = 0U; ulSectorIdx < ulSectorCount; ulSectorIdx++) - { - iErr = pDriver->readsector(pDriver, &pbBuffer[ulSectorIdx * ulSectorSize], - CAST_ULONG(ullSectorStart + ulSectorIdx)); - if(iErr != 0) - { - ret = -RED_EIO; - break; - } - } - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Write sectors to a disk. - - @param bVolNum The volume number of the volume whose block device - is being written to. - @param ullSectorStart The starting sector number. - @param ulSectorCount The number of sectors to write. - @param pBuffer The buffer from which to write the sector data. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL The block device is not open. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS DiskWrite( - uint8_t bVolNum, - uint64_t ullSectorStart, - uint32_t ulSectorCount, - const void *pBuffer) -{ - REDSTATUS ret = 0; - F_DRIVER *pDriver = gapFDriver[bVolNum]; - - if(pDriver == NULL) - { - ret = -RED_EINVAL; - } - else - { - const uint8_t *pbBuffer = CAST_VOID_PTR_TO_CONST_UINT8_PTR(pBuffer); - uint32_t ulSectorSize = gaRedVolConf[bVolNum].ulSectorSize; - uint32_t ulSectorIdx; - int iErr; - - for(ulSectorIdx = 0U; ulSectorIdx < ulSectorCount; ulSectorIdx++) - { - /* We have to cast pbBuffer to non-const since the writesector - prototype is flawed, using a non-const pointer for the buffer. - */ - iErr = pDriver->writesector(pDriver, CAST_AWAY_CONST(uint8_t, &pbBuffer[ulSectorIdx * ulSectorSize]), - CAST_ULONG(ullSectorStart + ulSectorIdx)); - if(iErr != 0) - { - ret = -RED_EIO; - break; - } - } - } - - return ret; -} - - -/** @brief Flush any caches beneath the file system. - - @param bVolNum The volume number of the volume whose block device is being - flushed. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -static REDSTATUS DiskFlush( - uint8_t bVolNum) -{ - REDSTATUS ret; - - if(gapFDriver[bVolNum] == NULL) - { - ret = -RED_EINVAL; - } - else - { - /* The F_DRIVER interface does not include a flush function, so to be - reliable the F_DRIVER implementation must use synchronous writes. - */ - ret = 0; - } - - return ret; -} -#endif /* REDCONF_READ_ONLY == 0 */ - - -#elif BDEV_EXAMPLE_IMPLEMENTATION == BDEV_FATFS - -#include -#include - -/* disk_read() and disk_write() use an unsigned 8-bit value to specify the - sector count, so no transfer can be larger than 255 sectors. -*/ -#define MAX_SECTOR_TRANSFER UINT8_MAX - - -/** @brief Initialize a disk. - - @param bVolNum The volume number of the volume whose block device is being - initialized. - @param mode The open mode, indicating the type of access required. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS DiskOpen( - uint8_t bVolNum, - BDEVOPENMODE mode) -{ - DSTATUS status; - uint32_t ulTries; - REDSTATUS ret = 0; - - /* With some implementations of disk_initialize(), such as the one - implemented by Atmel for the ASF, the first time the disk is opened, the - SD card can take a while to get ready, in which time disk_initialize() - returns an error. Try numerous times, waiting half a second after each - failure. Empirically, this has been observed to succeed on the second - try, so trying 10x more than that provides a margin of error. - */ - for(ulTries = 0U; ulTries < 20U; ulTries++) - { - /* Assuming that the volume number is also the correct drive number. - If this is not the case in your environment, a static constant array - can be declared to map volume numbers to the correct driver number. - */ - status = disk_initialize(bVolNum); - if(status == 0) - { - break; - } - - vTaskDelay(500U / portTICK_PERIOD_MS); - } - - if(status != 0) - { - ret = -RED_EIO; - } - - /* Retrieve the sector size and sector count to ensure they are compatible - with our compile-time geometry. - */ - if(ret == 0) - { - WORD wSectorSize; - DWORD dwSectorCount; - DRESULT result; - - result = disk_ioctl(bVolNum, GET_SECTOR_SIZE, &wSectorSize); - if(result == RES_OK) - { - result = disk_ioctl(bVolNum, GET_SECTOR_COUNT, &dwSectorCount); - if(result == RES_OK) - { - if( (wSectorSize != gaRedVolConf[bVolNum].ulSectorSize) - || (dwSectorCount < gaRedVolConf[bVolNum].ullSectorCount)) - { - ret = -RED_EINVAL; - } - } - else - { - ret = -RED_EIO; - } - } - else - { - ret = -RED_EIO; - } - } - - return ret; -} - - -/** @brief Uninitialize a disk. - - @param bVolNum The volume number of the volume whose block device is being - uninitialized. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -static REDSTATUS DiskClose( - uint8_t bVolNum) -{ - (void)bVolNum; - return 0; -} - - -/** @brief Read sectors from a disk. - - @param bVolNum The volume number of the volume whose block device - is being read from. - @param ullSectorStart The starting sector number. - @param ulSectorCount The number of sectors to read. - @param pBuffer The buffer into which to read the sector data. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS DiskRead( - uint8_t bVolNum, - uint64_t ullSectorStart, - uint32_t ulSectorCount, - void *pBuffer) -{ - REDSTATUS ret = 0; - uint32_t ulSectorIdx = 0U; - uint32_t ulSectorSize = gaRedVolConf[bVolNum].ulSectorSize; - uint8_t *pbBuffer = CAST_VOID_PTR_TO_UINT8_PTR(pBuffer); - - while(ulSectorIdx < ulSectorCount) - { - uint32_t ulTransfer = REDMIN(ulSectorCount - ulSectorIdx, MAX_SECTOR_TRANSFER); - DRESULT result; - - result = disk_read(bVolNum, &pbBuffer[ulSectorIdx * ulSectorSize], (DWORD)(ullSectorStart + ulSectorIdx), (BYTE)ulTransfer); - if(result != RES_OK) - { - ret = -RED_EIO; - break; - } - - ulSectorIdx += ulTransfer; - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Write sectors to a disk. - - @param bVolNum The volume number of the volume whose block device - is being written to. - @param ullSectorStart The starting sector number. - @param ulSectorCount The number of sectors to write. - @param pBuffer The buffer from which to write the sector data. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS DiskWrite( - uint8_t bVolNum, - uint64_t ullSectorStart, - uint32_t ulSectorCount, - const void *pBuffer) -{ - REDSTATUS ret = 0; - uint32_t ulSectorIdx = 0U; - uint32_t ulSectorSize = gaRedVolConf[bVolNum].ulSectorSize; - const uint8_t *pbBuffer = CAST_VOID_PTR_TO_CONST_UINT8_PTR(pBuffer); - - while(ulSectorIdx < ulSectorCount) - { - uint32_t ulTransfer = REDMIN(ulSectorCount - ulSectorIdx, MAX_SECTOR_TRANSFER); - DRESULT result; - - result = disk_write(bVolNum, &pbBuffer[ulSectorIdx * ulSectorSize], (DWORD)(ullSectorStart + ulSectorIdx), (BYTE)ulTransfer); - if(result != RES_OK) - { - ret = -RED_EIO; - break; - } - - ulSectorIdx += ulTransfer; - } - - return ret; -} - - -/** @brief Flush any caches beneath the file system. - - @param bVolNum The volume number of the volume whose block device is being - flushed. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -static REDSTATUS DiskFlush( - uint8_t bVolNum) -{ - REDSTATUS ret; - DRESULT result; - - result = disk_ioctl(bVolNum, CTRL_SYNC, NULL); - if(result == RES_OK) - { - ret = 0; - } - else - { - ret = -RED_EIO; - } - - return ret; -} -#endif /* REDCONF_READ_ONLY == 0 */ - - -#elif BDEV_EXAMPLE_IMPLEMENTATION == BDEV_ATMEL_SDMMC - -#include - -#include -#include -#include -#include - -/* sd_mmc_mem_2_ram_multi() and sd_mmc_ram_2_mem_multi() use an unsigned - 16-bit value to specify the sector count, so no transfer can be larger - than UINT16_MAX sectors. -*/ -#define MAX_SECTOR_TRANSFER UINT16_MAX - - -/** @brief Initialize a disk. - - @param bVolNum The volume number of the volume whose block device is being - initialized. - @param mode The open mode, indicating the type of access required. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EROFS The device is read-only media and write access was - requested. -*/ -static REDSTATUS DiskOpen( - uint8_t bVolNum, - BDEVOPENMODE mode) -{ - REDSTATUS ret = 0; - uint32_t ulTries; - Ctrl_status cs; - - /* Note: Assuming the volume number is the same as the SD card slot. The - ASF SD/MMC driver supports two SD slots. This implementation will need - to be modified if multiple volumes share a single SD card. - */ - - /* The first time the disk is opened, the SD card can take a while to get - ready, in which time sd_mmc_test_unit_ready() returns either CTRL_BUSY - or CTRL_NO_PRESENT. Try numerous times, waiting half a second after - each failure. Empirically, this has been observed to succeed on the - second try, so trying 10x more than that provides a margin of error. - */ - for(ulTries = 0U; ulTries < 20U; ulTries++) - { - cs = sd_mmc_test_unit_ready(bVolNum); - if((cs != CTRL_NO_PRESENT) && (cs != CTRL_BUSY)) - { - break; - } - - vTaskDelay(500U / portTICK_PERIOD_MS); - } - - if(cs == CTRL_GOOD) - { - #if REDCONF_READ_ONLY == 0 - if(mode != BDEV_O_RDONLY) - { - if(sd_mmc_wr_protect(bVolNum)) - { - ret = -RED_EROFS; - } - } - - if(ret == 0) - #endif - { - uint32_t ulSectorLast; - - IGNORE_ERRORS(sd_mmc_read_capacity(bVolNum, &ulSectorLast)); - - /* The ASF SD/MMC driver only supports 512-byte sectors. - */ - if( (gaRedVolConf[bVolNum].ulSectorSize != 512U) - || (((uint64_t)ulSectorLast + 1U) < gaRedVolConf[bVolNum].ullSectorCount)) - { - ret = -RED_EINVAL; - } - } - } - else - { - ret = -RED_EIO; - } - - return ret; -} - - -/** @brief Uninitialize a disk. - - @param bVolNum The volume number of the volume whose block device is being - uninitialized. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -static REDSTATUS DiskClose( - uint8_t bVolNum) -{ - (void)bVolNum; - return 0; -} - - -/** @brief Read sectors from a disk. - - @param bVolNum The volume number of the volume whose block device - is being read from. - @param ullSectorStart The starting sector number. - @param ulSectorCount The number of sectors to read. - @param pBuffer The buffer into which to read the sector data. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -static REDSTATUS DiskRead( - uint8_t bVolNum, - uint64_t ullSectorStart, - uint32_t ulSectorCount, - void *pBuffer) -{ - REDSTATUS ret = 0; - uint32_t ulSectorIdx = 0U; - uint32_t ulSectorSize = gaRedVolConf[bVolNum].ulSectorSize; - uint8_t *pbBuffer = CAST_VOID_PTR_TO_UINT8_PTR(pBuffer); - - while(ulSectorIdx < ulSectorCount) - { - uint32_t ulTransfer = REDMIN(ulSectorCount - ulSectorIdx, MAX_SECTOR_TRANSFER); - Ctrl_status cs; - - cs = sd_mmc_mem_2_ram_multi(bVolNum, (uint32_t)(ullSectorStart + ulSectorIdx), - (uint16_t)ulTransfer, &pbBuffer[ulSectorIdx * ulSectorSize]); - if(cs != CTRL_GOOD) - { - ret = -RED_EIO; - break; - } - - ulSectorIdx += ulTransfer; - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Write sectors to a disk. - - @param bVolNum The volume number of the volume whose block device - is being written to. - @param ullSectorStart The starting sector number. - @param ulSectorCount The number of sectors to write. - @param pBuffer The buffer from which to write the sector data. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -static REDSTATUS DiskWrite( - uint8_t bVolNum, - uint64_t ullSectorStart, - uint32_t ulSectorCount, - const void *pBuffer) -{ - REDSTATUS ret = 0; - uint32_t ulSectorIdx = 0U; - uint32_t ulSectorSize = gaRedVolConf[bVolNum].ulSectorSize; - const uint8_t *pbBuffer = CAST_VOID_PTR_TO_CONST_UINT8_PTR(pBuffer); - - while(ulSectorIdx < ulSectorCount) - { - uint32_t ulTransfer = REDMIN(ulSectorCount - ulSectorIdx, MAX_SECTOR_TRANSFER); - Ctrl_status cs; - - cs = sd_mmc_ram_2_mem_multi(bVolNum, (uint32_t)(ullSectorStart + ulSectorIdx), - (uint16_t)ulTransfer, &pbBuffer[ulSectorIdx * ulSectorSize]); - if(cs != CTRL_GOOD) - { - ret = -RED_EIO; - break; - } - - ulSectorIdx += ulTransfer; - } - - return ret; -} - - -/** @brief Flush any caches beneath the file system. - - @param bVolNum The volume number of the volume whose block device is being - flushed. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -static REDSTATUS DiskFlush( - uint8_t bVolNum) -{ - REDSTATUS ret; - Ctrl_status cs; - - /* The ASF SD/MMC driver appears to write sectors synchronously, so it - should be fine to do nothing and return success. However, Atmel's - implementation of the FatFs diskio.c file does the equivalent of the - below when the disk is flushed. Just in case this is important for some - non-obvious reason, do the same. - */ - cs = sd_mmc_test_unit_ready(bVolNum); - if(cs == CTRL_GOOD) - { - ret = 0; - } - else - { - ret = -RED_EIO; - } - - return ret; -} -#endif /* REDCONF_READ_ONLY == 0 */ - -#elif BDEV_EXAMPLE_IMPLEMENTATION == BDEV_STM32_SDIO - -#ifdef USE_STM324xG_EVAL - #include - #include -#elif defined(USE_STM32746G_DISCO) - #include - #include -#else - /* If you are using a compatible STM32 device other than the two listed above - and you have SD card driver headers, you can try adding them to the above - list. - */ - #error "Unsupported device." -#endif - -#if REDCONF_VOLUME_COUNT > 1 - #error "The STM32 SDIO block device implementation does not support multiple volumes." -#endif - - -#ifndef USE_HAL_DRIVER - #error "The STM32 StdPeriph driver is not supported. Please use the HAL driver or modify the Reliance Edge block device interface." -#endif - - -/** @brief Number of times to call BSP_SD_GetStatus() before timing out and - returning an error. - - See ::CheckStatus(). - - NOTE: Datalight has not observed a scenario where BSP_SD_GetStatus() - returns SD_TRANSFER_BUSY after a transfer command returns successfully. - Set SD_STATUS_TIMEOUT to 0U to skip checking BSP_SD_GetStatus(). -*/ -#define SD_STATUS_TIMEOUT (100000U) - -/** @brief 4-byte aligned buffer to use for DMA transfers when passed in - an unaligned buffer. -*/ -static uint32_t gaulAlignedBuffer[512U / sizeof(uint32_t)]; - - -#if SD_STATUS_TIMEOUT > 0U -static REDSTATUS CheckStatus(void); -#endif - - -/** @brief Initialize a disk. - - @param bVolNum The volume number of the volume whose block device is being - initialized. - @param mode The open mode, indicating the type of access required. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO No SD card was found; or BSP_SD_Init() failed. - @retval -RED_EINVAL The SD card's block size is not the same as the - configured sector size; or the SD card is not large - enough for the volume; or the volume size is above - 4GiB, meaning that part of it cannot be accessed - through the STM32 SDIO driver. -*/ -static REDSTATUS DiskOpen( - uint8_t bVolNum, - BDEVOPENMODE mode) -{ - REDSTATUS ret = 0; - static bool fSdInitted = false; - - (void) mode; - - if(!fSdInitted) - { - if(BSP_SD_Init() == MSD_OK) - { - fSdInitted = true; - } - } - - if(!fSdInitted) - { - /* Above initialization attempt failed. - */ - ret = -RED_EIO; - } - else if(BSP_SD_IsDetected() == SD_NOT_PRESENT) - { - ret = -RED_EIO; - } - else - { - uint32_t ulSectorSize = gaRedVolConf[bVolNum].ulSectorSize; - HAL_SD_CardInfoTypedef sdCardInfo = {{0}}; - - BSP_SD_GetCardInfo(&sdCardInfo); - - /* Note: the actual card block size is sdCardInfo.CardBlockSize, - but the interface only supports a 512 byte block size. Further, - one card has been observed to report a 1024-byte block size, - but it worked fine with a 512-byte Reliance Edge ulSectorSize. - */ - if( (ulSectorSize != 512U) - || (sdCardInfo.CardCapacity < (gaRedVolConf[bVolNum].ullSectorCount * ulSectorSize))) - { - ret = -RED_EINVAL; - } - } - - return ret; -} - - -/** @brief Uninitialize a disk. - - @param bVolNum The volume number of the volume whose block device is being - uninitialized. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -static REDSTATUS DiskClose( - uint8_t bVolNum) -{ - (void)bVolNum; - return 0; -} - - -/** @brief Read sectors from a disk. - - @param bVolNum The volume number of the volume whose block device - is being read from. - @param ullSectorStart The starting sector number. - @param ulSectorCount The number of sectors to read. - @param pBuffer The buffer into which to read the sector data. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS DiskRead( - uint8_t bVolNum, - uint64_t ullSectorStart, - uint32_t ulSectorCount, - void *pBuffer) -{ - REDSTATUS redStat = 0; - uint32_t ulSectorSize = gaRedVolConf[bVolNum].ulSectorSize; - uint8_t bSdError; - - if(IS_UINT32_ALIGNED_PTR(pBuffer)) - { - bSdError = BSP_SD_ReadBlocks_DMA(CAST_UINT32_PTR(pBuffer), ullSectorStart * ulSectorSize, ulSectorSize, ulSectorCount); - - if(bSdError != MSD_OK) - { - redStat = -RED_EIO; - } - #if SD_STATUS_TIMEOUT > 0U - else - { - redStat = CheckStatus(); - } - #endif - } - else - { - uint32_t ulSectorIdx; - - for(ulSectorIdx = 0U; ulSectorIdx < ulSectorCount; ulSectorIdx++) - { - bSdError = BSP_SD_ReadBlocks_DMA(gaulAlignedBuffer, (ullSectorStart + ulSectorIdx) * ulSectorSize, ulSectorSize, 1U); - - if(bSdError != MSD_OK) - { - redStat = -RED_EIO; - } - #if SD_STATUS_TIMEOUT > 0U - else - { - redStat = CheckStatus(); - } - #endif - - if(redStat == 0) - { - uint8_t *pbBuffer = CAST_VOID_PTR_TO_UINT8_PTR(pBuffer); - - RedMemCpy(&pbBuffer[ulSectorIdx * ulSectorSize], gaulAlignedBuffer, ulSectorSize); - } - else - { - break; - } - } - } - - return redStat; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Write sectors to a disk. - - @param bVolNum The volume number of the volume whose block device - is being written to. - @param ullSectorStart The starting sector number. - @param ulSectorCount The number of sectors to write. - @param pBuffer The buffer from which to write the sector data. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS DiskWrite( - uint8_t bVolNum, - uint64_t ullSectorStart, - uint32_t ulSectorCount, - const void *pBuffer) -{ - REDSTATUS redStat = 0; - uint32_t ulSectorSize = gaRedVolConf[bVolNum].ulSectorSize; - uint8_t bSdError; - - if(IS_UINT32_ALIGNED_PTR(pBuffer)) - { - bSdError = BSP_SD_WriteBlocks_DMA(CAST_UINT32_PTR(CAST_AWAY_CONST(void, pBuffer)), ullSectorStart * ulSectorSize, - ulSectorSize, ulSectorCount); - - if(bSdError != MSD_OK) - { - redStat = -RED_EIO; - } - #if SD_STATUS_TIMEOUT > 0U - else - { - redStat = CheckStatus(); - } - #endif - } - else - { - uint32_t ulSectorIdx; - - for(ulSectorIdx = 0U; ulSectorIdx < ulSectorCount; ulSectorIdx++) - { - const uint8_t *pbBuffer = CAST_VOID_PTR_TO_CONST_UINT8_PTR(pBuffer); - - RedMemCpy(gaulAlignedBuffer, &pbBuffer[ulSectorIdx * ulSectorSize], ulSectorSize); - - bSdError = BSP_SD_WriteBlocks_DMA(gaulAlignedBuffer, (ullSectorStart + ulSectorIdx) * ulSectorSize, ulSectorSize, 1U); - - if(bSdError != MSD_OK) - { - redStat = -RED_EIO; - } - #if SD_STATUS_TIMEOUT > 0U - else - { - redStat = CheckStatus(); - } - #endif - - if(redStat != 0) - { - break; - } - } - } - - return redStat; -} - - -/** @brief Flush any caches beneath the file system. - - @param bVolNum The volume number of the volume whose block device is being - flushed. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -static REDSTATUS DiskFlush( - uint8_t bVolNum) -{ - /* Disk transfer is synchronous; nothing to flush. - */ - (void) bVolNum; - return 0; -} - - -#if SD_STATUS_TIMEOUT > 0U -/** @brief Wait until BSP_SD_GetStatus returns SD_TRANSFER_OK. - - This function calls BSP_SD_GetStatus repeatedly as long as it returns - SD_TRANSFER_BUSY up to SD_STATUS_TIMEOUT times. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 SD_TRANSFER_OK was returned. - @retval -RED_EIO SD_TRANSFER_ERROR received, or timed out waiting for - SD_TRANSFER_OK. -*/ -static REDSTATUS CheckStatus(void) -{ - REDSTATUS redStat = 0; - uint32_t ulTimeout = SD_STATUS_TIMEOUT; - HAL_SD_TransferStateTypedef transferState; - - do - { - transferState = BSP_SD_GetStatus(); - ulTimeout--; - } while((transferState == SD_TRANSFER_BUSY) && (ulTimeout > 0U)); - - if(transferState != SD_TRANSFER_OK) - { - redStat = -RED_EIO; - } - - return redStat; -} -#endif - -#endif /* REDCONF_READ_ONLY == 0 */ - -#elif BDEV_EXAMPLE_IMPLEMENTATION == BDEV_RAM_DISK - -#include /* For ALLOCATE_CLEARED_MEMORY(), which expands to calloc(). */ - - -static uint8_t *gapbRamDisk[REDCONF_VOLUME_COUNT]; - - -/** @brief Initialize a disk. - - @param bVolNum The volume number of the volume whose block device is being - initialized. - @param mode The open mode, indicating the type of access required. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS DiskOpen( - uint8_t bVolNum, - BDEVOPENMODE mode) -{ - REDSTATUS ret = 0; - - (void)mode; - - if(gapbRamDisk[bVolNum] == NULL) - { - gapbRamDisk[bVolNum] = ALLOCATE_CLEARED_MEMORY(gaRedVolume[bVolNum].ulBlockCount, REDCONF_BLOCK_SIZE); - if(gapbRamDisk[bVolNum] == NULL) - { - ret = -RED_EIO; - } - } - - return ret; -} - - -/** @brief Uninitialize a disk. - - @param bVolNum The volume number of the volume whose block device is being - uninitialized. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -static REDSTATUS DiskClose( - uint8_t bVolNum) -{ - REDSTATUS ret; - - if(gapbRamDisk[bVolNum] == NULL) - { - ret = -RED_EINVAL; - } - else - { - /* This implementation uses dynamically allocated memory, but must - retain previously written data after the block device is closed, and - thus the memory cannot be freed and will remain allocated until - reboot. - */ - ret = 0; - } - - return ret; -} - - -/** @brief Read sectors from a disk. - - @param bVolNum The volume number of the volume whose block device - is being read from. - @param ullSectorStart The starting sector number. - @param ulSectorCount The number of sectors to read. - @param pBuffer The buffer into which to read the sector data. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -static REDSTATUS DiskRead( - uint8_t bVolNum, - uint64_t ullSectorStart, - uint32_t ulSectorCount, - void *pBuffer) -{ - REDSTATUS ret; - - if(gapbRamDisk[bVolNum] == NULL) - { - ret = -RED_EINVAL; - } - else - { - uint64_t ullByteOffset = ullSectorStart * gaRedVolConf[bVolNum].ulSectorSize; - uint32_t ulByteCount = ulSectorCount * gaRedVolConf[bVolNum].ulSectorSize; - - RedMemCpy(pBuffer, &gapbRamDisk[bVolNum][ullByteOffset], ulByteCount); - - ret = 0; - } - - return ret; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Write sectors to a disk. - - @param bVolNum The volume number of the volume whose block device - is being written to. - @param ullSectorStart The starting sector number. - @param ulSectorCount The number of sectors to write. - @param pBuffer The buffer from which to write the sector data. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -static REDSTATUS DiskWrite( - uint8_t bVolNum, - uint64_t ullSectorStart, - uint32_t ulSectorCount, - const void *pBuffer) -{ - REDSTATUS ret; - - if(gapbRamDisk[bVolNum] == NULL) - { - ret = -RED_EINVAL; - } - else - { - uint64_t ullByteOffset = ullSectorStart * gaRedVolConf[bVolNum].ulSectorSize; - uint32_t ulByteCount = ulSectorCount * gaRedVolConf[bVolNum].ulSectorSize; - - RedMemCpy(&gapbRamDisk[bVolNum][ullByteOffset], pBuffer, ulByteCount); - - ret = 0; - } - - return ret; -} - - -/** @brief Flush any caches beneath the file system. - - @param bVolNum The volume number of the volume whose block device is being - flushed. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -static REDSTATUS DiskFlush( - uint8_t bVolNum) -{ - REDSTATUS ret; - - if(gapbRamDisk[bVolNum] == NULL) - { - ret = -RED_EINVAL; - } - else - { - ret = 0; - } - - return ret; -} -#endif /* REDCONF_READ_ONLY == 0 */ - -#else - -#error "Invalid BDEV_EXAMPLE_IMPLEMENTATION value" - -#endif /* BDEV_EXAMPLE_IMPLEMENTATION == ... */ - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osclock.c b/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osclock.c deleted file mode 100755 index aaaf20c..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osclock.c +++ /dev/null @@ -1,79 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements real-time clock functions. -*/ -#include - - -/** @brief Initialize the real time clock. - - The behavior of calling this function when the RTC is already initialized - is undefined. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -REDSTATUS RedOsClockInit(void) -{ - return 0; -} - - -/** @brief Uninitialize the real time clock. - - The behavior of calling this function when the RTC is not initialized is - undefined. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -REDSTATUS RedOsClockUninit(void) -{ - return 0; -} - - -/** @brief Get the date/time. - - The behavior of calling this function when the RTC is not initialized is - undefined. - - @return The number of seconds since January 1, 1970 excluding leap seconds - (in other words, standard Unix time). If the resolution or epoch - of the RTC is different than this, the implementation must convert - it to the expected representation. -*/ -uint32_t RedOsClockGetTime(void) -{ - /* FreeRTOS does not provide an RTC abstraction since most of the systems - it targets have no RTC hardware. If your hardware includes an RTC that - you would like to use, this function must be customized. - */ - return 0; -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osmutex.c b/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osmutex.c deleted file mode 100755 index 68cd0ed..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osmutex.c +++ /dev/null @@ -1,134 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements a synchronization object to provide mutual exclusion. -*/ -#include -#include - -#include -#include - -#if REDCONF_TASK_COUNT > 1U - - -static SemaphoreHandle_t xMutex; -#if defined(configSUPPORT_STATIC_ALLOCATION) && (configSUPPORT_STATIC_ALLOCATION == 1) -static StaticSemaphore_t xMutexBuffer; -#endif - - -/** @brief Initialize the mutex. - - After initialization, the mutex is in the released state. - - The behavior of calling this function when the mutex is still initialized - is undefined. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -REDSTATUS RedOsMutexInit(void) -{ - REDSTATUS ret = 0; - - #if defined(configSUPPORT_STATIC_ALLOCATION) && (configSUPPORT_STATIC_ALLOCATION == 1) - xMutex = xSemaphoreCreateMutexStatic(&xMutexBuffer); - - if(xMutex == NULL) - { - /* The only error case for xSemaphoreCreateMutexStatic is that the mutex - buffer parameter is NULL, which is not the case. - */ - REDERROR(); - ret = -RED_EINVAL; - } - - #else - xMutex = xSemaphoreCreateMutex(); - if(xMutex == NULL) - { - ret = -RED_ENOMEM; - } - #endif - - return ret; -} - - -/** @brief Uninitialize the mutex. - - The behavior of calling this function when the mutex is not initialized is - undefined; likewise, the behavior of uninitializing the mutex when it is - in the acquired state is undefined. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -REDSTATUS RedOsMutexUninit(void) -{ - vSemaphoreDelete(xMutex); - xMutex = NULL; - - return 0; -} - - -/** @brief Acquire the mutex. - - The behavior of calling this function when the mutex is not initialized is - undefined; likewise, the behavior of recursively acquiring the mutex is - undefined. -*/ -void RedOsMutexAcquire(void) -{ - while(xSemaphoreTake(xMutex, portMAX_DELAY) != pdTRUE) - { - } -} - - -/** @brief Release the mutex. - - The behavior is undefined in the following cases: - - - Releasing the mutex when the mutex is not initialized. - - Releasing the mutex when it is not in the acquired state. - - Releasing the mutex from a task or thread other than the one which - acquired the mutex. -*/ -void RedOsMutexRelease(void) -{ - BaseType_t xSuccess; - - xSuccess = xSemaphoreGive(xMutex); - REDASSERT(xSuccess == pdTRUE); - IGNORE_ERRORS(xSuccess); -} - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osoutput.c b/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osoutput.c deleted file mode 100755 index 8a7fb1d..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/osoutput.c +++ /dev/null @@ -1,70 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements outputting a character string. -*/ -#include - -#if REDCONF_OUTPUT == 1 - -#include - - -/** @brief Write a string to a user-visible output location. - - Write a null-terminated string to the serial port, console, terminal, or - other display device, such that the text is visible to the user. - - @param pszString A null-terminated string. -*/ -void RedOsOutputString( - const char *pszString) -{ - if(pszString == NULL) - { - REDERROR(); - } - else - { - uint32_t ulIdx = 0U; - - while(pszString[ulIdx] != '\0') - { - OUTPUT_CHARACTER(pszString[ulIdx]); - - /* Serial output often requires a \r to print newlines correctly. - */ - if(pszString[ulIdx] == '\n') - { - OUTPUT_CHARACTER('\r'); - } - - ulIdx++; - } - } -} - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/ostask.c b/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/ostask.c deleted file mode 100755 index 01bf382..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/ostask.c +++ /dev/null @@ -1,68 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements task functions. -*/ -#include -#include - -#include - -#if (REDCONF_TASK_COUNT > 1U) && (REDCONF_API_POSIX == 1) - -#include - -#if INCLUDE_xTaskGetCurrentTaskHandle != 1 - #error "INCLUDE_xTaskGetCurrentTaskHandle must be 1 when REDCONF_TASK_COUNT > 1 and REDCONF_API_POSIX == 1" -#endif - - -/** @brief Get the current task ID. - - This task ID must be unique for all tasks using the file system. - - @return The task ID. Must not be 0. -*/ -uint32_t RedOsTaskId(void) -{ - /* Simply casting the xTaskGetCurrentTaskHandle() return value results in - warnings from some compilers, so use variables. - */ - TaskHandle_t xTask = xTaskGetCurrentTaskHandle(); - uintptr_t taskptr = CAST_TASK_PTR_TO_UINTPTR(xTask); - uint32_t ulTaskPtr = (uint32_t)taskptr; - - /* Assert no information was lost casting from uintptr_t to uint32_t. - */ - REDASSERT(ulTaskPtr == taskptr); - - /* NULL is a valid task handle in FreeRTOS, so add one to all task IDs. - */ - REDASSERT((ulTaskPtr + 1U) != 0U); - return ulTaskPtr + 1U; -} - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/ostimestamp.c b/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/ostimestamp.c deleted file mode 100755 index 364813e..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/os/freertos/services/ostimestamp.c +++ /dev/null @@ -1,109 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements timestamp functions. - - The functionality implemented herein is not needed for the file system - driver, only to provide accurate results with performance tests. -*/ -#include -#include - -#include - - -/* configTICK_RATE_HZ is almost always 100, 250, 500, or 1000. If - 1000000U % configTICK_RATE_HZ != 0, then RedOsTimePassed() will be a - little inaccurate. -*/ -#define MICROSECS_PER_TICK (1000000U / configTICK_RATE_HZ) - - -/** @brief Initialize the timestamp service. - - The behavior of invoking this function when timestamps are already - initialized is undefined. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_ENOSYS The timestamp service has not been implemented. -*/ -REDSTATUS RedOsTimestampInit(void) -{ - return 0; -} - - -/** @brief Uninitialize the timestamp service. - - The behavior of invoking this function when timestamps are not initialized - is undefined. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. -*/ -REDSTATUS RedOsTimestampUninit(void) -{ - return 0; -} - - -/** @brief Retrieve a timestamp. - - The behavior of invoking this function when timestamps are not initialized - is undefined - - @return A timestamp which can later be passed to RedOsTimePassed() to - determine the amount of time which passed between the two calls. -*/ -REDTIMESTAMP RedOsTimestamp(void) -{ - return xTaskGetTickCount(); -} - - -/** @brief Determine how much time has passed since a timestamp was retrieved. - - The behavior of invoking this function when timestamps are not initialized - is undefined. - - @param tsSince A timestamp acquired earlier via RedOsTimestamp(). - - @return The number of microseconds which have passed since @p tsSince. -*/ -uint64_t RedOsTimePassed( - REDTIMESTAMP tsSince) -{ - /* This works even if the tick count has wrapped around, provided it has - only wrapped around once. - */ - uint32_t ulTicksPassed = (uint32_t)xTaskGetTickCount() - tsSince; - uint64_t ullMicrosecs = (uint64_t)ulTicksPassed * MICROSECS_PER_TICK; - - return ullMicrosecs; -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/posix/path.c b/FreeRTOS-Plus/Source/Reliance-Edge/posix/path.c deleted file mode 100755 index 4e4df2e..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/posix/path.c +++ /dev/null @@ -1,448 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements path utilities for the POSIX-like API layer. -*/ -#include - -#if REDCONF_API_POSIX == 1 - -#include -#include -#include -#include - - -static bool IsRootDir(const char *pszLocalPath); -static bool PathHasMoreNames(const char *pszPathIdx); - - -/** @brief Split a path into its component parts: a volume and a volume-local - path. - - @param pszPath The path to split. - @param pbVolNum On successful return, if non-NULL, populated with - the volume number extracted from the path. - @param ppszLocalPath On successful return, populated with the - volume-local path: the path stripped of any volume - path prefixing. If this parameter is NULL, that - indicates there should be no local path, and any - characters beyond the prefix (other than path - separators) are treated as an error. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p pszPath is `NULL`. - @retval -RED_ENOENT @p pszPath could not be matched to any volume; or - @p ppszLocalPath is NULL but @p pszPath includes a local - path. -*/ -REDSTATUS RedPathSplit( - const char *pszPath, - uint8_t *pbVolNum, - const char **ppszLocalPath) -{ - REDSTATUS ret = 0; - - if(pszPath == NULL) - { - ret = -RED_EINVAL; - } - else - { - const char *pszLocalPath = pszPath; - uint8_t bMatchVol = UINT8_MAX; - uint32_t ulMatchLen = 0U; - uint8_t bDefaultVolNum = UINT8_MAX; - uint8_t bVolNum; - - for(bVolNum = 0U; bVolNum < REDCONF_VOLUME_COUNT; bVolNum++) - { - const char *pszPrefix = gaRedVolConf[bVolNum].pszPathPrefix; - uint32_t ulPrefixLen = RedStrLen(pszPrefix); - - if(ulPrefixLen == 0U) - { - /* A volume with a path prefix of an empty string is the - default volume, used when the path does not match the - prefix of any other volume. - - The default volume should only be found once. During - initialization, RedCoreInit() ensures that all volume - prefixes are unique (including empty prefixes). - */ - REDASSERT(bDefaultVolNum == UINT8_MAX); - bDefaultVolNum = bVolNum; - } - /* For a path to match, it must either be the prefix exactly, or - be followed by a path separator character. Thus, with a volume - prefix of "/foo", both "/foo" and "/foo/bar" are matches, but - "/foobar" is not. - */ - else if( (RedStrNCmp(pszPath, pszPrefix, ulPrefixLen) == 0) - && ((pszPath[ulPrefixLen] == '\0') || (pszPath[ulPrefixLen] == REDCONF_PATH_SEPARATOR))) - { - /* The length of this match should never exactly equal the - length of a previous match: that would require a duplicate - volume name, which should have been detected during init. - */ - REDASSERT(ulPrefixLen != ulMatchLen); - - /* If multiple prefixes match, the longest takes precedence. - Thus, if there are two prefixes "Flash" and "Flash/Backup", - the path "Flash/Backup/" will not be erroneously matched - with the "Flash" volume. - */ - if(ulPrefixLen > ulMatchLen) - { - bMatchVol = bVolNum; - ulMatchLen = ulPrefixLen; - } - } - else - { - /* No match, keep looking. - */ - } - } - - if(bMatchVol != UINT8_MAX) - { - /* The path matched a volume path prefix. - */ - bVolNum = bMatchVol; - pszLocalPath = &pszPath[ulMatchLen]; - } - else if(bDefaultVolNum != UINT8_MAX) - { - /* The path didn't match any of the prefixes, but one of the - volumes has a path prefix of "", so an unprefixed path is - assigned to that volume. - */ - bVolNum = bDefaultVolNum; - REDASSERT(pszLocalPath == pszPath); - } - else - { - /* The path cannot be assigned a volume. - */ - ret = -RED_ENOENT; - } - - if(ret == 0) - { - if(pbVolNum != NULL) - { - *pbVolNum = bVolNum; - } - - if(ppszLocalPath != NULL) - { - *ppszLocalPath = pszLocalPath; - } - else - { - /* If no local path is expected, then the string should either - terminate after the path prefix or the local path should name - the root directory. Allowing path separators here means that - red_mount("/data/") is OK with a path prefix of "/data". - */ - if(pszLocalPath[0U] != '\0') - { - if(!IsRootDir(pszLocalPath)) - { - ret = -RED_ENOENT; - } - } - } - } - } - - return ret; -} - - -/** @brief Lookup the inode named by the given path. - - @param pszLocalPath The path to lookup; this is a local path, without any - volume prefix. - @param pulInode On successful return, populated with the number of the - inode named by @p pszLocalPath. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p pszLocalPath is `NULL`; or @p pulInode is - `NULL`. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOENT @p pszLocalPath is an empty string; or - @p pszLocalPath does not name an existing file - or directory. - @retval -RED_ENOTDIR A component of the path other than the last is - not a directory. - @retval -RED_ENAMETOOLONG The length of a component of @p pszLocalPath is - longer than #REDCONF_NAME_MAX. -*/ -REDSTATUS RedPathLookup( - const char *pszLocalPath, - uint32_t *pulInode) -{ - REDSTATUS ret; - - if((pszLocalPath == NULL) || (pulInode == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else if(pszLocalPath[0U] == '\0') - { - ret = -RED_ENOENT; - } - else if(IsRootDir(pszLocalPath)) - { - ret = 0; - *pulInode = INODE_ROOTDIR; - } - else - { - uint32_t ulPInode; - const char *pszName; - - ret = RedPathToName(pszLocalPath, &ulPInode, &pszName); - - if(ret == 0) - { - ret = RedCoreLookup(ulPInode, pszName, pulInode); - } - } - - return ret; -} - - -/** @brief Given a path, return the parent inode number and a pointer to the - last component in the path (the name). - - @param pszLocalPath The path to examine; this is a local path, without any - volume prefix. - @param pulPInode On successful return, populated with the inode number of - the parent directory of the last component in the path. - For example, with the path "a/b/c", populated with the - inode number of "b". - @param ppszName On successful return, populated with a pointer to the - last component in the path. For example, with the path - "a/b/c", populated with a pointer to "c". - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p pszLocalPath is `NULL`; or @p pulPInode is - `NULL`; or @p ppszName is `NULL`; or the path - names the root directory. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENOENT @p pszLocalPath is an empty string; or a - component of the path other than the last does - not exist. - @retval -RED_ENOTDIR A component of the path other than the last is - not a directory. - @retval -RED_ENAMETOOLONG The length of a component of @p pszLocalPath is - longer than #REDCONF_NAME_MAX. -*/ -REDSTATUS RedPathToName( - const char *pszLocalPath, - uint32_t *pulPInode, - const char **ppszName) -{ - REDSTATUS ret; - - if((pszLocalPath == NULL) || (pulPInode == NULL) || (ppszName == NULL)) - { - REDERROR(); - ret = -RED_EINVAL; - } - else if(IsRootDir(pszLocalPath)) - { - ret = -RED_EINVAL; - } - else if(pszLocalPath[0U] == '\0') - { - ret = -RED_ENOENT; - } - else - { - uint32_t ulInode = INODE_ROOTDIR; - uint32_t ulPInode = INODE_INVALID; - uint32_t ulPathIdx = 0U; - uint32_t ulLastNameIdx = 0U; - - ret = 0; - - do - { - uint32_t ulNameLen; - - /* Skip over path separators, to get pszLocalPath[ulPathIdx] - pointing at the next name. - */ - while(pszLocalPath[ulPathIdx] == REDCONF_PATH_SEPARATOR) - { - ulPathIdx++; - } - - if(pszLocalPath[ulPathIdx] == '\0') - { - break; - } - - /* Point ulLastNameIdx at the first character of the name; after - we exit the loop, it will point at the first character of the - last name in the path. - */ - ulLastNameIdx = ulPathIdx; - - /* Point ulPInode at the parent inode: either the root inode - (first pass) or the inode of the previous name. After we exit - the loop, this will point at the parent inode of the last name. - */ - ulPInode = ulInode; - - ulNameLen = RedNameLen(&pszLocalPath[ulPathIdx]); - - /* Lookup the inode of the name, unless we are at the last name in - the path: we don't care whether the last name exists or not. - */ - if(PathHasMoreNames(&pszLocalPath[ulPathIdx + ulNameLen])) - { - ret = RedCoreLookup(ulPInode, &pszLocalPath[ulPathIdx], &ulInode); - } - - /* Move on to the next path element. - */ - if(ret == 0) - { - ulPathIdx += ulNameLen; - } - } - while(ret == 0); - - if(ret == 0) - { - *pulPInode = ulPInode; - *ppszName = &pszLocalPath[ulLastNameIdx]; - } - } - - return ret; -} - - -/** @brief Determine whether a path names the root directory. - - @param pszLocalPath The path to examine; this is a local path, without any - volume prefix. - - @return Returns whether @p pszLocalPath names the root directory. - - @retval true @p pszLocalPath names the root directory. - @retval false @p pszLocalPath does not name the root directory. -*/ -static bool IsRootDir( - const char *pszLocalPath) -{ - bool fRet; - - if(pszLocalPath == NULL) - { - REDERROR(); - fRet = false; - } - else - { - uint32_t ulIdx = 0U; - - /* A string containing nothing but path separators (usually only one) - names the root directory. An empty string does *not* name the root - directory, since in POSIX empty strings typically elicit -RED_ENOENT - errors. - */ - while(pszLocalPath[ulIdx] == REDCONF_PATH_SEPARATOR) - { - ulIdx++; - } - - fRet = (ulIdx > 0U) && (pszLocalPath[ulIdx] == '\0'); - } - - return fRet; -} - - -/** @brief Determine whether there are more names in a path. - - Example | Result - ------- | ------ - "" false - "/" false - "//" false - "a" true - "/a" true - "//a" true - - @param pszPathIdx The path to examine, incremented to the point of - interest. - - @return Returns whether there are more names in @p pszPathIdx. - - @retval true @p pszPathIdx has more names. - @retval false @p pszPathIdx has no more names. -*/ -static bool PathHasMoreNames( - const char *pszPathIdx) -{ - bool fRet; - - if(pszPathIdx == NULL) - { - REDERROR(); - fRet = false; - } - else - { - uint32_t ulIdx = 0U; - - while(pszPathIdx[ulIdx] == REDCONF_PATH_SEPARATOR) - { - ulIdx++; - } - - fRet = pszPathIdx[ulIdx] != '\0'; - } - - return fRet; -} - -#endif /* REDCONF_API_POSIX */ - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/posix/posix.c b/FreeRTOS-Plus/Source/Reliance-Edge/posix/posix.c deleted file mode 100755 index ef83395..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/posix/posix.c +++ /dev/null @@ -1,3088 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implementation of the the Reliance Edge POSIX-like API. -*/ - -#include - -#if REDCONF_API_POSIX == 1 - -/** @defgroup red_group_posix The POSIX-like File System Interface - @{ -*/ - -#include -#include -#include -#include - - -/*------------------------------------------------------------------- - File Descriptors --------------------------------------------------------------------*/ - -#define FD_GEN_BITS 11U /* File descriptor bits for mount generation. */ -#define FD_VOL_BITS 8U /* File descriptor bits for volume number. */ -#define FD_IDX_BITS 12U /* File descriptor bits for handle index. */ - -/* 31 bits available: file descriptors are int32_t, but the sign bit must - always be zero. -*/ -#if (FD_GEN_BITS + FD_VOL_BITS + FD_IDX_BITS) > 31U - #error "Internal error: too many file descriptor bits!" -#endif - -/* Maximum values for file descriptor components. -*/ -#define FD_GEN_MAX ((1UL << FD_GEN_BITS) - 1U) -#define FD_VOL_MAX ((1UL << FD_VOL_BITS) - 1U) -#define FD_IDX_MAX ((1UL << FD_IDX_BITS) - 1U) - -#if REDCONF_VOLUME_COUNT > FD_VOL_MAX - #error "Error: Too many file system volumes!" -#endif -#if REDCONF_HANDLE_COUNT > (FD_IDX_MAX + 1U) - #error "Error: Too many file system handles!" -#endif - -/* File descriptors must never be negative; and must never be zero, one, or - two, to avoid confusion with STDIN, STDOUT, and STDERR. -*/ -#define FD_MIN (3) - -/*------------------------------------------------------------------- - Handles --------------------------------------------------------------------*/ - -/* Mask of all RED_O_* values. -*/ -#define RED_O_MASK (RED_O_RDONLY|RED_O_WRONLY|RED_O_RDWR|RED_O_APPEND|RED_O_CREAT|RED_O_EXCL|RED_O_TRUNC) - -#define HFLAG_DIRECTORY 0x01U /* Handle is for a directory. */ -#define HFLAG_READABLE 0x02U /* Handle is readable. */ -#define HFLAG_WRITEABLE 0x04U /* Handle is writeable. */ -#define HFLAG_APPENDING 0x08U /* Handle was opened in append mode. */ - -/* @brief Handle structure, used to implement file descriptors and directory - streams. -*/ -typedef struct sREDHANDLE -{ - uint32_t ulInode; /**< Inode number; 0 if handle is available. */ - uint8_t bVolNum; /**< Volume containing the inode. */ - uint8_t bFlags; /**< Handle flags (type and mode). */ - uint64_t ullOffset; /**< File or directory offset. */ - #if REDCONF_API_POSIX_READDIR == 1 - REDDIRENT dirent; /**< Dirent structure returned by red_readdir(). */ - #endif -} REDHANDLE; - -/*------------------------------------------------------------------- - Tasks --------------------------------------------------------------------*/ - -#if REDCONF_TASK_COUNT > 1U -/* @brief Per-task information. -*/ -typedef struct -{ - uint32_t ulTaskId; /**< ID of the task which owns this slot; 0 if free. */ - REDSTATUS iErrno; /**< Last error value. */ -} TASKSLOT; -#endif - -/*------------------------------------------------------------------- - Local Prototypes --------------------------------------------------------------------*/ - -#if (REDCONF_READ_ONLY == 0) && ((REDCONF_API_POSIX_UNLINK == 1) || (REDCONF_API_POSIX_RMDIR == 1)) -static REDSTATUS UnlinkSub(const char *pszPath, FTYPE type); -#endif -static REDSTATUS FildesOpen(const char *pszPath, uint32_t ulOpenMode, FTYPE type, int32_t *piFildes); -static REDSTATUS FildesClose(int32_t iFildes); -static REDSTATUS FildesToHandle(int32_t iFildes, FTYPE expectedType, REDHANDLE **ppHandle); -static int32_t FildesPack(uint16_t uHandleIdx, uint8_t bVolNum); -static void FildesUnpack(int32_t iFildes, uint16_t *puHandleIdx, uint8_t *pbVolNum, uint16_t *puGeneration); -#if REDCONF_API_POSIX_READDIR == 1 -static bool DirStreamIsValid(const REDDIR *pDirStream); -#endif -static REDSTATUS PosixEnter(void); -static void PosixLeave(void); -static REDSTATUS ModeTypeCheck(uint16_t uMode, FTYPE expectedType); -#if (REDCONF_READ_ONLY == 0) && ((REDCONF_API_POSIX_UNLINK == 1) || (REDCONF_API_POSIX_RMDIR == 1) || ((REDCONF_API_POSIX_RENAME == 1) && (REDCONF_RENAME_ATOMIC == 1))) -static REDSTATUS InodeUnlinkCheck(uint32_t ulInode); -#endif -#if REDCONF_TASK_COUNT > 1U -static REDSTATUS TaskRegister(uint32_t *pulTaskIdx); -#endif -static int32_t PosixReturn(REDSTATUS iError); - -/*------------------------------------------------------------------- - Globals --------------------------------------------------------------------*/ - -static bool gfPosixInited; /* Whether driver is initialized. */ -static REDHANDLE gaHandle[REDCONF_HANDLE_COUNT]; /* Array of all handles. */ -#if REDCONF_TASK_COUNT > 1U -static TASKSLOT gaTask[REDCONF_TASK_COUNT]; /* Array of task slots. */ -#endif - -/* Array of volume mount "generations". These are incremented for a volume - each time that volume is mounted. The generation number (along with the - volume number) is incorporated into the file descriptors; a stale file - descriptor from a previous mount can be detected since it will include a - stale generation number. -*/ -static uint16_t gauGeneration[REDCONF_VOLUME_COUNT]; - - -/*------------------------------------------------------------------- - Public API --------------------------------------------------------------------*/ - -/** @brief Initialize the Reliance Edge file system driver. - - Prepares the Reliance Edge file system driver to be used. Must be the first - Reliance Edge function to be invoked: no volumes can be mounted or formatted - until the driver has been initialized. - - If this function is called when the Reliance Edge driver is already - initialized, it does nothing and returns success. - - This function is not thread safe: attempting to initialize from multiple - threads could leave things in a bad state. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EINVAL: The volume path prefix configuration is invalid. -*/ -int32_t red_init(void) -{ - REDSTATUS ret; - - if(gfPosixInited) - { - ret = 0; - } - else - { - ret = RedCoreInit(); - if(ret == 0) - { - RedMemSet(gaHandle, 0U, sizeof(gaHandle)); - - #if REDCONF_TASK_COUNT > 1U - RedMemSet(gaTask, 0U, sizeof(gaTask)); - #endif - - gfPosixInited = true; - } - } - - return PosixReturn(ret); -} - - -/** @brief Uninitialize the Reliance Edge file system driver. - - Tears down the Reliance Edge file system driver. Cannot be used until all - Reliance Edge volumes are unmounted. A subsequent call to red_init() will - initialize the driver again. - - If this function is called when the Reliance Edge driver is already - uninitialized, it does nothing and returns success. - - This function is not thread safe: attempting to uninitialize from multiple - threads could leave things in a bad state. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EBUSY: At least one volume is still mounted. -*/ -int32_t red_uninit(void) -{ - REDSTATUS ret; - - if(gfPosixInited) - { - ret = PosixEnter(); - - if(ret == 0) - { - uint8_t bVolNum; - - for(bVolNum = 0U; bVolNum < REDCONF_VOLUME_COUNT; bVolNum++) - { - if(gaRedVolume[bVolNum].fMounted) - { - ret = -RED_EBUSY; - break; - } - } - - if(ret == 0) - { - /* All volumes are unmounted. Mark the driver as - uninitialized before releasing the FS mutex, to avoid any - race condition where a volume could be mounted and then the - driver uninitialized with a mounted volume. - */ - gfPosixInited = false; - } - - /* The FS mutex must be released before we uninitialize the core, - since the FS mutex needs to be in the released state when it - gets uninitialized. - - Don't use PosixLeave(), since it asserts gfPosixInited is true. - */ - #if REDCONF_TASK_COUNT > 1U - RedOsMutexRelease(); - #endif - } - - if(ret == 0) - { - ret = RedCoreUninit(); - - /* Not good if the above fails, since things might be partly, but - not entirely, torn down, and there might not be a way back to - a valid driver state. - */ - REDASSERT(ret == 0); - } - } - else - { - ret = 0; - } - - return PosixReturn(ret); -} - - -/** @brief Mount a file system volume. - - Prepares the file system volume to be accessed. Mount will fail if the - volume has never been formatted, or if the on-disk format is inconsistent - with the compile-time configuration. - - An error is returned if the volume is already mounted. - - @param pszVolume A path prefix identifying the volume to mount. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EBUSY: Volume is already mounted. - - #RED_EINVAL: @p pszVolume is `NULL`; or the driver is uninitialized. - - #RED_EIO: Volume not formatted, improperly formatted, or corrupt. - - #RED_ENOENT: @p pszVolume is not a valid volume path prefix. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_mount( - const char *pszVolume) -{ - REDSTATUS ret; - - ret = PosixEnter(); - - if(ret == 0) - { - uint8_t bVolNum; - - ret = RedPathSplit(pszVolume, &bVolNum, NULL); - - /* The core will return success if the volume is already mounted, so - check for that condition here to propagate the error. - */ - if((ret == 0) && gaRedVolume[bVolNum].fMounted) - { - ret = -RED_EBUSY; - } - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(bVolNum); - } - #endif - - if(ret == 0) - { - ret = RedCoreVolMount(); - } - - if(ret == 0) - { - /* Increment the mount generation, invalidating file descriptors - from previous mounts. Note that while the generation numbers - are stored in 16-bit values, we have less than 16-bits to store - generations in the file descriptors, so we must wrap-around - manually. - */ - gauGeneration[bVolNum]++; - if(gauGeneration[bVolNum] > FD_GEN_MAX) - { - /* Wrap-around to one, rather than zero. The generation is - stored in the top bits of the file descriptor, and doing - this means that low numbers are never valid file - descriptors. This implements the requirement that 0, 1, - and 2 are never valid file descriptors, thereby avoiding - confusion with STDIN, STDOUT, and STDERR. - */ - gauGeneration[bVolNum] = 1U; - } - } - - PosixLeave(); - } - - return PosixReturn(ret); -} - - -/** @brief Unmount a file system volume. - - This function discards the in-memory state for the file system and marks it - as unmounted. Subsequent attempts to access the volume will fail until the - volume is mounted again. - - If unmount automatic transaction points are enabled, this function will - commit a transaction point prior to unmounting. If unmount automatic - transaction points are disabled, this function will unmount without - transacting, effectively discarding the working state. - - Before unmounting, this function will wait for any active file system - thread to complete by acquiring the FS mutex. The volume will be marked as - unmounted before the FS mutex is released, so subsequent FS threads will - possibly block and then see an error when attempting to access a volume - which is unmounting or unmounted. If the volume has open handles, the - unmount will fail. - - An error is returned if the volume is already unmounted. - - @param pszVolume A path prefix identifying the volume to unmount. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EBUSY: There are still open handles for this file system volume. - - #RED_EINVAL: @p pszVolume is `NULL`; or the driver is uninitialized; or - the volume is already unmounted. - - #RED_EIO: I/O error during unmount automatic transaction point. - - #RED_ENOENT: @p pszVolume is not a valid volume path prefix. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_umount( - const char *pszVolume) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - uint8_t bVolNum; - - ret = RedPathSplit(pszVolume, &bVolNum, NULL); - - /* The core will return success if the volume is already unmounted, so - check for that condition here to propagate the error. - */ - if((ret == 0) && !gaRedVolume[bVolNum].fMounted) - { - ret = -RED_EINVAL; - } - - if(ret == 0) - { - uint16_t uHandleIdx; - - /* Do not unmount the volume if it still has open handles. - */ - for(uHandleIdx = 0U; uHandleIdx < REDCONF_HANDLE_COUNT; uHandleIdx++) - { - const REDHANDLE *pHandle = &gaHandle[uHandleIdx]; - - if((pHandle->ulInode != INODE_INVALID) && (pHandle->bVolNum == bVolNum)) - { - ret = -RED_EBUSY; - break; - } - } - } - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(bVolNum); - } - #endif - - if(ret == 0) - { - ret = RedCoreVolUnmount(); - } - - PosixLeave(); - } - - return PosixReturn(ret); -} - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_FORMAT == 1) -/** @brief Format a file system volume. - - Uses the statically defined volume configuration. After calling this - function, the volume needs to be mounted -- see red_mount(). - - An error is returned if the volume is mounted. - - @param pszVolume A path prefix identifying the volume to format. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EBUSY: Volume is mounted. - - #RED_EINVAL: @p pszVolume is `NULL`; or the driver is uninitialized. - - #RED_EIO: I/O error formatting the volume. - - #RED_ENOENT: @p pszVolume is not a valid volume path prefix. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_format( - const char *pszVolume) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - uint8_t bVolNum; - - ret = RedPathSplit(pszVolume, &bVolNum, NULL); - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(bVolNum); - } - #endif - - if(ret == 0) - { - ret = RedCoreVolFormat(); - } - - PosixLeave(); - } - - return PosixReturn(ret); -} -#endif - - -#if REDCONF_READ_ONLY == 0 -/** @brief Commit a transaction point. - - Reliance Edge is a transactional file system. All modifications, of both - metadata and filedata, are initially working state. A transaction point - is a process whereby the working state atomically becomes the committed - state, replacing the previous committed state. Whenever Reliance Edge is - mounted, including after power loss, the state of the file system after - mount is the most recent committed state. Nothing from the committed - state is ever missing, and nothing from the working state is ever included. - - @param pszVolume A path prefix identifying the volume to transact. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EINVAL: Volume is not mounted; or @p pszVolume is `NULL`. - - #RED_EIO: I/O error during the transaction point. - - #RED_ENOENT: @p pszVolume is not a valid volume path prefix. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_transact( - const char *pszVolume) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - uint8_t bVolNum; - - ret = RedPathSplit(pszVolume, &bVolNum, NULL); - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(bVolNum); - } - #endif - - if(ret == 0) - { - ret = RedCoreVolTransact(); - } - - PosixLeave(); - } - - return PosixReturn(ret); -} -#endif - - -#if REDCONF_READ_ONLY == 0 -/** @brief Update the transaction mask. - - The following events are available: - - - #RED_TRANSACT_UMOUNT - - #RED_TRANSACT_CREAT - - #RED_TRANSACT_UNLINK - - #RED_TRANSACT_MKDIR - - #RED_TRANSACT_RENAME - - #RED_TRANSACT_LINK - - #RED_TRANSACT_CLOSE - - #RED_TRANSACT_WRITE - - #RED_TRANSACT_FSYNC - - #RED_TRANSACT_TRUNCATE - - #RED_TRANSACT_VOLFULL - - The #RED_TRANSACT_MANUAL macro (by itself) may be used to disable all - automatic transaction events. The #RED_TRANSACT_MASK macro is a bitmask - of all transaction flags, excluding those representing excluded - functionality. - - Attempting to enable events for excluded functionality will result in an - error. - - @param pszVolume The path prefix of the volume whose transaction mask is - being changed. - @param ulEventMask A bitwise-OR'd mask of automatic transaction events to - be set as the current transaction mode. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EINVAL: Volume is not mounted; or @p pszVolume is `NULL`; or - @p ulEventMask contains invalid bits. - - #RED_ENOENT: @p pszVolume is not a valid volume path prefix. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_settransmask( - const char *pszVolume, - uint32_t ulEventMask) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - uint8_t bVolNum; - - ret = RedPathSplit(pszVolume, &bVolNum, NULL); - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(bVolNum); - } - #endif - - if(ret == 0) - { - ret = RedCoreTransMaskSet(ulEventMask); - } - - PosixLeave(); - } - - return PosixReturn(ret); -} -#endif - - -/** @brief Read the transaction mask. - - If the volume is read-only, the returned event mask is always zero. - - @param pszVolume The path prefix of the volume whose transaction mask is - being retrieved. - @param pulEventMask Populated with a bitwise-OR'd mask of automatic - transaction events which represent the current - transaction mode for the volume. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EINVAL: Volume is not mounted; or @p pszVolume is `NULL`; or - @p pulEventMask is `NULL`. - - #RED_ENOENT: @p pszVolume is not a valid volume path prefix. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_gettransmask( - const char *pszVolume, - uint32_t *pulEventMask) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - uint8_t bVolNum; - - ret = RedPathSplit(pszVolume, &bVolNum, NULL); - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(bVolNum); - } - #endif - - if(ret == 0) - { - ret = RedCoreTransMaskGet(pulEventMask); - } - - PosixLeave(); - } - - return PosixReturn(ret); -} - - -/** @brief Query file system status information. - - @p pszVolume should name a valid volume prefix or a valid root directory; - this differs from POSIX statvfs, where any existing file or directory is a - valid path. - - @param pszVolume The path prefix of the volume to query. - @param pStatvfs The buffer to populate with volume information. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EINVAL: Volume is not mounted; or @p pszVolume is `NULL`; or - @p pStatvfs is `NULL`. - - #RED_ENOENT: @p pszVolume is not a valid volume path prefix. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_statvfs( - const char *pszVolume, - REDSTATFS *pStatvfs) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - uint8_t bVolNum; - - ret = RedPathSplit(pszVolume, &bVolNum, NULL); - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(bVolNum); - } - #endif - - if(ret == 0) - { - ret = RedCoreVolStat(pStatvfs); - } - - PosixLeave(); - } - - return PosixReturn(ret); -} - - -/** @brief Open a file or directory. - - Exactly one file access mode must be specified: - - - #RED_O_RDONLY: Open for reading only. - - #RED_O_WRONLY: Open for writing only. - - #RED_O_RDWR: Open for reading and writing. - - Directories can only be opened with `RED_O_RDONLY`. - - The following flags may also be used: - - - #RED_O_APPEND: Set the file offset to the end-of-file prior to each - write. - - #RED_O_CREAT: Create the named file if it does not exist. - - #RED_O_EXCL: In combination with `RED_O_CREAT`, return an error if the - path already exists. - - #RED_O_TRUNC: Truncate the opened file to size zero. Only supported when - #REDCONF_API_POSIX_FTRUNCATE is true. - - #RED_O_CREAT, #RED_O_EXCL, and #RED_O_TRUNC are invalid with #RED_O_RDONLY. - #RED_O_EXCL is invalid without #RED_O_CREAT. - - If the volume is read-only, #RED_O_RDONLY is the only valid open flag; use - of any other flag will result in an error. - - If #RED_O_TRUNC frees data which is in the committed state, it will not - return to free space until after a transaction point. - - The returned file descriptor must later be closed with red_close(). - - Unlike POSIX open, there is no optional third argument for the permissions - (which Reliance Edge does not use) and other open flags (like `O_SYNC`) are - not supported. - - @param pszPath The path to the file or directory. - @param ulOpenMode The open flags (mask of `RED_O_` values). - - @return On success, a nonnegative file descriptor is returned. On error, - -1 is returned and #red_errno is set appropriately. - - Errno values - - #RED_EEXIST: Using #RED_O_CREAT and #RED_O_EXCL, and the indicated path - already exists. - - #RED_EINVAL: @p ulOpenMode is invalid; or @p pszPath is `NULL`; or the - volume containing the path is not mounted. - - #RED_EIO: A disk I/O error occurred. - - #RED_EISDIR: The path names a directory and @p ulOpenMode includes - #RED_O_WRONLY or #RED_O_RDWR. - - #RED_EMFILE: There are no available file descriptors. - - #RED_ENAMETOOLONG: The length of a component of @p pszPath is longer than - #REDCONF_NAME_MAX. - - #RED_ENFILE: Attempting to create a file but the file system has used all - available inode slots. - - #RED_ENOENT: #RED_O_CREAT is not set and the named file does not exist; or - #RED_O_CREAT is set and the parent directory does not exist; or the - volume does not exist; or the @p pszPath argument, after removing the - volume prefix, points to an empty string. - - #RED_ENOSPC: The file does not exist and #RED_O_CREAT was specified, but - there is insufficient free space to expand the directory or to create the - new file. - - #RED_ENOTDIR: A component of the prefix in @p pszPath does not name a - directory. - - #RED_EROFS: The path resides on a read-only file system and a write - operation was requested. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_open( - const char *pszPath, - uint32_t ulOpenMode) -{ - int32_t iFildes = -1; /* Init'd to quiet warnings. */ - REDSTATUS ret; - - #if REDCONF_READ_ONLY == 1 - if(ulOpenMode != RED_O_RDONLY) - { - ret = -RED_EROFS; - } - #else - if( (ulOpenMode != (ulOpenMode & RED_O_MASK)) - || ((ulOpenMode & (RED_O_RDONLY|RED_O_WRONLY|RED_O_RDWR)) == 0U) - || (((ulOpenMode & RED_O_RDONLY) != 0U) && ((ulOpenMode & (RED_O_WRONLY|RED_O_RDWR)) != 0U)) - || (((ulOpenMode & RED_O_WRONLY) != 0U) && ((ulOpenMode & (RED_O_RDONLY|RED_O_RDWR)) != 0U)) - || (((ulOpenMode & RED_O_RDWR) != 0U) && ((ulOpenMode & (RED_O_RDONLY|RED_O_WRONLY)) != 0U)) - || (((ulOpenMode & (RED_O_TRUNC|RED_O_CREAT|RED_O_EXCL)) != 0U) && ((ulOpenMode & RED_O_RDONLY) != 0U)) - || (((ulOpenMode & RED_O_EXCL) != 0U) && ((ulOpenMode & RED_O_CREAT) == 0U))) - { - ret = -RED_EINVAL; - } - #if REDCONF_API_POSIX_FTRUNCATE == 0 - else if((ulOpenMode & RED_O_TRUNC) != 0U) - { - ret = -RED_EINVAL; - } - #endif - #endif - else - { - ret = PosixEnter(); - } - - if(ret == 0) - { - ret = FildesOpen(pszPath, ulOpenMode, FTYPE_EITHER, &iFildes); - - PosixLeave(); - } - - if(ret != 0) - { - iFildes = PosixReturn(ret); - } - - return iFildes; -} - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_UNLINK == 1) -/** @brief Delete a file or directory. - - The given name is deleted and the link count of the corresponding inode is - decremented. If the link count falls to zero (no remaining hard links), - the inode will be deleted. - - Unlike POSIX unlink, deleting a file or directory with open handles (file - descriptors or directory streams) will fail with an #RED_EBUSY error. This - only applies when deleting an inode with a link count of one; if a file has - multiple names (hard links), all but the last name may be deleted even if - the file is open. - - If the path names a directory which is not empty, the unlink will fail. - - If the deletion frees data in the committed state, it will not return to - free space until after a transaction point. - - Unlike POSIX unlink, this function can fail when the disk is full. To fix - this, transact and try again: Reliance Edge guarantees that it is possible - to delete at least one file or directory after a transaction point. If disk - full automatic transactions are enabled, this will happen automatically. - - @param pszPath The path of the file or directory to delete. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EBUSY: @p pszPath points to an inode with open handles and a link - count of one. - - #RED_EINVAL: @p pszPath is `NULL`; or the volume containing the path is - not mounted. - - #RED_EIO: A disk I/O error occurred. - - #RED_ENAMETOOLONG: The length of a component of @p pszPath is longer than - #REDCONF_NAME_MAX. - - #RED_ENOENT: The path does not name an existing file; or the @p pszPath - argument, after removing the volume prefix, points to an empty string. - - #RED_ENOTDIR: A component of the path prefix is not a directory. - - #RED_ENOTEMPTY: The path names a directory which is not empty. - - #RED_ENOSPC: The file system does not have enough space to modify the - parent directory to perform the deletion. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_unlink( - const char *pszPath) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - ret = UnlinkSub(pszPath, FTYPE_EITHER); - - PosixLeave(); - } - - return PosixReturn(ret); -} -#endif - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_MKDIR == 1) -/** @brief Create a new directory. - - Unlike POSIX mkdir, this function has no second argument for the - permissions (which Reliance Edge does not use). - - @param pszPath The name and location of the directory to create. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EEXIST: @p pszPath points to an existing file or directory. - - #RED_EINVAL: @p pszPath is `NULL`; or the volume containing the path is - not mounted. - - #RED_EIO: A disk I/O error occurred. - - #RED_ENAMETOOLONG: The length of a component of @p pszPath is longer than - #REDCONF_NAME_MAX. - - #RED_ENOENT: A component of the path prefix does not name an existing - directory; or the @p pszPath argument, after removing the volume prefix, - points to an empty string. - - #RED_ENOSPC: The file system does not have enough space for the new - directory or to extend the parent directory of the new directory. - - #RED_ENOTDIR: A component of the path prefix is not a directory. - - #RED_EROFS: The parent directory resides on a read-only file system. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_mkdir( - const char *pszPath) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - const char *pszLocalPath; - uint8_t bVolNum; - - ret = RedPathSplit(pszPath, &bVolNum, &pszLocalPath); - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(bVolNum); - } - #endif - - if(ret == 0) - { - const char *pszName; - uint32_t ulPInode; - - ret = RedPathToName(pszLocalPath, &ulPInode, &pszName); - - if(ret == 0) - { - uint32_t ulInode; - - ret = RedCoreCreate(ulPInode, pszName, true, &ulInode); - } - } - - PosixLeave(); - } - - return PosixReturn(ret); -} -#endif - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_RMDIR == 1) -/** @brief Delete a directory. - - The given directory name is deleted and the corresponding directory inode - will be deleted. - - Unlike POSIX rmdir, deleting a directory with open handles (file - descriptors or directory streams) will fail with an #RED_EBUSY error. - - If the path names a directory which is not empty, the deletion will fail. - If the path names the root directory of a file system volume, the deletion - will fail. - - If the path names a regular file, the deletion will fail. This provides - type checking and may be useful in cases where an application knows the - path to be deleted should name a directory. - - If the deletion frees data in the committed state, it will not return to - free space until after a transaction point. - - Unlike POSIX rmdir, this function can fail when the disk is full. To fix - this, transact and try again: Reliance Edge guarantees that it is possible - to delete at least one file or directory after a transaction point. If disk - full automatic transactions are enabled, this will happen automatically. - - @param pszPath The path of the directory to delete. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EBUSY: @p pszPath points to a directory with open handles. - - #RED_EINVAL: @p pszPath is `NULL`; or the volume containing the path is - not mounted. - - #RED_EIO: A disk I/O error occurred. - - #RED_ENAMETOOLONG: The length of a component of @p pszPath is longer than - #REDCONF_NAME_MAX. - - #RED_ENOENT: The path does not name an existing directory; or the - @p pszPath argument, after removing the volume prefix, points to an empty - string. - - #RED_ENOTDIR: A component of the path is not a directory. - - #RED_ENOTEMPTY: The path names a directory which is not empty. - - #RED_ENOSPC: The file system does not have enough space to modify the - parent directory to perform the deletion. - - #RED_EROFS: The directory to be removed resides on a read-only file - system. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_rmdir( - const char *pszPath) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - ret = UnlinkSub(pszPath, FTYPE_DIR); - - PosixLeave(); - } - - return PosixReturn(ret); -} -#endif - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_RENAME == 1) -/** @brief Rename a file or directory. - - Both paths must reside on the same file system volume. Attempting to use - this API to move a file to a different volume will result in an error. - - If @p pszNewPath names an existing file or directory, the behavior depends - on the configuration. If #REDCONF_RENAME_ATOMIC is false, and if the - destination name exists, this function always fails and sets #red_errno to - #RED_EEXIST. This behavior is contrary to POSIX. - - If #REDCONF_RENAME_ATOMIC is true, and if the new name exists, then in one - atomic operation, @p pszNewPath is unlinked and @p pszOldPath is renamed to - @p pszNewPath. Both @p pszNewPath and @p pszOldPath must be of the same - type (both files or both directories). As with red_unlink(), if - @p pszNewPath is a directory, it must be empty. The major exception to this - behavior is that if both @p pszOldPath and @p pszNewPath are links to the - same inode, then the rename does nothing and both names continue to exist. - Unlike POSIX rename, if @p pszNewPath points to an inode with a link count - of one and open handles (file descriptors or directory streams), the - rename will fail with #RED_EBUSY. - - If the rename deletes the old destination, it may free data in the - committed state, which will not return to free space until after a - transaction point. Similarly, if the deleted inode was part of the - committed state, the inode slot will not be available until after a - transaction point. - - @param pszOldPath The path of the file or directory to rename. - @param pszNewPath The new name and location after the rename. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EBUSY: #REDCONF_RENAME_ATOMIC is true and @p pszNewPath points to an - inode with open handles and a link count of one. - - #RED_EEXIST: #REDCONF_RENAME_ATOMIC is false and @p pszNewPath exists. - - #RED_EINVAL: @p pszOldPath is `NULL`; or @p pszNewPath is `NULL`; or the - volume containing the path is not mounted. - - #RED_EIO: A disk I/O error occurred. - - #RED_EISDIR: The @p pszNewPath argument names a directory and the - @p pszOldPath argument names a non-directory. - - #RED_ENAMETOOLONG: The length of a component of either @p pszOldPath or - @p pszNewPath is longer than #REDCONF_NAME_MAX. - - #RED_ENOENT: The link named by @p pszOldPath does not name an existing - entry; or either @p pszOldPath or @p pszNewPath, after removing the volume - prefix, point to an empty string. - - #RED_ENOTDIR: A component of either path prefix is not a directory; or - @p pszOldPath names a directory and @p pszNewPath names a file. - - #RED_ENOTEMPTY: The path named by @p pszNewPath is a directory which is - not empty. - - #RED_ENOSPC: The file system does not have enough space to extend the - directory that would contain @p pszNewPath. - - #RED_EROFS: The directory to be removed resides on a read-only file - system. - - #RED_EUSERS: Cannot become a file system user: too many users. - - #RED_EXDEV: @p pszOldPath and @p pszNewPath are on different file system - volumes. -*/ -int32_t red_rename( - const char *pszOldPath, - const char *pszNewPath) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - const char *pszOldLocalPath; - uint8_t bOldVolNum; - - ret = RedPathSplit(pszOldPath, &bOldVolNum, &pszOldLocalPath); - - if(ret == 0) - { - const char *pszNewLocalPath; - uint8_t bNewVolNum; - - ret = RedPathSplit(pszNewPath, &bNewVolNum, &pszNewLocalPath); - - if((ret == 0) && (bOldVolNum != bNewVolNum)) - { - ret = -RED_EXDEV; - } - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(bOldVolNum); - } - #endif - - if(ret == 0) - { - const char *pszOldName; - uint32_t ulOldPInode; - - ret = RedPathToName(pszOldLocalPath, &ulOldPInode, &pszOldName); - - if(ret == 0) - { - const char *pszNewName; - uint32_t ulNewPInode; - - ret = RedPathToName(pszNewLocalPath, &ulNewPInode, &pszNewName); - - #if REDCONF_RENAME_ATOMIC == 1 - if(ret == 0) - { - uint32_t ulDestInode; - - ret = RedCoreLookup(ulNewPInode, pszNewName, &ulDestInode); - if(ret == 0) - { - ret = InodeUnlinkCheck(ulDestInode); - } - else if(ret == -RED_ENOENT) - { - ret = 0; - } - else - { - /* Unexpected error, nothing to do. - */ - } - } - #endif - - if(ret == 0) - { - ret = RedCoreRename(ulOldPInode, pszOldName, ulNewPInode, pszNewName); - } - } - } - } - - PosixLeave(); - } - - return PosixReturn(ret); -} -#endif - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_LINK == 1) -/** @brief Create a hard link. - - This creates an additional name (link) for the file named by @p pszPath. - The new name refers to the same file with the same contents. If a name is - deleted, but the underlying file has other names, the file continues to - exist. The link count (accessible via red_fstat()) indicates the number of - names that a file has. All of a file's names are on equal footing: there - is nothing special about the original name. - - If @p pszPath names a directory, the operation will fail. - - @param pszPath The path indicating the inode for the new link. - @param pszHardLink The name and location for the new link. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EEXIST: @p pszHardLink resolves to an existing file. - - #RED_EINVAL: @p pszPath or @p pszHardLink is `NULL`; or the volume - containing the paths is not mounted. - - #RED_EIO: A disk I/O error occurred. - - #RED_EMLINK: Creating the link would exceed the maximum link count of the - inode named by @p pszPath. - - #RED_ENAMETOOLONG: The length of a component of either @p pszPath or - @p pszHardLink is longer than #REDCONF_NAME_MAX. - - #RED_ENOENT: A component of either path prefix does not exist; or the file - named by @p pszPath does not exist; or either @p pszPath or - @p pszHardLink, after removing the volume prefix, point to an empty - string. - - #RED_ENOSPC: There is insufficient free space to expand the directory that - would contain the link. - - #RED_ENOTDIR: A component of either path prefix is not a directory. - - #RED_EPERM: The @p pszPath argument names a directory. - - #RED_EROFS: The requested link requires writing in a directory on a - read-only file system. - - #RED_EUSERS: Cannot become a file system user: too many users. - - #RED_EXDEV: @p pszPath and @p pszHardLink are on different file system - volumes. -*/ -int32_t red_link( - const char *pszPath, - const char *pszHardLink) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - const char *pszLocalPath; - uint8_t bVolNum; - - ret = RedPathSplit(pszPath, &bVolNum, &pszLocalPath); - - if(ret == 0) - { - const char *pszLinkLocalPath; - uint8_t bLinkVolNum; - - ret = RedPathSplit(pszHardLink, &bLinkVolNum, &pszLinkLocalPath); - - if((ret == 0) && (bVolNum != bLinkVolNum)) - { - ret = -RED_EXDEV; - } - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(bVolNum); - } - #endif - - if(ret == 0) - { - uint32_t ulInode; - - ret = RedPathLookup(pszLocalPath, &ulInode); - - if(ret == 0) - { - const char *pszLinkName; - uint32_t ulLinkPInode; - - ret = RedPathToName(pszLinkLocalPath, &ulLinkPInode, &pszLinkName); - - if(ret == 0) - { - ret = RedCoreLink(ulLinkPInode, pszLinkName, ulInode); - } - } - } - } - - PosixLeave(); - } - - return PosixReturn(ret); -} -#endif - - -/** @brief Close a file descriptor. - - @param iFildes The file descriptor to close. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EBADF: @p iFildes is not a valid file descriptor. - - #RED_EIO: A disk I/O error occurred. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_close( - int32_t iFildes) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - ret = FildesClose(iFildes); - - PosixLeave(); - } - - return PosixReturn(ret); -} - - -/** @brief Read from an open file. - - The read takes place at the file offset associated with @p iFildes and - advances the file offset by the number of bytes actually read. - - Data which has not yet been written, but which is before the end-of-file - (sparse data), will read as zeroes. A short read -- where the number of - bytes read is less than requested -- indicates that the requested read was - partially or, if zero bytes were read, entirely beyond the end-of-file. - - @param iFildes The file descriptor from which to read. - @param pBuffer The buffer to populate with data read. Must be at least - @p ulLength bytes in size. - @param ulLength Number of bytes to attempt to read. - - @return On success, returns a nonnegative value indicating the number of - bytes actually read. On error, -1 is returned and #red_errno is - set appropriately. - - Errno values - - #RED_EBADF: The @p iFildes argument is not a valid file descriptor open - for reading. - - #RED_EINVAL: @p pBuffer is `NULL`; or @p ulLength exceeds INT32_MAX and - cannot be returned properly. - - #RED_EIO: A disk I/O error occurred. - - #RED_EISDIR: The @p iFildes is a file descriptor for a directory. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_read( - int32_t iFildes, - void *pBuffer, - uint32_t ulLength) -{ - uint32_t ulLenRead = 0U; - REDSTATUS ret; - int32_t iReturn; - - if(ulLength > (uint32_t)INT32_MAX) - { - ret = -RED_EINVAL; - } - else - { - ret = PosixEnter(); - } - - if(ret == 0) - { - REDHANDLE *pHandle; - - ret = FildesToHandle(iFildes, FTYPE_FILE, &pHandle); - - if((ret == 0) && ((pHandle->bFlags & HFLAG_READABLE) == 0U)) - { - ret = -RED_EBADF; - } - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(pHandle->bVolNum); - } - #endif - - if(ret == 0) - { - ulLenRead = ulLength; - ret = RedCoreFileRead(pHandle->ulInode, pHandle->ullOffset, &ulLenRead, pBuffer); - } - - if(ret == 0) - { - REDASSERT(ulLenRead <= ulLength); - - pHandle->ullOffset += ulLenRead; - } - - PosixLeave(); - } - - if(ret == 0) - { - iReturn = (int32_t)ulLenRead; - } - else - { - iReturn = PosixReturn(ret); - } - - return iReturn; -} - - -#if REDCONF_READ_ONLY == 0 -/** @brief Write to an open file. - - The write takes place at the file offset associated with @p iFildes and - advances the file offset by the number of bytes actually written. - Alternatively, if @p iFildes was opened with #RED_O_APPEND, the file offset - is set to the end-of-file before the write begins, and likewise advances by - the number of bytes actually written. - - A short write -- where the number of bytes written is less than requested - -- indicates either that the file system ran out of space but was still - able to write some of the request; or that the request would have caused - the file to exceed the maximum file size, but some of the data could be - written prior to the file size limit. - - If an error is returned (-1), either none of the data was written or a - critical error occurred (like an I/O error) and the file system volume will - be read-only. - - @param iFildes The file descriptor to write to. - @param pBuffer The buffer containing the data to be written. Must be at - least @p ulLength bytes in size. - @param ulLength Number of bytes to attempt to write. - - @return On success, returns a nonnegative value indicating the number of - bytes actually written. On error, -1 is returned and #red_errno is - set appropriately. - - Errno values - - #RED_EBADF: The @p iFildes argument is not a valid file descriptor open - for writing. This includes the case where the file descriptor is for a - directory. - - #RED_EFBIG: No data can be written to the current file offset since the - resulting file size would exceed the maximum file size. - - #RED_EINVAL: @p pBuffer is `NULL`; or @p ulLength exceeds INT32_MAX and - cannot be returned properly. - - #RED_EIO: A disk I/O error occurred. - - #RED_ENOSPC: No data can be written because there is insufficient free - space. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_write( - int32_t iFildes, - const void *pBuffer, - uint32_t ulLength) -{ - uint32_t ulLenWrote = 0U; - REDSTATUS ret; - int32_t iReturn; - - if(ulLength > (uint32_t)INT32_MAX) - { - ret = -RED_EINVAL; - } - else - { - ret = PosixEnter(); - } - - if(ret == 0) - { - REDHANDLE *pHandle; - - ret = FildesToHandle(iFildes, FTYPE_FILE, &pHandle); - if(ret == -RED_EISDIR) - { - /* POSIX says that if a file descriptor is not writable, the - errno should be -RED_EBADF. Directory file descriptors are - never writable, and unlike for read(), the spec does not - list -RED_EISDIR as an allowed errno. Therefore -RED_EBADF - takes precedence. - */ - ret = -RED_EBADF; - } - - if((ret == 0) && ((pHandle->bFlags & HFLAG_WRITEABLE) == 0U)) - { - ret = -RED_EBADF; - } - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(pHandle->bVolNum); - } - #endif - - if((ret == 0) && ((pHandle->bFlags & HFLAG_APPENDING) != 0U)) - { - REDSTAT s; - - ret = RedCoreStat(pHandle->ulInode, &s); - if(ret == 0) - { - pHandle->ullOffset = s.st_size; - } - } - - if(ret == 0) - { - ulLenWrote = ulLength; - ret = RedCoreFileWrite(pHandle->ulInode, pHandle->ullOffset, &ulLenWrote, pBuffer); - } - - if(ret == 0) - { - REDASSERT(ulLenWrote <= ulLength); - - pHandle->ullOffset += ulLenWrote; - } - - PosixLeave(); - } - - if(ret == 0) - { - iReturn = (int32_t)ulLenWrote; - } - else - { - iReturn = PosixReturn(ret); - } - - return iReturn; -} -#endif - - -#if REDCONF_READ_ONLY == 0 -/** @brief Synchronizes changes to a file. - - Commits all changes associated with a file or directory (including file - data, directory contents, and metadata) to permanent storage. This - function will not return until the operation is complete. - - In the current implementation, this function has global effect. All dirty - buffers are flushed and a transaction point is committed. Fsyncing one - file effectively fsyncs all files. - - If fsync automatic transactions have been disabled, this function does - nothing and returns success. In the current implementation, this is the - only real difference between this function and red_transact(): this - function can be configured to do nothing, whereas red_transact() is - unconditional. - - Applications written for portability should avoid assuming red_fsync() - effects all files, and use red_fsync() on each file that needs to be - synchronized. - - Passing read-only file descriptors to this function is permitted. - - @param iFildes The file descriptor to synchronize. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EBADF: The @p iFildes argument is not a valid file descriptor. - - #RED_EIO: A disk I/O error occurred. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_fsync( - int32_t iFildes) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - REDHANDLE *pHandle; - - ret = FildesToHandle(iFildes, FTYPE_EITHER, &pHandle); - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(pHandle->bVolNum); - } - #endif - - /* No core event for fsync, so this transaction flag needs to be - implemented here. - */ - if(ret == 0) - { - uint32_t ulTransMask; - - ret = RedCoreTransMaskGet(&ulTransMask); - - if((ret == 0) && ((ulTransMask & RED_TRANSACT_FSYNC) != 0U)) - { - ret = RedCoreVolTransact(); - } - } - - PosixLeave(); - } - - return PosixReturn(ret); -} -#endif - - -/** @brief Move the read/write file offset. - - The file offset of the @p iFildes file descriptor is set to @p llOffset, - relative to some starting position. The available positions are: - - - ::RED_SEEK_SET Seek from the start of the file. In other words, - @p llOffset becomes the new file offset. - - ::RED_SEEK_CUR Seek from the current file offset. In other words, - @p llOffset is added to the current file offset. - - ::RED_SEEK_END Seek from the end-of-file. In other words, the new file - offset is the file size plus @p llOffset. - - Since @p llOffset is signed (can be negative), it is possible to seek - backward with ::RED_SEEK_CUR or ::RED_SEEK_END. - - It is permitted to seek beyond the end-of-file; this does not increase the - file size (a subsequent red_write() call would). - - Unlike POSIX lseek, this function cannot be used with directory file - descriptors. - - @param iFildes The file descriptor whose offset is to be updated. - @param llOffset The new file offset, relative to @p whence. - @param whence The location from which @p llOffset should be applied. - - @return On success, returns the new file position, measured in bytes from - the beginning of the file. On error, -1 is returned and #red_errno - is set appropriately. - - Errno values - - #RED_EBADF: The @p iFildes argument is not an open file descriptor. - - #RED_EINVAL: @p whence is not a valid `RED_SEEK_` value; or the resulting - file offset would be negative or beyond the maximum file size. - - #RED_EIO: A disk I/O error occurred. - - #RED_EISDIR: The @p iFildes argument is a file descriptor for a directory. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int64_t red_lseek( - int32_t iFildes, - int64_t llOffset, - REDWHENCE whence) -{ - REDSTATUS ret; - int64_t llReturn = -1; /* Init'd to quiet warnings. */ - - ret = PosixEnter(); - if(ret == 0) - { - int64_t llFrom = 0; /* Init'd to quiet warnings. */ - REDHANDLE *pHandle; - - /* Unlike POSIX, we disallow lseek() on directory handles. - */ - ret = FildesToHandle(iFildes, FTYPE_FILE, &pHandle); - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(pHandle->bVolNum); - } - #endif - - if(ret == 0) - { - switch(whence) - { - /* Seek from the beginning of the file. - */ - case RED_SEEK_SET: - llFrom = 0; - break; - - /* Seek from the current file offset. - */ - case RED_SEEK_CUR: - REDASSERT(pHandle->ullOffset <= (uint64_t)INT64_MAX); - llFrom = (int64_t)pHandle->ullOffset; - break; - - /* Seek from the end of the file. - */ - case RED_SEEK_END: - { - REDSTAT s; - - ret = RedCoreStat(pHandle->ulInode, &s); - if(ret == 0) - { - REDASSERT(s.st_size <= (uint64_t)INT64_MAX); - llFrom = (int64_t)s.st_size; - } - - break; - } - - default: - ret = -RED_EINVAL; - break; - } - } - - if(ret == 0) - { - REDASSERT(llFrom >= 0); - - /* Avoid signed integer overflow from llFrom + llOffset with large - values of llOffset and nonzero llFrom values. Underflow isn't - possible since llFrom is nonnegative. - */ - if((llOffset > 0) && (((uint64_t)llFrom + (uint64_t)llOffset) > (uint64_t)INT64_MAX)) - { - ret = -RED_EINVAL; - } - else - { - int64_t llNewOffset = llFrom + llOffset; - - if((llNewOffset < 0) || ((uint64_t)llNewOffset > gpRedVolume->ullMaxInodeSize)) - { - /* Invalid file offset. - */ - ret = -RED_EINVAL; - } - else - { - pHandle->ullOffset = (uint64_t)llNewOffset; - llReturn = llNewOffset; - } - } - } - - PosixLeave(); - } - - if(ret != 0) - { - llReturn = PosixReturn(ret); - } - - return llReturn; -} - - -#if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_FTRUNCATE == 1) -/** @brief Truncate a file to a specified length. - - Allows the file size to be increased, decreased, or to remain the same. If - the file size is increased, the new area is sparse (will read as zeroes). - If the file size is decreased, the data beyond the new end-of-file will - return to free space once it is no longer part of the committed state - (either immediately or after the next transaction point). - - The value of the file offset is not modified by this function. - - Unlike POSIX ftruncate, this function can fail when the disk is full if - @p ullSize is non-zero. If decreasing the file size, this can be fixed by - transacting and trying again: Reliance Edge guarantees that it is possible - to perform a truncate of at least one file that decreases the file size - after a transaction point. If disk full transactions are enabled, this will - happen automatically. - - @param iFildes The file descriptor of the file to truncate. - @param ullSize The new size of the file. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EBADF: The @p iFildes argument is not a valid file descriptor open - for writing. This includes the case where the file descriptor is for a - directory. - - #RED_EFBIG: @p ullSize exceeds the maximum file size. - - #RED_EIO: A disk I/O error occurred. - - #RED_ENOSPC: Insufficient free space to perform the truncate. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_ftruncate( - int32_t iFildes, - uint64_t ullSize) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - REDHANDLE *pHandle; - - ret = FildesToHandle(iFildes, FTYPE_FILE, &pHandle); - if(ret == -RED_EISDIR) - { - /* Similar to red_write() (see comment there), the RED_EBADF error - for a non-writable file descriptor takes precedence. - */ - ret = -RED_EBADF; - } - - if((ret == 0) && ((pHandle->bFlags & HFLAG_WRITEABLE) == 0U)) - { - ret = -RED_EBADF; - } - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(pHandle->bVolNum); - } - #endif - - if(ret == 0) - { - ret = RedCoreFileTruncate(pHandle->ulInode, ullSize); - } - - PosixLeave(); - } - - return PosixReturn(ret); -} -#endif - - -/** @brief Get the status of a file or directory. - - See the ::REDSTAT type for the details of the information returned. - - @param iFildes An open file descriptor for the file whose information is - to be retrieved. - @param pStat Pointer to a ::REDSTAT buffer to populate. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EBADF: The @p iFildes argument is not a valid file descriptor. - - #RED_EINVAL: @p pStat is `NULL`. - - #RED_EIO: A disk I/O error occurred. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_fstat( - int32_t iFildes, - REDSTAT *pStat) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - REDHANDLE *pHandle; - - ret = FildesToHandle(iFildes, FTYPE_EITHER, &pHandle); - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(pHandle->bVolNum); - } - #endif - - if(ret == 0) - { - ret = RedCoreStat(pHandle->ulInode, pStat); - } - - PosixLeave(); - } - - return PosixReturn(ret); -} - - -#if REDCONF_API_POSIX_READDIR == 1 -/** @brief Open a directory stream for reading. - - @param pszPath The path of the directory to open. - - @return On success, returns a pointer to a ::REDDIR object that can be used - with red_readdir() and red_closedir(). On error, returns `NULL` - and #red_errno is set appropriately. - - Errno values - - #RED_EINVAL: @p pszPath is `NULL`; or the volume containing the path is - not mounted. - - #RED_EIO: A disk I/O error occurred. - - #RED_ENOENT: A component of @p pszPath does not exist; or the @p pszPath - argument, after removing the volume prefix, points to an empty string. - - #RED_ENOTDIR: A component of @p pszPath is a not a directory. - - #RED_EMFILE: There are no available file descriptors. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -REDDIR *red_opendir( - const char *pszPath) -{ - int32_t iFildes; - REDSTATUS ret; - REDDIR *pDir = NULL; - - ret = PosixEnter(); - if(ret == 0) - { - ret = FildesOpen(pszPath, RED_O_RDONLY, FTYPE_DIR, &iFildes); - if(ret == 0) - { - uint16_t uHandleIdx; - - FildesUnpack(iFildes, &uHandleIdx, NULL, NULL); - pDir = &gaHandle[uHandleIdx]; - } - - PosixLeave(); - } - - REDASSERT((pDir == NULL) == (ret != 0)); - - if(pDir == NULL) - { - red_errno = -ret; - } - - return pDir; -} - - -/** @brief Read from a directory stream. - - The ::REDDIRENT pointer returned by this function will be overwritten by - subsequent calls on the same @p pDir. Calls with other ::REDDIR objects - will *not* modify the returned ::REDDIRENT. - - If files are added to the directory after it is opened, the new files may - or may not be returned by this function. If files are deleted, the deleted - files will not be returned. - - This function (like its POSIX equivalent) returns `NULL` in two cases: on - error and when the end of the directory is reached. To distinguish between - these two cases, the application should set #red_errno to zero before - calling this function, and if `NULL` is returned, check if #red_errno is - still zero. If it is, the end of the directory was reached; otherwise, - there was an error. - - @param pDirStream The directory stream to read from. - - @return On success, returns a pointer to a ::REDDIRENT object which is - populated with directory entry information read from the directory. - On error, returns `NULL` and #red_errno is set appropriately. If at - the end of the directory, returns `NULL` but #red_errno is not - modified. - - Errno values - - #RED_EBADF: @p pDirStream is not an open directory stream. - - #RED_EIO: A disk I/O error occurred. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -REDDIRENT *red_readdir( - REDDIR *pDirStream) -{ - REDSTATUS ret; - REDDIRENT *pDirEnt = NULL; - - ret = PosixEnter(); - if(ret == 0) - { - if(!DirStreamIsValid(pDirStream)) - { - ret = -RED_EBADF; - } - #if REDCONF_VOLUME_COUNT > 1U - else - { - ret = RedCoreVolSetCurrent(pDirStream->bVolNum); - } - #endif - - if(ret == 0) - { - uint32_t ulDirPosition; - - /* To save memory, the directory position is stored in the same - location as the file offset. This would be a bit cleaner using - a union, but MISRA-C:2012 Rule 19.2 disallows unions. - */ - REDASSERT(pDirStream->ullOffset <= UINT32_MAX); - ulDirPosition = (uint32_t)pDirStream->ullOffset; - - ret = RedCoreDirRead(pDirStream->ulInode, &ulDirPosition, pDirStream->dirent.d_name, &pDirStream->dirent.d_ino); - - pDirStream->ullOffset = ulDirPosition; - - if(ret == 0) - { - /* POSIX extension: return stat information with the dirent. - */ - ret = RedCoreStat(pDirStream->dirent.d_ino, &pDirStream->dirent.d_stat); - if(ret == 0) - { - pDirEnt = &pDirStream->dirent; - } - } - else if(ret == -RED_ENOENT) - { - /* Reached the end of the directory; return NULL but do not set - errno. - */ - ret = 0; - } - else - { - /* Miscellaneous error; return NULL and set errno (done below). - */ - } - } - - PosixLeave(); - } - - if(ret != 0) - { - REDASSERT(pDirEnt == NULL); - - red_errno = -ret; - } - - return pDirEnt; -} - - -/** @brief Rewind a directory stream to read it from the beginning. - - Similar to closing the directory object and opening it again, but without - the need for the path. - - Since this function (like its POSIX equivalent) cannot return an error, - it takes no action in error conditions, such as when @p pDirStream is - invalid. - - @param pDirStream The directory stream to rewind. -*/ -void red_rewinddir( - REDDIR *pDirStream) -{ - if(PosixEnter() == 0) - { - if(DirStreamIsValid(pDirStream)) - { - pDirStream->ullOffset = 0U; - } - - PosixLeave(); - } -} - - -/** @brief Close a directory stream. - - After calling this function, @p pDirStream should no longer be used. - - @param pDirStream The directory stream to close. - - @return On success, zero is returned. On error, -1 is returned and - #red_errno is set appropriately. - - Errno values - - #RED_EBADF: @p pDirStream is not an open directory stream. - - #RED_EUSERS: Cannot become a file system user: too many users. -*/ -int32_t red_closedir( - REDDIR *pDirStream) -{ - REDSTATUS ret; - - ret = PosixEnter(); - if(ret == 0) - { - if(DirStreamIsValid(pDirStream)) - { - /* Mark this handle as unused. - */ - pDirStream->ulInode = INODE_INVALID; - } - else - { - ret = -RED_EBADF; - } - - PosixLeave(); - } - - return PosixReturn(ret); -} -#endif /* REDCONF_API_POSIX_READDIR */ - - -/** @brief Pointer to where the last file system error (errno) is stored. - - This function is intended to be used via the #red_errno macro, or a similar - user-defined macro, that can be used both as an lvalue (writable) and an - rvalue (readable). - - Under normal circumstances, the errno for each task is stored in a - different location. Applications do not need to worry about one task - obliterating an error value that another task needed to read. This task - errno for is initially zero. When one of the POSIX-like APIs returns an - indication of error, the location for the calling task will be populated - with the error value. - - In some circumstances, this function will return a pointer to a global - errno location which is shared by multiple tasks. If the calling task is - not registered as a file system user and all of the task slots are full, - there can be no task-specific errno, so the global pointer is returned. - Likewise, if the file system driver is uninitialized, there are no - registered file system users and this function always returns the pointer - to the global errno. Under these circumstances, multiple tasks - manipulating errno could be problematic. - - This function never returns `NULL` under any circumstances. The #red_errno - macro unconditionally dereferences the return value from this function, so - returning `NULL` could result in a fault. - - @return Pointer to where the errno value is stored for this task. -*/ -REDSTATUS *red_errnoptr(void) -{ - /* The global errno value, used in single-task configurations and when the - caller is not (and cannot become) a file system user (which includes - when the driver is uninitialized). - */ - static REDSTATUS iGlobalErrno = 0; - - #if REDCONF_TASK_COUNT == 1U - - return &iGlobalErrno; - - #else - - REDSTATUS *piErrno; - - if(gfPosixInited) - { - uint32_t ulTaskId = RedOsTaskId(); - uint32_t ulIdx; - - REDASSERT(ulTaskId != 0U); - - /* If this task has used the file system before, it will already have - a task slot, which includes the task-specific errno. - */ - RedOsMutexAcquire(); - - for(ulIdx = 0U; ulIdx < REDCONF_TASK_COUNT; ulIdx++) - { - if(gaTask[ulIdx].ulTaskId == ulTaskId) - { - break; - } - } - - RedOsMutexRelease(); - - if(ulIdx == REDCONF_TASK_COUNT) - { - REDSTATUS ret; - - /* This task is not a file system user, so try to register it as - one. This FS mutex must be held in order to register. - */ - RedOsMutexAcquire(); - - ret = TaskRegister(&ulIdx); - - RedOsMutexRelease(); - - if(ret == 0) - { - REDASSERT(gaTask[ulIdx].ulTaskId == RedOsTaskId()); - REDASSERT(gaTask[ulIdx].iErrno == 0); - - piErrno = &gaTask[ulIdx].iErrno; - } - else - { - /* Unable to register; use the global errno. - */ - piErrno = &iGlobalErrno; - } - } - else - { - piErrno = &gaTask[ulIdx].iErrno; - } - } - else - { - /* There are no registered file system tasks when the driver is - uninitialized, so use the global errno. - */ - piErrno = &iGlobalErrno; - } - - /* This function is not allowed to return NULL. - */ - REDASSERT(piErrno != NULL); - return piErrno; - - #endif -} -/** @} */ - -/*------------------------------------------------------------------- - Helper Functions --------------------------------------------------------------------*/ - -#if (REDCONF_READ_ONLY == 0) && ((REDCONF_API_POSIX_UNLINK == 1) || (REDCONF_API_POSIX_RMDIR == 1)) - -/** @brief Remove a link to a file or directory. - - If the link count becomes zero, the file or directory is deleted. - - @param pszPath Path of the link to remove. - @param type The expected type of the path: file, directory, or either. - An error is returned if the expected type is file or - directory and does not match the path. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval -RED_EBUSY @p pszPath points to an inode with open handles - and a link count of one. - @retval -RED_EINVAL @p pszPath is `NULL`; or the volume containing - the path is not mounted. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_EISDIR @p type is ::FTYPE_FILE and the path names a - directory. - @retval -RED_ENAMETOOLONG @p pszName is too long. - @retval -RED_ENOENT The path does not name an existing file; or - @p pszPath, after removing the volume prefix, - points to an empty string. - @retval -RED_ENOTDIR @p type is ::FTYPE_DIR and the path does not - name a directory. - @retval -RED_ENOTEMPTY @p pszPath is a directory which is not empty. - @retval -RED_ENOSPC The file system does not have enough space to - modify the parent directory to perform the - deletion. -*/ -static REDSTATUS UnlinkSub( - const char *pszPath, - FTYPE type) -{ - uint8_t bVolNum; - const char *pszLocalPath; - REDSTATUS ret; - - ret = RedPathSplit(pszPath, &bVolNum, &pszLocalPath); - - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(bVolNum); - } - #endif - - if(ret == 0) - { - const char *pszName; - uint32_t ulPInode; - - ret = RedPathToName(pszLocalPath, &ulPInode, &pszName); - - if(ret == 0) - { - uint32_t ulInode; - - ret = RedCoreLookup(ulPInode, pszName, &ulInode); - - /* ModeTypeCheck() always passes when the type is FTYPE_EITHER, so - skip stat'ing the inode in that case. - */ - if((ret == 0) && (type != FTYPE_EITHER)) - { - REDSTAT InodeStat; - - ret = RedCoreStat(ulInode, &InodeStat); - if(ret == 0) - { - ret = ModeTypeCheck(InodeStat.st_mode, type); - } - } - - if(ret == 0) - { - ret = InodeUnlinkCheck(ulInode); - } - - if(ret == 0) - { - ret = RedCoreUnlink(ulPInode, pszName); - } - } - } - - return ret; -} -#endif /* (REDCONF_API_POSIX_UNLINK == 1) || (REDCONF_API_POSIX_RMDIR == 1) */ - - -/** @brief Get a file descriptor for a path. - - @param pszPath Path to a file to open. - @param ulOpenMode The RED_O_* flags the descriptor is opened with. - @param type Indicates the expected descriptor type: file, directory, - or either. - @param piFildes On successful return, populated with the file - descriptor. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL @p piFildes is `NULL`; or @p pszPath is `NULL`; - or the volume is not mounted. - @retval -RED_EMFILE There are no available handles. - @retval -RED_EEXIST Using #RED_O_CREAT and #RED_O_EXCL, and the - indicated path already exists. - @retval -RED_EISDIR The path names a directory and @p ulOpenMode - includes #RED_O_WRONLY or #RED_O_RDWR. - @retval -RED_ENOENT #RED_O_CREAT is not set and the named file does - not exist; or #RED_O_CREAT is set and the parent - directory does not exist; or the volume does not - exist; or the @p pszPath argument, after - removing the volume prefix, points to an empty - string. - @retval -RED_EIO A disk I/O error occurred. - @retval -RED_ENAMETOOLONG The length of a component of @p pszPath is - longer than #REDCONF_NAME_MAX. - @retval -RED_ENFILE Attempting to create a file but the file system - has used all available inode slots. - @retval -RED_ENOSPC The file does not exist and #RED_O_CREAT was - specified, but there is insufficient free space - to expand the directory or to create the new - file. - @retval -RED_ENOTDIR A component of the prefix in @p pszPath does not - name a directory. - @retval -RED_EROFS The path resides on a read-only file system and - a write operation was requested. -*/ -static REDSTATUS FildesOpen( - const char *pszPath, - uint32_t ulOpenMode, - FTYPE type, - int32_t *piFildes) -{ - uint8_t bVolNum; - const char *pszLocalPath; - REDSTATUS ret; - - ret = RedPathSplit(pszPath, &bVolNum, &pszLocalPath); - - if(ret == 0) - { - if(piFildes == NULL) - { - ret = -RED_EINVAL; - } - #if REDCONF_READ_ONLY == 0 - else if(gaRedVolume[bVolNum].fReadOnly && (ulOpenMode != RED_O_RDONLY)) - { - ret = -RED_EROFS; - } - #endif - else - { - uint16_t uHandleIdx; - REDHANDLE *pHandle = NULL; - - /* Search for an unused handle. - */ - for(uHandleIdx = 0U; uHandleIdx < REDCONF_HANDLE_COUNT; uHandleIdx++) - { - if(gaHandle[uHandleIdx].ulInode == INODE_INVALID) - { - pHandle = &gaHandle[uHandleIdx]; - break; - } - } - - /* Error if all the handles are in use. - */ - if(pHandle == NULL) - { - ret = -RED_EMFILE; - } - else - { - bool fCreated = false; - uint16_t uMode = 0U; - uint32_t ulInode = 0U; /* Init'd to quiet warnings. */ - - #if REDCONF_VOLUME_COUNT > 1U - ret = RedCoreVolSetCurrent(bVolNum); - if(ret == 0) - #endif - { - #if REDCONF_READ_ONLY == 0 - if((ulOpenMode & RED_O_CREAT) != 0U) - { - uint32_t ulPInode; - const char *pszName; - - ret = RedPathToName(pszLocalPath, &ulPInode, &pszName); - if(ret == 0) - { - ret = RedCoreCreate(ulPInode, pszName, false, &ulInode); - if(ret == 0) - { - fCreated = true; - } - else if((ret == -RED_EEXIST) && ((ulOpenMode & RED_O_EXCL) == 0U)) - { - /* If the path already exists and that's OK, - lookup its inode number. - */ - ret = RedCoreLookup(ulPInode, pszName, &ulInode); - } - else - { - /* No action, just propagate the error. - */ - } - } - } - else - #endif - { - ret = RedPathLookup(pszLocalPath, &ulInode); - } - } - - /* If we created the inode, none of the below stuff is - necessary. This is important from an error handling - perspective -- we do not need code to delete the created - inode on error. - */ - if(!fCreated) - { - if(ret == 0) - { - REDSTAT s; - - ret = RedCoreStat(ulInode, &s); - if(ret == 0) - { - uMode = s.st_mode; - } - } - - /* Error if the inode is not of the expected type. - */ - if(ret == 0) - { - ret = ModeTypeCheck(uMode, type); - } - - /* Directories must always be opened with O_RDONLY. - */ - if((ret == 0) && RED_S_ISDIR(uMode) && ((ulOpenMode & RED_O_RDONLY) == 0U)) - { - ret = -RED_EISDIR; - } - - #if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_FTRUNCATE == 1) - if((ret == 0) && ((ulOpenMode & RED_O_TRUNC) != 0U)) - { - ret = RedCoreFileTruncate(ulInode, UINT64_SUFFIX(0)); - } - #endif - } - - if(ret == 0) - { - int32_t iFildes; - - RedMemSet(pHandle, 0U, sizeof(*pHandle)); - - /* Populate this handle, marking it as in use. - */ - pHandle->ulInode = ulInode; - pHandle->bVolNum = bVolNum; - - if(RED_S_ISDIR(uMode)) - { - pHandle->bFlags |= HFLAG_DIRECTORY; - } - - if(((ulOpenMode & RED_O_RDONLY) != 0U) || ((ulOpenMode & RED_O_RDWR) != 0U)) - { - pHandle->bFlags |= HFLAG_READABLE; - } - - #if REDCONF_READ_ONLY == 0 - if(((ulOpenMode & RED_O_WRONLY) != 0U) || ((ulOpenMode & RED_O_RDWR) != 0U)) - { - pHandle->bFlags |= HFLAG_WRITEABLE; - } - - if((ulOpenMode & RED_O_APPEND) != 0U) - { - pHandle->bFlags |= HFLAG_APPENDING; - } - #endif - - iFildes = FildesPack(uHandleIdx, bVolNum); - if(iFildes == -1) - { - /* It should be impossible to get here, unless there - is memory corruption. - */ - REDERROR(); - ret = -RED_EFUBAR; - } - else - { - *piFildes = iFildes; - } - } - } - } - } - - return ret; -} - - -/** @brief Close a file descriptor. - - @param iFildes The file descriptor to close. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p iFildes is not a valid file descriptor. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS FildesClose( - int32_t iFildes) -{ - REDHANDLE *pHandle; - REDSTATUS ret; - - ret = FildesToHandle(iFildes, FTYPE_EITHER, &pHandle); - - #if REDCONF_READ_ONLY == 0 - #if REDCONF_VOLUME_COUNT > 1U - if(ret == 0) - { - ret = RedCoreVolSetCurrent(pHandle->bVolNum); - } - #endif - - /* No core event for close, so this transaction flag needs to be - implemented here. - */ - if(ret == 0) - { - uint32_t ulTransMask; - - ret = RedCoreTransMaskGet(&ulTransMask); - - if((ret == 0) && ((ulTransMask & RED_TRANSACT_CLOSE) != 0U)) - { - ret = RedCoreVolTransact(); - } - } - #endif - - if(ret == 0) - { - /* Mark this handle as unused. - */ - pHandle->ulInode = INODE_INVALID; - } - - return ret; -} - - -/** @brief Convert a file descriptor into a handle pointer. - - Also validates the file descriptor. - - @param iFildes The file descriptor for which to get a handle. - @param expectedType The expected type of the file descriptor: ::FTYPE_DIR, - ::FTYPE_FILE, or ::FTYPE_EITHER. - @param ppHandle On successful return, populated with a pointer to the - handle associated with @p iFildes. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p iFildes is not a valid file descriptor. - @retval -RED_EINVAL @p ppHandle is `NULL`. - @retval -RED_EISDIR Expected a file, but the file descriptor is for a - directory. - @retval -RED_ENOTDIR Expected a directory, but the file descriptor is for - a file. -*/ -static REDSTATUS FildesToHandle( - int32_t iFildes, - FTYPE expectedType, - REDHANDLE **ppHandle) -{ - REDSTATUS ret; - - if(ppHandle == NULL) - { - REDERROR(); - ret = -RED_EINVAL; - } - else if(iFildes < FD_MIN) - { - ret = -RED_EBADF; - } - else - { - uint16_t uHandleIdx; - uint8_t bVolNum; - uint16_t uGeneration; - - FildesUnpack(iFildes, &uHandleIdx, &bVolNum, &uGeneration); - - if( (uHandleIdx >= REDCONF_HANDLE_COUNT) - || (bVolNum >= REDCONF_VOLUME_COUNT) - || (gaHandle[uHandleIdx].ulInode == INODE_INVALID) - || (gaHandle[uHandleIdx].bVolNum != bVolNum) - || (gauGeneration[bVolNum] != uGeneration)) - { - ret = -RED_EBADF; - } - else if((expectedType == FTYPE_FILE) && ((gaHandle[uHandleIdx].bFlags & HFLAG_DIRECTORY) != 0U)) - { - ret = -RED_EISDIR; - } - else if((expectedType == FTYPE_DIR) && ((gaHandle[uHandleIdx].bFlags & HFLAG_DIRECTORY) == 0U)) - { - ret = -RED_ENOTDIR; - } - else - { - *ppHandle = &gaHandle[uHandleIdx]; - ret = 0; - } - } - - return ret; -} - - -/** @brief Pack a file descriptor. - - @param uHandleIdx The index of the file handle that will be associated - with this file descriptor. - @param bVolNum The volume which contains the file or directory this - file descriptor was opened against. - - @return The packed file descriptor. -*/ -static int32_t FildesPack( - uint16_t uHandleIdx, - uint8_t bVolNum) -{ - int32_t iFildes; - - if((uHandleIdx >= REDCONF_HANDLE_COUNT) || (bVolNum >= REDCONF_VOLUME_COUNT)) - { - REDERROR(); - iFildes = -1; - } - else - { - uint32_t ulFdBits; - - REDASSERT(gauGeneration[bVolNum] <= FD_GEN_MAX); - REDASSERT(gauGeneration[bVolNum] != 0U); - - ulFdBits = gauGeneration[bVolNum]; - ulFdBits <<= FD_VOL_BITS; - ulFdBits |= bVolNum; - ulFdBits <<= FD_IDX_BITS; - ulFdBits |= uHandleIdx; - - iFildes = (int32_t)ulFdBits; - - if(iFildes < FD_MIN) - { - REDERROR(); - iFildes = -1; - } - } - - return iFildes; -} - - -/** @brief Unpack a file descriptor. - - @param iFildes The file descriptor to unpack. - @param puHandleIdx If non-NULL, populated with the handle index extracted - from the file descriptor. - @param pbVolNum If non-NULL, populated with the volume number extracted - from the file descriptor. - @param puGeneration If non-NULL, populated with the generation number - extracted from the file descriptor. -*/ -static void FildesUnpack( - int32_t iFildes, - uint16_t *puHandleIdx, - uint8_t *pbVolNum, - uint16_t *puGeneration) -{ - uint32_t ulFdBits = (uint32_t)iFildes; - - REDASSERT(iFildes >= FD_MIN); - - if(puHandleIdx != NULL) - { - *puHandleIdx = (uint16_t)(ulFdBits & FD_IDX_MAX); - } - - ulFdBits >>= FD_IDX_BITS; - - if(pbVolNum != NULL) - { - *pbVolNum = (uint8_t)(ulFdBits & FD_VOL_MAX); - } - - ulFdBits >>= FD_VOL_BITS; - - if(puGeneration != NULL) - { - *puGeneration = (uint16_t)(ulFdBits & FD_GEN_MAX); - } -} - - -#if REDCONF_API_POSIX_READDIR == 1 -/** @brief Validate a directory stream object. - - @param pDirStream The directory stream to validate. - - @return Whether the directory stream is valid. - - @retval true The directory stream object appears valid. - @retval false The directory stream object is invalid. -*/ -static bool DirStreamIsValid( - const REDDIR *pDirStream) -{ - bool fRet = true; - - if(pDirStream == NULL) - { - fRet = false; - } - else - { - uint16_t uHandleIdx; - - /* pDirStream should be a pointer to one of the handles. - - A good compiler will optimize this loop into a bounds check and an - alignment check. - */ - for(uHandleIdx = 0U; uHandleIdx < REDCONF_HANDLE_COUNT; uHandleIdx++) - { - if(pDirStream == &gaHandle[uHandleIdx]) - { - break; - } - } - - if(uHandleIdx < REDCONF_HANDLE_COUNT) - { - /* The handle must be in use, have a valid volume number, and be a - directory handle. - */ - if( (pDirStream->ulInode == INODE_INVALID) - || (pDirStream->bVolNum >= REDCONF_VOLUME_COUNT) - || ((pDirStream->bFlags & HFLAG_DIRECTORY) == 0U)) - { - fRet = false; - } - } - else - { - /* pDirStream is a non-null pointer, but it is not a pointer to one - of our handles. - */ - fRet = false; - } - } - - return fRet; -} -#endif - - -/** @brief Enter the file system driver. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EINVAL The file system driver is uninitialized. - @retval -RED_EUSERS Cannot become a file system user: too many users. -*/ -static REDSTATUS PosixEnter(void) -{ - REDSTATUS ret; - - if(gfPosixInited) - { - #if REDCONF_TASK_COUNT > 1U - RedOsMutexAcquire(); - - ret = TaskRegister(NULL); - if(ret != 0) - { - RedOsMutexRelease(); - } - #else - ret = 0; - #endif - } - else - { - ret = -RED_EINVAL; - } - - return ret; -} - - -/** @brief Leave the file system driver. -*/ -static void PosixLeave(void) -{ - /* If the driver was uninitialized, PosixEnter() should have failed and we - should not be calling PosixLeave(). - */ - REDASSERT(gfPosixInited); - - #if REDCONF_TASK_COUNT > 1U - RedOsMutexRelease(); - #endif -} - - -/** @brief Check that a mode is consistent with the given expected type. - - @param uMode An inode mode, indicating whether the inode is a file - or a directory. - @param expectedType The expected type: ::FTYPE_FILE, ::FTYPE_DIR, or - ::FTYPE_EITHER. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EISDIR Expected type is file, actual type is directory. - @retval -RED_ENOTDIR Expected type is directory, actual type is file. -*/ -static REDSTATUS ModeTypeCheck( - uint16_t uMode, - FTYPE expectedType) -{ - REDSTATUS ret; - - if((expectedType == FTYPE_FILE) && RED_S_ISDIR(uMode)) - { - /* Expected file, found directory. - */ - ret = -RED_EISDIR; - } - else if((expectedType == FTYPE_DIR) && RED_S_ISREG(uMode)) - { - /* Expected directory, found file. - */ - ret = -RED_ENOTDIR; - } - else - { - /* No expected type or found what we expected. - */ - ret = 0; - } - - return ret; -} - - -#if (REDCONF_READ_ONLY == 0) && ((REDCONF_API_POSIX_UNLINK == 1) || (REDCONF_API_POSIX_RMDIR == 1) || ((REDCONF_API_POSIX_RENAME == 1) && (REDCONF_RENAME_ATOMIC == 1))) -/** @brief Check whether an inode can be unlinked. - - If an inode has a link count of 1 (meaning unlinking another name would - result in the deletion of the inode) and open handles, it cannot be deleted - since this would break open handles. - - @param ulInode The inode whose name is to be unlinked. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EBADF @p ulInode is not a valid inode. - @retval -RED_EBUSY The inode has a link count of one and open handles. - @retval -RED_EIO A disk I/O error occurred. -*/ -static REDSTATUS InodeUnlinkCheck( - uint32_t ulInode) -{ - uint16_t uHandleIdx; - REDSTATUS ret; - - #if REDCONF_API_POSIX_LINK == 0 - ret = 0; - #else - REDSTAT InodeStat; - - ret = RedCoreStat(ulInode, &InodeStat); - - /* We only need to check for open handles if the inode is down to its last - link. If it has multiple links, the inode will continue to exist, so - deleting the name will not break the open handles. - */ - if((ret == 0) && (InodeStat.st_nlink == 1U)) - #endif - { - for(uHandleIdx = 0U; uHandleIdx < REDCONF_HANDLE_COUNT; uHandleIdx++) - { - if((gaHandle[uHandleIdx].ulInode == ulInode) && (gaHandle[uHandleIdx].bVolNum == gbRedVolNum)) - { - ret = -RED_EBUSY; - break; - } - } - } - - return ret; -} -#endif - - -#if REDCONF_TASK_COUNT > 1U -/** @brief Register a task as a file system user, if it is not already - registered as one. - - The caller must hold the FS mutex. - - @param pulTaskIdx On successful return, if non-NULL, populated with the - index of the task slot assigned to the calling task. - This is populated whether or not the task had already - been registered. - - @return A negated ::REDSTATUS code indicating the operation result. - - @retval 0 Operation was successful. - @retval -RED_EUSERS Cannot become a file system user: too many users. -*/ -static REDSTATUS TaskRegister( - uint32_t *pulTaskIdx) -{ - uint32_t ulTaskId = RedOsTaskId(); - uint32_t ulFirstFreeIdx = REDCONF_TASK_COUNT; - uint32_t ulIdx; - REDSTATUS ret; - - REDASSERT(ulTaskId != 0U); - - /* Scan the task slots to determine if the task is registered as a file - system task. - */ - for(ulIdx = 0U; ulIdx < REDCONF_TASK_COUNT; ulIdx++) - { - if(gaTask[ulIdx].ulTaskId == ulTaskId) - { - break; - } - - if((ulFirstFreeIdx == REDCONF_TASK_COUNT) && (gaTask[ulIdx].ulTaskId == 0U)) - { - ulFirstFreeIdx = ulIdx; - } - } - - if(ulIdx == REDCONF_TASK_COUNT) - { - /* Task not already registered. - */ - if(ulFirstFreeIdx == REDCONF_TASK_COUNT) - { - /* Cannot register task, no more slots. - */ - ret = -RED_EUSERS; - } - else - { - /* Registering task. - */ - ulIdx = ulFirstFreeIdx; - gaTask[ulIdx].ulTaskId = ulTaskId; - ret = 0; - } - } - else - { - /* Task already registered. - */ - ret = 0; - } - - if((ret == 0) && (pulTaskIdx != NULL)) - { - *pulTaskIdx = ulIdx; - } - - return ret; -} -#endif /* REDCONF_TASK_COUNT > 1U */ - - -/** @brief Convert an error value into a simple 0 or -1 return. - - This function is simple, but what it does is needed in many places. It - returns zero if @p iError is zero (meaning success) or it returns -1 if - @p iError is nonzero (meaning error). Also, if @p iError is nonzero, it - is saved in red_errno. - - @param iError The error value. - - @return Returns 0 if @p iError is 0; otherwise, returns -1. -*/ -static int32_t PosixReturn( - REDSTATUS iError) -{ - int32_t iReturn; - - if(iError == 0) - { - iReturn = 0; - } - else - { - iReturn = -1; - - /* The errors should be negative, and errno positive. - */ - REDASSERT(iError < 0); - red_errno = -iError; - } - - return iReturn; -} - - -#endif /* REDCONF_API_POSIX == 1 */ - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/tests/posix/fsstress.c b/FreeRTOS-Plus/Source/Reliance-Edge/tests/posix/fsstress.c deleted file mode 100755 index abc2aa9..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/tests/posix/fsstress.c +++ /dev/null @@ -1,2050 +0,0 @@ -/* - * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -/** @file - @brief File system stress test. - - This version of SGI fsstress has been modified to be single-threaded and to - work with the Reliance Edge POSIX-like API. -*/ -#include -#include -#include -#include -#include -#include - -#include -#include - -#if FSSTRESS_SUPPORTED - -#include "redposixcompat.h" - -#include -#include -#include -#include -#include -#include - -#if REDCONF_CHECKER == 1 -#include -#endif - - -/* Create POSIX types. Use #define to avoid name conflicts in those - environments where the type names already exist. -*/ -#define off_t int64_t -#define off64_t off_t -#define ino_t uint32_t -#define mode_t uint16_t -#define __int64_t int64_t - - -/** @brief Generate a random number. - - @return A nonnegative random number. -*/ -#define random() ((int)(RedRand32(NULL) & 0x7FFFFFFF)) - - -/** @brief Seed the random number generator. -*/ -#define srandom(seed) RedRandSeed(seed) - - -#define _exit(status) exit(status) -#define getpagesize() 4096U -#define getpid() 1 - - -/** @brief Determine the maximum file size. - - This is used for the MAXFSSIZE macro. -*/ -static uint64_t MaxFileSize(void) -{ - REDSTATFS info; - int32_t iStatus; - REDSTATUS errnoSave = errno; - uint64_t ullMaxFileSize; - - iStatus = red_statvfs("", &info); - if(iStatus == 0) - { - ullMaxFileSize = info.f_maxfsize; - } - else - { - /* This function does not change errno. - */ - errno = errnoSave; - - ullMaxFileSize = 0x7FFFFFFFU; - } - - return ullMaxFileSize; -} - - -/*------------------------------------------------------------------- - Simulated current working directory support --------------------------------------------------------------------*/ - - -/* Forward declaration for red_chdir(). -*/ -static int red_stat(const char *pszPath, REDSTAT *pStat); - -/* The simulated CWD functions. -*/ -#undef chdir -#undef getcwd -#define chdir(path) red_chdir(path) -#define getcwd(buf, size) red_getcwd(buf, size) - - -/* Redefine the path-based APIs to call MakeFullPath() on their arguments - since there is no CWD support in the red_*() APIs. -*/ -#undef open -#undef unlink -#undef mkdir -#undef rmdir -#undef rename -#undef link -#undef opendir -#define open(path, oflag) red_open(MakeFullPath(path), oflag) -#define unlink(path) red_unlink(MakeFullPath(path)) -#define mkdir(path) red_mkdir(MakeFullPath(path)) -#define rmdir(path) red_rmdir(MakeFullPath(path)) -#define rename(old, new) red_rename(MakeFullPath(old), MakeFullPath(new)) -#define link(path, hardlink) red_link(MakeFullPath(path), MakeFullPath(hardlink)) -#define opendir(path) red_opendir(MakeFullPath(path)) - -#define FSSTRESS_BUF_SIZE 1024U - -/* Stores the simulated current working directory. -*/ -static char szLocalCwd[FSSTRESS_BUF_SIZE] = "/"; - - -/** @brief Change the current working directory. - - This function only supports a subset of what is possible with POSIX chdir(). - - @param pszPath The new current working directory. - - @return Upon successful completion, 0 shall be returned. Otherwise, -1 - shall be returned, and errno shall be set to indicate the error. -*/ -static int red_chdir( - const char *pszPath) -{ - uint32_t ulIdx; - int iErrno = 0; - - if(strcmp(pszPath, "..") == 0) - { - uint32_t ulLastSlashIdx = 0U; - - /* Chop off the last path separator and everything after it, so that - "/foo/bar/baz" becomes "/foo/bar", moving the CWD up one directory. - */ - for(ulIdx = 0U; szLocalCwd[ulIdx] != '\0'; ulIdx++) - { - if(szLocalCwd[ulIdx] == '/') - { - ulLastSlashIdx = ulIdx; - } - } - - if(ulLastSlashIdx != 0U) - { - szLocalCwd[ulLastSlashIdx] = '\0'; - } - } - else - { - char szOldCwd[FSSTRESS_BUF_SIZE]; - - /* chdir() must have no effect on the CWD if it fails, so save the CWD - so we can revert it if necessary. - */ - strcpy(szOldCwd, szLocalCwd); - - if(pszPath[0U] == '/') - { - if(strlen(pszPath) >= sizeof(szLocalCwd)) - { - iErrno = RED_ENAMETOOLONG; - } - else - { - strcpy(szLocalCwd, pszPath); - } - } - else - { - ulIdx = strlen(szLocalCwd); - - if((ulIdx + 1U + strlen(pszPath)) >= sizeof(szLocalCwd)) - { - iErrno = RED_ENAMETOOLONG; - } - else - { - if(szLocalCwd[1U] != '\0') - { - szLocalCwd[ulIdx] = '/'; - ulIdx++; - } - - strcpy(&szLocalCwd[ulIdx], pszPath); - } - } - - if(iErrno == 0) - { - REDSTAT s; - int iStatus; - - iStatus = red_stat(szLocalCwd, &s); - if(iStatus != 0) - { - iErrno = errno; - } - else if(!S_ISDIR(s.st_mode)) - { - iErrno = RED_ENOTDIR; - } - else - { - /* No error, new CWD checks out. - */ - } - } - - if(iErrno != 0) - { - strcpy(szLocalCwd, szOldCwd); - } - } - - if(iErrno != 0) - { - errno = iErrno; - } - - return iErrno == 0 ? 0 : -1; -} - - -/** @brief Retrieve the current working directory. - - @param pszBuf On successful return, populated with the current working - directory. If NULL, memory will be allocated for the CWD - and returned by this function. - @param nSize The size of @p pszBuf. - - @return On success, if @p pszBuf was non-NULL, returns @p pszBuf; if - @p pszBuf was NULL, returns an allocated buffer populated with the - CWD which must be freed by the caller. On failure, returns NULL - and errno will be set. -*/ -static char *red_getcwd( - char *pszBuf, - size_t nSize) -{ - char *pszRet; - - if(pszBuf == NULL) - { - pszRet = malloc(strlen(szLocalCwd) + 1U); - if(pszRet == NULL) - { - errno = RED_ENOMEM; - } - else - { - strcpy(pszRet, szLocalCwd); - } - } - else if(nSize < strlen(szLocalCwd) + 1U) - { - errno = RED_ERANGE; - pszRet = NULL; - } - else - { - strcpy(pszBuf, szLocalCwd); - pszRet = pszBuf; - } - - return pszRet; -} - - -/** @brief Make a relative path into a fully qualified path. - - @param pszName The relative path. - - @return On success, a pointer to a fully qualified path. On error, NULL. -*/ -static const char *MakeFullPath( - const char *pszName) -{ - #define MAXVOLNAME 64U /* Enough for most configs. */ - static char aszFullPath[2U][MAXVOLNAME + 1U + FSSTRESS_BUF_SIZE]; - static uint32_t ulWhich = 0U; - - char *pszFullPath = aszFullPath[ulWhich]; - const char *pszVolume = gpRedVolConf->pszPathPrefix; - int32_t iLen; - - if(pszName[0U] == '/') - { - iLen = RedSNPrintf(pszFullPath, sizeof(aszFullPath[0U]), "%s%s", pszVolume, pszName); - } - else if(strcmp(pszName, ".") == 0U) - { - iLen = RedSNPrintf(pszFullPath, sizeof(aszFullPath[0U]), "%s%s", pszVolume, szLocalCwd); - } - else if((szLocalCwd[0U] == '/') && (szLocalCwd[1U] == '\0')) - { - iLen = RedSNPrintf(pszFullPath, sizeof(aszFullPath[0U]), "%s/%s", pszVolume, pszName); - } - else - { - iLen = RedSNPrintf(pszFullPath, sizeof(aszFullPath[0U]), "%s%s/%s", pszVolume, szLocalCwd, pszName); - } - - if(iLen == -1) - { - /* Insufficient path buffer space. - */ - pszFullPath = NULL; - } - else - { - /* Toggle between two full path arrays; a kluge to make rename() and - link() work correctly. - */ - ulWhich ^= 1U; - } - - return pszFullPath; -} - - -/*------------------------------------------------------------------- - POSIX functions not implemented by the RED POSIX-like API --------------------------------------------------------------------*/ - -#define stat(p, s) red_stat(p, s) -#define stat64(p, s) stat(p, s) -#define lstat(p, s) stat(p, s) -#define lstat64(p, s) stat(p, s) -#define truncate(p, s) red_truncate(p, s) -#define truncate64(p, s) truncate(p, s) - - -/** @brief Get the status of a file or directory. -*/ -static int red_stat( - const char *pszPath, - REDSTAT *pStat) -{ - int iFd; - int iRet; - - iFd = open(pszPath, O_RDONLY); - iRet = iFd; - if(iFd != -1) - { - iRet = fstat(iFd, pStat); - - (void)close(iFd); - } - - return iRet; -} - - -/** @brief Truncate a file to a specified length. -*/ -static int red_truncate( - const char *pszPath, - off_t llSize) -{ - int iFd; - int iRet; - - iFd = open(pszPath, O_WRONLY); - iRet = iFd; - if(iFd != -1) - { - iRet = ftruncate(iFd, llSize); - - (void)close(iFd); - } - - return iRet; -} - - -/*------------------------------------------------------------------- - Begin ported fsstress code --------------------------------------------------------------------*/ - -/* Stuff from xfscompat.h */ - -#define MAXNAMELEN (REDCONF_NAME_MAX+1U) /* Assumed to include NUL */ - -struct dioattr { - int d_miniosz, d_maxiosz, d_mem; -}; - -#define MIN(a,b) ((a)<(b) ? (a):(b)) -#define MAX(a,b) ((a)>(b) ? (a):(b)) - -/* End xfscompat.h */ - - -typedef enum { - OP_CREAT, - OP_FDATASYNC, - OP_FSYNC, - OP_GETDENTS, - OP_LINK, - OP_MKDIR, - OP_READ, - OP_RENAME, - OP_RMDIR, - OP_STAT, - OP_TRUNCATE, - OP_UNLINK, - OP_WRITE, - #if REDCONF_CHECKER == 1 - OP_CHECK, - #endif - OP_LAST -} opty_t; - -typedef void (*opfnc_t) (int, long); - -typedef struct opdesc { - opty_t op; - const char *name; - opfnc_t func; - int freq; - int iswrite; -} opdesc_t; - -typedef struct fent { - int id; - int parent; -} fent_t; - -typedef struct flist { - int nfiles; - int nslots; - int tag; - fent_t *fents; -} flist_t; - -typedef struct pathname { - int len; - char *path; -} pathname_t; - -#define FT_DIR 0 -#define FT_DIRm (1 << FT_DIR) -#define FT_REG 1 -#define FT_REGm (1 << FT_REG) -#define FT_SYM 2 -#define FT_SYMm (1 << FT_SYM) -#define FT_DEV 3 -#define FT_DEVm (1 << FT_DEV) -#define FT_RTF 4 -#define FT_RTFm (1 << FT_RTF) -#define FT_nft 5 -#define FT_ANYm ((1 << FT_nft) - 1) -#define FT_REGFILE (FT_REGm | FT_RTFm) -#define FT_NOTDIR (FT_ANYm & ~FT_DIRm) - -#define FLIST_SLOT_INCR 16 -#define NDCACHE 64 - -#define MAXFSIZE MaxFileSize() - -static void creat_f(int opno, long r); -static void fdatasync_f(int opno, long r); -static void fsync_f(int opno, long r); -static void getdents_f(int opno, long r); -static void link_f(int opno, long r); -static void mkdir_f(int opno, long r); -static void read_f(int opno, long r); -static void rename_f(int opno, long r); -static void rmdir_f(int opno, long r); -static void stat_f(int opno, long r); -static void truncate_f(int opno, long r); -static void unlink_f(int opno, long r); -static void write_f(int opno, long r); -#if REDCONF_CHECKER == 1 -static void check_f(int opno, long r); -#endif - -static opdesc_t ops[] = { - {OP_CREAT, "creat", creat_f, 4, 1}, - {OP_FDATASYNC, "fdatasync", fdatasync_f, 1, 1}, - {OP_FSYNC, "fsync", fsync_f, 1, 1}, - {OP_GETDENTS, "getdents", getdents_f, 1, 0}, - {OP_LINK, "link", link_f, 1, 1}, - {OP_MKDIR, "mkdir", mkdir_f, 2, 1}, - {OP_READ, "read", read_f, 1, 0}, - {OP_RENAME, "rename", rename_f, 2, 1}, - {OP_RMDIR, "rmdir", rmdir_f, 1, 1}, - {OP_STAT, "stat", stat_f, 1, 0}, - {OP_TRUNCATE, "truncate", truncate_f, 2, 1}, - {OP_UNLINK, "unlink", unlink_f, 1, 1}, - {OP_WRITE, "write", write_f, 4, 1}, - #if REDCONF_CHECKER == 1 - {OP_CHECK, "check", check_f, 1, 1}, - #endif -}, *ops_end; - -static flist_t flist[FT_nft] = { - {0, 0, 'd', NULL}, - {0, 0, 'f', NULL}, - {0, 0, 'l', NULL}, - {0, 0, 'c', NULL}, - {0, 0, 'r', NULL}, -}; - -static int dcache[NDCACHE]; -static opty_t *freq_table; -static int freq_table_size; -static char *homedir; -static int *ilist; -static int ilistlen; -static off64_t maxfsize; -static int namerand; -static int nameseq; -static int nops; -static int operations = 1; -static int procid; -static int rtpct; -static unsigned long seed = 0; -static ino_t top_ino; -static int verbose = 0; - -static int delete_tree(const char *path); -static void add_to_flist(int fd, int it, int parent); -static void append_pathname(pathname_t *name, const char *str); -static void check_cwd(void); -static int creat_path(pathname_t *name, mode_t mode); -static void dcache_enter(int dirid, int slot); -static void dcache_init(void); -static fent_t *dcache_lookup(int dirid); -static void dcache_purge(int dirid); -static void del_from_flist(int ft, int slot); -static void doproc(void); -static void fent_to_name(pathname_t *name, flist_t *flp, fent_t *fep); -static void fix_parent(int oldid, int newid); -static void free_pathname(pathname_t *name); -static int generate_fname(fent_t *fep, int ft, pathname_t *name, int *idp, int *v); -static int get_fname(int which, long r, pathname_t *name, flist_t **flpp, fent_t **fepp, int *v); -static void init_pathname(pathname_t *name); -static int link_path(pathname_t *name1, pathname_t *name2); -static int lstat64_path(pathname_t *name, REDSTAT *sbuf); -static void make_freq_table(void); -static int mkdir_path(pathname_t *name, mode_t mode); -static void namerandpad(int id, char *buf, int len); -static int open_path(pathname_t *name, int oflag); -static DIR *opendir_path(pathname_t *name); -static int rename_path(pathname_t *name1, pathname_t *name2); -static int rmdir_path(pathname_t *name); -static void separate_pathname(pathname_t *name, char *buf, pathname_t *newname); -static int stat64_path(pathname_t *name, REDSTAT *sbuf); -static int truncate64_path(pathname_t *name, off64_t length); -static int unlink_path(pathname_t *name); -static void usage(const char *progname); - - -/** @brief Parse parameters for fsstress. - - @param argc The number of arguments from main(). - @param argv The vector of arguments from main(). - @param pParam Populated with the fsstress parameters. - @param pbVolNum If non-NULL, populated with the volume number. - @param ppszDevice If non-NULL, populated with the device name argument or - NULL if no device argument is provided. - - @return The result of parsing the parameters. -*/ -PARAMSTATUS FsstressParseParams( - int argc, - char *argv[], - FSSTRESSPARAM *pParam, - uint8_t *pbVolNum, - const char **ppszDevice) -{ - int c; - uint8_t bVolNum; - const REDOPTION aLongopts[] = - { - { "no-cleanup", red_no_argument, NULL, 'c' }, - { "loops", red_required_argument, NULL, 'l' }, - { "nops", red_required_argument, NULL, 'n' }, - { "namepad", red_no_argument, NULL, 'r' }, - { "seed", red_required_argument, NULL, 's' }, - { "verbose", red_no_argument, NULL, 'v' }, - { "dev", red_required_argument, NULL, 'D' }, - { "help", red_no_argument, NULL, 'H' }, - { NULL } - }; - - /* If run without parameters, treat as a help request. - */ - if(argc <= 1) - { - goto Help; - } - - /* Assume no device argument to start with. - */ - if(ppszDevice != NULL) - { - *ppszDevice = NULL; - } - - /* Set default parameters. - */ - FsstressDefaultParams(pParam); - - while((c = RedGetoptLong(argc, argv, "cl:n:rs:vD:H", aLongopts, NULL)) != -1) - { - switch(c) - { - case 'c': /* --no-cleanup */ - pParam->fNoCleanup = true; - break; - case 'l': /* --loops */ - pParam->ulLoops = RedAtoI(red_optarg); - break; - case 'n': /* --nops */ - pParam->ulNops = RedAtoI(red_optarg); - break; - case 'r': /* --namepad */ - pParam->fNamePad = true; - break; - case 's': /* --seed */ - pParam->ulSeed = RedAtoI(red_optarg); - break; - case 'v': /* --verbose */ - pParam->fVerbose = true; - break; - case 'D': /* --dev */ - if(ppszDevice != NULL) - { - *ppszDevice = red_optarg; - } - break; - case 'H': /* --help */ - goto Help; - case '?': /* Unknown or ambiguous option */ - case ':': /* Option missing required argument */ - default: - goto BadOpt; - } - } - - /* RedGetoptLong() has permuted argv to move all non-option arguments to - the end. We expect to find a volume identifier. - */ - if(red_optind >= argc) - { - RedPrintf("Missing volume argument\n"); - goto BadOpt; - } - - bVolNum = RedFindVolumeNumber(argv[red_optind]); - if(bVolNum == REDCONF_VOLUME_COUNT) - { - RedPrintf("Error: \"%s\" is not a valid volume identifier.\n", argv[red_optind]); - goto BadOpt; - } - - if(pbVolNum != NULL) - { - *pbVolNum = bVolNum; - } - - red_optind++; /* Move past volume parameter. */ - if(red_optind < argc) - { - int32_t ii; - - for(ii = red_optind; ii < argc; ii++) - { - RedPrintf("Error: Unexpected command-line argument \"%s\".\n", argv[ii]); - } - - goto BadOpt; - } - - return PARAMSTATUS_OK; - - BadOpt: - - RedPrintf("%s - invalid parameters\n", argv[0U]); - usage(argv[0U]); - return PARAMSTATUS_BAD; - - Help: - - usage(argv[0U]); - return PARAMSTATUS_HELP; -} - - -/** @brief Set default fsstress parameters. - - @param pParam Populated with the default fsstress parameters. -*/ -void FsstressDefaultParams( - FSSTRESSPARAM *pParam) -{ - RedMemSet(pParam, 0U, sizeof(*pParam)); - pParam->ulLoops = 1U; - pParam->ulNops = 10000U; -} - - -/** @brief Start fsstress. - - @param pParam fsstress parameters, either from FsstressParseParams() or - constructed programatically. - - @return Zero on success, otherwise nonzero. -*/ -int FsstressStart( - const FSSTRESSPARAM *pParam) -{ - char buf[10]; - int fd; - int i; - int cleanup; - int loops; - int loopcntr = 1; - - nops = sizeof(ops) / sizeof(ops[0]); - ops_end = &ops[nops]; - - /* Copy the already-parsed parameters into the traditional variables. - */ - cleanup = pParam->fNoCleanup ? 1 : 0; - loops = pParam->ulLoops; - operations = pParam->ulNops; - namerand = pParam->fNamePad ? 1 : 0; - seed = pParam->ulSeed; - verbose = pParam->fVerbose ? 1 : 0; - - make_freq_table(); - - while ((loopcntr <= loops) || (loops == 0)) { - RedSNPrintf(buf, sizeof(buf), "fss%x", getpid()); - fd = creat(buf, 0666); - maxfsize = (off64_t) MAXFSIZE; - dcache_init(); - if (!seed) { - seed = (unsigned long)RedOsClockGetTime(); - RedPrintf("seed = %ld\n", seed); - } - close(fd); - unlink(buf); - procid = 0; - doproc(); - if (cleanup == 0) { - delete_tree("/"); - for (i = 0; i < FT_nft; i++) { - flist[i].nslots = 0; - flist[i].nfiles = 0; - free(flist[i].fents); - flist[i].fents = NULL; - } - } - loopcntr++; - } - return 0; -} - -static int delete_tree(const char *path) -{ - REDSTAT sb; - DIR *dp; - REDDIRENT *dep; - char *childpath; - size_t len; - int e; - - e = stat(path, &sb); - if (e) - return errno; - - if (!S_ISDIR(sb.st_mode)) - return unlink(path) ? errno : 0; - - dp = opendir(path); - if (dp == NULL) - return errno; - - while((dep = readdir(dp)) != NULL) { - len = strlen(path) + 1 + strlen(dep->d_name) + 1; - childpath = malloc(len); - - strcpy(childpath, path); - if (childpath[strlen(childpath) - 1] != '/') - strcat(childpath, "/"); - strcat(childpath, dep->d_name); - - e = delete_tree(childpath); - - free(childpath); - - if (e) - break; - } - - if (e == 0 && strcmp(path, "/") != 0) { - e = rmdir(path) ? errno : 0; - } - closedir(dp); - return e; -} - -static void add_to_flist(int ft, int id, int parent) -{ - fent_t *fep; - flist_t *ftp; - - ftp = &flist[ft]; - if (ftp->nfiles == ftp->nslots) { - ftp->nslots += FLIST_SLOT_INCR; - ftp->fents = realloc(ftp->fents, ftp->nslots * sizeof(fent_t)); - } - fep = &ftp->fents[ftp->nfiles++]; - fep->id = id; - fep->parent = parent; -} - -static void append_pathname(pathname_t *name, const char *str) -{ - int len; - - len = strlen(str); -#ifdef DEBUG - if (len && *str == '/' && name->len == 0) { - RedPrintf("fsstress: append_pathname failure\n"); - chdir(homedir); - abort(); - - } -#endif - name->path = realloc(name->path, name->len + 1 + len); - strcpy(&name->path[name->len], str); - name->len += len; -} - -static void check_cwd(void) -{ -#ifdef DEBUG - REDSTAT statbuf; - - if (stat64(".", &statbuf) == 0 && statbuf.st_ino == top_ino) - return; - chdir(homedir); - RedPrintf("fsstress: check_cwd failure\n"); - abort(); - -#endif -} - -static int creat_path(pathname_t *name, mode_t mode) -{ - char buf[MAXNAMELEN]; - pathname_t newname; - int rval; - - rval = creat(name->path, mode); - if (rval >= 0 || errno != RED_ENAMETOOLONG) - return rval; - separate_pathname(name, buf, &newname); - if (chdir(buf) == 0) { - rval = creat_path(&newname, mode); - chdir(".."); - } - free_pathname(&newname); - return rval; -} - -static void dcache_enter(int dirid, int slot) -{ - dcache[dirid % NDCACHE] = slot; -} - -static void dcache_init(void) -{ - int i; - - for (i = 0; i < NDCACHE; i++) - dcache[i] = -1; -} - -static fent_t *dcache_lookup(int dirid) -{ - fent_t *fep; - int i; - - i = dcache[dirid % NDCACHE]; - if (i >= 0 && (fep = &flist[FT_DIR].fents[i])->id == dirid) - return fep; - return NULL; -} - -static void dcache_purge(int dirid) -{ - int *dcp; - - dcp = &dcache[dirid % NDCACHE]; - if (*dcp >= 0 && flist[FT_DIR].fents[*dcp].id == dirid) - *dcp = -1; -} - -static void del_from_flist(int ft, int slot) -{ - flist_t *ftp; - - ftp = &flist[ft]; - if (ft == FT_DIR) - dcache_purge(ftp->fents[slot].id); - if (slot != ftp->nfiles - 1) { - if (ft == FT_DIR) - dcache_purge(ftp->fents[ftp->nfiles - 1].id); - ftp->fents[slot] = ftp->fents[--ftp->nfiles]; - } else - ftp->nfiles--; -} - -static fent_t *dirid_to_fent(int dirid) -{ - fent_t *efep; - fent_t *fep; - flist_t *flp; - - if ((fep = dcache_lookup(dirid))) - return fep; - flp = &flist[FT_DIR]; - for (fep = flp->fents, efep = &fep[flp->nfiles]; fep < efep; fep++) { - if (fep->id == dirid) { - dcache_enter(dirid, (int)(fep - flp->fents)); - return fep; - } - } - return NULL; -} - -static void doproc(void) -{ - REDSTAT statbuf; - char buf[10]; - int opno; - opdesc_t *p; - - RedSNPrintf(buf, sizeof(buf), "p%x", procid); - (void)mkdir(buf); - if (chdir(buf) < 0 || stat64(".", &statbuf) < 0) { - perror(buf); - _exit(1); - } - top_ino = statbuf.st_ino; - homedir = getcwd(NULL, 0); - seed += procid; - srandom(seed); - if (namerand) - namerand = random(); - for (opno = 0; opno < operations; opno++) { - p = &ops[freq_table[random() % freq_table_size]]; - if ((unsigned long)p->func < 4096) - abort(); - - p->func(opno, random()); - } - free(homedir); -} - -static void fent_to_name(pathname_t *name, flist_t *flp, fent_t *fep) -{ - char buf[MAXNAMELEN]; - int i; - fent_t *pfep; - - if (fep == NULL) - return; - if (fep->parent != -1) { - pfep = dirid_to_fent(fep->parent); - fent_to_name(name, &flist[FT_DIR], pfep); - append_pathname(name, "/"); - } - i = RedSNPrintf(buf, sizeof(buf), "%c%x", flp->tag, fep->id); - namerandpad(fep->id, buf, i); - append_pathname(name, buf); -} - -static void fix_parent(int oldid, int newid) -{ - fent_t *fep; - flist_t *flp; - int i; - int j; - - for (i = 0, flp = flist; i < FT_nft; i++, flp++) { - for (j = 0, fep = flp->fents; j < flp->nfiles; j++, fep++) { - if (fep->parent == oldid) - fep->parent = newid; - } - } -} - -static void free_pathname(pathname_t *name) -{ - if (name->path) { - free(name->path); - name->path = NULL; - name->len = 0; - } -} - -static int generate_fname(fent_t *fep, int ft, pathname_t *name, int *idp, int *v) -{ - char buf[MAXNAMELEN]; - flist_t *flp; - int id; - int j; - int len; - - flp = &flist[ft]; - len = RedSNPrintf(buf, sizeof(buf), "%c%x", flp->tag, id = nameseq++); - namerandpad(id, buf, len); - if (fep) { - fent_to_name(name, &flist[FT_DIR], fep); - append_pathname(name, "/"); - } - append_pathname(name, buf); - *idp = id; - *v = verbose; - for (j = 0; !*v && j < ilistlen; j++) { - if (ilist[j] == id) { - *v = 1; - break; - } - } - return 1; -} - -static int -get_fname(int which, long r, pathname_t *name, flist_t **flpp, fent_t **fepp, int *v) -{ - int c; - fent_t *fep; - flist_t *flp; - int i; - int j; - int x; - - for (i = 0, c = 0, flp = flist; i < FT_nft; i++, flp++) { - if (which & (1 << i)) - c += flp->nfiles; - } - if (c == 0) { - if (flpp) - *flpp = NULL; - if (fepp) - *fepp = NULL; - *v = verbose; - return 0; - } - x = (int)(r % c); - for (i = 0, c = 0, flp = flist; i < FT_nft; i++, flp++) { - if (which & (1 << i)) { - if (x < c + flp->nfiles) { - fep = &flp->fents[x - c]; - if (name) - fent_to_name(name, flp, fep); - if (flpp) - *flpp = flp; - if (fepp) - *fepp = fep; - *v = verbose; - for (j = 0; !*v && j < ilistlen; j++) { - if (ilist[j] == fep->id) { - *v = 1; - break; - } - } - return 1; - } - c += flp->nfiles; - } - } -#ifdef DEBUG - RedPrintf("fsstress: get_fname failure\n"); - abort(); -#endif - return -1; - -} - -static void init_pathname(pathname_t *name) -{ - name->len = 0; - name->path = NULL; -} - -static int link_path(pathname_t *name1, pathname_t *name2) -{ - char buf1[MAXNAMELEN]; - char buf2[MAXNAMELEN]; - int down1; - pathname_t newname1; - pathname_t newname2; - int rval; - - rval = link(name1->path, name2->path); - if (rval >= 0 || errno != RED_ENAMETOOLONG) - return rval; - separate_pathname(name1, buf1, &newname1); - separate_pathname(name2, buf2, &newname2); - if (strcmp(buf1, buf2) == 0) { - if (chdir(buf1) == 0) { - rval = link_path(&newname1, &newname2); - chdir(".."); - } - } else { - if (strcmp(buf1, "..") == 0) - down1 = 0; - else if (strcmp(buf2, "..") == 0) - down1 = 1; - else if (strlen(buf1) == 0) - down1 = 0; - else if (strlen(buf2) == 0) - down1 = 1; - else - down1 = MAX(newname1.len, 3 + name2->len) <= - MAX(3 + name1->len, newname2.len); - if (down1) { - free_pathname(&newname2); - append_pathname(&newname2, "../"); - append_pathname(&newname2, name2->path); - if (chdir(buf1) == 0) { - rval = link_path(&newname1, &newname2); - chdir(".."); - } - } else { - free_pathname(&newname1); - append_pathname(&newname1, "../"); - append_pathname(&newname1, name1->path); - if (chdir(buf2) == 0) { - rval = link_path(&newname1, &newname2); - chdir(".."); - } - } - } - free_pathname(&newname1); - free_pathname(&newname2); - return rval; -} - -static int lstat64_path(pathname_t *name, REDSTAT *sbuf) -{ - char buf[MAXNAMELEN]; - pathname_t newname; - int rval; - - rval = lstat64(name->path, sbuf); - if (rval >= 0 || errno != RED_ENAMETOOLONG) - return rval; - separate_pathname(name, buf, &newname); - if (chdir(buf) == 0) { - rval = lstat64_path(&newname, sbuf); - chdir(".."); - } - free_pathname(&newname); - return rval; -} - -static void make_freq_table(void) -{ - int f; - int i; - opdesc_t *p; - - for (p = ops, f = 0; p < ops_end; p++) - f += p->freq; - freq_table = malloc(f * sizeof(*freq_table)); - freq_table_size = f; - for (p = ops, i = 0; p < ops_end; p++) { - for (f = 0; f < p->freq; f++, i++) - freq_table[i] = p->op; - } -} - -static int mkdir_path(pathname_t *name, mode_t mode) -{ - char buf[MAXNAMELEN]; - pathname_t newname; - int rval; - - rval = mkdir(name->path); - if (rval >= 0 || errno != RED_ENAMETOOLONG) - return rval; - separate_pathname(name, buf, &newname); - if (chdir(buf) == 0) { - rval = mkdir_path(&newname, mode); - chdir(".."); - } - free_pathname(&newname); - return rval; -} - -static void namerandpad(int id, char *buf, int len) -{ - int bucket; - static int buckets[8] = {0}; - static int bucket_count = 0; - int bucket_value; - int i; - int padlen; - int padmod; - - if (namerand == 0) - return; - - /* buckets[] used to be a statically initialized array with the following - initializer: { 2, 4, 8, 16, 32, 64, 128, MAXNAMELEN - 1 } - - The problem is that with Reliance Edge, the maximum name length might be - less than 128. So the below code populates buckets[] in a similar - fashion but avoids name lengths longer than the maximum. For example, - if the max name is 20, the resulting array is { 2, 4, 8, 16, 20 }. - */ - if (!bucket_count) { - bucket_count = sizeof(buckets) / sizeof(buckets[0]); - bucket_value = 2; - for (i = 0; i < bucket_count; i++) { - if (bucket_value > 128 || bucket_value >= (int)MAXNAMELEN - 1) - break; - buckets[i] = bucket_value; - bucket_value *= 2; - } - if (i < bucket_count) { - buckets[i] = MAXNAMELEN - 1; - i++; - } - bucket_count = i; - } - - bucket = (id ^ namerand) % bucket_count; - padmod = buckets[bucket] + 1 - len; - if (padmod <= 0) - return; - padlen = (id ^ namerand) % padmod; - if (padlen) { - memset(&buf[len], 'X', padlen); - buf[len + padlen] = '\0'; - } -} - -static int open_path(pathname_t *name, int oflag) -{ - char buf[MAXNAMELEN]; - pathname_t newname; - int rval; - - rval = open(name->path, oflag); - if (rval >= 0 || errno != RED_ENAMETOOLONG) - return rval; - separate_pathname(name, buf, &newname); - if (chdir(buf) == 0) { - rval = open_path(&newname, oflag); - chdir(".."); - } - free_pathname(&newname); - return rval; -} - -static DIR *opendir_path(pathname_t *name) -{ - char buf[MAXNAMELEN]; - pathname_t newname; - DIR *rval; - - rval = opendir(name->path); - if (rval || errno != RED_ENAMETOOLONG) - return rval; - separate_pathname(name, buf, &newname); - if (chdir(buf) == 0) { - rval = opendir_path(&newname); - chdir(".."); - } - free_pathname(&newname); - return rval; -} - -static int rename_path(pathname_t *name1, pathname_t *name2) -{ - char buf1[MAXNAMELEN]; - char buf2[MAXNAMELEN]; - int down1; - pathname_t newname1; - pathname_t newname2; - int rval; - - rval = rename(name1->path, name2->path); - if (rval >= 0 || errno != RED_ENAMETOOLONG) - return rval; - separate_pathname(name1, buf1, &newname1); - separate_pathname(name2, buf2, &newname2); - if (strcmp(buf1, buf2) == 0) { - if (chdir(buf1) == 0) { - rval = rename_path(&newname1, &newname2); - chdir(".."); - } - } else { - if (strcmp(buf1, "..") == 0) - down1 = 0; - else if (strcmp(buf2, "..") == 0) - down1 = 1; - else if (strlen(buf1) == 0) - down1 = 0; - else if (strlen(buf2) == 0) - down1 = 1; - else - down1 = MAX(newname1.len, 3 + name2->len) <= - MAX(3 + name1->len, newname2.len); - if (down1) { - free_pathname(&newname2); - append_pathname(&newname2, "../"); - append_pathname(&newname2, name2->path); - if (chdir(buf1) == 0) { - rval = rename_path(&newname1, &newname2); - chdir(".."); - } - } else { - free_pathname(&newname1); - append_pathname(&newname1, "../"); - append_pathname(&newname1, name1->path); - if (chdir(buf2) == 0) { - rval = rename_path(&newname1, &newname2); - chdir(".."); - } - } - } - free_pathname(&newname1); - free_pathname(&newname2); - return rval; -} - -static int rmdir_path(pathname_t *name) -{ - char buf[MAXNAMELEN]; - pathname_t newname; - int rval; - - rval = rmdir(name->path); - if (rval >= 0 || errno != RED_ENAMETOOLONG) - return rval; - separate_pathname(name, buf, &newname); - if (chdir(buf) == 0) { - rval = rmdir_path(&newname); - chdir(".."); - } - free_pathname(&newname); - return rval; -} - -static void separate_pathname(pathname_t *name, char *buf, pathname_t *newname) -{ - char *slash; - - init_pathname(newname); - slash = strchr(name->path, '/'); - if (slash == NULL) { - buf[0] = '\0'; - return; - } - *slash = '\0'; - strcpy(buf, name->path); - *slash = '/'; - append_pathname(newname, slash + 1); -} - -static int stat64_path(pathname_t *name, REDSTAT *sbuf) -{ - char buf[MAXNAMELEN]; - pathname_t newname; - int rval; - - rval = stat64(name->path, sbuf); - if (rval >= 0 || errno != RED_ENAMETOOLONG) - return rval; - separate_pathname(name, buf, &newname); - if (chdir(buf) == 0) { - rval = stat64_path(&newname, sbuf); - chdir(".."); - } - free_pathname(&newname); - return rval; -} - -static int truncate64_path(pathname_t *name, off64_t length) -{ - char buf[MAXNAMELEN]; - pathname_t newname; - int rval; - - rval = truncate64(name->path, length); - if (rval >= 0 || errno != RED_ENAMETOOLONG) - return rval; - separate_pathname(name, buf, &newname); - if (chdir(buf) == 0) { - rval = truncate64_path(&newname, length); - chdir(".."); - } - free_pathname(&newname); - return rval; -} - -static int unlink_path(pathname_t *name) -{ - char buf[MAXNAMELEN]; - pathname_t newname; - int rval; - - rval = unlink(name->path); - if (rval >= 0 || errno != RED_ENAMETOOLONG) - return rval; - separate_pathname(name, buf, &newname); - if (chdir(buf) == 0) { - rval = unlink_path(&newname); - chdir(".."); - } - free_pathname(&newname); - return rval; -} - -static void usage(const char *progname) -{ - RedPrintf("usage: %s VolumeID [Options]\n", progname); - RedPrintf("File system stress test.\n\n"); - RedPrintf("Where:\n"); - RedPrintf(" VolumeID\n"); - RedPrintf(" A volume number (e.g., 2) or a volume path prefix (e.g., VOL1: or /data)\n"); - RedPrintf(" of the volume to test.\n"); - RedPrintf("And 'Options' are any of the following:\n"); - RedPrintf(" --no-cleanup, -c\n"); - RedPrintf(" Specifies not to remove files (cleanup) after execution\n"); - RedPrintf(" --loops=count, -l count\n"); - RedPrintf(" Specifies the number of times the entire test should loop. Use 0 for\n"); - RedPrintf(" infinite. Default 1.\n"); - RedPrintf(" --nops=count, -n count\n"); - RedPrintf(" Specifies the number of operations to run (default 10000).\n"); - RedPrintf(" --namepad, -r\n"); - RedPrintf(" Specifies to use random name padding (resulting in longer names).\n"); - RedPrintf(" --seed=value, -s value\n"); - RedPrintf(" Specifies the seed for the random number generator (default timestamp).\n"); - RedPrintf(" --verbose, -v\n"); - RedPrintf(" Specifies verbose mode (without this, test is very quiet).\n"); - RedPrintf(" --dev=devname, -D devname\n"); - RedPrintf(" Specifies the device name. This is typically only meaningful when\n"); - RedPrintf(" running the test on a host machine. This can be \"ram\" to test on a RAM\n"); - RedPrintf(" disk, the path and name of a file disk (e.g., red.bin); or an OS-specific\n"); - RedPrintf(" reference to a device (on Windows, a drive letter like G: or a device name\n"); - RedPrintf(" like \\\\.\\PhysicalDrive7).\n"); - RedPrintf(" --help, -H\n"); - RedPrintf(" Prints this usage text and exits.\n\n"); - RedPrintf("Warning: This test will format the volume -- destroying all existing data.\n\n"); -} - -static void creat_f(int opno, long r) -{ - int e; - int e1; - pathname_t f; - int fd; - fent_t *fep; - int id; - int parid; - int type; - int v; - int v1; - int esz = 0; - - if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v1)) - parid = -1; - else - parid = fep->id; - init_pathname(&f); - type = rtpct ? ((int)(random() % 100) > rtpct ? FT_REG : FT_RTF) : FT_REG; - e = generate_fname(fep, type, &f, &id, &v); - v |= v1; - if (!e) { - if (v) { - fent_to_name(&f, &flist[FT_DIR], fep); - RedPrintf("%d/%d: creat - no filename from %s\n", - procid, opno, f.path); - } - free_pathname(&f); - return; - } - fd = creat_path(&f, 0666); - e = fd < 0 ? errno : 0; - e1 = 0; - check_cwd(); - esz = 0; - if (fd >= 0) { - add_to_flist(type, id, parid); - close(fd); - } - if (v) - RedPrintf("%d/%d: creat %s x:%d %d %d\n", procid, opno, f.path, - esz, e, e1); - free_pathname(&f); -} - -static void fdatasync_f(int opno, long r) -{ - int e; - pathname_t f; - int fd; - int v; - - init_pathname(&f); - if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) { - if (v) - RedPrintf("%d/%d: fdatasync - no filename\n", - procid, opno); - free_pathname(&f); - return; - } - fd = open_path(&f, O_WRONLY); - e = fd < 0 ? errno : 0; - check_cwd(); - if (fd < 0) { - if (v) - RedPrintf("%d/%d: fdatasync - open %s failed %d\n", - procid, opno, f.path, e); - free_pathname(&f); - return; - } - e = fdatasync(fd) < 0 ? errno : 0; - if (v) - RedPrintf("%d/%d: fdatasync %s %d\n", procid, opno, f.path, e); - free_pathname(&f); - close(fd); -} - -static void fsync_f(int opno, long r) -{ - int e; - pathname_t f; - int fd; - int v; - - init_pathname(&f); - if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) { - if (v) - RedPrintf("%d/%d: fsync - no filename\n", procid, opno); - free_pathname(&f); - return; - } - fd = open_path(&f, O_WRONLY); - e = fd < 0 ? errno : 0; - check_cwd(); - if (fd < 0) { - if (v) - RedPrintf("%d/%d: fsync - open %s failed %d\n", - procid, opno, f.path, e); - free_pathname(&f); - return; - } - e = fsync(fd) < 0 ? errno : 0; - if (v) - RedPrintf("%d/%d: fsync %s %d\n", procid, opno, f.path, e); - free_pathname(&f); - close(fd); -} - -static void getdents_f(int opno, long r) -{ - DIR *dir; - pathname_t f; - int v; - - init_pathname(&f); - if (!get_fname(FT_DIRm, r, &f, NULL, NULL, &v)) - append_pathname(&f, "."); - dir = opendir_path(&f); - check_cwd(); - if (dir == NULL) { - if (v) - RedPrintf("%d/%d: getdents - can't open %s\n", - procid, opno, f.path); - free_pathname(&f); - return; - } - while (readdir64(dir) != NULL) - continue; - if (v) - RedPrintf("%d/%d: getdents %s 0\n", procid, opno, f.path); - free_pathname(&f); - closedir(dir); -} - -static void link_f(int opno, long r) -{ - int e; - pathname_t f; - fent_t *fep; - flist_t *flp; - int id; - pathname_t l; - int parid; - int v; - int v1; - - init_pathname(&f); - if (!get_fname(FT_NOTDIR, r, &f, &flp, NULL, &v1)) { - if (v1) - RedPrintf("%d/%d: link - no file\n", procid, opno); - free_pathname(&f); - return; - } - if (!get_fname(FT_DIRm, random(), NULL, NULL, &fep, &v)) - parid = -1; - else - parid = fep->id; - v |= v1; - init_pathname(&l); - e = generate_fname(fep, (int)(flp - flist), &l, &id, &v1); - v |= v1; - if (!e) { - if (v) { - fent_to_name(&l, &flist[FT_DIR], fep); - RedPrintf("%d/%d: link - no filename from %s\n", - procid, opno, l.path); - } - free_pathname(&l); - free_pathname(&f); - return; - } - e = link_path(&f, &l) < 0 ? errno : 0; - check_cwd(); - if (e == 0) - add_to_flist((int)(flp - flist), id, parid); - if (v) - RedPrintf("%d/%d: link %s %s %d\n", procid, opno, f.path, l.path, - e); - free_pathname(&l); - free_pathname(&f); -} - -static void mkdir_f(int opno, long r) -{ - int e; - pathname_t f; - fent_t *fep; - int id; - int parid; - int v; - int v1; - - if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v)) - parid = -1; - else - parid = fep->id; - init_pathname(&f); - e = generate_fname(fep, FT_DIR, &f, &id, &v1); - v |= v1; - if (!e) { - if (v) { - fent_to_name(&f, &flist[FT_DIR], fep); - RedPrintf("%d/%d: mkdir - no filename from %s\n", - procid, opno, f.path); - } - free_pathname(&f); - return; - } - e = mkdir_path(&f, 0777) < 0 ? errno : 0; - check_cwd(); - if (e == 0) - add_to_flist(FT_DIR, id, parid); - if (v) - RedPrintf("%d/%d: mkdir %s %d\n", procid, opno, f.path, e); - free_pathname(&f); -} - -static void read_f(int opno, long r) -{ - char *buf; - int e; - pathname_t f; - int fd; - uint32_t len; - __int64_t lr; - off64_t off; - REDSTAT stb; - int v; - - init_pathname(&f); - if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) { - if (v) - RedPrintf("%d/%d: read - no filename\n", procid, opno); - free_pathname(&f); - return; - } - fd = open_path(&f, O_RDONLY); - e = fd < 0 ? errno : 0; - check_cwd(); - if (fd < 0) { - if (v) - RedPrintf("%d/%d: read - open %s failed %d\n", - procid, opno, f.path, e); - free_pathname(&f); - return; - } - if (fstat64(fd, &stb) < 0) { - if (v) - RedPrintf("%d/%d: read - fstat64 %s failed %d\n", - procid, opno, f.path, errno); - free_pathname(&f); - close(fd); - return; - } - if (stb.st_size == 0) { - if (v) - RedPrintf("%d/%d: read - %s zero size\n", procid, opno, - f.path); - free_pathname(&f); - close(fd); - return; - } - lr = ((__int64_t) random() << 32) + random(); - off = (off64_t) (lr % stb.st_size); - lseek64(fd, off, SEEK_SET); - len = (random() % (getpagesize() * 4)) + 1; - buf = malloc(len); - e = read(fd, buf, len) < 0 ? errno : 0; - free(buf); - if (v) - RedPrintf("%d/%d: read %s [%lld,%ld] %d\n", - procid, opno, f.path, (long long)off, (long int)len, e); - free_pathname(&f); - close(fd); -} - -static void rename_f(int opno, long r) -{ - fent_t *dfep; - int e; - pathname_t f; - fent_t *fep; - flist_t *flp; - int id; - pathname_t newf; - int oldid; - int parid; - int v; - int v1; - - init_pathname(&f); - if (!get_fname(FT_ANYm, r, &f, &flp, &fep, &v1)) { - if (v1) - RedPrintf("%d/%d: rename - no filename\n", procid, opno); - free_pathname(&f); - return; - } - if (!get_fname(FT_DIRm, random(), NULL, NULL, &dfep, &v)) - parid = -1; - else - parid = dfep->id; - v |= v1; - init_pathname(&newf); - e = generate_fname(dfep, (int)(flp - flist), &newf, &id, &v1); - v |= v1; - if (!e) { - if (v) { - fent_to_name(&f, &flist[FT_DIR], dfep); - RedPrintf("%d/%d: rename - no filename from %s\n", - procid, opno, f.path); - } - free_pathname(&newf); - free_pathname(&f); - return; - } - e = rename_path(&f, &newf) < 0 ? errno : 0; - check_cwd(); - if (e == 0) { - if (flp - flist == FT_DIR) { - oldid = fep->id; - fix_parent(oldid, id); - } - del_from_flist((int)(flp - flist), (int)(fep - flp->fents)); - add_to_flist((int)(flp - flist), id, parid); - } - if (v) - RedPrintf("%d/%d: rename %s to %s %d\n", procid, opno, f.path, - newf.path, e); - free_pathname(&newf); - free_pathname(&f); -} - -static void rmdir_f(int opno, long r) -{ - int e; - pathname_t f; - fent_t *fep; - int v; - - init_pathname(&f); - if (!get_fname(FT_DIRm, r, &f, NULL, &fep, &v)) { - if (v) - RedPrintf("%d/%d: rmdir - no directory\n", procid, opno); - free_pathname(&f); - return; - } - e = rmdir_path(&f) < 0 ? errno : 0; - check_cwd(); - if (e == 0) - del_from_flist(FT_DIR, (int)(fep - flist[FT_DIR].fents)); - if (v) - RedPrintf("%d/%d: rmdir %s %d\n", procid, opno, f.path, e); - free_pathname(&f); -} - -static void stat_f(int opno, long r) -{ - int e; - pathname_t f; - REDSTAT stb; - int v; - - init_pathname(&f); - if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v)) { - if (v) - RedPrintf("%d/%d: stat - no entries\n", procid, opno); - free_pathname(&f); - return; - } - e = lstat64_path(&f, &stb) < 0 ? errno : 0; - check_cwd(); - if (v) - RedPrintf("%d/%d: stat %s %d\n", procid, opno, f.path, e); - free_pathname(&f); -} - -static void truncate_f(int opno, long r) -{ - int e; - pathname_t f; - __int64_t lr; - off64_t off; - REDSTAT stb; - int v; - - init_pathname(&f); - if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) { - if (v) - RedPrintf("%d/%d: truncate - no filename\n", procid, opno); - free_pathname(&f); - return; - } - e = stat64_path(&f, &stb) < 0 ? errno : 0; - check_cwd(); - if (e > 0) { - if (v) - RedPrintf("%d/%d: truncate - stat64 %s failed %d\n", - procid, opno, f.path, e); - free_pathname(&f); - return; - } - lr = ((__int64_t) random() << 32) + random(); - off = lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE); - off %= maxfsize; - e = truncate64_path(&f, off) < 0 ? errno : 0; - check_cwd(); - if (v) - RedPrintf("%d/%d: truncate %s %lld %d\n", procid, opno, f.path, - (long long)off, e); - free_pathname(&f); -} - -static void unlink_f(int opno, long r) -{ - int e; - pathname_t f; - fent_t *fep; - flist_t *flp; - int v; - - init_pathname(&f); - if (!get_fname(FT_NOTDIR, r, &f, &flp, &fep, &v)) { - if (v) - RedPrintf("%d/%d: unlink - no file\n", procid, opno); - free_pathname(&f); - return; - } - e = unlink_path(&f) < 0 ? errno : 0; - check_cwd(); - if (e == 0) - del_from_flist((int)(flp - flist), (int)(fep - flp->fents)); - if (v) - RedPrintf("%d/%d: unlink %s %d\n", procid, opno, f.path, e); - free_pathname(&f); -} - -static void write_f(int opno, long r) -{ - char *buf; - int e; - pathname_t f; - int fd; - uint32_t len; - __int64_t lr; - off64_t off; - REDSTAT stb; - int v; - - init_pathname(&f); - if (!get_fname(FT_REGm, r, &f, NULL, NULL, &v)) { - if (v) - RedPrintf("%d/%d: write - no filename\n", procid, opno); - free_pathname(&f); - return; - } - fd = open_path(&f, O_WRONLY); - e = fd < 0 ? errno : 0; - check_cwd(); - if (fd < 0) { - if (v) - RedPrintf("%d/%d: write - open %s failed %d\n", - procid, opno, f.path, e); - free_pathname(&f); - return; - } - if (fstat64(fd, &stb) < 0) { - if (v) - RedPrintf("%d/%d: write - fstat64 %s failed %d\n", - procid, opno, f.path, errno); - free_pathname(&f); - close(fd); - return; - } - lr = ((__int64_t) random() << 32) + random(); - off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE)); - off %= maxfsize; - lseek64(fd, off, SEEK_SET); - len = (random() % (getpagesize() * 4)) + 1; - buf = malloc(len); - memset(buf, nameseq & 0xff, len); - e = write(fd, buf, len) < 0 ? errno : 0; - free(buf); - if (v) - RedPrintf("%d/%d: write %s [%lld,%ld] %d\n", - procid, opno, f.path, (long long)off, (long int)len, e); - free_pathname(&f); - close(fd); -} - - -#if REDCONF_CHECKER == 1 -static void check_f(int opno, long r) -{ - int32_t ret; - const char *pszVolume = gpRedVolConf->pszPathPrefix; - - (void)r; - - errno = 0; - - ret = red_transact(pszVolume); - - if(ret == 0) - { - ret = red_umount(pszVolume); - - if(ret == 0) - { - int32_t ret2; - - errno = -RedCoreVolCheck(); - if(errno != 0) - { - ret = -1; - } - - ret2 = red_mount(pszVolume); - - if(ret == 0) - { - ret = ret2; - } - - if(ret2 != 0) - { - exit(1); - } - } - } - - if (verbose) - { - RedPrintf("%d/%d: check %s %d\n", procid, opno, pszVolume, errno); - } -} -#endif - - -#endif /* FSSTRESS_SUPPORTED */ - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/tests/posix/redposixcompat.h b/FreeRTOS-Plus/Source/Reliance-Edge/tests/posix/redposixcompat.h deleted file mode 100755 index d800d1e..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/tests/posix/redposixcompat.h +++ /dev/null @@ -1,152 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Defines macros which make the Reliance Edge POSIX-like API look more - like the actual POSIX API. - - This file is intended for porting POSIX file system tests; it is not - intended for application use. -*/ -#ifndef REDPOSIXCOMPAT_H -#define REDPOSIXCOMPAT_H - - -#ifndef assert -#define assert(x) REDASSERT(x) -#endif - - -#undef O_RDONLY -#undef O_WRONLY -#undef O_RDWR -#undef O_APPEND -#undef O_CREAT -#undef O_EXCL -#undef O_TRUNC -#define O_RDONLY RED_O_RDONLY -#define O_WRONLY RED_O_WRONLY -#define O_RDWR RED_O_RDWR -#define O_APPEND RED_O_APPEND -#define O_CREAT RED_O_CREAT -#define O_EXCL RED_O_EXCL -#define O_TRUNC RED_O_TRUNC - -#undef SEEK_SET -#undef SEEK_CUR -#undef SEEK_END -#define SEEK_SET RED_SEEK_SET -#define SEEK_CUR RED_SEEK_CUR -#define SEEK_END RED_SEEK_END - -/* Old-fashioned Linux seek names. -*/ -#undef L_SET -#undef L_INCR -#undef L_XTND -#define L_SET SEEK_SET -#define L_INCR SEEK_CUR -#define L_XTND SEEK_END - -#undef S_IFDIR -#undef S_IFREG -#undef S_ISDIR -#undef S_ISREG -#define S_IFDIR RED_S_IFDIR -#define S_IFREG RED_S_IFREG -#define S_ISDIR(m) RED_S_ISDIR(m) -#define S_ISREG(m) RED_S_ISREG(m) - -#undef ST_RDONLY -#undef ST_NOSUID -#define ST_RDONLY RED_ST_RDONLY -#define ST_NOSUID RED_ST_NOSUID - -#undef open -#undef creat -#undef unlink -#undef mkdir -#undef rmdir -#undef rename -#undef link -#undef close -#undef read -#undef write -#undef fsync -#undef fdatasync -#undef lseek -#undef ftruncate -#undef fstat -#undef opendir -#undef readdir -#undef rewinddir -#undef closedir -#define open(path, oflag) red_open(path, oflag) -#define creat(path, mode) open(path, O_WRONLY|O_CREAT|O_TRUNC) -#define unlink(path) red_unlink(path) -#define mkdir(path) red_mkdir(path) -#define rmdir(path) red_rmdir(path) -#define rename(old, new) red_rename(old, new) -#define link(path, hardlink) red_link(path, hardlink) -#define close(fd) red_close(fd) -#define read(fd, buf, len) red_read(fd, buf, len) -#define write(fd, buf, len) red_write(fd, buf, len) -#define fsync(fd) red_fsync(fd) -#define fdatasync(fd) fsync(fd) -#define lseek(fd, offset, whence) red_lseek(fd, offset, whence) -#define lseek64(fd, offset, whence) lseek(fd, offset, whence) -#define ftruncate(fd, size) red_ftruncate(fd, size) -#define fstat(fd, stat) red_fstat(fd, stat) -#define fstat64(fd, stat) fstat(fd, stat) -#define opendir(path) red_opendir(path) -#define readdir(dirp) red_readdir(dirp) -#define readdir64(dirp) readdir(dirp) -#define rewinddir(dirp) red_rewinddir(dirp) -#define closedir(dirp) red_closedir(dirp) - -#undef DIR -#define DIR REDDIR - -#undef errno -#define errno (*(int *)red_errnoptr()) - -#undef memcpy -#undef memmove -#undef memset -#undef strlen -#undef strncmp -#undef strcmp -#undef strncpy -#define memcpy(d, s, l) RedMemCpy(d, s, (uint32_t)(l)) -#define memmove(d, s, l) RedMemMove(d, s, (uint32_t)(l)) -#define memset(d, c, l) RedMemSet(d, (uint8_t)(c), (uint32_t)(l)) -#define strlen(s) RedStrLen(s) -#define strncmp(s1, s2, l) RedStrNCmp(s1, s2, (uint32_t)(l)) -#define strcmp(s1, s2) RedStrCmp(s1, s2) -#define strncpy(d, s, l) RedStrNCpy(d, s, (uint32_t)(l)) - - -#endif - - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/tests/util/atoi.c b/FreeRTOS-Plus/Source/Reliance-Edge/tests/util/atoi.c deleted file mode 100755 index ec11e0a..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/tests/util/atoi.c +++ /dev/null @@ -1,478 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements utilities that convert strings to numbers. -*/ -#include -#include - - -#define ISHEXDIGITU(c) (((c) >= 'A') && ((c) <= 'F')) -#define ISHEXDIGITL(c) (((c) >= 'a') && ((c) <= 'f')) -#define ISHEXDIGIT(c) (ISHEXDIGITL(c) || ISHEXDIGITU(c)) - - -/** @brief Converts an ASCII number into an int32_t. - - Converts all decimal digit numbers up to the end of the string or to the - first non-numerical character. - - @note This function does *not* ignore leading white space. - - @param pszNum Pointer to a constant array of characters. - - @return The integer represented in the string. -*/ -int32_t RedAtoI( - const char *pszNum) -{ - int32_t lValue = 0; - int32_t lNegative = 1; - uint32_t ulIdx = 0U; - - if(pszNum[ulIdx] == '+') - { - ulIdx++; - } - else if(pszNum[ulIdx] == '-') - { - ulIdx++; - lNegative = -1; - } - else - { - /* No sign, implicitly positive. - */ - } - - while(ISDIGIT(pszNum[ulIdx])) - { - lValue *= 10; - lValue += pszNum[ulIdx] - '0'; - ulIdx++; - } - - lValue *= lNegative; - - return lValue; -} - - -/** @brief Convert a hexadecimal ASCII number into a uint32_t value. - - The function processes all hex digits up to a NUL-terminator, or to the - first non-hex character. Only hexadecimal digits are processed, so leading - white space, or a leading "0x" prefix are not allowed. - - If pachNum points to an empty string (points to a NUL), this function will - return NULL, and the value at *pulNum will not be modified. - - @note This function does not check for overflow. If there are more - significant digits than can be represented in a uint32_t variable, the - output is unspecified. - - @param pszNum A pointer to a constant array of hex characters. - @param pulNum A pointer to the location in which to store the uint32_t - result. Upon return, this value will be modified ONLY if - the function succeeds and the returned pointer is valid (not - NULL). - - @return A pointer to the byte following the converted number or NULL to - indicate failure. -*/ -const char *RedHtoUL( - const char *pszNum, - uint32_t *pulNum) -{ - uint64_t ullValue; - const char *pszReturn; - - pszReturn = RedHtoULL(pszNum, &ullValue); - if(pszReturn != NULL) - { - if(ullValue < UINT32_MAX) - { - *pulNum = (uint32_t)ullValue; - } - else - { - pszReturn = NULL; - } - } - - return pszReturn; -} - - -/** @brief Convert a hexadecimal ASCII number into a D_UINT64 value. - - The function processes all hex digits up to a NUL-terminator, or to the - first non-hex character. Only hexadecimal digits are processed, so leading - white space, or a leading "0x" prefix are not allowed. - - If pachNum points to an empty string (points to a NUL), this function will - return NULL, and the value at *pulNum will not be modified. - - @note This function does not check for overflow. If there are more - significant digits than can be represented in a uint64_t variable, the - output is unspecified. - - @param pszNum A pointer to a constant array of hex characters. - @param pullNum A pointer to the location in which to store the uint64_t - result. Upon return, this value will be modified ONLY if - the function succeeds and the returned pointer is valid (not - NULL). - - @return A pointer to the byte following the converted number, or NULL to - indicate failure. -*/ -const char *RedHtoULL( - const char *pszNum, - uint64_t *pullNum) -{ - uint64_t ullValue = 0U; - const char *pszReturn = NULL; - uint32_t ulIdx = 0U; - - REDASSERT(pszNum != NULL); - REDASSERT(pullNum != NULL); - - while(pszNum[ulIdx] != '\0') - { - char cDigit = pszNum[ulIdx]; - - if(ISDIGIT(cDigit)) - { - cDigit -= '0'; - } - else if(ISHEXDIGITU(cDigit)) - { - cDigit -= ('A' - 10); - } - else if(ISHEXDIGITL(cDigit)) - { - cDigit -= ('a' - 10); - } - else - { - break; - } - - REDASSERT((ullValue & UINT64_SUFFIX(0xF000000000000000)) == 0U); - - ullValue <<= 4U; - ullValue += cDigit; - - ulIdx++; - pszReturn = &pszNum[ulIdx]; - } - - /* Modify the number returned only if we found one or more valid hex - digits. - */ - if(pszReturn != NULL) - { - *pullNum = ullValue; - } - - return pszReturn; -} - - -/** @brief Convert the ASCII number to a uint32_t value. - - The number may be hex or decimal. Hex numbers must be prefixed by '0x', and - they may be upper or lower case. The conversion process will stop with the - first non hex or decimal digit. - - If the number is negative (the first character is a '-' sign), the value - will be range checked and returned as the equivalent unsigned value. - - @note This function will NOT fail for numbers which exceed the size of a - uint32_t value. - - @param pszNum A pointer to the ASCII number to convert - @param pulNum A pointer to the uint32_t location to store the result. - This value will be modified on return only if the function - succeeds and the returned pointer is valid (not NULL). - - @return A pointer to the byte following the converted number, or NULL to - indicate failure. -*/ -const char *RedNtoUL( - const char *pszNum, - uint32_t *pulNum) -{ - bool fNegative = false; - uint32_t ulIdx = 0U; - const char *pszReturn; - - REDASSERT(pszNum != NULL); - REDASSERT(pulNum != NULL); - - if(pszNum[ulIdx] == '-') - { - fNegative = true; - ulIdx++; - } - - /* Hex numbers must be prefixed with '0x'. - */ - if((pszNum[ulIdx] == '0') && ((pszNum[ulIdx + 1U] == 'x') || (pszNum[ulIdx + 1U] == 'X'))) - { - ulIdx += 2U; - - if(ISDIGIT(pszNum[ulIdx]) || ISHEXDIGIT(pszNum[ulIdx])) - { - pszReturn = RedHtoUL(&pszNum[ulIdx], pulNum); - } - else - { - pszReturn = NULL; - } - } - else if(ISDIGIT(pszNum[ulIdx])) - { - uint32_t ulTemp; - - ulTemp = RedAtoI(&pszNum[ulIdx]); - - while(ISDIGIT(pszNum[ulIdx])) - { - ulIdx++; - } - - if(fNegative) - { - /* Fail if the number is out of range. - */ - if(ulTemp > INT32_MAX) - { - pszReturn = NULL; - } - else - { - *pulNum = -((int32_t)ulTemp); - pszReturn = &pszNum[ulIdx]; - } - } - else - { - *pulNum = ulTemp; - pszReturn = &pszNum[ulIdx]; - } - } - else - { - /* Return an error if there is not at least one hex or decimal digit. - */ - pszReturn = NULL; - } - - return pszReturn; -} - - -/** @brief Convert the ASCII number pointed to by pachNum to a uint64_t value. - - The number may be hex or decimal. Hex numbers must be prefixed by '0x', and - they may be upper or lower case. The conversion process will stop with the - first non hex or decimal digit. - - If the number is negative (the first character is a '-' sign), the value - will be range checked and returned as the equivalent unsigned value. - - @param pszNum A pointer to the ASCII number to convert. - @param pullNum A pointer to the uint64_t location to store the result. - This value will be modified on return only if the function - succeeds and the returned pointer is valid (not NULL). - - @return A pointer to the byte following the converted number, or NULL to - indicate failure. -*/ -const char *RedNtoULL( - const char *pszNum, - uint64_t *pullNum) -{ - bool fNegative = false; - uint32_t ulIdx = 0U; - const char *pszReturn; - - REDASSERT(pszNum != NULL); - REDASSERT(pullNum != NULL); - - if(pszNum[ulIdx] == '-') - { - fNegative = true; - ulIdx++; - } - - /* Hex numbers must be prefixed with '0x'. - */ - if((pszNum[ulIdx] == '0') && ((pszNum[ulIdx + 1U] == 'x') || (pszNum[ulIdx + 1U] == 'X'))) - { - ulIdx += 2U; - - if(ISDIGIT(pszNum[ulIdx]) || ISHEXDIGIT(pszNum[ulIdx])) - { - pszReturn = RedHtoULL(&pszNum[ulIdx], pullNum); - } - else - { - pszReturn = NULL; - } - } - else if(ISDIGIT(pszNum[ulIdx])) - { - uint64_t ullTemp = 0U; - - while(ISDIGIT(pszNum[ulIdx])) - { - ullTemp *= 10U; - ullTemp += pszNum[ulIdx] - '0'; - ulIdx++; - } - - if(fNegative) - { - /* Fail if the number is out of range. - */ - if(ullTemp > INT64_MAX) - { - pszReturn = NULL; - } - else - { - *pullNum = (uint64_t)(-((int64_t)ullTemp)); - pszReturn = &pszNum[ulIdx]; - } - } - else - { - *pullNum = ullTemp; - pszReturn = &pszNum[ulIdx]; - } - } - else - { - /* Return an error if there is not at least one hex or decimal digit. - */ - pszReturn = NULL; - } - - return pszReturn; -} - - -/** @brief Convert an ASCII hex or decimal number, which may may have a "B", - "KB", or "MB" suffix (case insensitive), to a binary value. - - Hex numbers must be prefixed with "0x". - - @note If there is no postfix, KB is assumed! - - May fail due to bad formatting or overflow. - - @param pszNum A pointer to the ASCII number to convert. - @param pulResult A pointer to a uint32_t in which to place the result. - - @return A pointer to the byte following the string, or NULL to indicate an - error. In the event of an error, *pulResult will not be modified. -*/ -const char *RedSizeToUL( - const char *pszNum, - uint32_t *pulResult) -{ - uint32_t ulResult; - const char *pszSuffix; - const char *pszReturn; - uint32_t ulIdx = 0U; - - REDASSERT(pszNum != NULL); - REDASSERT(pulResult != NULL); - - /* Do the basic hex/decimal conversion - */ - pszSuffix = RedNtoUL(pszNum, &ulResult); - if(pszSuffix != NULL) - { - if((pszSuffix[ulIdx] == 'B') || (pszSuffix[ulIdx] == 'b')) - { - ulIdx++; - pszReturn = &pszSuffix[ulIdx]; - } - else if( ((pszSuffix[ulIdx] == 'M') || (pszSuffix[ulIdx] == 'm')) - && ((pszSuffix[ulIdx + 1U] == 'B') || (pszSuffix[ulIdx + 1U] == 'b'))) - { - ulIdx += 2U; - - if(ulResult > (UINT32_MAX / (1024U * 1024U))) - { - pszReturn = NULL; - } - else - { - ulResult *= 1024U * 1024U; - pszReturn = &pszSuffix[ulIdx]; - } - } - else - { - /* The number is either postfixed with "KB" or something - else (we don't care), but we must increment the pointer - if it is something recognize. - */ - if( ((pszSuffix[ulIdx] == 'K') || (pszSuffix[ulIdx] == 'k')) - && ((pszSuffix[ulIdx + 1U] == 'B') || (pszSuffix[ulIdx + 1U] == 'b'))) - { - ulIdx += 2U; - } - - /* "B" or "MB" were not specified, so it must be "KB" - */ - if(ulResult > (UINT32_MAX / 1024U)) - { - pszReturn = NULL; - } - else - { - ulResult *= 1024UL; - pszReturn = &pszSuffix[ulIdx]; - } - } - - if(pszReturn != NULL) - { - *pulResult = ulResult; - } - } - else - { - pszReturn = NULL; - } - - return pszReturn; -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/tests/util/math.c b/FreeRTOS-Plus/Source/Reliance-Edge/tests/util/math.c deleted file mode 100755 index 00f6bc3..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/tests/util/math.c +++ /dev/null @@ -1,641 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements routines for certain 64-bit math operations and simulated - floating point. - - RedUint64DivMod32() and RedUint64DivMod64() are derived from code at - http://www.hackersdelight.org. This web site states explicitly that "You - are free to use, copy, and distribute any of the code on this web site, - whether modified by you or not. You need not give attribution." -*/ -#include -#include - - -static uint32_t nlz64(uint64_t ullValue); - - -/** @brief Return a ratio value formatted as a floating point string accurate to - the specified number of decimal places. - - The function exists to provide floating point style output without using - any actual floating point types. - - This function may scale the numbers down to avoid overflow at the high end. - Likewise, potential divide-by-zero errors are internally avoided. Here are - some examples: - - Dividend | Divisor | DecPlaces | Result - -------- | ------- | --------- | ------ - 12133 | 28545 | 2 | "0.42" - 1539 | 506 | 2 | "3.04" - - To get a number formatted as a percentage, take the take the portion of the - total (normally the smaller part), multiply it by 100, and pass it to this - function as the Dividend, pass the "total" value to this function as the - Divisor, and specify the desired number of decimal places. - - For example, if you have a disk format overhead value of N blocks out of a - total of Y blocks on the disk, and you want to display the format overhead - as a percentage, you would use a function call - similar to: - - ~~~{.c} - RedRatio(szBuffer, sizeof(szBuffer), N*100U, Y, 2U); - ~~~ - - If N=145, Y=4096, and decimal places is 2, the resulting output would be - "3.54". - - The string returned will always be null-terminated, even if it means - stomping on the least significant decimal digit. - - If either the dividend or divisor values are zero, the string "0.0" will be - returned, with the prescribed number of decimal places. - - @note This function has "reasonable" limits which meet the needs of the - various supplemental utilities which use this function. Extremely - large ratios, or using many decimal places may not function as - desired. - - Parameters: - @param pBuffer A pointer to the buffer in which to store the null - terminated results. - @param ulBufferLen The length of the output buffer. - @param ullDividend The "total" value to divide. - @param ullDivisor The portion of ullDividend for which to calculate the - ratio (may be greater than ulDividend). - @param ulDecPlaces The number of decimal places to use, from 0 to 9. - - @return @p pBuffer. -*/ -char *RedRatio( - char *pBuffer, - uint32_t ulBufferLen, - uint64_t ullDividend, - uint64_t ullDivisor, - uint32_t ulDecPlaces) -{ - REDASSERT(pBuffer != NULL); - REDASSERT(ulBufferLen > 0U); - REDASSERT(ulDecPlaces <= 9U); /* arbitrary */ - - if((ullDivisor > 0U) && (ullDividend > 0U)) - { - uint32_t ii; - uint32_t ulFactor = 1U; - uint64_t ullDecimal; - uint64_t ullTemp; - - for(ii = 1U; ii <= ulDecPlaces; ii++) - { - ulFactor *= 10U; - } - - ullDecimal = RedMulDiv64(ullDividend, ulFactor, ullDivisor); - - /* Shouldn't really be calling this function in a situation where we - can overflow at this point... - */ - REDASSERT(ullDecimal != UINT64_MAX); - - if(ullDivisor <= ullDividend) - { - uint32_t ulDecimal; - - (void)RedUint64DivMod32(ullDecimal, ulFactor, &ulDecimal); - ullDecimal = ulDecimal; - } - - ullTemp = RedUint64DivMod64(ullDividend, ullDivisor, NULL); - - if(ulDecPlaces > 0U) - { - RedSNPrintf(pBuffer, ulBufferLen, "%llu.%0*llu", (unsigned long long)ullTemp, - (unsigned)ulDecPlaces, (unsigned long long)ullDecimal); - } - else - { - RedSNPrintf(pBuffer, ulBufferLen, "%llu", (unsigned long long)ullTemp); - } - } - else - { - /* If either the dividend or divisor is zero, then just output a "0.0" - string with the prescribed number of decimal places. - */ - if(ulDecPlaces > 0U) - { - RedSNPrintf(pBuffer, ulBufferLen, "0.%0*u", (unsigned)ulDecPlaces, 0U); - } - else - { - RedStrNCpy(pBuffer, "0", ulBufferLen); - } - } - - /* Ensure the returned buffer is always null-terminated - */ - pBuffer[ulBufferLen - 1U] = '\0'; - - return pBuffer; -} - - -/** @brief Multiply 64-bit and 32-bit numbers, and divide by a 64-bit number, - returning a 64-bit result. - - @note This function may return an approximate value if multiplying - @p ullBase and @p ulMultplier results in a number larger than 64-bits - _and_ this cannot be avoided by scaling. - - @param ullBase The base 64-bit number number. - @param ulMultiplier The 32-bit number by which to multiply. - @param ullDivisor The 64-bit number by which to divide. - - @return The 64-bit unsigned integer result. Always returns zero if either - @p ullBase or @p ulMultiplier are zero (regardless what - @p ullDivisor is). Returns UINT64_MAX if an overflow condition - occurred, or if @p ullDivisor is zero. -*/ -uint64_t RedMulDiv64( - uint64_t ullBase, - uint32_t ulMultiplier, - uint64_t ullDivisor) -{ - uint64_t ullTemp; - - /* Result would always be zero if either of these are zero. Specifically - test this case before looking for a zero divisor. - */ - if((ullBase == 0U) || (ulMultiplier == 0U)) - { - return 0U; - } - - if(ullDivisor == 0U) - { - return UINT64_MAX; - } - - /* Since we don't have the ability (yet) to use 128-bit numbers, we jump - through the following hoops (in order) to try to determine the proper - results without losing precision: - - 1) Shift the divisor and one of the multiplicands as many times as is - necessary to reduce the scale -- only if it can be done without - losing precision. - 2) Divide one of the multiplicands by the divisor first, but only if it - divides evenly, preserving precision. - 3) Same as #2, but try it for the other multiplicand. - 4) Last ditch, divide the larger multiplicand by the divisor first, then - do the multiply. This lose precision. - - These solutions are identified as CODE-PATHs #1-4 which are used to - identify the matching tests in dltmain.c. - - Note that execution might partially include CODE-PATH #1 up until - shifting can no longer be done without losing precision. In that case, - one of the three remaining options will be used. - */ - - ullTemp = RedUint64DivMod32(UINT64_MAX, ulMultiplier, NULL); - while(ullBase > ullTemp) - { - uint64_t ullMod; - uint64_t ullBaseTemp; - uint64_t ullWideMultiplier; - - /* CODE-PATH #1 - */ - /* So long as ulDivisor, and at least one of the other numbers, are - evenly divisible by 2, we can scale the numbers so the result does - not overflow the intermediate 64-bit value. - */ - if((ullDivisor & 1U) == 0U) - { - if((ullBase & 1U) == 0U) - { - /* CODE-PATH #1a - */ - ullDivisor >>= 1U; - ullBase >>= 1U; - continue; - } - - if(((ulMultiplier & 1U) == 0U) && ((ullTemp & UINT64_SUFFIX(0x8000000000000000)) == 0U)) - { - /* CODE-PATH #1b - */ - ullDivisor >>= 1U; - ulMultiplier >>= 1U; - ullTemp <<= 1U; - continue; - } - } - - /* If we get to this point, the above method (#1) cannot be used - because not enough of the numbers are even long enough to scale the - operands down. We'll see if either multiplicand is evenly divisble - by ulDivisor, and if so, do the divide first, then the multiply. - (Note that once we get to this point, we will never exercise the - while{} loop anymore.) - */ - - /* CODE-PATH #2 - */ - ullBaseTemp = RedUint64DivMod64(ullBase, ullDivisor, &ullMod); - if(ullMod == 0U) - { - /* Evenly divides, so check that we won't overflow, and finish up. - */ - ullBase = ullBaseTemp; - if(ullBase > ullTemp) - { - return UINT64_MAX; - } - else - { - /* We've validated that this will not overflow. - */ - ullBase *= ulMultiplier; - return ullBase; - } - } - - /* CODE-PATH #3 - */ - ullWideMultiplier = RedUint64DivMod64(ulMultiplier, ullDivisor, &ullMod); - if(ullMod == 0U) - { - /* Evenly divides, so check that we won't overflow, and finish up. - */ - - /* Must recalculate ullTemp relative to ullBase - */ - ullTemp = RedUint64DivMod64(UINT64_MAX, ullBase, NULL); - if(ullWideMultiplier > ullTemp) - { - return UINT64_MAX; - } - else - { - uint32_t ulNarrowMultiplier = (uint32_t)ullWideMultiplier; - - /* We've validated that this will not overflow. - */ - ullBase *= ulNarrowMultiplier; - return ullBase; - } - } - - /* CODE-PATH #4 - - Neither of the multipliers is evenly divisible by the divisor, so - just punt and divide the larger number first, then do the final - multiply. - - All the other attempts above would preserve precision -- this is the - only case where precision may be lost. - */ - - /* If necessary reverse the ullBase and ulMultiplier operands so that - ullBase contains the larger of the two values. - */ - if(ullBase < ulMultiplier) - { - uint32_t ulTemp = ulMultiplier; - - ulMultiplier = (uint32_t)ullBase; - ullBase = ulTemp; - } - - ullBase = RedUint64DivMod64(ullBase, ullDivisor, NULL); - ullTemp = RedUint64DivMod32(UINT64_MAX, ulMultiplier, NULL); - if(ullBase > ullTemp) - { - return UINT64_MAX; - } - else - { - ullBase *= ulMultiplier; - return ullBase; - } - } - - /* We only get to this point if either there was never any chance of - overflow, or if the pure shifting mechanism succeeded in reducing - the scale so overflow is not a problem. - */ - - ullBase *= ulMultiplier; - ullBase = RedUint64DivMod64(ullBase, ullDivisor, NULL); - - return ullBase; -} - - -/** @brief Divide a 64-bit value by a 32-bit value, returning the quotient and - the remainder. - - Essentially this function does the following: - - ~~~{.c} - if(pulRemainder != NULL) - { - *pulRemainder = (uint32_t)(ullDividend % ulDivisor); - } - return ullDividend / ulDivisor; - ~~~ - - However, it does so without ever actually dividing/modulating a 64-bit - value, since such operations are not allowed in all environments. - - @param ullDividend The value to divide. - @param ulDivisor The value to divide by. - @param pulRemainder Populated with the remainder; may be NULL. - - @return The quotient (result of the division). -*/ -uint64_t RedUint64DivMod32( - uint64_t ullDividend, - uint32_t ulDivisor, - uint32_t *pulRemainder) -{ - uint64_t ullQuotient; - uint32_t ulResultRemainder; - - /* Check for divide by zero. - */ - if(ulDivisor == 0U) - { - REDERROR(); - - /* Nonsense value if no asserts. - */ - ullQuotient = UINT64_SUFFIX(0xFFFFFFFFFFFFFBAD); - ulResultRemainder = 0xFFFFFBADU; - } - else if(ullDividend <= UINT32_MAX) - { - uint32_t ulDividend = (uint32_t)ullDividend; - - ullQuotient = ulDividend / ulDivisor; - ulResultRemainder = ulDividend % ulDivisor; - } - else - { - uint32_t ulResultHi; - uint32_t ulResultLo; - uint32_t ulRemainder; - uint8_t bIndex; - uint32_t ulThisDivision; - uint32_t ulMask; - uint8_t ucNextValue; - uint32_t ulInterimHi, ulInterimLo; - uint32_t ulLowDword = (uint32_t)ullDividend; - uint32_t ulHighDword = (uint32_t)(ullDividend >> 32U); - - /* Compute the high part and get the remainder - */ - ulResultHi = ulHighDword / ulDivisor; - ulResultLo = 0U; - ulRemainder = ulHighDword % ulDivisor; - - /* Compute the low part - */ - ulMask = 0xFF000000U; - for(bIndex = 0U; bIndex < sizeof(uint32_t); bIndex++) - { - ucNextValue = (uint8_t)((ulLowDword & ulMask) >> ((sizeof(uint32_t) - 1U - bIndex) * 8U)); - ulInterimHi = ulRemainder >> 24U; - ulInterimLo = (ulRemainder << 8U) | ucNextValue; - ulThisDivision = 0U; - while(ulInterimHi != 0U) - { - uint64_t ullInterim = ((uint64_t)ulInterimHi << 32U) + ulInterimLo; - - ullInterim -= ulDivisor; - ulThisDivision++; - - ulInterimHi = (uint32_t)(ullInterim >> 32U); - ulInterimLo = (uint32_t)ullInterim; - } - ulThisDivision += ulInterimLo / ulDivisor; - ulRemainder = ulInterimLo % ulDivisor; - ulResultLo <<= 8U; - ulResultLo += ulThisDivision; - ulMask >>= 8U; - } - - ullQuotient = ((uint64_t)ulResultHi << 32U) + ulResultLo; - ulResultRemainder = (uint32_t)(ullDividend - (ullQuotient * ulDivisor)); - } - - if(pulRemainder != NULL) - { - *pulRemainder = ulResultRemainder; - } - - return ullQuotient; -} - - -/** @brief Divide a 64-bit value by a 64-bit value, returning the quotient and - the remainder. - - Essentially this function does the following: - - ~~~{.c} - if(pullRemainder != NULL) - { - *pullRemainder = ullDividend % ullDivisor; - } - return ullDividend / ullDivisor; - ~~~ - - However, it does so without ever actually dividing/modulating a 64-bit - value, since such operations are not allowed in all environments. - - @param ullDividend The value to divide. - @param ullDivisor The value to divide by. - @param pullRemainder Populated with the remainder; may be NULL. - - @return The quotient (result of the division). -*/ -uint64_t RedUint64DivMod64( - uint64_t ullDividend, - uint64_t ullDivisor, - uint64_t *pullRemainder) -{ - /* The variables u0, u1, etc. take on only 32-bit values, but they are - declared uint64_t to avoid some compiler warning messages and to avoid - some unnecessary EXTRs that the compiler would put in, to convert - uint64_ts to ints. - */ - uint64_t u0; - uint64_t u1; - uint64_t q0; - uint64_t q1; - uint64_t ullQuotient; - - /* First the procedure takes care of the case in which the divisor is a - 32-bit quantity. There are two subcases: (1) If the left half of the - dividend is less than the divisor, one execution of RedUint64DivMod32() - is all that is required (overflow is not possible). (2) Otherwise it - does two divisions, using the grade school method. - */ - - if((ullDivisor >> 32U) == 0U) - { - if((ullDividend >> 32U) < ullDivisor) - { - /* If ullDividend/ullDivisor cannot overflow, just do one division. - */ - ullQuotient = RedUint64DivMod32(ullDividend, (uint32_t)ullDivisor, NULL); - } - else - { - uint32_t k; - - /* If ullDividend/ullDivisor would overflow: - */ - - /* Break ullDividend up into two halves. - */ - u1 = ullDividend >> 32U; - u0 = ullDividend & 0xFFFFFFFFU; - - /* First quotient digit and first remainder. - */ - q1 = RedUint64DivMod32(u1, (uint32_t)ullDivisor, &k); - - /* 2nd quot. digit. - */ - q0 = RedUint64DivMod32(((uint64_t)k << 32U) + u0, (uint32_t)ullDivisor, NULL); - - ullQuotient = (q1 << 32U) + q0; - } - } - else - { - uint64_t n; - uint64_t v1; - - n = nlz64(ullDivisor); /* 0 <= n <= 31. */ - v1 = (ullDivisor << n) >> 32U; /* Normalize the divisor so its MSB is 1. */ - u1 = ullDividend >> 1U; /* To ensure no overflow. */ - - /* Get quotient from divide unsigned insn. - */ - q1 = RedUint64DivMod32(u1, (uint32_t)v1, NULL); - - q0 = (q1 << n) >> 31U; /* Undo normalization and division of ullDividend by 2. */ - - /* Make q0 correct or too small by 1. - */ - if(q0 != 0U) - { - q0--; - } - - if((ullDividend - (q0 * ullDivisor)) >= ullDivisor) - { - q0++; /* Now q0 is correct. */ - } - - ullQuotient = q0; - } - - if(pullRemainder != NULL) - { - *pullRemainder = ullDividend - (ullQuotient * ullDivisor); - } - - return ullQuotient; -} - - -/** @brief Compute the number of leading zeroes in a 64-bit value. - - @param ullValue The value for which to compute the NLZ. - - @return The number of leading zeroes in @p ullValue. -*/ -static uint32_t nlz64( - uint64_t ullValue) -{ - uint32_t n; - - if(ullValue == 0U) - { - n = 64U; - } - else - { - uint64_t x = ullValue; - - n = 0U; - - if(x <= UINT64_SUFFIX(0x00000000FFFFFFFF)) - { - n += 32U; - x <<= 32U; - } - - if(x <= UINT64_SUFFIX(0x0000FFFFFFFFFFFF)) - { - n += 16U; - x <<= 16U; - } - - if(x <= UINT64_SUFFIX(0x00FFFFFFFFFFFFFF)) - { - n += 8U; - x <<= 8U; - } - - if(x <= UINT64_SUFFIX(0x0FFFFFFFFFFFFFFF)) - { - n += 4U; - x <<= 4U; - } - - if(x <= UINT64_SUFFIX(0x3FFFFFFFFFFFFFFF)) - { - n += 2U; - x <<= 2U; - } - - if(x <= UINT64_SUFFIX(0x7FFFFFFFFFFFFFFF)) - { - n += 1; - } - } - - return n; -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/tests/util/printf.c b/FreeRTOS-Plus/Source/Reliance-Edge/tests/util/printf.c deleted file mode 100755 index 6df0cf4..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/tests/util/printf.c +++ /dev/null @@ -1,1265 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements functions for printing. - - These functions are intended to be used in portable test code, which cannot - assume the standard I/O functions will be available. Similar to their ANSI - C counterparts, these functions allow formatting text strings and (if the - configuration allows it) outputing formatted text. The latter ability - relies on the RedOsOutputString() OS service function. - - Do *not* use these functions in code which can safely assume the standard - I/O functions are available (e.g., in host tools code). - - Do *not* use these functions from within the file system driver. These - functions use variable arguments and thus are not MISRA-C:2012 compliant. -*/ -#include -#include -#include -#include - - -/** @brief Maximum number of bytes of output supported by RedPrintf(). - - Typically only Datalight code uses these functions, and that could should be - written to respect this limit, so it should not normally be necessary to - adjust this value. -*/ -#define OUTPUT_BUFFER_SIZE 256U - - -typedef enum -{ - PRFMT_UNKNOWN = 0, - PRFMT_CHAR, - PRFMT_ANSISTRING, - PRFMT_SIGNED8BIT, - PRFMT_UNSIGNED8BIT, - PRFMT_SIGNED16BIT, - PRFMT_UNSIGNED16BIT, - PRFMT_SIGNED32BIT, - PRFMT_UNSIGNED32BIT, - PRFMT_SIGNED64BIT, - PRFMT_UNSIGNED64BIT, - PRFMT_HEX8BIT, - PRFMT_HEX16BIT, - PRFMT_HEX32BIT, - PRFMT_HEX64BIT, - PRFMT_POINTER, - PRFMT_DOUBLEPERCENT -} PRINTTYPE; - -typedef struct -{ - PRINTTYPE type; /* The PRFMT_* type found */ - uint32_t ulSpecifierIdx; /* Returns a pointer to the % sign */ - uint32_t ulFillLen; - char cFillChar; - bool fLeftJustified; - bool fHasIllegalType; /* TRUE if an illegal sequence was skipped over */ - bool fHasVarWidth; -} PRINTFORMAT; - - -/* Our output handlers are written for standard fixed width data types. Map - the standard ANSI C data types onto our handlers. Currently this code has - the following requirements: - - 1) shorts must be either 16 or 32 bits - 2) ints must be either 16 or 32 bits - 3) longs must be between 32 or 64 bits - 4) long longs must be 64 bits -*/ -#if (USHRT_MAX == 0xFFFFU) - #define MAPSHORT PRFMT_SIGNED16BIT - #define MAPUSHORT PRFMT_UNSIGNED16BIT - #define MAPHEXUSHORT PRFMT_HEX16BIT -#elif (USHRT_MAX == 0xFFFFFFFFU) - #define MAPSHORT PRFMT_SIGNED32BIT - #define MAPUSHORT PRFMT_UNSIGNED32BIT - #define MAPHEXUSHORT PRFMT_HEX32BIT -#else - #error "The 'short' data type does not have a 16 or 32-bit width" -#endif - -#if (UINT_MAX == 0xFFFFU) - #define MAPINT PRFMT_SIGNED16BIT - #define MAPUINT PRFMT_UNSIGNED16BIT - #define MAPHEXUINT PRFMT_HEX16BIT -#elif (UINT_MAX == 0xFFFFFFFFU) - #define MAPINT PRFMT_SIGNED32BIT - #define MAPUINT PRFMT_UNSIGNED32BIT - #define MAPHEXUINT PRFMT_HEX32BIT -#else - #error "The 'int' data type does not have a 16 or 32-bit width" -#endif - -#if (ULONG_MAX == 0xFFFFFFFFU) - #define MAPLONG PRFMT_SIGNED32BIT - #define MAPULONG PRFMT_UNSIGNED32BIT - #define MAPHEXULONG PRFMT_HEX32BIT -#elif (ULONG_MAX <= UINT64_SUFFIX(0xFFFFFFFFFFFFFFFF)) - /* We've run into unusual environments where "longs" are 40-bits wide. - In this event, map them to 64-bit types so no data is lost. - */ - #define MAPLONG PRFMT_SIGNED64BIT - #define MAPULONG PRFMT_UNSIGNED64BIT - #define MAPHEXULONG PRFMT_HEX64BIT -#else - #error "The 'long' data type is not between 32 and 64 bits wide" -#endif - -#if defined(ULLONG_MAX) && (ULLONG_MAX != UINT64_SUFFIX(0xFFFFFFFFFFFFFFFF)) - #error "The 'long long' data type is not 64 bits wide" -#else - #define MAPLONGLONG PRFMT_SIGNED64BIT - #define MAPULONGLONG PRFMT_UNSIGNED64BIT - #define MAPHEXULONGLONG PRFMT_HEX64BIT -#endif - - -static uint32_t ProcessFormatSegment(char *pcBuffer, uint32_t ulBufferLen, const char *pszFormat, PRINTFORMAT *pFormat, uint32_t *pulSpecifierLen); -static uint32_t ParseFormatSpecifier(char const *pszFormat, PRINTFORMAT *pFormatType); -static PRINTTYPE ParseFormatType(const char *pszFormat, uint32_t *pulTypeLen); -static uint32_t LtoA(char *pcBuffer, uint32_t ulBufferLen, int32_t lNum, uint32_t ulFillLen, char cFill); -static uint32_t LLtoA(char *pcBuffer, uint32_t ulBufferLen, int64_t llNum, uint32_t ulFillLen, char cFill); -static uint32_t ULtoA(char *pcBuffer, uint32_t ulBufferLen, uint32_t ulNum, bool fHex, uint32_t ulFillLen, char cFill); -static uint32_t ULLtoA(char *pcBuffer, uint32_t ulBufferLen, uint64_t ullNum, bool fHex, uint32_t ulFillLen, char cFill); -static uint32_t FinishToA(const char *pcDigits, uint32_t ulDigits, char *pcOutBuffer, uint32_t ulBufferLen, uint32_t ulFillLen, char cFill); - - -/* Digits for the *LtoA() routines. -*/ -static const char gacDigits[] = "0123456789ABCDEF"; - - -#if REDCONF_OUTPUT == 1 -/** @brief Print formatted data with a variable length argument list. - - This function provides a subset of the ANSI C printf() functionality with - several extensions to support fixed size data types. - - See RedVSNPrintf() for the list of supported types. - - @param pszFormat A pointer to the null-terminated format string. - @param ... The variable length argument list. -*/ -void RedPrintf( - const char *pszFormat, - ...) -{ - va_list arglist; - - va_start(arglist, pszFormat); - - RedVPrintf(pszFormat, arglist); - - va_end(arglist); -} - - -/** @brief Print formatted data using a pointer to a variable length argument - list. - - This function provides a subset of the ANSI C vprintf() functionality. - - See RedVSNPrintf() for the list of supported types. - - This function accommodates a maximum output length of #OUTPUT_BUFFER_SIZE. - If this function must truncate the output, and the original string was - \n terminated, the truncated output will be \n terminated as well. - - @param pszFormat A pointer to the null-terminated format string. - @param arglist The variable length argument list. -*/ -void RedVPrintf( - const char *pszFormat, - va_list arglist) -{ - char achBuffer[OUTPUT_BUFFER_SIZE]; - - if(RedVSNPrintf(achBuffer, sizeof(achBuffer), pszFormat, arglist) == -1) - { - /* Ensture the buffer is null terminated. - */ - achBuffer[sizeof(achBuffer) - 1U] = '\0'; - - /* If the original string was \n terminated and the new one is not, due to - truncation, stuff a \n into the new one. - */ - if(pszFormat[RedStrLen(pszFormat) - 1U] == '\n') - { - achBuffer[sizeof(achBuffer) - 2U] = '\n'; - } - } - - RedOsOutputString(achBuffer); -} -#endif /* #if REDCONF_OUTPUT == 1 */ - - -/** @brief Format arguments into a string using a subset of the ANSI C - vsprintf() functionality. - - This function is modeled after the Microsoft _snprint() extension to the - ANSI C sprintf() function, and allows a buffer length to be specified so - that overflow is avoided. - - See RedVSNPrintf() for the list of supported types. - - @param pcBuffer A pointer to the output buffer - @param ulBufferLen The output buffer length - @param pszFormat A pointer to the null terminated format string - @param ... Variable argument list - - @return The length output, or -1 if the buffer filled up. If -1 is - returned, the output buffer may not be null-terminated. -*/ -int32_t RedSNPrintf( - char *pcBuffer, - uint32_t ulBufferLen, - const char *pszFormat, - ...) -{ - int32_t iLen; - va_list arglist; - - va_start(arglist, pszFormat); - - iLen = RedVSNPrintf(pcBuffer, ulBufferLen, pszFormat, arglist); - - va_end(arglist); - - return iLen; -} - - -/** @brief Format arguments into a string using a subset of the ANSI C - vsprintf() functionality. - - This function is modeled after the Microsoft _vsnprint() extension to the - ANSI C vsprintf() function, and requires a buffer length to be specified so - that overflow is avoided. - - The following ANSI C standard formatting codes are supported: - - | Code | Meaning | - | ---- | ---------------------------------- | - | %c | Format a character | - | %s | Format a null-terminated C string | - | %hd | Format a signed short | - | %hu | Format an unsigned short | - | %d | Format a signed integer | - | %u | Format an unsigned integer | - | %ld | Format a signed long | - | %lu | Format an unsigned long | - | %lld | Format a signed long long | - | %llu | Format an unsigned long long | - | %hx | Format a short in hex | - | %x | Format an integer in hex | - | %lx | Format a long in hex | - | %llx | Format a long long in hex | - | %p | Format a pointer (hex value) | - - @note All formatting codes are case-sensitive. - - Fill characters and field widths are supported per the ANSI standard, as is - left justification with the '-' character. - - The only supported fill characters are '0', ' ', and '_'. - - '*' is supported to specify variable length field widths. - - Hexidecimal numbers are always displayed in upper case. Formatting codes - which specifically request upper case (e.g., "%lX") are not supported. - - Unsupported behaviors: - - Precision is not supported. - - Floating point is not supported. - - Errata: - - There is a subtle difference in the return value for this function versus - the Microsoft implementation. In the Microsoft version, if the buffer - exactly fills up, but there is no room for a null-terminator, the return - value will be the length of the buffer. In this code, -1 will be returned - when this happens. - - When using left justified strings, the only supported fill character is a - space, regardless of what may be specified. It is not clear if this is - ANSI standard or just the way the Microsoft function works, but we emulate - the Microsoft behavior. - - @param pcBuffer A pointer to the output buffer. - @param ulBufferLen The output buffer length. - @param pszFormat A pointer to the null terminated ANSI format string. - @param arglist Variable argument list. - - @return The length output, or -1 if the buffer filled up. If -1 is - returned, the output buffer may not be null-terminated. -*/ -int32_t RedVSNPrintf( - char *pcBuffer, - uint32_t ulBufferLen, - const char *pszFormat, - va_list arglist) -{ - uint32_t ulBufIdx = 0U; - uint32_t ulFmtIdx = 0U; - int32_t iLen; - - while((pszFormat[ulFmtIdx] != '\0') && (ulBufIdx < ulBufferLen)) - { - PRINTFORMAT fmt; - uint32_t ulSpecifierLen; - uint32_t ulWidth; - - /* Process the next segment of the format string, outputting - any non-format specifiers, as output buffer space allows, - and return information about the next format specifier. - */ - ulWidth = ProcessFormatSegment(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, &pszFormat[ulFmtIdx], &fmt, &ulSpecifierLen); - if(ulWidth) - { - REDASSERT(ulWidth <= (ulBufferLen - ulBufIdx)); - - ulBufIdx += ulWidth; - } - - /* If no specifier was found, or if the output buffer is - full, we're done -- get out. - */ - if((ulSpecifierLen == 0U) || (ulBufIdx == ulBufferLen)) - { - break; - } - - /* Otherwise, the math should add up for these things... - */ - REDASSERT(&pszFormat[fmt.ulSpecifierIdx] == &pszFormat[ulWidth]); - - /* Point past the specifier, to the next piece of the format string. - */ - ulFmtIdx = ulFmtIdx + fmt.ulSpecifierIdx + ulSpecifierLen; - - if(fmt.fHasVarWidth) - { - int iFillLen = va_arg(arglist, int); - - if(iFillLen >= 0) - { - fmt.ulFillLen = (uint32_t)iFillLen; - } - else - { - /* Bogus fill length. Ignore. - */ - fmt.ulFillLen = 0U; - } - } - - switch(fmt.type) - { - case PRFMT_DOUBLEPERCENT: - { - /* Nothing to do. A single percent has already been output, - and we just finished skipping past the second percent. - */ - break; - } - - /*-----------------> Small int handling <------------------ - * - * Values smaller than "int" will be promoted to "int" by - * the compiler, so we must retrieve them using "int" when - * calling va_arg(). Once we've done that, we immediately - * put the value into the desired data type. - *---------------------------------------------------------*/ - - case PRFMT_CHAR: - { - pcBuffer[ulBufIdx] = (char)va_arg(arglist, int); - ulBufIdx++; - break; - } - case PRFMT_SIGNED8BIT: - { - int8_t num = (int8_t)va_arg(arglist, int); - - ulBufIdx += LtoA(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, num, fmt.ulFillLen, fmt.cFillChar); - break; - } - case PRFMT_UNSIGNED8BIT: - { - uint8_t bNum = (uint8_t)va_arg(arglist, unsigned); - - ulBufIdx += ULtoA(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, bNum, false, fmt.ulFillLen, fmt.cFillChar); - break; - } - case PRFMT_HEX8BIT: - { - uint8_t bNum = (uint8_t)va_arg(arglist, unsigned); - - ulBufIdx += ULtoA(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, bNum, true, fmt.ulFillLen, fmt.cFillChar); - break; - } - case PRFMT_SIGNED16BIT: - { - int16_t num = (int16_t)va_arg(arglist, int); - - ulBufIdx += LtoA(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, num, fmt.ulFillLen, fmt.cFillChar); - break; - } - case PRFMT_UNSIGNED16BIT: - { - uint16_t uNum = (uint16_t)va_arg(arglist, unsigned); - - ulBufIdx += ULtoA(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, uNum, false, fmt.ulFillLen, fmt.cFillChar); - break; - } - case PRFMT_HEX16BIT: - { - uint16_t uNum = (uint16_t)va_arg(arglist, unsigned); - - ulBufIdx += ULtoA(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, uNum, true, fmt.ulFillLen, fmt.cFillChar); - break; - } - case PRFMT_SIGNED32BIT: - { - int32_t lNum = va_arg(arglist, int32_t); - - ulBufIdx += LtoA(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, lNum, fmt.ulFillLen, fmt.cFillChar); - break; - } - case PRFMT_UNSIGNED32BIT: - { - uint32_t ulNum = va_arg(arglist, uint32_t); - - ulBufIdx += ULtoA(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, ulNum, false, fmt.ulFillLen, fmt.cFillChar); - break; - } - case PRFMT_HEX32BIT: - { - uint32_t ulNum = va_arg(arglist, uint32_t); - - ulBufIdx += ULtoA(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, ulNum, true, fmt.ulFillLen, fmt.cFillChar); - break; - } - case PRFMT_SIGNED64BIT: - { - int64_t llNum = va_arg(arglist, int64_t); - - ulBufIdx += LLtoA(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, llNum, fmt.ulFillLen, fmt.cFillChar); - break; - } - case PRFMT_UNSIGNED64BIT: - { - uint64_t ullNum = va_arg(arglist, uint64_t); - - ulBufIdx += ULLtoA(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, ullNum, false, fmt.ulFillLen, fmt.cFillChar); - break; - } - case PRFMT_HEX64BIT: - { - uint64_t ullNum = va_arg(arglist, uint64_t); - - ulBufIdx += ULLtoA(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, ullNum, true, fmt.ulFillLen, fmt.cFillChar); - break; - } - case PRFMT_POINTER: - { - const void *ptr = va_arg(arglist, const void *); - - /* Assert our assumption. - */ - REDASSERT(sizeof(void *) <= 8U); - - /* Format as either a 64-bit or a 32-bit value. - */ - if(sizeof(void *) > 4U) - { - /* Attempt to quiet warnings. - */ - uintptr_t ptrval = (uintptr_t)ptr; - uint64_t ullPtrVal = (uint64_t)ptrval; - - ulBufIdx += ULLtoA(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, ullPtrVal, true, fmt.ulFillLen, fmt.cFillChar); - } - else - { - /* Attempt to quiet warnings. - */ - uintptr_t ptrval = (uintptr_t)ptr; - uint32_t ulPtrVal = (uint32_t)ptrval; - - ulBufIdx += ULtoA(&pcBuffer[ulBufIdx], ulBufferLen - ulBufIdx, ulPtrVal, true, fmt.ulFillLen, fmt.cFillChar); - } - - break; - } - case PRFMT_ANSISTRING: - { - const char *pszArg = va_arg(arglist, const char *); - uint32_t ulArgIdx = 0U; - - if(pszArg == NULL) - { - pszArg = "null"; - } - - if(fmt.ulFillLen > 0U) - { - if(!fmt.fLeftJustified) - { - uint32_t ulLen = RedStrLen(pszArg); - - /* So long as we are not left justifying, fill as many - characters as is necessary to make the string right - justified. - */ - while(((ulBufferLen - ulBufIdx) > 0U) && (fmt.ulFillLen > ulLen)) - { - pcBuffer[ulBufIdx] = fmt.cFillChar; - ulBufIdx++; - fmt.ulFillLen--; - } - } - - /* Move as many characters as we have space for into the - output buffer. - */ - while(((ulBufferLen - ulBufIdx) > 0U) && (pszArg[ulArgIdx] != '\0')) - { - pcBuffer[ulBufIdx] = pszArg[ulArgIdx]; - ulBufIdx++; - ulArgIdx++; - if(fmt.ulFillLen > 0U) - { - fmt.ulFillLen--; - } - } - - /* If there is any space left to fill, do it (the string - must have been left justified). - */ - while(((ulBufferLen - ulBufIdx) > 0U) && (fmt.ulFillLen > 0U)) - { - /* This is NOT a typo -- when using left justified - strings, spaces are the only allowed fill character. - See the errata. - */ - pcBuffer[ulBufIdx] = ' '; - ulBufIdx++; - fmt.ulFillLen--; - } - } - else - { - /* No fill characters, just move up to as many - characters as we have space for in the output - buffer. - */ - while(((ulBufferLen - ulBufIdx) > 0U) && (pszArg[ulArgIdx] != '\0')) - { - pcBuffer[ulBufIdx] = pszArg[ulArgIdx]; - ulBufIdx++; - ulArgIdx++; - } - } - break; - } - default: - { - REDERROR(); - break; - } - } - } - - /* If there is space, tack on a null and return the output length - processed, not including the null. - */ - if(ulBufIdx < ulBufferLen) - { - pcBuffer[ulBufIdx] = '\0'; - iLen = (int32_t)ulBufIdx; - } - else - { - /* Not enough space, just return -1, with no null termination - */ - iLen = -1; - } - - return iLen; -} - - -/** @brief Process the next segment of the format string, outputting any - non-format specifiers, as output buffer space allows, and return - information about the next format specifier. - - @note If the returned value is the same as the supplied @p ulBufferLen, - the output buffer will not be null-terminated. In all other cases, - the result will be null-terminated. The returned length will never - include the null in the count. - - @param pcBuffer The output buffer. - @param ulBufferLen The output buffer length. - @param pszFormat The format string to process. - @param pFormat The PRINTFORMAT structure to fill. - @param pulSpecifierLen Returns the length of any format specifier string, - or zero if no specifier was found. - - @return The count of characters from pszFormatt which were processed and - copied to pcBuffer. - - If zero is returned and *pulSpecifierLen is non-zero, then - a format specifier string was found at the start of pszFmt. - - If non-zero is returned and *pulSpecifierLen is zero, then - no format specifier string was found, and the entire pszFmt - string was copied to pBuffer (or as much as will fit). -*/ -static uint32_t ProcessFormatSegment( - char *pcBuffer, - uint32_t ulBufferLen, - const char *pszFormat, - PRINTFORMAT *pFormat, - uint32_t *pulSpecifierLen) -{ - uint32_t ulWidth = 0U; - - /* Find the next format specifier string, and information about it. - */ - *pulSpecifierLen = ParseFormatSpecifier(pszFormat, pFormat); - - if(*pulSpecifierLen == 0U) - { - /* If no specifier was found at all, then simply output the full length - of the string, or as much as will fit. - */ - ulWidth = REDMIN(ulBufferLen, RedStrLen(pszFormat)); - - RedMemCpy(pcBuffer, pszFormat, ulWidth); - } - else - { - /* If we encountered a double percent, skip past one of them so it is - copied into the output buffer. - */ - if(pFormat->type == PRFMT_DOUBLEPERCENT) - { - pFormat->ulSpecifierIdx++; - - /* A double percent specifier always has a length of two. Since - we're processing one of those percent signs, reduce the length - to one. Assert it so. - */ - REDASSERT(*pulSpecifierLen == 2U); - - (*pulSpecifierLen)--; - } - - /* So long as the specifier is not the very first thing in the format - string... - */ - if(pFormat->ulSpecifierIdx != 0U) - { - /* A specifier was found, but there is other data preceding it. - Copy as much as allowed to the output buffer. - */ - ulWidth = REDMIN(ulBufferLen, pFormat->ulSpecifierIdx); - - RedMemCpy(pcBuffer, pszFormat, ulWidth); - } - } - - /* If there is room in the output buffer, null-terminate whatever is there. - But note that the returned length never includes the null. - */ - if(ulWidth < ulBufferLen) - { - pcBuffer[ulWidth] = 0U; - } - - return ulWidth; -} - - -/** @brief Parse the specified format string for a valid RedVSNPrintf() format - sequence, and return information about it. - - @param pszFormat The format string to process. - @param pFormatType The PRINTFORMAT structure to fill. The data is only - valid if a non-zero length is returned. - - @return The length of the full format specifier string, starting at - pFormat->ulSpecifierIdx. Returns zero if a valid specifier was - not found. -*/ -static uint32_t ParseFormatSpecifier( - char const *pszFormat, - PRINTFORMAT *pFormatType) -{ - bool fContainsIllegalSequence = false; - uint32_t ulLen = 0U; - uint32_t ulIdx = 0U; - - while(pszFormat[ulIdx] != '\0') - { - uint32_t ulTypeLen; - - /* general output - */ - if(pszFormat[ulIdx] != '%') - { - ulIdx++; - } - else - { - RedMemSet(pFormatType, 0U, sizeof(*pFormatType)); - - /* Record the location of the start of the format sequence - */ - pFormatType->ulSpecifierIdx = ulIdx; - ulIdx++; - - if(pszFormat[ulIdx] == '-') - { - pFormatType->fLeftJustified = true; - ulIdx++; - } - - if((pszFormat[ulIdx] == '0') || (pszFormat[ulIdx] == '_')) - { - pFormatType->cFillChar = pszFormat[ulIdx]; - ulIdx++; - } - else - { - pFormatType->cFillChar = ' '; - } - - if(pszFormat[ulIdx] == '*') - { - pFormatType->fHasVarWidth = true; - ulIdx++; - } - else if(ISDIGIT(pszFormat[ulIdx])) - { - pFormatType->ulFillLen = (uint32_t)RedAtoI(&pszFormat[ulIdx]); - while(ISDIGIT(pszFormat[ulIdx])) - { - ulIdx++; - } - } - else - { - /* No fill length. - */ - } - - pFormatType->type = ParseFormatType(&pszFormat[ulIdx], &ulTypeLen); - if(pFormatType->type != PRFMT_UNKNOWN) - { - /* Even though we are returning successfully, keep track of - whether an illegal sequence was encountered and skipped. - */ - pFormatType->fHasIllegalType = fContainsIllegalSequence; - - ulLen = (ulIdx - pFormatType->ulSpecifierIdx) + ulTypeLen; - break; - } - - /* In the case of an unrecognized type string, simply ignore - it entirely. Reset the pointer to the position following - the percent sign, so it is not found again. - */ - fContainsIllegalSequence = false; - ulIdx = pFormatType->ulSpecifierIdx + 1U; - } - } - - return ulLen; -} - - -/** @brief Parse a RedPrintf() format type string to determine the proper data - type. - - @param pszFormat The format string to process. This must be a pointer to - the character following any width or justification - characters. - @param pulTypeLen The location in which to store the type length. The - value will be 0 if PRFMT_UNKNOWN is returned. - - @return Rhe PRFMT_* type value, or PRFMT_UNKNOWN if the type is not - recognized. -*/ -static PRINTTYPE ParseFormatType( - const char *pszFormat, - uint32_t *pulTypeLen) -{ - PRINTTYPE fmtType = PRFMT_UNKNOWN; - uint32_t ulIdx = 0U; - - switch(pszFormat[ulIdx]) - { - case '%': - fmtType = PRFMT_DOUBLEPERCENT; - break; - case 'c': - fmtType = PRFMT_CHAR; - break; - case 's': - fmtType = PRFMT_ANSISTRING; - break; - case 'p': - fmtType = PRFMT_POINTER; - break; - case 'd': - fmtType = MAPINT; - break; - case 'u': - fmtType = MAPUINT; - break; - case 'x': - fmtType = MAPHEXUINT; - break; - case 'h': - { - ulIdx++; - switch(pszFormat[ulIdx]) - { - case 'd': - fmtType = MAPSHORT; - break; - case 'u': - fmtType = MAPUSHORT; - break; - case 'x': - fmtType = MAPHEXUSHORT; - break; - default: - break; - } - break; - } - case 'l': - { - ulIdx++; - switch(pszFormat[ulIdx]) - { - case 'd': - fmtType = MAPLONG; - break; - case 'u': - fmtType = MAPULONG; - break; - case 'x': - fmtType = MAPHEXULONG; - break; - case 'l': - { - ulIdx++; - switch(pszFormat[ulIdx]) - { - case 'd': - fmtType = MAPLONGLONG; - break; - case 'u': - fmtType = MAPULONGLONG; - break; - case 'x': - case 'X': - fmtType = MAPHEXULONGLONG; - break; - default: - break; - } - break; - } - default: - break; - } - break; - } - default: - break; - } - - if(fmtType != PRFMT_UNKNOWN) - { - *pulTypeLen = ulIdx + 1U; - } - else - { - *pulTypeLen = 0U; - } - - return fmtType; -} - - -/** @brief Format a signed 32-bit integer as a base 10 ASCII string. - - @note If the output buffer length is exhausted, the result will *not* be - null-terminated. - - @note If the @p ulFillLen value is greater than or equal to the buffer - length, the result will not be null-terminated, even if the - formatted portion of the data is shorter than the buffer length. - - @param pcBuffer The output buffer - @param ulBufferLen A pointer to the output buffer length - @param lNum The 32-bit signed number to convert - @param ulFillLen The fill length, if any - @param cFill The fill character to use - - @return The length of the string. -*/ -static uint32_t LtoA( - char *pcBuffer, - uint32_t ulBufferLen, - int32_t lNum, - uint32_t ulFillLen, - char cFill) -{ - uint32_t ulLen; - - if(pcBuffer == NULL) - { - REDERROR(); - ulLen = 0U; - } - else - { - char ach[12U]; /* big enough for a int32_t in base 10 */ - uint32_t ulDigits = 0U; - uint32_t ulNum; - bool fSign; - - if(lNum < 0) - { - fSign = true; - ulNum = (uint32_t)-lNum; - } - else - { - fSign = false; - ulNum = (uint32_t)lNum; - } - - do - { - ach[ulDigits] = gacDigits[ulNum % 10U]; - ulNum = ulNum / 10U; - ulDigits++; - } - while(ulNum); - - if(fSign) - { - ach[ulDigits] = '-'; - ulDigits++; - } - - ulLen = FinishToA(ach, ulDigits, pcBuffer, ulBufferLen, ulFillLen, cFill); - } - - return ulLen; -} - - -/** @brief Format a signed 64-bit integer as a base 10 ASCII string. - - @note If the output buffer length is exhausted, the result will *not* be - null-terminated. - - @note If the @p ulFillLen value is greater than or equal to the buffer - length, the result will not be null-terminated, even if the - formatted portion of the data is shorter than the buffer length. - - @param pcBuffer The output buffer - @param ulBufferLen A pointer to the output buffer length - @param llNum The 64-bit signed number to convert - @param ulFillLen The fill length, if any - @param cFill The fill character to use - - @return The length of the string. -*/ -static uint32_t LLtoA( - char *pcBuffer, - uint32_t ulBufferLen, - int64_t llNum, - uint32_t ulFillLen, - char cFill) -{ - uint32_t ulLen; - - if(pcBuffer == NULL) - { - REDERROR(); - ulLen = 0U; - } - else - { - char ach[12U]; /* big enough for a int32_t in base 10 */ - uint32_t ulDigits = 0U; - uint64_t ullNum; - bool fSign; - - if(llNum < 0) - { - fSign = true; - ullNum = (uint64_t)-llNum; - } - else - { - fSign = false; - ullNum = (uint64_t)llNum; - } - - /* Not allowed to assume that 64-bit division is OK, so use a - software division routine. - */ - do - { - uint64_t ullQuotient; - uint32_t ulRemainder; - - /* Note: RedUint64DivMod32() is smart enough to use normal division - once ullNumericVal <= UINT32_MAX. - */ - ullQuotient = RedUint64DivMod32(ullNum, 10U, &ulRemainder); - - ach[ulDigits] = gacDigits[ulRemainder]; - ullNum = ullQuotient; - ulDigits++; - } - while(ullNum > 0U); - - if(fSign) - { - ach[ulDigits] = '-'; - ulDigits++; - } - - ulLen = FinishToA(ach, ulDigits, pcBuffer, ulBufferLen, ulFillLen, cFill); - } - - return ulLen; -} - - -/** @brief Format an unsigned 32-bit integer as an ASCII string as decimal or - hex. - - @note If the output buffer length is exhausted, the result will *not* be - null-terminated. - - @param pcBuffer The output buffer - @param ulBufferLen The output buffer length - @param ulNum The 32-bit unsigned number to convert - @param fHex If true, format as hex; if false, decimal. - @param ulFillLen The fill length, if any - @param cFill The fill character to use - - @return The length of the string. -*/ -static uint32_t ULtoA( - char *pcBuffer, - uint32_t ulBufferLen, - uint32_t ulNum, - bool fHex, - uint32_t ulFillLen, - char cFill) -{ - uint32_t ulLen; - - if(pcBuffer == NULL) - { - REDERROR(); - ulLen = 0U; - } - else - { - char ach[11U]; /* Big enough for a uint32_t in radix 10 */ - uint32_t ulDigits = 0U; - uint32_t ulNumericVal = ulNum; - uint32_t ulRadix = fHex ? 16U : 10U; - - do - { - ach[ulDigits] = gacDigits[ulNumericVal % ulRadix]; - ulNumericVal = ulNumericVal / ulRadix; - ulDigits++; - } - while(ulNumericVal > 0U); - - ulLen = FinishToA(ach, ulDigits, pcBuffer, ulBufferLen, ulFillLen, cFill); - } - - return ulLen; -} - - -/** @brief Format an unsigned 64-bit integer as an ASCII string as decimal or - hex. - - @note If the output buffer length is exhausted, the result will *not* be - null-terminated. - - @param pcBuffer The output buffer. - @param ulBufferLen The output buffer length. - @param ullNum The unsigned 64-bit number to convert. - @param fHex If true, format as hex; if false, decimal. - @param ulFillLen The fill length, if any. - @param cFill The fill character to use. - - @return The length of the string. -*/ -static uint32_t ULLtoA( - char *pcBuffer, - uint32_t ulBufferLen, - uint64_t ullNum, - bool fHex, - uint32_t ulFillLen, - char cFill) -{ - uint32_t ulLen; - - if(pcBuffer == NULL) - { - REDERROR(); - ulLen = 0U; - } - else - { - - char ach[21U]; /* Big enough for a uint64_t in radix 10 */ - uint32_t ulDigits = 0U; - uint64_t ullNumericVal = ullNum; - - if(fHex) - { - /* We can figure out the digits using bit operations. - */ - do - { - ach[ulDigits] = gacDigits[ullNumericVal & 15U]; - ullNumericVal >>= 4U; - ulDigits++; - } - while(ullNumericVal > 0U); - } - else - { - /* Not allowed to assume that 64-bit division is OK, so use a - software division routine. - */ - do - { - uint64_t ullQuotient; - uint32_t ulRemainder; - - /* Note: RedUint64DivMod32() is smart enough to use normal division - once ullNumericVal <= UINT32_MAX. - */ - ullQuotient = RedUint64DivMod32(ullNumericVal, 10U, &ulRemainder); - - ach[ulDigits] = gacDigits[ulRemainder]; - ullNumericVal = ullQuotient; - ulDigits++; - } - while(ullNumericVal > 0U); - } - - ulLen = FinishToA(ach, ulDigits, pcBuffer, ulBufferLen, ulFillLen, cFill); - } - - return ulLen; -} - - -/** @brief Finish converting a number into an ASCII string representing that - number. - - This helper function contains common logic that needs to run at the end of - all the "toA" functions. It adds the fill character and reverses the digits - string. - - @param pcDigits The digits (and sign) for the ASCII string, in reverse - order as they were computed. - @param ulDigits The number of digit characters. - @param pcOutBuffer The output buffer. - @param ulBufferLen The length of the output buffer. - @param ulFillLen The fill length. If the number string is shorter than - this, the remaining bytes are filled with @p cFill. - @param cFill The fill character. - - @return The length of @p pcOutBuffer. -*/ -static uint32_t FinishToA( - const char *pcDigits, - uint32_t ulDigits, - char *pcOutBuffer, - uint32_t ulBufferLen, - uint32_t ulFillLen, - char cFill) -{ - uint32_t ulIdx = 0U; - uint32_t ulDigitIdx = ulDigits; - - /* user may have asked for a fill char - */ - if(ulFillLen > ulDigits) - { - uint32_t ulFillRem = ulFillLen - ulDigits; - - while((ulFillRem > 0U) && (ulIdx < ulBufferLen)) - { - pcOutBuffer[ulIdx] = cFill; - ulIdx++; - ulFillRem--; - } - } - - /* reverse the string - */ - while((ulDigitIdx > 0) && (ulIdx < ulBufferLen)) - { - ulDigitIdx--; - pcOutBuffer[ulIdx] = pcDigits[ulDigitIdx]; - ulIdx++; - } - - if(ulIdx < ulBufferLen) - { - pcOutBuffer[ulIdx] = '\0'; - } - - return ulIdx; -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/tests/util/rand.c b/FreeRTOS-Plus/Source/Reliance-Edge/tests/util/rand.c deleted file mode 100755 index 6dd4430..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/tests/util/rand.c +++ /dev/null @@ -1,159 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements a random number generator. -*/ -#include -#include - - -/* This is the global seed used by the random number generator when the caller - has not provided a seed to either the RedRand32() or RedRand64() functions. -*/ -static uint64_t ullGlobalRandomNumberSeed; - -/* Whether the above seed has been initialized. -*/ -static bool fGlobalSeedInited; - - -/** @brief Set the global seed used by the random number generator. - - The global seed gets used when RedRand64() or RedRand32() are called with - a NULL seed argument. - - @param ullSeed The value to use as the global RNG seed. -*/ -void RedRandSeed( - uint64_t ullSeed) -{ - ullGlobalRandomNumberSeed = ullSeed; - fGlobalSeedInited = true; -} - - -/** @brief Generate a 64-bit pseudo-random number. - - The period of this random number generator is 2^64 (1.8 x 1019). These - parameters are the same as the default one-stream SPRNG lcg64 generator and - it satisfies the requirements for a maximal period. - - The tempering value is used and an AND mask and is specifically selected to - favor the distribution of lower bits. - - @param pullSeed A pointer to the seed to use. Set this value to NULL to - use the internal global seed value. - - @return A pseudo-random number in the range [0, UINT64_MAX]. -*/ -uint64_t RedRand64( - uint64_t *pullSeed) -{ - const uint64_t ullA = UINT64_SUFFIX(2862933555777941757); - const uint64_t ullC = UINT64_SUFFIX(3037000493); - const uint64_t ullT = UINT64_SUFFIX(4921441182957829599); - uint64_t ullN; - uint64_t *pullSeedPtr; - uint64_t ullLocalSeed; - - if(pullSeed != NULL) - { - ullLocalSeed = *pullSeed; - pullSeedPtr = pullSeed; - } - else - { - if(!fGlobalSeedInited) - { - /* Unfortunately, the Reliance Edge OS services don't give us much - to work with to initialize the global seed. There is no entropy - abstraction, no tick count abstraction, and the timestamp - abstraction uses an opaque type which is not guaranteed to be an - integer. The best we can do is use the RTC. - - Tests using the RNG should be supplying a seed anyway, for - reproducibility. - */ - RedRandSeed((uint64_t)RedOsClockGetTime()); - } - - ullLocalSeed = ullGlobalRandomNumberSeed; - pullSeedPtr = &ullGlobalRandomNumberSeed; - } - - ullN = (ullLocalSeed * ullA) + ullC; - - *pullSeedPtr = ullN; - - /* The linear congruential generator used above produces good psuedo-random - 64-bit number sequences, however, as with any LCG, the period of the - lower order bits is much shorter resulting in alternately odd/even pairs - in bit zero. - - The result of the LGC above is tempered below with a series of XOR and - shift operations to produce a more acceptable equidistribution of bits - throughout the 64-bit range. - */ - ullN ^= (ullN >> 21U) & ullT; - ullN ^= (ullN >> 43U) & ullT; - ullN ^= (ullN << 23U) & ~ullT; - ullN ^= (ullN << 31U) & ~ullT; - - return ullN; -} - - -/** @brief Generate a 32-bit pseudo-random number. - - @note The 32-bit random number generator internally uses the 64-bit random - number generator, returning the low 32-bits of the pseudo-random - 64-bit value. - - @param pulSeed A pointer to the seed to use. Set this value to NULL to use - the internal global seed value. - - @return A pseudo-random number in the range [0, UINT32_MAX]. -*/ -uint32_t RedRand32( - uint32_t *pulSeed) -{ - uint64_t ullN; - - if(pulSeed != NULL) - { - uint64_t ullLocalSeed; - - ullLocalSeed = *pulSeed; - ullN = RedRand64(&ullLocalSeed); - *pulSeed = (uint32_t)ullLocalSeed; - } - else - { - ullN = RedRand64(NULL); - } - - return (uint32_t)ullN; -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/toolcmn/getopt.c b/FreeRTOS-Plus/Source/Reliance-Edge/toolcmn/getopt.c deleted file mode 100755 index 613d331..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/toolcmn/getopt.c +++ /dev/null @@ -1,559 +0,0 @@ -/* - * Copyright (c) 2002 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F39502-99-1-0512. - */ -/*- - * Copyright (c) 2000 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dieter Baron and Thomas Klausner. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/** @file - @brief Implementations of getopt() and getopt_long() work-alike functions. - - This code was taken from FreeBSD and slightly modified, mostly to rename - symbols with external linkage to avoid naming conflicts in systems where - there are real getopt()/getopt_long() implementations, and for portability. -*/ -#include -#include -#include - -#include -#include -#include -#include - - -int32_t red_opterr = 1; /* if error message should be printed */ -int32_t red_optind = 1; /* index into parent argv vector */ -int32_t red_optopt = '?'; /* character checked for validity */ -int32_t red_optreset; /* reset RedGetopt */ -const char *red_optarg; /* argument associated with option */ - -#define PRINT_ERROR ((red_opterr) && (*options != ':')) - -#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */ -#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */ -#define FLAG_LONGONLY 0x04 /* operate as RedGetoptLongOnly */ - -/* return values */ -#define BADCH (int)'?' -#define BADARG ((*options == ':') ? (int)':' : (int)'?') -#define INORDER (int)1 - -#define EMSG "" - -#define NO_PREFIX (-1) -#define D_PREFIX 0 -#define DD_PREFIX 1 -#define W_PREFIX 2 - -static int gcd(int a, int b); -static void permute_args(int panonopt_start, int panonopt_end, int opt_end, char * const *nargv); -static int parse_long_options(char * const *nargv, const char *options, const REDOPTION *long_options, int32_t *idx, int short_too, int flags); -static int getopt_internal(int nargc, char * const *nargv, const char *options, const REDOPTION *long_options, int32_t *idx, int flags); - -static const char *place = EMSG; /* option letter processing */ - -/* XXX: set red_optreset to 1 rather than these two */ -static int nonopt_start = -1; /* first non option argument (for permute) */ -static int nonopt_end = -1; /* first option after non options (for permute) */ - -/* Error messages */ -static const char recargchar[] = "option requires an argument -- %c\n"; -static const char illoptchar[] = "illegal option -- %c\n"; /* From P1003.2 */ -static int dash_prefix = NO_PREFIX; -static const char gnuoptchar[] = "invalid option -- %c\n"; - -static const char recargstring[] = "option `%s%s' requires an argument\n"; -static const char ambig[] = "option `%s%s' is ambiguous\n"; -static const char noarg[] = "option `%s%s' doesn't allow an argument\n"; -static const char illoptstring[] = "unrecognized option `%s%s'\n"; - -/* - * Compute the greatest common divisor of a and b. - */ -static int -gcd(int a, int b) -{ - int c; - - c = a % b; - while (c != 0) { - a = b; - b = c; - c = a % b; - } - - return (b); -} - -/* - * Exchange the block from nonopt_start to nonopt_end with the block - * from nonopt_end to opt_end (keeping the same order of arguments - * in each block). - */ -static void -permute_args(int panonopt_start, int panonopt_end, int opt_end, - char * const *nargv) -{ - int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; - char *swap; - - /* - * compute lengths of blocks and number and size of cycles - */ - nnonopts = panonopt_end - panonopt_start; - nopts = opt_end - panonopt_end; - ncycle = gcd(nnonopts, nopts); - cyclelen = (opt_end - panonopt_start) / ncycle; - - for (i = 0; i < ncycle; i++) { - cstart = panonopt_end+i; - pos = cstart; - for (j = 0; j < cyclelen; j++) { - if (pos >= panonopt_end) - pos -= nnonopts; - else - pos += nopts; - swap = nargv[pos]; - ((char **) nargv)[pos] = nargv[cstart]; - ((char **)nargv)[cstart] = swap; - } - } -} - -/* - * parse_long_options -- - * Parse long options in argc/argv argument vector. - * Returns -1 if short_too is set and the option does not match long_options. - */ -static int -parse_long_options(char * const *nargv, const char *options, - const REDOPTION *long_options, int32_t *idx, int short_too, int flags) -{ - const char *current_argv, *has_equal, *current_dash; - size_t current_argv_len; - int i, match, exact_match, second_partial_match; - - current_argv = place; - switch (dash_prefix) { - case D_PREFIX: - current_dash = "-"; - break; - case DD_PREFIX: - current_dash = "--"; - break; - case W_PREFIX: - current_dash = "-W "; - break; - default: - current_dash = ""; - break; - } - match = -1; - exact_match = 0; - second_partial_match = 0; - - red_optind++; - - if ((has_equal = strchr(current_argv, '=')) != NULL) { - /* argument found (--option=arg) */ - current_argv_len = has_equal - current_argv; - has_equal++; - } else - current_argv_len = strlen(current_argv); - - for (i = 0; long_options[i].name; i++) { - /* find matching long option */ - if (strncmp(current_argv, long_options[i].name, - current_argv_len)) - continue; - - if (strlen(long_options[i].name) == current_argv_len) { - /* exact match */ - match = i; - exact_match = 1; - break; - } - /* - * If this is a known short option, don't allow - * a partial match of a single character. - */ - if (short_too && current_argv_len == 1) - continue; - - if (match == -1) /* first partial match */ - match = i; - else if ((flags & FLAG_LONGONLY) || - long_options[i].has_arg != - long_options[match].has_arg || - long_options[i].flag != long_options[match].flag || - long_options[i].val != long_options[match].val) - second_partial_match = 1; - } - if (!exact_match && second_partial_match) { - /* ambiguous abbreviation */ - if (PRINT_ERROR) - fprintf(stderr, - ambig, - current_dash, - current_argv); - red_optopt = 0; - return (BADCH); - } - if (match != -1) { /* option found */ - if (long_options[match].has_arg == red_no_argument - && has_equal) { - if (PRINT_ERROR) - fprintf(stderr, - noarg, - current_dash, - current_argv); - /* - * XXX: GNU sets red_optopt to val regardless of flag - */ - if (long_options[match].flag == NULL) - red_optopt = long_options[match].val; - else - red_optopt = 0; - return (BADCH); - } - if (long_options[match].has_arg == red_required_argument || - long_options[match].has_arg == red_optional_argument) { - if (has_equal) - red_optarg = has_equal; - else if (long_options[match].has_arg == - red_required_argument) { - /* - * optional argument doesn't use next nargv - */ - red_optarg = nargv[red_optind++]; - } - } - if ((long_options[match].has_arg == red_required_argument) - && (red_optarg == NULL)) { - /* - * Missing argument; leading ':' indicates no error - * should be generated. - */ - if (PRINT_ERROR) - fprintf(stderr, - recargstring, - current_dash, - current_argv); - /* - * XXX: GNU sets red_optopt to val regardless of flag - */ - if (long_options[match].flag == NULL) - red_optopt = long_options[match].val; - else - red_optopt = 0; - --red_optind; - return (BADARG); - } - } else { /* unknown option */ - if (short_too) { - --red_optind; - return (-1); - } - if (PRINT_ERROR) - fprintf(stderr, - illoptstring, - current_dash, - current_argv); - red_optopt = 0; - return (BADCH); - } - if (idx) - *idx = match; - if (long_options[match].flag) { - *long_options[match].flag = long_options[match].val; - return (0); - } else - return (long_options[match].val); -} - -/* - * getopt_internal -- - * Parse argc/argv argument vector. Called by user level routines. - */ -static int -getopt_internal(int nargc, char * const *nargv, const char *options, - const REDOPTION *long_options, int32_t *idx, int flags) -{ - char *oli; /* option letter list index */ - int optchar, short_too; - - if (options == NULL) - return (-1); - - /* - * XXX Some GNU programs (like cvs) set red_optind to 0 instead of - * XXX using red_optreset. Work around this braindamage. - */ - if (red_optind == 0) - red_optind = red_optreset = 1; - - /* - * Disable GNU extensions if options string begins with a '+'. - */ - if (*options == '-') - flags |= FLAG_ALLARGS; - else if (*options == '+') - flags &= ~FLAG_PERMUTE; - if (*options == '+' || *options == '-') - options++; - - red_optarg = NULL; - if (red_optreset) - nonopt_start = nonopt_end = -1; -start: - if (red_optreset || !*place) { /* update scanning pointer */ - red_optreset = 0; - if (red_optind >= nargc) { /* end of argument vector */ - place = EMSG; - if (nonopt_end != -1) { - /* do permutation, if we have to */ - permute_args(nonopt_start, nonopt_end, - red_optind, nargv); - red_optind -= nonopt_end - nonopt_start; - } - else if (nonopt_start != -1) { - /* - * If we skipped non-options, set red_optind - * to the first of them. - */ - red_optind = nonopt_start; - } - nonopt_start = nonopt_end = -1; - return (-1); - } - if (*(place = nargv[red_optind]) != '-' || place[1] == '\0') { - place = EMSG; /* found non-option */ - if (flags & FLAG_ALLARGS) { - /* - * GNU extension: - * return non-option as argument to option 1 - */ - red_optarg = nargv[red_optind++]; - return (INORDER); - } - if (!(flags & FLAG_PERMUTE)) { - /* - * If no permutation wanted, stop parsing - * at first non-option. - */ - return (-1); - } - /* do permutation */ - if (nonopt_start == -1) - nonopt_start = red_optind; - else if (nonopt_end != -1) { - permute_args(nonopt_start, nonopt_end, - red_optind, nargv); - nonopt_start = red_optind - - (nonopt_end - nonopt_start); - nonopt_end = -1; - } - red_optind++; - /* process next argument */ - goto start; - } - if (nonopt_start != -1 && nonopt_end == -1) - nonopt_end = red_optind; - - /* - * If we have "-" do nothing, if "--" we are done. - */ - if (place[1] != '\0' && *++place == '-' && place[1] == '\0') { - red_optind++; - place = EMSG; - /* - * We found an option (--), so if we skipped - * non-options, we have to permute. - */ - if (nonopt_end != -1) { - permute_args(nonopt_start, nonopt_end, - red_optind, nargv); - red_optind -= nonopt_end - nonopt_start; - } - nonopt_start = nonopt_end = -1; - return (-1); - } - } - - /* - * Check long options if: - * 1) we were passed some - * 2) the arg is not just "-" - * 3) either the arg starts with -- we are RedGetoptLongOnly() - */ - if (long_options != NULL && place != nargv[red_optind] && - (*place == '-' || (flags & FLAG_LONGONLY))) { - short_too = 0; - dash_prefix = D_PREFIX; - if (*place == '-') { - place++; /* --foo long option */ - dash_prefix = DD_PREFIX; - } else if (*place != ':' && strchr(options, *place) != NULL) - short_too = 1; /* could be short option too */ - - optchar = parse_long_options(nargv, options, long_options, - idx, short_too, flags); - if (optchar != -1) { - place = EMSG; - return (optchar); - } - } - - if ((optchar = (int)*place++) == (int)':' || - (optchar == (int)'-' && *place != '\0') || - (oli = strchr(options, optchar)) == NULL) { - /* - * If the user specified "-" and '-' isn't listed in - * options, return -1 (non-option) as per POSIX. - * Otherwise, it is an unknown option character (or ':'). - */ - if (optchar == (int)'-' && *place == '\0') - return (-1); - if (!*place) - ++red_optind; - if (PRINT_ERROR) - fprintf(stderr, gnuoptchar, optchar); - red_optopt = optchar; - return (BADCH); - } - if (long_options != NULL && optchar == 'W' && oli[1] == ';') { - /* -W long-option */ - if (*place) /* no space */ - /* NOTHING */; - else if (++red_optind >= nargc) { /* no arg */ - place = EMSG; - if (PRINT_ERROR) - fprintf(stderr, recargchar, optchar); - red_optopt = optchar; - return (BADARG); - } else /* white space */ - place = nargv[red_optind]; - dash_prefix = W_PREFIX; - optchar = parse_long_options(nargv, options, long_options, - idx, 0, flags); - place = EMSG; - return (optchar); - } - if (*++oli != ':') { /* doesn't take argument */ - if (!*place) - ++red_optind; - } else { /* takes (optional) argument */ - red_optarg = NULL; - if (*place) /* no white space */ - red_optarg = place; - else if (oli[1] != ':') { /* arg not optional */ - if (++red_optind >= nargc) { /* no arg */ - place = EMSG; - if (PRINT_ERROR) - fprintf(stderr, recargchar, optchar); - red_optopt = optchar; - return (BADARG); - } else - red_optarg = nargv[red_optind]; - } - place = EMSG; - ++red_optind; - } - /* dump back option letter */ - return (optchar); -} - - -/** @brief Get option character from command line argument list. - - For more details, consult the getopt() man pages, since this function is - generally similar. - - @param nargc Number of arguments (argc passed into main()). - @param nargv Argument vector (argv passed into main()). - @param options String of option characters. - - @return The next known option character in @p options. If a character not - found in @p options is found or if an option is missing an argument, - it returns '?'. Returns -1 when the argument list is exhausted. -*/ -int32_t RedGetopt( - int32_t nargc, - char * const *nargv, - const char *options) -{ - return getopt_internal(nargc, nargv, options, NULL, NULL, FLAG_PERMUTE); -} - - -/** @brief Get long options from command line argument list. - - For more details, consult the getopt_long() man pages, since this function - is generally similar. - - @param nargc Number of arguments (argc passed into main()). - @param nargv Argument vector (argv passed into main()). - @param options String of option characters. - @param long_options The long options; the last element of this array must be - filled with zeroes. - @param idx If non-NULL, then populated with the index of the long - option relative to @p long_options. - - @return If the flag field in REDOPTION is NULL, returns the value specified - in the val field, which is usually just the corresponding short - option. If flag is non-NULL, returns zero and stores val in the - location pointed to by flag. Returns ':' if an option was missing - its argument, '?' for an unknown option, and -1 when the argument - list is exhausted. -*/ -int32_t RedGetoptLong( - int32_t nargc, - char * const *nargv, - const char *options, - const REDOPTION *long_options, - int32_t *idx) -{ - return getopt_internal(nargc, nargv, options, long_options, idx, FLAG_PERMUTE); -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/toolcmn/toolcmn.c b/FreeRTOS-Plus/Source/Reliance-Edge/toolcmn/toolcmn.c deleted file mode 100755 index c60c465..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/toolcmn/toolcmn.c +++ /dev/null @@ -1,99 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements common-code utilities for tools and tests. -*/ -#include -#include -#include -#include - -#include -#include -#include -#include - - -/** @brief Convert a string into a volume number. - - In a POSIX-like configuration, @p pszVolume can either be a volume number or - a volume path prefix. In case of ambiguity, the volume number of a matching - path prefix takes precedence. - - In an FSE configuration, @p pszVolume can be a volume number. - - @param pszVolume The volume string. - - @return On success, returns the volume number; on failure, returns - #REDCONF_VOLUME_COUNT. -*/ -uint8_t RedFindVolumeNumber( - const char *pszVolume) -{ - unsigned long ulNumber; - const char *pszEndPtr; - uint8_t bVolNum = REDCONF_VOLUME_COUNT; - #if REDCONF_API_POSIX == 1 - uint8_t bIndex; - #endif - - /* Determine if pszVolume can be interpreted as a volume number. - */ - errno = 0; - ulNumber = strtoul(pszVolume, (char **)&pszEndPtr, 10); - if((errno == 0) && (ulNumber != ULONG_MAX) && (pszEndPtr[0U] == '\0') && (ulNumber < REDCONF_VOLUME_COUNT)) - { - bVolNum = (uint8_t)ulNumber; - } - - #if REDCONF_API_POSIX == 1 - /* Determine if pszVolume is a valid path prefix. - */ - for(bIndex = 0U; bIndex < REDCONF_VOLUME_COUNT; bIndex++) - { - if(strcmp(gaRedVolConf[bIndex].pszPathPrefix, pszVolume) == 0) - { - break; - } - } - - if(bIndex < REDCONF_VOLUME_COUNT) - { - /* Edge case: It is technically possible for pszVolume to be both a - valid volume number and a valid volume prefix, for different - volumes. For example, if pszVolume is "2", that would be recognized - as volume number 2 above. But if "2" is the (poorly chosen) path - prefix for volume number 4, that would also be matched. Since the - POSIX-like API is primarily name based, and the ability to use - volume numbers with this tool is just a convenience, the volume - prefix takes precedence. - */ - bVolNum = bIndex; - } - #endif - - return bVolNum; -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/util/bitmap.c b/FreeRTOS-Plus/Source/Reliance-Edge/util/bitmap.c deleted file mode 100755 index 2424d19..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/util/bitmap.c +++ /dev/null @@ -1,101 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements utilities for working with bitmaps. -*/ -#include - - -/** @brief Query the state of a bit in a bitmap. - - Bits are counted from most significant to least significant. Thus, the mask - for bit zero is 0x80 applied to the first byte in the bitmap. - - @param pbBitmap Pointer to the bitmap. - @param ulBit The bit to query. - - @retval Whether the bit is set (true) or clear (false. -*/ -bool RedBitGet( - const uint8_t *pbBitmap, - uint32_t ulBit) -{ - bool fRet; - - if(pbBitmap == NULL) - { - REDERROR(); - fRet = false; - } - else - { - fRet = (pbBitmap[ulBit >> 3U] & (0x80U >> (ulBit & 7U))) != 0U; - } - - return fRet; -} - - -/** @brief Set a bit in a bitmap to one. - - Bits are counted from most significant to least significant. Thus, the mask - for bit zero is 0x80 applied to the first byte in the bitmap. - - @param pbBitmap Pointer to the bitmap. - @param ulBit The bit to set. -*/ -void RedBitSet( - uint8_t *pbBitmap, - uint32_t ulBit) -{ - REDASSERT(pbBitmap != NULL); - - if(pbBitmap != NULL) - { - pbBitmap[ulBit >> 3U] |= (0x80U >> (ulBit & 7U)); - } -} - - -/** @brief Clear a bit in a bitmap to zero. - - Bits are counted from most significant to least significant. Thus, the mask - for bit zero is 0x80 applied to the first byte in the bitmap. - - @param pbBitmap Pointer to the bitmap. - @param ulBit The bit to clear. -*/ -void RedBitClear( - uint8_t *pbBitmap, - uint32_t ulBit) -{ - REDASSERT(pbBitmap != NULL); - - if(pbBitmap != NULL) - { - pbBitmap[ulBit >> 3U] &= ~(0x80U >> (ulBit & 7U)); - } -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/util/crc.c b/FreeRTOS-Plus/Source/Reliance-Edge/util/crc.c deleted file mode 100755 index bec6905..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/util/crc.c +++ /dev/null @@ -1,598 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements utilities for calculating CRC-32 checksums. -*/ -#include - - -/* The CRC functions do not return errors since the only detectable error - condition is a NULL buffer pointer. If such a condition does arise, the - functions assert and return the below CRC, which, although a legal CRC, - is nonetheless suspicious and could provide a clue that something has - gone wrong. -*/ -#define SUSPICIOUS_CRC_VALUE (0xBAADC0DEU) - -#define CRC_BITWISE (0U) -#define CRC_SARWATE (1U) -#define CRC_SLICEBY8 (2U) - - -#if REDCONF_CRC_ALGORITHM == CRC_BITWISE - -/* The following is representative of the polynomial accepted by CCITT 32-bit - and in IEEE 802.3, Ethernet 2 specification. - - x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1 - (reverse order) - 1110 1101 1011 1000 1000 0011 0010 0000 1 - (E) (D) (B) (8) (8) (3) (2) (0) -*/ -#define CCITT_32_POLYNOMIAL (0xEDB88320U) - - -/** @brief Compute a CRC32 for the given data buffer. - - For CCITT-32 compliance, the initial CRC must be set to 0. To CRC multiple - buffers, call this function with the previously returned CRC value. - - @param ulInitCrc32 Starting CRC value. - @param pBuffer Data buffer to calculate the CRC from. - @param ulLength Number of bytes of data in the given buffer. - - @return The updated CRC value. -*/ -uint32_t RedCrc32Update( - uint32_t ulInitCrc32, - const void *pBuffer, - uint32_t ulLength) -{ - uint32_t ulCrc32; - - if(pBuffer == NULL) - { - REDERROR(); - ulCrc32 = SUSPICIOUS_CRC_VALUE; - } - else - { - const uint8_t *pbBuffer = CAST_VOID_PTR_TO_CONST_UINT8_PTR(pBuffer); - uint32_t ulIdx; - - ulCrc32 = ~ulInitCrc32; - - for(ulIdx = 0U; ulIdx < ulLength; ++ulIdx) - { - uint32_t ulBit; - - ulCrc32 ^= pbBuffer[ulIdx]; - - /* Branchless inner loop (greatly improves performance). - */ - for(ulBit = 0U; ulBit < 8U; ulBit++) - { - ulCrc32 = ((ulCrc32 & 1U) * CCITT_32_POLYNOMIAL) ^ (ulCrc32 >> 1U); - } - } - - ulCrc32 = ~ulCrc32; - } - - return ulCrc32; -} - -#elif REDCONF_CRC_ALGORITHM == CRC_SARWATE - -/** @brief Compute a CRC32 for the given data buffer. - - For CCITT-32 compliance, the initial CRC must be set to 0. To CRC multiple - buffers, call this function with the previously returned CRC value. - - @param ulInitCrc32 Starting CRC value. - @param pBuffer Data buffer to calculate the CRC from. - @param ulLength Number of bytes of data in the given buffer. - - @return The updated CRC value. -*/ -uint32_t RedCrc32Update( - uint32_t ulInitCrc32, - const void *pBuffer, - uint32_t ulLength) -{ - static const uint32_t aulCrc32Table[] = - { - 0x00000000U, 0x77073096U, 0xEE0E612CU, 0x990951BAU, 0x076DC419U, 0x706AF48FU, 0xE963A535U, 0x9E6495A3U, - 0x0EDB8832U, 0x79DCB8A4U, 0xE0D5E91EU, 0x97D2D988U, 0x09B64C2BU, 0x7EB17CBDU, 0xE7B82D07U, 0x90BF1D91U, - 0x1DB71064U, 0x6AB020F2U, 0xF3B97148U, 0x84BE41DEU, 0x1ADAD47DU, 0x6DDDE4EBU, 0xF4D4B551U, 0x83D385C7U, - 0x136C9856U, 0x646BA8C0U, 0xFD62F97AU, 0x8A65C9ECU, 0x14015C4FU, 0x63066CD9U, 0xFA0F3D63U, 0x8D080DF5U, - 0x3B6E20C8U, 0x4C69105EU, 0xD56041E4U, 0xA2677172U, 0x3C03E4D1U, 0x4B04D447U, 0xD20D85FDU, 0xA50AB56BU, - 0x35B5A8FAU, 0x42B2986CU, 0xDBBBC9D6U, 0xACBCF940U, 0x32D86CE3U, 0x45DF5C75U, 0xDCD60DCFU, 0xABD13D59U, - 0x26D930ACU, 0x51DE003AU, 0xC8D75180U, 0xBFD06116U, 0x21B4F4B5U, 0x56B3C423U, 0xCFBA9599U, 0xB8BDA50FU, - 0x2802B89EU, 0x5F058808U, 0xC60CD9B2U, 0xB10BE924U, 0x2F6F7C87U, 0x58684C11U, 0xC1611DABU, 0xB6662D3DU, - 0x76DC4190U, 0x01DB7106U, 0x98D220BCU, 0xEFD5102AU, 0x71B18589U, 0x06B6B51FU, 0x9FBFE4A5U, 0xE8B8D433U, - 0x7807C9A2U, 0x0F00F934U, 0x9609A88EU, 0xE10E9818U, 0x7F6A0DBBU, 0x086D3D2DU, 0x91646C97U, 0xE6635C01U, - 0x6B6B51F4U, 0x1C6C6162U, 0x856530D8U, 0xF262004EU, 0x6C0695EDU, 0x1B01A57BU, 0x8208F4C1U, 0xF50FC457U, - 0x65B0D9C6U, 0x12B7E950U, 0x8BBEB8EAU, 0xFCB9887CU, 0x62DD1DDFU, 0x15DA2D49U, 0x8CD37CF3U, 0xFBD44C65U, - 0x4DB26158U, 0x3AB551CEU, 0xA3BC0074U, 0xD4BB30E2U, 0x4ADFA541U, 0x3DD895D7U, 0xA4D1C46DU, 0xD3D6F4FBU, - 0x4369E96AU, 0x346ED9FCU, 0xAD678846U, 0xDA60B8D0U, 0x44042D73U, 0x33031DE5U, 0xAA0A4C5FU, 0xDD0D7CC9U, - 0x5005713CU, 0x270241AAU, 0xBE0B1010U, 0xC90C2086U, 0x5768B525U, 0x206F85B3U, 0xB966D409U, 0xCE61E49FU, - 0x5EDEF90EU, 0x29D9C998U, 0xB0D09822U, 0xC7D7A8B4U, 0x59B33D17U, 0x2EB40D81U, 0xB7BD5C3BU, 0xC0BA6CADU, - 0xEDB88320U, 0x9ABFB3B6U, 0x03B6E20CU, 0x74B1D29AU, 0xEAD54739U, 0x9DD277AFU, 0x04DB2615U, 0x73DC1683U, - 0xE3630B12U, 0x94643B84U, 0x0D6D6A3EU, 0x7A6A5AA8U, 0xE40ECF0BU, 0x9309FF9DU, 0x0A00AE27U, 0x7D079EB1U, - 0xF00F9344U, 0x8708A3D2U, 0x1E01F268U, 0x6906C2FEU, 0xF762575DU, 0x806567CBU, 0x196C3671U, 0x6E6B06E7U, - 0xFED41B76U, 0x89D32BE0U, 0x10DA7A5AU, 0x67DD4ACCU, 0xF9B9DF6FU, 0x8EBEEFF9U, 0x17B7BE43U, 0x60B08ED5U, - 0xD6D6A3E8U, 0xA1D1937EU, 0x38D8C2C4U, 0x4FDFF252U, 0xD1BB67F1U, 0xA6BC5767U, 0x3FB506DDU, 0x48B2364BU, - 0xD80D2BDAU, 0xAF0A1B4CU, 0x36034AF6U, 0x41047A60U, 0xDF60EFC3U, 0xA867DF55U, 0x316E8EEFU, 0x4669BE79U, - 0xCB61B38CU, 0xBC66831AU, 0x256FD2A0U, 0x5268E236U, 0xCC0C7795U, 0xBB0B4703U, 0x220216B9U, 0x5505262FU, - 0xC5BA3BBEU, 0xB2BD0B28U, 0x2BB45A92U, 0x5CB36A04U, 0xC2D7FFA7U, 0xB5D0CF31U, 0x2CD99E8BU, 0x5BDEAE1DU, - 0x9B64C2B0U, 0xEC63F226U, 0x756AA39CU, 0x026D930AU, 0x9C0906A9U, 0xEB0E363FU, 0x72076785U, 0x05005713U, - 0x95BF4A82U, 0xE2B87A14U, 0x7BB12BAEU, 0x0CB61B38U, 0x92D28E9BU, 0xE5D5BE0DU, 0x7CDCEFB7U, 0x0BDBDF21U, - 0x86D3D2D4U, 0xF1D4E242U, 0x68DDB3F8U, 0x1FDA836EU, 0x81BE16CDU, 0xF6B9265BU, 0x6FB077E1U, 0x18B74777U, - 0x88085AE6U, 0xFF0F6A70U, 0x66063BCAU, 0x11010B5CU, 0x8F659EFFU, 0xF862AE69U, 0x616BFFD3U, 0x166CCF45U, - 0xA00AE278U, 0xD70DD2EEU, 0x4E048354U, 0x3903B3C2U, 0xA7672661U, 0xD06016F7U, 0x4969474DU, 0x3E6E77DBU, - 0xAED16A4AU, 0xD9D65ADCU, 0x40DF0B66U, 0x37D83BF0U, 0xA9BCAE53U, 0xDEBB9EC5U, 0x47B2CF7FU, 0x30B5FFE9U, - 0xBDBDF21CU, 0xCABAC28AU, 0x53B39330U, 0x24B4A3A6U, 0xBAD03605U, 0xCDD70693U, 0x54DE5729U, 0x23D967BFU, - 0xB3667A2EU, 0xC4614AB8U, 0x5D681B02U, 0x2A6F2B94U, 0xB40BBE37U, 0xC30C8EA1U, 0x5A05DF1BU, 0x2D02EF8DU, - }; - - uint32_t ulCrc32; - - if(pBuffer == NULL) - { - REDERROR(); - ulCrc32 = SUSPICIOUS_CRC_VALUE; - } - else - { - const uint8_t *pbBuffer = CAST_VOID_PTR_TO_CONST_UINT8_PTR(pBuffer); - uint32_t ulIdx; - - ulCrc32 = ~ulInitCrc32; - - for(ulIdx = 0U; ulIdx < ulLength; ++ulIdx) - { - ulCrc32 = (ulCrc32 >> 8U) ^ aulCrc32Table[(ulCrc32 ^ pbBuffer[ulIdx]) & 0xFFU]; - } - - ulCrc32 = ~ulCrc32; - } - - return ulCrc32; -} - -#elif REDCONF_CRC_ALGORITHM == CRC_SLICEBY8 - - -/** @brief Compute a CRC32 for the given data buffer. - - For CCITT-32 compliance, the initial CRC must be set to 0. To CRC multiple - buffers, call this function with the previously returned CRC value. - - @param ulInitCrc32 Starting CRC value. - @param pBuffer Data buffer to calculate the CRC from. - @param ulLength Number of bytes of data in the given buffer. - - @return The updated CRC value. -*/ -uint32_t RedCrc32Update( - uint32_t ulInitCrc32, - const void *pBuffer, - uint32_t ulLength) -{ - /* CRC32 XOR table, with slicing-by-8 extensions. - - This first column of the table contains the same XOR values as used in - the classic byte-at-a-time Sarwate algorithm. The other seven columns - are derived from the first, and are used in Intel's slicing-by-eight CRC - algorithm. - - The layout of this array in memory is novel and deserves explanation. - In other implementations, including Intel's example, each of the below - columns is an array. The first column is a 256-entry array, followed by - another 256-entry array for the second column, etc. Testing on both ARM - and x86 has shown the below mixed arrangement to be about 5-9% faster. - One possible explanation: With the array-per-table approach, each of the - eight table lookups is guaranteed to be in a separate 1 KB chunk of - memory. With the below array, sometimes multiple table lookups will, by - coincidence, be close together, making better use of the cache. - */ - static const uint32_t aulCrc32Table[] = - { - 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, - 0x77073096U, 0x191B3141U, 0x01C26A37U, 0xB8BC6765U, 0x3D6029B0U, 0xCB5CD3A5U, 0xA6770BB4U, 0xCCAA009EU, - 0xEE0E612CU, 0x32366282U, 0x0384D46EU, 0xAA09C88BU, 0x7AC05360U, 0x4DC8A10BU, 0x979F1129U, 0x4225077DU, - 0x990951BAU, 0x2B2D53C3U, 0x0246BE59U, 0x12B5AFEEU, 0x47A07AD0U, 0x869472AEU, 0x31E81A9DU, 0x8E8F07E3U, - 0x076DC419U, 0x646CC504U, 0x0709A8DCU, 0x8F629757U, 0xF580A6C0U, 0x9B914216U, 0xF44F2413U, 0x844A0EFAU, - 0x706AF48FU, 0x7D77F445U, 0x06CBC2EBU, 0x37DEF032U, 0xC8E08F70U, 0x50CD91B3U, 0x52382FA7U, 0x48E00E64U, - 0xE963A535U, 0x565AA786U, 0x048D7CB2U, 0x256B5FDCU, 0x8F40F5A0U, 0xD659E31DU, 0x63D0353AU, 0xC66F0987U, - 0x9E6495A3U, 0x4F4196C7U, 0x054F1685U, 0x9DD738B9U, 0xB220DC10U, 0x1D0530B8U, 0xC5A73E8EU, 0x0AC50919U, - 0x0EDB8832U, 0xC8D98A08U, 0x0E1351B8U, 0xC5B428EFU, 0x30704BC1U, 0xEC53826DU, 0x33EF4E67U, 0xD3E51BB5U, - 0x79DCB8A4U, 0xD1C2BB49U, 0x0FD13B8FU, 0x7D084F8AU, 0x0D106271U, 0x270F51C8U, 0x959845D3U, 0x1F4F1B2BU, - 0xE0D5E91EU, 0xFAEFE88AU, 0x0D9785D6U, 0x6FBDE064U, 0x4AB018A1U, 0xA19B2366U, 0xA4705F4EU, 0x91C01CC8U, - 0x97D2D988U, 0xE3F4D9CBU, 0x0C55EFE1U, 0xD7018701U, 0x77D03111U, 0x6AC7F0C3U, 0x020754FAU, 0x5D6A1C56U, - 0x09B64C2BU, 0xACB54F0CU, 0x091AF964U, 0x4AD6BFB8U, 0xC5F0ED01U, 0x77C2C07BU, 0xC7A06A74U, 0x57AF154FU, - 0x7EB17CBDU, 0xB5AE7E4DU, 0x08D89353U, 0xF26AD8DDU, 0xF890C4B1U, 0xBC9E13DEU, 0x61D761C0U, 0x9B0515D1U, - 0xE7B82D07U, 0x9E832D8EU, 0x0A9E2D0AU, 0xE0DF7733U, 0xBF30BE61U, 0x3A0A6170U, 0x503F7B5DU, 0x158A1232U, - 0x90BF1D91U, 0x87981CCFU, 0x0B5C473DU, 0x58631056U, 0x825097D1U, 0xF156B2D5U, 0xF64870E9U, 0xD92012ACU, - 0x1DB71064U, 0x4AC21251U, 0x1C26A370U, 0x5019579FU, 0x60E09782U, 0x03D6029BU, 0x67DE9CCEU, 0x7CBB312BU, - 0x6AB020F2U, 0x53D92310U, 0x1DE4C947U, 0xE8A530FAU, 0x5D80BE32U, 0xC88AD13EU, 0xC1A9977AU, 0xB01131B5U, - 0xF3B97148U, 0x78F470D3U, 0x1FA2771EU, 0xFA109F14U, 0x1A20C4E2U, 0x4E1EA390U, 0xF0418DE7U, 0x3E9E3656U, - 0x84BE41DEU, 0x61EF4192U, 0x1E601D29U, 0x42ACF871U, 0x2740ED52U, 0x85427035U, 0x56368653U, 0xF23436C8U, - 0x1ADAD47DU, 0x2EAED755U, 0x1B2F0BACU, 0xDF7BC0C8U, 0x95603142U, 0x9847408DU, 0x9391B8DDU, 0xF8F13FD1U, - 0x6DDDE4EBU, 0x37B5E614U, 0x1AED619BU, 0x67C7A7ADU, 0xA80018F2U, 0x531B9328U, 0x35E6B369U, 0x345B3F4FU, - 0xF4D4B551U, 0x1C98B5D7U, 0x18ABDFC2U, 0x75720843U, 0xEFA06222U, 0xD58FE186U, 0x040EA9F4U, 0xBAD438ACU, - 0x83D385C7U, 0x05838496U, 0x1969B5F5U, 0xCDCE6F26U, 0xD2C04B92U, 0x1ED33223U, 0xA279A240U, 0x767E3832U, - 0x136C9856U, 0x821B9859U, 0x1235F2C8U, 0x95AD7F70U, 0x5090DC43U, 0xEF8580F6U, 0x5431D2A9U, 0xAF5E2A9EU, - 0x646BA8C0U, 0x9B00A918U, 0x13F798FFU, 0x2D111815U, 0x6DF0F5F3U, 0x24D95353U, 0xF246D91DU, 0x63F42A00U, - 0xFD62F97AU, 0xB02DFADBU, 0x11B126A6U, 0x3FA4B7FBU, 0x2A508F23U, 0xA24D21FDU, 0xC3AEC380U, 0xED7B2DE3U, - 0x8A65C9ECU, 0xA936CB9AU, 0x10734C91U, 0x8718D09EU, 0x1730A693U, 0x6911F258U, 0x65D9C834U, 0x21D12D7DU, - 0x14015C4FU, 0xE6775D5DU, 0x153C5A14U, 0x1ACFE827U, 0xA5107A83U, 0x7414C2E0U, 0xA07EF6BAU, 0x2B142464U, - 0x63066CD9U, 0xFF6C6C1CU, 0x14FE3023U, 0xA2738F42U, 0x98705333U, 0xBF481145U, 0x0609FD0EU, 0xE7BE24FAU, - 0xFA0F3D63U, 0xD4413FDFU, 0x16B88E7AU, 0xB0C620ACU, 0xDFD029E3U, 0x39DC63EBU, 0x37E1E793U, 0x69312319U, - 0x8D080DF5U, 0xCD5A0E9EU, 0x177AE44DU, 0x087A47C9U, 0xE2B00053U, 0xF280B04EU, 0x9196EC27U, 0xA59B2387U, - 0x3B6E20C8U, 0x958424A2U, 0x384D46E0U, 0xA032AF3EU, 0xC1C12F04U, 0x07AC0536U, 0xCFBD399CU, 0xF9766256U, - 0x4C69105EU, 0x8C9F15E3U, 0x398F2CD7U, 0x188EC85BU, 0xFCA106B4U, 0xCCF0D693U, 0x69CA3228U, 0x35DC62C8U, - 0xD56041E4U, 0xA7B24620U, 0x3BC9928EU, 0x0A3B67B5U, 0xBB017C64U, 0x4A64A43DU, 0x582228B5U, 0xBB53652BU, - 0xA2677172U, 0xBEA97761U, 0x3A0BF8B9U, 0xB28700D0U, 0x866155D4U, 0x81387798U, 0xFE552301U, 0x77F965B5U, - 0x3C03E4D1U, 0xF1E8E1A6U, 0x3F44EE3CU, 0x2F503869U, 0x344189C4U, 0x9C3D4720U, 0x3BF21D8FU, 0x7D3C6CACU, - 0x4B04D447U, 0xE8F3D0E7U, 0x3E86840BU, 0x97EC5F0CU, 0x0921A074U, 0x57619485U, 0x9D85163BU, 0xB1966C32U, - 0xD20D85FDU, 0xC3DE8324U, 0x3CC03A52U, 0x8559F0E2U, 0x4E81DAA4U, 0xD1F5E62BU, 0xAC6D0CA6U, 0x3F196BD1U, - 0xA50AB56BU, 0xDAC5B265U, 0x3D025065U, 0x3DE59787U, 0x73E1F314U, 0x1AA9358EU, 0x0A1A0712U, 0xF3B36B4FU, - 0x35B5A8FAU, 0x5D5DAEAAU, 0x365E1758U, 0x658687D1U, 0xF1B164C5U, 0xEBFF875BU, 0xFC5277FBU, 0x2A9379E3U, - 0x42B2986CU, 0x44469FEBU, 0x379C7D6FU, 0xDD3AE0B4U, 0xCCD14D75U, 0x20A354FEU, 0x5A257C4FU, 0xE639797DU, - 0xDBBBC9D6U, 0x6F6BCC28U, 0x35DAC336U, 0xCF8F4F5AU, 0x8B7137A5U, 0xA6372650U, 0x6BCD66D2U, 0x68B67E9EU, - 0xACBCF940U, 0x7670FD69U, 0x3418A901U, 0x7733283FU, 0xB6111E15U, 0x6D6BF5F5U, 0xCDBA6D66U, 0xA41C7E00U, - 0x32D86CE3U, 0x39316BAEU, 0x3157BF84U, 0xEAE41086U, 0x0431C205U, 0x706EC54DU, 0x081D53E8U, 0xAED97719U, - 0x45DF5C75U, 0x202A5AEFU, 0x3095D5B3U, 0x525877E3U, 0x3951EBB5U, 0xBB3216E8U, 0xAE6A585CU, 0x62737787U, - 0xDCD60DCFU, 0x0B07092CU, 0x32D36BEAU, 0x40EDD80DU, 0x7EF19165U, 0x3DA66446U, 0x9F8242C1U, 0xECFC7064U, - 0xABD13D59U, 0x121C386DU, 0x331101DDU, 0xF851BF68U, 0x4391B8D5U, 0xF6FAB7E3U, 0x39F54975U, 0x205670FAU, - 0x26D930ACU, 0xDF4636F3U, 0x246BE590U, 0xF02BF8A1U, 0xA121B886U, 0x047A07ADU, 0xA863A552U, 0x85CD537DU, - 0x51DE003AU, 0xC65D07B2U, 0x25A98FA7U, 0x48979FC4U, 0x9C419136U, 0xCF26D408U, 0x0E14AEE6U, 0x496753E3U, - 0xC8D75180U, 0xED705471U, 0x27EF31FEU, 0x5A22302AU, 0xDBE1EBE6U, 0x49B2A6A6U, 0x3FFCB47BU, 0xC7E85400U, - 0xBFD06116U, 0xF46B6530U, 0x262D5BC9U, 0xE29E574FU, 0xE681C256U, 0x82EE7503U, 0x998BBFCFU, 0x0B42549EU, - 0x21B4F4B5U, 0xBB2AF3F7U, 0x23624D4CU, 0x7F496FF6U, 0x54A11E46U, 0x9FEB45BBU, 0x5C2C8141U, 0x01875D87U, - 0x56B3C423U, 0xA231C2B6U, 0x22A0277BU, 0xC7F50893U, 0x69C137F6U, 0x54B7961EU, 0xFA5B8AF5U, 0xCD2D5D19U, - 0xCFBA9599U, 0x891C9175U, 0x20E69922U, 0xD540A77DU, 0x2E614D26U, 0xD223E4B0U, 0xCBB39068U, 0x43A25AFAU, - 0xB8BDA50FU, 0x9007A034U, 0x2124F315U, 0x6DFCC018U, 0x13016496U, 0x197F3715U, 0x6DC49BDCU, 0x8F085A64U, - 0x2802B89EU, 0x179FBCFBU, 0x2A78B428U, 0x359FD04EU, 0x9151F347U, 0xE82985C0U, 0x9B8CEB35U, 0x562848C8U, - 0x5F058808U, 0x0E848DBAU, 0x2BBADE1FU, 0x8D23B72BU, 0xAC31DAF7U, 0x23755665U, 0x3DFBE081U, 0x9A824856U, - 0xC60CD9B2U, 0x25A9DE79U, 0x29FC6046U, 0x9F9618C5U, 0xEB91A027U, 0xA5E124CBU, 0x0C13FA1CU, 0x140D4FB5U, - 0xB10BE924U, 0x3CB2EF38U, 0x283E0A71U, 0x272A7FA0U, 0xD6F18997U, 0x6EBDF76EU, 0xAA64F1A8U, 0xD8A74F2BU, - 0x2F6F7C87U, 0x73F379FFU, 0x2D711CF4U, 0xBAFD4719U, 0x64D15587U, 0x73B8C7D6U, 0x6FC3CF26U, 0xD2624632U, - 0x58684C11U, 0x6AE848BEU, 0x2CB376C3U, 0x0241207CU, 0x59B17C37U, 0xB8E41473U, 0xC9B4C492U, 0x1EC846ACU, - 0xC1611DABU, 0x41C51B7DU, 0x2EF5C89AU, 0x10F48F92U, 0x1E1106E7U, 0x3E7066DDU, 0xF85CDE0FU, 0x9047414FU, - 0xB6662D3DU, 0x58DE2A3CU, 0x2F37A2ADU, 0xA848E8F7U, 0x23712F57U, 0xF52CB578U, 0x5E2BD5BBU, 0x5CED41D1U, - 0x76DC4190U, 0xF0794F05U, 0x709A8DC0U, 0x9B14583DU, 0x58F35849U, 0x0F580A6CU, 0x440B7579U, 0x299DC2EDU, - 0x01DB7106U, 0xE9627E44U, 0x7158E7F7U, 0x23A83F58U, 0x659371F9U, 0xC404D9C9U, 0xE27C7ECDU, 0xE537C273U, - 0x98D220BCU, 0xC24F2D87U, 0x731E59AEU, 0x311D90B6U, 0x22330B29U, 0x4290AB67U, 0xD3946450U, 0x6BB8C590U, - 0xEFD5102AU, 0xDB541CC6U, 0x72DC3399U, 0x89A1F7D3U, 0x1F532299U, 0x89CC78C2U, 0x75E36FE4U, 0xA712C50EU, - 0x71B18589U, 0x94158A01U, 0x7793251CU, 0x1476CF6AU, 0xAD73FE89U, 0x94C9487AU, 0xB044516AU, 0xADD7CC17U, - 0x06B6B51FU, 0x8D0EBB40U, 0x76514F2BU, 0xACCAA80FU, 0x9013D739U, 0x5F959BDFU, 0x16335ADEU, 0x617DCC89U, - 0x9FBFE4A5U, 0xA623E883U, 0x7417F172U, 0xBE7F07E1U, 0xD7B3ADE9U, 0xD901E971U, 0x27DB4043U, 0xEFF2CB6AU, - 0xE8B8D433U, 0xBF38D9C2U, 0x75D59B45U, 0x06C36084U, 0xEAD38459U, 0x125D3AD4U, 0x81AC4BF7U, 0x2358CBF4U, - 0x7807C9A2U, 0x38A0C50DU, 0x7E89DC78U, 0x5EA070D2U, 0x68831388U, 0xE30B8801U, 0x77E43B1EU, 0xFA78D958U, - 0x0F00F934U, 0x21BBF44CU, 0x7F4BB64FU, 0xE61C17B7U, 0x55E33A38U, 0x28575BA4U, 0xD19330AAU, 0x36D2D9C6U, - 0x9609A88EU, 0x0A96A78FU, 0x7D0D0816U, 0xF4A9B859U, 0x124340E8U, 0xAEC3290AU, 0xE07B2A37U, 0xB85DDE25U, - 0xE10E9818U, 0x138D96CEU, 0x7CCF6221U, 0x4C15DF3CU, 0x2F236958U, 0x659FFAAFU, 0x460C2183U, 0x74F7DEBBU, - 0x7F6A0DBBU, 0x5CCC0009U, 0x798074A4U, 0xD1C2E785U, 0x9D03B548U, 0x789ACA17U, 0x83AB1F0DU, 0x7E32D7A2U, - 0x086D3D2DU, 0x45D73148U, 0x78421E93U, 0x697E80E0U, 0xA0639CF8U, 0xB3C619B2U, 0x25DC14B9U, 0xB298D73CU, - 0x91646C97U, 0x6EFA628BU, 0x7A04A0CAU, 0x7BCB2F0EU, 0xE7C3E628U, 0x35526B1CU, 0x14340E24U, 0x3C17D0DFU, - 0xE6635C01U, 0x77E153CAU, 0x7BC6CAFDU, 0xC377486BU, 0xDAA3CF98U, 0xFE0EB8B9U, 0xB2430590U, 0xF0BDD041U, - 0x6B6B51F4U, 0xBABB5D54U, 0x6CBC2EB0U, 0xCB0D0FA2U, 0x3813CFCBU, 0x0C8E08F7U, 0x23D5E9B7U, 0x5526F3C6U, - 0x1C6C6162U, 0xA3A06C15U, 0x6D7E4487U, 0x73B168C7U, 0x0573E67BU, 0xC7D2DB52U, 0x85A2E203U, 0x998CF358U, - 0x856530D8U, 0x888D3FD6U, 0x6F38FADEU, 0x6104C729U, 0x42D39CABU, 0x4146A9FCU, 0xB44AF89EU, 0x1703F4BBU, - 0xF262004EU, 0x91960E97U, 0x6EFA90E9U, 0xD9B8A04CU, 0x7FB3B51BU, 0x8A1A7A59U, 0x123DF32AU, 0xDBA9F425U, - 0x6C0695EDU, 0xDED79850U, 0x6BB5866CU, 0x446F98F5U, 0xCD93690BU, 0x971F4AE1U, 0xD79ACDA4U, 0xD16CFD3CU, - 0x1B01A57BU, 0xC7CCA911U, 0x6A77EC5BU, 0xFCD3FF90U, 0xF0F340BBU, 0x5C439944U, 0x71EDC610U, 0x1DC6FDA2U, - 0x8208F4C1U, 0xECE1FAD2U, 0x68315202U, 0xEE66507EU, 0xB7533A6BU, 0xDAD7EBEAU, 0x4005DC8DU, 0x9349FA41U, - 0xF50FC457U, 0xF5FACB93U, 0x69F33835U, 0x56DA371BU, 0x8A3313DBU, 0x118B384FU, 0xE672D739U, 0x5FE3FADFU, - 0x65B0D9C6U, 0x7262D75CU, 0x62AF7F08U, 0x0EB9274DU, 0x0863840AU, 0xE0DD8A9AU, 0x103AA7D0U, 0x86C3E873U, - 0x12B7E950U, 0x6B79E61DU, 0x636D153FU, 0xB6054028U, 0x3503ADBAU, 0x2B81593FU, 0xB64DAC64U, 0x4A69E8EDU, - 0x8BBEB8EAU, 0x4054B5DEU, 0x612BAB66U, 0xA4B0EFC6U, 0x72A3D76AU, 0xAD152B91U, 0x87A5B6F9U, 0xC4E6EF0EU, - 0xFCB9887CU, 0x594F849FU, 0x60E9C151U, 0x1C0C88A3U, 0x4FC3FEDAU, 0x6649F834U, 0x21D2BD4DU, 0x084CEF90U, - 0x62DD1DDFU, 0x160E1258U, 0x65A6D7D4U, 0x81DBB01AU, 0xFDE322CAU, 0x7B4CC88CU, 0xE47583C3U, 0x0289E689U, - 0x15DA2D49U, 0x0F152319U, 0x6464BDE3U, 0x3967D77FU, 0xC0830B7AU, 0xB0101B29U, 0x42028877U, 0xCE23E617U, - 0x8CD37CF3U, 0x243870DAU, 0x662203BAU, 0x2BD27891U, 0x872371AAU, 0x36846987U, 0x73EA92EAU, 0x40ACE1F4U, - 0xFBD44C65U, 0x3D23419BU, 0x67E0698DU, 0x936E1FF4U, 0xBA43581AU, 0xFDD8BA22U, 0xD59D995EU, 0x8C06E16AU, - 0x4DB26158U, 0x65FD6BA7U, 0x48D7CB20U, 0x3B26F703U, 0x9932774DU, 0x08F40F5AU, 0x8BB64CE5U, 0xD0EBA0BBU, - 0x3AB551CEU, 0x7CE65AE6U, 0x4915A117U, 0x839A9066U, 0xA4525EFDU, 0xC3A8DCFFU, 0x2DC14751U, 0x1C41A025U, - 0xA3BC0074U, 0x57CB0925U, 0x4B531F4EU, 0x912F3F88U, 0xE3F2242DU, 0x453CAE51U, 0x1C295DCCU, 0x92CEA7C6U, - 0xD4BB30E2U, 0x4ED03864U, 0x4A917579U, 0x299358EDU, 0xDE920D9DU, 0x8E607DF4U, 0xBA5E5678U, 0x5E64A758U, - 0x4ADFA541U, 0x0191AEA3U, 0x4FDE63FCU, 0xB4446054U, 0x6CB2D18DU, 0x93654D4CU, 0x7FF968F6U, 0x54A1AE41U, - 0x3DD895D7U, 0x188A9FE2U, 0x4E1C09CBU, 0x0CF80731U, 0x51D2F83DU, 0x58399EE9U, 0xD98E6342U, 0x980BAEDFU, - 0xA4D1C46DU, 0x33A7CC21U, 0x4C5AB792U, 0x1E4DA8DFU, 0x167282EDU, 0xDEADEC47U, 0xE86679DFU, 0x1684A93CU, - 0xD3D6F4FBU, 0x2ABCFD60U, 0x4D98DDA5U, 0xA6F1CFBAU, 0x2B12AB5DU, 0x15F13FE2U, 0x4E11726BU, 0xDA2EA9A2U, - 0x4369E96AU, 0xAD24E1AFU, 0x46C49A98U, 0xFE92DFECU, 0xA9423C8CU, 0xE4A78D37U, 0xB8590282U, 0x030EBB0EU, - 0x346ED9FCU, 0xB43FD0EEU, 0x4706F0AFU, 0x462EB889U, 0x9422153CU, 0x2FFB5E92U, 0x1E2E0936U, 0xCFA4BB90U, - 0xAD678846U, 0x9F12832DU, 0x45404EF6U, 0x549B1767U, 0xD3826FECU, 0xA96F2C3CU, 0x2FC613ABU, 0x412BBC73U, - 0xDA60B8D0U, 0x8609B26CU, 0x448224C1U, 0xEC277002U, 0xEEE2465CU, 0x6233FF99U, 0x89B1181FU, 0x8D81BCEDU, - 0x44042D73U, 0xC94824ABU, 0x41CD3244U, 0x71F048BBU, 0x5CC29A4CU, 0x7F36CF21U, 0x4C162691U, 0x8744B5F4U, - 0x33031DE5U, 0xD05315EAU, 0x400F5873U, 0xC94C2FDEU, 0x61A2B3FCU, 0xB46A1C84U, 0xEA612D25U, 0x4BEEB56AU, - 0xAA0A4C5FU, 0xFB7E4629U, 0x4249E62AU, 0xDBF98030U, 0x2602C92CU, 0x32FE6E2AU, 0xDB8937B8U, 0xC561B289U, - 0xDD0D7CC9U, 0xE2657768U, 0x438B8C1DU, 0x6345E755U, 0x1B62E09CU, 0xF9A2BD8FU, 0x7DFE3C0CU, 0x09CBB217U, - 0x5005713CU, 0x2F3F79F6U, 0x54F16850U, 0x6B3FA09CU, 0xF9D2E0CFU, 0x0B220DC1U, 0xEC68D02BU, 0xAC509190U, - 0x270241AAU, 0x362448B7U, 0x55330267U, 0xD383C7F9U, 0xC4B2C97FU, 0xC07EDE64U, 0x4A1FDB9FU, 0x60FA910EU, - 0xBE0B1010U, 0x1D091B74U, 0x5775BC3EU, 0xC1366817U, 0x8312B3AFU, 0x46EAACCAU, 0x7BF7C102U, 0xEE7596EDU, - 0xC90C2086U, 0x04122A35U, 0x56B7D609U, 0x798A0F72U, 0xBE729A1FU, 0x8DB67F6FU, 0xDD80CAB6U, 0x22DF9673U, - 0x5768B525U, 0x4B53BCF2U, 0x53F8C08CU, 0xE45D37CBU, 0x0C52460FU, 0x90B34FD7U, 0x1827F438U, 0x281A9F6AU, - 0x206F85B3U, 0x52488DB3U, 0x523AAABBU, 0x5CE150AEU, 0x31326FBFU, 0x5BEF9C72U, 0xBE50FF8CU, 0xE4B09FF4U, - 0xB966D409U, 0x7965DE70U, 0x507C14E2U, 0x4E54FF40U, 0x7692156FU, 0xDD7BEEDCU, 0x8FB8E511U, 0x6A3F9817U, - 0xCE61E49FU, 0x607EEF31U, 0x51BE7ED5U, 0xF6E89825U, 0x4BF23CDFU, 0x16273D79U, 0x29CFEEA5U, 0xA6959889U, - 0x5EDEF90EU, 0xE7E6F3FEU, 0x5AE239E8U, 0xAE8B8873U, 0xC9A2AB0EU, 0xE7718FACU, 0xDF879E4CU, 0x7FB58A25U, - 0x29D9C998U, 0xFEFDC2BFU, 0x5B2053DFU, 0x1637EF16U, 0xF4C282BEU, 0x2C2D5C09U, 0x79F095F8U, 0xB31F8ABBU, - 0xB0D09822U, 0xD5D0917CU, 0x5966ED86U, 0x048240F8U, 0xB362F86EU, 0xAAB92EA7U, 0x48188F65U, 0x3D908D58U, - 0xC7D7A8B4U, 0xCCCBA03DU, 0x58A487B1U, 0xBC3E279DU, 0x8E02D1DEU, 0x61E5FD02U, 0xEE6F84D1U, 0xF13A8DC6U, - 0x59B33D17U, 0x838A36FAU, 0x5DEB9134U, 0x21E91F24U, 0x3C220DCEU, 0x7CE0CDBAU, 0x2BC8BA5FU, 0xFBFF84DFU, - 0x2EB40D81U, 0x9A9107BBU, 0x5C29FB03U, 0x99557841U, 0x0142247EU, 0xB7BC1E1FU, 0x8DBFB1EBU, 0x37558441U, - 0xB7BD5C3BU, 0xB1BC5478U, 0x5E6F455AU, 0x8BE0D7AFU, 0x46E25EAEU, 0x31286CB1U, 0xBC57AB76U, 0xB9DA83A2U, - 0xC0BA6CADU, 0xA8A76539U, 0x5FAD2F6DU, 0x335CB0CAU, 0x7B82771EU, 0xFA74BF14U, 0x1A20A0C2U, 0x7570833CU, - 0xEDB88320U, 0x3B83984BU, 0xE1351B80U, 0xED59B63BU, 0xB1E6B092U, 0x1EB014D8U, 0x8816EAF2U, 0x533B85DAU, - 0x9ABFB3B6U, 0x2298A90AU, 0xE0F771B7U, 0x55E5D15EU, 0x8C869922U, 0xD5ECC77DU, 0x2E61E146U, 0x9F918544U, - 0x03B6E20CU, 0x09B5FAC9U, 0xE2B1CFEEU, 0x47507EB0U, 0xCB26E3F2U, 0x5378B5D3U, 0x1F89FBDBU, 0x111E82A7U, - 0x74B1D29AU, 0x10AECB88U, 0xE373A5D9U, 0xFFEC19D5U, 0xF646CA42U, 0x98246676U, 0xB9FEF06FU, 0xDDB48239U, - 0xEAD54739U, 0x5FEF5D4FU, 0xE63CB35CU, 0x623B216CU, 0x44661652U, 0x852156CEU, 0x7C59CEE1U, 0xD7718B20U, - 0x9DD277AFU, 0x46F46C0EU, 0xE7FED96BU, 0xDA874609U, 0x79063FE2U, 0x4E7D856BU, 0xDA2EC555U, 0x1BDB8BBEU, - 0x04DB2615U, 0x6DD93FCDU, 0xE5B86732U, 0xC832E9E7U, 0x3EA64532U, 0xC8E9F7C5U, 0xEBC6DFC8U, 0x95548C5DU, - 0x73DC1683U, 0x74C20E8CU, 0xE47A0D05U, 0x708E8E82U, 0x03C66C82U, 0x03B52460U, 0x4DB1D47CU, 0x59FE8CC3U, - 0xE3630B12U, 0xF35A1243U, 0xEF264A38U, 0x28ED9ED4U, 0x8196FB53U, 0xF2E396B5U, 0xBBF9A495U, 0x80DE9E6FU, - 0x94643B84U, 0xEA412302U, 0xEEE4200FU, 0x9051F9B1U, 0xBCF6D2E3U, 0x39BF4510U, 0x1D8EAF21U, 0x4C749EF1U, - 0x0D6D6A3EU, 0xC16C70C1U, 0xECA29E56U, 0x82E4565FU, 0xFB56A833U, 0xBF2B37BEU, 0x2C66B5BCU, 0xC2FB9912U, - 0x7A6A5AA8U, 0xD8774180U, 0xED60F461U, 0x3A58313AU, 0xC6368183U, 0x7477E41BU, 0x8A11BE08U, 0x0E51998CU, - 0xE40ECF0BU, 0x9736D747U, 0xE82FE2E4U, 0xA78F0983U, 0x74165D93U, 0x6972D4A3U, 0x4FB68086U, 0x04949095U, - 0x9309FF9DU, 0x8E2DE606U, 0xE9ED88D3U, 0x1F336EE6U, 0x49767423U, 0xA22E0706U, 0xE9C18B32U, 0xC83E900BU, - 0x0A00AE27U, 0xA500B5C5U, 0xEBAB368AU, 0x0D86C108U, 0x0ED60EF3U, 0x24BA75A8U, 0xD82991AFU, 0x46B197E8U, - 0x7D079EB1U, 0xBC1B8484U, 0xEA695CBDU, 0xB53AA66DU, 0x33B62743U, 0xEFE6A60DU, 0x7E5E9A1BU, 0x8A1B9776U, - 0xF00F9344U, 0x71418A1AU, 0xFD13B8F0U, 0xBD40E1A4U, 0xD1062710U, 0x1D661643U, 0xEFC8763CU, 0x2F80B4F1U, - 0x8708A3D2U, 0x685ABB5BU, 0xFCD1D2C7U, 0x05FC86C1U, 0xEC660EA0U, 0xD63AC5E6U, 0x49BF7D88U, 0xE32AB46FU, - 0x1E01F268U, 0x4377E898U, 0xFE976C9EU, 0x1749292FU, 0xABC67470U, 0x50AEB748U, 0x78576715U, 0x6DA5B38CU, - 0x6906C2FEU, 0x5A6CD9D9U, 0xFF5506A9U, 0xAFF54E4AU, 0x96A65DC0U, 0x9BF264EDU, 0xDE206CA1U, 0xA10FB312U, - 0xF762575DU, 0x152D4F1EU, 0xFA1A102CU, 0x322276F3U, 0x248681D0U, 0x86F75455U, 0x1B87522FU, 0xABCABA0BU, - 0x806567CBU, 0x0C367E5FU, 0xFBD87A1BU, 0x8A9E1196U, 0x19E6A860U, 0x4DAB87F0U, 0xBDF0599BU, 0x6760BA95U, - 0x196C3671U, 0x271B2D9CU, 0xF99EC442U, 0x982BBE78U, 0x5E46D2B0U, 0xCB3FF55EU, 0x8C184306U, 0xE9EFBD76U, - 0x6E6B06E7U, 0x3E001CDDU, 0xF85CAE75U, 0x2097D91DU, 0x6326FB00U, 0x006326FBU, 0x2A6F48B2U, 0x2545BDE8U, - 0xFED41B76U, 0xB9980012U, 0xF300E948U, 0x78F4C94BU, 0xE1766CD1U, 0xF135942EU, 0xDC27385BU, 0xFC65AF44U, - 0x89D32BE0U, 0xA0833153U, 0xF2C2837FU, 0xC048AE2EU, 0xDC164561U, 0x3A69478BU, 0x7A5033EFU, 0x30CFAFDAU, - 0x10DA7A5AU, 0x8BAE6290U, 0xF0843D26U, 0xD2FD01C0U, 0x9BB63FB1U, 0xBCFD3525U, 0x4BB82972U, 0xBE40A839U, - 0x67DD4ACCU, 0x92B553D1U, 0xF1465711U, 0x6A4166A5U, 0xA6D61601U, 0x77A1E680U, 0xEDCF22C6U, 0x72EAA8A7U, - 0xF9B9DF6FU, 0xDDF4C516U, 0xF4094194U, 0xF7965E1CU, 0x14F6CA11U, 0x6AA4D638U, 0x28681C48U, 0x782FA1BEU, - 0x8EBEEFF9U, 0xC4EFF457U, 0xF5CB2BA3U, 0x4F2A3979U, 0x2996E3A1U, 0xA1F8059DU, 0x8E1F17FCU, 0xB485A120U, - 0x17B7BE43U, 0xEFC2A794U, 0xF78D95FAU, 0x5D9F9697U, 0x6E369971U, 0x276C7733U, 0xBFF70D61U, 0x3A0AA6C3U, - 0x60B08ED5U, 0xF6D996D5U, 0xF64FFFCDU, 0xE523F1F2U, 0x5356B0C1U, 0xEC30A496U, 0x198006D5U, 0xF6A0A65DU, - 0xD6D6A3E8U, 0xAE07BCE9U, 0xD9785D60U, 0x4D6B1905U, 0x70279F96U, 0x191C11EEU, 0x47ABD36EU, 0xAA4DE78CU, - 0xA1D1937EU, 0xB71C8DA8U, 0xD8BA3757U, 0xF5D77E60U, 0x4D47B626U, 0xD240C24BU, 0xE1DCD8DAU, 0x66E7E712U, - 0x38D8C2C4U, 0x9C31DE6BU, 0xDAFC890EU, 0xE762D18EU, 0x0AE7CCF6U, 0x54D4B0E5U, 0xD034C247U, 0xE868E0F1U, - 0x4FDFF252U, 0x852AEF2AU, 0xDB3EE339U, 0x5FDEB6EBU, 0x3787E546U, 0x9F886340U, 0x7643C9F3U, 0x24C2E06FU, - 0xD1BB67F1U, 0xCA6B79EDU, 0xDE71F5BCU, 0xC2098E52U, 0x85A73956U, 0x828D53F8U, 0xB3E4F77DU, 0x2E07E976U, - 0xA6BC5767U, 0xD37048ACU, 0xDFB39F8BU, 0x7AB5E937U, 0xB8C710E6U, 0x49D1805DU, 0x1593FCC9U, 0xE2ADE9E8U, - 0x3FB506DDU, 0xF85D1B6FU, 0xDDF521D2U, 0x680046D9U, 0xFF676A36U, 0xCF45F2F3U, 0x247BE654U, 0x6C22EE0BU, - 0x48B2364BU, 0xE1462A2EU, 0xDC374BE5U, 0xD0BC21BCU, 0xC2074386U, 0x04192156U, 0x820CEDE0U, 0xA088EE95U, - 0xD80D2BDAU, 0x66DE36E1U, 0xD76B0CD8U, 0x88DF31EAU, 0x4057D457U, 0xF54F9383U, 0x74449D09U, 0x79A8FC39U, - 0xAF0A1B4CU, 0x7FC507A0U, 0xD6A966EFU, 0x3063568FU, 0x7D37FDE7U, 0x3E134026U, 0xD23396BDU, 0xB502FCA7U, - 0x36034AF6U, 0x54E85463U, 0xD4EFD8B6U, 0x22D6F961U, 0x3A978737U, 0xB8873288U, 0xE3DB8C20U, 0x3B8DFB44U, - 0x41047A60U, 0x4DF36522U, 0xD52DB281U, 0x9A6A9E04U, 0x07F7AE87U, 0x73DBE12DU, 0x45AC8794U, 0xF727FBDAU, - 0xDF60EFC3U, 0x02B2F3E5U, 0xD062A404U, 0x07BDA6BDU, 0xB5D77297U, 0x6EDED195U, 0x800BB91AU, 0xFDE2F2C3U, - 0xA867DF55U, 0x1BA9C2A4U, 0xD1A0CE33U, 0xBF01C1D8U, 0x88B75B27U, 0xA5820230U, 0x267CB2AEU, 0x3148F25DU, - 0x316E8EEFU, 0x30849167U, 0xD3E6706AU, 0xADB46E36U, 0xCF1721F7U, 0x2316709EU, 0x1794A833U, 0xBFC7F5BEU, - 0x4669BE79U, 0x299FA026U, 0xD2241A5DU, 0x15080953U, 0xF2770847U, 0xE84AA33BU, 0xB1E3A387U, 0x736DF520U, - 0xCB61B38CU, 0xE4C5AEB8U, 0xC55EFE10U, 0x1D724E9AU, 0x10C70814U, 0x1ACA1375U, 0x20754FA0U, 0xD6F6D6A7U, - 0xBC66831AU, 0xFDDE9FF9U, 0xC49C9427U, 0xA5CE29FFU, 0x2DA721A4U, 0xD196C0D0U, 0x86024414U, 0x1A5CD639U, - 0x256FD2A0U, 0xD6F3CC3AU, 0xC6DA2A7EU, 0xB77B8611U, 0x6A075B74U, 0x5702B27EU, 0xB7EA5E89U, 0x94D3D1DAU, - 0x5268E236U, 0xCFE8FD7BU, 0xC7184049U, 0x0FC7E174U, 0x576772C4U, 0x9C5E61DBU, 0x119D553DU, 0x5879D144U, - 0xCC0C7795U, 0x80A96BBCU, 0xC25756CCU, 0x9210D9CDU, 0xE547AED4U, 0x815B5163U, 0xD43A6BB3U, 0x52BCD85DU, - 0xBB0B4703U, 0x99B25AFDU, 0xC3953CFBU, 0x2AACBEA8U, 0xD8278764U, 0x4A0782C6U, 0x724D6007U, 0x9E16D8C3U, - 0x220216B9U, 0xB29F093EU, 0xC1D382A2U, 0x38191146U, 0x9F87FDB4U, 0xCC93F068U, 0x43A57A9AU, 0x1099DF20U, - 0x5505262FU, 0xAB84387FU, 0xC011E895U, 0x80A57623U, 0xA2E7D404U, 0x07CF23CDU, 0xE5D2712EU, 0xDC33DFBEU, - 0xC5BA3BBEU, 0x2C1C24B0U, 0xCB4DAFA8U, 0xD8C66675U, 0x20B743D5U, 0xF6999118U, 0x139A01C7U, 0x0513CD12U, - 0xB2BD0B28U, 0x350715F1U, 0xCA8FC59FU, 0x607A0110U, 0x1DD76A65U, 0x3DC542BDU, 0xB5ED0A73U, 0xC9B9CD8CU, - 0x2BB45A92U, 0x1E2A4632U, 0xC8C97BC6U, 0x72CFAEFEU, 0x5A7710B5U, 0xBB513013U, 0x840510EEU, 0x4736CA6FU, - 0x5CB36A04U, 0x07317773U, 0xC90B11F1U, 0xCA73C99BU, 0x67173905U, 0x700DE3B6U, 0x22721B5AU, 0x8B9CCAF1U, - 0xC2D7FFA7U, 0x4870E1B4U, 0xCC440774U, 0x57A4F122U, 0xD537E515U, 0x6D08D30EU, 0xE7D525D4U, 0x8159C3E8U, - 0xB5D0CF31U, 0x516BD0F5U, 0xCD866D43U, 0xEF189647U, 0xE857CCA5U, 0xA65400ABU, 0x41A22E60U, 0x4DF3C376U, - 0x2CD99E8BU, 0x7A468336U, 0xCFC0D31AU, 0xFDAD39A9U, 0xAFF7B675U, 0x20C07205U, 0x704A34FDU, 0xC37CC495U, - 0x5BDEAE1DU, 0x635DB277U, 0xCE02B92DU, 0x45115ECCU, 0x92979FC5U, 0xEB9CA1A0U, 0xD63D3F49U, 0x0FD6C40BU, - 0x9B64C2B0U, 0xCBFAD74EU, 0x91AF9640U, 0x764DEE06U, 0xE915E8DBU, 0x11E81EB4U, 0xCC1D9F8BU, 0x7AA64737U, - 0xEC63F226U, 0xD2E1E60FU, 0x906DFC77U, 0xCEF18963U, 0xD475C16BU, 0xDAB4CD11U, 0x6A6A943FU, 0xB60C47A9U, - 0x756AA39CU, 0xF9CCB5CCU, 0x922B422EU, 0xDC44268DU, 0x93D5BBBBU, 0x5C20BFBFU, 0x5B828EA2U, 0x3883404AU, - 0x026D930AU, 0xE0D7848DU, 0x93E92819U, 0x64F841E8U, 0xAEB5920BU, 0x977C6C1AU, 0xFDF58516U, 0xF42940D4U, - 0x9C0906A9U, 0xAF96124AU, 0x96A63E9CU, 0xF92F7951U, 0x1C954E1BU, 0x8A795CA2U, 0x3852BB98U, 0xFEEC49CDU, - 0xEB0E363FU, 0xB68D230BU, 0x976454ABU, 0x41931E34U, 0x21F567ABU, 0x41258F07U, 0x9E25B02CU, 0x32464953U, - 0x72076785U, 0x9DA070C8U, 0x9522EAF2U, 0x5326B1DAU, 0x66551D7BU, 0xC7B1FDA9U, 0xAFCDAAB1U, 0xBCC94EB0U, - 0x05005713U, 0x84BB4189U, 0x94E080C5U, 0xEB9AD6BFU, 0x5B3534CBU, 0x0CED2E0CU, 0x09BAA105U, 0x70634E2EU, - 0x95BF4A82U, 0x03235D46U, 0x9FBCC7F8U, 0xB3F9C6E9U, 0xD965A31AU, 0xFDBB9CD9U, 0xFFF2D1ECU, 0xA9435C82U, - 0xE2B87A14U, 0x1A386C07U, 0x9E7EADCFU, 0x0B45A18CU, 0xE4058AAAU, 0x36E74F7CU, 0x5985DA58U, 0x65E95C1CU, - 0x7BB12BAEU, 0x31153FC4U, 0x9C381396U, 0x19F00E62U, 0xA3A5F07AU, 0xB0733DD2U, 0x686DC0C5U, 0xEB665BFFU, - 0x0CB61B38U, 0x280E0E85U, 0x9DFA79A1U, 0xA14C6907U, 0x9EC5D9CAU, 0x7B2FEE77U, 0xCE1ACB71U, 0x27CC5B61U, - 0x92D28E9BU, 0x674F9842U, 0x98B56F24U, 0x3C9B51BEU, 0x2CE505DAU, 0x662ADECFU, 0x0BBDF5FFU, 0x2D095278U, - 0xE5D5BE0DU, 0x7E54A903U, 0x99770513U, 0x842736DBU, 0x11852C6AU, 0xAD760D6AU, 0xADCAFE4BU, 0xE1A352E6U, - 0x7CDCEFB7U, 0x5579FAC0U, 0x9B31BB4AU, 0x96929935U, 0x562556BAU, 0x2BE27FC4U, 0x9C22E4D6U, 0x6F2C5505U, - 0x0BDBDF21U, 0x4C62CB81U, 0x9AF3D17DU, 0x2E2EFE50U, 0x6B457F0AU, 0xE0BEAC61U, 0x3A55EF62U, 0xA386559BU, - 0x86D3D2D4U, 0x8138C51FU, 0x8D893530U, 0x2654B999U, 0x89F57F59U, 0x123E1C2FU, 0xABC30345U, 0x061D761CU, - 0xF1D4E242U, 0x9823F45EU, 0x8C4B5F07U, 0x9EE8DEFCU, 0xB49556E9U, 0xD962CF8AU, 0x0DB408F1U, 0xCAB77682U, - 0x68DDB3F8U, 0xB30EA79DU, 0x8E0DE15EU, 0x8C5D7112U, 0xF3352C39U, 0x5FF6BD24U, 0x3C5C126CU, 0x44387161U, - 0x1FDA836EU, 0xAA1596DCU, 0x8FCF8B69U, 0x34E11677U, 0xCE550589U, 0x94AA6E81U, 0x9A2B19D8U, 0x889271FFU, - 0x81BE16CDU, 0xE554001BU, 0x8A809DECU, 0xA9362ECEU, 0x7C75D999U, 0x89AF5E39U, 0x5F8C2756U, 0x825778E6U, - 0xF6B9265BU, 0xFC4F315AU, 0x8B42F7DBU, 0x118A49ABU, 0x4115F029U, 0x42F38D9CU, 0xF9FB2CE2U, 0x4EFD7878U, - 0x6FB077E1U, 0xD7626299U, 0x89044982U, 0x033FE645U, 0x06B58AF9U, 0xC467FF32U, 0xC813367FU, 0xC0727F9BU, - 0x18B74777U, 0xCE7953D8U, 0x88C623B5U, 0xBB838120U, 0x3BD5A349U, 0x0F3B2C97U, 0x6E643DCBU, 0x0CD87F05U, - 0x88085AE6U, 0x49E14F17U, 0x839A6488U, 0xE3E09176U, 0xB9853498U, 0xFE6D9E42U, 0x982C4D22U, 0xD5F86DA9U, - 0xFF0F6A70U, 0x50FA7E56U, 0x82580EBFU, 0x5B5CF613U, 0x84E51D28U, 0x35314DE7U, 0x3E5B4696U, 0x19526D37U, - 0x66063BCAU, 0x7BD72D95U, 0x801EB0E6U, 0x49E959FDU, 0xC34567F8U, 0xB3A53F49U, 0x0FB35C0BU, 0x97DD6AD4U, - 0x11010B5CU, 0x62CC1CD4U, 0x81DCDAD1U, 0xF1553E98U, 0xFE254E48U, 0x78F9ECECU, 0xA9C457BFU, 0x5B776A4AU, - 0x8F659EFFU, 0x2D8D8A13U, 0x8493CC54U, 0x6C820621U, 0x4C059258U, 0x65FCDC54U, 0x6C636931U, 0x51B26353U, - 0xF862AE69U, 0x3496BB52U, 0x8551A663U, 0xD43E6144U, 0x7165BBE8U, 0xAEA00FF1U, 0xCA146285U, 0x9D1863CDU, - 0x616BFFD3U, 0x1FBBE891U, 0x8717183AU, 0xC68BCEAAU, 0x36C5C138U, 0x28347D5FU, 0xFBFC7818U, 0x1397642EU, - 0x166CCF45U, 0x06A0D9D0U, 0x86D5720DU, 0x7E37A9CFU, 0x0BA5E888U, 0xE368AEFAU, 0x5D8B73ACU, 0xDF3D64B0U, - 0xA00AE278U, 0x5E7EF3ECU, 0xA9E2D0A0U, 0xD67F4138U, 0x28D4C7DFU, 0x16441B82U, 0x03A0A617U, 0x83D02561U, - 0xD70DD2EEU, 0x4765C2ADU, 0xA820BA97U, 0x6EC3265DU, 0x15B4EE6FU, 0xDD18C827U, 0xA5D7ADA3U, 0x4F7A25FFU, - 0x4E048354U, 0x6C48916EU, 0xAA6604CEU, 0x7C7689B3U, 0x521494BFU, 0x5B8CBA89U, 0x943FB73EU, 0xC1F5221CU, - 0x3903B3C2U, 0x7553A02FU, 0xABA46EF9U, 0xC4CAEED6U, 0x6F74BD0FU, 0x90D0692CU, 0x3248BC8AU, 0x0D5F2282U, - 0xA7672661U, 0x3A1236E8U, 0xAEEB787CU, 0x591DD66FU, 0xDD54611FU, 0x8DD55994U, 0xF7EF8204U, 0x079A2B9BU, - 0xD06016F7U, 0x230907A9U, 0xAF29124BU, 0xE1A1B10AU, 0xE03448AFU, 0x46898A31U, 0x519889B0U, 0xCB302B05U, - 0x4969474DU, 0x0824546AU, 0xAD6FAC12U, 0xF3141EE4U, 0xA794327FU, 0xC01DF89FU, 0x6070932DU, 0x45BF2CE6U, - 0x3E6E77DBU, 0x113F652BU, 0xACADC625U, 0x4BA87981U, 0x9AF41BCFU, 0x0B412B3AU, 0xC6079899U, 0x89152C78U, - 0xAED16A4AU, 0x96A779E4U, 0xA7F18118U, 0x13CB69D7U, 0x18A48C1EU, 0xFA1799EFU, 0x304FE870U, 0x50353ED4U, - 0xD9D65ADCU, 0x8FBC48A5U, 0xA633EB2FU, 0xAB770EB2U, 0x25C4A5AEU, 0x314B4A4AU, 0x9638E3C4U, 0x9C9F3E4AU, - 0x40DF0B66U, 0xA4911B66U, 0xA4755576U, 0xB9C2A15CU, 0x6264DF7EU, 0xB7DF38E4U, 0xA7D0F959U, 0x121039A9U, - 0x37D83BF0U, 0xBD8A2A27U, 0xA5B73F41U, 0x017EC639U, 0x5F04F6CEU, 0x7C83EB41U, 0x01A7F2EDU, 0xDEBA3937U, - 0xA9BCAE53U, 0xF2CBBCE0U, 0xA0F829C4U, 0x9CA9FE80U, 0xED242ADEU, 0x6186DBF9U, 0xC400CC63U, 0xD47F302EU, - 0xDEBB9EC5U, 0xEBD08DA1U, 0xA13A43F3U, 0x241599E5U, 0xD044036EU, 0xAADA085CU, 0x6277C7D7U, 0x18D530B0U, - 0x47B2CF7FU, 0xC0FDDE62U, 0xA37CFDAAU, 0x36A0360BU, 0x97E479BEU, 0x2C4E7AF2U, 0x539FDD4AU, 0x965A3753U, - 0x30B5FFE9U, 0xD9E6EF23U, 0xA2BE979DU, 0x8E1C516EU, 0xAA84500EU, 0xE712A957U, 0xF5E8D6FEU, 0x5AF037CDU, - 0xBDBDF21CU, 0x14BCE1BDU, 0xB5C473D0U, 0x866616A7U, 0x4834505DU, 0x15921919U, 0x647E3AD9U, 0xFF6B144AU, - 0xCABAC28AU, 0x0DA7D0FCU, 0xB40619E7U, 0x3EDA71C2U, 0x755479EDU, 0xDECECABCU, 0xC209316DU, 0x33C114D4U, - 0x53B39330U, 0x268A833FU, 0xB640A7BEU, 0x2C6FDE2CU, 0x32F4033DU, 0x585AB812U, 0xF3E12BF0U, 0xBD4E1337U, - 0x24B4A3A6U, 0x3F91B27EU, 0xB782CD89U, 0x94D3B949U, 0x0F942A8DU, 0x93066BB7U, 0x55962044U, 0x71E413A9U, - 0xBAD03605U, 0x70D024B9U, 0xB2CDDB0CU, 0x090481F0U, 0xBDB4F69DU, 0x8E035B0FU, 0x90311ECAU, 0x7B211AB0U, - 0xCDD70693U, 0x69CB15F8U, 0xB30FB13BU, 0xB1B8E695U, 0x80D4DF2DU, 0x455F88AAU, 0x3646157EU, 0xB78B1A2EU, - 0x54DE5729U, 0x42E6463BU, 0xB1490F62U, 0xA30D497BU, 0xC774A5FDU, 0xC3CBFA04U, 0x07AE0FE3U, 0x39041DCDU, - 0x23D967BFU, 0x5BFD777AU, 0xB08B6555U, 0x1BB12E1EU, 0xFA148C4DU, 0x089729A1U, 0xA1D90457U, 0xF5AE1D53U, - 0xB3667A2EU, 0xDC656BB5U, 0xBBD72268U, 0x43D23E48U, 0x78441B9CU, 0xF9C19B74U, 0x579174BEU, 0x2C8E0FFFU, - 0xC4614AB8U, 0xC57E5AF4U, 0xBA15485FU, 0xFB6E592DU, 0x4524322CU, 0x329D48D1U, 0xF1E67F0AU, 0xE0240F61U, - 0x5D681B02U, 0xEE530937U, 0xB853F606U, 0xE9DBF6C3U, 0x028448FCU, 0xB4093A7FU, 0xC00E6597U, 0x6EAB0882U, - 0x2A6F2B94U, 0xF7483876U, 0xB9919C31U, 0x516791A6U, 0x3FE4614CU, 0x7F55E9DAU, 0x66796E23U, 0xA201081CU, - 0xB40BBE37U, 0xB809AEB1U, 0xBCDE8AB4U, 0xCCB0A91FU, 0x8DC4BD5CU, 0x6250D962U, 0xA3DE50ADU, 0xA8C40105U, - 0xC30C8EA1U, 0xA1129FF0U, 0xBD1CE083U, 0x740CCE7AU, 0xB0A494ECU, 0xA90C0AC7U, 0x05A95B19U, 0x646E019BU, - 0x5A05DF1BU, 0x8A3FCC33U, 0xBF5A5EDAU, 0x66B96194U, 0xF704EE3CU, 0x2F987869U, 0x34414184U, 0xEAE10678U, - 0x2D02EF8DU, 0x9324FD72U, 0xBE9834EDU, 0xDE0506F1U, 0xCA64C78CU, 0xE4C4ABCCU, 0x92364A30U, 0x264B06E6U, - }; - - uint32_t ulCrc32; - - if(pBuffer == NULL) - { - REDERROR(); - ulCrc32 = SUSPICIOUS_CRC_VALUE; - } - else - { - const uint8_t *pbBuffer = CAST_VOID_PTR_TO_CONST_UINT8_PTR(pBuffer); - uint32_t ulIdx = 0U; - const uint32_t *pulXorCrc0 = &aulCrc32Table[7U]; - const uint32_t *pulXorCrc1 = &aulCrc32Table[6U]; - const uint32_t *pulXorCrc2 = &aulCrc32Table[5U]; - const uint32_t *pulXorCrc3 = &aulCrc32Table[4U]; - const uint32_t *pulXorData4 = &aulCrc32Table[3U]; - const uint32_t *pulXorData5 = &aulCrc32Table[2U]; - const uint32_t *pulXorData6 = &aulCrc32Table[1U]; - const uint32_t *pulXorData7 = &aulCrc32Table[0U]; - uint32_t ulSliceLen; - - ulCrc32 = ~ulInitCrc32; - - /* Aligned memory access is used below. To avoid suboptimal - performance and faults (depending on platform), handle the - unaligned initial bytes (if any) using the Sarwate algorithm. - */ - while((ulIdx < ulLength) && !IS_ALIGNED_PTR(&pbBuffer[ulIdx])) - { - ulCrc32 = (ulCrc32 >> 8U) ^ aulCrc32Table[((ulCrc32 ^ pbBuffer[ulIdx]) & 0xFFU) << 3U]; - - ulIdx++; - } - - /* Round down the length to the nearest multiple of eight. - */ - ulSliceLen = (((ulLength - ulIdx) >> 3U) << 3U) + ulIdx; - - /* Compute the CRC in eight byte "slices". Takes advantage of - modern processors which can load in parallel from multiple - memory locations. - */ - while(ulIdx < ulSliceLen) - { - #if REDCONF_ENDIAN_BIG == 1 - ulCrc32 ^= pbBuffer[ulIdx] | ((uint32_t)pbBuffer[ulIdx+1U] << 8U) | - ((uint32_t)pbBuffer[ulIdx+2U] << 16U) | ((uint32_t)pbBuffer[ulIdx+3U] << 24U); - #else - ulCrc32 ^= *CAST_CONST_UINT32_PTR(&pbBuffer[ulIdx]); - #endif - - ulCrc32 = - pulXorCrc3[((ulCrc32 >> 24U) & 0xFFU) << 3U] ^ - pulXorCrc2[((ulCrc32 >> 16U) & 0xFFU) << 3U] ^ - pulXorCrc1[((ulCrc32 >> 8U) & 0xFFU) << 3U] ^ - pulXorCrc0[ (ulCrc32 & 0xFFU) << 3U] ^ - pulXorData7[pbBuffer[ulIdx+7U] << 3U] ^ - pulXorData6[pbBuffer[ulIdx+6U] << 3U] ^ - pulXorData5[pbBuffer[ulIdx+5U] << 3U] ^ - pulXorData4[pbBuffer[ulIdx+4U] << 3U]; - - ulIdx += 8U; - } - - /* Compute the remaining bytes with the Sarwate algorithm. - */ - while(ulIdx < ulLength) - { - ulCrc32 = (ulCrc32 >> 8U) ^ aulCrc32Table[((ulCrc32 ^ pbBuffer[ulIdx]) & 0xFFU) << 3U]; - - ulIdx++; - } - - ulCrc32 = ~ulCrc32; - } - - return ulCrc32; -} - -#else - -#error "REDCONF_CRC_ALGORITHM must be set to CRC_BITWISE, CRC_SARWATE, or CRC_SLICEBY8" - -#endif - - -/** @brief Compute a CRC32 for a metadata node buffer. - - @param pBuffer The metadata node buffer for which to compute a CRC. Must - be a block sized buffer. - - @return The CRC of the buffer. -*/ -uint32_t RedCrcNode( - const void *pBuffer) -{ - uint32_t ulCrc; - - if(pBuffer == NULL) - { - REDERROR(); - ulCrc = SUSPICIOUS_CRC_VALUE; - } - else - { - const uint8_t *pbBuffer = CAST_VOID_PTR_TO_CONST_UINT8_PTR(pBuffer); - - /* The first eight bytes of a metadata node contain the signature and - the CRC. There is little value in CRCing the signature, and the - CRC cannot be CRC'd, so skip over that part of the buffer. - */ - ulCrc = RedCrc32Update(0U, &pbBuffer[8U], REDCONF_BLOCK_SIZE - 8U); - } - - return ulCrc; -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/util/endian.c b/FreeRTOS-Plus/Source/Reliance-Edge/util/endian.c deleted file mode 100755 index 312e366..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/util/endian.c +++ /dev/null @@ -1,82 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements utilities for performing endian swaps. -*/ -#include - - -#ifdef REDCONF_ENDIAN_SWAP - -/** @brief Reverse the byte order of a 64-bit number. - - @param ullToRev Number whose bytes will be reversed - - @retval @p ullToRev with its bytes reversed. -*/ -uint64_t RedRev64( - uint64_t ullToRev) -{ - uint64_t ullRet = ullToRev; - - ullRet = ((ullRet & UINT64_SUFFIX(0x00000000FFFFFFFF)) << 32U) | ((ullRet & UINT64_SUFFIX(0xFFFFFFFF00000000)) >> 32U); - ullRet = ((ullRet & UINT64_SUFFIX(0x0000FFFF0000FFFF)) << 16U) | ((ullRet & UINT64_SUFFIX(0xFFFF0000FFFF0000)) >> 16U); - ullRet = ((ullRet & UINT64_SUFFIX(0x00FF00FF00FF00FF)) << 8U) | ((ullRet & UINT64_SUFFIX(0xFF00FF00FF00FF00)) >> 8U); - - return ullRet; -} - - -/** @brief Reverse the byte order of a 32-bit number. - - @param ulToRev Number whose bytes will be reversed - - @retval @p ulToRev with its bytes reversed. -*/ -uint32_t RedRev32( - uint32_t ulToRev) -{ - return ((ulToRev & 0x000000FFU) << 24U) - | ((ulToRev & 0x0000FF00U) << 8U) - | ((ulToRev & 0x00FF0000U) >> 8U) - | ((ulToRev & 0xFF000000U) >> 24U); -} - - -/** @brief Reverse the byte order of a 16-bit number. - - @param uToRev Number whose bytes will be reversed - - @retval @p uToRev with its bytes reversed. -*/ -uint16_t RedRev16( - uint16_t uToRev) -{ - return ((uToRev & 0xFF00U) >> 8U) - | ((uToRev & 0x00FFU) << 8U); -} - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/util/memory.c b/FreeRTOS-Plus/Source/Reliance-Edge/util/memory.c deleted file mode 100755 index 5a3efaf..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/util/memory.c +++ /dev/null @@ -1,301 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Default implementations of memory manipulation functions. - - These implementations are intended to be small and simple, and thus forego - all optimizations. If the C library is available, or if there are better - third-party implementations available in the system, those can be used - instead by defining the appropriate macros in redconf.h. - - These functions are not intended to be completely 100% ANSI C compatible - implementations, but rather are designed to meet the needs of Reliance Edge. - The compatibility is close enough that ANSI C compatible implementations - can be "dropped in" as replacements without difficulty. -*/ -#include - - -#ifndef RedMemCpyUnchecked -static void RedMemCpyUnchecked(void *pDest, const void *pSrc, uint32_t ulLen); -#endif -#ifndef RedMemMoveUnchecked -static void RedMemMoveUnchecked(void *pDest, const void *pSrc, uint32_t ulLen); -#endif -#ifndef RedMemSetUnchecked -static void RedMemSetUnchecked(void *pDest, uint8_t bVal, uint32_t ulLen); -#endif -#ifndef RedMemCmpUnchecked -static int32_t RedMemCmpUnchecked(const void *pMem1, const void *pMem2, uint32_t ulLen); -#endif - - -/** @brief Copy memory from one address to another. - - The source and destination memory buffers should not overlap. If the - buffers overlap, use RedMemMove() instead. - - @param pDest The destination buffer. - @param pSrc The source buffer. - @param ulLen The number of bytes to copy. -*/ -void RedMemCpy( - void *pDest, - const void *pSrc, - uint32_t ulLen) -{ - if((pDest == NULL) || (pSrc == NULL)) - { - REDERROR(); - } - else - { - RedMemCpyUnchecked(pDest, pSrc, ulLen); - } -} - - -#ifndef RedMemCpyUnchecked -/** @brief Copy memory from one address to another. - - This function should only be called from RedMemCpy(). - - @param pDest The destination buffer. - @param pSrc The source buffer. - @param ulLen The number of bytes to copy. -*/ -static void RedMemCpyUnchecked( - void *pDest, - const void *pSrc, - uint32_t ulLen) -{ - uint8_t *pbDest = CAST_VOID_PTR_TO_UINT8_PTR(pDest); - const uint8_t *pbSrc = CAST_VOID_PTR_TO_CONST_UINT8_PTR(pSrc); - uint32_t ulIdx; - - for(ulIdx = 0U; ulIdx < ulLen; ulIdx++) - { - pbDest[ulIdx] = pbSrc[ulIdx]; - } -} -#endif - - -/** @brief Move memory from one address to another. - - Supports overlapping memory regions. If memory regions do not overlap, it - is generally better to use RedMemCpy() instead. - - @param pDest The destination buffer. - @param pSrc The source buffer. - @param ulLen The number of bytes to copy. -*/ -void RedMemMove( - void *pDest, - const void *pSrc, - uint32_t ulLen) -{ - if((pDest == NULL) || (pSrc == NULL)) - { - REDERROR(); - } - else - { - RedMemMoveUnchecked(pDest, pSrc, ulLen); - } -} - - -#ifndef RedMemMoveUnchecked -/** @brief Move memory from one address to another. - - This function should only be called from RedMemMove(). - - @param pDest The destination buffer. - @param pSrc The source buffer. - @param ulLen The number of bytes to copy. -*/ -static void RedMemMoveUnchecked( - void *pDest, - const void *pSrc, - uint32_t ulLen) -{ - uint8_t *pbDest = CAST_VOID_PTR_TO_UINT8_PTR(pDest); - const uint8_t *pbSrc = CAST_VOID_PTR_TO_CONST_UINT8_PTR(pSrc); - uint32_t ulIdx; - - if(MEMMOVE_MUST_COPY_FORWARD(pbDest, pbSrc)) - { - /* If the destination is lower than the source with overlapping memory - regions, we must copy from start to end in order to copy the memory - correctly. - - Don't use RedMemCpy() to do this. It is possible that RedMemCpy() - has been replaced (even though this function has not been replaced) - with an implementation that cannot handle any kind of buffer - overlap. - */ - for(ulIdx = 0U; ulIdx < ulLen; ulIdx++) - { - pbDest[ulIdx] = pbSrc[ulIdx]; - } - } - else - { - ulIdx = ulLen; - - while(ulIdx > 0U) - { - ulIdx--; - pbDest[ulIdx] = pbSrc[ulIdx]; - } - } -} -#endif /* RedMemMoveUnchecked */ - - -/** @brief Initialize a buffer with the specified byte value. - - @param pDest The buffer to initialize. - @param bVal The byte value with which to initialize @p pDest. - @param ulLen The number of bytes to initialize. -*/ -void RedMemSet( - void *pDest, - uint8_t bVal, - uint32_t ulLen) -{ - if(pDest == NULL) - { - REDERROR(); - } - else - { - RedMemSetUnchecked(pDest, bVal, ulLen); - } -} - - -#ifndef RedMemSetUnchecked -/** @brief Initialize a buffer with the specified byte value. - - This function should only be called from RedMemSet(). - - @param pDest The buffer to initialize. - @param bVal The byte value with which to initialize @p pDest. - @param ulLen The number of bytes to initialize. -*/ -static void RedMemSetUnchecked( - void *pDest, - uint8_t bVal, - uint32_t ulLen) -{ - uint8_t *pbDest = CAST_VOID_PTR_TO_UINT8_PTR(pDest); - uint32_t ulIdx; - - for(ulIdx = 0U; ulIdx < ulLen; ulIdx++) - { - pbDest[ulIdx] = bVal; - } -} -#endif - - -/** @brief Compare the contents of two buffers. - - @param pMem1 The first buffer to compare. - @param pMem2 The second buffer to compare. - @param ulLen The length to compare. - - @return Zero if the two buffers are the same, otherwise nonzero. - - @retval 0 @p pMem1 and @p pMem2 are the same. - @retval 1 @p pMem1 is greater than @p pMem2, as determined by the - values of the first differing bytes. - @retval -1 @p pMem2 is greater than @p pMem1, as determined by the - values of the first differing bytes. -*/ -int32_t RedMemCmp( - const void *pMem1, - const void *pMem2, - uint32_t ulLen) -{ - int32_t lResult; - - if((pMem1 == NULL) || (pMem2 == NULL)) - { - REDERROR(); - lResult = 0; - } - else - { - lResult = RedMemCmpUnchecked(pMem1, pMem2, ulLen); - } - - return lResult; -} - - -#ifndef RedMemCmpUnchecked -/** @brief Compare the contents of two buffers. - - @param pMem1 The first buffer to compare. - @param pMem2 The second buffer to compare. - @param ulLen The length to compare. - - @return Zero if the two buffers are the same, otherwise nonzero. -*/ -static int32_t RedMemCmpUnchecked( - const void *pMem1, - const void *pMem2, - uint32_t ulLen) -{ - const uint8_t *pbMem1 = CAST_VOID_PTR_TO_CONST_UINT8_PTR(pMem1); - const uint8_t *pbMem2 = CAST_VOID_PTR_TO_CONST_UINT8_PTR(pMem2); - uint32_t ulIdx = 0U; - int32_t lResult; - - while((ulIdx < ulLen) && (pbMem1[ulIdx] == pbMem2[ulIdx])) - { - ulIdx++; - } - - if(ulIdx == ulLen) - { - lResult = 0; - } - else if(pbMem1[ulIdx] > pbMem2[ulIdx]) - { - lResult = 1; - } - else - { - lResult = -1; - } - - return lResult; -} -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/util/namelen.c b/FreeRTOS-Plus/Source/Reliance-Edge/util/namelen.c deleted file mode 100755 index 440e78e..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/util/namelen.c +++ /dev/null @@ -1,61 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements a utility to find the length of a name. -*/ -#include - -#if REDCONF_API_POSIX == 1 - - -/** @brief Determine the length of a name, terminated either by a null or a path - separator character. - - @param pszName The name whose length is to be determined. - - @return The length of the name. -*/ -uint32_t RedNameLen( - const char *pszName) -{ - uint32_t ulIdx = 0U; - - if(pszName == NULL) - { - REDERROR(); - } - else - { - while((pszName[ulIdx] != '\0') && (pszName[ulIdx] != REDCONF_PATH_SEPARATOR)) - { - ulIdx++; - } - } - - return ulIdx; -} - -#endif - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/util/sign.c b/FreeRTOS-Plus/Source/Reliance-Edge/util/sign.c deleted file mode 100755 index c56553f..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/util/sign.c +++ /dev/null @@ -1,63 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Implements a sign on message. -*/ -#include - - -/** @brief Display the Reliance Edge signon message. -*/ -void RedSignOn(void) -{ - #if REDCONF_OUTPUT == 1 - - /* Use RedOsOutputString() instead of RedPrintf() to avoid using variadic - arguments, since this function is called from the driver and cannot use - functions that violate MISRA-C:2012. - */ - RedOsOutputString(RED_PRODUCT_NAME "\n"); - RedOsOutputString(RED_PRODUCT_EDITION "\n"); - RedOsOutputString(RED_PRODUCT_LEGAL "\n"); - RedOsOutputString(RED_PRODUCT_PATENT "\n"); - - #else - - /* Always embed the copyright into the program data. Use "volatile" to try - to avoid the compiler removing the variables. - */ - static volatile const char szVersion[] = RED_PRODUCT_NAME; - static volatile const char szEdition[] = RED_PRODUCT_EDITION; - static volatile const char szCopyright[] = RED_PRODUCT_LEGAL; - static volatile const char szPatent[] = RED_PRODUCT_PATENT; - - (void)szVersion; - (void)szEdition; - (void)szCopyright; - (void)szPatent; - - #endif -} - diff --git a/FreeRTOS-Plus/Source/Reliance-Edge/util/string.c b/FreeRTOS-Plus/Source/Reliance-Edge/util/string.c deleted file mode 100755 index abf5bc9..0000000 --- a/FreeRTOS-Plus/Source/Reliance-Edge/util/string.c +++ /dev/null @@ -1,329 +0,0 @@ -/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- - - Copyright (c) 2014-2015 Datalight, Inc. - All Rights Reserved Worldwide. - - This program 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; use version 2 of the License. - - This program is distributed in the hope that it will be useful, - but "AS-IS," 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-1301 USA. -*/ -/* Businesses and individuals that for commercial or other reasons cannot - comply with the terms of the GPLv2 license may obtain a commercial license - before incorporating Reliance Edge into proprietary software for - distribution in any form. Visit http://www.datalight.com/reliance-edge for - more information. -*/ -/** @file - @brief Default implementations of string manipulation functions. - - These implementations are intended to be small and simple, and thus forego - all optimizations. If the C library is available, or if there are better - third-party implementations available in the system, those can be used - instead by defining the appropriate macros in redconf.h. - - These functions are not intended to be completely 100% ANSI C compatible - implementations, but rather are designed to meet the needs of Reliance Edge. - The compatibility is close enough that ANSI C compatible implementations - can be "dropped in" as replacements without difficulty. -*/ -#include - - -#ifndef RedStrLenUnchecked -static uint32_t RedStrLenUnchecked(const char *pszStr); -#endif -#ifndef RedStrCmpUnchecked -static int32_t RedStrCmpUnchecked(const char *pszStr1, const char *pszStr2); -#endif -#ifndef RedStrNCmpUnchecked -static int32_t RedStrNCmpUnchecked(const char *pszStr1, const char *pszStr2, uint32_t ulLen); -#endif -#ifndef RedStrNCpyUnchecked -static void RedStrNCpyUnchecked(char *pszDst, const char *pszSrc, uint32_t ulLen); -#endif - - -/** @brief Determine the length (in bytes) of a null terminated string. - - The length does not include the null terminator byte. - - @param pszStr The null terminated string whose length is to be determined. - - @return The length of the @p pszStr string. -*/ -uint32_t RedStrLen( - const char *pszStr) -{ - uint32_t ulLen; - - if(pszStr == NULL) - { - REDERROR(); - ulLen = 0U; - } - else - { - /* Cast the result to uint32_t, since RedStrLenUnchecked() might be - strlen(), which returns size_t, which is possibly a 64-bit value. - */ - ulLen = (uint32_t)RedStrLenUnchecked(pszStr); - } - - return ulLen; -} - - -#ifndef RedStrLenUnchecked -/** @brief Determine the length (in bytes) of a null terminated string. - - @param pszStr The null terminated string whose length is to be determined. - - @return The length of the @p pszStr string. -*/ -static uint32_t RedStrLenUnchecked( - const char *pszStr) -{ - uint32_t ulLen = 0U; - - while(pszStr[ulLen] != '\0') - { - ulLen++; - } - - return ulLen; -} -#endif - - -/** @brief Compare two null terminated strings. - - @param pszStr1 The first string to compare. - @param pszStr2 The second string to compare. - - @return Zero if the two strings are the same, otherwise nonzero. - - @retval 0 @p pszStr1 and @p pszStr2 are the same. - @retval 1 @p pszStr1 is greater than @p pszStr2, as determined by the - values of the first differing bytes. - @retval -1 @p pszStr2 is greater than @p pszStr1, as determined by the - values of the first differing bytes. -*/ -int32_t RedStrCmp( - const char *pszStr1, - const char *pszStr2) -{ - int32_t lResult; - - if((pszStr1 == NULL) || (pszStr2 == NULL)) - { - REDERROR(); - lResult = 0; - } - else - { - lResult = RedStrCmpUnchecked(pszStr1, pszStr2); - } - - return lResult; -} - - -#ifndef RedStrCmpUnchecked -/** @brief Compare two null terminated strings. - - @param pszStr1 The first string to compare. - @param pszStr2 The second string to compare. - - @return Zero if the two strings are the same, otherwise nonzero. -*/ -static int32_t RedStrCmpUnchecked( - const char *pszStr1, - const char *pszStr2) -{ - int32_t lResult; - uint32_t ulIdx = 0U; - - while((pszStr1[ulIdx] == pszStr2[ulIdx]) && (pszStr1[ulIdx] != '\0')) - { - ulIdx++; - } - - /* "The sign of a non-zero return value is determined by the sign of the - difference between the values of the first pair of bytes (both - interpreted as type unsigned char) that differ in the strings being - compared." Use uint8_t instead of unsigned char to avoid MISRA C - deviations. - */ - if((uint8_t)pszStr1[ulIdx] > (uint8_t)pszStr2[ulIdx]) - { - lResult = 1; - } - else if((uint8_t)pszStr1[ulIdx] < (uint8_t)pszStr2[ulIdx]) - { - lResult = -1; - } - else - { - lResult = 0; - } - - return lResult; -} -#endif - - -/** @brief Compare the first @p ulLen characters of two null terminated strings. - - @param pszStr1 The first string to compare. - @param pszStr2 The second string to compare. - @param ulLen The maximum length to compare. The comparison stops when - either of the strings end or when @p ulLen bytes have been - compared. - - @return Zero if the two strings are the same, otherwise nonzero. - - @retval 0 @p pszStr1 and @p pszStr2 are the same. - @retval 1 @p pszStr1 is greater than @p pszStr2, as determined by the - values of the first differing bytes. - @retval -1 @p pszStr2 is greater than @p pszStr1, as determined by the - values of the first differing bytes. -*/ -int32_t RedStrNCmp( - const char *pszStr1, - const char *pszStr2, - uint32_t ulLen) -{ - int32_t lResult; - - if((pszStr1 == NULL) || (pszStr2 == NULL)) - { - REDERROR(); - lResult = 0; - } - else - { - lResult = RedStrNCmpUnchecked(pszStr1, pszStr2, ulLen); - } - - return lResult; -} - - -#ifndef RedStrNCmpUnchecked -/** @brief Compare the first @p ulLen characters of two null terminated strings. - - @param pszStr1 The first string to compare. - @param pszStr2 The second string to compare. - @param ulLen The maximum length to compare. The comparison stops when - either of the strings end or when @p ulLen bytes have been - compared. - - @return Zero if the two strings are the same, otherwise nonzero. -*/ -static int32_t RedStrNCmpUnchecked( - const char *pszStr1, - const char *pszStr2, - uint32_t ulLen) -{ - int32_t lResult = 0; - uint32_t ulIdx; - - for(ulIdx = 0U; ulIdx < ulLen; ulIdx++) - { - if(pszStr1[ulIdx] != pszStr2[ulIdx]) - { - /* "The sign of a non-zero return value is determined by the sign - of the difference between the values of the first pair of bytes - (both interpreted as type unsigned char) that differ in the - strings being compared." Use uint8_t instead of unsigned char - to avoid MISRA C deviations. - */ - if((uint8_t)pszStr1[ulIdx] > (uint8_t)pszStr2[ulIdx]) - { - lResult = 1; - } - else - { - lResult = -1; - } - } - - if((lResult != 0) || (pszStr1[ulIdx] == '\0')) - { - break; - } - } - - return lResult; -} -#endif - - -/** @brief Copy a string. - - Copy up to @p ulLen bytes of a null-terminated string (@p pszSrc) to a - destination buffer (@p pszDst). The result will not be null-terminated if - @p pszSrc is longer than @p ulLen - 1 bytes. - - If @p pszSrc is shorter than @p ulLen - 1 bytes, the remainder of @p pszDst - will be filled with null bytes. - - @param pszDst The destination buffer, which is at least @p ulLen bytes - in size. - @param pszSrc The null-terminated string to copy. - @param ulLen The maximum number of characters to copy. -*/ -void RedStrNCpy( - char *pszDst, - const char *pszSrc, - uint32_t ulLen) -{ - if((pszDst == NULL) || (pszSrc == NULL)) - { - REDERROR(); - } - else - { - RedStrNCpyUnchecked(pszDst, pszSrc, ulLen); - } -} - - -#ifndef RedStrNCpyUnchecked -/** @brief Copy a string. - - @param pszDst The destination buffer, which is at least @p ulLen bytes - in size. - @param pszSrc The null-terminated string to copy. - @param ulLen The maximum number of characters to copy. -*/ -static void RedStrNCpyUnchecked( - char *pszDst, - const char *pszSrc, - uint32_t ulLen) -{ - uint32_t ulIdx = 0U; - - while((ulIdx < ulLen) && (pszSrc[ulIdx] != '\0')) - { - pszDst[ulIdx] = pszSrc[ulIdx]; - ulIdx++; - } - - while(ulIdx < ulLen) - { - pszDst[ulIdx] = '\0'; - ulIdx++; - } -} -#endif - diff --git a/FreeRTOS-Plus/Source/WebDocs.url b/FreeRTOS-Plus/Source/WebDocs.url deleted file mode 100755 index 9ce0b5c..0000000 --- a/FreeRTOS-Plus/Source/WebDocs.url +++ /dev/null @@ -1,5 +0,0 @@ -[InternetShortcut] -URL=http://www.freertos.org/plus -IDList= -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 diff --git a/FreeRTOS-Plus/Source/WolfSSL/AUTHORS b/FreeRTOS-Plus/Source/WolfSSL/AUTHORS deleted file mode 100755 index e69de29..0000000 diff --git a/FreeRTOS-Plus/Source/WolfSSL/COPYING b/FreeRTOS-Plus/Source/WolfSSL/COPYING deleted file mode 100755 index d159169..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program 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. - - This program 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-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/FreeRTOS-Plus/Source/WolfSSL/ChangeLog b/FreeRTOS-Plus/Source/WolfSSL/ChangeLog deleted file mode 100755 index e69de29..0000000 diff --git a/FreeRTOS-Plus/Source/WolfSSL/INSTALL b/FreeRTOS-Plus/Source/WolfSSL/INSTALL deleted file mode 100755 index b9249c0..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/INSTALL +++ /dev/null @@ -1,45 +0,0 @@ -0. Building on *nix from git repository - - Run the autogen script to generate configure, you'll need the autoconf tools - installed, then proceed to step 1. - - $ ./autogen.sh - -1. Building on *nix from a release - - $ ./configure - $ make - $ make check # (optional, but highly recommended) - $ sudo make install - -2. Building on iOS - - Use on the xcode project in IDE/iOS/wolfssl.xcodeproj - There is a README in IDE/iOS with more information - -3. Building on Windows - - Use the 32bit Visual Studio Solution wolfssl.sln - For a 64bit solution please use wolfssl64.sln - -4. Building with IAR - - Please see the README in IDE/IAR-EWARM for detailed instructions - -5. Building with Keil - - Please see the Keil Projects in IDE/MDK5-ARM/Projects - -6. Building with Microchip tools - - Please see the README in mplabx - -7. Building with Freescale MQX - - Please see the README in mqx - -8. Porting to a new platform - - Please see section 2.4 in the manual: - http://www.wolfssl.com/yaSSL/Docs-cyassl-manual-2-building-cyassl.html - diff --git a/FreeRTOS-Plus/Source/WolfSSL/LICENSING b/FreeRTOS-Plus/Source/WolfSSL/LICENSING deleted file mode 100755 index e43bb9f..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/LICENSING +++ /dev/null @@ -1,11 +0,0 @@ - -CyaSSL and wolfCrypt are either licensed for use under the GPLv2 or a -standard commercial license. For our users who cannot use CyaSSL under -GPLv2, a commercial license to CyaSSL and wolfCrypt is available. -Please contact wolfSSL Inc. directly at: - -Email: licensing@wolfssl.com -Phone: +1 425 245-8247 - -More information can be found on the wolfSSL website at www.wolfssl.com. - diff --git a/FreeRTOS-Plus/Source/WolfSSL/Makefile.am b/FreeRTOS-Plus/Source/WolfSSL/Makefile.am deleted file mode 100755 index 5918a4d..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/Makefile.am +++ /dev/null @@ -1,164 +0,0 @@ -# includes append to these: -SUFFIXES = -TESTS = -CLEANFILES = -DISTCLEANFILES = -bin_PROGRAMS = -noinst_HEADERS = -lib_LTLIBRARIES = -man_MANS = -noinst_LTLIBRARIES = -noinst_PROGRAMS = -include_HEADERS = -nobase_include_HEADERS = -check_PROGRAMS = -EXTRA_HEADERS = -BUILT_SOURCES= -EXTRA_DIST= -dist_doc_DATA= - -#includes additional rules from aminclude.am -@INC_AMINCLUDE@ -DISTCLEANFILES+= aminclude.am - -CLEANFILES+= cert.der \ - cert.pem \ - certecc.der \ - certecc.pem \ - certreq.der \ - certreq.pem \ - key.der \ - key.pem \ - ntru-cert.der \ - ntru-cert.pem \ - ntru-key.raw \ - othercert.der \ - othercert.pem \ - pkcs7cert.der \ - pkcs7envelopedData.der \ - pkcs7signedData.der - -exampledir = $(docdir)/example -dist_example_DATA= - -ACLOCAL_AMFLAGS= -I m4 - -EXTRA_DIST+= lib/dummy - -EXTRA_DIST+= cyassl-ntru.vcproj -EXTRA_DIST+= cyassl.vcproj -EXTRA_DIST+= cyassl.vcxproj -EXTRA_DIST+= cyassl-iphone.xcodeproj/project.pbxproj -EXTRA_DIST+= cyassl-ios.xcodeproj/project.pbxproj -EXTRA_DIST+= cyassl-ntru.sln -EXTRA_DIST+= cyassl.sln -EXTRA_DIST+= cyassl64.sln -EXTRA_DIST+= valgrind-error.sh -EXTRA_DIST+= gencertbuf.pl -EXTRA_DIST+= IDE - -include cyassl/include.am -include certs/include.am -include certs/1024/include.am -include certs/crl/include.am -include doc/include.am -include swig/include.am - -include src/include.am -include support/include.am -include ctaocrypt/benchmark/include.am -include ctaocrypt/src/include.am -include ctaocrypt/test/include.am -include examples/client/include.am -include examples/server/include.am -include examples/echoclient/include.am -include examples/echoserver/include.am -include testsuite/include.am -include tests/include.am -include sslSniffer/sslSnifferTest/include.am -include rpm/include.am -include mqx/ctaocrypt_test/Sources/include.am -include mqx/cyassl/include.am -include mqx/cyassl_client/Sources/include.am -include mqx/util_lib/Sources/include.am -include mplabx/include.am -include mplabx/ctaocrypt_benchmark.X/nbproject/include.am -include mplabx/ctaocrypt_test.X/nbproject/include.am -include mplabx/cyassl.X/nbproject/include.am -include mcapi/include.am -include mcapi/ctaocrypt_mcapi.X/nbproject/include.am -include mcapi/ctaocrypt_test.X/nbproject/include.am -include mcapi/cyassl.X/nbproject/include.am -include mcapi/zlib.X/nbproject/include.am - -if USE_VALGRIND -TESTS_ENVIRONMENT=./valgrind-error.sh -endif - -TEST_EXTENSIONS=.test -TESTS += $(check_PROGRAMS) -test: check -tests/unit.log: testsuite/testsuite.log - -DISTCLEANFILES+= cyassl-config -# fips files shouldn't be left after make distclean -DISTCLEANFILES+= ctaocrypt/src/fips.c -DISTCLEANFILES+= ctaocrypt/src/fips_test.c - -maintainer-clean-local: - -rm Makefile.in - -rm aclocal.m4 - -rm build-aux/compile - -rm build-aux/config.guess - -rm build-aux/config.sub - -rm build-aux/depcomp - -rm build-aux/install-sh - -rm build-aux/ltmain.sh - -rm build-aux/missing - -rm cyassl-config - -rmdir build-aux - -rm configure - -rm config.log - -rm config.status - -rm config.in - -rm m4/libtool.m4 - -rm m4/ltoptions.m4 - -rm m4/ltsugar.m4 - -rm m4/ltversion.m4 - -rm m4/lt~obsolete.m4 - -rm support/cyassl.pc - find . -type f -name '*~' -exec rm -f '{}' \; - -rm -f @PACKAGE@-*.tar.gz - -rm -f @PACKAGE@-*.rpm - -# !!!! first line of rule has to start with a hard (real) tab, not spaces -egs: - $(MAKE) examples/client/client; \ - $(MAKE) examples/echoclient/echoclient;\ - $(MAKE) examples/server/server; \ - $(MAKE) examples/echoserver/echoserver; - -ctc: - $(MAKE) ctaocrypt/test/testctaocrypt; \ - $(MAKE) ctaocrypt/benchmark/benchmark; - -install-exec-local: install-generic-config - -install-generic-config: - $(mkinstalldirs) $(DESTDIR)$(bindir) - $(INSTALL_SCRIPT) @GENERIC_CONFIG@ $(DESTDIR)$(bindir) - -uninstall-local: - -rm -f $(DESTDIR)$(bindir)/@GENERIC_CONFIG@ - -merge-clean: - @find ./ | $(GREP) \.gcda | xargs rm -f - @find ./ | $(GREP) \.gcno | xargs rm -f - @find ./ | $(GREP) \.gz | xargs rm -f - @find ./ | $(GREP) \.orig | xargs rm -f - @find ./ | $(GREP) \.rej | xargs rm -f - @find ./ | $(GREP) \.rpm | xargs rm -f - @find ./ | $(GREP) \.THIS | xargs rm -f - @find ./ | $(GREP) \.OTHER | xargs rm -f - @find ./ | $(GREP) \.BASE | xargs rm -f - @find ./ | $(GREP) \~$$ | xargs rm -f diff --git a/FreeRTOS-Plus/Source/WolfSSL/Makefile.in b/FreeRTOS-Plus/Source/WolfSSL/Makefile.in deleted file mode 100755 index fa6cbfb..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/Makefile.in +++ /dev/null @@ -1,3090 +0,0 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2013 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# All paths should be given relative to the root - -# vim:ft=automake -# All paths should be given relative to the root - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - -# vim:ft=automake -# All paths should be given relative to the root - -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# All paths should be given relative to the root - -# vim:ft=automake -# All paths should be given relative to the root - -# vim:ft=automake -# All paths should be given relative to the root - -# vim:ft=automake -# All paths should be given relative to the root - -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - -# vim:ft=automake - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# All paths should be given relative to the root -# - -# vim:ft=automake -# All paths should be given relative to the root -# - - - - -VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -bin_PROGRAMS = -noinst_PROGRAMS = ctaocrypt/benchmark/benchmark$(EXEEXT) \ - ctaocrypt/test/testctaocrypt$(EXEEXT) $(am__EXEEXT_3) \ - $(am__EXEEXT_4) $(am__EXEEXT_2) -check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) -DIST_COMMON = $(srcdir)/cyassl/include.am \ - $(srcdir)/cyassl/ctaocrypt/include.am \ - $(srcdir)/cyassl/openssl/include.am $(srcdir)/certs/include.am \ - $(srcdir)/certs/1024/include.am $(srcdir)/certs/crl/include.am \ - $(srcdir)/doc/include.am $(srcdir)/swig/include.am \ - $(srcdir)/src/include.am $(srcdir)/support/include.am \ - $(srcdir)/ctaocrypt/benchmark/include.am \ - $(srcdir)/ctaocrypt/src/include.am \ - $(srcdir)/ctaocrypt/test/include.am \ - $(srcdir)/examples/client/include.am \ - $(srcdir)/examples/server/include.am \ - $(srcdir)/examples/echoclient/include.am \ - $(srcdir)/examples/echoserver/include.am \ - $(srcdir)/testsuite/include.am $(srcdir)/tests/include.am \ - $(srcdir)/sslSniffer/sslSnifferTest/include.am \ - $(srcdir)/rpm/include.am \ - $(srcdir)/mqx/ctaocrypt_test/Sources/include.am \ - $(srcdir)/mqx/cyassl/include.am \ - $(srcdir)/mqx/cyassl_client/Sources/include.am \ - $(srcdir)/mqx/util_lib/Sources/include.am \ - $(srcdir)/mplabx/include.am \ - $(srcdir)/mplabx/ctaocrypt_benchmark.X/nbproject/include.am \ - $(srcdir)/mplabx/ctaocrypt_test.X/nbproject/include.am \ - $(srcdir)/mplabx/cyassl.X/nbproject/include.am \ - $(srcdir)/mcapi/include.am \ - $(srcdir)/mcapi/ctaocrypt_mcapi.X/nbproject/include.am \ - $(srcdir)/mcapi/ctaocrypt_test.X/nbproject/include.am \ - $(srcdir)/mcapi/cyassl.X/nbproject/include.am \ - $(srcdir)/mcapi/zlib.X/nbproject/include.am \ - $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/configure $(am__configure_deps) \ - $(srcdir)/config.in $(srcdir)/stamp-h.in \ - $(top_srcdir)/cyassl/version.h.in \ - $(top_srcdir)/cyassl/options.h.in \ - $(top_srcdir)/support/cyassl.pc.in $(top_srcdir)/rpm/spec.in \ - $(top_srcdir)/build-aux/depcomp $(dist_doc_DATA) \ - $(dist_example_DATA) $(include_HEADERS) \ - $(nobase_include_HEADERS) $(am__noinst_HEADERS_DIST) \ - $(top_srcdir)/build-aux/test-driver AUTHORS COPYING ChangeLog \ - NEWS README build-aux/compile build-aux/config.guess \ - build-aux/config.sub build-aux/depcomp build-aux/install-sh \ - build-aux/missing build-aux/ltmain.sh \ - $(top_srcdir)/build-aux/compile \ - $(top_srcdir)/build-aux/config.guess \ - $(top_srcdir)/build-aux/config.sub \ - $(top_srcdir)/build-aux/install-sh \ - $(top_srcdir)/build-aux/ltmain.sh \ - $(top_srcdir)/build-aux/missing -@BUILD_FIPS_TRUE@am__append_1 = ctaocrypt/src/wolfcrypt_first.c -@BUILD_MEMORY_TRUE@am__append_2 = ctaocrypt/src/memory.c -@BUILD_RSA_TRUE@am__append_3 = ctaocrypt/src/rsa.c -@BUILD_DH_TRUE@am__append_4 = ctaocrypt/src/dh.c -@BUILD_ASN_TRUE@am__append_5 = ctaocrypt/src/asn.c -@BUILD_FIPS_TRUE@am__append_6 = ctaocrypt/src/fips.c \ -@BUILD_FIPS_TRUE@ ctaocrypt/src/fips_test.c -@BUILD_CODING_TRUE@am__append_7 = ctaocrypt/src/coding.c -@BUILD_AES_TRUE@am__append_8 = ctaocrypt/src/aes.c -@BUILD_DES3_TRUE@am__append_9 = ctaocrypt/src/des3.c -@BUILD_SHA_TRUE@am__append_10 = ctaocrypt/src/sha.c -@BUILD_RC4_TRUE@am__append_11 = ctaocrypt/src/arc4.c -@BUILD_MD4_TRUE@am__append_12 = ctaocrypt/src/md4.c -@BUILD_MD5_TRUE@am__append_13 = ctaocrypt/src/md5.c -@BUILD_PWDBASED_TRUE@am__append_14 = ctaocrypt/src/pwdbased.c -@BUILD_DSA_TRUE@am__append_15 = ctaocrypt/src/dsa.c -@BUILD_AESNI_TRUE@am__append_16 = ctaocrypt/src/aes_asm.s -@BUILD_CAMELLIA_TRUE@am__append_17 = ctaocrypt/src/camellia.c -@BUILD_MD2_TRUE@am__append_18 = ctaocrypt/src/md2.c -@BUILD_RIPEMD_TRUE@am__append_19 = ctaocrypt/src/ripemd.c -@BUILD_SHA512_TRUE@am__append_20 = ctaocrypt/src/sha512.c -@BUILD_BLAKE2_TRUE@am__append_21 = ctaocrypt/src/blake2b.c -@BUILD_SNIFFER_TRUE@am__append_22 = src/sniffer.c -@BUILD_HC128_TRUE@am__append_23 = ctaocrypt/src/hc128.c -@BUILD_RABBIT_TRUE@am__append_24 = ctaocrypt/src/rabbit.c -@BUILD_INLINE_FALSE@am__append_25 = ctaocrypt/src/misc.c -@BUILD_FASTMATH_TRUE@am__append_26 = ctaocrypt/src/tfm.c -@BUILD_SLOWMATH_TRUE@am__append_27 = ctaocrypt/src/integer.c -@BUILD_ECC_TRUE@am__append_28 = ctaocrypt/src/ecc.c -@BUILD_OCSP_TRUE@am__append_29 = src/ocsp.c -@BUILD_CRL_TRUE@am__append_30 = src/crl.c -@BUILD_LIBZ_TRUE@am__append_31 = ctaocrypt/src/compress.c -@BUILD_PKCS7_TRUE@am__append_32 = ctaocrypt/src/pkcs7.c -@BUILD_FIPS_TRUE@am__append_33 = ctaocrypt/src/wolfcrypt_last.c -@BUILD_EXAMPLES_TRUE@am__append_34 = examples/client/client \ -@BUILD_EXAMPLES_TRUE@ examples/server/server \ -@BUILD_EXAMPLES_TRUE@ examples/echoclient/echoclient \ -@BUILD_EXAMPLES_TRUE@ examples/echoserver/echoserver \ -@BUILD_EXAMPLES_TRUE@ testsuite/testsuite.test tests/unit.test -@BUILD_EXAMPLES_TRUE@am__append_35 = examples/client/client.h \ -@BUILD_EXAMPLES_TRUE@ examples/server/server.h \ -@BUILD_EXAMPLES_TRUE@ examples/echoclient/echoclient.h \ -@BUILD_EXAMPLES_TRUE@ examples/echoserver/echoserver.h -@BUILD_EXAMPLES_TRUE@am__append_36 = testsuite/testsuite.test \ -@BUILD_EXAMPLES_TRUE@ tests/unit.test -@BUILD_SNIFFTEST_TRUE@am__append_37 = sslSniffer/sslSnifferTest/snifftest -@BUILD_MCAPI_TRUE@am__append_38 = mcapi/test -@BUILD_MCAPI_TRUE@am__append_39 = mcapi/test -subdir = . -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_add_am_macro.m4 \ - $(top_srcdir)/m4/ax_am_jobserver.m4 \ - $(top_srcdir)/m4/ax_am_macros.m4 \ - $(top_srcdir)/m4/ax_append_compile_flags.m4 \ - $(top_srcdir)/m4/ax_append_flag.m4 \ - $(top_srcdir)/m4/ax_append_to_file.m4 \ - $(top_srcdir)/m4/ax_check_compile_flag.m4 \ - $(top_srcdir)/m4/ax_check_link_flag.m4 \ - $(top_srcdir)/m4/ax_count_cpus.m4 \ - $(top_srcdir)/m4/ax_create_generic_config.m4 \ - $(top_srcdir)/m4/ax_debug.m4 \ - $(top_srcdir)/m4/ax_file_escapes.m4 \ - $(top_srcdir)/m4/ax_harden_compiler_flags.m4 \ - $(top_srcdir)/m4/ax_print_to_file.m4 \ - $(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/ax_tls.m4 \ - $(top_srcdir)/m4/ax_vcs_checkout.m4 \ - $(top_srcdir)/m4/hexversion.m4 \ - $(top_srcdir)/m4/lib_socket_nsl.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/visibility.m4 \ - $(top_srcdir)/m4/wolfssl_darwin_clang.m4 \ - $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ - configure.lineno config.status.lineno -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = config.h -CONFIG_CLEAN_FILES = stamp-h cyassl/version.h cyassl/options.h \ - support/cyassl.pc rpm/spec -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ - "$(DESTDIR)$(docdir)" "$(DESTDIR)$(exampledir)" \ - "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)" \ - "$(DESTDIR)$(includedir)" -LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) -am__DEPENDENCIES_1 = -src_libcyassl_la_DEPENDENCIES = $(am__DEPENDENCIES_1) -am__src_libcyassl_la_SOURCES_DIST = ctaocrypt/src/wolfcrypt_first.c \ - src/internal.c src/io.c src/keys.c src/ssl.c src/tls.c \ - ctaocrypt/src/hmac.c ctaocrypt/src/random.c \ - ctaocrypt/src/sha256.c ctaocrypt/src/logging.c \ - ctaocrypt/src/wc_port.c ctaocrypt/src/error.c \ - ctaocrypt/src/memory.c ctaocrypt/src/rsa.c ctaocrypt/src/dh.c \ - ctaocrypt/src/asn.c ctaocrypt/src/fips.c \ - ctaocrypt/src/fips_test.c ctaocrypt/src/coding.c \ - ctaocrypt/src/aes.c ctaocrypt/src/des3.c ctaocrypt/src/sha.c \ - ctaocrypt/src/arc4.c ctaocrypt/src/md4.c ctaocrypt/src/md5.c \ - ctaocrypt/src/pwdbased.c ctaocrypt/src/dsa.c \ - ctaocrypt/src/aes_asm.s ctaocrypt/src/camellia.c \ - ctaocrypt/src/md2.c ctaocrypt/src/ripemd.c \ - ctaocrypt/src/sha512.c ctaocrypt/src/blake2b.c src/sniffer.c \ - ctaocrypt/src/hc128.c ctaocrypt/src/rabbit.c \ - ctaocrypt/src/misc.c ctaocrypt/src/tfm.c \ - ctaocrypt/src/integer.c ctaocrypt/src/ecc.c src/ocsp.c \ - src/crl.c ctaocrypt/src/compress.c ctaocrypt/src/pkcs7.c \ - ctaocrypt/src/wolfcrypt_last.c -am__dirstamp = $(am__leading_dot)dirstamp -@BUILD_FIPS_TRUE@am__objects_1 = ctaocrypt/src/src_libcyassl_la-wolfcrypt_first.lo -@BUILD_MEMORY_TRUE@am__objects_2 = \ -@BUILD_MEMORY_TRUE@ ctaocrypt/src/src_libcyassl_la-memory.lo -@BUILD_RSA_TRUE@am__objects_3 = ctaocrypt/src/src_libcyassl_la-rsa.lo -@BUILD_DH_TRUE@am__objects_4 = ctaocrypt/src/src_libcyassl_la-dh.lo -@BUILD_ASN_TRUE@am__objects_5 = ctaocrypt/src/src_libcyassl_la-asn.lo -@BUILD_FIPS_TRUE@am__objects_6 = \ -@BUILD_FIPS_TRUE@ ctaocrypt/src/src_libcyassl_la-fips.lo \ -@BUILD_FIPS_TRUE@ ctaocrypt/src/src_libcyassl_la-fips_test.lo -@BUILD_CODING_TRUE@am__objects_7 = \ -@BUILD_CODING_TRUE@ ctaocrypt/src/src_libcyassl_la-coding.lo -@BUILD_AES_TRUE@am__objects_8 = ctaocrypt/src/src_libcyassl_la-aes.lo -@BUILD_DES3_TRUE@am__objects_9 = \ -@BUILD_DES3_TRUE@ ctaocrypt/src/src_libcyassl_la-des3.lo -@BUILD_SHA_TRUE@am__objects_10 = \ -@BUILD_SHA_TRUE@ ctaocrypt/src/src_libcyassl_la-sha.lo -@BUILD_RC4_TRUE@am__objects_11 = \ -@BUILD_RC4_TRUE@ ctaocrypt/src/src_libcyassl_la-arc4.lo -@BUILD_MD4_TRUE@am__objects_12 = \ -@BUILD_MD4_TRUE@ ctaocrypt/src/src_libcyassl_la-md4.lo -@BUILD_MD5_TRUE@am__objects_13 = \ -@BUILD_MD5_TRUE@ ctaocrypt/src/src_libcyassl_la-md5.lo -@BUILD_PWDBASED_TRUE@am__objects_14 = ctaocrypt/src/src_libcyassl_la-pwdbased.lo -@BUILD_DSA_TRUE@am__objects_15 = \ -@BUILD_DSA_TRUE@ ctaocrypt/src/src_libcyassl_la-dsa.lo -@BUILD_AESNI_TRUE@am__objects_16 = ctaocrypt/src/aes_asm.lo -@BUILD_CAMELLIA_TRUE@am__objects_17 = ctaocrypt/src/src_libcyassl_la-camellia.lo -@BUILD_MD2_TRUE@am__objects_18 = \ -@BUILD_MD2_TRUE@ ctaocrypt/src/src_libcyassl_la-md2.lo -@BUILD_RIPEMD_TRUE@am__objects_19 = \ -@BUILD_RIPEMD_TRUE@ ctaocrypt/src/src_libcyassl_la-ripemd.lo -@BUILD_SHA512_TRUE@am__objects_20 = \ -@BUILD_SHA512_TRUE@ ctaocrypt/src/src_libcyassl_la-sha512.lo -@BUILD_BLAKE2_TRUE@am__objects_21 = \ -@BUILD_BLAKE2_TRUE@ ctaocrypt/src/src_libcyassl_la-blake2b.lo -@BUILD_SNIFFER_TRUE@am__objects_22 = src/src_libcyassl_la-sniffer.lo -@BUILD_HC128_TRUE@am__objects_23 = \ -@BUILD_HC128_TRUE@ ctaocrypt/src/src_libcyassl_la-hc128.lo -@BUILD_RABBIT_TRUE@am__objects_24 = \ -@BUILD_RABBIT_TRUE@ ctaocrypt/src/src_libcyassl_la-rabbit.lo -@BUILD_INLINE_FALSE@am__objects_25 = \ -@BUILD_INLINE_FALSE@ ctaocrypt/src/src_libcyassl_la-misc.lo -@BUILD_FASTMATH_TRUE@am__objects_26 = \ -@BUILD_FASTMATH_TRUE@ ctaocrypt/src/src_libcyassl_la-tfm.lo -@BUILD_SLOWMATH_TRUE@am__objects_27 = ctaocrypt/src/src_libcyassl_la-integer.lo -@BUILD_ECC_TRUE@am__objects_28 = \ -@BUILD_ECC_TRUE@ ctaocrypt/src/src_libcyassl_la-ecc.lo -@BUILD_OCSP_TRUE@am__objects_29 = src/src_libcyassl_la-ocsp.lo -@BUILD_CRL_TRUE@am__objects_30 = src/src_libcyassl_la-crl.lo -@BUILD_LIBZ_TRUE@am__objects_31 = \ -@BUILD_LIBZ_TRUE@ ctaocrypt/src/src_libcyassl_la-compress.lo -@BUILD_PKCS7_TRUE@am__objects_32 = \ -@BUILD_PKCS7_TRUE@ ctaocrypt/src/src_libcyassl_la-pkcs7.lo -@BUILD_FIPS_TRUE@am__objects_33 = ctaocrypt/src/src_libcyassl_la-wolfcrypt_last.lo -am_src_libcyassl_la_OBJECTS = $(am__objects_1) \ - src/src_libcyassl_la-internal.lo src/src_libcyassl_la-io.lo \ - src/src_libcyassl_la-keys.lo src/src_libcyassl_la-ssl.lo \ - src/src_libcyassl_la-tls.lo \ - ctaocrypt/src/src_libcyassl_la-hmac.lo \ - ctaocrypt/src/src_libcyassl_la-random.lo \ - ctaocrypt/src/src_libcyassl_la-sha256.lo \ - ctaocrypt/src/src_libcyassl_la-logging.lo \ - ctaocrypt/src/src_libcyassl_la-wc_port.lo \ - ctaocrypt/src/src_libcyassl_la-error.lo $(am__objects_2) \ - $(am__objects_3) $(am__objects_4) $(am__objects_5) \ - $(am__objects_6) $(am__objects_7) $(am__objects_8) \ - $(am__objects_9) $(am__objects_10) $(am__objects_11) \ - $(am__objects_12) $(am__objects_13) $(am__objects_14) \ - $(am__objects_15) $(am__objects_16) $(am__objects_17) \ - $(am__objects_18) $(am__objects_19) $(am__objects_20) \ - $(am__objects_21) $(am__objects_22) $(am__objects_23) \ - $(am__objects_24) $(am__objects_25) $(am__objects_26) \ - $(am__objects_27) $(am__objects_28) $(am__objects_29) \ - $(am__objects_30) $(am__objects_31) $(am__objects_32) \ - $(am__objects_33) -src_libcyassl_la_OBJECTS = $(am_src_libcyassl_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -src_libcyassl_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(src_libcyassl_la_CFLAGS) $(CFLAGS) \ - $(src_libcyassl_la_LDFLAGS) $(LDFLAGS) -o $@ -@BUILD_EXAMPLES_TRUE@am__EXEEXT_1 = testsuite/testsuite.test$(EXEEXT) \ -@BUILD_EXAMPLES_TRUE@ tests/unit.test$(EXEEXT) -@BUILD_MCAPI_TRUE@am__EXEEXT_2 = mcapi/test$(EXEEXT) -@BUILD_EXAMPLES_TRUE@am__EXEEXT_3 = examples/client/client$(EXEEXT) \ -@BUILD_EXAMPLES_TRUE@ examples/server/server$(EXEEXT) \ -@BUILD_EXAMPLES_TRUE@ examples/echoclient/echoclient$(EXEEXT) \ -@BUILD_EXAMPLES_TRUE@ examples/echoserver/echoserver$(EXEEXT) \ -@BUILD_EXAMPLES_TRUE@ testsuite/testsuite.test$(EXEEXT) \ -@BUILD_EXAMPLES_TRUE@ tests/unit.test$(EXEEXT) -@BUILD_SNIFFTEST_TRUE@am__EXEEXT_4 = sslSniffer/sslSnifferTest/snifftest$(EXEEXT) -PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) -am_ctaocrypt_benchmark_benchmark_OBJECTS = \ - ctaocrypt/benchmark/benchmark.$(OBJEXT) -ctaocrypt_benchmark_benchmark_OBJECTS = \ - $(am_ctaocrypt_benchmark_benchmark_OBJECTS) -am_ctaocrypt_test_testctaocrypt_OBJECTS = \ - ctaocrypt/test/test.$(OBJEXT) -ctaocrypt_test_testctaocrypt_OBJECTS = \ - $(am_ctaocrypt_test_testctaocrypt_OBJECTS) -am__examples_client_client_SOURCES_DIST = examples/client/client.c -@BUILD_EXAMPLES_TRUE@am_examples_client_client_OBJECTS = \ -@BUILD_EXAMPLES_TRUE@ examples/client/client.$(OBJEXT) -examples_client_client_OBJECTS = $(am_examples_client_client_OBJECTS) -am__examples_echoclient_echoclient_SOURCES_DIST = \ - examples/echoclient/echoclient.c -@BUILD_EXAMPLES_TRUE@am_examples_echoclient_echoclient_OBJECTS = \ -@BUILD_EXAMPLES_TRUE@ examples/echoclient/echoclient.$(OBJEXT) -examples_echoclient_echoclient_OBJECTS = \ - $(am_examples_echoclient_echoclient_OBJECTS) -am__examples_echoserver_echoserver_SOURCES_DIST = \ - examples/echoserver/echoserver.c -@BUILD_EXAMPLES_TRUE@am_examples_echoserver_echoserver_OBJECTS = \ -@BUILD_EXAMPLES_TRUE@ examples/echoserver/echoserver.$(OBJEXT) -examples_echoserver_echoserver_OBJECTS = \ - $(am_examples_echoserver_echoserver_OBJECTS) -am__examples_server_server_SOURCES_DIST = examples/server/server.c -@BUILD_EXAMPLES_TRUE@am_examples_server_server_OBJECTS = \ -@BUILD_EXAMPLES_TRUE@ examples/server/server.$(OBJEXT) -examples_server_server_OBJECTS = $(am_examples_server_server_OBJECTS) -am__mcapi_test_SOURCES_DIST = mcapi/crypto.c mcapi/mcapi_test.c -@BUILD_MCAPI_TRUE@am_mcapi_test_OBJECTS = mcapi/crypto.$(OBJEXT) \ -@BUILD_MCAPI_TRUE@ mcapi/mcapi_test.$(OBJEXT) -mcapi_test_OBJECTS = $(am_mcapi_test_OBJECTS) -am__sslSniffer_sslSnifferTest_snifftest_SOURCES_DIST = \ - sslSniffer/sslSnifferTest/snifftest.c -@BUILD_SNIFFTEST_TRUE@am_sslSniffer_sslSnifferTest_snifftest_OBJECTS = sslSniffer/sslSnifferTest/snifftest.$(OBJEXT) -sslSniffer_sslSnifferTest_snifftest_OBJECTS = \ - $(am_sslSniffer_sslSnifferTest_snifftest_OBJECTS) -am__tests_unit_test_SOURCES_DIST = tests/unit.c tests/api.c \ - tests/suites.c tests/hash.c examples/client/client.c \ - examples/server/server.c -@BUILD_EXAMPLES_TRUE@am_tests_unit_test_OBJECTS = \ -@BUILD_EXAMPLES_TRUE@ tests/tests_unit_test-unit.$(OBJEXT) \ -@BUILD_EXAMPLES_TRUE@ tests/tests_unit_test-api.$(OBJEXT) \ -@BUILD_EXAMPLES_TRUE@ tests/tests_unit_test-suites.$(OBJEXT) \ -@BUILD_EXAMPLES_TRUE@ tests/tests_unit_test-hash.$(OBJEXT) \ -@BUILD_EXAMPLES_TRUE@ examples/client/tests_unit_test-client.$(OBJEXT) \ -@BUILD_EXAMPLES_TRUE@ examples/server/tests_unit_test-server.$(OBJEXT) -tests_unit_test_OBJECTS = $(am_tests_unit_test_OBJECTS) -tests_unit_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(tests_unit_test_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ - -o $@ -am__testsuite_testsuite_test_SOURCES_DIST = ctaocrypt/test/test.c \ - examples/client/client.c examples/echoclient/echoclient.c \ - examples/echoserver/echoserver.c examples/server/server.c \ - testsuite/testsuite.c -@BUILD_EXAMPLES_TRUE@am_testsuite_testsuite_test_OBJECTS = ctaocrypt/test/testsuite_testsuite_test-test.$(OBJEXT) \ -@BUILD_EXAMPLES_TRUE@ examples/client/testsuite_testsuite_test-client.$(OBJEXT) \ -@BUILD_EXAMPLES_TRUE@ examples/echoclient/testsuite_testsuite_test-echoclient.$(OBJEXT) \ -@BUILD_EXAMPLES_TRUE@ examples/echoserver/testsuite_testsuite_test-echoserver.$(OBJEXT) \ -@BUILD_EXAMPLES_TRUE@ examples/server/testsuite_testsuite_test-server.$(OBJEXT) \ -@BUILD_EXAMPLES_TRUE@ testsuite/testsuite_testsuite_test-testsuite.$(OBJEXT) -testsuite_testsuite_test_OBJECTS = \ - $(am_testsuite_testsuite_test_OBJECTS) -testsuite_testsuite_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS) -LTCCASCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(AM_CCASFLAGS) \ - $(CCASFLAGS) -AM_V_CCAS = $(am__v_CCAS_@AM_V@) -am__v_CCAS_ = $(am__v_CCAS_@AM_DEFAULT_V@) -am__v_CCAS_0 = @echo " CCAS " $@; -am__v_CCAS_1 = -SOURCES = $(src_libcyassl_la_SOURCES) \ - $(ctaocrypt_benchmark_benchmark_SOURCES) \ - $(ctaocrypt_test_testctaocrypt_SOURCES) \ - $(examples_client_client_SOURCES) \ - $(examples_echoclient_echoclient_SOURCES) \ - $(examples_echoserver_echoserver_SOURCES) \ - $(examples_server_server_SOURCES) $(mcapi_test_SOURCES) \ - $(sslSniffer_sslSnifferTest_snifftest_SOURCES) \ - $(tests_unit_test_SOURCES) $(testsuite_testsuite_test_SOURCES) -DIST_SOURCES = $(am__src_libcyassl_la_SOURCES_DIST) \ - $(ctaocrypt_benchmark_benchmark_SOURCES) \ - $(ctaocrypt_test_testctaocrypt_SOURCES) \ - $(am__examples_client_client_SOURCES_DIST) \ - $(am__examples_echoclient_echoclient_SOURCES_DIST) \ - $(am__examples_echoserver_echoserver_SOURCES_DIST) \ - $(am__examples_server_server_SOURCES_DIST) \ - $(am__mcapi_test_SOURCES_DIST) \ - $(am__sslSniffer_sslSnifferTest_snifftest_SOURCES_DIST) \ - $(am__tests_unit_test_SOURCES_DIST) \ - $(am__testsuite_testsuite_test_SOURCES_DIST) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -DATA = $(dist_doc_DATA) $(dist_example_DATA) $(pkgconfig_DATA) -am__noinst_HEADERS_DIST = cyassl/internal.h ctaocrypt/test/test.h \ - examples/client/client.h examples/server/server.h \ - examples/echoclient/echoclient.h \ - examples/echoserver/echoserver.h mcapi/crypto.h -HEADERS = $(include_HEADERS) $(nobase_include_HEADERS) \ - $(noinst_HEADERS) -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ - $(LISP)config.in -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -CSCOPE = cscope -AM_RECURSIVE_TARGETS = cscope check recheck -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -TEST_SUITE_LOG = test-suite.log -LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -distdir = $(PACKAGE)-$(VERSION) -top_distdir = $(distdir) -am__remove_distdir = \ - if test -d "$(distdir)"; then \ - find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -rf "$(distdir)" \ - || { sleep 5 && rm -rf "$(distdir)"; }; \ - else :; fi -am__post_remove_distdir = $(am__remove_distdir) -DIST_ARCHIVES = $(distdir).tar.gz -GZIP_ENV = --best -DIST_TARGETS = dist-gzip -distuninstallcheck_listfiles = find . -type f -print -am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ - | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' -distcleancheck_listfiles = find . -type f -print -ACLOCAL = @ACLOCAL@ -AMINCLUDE = @AMINCLUDE@ -AMTAR = @AMTAR@ -AM_CFLAGS = @AM_CFLAGS@ -AM_CPPFLAGS = @AM_CPPFLAGS@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_LDFLAGS = @AM_LDFLAGS@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCAS = @CCAS@ -CCASDEPMODE = @CCASDEPMODE@ -CCASFLAGS = @CCASFLAGS@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYASSL_LIBRARY_VERSION = @CYASSL_LIBRARY_VERSION@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENERIC_CONFIG = @GENERIC_CONFIG@ -GREP = @GREP@ -HAVE_OPENSSL_CMD = @HAVE_OPENSSL_CMD@ -HAVE_VALGRIND = @HAVE_VALGRIND@ -HAVE_VISIBILITY = @HAVE_VISIBILITY@ -HEX_VERSION = @HEX_VERSION@ -INC_AMINCLUDE = @INC_AMINCLUDE@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBM = @LIBM@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MCHECK = @MCHECK@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PTHREAD_CC = @PTHREAD_CC@ -PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ -PTHREAD_LIBS = @PTHREAD_LIBS@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -ax_pthread_config = @ax_pthread_config@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ - -# includes append to these: -SUFFIXES = -TESTS = $(check_PROGRAMS) -CLEANFILES = cert.der cert.pem certecc.der certecc.pem certreq.der \ - certreq.pem key.der key.pem ntru-cert.der ntru-cert.pem \ - ntru-key.raw othercert.der othercert.pem pkcs7cert.der \ - pkcs7envelopedData.der pkcs7signedData.der -# fips files shouldn't be left after make distclean -DISTCLEANFILES = aminclude.am ctaocrypt/benchmark/.libs/benchmark \ - ctaocrypt/test/.libs/testctaocrypt \ - examples/client/.libs/client examples/server/.libs/server \ - examples/echoclient/.libs/echoclient \ - examples/echoserver/.libs/echoserver \ - testsuite/.libs/testsuite.test tests/.libs/unit.test \ - sslSniffer/sslSnifferTest/.libs/snifftest cyassl-config \ - ctaocrypt/src/fips.c ctaocrypt/src/fips_test.c -noinst_HEADERS = cyassl/internal.h ctaocrypt/test/test.h \ - $(am__append_35) mcapi/crypto.h -lib_LTLIBRARIES = src/libcyassl.la -man_MANS = -noinst_LTLIBRARIES = -include_HEADERS = -nobase_include_HEADERS = cyassl/ctaocrypt/aes.h \ - cyassl/ctaocrypt/arc4.h cyassl/ctaocrypt/asn.h \ - cyassl/ctaocrypt/asn_public.h cyassl/ctaocrypt/camellia.h \ - cyassl/ctaocrypt/coding.h cyassl/ctaocrypt/compress.h \ - cyassl/ctaocrypt/des3.h cyassl/ctaocrypt/dh.h \ - cyassl/ctaocrypt/dsa.h cyassl/ctaocrypt/ecc.h \ - cyassl/ctaocrypt/error-crypt.h cyassl/ctaocrypt/fips_test.h \ - cyassl/ctaocrypt/hc128.h cyassl/ctaocrypt/hmac.h \ - cyassl/ctaocrypt/integer.h cyassl/ctaocrypt/md2.h \ - cyassl/ctaocrypt/md4.h cyassl/ctaocrypt/md5.h \ - cyassl/ctaocrypt/misc.h cyassl/ctaocrypt/pkcs7.h \ - cyassl/ctaocrypt/wc_port.h cyassl/ctaocrypt/pwdbased.h \ - cyassl/ctaocrypt/rabbit.h cyassl/ctaocrypt/random.h \ - cyassl/ctaocrypt/ripemd.h cyassl/ctaocrypt/rsa.h \ - cyassl/ctaocrypt/settings.h cyassl/ctaocrypt/sha256.h \ - cyassl/ctaocrypt/sha512.h cyassl/ctaocrypt/sha.h \ - cyassl/ctaocrypt/blake2.h cyassl/ctaocrypt/blake2-int.h \ - cyassl/ctaocrypt/blake2-impl.h cyassl/ctaocrypt/tfm.h \ - cyassl/ctaocrypt/types.h cyassl/ctaocrypt/visibility.h \ - cyassl/ctaocrypt/logging.h cyassl/ctaocrypt/memory.h \ - cyassl/ctaocrypt/mpi_class.h cyassl/ctaocrypt/mpi_superclass.h \ - cyassl/openssl/asn1.h cyassl/openssl/bio.h cyassl/openssl/bn.h \ - cyassl/openssl/conf.h cyassl/openssl/crypto.h \ - cyassl/openssl/des.h cyassl/openssl/dh.h cyassl/openssl/dsa.h \ - cyassl/openssl/ecdsa.h cyassl/openssl/ec.h \ - cyassl/openssl/engine.h cyassl/openssl/err.h \ - cyassl/openssl/evp.h cyassl/openssl/hmac.h \ - cyassl/openssl/lhash.h cyassl/openssl/md4.h \ - cyassl/openssl/md5.h cyassl/openssl/ripemd.h \ - cyassl/openssl/ocsp.h cyassl/openssl/opensslconf.h \ - cyassl/openssl/opensslv.h cyassl/openssl/ossl_typ.h \ - cyassl/openssl/pem.h cyassl/openssl/pkcs12.h \ - cyassl/openssl/rand.h cyassl/openssl/rsa.h \ - cyassl/openssl/sha.h cyassl/openssl/ssl.h \ - cyassl/openssl/stack.h cyassl/openssl/ui.h \ - cyassl/openssl/x509.h cyassl/openssl/x509v3.h \ - cyassl/error-ssl.h cyassl/ssl.h cyassl/sniffer_error.h \ - cyassl/sniffer.h cyassl/callbacks.h cyassl/certs_test.h \ - cyassl/test.h cyassl/version.h cyassl/options.h cyassl/ocsp.h \ - cyassl/crl.h -EXTRA_HEADERS = -BUILT_SOURCES = -EXTRA_DIST = lib/dummy cyassl-ntru.vcproj cyassl.vcproj cyassl.vcxproj \ - cyassl-iphone.xcodeproj/project.pbxproj \ - cyassl-ios.xcodeproj/project.pbxproj cyassl-ntru.sln \ - cyassl.sln cyassl64.sln valgrind-error.sh gencertbuf.pl IDE \ - cyassl/sniffer_error.rc certs/ca-cert.pem certs/ca-key.pem \ - certs/client-cert.pem certs/client-keyEnc.pem \ - certs/client-key.pem certs/ecc-key.pem certs/ecc-keyPkcs8.pem \ - certs/ecc-client-key.pem certs/client-ecc-cert.pem \ - certs/ntru-cert.pem certs/dh2048.pem certs/server-cert.pem \ - certs/server-ecc.pem certs/server-ecc-rsa.pem \ - certs/server-keyEnc.pem certs/server-key.pem \ - certs/server-keyPkcs8Enc12.pem certs/server-keyPkcs8Enc2.pem \ - certs/server-keyPkcs8Enc.pem certs/server-keyPkcs8.pem \ - certs/ca-key.der certs/ca-cert.der certs/client-cert.der \ - certs/client-key.der certs/dh2048.der certs/rsa2048.der \ - certs/dsa2048.der certs/ecc-key.der certs/server-key.der \ - certs/server-cert.der certs/ntru-key.raw \ - certs/1024/client-cert.pem certs/1024/client-key.pem \ - certs/1024/dh1024.pem certs/1024/dsa1024.pem \ - certs/1024/client-cert.der certs/1024/client-key.der \ - certs/1024/dh1024.der certs/1024/dsa1024.der \ - certs/1024/rsa1024.der certs/crl/crl.pem certs/crl/cliCrl.pem \ - certs/crl/eccSrvCRL.pem certs/crl/eccCliCRL.pem \ - certs/crl/crl.revoked swig/PythonBuild.sh swig/README \ - swig/cyassl.i swig/cyassl_adds.c swig/python_cyassl.vcproj \ - swig/rsasign.py swig/runme.py support/cyassl.pc \ - ctaocrypt/benchmark/benchmark.sln \ - ctaocrypt/benchmark/benchmark.vcproj ctaocrypt/src/misc.c \ - ctaocrypt/src/asm.c ctaocrypt/src/aes_asm.asm \ - ctaocrypt/src/ecc_fp.c ctaocrypt/src/fp_mont_small.i \ - ctaocrypt/src/fp_mul_comba_12.i \ - ctaocrypt/src/fp_mul_comba_17.i \ - ctaocrypt/src/fp_mul_comba_20.i \ - ctaocrypt/src/fp_mul_comba_24.i \ - ctaocrypt/src/fp_mul_comba_28.i \ - ctaocrypt/src/fp_mul_comba_32.i ctaocrypt/src/fp_mul_comba_3.i \ - ctaocrypt/src/fp_mul_comba_48.i ctaocrypt/src/fp_mul_comba_4.i \ - ctaocrypt/src/fp_mul_comba_64.i ctaocrypt/src/fp_mul_comba_6.i \ - ctaocrypt/src/fp_mul_comba_7.i ctaocrypt/src/fp_mul_comba_8.i \ - ctaocrypt/src/fp_mul_comba_9.i \ - ctaocrypt/src/fp_mul_comba_small_set.i \ - ctaocrypt/src/fp_sqr_comba_12.i \ - ctaocrypt/src/fp_sqr_comba_17.i \ - ctaocrypt/src/fp_sqr_comba_20.i \ - ctaocrypt/src/fp_sqr_comba_24.i \ - ctaocrypt/src/fp_sqr_comba_28.i \ - ctaocrypt/src/fp_sqr_comba_32.i ctaocrypt/src/fp_sqr_comba_3.i \ - ctaocrypt/src/fp_sqr_comba_48.i ctaocrypt/src/fp_sqr_comba_4.i \ - ctaocrypt/src/fp_sqr_comba_64.i ctaocrypt/src/fp_sqr_comba_6.i \ - ctaocrypt/src/fp_sqr_comba_7.i ctaocrypt/src/fp_sqr_comba_8.i \ - ctaocrypt/src/fp_sqr_comba_9.i \ - ctaocrypt/src/fp_sqr_comba_small_set.i ctaocrypt/test/test.sln \ - ctaocrypt/test/test.vcproj examples/client/client.sln \ - examples/client/client-ntru.vcproj \ - examples/client/client.vcproj examples/client/client.vcxproj \ - examples/server/server.sln examples/server/server-ntru.vcproj \ - examples/server/server.vcproj examples/server/server.vcxproj \ - examples/echoclient/echoclient.sln \ - examples/echoclient/echoclient-ntru.vcproj \ - examples/echoclient/echoclient.vcproj \ - examples/echoclient/echoclient.vcxproj \ - examples/echoserver/echoserver.sln \ - examples/echoserver/echoserver-ntru.vcproj \ - examples/echoserver/echoserver.vcproj \ - examples/echoserver/echoserver.vcxproj testsuite/testsuite.sln \ - testsuite/testsuite-ntru.vcproj testsuite/testsuite.vcproj \ - testsuite/testsuite.vcxproj input quit tests/unit.h \ - tests/test.conf tests/test-dtls.conf \ - sslSniffer/sslSniffer.vcproj sslSniffer/sslSniffer.vcxproj \ - sslSniffer/sslSnifferTest/sslSniffTest.vcproj \ - mqx/ctaocrypt_test/.cproject mqx/ctaocrypt_test/.project \ - mqx/ctaocrypt_test/ReferencedRSESystems.xml \ - mqx/ctaocrypt_test/ctaocrypt_test_twrk70f120m_Int_Flash_SramData_Debug_PnE_U-MultiLink.launch \ - mqx/ctaocrypt_test/ctaocrypt_test_twrk70f120m_Int_Flash_SramData_Release_PnE_U-MultiLink.launch \ - mqx/ctaocrypt_test/Sources/main.c \ - mqx/ctaocrypt_test/Sources/main.h mqx/README \ - mqx/cyassl/.cproject mqx/cyassl/.project \ - mqx/cyassl_client/.cproject mqx/cyassl_client/.project \ - mqx/cyassl_client/ReferencedRSESystems.xml \ - mqx/cyassl_client/cyassl_client_twrk70f120m_Int_Flash_SramData_Debug_PnE_U-MultiLink.launch \ - mqx/cyassl_client/cyassl_client_twrk70f120m_Int_Flash_SramData_Release_PnE_U-MultiLink.launch \ - mqx/cyassl_client/Sources/main.c \ - mqx/cyassl_client/Sources/main.h mqx/util_lib/.cproject \ - mqx/util_lib/.project mqx/util_lib/Sources/util.c \ - mqx/util_lib/Sources/util.h mplabx/PIC32MZ-serial.h \ - mplabx/README mplabx/benchmark_main.c mplabx/test_main.c \ - mplabx/ctaocrypt_benchmark.X/Makefile \ - mplabx/ctaocrypt_benchmark.X/nbproject/configurations.xml \ - mplabx/ctaocrypt_benchmark.X/nbproject/project.xml \ - mplabx/ctaocrypt_test.X/Makefile \ - mplabx/ctaocrypt_test.X/nbproject/configurations.xml \ - mplabx/ctaocrypt_test.X/nbproject/project.xml \ - mplabx/cyassl.X/Makefile \ - mplabx/cyassl.X/nbproject/configurations.xml \ - mplabx/cyassl.X/nbproject/project.xml mcapi/README \ - mcapi/PIC32MZ-serial.h mcapi/ctaocrypt_mcapi.X/Makefile \ - mcapi/ctaocrypt_mcapi.X/nbproject/configurations.xml \ - mcapi/ctaocrypt_mcapi.X/nbproject/project.xml \ - mcapi/ctaocrypt_test.X/Makefile \ - mcapi/ctaocrypt_test.X/nbproject/configurations.xml \ - mcapi/ctaocrypt_test.X/nbproject/project.xml \ - mcapi/cyassl.X/Makefile \ - mcapi/cyassl.X/nbproject/configurations.xml \ - mcapi/cyassl.X/nbproject/project.xml mcapi/zlib.X/Makefile \ - mcapi/zlib.X/nbproject/configurations.xml \ - mcapi/zlib.X/nbproject/project.xml -dist_doc_DATA = certs/taoCert.txt doc/README.txt -exampledir = $(docdir)/example -dist_example_DATA = examples/client/client.c examples/server/server.c \ - examples/echoclient/echoclient.c \ - examples/echoserver/echoserver.c -ACLOCAL_AMFLAGS = -I m4 -src_libcyassl_la_SOURCES = $(am__append_1) src/internal.c src/io.c \ - src/keys.c src/ssl.c src/tls.c ctaocrypt/src/hmac.c \ - ctaocrypt/src/random.c ctaocrypt/src/sha256.c \ - ctaocrypt/src/logging.c ctaocrypt/src/wc_port.c \ - ctaocrypt/src/error.c $(am__append_2) $(am__append_3) \ - $(am__append_4) $(am__append_5) $(am__append_6) \ - $(am__append_7) $(am__append_8) $(am__append_9) \ - $(am__append_10) $(am__append_11) $(am__append_12) \ - $(am__append_13) $(am__append_14) $(am__append_15) \ - $(am__append_16) $(am__append_17) $(am__append_18) \ - $(am__append_19) $(am__append_20) $(am__append_21) \ - $(am__append_22) $(am__append_23) $(am__append_24) \ - $(am__append_25) $(am__append_26) $(am__append_27) \ - $(am__append_28) $(am__append_29) $(am__append_30) \ - $(am__append_31) $(am__append_32) $(am__append_33) -src_libcyassl_la_LDFLAGS = ${AM_LDFLAGS} -no-undefined -version-info ${CYASSL_LIBRARY_VERSION} -src_libcyassl_la_LIBADD = $(LIBM) -src_libcyassl_la_CFLAGS = -DBUILDING_CYASSL $(AM_CFLAGS) -src_libcyassl_la_CPPFLAGS = -DBUILDING_CYASSL $(AM_CPPFLAGS) -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = support/cyassl.pc -ctaocrypt_benchmark_benchmark_SOURCES = ctaocrypt/benchmark/benchmark.c -ctaocrypt_benchmark_benchmark_LDADD = src/libcyassl.la -ctaocrypt_benchmark_benchmark_DEPENDENCIES = src/libcyassl.la -ctaocrypt_test_testctaocrypt_SOURCES = ctaocrypt/test/test.c -ctaocrypt_test_testctaocrypt_LDADD = src/libcyassl.la -ctaocrypt_test_testctaocrypt_DEPENDENCIES = src/libcyassl.la -@BUILD_EXAMPLES_TRUE@examples_client_client_SOURCES = examples/client/client.c -@BUILD_EXAMPLES_TRUE@examples_client_client_LDADD = src/libcyassl.la -@BUILD_EXAMPLES_TRUE@examples_client_client_DEPENDENCIES = src/libcyassl.la -@BUILD_EXAMPLES_TRUE@examples_server_server_SOURCES = examples/server/server.c -@BUILD_EXAMPLES_TRUE@examples_server_server_LDADD = src/libcyassl.la -@BUILD_EXAMPLES_TRUE@examples_server_server_DEPENDENCIES = src/libcyassl.la -@BUILD_EXAMPLES_TRUE@examples_echoclient_echoclient_SOURCES = examples/echoclient/echoclient.c -@BUILD_EXAMPLES_TRUE@examples_echoclient_echoclient_LDADD = src/libcyassl.la -@BUILD_EXAMPLES_TRUE@examples_echoclient_echoclient_DEPENDENCIES = src/libcyassl.la -@BUILD_EXAMPLES_TRUE@examples_echoserver_echoserver_SOURCES = examples/echoserver/echoserver.c -@BUILD_EXAMPLES_TRUE@examples_echoserver_echoserver_LDADD = src/libcyassl.la -@BUILD_EXAMPLES_TRUE@examples_echoserver_echoserver_DEPENDENCIES = src/libcyassl.la -@BUILD_EXAMPLES_TRUE@testsuite_testsuite_test_SOURCES = \ -@BUILD_EXAMPLES_TRUE@ ctaocrypt/test/test.c \ -@BUILD_EXAMPLES_TRUE@ examples/client/client.c \ -@BUILD_EXAMPLES_TRUE@ examples/echoclient/echoclient.c \ -@BUILD_EXAMPLES_TRUE@ examples/echoserver/echoserver.c \ -@BUILD_EXAMPLES_TRUE@ examples/server/server.c \ -@BUILD_EXAMPLES_TRUE@ testsuite/testsuite.c - -@BUILD_EXAMPLES_TRUE@testsuite_testsuite_test_CFLAGS = -DNO_MAIN_DRIVER $(AM_CFLAGS) -@BUILD_EXAMPLES_TRUE@testsuite_testsuite_test_LDADD = src/libcyassl.la -@BUILD_EXAMPLES_TRUE@testsuite_testsuite_test_DEPENDENCIES = src/libcyassl.la -@BUILD_EXAMPLES_TRUE@tests_unit_test_SOURCES = \ -@BUILD_EXAMPLES_TRUE@ tests/unit.c \ -@BUILD_EXAMPLES_TRUE@ tests/api.c \ -@BUILD_EXAMPLES_TRUE@ tests/suites.c \ -@BUILD_EXAMPLES_TRUE@ tests/hash.c \ -@BUILD_EXAMPLES_TRUE@ examples/client/client.c \ -@BUILD_EXAMPLES_TRUE@ examples/server/server.c - -@BUILD_EXAMPLES_TRUE@tests_unit_test_CFLAGS = -DNO_MAIN_DRIVER $(AM_CFLAGS) -@BUILD_EXAMPLES_TRUE@tests_unit_test_LDADD = src/libcyassl.la -@BUILD_EXAMPLES_TRUE@tests_unit_test_DEPENDENCIES = src/libcyassl.la -@BUILD_SNIFFTEST_TRUE@sslSniffer_sslSnifferTest_snifftest_SOURCES = sslSniffer/sslSnifferTest/snifftest.c -@BUILD_SNIFFTEST_TRUE@sslSniffer_sslSnifferTest_snifftest_LDADD = src/libcyassl.la -lpcap -@BUILD_SNIFFTEST_TRUE@sslSniffer_sslSnifferTest_snifftest_DEPENDENCIES = src/libcyassl.la -@BUILD_MCAPI_TRUE@mcapi_test_SOURCES = mcapi/crypto.c \ -@BUILD_MCAPI_TRUE@ mcapi/mcapi_test.c - -@BUILD_MCAPI_TRUE@mcapi_test_LDADD = src/libcyassl.la -@BUILD_MCAPI_TRUE@mcapi_test_DEPENDENCIES = src/libcyassl.la -@USE_VALGRIND_TRUE@TESTS_ENVIRONMENT = ./valgrind-error.sh -TEST_EXTENSIONS = .test -all: $(BUILT_SOURCES) config.h - $(MAKE) $(AM_MAKEFLAGS) all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .s .test .test$(EXEEXT) .trs -am--refresh: Makefile - @: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/cyassl/include.am $(srcdir)/cyassl/ctaocrypt/include.am $(srcdir)/cyassl/openssl/include.am $(srcdir)/certs/include.am $(srcdir)/certs/1024/include.am $(srcdir)/certs/crl/include.am $(srcdir)/doc/include.am $(srcdir)/swig/include.am $(srcdir)/src/include.am $(srcdir)/support/include.am $(srcdir)/ctaocrypt/benchmark/include.am $(srcdir)/ctaocrypt/src/include.am $(srcdir)/ctaocrypt/test/include.am $(srcdir)/examples/client/include.am $(srcdir)/examples/server/include.am $(srcdir)/examples/echoclient/include.am $(srcdir)/examples/echoserver/include.am $(srcdir)/testsuite/include.am $(srcdir)/tests/include.am $(srcdir)/sslSniffer/sslSnifferTest/include.am $(srcdir)/rpm/include.am $(srcdir)/mqx/ctaocrypt_test/Sources/include.am $(srcdir)/mqx/cyassl/include.am $(srcdir)/mqx/cyassl_client/Sources/include.am $(srcdir)/mqx/util_lib/Sources/include.am $(srcdir)/mplabx/include.am $(srcdir)/mplabx/ctaocrypt_benchmark.X/nbproject/include.am $(srcdir)/mplabx/ctaocrypt_test.X/nbproject/include.am $(srcdir)/mplabx/cyassl.X/nbproject/include.am $(srcdir)/mcapi/include.am $(srcdir)/mcapi/ctaocrypt_mcapi.X/nbproject/include.am $(srcdir)/mcapi/ctaocrypt_test.X/nbproject/include.am $(srcdir)/mcapi/cyassl.X/nbproject/include.am $(srcdir)/mcapi/zlib.X/nbproject/include.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ - $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - echo ' $(SHELL) ./config.status'; \ - $(SHELL) ./config.status;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ - esac; -$(srcdir)/cyassl/include.am $(srcdir)/cyassl/ctaocrypt/include.am $(srcdir)/cyassl/openssl/include.am $(srcdir)/certs/include.am $(srcdir)/certs/1024/include.am $(srcdir)/certs/crl/include.am $(srcdir)/doc/include.am $(srcdir)/swig/include.am $(srcdir)/src/include.am $(srcdir)/support/include.am $(srcdir)/ctaocrypt/benchmark/include.am $(srcdir)/ctaocrypt/src/include.am $(srcdir)/ctaocrypt/test/include.am $(srcdir)/examples/client/include.am $(srcdir)/examples/server/include.am $(srcdir)/examples/echoclient/include.am $(srcdir)/examples/echoserver/include.am $(srcdir)/testsuite/include.am $(srcdir)/tests/include.am $(srcdir)/sslSniffer/sslSnifferTest/include.am $(srcdir)/rpm/include.am $(srcdir)/mqx/ctaocrypt_test/Sources/include.am $(srcdir)/mqx/cyassl/include.am $(srcdir)/mqx/cyassl_client/Sources/include.am $(srcdir)/mqx/util_lib/Sources/include.am $(srcdir)/mplabx/include.am $(srcdir)/mplabx/ctaocrypt_benchmark.X/nbproject/include.am $(srcdir)/mplabx/ctaocrypt_test.X/nbproject/include.am $(srcdir)/mplabx/cyassl.X/nbproject/include.am $(srcdir)/mcapi/include.am $(srcdir)/mcapi/ctaocrypt_mcapi.X/nbproject/include.am $(srcdir)/mcapi/ctaocrypt_test.X/nbproject/include.am $(srcdir)/mcapi/cyassl.X/nbproject/include.am $(srcdir)/mcapi/zlib.X/nbproject/include.am: - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck - -$(top_srcdir)/configure: $(am__configure_deps) - $(am__cd) $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -$(am__aclocal_m4_deps): - -config.h: stamp-h1 - @test -f $@ || rm -f stamp-h1 - @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 - -stamp-h1: $(srcdir)/config.in $(top_builddir)/config.status - @rm -f stamp-h1 - cd $(top_builddir) && $(SHELL) ./config.status config.h -$(srcdir)/config.in: $(am__configure_deps) - ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) - rm -f stamp-h1 - touch $@ - -distclean-hdr: - -rm -f config.h stamp-h1 -stamp-h: $(top_builddir)/config.status $(srcdir)/stamp-h.in - cd $(top_builddir) && $(SHELL) ./config.status $@ -cyassl/version.h: $(top_builddir)/config.status $(top_srcdir)/cyassl/version.h.in - cd $(top_builddir) && $(SHELL) ./config.status $@ -cyassl/options.h: $(top_builddir)/config.status $(top_srcdir)/cyassl/options.h.in - cd $(top_builddir) && $(SHELL) ./config.status $@ -support/cyassl.pc: $(top_builddir)/config.status $(top_srcdir)/support/cyassl.pc.in - cd $(top_builddir) && $(SHELL) ./config.status $@ -rpm/spec: $(top_builddir)/config.status $(top_srcdir)/rpm/spec.in - cd $(top_builddir) && $(SHELL) ./config.status $@ - -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ - } - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ - done - -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - @list='$(lib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } -ctaocrypt/src/$(am__dirstamp): - @$(MKDIR_P) ctaocrypt/src - @: > ctaocrypt/src/$(am__dirstamp) -ctaocrypt/src/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) ctaocrypt/src/$(DEPDIR) - @: > ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-wolfcrypt_first.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -src/$(am__dirstamp): - @$(MKDIR_P) src - @: > src/$(am__dirstamp) -src/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) src/$(DEPDIR) - @: > src/$(DEPDIR)/$(am__dirstamp) -src/src_libcyassl_la-internal.lo: src/$(am__dirstamp) \ - src/$(DEPDIR)/$(am__dirstamp) -src/src_libcyassl_la-io.lo: src/$(am__dirstamp) \ - src/$(DEPDIR)/$(am__dirstamp) -src/src_libcyassl_la-keys.lo: src/$(am__dirstamp) \ - src/$(DEPDIR)/$(am__dirstamp) -src/src_libcyassl_la-ssl.lo: src/$(am__dirstamp) \ - src/$(DEPDIR)/$(am__dirstamp) -src/src_libcyassl_la-tls.lo: src/$(am__dirstamp) \ - src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-hmac.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-random.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-sha256.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-logging.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-wc_port.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-error.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-memory.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-rsa.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-dh.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-asn.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-fips.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-fips_test.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-coding.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-aes.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-des3.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-sha.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-arc4.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-md4.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-md5.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-pwdbased.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-dsa.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/aes_asm.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-camellia.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-md2.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-ripemd.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-sha512.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-blake2b.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -src/src_libcyassl_la-sniffer.lo: src/$(am__dirstamp) \ - src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-hc128.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-rabbit.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-misc.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-tfm.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-integer.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-ecc.lo: ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -src/src_libcyassl_la-ocsp.lo: src/$(am__dirstamp) \ - src/$(DEPDIR)/$(am__dirstamp) -src/src_libcyassl_la-crl.lo: src/$(am__dirstamp) \ - src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-compress.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-pkcs7.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/src/src_libcyassl_la-wolfcrypt_last.lo: \ - ctaocrypt/src/$(am__dirstamp) \ - ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) - -src/libcyassl.la: $(src_libcyassl_la_OBJECTS) $(src_libcyassl_la_DEPENDENCIES) $(EXTRA_src_libcyassl_la_DEPENDENCIES) src/$(am__dirstamp) - $(AM_V_CCLD)$(src_libcyassl_la_LINK) -rpath $(libdir) $(src_libcyassl_la_OBJECTS) $(src_libcyassl_la_LIBADD) $(LIBS) -install-binPROGRAMS: $(bin_PROGRAMS) - @$(NORMAL_INSTALL) - @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ - fi; \ - for p in $$list; do echo "$$p $$p"; done | \ - sed 's/$(EXEEXT)$$//' | \ - while read p p1; do if test -f $$p \ - || test -f $$p1 \ - ; then echo "$$p"; echo "$$p"; else :; fi; \ - done | \ - sed -e 'p;s,.*/,,;n;h' \ - -e 's|.*|.|' \ - -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ - sed 'N;N;N;s,\n, ,g' | \ - $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ - { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ - if ($$2 == $$4) files[d] = files[d] " " $$1; \ - else { print "f", $$3 "/" $$4, $$1; } } \ - END { for (d in files) print "f", d, files[d] }' | \ - while read type dir files; do \ - if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ - test -z "$$files" || { \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ - } \ - ; done - -uninstall-binPROGRAMS: - @$(NORMAL_UNINSTALL) - @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ - files=`for p in $$list; do echo "$$p"; done | \ - sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ - -e 's/$$/$(EXEEXT)/' \ - `; \ - test -n "$$list" || exit 0; \ - echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(bindir)" && rm -f $$files - -clean-binPROGRAMS: - @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -clean-checkPROGRAMS: - @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list -ctaocrypt/benchmark/$(am__dirstamp): - @$(MKDIR_P) ctaocrypt/benchmark - @: > ctaocrypt/benchmark/$(am__dirstamp) -ctaocrypt/benchmark/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) ctaocrypt/benchmark/$(DEPDIR) - @: > ctaocrypt/benchmark/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/benchmark/benchmark.$(OBJEXT): \ - ctaocrypt/benchmark/$(am__dirstamp) \ - ctaocrypt/benchmark/$(DEPDIR)/$(am__dirstamp) - -ctaocrypt/benchmark/benchmark$(EXEEXT): $(ctaocrypt_benchmark_benchmark_OBJECTS) $(ctaocrypt_benchmark_benchmark_DEPENDENCIES) $(EXTRA_ctaocrypt_benchmark_benchmark_DEPENDENCIES) ctaocrypt/benchmark/$(am__dirstamp) - @rm -f ctaocrypt/benchmark/benchmark$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(ctaocrypt_benchmark_benchmark_OBJECTS) $(ctaocrypt_benchmark_benchmark_LDADD) $(LIBS) -ctaocrypt/test/$(am__dirstamp): - @$(MKDIR_P) ctaocrypt/test - @: > ctaocrypt/test/$(am__dirstamp) -ctaocrypt/test/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) ctaocrypt/test/$(DEPDIR) - @: > ctaocrypt/test/$(DEPDIR)/$(am__dirstamp) -ctaocrypt/test/test.$(OBJEXT): ctaocrypt/test/$(am__dirstamp) \ - ctaocrypt/test/$(DEPDIR)/$(am__dirstamp) - -ctaocrypt/test/testctaocrypt$(EXEEXT): $(ctaocrypt_test_testctaocrypt_OBJECTS) $(ctaocrypt_test_testctaocrypt_DEPENDENCIES) $(EXTRA_ctaocrypt_test_testctaocrypt_DEPENDENCIES) ctaocrypt/test/$(am__dirstamp) - @rm -f ctaocrypt/test/testctaocrypt$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(ctaocrypt_test_testctaocrypt_OBJECTS) $(ctaocrypt_test_testctaocrypt_LDADD) $(LIBS) -examples/client/$(am__dirstamp): - @$(MKDIR_P) examples/client - @: > examples/client/$(am__dirstamp) -examples/client/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) examples/client/$(DEPDIR) - @: > examples/client/$(DEPDIR)/$(am__dirstamp) -examples/client/client.$(OBJEXT): examples/client/$(am__dirstamp) \ - examples/client/$(DEPDIR)/$(am__dirstamp) - -examples/client/client$(EXEEXT): $(examples_client_client_OBJECTS) $(examples_client_client_DEPENDENCIES) $(EXTRA_examples_client_client_DEPENDENCIES) examples/client/$(am__dirstamp) - @rm -f examples/client/client$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(examples_client_client_OBJECTS) $(examples_client_client_LDADD) $(LIBS) -examples/echoclient/$(am__dirstamp): - @$(MKDIR_P) examples/echoclient - @: > examples/echoclient/$(am__dirstamp) -examples/echoclient/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) examples/echoclient/$(DEPDIR) - @: > examples/echoclient/$(DEPDIR)/$(am__dirstamp) -examples/echoclient/echoclient.$(OBJEXT): \ - examples/echoclient/$(am__dirstamp) \ - examples/echoclient/$(DEPDIR)/$(am__dirstamp) - -examples/echoclient/echoclient$(EXEEXT): $(examples_echoclient_echoclient_OBJECTS) $(examples_echoclient_echoclient_DEPENDENCIES) $(EXTRA_examples_echoclient_echoclient_DEPENDENCIES) examples/echoclient/$(am__dirstamp) - @rm -f examples/echoclient/echoclient$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(examples_echoclient_echoclient_OBJECTS) $(examples_echoclient_echoclient_LDADD) $(LIBS) -examples/echoserver/$(am__dirstamp): - @$(MKDIR_P) examples/echoserver - @: > examples/echoserver/$(am__dirstamp) -examples/echoserver/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) examples/echoserver/$(DEPDIR) - @: > examples/echoserver/$(DEPDIR)/$(am__dirstamp) -examples/echoserver/echoserver.$(OBJEXT): \ - examples/echoserver/$(am__dirstamp) \ - examples/echoserver/$(DEPDIR)/$(am__dirstamp) - -examples/echoserver/echoserver$(EXEEXT): $(examples_echoserver_echoserver_OBJECTS) $(examples_echoserver_echoserver_DEPENDENCIES) $(EXTRA_examples_echoserver_echoserver_DEPENDENCIES) examples/echoserver/$(am__dirstamp) - @rm -f examples/echoserver/echoserver$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(examples_echoserver_echoserver_OBJECTS) $(examples_echoserver_echoserver_LDADD) $(LIBS) -examples/server/$(am__dirstamp): - @$(MKDIR_P) examples/server - @: > examples/server/$(am__dirstamp) -examples/server/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) examples/server/$(DEPDIR) - @: > examples/server/$(DEPDIR)/$(am__dirstamp) -examples/server/server.$(OBJEXT): examples/server/$(am__dirstamp) \ - examples/server/$(DEPDIR)/$(am__dirstamp) - -examples/server/server$(EXEEXT): $(examples_server_server_OBJECTS) $(examples_server_server_DEPENDENCIES) $(EXTRA_examples_server_server_DEPENDENCIES) examples/server/$(am__dirstamp) - @rm -f examples/server/server$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(examples_server_server_OBJECTS) $(examples_server_server_LDADD) $(LIBS) -mcapi/$(am__dirstamp): - @$(MKDIR_P) mcapi - @: > mcapi/$(am__dirstamp) -mcapi/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) mcapi/$(DEPDIR) - @: > mcapi/$(DEPDIR)/$(am__dirstamp) -mcapi/crypto.$(OBJEXT): mcapi/$(am__dirstamp) \ - mcapi/$(DEPDIR)/$(am__dirstamp) -mcapi/mcapi_test.$(OBJEXT): mcapi/$(am__dirstamp) \ - mcapi/$(DEPDIR)/$(am__dirstamp) - -mcapi/test$(EXEEXT): $(mcapi_test_OBJECTS) $(mcapi_test_DEPENDENCIES) $(EXTRA_mcapi_test_DEPENDENCIES) mcapi/$(am__dirstamp) - @rm -f mcapi/test$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(mcapi_test_OBJECTS) $(mcapi_test_LDADD) $(LIBS) -sslSniffer/sslSnifferTest/$(am__dirstamp): - @$(MKDIR_P) sslSniffer/sslSnifferTest - @: > sslSniffer/sslSnifferTest/$(am__dirstamp) -sslSniffer/sslSnifferTest/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) sslSniffer/sslSnifferTest/$(DEPDIR) - @: > sslSniffer/sslSnifferTest/$(DEPDIR)/$(am__dirstamp) -sslSniffer/sslSnifferTest/snifftest.$(OBJEXT): \ - sslSniffer/sslSnifferTest/$(am__dirstamp) \ - sslSniffer/sslSnifferTest/$(DEPDIR)/$(am__dirstamp) - -sslSniffer/sslSnifferTest/snifftest$(EXEEXT): $(sslSniffer_sslSnifferTest_snifftest_OBJECTS) $(sslSniffer_sslSnifferTest_snifftest_DEPENDENCIES) $(EXTRA_sslSniffer_sslSnifferTest_snifftest_DEPENDENCIES) sslSniffer/sslSnifferTest/$(am__dirstamp) - @rm -f sslSniffer/sslSnifferTest/snifftest$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(sslSniffer_sslSnifferTest_snifftest_OBJECTS) $(sslSniffer_sslSnifferTest_snifftest_LDADD) $(LIBS) -tests/$(am__dirstamp): - @$(MKDIR_P) tests - @: > tests/$(am__dirstamp) -tests/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) tests/$(DEPDIR) - @: > tests/$(DEPDIR)/$(am__dirstamp) -tests/tests_unit_test-unit.$(OBJEXT): tests/$(am__dirstamp) \ - tests/$(DEPDIR)/$(am__dirstamp) -tests/tests_unit_test-api.$(OBJEXT): tests/$(am__dirstamp) \ - tests/$(DEPDIR)/$(am__dirstamp) -tests/tests_unit_test-suites.$(OBJEXT): tests/$(am__dirstamp) \ - tests/$(DEPDIR)/$(am__dirstamp) -tests/tests_unit_test-hash.$(OBJEXT): tests/$(am__dirstamp) \ - tests/$(DEPDIR)/$(am__dirstamp) -examples/client/tests_unit_test-client.$(OBJEXT): \ - examples/client/$(am__dirstamp) \ - examples/client/$(DEPDIR)/$(am__dirstamp) -examples/server/tests_unit_test-server.$(OBJEXT): \ - examples/server/$(am__dirstamp) \ - examples/server/$(DEPDIR)/$(am__dirstamp) - -tests/unit.test$(EXEEXT): $(tests_unit_test_OBJECTS) $(tests_unit_test_DEPENDENCIES) $(EXTRA_tests_unit_test_DEPENDENCIES) tests/$(am__dirstamp) - @rm -f tests/unit.test$(EXEEXT) - $(AM_V_CCLD)$(tests_unit_test_LINK) $(tests_unit_test_OBJECTS) $(tests_unit_test_LDADD) $(LIBS) -ctaocrypt/test/testsuite_testsuite_test-test.$(OBJEXT): \ - ctaocrypt/test/$(am__dirstamp) \ - ctaocrypt/test/$(DEPDIR)/$(am__dirstamp) -examples/client/testsuite_testsuite_test-client.$(OBJEXT): \ - examples/client/$(am__dirstamp) \ - examples/client/$(DEPDIR)/$(am__dirstamp) -examples/echoclient/testsuite_testsuite_test-echoclient.$(OBJEXT): \ - examples/echoclient/$(am__dirstamp) \ - examples/echoclient/$(DEPDIR)/$(am__dirstamp) -examples/echoserver/testsuite_testsuite_test-echoserver.$(OBJEXT): \ - examples/echoserver/$(am__dirstamp) \ - examples/echoserver/$(DEPDIR)/$(am__dirstamp) -examples/server/testsuite_testsuite_test-server.$(OBJEXT): \ - examples/server/$(am__dirstamp) \ - examples/server/$(DEPDIR)/$(am__dirstamp) -testsuite/$(am__dirstamp): - @$(MKDIR_P) testsuite - @: > testsuite/$(am__dirstamp) -testsuite/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) testsuite/$(DEPDIR) - @: > testsuite/$(DEPDIR)/$(am__dirstamp) -testsuite/testsuite_testsuite_test-testsuite.$(OBJEXT): \ - testsuite/$(am__dirstamp) testsuite/$(DEPDIR)/$(am__dirstamp) - -testsuite/testsuite.test$(EXEEXT): $(testsuite_testsuite_test_OBJECTS) $(testsuite_testsuite_test_DEPENDENCIES) $(EXTRA_testsuite_testsuite_test_DEPENDENCIES) testsuite/$(am__dirstamp) - @rm -f testsuite/testsuite.test$(EXEEXT) - $(AM_V_CCLD)$(testsuite_testsuite_test_LINK) $(testsuite_testsuite_test_OBJECTS) $(testsuite_testsuite_test_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -rm -f ctaocrypt/benchmark/*.$(OBJEXT) - -rm -f ctaocrypt/src/*.$(OBJEXT) - -rm -f ctaocrypt/src/*.lo - -rm -f ctaocrypt/test/*.$(OBJEXT) - -rm -f examples/client/*.$(OBJEXT) - -rm -f examples/echoclient/*.$(OBJEXT) - -rm -f examples/echoserver/*.$(OBJEXT) - -rm -f examples/server/*.$(OBJEXT) - -rm -f mcapi/*.$(OBJEXT) - -rm -f src/*.$(OBJEXT) - -rm -f src/*.lo - -rm -f sslSniffer/sslSnifferTest/*.$(OBJEXT) - -rm -f tests/*.$(OBJEXT) - -rm -f testsuite/*.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/benchmark/$(DEPDIR)/benchmark.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-aes.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-arc4.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-asn.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-blake2b.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-camellia.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-coding.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-compress.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-des3.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-dh.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-dsa.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-ecc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-error.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-fips.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-fips_test.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-hc128.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-hmac.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-integer.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-logging.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-md2.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-md4.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-md5.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-memory.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-misc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-pkcs7.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-pwdbased.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-rabbit.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-random.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-ripemd.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-rsa.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-sha.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-sha256.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-sha512.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-tfm.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-wc_port.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-wolfcrypt_first.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-wolfcrypt_last.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/test/$(DEPDIR)/test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ctaocrypt/test/$(DEPDIR)/testsuite_testsuite_test-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@examples/client/$(DEPDIR)/client.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@examples/client/$(DEPDIR)/tests_unit_test-client.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@examples/client/$(DEPDIR)/testsuite_testsuite_test-client.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@examples/echoclient/$(DEPDIR)/echoclient.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@examples/echoclient/$(DEPDIR)/testsuite_testsuite_test-echoclient.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@examples/echoserver/$(DEPDIR)/echoserver.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@examples/echoserver/$(DEPDIR)/testsuite_testsuite_test-echoserver.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@examples/server/$(DEPDIR)/server.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@examples/server/$(DEPDIR)/tests_unit_test-server.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@examples/server/$(DEPDIR)/testsuite_testsuite_test-server.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@mcapi/$(DEPDIR)/crypto.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@mcapi/$(DEPDIR)/mcapi_test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libcyassl_la-crl.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libcyassl_la-internal.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libcyassl_la-io.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libcyassl_la-keys.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libcyassl_la-ocsp.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libcyassl_la-sniffer.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libcyassl_la-ssl.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libcyassl_la-tls.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@sslSniffer/sslSnifferTest/$(DEPDIR)/snifftest.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/tests_unit_test-api.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/tests_unit_test-hash.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/tests_unit_test-suites.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/tests_unit_test-unit.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@testsuite/$(DEPDIR)/testsuite_testsuite_test-testsuite.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -ctaocrypt/src/src_libcyassl_la-wolfcrypt_first.lo: ctaocrypt/src/wolfcrypt_first.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-wolfcrypt_first.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-wolfcrypt_first.Tpo -c -o ctaocrypt/src/src_libcyassl_la-wolfcrypt_first.lo `test -f 'ctaocrypt/src/wolfcrypt_first.c' || echo '$(srcdir)/'`ctaocrypt/src/wolfcrypt_first.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-wolfcrypt_first.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-wolfcrypt_first.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/wolfcrypt_first.c' object='ctaocrypt/src/src_libcyassl_la-wolfcrypt_first.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-wolfcrypt_first.lo `test -f 'ctaocrypt/src/wolfcrypt_first.c' || echo '$(srcdir)/'`ctaocrypt/src/wolfcrypt_first.c - -src/src_libcyassl_la-internal.lo: src/internal.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT src/src_libcyassl_la-internal.lo -MD -MP -MF src/$(DEPDIR)/src_libcyassl_la-internal.Tpo -c -o src/src_libcyassl_la-internal.lo `test -f 'src/internal.c' || echo '$(srcdir)/'`src/internal.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libcyassl_la-internal.Tpo src/$(DEPDIR)/src_libcyassl_la-internal.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/internal.c' object='src/src_libcyassl_la-internal.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o src/src_libcyassl_la-internal.lo `test -f 'src/internal.c' || echo '$(srcdir)/'`src/internal.c - -src/src_libcyassl_la-io.lo: src/io.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT src/src_libcyassl_la-io.lo -MD -MP -MF src/$(DEPDIR)/src_libcyassl_la-io.Tpo -c -o src/src_libcyassl_la-io.lo `test -f 'src/io.c' || echo '$(srcdir)/'`src/io.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libcyassl_la-io.Tpo src/$(DEPDIR)/src_libcyassl_la-io.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/io.c' object='src/src_libcyassl_la-io.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o src/src_libcyassl_la-io.lo `test -f 'src/io.c' || echo '$(srcdir)/'`src/io.c - -src/src_libcyassl_la-keys.lo: src/keys.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT src/src_libcyassl_la-keys.lo -MD -MP -MF src/$(DEPDIR)/src_libcyassl_la-keys.Tpo -c -o src/src_libcyassl_la-keys.lo `test -f 'src/keys.c' || echo '$(srcdir)/'`src/keys.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libcyassl_la-keys.Tpo src/$(DEPDIR)/src_libcyassl_la-keys.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/keys.c' object='src/src_libcyassl_la-keys.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o src/src_libcyassl_la-keys.lo `test -f 'src/keys.c' || echo '$(srcdir)/'`src/keys.c - -src/src_libcyassl_la-ssl.lo: src/ssl.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT src/src_libcyassl_la-ssl.lo -MD -MP -MF src/$(DEPDIR)/src_libcyassl_la-ssl.Tpo -c -o src/src_libcyassl_la-ssl.lo `test -f 'src/ssl.c' || echo '$(srcdir)/'`src/ssl.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libcyassl_la-ssl.Tpo src/$(DEPDIR)/src_libcyassl_la-ssl.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/ssl.c' object='src/src_libcyassl_la-ssl.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o src/src_libcyassl_la-ssl.lo `test -f 'src/ssl.c' || echo '$(srcdir)/'`src/ssl.c - -src/src_libcyassl_la-tls.lo: src/tls.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT src/src_libcyassl_la-tls.lo -MD -MP -MF src/$(DEPDIR)/src_libcyassl_la-tls.Tpo -c -o src/src_libcyassl_la-tls.lo `test -f 'src/tls.c' || echo '$(srcdir)/'`src/tls.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libcyassl_la-tls.Tpo src/$(DEPDIR)/src_libcyassl_la-tls.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/tls.c' object='src/src_libcyassl_la-tls.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o src/src_libcyassl_la-tls.lo `test -f 'src/tls.c' || echo '$(srcdir)/'`src/tls.c - -ctaocrypt/src/src_libcyassl_la-hmac.lo: ctaocrypt/src/hmac.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-hmac.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-hmac.Tpo -c -o ctaocrypt/src/src_libcyassl_la-hmac.lo `test -f 'ctaocrypt/src/hmac.c' || echo '$(srcdir)/'`ctaocrypt/src/hmac.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-hmac.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-hmac.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/hmac.c' object='ctaocrypt/src/src_libcyassl_la-hmac.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-hmac.lo `test -f 'ctaocrypt/src/hmac.c' || echo '$(srcdir)/'`ctaocrypt/src/hmac.c - -ctaocrypt/src/src_libcyassl_la-random.lo: ctaocrypt/src/random.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-random.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-random.Tpo -c -o ctaocrypt/src/src_libcyassl_la-random.lo `test -f 'ctaocrypt/src/random.c' || echo '$(srcdir)/'`ctaocrypt/src/random.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-random.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-random.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/random.c' object='ctaocrypt/src/src_libcyassl_la-random.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-random.lo `test -f 'ctaocrypt/src/random.c' || echo '$(srcdir)/'`ctaocrypt/src/random.c - -ctaocrypt/src/src_libcyassl_la-sha256.lo: ctaocrypt/src/sha256.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-sha256.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-sha256.Tpo -c -o ctaocrypt/src/src_libcyassl_la-sha256.lo `test -f 'ctaocrypt/src/sha256.c' || echo '$(srcdir)/'`ctaocrypt/src/sha256.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-sha256.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-sha256.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/sha256.c' object='ctaocrypt/src/src_libcyassl_la-sha256.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-sha256.lo `test -f 'ctaocrypt/src/sha256.c' || echo '$(srcdir)/'`ctaocrypt/src/sha256.c - -ctaocrypt/src/src_libcyassl_la-logging.lo: ctaocrypt/src/logging.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-logging.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-logging.Tpo -c -o ctaocrypt/src/src_libcyassl_la-logging.lo `test -f 'ctaocrypt/src/logging.c' || echo '$(srcdir)/'`ctaocrypt/src/logging.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-logging.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-logging.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/logging.c' object='ctaocrypt/src/src_libcyassl_la-logging.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-logging.lo `test -f 'ctaocrypt/src/logging.c' || echo '$(srcdir)/'`ctaocrypt/src/logging.c - -ctaocrypt/src/src_libcyassl_la-wc_port.lo: ctaocrypt/src/wc_port.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-wc_port.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-wc_port.Tpo -c -o ctaocrypt/src/src_libcyassl_la-wc_port.lo `test -f 'ctaocrypt/src/wc_port.c' || echo '$(srcdir)/'`ctaocrypt/src/wc_port.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-wc_port.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-wc_port.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/wc_port.c' object='ctaocrypt/src/src_libcyassl_la-wc_port.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-wc_port.lo `test -f 'ctaocrypt/src/wc_port.c' || echo '$(srcdir)/'`ctaocrypt/src/wc_port.c - -ctaocrypt/src/src_libcyassl_la-error.lo: ctaocrypt/src/error.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-error.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-error.Tpo -c -o ctaocrypt/src/src_libcyassl_la-error.lo `test -f 'ctaocrypt/src/error.c' || echo '$(srcdir)/'`ctaocrypt/src/error.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-error.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-error.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/error.c' object='ctaocrypt/src/src_libcyassl_la-error.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-error.lo `test -f 'ctaocrypt/src/error.c' || echo '$(srcdir)/'`ctaocrypt/src/error.c - -ctaocrypt/src/src_libcyassl_la-memory.lo: ctaocrypt/src/memory.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-memory.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-memory.Tpo -c -o ctaocrypt/src/src_libcyassl_la-memory.lo `test -f 'ctaocrypt/src/memory.c' || echo '$(srcdir)/'`ctaocrypt/src/memory.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-memory.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-memory.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/memory.c' object='ctaocrypt/src/src_libcyassl_la-memory.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-memory.lo `test -f 'ctaocrypt/src/memory.c' || echo '$(srcdir)/'`ctaocrypt/src/memory.c - -ctaocrypt/src/src_libcyassl_la-rsa.lo: ctaocrypt/src/rsa.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-rsa.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-rsa.Tpo -c -o ctaocrypt/src/src_libcyassl_la-rsa.lo `test -f 'ctaocrypt/src/rsa.c' || echo '$(srcdir)/'`ctaocrypt/src/rsa.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-rsa.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-rsa.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/rsa.c' object='ctaocrypt/src/src_libcyassl_la-rsa.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-rsa.lo `test -f 'ctaocrypt/src/rsa.c' || echo '$(srcdir)/'`ctaocrypt/src/rsa.c - -ctaocrypt/src/src_libcyassl_la-dh.lo: ctaocrypt/src/dh.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-dh.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-dh.Tpo -c -o ctaocrypt/src/src_libcyassl_la-dh.lo `test -f 'ctaocrypt/src/dh.c' || echo '$(srcdir)/'`ctaocrypt/src/dh.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-dh.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-dh.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/dh.c' object='ctaocrypt/src/src_libcyassl_la-dh.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-dh.lo `test -f 'ctaocrypt/src/dh.c' || echo '$(srcdir)/'`ctaocrypt/src/dh.c - -ctaocrypt/src/src_libcyassl_la-asn.lo: ctaocrypt/src/asn.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-asn.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-asn.Tpo -c -o ctaocrypt/src/src_libcyassl_la-asn.lo `test -f 'ctaocrypt/src/asn.c' || echo '$(srcdir)/'`ctaocrypt/src/asn.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-asn.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-asn.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/asn.c' object='ctaocrypt/src/src_libcyassl_la-asn.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-asn.lo `test -f 'ctaocrypt/src/asn.c' || echo '$(srcdir)/'`ctaocrypt/src/asn.c - -ctaocrypt/src/src_libcyassl_la-fips.lo: ctaocrypt/src/fips.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-fips.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-fips.Tpo -c -o ctaocrypt/src/src_libcyassl_la-fips.lo `test -f 'ctaocrypt/src/fips.c' || echo '$(srcdir)/'`ctaocrypt/src/fips.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-fips.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-fips.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/fips.c' object='ctaocrypt/src/src_libcyassl_la-fips.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-fips.lo `test -f 'ctaocrypt/src/fips.c' || echo '$(srcdir)/'`ctaocrypt/src/fips.c - -ctaocrypt/src/src_libcyassl_la-fips_test.lo: ctaocrypt/src/fips_test.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-fips_test.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-fips_test.Tpo -c -o ctaocrypt/src/src_libcyassl_la-fips_test.lo `test -f 'ctaocrypt/src/fips_test.c' || echo '$(srcdir)/'`ctaocrypt/src/fips_test.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-fips_test.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-fips_test.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/fips_test.c' object='ctaocrypt/src/src_libcyassl_la-fips_test.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-fips_test.lo `test -f 'ctaocrypt/src/fips_test.c' || echo '$(srcdir)/'`ctaocrypt/src/fips_test.c - -ctaocrypt/src/src_libcyassl_la-coding.lo: ctaocrypt/src/coding.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-coding.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-coding.Tpo -c -o ctaocrypt/src/src_libcyassl_la-coding.lo `test -f 'ctaocrypt/src/coding.c' || echo '$(srcdir)/'`ctaocrypt/src/coding.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-coding.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-coding.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/coding.c' object='ctaocrypt/src/src_libcyassl_la-coding.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-coding.lo `test -f 'ctaocrypt/src/coding.c' || echo '$(srcdir)/'`ctaocrypt/src/coding.c - -ctaocrypt/src/src_libcyassl_la-aes.lo: ctaocrypt/src/aes.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-aes.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-aes.Tpo -c -o ctaocrypt/src/src_libcyassl_la-aes.lo `test -f 'ctaocrypt/src/aes.c' || echo '$(srcdir)/'`ctaocrypt/src/aes.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-aes.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-aes.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/aes.c' object='ctaocrypt/src/src_libcyassl_la-aes.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-aes.lo `test -f 'ctaocrypt/src/aes.c' || echo '$(srcdir)/'`ctaocrypt/src/aes.c - -ctaocrypt/src/src_libcyassl_la-des3.lo: ctaocrypt/src/des3.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-des3.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-des3.Tpo -c -o ctaocrypt/src/src_libcyassl_la-des3.lo `test -f 'ctaocrypt/src/des3.c' || echo '$(srcdir)/'`ctaocrypt/src/des3.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-des3.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-des3.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/des3.c' object='ctaocrypt/src/src_libcyassl_la-des3.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-des3.lo `test -f 'ctaocrypt/src/des3.c' || echo '$(srcdir)/'`ctaocrypt/src/des3.c - -ctaocrypt/src/src_libcyassl_la-sha.lo: ctaocrypt/src/sha.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-sha.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-sha.Tpo -c -o ctaocrypt/src/src_libcyassl_la-sha.lo `test -f 'ctaocrypt/src/sha.c' || echo '$(srcdir)/'`ctaocrypt/src/sha.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-sha.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-sha.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/sha.c' object='ctaocrypt/src/src_libcyassl_la-sha.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-sha.lo `test -f 'ctaocrypt/src/sha.c' || echo '$(srcdir)/'`ctaocrypt/src/sha.c - -ctaocrypt/src/src_libcyassl_la-arc4.lo: ctaocrypt/src/arc4.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-arc4.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-arc4.Tpo -c -o ctaocrypt/src/src_libcyassl_la-arc4.lo `test -f 'ctaocrypt/src/arc4.c' || echo '$(srcdir)/'`ctaocrypt/src/arc4.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-arc4.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-arc4.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/arc4.c' object='ctaocrypt/src/src_libcyassl_la-arc4.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-arc4.lo `test -f 'ctaocrypt/src/arc4.c' || echo '$(srcdir)/'`ctaocrypt/src/arc4.c - -ctaocrypt/src/src_libcyassl_la-md4.lo: ctaocrypt/src/md4.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-md4.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-md4.Tpo -c -o ctaocrypt/src/src_libcyassl_la-md4.lo `test -f 'ctaocrypt/src/md4.c' || echo '$(srcdir)/'`ctaocrypt/src/md4.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-md4.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-md4.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/md4.c' object='ctaocrypt/src/src_libcyassl_la-md4.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-md4.lo `test -f 'ctaocrypt/src/md4.c' || echo '$(srcdir)/'`ctaocrypt/src/md4.c - -ctaocrypt/src/src_libcyassl_la-md5.lo: ctaocrypt/src/md5.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-md5.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-md5.Tpo -c -o ctaocrypt/src/src_libcyassl_la-md5.lo `test -f 'ctaocrypt/src/md5.c' || echo '$(srcdir)/'`ctaocrypt/src/md5.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-md5.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-md5.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/md5.c' object='ctaocrypt/src/src_libcyassl_la-md5.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-md5.lo `test -f 'ctaocrypt/src/md5.c' || echo '$(srcdir)/'`ctaocrypt/src/md5.c - -ctaocrypt/src/src_libcyassl_la-pwdbased.lo: ctaocrypt/src/pwdbased.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-pwdbased.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-pwdbased.Tpo -c -o ctaocrypt/src/src_libcyassl_la-pwdbased.lo `test -f 'ctaocrypt/src/pwdbased.c' || echo '$(srcdir)/'`ctaocrypt/src/pwdbased.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-pwdbased.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-pwdbased.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/pwdbased.c' object='ctaocrypt/src/src_libcyassl_la-pwdbased.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-pwdbased.lo `test -f 'ctaocrypt/src/pwdbased.c' || echo '$(srcdir)/'`ctaocrypt/src/pwdbased.c - -ctaocrypt/src/src_libcyassl_la-dsa.lo: ctaocrypt/src/dsa.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-dsa.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-dsa.Tpo -c -o ctaocrypt/src/src_libcyassl_la-dsa.lo `test -f 'ctaocrypt/src/dsa.c' || echo '$(srcdir)/'`ctaocrypt/src/dsa.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-dsa.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-dsa.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/dsa.c' object='ctaocrypt/src/src_libcyassl_la-dsa.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-dsa.lo `test -f 'ctaocrypt/src/dsa.c' || echo '$(srcdir)/'`ctaocrypt/src/dsa.c - -ctaocrypt/src/src_libcyassl_la-camellia.lo: ctaocrypt/src/camellia.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-camellia.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-camellia.Tpo -c -o ctaocrypt/src/src_libcyassl_la-camellia.lo `test -f 'ctaocrypt/src/camellia.c' || echo '$(srcdir)/'`ctaocrypt/src/camellia.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-camellia.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-camellia.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/camellia.c' object='ctaocrypt/src/src_libcyassl_la-camellia.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-camellia.lo `test -f 'ctaocrypt/src/camellia.c' || echo '$(srcdir)/'`ctaocrypt/src/camellia.c - -ctaocrypt/src/src_libcyassl_la-md2.lo: ctaocrypt/src/md2.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-md2.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-md2.Tpo -c -o ctaocrypt/src/src_libcyassl_la-md2.lo `test -f 'ctaocrypt/src/md2.c' || echo '$(srcdir)/'`ctaocrypt/src/md2.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-md2.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-md2.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/md2.c' object='ctaocrypt/src/src_libcyassl_la-md2.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-md2.lo `test -f 'ctaocrypt/src/md2.c' || echo '$(srcdir)/'`ctaocrypt/src/md2.c - -ctaocrypt/src/src_libcyassl_la-ripemd.lo: ctaocrypt/src/ripemd.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-ripemd.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-ripemd.Tpo -c -o ctaocrypt/src/src_libcyassl_la-ripemd.lo `test -f 'ctaocrypt/src/ripemd.c' || echo '$(srcdir)/'`ctaocrypt/src/ripemd.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-ripemd.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-ripemd.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/ripemd.c' object='ctaocrypt/src/src_libcyassl_la-ripemd.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-ripemd.lo `test -f 'ctaocrypt/src/ripemd.c' || echo '$(srcdir)/'`ctaocrypt/src/ripemd.c - -ctaocrypt/src/src_libcyassl_la-sha512.lo: ctaocrypt/src/sha512.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-sha512.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-sha512.Tpo -c -o ctaocrypt/src/src_libcyassl_la-sha512.lo `test -f 'ctaocrypt/src/sha512.c' || echo '$(srcdir)/'`ctaocrypt/src/sha512.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-sha512.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-sha512.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/sha512.c' object='ctaocrypt/src/src_libcyassl_la-sha512.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-sha512.lo `test -f 'ctaocrypt/src/sha512.c' || echo '$(srcdir)/'`ctaocrypt/src/sha512.c - -ctaocrypt/src/src_libcyassl_la-blake2b.lo: ctaocrypt/src/blake2b.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-blake2b.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-blake2b.Tpo -c -o ctaocrypt/src/src_libcyassl_la-blake2b.lo `test -f 'ctaocrypt/src/blake2b.c' || echo '$(srcdir)/'`ctaocrypt/src/blake2b.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-blake2b.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-blake2b.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/blake2b.c' object='ctaocrypt/src/src_libcyassl_la-blake2b.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-blake2b.lo `test -f 'ctaocrypt/src/blake2b.c' || echo '$(srcdir)/'`ctaocrypt/src/blake2b.c - -src/src_libcyassl_la-sniffer.lo: src/sniffer.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT src/src_libcyassl_la-sniffer.lo -MD -MP -MF src/$(DEPDIR)/src_libcyassl_la-sniffer.Tpo -c -o src/src_libcyassl_la-sniffer.lo `test -f 'src/sniffer.c' || echo '$(srcdir)/'`src/sniffer.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libcyassl_la-sniffer.Tpo src/$(DEPDIR)/src_libcyassl_la-sniffer.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/sniffer.c' object='src/src_libcyassl_la-sniffer.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o src/src_libcyassl_la-sniffer.lo `test -f 'src/sniffer.c' || echo '$(srcdir)/'`src/sniffer.c - -ctaocrypt/src/src_libcyassl_la-hc128.lo: ctaocrypt/src/hc128.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-hc128.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-hc128.Tpo -c -o ctaocrypt/src/src_libcyassl_la-hc128.lo `test -f 'ctaocrypt/src/hc128.c' || echo '$(srcdir)/'`ctaocrypt/src/hc128.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-hc128.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-hc128.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/hc128.c' object='ctaocrypt/src/src_libcyassl_la-hc128.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-hc128.lo `test -f 'ctaocrypt/src/hc128.c' || echo '$(srcdir)/'`ctaocrypt/src/hc128.c - -ctaocrypt/src/src_libcyassl_la-rabbit.lo: ctaocrypt/src/rabbit.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-rabbit.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-rabbit.Tpo -c -o ctaocrypt/src/src_libcyassl_la-rabbit.lo `test -f 'ctaocrypt/src/rabbit.c' || echo '$(srcdir)/'`ctaocrypt/src/rabbit.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-rabbit.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-rabbit.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/rabbit.c' object='ctaocrypt/src/src_libcyassl_la-rabbit.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-rabbit.lo `test -f 'ctaocrypt/src/rabbit.c' || echo '$(srcdir)/'`ctaocrypt/src/rabbit.c - -ctaocrypt/src/src_libcyassl_la-misc.lo: ctaocrypt/src/misc.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-misc.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-misc.Tpo -c -o ctaocrypt/src/src_libcyassl_la-misc.lo `test -f 'ctaocrypt/src/misc.c' || echo '$(srcdir)/'`ctaocrypt/src/misc.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-misc.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-misc.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/misc.c' object='ctaocrypt/src/src_libcyassl_la-misc.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-misc.lo `test -f 'ctaocrypt/src/misc.c' || echo '$(srcdir)/'`ctaocrypt/src/misc.c - -ctaocrypt/src/src_libcyassl_la-tfm.lo: ctaocrypt/src/tfm.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-tfm.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-tfm.Tpo -c -o ctaocrypt/src/src_libcyassl_la-tfm.lo `test -f 'ctaocrypt/src/tfm.c' || echo '$(srcdir)/'`ctaocrypt/src/tfm.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-tfm.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-tfm.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/tfm.c' object='ctaocrypt/src/src_libcyassl_la-tfm.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-tfm.lo `test -f 'ctaocrypt/src/tfm.c' || echo '$(srcdir)/'`ctaocrypt/src/tfm.c - -ctaocrypt/src/src_libcyassl_la-integer.lo: ctaocrypt/src/integer.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-integer.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-integer.Tpo -c -o ctaocrypt/src/src_libcyassl_la-integer.lo `test -f 'ctaocrypt/src/integer.c' || echo '$(srcdir)/'`ctaocrypt/src/integer.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-integer.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-integer.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/integer.c' object='ctaocrypt/src/src_libcyassl_la-integer.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-integer.lo `test -f 'ctaocrypt/src/integer.c' || echo '$(srcdir)/'`ctaocrypt/src/integer.c - -ctaocrypt/src/src_libcyassl_la-ecc.lo: ctaocrypt/src/ecc.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-ecc.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-ecc.Tpo -c -o ctaocrypt/src/src_libcyassl_la-ecc.lo `test -f 'ctaocrypt/src/ecc.c' || echo '$(srcdir)/'`ctaocrypt/src/ecc.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-ecc.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-ecc.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/ecc.c' object='ctaocrypt/src/src_libcyassl_la-ecc.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-ecc.lo `test -f 'ctaocrypt/src/ecc.c' || echo '$(srcdir)/'`ctaocrypt/src/ecc.c - -src/src_libcyassl_la-ocsp.lo: src/ocsp.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT src/src_libcyassl_la-ocsp.lo -MD -MP -MF src/$(DEPDIR)/src_libcyassl_la-ocsp.Tpo -c -o src/src_libcyassl_la-ocsp.lo `test -f 'src/ocsp.c' || echo '$(srcdir)/'`src/ocsp.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libcyassl_la-ocsp.Tpo src/$(DEPDIR)/src_libcyassl_la-ocsp.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/ocsp.c' object='src/src_libcyassl_la-ocsp.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o src/src_libcyassl_la-ocsp.lo `test -f 'src/ocsp.c' || echo '$(srcdir)/'`src/ocsp.c - -src/src_libcyassl_la-crl.lo: src/crl.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT src/src_libcyassl_la-crl.lo -MD -MP -MF src/$(DEPDIR)/src_libcyassl_la-crl.Tpo -c -o src/src_libcyassl_la-crl.lo `test -f 'src/crl.c' || echo '$(srcdir)/'`src/crl.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libcyassl_la-crl.Tpo src/$(DEPDIR)/src_libcyassl_la-crl.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/crl.c' object='src/src_libcyassl_la-crl.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o src/src_libcyassl_la-crl.lo `test -f 'src/crl.c' || echo '$(srcdir)/'`src/crl.c - -ctaocrypt/src/src_libcyassl_la-compress.lo: ctaocrypt/src/compress.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-compress.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-compress.Tpo -c -o ctaocrypt/src/src_libcyassl_la-compress.lo `test -f 'ctaocrypt/src/compress.c' || echo '$(srcdir)/'`ctaocrypt/src/compress.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-compress.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-compress.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/compress.c' object='ctaocrypt/src/src_libcyassl_la-compress.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-compress.lo `test -f 'ctaocrypt/src/compress.c' || echo '$(srcdir)/'`ctaocrypt/src/compress.c - -ctaocrypt/src/src_libcyassl_la-pkcs7.lo: ctaocrypt/src/pkcs7.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-pkcs7.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-pkcs7.Tpo -c -o ctaocrypt/src/src_libcyassl_la-pkcs7.lo `test -f 'ctaocrypt/src/pkcs7.c' || echo '$(srcdir)/'`ctaocrypt/src/pkcs7.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-pkcs7.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-pkcs7.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/pkcs7.c' object='ctaocrypt/src/src_libcyassl_la-pkcs7.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-pkcs7.lo `test -f 'ctaocrypt/src/pkcs7.c' || echo '$(srcdir)/'`ctaocrypt/src/pkcs7.c - -ctaocrypt/src/src_libcyassl_la-wolfcrypt_last.lo: ctaocrypt/src/wolfcrypt_last.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -MT ctaocrypt/src/src_libcyassl_la-wolfcrypt_last.lo -MD -MP -MF ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-wolfcrypt_last.Tpo -c -o ctaocrypt/src/src_libcyassl_la-wolfcrypt_last.lo `test -f 'ctaocrypt/src/wolfcrypt_last.c' || echo '$(srcdir)/'`ctaocrypt/src/wolfcrypt_last.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-wolfcrypt_last.Tpo ctaocrypt/src/$(DEPDIR)/src_libcyassl_la-wolfcrypt_last.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/src/wolfcrypt_last.c' object='ctaocrypt/src/src_libcyassl_la-wolfcrypt_last.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libcyassl_la_CPPFLAGS) $(CPPFLAGS) $(src_libcyassl_la_CFLAGS) $(CFLAGS) -c -o ctaocrypt/src/src_libcyassl_la-wolfcrypt_last.lo `test -f 'ctaocrypt/src/wolfcrypt_last.c' || echo '$(srcdir)/'`ctaocrypt/src/wolfcrypt_last.c - -tests/tests_unit_test-unit.o: tests/unit.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -MT tests/tests_unit_test-unit.o -MD -MP -MF tests/$(DEPDIR)/tests_unit_test-unit.Tpo -c -o tests/tests_unit_test-unit.o `test -f 'tests/unit.c' || echo '$(srcdir)/'`tests/unit.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/tests_unit_test-unit.Tpo tests/$(DEPDIR)/tests_unit_test-unit.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/unit.c' object='tests/tests_unit_test-unit.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -c -o tests/tests_unit_test-unit.o `test -f 'tests/unit.c' || echo '$(srcdir)/'`tests/unit.c - -tests/tests_unit_test-unit.obj: tests/unit.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -MT tests/tests_unit_test-unit.obj -MD -MP -MF tests/$(DEPDIR)/tests_unit_test-unit.Tpo -c -o tests/tests_unit_test-unit.obj `if test -f 'tests/unit.c'; then $(CYGPATH_W) 'tests/unit.c'; else $(CYGPATH_W) '$(srcdir)/tests/unit.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/tests_unit_test-unit.Tpo tests/$(DEPDIR)/tests_unit_test-unit.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/unit.c' object='tests/tests_unit_test-unit.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -c -o tests/tests_unit_test-unit.obj `if test -f 'tests/unit.c'; then $(CYGPATH_W) 'tests/unit.c'; else $(CYGPATH_W) '$(srcdir)/tests/unit.c'; fi` - -tests/tests_unit_test-api.o: tests/api.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -MT tests/tests_unit_test-api.o -MD -MP -MF tests/$(DEPDIR)/tests_unit_test-api.Tpo -c -o tests/tests_unit_test-api.o `test -f 'tests/api.c' || echo '$(srcdir)/'`tests/api.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/tests_unit_test-api.Tpo tests/$(DEPDIR)/tests_unit_test-api.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/api.c' object='tests/tests_unit_test-api.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -c -o tests/tests_unit_test-api.o `test -f 'tests/api.c' || echo '$(srcdir)/'`tests/api.c - -tests/tests_unit_test-api.obj: tests/api.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -MT tests/tests_unit_test-api.obj -MD -MP -MF tests/$(DEPDIR)/tests_unit_test-api.Tpo -c -o tests/tests_unit_test-api.obj `if test -f 'tests/api.c'; then $(CYGPATH_W) 'tests/api.c'; else $(CYGPATH_W) '$(srcdir)/tests/api.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/tests_unit_test-api.Tpo tests/$(DEPDIR)/tests_unit_test-api.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/api.c' object='tests/tests_unit_test-api.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -c -o tests/tests_unit_test-api.obj `if test -f 'tests/api.c'; then $(CYGPATH_W) 'tests/api.c'; else $(CYGPATH_W) '$(srcdir)/tests/api.c'; fi` - -tests/tests_unit_test-suites.o: tests/suites.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -MT tests/tests_unit_test-suites.o -MD -MP -MF tests/$(DEPDIR)/tests_unit_test-suites.Tpo -c -o tests/tests_unit_test-suites.o `test -f 'tests/suites.c' || echo '$(srcdir)/'`tests/suites.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/tests_unit_test-suites.Tpo tests/$(DEPDIR)/tests_unit_test-suites.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/suites.c' object='tests/tests_unit_test-suites.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -c -o tests/tests_unit_test-suites.o `test -f 'tests/suites.c' || echo '$(srcdir)/'`tests/suites.c - -tests/tests_unit_test-suites.obj: tests/suites.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -MT tests/tests_unit_test-suites.obj -MD -MP -MF tests/$(DEPDIR)/tests_unit_test-suites.Tpo -c -o tests/tests_unit_test-suites.obj `if test -f 'tests/suites.c'; then $(CYGPATH_W) 'tests/suites.c'; else $(CYGPATH_W) '$(srcdir)/tests/suites.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/tests_unit_test-suites.Tpo tests/$(DEPDIR)/tests_unit_test-suites.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/suites.c' object='tests/tests_unit_test-suites.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -c -o tests/tests_unit_test-suites.obj `if test -f 'tests/suites.c'; then $(CYGPATH_W) 'tests/suites.c'; else $(CYGPATH_W) '$(srcdir)/tests/suites.c'; fi` - -tests/tests_unit_test-hash.o: tests/hash.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -MT tests/tests_unit_test-hash.o -MD -MP -MF tests/$(DEPDIR)/tests_unit_test-hash.Tpo -c -o tests/tests_unit_test-hash.o `test -f 'tests/hash.c' || echo '$(srcdir)/'`tests/hash.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/tests_unit_test-hash.Tpo tests/$(DEPDIR)/tests_unit_test-hash.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/hash.c' object='tests/tests_unit_test-hash.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -c -o tests/tests_unit_test-hash.o `test -f 'tests/hash.c' || echo '$(srcdir)/'`tests/hash.c - -tests/tests_unit_test-hash.obj: tests/hash.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -MT tests/tests_unit_test-hash.obj -MD -MP -MF tests/$(DEPDIR)/tests_unit_test-hash.Tpo -c -o tests/tests_unit_test-hash.obj `if test -f 'tests/hash.c'; then $(CYGPATH_W) 'tests/hash.c'; else $(CYGPATH_W) '$(srcdir)/tests/hash.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/tests_unit_test-hash.Tpo tests/$(DEPDIR)/tests_unit_test-hash.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/hash.c' object='tests/tests_unit_test-hash.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -c -o tests/tests_unit_test-hash.obj `if test -f 'tests/hash.c'; then $(CYGPATH_W) 'tests/hash.c'; else $(CYGPATH_W) '$(srcdir)/tests/hash.c'; fi` - -examples/client/tests_unit_test-client.o: examples/client/client.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -MT examples/client/tests_unit_test-client.o -MD -MP -MF examples/client/$(DEPDIR)/tests_unit_test-client.Tpo -c -o examples/client/tests_unit_test-client.o `test -f 'examples/client/client.c' || echo '$(srcdir)/'`examples/client/client.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) examples/client/$(DEPDIR)/tests_unit_test-client.Tpo examples/client/$(DEPDIR)/tests_unit_test-client.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='examples/client/client.c' object='examples/client/tests_unit_test-client.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -c -o examples/client/tests_unit_test-client.o `test -f 'examples/client/client.c' || echo '$(srcdir)/'`examples/client/client.c - -examples/client/tests_unit_test-client.obj: examples/client/client.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -MT examples/client/tests_unit_test-client.obj -MD -MP -MF examples/client/$(DEPDIR)/tests_unit_test-client.Tpo -c -o examples/client/tests_unit_test-client.obj `if test -f 'examples/client/client.c'; then $(CYGPATH_W) 'examples/client/client.c'; else $(CYGPATH_W) '$(srcdir)/examples/client/client.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) examples/client/$(DEPDIR)/tests_unit_test-client.Tpo examples/client/$(DEPDIR)/tests_unit_test-client.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='examples/client/client.c' object='examples/client/tests_unit_test-client.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -c -o examples/client/tests_unit_test-client.obj `if test -f 'examples/client/client.c'; then $(CYGPATH_W) 'examples/client/client.c'; else $(CYGPATH_W) '$(srcdir)/examples/client/client.c'; fi` - -examples/server/tests_unit_test-server.o: examples/server/server.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -MT examples/server/tests_unit_test-server.o -MD -MP -MF examples/server/$(DEPDIR)/tests_unit_test-server.Tpo -c -o examples/server/tests_unit_test-server.o `test -f 'examples/server/server.c' || echo '$(srcdir)/'`examples/server/server.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) examples/server/$(DEPDIR)/tests_unit_test-server.Tpo examples/server/$(DEPDIR)/tests_unit_test-server.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='examples/server/server.c' object='examples/server/tests_unit_test-server.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -c -o examples/server/tests_unit_test-server.o `test -f 'examples/server/server.c' || echo '$(srcdir)/'`examples/server/server.c - -examples/server/tests_unit_test-server.obj: examples/server/server.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -MT examples/server/tests_unit_test-server.obj -MD -MP -MF examples/server/$(DEPDIR)/tests_unit_test-server.Tpo -c -o examples/server/tests_unit_test-server.obj `if test -f 'examples/server/server.c'; then $(CYGPATH_W) 'examples/server/server.c'; else $(CYGPATH_W) '$(srcdir)/examples/server/server.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) examples/server/$(DEPDIR)/tests_unit_test-server.Tpo examples/server/$(DEPDIR)/tests_unit_test-server.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='examples/server/server.c' object='examples/server/tests_unit_test-server.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_unit_test_CFLAGS) $(CFLAGS) -c -o examples/server/tests_unit_test-server.obj `if test -f 'examples/server/server.c'; then $(CYGPATH_W) 'examples/server/server.c'; else $(CYGPATH_W) '$(srcdir)/examples/server/server.c'; fi` - -ctaocrypt/test/testsuite_testsuite_test-test.o: ctaocrypt/test/test.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -MT ctaocrypt/test/testsuite_testsuite_test-test.o -MD -MP -MF ctaocrypt/test/$(DEPDIR)/testsuite_testsuite_test-test.Tpo -c -o ctaocrypt/test/testsuite_testsuite_test-test.o `test -f 'ctaocrypt/test/test.c' || echo '$(srcdir)/'`ctaocrypt/test/test.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/test/$(DEPDIR)/testsuite_testsuite_test-test.Tpo ctaocrypt/test/$(DEPDIR)/testsuite_testsuite_test-test.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/test/test.c' object='ctaocrypt/test/testsuite_testsuite_test-test.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -c -o ctaocrypt/test/testsuite_testsuite_test-test.o `test -f 'ctaocrypt/test/test.c' || echo '$(srcdir)/'`ctaocrypt/test/test.c - -ctaocrypt/test/testsuite_testsuite_test-test.obj: ctaocrypt/test/test.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -MT ctaocrypt/test/testsuite_testsuite_test-test.obj -MD -MP -MF ctaocrypt/test/$(DEPDIR)/testsuite_testsuite_test-test.Tpo -c -o ctaocrypt/test/testsuite_testsuite_test-test.obj `if test -f 'ctaocrypt/test/test.c'; then $(CYGPATH_W) 'ctaocrypt/test/test.c'; else $(CYGPATH_W) '$(srcdir)/ctaocrypt/test/test.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ctaocrypt/test/$(DEPDIR)/testsuite_testsuite_test-test.Tpo ctaocrypt/test/$(DEPDIR)/testsuite_testsuite_test-test.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctaocrypt/test/test.c' object='ctaocrypt/test/testsuite_testsuite_test-test.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -c -o ctaocrypt/test/testsuite_testsuite_test-test.obj `if test -f 'ctaocrypt/test/test.c'; then $(CYGPATH_W) 'ctaocrypt/test/test.c'; else $(CYGPATH_W) '$(srcdir)/ctaocrypt/test/test.c'; fi` - -examples/client/testsuite_testsuite_test-client.o: examples/client/client.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -MT examples/client/testsuite_testsuite_test-client.o -MD -MP -MF examples/client/$(DEPDIR)/testsuite_testsuite_test-client.Tpo -c -o examples/client/testsuite_testsuite_test-client.o `test -f 'examples/client/client.c' || echo '$(srcdir)/'`examples/client/client.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) examples/client/$(DEPDIR)/testsuite_testsuite_test-client.Tpo examples/client/$(DEPDIR)/testsuite_testsuite_test-client.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='examples/client/client.c' object='examples/client/testsuite_testsuite_test-client.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -c -o examples/client/testsuite_testsuite_test-client.o `test -f 'examples/client/client.c' || echo '$(srcdir)/'`examples/client/client.c - -examples/client/testsuite_testsuite_test-client.obj: examples/client/client.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -MT examples/client/testsuite_testsuite_test-client.obj -MD -MP -MF examples/client/$(DEPDIR)/testsuite_testsuite_test-client.Tpo -c -o examples/client/testsuite_testsuite_test-client.obj `if test -f 'examples/client/client.c'; then $(CYGPATH_W) 'examples/client/client.c'; else $(CYGPATH_W) '$(srcdir)/examples/client/client.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) examples/client/$(DEPDIR)/testsuite_testsuite_test-client.Tpo examples/client/$(DEPDIR)/testsuite_testsuite_test-client.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='examples/client/client.c' object='examples/client/testsuite_testsuite_test-client.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -c -o examples/client/testsuite_testsuite_test-client.obj `if test -f 'examples/client/client.c'; then $(CYGPATH_W) 'examples/client/client.c'; else $(CYGPATH_W) '$(srcdir)/examples/client/client.c'; fi` - -examples/echoclient/testsuite_testsuite_test-echoclient.o: examples/echoclient/echoclient.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -MT examples/echoclient/testsuite_testsuite_test-echoclient.o -MD -MP -MF examples/echoclient/$(DEPDIR)/testsuite_testsuite_test-echoclient.Tpo -c -o examples/echoclient/testsuite_testsuite_test-echoclient.o `test -f 'examples/echoclient/echoclient.c' || echo '$(srcdir)/'`examples/echoclient/echoclient.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) examples/echoclient/$(DEPDIR)/testsuite_testsuite_test-echoclient.Tpo examples/echoclient/$(DEPDIR)/testsuite_testsuite_test-echoclient.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='examples/echoclient/echoclient.c' object='examples/echoclient/testsuite_testsuite_test-echoclient.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -c -o examples/echoclient/testsuite_testsuite_test-echoclient.o `test -f 'examples/echoclient/echoclient.c' || echo '$(srcdir)/'`examples/echoclient/echoclient.c - -examples/echoclient/testsuite_testsuite_test-echoclient.obj: examples/echoclient/echoclient.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -MT examples/echoclient/testsuite_testsuite_test-echoclient.obj -MD -MP -MF examples/echoclient/$(DEPDIR)/testsuite_testsuite_test-echoclient.Tpo -c -o examples/echoclient/testsuite_testsuite_test-echoclient.obj `if test -f 'examples/echoclient/echoclient.c'; then $(CYGPATH_W) 'examples/echoclient/echoclient.c'; else $(CYGPATH_W) '$(srcdir)/examples/echoclient/echoclient.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) examples/echoclient/$(DEPDIR)/testsuite_testsuite_test-echoclient.Tpo examples/echoclient/$(DEPDIR)/testsuite_testsuite_test-echoclient.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='examples/echoclient/echoclient.c' object='examples/echoclient/testsuite_testsuite_test-echoclient.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -c -o examples/echoclient/testsuite_testsuite_test-echoclient.obj `if test -f 'examples/echoclient/echoclient.c'; then $(CYGPATH_W) 'examples/echoclient/echoclient.c'; else $(CYGPATH_W) '$(srcdir)/examples/echoclient/echoclient.c'; fi` - -examples/echoserver/testsuite_testsuite_test-echoserver.o: examples/echoserver/echoserver.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -MT examples/echoserver/testsuite_testsuite_test-echoserver.o -MD -MP -MF examples/echoserver/$(DEPDIR)/testsuite_testsuite_test-echoserver.Tpo -c -o examples/echoserver/testsuite_testsuite_test-echoserver.o `test -f 'examples/echoserver/echoserver.c' || echo '$(srcdir)/'`examples/echoserver/echoserver.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) examples/echoserver/$(DEPDIR)/testsuite_testsuite_test-echoserver.Tpo examples/echoserver/$(DEPDIR)/testsuite_testsuite_test-echoserver.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='examples/echoserver/echoserver.c' object='examples/echoserver/testsuite_testsuite_test-echoserver.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -c -o examples/echoserver/testsuite_testsuite_test-echoserver.o `test -f 'examples/echoserver/echoserver.c' || echo '$(srcdir)/'`examples/echoserver/echoserver.c - -examples/echoserver/testsuite_testsuite_test-echoserver.obj: examples/echoserver/echoserver.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -MT examples/echoserver/testsuite_testsuite_test-echoserver.obj -MD -MP -MF examples/echoserver/$(DEPDIR)/testsuite_testsuite_test-echoserver.Tpo -c -o examples/echoserver/testsuite_testsuite_test-echoserver.obj `if test -f 'examples/echoserver/echoserver.c'; then $(CYGPATH_W) 'examples/echoserver/echoserver.c'; else $(CYGPATH_W) '$(srcdir)/examples/echoserver/echoserver.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) examples/echoserver/$(DEPDIR)/testsuite_testsuite_test-echoserver.Tpo examples/echoserver/$(DEPDIR)/testsuite_testsuite_test-echoserver.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='examples/echoserver/echoserver.c' object='examples/echoserver/testsuite_testsuite_test-echoserver.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -c -o examples/echoserver/testsuite_testsuite_test-echoserver.obj `if test -f 'examples/echoserver/echoserver.c'; then $(CYGPATH_W) 'examples/echoserver/echoserver.c'; else $(CYGPATH_W) '$(srcdir)/examples/echoserver/echoserver.c'; fi` - -examples/server/testsuite_testsuite_test-server.o: examples/server/server.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -MT examples/server/testsuite_testsuite_test-server.o -MD -MP -MF examples/server/$(DEPDIR)/testsuite_testsuite_test-server.Tpo -c -o examples/server/testsuite_testsuite_test-server.o `test -f 'examples/server/server.c' || echo '$(srcdir)/'`examples/server/server.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) examples/server/$(DEPDIR)/testsuite_testsuite_test-server.Tpo examples/server/$(DEPDIR)/testsuite_testsuite_test-server.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='examples/server/server.c' object='examples/server/testsuite_testsuite_test-server.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -c -o examples/server/testsuite_testsuite_test-server.o `test -f 'examples/server/server.c' || echo '$(srcdir)/'`examples/server/server.c - -examples/server/testsuite_testsuite_test-server.obj: examples/server/server.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -MT examples/server/testsuite_testsuite_test-server.obj -MD -MP -MF examples/server/$(DEPDIR)/testsuite_testsuite_test-server.Tpo -c -o examples/server/testsuite_testsuite_test-server.obj `if test -f 'examples/server/server.c'; then $(CYGPATH_W) 'examples/server/server.c'; else $(CYGPATH_W) '$(srcdir)/examples/server/server.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) examples/server/$(DEPDIR)/testsuite_testsuite_test-server.Tpo examples/server/$(DEPDIR)/testsuite_testsuite_test-server.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='examples/server/server.c' object='examples/server/testsuite_testsuite_test-server.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -c -o examples/server/testsuite_testsuite_test-server.obj `if test -f 'examples/server/server.c'; then $(CYGPATH_W) 'examples/server/server.c'; else $(CYGPATH_W) '$(srcdir)/examples/server/server.c'; fi` - -testsuite/testsuite_testsuite_test-testsuite.o: testsuite/testsuite.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -MT testsuite/testsuite_testsuite_test-testsuite.o -MD -MP -MF testsuite/$(DEPDIR)/testsuite_testsuite_test-testsuite.Tpo -c -o testsuite/testsuite_testsuite_test-testsuite.o `test -f 'testsuite/testsuite.c' || echo '$(srcdir)/'`testsuite/testsuite.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) testsuite/$(DEPDIR)/testsuite_testsuite_test-testsuite.Tpo testsuite/$(DEPDIR)/testsuite_testsuite_test-testsuite.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='testsuite/testsuite.c' object='testsuite/testsuite_testsuite_test-testsuite.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -c -o testsuite/testsuite_testsuite_test-testsuite.o `test -f 'testsuite/testsuite.c' || echo '$(srcdir)/'`testsuite/testsuite.c - -testsuite/testsuite_testsuite_test-testsuite.obj: testsuite/testsuite.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -MT testsuite/testsuite_testsuite_test-testsuite.obj -MD -MP -MF testsuite/$(DEPDIR)/testsuite_testsuite_test-testsuite.Tpo -c -o testsuite/testsuite_testsuite_test-testsuite.obj `if test -f 'testsuite/testsuite.c'; then $(CYGPATH_W) 'testsuite/testsuite.c'; else $(CYGPATH_W) '$(srcdir)/testsuite/testsuite.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) testsuite/$(DEPDIR)/testsuite_testsuite_test-testsuite.Tpo testsuite/$(DEPDIR)/testsuite_testsuite_test-testsuite.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='testsuite/testsuite.c' object='testsuite/testsuite_testsuite_test-testsuite.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testsuite_testsuite_test_CFLAGS) $(CFLAGS) -c -o testsuite/testsuite_testsuite_test-testsuite.obj `if test -f 'testsuite/testsuite.c'; then $(CYGPATH_W) 'testsuite/testsuite.c'; else $(CYGPATH_W) '$(srcdir)/testsuite/testsuite.c'; fi` - -.s.o: - $(AM_V_CCAS)$(CCASCOMPILE) -c -o $@ $< - -.s.obj: - $(AM_V_CCAS)$(CCASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.s.lo: - $(AM_V_CCAS)$(LTCCASCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -rm -rf ctaocrypt/benchmark/.libs ctaocrypt/benchmark/_libs - -rm -rf ctaocrypt/src/.libs ctaocrypt/src/_libs - -rm -rf ctaocrypt/test/.libs ctaocrypt/test/_libs - -rm -rf examples/client/.libs examples/client/_libs - -rm -rf examples/echoclient/.libs examples/echoclient/_libs - -rm -rf examples/echoserver/.libs examples/echoserver/_libs - -rm -rf examples/server/.libs examples/server/_libs - -rm -rf mcapi/.libs mcapi/_libs - -rm -rf src/.libs src/_libs - -rm -rf sslSniffer/sslSnifferTest/.libs sslSniffer/sslSnifferTest/_libs - -rm -rf tests/.libs tests/_libs - -rm -rf testsuite/.libs testsuite/_libs - -distclean-libtool: - -rm -f libtool config.lt -install-dist_docDATA: $(dist_doc_DATA) - @$(NORMAL_INSTALL) - @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ - done - -uninstall-dist_docDATA: - @$(NORMAL_UNINSTALL) - @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) -install-dist_exampleDATA: $(dist_example_DATA) - @$(NORMAL_INSTALL) - @list='$(dist_example_DATA)'; test -n "$(exampledir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(exampledir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(exampledir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(exampledir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(exampledir)" || exit $$?; \ - done - -uninstall-dist_exampleDATA: - @$(NORMAL_UNINSTALL) - @list='$(dist_example_DATA)'; test -n "$(exampledir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(exampledir)'; $(am__uninstall_files_from_dir) -install-pkgconfigDATA: $(pkgconfig_DATA) - @$(NORMAL_INSTALL) - @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ - done - -uninstall-pkgconfigDATA: - @$(NORMAL_UNINSTALL) - @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) -install-includeHEADERS: $(include_HEADERS) - @$(NORMAL_INSTALL) - @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ - done - -uninstall-includeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) -install-nobase_includeHEADERS: $(nobase_include_HEADERS) - @$(NORMAL_INSTALL) - @list='$(nobase_include_HEADERS)'; test -n "$(includedir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ - fi; \ - $(am__nobase_list) | while read dir files; do \ - xfiles=; for file in $$files; do \ - if test -f "$$file"; then xfiles="$$xfiles $$file"; \ - else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \ - test -z "$$xfiles" || { \ - test "x$$dir" = x. || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(includedir)/$$dir'"; \ - $(MKDIR_P) "$(DESTDIR)$(includedir)/$$dir"; }; \ - echo " $(INSTALL_HEADER) $$xfiles '$(DESTDIR)$(includedir)/$$dir'"; \ - $(INSTALL_HEADER) $$xfiles "$(DESTDIR)$(includedir)/$$dir" || exit $$?; }; \ - done - -uninstall-nobase_includeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(nobase_include_HEADERS)'; test -n "$(includedir)" || list=; \ - $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \ - dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscope: cscope.files - test ! -s cscope.files \ - || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) -clean-cscope: - -rm -f cscope.files -cscope.files: clean-cscope cscopelist -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -rm -f cscope.out cscope.in.out cscope.po.out cscope.files - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - else \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all $(check_PROGRAMS) - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -mcapi/test.log: mcapi/test$(EXEEXT) - @p='mcapi/test$(EXEEXT)'; \ - b='mcapi/test'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - $(am__remove_distdir) - test -d "$(distdir)" || mkdir "$(distdir)" - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - -test -n "$(am__skip_mode_fix)" \ - || find "$(distdir)" -type d ! -perm -755 \ - -exec chmod u+rwx,go+rx {} \; -o \ - ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ - || chmod -R a+r "$(distdir)" -dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__post_remove_distdir) - -dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 - $(am__post_remove_distdir) - -dist-lzip: distdir - tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz - $(am__post_remove_distdir) - -dist-xz: distdir - tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz - $(am__post_remove_distdir) - -dist-tarZ: distdir - @echo WARNING: "Support for shar distribution archives is" \ - "deprecated." >&2 - @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 - tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__post_remove_distdir) - -dist-shar: distdir - @echo WARNING: "Support for distribution archives compressed with" \ - "legacy program 'compress' is deprecated." >&2 - @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__post_remove_distdir) - -dist-zip: distdir - -rm -f $(distdir).zip - zip -rq $(distdir).zip $(distdir) - $(am__post_remove_distdir) - -dist dist-all: - $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' - $(am__post_remove_distdir) - -# This target untars the dist file and tries a VPATH configuration. Then -# it guarantees that the distribution is self-contained by making another -# tarfile. -distcheck: dist - case '$(DIST_ARCHIVES)' in \ - *.tar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ - *.tar.bz2*) \ - bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.lz*) \ - lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ - *.tar.xz*) \ - xz -dc $(distdir).tar.xz | $(am__untar) ;;\ - *.tar.Z*) \ - uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ - *.shar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ - *.zip*) \ - unzip $(distdir).zip ;;\ - esac - chmod -R a-w $(distdir) - chmod u+w $(distdir) - mkdir $(distdir)/_build $(distdir)/_inst - chmod a-w $(distdir) - test -d $(distdir)/_build || exit 0; \ - dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ - && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ - && am__cwd=`pwd` \ - && $(am__cd) $(distdir)/_build \ - && ../configure \ - $(AM_DISTCHECK_CONFIGURE_FLAGS) \ - $(DISTCHECK_CONFIGURE_FLAGS) \ - --srcdir=.. --prefix="$$dc_install_base" \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ - && $(MAKE) $(AM_MAKEFLAGS) install \ - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ - && $(MAKE) $(AM_MAKEFLAGS) uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ - distuninstallcheck \ - && chmod -R a-w "$$dc_install_base" \ - && ({ \ - (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ - distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ - } || { rm -rf "$$dc_destdir"; exit 1; }) \ - && rm -rf "$$dc_destdir" \ - && $(MAKE) $(AM_MAKEFLAGS) dist \ - && rm -rf $(DIST_ARCHIVES) \ - && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ - && cd "$$am__cwd" \ - || exit 1 - $(am__post_remove_distdir) - @(echo "$(distdir) archives ready for distribution: "; \ - list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ - sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' -distuninstallcheck: - @test -n '$(distuninstallcheck_dir)' || { \ - echo 'ERROR: trying to run $@ with an empty' \ - '$$(distuninstallcheck_dir)' >&2; \ - exit 1; \ - }; \ - $(am__cd) '$(distuninstallcheck_dir)' || { \ - echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ - exit 1; \ - }; \ - test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ - || { echo "ERROR: files left after uninstall:" ; \ - if test -n "$(DESTDIR)"; then \ - echo " (check DESTDIR support)"; \ - fi ; \ - $(distuninstallcheck_listfiles) ; \ - exit 1; } >&2 -distcleancheck: distclean - @if test '$(srcdir)' = . ; then \ - echo "ERROR: distcleancheck can only run from a VPATH build" ; \ - exit 1 ; \ - fi - @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ - || { echo "ERROR: files left in build directory after distclean:" ; \ - $(distcleancheck_listfiles) ; \ - exit 1; } >&2 -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) check-am -all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) $(HEADERS) \ - config.h -install-binPROGRAMS: install-libLTLIBRARIES - -installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(exampledir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includedir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -rm -f ctaocrypt/benchmark/$(DEPDIR)/$(am__dirstamp) - -rm -f ctaocrypt/benchmark/$(am__dirstamp) - -rm -f ctaocrypt/src/$(DEPDIR)/$(am__dirstamp) - -rm -f ctaocrypt/src/$(am__dirstamp) - -rm -f ctaocrypt/test/$(DEPDIR)/$(am__dirstamp) - -rm -f ctaocrypt/test/$(am__dirstamp) - -rm -f examples/client/$(DEPDIR)/$(am__dirstamp) - -rm -f examples/client/$(am__dirstamp) - -rm -f examples/echoclient/$(DEPDIR)/$(am__dirstamp) - -rm -f examples/echoclient/$(am__dirstamp) - -rm -f examples/echoserver/$(DEPDIR)/$(am__dirstamp) - -rm -f examples/echoserver/$(am__dirstamp) - -rm -f examples/server/$(DEPDIR)/$(am__dirstamp) - -rm -f examples/server/$(am__dirstamp) - -rm -f mcapi/$(DEPDIR)/$(am__dirstamp) - -rm -f mcapi/$(am__dirstamp) - -rm -f src/$(DEPDIR)/$(am__dirstamp) - -rm -f src/$(am__dirstamp) - -rm -f sslSniffer/sslSnifferTest/$(DEPDIR)/$(am__dirstamp) - -rm -f sslSniffer/sslSnifferTest/$(am__dirstamp) - -rm -f tests/$(DEPDIR)/$(am__dirstamp) - -rm -f tests/$(am__dirstamp) - -rm -f testsuite/$(DEPDIR)/$(am__dirstamp) - -rm -f testsuite/$(am__dirstamp) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -clean: clean-am - -clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ - clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \ - clean-noinstPROGRAMS mostlyclean-am - -distclean: distclean-am - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf ctaocrypt/benchmark/$(DEPDIR) ctaocrypt/src/$(DEPDIR) ctaocrypt/test/$(DEPDIR) examples/client/$(DEPDIR) examples/echoclient/$(DEPDIR) examples/echoserver/$(DEPDIR) examples/server/$(DEPDIR) mcapi/$(DEPDIR) src/$(DEPDIR) sslSniffer/sslSnifferTest/$(DEPDIR) tests/$(DEPDIR) testsuite/$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-hdr distclean-libtool distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: install-dist_docDATA install-dist_exampleDATA \ - install-includeHEADERS install-nobase_includeHEADERS \ - install-pkgconfigDATA - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-binPROGRAMS install-exec-local \ - install-libLTLIBRARIES - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf ctaocrypt/benchmark/$(DEPDIR) ctaocrypt/src/$(DEPDIR) ctaocrypt/test/$(DEPDIR) examples/client/$(DEPDIR) examples/echoclient/$(DEPDIR) examples/echoserver/$(DEPDIR) examples/server/$(DEPDIR) mcapi/$(DEPDIR) src/$(DEPDIR) sslSniffer/sslSnifferTest/$(DEPDIR) tests/$(DEPDIR) testsuite/$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic \ - maintainer-clean-local - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-binPROGRAMS uninstall-dist_docDATA \ - uninstall-dist_exampleDATA uninstall-includeHEADERS \ - uninstall-libLTLIBRARIES uninstall-local \ - uninstall-nobase_includeHEADERS uninstall-pkgconfigDATA - -.MAKE: all check check-am install install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-TESTS \ - check-am clean clean-binPROGRAMS clean-checkPROGRAMS \ - clean-cscope clean-generic clean-libLTLIBRARIES clean-libtool \ - clean-noinstLTLIBRARIES clean-noinstPROGRAMS cscope \ - cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ - dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \ - distcheck distclean distclean-compile distclean-generic \ - distclean-hdr distclean-libtool distclean-tags distcleancheck \ - distdir distuninstallcheck dvi dvi-am html html-am info \ - info-am install install-am install-binPROGRAMS install-data \ - install-data-am install-dist_docDATA install-dist_exampleDATA \ - install-dvi install-dvi-am install-exec install-exec-am \ - install-exec-local install-html install-html-am \ - install-includeHEADERS install-info install-info-am \ - install-libLTLIBRARIES install-man \ - install-nobase_includeHEADERS install-pdf install-pdf-am \ - install-pkgconfigDATA install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic maintainer-clean-local mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am recheck tags tags-am uninstall \ - uninstall-am uninstall-binPROGRAMS uninstall-dist_docDATA \ - uninstall-dist_exampleDATA uninstall-includeHEADERS \ - uninstall-libLTLIBRARIES uninstall-local \ - uninstall-nobase_includeHEADERS uninstall-pkgconfigDATA - - -#includes additional rules from aminclude.am -@INC_AMINCLUDE@ - -rpm-build: rpm/spec dist - @rm -f *.rpm - @rm -f ~/rpmbuild/RPMS/x86_64/$(PACKAGE)-$(VERSION)*.rpm - @rm -f ~/rpmbuild/SRPMS/$(PACKAGE)-$(VERSION)*.rpm - @mkdir -p ~/rpmbuild/BUILD/ - @mkdir -p ~/rpmbuild/RPMS/i386/ - @mkdir -p ~/rpmbuild/RPMS/i686/ - @mkdir -p ~/rpmbuild/RPMS/noarch/ - @mkdir -p ~/rpmbuild/RPMS/x86_64/ - @mkdir -p ~/rpmbuild/SOURCES/ - @mkdir -p ~/rpmbuild/SPECS/ - @mkdir -p ~/rpmbuild/SRPMS/ - @cp $(PACKAGE)-$(VERSION).tar.gz ~/rpmbuild/SOURCES/ - @rpmbuild -ba --clean rpm/spec - @cp ~/rpmbuild/RPMS/x86_64/$(PACKAGE)-$(VERSION)*.rpm . - @cp ~/rpmbuild/RPMS/x86_64/$(PACKAGE)-devel-$(VERSION)*.rpm . - @cp ~/rpmbuild/RPMS/x86_64/$(PACKAGE)-debuginfo-$(VERSION)*.rpm . - @cp ~/rpmbuild/SRPMS/$(PACKAGE)-$(VERSION)*.rpm . - -rpm-sign: rpm-build - @rpm --addsign *.rpm - @rpm --checksig *.rpm - -clean-rpm: - @rm -f *.tar.gz - @rm -f *.src.rpm - @rm -f *.rpm - -rpm: rpm-build - -release: rpm-sign - -auto-rpmbuild: - @auto-br-rpmbuild -ba rpm/spec -test: check -tests/unit.log: testsuite/testsuite.log - -maintainer-clean-local: - -rm Makefile.in - -rm aclocal.m4 - -rm build-aux/compile - -rm build-aux/config.guess - -rm build-aux/config.sub - -rm build-aux/depcomp - -rm build-aux/install-sh - -rm build-aux/ltmain.sh - -rm build-aux/missing - -rm cyassl-config - -rmdir build-aux - -rm configure - -rm config.log - -rm config.status - -rm config.in - -rm m4/libtool.m4 - -rm m4/ltoptions.m4 - -rm m4/ltsugar.m4 - -rm m4/ltversion.m4 - -rm m4/lt~obsolete.m4 - -rm support/cyassl.pc - find . -type f -name '*~' -exec rm -f '{}' \; - -rm -f @PACKAGE@-*.tar.gz - -rm -f @PACKAGE@-*.rpm - -# !!!! first line of rule has to start with a hard (real) tab, not spaces -egs: - $(MAKE) examples/client/client; \ - $(MAKE) examples/echoclient/echoclient;\ - $(MAKE) examples/server/server; \ - $(MAKE) examples/echoserver/echoserver; - -ctc: - $(MAKE) ctaocrypt/test/testctaocrypt; \ - $(MAKE) ctaocrypt/benchmark/benchmark; - -install-exec-local: install-generic-config - -install-generic-config: - $(mkinstalldirs) $(DESTDIR)$(bindir) - $(INSTALL_SCRIPT) @GENERIC_CONFIG@ $(DESTDIR)$(bindir) - -uninstall-local: - -rm -f $(DESTDIR)$(bindir)/@GENERIC_CONFIG@ - -merge-clean: - @find ./ | $(GREP) \.gcda | xargs rm -f - @find ./ | $(GREP) \.gcno | xargs rm -f - @find ./ | $(GREP) \.gz | xargs rm -f - @find ./ | $(GREP) \.orig | xargs rm -f - @find ./ | $(GREP) \.rej | xargs rm -f - @find ./ | $(GREP) \.rpm | xargs rm -f - @find ./ | $(GREP) \.THIS | xargs rm -f - @find ./ | $(GREP) \.OTHER | xargs rm -f - @find ./ | $(GREP) \.BASE | xargs rm -f - @find ./ | $(GREP) \~$$ | xargs rm -f - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/FreeRTOS-Plus/Source/WolfSSL/NEWS b/FreeRTOS-Plus/Source/WolfSSL/NEWS deleted file mode 100755 index e69de29..0000000 diff --git a/FreeRTOS-Plus/Source/WolfSSL/README b/FreeRTOS-Plus/Source/WolfSSL/README deleted file mode 100755 index e2da674..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/README +++ /dev/null @@ -1,1044 +0,0 @@ -*** Notes, Please read *** - -Note 1) -CyaSSL now needs all examples and tests to be run from the CyaSSL home -directory. This is because it finds certs and keys from ./certs/. Trying to -maintain the ability to run each program from its own directory, the testsuite -directory, the main directory (for make check/test), and for the various -different project layouts (with or without config) was becoming harder and -harder. Now to run testsuite just do: - -./testsuite/testsuite - -or - -make check (when using autoconf) - -On *nix or Windows the examples and testsuite will check to see if the current -directory is the source directory and if so, attempt to change to the CyaSSL -home directory. This should work in most setup cases, if not, just follow the -beginning of the note and specify the full path. - - -Note 2) -CyaSSL takes a different approach to certificate verification than OpenSSL does. -The default policy for the client is to verify the server, this means that if -you don't load CAs to verify the server you'll get a connect error, no signer -error to confirm failure (-188). If you want to mimic OpenSSL behavior of -having SSL_connect succeed even if verifying the server fails and reducing -security you can do this by calling: - -SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0); - -before calling SSL_new(); Though it's not recommended. - -*** end Notes *** - - -CyaSSL Release 3.1.0 (07/14/2014) - -Release 3.1.0 CyaSSL has bug fixes and new features including: - -- Fix for older versions of icc without 128-bit type -- Intel ASM syntax for AES-NI -- Updated NTRU support, keygen benchmark -- FIPS check for minimum required HMAC key length -- Small stack (--enable-smallstack) improvements for PKCS#7, ASN -- TLS extension support for DTLS -- Default I/O callbacks external to user -- Updated example client with bad clock test -- Ability to set optional ECC context info -- Ability to enable/disable DH separate from opensslextra -- Additional test key/cert buffers for CA and server -- Updated example certificates - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -************ CyaSSL Release 3.0.2 (05/30/2014) - -Release 3.0.2 CyaSSL has bug fixes and new features including: - -- Added the following cipher suites: - * TLS_PSK_WITH_AES_128_GCM_SHA256 - * TLS_PSK_WITH_AES_256_GCM_SHA384 - * TLS_PSK_WITH_AES_256_CBC_SHA384 - * TLS_PSK_WITH_NULL_SHA384 - * TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 - * TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 - * TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 - * TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 - * TLS_DHE_PSK_WITH_NULL_SHA256 - * TLS_DHE_PSK_WITH_NULL_SHA384 - * TLS_DHE_PSK_WITH_AES_128_CCM - * TLS_DHE_PSK_WITH_AES_256_CCM -- Added AES-NI support for Microsoft Visual Studio builds. -- Changed small stack build to be disabled by default. -- Updated the Hash DRBG and provided a configure option to enable. - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -************ CyaSSL Release 3.0.0 (04/29/2014) - -Release 3.0.0 CyaSSL has bug fixes and new features including: - -- FIPS release candidate -- X.509 improvements that address items reported by Suman Jana with security - researchers at UT Austin and UC Davis -- Small stack size improvements, --enable-smallstack. Offloads large local - variables to the heap. (Note this is not complete.) -- Updated AES-CCM-8 cipher suites to use approved suite numbers. - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -************ CyaSSL Release 2.9.4 (04/09/2014) - -Release 2.9.4 CyaSSL has bug fixes and new features including: - -- Security fixes that address items reported by Ivan Fratric of the Google - Security Team -- X.509 Unknown critical extensions treated as errors, report by Suman Jana with - security researchers at UT Austin and UC Davis -- Sniffer fixes for corrupted packet length and Jumbo frames -- ARM thumb mode assembly fixes -- Xcode 5.1 support including new clang -- PIC32 MZ hardware support -- CyaSSL Object has enough room to read the Record Header now w/o allocs -- FIPS wrappers for AES, 3DES, SHA1, SHA256, SHA384, HMAC, and RSA. -- A sample I/O pool is demonstrated with --enable-iopool to overtake memory - handling and reduce memory fragmentation on I/O large sizes - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -************ CyaSSL Release 2.9.0 (02/07/2014) - -Release 2.9.0 CyaSSL has bug fixes and new features including: -- Freescale Kinetis RNGB support -- Freescale Kinetis mmCAU support -- TLS Hello extensions - - ECC - - Secure Renegotiation (null) - - Truncated HMAC -- SCEP support - - PKCS #7 Enveloped data and signed data - - PKCS #10 Certificate Signing Request generation -- DTLS sliding window -- OCSP Improvements - - API change to integrate into Certificate Manager - - IPv4/IPv6 agnostic - - example client/server support for OCSP - - OCSP nonces are optional -- GMAC hashing -- Windows build additions -- Windows CYGWIN build fixes -- Updated test certificates -- Microchip MPLAB Harmony support -- Update autoconf scripts -- Additional X.509 inspection functions -- ECC encrypt/decrypt primitives -- ECC Certificate generation - -The Freescale Kinetis K53 RNGB documentation can be found in Chapter 33 of the -K53 Sub-Family Reference Manual: -http://cache.freescale.com/files/32bit/doc/ref_manual/K53P144M100SF2RM.pdf - -Freescale Kinetis K60 mmCAU (AES, DES, 3DES, MD5, SHA, SHA256) documentation -can be found in the "ColdFire/ColdFire+ CAU and Kinetis mmCAU Software Library -User Guide": -http://cache.freescale.com/files/32bit/doc/user_guide/CAUAPIUG.pdf - - -*****************CyaSSL Release 2.8.0 (8/30/2013) - -Release 2.8.0 CyaSSL has bug fixes and new features including: -- AES-GCM and AES-CCM use AES-NI -- NetX default IO callback handlers -- IPv6 fixes for DTLS Hello Cookies -- The ability to unload Certs/Keys after the handshake, CyaSSL_UnloadCertsKeys() -- SEP certificate extensions -- Callback getters for easier resource freeing -- External CYASSL_MAX_ERROR_SZ for correct error buffer sizing -- MacEncrypt and DecryptVerify Callbacks for User Atomic Record Layer Processing -- Public Key Callbacks for ECC and RSA -- Client now sends blank cert upon request if doesn't have one with TLS <= 1.2 - - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -*****************CyaSSL Release 2.7.0 (6/17/2013) - -Release 2.7.0 CyaSSL has bug fixes and new features including: -- SNI support for client and server -- KEIL MDK-ARM projects -- Wildcard check to domain name match, and Subject altnames are checked too -- Better error messages for certificate verification errors -- Ability to discard session during handshake verify -- More consistent error returns across all APIs -- Ability to unload CAs at the CTX or CertManager level -- Authority subject id support for Certificate matching -- Persistent session cache functionality -- Persistent CA cache functionality -- Client session table lookups to push serverID table to library level -- Camellia support to sniffer -- User controllable settings for DTLS timeout values -- Sniffer fixes for caching long lived sessions -- DTLS reliability enhancements for the handshake -- Better ThreadX support - -When compiling with Mingw, libtool may give the following warning due to -path conversion errors: - -libtool: link: Could not determine host file name corresponding to ** -libtool: link: Continuing, but uninstalled executables may not work. - -If so, examples and testsuite will have problems when run, showing an -error while loading shared libraries. To resolve, please run "make install". - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -************** CyaSSL Release 2.6.0 (04/15/2013) - -Release 2.6.0 CyaSSL has bug fixes and new features including: -- DTLS 1.2 support including AEAD ciphers -- SHA-3 finalist Blake2 support, it's fast and uses little resources -- SHA-384 cipher suites including ECC ones -- HMAC now supports SHA-512 -- Track memory use for example client/server with -t option -- Better IPv6 examples with --enable-ipv6, before if ipv6 examples/tests were - turned on, localhost only was used. Now link-local (with scope ids) and ipv6 - hosts can be used as well. -- Xcode v4.6 project for iOS v6.1 update -- settings.h is now checked in all *.c files for true one file setting detection -- Better alignment at SSL layer for hardware crypto alignment needs - * Note, SSL itself isn't friendly to alignment with 5 byte TLS headers and - 13 bytes DTLS headers, but every effort is now made to align with the - CYASSL_GENERAL_ALIGNMENT flag which sets desired alignment requirement -- NO_64BIT flag to turn off 64bit data type accumulators in public key code - * Note, some systems are faster with 32bit accumulators -- --enable-stacksize for example client/server stack use - * Note, modern desktop Operating Systems may add bytes to each stack frame -- Updated compression/decompression with direct crypto access -- All ./configure options are now lowercase only for consistency -- ./configure builds default to fastmath option - * Note, if on ia32 and building in shared mode this may produce a problem - with a missing register being available because of PIC, there are at least - 5 solutions to this: - 1) --disable-fastmath , don't use fastmath - 2) --disable-shared, don't build a shared library - 3) C_EXTRA_FLAGS=-DTFM_NO_ASM , turn off assembly use - 4) use clang, it just seems to work - 5) play around with no PIC options to force all registers being open -- Many new ./configure switches for option enable/disable for example - * rsa - * dh - * dsa - * md5 - * sha - * arc4 - * null (allow NULL ciphers) - * oldtls (only use TLS 1.2) - * asn (no certs or public keys allowed) -- ./configure generates cyassl/options.h which allows a header the user can - include in their app to make sure the same options are set at the app and - CyaSSL level. -- autoconf no longer needs serial-tests which lowers version requirements of - automake to 1.11 and autoconf to 2.63 - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -************** CyaSSL Release 2.5.0 (02/04/2013) - -Release 2.5.0 CyaSSL has bug fixes and new features including: -- Fix for TLS CBC padding timing attack identified by Nadhem Alfardan and - Kenny Paterson: http://www.isg.rhul.ac.uk/tls/ -- Microchip PIC32 (MIPS16, MIPS32) support -- Microchip MPLAB X example projects for PIC32 Ethernet Starter Kit -- Updated CTaoCrypt benchmark app for embedded systems -- 1024-bit test certs/keys and cert/key buffers -- AES-CCM-8 crypto and cipher suites -- Camellia crypto and cipher suites -- Bumped minimum autoconf version to 2.65, automake version to 1.12 -- Addition of OCSP callbacks -- STM32F2 support with hardware crypto and RNG -- Cavium NITROX support - -CTaoCrypt now has support for the Microchip PIC32 and has been tested with -the Microchip PIC32 Ethernet Starter Kit, the XC32 compiler and -MPLAB X IDE in both MIPS16 and MIPS32 instruction set modes. See the README -located under the /mplabx directory for more details. - -To add Cavium NITROX support do: - -./configure --with-cavium=/home/user/cavium/software - -pointing to your licensed cavium/software directory. Since Cavium doesn't -build a library we pull in the cavium_common.o file which gives a libtool -warning about the portability of this. Also, if you're using the github source -tree you'll need to remove the -Wredundant-decls warning from the generated -Makefile because the cavium headers don't conform to this warning. Currently -CyaSSL supports Cavium RNG, AES, 3DES, RC4, HMAC, and RSA directly at the crypto -layer. Support at the SSL level is partial and currently just does AES, 3DES, -and RC4. RSA and HMAC are slower until the Cavium calls can be utilized in non -blocking mode. The example client turns on cavium support as does the crypto -test and benchmark. Please see the HAVE_CAVIUM define. - -CyaSSL is able to use the STM32F2 hardware-based cryptography and random number -generator through the STM32F2 Standard Peripheral Library. For necessary -defines, see the CYASSL_STM32F2 define in settings.h. Documentation for the -STM32F2 Standard Peripheral Library can be found in the following document: -http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/USER_MANUAL/DM00023896.pdf - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -*************** CyaSSL Release 2.4.6 (12/20/2012) - -Release 2.4.6 CyaSSL has bug fixes and a few new features including: -- ECC into main version -- Lean PSK build (reduced code size, RAM usage, and stack usage) -- FreeBSD CRL monitor support -- CyaSSL_peek() -- CyaSSL_send() and CyaSSL_recv() for I/O flag setting -- CodeWarrior Support -- MQX Support -- Freescale Kinetis support including Hardware RNG -- autoconf builds use jobserver -- cyassl-config -- Sniffer memory reductions - -Thanks to Brian Aker for the improved autoconf system, make rpm, cyassl-config, -warning system, and general good ideas for improving CyaSSL! - -The Freescale Kinetis K70 RNGA documentation can be found in Chapter 37 of the -K70 Sub-Family Reference Manual: -http://cache.freescale.com/files/microcontrollers/doc/ref_manual/K70P256M150SF3RM.pdf - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -*************** CyaSSL Release 2.4.0 (10/10/2012) - -Release 2.4.0 CyaSSL has bug fixes and a few new features including: -- DTLS reliability -- Reduced memory usage after handshake -- Updated build process - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -*************** CyaSSL Release 2.3.0 (8/10/2012) - -Release 2.3.0 CyaSSL has bug fixes and a few new features including: -- AES-GCM crypto and cipher suites -- make test cipher suite checks -- Subject AltName processing -- Command line support for client/server examples -- Sniffer SessionTicket support -- SHA-384 cipher suites -- Verify cipher suite validity when user overrides -- CRL dir monitoring -- DTLS Cookie support, reliability coming soon - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -***************CyaSSL Release 2.2.0 (5/18/2012) - -Release 2.2.0 CyaSSL has bug fixes and a few new features including: -- Initial CRL support (--enable-crl) -- Initial OCSP support (--enable-ocsp) -- Add static ECDH suites -- SHA-384 support -- ECC client certificate support -- Add medium session cache size (1055 sessions) -- Updated unit tests -- Protection against mutex reinitialization - - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -***************CyaSSL Release 2.0.8 (2/24/2012) - -Release 2.0.8 CyaSSL has bug fixes and a few new features including: -- A fix for malicious certificates pointed out by Remi Gacogne (thanks) - resulting in NULL pointer use. -- Respond to renegotiation attempt with no_renegoatation alert -- Add basic path support for load_verify_locations() -- Add set Temp EC-DHE key size -- Extra checks on rsa test when porting into - - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -************* CyaSSL Release 2.0.6 (1/27/2012) - -Release 2.0.6 CyaSSL has bug fixes and a few new features including: -- Fixes for CA basis constraint check -- CTX reference counting -- Initial unit test additions -- Lean and Mean Windows fix -- ECC benchmarking -- SSMTP build support -- Ability to group handshake messages with set_group_messages(ctx/ssl) -- CA cache addition callback -- Export Base64_Encode for general use - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -************* CyaSSL Release 2.0.2 (12/05/2011) - -Release 2.0.2 CyaSSL has bug fixes and a few new features including: -- CTaoCrypt Runtime library detection settings when directly using the crypto - library -- Default certificate generation now uses SHAwRSA and adds SHA256wRSA generation -- All test certificates now use 2048bit and SHA-1 for better modern browser - support -- Direct AES block access and AES-CTR (counter) mode -- Microchip pic32 support - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -************* CyaSSL Release 2.0.0rc3 (9/28/2011) - -Release 2.0.0rc3 for CyaSSL has bug fixes and a few new features including: -- updated autoconf support -- better make install and uninstall (uses system directories) -- make test / make check -- CyaSSL headers now in -- CTaocrypt headers now in -- OpenSSL compatibility headers now in -- examples and tests all run from home directory so can use certs in ./certs - (see note 1) - -So previous applications that used the OpenSSL compatibility header - now need to include instead, no other -changes are required. - -Special Thanks to Brian Aker for his autoconf, install, and header patches. - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - -************CyaSSL Release 2.0.0rc2 (6/6/2011) - -Release 2.0.0rc2 for CyaSSL has bug fixes and a few new features including: -- bug fixes (Alerts, DTLS with DHE) -- FreeRTOS support -- lwIP support -- Wshadow warnings removed -- asn public header -- CTaoCrypt public headers now all have ctc_ prefix (the manual is still being - updated to reflect this change) -- and more. - -This is the 2nd and perhaps final release candidate for version 2. -Please send any comments or questions to support@yassl.com. - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - -***********CyaSSL Release 2.0.0rc1 (5/2/2011) - -Release 2.0.0rc1 for CyaSSL has many new features including: -- bug fixes -- SHA-256 cipher suites -- Root Certificate Verification (instead of needing all certs in the chain) -- PKCS #8 private key encryption (supports PKCS #5 v1-v2 and PKCS #12) -- Serial number retrieval for x509 -- PBKDF2 and PKCS #12 PBKDF -- UID parsing for x509 -- SHA-256 certificate signatures -- Client and server can send chains (SSL_CTX_use_certificate_chain_file) -- CA loading can now parse multiple certificates per file -- Dynamic memory runtime hooks -- Runtime hooks for logging -- EDH on server side -- More informative error codes -- More informative logging messages -- Version downgrade more robust (use SSL_v23*) -- Shared build only by default through ./configure -- Compiler visibility is now used, internal functions not polluting namespace -- Single Makefile, no recursion, for faster and simpler building -- Turn on all warnings possible build option, warning fixes -- and more. - -Because of all the new features and the multiple OS, compiler, feature-set -options that CyaSSL allows, there may be some configuration fixes needed. -Please send any comments or questions to support@yassl.com. - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - -****************** CyaSSL Release 1.9.0 (3/2/2011) - -Release 1.9.0 for CyaSSL adds bug fixes, improved TLSv1.2 through testing and -better hash/sig algo ids, --enable-webServer for the yaSSL embedded web server, -improper AES key setup detection, user cert verify callback improvements, and -more. - -The CyaSSL manual offering is included in the doc/ directory. For build -instructions and comments about the new features please check the manual. - -Please send any comments or questions to support@yassl.com. - -****************** CyaSSL Release 1.8.0 (12/23/2010) - -Release 1.8.0 for CyaSSL adds bug fixes, x509 v3 CA signed certificate -generation, a C standard library abstraction layer, lower memory use, increased -portability through the os_settings.h file, and the ability to use NTRU cipher -suites when used in conjunction with an NTRU license and library. - -The initial CyaSSL manual offering is included in the doc/ directory. For -build instructions and comments about the new features please check the manual. - -Please send any comments or questions to support@yassl.com. - -Happy Holidays. - - -********************* CyaSSL Release 1.6.5 (9/9/2010) - -Release 1.6.5 for CyaSSL adds bug fixes and x509 v3 self signed certificate -generation. - -For general build instructions see doc/Building_CyaSSL.pdf. - -To enable certificate generation support add this option to ./configure -./configure --enable-certgen - -An example is included in ctaocrypt/test/test.c and documentation is provided -in doc/CyaSSL_Extensions_Reference.pdf item 11. - -********************** CyaSSL Release 1.6.0 (8/27/2010) - -Release 1.6.0 for CyaSSL adds bug fixes, RIPEMD-160, SHA-512, and RSA key -generation. - -For general build instructions see doc/Building_CyaSSL.pdf. - -To add RIPEMD-160 support add this option to ./configure -./configure --enable-ripemd - -To add SHA-512 support add this option to ./configure -./configure --enable-sha512 - -To add RSA key generation support add this option to ./configure -./configure --enable-keygen - -Please see ctaocrypt/test/test.c for examples and usage. - -For Windows, RIPEMD-160 and SHA-512 are enabled by default but key generation is -off by default. To turn key generation on add the define CYASSL_KEY_GEN to -CyaSSL. - - -************* CyaSSL Release 1.5.6 (7/28/2010) - -Release 1.5.6 for CyaSSL adds bug fixes, compatibility for our JSSE provider, -and a fix for GCC builds on some systems. - -For general build instructions see doc/Building_CyaSSL.pdf. - -To add AES-NI support add this option to ./configure -./configure --enable-aesni - -You'll need GCC 4.4.3 or later to make use of the assembly. - -************** CyaSSL Release 1.5.4 (7/7/2010) - -Release 1.5.4 for CyaSSL adds bug fixes, support for AES-NI, SHA1 speed -improvements from loop unrolling, and support for the Mongoose Web Server. - -For general build instructions see doc/Building_CyaSSL.pdf. - -To add AES-NI support add this option to ./configure -./configure --enable-aesni - -You'll need GCC 4.4.3 or later to make use of the assembly. - -*************** CyaSSL Release 1.5.0 (5/11/2010) - -Release 1.5.0 for CyaSSL adds bug fixes, GoAhead WebServer support, sniffer -support, and initial swig interface support. - -For general build instructions see doc/Building_CyaSSL.pdf. - -To add support for GoAhead WebServer either --enable-opensslExtra or if you -don't want all the features of opensslExtra you can just define GOAHEAD_WS -instead. GOAHEAD_WS can be added to ./configure with CFLAGS=-DGOAHEAD_WS or -you can define it yourself. - -To look at the sniffer support please see the sniffertest app in -sslSniffer/sslSnifferTest. Build with --enable-sniffer on *nix or use the -vcproj files on windows. You'll need to have pcap installed on *nix and -WinPcap on windows. - -A swig interface file is now located in the swig directory for using Python, -Java, Perl, and others with CyaSSL. This is initial support and experimental, -please send questions or comments to support@yassl.com. - -When doing load testing with CyaSSL, on the echoserver example say, the client -machine may run out of tcp ephemeral ports, they will end up in the TIME_WAIT -queue, and can't be reused by default. There are generally two ways to fix -this. 1) Reduce the length sockets remain on the TIME_WAIT queue or 2) Allow -items on the TIME_WAIT queue to be reused. - - -To reduce the TIME_WAIT length in OS X to 3 seconds (3000 milliseconds) - -sudo sysctl -w net.inet.tcp.msl=3000 - -In Linux - -sudo sysctl -w net.ipv4.tcp_tw_reuse=1 - -allows reuse of sockets in TIME_WAIT - -sudo sysctl -w net.ipv4.tcp_tw_recycle=1 - -works but seems to remove sockets from TIME_WAIT entirely? - -sudo sysctl -w net.ipv4.tcp_fin_timeout=1 - -doen't control TIME_WAIT, it controls FIN_WAIT(2) contrary to some posts - - -******************** CyaSSL Release 1.4.0 (2/18/2010) - -Release 1.3.0 for CyaSSL adds bug fixes, better multi TLS/SSL version support -through SSLv23_server_method(), and improved documentation in the doc/ folder. - -For general build instructions doc/Building_CyaSSL.pdf. - -******************** CyaSSL Release 1.3.0 (1/21/2010) - -Release 1.3.0 for CyaSSL adds bug fixes, a potential security problem fix, -better porting support, removal of assert()s, and a complete THREADX port. - -For general build instructions see rc1 below. - -******************** CyaSSL Release 1.2.0 (11/2/2009) - -Release 1.2.0 for CyaSSL adds bug fixes and session negotiation if first use is -read or write. - -For general build instructions see rc1 below. - -******************** CyaSSL Release 1.1.0 (9/2/2009) - -Release 1.1.0 for CyaSSL adds bug fixes, a check against malicious session -cache use, support for lighttpd, and TLS 1.2. - -To get TLS 1.2 support please use the client and server functions: - -SSL_METHOD *TLSv1_2_server_method(void); -SSL_METHOD *TLSv1_2_client_method(void); - -CyaSSL was tested against lighttpd 1.4.23. To build CyaSSL for use with -lighttpd use the following commands from the CyaSSL install dir : - -./configure --disable-shared --enable-opensslExtra --enable-fastmath --without-zlib - -make -make openssl-links - -Then to build lighttpd with CyaSSL use the following commands from the -lighttpd install dir: - -./configure --with-openssl --with-openssl-includes=/include --with-openssl-libs=/lib LDFLAGS=-lm - -make - -On some systems you may get a linker error about a duplicate symbol for -MD5_Init or other MD5 calls. This seems to be caused by the lighttpd src file -md5.c, which defines MD5_Init(), and is included in liblightcomp_la-md5.o. -When liblightcomp is linked with the SSL_LIBs the linker may complain about -the duplicate symbol. This can be fixed by editing the lighttpd src file md5.c -and adding this line to the beginning of the file: - -#if 0 - -and this line to the end of the file - -#endif - -Then from the lighttpd src dir do a: - -make clean -make - - -If you get link errors about undefined symbols more than likely the actual -OpenSSL libraries are found by the linker before the CyaSSL openssl-links that -point to the CyaSSL library, causing the linker confusion. This can be fixed -by editing the Makefile in the lighttpd src directory and changing the line: - -SSL_LIB = -lssl -lcrypto - -to - -SSL_LIB = -lcyassl - -Then from the lighttpd src dir do a: - -make clean -make - -This should remove any confusion the linker may be having with missing symbols. - -For any questions or concerns please contact support@yassl.com . - -For general build instructions see rc1 below. - -******************CyaSSL Release 1.0.6 (8/03/2009) - -Release 1.0.6 for CyaSSL adds bug fixes, an improved session cache, and faster -math with a huge code option. - -The session cache now defaults to a client mode, also good for embedded servers. -For servers not under heavy load (less than 200 new sessions per minute), define -BIG_SESSION_CACHE. If the server will be under heavy load, define -HUGE_SESSION_CACHE. - -There is now a fasthugemath option for configure. This enables fastmath plus -even faster math by greatly increasing the code size of the math library. Use -the benchmark utility to compare public key operations. - - -For general build instructions see rc1 below. - -******************CyaSSL Release 1.0.3 (5/10/2009) - -Release 1.0.3 for CyaSSL adds bug fixes and add increased support for OpenSSL -compatibility when building other applications. - -Release 1.0.3 includes an alpha release of DTLS for both client and servers. -This is only for testing purposes at this time. Rebroadcast and reordering -aren't fully implemented at this time but will be for the next release. - -For general build instructions see rc1 below. - -******************CyaSSL Release 1.0.2 (4/3/2009) - -Release 1.0.2 for CyaSSL adds bug fixes for a couple I/O issues. Some systems -will send a SIGPIPE on socket recv() at any time and this should be handled by -the application by turning off SIGPIPE through setsockopt() or returning from -the handler. - -Release 1.0.2 includes an alpha release of DTLS for both client and servers. -This is only for testing purposes at this time. Rebroadcast and reordering -aren't fully implemented at this time but will be for the next release. - -For general build instructions see rc1 below. - -*****************CyaSSL Release Candidiate 3 rc3-1.0.0 (2/25/2009) - - -Release Candidate 3 for CyaSSL 1.0.0 adds bug fixes and adds a project file for -iPhone development with Xcode. cyassl-iphone.xcodeproj is located in the root -directory. This release also includes a fix for supporting other -implementations that bundle multiple messages at the record layer, this was -lost when cyassl i/o was re-implemented but is now fixed. - -For general build instructions see rc1 below. - -*****************CyaSSL Release Candidiate 2 rc2-1.0.0 (1/21/2009) - - -Release Candidate 2 for CyaSSL 1.0.0 adds bug fixes and adds two new stream -ciphers along with their respective cipher suites. CyaSSL adds support for -HC-128 and RABBIT stream ciphers. The new suites are: - -TLS_RSA_WITH_HC_128_SHA -TLS_RSA_WITH_RABBIT_SHA - -And the corresponding cipher names are - -HC128-SHA -RABBIT-SHA - -CyaSSL also adds support for building with devkitPro for PPC by changing the -library proper to use libogc. The examples haven't been changed yet but if -there's interest they can be. Here's an example ./configure to build CyaSSL -for devkitPro: - -./configure --disable-shared CC=/pathTo/devkitpro/devkitPPC/bin/powerpc-gekko-gcc --host=ppc --without-zlib --enable-singleThreaded RANLIB=/pathTo/devkitpro/devkitPPC/bin/powerpc-gekko-ranlib CFLAGS="-DDEVKITPRO -DGEKKO" - -For linking purposes you'll need - -LDFLAGS="-g -mrvl -mcpu=750 -meabi -mhard-float -Wl,-Map,$(notdir $@).map" - -For general build instructions see rc1 below. - - -********************CyaSSL Release Candidiate 1 rc1-1.0.0 (12/17/2008) - - -Release Candidate 1 for CyaSSL 1.0.0 contains major internal changes. Several -areas have optimization improvements, less dynamic memory use, and the I/O -strategy has been refactored to allow alternate I/O handling or Library use. -Many thanks to Thierry Fournier for providing these ideas and most of the work. - -Because of these changes, this release is only a candidate since some problems -are probably inevitable on some platform with some I/O use. Please report any -problems and we'll try to resolve them as soon as possible. You can contact us -at support@yassl.com or todd@yassl.com. - -Using TomsFastMath by passing --enable-fastmath to ./configure now uses assembly -on some platforms. This is new so please report any problems as every compiler, -mode, OS combination hasn't been tested. On ia32 all of the registers need to -be available so be sure to pass these options to CFLAGS: - -CFLAGS="-O3 -fomit-frame-pointer" - -OS X will also need -mdynamic-no-pic added to CFLAGS - -Also if you're building in shared mode for ia32 you'll need to pass options to -LDFLAGS as well on OS X: - -LDFLAGS=-Wl,-read_only_relocs,warning - -This gives warnings for some symbols but seems to work. - - ---To build on Linux, Solaris, *BSD, Mac OS X, or Cygwin: - - ./configure - make - - from the ./testsuite/ directory run ./testsuite - -to make a debug build: - - ./configure --enable-debug --disable-shared - make - - - ---To build on Win32 - -Choose (Re)Build All from the project workspace - -Run the testsuite program - - - - - -*************************CyaSSL version 0.9.9 (7/25/2008) - -This release of CyaSSL adds bug fixes, Pre-Shared Keys, over-rideable memory -handling, and optionally TomsFastMath. Thanks to Moisés Guimarães for the -work on TomsFastMath. - -To optionally use TomsFastMath pass --enable-fastmath to ./configure -Or define USE_FAST_MATH in each project from CyaSSL for MSVC. - -Please use the benchmark routine before and after to see the performance -difference, on some platforms the gains will be little but RSA encryption -always seems to be faster. On x86-64 machines with GCC the normal math library -may outperform the fast one when using CFLAGS=-m64 because TomsFastMath can't -yet use -m64 because of GCCs inability to do 128bit division. - - **** UPDATE GCC 4.2.1 can now do 128bit division *** - -See notes below (0.2.0) for complete build instructions. - - -****************CyaSSL version 0.9.8 (5/7/2008) - -This release of CyaSSL adds bug fixes, client side Diffie-Hellman, and better -socket handling. - -See notes below (0.2.0) for complete build instructions. - - -****************CyaSSL version 0.9.6 (1/31/2008) - -This release of CyaSSL adds bug fixes, increased session management, and a fix -for gnutls. - -See notes below (0.2.0) for complete build instructions. - - -****************CyaSSL version 0.9.0 (10/15/2007) - -This release of CyaSSL adds bug fixes, MSVC 2005 support, GCC 4.2 support, -IPV6 support and test, and new test certificates. - -See notes below (0.2.0) for complete build instructions. - - -****************CyaSSL version 0.8.0 (1/10/2007) - -This release of CyaSSL adds increased socket support, for non-blocking writes, -connects, and interrupted system calls. - -See notes below (0.2.0) for complete build instructions. - - -****************CyaSSL version 0.6.3 (10/30/2006) - -This release of CyaSSL adds debug logging to stderr to aid in the debugging of -CyaSSL on systems that may not provide the best support. - -If CyaSSL is built with debugging support then you need to call -CyaSSL_Debugging_ON() to turn logging on. - -On Unix use ./configure --enable-debug - -On Windows define DEBUG_CYASSL when building CyaSSL - - -To turn logging back off call CyaSSL_Debugging_OFF() - -See notes below (0.2.0) for complete build instructions. - - -*****************CyaSSL version 0.6.2 (10/29/2006) - -This release of CyaSSL adds TLS 1.1. - -Note that CyaSSL has certificate verification on by default, unlike OpenSSL. -To emulate OpenSSL behavior, you must call SSL_CTX_set_verify() with -SSL_VERIFY_NONE. In order to have full security you should never do this, -provide CyaSSL with the proper certificates to eliminate impostors and call -CyaSSL_check_domain_name() to prevent man in the middle attacks. - -See notes below (0.2.0) for build instructions. - -*****************CyaSSL version 0.6.0 (10/25/2006) - -This release of CyaSSL adds more SSL functions, better autoconf, nonblocking -I/O for accept, connect, and read. There is now an --enable-small configure -option that turns off TLS, AES, DES3, HMAC, and ERROR_STRINGS, see configure.in -for the defines. Note that TLS requires HMAC and AES requires TLS. - -See notes below (0.2.0) for build instructions. - - -*****************CyaSSL version 0.5.5 (09/27/2006) - -This mini release of CyaSSL adds better input processing through buffered input -and big message support. Added SSL_pending() and some sanity checks on user -settings. - -See notes below (0.2.0) for build instructions. - - -*****************CyaSSL version 0.5.0 (03/27/2006) - -This release of CyaSSL adds AES support and minor bug fixes. - -See notes below (0.2.0) for build instructions. - - -*****************CyaSSL version 0.4.0 (03/15/2006) - -This release of CyaSSL adds TLSv1 client/server support and libtool. - -See notes below for build instructions. - - -*****************CyaSSL version 0.3.0 (02/26/2006) - -This release of CyaSSL adds SSLv3 server support and session resumption. - -See notes below for build instructions. - - -*****************CyaSSL version 0.2.0 (02/19/2006) - - -This is the first release of CyaSSL and its crypt brother, CTaoCrypt. CyaSSL -is written in ANSI C with the idea of a small code size, footprint, and memory -usage in mind. CTaoCrypt can be as small as 32K, and the current client -version of CyaSSL can be as small as 12K. - - -The first release of CTaoCrypt supports MD5, SHA-1, 3DES, ARC4, Big Integer -Support, RSA, ASN parsing, and basic x509 (en/de)coding. - -The first release of CyaSSL supports normal client RSA mode SSLv3 connections -with support for SHA-1 and MD5 digests. Ciphers include 3DES and RC4. - - ---To build on Linux, Solaris, *BSD, Mac OS X, or Cygwin: - - ./configure - make - - from the ./testsuite/ directory run ./testsuite - -to make a debug build: - - ./configure --enable-debug --disable-shared - make - - - ---To build on Win32 - -Choose (Re)Build All from the project workspace - -Run the testsuite program - - - -*** The next release of CyaSSL will support a server and more OpenSSL -compatibility functions. - - -Please send questions or comments to todd@yassl.com - diff --git a/FreeRTOS-Plus/Source/WolfSSL/README.md b/FreeRTOS-Plus/Source/WolfSSL/README.md deleted file mode 100755 index a490ac2..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/README.md +++ /dev/null @@ -1,1194 +0,0 @@ -# Notes - Please read - -## Note 1 -``` -wolfSSL now needs all examples and tests to be run from the wolfSSL home -directory. This is because it finds certs and keys from ./certs/. Trying to -maintain the ability to run each program from its own directory, the testsuite -directory, the main directory (for make check/test), and for the various -different project layouts (with or without config) was becoming harder and -harder. Now to run testsuite just do: - -./testsuite/testsuite - -or - -make check (when using autoconf) - -On *nix or Windows the examples and testsuite will check to see if the current -directory is the source directory and if so, attempt to change to the wolfSSL -home directory. This should work in most setup cases, if not, just follow the -beginning of the note and specify the full path. -``` - -## Note 2 -``` -wolfSSL takes a different approach to certificate verification than OpenSSL -does. The default policy for the client is to verify the server, this means -that if you don't load CAs to verify the server you'll get a connect error, -no signer error to confirm failure (-188). If you want to mimic OpenSSL -behavior of having SSL_connect succeed even if verifying the server fails and -reducing security you can do this by calling: - -wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0); - -before calling wolfSSL_new(); Though it's not recommended. -``` - -- GNU Binutils 2.24 ld has problems with some debug builds, to fix an ld error - add -fdebug-types-section to C_EXTRA_FLAGS - -#wolfSSL (Formerly CyaSSL) Release 3.4.8 (04/06/2015) - -##Release 3.4.8 of wolfSSL has bug fixes and new features including: - -- FIPS version submitted for iOS. -- Max Strength build that only allows TLSv1.2, AEAD ciphers, and PFS. -- Improvements to usage of time code. -- Improvements to VS solution files. - -See INSTALL file for build instructions. -More info can be found on-line at //http://wolfssl.com/yaSSL/Docs.html - - -#wolfSSL (Formerly CyaSSL) Release 3.4.6 (03/30/2015) - -##Release 3.4.6 of wolfSSL has bug fixes and new features including: - -- Intel Assembly Speedups using instructions rdrand, rdseed, aesni, avx1/2, - rorx, mulx, adox, adcx . They can be enabled with --enable-intelasm. - These speedup the use of RNG, SHA2, and public key algorithms. -- Ed25519 support at the crypto level. Turn on with --enable-ed25519. Examples - in wolcrypt/test/test.c ed25519_test(). -- Post Handshake Memory reductions. wolfSSL can now hold less than 1,000 bytes - of memory per secure connection including cipher state. -- wolfSSL API and wolfCrypt API fixes, you can still include the cyassl and - ctaocrypt headers which will enable the compatibility APIs for the - foreseeable future -- INSTALL file to help direct users to build instructions for their environment -- For ECC users with the normal math library a fix that prevents a crash when - verify signature fails. Users of 3.4.0 with ECC and the normal math library - must update -- RC4 is now disabled by default in autoconf mode -- AES-GCM and ChaCha20/Poly1305 are now enabled by default to make AEAD ciphers - available without a switch -- External ChaCha-Poly AEAD API, thanks to Andrew Burks for the contribution -- DHE-PSK cipher suites can now be built without ASN or Cert support -- Fix some NO MD5 build issues with optional features -- Freescale CodeWarrior project updates -- ECC curves can be individually turned on/off at build time. -- Sniffer handles Cert Status message and other minor fixes -- SetMinVersion() at the wolfSSL Context level instead of just SSL session level - to allow minimum protocol version allowed at runtime -- RNG failure resource cleanup fix - -- No high level security fixes that requires an update though we always - recommend updating to the latest (except note 6 use case of ecc/normal math) - -See INSTALL file for build instructions. -More info can be found on-line at //http://wolfssl.com/yaSSL/Docs.html - - -#wolfSSL (Formerly CyaSSL) Release 3.4.0 (02/23/2015) - -## Release 3.4.0 wolfSSL has bug fixes and new features including: - -- wolfSSL API and wolfCrypt API, you can still include the cyassl and ctaocrypt - headers which will enable the compatibility APIs for the foreseeable future -- Example use of the wolfCrypt API can be found in wolfcrypt/test/test.c -- Example use of the wolfSSL API can be found in examples/client/client.c -- Curve25519 now supported at the wolfCrypt level, wolfSSL layer coming soon -- Improvements in the build configuration under AIX -- Microchip Pic32 MZ updates -- TIRTOS updates -- PowerPC updates -- Xcode project update -- Bidirectional shutdown examples in client/server with -w (wait for full - shutdown) option -- Cycle counts on benchmarks for x86_64, more coming soon -- ALT_ECC_SIZE for reducing ecc heap use with fastmath when also using large RSA - keys -- Various compile warnings -- Scan-build warning fixes -- Changed a memcpy to memmove in the sniffer (if using sniffer please update) -- No high level security fixes that requires an update though we always - recommend updating to the latest - - -# CyaSSL Release 3.3.0 (12/05/2014) - -- Countermeasuers for Handshake message duplicates, CHANGE CIPHER without - FINISHED, and fast forward attempts. Thanks to Karthikeyan Bhargavan from - the Prosecco team at INRIA Paris-Rocquencourt for the report. -- FIPS version submitted -- Removes SSLv2 Client Hello processing, can be enabled with OLD_HELLO_ALLOWED -- User can set mimimum downgrade version with CyaSSL_SetMinVersion() -- Small stack improvements at TLS/SSL layer -- TLS Master Secret generation and Key Expansion are now exposed -- Adds client side Secure Renegotiation, * not recommended * -- Client side session ticket support, not fully tested with Secure Renegotiation -- Allows up to 4096bit DHE at TLS Key Exchange layer -- Handles non standard SessionID sizes in Hello Messages -- PicoTCP Support -- Sniffer now supports SNI Virtual Hosts -- Sniffer now handles non HTTPS protocols using STARTTLS -- Sniffer can now parse records with multiple messages -- TI-RTOS updates -- Fix for ColdFire optimized fp_digit read only in explicit 32bit case -- ADH Cipher Suite ADH-AES128-SHA for EAP-FAST - -The CyaSSL manual is available at: -http://www.wolfssl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -# CyaSSL Release 3.2.0 (09/10/2014) - -#### Release 3.2.0 CyaSSL has bug fixes and new features including: - -- ChaCha20 and Poly1305 crypto and suites -- Small stack improvements for OCSP, CRL, TLS, DTLS -- NTRU Encrypt and Decrypt benchmarks -- Updated Visual Studio project files -- Updated Keil MDK5 project files -- Fix for DTLS sequence numbers with GCM/CCM -- Updated HashDRBG with more secure struct declaration -- TI-RTOS support and example Code Composer Studio project files -- Ability to get enabled cipher suites, CyaSSL_get_ciphers() -- AES-GCM/CCM/Direct support for Freescale mmCAU and CAU -- Sniffer improvement checking for decrypt key setup -- Support for raw ECC key import -- Ability to convert ecc_key to DER, EccKeyToDer() -- Security fix for RSA Padding check vulnerability reported by Intel Security - Advanced Threat Research team - -The CyaSSL manual is available at: -http://www.wolfssl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -# CyaSSL Release 3.1.0 (07/14/2014) - -#### Release 3.1.0 CyaSSL has bug fixes and new features including: - -- Fix for older versions of icc without 128-bit type -- Intel ASM syntax for AES-NI -- Updated NTRU support, keygen benchmark -- FIPS check for minimum required HMAC key length -- Small stack (--enable-smallstack) improvements for PKCS#7, ASN -- TLS extension support for DTLS -- Default I/O callbacks external to user -- Updated example client with bad clock test -- Ability to set optional ECC context info -- Ability to enable/disable DH separate from opensslextra -- Additional test key/cert buffers for CA and server -- Updated example certificates - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -# CyaSSL Release 3.0.2 (05/30/2014) - -#### Release 3.0.2 CyaSSL has bug fixes and new features including: - -- Added the following cipher suites: - * TLS_PSK_WITH_AES_128_GCM_SHA256 - * TLS_PSK_WITH_AES_256_GCM_SHA384 - * TLS_PSK_WITH_AES_256_CBC_SHA384 - * TLS_PSK_WITH_NULL_SHA384 - * TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 - * TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 - * TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 - * TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 - * TLS_DHE_PSK_WITH_NULL_SHA256 - * TLS_DHE_PSK_WITH_NULL_SHA384 - * TLS_DHE_PSK_WITH_AES_128_CCM - * TLS_DHE_PSK_WITH_AES_256_CCM -- Added AES-NI support for Microsoft Visual Studio builds. -- Changed small stack build to be disabled by default. -- Updated the Hash DRBG and provided a configure option to enable. - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -# CyaSSL Release 3.0.0 (04/29/2014) - -#### Release 3.0.0 CyaSSL has bug fixes and new features including: - -- FIPS release candidate -- X.509 improvements that address items reported by Suman Jana with security - researchers at UT Austin and UC Davis -- Small stack size improvements, --enable-smallstack. Offloads large local - variables to the heap. (Note this is not complete.) -- Updated AES-CCM-8 cipher suites to use approved suite numbers. - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -# CyaSSL Release 2.9.4 (04/09/2014) - -#### Release 2.9.4 CyaSSL has bug fixes and new features including: - -- Security fixes that address items reported by Ivan Fratric of the Google - Security Team -- X.509 Unknown critical extensions treated as errors, report by Suman Jana with - security researchers at UT Austin and UC Davis -- Sniffer fixes for corrupted packet length and Jumbo frames -- ARM thumb mode assembly fixes -- Xcode 5.1 support including new clang -- PIC32 MZ hardware support -- CyaSSL Object has enough room to read the Record Header now w/o allocs -- FIPS wrappers for AES, 3DES, SHA1, SHA256, SHA384, HMAC, and RSA. -- A sample I/O pool is demonstrated with --enable-iopool to overtake memory - handling and reduce memory fragmentation on I/O large sizes - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -# CyaSSL Release 2.9.0 (02/07/2014) - -#### Release 2.9.0 CyaSSL has bug fixes and new features including: -- Freescale Kinetis RNGB support -- Freescale Kinetis mmCAU support -- TLS Hello extensions - - ECC - - Secure Renegotiation (null) - - Truncated HMAC -- SCEP support - - PKCS #7 Enveloped data and signed data - - PKCS #10 Certificate Signing Request generation -- DTLS sliding window -- OCSP Improvements - - API change to integrate into Certificate Manager - - IPv4/IPv6 agnostic - - example client/server support for OCSP - - OCSP nonces are optional -- GMAC hashing -- Windows build additions -- Windows CYGWIN build fixes -- Updated test certificates -- Microchip MPLAB Harmony support -- Update autoconf scripts -- Additional X.509 inspection functions -- ECC encrypt/decrypt primitives -- ECC Certificate generation - -The Freescale Kinetis K53 RNGB documentation can be found in Chapter 33 of the -K53 Sub-Family Reference Manual: -http://cache.freescale.com/files/32bit/doc/ref_manual/K53P144M100SF2RM.pdf - -Freescale Kinetis K60 mmCAU (AES, DES, 3DES, MD5, SHA, SHA256) documentation -can be found in the "ColdFire/ColdFire+ CAU and Kinetis mmCAU Software Library -User Guide": -http://cache.freescale.com/files/32bit/doc/user_guide/CAUAPIUG.pdf - - -# CyaSSL Release 2.8.0 (8/30/2013) - -#### Release 2.8.0 CyaSSL has bug fixes and new features including: -- AES-GCM and AES-CCM use AES-NI -- NetX default IO callback handlers -- IPv6 fixes for DTLS Hello Cookies -- The ability to unload Certs/Keys after the handshake, CyaSSL_UnloadCertsKeys() -- SEP certificate extensions -- Callback getters for easier resource freeing -- External CYASSL_MAX_ERROR_SZ for correct error buffer sizing -- MacEncrypt and DecryptVerify Callbacks for User Atomic Record Layer Processing -- Public Key Callbacks for ECC and RSA -- Client now sends blank cert upon request if doesn't have one with TLS <= 1.2 - - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -# CyaSSL Release 2.7.0 (6/17/2013) - -#### Release 2.7.0 CyaSSL has bug fixes and new features including: -- SNI support for client and server -- KEIL MDK-ARM projects -- Wildcard check to domain name match, and Subject altnames are checked too -- Better error messages for certificate verification errors -- Ability to discard session during handshake verify -- More consistent error returns across all APIs -- Ability to unload CAs at the CTX or CertManager level -- Authority subject id support for Certificate matching -- Persistent session cache functionality -- Persistent CA cache functionality -- Client session table lookups to push serverID table to library level -- Camellia support to sniffer -- User controllable settings for DTLS timeout values -- Sniffer fixes for caching long lived sessions -- DTLS reliability enhancements for the handshake -- Better ThreadX support - -When compiling with Mingw, libtool may give the following warning due to -path conversion errors: - -``` -libtool: link: Could not determine host file name corresponding to ** -libtool: link: Continuing, but uninstalled executables may not work. -``` - -If so, examples and testsuite will have problems when run, showing an -error while loading shared libraries. To resolve, please run "make install". - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -# CyaSSL Release 2.6.0 (04/15/2013) - -#### Release 2.6.0 CyaSSL has bug fixes and new features including: -- DTLS 1.2 support including AEAD ciphers -- SHA-3 finalist Blake2 support, it's fast and uses little resources -- SHA-384 cipher suites including ECC ones -- HMAC now supports SHA-512 -- Track memory use for example client/server with -t option -- Better IPv6 examples with --enable-ipv6, before if ipv6 examples/tests were - turned on, localhost only was used. Now link-local (with scope ids) and ipv6 - hosts can be used as well. -- Xcode v4.6 project for iOS v6.1 update -- settings.h is now checked in all *.c files for true one file setting detection -- Better alignment at SSL layer for hardware crypto alignment needs - * Note, SSL itself isn't friendly to alignment with 5 byte TLS headers and - 13 bytes DTLS headers, but every effort is now made to align with the - CYASSL_GENERAL_ALIGNMENT flag which sets desired alignment requirement -- NO_64BIT flag to turn off 64bit data type accumulators in public key code - * Note, some systems are faster with 32bit accumulators -- --enable-stacksize for example client/server stack use - * Note, modern desktop Operating Systems may add bytes to each stack frame -- Updated compression/decompression with direct crypto access -- All ./configure options are now lowercase only for consistency -- ./configure builds default to fastmath option - * Note, if on ia32 and building in shared mode this may produce a problem - with a missing register being available because of PIC, there are at least - 5 solutions to this: - 1) --disable-fastmath , don't use fastmath - 2) --disable-shared, don't build a shared library - 3) C_EXTRA_FLAGS=-DTFM_NO_ASM , turn off assembly use - 4) use clang, it just seems to work - 5) play around with no PIC options to force all registers being open -- Many new ./configure switches for option enable/disable for example - * rsa - * dh - * dsa - * md5 - * sha - * arc4 - * null (allow NULL ciphers) - * oldtls (only use TLS 1.2) - * asn (no certs or public keys allowed) -- ./configure generates cyassl/options.h which allows a header the user can - include in their app to make sure the same options are set at the app and - CyaSSL level. -- autoconf no longer needs serial-tests which lowers version requirements of - automake to 1.11 and autoconf to 2.63 - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -# CyaSSL Release 2.5.0 (02/04/2013) - -#### Release 2.5.0 CyaSSL has bug fixes and new features including: -- Fix for TLS CBC padding timing attack identified by Nadhem Alfardan and - Kenny Paterson: http://www.isg.rhul.ac.uk/tls/ -- Microchip PIC32 (MIPS16, MIPS32) support -- Microchip MPLAB X example projects for PIC32 Ethernet Starter Kit -- Updated CTaoCrypt benchmark app for embedded systems -- 1024-bit test certs/keys and cert/key buffers -- AES-CCM-8 crypto and cipher suites -- Camellia crypto and cipher suites -- Bumped minimum autoconf version to 2.65, automake version to 1.12 -- Addition of OCSP callbacks -- STM32F2 support with hardware crypto and RNG -- Cavium NITROX support - -CTaoCrypt now has support for the Microchip PIC32 and has been tested with -the Microchip PIC32 Ethernet Starter Kit, the XC32 compiler and -MPLAB X IDE in both MIPS16 and MIPS32 instruction set modes. See the README -located under the /mplabx directory for more details. - -To add Cavium NITROX support do: - -./configure --with-cavium=/home/user/cavium/software - -pointing to your licensed cavium/software directory. Since Cavium doesn't -build a library we pull in the cavium_common.o file which gives a libtool -warning about the portability of this. Also, if you're using the github source -tree you'll need to remove the -Wredundant-decls warning from the generated -Makefile because the cavium headers don't conform to this warning. Currently -CyaSSL supports Cavium RNG, AES, 3DES, RC4, HMAC, and RSA directly at the crypto -layer. Support at the SSL level is partial and currently just does AES, 3DES, -and RC4. RSA and HMAC are slower until the Cavium calls can be utilized in non -blocking mode. The example client turns on cavium support as does the crypto -test and benchmark. Please see the HAVE_CAVIUM define. - -CyaSSL is able to use the STM32F2 hardware-based cryptography and random number -generator through the STM32F2 Standard Peripheral Library. For necessary -defines, see the CYASSL_STM32F2 define in settings.h. Documentation for the -STM32F2 Standard Peripheral Library can be found in the following document: -http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/USER_MANUAL/DM00023896.pdf - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -# CyaSSL Release 2.4.6 (12/20/2012) - -#### Release 2.4.6 CyaSSL has bug fixes and a few new features including: -- ECC into main version -- Lean PSK build (reduced code size, RAM usage, and stack usage) -- FreeBSD CRL monitor support -- CyaSSL_peek() -- CyaSSL_send() and CyaSSL_recv() for I/O flag setting -- CodeWarrior Support -- MQX Support -- Freescale Kinetis support including Hardware RNG -- autoconf builds use jobserver -- cyassl-config -- Sniffer memory reductions - -Thanks to Brian Aker for the improved autoconf system, make rpm, cyassl-config, -warning system, and general good ideas for improving CyaSSL! - -The Freescale Kinetis K70 RNGA documentation can be found in Chapter 37 of the -K70 Sub-Family Reference Manual: -http://cache.freescale.com/files/microcontrollers/doc/ref_manual/K70P256M150SF3RM.pdf - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - -# CyaSSL Release 2.4.0 (10/10/2012) - -#### Release 2.4.0 CyaSSL has bug fixes and a few new features including: -- DTLS reliability -- Reduced memory usage after handshake -- Updated build process - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -# CyaSSL Release 2.3.0 (8/10/2012) - -#### Release 2.3.0 CyaSSL has bug fixes and a few new features including: -- AES-GCM crypto and cipher suites -- make test cipher suite checks -- Subject AltName processing -- Command line support for client/server examples -- Sniffer SessionTicket support -- SHA-384 cipher suites -- Verify cipher suite validity when user overrides -- CRL dir monitoring -- DTLS Cookie support, reliability coming soon - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -# CyaSSL Release 2.2.0 (5/18/2012) - -#### Release 2.2.0 CyaSSL has bug fixes and a few new features including: -- Initial CRL support (--enable-crl) -- Initial OCSP support (--enable-ocsp) -- Add static ECDH suites -- SHA-384 support -- ECC client certificate support -- Add medium session cache size (1055 sessions) -- Updated unit tests -- Protection against mutex reinitialization - - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -# CyaSSL Release 2.0.8 (2/24/2012) - -#### Release 2.0.8 CyaSSL has bug fixes and a few new features including: -- A fix for malicious certificates pointed out by Remi Gacogne (thanks) - resulting in NULL pointer use. -- Respond to renegotiation attempt with no_renegoatation alert -- Add basic path support for load_verify_locations() -- Add set Temp EC-DHE key size -- Extra checks on rsa test when porting into - - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -# CyaSSL Release 2.0.6 (1/27/2012) - -#### Release 2.0.6 CyaSSL has bug fixes and a few new features including: -- Fixes for CA basis constraint check -- CTX reference counting -- Initial unit test additions -- Lean and Mean Windows fix -- ECC benchmarking -- SSMTP build support -- Ability to group handshake messages with set_group_messages(ctx/ssl) -- CA cache addition callback -- Export Base64_Encode for general use - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -# CyaSSL Release 2.0.2 (12/05/2011) - -#### Release 2.0.2 CyaSSL has bug fixes and a few new features including: -- CTaoCrypt Runtime library detection settings when directly using the crypto - library -- Default certificate generation now uses SHAwRSA and adds SHA256wRSA generation -- All test certificates now use 2048bit and SHA-1 for better modern browser - support -- Direct AES block access and AES-CTR (counter) mode -- Microchip pic32 support - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - - - -# CyaSSL Release 2.0.0rc3 (9/28/2011) - -#### Release 2.0.0rc3 for CyaSSL has bug fixes and a few new features including: -- updated autoconf support -- better make install and uninstall (uses system directories) -- make test / make check -- CyaSSL headers now in -- CTaocrypt headers now in -- OpenSSL compatibility headers now in -- examples and tests all run from home directory so can use certs in ./certs - (see note 1) - -So previous applications that used the OpenSSL compatibility header - now need to include instead, no other -changes are required. - -Special Thanks to Brian Aker for his autoconf, install, and header patches. - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - -# CyaSSL Release 2.0.0rc2 (6/6/2011) - -#### Release 2.0.0rc2 for CyaSSL has bug fixes and a few new features including: -- bug fixes (Alerts, DTLS with DHE) -- FreeRTOS support -- lwIP support -- Wshadow warnings removed -- asn public header -- CTaoCrypt public headers now all have ctc_ prefix (the manual is still being - updated to reflect this change) -- and more. - -This is the 2nd and perhaps final release candidate for version 2. -Please send any comments or questions to support@yassl.com. - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - -# CyaSSL Release 2.0.0rc1 (5/2/2011) - -#### Release 2.0.0rc1 for CyaSSL has many new features including: -- bug fixes -- SHA-256 cipher suites -- Root Certificate Verification (instead of needing all certs in the chain) -- PKCS #8 private key encryption (supports PKCS #5 v1-v2 and PKCS #12) -- Serial number retrieval for x509 -- PBKDF2 and PKCS #12 PBKDF -- UID parsing for x509 -- SHA-256 certificate signatures -- Client and server can send chains (SSL_CTX_use_certificate_chain_file) -- CA loading can now parse multiple certificates per file -- Dynamic memory runtime hooks -- Runtime hooks for logging -- EDH on server side -- More informative error codes -- More informative logging messages -- Version downgrade more robust (use SSL_v23*) -- Shared build only by default through ./configure -- Compiler visibility is now used, internal functions not polluting namespace -- Single Makefile, no recursion, for faster and simpler building -- Turn on all warnings possible build option, warning fixes -- and more. - -Because of all the new features and the multiple OS, compiler, feature-set -options that CyaSSL allows, there may be some configuration fixes needed. -Please send any comments or questions to support@yassl.com. - -The CyaSSL manual is available at: -http://www.yassl.com/documentation/CyaSSL-Manual.pdf. For build instructions -and comments about the new features please check the manual. - -# CyaSSL Release 1.9.0 (3/2/2011) - -Release 1.9.0 for CyaSSL adds bug fixes, improved TLSv1.2 through testing and -better hash/sig algo ids, --enable-webServer for the yaSSL embedded web server, -improper AES key setup detection, user cert verify callback improvements, and -more. - -The CyaSSL manual offering is included in the doc/ directory. For build -instructions and comments about the new features please check the manual. - -Please send any comments or questions to support@yassl.com. - -# CyaSSL Release 1.8.0 (12/23/2010) - -Release 1.8.0 for CyaSSL adds bug fixes, x509 v3 CA signed certificate -generation, a C standard library abstraction layer, lower memory use, increased -portability through the os_settings.h file, and the ability to use NTRU cipher -suites when used in conjunction with an NTRU license and library. - -The initial CyaSSL manual offering is included in the doc/ directory. For -build instructions and comments about the new features please check the manual. - -Please send any comments or questions to support@yassl.com. - -Happy Holidays. - - -# CyaSSL Release 1.6.5 (9/9/2010) - -Release 1.6.5 for CyaSSL adds bug fixes and x509 v3 self signed certificate -generation. - -For general build instructions see doc/Building_CyaSSL.pdf. - -To enable certificate generation support add this option to ./configure -./configure --enable-certgen - -An example is included in ctaocrypt/test/test.c and documentation is provided -in doc/CyaSSL_Extensions_Reference.pdf item 11. - -# CyaSSL Release 1.6.0 (8/27/2010) - -Release 1.6.0 for CyaSSL adds bug fixes, RIPEMD-160, SHA-512, and RSA key -generation. - -For general build instructions see doc/Building_CyaSSL.pdf. - -To add RIPEMD-160 support add this option to ./configure -./configure --enable-ripemd - -To add SHA-512 support add this option to ./configure -./configure --enable-sha512 - -To add RSA key generation support add this option to ./configure -./configure --enable-keygen - -Please see ctaocrypt/test/test.c for examples and usage. - -For Windows, RIPEMD-160 and SHA-512 are enabled by default but key generation is -off by default. To turn key generation on add the define CYASSL_KEY_GEN to -CyaSSL. - - -# CyaSSL Release 1.5.6 (7/28/2010) - -Release 1.5.6 for CyaSSL adds bug fixes, compatibility for our JSSE provider, -and a fix for GCC builds on some systems. - -For general build instructions see doc/Building_CyaSSL.pdf. - -To add AES-NI support add this option to ./configure -./configure --enable-aesni - -You'll need GCC 4.4.3 or later to make use of the assembly. - -# CyaSSL Release 1.5.4 (7/7/2010) - -Release 1.5.4 for CyaSSL adds bug fixes, support for AES-NI, SHA1 speed -improvements from loop unrolling, and support for the Mongoose Web Server. - -For general build instructions see doc/Building_CyaSSL.pdf. - -To add AES-NI support add this option to ./configure -./configure --enable-aesni - -You'll need GCC 4.4.3 or later to make use of the assembly. - -# CyaSSL Release 1.5.0 (5/11/2010) - -Release 1.5.0 for CyaSSL adds bug fixes, GoAhead WebServer support, sniffer -support, and initial swig interface support. - -For general build instructions see doc/Building_CyaSSL.pdf. - -To add support for GoAhead WebServer either --enable-opensslExtra or if you -don't want all the features of opensslExtra you can just define GOAHEAD_WS -instead. GOAHEAD_WS can be added to ./configure with CFLAGS=-DGOAHEAD_WS or -you can define it yourself. - -To look at the sniffer support please see the sniffertest app in -sslSniffer/sslSnifferTest. Build with --enable-sniffer on *nix or use the -vcproj files on windows. You'll need to have pcap installed on *nix and -WinPcap on windows. - -A swig interface file is now located in the swig directory for using Python, -Java, Perl, and others with CyaSSL. This is initial support and experimental, -please send questions or comments to support@yassl.com. - -When doing load testing with CyaSSL, on the echoserver example say, the client -machine may run out of tcp ephemeral ports, they will end up in the TIME_WAIT -queue, and can't be reused by default. There are generally two ways to fix -this. - -1. Reduce the length sockets remain on the TIME_WAIT queue OR -2. Allow items on the TIME_WAIT queue to be reused. - - -To reduce the TIME_WAIT length in OS X to 3 seconds (3000 milliseconds) - -`sudo sysctl -w net.inet.tcp.msl=3000` - -In Linux - -`sudo sysctl -w net.ipv4.tcp_tw_reuse=1` - -allows reuse of sockets in TIME_WAIT - -`sudo sysctl -w net.ipv4.tcp_tw_recycle=1` - -works but seems to remove sockets from TIME_WAIT entirely? - -`sudo sysctl -w net.ipv4.tcp_fin_timeout=1` - -doen't control TIME_WAIT, it controls FIN_WAIT(2) contrary to some posts - - -# CyaSSL Release 1.4.0 (2/18/2010) - -Release 1.3.0 for CyaSSL adds bug fixes, better multi TLS/SSL version support -through SSLv23_server_method(), and improved documentation in the doc/ folder. - -For general build instructions doc/Building_CyaSSL.pdf. - -# CyaSSL Release 1.3.0 (1/21/2010) - -Release 1.3.0 for CyaSSL adds bug fixes, a potential security problem fix, -better porting support, removal of assert()s, and a complete THREADX port. - -For general build instructions see rc1 below. - -# CyaSSL Release 1.2.0 (11/2/2009) - -Release 1.2.0 for CyaSSL adds bug fixes and session negotiation if first use is -read or write. - -For general build instructions see rc1 below. - -# CyaSSL Release 1.1.0 (9/2/2009) - -Release 1.1.0 for CyaSSL adds bug fixes, a check against malicious session -cache use, support for lighttpd, and TLS 1.2. - -To get TLS 1.2 support please use the client and server functions: - -```c -SSL_METHOD *TLSv1_2_server_method(void); -SSL_METHOD *TLSv1_2_client_method(void); -``` - -CyaSSL was tested against lighttpd 1.4.23. To build CyaSSL for use with -lighttpd use the following commands from the CyaSSL install dir : - -``` -./configure --disable-shared --enable-opensslExtra --enable-fastmath --without-zlib - -make -make openssl-links -``` - -Then to build lighttpd with CyaSSL use the following commands from the -lighttpd install dir: - -``` -./configure --with-openssl --with-openssl-includes=/include --with-openssl-libs=/lib LDFLAGS=-lm - -make -``` - -On some systems you may get a linker error about a duplicate symbol for -MD5_Init or other MD5 calls. This seems to be caused by the lighttpd src file -md5.c, which defines MD5_Init(), and is included in liblightcomp_la-md5.o. -When liblightcomp is linked with the SSL_LIBs the linker may complain about -the duplicate symbol. This can be fixed by editing the lighttpd src file md5.c -and adding this line to the beginning of the file: - -\#if 0 - -and this line to the end of the file - -\#endif - -Then from the lighttpd src dir do a: - -``` -make clean -make -``` - -If you get link errors about undefined symbols more than likely the actual -OpenSSL libraries are found by the linker before the CyaSSL openssl-links that -point to the CyaSSL library, causing the linker confusion. This can be fixed -by editing the Makefile in the lighttpd src directory and changing the line: - -`SSL_LIB = -lssl -lcrypto` - -to - -`SSL_LIB = -lcyassl` - -Then from the lighttpd src dir do a: - -``` -make clean -make -``` - -This should remove any confusion the linker may be having with missing symbols. - -For any questions or concerns please contact support@yassl.com . - -For general build instructions see rc1 below. - -# CyaSSL Release 1.0.6 (8/03/2009) - -Release 1.0.6 for CyaSSL adds bug fixes, an improved session cache, and faster -math with a huge code option. - -The session cache now defaults to a client mode, also good for embedded servers. -For servers not under heavy load (less than 200 new sessions per minute), define -BIG_SESSION_CACHE. If the server will be under heavy load, define -HUGE_SESSION_CACHE. - -There is now a fasthugemath option for configure. This enables fastmath plus -even faster math by greatly increasing the code size of the math library. Use -the benchmark utility to compare public key operations. - - -For general build instructions see rc1 below. - -# CyaSSL Release 1.0.3 (5/10/2009) - -Release 1.0.3 for CyaSSL adds bug fixes and add increased support for OpenSSL -compatibility when building other applications. - -Release 1.0.3 includes an alpha release of DTLS for both client and servers. -This is only for testing purposes at this time. Rebroadcast and reordering -aren't fully implemented at this time but will be for the next release. - -For general build instructions see rc1 below. - -# CyaSSL Release 1.0.2 (4/3/2009) - -Release 1.0.2 for CyaSSL adds bug fixes for a couple I/O issues. Some systems -will send a SIGPIPE on socket recv() at any time and this should be handled by -the application by turning off SIGPIPE through setsockopt() or returning from -the handler. - -Release 1.0.2 includes an alpha release of DTLS for both client and servers. -This is only for testing purposes at this time. Rebroadcast and reordering -aren't fully implemented at this time but will be for the next release. - -For general build instructions see rc1 below. - -## CyaSSL Release Candidiate 3 rc3-1.0.0 (2/25/2009) - - -Release Candidate 3 for CyaSSL 1.0.0 adds bug fixes and adds a project file for -iPhone development with Xcode. cyassl-iphone.xcodeproj is located in the root -directory. This release also includes a fix for supporting other -implementations that bundle multiple messages at the record layer, this was -lost when cyassl i/o was re-implemented but is now fixed. - -For general build instructions see rc1 below. - -## CyaSSL Release Candidiate 2 rc2-1.0.0 (1/21/2009) - - -Release Candidate 2 for CyaSSL 1.0.0 adds bug fixes and adds two new stream -ciphers along with their respective cipher suites. CyaSSL adds support for -HC-128 and RABBIT stream ciphers. The new suites are: - -``` -TLS_RSA_WITH_HC_128_SHA -TLS_RSA_WITH_RABBIT_SHA -``` - -And the corresponding cipher names are - -``` -HC128-SHA -RABBIT-SHA -``` - -CyaSSL also adds support for building with devkitPro for PPC by changing the -library proper to use libogc. The examples haven't been changed yet but if -there's interest they can be. Here's an example ./configure to build CyaSSL -for devkitPro: - -``` -./configure --disable-shared CC=/pathTo/devkitpro/devkitPPC/bin/powerpc-gekko-gcc --host=ppc --without-zlib --enable-singleThreaded RANLIB=/pathTo/devkitpro/devkitPPC/bin/powerpc-gekko-ranlib CFLAGS="-DDEVKITPRO -DGEKKO" -``` - -For linking purposes you'll need - -`LDFLAGS="-g -mrvl -mcpu=750 -meabi -mhard-float -Wl,-Map,$(notdir $@).map"` - -For general build instructions see rc1 below. - - -## CyaSSL Release Candidiate 1 rc1-1.0.0 (12/17/2008) - - -Release Candidate 1 for CyaSSL 1.0.0 contains major internal changes. Several -areas have optimization improvements, less dynamic memory use, and the I/O -strategy has been refactored to allow alternate I/O handling or Library use. -Many thanks to Thierry Fournier for providing these ideas and most of the work. - -Because of these changes, this release is only a candidate since some problems -are probably inevitable on some platform with some I/O use. Please report any -problems and we'll try to resolve them as soon as possible. You can contact us -at support@yassl.com or todd@yassl.com. - -Using TomsFastMath by passing --enable-fastmath to ./configure now uses assembly -on some platforms. This is new so please report any problems as every compiler, -mode, OS combination hasn't been tested. On ia32 all of the registers need to -be available so be sure to pass these options to CFLAGS: - -`CFLAGS="-O3 -fomit-frame-pointer"` - -OS X will also need -mdynamic-no-pic added to CFLAGS - -Also if you're building in shared mode for ia32 you'll need to pass options to -LDFLAGS as well on OS X: - -`LDFLAGS=-Wl,-read_only_relocs,warning` - -This gives warnings for some symbols but seems to work. - - -#### To build on Linux, Solaris, *BSD, Mac OS X, or Cygwin: - - ./configure - make - - from the ./testsuite/ directory run ./testsuite - -#### To make a debug build: - - ./configure --enable-debug --disable-shared - make - - - -#### To build on Win32 - -Choose (Re)Build All from the project workspace - -Run the testsuite program - - - - - -# CyaSSL version 0.9.9 (7/25/2008) - -This release of CyaSSL adds bug fixes, Pre-Shared Keys, over-rideable memory -handling, and optionally TomsFastMath. Thanks to Moisés Guimarães for the -work on TomsFastMath. - -To optionally use TomsFastMath pass --enable-fastmath to ./configure -Or define USE_FAST_MATH in each project from CyaSSL for MSVC. - -Please use the benchmark routine before and after to see the performance -difference, on some platforms the gains will be little but RSA encryption -always seems to be faster. On x86-64 machines with GCC the normal math library -may outperform the fast one when using CFLAGS=-m64 because TomsFastMath can't -yet use -m64 because of GCCs inability to do 128bit division. - - *** UPDATE GCC 4.2.1 can now do 128bit division *** - -See notes below (0.2.0) for complete build instructions. - - -# CyaSSL version 0.9.8 (5/7/2008) - -This release of CyaSSL adds bug fixes, client side Diffie-Hellman, and better -socket handling. - -See notes below (0.2.0) for complete build instructions. - - -# CyaSSL version 0.9.6 (1/31/2008) - -This release of CyaSSL adds bug fixes, increased session management, and a fix -for gnutls. - -See notes below (0.2.0) for complete build instructions. - - -# CyaSSL version 0.9.0 (10/15/2007) - -This release of CyaSSL adds bug fixes, MSVC 2005 support, GCC 4.2 support, -IPV6 support and test, and new test certificates. - -See notes below (0.2.0) for complete build instructions. - - -# CyaSSL version 0.8.0 (1/10/2007) - -This release of CyaSSL adds increased socket support, for non-blocking writes, -connects, and interrupted system calls. - -See notes below (0.2.0) for complete build instructions. - - -# CyaSSL version 0.6.3 (10/30/2006) - -This release of CyaSSL adds debug logging to stderr to aid in the debugging of -CyaSSL on systems that may not provide the best support. - -If CyaSSL is built with debugging support then you need to call -CyaSSL_Debugging_ON() to turn logging on. - -On Unix use ./configure --enable-debug - -On Windows define DEBUG_CYASSL when building CyaSSL - - -To turn logging back off call CyaSSL_Debugging_OFF() - -See notes below (0.2.0) for complete build instructions. - - -# CyaSSL version 0.6.2 (10/29/2006) - -This release of CyaSSL adds TLS 1.1. - -Note that CyaSSL has certificate verification on by default, unlike OpenSSL. -To emulate OpenSSL behavior, you must call SSL_CTX_set_verify() with -SSL_VERIFY_NONE. In order to have full security you should never do this, -provide CyaSSL with the proper certificates to eliminate impostors and call -CyaSSL_check_domain_name() to prevent man in the middle attacks. - -See notes below (0.2.0) for build instructions. - -# CyaSSL version 0.6.0 (10/25/2006) - -This release of CyaSSL adds more SSL functions, better autoconf, nonblocking -I/O for accept, connect, and read. There is now an --enable-small configure -option that turns off TLS, AES, DES3, HMAC, and ERROR_STRINGS, see configure.in -for the defines. Note that TLS requires HMAC and AES requires TLS. - -See notes below (0.2.0) for build instructions. - - -# CyaSSL version 0.5.5 (09/27/2006) - -This mini release of CyaSSL adds better input processing through buffered input -and big message support. Added SSL_pending() and some sanity checks on user -settings. - -See notes below (0.2.0) for build instructions. - - -# CyaSSL version 0.5.0 (03/27/2006) - -This release of CyaSSL adds AES support and minor bug fixes. - -See notes below (0.2.0) for build instructions. - - -# CyaSSL version 0.4.0 (03/15/2006) - -This release of CyaSSL adds TLSv1 client/server support and libtool. - -See notes below for build instructions. - - -# CyaSSL version 0.3.0 (02/26/2006) - -This release of CyaSSL adds SSLv3 server support and session resumption. - -See notes below for build instructions. - - -# CyaSSL version 0.2.0 (02/19/2006) - - -This is the first release of CyaSSL and its crypt brother, CTaoCrypt. CyaSSL -is written in ANSI C with the idea of a small code size, footprint, and memory -usage in mind. CTaoCrypt can be as small as 32K, and the current client -version of CyaSSL can be as small as 12K. - - -The first release of CTaoCrypt supports MD5, SHA-1, 3DES, ARC4, Big Integer -Support, RSA, ASN parsing, and basic x509 (en/de)coding. - -The first release of CyaSSL supports normal client RSA mode SSLv3 connections -with support for SHA-1 and MD5 digests. Ciphers include 3DES and RC4. - - -#### To build on Linux, Solaris, *BSD, Mac OS X, or Cygwin: - - ./configure - make - - from the ./testsuite/ directory run ./testsuite - -#### to make a debug build: - - ./configure --enable-debug --disable-shared - make - - - -#### To build on Win32 - -Choose (Re)Build All from the project workspace - -Run the testsuite program - - - -*** The next release of CyaSSL will support a server and more OpenSSL -compatibility functions. - - -Please send questions or comments to todd@yassl.com diff --git a/FreeRTOS-Plus/Source/WolfSSL/ReadMeFirst.url b/FreeRTOS-Plus/Source/WolfSSL/ReadMeFirst.url deleted file mode 100755 index 3af02b6..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/ReadMeFirst.url +++ /dev/null @@ -1,5 +0,0 @@ -[InternetShortcut] -URL=http://www.freertos.org/ssl -IDList= -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 diff --git a/FreeRTOS-Plus/Source/WolfSSL/aclocal.m4 b/FreeRTOS-Plus/Source/WolfSSL/aclocal.m4 deleted file mode 100755 index 64fd2c6..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/aclocal.m4 +++ /dev/null @@ -1,1195 +0,0 @@ -# generated automatically by aclocal 1.14.1 -*- Autoconf -*- - -# Copyright (C) 1996-2013 Free Software Foundation, Inc. - -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, -[m4_warning([this file was generated for autoconf 2.69. -You have another version of autoconf. It may work, but is not guaranteed to. -If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically 'autoreconf'.])]) - -# Copyright (C) 2002-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_AUTOMAKE_VERSION(VERSION) -# ---------------------------- -# Automake X.Y traces this macro to ensure aclocal.m4 has been -# generated from the m4 files accompanying Automake X.Y. -# (This private macro should not be called outside this file.) -AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.14' -dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to -dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.14.1], [], - [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl -]) - -# _AM_AUTOCONF_VERSION(VERSION) -# ----------------------------- -# aclocal traces this macro to find the Autoconf version. -# This is a private macro too. Using m4_define simplifies -# the logic in aclocal, which can simply ignore this definition. -m4_define([_AM_AUTOCONF_VERSION], []) - -# AM_SET_CURRENT_AUTOMAKE_VERSION -# ------------------------------- -# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. -# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. -AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.14.1])dnl -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) - -# Figure out how to run the assembler. -*- Autoconf -*- - -# Copyright (C) 2001-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_AS -# ---------- -AC_DEFUN([AM_PROG_AS], -[# By default we simply use the C compiler to build assembly code. -AC_REQUIRE([AC_PROG_CC]) -test "${CCAS+set}" = set || CCAS=$CC -test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS -AC_ARG_VAR([CCAS], [assembler compiler command (defaults to CC)]) -AC_ARG_VAR([CCASFLAGS], [assembler compiler flags (defaults to CFLAGS)]) -_AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl -]) - -# AM_AUX_DIR_EXPAND -*- Autoconf -*- - -# Copyright (C) 2001-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to -# '$srcdir', '$srcdir/..', or '$srcdir/../..'. -# -# Of course, Automake must honor this variable whenever it calls a -# tool from the auxiliary directory. The problem is that $srcdir (and -# therefore $ac_aux_dir as well) can be either absolute or relative, -# depending on how configure is run. This is pretty annoying, since -# it makes $ac_aux_dir quite unusable in subdirectories: in the top -# source directory, any form will work fine, but in subdirectories a -# relative path needs to be adjusted first. -# -# $ac_aux_dir/missing -# fails when called from a subdirectory if $ac_aux_dir is relative -# $top_srcdir/$ac_aux_dir/missing -# fails if $ac_aux_dir is absolute, -# fails when called from a subdirectory in a VPATH build with -# a relative $ac_aux_dir -# -# The reason of the latter failure is that $top_srcdir and $ac_aux_dir -# are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is '.', but things will broke when you -# start a VPATH build or use an absolute $srcdir. -# -# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, -# iff we strip the leading $srcdir from $ac_aux_dir. That would be: -# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` -# and then we would define $MISSING as -# MISSING="\${SHELL} $am_aux_dir/missing" -# This will work as long as MISSING is not called from configure, because -# unfortunately $(top_srcdir) has no meaning in configure. -# However there are other variables, like CC, which are often used in -# configure, and could therefore not use this "fixed" $ac_aux_dir. -# -# Another solution, used here, is to always expand $ac_aux_dir to an -# absolute PATH. The drawback is that using absolute paths prevent a -# configured tree to be moved without reconfiguration. - -AC_DEFUN([AM_AUX_DIR_EXPAND], -[dnl Rely on autoconf to set up CDPATH properly. -AC_PREREQ([2.50])dnl -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` -]) - -# AM_CONDITIONAL -*- Autoconf -*- - -# Copyright (C) 1997-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ([2.52])dnl - m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE])dnl -AC_SUBST([$1_FALSE])dnl -_AM_SUBST_NOTMAKE([$1_TRUE])dnl -_AM_SUBST_NOTMAKE([$1_FALSE])dnl -m4_define([_AM_COND_VALUE_$1], [$2])dnl -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([[conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]]) -fi])]) - -# Copyright (C) 1999-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - - -# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be -# written in clear, in which case automake, when reading aclocal.m4, -# will think it sees a *use*, and therefore will trigger all it's -# C support machinery. Also note that it means that autoscan, seeing -# CC etc. in the Makefile, will ask for an AC_PROG_CC use... - - -# _AM_DEPENDENCIES(NAME) -# ---------------------- -# See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". -# We try a few techniques and use that to set a single cache variable. -# -# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was -# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular -# dependency, and given that the user is not expected to run this macro, -# just rely on AC_PROG_CC. -AC_DEFUN([_AM_DEPENDENCIES], -[AC_REQUIRE([AM_SET_DEPDIR])dnl -AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl -AC_REQUIRE([AM_MAKE_INCLUDE])dnl -AC_REQUIRE([AM_DEP_TRACK])dnl - -m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], - [$1], [CXX], [depcc="$CXX" am_compiler_list=], - [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], - [$1], [UPC], [depcc="$UPC" am_compiler_list=], - [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) - -AC_CACHE_CHECK([dependency style of $depcc], - [am_cv_$1_dependencies_compiler_type], -[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_$1_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` - fi - am__universal=false - m4_case([$1], [CC], - [case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac], - [CXX], - [case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac]) - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with '-c' and '-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_$1_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_$1_dependencies_compiler_type=none -fi -]) -AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) -AM_CONDITIONAL([am__fastdep$1], [ - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) -]) - - -# AM_SET_DEPDIR -# ------------- -# Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES. -AC_DEFUN([AM_SET_DEPDIR], -[AC_REQUIRE([AM_SET_LEADING_DOT])dnl -AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl -]) - - -# AM_DEP_TRACK -# ------------ -AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE([dependency-tracking], [dnl -AS_HELP_STRING( - [--enable-dependency-tracking], - [do not reject slow dependency extractors]) -AS_HELP_STRING( - [--disable-dependency-tracking], - [speeds up one-time build])]) -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' - am__nodep='_no' -fi -AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -AC_SUBST([AMDEPBACKSLASH])dnl -_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl -AC_SUBST([am__nodep])dnl -_AM_SUBST_NOTMAKE([am__nodep])dnl -]) - -# Generate code to set up dependency tracking. -*- Autoconf -*- - -# Copyright (C) 1999-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - - -# _AM_OUTPUT_DEPENDENCY_COMMANDS -# ------------------------------ -AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -[{ - # Older Autoconf quotes --file arguments for eval, but not when files - # are listed without --file. Let's play safe and only enable the eval - # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac - shift - for mf - do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named 'Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line - # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running 'make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "$am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`AS_DIRNAME(["$file"])` - AS_MKDIR_P([$dirpart/$fdir]) - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done - done -} -])# _AM_OUTPUT_DEPENDENCY_COMMANDS - - -# AM_OUTPUT_DEPENDENCY_COMMANDS -# ----------------------------- -# This macro should only be invoked once -- use via AC_REQUIRE. -# -# This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each '.P' file that we will -# need in order to bootstrap the dependency handling code. -AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], -[AC_CONFIG_COMMANDS([depfiles], - [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) -]) - -# Do all the work for Automake. -*- Autoconf -*- - -# Copyright (C) 1996-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This macro actually does too much. Some checks are only needed if -# your package does certain things. But this isn't really a big deal. - -dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. -m4_define([AC_PROG_CC], -m4_defn([AC_PROG_CC]) -[_AM_PROG_CC_C_O -]) - -# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) -# AM_INIT_AUTOMAKE([OPTIONS]) -# ----------------------------------------------- -# The call with PACKAGE and VERSION arguments is the old style -# call (pre autoconf-2.50), which is being phased out. PACKAGE -# and VERSION should now be passed to AC_INIT and removed from -# the call to AM_INIT_AUTOMAKE. -# We support both call styles for the transition. After -# the next Automake release, Autoconf can make the AC_INIT -# arguments mandatory, and then we can depend on a new Autoconf -# release and drop the old call support. -AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.65])dnl -dnl Autoconf wants to disallow AM_ names. We explicitly allow -dnl the ones we care about. -m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl -AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl -AC_REQUIRE([AC_PROG_INSTALL])dnl -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi -AC_SUBST([CYGPATH_W]) - -# Define the identity of the package. -dnl Distinguish between old-style and new-style calls. -m4_ifval([$2], -[AC_DIAGNOSE([obsolete], - [$0: two- and three-arguments forms are deprecated.]) -m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl - AC_SUBST([PACKAGE], [$1])dnl - AC_SUBST([VERSION], [$2])], -[_AM_SET_OPTIONS([$1])dnl -dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if( - m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), - [ok:ok],, - [m4_fatal([AC_INIT should be called with package and version arguments])])dnl - AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl - AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl - -_AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) - AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl - -# Some tools Automake needs. -AC_REQUIRE([AM_SANITY_CHECK])dnl -AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) -AM_MISSING_PROG([AUTOCONF], [autoconf]) -AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) -AM_MISSING_PROG([AUTOHEADER], [autoheader]) -AM_MISSING_PROG([MAKEINFO], [makeinfo]) -AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -AC_SUBST([mkdir_p], ['$(MKDIR_P)']) -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -AC_REQUIRE([AC_PROG_AWK])dnl -AC_REQUIRE([AC_PROG_MAKE_SET])dnl -AC_REQUIRE([AM_SET_LEADING_DOT])dnl -_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], - [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], - [_AM_PROG_TAR([v7])])]) -_AM_IF_OPTION([no-dependencies],, -[AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES([CC])], - [m4_define([AC_PROG_CC], - m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES([CXX])], - [m4_define([AC_PROG_CXX], - m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES([OBJC])], - [m4_define([AC_PROG_OBJC], - m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], - [_AM_DEPENDENCIES([OBJCXX])], - [m4_define([AC_PROG_OBJCXX], - m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl -]) -AC_REQUIRE([AM_SILENT_RULES])dnl -dnl The testsuite driver may need to know about EXEEXT, so add the -dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This -dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. -AC_CONFIG_COMMANDS_PRE(dnl -[m4_provide_if([_AM_COMPILER_EXEEXT], - [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl - -# POSIX will say in a future version that running "rm -f" with no argument -# is OK; and we want to be able to make that assumption in our Makefile -# recipes. So use an aggressive probe to check that the usage we want is -# actually supported "in the wild" to an acceptable degree. -# See automake bug#10828. -# To make any issue more visible, cause the running configure to be aborted -# by default if the 'rm' program in use doesn't match our expectations; the -# user can still override this though. -if rm -f && rm -fr && rm -rf; then : OK; else - cat >&2 <<'END' -Oops! - -Your 'rm' program seems unable to run without file operands specified -on the command line, even when the '-f' option is present. This is contrary -to the behaviour of most rm programs out there, and not conforming with -the upcoming POSIX standard: - -Please tell bug-automake@gnu.org about your system, including the value -of your $PATH and any error possibly output before this message. This -can help us improve future automake versions. - -END - if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then - echo 'Configuration will proceed anyway, since you have set the' >&2 - echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 - echo >&2 - else - cat >&2 <<'END' -Aborting the configuration process, to ensure you take notice of the issue. - -You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . - -If you want to complete the configuration process using your problematic -'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM -to "yes", and re-run configure. - -END - AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) - fi -fi]) - -dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not -dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further -dnl mangled by Autoconf and run in a shell conditional statement. -m4_define([_AC_COMPILER_EXEEXT], -m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) - -# When config.status generates a header, we must update the stamp-h file. -# This file resides in the same directory as the config header -# that is generated. The stamp files are numbered to have different names. - -# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the -# loop where config.status creates the headers, so we can generate -# our stamp files there. -AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], -[# Compute $1's index in $config_headers. -_am_arg=$1 -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $_am_arg | $_am_arg:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) - -# Copyright (C) 2001-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_SH -# ------------------ -# Define $install_sh. -AC_DEFUN([AM_PROG_INSTALL_SH], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; - *) - install_sh="\${SHELL} $am_aux_dir/install-sh" - esac -fi -AC_SUBST([install_sh])]) - -# Copyright (C) 2003-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# Check whether the underlying file-system supports filenames -# with a leading dot. For instance MS-DOS doesn't. -AC_DEFUN([AM_SET_LEADING_DOT], -[rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null -AC_SUBST([am__leading_dot])]) - -# Check to see how 'make' treats includes. -*- Autoconf -*- - -# Copyright (C) 2001-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_MAKE_INCLUDE() -# ----------------- -# Check to see how make treats includes. -AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo this is the am__doit target -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -AC_MSG_CHECKING([for style of include used by $am_make]) -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf -]) - -# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- - -# Copyright (C) 1997-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_MISSING_PROG(NAME, PROGRAM) -# ------------------------------ -AC_DEFUN([AM_MISSING_PROG], -[AC_REQUIRE([AM_MISSING_HAS_RUN]) -$1=${$1-"${am_missing_run}$2"} -AC_SUBST($1)]) - -# AM_MISSING_HAS_RUN -# ------------------ -# Define MISSING if not defined so far and test if it is modern enough. -# If it is, set am_missing_run to use it, otherwise, to nothing. -AC_DEFUN([AM_MISSING_HAS_RUN], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([missing])dnl -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac -fi -# Use eval to expand $SHELL -if eval "$MISSING --is-lightweight"; then - am_missing_run="$MISSING " -else - am_missing_run= - AC_MSG_WARN(['missing' script is too old or missing]) -fi -]) - -# Helper functions for option handling. -*- Autoconf -*- - -# Copyright (C) 2001-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_MANGLE_OPTION(NAME) -# ----------------------- -AC_DEFUN([_AM_MANGLE_OPTION], -[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) - -# _AM_SET_OPTION(NAME) -# -------------------- -# Set option NAME. Presently that only means defining a flag for this option. -AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) - -# _AM_SET_OPTIONS(OPTIONS) -# ------------------------ -# OPTIONS is a space-separated list of Automake options. -AC_DEFUN([_AM_SET_OPTIONS], -[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) - -# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) -# ------------------------------------------- -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -AC_DEFUN([_AM_IF_OPTION], -[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) - -# Copyright (C) 1999-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_PROG_CC_C_O -# --------------- -# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC -# to automatically call this. -AC_DEFUN([_AM_PROG_CC_C_O], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([compile])dnl -AC_LANG_PUSH([C])dnl -AC_CACHE_CHECK( - [whether $CC understands -c and -o together], - [am_cv_prog_cc_c_o], - [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) - # Make sure it works both with $CC and with simple cc. - # Following AC_PROG_CC_C_O, we do the test twice because some - # compilers refuse to overwrite an existing .o file with -o, - # though they will create one. - am_cv_prog_cc_c_o=yes - for am_i in 1 2; do - if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ - && test -f conftest2.$ac_objext; then - : OK - else - am_cv_prog_cc_c_o=no - break - fi - done - rm -f core conftest* - unset am_i]) -if test "$am_cv_prog_cc_c_o" != yes; then - # Losing compiler, so override with the script. - # FIXME: It is wrong to rewrite CC. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__CC in this case, - # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" - CC="$am_aux_dir/compile $CC" -fi -AC_LANG_POP([C])]) - -# For backward compatibility. -AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) - -# Copyright (C) 2001-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_RUN_LOG(COMMAND) -# ------------------- -# Run COMMAND, save the exit status in ac_status, and log it. -# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) -AC_DEFUN([AM_RUN_LOG], -[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD - ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - (exit $ac_status); }]) - -# Check to make sure that the build environment is sane. -*- Autoconf -*- - -# Copyright (C) 1996-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_SANITY_CHECK -# --------------- -AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) -# Reject unsafe characters in $srcdir or the absolute working directory -# name. Accept space and tab only in the latter. -am_lf=' -' -case `pwd` in - *[[\\\"\#\$\&\'\`$am_lf]]*) - AC_MSG_ERROR([unsafe absolute working directory name]);; -esac -case $srcdir in - *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; -esac - -# Do 'set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken - alias in your environment]) - fi - if test "$[2]" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done - test "$[2]" = conftest.file - ) -then - # Ok. - : -else - AC_MSG_ERROR([newly created file is older than distributed files! -Check your system clock]) -fi -AC_MSG_RESULT([yes]) -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! -fi -AC_CONFIG_COMMANDS_PRE( - [AC_MSG_CHECKING([that generated files are newer than configure]) - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - AC_MSG_RESULT([done])]) -rm -f conftest.file -]) - -# Copyright (C) 2009-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_SILENT_RULES([DEFAULT]) -# -------------------------- -# Enable less verbose build rules; with the default set to DEFAULT -# ("yes" being less verbose, "no" or empty being verbose). -AC_DEFUN([AM_SILENT_RULES], -[AC_ARG_ENABLE([silent-rules], [dnl -AS_HELP_STRING( - [--enable-silent-rules], - [less verbose build output (undo: "make V=1")]) -AS_HELP_STRING( - [--disable-silent-rules], - [verbose build output (undo: "make V=0")])dnl -]) -case $enable_silent_rules in @%:@ ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; -esac -dnl -dnl A few 'make' implementations (e.g., NonStop OS and NextStep) -dnl do not support nested variable expansions. -dnl See automake bug#9928 and bug#10237. -am_make=${MAKE-make} -AC_CACHE_CHECK([whether $am_make supports nested variables], - [am_cv_make_support_nested_variables], - [if AS_ECHO([['TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi]) -if test $am_cv_make_support_nested_variables = yes; then - dnl Using '$V' instead of '$(V)' breaks IRIX make. - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AC_SUBST([AM_V])dnl -AM_SUBST_NOTMAKE([AM_V])dnl -AC_SUBST([AM_DEFAULT_V])dnl -AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl -AC_SUBST([AM_DEFAULT_VERBOSITY])dnl -AM_BACKSLASH='\' -AC_SUBST([AM_BACKSLASH])dnl -_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl -]) - -# Copyright (C) 2001-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_STRIP -# --------------------- -# One issue with vendor 'install' (even GNU) is that you can't -# specify the program used to strip binaries. This is especially -# annoying in cross-compiling environments, where the build's strip -# is unlikely to handle the host's binaries. -# Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in "make install-strip", and initialize -# STRIPPROG with the value of the STRIP variable (set by the user). -AC_DEFUN([AM_PROG_INSTALL_STRIP], -[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using 'strip' when the user -# run "make install-strip". However 'strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the 'STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. -if test "$cross_compiling" != no; then - AC_CHECK_TOOL([STRIP], [strip], :) -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" -AC_SUBST([INSTALL_STRIP_PROGRAM])]) - -# Copyright (C) 2006-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- -# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. -# This macro is traced by Automake. -AC_DEFUN([_AM_SUBST_NOTMAKE]) - -# AM_SUBST_NOTMAKE(VARIABLE) -# -------------------------- -# Public sister of _AM_SUBST_NOTMAKE. -AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) - -# Check how to create a tarball. -*- Autoconf -*- - -# Copyright (C) 2004-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_PROG_TAR(FORMAT) -# -------------------- -# Check how to create a tarball in format FORMAT. -# FORMAT should be one of 'v7', 'ustar', or 'pax'. -# -# Substitute a variable $(am__tar) that is a command -# writing to stdout a FORMAT-tarball containing the directory -# $tardir. -# tardir=directory && $(am__tar) > result.tar -# -# Substitute a variable $(am__untar) that extract such -# a tarball read from stdin. -# $(am__untar) < result.tar -# -AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. Yes, it's still used -# in the wild :-( We should find a proper way to deprecate it ... -AC_SUBST([AMTAR], ['$${TAR-tar}']) - -# We'll loop over all known methods to create a tar archive until one works. -_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' - -m4_if([$1], [v7], - [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], - - [m4_case([$1], - [ustar], - [# The POSIX 1988 'ustar' format is defined with fixed-size fields. - # There is notably a 21 bits limit for the UID and the GID. In fact, - # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 - # and bug#13588). - am_max_uid=2097151 # 2^21 - 1 - am_max_gid=$am_max_uid - # The $UID and $GID variables are not portable, so we need to resort - # to the POSIX-mandated id(1) utility. Errors in the 'id' calls - # below are definitely unexpected, so allow the users to see them - # (that is, avoid stderr redirection). - am_uid=`id -u || echo unknown` - am_gid=`id -g || echo unknown` - AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) - if test $am_uid -le $am_max_uid; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - _am_tools=none - fi - AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) - if test $am_gid -le $am_max_gid; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - _am_tools=none - fi], - - [pax], - [], - - [m4_fatal([Unknown tar format])]) - - AC_MSG_CHECKING([how to create a $1 tar archive]) - - # Go ahead even if we have the value already cached. We do so because we - # need to set the values for the 'am__tar' and 'am__untar' variables. - _am_tools=${am_cv_prog_tar_$1-$_am_tools} - - for _am_tool in $_am_tools; do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break - - # tar/untar a dummy directory, and stop if the command works. - rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi - done - rm -rf conftest.dir - - AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) - AC_MSG_RESULT([$am_cv_prog_tar_$1])]) - -AC_SUBST([am__tar]) -AC_SUBST([am__untar]) -]) # _AM_PROG_TAR - -m4_include([m4/ax_add_am_macro.m4]) -m4_include([m4/ax_am_jobserver.m4]) -m4_include([m4/ax_am_macros.m4]) -m4_include([m4/ax_append_compile_flags.m4]) -m4_include([m4/ax_append_flag.m4]) -m4_include([m4/ax_append_to_file.m4]) -m4_include([m4/ax_check_compile_flag.m4]) -m4_include([m4/ax_check_link_flag.m4]) -m4_include([m4/ax_count_cpus.m4]) -m4_include([m4/ax_create_generic_config.m4]) -m4_include([m4/ax_debug.m4]) -m4_include([m4/ax_file_escapes.m4]) -m4_include([m4/ax_harden_compiler_flags.m4]) -m4_include([m4/ax_print_to_file.m4]) -m4_include([m4/ax_pthread.m4]) -m4_include([m4/ax_tls.m4]) -m4_include([m4/ax_vcs_checkout.m4]) -m4_include([m4/hexversion.m4]) -m4_include([m4/lib_socket_nsl.m4]) -m4_include([m4/libtool.m4]) -m4_include([m4/ltoptions.m4]) -m4_include([m4/ltsugar.m4]) -m4_include([m4/ltversion.m4]) -m4_include([m4/lt~obsolete.m4]) -m4_include([m4/visibility.m4]) -m4_include([m4/wolfssl_darwin_clang.m4]) diff --git a/FreeRTOS-Plus/Source/WolfSSL/build-aux/compile b/FreeRTOS-Plus/Source/WolfSSL/build-aux/compile deleted file mode 100755 index 531136b..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/build-aux/compile +++ /dev/null @@ -1,347 +0,0 @@ -#! /bin/sh -# Wrapper for compilers which do not understand '-c -o'. - -scriptversion=2012-10-14.11; # UTC - -# Copyright (C) 1999-2013 Free Software Foundation, Inc. -# Written by Tom Tromey . -# -# This program 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, or (at your option) -# any later version. -# -# This program 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, see . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -nl=' -' - -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent tools from complaining about whitespace usage. -IFS=" "" $nl" - -file_conv= - -# func_file_conv build_file lazy -# Convert a $build file to $host form and store it in $file -# Currently only supports Windows hosts. If the determined conversion -# type is listed in (the comma separated) LAZY, no conversion will -# take place. -func_file_conv () -{ - file=$1 - case $file in - / | /[!/]*) # absolute file, and not a UNC file - if test -z "$file_conv"; then - # lazily determine how to convert abs files - case `uname -s` in - MINGW*) - file_conv=mingw - ;; - CYGWIN*) - file_conv=cygwin - ;; - *) - file_conv=wine - ;; - esac - fi - case $file_conv/,$2, in - *,$file_conv,*) - ;; - mingw/*) - file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` - ;; - cygwin/*) - file=`cygpath -m "$file" || echo "$file"` - ;; - wine/*) - file=`winepath -w "$file" || echo "$file"` - ;; - esac - ;; - esac -} - -# func_cl_dashL linkdir -# Make cl look for libraries in LINKDIR -func_cl_dashL () -{ - func_file_conv "$1" - if test -z "$lib_path"; then - lib_path=$file - else - lib_path="$lib_path;$file" - fi - linker_opts="$linker_opts -LIBPATH:$file" -} - -# func_cl_dashl library -# Do a library search-path lookup for cl -func_cl_dashl () -{ - lib=$1 - found=no - save_IFS=$IFS - IFS=';' - for dir in $lib_path $LIB - do - IFS=$save_IFS - if $shared && test -f "$dir/$lib.dll.lib"; then - found=yes - lib=$dir/$lib.dll.lib - break - fi - if test -f "$dir/$lib.lib"; then - found=yes - lib=$dir/$lib.lib - break - fi - if test -f "$dir/lib$lib.a"; then - found=yes - lib=$dir/lib$lib.a - break - fi - done - IFS=$save_IFS - - if test "$found" != yes; then - lib=$lib.lib - fi -} - -# func_cl_wrapper cl arg... -# Adjust compile command to suit cl -func_cl_wrapper () -{ - # Assume a capable shell - lib_path= - shared=: - linker_opts= - for arg - do - if test -n "$eat"; then - eat= - else - case $1 in - -o) - # configure might choose to run compile as 'compile cc -o foo foo.c'. - eat=1 - case $2 in - *.o | *.[oO][bB][jJ]) - func_file_conv "$2" - set x "$@" -Fo"$file" - shift - ;; - *) - func_file_conv "$2" - set x "$@" -Fe"$file" - shift - ;; - esac - ;; - -I) - eat=1 - func_file_conv "$2" mingw - set x "$@" -I"$file" - shift - ;; - -I*) - func_file_conv "${1#-I}" mingw - set x "$@" -I"$file" - shift - ;; - -l) - eat=1 - func_cl_dashl "$2" - set x "$@" "$lib" - shift - ;; - -l*) - func_cl_dashl "${1#-l}" - set x "$@" "$lib" - shift - ;; - -L) - eat=1 - func_cl_dashL "$2" - ;; - -L*) - func_cl_dashL "${1#-L}" - ;; - -static) - shared=false - ;; - -Wl,*) - arg=${1#-Wl,} - save_ifs="$IFS"; IFS=',' - for flag in $arg; do - IFS="$save_ifs" - linker_opts="$linker_opts $flag" - done - IFS="$save_ifs" - ;; - -Xlinker) - eat=1 - linker_opts="$linker_opts $2" - ;; - -*) - set x "$@" "$1" - shift - ;; - *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) - func_file_conv "$1" - set x "$@" -Tp"$file" - shift - ;; - *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) - func_file_conv "$1" mingw - set x "$@" "$file" - shift - ;; - *) - set x "$@" "$1" - shift - ;; - esac - fi - shift - done - if test -n "$linker_opts"; then - linker_opts="-link$linker_opts" - fi - exec "$@" $linker_opts - exit 1 -} - -eat= - -case $1 in - '') - echo "$0: No command. Try '$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: compile [--help] [--version] PROGRAM [ARGS] - -Wrapper for compilers which do not understand '-c -o'. -Remove '-o dest.o' from ARGS, run PROGRAM with the remaining -arguments, and rename the output as expected. - -If you are trying to build a whole package this is not the -right script to run: please start by reading the file 'INSTALL'. - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "compile $scriptversion" - exit $? - ;; - cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) - func_cl_wrapper "$@" # Doesn't return... - ;; -esac - -ofile= -cfile= - -for arg -do - if test -n "$eat"; then - eat= - else - case $1 in - -o) - # configure might choose to run compile as 'compile cc -o foo foo.c'. - # So we strip '-o arg' only if arg is an object. - eat=1 - case $2 in - *.o | *.obj) - ofile=$2 - ;; - *) - set x "$@" -o "$2" - shift - ;; - esac - ;; - *.c) - cfile=$1 - set x "$@" "$1" - shift - ;; - *) - set x "$@" "$1" - shift - ;; - esac - fi - shift -done - -if test -z "$ofile" || test -z "$cfile"; then - # If no '-o' option was seen then we might have been invoked from a - # pattern rule where we don't need one. That is ok -- this is a - # normal compilation that the losing compiler can handle. If no - # '.c' file was seen then we are probably linking. That is also - # ok. - exec "$@" -fi - -# Name of file we expect compiler to create. -cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` - -# Create the lock directory. -# Note: use '[/\\:.-]' here to ensure that we don't use the same name -# that we are using for the .o file. Also, base the name on the expected -# object file name, since that is what matters with a parallel build. -lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d -while true; do - if mkdir "$lockdir" >/dev/null 2>&1; then - break - fi - sleep 1 -done -# FIXME: race condition here if user kills between mkdir and trap. -trap "rmdir '$lockdir'; exit 1" 1 2 15 - -# Run the compile. -"$@" -ret=$? - -if test -f "$cofile"; then - test "$cofile" = "$ofile" || mv "$cofile" "$ofile" -elif test -f "${cofile}bj"; then - test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" -fi - -rmdir "$lockdir" -exit $ret - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/FreeRTOS-Plus/Source/WolfSSL/build-aux/config.guess b/FreeRTOS-Plus/Source/WolfSSL/build-aux/config.guess deleted file mode 100755 index 9afd676..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/build-aux/config.guess +++ /dev/null @@ -1,1568 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright 1992-2013 Free Software Foundation, Inc. - -timestamp='2013-11-29' - -# This file 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 3 of the License, or -# (at your option) any later version. -# -# This program 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, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). -# -# Originally written by Per Bothner. -# -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD -# -# Please send patches with a ChangeLog entry to config-patches@gnu.org. - - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright 1992-2013 Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -case "${UNAME_SYSTEM}" in -Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu - - eval $set_cc_for_build - cat <<-EOF > $dummy.c - #include - #if defined(__UCLIBC__) - LIBC=uclibc - #elif defined(__dietlibc__) - LIBC=dietlibc - #else - LIBC=gnu - #endif - EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` - ;; -esac - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ELF__ - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit ;; - *:Bitrig:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; - i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" - # If there is a compiler, see if it is configured for 64-bit objects. - # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. - # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - SUN_ARCH="x86_64" - fi - fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[4567]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep -q __LP64__ - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in - amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - esac - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 - exit ;; - *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - i*:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - *:Interix*:*) - case ${UNAME_MACHINE} in - x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; - IA64) - echo ia64-unknown-interix${UNAME_RELEASE} - exit ;; - esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - aarch64_be:Linux:*:*) - UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arm*:Linux:*:*) - eval $set_cc_for_build - if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_EABI__ - then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - else - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_PCS_VFP - then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi - else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf - fi - fi - exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } - ;; - or1k:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - or32:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; - esac - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} - exit ;; - ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} - exit ;; - ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} - exit ;; - x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. - # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that - # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - NCR*:*:4.2:* | MPRAS*:*:4.2:*) - OS_REL='.3' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - x86_64:Haiku:*:*) - echo x86_64-unknown-haiku - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; - SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; - SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc - fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi - fi - elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 - fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; - NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; - i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; - x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx - exit ;; -esac - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/FreeRTOS-Plus/Source/WolfSSL/build-aux/config.sub b/FreeRTOS-Plus/Source/WolfSSL/build-aux/config.sub deleted file mode 100755 index 61cb4bc..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/build-aux/config.sub +++ /dev/null @@ -1,1793 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright 1992-2013 Free Software Foundation, Inc. - -timestamp='2013-10-01' - -# This file 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 3 of the License, or -# (at your option) any later version. -# -# This program 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, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). - - -# Please send patches with a ChangeLog entry to config-patches@gnu.org. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright 1992-2013 Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | epiphany \ - | fido | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 \ - | or1k | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none - ;; - xscaleeb) - basic_machine=armeb-unknown - ;; - - xscaleel) - basic_machine=armel-unknown - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pyramid-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux - ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -zvmoe) - os=-zvmoe - ;; - -dicos*) - os=-dicos - ;; - -nacl*) - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - score-*) - os=-elf - ;; - spu-*) - os=-elf - ;; - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - c8051-*) - os=-elf - ;; - hexagon-*) - os=-elf - ;; - tic54x-*) - os=-coff - ;; - tic55x-*) - os=-coff - ;; - tic6x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - ;; - m68*-cisco) - os=-aout - ;; - mep-*) - os=-elf - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or1k-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -cnk*|-aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/FreeRTOS-Plus/Source/WolfSSL/build-aux/depcomp b/FreeRTOS-Plus/Source/WolfSSL/build-aux/depcomp deleted file mode 100755 index 4ebd5b3..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/build-aux/depcomp +++ /dev/null @@ -1,791 +0,0 @@ -#! /bin/sh -# depcomp - compile a program generating dependencies as side-effects - -scriptversion=2013-05-30.07; # UTC - -# Copyright (C) 1999-2013 Free Software Foundation, Inc. - -# This program 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, or (at your option) -# any later version. - -# This program 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, see . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Alexandre Oliva . - -case $1 in - '') - echo "$0: No command. Try '$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: depcomp [--help] [--version] PROGRAM [ARGS] - -Run PROGRAMS ARGS to compile a file, generating dependencies -as side-effects. - -Environment variables: - depmode Dependency tracking mode. - source Source file read by 'PROGRAMS ARGS'. - object Object file output by 'PROGRAMS ARGS'. - DEPDIR directory where to store dependencies. - depfile Dependency file to output. - tmpdepfile Temporary file to use when outputting dependencies. - libtool Whether libtool is used (yes/no). - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "depcomp $scriptversion" - exit $? - ;; -esac - -# Get the directory component of the given path, and save it in the -# global variables '$dir'. Note that this directory component will -# be either empty or ending with a '/' character. This is deliberate. -set_dir_from () -{ - case $1 in - */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; - *) dir=;; - esac -} - -# Get the suffix-stripped basename of the given path, and save it the -# global variable '$base'. -set_base_from () -{ - base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` -} - -# If no dependency file was actually created by the compiler invocation, -# we still have to create a dummy depfile, to avoid errors with the -# Makefile "include basename.Plo" scheme. -make_dummy_depfile () -{ - echo "#dummy" > "$depfile" -} - -# Factor out some common post-processing of the generated depfile. -# Requires the auxiliary global variable '$tmpdepfile' to be set. -aix_post_process_depfile () -{ - # If the compiler actually managed to produce a dependency file, - # post-process it. - if test -f "$tmpdepfile"; then - # Each line is of the form 'foo.o: dependency.h'. - # Do two passes, one to just change these to - # $object: dependency.h - # and one to simply output - # dependency.h: - # which is needed to avoid the deleted-header problem. - { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" - sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" - } > "$depfile" - rm -f "$tmpdepfile" - else - make_dummy_depfile - fi -} - -# A tabulation character. -tab=' ' -# A newline character. -nl=' -' -# Character ranges might be problematic outside the C locale. -# These definitions help. -upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ -lower=abcdefghijklmnopqrstuvwxyz -digits=0123456789 -alpha=${upper}${lower} - -if test -z "$depmode" || test -z "$source" || test -z "$object"; then - echo "depcomp: Variables source, object and depmode must be set" 1>&2 - exit 1 -fi - -# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. -depfile=${depfile-`echo "$object" | - sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Avoid interferences from the environment. -gccflag= dashmflag= - -# Some modes work just like other modes, but use different flags. We -# parameterize here, but still list the modes in the big case below, -# to make depend.m4 easier to write. Note that we *cannot* use a case -# here, because this file can only contain one case statement. -if test "$depmode" = hp; then - # HP compiler uses -M and no extra arg. - gccflag=-M - depmode=gcc -fi - -if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout -fi - -cygpath_u="cygpath -u -f -" -if test "$depmode" = msvcmsys; then - # This is just like msvisualcpp but w/o cygpath translation. - # Just convert the backslash-escaped backslashes to single forward - # slashes to satisfy depend.m4 - cygpath_u='sed s,\\\\,/,g' - depmode=msvisualcpp -fi - -if test "$depmode" = msvc7msys; then - # This is just like msvc7 but w/o cygpath translation. - # Just convert the backslash-escaped backslashes to single forward - # slashes to satisfy depend.m4 - cygpath_u='sed s,\\\\,/,g' - depmode=msvc7 -fi - -if test "$depmode" = xlc; then - # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. - gccflag=-qmakedep=gcc,-MF - depmode=gcc -fi - -case "$depmode" in -gcc3) -## gcc 3 implements dependency tracking that does exactly what -## we want. Yay! Note: for some reason libtool 1.4 doesn't like -## it if -MD -MP comes after the -MF stuff. Hmm. -## Unfortunately, FreeBSD c89 acceptance of flags depends upon -## the command line argument order; so add the flags where they -## appear in depend2.am. Note that the slowdown incurred here -## affects only configure: in makefiles, %FASTDEP% shortcuts this. - for arg - do - case $arg in - -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; - *) set fnord "$@" "$arg" ;; - esac - shift # fnord - shift # $arg - done - "$@" - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. -## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. -## (see the conditional assignment to $gccflag above). -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). Also, it might not be -## supported by the other compilers which use the 'gcc' depmode. -## - Using -M directly means running the compiler twice (even worse -## than renaming). - if test -z "$gccflag"; then - gccflag=-MD, - fi - "$@" -Wp,"$gccflag$tmpdepfile" - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - # The second -e expression handles DOS-style file names with drive - # letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the "deleted header file" problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. -## Some versions of gcc put a space before the ':'. On the theory -## that the space means something, we add a space to the output as -## well. hp depmode also adds that space, but also prefixes the VPATH -## to the object. Take care to not repeat it in the output. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ - | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like '#:fec' to the end of the - # dependency line. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ - | tr "$nl" ' ' >> "$depfile" - echo >> "$depfile" - # The second pass generates a dummy entry for each header file. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> "$depfile" - else - make_dummy_depfile - fi - rm -f "$tmpdepfile" - ;; - -xlc) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. In older versions, this file always lives in the - # current directory. Also, the AIX compiler puts '$object:' at the - # start of each line; $object doesn't have directory information. - # Version 6 uses the directory in both cases. - set_dir_from "$object" - set_base_from "$object" - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.u - tmpdepfile2=$base.u - tmpdepfile3=$dir.libs/$base.u - "$@" -Wc,-M - else - tmpdepfile1=$dir$base.u - tmpdepfile2=$dir$base.u - tmpdepfile3=$dir$base.u - "$@" -M - fi - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - do - test -f "$tmpdepfile" && break - done - aix_post_process_depfile - ;; - -tcc) - # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 - # FIXME: That version still under development at the moment of writing. - # Make that this statement remains true also for stable, released - # versions. - # It will wrap lines (doesn't matter whether long or short) with a - # trailing '\', as in: - # - # foo.o : \ - # foo.c \ - # foo.h \ - # - # It will put a trailing '\' even on the last line, and will use leading - # spaces rather than leading tabs (at least since its commit 0394caf7 - # "Emit spaces for -MD"). - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. - # We have to change lines of the first kind to '$object: \'. - sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" - # And for each line of the second kind, we have to emit a 'dep.h:' - # dummy dependency, to avoid the deleted-header problem. - sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" - rm -f "$tmpdepfile" - ;; - -## The order of this option in the case statement is important, since the -## shell code in configure will try each of these formats in the order -## listed in this file. A plain '-MD' option would be understood by many -## compilers, so we must ensure this comes after the gcc and icc options. -pgcc) - # Portland's C compiler understands '-MD'. - # Will always output deps to 'file.d' where file is the root name of the - # source file under compilation, even if file resides in a subdirectory. - # The object file name does not affect the name of the '.d' file. - # pgcc 10.2 will output - # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using '\' : - # foo.o: sub/foo.c ... \ - # sub/foo.h ... \ - # ... - set_dir_from "$object" - # Use the source, not the object, to determine the base name, since - # that's sadly what pgcc will do too. - set_base_from "$source" - tmpdepfile=$base.d - - # For projects that build the same source file twice into different object - # files, the pgcc approach of using the *source* file root name can cause - # problems in parallel builds. Use a locking strategy to avoid stomping on - # the same $tmpdepfile. - lockdir=$base.d-lock - trap " - echo '$0: caught signal, cleaning up...' >&2 - rmdir '$lockdir' - exit 1 - " 1 2 13 15 - numtries=100 - i=$numtries - while test $i -gt 0; do - # mkdir is a portable test-and-set. - if mkdir "$lockdir" 2>/dev/null; then - # This process acquired the lock. - "$@" -MD - stat=$? - # Release the lock. - rmdir "$lockdir" - break - else - # If the lock is being held by a different process, wait - # until the winning process is done or we timeout. - while test -d "$lockdir" && test $i -gt 0; do - sleep 1 - i=`expr $i - 1` - done - fi - i=`expr $i - 1` - done - trap - 1 2 13 15 - if test $i -le 0; then - echo "$0: failed to acquire lock after $numtries attempts" >&2 - echo "$0: check lockdir '$lockdir'" >&2 - exit 1 - fi - - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each line is of the form `foo.o: dependent.h', - # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process this invocation - # correctly. Breaking it into two sed invocations is a workaround. - sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ - | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp2) - # The "hp" stanza above does not work with aCC (C++) and HP's ia64 - # compilers, which have integrated preprocessors. The correct option - # to use with these is +Maked; it writes dependencies to a file named - # 'foo.d', which lands next to the object file, wherever that - # happens to be. - # Much of this is similar to the tru64 case; see comments there. - set_dir_from "$object" - set_base_from "$object" - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir.libs/$base.d - "$@" -Wc,+Maked - else - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir$base.d - "$@" +Maked - fi - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile1" "$tmpdepfile2" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" - # Add 'dependent.h:' lines. - sed -ne '2,${ - s/^ *// - s/ \\*$// - s/$/:/ - p - }' "$tmpdepfile" >> "$depfile" - else - make_dummy_depfile - fi - rm -f "$tmpdepfile" "$tmpdepfile2" - ;; - -tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in 'foo.d' instead, so we check for that too. - # Subdirectories are respected. - set_dir_from "$object" - set_base_from "$object" - - if test "$libtool" = yes; then - # Libtool generates 2 separate objects for the 2 libraries. These - # two compilations output dependencies in $dir.libs/$base.o.d and - # in $dir$base.o.d. We have to check for both files, because - # one of the two compilations can be disabled. We should prefer - # $dir$base.o.d over $dir.libs/$base.o.d because the latter is - # automatically cleaned when .libs/ is deleted, while ignoring - # the former would cause a distcleancheck panic. - tmpdepfile1=$dir$base.o.d # libtool 1.5 - tmpdepfile2=$dir.libs/$base.o.d # Likewise. - tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 - "$@" -Wc,-MD - else - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir$base.d - tmpdepfile3=$dir$base.d - "$@" -MD - fi - - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - do - test -f "$tmpdepfile" && break - done - # Same post-processing that is required for AIX mode. - aix_post_process_depfile - ;; - -msvc7) - if test "$libtool" = yes; then - showIncludes=-Wc,-showIncludes - else - showIncludes=-showIncludes - fi - "$@" $showIncludes > "$tmpdepfile" - stat=$? - grep -v '^Note: including file: ' "$tmpdepfile" - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - # The first sed program below extracts the file names and escapes - # backslashes for cygpath. The second sed program outputs the file - # name when reading, but also accumulates all include files in the - # hold buffer in order to output them again at the end. This only - # works with sed implementations that can handle large buffers. - sed < "$tmpdepfile" -n ' -/^Note: including file: *\(.*\)/ { - s//\1/ - s/\\/\\\\/g - p -}' | $cygpath_u | sort -u | sed -n ' -s/ /\\ /g -s/\(.*\)/'"$tab"'\1 \\/p -s/.\(.*\) \\/\1:/ -H -$ { - s/.*/'"$tab"'/ - G - p -}' >> "$depfile" - echo >> "$depfile" # make sure the fragment doesn't end with a backslash - rm -f "$tmpdepfile" - ;; - -msvc7msys) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - # Remove '-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for ':' - # in the target name. This is to cope with DOS-style filenames: - # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. - "$@" $dashmflag | - sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process this sed invocation - # correctly. Breaking it into two sed invocations is a workaround. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ - | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - "$@" || exit $? - # Remove any Libtool call - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - # X makedepend - shift - cleared=no eat=no - for arg - do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - if test $eat = yes; then - eat=no - continue - fi - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift ;; - # Strip any option that makedepend may not understand. Remove - # the object too, otherwise makedepend will parse it as a source file. - -arch) - eat=yes ;; - -*|$object) - ;; - *) - set fnord "$@" "$arg"; shift ;; - esac - done - obj_suffix=`echo "$object" | sed 's/^.*\././'` - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" - rm -f "$depfile" - # makedepend may prepend the VPATH from the source file name to the object. - # No need to regex-escape $object, excess matching of '.' is harmless. - sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process the last invocation - # correctly. Breaking it into two sed invocations is a workaround. - sed '1,2d' "$tmpdepfile" \ - | tr ' ' "$nl" \ - | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ - | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - # Remove '-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - "$@" -E \ - | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - | sed '$ s: \\$::' > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - IFS=" " - for arg - do - case "$arg" in - -o) - shift - ;; - $object) - shift - ;; - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E 2>/dev/null | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" - echo "$tab" >> "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvcmsys) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/FreeRTOS-Plus/Source/WolfSSL/build-aux/install-sh b/FreeRTOS-Plus/Source/WolfSSL/build-aux/install-sh deleted file mode 100755 index 377bb86..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/build-aux/install-sh +++ /dev/null @@ -1,527 +0,0 @@ -#!/bin/sh -# install - install a program, script, or datafile - -scriptversion=2011-11-20.07; # UTC - -# This originates from X11R5 (mit/util/scripts/install.sh), which was -# later released in X11R6 (xc/config/util/install.sh) with the -# following copyright and license. -# -# Copyright (C) 1994 X Consortium -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- -# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# Except as contained in this notice, the name of the X Consortium shall not -# be used in advertising or otherwise to promote the sale, use or other deal- -# ings in this Software without prior written authorization from the X Consor- -# tium. -# -# -# FSF changes to this file are in the public domain. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# 'make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. - -nl=' -' -IFS=" "" $nl" - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi - -# Put in absolute file names if you don't have them in your path; -# or use environment vars. - -chgrpprog=${CHGRPPROG-chgrp} -chmodprog=${CHMODPROG-chmod} -chownprog=${CHOWNPROG-chown} -cmpprog=${CMPPROG-cmp} -cpprog=${CPPROG-cp} -mkdirprog=${MKDIRPROG-mkdir} -mvprog=${MVPROG-mv} -rmprog=${RMPROG-rm} -stripprog=${STRIPPROG-strip} - -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - -posix_mkdir= - -# Desired mode of installed file. -mode=0755 - -chgrpcmd= -chmodcmd=$chmodprog -chowncmd= -mvcmd=$mvprog -rmcmd="$rmprog -f" -stripcmd= - -src= -dst= -dir_arg= -dst_arg= - -copy_on_change=false -no_target_directory= - -usage="\ -Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE - or: $0 [OPTION]... SRCFILES... DIRECTORY - or: $0 [OPTION]... -t DIRECTORY SRCFILES... - or: $0 [OPTION]... -d DIRECTORIES... - -In the 1st form, copy SRCFILE to DSTFILE. -In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. -In the 4th, create DIRECTORIES. - -Options: - --help display this help and exit. - --version display version info and exit. - - -c (ignored) - -C install only if different (preserve the last data modification time) - -d create directories instead of installing files. - -g GROUP $chgrpprog installed files to GROUP. - -m MODE $chmodprog installed files to MODE. - -o USER $chownprog installed files to USER. - -s $stripprog installed files. - -t DIRECTORY install into DIRECTORY. - -T report an error if DSTFILE is a directory. - -Environment variables override the default commands: - CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG - RMPROG STRIPPROG -" - -while test $# -ne 0; do - case $1 in - -c) ;; - - -C) copy_on_change=true;; - - -d) dir_arg=true;; - - -g) chgrpcmd="$chgrpprog $2" - shift;; - - --help) echo "$usage"; exit $?;; - - -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; - - -o) chowncmd="$chownprog $2" - shift;; - - -s) stripcmd=$stripprog;; - - -t) dst_arg=$2 - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - shift;; - - -T) no_target_directory=true;; - - --version) echo "$0 $scriptversion"; exit $?;; - - --) shift - break;; - - -*) echo "$0: invalid option: $1" >&2 - exit 1;; - - *) break;; - esac - shift -done - -if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then - # When -d is used, all remaining arguments are directories to create. - # When -t is used, the destination is already specified. - # Otherwise, the last argument is the destination. Remove it from $@. - for arg - do - if test -n "$dst_arg"; then - # $@ is not empty: it contains at least $arg. - set fnord "$@" "$dst_arg" - shift # fnord - fi - shift # arg - dst_arg=$arg - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - done -fi - -if test $# -eq 0; then - if test -z "$dir_arg"; then - echo "$0: no input file specified." >&2 - exit 1 - fi - # It's OK to call 'install-sh -d' without argument. - # This can happen when creating conditional directories. - exit 0 -fi - -if test -z "$dir_arg"; then - do_exit='(exit $ret); exit $ret' - trap "ret=129; $do_exit" 1 - trap "ret=130; $do_exit" 2 - trap "ret=141; $do_exit" 13 - trap "ret=143; $do_exit" 15 - - # Set umask so as not to create temps with too-generous modes. - # However, 'strip' requires both read and write access to temps. - case $mode in - # Optimize common cases. - *644) cp_umask=133;; - *755) cp_umask=22;; - - *[0-7]) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw='% 200' - fi - cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; - *) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw=,u+rw - fi - cp_umask=$mode$u_plus_rw;; - esac -fi - -for src -do - # Protect names problematic for 'test' and other utilities. - case $src in - -* | [=\(\)!]) src=./$src;; - esac - - if test -n "$dir_arg"; then - dst=$src - dstdir=$dst - test -d "$dstdir" - dstdir_status=$? - else - - # Waiting for this to be detected by the "$cpprog $src $dsttmp" command - # might cause directories to be created, which would be especially bad - # if $src (and thus $dsttmp) contains '*'. - if test ! -f "$src" && test ! -d "$src"; then - echo "$0: $src does not exist." >&2 - exit 1 - fi - - if test -z "$dst_arg"; then - echo "$0: no destination specified." >&2 - exit 1 - fi - dst=$dst_arg - - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. - if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 - fi - dstdir=$dst - dst=$dstdir/`basename "$src"` - dstdir_status=0 - else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - - test -d "$dstdir" - dstdir_status=$? - fi - fi - - obsolete_mkdir_used=false - - if test $dstdir_status != 0; then - case $posix_mkdir in - '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; - esac - - if - $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" - ) - then : - else - - # The umask is ridiculous, or mkdir does not conform to POSIX, - # or it failed possibly due to a race condition. Create the - # directory the slow way, step by step, checking for races as we go. - - case $dstdir in - /*) prefix='/';; - [-=\(\)!]*) prefix='./';; - *) prefix='';; - esac - - eval "$initialize_posix_glob" - - oIFS=$IFS - IFS=/ - $posix_glob set -f - set fnord $dstdir - shift - $posix_glob set +f - IFS=$oIFS - - prefixes= - - for d - do - test X"$d" = X && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ - done - - if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true - fi - fi - fi - - if test -n "$dir_arg"; then - { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && - { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || - test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 - else - - # Make a couple of temp file names in the proper directory. - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ - - # Trap to clean up those temp files at exit. - trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 - - # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && - - # and set any options; do chmod last to preserve setuid bits. - # - # If any of these fail, we abort the whole thing. If we want to - # ignore errors from any of these, just make sure not to ignore - # errors from the above "$doit $cpprog $src $dsttmp" command. - # - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && - { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && - { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && - - # If -C, don't bother to copy if it wouldn't change the file. - if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - - eval "$initialize_posix_glob" && - $posix_glob set -f && - set X $old && old=:$2:$4:$5:$6 && - set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && - - test "$old" = "$new" && - $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 - then - rm -f "$dsttmp" - else - # Rename the file to the real destination. - $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || - - # The rename failed, perhaps because mv can't rename something else - # to itself, or perhaps because mv is so ancient that it does not - # support -f. - { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" - } - fi || exit 1 - - trap '' 0 - fi -done - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/FreeRTOS-Plus/Source/WolfSSL/build-aux/ltmain.sh b/FreeRTOS-Plus/Source/WolfSSL/build-aux/ltmain.sh deleted file mode 100755 index 9ae038c..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/build-aux/ltmain.sh +++ /dev/null @@ -1,9656 +0,0 @@ - -# libtool (GNU libtool) 2.4.2 -# Written by Gordon Matzigkeit , 1996 - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, -# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. -# This is free software; see the source for copying conditions. There is NO -# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -# GNU Libtool 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. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, -# or obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# Usage: $progname [OPTION]... [MODE-ARG]... -# -# Provide generalized library-building support services. -# -# --config show all configuration variables -# --debug enable verbose shell tracing -# -n, --dry-run display commands without modifying any files -# --features display basic configuration information and exit -# --mode=MODE use operation mode MODE -# --preserve-dup-deps don't remove duplicate dependency libraries -# --quiet, --silent don't print informational messages -# --no-quiet, --no-silent -# print informational messages (default) -# --no-warn don't display warning messages -# --tag=TAG use configuration variables from tag TAG -# -v, --verbose print more informational messages than default -# --no-verbose don't print the extra informational messages -# --version print version information -# -h, --help, --help-all print short, long, or detailed help message -# -# MODE must be one of the following: -# -# clean remove files from the build directory -# compile compile a source file into a libtool object -# execute automatically set library path, then run a program -# finish complete the installation of libtool libraries -# install install libraries or executables -# link create a library or an executable -# uninstall remove libraries from an installed directory -# -# MODE-ARGS vary depending on the MODE. When passed as first option, -# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. -# Try `$progname --help --mode=MODE' for a more detailed description of MODE. -# -# When reporting a bug, please describe a test case to reproduce it and -# include the following information: -# -# host-triplet: $host -# shell: $SHELL -# compiler: $LTCC -# compiler flags: $LTCFLAGS -# linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.4.2 -# automake: $automake_version -# autoconf: $autoconf_version -# -# Report bugs to . -# GNU libtool home page: . -# General help using GNU software: . - -PROGRAM=libtool -PACKAGE=libtool -VERSION=2.4.2 -TIMESTAMP="" -package_revision=1.3337 - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -$1 -_LTECHO_EOF' -} - -# NLS nuisances: We save the old values to restore during execute mode. -lt_user_locale= -lt_safe_locale= -for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES -do - eval "if test \"\${$lt_var+set}\" = set; then - save_$lt_var=\$$lt_var - $lt_var=C - export $lt_var - lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" - lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" - fi" -done -LC_ALL=C -LANGUAGE=C -export LANGUAGE LC_ALL - -$lt_unset CDPATH - - -# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh -# is ksh but when the shell is invoked as "sh" and the current value of -# the _XPG environment variable is not equal to 1 (one), the special -# positional parameter $0, within a function call, is the name of the -# function. -progpath="$0" - - - -: ${CP="cp -f"} -test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} -: ${MAKE="make"} -: ${MKDIR="mkdir"} -: ${MV="mv -f"} -: ${RM="rm -f"} -: ${SHELL="${CONFIG_SHELL-/bin/sh}"} -: ${Xsed="$SED -e 1s/^X//"} - -# Global variables: -EXIT_SUCCESS=0 -EXIT_FAILURE=1 -EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. -EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. - -exit_status=$EXIT_SUCCESS - -# Make sure IFS has a sensible default -lt_nl=' -' -IFS=" $lt_nl" - -dirname="s,/[^/]*$,," -basename="s,^.*/,," - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} # func_dirname may be replaced by extended shell implementation - - -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "${1}" | $SED "$basename"` -} # func_basename may be replaced by extended shell implementation - - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi - func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` -} # func_dirname_and_basename may be replaced by extended shell implementation - - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; - esac -} # func_stripname may be replaced by extended shell implementation - - -# These SED scripts presuppose an absolute path with a trailing slash. -pathcar='s,^/\([^/]*\).*$,\1,' -pathcdr='s,^/[^/]*,,' -removedotparts=':dotsl - s@/\./@/@g - t dotsl - s,/\.$,/,' -collapseslashes='s@/\{1,\}@/@g' -finalslash='s,/*$,/,' - -# func_normal_abspath PATH -# Remove doubled-up and trailing slashes, "." path components, -# and cancel out any ".." path components in PATH after making -# it an absolute path. -# value returned in "$func_normal_abspath_result" -func_normal_abspath () -{ - # Start from root dir and reassemble the path. - func_normal_abspath_result= - func_normal_abspath_tpath=$1 - func_normal_abspath_altnamespace= - case $func_normal_abspath_tpath in - "") - # Empty path, that just means $cwd. - func_stripname '' '/' "`pwd`" - func_normal_abspath_result=$func_stripname_result - return - ;; - # The next three entries are used to spot a run of precisely - # two leading slashes without using negated character classes; - # we take advantage of case's first-match behaviour. - ///*) - # Unusual form of absolute path, do nothing. - ;; - //*) - # Not necessarily an ordinary path; POSIX reserves leading '//' - # and for example Cygwin uses it to access remote file shares - # over CIFS/SMB, so we conserve a leading double slash if found. - func_normal_abspath_altnamespace=/ - ;; - /*) - # Absolute path, do nothing. - ;; - *) - # Relative path, prepend $cwd. - func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath - ;; - esac - # Cancel out all the simple stuff to save iterations. We also want - # the path to end with a slash for ease of parsing, so make sure - # there is one (and only one) here. - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` - while :; do - # Processed it all yet? - if test "$func_normal_abspath_tpath" = / ; then - # If we ascended to the root using ".." the result may be empty now. - if test -z "$func_normal_abspath_result" ; then - func_normal_abspath_result=/ - fi - break - fi - func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcar"` - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcdr"` - # Figure out what to do with it - case $func_normal_abspath_tcomponent in - "") - # Trailing empty path component, ignore it. - ;; - ..) - # Parent dir; strip last assembled component from result. - func_dirname "$func_normal_abspath_result" - func_normal_abspath_result=$func_dirname_result - ;; - *) - # Actual path component, append it. - func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent - ;; - esac - done - # Restore leading double-slash if one was found on entry. - func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result -} - -# func_relative_path SRCDIR DSTDIR -# generates a relative path from SRCDIR to DSTDIR, with a trailing -# slash if non-empty, suitable for immediately appending a filename -# without needing to append a separator. -# value returned in "$func_relative_path_result" -func_relative_path () -{ - func_relative_path_result= - func_normal_abspath "$1" - func_relative_path_tlibdir=$func_normal_abspath_result - func_normal_abspath "$2" - func_relative_path_tbindir=$func_normal_abspath_result - - # Ascend the tree starting from libdir - while :; do - # check if we have found a prefix of bindir - case $func_relative_path_tbindir in - $func_relative_path_tlibdir) - # found an exact match - func_relative_path_tcancelled= - break - ;; - $func_relative_path_tlibdir*) - # found a matching prefix - func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" - func_relative_path_tcancelled=$func_stripname_result - if test -z "$func_relative_path_result"; then - func_relative_path_result=. - fi - break - ;; - *) - func_dirname $func_relative_path_tlibdir - func_relative_path_tlibdir=${func_dirname_result} - if test "x$func_relative_path_tlibdir" = x ; then - # Have to descend all the way to the root! - func_relative_path_result=../$func_relative_path_result - func_relative_path_tcancelled=$func_relative_path_tbindir - break - fi - func_relative_path_result=../$func_relative_path_result - ;; - esac - done - - # Now calculate path; take care to avoid doubling-up slashes. - func_stripname '' '/' "$func_relative_path_result" - func_relative_path_result=$func_stripname_result - func_stripname '/' '/' "$func_relative_path_tcancelled" - if test "x$func_stripname_result" != x ; then - func_relative_path_result=${func_relative_path_result}/${func_stripname_result} - fi - - # Normalisation. If bindir is libdir, return empty string, - # else relative path ending with a slash; either way, target - # file name can be directly appended. - if test ! -z "$func_relative_path_result"; then - func_stripname './' '' "$func_relative_path_result/" - func_relative_path_result=$func_stripname_result - fi -} - -# The name of this program: -func_dirname_and_basename "$progpath" -progname=$func_basename_result - -# Make sure we have an absolute path for reexecution: -case $progpath in - [\\/]*|[A-Za-z]:\\*) ;; - *[\\/]*) - progdir=$func_dirname_result - progdir=`cd "$progdir" && pwd` - progpath="$progdir/$progname" - ;; - *) - save_IFS="$IFS" - IFS=${PATH_SEPARATOR-:} - for progdir in $PATH; do - IFS="$save_IFS" - test -x "$progdir/$progname" && break - done - IFS="$save_IFS" - test -n "$progdir" || progdir=`pwd` - progpath="$progdir/$progname" - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed="${SED}"' -e 1s/^X//' -sed_quote_subst='s/\([`"$\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\(["`\\]\)/\\\1/g' - -# Sed substitution that turns a string into a regex matching for the -# string literally. -sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' - -# Sed substitution that converts a w32 file name or path -# which contains forward slashes, into one that contains -# (escaped) backslashes. A very naive implementation. -lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' - -# Re-`\' parameter expansions in output of double_quote_subst that were -# `\'-ed in input to the same. If an odd number of `\' preceded a '$' -# in input to double_quote_subst, that '$' was protected from expansion. -# Since each input `\' is now two `\'s, look for any number of runs of -# four `\'s followed by two `\'s and then a '$'. `\' that '$'. -bs='\\' -bs2='\\\\' -bs4='\\\\\\\\' -dollar='\$' -sed_double_backslash="\ - s/$bs4/&\\ -/g - s/^$bs2$dollar/$bs&/ - s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g - s/\n//g" - -# Standard options: -opt_dry_run=false -opt_help=false -opt_quiet=false -opt_verbose=false -opt_warning=: - -# func_echo arg... -# Echo program name prefixed message, along with the current mode -# name if it has been set yet. -func_echo () -{ - $ECHO "$progname: ${opt_mode+$opt_mode: }$*" -} - -# func_verbose arg... -# Echo program name prefixed message in verbose mode only. -func_verbose () -{ - $opt_verbose && func_echo ${1+"$@"} - - # A bug in bash halts the script if the last line of a function - # fails when set -e is in force, so we need another command to - # work around that: - : -} - -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "$*" -} - -# func_error arg... -# Echo program name prefixed message to standard error. -func_error () -{ - $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 -} - -# func_warning arg... -# Echo program name prefixed warning message to standard error. -func_warning () -{ - $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 - - # bash bug again: - : -} - -# func_fatal_error arg... -# Echo program name prefixed message to standard error, and exit. -func_fatal_error () -{ - func_error ${1+"$@"} - exit $EXIT_FAILURE -} - -# func_fatal_help arg... -# Echo program name prefixed message to standard error, followed by -# a help hint, and exit. -func_fatal_help () -{ - func_error ${1+"$@"} - func_fatal_error "$help" -} -help="Try \`$progname --help' for more information." ## default - - -# func_grep expression filename -# Check whether EXPRESSION matches any line of FILENAME, without output. -func_grep () -{ - $GREP "$1" "$2" >/dev/null 2>&1 -} - - -# func_mkdir_p directory-path -# Make sure the entire path to DIRECTORY-PATH is available. -func_mkdir_p () -{ - my_directory_path="$1" - my_dir_list= - - if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then - - # Protect directory names starting with `-' - case $my_directory_path in - -*) my_directory_path="./$my_directory_path" ;; - esac - - # While some portion of DIR does not yet exist... - while test ! -d "$my_directory_path"; do - # ...make a list in topmost first order. Use a colon delimited - # list incase some portion of path contains whitespace. - my_dir_list="$my_directory_path:$my_dir_list" - - # If the last portion added has no slash in it, the list is done - case $my_directory_path in */*) ;; *) break ;; esac - - # ...otherwise throw away the child directory and loop - my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` - done - my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` - - save_mkdir_p_IFS="$IFS"; IFS=':' - for my_dir in $my_dir_list; do - IFS="$save_mkdir_p_IFS" - # mkdir can fail with a `File exist' error if two processes - # try to create one of the directories concurrently. Don't - # stop in that case! - $MKDIR "$my_dir" 2>/dev/null || : - done - IFS="$save_mkdir_p_IFS" - - # Bail out if we (or some other process) failed to create a directory. - test -d "$my_directory_path" || \ - func_fatal_error "Failed to create \`$1'" - fi -} - - -# func_mktempdir [string] -# Make a temporary directory that won't clash with other running -# libtool processes, and avoids race conditions if possible. If -# given, STRING is the basename for that directory. -func_mktempdir () -{ - my_template="${TMPDIR-/tmp}/${1-$progname}" - - if test "$opt_dry_run" = ":"; then - # Return a directory name, but don't create it in dry-run mode - my_tmpdir="${my_template}-$$" - else - - # If mktemp works, use that first and foremost - my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` - - if test ! -d "$my_tmpdir"; then - # Failing that, at least try and use $RANDOM to avoid a race - my_tmpdir="${my_template}-${RANDOM-0}$$" - - save_mktempdir_umask=`umask` - umask 0077 - $MKDIR "$my_tmpdir" - umask $save_mktempdir_umask - fi - - # If we're not in dry-run mode, bomb out on failure - test -d "$my_tmpdir" || \ - func_fatal_error "cannot create temporary directory \`$my_tmpdir'" - fi - - $ECHO "$my_tmpdir" -} - - -# func_quote_for_eval arg -# Aesthetically quote ARG to be evaled later. -# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT -# is double-quoted, suitable for a subsequent eval, whereas -# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters -# which are still active within double quotes backslashified. -func_quote_for_eval () -{ - case $1 in - *[\\\`\"\$]*) - func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; - *) - func_quote_for_eval_unquoted_result="$1" ;; - esac - - case $func_quote_for_eval_unquoted_result in - # Double-quote args containing shell metacharacters to delay - # word splitting, command substitution and and variable - # expansion for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" - ;; - *) - func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" - esac -} - - -# func_quote_for_expand arg -# Aesthetically quote ARG to be evaled later; same as above, -# but do not quote variable references. -func_quote_for_expand () -{ - case $1 in - *[\\\`\"]*) - my_arg=`$ECHO "$1" | $SED \ - -e "$double_quote_subst" -e "$sed_double_backslash"` ;; - *) - my_arg="$1" ;; - esac - - case $my_arg in - # Double-quote args containing shell metacharacters to delay - # word splitting and command substitution for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - my_arg="\"$my_arg\"" - ;; - esac - - func_quote_for_expand_result="$my_arg" -} - - -# func_show_eval cmd [fail_exp] -# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is -# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP -# is given, then evaluate it. -func_show_eval () -{ - my_cmd="$1" - my_fail_exp="${2-:}" - - ${opt_silent-false} || { - func_quote_for_expand "$my_cmd" - eval "func_echo $func_quote_for_expand_result" - } - - if ${opt_dry_run-false}; then :; else - eval "$my_cmd" - my_status=$? - if test "$my_status" -eq 0; then :; else - eval "(exit $my_status); $my_fail_exp" - fi - fi -} - - -# func_show_eval_locale cmd [fail_exp] -# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is -# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP -# is given, then evaluate it. Use the saved locale for evaluation. -func_show_eval_locale () -{ - my_cmd="$1" - my_fail_exp="${2-:}" - - ${opt_silent-false} || { - func_quote_for_expand "$my_cmd" - eval "func_echo $func_quote_for_expand_result" - } - - if ${opt_dry_run-false}; then :; else - eval "$lt_user_locale - $my_cmd" - my_status=$? - eval "$lt_safe_locale" - if test "$my_status" -eq 0; then :; else - eval "(exit $my_status); $my_fail_exp" - fi - fi -} - -# func_tr_sh -# Turn $1 into a string suitable for a shell variable name. -# Result is stored in $func_tr_sh_result. All characters -# not in the set a-zA-Z0-9_ are replaced with '_'. Further, -# if $1 begins with a digit, a '_' is prepended as well. -func_tr_sh () -{ - case $1 in - [0-9]* | *[!a-zA-Z0-9_]*) - func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` - ;; - * ) - func_tr_sh_result=$1 - ;; - esac -} - - -# func_version -# Echo version message to standard output and exit. -func_version () -{ - $opt_debug - - $SED -n '/(C)/!b go - :more - /\./!{ - N - s/\n# / / - b more - } - :go - /^# '$PROGRAM' (GNU /,/# warranty; / { - s/^# // - s/^# *$// - s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ - p - }' < "$progpath" - exit $? -} - -# func_usage -# Echo short help message to standard output and exit. -func_usage () -{ - $opt_debug - - $SED -n '/^# Usage:/,/^# *.*--help/ { - s/^# // - s/^# *$// - s/\$progname/'$progname'/ - p - }' < "$progpath" - echo - $ECHO "run \`$progname --help | more' for full usage" - exit $? -} - -# func_help [NOEXIT] -# Echo long help message to standard output and exit, -# unless 'noexit' is passed as argument. -func_help () -{ - $opt_debug - - $SED -n '/^# Usage:/,/# Report bugs to/ { - :print - s/^# // - s/^# *$// - s*\$progname*'$progname'* - s*\$host*'"$host"'* - s*\$SHELL*'"$SHELL"'* - s*\$LTCC*'"$LTCC"'* - s*\$LTCFLAGS*'"$LTCFLAGS"'* - s*\$LD*'"$LD"'* - s/\$with_gnu_ld/'"$with_gnu_ld"'/ - s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ - s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ - p - d - } - /^# .* home page:/b print - /^# General help using/b print - ' < "$progpath" - ret=$? - if test -z "$1"; then - exit $ret - fi -} - -# func_missing_arg argname -# Echo program name prefixed message to standard error and set global -# exit_cmd. -func_missing_arg () -{ - $opt_debug - - func_error "missing argument for $1." - exit_cmd=exit -} - - -# func_split_short_opt shortopt -# Set func_split_short_opt_name and func_split_short_opt_arg shell -# variables after splitting SHORTOPT after the 2nd character. -func_split_short_opt () -{ - my_sed_short_opt='1s/^\(..\).*$/\1/;q' - my_sed_short_rest='1s/^..\(.*\)$/\1/;q' - - func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` - func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` -} # func_split_short_opt may be replaced by extended shell implementation - - -# func_split_long_opt longopt -# Set func_split_long_opt_name and func_split_long_opt_arg shell -# variables after splitting LONGOPT at the `=' sign. -func_split_long_opt () -{ - my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' - my_sed_long_arg='1s/^--[^=]*=//' - - func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` - func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` -} # func_split_long_opt may be replaced by extended shell implementation - -exit_cmd=: - - - - - -magic="%%%MAGIC variable%%%" -magic_exe="%%%MAGIC EXE variable%%%" - -# Global variables. -nonopt= -preserve_args= -lo2o="s/\\.lo\$/.${objext}/" -o2lo="s/\\.${objext}\$/.lo/" -extracted_archives= -extracted_serial=0 - -# If this variable is set in any of the actions, the command in it -# will be execed at the end. This prevents here-documents from being -# left over by shells. -exec_cmd= - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "${1}=\$${1}\${2}" -} # func_append may be replaced by extended shell implementation - -# func_append_quoted var value -# Quote VALUE and append to the end of shell variable VAR, separated -# by a space. -func_append_quoted () -{ - func_quote_for_eval "${2}" - eval "${1}=\$${1}\\ \$func_quote_for_eval_result" -} # func_append_quoted may be replaced by extended shell implementation - - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "${@}"` -} # func_arith may be replaced by extended shell implementation - - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` -} # func_len may be replaced by extended shell implementation - - -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` -} # func_lo2o may be replaced by extended shell implementation - - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` -} # func_xform may be replaced by extended shell implementation - - -# func_fatal_configuration arg... -# Echo program name prefixed message to standard error, followed by -# a configuration failure hint, and exit. -func_fatal_configuration () -{ - func_error ${1+"$@"} - func_error "See the $PACKAGE documentation for more information." - func_fatal_error "Fatal configuration error." -} - - -# func_config -# Display the configuration for all the tags in this script. -func_config () -{ - re_begincf='^# ### BEGIN LIBTOOL' - re_endcf='^# ### END LIBTOOL' - - # Default configuration. - $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" - - # Now print the configurations for the tags. - for tagname in $taglist; do - $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" - done - - exit $? -} - -# func_features -# Display the features supported by this script. -func_features () -{ - echo "host: $host" - if test "$build_libtool_libs" = yes; then - echo "enable shared libraries" - else - echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then - echo "enable static libraries" - else - echo "disable static libraries" - fi - - exit $? -} - -# func_enable_tag tagname -# Verify that TAGNAME is valid, and either flag an error and exit, or -# enable the TAGNAME tag. We also add TAGNAME to the global $taglist -# variable here. -func_enable_tag () -{ - # Global variable: - tagname="$1" - - re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" - re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" - sed_extractcf="/$re_begincf/,/$re_endcf/p" - - # Validate tagname. - case $tagname in - *[!-_A-Za-z0-9,/]*) - func_fatal_error "invalid tag name: $tagname" - ;; - esac - - # Don't test for the "default" C tag, as we know it's - # there but not specially marked. - case $tagname in - CC) ;; - *) - if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then - taglist="$taglist $tagname" - - # Evaluate the configuration. Be careful to quote the path - # and the sed script, to avoid splitting on whitespace, but - # also don't use non-portable quotes within backquotes within - # quotes we have to do it in 2 steps: - extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` - eval "$extractedcf" - else - func_error "ignoring unknown tag $tagname" - fi - ;; - esac -} - -# func_check_version_match -# Ensure that we are using m4 macros, and libtool script from the same -# release of libtool. -func_check_version_match () -{ - if test "$package_revision" != "$macro_revision"; then - if test "$VERSION" != "$macro_version"; then - if test -z "$macro_version"; then - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, but the -$progname: definition of this LT_INIT comes from an older release. -$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION -$progname: and run autoconf again. -_LT_EOF - else - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, but the -$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. -$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION -$progname: and run autoconf again. -_LT_EOF - fi - else - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, -$progname: but the definition of this LT_INIT comes from revision $macro_revision. -$progname: You should recreate aclocal.m4 with macros from revision $package_revision -$progname: of $PACKAGE $VERSION and run autoconf again. -_LT_EOF - fi - - exit $EXIT_MISMATCH - fi -} - - -# Shorthand for --mode=foo, only valid as the first argument -case $1 in -clean|clea|cle|cl) - shift; set dummy --mode clean ${1+"$@"}; shift - ;; -compile|compil|compi|comp|com|co|c) - shift; set dummy --mode compile ${1+"$@"}; shift - ;; -execute|execut|execu|exec|exe|ex|e) - shift; set dummy --mode execute ${1+"$@"}; shift - ;; -finish|finis|fini|fin|fi|f) - shift; set dummy --mode finish ${1+"$@"}; shift - ;; -install|instal|insta|inst|ins|in|i) - shift; set dummy --mode install ${1+"$@"}; shift - ;; -link|lin|li|l) - shift; set dummy --mode link ${1+"$@"}; shift - ;; -uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) - shift; set dummy --mode uninstall ${1+"$@"}; shift - ;; -esac - - - -# Option defaults: -opt_debug=: -opt_dry_run=false -opt_config=false -opt_preserve_dup_deps=false -opt_features=false -opt_finish=false -opt_help=false -opt_help_all=false -opt_silent=: -opt_warning=: -opt_verbose=: -opt_silent=false -opt_verbose=false - - -# Parse options once, thoroughly. This comes as soon as possible in the -# script to make things like `--version' happen as quickly as we can. -{ - # this just eases exit handling - while test $# -gt 0; do - opt="$1" - shift - case $opt in - --debug|-x) opt_debug='set -x' - func_echo "enabling shell trace mode" - $opt_debug - ;; - --dry-run|--dryrun|-n) - opt_dry_run=: - ;; - --config) - opt_config=: -func_config - ;; - --dlopen|-dlopen) - optarg="$1" - opt_dlopen="${opt_dlopen+$opt_dlopen -}$optarg" - shift - ;; - --preserve-dup-deps) - opt_preserve_dup_deps=: - ;; - --features) - opt_features=: -func_features - ;; - --finish) - opt_finish=: -set dummy --mode finish ${1+"$@"}; shift - ;; - --help) - opt_help=: - ;; - --help-all) - opt_help_all=: -opt_help=': help-all' - ;; - --mode) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_mode="$optarg" -case $optarg in - # Valid mode arguments: - clean|compile|execute|finish|install|link|relink|uninstall) ;; - - # Catch anything else as an error - *) func_error "invalid argument for $opt" - exit_cmd=exit - break - ;; -esac - shift - ;; - --no-silent|--no-quiet) - opt_silent=false -func_append preserve_args " $opt" - ;; - --no-warning|--no-warn) - opt_warning=false -func_append preserve_args " $opt" - ;; - --no-verbose) - opt_verbose=false -func_append preserve_args " $opt" - ;; - --silent|--quiet) - opt_silent=: -func_append preserve_args " $opt" - opt_verbose=false - ;; - --verbose|-v) - opt_verbose=: -func_append preserve_args " $opt" -opt_silent=false - ;; - --tag) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_tag="$optarg" -func_append preserve_args " $opt $optarg" -func_enable_tag "$optarg" - shift - ;; - - -\?|-h) func_usage ;; - --help) func_help ;; - --version) func_version ;; - - # Separate optargs to long options: - --*=*) - func_split_long_opt "$opt" - set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} - shift - ;; - - # Separate non-argument short options: - -\?*|-h*|-n*|-v*) - func_split_short_opt "$opt" - set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} - shift - ;; - - --) break ;; - -*) func_fatal_help "unrecognized option \`$opt'" ;; - *) set dummy "$opt" ${1+"$@"}; shift; break ;; - esac - done - - # Validate options: - - # save first non-option argument - if test "$#" -gt 0; then - nonopt="$opt" - shift - fi - - # preserve --debug - test "$opt_debug" = : || func_append preserve_args " --debug" - - case $host in - *cygwin* | *mingw* | *pw32* | *cegcc*) - # don't eliminate duplications in $postdeps and $predeps - opt_duplicate_compiler_generated_deps=: - ;; - *) - opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps - ;; - esac - - $opt_help || { - # Sanity checks first: - func_check_version_match - - if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then - func_fatal_configuration "not configured to build any kind of library" - fi - - # Darwin sucks - eval std_shrext=\"$shrext_cmds\" - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$opt_dlopen" && test "$opt_mode" != execute; then - func_error "unrecognized option \`-dlopen'" - $ECHO "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$progname --help --mode=$opt_mode' for more information." - } - - - # Bail if the options were screwed - $exit_cmd $EXIT_FAILURE -} - - - - -## ----------- ## -## Main. ## -## ----------- ## - -# func_lalib_p file -# True iff FILE is a libtool `.la' library or `.lo' object file. -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_lalib_p () -{ - test -f "$1" && - $SED -e 4q "$1" 2>/dev/null \ - | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 -} - -# func_lalib_unsafe_p file -# True iff FILE is a libtool `.la' library or `.lo' object file. -# This function implements the same check as func_lalib_p without -# resorting to external programs. To this end, it redirects stdin and -# closes it afterwards, without saving the original file descriptor. -# As a safety measure, use it only where a negative result would be -# fatal anyway. Works if `file' does not exist. -func_lalib_unsafe_p () -{ - lalib_p=no - if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then - for lalib_p_l in 1 2 3 4 - do - read lalib_p_line - case "$lalib_p_line" in - \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; - esac - done - exec 0<&5 5<&- - fi - test "$lalib_p" = yes -} - -# func_ltwrapper_script_p file -# True iff FILE is a libtool wrapper script -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_script_p () -{ - func_lalib_p "$1" -} - -# func_ltwrapper_executable_p file -# True iff FILE is a libtool wrapper executable -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_executable_p () -{ - func_ltwrapper_exec_suffix= - case $1 in - *.exe) ;; - *) func_ltwrapper_exec_suffix=.exe ;; - esac - $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 -} - -# func_ltwrapper_scriptname file -# Assumes file is an ltwrapper_executable -# uses $file to determine the appropriate filename for a -# temporary ltwrapper_script. -func_ltwrapper_scriptname () -{ - func_dirname_and_basename "$1" "" "." - func_stripname '' '.exe' "$func_basename_result" - func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" -} - -# func_ltwrapper_p file -# True iff FILE is a libtool wrapper script or wrapper executable -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_p () -{ - func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" -} - - -# func_execute_cmds commands fail_cmd -# Execute tilde-delimited COMMANDS. -# If FAIL_CMD is given, eval that upon failure. -# FAIL_CMD may read-access the current command in variable CMD! -func_execute_cmds () -{ - $opt_debug - save_ifs=$IFS; IFS='~' - for cmd in $1; do - IFS=$save_ifs - eval cmd=\"$cmd\" - func_show_eval "$cmd" "${2-:}" - done - IFS=$save_ifs -} - - -# func_source file -# Source FILE, adding directory component if necessary. -# Note that it is not necessary on cygwin/mingw to append a dot to -# FILE even if both FILE and FILE.exe exist: automatic-append-.exe -# behavior happens only for exec(3), not for open(2)! Also, sourcing -# `FILE.' does not work on cygwin managed mounts. -func_source () -{ - $opt_debug - case $1 in - */* | *\\*) . "$1" ;; - *) . "./$1" ;; - esac -} - - -# func_resolve_sysroot PATH -# Replace a leading = in PATH with a sysroot. Store the result into -# func_resolve_sysroot_result -func_resolve_sysroot () -{ - func_resolve_sysroot_result=$1 - case $func_resolve_sysroot_result in - =*) - func_stripname '=' '' "$func_resolve_sysroot_result" - func_resolve_sysroot_result=$lt_sysroot$func_stripname_result - ;; - esac -} - -# func_replace_sysroot PATH -# If PATH begins with the sysroot, replace it with = and -# store the result into func_replace_sysroot_result. -func_replace_sysroot () -{ - case "$lt_sysroot:$1" in - ?*:"$lt_sysroot"*) - func_stripname "$lt_sysroot" '' "$1" - func_replace_sysroot_result="=$func_stripname_result" - ;; - *) - # Including no sysroot. - func_replace_sysroot_result=$1 - ;; - esac -} - -# func_infer_tag arg -# Infer tagged configuration to use if any are available and -# if one wasn't chosen via the "--tag" command line option. -# Only attempt this if the compiler in the base compile -# command doesn't match the default compiler. -# arg is usually of the form 'gcc ...' -func_infer_tag () -{ - $opt_debug - if test -n "$available_tags" && test -z "$tagname"; then - CC_quoted= - for arg in $CC; do - func_append_quoted CC_quoted "$arg" - done - CC_expanded=`func_echo_all $CC` - CC_quoted_expanded=`func_echo_all $CC_quoted` - case $@ in - # Blanks in the command may have been stripped by the calling shell, - # but not from the CC environment variable when configure was run. - " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; - # Blanks at the start of $base_compile will cause this to fail - # if we don't check for them as well. - *) - for z in $available_tags; do - if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then - # Evaluate the configuration. - eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" - CC_quoted= - for arg in $CC; do - # Double-quote args containing other shell metacharacters. - func_append_quoted CC_quoted "$arg" - done - CC_expanded=`func_echo_all $CC` - CC_quoted_expanded=`func_echo_all $CC_quoted` - case "$@ " in - " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) - # The compiler in the base compile command matches - # the one in the tagged configuration. - # Assume this is the tagged configuration we want. - tagname=$z - break - ;; - esac - fi - done - # If $tagname still isn't set, then no tagged configuration - # was found and let the user know that the "--tag" command - # line option must be used. - if test -z "$tagname"; then - func_echo "unable to infer tagged configuration" - func_fatal_error "specify a tag with \`--tag'" -# else -# func_verbose "using $tagname tagged configuration" - fi - ;; - esac - fi -} - - - -# func_write_libtool_object output_name pic_name nonpic_name -# Create a libtool object file (analogous to a ".la" file), -# but don't create it if we're doing a dry run. -func_write_libtool_object () -{ - write_libobj=${1} - if test "$build_libtool_libs" = yes; then - write_lobj=\'${2}\' - else - write_lobj=none - fi - - if test "$build_old_libs" = yes; then - write_oldobj=\'${3}\' - else - write_oldobj=none - fi - - $opt_dry_run || { - cat >${write_libobj}T </dev/null` - if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then - func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | - $SED -e "$lt_sed_naive_backslashify"` - else - func_convert_core_file_wine_to_w32_result= - fi - fi -} -# end: func_convert_core_file_wine_to_w32 - - -# func_convert_core_path_wine_to_w32 ARG -# Helper function used by path conversion functions when $build is *nix, and -# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly -# configured wine environment available, with the winepath program in $build's -# $PATH. Assumes ARG has no leading or trailing path separator characters. -# -# ARG is path to be converted from $build format to win32. -# Result is available in $func_convert_core_path_wine_to_w32_result. -# Unconvertible file (directory) names in ARG are skipped; if no directory names -# are convertible, then the result may be empty. -func_convert_core_path_wine_to_w32 () -{ - $opt_debug - # unfortunately, winepath doesn't convert paths, only file names - func_convert_core_path_wine_to_w32_result="" - if test -n "$1"; then - oldIFS=$IFS - IFS=: - for func_convert_core_path_wine_to_w32_f in $1; do - IFS=$oldIFS - func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" - if test -n "$func_convert_core_file_wine_to_w32_result" ; then - if test -z "$func_convert_core_path_wine_to_w32_result"; then - func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" - else - func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" - fi - fi - done - IFS=$oldIFS - fi -} -# end: func_convert_core_path_wine_to_w32 - - -# func_cygpath ARGS... -# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when -# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) -# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or -# (2), returns the Cygwin file name or path in func_cygpath_result (input -# file name or path is assumed to be in w32 format, as previously converted -# from $build's *nix or MSYS format). In case (3), returns the w32 file name -# or path in func_cygpath_result (input file name or path is assumed to be in -# Cygwin format). Returns an empty string on error. -# -# ARGS are passed to cygpath, with the last one being the file name or path to -# be converted. -# -# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH -# environment variable; do not put it in $PATH. -func_cygpath () -{ - $opt_debug - if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then - func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` - if test "$?" -ne 0; then - # on failure, ensure result is empty - func_cygpath_result= - fi - else - func_cygpath_result= - func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" - fi -} -#end: func_cygpath - - -# func_convert_core_msys_to_w32 ARG -# Convert file name or path ARG from MSYS format to w32 format. Return -# result in func_convert_core_msys_to_w32_result. -func_convert_core_msys_to_w32 () -{ - $opt_debug - # awkward: cmd appends spaces to result - func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | - $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` -} -#end: func_convert_core_msys_to_w32 - - -# func_convert_file_check ARG1 ARG2 -# Verify that ARG1 (a file name in $build format) was converted to $host -# format in ARG2. Otherwise, emit an error message, but continue (resetting -# func_to_host_file_result to ARG1). -func_convert_file_check () -{ - $opt_debug - if test -z "$2" && test -n "$1" ; then - func_error "Could not determine host file name corresponding to" - func_error " \`$1'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback: - func_to_host_file_result="$1" - fi -} -# end func_convert_file_check - - -# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH -# Verify that FROM_PATH (a path in $build format) was converted to $host -# format in TO_PATH. Otherwise, emit an error message, but continue, resetting -# func_to_host_file_result to a simplistic fallback value (see below). -func_convert_path_check () -{ - $opt_debug - if test -z "$4" && test -n "$3"; then - func_error "Could not determine the host path corresponding to" - func_error " \`$3'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback. This is a deliberately simplistic "conversion" and - # should not be "improved". See libtool.info. - if test "x$1" != "x$2"; then - lt_replace_pathsep_chars="s|$1|$2|g" - func_to_host_path_result=`echo "$3" | - $SED -e "$lt_replace_pathsep_chars"` - else - func_to_host_path_result="$3" - fi - fi -} -# end func_convert_path_check - - -# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG -# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT -# and appending REPL if ORIG matches BACKPAT. -func_convert_path_front_back_pathsep () -{ - $opt_debug - case $4 in - $1 ) func_to_host_path_result="$3$func_to_host_path_result" - ;; - esac - case $4 in - $2 ) func_append func_to_host_path_result "$3" - ;; - esac -} -# end func_convert_path_front_back_pathsep - - -################################################## -# $build to $host FILE NAME CONVERSION FUNCTIONS # -################################################## -# invoked via `$to_host_file_cmd ARG' -# -# In each case, ARG is the path to be converted from $build to $host format. -# Result will be available in $func_to_host_file_result. - - -# func_to_host_file ARG -# Converts the file name ARG from $build format to $host format. Return result -# in func_to_host_file_result. -func_to_host_file () -{ - $opt_debug - $to_host_file_cmd "$1" -} -# end func_to_host_file - - -# func_to_tool_file ARG LAZY -# converts the file name ARG from $build format to toolchain format. Return -# result in func_to_tool_file_result. If the conversion in use is listed -# in (the comma separated) LAZY, no conversion takes place. -func_to_tool_file () -{ - $opt_debug - case ,$2, in - *,"$to_tool_file_cmd",*) - func_to_tool_file_result=$1 - ;; - *) - $to_tool_file_cmd "$1" - func_to_tool_file_result=$func_to_host_file_result - ;; - esac -} -# end func_to_tool_file - - -# func_convert_file_noop ARG -# Copy ARG to func_to_host_file_result. -func_convert_file_noop () -{ - func_to_host_file_result="$1" -} -# end func_convert_file_noop - - -# func_convert_file_msys_to_w32 ARG -# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic -# conversion to w32 is not available inside the cwrapper. Returns result in -# func_to_host_file_result. -func_convert_file_msys_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_msys_to_w32 "$1" - func_to_host_file_result="$func_convert_core_msys_to_w32_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_msys_to_w32 - - -# func_convert_file_cygwin_to_w32 ARG -# Convert file name ARG from Cygwin to w32 format. Returns result in -# func_to_host_file_result. -func_convert_file_cygwin_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - # because $build is cygwin, we call "the" cygpath in $PATH; no need to use - # LT_CYGPATH in this case. - func_to_host_file_result=`cygpath -m "$1"` - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_cygwin_to_w32 - - -# func_convert_file_nix_to_w32 ARG -# Convert file name ARG from *nix to w32 format. Requires a wine environment -# and a working winepath. Returns result in func_to_host_file_result. -func_convert_file_nix_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_file_wine_to_w32 "$1" - func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_nix_to_w32 - - -# func_convert_file_msys_to_cygwin ARG -# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. -# Returns result in func_to_host_file_result. -func_convert_file_msys_to_cygwin () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_msys_to_w32 "$1" - func_cygpath -u "$func_convert_core_msys_to_w32_result" - func_to_host_file_result="$func_cygpath_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_msys_to_cygwin - - -# func_convert_file_nix_to_cygwin ARG -# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed -# in a wine environment, working winepath, and LT_CYGPATH set. Returns result -# in func_to_host_file_result. -func_convert_file_nix_to_cygwin () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. - func_convert_core_file_wine_to_w32 "$1" - func_cygpath -u "$func_convert_core_file_wine_to_w32_result" - func_to_host_file_result="$func_cygpath_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_nix_to_cygwin - - -############################################# -# $build to $host PATH CONVERSION FUNCTIONS # -############################################# -# invoked via `$to_host_path_cmd ARG' -# -# In each case, ARG is the path to be converted from $build to $host format. -# The result will be available in $func_to_host_path_result. -# -# Path separators are also converted from $build format to $host format. If -# ARG begins or ends with a path separator character, it is preserved (but -# converted to $host format) on output. -# -# All path conversion functions are named using the following convention: -# file name conversion function : func_convert_file_X_to_Y () -# path conversion function : func_convert_path_X_to_Y () -# where, for any given $build/$host combination the 'X_to_Y' value is the -# same. If conversion functions are added for new $build/$host combinations, -# the two new functions must follow this pattern, or func_init_to_host_path_cmd -# will break. - - -# func_init_to_host_path_cmd -# Ensures that function "pointer" variable $to_host_path_cmd is set to the -# appropriate value, based on the value of $to_host_file_cmd. -to_host_path_cmd= -func_init_to_host_path_cmd () -{ - $opt_debug - if test -z "$to_host_path_cmd"; then - func_stripname 'func_convert_file_' '' "$to_host_file_cmd" - to_host_path_cmd="func_convert_path_${func_stripname_result}" - fi -} - - -# func_to_host_path ARG -# Converts the path ARG from $build format to $host format. Return result -# in func_to_host_path_result. -func_to_host_path () -{ - $opt_debug - func_init_to_host_path_cmd - $to_host_path_cmd "$1" -} -# end func_to_host_path - - -# func_convert_path_noop ARG -# Copy ARG to func_to_host_path_result. -func_convert_path_noop () -{ - func_to_host_path_result="$1" -} -# end func_convert_path_noop - - -# func_convert_path_msys_to_w32 ARG -# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic -# conversion to w32 is not available inside the cwrapper. Returns result in -# func_to_host_path_result. -func_convert_path_msys_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # Remove leading and trailing path separator characters from ARG. MSYS - # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; - # and winepath ignores them completely. - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_msys_to_w32_result" - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_msys_to_w32 - - -# func_convert_path_cygwin_to_w32 ARG -# Convert path ARG from Cygwin to w32 format. Returns result in -# func_to_host_file_result. -func_convert_path_cygwin_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_cygwin_to_w32 - - -# func_convert_path_nix_to_w32 ARG -# Convert path ARG from *nix to w32 format. Requires a wine environment and -# a working winepath. Returns result in func_to_host_file_result. -func_convert_path_nix_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_nix_to_w32 - - -# func_convert_path_msys_to_cygwin ARG -# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. -# Returns result in func_to_host_file_result. -func_convert_path_msys_to_cygwin () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_cygpath -u -p "$func_convert_core_msys_to_w32_result" - func_to_host_path_result="$func_cygpath_result" - func_convert_path_check : : \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" : "$1" - fi -} -# end func_convert_path_msys_to_cygwin - - -# func_convert_path_nix_to_cygwin ARG -# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a -# a wine environment, working winepath, and LT_CYGPATH set. Returns result in -# func_to_host_file_result. -func_convert_path_nix_to_cygwin () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # Remove leading and trailing path separator characters from - # ARG. msys behavior is inconsistent here, cygpath turns them - # into '.;' and ';.', and winepath ignores them completely. - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" - func_to_host_path_result="$func_cygpath_result" - func_convert_path_check : : \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" : "$1" - fi -} -# end func_convert_path_nix_to_cygwin - - -# func_mode_compile arg... -func_mode_compile () -{ - $opt_debug - # Get the compilation command and the source file. - base_compile= - srcfile="$nonopt" # always keep a non-empty value in "srcfile" - suppress_opt=yes - suppress_output= - arg_mode=normal - libobj= - later= - pie_flag= - - for arg - do - case $arg_mode in - arg ) - # do not "continue". Instead, add this to base_compile - lastarg="$arg" - arg_mode=normal - ;; - - target ) - libobj="$arg" - arg_mode=normal - continue - ;; - - normal ) - # Accept any command-line options. - case $arg in - -o) - test -n "$libobj" && \ - func_fatal_error "you cannot specify \`-o' more than once" - arg_mode=target - continue - ;; - - -pie | -fpie | -fPIE) - func_append pie_flag " $arg" - continue - ;; - - -shared | -static | -prefer-pic | -prefer-non-pic) - func_append later " $arg" - continue - ;; - - -no-suppress) - suppress_opt=no - continue - ;; - - -Xcompiler) - arg_mode=arg # the next one goes into the "base_compile" arg list - continue # The current "srcfile" will either be retained or - ;; # replaced later. I would guess that would be a bug. - - -Wc,*) - func_stripname '-Wc,' '' "$arg" - args=$func_stripname_result - lastarg= - save_ifs="$IFS"; IFS=',' - for arg in $args; do - IFS="$save_ifs" - func_append_quoted lastarg "$arg" - done - IFS="$save_ifs" - func_stripname ' ' '' "$lastarg" - lastarg=$func_stripname_result - - # Add the arguments to base_compile. - func_append base_compile " $lastarg" - continue - ;; - - *) - # Accept the current argument as the source file. - # The previous "srcfile" becomes the current argument. - # - lastarg="$srcfile" - srcfile="$arg" - ;; - esac # case $arg - ;; - esac # case $arg_mode - - # Aesthetically quote the previous argument. - func_append_quoted base_compile "$lastarg" - done # for arg - - case $arg_mode in - arg) - func_fatal_error "you must specify an argument for -Xcompile" - ;; - target) - func_fatal_error "you must specify a target with \`-o'" - ;; - *) - # Get the name of the library object. - test -z "$libobj" && { - func_basename "$srcfile" - libobj="$func_basename_result" - } - ;; - esac - - # Recognize several different file suffixes. - # If the user specifies -o file.o, it is replaced with file.lo - case $libobj in - *.[cCFSifmso] | \ - *.ada | *.adb | *.ads | *.asm | \ - *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ - *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) - func_xform "$libobj" - libobj=$func_xform_result - ;; - esac - - case $libobj in - *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; - *) - func_fatal_error "cannot determine name of library object from \`$libobj'" - ;; - esac - - func_infer_tag $base_compile - - for arg in $later; do - case $arg in - -shared) - test "$build_libtool_libs" != yes && \ - func_fatal_configuration "can not build a shared library" - build_old_libs=no - continue - ;; - - -static) - build_libtool_libs=no - build_old_libs=yes - continue - ;; - - -prefer-pic) - pic_mode=yes - continue - ;; - - -prefer-non-pic) - pic_mode=no - continue - ;; - esac - done - - func_quote_for_eval "$libobj" - test "X$libobj" != "X$func_quote_for_eval_result" \ - && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ - && func_warning "libobj name \`$libobj' may not contain shell special characters." - func_dirname_and_basename "$obj" "/" "" - objname="$func_basename_result" - xdir="$func_dirname_result" - lobj=${xdir}$objdir/$objname - - test -z "$base_compile" && \ - func_fatal_help "you must specify a compilation command" - - # Delete any leftover library objects. - if test "$build_old_libs" = yes; then - removelist="$obj $lobj $libobj ${libobj}T" - else - removelist="$lobj $libobj ${libobj}T" - fi - - # On Cygwin there's no "real" PIC flag so we must build both object types - case $host_os in - cygwin* | mingw* | pw32* | os2* | cegcc*) - pic_mode=default - ;; - esac - if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then - # non-PIC code in shared libraries is not supported - pic_mode=default - fi - - # Calculate the filename of the output object if compiler does - # not support -o with -c - if test "$compiler_c_o" = no; then - output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} - lockfile="$output_obj.lock" - else - output_obj= - need_locks=no - lockfile= - fi - - # Lock this critical section if it is needed - # We use this script file to make the link, it avoids creating a new file - if test "$need_locks" = yes; then - until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do - func_echo "Waiting for $lockfile to be removed" - sleep 2 - done - elif test "$need_locks" = warn; then - if test -f "$lockfile"; then - $ECHO "\ -*** ERROR, $lockfile exists and contains: -`cat $lockfile 2>/dev/null` - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - func_append removelist " $output_obj" - $ECHO "$srcfile" > "$lockfile" - fi - - $opt_dry_run || $RM $removelist - func_append removelist " $lockfile" - trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 - - func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 - srcfile=$func_to_tool_file_result - func_quote_for_eval "$srcfile" - qsrcfile=$func_quote_for_eval_result - - # Only build a PIC object if we are building libtool libraries. - if test "$build_libtool_libs" = yes; then - # Without this assignment, base_compile gets emptied. - fbsd_hideous_sh_bug=$base_compile - - if test "$pic_mode" != no; then - command="$base_compile $qsrcfile $pic_flag" - else - # Don't build PIC code - command="$base_compile $qsrcfile" - fi - - func_mkdir_p "$xdir$objdir" - - if test -z "$output_obj"; then - # Place PIC objects in $objdir - func_append command " -o $lobj" - fi - - func_show_eval_locale "$command" \ - 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' - - if test "$need_locks" = warn && - test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then - $ECHO "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - - # Just move the object if needed, then go on to compile the next one - if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then - func_show_eval '$MV "$output_obj" "$lobj"' \ - 'error=$?; $opt_dry_run || $RM $removelist; exit $error' - fi - - # Allow error messages only from the first compilation. - if test "$suppress_opt" = yes; then - suppress_output=' >/dev/null 2>&1' - fi - fi - - # Only build a position-dependent object if we build old libraries. - if test "$build_old_libs" = yes; then - if test "$pic_mode" != yes; then - # Don't build PIC code - command="$base_compile $qsrcfile$pie_flag" - else - command="$base_compile $qsrcfile $pic_flag" - fi - if test "$compiler_c_o" = yes; then - func_append command " -o $obj" - fi - - # Suppress compiler output if we already did a PIC compilation. - func_append command "$suppress_output" - func_show_eval_locale "$command" \ - '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' - - if test "$need_locks" = warn && - test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then - $ECHO "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - - # Just move the object if needed - if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then - func_show_eval '$MV "$output_obj" "$obj"' \ - 'error=$?; $opt_dry_run || $RM $removelist; exit $error' - fi - fi - - $opt_dry_run || { - func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" - - # Unlock the critical section if it was locked - if test "$need_locks" != no; then - removelist=$lockfile - $RM "$lockfile" - fi - } - - exit $EXIT_SUCCESS -} - -$opt_help || { - test "$opt_mode" = compile && func_mode_compile ${1+"$@"} -} - -func_mode_help () -{ - # We need to display help for each of the modes. - case $opt_mode in - "") - # Generic help is extracted from the usage comments - # at the start of this file. - func_help - ;; - - clean) - $ECHO \ -"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... - -Remove files from the build directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, object or program, all the files associated -with it are deleted. Otherwise, only FILE itself is deleted using RM." - ;; - - compile) - $ECHO \ -"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE - -Compile a source file into a libtool library object. - -This mode accepts the following additional options: - - -o OUTPUT-FILE set the output file name to OUTPUT-FILE - -no-suppress do not suppress compiler output for multiple passes - -prefer-pic try to build PIC objects only - -prefer-non-pic try to build non-PIC objects only - -shared do not build a \`.o' file suitable for static linking - -static only build a \`.o' file suitable for static linking - -Wc,FLAG pass FLAG directly to the compiler - -COMPILE-COMMAND is a command to be used in creating a \`standard' object file -from the given SOURCEFILE. - -The output file name is determined by removing the directory component from -SOURCEFILE, then substituting the C source code suffix \`.c' with the -library object suffix, \`.lo'." - ;; - - execute) - $ECHO \ -"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... - -Automatically set library path, then run a program. - -This mode accepts the following additional options: - - -dlopen FILE add the directory containing FILE to the library path - -This mode sets the library path environment variable according to \`-dlopen' -flags. - -If any of the ARGS are libtool executable wrappers, then they are translated -into their corresponding uninstalled binary, and any of their required library -directories are added to the library path. - -Then, COMMAND is executed, with ARGS as arguments." - ;; - - finish) - $ECHO \ -"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... - -Complete the installation of libtool libraries. - -Each LIBDIR is a directory that contains libtool libraries. - -The commands that this mode executes may require superuser privileges. Use -the \`--dry-run' option if you just want to see what would be executed." - ;; - - install) - $ECHO \ -"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... - -Install executables or libraries. - -INSTALL-COMMAND is the installation command. The first component should be -either the \`install' or \`cp' program. - -The following components of INSTALL-COMMAND are treated specially: - - -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation - -The rest of the components are interpreted as arguments to that command (only -BSD-compatible install options are recognized)." - ;; - - link) - $ECHO \ -"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... - -Link object files or libraries together to form another library, or to -create an executable program. - -LINK-COMMAND is a command using the C compiler that you would use to create -a program from several object files. - -The following components of LINK-COMMAND are treated specially: - - -all-static do not do any dynamic linking at all - -avoid-version do not add a version suffix if possible - -bindir BINDIR specify path to binaries directory (for systems where - libraries must be found in the PATH setting at runtime) - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime - -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols - -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) - -export-symbols SYMFILE - try to export only the symbols listed in SYMFILE - -export-symbols-regex REGEX - try to export only the symbols matching REGEX - -LLIBDIR search LIBDIR for required installed libraries - -lNAME OUTPUT-FILE requires the installed library libNAME - -module build a library that can dlopened - -no-fast-install disable the fast-install mode - -no-install link a not-installable executable - -no-undefined declare that a library does not refer to external symbols - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects - -objectlist FILE Use a list of object files found in FILE to specify objects - -precious-files-regex REGEX - don't remove output files matching REGEX - -release RELEASE specify package release information - -rpath LIBDIR the created library will eventually be installed in LIBDIR - -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries - -shared only do dynamic linking of libtool libraries - -shrext SUFFIX override the standard shared library file extension - -static do not do any dynamic linking of uninstalled libtool libraries - -static-libtool-libs - do not do any dynamic linking of libtool libraries - -version-info CURRENT[:REVISION[:AGE]] - specify library version info [each variable defaults to 0] - -weak LIBNAME declare that the target provides the LIBNAME interface - -Wc,FLAG - -Xcompiler FLAG pass linker-specific FLAG directly to the compiler - -Wl,FLAG - -Xlinker FLAG pass linker-specific FLAG directly to the linker - -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) - -All other options (arguments beginning with \`-') are ignored. - -Every other argument is treated as a filename. Files ending in \`.la' are -treated as uninstalled libtool libraries, other files are standard or library -object files. - -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, -only library objects (\`.lo' files) may be specified, and \`-rpath' is -required, except when creating a convenience library. - -If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created -using \`ar' and \`ranlib', or on Windows using \`lib'. - -If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file -is created, otherwise an executable program is created." - ;; - - uninstall) - $ECHO \ -"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... - -Remove libraries from an installation directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, all the files associated with it are deleted. -Otherwise, only FILE itself is deleted using RM." - ;; - - *) - func_fatal_help "invalid operation mode \`$opt_mode'" - ;; - esac - - echo - $ECHO "Try \`$progname --help' for more information about other modes." -} - -# Now that we've collected a possible --mode arg, show help if necessary -if $opt_help; then - if test "$opt_help" = :; then - func_mode_help - else - { - func_help noexit - for opt_mode in compile link execute install finish uninstall clean; do - func_mode_help - done - } | sed -n '1p; 2,$s/^Usage:/ or: /p' - { - func_help noexit - for opt_mode in compile link execute install finish uninstall clean; do - echo - func_mode_help - done - } | - sed '1d - /^When reporting/,/^Report/{ - H - d - } - $x - /information about other modes/d - /more detailed .*MODE/d - s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' - fi - exit $? -fi - - -# func_mode_execute arg... -func_mode_execute () -{ - $opt_debug - # The first argument is the command name. - cmd="$nonopt" - test -z "$cmd" && \ - func_fatal_help "you must specify a COMMAND" - - # Handle -dlopen flags immediately. - for file in $opt_dlopen; do - test -f "$file" \ - || func_fatal_help "\`$file' is not a file" - - dir= - case $file in - *.la) - func_resolve_sysroot "$file" - file=$func_resolve_sysroot_result - - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$file" \ - || func_fatal_help "\`$lib' is not a valid libtool archive" - - # Read the libtool library. - dlname= - library_names= - func_source "$file" - - # Skip this library if it cannot be dlopened. - if test -z "$dlname"; then - # Warn if it was a shared library. - test -n "$library_names" && \ - func_warning "\`$file' was not linked with \`-export-dynamic'" - continue - fi - - func_dirname "$file" "" "." - dir="$func_dirname_result" - - if test -f "$dir/$objdir/$dlname"; then - func_append dir "/$objdir" - else - if test ! -f "$dir/$dlname"; then - func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" - fi - fi - ;; - - *.lo) - # Just add the directory containing the .lo file. - func_dirname "$file" "" "." - dir="$func_dirname_result" - ;; - - *) - func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" - continue - ;; - esac - - # Get the absolute pathname. - absdir=`cd "$dir" && pwd` - test -n "$absdir" && dir="$absdir" - - # Now add the directory to shlibpath_var. - if eval "test -z \"\$$shlibpath_var\""; then - eval "$shlibpath_var=\"\$dir\"" - else - eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" - fi - done - - # This variable tells wrapper scripts just to set shlibpath_var - # rather than running their programs. - libtool_execute_magic="$magic" - - # Check if any of the arguments is a wrapper script. - args= - for file - do - case $file in - -* | *.la | *.lo ) ;; - *) - # Do a test to see if this is really a libtool program. - if func_ltwrapper_script_p "$file"; then - func_source "$file" - # Transform arg to wrapped name. - file="$progdir/$program" - elif func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - func_source "$func_ltwrapper_scriptname_result" - # Transform arg to wrapped name. - file="$progdir/$program" - fi - ;; - esac - # Quote arguments (to preserve shell metacharacters). - func_append_quoted args "$file" - done - - if test "X$opt_dry_run" = Xfalse; then - if test -n "$shlibpath_var"; then - # Export the shlibpath_var. - eval "export $shlibpath_var" - fi - - # Restore saved environment variables - for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES - do - eval "if test \"\${save_$lt_var+set}\" = set; then - $lt_var=\$save_$lt_var; export $lt_var - else - $lt_unset $lt_var - fi" - done - - # Now prepare to actually exec the command. - exec_cmd="\$cmd$args" - else - # Display what would be done. - if test -n "$shlibpath_var"; then - eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" - echo "export $shlibpath_var" - fi - $ECHO "$cmd$args" - exit $EXIT_SUCCESS - fi -} - -test "$opt_mode" = execute && func_mode_execute ${1+"$@"} - - -# func_mode_finish arg... -func_mode_finish () -{ - $opt_debug - libs= - libdirs= - admincmds= - - for opt in "$nonopt" ${1+"$@"} - do - if test -d "$opt"; then - func_append libdirs " $opt" - - elif test -f "$opt"; then - if func_lalib_unsafe_p "$opt"; then - func_append libs " $opt" - else - func_warning "\`$opt' is not a valid libtool archive" - fi - - else - func_fatal_error "invalid argument \`$opt'" - fi - done - - if test -n "$libs"; then - if test -n "$lt_sysroot"; then - sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` - sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" - else - sysroot_cmd= - fi - - # Remove sysroot references - if $opt_dry_run; then - for lib in $libs; do - echo "removing references to $lt_sysroot and \`=' prefixes from $lib" - done - else - tmpdir=`func_mktempdir` - for lib in $libs; do - sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ - > $tmpdir/tmp-la - mv -f $tmpdir/tmp-la $lib - done - ${RM}r "$tmpdir" - fi - fi - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for libdir in $libdirs; do - if test -n "$finish_cmds"; then - # Do each command in the finish commands. - func_execute_cmds "$finish_cmds" 'admincmds="$admincmds -'"$cmd"'"' - fi - if test -n "$finish_eval"; then - # Do the single finish_eval. - eval cmds=\"$finish_eval\" - $opt_dry_run || eval "$cmds" || func_append admincmds " - $cmds" - fi - done - fi - - # Exit here if they wanted silent mode. - $opt_silent && exit $EXIT_SUCCESS - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - echo "----------------------------------------------------------------------" - echo "Libraries have been installed in:" - for libdir in $libdirs; do - $ECHO " $libdir" - done - echo - echo "If you ever happen to want to link against installed libraries" - echo "in a given directory, LIBDIR, you must either use libtool, and" - echo "specify the full pathname of the library, or use the \`-LLIBDIR'" - echo "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - echo " during execution" - fi - if test -n "$runpath_var"; then - echo " - add LIBDIR to the \`$runpath_var' environment variable" - echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - - $ECHO " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then - $ECHO " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - echo - - echo "See any operating system documentation about shared libraries for" - case $host in - solaris2.[6789]|solaris2.1[0-9]) - echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" - echo "pages." - ;; - *) - echo "more information, such as the ld(1) and ld.so(8) manual pages." - ;; - esac - echo "----------------------------------------------------------------------" - fi - exit $EXIT_SUCCESS -} - -test "$opt_mode" = finish && func_mode_finish ${1+"$@"} - - -# func_mode_install arg... -func_mode_install () -{ - $opt_debug - # There may be an optional sh(1) argument at the beginning of - # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || - # Allow the use of GNU shtool's install command. - case $nonopt in *shtool*) :;; *) false;; esac; then - # Aesthetically quote it. - func_quote_for_eval "$nonopt" - install_prog="$func_quote_for_eval_result " - arg=$1 - shift - else - install_prog= - arg=$nonopt - fi - - # The real first argument should be the name of the installation program. - # Aesthetically quote it. - func_quote_for_eval "$arg" - func_append install_prog "$func_quote_for_eval_result" - install_shared_prog=$install_prog - case " $install_prog " in - *[\\\ /]cp\ *) install_cp=: ;; - *) install_cp=false ;; - esac - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir=no - stripme= - no_mode=: - for arg - do - arg2= - if test -n "$dest"; then - func_append files " $dest" - dest=$arg - continue - fi - - case $arg in - -d) isdir=yes ;; - -f) - if $install_cp; then :; else - prev=$arg - fi - ;; - -g | -m | -o) - prev=$arg - ;; - -s) - stripme=" -s" - continue - ;; - -*) - ;; - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - if test "x$prev" = x-m && test -n "$install_override_mode"; then - arg2=$install_override_mode - no_mode=false - fi - prev= - else - dest=$arg - continue - fi - ;; - esac - - # Aesthetically quote the argument. - func_quote_for_eval "$arg" - func_append install_prog " $func_quote_for_eval_result" - if test -n "$arg2"; then - func_quote_for_eval "$arg2" - fi - func_append install_shared_prog " $func_quote_for_eval_result" - done - - test -z "$install_prog" && \ - func_fatal_help "you must specify an install program" - - test -n "$prev" && \ - func_fatal_help "the \`$prev' option requires an argument" - - if test -n "$install_override_mode" && $no_mode; then - if $install_cp; then :; else - func_quote_for_eval "$install_override_mode" - func_append install_shared_prog " -m $func_quote_for_eval_result" - fi - fi - - if test -z "$files"; then - if test -z "$dest"; then - func_fatal_help "no file or destination specified" - else - func_fatal_help "you must specify a destination" - fi - fi - - # Strip any trailing slash from the destination. - func_stripname '' '/' "$dest" - dest=$func_stripname_result - - # Check to see that the destination is a directory. - test -d "$dest" && isdir=yes - if test "$isdir" = yes; then - destdir="$dest" - destname= - else - func_dirname_and_basename "$dest" "" "." - destdir="$func_dirname_result" - destname="$func_basename_result" - - # Not a directory, so check to see that there is only one file specified. - set dummy $files; shift - test "$#" -gt 1 && \ - func_fatal_help "\`$dest' is not a directory" - fi - case $destdir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - for file in $files; do - case $file in - *.lo) ;; - *) - func_fatal_help "\`$destdir' must be an absolute directory name" - ;; - esac - done - ;; - esac - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - staticlibs= - future_libdirs= - current_libdirs= - for file in $files; do - - # Do each installation. - case $file in - *.$libext) - # Do the static libraries later. - func_append staticlibs " $file" - ;; - - *.la) - func_resolve_sysroot "$file" - file=$func_resolve_sysroot_result - - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$file" \ - || func_fatal_help "\`$file' is not a valid libtool archive" - - library_names= - old_library= - relink_command= - func_source "$file" - - # Add the libdir to current_libdirs if it is the destination. - if test "X$destdir" = "X$libdir"; then - case "$current_libdirs " in - *" $libdir "*) ;; - *) func_append current_libdirs " $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) func_append future_libdirs " $libdir" ;; - esac - fi - - func_dirname "$file" "/" "" - dir="$func_dirname_result" - func_append dir "$objdir" - - if test -n "$relink_command"; then - # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` - - # Don't allow the user to place us outside of our expected - # location b/c this prevents finding dependent libraries that - # are installed to the same prefix. - # At present, this check doesn't affect windows .dll's that - # are installed into $libdir/../bin (currently, that works fine) - # but it's something to keep an eye on. - test "$inst_prefix_dir" = "$destdir" && \ - func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" - - if test -n "$inst_prefix_dir"; then - # Stick the inst_prefix_dir data into the link command. - relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` - else - relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` - fi - - func_warning "relinking \`$file'" - func_show_eval "$relink_command" \ - 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' - fi - - # See the names of the shared library. - set dummy $library_names; shift - if test -n "$1"; then - realname="$1" - shift - - srcname="$realname" - test -n "$relink_command" && srcname="$realname"T - - # Install the shared library and build the symlinks. - func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ - 'exit $?' - tstripme="$stripme" - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - case $realname in - *.dll.a) - tstripme="" - ;; - esac - ;; - esac - if test -n "$tstripme" && test -n "$striplib"; then - func_show_eval "$striplib $destdir/$realname" 'exit $?' - fi - - if test "$#" -gt 0; then - # Delete the old symlinks, and create new ones. - # Try `ln -sf' first, because the `ln' binary might depend on - # the symlink we replace! Solaris /bin/ln does not understand -f, - # so we also need to try rm && ln -s. - for linkname - do - test "$linkname" != "$realname" \ - && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" - done - fi - - # Do each command in the postinstall commands. - lib="$destdir/$realname" - func_execute_cmds "$postinstall_cmds" 'exit $?' - fi - - # Install the pseudo-library for information purposes. - func_basename "$file" - name="$func_basename_result" - instname="$dir/$name"i - func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' - - # Maybe install the static library, too. - test -n "$old_library" && func_append staticlibs " $dir/$old_library" - ;; - - *.lo) - # Install (i.e. copy) a libtool object. - - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - func_basename "$file" - destfile="$func_basename_result" - destfile="$destdir/$destfile" - fi - - # Deduce the name of the destination old-style object file. - case $destfile in - *.lo) - func_lo2o "$destfile" - staticdest=$func_lo2o_result - ;; - *.$objext) - staticdest="$destfile" - destfile= - ;; - *) - func_fatal_help "cannot copy a libtool object to \`$destfile'" - ;; - esac - - # Install the libtool object if requested. - test -n "$destfile" && \ - func_show_eval "$install_prog $file $destfile" 'exit $?' - - # Install the old object if enabled. - if test "$build_old_libs" = yes; then - # Deduce the name of the old-style object file. - func_lo2o "$file" - staticobj=$func_lo2o_result - func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' - fi - exit $EXIT_SUCCESS - ;; - - *) - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - func_basename "$file" - destfile="$func_basename_result" - destfile="$destdir/$destfile" - fi - - # If the file is missing, and there is a .exe on the end, strip it - # because it is most likely a libtool script we actually want to - # install - stripped_ext="" - case $file in - *.exe) - if test ! -f "$file"; then - func_stripname '' '.exe' "$file" - file=$func_stripname_result - stripped_ext=".exe" - fi - ;; - esac - - # Do a test to see if this is really a libtool program. - case $host in - *cygwin* | *mingw*) - if func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - wrapper=$func_ltwrapper_scriptname_result - else - func_stripname '' '.exe' "$file" - wrapper=$func_stripname_result - fi - ;; - *) - wrapper=$file - ;; - esac - if func_ltwrapper_script_p "$wrapper"; then - notinst_deplibs= - relink_command= - - func_source "$wrapper" - - # Check the variables that should have been set. - test -z "$generated_by_libtool_version" && \ - func_fatal_error "invalid libtool wrapper script \`$wrapper'" - - finalize=yes - for lib in $notinst_deplibs; do - # Check to see that each library is installed. - libdir= - if test -f "$lib"; then - func_source "$lib" - fi - libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test - if test -n "$libdir" && test ! -f "$libfile"; then - func_warning "\`$lib' has not been installed in \`$libdir'" - finalize=no - fi - done - - relink_command= - func_source "$wrapper" - - outputname= - if test "$fast_install" = no && test -n "$relink_command"; then - $opt_dry_run || { - if test "$finalize" = yes; then - tmpdir=`func_mktempdir` - func_basename "$file$stripped_ext" - file="$func_basename_result" - outputname="$tmpdir/$file" - # Replace the output file specification. - relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` - - $opt_silent || { - func_quote_for_expand "$relink_command" - eval "func_echo $func_quote_for_expand_result" - } - if eval "$relink_command"; then : - else - func_error "error: relink \`$file' with the above command before installing it" - $opt_dry_run || ${RM}r "$tmpdir" - continue - fi - file="$outputname" - else - func_warning "cannot relink \`$file'" - fi - } - else - # Install the binary that we compiled earlier. - file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` - fi - fi - - # remove .exe since cygwin /usr/bin/install will append another - # one anyway - case $install_prog,$host in - */usr/bin/install*,*cygwin*) - case $file:$destfile in - *.exe:*.exe) - # this is ok - ;; - *.exe:*) - destfile=$destfile.exe - ;; - *:*.exe) - func_stripname '' '.exe' "$destfile" - destfile=$func_stripname_result - ;; - esac - ;; - esac - func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' - $opt_dry_run || if test -n "$outputname"; then - ${RM}r "$tmpdir" - fi - ;; - esac - done - - for file in $staticlibs; do - func_basename "$file" - name="$func_basename_result" - - # Set up the ranlib parameters. - oldlib="$destdir/$name" - func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 - tool_oldlib=$func_to_tool_file_result - - func_show_eval "$install_prog \$file \$oldlib" 'exit $?' - - if test -n "$stripme" && test -n "$old_striplib"; then - func_show_eval "$old_striplib $tool_oldlib" 'exit $?' - fi - - # Do each command in the postinstall commands. - func_execute_cmds "$old_postinstall_cmds" 'exit $?' - done - - test -n "$future_libdirs" && \ - func_warning "remember to run \`$progname --finish$future_libdirs'" - - if test -n "$current_libdirs"; then - # Maybe just do a dry run. - $opt_dry_run && current_libdirs=" -n$current_libdirs" - exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' - else - exit $EXIT_SUCCESS - fi -} - -test "$opt_mode" = install && func_mode_install ${1+"$@"} - - -# func_generate_dlsyms outputname originator pic_p -# Extract symbols from dlprefiles and create ${outputname}S.o with -# a dlpreopen symbol table. -func_generate_dlsyms () -{ - $opt_debug - my_outputname="$1" - my_originator="$2" - my_pic_p="${3-no}" - my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` - my_dlsyms= - - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - if test -n "$NM" && test -n "$global_symbol_pipe"; then - my_dlsyms="${my_outputname}S.c" - else - func_error "not configured to extract global symbols from dlpreopened files" - fi - fi - - if test -n "$my_dlsyms"; then - case $my_dlsyms in - "") ;; - *.c) - # Discover the nlist of each of the dlfiles. - nlist="$output_objdir/${my_outputname}.nm" - - func_show_eval "$RM $nlist ${nlist}S ${nlist}T" - - # Parse the name list into a source file. - func_verbose "creating $output_objdir/$my_dlsyms" - - $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ -/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ -/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ - -#ifdef __cplusplus -extern \"C\" { -#endif - -#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) -#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" -#endif - -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT_DLSYM_CONST -#else -# define LT_DLSYM_CONST const -#endif - -/* External symbol declarations for the compiler. */\ -" - - if test "$dlself" = yes; then - func_verbose "generating symbol list for \`$output'" - - $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" - - # Add our own program objects to the symbol list. - progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` - for progfile in $progfiles; do - func_to_tool_file "$progfile" func_convert_file_msys_to_w32 - func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" - $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" - done - - if test -n "$exclude_expsyms"; then - $opt_dry_run || { - eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - } - fi - - if test -n "$export_symbols_regex"; then - $opt_dry_run || { - eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - } - fi - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - export_symbols="$output_objdir/$outputname.exp" - $opt_dry_run || { - $RM $export_symbols - eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' - case $host in - *cygwin* | *mingw* | *cegcc* ) - eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' - eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' - ;; - esac - } - else - $opt_dry_run || { - eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' - eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - case $host in - *cygwin* | *mingw* | *cegcc* ) - eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' - eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' - ;; - esac - } - fi - fi - - for dlprefile in $dlprefiles; do - func_verbose "extracting global C symbols from \`$dlprefile'" - func_basename "$dlprefile" - name="$func_basename_result" - case $host in - *cygwin* | *mingw* | *cegcc* ) - # if an import library, we need to obtain dlname - if func_win32_import_lib_p "$dlprefile"; then - func_tr_sh "$dlprefile" - eval "curr_lafile=\$libfile_$func_tr_sh_result" - dlprefile_dlbasename="" - if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then - # Use subshell, to avoid clobbering current variable values - dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` - if test -n "$dlprefile_dlname" ; then - func_basename "$dlprefile_dlname" - dlprefile_dlbasename="$func_basename_result" - else - # no lafile. user explicitly requested -dlpreopen . - $sharedlib_from_linklib_cmd "$dlprefile" - dlprefile_dlbasename=$sharedlib_from_linklib_result - fi - fi - $opt_dry_run || { - if test -n "$dlprefile_dlbasename" ; then - eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' - else - func_warning "Could not compute DLL name from $name" - eval '$ECHO ": $name " >> "$nlist"' - fi - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | - $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" - } - else # not an import lib - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - fi - ;; - *) - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - ;; - esac - done - - $opt_dry_run || { - # Make sure we have at least an empty file. - test -f "$nlist" || : > "$nlist" - - if test -n "$exclude_expsyms"; then - $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T - $MV "$nlist"T "$nlist" - fi - - # Try sorting and uniquifying the output. - if $GREP -v "^: " < "$nlist" | - if sort -k 3 /dev/null 2>&1; then - sort -k 3 - else - sort +2 - fi | - uniq > "$nlist"S; then - : - else - $GREP -v "^: " < "$nlist" > "$nlist"S - fi - - if test -f "$nlist"S; then - eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' - else - echo '/* NONE */' >> "$output_objdir/$my_dlsyms" - fi - - echo >> "$output_objdir/$my_dlsyms" "\ - -/* The mapping between symbol names and symbols. */ -typedef struct { - const char *name; - void *address; -} lt_dlsymlist; -extern LT_DLSYM_CONST lt_dlsymlist -lt_${my_prefix}_LTX_preloaded_symbols[]; -LT_DLSYM_CONST lt_dlsymlist -lt_${my_prefix}_LTX_preloaded_symbols[] = -{\ - { \"$my_originator\", (void *) 0 }," - - case $need_lib_prefix in - no) - eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" - ;; - *) - eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" - ;; - esac - echo >> "$output_objdir/$my_dlsyms" "\ - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt_${my_prefix}_LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif\ -" - } # !$opt_dry_run - - pic_flag_for_symtable= - case "$compile_command " in - *" -static "*) ;; - *) - case $host in - # compiling the symbol table file with pic_flag works around - # a FreeBSD bug that causes programs to crash when -lm is - # linked before any other PIC object. But we must not use - # pic_flag when linking with -static. The problem exists in - # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) - pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; - *-*-hpux*) - pic_flag_for_symtable=" $pic_flag" ;; - *) - if test "X$my_pic_p" != Xno; then - pic_flag_for_symtable=" $pic_flag" - fi - ;; - esac - ;; - esac - symtab_cflags= - for arg in $LTCFLAGS; do - case $arg in - -pie | -fpie | -fPIE) ;; - *) func_append symtab_cflags " $arg" ;; - esac - done - - # Now compile the dynamic symbol file. - func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' - - # Clean up the generated files. - func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' - - # Transform the symbol file into the correct name. - symfileobj="$output_objdir/${my_outputname}S.$objext" - case $host in - *cygwin* | *mingw* | *cegcc* ) - if test -f "$output_objdir/$my_outputname.def"; then - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - else - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` - fi - ;; - *) - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` - ;; - esac - ;; - *) - func_fatal_error "unknown suffix for \`$my_dlsyms'" - ;; - esac - else - # We keep going just in case the user didn't refer to - # lt_preloaded_symbols. The linker will fail if global_symbol_pipe - # really was required. - - # Nullify the symbol file. - compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` - fi -} - -# func_win32_libid arg -# return the library type of file 'arg' -# -# Need a lot of goo to handle *both* DLLs and import libs -# Has to be a shell function in order to 'eat' the argument -# that is supplied when $file_magic_command is called. -# Despite the name, also deal with 64 bit binaries. -func_win32_libid () -{ - $opt_debug - win32_libid_type="unknown" - win32_fileres=`file -L $1 2>/dev/null` - case $win32_fileres in - *ar\ archive\ import\ library*) # definitely import - win32_libid_type="x86 archive import" - ;; - *ar\ archive*) # could be an import, or static - # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. - if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | - $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then - func_to_tool_file "$1" func_convert_file_msys_to_w32 - win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | - $SED -n -e ' - 1,100{ - / I /{ - s,.*,import, - p - q - } - }'` - case $win32_nmres in - import*) win32_libid_type="x86 archive import";; - *) win32_libid_type="x86 archive static";; - esac - fi - ;; - *DLL*) - win32_libid_type="x86 DLL" - ;; - *executable*) # but shell scripts are "executable" too... - case $win32_fileres in - *MS\ Windows\ PE\ Intel*) - win32_libid_type="x86 DLL" - ;; - esac - ;; - esac - $ECHO "$win32_libid_type" -} - -# func_cygming_dll_for_implib ARG -# -# Platform-specific function to extract the -# name of the DLL associated with the specified -# import library ARG. -# Invoked by eval'ing the libtool variable -# $sharedlib_from_linklib_cmd -# Result is available in the variable -# $sharedlib_from_linklib_result -func_cygming_dll_for_implib () -{ - $opt_debug - sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` -} - -# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs -# -# The is the core of a fallback implementation of a -# platform-specific function to extract the name of the -# DLL associated with the specified import library LIBNAME. -# -# SECTION_NAME is either .idata$6 or .idata$7, depending -# on the platform and compiler that created the implib. -# -# Echos the name of the DLL associated with the -# specified import library. -func_cygming_dll_for_implib_fallback_core () -{ - $opt_debug - match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` - $OBJDUMP -s --section "$1" "$2" 2>/dev/null | - $SED '/^Contents of section '"$match_literal"':/{ - # Place marker at beginning of archive member dllname section - s/.*/====MARK====/ - p - d - } - # These lines can sometimes be longer than 43 characters, but - # are always uninteresting - /:[ ]*file format pe[i]\{,1\}-/d - /^In archive [^:]*:/d - # Ensure marker is printed - /^====MARK====/p - # Remove all lines with less than 43 characters - /^.\{43\}/!d - # From remaining lines, remove first 43 characters - s/^.\{43\}//' | - $SED -n ' - # Join marker and all lines until next marker into a single line - /^====MARK====/ b para - H - $ b para - b - :para - x - s/\n//g - # Remove the marker - s/^====MARK====// - # Remove trailing dots and whitespace - s/[\. \t]*$// - # Print - /./p' | - # we now have a list, one entry per line, of the stringified - # contents of the appropriate section of all members of the - # archive which possess that section. Heuristic: eliminate - # all those which have a first or second character that is - # a '.' (that is, objdump's representation of an unprintable - # character.) This should work for all archives with less than - # 0x302f exports -- but will fail for DLLs whose name actually - # begins with a literal '.' or a single character followed by - # a '.'. - # - # Of those that remain, print the first one. - $SED -e '/^\./d;/^.\./d;q' -} - -# func_cygming_gnu_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is a GNU/binutils-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_gnu_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` - test -n "$func_cygming_gnu_implib_tmp" -} - -# func_cygming_ms_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is an MS-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_ms_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` - test -n "$func_cygming_ms_implib_tmp" -} - -# func_cygming_dll_for_implib_fallback ARG -# Platform-specific function to extract the -# name of the DLL associated with the specified -# import library ARG. -# -# This fallback implementation is for use when $DLLTOOL -# does not support the --identify-strict option. -# Invoked by eval'ing the libtool variable -# $sharedlib_from_linklib_cmd -# Result is available in the variable -# $sharedlib_from_linklib_result -func_cygming_dll_for_implib_fallback () -{ - $opt_debug - if func_cygming_gnu_implib_p "$1" ; then - # binutils import library - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` - elif func_cygming_ms_implib_p "$1" ; then - # ms-generated import library - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` - else - # unknown - sharedlib_from_linklib_result="" - fi -} - - -# func_extract_an_archive dir oldlib -func_extract_an_archive () -{ - $opt_debug - f_ex_an_ar_dir="$1"; shift - f_ex_an_ar_oldlib="$1" - if test "$lock_old_archive_extraction" = yes; then - lockfile=$f_ex_an_ar_oldlib.lock - until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do - func_echo "Waiting for $lockfile to be removed" - sleep 2 - done - fi - func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ - 'stat=$?; rm -f "$lockfile"; exit $stat' - if test "$lock_old_archive_extraction" = yes; then - $opt_dry_run || rm -f "$lockfile" - fi - if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then - : - else - func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" - fi -} - - -# func_extract_archives gentop oldlib ... -func_extract_archives () -{ - $opt_debug - my_gentop="$1"; shift - my_oldlibs=${1+"$@"} - my_oldobjs="" - my_xlib="" - my_xabs="" - my_xdir="" - - for my_xlib in $my_oldlibs; do - # Extract the objects. - case $my_xlib in - [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; - *) my_xabs=`pwd`"/$my_xlib" ;; - esac - func_basename "$my_xlib" - my_xlib="$func_basename_result" - my_xlib_u=$my_xlib - while :; do - case " $extracted_archives " in - *" $my_xlib_u "*) - func_arith $extracted_serial + 1 - extracted_serial=$func_arith_result - my_xlib_u=lt$extracted_serial-$my_xlib ;; - *) break ;; - esac - done - extracted_archives="$extracted_archives $my_xlib_u" - my_xdir="$my_gentop/$my_xlib_u" - - func_mkdir_p "$my_xdir" - - case $host in - *-darwin*) - func_verbose "Extracting $my_xabs" - # Do not bother doing anything if just a dry run - $opt_dry_run || { - darwin_orig_dir=`pwd` - cd $my_xdir || exit $? - darwin_archive=$my_xabs - darwin_curdir=`pwd` - darwin_base_archive=`basename "$darwin_archive"` - darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` - if test -n "$darwin_arches"; then - darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` - darwin_arch= - func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" - for darwin_arch in $darwin_arches ; do - func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" - $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" - cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" - func_extract_an_archive "`pwd`" "${darwin_base_archive}" - cd "$darwin_curdir" - $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" - done # $darwin_arches - ## Okay now we've a bunch of thin objects, gotta fatten them up :) - darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` - darwin_file= - darwin_files= - for darwin_file in $darwin_filelist; do - darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` - $LIPO -create -output "$darwin_file" $darwin_files - done # $darwin_filelist - $RM -rf unfat-$$ - cd "$darwin_orig_dir" - else - cd $darwin_orig_dir - func_extract_an_archive "$my_xdir" "$my_xabs" - fi # $darwin_arches - } # !$opt_dry_run - ;; - *) - func_extract_an_archive "$my_xdir" "$my_xabs" - ;; - esac - my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` - done - - func_extract_archives_result="$my_oldobjs" -} - - -# func_emit_wrapper [arg=no] -# -# Emit a libtool wrapper script on stdout. -# Don't directly open a file because we may want to -# incorporate the script contents within a cygwin/mingw -# wrapper executable. Must ONLY be called from within -# func_mode_link because it depends on a number of variables -# set therein. -# -# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR -# variable will take. If 'yes', then the emitted script -# will assume that the directory in which it is stored is -# the $objdir directory. This is a cygwin/mingw-specific -# behavior. -func_emit_wrapper () -{ - func_emit_wrapper_arg1=${1-no} - - $ECHO "\ -#! $SHELL - -# $output - temporary wrapper script for $objdir/$outputname -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION -# -# The $output program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of the build directory. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -sed_quote_subst='$sed_quote_subst' - -# Be Bourne compatible -if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -relink_command=\"$relink_command\" - -# This environment variable determines our operation mode. -if test \"\$libtool_install_magic\" = \"$magic\"; then - # install mode needs the following variables: - generated_by_libtool_version='$macro_version' - notinst_deplibs='$notinst_deplibs' -else - # When we are sourced in execute mode, \$file and \$ECHO are already set. - if test \"\$libtool_execute_magic\" != \"$magic\"; then - file=\"\$0\"" - - qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` - $ECHO "\ - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$1 -_LTECHO_EOF' -} - ECHO=\"$qECHO\" - fi - -# Very basic option parsing. These options are (a) specific to -# the libtool wrapper, (b) are identical between the wrapper -# /script/ and the wrapper /executable/ which is used only on -# windows platforms, and (c) all begin with the string "--lt-" -# (application programs are unlikely to have options which match -# this pattern). -# -# There are only two supported options: --lt-debug and -# --lt-dump-script. There is, deliberately, no --lt-help. -# -# The first argument to this parsing function should be the -# script's $0 value, followed by "$@". -lt_option_debug= -func_parse_lt_options () -{ - lt_script_arg0=\$0 - shift - for lt_opt - do - case \"\$lt_opt\" in - --lt-debug) lt_option_debug=1 ;; - --lt-dump-script) - lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` - test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. - lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` - cat \"\$lt_dump_D/\$lt_dump_F\" - exit 0 - ;; - --lt-*) - \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 - exit 1 - ;; - esac - done - - # Print the debug banner immediately: - if test -n \"\$lt_option_debug\"; then - echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 - fi -} - -# Used when --lt-debug. Prints its arguments to stdout -# (redirection is the responsibility of the caller) -func_lt_dump_args () -{ - lt_dump_args_N=1; - for lt_arg - do - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" - lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` - done -} - -# Core function for launching the target application -func_exec_program_core () -{ -" - case $host in - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2* | *-cegcc*) - $ECHO "\ - if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 - func_lt_dump_args \${1+\"\$@\"} 1>&2 - fi - exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} -" - ;; - - *) - $ECHO "\ - if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 - func_lt_dump_args \${1+\"\$@\"} 1>&2 - fi - exec \"\$progdir/\$program\" \${1+\"\$@\"} -" - ;; - esac - $ECHO "\ - \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 - exit 1 -} - -# A function to encapsulate launching the target application -# Strips options in the --lt-* namespace from \$@ and -# launches target application with the remaining arguments. -func_exec_program () -{ - case \" \$* \" in - *\\ --lt-*) - for lt_wr_arg - do - case \$lt_wr_arg in - --lt-*) ;; - *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; - esac - shift - done ;; - esac - func_exec_program_core \${1+\"\$@\"} -} - - # Parse options - func_parse_lt_options \"\$0\" \${1+\"\$@\"} - - # Find the directory that this script lives in. - thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` - - # If there was a directory component, then change thisdir. - if test \"x\$destdir\" != \"x\$file\"; then - case \"\$destdir\" in - [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; - *) thisdir=\"\$thisdir/\$destdir\" ;; - esac - fi - - file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` - done - - # Usually 'no', except on cygwin/mingw when embedded into - # the cwrapper. - WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 - if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then - # special case for '.' - if test \"\$thisdir\" = \".\"; then - thisdir=\`pwd\` - fi - # remove .libs from thisdir - case \"\$thisdir\" in - *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; - $objdir ) thisdir=. ;; - esac - fi - - # Try to get the absolute directory name. - absdir=\`cd \"\$thisdir\" && pwd\` - test -n \"\$absdir\" && thisdir=\"\$absdir\" -" - - if test "$fast_install" = yes; then - $ECHO "\ - program=lt-'$outputname'$exeext - progdir=\"\$thisdir/$objdir\" - - if test ! -f \"\$progdir/\$program\" || - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ - test \"X\$file\" != \"X\$progdir/\$program\"; }; then - - file=\"\$\$-\$program\" - - if test ! -d \"\$progdir\"; then - $MKDIR \"\$progdir\" - else - $RM \"\$progdir/\$file\" - fi" - - $ECHO "\ - - # relink executable if necessary - if test -n \"\$relink_command\"; then - if relink_command_output=\`eval \$relink_command 2>&1\`; then : - else - $ECHO \"\$relink_command_output\" >&2 - $RM \"\$progdir/\$file\" - exit 1 - fi - fi - - $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || - { $RM \"\$progdir/\$program\"; - $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } - $RM \"\$progdir/\$file\" - fi" - else - $ECHO "\ - program='$outputname' - progdir=\"\$thisdir/$objdir\" -" - fi - - $ECHO "\ - - if test -f \"\$progdir/\$program\"; then" - - # fixup the dll searchpath if we need to. - # - # Fix the DLL searchpath if we need to. Do this before prepending - # to shlibpath, because on Windows, both are PATH and uninstalled - # libraries must come first. - if test -n "$dllsearchpath"; then - $ECHO "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - - # Export our shlibpath_var if we have one. - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $ECHO "\ - # Add our own library path to $shlibpath_var - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" - - # Some systems cannot cope with colon-terminated $shlibpath_var - # The second colon is a workaround for a bug in BeOS R4 sed - $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` - - export $shlibpath_var -" - fi - - $ECHO "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. - func_exec_program \${1+\"\$@\"} - fi - else - # The program doesn't exist. - \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 - \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 - \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 - exit 1 - fi -fi\ -" -} - - -# func_emit_cwrapperexe_src -# emit the source code for a wrapper executable on stdout -# Must ONLY be called from within func_mode_link because -# it depends on a number of variable set therein. -func_emit_cwrapperexe_src () -{ - cat < -#include -#ifdef _MSC_VER -# include -# include -# include -#else -# include -# include -# ifdef __CYGWIN__ -# include -# endif -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -/* declarations of non-ANSI functions */ -#if defined(__MINGW32__) -# ifdef __STRICT_ANSI__ -int _putenv (const char *); -# endif -#elif defined(__CYGWIN__) -# ifdef __STRICT_ANSI__ -char *realpath (const char *, char *); -int putenv (char *); -int setenv (const char *, const char *, int); -# endif -/* #elif defined (other platforms) ... */ -#endif - -/* portability defines, excluding path handling macros */ -#if defined(_MSC_VER) -# define setmode _setmode -# define stat _stat -# define chmod _chmod -# define getcwd _getcwd -# define putenv _putenv -# define S_IXUSR _S_IEXEC -# ifndef _INTPTR_T_DEFINED -# define _INTPTR_T_DEFINED -# define intptr_t int -# endif -#elif defined(__MINGW32__) -# define setmode _setmode -# define stat _stat -# define chmod _chmod -# define getcwd _getcwd -# define putenv _putenv -#elif defined(__CYGWIN__) -# define HAVE_SETENV -# define FOPEN_WB "wb" -/* #elif defined (other platforms) ... */ -#endif - -#if defined(PATH_MAX) -# define LT_PATHMAX PATH_MAX -#elif defined(MAXPATHLEN) -# define LT_PATHMAX MAXPATHLEN -#else -# define LT_PATHMAX 1024 -#endif - -#ifndef S_IXOTH -# define S_IXOTH 0 -#endif -#ifndef S_IXGRP -# define S_IXGRP 0 -#endif - -/* path handling portability macros */ -#ifndef DIR_SEPARATOR -# define DIR_SEPARATOR '/' -# define PATH_SEPARATOR ':' -#endif - -#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ - defined (__OS2__) -# define HAVE_DOS_BASED_FILE_SYSTEM -# define FOPEN_WB "wb" -# ifndef DIR_SEPARATOR_2 -# define DIR_SEPARATOR_2 '\\' -# endif -# ifndef PATH_SEPARATOR_2 -# define PATH_SEPARATOR_2 ';' -# endif -#endif - -#ifndef DIR_SEPARATOR_2 -# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) -#else /* DIR_SEPARATOR_2 */ -# define IS_DIR_SEPARATOR(ch) \ - (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) -#endif /* DIR_SEPARATOR_2 */ - -#ifndef PATH_SEPARATOR_2 -# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) -#else /* PATH_SEPARATOR_2 */ -# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) -#endif /* PATH_SEPARATOR_2 */ - -#ifndef FOPEN_WB -# define FOPEN_WB "w" -#endif -#ifndef _O_BINARY -# define _O_BINARY 0 -#endif - -#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) -#define XFREE(stale) do { \ - if (stale) { free ((void *) stale); stale = 0; } \ -} while (0) - -#if defined(LT_DEBUGWRAPPER) -static int lt_debug = 1; -#else -static int lt_debug = 0; -#endif - -const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ - -void *xmalloc (size_t num); -char *xstrdup (const char *string); -const char *base_name (const char *name); -char *find_executable (const char *wrapper); -char *chase_symlinks (const char *pathspec); -int make_executable (const char *path); -int check_executable (const char *path); -char *strendzap (char *str, const char *pat); -void lt_debugprintf (const char *file, int line, const char *fmt, ...); -void lt_fatal (const char *file, int line, const char *message, ...); -static const char *nonnull (const char *s); -static const char *nonempty (const char *s); -void lt_setenv (const char *name, const char *value); -char *lt_extend_str (const char *orig_value, const char *add, int to_end); -void lt_update_exe_path (const char *name, const char *value); -void lt_update_lib_path (const char *name, const char *value); -char **prepare_spawn (char **argv); -void lt_dump_script (FILE *f); -EOF - - cat <= 0) - && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) - return 1; - else - return 0; -} - -int -make_executable (const char *path) -{ - int rval = 0; - struct stat st; - - lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", - nonempty (path)); - if ((!path) || (!*path)) - return 0; - - if (stat (path, &st) >= 0) - { - rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); - } - return rval; -} - -/* Searches for the full path of the wrapper. Returns - newly allocated full path name if found, NULL otherwise - Does not chase symlinks, even on platforms that support them. -*/ -char * -find_executable (const char *wrapper) -{ - int has_slash = 0; - const char *p; - const char *p_next; - /* static buffer for getcwd */ - char tmp[LT_PATHMAX + 1]; - int tmp_len; - char *concat_name; - - lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", - nonempty (wrapper)); - - if ((wrapper == NULL) || (*wrapper == '\0')) - return NULL; - - /* Absolute path? */ -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') - { - concat_name = xstrdup (wrapper); - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } - else - { -#endif - if (IS_DIR_SEPARATOR (wrapper[0])) - { - concat_name = xstrdup (wrapper); - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - } -#endif - - for (p = wrapper; *p; p++) - if (*p == '/') - { - has_slash = 1; - break; - } - if (!has_slash) - { - /* no slashes; search PATH */ - const char *path = getenv ("PATH"); - if (path != NULL) - { - for (p = path; *p; p = p_next) - { - const char *q; - size_t p_len; - for (q = p; *q; q++) - if (IS_PATH_SEPARATOR (*q)) - break; - p_len = q - p; - p_next = (*q == '\0' ? q : q + 1); - if (p_len == 0) - { - /* empty path: current directory */ - if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", - nonnull (strerror (errno))); - tmp_len = strlen (tmp); - concat_name = - XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, tmp, tmp_len); - concat_name[tmp_len] = '/'; - strcpy (concat_name + tmp_len + 1, wrapper); - } - else - { - concat_name = - XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, p, p_len); - concat_name[p_len] = '/'; - strcpy (concat_name + p_len + 1, wrapper); - } - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } - } - /* not found in PATH; assume curdir */ - } - /* Relative path | not found in path: prepend cwd */ - if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", - nonnull (strerror (errno))); - tmp_len = strlen (tmp); - concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, tmp, tmp_len); - concat_name[tmp_len] = '/'; - strcpy (concat_name + tmp_len + 1, wrapper); - - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - return NULL; -} - -char * -chase_symlinks (const char *pathspec) -{ -#ifndef S_ISLNK - return xstrdup (pathspec); -#else - char buf[LT_PATHMAX]; - struct stat s; - char *tmp_pathspec = xstrdup (pathspec); - char *p; - int has_symlinks = 0; - while (strlen (tmp_pathspec) && !has_symlinks) - { - lt_debugprintf (__FILE__, __LINE__, - "checking path component for symlinks: %s\n", - tmp_pathspec); - if (lstat (tmp_pathspec, &s) == 0) - { - if (S_ISLNK (s.st_mode) != 0) - { - has_symlinks = 1; - break; - } - - /* search backwards for last DIR_SEPARATOR */ - p = tmp_pathspec + strlen (tmp_pathspec) - 1; - while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) - p--; - if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) - { - /* no more DIR_SEPARATORS left */ - break; - } - *p = '\0'; - } - else - { - lt_fatal (__FILE__, __LINE__, - "error accessing file \"%s\": %s", - tmp_pathspec, nonnull (strerror (errno))); - } - } - XFREE (tmp_pathspec); - - if (!has_symlinks) - { - return xstrdup (pathspec); - } - - tmp_pathspec = realpath (pathspec, buf); - if (tmp_pathspec == 0) - { - lt_fatal (__FILE__, __LINE__, - "could not follow symlinks for %s", pathspec); - } - return xstrdup (tmp_pathspec); -#endif -} - -char * -strendzap (char *str, const char *pat) -{ - size_t len, patlen; - - assert (str != NULL); - assert (pat != NULL); - - len = strlen (str); - patlen = strlen (pat); - - if (patlen <= len) - { - str += len - patlen; - if (strcmp (str, pat) == 0) - *str = '\0'; - } - return str; -} - -void -lt_debugprintf (const char *file, int line, const char *fmt, ...) -{ - va_list args; - if (lt_debug) - { - (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); - va_start (args, fmt); - (void) vfprintf (stderr, fmt, args); - va_end (args); - } -} - -static void -lt_error_core (int exit_status, const char *file, - int line, const char *mode, - const char *message, va_list ap) -{ - fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); - vfprintf (stderr, message, ap); - fprintf (stderr, ".\n"); - - if (exit_status >= 0) - exit (exit_status); -} - -void -lt_fatal (const char *file, int line, const char *message, ...) -{ - va_list ap; - va_start (ap, message); - lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); - va_end (ap); -} - -static const char * -nonnull (const char *s) -{ - return s ? s : "(null)"; -} - -static const char * -nonempty (const char *s) -{ - return (s && !*s) ? "(empty)" : nonnull (s); -} - -void -lt_setenv (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_setenv) setting '%s' to '%s'\n", - nonnull (name), nonnull (value)); - { -#ifdef HAVE_SETENV - /* always make a copy, for consistency with !HAVE_SETENV */ - char *str = xstrdup (value); - setenv (name, str, 1); -#else - int len = strlen (name) + 1 + strlen (value) + 1; - char *str = XMALLOC (char, len); - sprintf (str, "%s=%s", name, value); - if (putenv (str) != EXIT_SUCCESS) - { - XFREE (str); - } -#endif - } -} - -char * -lt_extend_str (const char *orig_value, const char *add, int to_end) -{ - char *new_value; - if (orig_value && *orig_value) - { - int orig_value_len = strlen (orig_value); - int add_len = strlen (add); - new_value = XMALLOC (char, add_len + orig_value_len + 1); - if (to_end) - { - strcpy (new_value, orig_value); - strcpy (new_value + orig_value_len, add); - } - else - { - strcpy (new_value, add); - strcpy (new_value + add_len, orig_value); - } - } - else - { - new_value = xstrdup (add); - } - return new_value; -} - -void -lt_update_exe_path (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", - nonnull (name), nonnull (value)); - - if (name && *name && value && *value) - { - char *new_value = lt_extend_str (getenv (name), value, 0); - /* some systems can't cope with a ':'-terminated path #' */ - int len = strlen (new_value); - while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) - { - new_value[len-1] = '\0'; - } - lt_setenv (name, new_value); - XFREE (new_value); - } -} - -void -lt_update_lib_path (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", - nonnull (name), nonnull (value)); - - if (name && *name && value && *value) - { - char *new_value = lt_extend_str (getenv (name), value, 0); - lt_setenv (name, new_value); - XFREE (new_value); - } -} - -EOF - case $host_os in - mingw*) - cat <<"EOF" - -/* Prepares an argument vector before calling spawn(). - Note that spawn() does not by itself call the command interpreter - (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : - ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&v); - v.dwPlatformId == VER_PLATFORM_WIN32_NT; - }) ? "cmd.exe" : "command.com"). - Instead it simply concatenates the arguments, separated by ' ', and calls - CreateProcess(). We must quote the arguments since Win32 CreateProcess() - interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a - special way: - - Space and tab are interpreted as delimiters. They are not treated as - delimiters if they are surrounded by double quotes: "...". - - Unescaped double quotes are removed from the input. Their only effect is - that within double quotes, space and tab are treated like normal - characters. - - Backslashes not followed by double quotes are not special. - - But 2*n+1 backslashes followed by a double quote become - n backslashes followed by a double quote (n >= 0): - \" -> " - \\\" -> \" - \\\\\" -> \\" - */ -#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" -#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" -char ** -prepare_spawn (char **argv) -{ - size_t argc; - char **new_argv; - size_t i; - - /* Count number of arguments. */ - for (argc = 0; argv[argc] != NULL; argc++) - ; - - /* Allocate new argument vector. */ - new_argv = XMALLOC (char *, argc + 1); - - /* Put quoted arguments into the new argument vector. */ - for (i = 0; i < argc; i++) - { - const char *string = argv[i]; - - if (string[0] == '\0') - new_argv[i] = xstrdup ("\"\""); - else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) - { - int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); - size_t length; - unsigned int backslashes; - const char *s; - char *quoted_string; - char *p; - - length = 0; - backslashes = 0; - if (quote_around) - length++; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - length += backslashes + 1; - length++; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - length += backslashes + 1; - - quoted_string = XMALLOC (char, length + 1); - - p = quoted_string; - backslashes = 0; - if (quote_around) - *p++ = '"'; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - { - unsigned int j; - for (j = backslashes + 1; j > 0; j--) - *p++ = '\\'; - } - *p++ = c; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - { - unsigned int j; - for (j = backslashes; j > 0; j--) - *p++ = '\\'; - *p++ = '"'; - } - *p = '\0'; - - new_argv[i] = quoted_string; - } - else - new_argv[i] = (char *) string; - } - new_argv[argc] = NULL; - - return new_argv; -} -EOF - ;; - esac - - cat <<"EOF" -void lt_dump_script (FILE* f) -{ -EOF - func_emit_wrapper yes | - $SED -n -e ' -s/^\(.\{79\}\)\(..*\)/\1\ -\2/ -h -s/\([\\"]\)/\\\1/g -s/$/\\n/ -s/\([^\n]*\).*/ fputs ("\1", f);/p -g -D' - cat <<"EOF" -} -EOF -} -# end: func_emit_cwrapperexe_src - -# func_win32_import_lib_p ARG -# True if ARG is an import lib, as indicated by $file_magic_cmd -func_win32_import_lib_p () -{ - $opt_debug - case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in - *import*) : ;; - *) false ;; - esac -} - -# func_mode_link arg... -func_mode_link () -{ - $opt_debug - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - # It is impossible to link a dll without this setting, and - # we shouldn't force the makefile maintainer to figure out - # which system we are compiling for in order to pass an extra - # flag for every libtool invocation. - # allow_undefined=no - - # FIXME: Unfortunately, there are problems with the above when trying - # to make a dll which has undefined symbols, in which case not - # even a static library is built. For now, we need to specify - # -no-undefined on the libtool link line when we can be certain - # that all symbols are satisfied, otherwise we get a static library. - allow_undefined=yes - ;; - *) - allow_undefined=yes - ;; - esac - libtool_args=$nonopt - base_compile="$nonopt $@" - compile_command=$nonopt - finalize_command=$nonopt - - compile_rpath= - finalize_rpath= - compile_shlibpath= - finalize_shlibpath= - convenience= - old_convenience= - deplibs= - old_deplibs= - compiler_flags= - linker_flags= - dllsearchpath= - lib_search_path=`pwd` - inst_prefix_dir= - new_inherited_linker_flags= - - avoid_version=no - bindir= - dlfiles= - dlprefiles= - dlself=no - export_dynamic=no - export_symbols= - export_symbols_regex= - generated= - libobjs= - ltlibs= - module=no - no_install=no - objs= - non_pic_objects= - precious_files_regex= - prefer_static_libs=no - preload=no - prev= - prevarg= - release= - rpath= - xrpath= - perm_rpath= - temp_rpath= - thread_safe=no - vinfo= - vinfo_number=no - weak_libs= - single_module="${wl}-single_module" - func_infer_tag $base_compile - - # We need to know -static, to get the right output filenames. - for arg - do - case $arg in - -shared) - test "$build_libtool_libs" != yes && \ - func_fatal_configuration "can not build a shared library" - build_old_libs=no - break - ;; - -all-static | -static | -static-libtool-libs) - case $arg in - -all-static) - if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then - func_warning "complete static linking is impossible in this configuration" - fi - if test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=yes - ;; - -static) - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=built - ;; - -static-libtool-libs) - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=yes - ;; - esac - build_libtool_libs=no - build_old_libs=yes - break - ;; - esac - done - - # See if our shared archives depend on static archives. - test -n "$old_archive_from_new_cmds" && build_old_libs=yes - - # Go through the arguments, transforming them on the way. - while test "$#" -gt 0; do - arg="$1" - shift - func_quote_for_eval "$arg" - qarg=$func_quote_for_eval_unquoted_result - func_append libtool_args " $func_quote_for_eval_result" - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - output) - func_append compile_command " @OUTPUT@" - func_append finalize_command " @OUTPUT@" - ;; - esac - - case $prev in - bindir) - bindir="$arg" - prev= - continue - ;; - dlfiles|dlprefiles) - if test "$preload" = no; then - # Add the symbol object into the linking commands. - func_append compile_command " @SYMFILE@" - func_append finalize_command " @SYMFILE@" - preload=yes - fi - case $arg in - *.la | *.lo) ;; # We handle these cases below. - force) - if test "$dlself" = no; then - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - self) - if test "$prev" = dlprefiles; then - dlself=yes - elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then - dlself=yes - else - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - *) - if test "$prev" = dlfiles; then - func_append dlfiles " $arg" - else - func_append dlprefiles " $arg" - fi - prev= - continue - ;; - esac - ;; - expsyms) - export_symbols="$arg" - test -f "$arg" \ - || func_fatal_error "symbol file \`$arg' does not exist" - prev= - continue - ;; - expsyms_regex) - export_symbols_regex="$arg" - prev= - continue - ;; - framework) - case $host in - *-*-darwin*) - case "$deplibs " in - *" $qarg.ltframework "*) ;; - *) func_append deplibs " $qarg.ltframework" # this is fixed later - ;; - esac - ;; - esac - prev= - continue - ;; - inst_prefix) - inst_prefix_dir="$arg" - prev= - continue - ;; - objectlist) - if test -f "$arg"; then - save_arg=$arg - moreargs= - for fil in `cat "$save_arg"` - do -# func_append moreargs " $fil" - arg=$fil - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if func_lalib_unsafe_p "$arg"; then - pic_object= - non_pic_object= - - # Read the .lo file - func_source "$arg" - - if test -z "$pic_object" || - test -z "$non_pic_object" || - test "$pic_object" = none && - test "$non_pic_object" = none; then - func_fatal_error "cannot find name of object for \`$arg'" - fi - - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - func_append dlfiles " $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - func_append dlprefiles " $pic_object" - prev= - fi - - # A PIC object. - func_append libobjs " $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - func_append non_pic_objects " $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - else - # If the PIC object exists, use it instead. - # $xdir was prepended to $pic_object above. - non_pic_object="$pic_object" - func_append non_pic_objects " $non_pic_object" - fi - else - # Only an error if not doing a dry-run. - if $opt_dry_run; then - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - func_lo2o "$arg" - pic_object=$xdir$objdir/$func_lo2o_result - non_pic_object=$xdir$func_lo2o_result - func_append libobjs " $pic_object" - func_append non_pic_objects " $non_pic_object" - else - func_fatal_error "\`$arg' is not a valid libtool object" - fi - fi - done - else - func_fatal_error "link input file \`$arg' does not exist" - fi - arg=$save_arg - prev= - continue - ;; - precious_regex) - precious_files_regex="$arg" - prev= - continue - ;; - release) - release="-$arg" - prev= - continue - ;; - rpath | xrpath) - # We need an absolute path. - case $arg in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - func_fatal_error "only absolute run-paths are allowed" - ;; - esac - if test "$prev" = rpath; then - case "$rpath " in - *" $arg "*) ;; - *) func_append rpath " $arg" ;; - esac - else - case "$xrpath " in - *" $arg "*) ;; - *) func_append xrpath " $arg" ;; - esac - fi - prev= - continue - ;; - shrext) - shrext_cmds="$arg" - prev= - continue - ;; - weak) - func_append weak_libs " $arg" - prev= - continue - ;; - xcclinker) - func_append linker_flags " $qarg" - func_append compiler_flags " $qarg" - prev= - func_append compile_command " $qarg" - func_append finalize_command " $qarg" - continue - ;; - xcompiler) - func_append compiler_flags " $qarg" - prev= - func_append compile_command " $qarg" - func_append finalize_command " $qarg" - continue - ;; - xlinker) - func_append linker_flags " $qarg" - func_append compiler_flags " $wl$qarg" - prev= - func_append compile_command " $wl$qarg" - func_append finalize_command " $wl$qarg" - continue - ;; - *) - eval "$prev=\"\$arg\"" - prev= - continue - ;; - esac - fi # test -n "$prev" - - prevarg="$arg" - - case $arg in - -all-static) - if test -n "$link_static_flag"; then - # See comment for -static flag below, for more details. - func_append compile_command " $link_static_flag" - func_append finalize_command " $link_static_flag" - fi - continue - ;; - - -allow-undefined) - # FIXME: remove this flag sometime in the future. - func_fatal_error "\`-allow-undefined' must not be used because it is the default" - ;; - - -avoid-version) - avoid_version=yes - continue - ;; - - -bindir) - prev=bindir - continue - ;; - - -dlopen) - prev=dlfiles - continue - ;; - - -dlpreopen) - prev=dlprefiles - continue - ;; - - -export-dynamic) - export_dynamic=yes - continue - ;; - - -export-symbols | -export-symbols-regex) - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - func_fatal_error "more than one -exported-symbols argument is not allowed" - fi - if test "X$arg" = "X-export-symbols"; then - prev=expsyms - else - prev=expsyms_regex - fi - continue - ;; - - -framework) - prev=framework - continue - ;; - - -inst-prefix-dir) - prev=inst_prefix - continue - ;; - - # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* - # so, if we see these flags be careful not to treat them like -L - -L[A-Z][A-Z]*:*) - case $with_gcc/$host in - no/*-*-irix* | /*-*-irix*) - func_append compile_command " $arg" - func_append finalize_command " $arg" - ;; - esac - continue - ;; - - -L*) - func_stripname "-L" '' "$arg" - if test -z "$func_stripname_result"; then - if test "$#" -gt 0; then - func_fatal_error "require no space between \`-L' and \`$1'" - else - func_fatal_error "need path for \`-L' option" - fi - fi - func_resolve_sysroot "$func_stripname_result" - dir=$func_resolve_sysroot_result - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - absdir=`cd "$dir" && pwd` - test -z "$absdir" && \ - func_fatal_error "cannot determine absolute directory name of \`$dir'" - dir="$absdir" - ;; - esac - case "$deplibs " in - *" -L$dir "* | *" $arg "*) - # Will only happen for absolute or sysroot arguments - ;; - *) - # Preserve sysroot, but never include relative directories - case $dir in - [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; - *) func_append deplibs " -L$dir" ;; - esac - func_append lib_search_path " $dir" - ;; - esac - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` - case :$dllsearchpath: in - *":$dir:"*) ;; - ::) dllsearchpath=$dir;; - *) func_append dllsearchpath ":$dir";; - esac - case :$dllsearchpath: in - *":$testbindir:"*) ;; - ::) dllsearchpath=$testbindir;; - *) func_append dllsearchpath ":$testbindir";; - esac - ;; - esac - continue - ;; - - -l*) - if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) - # These systems don't actually have a C or math library (as such) - continue - ;; - *-*-os2*) - # These systems don't actually have a C library (as such) - test "X$arg" = "X-lc" && continue - ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C and math libraries are in the System framework - func_append deplibs " System.ltframework" - continue - ;; - *-*-sco3.2v5* | *-*-sco5v6*) - # Causes problems with __ctype - test "X$arg" = "X-lc" && continue - ;; - *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) - # Compiler inserts libc in the correct place for threads to work - test "X$arg" = "X-lc" && continue - ;; - esac - elif test "X$arg" = "X-lc_r"; then - case $host in - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc_r directly, use -pthread flag. - continue - ;; - esac - fi - func_append deplibs " $arg" - continue - ;; - - -module) - module=yes - continue - ;; - - # Tru64 UNIX uses -model [arg] to determine the layout of C++ - # classes, name mangling, and exception handling. - # Darwin uses the -arch flag to determine output architecture. - -model|-arch|-isysroot|--sysroot) - func_append compiler_flags " $arg" - func_append compile_command " $arg" - func_append finalize_command " $arg" - prev=xcompiler - continue - ;; - - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) - func_append compiler_flags " $arg" - func_append compile_command " $arg" - func_append finalize_command " $arg" - case "$new_inherited_linker_flags " in - *" $arg "*) ;; - * ) func_append new_inherited_linker_flags " $arg" ;; - esac - continue - ;; - - -multi_module) - single_module="${wl}-multi_module" - continue - ;; - - -no-fast-install) - fast_install=no - continue - ;; - - -no-install) - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) - # The PATH hackery in wrapper scripts is required on Windows - # and Darwin in order for the loader to find any dlls it needs. - func_warning "\`-no-install' is ignored for $host" - func_warning "assuming \`-no-fast-install' instead" - fast_install=no - ;; - *) no_install=yes ;; - esac - continue - ;; - - -no-undefined) - allow_undefined=no - continue - ;; - - -objectlist) - prev=objectlist - continue - ;; - - -o) prev=output ;; - - -precious-files-regex) - prev=precious_regex - continue - ;; - - -release) - prev=release - continue - ;; - - -rpath) - prev=rpath - continue - ;; - - -R) - prev=xrpath - continue - ;; - - -R*) - func_stripname '-R' '' "$arg" - dir=$func_stripname_result - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - =*) - func_stripname '=' '' "$dir" - dir=$lt_sysroot$func_stripname_result - ;; - *) - func_fatal_error "only absolute run-paths are allowed" - ;; - esac - case "$xrpath " in - *" $dir "*) ;; - *) func_append xrpath " $dir" ;; - esac - continue - ;; - - -shared) - # The effects of -shared are defined in a previous loop. - continue - ;; - - -shrext) - prev=shrext - continue - ;; - - -static | -static-libtool-libs) - # The effects of -static are defined in a previous loop. - # We used to do the same as -all-static on platforms that - # didn't have a PIC flag, but the assumption that the effects - # would be equivalent was wrong. It would break on at least - # Digital Unix and AIX. - continue - ;; - - -thread-safe) - thread_safe=yes - continue - ;; - - -version-info) - prev=vinfo - continue - ;; - - -version-number) - prev=vinfo - vinfo_number=yes - continue - ;; - - -weak) - prev=weak - continue - ;; - - -Wc,*) - func_stripname '-Wc,' '' "$arg" - args=$func_stripname_result - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - func_quote_for_eval "$flag" - func_append arg " $func_quote_for_eval_result" - func_append compiler_flags " $func_quote_for_eval_result" - done - IFS="$save_ifs" - func_stripname ' ' '' "$arg" - arg=$func_stripname_result - ;; - - -Wl,*) - func_stripname '-Wl,' '' "$arg" - args=$func_stripname_result - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - func_quote_for_eval "$flag" - func_append arg " $wl$func_quote_for_eval_result" - func_append compiler_flags " $wl$func_quote_for_eval_result" - func_append linker_flags " $func_quote_for_eval_result" - done - IFS="$save_ifs" - func_stripname ' ' '' "$arg" - arg=$func_stripname_result - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Xlinker) - prev=xlinker - continue - ;; - - -XCClinker) - prev=xcclinker - continue - ;; - - # -msg_* for osf cc - -msg_*) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - - # Flags to be passed through unchanged, with rationale: - # -64, -mips[0-9] enable 64-bit mode for the SGI compiler - # -r[0-9][0-9]* specify processor for the SGI compiler - # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler - # +DA*, +DD* enable 64-bit mode for the HP compiler - # -q* compiler args for the IBM compiler - # -m*, -t[45]*, -txscale* architecture-specific flags for GCC - # -F/path path to uninstalled frameworks, gcc on darwin - # -p, -pg, --coverage, -fprofile-* profiling flags for GCC - # @file GCC response files - # -tp=* Portland pgcc target processor selection - # --sysroot=* for sysroot support - # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization - # -stdlib=* select c++ std lib with clang - -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ - -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ - -O*|-flto*|-fwhopr*|-fuse-linker-plugin|-stdlib=*) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - func_append compile_command " $arg" - func_append finalize_command " $arg" - func_append compiler_flags " $arg" - continue - ;; - - # Some other compiler flag. - -* | +*) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - - *.$objext) - # A standard object. - func_append objs " $arg" - ;; - - *.lo) - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if func_lalib_unsafe_p "$arg"; then - pic_object= - non_pic_object= - - # Read the .lo file - func_source "$arg" - - if test -z "$pic_object" || - test -z "$non_pic_object" || - test "$pic_object" = none && - test "$non_pic_object" = none; then - func_fatal_error "cannot find name of object for \`$arg'" - fi - - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - func_append dlfiles " $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - func_append dlprefiles " $pic_object" - prev= - fi - - # A PIC object. - func_append libobjs " $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - func_append non_pic_objects " $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - else - # If the PIC object exists, use it instead. - # $xdir was prepended to $pic_object above. - non_pic_object="$pic_object" - func_append non_pic_objects " $non_pic_object" - fi - else - # Only an error if not doing a dry-run. - if $opt_dry_run; then - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - func_lo2o "$arg" - pic_object=$xdir$objdir/$func_lo2o_result - non_pic_object=$xdir$func_lo2o_result - func_append libobjs " $pic_object" - func_append non_pic_objects " $non_pic_object" - else - func_fatal_error "\`$arg' is not a valid libtool object" - fi - fi - ;; - - *.$libext) - # An archive. - func_append deplibs " $arg" - func_append old_deplibs " $arg" - continue - ;; - - *.la) - # A libtool-controlled library. - - func_resolve_sysroot "$arg" - if test "$prev" = dlfiles; then - # This library was specified with -dlopen. - func_append dlfiles " $func_resolve_sysroot_result" - prev= - elif test "$prev" = dlprefiles; then - # The library was specified with -dlpreopen. - func_append dlprefiles " $func_resolve_sysroot_result" - prev= - else - func_append deplibs " $func_resolve_sysroot_result" - fi - continue - ;; - - # Some other compiler argument. - *) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - esac # arg - - # Now actually substitute the argument into the commands. - if test -n "$arg"; then - func_append compile_command " $arg" - func_append finalize_command " $arg" - fi - done # argument parsing loop - - test -n "$prev" && \ - func_fatal_help "the \`$prevarg' option requires an argument" - - if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then - eval arg=\"$export_dynamic_flag_spec\" - func_append compile_command " $arg" - func_append finalize_command " $arg" - fi - - oldlibs= - # calculate the name of the file, without its directory - func_basename "$output" - outputname="$func_basename_result" - libobjs_save="$libobjs" - - if test -n "$shlibpath_var"; then - # get the directories listed in $shlibpath_var - eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` - else - shlib_search_path= - fi - eval sys_lib_search_path=\"$sys_lib_search_path_spec\" - eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" - - func_dirname "$output" "/" "" - output_objdir="$func_dirname_result$objdir" - func_to_tool_file "$output_objdir/" - tool_output_objdir=$func_to_tool_file_result - # Create the object directory. - func_mkdir_p "$output_objdir" - - # Determine the type of output - case $output in - "") - func_fatal_help "you must specify an output file" - ;; - *.$libext) linkmode=oldlib ;; - *.lo | *.$objext) linkmode=obj ;; - *.la) linkmode=lib ;; - *) linkmode=prog ;; # Anything else should be a program. - esac - - specialdeplibs= - - libs= - # Find all interdependent deplibs by searching for libraries - # that are linked more than once (e.g. -la -lb -la) - for deplib in $deplibs; do - if $opt_preserve_dup_deps ; then - case "$libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; - esac - fi - func_append libs " $deplib" - done - - if test "$linkmode" = lib; then - libs="$predeps $libs $compiler_lib_search_path $postdeps" - - # Compute libraries that are listed more than once in $predeps - # $postdeps and mark them as special (i.e., whose duplicates are - # not to be eliminated). - pre_post_deps= - if $opt_duplicate_compiler_generated_deps; then - for pre_post_dep in $predeps $postdeps; do - case "$pre_post_deps " in - *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; - esac - func_append pre_post_deps " $pre_post_dep" - done - fi - pre_post_deps= - fi - - deplibs= - newdependency_libs= - newlib_search_path= - need_relink=no # whether we're linking any uninstalled libtool libraries - notinst_deplibs= # not-installed libtool libraries - notinst_path= # paths that contain not-installed libtool libraries - - case $linkmode in - lib) - passes="conv dlpreopen link" - for file in $dlfiles $dlprefiles; do - case $file in - *.la) ;; - *) - func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" - ;; - esac - done - ;; - prog) - compile_deplibs= - finalize_deplibs= - alldeplibs=no - newdlfiles= - newdlprefiles= - passes="conv scan dlopen dlpreopen link" - ;; - *) passes="conv" - ;; - esac - - for pass in $passes; do - # The preopen pass in lib mode reverses $deplibs; put it back here - # so that -L comes before libs that need it for instance... - if test "$linkmode,$pass" = "lib,link"; then - ## FIXME: Find the place where the list is rebuilt in the wrong - ## order, and fix it there properly - tmp_deplibs= - for deplib in $deplibs; do - tmp_deplibs="$deplib $tmp_deplibs" - done - deplibs="$tmp_deplibs" - fi - - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan"; then - libs="$deplibs" - deplibs= - fi - if test "$linkmode" = prog; then - case $pass in - dlopen) libs="$dlfiles" ;; - dlpreopen) libs="$dlprefiles" ;; - link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; - esac - fi - if test "$linkmode,$pass" = "lib,dlpreopen"; then - # Collect and forward deplibs of preopened libtool libs - for lib in $dlprefiles; do - # Ignore non-libtool-libs - dependency_libs= - func_resolve_sysroot "$lib" - case $lib in - *.la) func_source "$func_resolve_sysroot_result" ;; - esac - - # Collect preopened libtool deplibs, except any this library - # has declared as weak libs - for deplib in $dependency_libs; do - func_basename "$deplib" - deplib_base=$func_basename_result - case " $weak_libs " in - *" $deplib_base "*) ;; - *) func_append deplibs " $deplib" ;; - esac - done - done - libs="$dlprefiles" - fi - if test "$pass" = dlopen; then - # Collect dlpreopened libraries - save_deplibs="$deplibs" - deplibs= - fi - - for deplib in $libs; do - lib= - found=no - case $deplib in - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - func_append compiler_flags " $deplib" - if test "$linkmode" = lib ; then - case "$new_inherited_linker_flags " in - *" $deplib "*) ;; - * ) func_append new_inherited_linker_flags " $deplib" ;; - esac - fi - fi - continue - ;; - -l*) - if test "$linkmode" != lib && test "$linkmode" != prog; then - func_warning "\`-l' is ignored for archives/objects" - continue - fi - func_stripname '-l' '' "$deplib" - name=$func_stripname_result - if test "$linkmode" = lib; then - searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" - else - searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" - fi - for searchdir in $searchdirs; do - for search_ext in .la $std_shrext .so .a; do - # Search the libtool library - lib="$searchdir/lib${name}${search_ext}" - if test -f "$lib"; then - if test "$search_ext" = ".la"; then - found=yes - else - found=no - fi - break 2 - fi - done - done - if test "$found" != yes; then - # deplib doesn't seem to be a libtool library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - else # deplib is a libtool library - # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, - # We need to do some special things here, and not later. - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $deplib "*) - if func_lalib_p "$lib"; then - library_names= - old_library= - func_source "$lib" - for l in $old_library $library_names; do - ll="$l" - done - if test "X$ll" = "X$old_library" ; then # only static version available - found=no - func_dirname "$lib" "" "." - ladir="$func_dirname_result" - lib=$ladir/$old_library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - fi - fi - ;; - *) ;; - esac - fi - fi - ;; # -l - *.ltframework) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - if test "$linkmode" = lib ; then - case "$new_inherited_linker_flags " in - *" $deplib "*) ;; - * ) func_append new_inherited_linker_flags " $deplib" ;; - esac - fi - fi - continue - ;; - -L*) - case $linkmode in - lib) - deplibs="$deplib $deplibs" - test "$pass" = conv && continue - newdependency_libs="$deplib $newdependency_libs" - func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_result" - ;; - prog) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - if test "$pass" = scan; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_result" - ;; - *) - func_warning "\`-L' is ignored for archives/objects" - ;; - esac # linkmode - continue - ;; # -L - -R*) - if test "$pass" = link; then - func_stripname '-R' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - dir=$func_resolve_sysroot_result - # Make sure the xrpath contains only unique directories. - case "$xrpath " in - *" $dir "*) ;; - *) func_append xrpath " $dir" ;; - esac - fi - deplibs="$deplib $deplibs" - continue - ;; - *.la) - func_resolve_sysroot "$deplib" - lib=$func_resolve_sysroot_result - ;; - *.$libext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - case $linkmode in - lib) - # Linking convenience modules into shared libraries is allowed, - # but linking other static libraries is non-portable. - case " $dlpreconveniencelibs " in - *" $deplib "*) ;; - *) - valid_a_lib=no - case $deplibs_check_method in - match_pattern*) - set dummy $deplibs_check_method; shift - match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` - if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ - | $EGREP "$match_pattern_regex" > /dev/null; then - valid_a_lib=yes - fi - ;; - pass_all) - valid_a_lib=yes - ;; - esac - if test "$valid_a_lib" != yes; then - echo - $ECHO "*** Warning: Trying to link with static lib archive $deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because the file extensions .$libext of this argument makes me believe" - echo "*** that it is just a static archive that I should not use here." - else - echo - $ECHO "*** Warning: Linking the shared library $output against the" - $ECHO "*** static library $deplib is not portable!" - deplibs="$deplib $deplibs" - fi - ;; - esac - continue - ;; - prog) - if test "$pass" != link; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - continue - ;; - esac # linkmode - ;; # *.$libext - *.lo | *.$objext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - elif test "$linkmode" = prog; then - if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlopen support or we're linking statically, - # we need to preload. - func_append newdlprefiles " $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - func_append newdlfiles " $deplib" - fi - fi - continue - ;; - %DEPLIBS%) - alldeplibs=yes - continue - ;; - esac # case $deplib - - if test "$found" = yes || test -f "$lib"; then : - else - func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" - fi - - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$lib" \ - || func_fatal_error "\`$lib' is not a valid libtool archive" - - func_dirname "$lib" "" "." - ladir="$func_dirname_result" - - dlname= - dlopen= - dlpreopen= - libdir= - library_names= - old_library= - inherited_linker_flags= - # If the library was installed with an old release of libtool, - # it will not redefine variables installed, or shouldnotlink - installed=yes - shouldnotlink=no - avoidtemprpath= - - - # Read the .la file - func_source "$lib" - - # Convert "-framework foo" to "foo.ltframework" - if test -n "$inherited_linker_flags"; then - tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` - for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do - case " $new_inherited_linker_flags " in - *" $tmp_inherited_linker_flag "*) ;; - *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; - esac - done - fi - dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan" || - { test "$linkmode" != prog && test "$linkmode" != lib; }; then - test -n "$dlopen" && func_append dlfiles " $dlopen" - test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" - fi - - if test "$pass" = conv; then - # Only check for convenience libraries - deplibs="$lib $deplibs" - if test -z "$libdir"; then - if test -z "$old_library"; then - func_fatal_error "cannot find name of link library for \`$lib'" - fi - # It is a libtool convenience library, so add in its objects. - func_append convenience " $ladir/$objdir/$old_library" - func_append old_convenience " $ladir/$objdir/$old_library" - elif test "$linkmode" != prog && test "$linkmode" != lib; then - func_fatal_error "\`$lib' is not a convenience library" - fi - tmp_libs= - for deplib in $dependency_libs; do - deplibs="$deplib $deplibs" - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; - esac - fi - func_append tmp_libs " $deplib" - done - continue - fi # $pass = conv - - - # Get the name of the library we link against. - linklib= - if test -n "$old_library" && - { test "$prefer_static_libs" = yes || - test "$prefer_static_libs,$installed" = "built,no"; }; then - linklib=$old_library - else - for l in $old_library $library_names; do - linklib="$l" - done - fi - if test -z "$linklib"; then - func_fatal_error "cannot find name of link library for \`$lib'" - fi - - # This library was specified with -dlopen. - if test "$pass" = dlopen; then - if test -z "$libdir"; then - func_fatal_error "cannot -dlopen a convenience library: \`$lib'" - fi - if test -z "$dlname" || - test "$dlopen_support" != yes || - test "$build_libtool_libs" = no; then - # If there is no dlname, no dlopen support or we're linking - # statically, we need to preload. We also need to preload any - # dependent libraries so libltdl's deplib preloader doesn't - # bomb out in the load deplibs phase. - func_append dlprefiles " $lib $dependency_libs" - else - func_append newdlfiles " $lib" - fi - continue - fi # $pass = dlopen - - # We need an absolute path. - case $ladir in - [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; - *) - abs_ladir=`cd "$ladir" && pwd` - if test -z "$abs_ladir"; then - func_warning "cannot determine absolute directory name of \`$ladir'" - func_warning "passing it literally to the linker, although it might fail" - abs_ladir="$ladir" - fi - ;; - esac - func_basename "$lib" - laname="$func_basename_result" - - # Find the relevant object directory and library name. - if test "X$installed" = Xyes; then - if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then - func_warning "library \`$lib' was moved." - dir="$ladir" - absdir="$abs_ladir" - libdir="$abs_ladir" - else - dir="$lt_sysroot$libdir" - absdir="$lt_sysroot$libdir" - fi - test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes - else - if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then - dir="$ladir" - absdir="$abs_ladir" - # Remove this search path later - func_append notinst_path " $abs_ladir" - else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" - # Remove this search path later - func_append notinst_path " $abs_ladir" - fi - fi # $installed = yes - func_stripname 'lib' '.la' "$laname" - name=$func_stripname_result - - # This library was specified with -dlpreopen. - if test "$pass" = dlpreopen; then - if test -z "$libdir" && test "$linkmode" = prog; then - func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" - fi - case "$host" in - # special handling for platforms with PE-DLLs. - *cygwin* | *mingw* | *cegcc* ) - # Linker will automatically link against shared library if both - # static and shared are present. Therefore, ensure we extract - # symbols from the import library if a shared library is present - # (otherwise, the dlopen module name will be incorrect). We do - # this by putting the import library name into $newdlprefiles. - # We recover the dlopen module name by 'saving' the la file - # name in a special purpose variable, and (later) extracting the - # dlname from the la file. - if test -n "$dlname"; then - func_tr_sh "$dir/$linklib" - eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" - func_append newdlprefiles " $dir/$linklib" - else - func_append newdlprefiles " $dir/$old_library" - # Keep a list of preopened convenience libraries to check - # that they are being used correctly in the link pass. - test -z "$libdir" && \ - func_append dlpreconveniencelibs " $dir/$old_library" - fi - ;; - * ) - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - func_append newdlprefiles " $dir/$old_library" - # Keep a list of preopened convenience libraries to check - # that they are being used correctly in the link pass. - test -z "$libdir" && \ - func_append dlpreconveniencelibs " $dir/$old_library" - # Otherwise, use the dlname, so that lt_dlopen finds it. - elif test -n "$dlname"; then - func_append newdlprefiles " $dir/$dlname" - else - func_append newdlprefiles " $dir/$linklib" - fi - ;; - esac - fi # $pass = dlpreopen - - if test -z "$libdir"; then - # Link the convenience library - if test "$linkmode" = lib; then - deplibs="$dir/$old_library $deplibs" - elif test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$dir/$old_library $compile_deplibs" - finalize_deplibs="$dir/$old_library $finalize_deplibs" - else - deplibs="$lib $deplibs" # used for prog,scan pass - fi - continue - fi - - - if test "$linkmode" = prog && test "$pass" != link; then - func_append newlib_search_path " $ladir" - deplibs="$lib $deplibs" - - linkalldeplibs=no - if test "$link_all_deplibs" != no || test -z "$library_names" || - test "$build_libtool_libs" = no; then - linkalldeplibs=yes - fi - - tmp_libs= - for deplib in $dependency_libs; do - case $deplib in - -L*) func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_result" - ;; - esac - # Need to link against all dependency_libs? - if test "$linkalldeplibs" = yes; then - deplibs="$deplib $deplibs" - else - # Need to hardcode shared library paths - # or/and link against static libraries - newdependency_libs="$deplib $newdependency_libs" - fi - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; - esac - fi - func_append tmp_libs " $deplib" - done # for deplib - continue - fi # $linkmode = prog... - - if test "$linkmode,$pass" = "prog,link"; then - if test -n "$library_names" && - { { test "$prefer_static_libs" = no || - test "$prefer_static_libs,$installed" = "built,yes"; } || - test -z "$old_library"; }; then - # We need to hardcode the library path - if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath:" in - *"$absdir:"*) ;; - *) func_append temp_rpath "$absdir:" ;; - esac - fi - - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) func_append compile_rpath " $absdir" ;; - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; - esac - ;; - esac - fi # $linkmode,$pass = prog,link... - - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - fi - - link_static=no # Whether the deplib will be linked statically - use_static_libs=$prefer_static_libs - if test "$use_static_libs" = built && test "$installed" = yes; then - use_static_libs=no - fi - if test -n "$library_names" && - { test "$use_static_libs" = no || test -z "$old_library"; }; then - case $host in - *cygwin* | *mingw* | *cegcc*) - # No point in relinking DLLs because paths are not encoded - func_append notinst_deplibs " $lib" - need_relink=no - ;; - *) - if test "$installed" = no; then - func_append notinst_deplibs " $lib" - need_relink=yes - fi - ;; - esac - # This is a shared library - - # Warn about portability, can't link against -module's on some - # systems (darwin). Don't bleat about dlopened modules though! - dlopenmodule="" - for dlpremoduletest in $dlprefiles; do - if test "X$dlpremoduletest" = "X$lib"; then - dlopenmodule="$dlpremoduletest" - break - fi - done - if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then - echo - if test "$linkmode" = prog; then - $ECHO "*** Warning: Linking the executable $output against the loadable module" - else - $ECHO "*** Warning: Linking the shared library $output against the loadable module" - fi - $ECHO "*** $linklib is not portable!" - fi - if test "$linkmode" = lib && - test "$hardcode_into_libs" = yes; then - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) func_append compile_rpath " $absdir" ;; - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; - esac - ;; - esac - fi - - if test -n "$old_archive_from_expsyms_cmds"; then - # figure out the soname - set dummy $library_names - shift - realname="$1" - shift - libname=`eval "\\$ECHO \"$libname_spec\""` - # use dlname if we got it. it's perfectly good, no? - if test -n "$dlname"; then - soname="$dlname" - elif test -n "$soname_spec"; then - # bleh windows - case $host in - *cygwin* | mingw* | *cegcc*) - func_arith $current - $age - major=$func_arith_result - versuffix="-$major" - ;; - esac - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - - # Make a new name for the extract_expsyms_cmds to use - soroot="$soname" - func_basename "$soroot" - soname="$func_basename_result" - func_stripname 'lib' '.dll' "$soname" - newlib=libimp-$func_stripname_result.a - - # If the library has no export list, then create one now - if test -f "$output_objdir/$soname-def"; then : - else - func_verbose "extracting exported symbol list from \`$soname'" - func_execute_cmds "$extract_expsyms_cmds" 'exit $?' - fi - - # Create $newlib - if test -f "$output_objdir/$newlib"; then :; else - func_verbose "generating import library for \`$soname'" - func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' - fi - # make sure the library variables are pointing to the new library - dir=$output_objdir - linklib=$newlib - fi # test -n "$old_archive_from_expsyms_cmds" - - if test "$linkmode" = prog || test "$opt_mode" != relink; then - add_shlibpath= - add_dir= - add= - lib_linked=yes - case $hardcode_action in - immediate | unsupported) - if test "$hardcode_direct" = no; then - add="$dir/$linklib" - case $host in - *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; - *-*-sysv4*uw2*) add_dir="-L$dir" ;; - *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ - *-*-unixware7*) add_dir="-L$dir" ;; - *-*-darwin* ) - # if the lib is a (non-dlopened) module then we can not - # link against it, someone is ignoring the earlier warnings - if /usr/bin/file -L $add 2> /dev/null | - $GREP ": [^:]* bundle" >/dev/null ; then - if test "X$dlopenmodule" != "X$lib"; then - $ECHO "*** Warning: lib $linklib is a module, not a shared library" - if test -z "$old_library" ; then - echo - echo "*** And there doesn't seem to be a static archive available" - echo "*** The link will probably fail, sorry" - else - add="$dir/$old_library" - fi - elif test -n "$old_library"; then - add="$dir/$old_library" - fi - fi - esac - elif test "$hardcode_minus_L" = no; then - case $host in - *-*-sunos*) add_shlibpath="$dir" ;; - esac - add_dir="-L$dir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = no; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - relink) - if test "$hardcode_direct" = yes && - test "$hardcode_direct_absolute" = no; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$absdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) - func_append add_dir " -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - *) lib_linked=no ;; - esac - - if test "$lib_linked" != yes; then - func_fatal_configuration "unsupported hardcode properties" - fi - - if test -n "$add_shlibpath"; then - case :$compile_shlibpath: in - *":$add_shlibpath:"*) ;; - *) func_append compile_shlibpath "$add_shlibpath:" ;; - esac - fi - if test "$linkmode" = prog; then - test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" - test -n "$add" && compile_deplibs="$add $compile_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - if test "$hardcode_direct" != yes && - test "$hardcode_minus_L" != yes && - test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) func_append finalize_shlibpath "$libdir:" ;; - esac - fi - fi - fi - - if test "$linkmode" = prog || test "$opt_mode" = relink; then - add_shlibpath= - add_dir= - add= - # Finalize command for both is simple: just hardcode it. - if test "$hardcode_direct" = yes && - test "$hardcode_direct_absolute" = no; then - add="$libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$libdir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) func_append finalize_shlibpath "$libdir:" ;; - esac - add="-l$name" - elif test "$hardcode_automatic" = yes; then - if test -n "$inst_prefix_dir" && - test -f "$inst_prefix_dir$libdir/$linklib" ; then - add="$inst_prefix_dir$libdir/$linklib" - else - add="$libdir/$linklib" - fi - else - # We cannot seem to hardcode it, guess we'll fake it. - add_dir="-L$libdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) - func_append add_dir " -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - fi - - if test "$linkmode" = prog; then - test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" - test -n "$add" && finalize_deplibs="$add $finalize_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - fi - fi - elif test "$linkmode" = prog; then - # Here we assume that one of hardcode_direct or hardcode_minus_L - # is not unsupported. This is valid on all known static and - # shared platforms. - if test "$hardcode_direct" != unsupported; then - test -n "$old_library" && linklib="$old_library" - compile_deplibs="$dir/$linklib $compile_deplibs" - finalize_deplibs="$dir/$linklib $finalize_deplibs" - else - compile_deplibs="-l$name -L$dir $compile_deplibs" - finalize_deplibs="-l$name -L$dir $finalize_deplibs" - fi - elif test "$build_libtool_libs" = yes; then - # Not a shared library - if test "$deplibs_check_method" != pass_all; then - # We're trying link a shared library against a static one - # but the system doesn't support it. - - # Just print a warning and add the library to dependency_libs so - # that the program can be linked against the static library. - echo - $ECHO "*** Warning: This system can not link to static lib archive $lib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." - if test "$module" = yes; then - echo "*** But as you try to build a module library, libtool will still create " - echo "*** a static module, that should work as long as the dlopening application" - echo "*** is linked with the -dlopen flag to resolve symbols at runtime." - if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - else - deplibs="$dir/$old_library $deplibs" - link_static=yes - fi - fi # link shared/static library? - - if test "$linkmode" = lib; then - if test -n "$dependency_libs" && - { test "$hardcode_into_libs" != yes || - test "$build_old_libs" = yes || - test "$link_static" = yes; }; then - # Extract -R from dependency_libs - temp_deplibs= - for libdir in $dependency_libs; do - case $libdir in - -R*) func_stripname '-R' '' "$libdir" - temp_xrpath=$func_stripname_result - case " $xrpath " in - *" $temp_xrpath "*) ;; - *) func_append xrpath " $temp_xrpath";; - esac;; - *) func_append temp_deplibs " $libdir";; - esac - done - dependency_libs="$temp_deplibs" - fi - - func_append newlib_search_path " $absdir" - # Link against this library - test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" - # ... and its dependency_libs - tmp_libs= - for deplib in $dependency_libs; do - newdependency_libs="$deplib $newdependency_libs" - case $deplib in - -L*) func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result";; - *) func_resolve_sysroot "$deplib" ;; - esac - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $func_resolve_sysroot_result "*) - func_append specialdeplibs " $func_resolve_sysroot_result" ;; - esac - fi - func_append tmp_libs " $func_resolve_sysroot_result" - done - - if test "$link_all_deplibs" != no; then - # Add the search paths of all dependency libraries - for deplib in $dependency_libs; do - path= - case $deplib in - -L*) path="$deplib" ;; - *.la) - func_resolve_sysroot "$deplib" - deplib=$func_resolve_sysroot_result - func_dirname "$deplib" "" "." - dir=$func_dirname_result - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - func_warning "cannot determine absolute directory name of \`$dir'" - absdir="$dir" - fi - ;; - esac - if $GREP "^installed=no" $deplib > /dev/null; then - case $host in - *-*-darwin*) - depdepl= - eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` - if test -n "$deplibrary_names" ; then - for tmp in $deplibrary_names ; do - depdepl=$tmp - done - if test -f "$absdir/$objdir/$depdepl" ; then - depdepl="$absdir/$objdir/$depdepl" - darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` - if test -z "$darwin_install_name"; then - darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` - fi - func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" - func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" - path= - fi - fi - ;; - *) - path="-L$absdir/$objdir" - ;; - esac - else - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - test -z "$libdir" && \ - func_fatal_error "\`$deplib' is not a valid libtool archive" - test "$absdir" != "$libdir" && \ - func_warning "\`$deplib' seems to be moved" - - path="-L$absdir" - fi - ;; - esac - case " $deplibs " in - *" $path "*) ;; - *) deplibs="$path $deplibs" ;; - esac - done - fi # link_all_deplibs != no - fi # linkmode = lib - done # for deplib in $libs - if test "$pass" = link; then - if test "$linkmode" = "prog"; then - compile_deplibs="$new_inherited_linker_flags $compile_deplibs" - finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" - else - compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - fi - fi - dependency_libs="$newdependency_libs" - if test "$pass" = dlpreopen; then - # Link the dlpreopened libraries before other libraries - for deplib in $save_deplibs; do - deplibs="$deplib $deplibs" - done - fi - if test "$pass" != dlopen; then - if test "$pass" != conv; then - # Make sure lib_search_path contains only unique directories. - lib_search_path= - for dir in $newlib_search_path; do - case "$lib_search_path " in - *" $dir "*) ;; - *) func_append lib_search_path " $dir" ;; - esac - done - newlib_search_path= - fi - - if test "$linkmode,$pass" != "prog,link"; then - vars="deplibs" - else - vars="compile_deplibs finalize_deplibs" - fi - for var in $vars dependency_libs; do - # Add libraries to $var in reverse order - eval tmp_libs=\"\$$var\" - new_libs= - for deplib in $tmp_libs; do - # FIXME: Pedantically, this is the right thing to do, so - # that some nasty dependency loop isn't accidentally - # broken: - #new_libs="$deplib $new_libs" - # Pragmatically, this seems to cause very few problems in - # practice: - case $deplib in - -L*) new_libs="$deplib $new_libs" ;; - -R*) ;; - *) - # And here is the reason: when a library appears more - # than once as an explicit dependence of a library, or - # is implicitly linked in more than once by the - # compiler, it is considered special, and multiple - # occurrences thereof are not removed. Compare this - # with having the same library being listed as a - # dependency of multiple other libraries: in this case, - # we know (pedantically, we assume) the library does not - # need to be listed more than once, so we keep only the - # last copy. This is not always right, but it is rare - # enough that we require users that really mean to play - # such unportable linking tricks to link the library - # using -Wl,-lname, so that libtool does not consider it - # for duplicate removal. - case " $specialdeplibs " in - *" $deplib "*) new_libs="$deplib $new_libs" ;; - *) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$deplib $new_libs" ;; - esac - ;; - esac - ;; - esac - done - tmp_libs= - for deplib in $new_libs; do - case $deplib in - -L*) - case " $tmp_libs " in - *" $deplib "*) ;; - *) func_append tmp_libs " $deplib" ;; - esac - ;; - *) func_append tmp_libs " $deplib" ;; - esac - done - eval $var=\"$tmp_libs\" - done # for var - fi - # Last step: remove runtime libs from dependency_libs - # (they stay in deplibs) - tmp_libs= - for i in $dependency_libs ; do - case " $predeps $postdeps $compiler_lib_search_path " in - *" $i "*) - i="" - ;; - esac - if test -n "$i" ; then - func_append tmp_libs " $i" - fi - done - dependency_libs=$tmp_libs - done # for pass - if test "$linkmode" = prog; then - dlfiles="$newdlfiles" - fi - if test "$linkmode" = prog || test "$linkmode" = lib; then - dlprefiles="$newdlprefiles" - fi - - case $linkmode in - oldlib) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - func_warning "\`-dlopen' is ignored for archives" - fi - - case " $deplibs" in - *\ -l* | *\ -L*) - func_warning "\`-l' and \`-L' are ignored for archives" ;; - esac - - test -n "$rpath" && \ - func_warning "\`-rpath' is ignored for archives" - - test -n "$xrpath" && \ - func_warning "\`-R' is ignored for archives" - - test -n "$vinfo" && \ - func_warning "\`-version-info/-version-number' is ignored for archives" - - test -n "$release" && \ - func_warning "\`-release' is ignored for archives" - - test -n "$export_symbols$export_symbols_regex" && \ - func_warning "\`-export-symbols' is ignored for archives" - - # Now set the variables for building old libraries. - build_libtool_libs=no - oldlibs="$output" - func_append objs "$old_deplibs" - ;; - - lib) - # Make sure we only generate libraries of the form `libNAME.la'. - case $outputname in - lib*) - func_stripname 'lib' '.la' "$outputname" - name=$func_stripname_result - eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - ;; - *) - test "$module" = no && \ - func_fatal_help "libtool library \`$output' must begin with \`lib'" - - if test "$need_lib_prefix" != no; then - # Add the "lib" prefix for modules if required - func_stripname '' '.la' "$outputname" - name=$func_stripname_result - eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - else - func_stripname '' '.la' "$outputname" - libname=$func_stripname_result - fi - ;; - esac - - if test -n "$objs"; then - if test "$deplibs_check_method" != pass_all; then - func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" - else - echo - $ECHO "*** Warning: Linking the shared library $output against the non-libtool" - $ECHO "*** objects $objs is not portable!" - func_append libobjs " $objs" - fi - fi - - test "$dlself" != no && \ - func_warning "\`-dlopen self' is ignored for libtool libraries" - - set dummy $rpath - shift - test "$#" -gt 1 && \ - func_warning "ignoring multiple \`-rpath's for a libtool library" - - install_libdir="$1" - - oldlibs= - if test -z "$rpath"; then - if test "$build_libtool_libs" = yes; then - # Building a libtool convenience library. - # Some compilers have problems with a `.al' extension so - # convenience libraries should have the same extension an - # archive normally would. - oldlibs="$output_objdir/$libname.$libext $oldlibs" - build_libtool_libs=convenience - build_old_libs=yes - fi - - test -n "$vinfo" && \ - func_warning "\`-version-info/-version-number' is ignored for convenience libraries" - - test -n "$release" && \ - func_warning "\`-release' is ignored for convenience libraries" - else - - # Parse the version information argument. - save_ifs="$IFS"; IFS=':' - set dummy $vinfo 0 0 0 - shift - IFS="$save_ifs" - - test -n "$7" && \ - func_fatal_help "too many parameters to \`-version-info'" - - # convert absolute version numbers to libtool ages - # this retains compatibility with .la files and attempts - # to make the code below a bit more comprehensible - - case $vinfo_number in - yes) - number_major="$1" - number_minor="$2" - number_revision="$3" - # - # There are really only two kinds -- those that - # use the current revision as the major version - # and those that subtract age and use age as - # a minor version. But, then there is irix - # which has an extra 1 added just for fun - # - case $version_type in - # correct linux to gnu/linux during the next big refactor - darwin|linux|osf|windows|none) - func_arith $number_major + $number_minor - current=$func_arith_result - age="$number_minor" - revision="$number_revision" - ;; - freebsd-aout|freebsd-elf|qnx|sunos) - current="$number_major" - revision="$number_minor" - age="0" - ;; - irix|nonstopux) - func_arith $number_major + $number_minor - current=$func_arith_result - age="$number_minor" - revision="$number_minor" - lt_irix_increment=no - ;; - esac - ;; - no) - current="$1" - revision="$2" - age="$3" - ;; - esac - - # Check that each of the things are valid numbers. - case $current in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "CURRENT \`$current' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - case $revision in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "REVISION \`$revision' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - case $age in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "AGE \`$age' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - if test "$age" -gt "$current"; then - func_error "AGE \`$age' is greater than the current interface number \`$current'" - func_fatal_error "\`$vinfo' is not valid version information" - fi - - # Calculate the version variables. - major= - versuffix= - verstring= - case $version_type in - none) ;; - - darwin) - # Like Linux, but with the current version available in - # verstring for coding it into the library header - func_arith $current - $age - major=.$func_arith_result - versuffix="$major.$age.$revision" - # Darwin ld doesn't like 0 for these options... - func_arith $current + 1 - minor_current=$func_arith_result - xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" - verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" - ;; - - freebsd-aout) - major=".$current" - versuffix=".$current.$revision"; - ;; - - freebsd-elf) - major=".$current" - versuffix=".$current" - ;; - - irix | nonstopux) - if test "X$lt_irix_increment" = "Xno"; then - func_arith $current - $age - else - func_arith $current - $age + 1 - fi - major=$func_arith_result - - case $version_type in - nonstopux) verstring_prefix=nonstopux ;; - *) verstring_prefix=sgi ;; - esac - verstring="$verstring_prefix$major.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$revision - while test "$loop" -ne 0; do - func_arith $revision - $loop - iface=$func_arith_result - func_arith $loop - 1 - loop=$func_arith_result - verstring="$verstring_prefix$major.$iface:$verstring" - done - - # Before this point, $major must not contain `.'. - major=.$major - versuffix="$major.$revision" - ;; - - linux) # correct to gnu/linux during the next big refactor - func_arith $current - $age - major=.$func_arith_result - versuffix="$major.$age.$revision" - ;; - - osf) - func_arith $current - $age - major=.$func_arith_result - versuffix=".$current.$age.$revision" - verstring="$current.$age.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$age - while test "$loop" -ne 0; do - func_arith $current - $loop - iface=$func_arith_result - func_arith $loop - 1 - loop=$func_arith_result - verstring="$verstring:${iface}.0" - done - - # Make executables depend on our current version. - func_append verstring ":${current}.0" - ;; - - qnx) - major=".$current" - versuffix=".$current" - ;; - - sunos) - major=".$current" - versuffix=".$current.$revision" - ;; - - windows) - # Use '-' rather than '.', since we only want one - # extension on DOS 8.3 filesystems. - func_arith $current - $age - major=$func_arith_result - versuffix="-$major" - ;; - - *) - func_fatal_configuration "unknown library version type \`$version_type'" - ;; - esac - - # Clear the version info if we defaulted, and they specified a release. - if test -z "$vinfo" && test -n "$release"; then - major= - case $version_type in - darwin) - # we can't check for "0.0" in archive_cmds due to quoting - # problems, so we reset it completely - verstring= - ;; - *) - verstring="0.0" - ;; - esac - if test "$need_version" = no; then - versuffix= - else - versuffix=".0.0" - fi - fi - - # Remove version info from name if versioning should be avoided - if test "$avoid_version" = yes && test "$need_version" = no; then - major= - versuffix= - verstring="" - fi - - # Check to see if the archive will have undefined symbols. - if test "$allow_undefined" = yes; then - if test "$allow_undefined_flag" = unsupported; then - func_warning "undefined symbols not allowed in $host shared libraries" - build_libtool_libs=no - build_old_libs=yes - fi - else - # Don't allow undefined symbols. - allow_undefined_flag="$no_undefined_flag" - fi - - fi - - func_generate_dlsyms "$libname" "$libname" "yes" - func_append libobjs " $symfileobj" - test "X$libobjs" = "X " && libobjs= - - if test "$opt_mode" != relink; then - # Remove our outputs, but don't remove object files since they - # may have been created when compiling PIC objects. - removelist= - tempremovelist=`$ECHO "$output_objdir/*"` - for p in $tempremovelist; do - case $p in - *.$objext | *.gcno) - ;; - $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) - if test "X$precious_files_regex" != "X"; then - if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 - then - continue - fi - fi - func_append removelist " $p" - ;; - *) ;; - esac - done - test -n "$removelist" && \ - func_show_eval "${RM}r \$removelist" - fi - - # Now set the variables for building old libraries. - if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then - func_append oldlibs " $output_objdir/$libname.$libext" - - # Transform .lo files to .o files. - oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` - fi - - # Eliminate all temporary directories. - #for path in $notinst_path; do - # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` - # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` - # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` - #done - - if test -n "$xrpath"; then - # If the user specified any rpath flags, then add them. - temp_xrpath= - for libdir in $xrpath; do - func_replace_sysroot "$libdir" - func_append temp_xrpath " -R$func_replace_sysroot_result" - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; - esac - done - if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then - dependency_libs="$temp_xrpath $dependency_libs" - fi - fi - - # Make sure dlfiles contains only unique files that won't be dlpreopened - old_dlfiles="$dlfiles" - dlfiles= - for lib in $old_dlfiles; do - case " $dlprefiles $dlfiles " in - *" $lib "*) ;; - *) func_append dlfiles " $lib" ;; - esac - done - - # Make sure dlprefiles contains only unique files - old_dlprefiles="$dlprefiles" - dlprefiles= - for lib in $old_dlprefiles; do - case "$dlprefiles " in - *" $lib "*) ;; - *) func_append dlprefiles " $lib" ;; - esac - done - - if test "$build_libtool_libs" = yes; then - if test -n "$rpath"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) - # these systems don't actually have a c library (as such)! - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C library is in the System framework - func_append deplibs " System.ltframework" - ;; - *-*-netbsd*) - # Don't link with libc until the a.out ld.so is fixed. - ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc due to us having libc/libc_r. - ;; - *-*-sco3.2v5* | *-*-sco5v6*) - # Causes problems with __ctype - ;; - *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) - # Compiler inserts libc in the correct place for threads to work - ;; - *) - # Add libc to deplibs on all other systems if necessary. - if test "$build_libtool_need_lc" = "yes"; then - func_append deplibs " -lc" - fi - ;; - esac - fi - - # Transform deplibs into only deplibs that can be linked in shared. - name_save=$name - libname_save=$libname - release_save=$release - versuffix_save=$versuffix - major_save=$major - # I'm not sure if I'm treating the release correctly. I think - # release should show up in the -l (ie -lgmp5) so we don't want to - # add it in twice. Is that correct? - release="" - versuffix="" - major="" - newdeplibs= - droppeddeps=no - case $deplibs_check_method in - pass_all) - # Don't check for shared/static. Everything works. - # This might be a little naive. We might want to check - # whether the library exists or not. But this is on - # osf3 & osf4 and I'm not really sure... Just - # implementing what was already the behavior. - newdeplibs=$deplibs - ;; - test_compile) - # This code stresses the "libraries are programs" paradigm to its - # limits. Maybe even breaks it. We compile a program, linking it - # against the deplibs as a proxy for the library. Then we can check - # whether they linked in statically or dynamically with ldd. - $opt_dry_run || $RM conftest.c - cat > conftest.c </dev/null` - $nocaseglob - else - potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` - fi - for potent_lib in $potential_libs; do - # Follow soft links. - if ls -lLd "$potent_lib" 2>/dev/null | - $GREP " -> " >/dev/null; then - continue - fi - # The statement above tries to avoid entering an - # endless loop below, in case of cyclic links. - # We might still enter an endless loop, since a link - # loop can be closed while we follow links, - # but so what? - potlib="$potent_lib" - while test -h "$potlib" 2>/dev/null; do - potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` - case $potliblink in - [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; - *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; - esac - done - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | - $SED -e 10q | - $EGREP "$file_magic_regex" > /dev/null; then - func_append newdeplibs " $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - echo - $ECHO "*** Warning: linker path does not have real file for library $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $ECHO "*** with $libname but no candidates were found. (...for file magic test)" - else - $ECHO "*** with $libname and none of the candidates passed a file format test" - $ECHO "*** using a file magic. Last file checked: $potlib" - fi - fi - ;; - *) - # Add a -L argument. - func_append newdeplibs " $a_deplib" - ;; - esac - done # Gone through all deplibs. - ;; - match_pattern*) - set dummy $deplibs_check_method; shift - match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` - for a_deplib in $deplibs; do - case $a_deplib in - -l*) - func_stripname -l '' "$a_deplib" - name=$func_stripname_result - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $a_deplib "*) - func_append newdeplibs " $a_deplib" - a_deplib="" - ;; - esac - fi - if test -n "$a_deplib" ; then - libname=`eval "\\$ECHO \"$libname_spec\""` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do - potlib="$potent_lib" # see symlink-check above in file_magic test - if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ - $EGREP "$match_pattern_regex" > /dev/null; then - func_append newdeplibs " $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - echo - $ECHO "*** Warning: linker path does not have real file for library $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" - else - $ECHO "*** with $libname and none of the candidates passed a file format test" - $ECHO "*** using a regex pattern. Last file checked: $potlib" - fi - fi - ;; - *) - # Add a -L argument. - func_append newdeplibs " $a_deplib" - ;; - esac - done # Gone through all deplibs. - ;; - none | unknown | *) - newdeplibs="" - tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - for i in $predeps $postdeps ; do - # can't use Xsed below, because $i might contain '/' - tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` - done - fi - case $tmp_deplibs in - *[!\ \ ]*) - echo - if test "X$deplibs_check_method" = "Xnone"; then - echo "*** Warning: inter-library dependencies are not supported in this platform." - else - echo "*** Warning: inter-library dependencies are not known to be supported." - fi - echo "*** All declared inter-library dependencies are being dropped." - droppeddeps=yes - ;; - esac - ;; - esac - versuffix=$versuffix_save - major=$major_save - release=$release_save - libname=$libname_save - name=$name_save - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library with the System framework - newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` - ;; - esac - - if test "$droppeddeps" = yes; then - if test "$module" = yes; then - echo - echo "*** Warning: libtool could not satisfy all declared inter-library" - $ECHO "*** dependencies of module $libname. Therefore, libtool will create" - echo "*** a static module, that should work as long as the dlopening" - echo "*** application is linked with the -dlopen flag." - if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - else - echo "*** The inter-library dependencies that have been dropped here will be" - echo "*** automatically added whenever a program is linked with this library" - echo "*** or is declared to -dlopen it." - - if test "$allow_undefined" = no; then - echo - echo "*** Since this library must not contain undefined symbols," - echo "*** because either the platform does not support them or" - echo "*** it was explicitly requested with -no-undefined," - echo "*** libtool will only create a static version of it." - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - fi - fi - # Done checking deplibs! - deplibs=$newdeplibs - fi - # Time to change all our "foo.ltframework" stuff back to "-framework foo" - case $host in - *-*-darwin*) - newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - ;; - esac - - # move library search paths that coincide with paths to not yet - # installed libraries to the beginning of the library search list - new_libs= - for path in $notinst_path; do - case " $new_libs " in - *" -L$path/$objdir "*) ;; - *) - case " $deplibs " in - *" -L$path/$objdir "*) - func_append new_libs " -L$path/$objdir" ;; - esac - ;; - esac - done - for deplib in $deplibs; do - case $deplib in - -L*) - case " $new_libs " in - *" $deplib "*) ;; - *) func_append new_libs " $deplib" ;; - esac - ;; - *) func_append new_libs " $deplib" ;; - esac - done - deplibs="$new_libs" - - # All the library-specific variables (install_libdir is set above). - library_names= - old_library= - dlname= - - # Test again, we may have decided not to build it any more - if test "$build_libtool_libs" = yes; then - # Remove ${wl} instances when linking with ld. - # FIXME: should test the right _cmds variable. - case $archive_cmds in - *\$LD\ *) wl= ;; - esac - if test "$hardcode_into_libs" = yes; then - # Hardcode the library paths - hardcode_libdirs= - dep_rpath= - rpath="$finalize_rpath" - test "$opt_mode" != relink && rpath="$compile_rpath$rpath" - for libdir in $rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - func_replace_sysroot "$libdir" - libdir=$func_replace_sysroot_result - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append dep_rpath " $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) func_append perm_rpath " $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" - fi - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - func_append rpath "$dir:" - done - eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" - fi - test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" - fi - - shlibpath="$finalize_shlibpath" - test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" - if test -n "$shlibpath"; then - eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" - fi - - # Get the real and link names of the library. - eval shared_ext=\"$shrext_cmds\" - eval library_names=\"$library_names_spec\" - set dummy $library_names - shift - realname="$1" - shift - - if test -n "$soname_spec"; then - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - if test -z "$dlname"; then - dlname=$soname - fi - - lib="$output_objdir/$realname" - linknames= - for link - do - func_append linknames " $link" - done - - # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` - test "X$libobjs" = "X " && libobjs= - - delfiles= - if test -n "$export_symbols" && test -n "$include_expsyms"; then - $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" - export_symbols="$output_objdir/$libname.uexp" - func_append delfiles " $export_symbols" - fi - - orig_export_symbols= - case $host_os in - cygwin* | mingw* | cegcc*) - if test -n "$export_symbols" && test -z "$export_symbols_regex"; then - # exporting using user supplied symfile - if test "x`$SED 1q $export_symbols`" != xEXPORTS; then - # and it's NOT already a .def file. Must figure out - # which of the given symbols are data symbols and tag - # them as such. So, trigger use of export_symbols_cmds. - # export_symbols gets reassigned inside the "prepare - # the list of exported symbols" if statement, so the - # include_expsyms logic still works. - orig_export_symbols="$export_symbols" - export_symbols= - always_export_symbols=yes - fi - fi - ;; - esac - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then - func_verbose "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $opt_dry_run || $RM $export_symbols - cmds=$export_symbols_cmds - save_ifs="$IFS"; IFS='~' - for cmd1 in $cmds; do - IFS="$save_ifs" - # Take the normal branch if the nm_file_list_spec branch - # doesn't work or if tool conversion is not needed. - case $nm_file_list_spec~$to_tool_file_cmd in - *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) - try_normal_branch=yes - eval cmd=\"$cmd1\" - func_len " $cmd" - len=$func_len_result - ;; - *) - try_normal_branch=no - ;; - esac - if test "$try_normal_branch" = yes \ - && { test "$len" -lt "$max_cmd_len" \ - || test "$max_cmd_len" -le -1; } - then - func_show_eval "$cmd" 'exit $?' - skipped_export=false - elif test -n "$nm_file_list_spec"; then - func_basename "$output" - output_la=$func_basename_result - save_libobjs=$libobjs - save_output=$output - output=${output_objdir}/${output_la}.nm - func_to_tool_file "$output" - libobjs=$nm_file_list_spec$func_to_tool_file_result - func_append delfiles " $output" - func_verbose "creating $NM input file list: $output" - for obj in $save_libobjs; do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" - done > "$output" - eval cmd=\"$cmd1\" - func_show_eval "$cmd" 'exit $?' - output=$save_output - libobjs=$save_libobjs - skipped_export=false - else - # The command line is too long to execute in one step. - func_verbose "using reloadable object file for export list..." - skipped_export=: - # Break out early, otherwise skipped_export may be - # set to false by a later but shorter cmd. - break - fi - done - IFS="$save_ifs" - if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then - func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - func_show_eval '$MV "${export_symbols}T" "$export_symbols"' - fi - fi - fi - - if test -n "$export_symbols" && test -n "$include_expsyms"; then - tmp_export_symbols="$export_symbols" - test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" - $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' - fi - - if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then - # The given exports_symbols file has to be filtered, so filter it. - func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" - # FIXME: $output_objdir/$libname.filter potentially contains lots of - # 's' commands which not all seds can handle. GNU sed should be fine - # though. Also, the filter scales superlinearly with the number of - # global variables. join(1) would be nice here, but unfortunately - # isn't a blessed tool. - $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter - func_append delfiles " $export_symbols $output_objdir/$libname.filter" - export_symbols=$output_objdir/$libname.def - $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols - fi - - tmp_deplibs= - for test_deplib in $deplibs; do - case " $convenience " in - *" $test_deplib "*) ;; - *) - func_append tmp_deplibs " $test_deplib" - ;; - esac - done - deplibs="$tmp_deplibs" - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec" && - test "$compiler_needs_object" = yes && - test -z "$libobjs"; then - # extract the archives, so we have objects to list. - # TODO: could optimize this to just extract one archive. - whole_archive_flag_spec= - fi - if test -n "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - test "X$libobjs" = "X " && libobjs= - else - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - - func_extract_archives $gentop $convenience - func_append libobjs " $func_extract_archives_result" - test "X$libobjs" = "X " && libobjs= - fi - fi - - if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then - eval flag=\"$thread_safe_flag_spec\" - func_append linker_flags " $flag" - fi - - # Make a backup of the uninstalled library when relinking - if test "$opt_mode" = relink; then - $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? - fi - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - eval test_cmds=\"$module_expsym_cmds\" - cmds=$module_expsym_cmds - else - eval test_cmds=\"$module_cmds\" - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval test_cmds=\"$archive_expsym_cmds\" - cmds=$archive_expsym_cmds - else - eval test_cmds=\"$archive_cmds\" - cmds=$archive_cmds - fi - fi - - if test "X$skipped_export" != "X:" && - func_len " $test_cmds" && - len=$func_len_result && - test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then - : - else - # The command line is too long to link in one step, link piecewise - # or, if using GNU ld and skipped_export is not :, use a linker - # script. - - # Save the value of $output and $libobjs because we want to - # use them later. If we have whole_archive_flag_spec, we - # want to use save_libobjs as it was before - # whole_archive_flag_spec was expanded, because we can't - # assume the linker understands whole_archive_flag_spec. - # This may have to be revisited, in case too many - # convenience libraries get linked in and end up exceeding - # the spec. - if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - fi - save_output=$output - func_basename "$output" - output_la=$func_basename_result - - # Clear the reloadable object creation command queue and - # initialize k to one. - test_cmds= - concat_cmds= - objlist= - last_robj= - k=1 - - if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then - output=${output_objdir}/${output_la}.lnkscript - func_verbose "creating GNU ld script: $output" - echo 'INPUT (' > $output - for obj in $save_libobjs - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" >> $output - done - echo ')' >> $output - func_append delfiles " $output" - func_to_tool_file "$output" - output=$func_to_tool_file_result - elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then - output=${output_objdir}/${output_la}.lnk - func_verbose "creating linker input file list: $output" - : > $output - set x $save_libobjs - shift - firstobj= - if test "$compiler_needs_object" = yes; then - firstobj="$1 " - shift - fi - for obj - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" >> $output - done - func_append delfiles " $output" - func_to_tool_file "$output" - output=$firstobj\"$file_list_spec$func_to_tool_file_result\" - else - if test -n "$save_libobjs"; then - func_verbose "creating reloadable object files..." - output=$output_objdir/$output_la-${k}.$objext - eval test_cmds=\"$reload_cmds\" - func_len " $test_cmds" - len0=$func_len_result - len=$len0 - - # Loop over the list of objects to be linked. - for obj in $save_libobjs - do - func_len " $obj" - func_arith $len + $func_len_result - len=$func_arith_result - if test "X$objlist" = X || - test "$len" -lt "$max_cmd_len"; then - func_append objlist " $obj" - else - # The command $test_cmds is almost too long, add a - # command to the queue. - if test "$k" -eq 1 ; then - # The first file doesn't have a previous command to add. - reload_objs=$objlist - eval concat_cmds=\"$reload_cmds\" - else - # All subsequent reloadable object files will link in - # the last one created. - reload_objs="$objlist $last_robj" - eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" - fi - last_robj=$output_objdir/$output_la-${k}.$objext - func_arith $k + 1 - k=$func_arith_result - output=$output_objdir/$output_la-${k}.$objext - objlist=" $obj" - func_len " $last_robj" - func_arith $len0 + $func_len_result - len=$func_arith_result - fi - done - # Handle the remaining objects by creating one last - # reloadable object file. All subsequent reloadable object - # files will link in the last one created. - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - reload_objs="$objlist $last_robj" - eval concat_cmds=\"\${concat_cmds}$reload_cmds\" - if test -n "$last_robj"; then - eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" - fi - func_append delfiles " $output" - - else - output= - fi - - if ${skipped_export-false}; then - func_verbose "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $opt_dry_run || $RM $export_symbols - libobjs=$output - # Append the command to create the export file. - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" - if test -n "$last_robj"; then - eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" - fi - fi - - test -n "$save_libobjs" && - func_verbose "creating a temporary reloadable object file: $output" - - # Loop through the commands generated above and execute them. - save_ifs="$IFS"; IFS='~' - for cmd in $concat_cmds; do - IFS="$save_ifs" - $opt_silent || { - func_quote_for_expand "$cmd" - eval "func_echo $func_quote_for_expand_result" - } - $opt_dry_run || eval "$cmd" || { - lt_exit=$? - - # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then - ( cd "$output_objdir" && \ - $RM "${realname}T" && \ - $MV "${realname}U" "$realname" ) - fi - - exit $lt_exit - } - done - IFS="$save_ifs" - - if test -n "$export_symbols_regex" && ${skipped_export-false}; then - func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - func_show_eval '$MV "${export_symbols}T" "$export_symbols"' - fi - fi - - if ${skipped_export-false}; then - if test -n "$export_symbols" && test -n "$include_expsyms"; then - tmp_export_symbols="$export_symbols" - test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" - $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' - fi - - if test -n "$orig_export_symbols"; then - # The given exports_symbols file has to be filtered, so filter it. - func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" - # FIXME: $output_objdir/$libname.filter potentially contains lots of - # 's' commands which not all seds can handle. GNU sed should be fine - # though. Also, the filter scales superlinearly with the number of - # global variables. join(1) would be nice here, but unfortunately - # isn't a blessed tool. - $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter - func_append delfiles " $export_symbols $output_objdir/$libname.filter" - export_symbols=$output_objdir/$libname.def - $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols - fi - fi - - libobjs=$output - # Restore the value of output. - output=$save_output - - if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - test "X$libobjs" = "X " && libobjs= - fi - # Expand the library linking commands again to reset the - # value of $libobjs for piecewise linking. - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - cmds=$module_expsym_cmds - else - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - cmds=$archive_expsym_cmds - else - cmds=$archive_cmds - fi - fi - fi - - if test -n "$delfiles"; then - # Append the command to remove temporary files to $cmds. - eval cmds=\"\$cmds~\$RM $delfiles\" - fi - - # Add any objects from preloaded convenience libraries - if test -n "$dlprefiles"; then - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - - func_extract_archives $gentop $dlprefiles - func_append libobjs " $func_extract_archives_result" - test "X$libobjs" = "X " && libobjs= - fi - - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $opt_silent || { - func_quote_for_expand "$cmd" - eval "func_echo $func_quote_for_expand_result" - } - $opt_dry_run || eval "$cmd" || { - lt_exit=$? - - # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then - ( cd "$output_objdir" && \ - $RM "${realname}T" && \ - $MV "${realname}U" "$realname" ) - fi - - exit $lt_exit - } - done - IFS="$save_ifs" - - # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then - $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? - - if test -n "$convenience"; then - if test -z "$whole_archive_flag_spec"; then - func_show_eval '${RM}r "$gentop"' - fi - fi - - exit $EXIT_SUCCESS - fi - - # Create links to the real library. - for linkname in $linknames; do - if test "$realname" != "$linkname"; then - func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' - fi - done - - # If -module or -export-dynamic was specified, set the dlname. - if test "$module" = yes || test "$export_dynamic" = yes; then - # On all known operating systems, these are identical. - dlname="$soname" - fi - fi - ;; - - obj) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - func_warning "\`-dlopen' is ignored for objects" - fi - - case " $deplibs" in - *\ -l* | *\ -L*) - func_warning "\`-l' and \`-L' are ignored for objects" ;; - esac - - test -n "$rpath" && \ - func_warning "\`-rpath' is ignored for objects" - - test -n "$xrpath" && \ - func_warning "\`-R' is ignored for objects" - - test -n "$vinfo" && \ - func_warning "\`-version-info' is ignored for objects" - - test -n "$release" && \ - func_warning "\`-release' is ignored for objects" - - case $output in - *.lo) - test -n "$objs$old_deplibs" && \ - func_fatal_error "cannot build library object \`$output' from non-libtool objects" - - libobj=$output - func_lo2o "$libobj" - obj=$func_lo2o_result - ;; - *) - libobj= - obj="$output" - ;; - esac - - # Delete the old objects. - $opt_dry_run || $RM $obj $libobj - - # Objects from convenience libraries. This assumes - # single-version convenience libraries. Whenever we create - # different ones for PIC/non-PIC, this we'll have to duplicate - # the extraction. - reload_conv_objs= - gentop= - # reload_cmds runs $LD directly, so let us get rid of - # -Wl from whole_archive_flag_spec and hope we can get by with - # turning comma into space.. - wl= - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" - reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` - else - gentop="$output_objdir/${obj}x" - func_append generated " $gentop" - - func_extract_archives $gentop $convenience - reload_conv_objs="$reload_objs $func_extract_archives_result" - fi - fi - - # If we're not building shared, we need to use non_pic_objs - test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" - - # Create the old-style object. - reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test - - output="$obj" - func_execute_cmds "$reload_cmds" 'exit $?' - - # Exit if we aren't doing a library object file. - if test -z "$libobj"; then - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - exit $EXIT_SUCCESS - fi - - if test "$build_libtool_libs" != yes; then - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - # Create an invalid libtool object if no PIC, so that we don't - # accidentally link it into a program. - # $show "echo timestamp > $libobj" - # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? - exit $EXIT_SUCCESS - fi - - if test -n "$pic_flag" || test "$pic_mode" != default; then - # Only do commands if we really have different PIC objects. - reload_objs="$libobjs $reload_conv_objs" - output="$libobj" - func_execute_cmds "$reload_cmds" 'exit $?' - fi - - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - exit $EXIT_SUCCESS - ;; - - prog) - case $host in - *cygwin*) func_stripname '' '.exe' "$output" - output=$func_stripname_result.exe;; - esac - test -n "$vinfo" && \ - func_warning "\`-version-info' is ignored for programs" - - test -n "$release" && \ - func_warning "\`-release' is ignored for programs" - - test "$preload" = yes \ - && test "$dlopen_support" = unknown \ - && test "$dlopen_self" = unknown \ - && test "$dlopen_self_static" = unknown && \ - func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` - ;; - esac - - case $host in - *-*-darwin*) - # Don't allow lazy linking, it breaks C++ global constructors - # But is supposedly fixed on 10.4 or later (yay!). - if test "$tagname" = CXX ; then - case ${MACOSX_DEPLOYMENT_TARGET-10.0} in - 10.[0123]) - func_append compile_command " ${wl}-bind_at_load" - func_append finalize_command " ${wl}-bind_at_load" - ;; - esac - fi - # Time to change all our "foo.ltframework" stuff back to "-framework foo" - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - ;; - esac - - - # move library search paths that coincide with paths to not yet - # installed libraries to the beginning of the library search list - new_libs= - for path in $notinst_path; do - case " $new_libs " in - *" -L$path/$objdir "*) ;; - *) - case " $compile_deplibs " in - *" -L$path/$objdir "*) - func_append new_libs " -L$path/$objdir" ;; - esac - ;; - esac - done - for deplib in $compile_deplibs; do - case $deplib in - -L*) - case " $new_libs " in - *" $deplib "*) ;; - *) func_append new_libs " $deplib" ;; - esac - ;; - *) func_append new_libs " $deplib" ;; - esac - done - compile_deplibs="$new_libs" - - - func_append compile_command " $compile_deplibs" - func_append finalize_command " $finalize_deplibs" - - if test -n "$rpath$xrpath"; then - # If the user specified any rpath flags, then add them. - for libdir in $rpath $xrpath; do - # This is the magic to use -rpath. - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; - esac - done - fi - - # Now hardcode the library paths - rpath= - hardcode_libdirs= - for libdir in $compile_rpath $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append rpath " $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) func_append perm_rpath " $libdir" ;; - esac - fi - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` - case :$dllsearchpath: in - *":$libdir:"*) ;; - ::) dllsearchpath=$libdir;; - *) func_append dllsearchpath ":$libdir";; - esac - case :$dllsearchpath: in - *":$testbindir:"*) ;; - ::) dllsearchpath=$testbindir;; - *) func_append dllsearchpath ":$testbindir";; - esac - ;; - esac - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - compile_rpath="$rpath" - - rpath= - hardcode_libdirs= - for libdir in $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append rpath " $flag" - fi - elif test -n "$runpath_var"; then - case "$finalize_perm_rpath " in - *" $libdir "*) ;; - *) func_append finalize_perm_rpath " $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - finalize_rpath="$rpath" - - if test -n "$libobjs" && test "$build_old_libs" = yes; then - # Transform all the library objects into standard objects. - compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` - finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` - fi - - func_generate_dlsyms "$outputname" "@PROGRAM@" "no" - - # template prelinking step - if test -n "$prelink_cmds"; then - func_execute_cmds "$prelink_cmds" 'exit $?' - fi - - wrappers_required=yes - case $host in - *cegcc* | *mingw32ce*) - # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. - wrappers_required=no - ;; - *cygwin* | *mingw* ) - if test "$build_libtool_libs" != yes; then - wrappers_required=no - fi - ;; - *) - if test "$need_relink" = no || test "$build_libtool_libs" != yes; then - wrappers_required=no - fi - ;; - esac - if test "$wrappers_required" = no; then - # Replace the output file specification. - compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` - link_command="$compile_command$compile_rpath" - - # We have no uninstalled library dependencies, so finalize right now. - exit_status=0 - func_show_eval "$link_command" 'exit_status=$?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - # Delete the generated files. - if test -f "$output_objdir/${outputname}S.${objext}"; then - func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' - fi - - exit $exit_status - fi - - if test -n "$compile_shlibpath$finalize_shlibpath"; then - compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" - fi - if test -n "$finalize_shlibpath"; then - finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" - fi - - compile_var= - finalize_var= - if test -n "$runpath_var"; then - if test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - func_append rpath "$dir:" - done - compile_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - if test -n "$finalize_perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $finalize_perm_rpath; do - func_append rpath "$dir:" - done - finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - fi - - if test "$no_install" = yes; then - # We don't need to create a wrapper script. - link_command="$compile_var$compile_command$compile_rpath" - # Replace the output file specification. - link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` - # Delete the old output file. - $opt_dry_run || $RM $output - # Link the executable and exit - func_show_eval "$link_command" 'exit $?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - exit $EXIT_SUCCESS - fi - - if test "$hardcode_action" = relink; then - # Fast installation is not supported - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - - func_warning "this platform does not like uninstalled shared libraries" - func_warning "\`$output' will be relinked during installation" - else - if test "$fast_install" != no; then - link_command="$finalize_var$compile_command$finalize_rpath" - if test "$fast_install" = yes; then - relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` - else - # fast_install is set to needless - relink_command= - fi - else - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - fi - fi - - # Replace the output file specification. - link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` - - # Delete the old output files. - $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname - - func_show_eval "$link_command" 'exit $?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output_objdir/$outputname" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - # Now create the wrapper script. - func_verbose "creating $output" - - # Quote the relink command for shipping. - if test -n "$relink_command"; then - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - func_quote_for_eval "$var_value" - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" - fi - done - relink_command="(cd `pwd`; $relink_command)" - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` - fi - - # Only actually do things if not in dry run mode. - $opt_dry_run || { - # win32 will think the script is a binary if it has - # a .exe suffix, so we strip it off here. - case $output in - *.exe) func_stripname '' '.exe' "$output" - output=$func_stripname_result ;; - esac - # test for cygwin because mv fails w/o .exe extensions - case $host in - *cygwin*) - exeext=.exe - func_stripname '' '.exe' "$outputname" - outputname=$func_stripname_result ;; - *) exeext= ;; - esac - case $host in - *cygwin* | *mingw* ) - func_dirname_and_basename "$output" "" "." - output_name=$func_basename_result - output_path=$func_dirname_result - cwrappersource="$output_path/$objdir/lt-$output_name.c" - cwrapper="$output_path/$output_name.exe" - $RM $cwrappersource $cwrapper - trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 - - func_emit_cwrapperexe_src > $cwrappersource - - # The wrapper executable is built using the $host compiler, - # because it contains $host paths and files. If cross- - # compiling, it, like the target executable, must be - # executed on the $host or under an emulation environment. - $opt_dry_run || { - $LTCC $LTCFLAGS -o $cwrapper $cwrappersource - $STRIP $cwrapper - } - - # Now, create the wrapper script for func_source use: - func_ltwrapper_scriptname $cwrapper - $RM $func_ltwrapper_scriptname_result - trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 - $opt_dry_run || { - # note: this script will not be executed, so do not chmod. - if test "x$build" = "x$host" ; then - $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result - else - func_emit_wrapper no > $func_ltwrapper_scriptname_result - fi - } - ;; - * ) - $RM $output - trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 - - func_emit_wrapper no > $output - chmod +x $output - ;; - esac - } - exit $EXIT_SUCCESS - ;; - esac - - # See if we need to build an old-fashioned archive. - for oldlib in $oldlibs; do - - if test "$build_libtool_libs" = convenience; then - oldobjs="$libobjs_save $symfileobj" - addlibs="$convenience" - build_libtool_libs=no - else - if test "$build_libtool_libs" = module; then - oldobjs="$libobjs_save" - build_libtool_libs=no - else - oldobjs="$old_deplibs $non_pic_objects" - if test "$preload" = yes && test -f "$symfileobj"; then - func_append oldobjs " $symfileobj" - fi - fi - addlibs="$old_convenience" - fi - - if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - - func_extract_archives $gentop $addlibs - func_append oldobjs " $func_extract_archives_result" - fi - - # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - cmds=$old_archive_from_new_cmds - else - - # Add any objects from preloaded convenience libraries - if test -n "$dlprefiles"; then - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - - func_extract_archives $gentop $dlprefiles - func_append oldobjs " $func_extract_archives_result" - fi - - # POSIX demands no paths to be encoded in archives. We have - # to avoid creating archives with duplicate basenames if we - # might have to extract them afterwards, e.g., when creating a - # static archive out of a convenience library, or when linking - # the entirety of a libtool archive into another (currently - # not supported by libtool). - if (for obj in $oldobjs - do - func_basename "$obj" - $ECHO "$func_basename_result" - done | sort | sort -uc >/dev/null 2>&1); then - : - else - echo "copying selected object files to avoid basename conflicts..." - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - func_mkdir_p "$gentop" - save_oldobjs=$oldobjs - oldobjs= - counter=1 - for obj in $save_oldobjs - do - func_basename "$obj" - objbase="$func_basename_result" - case " $oldobjs " in - " ") oldobjs=$obj ;; - *[\ /]"$objbase "*) - while :; do - # Make sure we don't pick an alternate name that also - # overlaps. - newobj=lt$counter-$objbase - func_arith $counter + 1 - counter=$func_arith_result - case " $oldobjs " in - *[\ /]"$newobj "*) ;; - *) if test ! -f "$gentop/$newobj"; then break; fi ;; - esac - done - func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" - func_append oldobjs " $gentop/$newobj" - ;; - *) func_append oldobjs " $obj" ;; - esac - done - fi - func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 - tool_oldlib=$func_to_tool_file_result - eval cmds=\"$old_archive_cmds\" - - func_len " $cmds" - len=$func_len_result - if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then - cmds=$old_archive_cmds - elif test -n "$archiver_list_spec"; then - func_verbose "using command file archive linking..." - for obj in $oldobjs - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" - done > $output_objdir/$libname.libcmd - func_to_tool_file "$output_objdir/$libname.libcmd" - oldobjs=" $archiver_list_spec$func_to_tool_file_result" - cmds=$old_archive_cmds - else - # the command line is too long to link in one step, link in parts - func_verbose "using piecewise archive linking..." - save_RANLIB=$RANLIB - RANLIB=: - objlist= - concat_cmds= - save_oldobjs=$oldobjs - oldobjs= - # Is there a better way of finding the last object in the list? - for obj in $save_oldobjs - do - last_oldobj=$obj - done - eval test_cmds=\"$old_archive_cmds\" - func_len " $test_cmds" - len0=$func_len_result - len=$len0 - for obj in $save_oldobjs - do - func_len " $obj" - func_arith $len + $func_len_result - len=$func_arith_result - func_append objlist " $obj" - if test "$len" -lt "$max_cmd_len"; then - : - else - # the above command should be used before it gets too long - oldobjs=$objlist - if test "$obj" = "$last_oldobj" ; then - RANLIB=$save_RANLIB - fi - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" - objlist= - len=$len0 - fi - done - RANLIB=$save_RANLIB - oldobjs=$objlist - if test "X$oldobjs" = "X" ; then - eval cmds=\"\$concat_cmds\" - else - eval cmds=\"\$concat_cmds~\$old_archive_cmds\" - fi - fi - fi - func_execute_cmds "$cmds" 'exit $?' - done - - test -n "$generated" && \ - func_show_eval "${RM}r$generated" - - # Now create the libtool archive. - case $output in - *.la) - old_library= - test "$build_old_libs" = yes && old_library="$libname.$libext" - func_verbose "creating $output" - - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - func_quote_for_eval "$var_value" - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" - fi - done - # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` - if test "$hardcode_automatic" = yes ; then - relink_command= - fi - - # Only create the output if not a dry run. - $opt_dry_run || { - for installed in no yes; do - if test "$installed" = yes; then - if test -z "$install_libdir"; then - break - fi - output="$output_objdir/$outputname"i - # Replace all uninstalled libtool libraries with the installed ones - newdependency_libs= - for deplib in $dependency_libs; do - case $deplib in - *.la) - func_basename "$deplib" - name="$func_basename_result" - func_resolve_sysroot "$deplib" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` - test -z "$libdir" && \ - func_fatal_error "\`$deplib' is not a valid libtool archive" - func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" - ;; - -L*) - func_stripname -L '' "$deplib" - func_replace_sysroot "$func_stripname_result" - func_append newdependency_libs " -L$func_replace_sysroot_result" - ;; - -R*) - func_stripname -R '' "$deplib" - func_replace_sysroot "$func_stripname_result" - func_append newdependency_libs " -R$func_replace_sysroot_result" - ;; - *) func_append newdependency_libs " $deplib" ;; - esac - done - dependency_libs="$newdependency_libs" - newdlfiles= - - for lib in $dlfiles; do - case $lib in - *.la) - func_basename "$lib" - name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - test -z "$libdir" && \ - func_fatal_error "\`$lib' is not a valid libtool archive" - func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" - ;; - *) func_append newdlfiles " $lib" ;; - esac - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - *.la) - # Only pass preopened files to the pseudo-archive (for - # eventual linking with the app. that links it) if we - # didn't already link the preopened objects directly into - # the library: - func_basename "$lib" - name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - test -z "$libdir" && \ - func_fatal_error "\`$lib' is not a valid libtool archive" - func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" - ;; - esac - done - dlprefiles="$newdlprefiles" - else - newdlfiles= - for lib in $dlfiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - func_append newdlfiles " $abs" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - func_append newdlprefiles " $abs" - done - dlprefiles="$newdlprefiles" - fi - $RM $output - # place dlname in correct position for cygwin - # In fact, it would be nice if we could use this code for all target - # systems that can't hard-code library paths into their executables - # and that have no shared library path variable independent of PATH, - # but it turns out we can't easily determine that from inspecting - # libtool variables, so we have to hard-code the OSs to which it - # applies here; at the moment, that means platforms that use the PE - # object format with DLL files. See the long comment at the top of - # tests/bindir.at for full details. - tdlname=$dlname - case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) - # If a -bindir argument was supplied, place the dll there. - if test "x$bindir" != x ; - then - func_relative_path "$install_libdir" "$bindir" - tdlname=$func_relative_path_result$dlname - else - # Otherwise fall back on heuristic. - tdlname=../bin/$dlname - fi - ;; - esac - $ECHO > $output "\ -# $outputname - a libtool library file -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='$tdlname' - -# Names of this library. -library_names='$library_names' - -# The name of the static archive. -old_library='$old_library' - -# Linker flags that can not go in dependency_libs. -inherited_linker_flags='$new_inherited_linker_flags' - -# Libraries that this one depends upon. -dependency_libs='$dependency_libs' - -# Names of additional weak libraries provided by this library -weak_library_names='$weak_libs' - -# Version information for $libname. -current=$current -age=$age -revision=$revision - -# Is this an already installed library? -installed=$installed - -# Should we warn about portability when linking against -modules? -shouldnotlink=$module - -# Files to dlopen/dlpreopen -dlopen='$dlfiles' -dlpreopen='$dlprefiles' - -# Directory that this library needs to be installed in: -libdir='$install_libdir'" - if test "$installed" = no && test "$need_relink" = yes; then - $ECHO >> $output "\ -relink_command=\"$relink_command\"" - fi - done - } - - # Do a symbolic link so that the libtool archive can be found in - # LD_LIBRARY_PATH before the program is installed. - func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' - ;; - esac - exit $EXIT_SUCCESS -} - -{ test "$opt_mode" = link || test "$opt_mode" = relink; } && - func_mode_link ${1+"$@"} - - -# func_mode_uninstall arg... -func_mode_uninstall () -{ - $opt_debug - RM="$nonopt" - files= - rmforce= - exit_status=0 - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - for arg - do - case $arg in - -f) func_append RM " $arg"; rmforce=yes ;; - -*) func_append RM " $arg" ;; - *) func_append files " $arg" ;; - esac - done - - test -z "$RM" && \ - func_fatal_help "you must specify an RM program" - - rmdirs= - - for file in $files; do - func_dirname "$file" "" "." - dir="$func_dirname_result" - if test "X$dir" = X.; then - odir="$objdir" - else - odir="$dir/$objdir" - fi - func_basename "$file" - name="$func_basename_result" - test "$opt_mode" = uninstall && odir="$dir" - - # Remember odir for removal later, being careful to avoid duplicates - if test "$opt_mode" = clean; then - case " $rmdirs " in - *" $odir "*) ;; - *) func_append rmdirs " $odir" ;; - esac - fi - - # Don't error if the file doesn't exist and rm -f was used. - if { test -L "$file"; } >/dev/null 2>&1 || - { test -h "$file"; } >/dev/null 2>&1 || - test -f "$file"; then - : - elif test -d "$file"; then - exit_status=1 - continue - elif test "$rmforce" = yes; then - continue - fi - - rmfiles="$file" - - case $name in - *.la) - # Possibly a libtool archive, so verify it. - if func_lalib_p "$file"; then - func_source $dir/$name - - # Delete the libtool libraries and symlinks. - for n in $library_names; do - func_append rmfiles " $odir/$n" - done - test -n "$old_library" && func_append rmfiles " $odir/$old_library" - - case "$opt_mode" in - clean) - case " $library_names " in - *" $dlname "*) ;; - *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; - esac - test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" - ;; - uninstall) - if test -n "$library_names"; then - # Do each command in the postuninstall commands. - func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' - fi - - if test -n "$old_library"; then - # Do each command in the old_postuninstall commands. - func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' - fi - # FIXME: should reinstall the best remaining shared library. - ;; - esac - fi - ;; - - *.lo) - # Possibly a libtool object, so verify it. - if func_lalib_p "$file"; then - - # Read the .lo file - func_source $dir/$name - - # Add PIC object to the list of files to remove. - if test -n "$pic_object" && - test "$pic_object" != none; then - func_append rmfiles " $dir/$pic_object" - fi - - # Add non-PIC object to the list of files to remove. - if test -n "$non_pic_object" && - test "$non_pic_object" != none; then - func_append rmfiles " $dir/$non_pic_object" - fi - fi - ;; - - *) - if test "$opt_mode" = clean ; then - noexename=$name - case $file in - *.exe) - func_stripname '' '.exe' "$file" - file=$func_stripname_result - func_stripname '' '.exe' "$name" - noexename=$func_stripname_result - # $file with .exe has already been added to rmfiles, - # add $file without .exe - func_append rmfiles " $file" - ;; - esac - # Do a test to see if this is a libtool program. - if func_ltwrapper_p "$file"; then - if func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - relink_command= - func_source $func_ltwrapper_scriptname_result - func_append rmfiles " $func_ltwrapper_scriptname_result" - else - relink_command= - func_source $dir/$noexename - fi - - # note $name still contains .exe if it was in $file originally - # as does the version of $file that was added into $rmfiles - func_append rmfiles " $odir/$name $odir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then - func_append rmfiles " $odir/lt-$name" - fi - if test "X$noexename" != "X$name" ; then - func_append rmfiles " $odir/lt-${noexename}.c" - fi - fi - fi - ;; - esac - func_show_eval "$RM $rmfiles" 'exit_status=1' - done - - # Try to remove the ${objdir}s in the directories where we deleted files - for dir in $rmdirs; do - if test -d "$dir"; then - func_show_eval "rmdir $dir >/dev/null 2>&1" - fi - done - - exit $exit_status -} - -{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && - func_mode_uninstall ${1+"$@"} - -test -z "$opt_mode" && { - help="$generic_help" - func_fatal_help "you must specify a MODE" -} - -test -z "$exec_cmd" && \ - func_fatal_help "invalid operation mode \`$opt_mode'" - -if test -n "$exec_cmd"; then - eval exec "$exec_cmd" - exit $EXIT_FAILURE -fi - -exit $exit_status - - -# The TAGs below are defined such that we never get into a situation -# in which we disable both kinds of libraries. Given conflicting -# choices, we go for a static library, that is the most portable, -# since we can't tell whether shared libraries were disabled because -# the user asked for that or because the platform doesn't support -# them. This is particularly important on AIX, because we don't -# support having both static and shared libraries enabled at the same -# time on that platform, so we default to a shared-only configuration. -# If a disable-shared tag is given, we'll fallback to a static-only -# configuration. But we'll never go from static-only to shared-only. - -# ### BEGIN LIBTOOL TAG CONFIG: disable-shared -build_libtool_libs=no -build_old_libs=yes -# ### END LIBTOOL TAG CONFIG: disable-shared - -# ### BEGIN LIBTOOL TAG CONFIG: disable-static -build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` -# ### END LIBTOOL TAG CONFIG: disable-static - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: -# vi:sw=2 - diff --git a/FreeRTOS-Plus/Source/WolfSSL/build-aux/missing b/FreeRTOS-Plus/Source/WolfSSL/build-aux/missing deleted file mode 100755 index db98974..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/build-aux/missing +++ /dev/null @@ -1,215 +0,0 @@ -#! /bin/sh -# Common wrapper for a few potentially missing GNU programs. - -scriptversion=2013-10-28.13; # UTC - -# Copyright (C) 1996-2013 Free Software Foundation, Inc. -# Originally written by Fran,cois Pinard , 1996. - -# This program 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, or (at your option) -# any later version. - -# This program 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, see . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -if test $# -eq 0; then - echo 1>&2 "Try '$0 --help' for more information" - exit 1 -fi - -case $1 in - - --is-lightweight) - # Used by our autoconf macros to check whether the available missing - # script is modern enough. - exit 0 - ;; - - --run) - # Back-compat with the calling convention used by older automake. - shift - ;; - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due -to PROGRAM being missing or too old. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - -Supported PROGRAM values: - aclocal autoconf autoheader autom4te automake makeinfo - bison yacc flex lex help2man - -Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and -'g' are ignored when checking the name. - -Send bug reports to ." - exit $? - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing $scriptversion (GNU Automake)" - exit $? - ;; - - -*) - echo 1>&2 "$0: unknown '$1' option" - echo 1>&2 "Try '$0 --help' for more information" - exit 1 - ;; - -esac - -# Run the given program, remember its exit status. -"$@"; st=$? - -# If it succeeded, we are done. -test $st -eq 0 && exit 0 - -# Also exit now if we it failed (or wasn't found), and '--version' was -# passed; such an option is passed most likely to detect whether the -# program is present and works. -case $2 in --version|--help) exit $st;; esac - -# Exit code 63 means version mismatch. This often happens when the user -# tries to use an ancient version of a tool on a file that requires a -# minimum version. -if test $st -eq 63; then - msg="probably too old" -elif test $st -eq 127; then - # Program was missing. - msg="missing on your system" -else - # Program was found and executed, but failed. Give up. - exit $st -fi - -perl_URL=http://www.perl.org/ -flex_URL=http://flex.sourceforge.net/ -gnu_software_URL=http://www.gnu.org/software - -program_details () -{ - case $1 in - aclocal|automake) - echo "The '$1' program is part of the GNU Automake package:" - echo "<$gnu_software_URL/automake>" - echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" - echo "<$gnu_software_URL/autoconf>" - echo "<$gnu_software_URL/m4/>" - echo "<$perl_URL>" - ;; - autoconf|autom4te|autoheader) - echo "The '$1' program is part of the GNU Autoconf package:" - echo "<$gnu_software_URL/autoconf/>" - echo "It also requires GNU m4 and Perl in order to run:" - echo "<$gnu_software_URL/m4/>" - echo "<$perl_URL>" - ;; - esac -} - -give_advice () -{ - # Normalize program name to check for. - normalized_program=`echo "$1" | sed ' - s/^gnu-//; t - s/^gnu//; t - s/^g//; t'` - - printf '%s\n' "'$1' is $msg." - - configure_deps="'configure.ac' or m4 files included by 'configure.ac'" - case $normalized_program in - autoconf*) - echo "You should only need it if you modified 'configure.ac'," - echo "or m4 files included by it." - program_details 'autoconf' - ;; - autoheader*) - echo "You should only need it if you modified 'acconfig.h' or" - echo "$configure_deps." - program_details 'autoheader' - ;; - automake*) - echo "You should only need it if you modified 'Makefile.am' or" - echo "$configure_deps." - program_details 'automake' - ;; - aclocal*) - echo "You should only need it if you modified 'acinclude.m4' or" - echo "$configure_deps." - program_details 'aclocal' - ;; - autom4te*) - echo "You might have modified some maintainer files that require" - echo "the 'autom4te' program to be rebuilt." - program_details 'autom4te' - ;; - bison*|yacc*) - echo "You should only need it if you modified a '.y' file." - echo "You may want to install the GNU Bison package:" - echo "<$gnu_software_URL/bison/>" - ;; - lex*|flex*) - echo "You should only need it if you modified a '.l' file." - echo "You may want to install the Fast Lexical Analyzer package:" - echo "<$flex_URL>" - ;; - help2man*) - echo "You should only need it if you modified a dependency" \ - "of a man page." - echo "You may want to install the GNU Help2man package:" - echo "<$gnu_software_URL/help2man/>" - ;; - makeinfo*) - echo "You should only need it if you modified a '.texi' file, or" - echo "any other file indirectly affecting the aspect of the manual." - echo "You might want to install the Texinfo package:" - echo "<$gnu_software_URL/texinfo/>" - echo "The spurious makeinfo call might also be the consequence of" - echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" - echo "want to install GNU make:" - echo "<$gnu_software_URL/make/>" - ;; - *) - echo "You might have modified some files without having the proper" - echo "tools for further handling them. Check the 'README' file, it" - echo "often tells you about the needed prerequisites for installing" - echo "this package. You may also peek at any GNU archive site, in" - echo "case some other package contains this missing '$1' program." - ;; - esac -} - -give_advice "$1" | sed -e '1s/^/WARNING: /' \ - -e '2,$s/^/ /' >&2 - -# Propagate the correct exit status (expected to be 127 for a program -# not found, 63 for a program that failed due to version mismatch). -exit $st - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/FreeRTOS-Plus/Source/WolfSSL/build-aux/test-driver b/FreeRTOS-Plus/Source/WolfSSL/build-aux/test-driver deleted file mode 100755 index d306056..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/build-aux/test-driver +++ /dev/null @@ -1,139 +0,0 @@ -#! /bin/sh -# test-driver - basic testsuite driver script. - -scriptversion=2013-07-13.22; # UTC - -# Copyright (C) 2011-2013 Free Software Foundation, Inc. -# -# This program 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, or (at your option) -# any later version. -# -# This program 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, see . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -# Make unconditional expansion of undefined variables an error. This -# helps a lot in preventing typo-related bugs. -set -u - -usage_error () -{ - echo "$0: $*" >&2 - print_usage >&2 - exit 2 -} - -print_usage () -{ - cat <$log_file 2>&1 -estatus=$? -if test $enable_hard_errors = no && test $estatus -eq 99; then - estatus=1 -fi - -case $estatus:$expect_failure in - 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; - 0:*) col=$grn res=PASS recheck=no gcopy=no;; - 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; - 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; - *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; - *:*) col=$red res=FAIL recheck=yes gcopy=yes;; -esac - -# Report outcome to console. -echo "${col}${res}${std}: $test_name" - -# Register the test result, and other relevant metadata. -echo ":test-result: $res" > $trs_file -echo ":global-test-result: $res" >> $trs_file -echo ":recheck: $recheck" >> $trs_file -echo ":copy-in-global-log: $gcopy" >> $trs_file - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/client-cert.der b/FreeRTOS-Plus/Source/WolfSSL/certs/1024/client-cert.der deleted file mode 100755 index c2bd6df..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/client-cert.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/client-cert.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/1024/client-cert.pem deleted file mode 100755 index 2f13e8e..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/client-cert.pem +++ /dev/null @@ -1,66 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 16417767964199037690 (0xe3d7a0fa76df2afa) - Signature Algorithm: sha256WithRSAEncryption - Issuer: C=US, ST=Montana, L=Bozeman, O=wolfSSL_1024, OU=Programming-1024, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Validity - Not Before: May 7 18:21:01 2015 GMT - Not After : Jan 31 18:21:01 2018 GMT - Subject: C=US, ST=Montana, L=Bozeman, O=wolfSSL_1024, OU=Programming-1024, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (1024 bit) - Modulus: - 00:bc:73:0e:a8:49:f3:74:a2:a9:ef:18:a5:da:55: - 99:21:f9:c8:ec:b3:6d:48:e5:35:35:75:77:37:ec: - d1:61:90:5f:3e:d9:e4:d5:df:94:ca:c1:a9:d7:19: - da:86:c9:e8:4d:c4:61:36:82:fe:ab:ad:7e:77:25: - bb:8d:11:a5:bc:62:3a:a8:38:cc:39:a2:04:66:b4: - f7:f7:f3:aa:da:4d:02:0e:bb:5e:8d:69:48:dc:77: - c9:28:0e:22:e9:6b:a4:26:ba:4c:e8:c1:fd:4a:6f: - 2b:1f:ef:8a:ae:f6:90:62:e5:64:1e:eb:2b:3c:67: - c8:dc:27:00:f6:91:68:65:a9 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Subject Key Identifier: - 81:69:0F:F8:DF:DD:CF:34:29:D5:67:75:71:85:C7:75:10:69:59:EC - X509v3 Authority Key Identifier: - keyid:81:69:0F:F8:DF:DD:CF:34:29:D5:67:75:71:85:C7:75:10:69:59:EC - DirName:/C=US/ST=Montana/L=Bozeman/O=wolfSSL_1024/OU=Programming-1024/CN=www.wolfssl.com/emailAddress=info@wolfssl.com - serial:E3:D7:A0:FA:76:DF:2A:FA - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: sha256WithRSAEncryption - 1d:b7:d5:7c:e1:b1:d8:c0:67:5d:b5:d3:88:e7:50:29:71:63: - 8f:cc:26:1f:33:09:55:43:9b:ab:c6:1b:bc:c7:01:95:1a:fa: - 65:e0:fd:9c:eb:6f:0a:0f:14:ec:b5:2f:dc:1c:30:dd:52:97: - d4:1c:09:00:33:38:5f:cb:a8:16:8f:11:b7:b8:d0:66:e1:54: - 28:f3:3f:bf:6a:6f:76:48:2a:5e:56:a7:ce:1c:f0:04:dd:17: - bd:06:78:21:6d:d6:b1:9b:75:31:92:c1:fe:d4:8d:d4:67:2f: - 03:1b:27:8d:ab:ff:30:3b:c3:7f:23:e4:ab:5b:91:e1:1b:66: - e6:ed ------BEGIN CERTIFICATE----- -MIIDxTCCAy6gAwIBAgIJAOPXoPp23yr6MA0GCSqGSIb3DQEBCwUAMIGeMQswCQYD -VQQGEwJVUzEQMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjEVMBMG -A1UECgwMd29sZlNTTF8xMDI0MRkwFwYDVQQLDBBQcm9ncmFtbWluZy0xMDI0MRgw -FgYDVQQDDA93d3cud29sZnNzbC5jb20xHzAdBgkqhkiG9w0BCQEWEGluZm9Ad29s -ZnNzbC5jb20wHhcNMTUwNTA3MTgyMTAxWhcNMTgwMTMxMTgyMTAxWjCBnjELMAkG -A1UEBhMCVVMxEDAOBgNVBAgMB01vbnRhbmExEDAOBgNVBAcMB0JvemVtYW4xFTAT -BgNVBAoMDHdvbGZTU0xfMTAyNDEZMBcGA1UECwwQUHJvZ3JhbW1pbmctMTAyNDEY -MBYGA1UEAwwPd3d3LndvbGZzc2wuY29tMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdv -bGZzc2wuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8cw6oSfN0oqnv -GKXaVZkh+cjss21I5TU1dXc37NFhkF8+2eTV35TKwanXGdqGyehNxGE2gv6rrX53 -JbuNEaW8YjqoOMw5ogRmtPf386raTQIOu16NaUjcd8koDiLpa6Qmukzowf1Kbysf -74qu9pBi5WQe6ys8Z8jcJwD2kWhlqQIDAQABo4IBBzCCAQMwHQYDVR0OBBYEFIFp -D/jf3c80KdVndXGFx3UQaVnsMIHTBgNVHSMEgcswgciAFIFpD/jf3c80KdVndXGF -x3UQaVnsoYGkpIGhMIGeMQswCQYDVQQGEwJVUzEQMA4GA1UECAwHTW9udGFuYTEQ -MA4GA1UEBwwHQm96ZW1hbjEVMBMGA1UECgwMd29sZlNTTF8xMDI0MRkwFwYDVQQL -DBBQcm9ncmFtbWluZy0xMDI0MRgwFgYDVQQDDA93d3cud29sZnNzbC5jb20xHzAd -BgkqhkiG9w0BCQEWEGluZm9Ad29sZnNzbC5jb22CCQDj16D6dt8q+jAMBgNVHRME -BTADAQH/MA0GCSqGSIb3DQEBCwUAA4GBAB231XzhsdjAZ12104jnUClxY4/MJh8z -CVVDm6vGG7zHAZUa+mXg/ZzrbwoPFOy1L9wcMN1Sl9QcCQAzOF/LqBaPEbe40Gbh -VCjzP79qb3ZIKl5Wp84c8ATdF70GeCFt1rGbdTGSwf7UjdRnLwMbJ42r/zA7w38j -5KtbkeEbZubt ------END CERTIFICATE----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/client-key.der b/FreeRTOS-Plus/Source/WolfSSL/certs/1024/client-key.der deleted file mode 100755 index 1c47c25..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/client-key.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/client-key.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/1024/client-key.pem deleted file mode 100755 index 79e398c..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/client-key.pem +++ /dev/null @@ -1,15 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIICXAIBAAKBgQC8cw6oSfN0oqnvGKXaVZkh+cjss21I5TU1dXc37NFhkF8+2eTV -35TKwanXGdqGyehNxGE2gv6rrX53JbuNEaW8YjqoOMw5ogRmtPf386raTQIOu16N -aUjcd8koDiLpa6Qmukzowf1Kbysf74qu9pBi5WQe6ys8Z8jcJwD2kWhlqQIDAQAB -AoGAE5fq6Dh4JaJcBM4NQHwx5cRwzZuCO1gJhjtmX9wxkPFP1dsV3d7XO5WTMRgx -Dl6j1qIacW6BSBxLz9uOeoZhMtz7VcEWbSeSJEWL8bhIsUsdrN7a3Y4vwpH7palu -+Dpq8f1QGO+f58PKeOpW09NyW5bdTgZOOsPZvnK2ZQcHTAECQQD6R9R6fJI8Ve+B -8EEwLaPPjxzmhycFcA3fmDXW8Ys4LyS10IS2eU9xKZRa8GRqrOdyxu1NWZg+Zzrz -dCz5YRdpAkEAwMGCDQzrxi/ckvmdghox6en3S/KChxzuFmrRHRiCcPPAti/28/cd -8YYjyE7rj1aOj/W/8fcrtcw9xlc5DBtUQQJBAJ1+Bd7t9Ley+/wwS1Ud4y8BR5Zp -Bc0OLiy9g2O2q3y3bcpbZKfOvobfO1PeYdIe66X2N+2sq3jZTOdV+9cRmcECQBiY -GCnmHic5cCForAovoXLBIYaVOMZYkKBXnLrjp7EVyN72G8JhI3bvsJ0cRL4TQzln -F8idyvv1RWSLOIIs8oECQDmJ5ZwZVTC6t0iMSBQO9J9+d5dD4bQZNTEjdZw7RK1p -ElbuAGFkFmbTfHQrFbSi/r8IaxpdP5ASsQWGMSnb2eI= ------END RSA PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/dh1024.der b/FreeRTOS-Plus/Source/WolfSSL/certs/1024/dh1024.der deleted file mode 100755 index f29e6dc..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/dh1024.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/dh1024.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/1024/dh1024.pem deleted file mode 100755 index 372f50a..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/dh1024.pem +++ /dev/null @@ -1,17 +0,0 @@ - PKCS#3 DH Parameters: (1024 bit) - prime: - 00:a4:d2:b8:6e:78:f5:d9:ed:2d:7c:dd:b6:16:86: - 5a:4b:05:76:90:dd:66:61:b9:6d:52:a7:1c:af:62: - c6:69:47:7b:39:f2:fb:94:ec:bc:79:ff:24:5e:ef: - 79:bb:59:b2:fc:ca:07:d6:f4:e9:34:f7:e8:38:e7: - d7:33:44:1d:a3:64:76:1a:84:97:54:74:40:84:1f: - 15:fe:7c:25:2a:2b:25:fd:9e:c1:89:33:8c:39:25: - 2b:40:e6:cd:f8:a8:a1:8a:53:c6:47:b2:a0:d7:8f: - eb:2e:60:0a:0d:4b:f8:b4:94:8c:63:0a:ad:c7:10: - ea:c7:a1:b9:9d:f2:a8:37:73 - generator: 2 (0x2) ------BEGIN DH PARAMETERS----- -MIGHAoGBAKTSuG549dntLXzdthaGWksFdpDdZmG5bVKnHK9ixmlHezny+5TsvHn/ -JF7vebtZsvzKB9b06TT36Djn1zNEHaNkdhqEl1R0QIQfFf58JSorJf2ewYkzjDkl -K0DmzfiooYpTxkeyoNeP6y5gCg1L+LSUjGMKrccQ6sehuZ3yqDdzAgEC ------END DH PARAMETERS----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/dsa1024.der b/FreeRTOS-Plus/Source/WolfSSL/certs/1024/dsa1024.der deleted file mode 100755 index 65db155..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/dsa1024.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/dsa1024.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/1024/dsa1024.pem deleted file mode 100755 index c5bb067..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/dsa1024.pem +++ /dev/null @@ -1,12 +0,0 @@ ------BEGIN DSA PRIVATE KEY----- -MIIBvAIBAAKBgQD3S/m7FZjr3d4eTnGIhfK3uuJK2nZAzWlInoN8EfdlMXj1JS33 -t/hSP77YtsX+GBVbudWShryyF3zYsL6gfPLVc3pYj43lSgCZg0rAnhYJoRA01Rm7 -Y+Pdg3R/EMpzde4xSt2f4AJqne6yS6drKmzHhnfoBBXckrR6KR9Og2OFVQIVANIF -5HP7wZnF3GikjZInPeJSX4mLAoGBAKohAglDbvuiVBSFCvQofMvM2/UeohipId6I -iDOMLuuNo/AdyI/2fvjPEvW0oRFvDNTwBq3E/BRFx5QVvBlLru+Tak/MFNhHizlm -hwLUKAq47gk39ACgBKd5p9I89zRDVo7QfMLYTQ+J7RTBLJxMGZue3FMJn98t8Awn -VDp3FC3eAoGBAOgffLfAVFGnKC1YfN7UXN3VdoQ8NiDAwyXXOjjhVMj9QGgaIVQm -ORS/9qOcXtkr98klugAJy38MSiT9FRYVSM0LUkRAe5BjK5AixRgFgFOvgx9U4rCi -C1qSJOFiKD+3yrmJ1qC3ra4F4cFZQO1KG2ine/vDIIHvS/NpkbDOOrA4AhQlODuh -GXXfm/VyU0854RzsE4SCGA== ------END DSA PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/include.am b/FreeRTOS-Plus/Source/WolfSSL/certs/1024/include.am deleted file mode 100755 index c968497..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/include.am +++ /dev/null @@ -1,17 +0,0 @@ -# vim:ft=automake -# All paths should be given relative to the root -# - -EXTRA_DIST += \ - certs/1024/client-cert.pem \ - certs/1024/client-key.pem \ - certs/1024/dh1024.pem \ - certs/1024/dsa1024.pem - -EXTRA_DIST += \ - certs/1024/client-cert.der \ - certs/1024/client-key.der \ - certs/1024/dh1024.der \ - certs/1024/dsa1024.der \ - certs/1024/rsa1024.der - diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/rsa1024.der b/FreeRTOS-Plus/Source/WolfSSL/certs/1024/rsa1024.der deleted file mode 100755 index 173d32b..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/1024/rsa1024.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/ca-cert.der b/FreeRTOS-Plus/Source/WolfSSL/certs/ca-cert.der deleted file mode 100755 index d0eab7a..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/ca-cert.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/ca-cert.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/ca-cert.pem deleted file mode 100755 index 6eacbeb..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/ca-cert.pem +++ /dev/null @@ -1,86 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 15672591315981621815 (0xd9803ac3d2f4da37) - Signature Algorithm: sha256WithRSAEncryption - Issuer: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Validity - Not Before: May 7 18:21:01 2015 GMT - Not After : Jan 31 18:21:01 2018 GMT - Subject: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (2048 bit) - Modulus: - 00:bf:0c:ca:2d:14:b2:1e:84:42:5b:cd:38:1f:4a: - f2:4d:75:10:f1:b6:35:9f:df:ca:7d:03:98:d3:ac: - de:03:66:ee:2a:f1:d8:b0:7d:6e:07:54:0b:10:98: - 21:4d:80:cb:12:20:e7:cc:4f:de:45:7d:c9:72:77: - 32:ea:ca:90:bb:69:52:10:03:2f:a8:f3:95:c5:f1: - 8b:62:56:1b:ef:67:6f:a4:10:41:95:ad:0a:9b:e3: - a5:c0:b0:d2:70:76:50:30:5b:a8:e8:08:2c:7c:ed: - a7:a2:7a:8d:38:29:1c:ac:c7:ed:f2:7c:95:b0:95: - 82:7d:49:5c:38:cd:77:25:ef:bd:80:75:53:94:3c: - 3d:ca:63:5b:9f:15:b5:d3:1d:13:2f:19:d1:3c:db: - 76:3a:cc:b8:7d:c9:e5:c2:d7:da:40:6f:d8:21:dc: - 73:1b:42:2d:53:9c:fe:1a:fc:7d:ab:7a:36:3f:98: - de:84:7c:05:67:ce:6a:14:38:87:a9:f1:8c:b5:68: - cb:68:7f:71:20:2b:f5:a0:63:f5:56:2f:a3:26:d2: - b7:6f:b1:5a:17:d7:38:99:08:fe:93:58:6f:fe:c3: - 13:49:08:16:0b:a7:4d:67:00:52:31:67:23:4e:98: - ed:51:45:1d:b9:04:d9:0b:ec:d8:28:b3:4b:bd:ed: - 36:79 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Subject Key Identifier: - 27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5 - X509v3 Authority Key Identifier: - keyid:27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5 - DirName:/C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.wolfssl.com/emailAddress=info@wolfssl.com - serial:D9:80:3A:C3:D2:F4:DA:37 - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: sha256WithRSAEncryption - 7a:af:44:3b:aa:6f:53:42:b2:33:aa:43:5f:56:30:d3:b9:96: - 0b:9a:55:5a:39:2a:0b:4e:e4:2e:f1:95:66:c9:86:36:82:8d: - 63:7c:4d:a2:ee:48:ba:03:c7:90:d7:a7:c6:74:60:48:5f:31: - a2:f9:5e:3e:c3:82:e1:e5:2f:41:81:83:29:25:79:d1:53:00: - 69:3c:ed:0a:30:3b:41:1d:92:a1:2c:a8:9d:2c:e3:23:87:79: - e0:55:6e:91:a8:50:da:46:2f:c2:20:50:3e:2b:47:97:14:b0: - 7d:04:ba:45:51:d0:6e:e1:5a:a2:4b:84:9c:4d:cd:85:04:f9: - 28:31:82:93:bc:c7:59:49:91:03:e8:df:6a:e4:56:ad:6a:cb: - 1f:0d:37:e4:5e:bd:e7:9f:d5:ec:9d:3c:18:25:9b:f1:2f:50: - 7d:eb:31:cb:f1:63:22:9d:57:fc:f3:84:20:1a:c6:07:87:92: - 26:9e:15:18:59:33:06:dc:fb:b0:b6:76:5d:f1:c1:2f:c8:2f: - 62:9c:c0:d6:de:eb:65:77:f3:5c:a6:c3:88:27:96:75:b4:f4: - 54:cd:ff:2d:21:2e:96:f0:07:73:4b:e9:93:92:90:de:62:d9: - a3:3b:ac:6e:24:5f:27:4a:b3:94:70:ff:30:17:e7:7e:32:8f: - 65:b7:75:58 ------BEGIN CERTIFICATE----- -MIIEqjCCA5KgAwIBAgIJANmAOsPS9No3MA0GCSqGSIb3DQEBCwUAMIGUMQswCQYD -VQQGEwJVUzEQMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjERMA8G -A1UECgwIU2F3dG9vdGgxEzARBgNVBAsMCkNvbnN1bHRpbmcxGDAWBgNVBAMMD3d3 -dy53b2xmc3NsLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbTAe -Fw0xNTA1MDcxODIxMDFaFw0xODAxMzExODIxMDFaMIGUMQswCQYDVQQGEwJVUzEQ -MA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjERMA8GA1UECgwIU2F3 -dG9vdGgxEzARBgNVBAsMCkNvbnN1bHRpbmcxGDAWBgNVBAMMD3d3dy53b2xmc3Ns -LmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAL8Myi0Ush6EQlvNOB9K8k11EPG2NZ/fyn0D -mNOs3gNm7irx2LB9bgdUCxCYIU2AyxIg58xP3kV9yXJ3MurKkLtpUhADL6jzlcXx -i2JWG+9nb6QQQZWtCpvjpcCw0nB2UDBbqOgILHztp6J6jTgpHKzH7fJ8lbCVgn1J -XDjNdyXvvYB1U5Q8PcpjW58VtdMdEy8Z0TzbdjrMuH3J5cLX2kBv2CHccxtCLVOc -/hr8fat6Nj+Y3oR8BWfOahQ4h6nxjLVoy2h/cSAr9aBj9VYvoybSt2+xWhfXOJkI -/pNYb/7DE0kIFgunTWcAUjFnI06Y7VFFHbkE2Qvs2CizS73tNnkCAwEAAaOB/DCB -+TAdBgNVHQ4EFgQUJ45nEXTDJh0/7TNjs6TYHTDl6NUwgckGA1UdIwSBwTCBvoAU -J45nEXTDJh0/7TNjs6TYHTDl6NWhgZqkgZcwgZQxCzAJBgNVBAYTAlVTMRAwDgYD -VQQIDAdNb250YW5hMRAwDgYDVQQHDAdCb3plbWFuMREwDwYDVQQKDAhTYXd0b290 -aDETMBEGA1UECwwKQ29uc3VsdGluZzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29t -MR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdvbGZzc2wuY29tggkA2YA6w9L02jcwDAYD -VR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAeq9EO6pvU0KyM6pDX1Yw07mW -C5pVWjkqC07kLvGVZsmGNoKNY3xNou5IugPHkNenxnRgSF8xovlePsOC4eUvQYGD -KSV50VMAaTztCjA7QR2SoSyonSzjI4d54FVukahQ2kYvwiBQPitHlxSwfQS6RVHQ -buFaokuEnE3NhQT5KDGCk7zHWUmRA+jfauRWrWrLHw035F6955/V7J08GCWb8S9Q -fesxy/FjIp1X/POEIBrGB4eSJp4VGFkzBtz7sLZ2XfHBL8gvYpzA1t7rZXfzXKbD -iCeWdbT0VM3/LSEulvAHc0vpk5KQ3mLZozusbiRfJ0qzlHD/MBfnfjKPZbd1WA== ------END CERTIFICATE----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/ca-key.der b/FreeRTOS-Plus/Source/WolfSSL/certs/ca-key.der deleted file mode 100755 index 14456f3..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/ca-key.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/ca-key.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/ca-key.pem deleted file mode 100755 index 774feba..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/ca-key.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEAvwzKLRSyHoRCW804H0ryTXUQ8bY1n9/KfQOY06zeA2buKvHY -sH1uB1QLEJghTYDLEiDnzE/eRX3Jcncy6sqQu2lSEAMvqPOVxfGLYlYb72dvpBBB -la0Km+OlwLDScHZQMFuo6AgsfO2nonqNOCkcrMft8nyVsJWCfUlcOM13Je+9gHVT -lDw9ymNbnxW10x0TLxnRPNt2Osy4fcnlwtfaQG/YIdxzG0ItU5z+Gvx9q3o2P5je -hHwFZ85qFDiHqfGMtWjLaH9xICv1oGP1Vi+jJtK3b7FaF9c4mQj+k1hv/sMTSQgW -C6dNZwBSMWcjTpjtUUUduQTZC+zYKLNLve02eQIDAQABAoIBAD1uTmAahH+dhXzh -Swd84NaZKt6d+TY0DncOPgjqT+UGJtT2OPffDQ8cLgai9CponGNy4zXmBJGRtcGx -pFSs18b7QaDWdW+9C06/sVLoX0kmmFZHx97p6jxgAb8o3DG/SV+TSYd6gVuWS03K -XDhPt+Gy08ch2jwShwfkG9xD7OjsVGHn9u2mCy7134J/xh9hGZykgznfIYWJb3ev -hhUyCKJaCyZh+3AMypw4fbwi7uujqBYA+YqAHgCEqEpB+IQDZy8jWy+baybDBzSU -owM7ctWfcuCtzDSrvcfV9SYwhQ8wIzlS/zzLmSFNiKWr7mK5x+C7R4fBac9z8zC+ -zjkEnOUCgYEA4XZFgFm200nfCu8S1g/wt8sqN7+n+LVN9TE1reSjlKHb8ZattQVk -hYP8G1spqr74Jj92fq0c8MvXJrQbBY5Whn4IYiHBhtZHeT63XaTGOtexdCD2UJdB -BFPtPybWb5H6aCbsKtya8efc+3PweUMbIaNZBGNSB8nX5tEbXV6W+lMCgYEA2O1O -ZGFrkQxhAbUPu0RnUx7cB8Qkfp5shCORDOQSBBZNeJjMlj0gTg9Fmrb4s5MNsqIb -KfImecjF0nh+XnPy13Bhu0DOYQX+aR6CKeYUuKHnltAjPwWTAPLhTX7tt5Zs9/Dk -0c8BmE/cdFSqbV5aQTH+/5q2oAXdqRBU+GvQqoMCgYAh0wSKROtQt3xmv4cr5ihO -6oPi6TXh8hFH/6H1/J8t5TqB/AEDb1OtVCe2Uu7lVtETq+GzD3WQCoS0ocCMDNae -RrorPrUx7WO7pNUNj3LN0R4mNeu+G3L9mzm0h7cT9eqDRZOYuo/kSsy0TKh/CLpB -SahJKD1ePcHONwDL+SzdUQKBgQChV58+udavg22DP4/70NyozgMJI7GhG2PKxElW -NSvRLmVglQVVmRE1/dXfRMeliHJfsoJRqHFFkzbPXB9hUQwFgOivxXu6XiLjPHXD -hAVVbdY6LYSJkzPLONqqMQXNzmwt3VXTVwvwpTVqsK4xukOWygDHS+MZEkPTQvpv -6oDA0QKBgQC524kgNCdwYjTqXyViEvOdgb9I7poOwY0Q/2WanS0aipRayMClpYRh -ntQkue+pncl3C8dwZj26yFTf0jPh9X/5J2G+V0Xdt0UXJPUj5DgOkSfu4yDYFMiU -R3dAd0UYng3OeT9XMVYJSWe+lFhP9sSr4onj44rABVUsJMBKlwQnmg== ------END RSA PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/client-cert.der b/FreeRTOS-Plus/Source/WolfSSL/certs/client-cert.der deleted file mode 100755 index 9a7e0bf..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/client-cert.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/client-cert.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/client-cert.pem deleted file mode 100755 index 569cddd..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/client-cert.pem +++ /dev/null @@ -1,87 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 12260966172072242701 (0xaa27b3c5a9726e0d) - Signature Algorithm: sha256WithRSAEncryption - Issuer: C=US, ST=Montana, L=Bozeman, O=wolfSSL_2048, OU=Programming-2048, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Validity - Not Before: May 7 18:21:01 2015 GMT - Not After : Jan 31 18:21:01 2018 GMT - Subject: C=US, ST=Montana, L=Bozeman, O=wolfSSL_2048, OU=Programming-2048, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (2048 bit) - Modulus: - 00:c3:03:d1:2b:fe:39:a4:32:45:3b:53:c8:84:2b: - 2a:7c:74:9a:bd:aa:2a:52:07:47:d6:a6:36:b2:07: - 32:8e:d0:ba:69:7b:c6:c3:44:9e:d4:81:48:fd:2d: - 68:a2:8b:67:bb:a1:75:c8:36:2c:4a:d2:1b:f7:8b: - ba:cf:0d:f9:ef:ec:f1:81:1e:7b:9b:03:47:9a:bf: - 65:cc:7f:65:24:69:a6:e8:14:89:5b:e4:34:f7:c5: - b0:14:93:f5:67:7b:3a:7a:78:e1:01:56:56:91:a6: - 13:42:8d:d2:3c:40:9c:4c:ef:d1:86:df:37:51:1b: - 0c:a1:3b:f5:f1:a3:4a:35:e4:e1:ce:96:df:1b:7e: - bf:4e:97:d0:10:e8:a8:08:30:81:af:20:0b:43:14: - c5:74:67:b4:32:82:6f:8d:86:c2:88:40:99:36:83: - ba:1e:40:72:22:17:d7:52:65:24:73:b0:ce:ef:19: - cd:ae:ff:78:6c:7b:c0:12:03:d4:4e:72:0d:50:6d: - 3b:a3:3b:a3:99:5e:9d:c8:d9:0c:85:b3:d9:8a:d9: - 54:26:db:6d:fa:ac:bb:ff:25:4c:c4:d1:79:f4:71: - d3:86:40:18:13:b0:63:b5:72:4e:30:c4:97:84:86: - 2d:56:2f:d7:15:f7:7f:c0:ae:f5:fc:5b:e5:fb:a1: - ba:d3 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Subject Key Identifier: - 33:D8:45:66:D7:68:87:18:7E:54:0D:70:27:91:C7:26:D7:85:65:C0 - X509v3 Authority Key Identifier: - keyid:33:D8:45:66:D7:68:87:18:7E:54:0D:70:27:91:C7:26:D7:85:65:C0 - DirName:/C=US/ST=Montana/L=Bozeman/O=wolfSSL_2048/OU=Programming-2048/CN=www.wolfssl.com/emailAddress=info@wolfssl.com - serial:AA:27:B3:C5:A9:72:6E:0D - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: sha256WithRSAEncryption - 51:96:a7:1c:26:5d:1c:90:c6:32:9f:96:15:f2:1d:e7:93:9c: - ac:75:56:95:fd:20:70:ab:45:6a:09:b0:f3:f2:03:a8:db:dc: - 2f:bc:1f:87:7a:a3:d4:8f:d5:49:97:7e:3c:54:ac:b1:e3:f0: - 39:0d:fe:09:9a:23:f6:32:a6:41:59:bd:60:e8:bd:de:00:36: - 6f:3e:e9:41:6f:a9:63:c7:aa:d5:7b:f3:e4:39:48:9e:f6:60: - c6:c6:86:d5:72:86:23:cd:f5:6a:63:53:a4:f8:fc:51:6a:cd: - 60:74:8e:a3:86:61:01:34:78:f7:29:97:b3:a7:34:b6:0a:de: - b5:71:7a:09:a6:3e:d6:82:58:89:67:9c:c5:68:62:ba:06:d6: - 39:bb:cb:3a:c0:e0:63:1f:c7:0c:9c:12:86:ec:f7:39:6a:61: - 93:d0:33:14:c6:55:3b:b6:cf:80:5b:8c:43:ef:43:44:0b:3c: - 93:39:a3:4e:15:d1:0b:5f:84:98:1d:cd:9f:a9:47:eb:3b:56: - 30:b6:76:92:c1:48:5f:bc:95:b0:50:1a:55:c8:4e:62:47:87: - 54:64:0c:9b:91:fa:43:b3:29:48:be:e6:12:eb:e3:44:c6:52: - e4:40:c6:83:95:1b:a7:65:27:69:73:2f:c8:a0:4d:7f:be:ea: - 9b:67:b2:7b ------BEGIN CERTIFICATE----- -MIIEyjCCA7KgAwIBAgIJAKons8Wpcm4NMA0GCSqGSIb3DQEBCwUAMIGeMQswCQYD -VQQGEwJVUzEQMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjEVMBMG -A1UECgwMd29sZlNTTF8yMDQ4MRkwFwYDVQQLDBBQcm9ncmFtbWluZy0yMDQ4MRgw -FgYDVQQDDA93d3cud29sZnNzbC5jb20xHzAdBgkqhkiG9w0BCQEWEGluZm9Ad29s -ZnNzbC5jb20wHhcNMTUwNTA3MTgyMTAxWhcNMTgwMTMxMTgyMTAxWjCBnjELMAkG -A1UEBhMCVVMxEDAOBgNVBAgMB01vbnRhbmExEDAOBgNVBAcMB0JvemVtYW4xFTAT -BgNVBAoMDHdvbGZTU0xfMjA0ODEZMBcGA1UECwwQUHJvZ3JhbW1pbmctMjA0ODEY -MBYGA1UEAwwPd3d3LndvbGZzc2wuY29tMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdv -bGZzc2wuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwwPRK/45 -pDJFO1PIhCsqfHSavaoqUgdH1qY2sgcyjtC6aXvGw0Se1IFI/S1oootnu6F1yDYs -StIb94u6zw357+zxgR57mwNHmr9lzH9lJGmm6BSJW+Q098WwFJP1Z3s6enjhAVZW -kaYTQo3SPECcTO/Rht83URsMoTv18aNKNeThzpbfG36/TpfQEOioCDCBryALQxTF -dGe0MoJvjYbCiECZNoO6HkByIhfXUmUkc7DO7xnNrv94bHvAEgPUTnINUG07ozuj -mV6dyNkMhbPZitlUJttt+qy7/yVMxNF59HHThkAYE7BjtXJOMMSXhIYtVi/XFfd/ -wK71/Fvl+6G60wIDAQABo4IBBzCCAQMwHQYDVR0OBBYEFDPYRWbXaIcYflQNcCeR -xybXhWXAMIHTBgNVHSMEgcswgciAFDPYRWbXaIcYflQNcCeRxybXhWXAoYGkpIGh -MIGeMQswCQYDVQQGEwJVUzEQMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96 -ZW1hbjEVMBMGA1UECgwMd29sZlNTTF8yMDQ4MRkwFwYDVQQLDBBQcm9ncmFtbWlu -Zy0yMDQ4MRgwFgYDVQQDDA93d3cud29sZnNzbC5jb20xHzAdBgkqhkiG9w0BCQEW -EGluZm9Ad29sZnNzbC5jb22CCQCqJ7PFqXJuDTAMBgNVHRMEBTADAQH/MA0GCSqG -SIb3DQEBCwUAA4IBAQBRlqccJl0ckMYyn5YV8h3nk5ysdVaV/SBwq0VqCbDz8gOo -29wvvB+HeqPUj9VJl348VKyx4/A5Df4JmiP2MqZBWb1g6L3eADZvPulBb6ljx6rV -e/PkOUie9mDGxobVcoYjzfVqY1Ok+PxRas1gdI6jhmEBNHj3KZezpzS2Ct61cXoJ -pj7WgliJZ5zFaGK6BtY5u8s6wOBjH8cMnBKG7Pc5amGT0DMUxlU7ts+AW4xD70NE -CzyTOaNOFdELX4SYHc2fqUfrO1YwtnaSwUhfvJWwUBpVyE5iR4dUZAybkfpDsylI -vuYS6+NExlLkQMaDlRunZSdpcy/IoE1/vuqbZ7J7 ------END CERTIFICATE----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/client-ecc-cert.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/client-ecc-cert.pem deleted file mode 100755 index 2090515..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/client-ecc-cert.pem +++ /dev/null @@ -1,54 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 16108595702940209934 (0xdf8d3a71e022930e) - Signature Algorithm: ecdsa-with-SHA256 - Issuer: C=US, ST=Oregon, L=Salem, O=Client ECC, OU=Fast, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Validity - Not Before: May 7 18:21:01 2015 GMT - Not After : Jan 31 18:21:01 2018 GMT - Subject: C=US, ST=Oregon, L=Salem, O=Client ECC, OU=Fast, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Subject Public Key Info: - Public Key Algorithm: id-ecPublicKey - Public-Key: (256 bit) - pub: - 04:55:bf:f4:0f:44:50:9a:3d:ce:9b:b7:f0:c5:4d: - f5:70:7b:d4:ec:24:8e:19:80:ec:5a:4c:a2:24:03: - 62:2c:9b:da:ef:a2:35:12:43:84:76:16:c6:56:95: - 06:cc:01:a9:bd:f6:75:1a:42:f7:bd:a9:b2:36:22: - 5f:c7:5d:7f:b4 - ASN1 OID: prime256v1 - X509v3 extensions: - X509v3 Subject Key Identifier: - EB:D4:4B:59:6B:95:61:3F:51:57:B6:04:4D:89:41:88:44:5C:AB:F2 - X509v3 Authority Key Identifier: - keyid:EB:D4:4B:59:6B:95:61:3F:51:57:B6:04:4D:89:41:88:44:5C:AB:F2 - DirName:/C=US/ST=Oregon/L=Salem/O=Client ECC/OU=Fast/CN=www.wolfssl.com/emailAddress=info@wolfssl.com - serial:DF:8D:3A:71:E0:22:93:0E - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: ecdsa-with-SHA256 - 30:44:02:20:74:7b:ae:7e:9c:c8:69:95:8a:0b:ad:7f:c9:37: - 3d:3c:7f:b7:ef:f3:da:9b:ea:d0:a7:76:0a:a4:77:12:f7:a8: - 02:20:71:95:87:89:b7:a8:8b:bb:fa:9f:84:dc:2b:71:dc:4a: - c5:5a:65:b2:fc:33:c4:ce:36:4f:ab:c6:38:36:6c:88 ------BEGIN CERTIFICATE----- -MIIDCDCCAq+gAwIBAgIJAN+NOnHgIpMOMAoGCCqGSM49BAMCMIGNMQswCQYDVQQG -EwJVUzEPMA0GA1UECAwGT3JlZ29uMQ4wDAYDVQQHDAVTYWxlbTETMBEGA1UECgwK -Q2xpZW50IEVDQzENMAsGA1UECwwERmFzdDEYMBYGA1UEAwwPd3d3LndvbGZzc2wu -Y29tMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdvbGZzc2wuY29tMB4XDTE1MDUwNzE4 -MjEwMVoXDTE4MDEzMTE4MjEwMVowgY0xCzAJBgNVBAYTAlVTMQ8wDQYDVQQIDAZP -cmVnb24xDjAMBgNVBAcMBVNhbGVtMRMwEQYDVQQKDApDbGllbnQgRUNDMQ0wCwYD -VQQLDARGYXN0MRgwFgYDVQQDDA93d3cud29sZnNzbC5jb20xHzAdBgkqhkiG9w0B -CQEWEGluZm9Ad29sZnNzbC5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARV -v/QPRFCaPc6bt/DFTfVwe9TsJI4ZgOxaTKIkA2Ism9rvojUSQ4R2FsZWlQbMAam9 -9nUaQve9qbI2Il/HXX+0o4H1MIHyMB0GA1UdDgQWBBTr1EtZa5VhP1FXtgRNiUGI -RFyr8jCBwgYDVR0jBIG6MIG3gBTr1EtZa5VhP1FXtgRNiUGIRFyr8qGBk6SBkDCB -jTELMAkGA1UEBhMCVVMxDzANBgNVBAgMBk9yZWdvbjEOMAwGA1UEBwwFU2FsZW0x -EzARBgNVBAoMCkNsaWVudCBFQ0MxDTALBgNVBAsMBEZhc3QxGDAWBgNVBAMMD3d3 -dy53b2xmc3NsLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbYIJ -AN+NOnHgIpMOMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIgdHuufpzI -aZWKC61/yTc9PH+37/Pam+rQp3YKpHcS96gCIHGVh4m3qIu7+p+E3Ctx3ErFWmWy -/DPEzjZPq8Y4NmyI ------END CERTIFICATE----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/client-key.der b/FreeRTOS-Plus/Source/WolfSSL/certs/client-key.der deleted file mode 100755 index 94dc253..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/client-key.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/client-key.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/client-key.pem deleted file mode 100755 index c4e7ad2..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/client-key.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEAwwPRK/45pDJFO1PIhCsqfHSavaoqUgdH1qY2sgcyjtC6aXvG -w0Se1IFI/S1oootnu6F1yDYsStIb94u6zw357+zxgR57mwNHmr9lzH9lJGmm6BSJ -W+Q098WwFJP1Z3s6enjhAVZWkaYTQo3SPECcTO/Rht83URsMoTv18aNKNeThzpbf -G36/TpfQEOioCDCBryALQxTFdGe0MoJvjYbCiECZNoO6HkByIhfXUmUkc7DO7xnN -rv94bHvAEgPUTnINUG07ozujmV6dyNkMhbPZitlUJttt+qy7/yVMxNF59HHThkAY -E7BjtXJOMMSXhIYtVi/XFfd/wK71/Fvl+6G60wIDAQABAoIBAQCi5thfEHFkCJ4u -bdFtHoXSCrGMR84sUWqgEp5T3pFMHW3qWXvyd6rZxtmKq9jhFuRjJv+1bBNZuOOl -yHIXLgyfb+VZP3ZvSbERwlouFikN3reO3EDVou7gHqH0vpfbhmOWFM2YCWAtMHac -PM3miO5HknkLWgDiXl8RfH35CLcgBokqXf0AqyLh8LO8JKleJg4fAC3+IZpTW23T -K6uUgmhDNtj2L8Yi/LVBXQ0zYOqkfX7oS1WRVtNcV48flBcvqt7pnqj0z4pMjqDk -VnOyz0+GxWk88yQgi1yWDPprEjuaZ8HfxpaypdWSDZsJQmgkEEXUUOQXOUjQNYuU -bRHej8pZAoGBAOokp/lpM+lx3FJ9iCEoL0neunIW6cxHeogNlFeEWBY6gbA/os+m -bB6wBikAj+d3dqzbysfZXps/JpBSrvw4kAAUu7QPWJTnL2p+HE9BIdQxWR9OihqN -p1dsItjl9H4yphDLZKVVA4emJwWMw9e2J7JNujDaR49U0z2LhI2UmFilAoGBANU4 -G8OPxZMMRwtvNZLFsI1GyJIYj/WACvfvof6AubUqusoYsF2lB9CTjdicBBzUYo6m -JoEB/86KKmM0NUCqbYDeiSNqV02ebq2TTlaQC22dc4sMric93k7wqsVseGdslFKc -N2dsLe+7r9+mkDzER8+Nlp6YqbSfxaZQ3LPw+3QXAoGAXoMJYr26fKK/QnT1fBzS -ackEDYV+Pj0kEsMYe/Mp818OdmxZdeRBhGmdMvPNIquwNbpKsjzl2Vi2Yk9d3uWe -CspTsiz3nrNrClt5ZexukU6SIPb8/Bbt03YM4ux/smkTa3gOWkZktF63JaBadTpL -78c8Pvf9JrggxJkKmnO+wxkCgYEAukSTFKw0GTtfkWCs97TWgQU2UVM96GXcry7c -YT7Jfbh/h/A7mwOCKTfOck4R1bHBDAegmZFKjX/sec/xObXphexi99p9vGRNIjwO -8tZR9YfYmcARIF0PKf1b4q7ZHNkhVm38hNBf7RAVHBgh58Q9S9fQnmqVzyLJA3ue -42AB/C8CgYAR0EvPG2e5nxB1R4ZlrjHCxjCsWQZQ2Q+1cAb38NPIYnyo2m72IT/T -f1/qiqs/2Spe81HSwjA34y2jdQ0eTSE01VdwXIm/cuxKbmjVzRh0M06MOkWP5pZA -62P5GYY6Ud2JS7Dz+Z9dKJU4vjWrylznk1M0oUVdEzllQkahn831vw== ------END RSA PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/client-keyEnc.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/client-keyEnc.pem deleted file mode 100755 index 5476dc9..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/client-keyEnc.pem +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-CBC,45B763473154576D - -8ZSASs14Oqtc8p2nx5sx8oqPsgZmf0IfZTCzXLFivaA0UXdCQLxtsthQRQ07xRrH -if96wh11dWuxW0dkSLKna9HguzNQ96ybbw5CwCCkYrfjef7sxoEUe9D6j3UMXZ/F -iaVPMmbHTcf9gn1ozkkxPSlsts/5f8AKFloHRXUE1jAih4wLB3mbIyDG9iKm45ck -Rn7+u6Fe3hDG/9JWtbLW3ePh5L455U6zP5hlneodDZEabUguUef7EMzXE01LqPAy -qeatI7t54cAGkUVgGbZrsKcXtiDtRNUefa9hb90tugY29LAt1ls5K68kR1x9U+TM -kWgjMzmhab5e7Alh+yMfDg2WplI2EHTDuLvcX9Vh1OHe7akN67EN/0IYcpGCryfe -RHLYvNNjXyJWfMKuo0XVqMY1JyBDebYJTlEafwNcjSBWSo5U4uihnVXvj8NfU36Z -JIeGGo6fyq5D0pPjvtRpk3XwbzQlvAQSDxbFp9dIX7m46Ji7YaeQO8Fgg1L5ENfm -wTx6xdPPdFb3ux0ksiU8QoF7190kjmS4SbeSLvpLjGh1f3dz6suJ+7+KN0ZwQd4e -Ki+IDuaKhYR1vn0ROVvUQ0+nmkunblcO6HyhcTgWiSCBIWhTwrRJIV4tmiQYS5bc -G7PqGIIOsFwwOwY4IWYt57YS0DGJsbdBuXToZgnnpG0yvnsIkeasEc5h4KCslQ0o -lztCFZxGITjDtt+b8acnCEN2calYBkKZfc1LV1u/Fh2no1CnDtjHqk0E0tcjuU6M -sZ3NSiiI0puvG91LtwidHP7x0okR2voG8joN3XmBDigUo/6SazjPoWwhOFIuE/MY -aXnPMFxgZ/KV5DcPWa3lOTMIfOzY84aMs4q4q4huCX9/MVe4ZjcuI1T8RCoSSvTu -jOV+eJL7N2uZi40BWVPMwFOIkgVn3oK99L/FtTJUzYDXqVb0Cmi6bg0FrwGQOJMV -M+ETvTW89k+Zy/RLXiFvdGeCHQXwkUJYlQGJkrkC5fWevEDmdH2qZbcgs/o8X5tg -lFOGoXRvmMLrNXLQVt5SGKsTjRxMbbSmNY3J+e2hFVkc8oslQZqtacDlZ29D0enQ -6me7+n2Qy6QOeTJ1pQOY5jHiJwsub2OCx1oML6lKBpn7g0taUGZauSIr+R14F/R7 -YhgO2QTydUrbs7jOwaIitdiwNuaHlFIujB8tqo1xAjPE18QL4NbqV/CUzLDuyiB+ -3hHmzRJ1aQTGO0/2ucbUqf6MUWvNuc6zFg5AETSg1or8A7gqi8/HdlBR6wUo+rug -IvJ2OkR9vyR8QJDOM9Pn8TS0e0B7TVqb8rUltzRtXOcbtLL3Xvy00+wlVyyiLRPz -u/u355ZoMDZLVhOoVoLGlXhA+St91qrELpe1O8aNrqOQy3pyhybiPOh9lgtqyr1C -QMQLcBGdoyMCsSiuDFbV+7thd/rQPE1Qqy06rStv1OEv9Y+hzZxrzF8HSfSLuNPd -UCDn9SSzZwGU9odLJNrzSNfz8GDVc72lKHlIR4bHMw0FW2QPsJR8NrN6ch4oYmfw -17R/cQ9CfWA0cEcSiAKIthbP7NHWw4SAhJ6sqwpDK4Vh8PrDF3U6WCEEshaokm+H ------END RSA PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/crl/cliCrl.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/crl/cliCrl.pem deleted file mode 100755 index da4e617..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/crl/cliCrl.pem +++ /dev/null @@ -1,39 +0,0 @@ -Certificate Revocation List (CRL): - Version 2 (0x1) - Signature Algorithm: sha256WithRSAEncryption - Issuer: /C=US/ST=Montana/L=Bozeman/O=wolfSSL_2048/OU=Programming-2048/CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Last Update: May 7 18:21:01 2015 GMT - Next Update: Jan 31 18:21:01 2018 GMT - CRL extensions: - X509v3 CRL Number: - 3 -No Revoked Certificates. - Signature Algorithm: sha256WithRSAEncryption - a2:15:f0:cf:70:85:49:b9:5b:c1:af:2b:22:14:9d:ee:11:8d: - 93:2d:58:17:d8:f6:b6:1a:1a:25:a2:27:c9:6b:4f:b3:31:c7: - 2c:52:c4:53:59:19:ef:cf:91:ee:b5:19:28:37:49:9e:b6:e0: - 41:62:4c:9f:f1:34:bf:88:aa:ae:24:38:8d:29:0a:64:08:a8: - 68:f4:b5:28:73:d6:94:b9:0a:3f:7c:c1:22:72:be:14:ba:c9: - 1b:9d:26:af:78:c2:cf:5f:ff:1e:cc:25:c0:63:f1:9b:97:85: - 5c:c0:4d:14:ed:f9:ad:cb:02:7d:05:c7:5c:c1:7c:89:72:35: - 49:70:a8:b1:ae:91:96:77:9a:c6:cb:38:27:88:3f:f4:c8:ba: - c9:08:7f:dd:a6:41:82:62:65:a0:f2:0c:36:5a:d9:15:57:5e: - 66:c3:a2:ff:5e:4d:7c:bc:4b:7c:30:84:44:e3:06:34:a8:42: - 3b:d9:6a:04:4a:0b:e5:59:66:63:b9:7a:80:48:68:31:1c:aa: - 98:bc:09:0e:a7:83:5f:a7:00:f1:fb:78:bc:08:86:73:ef:53: - 25:b8:1b:5e:7c:77:a8:12:7b:52:7f:1e:63:bc:db:60:99:46: - ab:e1:2e:48:d1:28:40:68:1e:9e:a0:2f:14:04:66:b3:b1:b1: - 3b:d0:46:64 ------BEGIN X509 CRL----- -MIIB+DCB4QIBATANBgkqhkiG9w0BAQsFADCBnjELMAkGA1UEBhMCVVMxEDAOBgNV -BAgMB01vbnRhbmExEDAOBgNVBAcMB0JvemVtYW4xFTATBgNVBAoMDHdvbGZTU0xf -MjA0ODEZMBcGA1UECwwQUHJvZ3JhbW1pbmctMjA0ODEYMBYGA1UEAwwPd3d3Lndv -bGZzc2wuY29tMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdvbGZzc2wuY29tFw0xNTA1 -MDcxODIxMDFaFw0xODAxMzExODIxMDFaoA4wDDAKBgNVHRQEAwIBAzANBgkqhkiG -9w0BAQsFAAOCAQEAohXwz3CFSblbwa8rIhSd7hGNky1YF9j2thoaJaInyWtPszHH -LFLEU1kZ78+R7rUZKDdJnrbgQWJMn/E0v4iqriQ4jSkKZAioaPS1KHPWlLkKP3zB -InK+FLrJG50mr3jCz1//HswlwGPxm5eFXMBNFO35rcsCfQXHXMF8iXI1SXCosa6R -lneaxss4J4g/9Mi6yQh/3aZBgmJloPIMNlrZFVdeZsOi/15NfLxLfDCEROMGNKhC -O9lqBEoL5VlmY7l6gEhoMRyqmLwJDqeDX6cA8ft4vAiGc+9TJbgbXnx3qBJ7Un8e -Y7zbYJlGq+EuSNEoQGgenqAvFARms7GxO9BGZA== ------END X509 CRL----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/crl/crl.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/crl/crl.pem deleted file mode 100755 index 28311c7..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/crl/crl.pem +++ /dev/null @@ -1,39 +0,0 @@ -Certificate Revocation List (CRL): - Version 2 (0x1) - Signature Algorithm: sha256WithRSAEncryption - Issuer: /C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Last Update: May 7 18:21:01 2015 GMT - Next Update: Jan 31 18:21:01 2018 GMT - CRL extensions: - X509v3 CRL Number: - 1 -No Revoked Certificates. - Signature Algorithm: sha256WithRSAEncryption - 96:e2:b9:11:e0:e5:25:be:ab:69:e5:fa:8a:5c:7f:fc:6f:1d: - 8f:4a:54:70:f8:2e:87:fa:b0:f6:fd:3f:8f:9c:75:8a:eb:62: - cc:dd:2c:0a:8c:31:9e:30:3f:22:9b:91:50:6b:43:fd:32:8a: - 79:ea:0b:6b:68:6c:82:9c:79:da:20:95:83:25:5e:09:fc:57: - 2d:19:f9:bc:5a:67:95:98:65:dc:2d:91:13:2a:81:c2:6d:ff: - 12:48:6f:a4:ce:8a:b2:d3:19:b8:c2:86:e0:ba:91:3f:bb:ec: - c6:79:83:50:95:19:95:28:eb:ef:ff:bb:16:8f:3c:7d:4c:d1: - 3e:c3:82:22:8f:c5:e8:0e:b3:64:8f:5d:53:32:d5:98:64:9c: - 36:c4:6a:cf:68:21:4f:a8:4e:90:37:76:dc:05:70:66:2d:bc: - a0:d8:19:5c:96:90:d6:b9:09:56:46:07:be:3c:ae:08:bb:26: - 26:21:2c:d1:48:01:88:28:bc:21:a4:97:b7:3b:f0:7e:67:73: - 84:cf:21:43:e7:dd:53:9d:6a:59:c3:e5:98:c9:69:71:c3:e3: - 70:28:ba:f9:69:0a:af:78:e5:83:02:13:7e:08:70:8c:f3:8b: - 5d:96:b0:78:b9:d9:99:c5:1e:b7:45:dc:28:32:1a:d0:50:4b: - f4:41:92:19 ------BEGIN X509 CRL----- -MIIB7jCB1wIBATANBgkqhkiG9w0BAQsFADCBlDELMAkGA1UEBhMCVVMxEDAOBgNV -BAgMB01vbnRhbmExEDAOBgNVBAcMB0JvemVtYW4xETAPBgNVBAoMCFNhd3Rvb3Ro -MRMwEQYDVQQLDApDb25zdWx0aW5nMRgwFgYDVQQDDA93d3cud29sZnNzbC5jb20x -HzAdBgkqhkiG9w0BCQEWEGluZm9Ad29sZnNzbC5jb20XDTE1MDUwNzE4MjEwMVoX -DTE4MDEzMTE4MjEwMVqgDjAMMAoGA1UdFAQDAgEBMA0GCSqGSIb3DQEBCwUAA4IB -AQCW4rkR4OUlvqtp5fqKXH/8bx2PSlRw+C6H+rD2/T+PnHWK62LM3SwKjDGeMD8i -m5FQa0P9Mop56gtraGyCnHnaIJWDJV4J/FctGfm8WmeVmGXcLZETKoHCbf8SSG+k -zoqy0xm4wobgupE/u+zGeYNQlRmVKOvv/7sWjzx9TNE+w4Iij8XoDrNkj11TMtWY -ZJw2xGrPaCFPqE6QN3bcBXBmLbyg2BlclpDWuQlWRge+PK4IuyYmISzRSAGIKLwh -pJe3O/B+Z3OEzyFD591TnWpZw+WYyWlxw+NwKLr5aQqveOWDAhN+CHCM84tdlrB4 -udmZxR63RdwoMhrQUEv0QZIZ ------END X509 CRL----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/crl/crl.revoked b/FreeRTOS-Plus/Source/WolfSSL/certs/crl/crl.revoked deleted file mode 100755 index 60152d8..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/crl/crl.revoked +++ /dev/null @@ -1,41 +0,0 @@ -Certificate Revocation List (CRL): - Version 2 (0x1) - Signature Algorithm: sha256WithRSAEncryption - Issuer: /C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Last Update: May 7 18:21:01 2015 GMT - Next Update: Jan 31 18:21:01 2018 GMT - CRL extensions: - X509v3 CRL Number: - 2 -Revoked Certificates: - Serial Number: 01 - Revocation Date: May 7 18:21:01 2015 GMT - Signature Algorithm: sha256WithRSAEncryption - b7:34:2b:1c:09:6b:a2:9c:12:4f:fd:ef:69:4c:a4:1d:f2:39: - 52:29:98:78:b2:86:ea:54:9b:29:e5:c2:88:0e:2f:f9:d2:5b: - 9d:49:37:68:26:6c:45:61:d4:9d:05:ef:2d:ca:78:0a:d0:28: - c1:25:f2:f7:6a:ad:df:1d:eb:8a:66:64:4d:0c:02:91:fb:ff: - 70:b4:36:b6:e4:79:17:d5:18:6a:72:17:e1:8b:31:49:04:98: - 96:88:42:ea:8c:fe:91:40:5a:c5:ad:3b:da:9a:47:43:d6:e9: - f6:59:75:49:91:a9:e4:8b:c8:03:60:6b:36:69:87:71:f1:5b: - 92:00:51:bb:fe:d5:4f:0d:0e:f2:56:38:e3:b6:cb:76:11:7b: - 17:ad:a5:da:37:87:f2:49:af:73:42:56:ed:6c:a1:8d:46:5c: - dd:00:a7:8f:1f:5a:dd:d7:87:89:43:30:32:fe:e2:d4:b1:29: - 12:11:ef:22:0d:8f:7f:c5:33:3b:a9:a7:52:0c:25:b8:0c:e6: - 8a:8b:68:8f:55:84:65:04:c7:44:48:36:02:4d:4e:43:09:1d: - 1f:3b:f9:4a:0e:ff:59:42:ca:be:0e:a7:79:89:19:31:73:5a: - 45:6c:70:56:4d:1b:8a:59:c4:6d:ca:bc:f7:41:c4:f6:f0:fd: - 9c:7e:f1:7e ------BEGIN X509 CRL----- -MIICBDCB7QIBATANBgkqhkiG9w0BAQsFADCBlDELMAkGA1UEBhMCVVMxEDAOBgNV -BAgMB01vbnRhbmExEDAOBgNVBAcMB0JvemVtYW4xETAPBgNVBAoMCFNhd3Rvb3Ro -MRMwEQYDVQQLDApDb25zdWx0aW5nMRgwFgYDVQQDDA93d3cud29sZnNzbC5jb20x -HzAdBgkqhkiG9w0BCQEWEGluZm9Ad29sZnNzbC5jb20XDTE1MDUwNzE4MjEwMVoX -DTE4MDEzMTE4MjEwMVowFDASAgEBFw0xNTA1MDcxODIxMDFaoA4wDDAKBgNVHRQE -AwIBAjANBgkqhkiG9w0BAQsFAAOCAQEAtzQrHAlropwST/3vaUykHfI5UimYeLKG -6lSbKeXCiA4v+dJbnUk3aCZsRWHUnQXvLcp4CtAowSXy92qt3x3rimZkTQwCkfv/ -cLQ2tuR5F9UYanIX4YsxSQSYlohC6oz+kUBaxa072ppHQ9bp9ll1SZGp5IvIA2Br -NmmHcfFbkgBRu/7VTw0O8lY447bLdhF7F62l2jeH8kmvc0JW7WyhjUZc3QCnjx9a -3deHiUMwMv7i1LEpEhHvIg2Pf8UzO6mnUgwluAzmiotoj1WEZQTHREg2Ak1OQwkd -Hzv5Sg7/WULKvg6neYkZMXNaRWxwVk0bilnEbcq890HE9vD9nH7xfg== ------END X509 CRL----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/crl/eccCliCRL.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/crl/eccCliCRL.pem deleted file mode 100755 index 2e00a37..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/crl/eccCliCRL.pem +++ /dev/null @@ -1,24 +0,0 @@ -Certificate Revocation List (CRL): - Version 2 (0x1) - Signature Algorithm: ecdsa-with-SHA256 - Issuer: /C=US/ST=Oregon/L=Salem/O=Client ECC/OU=Fast/CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Last Update: May 7 18:21:01 2015 GMT - Next Update: Jan 31 18:21:01 2018 GMT - CRL extensions: - X509v3 CRL Number: - 4 -No Revoked Certificates. - Signature Algorithm: ecdsa-with-SHA256 - 30:44:02:20:62:9b:53:ee:21:52:bc:61:e8:ec:7b:f8:28:35: - 43:98:b8:57:9c:c7:73:cc:a0:45:e8:b9:96:2e:1c:c6:62:ff: - 02:20:2b:64:b8:3a:30:2c:15:7f:cf:57:99:60:9d:51:82:82: - ef:b6:13:cc:86:93:a2:19:41:12:a0:ec:7e:1e:07:09 ------BEGIN X509 CRL----- -MIIBJTCBzQIBATAKBggqhkjOPQQDAjCBjTELMAkGA1UEBhMCVVMxDzANBgNVBAgM -Bk9yZWdvbjEOMAwGA1UEBwwFU2FsZW0xEzARBgNVBAoMCkNsaWVudCBFQ0MxDTAL -BgNVBAsMBEZhc3QxGDAWBgNVBAMMD3d3dy53b2xmc3NsLmNvbTEfMB0GCSqGSIb3 -DQEJARYQaW5mb0B3b2xmc3NsLmNvbRcNMTUwNTA3MTgyMTAxWhcNMTgwMTMxMTgy -MTAxWqAOMAwwCgYDVR0UBAMCAQQwCgYIKoZIzj0EAwIDRwAwRAIgYptT7iFSvGHo -7Hv4KDVDmLhXnMdzzKBF6LmWLhzGYv8CICtkuDowLBV/z1eZYJ1RgoLvthPMhpOi -GUESoOx+HgcJ ------END X509 CRL----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/crl/eccSrvCRL.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/crl/eccSrvCRL.pem deleted file mode 100755 index 0746599..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/crl/eccSrvCRL.pem +++ /dev/null @@ -1,24 +0,0 @@ -Certificate Revocation List (CRL): - Version 2 (0x1) - Signature Algorithm: ecdsa-with-SHA256 - Issuer: /C=US/ST=Washington/L=Seattle/O=Eliptic/OU=ECC/CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Last Update: May 7 18:21:01 2015 GMT - Next Update: Jan 31 18:21:01 2018 GMT - CRL extensions: - X509v3 CRL Number: - 5 -No Revoked Certificates. - Signature Algorithm: ecdsa-with-SHA256 - 30:45:02:20:0d:fe:b7:79:fb:66:6c:cb:36:0a:1a:f3:6d:73: - ea:68:ab:fc:46:7e:49:bd:15:2a:9f:a1:17:50:56:82:cf:1f: - 02:21:00:ff:13:85:80:29:a4:60:54:10:93:fb:20:13:b8:9c: - 25:48:53:5e:4b:33:ef:5c:aa:9e:98:74:e0:c8:c3:ef:df ------BEGIN X509 CRL----- -MIIBKDCBzwIBATAKBggqhkjOPQQDAjCBjzELMAkGA1UEBhMCVVMxEzARBgNVBAgM -Cldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxEDAOBgNVBAoMB0VsaXB0aWMx -DDAKBgNVBAsMA0VDQzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29tMR8wHQYJKoZI -hvcNAQkBFhBpbmZvQHdvbGZzc2wuY29tFw0xNTA1MDcxODIxMDFaFw0xODAxMzEx -ODIxMDFaoA4wDDAKBgNVHRQEAwIBBTAKBggqhkjOPQQDAgNIADBFAiAN/rd5+2Zs -yzYKGvNtc+poq/xGfkm9FSqfoRdQVoLPHwIhAP8ThYAppGBUEJP7IBO4nCVIU15L -M+9cqp6YdODIw+/f ------END X509 CRL----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/crl/include.am b/FreeRTOS-Plus/Source/WolfSSL/certs/crl/include.am deleted file mode 100755 index 7adca32..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/crl/include.am +++ /dev/null @@ -1,14 +0,0 @@ -# vim:ft=automake -# All paths should be given relative to the root -# - -EXTRA_DIST += \ - certs/crl/crl.pem \ - certs/crl/cliCrl.pem \ - certs/crl/eccSrvCRL.pem \ - certs/crl/eccCliCRL.pem - -EXTRA_DIST += \ - certs/crl/crl.revoked - - diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/dh2048.der b/FreeRTOS-Plus/Source/WolfSSL/certs/dh2048.der deleted file mode 100755 index afdc522..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/dh2048.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/dh2048.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/dh2048.pem deleted file mode 100755 index 1e2b848..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/dh2048.pem +++ /dev/null @@ -1,29 +0,0 @@ -Diffie-Hellman-Parameters: (2048 bit) - prime: - 00:b0:a1:08:06:9c:08:13:ba:59:06:3c:bc:30:d5: - f5:00:c1:4f:44:a7:d6:ef:4a:c6:25:27:1c:e8:d2: - 96:53:0a:5c:91:dd:a2:c2:94:84:bf:7d:b2:44:9f: - 9b:d2:c1:8a:c5:be:72:5c:a7:e7:91:e6:d4:9f:73: - 07:85:5b:66:48:c7:70:fa:b4:ee:02:c9:3d:9a:4a: - da:3d:c1:46:3e:19:69:d1:17:46:07:a3:4d:9f:2b: - 96:17:39:6d:30:8d:2a:f3:94:d3:75:cf:a0:75:e6: - f2:92:1f:1a:70:05:aa:04:83:57:30:fb:da:76:93: - 38:50:e8:27:fd:63:ee:3c:e5:b7:c8:09:ae:6f:50: - 35:8e:84:ce:4a:00:e9:12:7e:5a:31:d7:33:fc:21: - 13:76:cc:16:30:db:0c:fc:c5:62:a7:35:b8:ef:b7: - b0:ac:c0:36:f6:d9:c9:46:48:f9:40:90:00:2b:1b: - aa:6c:e3:1a:c3:0b:03:9e:1b:c2:46:e4:48:4e:22: - 73:6f:c3:5f:d4:9a:d6:30:07:48:d6:8c:90:ab:d4: - f6:f1:e3:48:d3:58:4b:a6:b9:cd:29:bf:68:1f:08: - 4b:63:86:2f:5c:6b:d6:b6:06:65:f7:a6:dc:00:67: - 6b:bb:c3:a9:41:83:fb:c7:fa:c8:e2:1e:7e:af:00: - 3f:93 - generator: 2 (0x2) ------BEGIN DH PARAMETERS----- -MIIBCAKCAQEAsKEIBpwIE7pZBjy8MNX1AMFPRKfW70rGJScc6NKWUwpckd2iwpSE -v32yRJ+b0sGKxb5yXKfnkebUn3MHhVtmSMdw+rTuAsk9mkraPcFGPhlp0RdGB6NN -nyuWFzltMI0q85TTdc+gdebykh8acAWqBINXMPvadpM4UOgn/WPuPOW3yAmub1A1 -joTOSgDpEn5aMdcz/CETdswWMNsM/MVipzW477ewrMA29tnJRkj5QJAAKxuqbOMa -wwsDnhvCRuRITiJzb8Nf1JrWMAdI1oyQq9T28eNI01hLprnNKb9oHwhLY4YvXGvW -tgZl96bcAGdru8OpQYP7x/rI4h5+rwA/kwIBAg== ------END DH PARAMETERS----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/dsa2048.der b/FreeRTOS-Plus/Source/WolfSSL/certs/dsa2048.der deleted file mode 100755 index 0bcb0b4..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/dsa2048.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-client-key.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-client-key.pem deleted file mode 100755 index cf9812d..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-client-key.pem +++ /dev/null @@ -1,9 +0,0 @@ -ASN1 OID: prime256v1 ------BEGIN EC PARAMETERS----- -BggqhkjOPQMBBw== ------END EC PARAMETERS----- ------BEGIN EC PRIVATE KEY----- -MHcCAQEEIPjPkmu9HijxqKuhI08ydBiIUK1+x+yS+I+XTa9WiWXHoAoGCCqGSM49 -AwEHoUQDQgAEVb/0D0RQmj3Om7fwxU31cHvU7CSOGYDsWkyiJANiLJva76I1EkOE -dhbGVpUGzAGpvfZ1GkL3vamyNiJfx11/tA== ------END EC PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-key-comp.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-key-comp.pem deleted file mode 100755 index de76b8e..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-key-comp.pem +++ /dev/null @@ -1,4 +0,0 @@ ------BEGIN EC PRIVATE KEY----- -MFcCAQEEIEW2aQJznGyFoThbcujox6zEA41TNQT6bCjcNI3hqAmMoAoGCCqGSM49 -AwEHoSQDIgACuzOsTCdQSsZKpQTDPN6fNttyLc6U6iv6yyAJOSwW6GE= ------END EC PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-key.der b/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-key.der deleted file mode 100755 index a88d141..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-key.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-key.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-key.pem deleted file mode 100755 index 03e7a61..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-key.pem +++ /dev/null @@ -1,9 +0,0 @@ -ASN1 OID: prime256v1 ------BEGIN EC PARAMETERS----- -BggqhkjOPQMBBw== ------END EC PARAMETERS----- ------BEGIN EC PRIVATE KEY----- -MHcCAQEEIEW2aQJznGyFoThbcujox6zEA41TNQT6bCjcNI3hqAmMoAoGCCqGSM49 -AwEHoUQDQgAEuzOsTCdQSsZKpQTDPN6fNttyLc6U6iv6yyAJOSwW6GEC6a9N0wKT -mjFbl5Ihf/DPGNqREQI0huggWDMLgDSJ2A== ------END EC PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-keyPkcs8.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-keyPkcs8.pem deleted file mode 100755 index ca03d98..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/ecc-keyPkcs8.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgRbZpAnOcbIWhOFty -6OjHrMQDjVM1BPpsKNw0jeGoCYyhRANCAAS7M6xMJ1BKxkqlBMM83p8223ItzpTq -K/rLIAk5LBboYQLpr03TApOaMVuXkiF/8M8Y2pERAjSG6CBYMwuANInY ------END PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/include.am b/FreeRTOS-Plus/Source/WolfSSL/certs/include.am deleted file mode 100755 index b519204..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/include.am +++ /dev/null @@ -1,44 +0,0 @@ -# vim:ft=automake -# All paths should be given relative to the root -# - -EXTRA_DIST += \ - certs/ca-cert.pem \ - certs/ca-key.pem \ - certs/client-cert.pem \ - certs/client-keyEnc.pem \ - certs/client-key.pem \ - certs/ecc-key.pem \ - certs/ecc-key-comp.pem \ - certs/ecc-keyPkcs8.pem \ - certs/ecc-client-key.pem \ - certs/client-ecc-cert.pem \ - certs/ntru-cert.pem \ - certs/dh2048.pem \ - certs/server-cert.pem \ - certs/server-ecc.pem \ - certs/server-ecc-comp.pem \ - certs/server-ecc-rsa.pem \ - certs/server-keyEnc.pem \ - certs/server-key.pem \ - certs/server-keyPkcs8Enc12.pem \ - certs/server-keyPkcs8Enc2.pem \ - certs/server-keyPkcs8Enc.pem \ - certs/server-keyPkcs8.pem \ - certs/wolfssl-website-ca.pem -EXTRA_DIST += \ - certs/ca-key.der \ - certs/ca-cert.der \ - certs/client-cert.der \ - certs/client-key.der \ - certs/dh2048.der \ - certs/rsa2048.der \ - certs/dsa2048.der \ - certs/ecc-key.der \ - certs/server-key.der \ - certs/server-cert.der - -dist_doc_DATA+= certs/taoCert.txt - -EXTRA_DIST+= certs/ntru-key.raw - diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/ntru-cert.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/ntru-cert.pem deleted file mode 100755 index 4e8aa3e..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/ntru-cert.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIEzzCCA7egAwIBAgIIAazu2er3DUMwDQYJKoZIhvcNAQEFBQAwgZQxCzAJBgNV -BAYTAlVTMRAwDgYDVQQIDAdNb250YW5hMRAwDgYDVQQHDAdCb3plbWFuMREwDwYD -VQQKDAhTYXd0b290aDETMBEGA1UECwwKQ29uc3VsdGluZzEYMBYGA1UEAwwPd3d3 -LndvbGZzc2wuY29tMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdvbGZzc2wuY29tMCIY -DzIwMTUwMjA0MDYzMzI5WhgPMjAxNjA2MTkwNzMzMjlaMIGKMQswCQYDVQQGEwJV -UzELMAkGA1UECAwCT1IxETAPBgNVBAcMCFBvcnRsYW5kMQ4wDAYDVQQKDAV5YVNT -TDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxFjAUBgNVBAMMDXd3dy55YXNzbC5jb20x -HTAbBgkqhkiG9w0BCQEWDmluZm9AeWFzc2wuY29tMIICTTAaBgsrBgEEAcEWAQEB -AQYLKwYBBAHBFgEBAi4DggItAASCAiifDYOsBu8WQqIuom5HpD+jF7bvqvyO7LN4 -p7dOUfyBBX2zFc7fbhVoLcLw62Ye0i54UXMI/rglgOxEisVXPo0//Cs2rl3zwjho -fnEvEMpDU4mvqYTV8+N7FYoaUSEhMWTS0GMCJdK9aTvAz8l7F8gKP6MtgIv7Ght/ -r6JclP7fh12KMy9hiM/Tv3wqr+KhR8xFRfpL+paEIroidfpExFWbFB+xxA6KxGk4 -OEs/nus4rQl4w+6z5uf1cYfxKVRMFWLScEDQ3TdPcHz0+7fl/L7LYyCbK9z9LYVZ -5qZR1V27Iwx4H3d2w2D/3GGZpML/Uv8eBBHtODBbJC54U+bVh1ned28N1Y8I/bm8 -xRRCppfCJ3o+WxlsqHtyjIo/hi75SgUHknnbZ4hEuye1XhBBhUVhN2zybADMi1bv -S1RL/HAWsOO8qzBx5vkbVlDShsF+EccNUaNQyM98VE3FrUBbk4JxnyHBK5pA7aQ5 -7LOm83WkX2uR+ucR5en2TZIGVL+cJiTly+W7W8J83KEf5HJIUqnxFlgsre/0pMfe -7RqGer5Q4itWE+XWaPsDCUZnHy8a/CGdWlmdiGuw/0UvDqKQ4NRerbMgpo2Fl182 -fIQxfohhnm7iM0dAroIglkNBLM89A30d+73ZnUKgg4mRaqC5C29Me6LqpXjEUCiT -/s3g24IooqTj+8i8osRY5Zp4MQTmb3NrWVAWoOTtbFxDkhkwgqALupC8opUSIwAw -DQYJKoZIhvcNAQEFBQADggEBAHPi6MLfKV3ILr4wVgktXWNrPVgbqzUfoHhZhuhU -OgoT1KjiGQTpMrszGXyNKWTV+TpL2RmsBsXwI+lCl9nQMk5nkHAELShwXmgBpR+r -2dQTUy6C5xze8ZqPhsIjUjHyaagX8QY42SlSGOCChOEYshqO+QouPL2XOf2Hp4nJ -fgx4Mo2APTxGJ8TLYBCu4QzglCkKl7g1JRKBVA8Q4bkb1NWOnTgRQfIVv3N9DMn0 -ELw4uHkS2bXlzzbKRpwIMms0MIdWrVKFycQIp9Z2/7RsrIidZdGgsDeJLpItMZB8 -UM5Fz1UyZTy54Keoto4nBsU9ZJxzsTihT+Oq+/n1WaMEn+I= ------END CERTIFICATE----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/ntru-key.raw b/FreeRTOS-Plus/Source/WolfSSL/certs/ntru-key.raw deleted file mode 100755 index 740bd34..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/ntru-key.raw and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/rsa2048.der b/FreeRTOS-Plus/Source/WolfSSL/certs/rsa2048.der deleted file mode 100755 index 837095b..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/rsa2048.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/server-cert.der b/FreeRTOS-Plus/Source/WolfSSL/certs/server-cert.der deleted file mode 100755 index 0c936a2..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/server-cert.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/server-cert.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/server-cert.pem deleted file mode 100755 index 95df724..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/server-cert.pem +++ /dev/null @@ -1,172 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 1 (0x1) - Signature Algorithm: sha256WithRSAEncryption - Issuer: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Validity - Not Before: May 7 18:21:01 2015 GMT - Not After : Jan 31 18:21:01 2018 GMT - Subject: C=US, ST=Montana, L=Bozeman, O=wolfSSL, OU=Support, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (2048 bit) - Modulus: - 00:c0:95:08:e1:57:41:f2:71:6d:b7:d2:45:41:27: - 01:65:c6:45:ae:f2:bc:24:30:b8:95:ce:2f:4e:d6: - f6:1c:88:bc:7c:9f:fb:a8:67:7f:fe:5c:9c:51:75: - f7:8a:ca:07:e7:35:2f:8f:e1:bd:7b:c0:2f:7c:ab: - 64:a8:17:fc:ca:5d:7b:ba:e0:21:e5:72:2e:6f:2e: - 86:d8:95:73:da:ac:1b:53:b9:5f:3f:d7:19:0d:25: - 4f:e1:63:63:51:8b:0b:64:3f:ad:43:b8:a5:1c:5c: - 34:b3:ae:00:a0:63:c5:f6:7f:0b:59:68:78:73:a6: - 8c:18:a9:02:6d:af:c3:19:01:2e:b8:10:e3:c6:cc: - 40:b4:69:a3:46:33:69:87:6e:c4:bb:17:a6:f3:e8: - dd:ad:73:bc:7b:2f:21:b5:fd:66:51:0c:bd:54:b3: - e1:6d:5f:1c:bc:23:73:d1:09:03:89:14:d2:10:b9: - 64:c3:2a:d0:a1:96:4a:bc:e1:d4:1a:5b:c7:a0:c0: - c1:63:78:0f:44:37:30:32:96:80:32:23:95:a1:77: - ba:13:d2:97:73:e2:5d:25:c9:6a:0d:c3:39:60:a4: - b4:b0:69:42:42:09:e9:d8:08:bc:33:20:b3:58:22: - a7:aa:eb:c4:e1:e6:61:83:c5:d2:96:df:d9:d0:4f: - ad:d7 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Subject Key Identifier: - B3:11:32:C9:92:98:84:E2:C9:F8:D0:3B:6E:03:42:CA:1F:0E:8E:3C - X509v3 Authority Key Identifier: - keyid:27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5 - DirName:/C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.wolfssl.com/emailAddress=info@wolfssl.com - serial:D9:80:3A:C3:D2:F4:DA:37 - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: sha256WithRSAEncryption - 67:c0:2c:a9:43:47:e7:11:14:77:ae:cc:d8:e0:6b:23:82:91: - 63:e8:a8:0d:21:c5:c8:47:97:2f:d5:f3:86:fb:6c:ce:25:f9: - 7c:78:c8:3a:22:68:f2:16:1e:d2:d2:3f:24:04:87:f2:b7:c1: - 62:63:ba:c5:fa:ae:d2:20:81:1a:d2:0c:ae:26:6b:1b:2b:10: - d3:e1:9a:4e:64:6c:97:db:36:a8:8f:f8:05:63:bf:ba:0d:88: - 0b:87:46:c9:e4:64:e3:d7:bd:b8:2d:d5:c1:c3:c4:db:55:68: - dc:a3:7a:40:b9:a9:f6:04:4a:22:cf:98:76:1c:e4:a3:ff:79: - 19:96:57:63:07:6f:f6:32:77:16:50:9b:e3:34:18:d4:eb:be: - fd:b6:6f:e3:c7:f6:85:bf:ac:32:ad:98:57:be:13:92:44:10: - a5:f3:ae:e2:66:da:44:a9:94:71:3f:d0:2f:20:59:87:e4:5a: - 40:ee:d2:e4:0c:ce:25:94:dc:0f:fe:38:e0:41:52:34:5c:bb: - c3:db:c1:5f:76:c3:5d:0e:32:69:2b:9d:01:ed:50:1b:4f:77: - a9:a9:d8:71:30:cb:2e:2c:70:00:ab:78:4b:d7:15:d9:17:f8: - 64:b2:f7:3a:da:e1:0b:8b:0a:e1:4e:b1:03:46:14:ca:94:e3: - 44:77:d7:59 ------BEGIN CERTIFICATE----- -MIIEnjCCA4agAwIBAgIBATANBgkqhkiG9w0BAQsFADCBlDELMAkGA1UEBhMCVVMx -EDAOBgNVBAgMB01vbnRhbmExEDAOBgNVBAcMB0JvemVtYW4xETAPBgNVBAoMCFNh -d3Rvb3RoMRMwEQYDVQQLDApDb25zdWx0aW5nMRgwFgYDVQQDDA93d3cud29sZnNz -bC5jb20xHzAdBgkqhkiG9w0BCQEWEGluZm9Ad29sZnNzbC5jb20wHhcNMTUwNTA3 -MTgyMTAxWhcNMTgwMTMxMTgyMTAxWjCBkDELMAkGA1UEBhMCVVMxEDAOBgNVBAgM -B01vbnRhbmExEDAOBgNVBAcMB0JvemVtYW4xEDAOBgNVBAoMB3dvbGZTU0wxEDAO -BgNVBAsMB1N1cHBvcnQxGDAWBgNVBAMMD3d3dy53b2xmc3NsLmNvbTEfMB0GCSqG -SIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEP -ADCCAQoCggEBAMCVCOFXQfJxbbfSRUEnAWXGRa7yvCQwuJXOL07W9hyIvHyf+6hn -f/5cnFF194rKB+c1L4/hvXvAL3yrZKgX/Mpde7rgIeVyLm8uhtiVc9qsG1O5Xz/X -GQ0lT+FjY1GLC2Q/rUO4pRxcNLOuAKBjxfZ/C1loeHOmjBipAm2vwxkBLrgQ48bM -QLRpo0YzaYduxLsXpvPo3a1zvHsvIbX9ZlEMvVSz4W1fHLwjc9EJA4kU0hC5ZMMq -0KGWSrzh1Bpbx6DAwWN4D0Q3MDKWgDIjlaF3uhPSl3PiXSXJag3DOWCktLBpQkIJ -6dgIvDMgs1gip6rrxOHmYYPF0pbf2dBPrdcCAwEAAaOB/DCB+TAdBgNVHQ4EFgQU -sxEyyZKYhOLJ+NA7bgNCyh8OjjwwgckGA1UdIwSBwTCBvoAUJ45nEXTDJh0/7TNj -s6TYHTDl6NWhgZqkgZcwgZQxCzAJBgNVBAYTAlVTMRAwDgYDVQQIDAdNb250YW5h -MRAwDgYDVQQHDAdCb3plbWFuMREwDwYDVQQKDAhTYXd0b290aDETMBEGA1UECwwK -Q29uc3VsdGluZzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29tMR8wHQYJKoZIhvcN -AQkBFhBpbmZvQHdvbGZzc2wuY29tggkA2YA6w9L02jcwDAYDVR0TBAUwAwEB/zAN -BgkqhkiG9w0BAQsFAAOCAQEAZ8AsqUNH5xEUd67M2OBrI4KRY+ioDSHFyEeXL9Xz -hvtsziX5fHjIOiJo8hYe0tI/JASH8rfBYmO6xfqu0iCBGtIMriZrGysQ0+GaTmRs -l9s2qI/4BWO/ug2IC4dGyeRk49e9uC3VwcPE21Vo3KN6QLmp9gRKIs+Ydhzko/95 -GZZXYwdv9jJ3FlCb4zQY1Ou+/bZv48f2hb+sMq2YV74TkkQQpfOu4mbaRKmUcT/Q -LyBZh+RaQO7S5AzOJZTcD/444EFSNFy7w9vBX3bDXQ4yaSudAe1QG093qanYcTDL -LixwAKt4S9cV2Rf4ZLL3OtrhC4sK4U6xA0YUypTjRHfXWQ== ------END CERTIFICATE----- -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 15672591315981621815 (0xd9803ac3d2f4da37) - Signature Algorithm: sha256WithRSAEncryption - Issuer: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Validity - Not Before: May 7 18:21:01 2015 GMT - Not After : Jan 31 18:21:01 2018 GMT - Subject: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (2048 bit) - Modulus: - 00:bf:0c:ca:2d:14:b2:1e:84:42:5b:cd:38:1f:4a: - f2:4d:75:10:f1:b6:35:9f:df:ca:7d:03:98:d3:ac: - de:03:66:ee:2a:f1:d8:b0:7d:6e:07:54:0b:10:98: - 21:4d:80:cb:12:20:e7:cc:4f:de:45:7d:c9:72:77: - 32:ea:ca:90:bb:69:52:10:03:2f:a8:f3:95:c5:f1: - 8b:62:56:1b:ef:67:6f:a4:10:41:95:ad:0a:9b:e3: - a5:c0:b0:d2:70:76:50:30:5b:a8:e8:08:2c:7c:ed: - a7:a2:7a:8d:38:29:1c:ac:c7:ed:f2:7c:95:b0:95: - 82:7d:49:5c:38:cd:77:25:ef:bd:80:75:53:94:3c: - 3d:ca:63:5b:9f:15:b5:d3:1d:13:2f:19:d1:3c:db: - 76:3a:cc:b8:7d:c9:e5:c2:d7:da:40:6f:d8:21:dc: - 73:1b:42:2d:53:9c:fe:1a:fc:7d:ab:7a:36:3f:98: - de:84:7c:05:67:ce:6a:14:38:87:a9:f1:8c:b5:68: - cb:68:7f:71:20:2b:f5:a0:63:f5:56:2f:a3:26:d2: - b7:6f:b1:5a:17:d7:38:99:08:fe:93:58:6f:fe:c3: - 13:49:08:16:0b:a7:4d:67:00:52:31:67:23:4e:98: - ed:51:45:1d:b9:04:d9:0b:ec:d8:28:b3:4b:bd:ed: - 36:79 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Subject Key Identifier: - 27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5 - X509v3 Authority Key Identifier: - keyid:27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5 - DirName:/C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.wolfssl.com/emailAddress=info@wolfssl.com - serial:D9:80:3A:C3:D2:F4:DA:37 - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: sha256WithRSAEncryption - 7a:af:44:3b:aa:6f:53:42:b2:33:aa:43:5f:56:30:d3:b9:96: - 0b:9a:55:5a:39:2a:0b:4e:e4:2e:f1:95:66:c9:86:36:82:8d: - 63:7c:4d:a2:ee:48:ba:03:c7:90:d7:a7:c6:74:60:48:5f:31: - a2:f9:5e:3e:c3:82:e1:e5:2f:41:81:83:29:25:79:d1:53:00: - 69:3c:ed:0a:30:3b:41:1d:92:a1:2c:a8:9d:2c:e3:23:87:79: - e0:55:6e:91:a8:50:da:46:2f:c2:20:50:3e:2b:47:97:14:b0: - 7d:04:ba:45:51:d0:6e:e1:5a:a2:4b:84:9c:4d:cd:85:04:f9: - 28:31:82:93:bc:c7:59:49:91:03:e8:df:6a:e4:56:ad:6a:cb: - 1f:0d:37:e4:5e:bd:e7:9f:d5:ec:9d:3c:18:25:9b:f1:2f:50: - 7d:eb:31:cb:f1:63:22:9d:57:fc:f3:84:20:1a:c6:07:87:92: - 26:9e:15:18:59:33:06:dc:fb:b0:b6:76:5d:f1:c1:2f:c8:2f: - 62:9c:c0:d6:de:eb:65:77:f3:5c:a6:c3:88:27:96:75:b4:f4: - 54:cd:ff:2d:21:2e:96:f0:07:73:4b:e9:93:92:90:de:62:d9: - a3:3b:ac:6e:24:5f:27:4a:b3:94:70:ff:30:17:e7:7e:32:8f: - 65:b7:75:58 ------BEGIN CERTIFICATE----- -MIIEqjCCA5KgAwIBAgIJANmAOsPS9No3MA0GCSqGSIb3DQEBCwUAMIGUMQswCQYD -VQQGEwJVUzEQMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjERMA8G -A1UECgwIU2F3dG9vdGgxEzARBgNVBAsMCkNvbnN1bHRpbmcxGDAWBgNVBAMMD3d3 -dy53b2xmc3NsLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbTAe -Fw0xNTA1MDcxODIxMDFaFw0xODAxMzExODIxMDFaMIGUMQswCQYDVQQGEwJVUzEQ -MA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjERMA8GA1UECgwIU2F3 -dG9vdGgxEzARBgNVBAsMCkNvbnN1bHRpbmcxGDAWBgNVBAMMD3d3dy53b2xmc3Ns -LmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAL8Myi0Ush6EQlvNOB9K8k11EPG2NZ/fyn0D -mNOs3gNm7irx2LB9bgdUCxCYIU2AyxIg58xP3kV9yXJ3MurKkLtpUhADL6jzlcXx -i2JWG+9nb6QQQZWtCpvjpcCw0nB2UDBbqOgILHztp6J6jTgpHKzH7fJ8lbCVgn1J -XDjNdyXvvYB1U5Q8PcpjW58VtdMdEy8Z0TzbdjrMuH3J5cLX2kBv2CHccxtCLVOc -/hr8fat6Nj+Y3oR8BWfOahQ4h6nxjLVoy2h/cSAr9aBj9VYvoybSt2+xWhfXOJkI -/pNYb/7DE0kIFgunTWcAUjFnI06Y7VFFHbkE2Qvs2CizS73tNnkCAwEAAaOB/DCB -+TAdBgNVHQ4EFgQUJ45nEXTDJh0/7TNjs6TYHTDl6NUwgckGA1UdIwSBwTCBvoAU -J45nEXTDJh0/7TNjs6TYHTDl6NWhgZqkgZcwgZQxCzAJBgNVBAYTAlVTMRAwDgYD -VQQIDAdNb250YW5hMRAwDgYDVQQHDAdCb3plbWFuMREwDwYDVQQKDAhTYXd0b290 -aDETMBEGA1UECwwKQ29uc3VsdGluZzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29t -MR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdvbGZzc2wuY29tggkA2YA6w9L02jcwDAYD -VR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAeq9EO6pvU0KyM6pDX1Yw07mW -C5pVWjkqC07kLvGVZsmGNoKNY3xNou5IugPHkNenxnRgSF8xovlePsOC4eUvQYGD -KSV50VMAaTztCjA7QR2SoSyonSzjI4d54FVukahQ2kYvwiBQPitHlxSwfQS6RVHQ -buFaokuEnE3NhQT5KDGCk7zHWUmRA+jfauRWrWrLHw035F6955/V7J08GCWb8S9Q -fesxy/FjIp1X/POEIBrGB4eSJp4VGFkzBtz7sLZ2XfHBL8gvYpzA1t7rZXfzXKbD -iCeWdbT0VM3/LSEulvAHc0vpk5KQ3mLZozusbiRfJ0qzlHD/MBfnfjKPZbd1WA== ------END CERTIFICATE----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/server-ecc-comp.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/server-ecc-comp.pem deleted file mode 100755 index 50b74f8..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/server-ecc-comp.pem +++ /dev/null @@ -1,52 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 17764616133298603308 (0xf6889840946fc52c) - Signature Algorithm: ecdsa-with-SHA256 - Issuer: C=US, ST=Montana, L=Bozeman, O=Elliptic - comp, OU=Server ECC-comp, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Validity - Not Before: May 7 18:21:01 2015 GMT - Not After : Jan 31 18:21:01 2018 GMT - Subject: C=US, ST=Montana, L=Bozeman, O=Elliptic - comp, OU=Server ECC-comp, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Subject Public Key Info: - Public Key Algorithm: id-ecPublicKey - Public-Key: (256 bit) - pub: - 02:bb:33:ac:4c:27:50:4a:c6:4a:a5:04:c3:3c:de: - 9f:36:db:72:2d:ce:94:ea:2b:fa:cb:20:09:39:2c: - 16:e8:61 - ASN1 OID: prime256v1 - X509v3 extensions: - X509v3 Subject Key Identifier: - 8C:38:3A:6B:B8:24:B7:DF:6E:F4:59:AC:56:4E:AA:E2:58:A6:5A:18 - X509v3 Authority Key Identifier: - keyid:8C:38:3A:6B:B8:24:B7:DF:6E:F4:59:AC:56:4E:AA:E2:58:A6:5A:18 - DirName:/C=US/ST=Montana/L=Bozeman/O=Elliptic - comp/OU=Server ECC-comp/CN=www.wolfssl.com/emailAddress=info@wolfssl.com - serial:F6:88:98:40:94:6F:C5:2C - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: ecdsa-with-SHA256 - 30:46:02:21:00:9c:f8:3e:f6:5e:cd:da:b1:08:fe:e2:bd:78: - 14:b5:33:b3:29:69:d0:a0:de:19:05:ec:c3:46:29:01:8c:4c: - 56:02:21:00:e2:e7:ea:37:c1:08:f6:15:73:0c:92:4f:25:63: - f6:53:96:31:4c:9f:1d:1a:1f:c0:a0:a3:48:bd:71:ce:13:11 ------BEGIN CERTIFICATE----- -MIIDJTCCAsqgAwIBAgIJAPaImECUb8UsMAoGCCqGSM49BAMCMIGgMQswCQYDVQQG -EwJVUzEQMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjEYMBYGA1UE -CgwPRWxsaXB0aWMgLSBjb21wMRgwFgYDVQQLDA9TZXJ2ZXIgRUNDLWNvbXAxGDAW -BgNVBAMMD3d3dy53b2xmc3NsLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xm -c3NsLmNvbTAeFw0xNTA1MDcxODIxMDFaFw0xODAxMzExODIxMDFaMIGgMQswCQYD -VQQGEwJVUzEQMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjEYMBYG -A1UECgwPRWxsaXB0aWMgLSBjb21wMRgwFgYDVQQLDA9TZXJ2ZXIgRUNDLWNvbXAx -GDAWBgNVBAMMD3d3dy53b2xmc3NsLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3 -b2xmc3NsLmNvbTA5MBMGByqGSM49AgEGCCqGSM49AwEHAyIAArszrEwnUErGSqUE -wzzenzbbci3OlOor+ssgCTksFuhho4IBCTCCAQUwHQYDVR0OBBYEFIw4Omu4JLff -bvRZrFZOquJYploYMIHVBgNVHSMEgc0wgcqAFIw4Omu4JLffbvRZrFZOquJYploY -oYGmpIGjMIGgMQswCQYDVQQGEwJVUzEQMA4GA1UECAwHTW9udGFuYTEQMA4GA1UE -BwwHQm96ZW1hbjEYMBYGA1UECgwPRWxsaXB0aWMgLSBjb21wMRgwFgYDVQQLDA9T -ZXJ2ZXIgRUNDLWNvbXAxGDAWBgNVBAMMD3d3dy53b2xmc3NsLmNvbTEfMB0GCSqG -SIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbYIJAPaImECUb8UsMAwGA1UdEwQFMAMB -Af8wCgYIKoZIzj0EAwIDSQAwRgIhAJz4PvZezdqxCP7ivXgUtTOzKWnQoN4ZBezD -RikBjExWAiEA4ufqN8EI9hVzDJJPJWP2U5YxTJ8dGh/AoKNIvXHOExE= ------END CERTIFICATE----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/server-ecc-rsa.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/server-ecc-rsa.pem deleted file mode 100755 index 4c90d1d..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/server-ecc-rsa.pem +++ /dev/null @@ -1,69 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 1 (0x1) - Signature Algorithm: sha256WithRSAEncryption - Issuer: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Validity - Not Before: May 7 18:21:01 2015 GMT - Not After : Jan 31 18:21:01 2018 GMT - Subject: C=US, ST=Montana, L=Bozeman, O=Elliptic - RSAsig, OU=ECC-RSAsig, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Subject Public Key Info: - Public Key Algorithm: id-ecPublicKey - Public-Key: (256 bit) - pub: - 04:bb:33:ac:4c:27:50:4a:c6:4a:a5:04:c3:3c:de: - 9f:36:db:72:2d:ce:94:ea:2b:fa:cb:20:09:39:2c: - 16:e8:61:02:e9:af:4d:d3:02:93:9a:31:5b:97:92: - 21:7f:f0:cf:18:da:91:11:02:34:86:e8:20:58:33: - 0b:80:34:89:d8 - ASN1 OID: prime256v1 - X509v3 extensions: - X509v3 Subject Key Identifier: - 5D:5D:26:EF:AC:7E:36:F9:9B:76:15:2B:4A:25:02:23:EF:B2:89:30 - X509v3 Authority Key Identifier: - keyid:27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5 - DirName:/C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.wolfssl.com/emailAddress=info@wolfssl.com - serial:D9:80:3A:C3:D2:F4:DA:37 - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: sha256WithRSAEncryption - ac:2b:a9:d9:15:3b:9a:42:fb:86:2b:c1:f2:18:7c:a6:ca:27: - 0b:48:81:64:20:3b:d3:4f:ee:95:d4:c5:fd:5f:c7:d6:ab:a1: - 41:85:cc:e1:16:e1:fd:ce:8a:af:95:27:f2:f0:7a:3d:59:5d: - 3a:5d:03:99:cb:4c:5c:19:35:9c:b2:6e:7e:2b:10:e2:7f:ef: - 14:35:79:ca:67:eb:51:a9:e9:bb:5f:52:af:9d:79:80:b5:31: - 5c:f0:20:ca:c7:e9:9b:29:82:c4:a4:74:0a:2a:76:ea:ad:59: - a2:f9:a2:cf:53:40:11:ac:1a:de:fc:ab:28:96:9f:cf:ff:b9: - 74:31:95:c4:6d:d2:76:c1:93:97:75:a6:9f:69:a3:7d:92:75: - b8:27:a2:bd:4d:4b:54:11:b4:8a:43:f2:fc:10:a5:82:fb:51: - 45:57:86:00:85:71:91:21:37:5c:9f:f3:68:06:ae:9e:86:46: - 8d:4b:e3:d0:42:a4:cf:c1:5d:95:bc:1a:92:f8:44:1e:a0:1b: - c8:98:41:af:8e:94:41:60:69:b1:7c:8e:70:ce:88:42:44:3a: - 2d:3f:de:6e:3a:aa:d1:64:be:03:68:60:b6:ac:e5:44:c1:bb: - f1:c9:40:90:c2:c9:8f:ec:32:9d:e0:b4:4b:1a:e7:da:99:94: - fe:e2:b6:2a ------BEGIN CERTIFICATE----- -MIID4DCCAsigAwIBAgIBATANBgkqhkiG9w0BAQsFADCBlDELMAkGA1UEBhMCVVMx -EDAOBgNVBAgMB01vbnRhbmExEDAOBgNVBAcMB0JvemVtYW4xETAPBgNVBAoMCFNh -d3Rvb3RoMRMwEQYDVQQLDApDb25zdWx0aW5nMRgwFgYDVQQDDA93d3cud29sZnNz -bC5jb20xHzAdBgkqhkiG9w0BCQEWEGluZm9Ad29sZnNzbC5jb20wHhcNMTUwNTA3 -MTgyMTAxWhcNMTgwMTMxMTgyMTAxWjCBnTELMAkGA1UEBhMCVVMxEDAOBgNVBAgM -B01vbnRhbmExEDAOBgNVBAcMB0JvemVtYW4xGjAYBgNVBAoMEUVsbGlwdGljIC0g -UlNBc2lnMRMwEQYDVQQLDApFQ0MtUlNBc2lnMRgwFgYDVQQDDA93d3cud29sZnNz -bC5jb20xHzAdBgkqhkiG9w0BCQEWEGluZm9Ad29sZnNzbC5jb20wWTATBgcqhkjO -PQIBBggqhkjOPQMBBwNCAAS7M6xMJ1BKxkqlBMM83p8223ItzpTqK/rLIAk5LBbo -YQLpr03TApOaMVuXkiF/8M8Y2pERAjSG6CBYMwuANInYo4H8MIH5MB0GA1UdDgQW -BBRdXSbvrH42+Zt2FStKJQIj77KJMDCByQYDVR0jBIHBMIG+gBQnjmcRdMMmHT/t -M2OzpNgdMOXo1aGBmqSBlzCBlDELMAkGA1UEBhMCVVMxEDAOBgNVBAgMB01vbnRh -bmExEDAOBgNVBAcMB0JvemVtYW4xETAPBgNVBAoMCFNhd3Rvb3RoMRMwEQYDVQQL -DApDb25zdWx0aW5nMRgwFgYDVQQDDA93d3cud29sZnNzbC5jb20xHzAdBgkqhkiG -9w0BCQEWEGluZm9Ad29sZnNzbC5jb22CCQDZgDrD0vTaNzAMBgNVHRMEBTADAQH/ -MA0GCSqGSIb3DQEBCwUAA4IBAQCsK6nZFTuaQvuGK8HyGHymyicLSIFkIDvTT+6V -1MX9X8fWq6FBhczhFuH9zoqvlSfy8Ho9WV06XQOZy0xcGTWcsm5+KxDif+8UNXnK -Z+tRqem7X1KvnXmAtTFc8CDKx+mbKYLEpHQKKnbqrVmi+aLPU0ARrBre/Ksolp/P -/7l0MZXEbdJ2wZOXdaafaaN9knW4J6K9TUtUEbSKQ/L8EKWC+1FFV4YAhXGRITdc -n/NoBq6ehkaNS+PQQqTPwV2VvBqS+EQeoBvImEGvjpRBYGmxfI5wzohCRDotP95u -OqrRZL4DaGC2rOVEwbvxyUCQwsmP7DKd4LRLGufamZT+4rYq ------END CERTIFICATE----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/server-ecc.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/server-ecc.pem deleted file mode 100755 index 1957e0e..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/server-ecc.pem +++ /dev/null @@ -1,54 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 12841786837162396166 (0xb2373116f65a0a06) - Signature Algorithm: ecdsa-with-SHA256 - Issuer: C=US, ST=Washington, L=Seattle, O=Eliptic, OU=ECC, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Validity - Not Before: May 7 18:21:01 2015 GMT - Not After : Jan 31 18:21:01 2018 GMT - Subject: C=US, ST=Washington, L=Seattle, O=Eliptic, OU=ECC, CN=www.wolfssl.com/emailAddress=info@wolfssl.com - Subject Public Key Info: - Public Key Algorithm: id-ecPublicKey - Public-Key: (256 bit) - pub: - 04:bb:33:ac:4c:27:50:4a:c6:4a:a5:04:c3:3c:de: - 9f:36:db:72:2d:ce:94:ea:2b:fa:cb:20:09:39:2c: - 16:e8:61:02:e9:af:4d:d3:02:93:9a:31:5b:97:92: - 21:7f:f0:cf:18:da:91:11:02:34:86:e8:20:58:33: - 0b:80:34:89:d8 - ASN1 OID: prime256v1 - X509v3 extensions: - X509v3 Subject Key Identifier: - 5D:5D:26:EF:AC:7E:36:F9:9B:76:15:2B:4A:25:02:23:EF:B2:89:30 - X509v3 Authority Key Identifier: - keyid:5D:5D:26:EF:AC:7E:36:F9:9B:76:15:2B:4A:25:02:23:EF:B2:89:30 - DirName:/C=US/ST=Washington/L=Seattle/O=Eliptic/OU=ECC/CN=www.wolfssl.com/emailAddress=info@wolfssl.com - serial:B2:37:31:16:F6:5A:0A:06 - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: ecdsa-with-SHA256 - 30:45:02:20:35:25:33:ea:7c:3b:e2:2e:ed:e4:2e:9a:91:f1: - c3:86:ff:a7:27:35:a9:f6:29:d6:f8:d5:9a:0b:35:f1:21:c7: - 02:21:00:bc:79:f7:fd:66:d4:d3:46:61:e4:19:e5:f7:74:03: - 83:27:f8:26:c0:86:15:a9:e2:10:e3:ad:6b:b9:1c:1d:eb ------BEGIN CERTIFICATE----- -MIIDDzCCArWgAwIBAgIJALI3MRb2WgoGMAoGCCqGSM49BAMCMIGPMQswCQYDVQQG -EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjEQMA4GA1UEBwwHU2VhdHRsZTEQMA4G -A1UECgwHRWxpcHRpYzEMMAoGA1UECwwDRUNDMRgwFgYDVQQDDA93d3cud29sZnNz -bC5jb20xHzAdBgkqhkiG9w0BCQEWEGluZm9Ad29sZnNzbC5jb20wHhcNMTUwNTA3 -MTgyMTAxWhcNMTgwMTMxMTgyMTAxWjCBjzELMAkGA1UEBhMCVVMxEzARBgNVBAgM -Cldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxEDAOBgNVBAoMB0VsaXB0aWMx -DDAKBgNVBAsMA0VDQzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29tMR8wHQYJKoZI -hvcNAQkBFhBpbmZvQHdvbGZzc2wuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD -QgAEuzOsTCdQSsZKpQTDPN6fNttyLc6U6iv6yyAJOSwW6GEC6a9N0wKTmjFbl5Ih -f/DPGNqREQI0huggWDMLgDSJ2KOB9zCB9DAdBgNVHQ4EFgQUXV0m76x+NvmbdhUr -SiUCI++yiTAwgcQGA1UdIwSBvDCBuYAUXV0m76x+NvmbdhUrSiUCI++yiTChgZWk -gZIwgY8xCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRAwDgYDVQQH -DAdTZWF0dGxlMRAwDgYDVQQKDAdFbGlwdGljMQwwCgYDVQQLDANFQ0MxGDAWBgNV -BAMMD3d3dy53b2xmc3NsLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3Ns -LmNvbYIJALI3MRb2WgoGMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSAAwRQIg -NSUz6nw74i7t5C6akfHDhv+nJzWp9inW+NWaCzXxIccCIQC8eff9ZtTTRmHkGeX3 -dAODJ/gmwIYVqeIQ461ruRwd6w== ------END CERTIFICATE----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/server-key.der b/FreeRTOS-Plus/Source/WolfSSL/certs/server-key.der deleted file mode 100755 index 868f054..0000000 Binary files a/FreeRTOS-Plus/Source/WolfSSL/certs/server-key.der and /dev/null differ diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/server-key.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/server-key.pem deleted file mode 100755 index d1627f4..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/server-key.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpQIBAAKCAQEAwJUI4VdB8nFtt9JFQScBZcZFrvK8JDC4lc4vTtb2HIi8fJ/7 -qGd//lycUXX3isoH5zUvj+G9e8AvfKtkqBf8yl17uuAh5XIuby6G2JVz2qwbU7lf -P9cZDSVP4WNjUYsLZD+tQ7ilHFw0s64AoGPF9n8LWWh4c6aMGKkCba/DGQEuuBDj -xsxAtGmjRjNph27Euxem8+jdrXO8ey8htf1mUQy9VLPhbV8cvCNz0QkDiRTSELlk -wyrQoZZKvOHUGlvHoMDBY3gPRDcwMpaAMiOVoXe6E9KXc+JdJclqDcM5YKS0sGlC -Qgnp2Ai8MyCzWCKnquvE4eZhg8XSlt/Z0E+t1wIDAQABAoIBAQCa0DQPUmIFUAHv -n+1kbsLE2hryhNeSEEiSxOlq64t1bMZ5OPLJckqGZFSVd8vDmp231B2kAMieTuTd -x7pnFsF0vKnWlI8rMBr77d8hBSPZSjm9mGtlmrjcxH3upkMVLj2+HSJgKnMw1T7Y -oqyGQy7E9WReP4l1DxHYUSVOn9iqo85gs+KK2X4b8GTKmlsFC1uqy+XjP24yIgXz -0PrvdFKB4l90073/MYNFdfpjepcu1rYZxpIm5CgGUFAOeC6peA0Ul7QS2DFAq6EB -QcIw+AdfFuRhd9Jg8p+N6PS662PeKpeB70xs5lU0USsoNPRTHMRYCj+7r7X3SoVD -LTzxWFiBAoGBAPIsVHY5I2PJEDK3k62vvhl1loFk5rW4iUJB0W3QHBv4G6xpyzY8 -ZH3c9Bm4w2CxV0hfUk9ZOlV/MsAZQ1A/rs5vF/MOn0DKTq0VO8l56cBZOHNwnAp8 -yTpIMqfYSXUKhcLC/RVz2pkJKmmanwpxv7AEpox6Wm9IWlQ7xrFTF9/nAoGBAMuT -3ncVXbdcXHzYkKmYLdZpDmOzo9ymzItqpKISjI57SCyySzfcBhh96v52odSh6T8N -zRtfr1+elltbD6F8r7ObkNtXczrtsCNErkFPHwdCEyNMy/r0FKTV9542fFufqDzB -hV900jkt/9CE3/uzIHoumxeu5roLrl9TpFLtG8SRAoGBAOyY2rvV/vlSSn0CVUlv -VW5SL4SjK7OGYrNU0mNS2uOIdqDvixWl0xgUcndex6MEH54ZYrUbG57D8rUy+UzB -qusMJn3UX0pRXKRFBnBEp1bA1CIUdp7YY1CJkNPiv4GVkjFBhzkaQwsYpVMfORpf -H0O8h2rfbtMiAP4imHBOGhkpAoGBAIpBVihRnl/Ungs7mKNU8mxW1KrpaTOFJAza -1AwtxL9PAmk4fNTm3Ezt1xYRwz4A58MmwFEC3rt1nG9WnHrzju/PisUr0toGakTJ -c/5umYf4W77xfOZltU9s8MnF/xbKixsX4lg9ojerAby/QM5TjI7t7+5ZneBj5nxe -9Y5L8TvBAoGATUX5QIzFW/QqGoq08hysa+kMVja3TnKW1eWK0uL/8fEYEz2GCbjY -dqfJHHFSlDBD4PF4dP1hG0wJzOZoKnGtHN9DvFbbpaS+NXCkXs9P/ABVmTo9I89n -WvUi+LUp0EQR6zUuRr79jhiyX6i/GTKh9dwD5nyaHwx8qbAOITc78bA= ------END RSA PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyEnc.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyEnc.pem deleted file mode 100755 index e5ab57d..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyEnc.pem +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-CBC,136C7D8A69656668 - -jvNTyPaztxPIoAzbdmZnD0Zw2+60tMxNc0GMHNmeOyG25aHP/dT+TWiKFpFVkkkY -uoCIhYUyw7gmpw+CnRJwWd+ans4nrvAjwy5oWJvarvsyUpjqvnPoIlAqd+d4TDKN -eESzcI76+gHdisAtCrQD+fGqgTZhli5TgDbnpasL/QnY2qDlutvakkVw7gPXe156 -2Phy8WN+efr65J6wt3K/dj7Datl9u4JeHQK81gYyWBVX+EagEjPGDzkFQCj9Z0q7 -8K3iB5GW1JAqJS0IfZPB40AnSTF/n1TL1SN3qfU3l7hTGNrx9o7580bgDEoAR7pI -F8eZlS15KHtZmh11AnU1KTKZ6kmgnNqeMTGMN6N0ct2wMKW1dV87eTDlF0oiR2ol -XwtFgKmrIjfpmzkdWjbJmWnGMjD56KdiFZga/ZyKMsPrVoYLgfJEpn36iQspfygx -HCGNTf0PjIsjEWU0WyQiF86t+c45W3wNFsv/AxVyfMl+su02yrd6u2ecuQDir3Cs -b2k8IKtQgVe/NIpEWLKuiHG5oedIPPQyDYK5uq+gHxCGeOoKnWlsWFEHZRiza4X5 -tbgTrJB8Sw0ENWrvVGGmQZN4pSImlsMwzQ2qik5CQ00N1b3+56/obn0z75I3bUSb -tC5g8DRjl6oclAenNgh/MYMT287y5W2dD4npxHcekX4O3J2CDXNfg4vV2j5GRxtg -LVJdYE2p7bpYePCDHrYng8b9ubBprx0CrEnkIvvtUjzNPf6VDL0+MBKl+XgR2/nz -iRqTuZnlGGOyM+KYDwXpgwfs/HfvFGksxTAlO/40GkGh+WGPaIoNyCK0SgQKhyb4 -JIkR0vd2/yLg3lWMJrGwh7A0Gm07Z/781oURP3uWd+PaCOgGcd5ipcAjcEyuxNly -AthipWqmQWUcbf6Z2N9j3OA22Hv2Uzk8HSfi9VOZtL9svdEEZ0NnOekJgnc6stQp -bXiknlK/T5WdrWxSyCfgUq68Vf6DFfIRAVuFdJ3WHT2wVXHrDfft6D+Ne/XCxPoE -8zGmkyusaph33UHQ1oNyUbLbwcDCDSmOo8gYoedD3IwxtMA3wJRugomqosItwV8X -vkgmcy8eSE/+gZUxJEN2gnLcfKFhCkC80J6oFhmoDD6vuUnPHcFdKZgVPw2rzPk5 -Vb1kX+gpORplYmKpq1vz/ujscL4T0TmYLz02hkIS4edpW55ncTTv7JWefpRiTB1J -RB3td3me4htqR+YIDWJ+emrOmqsCG2WvpAS+MTw2mj1jYk9LL/ZYobTjSCEWmuwT -yVK6m303irR7HQDauxhslRFgoK21w63viOyj5NKIU1gQtaAANGDxcgORC1XLjjgt -oNutSQA+7P42vfHSHK4cnTBXl6V32H/GyVpdHQOZqSrqIjgLmUZodSmRPROxosZF -a46B1O7m/rJFxkiKW4vod+/WqjoE0Hhfrb8rRrkRjzGeCqqSSnQ3vrunVkvF8hlA -b6FOv4ZBJL4piC1GKH+rscqke9NEiDqXN8C3iYz86jbck/Ha21yUS8T3X7N52sg+ -B3AmOGnLK6BebYeto9vZxQjacChJZSixSxLV+l9/nVQ0+mW42azHdzk0ru59TGAj ------END RSA PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyPkcs8.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyPkcs8.pem deleted file mode 100755 index a24c5a2..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyPkcs8.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAlQjhV0HycW23 -0kVBJwFlxkWu8rwkMLiVzi9O1vYciLx8n/uoZ3/+XJxRdfeKygfnNS+P4b17wC98 -q2SoF/zKXXu64CHlci5vLobYlXParBtTuV8/1xkNJU/hY2NRiwtkP61DuKUcXDSz -rgCgY8X2fwtZaHhzpowYqQJtr8MZAS64EOPGzEC0aaNGM2mHbsS7F6bz6N2tc7x7 -LyG1/WZRDL1Us+FtXxy8I3PRCQOJFNIQuWTDKtChlkq84dQaW8egwMFjeA9ENzAy -loAyI5Whd7oT0pdz4l0lyWoNwzlgpLSwaUJCCenYCLwzILNYIqeq68Th5mGDxdKW -39nQT63XAgMBAAECggEBAJrQNA9SYgVQAe+f7WRuwsTaGvKE15IQSJLE6Wrri3Vs -xnk48slySoZkVJV3y8OanbfUHaQAyJ5O5N3HumcWwXS8qdaUjyswGvvt3yEFI9lK -Ob2Ya2WauNzEfe6mQxUuPb4dImAqczDVPtiirIZDLsT1ZF4/iXUPEdhRJU6f2Kqj -zmCz4orZfhvwZMqaWwULW6rL5eM/bjIiBfPQ+u90UoHiX3TTvf8xg0V1+mN6ly7W -thnGkibkKAZQUA54Lql4DRSXtBLYMUCroQFBwjD4B18W5GF30mDyn43o9LrrY94q -l4HvTGzmVTRRKyg09FMcxFgKP7uvtfdKhUMtPPFYWIECgYEA8ixUdjkjY8kQMreT -ra++GXWWgWTmtbiJQkHRbdAcG/gbrGnLNjxkfdz0GbjDYLFXSF9ST1k6VX8ywBlD -UD+uzm8X8w6fQMpOrRU7yXnpwFk4c3CcCnzJOkgyp9hJdQqFwsL9FXPamQkqaZqf -CnG/sASmjHpab0haVDvGsVMX3+cCgYEAy5PedxVdt1xcfNiQqZgt1mkOY7Oj3KbM -i2qkohKMjntILLJLN9wGGH3q/nah1KHpPw3NG1+vX56WW1sPoXyvs5uQ21dzOu2w -I0SuQU8fB0ITI0zL+vQUpNX3njZ8W5+oPMGFX3TSOS3/0ITf+7Mgei6bF67muguu -X1OkUu0bxJECgYEA7Jjau9X++VJKfQJVSW9VblIvhKMrs4Zis1TSY1La44h2oO+L -FaXTGBRyd17HowQfnhlitRsbnsPytTL5TMGq6wwmfdRfSlFcpEUGcESnVsDUIhR2 -nthjUImQ0+K/gZWSMUGHORpDCxilUx85Gl8fQ7yHat9u0yIA/iKYcE4aGSkCgYEA -ikFWKFGeX9SeCzuYo1TybFbUqulpM4UkDNrUDC3Ev08CaTh81ObcTO3XFhHDPgDn -wybAUQLeu3Wcb1acevOO78+KxSvS2gZqRMlz/m6Zh/hbvvF85mW1T2zwycX/FsqL -GxfiWD2iN6sBvL9AzlOMju3v7lmd4GPmfF71jkvxO8ECgYBNRflAjMVb9CoairTy -HKxr6QxWNrdOcpbV5YrS4v/x8RgTPYYJuNh2p8kccVKUMEPg8Xh0/WEbTAnM5mgq -ca0c30O8VtulpL41cKRez0/8AFWZOj0jz2da9SL4tSnQRBHrNS5Gvv2OGLJfqL8Z -MqH13APmfJofDHypsA4hNzvxsA== ------END PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyPkcs8Enc.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyPkcs8Enc.pem deleted file mode 100755 index 4be31a3..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyPkcs8Enc.pem +++ /dev/null @@ -1,29 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIE6TAbBgkqhkiG9w0BBQMwDgQIr3AyvPqfFRQCAggABIIEyPUs6wCboqtKmExH -zfez3vfHn2cp6s3X563Bz73hYn/8vXtI/q0oDNOpgav60/N7rMy50fno3LmW0/6E -+UN4MwofmBS3lp1ZVY3KmzDy6lz5vcFo4GCCj+X6dacsyBQ4lFOge5BihQ3R9cKt -dSrd1EFKwGGu3qTDG7ajTZukmYjxuRqpyHqPO5OJO7yXxHOB7B7sSKIyJRCkkucd -oBC86kQdWraweSYj+Klza6VjKzmNzDBx9Fyhrj9XGXJ3rJLhjgNpelwX+PIMU31i -/yklI4jm0aMSoAvXgdBXZuOsnsI27GXxy//i7AOgLLWi+Bu4dJSSl5PMtespf83u -5jSysJymXiNcN6vEautGyjCujdMs5c/FEMbgubAMXymCI9DsAN+5dNMDY8Zrfqdl -hFKfctcu8BxFa+0tavJ28fOEBuEyJLsQ9OvvS7dn4AV502JRKWObfsw7fi+mMzMu -oxhYo99MRqic6a9uDmYB3SPeU31eOHiEi0n51D7Gtcn++F+IaDFwSHMirThzakGn -go3nj0yq62euzVcEuhIfTTAe3F2tqzpzznVFbs1XgrGVREJ6gp5vRgMUUGYIqQir -p5oW0HVRI4iuoSjdN4/wNAxIP9zakwYx+vWx1VXhDVEJfgNmxDRvEbF+OOz+iJCf -7A2e8L+kZ/5oC3HO8h7GdHNTUjRRdh8FUM8lGo+HbMYDznMy/bJlIP2bx9hIIha7 -U70i09glS2Z7Ei+VecJbvFzdro0vdYyGO2ef8bWwCc5JMucxDcRklWdUxK6amKJN -VpXL3TW0VYCfr1rLmZXUfBGk/KXM20/BoM04WLjeR3oiV/2b7SYK7GnJ7kBmAHHx -gnrwMDO3JvH89CwlHRizVSQl59ViqEMGLmbHThcMqkEOkFphB2xox7/IOVyp6cFn -mY0ZCrbhdX+L6t5jiyq/4us5bzF7FOBYsJr6n1Rm9b8eeOL693y/6uM3CvTJcTOb -5RqWiHgTgmefeOeUQ0/dVgvEOIWz2yqBQmHKiB4+0CGGIRwUOXBrTKSLilumsjQe -qGhJ6yw25VIpdXsMD1WVviczgRTNYjdldIJoHQdvpCEAhQ1RR3rkuIPniTumJFmY -CnjfNqjtkaZWIN1nOCmcu50tswksWEEFEfkcP1xyzhr3EVCYAoFncLTp5vHBtdmg -6KBdar40/OFGAcbDGDX1g3XEEi6jHmy0Lyz7M3DwESgaMgwzscsQLr+wMITk1IUN -yfiXHl1CQjGxhDj8KoAhdDjjPENkSlCSd1vEO+lg1/IFb1dtnL2DJp6BQt9/VLHo -Fp3pdZ7r95H20+pEhCZp0HXLNo1o8xjJQ5RWUCs1Zc1cauDOAh8lAjps6MBxTa3a -LOgTW9lgiAQ+S1g2jK4BmqbLvZUF+Z6xupc8uE3E3HhJolmDRYojMNFNmmvODa8M -CneWmj3T1KvqEToAIq46mStlTfQufSMpaJ73Wds4gmIiGwn5hIuUN6f3kybbt4f2 -4DLZXMcjYweLi9tJtFC+JaO0rS5gtX/k/ys1QSblSU5qfRu1XfwNAcZO1ReKgGYN -ymI78cSACGIcEvAwin8CdRu3W99NbMqHW9AcCETFlTsC3wNlQxyYSem75sjPaWVF -sxLy7YxEJ8tDEJZbSQ== ------END ENCRYPTED PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyPkcs8Enc12.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyPkcs8Enc12.pem deleted file mode 100755 index f9d30d2..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyPkcs8Enc12.pem +++ /dev/null @@ -1,29 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIE6jAcBgoqhkiG9w0BDAEDMA4ECAGQiv1ZBAPqAgIIAASCBMhFUVwujBcs/XvB -vmxHOJWn27QJFXXADhKYA7pRFsSx3hlLAAZfQnRuulwoKUVLbyNN7wTB5z8R2PHb -WY1R/d34PIGfYTNZs2uzw3KMn6M4gio+dHwVoMN5eidda4sO861UpTRyy99Y2UXK -tNE84qQdm+ZbjN5PjFyvfpu5jRGyJWWnvvjlbTBoMP4exHJEEVfvV/QguaL5tOHv -lZqQ9Lynx6gy+Jt2dF87rz+90MdbjZgaaxqoMx6JYmCCRpkcIjCVdtWVmrUHzbIV -ee0w1/FiIKx+m63/8DzKxAsCvYuI8dAmWbNZ4KY7kWmGZ7A4dwZaqU87gUSvSnyL -J67K7+v7Tnx2y8muBkqVMX19EP5fnFRiM16x7/PIikR4Q4zJrN7sK6+zBSeq6szh -x3N94qm3EzBYY6nJAViEggY+Z+4+SQlErxZkBRfs7hGAejG1RoyyAr0/9ojwUH9p -0J4PiDmtnOq14eraRMMeWdIu+3301cZzrZLhBGXXPq1mYcoZxpt+vKTPHPfTSyEh -FuFSVDu43s89MwHpsK5b4FAqMd/rpLoXPYEboD6ZK3mhPKiIYkpjdOpQCCjcQ6Kf -acrFXo5jz+Zafz2U80qhpWxDz3RZQC/MBCwWVS8+iNv8KoxE40SSmlCFMcXSXNwP -dTRsZnRvNX91b8UAn37+dzRE1lJX79xT51uC1UjlkVeWz/ZV5KwupJ0MvdGDNVDN -4F+GpLvd/g2Q3xx4rl1Vx+fUPh+IDRIWRmaJ5rJqqgn1pzZx4tS+0Rjoekk28SUD -DIzmZFswWus385DYhYcn6FAWf2dTq3LulJcX2DovGLiGu3TUA4JlVl3ejWvf5FZY -kQx/Z9Cf7+nW69Okuwa+DX3d8g1pFPqWyoFN5cLqiNIiolqP/pIVTlCp5WZHRCJx -HO2f+mxt7lvymOKLrlq35DywLhYYj4J8OAXI95LRLGWY5GV68f4BKcVpPweAVrHm -V2zVgCvIDqe2rlXF/hB5eQiiUa9FOaoKJ2NAhfcCar8Ty0PnYwgFpcBh1fXaxfj+ -hwv7Pb2ioRDQOgaxtvF26phms79tMxK3HnDXfBvRzIn2pATOJr5om4z4JYna6DSp -dILlW9X5U5/OATIY9DdtvZiAom36YMUfXbHjHf6cZwIgkJQP3KF+2Jd9iMhQwAmQ -xiA114zmxlXzvJqGA1LTwVDPA3VyUTQXAZg/2RroB8rTufYRTYKC37h+YXXwtCkP -gLQtG6gsWPaQ23xddLQI1pk3HvLFR3y0Zr2vR7OYbv5CFXH3pCVeKN+Y9r6c/IbC -CRS2S7iwiEuI0YTvUrfscVIQGuc3iC2mJRjCrQUB28LQ6cbCccLk/P/2ynse/lyu -+29/QLZCL3GJlYHvOL1GBnupHygTOETtVW34+j/jDjyOVvZLTuOwtzb7+8R157OI -bUQujZ9f5IRYeRNTliwsZYQXjOI+iMheWHl1kd/qV3FFO946hp9BV1TeFQwCf1Vx -b8kWLgUpZpHz5d07EBKhzSQb0OacMEm5FsS3IRRIdnmqvpMsW1wsOjE6VxkS/Ozg -QE8YGeT1F10bfcJtp2m9uVRpPfffcckW89wBsI9uLsj6pETzLtHVVyepB7NxKRtT -3ChWuLWbwCQsrzyPdms= ------END ENCRYPTED PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyPkcs8Enc2.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyPkcs8Enc2.pem deleted file mode 100755 index 297f2a0..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/server-keyPkcs8Enc2.pem +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIxaI9IblN3acCAggA -MBQGCCqGSIb3DQMHBAi7kwdRvCrqMgSCBMjkSOSVfmu42O0q2GzFrJVr3cam9ZKe -InQsxqtgADdBxMgJJVnr360tUNPQyyvfCH//Duhz+aJIC0MQZkWR3ZSy5pfHX+vr -C3wd741VOlI44uEdzRktlPc11saMDyKS04/K9aaYIDqspOiobt9WZLQildXl1n8j -N+7Laj7A/vxJ5GUJ4hdPwQOIeuJXTDDzn+Ld12XXGH+Iw1M5Cx3tBw1TNizSnmXQ -vf/MsfsWsZbHBppCXZbF27jJA+6Bg7dGT0OZM0pI+ZQvyHr+qjog0hollY9KjwTG -h+hsM7umWFJdeRMrmkTrX/R9HY/c5I4ExNSp1AtMmFeeU8h2VTJtYcoykUU1q2pF -KHfjPghwmYromQGR4nPA9sqa9s+VMq9OaqoJDoBwNobdFr7sEtMLT08vTa0+rMX7 -bmjAF44/dVBYpBxXjTQ0pXVeb24Q00Sn6NOI4fTsBnkR+WTtuwz/L0qaGnJlh10y -sQ3+95cUtZc3SZS67yYUx5auswqT3V4JCmhJcHNi+/jHyrj9D8nVWibQ2TBmgUf+ -0NzvdKb7sraEx7PSgFWDMLoQrd2+cqsJArpY9TbLSLhBDrOVc8v/lXYuK6QI0gMd -HIwAZARUZMoI3WS6icTLYyLdQPMsFzI6U0arkbrdhjNNd3kVqeFEJ+oF0rkuAcJJ -K8eUcsby1AIBS/9tuW1gSYubmuXsZX8xbYbJnHUqGOTAVa7jo8eVUTiyUfPXa+0N -s1tTpZXtOOlqncZ08mPHppshdKF2cpuh0JNjiR6fHvXytGWFGMsKtxdwKs/14UCg -qoTW0EQU4ONfBxR2PtX8PlNV4bOt704HP8Vc0H9JV2uWpJaLRzY2bBiPgKcrO9Eh -83zFrPu/0obBQTxnP3mMihxvCndflHQqeJ0V1YYw9n4+XbgBqULXDQs7OetRohnY -gYyc//NdC2I8mbdabFYvUTWSH6oMA6lqkwTjTTwtn5E8BJkRi1sIq4jNFUekpm2T -5AwP7xWn//PM+B12CPoIgYtYT6Yhbf8arXuGU28y1Ahhi/hKcpR9HRPQeyaR62vi -skjjycfn38wcj0WrIVnOceGgPa3EBrkkTaPUHvMQ5G/xzMZ82o3CnmwdnH+lp3eg -TLcLm8Yp9InkMJNVOrGLxFvmTljl3h9x2JVuE0wtuWt91QVmfCZo0k3Cx46ad7xB -eK20veTy+PySy2U3W1twGfsXXXRwaQiXXRrgPciK0LcGXZneShZuebk04U31sq4F -rYaMAzIDDmvwbjh+UpNcl1VdBDGGePxzzOD3HHYPbm240HVMPuS85P2kFjak3PdJ -GqsRUS1SRp1e451aFGjzggPLXFjAfDMaxrgjSWapRzu78i+xvcvf69979oX0KO9Y -KMSC14RnmnT1+UdKxX+p9r1AwfH/vJxM34AOSva1uLiSJckRGYGOzuaYsTT9ZAx/ -q3CNALF4qFUMWmJnvQDYmCUnw6lJl3CazbtV5RI2ILQX6ZHR6YAHT5hYY43k+AnZ -mFW6BGKoX/f4iVqYtjQWiGWAJAf6C9+548O2t9MiVcgQf4Nvj6lFLM00pzFn7jW4 -DsDFUBmmrSF8wfR7SRpOc/ViVZBRleYPLsMu0tmD29fowqqBY0MEkxqSahFAGTgk -sao= ------END ENCRYPTED PRIVATE KEY----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/taoCert.txt b/FreeRTOS-Plus/Source/WolfSSL/certs/taoCert.txt deleted file mode 100755 index 3c954a7..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/taoCert.txt +++ /dev/null @@ -1,176 +0,0 @@ - -***** Create a self signed cert ************ - -1) openssl genrsa 1024 > client-key.pem - -2) openssl req -new -x509 -nodes -sha1 -days 1000 -key client-key.pem > client-cert.pem - -3) note md5 would be -md5 - --- adding metadata to beginning - -3) openssl x509 -in client-cert.pem -text > tmp.pem - -4) mv tmp.pem client-cert.pem - - -***** Create a CA, signing authority ********** - -same as self signed, use ca prefix instead of client - - -***** Create a cert signed by CA ************** - -1) openssl req -newkey rsa:1024 -sha1 -days 1000 -nodes -keyout server-key.pem > server-req.pem - -* note if using exisitng key do: -new -key keyName - -2) copy ca-key.pem ca-cert.srl (why ????) - -3) openssl x509 -req -in server-req.pem -days 1000 -sha1 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem - - -***** Adding Subject Key ID and Authentication Key ID extensions to a cert ***** - -Create a config file for OpenSSL with the example contents: - - [skidakid] - subjectKeyIdentifier=hash - authorityKeyIdentifier=keyid - -Add to the openssl command for creating a cert signed by a CA step 3 the -following options: - - -extfile -extensions skidakid - -anywhere before the redirect. This will add the cert's public key hash as the -Subject Key Identifier, and the signer's SKID as the Authentication Key ID. - - -***** To create a dsa cert ******************** - -1) openssl dsaparam 512 > dsa512.param # creates group params - -2) openssl gendsa dsa512.param > dsa512.pem # creates private key - -3) openssl req -new -x509 -nodes -days 1000 -key dsa512.pem > dsa-cert.pem - - - - -***** To convert from PEM to DER ************** - -a) openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER - -to convert rsa private PEM to DER : - -b) openssl rsa -in key.pem -outform DER -out key.der - - -**** To encrypt rsa key already in pem ********** - -a) openssl rsa server-keyEnc.pem - -note location of des, pass = yassl123 - - -*** To make a public key from a private key ****** - - -openssl rsa -in 1024rsa.priv -pubout -out 1024rsa.pub - - -**** To convert to pkcs8 ******* - -openssl pkcs8 -nocrypt -topk8 -in server-key.pem -out server-keyPkcs8.pem - - -**** To convert to pkcs8 encrypted ******* - -openssl pkcs8 -topk8 -in server-key.pem -out server-keyPkcs8Enc.pem - -passwd: yassl123 - -to use PKCS#5 v2 instead of v1.5 which is default add - --v2 des3 # file Pkcs8Enc2 - -to use PKCS#12 instead use -v1 witch a 12 algo like - --v1 PBE-SHA1-3DES # file Pkcs8Enc12 , see man pkcs8 for more info --v1 PBE-SHA1-RC4-128 # no longer file Pkcs8Enc12, arc4 now off by default - - -**** To convert from pkcs8 to traditional **** - -openssl pkcs8 -nocrypt -in server-keyPkcs8.pem -out server-key.pem - - -*** DH paramters *** - -openssl dhparam 2048 > dh2048.param - -to add metadata - -openssl dhparam -in dh2048.param -text > dh2048.pem - -**** ECC ****** - -1) make a key - - to see types available do - openssl ecparam -list_curves - - make a new key - openssl ecparam -genkey -text -name secp256r1 -out ecc-key.pem - - convert to compressed - openssl ec -in ecc-key.pem -conv_form compressed -out ecc-key-comp.pem - -*** CRL *** - -1) create a crl - -a) openssl ca -gencrl -crldays 120 -out crl.pem -keyfile ./ca-key.pem -cert ./ca-cert.pem - -Error No ./CA root/index.txt so: - -b) touch ./CA root/index.txt - -a) again - -Error No ./CA root/crlnumber so: - -c) touch ./CA root/crlnumber - -a) again - -Error unable to load CRL number - -d) add '01' to crlnumber file - -a) again - -2) view crl file - -openssl crl -in crl.pem -text - -3) revoke - -openssl ca -revoke server-cert.pem -keyfile ./ca-key.pem -cert ./ca-cert.pem - -Then regenerate crl with a) - -4) verify - -openssl verify -CAfile ./ca-cert.pem ./server-cert.pem - -OK - -Make file with both ca and crl - -cat ca-cert.pem crl.pem > ca-crl.pem - -openssl verify -CAfile ./ca-crl.pem -crl_check ./ca-cert.pem - -revoked diff --git a/FreeRTOS-Plus/Source/WolfSSL/certs/wolfssl-website-ca.pem b/FreeRTOS-Plus/Source/WolfSSL/certs/wolfssl-website-ca.pem deleted file mode 100755 index 704a29f..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/certs/wolfssl-website-ca.pem +++ /dev/null @@ -1,83 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 0 (0x0) - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=US, O=The Go Daddy Group, Inc., OU=Go Daddy Class 2 Certification Authority - Validity - Not Before: Jun 29 17:06:20 2004 GMT - Not After : Jun 29 17:06:20 2034 GMT - Subject: C=US, O=The Go Daddy Group, Inc., OU=Go Daddy Class 2 Certification Authority - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (2048 bit) - Modulus: - 00:de:9d:d7:ea:57:18:49:a1:5b:eb:d7:5f:48:86: - ea:be:dd:ff:e4:ef:67:1c:f4:65:68:b3:57:71:a0: - 5e:77:bb:ed:9b:49:e9:70:80:3d:56:18:63:08:6f: - da:f2:cc:d0:3f:7f:02:54:22:54:10:d8:b2:81:d4: - c0:75:3d:4b:7f:c7:77:c3:3e:78:ab:1a:03:b5:20: - 6b:2f:6a:2b:b1:c5:88:7e:c4:bb:1e:b0:c1:d8:45: - 27:6f:aa:37:58:f7:87:26:d7:d8:2d:f6:a9:17:b7: - 1f:72:36:4e:a6:17:3f:65:98:92:db:2a:6e:5d:a2: - fe:88:e0:0b:de:7f:e5:8d:15:e1:eb:cb:3a:d5:e2: - 12:a2:13:2d:d8:8e:af:5f:12:3d:a0:08:05:08:b6: - 5c:a5:65:38:04:45:99:1e:a3:60:60:74:c5:41:a5: - 72:62:1b:62:c5:1f:6f:5f:1a:42:be:02:51:65:a8: - ae:23:18:6a:fc:78:03:a9:4d:7f:80:c3:fa:ab:5a: - fc:a1:40:a4:ca:19:16:fe:b2:c8:ef:5e:73:0d:ee: - 77:bd:9a:f6:79:98:bc:b1:07:67:a2:15:0d:dd:a0: - 58:c6:44:7b:0a:3e:62:28:5f:ba:41:07:53:58:cf: - 11:7e:38:74:c5:f8:ff:b5:69:90:8f:84:74:ea:97: - 1b:af - Exponent: 3 (0x3) - X509v3 extensions: - X509v3 Subject Key Identifier: - D2:C4:B0:D2:91:D4:4C:11:71:B3:61:CB:3D:A1:FE:DD:A8:6A:D4:E3 - X509v3 Authority Key Identifier: - keyid:D2:C4:B0:D2:91:D4:4C:11:71:B3:61:CB:3D:A1:FE:DD:A8:6A:D4:E3 - DirName:/C=US/O=The Go Daddy Group, Inc./OU=Go Daddy Class 2 Certification Authority - serial:00 - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: sha1WithRSAEncryption - 32:4b:f3:b2:ca:3e:91:fc:12:c6:a1:07:8c:8e:77:a0:33:06: - 14:5c:90:1e:18:f7:08:a6:3d:0a:19:f9:87:80:11:6e:69:e4: - 96:17:30:ff:34:91:63:72:38:ee:cc:1c:01:a3:1d:94:28:a4: - 31:f6:7a:c4:54:d7:f6:e5:31:58:03:a2:cc:ce:62:db:94:45: - 73:b5:bf:45:c9:24:b5:d5:82:02:ad:23:79:69:8d:b8:b6:4d: - ce:cf:4c:ca:33:23:e8:1c:88:aa:9d:8b:41:6e:16:c9:20:e5: - 89:9e:cd:3b:da:70:f7:7e:99:26:20:14:54:25:ab:6e:73:85: - e6:9b:21:9d:0a:6c:82:0e:a8:f8:c2:0c:fa:10:1e:6c:96:ef: - 87:0d:c4:0f:61:8b:ad:ee:83:2b:95:f8:8e:92:84:72:39:eb: - 20:ea:83:ed:83:cd:97:6e:08:bc:eb:4e:26:b6:73:2b:e4:d3: - f6:4c:fe:26:71:e2:61:11:74:4a:ff:57:1a:87:0f:75:48:2e: - cf:51:69:17:a0:02:12:61:95:d5:d1:40:b2:10:4c:ee:c4:ac: - 10:43:a6:a5:9e:0a:d5:95:62:9a:0d:cf:88:82:c5:32:0c:e4: - 2b:9f:45:e6:0d:9f:28:9c:b1:b9:2a:5a:57:ad:37:0f:af:1d: - 7f:db:bd:9f ------BEGIN CERTIFICATE----- -MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh -MB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBE -YWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3 -MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRo -ZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3Mg -MiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN -ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCA -PVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6w -wdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXi -EqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWoriMY -avx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZEewo+ -YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0OBBYEFNLE -sNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h -/t2oatTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5 -IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmlj -YXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD -ggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wimPQoZ+YeAEW5p5JYXMP80kWNy -OO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKtI3lpjbi2Tc7P -TMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ -HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mER -dEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5Cuf -ReYNnyicsbkqWletNw+vHX/bvZ8= ------END CERTIFICATE----- diff --git a/FreeRTOS-Plus/Source/WolfSSL/config.in b/FreeRTOS-Plus/Source/WolfSSL/config.in deleted file mode 100755 index e040f36..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/config.in +++ /dev/null @@ -1,178 +0,0 @@ -/* config.in. Generated from configure.ac by autoheader. */ - -/* Define if building universal (internal helper macro) */ -#undef AC_APPLE_UNIVERSAL_BUILD - -/* Define to 1 to enable debugging code. */ -#undef DEBUG - -/* Define to 1 if you have the header file. */ -#undef HAVE_ARPA_INET_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_ERRNO_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if you have the `getaddrinfo' function. */ -#undef HAVE_GETADDRINFO - -/* Define to 1 if you have the `gethostbyname' function. */ -#undef HAVE_GETHOSTBYNAME - -/* Define to 1 if you have the `gettimeofday' function. */ -#undef HAVE_GETTIMEOFDAY - -/* Define to 1 if you have the `inet_ntoa' function. */ -#undef HAVE_INET_NTOA - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the `network' library (-lnetwork). */ -#undef HAVE_LIBNETWORK - -/* Define to 1 if you have the `pthread' library (-lpthread). */ -#undef HAVE_LIBPTHREAD - -/* Define to 1 if you have the header file. */ -#undef HAVE_LIMITS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `memset' function. */ -#undef HAVE_MEMSET - -/* Define to 1 if you have the header file. */ -#undef HAVE_NETDB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_NETINET_IN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_PCAP_PCAP_H - -/* Define if you have POSIX threads libraries and header files. */ -#undef HAVE_PTHREAD - -/* Have PTHREAD_PRIO_INHERIT. */ -#undef HAVE_PTHREAD_PRIO_INHERIT - -/* Define to 1 if you have the `socket' function. */ -#undef HAVE_SOCKET - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDDEF_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_IOCTL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SOCKET_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TIME_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 or 0, depending whether the compiler supports simple visibility - declarations. */ -#undef HAVE_VISIBILITY - -/* Define to 1 if the system has the type `__uint128_t'. */ -#undef HAVE___UINT128_T - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#undef LT_OBJDIR - -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -#undef NO_MINUS_C_MINUS_O - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to necessary symbol if this constant uses a non-standard name on - your system. */ -#undef PTHREAD_CREATE_JOINABLE - -/* The size of `long', as computed by sizeof. */ -#undef SIZEOF_LONG - -/* The size of `long long', as computed by sizeof. */ -#undef SIZEOF_LONG_LONG - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* If the compiler supports a TLS storage class define it to that here */ -#undef TLS - -/* Define if the code was built from VCS. */ -#undef VCS_CHECKOUT - -/* VCS system */ -#undef VCS_SYSTEM - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -# undef WORDS_BIGENDIAN -# endif -#endif - -/* Define for Solaris 2.5.1 so the uint8_t typedef from , - , or is not used. If the typedef were allowed, the - #define below would cause a syntax error. */ -#undef _UINT8_T - -/* Define to `unsigned int' if does not define. */ -#undef size_t - -/* Define to the type of an unsigned integer type of width exactly 8 bits if - such a type exists and the standard includes do not define it. */ -#undef uint8_t diff --git a/FreeRTOS-Plus/Source/WolfSSL/configure b/FreeRTOS-Plus/Source/WolfSSL/configure deleted file mode 100755 index 6523b8c..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/configure +++ /dev/null @@ -1,27938 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for wolfssl 3.6.0. -# -# Report bugs to . -# -# -# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. -# -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -# Use a proper internal environment variable to ensure we don't fall - # into an infinite loop, continuously re-executing ourselves. - if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then - _as_can_reexec=no; export _as_can_reexec; - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -as_fn_exit 255 - fi - # We don't want this to propagate to other subprocesses. - { _as_can_reexec=; unset _as_can_reexec;} -if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi -" - as_required="as_fn_return () { (exit \$1); } -as_fn_success () { as_fn_return 0; } -as_fn_failure () { as_fn_return 1; } -as_fn_ret_success () { return 0; } -as_fn_ret_failure () { return 1; } - -exitcode=0 -as_fn_success || { exitcode=1; echo as_fn_success failed.; } -as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } -as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } -as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : - -else - exitcode=1; echo positional parameters were not saved. -fi -test x\$exitcode = x0 || exit 1 -test -x / || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 - - test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( - ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' - ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO - ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO - PATH=/empty FPATH=/empty; export PATH FPATH - test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ - || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 -test \$(( 1 + 1 )) = 2 || exit 1" - if (eval "$as_required") 2>/dev/null; then : - as_have_required=yes -else - as_have_required=no -fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : - -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - as_found=: - case $as_dir in #( - /*) - for as_base in sh bash ksh sh5; do - # Try only shells that exist, to save several forks. - as_shell=$as_dir/$as_base - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : - CONFIG_SHELL=$as_shell as_have_required=yes - if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : - break 2 -fi -fi - done;; - esac - as_found=false -done -$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi; } -IFS=$as_save_IFS - - - if test "x$CONFIG_SHELL" != x; then : - export CONFIG_SHELL - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 -fi - - if test x$as_have_required = xno; then : - $as_echo "$0: This script requires a shell more modern than all" - $as_echo "$0: the shells that I found on your system." - if test x${ZSH_VERSION+set} = xset ; then - $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" - $as_echo "$0: be upgraded to zsh 4.3.4 or later." - else - $as_echo "$0: Please tell bug-autoconf@gnu.org and -$0: https://github.com/wolfssl/wolfssl/issues about your -$0: system, including any error possibly output before this -$0: message. Then install a modern shell, or manually run -$0: the script under such a shell if you do have one." - fi - exit 1 -fi -fi -fi -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -# Unset more variables known to interfere with behavior of common tools. -CLICOLOR_FORCE= GREP_OPTIONS= -unset CLICOLOR_FORCE GREP_OPTIONS - -## --------------------- ## -## M4sh Shell Functions. ## -## --------------------- ## -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - - - as_lineno_1=$LINENO as_lineno_1a=$LINENO - as_lineno_2=$LINENO as_lineno_2a=$LINENO - eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && - test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { - # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - - # If we had to re-execute with $CONFIG_SHELL, we're ensured to have - # already done that, so ensure we don't try to do so again and fall - # in an infinite loop. This has already happened in practice. - _as_can_reexec=no; export _as_can_reexec - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - -SHELL=${CONFIG_SHELL-/bin/sh} - - -test -n "$DJDIR" || exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= - -# Identity of this package. -PACKAGE_NAME='wolfssl' -PACKAGE_TARNAME='wolfssl' -PACKAGE_VERSION='3.6.0' -PACKAGE_STRING='wolfssl 3.6.0' -PACKAGE_BUGREPORT='https://github.com/wolfssl/wolfssl/issues' -PACKAGE_URL='http://www.wolfssl.com' - -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif" - -ac_subst_vars='am__EXEEXT_FALSE -am__EXEEXT_TRUE -LTLIBOBJS -LIBOBJS -INC_AMINCLUDE -AMINCLUDE -GENERIC_CONFIG -AM_LDFLAGS -AM_CFLAGS -AM_CPPFLAGS -HEX_VERSION -IS_VCS_CHECKOUT_FALSE -IS_VCS_CHECKOUT_TRUE -BUILD_MCAPI_FALSE -BUILD_MCAPI_TRUE -BUILD_LIBZ_FALSE -BUILD_LIBZ_TRUE -BUILD_EXAMPLES_FALSE -BUILD_EXAMPLES_TRUE -BUILD_SLOWMATH_FALSE -BUILD_SLOWMATH_TRUE -BUILD_FASTMATH_FALSE -BUILD_FASTMATH_TRUE -BUILD_PWDBASED_FALSE -BUILD_PWDBASED_TRUE -USE_VALGRIND_FALSE -USE_VALGRIND_TRUE -HAVE_VALGRIND -BUILD_PKCS7_FALSE -BUILD_PKCS7_TRUE -BUILD_NTRU_FALSE -BUILD_NTRU_TRUE -BUILD_CRL_MONITOR_FALSE -BUILD_CRL_MONITOR_TRUE -BUILD_CRL_FALSE -BUILD_CRL_TRUE -HAVE_OPENSSL_CMD -BUILD_OCSP_FALSE -BUILD_OCSP_TRUE -BUILD_INLINE_FALSE -BUILD_INLINE_TRUE -BUILD_CHACHA_FALSE -BUILD_CHACHA_TRUE -BUILD_POLY1305_FALSE -BUILD_POLY1305_TRUE -BUILD_FIPS_FALSE -BUILD_FIPS_TRUE -BUILD_RABBIT_FALSE -BUILD_RABBIT_TRUE -BUILD_HC128_FALSE -BUILD_HC128_TRUE -BUILD_MD4_FALSE -BUILD_MD4_TRUE -BUILD_SHA_FALSE -BUILD_SHA_TRUE -BUILD_MD5_FALSE -BUILD_MD5_TRUE -BUILD_RC4_FALSE -BUILD_RC4_TRUE -BUILD_DES3_FALSE -BUILD_DES3_TRUE -BUILD_CODING_FALSE -BUILD_CODING_TRUE -BUILD_AES_FALSE -BUILD_AES_TRUE -BUILD_ASN_FALSE -BUILD_ASN_TRUE -BUILD_DH_FALSE -BUILD_DH_TRUE -BUILD_RSA_FALSE -BUILD_RSA_TRUE -BUILD_MEMORY_FALSE -BUILD_MEMORY_TRUE -BUILD_GEMATH_FALSE -BUILD_GEMATH_TRUE -BUILD_FEMATH_FALSE -BUILD_FEMATH_TRUE -BUILD_CURVED25519_SMALL_FALSE -BUILD_CURVED25519_SMALL_TRUE -BUILD_ED25519_FALSE -BUILD_ED25519_TRUE -BUILD_CURVE25519_FALSE -BUILD_CURVE25519_TRUE -BUILD_ECC_FALSE -BUILD_ECC_TRUE -BUILD_DSA_FALSE -BUILD_DSA_TRUE -BUILD_SHA512_FALSE -BUILD_SHA512_TRUE -BUILD_BLAKE2_FALSE -BUILD_BLAKE2_TRUE -BUILD_RIPEMD_FALSE -BUILD_RIPEMD_TRUE -BUILD_MD2_FALSE -BUILD_MD2_TRUE -BUILD_CAMELLIA_FALSE -BUILD_CAMELLIA_TRUE -BUILD_AESNI_FALSE -BUILD_AESNI_TRUE -BUILD_AESCCM_FALSE -BUILD_AESCCM_TRUE -BUILD_AESGCM_FALSE -BUILD_AESGCM_TRUE -BUILD_SNIFFTEST_FALSE -BUILD_SNIFFTEST_TRUE -BUILD_SNIFFER_FALSE -BUILD_SNIFFER_TRUE -BUILD_LEANPSK_FALSE -BUILD_LEANPSK_TRUE -BUILD_IPV6_FALSE -BUILD_IPV6_TRUE -PTHREAD_CFLAGS -PTHREAD_LIBS -PTHREAD_CC -ax_pthread_config -DEBUG_FALSE -DEBUG_TRUE -MCHECK -LIBM -am__fastdepCCAS_FALSE -am__fastdepCCAS_TRUE -CCASDEPMODE -CCASFLAGS -CCAS -HAVE_VISIBILITY -CFLAG_VISIBILITY -CXXCPP -am__fastdepCXX_FALSE -am__fastdepCXX_TRUE -CXXDEPMODE -ac_ct_CXX -CXXFLAGS -CXX -CPP -OTOOL64 -OTOOL -LIPO -NMEDIT -DSYMUTIL -MANIFEST_TOOL -RANLIB -ac_ct_AR -AR -DLLTOOL -OBJDUMP -LN_S -NM -ac_ct_DUMPBIN -DUMPBIN -LD -FGREP -EGREP -GREP -SED -am__fastdepCC_FALSE -am__fastdepCC_TRUE -CCDEPMODE -am__nodep -AMDEPBACKSLASH -AMDEP_FALSE -AMDEP_TRUE -am__quote -am__include -DEPDIR -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC -LIBTOOL -WOLFSSL_LIBRARY_VERSION -AM_BACKSLASH -AM_DEFAULT_VERBOSITY -AM_DEFAULT_V -AM_V -am__untar -am__tar -AMTAR -am__leading_dot -SET_MAKE -AWK -mkdir_p -MKDIR_P -INSTALL_STRIP_PROGRAM -STRIP -install_sh -MAKEINFO -AUTOHEADER -AUTOMAKE -AUTOCONF -ACLOCAL -VERSION -PACKAGE -CYGPATH_W -am__isrc -INSTALL_DATA -INSTALL_SCRIPT -INSTALL_PROGRAM -host_os -host_vendor -host_cpu -host -build_os -build_vendor -build_cpu -build -target_alias -host_alias -build_alias -LIBS -ECHO_T -ECHO_N -ECHO_C -DEFS -mandir -localedir -libdir -psdir -pdfdir -dvidir -htmldir -infodir -docdir -oldincludedir -includedir -localstatedir -sharedstatedir -sysconfdir -datadir -datarootdir -libexecdir -sbindir -bindir -program_transform_name -prefix -exec_prefix -PACKAGE_URL -PACKAGE_BUGREPORT -PACKAGE_STRING -PACKAGE_VERSION -PACKAGE_TARNAME -PACKAGE_NAME -PATH_SEPARATOR -SHELL' -ac_subst_files='' -ac_user_opts=' -enable_option_checking -enable_silent_rules -enable_static -enable_shared -with_pic -enable_fast_install -enable_dependency_tracking -with_gnu_ld -with_sysroot -enable_libtool_lock -enable_debug -enable_singlethreaded -enable_dtls -enable_opensslextra -enable_maxstrength -enable_ipv6 -enable_fortress -enable_bump -enable_leanpsk -enable_bigcache -enable_hugecache -enable_smallcache -enable_savesession -enable_savecert -enable_atomicuser -enable_pkcallbacks -enable_sniffer -enable_aesgcm -enable_aesccm -enable_aesni -enable_intelasm -enable_camellia -enable_md2 -enable_nullcipher -enable_ripemd -enable_blake2 -enable_sha512 -enable_sessioncerts -enable_keygen -enable_certgen -enable_certreq -enable_sep -enable_hkdf -enable_dsa -enable_ecc -enable_curve25519 -enable_ed25519 -enable_fpecc -enable_eccencrypt -enable_psk -enable_errorstrings -enable_oldtls -enable_stacksize -enable_memory -enable_rsa -enable_dh -enable_anon -enable_asn -enable_aes -enable_coding -enable_des3 -enable_arc4 -enable_md5 -enable_sha -enable_md4 -enable_webserver -enable_hc128 -enable_rabbit -enable_fips -enable_poly1305 -enable_chacha -enable_hashdrbg -enable_filesystem -enable_inline -enable_ocsp -enable_crl -enable_crl_monitor -with_ntru -enable_sni -enable_maxfragment -enable_truncatedhmac -enable_renegotiation_indication -enable_secure_renegotiation -enable_supportedcurves -enable_session_ticket -enable_tlsx -enable_pkcs7 -enable_scep -enable_smallstack -enable_valgrind -enable_testcert -enable_iopool -enable_certservice -enable_pwdbased -enable_fastmath -enable_fasthugemath -enable_examples -with_libz -with_cavium -enable_mcapi -enable_jni -enable_jobserver -' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CPP -CXX -CXXFLAGS -CCC -CXXCPP -CCAS -CCASFLAGS' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -ac_unrecognized_opts= -ac_unrecognized_sep= -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *=) ac_optarg= ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=\$ac_optarg ;; - - -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) as_fn_error $? "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information" - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; - esac - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error $? "missing argument to $ac_option" -fi - -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir -do - eval ac_val=\$$ac_var - # Remove trailing slashes. - case $ac_val in - */ ) - ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` - eval $ac_var=\$ac_val;; - esac - # Be sure to have absolute directory names. - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error $? "working directory cannot be determined" -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error $? "pwd does not report name of working directory" - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$as_myself" || -$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_myself" : 'X\(//\)[^/]' \| \ - X"$as_myself" : 'X\(//\)$' \| \ - X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_myself" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures wolfssl 3.6.0 to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking ...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/wolfssl] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF - -Program names: - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM run sed PROGRAM on installed program names - -System types: - --build=BUILD configure for building on BUILD [guessed] - --host=HOST cross-compile to build programs to run on HOST [BUILD] -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of wolfssl 3.6.0:";; - esac - cat <<\_ACEOF - -Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-silent-rules less verbose build output (undo: "make V=1") - --disable-silent-rules verbose build output (undo: "make V=0") - --enable-static[=PKGS] build static libraries [default=no] - --enable-shared[=PKGS] build shared libraries [default=yes] - --enable-fast-install[=PKGS] - optimize for fast installation [default=yes] - --enable-dependency-tracking - do not reject slow dependency extractors - --disable-dependency-tracking - speeds up one-time build - --disable-libtool-lock avoid locking (might break parallel builds) - --enable-debug Add debug code/turns off optimizations (yes|no) - [default=no] - --enable-singlethreaded Enable wolfSSL single threaded (default: disabled) - --enable-dtls Enable wolfSSL DTLS (default: disabled) - --enable-opensslextra Enable extra OpenSSL API, size+ (default: disabled) - --enable-maxstrength Enable Max Strengh build, allows TLSv1.2-AEAD-PFS - ciphers only (default: disabled) - --enable-ipv6 Enable testing of IPV6 (default: disabled) - --enable-fortress Enable SSL fortress build (default: disabled) - --enable-bump Enable SSL Bump build (default: disabled) - --enable-leanpsk Enable Lean PSK build (default: disabled) - --enable-bigcache Enable big session cache (default: disabled) - --enable-hugecache Enable huge session cache (default: disabled) - --enable-smallcache Enable small session cache (default: disabled) - --enable-savesession Enable persistent session cache (default: disabled) - --enable-savecert Enable persistent cert cache (default: disabled) - --enable-atomicuser Enable Atomic User Record Layer (default: disabled) - --enable-pkcallbacks Enable Public Key Callbacks (default: disabled) - --enable-sniffer Enable wolfSSL sniffer support (default: disabled) - --enable-aesgcm Enable wolfSSL AES-GCM support (default: enabled) - --enable-aesccm Enable wolfSSL AES-CCM support (default: disabled) - --enable-aesni Enable wolfSSL AES-NI support (default: disabled) - --enable-intelasm Enable All Intel ASM speedups (default: disabled) - --enable-camellia Enable wolfSSL Camellia support (default: disabled) - --enable-md2 Enable wolfSSL MD2 support (default: disabled) - --enable-nullcipher Enable wolfSSL NULL cipher support (default: disabled) - --enable-ripemd Enable wolfSSL RIPEMD-160 support (default: disabled) - --enable-blake2 Enable wolfSSL BLAKE2 support (default: disabled) - --enable-sha512 Enable wolfSSL SHA-512 support (default: enabled on - x86_64) - --enable-sessioncerts Enable session cert storing (default: disabled) - --enable-keygen Enable key generation (default: disabled) - --enable-certgen Enable cert generation (default: disabled) - --enable-certreq Enable cert request generation (default: disabled) - --enable-sep Enable sep extensions (default: disabled) - --enable-hkdf Enable HKDF (HMAC-KDF) support (default: disabled) - --enable-dsa Enable DSA (default: disabled) - --enable-ecc Enable ECC (default: enabled on x86_64) - --enable-curve25519 Enable Curve25519 (default: disabled) - --enable-ed25519 Enable ED25519 (default: disabled) - --enable-fpecc Enable Fixed Point cache ECC (default: disabled) - --enable-eccencrypt Enable ECC encrypt (default: disabled) - --enable-psk Enable PSK (default: disabled) - --enable-errorstrings Enable error strings table (default: enabled) - --enable-oldtls Enable old TLS versions < 1.2 (default: enabled) - --enable-stacksize Enable stack size info on examples (default: disabled) - --enable-memory Enable memory callbacks (default: enabled) - --enable-rsa Enable RSA (default: enabled) - --enable-dh Enable DH (default: enabled) - --enable-anon Enable Anonymous (default: disabled) - --enable-asn Enable ASN (default: enabled) - --enable-aes Enable AES (default: enabled) - --enable-coding Enable Coding base 16/64 (default: enabled) - --enable-des3 Enable DES3 (default: enabled) - --enable-arc4 Enable ARC4 (default: disabled) - --enable-md5 Enable MD5 (default: enabled) - --enable-sha Enable SHA (default: enabled) - --enable-md4 Enable MD4 (default: disabled) - --enable-webserver Enable Web Server (default: disabled) - --enable-hc128 Enable HC-128 (default: disabled) - --enable-rabbit Enable RABBIT (default: disabled) - --enable-fips Enable FIPS 140-2, Will NOT work w/o FIPS license - (default: disabled) - --enable-poly1305 Enable wolfSSL POLY1305 support (default: enabled) - --enable-chacha Enable CHACHA (default: enabled) - --enable-hashdrbg Enable Hash DRBG support (default: enabled) - --enable-filesystem Enable Filesystem support (default: enabled) - --enable-inline Enable inline functions (default: enabled) - --enable-ocsp Enable OCSP (default: disabled) - --enable-crl Enable CRL (default: disabled) - --enable-crl-monitor Enable CRL Monitor (default: disabled) - --enable-sni Enable SNI (default: disabled) - --enable-maxfragment Enable Maximum Fragment Length (default: disabled) - --enable-truncatedhmac Enable Truncated HMAC (default: disabled) - --enable-renegotiation-indication - Enable Renegotiation Indication (default: disabled) - --enable-secure-renegotiation - Enable Secure Renegotiation (default: disabled) - --enable-supportedcurves - Enable Supported Elliptic Curves (default: disabled) - --enable-session-ticket Enable Session Ticket (default: disabled) - --enable-tlsx Enable all TLS Extensions (default: disabled) - --enable-pkcs7 Enable PKCS7 (default: disabled) - --enable-scep Enable wolfSCEP (default: disabled) - --enable-smallstack Enable Small Stack Usage (default: disabled) - --enable-valgrind Enable valgrind for unit tests (default: disabled) - --enable-testcert Enable Test Cert (default: disabled) - --enable-iopool Enable I/O Pool example (default: disabled) - --enable-certservice Enable cert service (default: disabled) - --enable-pwdbased Enable PWDBASED (default: disabled) - --enable-fastmath Enable fast math ops (default: enabled on x86_64) - --enable-fasthugemath Enable fast math + huge code (default: disabled) - --enable-examples Enable Examples (default: enabled) - --enable-mcapi Enable Microchip API (default: disabled) - --enable-jni Enable wolfSSL JNI (default: disabled) - --enable-jobserver[=no/yes/#] default=yes - Enable up to # make jobs - yes: enable one more than CPU count - - -Optional Packages: - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use - both] - --with-gnu-ld assume the C compiler uses GNU ld [default=no] - --with-sysroot=DIR Search for dependent libraries within DIR - (or the compiler's sysroot if not specified). - --with-ntru=PATH Path to NTRU install (default /usr/) - --with-libz=PATH PATH to libz install (default /usr/) - --with-cavium=PATH PATH to cavium/software dir - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CPP C preprocessor - CXX C++ compiler command - CXXFLAGS C++ compiler flags - CXXCPP C++ preprocessor - CCAS assembler compiler command (defaults to CC) - CCASFLAGS assembler compiler flags (defaults to CFLAGS) - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to . -wolfssl home page: . -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || - { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || - continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -wolfssl configure 3.6.0 -generated by GNU Autoconf 2.69 - -Copyright (C) 2012 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi - -## ------------------------ ## -## Autoconf initialization. ## -## ------------------------ ## - -# ac_fn_c_try_compile LINENO -# -------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_compile - -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link - -# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_c_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_compile - -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_check_func LINENO FUNC VAR -# ---------------------------------- -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_c_check_func () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case declares $2. - For example, HP-UX 11i declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -int -main () -{ -return $2 (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_func - -# ac_fn_cxx_try_compile LINENO -# ---------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_compile - -# ac_fn_cxx_try_cpp LINENO -# ------------------------ -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_cpp - -# ac_fn_cxx_try_link LINENO -# ------------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_link - -# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists, giving a warning if it cannot be compiled using -# the include files in INCLUDES and setting the cache variable VAR -# accordingly. -ac_fn_c_check_header_mongrel () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval \${$3+:} false; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 -$as_echo_n "checking $2 usability... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_header_compiler=yes -else - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 -$as_echo_n "checking $2 presence... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <$2> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - ac_header_preproc=yes -else - ac_header_preproc=no -fi -rm -f conftest.err conftest.i conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( - yes:no: ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; - no:yes:* ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} -( $as_echo "## -------------------------------------------------------- ## -## Report this to https://github.com/wolfssl/wolfssl/issues ## -## -------------------------------------------------------- ##" - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=\$ac_header_compiler" -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_mongrel - -# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES -# -------------------------------------------- -# Tries to find the compile-time value of EXPR in a program that includes -# INCLUDES, setting VAR accordingly. Returns whether the value could be -# computed -ac_fn_c_compute_int () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_lo=0 ac_mid=0 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=$ac_mid; break -else - as_fn_arith $ac_mid + 1 && ac_lo=$as_val - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=-1 ac_mid=-1 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_lo=$ac_mid; break -else - as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - ac_lo= ac_hi= -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=$ac_mid -else - as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in #(( -?*) eval "$3=\$ac_lo"; ac_retval=0 ;; -'') ac_retval=1 ;; -esac - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -static long int longval () { return $2; } -static unsigned long int ulongval () { return $2; } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - return 1; - if (($2) < 0) - { - long int i = longval (); - if (i != ($2)) - return 1; - fprintf (f, "%ld", i); - } - else - { - unsigned long int i = ulongval (); - if (i != ($2)) - return 1; - fprintf (f, "%lu", i); - } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - echo >>conftest.val; read $3 &5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof ($2)) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof (($2))) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - eval "$3=yes" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_type - -# ac_fn_c_find_uintX_t LINENO BITS VAR -# ------------------------------------ -# Finds an unsigned integer type with width BITS, setting cache variable VAR -# accordingly. -ac_fn_c_find_uintX_t () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 -$as_echo_n "checking for uint$2_t... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - # Order is important - never check a type that is potentially smaller - # than half of the expected target width. - for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ - 'unsigned long long int' 'unsigned short int' 'unsigned char'; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - case $ac_type in #( - uint$2_t) : - eval "$3=yes" ;; #( - *) : - eval "$3=\$ac_type" ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if eval test \"x\$"$3"\" = x"no"; then : - -else - break -fi - done -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_find_uintX_t -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by wolfssl $as_me 3.6.0, which was -generated by GNU Autoconf 2.69. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" - done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; - 2) - as_fn_append ac_configure_args1 " '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - as_fn_append ac_configure_args " '$ac_arg'" - ;; - esac - done -done -{ ac_configure_args0=; unset ac_configure_args0;} -{ ac_configure_args1=; unset ac_configure_args1;} - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - $as_echo "## ---------------- ## -## Cache variables. ## -## ---------------- ##" - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - $as_echo "## ----------------- ## -## Output variables. ## -## ----------------- ##" - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - $as_echo "## ------------------- ## -## File substitutions. ## -## ------------------- ##" - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - $as_echo "## ----------- ## -## confdefs.h. ## -## ----------- ##" - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -$as_echo "/* confdefs.h */" > confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_URL "$PACKAGE_URL" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer an explicitly selected file to automatically selected ones. -ac_site_file1=NONE -ac_site_file2=NONE -if test -n "$CONFIG_SITE"; then - # We do not want a PATH search for config.site. - case $CONFIG_SITE in #(( - -*) ac_site_file1=./$CONFIG_SITE;; - */*) ac_site_file1=$CONFIG_SITE;; - *) ac_site_file1=./$CONFIG_SITE;; - esac -elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site -else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site -fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" -do - test "x$ac_site_file" = xNONE && continue - if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" \ - || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special files - # actually), so we avoid doing that. DJGPP emulates it as a regular file. - if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 -fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -ac_aux_dir= -for ac_dir in build-aux "$srcdir"/build-aux; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - as_fn_error $? "cannot find install-sh, install.sh, or shtool in build-aux \"$srcdir\"/build-aux" "$LINENO" 5 -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - - -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` -test "x$ac_build_alias" = x && - as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - - - - -am__api_version='1.14' - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -# Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 -$as_echo_n "checking for a BSD-compatible install... " >&6; } -if test -z "$INSTALL"; then -if ${ac_cv_path_install+:} false; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in #(( - ./ | .// | /[cC]/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - rm -rf conftest.one conftest.two conftest.dir - echo one > conftest.one - echo two > conftest.two - mkdir conftest.dir - if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && - test -s conftest.one && test -s conftest.two && - test -s conftest.dir/conftest.one && - test -s conftest.dir/conftest.two - then - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - fi - done - done - ;; -esac - - done -IFS=$as_save_IFS - -rm -rf conftest.one conftest.two conftest.dir - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. Don't cache a - # value for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - INSTALL=$ac_install_sh - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 -$as_echo "$INSTALL" >&6; } - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 -$as_echo_n "checking whether build environment is sane... " >&6; } -# Reject unsafe characters in $srcdir or the absolute working directory -# name. Accept space and tab only in the latter. -am_lf=' -' -case `pwd` in - *[\\\"\#\$\&\'\`$am_lf]*) - as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; -esac -case $srcdir in - *[\\\"\#\$\&\'\`$am_lf\ \ ]*) - as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; -esac - -# Do 'set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - as_fn_error $? "ls -t appears to fail. Make sure there is not a broken - alias in your environment" "$LINENO" 5 - fi - if test "$2" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done - test "$2" = conftest.file - ) -then - # Ok. - : -else - as_fn_error $? "newly created file is older than distributed files! -Check your system clock" "$LINENO" 5 -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! -fi - -rm -f conftest.file - -test "$program_prefix" != NONE && - program_transform_name="s&^&$program_prefix&;$program_transform_name" -# Use a double $ so make ignores it. -test "$program_suffix" != NONE && - program_transform_name="s&\$&$program_suffix&;$program_transform_name" -# Double any \ or $. -# By default was `s,x,x', remove it if useless. -ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' -program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` - -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` - -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac -fi -# Use eval to expand $SHELL -if eval "$MISSING --is-lightweight"; then - am_missing_run="$MISSING " -else - am_missing_run= - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 -$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} -fi - -if test x"${install_sh}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; - *) - install_sh="\${SHELL} $am_aux_dir/install-sh" - esac -fi - -# Installed binaries are usually stripped using 'strip' when the user -# run "make install-strip". However 'strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the 'STRIP' environment variable to overrule this program. -if test "$cross_compiling" != no; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 -$as_echo "$STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 -$as_echo "$ac_ct_STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_STRIP" = x; then - STRIP=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - STRIP=$ac_ct_STRIP - fi -else - STRIP="$ac_cv_prog_STRIP" -fi - -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 -$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } -if test -z "$MKDIR_P"; then - if ${ac_cv_path_mkdir+:} false; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in mkdir gmkdir; do - for ac_exec_ext in '' $ac_executable_extensions; do - as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue - case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( - 'mkdir (GNU coreutils) '* | \ - 'mkdir (coreutils) '* | \ - 'mkdir (fileutils) '4.1*) - ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext - break 3;; - esac - done - done - done -IFS=$as_save_IFS - -fi - - test -d ./--version && rmdir ./--version - if test "${ac_cv_path_mkdir+set}" = set; then - MKDIR_P="$ac_cv_path_mkdir -p" - else - # As a last resort, use the slow shell script. Don't cache a - # value for MKDIR_P within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - MKDIR_P="$ac_install_sh -d" - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 -$as_echo "$MKDIR_P" >&6; } - -for ac_prog in gawk mawk nawk awk -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AWK+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AWK="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AWK=$ac_cv_prog_AWK -if test -n "$AWK"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 -$as_echo "$AWK" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$AWK" && break -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SET_MAKE= -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - -rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null - -# Check whether --enable-silent-rules was given. -if test "${enable_silent_rules+set}" = set; then : - enableval=$enable_silent_rules; -fi - -case $enable_silent_rules in # ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=1;; -esac -am_make=${MAKE-make} -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 -$as_echo_n "checking whether $am_make supports nested variables... " >&6; } -if ${am_cv_make_support_nested_variables+:} false; then : - $as_echo_n "(cached) " >&6 -else - if $as_echo 'TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 -$as_echo "$am_cv_make_support_nested_variables" >&6; } -if test $am_cv_make_support_nested_variables = yes; then - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AM_BACKSLASH='\' - -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - am__isrc=' -I$(srcdir)' - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi - - -# Define the identity of the package. - PACKAGE='wolfssl' - VERSION='3.6.0' - - -# Some tools Automake needs. - -ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} - - -AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} - - -AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} - - -AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} - - -MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} - -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -mkdir_p='$(MKDIR_P)' - -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -# Always define AMTAR for backward compatibility. Yes, it's still used -# in the wild :-( We should find a proper way to deprecate it ... -AMTAR='$${TAR-tar}' - - -# We'll loop over all known methods to create a tar archive until one works. -_am_tools='gnutar plaintar pax cpio none' - -# The POSIX 1988 'ustar' format is defined with fixed-size fields. - # There is notably a 21 bits limit for the UID and the GID. In fact, - # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 - # and bug#13588). - am_max_uid=2097151 # 2^21 - 1 - am_max_gid=$am_max_uid - # The $UID and $GID variables are not portable, so we need to resort - # to the POSIX-mandated id(1) utility. Errors in the 'id' calls - # below are definitely unexpected, so allow the users to see them - # (that is, avoid stderr redirection). - am_uid=`id -u || echo unknown` - am_gid=`id -g || echo unknown` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether UID '$am_uid' is supported by ustar format" >&5 -$as_echo_n "checking whether UID '$am_uid' is supported by ustar format... " >&6; } - if test $am_uid -le $am_max_uid; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - _am_tools=none - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether GID '$am_gid' is supported by ustar format" >&5 -$as_echo_n "checking whether GID '$am_gid' is supported by ustar format... " >&6; } - if test $am_gid -le $am_max_gid; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - _am_tools=none - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to create a ustar tar archive" >&5 -$as_echo_n "checking how to create a ustar tar archive... " >&6; } - - # Go ahead even if we have the value already cached. We do so because we - # need to set the values for the 'am__tar' and 'am__untar' variables. - _am_tools=${am_cv_prog_tar_ustar-$_am_tools} - - for _am_tool in $_am_tools; do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; do - { echo "$as_me:$LINENO: $_am_tar --version" >&5 - ($_am_tar --version) >&5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && break - done - am__tar="$_am_tar --format=ustar -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=ustar -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x ustar -w "$$tardir"' - am__tar_='pax -L -x ustar -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H ustar -L' - am__tar_='find "$tardir" -print | cpio -o -H ustar -L' - am__untar='cpio -i -H ustar -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_ustar}" && break - - # tar/untar a dummy directory, and stop if the command works. - rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - { echo "$as_me:$LINENO: tardir=conftest.dir && eval $am__tar_ >conftest.tar" >&5 - (tardir=conftest.dir && eval $am__tar_ >conftest.tar) >&5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - rm -rf conftest.dir - if test -s conftest.tar; then - { echo "$as_me:$LINENO: $am__untar &5 - ($am__untar &5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - { echo "$as_me:$LINENO: cat conftest.dir/file" >&5 - (cat conftest.dir/file) >&5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - grep GrepMe conftest.dir/file >/dev/null 2>&1 && break - fi - done - rm -rf conftest.dir - - if ${am_cv_prog_tar_ustar+:} false; then : - $as_echo_n "(cached) " >&6 -else - am_cv_prog_tar_ustar=$_am_tool -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_tar_ustar" >&5 -$as_echo "$am_cv_prog_tar_ustar" >&6; } - - - - - - -# POSIX will say in a future version that running "rm -f" with no argument -# is OK; and we want to be able to make that assumption in our Makefile -# recipes. So use an aggressive probe to check that the usage we want is -# actually supported "in the wild" to an acceptable degree. -# See automake bug#10828. -# To make any issue more visible, cause the running configure to be aborted -# by default if the 'rm' program in use doesn't match our expectations; the -# user can still override this though. -if rm -f && rm -fr && rm -rf; then : OK; else - cat >&2 <<'END' -Oops! - -Your 'rm' program seems unable to run without file operands specified -on the command line, even when the '-f' option is present. This is contrary -to the behaviour of most rm programs out there, and not conforming with -the upcoming POSIX standard: - -Please tell bug-automake@gnu.org about your system, including the value -of your $PATH and any error possibly output before this message. This -can help us improve future automake versions. - -END - if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then - echo 'Configuration will proceed anyway, since you have set the' >&2 - echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 - echo >&2 - else - cat >&2 <<'END' -Aborting the configuration process, to ensure you take notice of the issue. - -You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . - -If you want to complete the configuration process using your problematic -'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM -to "yes", and re-run configure. - -END - as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 - fi -fi - - - - -#PROTECT_AC_USE_SYSTEM_EXTENSIONS - - - -ac_config_headers="$ac_config_headers config.h:config.in" - -#shared library versioning -WOLFSSL_LIBRARY_VERSION=0:2:0 -# | | | -# +------+ | +---+ -# | | | -# current:revision:age -# | | | -# | | +- increment if interfaces have been added -# | | set to zero if interfaces have been removed -# | | or changed -# | +- increment if source code has changed -# | set to zero if current is incremented -# +- increment if interfaces have been added, removed or changed - - -# capture user C_EXTRA_FLAGS from ./configure line, CFLAGS may hold -g -O2 even -# if user doesn't override, no way to tell -USER_C_EXTRA_FLAGS="$C_EXTRA_FLAGS" - - -case `pwd` in - *\ * | *\ *) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 -$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; -esac - - - -macro_version='2.4.2' -macro_revision='1.3337' - - - - - - - - - - - - - -ltmain="$ac_aux_dir/ltmain.sh" - -# Backslashify metacharacters that are still active within -# double-quoted strings. -sed_quote_subst='s/\(["`$\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\(["`\\]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 -$as_echo_n "checking how to print strings... " >&6; } -# Test print first, because it will be a builtin if present. -if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ - test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='print -r --' -elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='printf %s\n' -else - # Use this function as a fallback that always works. - func_fallback_echo () - { - eval 'cat <<_LTECHO_EOF -$1 -_LTECHO_EOF' - } - ECHO='func_fallback_echo' -fi - -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "" -} - -case "$ECHO" in - printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 -$as_echo "printf" >&6; } ;; - print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 -$as_echo "print -r" >&6; } ;; - *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 -$as_echo "cat" >&6; } ;; -esac - - - - - - - - - - - - - - -DEPDIR="${am__leading_dot}deps" - -ac_config_commands="$ac_config_commands depfiles" - - -am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo this is the am__doit target -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 -$as_echo_n "checking for style of include used by $am_make... " >&6; } -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 -$as_echo "$_am_result" >&6; } -rm -f confinc confmf - -# Check whether --enable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then : - enableval=$enable_dependency_tracking; -fi - -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' - am__nodep='_no' -fi - if test "x$enable_dependency_tracking" != xno; then - AMDEP_TRUE= - AMDEP_FALSE='#' -else - AMDEP_TRUE='#' - AMDEP_FALSE= -fi - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 -$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } -if ${am_cv_prog_cc_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF - # Make sure it works both with $CC and with simple cc. - # Following AC_PROG_CC_C_O, we do the test twice because some - # compilers refuse to overwrite an existing .o file with -o, - # though they will create one. - am_cv_prog_cc_c_o=yes - for am_i in 1 2; do - if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 - ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } \ - && test -f conftest2.$ac_objext; then - : OK - else - am_cv_prog_cc_c_o=no - break - fi - done - rm -f core conftest* - unset am_i -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 -$as_echo "$am_cv_prog_cc_c_o" >&6; } -if test "$am_cv_prog_cc_c_o" != yes; then - # Losing compiler, so override with the script. - # FIXME: It is wrong to rewrite CC. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__CC in this case, - # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" - CC="$am_aux_dir/compile $CC" -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -depcc="$CC" am_compiler_list= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if ${am_cv_CC_dependencies_compiler_type+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CC_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - am__universal=false - case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with '-c' and '-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CC_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CC_dependencies_compiler_type=none -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } -CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then - am__fastdepCC_TRUE= - am__fastdepCC_FALSE='#' -else - am__fastdepCC_TRUE='#' - am__fastdepCC_FALSE= -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 -$as_echo_n "checking for a sed that does not truncate output... " >&6; } -if ${ac_cv_path_SED+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ - for ac_i in 1 2 3 4 5 6 7; do - ac_script="$ac_script$as_nl$ac_script" - done - echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed - { ac_script=; unset ac_script;} - if test -z "$SED"; then - ac_path_SED_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_SED" || continue -# Check for GNU ac_path_SED and select it if it is found. - # Check for GNU $ac_path_SED -case `"$ac_path_SED" --version 2>&1` in -*GNU*) - ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo '' >> "conftest.nl" - "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_SED_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_SED="$ac_path_SED" - ac_path_SED_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_SED_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_SED"; then - as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 - fi -else - ac_cv_path_SED=$SED -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 -$as_echo "$ac_cv_path_SED" >&6; } - SED="$ac_cv_path_SED" - rm -f conftest.sed - -test -z "$SED" && SED=sed -Xsed="$SED -e 1s/^X//" - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 -$as_echo_n "checking for fgrep... " >&6; } -if ${ac_cv_path_FGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 - then ac_cv_path_FGREP="$GREP -F" - else - if test -z "$FGREP"; then - ac_path_FGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in fgrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_FGREP" || continue -# Check for GNU ac_path_FGREP and select it if it is found. - # Check for GNU $ac_path_FGREP -case `"$ac_path_FGREP" --version 2>&1` in -*GNU*) - ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'FGREP' >> "conftest.nl" - "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_FGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_FGREP="$ac_path_FGREP" - ac_path_FGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_FGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_FGREP"; then - as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_FGREP=$FGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 -$as_echo "$ac_cv_path_FGREP" >&6; } - FGREP="$ac_cv_path_FGREP" - - -test -z "$GREP" && GREP=grep - - - - - - - - - - - - - - - - - - - -# Check whether --with-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then : - withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes -else - with_gnu_ld=no -fi - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 -$as_echo_n "checking for ld used by $CC... " >&6; } - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [\\/]* | ?:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` - while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do - ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 -$as_echo_n "checking for GNU ld... " >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 -$as_echo_n "checking for non-GNU ld... " >&6; } -fi -if ${lt_cv_path_LD+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &5 -$as_echo "$LD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi -test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 -$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } -if ${lt_cv_prog_gnu_ld+:} false; then : - $as_echo_n "(cached) " >&6 -else - # I'd rather use --version here, but apparently some GNU lds only accept -v. -case `$LD -v 2>&1 &5 -$as_echo "$lt_cv_prog_gnu_ld" >&6; } -with_gnu_ld=$lt_cv_prog_gnu_ld - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 -$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } -if ${lt_cv_path_NM+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_nm_to_check="${ac_tool_prefix}nm" - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then - lt_nm_to_check="$lt_nm_to_check nm" - fi - for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break - ;; - *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in - */dev/null*) - lt_cv_path_NM="$tmp_nm -p" - break - ;; - *) - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - ;; - esac - ;; - esac - fi - done - IFS="$lt_save_ifs" - done - : ${lt_cv_path_NM=no} -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 -$as_echo "$lt_cv_path_NM" >&6; } -if test "$lt_cv_path_NM" != "no"; then - NM="$lt_cv_path_NM" -else - # Didn't find any BSD compatible name lister, look for dumpbin. - if test -n "$DUMPBIN"; then : - # Let the user override the test. - else - if test -n "$ac_tool_prefix"; then - for ac_prog in dumpbin "link -dump" - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DUMPBIN+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DUMPBIN"; then - ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -DUMPBIN=$ac_cv_prog_DUMPBIN -if test -n "$DUMPBIN"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 -$as_echo "$DUMPBIN" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$DUMPBIN" && break - done -fi -if test -z "$DUMPBIN"; then - ac_ct_DUMPBIN=$DUMPBIN - for ac_prog in dumpbin "link -dump" -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DUMPBIN"; then - ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN -if test -n "$ac_ct_DUMPBIN"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 -$as_echo "$ac_ct_DUMPBIN" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_DUMPBIN" && break -done - - if test "x$ac_ct_DUMPBIN" = x; then - DUMPBIN=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DUMPBIN=$ac_ct_DUMPBIN - fi -fi - - case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in - *COFF*) - DUMPBIN="$DUMPBIN -symbols" - ;; - *) - DUMPBIN=: - ;; - esac - fi - - if test "$DUMPBIN" != ":"; then - NM="$DUMPBIN" - fi -fi -test -z "$NM" && NM=nm - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 -$as_echo_n "checking the name lister ($NM) interface... " >&6; } -if ${lt_cv_nm_interface+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_nm_interface="BSD nm" - echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&5 - (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) - cat conftest.err >&5 - (eval echo "\"\$as_me:$LINENO: output\"" >&5) - cat conftest.out >&5 - if $GREP 'External.*some_variable' conftest.out > /dev/null; then - lt_cv_nm_interface="MS dumpbin" - fi - rm -f conftest* -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 -$as_echo "$lt_cv_nm_interface" >&6; } - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 -$as_echo_n "checking whether ln -s works... " >&6; } -LN_S=$as_ln_s -if test "$LN_S" = "ln -s"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 -$as_echo "no, using $LN_S" >&6; } -fi - -# find the maximum length of command line arguments -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 -$as_echo_n "checking the maximum length of command line arguments... " >&6; } -if ${lt_cv_sys_max_cmd_len+:} false; then : - $as_echo_n "(cached) " >&6 -else - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw* | cegcc*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - mint*) - # On MiNT this can take a long time and run out of memory. - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - os2*) - # The test takes a long time on OS/2. - lt_cv_sys_max_cmd_len=8192 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - else - # Make teststring a little bigger before we do anything with it. - # a 1K string should be a reasonable start. - for i in 1 2 3 4 5 6 7 8 ; do - teststring=$teststring$teststring - done - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ - = "X$teststring$teststring"; } >/dev/null 2>&1 && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - # Only check the string length outside the loop. - lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` - teststring= - # Add a significant safety factor because C++ compilers can tack on - # massive amounts of additional arguments before passing them to the - # linker. It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - fi - ;; - esac - -fi - -if test -n $lt_cv_sys_max_cmd_len ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 -$as_echo "$lt_cv_sys_max_cmd_len" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 -$as_echo "none" >&6; } -fi -max_cmd_len=$lt_cv_sys_max_cmd_len - - - - - - -: ${CP="cp -f"} -: ${MV="mv -f"} -: ${RM="rm -f"} - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 -$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } -# Try some XSI features -xsi_shell=no -( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,b/c, \ - && eval 'test $(( 1 + 1 )) -eq 2 \ - && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ - && xsi_shell=yes -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 -$as_echo "$xsi_shell" >&6; } - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 -$as_echo_n "checking whether the shell understands \"+=\"... " >&6; } -lt_shell_append=no -( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ - >/dev/null 2>&1 \ - && lt_shell_append=yes -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 -$as_echo "$lt_shell_append" >&6; } - - -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - lt_unset=unset -else - lt_unset=false -fi - - - - - -# test EBCDIC or ASCII -case `echo X|tr X '\101'` in - A) # ASCII based system - # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr - lt_SP2NL='tr \040 \012' - lt_NL2SP='tr \015\012 \040\040' - ;; - *) # EBCDIC based system - lt_SP2NL='tr \100 \n' - lt_NL2SP='tr \r\n \100\100' - ;; -esac - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 -$as_echo_n "checking how to convert $build file names to $host format... " >&6; } -if ${lt_cv_to_host_file_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 - ;; - esac - ;; - *-*-cygwin* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin - ;; - esac - ;; - * ) # unhandled hosts (and "normal" native builds) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; -esac - -fi - -to_host_file_cmd=$lt_cv_to_host_file_cmd -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 -$as_echo "$lt_cv_to_host_file_cmd" >&6; } - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 -$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } -if ${lt_cv_to_tool_file_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else - #assume ordinary cross tools, or native build. -lt_cv_to_tool_file_cmd=func_convert_file_noop -case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 - ;; - esac - ;; -esac - -fi - -to_tool_file_cmd=$lt_cv_to_tool_file_cmd -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 -$as_echo "$lt_cv_to_tool_file_cmd" >&6; } - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 -$as_echo_n "checking for $LD option to reload object files... " >&6; } -if ${lt_cv_ld_reload_flag+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ld_reload_flag='-r' -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 -$as_echo "$lt_cv_ld_reload_flag" >&6; } -reload_flag=$lt_cv_ld_reload_flag -case $reload_flag in -"" | " "*) ;; -*) reload_flag=" $reload_flag" ;; -esac -reload_cmds='$LD$reload_flag -o $output$reload_objs' -case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - if test "$GCC" != yes; then - reload_cmds=false - fi - ;; - darwin*) - if test "$GCC" = yes; then - reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' - else - reload_cmds='$LD$reload_flag -o $output$reload_objs' - fi - ;; -esac - - - - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. -set dummy ${ac_tool_prefix}objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJDUMP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OBJDUMP"; then - ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OBJDUMP=$ac_cv_prog_OBJDUMP -if test -n "$OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 -$as_echo "$OBJDUMP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OBJDUMP"; then - ac_ct_OBJDUMP=$OBJDUMP - # Extract the first word of "objdump", so it can be a program name with args. -set dummy objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OBJDUMP"; then - ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OBJDUMP="objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP -if test -n "$ac_ct_OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 -$as_echo "$ac_ct_OBJDUMP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OBJDUMP" = x; then - OBJDUMP="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OBJDUMP=$ac_ct_OBJDUMP - fi -else - OBJDUMP="$ac_cv_prog_OBJDUMP" -fi - -test -z "$OBJDUMP" && OBJDUMP=objdump - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 -$as_echo_n "checking how to recognize dependent libraries... " >&6; } -if ${lt_cv_deplibs_check_method+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_file_magic_cmd='$MAGIC_CMD' -lt_cv_file_magic_test_file= -lt_cv_deplibs_check_method='unknown' -# Need to set the preceding variable on all platforms that support -# interlibrary dependencies. -# 'none' -- dependencies not supported. -# `unknown' -- same as none, but documents that we really don't know. -# 'pass_all' -- all dependencies passed with no checks. -# 'test_compile' -- check by making test program. -# 'file_magic [[regex]]' -- check by looking for files in library path -# which responds to the $file_magic_cmd with a given extended regex. -# If you have `file' or equivalent on your system and you're not sure -# whether `pass_all' will *always* work, you probably want this one. - -case $host_os in -aix[4-9]*) - lt_cv_deplibs_check_method=pass_all - ;; - -beos*) - lt_cv_deplibs_check_method=pass_all - ;; - -bsdi[45]*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' - lt_cv_file_magic_cmd='/usr/bin/file -L' - lt_cv_file_magic_test_file=/shlib/libc.so - ;; - -cygwin*) - # func_win32_libid is a shell function defined in ltmain.sh - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - ;; - -mingw* | pw32*) - # Base MSYS/MinGW do not provide the 'file' command needed by - # func_win32_libid shell function, so use a weaker test based on 'objdump', - # unless we find 'file', for example because we are cross-compiling. - # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. - if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - else - # Keep this pattern in sync with the one in func_win32_libid. - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' - lt_cv_file_magic_cmd='$OBJDUMP -f' - fi - ;; - -cegcc*) - # use the weaker test based on 'objdump'. See mingw*. - lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method=pass_all - ;; - -freebsd* | dragonfly*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -haiku*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file - case $host_cpu in - ia64*) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so - ;; - hppa*64*) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac - ;; - -interix[3-9]*) - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' - ;; - -irix5* | irix6* | nonstopux*) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -*nto* | *qnx*) - lt_cv_deplibs_check_method=pass_all - ;; - -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -rdos*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.3*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - siemens) - lt_cv_deplibs_check_method=pass_all - ;; - pc) - lt_cv_deplibs_check_method=pass_all - ;; - esac - ;; - -tpf*) - lt_cv_deplibs_check_method=pass_all - ;; -esac - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 -$as_echo "$lt_cv_deplibs_check_method" >&6; } - -file_magic_glob= -want_nocaseglob=no -if test "$build" = "$host"; then - case $host_os in - mingw* | pw32*) - if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then - want_nocaseglob=yes - else - file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` - fi - ;; - esac -fi - -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -test -z "$deplibs_check_method" && deplibs_check_method=unknown - - - - - - - - - - - - - - - - - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. -set dummy ${ac_tool_prefix}dlltool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DLLTOOL"; then - ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -DLLTOOL=$ac_cv_prog_DLLTOOL -if test -n "$DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 -$as_echo "$DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_DLLTOOL"; then - ac_ct_DLLTOOL=$DLLTOOL - # Extract the first word of "dlltool", so it can be a program name with args. -set dummy dlltool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DLLTOOL"; then - ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_DLLTOOL="dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL -if test -n "$ac_ct_DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 -$as_echo "$ac_ct_DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_DLLTOOL" = x; then - DLLTOOL="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DLLTOOL=$ac_ct_DLLTOOL - fi -else - DLLTOOL="$ac_cv_prog_DLLTOOL" -fi - -test -z "$DLLTOOL" && DLLTOOL=dlltool - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 -$as_echo_n "checking how to associate runtime and link libraries... " >&6; } -if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_sharedlib_from_linklib_cmd='unknown' - -case $host_os in -cygwin* | mingw* | pw32* | cegcc*) - # two different shell functions defined in ltmain.sh - # decide which to use based on capabilities of $DLLTOOL - case `$DLLTOOL --help 2>&1` in - *--identify-strict*) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib - ;; - *) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback - ;; - esac - ;; -*) - # fallback: assume linklib IS sharedlib - lt_cv_sharedlib_from_linklib_cmd="$ECHO" - ;; -esac - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 -$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } -sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd -test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO - - - - - - - - -if test -n "$ac_tool_prefix"; then - for ac_prog in ar - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AR="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AR=$ac_cv_prog_AR -if test -n "$AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 -$as_echo "$AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$AR" && break - done -fi -if test -z "$AR"; then - ac_ct_AR=$AR - for ac_prog in ar -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AR"; then - ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_AR="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_AR=$ac_cv_prog_ac_ct_AR -if test -n "$ac_ct_AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 -$as_echo "$ac_ct_AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_AR" && break -done - - if test "x$ac_ct_AR" = x; then - AR="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - AR=$ac_ct_AR - fi -fi - -: ${AR=ar} -: ${AR_FLAGS=cru} - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 -$as_echo_n "checking for archiver @FILE support... " >&6; } -if ${lt_cv_ar_at_file+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ar_at_file=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - echo conftest.$ac_objext > conftest.lst - lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 - (eval $lt_ar_try) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if test "$ac_status" -eq 0; then - # Ensure the archiver fails upon bogus file names. - rm -f conftest.$ac_objext libconftest.a - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 - (eval $lt_ar_try) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if test "$ac_status" -ne 0; then - lt_cv_ar_at_file=@ - fi - fi - rm -f conftest.* libconftest.a - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 -$as_echo "$lt_cv_ar_at_file" >&6; } - -if test "x$lt_cv_ar_at_file" = xno; then - archiver_list_spec= -else - archiver_list_spec=$lt_cv_ar_at_file -fi - - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 -$as_echo "$STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 -$as_echo "$ac_ct_STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_STRIP" = x; then - STRIP=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - STRIP=$ac_ct_STRIP - fi -else - STRIP="$ac_cv_prog_STRIP" -fi - -test -z "$STRIP" && STRIP=: - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_RANLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -RANLIB=$ac_cv_prog_RANLIB -if test -n "$RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 -$as_echo "$RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_RANLIB"; then - ac_ct_RANLIB=$RANLIB - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_RANLIB"; then - ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_RANLIB="ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -if test -n "$ac_ct_RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 -$as_echo "$ac_ct_RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_RANLIB" = x; then - RANLIB=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - RANLIB=$ac_ct_RANLIB - fi -else - RANLIB="$ac_cv_prog_RANLIB" -fi - -test -z "$RANLIB" && RANLIB=: - - - - - - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" -fi - -case $host_os in - darwin*) - lock_old_archive_extraction=yes ;; - *) - lock_old_archive_extraction=no ;; -esac - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# Check for command to grab the raw symbol name followed by C symbol from nm. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 -$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } -if ${lt_cv_sys_global_symbol_pipe+:} false; then : - $as_echo_n "(cached) " >&6 -else - -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[BCDEGRST]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([_A-Za-z][_A-Za-z0-9]*\)' - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[BCDT]' - ;; -cygwin* | mingw* | pw32* | cegcc*) - symcode='[ABCDGISTW]' - ;; -hpux*) - if test "$host_cpu" = ia64; then - symcode='[ABCDEGRST]' - fi - ;; -irix* | nonstopux*) - symcode='[BCDEGRST]' - ;; -osf*) - symcode='[BCDEGQRST]' - ;; -solaris*) - symcode='[BDRT]' - ;; -sco3.2v5*) - symcode='[DT]' - ;; -sysv4.2uw2*) - symcode='[DT]' - ;; -sysv5* | sco5v6* | unixware* | OpenUNIX*) - symcode='[ABDT]' - ;; -sysv4) - symcode='[DFNSTU]' - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[ABCDGIRSTW]' ;; -esac - -# Transform an extracted symbol line into a proper C declaration. -# Some systems (esp. on ia64) link data and code symbols differently, -# so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" - -# Handle CRLF in mingw tool chain -opt_cr= -case $build_os in -mingw*) - opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# Try without a prefix underscore, then with it. -for ac_symprfx in "" "_"; do - - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. - symxfrm="\\1 $ac_symprfx\\2 \\2" - - # Write the raw and C identifiers. - if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Fake it for dumpbin and say T for any non-static function - # and D for any global variable. - # Also find C++ and __fastcall symbols from MSVC++, - # which start with @ or ?. - lt_cv_sys_global_symbol_pipe="$AWK '"\ -" {last_section=section; section=\$ 3};"\ -" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ -" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ -" \$ 0!~/External *\|/{next};"\ -" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ -" {if(hide[section]) next};"\ -" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ -" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ -" s[1]~/^[@?]/{print s[1], s[1]; next};"\ -" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ -" ' prfx=^$ac_symprfx" - else - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - fi - lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext <<_LT_EOF -#ifdef __cplusplus -extern "C" { -#endif -char nm_test_var; -void nm_test_func(void); -void nm_test_func(void){} -#ifdef __cplusplus -} -#endif -int main(){nm_test_var='a';nm_test_func();return(0);} -_LT_EOF - - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - # Now try to grab the symbols. - nlist=conftest.nm - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 - (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if $GREP ' nm_test_var$' "$nlist" >/dev/null; then - if $GREP ' nm_test_func$' "$nlist" >/dev/null; then - cat <<_LT_EOF > conftest.$ac_ext -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT_DLSYM_CONST -#else -# define LT_DLSYM_CONST const -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -_LT_EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' - - cat <<_LT_EOF >> conftest.$ac_ext - -/* The mapping between symbol names and symbols. */ -LT_DLSYM_CONST struct { - const char *name; - void *address; -} -lt__PROGRAM__LTX_preloaded_symbols[] = -{ - { "@PROGRAM@", (void *) 0 }, -_LT_EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext - cat <<\_LT_EOF >> conftest.$ac_ext - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt__PROGRAM__LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif -_LT_EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - lt_globsym_save_LIBS=$LIBS - lt_globsym_save_CFLAGS=$CFLAGS - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 - (eval $ac_link) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext}; then - pipe_works=yes - fi - LIBS=$lt_globsym_save_LIBS - CFLAGS=$lt_globsym_save_CFLAGS - else - echo "cannot find nm_test_func in $nlist" >&5 - fi - else - echo "cannot find nm_test_var in $nlist" >&5 - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 - fi - else - echo "$progname: failed program was:" >&5 - cat conftest.$ac_ext >&5 - fi - rm -rf conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done - -fi - -if test -z "$lt_cv_sys_global_symbol_pipe"; then - lt_cv_sys_global_symbol_to_cdecl= -fi -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 -$as_echo "failed" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; } -fi - -# Response file support. -if test "$lt_cv_nm_interface" = "MS dumpbin"; then - nm_file_list_spec='@' -elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then - nm_file_list_spec='@' -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 -$as_echo_n "checking for sysroot... " >&6; } - -# Check whether --with-sysroot was given. -if test "${with_sysroot+set}" = set; then : - withval=$with_sysroot; -else - with_sysroot=no -fi - - -lt_sysroot= -case ${with_sysroot} in #( - yes) - if test "$GCC" = yes; then - lt_sysroot=`$CC --print-sysroot 2>/dev/null` - fi - ;; #( - /*) - lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` - ;; #( - no|'') - ;; #( - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 -$as_echo "${with_sysroot}" >&6; } - as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 - ;; -esac - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 -$as_echo "${lt_sysroot:-no}" >&6; } - - - - - -# Check whether --enable-libtool-lock was given. -if test "${enable_libtool_lock+set}" = set; then : - enableval=$enable_libtool_lock; -fi - -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '#line '$LINENO' "configure"' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_i386_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_x86_64_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - ppc*-*linux*|powerpc*-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*|s390*-*tpf*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 -$as_echo_n "checking whether the C compiler needs -belf... " >&6; } -if ${lt_cv_cc_needs_belf+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - lt_cv_cc_needs_belf=yes -else - lt_cv_cc_needs_belf=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 -$as_echo "$lt_cv_cc_needs_belf" >&6; } - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -*-*solaris*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) - case $host in - i?86-*-solaris*) - LD="${LD-ld} -m elf_x86_64" - ;; - sparc*-*-solaris*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - # GNU ld 2.21 introduced _sol2 emulations. Use them if available. - if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then - LD="${LD-ld}_sol2" - fi - ;; - *) - if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then - LD="${LD-ld} -64" - fi - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; -esac - -need_locks="$enable_libtool_lock" - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. -set dummy ${ac_tool_prefix}mt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$MANIFEST_TOOL"; then - ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL -if test -n "$MANIFEST_TOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 -$as_echo "$MANIFEST_TOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_MANIFEST_TOOL"; then - ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL - # Extract the first word of "mt", so it can be a program name with args. -set dummy mt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_MANIFEST_TOOL"; then - ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL -if test -n "$ac_ct_MANIFEST_TOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 -$as_echo "$ac_ct_MANIFEST_TOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_MANIFEST_TOOL" = x; then - MANIFEST_TOOL=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL - fi -else - MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" -fi - -test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 -$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } -if ${lt_cv_path_mainfest_tool+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_path_mainfest_tool=no - echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 - $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out - cat conftest.err >&5 - if $GREP 'Manifest Tool' conftest.out > /dev/null; then - lt_cv_path_mainfest_tool=yes - fi - rm -f conftest* -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 -$as_echo "$lt_cv_path_mainfest_tool" >&6; } -if test "x$lt_cv_path_mainfest_tool" != xyes; then - MANIFEST_TOOL=: -fi - - - - - - - case $host_os in - rhapsody* | darwin*) - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. -set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DSYMUTIL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DSYMUTIL"; then - ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -DSYMUTIL=$ac_cv_prog_DSYMUTIL -if test -n "$DSYMUTIL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 -$as_echo "$DSYMUTIL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_DSYMUTIL"; then - ac_ct_DSYMUTIL=$DSYMUTIL - # Extract the first word of "dsymutil", so it can be a program name with args. -set dummy dsymutil; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DSYMUTIL"; then - ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL -if test -n "$ac_ct_DSYMUTIL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 -$as_echo "$ac_ct_DSYMUTIL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_DSYMUTIL" = x; then - DSYMUTIL=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DSYMUTIL=$ac_ct_DSYMUTIL - fi -else - DSYMUTIL="$ac_cv_prog_DSYMUTIL" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. -set dummy ${ac_tool_prefix}nmedit; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_NMEDIT+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$NMEDIT"; then - ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -NMEDIT=$ac_cv_prog_NMEDIT -if test -n "$NMEDIT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 -$as_echo "$NMEDIT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_NMEDIT"; then - ac_ct_NMEDIT=$NMEDIT - # Extract the first word of "nmedit", so it can be a program name with args. -set dummy nmedit; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_NMEDIT"; then - ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_NMEDIT="nmedit" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT -if test -n "$ac_ct_NMEDIT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 -$as_echo "$ac_ct_NMEDIT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_NMEDIT" = x; then - NMEDIT=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - NMEDIT=$ac_ct_NMEDIT - fi -else - NMEDIT="$ac_cv_prog_NMEDIT" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. -set dummy ${ac_tool_prefix}lipo; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_LIPO+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$LIPO"; then - ac_cv_prog_LIPO="$LIPO" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_LIPO="${ac_tool_prefix}lipo" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -LIPO=$ac_cv_prog_LIPO -if test -n "$LIPO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 -$as_echo "$LIPO" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_LIPO"; then - ac_ct_LIPO=$LIPO - # Extract the first word of "lipo", so it can be a program name with args. -set dummy lipo; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_LIPO+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_LIPO"; then - ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_LIPO="lipo" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO -if test -n "$ac_ct_LIPO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 -$as_echo "$ac_ct_LIPO" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_LIPO" = x; then - LIPO=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - LIPO=$ac_ct_LIPO - fi -else - LIPO="$ac_cv_prog_LIPO" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. -set dummy ${ac_tool_prefix}otool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OTOOL"; then - ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OTOOL="${ac_tool_prefix}otool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OTOOL=$ac_cv_prog_OTOOL -if test -n "$OTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 -$as_echo "$OTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OTOOL"; then - ac_ct_OTOOL=$OTOOL - # Extract the first word of "otool", so it can be a program name with args. -set dummy otool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OTOOL"; then - ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OTOOL="otool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL -if test -n "$ac_ct_OTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 -$as_echo "$ac_ct_OTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OTOOL" = x; then - OTOOL=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OTOOL=$ac_ct_OTOOL - fi -else - OTOOL="$ac_cv_prog_OTOOL" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. -set dummy ${ac_tool_prefix}otool64; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OTOOL64+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OTOOL64"; then - ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OTOOL64=$ac_cv_prog_OTOOL64 -if test -n "$OTOOL64"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 -$as_echo "$OTOOL64" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OTOOL64"; then - ac_ct_OTOOL64=$OTOOL64 - # Extract the first word of "otool64", so it can be a program name with args. -set dummy otool64; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OTOOL64"; then - ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OTOOL64="otool64" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 -if test -n "$ac_ct_OTOOL64"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 -$as_echo "$ac_ct_OTOOL64" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OTOOL64" = x; then - OTOOL64=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OTOOL64=$ac_ct_OTOOL64 - fi -else - OTOOL64="$ac_cv_prog_OTOOL64" -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 -$as_echo_n "checking for -single_module linker flag... " >&6; } -if ${lt_cv_apple_cc_single_mod+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_apple_cc_single_mod=no - if test -z "${LT_MULTI_MODULE}"; then - # By default we will add the -single_module flag. You can override - # by either setting the environment variable LT_MULTI_MODULE - # non-empty at configure time, or by adding -multi_module to the - # link flags. - rm -rf libconftest.dylib* - echo "int foo(void){return 1;}" > conftest.c - echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ --dynamiclib -Wl,-single_module conftest.c" >&5 - $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ - -dynamiclib -Wl,-single_module conftest.c 2>conftest.err - _lt_result=$? - # If there is a non-empty error log, and "single_module" - # appears in it, assume the flag caused a linker warning - if test -s conftest.err && $GREP single_module conftest.err; then - cat conftest.err >&5 - # Otherwise, if the output was created with a 0 exit code from - # the compiler, it worked. - elif test -f libconftest.dylib && test $_lt_result -eq 0; then - lt_cv_apple_cc_single_mod=yes - else - cat conftest.err >&5 - fi - rm -rf libconftest.dylib* - rm -f conftest.* - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 -$as_echo "$lt_cv_apple_cc_single_mod" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 -$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } -if ${lt_cv_ld_exported_symbols_list+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ld_exported_symbols_list=no - save_LDFLAGS=$LDFLAGS - echo "_main" > conftest.sym - LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - lt_cv_ld_exported_symbols_list=yes -else - lt_cv_ld_exported_symbols_list=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 -$as_echo "$lt_cv_ld_exported_symbols_list" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 -$as_echo_n "checking for -force_load linker flag... " >&6; } -if ${lt_cv_ld_force_load+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ld_force_load=no - cat > conftest.c << _LT_EOF -int forced_loaded() { return 2;} -_LT_EOF - echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 - $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 - echo "$AR cru libconftest.a conftest.o" >&5 - $AR cru libconftest.a conftest.o 2>&5 - echo "$RANLIB libconftest.a" >&5 - $RANLIB libconftest.a 2>&5 - cat > conftest.c << _LT_EOF -int main() { return 0;} -_LT_EOF - echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 - $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err - _lt_result=$? - if test -s conftest.err && $GREP force_load conftest.err; then - cat conftest.err >&5 - elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then - lt_cv_ld_force_load=yes - else - cat conftest.err >&5 - fi - rm -f conftest.err libconftest.a conftest conftest.c - rm -rf conftest.dSYM - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 -$as_echo "$lt_cv_ld_force_load" >&6; } - case $host_os in - rhapsody* | darwin1.[012]) - _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; - darwin1.*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[91]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[012][,.]*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - esac - ;; - esac - if test "$lt_cv_apple_cc_single_mod" = "yes"; then - _lt_dar_single_mod='$single_module' - fi - if test "$lt_cv_ld_exported_symbols_list" = "yes"; then - _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' - else - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then - _lt_dsymutil='~$DSYMUTIL $lib || :' - else - _lt_dsymutil= - fi - ;; - esac - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -for ac_header in dlfcn.h -do : - ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default -" -if test "x$ac_cv_header_dlfcn_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_DLFCN_H 1 -_ACEOF - -fi - -done - - - - - -# Set options -# Check whether --enable-static was given. -if test "${enable_static+set}" = set; then : - enableval=$enable_static; p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_static=no -fi - - - - - - - - - - - enable_dlopen=no - - - enable_win32_dll=no - - - # Check whether --enable-shared was given. -if test "${enable_shared+set}" = set; then : - enableval=$enable_shared; p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_shared=yes -fi - - - - - - - - - - - -# Check whether --with-pic was given. -if test "${with_pic+set}" = set; then : - withval=$with_pic; lt_p=${PACKAGE-default} - case $withval in - yes|no) pic_mode=$withval ;; - *) - pic_mode=default - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for lt_pkg in $withval; do - IFS="$lt_save_ifs" - if test "X$lt_pkg" = "X$lt_p"; then - pic_mode=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - pic_mode=default -fi - - -test -z "$pic_mode" && pic_mode=default - - - - - - - - # Check whether --enable-fast-install was given. -if test "${enable_fast_install+set}" = set; then : - enableval=$enable_fast_install; p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; - *) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_fast_install=yes -fi - - - - - - - - - - - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ltmain" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -test -z "$LN_S" && LN_S="ln -s" - - - - - - - - - - - - - - -if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 -$as_echo_n "checking for objdir... " >&6; } -if ${lt_cv_objdir+:} false; then : - $as_echo_n "(cached) " >&6 -else - rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 -$as_echo "$lt_cv_objdir" >&6; } -objdir=$lt_cv_objdir - - - - - -cat >>confdefs.h <<_ACEOF -#define LT_OBJDIR "$lt_cv_objdir/" -_ACEOF - - - - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Global variables: -ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a - -with_gnu_ld="$lt_cv_prog_gnu_ld" - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$LD" && LD=ld -test -z "$ac_objext" && ac_objext=o - -for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` - - -# Only perform the check for file, if the check method requires it -test -z "$MAGIC_CMD" && MAGIC_CMD=file -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 -$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } -if ${lt_cv_path_MAGIC_CMD+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $MAGIC_CMD in -[\\/*] | ?:[\\/]*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/${ac_tool_prefix}file; then - lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac -fi - -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 -$as_echo "$MAGIC_CMD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - - - -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 -$as_echo_n "checking for file... " >&6; } -if ${lt_cv_path_MAGIC_CMD+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $MAGIC_CMD in -[\\/*] | ?:[\\/]*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/file; then - lt_cv_path_MAGIC_CMD="$ac_dir/file" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac -fi - -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 -$as_echo "$MAGIC_CMD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - else - MAGIC_CMD=: - fi -fi - - fi - ;; -esac - -# Use C for the default configuration in the libtool script - -lt_save_CC="$CC" -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -objext=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}' - - - - - - - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - -# Save the default compiler, since it gets overwritten when the other -# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. -compiler_DEFAULT=$CC - -# save warnings/boilerplate of simple test code -ac_outfile=conftest.$ac_objext -echo "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$RM conftest* - -ac_outfile=conftest.$ac_objext -echo "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$RM -r conftest* - - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -if test -n "$compiler"; then - -lt_prog_compiler_no_builtin_flag= - -if test "$GCC" = yes; then - case $cc_basename in - nvcc*) - lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; - *) - lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; - esac - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 -$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } -if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_rtti_exceptions=no - ac_outfile=conftest.$ac_objext - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="-fno-rtti -fno-exceptions" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_rtti_exceptions=yes - fi - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 -$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } - -if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then - lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" -else - : -fi - -fi - - - - - - - lt_prog_compiler_wl= -lt_prog_compiler_pic= -lt_prog_compiler_static= - - - if test "$GCC" = yes; then - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_static='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - lt_prog_compiler_pic='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - lt_prog_compiler_pic='-DDLL_EXPORT' - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_prog_compiler_pic='-fno-common' - ;; - - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - lt_prog_compiler_static= - ;; - - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic='-fPIC' - ;; - esac - ;; - - interix[3-9]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - lt_prog_compiler_can_build_shared=no - enable_shared=no - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - lt_prog_compiler_pic='-fPIC -shared' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - lt_prog_compiler_pic=-Kconform_pic - fi - ;; - - *) - lt_prog_compiler_pic='-fPIC' - ;; - esac - - case $cc_basename in - nvcc*) # Cuda Compiler Driver 2.2 - lt_prog_compiler_wl='-Xlinker ' - if test -n "$lt_prog_compiler_pic"; then - lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" - fi - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - lt_prog_compiler_wl='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static='-Bstatic' - else - lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_prog_compiler_pic='-DDLL_EXPORT' - ;; - - hpux9* | hpux10* | hpux11*) - lt_prog_compiler_wl='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - lt_prog_compiler_static='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - lt_prog_compiler_wl='-Wl,' - # PIC (with -KPIC) is the default. - lt_prog_compiler_static='-non_shared' - ;; - - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - # old Intel for x86_64 which still supported -KPIC. - ecc*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-static' - ;; - # icc used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - icc* | ifort*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fPIC' - lt_prog_compiler_static='-static' - ;; - # Lahey Fortran 8.1. - lf95*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='--shared' - lt_prog_compiler_static='--static' - ;; - nagfor*) - # NAG Fortran compiler - lt_prog_compiler_wl='-Wl,-Wl,,' - lt_prog_compiler_pic='-PIC' - lt_prog_compiler_static='-Bstatic' - ;; - pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fpic' - lt_prog_compiler_static='-Bstatic' - ;; - ccc*) - lt_prog_compiler_wl='-Wl,' - # All Alpha code is PIC. - lt_prog_compiler_static='-non_shared' - ;; - xl* | bgxl* | bgf* | mpixl*) - # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-qpic' - lt_prog_compiler_static='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) - # Sun Fortran 8.3 passes all unrecognized flags to the linker - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='' - ;; - *Sun\ F* | *Sun*Fortran*) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='-Qoption ld ' - ;; - *Sun\ C*) - # Sun C 5.9 - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='-Wl,' - ;; - *Intel*\ [CF]*Compiler*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fPIC' - lt_prog_compiler_static='-static' - ;; - *Portland\ Group*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fpic' - lt_prog_compiler_static='-Bstatic' - ;; - esac - ;; - esac - ;; - - newsos6) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - lt_prog_compiler_pic='-fPIC -shared' - ;; - - osf3* | osf4* | osf5*) - lt_prog_compiler_wl='-Wl,' - # All OSF/1 code is PIC. - lt_prog_compiler_static='-non_shared' - ;; - - rdos*) - lt_prog_compiler_static='-non_shared' - ;; - - solaris*) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - case $cc_basename in - f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) - lt_prog_compiler_wl='-Qoption ld ';; - *) - lt_prog_compiler_wl='-Wl,';; - esac - ;; - - sunos4*) - lt_prog_compiler_wl='-Qoption ld ' - lt_prog_compiler_pic='-PIC' - lt_prog_compiler_static='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - lt_prog_compiler_pic='-Kconform_pic' - lt_prog_compiler_static='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - unicos*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_can_build_shared=no - ;; - - uts4*) - lt_prog_compiler_pic='-pic' - lt_prog_compiler_static='-Bstatic' - ;; - - *) - lt_prog_compiler_can_build_shared=no - ;; - esac - fi - -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - lt_prog_compiler_pic= - ;; - *) - lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" - ;; -esac - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 -$as_echo_n "checking for $compiler option to produce PIC... " >&6; } -if ${lt_cv_prog_compiler_pic+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_pic=$lt_prog_compiler_pic -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 -$as_echo "$lt_cv_prog_compiler_pic" >&6; } -lt_prog_compiler_pic=$lt_cv_prog_compiler_pic - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$lt_prog_compiler_pic"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 -$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } -if ${lt_cv_prog_compiler_pic_works+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_pic_works=no - ac_outfile=conftest.$ac_objext - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic -DPIC" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_pic_works=yes - fi - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 -$as_echo "$lt_cv_prog_compiler_pic_works" >&6; } - -if test x"$lt_cv_prog_compiler_pic_works" = xyes; then - case $lt_prog_compiler_pic in - "" | " "*) ;; - *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; - esac -else - lt_prog_compiler_pic= - lt_prog_compiler_can_build_shared=no -fi - -fi - - - - - - - - - - - -# -# Check to make sure the static flag actually works. -# -wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 -$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } -if ${lt_cv_prog_compiler_static_works+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_static_works=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $lt_tmp_static_flag" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&5 - $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_static_works=yes - fi - else - lt_cv_prog_compiler_static_works=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 -$as_echo "$lt_cv_prog_compiler_static_works" >&6; } - -if test x"$lt_cv_prog_compiler_static_works" = xyes; then - : -else - lt_prog_compiler_static= -fi - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_c_o=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o=yes - fi - fi - chmod u+w . 2>&5 - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 -$as_echo "$lt_cv_prog_compiler_c_o" >&6; } - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_c_o=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o=yes - fi - fi - chmod u+w . 2>&5 - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 -$as_echo "$lt_cv_prog_compiler_c_o" >&6; } - - - - -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 -$as_echo_n "checking if we can lock with hard links... " >&6; } - hard_links=yes - $RM conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 -$as_echo "$hard_links" >&6; } - if test "$hard_links" = no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} - need_locks=warn - fi -else - need_locks=no -fi - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } - - runpath_var= - allow_undefined_flag= - always_export_symbols=no - archive_cmds= - archive_expsym_cmds= - compiler_needs_object=no - enable_shared_with_static_runtimes=no - export_dynamic_flag_spec= - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - hardcode_automatic=no - hardcode_direct=no - hardcode_direct_absolute=no - hardcode_libdir_flag_spec= - hardcode_libdir_separator= - hardcode_minus_L=no - hardcode_shlibpath_var=unsupported - inherit_rpath=no - link_all_deplibs=unknown - module_cmds= - module_expsym_cmds= - old_archive_from_new_cmds= - old_archive_from_expsyms_cmds= - thread_safe_flag_spec= - whole_archive_flag_spec= - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - include_expsyms= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - # Exclude shared library initialization/finalization symbols. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - ld_shlibs=yes - - # On some targets, GNU ld is compatible enough with the native linker - # that we're better off using the native interface for both. - lt_use_gnu_ld_interface=no - if test "$with_gnu_ld" = yes; then - case $host_os in - aix*) - # The AIX port of GNU ld has always aspired to compatibility - # with the native linker. However, as the warning in the GNU ld - # block says, versions before 2.19.5* couldn't really create working - # shared libraries, regardless of the interface used. - case `$LD -v 2>&1` in - *\ \(GNU\ Binutils\)\ 2.19.5*) ;; - *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; - *\ \(GNU\ Binutils\)\ [3-9]*) ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - fi - - if test "$lt_use_gnu_ld_interface" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - export_dynamic_flag_spec='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec= - fi - supports_anon_versioning=no - case `$LD -v 2>&1` in - *GNU\ gold*) supports_anon_versioning=yes ;; - *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix[3-9]*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - ld_shlibs=no - cat <<_LT_EOF 1>&2 - -*** Warning: the GNU linker, at least up to release 2.19, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to install binutils -*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. -*** You will then need to restart the configuration process. - -_LT_EOF - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='' - ;; - m68k) - archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - esac - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs=no - fi - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, - # as there is no search path for DLLs. - hardcode_libdir_flag_spec='-L$libdir' - export_dynamic_flag_spec='${wl}--export-all-symbols' - allow_undefined_flag=unsupported - always_export_symbols=no - enable_shared_with_static_runtimes=yes - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' - exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - ld_shlibs=no - fi - ;; - - haiku*) - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - link_all_deplibs=yes - ;; - - interix[3-9]*) - hardcode_direct=no - hardcode_shlibpath_var=no - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) - tmp_diet=no - if test "$host_os" = linux-dietlibc; then - case $cc_basename in - diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) - esac - fi - if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ - && test "$tmp_diet" = no - then - tmp_addflag=' $pic_flag' - tmp_sharedflag='-shared' - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95* | pgfortran*) - # Portland Group f77 and f90 compilers - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - lf95*) # Lahey Fortran 8.1 - whole_archive_flag_spec= - tmp_sharedflag='--shared' ;; - xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; - nvcc*) # Cuda Compiler Driver 2.2 - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - compiler_needs_object=yes - ;; - esac - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) # Sun C 5.9 - whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - compiler_needs_object=yes - tmp_sharedflag='-G' ;; - *Sun\ F*) # Sun Fortran 8.3 - tmp_sharedflag='-G' ;; - esac - archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test "x$supports_anon_versioning" = xyes; then - archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - - case $cc_basename in - xlf* | bgf* | bgxlf* | mpixlf*) - # IBM XL Fortran 10.1 on PPC cannot create shared libs itself - whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' - fi - ;; - esac - else - ld_shlibs=no - fi - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then - ld_shlibs=no - cat <<_LT_EOF 1>&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) - ld_shlibs=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - # For security reasons, it is highly recommended that you always - # use absolute paths for naming shared libraries, and exclude the - # DT_RUNPATH tag from executables and libraries. But doing so - # requires that you compile everything twice, which is a pain. - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - esac - ;; - - sunos4*) - archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - *) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - esac - - if test "$ld_shlibs" = no; then - runpath_var= - hardcode_libdir_flag_spec= - export_dynamic_flag_spec= - whole_archive_flag_spec= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - allow_undefined_flag=unsupported - always_export_symbols=yes - archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - - aix[4-9]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global - # defined symbols, whereas GNU nm marks them as "W". - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - archive_cmds='' - hardcode_direct=yes - hardcode_direct_absolute=yes - hardcode_libdir_separator=':' - link_all_deplibs=yes - file_list_spec='${wl}-f,' - - if test "$GCC" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - hardcode_direct=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - hardcode_minus_L=yes - hardcode_libdir_flag_spec='-L$libdir' - hardcode_libdir_separator= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - export_dynamic_flag_spec='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - always_export_symbols=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - allow_undefined_flag='-berok' - # Determine the default libpath from the value encoded in an - # empty executable. - if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - if ${lt_cv_aix_libpath_+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - - lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }' - lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - # Check for a 64-bit object if we didn't find anything. - if test -z "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - if test -z "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_="/usr/lib:/lib" - fi - -fi - - aix_libpath=$lt_cv_aix_libpath_ -fi - - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag="-z nodefs" - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - if ${lt_cv_aix_libpath_+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - - lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }' - lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - # Check for a 64-bit object if we didn't find anything. - if test -z "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - if test -z "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_="/usr/lib:/lib" - fi - -fi - - aix_libpath=$lt_cv_aix_libpath_ -fi - - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - no_undefined_flag=' ${wl}-bernotok' - allow_undefined_flag=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then - # We only use this code for GNU lds that support --whole-archive. - whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec='$convenience' - fi - archive_cmds_need_lc=yes - # This is similar to how AIX traditionally builds its shared libraries. - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='' - ;; - m68k) - archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - esac - ;; - - bsdi[45]*) - export_dynamic_flag_spec=-rdynamic - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - case $cc_basename in - cl*) - # Native MSVC - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - always_export_symbols=yes - file_list_spec='@' - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, )='true' - enable_shared_with_static_runtimes=yes - exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' - # Don't use ranlib - old_postinstall_cmds='chmod 644 $oldlib' - postlink_cmds='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # Assume MSVC wrapper - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_from_new_cmds='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' - enable_shared_with_static_runtimes=yes - ;; - esac - ;; - - darwin* | rhapsody*) - - - archive_cmds_need_lc=no - hardcode_direct=no - hardcode_automatic=yes - hardcode_shlibpath_var=unsupported - if test "$lt_cv_ld_force_load" = "yes"; then - whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' - - else - whole_archive_flag_spec='' - fi - link_all_deplibs=yes - allow_undefined_flag="$_lt_dar_allow_undefined" - case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; - *) _lt_dar_can_shared=$GCC ;; - esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=func_echo_all - archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - - else - ld_shlibs=no - fi - - ;; - - dgux*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2.*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - hpux9*) - if test "$GCC" = yes; then - archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - export_dynamic_flag_spec='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then - archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - hardcode_direct_absolute=yes - export_dynamic_flag_spec='${wl}-E' - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - - # Older versions of the 11.00 compiler do not understand -b yet - # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 -$as_echo_n "checking if $CC understands -b... " >&6; } -if ${lt_cv_prog_compiler__b+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler__b=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -b" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&5 - $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler__b=yes - fi - else - lt_cv_prog_compiler__b=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 -$as_echo "$lt_cv_prog_compiler__b" >&6; } - -if test x"$lt_cv_prog_compiler__b" = xyes; then - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' -else - archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' -fi - - ;; - esac - fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - - case $host_cpu in - hppa*64*|ia64*) - hardcode_direct=no - hardcode_shlibpath_var=no - ;; - *) - hardcode_direct=yes - hardcode_direct_absolute=yes - export_dynamic_flag_spec='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - # Try to use the -exported_symbol ld option, if it does not - # work, assume that -exports_file does not work either and - # implicitly export all symbols. - # This should be the same for all languages, so no per-tag cache variable. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 -$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } -if ${lt_cv_irix_exported_symbol+:} false; then : - $as_echo_n "(cached) " >&6 -else - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int foo (void) { return 0; } -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - lt_cv_irix_exported_symbol=yes -else - lt_cv_irix_exported_symbol=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 -$as_echo "$lt_cv_irix_exported_symbol" >&6; } - if test "$lt_cv_irix_exported_symbol" = yes; then - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - fi - else - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' - fi - archive_cmds_need_lc='no' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - inherit_rpath=yes - link_all_deplibs=yes - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - newsos6) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_shlibpath_var=no - ;; - - *nto* | *qnx*) - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - hardcode_direct=yes - hardcode_shlibpath_var=no - hardcode_direct_absolute=yes - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' - else - case $host_os in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac - fi - else - ld_shlibs=no - fi - ;; - - os2*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - allow_undefined_flag=unsupported - archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - fi - archive_cmds_need_lc='no' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' - - # Both c and cxx compiler support -rpath directly - hardcode_libdir_flag_spec='-rpath $libdir' - fi - archive_cmds_need_lc='no' - hardcode_libdir_separator=: - ;; - - solaris*) - no_undefined_flag=' -z defs' - if test "$GCC" = yes; then - wlarc='${wl}' - archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - else - case `$CC -V 2>&1` in - *"Compilers 5.0"*) - wlarc='' - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' - ;; - *) - wlarc='${wl}' - archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - ;; - esac - fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_shlibpath_var=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. GCC discards it without `$wl', - # but is careful enough not to reorder. - # Supported since Solaris 2.6 (maybe 2.5.1?) - if test "$GCC" = yes; then - whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - else - whole_archive_flag_spec='-z allextract$convenience -z defaultextract' - fi - ;; - esac - link_all_deplibs=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - sysv4) - case $host_vendor in - sni) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' - reload_cmds='$CC -r -o $output$reload_objs' - hardcode_direct=no - ;; - motorola) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var=no - ;; - - sysv4.3*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - export_dynamic_flag_spec='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ld_shlibs=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) - no_undefined_flag='${wl}-z,text' - archive_cmds_need_lc=no - hardcode_shlibpath_var=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - no_undefined_flag='${wl}-z,text' - allow_undefined_flag='${wl}-z,nodefs' - archive_cmds_need_lc=no - hardcode_shlibpath_var=no - hardcode_libdir_flag_spec='${wl}-R,$libdir' - hardcode_libdir_separator=':' - link_all_deplibs=yes - export_dynamic_flag_spec='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - *) - ld_shlibs=no - ;; - esac - - if test x$host_vendor = xsni; then - case $host in - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - export_dynamic_flag_spec='${wl}-Blargedynsym' - ;; - esac - fi - fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 -$as_echo "$ld_shlibs" >&6; } -test "$ld_shlibs" = no && can_build_shared=no - -with_gnu_ld=$with_gnu_ld - - - - - - - - - - - - - - - -# -# Do we need to explicitly link libc? -# -case "x$archive_cmds_need_lc" in -x|xyes) - # Assume -lc should be added - archive_cmds_need_lc=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 -$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } -if ${lt_cv_archive_cmds_need_lc+:} false; then : - $as_echo_n "(cached) " >&6 -else - $RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl - pic_flag=$lt_prog_compiler_pic - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag - allow_undefined_flag= - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 - (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - then - lt_cv_archive_cmds_need_lc=no - else - lt_cv_archive_cmds_need_lc=yes - fi - allow_undefined_flag=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 -$as_echo "$lt_cv_archive_cmds_need_lc" >&6; } - archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc - ;; - esac - fi - ;; -esac - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 -$as_echo_n "checking dynamic linker characteristics... " >&6; } - -if test "$GCC" = yes; then - case $host_os in - darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; - *) lt_awk_arg="/^libraries:/" ;; - esac - case $host_os in - mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; - *) lt_sed_strip_eq="s,=/,/,g" ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` - case $lt_search_path_spec in - *\;*) - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` - ;; - *) - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` - ;; - esac - # Ok, now we have the path, separated by spaces, we can step through it - # and add multilib dir if necessary. - lt_tmp_lt_search_path_spec= - lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` - for lt_sys_path in $lt_search_path_spec; do - if test -d "$lt_sys_path/$lt_multi_os_dir"; then - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" - else - test -d "$lt_sys_path" && \ - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" - fi - done - lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' -BEGIN {RS=" "; FS="/|\n";} { - lt_foo=""; - lt_count=0; - for (lt_i = NF; lt_i > 0; lt_i--) { - if ($lt_i != "" && $lt_i != ".") { - if ($lt_i == "..") { - lt_count++; - } else { - if (lt_count == 0) { - lt_foo="/" $lt_i lt_foo; - } else { - lt_count--; - } - } - } - } - if (lt_foo != "") { lt_freq[lt_foo]++; } - if (lt_freq[lt_foo] == 1) { print lt_foo; } -}'` - # AWK program above erroneously prepends '/' to C:/dos/paths - # for these hosts. - case $host_os in - mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ - $SED 's,/\([A-Za-z]:\),\1,g'` ;; - esac - sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix[4-9]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[01] | aix4.[01].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - case $host_cpu in - powerpc) - # Since July 2007 AmigaOS4 officially supports .so libraries. - # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - ;; - m68k) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - esac - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[45]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32* | cegcc*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$cc_basename in - yes,*) - # gcc - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - esac - dynamic_linker='Win32 ld.exe' - ;; - - *,cl*) - # Native MSVC - libname_spec='$name' - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - library_names_spec='${libname}.dll.lib' - - case $build_os in - mingw*) - sys_lib_search_path_spec= - lt_save_ifs=$IFS - IFS=';' - for lt_path in $LIB - do - IFS=$lt_save_ifs - # Let DOS variable expansion print the short 8.3 style file name. - lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` - sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" - done - IFS=$lt_save_ifs - # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` - ;; - cygwin*) - # Convert to unix form, then to dos form, then back to unix form - # but this time dos style (no spaces!) so that the unix form looks - # like /cygdrive/c/PROGRA~1:/cygdr... - sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` - sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` - sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - ;; - *) - sys_lib_search_path_spec="$LIB" - if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then - # It is most probably a Windows format PATH. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # FIXME: find the short name or the path components, as spaces are - # common. (e.g. "Program Files" -> "PROGRA~1") - ;; - esac - - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - dynamic_linker='Win32 link.exe' - ;; - - *) - # Assume MSVC wrapper - library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' - dynamic_linker='Win32 ld.exe' - ;; - esac - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' - - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[23].*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2.*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[01]* | freebsdelf3.[01]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ - freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - *) # from 4.6 on, and DragonFly - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -haiku*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - dynamic_linker="$host_os runtime_loader" - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LIBRARY_PATH - shlibpath_overrides_runpath=yes - sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555, ... - postinstall_cmds='chmod 555 $lib' - # or fails outright, so override atomically: - install_override_mode=555 - ;; - -interix[3-9]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux # correct to gnu/linux during the next big refactor - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - - # Some binutils ld are patched to set DT_RUNPATH - if ${lt_cv_shlibpath_overrides_runpath+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_shlibpath_overrides_runpath=no - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ - LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : - lt_cv_shlibpath_overrides_runpath=yes -fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - -fi - - shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath - - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -*nto* | *qnx*) - version_type=qnx - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='ldqnx.so' - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[89] | openbsd2.[89].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -rdos*) - dynamic_linker=no - ;; - -solaris*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -tpf*) - # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -uts4*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 -$as_echo "$dynamic_linker" >&6; } -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" -fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 -$as_echo_n "checking how to hardcode library paths into programs... " >&6; } -hardcode_action= -if test -n "$hardcode_libdir_flag_spec" || - test -n "$runpath_var" || - test "X$hardcode_automatic" = "Xyes" ; then - - # We can hardcode non-existent directories. - if test "$hardcode_direct" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && - test "$hardcode_minus_L" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action=unsupported -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 -$as_echo "$hardcode_action" >&6; } - -if test "$hardcode_action" = relink || - test "$inherit_rpath" = yes; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi - - - - - - - if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32* | cegcc*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -$as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dl_dlopen=yes -else - ac_cv_lib_dl_dlopen=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -$as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - -fi - - ;; - - *) - ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" -if test "x$ac_cv_func_shl_load" = xyes; then : - lt_cv_dlopen="shl_load" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 -$as_echo_n "checking for shl_load in -ldld... " >&6; } -if ${ac_cv_lib_dld_shl_load+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char shl_load (); -int -main () -{ -return shl_load (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dld_shl_load=yes -else - ac_cv_lib_dld_shl_load=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 -$as_echo "$ac_cv_lib_dld_shl_load" >&6; } -if test "x$ac_cv_lib_dld_shl_load" = xyes; then : - lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" -else - ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" -if test "x$ac_cv_func_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -$as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dl_dlopen=yes -else - ac_cv_lib_dl_dlopen=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -$as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 -$as_echo_n "checking for dlopen in -lsvld... " >&6; } -if ${ac_cv_lib_svld_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lsvld $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_svld_dlopen=yes -else - ac_cv_lib_svld_dlopen=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 -$as_echo "$ac_cv_lib_svld_dlopen" >&6; } -if test "x$ac_cv_lib_svld_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 -$as_echo_n "checking for dld_link in -ldld... " >&6; } -if ${ac_cv_lib_dld_dld_link+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dld_link (); -int -main () -{ -return dld_link (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dld_dld_link=yes -else - ac_cv_lib_dld_dld_link=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 -$as_echo "$ac_cv_lib_dld_dld_link" >&6; } -if test "x$ac_cv_lib_dld_dld_link" = xyes; then : - lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" -fi - - -fi - - -fi - - -fi - - -fi - - -fi - - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 -$as_echo_n "checking whether a program can dlopen itself... " >&6; } -if ${lt_cv_dlopen_self+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - lt_cv_dlopen_self=cross -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -#line $LINENO "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -/* When -fvisbility=hidden is used, assume the code has been annotated - correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); -#endif - -int fnord () { return 42; } -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else - { - if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - else puts (dlerror ()); - } - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -} -_LT_EOF - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 - (eval $ac_link) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&5 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; - x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self=no - fi -fi -rm -fr conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 -$as_echo "$lt_cv_dlopen_self" >&6; } - - if test "x$lt_cv_dlopen_self" = xyes; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 -$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } -if ${lt_cv_dlopen_self_static+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - lt_cv_dlopen_self_static=cross -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -#line $LINENO "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -/* When -fvisbility=hidden is used, assume the code has been annotated - correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); -#endif - -int fnord () { return 42; } -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else - { - if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - else puts (dlerror ()); - } - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -} -_LT_EOF - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 - (eval $ac_link) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&5 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self_static=no - fi -fi -rm -fr conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 -$as_echo "$lt_cv_dlopen_self_static" >&6; } - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi - - - - - - - - - - - - - - - - - -striplib= -old_striplib= -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 -$as_echo_n "checking whether stripping libraries is possible... " >&6; } -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - old_striplib="$STRIP -S" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - fi - ;; - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ;; - esac -fi - - - - - - - - - - - - - # Report which library types will actually be built - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 -$as_echo_n "checking if libtool supports shared libraries... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 -$as_echo "$can_build_shared" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 -$as_echo_n "checking whether to build shared libraries... " >&6; } - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - - aix[4-9]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 -$as_echo "$enable_shared" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 -$as_echo_n "checking whether to build static libraries... " >&6; } - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 -$as_echo "$enable_static" >&6; } - - - - -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -CC="$lt_save_CC" - - - - - - - - - - - - - - - - ac_config_commands="$ac_config_commands libtool" - - - - -# Only expand once: - - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -if test -z "$CXX"; then - if test -n "$CCC"; then - CXX=$CCC - else - if test -n "$ac_tool_prefix"; then - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CXX=$ac_cv_prog_CXX -if test -n "$CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 -$as_echo "$CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CXX" && break - done -fi -if test -z "$CXX"; then - ac_ct_CXX=$CXX - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CXX="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 -$as_echo "$ac_ct_CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CXX" && break -done - - if test "x$ac_ct_CXX" = x; then - CXX="g++" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_ct_CXX - fi -fi - - fi -fi -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 -$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if ${ac_cv_cxx_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_cxx_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 -$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GXX=yes -else - GXX= -fi -ac_test_CXXFLAGS=${CXXFLAGS+set} -ac_save_CXXFLAGS=$CXXFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 -$as_echo_n "checking whether $CXX accepts -g... " >&6; } -if ${ac_cv_prog_cxx_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_cxx_werror_flag=$ac_cxx_werror_flag - ac_cxx_werror_flag=yes - ac_cv_prog_cxx_g=no - CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_prog_cxx_g=yes -else - CXXFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - -else - ac_cxx_werror_flag=$ac_save_cxx_werror_flag - CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_prog_cxx_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_cxx_werror_flag=$ac_save_cxx_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 -$as_echo "$ac_cv_prog_cxx_g" >&6; } -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS=$ac_save_CXXFLAGS -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -depcc="$CXX" am_compiler_list= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if ${am_cv_CXX_dependencies_compiler_type+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CXX_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - am__universal=false - case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with '-c' and '-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CXX_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CXX_dependencies_compiler_type=none -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } -CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then - am__fastdepCXX_TRUE= - am__fastdepCXX_FALSE='#' -else - am__fastdepCXX_TRUE='#' - am__fastdepCXX_FALSE= -fi - - - - - -func_stripname_cnf () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; - esac -} # func_stripname_cnf - - if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 -$as_echo_n "checking how to run the C++ preprocessor... " >&6; } -if test -z "$CXXCPP"; then - if ${ac_cv_prog_CXXCPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CXXCPP needs to be expanded - for CXXCPP in "$CXX -E" "/lib/cpp" - do - ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CXXCPP=$CXXCPP - -fi - CXXCPP=$ac_cv_prog_CXXCPP -else - ac_cv_prog_CXXCPP=$CXXCPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 -$as_echo "$CXXCPP" >&6; } -ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -else - _lt_caught_CXX_error=yes -fi - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - -archive_cmds_need_lc_CXX=no -allow_undefined_flag_CXX= -always_export_symbols_CXX=no -archive_expsym_cmds_CXX= -compiler_needs_object_CXX=no -export_dynamic_flag_spec_CXX= -hardcode_direct_CXX=no -hardcode_direct_absolute_CXX=no -hardcode_libdir_flag_spec_CXX= -hardcode_libdir_separator_CXX= -hardcode_minus_L_CXX=no -hardcode_shlibpath_var_CXX=unsupported -hardcode_automatic_CXX=no -inherit_rpath_CXX=no -module_cmds_CXX= -module_expsym_cmds_CXX= -link_all_deplibs_CXX=unknown -old_archive_cmds_CXX=$old_archive_cmds -reload_flag_CXX=$reload_flag -reload_cmds_CXX=$reload_cmds -no_undefined_flag_CXX= -whole_archive_flag_spec_CXX= -enable_shared_with_static_runtimes_CXX=no - -# Source file extension for C++ test sources. -ac_ext=cpp - -# Object file extension for compiled C++ test sources. -objext=o -objext_CXX=$objext - -# No sense in running all these tests if we already determined that -# the CXX compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_caught_CXX_error" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="int some_variable = 0;" - - # Code to be used in simple link tests - lt_simple_link_test_code='int main(int, char *[]) { return(0); }' - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - - - - - - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - - # save warnings/boilerplate of simple test code - ac_outfile=conftest.$ac_objext -echo "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$RM conftest* - - ac_outfile=conftest.$ac_objext -echo "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$RM -r conftest* - - - # Allow CC to be a program name with arguments. - lt_save_CC=$CC - lt_save_CFLAGS=$CFLAGS - lt_save_LD=$LD - lt_save_GCC=$GCC - GCC=$GXX - lt_save_with_gnu_ld=$with_gnu_ld - lt_save_path_LD=$lt_cv_path_LD - if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then - lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx - else - $as_unset lt_cv_prog_gnu_ld - fi - if test -n "${lt_cv_path_LDCXX+set}"; then - lt_cv_path_LD=$lt_cv_path_LDCXX - else - $as_unset lt_cv_path_LD - fi - test -z "${LDCXX+set}" || LD=$LDCXX - CC=${CXX-"c++"} - CFLAGS=$CXXFLAGS - compiler=$CC - compiler_CXX=$CC - for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` - - - if test -n "$compiler"; then - # We don't want -fno-exception when compiling C++ code, so set the - # no_builtin_flag separately - if test "$GXX" = yes; then - lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' - else - lt_prog_compiler_no_builtin_flag_CXX= - fi - - if test "$GXX" = yes; then - # Set up default GNU C++ configuration - - - -# Check whether --with-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then : - withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes -else - with_gnu_ld=no -fi - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 -$as_echo_n "checking for ld used by $CC... " >&6; } - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [\\/]* | ?:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` - while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do - ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 -$as_echo_n "checking for GNU ld... " >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 -$as_echo_n "checking for non-GNU ld... " >&6; } -fi -if ${lt_cv_path_LD+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &5 -$as_echo "$LD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi -test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 -$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } -if ${lt_cv_prog_gnu_ld+:} false; then : - $as_echo_n "(cached) " >&6 -else - # I'd rather use --version here, but apparently some GNU lds only accept -v. -case `$LD -v 2>&1 &5 -$as_echo "$lt_cv_prog_gnu_ld" >&6; } -with_gnu_ld=$lt_cv_prog_gnu_ld - - - - - - - - # Check if GNU C++ uses GNU ld as the underlying linker, since the - # archiving commands below assume that GNU ld is being used. - if test "$with_gnu_ld" = yes; then - archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - - # If archive_cmds runs LD, not CC, wlarc should be empty - # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to - # investigate it a little bit more. (MM) - wlarc='${wl}' - - # ancient GNU ld didn't support --whole-archive et. al. - if eval "`$CC -print-prog-name=ld` --help 2>&1" | - $GREP 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec_CXX= - fi - else - with_gnu_ld=no - wlarc= - - # A generic and very simple default shared library creation - # command for GNU C++ for the case where it uses the native - # linker, instead of GNU ld. If possible, this setting should - # overridden to take advantage of the native linker features on - # the platform it is being used on. - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - fi - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - - else - GXX=no - with_gnu_ld=no - wlarc= - fi - - # PORTME: fill in a description of your system's C++ link characteristics - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } - ld_shlibs_CXX=yes - case $host_os in - aix3*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - aix[4-9]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) - for ld_flag in $LDFLAGS; do - case $ld_flag in - *-brtl*) - aix_use_runtimelinking=yes - break - ;; - esac - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - archive_cmds_CXX='' - hardcode_direct_CXX=yes - hardcode_direct_absolute_CXX=yes - hardcode_libdir_separator_CXX=':' - link_all_deplibs_CXX=yes - file_list_spec_CXX='${wl}-f,' - - if test "$GXX" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - hardcode_direct_CXX=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - hardcode_minus_L_CXX=yes - hardcode_libdir_flag_spec_CXX='-L$libdir' - hardcode_libdir_separator_CXX= - fi - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - export_dynamic_flag_spec_CXX='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to - # export. - always_export_symbols_CXX=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - allow_undefined_flag_CXX='-berok' - # Determine the default libpath from the value encoded in an empty - # executable. - if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - if ${lt_cv_aix_libpath__CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - - lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }' - lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - # Check for a 64-bit object if we didn't find anything. - if test -z "$lt_cv_aix_libpath__CXX"; then - lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - if test -z "$lt_cv_aix_libpath__CXX"; then - lt_cv_aix_libpath__CXX="/usr/lib:/lib" - fi - -fi - - aix_libpath=$lt_cv_aix_libpath__CXX -fi - - hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" - - archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag_CXX="-z nodefs" - archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - if ${lt_cv_aix_libpath__CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - - lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }' - lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - # Check for a 64-bit object if we didn't find anything. - if test -z "$lt_cv_aix_libpath__CXX"; then - lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - if test -z "$lt_cv_aix_libpath__CXX"; then - lt_cv_aix_libpath__CXX="/usr/lib:/lib" - fi - -fi - - aix_libpath=$lt_cv_aix_libpath__CXX -fi - - hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - no_undefined_flag_CXX=' ${wl}-bernotok' - allow_undefined_flag_CXX=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then - # We only use this code for GNU lds that support --whole-archive. - whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec_CXX='$convenience' - fi - archive_cmds_need_lc_CXX=yes - # This is similar to how AIX traditionally builds its shared - # libraries. - archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag_CXX=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs_CXX=no - fi - ;; - - chorus*) - case $cc_basename in - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - - cygwin* | mingw* | pw32* | cegcc*) - case $GXX,$cc_basename in - ,cl* | no,cl*) - # Native MSVC - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec_CXX=' ' - allow_undefined_flag_CXX=unsupported - always_export_symbols_CXX=yes - file_list_spec_CXX='@' - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true' - enable_shared_with_static_runtimes_CXX=yes - # Don't use ranlib - old_postinstall_cmds_CXX='chmod 644 $oldlib' - postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - func_to_tool_file "$lt_outputfile"~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # g++ - # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, - # as there is no search path for DLLs. - hardcode_libdir_flag_spec_CXX='-L$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-all-symbols' - allow_undefined_flag_CXX=unsupported - always_export_symbols_CXX=no - enable_shared_with_static_runtimes_CXX=yes - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - ld_shlibs_CXX=no - fi - ;; - esac - ;; - darwin* | rhapsody*) - - - archive_cmds_need_lc_CXX=no - hardcode_direct_CXX=no - hardcode_automatic_CXX=yes - hardcode_shlibpath_var_CXX=unsupported - if test "$lt_cv_ld_force_load" = "yes"; then - whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' - - else - whole_archive_flag_spec_CXX='' - fi - link_all_deplibs_CXX=yes - allow_undefined_flag_CXX="$_lt_dar_allow_undefined" - case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; - *) _lt_dar_can_shared=$GCC ;; - esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=func_echo_all - archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - if test "$lt_cv_apple_cc_single_mod" != "yes"; then - archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" - archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" - fi - - else - ld_shlibs_CXX=no - fi - - ;; - - dgux*) - case $cc_basename in - ec++*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - ghcx*) - # Green Hills C++ Compiler - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - - freebsd2.*) - # C++ shared libraries reported to be fairly broken before - # switch to ELF - ld_shlibs_CXX=no - ;; - - freebsd-elf*) - archive_cmds_need_lc_CXX=no - ;; - - freebsd* | dragonfly*) - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF - # conventions - ld_shlibs_CXX=yes - ;; - - gnu*) - ;; - - haiku*) - archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - link_all_deplibs_CXX=yes - ;; - - hpux9*) - hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_CXX=: - export_dynamic_flag_spec_CXX='${wl}-E' - hardcode_direct_CXX=yes - hardcode_minus_L_CXX=yes # Not in the search PATH, - # but as the default - # location of the library. - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - aCC*) - archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test "$GXX" = yes; then - archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - fi - ;; - esac - ;; - - hpux10*|hpux11*) - if test $with_gnu_ld = no; then - hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_CXX=: - - case $host_cpu in - hppa*64*|ia64*) - ;; - *) - export_dynamic_flag_spec_CXX='${wl}-E' - ;; - esac - fi - case $host_cpu in - hppa*64*|ia64*) - hardcode_direct_CXX=no - hardcode_shlibpath_var_CXX=no - ;; - *) - hardcode_direct_CXX=yes - hardcode_direct_absolute_CXX=yes - hardcode_minus_L_CXX=yes # Not in the search PATH, - # but as the default - # location of the library. - ;; - esac - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - aCC*) - case $host_cpu in - hppa*64*) - archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then - case $host_cpu in - hppa*64*) - archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - fi - else - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - fi - ;; - esac - ;; - - interix[3-9]*) - hardcode_direct_CXX=no - hardcode_shlibpath_var_CXX=no - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - export_dynamic_flag_spec_CXX='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - irix5* | irix6*) - case $cc_basename in - CC*) - # SGI C++ - archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - - # Archives containing C++ object files must be created using - # "CC -ar", where "CC" is the IRIX C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' - ;; - *) - if test "$GXX" = yes; then - if test "$with_gnu_ld" = no; then - archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' - fi - fi - link_all_deplibs_CXX=yes - ;; - esac - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_CXX=: - inherit_rpath_CXX=yes - ;; - - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' - ;; - icpc* | ecpc* ) - # Intel C++ - with_gnu_ld=yes - # version 8.0 and above of icpc choke on multiply defined symbols - # if we add $predep_objects and $postdep_objects, however 7.1 and - # earlier do not add the objects themselves. - case `$CC -V 2>&1` in - *"Version 7."*) - archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - *) # Version 8.0 or newer - tmp_idyn= - case $host_cpu in - ia64*) tmp_idyn=' -i_dynamic';; - esac - archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - esac - archive_cmds_need_lc_CXX=no - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - case `$CC -V` in - *pgCC\ [1-5].* | *pgcpp\ [1-5].*) - prelink_cmds_CXX='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ - compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' - old_archive_cmds_CXX='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ - $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ - $RANLIB $oldlib' - archive_cmds_CXX='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - archive_expsym_cmds_CXX='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - *) # Version 6 and above use weak symbols - archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - esac - - hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - ;; - cxx*) - # Compaq C++ - archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' - - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec_CXX='-rpath $libdir' - hardcode_libdir_separator_CXX=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' - ;; - xl* | mpixl* | bgxl*) - # IBM XL 8.0 on PPC, with GNU ld - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - no_undefined_flag_CXX=' -zdefs' - archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' - hardcode_libdir_flag_spec_CXX='-R$libdir' - whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - compiler_needs_object_CXX=yes - - # Not sure whether something based on - # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 - # would be better. - output_verbose_link_cmd='func_echo_all' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' - ;; - esac - ;; - esac - ;; - - lynxos*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - - m88k*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - - mvs*) - case $cc_basename in - cxx*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' - wlarc= - hardcode_libdir_flag_spec_CXX='-R$libdir' - hardcode_direct_CXX=yes - hardcode_shlibpath_var_CXX=no - fi - # Workaround some broken pre-1.5 toolchains - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' - ;; - - *nto* | *qnx*) - ld_shlibs_CXX=yes - ;; - - openbsd2*) - # C++ shared libraries are fairly broken - ld_shlibs_CXX=no - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - hardcode_direct_CXX=yes - hardcode_shlibpath_var_CXX=no - hardcode_direct_absolute_CXX=yes - archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' - export_dynamic_flag_spec_CXX='${wl}-E' - whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - fi - output_verbose_link_cmd=func_echo_all - else - ld_shlibs_CXX=no - fi - ;; - - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - hardcode_libdir_separator_CXX=: - - # Archives containing C++ object files must be created using - # the KAI C++ compiler. - case $host in - osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; - *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;; - esac - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - cxx*) - case $host in - osf3*) - allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - ;; - *) - allow_undefined_flag_CXX=' -expect_unresolved \*' - archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ - echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ - $RM $lib.exp' - hardcode_libdir_flag_spec_CXX='-rpath $libdir' - ;; - esac - - hardcode_libdir_separator_CXX=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' - case $host in - osf3*) - archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - *) - archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - esac - - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_CXX=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - - else - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - fi - ;; - esac - ;; - - psos*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - lcc*) - # Lucid - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - - solaris*) - case $cc_basename in - CC* | sunCC*) - # Sun C++ 4.2, 5.x and Centerline C++ - archive_cmds_need_lc_CXX=yes - no_undefined_flag_CXX=' -zdefs' - archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - hardcode_libdir_flag_spec_CXX='-R$libdir' - hardcode_shlibpath_var_CXX=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. - # Supported since Solaris 2.6 (maybe 2.5.1?) - whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract' - ;; - esac - link_all_deplibs_CXX=yes - - output_verbose_link_cmd='func_echo_all' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' - ;; - gcx*) - # Green Hills C++ Compiler - archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - - # The C++ compiler must be used to create the archive. - old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' - ;; - *) - # GNU C++ compiler with Solaris linker - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - no_undefined_flag_CXX=' ${wl}-z ${wl}defs' - if $CC --version | $GREP -v '^2\.7' > /dev/null; then - archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - else - # g++ 2.7 appears to require `-G' NOT `-shared' on this - # platform. - archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - fi - - hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) - whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - ;; - esac - fi - ;; - esac - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) - no_undefined_flag_CXX='${wl}-z,text' - archive_cmds_need_lc_CXX=no - hardcode_shlibpath_var_CXX=no - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - no_undefined_flag_CXX='${wl}-z,text' - allow_undefined_flag_CXX='${wl}-z,nodefs' - archive_cmds_need_lc_CXX=no - hardcode_shlibpath_var_CXX=no - hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir' - hardcode_libdir_separator_CXX=':' - link_all_deplibs_CXX=yes - export_dynamic_flag_spec_CXX='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~ - '"$old_archive_cmds_CXX" - reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~ - '"$reload_cmds_CXX" - ;; - *) - archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - - vxworks*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 -$as_echo "$ld_shlibs_CXX" >&6; } - test "$ld_shlibs_CXX" = no && can_build_shared=no - - GCC_CXX="$GXX" - LD_CXX="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - # Dependencies to place before and after the object being linked: -predep_objects_CXX= -postdep_objects_CXX= -predeps_CXX= -postdeps_CXX= -compiler_lib_search_path_CXX= - -cat > conftest.$ac_ext <<_LT_EOF -class Foo -{ -public: - Foo (void) { a = 0; } -private: - int a; -}; -_LT_EOF - - -_lt_libdeps_save_CFLAGS=$CFLAGS -case "$CC $CFLAGS " in #( -*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; -*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; -*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; -esac - -if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - # Parse the compiler output and extract the necessary - # objects, libraries and library flags. - - # Sentinel used to keep track of whether or not we are before - # the conftest object file. - pre_test_object_deps_done=no - - for p in `eval "$output_verbose_link_cmd"`; do - case ${prev}${p} in - - -L* | -R* | -l*) - # Some compilers place space between "-{L,R}" and the path. - # Remove the space. - if test $p = "-L" || - test $p = "-R"; then - prev=$p - continue - fi - - # Expand the sysroot to ease extracting the directories later. - if test -z "$prev"; then - case $p in - -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; - -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; - -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; - esac - fi - case $p in - =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; - esac - if test "$pre_test_object_deps_done" = no; then - case ${prev} in - -L | -R) - # Internal compiler library paths should come after those - # provided the user. The postdeps already come after the - # user supplied libs so there is no need to process them. - if test -z "$compiler_lib_search_path_CXX"; then - compiler_lib_search_path_CXX="${prev}${p}" - else - compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" - fi - ;; - # The "-l" case would never come before the object being - # linked, so don't bother handling this case. - esac - else - if test -z "$postdeps_CXX"; then - postdeps_CXX="${prev}${p}" - else - postdeps_CXX="${postdeps_CXX} ${prev}${p}" - fi - fi - prev= - ;; - - *.lto.$objext) ;; # Ignore GCC LTO objects - *.$objext) - # This assumes that the test object file only shows up - # once in the compiler output. - if test "$p" = "conftest.$objext"; then - pre_test_object_deps_done=yes - continue - fi - - if test "$pre_test_object_deps_done" = no; then - if test -z "$predep_objects_CXX"; then - predep_objects_CXX="$p" - else - predep_objects_CXX="$predep_objects_CXX $p" - fi - else - if test -z "$postdep_objects_CXX"; then - postdep_objects_CXX="$p" - else - postdep_objects_CXX="$postdep_objects_CXX $p" - fi - fi - ;; - - *) ;; # Ignore the rest. - - esac - done - - # Clean up. - rm -f a.out a.exe -else - echo "libtool.m4: error: problem compiling CXX test program" -fi - -$RM -f confest.$objext -CFLAGS=$_lt_libdeps_save_CFLAGS - -# PORTME: override above test on systems where it is broken -case $host_os in -interix[3-9]*) - # Interix 3.5 installs completely hosed .la files for C++, so rather than - # hack all around it, let's just trust "g++" to DTRT. - predep_objects_CXX= - postdep_objects_CXX= - postdeps_CXX= - ;; - -linux*) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - if test "$solaris_use_stlport4" != yes; then - postdeps_CXX='-library=Cstd -library=Crun' - fi - ;; - esac - ;; - -solaris*) - case $cc_basename in - CC* | sunCC*) - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - # Adding this requires a known-good setup of shared libraries for - # Sun compiler versions before 5.6, else PIC objects from an old - # archive will be linked into the output, leading to subtle bugs. - if test "$solaris_use_stlport4" != yes; then - postdeps_CXX='-library=Cstd -library=Crun' - fi - ;; - esac - ;; -esac - - -case " $postdeps_CXX " in -*" -lc "*) archive_cmds_need_lc_CXX=no ;; -esac - compiler_lib_search_dirs_CXX= -if test -n "${compiler_lib_search_path_CXX}"; then - compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - lt_prog_compiler_wl_CXX= -lt_prog_compiler_pic_CXX= -lt_prog_compiler_static_CXX= - - - # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_CXX='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - lt_prog_compiler_pic_CXX='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - lt_prog_compiler_pic_CXX='-DDLL_EXPORT' - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_prog_compiler_pic_CXX='-fno-common' - ;; - *djgpp*) - # DJGPP does not support shared libraries at all - lt_prog_compiler_pic_CXX= - ;; - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - lt_prog_compiler_static_CXX= - ;; - interix[3-9]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - sysv4*MP*) - if test -d /usr/nec; then - lt_prog_compiler_pic_CXX=-Kconform_pic - fi - ;; - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - ;; - *) - lt_prog_compiler_pic_CXX='-fPIC' - ;; - esac - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - lt_prog_compiler_pic_CXX='-fPIC -shared' - ;; - *) - lt_prog_compiler_pic_CXX='-fPIC' - ;; - esac - else - case $host_os in - aix[4-9]*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_CXX='-Bstatic' - else - lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' - fi - ;; - chorus*) - case $cc_basename in - cxch68*) - # Green Hills C++ Compiler - # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" - ;; - esac - ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_prog_compiler_pic_CXX='-DDLL_EXPORT' - ;; - dgux*) - case $cc_basename in - ec++*) - lt_prog_compiler_pic_CXX='-KPIC' - ;; - ghcx*) - # Green Hills C++ Compiler - lt_prog_compiler_pic_CXX='-pic' - ;; - *) - ;; - esac - ;; - freebsd* | dragonfly*) - # FreeBSD uses GNU C++ - ;; - hpux9* | hpux10* | hpux11*) - case $cc_basename in - CC*) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' - if test "$host_cpu" != ia64; then - lt_prog_compiler_pic_CXX='+Z' - fi - ;; - aCC*) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic_CXX='+Z' - ;; - esac - ;; - *) - ;; - esac - ;; - interix*) - # This is c89, which is MS Visual C++ (no shared libs) - # Anyone wants to do a port? - ;; - irix5* | irix6* | nonstopux*) - case $cc_basename in - CC*) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='-non_shared' - # CC pic flag -KPIC is the default. - ;; - *) - ;; - esac - ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - KCC*) - # KAI C++ Compiler - lt_prog_compiler_wl_CXX='--backend -Wl,' - lt_prog_compiler_pic_CXX='-fPIC' - ;; - ecpc* ) - # old Intel C++ for x86_64 which still supported -KPIC. - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_pic_CXX='-KPIC' - lt_prog_compiler_static_CXX='-static' - ;; - icpc* ) - # Intel C++, used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_pic_CXX='-fPIC' - lt_prog_compiler_static_CXX='-static' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_pic_CXX='-fpic' - lt_prog_compiler_static_CXX='-Bstatic' - ;; - cxx*) - # Compaq C++ - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - lt_prog_compiler_pic_CXX= - lt_prog_compiler_static_CXX='-non_shared' - ;; - xlc* | xlC* | bgxl[cC]* | mpixl[cC]*) - # IBM XL 8.0, 9.0 on PPC and BlueGene - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_pic_CXX='-qpic' - lt_prog_compiler_static_CXX='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - lt_prog_compiler_pic_CXX='-KPIC' - lt_prog_compiler_static_CXX='-Bstatic' - lt_prog_compiler_wl_CXX='-Qoption ld ' - ;; - esac - ;; - esac - ;; - lynxos*) - ;; - m88k*) - ;; - mvs*) - case $cc_basename in - cxx*) - lt_prog_compiler_pic_CXX='-W c,exportall' - ;; - *) - ;; - esac - ;; - netbsd*) - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - lt_prog_compiler_pic_CXX='-fPIC -shared' - ;; - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - lt_prog_compiler_wl_CXX='--backend -Wl,' - ;; - RCC*) - # Rational C++ 2.4.1 - lt_prog_compiler_pic_CXX='-pic' - ;; - cxx*) - # Digital/Compaq C++ - lt_prog_compiler_wl_CXX='-Wl,' - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - lt_prog_compiler_pic_CXX= - lt_prog_compiler_static_CXX='-non_shared' - ;; - *) - ;; - esac - ;; - psos*) - ;; - solaris*) - case $cc_basename in - CC* | sunCC*) - # Sun C++ 4.2, 5.x and Centerline C++ - lt_prog_compiler_pic_CXX='-KPIC' - lt_prog_compiler_static_CXX='-Bstatic' - lt_prog_compiler_wl_CXX='-Qoption ld ' - ;; - gcx*) - # Green Hills C++ Compiler - lt_prog_compiler_pic_CXX='-PIC' - ;; - *) - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - lt_prog_compiler_pic_CXX='-pic' - lt_prog_compiler_static_CXX='-Bstatic' - ;; - lcc*) - # Lucid - lt_prog_compiler_pic_CXX='-pic' - ;; - *) - ;; - esac - ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - case $cc_basename in - CC*) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_pic_CXX='-KPIC' - lt_prog_compiler_static_CXX='-Bstatic' - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - lt_prog_compiler_pic_CXX='-KPIC' - ;; - *) - ;; - esac - ;; - vxworks*) - ;; - *) - lt_prog_compiler_can_build_shared_CXX=no - ;; - esac - fi - -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - lt_prog_compiler_pic_CXX= - ;; - *) - lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" - ;; -esac - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 -$as_echo_n "checking for $compiler option to produce PIC... " >&6; } -if ${lt_cv_prog_compiler_pic_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; } -lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$lt_prog_compiler_pic_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 -$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } -if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_pic_works_CXX=no - ac_outfile=conftest.$ac_objext - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_pic_works_CXX=yes - fi - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; } - -if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then - case $lt_prog_compiler_pic_CXX in - "" | " "*) ;; - *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; - esac -else - lt_prog_compiler_pic_CXX= - lt_prog_compiler_can_build_shared_CXX=no -fi - -fi - - - - - -# -# Check to make sure the static flag actually works. -# -wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 -$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } -if ${lt_cv_prog_compiler_static_works_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_static_works_CXX=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $lt_tmp_static_flag" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&5 - $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_static_works_CXX=yes - fi - else - lt_cv_prog_compiler_static_works_CXX=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; } - -if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then - : -else - lt_prog_compiler_static_CXX= -fi - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_c_o_CXX=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o_CXX=yes - fi - fi - chmod u+w . 2>&5 - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_c_o_CXX=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o_CXX=yes - fi - fi - chmod u+w . 2>&5 - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } - - - - -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 -$as_echo_n "checking if we can lock with hard links... " >&6; } - hard_links=yes - $RM conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 -$as_echo "$hard_links" >&6; } - if test "$hard_links" = no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} - need_locks=warn - fi -else - need_locks=no -fi - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } - - export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' - case $host_os in - aix[4-9]*) - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global defined - # symbols, whereas GNU nm marks them as "W". - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - ;; - pw32*) - export_symbols_cmds_CXX="$ltdll_cmds" - ;; - cygwin* | mingw* | cegcc*) - case $cc_basename in - cl*) - exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - ;; - *) - export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' - exclude_expsyms_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' - ;; - esac - ;; - *) - export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 -$as_echo "$ld_shlibs_CXX" >&6; } -test "$ld_shlibs_CXX" = no && can_build_shared=no - -with_gnu_ld_CXX=$with_gnu_ld - - - - - - -# -# Do we need to explicitly link libc? -# -case "x$archive_cmds_need_lc_CXX" in -x|xyes) - # Assume -lc should be added - archive_cmds_need_lc_CXX=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds_CXX in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 -$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } -if ${lt_cv_archive_cmds_need_lc_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - $RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl_CXX - pic_flag=$lt_prog_compiler_pic_CXX - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag_CXX - allow_undefined_flag_CXX= - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 - (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - then - lt_cv_archive_cmds_need_lc_CXX=no - else - lt_cv_archive_cmds_need_lc_CXX=yes - fi - allow_undefined_flag_CXX=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5 -$as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; } - archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX - ;; - esac - fi - ;; -esac - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 -$as_echo_n "checking dynamic linker characteristics... " >&6; } - -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix[4-9]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[01] | aix4.[01].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - case $host_cpu in - powerpc) - # Since July 2007 AmigaOS4 officially supports .so libraries. - # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - ;; - m68k) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - esac - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[45]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32* | cegcc*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$cc_basename in - yes,*) - # gcc - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - esac - dynamic_linker='Win32 ld.exe' - ;; - - *,cl*) - # Native MSVC - libname_spec='$name' - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - library_names_spec='${libname}.dll.lib' - - case $build_os in - mingw*) - sys_lib_search_path_spec= - lt_save_ifs=$IFS - IFS=';' - for lt_path in $LIB - do - IFS=$lt_save_ifs - # Let DOS variable expansion print the short 8.3 style file name. - lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` - sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" - done - IFS=$lt_save_ifs - # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` - ;; - cygwin*) - # Convert to unix form, then to dos form, then back to unix form - # but this time dos style (no spaces!) so that the unix form looks - # like /cygdrive/c/PROGRA~1:/cygdr... - sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` - sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` - sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - ;; - *) - sys_lib_search_path_spec="$LIB" - if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then - # It is most probably a Windows format PATH. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # FIXME: find the short name or the path components, as spaces are - # common. (e.g. "Program Files" -> "PROGRA~1") - ;; - esac - - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - dynamic_linker='Win32 link.exe' - ;; - - *) - # Assume MSVC wrapper - library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' - dynamic_linker='Win32 ld.exe' - ;; - esac - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' - - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[23].*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2.*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[01]* | freebsdelf3.[01]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ - freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - *) # from 4.6 on, and DragonFly - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -haiku*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - dynamic_linker="$host_os runtime_loader" - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LIBRARY_PATH - shlibpath_overrides_runpath=yes - sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555, ... - postinstall_cmds='chmod 555 $lib' - # or fails outright, so override atomically: - install_override_mode=555 - ;; - -interix[3-9]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux # correct to gnu/linux during the next big refactor - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - - # Some binutils ld are patched to set DT_RUNPATH - if ${lt_cv_shlibpath_overrides_runpath+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_shlibpath_overrides_runpath=no - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \ - LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\"" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : - lt_cv_shlibpath_overrides_runpath=yes -fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - -fi - - shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath - - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -*nto* | *qnx*) - version_type=qnx - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='ldqnx.so' - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[89] | openbsd2.[89].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -rdos*) - dynamic_linker=no - ;; - -solaris*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -tpf*) - # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -uts4*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 -$as_echo "$dynamic_linker" >&6; } -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" -fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 -$as_echo_n "checking how to hardcode library paths into programs... " >&6; } -hardcode_action_CXX= -if test -n "$hardcode_libdir_flag_spec_CXX" || - test -n "$runpath_var_CXX" || - test "X$hardcode_automatic_CXX" = "Xyes" ; then - - # We can hardcode non-existent directories. - if test "$hardcode_direct_CXX" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no && - test "$hardcode_minus_L_CXX" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action_CXX=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action_CXX=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action_CXX=unsupported -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 -$as_echo "$hardcode_action_CXX" >&6; } - -if test "$hardcode_action_CXX" = relink || - test "$inherit_rpath_CXX" = yes; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi - - - - - - - - fi # test -n "$compiler" - - CC=$lt_save_CC - CFLAGS=$lt_save_CFLAGS - LDCXX=$LD - LD=$lt_save_LD - GCC=$lt_save_GCC - with_gnu_ld=$lt_save_with_gnu_ld - lt_cv_path_LDCXX=$lt_cv_path_LD - lt_cv_path_LD=$lt_save_path_LD - lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld - lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -fi # test "$_lt_caught_CXX_error" != yes - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - - - - - CFLAG_VISIBILITY= - HAVE_VISIBILITY=0 - if test -n "$GCC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the -Werror option is usable" >&5 -$as_echo_n "checking whether the -Werror option is usable... " >&6; } - if ${gl_cv_cc_vis_werror+:} false; then : - $as_echo_n "(cached) " >&6 -else - - gl_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Werror" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - gl_cv_cc_vis_werror=yes -else - gl_cv_cc_vis_werror=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS="$gl_save_CFLAGS" -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_vis_werror" >&5 -$as_echo "$gl_cv_cc_vis_werror" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for simple visibility declarations" >&5 -$as_echo_n "checking for simple visibility declarations... " >&6; } - if ${gl_cv_cc_visibility+:} false; then : - $as_echo_n "(cached) " >&6 -else - - gl_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -fvisibility=hidden" - if test $gl_cv_cc_vis_werror = yes; then - CFLAGS="$CFLAGS -Werror" - fi - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -extern __attribute__((__visibility__("hidden"))) int hiddenvar; - extern __attribute__((__visibility__("default"))) int exportedvar; - extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); - extern __attribute__((__visibility__("default"))) int exportedfunc (void); - void dummyfunc (void) {} - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - gl_cv_cc_visibility=yes -else - gl_cv_cc_visibility=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS="$gl_save_CFLAGS" -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_visibility" >&5 -$as_echo "$gl_cv_cc_visibility" >&6; } - if test $gl_cv_cc_visibility = yes; then - CFLAG_VISIBILITY="-fvisibility=hidden" - HAVE_VISIBILITY=1 - fi - fi - - - -cat >>confdefs.h <<_ACEOF -#define HAVE_VISIBILITY $HAVE_VISIBILITY -_ACEOF - - -if test -n "$CFLAG_VISIBILITY" ; then : - - AM_CPPFLAGS="$AM_CPPFLAGS $CFLAG_VISIBILITY" - CPPFLAGS="$CPPFLAGS $CFLAG_VISIBILITY" - -fi - -# Check whether --enable-silent-rules was given. -if test "${enable_silent_rules+set}" = set; then : - enableval=$enable_silent_rules; -fi - -case $enable_silent_rules in # ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=0;; -esac -am_make=${MAKE-make} -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 -$as_echo_n "checking whether $am_make supports nested variables... " >&6; } -if ${am_cv_make_support_nested_variables+:} false; then : - $as_echo_n "(cached) " >&6 -else - if $as_echo 'TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 -$as_echo "$am_cv_make_support_nested_variables" >&6; } -if test $am_cv_make_support_nested_variables = yes; then - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AM_BACKSLASH='\' - - -for ac_func in gethostbyname -do : - ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" -if test "x$ac_cv_func_gethostbyname" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_GETHOSTBYNAME 1 -_ACEOF - -fi -done - -for ac_func in getaddrinfo -do : - ac_fn_c_check_func "$LINENO" "getaddrinfo" "ac_cv_func_getaddrinfo" -if test "x$ac_cv_func_getaddrinfo" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_GETADDRINFO 1 -_ACEOF - -fi -done - -for ac_func in gettimeofday -do : - ac_fn_c_check_func "$LINENO" "gettimeofday" "ac_cv_func_gettimeofday" -if test "x$ac_cv_func_gettimeofday" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_GETTIMEOFDAY 1 -_ACEOF - -fi -done - -for ac_func in inet_ntoa -do : - ac_fn_c_check_func "$LINENO" "inet_ntoa" "ac_cv_func_inet_ntoa" -if test "x$ac_cv_func_inet_ntoa" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_INET_NTOA 1 -_ACEOF - -fi -done - -for ac_func in memset -do : - ac_fn_c_check_func "$LINENO" "memset" "ac_cv_func_memset" -if test "x$ac_cv_func_memset" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_MEMSET 1 -_ACEOF - -fi -done - -for ac_func in socket -do : - ac_fn_c_check_func "$LINENO" "socket" "ac_cv_func_socket" -if test "x$ac_cv_func_socket" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SOCKET 1 -_ACEOF - -fi -done - -for ac_header in arpa/inet.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "arpa/inet.h" "ac_cv_header_arpa_inet_h" "$ac_includes_default" -if test "x$ac_cv_header_arpa_inet_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_ARPA_INET_H 1 -_ACEOF - -fi - -done - -for ac_header in fcntl.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "fcntl.h" "ac_cv_header_fcntl_h" "$ac_includes_default" -if test "x$ac_cv_header_fcntl_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_FCNTL_H 1 -_ACEOF - -fi - -done - -for ac_header in limits.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "limits.h" "ac_cv_header_limits_h" "$ac_includes_default" -if test "x$ac_cv_header_limits_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIMITS_H 1 -_ACEOF - -fi - -done - -for ac_header in netdb.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "netdb.h" "ac_cv_header_netdb_h" "$ac_includes_default" -if test "x$ac_cv_header_netdb_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_NETDB_H 1 -_ACEOF - -fi - -done - -for ac_header in netinet/in.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "netinet/in.h" "ac_cv_header_netinet_in_h" "$ac_includes_default" -if test "x$ac_cv_header_netinet_in_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_NETINET_IN_H 1 -_ACEOF - -fi - -done - -for ac_header in stddef.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "stddef.h" "ac_cv_header_stddef_h" "$ac_includes_default" -if test "x$ac_cv_header_stddef_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STDDEF_H 1 -_ACEOF - -fi - -done - -for ac_header in sys/ioctl.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "sys/ioctl.h" "ac_cv_header_sys_ioctl_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_ioctl_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SYS_IOCTL_H 1 -_ACEOF - -fi - -done - -for ac_header in sys/socket.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_socket_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SYS_SOCKET_H 1 -_ACEOF - -fi - -done - -for ac_header in sys/time.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_time_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SYS_TIME_H 1 -_ACEOF - -fi - -done - -for ac_header in errno.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "errno.h" "ac_cv_header_errno_h" "$ac_includes_default" -if test "x$ac_cv_header_errno_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_ERRNO_H 1 -_ACEOF - -fi - -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lnetwork" >&5 -$as_echo_n "checking for socket in -lnetwork... " >&6; } -if ${ac_cv_lib_network_socket+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lnetwork $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char socket (); -int -main () -{ -return socket (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_network_socket=yes -else - ac_cv_lib_network_socket=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_network_socket" >&5 -$as_echo "$ac_cv_lib_network_socket" >&6; } -if test "x$ac_cv_lib_network_socket" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBNETWORK 1 -_ACEOF - - LIBS="-lnetwork $LIBS" - -fi - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5 -$as_echo_n "checking size of long long... " >&6; } -if ${ac_cv_sizeof_long_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_long_long" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (long long) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_long_long=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5 -$as_echo "$ac_cv_sizeof_long_long" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long -_ACEOF - - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 -$as_echo_n "checking size of long... " >&6; } -if ${ac_cv_sizeof_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_long" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (long) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_long=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 -$as_echo "$ac_cv_sizeof_long" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG $ac_cv_sizeof_long -_ACEOF - - -ac_fn_c_check_type "$LINENO" "__uint128_t" "ac_cv_type___uint128_t" "$ac_includes_default" -if test "x$ac_cv_type___uint128_t" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE___UINT128_T 1 -_ACEOF - - -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 -$as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if ${ac_cv_c_bigendian+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_c_bigendian=unknown - # See if we're dealing with a universal compiler. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifndef __APPLE_CC__ - not a universal capable compiler - #endif - typedef int dummy; - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - # Check for potential -arch flags. It is not universal unless - # there are at least two -arch flags with different values. - ac_arch= - ac_prev= - for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do - if test -n "$ac_prev"; then - case $ac_word in - i?86 | x86_64 | ppc | ppc64) - if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then - ac_arch=$ac_word - else - ac_cv_c_bigendian=universal - break - fi - ;; - esac - ac_prev= - elif test "x$ac_word" = "x-arch"; then - ac_prev=arch - fi - done -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test $ac_cv_c_bigendian = unknown; then - # See if sys/param.h defines the BYTE_ORDER macro. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - #include - -int -main () -{ -#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ - && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ - && LITTLE_ENDIAN) - bogus endian macros - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - # It does; now see whether it defined to BIG_ENDIAN or not. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - #include - -int -main () -{ -#if BYTE_ORDER != BIG_ENDIAN - not big endian - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_bigendian=yes -else - ac_cv_c_bigendian=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - if test $ac_cv_c_bigendian = unknown; then - # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -int -main () -{ -#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) - bogus endian macros - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - # It does; now see whether it defined to _BIG_ENDIAN or not. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -int -main () -{ -#ifndef _BIG_ENDIAN - not big endian - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_bigendian=yes -else - ac_cv_c_bigendian=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - if test $ac_cv_c_bigendian = unknown; then - # Compile a test program. - if test "$cross_compiling" = yes; then : - # Try to guess by grepping values from an object file. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -short int ascii_mm[] = - { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; - short int ascii_ii[] = - { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; - int use_ascii (int i) { - return ascii_mm[i] + ascii_ii[i]; - } - short int ebcdic_ii[] = - { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; - short int ebcdic_mm[] = - { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; - int use_ebcdic (int i) { - return ebcdic_mm[i] + ebcdic_ii[i]; - } - extern int foo; - -int -main () -{ -return use_ascii (foo) == use_ebcdic (foo); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then - ac_cv_c_bigendian=yes - fi - if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then - if test "$ac_cv_c_bigendian" = unknown; then - ac_cv_c_bigendian=no - else - # finding both strings is unlikely to happen, but who knows? - ac_cv_c_bigendian=unknown - fi - fi -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ - - /* Are we little or big endian? From Harbison&Steele. */ - union - { - long int l; - char c[sizeof (long int)]; - } u; - u.l = 1; - return u.c[sizeof (long int) - 1] == 1; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_c_bigendian=no -else - ac_cv_c_bigendian=yes -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 -$as_echo "$ac_cv_c_bigendian" >&6; } - case $ac_cv_c_bigendian in #( - yes) - $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h -;; #( - no) - ;; #( - universal) - -$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h - - ;; #( - *) - as_fn_error $? "unknown endianness - presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; - esac - -# mktime check takes forever on some systems, if time supported it would be -# highly unusual for mktime to be missing -#AC_FUNC_MKTIME - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 -$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } -if ${am_cv_prog_cc_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF - # Make sure it works both with $CC and with simple cc. - # Following AC_PROG_CC_C_O, we do the test twice because some - # compilers refuse to overwrite an existing .o file with -o, - # though they will create one. - am_cv_prog_cc_c_o=yes - for am_i in 1 2; do - if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 - ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } \ - && test -f conftest2.$ac_objext; then - : OK - else - am_cv_prog_cc_c_o=no - break - fi - done - rm -f core conftest* - unset am_i -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 -$as_echo "$am_cv_prog_cc_c_o" >&6; } -if test "$am_cv_prog_cc_c_o" != yes; then - # Losing compiler, so override with the script. - # FIXME: It is wrong to rewrite CC. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__CC in this case, - # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" - CC="$am_aux_dir/compile $CC" -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -depcc="$CC" am_compiler_list= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if ${am_cv_CC_dependencies_compiler_type+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CC_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - am__universal=false - case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with '-c' and '-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CC_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CC_dependencies_compiler_type=none -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } -CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then - am__fastdepCC_TRUE= - am__fastdepCC_FALSE='#' -else - am__fastdepCC_TRUE='#' - am__fastdepCC_FALSE= -fi - - -if test "x$CC" != xcc; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 -$as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5 -$as_echo_n "checking whether cc understands -c and -o together... " >&6; } -fi -set dummy $CC; ac_cc=`$as_echo "$2" | - sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` -if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -# Make sure it works both with $CC and with simple cc. -# We do the test twice because some compilers refuse to overwrite an -# existing .o file with -o, though they will create one. -ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' -rm -f conftest2.* -if { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && - test -f conftest2.$ac_objext && { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; -then - eval ac_cv_prog_cc_${ac_cc}_c_o=yes - if test "x$CC" != xcc; then - # Test first that cc exists at all. - if { ac_try='cc -c conftest.$ac_ext >&5' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' - rm -f conftest2.* - if { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && - test -f conftest2.$ac_objext && { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; - then - # cc works too. - : - else - # cc exists but doesn't like -o. - eval ac_cv_prog_cc_${ac_cc}_c_o=no - fi - fi - fi -else - eval ac_cv_prog_cc_${ac_cc}_c_o=no -fi -rm -f core conftest* - -fi -if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -$as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h - -fi - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -if test -z "$CXX"; then - if test -n "$CCC"; then - CXX=$CCC - else - if test -n "$ac_tool_prefix"; then - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CXX=$ac_cv_prog_CXX -if test -n "$CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 -$as_echo "$CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CXX" && break - done -fi -if test -z "$CXX"; then - ac_ct_CXX=$CXX - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CXX="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 -$as_echo "$ac_ct_CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CXX" && break -done - - if test "x$ac_ct_CXX" = x; then - CXX="g++" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_ct_CXX - fi -fi - - fi -fi -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 -$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if ${ac_cv_cxx_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_cxx_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 -$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GXX=yes -else - GXX= -fi -ac_test_CXXFLAGS=${CXXFLAGS+set} -ac_save_CXXFLAGS=$CXXFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 -$as_echo_n "checking whether $CXX accepts -g... " >&6; } -if ${ac_cv_prog_cxx_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_cxx_werror_flag=$ac_cxx_werror_flag - ac_cxx_werror_flag=yes - ac_cv_prog_cxx_g=no - CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_prog_cxx_g=yes -else - CXXFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - -else - ac_cxx_werror_flag=$ac_save_cxx_werror_flag - CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_prog_cxx_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_cxx_werror_flag=$ac_save_cxx_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 -$as_echo "$ac_cv_prog_cxx_g" >&6; } -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS=$ac_save_CXXFLAGS -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -depcc="$CXX" am_compiler_list= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if ${am_cv_CXX_dependencies_compiler_type+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CXX_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - am__universal=false - case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with '-c' and '-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CXX_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CXX_dependencies_compiler_type=none -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } -CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then - am__fastdepCXX_TRUE= - am__fastdepCXX_FALSE='#' -else - am__fastdepCXX_TRUE='#' - am__fastdepCXX_FALSE= -fi - - - -ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = xyes; then : - -else - -cat >>confdefs.h <<_ACEOF -#define size_t unsigned int -_ACEOF - -fi - -ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t" -case $ac_cv_c_uint8_t in #( - no|yes) ;; #( - *) - -$as_echo "#define _UINT8_T 1" >>confdefs.h - - -cat >>confdefs.h <<_ACEOF -#define uint8_t $ac_cv_c_uint8_t -_ACEOF -;; - esac - -# By default we simply use the C compiler to build assembly code. - -test "${CCAS+set}" = set || CCAS=$CC -test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS - - - -depcc="$CCAS" am_compiler_list= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if ${am_cv_CCAS_dependencies_compiler_type+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CCAS_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - am__universal=false - - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with '-c' and '-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CCAS_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CCAS_dependencies_compiler_type=none -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CCAS_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CCAS_dependencies_compiler_type" >&6; } -CCASDEPMODE=depmode=$am_cv_CCAS_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CCAS_dependencies_compiler_type" = gcc3; then - am__fastdepCCAS_TRUE= - am__fastdepCCAS_FALSE='#' -else - am__fastdepCCAS_TRUE='#' - am__fastdepCCAS_FALSE= -fi - - - -LIBM= -case $host in -*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) - # These system don't have libm, or don't need it - ;; -*-ncr-sysv4.3*) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _mwvalidcheckl in -lmw" >&5 -$as_echo_n "checking for _mwvalidcheckl in -lmw... " >&6; } -if ${ac_cv_lib_mw__mwvalidcheckl+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lmw $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char _mwvalidcheckl (); -int -main () -{ -return _mwvalidcheckl (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_mw__mwvalidcheckl=yes -else - ac_cv_lib_mw__mwvalidcheckl=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mw__mwvalidcheckl" >&5 -$as_echo "$ac_cv_lib_mw__mwvalidcheckl" >&6; } -if test "x$ac_cv_lib_mw__mwvalidcheckl" = xyes; then : - LIBM="-lmw" -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 -$as_echo_n "checking for cos in -lm... " >&6; } -if ${ac_cv_lib_m_cos+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lm $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char cos (); -int -main () -{ -return cos (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_m_cos=yes -else - ac_cv_lib_m_cos=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 -$as_echo "$ac_cv_lib_m_cos" >&6; } -if test "x$ac_cv_lib_m_cos" = xyes; then : - LIBM="$LIBM -lm" -fi - - ;; -*) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 -$as_echo_n "checking for cos in -lm... " >&6; } -if ${ac_cv_lib_m_cos+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lm $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char cos (); -int -main () -{ -return cos (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_m_cos=yes -else - ac_cv_lib_m_cos=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 -$as_echo "$ac_cv_lib_m_cos" >&6; } -if test "x$ac_cv_lib_m_cos" = xyes; then : - LIBM="-lm" -fi - - ;; -esac - - - -OPTIMIZE_CFLAGS="-Os -fomit-frame-pointer" -OPTIMIZE_FAST_CFLAGS="-O2 -fomit-frame-pointer" -OPTIMIZE_HUGE_CFLAGS="-funroll-loops -DTFM_SMALL_SET -DTFM_HUGE_SET" -DEBUG_CFLAGS="-g -DDEBUG -DDEBUG_WOLFSSL" - -thread_ls_on=no -# Thread local storage - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for thread local storage (TLS) class" >&5 -$as_echo_n "checking for thread local storage (TLS) class... " >&6; } - if ${ac_cv_tls+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_tls_keywords="__thread __declspec(thread) none" - for ax_tls_keyword in $ax_tls_keywords; do - case $ax_tls_keyword in #( - none) : - ac_cv_tls=none ; break ;; #( - *) : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - static void - foo(void) { - static $ax_tls_keyword int bar; - exit(1); - } -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_tls=$ax_tls_keyword ; break -else - ac_cv_tls=none - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; -esac - done - -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_tls" >&5 -$as_echo "$ac_cv_tls" >&6; } - - if test "$ac_cv_tls" != "none"; then : - -cat >>confdefs.h <<_ACEOF -#define TLS $ac_cv_tls -_ACEOF - - - AM_CFLAGS="$AM_CFLAGS -DHAVE_THREAD_LS" - thread_ls_on=yes - -else - : - -fi - - - -# DEBUG - # Check whether --enable-debug was given. -if test "${enable_debug+set}" = set; then : - enableval=$enable_debug; ax_enable_debug=$enableval -else - ax_enable_debug=no -fi - - - if test "x$ax_enable_debug" = xyes; then : - -$as_echo "#define DEBUG 1" >>confdefs.h - -else - - -$as_echo "#define DEBUG 0" >>confdefs.h - -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for debug" >&5 -$as_echo_n "checking for debug... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_enable_debug" >&5 -$as_echo "$ax_enable_debug" >&6; } - if test "x${ax_enable_debug}" = xyes; then - DEBUG_TRUE= - DEBUG_FALSE='#' -else - DEBUG_TRUE='#' - DEBUG_FALSE= -fi - -if test "$ax_enable_debug" = "yes"; then : - AM_CFLAGS="$DEBUG_CFLAGS $AM_CFLAGS" -else - AM_CFLAGS="$AM_CFLAGS -DNDEBUG" -fi - - -# SINGLE THREADED -# Check whether --enable-singlethreaded was given. -if test "${enable_singlethreaded+set}" = set; then : - enableval=$enable_singlethreaded; ENABLED_SINGLETHREADED=$enableval -else - ENABLED_SINGLETHREADED=no -fi - - - - if test x"$CC" = xclang; then - wolfssl_darwin_clang=yes - elif test x"$CC" = x || test x"$CC" = xgcc; then - if /usr/bin/gcc -v 2>&1 | grep 'clang' >/dev/null 2>&1; then - wolfssl_darwin_clang=yes - fi - fi - -if test "x$ENABLED_SINGLETHREADED" = "xno" ; then : - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ax_pthread_ok=no - -# We used to check for pthread.h first, but this fails if pthread.h -# requires special compiler flags (e.g. on True64 or Sequent). -# It gets checked for in the link test anyway. - -# First of all, check if the user has set any of the PTHREAD_LIBS, -# etcetera environment variables, and if threads linking works using -# them: -if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5 -$as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char pthread_join (); -int -main () -{ -return pthread_join (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ax_pthread_ok=yes -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5 -$as_echo "$ax_pthread_ok" >&6; } - if test x"$ax_pthread_ok" = xno; then - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" - fi - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" -fi - -# We must check for the threads library under a number of different -# names; the ordering is very important because some systems -# (e.g. DEC) have both -lpthread and -lpthreads, where one of the -# libraries is broken (non-POSIX). - -# Create a list of thread flags to try. Items starting with a "-" are -# C compiler flags, and other items are library names, except for "none" -# which indicates that we try without any flags at all, and "pthread-config" -# which is a program returning the flags for the Pth emulation library. - -ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" - -# The ordering *is* (sometimes) important. Some notes on the -# individual items follow: - -# pthreads: AIX (must check this before -lpthread) -# none: in case threads are in libc; should be tried before -Kthread and -# other compiler flags to prevent continual compiler warnings -# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) -# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) -# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) -# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) -# -pthreads: Solaris/gcc -# -mthreads: Mingw32/gcc, Lynx/gcc -# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it -# doesn't hurt to check since this sometimes defines pthreads too; -# also defines -D_REENTRANT) -# ... -mt is also the pthreads flag for HP/aCC -# pthread: Linux, etcetera -# --thread-safe: KAI C++ -# pthread-config: use pthread-config program (for GNU Pth library) - -case ${host_os} in - solaris*) - - # On Solaris (at least, for some versions), libc contains stubbed - # (non-functional) versions of the pthreads routines, so link-based - # tests will erroneously succeed. (We need to link with -pthreads/-mt/ - # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather - # a function called by this macro, so we could check for that, but - # who knows whether they'll stub that too in a future libc.) So, - # we'll just look for -pthreads and -lpthread first: - - ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" - ;; - - darwin*) - - if test x"$wolfssl_darwin_clang" = x"yes"; then : - ax_pthread_flags="$ax_pthread_flags" -else - ax_pthread_flags="-pthread $ax_pthread_flags" -fi - ;; -esac - -if test x"$ax_pthread_ok" = xno; then -for flag in $ax_pthread_flags; do - - case $flag in - none) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5 -$as_echo_n "checking whether pthreads work without any flags... " >&6; } - ;; - - -*) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5 -$as_echo_n "checking whether pthreads work with $flag... " >&6; } - PTHREAD_CFLAGS="$flag" - ;; - - pthread-config) - # Extract the first word of "pthread-config", so it can be a program name with args. -set dummy pthread-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ax_pthread_config+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ax_pthread_config"; then - ac_cv_prog_ax_pthread_config="$ax_pthread_config" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ax_pthread_config="yes" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_prog_ax_pthread_config" && ac_cv_prog_ax_pthread_config="no" -fi -fi -ax_pthread_config=$ac_cv_prog_ax_pthread_config -if test -n "$ax_pthread_config"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_config" >&5 -$as_echo "$ax_pthread_config" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - if test x"$ax_pthread_config" = xno; then continue; fi - PTHREAD_CFLAGS="`pthread-config --cflags`" - PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" - ;; - - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5 -$as_echo_n "checking for the pthreads library -l$flag... " >&6; } - PTHREAD_LIBS="-l$flag" - ;; - esac - - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - - # Check for various functions. We must include pthread.h, - # since some functions may be macros. (On the Sequent, we - # need a special flag -Kthread to make this header compile.) - # We check for pthread_join because it is in -lpthread on IRIX - # while pthread_create is in libc. We check for pthread_attr_init - # due to DEC craziness with -lpthreads. We check for - # pthread_cleanup_push because it is one of the few pthread - # functions on Solaris that doesn't have a non-functional libc stub. - # We try pthread_create on general principles. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - static void routine(void *a) { a = 0; } - static void *start_routine(void *a) { return a; } -int -main () -{ -pthread_t th; pthread_attr_t attr; - pthread_create(&th, 0, start_routine, 0); - pthread_join(th, 0); - pthread_attr_init(&attr); - pthread_cleanup_push(routine, 0); - pthread_cleanup_pop(0) /* ; */ - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ax_pthread_ok=yes -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5 -$as_echo "$ax_pthread_ok" >&6; } - if test "x$ax_pthread_ok" = xyes; then - break; - fi - - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" -done -fi - -# Various other checks: -if test "x$ax_pthread_ok" = xyes; then - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - - # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5 -$as_echo_n "checking for joinable pthread attribute... " >&6; } - attr_name=unknown - for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -int attr = $attr; return attr /* ; */ - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - attr_name=$attr; break -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - done - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5 -$as_echo "$attr_name" >&6; } - if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then - -cat >>confdefs.h <<_ACEOF -#define PTHREAD_CREATE_JOINABLE $attr_name -_ACEOF - - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5 -$as_echo_n "checking if more special flags are required for pthreads... " >&6; } - flag=no - case ${host_os} in - aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";; - osf* | hpux*) flag="-D_REENTRANT";; - solaris*) - if test "$GCC" = "yes"; then - flag="-D_REENTRANT" - else - flag="-mt -D_REENTRANT" - fi - ;; - esac - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5 -$as_echo "${flag}" >&6; } - if test "x$flag" != xno; then - PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PTHREAD_PRIO_INHERIT" >&5 -$as_echo_n "checking for PTHREAD_PRIO_INHERIT... " >&6; } -if ${ax_cv_PTHREAD_PRIO_INHERIT+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #include -int -main () -{ -int i = PTHREAD_PRIO_INHERIT; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ax_cv_PTHREAD_PRIO_INHERIT=yes -else - ax_cv_PTHREAD_PRIO_INHERIT=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_PRIO_INHERIT" >&5 -$as_echo "$ax_cv_PTHREAD_PRIO_INHERIT" >&6; } - if test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"; then : - -$as_echo "#define HAVE_PTHREAD_PRIO_INHERIT 1" >>confdefs.h - -fi - - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - # More AIX lossage: compile with *_r variant - if test "x$GCC" != xyes; then - case $host_os in - aix*) - case "x/$CC" in #( - x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6) : - #handle absolute path differently from PATH based program lookup - case "x$CC" in #( - x/*) : - if as_fn_executable_p ${CC}_r; then : - PTHREAD_CC="${CC}_r" -fi ;; #( - *) : - for ac_prog in ${CC}_r -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_PTHREAD_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PTHREAD_CC"; then - ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_PTHREAD_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PTHREAD_CC=$ac_cv_prog_PTHREAD_CC -if test -n "$PTHREAD_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5 -$as_echo "$PTHREAD_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$PTHREAD_CC" && break -done -test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" - ;; -esac ;; #( - *) : - ;; -esac - ;; - esac - fi -fi - -test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" - - - - - -# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -if test x"$ax_pthread_ok" = xyes; then - - -$as_echo "#define HAVE_PTHREAD 1" >>confdefs.h - - AM_CFLAGS="-D_POSIX_THREADS $AM_CFLAGS $PTHREAD_CFLAGS" - LIBS="$LIBS $PTHREAD_LIBS" - - : -else - ax_pthread_ok=no - - ENABLED_SINGLETHREADED=yes - -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -fi - -if test "x$ENABLED_SINGLETHREADED" = "xyes" ; then : - AM_CFLAGS="-DSINGLE_THREADED $AM_CFLAGS" -fi - - -# DTLS -# Check whether --enable-dtls was given. -if test "${enable_dtls+set}" = set; then : - enableval=$enable_dtls; ENABLED_DTLS=$enableval -else - ENABLED_DTLS=no - -fi - -if test "$ENABLED_DTLS" = "yes" -then - AM_CFLAGS="-DWOLFSSL_DTLS $AM_CFLAGS" -fi - - -# OPENSSL Extra Compatibility -# Check whether --enable-opensslextra was given. -if test "${enable_opensslextra+set}" = set; then : - enableval=$enable_opensslextra; ENABLED_OPENSSLEXTRA=$enableval -else - ENABLED_OPENSSLEXTRA=no - -fi - -if test "$ENABLED_OPENSSLEXTRA" = "yes" -then - AM_CFLAGS="-DOPENSSL_EXTRA $AM_CFLAGS" -fi - -if test "$ENABLED_OPENSSLEXTRA" = "yes" && test "$ENABLED_SMALL" = "yes" -then - as_fn_error $? "cannot enable small and opensslextra, only one or the other." "$LINENO" 5 -fi - - -# High Strength Build -# Check whether --enable-maxstrength was given. -if test "${enable_maxstrength+set}" = set; then : - enableval=$enable_maxstrength; ENABLED_MAXSTRENGTH=$enableval -else - ENABLED_MAXSTRENGTH=no -fi - - - -# IPv6 Test Apps -# Check whether --enable-ipv6 was given. -if test "${enable_ipv6+set}" = set; then : - enableval=$enable_ipv6; ENABLED_IPV6=$enableval -else - ENABLED_IPV6=no - -fi - - -if test "$ENABLED_IPV6" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DTEST_IPV6" -fi - - if test "x$ENABLED_IPV6" = "xyes"; then - BUILD_IPV6_TRUE= - BUILD_IPV6_FALSE='#' -else - BUILD_IPV6_TRUE='#' - BUILD_IPV6_FALSE= -fi - - - -# Fortress build -# Check whether --enable-fortress was given. -if test "${enable_fortress+set}" = set; then : - enableval=$enable_fortress; ENABLED_FORTRESS=$enableval -else - ENABLED_FORTRESS=no - -fi - - -if test "$ENABLED_FORTRESS" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DFORTRESS -DWOLFSSL_ALWAYS_VERIFY_CB -DOPENSSL_EXTRA -DWOLFSSL_DES_ECB -DWOLFSSL_AES_COUNTER -DWOLFSSL_AES_DIRECT -DWOLFSSL_DER_LOAD -DWOLFSSL_SHA512 -DWOLFSSL_SHA384 -DWOLFSSL_KEY_GEN" -fi - - -# ssl bump build -# Check whether --enable-bump was given. -if test "${enable_bump+set}" = set; then : - enableval=$enable_bump; ENABLED_BUMP=$enableval -else - ENABLED_BUMP=no - -fi - - -if test "$ENABLED_BUMP" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DLARGE_STATIC_BUFFERS -DWOLFSSL_CERT_GEN -DWOLFSSL_KEY_GEN -DHUGE_SESSION_CACHE -DOPENSSL_EXTRA -DFP_MAX_BITS=8192 -DWOLFSSL_DER_LOAD -DWOLFSSL_ALT_NAMES -DWOLFSSL_TEST_CERT" -fi - -ENABLED_SLOWMATH="yes" - -# lean psk build -# Check whether --enable-leanpsk was given. -if test "${enable_leanpsk+set}" = set; then : - enableval=$enable_leanpsk; ENABLED_LEANPSK=$enableval -else - ENABLED_LEANPSK=no - -fi - - -if test "$ENABLED_LEANPSK" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_LEANPSK -DHAVE_NULL_CIPHER -DSINGLE_THREADED -DNO_AES -DNO_FILESYSTEM -DNO_RABBIT -DNO_RSA -DNO_DSA -DNO_DH -DNO_CERTS -DNO_PWDBASED -DNO_DES3 -DNO_MD4 -DNO_MD5 -DNO_ERROR_STRINGS -DNO_OLD_TLS -DNO_RC4 -DNO_WRITEV -DNO_SESSION_CACHE -DNO_DEV_RANDOM -DWOLFSSL_USER_IO -DNO_SHA -DUSE_SLOW_SHA" - ENABLED_SLOWMATH="no" - ENABLED_SINGLETHREADED="yes" -fi - - if test "x$ENABLED_LEANPSK" = "xyes"; then - BUILD_LEANPSK_TRUE= - BUILD_LEANPSK_FALSE='#' -else - BUILD_LEANPSK_TRUE='#' - BUILD_LEANPSK_FALSE= -fi - - - -# big cache -# Check whether --enable-bigcache was given. -if test "${enable_bigcache+set}" = set; then : - enableval=$enable_bigcache; ENABLED_BIGCACHE=$enableval -else - ENABLED_BIGCACHE=no - -fi - - -if test "$ENABLED_BIGCACHE" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DBIG_SESSION_CACHE" -fi - - -# HUGE cache -# Check whether --enable-hugecache was given. -if test "${enable_hugecache+set}" = set; then : - enableval=$enable_hugecache; ENABLED_HUGECACHE=$enableval -else - ENABLED_HUGECACHE=no - -fi - - -if test "$ENABLED_HUGECACHE" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHUGE_SESSION_CACHE" -fi - - -# SMALL cache -# Check whether --enable-smallcache was given. -if test "${enable_smallcache+set}" = set; then : - enableval=$enable_smallcache; ENABLED_SMALLCACHE=$enableval -else - ENABLED_SMALLCACHE=no - -fi - - -if test "$ENABLED_SMALLCACHE" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DSMALL_SESSION_CACHE" -fi - - -# Persistent session cache -# Check whether --enable-savesession was given. -if test "${enable_savesession+set}" = set; then : - enableval=$enable_savesession; ENABLED_SAVESESSION=$enableval -else - ENABLED_SAVESESSION=no - -fi - - -if test "$ENABLED_SAVESESSION" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DPERSIST_SESSION_CACHE" -fi - - -# Persistent cert cache -# Check whether --enable-savecert was given. -if test "${enable_savecert+set}" = set; then : - enableval=$enable_savecert; ENABLED_SAVECERT=$enableval -else - ENABLED_SAVECERT=no - -fi - - -if test "$ENABLED_SAVECERT" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DPERSIST_CERT_CACHE" -fi - - -# Atomic User Record Layer -# Check whether --enable-atomicuser was given. -if test "${enable_atomicuser+set}" = set; then : - enableval=$enable_atomicuser; ENABLED_ATOMICUSER=$enableval -else - ENABLED_ATOMICUSER=no - -fi - - -if test "$ENABLED_ATOMICUSER" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DATOMIC_USER" -fi - - -# Public Key Callbacks -# Check whether --enable-pkcallbacks was given. -if test "${enable_pkcallbacks+set}" = set; then : - enableval=$enable_pkcallbacks; ENABLED_PKCALLBACKS=$enableval -else - ENABLED_PKCALLBACKS=no - -fi - - -if test "$ENABLED_PKCALLBACKS" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_PK_CALLBACKS" -fi - - -# SNIFFER -# Check whether --enable-sniffer was given. -if test "${enable_sniffer+set}" = set; then : - enableval=$enable_sniffer; ENABLED_SNIFFER=$enableval -else - ENABLED_SNIFFER=no - -fi - - -# sniffer does't work in maxstrength mode -if test "$ENABLED_SNIFFER" = "yes" && test "$ENABLED_MAXSTRENGTH" = "yes" -then - as_fn_error $? "cannot enable maxstrength in sniffer mode." "$LINENO" 5 -fi - -ENABLED_SNIFFTEST=no -if test "x$ENABLED_SNIFFER" = "xyes" ; then : - - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SNIFFER -DOPENSSL_EXTRA" - for ac_header in pcap/pcap.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "pcap/pcap.h" "ac_cv_header_pcap_pcap_h" "$ac_includes_default" -if test "x$ac_cv_header_pcap_pcap_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_PCAP_PCAP_H 1 -_ACEOF - ENABLED_SNIFFTEST=yes -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable sniffer test without having libpcap available." >&5 -$as_echo "$as_me: WARNING: cannot enable sniffer test without having libpcap available." >&2;} - -fi - -done - - -fi - - if test "x$ENABLED_SNIFFER" = "xyes" ; then - BUILD_SNIFFER_TRUE= - BUILD_SNIFFER_FALSE='#' -else - BUILD_SNIFFER_TRUE='#' - BUILD_SNIFFER_FALSE= -fi - - if test "x$ENABLED_SNIFFTEST" = "xyes" ; then - BUILD_SNIFFTEST_TRUE= - BUILD_SNIFFTEST_FALSE='#' -else - BUILD_SNIFFTEST_TRUE='#' - BUILD_SNIFFTEST_FALSE= -fi - - -# AES-GCM -# Check whether --enable-aesgcm was given. -if test "${enable_aesgcm+set}" = set; then : - enableval=$enable_aesgcm; ENABLED_AESGCM=$enableval -else - ENABLED_AESGCM=yes - -fi - - -# lean psk does't need gcm -if test "$ENABLED_LEANPSK" = "yes" -then - ENABLED_AESGCM=no -fi - -if test "$ENABLED_AESGCM" = "word32" -then - AM_CFLAGS="$AM_CFLAGS -DGCM_WORD32" - ENABLED_AESGCM=yes -fi - -if test "$ENABLED_AESGCM" = "small" -then - AM_CFLAGS="$AM_CFLAGS -DGCM_SMALL" - ENABLED_AESGCM=yes -fi - -if test "$ENABLED_AESGCM" = "table" -then - AM_CFLAGS="$AM_CFLAGS -DGCM_TABLE" - ENABLED_AESGCM=yes -fi - -if test "$ENABLED_AESGCM" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_AESGCM" -fi - - if test "x$ENABLED_AESGCM" = "xyes"; then - BUILD_AESGCM_TRUE= - BUILD_AESGCM_FALSE='#' -else - BUILD_AESGCM_TRUE='#' - BUILD_AESGCM_FALSE= -fi - - - -# AES-CCM -# Check whether --enable-aesccm was given. -if test "${enable_aesccm+set}" = set; then : - enableval=$enable_aesccm; ENABLED_AESCCM=$enableval -else - ENABLED_AESCCM=no - -fi - - -if test "$ENABLED_AESCCM" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_AESCCM" -fi - - if test "x$ENABLED_AESCCM" = "xyes"; then - BUILD_AESCCM_TRUE= - BUILD_AESCCM_FALSE='#' -else - BUILD_AESCCM_TRUE='#' - BUILD_AESCCM_FALSE= -fi - - - -# AES-NI -# Check whether --enable-aesni was given. -if test "${enable_aesni+set}" = set; then : - enableval=$enable_aesni; ENABLED_AESNI=$enableval -else - ENABLED_AESNI=no - -fi - - -# INTEL ASM -# Check whether --enable-intelasm was given. -if test "${enable_intelasm+set}" = set; then : - enableval=$enable_intelasm; ENABLED_INTELASM=$enableval -else - ENABLED_INTELASM=no - -fi - - -if test "$ENABLED_AESNI" = "yes" || test "$ENABLED_INTELASM" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_AESNI" - if test "$GCC" = "yes" - then - # GCC needs these flags, icc doesn't - # opt levels greater than 2 may cause problems on systems w/o aesni - if test "$CC" != "icc" - then - AM_CFLAGS="$AM_CFLAGS -maes -msse4" - fi - fi -fi - -if test "$ENABLED_INTELASM" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_INTEL_RDGEN -DUSE_INTEL_SPEEDUP" - ENABLED_AESNI=yes -fi - - if test "x$ENABLED_AESNI" = "xyes"; then - BUILD_AESNI_TRUE= - BUILD_AESNI_FALSE='#' -else - BUILD_AESNI_TRUE='#' - BUILD_AESNI_FALSE= -fi - - - -# Camellia -# Check whether --enable-camellia was given. -if test "${enable_camellia+set}" = set; then : - enableval=$enable_camellia; ENABLED_CAMELLIA=$enableval -else - ENABLED_CAMELLIA=no - -fi - - -if test "$ENABLED_CAMELLIA" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_CAMELLIA" -fi - - if test "x$ENABLED_CAMELLIA" = "xyes"; then - BUILD_CAMELLIA_TRUE= - BUILD_CAMELLIA_FALSE='#' -else - BUILD_CAMELLIA_TRUE='#' - BUILD_CAMELLIA_FALSE= -fi - - - -# MD2 -# Check whether --enable-md2 was given. -if test "${enable_md2+set}" = set; then : - enableval=$enable_md2; ENABLED_MD2=$enableval -else - ENABLED_MD2=no - -fi - - -if test "$ENABLED_BUMP" = "yes" -then - ENABLED_MD2="yes" -fi - -if test "$ENABLED_MD2" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_MD2" -fi - - if test "x$ENABLED_MD2" = "xyes"; then - BUILD_MD2_TRUE= - BUILD_MD2_FALSE='#' -else - BUILD_MD2_TRUE='#' - BUILD_MD2_FALSE= -fi - - - -# NULL CIPHER -# Check whether --enable-nullcipher was given. -if test "${enable_nullcipher+set}" = set; then : - enableval=$enable_nullcipher; ENABLED_NULL_CIPHER=$enableval -else - ENABLED_NULL_CIPHER=no - -fi - - -if test "$ENABLED_NULL_CIPHER" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_NULL_CIPHER" -fi - -# RIPEMD -# Check whether --enable-ripemd was given. -if test "${enable_ripemd+set}" = set; then : - enableval=$enable_ripemd; ENABLED_RIPEMD=$enableval -else - ENABLED_RIPEMD=no - -fi - - -if test "$ENABLED_RIPEMD" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_RIPEMD" -fi - - if test "x$ENABLED_RIPEMD" = "xyes"; then - BUILD_RIPEMD_TRUE= - BUILD_RIPEMD_FALSE='#' -else - BUILD_RIPEMD_TRUE='#' - BUILD_RIPEMD_FALSE= -fi - - - -# BLAKE2 -# Check whether --enable-blake2 was given. -if test "${enable_blake2+set}" = set; then : - enableval=$enable_blake2; ENABLED_BLAKE2=$enableval -else - ENABLED_BLAKE2=no - -fi - - -if test "$ENABLED_BLAKE2" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_BLAKE2" -fi - - if test "x$ENABLED_BLAKE2" = "xyes"; then - BUILD_BLAKE2_TRUE= - BUILD_BLAKE2_FALSE='#' -else - BUILD_BLAKE2_TRUE='#' - BUILD_BLAKE2_FALSE= -fi - - - -# set sha512 default -SHA512_DEFAULT=no -if test "$host_cpu" = "x86_64" -then -SHA512_DEFAULT=yes -fi - -# SHA512 -# Check whether --enable-sha512 was given. -if test "${enable_sha512+set}" = set; then : - enableval=$enable_sha512; ENABLED_SHA512=$enableval -else - ENABLED_SHA512=$SHA512_DEFAULT - -fi - - -# lean psk does't need sha512 -if test "$ENABLED_LEANPSK" = "yes" -then - ENABLED_SHA512=no -fi - -if test "$ENABLED_SHA512" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SHA512 -DWOLFSSL_SHA384" -fi - -if test "$ENABLED_FORTRESS" = "yes" -then - ENABLED_SHA512="yes" -fi - - - if test "x$ENABLED_SHA512" = "xyes"; then - BUILD_SHA512_TRUE= - BUILD_SHA512_FALSE='#' -else - BUILD_SHA512_TRUE='#' - BUILD_SHA512_FALSE= -fi - - - -# SESSION CERTS -# Check whether --enable-sessioncerts was given. -if test "${enable_sessioncerts+set}" = set; then : - enableval=$enable_sessioncerts; ENABLED_SESSIONCERTS=$enableval -else - ENABLED_SESSIONCERTS=no - -fi - - -if test "$ENABLED_SESSIONCERTS" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DSESSION_CERTS" -fi - - -# KEY GENERATION -# Check whether --enable-keygen was given. -if test "${enable_keygen+set}" = set; then : - enableval=$enable_keygen; ENABLED_KEYGEN=$enableval -else - ENABLED_KEYGEN=no - -fi - - -if test "$ENABLED_KEYGEN" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_KEY_GEN" -fi - - -# CERT GENERATION -# Check whether --enable-certgen was given. -if test "${enable_certgen+set}" = set; then : - enableval=$enable_certgen; ENABLED_CERTGEN=$enableval -else - ENABLED_CERTGEN=no - -fi - - -if test "$ENABLED_CERTGEN" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CERT_GEN" -fi - - -# CERT REQUEST GENERATION -# Check whether --enable-certreq was given. -if test "${enable_certreq+set}" = set; then : - enableval=$enable_certreq; ENABLED_CERTREQ=$enableval -else - ENABLED_CERTREQ=no - -fi - - -if test "$ENABLED_CERTREQ" = "yes" -then - if test "$ENABLED_CERTGEN" = "no" - then - as_fn_error $? "cannot enable certreq without enabling certgen." "$LINENO" 5 - fi - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CERT_REQ" -fi - - -# SEP -# Check whether --enable-sep was given. -if test "${enable_sep+set}" = set; then : - enableval=$enable_sep; ENABLED_SEP=$enableval -else - ENABLED_SEP=no - -fi - -if test "$ENABLED_SEP" = "yes" -then - AM_CFLAGS="-DWOLFSSL_SEP -DKEEP_PEER_CERT $AM_CFLAGS" -fi - - -# HKDF -# Check whether --enable-hkdf was given. -if test "${enable_hkdf+set}" = set; then : - enableval=$enable_hkdf; ENABLED_HKDF=$enableval -else - ENABLED_HKDF=no - -fi - -if test "$ENABLED_HKDF" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_HKDF" -fi - - -# DSA -# Check whether --enable-dsa was given. -if test "${enable_dsa+set}" = set; then : - enableval=$enable_dsa; ENABLED_DSA=$enableval -else - ENABLED_DSA=no - -fi - - -if test "$ENABLED_DSA" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_DSA" -fi - - if test "x$ENABLED_DSA" = "xyes"; then - BUILD_DSA_TRUE= - BUILD_DSA_FALSE='#' -else - BUILD_DSA_TRUE='#' - BUILD_DSA_FALSE= -fi - - - -# set ecc default -ECC_DEFAULT=no - -if test "$host_cpu" = "x86_64" -then -ECC_DEFAULT=yes -fi - -# ECC -# Check whether --enable-ecc was given. -if test "${enable_ecc+set}" = set; then : - enableval=$enable_ecc; ENABLED_ECC=$enableval -else - ENABLED_ECC=$ECC_DEFAULT - -fi - - -# lean psk does't need ecc -if test "$ENABLED_LEANPSK" = "yes" -then - ENABLED_ECC=no -fi - -if test "$ENABLED_ECC" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC -DTFM_ECC256 -DECC_SHAMIR" -fi - - if test "x$ENABLED_ECC" = "xyes"; then - BUILD_ECC_TRUE= - BUILD_ECC_FALSE='#' -else - BUILD_ECC_TRUE='#' - BUILD_ECC_FALSE= -fi - - - -if test "$ENABLED_ECC" = "yes" && test "$ENABLED_SMALL" = "yes" -then - as_fn_error $? "cannot enable ecc and small, ecc requires TLS which small turns off." "$LINENO" 5 -fi - - -# for using memory optimization setting on both curve25519 and ed25519 -ENABLED_CURVED25519_SMALL=no - -# CURVE25519 -# Check whether --enable-curve25519 was given. -if test "${enable_curve25519+set}" = set; then : - enableval=$enable_curve25519; ENABLED_CURVE25519=$enableval -else - ENABLED_CURVE25519=no - -fi - - - -if test "$ENABLED_CURVE25519" = "small" -then - AM_CFLAGS="$AM_CFLAGS -DCURVED25519_SMALL" - ENABLED_CURVED25519_SMALL=yes - ENABLED_CURVE25519=yes -fi - -if test "$ENABLED_CURVE25519" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_CURVE25519" - ENABLED_FEMATH=yes -fi - - - if test "x$ENABLED_CURVE25519" = "xyes"; then - BUILD_CURVE25519_TRUE= - BUILD_CURVE25519_FALSE='#' -else - BUILD_CURVE25519_TRUE='#' - BUILD_CURVE25519_FALSE= -fi - - - -# ED25519 -# Check whether --enable-ed25519 was given. -if test "${enable_ed25519+set}" = set; then : - enableval=$enable_ed25519; ENABLED_ED25519=$enableval -else - ENABLED_ED25519=no - -fi - - - -if test "$ENABLED_ED25519" = "small" -then - AM_CFLAGS="$AM_CFLAGS -DCURVED25519_SMALL" - ENABLED_CURVED25519_SMALL=yes - ENABLED_ED25519=yes -fi - -if test "$ENABLED_ED25519" = "yes" -then - if test "$ENABLED_SHA512" = "no" - then - as_fn_error $? "cannot enable ed25519 without enabling sha512." "$LINENO" 5 - fi - ENABLED_FEMATH=yes - ENABLED_GEMATH=yes - AM_CFLAGS="$AM_CFLAGS -DHAVE_ED25519" -fi - - if test "x$ENABLED_ED25519" = "xyes"; then - BUILD_ED25519_TRUE= - BUILD_ED25519_FALSE='#' -else - BUILD_ED25519_TRUE='#' - BUILD_ED25519_FALSE= -fi - - if test "x$ENABLED_CURVED25519_SMALL" = "xyes"; then - BUILD_CURVED25519_SMALL_TRUE= - BUILD_CURVED25519_SMALL_FALSE='#' -else - BUILD_CURVED25519_SMALL_TRUE='#' - BUILD_CURVED25519_SMALL_FALSE= -fi - - if test "x$ENABLED_FEMATH" = "xyes"; then - BUILD_FEMATH_TRUE= - BUILD_FEMATH_FALSE='#' -else - BUILD_FEMATH_TRUE='#' - BUILD_FEMATH_FALSE= -fi - - if test "x$ENABLED_GEMATH" = "xyes"; then - BUILD_GEMATH_TRUE= - BUILD_GEMATH_FALSE='#' -else - BUILD_GEMATH_TRUE='#' - BUILD_GEMATH_FALSE= -fi - - -# FP ECC, Fixed Point cache ECC -# Check whether --enable-fpecc was given. -if test "${enable_fpecc+set}" = set; then : - enableval=$enable_fpecc; ENABLED_FPECC=$enableval -else - ENABLED_FPECC=no - -fi - - -if test "$ENABLED_FPECC" = "yes" -then - if test "$ENABLED_ECC" = "no" - then - as_fn_error $? "cannot enable fpecc without enabling ecc." "$LINENO" 5 - fi - AM_CFLAGS="$AM_CFLAGS -DFP_ECC" -fi - - -# ECC encrypt -# Check whether --enable-eccencrypt was given. -if test "${enable_eccencrypt+set}" = set; then : - enableval=$enable_eccencrypt; ENABLED_ECC_ENCRYPT=$enableval -else - ENABLED_ECC_ENCRYPT=no - -fi - - -if test "$ENABLED_ECC_ENCRYPT" = "yes" -then - if test "$ENABLED_ECC" = "no" - then - as_fn_error $? "cannot enable eccencrypt without enabling ecc." "$LINENO" 5 - fi - if test "$ENABLED_HKDF" = "no" - then - as_fn_error $? "cannot enable eccencrypt without enabling hkdf." "$LINENO" 5 - fi - AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC_ENCRYPT" -fi - - -# PSK -# Check whether --enable-psk was given. -if test "${enable_psk+set}" = set; then : - enableval=$enable_psk; ENABLED_PSK=$enableval -else - ENABLED_PSK=no - -fi - - -if test "$ENABLED_PSK" = "no" && test "$ENABLED_LEANPSK" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_PSK" -fi - -if test "$ENABLED_PSK" = "no" && test "$ENABLED_LEANPSK" = "yes" -then - ENABLED_PSK=yes -fi - - -# ERROR STRINGS -# Check whether --enable-errorstrings was given. -if test "${enable_errorstrings+set}" = set; then : - enableval=$enable_errorstrings; ENABLED_ERROR_STRINGS=$enableval -else - ENABLED_ERROR_STRINGS=yes - -fi - - -if test "$ENABLED_ERROR_STRINGS" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_ERROR_STRINGS" -else - # turn off error strings if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_ERROR_STRINGS" - ENABLED_ERROR_STRINGS=no - fi -fi - - -# OLD TLS -# Check whether --enable-oldtls was given. -if test "${enable_oldtls+set}" = set; then : - enableval=$enable_oldtls; ENABLED_OLD_TLS=$enableval -else - ENABLED_OLD_TLS=yes - -fi - - -if test "$ENABLED_OLD_TLS" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_OLD_TLS" -else - # turn off old if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_OLD_TLS" - ENABLED_OLD_TLS=no - fi -fi - - -# STACK SIZE info for examples -# Check whether --enable-stacksize was given. -if test "${enable_stacksize+set}" = set; then : - enableval=$enable_stacksize; ENABLED_STACKSIZE=$enableval -else - ENABLED_STACKSIZE=no - -fi - - -if test "$ENABLED_STACKSIZE" = "yes" -then - ac_fn_c_check_func "$LINENO" "posix_memalign" "ac_cv_func_posix_memalign" -if test "x$ac_cv_func_posix_memalign" = xyes; then : - -else - as_fn_error $? "stacksize needs posix_memalign" "$LINENO" 5 -fi - - ac_fn_c_check_func "$LINENO" "pthread_attr_setstack" "ac_cv_func_pthread_attr_setstack" -if test "x$ac_cv_func_pthread_attr_setstack" = xyes; then : - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_attr_setstack in -lpthread" >&5 -$as_echo_n "checking for pthread_attr_setstack in -lpthread... " >&6; } -if ${ac_cv_lib_pthread_pthread_attr_setstack+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lpthread $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char pthread_attr_setstack (); -int -main () -{ -return pthread_attr_setstack (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_pthread_pthread_attr_setstack=yes -else - ac_cv_lib_pthread_pthread_attr_setstack=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_attr_setstack" >&5 -$as_echo "$ac_cv_lib_pthread_pthread_attr_setstack" >&6; } -if test "x$ac_cv_lib_pthread_pthread_attr_setstack" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBPTHREAD 1 -_ACEOF - - LIBS="-lpthread $LIBS" - -fi - -fi - - AM_CFLAGS="$AM_CFLAGS -DHAVE_STACK_SIZE -DWOLFSSL_LOW_MEMORY" -fi - - -# MEMORY -# Check whether --enable-memory was given. -if test "${enable_memory+set}" = set; then : - enableval=$enable_memory; ENABLED_MEMORY=$enableval -else - ENABLED_MEMORY=yes - -fi - - -if test "$ENABLED_MEMORY" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_WOLFSSL_MEMORY" -else - # turn off memory cb if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - # but don't turn on NO_WOLFSSL_MEMORY because using own - ENABLED_MEMORY=no - fi -fi - - if test "x$ENABLED_MEMORY" = "xyes"; then - BUILD_MEMORY_TRUE= - BUILD_MEMORY_FALSE='#' -else - BUILD_MEMORY_TRUE='#' - BUILD_MEMORY_FALSE= -fi - - - -# RSA -# Check whether --enable-rsa was given. -if test "${enable_rsa+set}" = set; then : - enableval=$enable_rsa; ENABLED_RSA=$enableval -else - ENABLED_RSA=yes - -fi - - -if test "$ENABLED_RSA" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_RSA" -else - # turn off RSA if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_RSA" - ENABLED_RSA=no - fi -fi - - if test "x$ENABLED_RSA" = "xyes"; then - BUILD_RSA_TRUE= - BUILD_RSA_FALSE='#' -else - BUILD_RSA_TRUE='#' - BUILD_RSA_FALSE= -fi - - - -# DH -# Check whether --enable-dh was given. -if test "${enable_dh+set}" = set; then : - enableval=$enable_dh; ENABLED_DH=$enableval -else - ENABLED_DH=yes - -fi - - -if test "$ENABLED_DH" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_DH" -else - # turn off DH if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_DH" - ENABLED_DH=no - fi -fi - - if test "x$ENABLED_DH" = "xyes"; then - BUILD_DH_TRUE= - BUILD_DH_FALSE='#' -else - BUILD_DH_TRUE='#' - BUILD_DH_FALSE= -fi - - - -# Anonymous -# Check whether --enable-anon was given. -if test "${enable_anon+set}" = set; then : - enableval=$enable_anon; ENABLED_ANON=$enableval -else - ENABLED_ANON=no - -fi - - - -if test "x$ENABLED_ANON" = "xyes" -then - if test "x$ENABLED_DH" != "xyes" - then - as_fn_error $? "Anonymous suite requires DH." "$LINENO" 5 - fi - AM_CFLAGS="$AM_CFLAGS -DHAVE_ANON" -fi - - -# ASN -# turn off asn, which means no certs, no rsa, no dsa, no ecc, -# and no big int (unless dh is on) -# Check whether --enable-asn was given. -if test "${enable_asn+set}" = set; then : - enableval=$enable_asn; ENABLED_ASN=$enableval -else - ENABLED_ASN=yes - -fi - - -if test "$ENABLED_ASN" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_ASN -DNO_CERTS" - if test "$ENABLED_DH" = "no" - then - # DH needs bigint - AM_CFLAGS="$AM_CFLAGS -DNO_BIG_INT" - fi -else - # turn off ASN if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_ASN -DNO_CERTS -DNO_BIG_INT" - ENABLED_ASN=no - fi -fi - -if test "$ENABLED_RSA" = "yes" && test "$ENABLED_ASN" = "no" -then - as_fn_error $? "please disable rsa if disabling asn." "$LINENO" 5 -fi - -if test "$ENABLED_DSA" = "yes" && test "$ENABLED_ASN" = "no" -then - as_fn_error $? "please disable dsa if disabling asn." "$LINENO" 5 -fi - -if test "$ENABLED_ECC" = "yes" && test "$ENABLED_ASN" = "no" -then - as_fn_error $? "please disable ecc if disabling asn." "$LINENO" 5 -fi - -if test "$ENABLED_PSK" = "no" && test "$ENABLED_ASN" = "no" -then - as_fn_error $? "please enable psk if disabling asn." "$LINENO" 5 -fi - -# DH needs bigint -if test "$ENABLED_ASN" = "no" && test "$ENABLED_DH" = "no" -then - ENABLED_FASTMATH=no - ENABLED_SLOWMATH=no -fi - - if test "x$ENABLED_ASN" = "xyes"; then - BUILD_ASN_TRUE= - BUILD_ASN_FALSE='#' -else - BUILD_ASN_TRUE='#' - BUILD_ASN_FALSE= -fi - - - -# AES -# Check whether --enable-aes was given. -if test "${enable_aes+set}" = set; then : - enableval=$enable_aes; ENABLED_AES=$enableval -else - ENABLED_AES=yes - -fi - - -if test "$ENABLED_AES" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_AES" - if test "$ENABLED_AESGCM" = "yes" - then - as_fn_error $? "AESGCM requires AES." "$LINENO" 5 - fi - if test "$ENABLED_AESCCM" = "yes" - then - as_fn_error $? "AESCCM requires AES." "$LINENO" 5 - fi -else - # turn off AES if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_AES" - ENABLED_AES=no - fi -fi - - if test "x$ENABLED_AES" = "xyes"; then - BUILD_AES_TRUE= - BUILD_AES_FALSE='#' -else - BUILD_AES_TRUE='#' - BUILD_AES_FALSE= -fi - - - -# CODING -# Check whether --enable-coding was given. -if test "${enable_coding+set}" = set; then : - enableval=$enable_coding; ENABLED_CODING=$enableval -else - ENABLED_CODING=yes - -fi - - -if test "$ENABLED_CODING" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_CODING" -else - # turn off CODING if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_CODING" - ENABLED_CODING=no - fi -fi - - if test "x$ENABLED_CODING" = "xyes"; then - BUILD_CODING_TRUE= - BUILD_CODING_FALSE='#' -else - BUILD_CODING_TRUE='#' - BUILD_CODING_FALSE= -fi - - - -# DES3 -# Check whether --enable-des3 was given. -if test "${enable_des3+set}" = set; then : - enableval=$enable_des3; ENABLED_DES3=$enableval -else - ENABLED_DES3=yes - -fi - - -if test "$ENABLED_DES3" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_DES3" -else - # turn off DES3 if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_DES3" - ENABLED_DES3=no - fi -fi - - if test "x$ENABLED_DES3" = "xyes"; then - BUILD_DES3_TRUE= - BUILD_DES3_FALSE='#' -else - BUILD_DES3_TRUE='#' - BUILD_DES3_FALSE= -fi - - - -# ARC4 -# Check whether --enable-arc4 was given. -if test "${enable_arc4+set}" = set; then : - enableval=$enable_arc4; ENABLED_ARC4=$enableval -else - ENABLED_ARC4=no - -fi - - -if test "$ENABLED_ARC4" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_RC4" -else - # turn off ARC4 if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_RC4" - ENABLED_ARC4=no - fi -fi - - if test "x$ENABLED_ARC4" = "xyes"; then - BUILD_RC4_TRUE= - BUILD_RC4_FALSE='#' -else - BUILD_RC4_TRUE='#' - BUILD_RC4_FALSE= -fi - - - -# MD5 -# Check whether --enable-md5 was given. -if test "${enable_md5+set}" = set; then : - enableval=$enable_md5; ENABLED_MD5=$enableval -else - ENABLED_MD5=yes - -fi - - -if test "$ENABLED_MD5" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_MD5 -DNO_OLD_TLS" -else - # turn off MD5 if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_MD5 -DNO_OLD_TLS" - ENABLED_MD5=no - fi -fi - - if test "x$ENABLED_MD5" = "xyes"; then - BUILD_MD5_TRUE= - BUILD_MD5_FALSE='#' -else - BUILD_MD5_TRUE='#' - BUILD_MD5_FALSE= -fi - - - -# SHA -# Check whether --enable-sha was given. -if test "${enable_sha+set}" = set; then : - enableval=$enable_sha; ENABLED_SHA=$enableval -else - ENABLED_SHA=yes - -fi - - -if test "$ENABLED_SHA" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_SHA -DNO_OLD_TLS" -else - # turn off SHA if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_SHA -DNO_OLD_TLS" - ENABLED_SHA=no - fi -fi - - if test "x$ENABLED_SHA" = "xyes"; then - BUILD_SHA_TRUE= - BUILD_SHA_FALSE='#' -else - BUILD_SHA_TRUE='#' - BUILD_SHA_FALSE= -fi - - - -# MD4 -# Check whether --enable-md4 was given. -if test "${enable_md4+set}" = set; then : - enableval=$enable_md4; ENABLED_MD4=$enableval -else - ENABLED_MD4=no - -fi - - -if test "$ENABLED_MD4" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_MD4" -fi - - if test "x$ENABLED_MD4" = "xyes"; then - BUILD_MD4_TRUE= - BUILD_MD4_FALSE='#' -else - BUILD_MD4_TRUE='#' - BUILD_MD4_FALSE= -fi - - - -# Web Server Build -# Check whether --enable-webserver was given. -if test "${enable_webserver+set}" = set; then : - enableval=$enable_webserver; ENABLED_WEBSERVER=$enableval -else - ENABLED_WEBSERVER=no - -fi - - -if test "$ENABLED_WEBSERVER" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_WEBSERVER" -fi - - - -# HC128 -# Check whether --enable-hc128 was given. -if test "${enable_hc128+set}" = set; then : - enableval=$enable_hc128; ENABLED_HC128=$enableval -else - ENABLED_HC128=no - -fi - - -if test "$ENABLED_HC128" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_HC128" -else - AM_CFLAGS="$AM_CFLAGS -DHAVE_HC128" -fi - - if test "x$ENABLED_HC128" = "xyes"; then - BUILD_HC128_TRUE= - BUILD_HC128_FALSE='#' -else - BUILD_HC128_TRUE='#' - BUILD_HC128_FALSE= -fi - - - -# RABBIT -# Check whether --enable-rabbit was given. -if test "${enable_rabbit+set}" = set; then : - enableval=$enable_rabbit; ENABLED_RABBIT=$enableval -else - ENABLED_RABBIT=no - -fi - - -if test "$ENABLED_RABBIT" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_RABBIT" -else - AM_CFLAGS="$AM_CFLAGS -DHAVE_RABBIT" -fi - - if test "x$ENABLED_RABBIT" = "xyes"; then - BUILD_RABBIT_TRUE= - BUILD_RABBIT_FALSE='#' -else - BUILD_RABBIT_TRUE='#' - BUILD_RABBIT_FALSE= -fi - - - -# FIPS -# Check whether --enable-fips was given. -if test "${enable_fips+set}" = set; then : - enableval=$enable_fips; ENABLED_FIPS=$enableval -else - ENABLED_FIPS=no - -fi - - -if test "x$ENABLED_FIPS" = "xyes" -then - # requires thread local storage - if test "$thread_ls_on" = "no" - then - as_fn_error $? "FIPS requires Thread Local Storage" "$LINENO" 5 - fi - # requires SHA512 - if test "x$ENABLED_SHA512" = "xno" - then - ENABLED_SHA512="yes" - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SHA512 -DWOLFSSL_SHA384" - if test "x$ENABLED_SHA512" = "xyes"; then - BUILD_SHA512_TRUE= - BUILD_SHA512_FALSE='#' -else - BUILD_SHA512_TRUE='#' - BUILD_SHA512_FALSE= -fi - - fi - # requires AESGCM - if test "x$ENABLED_AESGCM" != "xyes" - then - ENABLED_AESGCM="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_AESGCM" - if test "x$ENABLED_SHA512" = "xyes"; then - BUILD_SHA512_TRUE= - BUILD_SHA512_FALSE='#' -else - BUILD_SHA512_TRUE='#' - BUILD_SHA512_FALSE= -fi - - fi - AM_CFLAGS="$AM_CFLAGS -DHAVE_FIPS" -fi - - if test "x$ENABLED_FIPS" = "xyes"; then - BUILD_FIPS_TRUE= - BUILD_FIPS_FALSE='#' -else - BUILD_FIPS_TRUE='#' - BUILD_FIPS_FALSE= -fi - - - -# set POLY1305 default -POLY1305_DEFAULT=yes - -if test "x$ENABLED_FIPS" = "xyes" -then -POLY1305_DEFAULT=no -fi - -# POLY1305 -# Check whether --enable-poly1305 was given. -if test "${enable_poly1305+set}" = set; then : - enableval=$enable_poly1305; ENABLED_POLY1305=$enableval -else - ENABLED_POLY1305=$POLY1305_DEFAULT - -fi - - -# lean psk does't need poly1305 -if test "$ENABLED_LEANPSK" = "yes" -then - ENABLED_POLY1305=no -fi - -if test "$ENABLED_POLY1305" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_POLY1305 -DHAVE_ONE_TIME_AUTH" -fi - - if test "x$ENABLED_POLY1305" = "xyes"; then - BUILD_POLY1305_TRUE= - BUILD_POLY1305_FALSE='#' -else - BUILD_POLY1305_TRUE='#' - BUILD_POLY1305_FALSE= -fi - - - -# set CHACHA default -CHACHA_DEFAULT=yes - -if test "x$ENABLED_FIPS" = "xyes" -then -CHACHA_DEFAULT=no -fi - -# CHACHA -# Check whether --enable-chacha was given. -if test "${enable_chacha+set}" = set; then : - enableval=$enable_chacha; ENABLED_CHACHA=$enableval -else - ENABLED_CHACHA=$CHACHA_DEFAULT - -fi - - -# lean psk does't need chacha -if test "$ENABLED_LEANPSK" = "yes" -then - ENABLED_CHACHA=no -fi - -if test "$ENABLED_CHACHA" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_CHACHA" -fi - - if test "x$ENABLED_CHACHA" = "xyes"; then - BUILD_CHACHA_TRUE= - BUILD_CHACHA_FALSE='#' -else - BUILD_CHACHA_TRUE='#' - BUILD_CHACHA_FALSE= -fi - - - -# Hash DRBG -# Check whether --enable-hashdrbg was given. -if test "${enable_hashdrbg+set}" = set; then : - enableval=$enable_hashdrbg; ENABLED_HASHDRBG=$enableval -else - ENABLED_HASHDRBG=yes - -fi - - -if test "x$ENABLED_HASHDRBG" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_HASHDRBG" -else - # turn on Hash DRBG if FIPS is on or ARC4 is off - if test "x$ENABLED_FIPS" = "xyes" || test "x$ENABLED_ARC4" = "xno" - then - AM_CFLAGS="$AM_CFLAGS -DHAVE_HASHDRBG" - ENABLED_HASHDRBG=yes - fi -fi - - -# Filesystem Build -# Check whether --enable-filesystem was given. -if test "${enable_filesystem+set}" = set; then : - enableval=$enable_filesystem; ENABLED_FILESYSTEM=$enableval -else - ENABLED_FILESYSTEM=yes - -fi - - -if test "$ENABLED_FILESYSTEM" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_FILESYSTEM" -else - # turn off filesystem if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_FILESYSTEM" - ENABLED_FILESYSTEM=no - fi -fi - - -# inline Build -# Check whether --enable-inline was given. -if test "${enable_inline+set}" = set; then : - enableval=$enable_inline; ENABLED_INLINE=$enableval -else - ENABLED_INLINE=yes - -fi - - -if test "$ENABLED_INLINE" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_INLINE" -fi - - if test "x$ENABLED_INLINE" = "xyes"; then - BUILD_INLINE_TRUE= - BUILD_INLINE_FALSE='#' -else - BUILD_INLINE_TRUE='#' - BUILD_INLINE_FALSE= -fi - - - -# OCSP -# Check whether --enable-ocsp was given. -if test "${enable_ocsp+set}" = set; then : - enableval=$enable_ocsp; ENABLED_OCSP=$enableval -else - ENABLED_OCSP=no -fi - - -if test "$ENABLED_OCSP" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_OCSP" -fi - - if test "x$ENABLED_OCSP" = "xyes"; then - BUILD_OCSP_TRUE= - BUILD_OCSP_FALSE='#' -else - BUILD_OCSP_TRUE='#' - BUILD_OCSP_FALSE= -fi - - - -if test "$ENABLED_OCSP" = "yes" -then - # check openssl command tool for testing ocsp - # Extract the first word of "openssl", so it can be a program name with args. -set dummy openssl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_HAVE_OPENSSL_CMD+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$HAVE_OPENSSL_CMD"; then - ac_cv_prog_HAVE_OPENSSL_CMD="$HAVE_OPENSSL_CMD" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_HAVE_OPENSSL_CMD="yes" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_prog_HAVE_OPENSSL_CMD" && ac_cv_prog_HAVE_OPENSSL_CMD="no" -fi -fi -HAVE_OPENSSL_CMD=$ac_cv_prog_HAVE_OPENSSL_CMD -if test -n "$HAVE_OPENSSL_CMD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HAVE_OPENSSL_CMD" >&5 -$as_echo "$HAVE_OPENSSL_CMD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - - if test "$HAVE_OPENSSL_CMD" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DHAVE_OPENSSL_CMD" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: openssl command line tool not available for testing ocsp" >&5 -$as_echo "$as_me: WARNING: openssl command line tool not available for testing ocsp" >&2;} - fi -fi - - -# CRL -# Check whether --enable-crl was given. -if test "${enable_crl+set}" = set; then : - enableval=$enable_crl; ENABLED_CRL=$enableval -else - ENABLED_CRL=no -fi - - -if test "$ENABLED_CRL" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL" -fi - - if test "x$ENABLED_CRL" = "xyes"; then - BUILD_CRL_TRUE= - BUILD_CRL_FALSE='#' -else - BUILD_CRL_TRUE='#' - BUILD_CRL_FALSE= -fi - - - -# CRL Monitor -# Check whether --enable-crl-monitor was given. -if test "${enable_crl_monitor+set}" = set; then : - enableval=$enable_crl_monitor; ENABLED_CRL_MONITOR=$enableval -else - ENABLED_CRL_MONITOR=no -fi - - -if test "$ENABLED_CRL_MONITOR" = "yes" -then - case $host_os in - *linux* | *darwin* | *freebsd*) - AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL_MONITOR" ;; - *) - as_fn_error $? "crl monitor only allowed on linux, OS X, or freebsd" "$LINENO" 5 ;; - esac -fi - - if test "x$ENABLED_CRL_MONITOR" = "xyes"; then - BUILD_CRL_MONITOR_TRUE= - BUILD_CRL_MONITOR_FALSE='#' -else - BUILD_CRL_MONITOR_TRUE='#' - BUILD_CRL_MONITOR_FALSE= -fi - - - -# NTRU -ENABLED_NTRU="no" -tryntrudir="" - -# Check whether --with-ntru was given. -if test "${with_ntru+set}" = set; then : - withval=$with_ntru; - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NTRU" >&5 -$as_echo_n "checking for NTRU... " >&6; } - CPPFLAGS="$CPPFLAGS -DHAVE_NTRU" - LIBS="$LIBS -lNTRUEncrypt" - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ - ntru_crypto_drbg_instantiate(0, 0, 0, 0, 0); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ntru_linked=yes -else - ntru_linked=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - - if test "x$ntru_linked" == "xno" ; then - if test "x$withval" != "xno" ; then - tryntrudir=$withval - fi - if test "x$withval" == "xyes" ; then - tryntrudir="/usr" - fi - - LDFLAGS="$AM_LDFLAGS -L$tryntrudir/lib" - CPPFLAGS="$CPPFLAGS -I$tryntrudir/include" - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ - ntru_crypto_drbg_instantiate(0, 0, 0, 0, 0); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ntru_linked=yes -else - ntru_linked=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - - if test "x$ntru_linked" == "xno" ; then - as_fn_error $? "NTRU isn't found. - If it's already installed, specify its path using --with-ntru=/dir/" "$LINENO" 5 - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - AM_LDFLAGS="$AM_LDFLAGS -L$tryntrudir/lib" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - fi - - AM_CFLAGS="$AM_CFLAGS -DHAVE_NTRU" - ENABLED_NTRU="yes" - - -fi - - - if test "x$ENABLED_NTRU" = "xyes"; then - BUILD_NTRU_TRUE= - BUILD_NTRU_FALSE='#' -else - BUILD_NTRU_TRUE='#' - BUILD_NTRU_FALSE= -fi - - -if test "$ENABLED_NTRU" = "yes" && test "$ENABLED_SMALL" = "yes" -then - as_fn_error $? "cannot enable ntru and small, ntru requires TLS which small turns off." "$LINENO" 5 -fi - -# SNI -# Check whether --enable-sni was given. -if test "${enable_sni+set}" = set; then : - enableval=$enable_sni; ENABLED_SNI=$enableval -else - ENABLED_SNI=no - -fi - - -if test "x$ENABLED_SNI" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SNI" -fi - -# Maximum Fragment Length -# Check whether --enable-maxfragment was given. -if test "${enable_maxfragment+set}" = set; then : - enableval=$enable_maxfragment; ENABLED_MAX_FRAGMENT=$enableval -else - ENABLED_MAX_FRAGMENT=no - -fi - - -if test "x$ENABLED_MAX_FRAGMENT" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_MAX_FRAGMENT" -fi - -# Truncated HMAC -# Check whether --enable-truncatedhmac was given. -if test "${enable_truncatedhmac+set}" = set; then : - enableval=$enable_truncatedhmac; ENABLED_TRUNCATED_HMAC=$enableval -else - ENABLED_TRUNCATED_HMAC=no - -fi - - -if test "x$ENABLED_TRUNCATED_HMAC" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_TRUNCATED_HMAC" -fi - -# Renegotiation Indication - (FAKE Secure Renegotiation) -# Check whether --enable-renegotiation-indication was given. -if test "${enable_renegotiation_indication+set}" = set; then : - enableval=$enable_renegotiation_indication; ENABLED_RENEGOTIATION_INDICATION=$enableval -else - ENABLED_RENEGOTIATION_INDICATION=no - -fi - - -if test "x$ENABLED_RENEGOTIATION_INDICATION" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_RENEGOTIATION_INDICATION" -fi - -# Secure Renegotiation -# Check whether --enable-secure-renegotiation was given. -if test "${enable_secure_renegotiation+set}" = set; then : - enableval=$enable_secure_renegotiation; ENABLED_SECURE_RENEGOTIATION=$enableval -else - ENABLED_SECURE_RENEGOTIATION=no - -fi - - -if test "x$ENABLED_SECURE_RENEGOTIATION" = "xyes" -then - if test "x$ENABLED_RENEGOTIATION_INDICATION" = "xyes" - then - as_fn_error $? "cannot enable renegotiation-indication and secure-renegotiation." "$LINENO" 5 - fi - AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SECURE_RENEGOTIATION" -fi - -# Supported Elliptic Curves Extensions -# Check whether --enable-supportedcurves was given. -if test "${enable_supportedcurves+set}" = set; then : - enableval=$enable_supportedcurves; ENABLED_SUPPORTED_CURVES=$enableval -else - ENABLED_SUPPORTED_CURVES=no - -fi - - -if test "x$ENABLED_SUPPORTED_CURVES" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SUPPORTED_CURVES" -fi - -# Session Ticket Extension -# Check whether --enable-session-ticket was given. -if test "${enable_session_ticket+set}" = set; then : - enableval=$enable_session_ticket; ENABLED_SESSION_TICKET=$enableval -else - ENABLED_SESSION_TICKET=no - -fi - - -if test "x$ENABLED_SESSION_TICKET" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SESSION_TICKET" -fi - -# TLS Extensions -# Check whether --enable-tlsx was given. -if test "${enable_tlsx+set}" = set; then : - enableval=$enable_tlsx; ENABLED_TLSX=$enableval -else - ENABLED_TLSX=no - -fi - - -if test "x$ENABLED_TLSX" = "xyes" -then - ENABLED_SNI=yes - ENABLED_MAX_FRAGMENT=yes - ENABLED_TRUNCATED_HMAC=yes - ENABLED_SUPPORTED_CURVES=yes - AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SNI -DHAVE_MAX_FRAGMENT -DHAVE_TRUNCATED_HMAC -DHAVE_SUPPORTED_CURVES" -fi - -# PKCS7 -# Check whether --enable-pkcs7 was given. -if test "${enable_pkcs7+set}" = set; then : - enableval=$enable_pkcs7; ENABLED_PKCS7=$enableval -else - ENABLED_PKCS7=no -fi - - -if test "$ENABLED_PKCS7" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_PKCS7" -fi - - if test "x$ENABLED_PKCS7" = "xyes"; then - BUILD_PKCS7_TRUE= - BUILD_PKCS7_FALSE='#' -else - BUILD_PKCS7_TRUE='#' - BUILD_PKCS7_FALSE= -fi - - - -# Simple Certificate Enrollment Protocol (SCEP) -# Check whether --enable-scep was given. -if test "${enable_scep+set}" = set; then : - enableval=$enable_scep; ENABLED_WOLFSCEP=$enableval -else - ENABLED_WOLFSCEP=no - -fi - -if test "$ENABLED_WOLFSCEP" = "yes" -then - # Enable prereqs if not already enabled - if test "x$ENABLED_KEYGEN" = "xno" - then - ENABLED_KEYGEN="yes" - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_KEY_GEN" - fi - if test "x$ENABLED_CERTGEN" = "xno" - then - ENABLED_CERTGEN="yes" - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CERT_GEN" - fi - if test "x$ENABLED_CERTREQ" = "xno" - then - ENABLED_CERTREQ="yes" - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CERT_REQ" - fi - if test "x$ENABLED_PKCS7" = "xno" - then - ENABLED_PKCS7="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_PKCS7" - if test "x$ENABLED_PKCS7" = "xyes"; then - BUILD_PKCS7_TRUE= - BUILD_PKCS7_FALSE='#' -else - BUILD_PKCS7_TRUE='#' - BUILD_PKCS7_FALSE= -fi - - fi - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAVE_WOLFSCEP" -fi - - -# Small Stack -# Check whether --enable-smallstack was given. -if test "${enable_smallstack+set}" = set; then : - enableval=$enable_smallstack; ENABLED_SMALL_STACK=$enableval -else - ENABLED_SMALL_STACK=no - -fi - - -if test "x$ENABLED_SMALL_STACK" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SMALL_STACK" -fi - - -#valgrind -# Check whether --enable-valgrind was given. -if test "${enable_valgrind+set}" = set; then : - enableval=$enable_valgrind; ENABLED_VALGRIND=$enableval -else - ENABLED_VALGRIND=no - -fi - - -if test "$ENABLED_VALGRIND" = "yes" -then - # Extract the first word of "valgrind", so it can be a program name with args. -set dummy valgrind; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_HAVE_VALGRIND+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$HAVE_VALGRIND"; then - ac_cv_prog_HAVE_VALGRIND="$HAVE_VALGRIND" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_HAVE_VALGRIND="yes" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_prog_HAVE_VALGRIND" && ac_cv_prog_HAVE_VALGRIND="no" -fi -fi -HAVE_VALGRIND=$ac_cv_prog_HAVE_VALGRIND -if test -n "$HAVE_VALGRIND"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HAVE_VALGRIND" >&5 -$as_echo "$HAVE_VALGRIND" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - - if test "$HAVE_VALGRIND" = "no" - then - as_fn_error $? "Valgrind not found." "$LINENO" 5 - fi - enable_shared=no - enable_static=yes - AM_CFLAGS="$AM_CFLAGS -DHAVE_VALGRIND" -fi - - if test "x$ENABLED_VALGRIND" = "xyes"; then - USE_VALGRIND_TRUE= - USE_VALGRIND_FALSE='#' -else - USE_VALGRIND_TRUE='#' - USE_VALGRIND_FALSE= -fi - - - -# Test certs, use internal cert functions for extra testing -# Check whether --enable-testcert was given. -if test "${enable_testcert+set}" = set; then : - enableval=$enable_testcert; ENABLED_TESTCERT=$enableval -else - ENABLED_TESTCERT=no - -fi - - -if test "$ENABLED_TESTCERT" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_TEST_CERT" -fi - - -# I/O Pool, an example to show user how to override memory handler and use -# a pool for the input/output buffer requests -# Check whether --enable-iopool was given. -if test "${enable_iopool+set}" = set; then : - enableval=$enable_iopool; ENABLED_IOPOOL=$enableval -else - ENABLED_IOPOOL=no - -fi - - -if test "$ENABLED_IOPOOL" = "yes" -then - if test "$thread_ls_on" = "no" - then - as_fn_error $? "I/O Pool example requires Thread Local Storage" "$LINENO" 5 - fi - AM_CFLAGS="$AM_CFLAGS -DHAVE_IO_POOL -DXMALLOC_USER" -fi - - -# Certificate Service Support -# Check whether --enable-certservice was given. -if test "${enable_certservice+set}" = set; then : - enableval=$enable_certservice; ENABLED_CERT_SERVICE=$enableval -else - ENABLED_CERT_SERVICE=no - -fi - -if test "$ENABLED_CERT_SERVICE" = "yes" -then - # Requires ecc,certgen, and opensslextra make sure on - if test "x$ENABLED_CERTGEN" = "xno" - then - ENABLED_CERTGEN="yes" - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CERT_GEN" - fi - if test "x$ENABLED_ECC" = "xno" - then - ENABLED_ECC="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC -DTFM_ECC256 -DECC_SHAMIR" - if test "x$ENABLED_ECC" = "xyes"; then - BUILD_ECC_TRUE= - BUILD_ECC_FALSE='#' -else - BUILD_ECC_TRUE='#' - BUILD_ECC_FALSE= -fi - - fi - if test "x$ENABLED_OPENSSLEXTRA" = "xno" - then - ENABLED_OPENSSLEXTRA="yes" - AM_CFLAGS="-DOPENSSL_EXTRA $AM_CFLAGS" - fi - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAVE_CERT_SERVICE" -fi - - -# PWDBASED has to come after certservice since we want it on w/o explicit on -# PWDBASED -# Check whether --enable-pwdbased was given. -if test "${enable_pwdbased+set}" = set; then : - enableval=$enable_pwdbased; ENABLED_PWDBASED=$enableval -else - ENABLED_PWDBASED=no - -fi - - -if test "$ENABLED_PWDBASED" = "no" -then - if test "$ENABLED_OPENSSLEXTRA" = "yes" || test "$ENABLED_WEBSERVER" = "yes" - then - # opensslextra and webserver needs pwdbased - ENABLED_PWDBASED=yes - else - AM_CFLAGS="$AM_CFLAGS -DNO_PWDBASED" - fi -fi - - if test "x$ENABLED_PWDBASED" = "xyes"; then - BUILD_PWDBASED_TRUE= - BUILD_PWDBASED_FALSE='#' -else - BUILD_PWDBASED_TRUE='#' - BUILD_PWDBASED_FALSE= -fi - - - -# set fastmath default -FASTMATH_DEFAULT=no - -if test "$host_cpu" = "x86_64" -then -FASTMATH_DEFAULT=yes -fi - -# fastmath -# Check whether --enable-fastmath was given. -if test "${enable_fastmath+set}" = set; then : - enableval=$enable_fastmath; ENABLED_FASTMATH=$enableval -else - ENABLED_FASTMATH=$FASTMATH_DEFAULT - -fi - - -if test "x$ENABLED_FASTMATH" = "xyes" -then - # turn off fastmth if leanpsk on or asn off (w/o dh) - if test "$ENABLED_LEANPSK" = "yes" || test "$ENABLED_ASN" = "no" - then - if test "$ENABLED_DH" = "no" - then - ENABLED_FASTMATH=no - else - AM_CFLAGS="$AM_CFLAGS -DUSE_FAST_MATH" - ENABLED_SLOWMATH="no" - fi - else - AM_CFLAGS="$AM_CFLAGS -DUSE_FAST_MATH" - ENABLED_SLOWMATH="no" - fi - if test "$host_cpu" = "x86_64" - then - # Have settings.h set FP_MAX_BITS higher if user didn't set directly - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_X86_64_BUILD" - fi -fi - - -# fast HUGE math -# Check whether --enable-fasthugemath was given. -if test "${enable_fasthugemath+set}" = set; then : - enableval=$enable_fasthugemath; ENABLED_FASTHUGEMATH=$enableval -else - ENABLED_FASTHUGEMATH=no - -fi - - -if test "$ENABLED_BUMP" = "yes" -then - ENABLED_FASTHUGEMATH="yes" -fi - -if test "$ENABLED_FASTHUGEMATH" = "yes" -then - ENABLED_FASTMATH="yes" - AM_CFLAGS="$AM_CFLAGS -DUSE_FAST_MATH" - ENABLED_SLOWMATH="no" -fi - - if test "x$ENABLED_FASTMATH" = "xyes"; then - BUILD_FASTMATH_TRUE= - BUILD_FASTMATH_FALSE='#' -else - BUILD_FASTMATH_TRUE='#' - BUILD_FASTMATH_FALSE= -fi - - if test "x$ENABLED_SLOWMATH" = "xyes"; then - BUILD_SLOWMATH_TRUE= - BUILD_SLOWMATH_FALSE='#' -else - BUILD_SLOWMATH_TRUE='#' - BUILD_SLOWMATH_FALSE= -fi - - - -# Enable Examples, used to disable examples -# Check whether --enable-examples was given. -if test "${enable_examples+set}" = set; then : - enableval=$enable_examples; ENABLED_EXAMPLES=$enableval -else - ENABLED_EXAMPLES=yes - -fi - - -if test "x$ENABLED_FILESYSTEM" = "xno"; then : - ENABLED_EXAMPLES="no" -fi -if test "x$ENABLED_INLINE" = "xno"; then : - ENABLED_EXAMPLES="no" -fi - if test "x$ENABLED_EXAMPLES" = "xyes"; then - BUILD_EXAMPLES_TRUE= - BUILD_EXAMPLES_FALSE='#' -else - BUILD_EXAMPLES_TRUE='#' - BUILD_EXAMPLES_FALSE= -fi - - - -# LIBZ -ENABLED_LIBZ="no" -trylibzdir="" - -# Check whether --with-libz was given. -if test "${with_libz+set}" = set; then : - withval=$with_libz; - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5 -$as_echo_n "checking for libz... " >&6; } - CPPFLAGS="$CPPFLAGS -DHAVE_LIBZ" - LIBS="$LIBS -lz" - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ - deflateInit(0, 8); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - libz_linked=yes -else - libz_linked=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - - if test "x$libz_linked" == "xno" ; then - if test "x$withval" != "xno" ; then - trylibzdir=$withval - fi - if test "x$withval" == "xyes" ; then - trylibzdir="/usr" - fi - - AM_LDFLAGS="$AM_LDFLAGS -L$trylibzdir/lib" - CPPFLAGS="$CPPFLAGS -I$trylibzdir/include" - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ - deflateInit(0, 8); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - libz_linked=yes -else - libz_linked=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - - if test "x$libz_linked" == "xno" ; then - as_fn_error $? "libz isn't found. - If it's already installed, specify its path using --with-libz=/dir/" "$LINENO" 5 - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - fi - ENABLED_LIBZ="yes" - - -fi - - if test "x$ENABLED_LIBZ" = "xyes"; then - BUILD_LIBZ_TRUE= - BUILD_LIBZ_FALSE='#' -else - BUILD_LIBZ_TRUE='#' - BUILD_LIBZ_FALSE= -fi - - - -# cavium -trycaviumdir="" - -# Check whether --with-cavium was given. -if test "${with_cavium+set}" = set; then : - withval=$with_cavium; - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cavium" >&5 -$as_echo_n "checking for cavium... " >&6; } - CPPFLAGS="$CPPFLAGS -DHAVE_CAVIUM" - - if test "x$withval" == "xyes" ; then - as_fn_error $? "need a PATH for --with-cavium" "$LINENO" 5 - fi - if test "x$withval" != "xno" ; then - trycaviumdir=$withval - fi - - LDFLAGS="$AM_LDFLAGS $trycaviumdir/api/cavium_common.o" - CPPFLAGS="$CPPFLAGS -I$trycaviumdir/include" - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include "cavium_common.h" -int -main () -{ - CspShutdown(CAVIUM_DEV_ID); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - cavium_linked=yes -else - cavium_linked=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - - if test "x$cavium_linked" == "xno" ; then - as_fn_error $? "cavium isn't found. - If it's already installed, specify its path using --with-cavium=/dir/" "$LINENO" 5 - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - enable_shared=no - enable_static=yes - - -fi - - - -# microchip api -# Check whether --enable-mcapi was given. -if test "${enable_mcapi+set}" = set; then : - enableval=$enable_mcapi; ENABLED_MCAPI=$enableval -else - ENABLED_MCAPI=no - -fi - - -if test "$ENABLED_MCAPI" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_MCAPI -DWOLFSSL_AES_COUNTER -DWOLFSSL_AES_DIRECT" -fi - -if test "$ENABLED_MCAPI" = "yes" && test "$ENABLED_SHA512" = "no" -then - as_fn_error $? "please enable sha512 if enabling mcapi." "$LINENO" 5 -fi - -if test "$ENABLED_MCAPI" = "yes" && test "$ENABLED_ECC" = "no" -then - as_fn_error $? "please enable ecc if enabling mcapi." "$LINENO" 5 -fi - -if test "$ENABLED_MCAPI" = "yes" && test "$ENABLED_LIBZ" = "no" -then - as_fn_error $? "please use --with-libz if enabling mcapi." "$LINENO" 5 -fi - - if test "x$ENABLED_MCAPI" = "xyes"; then - BUILD_MCAPI_TRUE= - BUILD_MCAPI_FALSE='#' -else - BUILD_MCAPI_TRUE='#' - BUILD_MCAPI_FALSE= -fi - - - -# wolfSSL JNI -# Check whether --enable-jni was given. -if test "${enable_jni+set}" = set; then : - enableval=$enable_jni; ENABLED_JNI=$enableval -else - ENABLED_JNI=no - -fi - -if test "$ENABLED_JNI" = "yes" -then - # Enable prereqs if not already enabled - if test "x$ENABLED_DTLS" = "xno" - then - ENABLED_DTLS="yes" - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DTLS" - fi - if test "x$ENABLED_OPENSSLEXTRA" = "xno" - then - ENABLED_OPENSSLEXTRA="yes" - AM_CFLAGS="$AM_CFLAGS -DOPENSSL_EXTRA" - fi - if test "x$ENABLED_CRL" = "xno" - then - ENABLED_CRL="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL" - if test "x$ENABLED_CRL" = "xyes"; then - BUILD_CRL_TRUE= - BUILD_CRL_FALSE='#' -else - BUILD_CRL_TRUE='#' - BUILD_CRL_FALSE= -fi - - fi - if test "x$ENABLED_OCSP" = "xno" - then - ENABLED_OCSP="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_OCSP" - if test "x$ENABLED_OCSP" = "xyes"; then - BUILD_OCSP_TRUE= - BUILD_OCSP_FALSE='#' -else - BUILD_OCSP_TRUE='#' - BUILD_OCSP_FALSE= -fi - - fi - if test "x$ENABLED_CRL_MONITOR" = "xno" - then - ENABLED_CRL_MONITOR="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL_MONITOR" - fi - if test "x$ENABLED_SAVESESSION" = "xno" - then - ENABLED_SAVESESSION="yes" - AM_CFLAGS="$AM_CFLAGS -DPERSIST_SESSION_CACHE" - fi - if test "x$ENABLED_SAVECERT" = "xno" - then - ENABLED_SAVECERT="yes" - AM_CFLAGS="$AM_CFLAGS -DPERSIST_CERT_CACHE" - fi - if test "x$ENABLED_ATOMICUSER" = "xno" - then - ENABLED_ATOMICUSER="yes" - AM_CFLAGS="$AM_CFLAGS -DATOMIC_USER" - fi - if test "x$ENABLED_ECC" = "xno" - then - ENABLED_ECC="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC" - fi - if test "x$ENABLED_PKCALLBACKS" = "xno" - then - ENABLED_PKCALLBACKS="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_PK_CALLBACKS" - fi - if test "x$ENABLED_DH" = "xno" - then - ENABLED_DH="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_DH" - fi -fi - - -# Check for build-type conflicts -if test "x$ENABLED_MAXSTRENGTH" = "xyes" && \ - test "x$ENABLED_LEANPSK" = "xyes"; then : - as_fn_error $? "Cannot use Max Strength and Lean PSK at the same time." "$LINENO" 5 -fi - - -# Update CFLAGS based on options -if test "x$ENABLED_MAXSTRENGTH" = "xyes"; then : - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_MAX_STRENGTH" -fi - -if test "x$ENABLED_MAXSTRENGTH" = "xyes" && \ - test "x$ENABLED_OLD_TLS" = "xyes"; then : - AM_CFLAGS="$AM_CFLAGS -DNO_OLD_TLS" - ENABLED_OLD_TLS=no -fi - - -# OPTIMIZE FLAGS -if test "$GCC" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -Wall -Wno-unused" - if test "$ax_enable_debug" = "no" - then - if test "$ENABLED_FASTMATH" = "yes" - then - AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_FAST_CFLAGS" - if test "$ENABLED_FASTHUGEMATH" = "yes" - then - AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_HUGE_CFLAGS" - fi - else - AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_CFLAGS" - fi - fi -fi - -# ICC command line warning for non supported warning flags -if test "$CC" = "icc" -then - AM_CFLAGS="$AM_CFLAGS -wd10006" -fi - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 -$as_echo_n "checking for library containing gethostbyname... " >&6; } -if ${ac_cv_search_gethostbyname+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gethostbyname (); -int -main () -{ -return gethostbyname (); - ; - return 0; -} -_ACEOF -for ac_lib in '' nsl; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_gethostbyname=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_gethostbyname+:} false; then : - break -fi -done -if ${ac_cv_search_gethostbyname+:} false; then : - -else - ac_cv_search_gethostbyname=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 -$as_echo "$ac_cv_search_gethostbyname" >&6; } -ac_res=$ac_cv_search_gethostbyname -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5 -$as_echo_n "checking for library containing socket... " >&6; } -if ${ac_cv_search_socket+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char socket (); -int -main () -{ -return socket (); - ; - return 0; -} -_ACEOF -for ac_lib in '' socket; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_socket=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_socket+:} false; then : - break -fi -done -if ${ac_cv_search_socket+:} false; then : - -else - ac_cv_search_socket=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5 -$as_echo "$ac_cv_search_socket" >&6; } -ac_res=$ac_cv_search_socket -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 -$as_echo_n "checking for socket in -lsocket... " >&6; } -if ${ac_cv_lib_socket_socket+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lsocket -lnsl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char socket (); -int -main () -{ -return socket (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_socket_socket=yes -else - ac_cv_lib_socket_socket=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5 -$as_echo "$ac_cv_lib_socket_socket" >&6; } -if test "x$ac_cv_lib_socket_socket" = xyes; then : - LIBS="-lsocket -lnsl $LIBS" -fi - -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for vcs system" >&5 -$as_echo_n "checking for vcs system... " >&6; } -if ${ac_cv_vcs_system+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_vcs_system="none" - if test -d ".bzr"; then : - ac_cv_vcs_system="bazaar" -fi - if test -d ".svn"; then : - ac_cv_vcs_system="svn" -fi - if test -d ".hg"; then : - ac_cv_vcs_system="mercurial" -fi - if test -d ".git"; then : - ac_cv_vcs_system="git" -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_vcs_system" >&5 -$as_echo "$ac_cv_vcs_system" >&6; } - -cat >>confdefs.h <<_ACEOF -#define VCS_SYSTEM "$ac_cv_vcs_system" -_ACEOF - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for vcs checkout" >&5 -$as_echo_n "checking for vcs checkout... " >&6; } -if ${ac_cv_vcs_checkout+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "x$ac_cv_vcs_system" != "xnone"; then : - ac_cv_vcs_checkout=yes -else - ac_cv_vcs_checkout=no -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_vcs_checkout" >&5 -$as_echo "$ac_cv_vcs_checkout" >&6; } - - if test "x$ac_cv_vcs_checkout" = "xyes"; then - IS_VCS_CHECKOUT_TRUE= - IS_VCS_CHECKOUT_FALSE='#' -else - IS_VCS_CHECKOUT_TRUE='#' - IS_VCS_CHECKOUT_FALSE= -fi - - if test "x$ac_cv_vcs_checkout" = "xyes"; then : - -$as_echo "#define VCS_CHECKOUT 1" >>confdefs.h - -else - -$as_echo "#define VCS_CHECKOUT 0" >>confdefs.h - -fi - - - - - - AX_HARDEN_LIB= - ax_append_compile_link_flags_extra= - if test "x$ac_cv_vcs_checkout" = "xyes"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -Werror" >&5 -$as_echo_n "checking whether the linker accepts -Werror... " >&6; } -if ${ax_cv_check_ldflags___Werror+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$LDFLAGS - LDFLAGS="$LDFLAGS -Werror" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ax_cv_check_ldflags___Werror=yes -else - ax_cv_check_ldflags___Werror=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$ax_check_save_flags -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___Werror" >&5 -$as_echo "$ax_cv_check_ldflags___Werror" >&6; } -if test x"$ax_cv_check_ldflags___Werror" = xyes; then : - - AX_HARDEN_LIB="-Werror $AX_HARDEN_LIB" - -else - : -fi - - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -Werror" >&5 -$as_echo_n "checking whether the linker accepts -Werror... " >&6; } -if ${ax_cv_check_ldflags___Werror+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$LDFLAGS - LDFLAGS="$LDFLAGS -Werror" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ax_cv_check_ldflags___Werror=yes -else - ax_cv_check_ldflags___Werror=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$ax_check_save_flags -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___Werror" >&5 -$as_echo "$ax_cv_check_ldflags___Werror" >&6; } -if test x"$ax_cv_check_ldflags___Werror" = xyes; then : - - ax_append_compile_link_flags_extra='-Werror' - -else - : -fi - - -fi - - as_CACHEVAR=`$as_echo "ax_cv_check_ldflags_$ax_append_compile_link_flags_extra_-z relro -z now" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -z relro -z now" >&5 -$as_echo_n "checking whether the linker accepts -z relro -z now... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$LDFLAGS - LDFLAGS="$LDFLAGS $ax_append_compile_link_flags_extra -z relro -z now" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - - AX_HARDEN_LIB="-z relro -z now $AX_HARDEN_LIB" - -else - : -fi - - - as_CACHEVAR=`$as_echo "ax_cv_check_ldflags_$ax_append_compile_link_flags_extra_-pie" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -pie" >&5 -$as_echo_n "checking whether the linker accepts -pie... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$LDFLAGS - LDFLAGS="$LDFLAGS $ax_append_compile_link_flags_extra -pie" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - - AX_HARDEN_LIB="-pie $AX_HARDEN_LIB" - -else - : -fi - - - LIB="$LIB $AX_HARDEN_LIB" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts " >&5 -$as_echo_n "checking whether C compiler accepts ... " >&6; } -if ${ax_cv_check_cflags__+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS " - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ax_cv_check_cflags__=yes -else - ax_cv_check_cflags__=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags__" >&5 -$as_echo "$ax_cv_check_cflags__" >&6; } -if test x"$ax_cv_check_cflags__" = xyes; then : - : -else - : -fi - -if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains "; } >&5 - (: CFLAGS already contains ) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \""; } >&5 - (: CFLAGS="$CFLAGS ") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS " - ;; - esac -else - CFLAGS="" -fi - - - - - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - CFLAGS= - ac_cv_warnings_as_errors=no - ax_append_compile_cflags_extra= - if test "$ac_cv_vcs_checkout" = "yes"; then : - - - -for flag in -Werror; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - ac_cv_warnings_as_errors=yes - -else - - - -for flag in -Werror; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${ax_append_compile_cflags_extra+:} false; then : - case " $ax_append_compile_cflags_extra " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : ax_append_compile_cflags_extra already contains \$flag"; } >&5 - (: ax_append_compile_cflags_extra already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : ax_append_compile_cflags_extra=\"\$ax_append_compile_cflags_extra \$flag\""; } >&5 - (: ax_append_compile_cflags_extra="$ax_append_compile_cflags_extra $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ax_append_compile_cflags_extra="$ax_append_compile_cflags_extra $flag" - ;; - esac -else - ax_append_compile_cflags_extra="$flag" -fi - -else - : -fi - -done - - -fi - - if test "$ax_enable_debug" = "yes"; then : - - - -for flag in -g; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -ggdb; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -O0; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - -fi - - - -for flag in -Wno-pragmas; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - - -for flag in -Wall; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wno-strict-aliasing; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wextra; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wunknown-pragmas; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wthis-test-should-fail; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - if test "$CC" = "clang"; then : - -else - - - -for flag in --param=ssp-buffer-size=1; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - -fi - - -for flag in -Waddress; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Warray-bounds; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wbad-function-cast; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wchar-subscripts; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wcomment; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wfloat-equal; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wformat-security; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wformat=2; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wmaybe-uninitialized; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wmissing-field-initializers; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wmissing-noreturn; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wmissing-prototypes; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wnested-externs; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wnormalized=id; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Woverride-init; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wpointer-arith; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wpointer-sign; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wredundant-decls; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wshadow; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wshorten-64-to-32; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wsign-compare; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wstrict-overflow=1; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wstrict-prototypes; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wswitch-enum; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wundef; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wunused; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wunused-result; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wunused-variable; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -Wwrite-strings; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -fwrapv; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - - -for flag in -fPIE; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$ax_append_compile_cflags_extra_$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $ax_append_compile_cflags_extra $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $flag "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 - (: CFLAGS already contains $flag) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 - (: CFLAGS="$CFLAGS $flag") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $flag" - ;; - esac -else - CFLAGS="$flag" -fi - -else - : -fi - -done - - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -# link to ws2_32 if on mingw -case $host_os in - *mingw32) - LDFLAGS="$LDFLAGS -lws2_32" ;; -esac - -# add user C_EXTRA_FLAGS back -CFLAGS="$CFLAGS $USER_C_EXTRA_FLAGS" -OPTION_FLAGS="$USER_C_EXTRA_FLAGS $AM_CFLAGS" - - - - HEX_VERSION=`echo $VERSION | sed 's|\-a-z0-9*$||' | \ - awk -F. '{printf "0x%0.2d%0.3d%0.3d", $1, $2, $3}'` - - - - - - -# FINAL -ac_config_files="$ac_config_files stamp-h" - -ac_config_files="$ac_config_files Makefile" - -ac_config_files="$ac_config_files wolfssl/version.h" - -ac_config_files="$ac_config_files wolfssl/options.h" - -#have options.h and version.h for autoconf fips tag and build -#if test "x$ENABLED_FIPS" = "xyes" -#then -# AC_CONFIG_FILES([cyassl/version.h]) -# AC_CONFIG_FILES([cyassl/options.h]) -#fi -ac_config_files="$ac_config_files support/wolfssl.pc" - -ac_config_files="$ac_config_files rpm/spec" - - -# create a generic PACKAGE-config file -L=`echo $PACKAGE $LIBS` -P=`echo $L | sed -e 's/ -.*//'` -P=`echo $P` -V=`echo $VERSION` -F=`echo $P-config` -L=`echo -l$L | sed -e 's/^-llib/-l/'` -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: creating $F - generic $V for $L" >&5 -$as_echo "creating $F - generic $V for $L" >&6; } -test "x$prefix" = xNONE && prefix="$ac_default_prefix" -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -echo '#! /bin/sh' >$F -echo ' ' >>$F -echo 'package="'$P'"' >>$F -echo 'version="'$V'"' >>$F -echo 'libs="'$L'"' >>$F -echo ' ' >>$F -# in the order of occurence a standard automake Makefile -echo 'prefix="'$prefix'"' >>$F -echo 'exec_prefix="'$exec_prefix'"' >>$F -echo 'bindir="'$bindir'"' >>$F -echo 'sbindir="'$sbindir'"' >>$F -echo 'libexecdir="'$libexecdir'"' >>$F -echo 'datadir="'$datadir'"' >>$F -echo 'sysconfdir="'$sysconfdir'"' >>$F -echo 'sharedstatedir="'$sharedstatedir'"' >>$F -echo 'localstatedir="'$localstatedir'"' >>$F -echo 'libdir="'$libdir'"' >>$F -echo 'infodir="'$infodir'"' >>$F -echo 'mandir="'$mandir'"' >>$F -echo 'includedir="'$includedir'"' >>$F -echo 'target="'$target'"' >>$F -echo 'host="'$host'"' >>$F -echo 'build="'$build'"' >>$F -echo ' ' >>$F -echo 'if test "'"\$""#"'" -eq 0; then' >>$F -echo ' cat <>$F -echo 'Usage: $package-config OPTIONS' >>$F -echo 'Options:' >>$F -echo ' --prefix=DIR) : \$prefix' >>$F -echo ' --package) : \$package' >>$F -echo ' --version) : \$version' >>$F -echo ' --cflags) : -I\$includedir' >>$F -echo ' --libs) : -L\$libdir -l\$package' >>$F -echo ' --help) print all the options (not just these)' >>$F -echo 'EOF' >>$F -echo 'fi' >>$F -echo ' ' >>$F -echo 'o=""' >>$F -echo 'h=""' >>$F -echo 'for i in "$@"; do' >>$F -echo ' case $i in' >>$F -echo ' --prefix=*) prefix=`echo $i | sed -e "s/--prefix=//"` ;;' >>$F -echo ' --prefix) o="$o $prefix" ;;' >>$F -echo ' --package) o="$o $package" ;;' >>$F -echo ' --version) o="$o $version" ;;' >>$F -echo ' --cflags) if test "_$includedir" != "_/usr/include"' >>$F -echo ' then o="$o -I$includedir" ; fi' >>$F -echo ' ;;' >>$F -echo ' --libs) o="$o -L$libdir $libs" ;;' >>$F -echo ' --exec_prefix|--eprefix) o="$o $exec_prefix" ;;' >>$F -echo ' --bindir) o="$o $bindir" ;;' >>$F -echo ' --sbindir) o="$o $sbindir" ;;' >>$F -echo ' --libexecdir) o="$o $libexecdir" ;;' >>$F -echo ' --datadir) o="$o $datadir" ;;' >>$F -echo ' --datainc) o="$o -I$datadir" ;;' >>$F -echo ' --datalib) o="$o -L$datadir" ;;' >>$F -echo ' --sysconfdir) o="$o $sysconfdir" ;;' >>$F -echo ' --sharedstatedir) o="$o $sharedstatedir" ;;' >>$F -echo ' --localstatedir) o="$o $localstatedir" ;;' >>$F -echo ' --libdir) o="$o $libdir" ;;' >>$F -echo ' --libadd) o="$o -L$libdir" ;;' >>$F -echo ' --infodir) o="$o $infodir" ;;' >>$F -echo ' --mandir) o="$o $mandir" ;;' >>$F -echo ' --target) o="$o $target" ;;' >>$F -echo ' --host) o="$o $host" ;;' >>$F -echo ' --build) o="$o $build" ;;' >>$F -echo ' --data) o="$o -I$datadir/$package" ;;' >>$F -echo ' --pkgdatadir) o="$o $datadir/$package" ;;' >>$F -echo ' --pkgdatainc) o="$o -I$datadir/$package" ;;' >>$F -echo ' --pkgdatalib) o="$o -L$datadir/$package" ;;' >>$F -echo ' --pkglibdir) o="$o $libdir/$package" ;;' >>$F -echo ' --pkglibinc) o="$o -I$libinc/$package" ;;' >>$F -echo ' --pkglibadd) o="$o -L$libadd/$package" ;;' >>$F -echo ' --pkgincludedir) o="$o $includedir/$package" ;;' >>$F -echo ' --help) h="1" ;;' >>$F -echo ' -?//*|-?/*//*|-?./*//*|//*|/*//*|./*//*) ' >>$F -echo ' v=`echo $i | sed -e s://:\$:g`' >>$F -echo ' v=`eval "echo $v"` ' >>$F -echo ' o="$o $v" ;; ' >>$F -echo ' esac' >>$F -echo 'done' >>$F -echo ' ' >>$F -echo 'o=`eval "echo $o"`' >>$F -echo 'o=`eval "echo $o"`' >>$F -echo 'eval "echo $o"' >>$F -echo ' ' >>$F -echo 'if test ! -z "$h" ; then ' >>$F -echo 'cat <>$F -echo ' --prefix=xxx) (what is that for anyway?)' >>$F -echo ' --prefix) \$prefix $prefix' >>$F -echo ' --package) \$package $package' >>$F -echo ' --version) \$version $version' >>$F -echo ' --cflags) -I\$includedir unless it is /usr/include' >>$F -echo ' --libs) -L\$libdir -l\$PACKAGE \$LIBS' >>$F -echo ' --exec_prefix) or... ' >>$F -echo ' --eprefix) \$exec_prefix $exec_prefix' >>$F -echo ' --bindir) \$bindir $bindir' >>$F -echo ' --sbindir) \$sbindir $sbindir' >>$F -echo ' --libexecdir) \$libexecdir $libexecdir' >>$F -echo ' --datadir) \$datadir $datadir' >>$F -echo ' --sysconfdir) \$sysconfdir $sysconfdir' >>$F -echo ' --sharedstatedir) \$sharedstatedir$sharedstatedir' >>$F -echo ' --localstatedir) \$localstatedir $localstatedir' >>$F -echo ' --libdir) \$libdir $libdir' >>$F -echo ' --infodir) \$infodir $infodir' >>$F -echo ' --mandir) \$mandir $mandir' >>$F -echo ' --target) \$target $target' >>$F -echo ' --host) \$host $host' >>$F -echo ' --build) \$build $build' >>$F -echo ' --data) -I\$datadir/\$package' >>$F -echo ' --pkgdatadir) \$datadir/\$package' >>$F -echo ' --pkglibdir) \$libdir/\$package' >>$F -echo ' --pkgincludedir) \$includedir/\$package' >>$F -echo ' --help) generated by ax_create_generic_config.m4' >>$F -echo ' -I//varname and other inc-targets like --pkgdatainc supported' >>$F -echo ' -L//varname and other lib-targets, e.g. --pkgdatalib or --libadd' >>$F -echo 'EOF' >>$F -echo 'fi' >>$F -GENERIC_CONFIG="$F" - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking the number of available CPUs" >&5 -$as_echo_n "checking the number of available CPUs... " >&6; } - CPU_COUNT="0" - - case $host_os in #( - - *darwin*) : - - if test -x /usr/sbin/sysctl; then : - - sysctl_a=`/usr/sbin/sysctl -a 2>/dev/null| grep -c hw.cpu` - if test sysctl_a; then : - - CPU_COUNT=`/usr/sbin/sysctl -n hw.ncpu` - -fi - -fi ;; #( - - *linux*) : - - if test "x$CPU_COUNT" = "x0" -a -e /proc/cpuinfo; then : - - if test "x$CPU_COUNT" = "x0" -a -e /proc/cpuinfo; then : - - CPU_COUNT=`$EGREP -c '^processor' /proc/cpuinfo` - -fi - -fi - ;; #( - *) : - ;; -esac - - if test "x$CPU_COUNT" = "x0"; then : - - CPU_COUNT="1" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unable to detect (assuming 1) " >&5 -$as_echo "unable to detect (assuming 1) " >&6; } - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPU_COUNT " >&5 -$as_echo "$CPU_COUNT " >&6; } - -fi - - -AX_DOLLAR="\$" -AX_SRB="\\135" -AX_SLB="\\133" -AX_BS="\\\\" -AX_DQ="\"" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: adding automake macro support" >&5 -$as_echo "$as_me: adding automake macro support" >&6;} -AMINCLUDE="aminclude.am" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $AMINCLUDE" >&5 -$as_echo "$as_me: creating $AMINCLUDE" >&6;} -AMINCLUDE_TIME=`date` - - -printf " -# generated automatically by configure from AX_AUTOMAKE_MACROS -# on $AMINCLUDE_TIME - -" > "$AMINCLUDE" - - -INC_AMINCLUDE="include \$(top_builddir)/$AMINCLUDE" - - - - - - # Check whether --enable-jobserver was given. -if test "${enable_jobserver+set}" = set; then : - enableval=$enable_jobserver; -else - enable_jobserver=yes -fi - - if test "x$enable_jobserver" = "xyes"; then - let enable_jobserver=$CPU_COUNT+1 - fi - - if test "x$enable_jobserver" != "xno"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: added jobserver support to make for $enable_jobserver jobs" >&5 -$as_echo "$as_me: added jobserver support to make for $enable_jobserver jobs" >&6;} - - - - -printf "AM_MAKEFLAGS += -j$enable_jobserver \n" >> "$AMINCLUDE" - - - fi - - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -DEFS=-DHAVE_CONFIG_H - -ac_libobjs= -ac_ltlibobjs= -U= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 -$as_echo_n "checking that generated files are newer than configure... " >&6; } - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 -$as_echo "done" >&6; } - if test -n "$EXEEXT"; then - am__EXEEXT_TRUE= - am__EXEEXT_FALSE='#' -else - am__EXEEXT_TRUE='#' - am__EXEEXT_FALSE= -fi - -if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - as_fn_error $? "conditional \"AMDEP\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - as_fn_error $? "conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then - as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi - -if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - as_fn_error $? "conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then - as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then - as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${DEBUG_TRUE}" && test -z "${DEBUG_FALSE}"; then - as_fn_error $? "conditional \"DEBUG\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_IPV6_TRUE}" && test -z "${BUILD_IPV6_FALSE}"; then - as_fn_error $? "conditional \"BUILD_IPV6\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_LEANPSK_TRUE}" && test -z "${BUILD_LEANPSK_FALSE}"; then - as_fn_error $? "conditional \"BUILD_LEANPSK\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_SNIFFER_TRUE}" && test -z "${BUILD_SNIFFER_FALSE}"; then - as_fn_error $? "conditional \"BUILD_SNIFFER\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_SNIFFTEST_TRUE}" && test -z "${BUILD_SNIFFTEST_FALSE}"; then - as_fn_error $? "conditional \"BUILD_SNIFFTEST\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_AESGCM_TRUE}" && test -z "${BUILD_AESGCM_FALSE}"; then - as_fn_error $? "conditional \"BUILD_AESGCM\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_AESCCM_TRUE}" && test -z "${BUILD_AESCCM_FALSE}"; then - as_fn_error $? "conditional \"BUILD_AESCCM\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_AESNI_TRUE}" && test -z "${BUILD_AESNI_FALSE}"; then - as_fn_error $? "conditional \"BUILD_AESNI\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_CAMELLIA_TRUE}" && test -z "${BUILD_CAMELLIA_FALSE}"; then - as_fn_error $? "conditional \"BUILD_CAMELLIA\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_MD2_TRUE}" && test -z "${BUILD_MD2_FALSE}"; then - as_fn_error $? "conditional \"BUILD_MD2\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_RIPEMD_TRUE}" && test -z "${BUILD_RIPEMD_FALSE}"; then - as_fn_error $? "conditional \"BUILD_RIPEMD\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_BLAKE2_TRUE}" && test -z "${BUILD_BLAKE2_FALSE}"; then - as_fn_error $? "conditional \"BUILD_BLAKE2\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_SHA512_TRUE}" && test -z "${BUILD_SHA512_FALSE}"; then - as_fn_error $? "conditional \"BUILD_SHA512\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_DSA_TRUE}" && test -z "${BUILD_DSA_FALSE}"; then - as_fn_error $? "conditional \"BUILD_DSA\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_ECC_TRUE}" && test -z "${BUILD_ECC_FALSE}"; then - as_fn_error $? "conditional \"BUILD_ECC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_CURVE25519_TRUE}" && test -z "${BUILD_CURVE25519_FALSE}"; then - as_fn_error $? "conditional \"BUILD_CURVE25519\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_ED25519_TRUE}" && test -z "${BUILD_ED25519_FALSE}"; then - as_fn_error $? "conditional \"BUILD_ED25519\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_CURVED25519_SMALL_TRUE}" && test -z "${BUILD_CURVED25519_SMALL_FALSE}"; then - as_fn_error $? "conditional \"BUILD_CURVED25519_SMALL\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_FEMATH_TRUE}" && test -z "${BUILD_FEMATH_FALSE}"; then - as_fn_error $? "conditional \"BUILD_FEMATH\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_GEMATH_TRUE}" && test -z "${BUILD_GEMATH_FALSE}"; then - as_fn_error $? "conditional \"BUILD_GEMATH\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_MEMORY_TRUE}" && test -z "${BUILD_MEMORY_FALSE}"; then - as_fn_error $? "conditional \"BUILD_MEMORY\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_RSA_TRUE}" && test -z "${BUILD_RSA_FALSE}"; then - as_fn_error $? "conditional \"BUILD_RSA\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_DH_TRUE}" && test -z "${BUILD_DH_FALSE}"; then - as_fn_error $? "conditional \"BUILD_DH\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_ASN_TRUE}" && test -z "${BUILD_ASN_FALSE}"; then - as_fn_error $? "conditional \"BUILD_ASN\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_AES_TRUE}" && test -z "${BUILD_AES_FALSE}"; then - as_fn_error $? "conditional \"BUILD_AES\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_CODING_TRUE}" && test -z "${BUILD_CODING_FALSE}"; then - as_fn_error $? "conditional \"BUILD_CODING\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_DES3_TRUE}" && test -z "${BUILD_DES3_FALSE}"; then - as_fn_error $? "conditional \"BUILD_DES3\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_RC4_TRUE}" && test -z "${BUILD_RC4_FALSE}"; then - as_fn_error $? "conditional \"BUILD_RC4\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_MD5_TRUE}" && test -z "${BUILD_MD5_FALSE}"; then - as_fn_error $? "conditional \"BUILD_MD5\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_SHA_TRUE}" && test -z "${BUILD_SHA_FALSE}"; then - as_fn_error $? "conditional \"BUILD_SHA\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_MD4_TRUE}" && test -z "${BUILD_MD4_FALSE}"; then - as_fn_error $? "conditional \"BUILD_MD4\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_HC128_TRUE}" && test -z "${BUILD_HC128_FALSE}"; then - as_fn_error $? "conditional \"BUILD_HC128\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_RABBIT_TRUE}" && test -z "${BUILD_RABBIT_FALSE}"; then - as_fn_error $? "conditional \"BUILD_RABBIT\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_SHA512_TRUE}" && test -z "${BUILD_SHA512_FALSE}"; then - as_fn_error $? "conditional \"BUILD_SHA512\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_SHA512_TRUE}" && test -z "${BUILD_SHA512_FALSE}"; then - as_fn_error $? "conditional \"BUILD_SHA512\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_FIPS_TRUE}" && test -z "${BUILD_FIPS_FALSE}"; then - as_fn_error $? "conditional \"BUILD_FIPS\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_POLY1305_TRUE}" && test -z "${BUILD_POLY1305_FALSE}"; then - as_fn_error $? "conditional \"BUILD_POLY1305\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_CHACHA_TRUE}" && test -z "${BUILD_CHACHA_FALSE}"; then - as_fn_error $? "conditional \"BUILD_CHACHA\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_INLINE_TRUE}" && test -z "${BUILD_INLINE_FALSE}"; then - as_fn_error $? "conditional \"BUILD_INLINE\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_OCSP_TRUE}" && test -z "${BUILD_OCSP_FALSE}"; then - as_fn_error $? "conditional \"BUILD_OCSP\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_CRL_TRUE}" && test -z "${BUILD_CRL_FALSE}"; then - as_fn_error $? "conditional \"BUILD_CRL\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_CRL_MONITOR_TRUE}" && test -z "${BUILD_CRL_MONITOR_FALSE}"; then - as_fn_error $? "conditional \"BUILD_CRL_MONITOR\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_NTRU_TRUE}" && test -z "${BUILD_NTRU_FALSE}"; then - as_fn_error $? "conditional \"BUILD_NTRU\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_PKCS7_TRUE}" && test -z "${BUILD_PKCS7_FALSE}"; then - as_fn_error $? "conditional \"BUILD_PKCS7\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_PKCS7_TRUE}" && test -z "${BUILD_PKCS7_FALSE}"; then - as_fn_error $? "conditional \"BUILD_PKCS7\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${USE_VALGRIND_TRUE}" && test -z "${USE_VALGRIND_FALSE}"; then - as_fn_error $? "conditional \"USE_VALGRIND\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_ECC_TRUE}" && test -z "${BUILD_ECC_FALSE}"; then - as_fn_error $? "conditional \"BUILD_ECC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_PWDBASED_TRUE}" && test -z "${BUILD_PWDBASED_FALSE}"; then - as_fn_error $? "conditional \"BUILD_PWDBASED\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_FASTMATH_TRUE}" && test -z "${BUILD_FASTMATH_FALSE}"; then - as_fn_error $? "conditional \"BUILD_FASTMATH\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_SLOWMATH_TRUE}" && test -z "${BUILD_SLOWMATH_FALSE}"; then - as_fn_error $? "conditional \"BUILD_SLOWMATH\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_EXAMPLES_TRUE}" && test -z "${BUILD_EXAMPLES_FALSE}"; then - as_fn_error $? "conditional \"BUILD_EXAMPLES\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_LIBZ_TRUE}" && test -z "${BUILD_LIBZ_FALSE}"; then - as_fn_error $? "conditional \"BUILD_LIBZ\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_MCAPI_TRUE}" && test -z "${BUILD_MCAPI_FALSE}"; then - as_fn_error $? "conditional \"BUILD_MCAPI\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_CRL_TRUE}" && test -z "${BUILD_CRL_FALSE}"; then - as_fn_error $? "conditional \"BUILD_CRL\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_OCSP_TRUE}" && test -z "${BUILD_OCSP_FALSE}"; then - as_fn_error $? "conditional \"BUILD_OCSP\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${IS_VCS_CHECKOUT_TRUE}" && test -z "${IS_VCS_CHECKOUT_FALSE}"; then - as_fn_error $? "conditional \"IS_VCS_CHECKOUT\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi - -: "${CONFIG_STATUS=./config.status}" -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by wolfssl $as_me 3.6.0, which was -generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - -case $ac_config_headers in *" -"*) set x $ac_config_headers; shift; ac_config_headers=$*;; -esac - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" -config_headers="$ac_config_headers" -config_commands="$ac_config_commands" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE - -Configuration files: -$config_files - -Configuration headers: -$config_headers - -Configuration commands: -$config_commands - -Report bugs to . -wolfssl home page: ." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" -ac_cs_version="\\ -wolfssl config.status 3.6.0 -configured by $0, generated by GNU Autoconf 2.69, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2012 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -INSTALL='$INSTALL' -MKDIR_P='$MKDIR_P' -AWK='$AWK' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=?*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append CONFIG_HEADERS " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h) - # Conflict between --help and --header - as_fn_error $? "ambiguous option: \`$1' -Try \`$0 --help' for more information.";; - --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# -# INIT-COMMANDS -# -AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" - - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -sed_quote_subst='$sed_quote_subst' -double_quote_subst='$double_quote_subst' -delay_variable_subst='$delay_variable_subst' -macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' -macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' -enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' -enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' -pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' -enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' -SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' -ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' -PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' -host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' -host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' -host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' -build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' -build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' -build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' -SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' -Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' -GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' -EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' -FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' -LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' -NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' -LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' -max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' -ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' -exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' -lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' -lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' -lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' -lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' -lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' -reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' -reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' -OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' -deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' -file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' -file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' -want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' -DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' -sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' -AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' -AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' -archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' -STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' -RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' -old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' -old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' -old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' -lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' -CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' -CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' -compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' -GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' -nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' -lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' -objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' -MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' -lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' -need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' -MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' -DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' -NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' -LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' -OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' -OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' -libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' -shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' -extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' -archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' -enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' -export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' -whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' -compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' -old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' -old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' -archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' -archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' -module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' -module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' -with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' -allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' -no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' -hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' -hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' -hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' -hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' -hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' -hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' -inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' -link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' -always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' -export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' -exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' -include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' -prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' -postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' -file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' -variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' -need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' -need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' -version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' -runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' -shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' -shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' -libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' -library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' -soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' -install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' -postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' -postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' -finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' -finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' -hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' -sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' -sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' -hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' -enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' -enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' -enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' -old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' -striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' -compiler_lib_search_dirs='`$ECHO "$compiler_lib_search_dirs" | $SED "$delay_single_quote_subst"`' -predep_objects='`$ECHO "$predep_objects" | $SED "$delay_single_quote_subst"`' -postdep_objects='`$ECHO "$postdep_objects" | $SED "$delay_single_quote_subst"`' -predeps='`$ECHO "$predeps" | $SED "$delay_single_quote_subst"`' -postdeps='`$ECHO "$postdeps" | $SED "$delay_single_quote_subst"`' -compiler_lib_search_path='`$ECHO "$compiler_lib_search_path" | $SED "$delay_single_quote_subst"`' -LD_CXX='`$ECHO "$LD_CXX" | $SED "$delay_single_quote_subst"`' -reload_flag_CXX='`$ECHO "$reload_flag_CXX" | $SED "$delay_single_quote_subst"`' -reload_cmds_CXX='`$ECHO "$reload_cmds_CXX" | $SED "$delay_single_quote_subst"`' -old_archive_cmds_CXX='`$ECHO "$old_archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' -compiler_CXX='`$ECHO "$compiler_CXX" | $SED "$delay_single_quote_subst"`' -GCC_CXX='`$ECHO "$GCC_CXX" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "$lt_prog_compiler_no_builtin_flag_CXX" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_pic_CXX='`$ECHO "$lt_prog_compiler_pic_CXX" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_wl_CXX='`$ECHO "$lt_prog_compiler_wl_CXX" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_static_CXX='`$ECHO "$lt_prog_compiler_static_CXX" | $SED "$delay_single_quote_subst"`' -lt_cv_prog_compiler_c_o_CXX='`$ECHO "$lt_cv_prog_compiler_c_o_CXX" | $SED "$delay_single_quote_subst"`' -archive_cmds_need_lc_CXX='`$ECHO "$archive_cmds_need_lc_CXX" | $SED "$delay_single_quote_subst"`' -enable_shared_with_static_runtimes_CXX='`$ECHO "$enable_shared_with_static_runtimes_CXX" | $SED "$delay_single_quote_subst"`' -export_dynamic_flag_spec_CXX='`$ECHO "$export_dynamic_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' -whole_archive_flag_spec_CXX='`$ECHO "$whole_archive_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' -compiler_needs_object_CXX='`$ECHO "$compiler_needs_object_CXX" | $SED "$delay_single_quote_subst"`' -old_archive_from_new_cmds_CXX='`$ECHO "$old_archive_from_new_cmds_CXX" | $SED "$delay_single_quote_subst"`' -old_archive_from_expsyms_cmds_CXX='`$ECHO "$old_archive_from_expsyms_cmds_CXX" | $SED "$delay_single_quote_subst"`' -archive_cmds_CXX='`$ECHO "$archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' -archive_expsym_cmds_CXX='`$ECHO "$archive_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' -module_cmds_CXX='`$ECHO "$module_cmds_CXX" | $SED "$delay_single_quote_subst"`' -module_expsym_cmds_CXX='`$ECHO "$module_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' -with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`' -allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' -no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_minus_L_CXX='`$ECHO "$hardcode_minus_L_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_shlibpath_var_CXX='`$ECHO "$hardcode_shlibpath_var_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_automatic_CXX='`$ECHO "$hardcode_automatic_CXX" | $SED "$delay_single_quote_subst"`' -inherit_rpath_CXX='`$ECHO "$inherit_rpath_CXX" | $SED "$delay_single_quote_subst"`' -link_all_deplibs_CXX='`$ECHO "$link_all_deplibs_CXX" | $SED "$delay_single_quote_subst"`' -always_export_symbols_CXX='`$ECHO "$always_export_symbols_CXX" | $SED "$delay_single_quote_subst"`' -export_symbols_cmds_CXX='`$ECHO "$export_symbols_cmds_CXX" | $SED "$delay_single_quote_subst"`' -exclude_expsyms_CXX='`$ECHO "$exclude_expsyms_CXX" | $SED "$delay_single_quote_subst"`' -include_expsyms_CXX='`$ECHO "$include_expsyms_CXX" | $SED "$delay_single_quote_subst"`' -prelink_cmds_CXX='`$ECHO "$prelink_cmds_CXX" | $SED "$delay_single_quote_subst"`' -postlink_cmds_CXX='`$ECHO "$postlink_cmds_CXX" | $SED "$delay_single_quote_subst"`' -file_list_spec_CXX='`$ECHO "$file_list_spec_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_action_CXX='`$ECHO "$hardcode_action_CXX" | $SED "$delay_single_quote_subst"`' -compiler_lib_search_dirs_CXX='`$ECHO "$compiler_lib_search_dirs_CXX" | $SED "$delay_single_quote_subst"`' -predep_objects_CXX='`$ECHO "$predep_objects_CXX" | $SED "$delay_single_quote_subst"`' -postdep_objects_CXX='`$ECHO "$postdep_objects_CXX" | $SED "$delay_single_quote_subst"`' -predeps_CXX='`$ECHO "$predeps_CXX" | $SED "$delay_single_quote_subst"`' -postdeps_CXX='`$ECHO "$postdeps_CXX" | $SED "$delay_single_quote_subst"`' -compiler_lib_search_path_CXX='`$ECHO "$compiler_lib_search_path_CXX" | $SED "$delay_single_quote_subst"`' - -LTCC='$LTCC' -LTCFLAGS='$LTCFLAGS' -compiler='$compiler_DEFAULT' - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$1 -_LTECHO_EOF' -} - -# Quote evaled strings. -for var in SHELL \ -ECHO \ -PATH_SEPARATOR \ -SED \ -GREP \ -EGREP \ -FGREP \ -LD \ -NM \ -LN_S \ -lt_SP2NL \ -lt_NL2SP \ -reload_flag \ -OBJDUMP \ -deplibs_check_method \ -file_magic_cmd \ -file_magic_glob \ -want_nocaseglob \ -DLLTOOL \ -sharedlib_from_linklib_cmd \ -AR \ -AR_FLAGS \ -archiver_list_spec \ -STRIP \ -RANLIB \ -CC \ -CFLAGS \ -compiler \ -lt_cv_sys_global_symbol_pipe \ -lt_cv_sys_global_symbol_to_cdecl \ -lt_cv_sys_global_symbol_to_c_name_address \ -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ -nm_file_list_spec \ -lt_prog_compiler_no_builtin_flag \ -lt_prog_compiler_pic \ -lt_prog_compiler_wl \ -lt_prog_compiler_static \ -lt_cv_prog_compiler_c_o \ -need_locks \ -MANIFEST_TOOL \ -DSYMUTIL \ -NMEDIT \ -LIPO \ -OTOOL \ -OTOOL64 \ -shrext_cmds \ -export_dynamic_flag_spec \ -whole_archive_flag_spec \ -compiler_needs_object \ -with_gnu_ld \ -allow_undefined_flag \ -no_undefined_flag \ -hardcode_libdir_flag_spec \ -hardcode_libdir_separator \ -exclude_expsyms \ -include_expsyms \ -file_list_spec \ -variables_saved_for_relink \ -libname_spec \ -library_names_spec \ -soname_spec \ -install_override_mode \ -finish_eval \ -old_striplib \ -striplib \ -compiler_lib_search_dirs \ -predep_objects \ -postdep_objects \ -predeps \ -postdeps \ -compiler_lib_search_path \ -LD_CXX \ -reload_flag_CXX \ -compiler_CXX \ -lt_prog_compiler_no_builtin_flag_CXX \ -lt_prog_compiler_pic_CXX \ -lt_prog_compiler_wl_CXX \ -lt_prog_compiler_static_CXX \ -lt_cv_prog_compiler_c_o_CXX \ -export_dynamic_flag_spec_CXX \ -whole_archive_flag_spec_CXX \ -compiler_needs_object_CXX \ -with_gnu_ld_CXX \ -allow_undefined_flag_CXX \ -no_undefined_flag_CXX \ -hardcode_libdir_flag_spec_CXX \ -hardcode_libdir_separator_CXX \ -exclude_expsyms_CXX \ -include_expsyms_CXX \ -file_list_spec_CXX \ -compiler_lib_search_dirs_CXX \ -predep_objects_CXX \ -postdep_objects_CXX \ -predeps_CXX \ -postdeps_CXX \ -compiler_lib_search_path_CXX; do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in - *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Double-quote double-evaled strings. -for var in reload_cmds \ -old_postinstall_cmds \ -old_postuninstall_cmds \ -old_archive_cmds \ -extract_expsyms_cmds \ -old_archive_from_new_cmds \ -old_archive_from_expsyms_cmds \ -archive_cmds \ -archive_expsym_cmds \ -module_cmds \ -module_expsym_cmds \ -export_symbols_cmds \ -prelink_cmds \ -postlink_cmds \ -postinstall_cmds \ -postuninstall_cmds \ -finish_cmds \ -sys_lib_search_path_spec \ -sys_lib_dlsearch_path_spec \ -reload_cmds_CXX \ -old_archive_cmds_CXX \ -old_archive_from_new_cmds_CXX \ -old_archive_from_expsyms_cmds_CXX \ -archive_cmds_CXX \ -archive_expsym_cmds_CXX \ -module_cmds_CXX \ -module_expsym_cmds_CXX \ -export_symbols_cmds_CXX \ -prelink_cmds_CXX \ -postlink_cmds_CXX; do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in - *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -ac_aux_dir='$ac_aux_dir' -xsi_shell='$xsi_shell' -lt_shell_append='$lt_shell_append' - -# See if we are running on zsh, and set the options which allow our -# commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - - - PACKAGE='$PACKAGE' - VERSION='$VERSION' - TIMESTAMP='$TIMESTAMP' - RM='$RM' - ofile='$ofile' - - - - - - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;; - "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; - "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; - "stamp-h") CONFIG_FILES="$CONFIG_FILES stamp-h" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "wolfssl/version.h") CONFIG_FILES="$CONFIG_FILES wolfssl/version.h" ;; - "wolfssl/options.h") CONFIG_FILES="$CONFIG_FILES wolfssl/options.h" ;; - "support/wolfssl.pc") CONFIG_FILES="$CONFIG_FILES support/wolfssl.pc" ;; - "rpm/spec") CONFIG_FILES="$CONFIG_FILES rpm/spec" ;; - - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= ac_tmp= - trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\)..*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\)..*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// -s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - -# Set up the scripts for CONFIG_HEADERS section. -# No need to generate them if there are no CONFIG_HEADERS. -# This happens for instance with `./config.status Makefile'. -if test -n "$CONFIG_HEADERS"; then -cat >"$ac_tmp/defines.awk" <<\_ACAWK || -BEGIN { -_ACEOF - -# Transform confdefs.h into an awk script `defines.awk', embedded as -# here-document in config.status, that substitutes the proper values into -# config.h.in to produce config.h. - -# Create a delimiter string that does not exist in confdefs.h, to ease -# handling of long lines. -ac_delim='%!_!# ' -for ac_last_try in false false :; do - ac_tt=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_tt"; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done - -# For the awk script, D is an array of macro values keyed by name, -# likewise P contains macro parameters if any. Preserve backslash -# newline sequences. - -ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* -sed -n ' -s/.\{148\}/&'"$ac_delim"'/g -t rset -:rset -s/^[ ]*#[ ]*define[ ][ ]*/ / -t def -d -:def -s/\\$// -t bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3"/p -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p -d -:bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3\\\\\\n"\\/p -t cont -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p -t cont -d -:cont -n -s/.\{148\}/&'"$ac_delim"'/g -t clear -:clear -s/\\$// -t bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/"/p -d -:bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p -b cont -' >$CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - for (key in D) D_is_set[key] = 1 - FS = "" -} -/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { - line = \$ 0 - split(line, arg, " ") - if (arg[1] == "#") { - defundef = arg[2] - mac1 = arg[3] - } else { - defundef = substr(arg[1], 2) - mac1 = arg[2] - } - split(mac1, mac2, "(") #) - macro = mac2[1] - prefix = substr(line, 1, index(line, defundef) - 1) - if (D_is_set[macro]) { - # Preserve the white space surrounding the "#". - print prefix "define", macro P[macro] D[macro] - next - } else { - # Replace #undef with comments. This is necessary, for example, - # in the case of _POSIX_SOURCE, which is predefined and required - # on some systems where configure will not decide to define it. - if (defundef == "undef") { - print "/*", prefix defundef, macro, "*/" - next - } - } -} -{ print } -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 -fi # test -n "$CONFIG_HEADERS" - - -eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$ac_tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; - esac - ac_MKDIR_P=$MKDIR_P - case $MKDIR_P in - [\\/$]* | ?:[\\/]* ) ;; - */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; - esac -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -s&@INSTALL@&$ac_INSTALL&;t t -s&@MKDIR_P@&$ac_MKDIR_P&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&2;} - - rm -f "$ac_tmp/stdin" - case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; - esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - :H) - # - # CONFIG_HEADER - # - if test x"$ac_file" != x-; then - { - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" - } >"$ac_tmp/config.h" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 -$as_echo "$as_me: $ac_file is unchanged" >&6;} - else - rm -f "$ac_file" - mv "$ac_tmp/config.h" "$ac_file" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - fi - else - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error $? "could not create -" "$LINENO" 5 - fi -# Compute "$ac_file"'s index in $config_headers. -_am_arg="$ac_file" -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $_am_arg | $_am_arg:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || -$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$_am_arg" : 'X\(//\)[^/]' \| \ - X"$_am_arg" : 'X\(//\)$' \| \ - X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$_am_arg" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'`/stamp-h$_am_stamp_count - ;; - - :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 -$as_echo "$as_me: executing $ac_file commands" >&6;} - ;; - esac - - - case $ac_file$ac_mode in - "depfiles":C) test x"$AMDEP_TRUE" != x"" || { - # Older Autoconf quotes --file arguments for eval, but not when files - # are listed without --file. Let's play safe and only enable the eval - # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac - shift - for mf - do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named 'Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line - # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`$as_dirname -- "$mf" || -$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$mf" : 'X\(//\)[^/]' \| \ - X"$mf" : 'X\(//\)$' \| \ - X"$mf" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$mf" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running 'make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "$am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`$as_dirname -- "$file" || -$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$file" : 'X\(//\)[^/]' \| \ - X"$file" : 'X\(//\)$' \| \ - X"$file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir=$dirpart/$fdir; as_fn_mkdir_p - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done - done -} - ;; - "libtool":C) - - # See if we are running on zsh, and set the options which allow our - # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - - cfgfile="${ofile}T" - trap "$RM \"$cfgfile\"; exit 1" 1 2 15 - $RM "$cfgfile" - - cat <<_LT_EOF >> "$cfgfile" -#! $SHELL - -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is part of GNU Libtool. -# -# GNU Libtool 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. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - -# The names of the tagged configurations supported by this script. -available_tags="CXX " - -# ### BEGIN LIBTOOL CONFIG - -# Which release of libtool.m4 was used? -macro_version=$macro_version -macro_revision=$macro_revision - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# What type of objects to build. -pic_mode=$pic_mode - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# An echo program that protects backslashes. -ECHO=$lt_ECHO - -# The PATH separator for the build system. -PATH_SEPARATOR=$lt_PATH_SEPARATOR - -# The host system. -host_alias=$host_alias -host=$host -host_os=$host_os - -# The build system. -build_alias=$build_alias -build=$build -build_os=$build_os - -# A sed program that does not truncate output. -SED=$lt_SED - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="\$SED -e 1s/^X//" - -# A grep program that handles long lines. -GREP=$lt_GREP - -# An ERE matcher. -EGREP=$lt_EGREP - -# A literal string matcher. -FGREP=$lt_FGREP - -# A BSD- or MS-compatible name lister. -NM=$lt_NM - -# Whether we need soft or hard links. -LN_S=$lt_LN_S - -# What is the maximum length of a command? -max_cmd_len=$max_cmd_len - -# Object file suffix (normally "o"). -objext=$ac_objext - -# Executable file suffix (normally ""). -exeext=$exeext - -# whether the shell understands "unset". -lt_unset=$lt_unset - -# turn spaces into newlines. -SP2NL=$lt_lt_SP2NL - -# turn newlines into spaces. -NL2SP=$lt_lt_NL2SP - -# convert \$build file names to \$host format. -to_host_file_cmd=$lt_cv_to_host_file_cmd - -# convert \$build files to toolchain format. -to_tool_file_cmd=$lt_cv_to_tool_file_cmd - -# An object symbol dumper. -OBJDUMP=$lt_OBJDUMP - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method=$lt_deplibs_check_method - -# Command to use when deplibs_check_method = "file_magic". -file_magic_cmd=$lt_file_magic_cmd - -# How to find potential files when deplibs_check_method = "file_magic". -file_magic_glob=$lt_file_magic_glob - -# Find potential files using nocaseglob when deplibs_check_method = "file_magic". -want_nocaseglob=$lt_want_nocaseglob - -# DLL creation program. -DLLTOOL=$lt_DLLTOOL - -# Command to associate shared and link libraries. -sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd - -# The archiver. -AR=$lt_AR - -# Flags to create an archive. -AR_FLAGS=$lt_AR_FLAGS - -# How to feed a file listing to the archiver. -archiver_list_spec=$lt_archiver_list_spec - -# A symbol stripping program. -STRIP=$lt_STRIP - -# Commands used to install an old-style archive. -RANLIB=$lt_RANLIB -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Whether to use a lock for old archive extraction. -lock_old_archive_extraction=$lock_old_archive_extraction - -# A C compiler. -LTCC=$lt_CC - -# LTCC compiler flags. -LTCFLAGS=$lt_CFLAGS - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe - -# Transform the output of nm in a proper C declaration. -global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl - -# Transform the output of nm in a C name address pair. -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# Transform the output of nm in a C name address pair when lib prefix is needed. -global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix - -# Specify filename containing input files for \$NM. -nm_file_list_spec=$lt_nm_file_list_spec - -# The root where to search for dependent libraries,and in which our libraries should be installed. -lt_sysroot=$lt_sysroot - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# Used to examine libraries when file_magic_cmd begins with "file". -MAGIC_CMD=$MAGIC_CMD - -# Must we lock files when doing compilation? -need_locks=$lt_need_locks - -# Manifest tool. -MANIFEST_TOOL=$lt_MANIFEST_TOOL - -# Tool to manipulate archived DWARF debug symbol files on Mac OS X. -DSYMUTIL=$lt_DSYMUTIL - -# Tool to change global to local symbols on Mac OS X. -NMEDIT=$lt_NMEDIT - -# Tool to manipulate fat objects and archives on Mac OS X. -LIPO=$lt_LIPO - -# ldd/readelf like tool for Mach-O binaries on Mac OS X. -OTOOL=$lt_OTOOL - -# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. -OTOOL64=$lt_OTOOL64 - -# Old archive suffix (normally "a"). -libext=$libext - -# Shared library suffix (normally ".so"). -shrext_cmds=$lt_shrext_cmds - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at link time. -variables_saved_for_relink=$lt_variables_saved_for_relink - -# Do we need the "lib" prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Library versioning type. -version_type=$version_type - -# Shared library runtime path variable. -runpath_var=$runpath_var - -# Shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Permission mode override for installation of shared libraries. -install_override_mode=$lt_install_override_mode - -# Command to use after installation of a shared archive. -postinstall_cmds=$lt_postinstall_cmds - -# Command to use after uninstallation of a shared archive. -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# As "finish_cmds", except a single script fragment to be evaled but -# not shown. -finish_eval=$lt_finish_eval - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Compile-time system search path for libraries. -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec - -# Run-time system search path for libraries. -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - - -# The linker used to build libraries. -LD=$lt_LD - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# Commands used to build an old-style archive. -old_archive_cmds=$lt_old_archive_cmds - -# A language specific compiler. -CC=$lt_compiler - -# Is the compiler the GNU compiler? -with_gcc=$GCC - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc - -# Whether or not to disallow shared libs when runtime libs are static. -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec - -# Whether the compiler copes with passing no objects directly. -compiler_needs_object=$lt_compiler_needs_object - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds - -# Commands used to build a shared archive. -archive_cmds=$lt_archive_cmds -archive_expsym_cmds=$lt_archive_expsym_cmds - -# Commands used to build a loadable module if different from building -# a shared archive. -module_cmds=$lt_module_cmds -module_expsym_cmds=$lt_module_expsym_cmds - -# Whether we are building with GNU ld or not. -with_gnu_ld=$lt_with_gnu_ld - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag - -# Flag that enforces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec - -# Whether we need a single "-rpath" flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator - -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes -# DIR into the resulting binary. -hardcode_direct=$hardcode_direct - -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes -# DIR into the resulting binary and the resulting library dependency is -# "absolute",i.e impossible to change by setting \${shlibpath_var} if the -# library is relocated. -hardcode_direct_absolute=$hardcode_direct_absolute - -# Set to "yes" if using the -LDIR flag during linking hardcodes DIR -# into the resulting binary. -hardcode_minus_L=$hardcode_minus_L - -# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR -# into the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var - -# Set to "yes" if building a shared library automatically hardcodes DIR -# into the library and all subsequent libraries and executables linked -# against it. -hardcode_automatic=$hardcode_automatic - -# Set to yes if linker adds runtime paths of dependent libraries -# to runtime path list. -inherit_rpath=$inherit_rpath - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs - -# Set to "yes" if exported symbols are required. -always_export_symbols=$always_export_symbols - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms - -# Commands necessary for linking programs (against libraries) with templates. -prelink_cmds=$lt_prelink_cmds - -# Commands necessary for finishing linking programs. -postlink_cmds=$lt_postlink_cmds - -# Specify filename containing input files. -file_list_spec=$lt_file_list_spec - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action - -# The directories searched by this compiler when creating a shared library. -compiler_lib_search_dirs=$lt_compiler_lib_search_dirs - -# Dependencies to place before and after the objects being linked to -# create a shared library. -predep_objects=$lt_predep_objects -postdep_objects=$lt_postdep_objects -predeps=$lt_predeps -postdeps=$lt_postdeps - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path - -# ### END LIBTOOL CONFIG - -_LT_EOF - - case $host_os in - aix3*) - cat <<\_LT_EOF >> "$cfgfile" -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -_LT_EOF - ;; - esac - - -ltmain="$ac_aux_dir/ltmain.sh" - - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '$q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - if test x"$xsi_shell" = xyes; then - sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ -func_dirname ()\ -{\ -\ case ${1} in\ -\ */*) func_dirname_result="${1%/*}${2}" ;;\ -\ * ) func_dirname_result="${3}" ;;\ -\ esac\ -} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_basename ()$/,/^} # func_basename /c\ -func_basename ()\ -{\ -\ func_basename_result="${1##*/}"\ -} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ -func_dirname_and_basename ()\ -{\ -\ case ${1} in\ -\ */*) func_dirname_result="${1%/*}${2}" ;;\ -\ * ) func_dirname_result="${3}" ;;\ -\ esac\ -\ func_basename_result="${1##*/}"\ -} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ -func_stripname ()\ -{\ -\ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ -\ # positional parameters, so assign one to ordinary parameter first.\ -\ func_stripname_result=${3}\ -\ func_stripname_result=${func_stripname_result#"${1}"}\ -\ func_stripname_result=${func_stripname_result%"${2}"}\ -} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ -func_split_long_opt ()\ -{\ -\ func_split_long_opt_name=${1%%=*}\ -\ func_split_long_opt_arg=${1#*=}\ -} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ -func_split_short_opt ()\ -{\ -\ func_split_short_opt_arg=${1#??}\ -\ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ -} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ -func_lo2o ()\ -{\ -\ case ${1} in\ -\ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ -\ *) func_lo2o_result=${1} ;;\ -\ esac\ -} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_xform ()$/,/^} # func_xform /c\ -func_xform ()\ -{\ - func_xform_result=${1%.*}.lo\ -} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_arith ()$/,/^} # func_arith /c\ -func_arith ()\ -{\ - func_arith_result=$(( $* ))\ -} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_len ()$/,/^} # func_len /c\ -func_len ()\ -{\ - func_len_result=${#1}\ -} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - -fi - -if test x"$lt_shell_append" = xyes; then - sed -e '/^func_append ()$/,/^} # func_append /c\ -func_append ()\ -{\ - eval "${1}+=\\${2}"\ -} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ -func_append_quoted ()\ -{\ -\ func_quote_for_eval "${2}"\ -\ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ -} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - # Save a `func_append' function call where possible by direct use of '+=' - sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -else - # Save a `func_append' function call even when '+=' is not available - sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -fi - -if test x"$_lt_function_replace_fail" = x":"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 -$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} -fi - - - mv -f "$cfgfile" "$ofile" || - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" - - - cat <<_LT_EOF >> "$ofile" - -# ### BEGIN LIBTOOL TAG CONFIG: CXX - -# The linker used to build libraries. -LD=$lt_LD_CXX - -# How to create reloadable object files. -reload_flag=$lt_reload_flag_CXX -reload_cmds=$lt_reload_cmds_CXX - -# Commands used to build an old-style archive. -old_archive_cmds=$lt_old_archive_cmds_CXX - -# A language specific compiler. -CC=$lt_compiler_CXX - -# Is the compiler the GNU compiler? -with_gcc=$GCC_CXX - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic_CXX - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl_CXX - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static_CXX - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc_CXX - -# Whether or not to disallow shared libs when runtime libs are static. -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX - -# Whether the compiler copes with passing no objects directly. -compiler_needs_object=$lt_compiler_needs_object_CXX - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX - -# Commands used to build a shared archive. -archive_cmds=$lt_archive_cmds_CXX -archive_expsym_cmds=$lt_archive_expsym_cmds_CXX - -# Commands used to build a loadable module if different from building -# a shared archive. -module_cmds=$lt_module_cmds_CXX -module_expsym_cmds=$lt_module_expsym_cmds_CXX - -# Whether we are building with GNU ld or not. -with_gnu_ld=$lt_with_gnu_ld_CXX - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag_CXX - -# Flag that enforces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag_CXX - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX - -# Whether we need a single "-rpath" flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX - -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes -# DIR into the resulting binary. -hardcode_direct=$hardcode_direct_CXX - -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes -# DIR into the resulting binary and the resulting library dependency is -# "absolute",i.e impossible to change by setting \${shlibpath_var} if the -# library is relocated. -hardcode_direct_absolute=$hardcode_direct_absolute_CXX - -# Set to "yes" if using the -LDIR flag during linking hardcodes DIR -# into the resulting binary. -hardcode_minus_L=$hardcode_minus_L_CXX - -# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR -# into the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX - -# Set to "yes" if building a shared library automatically hardcodes DIR -# into the library and all subsequent libraries and executables linked -# against it. -hardcode_automatic=$hardcode_automatic_CXX - -# Set to yes if linker adds runtime paths of dependent libraries -# to runtime path list. -inherit_rpath=$inherit_rpath_CXX - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs_CXX - -# Set to "yes" if exported symbols are required. -always_export_symbols=$always_export_symbols_CXX - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds_CXX - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms_CXX - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms_CXX - -# Commands necessary for linking programs (against libraries) with templates. -prelink_cmds=$lt_prelink_cmds_CXX - -# Commands necessary for finishing linking programs. -postlink_cmds=$lt_postlink_cmds_CXX - -# Specify filename containing input files. -file_list_spec=$lt_file_list_spec_CXX - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action_CXX - -# The directories searched by this compiler when creating a shared library. -compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX - -# Dependencies to place before and after the objects being linked to -# create a shared library. -predep_objects=$lt_predep_objects_CXX -postdep_objects=$lt_postdep_objects_CXX -predeps=$lt_predeps_CXX -postdeps=$lt_postdeps_CXX - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path_CXX - -# ### END LIBTOOL TAG CONFIG: CXX -_LT_EOF - - ;; - "stamp-h":F) echo timestamp > stamp-h ;; - - esac -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit 1 -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - - - -# force make clean -echo "---" -echo "Running make clean..." -make clean >/dev/null 2>&1 -# Touch files that may not be in repository -echo "Touching File..." -touch ctaocrypt/src/fips.c -touch ctaocrypt/src/fips_test.c -echo - -# generate user options header -echo "---" -echo "Generating user options header..." - -OPTION_FILE="wolfssl/options.h" -#if -#OPTION_FILE+="cyassl/options.h" -#fi -rm -f $OPTION_FILE - -echo "/* wolfssl options.h" > $OPTION_FILE -echo " * generated from configure options" >> $OPTION_FILE -echo " *" >> $OPTION_FILE -echo " * Copyright (C) 2006-2015 wolfSSL Inc." >> $OPTION_FILE -echo " *" >> $OPTION_FILE -echo " * This file is part of wolfSSL. (formerly known as CyaSSL)" >> $OPTION_FILE -echo " *" >> $OPTION_FILE -echo " */" >> $OPTION_FILE - -echo "" >> $OPTION_FILE -echo "#pragma once" >> $OPTION_FILE -echo "" >> $OPTION_FILE -echo "#ifdef __cplusplus" >> $OPTION_FILE -echo "extern \"C\" {" >> $OPTION_FILE -echo "#endif" >> $OPTION_FILE -echo "" >> $OPTION_FILE - -for option in $OPTION_FLAGS; do - defonly=`echo $option | sed 's/-D//'` - if test "$defonly" != "$option" - then - noequalsign=`echo $defonly | sed 's/=/ /'` - if test "$noequalsign" = "NDEBUG" || test "$noequalsign" = "DEBUG" - then - echo "not outputing (N)DEBUG to $OPTION_FILE" - continue - fi - - # allow user to igonore system options - ignoresys=no - if [[ $noequalsign == _* ]] ; - then - ignoresys=yes - echo "#ifndef WOLFSSL_OPTIONS_IGNORE_SYS" >> $OPTION_FILE - fi - - noarg=`echo $defonly | sed 's/=.*//'` - echo "#undef $noarg" >> $OPTION_FILE - echo "#define $noequalsign" >> $OPTION_FILE - - if test "$ignoresys" = "yes" - then - echo "#endif" >> $OPTION_FILE - fi - - echo "" >> $OPTION_FILE - else - echo "option w/o begin -D is $option, not saving to $OPTION_FILE" - fi -done - -echo "" >> $OPTION_FILE -echo "#ifdef __cplusplus" >> $OPTION_FILE -echo "}" >> $OPTION_FILE -echo "#endif" >> $OPTION_FILE -echo "" >> $OPTION_FILE -echo - -#backwards compatability for those who have included options or version -touch cyassl/options.h -echo "/* cyassl options.h" > cyassl/options.h -echo " * generated from wolfssl/options.h" >> cyassl/options.h -echo " */" >> cyassl/options.h -echo "" -while read -r line -do - echo "$line" >> cyassl/options.h -done < $OPTION_FILE - -# output config summary -echo "---" -echo "Configuration summary for $PACKAGE_NAME version $VERSION" -echo "" -echo " * Installation prefix: $prefix" -echo " * System type: $host_vendor-$host_os" -echo " * Host CPU: $host_cpu" -echo " * C Compiler: $CC" -echo " * C Flags: $CFLAGS" -echo " * C++ Compiler: $CXX" -echo " * C++ Flags: $CXXFLAGS" -echo " * CPP Flags: $CPPFLAGS" -echo " * LIB Flags: $LIB" -echo " * Debug enabled: $ax_enable_debug" -echo " * Warnings as failure: $ac_cv_warnings_as_errors" -echo " * make -j: $enable_jobserver" -echo " * VCS checkout: $ac_cv_vcs_checkout" -echo -echo " Features " -echo " * Single threaded: $ENABLED_SINGLETHREADED" -echo " * Filesystem: $ENABLED_FILESYSTEM" -echo " * OpenSSL Extra API: $ENABLED_OPENSSLEXTRA" -echo " * Max Strength Build: $ENABLED_MAXSTRENGTH" -echo " * fastmath: $ENABLED_FASTMATH" -echo " * sniffer: $ENABLED_SNIFFER" -echo " * snifftest: $ENABLED_SNIFFTEST" -echo " * ARC4: $ENABLED_ARC4" -echo " * AES: $ENABLED_AES" -echo " * AES-NI: $ENABLED_AESNI" -echo " * AES-GCM: $ENABLED_AESGCM" -echo " * AES-CCM: $ENABLED_AESCCM" -echo " * DES3: $ENABLED_DES3" -echo " * Camellia: $ENABLED_CAMELLIA" -echo " * NULL Cipher: $ENABLED_NULL_CIPHER" -echo " * MD5: $ENABLED_MD5" -echo " * RIPEMD: $ENABLED_RIPEMD" -echo " * SHA: $ENABLED_SHA" -echo " * SHA-512: $ENABLED_SHA512" -echo " * BLAKE2: $ENABLED_BLAKE2" -echo " * keygen: $ENABLED_KEYGEN" -echo " * certgen: $ENABLED_CERTGEN" -echo " * certreq: $ENABLED_CERTREQ" -echo " * HC-128: $ENABLED_HC128" -echo " * RABBIT: $ENABLED_RABBIT" -echo " * CHACHA: $ENABLED_CHACHA" -echo " * Hash DRBG: $ENABLED_HASHDRBG" -echo " * PWDBASED: $ENABLED_PWDBASED" -echo " * HKDF: $ENABLED_HKDF" -echo " * MD4: $ENABLED_MD4" -echo " * PSK: $ENABLED_PSK" -echo " * Poly1305: $ENABLED_POLY1305" -echo " * LEANPSK: $ENABLED_LEANPSK" -echo " * RSA: $ENABLED_RSA" -echo " * DSA: $ENABLED_DSA" -echo " * DH: $ENABLED_DH" -echo " * ECC: $ENABLED_ECC" -echo " * CURVE25519: $ENABLED_CURVE25519" -echo " * ED25519: $ENABLED_ED25519" -echo " * FPECC: $ENABLED_FPECC" -echo " * ECC_ENCRYPT: $ENABLED_ECC_ENCRYPT" -echo " * ASN: $ENABLED_ASN" -echo " * Anonymous cipher: $ENABLED_ANON" -echo " * CODING: $ENABLED_CODING" -echo " * MEMORY: $ENABLED_MEMORY" -echo " * I/O POOL: $ENABLED_IOPOOL" -echo " * ERROR_STRINGS: $ENABLED_ERROR_STRINGS" -echo " * DTLS: $ENABLED_DTLS" -echo " * Old TLS Versions: $ENABLED_OLD_TLS" -echo " * OCSP: $ENABLED_OCSP" -echo " * CRL: $ENABLED_CRL" -echo " * CRL-MONITOR: $ENABLED_CRL_MONITOR" -echo " * Persistent session cache: $ENABLED_SAVESESSION" -echo " * Persistent cert cache: $ENABLED_SAVECERT" -echo " * Atomic User Record Layer: $ENABLED_ATOMICUSER" -echo " * Public Key Callbacks: $ENABLED_PKCALLBACKS" -echo " * NTRU: $ENABLED_NTRU" -echo " * SNI: $ENABLED_SNI" -echo " * Maximum Fragment Length: $ENABLED_MAX_FRAGMENT" -echo " * Truncated HMAC: $ENABLED_TRUNCATED_HMAC" -echo " * Renegotiation Indication: $ENABLED_RENEGOTIATION_INDICATION" -echo " * Secure Renegotiation: $ENABLED_SECURE_RENEGOTIATION" -echo " * Supported Elliptic Curves: $ENABLED_SUPPORTED_CURVES" -echo " * Session Ticket: $ENABLED_SESSION_TICKET" -echo " * All TLS Extensions: $ENABLED_TLSX" -echo " * PKCS#7 $ENABLED_PKCS7" -echo " * wolfSCEP $ENABLED_WOLFSCEP" -echo " * Small Stack: $ENABLED_SMALL_STACK" -echo " * valgrind unit tests: $ENABLED_VALGRIND" -echo " * LIBZ: $ENABLED_LIBZ" -echo " * Examples: $ENABLED_EXAMPLES" -echo "" -echo "---" - diff --git a/FreeRTOS-Plus/Source/WolfSSL/configure.ac b/FreeRTOS-Plus/Source/WolfSSL/configure.ac deleted file mode 100755 index 4b6d331..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/configure.ac +++ /dev/null @@ -1,2229 +0,0 @@ -# configure.ac -# -# Copyright (C) 2006-2015 wolfSSL Inc. -# -# This file is part of wolfSSL. (formerly known as CyaSSL) -# -# - -AC_INIT([wolfssl],[3.6.0],[https://github.com/wolfssl/wolfssl/issues],[wolfssl],[http://www.wolfssl.com]) - -AC_CONFIG_AUX_DIR([build-aux]) - -AC_CANONICAL_HOST -AC_CANONICAL_BUILD - -AM_INIT_AUTOMAKE([1.11 -Wall -Werror -Wno-portability foreign tar-ustar subdir-objects no-define color-tests]) -AC_PREREQ([2.63]) - -AC_ARG_PROGRAM -AC_DEFUN([PROTECT_AC_USE_SYSTEM_EXTENSIONS], - [AX_SAVE_FLAGS - AC_LANG_PUSH([C]) - AC_USE_SYSTEM_EXTENSIONS - AC_LANG_POP([C]) - AX_RESTORE_FLAGS - ]) -#PROTECT_AC_USE_SYSTEM_EXTENSIONS - -AC_CONFIG_MACRO_DIR([m4]) - -AC_CONFIG_HEADERS([config.h:config.in])dnl Keep filename to 8.3 for MS-DOS. - -#shared library versioning -WOLFSSL_LIBRARY_VERSION=0:2:0 -# | | | -# +------+ | +---+ -# | | | -# current:revision:age -# | | | -# | | +- increment if interfaces have been added -# | | set to zero if interfaces have been removed -# | | or changed -# | +- increment if source code has changed -# | set to zero if current is incremented -# +- increment if interfaces have been added, removed or changed -AC_SUBST([WOLFSSL_LIBRARY_VERSION]) - -# capture user C_EXTRA_FLAGS from ./configure line, CFLAGS may hold -g -O2 even -# if user doesn't override, no way to tell -USER_C_EXTRA_FLAGS="$C_EXTRA_FLAGS" - -LT_PREREQ([2.2]) -LT_INIT([disable-static],[win32-dll]) -LT_LANG([C++]) -LT_LANG([C]) - -gl_VISIBILITY -AS_IF([ test -n "$CFLAG_VISIBILITY" ], [ - AM_CPPFLAGS="$AM_CPPFLAGS $CFLAG_VISIBILITY" - CPPFLAGS="$CPPFLAGS $CFLAG_VISIBILITY" - ]) - -m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) - -AC_CHECK_FUNCS([gethostbyname]) -AC_CHECK_FUNCS([getaddrinfo]) -AC_CHECK_FUNCS([gettimeofday]) -AC_CHECK_FUNCS([inet_ntoa]) -AC_CHECK_FUNCS([memset]) -AC_CHECK_FUNCS([socket]) -AC_CHECK_HEADERS([arpa/inet.h]) -AC_CHECK_HEADERS([fcntl.h]) -AC_CHECK_HEADERS([limits.h]) -AC_CHECK_HEADERS([netdb.h]) -AC_CHECK_HEADERS([netinet/in.h]) -AC_CHECK_HEADERS([stddef.h]) -AC_CHECK_HEADERS([sys/ioctl.h]) -AC_CHECK_HEADERS([sys/socket.h]) -AC_CHECK_HEADERS([sys/time.h]) -AC_CHECK_HEADERS([errno.h]) -AC_CHECK_LIB(network,socket) -AC_CHECK_SIZEOF(long long, 8) -AC_CHECK_SIZEOF(long, 4) -AC_CHECK_TYPES(__uint128_t) -AC_C_BIGENDIAN -# mktime check takes forever on some systems, if time supported it would be -# highly unusual for mktime to be missing -#AC_FUNC_MKTIME - -AC_PROG_CC -AC_PROG_CC_C_O -AC_PROG_CXX -AC_PROG_INSTALL -AC_TYPE_SIZE_T -AC_TYPE_UINT8_T -AM_PROG_AS -AM_PROG_CC_C_O -LT_LIB_M - -OPTIMIZE_CFLAGS="-Os -fomit-frame-pointer" -OPTIMIZE_FAST_CFLAGS="-O2 -fomit-frame-pointer" -OPTIMIZE_HUGE_CFLAGS="-funroll-loops -DTFM_SMALL_SET -DTFM_HUGE_SET" -DEBUG_CFLAGS="-g -DDEBUG -DDEBUG_WOLFSSL" - -thread_ls_on=no -# Thread local storage -AX_TLS([ - [AM_CFLAGS="$AM_CFLAGS -DHAVE_THREAD_LS"] - [thread_ls_on=yes] - ] , [:]) - - -# DEBUG -AX_DEBUG -AS_IF([test "$ax_enable_debug" = "yes"], - [AM_CFLAGS="$DEBUG_CFLAGS $AM_CFLAGS"], - [AM_CFLAGS="$AM_CFLAGS -DNDEBUG"]) - - -# SINGLE THREADED -AC_ARG_ENABLE([singlethreaded], - [ --enable-singlethreaded Enable wolfSSL single threaded (default: disabled)], - [ ENABLED_SINGLETHREADED=$enableval ], - [ ENABLED_SINGLETHREADED=no ]) - -AS_IF([ test "x$ENABLED_SINGLETHREADED" = "xno" ],[ - AX_PTHREAD([ - AC_DEFINE([HAVE_PTHREAD], [1], [Define if you have POSIX threads libraries and header files.]) - AM_CFLAGS="-D_POSIX_THREADS $AM_CFLAGS $PTHREAD_CFLAGS" - LIBS="$LIBS $PTHREAD_LIBS" - ],[ - ENABLED_SINGLETHREADED=yes - ]) - ]) - -AS_IF([ test "x$ENABLED_SINGLETHREADED" = "xyes" ],[ AM_CFLAGS="-DSINGLE_THREADED $AM_CFLAGS" ]) - - -# DTLS -AC_ARG_ENABLE([dtls], - [ --enable-dtls Enable wolfSSL DTLS (default: disabled)], - [ ENABLED_DTLS=$enableval ], - [ ENABLED_DTLS=no ] - ) -if test "$ENABLED_DTLS" = "yes" -then - AM_CFLAGS="-DWOLFSSL_DTLS $AM_CFLAGS" -fi - - -# OPENSSL Extra Compatibility -AC_ARG_ENABLE([opensslextra], - [ --enable-opensslextra Enable extra OpenSSL API, size+ (default: disabled)], - [ ENABLED_OPENSSLEXTRA=$enableval ], - [ ENABLED_OPENSSLEXTRA=no ] - ) -if test "$ENABLED_OPENSSLEXTRA" = "yes" -then - AM_CFLAGS="-DOPENSSL_EXTRA $AM_CFLAGS" -fi - -if test "$ENABLED_OPENSSLEXTRA" = "yes" && test "$ENABLED_SMALL" = "yes" -then - AC_MSG_ERROR([cannot enable small and opensslextra, only one or the other.]) -fi - - -# High Strength Build -AC_ARG_ENABLE([maxstrength], - [AS_HELP_STRING([--enable-maxstrength],[Enable Max Strengh build, allows TLSv1.2-AEAD-PFS ciphers only (default: disabled)])], - [ENABLED_MAXSTRENGTH=$enableval], - [ENABLED_MAXSTRENGTH=no]) - - -# IPv6 Test Apps -AC_ARG_ENABLE([ipv6], - [ --enable-ipv6 Enable testing of IPV6 (default: disabled)], - [ ENABLED_IPV6=$enableval ], - [ ENABLED_IPV6=no ] - ) - -if test "$ENABLED_IPV6" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DTEST_IPV6" -fi - -AM_CONDITIONAL([BUILD_IPV6], [test "x$ENABLED_IPV6" = "xyes"]) - - -# Fortress build -AC_ARG_ENABLE([fortress], - [ --enable-fortress Enable SSL fortress build (default: disabled)], - [ ENABLED_FORTRESS=$enableval ], - [ ENABLED_FORTRESS=no ] - ) - -if test "$ENABLED_FORTRESS" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DFORTRESS -DWOLFSSL_ALWAYS_VERIFY_CB -DOPENSSL_EXTRA -DWOLFSSL_DES_ECB -DWOLFSSL_AES_COUNTER -DWOLFSSL_AES_DIRECT -DWOLFSSL_DER_LOAD -DWOLFSSL_SHA512 -DWOLFSSL_SHA384 -DWOLFSSL_KEY_GEN" -fi - - -# ssl bump build -AC_ARG_ENABLE([bump], - [ --enable-bump Enable SSL Bump build (default: disabled)], - [ ENABLED_BUMP=$enableval ], - [ ENABLED_BUMP=no ] - ) - -if test "$ENABLED_BUMP" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DLARGE_STATIC_BUFFERS -DWOLFSSL_CERT_GEN -DWOLFSSL_KEY_GEN -DHUGE_SESSION_CACHE -DOPENSSL_EXTRA -DFP_MAX_BITS=8192 -DWOLFSSL_DER_LOAD -DWOLFSSL_ALT_NAMES -DWOLFSSL_TEST_CERT" -fi - -ENABLED_SLOWMATH="yes" - -# lean psk build -AC_ARG_ENABLE([leanpsk], - [ --enable-leanpsk Enable Lean PSK build (default: disabled)], - [ ENABLED_LEANPSK=$enableval ], - [ ENABLED_LEANPSK=no ] - ) - -if test "$ENABLED_LEANPSK" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_LEANPSK -DHAVE_NULL_CIPHER -DSINGLE_THREADED -DNO_AES -DNO_FILESYSTEM -DNO_RABBIT -DNO_RSA -DNO_DSA -DNO_DH -DNO_CERTS -DNO_PWDBASED -DNO_DES3 -DNO_MD4 -DNO_MD5 -DNO_ERROR_STRINGS -DNO_OLD_TLS -DNO_RC4 -DNO_WRITEV -DNO_SESSION_CACHE -DNO_DEV_RANDOM -DWOLFSSL_USER_IO -DNO_SHA -DUSE_SLOW_SHA" - ENABLED_SLOWMATH="no" - ENABLED_SINGLETHREADED="yes" -fi - -AM_CONDITIONAL([BUILD_LEANPSK], [test "x$ENABLED_LEANPSK" = "xyes"]) - - -# big cache -AC_ARG_ENABLE([bigcache], - [ --enable-bigcache Enable big session cache (default: disabled)], - [ ENABLED_BIGCACHE=$enableval ], - [ ENABLED_BIGCACHE=no ] - ) - -if test "$ENABLED_BIGCACHE" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DBIG_SESSION_CACHE" -fi - - -# HUGE cache -AC_ARG_ENABLE([hugecache], - [ --enable-hugecache Enable huge session cache (default: disabled)], - [ ENABLED_HUGECACHE=$enableval ], - [ ENABLED_HUGECACHE=no ] - ) - -if test "$ENABLED_HUGECACHE" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHUGE_SESSION_CACHE" -fi - - -# SMALL cache -AC_ARG_ENABLE([smallcache], - [ --enable-smallcache Enable small session cache (default: disabled)], - [ ENABLED_SMALLCACHE=$enableval ], - [ ENABLED_SMALLCACHE=no ] - ) - -if test "$ENABLED_SMALLCACHE" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DSMALL_SESSION_CACHE" -fi - - -# Persistent session cache -AC_ARG_ENABLE([savesession], - [ --enable-savesession Enable persistent session cache (default: disabled)], - [ ENABLED_SAVESESSION=$enableval ], - [ ENABLED_SAVESESSION=no ] - ) - -if test "$ENABLED_SAVESESSION" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DPERSIST_SESSION_CACHE" -fi - - -# Persistent cert cache -AC_ARG_ENABLE([savecert], - [ --enable-savecert Enable persistent cert cache (default: disabled)], - [ ENABLED_SAVECERT=$enableval ], - [ ENABLED_SAVECERT=no ] - ) - -if test "$ENABLED_SAVECERT" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DPERSIST_CERT_CACHE" -fi - - -# Atomic User Record Layer -AC_ARG_ENABLE([atomicuser], - [ --enable-atomicuser Enable Atomic User Record Layer (default: disabled)], - [ ENABLED_ATOMICUSER=$enableval ], - [ ENABLED_ATOMICUSER=no ] - ) - -if test "$ENABLED_ATOMICUSER" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DATOMIC_USER" -fi - - -# Public Key Callbacks -AC_ARG_ENABLE([pkcallbacks], - [ --enable-pkcallbacks Enable Public Key Callbacks (default: disabled)], - [ ENABLED_PKCALLBACKS=$enableval ], - [ ENABLED_PKCALLBACKS=no ] - ) - -if test "$ENABLED_PKCALLBACKS" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_PK_CALLBACKS" -fi - - -# SNIFFER -AC_ARG_ENABLE([sniffer], - [AS_HELP_STRING([--enable-sniffer],[Enable wolfSSL sniffer support (default: disabled)])], - [ ENABLED_SNIFFER=$enableval ], - [ ENABLED_SNIFFER=no ] - ) - -# sniffer does't work in maxstrength mode -if test "$ENABLED_SNIFFER" = "yes" && test "$ENABLED_MAXSTRENGTH" = "yes" -then - AC_MSG_ERROR([cannot enable maxstrength in sniffer mode.]) -fi - -ENABLED_SNIFFTEST=no -AS_IF([ test "x$ENABLED_SNIFFER" = "xyes" ], - [ - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SNIFFER -DOPENSSL_EXTRA" - AC_CHECK_HEADERS([pcap/pcap.h], - [ ENABLED_SNIFFTEST=yes ], - [ AC_MSG_WARN([cannot enable sniffer test without having libpcap available.]) ] - ) - ]) - -AM_CONDITIONAL([BUILD_SNIFFER], [ test "x$ENABLED_SNIFFER" = "xyes" ]) -AM_CONDITIONAL([BUILD_SNIFFTEST], [ test "x$ENABLED_SNIFFTEST" = "xyes" ]) - -# AES-GCM -AC_ARG_ENABLE([aesgcm], - [AS_HELP_STRING([--enable-aesgcm],[Enable wolfSSL AES-GCM support (default: enabled)])], - [ ENABLED_AESGCM=$enableval ], - [ ENABLED_AESGCM=yes ] - ) - -# lean psk does't need gcm -if test "$ENABLED_LEANPSK" = "yes" -then - ENABLED_AESGCM=no -fi - -if test "$ENABLED_AESGCM" = "word32" -then - AM_CFLAGS="$AM_CFLAGS -DGCM_WORD32" - ENABLED_AESGCM=yes -fi - -if test "$ENABLED_AESGCM" = "small" -then - AM_CFLAGS="$AM_CFLAGS -DGCM_SMALL" - ENABLED_AESGCM=yes -fi - -if test "$ENABLED_AESGCM" = "table" -then - AM_CFLAGS="$AM_CFLAGS -DGCM_TABLE" - ENABLED_AESGCM=yes -fi - -if test "$ENABLED_AESGCM" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_AESGCM" -fi - -AM_CONDITIONAL([BUILD_AESGCM], [test "x$ENABLED_AESGCM" = "xyes"]) - - -# AES-CCM -AC_ARG_ENABLE([aesccm], - [ --enable-aesccm Enable wolfSSL AES-CCM support (default: disabled)], - [ ENABLED_AESCCM=$enableval ], - [ ENABLED_AESCCM=no ] - ) - -if test "$ENABLED_AESCCM" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_AESCCM" -fi - -AM_CONDITIONAL([BUILD_AESCCM], [test "x$ENABLED_AESCCM" = "xyes"]) - - -# AES-NI -AC_ARG_ENABLE([aesni], - [AS_HELP_STRING([--enable-aesni],[Enable wolfSSL AES-NI support (default: disabled)])], - [ ENABLED_AESNI=$enableval ], - [ ENABLED_AESNI=no ] - ) - -# INTEL ASM -AC_ARG_ENABLE([intelasm], - [AS_HELP_STRING([--enable-intelasm],[Enable All Intel ASM speedups (default: disabled)])], - [ ENABLED_INTELASM=$enableval ], - [ ENABLED_INTELASM=no ] - ) - -if test "$ENABLED_AESNI" = "yes" || test "$ENABLED_INTELASM" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_AESNI" - if test "$GCC" = "yes" - then - # GCC needs these flags, icc doesn't - # opt levels greater than 2 may cause problems on systems w/o aesni - if test "$CC" != "icc" - then - AM_CFLAGS="$AM_CFLAGS -maes -msse4" - fi - fi -fi - -if test "$ENABLED_INTELASM" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_INTEL_RDGEN -DUSE_INTEL_SPEEDUP" - ENABLED_AESNI=yes -fi - -AM_CONDITIONAL([BUILD_AESNI], [test "x$ENABLED_AESNI" = "xyes"]) - - -# Camellia -AC_ARG_ENABLE([camellia], - [ --enable-camellia Enable wolfSSL Camellia support (default: disabled)], - [ ENABLED_CAMELLIA=$enableval ], - [ ENABLED_CAMELLIA=no ] - ) - -if test "$ENABLED_CAMELLIA" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_CAMELLIA" -fi - -AM_CONDITIONAL([BUILD_CAMELLIA], [test "x$ENABLED_CAMELLIA" = "xyes"]) - - -# MD2 -AC_ARG_ENABLE([md2], - [ --enable-md2 Enable wolfSSL MD2 support (default: disabled)], - [ ENABLED_MD2=$enableval ], - [ ENABLED_MD2=no ] - ) - -if test "$ENABLED_BUMP" = "yes" -then - ENABLED_MD2="yes" -fi - -if test "$ENABLED_MD2" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_MD2" -fi - -AM_CONDITIONAL([BUILD_MD2], [test "x$ENABLED_MD2" = "xyes"]) - - -# NULL CIPHER -AC_ARG_ENABLE([nullcipher], - [ --enable-nullcipher Enable wolfSSL NULL cipher support (default: disabled)], - [ ENABLED_NULL_CIPHER=$enableval ], - [ ENABLED_NULL_CIPHER=no ] - ) - -if test "$ENABLED_NULL_CIPHER" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_NULL_CIPHER" -fi - -# RIPEMD -AC_ARG_ENABLE([ripemd], - [ --enable-ripemd Enable wolfSSL RIPEMD-160 support (default: disabled)], - [ ENABLED_RIPEMD=$enableval ], - [ ENABLED_RIPEMD=no ] - ) - -if test "$ENABLED_RIPEMD" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_RIPEMD" -fi - -AM_CONDITIONAL([BUILD_RIPEMD], [test "x$ENABLED_RIPEMD" = "xyes"]) - - -# BLAKE2 -AC_ARG_ENABLE([blake2], - [ --enable-blake2 Enable wolfSSL BLAKE2 support (default: disabled)], - [ ENABLED_BLAKE2=$enableval ], - [ ENABLED_BLAKE2=no ] - ) - -if test "$ENABLED_BLAKE2" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_BLAKE2" -fi - -AM_CONDITIONAL([BUILD_BLAKE2], [test "x$ENABLED_BLAKE2" = "xyes"]) - - -# set sha512 default -SHA512_DEFAULT=no -if test "$host_cpu" = "x86_64" -then -SHA512_DEFAULT=yes -fi - -# SHA512 -AC_ARG_ENABLE([sha512], - [AS_HELP_STRING([--enable-sha512],[Enable wolfSSL SHA-512 support (default: enabled on x86_64)])], - [ ENABLED_SHA512=$enableval ], - [ ENABLED_SHA512=$SHA512_DEFAULT ] - ) - -# lean psk does't need sha512 -if test "$ENABLED_LEANPSK" = "yes" -then - ENABLED_SHA512=no -fi - -if test "$ENABLED_SHA512" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SHA512 -DWOLFSSL_SHA384" -fi - -if test "$ENABLED_FORTRESS" = "yes" -then - ENABLED_SHA512="yes" -fi - - -AM_CONDITIONAL([BUILD_SHA512], [test "x$ENABLED_SHA512" = "xyes"]) - - -# SESSION CERTS -AC_ARG_ENABLE([sessioncerts], - [ --enable-sessioncerts Enable session cert storing (default: disabled)], - [ ENABLED_SESSIONCERTS=$enableval ], - [ ENABLED_SESSIONCERTS=no ] - ) - -if test "$ENABLED_SESSIONCERTS" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DSESSION_CERTS" -fi - - -# KEY GENERATION -AC_ARG_ENABLE([keygen], - [ --enable-keygen Enable key generation (default: disabled)], - [ ENABLED_KEYGEN=$enableval ], - [ ENABLED_KEYGEN=no ] - ) - -if test "$ENABLED_KEYGEN" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_KEY_GEN" -fi - - -# CERT GENERATION -AC_ARG_ENABLE([certgen], - [ --enable-certgen Enable cert generation (default: disabled)], - [ ENABLED_CERTGEN=$enableval ], - [ ENABLED_CERTGEN=no ] - ) - -if test "$ENABLED_CERTGEN" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CERT_GEN" -fi - - -# CERT REQUEST GENERATION -AC_ARG_ENABLE([certreq], - [ --enable-certreq Enable cert request generation (default: disabled)], - [ ENABLED_CERTREQ=$enableval ], - [ ENABLED_CERTREQ=no ] - ) - -if test "$ENABLED_CERTREQ" = "yes" -then - if test "$ENABLED_CERTGEN" = "no" - then - AC_MSG_ERROR([cannot enable certreq without enabling certgen.]) - fi - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CERT_REQ" -fi - - -# SEP -AC_ARG_ENABLE([sep], - [ --enable-sep Enable sep extensions (default: disabled)], - [ ENABLED_SEP=$enableval ], - [ ENABLED_SEP=no ] - ) -if test "$ENABLED_SEP" = "yes" -then - AM_CFLAGS="-DWOLFSSL_SEP -DKEEP_PEER_CERT $AM_CFLAGS" -fi - - -# HKDF -AC_ARG_ENABLE([hkdf], - [ --enable-hkdf Enable HKDF (HMAC-KDF) support (default: disabled)], - [ ENABLED_HKDF=$enableval ], - [ ENABLED_HKDF=no ] - ) -if test "$ENABLED_HKDF" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_HKDF" -fi - - -# DSA -AC_ARG_ENABLE([dsa], - [ --enable-dsa Enable DSA (default: disabled)], - [ ENABLED_DSA=$enableval ], - [ ENABLED_DSA=no ] - ) - -if test "$ENABLED_DSA" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_DSA" -fi - -AM_CONDITIONAL([BUILD_DSA], [test "x$ENABLED_DSA" = "xyes"]) - - -# set ecc default -ECC_DEFAULT=no - -if test "$host_cpu" = "x86_64" -then -ECC_DEFAULT=yes -fi - -# ECC -AC_ARG_ENABLE([ecc], - [AS_HELP_STRING([--enable-ecc],[Enable ECC (default: enabled on x86_64)])], - [ ENABLED_ECC=$enableval ], - [ ENABLED_ECC=$ECC_DEFAULT ] - ) - -# lean psk does't need ecc -if test "$ENABLED_LEANPSK" = "yes" -then - ENABLED_ECC=no -fi - -if test "$ENABLED_ECC" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC -DTFM_ECC256 -DECC_SHAMIR" -fi - -AM_CONDITIONAL([BUILD_ECC], [test "x$ENABLED_ECC" = "xyes"]) - - -if test "$ENABLED_ECC" = "yes" && test "$ENABLED_SMALL" = "yes" -then - AC_MSG_ERROR([cannot enable ecc and small, ecc requires TLS which small turns off.]) -fi - - -# for using memory optimization setting on both curve25519 and ed25519 -ENABLED_CURVED25519_SMALL=no - -# CURVE25519 -AC_ARG_ENABLE([curve25519], - [AS_HELP_STRING([--enable-curve25519],[Enable Curve25519 (default: disabled)])], - [ ENABLED_CURVE25519=$enableval ], - [ ENABLED_CURVE25519=no ] - ) - - -if test "$ENABLED_CURVE25519" = "small" -then - AM_CFLAGS="$AM_CFLAGS -DCURVED25519_SMALL" - ENABLED_CURVED25519_SMALL=yes - ENABLED_CURVE25519=yes -fi - -if test "$ENABLED_CURVE25519" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_CURVE25519" - ENABLED_FEMATH=yes -fi - - -AM_CONDITIONAL([BUILD_CURVE25519], [test "x$ENABLED_CURVE25519" = "xyes"]) - - -# ED25519 -AC_ARG_ENABLE([ed25519], - [AS_HELP_STRING([--enable-ed25519],[Enable ED25519 (default: disabled)])], - [ ENABLED_ED25519=$enableval ], - [ ENABLED_ED25519=no ] - ) - - -if test "$ENABLED_ED25519" = "small" -then - AM_CFLAGS="$AM_CFLAGS -DCURVED25519_SMALL" - ENABLED_CURVED25519_SMALL=yes - ENABLED_ED25519=yes -fi - -if test "$ENABLED_ED25519" = "yes" -then - if test "$ENABLED_SHA512" = "no" - then - AC_MSG_ERROR([cannot enable ed25519 without enabling sha512.]) - fi - ENABLED_FEMATH=yes - ENABLED_GEMATH=yes - AM_CFLAGS="$AM_CFLAGS -DHAVE_ED25519" -fi - -AM_CONDITIONAL([BUILD_ED25519], [test "x$ENABLED_ED25519" = "xyes"]) -AM_CONDITIONAL([BUILD_CURVED25519_SMALL], [test "x$ENABLED_CURVED25519_SMALL" = "xyes"]) -AM_CONDITIONAL([BUILD_FEMATH], [test "x$ENABLED_FEMATH" = "xyes"]) -AM_CONDITIONAL([BUILD_GEMATH], [test "x$ENABLED_GEMATH" = "xyes"]) - -# FP ECC, Fixed Point cache ECC -AC_ARG_ENABLE([fpecc], - [ --enable-fpecc Enable Fixed Point cache ECC (default: disabled)], - [ ENABLED_FPECC=$enableval ], - [ ENABLED_FPECC=no ] - ) - -if test "$ENABLED_FPECC" = "yes" -then - if test "$ENABLED_ECC" = "no" - then - AC_MSG_ERROR([cannot enable fpecc without enabling ecc.]) - fi - AM_CFLAGS="$AM_CFLAGS -DFP_ECC" -fi - - -# ECC encrypt -AC_ARG_ENABLE([eccencrypt], - [ --enable-eccencrypt Enable ECC encrypt (default: disabled)], - [ ENABLED_ECC_ENCRYPT=$enableval ], - [ ENABLED_ECC_ENCRYPT=no ] - ) - -if test "$ENABLED_ECC_ENCRYPT" = "yes" -then - if test "$ENABLED_ECC" = "no" - then - AC_MSG_ERROR([cannot enable eccencrypt without enabling ecc.]) - fi - if test "$ENABLED_HKDF" = "no" - then - AC_MSG_ERROR([cannot enable eccencrypt without enabling hkdf.]) - fi - AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC_ENCRYPT" -fi - - -# PSK -AC_ARG_ENABLE([psk], - [ --enable-psk Enable PSK (default: disabled)], - [ ENABLED_PSK=$enableval ], - [ ENABLED_PSK=no ] - ) - -if test "$ENABLED_PSK" = "no" && test "$ENABLED_LEANPSK" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_PSK" -fi - -if test "$ENABLED_PSK" = "no" && test "$ENABLED_LEANPSK" = "yes" -then - ENABLED_PSK=yes -fi - - -# ERROR STRINGS -AC_ARG_ENABLE([errorstrings], - [ --enable-errorstrings Enable error strings table (default: enabled)], - [ ENABLED_ERROR_STRINGS=$enableval ], - [ ENABLED_ERROR_STRINGS=yes ] - ) - -if test "$ENABLED_ERROR_STRINGS" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_ERROR_STRINGS" -else - # turn off error strings if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_ERROR_STRINGS" - ENABLED_ERROR_STRINGS=no - fi -fi - - -# OLD TLS -AC_ARG_ENABLE([oldtls], - [ --enable-oldtls Enable old TLS versions < 1.2 (default: enabled)], - [ ENABLED_OLD_TLS=$enableval ], - [ ENABLED_OLD_TLS=yes ] - ) - -if test "$ENABLED_OLD_TLS" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_OLD_TLS" -else - # turn off old if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_OLD_TLS" - ENABLED_OLD_TLS=no - fi -fi - - -# STACK SIZE info for examples -AC_ARG_ENABLE([stacksize], - [ --enable-stacksize Enable stack size info on examples (default: disabled)], - [ ENABLED_STACKSIZE=$enableval ], - [ ENABLED_STACKSIZE=no ] - ) - -if test "$ENABLED_STACKSIZE" = "yes" -then - AC_CHECK_FUNC([posix_memalign], [], [AC_MSG_ERROR(stacksize needs posix_memalign)]) - AC_CHECK_FUNC([pthread_attr_setstack], [], AC_CHECK_LIB([pthread],[pthread_attr_setstack])) - AM_CFLAGS="$AM_CFLAGS -DHAVE_STACK_SIZE -DWOLFSSL_LOW_MEMORY" -fi - - -# MEMORY -AC_ARG_ENABLE([memory], - [ --enable-memory Enable memory callbacks (default: enabled)], - [ ENABLED_MEMORY=$enableval ], - [ ENABLED_MEMORY=yes ] - ) - -if test "$ENABLED_MEMORY" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_WOLFSSL_MEMORY" -else - # turn off memory cb if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - # but don't turn on NO_WOLFSSL_MEMORY because using own - ENABLED_MEMORY=no - fi -fi - -AM_CONDITIONAL([BUILD_MEMORY], [test "x$ENABLED_MEMORY" = "xyes"]) - - -# RSA -AC_ARG_ENABLE([rsa], - [ --enable-rsa Enable RSA (default: enabled)], - [ ENABLED_RSA=$enableval ], - [ ENABLED_RSA=yes ] - ) - -if test "$ENABLED_RSA" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_RSA" -else - # turn off RSA if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_RSA" - ENABLED_RSA=no - fi -fi - -AM_CONDITIONAL([BUILD_RSA], [test "x$ENABLED_RSA" = "xyes"]) - - -# DH -AC_ARG_ENABLE([dh], - [AS_HELP_STRING([--enable-dh],[Enable DH (default: enabled)])], - [ ENABLED_DH=$enableval ], - [ ENABLED_DH=yes ] - ) - -if test "$ENABLED_DH" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_DH" -else - # turn off DH if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_DH" - ENABLED_DH=no - fi -fi - -AM_CONDITIONAL([BUILD_DH], [test "x$ENABLED_DH" = "xyes"]) - - -# Anonymous -AC_ARG_ENABLE([anon], - [AS_HELP_STRING([--enable-anon],[Enable Anonymous (default: disabled)])], - [ ENABLED_ANON=$enableval ], - [ ENABLED_ANON=no ] - ) - - -if test "x$ENABLED_ANON" = "xyes" -then - if test "x$ENABLED_DH" != "xyes" - then - AC_MSG_ERROR([Anonymous suite requires DH.]) - fi - AM_CFLAGS="$AM_CFLAGS -DHAVE_ANON" -fi - - -# ASN -# turn off asn, which means no certs, no rsa, no dsa, no ecc, -# and no big int (unless dh is on) -AC_ARG_ENABLE([asn], - [ --enable-asn Enable ASN (default: enabled)], - [ ENABLED_ASN=$enableval ], - [ ENABLED_ASN=yes ] - ) - -if test "$ENABLED_ASN" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_ASN -DNO_CERTS" - if test "$ENABLED_DH" = "no" - then - # DH needs bigint - AM_CFLAGS="$AM_CFLAGS -DNO_BIG_INT" - fi -else - # turn off ASN if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_ASN -DNO_CERTS -DNO_BIG_INT" - ENABLED_ASN=no - fi -fi - -if test "$ENABLED_RSA" = "yes" && test "$ENABLED_ASN" = "no" -then - AC_MSG_ERROR([please disable rsa if disabling asn.]) -fi - -if test "$ENABLED_DSA" = "yes" && test "$ENABLED_ASN" = "no" -then - AC_MSG_ERROR([please disable dsa if disabling asn.]) -fi - -if test "$ENABLED_ECC" = "yes" && test "$ENABLED_ASN" = "no" -then - AC_MSG_ERROR([please disable ecc if disabling asn.]) -fi - -if test "$ENABLED_PSK" = "no" && test "$ENABLED_ASN" = "no" -then - AC_MSG_ERROR([please enable psk if disabling asn.]) -fi - -# DH needs bigint -if test "$ENABLED_ASN" = "no" && test "$ENABLED_DH" = "no" -then - ENABLED_FASTMATH=no - ENABLED_SLOWMATH=no -fi - -AM_CONDITIONAL([BUILD_ASN], [test "x$ENABLED_ASN" = "xyes"]) - - -# AES -AC_ARG_ENABLE([aes], - [ --enable-aes Enable AES (default: enabled)], - [ ENABLED_AES=$enableval ], - [ ENABLED_AES=yes ] - ) - -if test "$ENABLED_AES" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_AES" - if test "$ENABLED_AESGCM" = "yes" - then - AC_MSG_ERROR([AESGCM requires AES.]) - fi - if test "$ENABLED_AESCCM" = "yes" - then - AC_MSG_ERROR([AESCCM requires AES.]) - fi -else - # turn off AES if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_AES" - ENABLED_AES=no - fi -fi - -AM_CONDITIONAL([BUILD_AES], [test "x$ENABLED_AES" = "xyes"]) - - -# CODING -AC_ARG_ENABLE([coding], - [ --enable-coding Enable Coding base 16/64 (default: enabled)], - [ ENABLED_CODING=$enableval ], - [ ENABLED_CODING=yes ] - ) - -if test "$ENABLED_CODING" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_CODING" -else - # turn off CODING if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_CODING" - ENABLED_CODING=no - fi -fi - -AM_CONDITIONAL([BUILD_CODING], [test "x$ENABLED_CODING" = "xyes"]) - - -# DES3 -AC_ARG_ENABLE([des3], - [ --enable-des3 Enable DES3 (default: enabled)], - [ ENABLED_DES3=$enableval ], - [ ENABLED_DES3=yes ] - ) - -if test "$ENABLED_DES3" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_DES3" -else - # turn off DES3 if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_DES3" - ENABLED_DES3=no - fi -fi - -AM_CONDITIONAL([BUILD_DES3], [test "x$ENABLED_DES3" = "xyes"]) - - -# ARC4 -AC_ARG_ENABLE([arc4], - [ --enable-arc4 Enable ARC4 (default: disabled)], - [ ENABLED_ARC4=$enableval ], - [ ENABLED_ARC4=no ] - ) - -if test "$ENABLED_ARC4" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_RC4" -else - # turn off ARC4 if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_RC4" - ENABLED_ARC4=no - fi -fi - -AM_CONDITIONAL([BUILD_RC4], [test "x$ENABLED_ARC4" = "xyes"]) - - -# MD5 -AC_ARG_ENABLE([md5], - [ --enable-md5 Enable MD5 (default: enabled)], - [ ENABLED_MD5=$enableval ], - [ ENABLED_MD5=yes ] - ) - -if test "$ENABLED_MD5" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_MD5 -DNO_OLD_TLS" -else - # turn off MD5 if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_MD5 -DNO_OLD_TLS" - ENABLED_MD5=no - fi -fi - -AM_CONDITIONAL([BUILD_MD5], [test "x$ENABLED_MD5" = "xyes"]) - - -# SHA -AC_ARG_ENABLE([sha], - [ --enable-sha Enable SHA (default: enabled)], - [ ENABLED_SHA=$enableval ], - [ ENABLED_SHA=yes ] - ) - -if test "$ENABLED_SHA" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_SHA -DNO_OLD_TLS" -else - # turn off SHA if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_SHA -DNO_OLD_TLS" - ENABLED_SHA=no - fi -fi - -AM_CONDITIONAL([BUILD_SHA], [test "x$ENABLED_SHA" = "xyes"]) - - -# MD4 -AC_ARG_ENABLE([md4], - [ --enable-md4 Enable MD4 (default: disabled)], - [ ENABLED_MD4=$enableval ], - [ ENABLED_MD4=no ] - ) - -if test "$ENABLED_MD4" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_MD4" -fi - -AM_CONDITIONAL([BUILD_MD4], [test "x$ENABLED_MD4" = "xyes"]) - - -# Web Server Build -AC_ARG_ENABLE([webserver], - [ --enable-webserver Enable Web Server (default: disabled)], - [ ENABLED_WEBSERVER=$enableval ], - [ ENABLED_WEBSERVER=no ] - ) - -if test "$ENABLED_WEBSERVER" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_WEBSERVER" -fi - - - -# HC128 -AC_ARG_ENABLE([hc128], - [ --enable-hc128 Enable HC-128 (default: disabled)], - [ ENABLED_HC128=$enableval ], - [ ENABLED_HC128=no ] - ) - -if test "$ENABLED_HC128" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_HC128" -else - AM_CFLAGS="$AM_CFLAGS -DHAVE_HC128" -fi - -AM_CONDITIONAL([BUILD_HC128], [test "x$ENABLED_HC128" = "xyes"]) - - -# RABBIT -AC_ARG_ENABLE([rabbit], - [ --enable-rabbit Enable RABBIT (default: disabled)], - [ ENABLED_RABBIT=$enableval ], - [ ENABLED_RABBIT=no ] - ) - -if test "$ENABLED_RABBIT" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_RABBIT" -else - AM_CFLAGS="$AM_CFLAGS -DHAVE_RABBIT" -fi - -AM_CONDITIONAL([BUILD_RABBIT], [test "x$ENABLED_RABBIT" = "xyes"]) - - -# FIPS -AC_ARG_ENABLE([fips], - [AS_HELP_STRING([--enable-fips],[Enable FIPS 140-2, Will NOT work w/o FIPS license (default: disabled)])], - [ ENABLED_FIPS=$enableval ], - [ ENABLED_FIPS=no ] - ) - -if test "x$ENABLED_FIPS" = "xyes" -then - # requires thread local storage - if test "$thread_ls_on" = "no" - then - AC_MSG_ERROR([FIPS requires Thread Local Storage]) - fi - # requires SHA512 - if test "x$ENABLED_SHA512" = "xno" - then - ENABLED_SHA512="yes" - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SHA512 -DWOLFSSL_SHA384" - AM_CONDITIONAL([BUILD_SHA512], [test "x$ENABLED_SHA512" = "xyes"]) - fi - # requires AESGCM - if test "x$ENABLED_AESGCM" != "xyes" - then - ENABLED_AESGCM="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_AESGCM" - AM_CONDITIONAL([BUILD_SHA512], [test "x$ENABLED_SHA512" = "xyes"]) - fi - AM_CFLAGS="$AM_CFLAGS -DHAVE_FIPS" -fi - -AM_CONDITIONAL([BUILD_FIPS], [test "x$ENABLED_FIPS" = "xyes"]) - - -# set POLY1305 default -POLY1305_DEFAULT=yes - -if test "x$ENABLED_FIPS" = "xyes" -then -POLY1305_DEFAULT=no -fi - -# POLY1305 -AC_ARG_ENABLE([poly1305], - [AS_HELP_STRING([--enable-poly1305],[Enable wolfSSL POLY1305 support (default: enabled)])], - [ ENABLED_POLY1305=$enableval ], - [ ENABLED_POLY1305=$POLY1305_DEFAULT] - ) - -# lean psk does't need poly1305 -if test "$ENABLED_LEANPSK" = "yes" -then - ENABLED_POLY1305=no -fi - -if test "$ENABLED_POLY1305" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_POLY1305 -DHAVE_ONE_TIME_AUTH" -fi - -AM_CONDITIONAL([BUILD_POLY1305], [test "x$ENABLED_POLY1305" = "xyes"]) - - -# set CHACHA default -CHACHA_DEFAULT=yes - -if test "x$ENABLED_FIPS" = "xyes" -then -CHACHA_DEFAULT=no -fi - -# CHACHA -AC_ARG_ENABLE([chacha], - [ --enable-chacha Enable CHACHA (default: enabled)], - [ ENABLED_CHACHA=$enableval ], - [ ENABLED_CHACHA=$CHACHA_DEFAULT] - ) - -# lean psk does't need chacha -if test "$ENABLED_LEANPSK" = "yes" -then - ENABLED_CHACHA=no -fi - -if test "$ENABLED_CHACHA" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_CHACHA" -fi - -AM_CONDITIONAL([BUILD_CHACHA], [test "x$ENABLED_CHACHA" = "xyes"]) - - -# Hash DRBG -AC_ARG_ENABLE([hashdrbg], - [ --enable-hashdrbg Enable Hash DRBG support (default: enabled)], - [ ENABLED_HASHDRBG=$enableval ], - [ ENABLED_HASHDRBG=yes ] - ) - -if test "x$ENABLED_HASHDRBG" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_HASHDRBG" -else - # turn on Hash DRBG if FIPS is on or ARC4 is off - if test "x$ENABLED_FIPS" = "xyes" || test "x$ENABLED_ARC4" = "xno" - then - AM_CFLAGS="$AM_CFLAGS -DHAVE_HASHDRBG" - ENABLED_HASHDRBG=yes - fi -fi - - -# Filesystem Build -AC_ARG_ENABLE([filesystem], - [ --enable-filesystem Enable Filesystem support (default: enabled)], - [ ENABLED_FILESYSTEM=$enableval ], - [ ENABLED_FILESYSTEM=yes ] - ) - -if test "$ENABLED_FILESYSTEM" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_FILESYSTEM" -else - # turn off filesystem if leanpsk on - if test "$ENABLED_LEANPSK" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DNO_FILESYSTEM" - ENABLED_FILESYSTEM=no - fi -fi - - -# inline Build -AC_ARG_ENABLE([inline], - [ --enable-inline Enable inline functions (default: enabled)], - [ ENABLED_INLINE=$enableval ], - [ ENABLED_INLINE=yes ] - ) - -if test "$ENABLED_INLINE" = "no" -then - AM_CFLAGS="$AM_CFLAGS -DNO_INLINE" -fi - -AM_CONDITIONAL([BUILD_INLINE], [test "x$ENABLED_INLINE" = "xyes"]) - - -# OCSP -AC_ARG_ENABLE([ocsp], - [ --enable-ocsp Enable OCSP (default: disabled)], - [ ENABLED_OCSP=$enableval ], - [ ENABLED_OCSP=no ], - ) - -if test "$ENABLED_OCSP" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_OCSP" -fi - -AM_CONDITIONAL([BUILD_OCSP], [test "x$ENABLED_OCSP" = "xyes"]) - - -if test "$ENABLED_OCSP" = "yes" -then - # check openssl command tool for testing ocsp - AC_CHECK_PROG([HAVE_OPENSSL_CMD],[openssl],[yes],[no]) - - if test "$HAVE_OPENSSL_CMD" = "yes" - then - AM_CFLAGS="$AM_CFLAGS -DHAVE_OPENSSL_CMD" - else - AC_MSG_WARN([openssl command line tool not available for testing ocsp]) - fi -fi - - -# CRL -AC_ARG_ENABLE([crl], - [ --enable-crl Enable CRL (default: disabled)], - [ ENABLED_CRL=$enableval ], - [ ENABLED_CRL=no ], - ) - -if test "$ENABLED_CRL" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL" -fi - -AM_CONDITIONAL([BUILD_CRL], [test "x$ENABLED_CRL" = "xyes"]) - - -# CRL Monitor -AC_ARG_ENABLE([crl-monitor], - [ --enable-crl-monitor Enable CRL Monitor (default: disabled)], - [ ENABLED_CRL_MONITOR=$enableval ], - [ ENABLED_CRL_MONITOR=no ], - ) - -if test "$ENABLED_CRL_MONITOR" = "yes" -then - case $host_os in - *linux* | *darwin* | *freebsd*) - AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL_MONITOR" ;; - *) - AC_MSG_ERROR([crl monitor only allowed on linux, OS X, or freebsd]) ;; - esac -fi - -AM_CONDITIONAL([BUILD_CRL_MONITOR], [test "x$ENABLED_CRL_MONITOR" = "xyes"]) - - -# NTRU -ENABLED_NTRU="no" -tryntrudir="" -AC_ARG_WITH([ntru], - [ --with-ntru=PATH Path to NTRU install (default /usr/) ], - [ - AC_MSG_CHECKING([for NTRU]) - CPPFLAGS="$CPPFLAGS -DHAVE_NTRU" - LIBS="$LIBS -lNTRUEncrypt" - - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ ntru_crypto_drbg_instantiate(0, 0, 0, 0, 0); ]])], [ ntru_linked=yes ],[ ntru_linked=no ]) - - if test "x$ntru_linked" == "xno" ; then - if test "x$withval" != "xno" ; then - tryntrudir=$withval - fi - if test "x$withval" == "xyes" ; then - tryntrudir="/usr" - fi - - LDFLAGS="$AM_LDFLAGS -L$tryntrudir/lib" - CPPFLAGS="$CPPFLAGS -I$tryntrudir/include" - - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ ntru_crypto_drbg_instantiate(0, 0, 0, 0, 0); ]])], [ ntru_linked=yes ],[ ntru_linked=no ]) - - if test "x$ntru_linked" == "xno" ; then - AC_MSG_ERROR([NTRU isn't found. - If it's already installed, specify its path using --with-ntru=/dir/]) - fi - AC_MSG_RESULT([yes]) - AM_LDFLAGS="$AM_LDFLAGS -L$tryntrudir/lib" - else - AC_MSG_RESULT([yes]) - fi - - AM_CFLAGS="$AM_CFLAGS -DHAVE_NTRU" - ENABLED_NTRU="yes" - ] -) - -AM_CONDITIONAL([BUILD_NTRU], [test "x$ENABLED_NTRU" = "xyes"]) - -if test "$ENABLED_NTRU" = "yes" && test "$ENABLED_SMALL" = "yes" -then - AC_MSG_ERROR([cannot enable ntru and small, ntru requires TLS which small turns off.]) -fi - -# SNI -AC_ARG_ENABLE([sni], - [ --enable-sni Enable SNI (default: disabled)], - [ ENABLED_SNI=$enableval ], - [ ENABLED_SNI=no ] - ) - -if test "x$ENABLED_SNI" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SNI" -fi - -# Maximum Fragment Length -AC_ARG_ENABLE([maxfragment], - [ --enable-maxfragment Enable Maximum Fragment Length (default: disabled)], - [ ENABLED_MAX_FRAGMENT=$enableval ], - [ ENABLED_MAX_FRAGMENT=no ] - ) - -if test "x$ENABLED_MAX_FRAGMENT" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_MAX_FRAGMENT" -fi - -# Truncated HMAC -AC_ARG_ENABLE([truncatedhmac], - [ --enable-truncatedhmac Enable Truncated HMAC (default: disabled)], - [ ENABLED_TRUNCATED_HMAC=$enableval ], - [ ENABLED_TRUNCATED_HMAC=no ] - ) - -if test "x$ENABLED_TRUNCATED_HMAC" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_TRUNCATED_HMAC" -fi - -# Renegotiation Indication - (FAKE Secure Renegotiation) -AC_ARG_ENABLE([renegotiation-indication], - [AS_HELP_STRING([--enable-renegotiation-indication],[Enable Renegotiation Indication (default: disabled)])], - [ ENABLED_RENEGOTIATION_INDICATION=$enableval ], - [ ENABLED_RENEGOTIATION_INDICATION=no ] - ) - -if test "x$ENABLED_RENEGOTIATION_INDICATION" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_RENEGOTIATION_INDICATION" -fi - -# Secure Renegotiation -AC_ARG_ENABLE([secure-renegotiation], - [AS_HELP_STRING([--enable-secure-renegotiation],[Enable Secure Renegotiation (default: disabled)])], - [ ENABLED_SECURE_RENEGOTIATION=$enableval ], - [ ENABLED_SECURE_RENEGOTIATION=no ] - ) - -if test "x$ENABLED_SECURE_RENEGOTIATION" = "xyes" -then - if test "x$ENABLED_RENEGOTIATION_INDICATION" = "xyes" - then - AC_MSG_ERROR([cannot enable renegotiation-indication and secure-renegotiation.]) - fi - AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SECURE_RENEGOTIATION" -fi - -# Supported Elliptic Curves Extensions -AC_ARG_ENABLE([supportedcurves], - [AS_HELP_STRING([--enable-supportedcurves],[Enable Supported Elliptic Curves (default: disabled)])], - [ ENABLED_SUPPORTED_CURVES=$enableval ], - [ ENABLED_SUPPORTED_CURVES=no ] - ) - -if test "x$ENABLED_SUPPORTED_CURVES" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SUPPORTED_CURVES" -fi - -# Session Ticket Extension -AC_ARG_ENABLE([session-ticket], - [AS_HELP_STRING([--enable-session-ticket],[Enable Session Ticket (default: disabled)])], - [ ENABLED_SESSION_TICKET=$enableval ], - [ ENABLED_SESSION_TICKET=no ] - ) - -if test "x$ENABLED_SESSION_TICKET" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SESSION_TICKET" -fi - -# TLS Extensions -AC_ARG_ENABLE([tlsx], - [ --enable-tlsx Enable all TLS Extensions (default: disabled)], - [ ENABLED_TLSX=$enableval ], - [ ENABLED_TLSX=no ] - ) - -if test "x$ENABLED_TLSX" = "xyes" -then - ENABLED_SNI=yes - ENABLED_MAX_FRAGMENT=yes - ENABLED_TRUNCATED_HMAC=yes - ENABLED_SUPPORTED_CURVES=yes - AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SNI -DHAVE_MAX_FRAGMENT -DHAVE_TRUNCATED_HMAC -DHAVE_SUPPORTED_CURVES" -fi - -# PKCS7 -AC_ARG_ENABLE([pkcs7], - [ --enable-pkcs7 Enable PKCS7 (default: disabled)], - [ ENABLED_PKCS7=$enableval ], - [ ENABLED_PKCS7=no ], - ) - -if test "$ENABLED_PKCS7" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_PKCS7" -fi - -AM_CONDITIONAL([BUILD_PKCS7], [test "x$ENABLED_PKCS7" = "xyes"]) - - -# Simple Certificate Enrollment Protocol (SCEP) -AC_ARG_ENABLE([scep], - [ --enable-scep Enable wolfSCEP (default: disabled)], - [ ENABLED_WOLFSCEP=$enableval ], - [ ENABLED_WOLFSCEP=no ] - ) -if test "$ENABLED_WOLFSCEP" = "yes" -then - # Enable prereqs if not already enabled - if test "x$ENABLED_KEYGEN" = "xno" - then - ENABLED_KEYGEN="yes" - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_KEY_GEN" - fi - if test "x$ENABLED_CERTGEN" = "xno" - then - ENABLED_CERTGEN="yes" - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CERT_GEN" - fi - if test "x$ENABLED_CERTREQ" = "xno" - then - ENABLED_CERTREQ="yes" - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CERT_REQ" - fi - if test "x$ENABLED_PKCS7" = "xno" - then - ENABLED_PKCS7="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_PKCS7" - AM_CONDITIONAL([BUILD_PKCS7], [test "x$ENABLED_PKCS7" = "xyes"]) - fi - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAVE_WOLFSCEP" -fi - - -# Small Stack -AC_ARG_ENABLE([smallstack], - [ --enable-smallstack Enable Small Stack Usage (default: disabled)], - [ ENABLED_SMALL_STACK=$enableval ], - [ ENABLED_SMALL_STACK=no ] - ) - -if test "x$ENABLED_SMALL_STACK" = "xyes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SMALL_STACK" -fi - - -#valgrind -AC_ARG_ENABLE([valgrind], - [ --enable-valgrind Enable valgrind for unit tests (default: disabled)], - [ ENABLED_VALGRIND=$enableval ], - [ ENABLED_VALGRIND=no ] - ) - -if test "$ENABLED_VALGRIND" = "yes" -then - AC_CHECK_PROG([HAVE_VALGRIND],[valgrind],[yes],[no]) - - if test "$HAVE_VALGRIND" = "no" - then - AC_MSG_ERROR([Valgrind not found.]) - fi - enable_shared=no - enable_static=yes - AM_CFLAGS="$AM_CFLAGS -DHAVE_VALGRIND" -fi - -AM_CONDITIONAL([USE_VALGRIND], [test "x$ENABLED_VALGRIND" = "xyes"]) - - -# Test certs, use internal cert functions for extra testing -AC_ARG_ENABLE([testcert], - [ --enable-testcert Enable Test Cert (default: disabled)], - [ ENABLED_TESTCERT=$enableval ], - [ ENABLED_TESTCERT=no ] - ) - -if test "$ENABLED_TESTCERT" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_TEST_CERT" -fi - - -# I/O Pool, an example to show user how to override memory handler and use -# a pool for the input/output buffer requests -AC_ARG_ENABLE([iopool], - [ --enable-iopool Enable I/O Pool example (default: disabled)], - [ ENABLED_IOPOOL=$enableval ], - [ ENABLED_IOPOOL=no ] - ) - -if test "$ENABLED_IOPOOL" = "yes" -then - if test "$thread_ls_on" = "no" - then - AC_MSG_ERROR([I/O Pool example requires Thread Local Storage]) - fi - AM_CFLAGS="$AM_CFLAGS -DHAVE_IO_POOL -DXMALLOC_USER" -fi - - -# Certificate Service Support -AC_ARG_ENABLE([certservice], - [ --enable-certservice Enable cert service (default: disabled)], - [ ENABLED_CERT_SERVICE=$enableval ], - [ ENABLED_CERT_SERVICE=no ] - ) -if test "$ENABLED_CERT_SERVICE" = "yes" -then - # Requires ecc,certgen, and opensslextra make sure on - if test "x$ENABLED_CERTGEN" = "xno" - then - ENABLED_CERTGEN="yes" - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CERT_GEN" - fi - if test "x$ENABLED_ECC" = "xno" - then - ENABLED_ECC="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC -DTFM_ECC256 -DECC_SHAMIR" - AM_CONDITIONAL([BUILD_ECC], [test "x$ENABLED_ECC" = "xyes"]) - fi - if test "x$ENABLED_OPENSSLEXTRA" = "xno" - then - ENABLED_OPENSSLEXTRA="yes" - AM_CFLAGS="-DOPENSSL_EXTRA $AM_CFLAGS" - fi - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAVE_CERT_SERVICE" -fi - - -# PWDBASED has to come after certservice since we want it on w/o explicit on -# PWDBASED -AC_ARG_ENABLE([pwdbased], - [ --enable-pwdbased Enable PWDBASED (default: disabled)], - [ ENABLED_PWDBASED=$enableval ], - [ ENABLED_PWDBASED=no ] - ) - -if test "$ENABLED_PWDBASED" = "no" -then - if test "$ENABLED_OPENSSLEXTRA" = "yes" || test "$ENABLED_WEBSERVER" = "yes" - then - # opensslextra and webserver needs pwdbased - ENABLED_PWDBASED=yes - else - AM_CFLAGS="$AM_CFLAGS -DNO_PWDBASED" - fi -fi - -AM_CONDITIONAL([BUILD_PWDBASED], [test "x$ENABLED_PWDBASED" = "xyes"]) - - -# set fastmath default -FASTMATH_DEFAULT=no - -if test "$host_cpu" = "x86_64" -then -FASTMATH_DEFAULT=yes -fi - -# fastmath -AC_ARG_ENABLE([fastmath], - [ --enable-fastmath Enable fast math ops (default: enabled on x86_64)], - [ ENABLED_FASTMATH=$enableval ], - [ ENABLED_FASTMATH=$FASTMATH_DEFAULT] - ) - -if test "x$ENABLED_FASTMATH" = "xyes" -then - # turn off fastmth if leanpsk on or asn off (w/o dh) - if test "$ENABLED_LEANPSK" = "yes" || test "$ENABLED_ASN" = "no" - then - if test "$ENABLED_DH" = "no" - then - ENABLED_FASTMATH=no - else - AM_CFLAGS="$AM_CFLAGS -DUSE_FAST_MATH" - ENABLED_SLOWMATH="no" - fi - else - AM_CFLAGS="$AM_CFLAGS -DUSE_FAST_MATH" - ENABLED_SLOWMATH="no" - fi - if test "$host_cpu" = "x86_64" - then - # Have settings.h set FP_MAX_BITS higher if user didn't set directly - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_X86_64_BUILD" - fi -fi - - -# fast HUGE math -AC_ARG_ENABLE([fasthugemath], - [ --enable-fasthugemath Enable fast math + huge code (default: disabled)], - [ ENABLED_FASTHUGEMATH=$enableval ], - [ ENABLED_FASTHUGEMATH=no ] - ) - -if test "$ENABLED_BUMP" = "yes" -then - ENABLED_FASTHUGEMATH="yes" -fi - -if test "$ENABLED_FASTHUGEMATH" = "yes" -then - ENABLED_FASTMATH="yes" - AM_CFLAGS="$AM_CFLAGS -DUSE_FAST_MATH" - ENABLED_SLOWMATH="no" -fi - -AM_CONDITIONAL([BUILD_FASTMATH], [test "x$ENABLED_FASTMATH" = "xyes"]) -AM_CONDITIONAL([BUILD_SLOWMATH], [test "x$ENABLED_SLOWMATH" = "xyes"]) - - -# Enable Examples, used to disable examples -AC_ARG_ENABLE([examples], - [ --enable-examples Enable Examples (default: enabled)], - [ ENABLED_EXAMPLES=$enableval ], - [ ENABLED_EXAMPLES=yes ] - ) - -AS_IF([test "x$ENABLED_FILESYSTEM" = "xno"], [ENABLED_EXAMPLES="no"]) -AS_IF([test "x$ENABLED_INLINE" = "xno"], [ENABLED_EXAMPLES="no"]) -AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$ENABLED_EXAMPLES" = "xyes"]) - - -# LIBZ -ENABLED_LIBZ="no" -trylibzdir="" -AC_ARG_WITH([libz], - [ --with-libz=PATH PATH to libz install (default /usr/) ], - [ - AC_MSG_CHECKING([for libz]) - CPPFLAGS="$CPPFLAGS -DHAVE_LIBZ" - LIBS="$LIBS -lz" - - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ deflateInit(0, 8); ]])],[ libz_linked=yes ],[ libz_linked=no ]) - - if test "x$libz_linked" == "xno" ; then - if test "x$withval" != "xno" ; then - trylibzdir=$withval - fi - if test "x$withval" == "xyes" ; then - trylibzdir="/usr" - fi - - AM_LDFLAGS="$AM_LDFLAGS -L$trylibzdir/lib" - CPPFLAGS="$CPPFLAGS -I$trylibzdir/include" - - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ deflateInit(0, 8); ]])],[ libz_linked=yes ],[ libz_linked=no ]) - - if test "x$libz_linked" == "xno" ; then - AC_MSG_ERROR([libz isn't found. - If it's already installed, specify its path using --with-libz=/dir/]) - fi - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([yes]) - fi - ENABLED_LIBZ="yes" - ] -) -AM_CONDITIONAL([BUILD_LIBZ], [test "x$ENABLED_LIBZ" = "xyes"]) - - -# cavium -trycaviumdir="" -AC_ARG_WITH([cavium], - [ --with-cavium=PATH PATH to cavium/software dir ], - [ - AC_MSG_CHECKING([for cavium]) - CPPFLAGS="$CPPFLAGS -DHAVE_CAVIUM" - - if test "x$withval" == "xyes" ; then - AC_MSG_ERROR([need a PATH for --with-cavium]) - fi - if test "x$withval" != "xno" ; then - trycaviumdir=$withval - fi - - LDFLAGS="$AM_LDFLAGS $trycaviumdir/api/cavium_common.o" - CPPFLAGS="$CPPFLAGS -I$trycaviumdir/include" - - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "cavium_common.h"]], [[ CspShutdown(CAVIUM_DEV_ID); ]])],[ cavium_linked=yes ],[ cavium_linked=no ]) - - if test "x$cavium_linked" == "xno" ; then - AC_MSG_ERROR([cavium isn't found. - If it's already installed, specify its path using --with-cavium=/dir/]) - fi - AC_MSG_RESULT([yes]) - enable_shared=no - enable_static=yes - ] -) - - -# microchip api -AC_ARG_ENABLE([mcapi], - [ --enable-mcapi Enable Microchip API (default: disabled)], - [ ENABLED_MCAPI=$enableval ], - [ ENABLED_MCAPI=no ] - ) - -if test "$ENABLED_MCAPI" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -DHAVE_MCAPI -DWOLFSSL_AES_COUNTER -DWOLFSSL_AES_DIRECT" -fi - -if test "$ENABLED_MCAPI" = "yes" && test "$ENABLED_SHA512" = "no" -then - AC_MSG_ERROR([please enable sha512 if enabling mcapi.]) -fi - -if test "$ENABLED_MCAPI" = "yes" && test "$ENABLED_ECC" = "no" -then - AC_MSG_ERROR([please enable ecc if enabling mcapi.]) -fi - -if test "$ENABLED_MCAPI" = "yes" && test "$ENABLED_LIBZ" = "no" -then - AC_MSG_ERROR([please use --with-libz if enabling mcapi.]) -fi - -AM_CONDITIONAL([BUILD_MCAPI], [test "x$ENABLED_MCAPI" = "xyes"]) - - -# wolfSSL JNI -AC_ARG_ENABLE([jni], - [ --enable-jni Enable wolfSSL JNI (default: disabled)], - [ ENABLED_JNI=$enableval ], - [ ENABLED_JNI=no ] - ) -if test "$ENABLED_JNI" = "yes" -then - # Enable prereqs if not already enabled - if test "x$ENABLED_DTLS" = "xno" - then - ENABLED_DTLS="yes" - AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DTLS" - fi - if test "x$ENABLED_OPENSSLEXTRA" = "xno" - then - ENABLED_OPENSSLEXTRA="yes" - AM_CFLAGS="$AM_CFLAGS -DOPENSSL_EXTRA" - fi - if test "x$ENABLED_CRL" = "xno" - then - ENABLED_CRL="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL" - AM_CONDITIONAL([BUILD_CRL], [test "x$ENABLED_CRL" = "xyes"]) - fi - if test "x$ENABLED_OCSP" = "xno" - then - ENABLED_OCSP="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_OCSP" - AM_CONDITIONAL([BUILD_OCSP], [test "x$ENABLED_OCSP" = "xyes"]) - fi - if test "x$ENABLED_CRL_MONITOR" = "xno" - then - ENABLED_CRL_MONITOR="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL_MONITOR" - fi - if test "x$ENABLED_SAVESESSION" = "xno" - then - ENABLED_SAVESESSION="yes" - AM_CFLAGS="$AM_CFLAGS -DPERSIST_SESSION_CACHE" - fi - if test "x$ENABLED_SAVECERT" = "xno" - then - ENABLED_SAVECERT="yes" - AM_CFLAGS="$AM_CFLAGS -DPERSIST_CERT_CACHE" - fi - if test "x$ENABLED_ATOMICUSER" = "xno" - then - ENABLED_ATOMICUSER="yes" - AM_CFLAGS="$AM_CFLAGS -DATOMIC_USER" - fi - if test "x$ENABLED_ECC" = "xno" - then - ENABLED_ECC="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC" - fi - if test "x$ENABLED_PKCALLBACKS" = "xno" - then - ENABLED_PKCALLBACKS="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_PK_CALLBACKS" - fi - if test "x$ENABLED_DH" = "xno" - then - ENABLED_DH="yes" - AM_CFLAGS="$AM_CFLAGS -DHAVE_DH" - fi -fi - - -# Check for build-type conflicts -AS_IF([test "x$ENABLED_MAXSTRENGTH" = "xyes" && \ - test "x$ENABLED_LEANPSK" = "xyes"], - [AC_MSG_ERROR([Cannot use Max Strength and Lean PSK at the same time.])]) - - -# Update CFLAGS based on options -AS_IF([test "x$ENABLED_MAXSTRENGTH" = "xyes"], - [AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_MAX_STRENGTH"]) - -AS_IF([test "x$ENABLED_MAXSTRENGTH" = "xyes" && \ - test "x$ENABLED_OLD_TLS" = "xyes"], - [AM_CFLAGS="$AM_CFLAGS -DNO_OLD_TLS" - ENABLED_OLD_TLS=no]) - - -# OPTIMIZE FLAGS -if test "$GCC" = "yes" -then - AM_CFLAGS="$AM_CFLAGS -Wall -Wno-unused" - if test "$ax_enable_debug" = "no" - then - if test "$ENABLED_FASTMATH" = "yes" - then - AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_FAST_CFLAGS" - if test "$ENABLED_FASTHUGEMATH" = "yes" - then - AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_HUGE_CFLAGS" - fi - else - AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_CFLAGS" - fi - fi -fi - -# ICC command line warning for non supported warning flags -if test "$CC" = "icc" -then - AM_CFLAGS="$AM_CFLAGS -wd10006" -fi - - -LIB_SOCKET_NSL -AX_HARDEN_CC_COMPILER_FLAGS - -# link to ws2_32 if on mingw -case $host_os in - *mingw32) - LDFLAGS="$LDFLAGS -lws2_32" ;; -esac - -# add user C_EXTRA_FLAGS back -CFLAGS="$CFLAGS $USER_C_EXTRA_FLAGS" -OPTION_FLAGS="$USER_C_EXTRA_FLAGS $AM_CFLAGS" - -CREATE_HEX_VERSION -AC_SUBST([AM_CPPFLAGS]) -AC_SUBST([AM_CFLAGS]) -AC_SUBST([AM_LDFLAGS]) - -# FINAL -AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) -AC_CONFIG_FILES([Makefile]) -AC_CONFIG_FILES([wolfssl/version.h]) -AC_CONFIG_FILES([wolfssl/options.h]) -#have options.h and version.h for autoconf fips tag and build -#if test "x$ENABLED_FIPS" = "xyes" -#then -# AC_CONFIG_FILES([cyassl/version.h]) -# AC_CONFIG_FILES([cyassl/options.h]) -#fi -AC_CONFIG_FILES([support/wolfssl.pc]) -AC_CONFIG_FILES([rpm/spec]) - -AX_CREATE_GENERIC_CONFIG -AX_AM_JOBSERVER([yes]) - -AC_OUTPUT - - -# force make clean -echo "---" -echo "Running make clean..." -make clean >/dev/null 2>&1 -# Touch files that may not be in repository -echo "Touching File..." -touch ctaocrypt/src/fips.c -touch ctaocrypt/src/fips_test.c -echo - -# generate user options header -echo "---" -echo "Generating user options header..." - -OPTION_FILE="wolfssl/options.h" -#if -#OPTION_FILE+="cyassl/options.h" -#fi -rm -f $OPTION_FILE - -echo "/* wolfssl options.h" > $OPTION_FILE -echo " * generated from configure options" >> $OPTION_FILE -echo " *" >> $OPTION_FILE -echo " * Copyright (C) 2006-2015 wolfSSL Inc." >> $OPTION_FILE -echo " *" >> $OPTION_FILE -echo " * This file is part of wolfSSL. (formerly known as CyaSSL)" >> $OPTION_FILE -echo " *" >> $OPTION_FILE -echo " */" >> $OPTION_FILE - -echo "" >> $OPTION_FILE -echo "#pragma once" >> $OPTION_FILE -echo "" >> $OPTION_FILE -echo "#ifdef __cplusplus" >> $OPTION_FILE -echo "extern \"C\" {" >> $OPTION_FILE -echo "#endif" >> $OPTION_FILE -echo "" >> $OPTION_FILE - -for option in $OPTION_FLAGS; do - defonly=`echo $option | sed 's/-D//'` - if test "$defonly" != "$option" - then - noequalsign=`echo $defonly | sed 's/=/ /'` - if test "$noequalsign" = "NDEBUG" || test "$noequalsign" = "DEBUG" - then - echo "not outputing (N)DEBUG to $OPTION_FILE" - continue - fi - - # allow user to igonore system options - ignoresys=no - if [[[ $noequalsign == _* ]]] ; - then - ignoresys=yes - echo "#ifndef WOLFSSL_OPTIONS_IGNORE_SYS" >> $OPTION_FILE - fi - - noarg=`echo $defonly | sed 's/=.*//'` - echo "#undef $noarg" >> $OPTION_FILE - echo "#define $noequalsign" >> $OPTION_FILE - - if test "$ignoresys" = "yes" - then - echo "#endif" >> $OPTION_FILE - fi - - echo "" >> $OPTION_FILE - else - echo "option w/o begin -D is $option, not saving to $OPTION_FILE" - fi -done - -echo "" >> $OPTION_FILE -echo "#ifdef __cplusplus" >> $OPTION_FILE -echo "}" >> $OPTION_FILE -echo "#endif" >> $OPTION_FILE -echo "" >> $OPTION_FILE -echo - -#backwards compatability for those who have included options or version -touch cyassl/options.h -echo "/* cyassl options.h" > cyassl/options.h -echo " * generated from wolfssl/options.h" >> cyassl/options.h -echo " */" >> cyassl/options.h -echo "" -while read -r line -do - echo "$line" >> cyassl/options.h -done < $OPTION_FILE - -# output config summary -echo "---" -echo "Configuration summary for $PACKAGE_NAME version $VERSION" -echo "" -echo " * Installation prefix: $prefix" -echo " * System type: $host_vendor-$host_os" -echo " * Host CPU: $host_cpu" -echo " * C Compiler: $CC" -echo " * C Flags: $CFLAGS" -echo " * C++ Compiler: $CXX" -echo " * C++ Flags: $CXXFLAGS" -echo " * CPP Flags: $CPPFLAGS" -echo " * LIB Flags: $LIB" -echo " * Debug enabled: $ax_enable_debug" -echo " * Warnings as failure: $ac_cv_warnings_as_errors" -echo " * make -j: $enable_jobserver" -echo " * VCS checkout: $ac_cv_vcs_checkout" -echo -echo " Features " -echo " * Single threaded: $ENABLED_SINGLETHREADED" -echo " * Filesystem: $ENABLED_FILESYSTEM" -echo " * OpenSSL Extra API: $ENABLED_OPENSSLEXTRA" -echo " * Max Strength Build: $ENABLED_MAXSTRENGTH" -echo " * fastmath: $ENABLED_FASTMATH" -echo " * sniffer: $ENABLED_SNIFFER" -echo " * snifftest: $ENABLED_SNIFFTEST" -echo " * ARC4: $ENABLED_ARC4" -echo " * AES: $ENABLED_AES" -echo " * AES-NI: $ENABLED_AESNI" -echo " * AES-GCM: $ENABLED_AESGCM" -echo " * AES-CCM: $ENABLED_AESCCM" -echo " * DES3: $ENABLED_DES3" -echo " * Camellia: $ENABLED_CAMELLIA" -echo " * NULL Cipher: $ENABLED_NULL_CIPHER" -echo " * MD5: $ENABLED_MD5" -echo " * RIPEMD: $ENABLED_RIPEMD" -echo " * SHA: $ENABLED_SHA" -echo " * SHA-512: $ENABLED_SHA512" -echo " * BLAKE2: $ENABLED_BLAKE2" -echo " * keygen: $ENABLED_KEYGEN" -echo " * certgen: $ENABLED_CERTGEN" -echo " * certreq: $ENABLED_CERTREQ" -echo " * HC-128: $ENABLED_HC128" -echo " * RABBIT: $ENABLED_RABBIT" -echo " * CHACHA: $ENABLED_CHACHA" -echo " * Hash DRBG: $ENABLED_HASHDRBG" -echo " * PWDBASED: $ENABLED_PWDBASED" -echo " * HKDF: $ENABLED_HKDF" -echo " * MD4: $ENABLED_MD4" -echo " * PSK: $ENABLED_PSK" -echo " * Poly1305: $ENABLED_POLY1305" -echo " * LEANPSK: $ENABLED_LEANPSK" -echo " * RSA: $ENABLED_RSA" -echo " * DSA: $ENABLED_DSA" -echo " * DH: $ENABLED_DH" -echo " * ECC: $ENABLED_ECC" -echo " * CURVE25519: $ENABLED_CURVE25519" -echo " * ED25519: $ENABLED_ED25519" -echo " * FPECC: $ENABLED_FPECC" -echo " * ECC_ENCRYPT: $ENABLED_ECC_ENCRYPT" -echo " * ASN: $ENABLED_ASN" -echo " * Anonymous cipher: $ENABLED_ANON" -echo " * CODING: $ENABLED_CODING" -echo " * MEMORY: $ENABLED_MEMORY" -echo " * I/O POOL: $ENABLED_IOPOOL" -echo " * ERROR_STRINGS: $ENABLED_ERROR_STRINGS" -echo " * DTLS: $ENABLED_DTLS" -echo " * Old TLS Versions: $ENABLED_OLD_TLS" -echo " * OCSP: $ENABLED_OCSP" -echo " * CRL: $ENABLED_CRL" -echo " * CRL-MONITOR: $ENABLED_CRL_MONITOR" -echo " * Persistent session cache: $ENABLED_SAVESESSION" -echo " * Persistent cert cache: $ENABLED_SAVECERT" -echo " * Atomic User Record Layer: $ENABLED_ATOMICUSER" -echo " * Public Key Callbacks: $ENABLED_PKCALLBACKS" -echo " * NTRU: $ENABLED_NTRU" -echo " * SNI: $ENABLED_SNI" -echo " * Maximum Fragment Length: $ENABLED_MAX_FRAGMENT" -echo " * Truncated HMAC: $ENABLED_TRUNCATED_HMAC" -echo " * Renegotiation Indication: $ENABLED_RENEGOTIATION_INDICATION" -echo " * Secure Renegotiation: $ENABLED_SECURE_RENEGOTIATION" -echo " * Supported Elliptic Curves: $ENABLED_SUPPORTED_CURVES" -echo " * Session Ticket: $ENABLED_SESSION_TICKET" -echo " * All TLS Extensions: $ENABLED_TLSX" -echo " * PKCS#7 $ENABLED_PKCS7" -echo " * wolfSCEP $ENABLED_WOLFSCEP" -echo " * Small Stack: $ENABLED_SMALL_STACK" -echo " * valgrind unit tests: $ENABLED_VALGRIND" -echo " * LIBZ: $ENABLED_LIBZ" -echo " * Examples: $ENABLED_EXAMPLES" -echo "" -echo "---" - diff --git a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/aes.c b/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/aes.c deleted file mode 100755 index e9f5886..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/aes.c +++ /dev/null @@ -1 +0,0 @@ -/* dummy file for autoconf */ diff --git a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/des3.c b/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/des3.c deleted file mode 100755 index e9f5886..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/des3.c +++ /dev/null @@ -1 +0,0 @@ -/* dummy file for autoconf */ diff --git a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/fips.c b/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/fips.c deleted file mode 100755 index e69de29..0000000 diff --git a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/fips_test.c b/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/fips_test.c deleted file mode 100755 index e69de29..0000000 diff --git a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/hmac.c b/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/hmac.c deleted file mode 100755 index e9f5886..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/hmac.c +++ /dev/null @@ -1 +0,0 @@ -/* dummy file for autoconf */ diff --git a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/misc.c b/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/misc.c deleted file mode 100755 index dc4198b..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/misc.c +++ /dev/null @@ -1,27 +0,0 @@ -/* misc.c - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#ifdef NO_INLINE - #include -#else - /* for inline includes */ - #include -#endif diff --git a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/random.c b/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/random.c deleted file mode 100755 index e9f5886..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/random.c +++ /dev/null @@ -1 +0,0 @@ -/* dummy file for autoconf */ diff --git a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/rsa.c b/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/rsa.c deleted file mode 100755 index e9f5886..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/rsa.c +++ /dev/null @@ -1 +0,0 @@ -/* dummy file for autoconf */ diff --git a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/sha.c b/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/sha.c deleted file mode 100755 index e9f5886..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/sha.c +++ /dev/null @@ -1 +0,0 @@ -/* dummy file for autoconf */ diff --git a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/sha256.c b/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/sha256.c deleted file mode 100755 index e9f5886..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/sha256.c +++ /dev/null @@ -1 +0,0 @@ -/* dummy file for autoconf */ diff --git a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/sha512.c b/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/sha512.c deleted file mode 100755 index e9f5886..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/sha512.c +++ /dev/null @@ -1 +0,0 @@ -/* dummy file for autoconf */ diff --git a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/wolfcrypt_first.c b/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/wolfcrypt_first.c deleted file mode 100755 index c694aa0..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/wolfcrypt_first.c +++ /dev/null @@ -1,47 +0,0 @@ -/* wolfcrypt_first.c - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -/* This file needs to be linked first in order to work correctly */ - -#ifdef HAVE_CONFIG_H - #include -#endif - -/* in case user set HAVE_FIPS there */ -#include - -#ifdef HAVE_FIPS - -/* read only start address */ -const unsigned int wolfCrypt_FIPS_ro_start[] = -{ 0x1a2b3c4d, 0x00000001 }; - - -/* first function of text/code segment */ -int wolfCrypt_FIPS_first(void); -int wolfCrypt_FIPS_first(void) -{ - return 0; -} - - -#endif /* HAVE_FIPS */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/wolfcrypt_last.c b/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/wolfcrypt_last.c deleted file mode 100755 index cdcd741..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/wolfcrypt_last.c +++ /dev/null @@ -1,47 +0,0 @@ -/* wolfcrypt_last.c - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -/* This file needs to be linked last in order to work correctly */ - -#ifdef HAVE_CONFIG_H - #include -#endif - -/* in case user set HAVE_FIPS there */ -#include - -#ifdef HAVE_FIPS - -/* last function of text/code segment */ -int wolfCrypt_FIPS_last(void); -int wolfCrypt_FIPS_last(void) -{ - return 0; -} - - -/* read only end address */ -const unsigned int wolfCrypt_FIPS_ro_end[] = -{ 0x1a2b3c4d, 0xffffffff }; - - -#endif /* HAVE_FIPS */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/callbacks.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/callbacks.h deleted file mode 100755 index f74f7a6..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/callbacks.h +++ /dev/null @@ -1,22 +0,0 @@ -/* callbacks.h - * - * Copyright (C) 2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/certs_test.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/certs_test.h deleted file mode 100755 index c8465ac..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/certs_test.h +++ /dev/null @@ -1,10 +0,0 @@ -/* certs_test.h */ - -#include - -#ifndef CYASSL_CERTS_TEST_H - #define CYASSL_CERTS_TEST_H WOLFSSL_CERTS_TEST_H -#else - #undef CYASSL_CERTS_TEST_H - #define CYASSL_CERTS_TEST_H WOLFSSL_CERTS_TEST_H -#endif diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/crl.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/crl.h deleted file mode 100755 index 87e402f..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/crl.h +++ /dev/null @@ -1,22 +0,0 @@ -/* crl.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/aes.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/aes.h deleted file mode 100755 index 2bb2135..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/aes.h +++ /dev/null @@ -1,65 +0,0 @@ -/* aes.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef NO_AES - -#ifndef CTAO_CRYPT_AES_H -#define CTAO_CRYPT_AES_H - -#include -#define AesSetKey wc_AesSetKey -#define AesSetIV wc_AesSetIV -#define AesCbcEncrypt wc_AesCbcEncrypt -#define AesCbcDecrypt wc_AesCbcDecrypt -#define AesCbcDecryptWithKey wc_AesCbcDecryptWithKey - -/* AES-CTR */ -#ifdef WOLFSSL_AES_COUNTER - #define AesCtrEncrypt wc_AesCtrEncrypt -#endif -/* AES-DIRECT */ -#if defined(WOLFSSL_AES_DIRECT) - #define AesEncryptDirect wc_AesEncryptDirect - #define AesDecryptDirect wc_AesDecryptDirect - #define AesSetKeyDirect wc_AesSetKeyDirect -#endif -#ifdef HAVE_AESGCM - #define AesGcmSetKey wc_AesGcmSetKey - #define AesGcmEncrypt wc_AesGcmEncrypt - #define AesGcmDecrypt wc_AesGcmDecrypt - #define GmacSetKey wc_GmacSetKey - #define GmacUpdate wc_GmacUpdate -#endif /* HAVE_AESGCM */ -#ifdef HAVE_AESCCM - #define AesCcmSetKey wc_AesCcmSetKey - #define AesCcmEncrypt wc_AesCcmEncrypt - #define AesCcmDecrypt wc_AesCcmDecrypt -#endif /* HAVE_AESCCM */ - -#ifdef HAVE_CAVIUM - #define AesInitCavium wc_AesInitCavium - #define AesFreeCavium wc_AesFreeCavium -#endif - -#endif /* CTAO_CRYPT_AES_H */ -#endif /* NO_AES */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/arc4.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/arc4.h deleted file mode 100755 index 965b079..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/arc4.h +++ /dev/null @@ -1,36 +0,0 @@ -/* arc4.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#ifndef CTAO_CRYPT_ARC4_H -#define CTAO_CRYPT_ARC4_H - -/* for arc4 reverse compatibility */ -#ifndef NO_RC4 -#include - #define CYASSL_ARC4_CAVIUM_MAGIC WOLFSSL_ARC4_CAVIUM_MAGIC - #define Arc4Process wc_Arc4Process - #define Arc4SetKey wc_Arc4SetKey - #define Arc4InitCavium wc_Arc4InitCavium - #define Arc4FreeCavium wc_Arc4FreeCavium -#endif - -#endif /* CTAO_CRYPT_ARC4_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/asn.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/asn.h deleted file mode 100755 index c27c144..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/asn.h +++ /dev/null @@ -1,49 +0,0 @@ -/* asn.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#ifndef NO_ASN - -#ifndef CTAO_CRYPT_ASN_H -#define CTAO_CRYPT_ASN_H - -/* pull in compatibility for each include */ -#include -#include -#include -#include -#include /* public interface */ -#ifdef HAVE_ECC - #include -#endif - - -#include - -#ifndef WOLFSSL_PEMCERT_TODER_DEFINED -#ifndef NO_FILESYSTEM - #define CyaSSL_PemCertToDer wolfSSL_PemCertToDer -#endif -#endif - -#endif /* CTAO_CRYPT_ASN_H */ - -#endif /* !NO_ASN */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/asn_public.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/asn_public.h deleted file mode 100755 index 040734e..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/asn_public.h +++ /dev/null @@ -1,78 +0,0 @@ -/* asn_public.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef CTAO_CRYPT_ASN_PUBLIC_H -#define CTAO_CRYPT_ASN_PUBLIC_H - -/* pull in compatibility for each of the includes */ -#include -#include -#include -#ifdef WOLFSSL_CERT_GEN - #include -#endif - -#include -#ifdef WOLFSSL_CERT_GEN - #define InitCert wc_InitCert - #define MakeCert wc_MakeCert - - #ifdef WOLFSSL_CERT_REQ - #define MakeCertReq wc_MakeCertReq -#endif - - #define SignCert wc_SignCert - #define MakeSelfCert wc_MakeSelfCert - #define SetIssuer wc_SetIssuer - #define SetSubject wc_SetSubject - - #ifdef WOLFSSL_ALT_NAMES - #define SetAltNames wc_SetAltNames -#endif - - #define SetIssuerBuffer wc_SetIssuerBuffer - #define SetSubjectBuffer wc_SetSubjectBuffer - #define SetAltNamesBuffer wc_SetAltNamesBuffer - #define SetDatesBuffer wc_SetDatesBuffer - - #ifdef HAVE_NTRU - #define MakeNtruCert wc_MakeNtruCert - #endif - -#endif /* WOLFSSL_CERT_GEN */ - - #if defined(WOLFSSL_KEY_GEN) || defined(WOLFSSL_CERT_GEN) - #define DerToPem wc_DerToPem -#endif - -#ifdef HAVE_ECC - /* private key helpers */ - #define EccPrivateKeyDecode wc_EccPrivateKeyDecode - #define EccKeyToDer wc_EccKeyToDer -#endif - - /* DER encode signature */ - #define EncodeSignature wc_EncodeSignature - #define GetCTC_HashOID wc_GetCTC_HashOID - -#endif /* CTAO_CRYPT_ASN_PUBLIC_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/blake2-impl.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/blake2-impl.h deleted file mode 100755 index fc5ec3a..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/blake2-impl.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - BLAKE2 reference source code package - reference C implementations - - Written in 2012 by Samuel Neves - - To the extent possible under law, the author(s) have dedicated all copyright - and related and neighboring rights to this software to the public domain - worldwide. This software is distributed without any warranty. - - You should have received a copy of the CC0 Public Domain Dedication along with - this software. If not, see . -*/ -/* blake2-impl.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef CTAOCRYPT_BLAKE2_IMPL_H -#define CTAOCRYPT_BLAKE2_IMPL_H - -#include -#include - -#endif /* CTAOCRYPT_BLAKE2_IMPL_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/blake2-int.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/blake2-int.h deleted file mode 100755 index 07ea8e7..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/blake2-int.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - BLAKE2 reference source code package - reference C implementations - - Written in 2012 by Samuel Neves - - To the extent possible under law, the author(s) have dedicated all copyright - and related and neighboring rights to this software to the public domain - worldwide. This software is distributed without any warranty. - - You should have received a copy of the CC0 Public Domain Dedication along with - this software. If not, see . -*/ -/* blake2-int.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - - -#ifndef CTAOCRYPT_BLAKE2_INT_H -#define CTAOCRYPT_BLAKE2_INT_H - -#include -#include - -#endif /* CTAOCRYPT_BLAKE2_INT_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/blake2.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/blake2.h deleted file mode 100755 index b774917..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/blake2.h +++ /dev/null @@ -1,44 +0,0 @@ -/* blake2.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifdef HAVE_BLAKE2 - -#ifndef CTAOCRYPT_BLAKE2_H -#define CTAOCRYPT_BLAKE2_H - -#include - -/* for blake2 reverse compatibility */ -#ifndef HAVE_FIPS - #define InitBlake2b wc_InitBlake2b - #define Blake2bUpdate wc_Blake2bUpdate - #define Blake2bFinal wc_Blake2bFinal -#else - /* name for when fips hmac calls blake */ - #define wc_InitBlake2b InitBlake2b - #define wc_Blake2bUpdate Blake2bUpdate - #define wc_Blake2bFinal Blake2bFinal -#endif /* HAVE_FIPS */ - -#endif /* CTAOCRYPT_BLAKE2_H */ -#endif /* HAVE_BLAKE2 */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/camellia.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/camellia.h deleted file mode 100755 index bbe7dcf..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/camellia.h +++ /dev/null @@ -1,38 +0,0 @@ -/* camellia.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#ifndef CTAO_CRYPT_CAMELLIA_H -#define CTAO_CRYPT_CAMELLIA_H - - -/* for camellia reverse compatibility */ -#ifdef HAVE_CAMELLIA - #include - #define CamelliaSetKey wc_CamelliaSetKey - #define CamelliaSetIV wc_CamelliaSetIV - #define CamelliaEncryptDirect wc_CamelliaEncryptDirect - #define CamelliaDecryptDirect wc_CamelliaDecryptDirect - #define CamelliaCbcEncrypt wc_CamelliaCbcEncrypt - #define CamelliaCbcDecrypt wc_CamelliaCbcDecrypt -#endif - -#endif /* CTAO_CRYPT_CAMELLIA_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/chacha.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/chacha.h deleted file mode 100755 index 7651d28..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/chacha.h +++ /dev/null @@ -1,35 +0,0 @@ -/* chacha.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#ifndef CTAO_CRYPT_CHACHA_H -#define CTAO_CRYPT_CHACHA_H - - -/* for chacha reverse compatibility */ -#ifdef HAVE_CHACHA - #include - #define Chacha_Process wc_Chacha_Process - #define Chacha_SetKey wc_Chacha_SetKey - #define Chacha_SetIV wc_Chacha_SetIV -#endif - -#endif /* CTAO_CRYPT_CHACHA_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/coding.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/coding.h deleted file mode 100755 index 47f5d25..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/coding.h +++ /dev/null @@ -1,29 +0,0 @@ -/* coding.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef CTAO_CRYPT_CODING_H -#define CTAO_CRYPT_CODING_H - -#include - -#endif /* CTAO_CRYPT_CODING_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/compress.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/compress.h deleted file mode 100755 index 632af2e..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/compress.h +++ /dev/null @@ -1,37 +0,0 @@ -/* compress.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifdef HAVE_LIBZ - -#ifndef CTAO_CRYPT_COMPRESS_H -#define CTAO_CRYPT_COMPRESS_H - -#include - -/* reverse compatibility */ -#define Compress wc_Compress -#define DeCompress wc_DeCompress - -#endif /* CTAO_CRYPT_COMPRESS_H */ - -#endif /* HAVE_LIBZ */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/des3.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/des3.h deleted file mode 100755 index c6fbaa8..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/des3.h +++ /dev/null @@ -1,48 +0,0 @@ -/* des3.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef NO_DES3 - -#ifndef CTAO_CRYPT_DES3_H -#define CTAO_CRYPT_DES3_H - - -#include -#define Des_SetKey wc_Des_SetKey -#define Des_SetIV wc_Des_SetIV -#define Des_CbcEncrypt wc_Des_CbcEncrypt -#define Des_CbcDecrypt wc_Des_CbcDecrypt -#define Des_EcbEncrypt wc_Des_EcbEncrypt -#define Des_CbcDecryptWithKey wc_Des_CbcDecryptWithKey -#define Des3_SetKey wc_Des3_SetKey -#define Des3_SetIV wc_Des3_SetIV -#define Des3_CbcEncrypt wc_Des3_CbcEncrypt -#define Des3_CbcDecrypt wc_Des3_CbcDecrypt -#define Des3_CbcDecryptWithKey wc_Des3_CbcDecryptWithKey -#ifdef HAVE_CAVIUM - #define Des3_InitCavium wc_Des3_InitCavium - #define Des3_FreeCavium wc_Des3_FreeCavium -#endif - -#endif /* NO_DES3 */ -#endif /* CTAO_CRYPT_DES3_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/dh.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/dh.h deleted file mode 100755 index 4bd7757..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/dh.h +++ /dev/null @@ -1,41 +0,0 @@ -/* dh.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef NO_DH - -#ifndef CTAO_CRYPT_DH_H -#define CTAO_CRYPT_DH_H - -/* for dh reverse compatibility */ -#include -#define InitDhKey wc_InitDhKey -#define FreeDhKey wc_FreeDhKey -#define DhGenerateKeyPair wc_DhGenerateKeyPair -#define DhAgree wc_DhAgree -#define DhKeyDecode wc_DhKeyDecode -#define DhSetKey wc_DhSetKey -#define DhParamsLoad wc_DhParamsLoad - -#endif /* CTAO_CRYPT_DH_H */ - -#endif /* NO_DH */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/dsa.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/dsa.h deleted file mode 100755 index bdc8cd5..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/dsa.h +++ /dev/null @@ -1,32 +0,0 @@ -/* dsa.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef NO_DSA - -#ifndef CTAO_CRYPT_DSA_H -#define CTAO_CRYPT_DSA_H - -#include - -#endif /* CTAO_CRYPT_DSA_H */ -#endif /* NO_DSA */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/ecc.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/ecc.h deleted file mode 100755 index 3ae13f7..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/ecc.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ecc.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#ifdef HAVE_ECC - -#ifndef CTAO_CRYPT_ECC_H -#define CTAO_CRYPT_ECC_H - -#include - -/* includes for compatibility */ -#include -#include -#include - -/* for ecc reverse compatibility */ -#ifdef HAVE_ECC - #define ecc_make_key wc_ecc_make_key - #define ecc_shared_secret wc_ecc_shared_secret - #define ecc_sign_hash wc_ecc_sign_hash - #define ecc_verify_hash wc_ecc_verify_hash - #define ecc_init wc_ecc_init - #define ecc_free wc_ecc_free - #define ecc_fp_free wc_ecc_fp_free - #define ecc_export_x963 wc_ecc_export_x963 - #define ecc_size wc_ecc_size - #define ecc_sig_size wc_ecc_sig_size - #define ecc_export_x963_ex wc_ecc_export_x963_ex - #define ecc_import_x963 wc_ecc_import_x963 - #define ecc_import_private_key wc_ecc_import_private_key - #define ecc_rs_to_sig wc_ecc_rs_to_sig - #define ecc_import_raw wc_ecc_import_raw - #define ecc_export_private_only wc_ecc_export_private_only - -#ifdef HAVE_ECC_ENCRYPT - /* ecc encrypt */ - #define ecc_ctx_new wc_ecc_ctx_new - #define ecc_ctx_free wc_ecc_ctx_free - #define ecc_ctx_reset wc_ecc_ctx_reset - #define ecc_ctx_get_own_salt wc_ecc_ctx_get_own_salt - #define ecc_ctx_set_peer_salt wc_ecc_ctx_set_peer_salt - #define ecc_ctx_set_info wc_ecc_ctx_set_info - #define ecc_encrypt wc_ecc_encrypt - #define ecc_decrypt wc_ecc_decrypt -#endif /* HAVE_ECC_ENCRYPT */ -#endif - -#endif /* CTAO_CRYPT_ECC_H */ -#endif /* HAVE_ECC */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/error-crypt.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/error-crypt.h deleted file mode 100755 index f201455..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/error-crypt.h +++ /dev/null @@ -1,32 +0,0 @@ -/* error-crypt.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef CTAO_CRYPT_ERROR_H -#define CTAO_CRYPT_ERROR_H - -/* for name change and fips compatibility @wc_fips */ -#include -#define CTaoCryptErrorString wc_ErrorString -#define CTaoCryptGetErrorString wc_GetErrorString - -#endif /* CTAO_CRYPT_ERROR_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/fips_test.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/fips_test.h deleted file mode 100755 index 12e1ce0..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/fips_test.h +++ /dev/null @@ -1,58 +0,0 @@ -/* fips_test.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef CTAO_CRYPT_FIPS_TEST_H -#define CTAO_CRYPT_FIPS_TEST_H - -#include - - -#ifdef __cplusplus - extern "C" { -#endif - -/* Known Answer Test string inputs are hex, internal */ -CYASSL_LOCAL int DoKnownAnswerTests(char*, int); - - -/* FIPS failure callback */ -typedef void(*wolfCrypt_fips_cb)(int ok, int err, const char* hash); - -/* Public set function */ -CYASSL_API int wolfCrypt_SetCb_fips(wolfCrypt_fips_cb cbf); - -/* Public get status functions */ -CYASSL_API int wolfCrypt_GetStatus_fips(void); -CYASSL_API const char* wolfCrypt_GetCoreHash_fips(void); - -#ifdef HAVE_FORCE_FIPS_FAILURE - /* Public function to force failure mode for operational testing */ - CYASSL_API int wolfCrypt_SetStatus_fips(int); -#endif - - -#ifdef __cplusplus - } /* extern "C" */ -#endif - -#endif /* CTAO_CRYPT_FIPS_TEST_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/hc128.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/hc128.h deleted file mode 100755 index b2c9bc9..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/hc128.h +++ /dev/null @@ -1,39 +0,0 @@ -/* hc128.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef NO_HC128 - -#ifndef CTAO_CRYPT_HC128_H -#define CTAO_CRYPT_HC128_H - -#include - -/* for hc128 reverse compatibility */ -#ifdef HAVE_HC128 - #define Hc128_Process wc_Hc128_Process - #define Hc128_SetKey wc_Hc128_SetKey -#endif - -#endif /* CTAO_CRYPT_HC128_H */ - -#endif /* HAVE_HC128 */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/hmac.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/hmac.h deleted file mode 100755 index 4625f10..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/hmac.h +++ /dev/null @@ -1,44 +0,0 @@ -/* hmac.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef NO_HMAC - -#ifndef CTAO_CRYPT_HMAC_H -#define CTAO_CRYPT_HMAC_H - -#include -#define HmacSetKey wc_HmacSetKey -#define HmacUpdate wc_HmacUpdate -#define HmacFinal wc_HmacFinal -#ifdef HAVE_CAVIUM - #define HmacInitCavium wc_HmacInitCavium - #define HmacFreeCavium wc_HmacFreeCavium -#endif -#define CyaSSL_GetHmacMaxSize wolfSSL_GetHmacMaxSize -#ifdef HAVE_HKDF - #define HKDF wc_HKDF -#endif /* HAVE_HKDF */ - -#endif /* CTAO_CRYPT_HMAC_H */ - -#endif /* NO_HMAC */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/include.am b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/include.am deleted file mode 100755 index c30b26f..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/include.am +++ /dev/null @@ -1,54 +0,0 @@ -# vim:ft=automake -# All paths should be given relative to the root - -EXTRA_DIST+= ctaocrypt/src/misc.c - -nobase_include_HEADERS+= \ - cyassl/ctaocrypt/aes.h \ - cyassl/ctaocrypt/arc4.h \ - cyassl/ctaocrypt/asn.h \ - cyassl/ctaocrypt/asn_public.h \ - cyassl/ctaocrypt/poly1305.h \ - cyassl/ctaocrypt/camellia.h \ - cyassl/ctaocrypt/coding.h \ - cyassl/ctaocrypt/compress.h \ - cyassl/ctaocrypt/des3.h \ - cyassl/ctaocrypt/dh.h \ - cyassl/ctaocrypt/dsa.h \ - cyassl/ctaocrypt/ecc.h \ - cyassl/ctaocrypt/error-crypt.h \ - cyassl/ctaocrypt/fips_test.h \ - cyassl/ctaocrypt/hc128.h \ - cyassl/ctaocrypt/hmac.h \ - cyassl/ctaocrypt/integer.h \ - cyassl/ctaocrypt/md2.h \ - cyassl/ctaocrypt/md4.h \ - cyassl/ctaocrypt/md5.h \ - cyassl/ctaocrypt/misc.h \ - cyassl/ctaocrypt/pkcs7.h \ - cyassl/ctaocrypt/wc_port.h \ - cyassl/ctaocrypt/pwdbased.h \ - cyassl/ctaocrypt/rabbit.h \ - cyassl/ctaocrypt/chacha.h \ - cyassl/ctaocrypt/random.h \ - cyassl/ctaocrypt/ripemd.h \ - cyassl/ctaocrypt/rsa.h \ - cyassl/ctaocrypt/settings.h \ - cyassl/ctaocrypt/settings_comp.h \ - cyassl/ctaocrypt/sha256.h \ - cyassl/ctaocrypt/sha512.h \ - cyassl/ctaocrypt/sha.h \ - cyassl/ctaocrypt/blake2.h \ - cyassl/ctaocrypt/blake2-int.h \ - cyassl/ctaocrypt/blake2-impl.h \ - cyassl/ctaocrypt/tfm.h \ - cyassl/ctaocrypt/types.h \ - cyassl/ctaocrypt/visibility.h \ - cyassl/ctaocrypt/logging.h \ - cyassl/ctaocrypt/memory.h \ - cyassl/ctaocrypt/mpi_class.h \ - cyassl/ctaocrypt/mpi_superclass.h - -noinst_HEADERS+= \ - cyassl/ctaocrypt/port/pic32/pic32mz-crypt.h - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/integer.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/integer.h deleted file mode 100755 index 97b2282..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/integer.h +++ /dev/null @@ -1,34 +0,0 @@ -/* integer.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -/* - * Based on public domain LibTomMath 0.38 by Tom St Denis, tomstdenis@iahu.ca, - * http://math.libtomcrypt.com - */ - - -#ifndef CTAO_CRYPT_INTEGER_H -#define CTAO_CRYPT_INTEGER_H - -#include - -#endif /* CTAO_CRYPT_INTEGER_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/logging.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/logging.h deleted file mode 100755 index faa85d4..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/logging.h +++ /dev/null @@ -1,40 +0,0 @@ -/* logging.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -/* submitted by eof */ - - -#ifndef CYASSL_LOGGING_H -#define CYASSL_LOGGING_H - -/* for fips compatibility @wc_fips */ -#include -#define CYASSL_LEAVE WOLFSSL_LEAVE -#define CYASSL_ERROR WOLFSSL_ERROR -#define CYASSL_ENTER WOLFSSL_ENTER -#define CYASSL_MSG WOLFSSL_MSG -/* check old macros possibly declared */ -#if defined(DEBUG_CYASSL) && !defined(DEBUG_WOLFSSL) - #define DEBUG_WOLFSSL -#endif - -#endif /* CYASSL_LOGGING_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/md2.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/md2.h deleted file mode 100755 index cb76337..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/md2.h +++ /dev/null @@ -1,42 +0,0 @@ -/* md2.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -/* check for old macro */ -#if !defined(CYASSL_MD2) && defined(WOLFSSL_MD2) - #define CYASSL_MD2 -#endif - -#ifdef CYASSL_MD2 - -#ifndef CTAO_CRYPT_MD2_H -#define CTAO_CRYPT_MD2_H - -#include - -#define InitMd2 wc_InitMd2 -#define Md2Update wc_Md2Update -#define Md2Final wc_Md2Final -#define Md2Hash wc_Md2Hash - -#endif /* CTAO_CRYPT_MD2_H */ -#endif /* CYASSL_MD2 */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/md4.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/md4.h deleted file mode 100755 index 4584656..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/md4.h +++ /dev/null @@ -1,37 +0,0 @@ -/* md4.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef NO_MD4 - -#ifndef CTAO_CRYPT_MD4_H -#define CTAO_CRYPT_MD4_H - -#include - -#define InitMd4 wc_InitMd4 -#define Md4Update wc_Md4Update -#define Md4Final wc_Md4Final - -#endif /* CTAO_CRYPT_MD4_H */ - -#endif /* NO_MD4 */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/md5.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/md5.h deleted file mode 100755 index 3f5d017..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/md5.h +++ /dev/null @@ -1,44 +0,0 @@ -/* md5.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#ifndef NO_MD5 - -#ifndef CTAO_CRYPT_MD5_H -#define CTAO_CRYPT_MD5_H - -#include - -#ifndef HAVE_FIPS - #define InitMd5 wc_InitMd5 - #define Md5Update wc_Md5Update - #define Md5Final wc_Md5Final - #define Md5Hash wc_Md5Hash -#else - /* redfined name so that hmac is calling same function names with fips */ - #define wc_InitMd5 InitMd5 - #define wc_Md5Update Md5Update - #define wc_Md5Final Md5Final - #define wc_Md5Hash Md5Hash -#endif - -#endif /* CTAO_CRYPT_MD5_H */ -#endif /* NO_MD5 */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/memory.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/memory.h deleted file mode 100755 index 2850053..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/memory.h +++ /dev/null @@ -1,41 +0,0 @@ -/* memory.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -/* submitted by eof */ - - -#ifndef CYASSL_MEMORY_H -#define CYASSL_MEMORY_H - - -#include -#define CyaSSL_Malloc_cb wolfSSL_Malloc_cb -#define CyaSSL_Free_cb wolfSSL_Free_cb -#define CyaSSL_Realloc_cb wolfSSL_Realloc_cb -#define CyaSSL_SetAllocators wolfSSL_SetAllocators - -/* Public in case user app wants to use XMALLOC/XFREE */ -#define CyaSSL_Malloc wolfSSL_Malloc -#define CyaSSL_Free wolfSSL_Free -#define CyaSSL_Realloc wolfSSL_Realloc - -#endif /* CYASSL_MEMORY_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/misc.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/misc.h deleted file mode 100755 index a640044..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/misc.h +++ /dev/null @@ -1,29 +0,0 @@ -/* misc.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef CTAO_CRYPT_MISC_H -#define CTAO_CRYPT_MISC_H - -#include - -#endif /* CTAO_CRYPT_MISC_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/mpi_class.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/mpi_class.h deleted file mode 100755 index 0ce92a6..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/mpi_class.h +++ /dev/null @@ -1,23 +0,0 @@ -/* mpi_class.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#include - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/mpi_superclass.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/mpi_superclass.h deleted file mode 100755 index 68cd0a6..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/mpi_superclass.h +++ /dev/null @@ -1,26 +0,0 @@ -/* mpi_superclass.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -/* super class file for PK algos */ - -#include - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/pkcs7.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/pkcs7.h deleted file mode 100755 index dfb7c2f..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/pkcs7.h +++ /dev/null @@ -1,52 +0,0 @@ -/* pkcs7.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifdef HAVE_PKCS7 - -#ifndef CTAO_CRYPT_PKCS7_H -#define CTAO_CRYPT_PKCS7_H - -/* pull in compatibility for old includes */ -#include -#include -#include -#include -#include - -#include - -/* for pkcs7 reverse compatibility */ -#define SetContentType wc_SetContentType -#define GetContentType wc_GetContentType -#define CreateRecipientInfo wc_CreateRecipientInfo -#define PKCS7_InitWithCert wc_PKCS7_InitWithCert -#define PKCS7_Free wc_PKCS7_Free -#define PKCS7_EncodeData wc_PKCS7_EncodeData -#define PKCS7_EncodeSignedData wc_PKCS7_EncodeSignedData -#define PKCS7_VerifySignedData wc_PKCS7_VerifySignedData -#define PKCS7_EncodeEnvelopedData wc_PKCS7_EncodeEnvelopedData -#define PKCS7_DecodeEnvelopedData wc_PKCS7_DecodeEnvelopedData - -#endif /* CTAO_CRYPT_PKCS7_H */ - -#endif /* HAVE_PKCS7 */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/poly1305.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/poly1305.h deleted file mode 100755 index bceb772..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/poly1305.h +++ /dev/null @@ -1,38 +0,0 @@ -/* poly1305.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifdef HAVE_POLY1305 - -#ifndef CTAO_CRYPT_POLY1305_H -#define CTAO_CRYPT_POLY1305_H - -#include - -/* for poly1305 reverse compatibility */ -#define Poly1305SetKey wc_Poly1305SetKey -#define Poly1305Update wc_Poly1305Update -#define Poly1305Final wc_Poly1305Final - -#endif /* CTAO_CRYPT_POLY1305_H */ - -#endif /* HAVE_POLY1305 */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/port/pic32/pic32mz-crypt.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/port/pic32/pic32mz-crypt.h deleted file mode 100755 index a5dca89..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/port/pic32/pic32mz-crypt.h +++ /dev/null @@ -1,28 +0,0 @@ -/* pic32mz-crypt.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#ifndef PIC32MZ_CRYPT_H -#define PIC32MZ_CRYPT_H - -#include - -#endif /* PIC32MZ_CRYPT_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/pwdbased.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/pwdbased.h deleted file mode 100755 index 7d6dced..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/pwdbased.h +++ /dev/null @@ -1,36 +0,0 @@ -/* pwdbased.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef NO_PWDBASED - -#ifndef CTAO_CRYPT_PWDBASED_H -#define CTAO_CRYPT_PWDBASED_H - -/* for pwdbased reverse compatibility */ -#include -#define PBKDF1 wc_PBKDF1 -#define PBKDF2 wc_PBKDF2 -#define PKCS12_PBKDF wc_PKCS12_PBKDF - -#endif /* CTAO_CRYPT_PWDBASED_H */ -#endif /* NO_PWDBASED */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/rabbit.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/rabbit.h deleted file mode 100755 index a6e92ec..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/rabbit.h +++ /dev/null @@ -1,39 +0,0 @@ -/* rabbit.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef NO_RABBIT - -#ifndef CTAO_CRYPT_RABBIT_H -#define CTAO_CRYPT_RABBIT_H - -#include - -/* for rabbit reverse compatibility */ -#ifndef NO_RABBIT - #define RabbitProcess wc_RabbitProcess - #define RabbitSetKey wc_RabbitSetKey -#endif - -#endif /* CTAO_CRYPT_RABBIT_H */ - -#endif /* NO_RABBIT */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/random.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/random.h deleted file mode 100755 index 6d3a96f..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/random.h +++ /dev/null @@ -1,38 +0,0 @@ -/* random.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef CTAO_CRYPT_RANDOM_H -#define CTAO_CRYPT_RANDOM_H - - /* for random.h compatibility */ - #include - #define InitRng wc_InitRng - #define RNG_GenerateBlock wc_RNG_GenerateBlock - #define RNG_GenerateByte wc_RNG_GenerateByte - #define FreeRng wc_FreeRng - - #if defined(HAVE_HASHDRBG) || defined(NO_RC4) - #define RNG_HealthTest wc_RNG_HealthTest - #endif /* HAVE_HASHDRBG || NO_RC4 */ - -#endif /* CTAO_CRYPT_RANDOM_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/ripemd.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/ripemd.h deleted file mode 100755 index 4458fcc..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/ripemd.h +++ /dev/null @@ -1,37 +0,0 @@ -/* ripemd.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - - -#ifndef CTAO_CRYPT_RIPEMD_H -#define CTAO_CRYPT_RIPEME_H - -#include - -/* for ripemd reverse compatibility */ -#ifdef WOLFSSL_RIPEMD - #define InitRipeMd wc_InitRipeMd - #define RipeMdUpdate wc_RipeMdUpdate - #define RipeMdFinal wc_RipeMdFinal -#endif - -#endif /* CTAO_CRYPT_RIPEMD_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/rsa.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/rsa.h deleted file mode 100755 index 72f8dc5..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/rsa.h +++ /dev/null @@ -1,56 +0,0 @@ -/* rsa.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#ifndef NO_RSA - -#ifndef CTAO_CRYPT_RSA_H -#define CTAO_CRYPT_RSA_H - -#include -/* includes for their compatibility */ -#include -#include -#include - -#define InitRsaKey wc_InitRsaKey -#define FreeRsaKey wc_FreeRsaKey -#define RsaPublicEncrypt wc_RsaPublicEncrypt -#define RsaPrivateDecryptInline wc_RsaPrivateDecryptInline -#define RsaPrivateDecrypt wc_RsaPrivateDecrypt -#define RsaSSL_Sign wc_RsaSSL_Sign -#define RsaSSL_VerifyInline wc_RsaSSL_VerifyInline -#define RsaSSL_Verify wc_RsaSSL_Verify -#define RsaEncryptSize wc_RsaEncryptSize -#define RsaFlattenPublicKey wc_RsaFlattenPublicKey - -#ifdef WOLFSSL_KEY_GEN - #define MakeRsaKey wc_MakeRsaKey - #define RsaKeyToDer wc_RsaKeyToDer -#endif - -#ifdef HAVE_CAVIUM - #define RsaInitCavium wc_RsaInitCavium - #define RsaFreeCavium wc_RsaFreeCavium -#endif - -#endif /* CTAO_CRYPT_RSA_H */ - -#endif /* NO_RSA */ diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/settings.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/settings.h deleted file mode 100755 index 2d1ab55..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/settings.h +++ /dev/null @@ -1,745 +0,0 @@ -/* settings.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -/* Place OS specific preprocessor flags, defines, includes here, will be - included into every file because types.h includes it */ - - -#ifndef CTAO_CRYPT_SETTINGS_H -#define CTAO_CRYPT_SETTINGS_H - -/* for reverse compatibility after name change */ -#include - -#ifdef __cplusplus - extern "C" { -#endif - -/* Uncomment next line if using IPHONE */ -/* #define IPHONE */ - -/* Uncomment next line if using ThreadX */ -/* #define THREADX */ - -/* Uncomment next line if using Micrium ucOS */ -/* #define MICRIUM */ - -/* Uncomment next line if using Mbed */ -/* #define MBED */ - -/* Uncomment next line if using Microchip PIC32 ethernet starter kit */ -/* #define MICROCHIP_PIC32 */ - -/* Uncomment next line if using Microchip TCP/IP stack, version 5 */ -/* #define MICROCHIP_TCPIP_V5 */ - -/* Uncomment next line if using Microchip TCP/IP stack, version 6 or later */ -/* #define MICROCHIP_TCPIP */ - -/* Uncomment next line if using PIC32MZ Crypto Engine */ -/* #define CYASSL_MICROCHIP_PIC32MZ */ - -/* Uncomment next line if using FreeRTOS */ -/* #define FREERTOS */ - -/* Uncomment next line if using FreeRTOS Windows Simulator */ -/* #define FREERTOS_WINSIM */ - -/* Uncomment next line if using RTIP */ -/* #define EBSNET */ - -/* Uncomment next line if using lwip */ -/* #define CYASSL_LWIP */ - -/* Uncomment next line if building CyaSSL for a game console */ -/* #define CYASSL_GAME_BUILD */ - -/* Uncomment next line if building CyaSSL for LSR */ -/* #define CYASSL_LSR */ - -/* Uncomment next line if building CyaSSL for Freescale MQX/RTCS/MFS */ -/* #define FREESCALE_MQX */ - -/* Uncomment next line if using STM32F2 */ -/* #define CYASSL_STM32F2 */ - -/* Uncomment next line if using Comverge settings */ -/* #define COMVERGE */ - -/* Uncomment next line if using QL SEP settings */ -/* #define CYASSL_QL */ - -/* Uncomment next line if building for EROAD */ -/* #define CYASSL_EROAD */ - -/* Uncomment next line if building for IAR EWARM */ -/* #define CYASSL_IAR_ARM */ - -/* Uncomment next line if using TI-RTOS settings */ -/* #define CYASSL_TIRTOS */ - -/* Uncomment next line if building with PicoTCP */ -/* #define CYASSL_PICOTCP */ - -/* Uncomment next line if building for PicoTCP demo bundle */ -/* #define CYASSL_PICOTCP_DEMO */ - -#include - -#ifdef IPHONE - #define SIZEOF_LONG_LONG 8 -#endif - - -#ifdef CYASSL_USER_SETTINGS - #include -#endif - - -#ifdef COMVERGE - #define THREADX - #define HAVE_NETX - #define CYASSL_USER_IO - #define NO_WRITEV - #define NO_DEV_RANDOM - #define NO_FILESYSTEM - #define NO_SHA512 - #define NO_DH - #define NO_DSA - #define NO_HC128 - #define NO_RSA - #define NO_SESSION_CACHE - #define HAVE_ECC -#endif - - -#ifdef THREADX - #define SIZEOF_LONG_LONG 8 -#endif - -#ifdef HAVE_NETX - #include "nx_api.h" -#endif - -#if defined(HAVE_LWIP_NATIVE) /* using LwIP native TCP socket */ - #define CYASSL_LWIP - #define NO_WRITEV - #define SINGLE_THREADED - #define CYASSL_USER_IO - #define NO_FILESYSTEM -#endif - -#if defined(CYASSL_IAR_ARM) - #define NO_MAIN_DRIVER - #define SINGLE_THREADED - #define USE_CERT_BUFFERS_1024 - #define BENCH_EMBEDDED - #define NO_FILESYSTEM - #define NO_WRITEV - #define CYASSL_USER_IO - #define BENCH_EMBEDDED -#endif - -#ifdef MICROCHIP_PIC32 - /* #define CYASSL_MICROCHIP_PIC32MZ */ - #define SIZEOF_LONG_LONG 8 - #define SINGLE_THREADED - #define CYASSL_USER_IO - #define NO_WRITEV - #define NO_DEV_RANDOM - #define NO_FILESYSTEM - #define USE_FAST_MATH - #define TFM_TIMING_RESISTANT -#endif - -#ifdef CYASSL_MICROCHIP_PIC32MZ - #define CYASSL_PIC32MZ_CE - #define CYASSL_PIC32MZ_CRYPT - #define HAVE_AES_ENGINE - #define CYASSL_PIC32MZ_RNG - /* #define CYASSL_PIC32MZ_HASH */ - #define CYASSL_AES_COUNTER - #define HAVE_AESGCM - #define NO_BIG_INT - -#endif - -#ifdef MICROCHIP_TCPIP_V5 - /* include timer functions */ - #include "TCPIP Stack/TCPIP.h" -#endif - -#ifdef MICROCHIP_TCPIP - /* include timer, NTP functions */ - #ifdef MICROCHIP_MPLAB_HARMONY - #include "tcpip/tcpip.h" - #else - #include "system/system_services.h" - #include "tcpip/sntp.h" - #endif -#endif - -#ifdef MBED - #define CYASSL_USER_IO - #define NO_FILESYSTEM - #define NO_CERT - #define USE_CERT_BUFFERS_1024 - #define NO_WRITEV - #define NO_DEV_RANDOM - #define NO_SHA512 - #define NO_DH - #define NO_DSA - #define NO_HC128 - #define HAVE_ECC - #define NO_SESSION_CACHE - #define CYASSL_CMSIS_RTOS -#endif - - -#ifdef CYASSL_EROAD - #define FREESCALE_MQX - #define FREESCALE_MMCAU - #define SINGLE_THREADED - #define NO_STDIO_FILESYSTEM - #define CYASSL_LEANPSK - #define HAVE_NULL_CIPHER - #define NO_OLD_TLS - #define NO_ASN - #define NO_BIG_INT - #define NO_RSA - #define NO_DSA - #define NO_DH - #define NO_CERTS - #define NO_PWDBASED - #define NO_DES3 - #define NO_MD4 - #define NO_RC4 - #define NO_MD5 - #define NO_SESSION_CACHE - #define NO_MAIN_DRIVER -#endif - -#ifdef CYASSL_PICOTCP - #define errno pico_err - #include "pico_defines.h" - #include "pico_stack.h" - #include "pico_constants.h" - #define CUSTOM_RAND_GENERATE pico_rand -#endif - -#ifdef CYASSL_PICOTCP_DEMO - #define CYASSL_STM32 - #define USE_FAST_MATH - #define TFM_TIMING_RESISTANT - #define XMALLOC(s, h, type) PICO_ZALLOC((s)) - #define XFREE(p, h, type) PICO_FREE((p)) - #define SINGLE_THREADED - #define NO_WRITEV - #define CYASSL_USER_IO - #define NO_DEV_RANDOM - #define NO_FILESYSTEM -#endif - -#ifdef FREERTOS_WINSIM - #define FREERTOS - #define USE_WINDOWS_API -#endif - - -/* Micrium will use Visual Studio for compilation but not the Win32 API */ -#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) \ - && !defined(EBSNET) && !defined(CYASSL_EROAD) - #define USE_WINDOWS_API -#endif - - -#if defined(CYASSL_LEANPSK) && !defined(XMALLOC_USER) - #include - #define XMALLOC(s, h, type) malloc((s)) - #define XFREE(p, h, type) free((p)) - #define XREALLOC(p, n, h, t) realloc((p), (n)) -#endif - -#if defined(XMALLOC_USER) && defined(SSN_BUILDING_LIBYASSL) - #undef XMALLOC - #define XMALLOC yaXMALLOC - #undef XFREE - #define XFREE yaXFREE - #undef XREALLOC - #define XREALLOC yaXREALLOC -#endif - - -#ifdef FREERTOS - #ifndef NO_WRITEV - #define NO_WRITEV - #endif - #ifndef NO_SHA512 - #define NO_SHA512 - #endif - #ifndef NO_DH - #define NO_DH - #endif - #ifndef NO_DSA - #define NO_DSA - #endif - #ifndef NO_HC128 - #define NO_HC128 - #endif - - #ifndef SINGLE_THREADED - #include "FreeRTOS.h" - #include "semphr.h" - #endif -#endif - -#ifdef CYASSL_TIRTOS - #define SIZEOF_LONG_LONG 8 - #define NO_WRITEV - #define NO_CYASSL_DIR - #define USE_FAST_MATH - #define TFM_TIMING_RESISTANT - #define NO_DEV_RANDOM - #define NO_FILESYSTEM - #define USE_CERT_BUFFERS_2048 - #define NO_ERROR_STRINGS - #define USER_TIME - - #ifdef __IAR_SYSTEMS_ICC__ - #pragma diag_suppress=Pa089 - #elif !defined(__GNUC__) - /* Suppress the sslpro warning */ - #pragma diag_suppress=11 - #endif - - #include -#endif - -#ifdef EBSNET - #include "rtip.h" - - /* #define DEBUG_CYASSL */ - #define NO_CYASSL_DIR /* tbd */ - - #if (POLLOS) - #define SINGLE_THREADED - #endif - - #if (RTPLATFORM) - #if (!RTP_LITTLE_ENDIAN) - #define BIG_ENDIAN_ORDER - #endif - #else - #if (!KS_LITTLE_ENDIAN) - #define BIG_ENDIAN_ORDER - #endif - #endif - - #if (WINMSP3) - #undef SIZEOF_LONG - #define SIZEOF_LONG_LONG 8 - #else - #sslpro: settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG - #endif - - #define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC)) - #define XFREE(p, h, type) (rtp_free(p)) - #define XREALLOC(p, n, h, t) realloc((p), (n)) - -#endif /* EBSNET */ - -#ifdef CYASSL_GAME_BUILD - #define SIZEOF_LONG_LONG 8 - #if defined(__PPU) || defined(__XENON) - #define BIG_ENDIAN_ORDER - #endif -#endif - -#ifdef CYASSL_LSR - #define HAVE_WEBSERVER - #define SIZEOF_LONG_LONG 8 - #define CYASSL_LOW_MEMORY - #define NO_WRITEV - #define NO_SHA512 - #define NO_DH - #define NO_DSA - #define NO_HC128 - #define NO_DEV_RANDOM - #define NO_CYASSL_DIR - #define NO_RABBIT - #ifndef NO_FILESYSTEM - #define LSR_FS - #include "inc/hw_types.h" - #include "fs.h" - #endif - #define CYASSL_LWIP - #include /* for tcp errno */ - #define CYASSL_SAFERTOS - #if defined(__IAR_SYSTEMS_ICC__) - /* enum uses enum */ - #pragma diag_suppress=Pa089 - #endif -#endif - -#ifdef CYASSL_SAFERTOS - #ifndef SINGLE_THREADED - #include "SafeRTOS/semphr.h" - #endif - - #include "SafeRTOS/heap.h" - #define XMALLOC(s, h, type) pvPortMalloc((s)) - #define XFREE(p, h, type) vPortFree((p)) - #define XREALLOC(p, n, h, t) pvPortRealloc((p), (n)) -#endif - -#ifdef CYASSL_LOW_MEMORY - #undef RSA_LOW_MEM - #define RSA_LOW_MEM - #undef CYASSL_SMALL_STACK - #define CYASSL_SMALL_STACK - #undef TFM_TIMING_RESISTANT - #define TFM_TIMING_RESISTANT -#endif - -#ifdef FREESCALE_MQX - #define SIZEOF_LONG_LONG 8 - #define NO_WRITEV - #define NO_DEV_RANDOM - #define NO_RABBIT - #define NO_CYASSL_DIR - #define USE_FAST_MATH - #define TFM_TIMING_RESISTANT - #define FREESCALE_K70_RNGA - /* #define FREESCALE_K53_RNGB */ - #include "mqx.h" - #ifndef NO_FILESYSTEM - #include "mfs.h" - #include "fio.h" - #endif - #ifndef SINGLE_THREADED - #include "mutex.h" - #endif - - #define XMALLOC(s, h, t) (void *)_mem_alloc_system((s)) - #define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));} - /* Note: MQX has no realloc, using fastmath above */ -#endif - -#ifdef CYASSL_STM32F2 - #define SIZEOF_LONG_LONG 8 - #define NO_DEV_RANDOM - #define NO_CYASSL_DIR - #define NO_RABBIT - #define STM32F2_RNG - #define STM32F2_CRYPTO - #define KEIL_INTRINSICS -#endif - -#ifdef MICRIUM - - #include "stdlib.h" - #include "net_cfg.h" - #include "ssl_cfg.h" - #include "net_secure_os.h" - - #define CYASSL_TYPES - - typedef CPU_INT08U byte; - typedef CPU_INT16U word16; - typedef CPU_INT32U word32; - - #if (NET_SECURE_MGR_CFG_WORD_SIZE == CPU_WORD_SIZE_32) - #define SIZEOF_LONG 4 - #undef SIZEOF_LONG_LONG - #else - #undef SIZEOF_LONG - #define SIZEOF_LONG_LONG 8 - #endif - - #define STRING_USER - - #define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr))) - #define XSTRNCPY(pstr_dest, pstr_src, len_max) \ - ((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \ - (CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max))) - #define XSTRNCMP(pstr_1, pstr_2, len_max) \ - ((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \ - (CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max))) - #define XSTRSTR(pstr, pstr_srch) \ - ((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \ - (CPU_CHAR *)(pstr_srch))) - #define XMEMSET(pmem, data_val, size) \ - ((void)Mem_Set((void *)(pmem), (CPU_INT08U) (data_val), \ - (CPU_SIZE_T)(size))) - #define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \ - (void *)(psrc), (CPU_SIZE_T)(size))) - #define XMEMCMP(pmem_1, pmem_2, size) \ - (((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), (void *)(pmem_2), \ - (CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES) - #define XMEMMOVE XMEMCPY - -#if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED) - #define MICRIUM_MALLOC - #define XMALLOC(s, h, type) ((void *)NetSecure_BlkGet((CPU_INT08U)(type), \ - (CPU_SIZE_T)(s), (void *)0)) - #define XFREE(p, h, type) (NetSecure_BlkFree((CPU_INT08U)(type), \ - (p), (void *)0)) - #define XREALLOC(p, n, h, t) realloc((p), (n)) -#endif - - #if (NET_SECURE_MGR_CFG_FS_EN == DEF_ENABLED) - #undef NO_FILESYSTEM - #else - #define NO_FILESYSTEM - #endif - - #if (SSL_CFG_TRACE_LEVEL == CYASSL_TRACE_LEVEL_DBG) - #define DEBUG_CYASSL - #else - #undef DEBUG_CYASSL - #endif - - #if (SSL_CFG_OPENSSL_EN == DEF_ENABLED) - #define OPENSSL_EXTRA - #else - #undef OPENSSL_EXTRA - #endif - - #if (SSL_CFG_MULTI_THREAD_EN == DEF_ENABLED) - #undef SINGLE_THREADED - #else - #define SINGLE_THREADED - #endif - - #if (SSL_CFG_DH_EN == DEF_ENABLED) - #undef NO_DH - #else - #define NO_DH - #endif - - #if (SSL_CFG_DSA_EN == DEF_ENABLED) - #undef NO_DSA - #else - #define NO_DSA - #endif - - #if (SSL_CFG_PSK_EN == DEF_ENABLED) - #undef NO_PSK - #else - #define NO_PSK - #endif - - #if (SSL_CFG_3DES_EN == DEF_ENABLED) - #undef NO_DES - #else - #define NO_DES - #endif - - #if (SSL_CFG_AES_EN == DEF_ENABLED) - #undef NO_AES - #else - #define NO_AES - #endif - - #if (SSL_CFG_RC4_EN == DEF_ENABLED) - #undef NO_RC4 - #else - #define NO_RC4 - #endif - - #if (SSL_CFG_RABBIT_EN == DEF_ENABLED) - #undef NO_RABBIT - #else - #define NO_RABBIT - #endif - - #if (SSL_CFG_HC128_EN == DEF_ENABLED) - #undef NO_HC128 - #else - #define NO_HC128 - #endif - - #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG) - #define BIG_ENDIAN_ORDER - #else - #undef BIG_ENDIAN_ORDER - #define LITTLE_ENDIAN_ORDER - #endif - - #if (SSL_CFG_MD4_EN == DEF_ENABLED) - #undef NO_MD4 - #else - #define NO_MD4 - #endif - - #if (SSL_CFG_WRITEV_EN == DEF_ENABLED) - #undef NO_WRITEV - #else - #define NO_WRITEV - #endif - - #if (SSL_CFG_USER_RNG_SEED_EN == DEF_ENABLED) - #define NO_DEV_RANDOM - #else - #undef NO_DEV_RANDOM - #endif - - #if (SSL_CFG_USER_IO_EN == DEF_ENABLED) - #define CYASSL_USER_IO - #else - #undef CYASSL_USER_IO - #endif - - #if (SSL_CFG_DYNAMIC_BUFFERS_EN == DEF_ENABLED) - #undef LARGE_STATIC_BUFFERS - #undef STATIC_CHUNKS_ONLY - #else - #define LARGE_STATIC_BUFFERS - #define STATIC_CHUNKS_ONLY - #endif - - #if (SSL_CFG_DER_LOAD_EN == DEF_ENABLED) - #define CYASSL_DER_LOAD - #else - #undef CYASSL_DER_LOAD - #endif - - #if (SSL_CFG_DTLS_EN == DEF_ENABLED) - #define CYASSL_DTLS - #else - #undef CYASSL_DTLS - #endif - - #if (SSL_CFG_CALLBACKS_EN == DEF_ENABLED) - #define CYASSL_CALLBACKS - #else - #undef CYASSL_CALLBACKS - #endif - - #if (SSL_CFG_FAST_MATH_EN == DEF_ENABLED) - #define USE_FAST_MATH - #else - #undef USE_FAST_MATH - #endif - - #if (SSL_CFG_TFM_TIMING_RESISTANT_EN == DEF_ENABLED) - #define TFM_TIMING_RESISTANT - #else - #undef TFM_TIMING_RESISTANT - #endif - -#endif /* MICRIUM */ - - -#ifdef CYASSL_QL - #ifndef CYASSL_SEP - #define CYASSL_SEP - #endif - #ifndef OPENSSL_EXTRA - #define OPENSSL_EXTRA - #endif - #ifndef SESSION_CERTS - #define SESSION_CERTS - #endif - #ifndef HAVE_AESCCM - #define HAVE_AESCCM - #endif - #ifndef ATOMIC_USER - #define ATOMIC_USER - #endif - #ifndef CYASSL_DER_LOAD - #define CYASSL_DER_LOAD - #endif - #ifndef KEEP_PEER_CERT - #define KEEP_PEER_CERT - #endif - #ifndef HAVE_ECC - #define HAVE_ECC - #endif - #ifndef SESSION_INDEX - #define SESSION_INDEX - #endif -#endif /* CYASSL_QL */ - - -#if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \ - !defined(CYASSL_LEANPSK) && !defined(NO_CYASSL_MEMORY) - #define USE_CYASSL_MEMORY -#endif - - -#if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) - #undef KEEP_PEER_CERT - #define KEEP_PEER_CERT -#endif - - -/* stream ciphers except arc4 need 32bit alignment, intel ok without */ -#ifndef XSTREAM_ALIGNMENT - #if defined(__x86_64__) || defined(__ia64__) || defined(__i386__) - #define NO_XSTREAM_ALIGNMENT - #else - #define XSTREAM_ALIGNMENT - #endif -#endif - - -/* FreeScale MMCAU hardware crypto has 4 byte alignment */ -#ifdef FREESCALE_MMCAU - #define CYASSL_MMCAU_ALIGNMENT 4 -#endif - -/* if using hardware crypto and have alignment requirements, specify the - requirement here. The record header of SSL/TLS will prvent easy alignment. - This hint tries to help as much as possible. */ -#ifndef CYASSL_GENERAL_ALIGNMENT - #ifdef CYASSL_AESNI - #define CYASSL_GENERAL_ALIGNMENT 16 - #elif defined(XSTREAM_ALIGNMENT) - #define CYASSL_GENERAL_ALIGNMENT 4 - #elif defined(FREESCALE_MMCAU) - #define CYASSL_GENERAL_ALIGNMENT CYASSL_MMCAU_ALIGNMENT - #else - #define CYASSL_GENERAL_ALIGNMENT 0 - #endif -#endif - -#ifdef HAVE_CRL - /* not widely supported yet */ - #undef NO_SKID - #define NO_SKID -#endif - - -#ifdef __INTEL_COMPILER - #pragma warning(disable:2259) /* explicit casts to smaller sizes, disable */ -#endif - - -/* Place any other flags or defines here */ - - -#ifdef __cplusplus - } /* extern "C" */ -#endif - - -#endif /* CTAO_CRYPT_SETTINGS_H */ diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/settings_comp.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/settings_comp.h deleted file mode 100755 index 89278a2..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/settings_comp.h +++ /dev/null @@ -1,58 +0,0 @@ -/* settings_comp.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#ifndef CTAO_CRYPT_SETTINGS_C_H -#define CTAO_CRYPT_SETTINGS_C_H - - -/* since fips overrides rsa.h map compatibility here */ -#if !defined(NO_RSA) - #ifdef WOLFSSL_KEY_GEN - #define RsaKeyToDer wc_RsaKeyToDer - #endif - - #define RsaPrivateKeyDecode wc_RsaPrivateKeyDecode - #define RsaPublicKeyDecode wc_RsaPublicKeyDecode - #define RsaPublicKeyDecodeRaw wc_RsaPublicKeyDecodeRaw -#endif /* have rsa and HAVE_FIPS */ - -/* Macro redefinitions for compatibility */ -#ifdef HAVE_NTRU - #define MakeNtruCert wc_MakeNtruCert -#endif -#if defined(WOLFSSL_SHA512) && !defined(CYASSL_SHA512) - #define CYASSL_SHA512 -#endif -#if defined(WOLFSSL_SHA384) && !defined(CYASSL_SHA384) - #define CYASSL_SHA384 -#endif -#if defined(WOLFSSL_LEANPSK) && !defined(CYASSL_LEANPSK) - #define CYASSL_LEANPSK -#endif -#if defined(NO_WOLFSSL_MEMORY) && !defined(NO_CYASSL_MEMORY) - #define NO_CYASSL_MEMORY -#endif -#ifdef WOLFSSL_KEY_GEN - #define CYASSL_KEY_GEN -#endif - -#endif /* CTAO_CRYPT_SETTINGS_C_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/sha.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/sha.h deleted file mode 100755 index 56927e2..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/sha.h +++ /dev/null @@ -1,36 +0,0 @@ -/* sha.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef NO_SHA - -#ifndef CTAO_CRYPT_SHA_H -#define CTAO_CRYPT_SHA_H - -#include -#define InitSha wc_InitSha -#define ShaUpdate wc_ShaUpdate -#define ShaFinal wc_ShaFinal -#define ShaHash wc_ShaHash - -#endif /* CTAO_CRYPT_SHA_H */ -#endif /* NO_SHA */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/sha256.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/sha256.h deleted file mode 100755 index b8b1f24..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/sha256.h +++ /dev/null @@ -1,39 +0,0 @@ -/* sha256.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -/* code submitted by raphael.huck@efixo.com */ - - -#ifndef NO_SHA256 - -#ifndef CTAO_CRYPT_SHA256_H -#define CTAO_CRYPT_SHA256_H - -#include -#define InitSha256 wc_InitSha256 -#define Sha256Update wc_Sha256Update -#define Sha256Final wc_Sha256Final -#define Sha256Hash wc_Sha256Hash - -#endif /* CTAO_CRYPT_SHA256_H */ -#endif /* NO_SHA256 */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/sha512.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/sha512.h deleted file mode 100755 index 3eab760..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/sha512.h +++ /dev/null @@ -1,40 +0,0 @@ -/* sha512.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef CTAO_CRYPT_SHA512_H -#define CTAO_CRYPT_SHA512_H - -#include -#define InitSha512 wc_InitSha512 -#define Sha512Update wc_Sha512Update -#define Sha512Final wc_Sha512Final -#define Sha512Hash wc_Sha512Hash - -#if defined(WOLFSSL_SHA384) || defined(HAVE_AESGCM) - #define InitSha384 wc_InitSha384 - #define Sha384Update wc_Sha384Update - #define Sha384Final wc_Sha384Final - #define Sha384Hash wc_Sha384Hash -#endif /* WOLFSSL_SHA384 */ - -#endif /* CTAO_CRYPT_SHA512_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/tfm.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/tfm.h deleted file mode 100755 index 0b16b51..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/tfm.h +++ /dev/null @@ -1,41 +0,0 @@ -/* tfm.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -/* - * Based on public domain TomsFastMath 0.10 by Tom St Denis, tomstdenis@iahu.ca, - * http://math.libtomcrypt.com - */ - - -/** - * Edited by Moisés Guimarães (moises.guimaraes@phoebus.com.br) - * to fit CyaSSL's needs. - */ - - -#ifndef CTAO_CRYPT_TFM_H -#define CTAO_CRYPT_TFM_H - -#include - -#endif /* CTAO_CRYPT_TFM_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/types.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/types.h deleted file mode 100755 index 95bfb45..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/types.h +++ /dev/null @@ -1,39 +0,0 @@ -/* types.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef CTAO_CRYPT_TYPES_H -#define CTAO_CRYPT_TYPES_H - -#include -#include -#include - -/* compatibility macros */ -#define CYASSL_WORD_SIZE WOLFSSL_WORD_SIZE -#define CYASSL_BIT_SIZE WOLFSSL_BIT_SIZE -#define CYASSL_MAX_16BIT WOLFSSL_MAX_16BIT -#define CYASSL_MAX_ERROR_SZ WOLFSSL_MAX_ERROR_SZ -#define cyassl_word wolfssl_word -#define CYASSL_MAX_ERROR_SZ WOLFSSL_MAX_ERROR_SZ - -#endif /* CTAO_CRYPT_TYPES_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/visibility.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/visibility.h deleted file mode 100755 index 6bb4953..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/visibility.h +++ /dev/null @@ -1,72 +0,0 @@ -/* visibility.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -/* Visibility control macros */ - -#ifndef CTAO_CRYPT_VISIBILITY_H -#define CTAO_CRYPT_VISIBILITY_H - -/* fips compatibility @wc_fips */ -#ifndef HAVE_FIPS - #include - #define CYASSL_API WOLFSSL_API - #define CYASSL_LOCAL WOLFSSL_LOCAL -#else -/* CYASSL_API is used for the public API symbols. - It either imports or exports (or does nothing for static builds) - - CYASSL_LOCAL is used for non-API symbols (private). -*/ - -#if defined(BUILDING_WOLFSSL) - #if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY - #define CYASSL_API __attribute__ ((visibility("default"))) - #define CYASSL_LOCAL __attribute__ ((visibility("hidden"))) - #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) - #define CYASSL_API __global - #define CYASSL_LOCAL __hidden - #elif defined(_MSC_VER) - #ifdef CYASSL_DLL - #define CYASSL_API extern __declspec(dllexport) - #else - #define CYASSL_API - #endif - #define CYASSL_LOCAL - #else - #define CYASSL_API - #define CYASSL_LOCAL - #endif /* HAVE_VISIBILITY */ -#else /* BUILDING_WOLFSSL */ - #if defined(_MSC_VER) - #ifdef CYASSL_DLL - #define CYASSL_API extern __declspec(dllimport) - #else - #define CYASSL_API - #endif - #define CYASSL_LOCAL - #else - #define CYASSL_API - #define CYASSL_LOCAL - #endif -#endif /* BUILDING_WOLFSSL */ -#endif /* HAVE_FIPS */ -#endif /* CTAO_CRYPT_VISIBILITY_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/wc_port.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/wc_port.h deleted file mode 100755 index f35a451..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ctaocrypt/wc_port.h +++ /dev/null @@ -1,31 +0,0 @@ -/* port.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -#ifndef CTAO_CRYPT_PORT_H -#define CTAO_CRYPT_PORT_H - -#include -#include -#define CyaSSL_Mutex wolfSSL_Mutex - -#endif /* CTAO_CRYPT_PORT_H */ - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/error-ssl.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/error-ssl.h deleted file mode 100755 index 8eab843..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/error-ssl.h +++ /dev/null @@ -1,22 +0,0 @@ -/* error-ssl.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/include.am b/FreeRTOS-Plus/Source/WolfSSL/cyassl/include.am deleted file mode 100755 index db1f089..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/include.am +++ /dev/null @@ -1,25 +0,0 @@ -# vim:ft=automake -# All paths should be given relative to the root -# - -include cyassl/ctaocrypt/include.am -include cyassl/openssl/include.am - -EXTRA_DIST+= cyassl/sniffer_error.rc - -nobase_include_HEADERS+= \ - cyassl/error-ssl.h \ - cyassl/ssl.h \ - cyassl/sniffer_error.h \ - cyassl/sniffer.h \ - cyassl/callbacks.h \ - cyassl/certs_test.h \ - cyassl/test.h \ - cyassl/version.h \ - cyassl/options.h \ - cyassl/ocsp.h \ - cyassl/crl.h - -noinst_HEADERS+= \ - cyassl/internal.h - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/internal.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/internal.h deleted file mode 100755 index c0ba722..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/internal.h +++ /dev/null @@ -1,22 +0,0 @@ -/* internal.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ocsp.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ocsp.h deleted file mode 100755 index 1ad9efe..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ocsp.h +++ /dev/null @@ -1,22 +0,0 @@ -/* ocsp.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/asn1.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/asn1.h deleted file mode 100755 index 35be23f..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/asn1.h +++ /dev/null @@ -1,3 +0,0 @@ -/* asn1.h for openssl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/bio.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/bio.h deleted file mode 100755 index 8f52983..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/bio.h +++ /dev/null @@ -1,4 +0,0 @@ -/* bio.h for openssl */ - -#include - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/bn.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/bn.h deleted file mode 100755 index e14f4e2..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/bn.h +++ /dev/null @@ -1,3 +0,0 @@ -/* bn.h for openssl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/conf.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/conf.h deleted file mode 100755 index 4005ea9..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/conf.h +++ /dev/null @@ -1,3 +0,0 @@ -/* conf.h for openssl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/crypto.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/crypto.h deleted file mode 100755 index 32e1108..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/crypto.h +++ /dev/null @@ -1,4 +0,0 @@ -/* crypto.h for openSSL */ - -#include - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/des.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/des.h deleted file mode 100755 index 0c8d55c..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/des.h +++ /dev/null @@ -1,27 +0,0 @@ -/* des.h - * - * Copyright (C) 2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -/* des.h defines mini des openssl compatibility layer - * - */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/dh.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/dh.h deleted file mode 100755 index 6fd8e36..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/dh.h +++ /dev/null @@ -1,4 +0,0 @@ -/* dh.h for openSSL */ - - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/dsa.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/dsa.h deleted file mode 100755 index 2bb476b..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/dsa.h +++ /dev/null @@ -1,3 +0,0 @@ -/* dsa.h for openSSL */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ec.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ec.h deleted file mode 100755 index 1ce8aa9..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ec.h +++ /dev/null @@ -1,3 +0,0 @@ -/* ec.h for openssl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ecdsa.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ecdsa.h deleted file mode 100755 index 9a1c02b..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ecdsa.h +++ /dev/null @@ -1,3 +0,0 @@ -/* ecdsa.h for openssl */ - -#include \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/engine.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/engine.h deleted file mode 100755 index fcce4bd..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/engine.h +++ /dev/null @@ -1,5 +0,0 @@ -/* engine.h for libcurl */ - -#include - - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/err.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/err.h deleted file mode 100755 index 3611117..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/err.h +++ /dev/null @@ -1,3 +0,0 @@ -/* err.h for openssl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/evp.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/evp.h deleted file mode 100755 index fe9f424..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/evp.h +++ /dev/null @@ -1,27 +0,0 @@ -/* evp.h - * - * Copyright (C) 2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -/* evp.h defines mini evp openssl compatibility layer - * - */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/hmac.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/hmac.h deleted file mode 100755 index f35fd75..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/hmac.h +++ /dev/null @@ -1,27 +0,0 @@ -/* hmac.h - * - * Copyright (C) 2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - - -/* hmac.h defines mini hamc openssl compatibility layer - * - */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/include.am b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/include.am deleted file mode 100755 index e531f76..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/include.am +++ /dev/null @@ -1,36 +0,0 @@ -# vim:ft=automake -# All paths should be given relative to the root - -nobase_include_HEADERS+= \ - cyassl/openssl/asn1.h \ - cyassl/openssl/bio.h \ - cyassl/openssl/bn.h \ - cyassl/openssl/conf.h \ - cyassl/openssl/crypto.h \ - cyassl/openssl/des.h \ - cyassl/openssl/dh.h \ - cyassl/openssl/dsa.h \ - cyassl/openssl/ecdsa.h \ - cyassl/openssl/ec.h \ - cyassl/openssl/engine.h \ - cyassl/openssl/err.h \ - cyassl/openssl/evp.h \ - cyassl/openssl/hmac.h \ - cyassl/openssl/lhash.h \ - cyassl/openssl/md4.h \ - cyassl/openssl/md5.h \ - cyassl/openssl/ripemd.h \ - cyassl/openssl/ocsp.h \ - cyassl/openssl/opensslconf.h \ - cyassl/openssl/opensslv.h \ - cyassl/openssl/ossl_typ.h \ - cyassl/openssl/pem.h \ - cyassl/openssl/pkcs12.h \ - cyassl/openssl/rand.h \ - cyassl/openssl/rsa.h \ - cyassl/openssl/sha.h \ - cyassl/openssl/ssl.h \ - cyassl/openssl/stack.h \ - cyassl/openssl/ui.h \ - cyassl/openssl/x509.h \ - cyassl/openssl/x509v3.h diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/lhash.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/lhash.h deleted file mode 100755 index 6285f6a..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/lhash.h +++ /dev/null @@ -1,3 +0,0 @@ -/* lhash.h for openSSL */ - -#include \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/md4.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/md4.h deleted file mode 100755 index fb0d437..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/md4.h +++ /dev/null @@ -1,3 +0,0 @@ -/* md4.h for libcurl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/md5.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/md5.h deleted file mode 100755 index f3dd4e4..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/md5.h +++ /dev/null @@ -1,5 +0,0 @@ -/* md5.h for openssl */ - - -#include - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ocsp.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ocsp.h deleted file mode 100755 index 8c0f468..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ocsp.h +++ /dev/null @@ -1,3 +0,0 @@ -/* ocsp.h for libcurl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/opensslconf.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/opensslconf.h deleted file mode 100755 index 7f21cd9..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/opensslconf.h +++ /dev/null @@ -1,3 +0,0 @@ -/* opensslconf.h for openSSL */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/opensslv.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/opensslv.h deleted file mode 100755 index d119f82..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/opensslv.h +++ /dev/null @@ -1,3 +0,0 @@ -/* opensslv.h compatibility */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ossl_typ.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ossl_typ.h deleted file mode 100755 index 5e6e627..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ossl_typ.h +++ /dev/null @@ -1,3 +0,0 @@ -/* ossl_typ.h for openssl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/pem.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/pem.h deleted file mode 100755 index a07b912..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/pem.h +++ /dev/null @@ -1,3 +0,0 @@ -/* pem.h for openssl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/pkcs12.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/pkcs12.h deleted file mode 100755 index 1fb089f..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/pkcs12.h +++ /dev/null @@ -1,3 +0,0 @@ -/* pkcs12.h for openssl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/rand.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/rand.h deleted file mode 100755 index 5bd77b6..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/rand.h +++ /dev/null @@ -1,3 +0,0 @@ -/* rand.h for openSSL */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ripemd.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ripemd.h deleted file mode 100755 index b25de78..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ripemd.h +++ /dev/null @@ -1,3 +0,0 @@ -/* ripemd.h for openssl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/rsa.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/rsa.h deleted file mode 100755 index 06f10a5..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/rsa.h +++ /dev/null @@ -1,3 +0,0 @@ -/* rsa.h for openSSL */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/sha.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/sha.h deleted file mode 100755 index ced3ca1..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/sha.h +++ /dev/null @@ -1,3 +0,0 @@ -/* sha.h for openssl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ssl.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ssl.h deleted file mode 100755 index 094b994..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ssl.h +++ /dev/null @@ -1,27 +0,0 @@ -/* ssl.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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 - * a with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - - -/* ssl.h defines openssl compatibility layer - * - */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/stack.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/stack.h deleted file mode 100755 index 831502f..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/stack.h +++ /dev/null @@ -1,3 +0,0 @@ -/* stack.h for openssl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ui.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ui.h deleted file mode 100755 index b1f4042..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/ui.h +++ /dev/null @@ -1,3 +0,0 @@ -/* ui.h for openssl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/x509.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/x509.h deleted file mode 100755 index 9d13002..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/x509.h +++ /dev/null @@ -1,3 +0,0 @@ -/* x509.h for openssl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/x509v3.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/x509v3.h deleted file mode 100755 index 2a5240d..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/openssl/x509v3.h +++ /dev/null @@ -1,3 +0,0 @@ -/* x509v3.h for openssl */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/options.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/options.h deleted file mode 100755 index ff58ee4..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/options.h +++ /dev/null @@ -1,93 +0,0 @@ -/* cyassl options.h - * generated from wolfssl/options.h - */ -/* wolfssl options.h -* generated from configure options -* -* Copyright (C) 2006-2015 wolfSSL Inc. -* -* This file is part of wolfSSL. (formerly known as CyaSSL) -* -*/ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef WOLFSSL_OPTIONS_IGNORE_SYS -#undef _POSIX_THREADS -#define _POSIX_THREADS -#endif - -#undef HAVE_THREAD_LS -#define HAVE_THREAD_LS - -#ifndef WOLFSSL_OPTIONS_IGNORE_SYS -#undef _THREAD_SAFE -#define _THREAD_SAFE -#endif - -#undef HAVE_AESGCM -#define HAVE_AESGCM - -#undef WOLFSSL_SHA512 -#define WOLFSSL_SHA512 - -#undef WOLFSSL_SHA384 -#define WOLFSSL_SHA384 - -#undef NO_DSA -#define NO_DSA - -#undef HAVE_ECC -#define HAVE_ECC - -#undef TFM_ECC256 -#define TFM_ECC256 - -#undef ECC_SHAMIR -#define ECC_SHAMIR - -#undef NO_PSK -#define NO_PSK - -#undef NO_RC4 -#define NO_RC4 - -#undef NO_MD4 -#define NO_MD4 - -#undef NO_HC128 -#define NO_HC128 - -#undef NO_RABBIT -#define NO_RABBIT - -#undef HAVE_POLY1305 -#define HAVE_POLY1305 - -#undef HAVE_ONE_TIME_AUTH -#define HAVE_ONE_TIME_AUTH - -#undef HAVE_CHACHA -#define HAVE_CHACHA - -#undef HAVE_HASHDRBG -#define HAVE_HASHDRBG - -#undef NO_PWDBASED -#define NO_PWDBASED - -#undef USE_FAST_MATH -#define USE_FAST_MATH - -#undef WOLFSSL_X86_64_BUILD -#define WOLFSSL_X86_64_BUILD - - -#ifdef __cplusplus -} -#endif - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/sniffer.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/sniffer.h deleted file mode 100755 index 2ae6744..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/sniffer.h +++ /dev/null @@ -1,22 +0,0 @@ -/* sniffer.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/sniffer_error.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/sniffer_error.h deleted file mode 100755 index 8b3e003..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/sniffer_error.h +++ /dev/null @@ -1,22 +0,0 @@ -/* sniffer_error.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/sniffer_error.rc b/FreeRTOS-Plus/Source/WolfSSL/cyassl/sniffer_error.rc deleted file mode 100755 index 8bcd692..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/sniffer_error.rc +++ /dev/null @@ -1,93 +0,0 @@ - -STRINGTABLE -{ - 1, "Out of Memory" - 2, "New SSL Sniffer Server Registered" - 3, "Checking IP Header" - 4, "SSL Sniffer Server Not Registered" - 5, "Checking TCP Header" - - 6, "SSL Sniffer Server Port Not Registered" - 7, "RSA Private Decrypt Error" - 8, "RSA Private Decode Error" - 9, "Set Cipher Spec Error" - 10, "Server Hello Input Malformed" - - 11, "Couldn't Resume Session Error" - 12, "Server Did Resumption" - 13, "Client Hello Input Malformed" - 14, "Client Trying to Resume" - 15, "Handshake Input Malformed" - - 16, "Got Hello Verify msg" - 17, "Got Server Hello msg" - 18, "Got Cert Request msg" - 19, "Got Server Key Exchange msg" - 20, "Got Cert msg" - - 21, "Got Server Hello Done msg" - 22, "Got Finished msg" - 23, "Got Client Hello msg" - 24, "Got Client Key Exchange msg" - 25, "Got Cert Verify msg" - - 26, "Got Unknown Handshake msg" - 27, "New SSL Sniffer Session created" - 28, "Couldn't create new SSL" - 29, "Got a Packet to decode" - 30, "No data present" - - 31, "Session Not Found" - 32, "Got an Old Client Hello msg" - 33, "Old Client Hello Input Malformed" - 34, "Old Client Hello OK" - 35, "Bad Old Client Hello" - - 36, "Bad Record Header" - 37, "Record Header Input Malformed" - 38, "Got a HandShake msg" - 39, "Bad HandShake msg" - 40, "Got a Change Cipher Spec msg" - - 41, "Got Application Data msg" - 42, "Bad Application Data" - 43, "Got an Alert msg" - 44, "Another msg to Process" - 45, "Removing Session From Table" - - 46, "Bad Key File" - 47, "Wrong IP Version" - 48, "Wrong Protocol type" - 49, "Packet Short for header processing" - 50, "Got Unknown Record Type" - - 51, "Can't Open Trace File" - 52, "Session in Fatal Error State" - 53, "Partial SSL record received" - 54, "Buffer Error, malformed input" - 55, "Added to Partial Input" - - 56, "Received a Duplicate Packet" - 57, "Received an Out of Order Packet" - 58, "Received an Overlap Duplicate Packet" - 59, "Received an Overlap Reassembly Begin Duplicate Packet" - 60, "Received an Overlap Reassembly End Duplicate Packet" - - 61, "Missed the Client Hello Entirely" - 62, "Got Hello Request msg" - 63, "Got Session Ticket msg" - 64, "Bad Input" - 65, "Bad Decrypt Type" - - 66, "Bad Finished Message Processing" - 67, "Bad Compression Type" - 68, "Bad DeriveKeys Error" - 69, "Saw ACK for Missing Packet Error" - 70, "Bad Decrypt Operation" - - 71, "Decrypt Keys Not Set Up" - 72, "Late Key Load Error" - 73, "Got Certificate Status msg" - 74, "RSA Key Missing Error" -} - diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ssl.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/ssl.h deleted file mode 100755 index eadf296..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/ssl.h +++ /dev/null @@ -1,720 +0,0 @@ -/* ssl.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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 - * a with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/* - * ssl.h makes wolfssl backwards compatibile with cyassl - */ - -#ifndef WOLFSSL_CYASSL_H_ -#define WOLFSSL_CYASSL_H_ -/* - * Name change - * include the new ssl.h - */ -#include -#include -#include - -#ifdef __cplusplus - extern "C" { -#endif - -#ifdef _WIN32 - /* wincrypt.h clashes */ - #undef X509_NAME -#endif - -#ifdef CYASSL_TIRTOS - #undef CYASSL_TIRTOS - #define CYASSL_TIRTOS WOLFSSL_TIRTOS -#endif - -#define CYASSL WOLFSSL -#define DEBUG_CYASSL DEBUG_WOLFSSL -#define CYASSL_CTX WOLFSSL_CTX -#define CYASSL_METHOD WOLFSSL_METHOD -#define CYASSL_SESSION WOLFSSL_SESSION - -#define CYASSL_X509 WOLFSSL_X509 -#define CYASSL_X509_NAME WOLFSSL_X509_NAME -#define CYASSL_X509_CHAIN WOLFSSL_X509_CHAIN -#ifdef WOLFSSL_SNIFFER - #define CYASSL_SNIFFER WOLFSSL_SNIFFER -#endif - -/* redeclare guard */ -#define CYASSL_TYPES_DEFINED WOLFSSL_TYPES_DEFINED - -/* legacy defines */ -#define yasslIP wolfSSLIP /**/ -#define yasslPort wolfSSLPort /**/ - -/* cyassl/ssl.h (structs) */ -#define CYASSL_RSA WOLFSSL_RSA -#define CYASSL_DSA WOLFSSL_DSA -#define CYASSL_BIO WOLFSSL_BIO -#define CYASSL_CIPHER WOLFSSL_CIPHER -#define CYASSL_MD4_CTX WOLFSSL_MD4_CTX -#define CYASSL_MFL_2_9 WOLFSSL_MFL_2_9 /**/ -#define CYASSL_MFL_2_13 WOLFSSL_MFL_2_13 /**/ -#define CYASSL_EVP_PKEY WOLFSSL_EVP_PKEY -#define CYASSL_X509_CRL WOLFSSL_X509_CRL -#define CYASSL_ASN1_TIME WOLFSSL_ASN1_TIME -#define CYASSL_BIO_METHOD WOLFSSL_BIO_METHOD -#define CYASSL_X509_STORE WOLFSSL_X509_STORE -#define CYASSL_X509_OBJECT WOLFSSL_X509_OBJECT -#define CYASSL_X509_LOOKUP WOLFSSL_X509_LOOKUP -#define CYASSL_ASN1_OBJECT WOLFSSL_ASN1_OBJECT -#define CYASSL_ASN1_STRING WOLFSSL_ASN1_STRING -#define CYASSL_COMP_METHOD WOLFSSL_COMP_METHOD -#define CYASSL_CRL_CHECKALL WOLFSSL_CRL_CHECKALL -#define CYASSL_ASN1_INTEGER WOLFSSL_ASN1_INTEGER -#define CYASSL_X509_REVOKED WOLFSSL_X509_REVOKED -#define CYASSL_dynlock_value WOLFSSL_dynlock_value -#define CYASSL_X509_EXTENSION WOLFSSL_X509_EXTENSION -#define CYASSL_X509_STORE_CTX WOLFSSL_X509_STORE_CTX -#define CYASSL_X509_LOOKUP_METHOD WOLFSSL_X509_LOOKUP_METHOD - -#define CyaSSL_LoadCRL wolfSSL_LoadCRL -#define CyaSSL_EnableCRL wolfSSL_EnableCRL -#define CyaSSL_SetCRL_Cb wolfSSL_SetCRL_Cb - -/* cyassl/test.h */ -#ifdef CyaSSL_TEST_H - #define CYASSL_THREAD WOLFSSL_THREAD -#endif - -/* src/ssl.c */ -#define CYASSL_CRL WOLFSSL_CRL -#define CYASSL_SSLV3 WOLFSSL_SSLV3 -#define CYASSL_TLSV1 WOLFSSL_TLSV1 -#define CYASSL_TLSV1_1 WOLFSSL_TLSV1_1 -#define CYASSL_TLSV1_2 WOLFSSL_TLSV1_2 -#define CYASSL_USER_CA WOLFSSL_USER_CA -#define CYASSL_CLIENT_END WOLFSSL_CLIENT_END -#define CYASSL_CERT_MANAGER WOLFSSL_CERT_MANAGER -#define MAX_CYASSL_FILE_SIZE MAX_WOLFSSL_FILE_SIZE - -#define CyaSSL_get_cipher wolfSSL_get_cipher -#define CyaSSL_get_ciphers wolfSSL_get_ciphers -#define CyaSSL_KeyPemToDer wolfSSL_KeyPemToDer -#define CyaSSL_get_version wolfSSL_get_version -#define CyaSSL_SetServerID wolfSSL_SetServerID -#define CyaSSL_use_old_poly wolfSSL_use_old_poly -#define CyaSSL_SetCertCbCtx wolfSSL_SetCertCbCtx -#define CyaSSL_CertPemToDer wolfSSL_CertPemToDer -#define CyaSSL_get_shutdown wolfSSL_get_shutdown -#define CyaSSL_SetMinVersion wolfSSL_SetMinVersion -#define CyaSSL_CTX_UnloadCAs wolfSSL_CTX_UnloadCAs -#define CyaSSL_session_reused wolfSSL_session_reused -#define CyaSSL_UnloadCertsKeys wolfSSL_UnloadCertsKeys -#define CyaSSL_CIPHER_get_name wolfSSL_CIPHER_get_name -#define CyaSSL_is_init_finished wolfSSL_is_init_finished -#define CyaSSL_get_alert_history wolfSSL_get_alert_history -#define CyaSSL_get_current_cipher wolfSSL_get_current_cipher -#define CyaSSL_CertManagerUnloadCAs wolfSSL_CertManagerUnloadCAs -#define CyaSSL_CertManagerEnableOCSP wolfSSL_CertManagerEnableOCSP -#define CyaSSL_CTX_check_private_key wolfSSL_CTX_check_private_key -#define CyaSSL_CertManagerDisableOCSP wolfSSL_CertManagerDisableOCSP -#define CyaSSL_get_current_cipher_suite wolfSSL_get_current_cipher_suite -#define CyaSSL_CTX_load_verify_locations wolfSSL_CTX_load_verify_locations -#define CyaSSL_CTX_set_default_passwd_cb wolfSSL_CTX_set_default_passwd_cb - -#define CyaSSL_save_session_cache wolfSSL_save_session_cache -#define CyaSSL_restore_session_cache wolfSSL_restore_session_cache -#define CyaSSL_memsave_session_cache wolfSSL_memsave_session_cache -#define CyaSSL_memrestore_session_cache wolfSSL_memrestore_session_cache -#define CyaSSL_get_session_cache_memsize wolfSSL_get_session_cache_memsize - -/* certificate cache persistence, uses ctx since certs are per ctx */ -#define CyaSSL_CTX_save_cert_cache wolfSSL_CTX_save_cert_cache -#define CyaSSL_CTX_restore_cert_cache wolfSSL_CTX_restore_cert_cache -#define CyaSSL_CTX_memsave_cert_cache wolfSSL_CTX_memsave_cert_cache -#define CyaSSL_CTX_memrestore_cert_cache wolfSSL_CTX_memrestore_cert_cache -#define CyaSSL_CTX_get_cert_cache_memsize wolfSSL_CTX_get_cert_cache_memsize - -/* wolfSSL extensions */ -/* get wolfSSL peer X509_CHAIN */ -#define CyaSSL_get_chain_count wolfSSL_get_chain_count -/* index cert length */ -#define CyaSSL_get_chain_length wolfSSL_get_chain_length -/* index cert in X509 */ -#define CyaSSL_get_chain_X509 wolfSSL_get_chain_X509 -/* free X509 */ -#define CyaSSL_FreeX509 wolfSSL_FreeX509 -/* get index cert in PEM */ -#define CyaSSL_X509_get_subjectCN wolfSSL_X509_get_subjectCN -#define CyaSSL_X509_get_der wolfSSL_X509_get_der -#define CyaSSL_X509_notBefore wolfSSL_X509_notBefore -#define CyaSSL_X509_notAfter wolfSSL_X509_notAfter -#define CyaSSL_X509_version wolfSSL_X509_version - -#define CyaSSL_cmp_peer_cert_to_file wolfSSL_cmp_peer_cert_to_file - -#define CyaSSL_X509_get_next_altname wolfSSL_X509_get_next_altname - -#define CyaSSL_X509_d2i wolfSSL_X509_d2i -#ifndef NO_FILESYSTEM - #ifndef NO_STDIO_FILESYSTEM - #define CyaSSL_X509_d2i_fp wolfSSL_X509_d2i_fp - #endif -#define CyaSSL_X509_load_certificate_file wolfSSL_X509_load_certificate_file -#endif - -#ifdef WOLFSSL_SEP -#define CyaSSL_X509_get_device_type wolfSSL_X509_get_device_type -#define CyaSSL_X509_get_hw_type wolfSSL_X509_get_hw_type -#define CyaSSL_X509_get_hw_serial_number wolfSSL_X509_get_hw_serial_number -#endif - -#define CyaSSL_CTX_SetGenCookie wolfSSL_CTX_SetGenCookie -#define CyaSSL_SetCookieCtx wolfSSL_SetCookieCtx -#define CyaSSL_GetCookieCtx wolfSSL_GetCookieCtx -#define CyaSSL_ERR_get_error_line_data wolfSSL_ERR_get_error_line_data -#define CyaSSL_ERR_get_error wolfSSL_ERR_get_error -#define CyaSSL_ERR_clear_error wolfSSL_ERR_clear_error -#define CyaSSL_RAND_status wolfSSL_RAND_status -#define CyaSSL_RAND_bytes wolfSSL_RAND_bytes -#define CyaSSL_CTX_set_options wolfSSL_CTX_set_options -#define CyaSSL_ERR_free_strings wolfSSL_ERR_free_strings -#define CyaSSL_ERR_remove_state wolfSSL_ERR_remove_state -#define CyaSSL_EVP_cleanup wolfSSL_EVP_cleanup -#define CyaSSL_cleanup_all_ex_data wolfSSL_cleanup_all_ex_data -#define CyaSSL_CTX_set_mode wolfSSL_CTX_set_mode -#define CyaSSL_CTX_get_mode wolfSSL_CTX_get_mode -#define CyaSSL_CTX_set_default_read_ahead wolfSSL_CTX_set_default_read_ahead -#define CyaSSL_CTX_sess_set_cache_size wolfSSL_CTX_sess_set_cache_size -#define CyaSSL_CTX_set_default_verify_paths wolfSSL_CTX_set_default_verify_paths -#define CyaSSL_CTX_set_session_id_context wolfSSL_CTX_set_session_id_context -#define CyaSSL_get_peer_certificate wolfSSL_get_peer_certificate -#define CyaSSL_BIO_printf wolfSSL_BIO_printf -#define CyaSSL_ASN1_UTCTIME_print wolfSSL_ASN1_UTCTIME_print -#define CyaSSL_sk_num wolfSSL_sk_num -#define CyaSSL_sk_value wolfSSL_sk_value - -/* stunnel 4.28 needs */ -#define CyaSSL_CTX_get_ex_data wolfSSL_CTX_get_ex_data -#define CyaSSL_CTX_set_ex_data wolfSSL_CTX_set_ex_data -#define CyaSSL_CTX_sess_set_get_cb wolfSSL_CTX_sess_set_get_cb -#define CyaSSL_CTX_sess_set_new_cb wolfSSL_CTX_sess_set_new_cb -#define CyaSSL_CTX_sess_set_remove_cb wolfSSL_CTX_sess_set_remove_cb - -#define CyaSSL_i2d_SSL_SESSION wolfSSL_i2d_SSL_SESSION -#define CyaSSL_d2i_SSL_SESSION wolfSSL_d2i_SSL_SESSION - -#define CyaSSL_SESSION_get_timeout wolfSSL_SESSION_get_timeout -#define CyaSSL_SESSION_get_time wolfSSL_SESSION_get_time -#define CyaSSL_CTX_get_ex_new_index wolfSSL_CTX_get_ex_new_index - - -/* io.c */ -#define CYASSL_CBIO_ERR_ISR WOLFSSL_CBIO_ERR_ISR -#define CYASSL_CBIO_ERR_TIMEOUT WOLFSSL_CBIO_ERR_TIMEOUT -#define CYASSL_CBIO_ERR_GENERAL WOLFSSL_CBIO_ERR_GENERAL -#define CYASSL_CBIO_ERR_CONN_RST WOLFSSL_CBIO_ERR_CONN_RST -#define CYASSL_CBIO_ERR_WANT_READ WOLFSSL_CBIO_ERR_WANT_READ -#define CYASSL_CBIO_ERR_WANT_WRITE WOLFSSL_CBIO_ERR_WANT_WRITE -#define CYASSL_CBIO_ERR_CONN_CLOSE WOLFSSL_CBIO_ERR_CONN_CLOSE - -#define CyaSSL_GetIOReadCtx wolfSSL_GetIOReadCtx -#define CyaSSL_GetIOWriteCtx wolfSSL_GetIOWriteCtx - -/* src/tls.c */ -#define CYASSL_SERVER_END WOLFSSL_SERVER_END -#define CYASSL_TLS_HMAC_INNER_SZ WOLFSSL_TLS_HMAC_INNER_SZ - -#define CyaSSL_DeriveTlsKeys wolfSSL_DeriveTlsKeys -#define CyaSSL_make_eap_keys wolfSSL_make_eap_keys -#define CyaSSL_MakeTlsMasterSecret wolfSSL_MakeTlsMasterSecret - -/* src/internal.c */ -#define CYASSL_CHAIN_CA WOLFSSL_CHAIN_CA -#define CYASSL_ALERT_HISTORY WOLFSSL_ALERT_HISTORY -#define CYASSL_SESSION_TIMEOUT WOLFSSL_SESSION_TIMEOUT -#define CYASSL_CBIO_ERR_CONN_RST WOLFSSL_CBIO_ERR_CONN_RST - -#define cyassl_rc4 wolfssl_rc4 -#define cyassl_aes wolfssl_aes -#define cyassl_chacha wolfssl_chacha -#define CyaSSL_ERR_reason_error_string wolfSSL_ERR_reason_error_string - -#define CyaSSL_set_ex_data wolfSSL_set_ex_data -#define CyaSSL_get_shutdown wolfSSL_get_shutdown -#define CyaSSL_set_rfd wolfSSL_set_rfd -#define CyaSSL_set_wfd wolfSSL_set_wfd -#define CyaSSL_set_shutdown wolfSSL_set_shutdown -#define CyaSSL_set_session_id_context wolfSSL_set_session_id_context -#define CyaSSL_set_connect_state wolfSSL_set_connect_state -#define CyaSSL_set_accept_state wolfSSL_set_accept_state -#define CyaSSL_session_reused wolfSSL_session_reused -#define CyaSSL_SESSION_free wolfSSL_SESSION_free -#define CyaSSL_is_init_finished wolfSSL_is_init_finished - -#define CyaSSL_get_version wolfSSL_get_version -#define CyaSSL_get_current_cipher_suite wolfSSL_get_current_cipher_suite -#define CyaSSL_get_current_cipher wolfSSL_get_current_cipher -#define CyaSSL_CIPHER_description wolfSSL_CIPHER_description -#define CyaSSL_CIPHER_get_name wolfSSL_CIPHER_get_name -#define CyaSSL_get_cipher wolfSSL_get_cipher -#define CyaSSL_get1_session wolfSSL_get1_session - -#define CyaSSL_X509_free wolfSSL_X509_free -#define CyaSSL_OPENSSL_free wolfSSL_OPENSSL_free -#define CyaSSL_OCSP_parse_url wolfSSL_OCSP_parse_url - -#define CyaSSLv23_client_method wolfSSLv23_client_method -#define CyaSSLv2_client_method wolfSSLv2_client_method -#define CyaSSLv2_server_method wolfSSLv2_server_method - -#define CyaSSL_MD4_Init wolfSSL_MD4_Init -#define CyaSSL_MD4_Update wolfSSL_MD4_Update -#define CyaSSL_MD4_Final wolfSSL_MD4_Final - - -#define CyaSSL_BIO_new wolfSSL_BIO_new -#define CyaSSL_BIO_free wolfSSL_BIO_free -#define CyaSSL_BIO_free_all wolfSSL_BIO_free_all -#define CyaSSL_BIO_read wolfSSL_BIO_read -#define CyaSSL_BIO_write wolfSSL_BIO_write -#define CyaSSL_BIO_push wolfSSL_BIO_push -#define CyaSSL_BIO_pop wolfSSL_BIO_pop -#define CyaSSL_BIO_flush wolfSSL_BIO_flush -#define CyaSSL_BIO_pending wolfSSL_BIO_pending - -#define CyaSSL_BIO_f_buffer wolfSSL_BIO_f_buffer -#define CyaSSL_BIO_set_write_buffer_size wolfSSL_BIO_set_write_buffer_size -#define CyaSSL_BIO_f_ssl wolfSSL_BIO_f_ssl -#define CyaSSL_BIO_new_socket wolfSSL_BIO_new_socket -#define CyaSSL_BIO_eof wolfSSL_BIO_eof - -#define CyaSSL_BIO_s_mem wolfSSL_BIO_s_mem -#define CyaSSL_BIO_f_base64 wolfSSL_BIO_f_base64 -#define CyaSSL_BIO_set_flags wolfSSL_BIO_set_flags -#define CyaSSL_BIO_get_mem_data wolfSSL_BIO_get_mem_data -#define CyaSSL_BIO_new_mem_buf wolfSSL_BIO_new_mem_buf - - -#define CyaSSL_BIO_set_ssl wolfSSL_BIO_set_ssl -#define CyaSSL_set_bio wolfSSL_set_bio - -#define CyaSSL_add_all_algorithms wolfSSL_add_all_algorithms -#define CyaSSL_RAND_screen wolfSSL_RAND_screen -#define CyaSSL_RAND_file_name wolfSSL_RAND_file_name -#define CyaSSL_RAND_write_file wolfSSL_RAND_write_file -#define CyaSSL_RAND_load_file wolfSSL_RAND_load_file -#define CyaSSL_RAND_egd wolfSSL_RAND_egd -#define CyaSSL_RAND_seed wolfSSL_RAND_seed -#define CyaSSL_RAND_add wolfSSL_RAND_add - -#define CyaSSL_COMP_zlib wolfSSL_COMP_zlib -#define CyaSSL_COMP_rle wolfSSL_COMP_rle -#define CyaSSL_COMP_add_compression_method wolfSSL_COMP_add_compression_method -#define CyaSSL_set_dynlock_create_callback wolfSSL_set_dynlock_create_callback -#define CyaSSL_set_dynlock_lock_callback wolfSSL_set_dynlock_lock_callback -#define CyaSSL_set_dynlock_destroy_callback wolfSSL_set_dynlock_destroy_callback -#define CyaSSL_get_ex_new_index wolfSSL_get_ex_new_index -#define CyaSSL_set_id_callback wolfSSL_set_id_callback -#define CyaSSL_set_locking_callback wolfSSL_set_locking_callback -#define CyaSSL_num_locks wolfSSL_num_locks - -#define CyaSSL_X509_STORE_CTX_get_current_cert wolfSSL_X509_STORE_CTX_get_current_cert -#define CyaSSL_X509_STORE_CTX_get_error wolfSSL_X509_STORE_CTX_get_error -#define CyaSSL_X509_STORE_CTX_get_error_depth wolfSSL_X509_STORE_CTX_get_error_depth - -#define CyaSSL_X509_NAME_oneline wolfSSL_X509_NAME_oneline -#define CyaSSL_X509_get_issuer_name wolfSSL_X509_get_issuer_name -#define CyaSSL_X509_get_subject_name wolfSSL_X509_get_subject_name -#define CyaSSL_X509_ext_isSet_by_NID wolfSSL_X509_ext_isSet_by_NID -#define CyaSSL_X509_ext_get_critical_by_NID wolfSSL_X509_ext_get_critical_by_NID -#define CyaSSL_X509_get_isCA wolfSSL_X509_get_isCA -#define CyaSSL_X509_get_isSet_pathLength wolfSSL_X509_get_isSet_pathLength -#define CyaSSL_X509_get_pathLength wolfSSL_X509_get_pathLength -#define CyaSSL_X509_get_keyUsage wolfSSL_X509_get_keyUsage -#define CyaSSL_X509_get_authorityKeyID wolfSSL_X509_get_authorityKeyID -#define CyaSSL_X509_get_subjectKeyID wolfSSL_X509_get_subjectKeyID -#define CyaSSL_X509_NAME_entry_count wolfSSL_X509_NAME_entry_count -#define CyaSSL_X509_NAME_get_text_by_NID wolfSSL_X509_NAME_get_text_by_NID -#define CyaSSL_X509_verify_cert wolfSSL_X509_verify_cert -#define CyaSSL_X509_verify_cert_error_string wolfSSL_X509_verify_cert_error_string -#define CyaSSL_X509_get_signature_type wolfSSL_X509_get_signature_type -#define CyaSSL_X509_get_signature wolfSSL_X509_get_signature - -#define CyaSSL_X509_LOOKUP_add_dir wolfSSL_X509_LOOKUP_add_dir -#define CyaSSL_X509_LOOKUP_load_file wolfSSL_X509_LOOKUP_load_file -#define CyaSSL_X509_LOOKUP_hash_dir wolfSSL_X509_LOOKUP_hash_dir -#define CyaSSL_X509_LOOKUP_file wolfSSL_X509_LOOKUP_file - -#define CyaSSL_X509_STORE_add_lookup wolfSSL_X509_STORE_add_lookup -#define CyaSSL_X509_STORE_new wolfSSL_X509_STORE_new -#define CyaSSL_X509_STORE_free wolfSSL_X509_STORE_free -#define CyaSSL_X509_STORE_add_cert wolfSSL_X509_STORE_add_cert -#define CyaSSL_X509_STORE_set_default_paths wolfSSL_X509_STORE_set_default_paths -#define CyaSSL_X509_STORE_get_by_subject wolfSSL_X509_STORE_get_by_subject -#define CyaSSL_X509_STORE_CTX_new wolfSSL_X509_STORE_CTX_new -#define CyaSSL_X509_STORE_CTX_init wolfSSL_X509_STORE_CTX_init -#define CyaSSL_X509_STORE_CTX_free wolfSSL_X509_STORE_CTX_free -#define CyaSSL_X509_STORE_CTX_cleanup wolfSSL_X509_STORE_CTX_cleanup - -#define CyaSSL_X509_CRL_get_lastUpdate wolfSSL_X509_CRL_get_lastUpdate -#define CyaSSL_X509_CRL_get_nextUpdate wolfSSL_X509_CRL_get_nextUpdate - -#define CyaSSL_X509_get_pubkey wolfSSL_X509_get_pubkey -#define CyaSSL_X509_CRL_verify wolfSSL_X509_CRL_verify -#define CyaSSL_X509_STORE_CTX_set_error wolfSSL_X509_STORE_CTX_set_error -#define CyaSSL_X509_OBJECT_free_contents wolfSSL_X509_OBJECT_free_contents -#define CyaSSL_EVP_PKEY_free wolfSSL_EVP_PKEY_free -#define CyaSSL_X509_cmp_current_time wolfSSL_X509_cmp_current_time -#define CyaSSL_sk_X509_REVOKED_num wolfSSL_sk_X509_REVOKED_num - -#define CyaSSL_X509_CRL_get_REVOKED wolfSSL_X509_CRL_get_REVOKED -#define CyaSSL_sk_X509_REVOKED_value wolfSSL_sk_X509_REVOKED_value -#define CyaSSL_X509_get_serialNumber wolfSSL_X509_get_serialNumber -#define CyaSSL_ASN1_TIME_print wolfSSL_ASN1_TIME_print -#define CyaSSL_ASN1_INTEGER_cmp wolfSSL_ASN1_INTEGER_cmp -#define CyaSSL_ASN1_INTEGER_get wolfSSL_ASN1_INTEGER_get -#define CyaSSL_load_client_CA_file wolfSSL_load_client_CA_file -#define CyaSSL_CTX_set_client_CA_list wolfSSL_CTX_set_client_CA_list -#define CyaSSL_X509_STORE_CTX_get_ex_data wolfSSL_X509_STORE_CTX_get_ex_data -#define CyaSSL_get_ex_data_X509_STORE_CTX_idx wolfSSL_get_ex_data_X509_STORE_CTX_idx -#define CyaSSL_get_ex_data wolfSSL_get_ex_data - -#define CyaSSL_CTX_set_default_passwd_cb_userdata wolfSSL_CTX_set_default_passwd_cb_userdata -#define CyaSSL_CTX_set_default_passwd_cb wolfSSL_CTX_set_default_passwd_cb -#define CyaSSL_CTX_set_info_callback wolfSSL_CTX_set_info_callback -#define CyaSSL_ERR_peek_error wolfSSL_ERR_peek_error -#define CyaSSL_GET_REASON wolfSSL_GET_REASON -#define CyaSSL_alert_type_string_long wolfSSL_alert_type_string_long -#define CyaSSL_alert_desc_string_long wolfSSL_alert_desc_string_long -#define CyaSSL_state_string_long wolfSSL_state_string_long - -#define CyaSSL_RSA_generate_key wolfSSL_RSA_generate_key -#define CyaSSL_CTX_set_tmp_rsa_callback wolfSSL_CTX_set_tmp_rsa_callback -#define CyaSSL_PEM_def_callback wolfSSL_PEM_def_callback -#define CyaSSL_CTX_sess_accept wolfSSL_CTX_sess_accept -#define CyaSSL_CTX_sess_connect wolfSSL_CTX_sess_connect -#define CyaSSL_CTX_sess_accept_good wolfSSL_CTX_sess_accept_good -#define CyaSSL_CTX_sess_connect_good wolfSSL_CTX_sess_connect_good -#define CyaSSL_CTX_sess_accept_renegotiate wolfSSL_CTX_sess_accept_renegotiate -#define CyaSSL_CTX_sess_connect_renegotiate wolfSSL_CTX_sess_connect_renegotiate -#define CyaSSL_CTX_sess_hits wolfSSL_CTX_sess_hits -#define CyaSSL_CTX_sess_cb_hits wolfSSL_CTX_sess_cb_hits -#define CyaSSL_CTX_sess_cache_full wolfSSL_CTX_sess_cache_full -#define CyaSSL_CTX_sess_misses wolfSSL_CTX_sess_misses -#define CyaSSL_CTX_sess_timeouts wolfSSL_CTX_sess_timeouts -#define CyaSSL_CTX_sess_number wolfSSL_CTX_sess_number -#define CyaSSL_CTX_sess_get_cache_size wolfSSL_CTX_sess_get_cache_size - - - -/* src/keys.c */ -#define cyassl_triple_des wolfssl_triple_des - -/* Initialization and Shutdown */ -#define CyaSSL_Init wolfSSL_Init -#define CyaSSL_library_init wolfSSL_library_init -#define CyaSSL_Cleanup wolfSSL_Cleanup -#define CyaSSL_shutdown wolfSSL_shutdown - -/* Certs and keys */ -#define CyaSSL_SetTmpDH wolfSSL_SetTmpDH -#define CyaSSL_KeepArrays wolfSSL_KeepArrays -#define CyaSSL_FreeArrays wolfSSL_FreeArrays -#define CyaSSL_SetTmpDH_file wolfSSL_SetTmpDH_file -#define CyaSSL_use_PrivateKey_buffer wolfSSL_use_PrivateKey_buffer -#define CyaSSL_use_certificate_buffer wolfSSL_use_certificate_buffer -#define CyaSSL_CTX_load_verify_buffer wolfSSL_CTX_load_verify_buffer -#define CyaSSL_CTX_use_PrivateKey_file wolfSSL_CTX_use_PrivateKey_file -#define CyaSSL_CTX_use_certificate_file wolfSSL_CTX_use_certificate_file -#define CyaSSL_CTX_use_PrivateKey_buffer wolfSSL_CTX_use_PrivateKey_buffer -#define CyaSSL_CTX_use_PrivateKey_buffer wolfSSL_CTX_use_PrivateKey_buffer -#define CyaSSL_CTX_use_certificate_buffer wolfSSL_CTX_use_certificate_buffer -#define CyaSSL_CTX_use_NTRUPrivateKey_file wolfSSL_CTX_use_NTRUPrivateKey_file -#define CyaSSL_use_certificate_chain_buffer wolfSSL_use_certificate_chain_buffer -#define CyaSSL_CTX_der_load_verify_locations \ - wolfSSL_CTX_der_load_verify_locations -#define CyaSSL_CTX_use_certificate_chain_file \ - wolfSSL_CTX_use_certificate_chain_file -#define CyaSSL_CTX_use_certificate_chain_buffer \ - wolfSSL_CTX_use_certificate_chain_buffer - -/* Context and Session Setup*/ -#define CyaSSL_new wolfSSL_new -#define CyaSSL_free wolfSSL_free -#define CyaSSL_set_fd wolfSSL_set_fd -#define CyaSSL_CTX_new wolfSSL_CTX_new -#define CyaSSL_CTX_free wolfSSL_CTX_free -#define CyaSSL_SetVersion wolfSSL_SetVersion -#define CyaSSL_set_verify wolfSSL_set_verify -#define CyaSSL_set_session wolfSSL_set_session -#define CyaSSL_set_timeout wolfSSL_set_timeout -#define CyaSSL_CTX_set_verify wolfSSL_CTX_set_verify -#define CyaSSL_CTX_set_timeout wolfSSL_CTX_set_timeout -#define CyaSSL_set_cipher_list wolfSSL_set_cipher_list -#define CyaSSL_set_compression wolfSSL_set_compression -#define CyaTLSv1_client_method wolfTLSv1_client_method -#define CyaTLSv1_server_method wolfTLSv1_server_method -#define CyaSSLv3_client_method wolfSSLv3_client_method -#define CyaSSLv3_server_method wolfSSLv3_server_method -#define CyaSSLv23_client_method wolfSSLv23_client_method -#define CyaSSLv23_server_method wolfSSLv23_server_method -#define CyaDTLSv1_client_method wolfDTLSv1_client_method -#define CyaDTLSv1_server_method wolfDTLSv1_server_method -#define CyaSSL_check_domain_name wolfSSL_check_domain_name -#define CyaTLSv1_1_client_method wolfTLSv1_1_client_method -#define CyaTLSv1_1_server_method wolfTLSv1_1_server_method -#define CyaTLSv1_2_client_method wolfTLSv1_2_client_method -#define CyaTLSv1_2_server_method wolfTLSv1_2_server_method -#define CyaDTLSv1_2_client_method wolfDTLSv1_2_client_method -#define CyaDTLSv1_2_server_method wolfDTLSv1_2_server_method -#define CyaSSL_set_group_messages wolfSSL_set_group_messages -#define CyaSSL_set_using_nonblock wolfSSL_set_using_nonblock -#define CyaSSL_CTX_set_cipher_list wolfSSL_CTX_set_cipher_list -#define CyaSSL_CTX_set_group_messages wolfSSL_CTX_set_group_messages -#define CyaSSL_CTX_set_session_cache_mode wolfSSL_CTX_set_session_cache_mode - -/* Callbacks */ - -/* - * Empty commment denotes not listed in CyaSSL Manual - * (soon to be wolfSSL Manual) - */ - -#define CyaSSL_accept_ex wolfSSL_accept_ex -#define CyaSSL_SetIORecv wolfSSL_SetIORecv -#define CyaSSL_SetIOSend wolfSSL_SetIOSend -#define CyaSSL_connect_ex wolfSSL_connect_ex -#define CyaSSL_CTX_SetCACb wolfSSL_CTX_SetCACb -#define CyaSSL_SetIOReadCtx wolfSSL_SetIOReadCtx -#define CyaSSL_SetRsaEncCtx wolfSSL_SetRsaEncCtx -#define CyaSSL_GetRsaEncCtx wolfSSL_GetRsaEncCtx -#define CyaSSL_SetRsaDecCtx wolfSSL_SetRsaDecCtx -#define CyaSSL_GetRsaDecCtx wolfSSL_GetRsaDecCtx -#define CyaSSL_SetLoggingCb wolfSSL_SetLoggingCb -#define CyaSSL_SetEccSignCtx wolfSSL_SetEccSignCtx -#define CyaSSL_GetEccSignCtx wolfSSL_GetEccSignCtx -#define CyaSSL_SetRsaSignCtx wolfSSL_SetRsaSignCtx -#define CyaSSL_GetRsaSignCtx wolfSSL_GetRsaSignCtx -#define CyaSSL_SetIOWriteCtx wolfSSL_SetIOWriteCtx -#define CyaSSL_SetIOReadFlags wolfSSL_SetIOReadFlags -#define CyaSSL_SetEccVerifyCtx wolfSSL_SetEccVerifyCtx -#define CyaSSL_GetEccVerifyCtx wolfSSL_GetEccVerifyCtx -#define CyaSSL_SetRsaVerifyCtx wolfSSL_SetRsaVerifyCtx -#define CyaSSL_GetRsaVerifyCtx wolfSSL_GetRsaVerifyCtx -#define CyaSSL_CTX_SetRsaEncCb wolfSSL_CTX_SetRsaEncCb -#define CyaSSL_CTX_SetRsaDecCb wolfSSL_CTX_SetRsaDecCb -#define CyaSSL_SetIOWriteFlags wolfSSL_SetIOWriteFlags -#define CyaSSL_SetTlsHmacInner wolfSSL_SetTlsHmacInner -#define CyaSSL_SetMacEncryptCtx wolfSSL_SetMacEncryptCtx -#define CyaSSL_GetMacEncryptCtx wolfSSL_GetMacEncryptCtx -#define CyaSSL_CTX_SetEccSignCb wolfSSL_CTX_SetEccSignCb -#define CyaSSL_CTX_SetRsaSignCb wolfSSL_CTX_SetRsaSignCb -#define CyaSSL_CTX_SetEccVerifyCb wolfSSL_CTX_SetEccVerifyCb -#define CyaSSL_CTX_SetRsaVerifyCb wolfSSL_CTX_SetRsaVerifyCb -#define CyaSSL_CTX_SetMacEncryptCb wolfSSL_CTX_SetMacEncryptCb -#define CyaSSL_SetDecryptVerifyCtx wolfSSL_SetDecryptVerifyCtx -#define CyaSSL_GetDecryptVerifyCtx wolfSSL_GetDecryptVerifyCtx -#define CyaSSL_CTX_SetDecryptVerifyCb wolfSSL_CTX_SetDecryptVerifyCb - -/* psk specific */ -#ifndef NO_PSK - -#define CyaSSL_get_psk_identity wolfSSL_get_psk_identity /**/ -#define CyaSSL_get_psk_identity_hint wolfSSL_get_psk_identity_hint /**/ -#define CyaSSL_use_psk_identity_hint wolfSSL_use_psk_identity_hint /**/ -#define CyaSSL_set_psk_client_callback wolfSSL_set_psk_client_callback /**/ -#define CyaSSL_set_psk_server_callback wolfSSL_set_psk_server_callback /**/ -#define CyaSSL_CTX_use_psk_identity_hint wolfSSL_CTX_use_psk_identity_hint /**/ -#define CyaSSL_CTX_set_psk_client_callback \ - wolfSSL_CTX_set_psk_client_callback /**/ -#define CyaSSL_CTX_set_psk_server_callback \ - wolfSSL_CTX_set_psk_server_callback /**/ - -#endif -/* end psk specific */ - -/* Anonymous */ -#define CyaSSL_CTX_allow_anon_cipher wolfSSL_CTX_allow_anon_cipher /**/ - -/* Error Handling and Debugging*/ -#define CyaSSL_get_error wolfSSL_get_error -#define CyaSSL_want_read wolfSSL_want_read -#define CyaSSL_want_write wolfSSL_want_write -#define CyaSSL_Debugging_ON wolfSSL_Debugging_ON -#define CyaSSL_Debugging_OFF wolfSSL_Debugging_OFF -#define CyaSSL_ERR_error_string wolfSSL_ERR_error_string -#define CyaSSL_load_error_strings wolfSSL_load_error_strings -#define CyaSSL_ERR_error_string_n wolfSSL_ERR_error_string_n -#define CyaSSL_ERR_print_errors_fp wolfSSL_ERR_print_errors_fp - -/* OCSP and CRL */ - -/* - * Empty commment denotes not listed in CyaSSL Manual - * (soon to be wolfSSL Manual) - */ - -#define CYASSL_CRL_MONITOR WOLFSSL_CRL_MONITOR /**/ -#define CYASSL_CRL_START_MON WOLFSSL_CRL_START_MON /**/ -#define CYASSL_OCSP_NO_NONCE WOLFSSL_OCSP_NO_NONCE /**/ -#define CYASSL_OCSP_URL_OVERRIDE WOLFSSL_OCSP_URL_OVERRIDE -#define CYASSL_OCSP_CHECKALL WOLFSSL_OCSP_CHECKALL - -#define CyaSSL_CTX_EnableOCSP wolfSSL_CTX_EnableOCSP -#define CyaSSL_CTX_OCSP_set_options wolfSSL_CTX_OCSP_set_options /**/ -#define CyaSSL_CTX_SetOCSP_OverrideURL wolfSSL_CTX_SetOCSP_OverrideURL /**/ -#define CyaSSL_CTX_OCSP_set_override_url wolfSSL_CTX_OCSP_set_override_url /**/ - -/* Informational */ -#define CyaSSL_GetSide wolfSSL_GetSide -#define CyaSSL_IsTLSv1_1 wolfSSL_IsTLSv1_1 -#define CyaSSL_GetKeySize wolfSSL_GetKeySize -#define CyaSSL_GetHmacSize wolfSSL_GetHmacSize -#define CyaSSL_GetHmacType wolfSSL_GetHmacType -#define CyaSSL_GetMacSecret wolfSSL_GetMacSecret -#define CyaSSL_GetObjectSize wolfSSL_GetObjectSize -#define CyaSSL_GetBulkCipher wolfSSL_GetBulkCipher -#define CyaSSL_GetCipherType wolfSSL_GetCipherType -#define CyaSSL_GetAeadMacSize wolfSSL_GetAeadMacSize -#define CyaSSL_GetClientWriteIV wolfSSL_GetClientWriteIV -#define CyaSSL_GetServerWriteIV wolfSSL_GetServerWriteIV -#define CyaSSL_GetClientWriteKey wolfSSL_GetClientWriteKey -#define CyaSSL_GetServerWriteKey wolfSSL_GetServerWriteKey -#define CyaSSL_GetCipherBlockSize wolfSSL_GetCipherBlockSize - -/* Connection, Session, and I/O */ -#define CyaSSL_peek wolfSSL_peek -#define CyaSSL_read wolfSSL_read -#define CyaSSL_recv wolfSSL_recv -#define CyaSSL_send wolfSSL_send -#define CyaSSL_write wolfSSL_write -#define CyaSSL_writev wolfSSL_writev -#define CyaSSL_accept wolfSSL_accept -#define CyaSSL_get_fd wolfSSL_get_fd -#define CyaSSL_connect wolfSSL_connect -#define CyaSSL_pending wolfSSL_pending -#define CyaSSL_negotiate wolfSSL_negotiate -#define CyaSSL_get_session wolfSSL_get_session -#define CyaSSL_connect_cert wolfSSL_connect_cert -#define CyaSSL_flush_sessions wolfSSL_flush_sessions -#define CyaSSL_get_using_nonblock wolfSSL_get_using_nonblock -#define CyaSSL_PrintSessionStats wolfSSL_PrintSessionStats - -/* DTLS Specific */ -#define CyaSSL_dtls wolfSSL_dtls -#define CyaSSL_dtls_set_peer wolfSSL_dtls_set_peer -#define CyaSSL_dtls_get_peer wolfSSL_dtls_get_peer -#define CyaSSL_dtls_got_timeout wolfSSL_dtls_got_timeout -#define CyaSSL_dtls_get_current_timeout wolfSSL_dtls_get_current_timeout - -/* Certificate Manager */ -#define CyaSSL_CertManagerNew wolfSSL_CertManagerNew -#define CyaSSL_CertManagerFree wolfSSL_CertManagerFree -#define CyaSSL_CertManagerLoadCA wolfSSL_CertManagerLoadCA -#define CyaSSL_CertManagerVerify wolfSSL_CertManagerVerify -#define CyaSSL_CertManagerEnableCRL wolfSSL_CertManagerEnableCRL -#define CyaSSL_CertManagerDisableCRL wolfSSL_CertManagerDisableCRL -#define CyaSSL_CertManagerVerifyBuffer wolfSSL_CertManagerVerifyBuffer -#ifndef NO_CERTS - #define CyaSSL_CertManagerCheckCRL wolfSSL_CertManagerCheckCRL - #define CyaSSL_CertManagerLoadCRL wolfSSL_CertManagerLoadCRL - #define CyaSSL_CertManagerSetCRL_Cb wolfSSL_CertManagerSetCRL_Cb - #define CyaSSL_CertManagerCheckOCSP wolfSSL_CertManagerCheckOCSP - #define CyaSSL_CertManagerSetOCSP_Cb wolfSSL_CertManagerSetOCSP_Cb - #define CyaSSL_CertManagerSetOCSPOverrideURL \ - wolfSSL_CertManagerSetOCSPOverrideURL - - #define CyaSSL_DisableCRL wolfSSL_DisableCRL - #define CyaSSL_EnableOCSP wolfSSL_EnableOCSP - #define CyaSSL_DisableOCSP wolfSSL_DisableOCSP - #define CyaSSL_SetOCSP_OverrideURL wolfSSL_SetOCSP_OverrideURL - #define CyaSSL_SetOCSP_Cb wolfSSL_SetOCSP_Cb - - #define CyaSSL_CTX_EnableCRL wolfSSL_CTX_EnableCRL - #define CyaSSL_CTX_DisableCRL wolfSSL_CTX_DisableCRL - #define CyaSSL_CTX_LoadCRL wolfSSL_CTX_LoadCRL - #define CyaSSL_CTX_SetCRL_Cb wolfSSL_CTX_SetCRL_Cb - #define CyaSSL_CTX_DisableOCSP wolfSSL_CTX_DisableOCSP - #define CyaSSL_CTX_SetOCSP_Cb wolfSSL_CTX_SetOCSP_Cb -#endif /* !NO_CERTS */ - - -/* OpenSSL Compatibility Layer */ -#define CyaSSL_PemCertToDer wolfSSL_PemCertToDer -#define CyaSSL_get_sessionID wolfSSL_get_sessionID -#define CyaSSL_get_peer_count wolfSSL_get_peer_count -#define CyaSSL_get_chain_cert wolfSSL_get_chain_cert -#define CyaSSL_get_peer_chain wolfSSL_get_peer_chain -#define CyaSSL_get_peer_length wolfSSL_get_peer_length -#define CyaSSL_get_chain_cert_pem wolfSSL_get_chain_cert_pem -#define CyaSSL_use_PrivateKey_file wolfSSL_use_PrivateKey_file -#define CyaSSL_use_certificate_file wolfSSL_use_certificate_file -#define CyaSSL_use_RSAPrivateKey_file wolfSSL_use_RSAPrivateKey_file -#define CyaSSL_X509_get_serial_number wolfSSL_X509_get_serial_number -#define CyaSSL_CTX_use_RSAPrivateKey_file wolfSSL_CTX_use_RSAPrivateKey_file -#define CyaSSL_use_certificate_chain_file wolfSSL_use_certificate_chain_file - -/* TLS Extensions */ -#define CYASSL_SNI_HOST_NAME WOLFSSL_SNI_HOST_NAME - -#define CyaSSL_UseSNI wolfSSL_UseSNI -#define CyaSSL_CTX_UseSNI wolfSSL_CTX_UseSNI -#define CyaSSL_SNI_SetOptions wolfSSL_SNI_SetOptions -#define CyaSSL_SNI_GetRequest wolfSSL_SNI_GetRequest -#define CyaSSL_UseMaxFragment wolfSSL_UseMaxFragment -#define CyaSSL_UseTruncatedHMAC wolfSSL_UseTruncatedHMAC -#define CyaSSL_UseSupportedCurve wolfSSL_UseSupportedCurve -#define CyaSSL_SNI_GetFromBuffer wolfSSL_SNI_GetFromBuffer -#define CyaSSL_CTX_SNI_SetOptions wolfSSL_CTX_SNI_SetOptions -#define CyaSSL_CTX_UseMaxFragment wolfSSL_CTX_UseMaxFragment -#define CyaSSL_CTX_UseTruncatedHMAC wolfSSL_CTX_UseTruncatedHMAC -#define CyaSSL_CTX_UseSupportedCurve wolfSSL_CTX_UseSupportedCurve - -/* End wolfssl -> cyassl -> openssl compatibility */ - -/* JRB macro redefinitions and api calls for cryptography for reverse compat. */ - -#ifdef WOLFSSL_SMALL_STACK - #define CYASSL_SMALL_STACK -#endif - - -/* - * wrapper around macros until they are changed in cyassl code - * needs investigation in regards to macros in fips - */ -#define NO_WOLFSSL_ALLOC_ALIGN NO_CYASSL_ALLOC_ALIGN /* @TODO */ - - -/* examples/client/client.h */ -#define CYASSL_THREAD WOLFSSL_THREAD -#ifdef WOLFSSL_DTLS - #define CYASSL_DTLS WOLFSSL_DTLS -#endif - -/* examples/client/client.c */ -#define LIBCYASSL_VERSION_STRING LIBWOLFSSL_VERSION_STRING - -#ifdef __cplusplus - } /* extern "C" */ -#endif - - -#endif /* CyaSSL_openssl_h__ */ diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/test.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/test.h deleted file mode 100755 index 428b141..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/test.h +++ /dev/null @@ -1,3 +0,0 @@ -/* test.h */ - -#include diff --git a/FreeRTOS-Plus/Source/WolfSSL/cyassl/version.h b/FreeRTOS-Plus/Source/WolfSSL/cyassl/version.h deleted file mode 100755 index 79bcc17..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/cyassl/version.h +++ /dev/null @@ -1,26 +0,0 @@ -/* cyassl/version.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#include - -#define LIBCYASSL_VERSION_STRING LIBWOLFSSL_VERSION_STRING -#define LIBCYASSL_VERSION_HEX LIBWOLFSSL_VERSION_HEX - diff --git a/FreeRTOS-Plus/Source/WolfSSL/doc/README.txt b/FreeRTOS-Plus/Source/WolfSSL/doc/README.txt deleted file mode 100755 index e969894..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/doc/README.txt +++ /dev/null @@ -1,3 +0,0 @@ -The wolfSSL manual is available at: -http://www.wolfssl.com/documentation/wolfSSL-Manual.pdf - diff --git a/FreeRTOS-Plus/Source/WolfSSL/doc/include.am b/FreeRTOS-Plus/Source/WolfSSL/doc/include.am deleted file mode 100755 index 5bef623..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/doc/include.am +++ /dev/null @@ -1,5 +0,0 @@ -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - -dist_doc_DATA+= doc/README.txt diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/client/client-ntru.vcproj b/FreeRTOS-Plus/Source/WolfSSL/examples/client/client-ntru.vcproj deleted file mode 100755 index 57eeeeb..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/client/client-ntru.vcproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.c b/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.c deleted file mode 100755 index 5838c67..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.c +++ /dev/null @@ -1,1083 +0,0 @@ -/* client.c - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#ifdef HAVE_CONFIG_H - #include -#endif - -#include - -#if defined(WOLFSSL_MDK_ARM) - #include - #include - - #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 - -#if !defined(WOLFSSL_TRACK_MEMORY) && !defined(NO_MAIN_DRIVER) - /* in case memory tracker wants stats */ - #define WOLFSSL_TRACK_MEMORY -#endif - -#include - -#include - -#include "examples/client/client.h" - - -#ifdef WOLFSSL_CALLBACKS - int handShakeCB(HandShakeInfo*); - int timeoutCB(TimeoutInfo*); - Timeval timeout; -#endif - -#ifdef HAVE_SESSION_TICKET - int sessionTicketCB(WOLFSSL*, const unsigned char*, int, void*); -#endif - - -static void NonBlockingSSL_Connect(WOLFSSL* ssl) -{ -#ifndef WOLFSSL_CALLBACKS - int ret = wolfSSL_connect(ssl); -#else - int ret = wolfSSL_connect_ex(ssl, handShakeCB, timeoutCB, timeout); -#endif - int error = wolfSSL_get_error(ssl, 0); - SOCKET_T sockfd = (SOCKET_T)wolfSSL_get_fd(ssl); - int select_ret; - - while (ret != SSL_SUCCESS && (error == SSL_ERROR_WANT_READ || - error == SSL_ERROR_WANT_WRITE)) { - int currTimeout = 1; - - if (error == SSL_ERROR_WANT_READ) - printf("... client would read block\n"); - else - printf("... client would write block\n"); - -#ifdef WOLFSSL_DTLS - currTimeout = wolfSSL_dtls_get_current_timeout(ssl); -#endif - select_ret = tcp_select(sockfd, currTimeout); - - if ((select_ret == TEST_RECV_READY) || - (select_ret == TEST_ERROR_READY)) { - #ifndef WOLFSSL_CALLBACKS - ret = wolfSSL_connect(ssl); - #else - ret = wolfSSL_connect_ex(ssl,handShakeCB,timeoutCB,timeout); - #endif - error = wolfSSL_get_error(ssl, 0); - } - else if (select_ret == TEST_TIMEOUT && !wolfSSL_dtls(ssl)) { - error = SSL_ERROR_WANT_READ; - } -#ifdef WOLFSSL_DTLS - else if (select_ret == TEST_TIMEOUT && wolfSSL_dtls(ssl) && - wolfSSL_dtls_got_timeout(ssl) >= 0) { - error = SSL_ERROR_WANT_READ; - } -#endif - else { - error = SSL_FATAL_ERROR; - } - } - if (ret != SSL_SUCCESS) - err_sys("SSL_connect failed"); -} - - -static void Usage(void) -{ - printf("client " LIBWOLFSSL_VERSION_STRING - " NOTE: All files relative to wolfSSL home dir\n"); - printf("-? Help, print this usage\n"); - printf("-h Host to connect to, default %s\n", wolfSSLIP); - printf("-p Port to connect on, not 0, default %d\n", wolfSSLPort); - printf("-v SSL version [0-3], SSLv3(0) - TLS1.2(3)), default %d\n", - CLIENT_DEFAULT_VERSION); - printf("-l Cipher list\n"); - printf("-c Certificate file, default %s\n", cliCert); - printf("-k Key file, default %s\n", cliKey); - printf("-A Certificate Authority file, default %s\n", caCert); -#ifndef NO_DH - printf("-Z Minimum DH key bits, default %d\n", - DEFAULT_MIN_DHKEY_BITS); -#endif - printf("-b Benchmark connections and print stats\n"); - printf("-s Use pre Shared keys\n"); - printf("-t Track wolfSSL memory use\n"); - printf("-d Disable peer checks\n"); - printf("-D Override Date Errors example\n"); - printf("-g Send server HTTP GET\n"); - printf("-u Use UDP DTLS," - " add -v 2 for DTLSv1 (default), -v 3 for DTLSv1.2\n"); - printf("-m Match domain name in cert\n"); - printf("-N Use Non-blocking sockets\n"); - printf("-r Resume session\n"); - printf("-w Wait for bidirectional shutdown\n"); -#ifdef HAVE_SECURE_RENEGOTIATION - printf("-R Allow Secure Renegotiation\n"); - printf("-i Force client Initiated Secure Renegotiation\n"); -#endif - printf("-f Fewer packets/group messages\n"); - printf("-x Disable client cert/key loading\n"); - printf("-X Driven by eXternal test case\n"); -#ifdef SHOW_SIZES - printf("-z Print structure sizes\n"); -#endif -#ifdef HAVE_SNI - printf("-S Use Host Name Indication\n"); -#endif -#ifdef HAVE_MAX_FRAGMENT - printf("-L Use Maximum Fragment Length [1-5]\n"); -#endif -#ifdef HAVE_TRUNCATED_HMAC - printf("-T Use Truncated HMAC\n"); -#endif -#ifdef HAVE_OCSP - printf("-o Perform OCSP lookup on peer certificate\n"); - printf("-O Perform OCSP lookup using as responder\n"); -#endif -#ifdef ATOMIC_USER - printf("-U Atomic User Record Layer Callbacks\n"); -#endif -#ifdef HAVE_PK_CALLBACKS - printf("-P Public Key Callbacks\n"); -#endif -#ifdef HAVE_ANON - printf("-a Anonymous client\n"); -#endif -#ifdef HAVE_CRL - printf("-C Disable CRL\n"); -#endif -} - -THREAD_RETURN WOLFSSL_THREAD client_test(void* args) -{ - SOCKET_T sockfd = 0; - - WOLFSSL_METHOD* method = 0; - WOLFSSL_CTX* ctx = 0; - WOLFSSL* ssl = 0; - - WOLFSSL* sslResume = 0; - WOLFSSL_SESSION* session = 0; - char resumeMsg[] = "resuming wolfssl!"; - int resumeSz = sizeof(resumeMsg); - - char msg[32] = "hello wolfssl!"; /* GET may make bigger */ - char reply[80]; - int input; - int msgSz = (int)strlen(msg); - - word16 port = wolfSSLPort; - char* host = (char*)wolfSSLIP; - const char* domain = "www.wolfssl.com"; - - int ch; - int version = CLIENT_INVALID_VERSION; - int usePsk = 0; - int useAnon = 0; - int sendGET = 0; - int benchmark = 0; - int doDTLS = 0; - int matchName = 0; - int doPeerCheck = 1; - int nonBlocking = 0; - int resumeSession = 0; - int wc_shutdown = 0; - int disableCRL = 0; - int externalTest = 0; - int ret; - int scr = 0; /* allow secure renegotiation */ - int forceScr = 0; /* force client initiaed scr */ - int trackMemory = 0; - int useClientCert = 1; - int fewerPackets = 0; - int atomicUser = 0; - int pkCallbacks = 0; - int overrideDateErrors = 0; - int minDhKeyBits = DEFAULT_MIN_DHKEY_BITS; - char* cipherList = NULL; - const char* verifyCert = caCert; - const char* ourCert = cliCert; - const char* ourKey = cliKey; - -#ifdef HAVE_SNI - char* sniHostName = NULL; -#endif -#ifdef HAVE_MAX_FRAGMENT - byte maxFragment = 0; -#endif -#ifdef HAVE_TRUNCATED_HMAC - byte truncatedHMAC = 0; -#endif - - -#ifdef HAVE_OCSP - int useOcsp = 0; - char* ocspUrl = NULL; -#endif - - int argc = ((func_args*)args)->argc; - char** argv = ((func_args*)args)->argv; - - ((func_args*)args)->return_code = -1; /* error state */ - -#ifdef NO_RSA - verifyCert = (char*)eccCert; - ourCert = (char*)cliEccCert; - ourKey = (char*)cliEccKey; -#endif - (void)resumeSz; - (void)session; - (void)sslResume; - (void)trackMemory; - (void)atomicUser; - (void)pkCallbacks; - (void)scr; - (void)forceScr; - (void)ourKey; - (void)ourCert; - (void)verifyCert; - (void)useClientCert; - (void)overrideDateErrors; - (void)disableCRL; - (void)minDhKeyBits; - - StackTrap(); - - while ((ch = mygetopt(argc, argv, - "?gdDusmNrwRitfxXUPCh:p:v:l:A:c:k:Z:b:zS:L:ToO:a")) - != -1) { - switch (ch) { - case '?' : - Usage(); - exit(EXIT_SUCCESS); - - case 'g' : - sendGET = 1; - break; - - case 'd' : - doPeerCheck = 0; - break; - - case 'D' : - overrideDateErrors = 1; - break; - - case 'C' : - #ifdef HAVE_CRL - disableCRL = 1; - #endif - break; - - case 'u' : - doDTLS = 1; - break; - - case 's' : - usePsk = 1; - break; - - case 't' : - #ifdef USE_WOLFSSL_MEMORY - trackMemory = 1; - #endif - break; - - case 'm' : - matchName = 1; - break; - - case 'x' : - useClientCert = 0; - break; - - case 'X' : - externalTest = 1; - break; - - case 'f' : - fewerPackets = 1; - break; - - case 'U' : - #ifdef ATOMIC_USER - atomicUser = 1; - #endif - break; - - case 'P' : - #ifdef HAVE_PK_CALLBACKS - pkCallbacks = 1; - #endif - break; - - case 'h' : - host = myoptarg; - domain = myoptarg; - break; - - case 'p' : - port = (word16)atoi(myoptarg); - #if !defined(NO_MAIN_DRIVER) || defined(USE_WINDOWS_API) - if (port == 0) - err_sys("port number cannot be 0"); - #endif - break; - - case 'v' : - version = atoi(myoptarg); - if (version < 0 || version > 3) { - Usage(); - exit(MY_EX_USAGE); - } - break; - - case 'l' : - cipherList = myoptarg; - break; - - case 'A' : - verifyCert = myoptarg; - break; - - case 'c' : - ourCert = myoptarg; - break; - - case 'k' : - ourKey = myoptarg; - break; - - case 'Z' : - #ifndef NO_DH - minDhKeyBits = atoi(myoptarg); - if (minDhKeyBits <= 0 || minDhKeyBits > 16000) { - Usage(); - exit(MY_EX_USAGE); - } - #endif - break; - - case 'b' : - benchmark = atoi(myoptarg); - if (benchmark < 0 || benchmark > 1000000) { - Usage(); - exit(MY_EX_USAGE); - } - break; - - case 'N' : - nonBlocking = 1; - break; - - case 'r' : - resumeSession = 1; - break; - - case 'w' : - wc_shutdown = 1; - break; - - case 'R' : - #ifdef HAVE_SECURE_RENEGOTIATION - scr = 1; - #endif - break; - - case 'i' : - #ifdef HAVE_SECURE_RENEGOTIATION - scr = 1; - forceScr = 1; - #endif - break; - - case 'z' : - #ifndef WOLFSSL_LEANPSK - wolfSSL_GetObjectSize(); - #endif - break; - - case 'S' : - #ifdef HAVE_SNI - sniHostName = myoptarg; - #endif - break; - - case 'L' : - #ifdef HAVE_MAX_FRAGMENT - maxFragment = atoi(myoptarg); - if (maxFragment < WOLFSSL_MFL_2_9 || - maxFragment > WOLFSSL_MFL_2_13) { - Usage(); - exit(MY_EX_USAGE); - } - #endif - break; - - case 'T' : - #ifdef HAVE_TRUNCATED_HMAC - truncatedHMAC = 1; - #endif - break; - - case 'o' : - #ifdef HAVE_OCSP - useOcsp = 1; - #endif - break; - - case 'O' : - #ifdef HAVE_OCSP - useOcsp = 1; - ocspUrl = myoptarg; - #endif - break; - - case 'a' : - #ifdef HAVE_ANON - useAnon = 1; - #endif - break; - - default: - Usage(); - exit(MY_EX_USAGE); - } - } - - myoptind = 0; /* reset for test cases */ - - if (externalTest) { - /* detect build cases that wouldn't allow test against wolfssl.com */ - int done = 0; - (void)done; - - #ifdef NO_RSA - done = 1; - #endif - - #ifndef NO_PSK - done = 1; - #endif - - #ifdef NO_SHA - done = 1; /* external cert chain most likely has SHA */ - #endif - - if (done) { - printf("external test can't be run in this mode"); - - ((func_args*)args)->return_code = 0; - exit(EXIT_SUCCESS); - } - } - - /* sort out DTLS versus TLS versions */ - if (version == CLIENT_INVALID_VERSION) { - if (doDTLS) - version = CLIENT_DTLS_DEFAULT_VERSION; - else - version = CLIENT_DEFAULT_VERSION; - } - else { - if (doDTLS) { - if (version == 3) - version = -2; - else - version = -1; - } - } - -#ifdef USE_WOLFSSL_MEMORY - if (trackMemory) - InitMemoryTracker(); -#endif - - switch (version) { -#ifndef NO_OLD_TLS - case 0: - method = wolfSSLv3_client_method(); - break; - - - #ifndef NO_TLS - case 1: - method = wolfTLSv1_client_method(); - break; - - case 2: - method = wolfTLSv1_1_client_method(); - break; - #endif /* NO_TLS */ - -#endif /* NO_OLD_TLS */ - -#ifndef NO_TLS - case 3: - method = wolfTLSv1_2_client_method(); - break; -#endif - -#ifdef WOLFSSL_DTLS - #ifndef NO_OLD_TLS - case -1: - method = wolfDTLSv1_client_method(); - break; - #endif - - case -2: - method = wolfDTLSv1_2_client_method(); - break; -#endif - - default: - err_sys("Bad SSL version"); - break; - } - - if (method == NULL) - err_sys("unable to get method"); - - ctx = wolfSSL_CTX_new(method); - if (ctx == NULL) - err_sys("unable to get ctx"); - - if (cipherList) - if (wolfSSL_CTX_set_cipher_list(ctx, cipherList) != SSL_SUCCESS) - err_sys("client can't set cipher list 1"); - -#ifdef WOLFSSL_LEANPSK - usePsk = 1; -#endif - -#if defined(NO_RSA) && !defined(HAVE_ECC) - usePsk = 1; -#endif - - if (fewerPackets) - wolfSSL_CTX_set_group_messages(ctx); - -#ifndef NO_DH - wolfSSL_CTX_SetMinDhKey_Sz(ctx, (word16)minDhKeyBits); -#endif - - if (usePsk) { -#ifndef NO_PSK - wolfSSL_CTX_set_psk_client_callback(ctx, my_psk_client_cb); - if (cipherList == NULL) { - const char *defaultCipherList; - #if defined(HAVE_AESGCM) && !defined(NO_DH) - defaultCipherList = "DHE-PSK-AES128-GCM-SHA256"; - #elif defined(HAVE_NULL_CIPHER) - defaultCipherList = "PSK-NULL-SHA256"; - #else - defaultCipherList = "PSK-AES128-CBC-SHA256"; - #endif - if (wolfSSL_CTX_set_cipher_list(ctx,defaultCipherList) - !=SSL_SUCCESS) - err_sys("client can't set cipher list 2"); - } -#endif - useClientCert = 0; - } - - if (useAnon) { -#ifdef HAVE_ANON - if (cipherList == NULL) { - wolfSSL_CTX_allow_anon_cipher(ctx); - if (wolfSSL_CTX_set_cipher_list(ctx,"ADH-AES128-SHA") != SSL_SUCCESS) - err_sys("client can't set cipher list 4"); - } -#endif - useClientCert = 0; - } - -#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) - wolfSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack); -#endif - -#if defined(WOLFSSL_SNIFFER) - if (cipherList == NULL) { - /* don't use EDH, can't sniff tmp keys */ - if (wolfSSL_CTX_set_cipher_list(ctx, "AES256-SHA256") != SSL_SUCCESS) { - err_sys("client can't set cipher list 3"); - } - } -#endif - -#ifdef HAVE_OCSP - if (useOcsp) { - if (ocspUrl != NULL) { - wolfSSL_CTX_SetOCSP_OverrideURL(ctx, ocspUrl); - wolfSSL_CTX_EnableOCSP(ctx, WOLFSSL_OCSP_NO_NONCE - | WOLFSSL_OCSP_URL_OVERRIDE); - } - else - wolfSSL_CTX_EnableOCSP(ctx, WOLFSSL_OCSP_NO_NONCE); - } -#endif - -#ifdef USER_CA_CB - wolfSSL_CTX_SetCACb(ctx, CaCb); -#endif - -#ifdef VERIFY_CALLBACK - wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, myVerify); -#endif -#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) - if (useClientCert){ - if (wolfSSL_CTX_use_certificate_chain_file(ctx, ourCert) != SSL_SUCCESS) - err_sys("can't load client cert file, check file and run from" - " wolfSSL home dir"); - - if (wolfSSL_CTX_use_PrivateKey_file(ctx, ourKey, SSL_FILETYPE_PEM) - != SSL_SUCCESS) - err_sys("can't load client private key file, check file and run " - "from wolfSSL home dir"); - } - - if (!usePsk && !useAnon) { - if (wolfSSL_CTX_load_verify_locations(ctx, verifyCert,0) != SSL_SUCCESS) - err_sys("can't load ca file, Please run from wolfSSL home dir"); -#ifdef HAVE_ECC - /* load ecc verify too, echoserver uses it by default w/ ecc */ - if (wolfSSL_CTX_load_verify_locations(ctx, eccCert, 0) != SSL_SUCCESS) - err_sys("can't load ecc ca file, Please run from wolfSSL home dir"); -#endif /* HAVE_ECC */ - } -#endif /* !NO_FILESYSTEM && !NO_CERTS */ -#if !defined(NO_CERTS) - if (!usePsk && !useAnon && doPeerCheck == 0) - wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0); - if (!usePsk && !useAnon && overrideDateErrors == 1) - wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, myDateCb); -#endif - -#ifdef HAVE_CAVIUM - wolfSSL_CTX_UseCavium(ctx, CAVIUM_DEV_ID); -#endif - -#ifdef HAVE_SNI - if (sniHostName) - if (wolfSSL_CTX_UseSNI(ctx, 0, sniHostName, XSTRLEN(sniHostName)) - != SSL_SUCCESS) - err_sys("UseSNI failed"); -#endif -#ifdef HAVE_MAX_FRAGMENT - if (maxFragment) - if (wolfSSL_CTX_UseMaxFragment(ctx, maxFragment) != SSL_SUCCESS) - err_sys("UseMaxFragment failed"); -#endif -#ifdef HAVE_TRUNCATED_HMAC - if (truncatedHMAC) - if (wolfSSL_CTX_UseTruncatedHMAC(ctx) != SSL_SUCCESS) - err_sys("UseTruncatedHMAC failed"); -#endif -#ifdef HAVE_SESSION_TICKET - if (wolfSSL_CTX_UseSessionTicket(ctx) != SSL_SUCCESS) - err_sys("UseSessionTicket failed"); -#endif - - if (benchmark) { - /* time passed in number of connects give average */ - int times = benchmark; - int loops = resumeSession ? 2 : 1; - int i = 0; - WOLFSSL_SESSION* benchSession = NULL; - - while (loops--) { - int benchResume = resumeSession && loops == 0; - double start = current_time(), avg; - - for (i = 0; i < times; i++) { - tcp_connect(&sockfd, host, port, doDTLS); - - ssl = wolfSSL_new(ctx); - if (benchResume) - wolfSSL_set_session(ssl, benchSession); - wolfSSL_set_fd(ssl, sockfd); - if (wolfSSL_connect(ssl) != SSL_SUCCESS) - err_sys("SSL_connect failed"); - - wolfSSL_shutdown(ssl); - if (i == (times-1) && resumeSession) { - benchSession = wolfSSL_get_session(ssl); - } - wolfSSL_free(ssl); - CloseSocket(sockfd); - } - avg = current_time() - start; - avg /= times; - avg *= 1000; /* milliseconds */ - if (benchResume) - printf("wolfSSL_resume avg took: %8.3f milliseconds\n", avg); - else - printf("wolfSSL_connect avg took: %8.3f milliseconds\n", avg); - } - - wolfSSL_CTX_free(ctx); - ((func_args*)args)->return_code = 0; - - exit(EXIT_SUCCESS); - } - - #if defined(WOLFSSL_MDK_ARM) - wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0); - #endif - - ssl = wolfSSL_new(ctx); - if (ssl == NULL) - err_sys("unable to get SSL object"); - #ifdef HAVE_SESSION_TICKET - wolfSSL_set_SessionTicket_cb(ssl, sessionTicketCB, (void*)"initial session"); - #endif - if (doDTLS) { - SOCKADDR_IN_T addr; - build_addr(&addr, host, port, 1); - wolfSSL_dtls_set_peer(ssl, &addr, sizeof(addr)); - tcp_socket(&sockfd, 1); - } - else { - tcp_connect(&sockfd, host, port, 0); - } - -#ifdef HAVE_POLY1305 - /* use old poly to connect with google server */ - if (!XSTRNCMP(domain, "www.google.com", 14)) { - if (wolfSSL_use_old_poly(ssl, 1) != 0) - err_sys("unable to set to old poly"); - } -#endif - - wolfSSL_set_fd(ssl, sockfd); -#ifdef HAVE_CRL - if (disableCRL == 0) { - if (wolfSSL_EnableCRL(ssl, WOLFSSL_CRL_CHECKALL) != SSL_SUCCESS) - err_sys("can't enable crl check"); - if (wolfSSL_LoadCRL(ssl, crlPemDir, SSL_FILETYPE_PEM, 0) != SSL_SUCCESS) - err_sys("can't load crl, check crlfile and date validity"); - if (wolfSSL_SetCRL_Cb(ssl, CRL_CallBack) != SSL_SUCCESS) - err_sys("can't set crl callback"); - } -#endif -#ifdef HAVE_SECURE_RENEGOTIATION - if (scr) { - if (wolfSSL_UseSecureRenegotiation(ssl) != SSL_SUCCESS) - err_sys("can't enable secure renegotiation"); - } -#endif -#ifdef ATOMIC_USER - if (atomicUser) - SetupAtomicUser(ctx, ssl); -#endif -#ifdef HAVE_PK_CALLBACKS - if (pkCallbacks) - SetupPkCallbacks(ctx, ssl); -#endif - if (matchName && doPeerCheck) - wolfSSL_check_domain_name(ssl, domain); -#ifndef WOLFSSL_CALLBACKS - if (nonBlocking) { - wolfSSL_set_using_nonblock(ssl, 1); - tcp_set_nonblocking(&sockfd); - NonBlockingSSL_Connect(ssl); - } - else if (wolfSSL_connect(ssl) != SSL_SUCCESS) { - /* see note at top of README */ - int err = wolfSSL_get_error(ssl, 0); - char buffer[WOLFSSL_MAX_ERROR_SZ]; - printf("err = %d, %s\n", err, - wolfSSL_ERR_error_string(err, buffer)); - err_sys("SSL_connect failed"); - /* if you're getting an error here */ - } -#else - timeout.tv_sec = 2; - timeout.tv_usec = 0; - NonBlockingSSL_Connect(ssl); /* will keep retrying on timeout */ -#endif - showPeer(ssl); - -#ifdef HAVE_SECURE_RENEGOTIATION - if (scr && forceScr) { - if (nonBlocking) { - printf("not doing secure renegotiation on example with" - " nonblocking yet"); - } else { - if (wolfSSL_Rehandshake(ssl) != SSL_SUCCESS) { - int err = wolfSSL_get_error(ssl, 0); - char buffer[WOLFSSL_MAX_ERROR_SZ]; - printf("err = %d, %s\n", err, - wolfSSL_ERR_error_string(err, buffer)); - err_sys("wolfSSL_Rehandshake failed"); - } - } - } -#endif /* HAVE_SECURE_RENEGOTIATION */ - - if (sendGET) { - printf("SSL connect ok, sending GET...\n"); - msgSz = 28; - strncpy(msg, "GET /index.html HTTP/1.0\r\n\r\n", msgSz); - msg[msgSz] = '\0'; - } - if (wolfSSL_write(ssl, msg, msgSz) != msgSz) - err_sys("SSL_write failed"); - - input = wolfSSL_read(ssl, reply, sizeof(reply)-1); - if (input > 0) { - reply[input] = 0; - printf("Server response: %s\n", reply); - - if (sendGET) { /* get html */ - while (1) { - input = wolfSSL_read(ssl, reply, sizeof(reply)-1); - if (input > 0) { - reply[input] = 0; - printf("%s\n", reply); - } - else - break; - } - } - } - else if (input < 0) { - int readErr = wolfSSL_get_error(ssl, 0); - if (readErr != SSL_ERROR_WANT_READ) - err_sys("wolfSSL_read failed"); - } - -#ifndef NO_SESSION_CACHE - if (resumeSession) { - session = wolfSSL_get_session(ssl); - sslResume = wolfSSL_new(ctx); - } -#endif - - if (doDTLS == 0) { /* don't send alert after "break" command */ - ret = wolfSSL_shutdown(ssl); - if (wc_shutdown && ret == SSL_SHUTDOWN_NOT_DONE) - wolfSSL_shutdown(ssl); /* bidirectional shutdown */ - } -#ifdef ATOMIC_USER - if (atomicUser) - FreeAtomicUser(ssl); -#endif - wolfSSL_free(ssl); - CloseSocket(sockfd); - -#ifndef NO_SESSION_CACHE - if (resumeSession) { - if (doDTLS) { - SOCKADDR_IN_T addr; - #ifdef USE_WINDOWS_API - Sleep(500); - #elif defined(WOLFSSL_TIRTOS) - Task_sleep(1); - #else - sleep(1); - #endif - build_addr(&addr, host, port, 1); - wolfSSL_dtls_set_peer(sslResume, &addr, sizeof(addr)); - tcp_socket(&sockfd, 1); - } - else { - tcp_connect(&sockfd, host, port, 0); - } - wolfSSL_set_fd(sslResume, sockfd); -#ifdef HAVE_SECURE_RENEGOTIATION - if (scr) { - if (wolfSSL_UseSecureRenegotiation(sslResume) != SSL_SUCCESS) - err_sys("can't enable secure renegotiation"); - } -#endif - wolfSSL_set_session(sslResume, session); -#ifdef HAVE_SESSION_TICKET - wolfSSL_set_SessionTicket_cb(sslResume, sessionTicketCB, - (void*)"resumed session"); -#endif - - showPeer(sslResume); -#ifndef WOLFSSL_CALLBACKS - if (nonBlocking) { - wolfSSL_set_using_nonblock(sslResume, 1); - tcp_set_nonblocking(&sockfd); - NonBlockingSSL_Connect(sslResume); - } - else if (wolfSSL_connect(sslResume) != SSL_SUCCESS) - err_sys("SSL resume failed"); -#else - timeout.tv_sec = 2; - timeout.tv_usec = 0; - NonBlockingSSL_Connect(ssl); /* will keep retrying on timeout */ -#endif - - if (wolfSSL_session_reused(sslResume)) - printf("reused session id\n"); - else - printf("didn't reuse session id!!!\n"); - - if (wolfSSL_write(sslResume, resumeMsg, resumeSz) != resumeSz) - err_sys("SSL_write failed"); - - if (nonBlocking) { - /* give server a chance to bounce a message back to client */ - #ifdef USE_WINDOWS_API - Sleep(500); - #elif defined(WOLFSSL_TIRTOS) - Task_sleep(1); - #else - sleep(1); - #endif - } - - input = wolfSSL_read(sslResume, reply, sizeof(reply)-1); - if (input > 0) { - reply[input] = 0; - printf("Server resume response: %s\n", reply); - } - - /* try to send session break */ - wolfSSL_write(sslResume, msg, msgSz); - - ret = wolfSSL_shutdown(sslResume); - if (wc_shutdown && ret == SSL_SHUTDOWN_NOT_DONE) - wolfSSL_shutdown(sslResume); /* bidirectional shutdown */ - - wolfSSL_free(sslResume); - CloseSocket(sockfd); - } -#endif /* NO_SESSION_CACHE */ - - wolfSSL_CTX_free(ctx); - - ((func_args*)args)->return_code = 0; - -#ifdef USE_WOLFSSL_MEMORY - if (trackMemory) - ShowMemoryTracker(); -#endif /* USE_WOLFSSL_MEMORY */ - -#if !defined(WOLFSSL_TIRTOS) - return 0; -#endif -} - - -/* so overall tests can pull in test function */ -#ifndef NO_MAIN_DRIVER - - int main(int argc, char** argv) - { - func_args args; - -#ifdef HAVE_CAVIUM - int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID); - if (ret != 0) - err_sys("Cavium OpenNitroxDevice failed"); -#endif /* HAVE_CAVIUM */ - - StartTCP(); - - args.argc = argc; - args.argv = argv; - - wolfSSL_Init(); -#if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_MDK_SHELL) && !defined(STACK_TRAP) - wolfSSL_Debugging_ON(); -#endif - if (CurrentDir("_build")) - ChangeDirBack(1); - else if (CurrentDir("client")) - ChangeDirBack(2); - else if (CurrentDir("Debug") || CurrentDir("Release")) - ChangeDirBack(3); - -#ifdef HAVE_STACK_SIZE - StackSizeCheck(&args, client_test); -#else - client_test(&args); -#endif - wolfSSL_Cleanup(); - -#ifdef HAVE_CAVIUM - CspShutdown(CAVIUM_DEV_ID); -#endif - return args.return_code; - } - - int myoptind = 0; - char* myoptarg = NULL; - -#endif /* NO_MAIN_DRIVER */ - - - -#ifdef WOLFSSL_CALLBACKS - - int handShakeCB(HandShakeInfo* info) - { - (void)info; - return 0; - } - - - int timeoutCB(TimeoutInfo* info) - { - (void)info; - return 0; - } - -#endif - - -#ifdef HAVE_SESSION_TICKET - - int sessionTicketCB(WOLFSSL* ssl, - const unsigned char* ticket, int ticketSz, - void* ctx) - { - (void)ssl; - (void)ticket; - printf("Session Ticket CB: ticketSz = %d, ctx = %s\n", - ticketSz, (char*)ctx); - return 0; - } - -#endif - diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.h b/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.h deleted file mode 100755 index e4b13be..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.h +++ /dev/null @@ -1,25 +0,0 @@ -/* client.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#pragma once - -THREAD_RETURN WOLFSSL_THREAD client_test(void* args); - diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.sln b/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.sln deleted file mode 100755 index 3c4bbb1..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "client.vcproj", "{F117DD21-2672-4001-9FF8-8DBEBBFCA380}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F117DD21-2672-4001-9FF8-8DBEBBFCA380}.Debug|Win32.ActiveCfg = Debug|Win32 - {F117DD21-2672-4001-9FF8-8DBEBBFCA380}.Debug|Win32.Build.0 = Debug|Win32 - {F117DD21-2672-4001-9FF8-8DBEBBFCA380}.Release|Win32.ActiveCfg = Release|Win32 - {F117DD21-2672-4001-9FF8-8DBEBBFCA380}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.vcproj b/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.vcproj deleted file mode 100755 index 98c2883..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.vcproj +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.vcxproj b/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.vcxproj deleted file mode 100755 index dec191d..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/client/client.vcxproj +++ /dev/null @@ -1,332 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - DLL Debug - Win32 - - - DLL Debug - x64 - - - DLL Release - Win32 - - - DLL Release - x64 - - - Release - Win32 - - - Release - x64 - - - - {3ADE9549-582D-4D8E-9826-B172197A7959} - client - Win32Proj - - - - Application - v110 - Unicode - true - - - Application - v110 - Unicode - true - - - Application - v110 - Unicode - true - - - Application - v110 - Unicode - true - - - Application - v110 - Unicode - - - Application - v110 - Unicode - - - Application - v110 - Unicode - - - Application - v110 - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>11.0.61030.0 - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\obj\ - true - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\obj\ - true - - - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\obj\ - - - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\obj\ - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\obj\ - false - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\obj\ - false - - - false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\obj\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\obj\ - - - - Disabled - ../../;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - Level3 - EditAndContinue - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - MachineX86 - false - - - - - Disabled - ../../;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - MachineX86 - - - - - Disabled - ../../;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - - - - - Disabled - ../../;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - - - - - MaxSpeed - true - ../../;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - Level3 - ProgramDatabase - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - true - true - MachineX86 - false - - - - - MaxSpeed - true - ../../;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - true - true - MachineX86 - - - - - MaxSpeed - true - ../../;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - true - true - - - - - MaxSpeed - true - ../../;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - true - true - - - - - - - - {73973223-5ee8-41ca-8e88-1d60e89a237b} - false - - - - - - diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/client/include.am b/FreeRTOS-Plus/Source/WolfSSL/examples/client/include.am deleted file mode 100755 index d0ddcdf..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/client/include.am +++ /dev/null @@ -1,17 +0,0 @@ -# vim:ft=automake -# All paths should be given relative to the root - -if BUILD_EXAMPLES -noinst_PROGRAMS += examples/client/client -noinst_HEADERS += examples/client/client.h -examples_client_client_SOURCES = examples/client/client.c -examples_client_client_LDADD = src/libwolfssl.la -examples_client_client_DEPENDENCIES = src/libwolfssl.la -endif -EXTRA_DIST += examples/client/client.sln -EXTRA_DIST += examples/client/client-ntru.vcproj -EXTRA_DIST += examples/client/client.vcproj -EXTRA_DIST += examples/client/client.vcxproj - -dist_example_DATA+= examples/client/client.c -DISTCLEANFILES+= examples/client/.libs/client diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient-ntru.vcproj b/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient-ntru.vcproj deleted file mode 100755 index 4453f3d..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient-ntru.vcproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.c b/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.c deleted file mode 100755 index 594d146..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.c +++ /dev/null @@ -1,284 +0,0 @@ -/* echoclient.c - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#ifdef HAVE_CONFIG_H - #include -#endif - -#include - -/* let's use cyassl layer AND cyassl openssl layer */ -#include -#include - -#if defined(CYASSL_MDK_ARM) - #include - #include - - #if defined(CYASSL_MDK5) - #include "cmsis_os.h" - #include "rl_fs.h" - #include "rl_net.h" - #else - #include "rtl.h" - #endif - - #include "cyassl_MDK_ARM.h" -#endif - -#include - -#include "examples/echoclient/echoclient.h" - -void echoclient_test(void* args) -{ - SOCKET_T sockfd = 0; - - FILE* fin = stdin ; - FILE* fout = stdout; - - int inCreated = 0; - int outCreated = 0; - - char msg[1024]; - char reply[1024+1]; - - SSL_METHOD* method = 0; - SSL_CTX* ctx = 0; - SSL* ssl = 0; - - int doDTLS = 0; - int doPSK = 0; - int sendSz; - int argc = 0; - char** argv = 0; - word16 port = yasslPort; - - ((func_args*)args)->return_code = -1; /* error state */ - -#ifndef CYASSL_MDK_SHELL - argc = ((func_args*)args)->argc; - argv = ((func_args*)args)->argv; -#endif - - if (argc >= 2) { - fin = fopen(argv[1], "r"); - inCreated = 1; - } - if (argc >= 3) { - fout = fopen(argv[2], "w"); - outCreated = 1; - } - - if (!fin) err_sys("can't open input file"); - if (!fout) err_sys("can't open output file"); - -#ifdef CYASSL_DTLS - doDTLS = 1; -#endif - -#ifdef CYASSL_LEANPSK - doPSK = 1; -#endif - -#if defined(NO_RSA) && !defined(HAVE_ECC) - doPSK = 1; -#endif - -#if defined(NO_MAIN_DRIVER) && !defined(USE_WINDOWS_API) && !defined(CYASSL_MDK_SHELL) - port = ((func_args*)args)->signal->port; -#endif - -#if defined(CYASSL_DTLS) - method = DTLSv1_2_client_method(); -#elif !defined(NO_TLS) - method = CyaSSLv23_client_method(); -#else - method = SSLv3_client_method(); -#endif - ctx = SSL_CTX_new(method); - -#ifndef NO_FILESYSTEM - #ifndef NO_RSA - if (SSL_CTX_load_verify_locations(ctx, caCert, 0) != SSL_SUCCESS) - err_sys("can't load ca file, Please run from wolfSSL home dir"); - #endif - #ifdef HAVE_ECC - if (SSL_CTX_load_verify_locations(ctx, eccCert, 0) != SSL_SUCCESS) - err_sys("can't load ca file, Please run from wolfSSL home dir"); - #endif -#elif !defined(NO_CERTS) - if (!doPSK) - load_buffer(ctx, caCert, CYASSL_CA); -#endif - -#if defined(CYASSL_SNIFFER) - /* don't use EDH, can't sniff tmp keys */ - SSL_CTX_set_cipher_list(ctx, "AES256-SHA"); -#endif - if (doPSK) { -#ifndef NO_PSK - const char *defaultCipherList; - - CyaSSL_CTX_set_psk_client_callback(ctx, my_psk_client_cb); - #ifdef HAVE_NULL_CIPHER - defaultCipherList = "PSK-NULL-SHA256"; - #else - defaultCipherList = "PSK-AES128-CBC-SHA256"; - #endif - if (CyaSSL_CTX_set_cipher_list(ctx,defaultCipherList) !=SSL_SUCCESS) - err_sys("client can't set cipher list 2"); -#endif - } - -#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) - SSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack); -#endif - - #if defined(CYASSL_MDK_ARM) - CyaSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0); - #endif - - ssl = SSL_new(ctx); - - if (doDTLS) { - SOCKADDR_IN_T addr; - build_addr(&addr, yasslIP, port, 1); - CyaSSL_dtls_set_peer(ssl, &addr, sizeof(addr)); - tcp_socket(&sockfd, 1); - } - else { - tcp_connect(&sockfd, yasslIP, port, 0); - } - - SSL_set_fd(ssl, sockfd); -#if defined(USE_WINDOWS_API) && defined(CYASSL_DTLS) && defined(NO_MAIN_DRIVER) - /* let echoserver bind first, TODO: add Windows signal like pthreads does */ - Sleep(100); -#endif - - if (SSL_connect(ssl) != SSL_SUCCESS) err_sys("SSL_connect failed"); - - while (fgets(msg, sizeof(msg), fin) != 0) { - - sendSz = (int)strlen(msg); - - if (SSL_write(ssl, msg, sendSz) != sendSz) - err_sys("SSL_write failed"); - - if (strncmp(msg, "quit", 4) == 0) { - fputs("sending server shutdown command: quit!\n", fout); - break; - } - - if (strncmp(msg, "break", 5) == 0) { - fputs("sending server session close: break!\n", fout); - break; - } - - #ifndef CYASSL_MDK_SHELL - while (sendSz) { - int got; - if ( (got = SSL_read(ssl, reply, sizeof(reply)-1)) > 0) { - reply[got] = 0; - fputs(reply, fout); - fflush(fout) ; - sendSz -= got; - } - else - break; - } - #else - { - int got; - if ( (got = SSL_read(ssl, reply, sizeof(reply)-1)) > 0) { - reply[got] = 0; - fputs(reply, fout); - fflush(fout) ; - sendSz -= got; - } - } - #endif - } - - -#ifdef CYASSL_DTLS - strncpy(msg, "break", 6); - sendSz = (int)strlen(msg); - /* try to tell server done */ - SSL_write(ssl, msg, sendSz); -#else - SSL_shutdown(ssl); -#endif - - SSL_free(ssl); - SSL_CTX_free(ctx); - - fflush(fout); - if (inCreated) fclose(fin); - if (outCreated) fclose(fout); - - CloseSocket(sockfd); - ((func_args*)args)->return_code = 0; -} - - -/* so overall tests can pull in test function */ -#ifndef NO_MAIN_DRIVER - - int main(int argc, char** argv) - { - func_args args; - -#ifdef HAVE_CAVIUM - int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID); - if (ret != 0) - err_sys("Cavium OpenNitroxDevice failed"); -#endif /* HAVE_CAVIUM */ - - StartTCP(); - - args.argc = argc; - args.argv = argv; - - CyaSSL_Init(); -#if defined(DEBUG_CYASSL) && !defined(CYASSL_MDK_SHELL) - CyaSSL_Debugging_ON(); -#endif -#ifndef CYASSL_TIRTOS - if (CurrentDir("echoclient")) - ChangeDirBack(2); - else if (CurrentDir("Debug") || CurrentDir("Release")) - ChangeDirBack(3); -#endif - echoclient_test(&args); - - CyaSSL_Cleanup(); - -#ifdef HAVE_CAVIUM - CspShutdown(CAVIUM_DEV_ID); -#endif - return args.return_code; - } - -#endif /* NO_MAIN_DRIVER */ - - diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.h b/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.h deleted file mode 100755 index d945edb..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.h +++ /dev/null @@ -1,23 +0,0 @@ -/* echoclient.h - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#pragma once -void echoclient_test(void* args); diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.sln b/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.sln deleted file mode 100755 index 3fb7851..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "echoclient", "echoclient.vcproj", "{A7AA93AD-AFF0-4FF0-8AED-14685DE55CF3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A7AA93AD-AFF0-4FF0-8AED-14685DE55CF3}.Debug|Win32.ActiveCfg = Debug|Win32 - {A7AA93AD-AFF0-4FF0-8AED-14685DE55CF3}.Debug|Win32.Build.0 = Debug|Win32 - {A7AA93AD-AFF0-4FF0-8AED-14685DE55CF3}.Release|Win32.ActiveCfg = Release|Win32 - {A7AA93AD-AFF0-4FF0-8AED-14685DE55CF3}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.vcproj b/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.vcproj deleted file mode 100755 index 8ab0e28..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.vcproj +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.vcxproj b/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.vcxproj deleted file mode 100755 index a3a6054..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/echoclient.vcxproj +++ /dev/null @@ -1,334 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - DLL Debug - Win32 - - - DLL Debug - x64 - - - DLL Release - Win32 - - - DLL Release - x64 - - - Release - Win32 - - - Release - x64 - - - - {8362A816-C5DC-4E22-B5C5-9E6806387073} - echoclient - Win32Proj - - - - Application - v110 - Unicode - true - - - Application - v110 - Unicode - true - - - Application - v110 - Unicode - true - - - Application - v110 - Unicode - true - - - Application - v110 - Unicode - - - Application - v110 - Unicode - - - Application - v110 - Unicode - - - Application - v110 - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>11.0.61030.0 - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\obj\ - true - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\obj\ - true - - - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\obj\ - - - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\obj\ - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\obj\ - false - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\obj\ - false - - - false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\obj\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\obj\ - - - - Disabled - ../../;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - Level3 - EditAndContinue - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - MachineX86 - false - - - - - - Disabled - ../../;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - MachineX86 - - - - - Disabled - ../../;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - - - - - Disabled - ../../;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - - - - - MaxSpeed - true - ../../;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - Level3 - ProgramDatabase - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - true - true - MachineX86 - false - - - - - - MaxSpeed - true - ../../;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - true - true - MachineX86 - - - - - MaxSpeed - true - ../../;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - true - true - - - - - MaxSpeed - true - ../../;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - Ws2_32.lib;%(AdditionalDependencies) - true - Console - true - true - - - - - - - - {73973223-5ee8-41ca-8e88-1d60e89a237b} - false - - - - - - diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/include.am b/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/include.am deleted file mode 100755 index 179cf99..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/echoclient/include.am +++ /dev/null @@ -1,20 +0,0 @@ -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - - -if BUILD_EXAMPLES -noinst_PROGRAMS += examples/echoclient/echoclient -noinst_HEADERS += examples/echoclient/echoclient.h -examples_echoclient_echoclient_SOURCES = examples/echoclient/echoclient.c -examples_echoclient_echoclient_LDADD = src/libwolfssl.la -examples_echoclient_echoclient_DEPENDENCIES = src/libwolfssl.la -endif -EXTRA_DIST += examples/echoclient/echoclient.sln -EXTRA_DIST += examples/echoclient/echoclient-ntru.vcproj -EXTRA_DIST += examples/echoclient/echoclient.vcproj -EXTRA_DIST += examples/echoclient/echoclient.vcxproj - -dist_example_DATA+= examples/echoclient/echoclient.c -DISTCLEANFILES+= examples/echoclient/.libs/echoclient - diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver-ntru.vcproj b/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver-ntru.vcproj deleted file mode 100755 index 1bf1688..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver-ntru.vcproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.c b/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.c deleted file mode 100755 index 6b5c575..0000000 --- a/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.c +++ /dev/null @@ -1,395 +0,0 @@ -/* echoserver.c - * - * Copyright (C) 2006-2015 wolfSSL Inc. - * - * This file is part of wolfSSL. (formerly known as CyaSSL) - * - * 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-1301, USA - */ - -#ifdef HAVE_CONFIG_H - #include -#endif - -#include /* name change portability layer */ -#include -#ifdef HAVE_ECC - #include /* ecc_fp_free */ -#endif - -#if defined(CYASSL_MDK_ARM) - #include - #include - - #if defined(CYASSL_MDK5) - #include "cmsis_os.h" - #include "rl_fs.h" - #include "rl_net.h" - #else - #include "rtl.h" - #endif - - #include "cyassl_MDK_ARM.h" -#endif - -#include -#include - -#ifndef NO_MAIN_DRIVER - #define ECHO_OUT -#endif - -#include "examples/echoserver/echoserver.h" - -#define SVR_COMMAND_SIZE 256 - -static void SignalReady(void* args, word16 port) -{ -#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) && !defined(__MINGW32__) - /* signal ready to tcp_accept */ - func_args* server_args = (func_args*)args; - tcp_ready* ready = server_args->signal; - pthread_mutex_lock(&ready->mutex); - ready->ready = 1; - ready->port = port; - pthread_cond_signal(&ready->cond); - pthread_mutex_unlock(&ready->mutex); -#endif - (void)args; - (void)port; -} - - -THREAD_RETURN CYASSL_THREAD echoserver_test(void* args) -{ - SOCKET_T sockfd = 0; - CYASSL_METHOD* method = 0; - CYASSL_CTX* ctx = 0; - - int doDTLS = 0; - int doPSK = 0; - int outCreated = 0; - int shutDown = 0; - int useAnyAddr = 0; - word16 port = yasslPort; - int argc = ((func_args*)args)->argc; - char** argv = ((func_args*)args)->argv; - -#ifdef ECHO_OUT - FILE* fout = stdout; - if (argc >= 2) { - fout = fopen(argv[1], "w"); - outCreated = 1; - } - if (!fout) err_sys("can't open output file"); -#endif - (void)outCreated; - (void)argc; - (void)argv; - - ((func_args*)args)->return_code = -1; /* error state */ - -#ifdef CYASSL_DTLS - doDTLS = 1; -#endif - -#ifdef CYASSL_LEANPSK - doPSK = 1; -#endif - -#if defined(NO_RSA) && !defined(HAVE_ECC) - doPSK = 1; -#endif - - #if defined(NO_MAIN_DRIVER) && !defined(USE_WINDOWS_API) && \ - !defined(CYASSL_SNIFFER) && !defined(CYASSL_MDK_SHELL) && \ - !defined(CYASSL_TIRTOS) - port = 0; - #endif - #if defined(USE_ANY_ADDR) - useAnyAddr = 1; - #endif - -#ifdef CYASSL_TIRTOS - fdOpenSession(Task_self()); -#endif - - tcp_listen(&sockfd, &port, useAnyAddr, doDTLS); - -#if defined(CYASSL_DTLS) - method = CyaDTLSv1_2_server_method(); -#elif !defined(NO_TLS) - method = CyaSSLv23_server_method(); -#else - method = CyaSSLv3_server_method(); -#endif - ctx = CyaSSL_CTX_new(method); - /* CyaSSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF); */ - -#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) - CyaSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack); -#endif - -#if defined(HAVE_SESSION_TICKET) && defined(HAVE_CHACHA) && \ - defined(HAVE_POLY1305) - if (TicketInit() != 0) - err_sys("unable to setup Session Ticket Key context"); - wolfSSL_CTX_set_TicketEncCb(ctx, myTicketEncCb); -#endif - -#ifndef NO_FILESYSTEM - if (doPSK == 0) { - #ifdef HAVE_NTRU - /* ntru */ - if (CyaSSL_CTX_use_certificate_file(ctx, ntruCert, SSL_FILETYPE_PEM) - != SSL_SUCCESS) - err_sys("can't load ntru cert file, " - "Please run from wolfSSL home dir"); - - if (CyaSSL_CTX_use_NTRUPrivateKey_file(ctx, ntruKey) - != SSL_SUCCESS) - err_sys("can't load ntru key file, " - "Please run from wolfSSL home dir"); - #elif defined(HAVE_ECC) && !defined(CYASSL_SNIFFER) - /* ecc */ - if (CyaSSL_CTX_use_certificate_file(ctx, eccCert, SSL_FILETYPE_PEM) - != SSL_SUCCESS) - err_sys("can't load server cert file, " - "Please run from wolfSSL home dir"); - - if (CyaSSL_CTX_use_PrivateKey_file(ctx, eccKey, SSL_FILETYPE_PEM) - != SSL_SUCCESS) - err_sys("can't load server key file, " - "Please run from wolfSSL home dir"); - #elif defined(NO_CERTS) - /* do nothing, just don't load cert files */ - #else - /* normal */ - if (CyaSSL_CTX_use_certificate_file(ctx, svrCert, SSL_FILETYPE_PEM) - != SSL_SUCCESS) - err_sys("can't load server cert file, " - "Please run from wolfSSL home dir"); - - if (CyaSSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM) - != SSL_SUCCESS) - err_sys("can't load server key file, " - "Please run from wolfSSL home dir"); - #endif - } /* doPSK */ -#elif !defined(NO_CERTS) - if (!doPSK) { - load_buffer(ctx, svrCert, CYASSL_CERT); - load_buffer(ctx, svrKey, CYASSL_KEY); - } -#endif - -#if defined(CYASSL_SNIFFER) - /* don't use EDH, can't sniff tmp keys */ - CyaSSL_CTX_set_cipher_list(ctx, "AES256-SHA"); -#endif - - if (doPSK) { -#ifndef NO_PSK - const char *defaultCipherList; - - CyaSSL_CTX_set_psk_server_callback(ctx, my_psk_server_cb); - CyaSSL_CTX_use_psk_identity_hint(ctx, "cyassl server"); - #ifdef HAVE_NULL_CIPHER - defaultCipherList = "PSK-NULL-SHA256"; - #else - defaultCipherList = "PSK-AES128-CBC-SHA256"; - #endif - if (CyaSSL_CTX_set_cipher_list(ctx, defaultCipherList) != SSL_SUCCESS) - err_sys("server can't set cipher list 2"); -#endif - } - - SignalReady(args, port); - - while (!shutDown) { - CYASSL* ssl = 0; - char command[SVR_COMMAND_SIZE+1]; - int echoSz = 0; - int clientfd; - int firstRead = 1; - int gotFirstG = 0; - -#ifndef CYASSL_DTLS - SOCKADDR_IN_T client; - socklen_t client_len = sizeof(client); - clientfd = accept(sockfd, (struct sockaddr*)&client, - (ACCEPT_THIRD_T)&client_len); -#else - clientfd = udp_read_connect(sockfd); -#endif - if (clientfd == -1) err_sys("tcp accept failed"); - - ssl = CyaSSL_new(ctx); - if (ssl == NULL) err_sys("SSL_new failed"); - CyaSSL_set_fd(ssl, clientfd); - #if !defined(NO_FILESYSTEM) && !defined(NO_DH) && !defined(NO_ASN) - CyaSSL_SetTmpDH_file(ssl, dhParam, SSL_FILETYPE_PEM); - #elif !defined(NO_DH) - SetDH(ssl); /* will repick suites with DHE, higher than PSK */ - #endif - if (CyaSSL_accept(ssl) != SSL_SUCCESS) { - printf("SSL_accept failed\n"); - CyaSSL_free(ssl); - CloseSocket(clientfd); - continue; - } -#if defined(PEER_INFO) - showPeer(ssl); -#endif - - while ( (echoSz = CyaSSL_read(ssl, command, sizeof(command)-1)) > 0) { - - if (firstRead == 1) { - firstRead = 0; /* browser may send 1 byte 'G' to start */ - if (echoSz == 1 && command[0] == 'G') { - gotFirstG = 1; - continue; - } - } - else if (gotFirstG == 1 && strncmp(command, "ET /", 4) == 0) { - strncpy(command, "GET", 4); - /* fall through to normal GET */ - } - - if ( strncmp(command, "quit", 4) == 0) { - printf("client sent quit command: shutting down!\n"); - shutDown = 1; - break; - } - if ( strncmp(command, "break", 5) == 0) { - printf("client sent break command: closing session!\n"); - break; - } -#ifdef PRINT_SESSION_STATS - if ( strncmp(command, "printstats", 10) == 0) { - CyaSSL_PrintSessionStats(); - break; - } -#endif - if ( strncmp(command, "GET", 3) == 0) { - char type[] = "HTTP/1.0 200 ok\r\nContent-type:" - " text/html\r\n\r\n"; - char header[] = "\n
\n";
-                char body[]   = "greetings from wolfSSL\n";
-                char footer[] = "\r\n\r\n";
-            
-                strncpy(command, type, sizeof(type));
-                echoSz = sizeof(type) - 1;
-
-                strncpy(&command[echoSz], header, sizeof(header));
-                echoSz += (int)sizeof(header) - 1;
-                strncpy(&command[echoSz], body, sizeof(body));
-                echoSz += (int)sizeof(body) - 1;
-                strncpy(&command[echoSz], footer, sizeof(footer));
-                echoSz += (int)sizeof(footer);
-
-                if (CyaSSL_write(ssl, command, echoSz) != echoSz)
-                    err_sys("SSL_write failed");
-                break;
-            }
-            command[echoSz] = 0;
-
-            #ifdef ECHO_OUT
-                fputs(command, fout);
-            #endif
-
-            if (CyaSSL_write(ssl, command, echoSz) != echoSz)
-                err_sys("SSL_write failed");
-        }
-#ifndef CYASSL_DTLS
-        CyaSSL_shutdown(ssl);
-#endif
-        CyaSSL_free(ssl);
-        CloseSocket(clientfd);
-#ifdef CYASSL_DTLS
-        tcp_listen(&sockfd, &port, useAnyAddr, doDTLS);
-        SignalReady(args, port);
-#endif
-    }
-
-    CloseSocket(sockfd);
-    CyaSSL_CTX_free(ctx);
-
-#ifdef ECHO_OUT
-    if (outCreated)
-        fclose(fout);
-#endif
-
-    ((func_args*)args)->return_code = 0;
-
-#if defined(NO_MAIN_DRIVER) && defined(HAVE_ECC) && defined(FP_ECC) \
-                            && defined(HAVE_THREAD_LS)
-    ecc_fp_free();  /* free per thread cache */
-#endif
-
-#ifdef CYASSL_TIRTOS
-    fdCloseSession(Task_self());
-#endif
-
-#if defined(HAVE_SESSION_TICKET) && defined(HAVE_CHACHA) && \
-                                    defined(HAVE_POLY1305)
-    TicketCleanup();
-#endif
-
-#ifndef CYASSL_TIRTOS
-    return 0;
-#endif
-}
-
-
-/* so overall tests can pull in test function */
-#ifndef NO_MAIN_DRIVER
-
-    int main(int argc, char** argv)
-    {
-        func_args args;
-
-#ifdef HAVE_CAVIUM
-        int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID);
-        if (ret != 0)
-            err_sys("Cavium OpenNitroxDevice failed");
-#endif /* HAVE_CAVIUM */
-
-        StartTCP();
-
-        args.argc = argc;
-        args.argv = argv;
-
-        CyaSSL_Init();
-#if defined(DEBUG_CYASSL) && !defined(CYASSL_MDK_SHELL)
-        CyaSSL_Debugging_ON();
-#endif
-        if (CurrentDir("echoserver"))
-            ChangeDirBack(2);
-        else if (CurrentDir("Debug") || CurrentDir("Release"))
-            ChangeDirBack(3);
-        echoserver_test(&args);
-        CyaSSL_Cleanup();
-
-#ifdef HAVE_CAVIUM
-        CspShutdown(CAVIUM_DEV_ID);
-#endif
-        return args.return_code;
-    }
-
-        
-#endif /* NO_MAIN_DRIVER */
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.h b/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.h
deleted file mode 100755
index 2f0d88d..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* echoserver.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#pragma once
-
-THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args);
diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.sln b/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.sln
deleted file mode 100755
index 6bda354..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual C++ Express 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "echoserver", "echoserver.vcproj", "{4F3F3EF1-BB95-466A-87B2-A91C059D0197}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{4F3F3EF1-BB95-466A-87B2-A91C059D0197}.Debug|Win32.ActiveCfg = Debug|Win32
-		{4F3F3EF1-BB95-466A-87B2-A91C059D0197}.Debug|Win32.Build.0 = Debug|Win32
-		{4F3F3EF1-BB95-466A-87B2-A91C059D0197}.Release|Win32.ActiveCfg = Release|Win32
-		{4F3F3EF1-BB95-466A-87B2-A91C059D0197}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.vcproj b/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.vcproj
deleted file mode 100755
index 554b55b..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.vcproj
+++ /dev/null
@@ -1,197 +0,0 @@
-
-
-	
-		
-	
-	
-	
-	
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-	
-	
-	
-	
-		
-			
-			
-		
-		
-		
-		
-		
-	
-	
-	
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.vcxproj b/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.vcxproj
deleted file mode 100755
index 096ba75..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/echoserver.vcxproj
+++ /dev/null
@@ -1,333 +0,0 @@
-
-
-  
-    
-      Debug
-      Win32
-    
-    
-      Debug
-      x64
-    
-    
-      DLL Debug
-      Win32
-    
-    
-      DLL Debug
-      x64
-    
-    
-      DLL Release
-      Win32
-    
-    
-      DLL Release
-      x64
-    
-    
-      Release
-      Win32
-    
-    
-      Release
-      x64
-    
-  
-  
-    {07D97C48-E08F-4E34-9F67-3064039FF2CB}
-    echoserver
-    Win32Proj
-  
-  
-  
-    Application
-    v110
-    Unicode
-    true
-  
-  
-    Application
-    v110
-    Unicode
-    true
-  
-  
-    Application
-    v110
-    Unicode
-    true
-  
-  
-    Application
-    v110
-    Unicode
-    true
-  
-  
-    Application
-    v110
-    Unicode
-  
-  
-    Application
-    v110
-    Unicode
-  
-  
-    Application
-    v110
-    Unicode
-  
-  
-    Application
-    v110
-    Unicode
-  
-  
-  
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-  
-    <_ProjectFileVersion>11.0.61030.0
-  
-  
-    $(SolutionDir)$(Configuration)\
-    $(Configuration)\obj\
-    true
-  
-  
-    $(SolutionDir)$(Configuration)\
-    $(Configuration)\obj\
-    true
-  
-  
-    true
-    $(SolutionDir)$(Platform)\$(Configuration)\
-    $(Platform)\$(Configuration)\obj\
-  
-  
-    true
-    $(SolutionDir)$(Platform)\$(Configuration)\
-    $(Platform)\$(Configuration)\obj\
-  
-  
-    $(SolutionDir)$(Configuration)\
-    $(Configuration)\obj\
-    false
-  
-  
-    $(SolutionDir)$(Configuration)\
-    $(Configuration)\obj\
-    false
-  
-  
-    false
-    $(SolutionDir)$(Platform)\$(Configuration)\
-    $(Platform)\$(Configuration)\obj\
-  
-  
-    false
-    $(SolutionDir)$(Platform)\$(Configuration)\
-    $(Platform)\$(Configuration)\obj\
-  
-  
-    
-      Disabled
-      ../../;%(AdditionalIncludeDirectories)
-      USE_ANY_ADDR;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)
-      true
-      EnableFastChecks
-      MultiThreadedDebugDLL
-      
-      Level3
-      EditAndContinue
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      MachineX86
-      false
-
-    
-  
-  
-    
-      Disabled
-      ../../;%(AdditionalIncludeDirectories)
-      USE_ANY_ADDR;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions)
-      true
-      EnableFastChecks
-      MultiThreadedDebugDLL
-      
-      
-      Level3
-      EditAndContinue
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      MachineX86
-    
-  
-  
-    
-      Disabled
-      ../../;%(AdditionalIncludeDirectories)
-      USE_ANY_ADDR;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)
-      EnableFastChecks
-      MultiThreadedDebugDLL
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-    
-  
-  
-    
-      Disabled
-      ../../;%(AdditionalIncludeDirectories)
-      USE_ANY_ADDR;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions)
-      EnableFastChecks
-      MultiThreadedDebugDLL
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-    
-  
-  
-    
-      MaxSpeed
-      true
-      ../../;%(AdditionalIncludeDirectories)
-      USE_ANY_ADDR;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)
-      MultiThreadedDLL
-      true
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      true
-      true
-      MachineX86
-      false
-    
-  
-  
-    
-      MaxSpeed
-      true
-      ../../;%(AdditionalIncludeDirectories)
-      USE_ANY_ADDR;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions)
-      MultiThreadedDLL
-      true
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      true
-      true
-      MachineX86
-    
-  
-  
-    
-      MaxSpeed
-      true
-      ../../;%(AdditionalIncludeDirectories)
-      USE_ANY_ADDR;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)
-      MultiThreadedDLL
-      true
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      true
-      true
-    
-  
-  
-    
-      MaxSpeed
-      true
-      ../../;%(AdditionalIncludeDirectories)
-      USE_ANY_ADDR;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions)
-      MultiThreadedDLL
-      true
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      true
-      true
-    
-  
-  
-    
-  
-  
-    
-      {73973223-5ee8-41ca-8e88-1d60e89a237b}
-      false
-    
-  
-  
-  
-  
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/include.am b/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/include.am
deleted file mode 100755
index a843121..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/examples/echoserver/include.am
+++ /dev/null
@@ -1,19 +0,0 @@
-# vim:ft=automake
-# included from Top Level Makefile.am
-# All paths should be given relative to the root
-
-
-if BUILD_EXAMPLES
-noinst_PROGRAMS += examples/echoserver/echoserver
-noinst_HEADERS += examples/echoserver/echoserver.h
-examples_echoserver_echoserver_SOURCES      = examples/echoserver/echoserver.c
-examples_echoserver_echoserver_LDADD        = src/libwolfssl.la
-examples_echoserver_echoserver_DEPENDENCIES = src/libwolfssl.la
-endif
-EXTRA_DIST += examples/echoserver/echoserver.sln
-EXTRA_DIST += examples/echoserver/echoserver-ntru.vcproj
-EXTRA_DIST += examples/echoserver/echoserver.vcproj
-EXTRA_DIST += examples/echoserver/echoserver.vcxproj
-
-dist_example_DATA+= examples/echoserver/echoserver.c
-DISTCLEANFILES+= examples/echoserver/.libs/echoserver
diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/server/include.am b/FreeRTOS-Plus/Source/WolfSSL/examples/server/include.am
deleted file mode 100755
index bd70376..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/examples/server/include.am
+++ /dev/null
@@ -1,20 +0,0 @@
-# vim:ft=automake
-# included from Top Level Makefile.am
-# All paths should be given relative to the root
-
-
-if BUILD_EXAMPLES
-noinst_PROGRAMS += examples/server/server
-noinst_HEADERS += examples/server/server.h
-examples_server_server_SOURCES      = examples/server/server.c
-examples_server_server_LDADD        = src/libwolfssl.la
-examples_server_server_DEPENDENCIES = src/libwolfssl.la
-endif
-EXTRA_DIST += examples/server/server.sln
-EXTRA_DIST += examples/server/server-ntru.vcproj
-EXTRA_DIST += examples/server/server.vcproj
-EXTRA_DIST += examples/server/server.vcxproj
-
-dist_example_DATA+= examples/server/server.c
-DISTCLEANFILES+= examples/server/.libs/server
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/server/server-ntru.vcproj b/FreeRTOS-Plus/Source/WolfSSL/examples/server/server-ntru.vcproj
deleted file mode 100755
index 4123a28..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/examples/server/server-ntru.vcproj
+++ /dev/null
@@ -1,199 +0,0 @@
-
-
-	
-		
-	
-	
-	
-	
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-	
-	
-	
-	
-		
-			
-			
-		
-		
-		
-		
-		
-	
-	
-	
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.c b/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.c
deleted file mode 100755
index a8d597a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.c
+++ /dev/null
@@ -1,777 +0,0 @@
-/* server.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-#include  /* name change portability layer */
-
-#include 
-#ifdef HAVE_ECC
-    #include    /* ecc_fp_free */
-#endif
-
-#if !defined(WOLFSSL_TRACK_MEMORY) && !defined(NO_MAIN_DRIVER)
-    /* in case memory tracker wants stats */
-    #define WOLFSSL_TRACK_MEMORY
-#endif
-
-#if defined(CYASSL_MDK_ARM)
-        #include 
-        #include 
-
-        #if defined(CYASSL_MDK5)
-            #include "cmsis_os.h"
-            #include "rl_fs.h" 
-            #include "rl_net.h" 
-        #else
-            #include "rtl.h"
-        #endif
-
-        #include "cyassl_MDK_ARM.h"
-#endif
-#include 
-#include 
-
-#include "examples/server/server.h"
-
-
-#ifdef CYASSL_CALLBACKS
-    int srvHandShakeCB(HandShakeInfo*);
-    int srvTimeoutCB(TimeoutInfo*);
-    Timeval srvTo;
-#endif
-
-#ifndef NO_HANDSHAKE_DONE_CB
-    int myHsDoneCb(WOLFSSL* ssl, void* user_ctx);
-#endif
-
-
-
-static void NonBlockingSSL_Accept(SSL* ssl)
-{
-#ifndef CYASSL_CALLBACKS
-    int ret = SSL_accept(ssl);
-#else
-    int ret = CyaSSL_accept_ex(ssl, srvHandShakeCB, srvTimeoutCB, srvTo);
-#endif
-    int error = SSL_get_error(ssl, 0);
-    SOCKET_T sockfd = (SOCKET_T)CyaSSL_get_fd(ssl);
-    int select_ret;
-
-    while (ret != SSL_SUCCESS && (error == SSL_ERROR_WANT_READ ||
-                                  error == SSL_ERROR_WANT_WRITE)) {
-        int currTimeout = 1;
-
-        if (error == SSL_ERROR_WANT_READ)
-            printf("... server would read block\n");
-        else
-            printf("... server would write block\n");
-
-#ifdef CYASSL_DTLS
-        currTimeout = CyaSSL_dtls_get_current_timeout(ssl);
-#endif
-        select_ret = tcp_select(sockfd, currTimeout);
-
-        if ((select_ret == TEST_RECV_READY) ||
-                                        (select_ret == TEST_ERROR_READY)) {
-            #ifndef CYASSL_CALLBACKS
-                ret = SSL_accept(ssl);
-            #else
-                ret = CyaSSL_accept_ex(ssl,
-                                    srvHandShakeCB, srvTimeoutCB, srvTo);
-            #endif
-            error = SSL_get_error(ssl, 0);
-        }
-        else if (select_ret == TEST_TIMEOUT && !CyaSSL_dtls(ssl)) {
-            error = SSL_ERROR_WANT_READ;
-        }
-#ifdef CYASSL_DTLS
-        else if (select_ret == TEST_TIMEOUT && CyaSSL_dtls(ssl) &&
-                                            CyaSSL_dtls_got_timeout(ssl) >= 0) {
-            error = SSL_ERROR_WANT_READ;
-        }
-#endif
-        else {
-            error = SSL_FATAL_ERROR;
-        }
-    }
-    if (ret != SSL_SUCCESS)
-        err_sys("SSL_accept failed");
-}
-
-
-static void Usage(void)
-{
-    printf("server "    LIBCYASSL_VERSION_STRING
-           " NOTE: All files relative to wolfSSL home dir\n");
-    printf("-?          Help, print this usage\n");
-    printf("-p     Port to listen on, not 0, default %d\n", yasslPort);
-    printf("-v     SSL version [0-3], SSLv3(0) - TLS1.2(3)), default %d\n",
-                                 SERVER_DEFAULT_VERSION);
-    printf("-l     Cipher list\n");
-    printf("-c    Certificate file,           default %s\n", svrCert);
-    printf("-k    Key file,                   default %s\n", svrKey);
-    printf("-A    Certificate Authority file, default %s\n", cliCert);
-#ifndef NO_DH
-    printf("-D    Diffie-Hellman Params file, default %s\n", dhParam);
-    printf("-Z     Minimum DH key bits,        default %d\n",
-                                 DEFAULT_MIN_DHKEY_BITS);
-#endif
-    printf("-d          Disable client cert check\n");
-    printf("-b          Bind to any interface instead of localhost only\n");
-    printf("-s          Use pre Shared keys\n");
-    printf("-t          Track wolfSSL memory use\n");
-    printf("-u          Use UDP DTLS,"
-           " add -v 2 for DTLSv1 (default), -v 3 for DTLSv1.2\n");
-    printf("-f          Fewer packets/group messages\n");
-    printf("-R          Create server ready file, for external monitor\n");
-    printf("-r          Allow one client Resumption\n");
-    printf("-N          Use Non-blocking sockets\n");
-    printf("-S     Use Host Name Indication\n");
-    printf("-w          Wait for bidirectional shutdown\n");
-#ifdef HAVE_OCSP
-    printf("-o          Perform OCSP lookup on peer certificate\n");
-    printf("-O     Perform OCSP lookup using  as responder\n");
-#endif
-#ifdef HAVE_PK_CALLBACKS 
-    printf("-P          Public Key Callbacks\n");
-#endif
-#ifdef HAVE_ANON
-    printf("-a          Anonymous server\n");
-#endif
-}
-
-THREAD_RETURN CYASSL_THREAD server_test(void* args)
-{
-    SOCKET_T sockfd   = 0;
-    SOCKET_T clientfd = 0;
-
-    SSL_METHOD* method = 0;
-    SSL_CTX*    ctx    = 0;
-    SSL*        ssl    = 0;
-
-    char   msg[] = "I hear you fa shizzle!";
-    char   input[80];
-    int    idx;
-    int    ch;
-    int    version = SERVER_DEFAULT_VERSION;
-    int    doCliCertCheck = 1;
-    int    useAnyAddr = 0;
-    word16 port = yasslPort;
-    int    usePsk = 0;
-    int    useAnon = 0;
-    int    doDTLS = 0;
-    int    needDH = 0;
-    int    useNtruKey   = 0;
-    int    nonBlocking  = 0;
-    int    trackMemory  = 0;
-    int    fewerPackets = 0;
-    int    pkCallbacks  = 0;
-    int    serverReadyFile = 0;
-    int    wc_shutdown     = 0;
-    int    resume = 0;            /* do resume, and resume count */
-    int    minDhKeyBits = DEFAULT_MIN_DHKEY_BITS;
-    int    ret;
-    char*  cipherList = NULL;
-    const char* verifyCert = cliCert;
-    const char* ourCert    = svrCert;
-    const char* ourKey     = svrKey;
-    const char* ourDhParam = dhParam;
-    int    argc = ((func_args*)args)->argc;
-    char** argv = ((func_args*)args)->argv;
-
-#ifdef HAVE_SNI
-    char*  sniHostName = NULL;
-#endif
-
-#ifdef HAVE_OCSP
-    int    useOcsp  = 0;
-    char*  ocspUrl  = NULL;
-#endif
-
-    ((func_args*)args)->return_code = -1; /* error state */
-
-#ifdef NO_RSA
-    verifyCert = (char*)cliEccCert;
-    ourCert    = (char*)eccCert;
-    ourKey     = (char*)eccKey;
-#endif
-    (void)trackMemory;
-    (void)pkCallbacks;
-    (void)needDH;
-    (void)ourKey;
-    (void)ourCert;
-    (void)ourDhParam;
-    (void)verifyCert;
-    (void)useNtruKey;
-    (void)doCliCertCheck;
-    (void)minDhKeyBits;
-
-#ifdef CYASSL_TIRTOS
-    fdOpenSession(Task_self());
-#endif
-
-    while ((ch = mygetopt(argc, argv, "?dbstnNufrRawPp:v:l:A:c:k:Z:S:oO:D:"))
-                         != -1) {
-        switch (ch) {
-            case '?' :
-                Usage();
-                exit(EXIT_SUCCESS);
-
-            case 'd' :
-                doCliCertCheck = 0;
-                break;
-
-            case 'b' :
-                useAnyAddr = 1;
-                break;
-
-            case 's' :
-                usePsk = 1;
-                break;
-
-            case 't' :
-            #ifdef USE_WOLFSSL_MEMORY
-                trackMemory = 1;
-            #endif
-                break;
-
-            case 'n' :
-                useNtruKey = 1;
-                break;
-
-            case 'u' :
-                doDTLS  = 1;
-                break;
-
-            case 'f' :
-                fewerPackets = 1;
-                break;
-
-            case 'R' :
-                serverReadyFile = 1;
-                break;
-
-            case 'r' :
-                #ifndef NO_SESSION_CACHE
-                    resume = 1;
-                #endif
-                break;
-
-            case 'P' :
-            #ifdef HAVE_PK_CALLBACKS 
-                pkCallbacks = 1;
-            #endif
-                break;
-
-            case 'p' :
-                port = (word16)atoi(myoptarg);
-                #if !defined(NO_MAIN_DRIVER) || defined(USE_WINDOWS_API)
-                    if (port == 0)
-                        err_sys("port number cannot be 0");
-                #endif
-                break;
-
-            case 'w' :
-                wc_shutdown = 1;
-                break;
-
-            case 'v' :
-                version = atoi(myoptarg);
-                if (version < 0 || version > 3) {
-                    Usage();
-                    exit(MY_EX_USAGE);
-                }
-                break;
-
-            case 'l' :
-                cipherList = myoptarg;
-                break;
-
-            case 'A' :
-                verifyCert = myoptarg;
-                break;
-
-            case 'c' :
-                ourCert = myoptarg;
-                break;
-
-            case 'k' :
-                ourKey = myoptarg;
-                break;
-
-            case 'D' :
-                #ifndef NO_DH
-                    ourDhParam = myoptarg;
-                #endif
-                break;
-
-            case 'Z' :
-                #ifndef NO_DH
-                    minDhKeyBits = atoi(myoptarg);
-                    if (minDhKeyBits <= 0 || minDhKeyBits > 16000) {
-                        Usage();
-                        exit(MY_EX_USAGE);
-                    }
-                #endif
-                break;
-
-            case 'N':
-                nonBlocking = 1;
-                break;
-
-            case 'S' :
-                #ifdef HAVE_SNI
-                    sniHostName = myoptarg;
-                #endif
-                break;
-
-            case 'o' :
-                #ifdef HAVE_OCSP
-                    useOcsp = 1;
-                #endif
-                break;
-
-            case 'O' :
-                #ifdef HAVE_OCSP
-                    useOcsp = 1;
-                    ocspUrl = myoptarg;
-                #endif
-                break;
-
-            case 'a' :
-                #ifdef HAVE_ANON
-                    useAnon = 1;
-                #endif
-                break;
-
-            default:
-                Usage();
-                exit(MY_EX_USAGE);
-        }
-    }
-
-    myoptind = 0;      /* reset for test cases */
-
-    /* sort out DTLS versus TLS versions */
-    if (version == CLIENT_INVALID_VERSION) {
-        if (doDTLS)
-            version = CLIENT_DTLS_DEFAULT_VERSION;
-        else
-            version = CLIENT_DEFAULT_VERSION;
-    }
-    else {
-        if (doDTLS) {
-            if (version == 3)
-                version = -2;
-            else
-                version = -1;
-        }
-    }
-
-#ifdef USE_CYASSL_MEMORY
-    if (trackMemory)
-        InitMemoryTracker(); 
-#endif
-
-    switch (version) {
-#ifndef NO_OLD_TLS
-        case 0:
-            method = SSLv3_server_method();
-            break;
-
-    #ifndef NO_TLS
-        case 1:
-            method = TLSv1_server_method();
-            break;
-
-
-        case 2:
-            method = TLSv1_1_server_method();
-            break;
-
-        #endif
-#endif
-
-#ifndef NO_TLS
-        case 3:
-            method = TLSv1_2_server_method();
-            break;
-#endif
-                
-#ifdef CYASSL_DTLS
-    #ifndef NO_OLD_TLS
-        case -1:
-            method = DTLSv1_server_method();
-            break;
-    #endif
-
-        case -2:
-            method = DTLSv1_2_server_method();
-            break;
-#endif
-
-        default:
-            err_sys("Bad SSL version");
-    }
-
-    if (method == NULL)
-        err_sys("unable to get method");
-
-    ctx = SSL_CTX_new(method);
-    if (ctx == NULL)
-        err_sys("unable to get ctx");
-
-#if defined(HAVE_SESSION_TICKET) && defined(HAVE_CHACHA) && \
-                                    defined(HAVE_POLY1305)
-    if (TicketInit() != 0)
-        err_sys("unable to setup Session Ticket Key context");
-    wolfSSL_CTX_set_TicketEncCb(ctx, myTicketEncCb);
-#endif
-
-    if (cipherList)
-        if (SSL_CTX_set_cipher_list(ctx, cipherList) != SSL_SUCCESS)
-            err_sys("server can't set cipher list 1");
-
-#ifdef CYASSL_LEANPSK
-    usePsk = 1;
-#endif
-
-#if defined(NO_RSA) && !defined(HAVE_ECC)
-    usePsk = 1;
-#endif
-
-    if (fewerPackets)
-        CyaSSL_CTX_set_group_messages(ctx);
-
-#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
-    SSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
-#endif
-
-#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
-    if (!usePsk && !useAnon) {
-        if (SSL_CTX_use_certificate_file(ctx, ourCert, SSL_FILETYPE_PEM)
-                                         != SSL_SUCCESS)
-            err_sys("can't load server cert file, check file and run from"
-                    " wolfSSL home dir");
-    }
-#endif
-
-#ifndef NO_DH
-    wolfSSL_CTX_SetMinDhKey_Sz(ctx, (word16)minDhKeyBits);
-#endif
-
-#ifdef HAVE_NTRU
-    if (useNtruKey) {
-        if (CyaSSL_CTX_use_NTRUPrivateKey_file(ctx, ourKey)
-                                               != SSL_SUCCESS)
-            err_sys("can't load ntru key file, "
-                    "Please run from wolfSSL home dir");
-    }
-#endif
-
-#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
-    if (!useNtruKey && !usePsk && !useAnon) {
-        if (SSL_CTX_use_PrivateKey_file(ctx, ourKey, SSL_FILETYPE_PEM)
-                                         != SSL_SUCCESS)
-            err_sys("can't load server private key file, check file and run "
-                "from wolfSSL home dir");
-    }
-#endif
-
-    if (usePsk) {
-#ifndef NO_PSK
-        SSL_CTX_set_psk_server_callback(ctx, my_psk_server_cb);
-        SSL_CTX_use_psk_identity_hint(ctx, "cyassl server");
-        if (cipherList == NULL) {
-            const char *defaultCipherList;
-            #if defined(HAVE_AESGCM) && !defined(NO_DH)
-                defaultCipherList = "DHE-PSK-AES128-GCM-SHA256";
-                needDH = 1;
-            #elif defined(HAVE_NULL_CIPHER)
-                defaultCipherList = "PSK-NULL-SHA256";
-            #else
-                defaultCipherList = "PSK-AES128-CBC-SHA256";
-            #endif
-            if (SSL_CTX_set_cipher_list(ctx, defaultCipherList) != SSL_SUCCESS)
-                err_sys("server can't set cipher list 2");
-        }
-#endif
-    }
-
-    if (useAnon) {
-#ifdef HAVE_ANON
-        CyaSSL_CTX_allow_anon_cipher(ctx);
-        if (cipherList == NULL) {
-            if (SSL_CTX_set_cipher_list(ctx, "ADH-AES128-SHA") != SSL_SUCCESS)
-                err_sys("server can't set cipher list 4");
-        }
-#endif
-    }
-
-#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
-    /* if not using PSK, verify peer with certs */
-    if (doCliCertCheck && usePsk == 0 && useAnon == 0) {
-        SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER |
-                                SSL_VERIFY_FAIL_IF_NO_PEER_CERT,0);
-        if (SSL_CTX_load_verify_locations(ctx, verifyCert, 0) != SSL_SUCCESS)
-            err_sys("can't load ca file, Please run from wolfSSL home dir");
-    }
-#endif
-
-#if defined(CYASSL_SNIFFER)
-    /* don't use EDH, can't sniff tmp keys */
-    if (cipherList == NULL) {
-        if (SSL_CTX_set_cipher_list(ctx, "AES256-SHA256") != SSL_SUCCESS)
-            err_sys("server can't set cipher list 3");
-    }
-#endif
-
-#ifdef HAVE_SNI
-    if (sniHostName)
-        if (CyaSSL_CTX_UseSNI(ctx, CYASSL_SNI_HOST_NAME, sniHostName,
-                                           XSTRLEN(sniHostName)) != SSL_SUCCESS)
-            err_sys("UseSNI failed");
-#endif
-
-while (1) {  /* allow resume option */
-    if (resume > 1) {  /* already did listen, just do accept */
-        if (doDTLS == 0) {
-            SOCKADDR_IN_T client;
-            socklen_t client_len = sizeof(client);
-            clientfd = accept(sockfd, (struct sockaddr*)&client,
-                             (ACCEPT_THIRD_T)&client_len);
-        } else {
-            tcp_listen(&sockfd, &port, useAnyAddr, doDTLS);
-            clientfd = udp_read_connect(sockfd);
-        }
-        #ifdef USE_WINDOWS_API
-            if (clientfd == INVALID_SOCKET) err_sys("tcp accept failed");
-        #else
-            if (clientfd == -1) err_sys("tcp accept failed");
-        #endif
-    }
-
-    ssl = SSL_new(ctx);
-    if (ssl == NULL)
-        err_sys("unable to get SSL");
-
-#ifndef NO_HANDSHAKE_DONE_CB
-    wolfSSL_SetHsDoneCb(ssl, myHsDoneCb, NULL);
-#endif
-#ifdef HAVE_CRL
-    CyaSSL_EnableCRL(ssl, 0);
-    CyaSSL_LoadCRL(ssl, crlPemDir, SSL_FILETYPE_PEM, CYASSL_CRL_MONITOR |
-                                                     CYASSL_CRL_START_MON);
-    CyaSSL_SetCRL_Cb(ssl, CRL_CallBack);
-#endif
-#ifdef HAVE_OCSP
-    if (useOcsp) {
-        if (ocspUrl != NULL) {
-            CyaSSL_CTX_SetOCSP_OverrideURL(ctx, ocspUrl);
-            CyaSSL_CTX_EnableOCSP(ctx, CYASSL_OCSP_NO_NONCE
-                                                    | CYASSL_OCSP_URL_OVERRIDE);
-        }
-        else
-            CyaSSL_CTX_EnableOCSP(ctx, CYASSL_OCSP_NO_NONCE);
-    }
-#endif
-#ifdef HAVE_PK_CALLBACKS
-    if (pkCallbacks)
-        SetupPkCallbacks(ctx, ssl);
-#endif
-
-    if (resume < 2) {  /* do listen and accept */
-        tcp_accept(&sockfd, &clientfd, (func_args*)args, port, useAnyAddr,
-                   doDTLS, serverReadyFile);
-    }
-
-    SSL_set_fd(ssl, clientfd);
-    if (usePsk == 0 || useAnon == 1 || cipherList != NULL || needDH == 1) {
-        #if !defined(NO_FILESYSTEM) && !defined(NO_DH) && !defined(NO_ASN)
-            CyaSSL_SetTmpDH_file(ssl, ourDhParam, SSL_FILETYPE_PEM);
-        #elif !defined(NO_DH)
-            SetDH(ssl);  /* repick suites with DHE, higher priority than PSK */
-        #endif
-    }
-
-#ifndef CYASSL_CALLBACKS
-    if (nonBlocking) {
-        CyaSSL_set_using_nonblock(ssl, 1);
-        tcp_set_nonblocking(&clientfd);
-        NonBlockingSSL_Accept(ssl);
-    } else if (SSL_accept(ssl) != SSL_SUCCESS) {
-        int err = SSL_get_error(ssl, 0);
-        char buffer[CYASSL_MAX_ERROR_SZ];
-        printf("error = %d, %s\n", err, ERR_error_string(err, buffer));
-        err_sys("SSL_accept failed");
-    }
-#else
-    NonBlockingSSL_Accept(ssl);
-#endif
-    showPeer(ssl);
-
-    idx = SSL_read(ssl, input, sizeof(input)-1);
-    if (idx > 0) {
-        input[idx] = 0;
-        printf("Client message: %s\n", input);
-
-    }
-    else if (idx < 0) {
-        int readErr = SSL_get_error(ssl, 0);
-        if (readErr != SSL_ERROR_WANT_READ)
-            err_sys("SSL_read failed");
-    }
-
-    if (SSL_write(ssl, msg, sizeof(msg)) != sizeof(msg))
-        err_sys("SSL_write failed");
-        
-    #if defined(CYASSL_MDK_SHELL) && defined(HAVE_MDK_RTX)
-        os_dly_wait(500) ;
-    #elif defined (CYASSL_TIRTOS)
-        Task_yield();
-    #endif
-
-    if (doDTLS == 0) {
-        ret = SSL_shutdown(ssl);
-        if (wc_shutdown && ret == SSL_SHUTDOWN_NOT_DONE)
-            SSL_shutdown(ssl);    /* bidirectional shutdown */
-    }
-    SSL_free(ssl);
-    if (resume == 1) {
-        CloseSocket(clientfd);
-        resume++;           /* only do one resume for testing */
-        continue;
-    }
-    break;  /* out of while loop, done with normal and resume option */
-}
-    SSL_CTX_free(ctx);
-
-    CloseSocket(clientfd);
-    CloseSocket(sockfd);
-    ((func_args*)args)->return_code = 0;
-
-
-#if defined(NO_MAIN_DRIVER) && defined(HAVE_ECC) && defined(FP_ECC) \
-                            && defined(HAVE_THREAD_LS)
-    ecc_fp_free();  /* free per thread cache */
-#endif
-
-#ifdef USE_WOLFSSL_MEMORY
-    if (trackMemory)
-        ShowMemoryTracker();
-#endif
-
-#ifdef CYASSL_TIRTOS
-    fdCloseSession(Task_self());
-#endif
-
-#if defined(HAVE_SESSION_TICKET) && defined(HAVE_CHACHA) && \
-                                    defined(HAVE_POLY1305)
-    TicketCleanup();
-#endif
-
-#ifndef CYASSL_TIRTOS
-    return 0;
-#endif
-}
-
-
-/* so overall tests can pull in test function */
-#ifndef NO_MAIN_DRIVER
-
-    int main(int argc, char** argv)
-    {
-        func_args args;
-
-#ifdef HAVE_CAVIUM
-        int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID);
-        if (ret != 0)
-            err_sys("Cavium OpenNitroxDevice failed");
-#endif /* HAVE_CAVIUM */
-
-        StartTCP();
-
-        args.argc = argc;
-        args.argv = argv;
-
-        CyaSSL_Init();
-#if defined(DEBUG_CYASSL) && !defined(CYASSL_MDK_SHELL)
-        CyaSSL_Debugging_ON();
-#endif
-        if (CurrentDir("_build"))
-            ChangeDirBack(1);
-        else if (CurrentDir("server"))
-            ChangeDirBack(2);
-        else if (CurrentDir("Debug") || CurrentDir("Release"))
-            ChangeDirBack(3);
-   
-#ifdef HAVE_STACK_SIZE
-        StackSizeCheck(&args, server_test);
-#else 
-        server_test(&args);
-#endif
-        CyaSSL_Cleanup();
-
-#ifdef HAVE_CAVIUM
-        CspShutdown(CAVIUM_DEV_ID);
-#endif
-        return args.return_code;
-    }
-
-    int myoptind = 0;
-    char* myoptarg = NULL;
-
-#endif /* NO_MAIN_DRIVER */
-
-
-#ifdef CYASSL_CALLBACKS
-
-    int srvHandShakeCB(HandShakeInfo* info)
-    {
-        (void)info;
-        return 0;
-    }
-
-
-    int srvTimeoutCB(TimeoutInfo* info)
-    {
-        (void)info;
-        return 0;
-    }
-
-#endif
-
-#ifndef NO_HANDSHAKE_DONE_CB
-    int myHsDoneCb(WOLFSSL* ssl, void* user_ctx)
-    {
-        (void)user_ctx;
-        (void)ssl;
-
-        /* printf("Notified HandShake done\n"); */
-
-        /* return negative number to end TLS connection now */
-        return 0;
-    }
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.h b/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.h
deleted file mode 100755
index c42260f..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* server.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#pragma once
-
-THREAD_RETURN WOLFSSL_THREAD server_test(void* args);
diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.sln b/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.sln
deleted file mode 100755
index 7c9de30..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual C++ Express 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "server.vcproj", "{13A60276-EFB2-4D3F-AFC3-D66E4C4CC27B}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{13A60276-EFB2-4D3F-AFC3-D66E4C4CC27B}.Debug|Win32.ActiveCfg = Debug|Win32
-		{13A60276-EFB2-4D3F-AFC3-D66E4C4CC27B}.Debug|Win32.Build.0 = Debug|Win32
-		{13A60276-EFB2-4D3F-AFC3-D66E4C4CC27B}.Release|Win32.ActiveCfg = Release|Win32
-		{13A60276-EFB2-4D3F-AFC3-D66E4C4CC27B}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.vcproj b/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.vcproj
deleted file mode 100755
index 4795e69..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.vcproj
+++ /dev/null
@@ -1,197 +0,0 @@
-
-
-	
-		
-	
-	
-	
-	
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-	
-	
-	
-	
-		
-			
-			
-		
-		
-		
-		
-		
-	
-	
-	
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.vcxproj b/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.vcxproj
deleted file mode 100755
index f6b53fc..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/examples/server/server.vcxproj
+++ /dev/null
@@ -1,334 +0,0 @@
-
-
-  
-    
-      Debug
-      Win32
-    
-    
-      Debug
-      x64
-    
-    
-      DLL Debug
-      Win32
-    
-    
-      DLL Debug
-      x64
-    
-    
-      DLL Release
-      Win32
-    
-    
-      DLL Release
-      x64
-    
-    
-      Release
-      Win32
-    
-    
-      Release
-      x64
-    
-  
-  
-    {E9FB0BA5-BA46-4A59-A953-39C18CD1DCB1}
-    server
-    Win32Proj
-  
-  
-  
-    Application
-    v110
-    Unicode
-    true
-  
-  
-    Application
-    v110
-    Unicode
-    true
-  
-  
-    Application
-    v110
-    Unicode
-    true
-  
-  
-    Application
-    v110
-    Unicode
-    true
-  
-  
-    Application
-    v110
-    Unicode
-  
-  
-    Application
-    v110
-    Unicode
-  
-  
-    Application
-    v110
-    Unicode
-  
-  
-    Application
-    v110
-    Unicode
-  
-  
-  
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-  
-    <_ProjectFileVersion>11.0.61030.0
-  
-  
-    $(SolutionDir)$(Configuration)\
-    $(Configuration)\obj\
-    true
-  
-  
-    $(SolutionDir)$(Configuration)\
-    $(Configuration)\obj\
-    true
-  
-  
-    true
-    $(SolutionDir)$(Platform)\$(Configuration)\
-    $(Platform)\$(Configuration)\obj\
-  
-  
-    true
-    $(SolutionDir)$(Platform)\$(Configuration)\
-    $(Platform)\$(Configuration)\obj\
-  
-  
-    $(SolutionDir)$(Configuration)\
-    $(Configuration)\obj\
-    false
-  
-  
-    $(SolutionDir)$(Configuration)\
-    $(Configuration)\obj\
-    false
-  
-  
-    false
-    $(SolutionDir)$(Platform)\$(Configuration)\
-    $(Platform)\$(Configuration)\obj\
-  
-  
-    false
-    $(SolutionDir)$(Platform)\$(Configuration)\
-    $(Platform)\$(Configuration)\obj\
-  
-  
-    
-      Disabled
-      ../../;%(AdditionalIncludeDirectories)
-      WIN32;_DEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)
-      true
-      EnableFastChecks
-      MultiThreadedDebugDLL
-      
-      Level3
-      EditAndContinue
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      MachineX86
-      false
-
-    
-  
-  
-    
-      Disabled
-      ../../;%(AdditionalIncludeDirectories)
-      WIN32;_DEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions)
-      true
-      EnableFastChecks
-      MultiThreadedDebugDLL
-      
-      
-      Level3
-      EditAndContinue
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      MachineX86
-    
-  
-  
-    
-      Disabled
-      ../../;%(AdditionalIncludeDirectories)
-      WIN32;_DEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)
-      EnableFastChecks
-      MultiThreadedDebugDLL
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-    
-  
-  
-    
-      Disabled
-      ../../;%(AdditionalIncludeDirectories)
-      WIN32;_DEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions)
-      EnableFastChecks
-      MultiThreadedDebugDLL
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-    
-  
-  
-    
-      MaxSpeed
-      true
-      ../../;%(AdditionalIncludeDirectories)
-      WIN32;NDEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)
-      MultiThreadedDLL
-      true
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      true
-      true
-      MachineX86
-      false
-
-    
-  
-  
-    
-      MaxSpeed
-      true
-      ../../;%(AdditionalIncludeDirectories)
-      WIN32;NDEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions)
-      MultiThreadedDLL
-      true
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      true
-      true
-      MachineX86
-    
-  
-  
-    
-      MaxSpeed
-      true
-      ../../;%(AdditionalIncludeDirectories)
-      WIN32;NDEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)
-      MultiThreadedDLL
-      true
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      true
-      true
-    
-  
-  
-    
-      MaxSpeed
-      true
-      ../../;%(AdditionalIncludeDirectories)
-      WIN32;NDEBUG;_CONSOLE;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions)
-      MultiThreadedDLL
-      true
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      true
-      true
-    
-  
-  
-    
-  
-  
-    
-      {73973223-5ee8-41ca-8e88-1d60e89a237b}
-      false
-    
-  
-  
-  
-  
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/gencertbuf.pl b/FreeRTOS-Plus/Source/WolfSSL/gencertbuf.pl
deleted file mode 100755
index d3d1166..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/gencertbuf.pl
+++ /dev/null
@@ -1,145 +0,0 @@
-#!/usr/bin/perl
-
-# gencertbuf.pl
-# version 1.1
-# Updated 07/01/2014
-#
-# Copyright (C) 2006-2015 wolfSSL Inc.
-#
-
-use strict;
-use warnings;
-
-# ---- SCRIPT SETTINGS -------------------------------------------------------
-
-# output C header file to write cert/key buffers to
-my $outputFile = "./wolfssl/certs_test.h";
-
-# 1024-bit certs/keys to be converted
-# Used with USE_CERT_BUFFERS_1024 define.
-
-my @fileList_1024 = (
-        [ "./certs/1024/client-key.der", "client_key_der_1024" ],
-        [ "./certs/1024/client-cert.der", "client_cert_der_1024" ],
-        [ "./certs/1024/dh1024.der", "dh_key_der_1024" ],
-        [ "./certs/1024/dsa1024.der", "dsa_key_der_1024" ],
-        [ "./certs/1024/rsa1024.der", "rsa_key_der_1024" ]
-        );
-
-# 2048-bit certs/keys to be converted
-# Used with USE_CERT_BUFFERS_2048 define.
-
-my @fileList_2048 = (
-        [ "./certs/client-key.der", "client_key_der_2048" ],
-        [ "./certs/client-cert.der", "client_cert_der_2048" ],
-        [ "./certs/dh2048.der", "dh_key_der_2048" ],
-        [ "./certs/dsa2048.der", "dsa_key_der_2048" ],
-        [ "./certs/rsa2048.der", "rsa_key_der_2048" ],
-        [ "./certs/ca-cert.der", "ca_cert_der_2048" ],
-        [ "./certs/server-key.der", "server_key_der_2048" ],
-        [ "./certs/server-cert.der", "server_cert_der_2048" ]
-        );
-
-# ----------------------------------------------------------------------------
-
-my $num_1024 = @fileList_1024;
-my $num_2048 = @fileList_2048;
-
-# open our output file, "+>" creates and/or truncates
-open OUT_FILE, "+>", $outputFile  or die $!;
-
-print OUT_FILE "/* certs_test.h */\n\n";
-print OUT_FILE "#ifndef WOLFSSL_CERTS_TEST_H\n";
-print OUT_FILE "#define WOLFSSL_CERTS_TEST_H\n\n";
-
-# convert and print 1024-bit cert/keys
-print OUT_FILE "#ifdef USE_CERT_BUFFERS_1024\n\n";
-for (my $i = 0; $i < $num_1024; $i++) {
-
-    my $fname = $fileList_1024[$i][0];
-    my $sname = $fileList_1024[$i][1];
-
-    print OUT_FILE "/* $fname, 1024-bit */\n";
-    print OUT_FILE "static const unsigned char $sname\[] =\n";
-    print OUT_FILE "{\n";
-    file_to_hex($fname);
-    print OUT_FILE "};\n";
-    print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
-}
-
-# convert and print 2048-bit certs/keys
-print OUT_FILE "#elif defined(USE_CERT_BUFFERS_2048)\n\n";
-for (my $i = 0; $i < $num_2048; $i++) {
-
-    my $fname = $fileList_2048[$i][0];
-    my $sname = $fileList_2048[$i][1];
-
-    print OUT_FILE "/* $fname, 2048-bit */\n";
-    print OUT_FILE "static const unsigned char $sname\[] =\n";
-    print OUT_FILE "{\n";
-    file_to_hex($fname);
-    print OUT_FILE "};\n";
-    print OUT_FILE "static const int sizeof_$sname = sizeof($sname);\n\n";
-}
-
-print OUT_FILE "#endif /* USE_CERT_BUFFERS_1024 */\n\n";
-print OUT_FILE "/* dh1024 p */
-static const unsigned char dh_p[] =
-{
-    0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3,
-    0xBD, 0xD4, 0x79, 0x8E, 0x91, 0xB7, 0x81, 0x82, 0x51, 0xBB, 0x05, 0x5E,
-    0x2A, 0x20, 0x64, 0x90, 0x4A, 0x79, 0xA7, 0x70, 0xFA, 0x15, 0xA2, 0x59,
-    0xCB, 0xD5, 0x23, 0xA6, 0xA6, 0xEF, 0x09, 0xC4, 0x30, 0x48, 0xD5, 0xA2,
-    0x2F, 0x97, 0x1F, 0x3C, 0x20, 0x12, 0x9B, 0x48, 0x00, 0x0E, 0x6E, 0xDD,
-    0x06, 0x1C, 0xBC, 0x05, 0x3E, 0x37, 0x1D, 0x79, 0x4E, 0x53, 0x27, 0xDF,
-    0x61, 0x1E, 0xBB, 0xBE, 0x1B, 0xAC, 0x9B, 0x5C, 0x60, 0x44, 0xCF, 0x02,
-    0x3D, 0x76, 0xE0, 0x5E, 0xEA, 0x9B, 0xAD, 0x99, 0x1B, 0x13, 0xA6, 0x3C,
-    0x97, 0x4E, 0x9E, 0xF1, 0x83, 0x9E, 0xB5, 0xDB, 0x12, 0x51, 0x36, 0xF7,
-    0x26, 0x2E, 0x56, 0xA8, 0x87, 0x15, 0x38, 0xDF, 0xD8, 0x23, 0xC6, 0x50,
-    0x50, 0x85, 0xE2, 0x1F, 0x0D, 0xD5, 0xC8, 0x6B,
-};
-
-/* dh1024 g */
-static const unsigned char dh_g[] =
-{
-  0x02,
-};\n\n\n";
-print OUT_FILE "#endif /* WOLFSSL_CERTS_TEST_H */\n\n";
-
-# close certs_test.h file
-close OUT_FILE or die $!;
-
-# print file as hex, comma-separated, as needed by C buffer
-sub file_to_hex {
-    my $fileName = $_[0];
-
-    open my $fp, "<", $fileName or die $!;
-    binmode($fp);
-
-    my $fileLen = -s $fileName;
-    my $byte;
-
-    for (my $i = 0, my $j = 1; $i < $fileLen; $i++, $j++)
-    {
-        if ($j == 1) {
-            print OUT_FILE "\t";
-        }
-        read($fp, $byte, 1) or die "Error reading $fileName";
-        my $output = sprintf("0x%02X", ord($byte));
-        print OUT_FILE $output;
-
-        if ($i != ($fileLen - 1)) {
-            print OUT_FILE ", ";
-        }
-
-        if ($j == 10) {
-            $j = 0;
-            print OUT_FILE "\n";
-        }
-    }
-
-    print OUT_FILE "\n";
-
-    close($fp); 
-}
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/input b/FreeRTOS-Plus/Source/WolfSSL/input
deleted file mode 100755
index 7364d4d..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/input
+++ /dev/null
@@ -1,87 +0,0 @@
-/* echoclient.c  */
-
-#include "openssl/ssl.h"
-#include "../test.h"
-
-
-int main(int argc, char** argv)
-{
-    SOCKET_T sockfd = 0;
-
-    FILE* fin  = stdin;
-    FILE* fout = stdout;
-
-    int inCreated  = 0;
-    int outCreated = 0;
-
-    char send[1024];
-    char reply[1024];
-
-    SSL_METHOD* method = 0;
-    SSL_CTX*    ctx    = 0;
-    SSL*        ssl    = 0;
-
-#ifdef _WIN32
-    WSADATA wsd;
-    WSAStartup(0x0002, &wsd);
-#endif
-
-    if (argc >= 2) {
-        fin  = fopen(argv[1], "r"); 
-        inCreated = 1;
-    }
-    if (argc >= 3) {
-        fout = fopen(argv[2], "w");
-        outCreated = 1;
-    }
-
-    if (!fin)  err_sys("can't open input file");
-    if (!fout) err_sys("can't open output file");
-
-    tcp_connect(&sockfd);
-
-    method = SSLv3_client_method();
-    ctx    = SSL_CTX_new(method);
-
-    if (SSL_CTX_load_verify_locations(ctx, caCert, 0) != SSL_SUCCESS)
-        err_sys("can't load ca file");
-
-    ssl = SSL_new(ctx);
-
-    SSL_set_fd(ssl, sockfd);
-    if (SSL_connect(ssl) != SSL_SUCCESS) err_sys("SSL_connect failed");
-
-    while (fgets(send, sizeof(send), fin)) {
-
-        int  sendSz = strlen(send) + 1;
-
-        if (SSL_write(ssl, send, sendSz) != sendSz)
-            err_sys("SSL_write failed");
-
-        if (strncmp(send, "quit", 4) == 0) {
-            fputs("sending server shutdown command: quit!\n", fout);
-            break;
-        }
-
-        if (SSL_read(ssl, reply, sizeof(reply)) > 0) 
-            fputs(reply, fout);
-    }
-
-    SSL_shutdown(ssl);
-    SSL_free(ssl);
-    SSL_CTX_free(ctx);
-
-    fflush(fout);
-    if (inCreated)  fclose(fin);
-    if (outCreated) fclose(fout);
-
-#ifdef _WIN32
-    closesocket(sockfd);
-#else
-    close(sockfd);
-#endif
-
-    return 0;
-}
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/lib/dummy b/FreeRTOS-Plus/Source/WolfSSL/lib/dummy
deleted file mode 100755
index 13c3b18..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/lib/dummy
+++ /dev/null
@@ -1,2 +0,0 @@
-// this is a dummy file
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_add_am_macro.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_add_am_macro.m4
deleted file mode 100755
index 51ce0d0..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_add_am_macro.m4
+++ /dev/null
@@ -1,29 +0,0 @@
-# ===========================================================================
-#      http://www.gnu.org/software/autoconf-archive/ax_add_am_macro.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_ADD_AM_MACRO([RULE])
-#
-# DESCRIPTION
-#
-#   Adds the specified rule to $AMINCLUDE. This macro will only work
-#   properly with implementations of Make which allow include statements.
-#   See also AX_ADD_AM_MACRO_STATIC.
-#
-# LICENSE
-#
-#   Copyright (c) 2009 Tom Howard 
-#
-#   Copying and distribution of this file, with or without modification, are
-#   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved. This file is offered as-is, without any
-#   warranty.
-
-#serial 9
-
-AC_DEFUN([AX_ADD_AM_MACRO],[
-  AC_REQUIRE([AX_AM_MACROS])
-  AX_APPEND_TO_FILE([$AMINCLUDE],[$1])
-])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_am_jobserver.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_am_jobserver.m4
deleted file mode 100755
index 5a398f8..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_am_jobserver.m4
+++ /dev/null
@@ -1,54 +0,0 @@
-# ===========================================================================
-#      http://www.gnu.org/software/autoconf-archive/ax_am_jobserver.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_AM_JOBSERVER([default_value])
-#
-# DESCRIPTION
-#
-#   Enables the use of make's jobserver for the purpose of parallel building
-#   by passing the -j option to make.
-#
-#   The option --enable-jobserver is added to configure which can accept a
-#   yes, no, or an integer. The integer is the number of separate jobs to
-#   allow. If 'yes' is given, then the is assumed to be one more than the
-#   number of CPUs (determined through AX_COUNT_CPUS). If the value of no is
-#   given, then the jobserver is disabled. The default value is given by the
-#   first argument of the macro, or 'yes' if the argument is omitted.
-#
-#   This macro makes use of AX_AM_MACROS, so you must add the following line
-#
-#     @INC_AMINCLUDE@
-#
-#   to your Makefile.am files.
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Michael Paul Bailey 
-#
-#   Copying and distribution of this file, with or without modification, are
-#   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved. This file is offered as-is, without any
-#   warranty.
-
-#serial 7.1
-
-AC_DEFUN([AX_AM_JOBSERVER], [
-    AC_REQUIRE([AX_COUNT_CPUS])
-    AC_REQUIRE([AX_AM_MACROS])
-    AC_ARG_ENABLE( jobserver,
-    [  --enable-jobserver@<:@=no/yes/@%:@@:>@ default=m4_ifval([$1],[$1],[yes])
-                        Enable up to @%:@ make jobs
-                        yes: enable one more than CPU count
-    ],, [enable_jobserver=m4_ifval([$1],[$1],[yes])])
-    if test "x$enable_jobserver" = "xyes"; then
-        let enable_jobserver=$CPU_COUNT+1
-    fi
-    m4_pattern_allow(AM_MAKEFLAGS)
-    if test "x$enable_jobserver" != "xno"; then
-        AC_MSG_NOTICE([added jobserver support to make for $enable_jobserver jobs])
-        AX_ADD_AM_MACRO( AM_MAKEFLAGS += -j$enable_jobserver )
-    fi
-])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_am_macros.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_am_macros.m4
deleted file mode 100755
index 6b4bd22..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_am_macros.m4
+++ /dev/null
@@ -1,44 +0,0 @@
-# ===========================================================================
-#       http://www.gnu.org/software/autoconf-archive/ax_am_macros.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_AM_MACROS
-#
-# DESCRIPTION
-#
-#   Adds support for macros that create Make rules. You must manually add
-#   the following line
-#
-#     @INC_AMINCLUDE@
-#
-#   to your Makefile.in (or Makefile.am if you use Automake) files.
-#
-# LICENSE
-#
-#   Copyright (c) 2009 Tom Howard 
-#
-#   Copying and distribution of this file, with or without modification, are
-#   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved. This file is offered as-is, without any
-#   warranty.
-
-#serial 9
-
-AC_DEFUN([AX_AM_MACROS],
-[
-AC_MSG_NOTICE([adding automake macro support])
-AMINCLUDE="aminclude.am"
-AC_SUBST(AMINCLUDE)
-AC_MSG_NOTICE([creating $AMINCLUDE])
-AMINCLUDE_TIME=`date`
-AX_PRINT_TO_FILE([$AMINCLUDE],[[
-# generated automatically by configure from AX_AUTOMAKE_MACROS
-# on $AMINCLUDE_TIME
-
-]])
-
-INC_AMINCLUDE="include \$(top_builddir)/$AMINCLUDE"
-AC_SUBST(INC_AMINCLUDE)
-])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_append_compile_flags.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_append_compile_flags.m4
deleted file mode 100755
index 1f8e708..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_append_compile_flags.m4
+++ /dev/null
@@ -1,65 +0,0 @@
-# ===========================================================================
-#  http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS])
-#
-# DESCRIPTION
-#
-#   For every FLAG1, FLAG2 it is checked whether the compiler works with the
-#   flag.  If it does, the flag is added FLAGS-VARIABLE
-#
-#   If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
-#   CFLAGS) is used.  During the check the flag is always added to the
-#   current language's flags.
-#
-#   If EXTRA-FLAGS is defined, it is added to the current language's default
-#   flags (e.g. CFLAGS) when the check is done.  The check is thus made with
-#   the flags: "CFLAGS EXTRA-FLAGS FLAG".  This can for example be used to
-#   force the compiler to issue an error when a bad flag is given.
-#
-#   NOTE: This macro depends on the AX_APPEND_FLAG and
-#   AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
-#   AX_APPEND_LINK_FLAGS.
-#
-# LICENSE
-#
-#   Copyright (c) 2011 Maarten Bosmans 
-#
-#   This program 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 3 of the License, or (at your
-#   option) any later version.
-#
-#   This program 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, see .
-#
-#   As a special exception, the respective Autoconf Macro's copyright owner
-#   gives unlimited permission to copy, distribute and modify the configure
-#   scripts that are the output of Autoconf when processing the Macro. You
-#   need not follow the terms of the GNU General Public License when using
-#   or distributing such scripts, even though portions of the text of the
-#   Macro appear in them. The GNU General Public License (GPL) does govern
-#   all other use of the material that constitutes the Autoconf Macro.
-#
-#   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Archive. When you make and distribute a
-#   modified version of the Autoconf Macro, you may extend this special
-#   exception to the GPL to apply to your modified version as well.
-
-#serial 3
-
-AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
-[AC_REQUIRE([AX_CHECK_COMPILE_FLAG])
-AC_REQUIRE([AX_APPEND_FLAG])
-for flag in $1; do
-  AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3])
-done
-])dnl AX_APPEND_COMPILE_FLAGS
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_append_flag.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_append_flag.m4
deleted file mode 100755
index 1d38b76..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_append_flag.m4
+++ /dev/null
@@ -1,69 +0,0 @@
-# ===========================================================================
-#      http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
-#
-# DESCRIPTION
-#
-#   FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
-#   added in between.
-#
-#   If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
-#   CFLAGS) is used.  FLAGS-VARIABLE is not changed if it already contains
-#   FLAG.  If FLAGS-VARIABLE is unset in the shell, it is set to exactly
-#   FLAG.
-#
-#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Guido U. Draheim 
-#   Copyright (c) 2011 Maarten Bosmans 
-#
-#   This program 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 3 of the License, or (at your
-#   option) any later version.
-#
-#   This program 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, see .
-#
-#   As a special exception, the respective Autoconf Macro's copyright owner
-#   gives unlimited permission to copy, distribute and modify the configure
-#   scripts that are the output of Autoconf when processing the Macro. You
-#   need not follow the terms of the GNU General Public License when using
-#   or distributing such scripts, even though portions of the text of the
-#   Macro appear in them. The GNU General Public License (GPL) does govern
-#   all other use of the material that constitutes the Autoconf Macro.
-#
-#   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Archive. When you make and distribute a
-#   modified version of the Autoconf Macro, you may extend this special
-#   exception to the GPL to apply to your modified version as well.
-
-#serial 2
-
-AC_DEFUN([AX_APPEND_FLAG],
-[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
-AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl
-AS_VAR_SET_IF(FLAGS,
-  [case " AS_VAR_GET(FLAGS) " in
-    *" $1 "*)
-      AC_RUN_LOG([: FLAGS already contains $1])
-      ;;
-    *)
-      AC_RUN_LOG([: FLAGS="$FLAGS $1"])
-      AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"])
-      ;;
-   esac],
-  [AS_VAR_SET(FLAGS,["$1"])])
-AS_VAR_POPDEF([FLAGS])dnl
-])dnl AX_APPEND_FLAG
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_append_to_file.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_append_to_file.m4
deleted file mode 100755
index f9f54e0..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_append_to_file.m4
+++ /dev/null
@@ -1,27 +0,0 @@
-# ===========================================================================
-#     http://www.gnu.org/software/autoconf-archive/ax_append_to_file.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_APPEND_TO_FILE([FILE],[DATA])
-#
-# DESCRIPTION
-#
-#   Appends the specified data to the specified file.
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Tom Howard 
-#
-#   Copying and distribution of this file, with or without modification, are
-#   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved. This file is offered as-is, without any
-#   warranty.
-
-#serial 8
-
-AC_DEFUN([AX_APPEND_TO_FILE],[
-AC_REQUIRE([AX_FILE_ESCAPES])
-printf "$2\n" >> "$1"
-])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_check_compile_flag.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_check_compile_flag.m4
deleted file mode 100755
index c3a8d69..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_check_compile_flag.m4
+++ /dev/null
@@ -1,72 +0,0 @@
-# ===========================================================================
-#   http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
-#
-# DESCRIPTION
-#
-#   Check whether the given FLAG works with the current language's compiler
-#   or gives an error.  (Warnings, however, are ignored)
-#
-#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
-#   success/failure.
-#
-#   If EXTRA-FLAGS is defined, it is added to the current language's default
-#   flags (e.g. CFLAGS) when the check is done.  The check is thus made with
-#   the flags: "CFLAGS EXTRA-FLAGS FLAG".  This can for example be used to
-#   force the compiler to issue an error when a bad flag is given.
-#
-#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
-#   macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Guido U. Draheim 
-#   Copyright (c) 2011 Maarten Bosmans 
-#
-#   This program 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 3 of the License, or (at your
-#   option) any later version.
-#
-#   This program 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, see .
-#
-#   As a special exception, the respective Autoconf Macro's copyright owner
-#   gives unlimited permission to copy, distribute and modify the configure
-#   scripts that are the output of Autoconf when processing the Macro. You
-#   need not follow the terms of the GNU General Public License when using
-#   or distributing such scripts, even though portions of the text of the
-#   Macro appear in them. The GNU General Public License (GPL) does govern
-#   all other use of the material that constitutes the Autoconf Macro.
-#
-#   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Archive. When you make and distribute a
-#   modified version of the Autoconf Macro, you may extend this special
-#   exception to the GPL to apply to your modified version as well.
-
-#serial 2
-
-AC_DEFUN([AX_CHECK_COMPILE_FLAG],
-[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
-AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
-AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
-  ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
-  _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
-  AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-    [AS_VAR_SET(CACHEVAR,[yes])],
-    [AS_VAR_SET(CACHEVAR,[no])])
-  _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
-AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
-  [m4_default([$2], :)],
-  [m4_default([$3], :)])
-AS_VAR_POPDEF([CACHEVAR])dnl
-])dnl AX_CHECK_COMPILE_FLAGS
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_check_link_flag.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_check_link_flag.m4
deleted file mode 100755
index e2d0d36..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_check_link_flag.m4
+++ /dev/null
@@ -1,71 +0,0 @@
-# ===========================================================================
-#    http://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
-#
-# DESCRIPTION
-#
-#   Check whether the given FLAG works with the linker or gives an error.
-#   (Warnings, however, are ignored)
-#
-#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
-#   success/failure.
-#
-#   If EXTRA-FLAGS is defined, it is added to the linker's default flags
-#   when the check is done.  The check is thus made with the flags: "LDFLAGS
-#   EXTRA-FLAGS FLAG".  This can for example be used to force the linker to
-#   issue an error when a bad flag is given.
-#
-#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
-#   macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Guido U. Draheim 
-#   Copyright (c) 2011 Maarten Bosmans 
-#
-#   This program 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 3 of the License, or (at your
-#   option) any later version.
-#
-#   This program 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, see .
-#
-#   As a special exception, the respective Autoconf Macro's copyright owner
-#   gives unlimited permission to copy, distribute and modify the configure
-#   scripts that are the output of Autoconf when processing the Macro. You
-#   need not follow the terms of the GNU General Public License when using
-#   or distributing such scripts, even though portions of the text of the
-#   Macro appear in them. The GNU General Public License (GPL) does govern
-#   all other use of the material that constitutes the Autoconf Macro.
-#
-#   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Archive. When you make and distribute a
-#   modified version of the Autoconf Macro, you may extend this special
-#   exception to the GPL to apply to your modified version as well.
-
-#serial 2
-
-AC_DEFUN([AX_CHECK_LINK_FLAG],
-[AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
-AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
-  ax_check_save_flags=$LDFLAGS
-  LDFLAGS="$LDFLAGS $4 $1"
-  AC_LINK_IFELSE([AC_LANG_PROGRAM()],
-    [AS_VAR_SET(CACHEVAR,[yes])],
-    [AS_VAR_SET(CACHEVAR,[no])])
-  LDFLAGS=$ax_check_save_flags])
-AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
-  [m4_default([$2], :)],
-  [m4_default([$3], :)])
-AS_VAR_POPDEF([CACHEVAR])dnl
-])dnl AX_CHECK_LINK_FLAGS
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_count_cpus.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_count_cpus.m4
deleted file mode 100755
index d4f3d29..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_count_cpus.m4
+++ /dev/null
@@ -1,57 +0,0 @@
-# ===========================================================================
-#       http://www.gnu.org/software/autoconf-archive/ax_count_cpus.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_COUNT_CPUS
-#
-# DESCRIPTION
-#
-#   Attempt to count the number of processors present on the machine. If the
-#   detection fails, then a value of 1 is assumed.
-#
-#   The value is placed in the CPU_COUNT variable.
-#
-# LICENSE
-#
-#   Copyright (c) 2012 Brian Aker 
-#   Copyright (c) 2008 Michael Paul Bailey 
-#   Copyright (c) 2008 Christophe Tournayre 
-#
-#   Copying and distribution of this file, with or without modification, are
-#   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved. This file is offered as-is, without any
-#   warranty.
-
-#serial 10
-
-  AC_DEFUN([AX_COUNT_CPUS],[
-      AC_REQUIRE([AC_CANONICAL_HOST])
-      AC_REQUIRE([AC_PROG_EGREP])
-      AC_MSG_CHECKING([the number of available CPUs])
-      CPU_COUNT="0"
-
-      AS_CASE([$host_os],[
-        *darwin*],[
-        AS_IF([test -x /usr/sbin/sysctl],[
-          sysctl_a=`/usr/sbin/sysctl -a 2>/dev/null| grep -c hw.cpu`
-          AS_IF([test sysctl_a],[
-            CPU_COUNT=`/usr/sbin/sysctl -n hw.ncpu`
-            ])
-          ])],[
-        *linux*],[
-        AS_IF([test "x$CPU_COUNT" = "x0" -a -e /proc/cpuinfo],[
-          AS_IF([test "x$CPU_COUNT" = "x0" -a -e /proc/cpuinfo],[
-            CPU_COUNT=`$EGREP -c '^processor' /proc/cpuinfo`
-            ])
-          ])
-        ])
-
-      AS_IF([test "x$CPU_COUNT" = "x0"],[
-        CPU_COUNT="1"
-        AC_MSG_RESULT( [unable to detect (assuming 1)] )
-        ],[
-        AC_MSG_RESULT( $CPU_COUNT )
-        ])
-      ])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_create_generic_config.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_create_generic_config.m4
deleted file mode 100755
index 535838f..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_create_generic_config.m4
+++ /dev/null
@@ -1,195 +0,0 @@
-# ============================================================================
-#  http://www.gnu.org/software/autoconf-archive/ax_create_generic_config.html
-# ============================================================================
-#
-# SYNOPSIS
-#
-#   AX_CREATE_GENERIC_CONFIG [(PACKAGEnlibs [, VERSION])]
-#
-# DESCRIPTION
-#
-#   Creates a generic PACKAGE-config file that has all the things that you
-#   want, hmm, well, atleast it has --cflags, --version, --libs. Ahhm, did
-#   you see ax_path_generic in the autoconf-archive? ;-)
-#
-#   this macros saves you all the typing for a pkg-config.in script, you
-#   don't even need to distribute one along. Place this macro in your
-#   configure.ac, et voila, you got one that you want to install.
-#
-#   oh, btw, if the first arg looks like "mylib -lwhat' then it will go to
-#   be added to the --libs, and mylib is extracted.
-#
-#   the defaults: $1 = $PACKAGE $LIBS $2 = $VERSION there is also an
-#   AC_SUBST(GENERIC_CONFIG) that will be set to the name of the file that
-#   we did output in this macro. Use as:
-#
-#    install-exec-local:    install-generic-config
-#
-#    install-generic-config:
-#       $(mkinstalldirs) $(DESTDIR)$(bindir)
-#       $(INSTALL_SCRIPT) @GENERIC_CONFIG@ $(DESTDIR)$(bindir)
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Guido U. Draheim 
-#
-#   This program 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 3 of the License, or (at your
-#   option) any later version.
-#
-#   This program 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, see .
-#
-#   As a special exception, the respective Autoconf Macro's copyright owner
-#   gives unlimited permission to copy, distribute and modify the configure
-#   scripts that are the output of Autoconf when processing the Macro. You
-#   need not follow the terms of the GNU General Public License when using
-#   or distributing such scripts, even though portions of the text of the
-#   Macro appear in them. The GNU General Public License (GPL) does govern
-#   all other use of the material that constitutes the Autoconf Macro.
-#
-#   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Archive. When you make and distribute a
-#   modified version of the Autoconf Macro, you may extend this special
-#   exception to the GPL to apply to your modified version as well.
-
-#serial 6
-
-AU_ALIAS([AC_CREATE_GENERIC_CONFIG], [AX_CREATE_GENERIC_CONFIG])
-AC_DEFUN([AX_CREATE_GENERIC_CONFIG],[# create a generic PACKAGE-config file
-L=`echo ifelse($1, , $PACKAGE $LIBS, $1)`
-P=`echo $L | sed -e 's/ -.*//'`
-P=`echo $P`
-V=`echo ifelse($2, , $VERSION, $2)`
-F=`echo $P-config`
-L=`echo -l$L | sed -e 's/^-llib/-l/'`
-AC_MSG_RESULT(creating $F - generic $V for $L)
-test "x$prefix" = xNONE && prefix="$ac_default_prefix"
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-echo '#! /bin/sh' >$F
-echo ' ' >>$F
-echo 'package="'$P'"' >>$F
-echo 'version="'$V'"' >>$F
-echo 'libs="'$L'"' >>$F
-echo ' ' >>$F
-# in the order of occurence a standard automake Makefile
-echo 'prefix="'$prefix'"' >>$F
-echo 'exec_prefix="'$exec_prefix'"' >>$F
-echo 'bindir="'$bindir'"' >>$F
-echo 'sbindir="'$sbindir'"' >>$F
-echo 'libexecdir="'$libexecdir'"' >>$F
-echo 'datadir="'$datadir'"' >>$F
-echo 'sysconfdir="'$sysconfdir'"' >>$F
-echo 'sharedstatedir="'$sharedstatedir'"' >>$F
-echo 'localstatedir="'$localstatedir'"' >>$F
-echo 'libdir="'$libdir'"' >>$F
-echo 'infodir="'$infodir'"' >>$F
-echo 'mandir="'$mandir'"' >>$F
-echo 'includedir="'$includedir'"' >>$F
-echo 'target="'$target'"' >>$F
-echo 'host="'$host'"' >>$F
-echo 'build="'$build'"' >>$F
-echo ' ' >>$F
-echo 'if test "'"\$""#"'" -eq 0; then' >>$F
-echo '   cat <>$F
-echo 'Usage: $package-config [OPTIONS]' >>$F
-echo 'Options:' >>$F
-echo '  --prefix[=DIR]) : \$prefix' >>$F
-echo '  --package) : \$package' >>$F
-echo '  --version) : \$version' >>$F
-echo '  --cflags) : -I\$includedir' >>$F
-echo '  --libs) : -L\$libdir -l\$package' >>$F
-echo '  --help) print all the options (not just these)' >>$F
-echo 'EOF' >>$F
-echo 'fi' >>$F
-echo ' ' >>$F
-echo 'o=""' >>$F
-echo 'h=""' >>$F
-echo 'for i in "[$]@"; do' >>$F
-echo '  case $i in' >>$F
-echo '  --prefix=*) prefix=`echo $i | sed -e "s/--prefix=//"` ;;' >>$F
-echo '  --prefix)    o="$o $prefix" ;;' >>$F
-echo '  --package)   o="$o $package" ;;' >>$F
-echo '  --version)   o="$o $version" ;;' >>$F
-echo '  --cflags) if test "_$includedir" != "_/usr/include"' >>$F
-echo '          then o="$o -I$includedir" ; fi' >>$F
-echo '  ;;' >>$F
-echo '  --libs)      o="$o -L$libdir $libs" ;;' >>$F
-echo '  --exec_prefix|--eprefix) o="$o $exec_prefix" ;;' >>$F
-echo '  --bindir)                o="$o $bindir" ;;' >>$F
-echo '  --sbindir)               o="$o $sbindir" ;;' >>$F
-echo '  --libexecdir)            o="$o $libexecdir" ;;' >>$F
-echo '  --datadir)               o="$o $datadir" ;;' >>$F
-echo '  --datainc)               o="$o -I$datadir" ;;' >>$F
-echo '  --datalib)               o="$o -L$datadir" ;;' >>$F
-echo '  --sysconfdir)            o="$o $sysconfdir" ;;' >>$F
-echo '  --sharedstatedir)        o="$o $sharedstatedir" ;;' >>$F
-echo '  --localstatedir)         o="$o $localstatedir" ;;' >>$F
-echo '  --libdir)                o="$o $libdir" ;;' >>$F
-echo '  --libadd)                o="$o -L$libdir" ;;' >>$F
-echo '  --infodir)               o="$o $infodir" ;;' >>$F
-echo '  --mandir)                o="$o $mandir" ;;' >>$F
-echo '  --target)                o="$o $target" ;;' >>$F
-echo '  --host)                  o="$o $host" ;;' >>$F
-echo '  --build)                 o="$o $build" ;;' >>$F
-echo '  --data)                  o="$o -I$datadir/$package" ;;' >>$F
-echo '  --pkgdatadir)            o="$o $datadir/$package" ;;' >>$F
-echo '  --pkgdatainc)            o="$o -I$datadir/$package" ;;' >>$F
-echo '  --pkgdatalib)            o="$o -L$datadir/$package" ;;' >>$F
-echo '  --pkglibdir)             o="$o $libdir/$package" ;;' >>$F
-echo '  --pkglibinc)             o="$o -I$libinc/$package" ;;' >>$F
-echo '  --pkglibadd)             o="$o -L$libadd/$package" ;;' >>$F
-echo '  --pkgincludedir)         o="$o $includedir/$package" ;;' >>$F
-echo '  --help) h="1" ;;' >>$F
-echo '  -?//*|-?/*//*|-?./*//*|//*|/*//*|./*//*) ' >>$F
-echo '       v=`echo $i | sed -e s://:\$:g`' >>$F
-echo '       v=`eval "echo $v"` ' >>$F
-echo '       o="$o $v" ;; ' >>$F
-echo '  esac' >>$F
-echo 'done' >>$F
-echo ' ' >>$F
-echo 'o=`eval "echo $o"`' >>$F
-echo 'o=`eval "echo $o"`' >>$F
-echo 'eval "echo $o"' >>$F
-echo ' ' >>$F
-echo 'if test ! -z "$h" ; then ' >>$F
-echo 'cat <>$F
-echo '  --prefix=xxx)      (what is that for anyway?)' >>$F
-echo '  --prefix)         \$prefix        $prefix' >>$F
-echo '  --package)        \$package       $package' >>$F
-echo '  --version)        \$version       $version' >>$F
-echo '  --cflags)         -I\$includedir    unless it is /usr/include' >>$F
-echo '  --libs)           -L\$libdir -l\$PACKAGE \$LIBS' >>$F
-echo '  --exec_prefix) or... ' >>$F
-echo '  --eprefix)        \$exec_prefix   $exec_prefix' >>$F
-echo '  --bindir)         \$bindir        $bindir' >>$F
-echo '  --sbindir)        \$sbindir       $sbindir' >>$F
-echo '  --libexecdir)     \$libexecdir    $libexecdir' >>$F
-echo '  --datadir)        \$datadir       $datadir' >>$F
-echo '  --sysconfdir)     \$sysconfdir    $sysconfdir' >>$F
-echo '  --sharedstatedir) \$sharedstatedir$sharedstatedir' >>$F
-echo '  --localstatedir)  \$localstatedir $localstatedir' >>$F
-echo '  --libdir)         \$libdir        $libdir' >>$F
-echo '  --infodir)        \$infodir       $infodir' >>$F
-echo '  --mandir)         \$mandir        $mandir' >>$F
-echo '  --target)         \$target        $target' >>$F
-echo '  --host)           \$host          $host' >>$F
-echo '  --build)          \$build         $build' >>$F
-echo '  --data)           -I\$datadir/\$package' >>$F
-echo '  --pkgdatadir)     \$datadir/\$package' >>$F
-echo '  --pkglibdir)      \$libdir/\$package' >>$F
-echo '  --pkgincludedir)  \$includedir/\$package' >>$F
-echo '  --help)           generated by ax_create_generic_config.m4' >>$F
-echo '  -I//varname and other inc-targets like --pkgdatainc supported' >>$F
-echo '  -L//varname and other lib-targets, e.g. --pkgdatalib or --libadd' >>$F
-echo 'EOF' >>$F
-echo 'fi' >>$F
-GENERIC_CONFIG="$F"
-AC_SUBST(GENERIC_CONFIG)
-])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_debug.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_debug.m4
deleted file mode 100755
index 94e4c9c..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_debug.m4
+++ /dev/null
@@ -1,63 +0,0 @@
-# ===========================================================================
-#      https://github.com/BrianAker/ddm4/
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_DEBUG()
-#
-# DESCRIPTION
-#
-#   --enable-debug
-#
-# LICENSE
-#
-#  Copyright (C) 2012 Brian Aker
-#  All rights reserved.
-#  
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions are
-#  met:
-#  
-#      * Redistributions of source code must retain the above copyright
-#  notice, this list of conditions and the following disclaimer.
-#  
-#      * Redistributions in binary form must reproduce the above
-#  copyright notice, this list of conditions and the following disclaimer
-#  in the documentation and/or other materials provided with the
-#  distribution.
-#  
-#      * The names of its contributors may not be used to endorse or
-#  promote products derived from this software without specific prior
-#  written permission.
-#  
-#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#serial 6.1
-
-AC_DEFUN([AX_DEBUG],
-    [AC_PREREQ([2.63])dnl
-    AC_ARG_ENABLE([debug],
-      [AS_HELP_STRING([--enable-debug],
-        [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])],
-      [ax_enable_debug=$enableval],
-      [ax_enable_debug=no])
-
-	AS_IF([test "x$ax_enable_debug" = xyes],
-		[AC_DEFINE([DEBUG],[1],[Define to 1 to enable debugging code.])],
-		[AC_SUBST([MCHECK])
-         AC_DEFINE([DEBUG],[0],[Define to 1 to enable debugging code.])])
-
-    AC_MSG_CHECKING([for debug])
-    AC_MSG_RESULT([$ax_enable_debug])
-    AM_CONDITIONAL([DEBUG],[test "x${ax_enable_debug}" = xyes])])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_file_escapes.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_file_escapes.m4
deleted file mode 100755
index f4c6a06..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_file_escapes.m4
+++ /dev/null
@@ -1,30 +0,0 @@
-# ===========================================================================
-#      http://www.gnu.org/software/autoconf-archive/ax_file_escapes.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_FILE_ESCAPES
-#
-# DESCRIPTION
-#
-#   Writes the specified data to the specified file.
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Tom Howard 
-#
-#   Copying and distribution of this file, with or without modification, are
-#   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved. This file is offered as-is, without any
-#   warranty.
-
-#serial 7
-
-AC_DEFUN([AX_FILE_ESCAPES],[
-AX_DOLLAR="\$"
-AX_SRB="\\135"
-AX_SLB="\\133"
-AX_BS="\\\\"
-AX_DQ="\""
-])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_harden_compiler_flags.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_harden_compiler_flags.m4
deleted file mode 100755
index 018ffcb..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_harden_compiler_flags.m4
+++ /dev/null
@@ -1,235 +0,0 @@
-# ===========================================================================
-#      https://github.com/BrianAker/ddm4/
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_HARDEN_COMPILER_FLAGS()
-#   AX_HARDEN_LINKER_FLAGS()
-#   AX_HARDEN_CC_COMPILER_FLAGS()
-#   AX_HARDEN_CXX_COMPILER_FLAGS()
-#
-# DESCRIPTION
-#
-#   Any compiler flag that "hardens" or tests code. C99 is assumed.
-#
-#   NOTE: Implementation based on AX_APPEND_FLAG.
-#
-# LICENSE
-#
-#  Copyright (C) 2012 Brian Aker
-#  All rights reserved.
-#  
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions are
-#  met:
-#  
-#      * Redistributions of source code must retain the above copyright
-#  notice, this list of conditions and the following disclaimer.
-#  
-#      * Redistributions in binary form must reproduce the above
-#  copyright notice, this list of conditions and the following disclaimer
-#  in the documentation and/or other materials provided with the
-#  distribution.
-#  
-#      * The names of its contributors may not be used to endorse or
-#  promote products derived from this software without specific prior
-#  written permission.
-#  
-#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# The Following flags are not checked for
-# -Wdeclaration-after-statement is counter to C99
-# AX_APPEND_COMPILE_FLAGS([-std=c++11]) -- Not ready yet
-# AX_APPEND_COMPILE_FLAGS([-pedantic]) -- ?
-# AX_APPEND_COMPILE_FLAGS([-Wstack-protector]) -- Issues on 32bit compile
-# AX_APPEND_COMPILE_FLAGS([-fstack-protector-all]) -- Issues on 32bit compile
-# AX_APPEND_COMPILE_FLAGS([-Wlong-long]) -- Don't turn on for compatibility issues memcached_stat_st
-# AX_APPEND_COMPILE_FLAGS([-Wold-style-definition],,[$ax_append_compile_cflags_extra])
-# AX_APPEND_COMPILE_FLAGS([-std=c99],,[$ax_append_compile_cflags_extra])
-# AX_APPEND_COMPILE_FLAGS([-Wlogical-op],,[$ax_append_compile_cflags_extra])
-# AX_APPEND_COMPILE_FLAGS([-fstack-check],,[$ax_append_compile_cflags_extra]) -- problems with fastmath stack size checks
-# AX_APPEND_COMPILE_FLAGS([-floop-parallelize-all],,[$ax_append_compile_cflags_extra]) -- causes RSA verify problem on x64
-# AX_APPEND_COMPILE_FLAGS([-Wunreachable-code],,[$ax_append_compile_cflags_extra])  -- older clang and when gcc had it are buggy
-
-#serial 4.1
-
-  AC_DEFUN([AX_HARDEN_LINKER_FLAGS], [
-      AC_REQUIRE([AX_VCS_CHECKOUT])
-      AC_REQUIRE([AX_DEBUG])
-
-      dnl If we are inside of VCS we append -Werror, otherwise we just use it to test other flags
-      AX_HARDEN_LIB=
-      ax_append_compile_link_flags_extra=
-      AS_IF([test "x$ac_cv_vcs_checkout" = "xyes"],[
-        AX_CHECK_LINK_FLAG([-Werror],[
-          AX_HARDEN_LIB="-Werror $AX_HARDEN_LIB"
-          ])
-        ],[
-        AX_CHECK_LINK_FLAG([-Werror],[
-          ax_append_compile_link_flags_extra='-Werror'
-          ])
-        ])
-
-      AX_CHECK_LINK_FLAG([-z relro -z now],[
-        AX_HARDEN_LIB="-z relro -z now $AX_HARDEN_LIB"
-        ],,[$ax_append_compile_link_flags_extra])
-
-      AX_CHECK_LINK_FLAG([-pie],[
-          AX_HARDEN_LIB="-pie $AX_HARDEN_LIB"
-          ],,[$ax_append_compile_link_flags_extra])
-
-      LIB="$LIB $AX_HARDEN_LIB"
-      ])
-
-  AC_DEFUN([AX_HARDEN_CC_COMPILER_FLAGS], [
-      AC_REQUIRE([AX_HARDEN_LINKER_FLAGS])
-
-      AC_LANG_PUSH([C])
-
-      CFLAGS=
-      ac_cv_warnings_as_errors=no
-      ax_append_compile_cflags_extra=
-      AS_IF([test "$ac_cv_vcs_checkout" = "yes"],[
-        AX_APPEND_COMPILE_FLAGS([-Werror])
-        ac_cv_warnings_as_errors=yes
-        ],[
-        AX_APPEND_COMPILE_FLAGS([-Werror],[ax_append_compile_cflags_extra])
-        ])
-
-      AS_IF([test "$ax_enable_debug" = "yes"], [
-        AX_APPEND_COMPILE_FLAGS([-g])
-        AX_APPEND_COMPILE_FLAGS([-ggdb],,[$ax_append_compile_cflags_extra])
-        AX_APPEND_COMPILE_FLAGS([-O0],,[$ax_append_compile_cflags_extra])
-        ],[])
-
-      AX_APPEND_COMPILE_FLAGS([-Wno-pragmas],,[$ax_append_compile_cflags_extra])
-
-      AX_APPEND_COMPILE_FLAGS([-Wall],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wno-strict-aliasing],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wextra],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wunknown-pragmas],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wthis-test-should-fail],,[$ax_append_compile_cflags_extra])
-      dnl Anything below this comment please keep sorted.
-      AS_IF([test "$CC" = "clang"],[],[
-        AX_APPEND_COMPILE_FLAGS([--param=ssp-buffer-size=1],,[$ax_append_compile_cflags_extra])
-        ])
-      AX_APPEND_COMPILE_FLAGS([-Waddress],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Warray-bounds],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wbad-function-cast],,[$ax_append_compile_cflags_extra])
-      dnl Not in use -Wc++-compat
-      AX_APPEND_COMPILE_FLAGS([-Wchar-subscripts],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wcomment],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wfloat-equal],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wformat-security],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wformat=2],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wmaybe-uninitialized],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wmissing-field-initializers],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wmissing-noreturn],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wnested-externs],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wnormalized=id],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Woverride-init],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wpointer-arith],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wpointer-sign],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wredundant-decls],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wshadow],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wsign-compare],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wstrict-overflow=1],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wswitch-enum],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wundef],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wunused],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wunused-result],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wunused-variable],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wwrite-strings],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-fwrapv],,[$ax_append_compile_cflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-fPIE],,[$ax_append_compile_cflags_extra])
-      AC_LANG_POP
-      ])
-
-  AC_DEFUN([AX_HARDEN_CXX_COMPILER_FLAGS], [
-      AC_REQUIRE([AX_HARDEN_CC_COMPILER_FLAGS])
-      AC_LANG_PUSH([C++])
-
-      ax_append_compile_cxxflags_extra=
-      AS_IF([test "$ac_cv_warnings_as_errors" = "yes"],[
-        AX_APPEND_COMPILE_FLAGS([-Werror])
-        ],[
-        AX_APPEND_COMPILE_FLAGS([-Werror],[ax_append_compile_cxxflags_extra])
-        ])
-
-      AS_IF([test "$ax_enable_debug" = "yes" ], [
-        AX_APPEND_COMPILE_FLAGS([-g],,[$ax_append_compile_cxxflags_extra])
-        AX_APPEND_COMPILE_FLAGS([-O0],,[$ax_append_compile_cxxflags_extra])
-        AX_APPEND_COMPILE_FLAGS([-ggdb],,[$ax_append_compile_cxxflags_extra])
-        ],[
-        AX_APPEND_COMPILE_FLAGS([-D_FORTIFY_SOURCE=2],,[$ax_append_compile_cxxflags_extra])
-        ])
-
-      AS_IF([test "$ac_cv_vcs_checkout" = "yes" ], [
-        AX_APPEND_COMPILE_FLAGS([-Werror],,[$ax_append_compile_cxxflags_extra])
-        ],[
-        AX_APPEND_COMPILE_FLAGS([-Wno-pragmas],,[$ax_append_compile_cxxflags_extra])
-        ])
-
-      AX_APPEND_COMPILE_FLAGS([-Wall],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wno-strict-aliasing],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wextra],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wunknown-pragmas],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wthis-test-should-fail],,[$ax_append_compile_cxxflags_extra])
-      dnl Anything below this comment please keep sorted.
-      AX_APPEND_COMPILE_FLAGS([--param=ssp-buffer-size=1],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Waddress],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Warray-bounds],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wchar-subscripts],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wcomment],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wctor-dtor-privacy],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wfloat-equal],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wformat=2],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wmaybe-uninitialized],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wmissing-field-initializers],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wmissing-noreturn],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wnon-virtual-dtor],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wnormalized=id],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Woverloaded-virtual],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wpointer-arith],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wredundant-decls],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wshadow],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wsign-compare],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wstrict-overflow=1],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wswitch-enum],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wundef],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wc++11-compat],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wunused],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wunused-result],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wunused-variable],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wwrite-strings],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-Wformat-security],,[$ax_append_compile_cxxflags_extra])
-      AX_APPEND_COMPILE_FLAGS([-fwrapv],,[$ax_append_compile_cxxflags_extra])
-      AC_LANG_POP
-  ])
-
-  AC_DEFUN([AX_HARDEN_COMPILER_FLAGS], [
-      AC_REQUIRE([AX_HARDEN_CXX_COMPILER_FLAGS])
-      ])
-
-  AC_DEFUN([AX_CC_OTHER_FLAGS], [
-      AC_REQUIRE([AX_HARDEN_CC_COMPILER_FLAGS])
-
-      AC_LANG_PUSH([C])
-      AX_APPEND_COMPILE_FLAGS([-pipe],,[$ax_append_compile_cflags_extra])
-      AC_LANG_POP
-      ])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_print_to_file.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_print_to_file.m4
deleted file mode 100755
index 5b9d1c3..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_print_to_file.m4
+++ /dev/null
@@ -1,27 +0,0 @@
-# ===========================================================================
-#     http://www.gnu.org/software/autoconf-archive/ax_print_to_file.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_PRINT_TO_FILE([FILE],[DATA])
-#
-# DESCRIPTION
-#
-#   Writes the specified data to the specified file.
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Tom Howard 
-#
-#   Copying and distribution of this file, with or without modification, are
-#   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved. This file is offered as-is, without any
-#   warranty.
-
-#serial 7
-
-AC_DEFUN([AX_PRINT_TO_FILE],[
-AC_REQUIRE([AX_FILE_ESCAPES])
-printf "$2" > "$1"
-])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_pthread.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_pthread.m4
deleted file mode 100755
index bdb34b0..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_pthread.m4
+++ /dev/null
@@ -1,320 +0,0 @@
-# ===========================================================================
-#        http://www.gnu.org/software/autoconf-archive/ax_pthread.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
-#
-# DESCRIPTION
-#
-#   This macro figures out how to build C programs using POSIX threads. It
-#   sets the PTHREAD_LIBS output variable to the threads library and linker
-#   flags, and the PTHREAD_CFLAGS output variable to any special C compiler
-#   flags that are needed. (The user can also force certain compiler
-#   flags/libs to be tested by setting these environment variables.)
-#
-#   Also sets PTHREAD_CC to any special C compiler that is needed for
-#   multi-threaded programs (defaults to the value of CC otherwise). (This
-#   is necessary on AIX to use the special cc_r compiler alias.)
-#
-#   NOTE: You are assumed to not only compile your program with these flags,
-#   but also link it with them as well. e.g. you should link with
-#   $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
-#
-#   If you are only building threads programs, you may wish to use these
-#   variables in your default LIBS, CFLAGS, and CC:
-#
-#     LIBS="$PTHREAD_LIBS $LIBS"
-#     CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-#     CC="$PTHREAD_CC"
-#
-#   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
-#   has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
-#   (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
-#
-#   Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
-#   PTHREAD_PRIO_INHERIT symbol is defined when compiling with
-#   PTHREAD_CFLAGS.
-#
-#   ACTION-IF-FOUND is a list of shell commands to run if a threads library
-#   is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
-#   is not found. If ACTION-IF-FOUND is not specified, the default action
-#   will define HAVE_PTHREAD.
-#
-#   Please let the authors know if this macro fails on any platform, or if
-#   you have any other suggestions or comments. This macro was based on work
-#   by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
-#   from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
-#   Alejandro Forero Cuervo to the autoconf macro repository. We are also
-#   grateful for the helpful feedback of numerous users.
-#
-#   Updated for Autoconf 2.68 by Daniel Richard G.
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Steven G. Johnson 
-#   Copyright (c) 2011 Daniel Richard G. 
-#
-#   This program 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 3 of the License, or (at your
-#   option) any later version.
-#
-#   This program 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, see .
-#
-#   As a special exception, the respective Autoconf Macro's copyright owner
-#   gives unlimited permission to copy, distribute and modify the configure
-#   scripts that are the output of Autoconf when processing the Macro. You
-#   need not follow the terms of the GNU General Public License when using
-#   or distributing such scripts, even though portions of the text of the
-#   Macro appear in them. The GNU General Public License (GPL) does govern
-#   all other use of the material that constitutes the Autoconf Macro.
-#
-#   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Archive. When you make and distribute a
-#   modified version of the Autoconf Macro, you may extend this special
-#   exception to the GPL to apply to your modified version as well.
-
-#serial 20
-
-AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
-AC_DEFUN([AX_PTHREAD], [
-AC_REQUIRE([AC_CANONICAL_HOST])
-AC_LANG_PUSH([C])
-ax_pthread_ok=no
-
-# We used to check for pthread.h first, but this fails if pthread.h
-# requires special compiler flags (e.g. on True64 or Sequent).
-# It gets checked for in the link test anyway.
-
-# First of all, check if the user has set any of the PTHREAD_LIBS,
-# etcetera environment variables, and if threads linking works using
-# them:
-if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
-        save_CFLAGS="$CFLAGS"
-        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-        save_LIBS="$LIBS"
-        LIBS="$PTHREAD_LIBS $LIBS"
-        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
-        AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes)
-        AC_MSG_RESULT($ax_pthread_ok)
-        if test x"$ax_pthread_ok" = xno; then
-                PTHREAD_LIBS=""
-                PTHREAD_CFLAGS=""
-        fi
-        LIBS="$save_LIBS"
-        CFLAGS="$save_CFLAGS"
-fi
-
-# We must check for the threads library under a number of different
-# names; the ordering is very important because some systems
-# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
-# libraries is broken (non-POSIX).
-
-# Create a list of thread flags to try.  Items starting with a "-" are
-# C compiler flags, and other items are library names, except for "none"
-# which indicates that we try without any flags at all, and "pthread-config"
-# which is a program returning the flags for the Pth emulation library.
-
-ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
-
-# The ordering *is* (sometimes) important.  Some notes on the
-# individual items follow:
-
-# pthreads: AIX (must check this before -lpthread)
-# none: in case threads are in libc; should be tried before -Kthread and
-#       other compiler flags to prevent continual compiler warnings
-# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
-# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
-# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
-# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
-# -pthreads: Solaris/gcc
-# -mthreads: Mingw32/gcc, Lynx/gcc
-# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
-#      doesn't hurt to check since this sometimes defines pthreads too;
-#      also defines -D_REENTRANT)
-#      ... -mt is also the pthreads flag for HP/aCC
-# pthread: Linux, etcetera
-# --thread-safe: KAI C++
-# pthread-config: use pthread-config program (for GNU Pth library)
-
-case ${host_os} in
-        solaris*)
-
-        # On Solaris (at least, for some versions), libc contains stubbed
-        # (non-functional) versions of the pthreads routines, so link-based
-        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
-        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
-        # a function called by this macro, so we could check for that, but
-        # who knows whether they'll stub that too in a future libc.)  So,
-        # we'll just look for -pthreads and -lpthread first:
-
-        ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
-        ;;
-
-        darwin*)
-        AC_REQUIRE([WOLFSSL_DARWIN_USING_CLANG])
-        AS_IF([test x"$wolfssl_darwin_clang" = x"yes"],
-                [ax_pthread_flags="$ax_pthread_flags"],
-                [ax_pthread_flags="-pthread $ax_pthread_flags"])
-        ;;
-esac
-
-if test x"$ax_pthread_ok" = xno; then
-for flag in $ax_pthread_flags; do
-
-        case $flag in
-                none)
-                AC_MSG_CHECKING([whether pthreads work without any flags])
-                ;;
-
-                -*)
-                AC_MSG_CHECKING([whether pthreads work with $flag])
-                PTHREAD_CFLAGS="$flag"
-                ;;
-
-                pthread-config)
-                AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no)
-                if test x"$ax_pthread_config" = xno; then continue; fi
-                PTHREAD_CFLAGS="`pthread-config --cflags`"
-                PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
-                ;;
-
-                *)
-                AC_MSG_CHECKING([for the pthreads library -l$flag])
-                PTHREAD_LIBS="-l$flag"
-                ;;
-        esac
-
-        save_LIBS="$LIBS"
-        save_CFLAGS="$CFLAGS"
-        LIBS="$PTHREAD_LIBS $LIBS"
-        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-
-        # Check for various functions.  We must include pthread.h,
-        # since some functions may be macros.  (On the Sequent, we
-        # need a special flag -Kthread to make this header compile.)
-        # We check for pthread_join because it is in -lpthread on IRIX
-        # while pthread_create is in libc.  We check for pthread_attr_init
-        # due to DEC craziness with -lpthreads.  We check for
-        # pthread_cleanup_push because it is one of the few pthread
-        # functions on Solaris that doesn't have a non-functional libc stub.
-        # We try pthread_create on general principles.
-        AC_LINK_IFELSE([AC_LANG_PROGRAM([#include 
-                        static void routine(void *a) { a = 0; }
-                        static void *start_routine(void *a) { return a; }],
-                       [pthread_t th; pthread_attr_t attr;
-                        pthread_create(&th, 0, start_routine, 0);
-                        pthread_join(th, 0);
-                        pthread_attr_init(&attr);
-                        pthread_cleanup_push(routine, 0);
-                        pthread_cleanup_pop(0) /* ; */])],
-                [ax_pthread_ok=yes],
-                [])
-
-        LIBS="$save_LIBS"
-        CFLAGS="$save_CFLAGS"
-
-        AC_MSG_RESULT($ax_pthread_ok)
-        if test "x$ax_pthread_ok" = xyes; then
-                break;
-        fi
-
-        PTHREAD_LIBS=""
-        PTHREAD_CFLAGS=""
-done
-fi
-
-# Various other checks:
-if test "x$ax_pthread_ok" = xyes; then
-        save_LIBS="$LIBS"
-        LIBS="$PTHREAD_LIBS $LIBS"
-        save_CFLAGS="$CFLAGS"
-        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-
-        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
-        AC_MSG_CHECKING([for joinable pthread attribute])
-        attr_name=unknown
-        for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
-            AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ],
-                           [int attr = $attr; return attr /* ; */])],
-                [attr_name=$attr; break],
-                [])
-        done
-        AC_MSG_RESULT($attr_name)
-        if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
-            AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
-                               [Define to necessary symbol if this constant
-                                uses a non-standard name on your system.])
-        fi
-
-        AC_MSG_CHECKING([if more special flags are required for pthreads])
-        flag=no
-        case ${host_os} in
-            aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
-            osf* | hpux*) flag="-D_REENTRANT";;
-            solaris*)
-            if test "$GCC" = "yes"; then
-                flag="-D_REENTRANT"
-            else
-                flag="-mt -D_REENTRANT"
-            fi
-            ;;
-        esac
-        AC_MSG_RESULT(${flag})
-        if test "x$flag" != xno; then
-            PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
-        fi
-
-        AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
-            ax_cv_PTHREAD_PRIO_INHERIT, [
-                AC_LINK_IFELSE([
-                    AC_LANG_PROGRAM([[#include ]], [[int i = PTHREAD_PRIO_INHERIT;]])],
-                    [ax_cv_PTHREAD_PRIO_INHERIT=yes],
-                    [ax_cv_PTHREAD_PRIO_INHERIT=no])
-            ])
-        AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
-            AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.]))
-
-        LIBS="$save_LIBS"
-        CFLAGS="$save_CFLAGS"
-
-        # More AIX lossage: compile with *_r variant
-        if test "x$GCC" != xyes; then
-            case $host_os in
-                aix*)
-                AS_CASE(["x/$CC"],
-                  [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
-                  [#handle absolute path differently from PATH based program lookup
-                   AS_CASE(["x$CC"],
-                     [x/*],
-                     [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
-                     [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
-                ;;
-            esac
-        fi
-fi
-
-test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
-
-AC_SUBST(PTHREAD_LIBS)
-AC_SUBST(PTHREAD_CFLAGS)
-AC_SUBST(PTHREAD_CC)
-
-# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
-if test x"$ax_pthread_ok" = xyes; then
-        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
-        :
-else
-        ax_pthread_ok=no
-        $2
-fi
-AC_LANG_POP
-])dnl AX_PTHREAD
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_tls.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_tls.m4
deleted file mode 100755
index 3f6b5e1..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_tls.m4
+++ /dev/null
@@ -1,92 +0,0 @@
-# ===========================================================================
-#          http://www.gnu.org/software/autoconf-archive/ax_tls.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_TLS([action-if-found], [action-if-not-found])
-#
-# DESCRIPTION
-#
-#   Provides a test for the compiler support of thread local storage (TLS)
-#   extensions. Defines TLS if it is found. Currently knows about GCC/ICC
-#   and MSVC. I think SunPro uses the same as GCC, and Borland apparently
-#   supports either.
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Alan Woodland 
-#   Copyright (c) 2010 Diego Elio Petteno` 
-#
-#   This program 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 3 of the License, or (at your
-#   option) any later version.
-#
-#   This program 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, see .
-#
-#   As a special exception, the respective Autoconf Macro's copyright owner
-#   gives unlimited permission to copy, distribute and modify the configure
-#   scripts that are the output of Autoconf when processing the Macro. You
-#   need not follow the terms of the GNU General Public License when using
-#   or distributing such scripts, even though portions of the text of the
-#   Macro appear in them. The GNU General Public License (GPL) does govern
-#   all other use of the material that constitutes the Autoconf Macro.
-#
-#   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Archive. When you make and distribute a
-#   modified version of the Autoconf Macro, you may extend this special
-#   exception to the GPL to apply to your modified version as well.
-
-#serial 11
-
-#   Define m4_ifblank and m4_ifnblank macros from introduced in
-#   autotools 2.64 m4sugar.m4 if using an earlier autotools.
-
-ifdef([m4_ifblank], [], [
-    m4_define([m4_ifblank],
-    [m4_if(m4_translit([[$1]], [ ][	][
-]), [], [$2], [$3])])
-    ])
-
-
-ifdef([m4_ifnblank], [], [
-    m4_define([m4_ifnblank],
-    [m4_if(m4_translit([[$1]], [ ][	][
-]), [], [$3], [$2])])
-    ])
-
-AC_DEFUN([AX_TLS], [
-  AC_MSG_CHECKING(for thread local storage (TLS) class)
-  AC_CACHE_VAL(ac_cv_tls, [
-    ax_tls_keywords="__thread __declspec(thread) none"
-    for ax_tls_keyword in $ax_tls_keywords; do
-       AS_CASE([$ax_tls_keyword],
-          [none], [ac_cv_tls=none ; break],
-          [AC_TRY_COMPILE(
-              [#include 
-               static void
-               foo(void) {
-               static ] $ax_tls_keyword [ int bar;
-               exit(1);
-               }],
-               [],
-               [ac_cv_tls=$ax_tls_keyword ; break],
-               ac_cv_tls=none
-           )])
-    done
-  ])
-  AC_MSG_RESULT($ac_cv_tls)
-
-  AS_IF([test "$ac_cv_tls" != "none"],
-    AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [If the compiler supports a TLS storage class define it to that here])
-      m4_ifnblank([$1], [$1]),
-    m4_ifnblank([$2], [$2])
-  )
-])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_vcs_checkout.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ax_vcs_checkout.m4
deleted file mode 100755
index 8047b65..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ax_vcs_checkout.m4
+++ /dev/null
@@ -1,75 +0,0 @@
-# ===========================================================================
-#      http://
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_VCS_CHECKOUT
-#
-# DESCRIPTION
-#
-#   Discover whether or not we are operating with a tree which
-#   has been checked out of a version control system.
-#
-#
-# LICENSE
-#
-#  Copyright (C) 2012 Brian Aker
-#  All rights reserved.
-#  
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions are
-#  met:
-#  
-#      * Redistributions of source code must retain the above copyright
-#  notice, this list of conditions and the following disclaimer.
-#  
-#      * Redistributions in binary form must reproduce the above
-#  copyright notice, this list of conditions and the following disclaimer
-#  in the documentation and/or other materials provided with the
-#  distribution.
-#  
-#      * The names of its contributors may not be used to endorse or
-#  promote products derived from this software without specific prior
-#  written permission.
-#  
-#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#serial 6
-
-AC_DEFUN([AX_VCS_SYSTEM],
-    [AC_PREREQ([2.63])dnl
-    AC_CACHE_CHECK([for vcs system], [ac_cv_vcs_system],
-      [ac_cv_vcs_system="none"
-      AS_IF([test -d ".bzr"],[ac_cv_vcs_system="bazaar"])
-      AS_IF([test -d ".svn"],[ac_cv_vcs_system="svn"])
-      AS_IF([test -d ".hg"],[ac_cv_vcs_system="mercurial"])
-      AS_IF([test -d ".git"],[ac_cv_vcs_system="git"])
-      ])
-    AC_DEFINE_UNQUOTED([VCS_SYSTEM],["$ac_cv_vcs_system"],[VCS system])
-    ])
-
-AC_DEFUN([AX_VCS_CHECKOUT],
-    [AC_PREREQ([2.63])dnl
-    AC_REQUIRE([AX_VCS_SYSTEM])
-    AC_CACHE_CHECK([for vcs checkout],[ac_cv_vcs_checkout],
-      [AS_IF([test "x$ac_cv_vcs_system" != "xnone"],
-        [ac_cv_vcs_checkout=yes],
-        [ac_cv_vcs_checkout=no])
-      ])
-
-    AM_CONDITIONAL([IS_VCS_CHECKOUT],[test "x$ac_cv_vcs_checkout" = "xyes"])
-    AS_IF([test "x$ac_cv_vcs_checkout" = "xyes"],
-      [AC_DEFINE([VCS_CHECKOUT],[1],[Define if the code was built from VCS.])],
-      [AC_DEFINE([VCS_CHECKOUT],[0],[Define if the code was built from VCS.])])
-    ])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/hexversion.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/hexversion.m4
deleted file mode 100755
index 8d26155..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/hexversion.m4
+++ /dev/null
@@ -1,6 +0,0 @@
-AC_DEFUN([CREATE_HEX_VERSION],[
-
-  HEX_VERSION=`echo $VERSION | sed 's|[\-a-z0-9]*$||' | \
-    awk -F. '{printf "0x%0.2d%0.3d%0.3d", $[]1, $[]2, $[]3}'`
-  AC_SUBST([HEX_VERSION])
-])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/lib_socket_nsl.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/lib_socket_nsl.m4
deleted file mode 100755
index e786e61..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/lib_socket_nsl.m4
+++ /dev/null
@@ -1,25 +0,0 @@
-dnl @synopsis LIB_SOCKET_NSL
-dnl
-dnl This macro figures out what libraries are required on this platform
-dnl to link sockets programs.
-dnl
-dnl The common cases are not to need any extra libraries, or to need
-dnl -lsocket and -lnsl. We need to avoid linking with libnsl unless we
-dnl need it, though, since on some OSes where it isn't necessary it
-dnl will totally break networking. Unisys also includes gethostbyname()
-dnl in libsocket but needs libnsl for socket().
-dnl
-dnl @category Misc
-dnl @author Russ Allbery 
-dnl @author Stepan Kasal 
-dnl @author Warren Young 
-dnl @version 2005-09-06
-dnl @license AllPermissive
-
-AC_DEFUN([LIB_SOCKET_NSL],
-[
-	AC_SEARCH_LIBS([gethostbyname], [nsl])
-	AC_SEARCH_LIBS([socket], [socket], [], [
-		AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"],
-		[], [-lnsl])])
-])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/libtool.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/libtool.m4
deleted file mode 100755
index 4adcf73..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/libtool.m4
+++ /dev/null
@@ -1,7982 +0,0 @@
-# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
-#
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-# This file is free software; the Free Software Foundation gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
-
-m4_define([_LT_COPYING], [dnl
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-#   This file is part of GNU Libtool.
-#
-# GNU Libtool 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.
-#
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
-#
-# GNU Libtool 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 GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-])
-
-# serial 57 LT_INIT
-
-
-# LT_PREREQ(VERSION)
-# ------------------
-# Complain and exit if this libtool version is less that VERSION.
-m4_defun([LT_PREREQ],
-[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
-       [m4_default([$3],
-		   [m4_fatal([Libtool version $1 or higher is required],
-		             63)])],
-       [$2])])
-
-
-# _LT_CHECK_BUILDDIR
-# ------------------
-# Complain if the absolute build directory name contains unusual characters
-m4_defun([_LT_CHECK_BUILDDIR],
-[case `pwd` in
-  *\ * | *\	*)
-    AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
-esac
-])
-
-
-# LT_INIT([OPTIONS])
-# ------------------
-AC_DEFUN([LT_INIT],
-[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
-AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
-AC_BEFORE([$0], [LT_LANG])dnl
-AC_BEFORE([$0], [LT_OUTPUT])dnl
-AC_BEFORE([$0], [LTDL_INIT])dnl
-m4_require([_LT_CHECK_BUILDDIR])dnl
-
-dnl Autoconf doesn't catch unexpanded LT_ macros by default:
-m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
-m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
-dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
-dnl unless we require an AC_DEFUNed macro:
-AC_REQUIRE([LTOPTIONS_VERSION])dnl
-AC_REQUIRE([LTSUGAR_VERSION])dnl
-AC_REQUIRE([LTVERSION_VERSION])dnl
-AC_REQUIRE([LTOBSOLETE_VERSION])dnl
-m4_require([_LT_PROG_LTMAIN])dnl
-
-_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}])
-
-dnl Parse OPTIONS
-_LT_SET_OPTIONS([$0], [$1])
-
-# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
-
-# Always use our own libtool.
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-AC_SUBST(LIBTOOL)dnl
-
-_LT_SETUP
-
-# Only expand once:
-m4_define([LT_INIT])
-])# LT_INIT
-
-# Old names:
-AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
-AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
-dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
-
-
-# _LT_CC_BASENAME(CC)
-# -------------------
-# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
-m4_defun([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
-  case $cc_temp in
-    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
-    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
-])
-
-
-# _LT_FILEUTILS_DEFAULTS
-# ----------------------
-# It is okay to use these file commands and assume they have been set
-# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
-m4_defun([_LT_FILEUTILS_DEFAULTS],
-[: ${CP="cp -f"}
-: ${MV="mv -f"}
-: ${RM="rm -f"}
-])# _LT_FILEUTILS_DEFAULTS
-
-
-# _LT_SETUP
-# ---------
-m4_defun([_LT_SETUP],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl
-AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
-
-_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl
-dnl
-_LT_DECL([], [host_alias], [0], [The host system])dnl
-_LT_DECL([], [host], [0])dnl
-_LT_DECL([], [host_os], [0])dnl
-dnl
-_LT_DECL([], [build_alias], [0], [The build system])dnl
-_LT_DECL([], [build], [0])dnl
-_LT_DECL([], [build_os], [0])dnl
-dnl
-AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([LT_PATH_LD])dnl
-AC_REQUIRE([LT_PATH_NM])dnl
-dnl
-AC_REQUIRE([AC_PROG_LN_S])dnl
-test -z "$LN_S" && LN_S="ln -s"
-_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
-dnl
-AC_REQUIRE([LT_CMD_MAX_LEN])dnl
-_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
-_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
-dnl
-m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_CHECK_SHELL_FEATURES])dnl
-m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl
-m4_require([_LT_CMD_RELOAD])dnl
-m4_require([_LT_CHECK_MAGIC_METHOD])dnl
-m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
-m4_require([_LT_CMD_OLD_ARCHIVE])dnl
-m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
-m4_require([_LT_WITH_SYSROOT])dnl
-
-_LT_CONFIG_LIBTOOL_INIT([
-# See if we are running on zsh, and set the options which allow our
-# commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
-   setopt NO_GLOB_SUBST
-fi
-])
-if test -n "${ZSH_VERSION+set}" ; then
-   setopt NO_GLOB_SUBST
-fi
-
-_LT_CHECK_OBJDIR
-
-m4_require([_LT_TAG_COMPILER])dnl
-
-case $host_os in
-aix3*)
-  # AIX sometimes has problems with the GCC collect2 program.  For some
-  # reason, if we set the COLLECT_NAMES environment variable, the problems
-  # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
-    COLLECT_NAMES=
-    export COLLECT_NAMES
-  fi
-  ;;
-esac
-
-# Global variables:
-ofile=libtool
-can_build_shared=yes
-
-# All known linkers require a `.a' archive for static linking (except MSVC,
-# which needs '.lib').
-libext=a
-
-with_gnu_ld="$lt_cv_prog_gnu_ld"
-
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
-
-# Set sane defaults for various variables
-test -z "$CC" && CC=cc
-test -z "$LTCC" && LTCC=$CC
-test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
-test -z "$LD" && LD=ld
-test -z "$ac_objext" && ac_objext=o
-
-_LT_CC_BASENAME([$compiler])
-
-# Only perform the check for file, if the check method requires it
-test -z "$MAGIC_CMD" && MAGIC_CMD=file
-case $deplibs_check_method in
-file_magic*)
-  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
-    _LT_PATH_MAGIC
-  fi
-  ;;
-esac
-
-# Use C for the default configuration in the libtool script
-LT_SUPPORTED_TAG([CC])
-_LT_LANG_C_CONFIG
-_LT_LANG_DEFAULT_CONFIG
-_LT_CONFIG_COMMANDS
-])# _LT_SETUP
-
-
-# _LT_PREPARE_SED_QUOTE_VARS
-# --------------------------
-# Define a few sed substitution that help us do robust quoting.
-m4_defun([_LT_PREPARE_SED_QUOTE_VARS],
-[# Backslashify metacharacters that are still active within
-# double-quoted strings.
-sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
-
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\([["`\\]]\)/\\\1/g'
-
-# Sed substitution to delay expansion of an escaped shell variable in a
-# double_quote_subst'ed string.
-delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
-
-# Sed substitution to delay expansion of an escaped single quote.
-delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
-
-# Sed substitution to avoid accidental globbing in evaled expressions
-no_glob_subst='s/\*/\\\*/g'
-])
-
-# _LT_PROG_LTMAIN
-# ---------------
-# Note that this code is called both from `configure', and `config.status'
-# now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,
-# `config.status' has no value for ac_aux_dir unless we are using Automake,
-# so we pass a copy along to make sure it has a sensible value anyway.
-m4_defun([_LT_PROG_LTMAIN],
-[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
-_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
-ltmain="$ac_aux_dir/ltmain.sh"
-])# _LT_PROG_LTMAIN
-
-
-## ------------------------------------- ##
-## Accumulate code for creating libtool. ##
-## ------------------------------------- ##
-
-# So that we can recreate a full libtool script including additional
-# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
-# in macros and then make a single call at the end using the `libtool'
-# label.
-
-
-# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
-# ----------------------------------------
-# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
-m4_define([_LT_CONFIG_LIBTOOL_INIT],
-[m4_ifval([$1],
-          [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
-                     [$1
-])])])
-
-# Initialize.
-m4_define([_LT_OUTPUT_LIBTOOL_INIT])
-
-
-# _LT_CONFIG_LIBTOOL([COMMANDS])
-# ------------------------------
-# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
-m4_define([_LT_CONFIG_LIBTOOL],
-[m4_ifval([$1],
-          [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
-                     [$1
-])])])
-
-# Initialize.
-m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
-
-
-# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
-# -----------------------------------------------------
-m4_defun([_LT_CONFIG_SAVE_COMMANDS],
-[_LT_CONFIG_LIBTOOL([$1])
-_LT_CONFIG_LIBTOOL_INIT([$2])
-])
-
-
-# _LT_FORMAT_COMMENT([COMMENT])
-# -----------------------------
-# Add leading comment marks to the start of each line, and a trailing
-# full-stop to the whole comment if one is not present already.
-m4_define([_LT_FORMAT_COMMENT],
-[m4_ifval([$1], [
-m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
-              [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
-)])
-
-
-
-## ------------------------ ##
-## FIXME: Eliminate VARNAME ##
-## ------------------------ ##
-
-
-# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
-# -------------------------------------------------------------------
-# CONFIGNAME is the name given to the value in the libtool script.
-# VARNAME is the (base) name used in the configure script.
-# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
-# VARNAME.  Any other value will be used directly.
-m4_define([_LT_DECL],
-[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
-    [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
-	[m4_ifval([$1], [$1], [$2])])
-    lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
-    m4_ifval([$4],
-	[lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
-    lt_dict_add_subkey([lt_decl_dict], [$2],
-	[tagged?], [m4_ifval([$5], [yes], [no])])])
-])
-
-
-# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
-# --------------------------------------------------------
-m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
-
-
-# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
-# ------------------------------------------------
-m4_define([lt_decl_tag_varnames],
-[_lt_decl_filter([tagged?], [yes], $@)])
-
-
-# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
-# ---------------------------------------------------------
-m4_define([_lt_decl_filter],
-[m4_case([$#],
-  [0], [m4_fatal([$0: too few arguments: $#])],
-  [1], [m4_fatal([$0: too few arguments: $#: $1])],
-  [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
-  [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
-  [lt_dict_filter([lt_decl_dict], $@)])[]dnl
-])
-
-
-# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
-# --------------------------------------------------
-m4_define([lt_decl_quote_varnames],
-[_lt_decl_filter([value], [1], $@)])
-
-
-# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
-# ---------------------------------------------------
-m4_define([lt_decl_dquote_varnames],
-[_lt_decl_filter([value], [2], $@)])
-
-
-# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
-# ---------------------------------------------------
-m4_define([lt_decl_varnames_tagged],
-[m4_assert([$# <= 2])dnl
-_$0(m4_quote(m4_default([$1], [[, ]])),
-    m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
-    m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
-m4_define([_lt_decl_varnames_tagged],
-[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
-
-
-# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
-# ------------------------------------------------
-m4_define([lt_decl_all_varnames],
-[_$0(m4_quote(m4_default([$1], [[, ]])),
-     m4_if([$2], [],
-	   m4_quote(lt_decl_varnames),
-	m4_quote(m4_shift($@))))[]dnl
-])
-m4_define([_lt_decl_all_varnames],
-[lt_join($@, lt_decl_varnames_tagged([$1],
-			lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
-])
-
-
-# _LT_CONFIG_STATUS_DECLARE([VARNAME])
-# ------------------------------------
-# Quote a variable value, and forward it to `config.status' so that its
-# declaration there will have the same value as in `configure'.  VARNAME
-# must have a single quote delimited value for this to work.
-m4_define([_LT_CONFIG_STATUS_DECLARE],
-[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
-
-
-# _LT_CONFIG_STATUS_DECLARATIONS
-# ------------------------------
-# We delimit libtool config variables with single quotes, so when
-# we write them to config.status, we have to be sure to quote all
-# embedded single quotes properly.  In configure, this macro expands
-# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
-#
-#    ='`$ECHO "$" | $SED "$delay_single_quote_subst"`'
-m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
-[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
-    [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
-
-
-# _LT_LIBTOOL_TAGS
-# ----------------
-# Output comment and list of tags supported by the script
-m4_defun([_LT_LIBTOOL_TAGS],
-[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
-available_tags="_LT_TAGS"dnl
-])
-
-
-# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
-# -----------------------------------
-# Extract the dictionary values for VARNAME (optionally with TAG) and
-# expand to a commented shell variable setting:
-#
-#    # Some comment about what VAR is for.
-#    visible_name=$lt_internal_name
-m4_define([_LT_LIBTOOL_DECLARE],
-[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
-					   [description])))[]dnl
-m4_pushdef([_libtool_name],
-    m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
-m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
-    [0], [_libtool_name=[$]$1],
-    [1], [_libtool_name=$lt_[]$1],
-    [2], [_libtool_name=$lt_[]$1],
-    [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
-m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
-])
-
-
-# _LT_LIBTOOL_CONFIG_VARS
-# -----------------------
-# Produce commented declarations of non-tagged libtool config variables
-# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
-# script.  Tagged libtool config variables (even for the LIBTOOL CONFIG
-# section) are produced by _LT_LIBTOOL_TAG_VARS.
-m4_defun([_LT_LIBTOOL_CONFIG_VARS],
-[m4_foreach([_lt_var],
-    m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
-    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
-
-
-# _LT_LIBTOOL_TAG_VARS(TAG)
-# -------------------------
-m4_define([_LT_LIBTOOL_TAG_VARS],
-[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
-    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
-
-
-# _LT_TAGVAR(VARNAME, [TAGNAME])
-# ------------------------------
-m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
-
-
-# _LT_CONFIG_COMMANDS
-# -------------------
-# Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of
-# variables for single and double quote escaping we saved from calls
-# to _LT_DECL, we can put quote escaped variables declarations
-# into `config.status', and then the shell code to quote escape them in
-# for loops in `config.status'.  Finally, any additional code accumulated
-# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
-m4_defun([_LT_CONFIG_COMMANDS],
-[AC_PROVIDE_IFELSE([LT_OUTPUT],
-	dnl If the libtool generation code has been placed in $CONFIG_LT,
-	dnl instead of duplicating it all over again into config.status,
-	dnl then we will have config.status run $CONFIG_LT later, so it
-	dnl needs to know what name is stored there:
-        [AC_CONFIG_COMMANDS([libtool],
-            [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
-    dnl If the libtool generation code is destined for config.status,
-    dnl expand the accumulated commands and init code now:
-    [AC_CONFIG_COMMANDS([libtool],
-        [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
-])#_LT_CONFIG_COMMANDS
-
-
-# Initialize.
-m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
-[
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-sed_quote_subst='$sed_quote_subst'
-double_quote_subst='$double_quote_subst'
-delay_variable_subst='$delay_variable_subst'
-_LT_CONFIG_STATUS_DECLARATIONS
-LTCC='$LTCC'
-LTCFLAGS='$LTCFLAGS'
-compiler='$compiler_DEFAULT'
-
-# A function that is used when there is no print builtin or printf.
-func_fallback_echo ()
-{
-  eval 'cat <<_LTECHO_EOF
-\$[]1
-_LTECHO_EOF'
-}
-
-# Quote evaled strings.
-for var in lt_decl_all_varnames([[ \
-]], lt_decl_quote_varnames); do
-    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
-    *[[\\\\\\\`\\"\\\$]]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
-      ;;
-    *)
-      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
-      ;;
-    esac
-done
-
-# Double-quote double-evaled strings.
-for var in lt_decl_all_varnames([[ \
-]], lt_decl_dquote_varnames); do
-    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
-    *[[\\\\\\\`\\"\\\$]]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
-      ;;
-    *)
-      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
-      ;;
-    esac
-done
-
-_LT_OUTPUT_LIBTOOL_INIT
-])
-
-# _LT_GENERATED_FILE_INIT(FILE, [COMMENT])
-# ------------------------------------
-# Generate a child script FILE with all initialization necessary to
-# reuse the environment learned by the parent script, and make the
-# file executable.  If COMMENT is supplied, it is inserted after the
-# `#!' sequence but before initialization text begins.  After this
-# macro, additional text can be appended to FILE to form the body of
-# the child script.  The macro ends with non-zero status if the
-# file could not be fully written (such as if the disk is full).
-m4_ifdef([AS_INIT_GENERATED],
-[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])],
-[m4_defun([_LT_GENERATED_FILE_INIT],
-[m4_require([AS_PREPARE])]dnl
-[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
-[lt_write_fail=0
-cat >$1 <<_ASEOF || lt_write_fail=1
-#! $SHELL
-# Generated by $as_me.
-$2
-SHELL=\${CONFIG_SHELL-$SHELL}
-export SHELL
-_ASEOF
-cat >>$1 <<\_ASEOF || lt_write_fail=1
-AS_SHELL_SANITIZE
-_AS_PREPARE
-exec AS_MESSAGE_FD>&1
-_ASEOF
-test $lt_write_fail = 0 && chmod +x $1[]dnl
-m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
-
-# LT_OUTPUT
-# ---------
-# This macro allows early generation of the libtool script (before
-# AC_OUTPUT is called), incase it is used in configure for compilation
-# tests.
-AC_DEFUN([LT_OUTPUT],
-[: ${CONFIG_LT=./config.lt}
-AC_MSG_NOTICE([creating $CONFIG_LT])
-_LT_GENERATED_FILE_INIT(["$CONFIG_LT"],
-[# Run this file to recreate a libtool stub with the current configuration.])
-
-cat >>"$CONFIG_LT" <<\_LTEOF
-lt_cl_silent=false
-exec AS_MESSAGE_LOG_FD>>config.log
-{
-  echo
-  AS_BOX([Running $as_me.])
-} >&AS_MESSAGE_LOG_FD
-
-lt_cl_help="\
-\`$as_me' creates a local libtool stub from the current configuration,
-for use in further configure time tests before the real libtool is
-generated.
-
-Usage: $[0] [[OPTIONS]]
-
-  -h, --help      print this help, then exit
-  -V, --version   print version number, then exit
-  -q, --quiet     do not print progress messages
-  -d, --debug     don't remove temporary files
-
-Report bugs to ."
-
-lt_cl_version="\
-m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
-m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
-configured by $[0], generated by m4_PACKAGE_STRING.
-
-Copyright (C) 2011 Free Software Foundation, Inc.
-This config.lt script is free software; the Free Software Foundation
-gives unlimited permision to copy, distribute and modify it."
-
-while test $[#] != 0
-do
-  case $[1] in
-    --version | --v* | -V )
-      echo "$lt_cl_version"; exit 0 ;;
-    --help | --h* | -h )
-      echo "$lt_cl_help"; exit 0 ;;
-    --debug | --d* | -d )
-      debug=: ;;
-    --quiet | --q* | --silent | --s* | -q )
-      lt_cl_silent=: ;;
-
-    -*) AC_MSG_ERROR([unrecognized option: $[1]
-Try \`$[0] --help' for more information.]) ;;
-
-    *) AC_MSG_ERROR([unrecognized argument: $[1]
-Try \`$[0] --help' for more information.]) ;;
-  esac
-  shift
-done
-
-if $lt_cl_silent; then
-  exec AS_MESSAGE_FD>/dev/null
-fi
-_LTEOF
-
-cat >>"$CONFIG_LT" <<_LTEOF
-_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
-_LTEOF
-
-cat >>"$CONFIG_LT" <<\_LTEOF
-AC_MSG_NOTICE([creating $ofile])
-_LT_OUTPUT_LIBTOOL_COMMANDS
-AS_EXIT(0)
-_LTEOF
-chmod +x "$CONFIG_LT"
-
-# configure is writing to config.log, but config.lt does its own redirection,
-# appending to config.log, which fails on DOS, as config.log is still kept
-# open by configure.  Here we exec the FD to /dev/null, effectively closing
-# config.log, so it can be properly (re)opened and appended to by config.lt.
-lt_cl_success=:
-test "$silent" = yes &&
-  lt_config_lt_args="$lt_config_lt_args --quiet"
-exec AS_MESSAGE_LOG_FD>/dev/null
-$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
-exec AS_MESSAGE_LOG_FD>>config.log
-$lt_cl_success || AS_EXIT(1)
-])# LT_OUTPUT
-
-
-# _LT_CONFIG(TAG)
-# ---------------
-# If TAG is the built-in tag, create an initial libtool script with a
-# default configuration from the untagged config vars.  Otherwise add code
-# to config.status for appending the configuration named by TAG from the
-# matching tagged config vars.
-m4_defun([_LT_CONFIG],
-[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-_LT_CONFIG_SAVE_COMMANDS([
-  m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
-  m4_if(_LT_TAG, [C], [
-    # See if we are running on zsh, and set the options which allow our
-    # commands through without removal of \ escapes.
-    if test -n "${ZSH_VERSION+set}" ; then
-      setopt NO_GLOB_SUBST
-    fi
-
-    cfgfile="${ofile}T"
-    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
-    $RM "$cfgfile"
-
-    cat <<_LT_EOF >> "$cfgfile"
-#! $SHELL
-
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-# NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
-_LT_COPYING
-_LT_LIBTOOL_TAGS
-
-# ### BEGIN LIBTOOL CONFIG
-_LT_LIBTOOL_CONFIG_VARS
-_LT_LIBTOOL_TAG_VARS
-# ### END LIBTOOL CONFIG
-
-_LT_EOF
-
-  case $host_os in
-  aix3*)
-    cat <<\_LT_EOF >> "$cfgfile"
-# AIX sometimes has problems with the GCC collect2 program.  For some
-# reason, if we set the COLLECT_NAMES environment variable, the problems
-# vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
-  COLLECT_NAMES=
-  export COLLECT_NAMES
-fi
-_LT_EOF
-    ;;
-  esac
-
-  _LT_PROG_LTMAIN
-
-  # We use sed instead of cat because bash on DJGPP gets confused if
-  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
-  # text mode, it properly converts lines to CR/LF.  This bash problem
-  # is reportedly fixed, but why not run on old versions too?
-  sed '$q' "$ltmain" >> "$cfgfile" \
-     || (rm -f "$cfgfile"; exit 1)
-
-  _LT_PROG_REPLACE_SHELLFNS
-
-   mv -f "$cfgfile" "$ofile" ||
-    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
-  chmod +x "$ofile"
-],
-[cat <<_LT_EOF >> "$ofile"
-
-dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
-dnl in a comment (ie after a #).
-# ### BEGIN LIBTOOL TAG CONFIG: $1
-_LT_LIBTOOL_TAG_VARS(_LT_TAG)
-# ### END LIBTOOL TAG CONFIG: $1
-_LT_EOF
-])dnl /m4_if
-],
-[m4_if([$1], [], [
-    PACKAGE='$PACKAGE'
-    VERSION='$VERSION'
-    TIMESTAMP='$TIMESTAMP'
-    RM='$RM'
-    ofile='$ofile'], [])
-])dnl /_LT_CONFIG_SAVE_COMMANDS
-])# _LT_CONFIG
-
-
-# LT_SUPPORTED_TAG(TAG)
-# ---------------------
-# Trace this macro to discover what tags are supported by the libtool
-# --tag option, using:
-#    autoconf --trace 'LT_SUPPORTED_TAG:$1'
-AC_DEFUN([LT_SUPPORTED_TAG], [])
-
-
-# C support is built-in for now
-m4_define([_LT_LANG_C_enabled], [])
-m4_define([_LT_TAGS], [])
-
-
-# LT_LANG(LANG)
-# -------------
-# Enable libtool support for the given language if not already enabled.
-AC_DEFUN([LT_LANG],
-[AC_BEFORE([$0], [LT_OUTPUT])dnl
-m4_case([$1],
-  [C],			[_LT_LANG(C)],
-  [C++],		[_LT_LANG(CXX)],
-  [Go],			[_LT_LANG(GO)],
-  [Java],		[_LT_LANG(GCJ)],
-  [Fortran 77],		[_LT_LANG(F77)],
-  [Fortran],		[_LT_LANG(FC)],
-  [Windows Resource],	[_LT_LANG(RC)],
-  [m4_ifdef([_LT_LANG_]$1[_CONFIG],
-    [_LT_LANG($1)],
-    [m4_fatal([$0: unsupported language: "$1"])])])dnl
-])# LT_LANG
-
-
-# _LT_LANG(LANGNAME)
-# ------------------
-m4_defun([_LT_LANG],
-[m4_ifdef([_LT_LANG_]$1[_enabled], [],
-  [LT_SUPPORTED_TAG([$1])dnl
-  m4_append([_LT_TAGS], [$1 ])dnl
-  m4_define([_LT_LANG_]$1[_enabled], [])dnl
-  _LT_LANG_$1_CONFIG($1)])dnl
-])# _LT_LANG
-
-
-m4_ifndef([AC_PROG_GO], [
-############################################################
-# NOTE: This macro has been submitted for inclusion into   #
-#  GNU Autoconf as AC_PROG_GO.  When it is available in    #
-#  a released version of Autoconf we should remove this    #
-#  macro and use it instead.                               #
-############################################################
-m4_defun([AC_PROG_GO],
-[AC_LANG_PUSH(Go)dnl
-AC_ARG_VAR([GOC],     [Go compiler command])dnl
-AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl
-_AC_ARG_VAR_LDFLAGS()dnl
-AC_CHECK_TOOL(GOC, gccgo)
-if test -z "$GOC"; then
-  if test -n "$ac_tool_prefix"; then
-    AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo])
-  fi
-fi
-if test -z "$GOC"; then
-  AC_CHECK_PROG(GOC, gccgo, gccgo, false)
-fi
-])#m4_defun
-])#m4_ifndef
-
-
-# _LT_LANG_DEFAULT_CONFIG
-# -----------------------
-m4_defun([_LT_LANG_DEFAULT_CONFIG],
-[AC_PROVIDE_IFELSE([AC_PROG_CXX],
-  [LT_LANG(CXX)],
-  [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
-
-AC_PROVIDE_IFELSE([AC_PROG_F77],
-  [LT_LANG(F77)],
-  [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
-
-AC_PROVIDE_IFELSE([AC_PROG_FC],
-  [LT_LANG(FC)],
-  [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
-
-dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
-dnl pulling things in needlessly.
-AC_PROVIDE_IFELSE([AC_PROG_GCJ],
-  [LT_LANG(GCJ)],
-  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
-    [LT_LANG(GCJ)],
-    [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
-      [LT_LANG(GCJ)],
-      [m4_ifdef([AC_PROG_GCJ],
-	[m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
-       m4_ifdef([A][M_PROG_GCJ],
-	[m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
-       m4_ifdef([LT_PROG_GCJ],
-	[m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
-
-AC_PROVIDE_IFELSE([AC_PROG_GO],
-  [LT_LANG(GO)],
-  [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])])
-
-AC_PROVIDE_IFELSE([LT_PROG_RC],
-  [LT_LANG(RC)],
-  [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
-])# _LT_LANG_DEFAULT_CONFIG
-
-# Obsolete macros:
-AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
-AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
-AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
-AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
-AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
-dnl AC_DEFUN([AC_LIBTOOL_F77], [])
-dnl AC_DEFUN([AC_LIBTOOL_FC], [])
-dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
-dnl AC_DEFUN([AC_LIBTOOL_RC], [])
-
-
-# _LT_TAG_COMPILER
-# ----------------
-m4_defun([_LT_TAG_COMPILER],
-[AC_REQUIRE([AC_PROG_CC])dnl
-
-_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
-_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
-_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
-_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-])# _LT_TAG_COMPILER
-
-
-# _LT_COMPILER_BOILERPLATE
-# ------------------------
-# Check for compiler boilerplate output or warnings with
-# the simple compiler test code.
-m4_defun([_LT_COMPILER_BOILERPLATE],
-[m4_require([_LT_DECL_SED])dnl
-ac_outfile=conftest.$ac_objext
-echo "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$RM conftest*
-])# _LT_COMPILER_BOILERPLATE
-
-
-# _LT_LINKER_BOILERPLATE
-# ----------------------
-# Check for linker boilerplate output or warnings with
-# the simple link test code.
-m4_defun([_LT_LINKER_BOILERPLATE],
-[m4_require([_LT_DECL_SED])dnl
-ac_outfile=conftest.$ac_objext
-echo "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$RM -r conftest*
-])# _LT_LINKER_BOILERPLATE
-
-# _LT_REQUIRED_DARWIN_CHECKS
-# -------------------------
-m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
-  case $host_os in
-    rhapsody* | darwin*)
-    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
-    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
-    AC_CHECK_TOOL([LIPO], [lipo], [:])
-    AC_CHECK_TOOL([OTOOL], [otool], [:])
-    AC_CHECK_TOOL([OTOOL64], [otool64], [:])
-    _LT_DECL([], [DSYMUTIL], [1],
-      [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
-    _LT_DECL([], [NMEDIT], [1],
-      [Tool to change global to local symbols on Mac OS X])
-    _LT_DECL([], [LIPO], [1],
-      [Tool to manipulate fat objects and archives on Mac OS X])
-    _LT_DECL([], [OTOOL], [1],
-      [ldd/readelf like tool for Mach-O binaries on Mac OS X])
-    _LT_DECL([], [OTOOL64], [1],
-      [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
-
-    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
-      [lt_cv_apple_cc_single_mod=no
-      if test -z "${LT_MULTI_MODULE}"; then
-	# By default we will add the -single_module flag. You can override
-	# by either setting the environment variable LT_MULTI_MODULE
-	# non-empty at configure time, or by adding -multi_module to the
-	# link flags.
-	rm -rf libconftest.dylib*
-	echo "int foo(void){return 1;}" > conftest.c
-	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
--dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
-	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
-	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
-        _lt_result=$?
-	# If there is a non-empty error log, and "single_module"
-	# appears in it, assume the flag caused a linker warning
-        if test -s conftest.err && $GREP single_module conftest.err; then
-	  cat conftest.err >&AS_MESSAGE_LOG_FD
-	# Otherwise, if the output was created with a 0 exit code from
-	# the compiler, it worked.
-	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
-	  lt_cv_apple_cc_single_mod=yes
-	else
-	  cat conftest.err >&AS_MESSAGE_LOG_FD
-	fi
-	rm -rf libconftest.dylib*
-	rm -f conftest.*
-      fi])
-
-    AC_CACHE_CHECK([for -exported_symbols_list linker flag],
-      [lt_cv_ld_exported_symbols_list],
-      [lt_cv_ld_exported_symbols_list=no
-      save_LDFLAGS=$LDFLAGS
-      echo "_main" > conftest.sym
-      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
-      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
-	[lt_cv_ld_exported_symbols_list=yes],
-	[lt_cv_ld_exported_symbols_list=no])
-	LDFLAGS="$save_LDFLAGS"
-    ])
-
-    AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
-      [lt_cv_ld_force_load=no
-      cat > conftest.c << _LT_EOF
-int forced_loaded() { return 2;}
-_LT_EOF
-      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
-      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
-      echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
-      $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
-      echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD
-      $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD
-      cat > conftest.c << _LT_EOF
-int main() { return 0;}
-_LT_EOF
-      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD
-      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
-      _lt_result=$?
-      if test -s conftest.err && $GREP force_load conftest.err; then
-	cat conftest.err >&AS_MESSAGE_LOG_FD
-      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
-	lt_cv_ld_force_load=yes
-      else
-	cat conftest.err >&AS_MESSAGE_LOG_FD
-      fi
-        rm -f conftest.err libconftest.a conftest conftest.c
-        rm -rf conftest.dSYM
-    ])
-    case $host_os in
-    rhapsody* | darwin1.[[012]])
-      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
-    darwin1.*)
-      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
-    darwin*) # darwin 5.x on
-      # if running on 10.5 or later, the deployment target defaults
-      # to the OS version, if on x86, and 10.4, the deployment
-      # target defaults to 10.4. Don't you love it?
-      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
-	10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-	10.[[012]][[,.]]*)
-	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
-	10.*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-      esac
-    ;;
-  esac
-    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
-      _lt_dar_single_mod='$single_module'
-    fi
-    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
-      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
-    else
-      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
-    fi
-    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
-      _lt_dsymutil='~$DSYMUTIL $lib || :'
-    else
-      _lt_dsymutil=
-    fi
-    ;;
-  esac
-])
-
-
-# _LT_DARWIN_LINKER_FEATURES([TAG])
-# ---------------------------------
-# Checks for linker and compiler features on darwin
-m4_defun([_LT_DARWIN_LINKER_FEATURES],
-[
-  m4_require([_LT_REQUIRED_DARWIN_CHECKS])
-  _LT_TAGVAR(archive_cmds_need_lc, $1)=no
-  _LT_TAGVAR(hardcode_direct, $1)=no
-  _LT_TAGVAR(hardcode_automatic, $1)=yes
-  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
-    m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],
-                  [FC],  [_LT_TAGVAR(compiler_needs_object, $1)=yes])
-  else
-    _LT_TAGVAR(whole_archive_flag_spec, $1)=''
-  fi
-  _LT_TAGVAR(link_all_deplibs, $1)=yes
-  _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
-  case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
-     *) _lt_dar_can_shared=$GCC ;;
-  esac
-  if test "$_lt_dar_can_shared" = "yes"; then
-    output_verbose_link_cmd=func_echo_all
-    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-    m4_if([$1], [CXX],
-[   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
-      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
-    fi
-],[])
-  else
-  _LT_TAGVAR(ld_shlibs, $1)=no
-  fi
-])
-
-# _LT_SYS_MODULE_PATH_AIX([TAGNAME])
-# ----------------------------------
-# Links a minimal program and checks the executable
-# for the system default hardcoded library path. In most cases,
-# this is /usr/lib:/lib, but when the MPI compilers are used
-# the location of the communication and MPI libs are included too.
-# If we don't find anything, use the default library path according
-# to the aix ld manual.
-# Store the results from the different compilers for each TAGNAME.
-# Allow to override them for all tags through lt_cv_aix_libpath.
-m4_defun([_LT_SYS_MODULE_PATH_AIX],
-[m4_require([_LT_DECL_SED])dnl
-if test "${lt_cv_aix_libpath+set}" = set; then
-  aix_libpath=$lt_cv_aix_libpath
-else
-  AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
-  [AC_LINK_IFELSE([AC_LANG_PROGRAM],[
-  lt_aix_libpath_sed='[
-      /Import File Strings/,/^$/ {
-	  /^0/ {
-	      s/^0  *\([^ ]*\) *$/\1/
-	      p
-	  }
-      }]'
-  _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  # Check for a 64-bit object if we didn't find anything.
-  if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
-    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  fi],[])
-  if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
-    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib"
-  fi
-  ])
-  aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
-fi
-])# _LT_SYS_MODULE_PATH_AIX
-
-
-# _LT_SHELL_INIT(ARG)
-# -------------------
-m4_define([_LT_SHELL_INIT],
-[m4_divert_text([M4SH-INIT], [$1
-])])# _LT_SHELL_INIT
-
-
-
-# _LT_PROG_ECHO_BACKSLASH
-# -----------------------
-# Find how we can fake an echo command that does not interpret backslash.
-# In particular, with Autoconf 2.60 or later we add some code to the start
-# of the generated configure script which will find a shell with a builtin
-# printf (which we can use as an echo command).
-m4_defun([_LT_PROG_ECHO_BACKSLASH],
-[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
-ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
-
-AC_MSG_CHECKING([how to print strings])
-# Test print first, because it will be a builtin if present.
-if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
-   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
-  ECHO='print -r --'
-elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
-  ECHO='printf %s\n'
-else
-  # Use this function as a fallback that always works.
-  func_fallback_echo ()
-  {
-    eval 'cat <<_LTECHO_EOF
-$[]1
-_LTECHO_EOF'
-  }
-  ECHO='func_fallback_echo'
-fi
-
-# func_echo_all arg...
-# Invoke $ECHO with all args, space-separated.
-func_echo_all ()
-{
-    $ECHO "$*" 
-}
-
-case "$ECHO" in
-  printf*) AC_MSG_RESULT([printf]) ;;
-  print*) AC_MSG_RESULT([print -r]) ;;
-  *) AC_MSG_RESULT([cat]) ;;
-esac
-
-m4_ifdef([_AS_DETECT_SUGGESTED],
-[_AS_DETECT_SUGGESTED([
-  test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || (
-    ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
-    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
-    PATH=/empty FPATH=/empty; export PATH FPATH
-    test "X`printf %s $ECHO`" = "X$ECHO" \
-      || test "X`print -r -- $ECHO`" = "X$ECHO" )])])
-
-_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
-_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
-])# _LT_PROG_ECHO_BACKSLASH
-
-
-# _LT_WITH_SYSROOT
-# ----------------
-AC_DEFUN([_LT_WITH_SYSROOT],
-[AC_MSG_CHECKING([for sysroot])
-AC_ARG_WITH([sysroot],
-[  --with-sysroot[=DIR] Search for dependent libraries within DIR
-                        (or the compiler's sysroot if not specified).],
-[], [with_sysroot=no])
-
-dnl lt_sysroot will always be passed unquoted.  We quote it here
-dnl in case the user passed a directory name.
-lt_sysroot=
-case ${with_sysroot} in #(
- yes)
-   if test "$GCC" = yes; then
-     lt_sysroot=`$CC --print-sysroot 2>/dev/null`
-   fi
-   ;; #(
- /*)
-   lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
-   ;; #(
- no|'')
-   ;; #(
- *)
-   AC_MSG_RESULT([${with_sysroot}])
-   AC_MSG_ERROR([The sysroot must be an absolute path.])
-   ;;
-esac
-
- AC_MSG_RESULT([${lt_sysroot:-no}])
-_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
-[dependent libraries, and in which our libraries should be installed.])])
-
-# _LT_ENABLE_LOCK
-# ---------------
-m4_defun([_LT_ENABLE_LOCK],
-[AC_ARG_ENABLE([libtool-lock],
-  [AS_HELP_STRING([--disable-libtool-lock],
-    [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-# Some flags need to be propagated to the compiler or linker for good
-# libtool support.
-case $host in
-ia64-*-hpux*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if AC_TRY_EVAL(ac_compile); then
-    case `/usr/bin/file conftest.$ac_objext` in
-      *ELF-32*)
-	HPUX_IA64_MODE="32"
-	;;
-      *ELF-64*)
-	HPUX_IA64_MODE="64"
-	;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-*-*-irix6*)
-  # Find out which ABI we are using.
-  echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
-  if AC_TRY_EVAL(ac_compile); then
-    if test "$lt_cv_prog_gnu_ld" = yes; then
-      case `/usr/bin/file conftest.$ac_objext` in
-	*32-bit*)
-	  LD="${LD-ld} -melf32bsmip"
-	  ;;
-	*N32*)
-	  LD="${LD-ld} -melf32bmipn32"
-	  ;;
-	*64-bit*)
-	  LD="${LD-ld} -melf64bmip"
-	;;
-      esac
-    else
-      case `/usr/bin/file conftest.$ac_objext` in
-	*32-bit*)
-	  LD="${LD-ld} -32"
-	  ;;
-	*N32*)
-	  LD="${LD-ld} -n32"
-	  ;;
-	*64-bit*)
-	  LD="${LD-ld} -64"
-	  ;;
-      esac
-    fi
-  fi
-  rm -rf conftest*
-  ;;
-
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
-s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if AC_TRY_EVAL(ac_compile); then
-    case `/usr/bin/file conftest.o` in
-      *32-bit*)
-	case $host in
-	  x86_64-*kfreebsd*-gnu)
-	    LD="${LD-ld} -m elf_i386_fbsd"
-	    ;;
-	  x86_64-*linux*)
-	    LD="${LD-ld} -m elf_i386"
-	    ;;
-	  ppc64-*linux*|powerpc64-*linux*)
-	    LD="${LD-ld} -m elf32ppclinux"
-	    ;;
-	  s390x-*linux*)
-	    LD="${LD-ld} -m elf_s390"
-	    ;;
-	  sparc64-*linux*)
-	    LD="${LD-ld} -m elf32_sparc"
-	    ;;
-	esac
-	;;
-      *64-bit*)
-	case $host in
-	  x86_64-*kfreebsd*-gnu)
-	    LD="${LD-ld} -m elf_x86_64_fbsd"
-	    ;;
-	  x86_64-*linux*)
-	    LD="${LD-ld} -m elf_x86_64"
-	    ;;
-	  ppc*-*linux*|powerpc*-*linux*)
-	    LD="${LD-ld} -m elf64ppc"
-	    ;;
-	  s390*-*linux*|s390*-*tpf*)
-	    LD="${LD-ld} -m elf64_s390"
-	    ;;
-	  sparc*-*linux*)
-	    LD="${LD-ld} -m elf64_sparc"
-	    ;;
-	esac
-	;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-
-*-*-sco3.2v5*)
-  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS -belf"
-  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
-    [AC_LANG_PUSH(C)
-     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
-     AC_LANG_POP])
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
-    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
-  fi
-  ;;
-*-*solaris*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if AC_TRY_EVAL(ac_compile); then
-    case `/usr/bin/file conftest.o` in
-    *64-bit*)
-      case $lt_cv_prog_gnu_ld in
-      yes*)
-        case $host in
-        i?86-*-solaris*)
-          LD="${LD-ld} -m elf_x86_64"
-          ;;
-        sparc*-*-solaris*)
-          LD="${LD-ld} -m elf64_sparc"
-          ;;
-        esac
-        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
-        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
-          LD="${LD-ld}_sol2"
-        fi
-        ;;
-      *)
-	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
-	  LD="${LD-ld} -64"
-	fi
-	;;
-      esac
-      ;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-esac
-
-need_locks="$enable_libtool_lock"
-])# _LT_ENABLE_LOCK
-
-
-# _LT_PROG_AR
-# -----------
-m4_defun([_LT_PROG_AR],
-[AC_CHECK_TOOLS(AR, [ar], false)
-: ${AR=ar}
-: ${AR_FLAGS=cru}
-_LT_DECL([], [AR], [1], [The archiver])
-_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive])
-
-AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
-  [lt_cv_ar_at_file=no
-   AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
-     [echo conftest.$ac_objext > conftest.lst
-      lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
-      AC_TRY_EVAL([lt_ar_try])
-      if test "$ac_status" -eq 0; then
-	# Ensure the archiver fails upon bogus file names.
-	rm -f conftest.$ac_objext libconftest.a
-	AC_TRY_EVAL([lt_ar_try])
-	if test "$ac_status" -ne 0; then
-          lt_cv_ar_at_file=@
-        fi
-      fi
-      rm -f conftest.* libconftest.a
-     ])
-  ])
-
-if test "x$lt_cv_ar_at_file" = xno; then
-  archiver_list_spec=
-else
-  archiver_list_spec=$lt_cv_ar_at_file
-fi
-_LT_DECL([], [archiver_list_spec], [1],
-  [How to feed a file listing to the archiver])
-])# _LT_PROG_AR
-
-
-# _LT_CMD_OLD_ARCHIVE
-# -------------------
-m4_defun([_LT_CMD_OLD_ARCHIVE],
-[_LT_PROG_AR
-
-AC_CHECK_TOOL(STRIP, strip, :)
-test -z "$STRIP" && STRIP=:
-_LT_DECL([], [STRIP], [1], [A symbol stripping program])
-
-AC_CHECK_TOOL(RANLIB, ranlib, :)
-test -z "$RANLIB" && RANLIB=:
-_LT_DECL([], [RANLIB], [1],
-    [Commands used to install an old-style archive])
-
-# Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
-old_postinstall_cmds='chmod 644 $oldlib'
-old_postuninstall_cmds=
-
-if test -n "$RANLIB"; then
-  case $host_os in
-  openbsd*)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
-    ;;
-  *)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
-    ;;
-  esac
-  old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
-fi
-
-case $host_os in
-  darwin*)
-    lock_old_archive_extraction=yes ;;
-  *)
-    lock_old_archive_extraction=no ;;
-esac
-_LT_DECL([], [old_postinstall_cmds], [2])
-_LT_DECL([], [old_postuninstall_cmds], [2])
-_LT_TAGDECL([], [old_archive_cmds], [2],
-    [Commands used to build an old-style archive])
-_LT_DECL([], [lock_old_archive_extraction], [0],
-    [Whether to use a lock for old archive extraction])
-])# _LT_CMD_OLD_ARCHIVE
-
-
-# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
-#		[OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
-# ----------------------------------------------------------------
-# Check whether the given compiler option works
-AC_DEFUN([_LT_COMPILER_OPTION],
-[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_DECL_SED])dnl
-AC_CACHE_CHECK([$1], [$2],
-  [$2=no
-   m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$3"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&AS_MESSAGE_LOG_FD
-   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       $2=yes
-     fi
-   fi
-   $RM conftest*
-])
-
-if test x"[$]$2" = xyes; then
-    m4_if([$5], , :, [$5])
-else
-    m4_if([$6], , :, [$6])
-fi
-])# _LT_COMPILER_OPTION
-
-# Old name:
-AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
-
-
-# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
-#                  [ACTION-SUCCESS], [ACTION-FAILURE])
-# ----------------------------------------------------
-# Check whether the given linker option works
-AC_DEFUN([_LT_LINKER_OPTION],
-[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_DECL_SED])dnl
-AC_CACHE_CHECK([$1], [$2],
-  [$2=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $3"
-   echo "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&AS_MESSAGE_LOG_FD
-       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         $2=yes
-       fi
-     else
-       $2=yes
-     fi
-   fi
-   $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
-])
-
-if test x"[$]$2" = xyes; then
-    m4_if([$4], , :, [$4])
-else
-    m4_if([$5], , :, [$5])
-fi
-])# _LT_LINKER_OPTION
-
-# Old name:
-AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
-
-
-# LT_CMD_MAX_LEN
-#---------------
-AC_DEFUN([LT_CMD_MAX_LEN],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-# find the maximum length of command line arguments
-AC_MSG_CHECKING([the maximum length of command line arguments])
-AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
-  i=0
-  teststring="ABCD"
-
-  case $build_os in
-  msdosdjgpp*)
-    # On DJGPP, this test can blow up pretty badly due to problems in libc
-    # (any single argument exceeding 2000 bytes causes a buffer overrun
-    # during glob expansion).  Even if it were fixed, the result of this
-    # check would be larger than it should be.
-    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
-    ;;
-
-  gnu*)
-    # Under GNU Hurd, this test is not required because there is
-    # no limit to the length of command line arguments.
-    # Libtool will interpret -1 as no limit whatsoever
-    lt_cv_sys_max_cmd_len=-1;
-    ;;
-
-  cygwin* | mingw* | cegcc*)
-    # On Win9x/ME, this test blows up -- it succeeds, but takes
-    # about 5 minutes as the teststring grows exponentially.
-    # Worse, since 9x/ME are not pre-emptively multitasking,
-    # you end up with a "frozen" computer, even though with patience
-    # the test eventually succeeds (with a max line length of 256k).
-    # Instead, let's just punt: use the minimum linelength reported by
-    # all of the supported platforms: 8192 (on NT/2K/XP).
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
-
-  mint*)
-    # On MiNT this can take a long time and run out of memory.
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
-
-  amigaos*)
-    # On AmigaOS with pdksh, this test takes hours, literally.
-    # So we just punt and use a minimum line length of 8192.
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
-
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
-    # This has been around since 386BSD, at least.  Likely further.
-    if test -x /sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
-    elif test -x /usr/sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
-    else
-      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
-    fi
-    # And add a safety zone
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    ;;
-
-  interix*)
-    # We know the value 262144 and hardcode it with a safety zone (like BSD)
-    lt_cv_sys_max_cmd_len=196608
-    ;;
-
-  os2*)
-    # The test takes a long time on OS/2.
-    lt_cv_sys_max_cmd_len=8192
-    ;;
-
-  osf*)
-    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
-    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
-    # nice to cause kernel panics so lets avoid the loop below.
-    # First set a reasonable default.
-    lt_cv_sys_max_cmd_len=16384
-    #
-    if test -x /sbin/sysconfig; then
-      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
-        *1*) lt_cv_sys_max_cmd_len=-1 ;;
-      esac
-    fi
-    ;;
-  sco3.2v5*)
-    lt_cv_sys_max_cmd_len=102400
-    ;;
-  sysv5* | sco5v6* | sysv4.2uw2*)
-    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
-    if test -n "$kargmax"; then
-      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[	 ]]//'`
-    else
-      lt_cv_sys_max_cmd_len=32768
-    fi
-    ;;
-  *)
-    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
-    if test -n "$lt_cv_sys_max_cmd_len"; then
-      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    else
-      # Make teststring a little bigger before we do anything with it.
-      # a 1K string should be a reasonable start.
-      for i in 1 2 3 4 5 6 7 8 ; do
-        teststring=$teststring$teststring
-      done
-      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
-      # If test is not a shell built-in, we'll probably end up computing a
-      # maximum length that is only half of the actual maximum length, but
-      # we can't tell.
-      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
-	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
-	      test $i != 17 # 1/2 MB should be enough
-      do
-        i=`expr $i + 1`
-        teststring=$teststring$teststring
-      done
-      # Only check the string length outside the loop.
-      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
-      teststring=
-      # Add a significant safety factor because C++ compilers can tack on
-      # massive amounts of additional arguments before passing them to the
-      # linker.  It appears as though 1/2 is a usable value.
-      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
-    fi
-    ;;
-  esac
-])
-if test -n $lt_cv_sys_max_cmd_len ; then
-  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
-else
-  AC_MSG_RESULT(none)
-fi
-max_cmd_len=$lt_cv_sys_max_cmd_len
-_LT_DECL([], [max_cmd_len], [0],
-    [What is the maximum length of a command?])
-])# LT_CMD_MAX_LEN
-
-# Old name:
-AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
-
-
-# _LT_HEADER_DLFCN
-# ----------------
-m4_defun([_LT_HEADER_DLFCN],
-[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
-])# _LT_HEADER_DLFCN
-
-
-# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
-#                      ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
-# ----------------------------------------------------------------
-m4_defun([_LT_TRY_DLOPEN_SELF],
-[m4_require([_LT_HEADER_DLFCN])dnl
-if test "$cross_compiling" = yes; then :
-  [$4]
-else
-  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-  lt_status=$lt_dlunknown
-  cat > conftest.$ac_ext <<_LT_EOF
-[#line $LINENO "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include 
-#endif
-
-#include 
-
-#ifdef RTLD_GLOBAL
-#  define LT_DLGLOBAL		RTLD_GLOBAL
-#else
-#  ifdef DL_GLOBAL
-#    define LT_DLGLOBAL		DL_GLOBAL
-#  else
-#    define LT_DLGLOBAL		0
-#  endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-#  ifdef RTLD_LAZY
-#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
-#  else
-#    ifdef DL_LAZY
-#      define LT_DLLAZY_OR_NOW		DL_LAZY
-#    else
-#      ifdef RTLD_NOW
-#        define LT_DLLAZY_OR_NOW	RTLD_NOW
-#      else
-#        ifdef DL_NOW
-#          define LT_DLLAZY_OR_NOW	DL_NOW
-#        else
-#          define LT_DLLAZY_OR_NOW	0
-#        endif
-#      endif
-#    endif
-#  endif
-#endif
-
-/* When -fvisbility=hidden is used, assume the code has been annotated
-   correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
-int fnord () __attribute__((visibility("default")));
-#endif
-
-int fnord () { return 42; }
-int main ()
-{
-  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
-  int status = $lt_dlunknown;
-
-  if (self)
-    {
-      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
-      else
-        {
-	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
-          else puts (dlerror ());
-	}
-      /* dlclose (self); */
-    }
-  else
-    puts (dlerror ());
-
-  return status;
-}]
-_LT_EOF
-  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
-    lt_status=$?
-    case x$lt_status in
-      x$lt_dlno_uscore) $1 ;;
-      x$lt_dlneed_uscore) $2 ;;
-      x$lt_dlunknown|x*) $3 ;;
-    esac
-  else :
-    # compilation failed
-    $3
-  fi
-fi
-rm -fr conftest*
-])# _LT_TRY_DLOPEN_SELF
-
-
-# LT_SYS_DLOPEN_SELF
-# ------------------
-AC_DEFUN([LT_SYS_DLOPEN_SELF],
-[m4_require([_LT_HEADER_DLFCN])dnl
-if test "x$enable_dlopen" != xyes; then
-  enable_dlopen=unknown
-  enable_dlopen_self=unknown
-  enable_dlopen_self_static=unknown
-else
-  lt_cv_dlopen=no
-  lt_cv_dlopen_libs=
-
-  case $host_os in
-  beos*)
-    lt_cv_dlopen="load_add_on"
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=yes
-    ;;
-
-  mingw* | pw32* | cegcc*)
-    lt_cv_dlopen="LoadLibrary"
-    lt_cv_dlopen_libs=
-    ;;
-
-  cygwin*)
-    lt_cv_dlopen="dlopen"
-    lt_cv_dlopen_libs=
-    ;;
-
-  darwin*)
-  # if libdl is installed we need to link against it
-    AC_CHECK_LIB([dl], [dlopen],
-		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
-    lt_cv_dlopen="dyld"
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=yes
-    ])
-    ;;
-
-  *)
-    AC_CHECK_FUNC([shl_load],
-	  [lt_cv_dlopen="shl_load"],
-      [AC_CHECK_LIB([dld], [shl_load],
-	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
-	[AC_CHECK_FUNC([dlopen],
-	      [lt_cv_dlopen="dlopen"],
-	  [AC_CHECK_LIB([dl], [dlopen],
-		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
-	    [AC_CHECK_LIB([svld], [dlopen],
-		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
-	      [AC_CHECK_LIB([dld], [dld_link],
-		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
-	      ])
-	    ])
-	  ])
-	])
-      ])
-    ;;
-  esac
-
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
-    enable_dlopen=no
-  fi
-
-  case $lt_cv_dlopen in
-  dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
-
-    save_LDFLAGS="$LDFLAGS"
-    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
-
-    save_LIBS="$LIBS"
-    LIBS="$lt_cv_dlopen_libs $LIBS"
-
-    AC_CACHE_CHECK([whether a program can dlopen itself],
-	  lt_cv_dlopen_self, [dnl
-	  _LT_TRY_DLOPEN_SELF(
-	    lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
-	    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
-    ])
-
-    if test "x$lt_cv_dlopen_self" = xyes; then
-      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
-      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
-	  lt_cv_dlopen_self_static, [dnl
-	  _LT_TRY_DLOPEN_SELF(
-	    lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
-	    lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)
-      ])
-    fi
-
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
-    ;;
-  esac
-
-  case $lt_cv_dlopen_self in
-  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
-  *) enable_dlopen_self=unknown ;;
-  esac
-
-  case $lt_cv_dlopen_self_static in
-  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
-  *) enable_dlopen_self_static=unknown ;;
-  esac
-fi
-_LT_DECL([dlopen_support], [enable_dlopen], [0],
-	 [Whether dlopen is supported])
-_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
-	 [Whether dlopen of programs is supported])
-_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
-	 [Whether dlopen of statically linked programs is supported])
-])# LT_SYS_DLOPEN_SELF
-
-# Old name:
-AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
-
-
-# _LT_COMPILER_C_O([TAGNAME])
-# ---------------------------
-# Check to see if options -c and -o are simultaneously supported by compiler.
-# This macro does not hard code the compiler like AC_PROG_CC_C_O.
-m4_defun([_LT_COMPILER_C_O],
-[m4_require([_LT_DECL_SED])dnl
-m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_TAG_COMPILER])dnl
-AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
-  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
-  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
-   $RM -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&AS_MESSAGE_LOG_FD
-   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
-     fi
-   fi
-   chmod u+w . 2>&AS_MESSAGE_LOG_FD
-   $RM conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
-   $RM out/* && rmdir out
-   cd ..
-   $RM -r conftest
-   $RM conftest*
-])
-_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
-	[Does compiler simultaneously support -c and -o options?])
-])# _LT_COMPILER_C_O
-
-
-# _LT_COMPILER_FILE_LOCKS([TAGNAME])
-# ----------------------------------
-# Check to see if we can do hard links to lock some files if needed
-m4_defun([_LT_COMPILER_FILE_LOCKS],
-[m4_require([_LT_ENABLE_LOCK])dnl
-m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-_LT_COMPILER_C_O([$1])
-
-hard_links="nottested"
-if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  AC_MSG_CHECKING([if we can lock with hard links])
-  hard_links=yes
-  $RM conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  AC_MSG_RESULT([$hard_links])
-  if test "$hard_links" = no; then
-    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
-    need_locks=warn
-  fi
-else
-  need_locks=no
-fi
-_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
-])# _LT_COMPILER_FILE_LOCKS
-
-
-# _LT_CHECK_OBJDIR
-# ----------------
-m4_defun([_LT_CHECK_OBJDIR],
-[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
-[rm -f .libs 2>/dev/null
-mkdir .libs 2>/dev/null
-if test -d .libs; then
-  lt_cv_objdir=.libs
-else
-  # MS-DOS does not allow filenames that begin with a dot.
-  lt_cv_objdir=_libs
-fi
-rmdir .libs 2>/dev/null])
-objdir=$lt_cv_objdir
-_LT_DECL([], [objdir], [0],
-         [The name of the directory that contains temporary libtool files])dnl
-m4_pattern_allow([LT_OBJDIR])dnl
-AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
-  [Define to the sub-directory in which libtool stores uninstalled libraries.])
-])# _LT_CHECK_OBJDIR
-
-
-# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
-# --------------------------------------
-# Check hardcoding attributes.
-m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
-[AC_MSG_CHECKING([how to hardcode library paths into programs])
-_LT_TAGVAR(hardcode_action, $1)=
-if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
-   test -n "$_LT_TAGVAR(runpath_var, $1)" ||
-   test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
-
-  # We can hardcode non-existent directories.
-  if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
-     test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
-    # Linking always hardcodes the temporary library directory.
-    _LT_TAGVAR(hardcode_action, $1)=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    _LT_TAGVAR(hardcode_action, $1)=immediate
-  fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  _LT_TAGVAR(hardcode_action, $1)=unsupported
-fi
-AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
-
-if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
-   test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
-_LT_TAGDECL([], [hardcode_action], [0],
-    [How to hardcode a shared library path into an executable])
-])# _LT_LINKER_HARDCODE_LIBPATH
-
-
-# _LT_CMD_STRIPLIB
-# ----------------
-m4_defun([_LT_CMD_STRIPLIB],
-[m4_require([_LT_DECL_EGREP])
-striplib=
-old_striplib=
-AC_MSG_CHECKING([whether stripping libraries is possible])
-if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
-  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
-  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
-  AC_MSG_RESULT([yes])
-else
-# FIXME - insert some real tests, host_os isn't really good enough
-  case $host_os in
-  darwin*)
-    if test -n "$STRIP" ; then
-      striplib="$STRIP -x"
-      old_striplib="$STRIP -S"
-      AC_MSG_RESULT([yes])
-    else
-      AC_MSG_RESULT([no])
-    fi
-    ;;
-  *)
-    AC_MSG_RESULT([no])
-    ;;
-  esac
-fi
-_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
-_LT_DECL([], [striplib], [1])
-])# _LT_CMD_STRIPLIB
-
-
-# _LT_SYS_DYNAMIC_LINKER([TAG])
-# -----------------------------
-# PORTME Fill in your ld.so characteristics
-m4_defun([_LT_SYS_DYNAMIC_LINKER],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-m4_require([_LT_DECL_EGREP])dnl
-m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_DECL_OBJDUMP])dnl
-m4_require([_LT_DECL_SED])dnl
-m4_require([_LT_CHECK_SHELL_FEATURES])dnl
-AC_MSG_CHECKING([dynamic linker characteristics])
-m4_if([$1],
-	[], [
-if test "$GCC" = yes; then
-  case $host_os in
-    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
-    *) lt_awk_arg="/^libraries:/" ;;
-  esac
-  case $host_os in
-    mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
-    *) lt_sed_strip_eq="s,=/,/,g" ;;
-  esac
-  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
-  case $lt_search_path_spec in
-  *\;*)
-    # if the path contains ";" then we assume it to be the separator
-    # otherwise default to the standard path separator (i.e. ":") - it is
-    # assumed that no part of a normal pathname contains ";" but that should
-    # okay in the real world where ";" in dirpaths is itself problematic.
-    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
-    ;;
-  *)
-    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
-    ;;
-  esac
-  # Ok, now we have the path, separated by spaces, we can step through it
-  # and add multilib dir if necessary.
-  lt_tmp_lt_search_path_spec=
-  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
-  for lt_sys_path in $lt_search_path_spec; do
-    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
-      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
-    else
-      test -d "$lt_sys_path" && \
-	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
-    fi
-  done
-  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS=" "; FS="/|\n";} {
-  lt_foo="";
-  lt_count=0;
-  for (lt_i = NF; lt_i > 0; lt_i--) {
-    if ($lt_i != "" && $lt_i != ".") {
-      if ($lt_i == "..") {
-        lt_count++;
-      } else {
-        if (lt_count == 0) {
-          lt_foo="/" $lt_i lt_foo;
-        } else {
-          lt_count--;
-        }
-      }
-    }
-  }
-  if (lt_foo != "") { lt_freq[[lt_foo]]++; }
-  if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
-}'`
-  # AWK program above erroneously prepends '/' to C:/dos/paths
-  # for these hosts.
-  case $host_os in
-    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
-      $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
-  esac
-  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
-else
-  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi])
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
-  shlibpath_var=LIBPATH
-
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
-  ;;
-
-aix[[4-9]]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
-    case $host_os in
-      aix4 | aix4.[[01]] | aix4.[[01]].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
-	:
-      else
-	can_build_shared=no
-      fi
-      ;;
-    esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
-      # If using run time linking (on AIX 4.2 or later) use lib.so
-      # instead of lib.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
-    shlibpath_var=LIBPATH
-  fi
-  ;;
-
-amigaos*)
-  case $host_cpu in
-  powerpc)
-    # Since July 2007 AmigaOS4 officially supports .so libraries.
-    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    ;;
-  m68k)
-    library_names_spec='$libname.ixlibrary $libname.a'
-    # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-    ;;
-  esac
-  ;;
-
-beos*)
-  library_names_spec='${libname}${shared_ext}'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  ;;
-
-bsdi[[45]]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
-
-cygwin* | mingw* | pw32* | cegcc*)
-  version_type=windows
-  shrext_cmds=".dll"
-  need_version=no
-  need_lib_prefix=no
-
-  case $GCC,$cc_basename in
-  yes,*)
-    # gcc
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname~
-      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
-        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
-      fi'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $RM \$dlpath'
-    shlibpath_overrides_runpath=yes
-
-    case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-m4_if([$1], [],[
-      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
-      ;;
-    mingw* | cegcc*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    esac
-    dynamic_linker='Win32 ld.exe'
-    ;;
-
-  *,cl*)
-    # Native MSVC
-    libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
-
-    case $build_os in
-    mingw*)
-      sys_lib_search_path_spec=
-      lt_save_ifs=$IFS
-      IFS=';'
-      for lt_path in $LIB
-      do
-        IFS=$lt_save_ifs
-        # Let DOS variable expansion print the short 8.3 style file name.
-        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
-        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
-      done
-      IFS=$lt_save_ifs
-      # Convert to MSYS style.
-      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`
-      ;;
-    cygwin*)
-      # Convert to unix form, then to dos form, then back to unix form
-      # but this time dos style (no spaces!) so that the unix form looks
-      # like /cygdrive/c/PROGRA~1:/cygdr...
-      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
-      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
-      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
-      ;;
-    *)
-      sys_lib_search_path_spec="$LIB"
-      if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
-        # It is most probably a Windows format PATH.
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-      else
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
-      fi
-      # FIXME: find the short name or the path components, as spaces are
-      # common. (e.g. "Program Files" -> "PROGRA~1")
-      ;;
-    esac
-
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $RM \$dlpath'
-    shlibpath_overrides_runpath=yes
-    dynamic_linker='Win32 link.exe'
-    ;;
-
-  *)
-    # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
-    dynamic_linker='Win32 ld.exe'
-    ;;
-  esac
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  ;;
-
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
-m4_if([$1], [],[
-  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
-  ;;
-
-dgux*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[[23]].*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-      need_version=no
-      need_lib_prefix=no
-      ;;
-    freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
-      need_version=yes
-      ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_os in
-  freebsd2.*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
-  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  *) # from 4.6 on, and DragonFly
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  esac
-  ;;
-
-gnu*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
-haiku*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
-  hardcode_into_libs=yes
-  ;;
-
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
-    fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  hppa*64*)
-    shrext_cmds='.sl'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
-  postinstall_cmds='chmod 555 $lib'
-  # or fails outright, so override atomically:
-  install_override_mode=555
-  ;;
-
-interix[[3-9]]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
-    *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux # correct to gnu/linux during the next big refactor
-	else
-		version_type=irix
-	fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
-  *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  hardcode_into_libs=yes
-  ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
-
-# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-
-  # Some binutils ld are patched to set DT_RUNPATH
-  AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath],
-    [lt_cv_shlibpath_overrides_runpath=no
-    save_LDFLAGS=$LDFLAGS
-    save_libdir=$libdir
-    eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
-	 LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
-    AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
-      [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
-	 [lt_cv_shlibpath_overrides_runpath=yes])])
-    LDFLAGS=$save_LDFLAGS
-    libdir=$save_libdir
-    ])
-  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
-
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
-
-  # Append ld.so.conf contents to the search path
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
-  fi
-
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
-
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    dynamic_linker='NetBSD ld.elf_so'
-  fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  ;;
-
-newsos6)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
-
-*nto* | *qnx*)
-  version_type=qnx
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='ldqnx.so'
-  ;;
-
-openbsd*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
-  need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[[89]] | openbsd2.[[89]].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
-  else
-    shlibpath_overrides_runpath=yes
-  fi
-  ;;
-
-os2*)
-  libname_spec='$name'
-  shrext_cmds=".dll"
-  need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
-  ;;
-
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
-  ;;
-
-rdos*)
-  dynamic_linker=no
-  ;;
-
-solaris*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  ;;
-
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
-  fi
-  need_version=yes
-  ;;
-
-sysv4 | sysv4.3*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      runpath_var=LD_RUN_PATH
-      ;;
-    siemens)
-      need_lib_prefix=no
-      ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
-      ;;
-  esac
-  ;;
-
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
-
-tpf*)
-  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
-uts4*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-*)
-  dynamic_linker=no
-  ;;
-esac
-AC_MSG_RESULT([$dynamic_linker])
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
-fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
-fi
-
-_LT_DECL([], [variables_saved_for_relink], [1],
-    [Variables whose values should be saved in libtool wrapper scripts and
-    restored at link time])
-_LT_DECL([], [need_lib_prefix], [0],
-    [Do we need the "lib" prefix for modules?])
-_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
-_LT_DECL([], [version_type], [0], [Library versioning type])
-_LT_DECL([], [runpath_var], [0],  [Shared library runtime path variable])
-_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
-_LT_DECL([], [shlibpath_overrides_runpath], [0],
-    [Is shlibpath searched before the hard-coded library search path?])
-_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
-_LT_DECL([], [library_names_spec], [1],
-    [[List of archive names.  First name is the real one, the rest are links.
-    The last name is the one that the linker finds with -lNAME]])
-_LT_DECL([], [soname_spec], [1],
-    [[The coded name of the library, if different from the real name]])
-_LT_DECL([], [install_override_mode], [1],
-    [Permission mode override for installation of shared libraries])
-_LT_DECL([], [postinstall_cmds], [2],
-    [Command to use after installation of a shared archive])
-_LT_DECL([], [postuninstall_cmds], [2],
-    [Command to use after uninstallation of a shared archive])
-_LT_DECL([], [finish_cmds], [2],
-    [Commands used to finish a libtool library installation in a directory])
-_LT_DECL([], [finish_eval], [1],
-    [[As "finish_cmds", except a single script fragment to be evaled but
-    not shown]])
-_LT_DECL([], [hardcode_into_libs], [0],
-    [Whether we should hardcode library paths into libraries])
-_LT_DECL([], [sys_lib_search_path_spec], [2],
-    [Compile-time system search path for libraries])
-_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
-    [Run-time system search path for libraries])
-])# _LT_SYS_DYNAMIC_LINKER
-
-
-# _LT_PATH_TOOL_PREFIX(TOOL)
-# --------------------------
-# find a file program which can recognize shared library
-AC_DEFUN([_LT_PATH_TOOL_PREFIX],
-[m4_require([_LT_DECL_EGREP])dnl
-AC_MSG_CHECKING([for $1])
-AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
-[case $MAGIC_CMD in
-[[\\/*] |  ?:[\\/]*])
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
-  ;;
-*)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-dnl $ac_dummy forces splitting on constant user-supplied paths.
-dnl POSIX.2 word splitting is done only on the output of word expansions,
-dnl not every word.  This closes a longstanding sh security hole.
-  ac_dummy="m4_if([$2], , $PATH, [$2])"
-  for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$1; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
-      if test -n "$file_magic_test_file"; then
-	case $deplibs_check_method in
-	"file_magic "*)
-	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
-	    $EGREP "$file_magic_regex" > /dev/null; then
-	    :
-	  else
-	    cat <<_LT_EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such.  This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem.  Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-
-_LT_EOF
-	  fi ;;
-	esac
-      fi
-      break
-    fi
-  done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
-  ;;
-esac])
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
-  AC_MSG_RESULT($MAGIC_CMD)
-else
-  AC_MSG_RESULT(no)
-fi
-_LT_DECL([], [MAGIC_CMD], [0],
-	 [Used to examine libraries when file_magic_cmd begins with "file"])dnl
-])# _LT_PATH_TOOL_PREFIX
-
-# Old name:
-AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
-
-
-# _LT_PATH_MAGIC
-# --------------
-# find a file program which can recognize a shared library
-m4_defun([_LT_PATH_MAGIC],
-[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
-if test -z "$lt_cv_path_MAGIC_CMD"; then
-  if test -n "$ac_tool_prefix"; then
-    _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
-  else
-    MAGIC_CMD=:
-  fi
-fi
-])# _LT_PATH_MAGIC
-
-
-# LT_PATH_LD
-# ----------
-# find the pathname to the GNU or non-GNU linker
-AC_DEFUN([LT_PATH_LD],
-[AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-m4_require([_LT_DECL_SED])dnl
-m4_require([_LT_DECL_EGREP])dnl
-m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
-
-AC_ARG_WITH([gnu-ld],
-    [AS_HELP_STRING([--with-gnu-ld],
-	[assume the C compiler uses GNU ld @<:@default=no@:>@])],
-    [test "$withval" = no || with_gnu_ld=yes],
-    [with_gnu_ld=no])dnl
-
-ac_prog=ld
-if test "$GCC" = yes; then
-  # Check if gcc -print-prog-name=ld gives a path.
-  AC_MSG_CHECKING([for ld used by $CC])
-  case $host in
-  *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
-    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
-  *)
-    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
-  esac
-  case $ac_prog in
-    # Accept absolute paths.
-    [[\\/]]* | ?:[[\\/]]*)
-      re_direlt='/[[^/]][[^/]]*/\.\./'
-      # Canonicalize the pathname of ld
-      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
-      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
-	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
-      done
-      test -z "$LD" && LD="$ac_prog"
-      ;;
-  "")
-    # If it fails, then pretend we aren't using GCC.
-    ac_prog=ld
-    ;;
-  *)
-    # If it is relative, then search for the first ld in PATH.
-    with_gnu_ld=unknown
-    ;;
-  esac
-elif test "$with_gnu_ld" = yes; then
-  AC_MSG_CHECKING([for GNU ld])
-else
-  AC_MSG_CHECKING([for non-GNU ld])
-fi
-AC_CACHE_VAL(lt_cv_path_LD,
-[if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
-      # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
-      # Break only if it was the GNU/non-GNU ld that we prefer.
-      case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then
-    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
-    lt_cv_file_magic_cmd='func_win32_libid'
-  else
-    # Keep this pattern in sync with the one in func_win32_libid.
-    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
-    lt_cv_file_magic_cmd='$OBJDUMP -f'
-  fi
-  ;;
-
-cegcc*)
-  # use the weaker test based on 'objdump'. See mingw*.
-  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
-  lt_cv_file_magic_cmd='$OBJDUMP -f'
-  ;;
-
-darwin* | rhapsody*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-freebsd* | dragonfly*)
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
-    case $host_cpu in
-    i*86 )
-      # Not sure whether the presence of OpenBSD here was a mistake.
-      # Let's accept both of them until this is cleared up.
-      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
-      lt_cv_file_magic_cmd=/usr/bin/file
-      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
-      ;;
-    esac
-  else
-    lt_cv_deplibs_check_method=pass_all
-  fi
-  ;;
-
-gnu*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-haiku*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-hpux10.20* | hpux11*)
-  lt_cv_file_magic_cmd=/usr/bin/file
-  case $host_cpu in
-  ia64*)
-    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
-    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
-    ;;
-  hppa*64*)
-    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]']
-    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
-    ;;
-  *)
-    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library'
-    lt_cv_file_magic_test_file=/usr/lib/libc.sl
-    ;;
-  esac
-  ;;
-
-interix[[3-9]]*)
-  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
-  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
-  ;;
-
-irix5* | irix6* | nonstopux*)
-  case $LD in
-  *-32|*"-32 ") libmagic=32-bit;;
-  *-n32|*"-n32 ") libmagic=N32;;
-  *-64|*"-64 ") libmagic=64-bit;;
-  *) libmagic=never-match;;
-  esac
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-netbsd*)
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
-  else
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
-  fi
-  ;;
-
-newos6*)
-  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
-  lt_cv_file_magic_cmd=/usr/bin/file
-  lt_cv_file_magic_test_file=/usr/lib/libnls.so
-  ;;
-
-*nto* | *qnx*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
-  else
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
-  fi
-  ;;
-
-osf3* | osf4* | osf5*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-rdos*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-solaris*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-sysv4 | sysv4.3*)
-  case $host_vendor in
-  motorola)
-    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
-    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
-    ;;
-  ncr)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  sequent)
-    lt_cv_file_magic_cmd='/bin/file'
-    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
-    ;;
-  sni)
-    lt_cv_file_magic_cmd='/bin/file'
-    lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
-    lt_cv_file_magic_test_file=/lib/libc.so
-    ;;
-  siemens)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  pc)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  esac
-  ;;
-
-tpf*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-esac
-])
-
-file_magic_glob=
-want_nocaseglob=no
-if test "$build" = "$host"; then
-  case $host_os in
-  mingw* | pw32*)
-    if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
-      want_nocaseglob=yes
-    else
-      file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"`
-    fi
-    ;;
-  esac
-fi
-
-file_magic_cmd=$lt_cv_file_magic_cmd
-deplibs_check_method=$lt_cv_deplibs_check_method
-test -z "$deplibs_check_method" && deplibs_check_method=unknown
-
-_LT_DECL([], [deplibs_check_method], [1],
-    [Method to check whether dependent libraries are shared objects])
-_LT_DECL([], [file_magic_cmd], [1],
-    [Command to use when deplibs_check_method = "file_magic"])
-_LT_DECL([], [file_magic_glob], [1],
-    [How to find potential files when deplibs_check_method = "file_magic"])
-_LT_DECL([], [want_nocaseglob], [1],
-    [Find potential files using nocaseglob when deplibs_check_method = "file_magic"])
-])# _LT_CHECK_MAGIC_METHOD
-
-
-# LT_PATH_NM
-# ----------
-# find the pathname to a BSD- or MS-compatible name lister
-AC_DEFUN([LT_PATH_NM],
-[AC_REQUIRE([AC_PROG_CC])dnl
-AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
-[if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  : ${lt_cv_path_NM=no}
-fi])
-if test "$lt_cv_path_NM" != "no"; then
-  NM="$lt_cv_path_NM"
-else
-  # Didn't find any BSD compatible name lister, look for dumpbin.
-  if test -n "$DUMPBIN"; then :
-    # Let the user override the test.
-  else
-    AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
-    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
-    *COFF*)
-      DUMPBIN="$DUMPBIN -symbols"
-      ;;
-    *)
-      DUMPBIN=:
-      ;;
-    esac
-  fi
-  AC_SUBST([DUMPBIN])
-  if test "$DUMPBIN" != ":"; then
-    NM="$DUMPBIN"
-  fi
-fi
-test -z "$NM" && NM=nm
-AC_SUBST([NM])
-_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
-
-AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
-  [lt_cv_nm_interface="BSD nm"
-  echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
-  (eval "$ac_compile" 2>conftest.err)
-  cat conftest.err >&AS_MESSAGE_LOG_FD
-  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
-  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
-  cat conftest.err >&AS_MESSAGE_LOG_FD
-  (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD)
-  cat conftest.out >&AS_MESSAGE_LOG_FD
-  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
-    lt_cv_nm_interface="MS dumpbin"
-  fi
-  rm -f conftest*])
-])# LT_PATH_NM
-
-# Old names:
-AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
-AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AM_PROG_NM], [])
-dnl AC_DEFUN([AC_PROG_NM], [])
-
-# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
-# --------------------------------
-# how to determine the name of the shared library
-# associated with a specific link library.
-#  -- PORTME fill in with the dynamic library characteristics
-m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB],
-[m4_require([_LT_DECL_EGREP])
-m4_require([_LT_DECL_OBJDUMP])
-m4_require([_LT_DECL_DLLTOOL])
-AC_CACHE_CHECK([how to associate runtime and link libraries],
-lt_cv_sharedlib_from_linklib_cmd,
-[lt_cv_sharedlib_from_linklib_cmd='unknown'
-
-case $host_os in
-cygwin* | mingw* | pw32* | cegcc*)
-  # two different shell functions defined in ltmain.sh
-  # decide which to use based on capabilities of $DLLTOOL
-  case `$DLLTOOL --help 2>&1` in
-  *--identify-strict*)
-    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
-    ;;
-  *)
-    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
-    ;;
-  esac
-  ;;
-*)
-  # fallback: assume linklib IS sharedlib
-  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
-  ;;
-esac
-])
-sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
-test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
-
-_LT_DECL([], [sharedlib_from_linklib_cmd], [1],
-    [Command to associate shared and link libraries])
-])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
-
-
-# _LT_PATH_MANIFEST_TOOL
-# ----------------------
-# locate the manifest tool
-m4_defun([_LT_PATH_MANIFEST_TOOL],
-[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :)
-test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
-AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool],
-  [lt_cv_path_mainfest_tool=no
-  echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD
-  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
-  cat conftest.err >&AS_MESSAGE_LOG_FD
-  if $GREP 'Manifest Tool' conftest.out > /dev/null; then
-    lt_cv_path_mainfest_tool=yes
-  fi
-  rm -f conftest*])
-if test "x$lt_cv_path_mainfest_tool" != xyes; then
-  MANIFEST_TOOL=:
-fi
-_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
-])# _LT_PATH_MANIFEST_TOOL
-
-
-# LT_LIB_M
-# --------
-# check for math library
-AC_DEFUN([LT_LIB_M],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-LIBM=
-case $host in
-*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
-  # These system don't have libm, or don't need it
-  ;;
-*-ncr-sysv4.3*)
-  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
-  AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
-  ;;
-*)
-  AC_CHECK_LIB(m, cos, LIBM="-lm")
-  ;;
-esac
-AC_SUBST([LIBM])
-])# LT_LIB_M
-
-# Old name:
-AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_CHECK_LIBM], [])
-
-
-# _LT_COMPILER_NO_RTTI([TAGNAME])
-# -------------------------------
-m4_defun([_LT_COMPILER_NO_RTTI],
-[m4_require([_LT_TAG_COMPILER])dnl
-
-_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
-
-if test "$GCC" = yes; then
-  case $cc_basename in
-  nvcc*)
-    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
-  *)
-    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;;
-  esac
-
-  _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
-    lt_cv_prog_compiler_rtti_exceptions,
-    [-fno-rtti -fno-exceptions], [],
-    [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
-fi
-_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
-	[Compiler flag to turn off builtin functions])
-])# _LT_COMPILER_NO_RTTI
-
-
-# _LT_CMD_GLOBAL_SYMBOLS
-# ----------------------
-m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([AC_PROG_AWK])dnl
-AC_REQUIRE([LT_PATH_NM])dnl
-AC_REQUIRE([LT_PATH_LD])dnl
-m4_require([_LT_DECL_SED])dnl
-m4_require([_LT_DECL_EGREP])dnl
-m4_require([_LT_TAG_COMPILER])dnl
-
-# Check for command to grab the raw symbol name followed by C symbol from nm.
-AC_MSG_CHECKING([command to parse $NM output from $compiler object])
-AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
-[
-# These are sane defaults that work on at least a few old systems.
-# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
-
-# Character class describing NM global symbol codes.
-symcode='[[BCDEGRST]]'
-
-# Regexp to match symbols that can be accessed directly from C.
-sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
-
-# Define system-specific variables.
-case $host_os in
-aix*)
-  symcode='[[BCDT]]'
-  ;;
-cygwin* | mingw* | pw32* | cegcc*)
-  symcode='[[ABCDGISTW]]'
-  ;;
-hpux*)
-  if test "$host_cpu" = ia64; then
-    symcode='[[ABCDEGRST]]'
-  fi
-  ;;
-irix* | nonstopux*)
-  symcode='[[BCDEGRST]]'
-  ;;
-osf*)
-  symcode='[[BCDEGQRST]]'
-  ;;
-solaris*)
-  symcode='[[BDRT]]'
-  ;;
-sco3.2v5*)
-  symcode='[[DT]]'
-  ;;
-sysv4.2uw2*)
-  symcode='[[DT]]'
-  ;;
-sysv5* | sco5v6* | unixware* | OpenUNIX*)
-  symcode='[[ABDT]]'
-  ;;
-sysv4)
-  symcode='[[DFNSTU]]'
-  ;;
-esac
-
-# If we're using GNU nm, then use its standard symbol codes.
-case `$NM -V 2>&1` in
-*GNU* | *'with BFD'*)
-  symcode='[[ABCDGIRSTW]]' ;;
-esac
-
-# Transform an extracted symbol line into a proper C declaration.
-# Some systems (esp. on ia64) link data and code symbols differently,
-# so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
-
-# Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
-
-# Handle CRLF in mingw tool chain
-opt_cr=
-case $build_os in
-mingw*)
-  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
-  ;;
-esac
-
-# Try without a prefix underscore, then with it.
-for ac_symprfx in "" "_"; do
-
-  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
-  symxfrm="\\1 $ac_symprfx\\2 \\2"
-
-  # Write the raw and C identifiers.
-  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-    # Fake it for dumpbin and say T for any non-static function
-    # and D for any global variable.
-    # Also find C++ and __fastcall symbols from MSVC++,
-    # which start with @ or ?.
-    lt_cv_sys_global_symbol_pipe="$AWK ['"\
-"     {last_section=section; section=\$ 3};"\
-"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
-"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
-"     \$ 0!~/External *\|/{next};"\
-"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
-"     {if(hide[section]) next};"\
-"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
-"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
-"     ' prfx=^$ac_symprfx]"
-  else
-    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[	 ]]\($symcode$symcode*\)[[	 ]][[	 ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
-  fi
-  lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
-
-  # Check to see that the pipe works correctly.
-  pipe_works=no
-
-  rm -f conftest*
-  cat > conftest.$ac_ext <<_LT_EOF
-#ifdef __cplusplus
-extern "C" {
-#endif
-char nm_test_var;
-void nm_test_func(void);
-void nm_test_func(void){}
-#ifdef __cplusplus
-}
-#endif
-int main(){nm_test_var='a';nm_test_func();return(0);}
-_LT_EOF
-
-  if AC_TRY_EVAL(ac_compile); then
-    # Now try to grab the symbols.
-    nlist=conftest.nm
-    if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
-      # Try sorting and uniquifying the output.
-      if sort "$nlist" | uniq > "$nlist"T; then
-	mv -f "$nlist"T "$nlist"
-      else
-	rm -f "$nlist"T
-      fi
-
-      # Make sure that we snagged all the symbols we need.
-      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
-	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
-	  cat <<_LT_EOF > conftest.$ac_ext
-/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
-   relocations are performed -- see ld's documentation on pseudo-relocs.  */
-# define LT@&t@_DLSYM_CONST
-#elif defined(__osf__)
-/* This system does not cope well with relocations in const data.  */
-# define LT@&t@_DLSYM_CONST
-#else
-# define LT@&t@_DLSYM_CONST const
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-_LT_EOF
-	  # Now generate the symbol file.
-	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
-
-	  cat <<_LT_EOF >> conftest.$ac_ext
-
-/* The mapping between symbol names and symbols.  */
-LT@&t@_DLSYM_CONST struct {
-  const char *name;
-  void       *address;
-}
-lt__PROGRAM__LTX_preloaded_symbols[[]] =
-{
-  { "@PROGRAM@", (void *) 0 },
-_LT_EOF
-	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
-	  cat <<\_LT_EOF >> conftest.$ac_ext
-  {0, (void *) 0}
-};
-
-/* This works around a problem in FreeBSD linker */
-#ifdef FREEBSD_WORKAROUND
-static const void *lt_preloaded_setup() {
-  return lt__PROGRAM__LTX_preloaded_symbols;
-}
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-_LT_EOF
-	  # Now try linking the two files.
-	  mv conftest.$ac_objext conftstm.$ac_objext
-	  lt_globsym_save_LIBS=$LIBS
-	  lt_globsym_save_CFLAGS=$CFLAGS
-	  LIBS="conftstm.$ac_objext"
-	  CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
-	  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
-	    pipe_works=yes
-	  fi
-	  LIBS=$lt_globsym_save_LIBS
-	  CFLAGS=$lt_globsym_save_CFLAGS
-	else
-	  echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
-	fi
-      else
-	echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
-      fi
-    else
-      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
-    fi
-  else
-    echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
-    cat conftest.$ac_ext >&5
-  fi
-  rm -rf conftest* conftst*
-
-  # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
-    break
-  else
-    lt_cv_sys_global_symbol_pipe=
-  fi
-done
-])
-if test -z "$lt_cv_sys_global_symbol_pipe"; then
-  lt_cv_sys_global_symbol_to_cdecl=
-fi
-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
-  AC_MSG_RESULT(failed)
-else
-  AC_MSG_RESULT(ok)
-fi
-
-# Response file support.
-if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-  nm_file_list_spec='@'
-elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then
-  nm_file_list_spec='@'
-fi
-
-_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
-    [Take the output of nm and produce a listing of raw symbols and C names])
-_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
-    [Transform the output of nm in a proper C declaration])
-_LT_DECL([global_symbol_to_c_name_address],
-    [lt_cv_sys_global_symbol_to_c_name_address], [1],
-    [Transform the output of nm in a C name address pair])
-_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
-    [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
-    [Transform the output of nm in a C name address pair when lib prefix is needed])
-_LT_DECL([], [nm_file_list_spec], [1],
-    [Specify filename containing input files for $NM])
-]) # _LT_CMD_GLOBAL_SYMBOLS
-
-
-# _LT_COMPILER_PIC([TAGNAME])
-# ---------------------------
-m4_defun([_LT_COMPILER_PIC],
-[m4_require([_LT_TAG_COMPILER])dnl
-_LT_TAGVAR(lt_prog_compiler_wl, $1)=
-_LT_TAGVAR(lt_prog_compiler_pic, $1)=
-_LT_TAGVAR(lt_prog_compiler_static, $1)=
-
-m4_if([$1], [CXX], [
-  # C++ specific cases for pic, static, wl, etc.
-  if test "$GXX" = yes; then
-    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
-
-    case $host_os in
-    aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      fi
-      ;;
-
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-        ;;
-      m68k)
-            # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
-            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
-        ;;
-      esac
-      ;;
-
-    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
-    mingw* | cygwin* | os2* | pw32* | cegcc*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      # Although the cygwin gcc ignores -fPIC, still need this for old-style
-      # (--disable-auto-import) libraries
-      m4_if([$1], [GCJ], [],
-	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
-      ;;
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
-      ;;
-    *djgpp*)
-      # DJGPP does not support shared libraries at all
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)=
-      ;;
-    haiku*)
-      # PIC is the default for Haiku.
-      # The "-static" flag exists, but is broken.
-      _LT_TAGVAR(lt_prog_compiler_static, $1)=
-      ;;
-    interix[[3-9]]*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	_LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
-      fi
-      ;;
-    hpux*)
-      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
-      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
-      # sets the default TLS model and affects inlining.
-      case $host_cpu in
-      hppa*64*)
-	;;
-      *)
-	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-	;;
-      esac
-      ;;
-    *qnx* | *nto*)
-      # QNX uses GNU C++, but need to define -shared option too, otherwise
-      # it will coredump.
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
-      ;;
-    *)
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-      ;;
-    esac
-  else
-    case $host_os in
-      aix[[4-9]]*)
-	# All AIX code is PIC.
-	if test "$host_cpu" = ia64; then
-	  # AIX 5 now supports IA64 processor
-	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-	else
-	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
-	fi
-	;;
-      chorus*)
-	case $cc_basename in
-	cxch68*)
-	  # Green Hills C++ Compiler
-	  # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
-	  ;;
-	esac
-	;;
-      mingw* | cygwin* | os2* | pw32* | cegcc*)
-	# This hack is so that the source file can tell whether it is being
-	# built for inclusion in a dll (and should export symbols for example).
-	m4_if([$1], [GCJ], [],
-	  [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
-	;;
-      dgux*)
-	case $cc_basename in
-	  ec++*)
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-	    ;;
-	  ghcx*)
-	    # Green Hills C++ Compiler
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      freebsd* | dragonfly*)
-	# FreeBSD uses GNU C++
-	;;
-      hpux9* | hpux10* | hpux11*)
-	case $cc_basename in
-	  CC*)
-	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
-	    if test "$host_cpu" != ia64; then
-	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
-	    fi
-	    ;;
-	  aCC*)
-	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
-	    case $host_cpu in
-	    hppa*64*|ia64*)
-	      # +Z the default
-	      ;;
-	    *)
-	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
-	      ;;
-	    esac
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      interix*)
-	# This is c89, which is MS Visual C++ (no shared libs)
-	# Anyone wants to do a port?
-	;;
-      irix5* | irix6* | nonstopux*)
-	case $cc_basename in
-	  CC*)
-	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
-	    # CC pic flag -KPIC is the default.
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      linux* | k*bsd*-gnu | kopensolaris*-gnu)
-	case $cc_basename in
-	  KCC*)
-	    # KAI C++ Compiler
-	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-	    ;;
-	  ecpc* )
-	    # old Intel C++ for x86_64 which still supported -KPIC.
-	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
-	    ;;
-	  icpc* )
-	    # Intel C++, used to be incompatible with GCC.
-	    # ICC 10 doesn't accept -KPIC any more.
-	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
-	    ;;
-	  pgCC* | pgcpp*)
-	    # Portland Group C++ compiler
-	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-	    ;;
-	  cxx*)
-	    # Compaq C++
-	    # Make sure the PIC flag is empty.  It appears that all Alpha
-	    # Linux and Compaq Tru64 Unix objects are PIC.
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
-	    ;;
-	  xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*)
-	    # IBM XL 8.0, 9.0 on PPC and BlueGene
-	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
-	    ;;
-	  *)
-	    case `$CC -V 2>&1 | sed 5q` in
-	    *Sun\ C*)
-	      # Sun C++ 5.9
-	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-	      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-	      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
-	      ;;
-	    esac
-	    ;;
-	esac
-	;;
-      lynxos*)
-	;;
-      m88k*)
-	;;
-      mvs*)
-	case $cc_basename in
-	  cxx*)
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      netbsd*)
-	;;
-      *qnx* | *nto*)
-        # QNX uses GNU C++, but need to define -shared option too, otherwise
-        # it will coredump.
-        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
-        ;;
-      osf3* | osf4* | osf5*)
-	case $cc_basename in
-	  KCC*)
-	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
-	    ;;
-	  RCC*)
-	    # Rational C++ 2.4.1
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
-	    ;;
-	  cxx*)
-	    # Digital/Compaq C++
-	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    # Make sure the PIC flag is empty.  It appears that all Alpha
-	    # Linux and Compaq Tru64 Unix objects are PIC.
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      psos*)
-	;;
-      solaris*)
-	case $cc_basename in
-	  CC* | sunCC*)
-	    # Sun C++ 4.2, 5.x and Centerline C++
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
-	    ;;
-	  gcx*)
-	    # Green Hills C++ Compiler
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      sunos4*)
-	case $cc_basename in
-	  CC*)
-	    # Sun C++ 4.x
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-	    ;;
-	  lcc*)
-	    # Lucid
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-	case $cc_basename in
-	  CC*)
-	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-	    ;;
-	esac
-	;;
-      tandem*)
-	case $cc_basename in
-	  NCC*)
-	    # NonStop-UX NCC 3.20
-	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      vxworks*)
-	;;
-      *)
-	_LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
-	;;
-    esac
-  fi
-],
-[
-  if test "$GCC" = yes; then
-    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
-
-    case $host_os in
-      aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      fi
-      ;;
-
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-        ;;
-      m68k)
-            # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
-            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
-        ;;
-      esac
-      ;;
-
-    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
-
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      # Although the cygwin gcc ignores -fPIC, still need this for old-style
-      # (--disable-auto-import) libraries
-      m4_if([$1], [GCJ], [],
-	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
-      ;;
-
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
-      ;;
-
-    haiku*)
-      # PIC is the default for Haiku.
-      # The "-static" flag exists, but is broken.
-      _LT_TAGVAR(lt_prog_compiler_static, $1)=
-      ;;
-
-    hpux*)
-      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
-      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
-      # sets the default TLS model and affects inlining.
-      case $host_cpu in
-      hppa*64*)
-	# +Z the default
-	;;
-      *)
-	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-	;;
-      esac
-      ;;
-
-    interix[[3-9]]*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
-
-    msdosdjgpp*)
-      # Just because we use GCC doesn't mean we suddenly get shared libraries
-      # on systems that don't support them.
-      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
-      enable_shared=no
-      ;;
-
-    *nto* | *qnx*)
-      # QNX uses GNU C++, but need to define -shared option too, otherwise
-      # it will coredump.
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	_LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
-      fi
-      ;;
-
-    *)
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-      ;;
-    esac
-
-    case $cc_basename in
-    nvcc*) # Cuda Compiler Driver 2.2
-      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker '
-      if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
-        _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)"
-      fi
-      ;;
-    esac
-  else
-    # PORTME Check for flag to pass linker flags through the system compiler.
-    case $host_os in
-    aix*)
-      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      else
-	_LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
-      fi
-      ;;
-
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      m4_if([$1], [GCJ], [],
-	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
-      ;;
-
-    hpux9* | hpux10* | hpux11*)
-      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	_LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
-	;;
-      esac
-      # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
-      ;;
-
-    irix5* | irix6* | nonstopux*)
-      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      # PIC (with -KPIC) is the default.
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
-      ;;
-
-    linux* | k*bsd*-gnu | kopensolaris*-gnu)
-      case $cc_basename in
-      # old Intel for x86_64 which still supported -KPIC.
-      ecc*)
-	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
-        ;;
-      # icc used to be incompatible with GCC.
-      # ICC 10 doesn't accept -KPIC any more.
-      icc* | ifort*)
-	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
-        ;;
-      # Lahey Fortran 8.1.
-      lf95*)
-	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	_LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'
-	_LT_TAGVAR(lt_prog_compiler_static, $1)='--static'
-	;;
-      nagfor*)
-	# NAG Fortran compiler
-	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'
-	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
-	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-	;;
-      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
-	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-        ;;
-      ccc*)
-        _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-        # All Alpha code is PIC.
-        _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
-        ;;
-      xl* | bgxl* | bgf* | mpixl*)
-	# IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
-	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
-	_LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
-	;;
-      *)
-	case `$CC -V 2>&1 | sed 5q` in
-	*Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*)
-	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
-	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-	  _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
-	  ;;
-	*Sun\ F* | *Sun*Fortran*)
-	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-	  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
-	  ;;
-	*Sun\ C*)
-	  # Sun C 5.9
-	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-	  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	  ;;
-        *Intel*\ [[CF]]*Compiler*)
-	  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
-	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
-	  ;;
-	*Portland\ Group*)
-	  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
-	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-	  ;;
-	esac
-	;;
-      esac
-      ;;
-
-    newsos6)
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      ;;
-
-    *nto* | *qnx*)
-      # QNX uses GNU C++, but need to define -shared option too, otherwise
-      # it will coredump.
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
-      ;;
-
-    osf3* | osf4* | osf5*)
-      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      # All OSF/1 code is PIC.
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
-      ;;
-
-    rdos*)
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
-      ;;
-
-    solaris*)
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
-	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
-      *)
-	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
-      esac
-      ;;
-
-    sunos4*)
-      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      ;;
-
-    sysv4 | sysv4.2uw2* | sysv4.3*)
-      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec ;then
-	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
-	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      fi
-      ;;
-
-    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      ;;
-
-    unicos*)
-      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
-      ;;
-
-    uts4*)
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      ;;
-
-    *)
-      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
-      ;;
-    esac
-  fi
-])
-case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
-  *djgpp*)
-    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
-    ;;
-  *)
-    _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
-    ;;
-esac
-
-AC_CACHE_CHECK([for $compiler option to produce PIC],
-  [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)],
-  [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
-_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
-  _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
-    [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
-    [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
-    [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
-     "" | " "*) ;;
-     *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
-     esac],
-    [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
-     _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
-fi
-_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
-	[Additional compiler flags for building library objects])
-
-_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
-	[How to pass a linker flag through the compiler])
-#
-# Check to make sure the static flag actually works.
-#
-wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
-_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
-  _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
-  $lt_tmp_static_flag,
-  [],
-  [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
-_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
-	[Compiler flag to prevent dynamic linking])
-])# _LT_COMPILER_PIC
-
-
-# _LT_LINKER_SHLIBS([TAGNAME])
-# ----------------------------
-# See if the linker supports building shared libraries.
-m4_defun([_LT_LINKER_SHLIBS],
-[AC_REQUIRE([LT_PATH_LD])dnl
-AC_REQUIRE([LT_PATH_NM])dnl
-m4_require([_LT_PATH_MANIFEST_TOOL])dnl
-m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_DECL_EGREP])dnl
-m4_require([_LT_DECL_SED])dnl
-m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
-m4_require([_LT_TAG_COMPILER])dnl
-AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
-m4_if([$1], [CXX], [
-  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
-  case $host_os in
-  aix[[4-9]]*)
-    # If we're using GNU nm, then we don't want the "-C" option.
-    # -C means demangle to AIX nm, but means don't demangle with GNU nm
-    # Also, AIX nm treats weak defined symbols like other global defined
-    # symbols, whereas GNU nm marks them as "W".
-    if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
-    else
-      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
-    fi
-    ;;
-  pw32*)
-    _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
-    ;;
-  cygwin* | mingw* | cegcc*)
-    case $cc_basename in
-    cl*)
-      _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
-      ;;
-    *)
-      _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
-      _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
-      ;;
-    esac
-    ;;
-  *)
-    _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-    ;;
-  esac
-], [
-  runpath_var=
-  _LT_TAGVAR(allow_undefined_flag, $1)=
-  _LT_TAGVAR(always_export_symbols, $1)=no
-  _LT_TAGVAR(archive_cmds, $1)=
-  _LT_TAGVAR(archive_expsym_cmds, $1)=
-  _LT_TAGVAR(compiler_needs_object, $1)=no
-  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-  _LT_TAGVAR(export_dynamic_flag_spec, $1)=
-  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  _LT_TAGVAR(hardcode_automatic, $1)=no
-  _LT_TAGVAR(hardcode_direct, $1)=no
-  _LT_TAGVAR(hardcode_direct_absolute, $1)=no
-  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-  _LT_TAGVAR(hardcode_libdir_separator, $1)=
-  _LT_TAGVAR(hardcode_minus_L, $1)=no
-  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-  _LT_TAGVAR(inherit_rpath, $1)=no
-  _LT_TAGVAR(link_all_deplibs, $1)=unknown
-  _LT_TAGVAR(module_cmds, $1)=
-  _LT_TAGVAR(module_expsym_cmds, $1)=
-  _LT_TAGVAR(old_archive_from_new_cmds, $1)=
-  _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
-  _LT_TAGVAR(thread_safe_flag_spec, $1)=
-  _LT_TAGVAR(whole_archive_flag_spec, $1)=
-  # include_expsyms should be a list of space-separated symbols to be *always*
-  # included in the symbol list
-  _LT_TAGVAR(include_expsyms, $1)=
-  # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
-  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
-  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
-  # platforms (ab)use it in PIC code, but their linkers get confused if
-  # the symbol is explicitly referenced.  Since portable code cannot
-  # rely on this symbol name, it's probably fine to never include it in
-  # preloaded symbol tables.
-  # Exclude shared library initialization/finalization symbols.
-dnl Note also adjust exclude_expsyms for C++ above.
-  extract_expsyms_cmds=
-
-  case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
-    # FIXME: the MSVC++ port hasn't been tested in a loooong time
-    # When not using gcc, we currently assume that we are using
-    # Microsoft Visual C++.
-    if test "$GCC" != yes; then
-      with_gnu_ld=no
-    fi
-    ;;
-  interix*)
-    # we just hope/assume this is gcc and not c89 (= MSVC++)
-    with_gnu_ld=yes
-    ;;
-  openbsd*)
-    with_gnu_ld=no
-    ;;
-  esac
-
-  _LT_TAGVAR(ld_shlibs, $1)=yes
-
-  # On some targets, GNU ld is compatible enough with the native linker
-  # that we're better off using the native interface for both.
-  lt_use_gnu_ld_interface=no
-  if test "$with_gnu_ld" = yes; then
-    case $host_os in
-      aix*)
-	# The AIX port of GNU ld has always aspired to compatibility
-	# with the native linker.  However, as the warning in the GNU ld
-	# block says, versions before 2.19.5* couldn't really create working
-	# shared libraries, regardless of the interface used.
-	case `$LD -v 2>&1` in
-	  *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
-	  *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;;
-	  *\ \(GNU\ Binutils\)\ [[3-9]]*) ;;
-	  *)
-	    lt_use_gnu_ld_interface=yes
-	    ;;
-	esac
-	;;
-      *)
-	lt_use_gnu_ld_interface=yes
-	;;
-    esac
-  fi
-
-  if test "$lt_use_gnu_ld_interface" = yes; then
-    # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
-
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-    else
-      _LT_TAGVAR(whole_archive_flag_spec, $1)=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>&1` in
-      *GNU\ gold*) supports_anon_versioning=yes ;;
-      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
-    # See if GNU ld supports shared libraries.
-    case $host_os in
-    aix[[3-9]]*)
-      # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
-	_LT_TAGVAR(ld_shlibs, $1)=no
-	cat <<_LT_EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.19, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support.  If you
-*** really care for shared libraries, you may want to install binutils
-*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
-*** You will then need to restart the configuration process.
-
-_LT_EOF
-      fi
-      ;;
-
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-            _LT_TAGVAR(archive_expsym_cmds, $1)=''
-        ;;
-      m68k)
-            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-            _LT_TAGVAR(hardcode_minus_L, $1)=yes
-        ;;
-      esac
-      ;;
-
-    beos*)
-      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-	# Joseph Beckenbach  says some releases of gcc
-	# support --undefined.  This deserves some investigation.  FIXME
-	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-      else
-	_LT_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-
-    cygwin* | mingw* | pw32* | cegcc*)
-      # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
-      # as there is no search path for DLLs.
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
-      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-      _LT_TAGVAR(always_export_symbols, $1)=no
-      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-      _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
-      _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
-
-      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      else
-	_LT_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-
-    haiku*)
-      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-      _LT_TAGVAR(link_all_deplibs, $1)=yes
-      ;;
-
-    interix[[3-9]]*)
-      _LT_TAGVAR(hardcode_direct, $1)=no
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-      # Instead, shared libraries are loaded at an image base (0x10000000 by
-      # default) and relocated if they conflict, which is a slow very memory
-      # consuming and fragmenting process.  To avoid this, we pick a random,
-      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      ;;
-
-    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
-      tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
-	case $cc_basename in
-	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
-	esac
-      fi
-      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
-      then
-	tmp_addflag=' $pic_flag'
-	tmp_sharedflag='-shared'
-	case $cc_basename,$host_cpu in
-        pgcc*)				# Portland Group C compiler
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95* | pgfortran*)
-					# Portland Group f77 and f90 compilers
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	lf95*)				# Lahey Fortran 8.1
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)=
-	  tmp_sharedflag='--shared' ;;
-	xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
-	  tmp_sharedflag='-qmkshrobj'
-	  tmp_addflag= ;;
-	nvcc*)	# Cuda Compiler Driver 2.2
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	  _LT_TAGVAR(compiler_needs_object, $1)=yes
-	  ;;
-	esac
-	case `$CC -V 2>&1 | sed 5q` in
-	*Sun\ C*)			# Sun C 5.9
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	  _LT_TAGVAR(compiler_needs_object, $1)=yes
-	  tmp_sharedflag='-G' ;;
-	*Sun\ F*)			# Sun Fortran 8.3
-	  tmp_sharedflag='-G' ;;
-	esac
-	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-        if test "x$supports_anon_versioning" = xyes; then
-          _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-        fi
-
-	case $cc_basename in
-	xlf* | bgf* | bgxlf* | mpixlf*)
-	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	  _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
-	  if test "x$supports_anon_versioning" = xyes; then
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
-	  fi
-	  ;;
-	esac
-      else
-        _LT_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-
-    netbsd*)
-      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
-	wlarc=
-      else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      fi
-      ;;
-
-    solaris*)
-      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
-	_LT_TAGVAR(ld_shlibs, $1)=no
-	cat <<_LT_EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
-      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	_LT_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-
-    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
-      case `$LD -v 2>&1` in
-        *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
-	_LT_TAGVAR(ld_shlibs, $1)=no
-	cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
-	;;
-	*)
-	  # For security reasons, it is highly recommended that you always
-	  # use absolute paths for naming shared libraries, and exclude the
-	  # DT_RUNPATH tag from executables and libraries.  But doing so
-	  # requires that you compile everything twice, which is a pain.
-	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  else
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	  fi
-	;;
-      esac
-      ;;
-
-    sunos4*)
-      _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      wlarc=
-      _LT_TAGVAR(hardcode_direct, $1)=yes
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    *)
-      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	_LT_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-    esac
-
-    if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
-      runpath_var=
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)=
-      _LT_TAGVAR(whole_archive_flag_spec, $1)=
-    fi
-  else
-    # PORTME fill in a description of your system's linker (not GNU ld)
-    case $host_os in
-    aix3*)
-      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-      _LT_TAGVAR(always_export_symbols, $1)=yes
-      _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
-      # Note: this linker hardcodes the directories in LIBPATH if there
-      # are no directories specified by -L.
-      _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
-	# Neither direct hardcoding nor static linking is supported with a
-	# broken collect2.
-	_LT_TAGVAR(hardcode_direct, $1)=unsupported
-      fi
-      ;;
-
-    aix[[4-9]]*)
-      if test "$host_cpu" = ia64; then
-	# On IA64, the linker does run time linking by default, so we don't
-	# have to do anything special.
-	aix_use_runtimelinking=no
-	exp_sym_flag='-Bexport'
-	no_entry_flag=""
-      else
-	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	# Also, AIX nm treats weak defined symbols like other global
-	# defined symbols, whereas GNU nm marks them as "W".
-	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
-	else
-	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
-	fi
-	aix_use_runtimelinking=no
-
-	# Test if we are trying to use run time linking or normal
-	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
-	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
-	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
-	    aix_use_runtimelinking=yes
-	    break
-	  fi
-	  done
-	  ;;
-	esac
-
-	exp_sym_flag='-bexport'
-	no_entry_flag='-bnoentry'
-      fi
-
-      # When large executables or shared objects are built, AIX ld can
-      # have problems creating the table of contents.  If linking a library
-      # or program results in "error TOC overflow" add -mminimal-toc to
-      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
-      _LT_TAGVAR(archive_cmds, $1)=''
-      _LT_TAGVAR(hardcode_direct, $1)=yes
-      _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
-      _LT_TAGVAR(link_all_deplibs, $1)=yes
-      _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
-
-      if test "$GCC" = yes; then
-	case $host_os in aix4.[[012]]|aix4.[[012]].*)
-	# We only want to do this on AIX 4.2 and lower, the check
-	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
-	  if test -f "$collect2name" &&
-	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
-	  then
-	  # We have reworked collect2
-	  :
-	  else
-	  # We have old collect2
-	  _LT_TAGVAR(hardcode_direct, $1)=unsupported
-	  # It fails to find uninstalled libraries when the uninstalled
-	  # path is not listed in the libpath.  Setting hardcode_minus_L
-	  # to unsupported forces relinking
-	  _LT_TAGVAR(hardcode_minus_L, $1)=yes
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-	  _LT_TAGVAR(hardcode_libdir_separator, $1)=
-	  fi
-	  ;;
-	esac
-	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
-      else
-	# not using gcc
-	if test "$host_cpu" = ia64; then
-	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-	# chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
-	  else
-	    shared_flag='${wl}-bM:SRE'
-	  fi
-	fi
-      fi
-
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
-      # It seems that -bexpall does not export symbols beginning with
-      # underscore (_), so it is better to generate a list of symbols to export.
-      _LT_TAGVAR(always_export_symbols, $1)=yes
-      if test "$aix_use_runtimelinking" = yes; then
-	# Warning - without using the other runtime loading flags (-brtl),
-	# -berok will link without error, but may produce a broken library.
-	_LT_TAGVAR(allow_undefined_flag, $1)='-berok'
-        # Determine the default libpath from the value encoded in an
-        # empty executable.
-        _LT_SYS_MODULE_PATH_AIX([$1])
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-      else
-	if test "$host_cpu" = ia64; then
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
-	  _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-	else
-	 # Determine the default libpath from the value encoded in an
-	 # empty executable.
-	 _LT_SYS_MODULE_PATH_AIX([$1])
-	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-	  # Warning - without using the other run time loading flags,
-	  # -berok will link without error, but may produce a broken library.
-	  _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-	  _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	  if test "$with_gnu_ld" = yes; then
-	    # We only use this code for GNU lds that support --whole-archive.
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
-	  else
-	    # Exported symbols can be pulled into shared objects from archives
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
-	  fi
-	  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-	fi
-      fi
-      ;;
-
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-            _LT_TAGVAR(archive_expsym_cmds, $1)=''
-        ;;
-      m68k)
-            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-            _LT_TAGVAR(hardcode_minus_L, $1)=yes
-        ;;
-      esac
-      ;;
-
-    bsdi[[45]]*)
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
-      ;;
-
-    cygwin* | mingw* | pw32* | cegcc*)
-      # When not using gcc, we currently assume that we are using
-      # Microsoft Visual C++.
-      # hardcode_libdir_flag_spec is actually meaningless, as there is
-      # no search path for DLLs.
-      case $cc_basename in
-      cl*)
-	# Native MSVC
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
-	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-	_LT_TAGVAR(always_export_symbols, $1)=yes
-	_LT_TAGVAR(file_list_spec, $1)='@'
-	# Tell ltmain to make .lib files, not .a files.
-	libext=lib
-	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
-	# FIXME: Setting linknames here is a bad hack.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	  else
-	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	  fi~
-	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	  linknames='
-	# The linker will not automatically build a static lib if we build a DLL.
-	# _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
-	_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-	_LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
-	_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
-	# Don't use ranlib
-	_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
-	_LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
-	  lt_tool_outputfile="@TOOL_OUTPUT@"~
-	  case $lt_outputfile in
-	    *.exe|*.EXE) ;;
-	    *)
-	      lt_outputfile="$lt_outputfile.exe"
-	      lt_tool_outputfile="$lt_tool_outputfile.exe"
-	      ;;
-	  esac~
-	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	    $RM "$lt_outputfile.manifest";
-	  fi'
-	;;
-      *)
-	# Assume MSVC wrapper
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
-	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-	# Tell ltmain to make .lib files, not .a files.
-	libext=lib
-	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
-	# FIXME: Setting linknames here is a bad hack.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
-	# The linker will automatically build a .lib file if we build a DLL.
-	_LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
-	# FIXME: Should let the user specify the lib program.
-	_LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
-	_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-	;;
-      esac
-      ;;
-
-    darwin* | rhapsody*)
-      _LT_DARWIN_LINKER_FEATURES($1)
-      ;;
-
-    dgux*)
-      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
-    # support.  Future versions do this automatically, but an explicit c++rt0.o
-    # does not break anything, and helps significantly (at the cost of a little
-    # extra space).
-    freebsd2.2*)
-      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-      _LT_TAGVAR(hardcode_direct, $1)=yes
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2.*)
-      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      _LT_TAGVAR(hardcode_direct, $1)=yes
-      _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | dragonfly*)
-      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-      _LT_TAGVAR(hardcode_direct, $1)=yes
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    hpux9*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      else
-	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      fi
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-      _LT_TAGVAR(hardcode_direct, $1)=yes
-
-      # hardcode_minus_L: Not really in the search PATH,
-      # but as the default location of the library.
-      _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-      ;;
-
-    hpux10*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      if test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
-	_LT_TAGVAR(hardcode_direct, $1)=yes
-	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-	# hardcode_minus_L: Not really in the search PATH,
-	# but as the default location of the library.
-	_LT_TAGVAR(hardcode_minus_L, $1)=yes
-      fi
-      ;;
-
-    hpux11*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	case $host_cpu in
-	hppa*64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      else
-	case $host_cpu in
-	hppa*64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	m4_if($1, [], [
-	  # Older versions of the 11.00 compiler do not understand -b yet
-	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
-	  _LT_LINKER_OPTION([if $CC understands -b],
-	    _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
-	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
-	    [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
-	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
-	  ;;
-	esac
-      fi
-      if test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
-
-	case $host_cpu in
-	hppa*64*|ia64*)
-	  _LT_TAGVAR(hardcode_direct, $1)=no
-	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	  ;;
-	*)
-	  _LT_TAGVAR(hardcode_direct, $1)=yes
-	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-
-	  # hardcode_minus_L: Not really in the search PATH,
-	  # but as the default location of the library.
-	  _LT_TAGVAR(hardcode_minus_L, $1)=yes
-	  ;;
-	esac
-      fi
-      ;;
-
-    irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	# Try to use the -exported_symbol ld option, if it does not
-	# work, assume that -exports_file does not work either and
-	# implicitly export all symbols.
-	# This should be the same for all languages, so no per-tag cache variable.
-	AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol],
-	  [lt_cv_irix_exported_symbol],
-	  [save_LDFLAGS="$LDFLAGS"
-	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
-	   AC_LINK_IFELSE(
-	     [AC_LANG_SOURCE(
-	        [AC_LANG_CASE([C], [[int foo (void) { return 0; }]],
-			      [C++], [[int foo (void) { return 0; }]],
-			      [Fortran 77], [[
-      subroutine foo
-      end]],
-			      [Fortran], [[
-      subroutine foo
-      end]])])],
-	      [lt_cv_irix_exported_symbol=yes],
-	      [lt_cv_irix_exported_symbol=no])
-           LDFLAGS="$save_LDFLAGS"])
-	if test "$lt_cv_irix_exported_symbol" = yes; then
-          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
-	fi
-      else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
-      fi
-      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-      _LT_TAGVAR(inherit_rpath, $1)=yes
-      _LT_TAGVAR(link_all_deplibs, $1)=yes
-      ;;
-
-    netbsd*)
-      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
-      else
-	_LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
-      fi
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-      _LT_TAGVAR(hardcode_direct, $1)=yes
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    newsos6)
-      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      _LT_TAGVAR(hardcode_direct, $1)=yes
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    *nto* | *qnx*)
-      ;;
-
-    openbsd*)
-      if test -f /usr/libexec/ld.so; then
-	_LT_TAGVAR(hardcode_direct, $1)=yes
-	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-	else
-	  case $host_os in
-	   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
-	     _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	     ;;
-	   *)
-	     _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	     ;;
-	  esac
-	fi
-      else
-	_LT_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-
-    os2*)
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
-      ;;
-
-    osf3*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-      fi
-      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-      ;;
-
-    osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-      else
-	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
-
-	# Both c and cxx compiler support -rpath directly
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
-      fi
-      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
-      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-      ;;
-
-    solaris*)
-      _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
-      else
-	case `$CC -V 2>&1` in
-	*"Compilers 5.0"*)
-	  wlarc=''
-	  _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
-	  ;;
-	*)
-	  wlarc='${wl}'
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
-	  ;;
-	esac
-      fi
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      case $host_os in
-      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
-      *)
-	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
-	# but is careful enough not to reorder.
-	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
-	else
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
-	fi
-	;;
-      esac
-      _LT_TAGVAR(link_all_deplibs, $1)=yes
-      ;;
-
-    sunos4*)
-      if test "x$host_vendor" = xsequent; then
-	# Use $CC to link under sequent, because it throws in some extra .o
-	# files that make .init and .fini sections work.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_TAGVAR(hardcode_direct, $1)=yes
-      _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    sysv4)
-      case $host_vendor in
-	sni)
-	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
-	;;
-	siemens)
-	  ## LD is ld it makes a PLAMLIB
-	  ## CC just makes a GrossModule.
-	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-	  _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
-	  _LT_TAGVAR(hardcode_direct, $1)=no
-        ;;
-	motorola)
-	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
-	;;
-      esac
-      runpath_var='LD_RUN_PATH'
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    sysv4.3*)
-      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	runpath_var=LD_RUN_PATH
-	hardcode_runpath_var=yes
-	_LT_TAGVAR(ld_shlibs, $1)=yes
-      fi
-      ;;
-
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
-
-    sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
-      # link with -lc, and that would cause any symbols used from libc to
-      # always be unresolved, which means just about no library would
-      # ever link correctly.  If we're not using GNU ld we use -z text
-      # though, which does catch some bad symbols but isn't as heavy-handed
-      # as -z defs.
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-      _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
-      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
-      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
-      _LT_TAGVAR(link_all_deplibs, $1)=yes
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
-
-    uts4*)
-      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      ;;
-
-    *)
-      _LT_TAGVAR(ld_shlibs, $1)=no
-      ;;
-    esac
-
-    if test x$host_vendor = xsni; then
-      case $host in
-      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
-	;;
-      esac
-    fi
-  fi
-])
-AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
-
-_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
-
-_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
-_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
-_LT_DECL([], [extract_expsyms_cmds], [2],
-    [The commands to extract the exported symbol list from a shared archive])
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
-x|xyes)
-  # Assume -lc should be added
-  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
-    case $_LT_TAGVAR(archive_cmds, $1) in
-    *'~'*)
-      # FIXME: we may have to deal with multi-command sequences.
-      ;;
-    '$CC '*)
-      # Test whether the compiler implicitly links with -lc since on some
-      # systems, -lgcc has to come before -lc. If gcc already passes -lc
-      # to ld, don't add -lc before -lgcc.
-      AC_CACHE_CHECK([whether -lc should be explicitly linked in],
-	[lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1),
-	[$RM conftest*
-	echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-	if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
-	  soname=conftest
-	  lib=conftest
-	  libobjs=conftest.$ac_objext
-	  deplibs=
-	  wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
-	  pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
-	  compiler_flags=-v
-	  linker_flags=-v
-	  verstring=
-	  output_objdir=.
-	  libname=conftest
-	  lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
-	  _LT_TAGVAR(allow_undefined_flag, $1)=
-	  if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
-	  then
-	    lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no
-	  else
-	    lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-	  fi
-	  _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
-	else
-	  cat conftest.err 1>&5
-	fi
-	$RM conftest*
-	])
-      _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)
-      ;;
-    esac
-  fi
-  ;;
-esac
-
-_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
-    [Whether or not to add -lc for building shared libraries])
-_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
-    [enable_shared_with_static_runtimes], [0],
-    [Whether or not to disallow shared libs when runtime libs are static])
-_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
-    [Compiler flag to allow reflexive dlopens])
-_LT_TAGDECL([], [whole_archive_flag_spec], [1],
-    [Compiler flag to generate shared objects directly from archives])
-_LT_TAGDECL([], [compiler_needs_object], [1],
-    [Whether the compiler copes with passing no objects directly])
-_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
-    [Create an old-style archive from a shared archive])
-_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
-    [Create a temporary old-style archive to link instead of a shared archive])
-_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
-_LT_TAGDECL([], [archive_expsym_cmds], [2])
-_LT_TAGDECL([], [module_cmds], [2],
-    [Commands used to build a loadable module if different from building
-    a shared archive.])
-_LT_TAGDECL([], [module_expsym_cmds], [2])
-_LT_TAGDECL([], [with_gnu_ld], [1],
-    [Whether we are building with GNU ld or not])
-_LT_TAGDECL([], [allow_undefined_flag], [1],
-    [Flag that allows shared libraries with undefined symbols to be built])
-_LT_TAGDECL([], [no_undefined_flag], [1],
-    [Flag that enforces no undefined symbols])
-_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
-    [Flag to hardcode $libdir into a binary during linking.
-    This must work even if $libdir does not exist])
-_LT_TAGDECL([], [hardcode_libdir_separator], [1],
-    [Whether we need a single "-rpath" flag with a separated argument])
-_LT_TAGDECL([], [hardcode_direct], [0],
-    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
-    DIR into the resulting binary])
-_LT_TAGDECL([], [hardcode_direct_absolute], [0],
-    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
-    DIR into the resulting binary and the resulting library dependency is
-    "absolute", i.e impossible to change by setting ${shlibpath_var} if the
-    library is relocated])
-_LT_TAGDECL([], [hardcode_minus_L], [0],
-    [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
-    into the resulting binary])
-_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
-    [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
-    into the resulting binary])
-_LT_TAGDECL([], [hardcode_automatic], [0],
-    [Set to "yes" if building a shared library automatically hardcodes DIR
-    into the library and all subsequent libraries and executables linked
-    against it])
-_LT_TAGDECL([], [inherit_rpath], [0],
-    [Set to yes if linker adds runtime paths of dependent libraries
-    to runtime path list])
-_LT_TAGDECL([], [link_all_deplibs], [0],
-    [Whether libtool must link a program against all its dependency libraries])
-_LT_TAGDECL([], [always_export_symbols], [0],
-    [Set to "yes" if exported symbols are required])
-_LT_TAGDECL([], [export_symbols_cmds], [2],
-    [The commands to list exported symbols])
-_LT_TAGDECL([], [exclude_expsyms], [1],
-    [Symbols that should not be listed in the preloaded symbols])
-_LT_TAGDECL([], [include_expsyms], [1],
-    [Symbols that must always be exported])
-_LT_TAGDECL([], [prelink_cmds], [2],
-    [Commands necessary for linking programs (against libraries) with templates])
-_LT_TAGDECL([], [postlink_cmds], [2],
-    [Commands necessary for finishing linking programs])
-_LT_TAGDECL([], [file_list_spec], [1],
-    [Specify filename containing input files])
-dnl FIXME: Not yet implemented
-dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
-dnl    [Compiler flag to generate thread safe objects])
-])# _LT_LINKER_SHLIBS
-
-
-# _LT_LANG_C_CONFIG([TAG])
-# ------------------------
-# Ensure that the configuration variables for a C compiler are suitably
-# defined.  These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
-m4_defun([_LT_LANG_C_CONFIG],
-[m4_require([_LT_DECL_EGREP])dnl
-lt_save_CC="$CC"
-AC_LANG_PUSH(C)
-
-# Source file extension for C test sources.
-ac_ext=c
-
-# Object file extension for compiled C test sources.
-objext=o
-_LT_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}'
-
-_LT_TAG_COMPILER
-# Save the default compiler, since it gets overwritten when the other
-# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
-compiler_DEFAULT=$CC
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-## CAVEAT EMPTOR:
-## There is no encapsulation within the following macros, do not change
-## the running order or otherwise move them around unless you know exactly
-## what you are doing...
-if test -n "$compiler"; then
-  _LT_COMPILER_NO_RTTI($1)
-  _LT_COMPILER_PIC($1)
-  _LT_COMPILER_C_O($1)
-  _LT_COMPILER_FILE_LOCKS($1)
-  _LT_LINKER_SHLIBS($1)
-  _LT_SYS_DYNAMIC_LINKER($1)
-  _LT_LINKER_HARDCODE_LIBPATH($1)
-  LT_SYS_DLOPEN_SELF
-  _LT_CMD_STRIPLIB
-
-  # Report which library types will actually be built
-  AC_MSG_CHECKING([if libtool supports shared libraries])
-  AC_MSG_RESULT([$can_build_shared])
-
-  AC_MSG_CHECKING([whether to build shared libraries])
-  test "$can_build_shared" = "no" && enable_shared=no
-
-  # On AIX, shared libraries and static libraries use the same namespace, and
-  # are all built from PIC.
-  case $host_os in
-  aix3*)
-    test "$enable_shared" = yes && enable_static=no
-    if test -n "$RANLIB"; then
-      archive_cmds="$archive_cmds~\$RANLIB \$lib"
-      postinstall_cmds='$RANLIB $lib'
-    fi
-    ;;
-
-  aix[[4-9]]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
-    fi
-    ;;
-  esac
-  AC_MSG_RESULT([$enable_shared])
-
-  AC_MSG_CHECKING([whether to build static libraries])
-  # Make sure either enable_shared or enable_static is yes.
-  test "$enable_shared" = yes || enable_static=yes
-  AC_MSG_RESULT([$enable_static])
-
-  _LT_CONFIG($1)
-fi
-AC_LANG_POP
-CC="$lt_save_CC"
-])# _LT_LANG_C_CONFIG
-
-
-# _LT_LANG_CXX_CONFIG([TAG])
-# --------------------------
-# Ensure that the configuration variables for a C++ compiler are suitably
-# defined.  These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
-m4_defun([_LT_LANG_CXX_CONFIG],
-[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_DECL_EGREP])dnl
-m4_require([_LT_PATH_MANIFEST_TOOL])dnl
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
-  AC_PROG_CXXCPP
-else
-  _lt_caught_CXX_error=yes
-fi
-
-AC_LANG_PUSH(C++)
-_LT_TAGVAR(archive_cmds_need_lc, $1)=no
-_LT_TAGVAR(allow_undefined_flag, $1)=
-_LT_TAGVAR(always_export_symbols, $1)=no
-_LT_TAGVAR(archive_expsym_cmds, $1)=
-_LT_TAGVAR(compiler_needs_object, $1)=no
-_LT_TAGVAR(export_dynamic_flag_spec, $1)=
-_LT_TAGVAR(hardcode_direct, $1)=no
-_LT_TAGVAR(hardcode_direct_absolute, $1)=no
-_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_TAGVAR(hardcode_libdir_separator, $1)=
-_LT_TAGVAR(hardcode_minus_L, $1)=no
-_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-_LT_TAGVAR(hardcode_automatic, $1)=no
-_LT_TAGVAR(inherit_rpath, $1)=no
-_LT_TAGVAR(module_cmds, $1)=
-_LT_TAGVAR(module_expsym_cmds, $1)=
-_LT_TAGVAR(link_all_deplibs, $1)=unknown
-_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_TAGVAR(reload_flag, $1)=$reload_flag
-_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
-_LT_TAGVAR(no_undefined_flag, $1)=
-_LT_TAGVAR(whole_archive_flag_spec, $1)=
-_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-
-# Source file extension for C++ test sources.
-ac_ext=cpp
-
-# Object file extension for compiled C++ test sources.
-objext=o
-_LT_TAGVAR(objext, $1)=$objext
-
-# No sense in running all these tests if we already determined that
-# the CXX compiler isn't working.  Some variables (like enable_shared)
-# are currently assumed to apply to all compilers on this platform,
-# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_caught_CXX_error" != yes; then
-  # Code to be used in simple compile tests
-  lt_simple_compile_test_code="int some_variable = 0;"
-
-  # Code to be used in simple link tests
-  lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
-
-  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
-  _LT_TAG_COMPILER
-
-  # save warnings/boilerplate of simple test code
-  _LT_COMPILER_BOILERPLATE
-  _LT_LINKER_BOILERPLATE
-
-  # Allow CC to be a program name with arguments.
-  lt_save_CC=$CC
-  lt_save_CFLAGS=$CFLAGS
-  lt_save_LD=$LD
-  lt_save_GCC=$GCC
-  GCC=$GXX
-  lt_save_with_gnu_ld=$with_gnu_ld
-  lt_save_path_LD=$lt_cv_path_LD
-  if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
-    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
-  else
-    $as_unset lt_cv_prog_gnu_ld
-  fi
-  if test -n "${lt_cv_path_LDCXX+set}"; then
-    lt_cv_path_LD=$lt_cv_path_LDCXX
-  else
-    $as_unset lt_cv_path_LD
-  fi
-  test -z "${LDCXX+set}" || LD=$LDCXX
-  CC=${CXX-"c++"}
-  CFLAGS=$CXXFLAGS
-  compiler=$CC
-  _LT_TAGVAR(compiler, $1)=$CC
-  _LT_CC_BASENAME([$compiler])
-
-  if test -n "$compiler"; then
-    # We don't want -fno-exception when compiling C++ code, so set the
-    # no_builtin_flag separately
-    if test "$GXX" = yes; then
-      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
-    else
-      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
-    fi
-
-    if test "$GXX" = yes; then
-      # Set up default GNU C++ configuration
-
-      LT_PATH_LD
-
-      # Check if GNU C++ uses GNU ld as the underlying linker, since the
-      # archiving commands below assume that GNU ld is being used.
-      if test "$with_gnu_ld" = yes; then
-        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-
-        # If archive_cmds runs LD, not CC, wlarc should be empty
-        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
-        #     investigate it a little bit more. (MM)
-        wlarc='${wl}'
-
-        # ancient GNU ld didn't support --whole-archive et. al.
-        if eval "`$CC -print-prog-name=ld` --help 2>&1" |
-	  $GREP 'no-whole-archive' > /dev/null; then
-          _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-        else
-          _LT_TAGVAR(whole_archive_flag_spec, $1)=
-        fi
-      else
-        with_gnu_ld=no
-        wlarc=
-
-        # A generic and very simple default shared library creation
-        # command for GNU C++ for the case where it uses the native
-        # linker, instead of GNU ld.  If possible, this setting should
-        # overridden to take advantage of the native linker features on
-        # the platform it is being used on.
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-      fi
-
-      # Commands to make compiler produce verbose output that lists
-      # what "hidden" libraries, object files and flags are used when
-      # linking a shared library.
-      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
-
-    else
-      GXX=no
-      with_gnu_ld=no
-      wlarc=
-    fi
-
-    # PORTME: fill in a description of your system's C++ link characteristics
-    AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
-    _LT_TAGVAR(ld_shlibs, $1)=yes
-    case $host_os in
-      aix3*)
-        # FIXME: insert proper C++ library support
-        _LT_TAGVAR(ld_shlibs, $1)=no
-        ;;
-      aix[[4-9]]*)
-        if test "$host_cpu" = ia64; then
-          # On IA64, the linker does run time linking by default, so we don't
-          # have to do anything special.
-          aix_use_runtimelinking=no
-          exp_sym_flag='-Bexport'
-          no_entry_flag=""
-        else
-          aix_use_runtimelinking=no
-
-          # Test if we are trying to use run time linking or normal
-          # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-          # need to do runtime linking.
-          case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
-	    for ld_flag in $LDFLAGS; do
-	      case $ld_flag in
-	      *-brtl*)
-	        aix_use_runtimelinking=yes
-	        break
-	        ;;
-	      esac
-	    done
-	    ;;
-          esac
-
-          exp_sym_flag='-bexport'
-          no_entry_flag='-bnoentry'
-        fi
-
-        # When large executables or shared objects are built, AIX ld can
-        # have problems creating the table of contents.  If linking a library
-        # or program results in "error TOC overflow" add -mminimal-toc to
-        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
-        _LT_TAGVAR(archive_cmds, $1)=''
-        _LT_TAGVAR(hardcode_direct, $1)=yes
-        _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-        _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
-        _LT_TAGVAR(link_all_deplibs, $1)=yes
-        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
-
-        if test "$GXX" = yes; then
-          case $host_os in aix4.[[012]]|aix4.[[012]].*)
-          # We only want to do this on AIX 4.2 and lower, the check
-          # below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
-	  if test -f "$collect2name" &&
-	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
-	  then
-	    # We have reworked collect2
-	    :
-	  else
-	    # We have old collect2
-	    _LT_TAGVAR(hardcode_direct, $1)=unsupported
-	    # It fails to find uninstalled libraries when the uninstalled
-	    # path is not listed in the libpath.  Setting hardcode_minus_L
-	    # to unsupported forces relinking
-	    _LT_TAGVAR(hardcode_minus_L, $1)=yes
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-	    _LT_TAGVAR(hardcode_libdir_separator, $1)=
-	  fi
-          esac
-          shared_flag='-shared'
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag="$shared_flag "'${wl}-G'
-	  fi
-        else
-          # not using gcc
-          if test "$host_cpu" = ia64; then
-	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-	  # chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-          else
-	    if test "$aix_use_runtimelinking" = yes; then
-	      shared_flag='${wl}-G'
-	    else
-	      shared_flag='${wl}-bM:SRE'
-	    fi
-          fi
-        fi
-
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
-        # It seems that -bexpall does not export symbols beginning with
-        # underscore (_), so it is better to generate a list of symbols to
-	# export.
-        _LT_TAGVAR(always_export_symbols, $1)=yes
-        if test "$aix_use_runtimelinking" = yes; then
-          # Warning - without using the other runtime loading flags (-brtl),
-          # -berok will link without error, but may produce a broken library.
-          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
-          # Determine the default libpath from the value encoded in an empty
-          # executable.
-          _LT_SYS_MODULE_PATH_AIX([$1])
-          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-
-          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-        else
-          if test "$host_cpu" = ia64; then
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
-	    _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-          else
-	    # Determine the default libpath from the value encoded in an
-	    # empty executable.
-	    _LT_SYS_MODULE_PATH_AIX([$1])
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-	    # Warning - without using the other run time loading flags,
-	    # -berok will link without error, but may produce a broken library.
-	    _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-	    _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	    if test "$with_gnu_ld" = yes; then
-	      # We only use this code for GNU lds that support --whole-archive.
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
-	    else
-	      # Exported symbols can be pulled into shared objects from archives
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
-	    fi
-	    _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-	    # This is similar to how AIX traditionally builds its shared
-	    # libraries.
-	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-          fi
-        fi
-        ;;
-
-      beos*)
-	if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-	  # Joseph Beckenbach  says some releases of gcc
-	  # support --undefined.  This deserves some investigation.  FIXME
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	else
-	  _LT_TAGVAR(ld_shlibs, $1)=no
-	fi
-	;;
-
-      chorus*)
-        case $cc_basename in
-          *)
-	  # FIXME: insert proper C++ library support
-	  _LT_TAGVAR(ld_shlibs, $1)=no
-	  ;;
-        esac
-        ;;
-
-      cygwin* | mingw* | pw32* | cegcc*)
-	case $GXX,$cc_basename in
-	,cl* | no,cl*)
-	  # Native MSVC
-	  # hardcode_libdir_flag_spec is actually meaningless, as there is
-	  # no search path for DLLs.
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
-	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-	  _LT_TAGVAR(always_export_symbols, $1)=yes
-	  _LT_TAGVAR(file_list_spec, $1)='@'
-	  # Tell ltmain to make .lib files, not .a files.
-	  libext=lib
-	  # Tell ltmain to make .dll files, not .so files.
-	  shrext_cmds=".dll"
-	  # FIXME: Setting linknames here is a bad hack.
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	    else
-	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	    fi~
-	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	    linknames='
-	  # The linker will not automatically build a static lib if we build a DLL.
-	  # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
-	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-	  # Don't use ranlib
-	  _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
-	  _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
-	    lt_tool_outputfile="@TOOL_OUTPUT@"~
-	    case $lt_outputfile in
-	      *.exe|*.EXE) ;;
-	      *)
-		lt_outputfile="$lt_outputfile.exe"
-		lt_tool_outputfile="$lt_tool_outputfile.exe"
-		;;
-	    esac~
-	    func_to_tool_file "$lt_outputfile"~
-	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	      $RM "$lt_outputfile.manifest";
-	    fi'
-	  ;;
-	*)
-	  # g++
-	  # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
-	  # as there is no search path for DLLs.
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
-	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-	  _LT_TAGVAR(always_export_symbols, $1)=no
-	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-
-	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	    # If the export-symbols file already is a .def file (1st line
-	    # is EXPORTS), use it as is; otherwise, prepend...
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      cp $export_symbols $output_objdir/$soname.def;
-	    else
-	      echo EXPORTS > $output_objdir/$soname.def;
-	      cat $export_symbols >> $output_objdir/$soname.def;
-	    fi~
-	    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	  else
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	  fi
-	  ;;
-	esac
-	;;
-      darwin* | rhapsody*)
-        _LT_DARWIN_LINKER_FEATURES($1)
-	;;
-
-      dgux*)
-        case $cc_basename in
-          ec++*)
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-          ghcx*)
-	    # Green Hills C++ Compiler
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-          *)
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-        esac
-        ;;
-
-      freebsd2.*)
-        # C++ shared libraries reported to be fairly broken before
-	# switch to ELF
-        _LT_TAGVAR(ld_shlibs, $1)=no
-        ;;
-
-      freebsd-elf*)
-        _LT_TAGVAR(archive_cmds_need_lc, $1)=no
-        ;;
-
-      freebsd* | dragonfly*)
-        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
-        # conventions
-        _LT_TAGVAR(ld_shlibs, $1)=yes
-        ;;
-
-      gnu*)
-        ;;
-
-      haiku*)
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        _LT_TAGVAR(link_all_deplibs, $1)=yes
-        ;;
-
-      hpux9*)
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-        _LT_TAGVAR(hardcode_direct, $1)=yes
-        _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
-				             # but as the default
-				             # location of the library.
-
-        case $cc_basename in
-          CC*)
-            # FIXME: insert proper C++ library support
-            _LT_TAGVAR(ld_shlibs, $1)=no
-            ;;
-          aCC*)
-            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-            # Commands to make compiler produce verbose output that lists
-            # what "hidden" libraries, object files and flags are used when
-            # linking a shared library.
-            #
-            # There doesn't appear to be a way to prevent this compiler from
-            # explicitly linking system object files so we need to strip them
-            # from the output so that they don't get included in the library
-            # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
-            ;;
-          *)
-            if test "$GXX" = yes; then
-              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-            else
-              # FIXME: insert proper C++ library support
-              _LT_TAGVAR(ld_shlibs, $1)=no
-            fi
-            ;;
-        esac
-        ;;
-
-      hpux10*|hpux11*)
-        if test $with_gnu_ld = no; then
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-	  _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-
-          case $host_cpu in
-            hppa*64*|ia64*)
-              ;;
-            *)
-	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-              ;;
-          esac
-        fi
-        case $host_cpu in
-          hppa*64*|ia64*)
-            _LT_TAGVAR(hardcode_direct, $1)=no
-            _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-            ;;
-          *)
-            _LT_TAGVAR(hardcode_direct, $1)=yes
-            _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-            _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
-					         # but as the default
-					         # location of the library.
-            ;;
-        esac
-
-        case $cc_basename in
-          CC*)
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-          aCC*)
-	    case $host_cpu in
-	      hppa*64*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	        ;;
-	      ia64*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	        ;;
-	      *)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	        ;;
-	    esac
-	    # Commands to make compiler produce verbose output that lists
-	    # what "hidden" libraries, object files and flags are used when
-	    # linking a shared library.
-	    #
-	    # There doesn't appear to be a way to prevent this compiler from
-	    # explicitly linking system object files so we need to strip them
-	    # from the output so that they don't get included in the library
-	    # dependencies.
-	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
-	    ;;
-          *)
-	    if test "$GXX" = yes; then
-	      if test $with_gnu_ld = no; then
-	        case $host_cpu in
-	          hppa*64*)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	            ;;
-	          ia64*)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	            ;;
-	          *)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	            ;;
-	        esac
-	      fi
-	    else
-	      # FIXME: insert proper C++ library support
-	      _LT_TAGVAR(ld_shlibs, $1)=no
-	    fi
-	    ;;
-        esac
-        ;;
-
-      interix[[3-9]]*)
-	_LT_TAGVAR(hardcode_direct, $1)=no
-	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-	# Instead, shared libraries are loaded at an image base (0x10000000 by
-	# default) and relocated if they conflict, which is a slow very memory
-	# consuming and fragmenting process.  To avoid this, we pick a random,
-	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	;;
-      irix5* | irix6*)
-        case $cc_basename in
-          CC*)
-	    # SGI C++
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-
-	    # Archives containing C++ object files must be created using
-	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
-	    # necessary to make sure instantiated templates are included
-	    # in the archive.
-	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
-	    ;;
-          *)
-	    if test "$GXX" = yes; then
-	      if test "$with_gnu_ld" = no; then
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	      else
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
-	      fi
-	    fi
-	    _LT_TAGVAR(link_all_deplibs, $1)=yes
-	    ;;
-        esac
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-        _LT_TAGVAR(inherit_rpath, $1)=yes
-        ;;
-
-      linux* | k*bsd*-gnu | kopensolaris*-gnu)
-        case $cc_basename in
-          KCC*)
-	    # Kuck and Associates, Inc. (KAI) C++ Compiler
-
-	    # KCC will only create a shared library if the output file
-	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
-	    # to its proper name (with version) after linking.
-	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
-	    # Commands to make compiler produce verbose output that lists
-	    # what "hidden" libraries, object files and flags are used when
-	    # linking a shared library.
-	    #
-	    # There doesn't appear to be a way to prevent this compiler from
-	    # explicitly linking system object files so we need to strip them
-	    # from the output so that they don't get included in the library
-	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
-
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-
-	    # Archives containing C++ object files must be created using
-	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
-	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
-	    ;;
-	  icpc* | ecpc* )
-	    # Intel C++
-	    with_gnu_ld=yes
-	    # version 8.0 and above of icpc choke on multiply defined symbols
-	    # if we add $predep_objects and $postdep_objects, however 7.1 and
-	    # earlier do not add the objects themselves.
-	    case `$CC -V 2>&1` in
-	      *"Version 7."*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-		;;
-	      *)  # Version 8.0 or newer
-	        tmp_idyn=
-	        case $host_cpu in
-		  ia64*) tmp_idyn=' -i_dynamic';;
-		esac
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-		;;
-	    esac
-	    _LT_TAGVAR(archive_cmds_need_lc, $1)=no
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
-	    ;;
-          pgCC* | pgcpp*)
-            # Portland Group C++ compiler
-	    case `$CC -V` in
-	    *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
-	      _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
-		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
-	      _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
-		$RANLIB $oldlib'
-	      _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-	      ;;
-	    *) # Version 6 and above use weak symbols
-	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-	      ;;
-	    esac
-
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-            ;;
-	  cxx*)
-	    # Compaq C++
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
-
-	    runpath_var=LD_RUN_PATH
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
-	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-
-	    # Commands to make compiler produce verbose output that lists
-	    # what "hidden" libraries, object files and flags are used when
-	    # linking a shared library.
-	    #
-	    # There doesn't appear to be a way to prevent this compiler from
-	    # explicitly linking system object files so we need to strip them
-	    # from the output so that they don't get included in the library
-	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
-	    ;;
-	  xl* | mpixl* | bgxl*)
-	    # IBM XL 8.0 on PPC, with GNU ld
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    if test "x$supports_anon_versioning" = xyes; then
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-		echo "local: *; };" >> $output_objdir/$libname.ver~
-		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	    fi
-	    ;;
-	  *)
-	    case `$CC -V 2>&1 | sed 5q` in
-	    *Sun\ C*)
-	      # Sun C++ 5.9
-	      _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	      _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	      _LT_TAGVAR(compiler_needs_object, $1)=yes
-
-	      # Not sure whether something based on
-	      # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
-	      # would be better.
-	      output_verbose_link_cmd='func_echo_all'
-
-	      # Archives containing C++ object files must be created using
-	      # "CC -xar", where "CC" is the Sun C++ compiler.  This is
-	      # necessary to make sure instantiated templates are included
-	      # in the archive.
-	      _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
-	      ;;
-	    esac
-	    ;;
-	esac
-	;;
-
-      lynxos*)
-        # FIXME: insert proper C++ library support
-	_LT_TAGVAR(ld_shlibs, $1)=no
-	;;
-
-      m88k*)
-        # FIXME: insert proper C++ library support
-        _LT_TAGVAR(ld_shlibs, $1)=no
-	;;
-
-      mvs*)
-        case $cc_basename in
-          cxx*)
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-	  *)
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-	esac
-	;;
-
-      netbsd*)
-        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	  _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
-	  wlarc=
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	  _LT_TAGVAR(hardcode_direct, $1)=yes
-	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	fi
-	# Workaround some broken pre-1.5 toolchains
-	output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
-	;;
-
-      *nto* | *qnx*)
-        _LT_TAGVAR(ld_shlibs, $1)=yes
-	;;
-
-      openbsd2*)
-        # C++ shared libraries are fairly broken
-	_LT_TAGVAR(ld_shlibs, $1)=no
-	;;
-
-      openbsd*)
-	if test -f /usr/libexec/ld.so; then
-	  _LT_TAGVAR(hardcode_direct, $1)=yes
-	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-	  fi
-	  output_verbose_link_cmd=func_echo_all
-	else
-	  _LT_TAGVAR(ld_shlibs, $1)=no
-	fi
-	;;
-
-      osf3* | osf4* | osf5*)
-        case $cc_basename in
-          KCC*)
-	    # Kuck and Associates, Inc. (KAI) C++ Compiler
-
-	    # KCC will only create a shared library if the output file
-	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
-	    # to its proper name (with version) after linking.
-	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-
-	    # Archives containing C++ object files must be created using
-	    # the KAI C++ compiler.
-	    case $host in
-	      osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
-	      *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
-	    esac
-	    ;;
-          RCC*)
-	    # Rational C++ 2.4.1
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-          cxx*)
-	    case $host in
-	      osf3*)
-	        _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-		;;
-	      *)
-	        _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
-	          echo "-hidden">> $lib.exp~
-	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
-	          $RM $lib.exp'
-	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
-		;;
-	    esac
-
-	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-
-	    # Commands to make compiler produce verbose output that lists
-	    # what "hidden" libraries, object files and flags are used when
-	    # linking a shared library.
-	    #
-	    # There doesn't appear to be a way to prevent this compiler from
-	    # explicitly linking system object files so we need to strip them
-	    # from the output so that they don't get included in the library
-	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
-	    ;;
-	  *)
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	      case $host in
-	        osf3*)
-	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-		  ;;
-	        *)
-	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-		  ;;
-	      esac
-
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-
-	      # Commands to make compiler produce verbose output that lists
-	      # what "hidden" libraries, object files and flags are used when
-	      # linking a shared library.
-	      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
-
-	    else
-	      # FIXME: insert proper C++ library support
-	      _LT_TAGVAR(ld_shlibs, $1)=no
-	    fi
-	    ;;
-        esac
-        ;;
-
-      psos*)
-        # FIXME: insert proper C++ library support
-        _LT_TAGVAR(ld_shlibs, $1)=no
-        ;;
-
-      sunos4*)
-        case $cc_basename in
-          CC*)
-	    # Sun C++ 4.x
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-          lcc*)
-	    # Lucid
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-          *)
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-        esac
-        ;;
-
-      solaris*)
-        case $cc_basename in
-          CC* | sunCC*)
-	    # Sun C++ 4.2, 5.x and Centerline C++
-            _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
-	    _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
-
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	    _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	    case $host_os in
-	      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
-	      *)
-		# The compiler driver will combine and reorder linker options,
-		# but understands `-z linker_flag'.
-	        # Supported since Solaris 2.6 (maybe 2.5.1?)
-		_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
-	        ;;
-	    esac
-	    _LT_TAGVAR(link_all_deplibs, $1)=yes
-
-	    output_verbose_link_cmd='func_echo_all'
-
-	    # Archives containing C++ object files must be created using
-	    # "CC -xar", where "CC" is the Sun C++ compiler.  This is
-	    # necessary to make sure instantiated templates are included
-	    # in the archive.
-	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
-	    ;;
-          gcx*)
-	    # Green Hills C++ Compiler
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-
-	    # The C++ compiler must be used to create the archive.
-	    _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
-	    ;;
-          *)
-	    # GNU C++ compiler with Solaris linker
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
-	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
-
-	        # Commands to make compiler produce verbose output that lists
-	        # what "hidden" libraries, object files and flags are used when
-	        # linking a shared library.
-	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
-	      else
-	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
-	        # platform.
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
-
-	        # Commands to make compiler produce verbose output that lists
-	        # what "hidden" libraries, object files and flags are used when
-	        # linking a shared library.
-	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
-	      fi
-
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
-	      case $host_os in
-		solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
-		*)
-		  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
-		  ;;
-	      esac
-	    fi
-	    ;;
-        esac
-        ;;
-
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
-      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      runpath_var='LD_RUN_PATH'
-
-      case $cc_basename in
-        CC*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-      esac
-      ;;
-
-      sysv5* | sco3.2v5* | sco5v6*)
-	# Note: We can NOT use -z defs as we might desire, because we do not
-	# link with -lc, and that would cause any symbols used from libc to
-	# always be unresolved, which means just about no library would
-	# ever link correctly.  If we're not using GNU ld we use -z text
-	# though, which does catch some bad symbols but isn't as heavy-handed
-	# as -z defs.
-	_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-	_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
-	_LT_TAGVAR(archive_cmds_need_lc, $1)=no
-	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
-	_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
-	_LT_TAGVAR(link_all_deplibs, $1)=yes
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
-	runpath_var='LD_RUN_PATH'
-
-	case $cc_basename in
-          CC*)
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
-	      '"$_LT_TAGVAR(old_archive_cmds, $1)"
-	    _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
-	      '"$_LT_TAGVAR(reload_cmds, $1)"
-	    ;;
-	  *)
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    ;;
-	esac
-      ;;
-
-      tandem*)
-        case $cc_basename in
-          NCC*)
-	    # NonStop-UX NCC 3.20
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-          *)
-	    # FIXME: insert proper C++ library support
-	    _LT_TAGVAR(ld_shlibs, $1)=no
-	    ;;
-        esac
-        ;;
-
-      vxworks*)
-        # FIXME: insert proper C++ library support
-        _LT_TAGVAR(ld_shlibs, $1)=no
-        ;;
-
-      *)
-        # FIXME: insert proper C++ library support
-        _LT_TAGVAR(ld_shlibs, $1)=no
-        ;;
-    esac
-
-    AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
-
-    _LT_TAGVAR(GCC, $1)="$GXX"
-    _LT_TAGVAR(LD, $1)="$LD"
-
-    ## CAVEAT EMPTOR:
-    ## There is no encapsulation within the following macros, do not change
-    ## the running order or otherwise move them around unless you know exactly
-    ## what you are doing...
-    _LT_SYS_HIDDEN_LIBDEPS($1)
-    _LT_COMPILER_PIC($1)
-    _LT_COMPILER_C_O($1)
-    _LT_COMPILER_FILE_LOCKS($1)
-    _LT_LINKER_SHLIBS($1)
-    _LT_SYS_DYNAMIC_LINKER($1)
-    _LT_LINKER_HARDCODE_LIBPATH($1)
-
-    _LT_CONFIG($1)
-  fi # test -n "$compiler"
-
-  CC=$lt_save_CC
-  CFLAGS=$lt_save_CFLAGS
-  LDCXX=$LD
-  LD=$lt_save_LD
-  GCC=$lt_save_GCC
-  with_gnu_ld=$lt_save_with_gnu_ld
-  lt_cv_path_LDCXX=$lt_cv_path_LD
-  lt_cv_path_LD=$lt_save_path_LD
-  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
-  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-fi # test "$_lt_caught_CXX_error" != yes
-
-AC_LANG_POP
-])# _LT_LANG_CXX_CONFIG
-
-
-# _LT_FUNC_STRIPNAME_CNF
-# ----------------------
-# func_stripname_cnf prefix suffix name
-# strip PREFIX and SUFFIX off of NAME.
-# PREFIX and SUFFIX must not contain globbing or regex special
-# characters, hashes, percent signs, but SUFFIX may contain a leading
-# dot (in which case that matches only a dot).
-#
-# This function is identical to the (non-XSI) version of func_stripname,
-# except this one can be used by m4 code that may be executed by configure,
-# rather than the libtool script.
-m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl
-AC_REQUIRE([_LT_DECL_SED])
-AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
-func_stripname_cnf ()
-{
-  case ${2} in
-  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
-  esac
-} # func_stripname_cnf
-])# _LT_FUNC_STRIPNAME_CNF
-
-# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
-# ---------------------------------
-# Figure out "hidden" library dependencies from verbose
-# compiler output when linking a shared library.
-# Parse the compiler output and extract the necessary
-# objects, libraries and library flags.
-m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
-[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl
-# Dependencies to place before and after the object being linked:
-_LT_TAGVAR(predep_objects, $1)=
-_LT_TAGVAR(postdep_objects, $1)=
-_LT_TAGVAR(predeps, $1)=
-_LT_TAGVAR(postdeps, $1)=
-_LT_TAGVAR(compiler_lib_search_path, $1)=
-
-dnl we can't use the lt_simple_compile_test_code here,
-dnl because it contains code intended for an executable,
-dnl not a library.  It's possible we should let each
-dnl tag define a new lt_????_link_test_code variable,
-dnl but it's only used here...
-m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
-int a;
-void foo (void) { a = 0; }
-_LT_EOF
-], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
-class Foo
-{
-public:
-  Foo (void) { a = 0; }
-private:
-  int a;
-};
-_LT_EOF
-], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
-      subroutine foo
-      implicit none
-      integer*4 a
-      a=0
-      return
-      end
-_LT_EOF
-], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
-      subroutine foo
-      implicit none
-      integer a
-      a=0
-      return
-      end
-_LT_EOF
-], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
-public class foo {
-  private int a;
-  public void bar (void) {
-    a = 0;
-  }
-};
-_LT_EOF
-], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF
-package foo
-func foo() {
-}
-_LT_EOF
-])
-
-_lt_libdeps_save_CFLAGS=$CFLAGS
-case "$CC $CFLAGS " in #(
-*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
-*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
-*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
-esac
-
-dnl Parse the compiler output and extract the necessary
-dnl objects, libraries and library flags.
-if AC_TRY_EVAL(ac_compile); then
-  # Parse the compiler output and extract the necessary
-  # objects, libraries and library flags.
-
-  # Sentinel used to keep track of whether or not we are before
-  # the conftest object file.
-  pre_test_object_deps_done=no
-
-  for p in `eval "$output_verbose_link_cmd"`; do
-    case ${prev}${p} in
-
-    -L* | -R* | -l*)
-       # Some compilers place space between "-{L,R}" and the path.
-       # Remove the space.
-       if test $p = "-L" ||
-          test $p = "-R"; then
-	 prev=$p
-	 continue
-       fi
-
-       # Expand the sysroot to ease extracting the directories later.
-       if test -z "$prev"; then
-         case $p in
-         -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
-         -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
-         -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
-         esac
-       fi
-       case $p in
-       =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
-       esac
-       if test "$pre_test_object_deps_done" = no; then
-	 case ${prev} in
-	 -L | -R)
-	   # Internal compiler library paths should come after those
-	   # provided the user.  The postdeps already come after the
-	   # user supplied libs so there is no need to process them.
-	   if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
-	     _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
-	   else
-	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
-	   fi
-	   ;;
-	 # The "-l" case would never come before the object being
-	 # linked, so don't bother handling this case.
-	 esac
-       else
-	 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
-	   _LT_TAGVAR(postdeps, $1)="${prev}${p}"
-	 else
-	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
-	 fi
-       fi
-       prev=
-       ;;
-
-    *.lto.$objext) ;; # Ignore GCC LTO objects
-    *.$objext)
-       # This assumes that the test object file only shows up
-       # once in the compiler output.
-       if test "$p" = "conftest.$objext"; then
-	 pre_test_object_deps_done=yes
-	 continue
-       fi
-
-       if test "$pre_test_object_deps_done" = no; then
-	 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
-	   _LT_TAGVAR(predep_objects, $1)="$p"
-	 else
-	   _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
-	 fi
-       else
-	 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
-	   _LT_TAGVAR(postdep_objects, $1)="$p"
-	 else
-	   _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
-	 fi
-       fi
-       ;;
-
-    *) ;; # Ignore the rest.
-
-    esac
-  done
-
-  # Clean up.
-  rm -f a.out a.exe
-else
-  echo "libtool.m4: error: problem compiling $1 test program"
-fi
-
-$RM -f confest.$objext
-CFLAGS=$_lt_libdeps_save_CFLAGS
-
-# PORTME: override above test on systems where it is broken
-m4_if([$1], [CXX],
-[case $host_os in
-interix[[3-9]]*)
-  # Interix 3.5 installs completely hosed .la files for C++, so rather than
-  # hack all around it, let's just trust "g++" to DTRT.
-  _LT_TAGVAR(predep_objects,$1)=
-  _LT_TAGVAR(postdep_objects,$1)=
-  _LT_TAGVAR(postdeps,$1)=
-  ;;
-
-linux*)
-  case `$CC -V 2>&1 | sed 5q` in
-  *Sun\ C*)
-    # Sun C++ 5.9
-
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    if test "$solaris_use_stlport4" != yes; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC* | sunCC*)
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    if test "$solaris_use_stlport4" != yes; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
-esac
-])
-
-case " $_LT_TAGVAR(postdeps, $1) " in
-*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
-esac
- _LT_TAGVAR(compiler_lib_search_dirs, $1)=
-if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
- _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
-fi
-_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
-    [The directories searched by this compiler when creating a shared library])
-_LT_TAGDECL([], [predep_objects], [1],
-    [Dependencies to place before and after the objects being linked to
-    create a shared library])
-_LT_TAGDECL([], [postdep_objects], [1])
-_LT_TAGDECL([], [predeps], [1])
-_LT_TAGDECL([], [postdeps], [1])
-_LT_TAGDECL([], [compiler_lib_search_path], [1],
-    [The library search path used internally by the compiler when linking
-    a shared library])
-])# _LT_SYS_HIDDEN_LIBDEPS
-
-
-# _LT_LANG_F77_CONFIG([TAG])
-# --------------------------
-# Ensure that the configuration variables for a Fortran 77 compiler are
-# suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
-m4_defun([_LT_LANG_F77_CONFIG],
-[AC_LANG_PUSH(Fortran 77)
-if test -z "$F77" || test "X$F77" = "Xno"; then
-  _lt_disable_F77=yes
-fi
-
-_LT_TAGVAR(archive_cmds_need_lc, $1)=no
-_LT_TAGVAR(allow_undefined_flag, $1)=
-_LT_TAGVAR(always_export_symbols, $1)=no
-_LT_TAGVAR(archive_expsym_cmds, $1)=
-_LT_TAGVAR(export_dynamic_flag_spec, $1)=
-_LT_TAGVAR(hardcode_direct, $1)=no
-_LT_TAGVAR(hardcode_direct_absolute, $1)=no
-_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_TAGVAR(hardcode_libdir_separator, $1)=
-_LT_TAGVAR(hardcode_minus_L, $1)=no
-_LT_TAGVAR(hardcode_automatic, $1)=no
-_LT_TAGVAR(inherit_rpath, $1)=no
-_LT_TAGVAR(module_cmds, $1)=
-_LT_TAGVAR(module_expsym_cmds, $1)=
-_LT_TAGVAR(link_all_deplibs, $1)=unknown
-_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_TAGVAR(reload_flag, $1)=$reload_flag
-_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
-_LT_TAGVAR(no_undefined_flag, $1)=
-_LT_TAGVAR(whole_archive_flag_spec, $1)=
-_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-
-# Source file extension for f77 test sources.
-ac_ext=f
-
-# Object file extension for compiled f77 test sources.
-objext=o
-_LT_TAGVAR(objext, $1)=$objext
-
-# No sense in running all these tests if we already determined that
-# the F77 compiler isn't working.  Some variables (like enable_shared)
-# are currently assumed to apply to all compilers on this platform,
-# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_F77" != yes; then
-  # Code to be used in simple compile tests
-  lt_simple_compile_test_code="\
-      subroutine t
-      return
-      end
-"
-
-  # Code to be used in simple link tests
-  lt_simple_link_test_code="\
-      program t
-      end
-"
-
-  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
-  _LT_TAG_COMPILER
-
-  # save warnings/boilerplate of simple test code
-  _LT_COMPILER_BOILERPLATE
-  _LT_LINKER_BOILERPLATE
-
-  # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
-  lt_save_GCC=$GCC
-  lt_save_CFLAGS=$CFLAGS
-  CC=${F77-"f77"}
-  CFLAGS=$FFLAGS
-  compiler=$CC
-  _LT_TAGVAR(compiler, $1)=$CC
-  _LT_CC_BASENAME([$compiler])
-  GCC=$G77
-  if test -n "$compiler"; then
-    AC_MSG_CHECKING([if libtool supports shared libraries])
-    AC_MSG_RESULT([$can_build_shared])
-
-    AC_MSG_CHECKING([whether to build shared libraries])
-    test "$can_build_shared" = "no" && enable_shared=no
-
-    # On AIX, shared libraries and static libraries use the same namespace, and
-    # are all built from PIC.
-    case $host_os in
-      aix3*)
-        test "$enable_shared" = yes && enable_static=no
-        if test -n "$RANLIB"; then
-          archive_cmds="$archive_cmds~\$RANLIB \$lib"
-          postinstall_cmds='$RANLIB $lib'
-        fi
-        ;;
-      aix[[4-9]]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
-	fi
-        ;;
-    esac
-    AC_MSG_RESULT([$enable_shared])
-
-    AC_MSG_CHECKING([whether to build static libraries])
-    # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
-    AC_MSG_RESULT([$enable_static])
-
-    _LT_TAGVAR(GCC, $1)="$G77"
-    _LT_TAGVAR(LD, $1)="$LD"
-
-    ## CAVEAT EMPTOR:
-    ## There is no encapsulation within the following macros, do not change
-    ## the running order or otherwise move them around unless you know exactly
-    ## what you are doing...
-    _LT_COMPILER_PIC($1)
-    _LT_COMPILER_C_O($1)
-    _LT_COMPILER_FILE_LOCKS($1)
-    _LT_LINKER_SHLIBS($1)
-    _LT_SYS_DYNAMIC_LINKER($1)
-    _LT_LINKER_HARDCODE_LIBPATH($1)
-
-    _LT_CONFIG($1)
-  fi # test -n "$compiler"
-
-  GCC=$lt_save_GCC
-  CC="$lt_save_CC"
-  CFLAGS="$lt_save_CFLAGS"
-fi # test "$_lt_disable_F77" != yes
-
-AC_LANG_POP
-])# _LT_LANG_F77_CONFIG
-
-
-# _LT_LANG_FC_CONFIG([TAG])
-# -------------------------
-# Ensure that the configuration variables for a Fortran compiler are
-# suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
-m4_defun([_LT_LANG_FC_CONFIG],
-[AC_LANG_PUSH(Fortran)
-
-if test -z "$FC" || test "X$FC" = "Xno"; then
-  _lt_disable_FC=yes
-fi
-
-_LT_TAGVAR(archive_cmds_need_lc, $1)=no
-_LT_TAGVAR(allow_undefined_flag, $1)=
-_LT_TAGVAR(always_export_symbols, $1)=no
-_LT_TAGVAR(archive_expsym_cmds, $1)=
-_LT_TAGVAR(export_dynamic_flag_spec, $1)=
-_LT_TAGVAR(hardcode_direct, $1)=no
-_LT_TAGVAR(hardcode_direct_absolute, $1)=no
-_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_TAGVAR(hardcode_libdir_separator, $1)=
-_LT_TAGVAR(hardcode_minus_L, $1)=no
-_LT_TAGVAR(hardcode_automatic, $1)=no
-_LT_TAGVAR(inherit_rpath, $1)=no
-_LT_TAGVAR(module_cmds, $1)=
-_LT_TAGVAR(module_expsym_cmds, $1)=
-_LT_TAGVAR(link_all_deplibs, $1)=unknown
-_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_TAGVAR(reload_flag, $1)=$reload_flag
-_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
-_LT_TAGVAR(no_undefined_flag, $1)=
-_LT_TAGVAR(whole_archive_flag_spec, $1)=
-_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-
-# Source file extension for fc test sources.
-ac_ext=${ac_fc_srcext-f}
-
-# Object file extension for compiled fc test sources.
-objext=o
-_LT_TAGVAR(objext, $1)=$objext
-
-# No sense in running all these tests if we already determined that
-# the FC compiler isn't working.  Some variables (like enable_shared)
-# are currently assumed to apply to all compilers on this platform,
-# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_FC" != yes; then
-  # Code to be used in simple compile tests
-  lt_simple_compile_test_code="\
-      subroutine t
-      return
-      end
-"
-
-  # Code to be used in simple link tests
-  lt_simple_link_test_code="\
-      program t
-      end
-"
-
-  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
-  _LT_TAG_COMPILER
-
-  # save warnings/boilerplate of simple test code
-  _LT_COMPILER_BOILERPLATE
-  _LT_LINKER_BOILERPLATE
-
-  # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
-  lt_save_GCC=$GCC
-  lt_save_CFLAGS=$CFLAGS
-  CC=${FC-"f95"}
-  CFLAGS=$FCFLAGS
-  compiler=$CC
-  GCC=$ac_cv_fc_compiler_gnu
-
-  _LT_TAGVAR(compiler, $1)=$CC
-  _LT_CC_BASENAME([$compiler])
-
-  if test -n "$compiler"; then
-    AC_MSG_CHECKING([if libtool supports shared libraries])
-    AC_MSG_RESULT([$can_build_shared])
-
-    AC_MSG_CHECKING([whether to build shared libraries])
-    test "$can_build_shared" = "no" && enable_shared=no
-
-    # On AIX, shared libraries and static libraries use the same namespace, and
-    # are all built from PIC.
-    case $host_os in
-      aix3*)
-        test "$enable_shared" = yes && enable_static=no
-        if test -n "$RANLIB"; then
-          archive_cmds="$archive_cmds~\$RANLIB \$lib"
-          postinstall_cmds='$RANLIB $lib'
-        fi
-        ;;
-      aix[[4-9]]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
-	fi
-        ;;
-    esac
-    AC_MSG_RESULT([$enable_shared])
-
-    AC_MSG_CHECKING([whether to build static libraries])
-    # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
-    AC_MSG_RESULT([$enable_static])
-
-    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
-    _LT_TAGVAR(LD, $1)="$LD"
-
-    ## CAVEAT EMPTOR:
-    ## There is no encapsulation within the following macros, do not change
-    ## the running order or otherwise move them around unless you know exactly
-    ## what you are doing...
-    _LT_SYS_HIDDEN_LIBDEPS($1)
-    _LT_COMPILER_PIC($1)
-    _LT_COMPILER_C_O($1)
-    _LT_COMPILER_FILE_LOCKS($1)
-    _LT_LINKER_SHLIBS($1)
-    _LT_SYS_DYNAMIC_LINKER($1)
-    _LT_LINKER_HARDCODE_LIBPATH($1)
-
-    _LT_CONFIG($1)
-  fi # test -n "$compiler"
-
-  GCC=$lt_save_GCC
-  CC=$lt_save_CC
-  CFLAGS=$lt_save_CFLAGS
-fi # test "$_lt_disable_FC" != yes
-
-AC_LANG_POP
-])# _LT_LANG_FC_CONFIG
-
-
-# _LT_LANG_GCJ_CONFIG([TAG])
-# --------------------------
-# Ensure that the configuration variables for the GNU Java Compiler compiler
-# are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
-m4_defun([_LT_LANG_GCJ_CONFIG],
-[AC_REQUIRE([LT_PROG_GCJ])dnl
-AC_LANG_SAVE
-
-# Source file extension for Java test sources.
-ac_ext=java
-
-# Object file extension for compiled Java test sources.
-objext=o
-_LT_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="class foo {}"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_TAG_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC=$CC
-lt_save_CFLAGS=$CFLAGS
-lt_save_GCC=$GCC
-GCC=yes
-CC=${GCJ-"gcj"}
-CFLAGS=$GCJFLAGS
-compiler=$CC
-_LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
-_LT_CC_BASENAME([$compiler])
-
-# GCJ did not exist at the time GCC didn't implicitly link libc in.
-_LT_TAGVAR(archive_cmds_need_lc, $1)=no
-
-_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_TAGVAR(reload_flag, $1)=$reload_flag
-_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
-
-## CAVEAT EMPTOR:
-## There is no encapsulation within the following macros, do not change
-## the running order or otherwise move them around unless you know exactly
-## what you are doing...
-if test -n "$compiler"; then
-  _LT_COMPILER_NO_RTTI($1)
-  _LT_COMPILER_PIC($1)
-  _LT_COMPILER_C_O($1)
-  _LT_COMPILER_FILE_LOCKS($1)
-  _LT_LINKER_SHLIBS($1)
-  _LT_LINKER_HARDCODE_LIBPATH($1)
-
-  _LT_CONFIG($1)
-fi
-
-AC_LANG_RESTORE
-
-GCC=$lt_save_GCC
-CC=$lt_save_CC
-CFLAGS=$lt_save_CFLAGS
-])# _LT_LANG_GCJ_CONFIG
-
-
-# _LT_LANG_GO_CONFIG([TAG])
-# --------------------------
-# Ensure that the configuration variables for the GNU Go compiler
-# are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
-m4_defun([_LT_LANG_GO_CONFIG],
-[AC_REQUIRE([LT_PROG_GO])dnl
-AC_LANG_SAVE
-
-# Source file extension for Go test sources.
-ac_ext=go
-
-# Object file extension for compiled Go test sources.
-objext=o
-_LT_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="package main; func main() { }"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='package main; func main() { }'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_TAG_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC=$CC
-lt_save_CFLAGS=$CFLAGS
-lt_save_GCC=$GCC
-GCC=yes
-CC=${GOC-"gccgo"}
-CFLAGS=$GOFLAGS
-compiler=$CC
-_LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
-_LT_CC_BASENAME([$compiler])
-
-# Go did not exist at the time GCC didn't implicitly link libc in.
-_LT_TAGVAR(archive_cmds_need_lc, $1)=no
-
-_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_TAGVAR(reload_flag, $1)=$reload_flag
-_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
-
-## CAVEAT EMPTOR:
-## There is no encapsulation within the following macros, do not change
-## the running order or otherwise move them around unless you know exactly
-## what you are doing...
-if test -n "$compiler"; then
-  _LT_COMPILER_NO_RTTI($1)
-  _LT_COMPILER_PIC($1)
-  _LT_COMPILER_C_O($1)
-  _LT_COMPILER_FILE_LOCKS($1)
-  _LT_LINKER_SHLIBS($1)
-  _LT_LINKER_HARDCODE_LIBPATH($1)
-
-  _LT_CONFIG($1)
-fi
-
-AC_LANG_RESTORE
-
-GCC=$lt_save_GCC
-CC=$lt_save_CC
-CFLAGS=$lt_save_CFLAGS
-])# _LT_LANG_GO_CONFIG
-
-
-# _LT_LANG_RC_CONFIG([TAG])
-# -------------------------
-# Ensure that the configuration variables for the Windows resource compiler
-# are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
-m4_defun([_LT_LANG_RC_CONFIG],
-[AC_REQUIRE([LT_PROG_RC])dnl
-AC_LANG_SAVE
-
-# Source file extension for RC test sources.
-ac_ext=rc
-
-# Object file extension for compiled RC test sources.
-objext=o
-_LT_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
-
-# Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_TAG_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-lt_save_CFLAGS=$CFLAGS
-lt_save_GCC=$GCC
-GCC=
-CC=${RC-"windres"}
-CFLAGS=
-compiler=$CC
-_LT_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
-
-if test -n "$compiler"; then
-  :
-  _LT_CONFIG($1)
-fi
-
-GCC=$lt_save_GCC
-AC_LANG_RESTORE
-CC=$lt_save_CC
-CFLAGS=$lt_save_CFLAGS
-])# _LT_LANG_RC_CONFIG
-
-
-# LT_PROG_GCJ
-# -----------
-AC_DEFUN([LT_PROG_GCJ],
-[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
-  [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
-    [AC_CHECK_TOOL(GCJ, gcj,)
-      test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
-      AC_SUBST(GCJFLAGS)])])[]dnl
-])
-
-# Old name:
-AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
-
-
-# LT_PROG_GO
-# ----------
-AC_DEFUN([LT_PROG_GO],
-[AC_CHECK_TOOL(GOC, gccgo,)
-])
-
-
-# LT_PROG_RC
-# ----------
-AC_DEFUN([LT_PROG_RC],
-[AC_CHECK_TOOL(RC, windres,)
-])
-
-# Old name:
-AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([LT_AC_PROG_RC], [])
-
-
-# _LT_DECL_EGREP
-# --------------
-# If we don't have a new enough Autoconf to choose the best grep
-# available, choose the one first in the user's PATH.
-m4_defun([_LT_DECL_EGREP],
-[AC_REQUIRE([AC_PROG_EGREP])dnl
-AC_REQUIRE([AC_PROG_FGREP])dnl
-test -z "$GREP" && GREP=grep
-_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
-_LT_DECL([], [EGREP], [1], [An ERE matcher])
-_LT_DECL([], [FGREP], [1], [A literal string matcher])
-dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
-AC_SUBST([GREP])
-])
-
-
-# _LT_DECL_OBJDUMP
-# --------------
-# If we don't have a new enough Autoconf to choose the best objdump
-# available, choose the one first in the user's PATH.
-m4_defun([_LT_DECL_OBJDUMP],
-[AC_CHECK_TOOL(OBJDUMP, objdump, false)
-test -z "$OBJDUMP" && OBJDUMP=objdump
-_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
-AC_SUBST([OBJDUMP])
-])
-
-# _LT_DECL_DLLTOOL
-# ----------------
-# Ensure DLLTOOL variable is set.
-m4_defun([_LT_DECL_DLLTOOL],
-[AC_CHECK_TOOL(DLLTOOL, dlltool, false)
-test -z "$DLLTOOL" && DLLTOOL=dlltool
-_LT_DECL([], [DLLTOOL], [1], [DLL creation program])
-AC_SUBST([DLLTOOL])
-])
-
-# _LT_DECL_SED
-# ------------
-# Check for a fully-functional sed program, that truncates
-# as few characters as possible.  Prefer GNU sed if found.
-m4_defun([_LT_DECL_SED],
-[AC_PROG_SED
-test -z "$SED" && SED=sed
-Xsed="$SED -e 1s/^X//"
-_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
-_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
-    [Sed that helps us avoid accidentally triggering echo(1) options like -n])
-])# _LT_DECL_SED
-
-m4_ifndef([AC_PROG_SED], [
-############################################################
-# NOTE: This macro has been submitted for inclusion into   #
-#  GNU Autoconf as AC_PROG_SED.  When it is available in   #
-#  a released version of Autoconf we should remove this    #
-#  macro and use it instead.                               #
-############################################################
-
-m4_defun([AC_PROG_SED],
-[AC_MSG_CHECKING([for a sed that does not truncate output])
-AC_CACHE_VAL(lt_cv_path_SED,
-[# Loop through the user's path and test for sed and gsed.
-# Then use that list of sed's as ones to test for truncation.
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for lt_ac_prog in sed gsed; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
-        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
-      fi
-    done
-  done
-done
-IFS=$as_save_IFS
-lt_ac_max=0
-lt_ac_count=0
-# Add /usr/xpg4/bin/sed as it is typically found on Solaris
-# along with /bin/sed that truncates output.
-for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
-  cat /dev/null > conftest.in
-  lt_ac_count=0
-  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
-  # Check for GNU sed and select it if it is found.
-  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
-    lt_cv_path_SED=$lt_ac_sed
-    break
-  fi
-  while true; do
-    cat conftest.in conftest.in >conftest.tmp
-    mv conftest.tmp conftest.in
-    cp conftest.in conftest.nl
-    echo >>conftest.nl
-    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
-    cmp -s conftest.out conftest.nl || break
-    # 10000 chars as input seems more than enough
-    test $lt_ac_count -gt 10 && break
-    lt_ac_count=`expr $lt_ac_count + 1`
-    if test $lt_ac_count -gt $lt_ac_max; then
-      lt_ac_max=$lt_ac_count
-      lt_cv_path_SED=$lt_ac_sed
-    fi
-  done
-done
-])
-SED=$lt_cv_path_SED
-AC_SUBST([SED])
-AC_MSG_RESULT([$SED])
-])#AC_PROG_SED
-])#m4_ifndef
-
-# Old name:
-AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([LT_AC_PROG_SED], [])
-
-
-# _LT_CHECK_SHELL_FEATURES
-# ------------------------
-# Find out whether the shell is Bourne or XSI compatible,
-# or has some other useful features.
-m4_defun([_LT_CHECK_SHELL_FEATURES],
-[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
-  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
-      = c,a/b,b/c, \
-    && eval 'test $(( 1 + 1 )) -eq 2 \
-    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
-  && xsi_shell=yes
-AC_MSG_RESULT([$xsi_shell])
-_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
-
-AC_MSG_CHECKING([whether the shell understands "+="])
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
-    >/dev/null 2>&1 \
-  && lt_shell_append=yes
-AC_MSG_RESULT([$lt_shell_append])
-_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
-
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
-  lt_unset=unset
-else
-  lt_unset=false
-fi
-_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
-
-# test EBCDIC or ASCII
-case `echo X|tr X '\101'` in
- A) # ASCII based system
-    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
-  lt_SP2NL='tr \040 \012'
-  lt_NL2SP='tr \015\012 \040\040'
-  ;;
- *) # EBCDIC based system
-  lt_SP2NL='tr \100 \n'
-  lt_NL2SP='tr \r\n \100\100'
-  ;;
-esac
-_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
-_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
-])# _LT_CHECK_SHELL_FEATURES
-
-
-# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)
-# ------------------------------------------------------
-# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and
-# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.
-m4_defun([_LT_PROG_FUNCTION_REPLACE],
-[dnl {
-sed -e '/^$1 ()$/,/^} # $1 /c\
-$1 ()\
-{\
-m4_bpatsubsts([$2], [$], [\\], [^\([	 ]\)], [\\\1])
-} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-])
-
-
-# _LT_PROG_REPLACE_SHELLFNS
-# -------------------------
-# Replace existing portable implementations of several shell functions with
-# equivalent extended shell implementations where those features are available..
-m4_defun([_LT_PROG_REPLACE_SHELLFNS],
-[if test x"$xsi_shell" = xyes; then
-  _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl
-    case ${1} in
-      */*) func_dirname_result="${1%/*}${2}" ;;
-      *  ) func_dirname_result="${3}" ;;
-    esac])
-
-  _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl
-    func_basename_result="${1##*/}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl
-    case ${1} in
-      */*) func_dirname_result="${1%/*}${2}" ;;
-      *  ) func_dirname_result="${3}" ;;
-    esac
-    func_basename_result="${1##*/}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl
-    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
-    # positional parameters, so assign one to ordinary parameter first.
-    func_stripname_result=${3}
-    func_stripname_result=${func_stripname_result#"${1}"}
-    func_stripname_result=${func_stripname_result%"${2}"}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl
-    func_split_long_opt_name=${1%%=*}
-    func_split_long_opt_arg=${1#*=}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl
-    func_split_short_opt_arg=${1#??}
-    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl
-    case ${1} in
-      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
-      *)    func_lo2o_result=${1} ;;
-    esac])
-
-  _LT_PROG_FUNCTION_REPLACE([func_xform], [    func_xform_result=${1%.*}.lo])
-
-  _LT_PROG_FUNCTION_REPLACE([func_arith], [    func_arith_result=$(( $[*] ))])
-
-  _LT_PROG_FUNCTION_REPLACE([func_len], [    func_len_result=${#1}])
-fi
-
-if test x"$lt_shell_append" = xyes; then
-  _LT_PROG_FUNCTION_REPLACE([func_append], [    eval "${1}+=\\${2}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl
-    func_quote_for_eval "${2}"
-dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \
-    eval "${1}+=\\\\ \\$func_quote_for_eval_result"])
-
-  # Save a `func_append' function call where possible by direct use of '+='
-  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-else
-  # Save a `func_append' function call even when '+=' is not available
-  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-fi
-
-if test x"$_lt_function_replace_fail" = x":"; then
-  AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])
-fi
-])
-
-# _LT_PATH_CONVERSION_FUNCTIONS
-# -----------------------------
-# Determine which file name conversion functions should be used by
-# func_to_host_file (and, implicitly, by func_to_host_path).  These are needed
-# for certain cross-compile configurations and native mingw.
-m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-AC_MSG_CHECKING([how to convert $build file names to $host format])
-AC_CACHE_VAL(lt_cv_to_host_file_cmd,
-[case $host in
-  *-*-mingw* )
-    case $build in
-      *-*-mingw* ) # actually msys
-        lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
-        ;;
-      *-*-cygwin* )
-        lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
-        ;;
-      * ) # otherwise, assume *nix
-        lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
-        ;;
-    esac
-    ;;
-  *-*-cygwin* )
-    case $build in
-      *-*-mingw* ) # actually msys
-        lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
-        ;;
-      *-*-cygwin* )
-        lt_cv_to_host_file_cmd=func_convert_file_noop
-        ;;
-      * ) # otherwise, assume *nix
-        lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
-        ;;
-    esac
-    ;;
-  * ) # unhandled hosts (and "normal" native builds)
-    lt_cv_to_host_file_cmd=func_convert_file_noop
-    ;;
-esac
-])
-to_host_file_cmd=$lt_cv_to_host_file_cmd
-AC_MSG_RESULT([$lt_cv_to_host_file_cmd])
-_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd],
-         [0], [convert $build file names to $host format])dnl
-
-AC_MSG_CHECKING([how to convert $build file names to toolchain format])
-AC_CACHE_VAL(lt_cv_to_tool_file_cmd,
-[#assume ordinary cross tools, or native build.
-lt_cv_to_tool_file_cmd=func_convert_file_noop
-case $host in
-  *-*-mingw* )
-    case $build in
-      *-*-mingw* ) # actually msys
-        lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
-        ;;
-    esac
-    ;;
-esac
-])
-to_tool_file_cmd=$lt_cv_to_tool_file_cmd
-AC_MSG_RESULT([$lt_cv_to_tool_file_cmd])
-_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd],
-         [0], [convert $build files to toolchain format])dnl
-])# _LT_PATH_CONVERSION_FUNCTIONS
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ltoptions.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ltoptions.m4
deleted file mode 100755
index 5d9acd8..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ltoptions.m4
+++ /dev/null
@@ -1,384 +0,0 @@
-# Helper functions for option handling.                    -*- Autoconf -*-
-#
-#   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
-#   Inc.
-#   Written by Gary V. Vaughan, 2004
-#
-# This file is free software; the Free Software Foundation gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
-
-# serial 7 ltoptions.m4
-
-# This is to help aclocal find these macros, as it can't see m4_define.
-AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
-
-
-# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
-# ------------------------------------------
-m4_define([_LT_MANGLE_OPTION],
-[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
-
-
-# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
-# ---------------------------------------
-# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
-# matching handler defined, dispatch to it.  Other OPTION-NAMEs are
-# saved as a flag.
-m4_define([_LT_SET_OPTION],
-[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
-m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
-        _LT_MANGLE_DEFUN([$1], [$2]),
-    [m4_warning([Unknown $1 option `$2'])])[]dnl
-])
-
-
-# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
-# ------------------------------------------------------------
-# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
-m4_define([_LT_IF_OPTION],
-[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
-
-
-# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
-# -------------------------------------------------------
-# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
-# are set.
-m4_define([_LT_UNLESS_OPTIONS],
-[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
-	    [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
-		      [m4_define([$0_found])])])[]dnl
-m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
-])[]dnl
-])
-
-
-# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
-# ----------------------------------------
-# OPTION-LIST is a space-separated list of Libtool options associated
-# with MACRO-NAME.  If any OPTION has a matching handler declared with
-# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
-# the unknown option and exit.
-m4_defun([_LT_SET_OPTIONS],
-[# Set options
-m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
-    [_LT_SET_OPTION([$1], _LT_Option)])
-
-m4_if([$1],[LT_INIT],[
-  dnl
-  dnl Simply set some default values (i.e off) if boolean options were not
-  dnl specified:
-  _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
-  ])
-  _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
-  ])
-  dnl
-  dnl If no reference was made to various pairs of opposing options, then
-  dnl we run the default mode handler for the pair.  For example, if neither
-  dnl `shared' nor `disable-shared' was passed, we enable building of shared
-  dnl archives by default:
-  _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
-  _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
-  _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
-  _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
-  		   [_LT_ENABLE_FAST_INSTALL])
-  ])
-])# _LT_SET_OPTIONS
-
-
-## --------------------------------- ##
-## Macros to handle LT_INIT options. ##
-## --------------------------------- ##
-
-# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
-# -----------------------------------------
-m4_define([_LT_MANGLE_DEFUN],
-[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
-
-
-# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
-# -----------------------------------------------
-m4_define([LT_OPTION_DEFINE],
-[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
-])# LT_OPTION_DEFINE
-
-
-# dlopen
-# ------
-LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
-])
-
-AU_DEFUN([AC_LIBTOOL_DLOPEN],
-[_LT_SET_OPTION([LT_INIT], [dlopen])
-AC_DIAGNOSE([obsolete],
-[$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `dlopen' option into LT_INIT's first parameter.])
-])
-
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
-
-
-# win32-dll
-# ---------
-# Declare package support for building win32 dll's.
-LT_OPTION_DEFINE([LT_INIT], [win32-dll],
-[enable_win32_dll=yes
-
-case $host in
-*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
-  AC_CHECK_TOOL(AS, as, false)
-  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
-  AC_CHECK_TOOL(OBJDUMP, objdump, false)
-  ;;
-esac
-
-test -z "$AS" && AS=as
-_LT_DECL([], [AS],      [1], [Assembler program])dnl
-
-test -z "$DLLTOOL" && DLLTOOL=dlltool
-_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
-
-test -z "$OBJDUMP" && OBJDUMP=objdump
-_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
-])# win32-dll
-
-AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-_LT_SET_OPTION([LT_INIT], [win32-dll])
-AC_DIAGNOSE([obsolete],
-[$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `win32-dll' option into LT_INIT's first parameter.])
-])
-
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
-
-
-# _LT_ENABLE_SHARED([DEFAULT])
-# ----------------------------
-# implement the --enable-shared flag, and supports the `shared' and
-# `disable-shared' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
-m4_define([_LT_ENABLE_SHARED],
-[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
-AC_ARG_ENABLE([shared],
-    [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
-	[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
-    [p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_shared=yes ;;
-    no) enable_shared=no ;;
-    *)
-      enable_shared=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-	IFS="$lt_save_ifs"
-	if test "X$pkg" = "X$p"; then
-	  enable_shared=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac],
-    [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
-
-    _LT_DECL([build_libtool_libs], [enable_shared], [0],
-	[Whether or not to build shared libraries])
-])# _LT_ENABLE_SHARED
-
-LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
-LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
-
-# Old names:
-AC_DEFUN([AC_ENABLE_SHARED],
-[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
-])
-
-AC_DEFUN([AC_DISABLE_SHARED],
-[_LT_SET_OPTION([LT_INIT], [disable-shared])
-])
-
-AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
-AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
-
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AM_ENABLE_SHARED], [])
-dnl AC_DEFUN([AM_DISABLE_SHARED], [])
-
-
-
-# _LT_ENABLE_STATIC([DEFAULT])
-# ----------------------------
-# implement the --enable-static flag, and support the `static' and
-# `disable-static' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
-m4_define([_LT_ENABLE_STATIC],
-[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
-AC_ARG_ENABLE([static],
-    [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
-	[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
-    [p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_static=yes ;;
-    no) enable_static=no ;;
-    *)
-     enable_static=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-	IFS="$lt_save_ifs"
-	if test "X$pkg" = "X$p"; then
-	  enable_static=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac],
-    [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
-
-    _LT_DECL([build_old_libs], [enable_static], [0],
-	[Whether or not to build static libraries])
-])# _LT_ENABLE_STATIC
-
-LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
-LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
-
-# Old names:
-AC_DEFUN([AC_ENABLE_STATIC],
-[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
-])
-
-AC_DEFUN([AC_DISABLE_STATIC],
-[_LT_SET_OPTION([LT_INIT], [disable-static])
-])
-
-AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
-AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
-
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AM_ENABLE_STATIC], [])
-dnl AC_DEFUN([AM_DISABLE_STATIC], [])
-
-
-
-# _LT_ENABLE_FAST_INSTALL([DEFAULT])
-# ----------------------------------
-# implement the --enable-fast-install flag, and support the `fast-install'
-# and `disable-fast-install' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
-m4_define([_LT_ENABLE_FAST_INSTALL],
-[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
-AC_ARG_ENABLE([fast-install],
-    [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
-    [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
-    [p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_fast_install=yes ;;
-    no) enable_fast_install=no ;;
-    *)
-      enable_fast_install=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-	IFS="$lt_save_ifs"
-	if test "X$pkg" = "X$p"; then
-	  enable_fast_install=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac],
-    [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
-
-_LT_DECL([fast_install], [enable_fast_install], [0],
-	 [Whether or not to optimize for fast installation])dnl
-])# _LT_ENABLE_FAST_INSTALL
-
-LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
-LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
-
-# Old names:
-AU_DEFUN([AC_ENABLE_FAST_INSTALL],
-[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
-AC_DIAGNOSE([obsolete],
-[$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `fast-install' option into LT_INIT's first parameter.])
-])
-
-AU_DEFUN([AC_DISABLE_FAST_INSTALL],
-[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
-AC_DIAGNOSE([obsolete],
-[$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `disable-fast-install' option into LT_INIT's first parameter.])
-])
-
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
-dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
-
-
-# _LT_WITH_PIC([MODE])
-# --------------------
-# implement the --with-pic flag, and support the `pic-only' and `no-pic'
-# LT_INIT options.
-# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
-m4_define([_LT_WITH_PIC],
-[AC_ARG_WITH([pic],
-    [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
-	[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
-    [lt_p=${PACKAGE-default}
-    case $withval in
-    yes|no) pic_mode=$withval ;;
-    *)
-      pic_mode=default
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for lt_pkg in $withval; do
-	IFS="$lt_save_ifs"
-	if test "X$lt_pkg" = "X$lt_p"; then
-	  pic_mode=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac],
-    [pic_mode=default])
-
-test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
-
-_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
-])# _LT_WITH_PIC
-
-LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
-LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
-
-# Old name:
-AU_DEFUN([AC_LIBTOOL_PICMODE],
-[_LT_SET_OPTION([LT_INIT], [pic-only])
-AC_DIAGNOSE([obsolete],
-[$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `pic-only' option into LT_INIT's first parameter.])
-])
-
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
-
-## ----------------- ##
-## LTDL_INIT Options ##
-## ----------------- ##
-
-m4_define([_LTDL_MODE], [])
-LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
-		 [m4_define([_LTDL_MODE], [nonrecursive])])
-LT_OPTION_DEFINE([LTDL_INIT], [recursive],
-		 [m4_define([_LTDL_MODE], [recursive])])
-LT_OPTION_DEFINE([LTDL_INIT], [subproject],
-		 [m4_define([_LTDL_MODE], [subproject])])
-
-m4_define([_LTDL_TYPE], [])
-LT_OPTION_DEFINE([LTDL_INIT], [installable],
-		 [m4_define([_LTDL_TYPE], [installable])])
-LT_OPTION_DEFINE([LTDL_INIT], [convenience],
-		 [m4_define([_LTDL_TYPE], [convenience])])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ltsugar.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ltsugar.m4
deleted file mode 100755
index 9000a05..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ltsugar.m4
+++ /dev/null
@@ -1,123 +0,0 @@
-# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
-#
-# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
-# Written by Gary V. Vaughan, 2004
-#
-# This file is free software; the Free Software Foundation gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
-
-# serial 6 ltsugar.m4
-
-# This is to help aclocal find these macros, as it can't see m4_define.
-AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
-
-
-# lt_join(SEP, ARG1, [ARG2...])
-# -----------------------------
-# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
-# associated separator.
-# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
-# versions in m4sugar had bugs.
-m4_define([lt_join],
-[m4_if([$#], [1], [],
-       [$#], [2], [[$2]],
-       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
-m4_define([_lt_join],
-[m4_if([$#$2], [2], [],
-       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
-
-
-# lt_car(LIST)
-# lt_cdr(LIST)
-# ------------
-# Manipulate m4 lists.
-# These macros are necessary as long as will still need to support
-# Autoconf-2.59 which quotes differently.
-m4_define([lt_car], [[$1]])
-m4_define([lt_cdr],
-[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
-       [$#], 1, [],
-       [m4_dquote(m4_shift($@))])])
-m4_define([lt_unquote], $1)
-
-
-# lt_append(MACRO-NAME, STRING, [SEPARATOR])
-# ------------------------------------------
-# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
-# Note that neither SEPARATOR nor STRING are expanded; they are appended
-# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
-# No SEPARATOR is output if MACRO-NAME was previously undefined (different
-# than defined and empty).
-#
-# This macro is needed until we can rely on Autoconf 2.62, since earlier
-# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
-m4_define([lt_append],
-[m4_define([$1],
-	   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
-
-
-
-# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
-# ----------------------------------------------------------
-# Produce a SEP delimited list of all paired combinations of elements of
-# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
-# has the form PREFIXmINFIXSUFFIXn.
-# Needed until we can rely on m4_combine added in Autoconf 2.62.
-m4_define([lt_combine],
-[m4_if(m4_eval([$# > 3]), [1],
-       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
-[[m4_foreach([_Lt_prefix], [$2],
-	     [m4_foreach([_Lt_suffix],
-		]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
-	[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
-
-
-# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
-# -----------------------------------------------------------------------
-# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
-# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
-m4_define([lt_if_append_uniq],
-[m4_ifdef([$1],
-	  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
-		 [lt_append([$1], [$2], [$3])$4],
-		 [$5])],
-	  [lt_append([$1], [$2], [$3])$4])])
-
-
-# lt_dict_add(DICT, KEY, VALUE)
-# -----------------------------
-m4_define([lt_dict_add],
-[m4_define([$1($2)], [$3])])
-
-
-# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
-# --------------------------------------------
-m4_define([lt_dict_add_subkey],
-[m4_define([$1($2:$3)], [$4])])
-
-
-# lt_dict_fetch(DICT, KEY, [SUBKEY])
-# ----------------------------------
-m4_define([lt_dict_fetch],
-[m4_ifval([$3],
-	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
-    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
-
-
-# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
-# -----------------------------------------------------------------
-m4_define([lt_if_dict_fetch],
-[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
-	[$5],
-    [$6])])
-
-
-# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
-# --------------------------------------------------------------
-m4_define([lt_dict_filter],
-[m4_if([$5], [], [],
-  [lt_join(m4_quote(m4_default([$4], [[, ]])),
-           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
-		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
-])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/ltversion.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/ltversion.m4
deleted file mode 100755
index 07a8602..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/ltversion.m4
+++ /dev/null
@@ -1,23 +0,0 @@
-# ltversion.m4 -- version numbers			-*- Autoconf -*-
-#
-#   Copyright (C) 2004 Free Software Foundation, Inc.
-#   Written by Scott James Remnant, 2004
-#
-# This file is free software; the Free Software Foundation gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
-
-# @configure_input@
-
-# serial 3337 ltversion.m4
-# This file is part of GNU Libtool
-
-m4_define([LT_PACKAGE_VERSION], [2.4.2])
-m4_define([LT_PACKAGE_REVISION], [1.3337])
-
-AC_DEFUN([LTVERSION_VERSION],
-[macro_version='2.4.2'
-macro_revision='1.3337'
-_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
-_LT_DECL(, macro_revision, 0)
-])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/lt~obsolete.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/lt~obsolete.m4
deleted file mode 100755
index c573da9..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/lt~obsolete.m4
+++ /dev/null
@@ -1,98 +0,0 @@
-# lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
-#
-#   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
-#   Written by Scott James Remnant, 2004.
-#
-# This file is free software; the Free Software Foundation gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
-
-# serial 5 lt~obsolete.m4
-
-# These exist entirely to fool aclocal when bootstrapping libtool.
-#
-# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
-# which have later been changed to m4_define as they aren't part of the
-# exported API, or moved to Autoconf or Automake where they belong.
-#
-# The trouble is, aclocal is a bit thick.  It'll see the old AC_DEFUN
-# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
-# using a macro with the same name in our local m4/libtool.m4 it'll
-# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
-# and doesn't know about Autoconf macros at all.)
-#
-# So we provide this file, which has a silly filename so it's always
-# included after everything else.  This provides aclocal with the
-# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
-# because those macros already exist, or will be overwritten later.
-# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
-#
-# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
-# Yes, that means every name once taken will need to remain here until
-# we give up compatibility with versions before 1.7, at which point
-# we need to keep only those names which we still refer to.
-
-# This is to help aclocal find these macros, as it can't see m4_define.
-AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
-
-m4_ifndef([AC_LIBTOOL_LINKER_OPTION],	[AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
-m4_ifndef([AC_PROG_EGREP],		[AC_DEFUN([AC_PROG_EGREP])])
-m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH],	[AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
-m4_ifndef([_LT_AC_SHELL_INIT],		[AC_DEFUN([_LT_AC_SHELL_INIT])])
-m4_ifndef([_LT_AC_SYS_LIBPATH_AIX],	[AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
-m4_ifndef([_LT_PROG_LTMAIN],		[AC_DEFUN([_LT_PROG_LTMAIN])])
-m4_ifndef([_LT_AC_TAGVAR],		[AC_DEFUN([_LT_AC_TAGVAR])])
-m4_ifndef([AC_LTDL_ENABLE_INSTALL],	[AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
-m4_ifndef([AC_LTDL_PREOPEN],		[AC_DEFUN([AC_LTDL_PREOPEN])])
-m4_ifndef([_LT_AC_SYS_COMPILER],	[AC_DEFUN([_LT_AC_SYS_COMPILER])])
-m4_ifndef([_LT_AC_LOCK],		[AC_DEFUN([_LT_AC_LOCK])])
-m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE],	[AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
-m4_ifndef([_LT_AC_TRY_DLOPEN_SELF],	[AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
-m4_ifndef([AC_LIBTOOL_PROG_CC_C_O],	[AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
-m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
-m4_ifndef([AC_LIBTOOL_OBJDIR],		[AC_DEFUN([AC_LIBTOOL_OBJDIR])])
-m4_ifndef([AC_LTDL_OBJDIR],		[AC_DEFUN([AC_LTDL_OBJDIR])])
-m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
-m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP],	[AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
-m4_ifndef([AC_PATH_MAGIC],		[AC_DEFUN([AC_PATH_MAGIC])])
-m4_ifndef([AC_PROG_LD_GNU],		[AC_DEFUN([AC_PROG_LD_GNU])])
-m4_ifndef([AC_PROG_LD_RELOAD_FLAG],	[AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
-m4_ifndef([AC_DEPLIBS_CHECK_METHOD],	[AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
-m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
-m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
-m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
-m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS],	[AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
-m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP],	[AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
-m4_ifndef([LT_AC_PROG_EGREP],		[AC_DEFUN([LT_AC_PROG_EGREP])])
-m4_ifndef([LT_AC_PROG_SED],		[AC_DEFUN([LT_AC_PROG_SED])])
-m4_ifndef([_LT_CC_BASENAME],		[AC_DEFUN([_LT_CC_BASENAME])])
-m4_ifndef([_LT_COMPILER_BOILERPLATE],	[AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
-m4_ifndef([_LT_LINKER_BOILERPLATE],	[AC_DEFUN([_LT_LINKER_BOILERPLATE])])
-m4_ifndef([_AC_PROG_LIBTOOL],		[AC_DEFUN([_AC_PROG_LIBTOOL])])
-m4_ifndef([AC_LIBTOOL_SETUP],		[AC_DEFUN([AC_LIBTOOL_SETUP])])
-m4_ifndef([_LT_AC_CHECK_DLFCN],		[AC_DEFUN([_LT_AC_CHECK_DLFCN])])
-m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER],	[AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
-m4_ifndef([_LT_AC_TAGCONFIG],		[AC_DEFUN([_LT_AC_TAGCONFIG])])
-m4_ifndef([AC_DISABLE_FAST_INSTALL],	[AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
-m4_ifndef([_LT_AC_LANG_CXX],		[AC_DEFUN([_LT_AC_LANG_CXX])])
-m4_ifndef([_LT_AC_LANG_F77],		[AC_DEFUN([_LT_AC_LANG_F77])])
-m4_ifndef([_LT_AC_LANG_GCJ],		[AC_DEFUN([_LT_AC_LANG_GCJ])])
-m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
-m4_ifndef([_LT_AC_LANG_C_CONFIG],	[AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
-m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
-m4_ifndef([_LT_AC_LANG_CXX_CONFIG],	[AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
-m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
-m4_ifndef([_LT_AC_LANG_F77_CONFIG],	[AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
-m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
-m4_ifndef([_LT_AC_LANG_GCJ_CONFIG],	[AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
-m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
-m4_ifndef([_LT_AC_LANG_RC_CONFIG],	[AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
-m4_ifndef([AC_LIBTOOL_CONFIG],		[AC_DEFUN([AC_LIBTOOL_CONFIG])])
-m4_ifndef([_LT_AC_FILE_LTDLL_C],	[AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
-m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS],	[AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
-m4_ifndef([_LT_AC_PROG_CXXCPP],		[AC_DEFUN([_LT_AC_PROG_CXXCPP])])
-m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS],	[AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
-m4_ifndef([_LT_PROG_ECHO_BACKSLASH],	[AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
-m4_ifndef([_LT_PROG_F77],		[AC_DEFUN([_LT_PROG_F77])])
-m4_ifndef([_LT_PROG_FC],		[AC_DEFUN([_LT_PROG_FC])])
-m4_ifndef([_LT_PROG_CXX],		[AC_DEFUN([_LT_PROG_CXX])])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/visibility.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/visibility.m4
deleted file mode 100755
index 75c34b6..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/visibility.m4
+++ /dev/null
@@ -1,77 +0,0 @@
-# visibility.m4 serial 4 (gettext-0.18.2)
-dnl Copyright (C) 2005, 2008, 2010-2011 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Bruno Haible.
-
-dnl Tests whether the compiler supports the command-line option
-dnl -fvisibility=hidden and the function and variable attributes
-dnl __attribute__((__visibility__("hidden"))) and
-dnl __attribute__((__visibility__("default"))).
-dnl Does *not* test for __visibility__("protected") - which has tricky
-dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
-dnl MacOS X.
-dnl Does *not* test for __visibility__("internal") - which has processor
-dnl dependent semantics.
-dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
-dnl "really only recommended for legacy code".
-dnl Set the variable CFLAG_VISIBILITY.
-dnl Defines and sets the variable HAVE_VISIBILITY.
-
-AC_DEFUN([gl_VISIBILITY],
-[
-  AC_REQUIRE([AC_PROG_CC])
-  CFLAG_VISIBILITY=
-  HAVE_VISIBILITY=0
-  if test -n "$GCC"; then
-    dnl First, check whether -Werror can be added to the command line, or
-    dnl whether it leads to an error because of some other option that the
-    dnl user has put into $CC $CFLAGS $CPPFLAGS.
-    AC_MSG_CHECKING([whether the -Werror option is usable])
-    AC_CACHE_VAL([gl_cv_cc_vis_werror], [
-      gl_save_CFLAGS="$CFLAGS"
-      CFLAGS="$CFLAGS -Werror"
-      AC_COMPILE_IFELSE(
-        [AC_LANG_PROGRAM([[]], [[]])],
-        [gl_cv_cc_vis_werror=yes],
-        [gl_cv_cc_vis_werror=no])
-      CFLAGS="$gl_save_CFLAGS"])
-    AC_MSG_RESULT([$gl_cv_cc_vis_werror])
-    dnl Now check whether visibility declarations are supported.
-    AC_MSG_CHECKING([for simple visibility declarations])
-    AC_CACHE_VAL([gl_cv_cc_visibility], [
-      gl_save_CFLAGS="$CFLAGS"
-      CFLAGS="$CFLAGS -fvisibility=hidden"
-      dnl We use the option -Werror and a function dummyfunc, because on some
-      dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
-      dnl "visibility attribute not supported in this configuration; ignored"
-      dnl at the first function definition in every compilation unit, and we
-      dnl don't want to use the option in this case.
-      if test $gl_cv_cc_vis_werror = yes; then
-        CFLAGS="$CFLAGS -Werror"
-      fi
-      AC_COMPILE_IFELSE(
-        [AC_LANG_PROGRAM(
-           [[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
-             extern __attribute__((__visibility__("default"))) int exportedvar;
-             extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
-             extern __attribute__((__visibility__("default"))) int exportedfunc (void);
-             void dummyfunc (void) {}
-           ]],
-           [[]])],
-        [gl_cv_cc_visibility=yes],
-        [gl_cv_cc_visibility=no])
-      CFLAGS="$gl_save_CFLAGS"])
-    AC_MSG_RESULT([$gl_cv_cc_visibility])
-    if test $gl_cv_cc_visibility = yes; then
-      CFLAG_VISIBILITY="-fvisibility=hidden"
-      HAVE_VISIBILITY=1
-    fi
-  fi
-  AC_SUBST([CFLAG_VISIBILITY])
-  AC_SUBST([HAVE_VISIBILITY])
-  AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY],
-    [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.])
-])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/m4/wolfssl_darwin_clang.m4 b/FreeRTOS-Plus/Source/WolfSSL/m4/wolfssl_darwin_clang.m4
deleted file mode 100755
index fee9b6a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/m4/wolfssl_darwin_clang.m4
+++ /dev/null
@@ -1,37 +0,0 @@
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   WOLFSSL_DARWIN_USING_CLANG
-#
-# DESCRIPTION
-#
-#   With the advent of Apple Xcode v5.0, the old tool sets are missing from
-#   the distribution. The provided "gcc" executable wrapper accepts the
-#   "-pthread" flag, and passes it to the underlying "clang" which chokes
-#   on it. This script checks the version of the gcc executable to see if
-#   it reports it is really "clang".
-#
-#   The value is placed in the wolfssl_darwin_clang variable.
-#
-# LICENSE
-#
-#   Copyright (c) 2013 John Safranek 
-#
-#   Copying and distribution of this file, with or without modification, are
-#   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved. This file is offered as-is, without any
-#   warranty.
-
-#serial 1
-
-AC_DEFUN([WOLFSSL_DARWIN_USING_CLANG],
-        [
-            if test x"$CC" = xclang; then
-                wolfssl_darwin_clang=yes
-            elif test x"$CC" = x || test x"$CC" = xgcc; then
-                if /usr/bin/gcc -v 2>&1 | grep 'clang' >/dev/null 2>&1; then
-                    wolfssl_darwin_clang=yes
-                fi
-            fi
-        ])
diff --git a/FreeRTOS-Plus/Source/WolfSSL/quit b/FreeRTOS-Plus/Source/WolfSSL/quit
deleted file mode 100755
index 3db49b3..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/quit
+++ /dev/null
@@ -1,2 +0,0 @@
-quit
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/rpm/include.am b/FreeRTOS-Plus/Source/WolfSSL/rpm/include.am
deleted file mode 100755
index e5253dd..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/rpm/include.am
+++ /dev/null
@@ -1,37 +0,0 @@
-# vim:ft=automake
-
-rpm-build: rpm/spec dist
-	@rm -f *.rpm
-	@rm -f ~/rpmbuild/RPMS/x86_64/$(PACKAGE)-$(VERSION)*.rpm
-	@rm -f ~/rpmbuild/SRPMS/$(PACKAGE)-$(VERSION)*.rpm
-	@mkdir -p ~/rpmbuild/BUILD/
-	@mkdir -p ~/rpmbuild/RPMS/i386/
-	@mkdir -p ~/rpmbuild/RPMS/i686/
-	@mkdir -p ~/rpmbuild/RPMS/noarch/
-	@mkdir -p ~/rpmbuild/RPMS/x86_64/
-	@mkdir -p ~/rpmbuild/SOURCES/
-	@mkdir -p ~/rpmbuild/SPECS/
-	@mkdir -p ~/rpmbuild/SRPMS/
-	@cp $(PACKAGE)-$(VERSION).tar.gz ~/rpmbuild/SOURCES/
-	@rpmbuild -ba --clean rpm/spec
-	@cp ~/rpmbuild/RPMS/x86_64/$(PACKAGE)-$(VERSION)*.rpm .
-	@cp ~/rpmbuild/RPMS/x86_64/$(PACKAGE)-devel-$(VERSION)*.rpm .
-	@cp ~/rpmbuild/RPMS/x86_64/$(PACKAGE)-debuginfo-$(VERSION)*.rpm .
-	@cp ~/rpmbuild/SRPMS/$(PACKAGE)-$(VERSION)*.rpm .
-
-rpm-sign: rpm-build
-	@rpm --addsign *.rpm
-	@rpm --checksig *.rpm
-
-clean-rpm:
-	@rm -f *.tar.gz
-	@rm -f *.src.rpm
-	@rm -f *.rpm
-
-rpm: rpm-build
-
-release: rpm-sign
-
-auto-rpmbuild:
-	@auto-br-rpmbuild -ba rpm/spec
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/rpm/spec.in b/FreeRTOS-Plus/Source/WolfSSL/rpm/spec.in
deleted file mode 100755
index 1e291dd..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/rpm/spec.in
+++ /dev/null
@@ -1,265 +0,0 @@
-Summary: Embedded SSL Library
-Name: @PACKAGE@
-Version: @VERSION@
-Release: 1
-License: GPLv2
-Group: System Environment/Libraries
-BuildRequires: gcc
-BuildRequires: glibc
-BuildRequires: glibc-common
-BuildRequires: glibc-devel
-BuildRequires: glibc-headers
-BuildRequires: make
-BuildRequires: pkgconfig
-BuildRequires: sed
-BuildRequires: tar
-URL: http://www.wolfssl.com/
-
-Packager: Brian Aker 
-
-Source: http://wolfssl.com/%{name}-%{version}.tar.gz
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
-
-%description
-Misc tools for wolfSSL.
-
-%package devel
-Summary: Header files and development libraries for %{name}
-Group: Development/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description devel
-This package contains the header files and development libraries
-for %{name}. If you like to develop programs using %{name},
-you will need to install %{name}-devel.
-
-%prep
-%setup -q
-
-%configure
-
-
-%build
-%{__make} %{?_smp_mflags}
-
-%install
-%{__rm} -rf %{buildroot}
-%{__make} install  DESTDIR="%{buildroot}" AM_INSTALL_PROGRAM_FLAGS=""
-mkdir -p $RPM_BUILD_ROOT/
-
-%check
-
-
-%clean
-%{__rm} -rf %{buildroot}
-
-%post -p /sbin/ldconfig
-
-%postun -p /sbin/ldconfig
-
-%files
-%defattr(-,root,root,-)
-%doc AUTHORS ChangeLog COPYING NEWS README
-%{_docdir}/wolfssl/taoCert.txt
-%{_docdir}/wolfssl/example/echoserver.c
-%{_docdir}/wolfssl/example/server.c
-%{_docdir}/wolfssl/example/echoclient.c
-%{_docdir}/wolfssl/example/client.c
-%{_docdir}/wolfssl/README.txt
-%{_libdir}/libwolfssl.la
-%{_libdir}/libwolfssl.so
-%{_libdir}/libwolfssl.so.0
-%{_libdir}/libwolfssl.so.0.0.2
-
-%files devel
-%defattr(-,root,root,-)
-%doc AUTHORS ChangeLog COPYING NEWS README
-%{_bindir}/wolfssl-config
-%{_includedir}/cyassl/callbacks.h
-%{_includedir}/cyassl/certs_test.h
-%{_includedir}/cyassl/crl.h
-%{_includedir}/cyassl/ctaocrypt/aes.h
-%{_includedir}/cyassl/ctaocrypt/arc4.h
-%{_includedir}/cyassl/ctaocrypt/asn.h
-%{_includedir}/cyassl/ctaocrypt/asn_public.h
-%{_includedir}/cyassl/ctaocrypt/blake2-impl.h
-%{_includedir}/cyassl/ctaocrypt/blake2-int.h
-%{_includedir}/cyassl/ctaocrypt/blake2.h
-%{_includedir}/cyassl/ctaocrypt/camellia.h
-%{_includedir}/cyassl/ctaocrypt/chacha.h
-%{_includedir}/cyassl/ctaocrypt/coding.h
-%{_includedir}/cyassl/ctaocrypt/compress.h
-%{_includedir}/cyassl/ctaocrypt/des3.h
-%{_includedir}/cyassl/ctaocrypt/dh.h
-%{_includedir}/cyassl/ctaocrypt/dsa.h
-%{_includedir}/cyassl/ctaocrypt/ecc.h
-%{_includedir}/cyassl/ctaocrypt/error-crypt.h
-%{_includedir}/cyassl/ctaocrypt/fips_test.h
-%{_includedir}/cyassl/ctaocrypt/hc128.h
-%{_includedir}/cyassl/ctaocrypt/hmac.h
-%{_includedir}/cyassl/ctaocrypt/integer.h
-%{_includedir}/cyassl/ctaocrypt/logging.h
-%{_includedir}/cyassl/ctaocrypt/md2.h
-%{_includedir}/cyassl/ctaocrypt/md4.h
-%{_includedir}/cyassl/ctaocrypt/md5.h
-%{_includedir}/cyassl/ctaocrypt/memory.h
-%{_includedir}/cyassl/ctaocrypt/misc.h
-%{_includedir}/cyassl/ctaocrypt/mpi_class.h
-%{_includedir}/cyassl/ctaocrypt/mpi_superclass.h
-%{_includedir}/cyassl/ctaocrypt/pkcs7.h
-%{_includedir}/cyassl/ctaocrypt/poly1305.h
-%{_includedir}/cyassl/ctaocrypt/wc_port.h
-%{_includedir}/cyassl/ctaocrypt/pwdbased.h
-%{_includedir}/cyassl/ctaocrypt/rabbit.h
-%{_includedir}/cyassl/ctaocrypt/random.h
-%{_includedir}/cyassl/ctaocrypt/ripemd.h
-%{_includedir}/cyassl/ctaocrypt/rsa.h
-%{_includedir}/cyassl/ctaocrypt/settings.h
-%{_includedir}/cyassl/ctaocrypt/settings_comp.h
-%{_includedir}/cyassl/ctaocrypt/sha.h
-%{_includedir}/cyassl/ctaocrypt/sha256.h
-%{_includedir}/cyassl/ctaocrypt/sha512.h
-%{_includedir}/cyassl/ctaocrypt/tfm.h
-%{_includedir}/cyassl/ctaocrypt/types.h
-%{_includedir}/cyassl/ctaocrypt/visibility.h
-%{_includedir}/cyassl/error-ssl.h
-%{_includedir}/cyassl/ocsp.h
-%{_includedir}/cyassl/openssl/asn1.h
-%{_includedir}/cyassl/openssl/bio.h
-%{_includedir}/cyassl/openssl/bn.h
-%{_includedir}/cyassl/openssl/conf.h
-%{_includedir}/cyassl/openssl/crypto.h
-%{_includedir}/cyassl/openssl/des.h
-%{_includedir}/cyassl/openssl/dh.h
-%{_includedir}/cyassl/openssl/dsa.h
-%{_includedir}/cyassl/openssl/ec.h
-%{_includedir}/cyassl/openssl/ecdsa.h
-%{_includedir}/cyassl/openssl/engine.h
-%{_includedir}/cyassl/openssl/err.h
-%{_includedir}/cyassl/openssl/evp.h
-%{_includedir}/cyassl/openssl/hmac.h
-%{_includedir}/cyassl/openssl/lhash.h
-%{_includedir}/cyassl/openssl/md4.h
-%{_includedir}/cyassl/openssl/md5.h
-%{_includedir}/cyassl/openssl/ocsp.h
-%{_includedir}/cyassl/openssl/opensslconf.h
-%{_includedir}/cyassl/openssl/opensslv.h
-%{_includedir}/cyassl/openssl/ossl_typ.h
-%{_includedir}/cyassl/openssl/pem.h
-%{_includedir}/cyassl/openssl/pkcs12.h
-%{_includedir}/cyassl/openssl/rand.h
-%{_includedir}/cyassl/openssl/ripemd.h
-%{_includedir}/cyassl/openssl/rsa.h
-%{_includedir}/cyassl/openssl/sha.h
-%{_includedir}/cyassl/openssl/ssl.h
-%{_includedir}/cyassl/openssl/stack.h
-%{_includedir}/cyassl/openssl/ui.h
-%{_includedir}/cyassl/openssl/x509.h
-%{_includedir}/cyassl/openssl/x509v3.h
-%{_includedir}/cyassl/options.h
-%{_includedir}/cyassl/sniffer.h
-%{_includedir}/cyassl/sniffer_error.h
-%{_includedir}/cyassl/ssl.h
-%{_includedir}/cyassl/test.h
-%{_includedir}/cyassl/version.h
-%{_includedir}/wolfssl/callbacks.h
-%{_includedir}/wolfssl/certs_test.h
-%{_includedir}/wolfssl/crl.h
-%{_includedir}/wolfssl/wolfcrypt/aes.h
-%{_includedir}/wolfssl/wolfcrypt/arc4.h
-%{_includedir}/wolfssl/wolfcrypt/asn.h
-%{_includedir}/wolfssl/wolfcrypt/asn_public.h
-%{_includedir}/wolfssl/wolfcrypt/blake2-impl.h
-%{_includedir}/wolfssl/wolfcrypt/blake2-int.h
-%{_includedir}/wolfssl/wolfcrypt/blake2.h
-%{_includedir}/wolfssl/wolfcrypt/camellia.h
-%{_includedir}/wolfssl/wolfcrypt/chacha.h
-%{_includedir}/wolfssl/wolfcrypt/chacha20_poly1305.h
-%{_includedir}/wolfssl/wolfcrypt/coding.h
-%{_includedir}/wolfssl/wolfcrypt/compress.h
-%{_includedir}/wolfssl/wolfcrypt/curve25519.h
-%{_includedir}/wolfssl/wolfcrypt/des3.h
-%{_includedir}/wolfssl/wolfcrypt/dh.h
-%{_includedir}/wolfssl/wolfcrypt/dsa.h
-%{_includedir}/wolfssl/wolfcrypt/ecc.h
-%{_includedir}/wolfssl/wolfcrypt/ed25519.h
-%{_includedir}/wolfssl/wolfcrypt/error-crypt.h
-%{_includedir}/wolfssl/wolfcrypt/fe_operations.h
-%{_includedir}/wolfssl/wolfcrypt/fips_test.h
-%{_includedir}/wolfssl/wolfcrypt/ge_operations.h
-%{_includedir}/wolfssl/wolfcrypt/hash.h
-%{_includedir}/wolfssl/wolfcrypt/hc128.h
-%{_includedir}/wolfssl/wolfcrypt/hmac.h
-%{_includedir}/wolfssl/wolfcrypt/integer.h
-%{_includedir}/wolfssl/wolfcrypt/logging.h
-%{_includedir}/wolfssl/wolfcrypt/md2.h
-%{_includedir}/wolfssl/wolfcrypt/md4.h
-%{_includedir}/wolfssl/wolfcrypt/md5.h
-%{_includedir}/wolfssl/wolfcrypt/memory.h
-%{_includedir}/wolfssl/wolfcrypt/misc.h
-%{_includedir}/wolfssl/wolfcrypt/mpi_class.h
-%{_includedir}/wolfssl/wolfcrypt/mpi_superclass.h
-%{_includedir}/wolfssl/wolfcrypt/pkcs7.h
-%{_includedir}/wolfssl/wolfcrypt/wc_port.h
-%{_includedir}/wolfssl/wolfcrypt/poly1305.h
-%{_includedir}/wolfssl/wolfcrypt/pwdbased.h
-%{_includedir}/wolfssl/wolfcrypt/rabbit.h
-%{_includedir}/wolfssl/wolfcrypt/random.h
-%{_includedir}/wolfssl/wolfcrypt/ripemd.h
-%{_includedir}/wolfssl/wolfcrypt/rsa.h
-%{_includedir}/wolfssl/wolfcrypt/settings.h
-%{_includedir}/wolfssl/wolfcrypt/sha.h
-%{_includedir}/wolfssl/wolfcrypt/sha256.h
-%{_includedir}/wolfssl/wolfcrypt/sha512.h
-%{_includedir}/wolfssl/wolfcrypt/tfm.h
-%{_includedir}/wolfssl/wolfcrypt/types.h
-%{_includedir}/wolfssl/wolfcrypt/visibility.h
-%{_includedir}/wolfssl/error-ssl.h
-%{_includedir}/wolfssl/ocsp.h
-%{_includedir}/wolfssl/openssl/asn1.h
-%{_includedir}/wolfssl/openssl/bio.h
-%{_includedir}/wolfssl/openssl/bn.h
-%{_includedir}/wolfssl/openssl/conf.h
-%{_includedir}/wolfssl/openssl/crypto.h
-%{_includedir}/wolfssl/openssl/des.h
-%{_includedir}/wolfssl/openssl/dh.h
-%{_includedir}/wolfssl/openssl/dsa.h
-%{_includedir}/wolfssl/openssl/ec.h
-%{_includedir}/wolfssl/openssl/ecdsa.h
-%{_includedir}/wolfssl/openssl/engine.h
-%{_includedir}/wolfssl/openssl/err.h
-%{_includedir}/wolfssl/openssl/evp.h
-%{_includedir}/wolfssl/openssl/hmac.h
-%{_includedir}/wolfssl/openssl/lhash.h
-%{_includedir}/wolfssl/openssl/md4.h
-%{_includedir}/wolfssl/openssl/md5.h
-%{_includedir}/wolfssl/openssl/ocsp.h
-%{_includedir}/wolfssl/openssl/opensslconf.h
-%{_includedir}/wolfssl/openssl/opensslv.h
-%{_includedir}/wolfssl/openssl/ossl_typ.h
-%{_includedir}/wolfssl/openssl/pem.h
-%{_includedir}/wolfssl/openssl/pkcs12.h
-%{_includedir}/wolfssl/openssl/rand.h
-%{_includedir}/wolfssl/openssl/ripemd.h
-%{_includedir}/wolfssl/openssl/rsa.h
-%{_includedir}/wolfssl/openssl/sha.h
-%{_includedir}/wolfssl/openssl/ssl.h
-%{_includedir}/wolfssl/openssl/stack.h
-%{_includedir}/wolfssl/openssl/ui.h
-%{_includedir}/wolfssl/openssl/x509.h
-%{_includedir}/wolfssl/openssl/x509v3.h
-%{_includedir}/wolfssl/options.h
-%{_includedir}/wolfssl/sniffer.h
-%{_includedir}/wolfssl/sniffer_error.h
-%{_includedir}/wolfssl/ssl.h
-%{_includedir}/wolfssl/test.h
-%{_includedir}/wolfssl/version.h
-%{_libdir}/pkgconfig/wolfssl.pc
-
-%changelog
-* Tue Mar 31 2015 John Safranek 
-- Added recent new wolfcrypt headers for curve25519
-* Fri Jan 09 2015 John Safranek 
-- Update for cyassl->wolfssl name change
-* Fri Oct 20 2012 Brian Aker 
-- Initial package
diff --git a/FreeRTOS-Plus/Source/WolfSSL/src/crl.c b/FreeRTOS-Plus/Source/WolfSSL/src/crl.c
deleted file mode 100755
index 0f47ee1..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/src/crl.c
+++ /dev/null
@@ -1,790 +0,0 @@
-/* crl.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-  /* Name change compatibility layer no longer needs included here */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef HAVE_CRL
-
-#include 
-#include 
-
-#include 
-#include 
-#include 
-
-#ifdef HAVE_CRL_MONITOR
-    static int StopMonitor(int mfd);
-#endif
-
-
-/* Initialze CRL members */
-int InitCRL(WOLFSSL_CRL* crl, WOLFSSL_CERT_MANAGER* cm)
-{
-    WOLFSSL_ENTER("InitCRL");
-
-    crl->cm = cm;
-    crl->crlList = NULL;
-    crl->monitors[0].path = NULL;
-    crl->monitors[1].path = NULL;
-#ifdef HAVE_CRL_MONITOR
-    crl->tid =  0;
-    crl->mfd = -1;   /* mfd for bsd is kqueue fd, eventfd for linux */
-#endif
-    if (InitMutex(&crl->crlLock) != 0)
-        return BAD_MUTEX_E; 
-
-    return 0;
-}
-
-
-/* Initialze CRL Entry */
-static int InitCRL_Entry(CRL_Entry* crle, DecodedCRL* dcrl)
-{
-    WOLFSSL_ENTER("InitCRL_Entry");
-
-    XMEMCPY(crle->issuerHash, dcrl->issuerHash, CRL_DIGEST_SIZE);
-    /* XMEMCPY(crle->crlHash, dcrl->crlHash, CRL_DIGEST_SIZE);
-     *   copy the hash here if needed for optimized comparisons */
-    XMEMCPY(crle->lastDate, dcrl->lastDate, MAX_DATE_SIZE);
-    XMEMCPY(crle->nextDate, dcrl->nextDate, MAX_DATE_SIZE);
-    crle->lastDateFormat = dcrl->lastDateFormat;
-    crle->nextDateFormat = dcrl->nextDateFormat;
-
-    crle->certs = dcrl->certs;   /* take ownsership */
-    dcrl->certs = NULL;
-    crle->totalCerts = dcrl->totalCerts;
-
-    return 0;
-}
-
-
-/* Free all CRL Entry resources */
-static void FreeCRL_Entry(CRL_Entry* crle)
-{
-    RevokedCert* tmp = crle->certs; 
-
-    WOLFSSL_ENTER("FreeCRL_Entry");
-
-    while(tmp) {
-        RevokedCert* next = tmp->next;
-        XFREE(tmp, NULL, DYNAMIC_TYPE_REVOKED);
-        tmp = next;
-    }
-}
-
-
-
-/* Free all CRL resources */
-void FreeCRL(WOLFSSL_CRL* crl, int dynamic)
-{
-    CRL_Entry* tmp = crl->crlList;
-
-    WOLFSSL_ENTER("FreeCRL");
-
-    if (crl->monitors[0].path)
-        XFREE(crl->monitors[0].path, NULL, DYNAMIC_TYPE_CRL_MONITOR);
-
-    if (crl->monitors[1].path)
-        XFREE(crl->monitors[1].path, NULL, DYNAMIC_TYPE_CRL_MONITOR);
-
-    while(tmp) {
-        CRL_Entry* next = tmp->next;
-        FreeCRL_Entry(tmp);
-        XFREE(tmp, NULL, DYNAMIC_TYPE_CRL_ENTRY);
-        tmp = next;
-    }	
-
-#ifdef HAVE_CRL_MONITOR
-    if (crl->tid != 0) {
-        WOLFSSL_MSG("stopping monitor thread");
-        if (StopMonitor(crl->mfd) == 0)
-            pthread_join(crl->tid, NULL);
-        else {
-            WOLFSSL_MSG("stop monitor failed, cancel instead");
-            pthread_cancel(crl->tid);
-        }
-    }
-#endif
-    FreeMutex(&crl->crlLock);
-    if (dynamic)   /* free self */
-        XFREE(crl, NULL, DYNAMIC_TYPE_CRL);
-}
-
-
-/* Is the cert ok with CRL, return 0 on success */
-int CheckCertCRL(WOLFSSL_CRL* crl, DecodedCert* cert)
-{
-    CRL_Entry* crle;
-    int        foundEntry = 0;
-    int        ret = 0;
-
-    WOLFSSL_ENTER("CheckCertCRL");
-
-    if (LockMutex(&crl->crlLock) != 0) {
-        WOLFSSL_MSG("LockMutex failed");
-        return BAD_MUTEX_E;
-    }
-
-    crle = crl->crlList;
-
-    while (crle) {
-        if (XMEMCMP(crle->issuerHash, cert->issuerHash, CRL_DIGEST_SIZE) == 0) {
-            WOLFSSL_MSG("Found CRL Entry on list");
-            WOLFSSL_MSG("Checking next date validity");
-
-            if (!ValidateDate(crle->nextDate, crle->nextDateFormat, AFTER)) {
-                WOLFSSL_MSG("CRL next date is no longer valid");
-                ret = ASN_AFTER_DATE_E;
-            }
-            else
-                foundEntry = 1;
-            break;
-        }
-        crle = crle->next;
-    }
-
-    if (foundEntry) {
-        RevokedCert* rc = crle->certs;
-
-        while (rc) {
-            if (XMEMCMP(rc->serialNumber, cert->serial, rc->serialSz) == 0) {
-                WOLFSSL_MSG("Cert revoked");
-                ret = CRL_CERT_REVOKED;
-                break;
-            }
-            rc = rc->next;	
-        }
-    }
-
-    UnLockMutex(&crl->crlLock);
-
-    if (foundEntry == 0) {
-        WOLFSSL_MSG("Couldn't find CRL for status check");
-        ret = CRL_MISSING;
-        if (crl->cm->cbMissingCRL) {
-            char url[256];
-
-            WOLFSSL_MSG("Issuing missing CRL callback");
-            url[0] = '\0';
-            if (cert->extCrlInfoSz < (int)sizeof(url) -1 ) {
-                XMEMCPY(url, cert->extCrlInfo, cert->extCrlInfoSz);
-                url[cert->extCrlInfoSz] = '\0';
-            }
-            else  {
-                WOLFSSL_MSG("CRL url too long");
-            }
-            crl->cm->cbMissingCRL(url);
-        }
-    }
-
-
-    return ret;	
-}
-
-
-/* Add Decoded CRL, 0 on success */
-static int AddCRL(WOLFSSL_CRL* crl, DecodedCRL* dcrl)
-{
-    CRL_Entry* crle;
-
-    WOLFSSL_ENTER("AddCRL");
-
-    crle = (CRL_Entry*)XMALLOC(sizeof(CRL_Entry), NULL, DYNAMIC_TYPE_CRL_ENTRY);
-    if (crle == NULL) {
-        WOLFSSL_MSG("alloc CRL Entry failed");
-        return -1;
-    }
-
-    if (InitCRL_Entry(crle, dcrl) < 0) {
-        WOLFSSL_MSG("Init CRL Entry failed");
-        XFREE(crle, NULL, DYNAMIC_TYPE_CRL_ENTRY);
-        return -1;
-    }
-
-    if (LockMutex(&crl->crlLock) != 0) {
-        WOLFSSL_MSG("LockMutex failed");
-        FreeCRL_Entry(crle);
-        XFREE(crle, NULL, DYNAMIC_TYPE_CRL_ENTRY);
-        return BAD_MUTEX_E;
-    }
-    crle->next = crl->crlList;
-    crl->crlList = crle;
-    UnLockMutex(&crl->crlLock);
-
-    return 0;
-}
-
-
-/* Load CRL File of type, SSL_SUCCESS on ok */
-int BufferLoadCRL(WOLFSSL_CRL* crl, const byte* buff, long sz, int type)
-{
-    int          ret = SSL_SUCCESS;
-    const byte*  myBuffer = buff;    /* if DER ok, otherwise switch */
-    buffer       der;
-#ifdef WOLFSSL_SMALL_STACK
-    DecodedCRL*  dcrl;
-#else
-    DecodedCRL   dcrl[1];
-#endif
-
-    der.buffer = NULL;
-
-    WOLFSSL_ENTER("BufferLoadCRL");
-
-    if (crl == NULL || buff == NULL || sz == 0)
-        return BAD_FUNC_ARG;
-
-    if (type == SSL_FILETYPE_PEM) {
-        int eccKey = 0;   /* not used */
-        EncryptedInfo info;
-        info.ctx = NULL;
-
-        ret = PemToDer(buff, sz, CRL_TYPE, &der, NULL, &info, &eccKey);
-        if (ret == 0) {
-            myBuffer = der.buffer;
-            sz = der.length;
-        }
-        else {
-            WOLFSSL_MSG("Pem to Der failed");
-            return -1;
-        }
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    dcrl = (DecodedCRL*)XMALLOC(sizeof(DecodedCRL), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (dcrl == NULL) {
-        if (der.buffer)
-            XFREE(der.buffer, NULL, DYNAMIC_TYPE_CRL);
-
-        return MEMORY_E;
-    }
-#endif
-
-    InitDecodedCRL(dcrl);
-    ret = ParseCRL(dcrl, myBuffer, (word32)sz, crl->cm);
-    if (ret != 0) {
-        WOLFSSL_MSG("ParseCRL error");
-    }
-    else {
-        ret = AddCRL(crl, dcrl);
-        if (ret != 0) {
-            WOLFSSL_MSG("AddCRL error");
-        }
-    }
-
-    FreeDecodedCRL(dcrl);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(dcrl, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    if (der.buffer)
-        XFREE(der.buffer, NULL, DYNAMIC_TYPE_CRL);
-
-    return ret ? ret : SSL_SUCCESS; /* convert 0 to SSL_SUCCESS */
-}
-
-
-#ifdef HAVE_CRL_MONITOR
-
-
-/* read in new CRL entries and save new list */
-static int SwapLists(WOLFSSL_CRL* crl)
-{
-    int        ret;
-    CRL_Entry* newList;
-#ifdef WOLFSSL_SMALL_STACK
-    WOLFSSL_CRL* tmp;    
-#else
-    WOLFSSL_CRL tmp[1];
-#endif
-    
-#ifdef WOLFSSL_SMALL_STACK
-    tmp = (WOLFSSL_CRL*)XMALLOC(sizeof(WOLFSSL_CRL), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (tmp == NULL)
-        return MEMORY_E;
-#endif   
-
-    if (InitCRL(tmp, crl->cm) < 0) {
-        WOLFSSL_MSG("Init tmp CRL failed");
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return -1;
-    }
-
-    if (crl->monitors[0].path) {
-        ret = LoadCRL(tmp, crl->monitors[0].path, SSL_FILETYPE_PEM, 0);
-        if (ret != SSL_SUCCESS) {
-            WOLFSSL_MSG("PEM LoadCRL on dir change failed");
-            FreeCRL(tmp, 0);
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return -1;
-        }
-    }
-
-    if (crl->monitors[1].path) {
-        ret = LoadCRL(tmp, crl->monitors[1].path, SSL_FILETYPE_ASN1, 0);
-        if (ret != SSL_SUCCESS) {
-            WOLFSSL_MSG("DER LoadCRL on dir change failed");
-            FreeCRL(tmp, 0);
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return -1;
-        }
-    }
-
-    if (LockMutex(&crl->crlLock) != 0) {
-        WOLFSSL_MSG("LockMutex failed");
-        FreeCRL(tmp, 0);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return -1;
-    }
-
-    newList = tmp->crlList;
-
-    /* swap lists */
-    tmp->crlList  = crl->crlList;
-    crl->crlList = newList;
-
-    UnLockMutex(&crl->crlLock);
-
-    FreeCRL(tmp, 0);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return 0;
-}
-
-
-#if (defined(__MACH__) || defined(__FreeBSD__))
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#ifdef __MACH__
-    #define XEVENT_MODE O_EVTONLY
-#elif defined(__FreeBSD__)
-    #define XEVENT_MODE EVFILT_VNODE
-#endif
-
-
-/* we need a unique kqueue user filter fd for crl in case user is doing custom
- * events too */
-#ifndef CRL_CUSTOM_FD
-    #define CRL_CUSTOM_FD 123456
-#endif
-
-
-/* shutdown monitor thread, 0 on success */
-static int StopMonitor(int mfd)
-{
-    struct kevent change;
-
-    /* trigger custom shutdown */
-    EV_SET(&change, CRL_CUSTOM_FD, EVFILT_USER, 0, NOTE_TRIGGER, 0, NULL);
-    if (kevent(mfd, &change, 1, NULL, 0, NULL) < 0) {
-        WOLFSSL_MSG("kevent trigger customer event failed");
-        return -1;
-    }
-
-    return 0;
-}
-
-
-/* OS X  monitoring */
-static void* DoMonitor(void* arg)
-{
-    int fPEM, fDER;
-    struct kevent change;
-
-    WOLFSSL_CRL* crl = (WOLFSSL_CRL*)arg;
-
-    WOLFSSL_ENTER("DoMonitor");
-
-    crl->mfd = kqueue();
-    if (crl->mfd == -1) {
-        WOLFSSL_MSG("kqueue failed");
-        return NULL;
-    }
-
-    /* listen for custom shutdown event */
-    EV_SET(&change, CRL_CUSTOM_FD, EVFILT_USER, EV_ADD, 0, 0, NULL);
-    if (kevent(crl->mfd, &change, 1, NULL, 0, NULL) < 0) {
-        WOLFSSL_MSG("kevent monitor customer event failed");
-        close(crl->mfd);
-        return NULL;
-    }
-
-    fPEM = -1;
-    fDER = -1;
-
-    if (crl->monitors[0].path) {
-        fPEM = open(crl->monitors[0].path, XEVENT_MODE);
-        if (fPEM == -1) {
-            WOLFSSL_MSG("PEM event dir open failed");
-            close(crl->mfd);
-            return NULL;
-        }
-    }
-
-    if (crl->monitors[1].path) {
-        fDER = open(crl->monitors[1].path, XEVENT_MODE);
-        if (fDER == -1) {
-            WOLFSSL_MSG("DER event dir open failed");
-            close(crl->mfd);
-            return NULL;
-        }
-    }
-
-    if (fPEM != -1)
-        EV_SET(&change, fPEM, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_ONESHOT,
-                NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_ATTRIB, 0, 0);
-
-    if (fDER != -1)
-        EV_SET(&change, fDER, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_ONESHOT,
-                NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_ATTRIB, 0, 0);
-
-    for (;;) {
-        struct kevent event;
-        int           numEvents = kevent(crl->mfd, &change, 1, &event, 1, NULL);
-       
-        WOLFSSL_MSG("Got kevent");
-
-        if (numEvents == -1) {
-            WOLFSSL_MSG("kevent problem, continue");
-            continue;
-        }
-
-        if (event.filter == EVFILT_USER) {
-            WOLFSSL_MSG("Got user shutdown event, breaking out");
-            break;
-        }
-
-        if (SwapLists(crl) < 0) {
-            WOLFSSL_MSG("SwapLists problem, continue");
-        }
-    }
-
-    if (fPEM != -1)
-        close(fPEM);
-    if (fDER != -1)
-        close(fDER);
-
-    close(crl->mfd);
-
-    return NULL;
-}
-
-
-#elif defined(__linux__)
-
-#include 
-#include 
-#include 
-#include 
-
-
-#ifndef max
-    static INLINE int max(int a, int b)
-    {
-        return a > b ? a : b;
-    }
-#endif /* max */
-
-
-/* shutdown monitor thread, 0 on success */
-static int StopMonitor(int mfd)
-{
-    word64 w64 = 1;
-
-    /* write to our custom event */
-    if (write(mfd, &w64, sizeof(w64)) < 0) {
-        WOLFSSL_MSG("StopMonitor write failed");
-        return -1;
-    }
-
-    return 0;
-}
-
-
-/* linux monitoring */
-static void* DoMonitor(void* arg)
-{
-    int         notifyFd;
-    int         wd  = -1;
-    WOLFSSL_CRL* crl = (WOLFSSL_CRL*)arg;
-#ifdef WOLFSSL_SMALL_STACK
-    char*       buff;
-#else
-    char        buff[8192];
-#endif
-
-    WOLFSSL_ENTER("DoMonitor");
-
-    crl->mfd = eventfd(0, 0);  /* our custom shutdown event */
-    if (crl->mfd < 0) {
-        WOLFSSL_MSG("eventfd failed");
-        return NULL;
-    }
-
-    notifyFd = inotify_init();
-    if (notifyFd < 0) {
-        WOLFSSL_MSG("inotify failed");
-        close(crl->mfd);
-        return NULL;
-    }
-
-    if (crl->monitors[0].path) {
-        wd = inotify_add_watch(notifyFd, crl->monitors[0].path, IN_CLOSE_WRITE |
-                                                                IN_DELETE);
-        if (wd < 0) {
-            WOLFSSL_MSG("PEM notify add watch failed");
-            close(crl->mfd);
-            close(notifyFd);
-            return NULL;
-        }
-    }
-
-    if (crl->monitors[1].path) {
-        wd = inotify_add_watch(notifyFd, crl->monitors[1].path, IN_CLOSE_WRITE |
-                                                                IN_DELETE);
-        if (wd < 0) {
-            WOLFSSL_MSG("DER notify add watch failed");
-            close(crl->mfd);
-            close(notifyFd);
-            return NULL;
-        }
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    buff = (char*)XMALLOC(8192, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (buff == NULL)
-        return NULL;
-#endif
-
-    for (;;) {
-        fd_set readfds;
-        int    result;
-        int    length;
-
-        FD_ZERO(&readfds);
-        FD_SET(notifyFd, &readfds);
-        FD_SET(crl->mfd, &readfds);
-
-        result = select(max(notifyFd, crl->mfd) + 1, &readfds, NULL, NULL,NULL);
-       
-        WOLFSSL_MSG("Got notify event");
-
-        if (result < 0) {
-            WOLFSSL_MSG("select problem, continue");
-            continue;
-        }
-
-        if (FD_ISSET(crl->mfd, &readfds)) {
-            WOLFSSL_MSG("got custom shutdown event, breaking out");
-            break;
-        }
-
-        length = read(notifyFd, buff, 8192);
-        if (length < 0) {
-            WOLFSSL_MSG("notify read problem, continue");
-            continue;
-        } 
-
-        if (SwapLists(crl) < 0) {
-            WOLFSSL_MSG("SwapLists problem, continue");
-        }
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(buff, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    if (wd > 0)
-        inotify_rm_watch(notifyFd, wd);
-    close(crl->mfd);
-    close(notifyFd);
-
-    return NULL;
-}
-
-
-#else
-
-#error "CRL monitor only currently supported on linux or mach"
-
-#endif /* MACH or linux */
-
-
-/* Start Monitoring the CRL path(s) in a thread */
-static int StartMonitorCRL(WOLFSSL_CRL* crl)
-{
-    pthread_attr_t attr;
-
-    WOLFSSL_ENTER("StartMonitorCRL");
-
-    if (crl == NULL) 
-        return BAD_FUNC_ARG;
-
-    if (crl->tid != 0) {
-        WOLFSSL_MSG("Monitor thread already running");
-        return MONITOR_RUNNING_E;
-    }
-
-    pthread_attr_init(&attr);
-
-    if (pthread_create(&crl->tid, &attr, DoMonitor, crl) != 0) {
-        WOLFSSL_MSG("Thread creation error");
-        return THREAD_CREATE_E;
-    }
-
-    return SSL_SUCCESS;
-}
-
-
-#else /* HAVE_CRL_MONITOR */
-
-static int StartMonitorCRL(WOLFSSL_CRL* crl)
-{
-    (void)crl;
-
-    WOLFSSL_ENTER("StartMonitorCRL");
-    WOLFSSL_MSG("Not compiled in");
-
-    return NOT_COMPILED_IN;
-}
-
-#endif  /* HAVE_CRL_MONITOR */
-
-
-/* Load CRL path files of type, SSL_SUCCESS on ok */ 
-int LoadCRL(WOLFSSL_CRL* crl, const char* path, int type, int monitor)
-{
-    struct dirent* entry;
-    DIR*           dir;
-    int            ret = SSL_SUCCESS;
-#ifdef WOLFSSL_SMALL_STACK
-    char*          name;
-#else
-    char           name[MAX_FILENAME_SZ];
-#endif
-
-    WOLFSSL_ENTER("LoadCRL");
-    if (crl == NULL)
-        return BAD_FUNC_ARG;
-
-    dir = opendir(path);
-    if (dir == NULL) {
-        WOLFSSL_MSG("opendir path crl load failed");
-        return BAD_PATH_ERROR;
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    name = (char*)XMALLOC(MAX_FILENAME_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (name == NULL)
-        return MEMORY_E;
-#endif
-
-    while ( (entry = readdir(dir)) != NULL) {
-        struct stat s;
-
-        XMEMSET(name, 0, MAX_FILENAME_SZ);
-        XSTRNCPY(name, path, MAX_FILENAME_SZ/2 - 2);
-        XSTRNCAT(name, "/", 1);
-        XSTRNCAT(name, entry->d_name, MAX_FILENAME_SZ/2);
-
-        if (stat(name, &s) != 0) {
-            WOLFSSL_MSG("stat on name failed");
-            continue;
-        }
-        if (s.st_mode & S_IFREG) {
-
-            if (type == SSL_FILETYPE_PEM) {
-                if (strstr(entry->d_name, ".pem") == NULL) {
-                    WOLFSSL_MSG("not .pem file, skipping");
-                    continue;
-                }
-            }
-            else {
-                if (strstr(entry->d_name, ".der") == NULL &&
-                    strstr(entry->d_name, ".crl") == NULL) {
-
-                    WOLFSSL_MSG("not .der or .crl file, skipping");
-                    continue;
-                }
-            }
-
-            if (ProcessFile(NULL, name, type, CRL_TYPE, NULL, 0, crl)
-                                                               != SSL_SUCCESS) {
-                WOLFSSL_MSG("CRL file load failed, continuing");
-            }
-        }
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(name, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    if (monitor & WOLFSSL_CRL_MONITOR) {
-        WOLFSSL_MSG("monitor path requested");
-
-        if (type == SSL_FILETYPE_PEM) {
-            crl->monitors[0].path = strdup(path);
-            crl->monitors[0].type = SSL_FILETYPE_PEM;
-            if (crl->monitors[0].path == NULL)
-                ret = MEMORY_E;
-        } else {
-            crl->monitors[1].path = strdup(path);
-            crl->monitors[1].type = SSL_FILETYPE_ASN1;
-            if (crl->monitors[1].path == NULL)
-                ret = MEMORY_E;
-        }
-      
-        if (monitor & WOLFSSL_CRL_START_MON) {
-            WOLFSSL_MSG("start monitoring requested");
-    
-            ret = StartMonitorCRL(crl);
-       } 
-    }
-    
-    closedir(dir);
-
-    return ret;
-}
-
-#endif /* HAVE_CRL */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/src/include.am b/FreeRTOS-Plus/Source/WolfSSL/src/include.am
deleted file mode 100755
index 80ed4de..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/src/include.am
+++ /dev/null
@@ -1,222 +0,0 @@
-# vim:ft=automake
-# included from Top Level Makefile.am
-# All paths should be given relative to the root
-
-lib_LTLIBRARIES+= src/libwolfssl.la
-src_libwolfssl_la_SOURCES =
-
-src_libwolfssl_la_LDFLAGS = ${AM_LDFLAGS} -no-undefined -version-info ${WOLFSSL_LIBRARY_VERSION}
-src_libwolfssl_la_LIBADD = $(LIBM)
-src_libwolfssl_la_CFLAGS = -DBUILDING_WOLFSSL $(AM_CFLAGS)
-src_libwolfssl_la_CPPFLAGS = -DBUILDING_WOLFSSL $(AM_CPPFLAGS)
-
-# fips first  file
-if BUILD_FIPS
-src_libwolfssl_la_SOURCES += ctaocrypt/src/wolfcrypt_first.c
-
-src_libwolfssl_la_SOURCES += \
-               ctaocrypt/src/hmac.c \
-               ctaocrypt/src/random.c \
-               ctaocrypt/src/sha256.c
-
-if BUILD_RSA
-src_libwolfssl_la_SOURCES += ctaocrypt/src/rsa.c
-endif
-
-if BUILD_AES
-src_libwolfssl_la_SOURCES += ctaocrypt/src/aes.c
-endif
-
-if BUILD_DES3
-src_libwolfssl_la_SOURCES += ctaocrypt/src/des3.c
-endif
-
-if BUILD_SHA
-src_libwolfssl_la_SOURCES += ctaocrypt/src/sha.c
-endif
-
-if BUILD_SHA512
-src_libwolfssl_la_SOURCES += ctaocrypt/src/sha512.c
-endif
-
-src_libwolfssl_la_SOURCES += ctaocrypt/src/fips.c
-src_libwolfssl_la_SOURCES += ctaocrypt/src/fips_test.c
-
-# fips last file
-src_libwolfssl_la_SOURCES += ctaocrypt/src/wolfcrypt_last.c
-endif
-
-src_libwolfssl_la_SOURCES += \
-               wolfcrypt/src/hmac.c \
-               wolfcrypt/src/random.c \
-               wolfcrypt/src/sha256.c \
-               wolfcrypt/src/hash.c
-
-if BUILD_RSA
-src_libwolfssl_la_SOURCES += wolfcrypt/src/rsa.c
-endif
-
-if BUILD_AES
-src_libwolfssl_la_SOURCES += wolfcrypt/src/aes.c
-endif
-
-if BUILD_DES3
-src_libwolfssl_la_SOURCES += wolfcrypt/src/des3.c
-endif
-
-if BUILD_SHA
-src_libwolfssl_la_SOURCES += wolfcrypt/src/sha.c
-endif
-
-if BUILD_SHA512
-src_libwolfssl_la_SOURCES += wolfcrypt/src/sha512.c
-endif
-
-src_libwolfssl_la_SOURCES += \
-               wolfcrypt/src/logging.c \
-               wolfcrypt/src/wc_port.c \
-               wolfcrypt/src/error.c
-
-if BUILD_MEMORY
-src_libwolfssl_la_SOURCES += wolfcrypt/src/memory.c
-endif
-
-if BUILD_DH
-src_libwolfssl_la_SOURCES += wolfcrypt/src/dh.c
-endif
-
-if BUILD_ASN
-src_libwolfssl_la_SOURCES += wolfcrypt/src/asn.c
-endif
-
-if BUILD_CODING
-src_libwolfssl_la_SOURCES += wolfcrypt/src/coding.c
-endif
-
-if BUILD_POLY1305
-src_libwolfssl_la_SOURCES += wolfcrypt/src/poly1305.c
-endif
-
-if BUILD_RC4
-src_libwolfssl_la_SOURCES += wolfcrypt/src/arc4.c
-endif
-
-if BUILD_MD4
-src_libwolfssl_la_SOURCES += wolfcrypt/src/md4.c
-endif
-
-if BUILD_MD5
-src_libwolfssl_la_SOURCES += wolfcrypt/src/md5.c
-endif
-
-if BUILD_PWDBASED
-src_libwolfssl_la_SOURCES += wolfcrypt/src/pwdbased.c
-endif
-
-if BUILD_DSA
-src_libwolfssl_la_SOURCES += wolfcrypt/src/dsa.c
-endif
-
-if BUILD_AESNI
-src_libwolfssl_la_SOURCES += wolfcrypt/src/aes_asm.s
-endif
-
-if BUILD_CAMELLIA
-src_libwolfssl_la_SOURCES += wolfcrypt/src/camellia.c
-endif
-
-if BUILD_MD2
-src_libwolfssl_la_SOURCES += wolfcrypt/src/md2.c
-endif
-
-if BUILD_RIPEMD
-src_libwolfssl_la_SOURCES += wolfcrypt/src/ripemd.c
-endif
-
-if BUILD_BLAKE2
-src_libwolfssl_la_SOURCES += wolfcrypt/src/blake2b.c
-endif
-
-if BUILD_HC128
-src_libwolfssl_la_SOURCES += wolfcrypt/src/hc128.c
-endif
-
-if BUILD_RABBIT
-src_libwolfssl_la_SOURCES += wolfcrypt/src/rabbit.c
-endif
-
-if BUILD_CHACHA
-src_libwolfssl_la_SOURCES += wolfcrypt/src/chacha.c
-if BUILD_POLY1305
-src_libwolfssl_la_SOURCES += wolfcrypt/src/chacha20_poly1305.c
-endif
-endif
-
-if !BUILD_INLINE
-src_libwolfssl_la_SOURCES += wolfcrypt/src/misc.c
-endif
-
-if BUILD_FASTMATH
-src_libwolfssl_la_SOURCES += wolfcrypt/src/tfm.c
-endif
-
-if BUILD_SLOWMATH
-src_libwolfssl_la_SOURCES += wolfcrypt/src/integer.c
-endif
-
-if BUILD_ECC
-src_libwolfssl_la_SOURCES += wolfcrypt/src/ecc.c
-endif
-
-if BUILD_CURVE25519
-src_libwolfssl_la_SOURCES += wolfcrypt/src/curve25519.c
-endif
-
-if BUILD_ED25519
-src_libwolfssl_la_SOURCES += wolfcrypt/src/ed25519.c
-endif
-
-if BUILD_FEMATH
-if BUILD_CURVED25519_SMALL
-src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_low_mem.c
-else
-src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_operations.c
-endif
-endif
-
-if BUILD_GEMATH
-if BUILD_CURVED25519_SMALL
-src_libwolfssl_la_SOURCES += wolfcrypt/src/ge_low_mem.c
-else
-src_libwolfssl_la_SOURCES += wolfcrypt/src/ge_operations.c
-endif
-endif
-
-if BUILD_LIBZ
-src_libwolfssl_la_SOURCES += wolfcrypt/src/compress.c
-endif
-
-if BUILD_PKCS7
-src_libwolfssl_la_SOURCES += wolfcrypt/src/pkcs7.c
-endif
-
-# ssl files
-src_libwolfssl_la_SOURCES += \
-               src/internal.c \
-               src/io.c \
-               src/keys.c \
-               src/ssl.c \
-               src/tls.c
-
-if BUILD_OCSP
-src_libwolfssl_la_SOURCES += src/ocsp.c
-endif
-
-if BUILD_CRL
-src_libwolfssl_la_SOURCES += src/crl.c
-endif
-
-if BUILD_SNIFFER
-src_libwolfssl_la_SOURCES += src/sniffer.c
-endif
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/src/internal.c b/FreeRTOS-Plus/Source/WolfSSL/src/internal.c
deleted file mode 100755
index 75d85b1..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/src/internal.c
+++ /dev/null
@@ -1,14388 +0,0 @@
-/* internal.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-#ifdef HAVE_LIBZ
-    #include "zlib.h"
-#endif
-
-#ifdef HAVE_NTRU
-    #include "ntru_crypto.h"
-#endif
-
-#if defined(DEBUG_WOLFSSL) || defined(SHOW_SECRETS) || defined(CHACHA_AEAD_TEST)
-    #ifdef FREESCALE_MQX
-        #include 
-    #else
-        #include 
-    #endif
-#endif
-
-#ifdef __sun
-    #include 
-#endif
-
-#ifndef TRUE
-    #define TRUE  1
-#endif
-#ifndef FALSE
-    #define FALSE 0
-#endif
-
-#ifdef _MSC_VER
-    /* disable for while(0) cases at the .c level for now */
-    #pragma warning(disable:4127)
-#endif
-
-#if defined(WOLFSSL_CALLBACKS) && !defined(LARGE_STATIC_BUFFERS)
-    #error \
-WOLFSSL_CALLBACKS needs LARGE_STATIC_BUFFERS, please add LARGE_STATIC_BUFFERS
-#endif
-
-#if defined(HAVE_SECURE_RENEGOTIATION) && defined(HAVE_RENEGOTIATION_INDICATION)
-    #error Cannot use both secure-renegotiation and renegotiation-indication
-#endif
-
-static int BuildMessage(WOLFSSL* ssl, byte* output, int outSz,
-                        const byte* input, int inSz, int type);
-
-#ifndef NO_WOLFSSL_CLIENT
-    static int DoHelloVerifyRequest(WOLFSSL* ssl, const byte* input, word32*,
-                                                                        word32);
-    static int DoServerHello(WOLFSSL* ssl, const byte* input, word32*, word32);
-    static int DoServerKeyExchange(WOLFSSL* ssl, const byte* input, word32*,
-                                                                        word32);
-    #ifndef NO_CERTS
-        static int DoCertificateRequest(WOLFSSL* ssl, const byte* input, word32*,
-                                                                        word32);
-    #endif
-    #ifdef HAVE_SESSION_TICKET
-        static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32*,
-                                                                        word32);
-    #endif
-#endif
-
-
-#ifndef NO_WOLFSSL_SERVER
-    static int DoClientHello(WOLFSSL* ssl, const byte* input, word32*, word32);
-    static int DoClientKeyExchange(WOLFSSL* ssl, byte* input, word32*, word32);
-    #if !defined(NO_RSA) || defined(HAVE_ECC)
-        static int DoCertificateVerify(WOLFSSL* ssl, byte*, word32*, word32);
-    #endif
-#endif
-
-
-#ifdef WOLFSSL_DTLS
-    static INLINE int DtlsCheckWindow(DtlsState* state);
-    static INLINE int DtlsUpdateWindow(DtlsState* state);
-#endif
-
-
-typedef enum {
-    doProcessInit = 0,
-#ifndef NO_WOLFSSL_SERVER
-    runProcessOldClientHello,
-#endif
-    getRecordLayerHeader,
-    getData,
-    runProcessingOneMessage
-} processReply;
-
-#ifndef NO_OLD_TLS
-static int SSL_hmac(WOLFSSL* ssl, byte* digest, const byte* in, word32 sz,
-                    int content, int verify);
-
-#endif
-
-#ifndef NO_CERTS
-static int BuildCertHashes(WOLFSSL* ssl, Hashes* hashes);
-#endif
-
-static void PickHashSigAlgo(WOLFSSL* ssl,
-                                const byte* hashSigAlgo, word32 hashSigAlgoSz);
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-
-int IsTLS(const WOLFSSL* ssl)
-{
-    if (ssl->version.major == SSLv3_MAJOR && ssl->version.minor >=TLSv1_MINOR)
-        return 1;
-
-    return 0;
-}
-
-
-int IsAtLeastTLSv1_2(const WOLFSSL* ssl)
-{
-    if (ssl->version.major == SSLv3_MAJOR && ssl->version.minor >=TLSv1_2_MINOR)
-        return 1;
-    if (ssl->version.major == DTLS_MAJOR && ssl->version.minor <= DTLSv1_2_MINOR)
-        return 1;
-
-    return 0;
-}
-
-
-#ifdef HAVE_NTRU
-
-static byte GetEntropy(ENTROPY_CMD cmd, byte* out)
-{
-    /* TODO: add locking? */
-    static RNG rng;
-
-    if (cmd == INIT)
-        return (wc_InitRng(&rng) == 0) ? 1 : 0;
-
-    if (out == NULL)
-        return 0;
-
-    if (cmd == GET_BYTE_OF_ENTROPY)
-        return (wc_RNG_GenerateBlock(&rng, out, 1) == 0) ? 1 : 0;
-
-    if (cmd == GET_NUM_BYTES_PER_BYTE_OF_ENTROPY) {
-        *out = 1;
-        return 1;
-    }
-
-    return 0;
-}
-
-#endif /* HAVE_NTRU */
-
-/* used by ssl.c too */
-void c32to24(word32 in, word24 out)
-{
-    out[0] = (in >> 16) & 0xff;
-    out[1] = (in >>  8) & 0xff;
-    out[2] =  in & 0xff;
-}
-
-
-#ifdef WOLFSSL_DTLS
-
-static INLINE void c32to48(word32 in, byte out[6])
-{
-    out[0] = 0;
-    out[1] = 0;
-    out[2] = (in >> 24) & 0xff;
-    out[3] = (in >> 16) & 0xff;
-    out[4] = (in >>  8) & 0xff;
-    out[5] =  in & 0xff;
-}
-
-#endif /* WOLFSSL_DTLS */
-
-
-/* convert 16 bit integer to opaque */
-static INLINE void c16toa(word16 u16, byte* c)
-{
-    c[0] = (u16 >> 8) & 0xff;
-    c[1] =  u16 & 0xff;
-}
-
-
-#if !defined(NO_OLD_TLS) || defined(HAVE_CHACHA) || defined(HAVE_AESCCM) \
-    || defined(HAVE_AESGCM)
-/* convert 32 bit integer to opaque */
-static INLINE void c32toa(word32 u32, byte* c)
-{
-    c[0] = (u32 >> 24) & 0xff;
-    c[1] = (u32 >> 16) & 0xff;
-    c[2] = (u32 >>  8) & 0xff;
-    c[3] =  u32 & 0xff;
-}
-#endif
-
-
-/* convert a 24 bit integer into a 32 bit one */
-static INLINE void c24to32(const word24 u24, word32* u32)
-{
-    *u32 = (u24[0] << 16) | (u24[1] << 8) | u24[2];
-}
-
-
-/* convert opaque to 16 bit integer */
-static INLINE void ato16(const byte* c, word16* u16)
-{
-    *u16 = (word16) ((c[0] << 8) | (c[1]));
-}
-
-
-#if defined(WOLFSSL_DTLS) || defined(HAVE_SESSION_TICKET)
-
-/* convert opaque to 32 bit integer */
-static INLINE void ato32(const byte* c, word32* u32)
-{
-    *u32 = (c[0] << 24) | (c[1] << 16) | (c[2] << 8) | c[3];
-}
-
-#endif /* WOLFSSL_DTLS */
-
-
-#ifdef HAVE_LIBZ
-
-    /* alloc user allocs to work with zlib */
-    static void* myAlloc(void* opaque, unsigned int item, unsigned int size)
-    {
-        (void)opaque;
-        return XMALLOC(item * size, opaque, DYNAMIC_TYPE_LIBZ);
-    }
-
-
-    static void myFree(void* opaque, void* memory)
-    {
-        (void)opaque;
-        XFREE(memory, opaque, DYNAMIC_TYPE_LIBZ);
-    }
-
-
-    /* init zlib comp/decomp streams, 0 on success */
-    static int InitStreams(WOLFSSL* ssl)
-    {
-        ssl->c_stream.zalloc = (alloc_func)myAlloc;
-        ssl->c_stream.zfree  = (free_func)myFree;
-        ssl->c_stream.opaque = (voidpf)ssl->heap;
-
-        if (deflateInit(&ssl->c_stream, Z_DEFAULT_COMPRESSION) != Z_OK)
-            return ZLIB_INIT_ERROR;
-
-        ssl->didStreamInit = 1;
-
-        ssl->d_stream.zalloc = (alloc_func)myAlloc;
-        ssl->d_stream.zfree  = (free_func)myFree;
-        ssl->d_stream.opaque = (voidpf)ssl->heap;
-
-        if (inflateInit(&ssl->d_stream) != Z_OK) return ZLIB_INIT_ERROR;
-
-        return 0;
-    }
-
-
-    static void FreeStreams(WOLFSSL* ssl)
-    {
-        if (ssl->didStreamInit) {
-            deflateEnd(&ssl->c_stream);
-            inflateEnd(&ssl->d_stream);
-        }
-    }
-
-
-    /* compress in to out, return out size or error */
-    static int myCompress(WOLFSSL* ssl, byte* in, int inSz, byte* out, int outSz)
-    {
-        int    err;
-        int    currTotal = (int)ssl->c_stream.total_out;
-
-        ssl->c_stream.next_in   = in;
-        ssl->c_stream.avail_in  = inSz;
-        ssl->c_stream.next_out  = out;
-        ssl->c_stream.avail_out = outSz;
-
-        err = deflate(&ssl->c_stream, Z_SYNC_FLUSH);
-        if (err != Z_OK && err != Z_STREAM_END) return ZLIB_COMPRESS_ERROR;
-
-        return (int)ssl->c_stream.total_out - currTotal;
-    }
-
-
-    /* decompress in to out, returnn out size or error */
-    static int myDeCompress(WOLFSSL* ssl, byte* in,int inSz, byte* out,int outSz)
-    {
-        int    err;
-        int    currTotal = (int)ssl->d_stream.total_out;
-
-        ssl->d_stream.next_in   = in;
-        ssl->d_stream.avail_in  = inSz;
-        ssl->d_stream.next_out  = out;
-        ssl->d_stream.avail_out = outSz;
-
-        err = inflate(&ssl->d_stream, Z_SYNC_FLUSH);
-        if (err != Z_OK && err != Z_STREAM_END) return ZLIB_DECOMPRESS_ERROR;
-
-        return (int)ssl->d_stream.total_out - currTotal;
-    }
-
-#endif /* HAVE_LIBZ */
-
-
-void InitSSL_Method(WOLFSSL_METHOD* method, ProtocolVersion pv)
-{
-    method->version    = pv;
-    method->side       = WOLFSSL_CLIENT_END;
-    method->downgrade  = 0;
-}
-
-
-/* Initialze SSL context, return 0 on success */
-int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method)
-{
-    XMEMSET(ctx, 0, sizeof(WOLFSSL_CTX));
-
-    ctx->method   = method;
-    ctx->refCount = 1;          /* so either CTX_free or SSL_free can release */
-    ctx->heap     = ctx;        /* defaults to self */
-    ctx->timeout  = WOLFSSL_SESSION_TIMEOUT;
-    ctx->minDowngrade = TLSv1_MINOR;     /* current default */
-
-    if (InitMutex(&ctx->countMutex) < 0) {
-        WOLFSSL_MSG("Mutex error on CTX init");
-        return BAD_MUTEX_E;
-    }
-
-#ifndef NO_DH
-    ctx->minDhKeySz = MIN_DHKEY_SZ;
-#endif
-
-#ifdef HAVE_ECC
-    ctx->eccTempKeySz = ECDHE_SIZE;
-#endif
-
-#ifndef WOLFSSL_USER_IO
-    ctx->CBIORecv = EmbedReceive;
-    ctx->CBIOSend = EmbedSend;
-    #ifdef WOLFSSL_DTLS
-        if (method->version.major == DTLS_MAJOR) {
-            ctx->CBIORecv   = EmbedReceiveFrom;
-            ctx->CBIOSend   = EmbedSendTo;
-            ctx->CBIOCookie = EmbedGenerateCookie;
-        }
-    #endif
-#endif /* WOLFSSL_USER_IO */
-
-#ifdef HAVE_NETX
-    ctx->CBIORecv = NetX_Receive;
-    ctx->CBIOSend = NetX_Send;
-#endif
-
-#ifdef HAVE_NTRU
-    if (method->side == WOLFSSL_CLIENT_END)
-        ctx->haveNTRU = 1;           /* always on cliet side */
-                                     /* server can turn on by loading key */
-#endif
-#ifdef HAVE_ECC
-    if (method->side == WOLFSSL_CLIENT_END) {
-        ctx->haveECDSAsig  = 1;        /* always on cliet side */
-        ctx->haveStaticECC = 1;        /* server can turn on by loading key */
-    }
-#endif
-
-#ifdef HAVE_CAVIUM
-    ctx->devId = NO_CAVIUM_DEVICE;
-#endif
-
-#ifndef NO_CERTS
-    ctx->cm = wolfSSL_CertManagerNew();
-    if (ctx->cm == NULL) {
-        WOLFSSL_MSG("Bad Cert Manager New");
-        return BAD_CERT_MANAGER_ERROR;
-    }
-#endif
-
-#if defined(HAVE_SESSION_TICKET) && !defined(NO_WOLFSSL_SERVER)
-    ctx->ticketHint = SESSION_TICKET_HINT_DEFAULT;
-#endif
-
-    return 0;
-}
-
-
-/* In case contexts are held in array and don't want to free actual ctx */
-void SSL_CtxResourceFree(WOLFSSL_CTX* ctx)
-{
-    XFREE(ctx->method, ctx->heap, DYNAMIC_TYPE_METHOD);
-    if (ctx->suites)
-        XFREE(ctx->suites, ctx->heap, DYNAMIC_TYPE_SUITES);
-
-#ifndef NO_DH
-    XFREE(ctx->serverDH_G.buffer, ctx->heap, DYNAMIC_TYPE_DH);
-    XFREE(ctx->serverDH_P.buffer, ctx->heap, DYNAMIC_TYPE_DH);
-#endif
-#ifndef NO_CERTS
-    XFREE(ctx->privateKey.buffer, ctx->heap, DYNAMIC_TYPE_KEY);
-    XFREE(ctx->certificate.buffer, ctx->heap, DYNAMIC_TYPE_CERT);
-    XFREE(ctx->certChain.buffer, ctx->heap, DYNAMIC_TYPE_CERT);
-    wolfSSL_CertManagerFree(ctx->cm);
-#endif
-#ifdef HAVE_TLS_EXTENSIONS
-    TLSX_FreeAll(ctx->extensions);
-#endif
-}
-
-
-void FreeSSL_Ctx(WOLFSSL_CTX* ctx)
-{
-    int doFree = 0;
-
-    if (LockMutex(&ctx->countMutex) != 0) {
-        WOLFSSL_MSG("Couldn't lock count mutex");
-        return;
-    }
-    ctx->refCount--;
-    if (ctx->refCount == 0)
-        doFree = 1;
-    UnLockMutex(&ctx->countMutex);
-
-    if (doFree) {
-        WOLFSSL_MSG("CTX ref count down to 0, doing full free");
-        SSL_CtxResourceFree(ctx);
-        FreeMutex(&ctx->countMutex);
-        XFREE(ctx, ctx->heap, DYNAMIC_TYPE_CTX);
-    }
-    else {
-        (void)ctx;
-        WOLFSSL_MSG("CTX ref count not 0 yet, no free");
-    }
-}
-
-
-/* Set cipher pointers to null */
-void InitCiphers(WOLFSSL* ssl)
-{
-#ifdef BUILD_ARC4
-    ssl->encrypt.arc4 = NULL;
-    ssl->decrypt.arc4 = NULL;
-#endif
-#ifdef BUILD_DES3
-    ssl->encrypt.des3 = NULL;
-    ssl->decrypt.des3 = NULL;
-#endif
-#ifdef BUILD_AES
-    ssl->encrypt.aes = NULL;
-    ssl->decrypt.aes = NULL;
-#endif
-#ifdef HAVE_CAMELLIA
-    ssl->encrypt.cam = NULL;
-    ssl->decrypt.cam = NULL;
-#endif
-#ifdef HAVE_HC128
-    ssl->encrypt.hc128 = NULL;
-    ssl->decrypt.hc128 = NULL;
-#endif
-#ifdef BUILD_RABBIT
-    ssl->encrypt.rabbit = NULL;
-    ssl->decrypt.rabbit = NULL;
-#endif
-#ifdef HAVE_CHACHA
-    ssl->encrypt.chacha = NULL;
-    ssl->decrypt.chacha = NULL;
-#endif
-#ifdef HAVE_POLY1305
-    ssl->auth.poly1305 = NULL;
-#endif
-    ssl->encrypt.setup = 0;
-    ssl->decrypt.setup = 0;
-#ifdef HAVE_ONE_TIME_AUTH
-    ssl->auth.setup    = 0;
-#endif
-}
-
-
-/* Free ciphers */
-void FreeCiphers(WOLFSSL* ssl)
-{
-    (void)ssl;
-#ifdef BUILD_ARC4
-    #ifdef HAVE_CAVIUM
-    if (ssl->devId != NO_CAVIUM_DEVICE) {
-        wc_Arc4FreeCavium(ssl->encrypt.arc4);
-        wc_Arc4FreeCavium(ssl->decrypt.arc4);
-    }
-    #endif
-    XFREE(ssl->encrypt.arc4, ssl->heap, DYNAMIC_TYPE_CIPHER);
-    XFREE(ssl->decrypt.arc4, ssl->heap, DYNAMIC_TYPE_CIPHER);
-#endif
-#ifdef BUILD_DES3
-    #ifdef HAVE_CAVIUM
-    if (ssl->devId != NO_CAVIUM_DEVICE) {
-        wc_Des3_FreeCavium(ssl->encrypt.des3);
-        wc_Des3_FreeCavium(ssl->decrypt.des3);
-    }
-    #endif
-    XFREE(ssl->encrypt.des3, ssl->heap, DYNAMIC_TYPE_CIPHER);
-    XFREE(ssl->decrypt.des3, ssl->heap, DYNAMIC_TYPE_CIPHER);
-#endif
-#ifdef BUILD_AES
-    #ifdef HAVE_CAVIUM
-    if (ssl->devId != NO_CAVIUM_DEVICE) {
-        wc_AesFreeCavium(ssl->encrypt.aes);
-        wc_AesFreeCavium(ssl->decrypt.aes);
-    }
-    #endif
-    XFREE(ssl->encrypt.aes, ssl->heap, DYNAMIC_TYPE_CIPHER);
-    XFREE(ssl->decrypt.aes, ssl->heap, DYNAMIC_TYPE_CIPHER);
-#endif
-#ifdef HAVE_CAMELLIA
-    XFREE(ssl->encrypt.cam, ssl->heap, DYNAMIC_TYPE_CIPHER);
-    XFREE(ssl->decrypt.cam, ssl->heap, DYNAMIC_TYPE_CIPHER);
-#endif
-#ifdef HAVE_HC128
-    XFREE(ssl->encrypt.hc128, ssl->heap, DYNAMIC_TYPE_CIPHER);
-    XFREE(ssl->decrypt.hc128, ssl->heap, DYNAMIC_TYPE_CIPHER);
-#endif
-#ifdef BUILD_RABBIT
-    XFREE(ssl->encrypt.rabbit, ssl->heap, DYNAMIC_TYPE_CIPHER);
-    XFREE(ssl->decrypt.rabbit, ssl->heap, DYNAMIC_TYPE_CIPHER);
-#endif
-#ifdef HAVE_CHACHA
-    XFREE(ssl->encrypt.chacha, ssl->heap, DYNAMIC_TYPE_CIPHER);
-    XFREE(ssl->decrypt.chacha, ssl->heap, DYNAMIC_TYPE_CIPHER);
-#endif
-#ifdef HAVE_POLY1305
-    XFREE(ssl->auth.poly1305, ssl->heap, DYNAMIC_TYPE_CIPHER);
-#endif
-}
-
-
-void InitCipherSpecs(CipherSpecs* cs)
-{
-    cs->bulk_cipher_algorithm = INVALID_BYTE;
-    cs->cipher_type           = INVALID_BYTE;
-    cs->mac_algorithm         = INVALID_BYTE;
-    cs->kea                   = INVALID_BYTE;
-    cs->sig_algo              = INVALID_BYTE;
-
-    cs->hash_size   = 0;
-    cs->static_ecdh = 0;
-    cs->key_size    = 0;
-    cs->iv_size     = 0;
-    cs->block_size  = 0;
-}
-
-static void InitSuitesHashSigAlgo(Suites* suites, int haveECDSAsig,
-                                                  int haveRSAsig, int haveAnon)
-{
-    int idx = 0;
-
-    if (haveECDSAsig) {
-        #ifdef WOLFSSL_SHA512
-            suites->hashSigAlgo[idx++] = sha512_mac;
-            suites->hashSigAlgo[idx++] = ecc_dsa_sa_algo;
-        #endif
-        #ifdef WOLFSSL_SHA384
-            suites->hashSigAlgo[idx++] = sha384_mac;
-            suites->hashSigAlgo[idx++] = ecc_dsa_sa_algo;
-        #endif
-        #ifndef NO_SHA256
-            suites->hashSigAlgo[idx++] = sha256_mac;
-            suites->hashSigAlgo[idx++] = ecc_dsa_sa_algo;
-        #endif
-        #ifndef NO_SHA
-            suites->hashSigAlgo[idx++] = sha_mac;
-            suites->hashSigAlgo[idx++] = ecc_dsa_sa_algo;
-        #endif
-    }
-
-    if (haveRSAsig) {
-        #ifdef WOLFSSL_SHA512
-            suites->hashSigAlgo[idx++] = sha512_mac;
-            suites->hashSigAlgo[idx++] = rsa_sa_algo;
-        #endif
-        #ifdef WOLFSSL_SHA384
-            suites->hashSigAlgo[idx++] = sha384_mac;
-            suites->hashSigAlgo[idx++] = rsa_sa_algo;
-        #endif
-        #ifndef NO_SHA256
-            suites->hashSigAlgo[idx++] = sha256_mac;
-            suites->hashSigAlgo[idx++] = rsa_sa_algo;
-        #endif
-        #ifndef NO_SHA
-            suites->hashSigAlgo[idx++] = sha_mac;
-            suites->hashSigAlgo[idx++] = rsa_sa_algo;
-        #endif
-    }
-
-    if (haveAnon) {
-        #ifdef HAVE_ANON
-            suites->hashSigAlgo[idx++] = sha_mac;
-            suites->hashSigAlgo[idx++] = anonymous_sa_algo;
-        #endif
-    }
-
-    suites->hashSigAlgoSz = (word16)idx;
-}
-
-void InitSuites(Suites* suites, ProtocolVersion pv, word16 haveRSA,
-                word16 havePSK, word16 haveDH, word16 haveNTRU,
-                word16 haveECDSAsig, word16 haveStaticECC, int side)
-{
-    word16 idx = 0;
-    int    tls    = pv.major == SSLv3_MAJOR && pv.minor >= TLSv1_MINOR;
-    int    tls1_2 = pv.major == SSLv3_MAJOR && pv.minor >= TLSv1_2_MINOR;
-    int    haveRSAsig = 1;
-
-    (void)tls;  /* shut up compiler */
-    (void)tls1_2;
-    (void)haveDH;
-    (void)havePSK;
-    (void)haveNTRU;
-    (void)haveStaticECC;
-
-    if (suites == NULL) {
-        WOLFSSL_MSG("InitSuites pointer error");
-        return;
-    }
-
-    if (suites->setSuites)
-        return;      /* trust user settings, don't override */
-
-    if (side == WOLFSSL_SERVER_END && haveStaticECC) {
-        haveRSA = 0;   /* can't do RSA with ECDSA key */
-        (void)haveRSA; /* some builds won't read */
-    }
-
-    if (side == WOLFSSL_SERVER_END && haveECDSAsig) {
-        haveRSAsig = 0;     /* can't have RSA sig if signed by ECDSA */
-        (void)haveRSAsig;   /* non ecc builds won't read */
-    }
-
-#ifdef WOLFSSL_DTLS
-    if (pv.major == DTLS_MAJOR) {
-        tls    = 1;
-        tls1_2 = pv.minor <= DTLSv1_2_MINOR;
-    }
-#endif
-
-#ifdef HAVE_RENEGOTIATION_INDICATION
-    if (side == WOLFSSL_CLIENT_END) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_EMPTY_RENEGOTIATION_INFO_SCSV;
-    }
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_AES_256_CBC_SHA
-    if (tls && haveNTRU && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_NTRU_RSA_WITH_AES_256_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_AES_128_CBC_SHA
-    if (tls && haveNTRU && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_NTRU_RSA_WITH_AES_128_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_RC4_128_SHA
-    if (tls && haveNTRU && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_NTRU_RSA_WITH_RC4_128_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA
-    if (tls && haveNTRU && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
-    if (tls1_2 && haveECDSAsig) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
-    if (tls1_2 && haveECDSAsig) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
-    if (tls1_2 && haveRSA) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
-    if (tls1_2 && haveRSA) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
-    if (tls1_2 && haveDH && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_RSA_WITH_AES_256_GCM_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
-    if (tls1_2 && haveDH && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_RSA_WITH_AES_128_GCM_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_GCM_SHA384
-    if (tls1_2 && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_AES_256_GCM_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_GCM_SHA256
-    if (tls1_2 && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_AES_128_GCM_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
-    if (tls1_2 && haveECDSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
-    if (tls1_2 && haveECDSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
-    if (tls1_2 && haveRSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
-    if (tls1_2 && haveRSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384
-    if (tls1_2 && haveDH && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_PSK_WITH_AES_256_GCM_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256
-    if (tls1_2 && haveDH && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_PSK_WITH_AES_128_GCM_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_GCM_SHA384
-    if (tls1_2 && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_PSK_WITH_AES_256_GCM_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_GCM_SHA256
-    if (tls1_2 && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_PSK_WITH_AES_128_GCM_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
-    if (tls1_2 && haveECDSAsig) {
-        suites->suites[idx++] = CHACHA_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
-    if (tls && haveRSA) {
-        suites->suites[idx++] = CHACHA_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256
-    if (tls && haveRSA) {
-        suites->suites[idx++] = CHACHA_BYTE;
-        suites->suites[idx++] = TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
-    if (tls1_2 && haveRSAsig) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
-    if (tls1_2 && haveECDSAsig) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
-    if (tls1_2 && haveRSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
-    if (tls1_2 && haveECDSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
-    if (tls1_2 && haveRSAsig) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
-    if (tls1_2 && haveECDSAsig) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
-    if (tls1_2 && haveRSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
-    if (tls1_2 && haveECDSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
-    if (tls && haveECDSAsig) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
-    if (tls && haveECDSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
-    if (tls && haveECDSAsig) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
-    if (tls && haveECDSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
-    if (tls && haveECDSAsig) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_ECDSA_WITH_RC4_128_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_RC4_128_SHA
-    if (tls && haveECDSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_ECDSA_WITH_RC4_128_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
-    if (tls && haveECDSAsig) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
-    if (tls && haveECDSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
-    if (tls && haveRSA) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
-    if (tls && haveRSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_RSA_WITH_AES_256_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
-    if (tls && haveRSA) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
-    if (tls && haveRSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_RSA_WITH_AES_128_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_RC4_128_SHA
-    if (tls && haveRSA) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_RSA_WITH_RC4_128_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_RC4_128_SHA
-    if (tls && haveRSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_RSA_WITH_RC4_128_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
-    if (tls && haveRSA) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
-    if (tls && haveRSAsig && haveStaticECC) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
-    if (tls1_2 && haveECDSAsig) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8;
-    }
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8
-    if (tls1_2 && haveECDSAsig) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CCM_8
-    if (tls1_2 && haveRSA) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_RSA_WITH_AES_128_CCM_8;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CCM_8
-    if (tls1_2 && haveRSA) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_RSA_WITH_AES_256_CCM_8;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
-    if (tls1_2 && haveDH && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_RSA_WITH_AES_256_CBC_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
-    if (tls1_2 && haveDH && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_RSA_WITH_AES_128_CBC_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA
-    if (tls && haveDH && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_RSA_WITH_AES_256_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA
-    if (tls && haveDH && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_RSA_WITH_AES_128_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA256
-    if (tls1_2 && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_AES_256_CBC_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA256
-    if (tls1_2 && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_AES_128_CBC_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA
-    if (tls && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_AES_256_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA
-    if (tls && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_AES_128_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_NULL_SHA
-    if (tls && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_NULL_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_NULL_SHA256
-    if (tls && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_NULL_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA
-    if (tls && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_PSK_WITH_AES_256_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384
-    if (tls && haveDH && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_PSK_WITH_AES_256_CBC_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA384
-    if (tls && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_PSK_WITH_AES_256_CBC_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256
-    if (tls && haveDH && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_PSK_WITH_AES_128_CBC_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA256
-    if (tls && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_PSK_WITH_AES_128_CBC_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA
-    if (tls && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_PSK_WITH_AES_128_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_CCM
-    if (tls && haveDH && havePSK) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_DHE_PSK_WITH_AES_128_CCM;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_CCM
-    if (tls && haveDH && havePSK) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_DHE_PSK_WITH_AES_256_CCM;
-    }
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CCM
-    if (tls && havePSK) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_PSK_WITH_AES_128_CCM;
-    }
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CCM
-    if (tls && havePSK) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_PSK_WITH_AES_256_CCM;
-    }
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CCM_8
-    if (tls && havePSK) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_PSK_WITH_AES_128_CCM_8;
-    }
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CCM_8
-    if (tls && havePSK) {
-        suites->suites[idx++] = ECC_BYTE;
-        suites->suites[idx++] = TLS_PSK_WITH_AES_256_CCM_8;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_NULL_SHA384
-    if (tls && haveDH && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_PSK_WITH_NULL_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_NULL_SHA384
-    if (tls && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_PSK_WITH_NULL_SHA384;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_NULL_SHA256
-    if (tls && haveDH && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_PSK_WITH_NULL_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_NULL_SHA256
-    if (tls && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_PSK_WITH_NULL_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_NULL_SHA
-    if (tls && havePSK) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_PSK_WITH_NULL_SHA;
-    }
-#endif
-
-#ifdef BUILD_SSL_RSA_WITH_RC4_128_SHA
-    if (haveRSA ) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = SSL_RSA_WITH_RC4_128_SHA;
-    }
-#endif
-
-#ifdef BUILD_SSL_RSA_WITH_RC4_128_MD5
-    if (haveRSA ) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = SSL_RSA_WITH_RC4_128_MD5;
-    }
-#endif
-
-#ifdef BUILD_SSL_RSA_WITH_3DES_EDE_CBC_SHA
-    if (haveRSA ) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = SSL_RSA_WITH_3DES_EDE_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_HC_128_MD5
-    if (tls && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_HC_128_MD5;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_HC_128_SHA
-    if (tls && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_HC_128_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_HC_128_B2B256
-    if (tls && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_HC_128_B2B256;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_B2B256
-    if (tls && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_AES_128_CBC_B2B256;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_B2B256
-    if (tls && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_AES_256_CBC_B2B256;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_RABBIT_SHA
-    if (tls && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_RABBIT_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA
-    if (tls && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_CAMELLIA_128_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
-    if (tls && haveDH && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA
-    if (tls && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_CAMELLIA_256_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_WITH_RSA_CAMELLIA_256_CBC_SHA
-    if (tls && haveDH && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256
-    if (tls && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
-    if (tls && haveDH && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256
-    if (tls && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256;
-    }
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256
-    if (tls && haveDH && haveRSA) {
-        suites->suites[idx++] = 0;
-        suites->suites[idx++] = TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256;
-    }
-#endif
-
-    suites->suiteSz = idx;
-
-    InitSuitesHashSigAlgo(suites, haveECDSAsig, haveRSAsig, 0);
-}
-
-
-#ifndef NO_CERTS
-
-
-void InitX509Name(WOLFSSL_X509_NAME* name, int dynamicFlag)
-{
-    (void)dynamicFlag;
-
-    if (name != NULL) {
-        name->name        = name->staticName;
-        name->dynamicName = 0;
-#ifdef OPENSSL_EXTRA
-        XMEMSET(&name->fullName, 0, sizeof(DecodedName));
-#endif /* OPENSSL_EXTRA */
-    }
-}
-
-
-void FreeX509Name(WOLFSSL_X509_NAME* name)
-{
-    if (name != NULL) {
-        if (name->dynamicName)
-            XFREE(name->name, NULL, DYNAMIC_TYPE_SUBJECT_CN);
-#ifdef OPENSSL_EXTRA
-        if (name->fullName.fullName != NULL)
-            XFREE(name->fullName.fullName, NULL, DYNAMIC_TYPE_X509);
-#endif /* OPENSSL_EXTRA */
-    }
-}
-
-
-/* Initialize wolfSSL X509 type */
-void InitX509(WOLFSSL_X509* x509, int dynamicFlag)
-{
-    InitX509Name(&x509->issuer, 0);
-    InitX509Name(&x509->subject, 0);
-    x509->version        = 0;
-    x509->pubKey.buffer  = NULL;
-    x509->sig.buffer     = NULL;
-    x509->derCert.buffer = NULL;
-    x509->altNames       = NULL;
-    x509->altNamesNext   = NULL;
-    x509->dynamicMemory  = (byte)dynamicFlag;
-    x509->isCa           = 0;
-#ifdef HAVE_ECC
-    x509->pkCurveOID = 0;
-#endif /* HAVE_ECC */
-#ifdef OPENSSL_EXTRA
-    x509->pathLength     = 0;
-    x509->basicConstSet  = 0;
-    x509->basicConstCrit = 0;
-    x509->basicConstPlSet = 0;
-    x509->subjAltNameSet = 0;
-    x509->subjAltNameCrit = 0;
-    x509->authKeyIdSet   = 0;
-    x509->authKeyIdCrit  = 0;
-    x509->authKeyId      = NULL;
-    x509->authKeyIdSz    = 0;
-    x509->subjKeyIdSet   = 0;
-    x509->subjKeyIdCrit  = 0;
-    x509->subjKeyId      = NULL;
-    x509->subjKeyIdSz    = 0;
-    x509->keyUsageSet    = 0;
-    x509->keyUsageCrit   = 0;
-    x509->keyUsage       = 0;
-    #ifdef WOLFSSL_SEP
-        x509->certPolicySet  = 0;
-        x509->certPolicyCrit = 0;
-    #endif /* WOLFSSL_SEP */
-#endif /* OPENSSL_EXTRA */
-}
-
-
-/* Free wolfSSL X509 type */
-void FreeX509(WOLFSSL_X509* x509)
-{
-    if (x509 == NULL)
-        return;
-
-    FreeX509Name(&x509->issuer);
-    FreeX509Name(&x509->subject);
-    if (x509->pubKey.buffer)
-        XFREE(x509->pubKey.buffer, NULL, DYNAMIC_TYPE_PUBLIC_KEY);
-    XFREE(x509->derCert.buffer, NULL, DYNAMIC_TYPE_SUBJECT_CN);
-    XFREE(x509->sig.buffer, NULL, DYNAMIC_TYPE_SIGNATURE);
-    #ifdef OPENSSL_EXTRA
-        XFREE(x509->authKeyId, NULL, 0);
-        XFREE(x509->subjKeyId, NULL, 0);
-    #endif /* OPENSSL_EXTRA */
-    if (x509->altNames)
-        FreeAltNames(x509->altNames, NULL);
-    if (x509->dynamicMemory)
-        XFREE(x509, NULL, DYNAMIC_TYPE_X509);
-}
-
-#endif /* NO_CERTS */
-
-
-/* init everything to 0, NULL, default values before calling anything that may
-   fail so that desctructor has a "good" state to cleanup */
-int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx)
-{
-    int  ret;
-    byte haveRSA = 0;
-    byte havePSK = 0;
-    byte haveAnon = 0;
-
-    (void) haveAnon;
-
-    XMEMSET(ssl, 0, sizeof(WOLFSSL));
-
-    ssl->ctx     = ctx; /* only for passing to calls, options could change */
-    ssl->version = ctx->method->version;
-
-#ifndef NO_RSA
-    haveRSA = 1;
-#endif
-
-    ssl->buffers.inputBuffer.buffer = ssl->buffers.inputBuffer.staticBuffer;
-    ssl->buffers.inputBuffer.bufferSize  = STATIC_BUFFER_LEN;
-
-    ssl->buffers.outputBuffer.buffer = ssl->buffers.outputBuffer.staticBuffer;
-    ssl->buffers.outputBuffer.bufferSize  = STATIC_BUFFER_LEN;
-
-#ifdef KEEP_PEER_CERT
-    InitX509(&ssl->peerCert, 0);
-#endif
-
-#ifdef HAVE_ECC
-    ssl->eccTempKeySz = ctx->eccTempKeySz;
-    ssl->pkCurveOID = ctx->pkCurveOID;
-#endif
-
-    ssl->timeout = ctx->timeout;
-    ssl->rfd = -1;   /* set to invalid descriptor */
-    ssl->wfd = -1;
-
-    ssl->IOCB_ReadCtx  = &ssl->rfd;  /* prevent invalid pointer access if not */
-    ssl->IOCB_WriteCtx = &ssl->wfd;  /* correctly set */
-
-#ifdef HAVE_NETX
-    ssl->IOCB_ReadCtx  = &ssl->nxCtx;  /* default NetX IO ctx, same for read */
-    ssl->IOCB_WriteCtx = &ssl->nxCtx;  /* and write */
-#endif
-#ifdef WOLFSSL_DTLS
-    ssl->dtls_expected_rx = MAX_MTU;
-#endif
-
-    ssl->verifyCallback    = ctx->verifyCallback;
-    ssl->options.side      = ctx->method->side;
-    ssl->options.downgrade    = ctx->method->downgrade;
-    ssl->options.minDowngrade = ctx->minDowngrade;
-
-    if (ssl->options.side == WOLFSSL_SERVER_END)
-        ssl->options.haveDH = ctx->haveDH;
-
-    ssl->options.haveNTRU      = ctx->haveNTRU;
-    ssl->options.haveECDSAsig  = ctx->haveECDSAsig;
-    ssl->options.haveStaticECC = ctx->haveStaticECC;
-
-#ifndef NO_PSK
-    havePSK = ctx->havePSK;
-    ssl->options.havePSK   = ctx->havePSK;
-    ssl->options.client_psk_cb = ctx->client_psk_cb;
-    ssl->options.server_psk_cb = ctx->server_psk_cb;
-#endif /* NO_PSK */
-
-#ifdef HAVE_ANON
-    haveAnon = ctx->haveAnon;
-    ssl->options.haveAnon = ctx->haveAnon;
-#endif
-
-    ssl->options.serverState = NULL_STATE;
-    ssl->options.clientState = NULL_STATE;
-    ssl->options.connectState = CONNECT_BEGIN;
-    ssl->options.acceptState  = ACCEPT_BEGIN;
-    ssl->options.handShakeState  = NULL_STATE;
-    ssl->options.processReply = doProcessInit;
-
-#ifndef NO_DH
-    ssl->options.minDhKeySz = ctx->minDhKeySz;
-#endif
-
-#ifdef WOLFSSL_DTLS
-    ssl->dtls_timeout_init              = DTLS_TIMEOUT_INIT;
-    ssl->dtls_timeout_max               = DTLS_TIMEOUT_MAX;
-    ssl->dtls_timeout                   = ssl->dtls_timeout_init;
-#endif
-
-    ssl->options.sessionCacheOff      = ctx->sessionCacheOff;
-    ssl->options.sessionCacheFlushOff = ctx->sessionCacheFlushOff;
-
-    ssl->options.verifyPeer = ctx->verifyPeer;
-    ssl->options.verifyNone = ctx->verifyNone;
-    ssl->options.failNoCert = ctx->failNoCert;
-    ssl->options.sendVerify = ctx->sendVerify;
-
-    #ifndef NO_OLD_TLS
-        ssl->hmac = SSL_hmac; /* default to SSLv3 */
-    #else
-        ssl->hmac = TLS_hmac;
-    #endif
-
-    ssl->heap = ctx->heap;    /* defaults to self */
-
-    ssl->options.dtls = ssl->version.major == DTLS_MAJOR;
-    ssl->options.partialWrite  = ctx->partialWrite;
-    ssl->options.quietShutdown = ctx->quietShutdown;
-    ssl->options.groupMessages = ctx->groupMessages;
-
-#ifndef NO_DH
-    if (ssl->options.side == WOLFSSL_SERVER_END) {
-        ssl->buffers.serverDH_P = ctx->serverDH_P;
-        ssl->buffers.serverDH_G = ctx->serverDH_G;
-    }
-#endif
-#ifndef NO_CERTS
-    /* ctx still owns certificate, certChain, key, dh, and cm */
-    ssl->buffers.certificate = ctx->certificate;
-    ssl->buffers.certChain = ctx->certChain;
-    ssl->buffers.key = ctx->privateKey;
-#endif
-
-#ifdef WOLFSSL_DTLS
-    ssl->buffers.dtlsCtx.fd = -1;
-#endif
-
-    ssl->cipher.ssl = ssl;
-
-#ifdef HAVE_CAVIUM
-    ssl->devId = ctx->devId;
-#endif
-
-#ifdef HAVE_TLS_EXTENSIONS
-#ifdef HAVE_MAX_FRAGMENT
-    ssl->max_fragment = MAX_RECORD_SIZE;
-#endif
-#endif
-
-    /* default alert state (none) */
-    ssl->alert_history.last_rx.code  = -1;
-    ssl->alert_history.last_rx.level = -1;
-    ssl->alert_history.last_tx.code  = -1;
-    ssl->alert_history.last_tx.level = -1;
-
-    InitCiphers(ssl);
-    InitCipherSpecs(&ssl->specs);
-
-    /* all done with init, now can return errors, call other stuff */
-
-    /* hsHashes */
-    ssl->hsHashes = (HS_Hashes*)XMALLOC(sizeof(HS_Hashes), ssl->heap,
-                                                           DYNAMIC_TYPE_HASHES);
-    if (ssl->hsHashes == NULL) {
-        WOLFSSL_MSG("HS_Hashes Memory error");
-        return MEMORY_E;
-    }
-
-#ifndef NO_OLD_TLS
-#ifndef NO_MD5
-    wc_InitMd5(&ssl->hsHashes->hashMd5);
-#endif
-#ifndef NO_SHA
-    ret = wc_InitSha(&ssl->hsHashes->hashSha);
-    if (ret != 0) {
-        return ret;
-    }
-#endif
-#endif
-#ifndef NO_SHA256
-    ret = wc_InitSha256(&ssl->hsHashes->hashSha256);
-    if (ret != 0) {
-        return ret;
-    }
-#endif
-#ifdef WOLFSSL_SHA384
-    ret = wc_InitSha384(&ssl->hsHashes->hashSha384);
-    if (ret != 0) {
-        return ret;
-    }
-#endif
-#ifdef WOLFSSL_SHA512
-    ret = wc_InitSha512(&ssl->hsHashes->hashSha512);
-    if (ret != 0) {
-        return ret;
-    }
-#endif
-
-    /* increment CTX reference count */
-    if (LockMutex(&ctx->countMutex) != 0) {
-        WOLFSSL_MSG("Couldn't lock CTX count mutex");
-        return BAD_MUTEX_E;
-    }
-    ctx->refCount++;
-    UnLockMutex(&ctx->countMutex);
-
-    /* arrays */
-    ssl->arrays = (Arrays*)XMALLOC(sizeof(Arrays), ssl->heap,
-                                                           DYNAMIC_TYPE_ARRAYS);
-    if (ssl->arrays == NULL) {
-        WOLFSSL_MSG("Arrays Memory error");
-        return MEMORY_E;
-    }
-    XMEMSET(ssl->arrays, 0, sizeof(Arrays));
-
-#ifndef NO_PSK
-    if (ctx->server_hint[0]) {   /* set in CTX */
-        XSTRNCPY(ssl->arrays->server_hint, ctx->server_hint, MAX_PSK_ID_LEN);
-        ssl->arrays->server_hint[MAX_PSK_ID_LEN - 1] = '\0';
-    }
-#endif /* NO_PSK */
-
-    /* RNG */
-    ssl->rng = (RNG*)XMALLOC(sizeof(RNG), ssl->heap, DYNAMIC_TYPE_RNG);
-    if (ssl->rng == NULL) {
-        WOLFSSL_MSG("RNG Memory error");
-        return MEMORY_E;
-    }
-
-    if ( (ret = wc_InitRng(ssl->rng)) != 0) {
-        WOLFSSL_MSG("RNG Init error");
-        return ret;
-    }
-
-    /* suites */
-    ssl->suites = (Suites*)XMALLOC(sizeof(Suites), ssl->heap,
-                                   DYNAMIC_TYPE_SUITES);
-    if (ssl->suites == NULL) {
-        WOLFSSL_MSG("Suites Memory error");
-        return MEMORY_E;
-    }
-    if (ctx->suites)
-        *ssl->suites = *ctx->suites;
-    else
-        XMEMSET(ssl->suites, 0, sizeof(Suites));
-
-
-#ifndef NO_CERTS
-    /* make sure server has cert and key unless using PSK or Anon */
-    if (ssl->options.side == WOLFSSL_SERVER_END && !havePSK && !haveAnon)
-        if (!ssl->buffers.certificate.buffer || !ssl->buffers.key.buffer) {
-            WOLFSSL_MSG("Server missing certificate and/or private key");
-            return NO_PRIVATE_KEY;
-        }
-#endif
-#ifdef HAVE_SECRET_CALLBACK
-    ssl->sessionSecretCb  = NULL;
-    ssl->sessionSecretCtx = NULL;
-#endif
-
-    /* make sure server has DH parms, and add PSK if there, add NTRU too */
-    if (ssl->options.side == WOLFSSL_SERVER_END)
-        InitSuites(ssl->suites, ssl->version, haveRSA, havePSK,
-                   ssl->options.haveDH, ssl->options.haveNTRU,
-                   ssl->options.haveECDSAsig, ssl->options.haveStaticECC,
-                   ssl->options.side);
-    else
-        InitSuites(ssl->suites, ssl->version, haveRSA, havePSK, TRUE,
-                   ssl->options.haveNTRU, ssl->options.haveECDSAsig,
-                   ssl->options.haveStaticECC, ssl->options.side);
-
-    return 0;
-}
-
-
-/* free use of temporary arrays */
-void FreeArrays(WOLFSSL* ssl, int keep)
-{
-    if (ssl->arrays && keep) {
-        /* keeps session id for user retrieval */
-        XMEMCPY(ssl->session.sessionID, ssl->arrays->sessionID, ID_LEN);
-        ssl->session.sessionIDSz = ssl->arrays->sessionIDSz;
-    }
-    XFREE(ssl->arrays, ssl->heap, DYNAMIC_TYPE_ARRAYS);
-    ssl->arrays = NULL;
-}
-
-
-/* In case holding SSL object in array and don't want to free actual ssl */
-void SSL_ResourceFree(WOLFSSL* ssl)
-{
-    /* Note: any resources used during the handshake should be released in the
-     * function FreeHandshakeResources(). Be careful with the special cases
-     * like the RNG which may optionally be kept for the whole session. (For
-     * example with the RNG, it isn't used beyond the handshake except when
-     * using stream ciphers where it is retained. */
-
-    FreeCiphers(ssl);
-    FreeArrays(ssl, 0);
-    wc_FreeRng(ssl->rng);
-    XFREE(ssl->rng, ssl->heap, DYNAMIC_TYPE_RNG);
-    XFREE(ssl->suites, ssl->heap, DYNAMIC_TYPE_SUITES);
-    XFREE(ssl->hsHashes, ssl->heap, DYNAMIC_TYPE_HASHES);
-    XFREE(ssl->buffers.domainName.buffer, ssl->heap, DYNAMIC_TYPE_DOMAIN);
-
-#ifndef NO_DH
-    XFREE(ssl->buffers.serverDH_Priv.buffer, ssl->heap, DYNAMIC_TYPE_DH);
-    XFREE(ssl->buffers.serverDH_Pub.buffer, ssl->heap, DYNAMIC_TYPE_DH);
-    /* parameters (p,g) may be owned by ctx */
-    if (ssl->buffers.weOwnDH || ssl->options.side == WOLFSSL_CLIENT_END) {
-        XFREE(ssl->buffers.serverDH_G.buffer, ssl->heap, DYNAMIC_TYPE_DH);
-        XFREE(ssl->buffers.serverDH_P.buffer, ssl->heap, DYNAMIC_TYPE_DH);
-    }
-#endif
-#ifndef NO_CERTS
-    if (ssl->buffers.weOwnCert)
-        XFREE(ssl->buffers.certificate.buffer, ssl->heap, DYNAMIC_TYPE_CERT);
-    if (ssl->buffers.weOwnCertChain)
-        XFREE(ssl->buffers.certChain.buffer, ssl->heap, DYNAMIC_TYPE_CERT);
-    if (ssl->buffers.weOwnKey)
-        XFREE(ssl->buffers.key.buffer, ssl->heap, DYNAMIC_TYPE_KEY);
-#endif
-#ifndef NO_RSA
-    if (ssl->peerRsaKey) {
-        wc_FreeRsaKey(ssl->peerRsaKey);
-        XFREE(ssl->peerRsaKey, ssl->heap, DYNAMIC_TYPE_RSA);
-    }
-#endif
-    if (ssl->buffers.inputBuffer.dynamicFlag)
-        ShrinkInputBuffer(ssl, FORCED_FREE);
-    if (ssl->buffers.outputBuffer.dynamicFlag)
-        ShrinkOutputBuffer(ssl);
-#ifdef WOLFSSL_DTLS
-    if (ssl->dtls_pool != NULL) {
-        DtlsPoolReset(ssl);
-        XFREE(ssl->dtls_pool, ssl->heap, DYNAMIC_TYPE_NONE);
-    }
-    if (ssl->dtls_msg_list != NULL) {
-        DtlsMsgListDelete(ssl->dtls_msg_list, ssl->heap);
-        ssl->dtls_msg_list = NULL;
-    }
-    XFREE(ssl->buffers.dtlsCtx.peer.sa, ssl->heap, DYNAMIC_TYPE_SOCKADDR);
-    ssl->buffers.dtlsCtx.peer.sa = NULL;
-#endif
-#if defined(KEEP_PEER_CERT) || defined(GOAHEAD_WS)
-    FreeX509(&ssl->peerCert);
-#endif
-#if defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS)
-    wolfSSL_BIO_free(ssl->biord);
-    if (ssl->biord != ssl->biowr)        /* in case same as write */
-        wolfSSL_BIO_free(ssl->biowr);
-#endif
-#ifdef HAVE_LIBZ
-    FreeStreams(ssl);
-#endif
-#ifdef HAVE_ECC
-    if (ssl->peerEccKey) {
-        if (ssl->peerEccKeyPresent)
-            wc_ecc_free(ssl->peerEccKey);
-        XFREE(ssl->peerEccKey, ssl->heap, DYNAMIC_TYPE_ECC);
-    }
-    if (ssl->peerEccDsaKey) {
-        if (ssl->peerEccDsaKeyPresent)
-            wc_ecc_free(ssl->peerEccDsaKey);
-        XFREE(ssl->peerEccDsaKey, ssl->heap, DYNAMIC_TYPE_ECC);
-    }
-    if (ssl->eccTempKey) {
-        if (ssl->eccTempKeyPresent)
-            wc_ecc_free(ssl->eccTempKey);
-        XFREE(ssl->eccTempKey, ssl->heap, DYNAMIC_TYPE_ECC);
-    }
-#endif
-#ifdef HAVE_PK_CALLBACKS
-    #ifdef HAVE_ECC
-        XFREE(ssl->buffers.peerEccDsaKey.buffer, ssl->heap, DYNAMIC_TYPE_ECC);
-    #endif /* HAVE_ECC */
-    #ifndef NO_RSA
-        XFREE(ssl->buffers.peerRsaKey.buffer, ssl->heap, DYNAMIC_TYPE_RSA);
-    #endif /* NO_RSA */
-#endif /* HAVE_PK_CALLBACKS */
-#ifdef HAVE_TLS_EXTENSIONS
-    TLSX_FreeAll(ssl->extensions);
-#endif
-#ifdef HAVE_NETX
-    if (ssl->nxCtx.nxPacket)
-        nx_packet_release(ssl->nxCtx.nxPacket);
-#endif
-}
-
-#ifdef WOLFSSL_TI_HASH
-static void HashFinal(WOLFSSL * ssl) {
-    byte dummyHash[32] ;
-#ifndef NO_MD5
-    wc_Md5Final(&(ssl->hsHashes->hashMd5), dummyHash) ;
-#endif
-#ifndef NO_SHA
-    wc_ShaFinal(&(ssl->hsHashes->hashSha), dummyHash) ;
-#endif
-#ifndef NO_SHA256
-    wc_Sha256Final(&(ssl->hsHashes->hashSha256), dummyHash) ;
-#endif
-}
-#else
-
-    #define HashFinal(ssl)
-
-#endif
-
-/* Free any handshake resources no longer needed */
-void FreeHandshakeResources(WOLFSSL* ssl)
-{
-
-    HashFinal(ssl) ;
-#ifdef HAVE_SECURE_RENEGOTIATION
-    if (ssl->secure_renegotiation && ssl->secure_renegotiation->enabled) {
-        WOLFSSL_MSG("Secure Renegotiation needs to retain handshake resources");
-        return;
-    }
-#endif
-
-    /* input buffer */
-    if (ssl->buffers.inputBuffer.dynamicFlag)
-        ShrinkInputBuffer(ssl, NO_FORCED_FREE);
-
-    /* suites */
-    XFREE(ssl->suites, ssl->heap, DYNAMIC_TYPE_SUITES);
-    ssl->suites = NULL;
-
-    /* hsHashes */
-    XFREE(ssl->hsHashes, ssl->heap, DYNAMIC_TYPE_HASHES);
-    ssl->hsHashes = NULL;
-
-    /* RNG */
-    if (ssl->specs.cipher_type == stream || ssl->options.tls1_1 == 0) {
-        wc_FreeRng(ssl->rng);
-        XFREE(ssl->rng, ssl->heap, DYNAMIC_TYPE_RNG);
-        ssl->rng = NULL;
-    }
-
-#ifdef WOLFSSL_DTLS
-    /* DTLS_POOL */
-    if (ssl->options.dtls && ssl->dtls_pool != NULL) {
-        DtlsPoolReset(ssl);
-        XFREE(ssl->dtls_pool, ssl->heap, DYNAMIC_TYPE_DTLS_POOL);
-        ssl->dtls_pool = NULL;
-    }
-#endif
-
-    /* arrays */
-    if (ssl->options.saveArrays == 0)
-        FreeArrays(ssl, 1);
-
-#ifndef NO_RSA
-    /* peerRsaKey */
-    if (ssl->peerRsaKey) {
-        wc_FreeRsaKey(ssl->peerRsaKey);
-        XFREE(ssl->peerRsaKey, ssl->heap, DYNAMIC_TYPE_RSA);
-        ssl->peerRsaKey = NULL;
-    }
-#endif
-
-#ifdef HAVE_ECC
-    if (ssl->peerEccKey)
-    {
-        if (ssl->peerEccKeyPresent) {
-            wc_ecc_free(ssl->peerEccKey);
-            ssl->peerEccKeyPresent = 0;
-        }
-        XFREE(ssl->peerEccKey, ssl->heap, DYNAMIC_TYPE_ECC);
-        ssl->peerEccKey = NULL;
-    }
-    if (ssl->peerEccDsaKey)
-    {
-        if (ssl->peerEccDsaKeyPresent) {
-            wc_ecc_free(ssl->peerEccDsaKey);
-            ssl->peerEccDsaKeyPresent = 0;
-        }
-        XFREE(ssl->peerEccDsaKey, ssl->heap, DYNAMIC_TYPE_ECC);
-        ssl->peerEccDsaKey = NULL;
-    }
-    if (ssl->eccTempKey)
-    {
-        if (ssl->eccTempKeyPresent) {
-            wc_ecc_free(ssl->eccTempKey);
-            ssl->eccTempKeyPresent = 0;
-        }
-        XFREE(ssl->eccTempKey, ssl->heap, DYNAMIC_TYPE_ECC);
-        ssl->eccTempKey = NULL;
-    }
-#endif
-#ifndef NO_DH
-    XFREE(ssl->buffers.serverDH_Priv.buffer, ssl->heap, DYNAMIC_TYPE_DH);
-    ssl->buffers.serverDH_Priv.buffer = NULL;
-    XFREE(ssl->buffers.serverDH_Pub.buffer, ssl->heap, DYNAMIC_TYPE_DH);
-    ssl->buffers.serverDH_Pub.buffer = NULL;
-    /* parameters (p,g) may be owned by ctx */
-    if (ssl->buffers.weOwnDH || ssl->options.side == WOLFSSL_CLIENT_END) {
-        XFREE(ssl->buffers.serverDH_G.buffer, ssl->heap, DYNAMIC_TYPE_DH);
-        ssl->buffers.serverDH_G.buffer = NULL;
-        XFREE(ssl->buffers.serverDH_P.buffer, ssl->heap, DYNAMIC_TYPE_DH);
-        ssl->buffers.serverDH_P.buffer = NULL;
-    }
-#endif
-#ifndef NO_CERTS
-    if (ssl->buffers.weOwnCert) {
-        XFREE(ssl->buffers.certificate.buffer, ssl->heap, DYNAMIC_TYPE_CERT);
-        ssl->buffers.certificate.buffer = NULL;
-    }
-    if (ssl->buffers.weOwnCertChain) {
-        XFREE(ssl->buffers.certChain.buffer, ssl->heap, DYNAMIC_TYPE_CERT);
-        ssl->buffers.certChain.buffer = NULL;
-    }
-    if (ssl->buffers.weOwnKey) {
-        XFREE(ssl->buffers.key.buffer, ssl->heap, DYNAMIC_TYPE_KEY);
-        ssl->buffers.key.buffer = NULL;
-    }
-#endif
-#ifdef HAVE_PK_CALLBACKS
-    #ifdef HAVE_ECC
-        XFREE(ssl->buffers.peerEccDsaKey.buffer, ssl->heap, DYNAMIC_TYPE_ECC);
-        ssl->buffers.peerEccDsaKey.buffer = NULL;
-    #endif /* HAVE_ECC */
-    #ifndef NO_RSA
-        XFREE(ssl->buffers.peerRsaKey.buffer, ssl->heap, DYNAMIC_TYPE_RSA);
-        ssl->buffers.peerRsaKey.buffer = NULL;
-    #endif /* NO_RSA */
-#endif /* HAVE_PK_CALLBACKS */
-}
-
-
-void FreeSSL(WOLFSSL* ssl)
-{
-    FreeSSL_Ctx(ssl->ctx);  /* will decrement and free underyling CTX if 0 */
-    SSL_ResourceFree(ssl);
-    XFREE(ssl, ssl->heap, DYNAMIC_TYPE_SSL);
-}
-
-
-#ifdef WOLFSSL_DTLS
-
-int DtlsPoolInit(WOLFSSL* ssl)
-{
-    if (ssl->dtls_pool == NULL) {
-        DtlsPool *pool = (DtlsPool*)XMALLOC(sizeof(DtlsPool),
-                                             ssl->heap, DYNAMIC_TYPE_DTLS_POOL);
-        if (pool == NULL) {
-            WOLFSSL_MSG("DTLS Buffer Pool Memory error");
-            return MEMORY_E;
-        }
-        else {
-            int i;
-
-            for (i = 0; i < DTLS_POOL_SZ; i++) {
-                pool->buf[i].length = 0;
-                pool->buf[i].buffer = NULL;
-            }
-            pool->used = 0;
-            ssl->dtls_pool = pool;
-        }
-    }
-    return 0;
-}
-
-
-int DtlsPoolSave(WOLFSSL* ssl, const byte *src, int sz)
-{
-    DtlsPool *pool = ssl->dtls_pool;
-    if (pool != NULL && pool->used < DTLS_POOL_SZ) {
-        buffer *pBuf = &pool->buf[pool->used];
-        pBuf->buffer = (byte*)XMALLOC(sz, ssl->heap, DYNAMIC_TYPE_DTLS_POOL);
-        if (pBuf->buffer == NULL) {
-            WOLFSSL_MSG("DTLS Buffer Memory error");
-            return MEMORY_ERROR;
-        }
-        XMEMCPY(pBuf->buffer, src, sz);
-        pBuf->length = (word32)sz;
-        pool->used++;
-    }
-    return 0;
-}
-
-
-void DtlsPoolReset(WOLFSSL* ssl)
-{
-    DtlsPool *pool = ssl->dtls_pool;
-    if (pool != NULL) {
-        buffer *pBuf;
-        int i, used;
-
-        used = pool->used;
-        for (i = 0, pBuf = &pool->buf[0]; i < used; i++, pBuf++) {
-            XFREE(pBuf->buffer, ssl->heap, DYNAMIC_TYPE_DTLS_POOL);
-            pBuf->buffer = NULL;
-            pBuf->length = 0;
-        }
-        pool->used = 0;
-    }
-    ssl->dtls_timeout = ssl->dtls_timeout_init;
-}
-
-
-int DtlsPoolTimeout(WOLFSSL* ssl)
-{
-    int result = -1;
-    if (ssl->dtls_timeout <  ssl->dtls_timeout_max) {
-        ssl->dtls_timeout *= DTLS_TIMEOUT_MULTIPLIER;
-        result = 0;
-    }
-    return result;
-}
-
-
-int DtlsPoolSend(WOLFSSL* ssl)
-{
-    int ret;
-    DtlsPool *pool = ssl->dtls_pool;
-
-    if (pool != NULL && pool->used > 0) {
-        int i;
-        for (i = 0; i < pool->used; i++) {
-            int sendResult;
-            buffer* buf = &pool->buf[i];
-
-            DtlsRecordLayerHeader* dtls = (DtlsRecordLayerHeader*)buf->buffer;
-
-            word16 message_epoch;
-            ato16(dtls->epoch, &message_epoch);
-            if (message_epoch == ssl->keys.dtls_epoch) {
-                /* Increment record sequence number on retransmitted handshake
-                 * messages */
-                c32to48(ssl->keys.dtls_sequence_number, dtls->sequence_number);
-                ssl->keys.dtls_sequence_number++;
-            }
-            else {
-                /* The Finished message is sent with the next epoch, keep its
-                 * sequence number */
-            }
-
-            if ((ret = CheckAvailableSize(ssl, buf->length)) != 0)
-                return ret;
-
-            XMEMCPY(ssl->buffers.outputBuffer.buffer, buf->buffer, buf->length);
-            ssl->buffers.outputBuffer.idx = 0;
-            ssl->buffers.outputBuffer.length = buf->length;
-
-            sendResult = SendBuffered(ssl);
-            if (sendResult < 0) {
-                return sendResult;
-            }
-        }
-    }
-    return 0;
-}
-
-
-/* functions for managing DTLS datagram reordering */
-
-/* Need to allocate space for the handshake message header. The hashing
- * routines assume the message pointer is still within the buffer that
- * has the headers, and will include those headers in the hash. The store
- * routines need to take that into account as well. New will allocate
- * extra space for the headers. */
-DtlsMsg* DtlsMsgNew(word32 sz, void* heap)
-{
-    DtlsMsg* msg = NULL;
-
-    msg = (DtlsMsg*)XMALLOC(sizeof(DtlsMsg), heap, DYNAMIC_TYPE_DTLS_MSG);
-
-    if (msg != NULL) {
-        msg->buf = (byte*)XMALLOC(sz + DTLS_HANDSHAKE_HEADER_SZ,
-                                                     heap, DYNAMIC_TYPE_NONE);
-        if (msg->buf != NULL) {
-            msg->next = NULL;
-            msg->seq = 0;
-            msg->sz = sz;
-            msg->fragSz = 0;
-            msg->msg = msg->buf + DTLS_HANDSHAKE_HEADER_SZ;
-        }
-        else {
-            XFREE(msg, heap, DYNAMIC_TYPE_DTLS_MSG);
-            msg = NULL;
-        }
-    }
-
-    return msg;
-}
-
-void DtlsMsgDelete(DtlsMsg* item, void* heap)
-{
-    (void)heap;
-
-    if (item != NULL) {
-        if (item->buf != NULL)
-            XFREE(item->buf, heap, DYNAMIC_TYPE_NONE);
-        XFREE(item, heap, DYNAMIC_TYPE_DTLS_MSG);
-    }
-}
-
-
-void DtlsMsgListDelete(DtlsMsg* head, void* heap)
-{
-    DtlsMsg* next;
-    while (head) {
-        next = head->next;
-        DtlsMsgDelete(head, heap);
-        head = next;
-    }
-}
-
-
-void DtlsMsgSet(DtlsMsg* msg, word32 seq, const byte* data, byte type,
-                                              word32 fragOffset, word32 fragSz)
-{
-    if (msg != NULL && data != NULL && msg->fragSz <= msg->sz &&
-                    fragOffset <= msg->sz && (fragOffset + fragSz) <= msg->sz) {
-
-        msg->seq = seq;
-        msg->type = type;
-        msg->fragSz += fragSz;
-        /* If fragOffset is zero, this is either a full message that is out
-         * of order, or the first fragment of a fragmented message. Copy the
-         * handshake message header with the message data. Zero length messages
-         * like Server Hello Done should be saved as well. */
-        if (fragOffset == 0)
-            XMEMCPY(msg->buf, data - DTLS_HANDSHAKE_HEADER_SZ,
-                                            fragSz + DTLS_HANDSHAKE_HEADER_SZ);
-        else {
-            /* If fragOffet is non-zero, this is an additional fragment that
-             * needs to be copied to its location in the message buffer. Also
-             * copy the total size of the message over the fragment size. The
-             * hash routines look at a defragmented message if it had actually
-             * come across as a single handshake message. */
-            XMEMCPY(msg->msg + fragOffset, data, fragSz);
-        }
-        c32to24(msg->sz, msg->msg - DTLS_HANDSHAKE_FRAG_SZ);
-    }
-}
-
-
-DtlsMsg* DtlsMsgFind(DtlsMsg* head, word32 seq)
-{
-    while (head != NULL && head->seq != seq) {
-        head = head->next;
-    }
-    return head;
-}
-
-
-DtlsMsg* DtlsMsgStore(DtlsMsg* head, word32 seq, const byte* data,
-        word32 dataSz, byte type, word32 fragOffset, word32 fragSz, void* heap)
-{
-
-    /* See if seq exists in the list. If it isn't in the list, make
-     * a new item of size dataSz, copy fragSz bytes from data to msg->msg
-     * starting at offset fragOffset, and add fragSz to msg->fragSz. If
-     * the seq is in the list and it isn't full, copy fragSz bytes from
-     * data to msg->msg starting at offset fragOffset, and add fragSz to
-     * msg->fragSz. The new item should be inserted into the list in its
-     * proper position.
-     *
-     * 1. Find seq in list, or where seq should go in list. If seq not in
-     *    list, create new item and insert into list. Either case, keep
-     *    pointer to item.
-     * 2. If msg->fragSz + fragSz < sz, copy data to msg->msg at offset
-     *    fragOffset. Add fragSz to msg->fragSz.
-     */
-
-    if (head != NULL) {
-        DtlsMsg* cur = DtlsMsgFind(head, seq);
-        if (cur == NULL) {
-            cur = DtlsMsgNew(dataSz, heap);
-            if (cur != NULL) {
-                DtlsMsgSet(cur, seq, data, type, fragOffset, fragSz);
-                head = DtlsMsgInsert(head, cur);
-            }
-        }
-        else {
-            DtlsMsgSet(cur, seq, data, type, fragOffset, fragSz);
-        }
-    }
-    else {
-        head = DtlsMsgNew(dataSz, heap);
-        DtlsMsgSet(head, seq, data, type, fragOffset, fragSz);
-    }
-
-    return head;
-}
-
-
-/* DtlsMsgInsert() is an in-order insert. */
-DtlsMsg* DtlsMsgInsert(DtlsMsg* head, DtlsMsg* item)
-{
-    if (head == NULL || item->seq < head->seq) {
-        item->next = head;
-        head = item;
-    }
-    else if (head->next == NULL) {
-        head->next = item;
-    }
-    else {
-        DtlsMsg* cur = head->next;
-        DtlsMsg* prev = head;
-        while (cur) {
-            if (item->seq < cur->seq) {
-                item->next = cur;
-                prev->next = item;
-                break;
-            }
-            prev = cur;
-            cur = cur->next;
-        }
-        if (cur == NULL) {
-            prev->next = item;
-        }
-    }
-
-    return head;
-}
-
-#endif /* WOLFSSL_DTLS */
-
-#ifndef NO_OLD_TLS
-
-ProtocolVersion MakeSSLv3(void)
-{
-    ProtocolVersion pv;
-    pv.major = SSLv3_MAJOR;
-    pv.minor = SSLv3_MINOR;
-
-    return pv;
-}
-
-#endif /* NO_OLD_TLS */
-
-
-#ifdef WOLFSSL_DTLS
-
-ProtocolVersion MakeDTLSv1(void)
-{
-    ProtocolVersion pv;
-    pv.major = DTLS_MAJOR;
-    pv.minor = DTLS_MINOR;
-
-    return pv;
-}
-
-ProtocolVersion MakeDTLSv1_2(void)
-{
-    ProtocolVersion pv;
-    pv.major = DTLS_MAJOR;
-    pv.minor = DTLSv1_2_MINOR;
-
-    return pv;
-}
-
-#endif /* WOLFSSL_DTLS */
-
-
-
-
-#ifdef USE_WINDOWS_API
-
-    word32 LowResTimer(void)
-    {
-        static int           init = 0;
-        static LARGE_INTEGER freq;
-        LARGE_INTEGER        count;
-
-        if (!init) {
-            QueryPerformanceFrequency(&freq);
-            init = 1;
-        }
-
-        QueryPerformanceCounter(&count);
-
-        return (word32)(count.QuadPart / freq.QuadPart);
-    }
-
-#elif defined(HAVE_RTP_SYS)
-
-    #include "rtptime.h"
-
-    word32 LowResTimer(void)
-    {
-        return (word32)rtp_get_system_sec();
-    }
-
-
-#elif defined(MICRIUM)
-
-    word32 LowResTimer(void)
-    {
-        NET_SECURE_OS_TICK  clk;
-
-        #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
-            clk = NetSecure_OS_TimeGet();
-        #endif
-        return (word32)clk;
-    }
-
-
-#elif defined(MICROCHIP_TCPIP_V5)
-
-    word32 LowResTimer(void)
-    {
-        return (word32) TickGet();
-    }
-
-
-#elif defined(MICROCHIP_TCPIP)
-
-    #if defined(MICROCHIP_MPLAB_HARMONY)
-
-        #include 
-
-        word32 LowResTimer(void)
-        {
-            return (word32) SYS_TMR_TickCountGet();
-        }
-
-    #else
-
-        word32 LowResTimer(void)
-        {
-            return (word32) SYS_TICK_Get();
-        }
-
-    #endif
-
-#elif defined(FREESCALE_MQX)
-
-    word32 LowResTimer(void)
-    {
-        TIME_STRUCT mqxTime;
-
-        _time_get_elapsed(&mqxTime);
-
-        return (word32) mqxTime.SECONDS;
-    }
-
-#elif defined(WOLFSSL_TIRTOS)
-
-    word32 LowResTimer(void)
-    {
-        return (word32) Seconds_get();
-    }
-
-#elif defined(USER_TICKS)
-#if 0
-    word32 LowResTimer(void)
-    {
-        /*
-        write your own clock tick function if don't want time(0)
-        needs second accuracy but doesn't have to correlated to EPOCH
-        */
-    }
-#endif
-
-#elif defined(TIME_OVERRIDES)
-
-    /* use same asn time overrides unless user wants tick override above */
-
-    #ifndef HAVE_TIME_T_TYPE
-        typedef long time_t;
-    #endif
-    extern time_t XTIME(time_t * timer);
-
-    word32 LowResTimer(void)
-    {
-        return (word32) XTIME(0);
-    }
-
-#else /* !USE_WINDOWS_API && !HAVE_RTP_SYS && !MICRIUM && !USER_TICKS */
-
-    #include 
-
-    word32 LowResTimer(void)
-    {
-        return (word32)time(0);
-    }
-
-
-#endif /* USE_WINDOWS_API */
-
-
-/* add output to md5 and sha handshake hashes, exclude record header */
-static int HashOutput(WOLFSSL* ssl, const byte* output, int sz, int ivSz)
-{
-    const byte* adj = output + RECORD_HEADER_SZ + ivSz;
-    sz -= RECORD_HEADER_SZ;
-
-#ifdef HAVE_FUZZER
-    if (ssl->fuzzerCb)
-        ssl->fuzzerCb(ssl, output, sz, FUZZ_HASH, ssl->fuzzerCtx);
-#endif
-#ifdef WOLFSSL_DTLS
-    if (ssl->options.dtls) {
-        adj += DTLS_RECORD_EXTRA;
-        sz  -= DTLS_RECORD_EXTRA;
-    }
-#endif
-#ifndef NO_OLD_TLS
-#ifndef NO_SHA
-    wc_ShaUpdate(&ssl->hsHashes->hashSha, adj, sz);
-#endif
-#ifndef NO_MD5
-    wc_Md5Update(&ssl->hsHashes->hashMd5, adj, sz);
-#endif
-#endif
-
-    if (IsAtLeastTLSv1_2(ssl)) {
-        int ret;
-
-#ifndef NO_SHA256
-        ret = wc_Sha256Update(&ssl->hsHashes->hashSha256, adj, sz);
-        if (ret != 0)
-            return ret;
-#endif
-#ifdef WOLFSSL_SHA384
-        ret = wc_Sha384Update(&ssl->hsHashes->hashSha384, adj, sz);
-        if (ret != 0)
-            return ret;
-#endif
-#ifdef WOLFSSL_SHA512
-        ret = wc_Sha512Update(&ssl->hsHashes->hashSha512, adj, sz);
-        if (ret != 0)
-            return ret;
-#endif
-    }
-
-    return 0;
-}
-
-
-/* add input to md5 and sha handshake hashes, include handshake header */
-static int HashInput(WOLFSSL* ssl, const byte* input, int sz)
-{
-    const byte* adj = input - HANDSHAKE_HEADER_SZ;
-    sz += HANDSHAKE_HEADER_SZ;
-
-#ifdef WOLFSSL_DTLS
-    if (ssl->options.dtls) {
-        adj -= DTLS_HANDSHAKE_EXTRA;
-        sz  += DTLS_HANDSHAKE_EXTRA;
-    }
-#endif
-
-#ifndef NO_OLD_TLS
-#ifndef NO_SHA
-    wc_ShaUpdate(&ssl->hsHashes->hashSha, adj, sz);
-#endif
-#ifndef NO_MD5
-    wc_Md5Update(&ssl->hsHashes->hashMd5, adj, sz);
-#endif
-#endif
-
-    if (IsAtLeastTLSv1_2(ssl)) {
-        int ret;
-
-#ifndef NO_SHA256
-        ret = wc_Sha256Update(&ssl->hsHashes->hashSha256, adj, sz);
-        if (ret != 0)
-            return ret;
-#endif
-#ifdef WOLFSSL_SHA384
-        ret = wc_Sha384Update(&ssl->hsHashes->hashSha384, adj, sz);
-        if (ret != 0)
-            return ret;
-#endif
-#ifdef WOLFSSL_SHA512
-        ret = wc_Sha512Update(&ssl->hsHashes->hashSha512, adj, sz);
-        if (ret != 0)
-            return ret;
-#endif
-    }
-
-    return 0;
-}
-
-
-/* add record layer header for message */
-static void AddRecordHeader(byte* output, word32 length, byte type, WOLFSSL* ssl)
-{
-    RecordLayerHeader* rl;
-
-    /* record layer header */
-    rl = (RecordLayerHeader*)output;
-    rl->type    = type;
-    rl->pvMajor = ssl->version.major;       /* type and version same in each */
-    rl->pvMinor = ssl->version.minor;
-
-    if (!ssl->options.dtls)
-        c16toa((word16)length, rl->length);
-    else {
-#ifdef WOLFSSL_DTLS
-        DtlsRecordLayerHeader* dtls;
-
-        /* dtls record layer header extensions */
-        dtls = (DtlsRecordLayerHeader*)output;
-        c16toa(ssl->keys.dtls_epoch, dtls->epoch);
-        c32to48(ssl->keys.dtls_sequence_number++, dtls->sequence_number);
-        c16toa((word16)length, dtls->length);
-#endif
-    }
-}
-
-
-/* add handshake header for message */
-static void AddHandShakeHeader(byte* output, word32 length, byte type,
-                               WOLFSSL* ssl)
-{
-    HandShakeHeader* hs;
-    (void)ssl;
-
-    /* handshake header */
-    hs = (HandShakeHeader*)output;
-    hs->type = type;
-    c32to24(length, hs->length);         /* type and length same for each */
-#ifdef WOLFSSL_DTLS
-    if (ssl->options.dtls) {
-        DtlsHandShakeHeader* dtls;
-
-        /* dtls handshake header extensions */
-        dtls = (DtlsHandShakeHeader*)output;
-        c16toa(ssl->keys.dtls_handshake_number++, dtls->message_seq);
-        c32to24(0, dtls->fragment_offset);
-        c32to24(length, dtls->fragment_length);
-    }
-#endif
-}
-
-
-/* add both headers for handshake message */
-static void AddHeaders(byte* output, word32 length, byte type, WOLFSSL* ssl)
-{
-    if (!ssl->options.dtls) {
-        AddRecordHeader(output, length + HANDSHAKE_HEADER_SZ, handshake, ssl);
-        AddHandShakeHeader(output + RECORD_HEADER_SZ, length, type, ssl);
-    }
-#ifdef WOLFSSL_DTLS
-    else  {
-        AddRecordHeader(output, length+DTLS_HANDSHAKE_HEADER_SZ, handshake,ssl);
-        AddHandShakeHeader(output + DTLS_RECORD_HEADER_SZ, length, type, ssl);
-    }
-#endif
-}
-
-
-/* return bytes received, -1 on error */
-static int Receive(WOLFSSL* ssl, byte* buf, word32 sz)
-{
-    int recvd;
-
-    if (ssl->ctx->CBIORecv == NULL) {
-        WOLFSSL_MSG("Your IO Recv callback is null, please set");
-        return -1;
-    }
-
-retry:
-    recvd = ssl->ctx->CBIORecv(ssl, (char *)buf, (int)sz, ssl->IOCB_ReadCtx);
-    if (recvd < 0)
-        switch (recvd) {
-            case WOLFSSL_CBIO_ERR_GENERAL:        /* general/unknown error */
-                return -1;
-
-            case WOLFSSL_CBIO_ERR_WANT_READ:      /* want read, would block */
-                return WANT_READ;
-
-            case WOLFSSL_CBIO_ERR_CONN_RST:       /* connection reset */
-                #ifdef USE_WINDOWS_API
-                if (ssl->options.dtls) {
-                    goto retry;
-                }
-                #endif
-                ssl->options.connReset = 1;
-                return -1;
-
-            case WOLFSSL_CBIO_ERR_ISR:            /* interrupt */
-                /* see if we got our timeout */
-                #ifdef WOLFSSL_CALLBACKS
-                    if (ssl->toInfoOn) {
-                        struct itimerval timeout;
-                        getitimer(ITIMER_REAL, &timeout);
-                        if (timeout.it_value.tv_sec == 0 &&
-                                                timeout.it_value.tv_usec == 0) {
-                            XSTRNCPY(ssl->timeoutInfo.timeoutName,
-                                    "recv() timeout", MAX_TIMEOUT_NAME_SZ);
-                            WOLFSSL_MSG("Got our timeout");
-                            return WANT_READ;
-                        }
-                    }
-                #endif
-                goto retry;
-
-            case WOLFSSL_CBIO_ERR_CONN_CLOSE:     /* peer closed connection */
-                ssl->options.isClosed = 1;
-                return -1;
-
-            case WOLFSSL_CBIO_ERR_TIMEOUT:
-#ifdef WOLFSSL_DTLS
-                if (DtlsPoolTimeout(ssl) == 0 && DtlsPoolSend(ssl) == 0)
-                    goto retry;
-                else
-#endif
-                    return -1;
-
-            default:
-                return recvd;
-        }
-
-    return recvd;
-}
-
-
-/* Switch dynamic output buffer back to static, buffer is assumed clear */
-void ShrinkOutputBuffer(WOLFSSL* ssl)
-{
-    WOLFSSL_MSG("Shrinking output buffer\n");
-    XFREE(ssl->buffers.outputBuffer.buffer - ssl->buffers.outputBuffer.offset,
-          ssl->heap, DYNAMIC_TYPE_OUT_BUFFER);
-    ssl->buffers.outputBuffer.buffer = ssl->buffers.outputBuffer.staticBuffer;
-    ssl->buffers.outputBuffer.bufferSize  = STATIC_BUFFER_LEN;
-    ssl->buffers.outputBuffer.dynamicFlag = 0;
-    ssl->buffers.outputBuffer.offset      = 0;
-}
-
-
-/* Switch dynamic input buffer back to static, keep any remaining input */
-/* forced free means cleaning up */
-void ShrinkInputBuffer(WOLFSSL* ssl, int forcedFree)
-{
-    int usedLength = ssl->buffers.inputBuffer.length -
-                     ssl->buffers.inputBuffer.idx;
-    if (!forcedFree && usedLength > STATIC_BUFFER_LEN)
-        return;
-
-    WOLFSSL_MSG("Shrinking input buffer\n");
-
-    if (!forcedFree && usedLength)
-        XMEMCPY(ssl->buffers.inputBuffer.staticBuffer,
-               ssl->buffers.inputBuffer.buffer + ssl->buffers.inputBuffer.idx,
-               usedLength);
-
-    XFREE(ssl->buffers.inputBuffer.buffer - ssl->buffers.inputBuffer.offset,
-          ssl->heap, DYNAMIC_TYPE_IN_BUFFER);
-    ssl->buffers.inputBuffer.buffer = ssl->buffers.inputBuffer.staticBuffer;
-    ssl->buffers.inputBuffer.bufferSize  = STATIC_BUFFER_LEN;
-    ssl->buffers.inputBuffer.dynamicFlag = 0;
-    ssl->buffers.inputBuffer.offset      = 0;
-    ssl->buffers.inputBuffer.idx = 0;
-    ssl->buffers.inputBuffer.length = usedLength;
-}
-
-int SendBuffered(WOLFSSL* ssl)
-{
-    if (ssl->ctx->CBIOSend == NULL) {
-        WOLFSSL_MSG("Your IO Send callback is null, please set");
-        return SOCKET_ERROR_E;
-    }
-
-    while (ssl->buffers.outputBuffer.length > 0) {
-        int sent = ssl->ctx->CBIOSend(ssl,
-                                      (char*)ssl->buffers.outputBuffer.buffer +
-                                      ssl->buffers.outputBuffer.idx,
-                                      (int)ssl->buffers.outputBuffer.length,
-                                      ssl->IOCB_WriteCtx);
-        if (sent < 0) {
-            switch (sent) {
-
-                case WOLFSSL_CBIO_ERR_WANT_WRITE:        /* would block */
-                    return WANT_WRITE;
-
-                case WOLFSSL_CBIO_ERR_CONN_RST:          /* connection reset */
-                    ssl->options.connReset = 1;
-                    break;
-
-                case WOLFSSL_CBIO_ERR_ISR:               /* interrupt */
-                    /* see if we got our timeout */
-                    #ifdef WOLFSSL_CALLBACKS
-                        if (ssl->toInfoOn) {
-                            struct itimerval timeout;
-                            getitimer(ITIMER_REAL, &timeout);
-                            if (timeout.it_value.tv_sec == 0 &&
-                                                timeout.it_value.tv_usec == 0) {
-                                XSTRNCPY(ssl->timeoutInfo.timeoutName,
-                                        "send() timeout", MAX_TIMEOUT_NAME_SZ);
-                                WOLFSSL_MSG("Got our timeout");
-                                return WANT_WRITE;
-                            }
-                        }
-                    #endif
-                    continue;
-
-                case WOLFSSL_CBIO_ERR_CONN_CLOSE: /* epipe / conn closed */
-                    ssl->options.connReset = 1;  /* treat same as reset */
-                    break;
-
-                default:
-                    return SOCKET_ERROR_E;
-            }
-
-            return SOCKET_ERROR_E;
-        }
-
-        if (sent > (int)ssl->buffers.outputBuffer.length) {
-            WOLFSSL_MSG("SendBuffered() out of bounds read");
-            return SEND_OOB_READ_E;
-        }
-
-        ssl->buffers.outputBuffer.idx += sent;
-        ssl->buffers.outputBuffer.length -= sent;
-    }
-
-    ssl->buffers.outputBuffer.idx = 0;
-
-    if (ssl->buffers.outputBuffer.dynamicFlag)
-        ShrinkOutputBuffer(ssl);
-
-    return 0;
-}
-
-
-/* Grow the output buffer */
-static INLINE int GrowOutputBuffer(WOLFSSL* ssl, int size)
-{
-    byte* tmp;
-    byte  hdrSz = ssl->options.dtls ? DTLS_RECORD_HEADER_SZ :
-                                      RECORD_HEADER_SZ;
-    byte  align = WOLFSSL_GENERAL_ALIGNMENT;
-    /* the encrypted data will be offset from the front of the buffer by
-       the header, if the user wants encrypted alignment they need
-       to define their alignment requirement */
-
-    if (align) {
-       while (align < hdrSz)
-           align *= 2;
-    }
-
-    tmp = (byte*) XMALLOC(size + ssl->buffers.outputBuffer.length + align,
-                          ssl->heap, DYNAMIC_TYPE_OUT_BUFFER);
-    WOLFSSL_MSG("growing output buffer\n");
-
-    if (!tmp) return MEMORY_E;
-    if (align)
-        tmp += align - hdrSz;
-
-    if (ssl->buffers.outputBuffer.length)
-        XMEMCPY(tmp, ssl->buffers.outputBuffer.buffer,
-               ssl->buffers.outputBuffer.length);
-
-    if (ssl->buffers.outputBuffer.dynamicFlag)
-        XFREE(ssl->buffers.outputBuffer.buffer -
-              ssl->buffers.outputBuffer.offset, ssl->heap,
-              DYNAMIC_TYPE_OUT_BUFFER);
-    ssl->buffers.outputBuffer.dynamicFlag = 1;
-    if (align)
-        ssl->buffers.outputBuffer.offset = align - hdrSz;
-    else
-        ssl->buffers.outputBuffer.offset = 0;
-    ssl->buffers.outputBuffer.buffer = tmp;
-    ssl->buffers.outputBuffer.bufferSize = size +
-                                           ssl->buffers.outputBuffer.length;
-    return 0;
-}
-
-
-/* Grow the input buffer, should only be to read cert or big app data */
-int GrowInputBuffer(WOLFSSL* ssl, int size, int usedLength)
-{
-    byte* tmp;
-    byte  hdrSz = DTLS_RECORD_HEADER_SZ;
-    byte  align = ssl->options.dtls ? WOLFSSL_GENERAL_ALIGNMENT : 0;
-    /* the encrypted data will be offset from the front of the buffer by
-       the dtls record header, if the user wants encrypted alignment they need
-       to define their alignment requirement. in tls we read record header
-       to get size of record and put actual data back at front, so don't need */
-
-    if (align) {
-       while (align < hdrSz)
-           align *= 2;
-    }
-    tmp = (byte*) XMALLOC(size + usedLength + align, ssl->heap,
-                          DYNAMIC_TYPE_IN_BUFFER);
-    WOLFSSL_MSG("growing input buffer\n");
-
-    if (!tmp) return MEMORY_E;
-    if (align)
-        tmp += align - hdrSz;
-
-    if (usedLength)
-        XMEMCPY(tmp, ssl->buffers.inputBuffer.buffer +
-                    ssl->buffers.inputBuffer.idx, usedLength);
-
-    if (ssl->buffers.inputBuffer.dynamicFlag)
-        XFREE(ssl->buffers.inputBuffer.buffer - ssl->buffers.inputBuffer.offset,
-              ssl->heap,DYNAMIC_TYPE_IN_BUFFER);
-
-    ssl->buffers.inputBuffer.dynamicFlag = 1;
-    if (align)
-        ssl->buffers.inputBuffer.offset = align - hdrSz;
-    else
-        ssl->buffers.inputBuffer.offset = 0;
-    ssl->buffers.inputBuffer.buffer = tmp;
-    ssl->buffers.inputBuffer.bufferSize = size + usedLength;
-    ssl->buffers.inputBuffer.idx    = 0;
-    ssl->buffers.inputBuffer.length = usedLength;
-
-    return 0;
-}
-
-
-/* check available size into output buffer, make room if needed */
-int CheckAvailableSize(WOLFSSL *ssl, int size)
-{
-
-    if (size < 0) {
-        WOLFSSL_MSG("CheckAvailableSize() called with negative number");
-        return BAD_FUNC_ARG;
-    }
-
-    if (ssl->buffers.outputBuffer.bufferSize - ssl->buffers.outputBuffer.length
-                                             < (word32)size) {
-        if (GrowOutputBuffer(ssl, size) < 0)
-            return MEMORY_E;
-    }
-
-    return 0;
-}
-
-
-/* do all verify and sanity checks on record header */
-static int GetRecordHeader(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
-                           RecordLayerHeader* rh, word16 *size)
-{
-    if (!ssl->options.dtls) {
-#ifdef HAVE_FUZZER
-        if (ssl->fuzzerCb)
-            ssl->fuzzerCb(ssl, input + *inOutIdx, RECORD_HEADER_SZ, FUZZ_HEAD,
-                    ssl->fuzzerCtx);
-#endif
-        XMEMCPY(rh, input + *inOutIdx, RECORD_HEADER_SZ);
-        *inOutIdx += RECORD_HEADER_SZ;
-        ato16(rh->length, size);
-    }
-    else {
-#ifdef WOLFSSL_DTLS
-        /* type and version in same sport */
-        XMEMCPY(rh, input + *inOutIdx, ENUM_LEN + VERSION_SZ);
-        *inOutIdx += ENUM_LEN + VERSION_SZ;
-        ato16(input + *inOutIdx, &ssl->keys.dtls_state.curEpoch);
-        *inOutIdx += 4; /* advance past epoch, skip first 2 seq bytes for now */
-        ato32(input + *inOutIdx, &ssl->keys.dtls_state.curSeq);
-        *inOutIdx += 4;  /* advance past rest of seq */
-        ato16(input + *inOutIdx, size);
-        *inOutIdx += LENGTH_SZ;
-#ifdef HAVE_FUZZER
-        if (ssl->fuzzerCb)
-            ssl->fuzzerCb(ssl, input + *inOutIdx - LENGTH_SZ - 8 - ENUM_LEN -
-                           VERSION_SZ, ENUM_LEN + VERSION_SZ + 8 + LENGTH_SZ,
-                           FUZZ_HEAD, ssl->fuzzerCtx);
-#endif
-#endif
-    }
-
-    /* catch version mismatch */
-    if (rh->pvMajor != ssl->version.major || rh->pvMinor != ssl->version.minor){
-        if (ssl->options.side == WOLFSSL_SERVER_END &&
-            ssl->options.acceptState == ACCEPT_BEGIN)
-            WOLFSSL_MSG("Client attempting to connect with different version");
-        else if (ssl->options.side == WOLFSSL_CLIENT_END &&
-                                 ssl->options.downgrade &&
-                                 ssl->options.connectState < FIRST_REPLY_DONE)
-            WOLFSSL_MSG("Server attempting to accept with different version");
-        else {
-            WOLFSSL_MSG("SSL version error");
-            return VERSION_ERROR;              /* only use requested version */
-        }
-    }
-
-#ifdef WOLFSSL_DTLS
-    if (ssl->options.dtls) {
-        if (DtlsCheckWindow(&ssl->keys.dtls_state) != 1)
-            return SEQUENCE_ERROR;
-    }
-#endif
-
-    /* record layer length check */
-#ifdef HAVE_MAX_FRAGMENT
-    if (*size > (ssl->max_fragment + MAX_COMP_EXTRA + MAX_MSG_EXTRA)) {
-        SendAlert(ssl, alert_fatal, record_overflow);
-        return LENGTH_ERROR;
-    }
-#else
-    if (*size > (MAX_RECORD_SIZE + MAX_COMP_EXTRA + MAX_MSG_EXTRA))
-        return LENGTH_ERROR;
-#endif
-
-    /* verify record type here as well */
-    switch (rh->type) {
-        case handshake:
-        case change_cipher_spec:
-        case application_data:
-        case alert:
-            break;
-        case no_type:
-        default:
-            WOLFSSL_MSG("Unknown Record Type");
-            return UNKNOWN_RECORD_TYPE;
-    }
-
-    /* haven't decrypted this record yet */
-    ssl->keys.decryptedCur = 0;
-
-    return 0;
-}
-
-
-static int GetHandShakeHeader(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
-                              byte *type, word32 *size, word32 totalSz)
-{
-    const byte *ptr = input + *inOutIdx;
-    (void)ssl;
-
-    *inOutIdx += HANDSHAKE_HEADER_SZ;
-    if (*inOutIdx > totalSz)
-        return BUFFER_E;
-
-    *type = ptr[0];
-    c24to32(&ptr[1], size);
-
-    return 0;
-}
-
-
-#ifdef WOLFSSL_DTLS
-static int GetDtlsHandShakeHeader(WOLFSSL* ssl, const byte* input,
-                                  word32* inOutIdx, byte *type, word32 *size,
-                                  word32 *fragOffset, word32 *fragSz,
-                                  word32 totalSz)
-{
-    word32 idx = *inOutIdx;
-
-    *inOutIdx += HANDSHAKE_HEADER_SZ + DTLS_HANDSHAKE_EXTRA;
-    if (*inOutIdx > totalSz)
-        return BUFFER_E;
-
-    *type = input[idx++];
-    c24to32(input + idx, size);
-    idx += BYTE3_LEN;
-
-    ato16(input + idx, &ssl->keys.dtls_peer_handshake_number);
-    idx += DTLS_HANDSHAKE_SEQ_SZ;
-
-    c24to32(input + idx, fragOffset);
-    idx += DTLS_HANDSHAKE_FRAG_SZ;
-    c24to32(input + idx, fragSz);
-
-    return 0;
-}
-#endif
-
-
-#ifndef NO_OLD_TLS
-/* fill with MD5 pad size since biggest required */
-static const byte PAD1[PAD_MD5] =
-                              { 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
-                                0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
-                                0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
-                                0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
-                                0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
-                                0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36
-                              };
-static const byte PAD2[PAD_MD5] =
-                              { 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
-                                0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
-                                0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
-                                0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
-                                0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
-                                0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c
-                              };
-
-/* calculate MD5 hash for finished */
-#ifdef WOLFSSL_TI_HASH
-#include 
-#endif
-
-static void BuildMD5(WOLFSSL* ssl, Hashes* hashes, const byte* sender)
-{
-
-    byte md5_result[MD5_DIGEST_SIZE];
-
-#ifdef WOLFSSL_SMALL_STACK
-        Md5* md5   = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        Md5* md5_2 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#else
-        Md5 md5[1];
-        Md5 md5_2[1];
-#endif
-
-    /* make md5 inner */
-    md5[0] = ssl->hsHashes->hashMd5 ; /* Save current position */
-
-    wc_Md5Update(&ssl->hsHashes->hashMd5, sender, SIZEOF_SENDER);
-    wc_Md5Update(&ssl->hsHashes->hashMd5, ssl->arrays->masterSecret,SECRET_LEN);
-    wc_Md5Update(&ssl->hsHashes->hashMd5, PAD1, PAD_MD5);
-    wc_Md5GetHash(&ssl->hsHashes->hashMd5, md5_result);
-    wc_Md5RestorePos(&ssl->hsHashes->hashMd5, md5) ; /* Restore current position */
-
-    /* make md5 outer */
-    wc_InitMd5(md5_2) ;
-    wc_Md5Update(md5_2, ssl->arrays->masterSecret,SECRET_LEN);
-    wc_Md5Update(md5_2, PAD2, PAD_MD5);
-    wc_Md5Update(md5_2, md5_result, MD5_DIGEST_SIZE);
-    wc_Md5Final(md5_2, hashes->md5);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(md5_2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-}
-
-
-/* calculate SHA hash for finished */
-static void BuildSHA(WOLFSSL* ssl, Hashes* hashes, const byte* sender)
-{
-    byte sha_result[SHA_DIGEST_SIZE];
-
-#ifdef WOLFSSL_SMALL_STACK
-        Sha* sha = (Sha*)XMALLOC(sizeof(Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        Sha* sha2 = (Sha*)XMALLOC(sizeof(Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#else
-        Sha sha[1];
-        Sha sha2[1] ;
-#endif
-    /* make sha inner */
-    sha[0] = ssl->hsHashes->hashSha ; /* Save current position */
-
-    wc_ShaUpdate(&ssl->hsHashes->hashSha, sender, SIZEOF_SENDER);
-    wc_ShaUpdate(&ssl->hsHashes->hashSha, ssl->arrays->masterSecret,SECRET_LEN);
-    wc_ShaUpdate(&ssl->hsHashes->hashSha, PAD1, PAD_SHA);
-    wc_ShaGetHash(&ssl->hsHashes->hashSha, sha_result);
-    wc_ShaRestorePos(&ssl->hsHashes->hashSha, sha) ; /* Restore current position */
-
-    /* make sha outer */
-    wc_InitSha(sha2) ;
-    wc_ShaUpdate(sha2, ssl->arrays->masterSecret,SECRET_LEN);
-    wc_ShaUpdate(sha2, PAD2, PAD_SHA);
-    wc_ShaUpdate(sha2, sha_result, SHA_DIGEST_SIZE);
-    wc_ShaFinal(sha2, hashes->sha);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(sha2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-}
-#endif
-
-/* Finished doesn't support SHA512, not SHA512 cipher suites yet */
-static int BuildFinished(WOLFSSL* ssl, Hashes* hashes, const byte* sender)
-{
-    int ret = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    #ifdef WOLFSSL_SHA384
-        Sha384* sha384 = (Sha384*)XMALLOC(sizeof(Sha384), NULL,                                                                        DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-#else
-    #ifdef WOLFSSL_SHA384
-        Sha384 sha384[1];
-    #endif
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    if (ssl == NULL
-    #ifdef WOLFSSL_SHA384
-        || sha384 == NULL
-    #endif
-        ) {
-    #ifdef WOLFSSL_SHA384
-        XFREE(sha384, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-        return MEMORY_E;
-    }
-#endif
-
-    /* store current states, building requires get_digest which resets state */
-#ifdef WOLFSSL_SHA384
-    sha384[0] = ssl->hsHashes->hashSha384;
-#endif
-
-#ifndef NO_TLS
-    if (ssl->options.tls) {
-        ret = BuildTlsFinished(ssl, hashes, sender);
-    }
-#endif
-#ifndef NO_OLD_TLS
-    if (!ssl->options.tls) {
-        BuildMD5(ssl, hashes, sender);
-        BuildSHA(ssl, hashes, sender);
-    }
-#endif
-
-    /* restore */
-    if (IsAtLeastTLSv1_2(ssl)) {
-    #ifdef WOLFSSL_SHA384
-        ssl->hsHashes->hashSha384 = sha384[0];
-    #endif
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-#ifdef WOLFSSL_SHA384
-    XFREE(sha384, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-#endif
-
-    return ret;
-}
-
-
-    /* cipher requirements */
-    enum {
-        REQUIRES_RSA,
-        REQUIRES_DHE,
-        REQUIRES_ECC_DSA,
-        REQUIRES_ECC_STATIC,
-        REQUIRES_PSK,
-        REQUIRES_NTRU,
-        REQUIRES_RSA_SIG
-    };
-
-
-
-    /* Does this cipher suite (first, second) have the requirement
-       an ephemeral key exchange will still require the key for signing
-       the key exchange so ECHDE_RSA requires an rsa key thus rsa_kea */
-    static int CipherRequires(byte first, byte second, int requirement)
-    {
-
-        if (first == CHACHA_BYTE) {
-
-        switch (second) {
-
-        case TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 :
-            if (requirement == REQUIRES_ECC_DSA)
-                return 1;
-            break;
-
-        case TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            if (requirement == REQUIRES_DHE)
-                return 1;
-            break;
-            }
-        }
-
-        /* ECC extensions */
-        if (first == ECC_BYTE) {
-
-        switch (second) {
-
-#ifndef NO_RSA
-        case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA :
-            if (requirement == REQUIRES_ECC_STATIC)
-                return 1;
-            if (requirement == REQUIRES_RSA_SIG)
-                return 1;
-            break;
-
-#ifndef NO_DES3
-        case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA :
-            if (requirement == REQUIRES_ECC_STATIC)
-                return 1;
-            if (requirement == REQUIRES_RSA_SIG)
-                return 1;
-            break;
-#endif
-
-#ifndef NO_RC4
-        case TLS_ECDHE_RSA_WITH_RC4_128_SHA :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_ECDH_RSA_WITH_RC4_128_SHA :
-            if (requirement == REQUIRES_ECC_STATIC)
-                return 1;
-            if (requirement == REQUIRES_RSA_SIG)
-                return 1;
-            break;
-#endif
-#endif /* NO_RSA */
-
-#ifndef NO_DES3
-        case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA :
-            if (requirement == REQUIRES_ECC_DSA)
-                return 1;
-            break;
-
-        case TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA :
-            if (requirement == REQUIRES_ECC_STATIC)
-                return 1;
-            break;
-#endif
-#ifndef NO_RC4
-        case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA :
-            if (requirement == REQUIRES_ECC_DSA)
-                return 1;
-            break;
-
-        case TLS_ECDH_ECDSA_WITH_RC4_128_SHA :
-            if (requirement == REQUIRES_ECC_STATIC)
-                return 1;
-            break;
-#endif
-#ifndef NO_RSA
-        case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA :
-            if (requirement == REQUIRES_ECC_STATIC)
-                return 1;
-            if (requirement == REQUIRES_RSA_SIG)
-                return 1;
-            break;
-#endif
-
-        case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA :
-            if (requirement == REQUIRES_ECC_DSA)
-                return 1;
-            break;
-
-        case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA :
-            if (requirement == REQUIRES_ECC_STATIC)
-                return 1;
-            break;
-
-        case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA :
-            if (requirement == REQUIRES_ECC_DSA)
-                return 1;
-            break;
-
-        case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA :
-            if (requirement == REQUIRES_ECC_STATIC)
-                return 1;
-            break;
-
-        case TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 :
-            if (requirement == REQUIRES_ECC_DSA)
-                return 1;
-            break;
-
-        case TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 :
-            if (requirement == REQUIRES_ECC_DSA)
-                return 1;
-            break;
-
-        case TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 :
-            if (requirement == REQUIRES_ECC_STATIC)
-                return 1;
-            break;
-
-        case TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 :
-            if (requirement == REQUIRES_ECC_STATIC)
-                return 1;
-            break;
-
-#ifndef NO_RSA
-        case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 :
-            if (requirement == REQUIRES_ECC_STATIC)
-                return 1;
-            if (requirement == REQUIRES_RSA_SIG)
-                return 1;
-            break;
-
-        case TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 :
-            if (requirement == REQUIRES_ECC_STATIC)
-                return 1;
-            if (requirement == REQUIRES_RSA_SIG)
-                return 1;
-            break;
-
-        case TLS_RSA_WITH_AES_128_CCM_8 :
-        case TLS_RSA_WITH_AES_256_CCM_8 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            if (requirement == REQUIRES_RSA_SIG)
-                return 1;
-            break;
-
-        case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 :
-        case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            if (requirement == REQUIRES_RSA_SIG)
-                return 1;
-            break;
-
-        case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 :
-        case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 :
-            if (requirement == REQUIRES_RSA_SIG)
-                return 1;
-            if (requirement == REQUIRES_ECC_STATIC)
-                return 1;
-            break;
-#endif
-
-        case TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 :
-        case TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 :
-            if (requirement == REQUIRES_ECC_DSA)
-                return 1;
-            break;
-
-        case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 :
-        case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 :
-            if (requirement == REQUIRES_ECC_DSA)
-                return 1;
-            break;
-
-        case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 :
-        case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 :
-            if (requirement == REQUIRES_ECC_DSA)
-                return 1;
-            if (requirement == REQUIRES_ECC_STATIC)
-                return 1;
-            break;
-
-        case TLS_PSK_WITH_AES_128_CCM:
-        case TLS_PSK_WITH_AES_256_CCM:
-        case TLS_PSK_WITH_AES_128_CCM_8:
-        case TLS_PSK_WITH_AES_256_CCM_8:
-            if (requirement == REQUIRES_PSK)
-                return 1;
-            break;
-
-        case TLS_DHE_PSK_WITH_AES_128_CCM:
-        case TLS_DHE_PSK_WITH_AES_256_CCM:
-            if (requirement == REQUIRES_PSK)
-                return 1;
-            if (requirement == REQUIRES_DHE)
-                return 1;
-            break;
-
-        default:
-            WOLFSSL_MSG("Unsupported cipher suite, CipherRequires ECC");
-            return 0;
-        }   /* switch */
-        }   /* if     */
-        if (first != ECC_BYTE) {   /* normal suites */
-        switch (second) {
-
-#ifndef NO_RSA
-        case SSL_RSA_WITH_RC4_128_SHA :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_NTRU_RSA_WITH_RC4_128_SHA :
-            if (requirement == REQUIRES_NTRU)
-                return 1;
-            break;
-
-        case SSL_RSA_WITH_RC4_128_MD5 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case SSL_RSA_WITH_3DES_EDE_CBC_SHA :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA :
-            if (requirement == REQUIRES_NTRU)
-                return 1;
-            break;
-
-        case TLS_RSA_WITH_AES_128_CBC_SHA :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_RSA_WITH_AES_128_CBC_SHA256 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_NTRU_RSA_WITH_AES_128_CBC_SHA :
-            if (requirement == REQUIRES_NTRU)
-                return 1;
-            break;
-
-        case TLS_RSA_WITH_AES_256_CBC_SHA :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_RSA_WITH_AES_256_CBC_SHA256 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_RSA_WITH_NULL_SHA :
-        case TLS_RSA_WITH_NULL_SHA256 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_NTRU_RSA_WITH_AES_256_CBC_SHA :
-            if (requirement == REQUIRES_NTRU)
-                return 1;
-            break;
-#endif
-
-        case TLS_PSK_WITH_AES_128_GCM_SHA256 :
-        case TLS_PSK_WITH_AES_256_GCM_SHA384 :
-        case TLS_PSK_WITH_AES_128_CBC_SHA256 :
-        case TLS_PSK_WITH_AES_256_CBC_SHA384 :
-        case TLS_PSK_WITH_AES_128_CBC_SHA :
-        case TLS_PSK_WITH_AES_256_CBC_SHA :
-        case TLS_PSK_WITH_NULL_SHA384 :
-        case TLS_PSK_WITH_NULL_SHA256 :
-        case TLS_PSK_WITH_NULL_SHA :
-            if (requirement == REQUIRES_PSK)
-                return 1;
-            break;
-
-        case TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 :
-        case TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 :
-        case TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 :
-        case TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 :
-        case TLS_DHE_PSK_WITH_NULL_SHA384 :
-        case TLS_DHE_PSK_WITH_NULL_SHA256 :
-            if (requirement == REQUIRES_DHE)
-                return 1;
-            if (requirement == REQUIRES_PSK)
-                return 1;
-            break;
-
-#ifndef NO_RSA
-        case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            if (requirement == REQUIRES_DHE)
-                return 1;
-            break;
-
-        case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            if (requirement == REQUIRES_DHE)
-                return 1;
-            break;
-
-        case TLS_DHE_RSA_WITH_AES_128_CBC_SHA :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            if (requirement == REQUIRES_DHE)
-                return 1;
-            break;
-
-        case TLS_DHE_RSA_WITH_AES_256_CBC_SHA :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            if (requirement == REQUIRES_DHE)
-                return 1;
-            break;
-
-        case TLS_RSA_WITH_HC_128_MD5 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_RSA_WITH_HC_128_SHA :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_RSA_WITH_HC_128_B2B256:
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_RSA_WITH_AES_128_CBC_B2B256:
-        case TLS_RSA_WITH_AES_256_CBC_B2B256:
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_RSA_WITH_RABBIT_SHA :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_RSA_WITH_AES_128_GCM_SHA256 :
-        case TLS_RSA_WITH_AES_256_GCM_SHA384 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 :
-        case TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            if (requirement == REQUIRES_DHE)
-                return 1;
-            break;
-
-        case TLS_RSA_WITH_CAMELLIA_128_CBC_SHA :
-        case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA :
-        case TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 :
-        case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            break;
-
-        case TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA :
-        case TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA :
-        case TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 :
-        case TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 :
-            if (requirement == REQUIRES_RSA)
-                return 1;
-            if (requirement == REQUIRES_RSA_SIG)
-                return 1;
-            if (requirement == REQUIRES_DHE)
-                return 1;
-            break;
-#endif
-#ifdef HAVE_ANON
-        case TLS_DH_anon_WITH_AES_128_CBC_SHA :
-            if (requirement == REQUIRES_DHE)
-                return 1;
-            break;
-#endif
-
-        default:
-            WOLFSSL_MSG("Unsupported cipher suite, CipherRequires");
-            return 0;
-        }  /* switch */
-        }  /* if ECC / Normal suites else */
-
-        return 0;
-    }
-
-
-#ifndef NO_CERTS
-
-
-/* Match names with wildcards, each wildcard can represent a single name
-   component or fragment but not mulitple names, i.e.,
-   *.z.com matches y.z.com but not x.y.z.com
-
-   return 1 on success */
-static int MatchDomainName(const char* pattern, int len, const char* str)
-{
-    char p, s;
-
-    if (pattern == NULL || str == NULL || len <= 0)
-        return 0;
-
-    while (len > 0) {
-
-        p = (char)XTOLOWER((unsigned char)*pattern++);
-        if (p == 0)
-            break;
-
-        if (p == '*') {
-            while (--len > 0 &&
-                         (p = (char)XTOLOWER((unsigned char)*pattern++)) == '*')
-                ;
-
-            if (len == 0)
-                p = '\0';
-
-            while ( (s = (char)XTOLOWER((unsigned char) *str)) != '\0') {
-                if (s == p)
-                    break;
-                if (s == '.')
-                    return 0;
-                str++;
-            }
-        }
-        else {
-            if (p != (char)XTOLOWER((unsigned char) *str))
-                return 0;
-        }
-
-        if (*str != '\0')
-            str++;
-
-        if (len > 0)
-            len--;
-    }
-
-    return *str == '\0';
-}
-
-
-/* try to find an altName match to domain, return 1 on success */
-static int CheckAltNames(DecodedCert* dCert, char* domain)
-{
-    int        match = 0;
-    DNS_entry* altName = NULL;
-
-    WOLFSSL_MSG("Checking AltNames");
-
-    if (dCert)
-        altName = dCert->altNames;
-
-    while (altName) {
-        WOLFSSL_MSG("    individual AltName check");
-
-        if (MatchDomainName(altName->name,(int)XSTRLEN(altName->name), domain)){
-            match = 1;
-            break;
-        }
-
-        altName = altName->next;
-    }
-
-    return match;
-}
-
-
-#if defined(KEEP_PEER_CERT) || defined(SESSION_CERTS)
-
-/* Copy parts X509 needs from Decoded cert, 0 on success */
-int CopyDecodedToX509(WOLFSSL_X509* x509, DecodedCert* dCert)
-{
-    int ret = 0;
-
-    if (x509 == NULL || dCert == NULL)
-        return BAD_FUNC_ARG;
-
-    x509->version = dCert->version + 1;
-
-    XSTRNCPY(x509->issuer.name, dCert->issuer, ASN_NAME_MAX);
-    x509->issuer.name[ASN_NAME_MAX - 1] = '\0';
-    x509->issuer.sz = (int)XSTRLEN(x509->issuer.name) + 1;
-#ifdef OPENSSL_EXTRA
-    if (dCert->issuerName.fullName != NULL) {
-        XMEMCPY(&x509->issuer.fullName,
-                                       &dCert->issuerName, sizeof(DecodedName));
-        x509->issuer.fullName.fullName = (char*)XMALLOC(
-                        dCert->issuerName.fullNameLen, NULL, DYNAMIC_TYPE_X509);
-        if (x509->issuer.fullName.fullName != NULL)
-            XMEMCPY(x509->issuer.fullName.fullName,
-                     dCert->issuerName.fullName, dCert->issuerName.fullNameLen);
-    }
-#endif /* OPENSSL_EXTRA */
-
-    XSTRNCPY(x509->subject.name, dCert->subject, ASN_NAME_MAX);
-    x509->subject.name[ASN_NAME_MAX - 1] = '\0';
-    x509->subject.sz = (int)XSTRLEN(x509->subject.name) + 1;
-#ifdef OPENSSL_EXTRA
-    if (dCert->subjectName.fullName != NULL) {
-        XMEMCPY(&x509->subject.fullName,
-                                      &dCert->subjectName, sizeof(DecodedName));
-        x509->subject.fullName.fullName = (char*)XMALLOC(
-                       dCert->subjectName.fullNameLen, NULL, DYNAMIC_TYPE_X509);
-        if (x509->subject.fullName.fullName != NULL)
-            XMEMCPY(x509->subject.fullName.fullName,
-                   dCert->subjectName.fullName, dCert->subjectName.fullNameLen);
-    }
-#endif /* OPENSSL_EXTRA */
-
-    XMEMCPY(x509->serial, dCert->serial, EXTERNAL_SERIAL_SIZE);
-    x509->serialSz = dCert->serialSz;
-    if (dCert->subjectCNLen < ASN_NAME_MAX) {
-        XMEMCPY(x509->subjectCN, dCert->subjectCN, dCert->subjectCNLen);
-        x509->subjectCN[dCert->subjectCNLen] = '\0';
-    }
-    else
-        x509->subjectCN[0] = '\0';
-
-#ifdef WOLFSSL_SEP
-    {
-        int minSz = min(dCert->deviceTypeSz, EXTERNAL_SERIAL_SIZE);
-        if (minSz > 0) {
-            x509->deviceTypeSz = minSz;
-            XMEMCPY(x509->deviceType, dCert->deviceType, minSz);
-        }
-        else
-            x509->deviceTypeSz = 0;
-        minSz = min(dCert->hwTypeSz, EXTERNAL_SERIAL_SIZE);
-        if (minSz != 0) {
-            x509->hwTypeSz = minSz;
-            XMEMCPY(x509->hwType, dCert->hwType, minSz);
-        }
-        else
-            x509->hwTypeSz = 0;
-        minSz = min(dCert->hwSerialNumSz, EXTERNAL_SERIAL_SIZE);
-        if (minSz != 0) {
-            x509->hwSerialNumSz = minSz;
-            XMEMCPY(x509->hwSerialNum, dCert->hwSerialNum, minSz);
-        }
-        else
-            x509->hwSerialNumSz = 0;
-    }
-#endif /* WOLFSSL_SEP */
-    {
-        int minSz = min(dCert->beforeDateLen, MAX_DATE_SZ);
-        if (minSz != 0) {
-            x509->notBeforeSz = minSz;
-            XMEMCPY(x509->notBefore, dCert->beforeDate, minSz);
-        }
-        else
-            x509->notBeforeSz = 0;
-        minSz = min(dCert->afterDateLen, MAX_DATE_SZ);
-        if (minSz != 0) {
-            x509->notAfterSz = minSz;
-            XMEMCPY(x509->notAfter, dCert->afterDate, minSz);
-        }
-        else
-            x509->notAfterSz = 0;
-    }
-
-    if (dCert->publicKey != NULL && dCert->pubKeySize != 0) {
-        x509->pubKey.buffer = (byte*)XMALLOC(
-                              dCert->pubKeySize, NULL, DYNAMIC_TYPE_PUBLIC_KEY);
-        if (x509->pubKey.buffer != NULL) {
-            x509->pubKeyOID = dCert->keyOID;
-            x509->pubKey.length = dCert->pubKeySize;
-            XMEMCPY(x509->pubKey.buffer, dCert->publicKey, dCert->pubKeySize);
-        }
-        else
-            ret = MEMORY_E;
-    }
-
-    if (dCert->signature != NULL && dCert->sigLength != 0) {
-        x509->sig.buffer = (byte*)XMALLOC(
-                                dCert->sigLength, NULL, DYNAMIC_TYPE_SIGNATURE);
-        if (x509->sig.buffer == NULL) {
-            ret = MEMORY_E;
-        }
-        else {
-            XMEMCPY(x509->sig.buffer, dCert->signature, dCert->sigLength);
-            x509->sig.length = dCert->sigLength;
-            x509->sigOID = dCert->signatureOID;
-        }
-    }
-
-    /* store cert for potential retrieval */
-    x509->derCert.buffer = (byte*)XMALLOC(dCert->maxIdx, NULL,
-                                          DYNAMIC_TYPE_CERT);
-    if (x509->derCert.buffer == NULL) {
-        ret = MEMORY_E;
-    }
-    else {
-        XMEMCPY(x509->derCert.buffer, dCert->source, dCert->maxIdx);
-        x509->derCert.length = dCert->maxIdx;
-    }
-
-    x509->altNames       = dCert->altNames;
-    dCert->weOwnAltNames = 0;
-    x509->altNamesNext   = x509->altNames;  /* index hint */
-
-    x509->isCa = dCert->isCA;
-#ifdef OPENSSL_EXTRA
-    x509->pathLength = dCert->pathLength;
-    x509->keyUsage = dCert->extKeyUsage;
-
-    x509->basicConstSet = dCert->extBasicConstSet;
-    x509->basicConstCrit = dCert->extBasicConstCrit;
-    x509->basicConstPlSet = dCert->extBasicConstPlSet;
-    x509->subjAltNameSet = dCert->extSubjAltNameSet;
-    x509->subjAltNameCrit = dCert->extSubjAltNameCrit;
-    x509->authKeyIdSet = dCert->extAuthKeyIdSet;
-    x509->authKeyIdCrit = dCert->extAuthKeyIdCrit;
-    if (dCert->extAuthKeyIdSrc != NULL && dCert->extAuthKeyIdSz != 0) {
-        x509->authKeyId = (byte*)XMALLOC(dCert->extAuthKeyIdSz, NULL, 0);
-        if (x509->authKeyId != NULL) {
-            XMEMCPY(x509->authKeyId,
-                                 dCert->extAuthKeyIdSrc, dCert->extAuthKeyIdSz);
-            x509->authKeyIdSz = dCert->extAuthKeyIdSz;
-        }
-        else
-            ret = MEMORY_E;
-    }
-    x509->subjKeyIdSet = dCert->extSubjKeyIdSet;
-    x509->subjKeyIdCrit = dCert->extSubjKeyIdCrit;
-    if (dCert->extSubjKeyIdSrc != NULL && dCert->extSubjKeyIdSz != 0) {
-        x509->subjKeyId = (byte*)XMALLOC(dCert->extSubjKeyIdSz, NULL, 0);
-        if (x509->subjKeyId != NULL) {
-            XMEMCPY(x509->subjKeyId,
-                                 dCert->extSubjKeyIdSrc, dCert->extSubjKeyIdSz);
-            x509->subjKeyIdSz = dCert->extSubjKeyIdSz;
-        }
-        else
-            ret = MEMORY_E;
-    }
-    x509->keyUsageSet = dCert->extKeyUsageSet;
-    x509->keyUsageCrit = dCert->extKeyUsageCrit;
-    #ifdef WOLFSSL_SEP
-        x509->certPolicySet = dCert->extCertPolicySet;
-        x509->certPolicyCrit = dCert->extCertPolicyCrit;
-    #endif /* WOLFSSL_SEP */
-#endif /* OPENSSL_EXTRA */
-#ifdef HAVE_ECC
-    x509->pkCurveOID = dCert->pkCurveOID;
-#endif /* HAVE_ECC */
-
-    return ret;
-}
-
-#endif /* KEEP_PEER_CERT || SESSION_CERTS */
-
-
-static int DoCertificate(WOLFSSL* ssl, byte* input, word32* inOutIdx,
-                                                                    word32 size)
-{
-    word32 listSz;
-    word32 begin = *inOutIdx;
-    int    ret = 0;
-    int    anyError = 0;
-    int    totalCerts = 0;    /* number of certs in certs buffer */
-    int    count;
-    buffer certs[MAX_CHAIN_DEPTH];
-
-#ifdef WOLFSSL_SMALL_STACK
-    char*                  domain = NULL;
-    DecodedCert*           dCert  = NULL;
-    WOLFSSL_X509_STORE_CTX* store  = NULL;
-#else
-    char                   domain[ASN_NAME_MAX];
-    DecodedCert            dCert[1];
-    WOLFSSL_X509_STORE_CTX  store[1];
-#endif
-
-    #ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn) AddPacketName("Certificate", &ssl->handShakeInfo);
-        if (ssl->toInfoOn) AddLateName("Certificate", &ssl->timeoutInfo);
-    #endif
-
-    if ((*inOutIdx - begin) + OPAQUE24_LEN > size)
-        return BUFFER_ERROR;
-
-    c24to32(input + *inOutIdx, &listSz);
-    *inOutIdx += OPAQUE24_LEN;
-
-#ifdef HAVE_MAX_FRAGMENT
-    if (listSz > ssl->max_fragment) {
-        SendAlert(ssl, alert_fatal, record_overflow);
-        return BUFFER_E;
-    }
-#else
-    if (listSz > MAX_RECORD_SIZE)
-        return BUFFER_E;
-#endif
-
-    if ((*inOutIdx - begin) + listSz != size)
-        return BUFFER_ERROR;
-
-    WOLFSSL_MSG("Loading peer's cert chain");
-    /* first put cert chain into buffer so can verify top down
-       we're sent bottom up */
-    while (listSz) {
-        word32 certSz;
-
-        if (totalCerts >= MAX_CHAIN_DEPTH)
-            return MAX_CHAIN_ERROR;
-
-        if ((*inOutIdx - begin) + OPAQUE24_LEN > size)
-            return BUFFER_ERROR;
-
-        c24to32(input + *inOutIdx, &certSz);
-        *inOutIdx += OPAQUE24_LEN;
-
-        if ((*inOutIdx - begin) + certSz > size)
-            return BUFFER_ERROR;
-
-        certs[totalCerts].length = certSz;
-        certs[totalCerts].buffer = input + *inOutIdx;
-
-#ifdef SESSION_CERTS
-        if (ssl->session.chain.count < MAX_CHAIN_DEPTH &&
-                                       certSz < MAX_X509_SIZE) {
-            ssl->session.chain.certs[ssl->session.chain.count].length = certSz;
-            XMEMCPY(ssl->session.chain.certs[ssl->session.chain.count].buffer,
-                    input + *inOutIdx, certSz);
-            ssl->session.chain.count++;
-        } else {
-            WOLFSSL_MSG("Couldn't store chain cert for session");
-        }
-#endif
-
-        *inOutIdx += certSz;
-        listSz -= certSz + CERT_HEADER_SZ;
-
-        totalCerts++;
-        WOLFSSL_MSG("    Put another cert into chain");
-    }
-
-    count = totalCerts;
-
-#ifdef WOLFSSL_SMALL_STACK
-    dCert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (dCert == NULL)
-        return MEMORY_E;
-#endif
-
-    /* verify up to peer's first */
-    while (count > 1) {
-        buffer myCert = certs[count - 1];
-        byte* subjectHash;
-
-        InitDecodedCert(dCert, myCert.buffer, myCert.length, ssl->heap);
-        ret = ParseCertRelative(dCert, CERT_TYPE, !ssl->options.verifyNone,
-                                ssl->ctx->cm);
-        #ifndef NO_SKID
-            subjectHash = dCert->extSubjKeyId;
-        #else
-            subjectHash = dCert->subjectHash;
-        #endif
-
-        if (ret == 0 && dCert->isCA == 0) {
-            WOLFSSL_MSG("Chain cert is not a CA, not adding as one");
-        }
-        else if (ret == 0 && ssl->options.verifyNone) {
-            WOLFSSL_MSG("Chain cert not verified by option, not adding as CA");
-        }
-        else if (ret == 0 && !AlreadySigner(ssl->ctx->cm, subjectHash)) {
-            buffer add;
-            add.length = myCert.length;
-            add.buffer = (byte*)XMALLOC(myCert.length, ssl->heap,
-                                        DYNAMIC_TYPE_CA);
-            WOLFSSL_MSG("Adding CA from chain");
-
-            if (add.buffer == NULL)
-                return MEMORY_E;
-            XMEMCPY(add.buffer, myCert.buffer, myCert.length);
-
-            ret = AddCA(ssl->ctx->cm, add, WOLFSSL_CHAIN_CA,
-                        ssl->ctx->verifyPeer);
-            if (ret == 1) ret = 0;   /* SSL_SUCCESS for external */
-        }
-        else if (ret != 0) {
-            WOLFSSL_MSG("Failed to verify CA from chain");
-        }
-        else {
-            WOLFSSL_MSG("Verified CA from chain and already had it");
-        }
-
-#if defined(HAVE_OCSP) || defined(HAVE_CRL)
-        if (ret == 0) {
-            int doCrlLookup = 1;
-            (void)doCrlLookup;
-#ifdef HAVE_OCSP
-            if (ssl->ctx->cm->ocspEnabled && ssl->ctx->cm->ocspCheckAll) {
-                WOLFSSL_MSG("Doing Non Leaf OCSP check");
-                ret = CheckCertOCSP(ssl->ctx->cm->ocsp, dCert);
-                doCrlLookup = (ret == OCSP_CERT_UNKNOWN);
-                if (ret != 0) {
-                    doCrlLookup = 0;
-                    WOLFSSL_MSG("\tOCSP Lookup not ok");
-                }
-            }
-#endif /* HAVE_OCSP */
-
-#ifdef HAVE_CRL
-            if (doCrlLookup && ssl->ctx->cm->crlEnabled
-                                                 && ssl->ctx->cm->crlCheckAll) {
-                WOLFSSL_MSG("Doing Non Leaf CRL check");
-                ret = CheckCertCRL(ssl->ctx->cm->crl, dCert);
-
-                if (ret != 0) {
-                    WOLFSSL_MSG("\tCRL check not ok");
-                }
-            }
-#endif /* HAVE_CRL */
-        }
-#endif /* HAVE_OCSP || HAVE_CRL */
-
-        if (ret != 0 && anyError == 0)
-            anyError = ret;   /* save error from last time */
-
-        FreeDecodedCert(dCert);
-        count--;
-    }
-
-    /* peer's, may not have one if blank client cert sent by TLSv1.2 */
-    if (count) {
-        buffer myCert = certs[0];
-        int    fatal  = 0;
-
-        WOLFSSL_MSG("Verifying Peer's cert");
-
-        InitDecodedCert(dCert, myCert.buffer, myCert.length, ssl->heap);
-        ret = ParseCertRelative(dCert, CERT_TYPE, !ssl->options.verifyNone,
-                                ssl->ctx->cm);
-        if (ret == 0) {
-            WOLFSSL_MSG("Verified Peer's cert");
-            fatal = 0;
-        }
-        else if (ret == ASN_PARSE_E) {
-            WOLFSSL_MSG("Got Peer cert ASN PARSE ERROR, fatal");
-            fatal = 1;
-        }
-        else {
-            WOLFSSL_MSG("Failed to verify Peer's cert");
-            if (ssl->verifyCallback) {
-                WOLFSSL_MSG("\tCallback override available, will continue");
-                fatal = 0;
-            }
-            else {
-                WOLFSSL_MSG("\tNo callback override available, fatal");
-                fatal = 1;
-            }
-        }
-
-#ifdef HAVE_SECURE_RENEGOTIATION
-        if (fatal == 0 && ssl->secure_renegotiation
-                       && ssl->secure_renegotiation->enabled) {
-
-            if (ssl->keys.encryptionOn) {
-                /* compare against previous time */
-                if (XMEMCMP(dCert->subjectHash,
-                            ssl->secure_renegotiation->subject_hash,
-                            SHA_DIGEST_SIZE) != 0) {
-                    WOLFSSL_MSG("Peer sent different cert during scr, fatal");
-                    fatal = 1;
-                    ret   = SCR_DIFFERENT_CERT_E;
-                }
-            }
-
-            /* cache peer's hash */
-            if (fatal == 0) {
-                XMEMCPY(ssl->secure_renegotiation->subject_hash,
-                        dCert->subjectHash, SHA_DIGEST_SIZE);
-            }
-        }
-#endif
-
-#if defined(HAVE_OCSP) || defined(HAVE_CRL)
-        if (fatal == 0) {
-            int doCrlLookup = 1;
-            (void)doCrlLookup;
-#ifdef HAVE_OCSP
-            if (ssl->ctx->cm->ocspEnabled) {
-                ret = CheckCertOCSP(ssl->ctx->cm->ocsp, dCert);
-                doCrlLookup = (ret == OCSP_CERT_UNKNOWN);
-                if (ret != 0) {
-                    WOLFSSL_MSG("\tOCSP Lookup not ok");
-                    fatal = 0;
-                }
-            }
-#endif /* HAVE_OCSP */
-
-#ifdef HAVE_CRL
-            if (doCrlLookup && ssl->ctx->cm->crlEnabled) {
-                WOLFSSL_MSG("Doing Leaf CRL check");
-                ret = CheckCertCRL(ssl->ctx->cm->crl, dCert);
-                if (ret != 0) {
-                    WOLFSSL_MSG("\tCRL check not ok");
-                    fatal = 0;
-                }
-            }
-#endif /* HAVE_CRL */
-        }
-#endif /* HAVE_OCSP || HAVE_CRL */
-
-#ifdef KEEP_PEER_CERT
-        {
-        /* set X509 format for peer cert even if fatal */
-        int copyRet = CopyDecodedToX509(&ssl->peerCert, dCert);
-        if (copyRet == MEMORY_E)
-            fatal = 1;
-        }
-#endif
-
-#ifndef IGNORE_KEY_EXTENSIONS
-        if (dCert->extKeyUsageSet) {
-            if ((ssl->specs.kea == rsa_kea) &&
-                (dCert->extKeyUsage & KEYUSE_KEY_ENCIPHER) == 0) {
-                ret = KEYUSE_ENCIPHER_E;
-            }
-            if ((ssl->specs.sig_algo == rsa_sa_algo ||
-                    (ssl->specs.sig_algo == ecc_dsa_sa_algo &&
-                         !ssl->specs.static_ecdh)) &&
-                (dCert->extKeyUsage & KEYUSE_DIGITAL_SIG) == 0) {
-                WOLFSSL_MSG("KeyUse Digital Sig not set");
-                ret = KEYUSE_SIGNATURE_E;
-            }
-        }
-
-        if (dCert->extExtKeyUsageSet) {
-            if (ssl->options.side == WOLFSSL_CLIENT_END) {
-                if ((dCert->extExtKeyUsage &
-                        (EXTKEYUSE_ANY | EXTKEYUSE_SERVER_AUTH)) == 0) {
-                    WOLFSSL_MSG("ExtKeyUse Server Auth not set");
-                    ret = EXTKEYUSE_AUTH_E;
-                }
-            }
-            else {
-                if ((dCert->extExtKeyUsage &
-                        (EXTKEYUSE_ANY | EXTKEYUSE_CLIENT_AUTH)) == 0) {
-                    WOLFSSL_MSG("ExtKeyUse Client Auth not set");
-                    ret = EXTKEYUSE_AUTH_E;
-                }
-            }
-        }
-#endif /* IGNORE_KEY_EXTENSIONS */
-
-        if (fatal) {
-            FreeDecodedCert(dCert);
-        #ifdef WOLFSSL_SMALL_STACK
-            XFREE(dCert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        #endif
-            ssl->error = ret;
-            return ret;
-        }
-        ssl->options.havePeerCert = 1;
-
-#ifdef WOLFSSL_SMALL_STACK
-        domain = (char*)XMALLOC(ASN_NAME_MAX, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (domain == NULL) {
-            FreeDecodedCert(dCert);
-            XFREE(dCert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            return MEMORY_E;
-        }
-#endif
-        /* store for callback use */
-        if (dCert->subjectCNLen < ASN_NAME_MAX) {
-            XMEMCPY(domain, dCert->subjectCN, dCert->subjectCNLen);
-            domain[dCert->subjectCNLen] = '\0';
-        }
-        else
-            domain[0] = '\0';
-
-        if (!ssl->options.verifyNone && ssl->buffers.domainName.buffer) {
-            if (MatchDomainName(dCert->subjectCN, dCert->subjectCNLen,
-                                (char*)ssl->buffers.domainName.buffer) == 0) {
-                WOLFSSL_MSG("DomainName match on common name failed");
-                if (CheckAltNames(dCert,
-                                 (char*)ssl->buffers.domainName.buffer) == 0 ) {
-                    WOLFSSL_MSG("DomainName match on alt names failed too");
-                    ret = DOMAIN_NAME_MISMATCH; /* try to get peer key still */
-                }
-            }
-        }
-
-        /* decode peer key */
-        switch (dCert->keyOID) {
-        #ifndef NO_RSA
-            case RSAk:
-                {
-                    word32 idx = 0;
-                    int    keyRet = 0;
-
-                    if (ssl->peerRsaKey == NULL) {
-                        ssl->peerRsaKey = (RsaKey*)XMALLOC(sizeof(RsaKey),
-                                                   ssl->heap, DYNAMIC_TYPE_RSA);
-                        if (ssl->peerRsaKey == NULL) {
-                            WOLFSSL_MSG("PeerRsaKey Memory error");
-                            keyRet = MEMORY_E;
-                        } else {
-                            keyRet = wc_InitRsaKey(ssl->peerRsaKey,
-                                                   ssl->ctx->heap);
-                        }
-                    } else if (ssl->peerRsaKeyPresent) {
-                        /* don't leak on reuse */
-                        wc_FreeRsaKey(ssl->peerRsaKey);
-                        ssl->peerRsaKeyPresent = 0;
-                        keyRet = wc_InitRsaKey(ssl->peerRsaKey, ssl->heap);
-                    }
-
-                    if (keyRet != 0 || wc_RsaPublicKeyDecode(dCert->publicKey,
-                               &idx, ssl->peerRsaKey, dCert->pubKeySize) != 0) {
-                        ret = PEER_KEY_ERROR;
-                    }
-                    else {
-                        ssl->peerRsaKeyPresent = 1;
-                        #ifdef HAVE_PK_CALLBACKS
-                            #ifndef NO_RSA
-                                ssl->buffers.peerRsaKey.buffer =
-                                       (byte*)XMALLOC(dCert->pubKeySize,
-                                               ssl->heap, DYNAMIC_TYPE_RSA);
-                                if (ssl->buffers.peerRsaKey.buffer == NULL)
-                                    ret = MEMORY_ERROR;
-                                else {
-                                    XMEMCPY(ssl->buffers.peerRsaKey.buffer,
-                                           dCert->publicKey, dCert->pubKeySize);
-                                    ssl->buffers.peerRsaKey.length =
-                                            dCert->pubKeySize;
-                                }
-                            #endif /* NO_RSA */
-                        #endif /*HAVE_PK_CALLBACKS */
-                    }
-                }
-                break;
-        #endif /* NO_RSA */
-        #ifdef HAVE_NTRU
-            case NTRUk:
-                {
-                    if (dCert->pubKeySize > sizeof(ssl->peerNtruKey)) {
-                        ret = PEER_KEY_ERROR;
-                    }
-                    else {
-                        XMEMCPY(ssl->peerNtruKey, dCert->publicKey,
-                                                             dCert->pubKeySize);
-                        ssl->peerNtruKeyLen = (word16)dCert->pubKeySize;
-                        ssl->peerNtruKeyPresent = 1;
-                    }
-                }
-                break;
-        #endif /* HAVE_NTRU */
-        #ifdef HAVE_ECC
-            case ECDSAk:
-                {
-                    if (ssl->peerEccDsaKey == NULL) {
-                        /* alloc/init on demand */
-                        ssl->peerEccDsaKey = (ecc_key*)XMALLOC(sizeof(ecc_key),
-                                              ssl->ctx->heap, DYNAMIC_TYPE_ECC);
-                        if (ssl->peerEccDsaKey == NULL) {
-                            WOLFSSL_MSG("PeerEccDsaKey Memory error");
-                            return MEMORY_E;
-                        }
-                        wc_ecc_init(ssl->peerEccDsaKey);
-                    } else if (ssl->peerEccDsaKeyPresent) {
-                        /* don't leak on reuse */
-                        wc_ecc_free(ssl->peerEccDsaKey);
-                        ssl->peerEccDsaKeyPresent = 0;
-                        wc_ecc_init(ssl->peerEccDsaKey);
-                    }
-                    if (wc_ecc_import_x963(dCert->publicKey, dCert->pubKeySize,
-                                        ssl->peerEccDsaKey) != 0) {
-                        ret = PEER_KEY_ERROR;
-                    }
-                    else {
-                        ssl->peerEccDsaKeyPresent = 1;
-                        #ifdef HAVE_PK_CALLBACKS
-                            #ifdef HAVE_ECC
-                                ssl->buffers.peerEccDsaKey.buffer =
-                                       (byte*)XMALLOC(dCert->pubKeySize,
-                                               ssl->heap, DYNAMIC_TYPE_ECC);
-                                if (ssl->buffers.peerEccDsaKey.buffer == NULL)
-                                    ret = MEMORY_ERROR;
-                                else {
-                                    XMEMCPY(ssl->buffers.peerEccDsaKey.buffer,
-                                           dCert->publicKey, dCert->pubKeySize);
-                                    ssl->buffers.peerEccDsaKey.length =
-                                            dCert->pubKeySize;
-                                }
-                            #endif /* HAVE_ECC */
-                        #endif /*HAVE_PK_CALLBACKS */
-                    }
-                }
-                break;
-        #endif /* HAVE_ECC */
-            default:
-                break;
-        }
-
-        FreeDecodedCert(dCert);
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(dCert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-    store = (WOLFSSL_X509_STORE_CTX*)XMALLOC(sizeof(WOLFSSL_X509_STORE_CTX),
-                                                 NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (store == NULL) {
-        XFREE(domain, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#endif
-
-    if (anyError != 0 && ret == 0)
-        ret = anyError;
-
-    if (ret != 0) {
-        if (!ssl->options.verifyNone) {
-            int why = bad_certificate;
-
-            if (ret == ASN_AFTER_DATE_E || ret == ASN_BEFORE_DATE_E)
-                why = certificate_expired;
-            if (ssl->verifyCallback) {
-                int ok;
-
-                store->error = ret;
-                store->error_depth = totalCerts;
-                store->discardSessionCerts = 0;
-                store->domain = domain;
-                store->userCtx = ssl->verifyCbCtx;
-#ifdef KEEP_PEER_CERT
-                store->current_cert = &ssl->peerCert;
-#else
-                store->current_cert = NULL;
-#endif
-#ifdef FORTRESS
-                store->ex_data = ssl;
-#endif
-                ok = ssl->verifyCallback(0, store);
-                if (ok) {
-                    WOLFSSL_MSG("Verify callback overriding error!");
-                    ret = 0;
-                }
-                #ifdef SESSION_CERTS
-                if (store->discardSessionCerts) {
-                    WOLFSSL_MSG("Verify callback requested discard sess certs");
-                    ssl->session.chain.count = 0;
-                }
-                #endif
-            }
-            if (ret != 0) {
-                SendAlert(ssl, alert_fatal, why);   /* try to send */
-                ssl->options.isClosed = 1;
-            }
-        }
-        ssl->error = ret;
-    }
-#ifdef WOLFSSL_ALWAYS_VERIFY_CB
-    else {
-        if (ssl->verifyCallback) {
-            int ok;
-
-            store->error = ret;
-            store->error_depth = totalCerts;
-            store->discardSessionCerts = 0;
-            store->domain = domain;
-            store->userCtx = ssl->verifyCbCtx;
-#ifdef KEEP_PEER_CERT
-            store->current_cert = &ssl->peerCert;
-#endif
-            store->ex_data = ssl;
-
-            ok = ssl->verifyCallback(1, store);
-            if (!ok) {
-                WOLFSSL_MSG("Verify callback overriding valid certificate!");
-                ret = -1;
-                SendAlert(ssl, alert_fatal, bad_certificate);
-                ssl->options.isClosed = 1;
-            }
-            #ifdef SESSION_CERTS
-            if (store->discardSessionCerts) {
-                WOLFSSL_MSG("Verify callback requested discard sess certs");
-                ssl->session.chain.count = 0;
-            }
-            #endif
-        }
-    }
-#endif
-
-    if (ssl->options.verifyNone &&
-                              (ret == CRL_MISSING || ret == CRL_CERT_REVOKED)) {
-        WOLFSSL_MSG("Ignoring CRL problem based on verify setting");
-        ret = ssl->error = 0;
-    }
-
-    if (ret == 0 && ssl->options.side == WOLFSSL_CLIENT_END)
-        ssl->options.serverState = SERVER_CERT_COMPLETE;
-
-    if (ssl->keys.encryptionOn) {
-        *inOutIdx += ssl->keys.padSz;
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(store,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(domain, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-#endif /* !NO_CERTS */
-
-
-static int DoHelloRequest(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
-                                                    word32 size, word32 totalSz)
-{
-    (void)input;
-
-    if (size) /* must be 0 */
-        return BUFFER_ERROR;
-
-    if (ssl->keys.encryptionOn) {
-        /* access beyond input + size should be checked against totalSz */
-        if (*inOutIdx + ssl->keys.padSz > totalSz)
-            return BUFFER_E;
-
-        *inOutIdx += ssl->keys.padSz;
-    }
-
-    if (ssl->options.side == WOLFSSL_SERVER_END) {
-        SendAlert(ssl, alert_fatal, unexpected_message); /* try */
-        return FATAL_ERROR;
-    }
-#ifdef HAVE_SECURE_RENEGOTIATION
-    else if (ssl->secure_renegotiation && ssl->secure_renegotiation->enabled) {
-        ssl->secure_renegotiation->startScr = 1;
-        return 0;
-    }
-#endif
-    else {
-        return SendAlert(ssl, alert_warning, no_renegotiation);
-    }
-}
-
-
-int DoFinished(WOLFSSL* ssl, const byte* input, word32* inOutIdx, word32 size,
-                                                      word32 totalSz, int sniff)
-{
-    word32 finishedSz = (ssl->options.tls ? TLS_FINISHED_SZ : FINISHED_SZ);
-
-    if (finishedSz != size)
-        return BUFFER_ERROR;
-
-    /* check against totalSz */
-    if (*inOutIdx + size + ssl->keys.padSz > totalSz)
-        return BUFFER_E;
-
-    #ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn) AddPacketName("Finished", &ssl->handShakeInfo);
-        if (ssl->toInfoOn) AddLateName("Finished", &ssl->timeoutInfo);
-    #endif
-
-    if (sniff == NO_SNIFF) {
-        if (XMEMCMP(input + *inOutIdx, &ssl->hsHashes->verifyHashes,size) != 0){
-            WOLFSSL_MSG("Verify finished error on hashes");
-            return VERIFY_FINISHED_ERROR;
-        }
-    }
-
-#ifdef HAVE_SECURE_RENEGOTIATION
-    if (ssl->secure_renegotiation) {
-        /* save peer's state */
-        if (ssl->options.side == WOLFSSL_CLIENT_END)
-            XMEMCPY(ssl->secure_renegotiation->server_verify_data,
-                    input + *inOutIdx, TLS_FINISHED_SZ);
-        else
-            XMEMCPY(ssl->secure_renegotiation->client_verify_data,
-                    input + *inOutIdx, TLS_FINISHED_SZ);
-    }
-#endif
-
-    /* force input exhaustion at ProcessReply consuming padSz */
-    *inOutIdx += size + ssl->keys.padSz;
-
-    if (ssl->options.side == WOLFSSL_CLIENT_END) {
-        ssl->options.serverState = SERVER_FINISHED_COMPLETE;
-        if (!ssl->options.resuming) {
-            ssl->options.handShakeState = HANDSHAKE_DONE;
-            ssl->options.handShakeDone  = 1;
-
-#ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls) {
-                /* Other side has received our Finished, go to next epoch */
-                ssl->keys.dtls_epoch++;
-                ssl->keys.dtls_sequence_number = 1;
-            }
-#endif
-        }
-    }
-    else {
-        ssl->options.clientState = CLIENT_FINISHED_COMPLETE;
-        if (ssl->options.resuming) {
-            ssl->options.handShakeState = HANDSHAKE_DONE;
-            ssl->options.handShakeDone  = 1;
-
-#ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls) {
-                /* Other side has received our Finished, go to next epoch */
-                ssl->keys.dtls_epoch++;
-                ssl->keys.dtls_sequence_number = 1;
-            }
-#endif
-        }
-    }
-
-    return 0;
-}
-
-
-/* Make sure no duplicates, no fast forward, or other problems; 0 on success */
-static int SanityCheckMsgReceived(WOLFSSL* ssl, byte type)
-{
-    /* verify not a duplicate, mark received, check state */
-    switch (type) {
-
-#ifndef NO_WOLFSSL_CLIENT
-        case hello_request:
-            if (ssl->msgsReceived.got_hello_request) {
-                WOLFSSL_MSG("Duplicate HelloRequest received");
-                return DUPLICATE_MSG_E;
-            }
-            ssl->msgsReceived.got_hello_request = 1;
-
-            break;
-#endif
-
-#ifndef NO_WOLFSSL_SERVER
-        case client_hello:
-            if (ssl->msgsReceived.got_client_hello) {
-                WOLFSSL_MSG("Duplicate ClientHello received");
-                return DUPLICATE_MSG_E;
-            }
-            ssl->msgsReceived.got_client_hello = 1;
-
-            break;
-#endif
-
-#ifndef NO_WOLFSSL_CLIENT
-        case server_hello:
-            if (ssl->msgsReceived.got_server_hello) {
-                WOLFSSL_MSG("Duplicate ServerHello received");
-                return DUPLICATE_MSG_E;
-            }
-            ssl->msgsReceived.got_server_hello = 1;
-
-            break;
-#endif
-
-#ifndef NO_WOLFSSL_CLIENT
-        case hello_verify_request:
-            if (ssl->msgsReceived.got_hello_verify_request) {
-                WOLFSSL_MSG("Duplicate HelloVerifyRequest received");
-                return DUPLICATE_MSG_E;
-            }
-            ssl->msgsReceived.got_hello_verify_request = 1;
-
-            break;
-#endif
-
-#ifndef NO_WOLFSSL_CLIENT
-        case session_ticket:
-            if (ssl->msgsReceived.got_session_ticket) {
-                WOLFSSL_MSG("Duplicate SessionTicket received");
-                return DUPLICATE_MSG_E;
-            }
-            ssl->msgsReceived.got_session_ticket = 1;
-
-            break;
-#endif
-
-        case certificate:
-            if (ssl->msgsReceived.got_certificate) {
-                WOLFSSL_MSG("Duplicate Certificate received");
-                return DUPLICATE_MSG_E;
-            }
-            ssl->msgsReceived.got_certificate = 1;
-
-#ifndef NO_WOLFSSL_CLIENT
-            if (ssl->options.side == WOLFSSL_CLIENT_END) {
-                if ( ssl->msgsReceived.got_server_hello == 0) {
-                    WOLFSSL_MSG("No ServerHello before Cert");
-                    return OUT_OF_ORDER_E;
-                }
-            }
-#endif
-#ifndef NO_WOLFSSL_SERVER
-            if (ssl->options.side == WOLFSSL_SERVER_END) {
-                if ( ssl->msgsReceived.got_client_hello == 0) {
-                    WOLFSSL_MSG("No ClientHello before Cert");
-                    return OUT_OF_ORDER_E;
-                }
-            }
-#endif
-            break;
-
-#ifndef NO_WOLFSSL_CLIENT
-        case server_key_exchange:
-            if (ssl->msgsReceived.got_server_key_exchange) {
-                WOLFSSL_MSG("Duplicate ServerKeyExchange received");
-                return DUPLICATE_MSG_E;
-            }
-            ssl->msgsReceived.got_server_key_exchange = 1;
-
-            if ( ssl->msgsReceived.got_server_hello == 0) {
-                WOLFSSL_MSG("No ServerHello before Cert");
-                return OUT_OF_ORDER_E;
-            }
-
-            break;
-#endif
-
-#ifndef NO_WOLFSSL_CLIENT
-        case certificate_request:
-            if (ssl->msgsReceived.got_certificate_request) {
-                WOLFSSL_MSG("Duplicate CertificateRequest received");
-                return DUPLICATE_MSG_E;
-            }
-            ssl->msgsReceived.got_certificate_request = 1;
-
-            break;
-#endif
-
-#ifndef NO_WOLFSSL_CLIENT
-        case server_hello_done:
-            if (ssl->msgsReceived.got_server_hello_done) {
-                WOLFSSL_MSG("Duplicate ServerHelloDone received");
-                return DUPLICATE_MSG_E;
-            }
-            ssl->msgsReceived.got_server_hello_done = 1;
-
-            if (ssl->msgsReceived.got_certificate == 0) {
-                if (ssl->specs.kea == psk_kea ||
-                    ssl->specs.kea == dhe_psk_kea ||
-                    ssl->options.usingAnon_cipher) {
-                    WOLFSSL_MSG("No Cert required");
-                } else {
-                    WOLFSSL_MSG("No Certificate before ServerHelloDone");
-                    return OUT_OF_ORDER_E;
-                }
-            }
-            if (ssl->msgsReceived.got_server_key_exchange == 0) {
-                if (ssl->specs.static_ecdh == 1 ||
-                    ssl->specs.kea == rsa_kea ||
-                    ssl->specs.kea == ntru_kea) {
-                    WOLFSSL_MSG("No KeyExchange required");
-                } else {
-                    WOLFSSL_MSG("No ServerKeyExchange before ServerDone");
-                    return OUT_OF_ORDER_E;
-                }
-            }
-            break;
-#endif
-
-#ifndef NO_WOLFSSL_SERVER
-        case certificate_verify:
-            if (ssl->msgsReceived.got_certificate_verify) {
-                WOLFSSL_MSG("Duplicate CertificateVerify received");
-                return DUPLICATE_MSG_E;
-            }
-            ssl->msgsReceived.got_certificate_verify = 1;
-
-            if ( ssl->msgsReceived.got_certificate == 0) {
-                WOLFSSL_MSG("No Cert before CertVerify");
-                return OUT_OF_ORDER_E;
-            }
-            break;
-#endif
-
-#ifndef NO_WOLFSSL_SERVER
-        case client_key_exchange:
-            if (ssl->msgsReceived.got_client_key_exchange) {
-                WOLFSSL_MSG("Duplicate ClientKeyExchange received");
-                return DUPLICATE_MSG_E;
-            }
-            ssl->msgsReceived.got_client_key_exchange = 1;
-
-            if (ssl->msgsReceived.got_client_hello == 0) {
-                WOLFSSL_MSG("No ClientHello before ClientKeyExchange");
-                return OUT_OF_ORDER_E;
-            }
-            break;
-#endif
-
-        case finished:
-            if (ssl->msgsReceived.got_finished) {
-                WOLFSSL_MSG("Duplicate Finished received");
-                return DUPLICATE_MSG_E;
-            }
-            ssl->msgsReceived.got_finished = 1;
-
-            if (ssl->msgsReceived.got_change_cipher == 0) {
-                WOLFSSL_MSG("Finished received before ChangeCipher");
-                return NO_CHANGE_CIPHER_E;
-            }
-
-            break;
-
-        case change_cipher_hs:
-            if (ssl->msgsReceived.got_change_cipher) {
-                WOLFSSL_MSG("Duplicate ChangeCipher received");
-                return DUPLICATE_MSG_E;
-            }
-            ssl->msgsReceived.got_change_cipher = 1;
-
-#ifndef NO_WOLFSSL_CLIENT
-            if (ssl->options.side == WOLFSSL_CLIENT_END) {
-                if (!ssl->options.resuming &&
-                                 ssl->msgsReceived.got_server_hello_done == 0) {
-                    WOLFSSL_MSG("No ServerHelloDone before ChangeCipher");
-                    return OUT_OF_ORDER_E;
-                }
-            }
-#endif
-#ifndef NO_WOLFSSL_SERVER
-            if (ssl->options.side == WOLFSSL_SERVER_END) {
-                if (!ssl->options.resuming &&
-                               ssl->msgsReceived.got_client_key_exchange == 0) {
-                    WOLFSSL_MSG("No ClientKeyExchange before ChangeCipher");
-                    return OUT_OF_ORDER_E;
-                }
-            }
-#endif
-
-            break;
-
-        default:
-            WOLFSSL_MSG("Unknown message type");
-            return SANITY_MSG_E;
-    }
-
-    return 0;
-}
-
-
-static int DoHandShakeMsgType(WOLFSSL* ssl, byte* input, word32* inOutIdx,
-                          byte type, word32 size, word32 totalSz)
-{
-    int ret = 0;
-    (void)totalSz;
-
-    WOLFSSL_ENTER("DoHandShakeMsgType");
-
-    /* make sure can read the message */
-    if (*inOutIdx + size > totalSz)
-        return INCOMPLETE_DATA;
-
-    /* sanity check msg received */
-    if ( (ret = SanityCheckMsgReceived(ssl, type)) != 0) {
-        WOLFSSL_MSG("Sanity Check on handshake message type received failed");
-        return ret;
-    }
-
-#ifdef WOLFSSL_CALLBACKS
-    /* add name later, add on record and handshake header part back on */
-    if (ssl->toInfoOn) {
-        int add = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ;
-        AddPacketInfo(0, &ssl->timeoutInfo, input + *inOutIdx - add,
-                      size + add, ssl->heap);
-        AddLateRecordHeader(&ssl->curRL, &ssl->timeoutInfo);
-    }
-#endif
-
-    if (ssl->options.handShakeState == HANDSHAKE_DONE && type != hello_request){
-        WOLFSSL_MSG("HandShake message after handshake complete");
-        SendAlert(ssl, alert_fatal, unexpected_message);
-        return OUT_OF_ORDER_E;
-    }
-
-    if (ssl->options.side == WOLFSSL_CLIENT_END && ssl->options.dtls == 0 &&
-               ssl->options.serverState == NULL_STATE && type != server_hello) {
-        WOLFSSL_MSG("First server message not server hello");
-        SendAlert(ssl, alert_fatal, unexpected_message);
-        return OUT_OF_ORDER_E;
-    }
-
-    if (ssl->options.side == WOLFSSL_CLIENT_END && ssl->options.dtls &&
-            type == server_hello_done &&
-            ssl->options.serverState < SERVER_HELLO_COMPLETE) {
-        WOLFSSL_MSG("Server hello done received before server hello in DTLS");
-        SendAlert(ssl, alert_fatal, unexpected_message);
-        return OUT_OF_ORDER_E;
-    }
-
-    if (ssl->options.side == WOLFSSL_SERVER_END &&
-               ssl->options.clientState == NULL_STATE && type != client_hello) {
-        WOLFSSL_MSG("First client message not client hello");
-        SendAlert(ssl, alert_fatal, unexpected_message);
-        return OUT_OF_ORDER_E;
-    }
-
-    /* above checks handshake state */
-    /* hello_request not hashed */
-    if (type != hello_request) {
-        ret = HashInput(ssl, input + *inOutIdx, size);
-        if (ret != 0) return ret;
-    }
-
-    switch (type) {
-
-    case hello_request:
-        WOLFSSL_MSG("processing hello request");
-        ret = DoHelloRequest(ssl, input, inOutIdx, size, totalSz);
-        break;
-
-#ifndef NO_WOLFSSL_CLIENT
-    case hello_verify_request:
-        WOLFSSL_MSG("processing hello verify request");
-        ret = DoHelloVerifyRequest(ssl, input,inOutIdx, size);
-        break;
-
-    case server_hello:
-        WOLFSSL_MSG("processing server hello");
-        ret = DoServerHello(ssl, input, inOutIdx, size);
-        break;
-
-#ifndef NO_CERTS
-    case certificate_request:
-        WOLFSSL_MSG("processing certificate request");
-        ret = DoCertificateRequest(ssl, input, inOutIdx, size);
-        break;
-#endif
-
-    case server_key_exchange:
-        WOLFSSL_MSG("processing server key exchange");
-        ret = DoServerKeyExchange(ssl, input, inOutIdx, size);
-        break;
-
-#ifdef HAVE_SESSION_TICKET
-    case session_ticket:
-        WOLFSSL_MSG("processing session ticket");
-        ret = DoSessionTicket(ssl, input, inOutIdx, size);
-        break;
-#endif /* HAVE_SESSION_TICKET */
-#endif
-
-#ifndef NO_CERTS
-    case certificate:
-        WOLFSSL_MSG("processing certificate");
-        ret =  DoCertificate(ssl, input, inOutIdx, size);
-        break;
-#endif
-
-    case server_hello_done:
-        WOLFSSL_MSG("processing server hello done");
-        #ifdef WOLFSSL_CALLBACKS
-            if (ssl->hsInfoOn)
-                AddPacketName("ServerHelloDone", &ssl->handShakeInfo);
-            if (ssl->toInfoOn)
-                AddLateName("ServerHelloDone", &ssl->timeoutInfo);
-        #endif
-        ssl->options.serverState = SERVER_HELLODONE_COMPLETE;
-        if (ssl->keys.encryptionOn) {
-            *inOutIdx += ssl->keys.padSz;
-        }
-        if (ssl->options.resuming) {
-            WOLFSSL_MSG("Not resuming as thought");
-            ssl->options.resuming = 0;
-        }
-        break;
-
-    case finished:
-        WOLFSSL_MSG("processing finished");
-        ret = DoFinished(ssl, input, inOutIdx, size, totalSz, NO_SNIFF);
-        break;
-
-#ifndef NO_WOLFSSL_SERVER
-    case client_hello:
-        WOLFSSL_MSG("processing client hello");
-        ret = DoClientHello(ssl, input, inOutIdx, size);
-        break;
-
-    case client_key_exchange:
-        WOLFSSL_MSG("processing client key exchange");
-        ret = DoClientKeyExchange(ssl, input, inOutIdx, size);
-        break;
-
-#if !defined(NO_RSA) || defined(HAVE_ECC)
-    case certificate_verify:
-        WOLFSSL_MSG("processing certificate verify");
-        ret = DoCertificateVerify(ssl, input, inOutIdx, size);
-        break;
-#endif /* !NO_RSA || HAVE_ECC */
-
-#endif /* !NO_WOLFSSL_SERVER */
-
-    default:
-        WOLFSSL_MSG("Unknown handshake message type");
-        ret = UNKNOWN_HANDSHAKE_TYPE;
-        break;
-    }
-
-    WOLFSSL_LEAVE("DoHandShakeMsgType()", ret);
-    return ret;
-}
-
-
-static int DoHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
-                          word32 totalSz)
-{
-    byte   type;
-    word32 size;
-    int    ret = 0;
-
-    WOLFSSL_ENTER("DoHandShakeMsg()");
-
-    if (GetHandShakeHeader(ssl, input, inOutIdx, &type, &size, totalSz) != 0)
-        return PARSE_ERROR;
-
-    ret = DoHandShakeMsgType(ssl, input, inOutIdx, type, size, totalSz);
-
-    WOLFSSL_LEAVE("DoHandShakeMsg()", ret);
-    return ret;
-}
-
-
-#ifdef WOLFSSL_DTLS
-
-static INLINE int DtlsCheckWindow(DtlsState* state)
-{
-    word32 cur;
-    word32 next;
-    DtlsSeq window;
-
-    if (state->curEpoch == state->nextEpoch) {
-        next = state->nextSeq;
-        window = state->window;
-    }
-    else if (state->curEpoch < state->nextEpoch) {
-        next = state->prevSeq;
-        window = state->prevWindow;
-    }
-    else {
-        return 0;
-    }
-
-    cur = state->curSeq;
-
-    if ((next > DTLS_SEQ_BITS) && (cur < next - DTLS_SEQ_BITS)) {
-        return 0;
-    }
-    else if ((cur < next) && (window & ((DtlsSeq)1 << (next - cur - 1)))) {
-        return 0;
-    }
-
-    return 1;
-}
-
-
-static INLINE int DtlsUpdateWindow(DtlsState* state)
-{
-    word32 cur;
-    word32* next;
-    DtlsSeq* window;
-
-    if (state->curEpoch == state->nextEpoch) {
-        next = &state->nextSeq;
-        window = &state->window;
-    }
-    else {
-        next = &state->prevSeq;
-        window = &state->prevWindow;
-    }
-
-    cur = state->curSeq;
-
-    if (cur < *next) {
-        *window |= ((DtlsSeq)1 << (*next - cur - 1));
-    }
-    else {
-        *window <<= (1 + cur - *next);
-        *window |= 1;
-        *next = cur + 1;
-    }
-
-    return 1;
-}
-
-
-static int DtlsMsgDrain(WOLFSSL* ssl)
-{
-    DtlsMsg* item = ssl->dtls_msg_list;
-    int ret = 0;
-
-    /* While there is an item in the store list, and it is the expected
-     * message, and it is complete, and there hasn't been an error in the
-     * last messge... */
-    while (item != NULL &&
-            ssl->keys.dtls_expected_peer_handshake_number == item->seq &&
-            item->fragSz == item->sz &&
-            ret == 0) {
-        word32 idx = 0;
-        ssl->keys.dtls_expected_peer_handshake_number++;
-        ret = DoHandShakeMsgType(ssl, item->msg,
-                                 &idx, item->type, item->sz, item->sz);
-        ssl->dtls_msg_list = item->next;
-        DtlsMsgDelete(item, ssl->heap);
-        item = ssl->dtls_msg_list;
-    }
-
-    return ret;
-}
-
-
-static int DoDtlsHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
-                          word32 totalSz)
-{
-    byte type;
-    word32 size;
-    word32 fragOffset, fragSz;
-    int ret = 0;
-
-    WOLFSSL_ENTER("DoDtlsHandShakeMsg()");
-    if (GetDtlsHandShakeHeader(ssl, input, inOutIdx, &type,
-                               &size, &fragOffset, &fragSz, totalSz) != 0)
-        return PARSE_ERROR;
-
-    if (*inOutIdx + fragSz > totalSz)
-        return INCOMPLETE_DATA;
-
-    /* Check the handshake sequence number first. If out of order,
-     * add the current message to the list. If the message is in order,
-     * but it is a fragment, add the current message to the list, then
-     * check the head of the list to see if it is complete, if so, pop
-     * it out as the current message. If the message is complete and in
-     * order, process it. Check the head of the list to see if it is in
-     * order, if so, process it. (Repeat until list exhausted.) If the
-     * head is out of order, return for more processing.
-     */
-    if (ssl->keys.dtls_peer_handshake_number >
-                                ssl->keys.dtls_expected_peer_handshake_number) {
-        /* Current message is out of order. It will get stored in the list.
-         * Storing also takes care of defragmentation. */
-        ssl->dtls_msg_list = DtlsMsgStore(ssl->dtls_msg_list,
-                        ssl->keys.dtls_peer_handshake_number, input + *inOutIdx,
-                        size, type, fragOffset, fragSz, ssl->heap);
-        *inOutIdx += fragSz;
-        ret = 0;
-    }
-    else if (ssl->keys.dtls_peer_handshake_number <
-                                ssl->keys.dtls_expected_peer_handshake_number) {
-        /* Already saw this message and processed it. It can be ignored. */
-        *inOutIdx += fragSz;
-        ret = 0;
-    }
-    else if (fragSz < size) {
-        /* Since this branch is in order, but fragmented, dtls_msg_list will be
-         * pointing to the message with this fragment in it. Check it to see
-         * if it is completed. */
-        ssl->dtls_msg_list = DtlsMsgStore(ssl->dtls_msg_list,
-                        ssl->keys.dtls_peer_handshake_number, input + *inOutIdx,
-                        size, type, fragOffset, fragSz, ssl->heap);
-        *inOutIdx += fragSz;
-        ret = 0;
-        if (ssl->dtls_msg_list != NULL &&
-            ssl->dtls_msg_list->fragSz >= ssl->dtls_msg_list->sz)
-            ret = DtlsMsgDrain(ssl);
-    }
-    else {
-        /* This branch is in order next, and a complete message. */
-        ssl->keys.dtls_expected_peer_handshake_number++;
-        ret = DoHandShakeMsgType(ssl, input, inOutIdx, type, size, totalSz);
-        if (ret == 0 && ssl->dtls_msg_list != NULL)
-            ret = DtlsMsgDrain(ssl);
-    }
-
-    WOLFSSL_LEAVE("DoDtlsHandShakeMsg()", ret);
-    return ret;
-}
-#endif
-
-
-#if !defined(NO_OLD_TLS) || defined(HAVE_CHACHA) || defined(HAVE_AESCCM) \
-    || defined(HAVE_AESGCM)
-static INLINE word32 GetSEQIncrement(WOLFSSL* ssl, int verify)
-{
-#ifdef WOLFSSL_DTLS
-    if (ssl->options.dtls) {
-        if (verify)
-            return ssl->keys.dtls_state.curSeq; /* explicit from peer */
-        else
-            return ssl->keys.dtls_sequence_number - 1; /* already incremented */
-    }
-#endif
-    if (verify)
-        return ssl->keys.peer_sequence_number++;
-    else
-        return ssl->keys.sequence_number++;
-}
-#endif
-
-
-#ifdef HAVE_AEAD
-static INLINE void AeadIncrementExpIV(WOLFSSL* ssl)
-{
-    int i;
-    for (i = AEAD_EXP_IV_SZ-1; i >= 0; i--) {
-        if (++ssl->keys.aead_exp_IV[i]) return;
-    }
-}
-
-
-#if defined(HAVE_POLY1305) && defined(HAVE_CHACHA)
-/*more recent rfc's concatonate input for poly1305 differently*/
-static int Poly1305Tag(WOLFSSL* ssl, byte* additional, const byte* out,
-                       byte* cipher, word16 sz, byte* tag)
-{
-    int ret       = 0;
-    int paddingSz = 0;
-    int msglen    = (sz - ssl->specs.aead_mac_size);
-    word32 keySz  = 32;
-    int blockSz   = 16;
-    byte padding[16];
-
-    if (msglen < 0)
-        return INPUT_CASE_ERROR;
-
-    XMEMSET(padding, 0, sizeof(padding));
-
-    if ((ret = wc_Poly1305SetKey(ssl->auth.poly1305, cipher, keySz)) != 0)
-        return ret;
-
-    /* additional input to poly1305 */
-    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, additional, blockSz)) != 0)
-        return ret;
-
-    /* cipher input */
-    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, out, msglen)) != 0)
-        return ret;
-
-    /* handle padding for cipher input to make it 16 bytes long */
-    if (msglen % 16 != 0) {
-          paddingSz = (16 - (sz - ssl->specs.aead_mac_size) % 16);
-          if (paddingSz < 0)
-              return INPUT_CASE_ERROR;
-
-          if ((ret = wc_Poly1305Update(ssl->auth.poly1305, padding, paddingSz))
-                 != 0)
-              return ret;
-    }
-
-    /* add size of AD and size of cipher to poly input */
-    XMEMSET(padding, 0, sizeof(padding));
-    padding[0] = blockSz;
-
-    /* 32 bit size of cipher to 64 bit endian */
-    padding[8]  =  msglen       & 0xff;
-    padding[9]  = (msglen >> 8) & 0xff;
-    padding[10] = (msglen >>16) & 0xff;
-    padding[11] = (msglen >>24) & 0xff;
-    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, padding, sizeof(padding)))
-                != 0)
-        return ret;
-
-    /* generate tag */
-    if ((ret = wc_Poly1305Final(ssl->auth.poly1305, tag)) != 0)
-        return ret;
-
-    return ret;
-}
-
-
-/* Used for the older version of creating AEAD tags with Poly1305 */
-static int Poly1305TagOld(WOLFSSL* ssl, byte* additional, const byte* out,
-                       byte* cipher, word16 sz, byte* tag)
-{
-    int ret       = 0;
-    int msglen    = (sz - ssl->specs.aead_mac_size);
-    word32 keySz  = 32;
-    byte padding[8]; /* used to temporarly store lengths */
-
-#ifdef CHACHA_AEAD_TEST
-      printf("Using old version of poly1305 input.\n");
-#endif
-
-    if (msglen < 0)
-        return INPUT_CASE_ERROR;
-
-    if ((ret = wc_Poly1305SetKey(ssl->auth.poly1305, cipher, keySz)) != 0)
-        return ret;
-
-    /* add TLS compressed length and additional input to poly1305 */
-    additional[AEAD_AUTH_DATA_SZ - 2] = (msglen >> 8) & 0xff;
-    additional[AEAD_AUTH_DATA_SZ - 1] =  msglen       & 0xff;
-    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, additional,
-                   AEAD_AUTH_DATA_SZ)) != 0)
-        return ret;
-
-    /* length of additional input plus padding */
-    XMEMSET(padding, 0, sizeof(padding));
-    padding[0] = AEAD_AUTH_DATA_SZ;
-    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, padding,
-                    sizeof(padding))) != 0)
-        return ret;
-
-
-    /* add cipher info and then its length */
-    XMEMSET(padding, 0, sizeof(padding));
-    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, out, msglen)) != 0)
-        return ret;
-
-    /* 32 bit size of cipher to 64 bit endian */
-    padding[0] =  msglen        & 0xff;
-    padding[1] = (msglen >>  8) & 0xff;
-    padding[2] = (msglen >> 16) & 0xff;
-    padding[3] = (msglen >> 24) & 0xff;
-    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, padding, sizeof(padding)))
-        != 0)
-        return ret;
-
-    /* generate tag */
-    if ((ret = wc_Poly1305Final(ssl->auth.poly1305, tag)) != 0)
-        return ret;
-
-    return ret;
-}
-
-
-static int  ChachaAEADEncrypt(WOLFSSL* ssl, byte* out, const byte* input,
-                              word16 sz)
-{
-    const byte* additionalSrc = input - RECORD_HEADER_SZ;
-    int ret = 0;
-    byte tag[POLY1305_AUTH_SZ];
-    byte additional[CHACHA20_BLOCK_SIZE];
-    byte nonce[AEAD_NONCE_SZ];
-    byte cipher[CHACHA20_256_KEY_SIZE]; /* generated key for poly1305 */
-    #ifdef CHACHA_AEAD_TEST
-        int i;
-    #endif
-
-    XMEMSET(tag, 0, sizeof(tag));
-    XMEMSET(nonce, 0, AEAD_NONCE_SZ);
-    XMEMSET(cipher, 0, sizeof(cipher));
-    XMEMSET(additional, 0, CHACHA20_BLOCK_SIZE);
-
-    /* get nonce */
-    c32toa(ssl->keys.sequence_number, nonce + AEAD_IMP_IV_SZ
-           + AEAD_SEQ_OFFSET);
-
-    /* opaque SEQ number stored for AD */
-    c32toa(GetSEQIncrement(ssl, 0), additional + AEAD_SEQ_OFFSET);
-
-    /* Store the type, version. Unfortunately, they are in
-     * the input buffer ahead of the plaintext. */
-    #ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            c16toa(ssl->keys.dtls_epoch, additional);
-            additionalSrc -= DTLS_HANDSHAKE_EXTRA;
-        }
-    #endif
-
-    XMEMCPY(additional + AEAD_TYPE_OFFSET, additionalSrc, 3);
-
-    #ifdef CHACHA_AEAD_TEST
-        printf("Encrypt Additional : ");
-        for (i = 0; i < CHACHA20_BLOCK_SIZE; i++) {
-            printf("%02x", additional[i]);
-        }
-        printf("\n\n");
-        printf("input before encryption :\n");
-        for (i = 0; i < sz; i++) {
-            printf("%02x", input[i]);
-            if ((i + 1) % 16 == 0)
-                printf("\n");
-        }
-        printf("\n");
-    #endif
-
-    /* set the nonce for chacha and get poly1305 key */
-    if ((ret = wc_Chacha_SetIV(ssl->encrypt.chacha, nonce, 0)) != 0)
-        return ret;
-
-        if ((ret = wc_Chacha_Process(ssl->encrypt.chacha, cipher,
-                    cipher, sizeof(cipher))) != 0)
-        return ret;
-
-    /* encrypt the plain text */
-    if ((ret = wc_Chacha_Process(ssl->encrypt.chacha, out, input,
-                   sz - ssl->specs.aead_mac_size)) != 0)
-        return ret;
-
-    /* get the tag : future use of hmac could go here*/
-    if (ssl->options.oldPoly == 1) {
-        if ((ret = Poly1305TagOld(ssl, additional, (const byte* )out,
-                    cipher, sz, tag)) != 0)
-            return ret;
-    }
-    else {
-        if ((ret = Poly1305Tag(ssl, additional, (const byte* )out,
-                    cipher, sz, tag)) != 0)
-            return ret;
-    }
-
-    /* append tag to ciphertext */
-    XMEMCPY(out + sz - ssl->specs.aead_mac_size, tag, sizeof(tag));
-
-    AeadIncrementExpIV(ssl);
-    ForceZero(nonce, AEAD_NONCE_SZ);
-
-    #ifdef CHACHA_AEAD_TEST
-       printf("mac tag :\n");
-        for (i = 0; i < 16; i++) {
-           printf("%02x", tag[i]);
-           if ((i + 1) % 16 == 0)
-               printf("\n");
-        }
-       printf("\n\noutput after encrypt :\n");
-        for (i = 0; i < sz; i++) {
-           printf("%02x", out[i]);
-           if ((i + 1) % 16 == 0)
-               printf("\n");
-        }
-        printf("\n");
-    #endif
-
-    return ret;
-}
-
-
-static int ChachaAEADDecrypt(WOLFSSL* ssl, byte* plain, const byte* input,
-                           word16 sz)
-{
-    byte additional[CHACHA20_BLOCK_SIZE];
-    byte nonce[AEAD_NONCE_SZ];
-    byte tag[POLY1305_AUTH_SZ];
-    byte cipher[CHACHA20_256_KEY_SIZE]; /* generated key for mac */
-    int ret = 0;
-
-    XMEMSET(tag, 0, sizeof(tag));
-    XMEMSET(cipher, 0, sizeof(cipher));
-    XMEMSET(nonce, 0, AEAD_NONCE_SZ);
-    XMEMSET(additional, 0, CHACHA20_BLOCK_SIZE);
-
-    #ifdef CHACHA_AEAD_TEST
-       int i;
-       printf("input before decrypt :\n");
-        for (i = 0; i < sz; i++) {
-           printf("%02x", input[i]);
-           if ((i + 1) % 16 == 0)
-               printf("\n");
-        }
-        printf("\n");
-    #endif
-
-    /* get nonce */
-    c32toa(ssl->keys.peer_sequence_number, nonce + AEAD_IMP_IV_SZ
-            + AEAD_SEQ_OFFSET);
-
-    /* sequence number field is 64-bits, we only use 32-bits */
-    c32toa(GetSEQIncrement(ssl, 1), additional + AEAD_SEQ_OFFSET);
-
-    /* get AD info */
-    additional[AEAD_TYPE_OFFSET] = ssl->curRL.type;
-    additional[AEAD_VMAJ_OFFSET] = ssl->curRL.pvMajor;
-    additional[AEAD_VMIN_OFFSET] = ssl->curRL.pvMinor;
-
-    /* Store the type, version. */
-    #ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls)
-            c16toa(ssl->keys.dtls_state.curEpoch, additional);
-    #endif
-
-    #ifdef CHACHA_AEAD_TEST
-        printf("Decrypt Additional : ");
-        for (i = 0; i < CHACHA20_BLOCK_SIZE; i++) {
-            printf("%02x", additional[i]);
-        }
-        printf("\n\n");
-    #endif
-
-    /* set nonce and get poly1305 key */
-    if ((ret = wc_Chacha_SetIV(ssl->decrypt.chacha, nonce, 0)) != 0)
-        return ret;
-
-    if ((ret = wc_Chacha_Process(ssl->decrypt.chacha, cipher,
-                    cipher, sizeof(cipher))) != 0)
-        return ret;
-
-    /* get the tag : future use of hmac could go here*/
-    if (ssl->options.oldPoly == 1) {
-        if ((ret = Poly1305TagOld(ssl, additional, input, cipher,
-                        sz, tag)) != 0)
-            return ret;
-    }
-    else {
-        if ((ret = Poly1305Tag(ssl, additional, input, cipher,
-                        sz, tag)) != 0)
-            return ret;
-    }
-
-    /* check mac sent along with packet */
-    if (ConstantCompare(input + sz - ssl->specs.aead_mac_size, tag,
-                ssl->specs.aead_mac_size) != 0) {
-        WOLFSSL_MSG("Mac did not match");
-        SendAlert(ssl, alert_fatal, bad_record_mac);
-        ForceZero(nonce, AEAD_NONCE_SZ);
-        return VERIFY_MAC_ERROR;
-    }
-
-    /* if mac was good decrypt message */
-    if ((ret = wc_Chacha_Process(ssl->decrypt.chacha, plain, input,
-                   sz - ssl->specs.aead_mac_size)) != 0)
-        return ret;
-
-    #ifdef CHACHA_AEAD_TEST
-       printf("plain after decrypt :\n");
-        for (i = 0; i < sz; i++) {
-           printf("%02x", plain[i]);
-           if ((i + 1) % 16 == 0)
-               printf("\n");
-        }
-        printf("\n");
-    #endif
-
-    return ret;
-}
-#endif /* HAVE_CHACHA && HAVE_POLY1305 */
-#endif /* HAVE_AEAD */
-
-
-static INLINE int Encrypt(WOLFSSL* ssl, byte* out, const byte* input, word16 sz)
-{
-    int ret = 0;
-
-    (void)out;
-    (void)input;
-    (void)sz;
-
-    if (ssl->encrypt.setup == 0) {
-        WOLFSSL_MSG("Encrypt ciphers not setup");
-        return ENCRYPT_ERROR;
-    }
-
-#ifdef HAVE_FUZZER
-    if (ssl->fuzzerCb)
-        ssl->fuzzerCb(ssl, input, sz, FUZZ_ENCRYPT, ssl->fuzzerCtx);
-#endif
-
-    switch (ssl->specs.bulk_cipher_algorithm) {
-        #ifdef BUILD_ARC4
-            case wolfssl_rc4:
-                wc_Arc4Process(ssl->encrypt.arc4, out, input, sz);
-                break;
-        #endif
-
-        #ifdef BUILD_DES3
-            case wolfssl_triple_des:
-                ret = wc_Des3_CbcEncrypt(ssl->encrypt.des3, out, input, sz);
-                break;
-        #endif
-
-        #ifdef BUILD_AES
-            case wolfssl_aes:
-                ret = wc_AesCbcEncrypt(ssl->encrypt.aes, out, input, sz);
-                break;
-        #endif
-
-        #ifdef BUILD_AESGCM
-            case wolfssl_aes_gcm:
-                {
-                    byte additional[AEAD_AUTH_DATA_SZ];
-                    byte nonce[AEAD_NONCE_SZ];
-                    const byte* additionalSrc = input - 5;
-
-                    XMEMSET(additional, 0, AEAD_AUTH_DATA_SZ);
-
-                    /* sequence number field is 64-bits, we only use 32-bits */
-                    c32toa(GetSEQIncrement(ssl, 0),
-                                            additional + AEAD_SEQ_OFFSET);
-
-                    /* Store the type, version. Unfortunately, they are in
-                     * the input buffer ahead of the plaintext. */
-                    #ifdef WOLFSSL_DTLS
-                        if (ssl->options.dtls) {
-                            c16toa(ssl->keys.dtls_epoch, additional);
-                            additionalSrc -= DTLS_HANDSHAKE_EXTRA;
-                        }
-                    #endif
-                    XMEMCPY(additional + AEAD_TYPE_OFFSET, additionalSrc, 3);
-
-                    /* Store the length of the plain text minus the explicit
-                     * IV length minus the authentication tag size. */
-                    c16toa(sz - AEAD_EXP_IV_SZ - ssl->specs.aead_mac_size,
-                                                additional + AEAD_LEN_OFFSET);
-                    XMEMCPY(nonce,
-                                 ssl->keys.aead_enc_imp_IV, AEAD_IMP_IV_SZ);
-                    XMEMCPY(nonce + AEAD_IMP_IV_SZ,
-                                     ssl->keys.aead_exp_IV, AEAD_EXP_IV_SZ);
-                    ret = wc_AesGcmEncrypt(ssl->encrypt.aes,
-                                 out + AEAD_EXP_IV_SZ, input + AEAD_EXP_IV_SZ,
-                                 sz - AEAD_EXP_IV_SZ - ssl->specs.aead_mac_size,
-                                 nonce, AEAD_NONCE_SZ,
-                                 out + sz - ssl->specs.aead_mac_size,
-                                 ssl->specs.aead_mac_size,
-                                 additional, AEAD_AUTH_DATA_SZ);
-                    if (ret == 0)
-                        AeadIncrementExpIV(ssl);
-                    ForceZero(nonce, AEAD_NONCE_SZ);
-                }
-                break;
-        #endif
-
-        #ifdef HAVE_AESCCM
-            case wolfssl_aes_ccm:
-                {
-                    byte additional[AEAD_AUTH_DATA_SZ];
-                    byte nonce[AEAD_NONCE_SZ];
-                    const byte* additionalSrc = input - 5;
-
-                    XMEMSET(additional, 0, AEAD_AUTH_DATA_SZ);
-
-                    /* sequence number field is 64-bits, we only use 32-bits */
-                    c32toa(GetSEQIncrement(ssl, 0),
-                                            additional + AEAD_SEQ_OFFSET);
-
-                    /* Store the type, version. Unfortunately, they are in
-                     * the input buffer ahead of the plaintext. */
-                    #ifdef WOLFSSL_DTLS
-                        if (ssl->options.dtls) {
-                            c16toa(ssl->keys.dtls_epoch, additional);
-                            additionalSrc -= DTLS_HANDSHAKE_EXTRA;
-                        }
-                    #endif
-                    XMEMCPY(additional + AEAD_TYPE_OFFSET, additionalSrc, 3);
-
-                    /* Store the length of the plain text minus the explicit
-                     * IV length minus the authentication tag size. */
-                    c16toa(sz - AEAD_EXP_IV_SZ - ssl->specs.aead_mac_size,
-                                                additional + AEAD_LEN_OFFSET);
-                    XMEMCPY(nonce,
-                                 ssl->keys.aead_enc_imp_IV, AEAD_IMP_IV_SZ);
-                    XMEMCPY(nonce + AEAD_IMP_IV_SZ,
-                                     ssl->keys.aead_exp_IV, AEAD_EXP_IV_SZ);
-                    wc_AesCcmEncrypt(ssl->encrypt.aes,
-                        out + AEAD_EXP_IV_SZ, input + AEAD_EXP_IV_SZ,
-                            sz - AEAD_EXP_IV_SZ - ssl->specs.aead_mac_size,
-                        nonce, AEAD_NONCE_SZ,
-                        out + sz - ssl->specs.aead_mac_size,
-                        ssl->specs.aead_mac_size,
-                        additional, AEAD_AUTH_DATA_SZ);
-                    AeadIncrementExpIV(ssl);
-                    ForceZero(nonce, AEAD_NONCE_SZ);
-                }
-                break;
-        #endif
-
-        #ifdef HAVE_CAMELLIA
-            case wolfssl_camellia:
-                wc_CamelliaCbcEncrypt(ssl->encrypt.cam, out, input, sz);
-                break;
-        #endif
-
-        #ifdef HAVE_HC128
-            case wolfssl_hc128:
-                ret = wc_Hc128_Process(ssl->encrypt.hc128, out, input, sz);
-                break;
-        #endif
-
-        #ifdef BUILD_RABBIT
-            case wolfssl_rabbit:
-                ret = wc_RabbitProcess(ssl->encrypt.rabbit, out, input, sz);
-                break;
-        #endif
-
-        #if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
-            case wolfssl_chacha:
-                ret = ChachaAEADEncrypt(ssl, out, input, sz);
-                break;
-        #endif
-
-        #ifdef HAVE_NULL_CIPHER
-            case wolfssl_cipher_null:
-                if (input != out) {
-                    XMEMMOVE(out, input, sz);
-                }
-                break;
-        #endif
-
-            default:
-                WOLFSSL_MSG("wolfSSL Encrypt programming error");
-                ret = ENCRYPT_ERROR;
-    }
-
-    return ret;
-}
-
-
-
-static INLINE int Decrypt(WOLFSSL* ssl, byte* plain, const byte* input,
-                           word16 sz)
-{
-    int ret = 0;
-
-    (void)plain;
-    (void)input;
-    (void)sz;
-
-    if (ssl->decrypt.setup == 0) {
-        WOLFSSL_MSG("Decrypt ciphers not setup");
-        return DECRYPT_ERROR;
-    }
-
-    switch (ssl->specs.bulk_cipher_algorithm) {
-        #ifdef BUILD_ARC4
-            case wolfssl_rc4:
-                wc_Arc4Process(ssl->decrypt.arc4, plain, input, sz);
-                break;
-        #endif
-
-        #ifdef BUILD_DES3
-            case wolfssl_triple_des:
-                ret = wc_Des3_CbcDecrypt(ssl->decrypt.des3, plain, input, sz);
-                break;
-        #endif
-
-        #ifdef BUILD_AES
-            case wolfssl_aes:
-                ret = wc_AesCbcDecrypt(ssl->decrypt.aes, plain, input, sz);
-                break;
-        #endif
-
-        #ifdef BUILD_AESGCM
-            case wolfssl_aes_gcm:
-            {
-                byte additional[AEAD_AUTH_DATA_SZ];
-                byte nonce[AEAD_NONCE_SZ];
-
-                XMEMSET(additional, 0, AEAD_AUTH_DATA_SZ);
-
-                /* sequence number field is 64-bits, we only use 32-bits */
-                c32toa(GetSEQIncrement(ssl, 1), additional + AEAD_SEQ_OFFSET);
-
-                #ifdef WOLFSSL_DTLS
-                    if (ssl->options.dtls)
-                        c16toa(ssl->keys.dtls_state.curEpoch, additional);
-                #endif
-
-                additional[AEAD_TYPE_OFFSET] = ssl->curRL.type;
-                additional[AEAD_VMAJ_OFFSET] = ssl->curRL.pvMajor;
-                additional[AEAD_VMIN_OFFSET] = ssl->curRL.pvMinor;
-
-                c16toa(sz - AEAD_EXP_IV_SZ - ssl->specs.aead_mac_size,
-                                        additional + AEAD_LEN_OFFSET);
-                XMEMCPY(nonce, ssl->keys.aead_dec_imp_IV, AEAD_IMP_IV_SZ);
-                XMEMCPY(nonce + AEAD_IMP_IV_SZ, input, AEAD_EXP_IV_SZ);
-                if (wc_AesGcmDecrypt(ssl->decrypt.aes,
-                            plain + AEAD_EXP_IV_SZ,
-                            input + AEAD_EXP_IV_SZ,
-                                sz - AEAD_EXP_IV_SZ - ssl->specs.aead_mac_size,
-                            nonce, AEAD_NONCE_SZ,
-                            input + sz - ssl->specs.aead_mac_size,
-                            ssl->specs.aead_mac_size,
-                            additional, AEAD_AUTH_DATA_SZ) < 0) {
-                    SendAlert(ssl, alert_fatal, bad_record_mac);
-                    ret = VERIFY_MAC_ERROR;
-                }
-                ForceZero(nonce, AEAD_NONCE_SZ);
-            }
-            break;
-        #endif
-
-        #ifdef HAVE_AESCCM
-            case wolfssl_aes_ccm:
-            {
-                byte additional[AEAD_AUTH_DATA_SZ];
-                byte nonce[AEAD_NONCE_SZ];
-
-                XMEMSET(additional, 0, AEAD_AUTH_DATA_SZ);
-
-                /* sequence number field is 64-bits, we only use 32-bits */
-                c32toa(GetSEQIncrement(ssl, 1), additional + AEAD_SEQ_OFFSET);
-
-                #ifdef WOLFSSL_DTLS
-                    if (ssl->options.dtls)
-                        c16toa(ssl->keys.dtls_state.curEpoch, additional);
-                #endif
-
-                additional[AEAD_TYPE_OFFSET] = ssl->curRL.type;
-                additional[AEAD_VMAJ_OFFSET] = ssl->curRL.pvMajor;
-                additional[AEAD_VMIN_OFFSET] = ssl->curRL.pvMinor;
-
-                c16toa(sz - AEAD_EXP_IV_SZ - ssl->specs.aead_mac_size,
-                                        additional + AEAD_LEN_OFFSET);
-                XMEMCPY(nonce, ssl->keys.aead_dec_imp_IV, AEAD_IMP_IV_SZ);
-                XMEMCPY(nonce + AEAD_IMP_IV_SZ, input, AEAD_EXP_IV_SZ);
-                if (wc_AesCcmDecrypt(ssl->decrypt.aes,
-                            plain + AEAD_EXP_IV_SZ,
-                            input + AEAD_EXP_IV_SZ,
-                                sz - AEAD_EXP_IV_SZ - ssl->specs.aead_mac_size,
-                            nonce, AEAD_NONCE_SZ,
-                            input + sz - ssl->specs.aead_mac_size,
-                            ssl->specs.aead_mac_size,
-                            additional, AEAD_AUTH_DATA_SZ) < 0) {
-                    SendAlert(ssl, alert_fatal, bad_record_mac);
-                    ret = VERIFY_MAC_ERROR;
-                }
-                ForceZero(nonce, AEAD_NONCE_SZ);
-            }
-            break;
-        #endif
-
-        #ifdef HAVE_CAMELLIA
-            case wolfssl_camellia:
-                wc_CamelliaCbcDecrypt(ssl->decrypt.cam, plain, input, sz);
-                break;
-        #endif
-
-        #ifdef HAVE_HC128
-            case wolfssl_hc128:
-                ret = wc_Hc128_Process(ssl->decrypt.hc128, plain, input, sz);
-                break;
-        #endif
-
-        #ifdef BUILD_RABBIT
-            case wolfssl_rabbit:
-                ret = wc_RabbitProcess(ssl->decrypt.rabbit, plain, input, sz);
-                break;
-        #endif
-
-        #if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
-            case wolfssl_chacha:
-                ret = ChachaAEADDecrypt(ssl, plain, input, sz);
-                break;
-        #endif
-
-        #ifdef HAVE_NULL_CIPHER
-            case wolfssl_cipher_null:
-                if (input != plain) {
-                    XMEMMOVE(plain, input, sz);
-                }
-                break;
-        #endif
-
-            default:
-                WOLFSSL_MSG("wolfSSL Decrypt programming error");
-                ret = DECRYPT_ERROR;
-    }
-
-    return ret;
-}
-
-
-/* check cipher text size for sanity */
-static int SanityCheckCipherText(WOLFSSL* ssl, word32 encryptSz)
-{
-#ifdef HAVE_TRUNCATED_HMAC
-    word32 minLength = ssl->truncated_hmac ? TRUNCATED_HMAC_SZ
-                                           : ssl->specs.hash_size;
-#else
-    word32 minLength = ssl->specs.hash_size; /* covers stream */
-#endif
-
-    if (ssl->specs.cipher_type == block) {
-        if (encryptSz % ssl->specs.block_size) {
-            WOLFSSL_MSG("Block ciphertext not block size");
-            return SANITY_CIPHER_E;
-        }
-
-        minLength++;  /* pad byte */
-
-        if (ssl->specs.block_size > minLength)
-            minLength = ssl->specs.block_size;
-
-        if (ssl->options.tls1_1)
-            minLength += ssl->specs.block_size;  /* explicit IV */
-    }
-    else if (ssl->specs.cipher_type == aead) {
-        minLength = ssl->specs.aead_mac_size;    /* authTag size */
-        if (ssl->specs.bulk_cipher_algorithm != wolfssl_chacha)
-           minLength += AEAD_EXP_IV_SZ;          /* explicit IV  */
-    }
-
-    if (encryptSz < minLength) {
-        WOLFSSL_MSG("Ciphertext not minimum size");
-        return SANITY_CIPHER_E;
-    }
-
-    return 0;
-}
-
-
-#ifndef NO_OLD_TLS
-
-static INLINE void Md5Rounds(int rounds, const byte* data, int sz)
-{
-    Md5 md5;
-    int i;
-
-    wc_InitMd5(&md5);
-
-    for (i = 0; i < rounds; i++)
-        wc_Md5Update(&md5, data, sz);
-}
-
-
-
-/* do a dummy sha round */
-static INLINE void ShaRounds(int rounds, const byte* data, int sz)
-{
-    Sha sha;
-    int i;
-
-    wc_InitSha(&sha);  /* no error check on purpose, dummy round */
-
-    for (i = 0; i < rounds; i++)
-        wc_ShaUpdate(&sha, data, sz);
-}
-#endif
-
-
-#ifndef NO_SHA256
-
-static INLINE void Sha256Rounds(int rounds, const byte* data, int sz)
-{
-    Sha256 sha256;
-    int i;
-
-    wc_InitSha256(&sha256);  /* no error check on purpose, dummy round */
-
-    for (i = 0; i < rounds; i++) {
-        wc_Sha256Update(&sha256, data, sz);
-        /* no error check on purpose, dummy round */
-    }
-
-}
-
-#endif
-
-
-#ifdef WOLFSSL_SHA384
-
-static INLINE void Sha384Rounds(int rounds, const byte* data, int sz)
-{
-    Sha384 sha384;
-    int i;
-
-    wc_InitSha384(&sha384);  /* no error check on purpose, dummy round */
-
-    for (i = 0; i < rounds; i++) {
-        wc_Sha384Update(&sha384, data, sz);
-        /* no error check on purpose, dummy round */
-    }
-}
-
-#endif
-
-
-#ifdef WOLFSSL_SHA512
-
-static INLINE void Sha512Rounds(int rounds, const byte* data, int sz)
-{
-    Sha512 sha512;
-    int i;
-
-    wc_InitSha512(&sha512);  /* no error check on purpose, dummy round */
-
-    for (i = 0; i < rounds; i++) {
-        wc_Sha512Update(&sha512, data, sz);
-        /* no error check on purpose, dummy round */
-    }
-}
-
-#endif
-
-
-#ifdef WOLFSSL_RIPEMD
-
-static INLINE void RmdRounds(int rounds, const byte* data, int sz)
-{
-    RipeMd ripemd;
-    int i;
-
-    wc_InitRipeMd(&ripemd);
-
-    for (i = 0; i < rounds; i++)
-        wc_RipeMdUpdate(&ripemd, data, sz);
-}
-
-#endif
-
-
-/* Do dummy rounds */
-static INLINE void DoRounds(int type, int rounds, const byte* data, int sz)
-{
-    switch (type) {
-
-        case no_mac :
-            break;
-
-#ifndef NO_OLD_TLS
-#ifndef NO_MD5
-        case md5_mac :
-            Md5Rounds(rounds, data, sz);
-            break;
-#endif
-
-#ifndef NO_SHA
-        case sha_mac :
-            ShaRounds(rounds, data, sz);
-            break;
-#endif
-#endif
-
-#ifndef NO_SHA256
-        case sha256_mac :
-            Sha256Rounds(rounds, data, sz);
-            break;
-#endif
-
-#ifdef WOLFSSL_SHA384
-        case sha384_mac :
-            Sha384Rounds(rounds, data, sz);
-            break;
-#endif
-
-#ifdef WOLFSSL_SHA512
-        case sha512_mac :
-            Sha512Rounds(rounds, data, sz);
-            break;
-#endif
-
-#ifdef WOLFSSL_RIPEMD
-        case rmd_mac :
-            RmdRounds(rounds, data, sz);
-            break;
-#endif
-
-        default:
-            WOLFSSL_MSG("Bad round type");
-            break;
-    }
-}
-
-
-/* do number of compression rounds on dummy data */
-static INLINE void CompressRounds(WOLFSSL* ssl, int rounds, const byte* dummy)
-{
-    if (rounds)
-        DoRounds(ssl->specs.mac_algorithm, rounds, dummy, COMPRESS_LOWER);
-}
-
-
-/* check all length bytes for the pad value, return 0 on success */
-static int PadCheck(const byte* a, byte pad, int length)
-{
-    int i;
-    int compareSum = 0;
-
-    for (i = 0; i < length; i++) {
-        compareSum |= a[i] ^ pad;
-    }
-
-    return compareSum;
-}
-
-
-/* get compression extra rounds */
-static INLINE int GetRounds(int pLen, int padLen, int t)
-{
-    int  roundL1 = 1;  /* round up flags */
-    int  roundL2 = 1;
-
-    int L1 = COMPRESS_CONSTANT + pLen - t;
-    int L2 = COMPRESS_CONSTANT + pLen - padLen - 1 - t;
-
-    L1 -= COMPRESS_UPPER;
-    L2 -= COMPRESS_UPPER;
-
-    if ( (L1 % COMPRESS_LOWER) == 0)
-        roundL1 = 0;
-    if ( (L2 % COMPRESS_LOWER) == 0)
-        roundL2 = 0;
-
-    L1 /= COMPRESS_LOWER;
-    L2 /= COMPRESS_LOWER;
-
-    L1 += roundL1;
-    L2 += roundL2;
-
-    return L1 - L2;
-}
-
-
-/* timing resistant pad/verify check, return 0 on success */
-static int TimingPadVerify(WOLFSSL* ssl, const byte* input, int padLen, int t,
-                           int pLen, int content)
-{
-    byte verify[MAX_DIGEST_SIZE];
-    byte dmy[sizeof(WOLFSSL) >= MAX_PAD_SIZE ? 1 : MAX_PAD_SIZE] = {0};
-    byte* dummy = sizeof(dmy) < MAX_PAD_SIZE ? (byte*) ssl : dmy;
-    int  ret = 0;
-
-    (void)dmy;
-
-    if ( (t + padLen + 1) > pLen) {
-        WOLFSSL_MSG("Plain Len not long enough for pad/mac");
-        PadCheck(dummy, (byte)padLen, MAX_PAD_SIZE);
-        ssl->hmac(ssl, verify, input, pLen - t, content, 1); /* still compare */
-        ConstantCompare(verify, input + pLen - t, t);
-
-        return VERIFY_MAC_ERROR;
-    }
-
-    if (PadCheck(input + pLen - (padLen + 1), (byte)padLen, padLen + 1) != 0) {
-        WOLFSSL_MSG("PadCheck failed");
-        PadCheck(dummy, (byte)padLen, MAX_PAD_SIZE - padLen - 1);
-        ssl->hmac(ssl, verify, input, pLen - t, content, 1); /* still compare */
-        ConstantCompare(verify, input + pLen - t, t);
-
-        return VERIFY_MAC_ERROR;
-    }
-
-    PadCheck(dummy, (byte)padLen, MAX_PAD_SIZE - padLen - 1);
-    ret = ssl->hmac(ssl, verify, input, pLen - padLen - 1 - t, content, 1);
-
-    CompressRounds(ssl, GetRounds(pLen, padLen, t), dummy);
-
-    if (ConstantCompare(verify, input + (pLen - padLen - 1 - t), t) != 0) {
-        WOLFSSL_MSG("Verify MAC compare failed");
-        return VERIFY_MAC_ERROR;
-    }
-
-    if (ret != 0)
-        return VERIFY_MAC_ERROR;
-    return 0;
-}
-
-
-int DoApplicationData(WOLFSSL* ssl, byte* input, word32* inOutIdx)
-{
-    word32 msgSz   = ssl->keys.encryptSz;
-    word32 idx     = *inOutIdx;
-    int    dataSz;
-    int    ivExtra = 0;
-    byte*  rawData = input + idx;  /* keep current  for hmac */
-#ifdef HAVE_LIBZ
-    byte   decomp[MAX_RECORD_SIZE + MAX_COMP_EXTRA];
-#endif
-
-    if (ssl->options.handShakeDone == 0) {
-        WOLFSSL_MSG("Received App data before a handshake completed");
-        SendAlert(ssl, alert_fatal, unexpected_message);
-        return OUT_OF_ORDER_E;
-    }
-
-    if (ssl->specs.cipher_type == block) {
-        if (ssl->options.tls1_1)
-            ivExtra = ssl->specs.block_size;
-    }
-    else if (ssl->specs.cipher_type == aead) {
-        if (ssl->specs.bulk_cipher_algorithm != wolfssl_chacha)
-            ivExtra = AEAD_EXP_IV_SZ;
-    }
-
-    dataSz = msgSz - ivExtra - ssl->keys.padSz;
-    if (dataSz < 0) {
-        WOLFSSL_MSG("App data buffer error, malicious input?");
-        return BUFFER_ERROR;
-    }
-
-    /* read data */
-    if (dataSz) {
-        int rawSz = dataSz;       /* keep raw size for idx adjustment */
-
-#ifdef HAVE_LIBZ
-        if (ssl->options.usingCompression) {
-            dataSz = myDeCompress(ssl, rawData, dataSz, decomp, sizeof(decomp));
-            if (dataSz < 0) return dataSz;
-        }
-#endif
-        idx += rawSz;
-
-        ssl->buffers.clearOutputBuffer.buffer = rawData;
-        ssl->buffers.clearOutputBuffer.length = dataSz;
-    }
-
-    idx += ssl->keys.padSz;
-
-#ifdef HAVE_LIBZ
-    /* decompress could be bigger, overwrite after verify */
-    if (ssl->options.usingCompression)
-        XMEMMOVE(rawData, decomp, dataSz);
-#endif
-
-    *inOutIdx = idx;
-    return 0;
-}
-
-
-/* process alert, return level */
-static int DoAlert(WOLFSSL* ssl, byte* input, word32* inOutIdx, int* type,
-                   word32 totalSz)
-{
-    byte level;
-    byte code;
-
-    #ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn)
-            AddPacketName("Alert", &ssl->handShakeInfo);
-        if (ssl->toInfoOn)
-            /* add record header back on to info + 2 byte level, data */
-            AddPacketInfo("Alert", &ssl->timeoutInfo, input + *inOutIdx -
-                          RECORD_HEADER_SZ, 2 + RECORD_HEADER_SZ, ssl->heap);
-    #endif
-
-    /* make sure can read the message */
-    if (*inOutIdx + ALERT_SIZE > totalSz)
-        return BUFFER_E;
-
-    level = input[(*inOutIdx)++];
-    code  = input[(*inOutIdx)++];
-    ssl->alert_history.last_rx.code = code;
-    ssl->alert_history.last_rx.level = level;
-    *type = code;
-    if (level == alert_fatal) {
-        ssl->options.isClosed = 1;  /* Don't send close_notify */
-    }
-
-    WOLFSSL_MSG("Got alert");
-    if (*type == close_notify) {
-        WOLFSSL_MSG("    close notify");
-        ssl->options.closeNotify = 1;
-    }
-    WOLFSSL_ERROR(*type);
-    if (ssl->keys.encryptionOn) {
-        if (*inOutIdx + ssl->keys.padSz > totalSz)
-            return BUFFER_E;
-        *inOutIdx += ssl->keys.padSz;
-    }
-
-    return level;
-}
-
-static int GetInputData(WOLFSSL *ssl, word32 size)
-{
-    int in;
-    int inSz;
-    int maxLength;
-    int usedLength;
-    int dtlsExtra = 0;
-
-
-    /* check max input length */
-    usedLength = ssl->buffers.inputBuffer.length - ssl->buffers.inputBuffer.idx;
-    maxLength  = ssl->buffers.inputBuffer.bufferSize - usedLength;
-    inSz       = (int)(size - usedLength);      /* from last partial read */
-
-#ifdef WOLFSSL_DTLS
-    if (ssl->options.dtls) {
-        if (size < ssl->dtls_expected_rx)
-            dtlsExtra = (int)(ssl->dtls_expected_rx - size);
-        inSz = ssl->dtls_expected_rx;
-    }
-#endif
-
-    if (inSz > maxLength) {
-        if (GrowInputBuffer(ssl, size + dtlsExtra, usedLength) < 0)
-            return MEMORY_E;
-    }
-
-    if (inSz <= 0)
-        return BUFFER_ERROR;
-
-    /* Put buffer data at start if not there */
-    if (usedLength > 0 && ssl->buffers.inputBuffer.idx != 0)
-        XMEMMOVE(ssl->buffers.inputBuffer.buffer,
-                ssl->buffers.inputBuffer.buffer + ssl->buffers.inputBuffer.idx,
-                usedLength);
-
-    /* remove processed data */
-    ssl->buffers.inputBuffer.idx    = 0;
-    ssl->buffers.inputBuffer.length = usedLength;
-
-    /* read data from network */
-    do {
-        in = Receive(ssl,
-                     ssl->buffers.inputBuffer.buffer +
-                     ssl->buffers.inputBuffer.length,
-                     inSz);
-        if (in == -1)
-            return SOCKET_ERROR_E;
-
-        if (in == WANT_READ)
-            return WANT_READ;
-
-        if (in > inSz)
-            return RECV_OVERFLOW_E;
-
-        ssl->buffers.inputBuffer.length += in;
-        inSz -= in;
-
-    } while (ssl->buffers.inputBuffer.length < size);
-
-    return 0;
-}
-
-
-static INLINE int VerifyMac(WOLFSSL* ssl, const byte* input, word32 msgSz,
-                            int content, word32* padSz)
-{
-    int    ivExtra = 0;
-    int    ret;
-    word32 pad     = 0;
-    word32 padByte = 0;
-#ifdef HAVE_TRUNCATED_HMAC
-    word32 digestSz = ssl->truncated_hmac ? TRUNCATED_HMAC_SZ
-                                          : ssl->specs.hash_size;
-#else
-    word32 digestSz = ssl->specs.hash_size;
-#endif
-    byte   verify[MAX_DIGEST_SIZE];
-
-    if (ssl->specs.cipher_type == block) {
-        if (ssl->options.tls1_1)
-            ivExtra = ssl->specs.block_size;
-        pad = *(input + msgSz - ivExtra - 1);
-        padByte = 1;
-
-        if (ssl->options.tls) {
-            ret = TimingPadVerify(ssl, input, pad, digestSz, msgSz - ivExtra,
-                                  content);
-            if (ret != 0)
-                return ret;
-        }
-        else {  /* sslv3, some implementations have bad padding, but don't
-                 * allow bad read */
-            int  badPadLen = 0;
-            byte dmy[sizeof(WOLFSSL) >= MAX_PAD_SIZE ? 1 : MAX_PAD_SIZE] = {0};
-            byte* dummy = sizeof(dmy) < MAX_PAD_SIZE ? (byte*) ssl : dmy;
-
-            (void)dmy;
-
-            if (pad > (msgSz - digestSz - 1)) {
-                WOLFSSL_MSG("Plain Len not long enough for pad/mac");
-                pad       = 0;  /* no bad read */
-                badPadLen = 1;
-            }
-            PadCheck(dummy, (byte)pad, MAX_PAD_SIZE);  /* timing only */
-            ret = ssl->hmac(ssl, verify, input, msgSz - digestSz - pad - 1,
-                            content, 1);
-            if (ConstantCompare(verify, input + msgSz - digestSz - pad - 1,
-                                digestSz) != 0)
-                return VERIFY_MAC_ERROR;
-            if (ret != 0 || badPadLen)
-                return VERIFY_MAC_ERROR;
-        }
-    }
-    else if (ssl->specs.cipher_type == stream) {
-        ret = ssl->hmac(ssl, verify, input, msgSz - digestSz, content, 1);
-        if (ConstantCompare(verify, input + msgSz - digestSz, digestSz) != 0){
-            return VERIFY_MAC_ERROR;
-        }
-        if (ret != 0)
-            return VERIFY_MAC_ERROR;
-    }
-
-    if (ssl->specs.cipher_type == aead) {
-        *padSz = ssl->specs.aead_mac_size;
-    }
-    else {
-        *padSz = digestSz + pad + padByte;
-    }
-
-    return 0;
-}
-
-
-/* process input requests, return 0 is done, 1 is call again to complete, and
-   negative number is error */
-int ProcessReply(WOLFSSL* ssl)
-{
-    int    ret = 0, type, readSz;
-    int    atomicUser = 0;
-    word32 startIdx = 0;
-#ifdef WOLFSSL_DTLS
-    int    used;
-#endif
-
-#ifdef ATOMIC_USER
-    if (ssl->ctx->DecryptVerifyCb)
-        atomicUser = 1;
-#endif
-
-    if (ssl->error != 0 && ssl->error != WANT_READ && ssl->error != WANT_WRITE){
-        WOLFSSL_MSG("ProcessReply retry in error state, not allowed");
-        return ssl->error;
-    }
-
-    for (;;) {
-        switch (ssl->options.processReply) {
-
-        /* in the WOLFSSL_SERVER case, get the first byte for detecting
-         * old client hello */
-        case doProcessInit:
-
-            readSz = RECORD_HEADER_SZ;
-
-            #ifdef WOLFSSL_DTLS
-                if (ssl->options.dtls)
-                    readSz = DTLS_RECORD_HEADER_SZ;
-            #endif
-
-            /* get header or return error */
-            if (!ssl->options.dtls) {
-                if ((ret = GetInputData(ssl, readSz)) < 0)
-                    return ret;
-            } else {
-            #ifdef WOLFSSL_DTLS
-                /* read ahead may already have header */
-                used = ssl->buffers.inputBuffer.length -
-                       ssl->buffers.inputBuffer.idx;
-                if (used < readSz)
-                    if ((ret = GetInputData(ssl, readSz)) < 0)
-                        return ret;
-            #endif
-            }
-
-#ifdef OLD_HELLO_ALLOWED
-
-            /* see if sending SSLv2 client hello */
-            if ( ssl->options.side == WOLFSSL_SERVER_END &&
-                 ssl->options.clientState == NULL_STATE &&
-                 ssl->buffers.inputBuffer.buffer[ssl->buffers.inputBuffer.idx]
-                         != handshake) {
-                byte b0, b1;
-
-                ssl->options.processReply = runProcessOldClientHello;
-
-                /* sanity checks before getting size at front */
-                if (ssl->buffers.inputBuffer.buffer[
-                          ssl->buffers.inputBuffer.idx + 2] != OLD_HELLO_ID) {
-                    WOLFSSL_MSG("Not a valid old client hello");
-                    return PARSE_ERROR;
-                }
-
-                if (ssl->buffers.inputBuffer.buffer[
-                          ssl->buffers.inputBuffer.idx + 3] != SSLv3_MAJOR &&
-                    ssl->buffers.inputBuffer.buffer[
-                          ssl->buffers.inputBuffer.idx + 3] != DTLS_MAJOR) {
-                    WOLFSSL_MSG("Not a valid version in old client hello");
-                    return PARSE_ERROR;
-                }
-
-                /* how many bytes need ProcessOldClientHello */
-                b0 =
-                ssl->buffers.inputBuffer.buffer[ssl->buffers.inputBuffer.idx++];
-                b1 =
-                ssl->buffers.inputBuffer.buffer[ssl->buffers.inputBuffer.idx++];
-                ssl->curSize = (word16)(((b0 & 0x7f) << 8) | b1);
-            }
-            else {
-                ssl->options.processReply = getRecordLayerHeader;
-                continue;
-            }
-
-        /* in the WOLFSSL_SERVER case, run the old client hello */
-        case runProcessOldClientHello:
-
-            /* get sz bytes or return error */
-            if (!ssl->options.dtls) {
-                if ((ret = GetInputData(ssl, ssl->curSize)) < 0)
-                    return ret;
-            } else {
-            #ifdef WOLFSSL_DTLS
-                /* read ahead may already have */
-                used = ssl->buffers.inputBuffer.length -
-                       ssl->buffers.inputBuffer.idx;
-                if (used < ssl->curSize)
-                    if ((ret = GetInputData(ssl, ssl->curSize)) < 0)
-                        return ret;
-            #endif  /* WOLFSSL_DTLS */
-            }
-
-            ret = ProcessOldClientHello(ssl, ssl->buffers.inputBuffer.buffer,
-                                        &ssl->buffers.inputBuffer.idx,
-                                        ssl->buffers.inputBuffer.length -
-                                        ssl->buffers.inputBuffer.idx,
-                                        ssl->curSize);
-            if (ret < 0)
-                return ret;
-
-            else if (ssl->buffers.inputBuffer.idx ==
-                     ssl->buffers.inputBuffer.length) {
-                ssl->options.processReply = doProcessInit;
-                return 0;
-            }
-
-#endif  /* OLD_HELLO_ALLOWED */
-
-        /* get the record layer header */
-        case getRecordLayerHeader:
-
-            ret = GetRecordHeader(ssl, ssl->buffers.inputBuffer.buffer,
-                                       &ssl->buffers.inputBuffer.idx,
-                                       &ssl->curRL, &ssl->curSize);
-#ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls && ret == SEQUENCE_ERROR) {
-                ssl->options.processReply = doProcessInit;
-                ssl->buffers.inputBuffer.length = 0;
-                ssl->buffers.inputBuffer.idx = 0;
-                continue;
-            }
-#endif
-            if (ret != 0)
-                return ret;
-
-            ssl->options.processReply = getData;
-
-        /* retrieve record layer data */
-        case getData:
-
-            /* get sz bytes or return error */
-            if (!ssl->options.dtls) {
-                if ((ret = GetInputData(ssl, ssl->curSize)) < 0)
-                    return ret;
-            } else {
-#ifdef WOLFSSL_DTLS
-                /* read ahead may already have */
-                used = ssl->buffers.inputBuffer.length -
-                       ssl->buffers.inputBuffer.idx;
-                if (used < ssl->curSize)
-                    if ((ret = GetInputData(ssl, ssl->curSize)) < 0)
-                        return ret;
-#endif
-            }
-
-            ssl->options.processReply = runProcessingOneMessage;
-            startIdx = ssl->buffers.inputBuffer.idx;  /* in case > 1 msg per */
-
-        /* the record layer is here */
-        case runProcessingOneMessage:
-
-            #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls &&
-                ssl->keys.dtls_state.curEpoch < ssl->keys.dtls_state.nextEpoch)
-                ssl->keys.decryptedCur = 1;
-            #endif
-
-            if (ssl->keys.encryptionOn && ssl->keys.decryptedCur == 0)
-            {
-                ret = SanityCheckCipherText(ssl, ssl->curSize);
-                if (ret < 0)
-                    return ret;
-
-                if (atomicUser) {
-                #ifdef ATOMIC_USER
-                    ret = ssl->ctx->DecryptVerifyCb(ssl,
-                                  ssl->buffers.inputBuffer.buffer +
-                                  ssl->buffers.inputBuffer.idx,
-                                  ssl->buffers.inputBuffer.buffer +
-                                  ssl->buffers.inputBuffer.idx,
-                                  ssl->curSize, ssl->curRL.type, 1,
-                                  &ssl->keys.padSz, ssl->DecryptVerifyCtx);
-                    if (ssl->options.tls1_1 && ssl->specs.cipher_type == block)
-                        ssl->buffers.inputBuffer.idx += ssl->specs.block_size;
-                        /* go past TLSv1.1 IV */
-                    if (ssl->specs.cipher_type == aead &&
-                            ssl->specs.bulk_cipher_algorithm != wolfssl_chacha)
-                        ssl->buffers.inputBuffer.idx += AEAD_EXP_IV_SZ;
-                #endif /* ATOMIC_USER */
-                }
-                else {
-                    ret = Decrypt(ssl, ssl->buffers.inputBuffer.buffer +
-                                  ssl->buffers.inputBuffer.idx,
-                                  ssl->buffers.inputBuffer.buffer +
-                                  ssl->buffers.inputBuffer.idx,
-                                  ssl->curSize);
-                    if (ret < 0) {
-                        WOLFSSL_ERROR(ret);
-                        return DECRYPT_ERROR;
-                    }
-                    if (ssl->options.tls1_1 && ssl->specs.cipher_type == block)
-                        ssl->buffers.inputBuffer.idx += ssl->specs.block_size;
-                        /* go past TLSv1.1 IV */
-                    if (ssl->specs.cipher_type == aead &&
-                            ssl->specs.bulk_cipher_algorithm != wolfssl_chacha)
-                        ssl->buffers.inputBuffer.idx += AEAD_EXP_IV_SZ;
-
-                    ret = VerifyMac(ssl, ssl->buffers.inputBuffer.buffer +
-                                    ssl->buffers.inputBuffer.idx,
-                                    ssl->curSize, ssl->curRL.type,
-                                    &ssl->keys.padSz);
-                }
-                if (ret < 0) {
-                    WOLFSSL_ERROR(ret);
-                    return DECRYPT_ERROR;
-                }
-                ssl->keys.encryptSz    = ssl->curSize;
-                ssl->keys.decryptedCur = 1;
-            }
-
-            if (ssl->options.dtls) {
-            #ifdef WOLFSSL_DTLS
-                DtlsUpdateWindow(&ssl->keys.dtls_state);
-            #endif /* WOLFSSL_DTLS */
-            }
-
-            WOLFSSL_MSG("received record layer msg");
-
-            switch (ssl->curRL.type) {
-                case handshake :
-                    /* debugging in DoHandShakeMsg */
-                    if (!ssl->options.dtls) {
-                        ret = DoHandShakeMsg(ssl,
-                                            ssl->buffers.inputBuffer.buffer,
-                                            &ssl->buffers.inputBuffer.idx,
-                                            ssl->buffers.inputBuffer.length);
-                    }
-                    else {
-#ifdef WOLFSSL_DTLS
-                        ret = DoDtlsHandShakeMsg(ssl,
-                                            ssl->buffers.inputBuffer.buffer,
-                                            &ssl->buffers.inputBuffer.idx,
-                                            ssl->buffers.inputBuffer.length);
-#endif
-                    }
-                    if (ret != 0)
-                        return ret;
-                    break;
-
-                case change_cipher_spec:
-                    WOLFSSL_MSG("got CHANGE CIPHER SPEC");
-                    #ifdef WOLFSSL_CALLBACKS
-                        if (ssl->hsInfoOn)
-                            AddPacketName("ChangeCipher", &ssl->handShakeInfo);
-                        /* add record header back on info */
-                        if (ssl->toInfoOn) {
-                            AddPacketInfo("ChangeCipher", &ssl->timeoutInfo,
-                                ssl->buffers.inputBuffer.buffer +
-                                ssl->buffers.inputBuffer.idx - RECORD_HEADER_SZ,
-                                1 + RECORD_HEADER_SZ, ssl->heap);
-                            AddLateRecordHeader(&ssl->curRL, &ssl->timeoutInfo);
-                        }
-                    #endif
-
-                    ret = SanityCheckMsgReceived(ssl, change_cipher_hs);
-                    if (ret != 0)
-                        return ret;
-
-#ifdef HAVE_SESSION_TICKET
-                    if (ssl->options.side == WOLFSSL_CLIENT_END &&
-                                                  ssl->expect_session_ticket) {
-                        WOLFSSL_MSG("Expected session ticket missing");
-                        return SESSION_TICKET_EXPECT_E;
-                    }
-#endif
-
-                    if (ssl->keys.encryptionOn && ssl->options.handShakeDone) {
-                        ssl->buffers.inputBuffer.idx += ssl->keys.padSz;
-                        ssl->curSize -= (word16) ssl->buffers.inputBuffer.idx;
-                    }
-
-                    if (ssl->curSize != 1) {
-                        WOLFSSL_MSG("Malicious or corrupted ChangeCipher msg");
-                        return LENGTH_ERROR;
-                    }
-                    #ifndef NO_CERTS
-                        if (ssl->options.side == WOLFSSL_SERVER_END &&
-                                 ssl->options.verifyPeer &&
-                                 ssl->options.havePeerCert)
-                            if (!ssl->options.havePeerVerify) {
-                                WOLFSSL_MSG("client didn't send cert verify");
-                                return NO_PEER_VERIFY;
-                            }
-                    #endif
-
-
-                    ssl->buffers.inputBuffer.idx++;
-                    ssl->keys.encryptionOn = 1;
-
-                    /* setup decrypt keys for following messages */
-                    if ((ret = SetKeysSide(ssl, DECRYPT_SIDE_ONLY)) != 0)
-                        return ret;
-
-                    #ifdef WOLFSSL_DTLS
-                        if (ssl->options.dtls) {
-                            DtlsPoolReset(ssl);
-                            ssl->keys.dtls_state.nextEpoch++;
-                            ssl->keys.dtls_state.nextSeq = 0;
-                        }
-                    #endif
-
-                    #ifdef HAVE_LIBZ
-                        if (ssl->options.usingCompression)
-                            if ( (ret = InitStreams(ssl)) != 0)
-                                return ret;
-                    #endif
-                    ret = BuildFinished(ssl, &ssl->hsHashes->verifyHashes,
-                                       ssl->options.side == WOLFSSL_CLIENT_END ?
-                                       server : client);
-                    if (ret != 0)
-                        return ret;
-                    break;
-
-                case application_data:
-                    WOLFSSL_MSG("got app DATA");
-                    if ((ret = DoApplicationData(ssl,
-                                                ssl->buffers.inputBuffer.buffer,
-                                               &ssl->buffers.inputBuffer.idx))
-                                                                         != 0) {
-                        WOLFSSL_ERROR(ret);
-                        return ret;
-                    }
-                    break;
-
-                case alert:
-                    WOLFSSL_MSG("got ALERT!");
-                    ret = DoAlert(ssl, ssl->buffers.inputBuffer.buffer,
-                                  &ssl->buffers.inputBuffer.idx, &type,
-                                   ssl->buffers.inputBuffer.length);
-                    if (ret == alert_fatal)
-                        return FATAL_ERROR;
-                    else if (ret < 0)
-                        return ret;
-
-                    /* catch warnings that are handled as errors */
-                    if (type == close_notify)
-                        return ssl->error = ZERO_RETURN;
-
-                    if (type == decrypt_error)
-                        return FATAL_ERROR;
-                    break;
-
-                default:
-                    WOLFSSL_ERROR(UNKNOWN_RECORD_TYPE);
-                    return UNKNOWN_RECORD_TYPE;
-            }
-
-            ssl->options.processReply = doProcessInit;
-
-            /* input exhausted? */
-            if (ssl->buffers.inputBuffer.idx == ssl->buffers.inputBuffer.length)
-                return 0;
-
-            /* more messages per record */
-            else if ((ssl->buffers.inputBuffer.idx - startIdx) < ssl->curSize) {
-                WOLFSSL_MSG("More messages in record");
-                #ifdef WOLFSSL_DTLS
-                    /* read-ahead but dtls doesn't bundle messages per record */
-                    if (ssl->options.dtls) {
-                        ssl->options.processReply = doProcessInit;
-                        continue;
-                    }
-                #endif
-                ssl->options.processReply = runProcessingOneMessage;
-
-                if (ssl->keys.encryptionOn) {
-                    WOLFSSL_MSG("Bundled encrypted messages, remove middle pad");
-                    ssl->buffers.inputBuffer.idx -= ssl->keys.padSz;
-                }
-
-                continue;
-            }
-            /* more records */
-            else {
-                WOLFSSL_MSG("More records in input");
-                ssl->options.processReply = doProcessInit;
-                continue;
-            }
-
-        default:
-            WOLFSSL_MSG("Bad process input state, programming error");
-            return INPUT_CASE_ERROR;
-        }
-    }
-}
-
-
-int SendChangeCipher(WOLFSSL* ssl)
-{
-    byte              *output;
-    int                sendSz = RECORD_HEADER_SZ + ENUM_LEN;
-    int                idx    = RECORD_HEADER_SZ;
-    int                ret;
-
-    #ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            sendSz += DTLS_RECORD_EXTRA;
-            idx    += DTLS_RECORD_EXTRA;
-        }
-    #endif
-
-    /* are we in scr */
-    if (ssl->keys.encryptionOn && ssl->options.handShakeDone) {
-        sendSz += MAX_MSG_EXTRA;
-    }
-
-    /* check for avalaible size */
-    if ((ret = CheckAvailableSize(ssl, sendSz)) != 0)
-        return ret;
-
-    /* get ouput buffer */
-    output = ssl->buffers.outputBuffer.buffer +
-             ssl->buffers.outputBuffer.length;
-
-    AddRecordHeader(output, 1, change_cipher_spec, ssl);
-
-    output[idx] = 1;             /* turn it on */
-
-    if (ssl->keys.encryptionOn && ssl->options.handShakeDone) {
-        byte input[ENUM_LEN];
-        int  inputSz = ENUM_LEN;
-
-        input[0] = 1;  /* turn it on */
-        sendSz = BuildMessage(ssl, output, sendSz, input, inputSz,
-                              change_cipher_spec);
-        if (sendSz < 0)
-            return sendSz;
-    }
-
-    #ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0)
-                return ret;
-        }
-    #endif
-    #ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn) AddPacketName("ChangeCipher", &ssl->handShakeInfo);
-        if (ssl->toInfoOn)
-            AddPacketInfo("ChangeCipher", &ssl->timeoutInfo, output, sendSz,
-                           ssl->heap);
-    #endif
-    ssl->buffers.outputBuffer.length += sendSz;
-
-    if (ssl->options.groupMessages)
-        return 0;
-    #ifdef WOLFSSL_DTLS
-    else if (ssl->options.dtls) {
-        /* If using DTLS, force the ChangeCipherSpec message to be in the
-         * same datagram as the finished message. */
-        return 0;
-    }
-    #endif
-    else
-        return SendBuffered(ssl);
-}
-
-
-#ifndef NO_OLD_TLS
-static int SSL_hmac(WOLFSSL* ssl, byte* digest, const byte* in, word32 sz,
-                 int content, int verify)
-{
-    byte   result[MAX_DIGEST_SIZE];
-    word32 digestSz = ssl->specs.hash_size;            /* actual sizes */
-    word32 padSz    = ssl->specs.pad_size;
-    int    ret      = 0;
-
-    Md5 md5;
-    Sha sha;
-
-    /* data */
-    byte seq[SEQ_SZ];
-    byte conLen[ENUM_LEN + LENGTH_SZ];     /* content & length */
-    const byte* macSecret = wolfSSL_GetMacSecret(ssl, verify);
-
-#ifdef HAVE_FUZZER
-    if (ssl->fuzzerCb)
-        ssl->fuzzerCb(ssl, in, sz, FUZZ_HMAC, ssl->fuzzerCtx);
-#endif
-
-    XMEMSET(seq, 0, SEQ_SZ);
-    conLen[0] = (byte)content;
-    c16toa((word16)sz, &conLen[ENUM_LEN]);
-    c32toa(GetSEQIncrement(ssl, verify), &seq[sizeof(word32)]);
-
-    if (ssl->specs.mac_algorithm == md5_mac) {
-        wc_InitMd5(&md5);
-        /* inner */
-        wc_Md5Update(&md5, macSecret, digestSz);
-        wc_Md5Update(&md5, PAD1, padSz);
-        wc_Md5Update(&md5, seq, SEQ_SZ);
-        wc_Md5Update(&md5, conLen, sizeof(conLen));
-        /* in buffer */
-        wc_Md5Update(&md5, in, sz);
-        wc_Md5Final(&md5, result);
-        /* outer */
-        wc_Md5Update(&md5, macSecret, digestSz);
-        wc_Md5Update(&md5, PAD2, padSz);
-        wc_Md5Update(&md5, result, digestSz);
-        wc_Md5Final(&md5, digest);
-    }
-    else {
-        ret = wc_InitSha(&sha);
-        if (ret != 0)
-            return ret;
-        /* inner */
-        wc_ShaUpdate(&sha, macSecret, digestSz);
-        wc_ShaUpdate(&sha, PAD1, padSz);
-        wc_ShaUpdate(&sha, seq, SEQ_SZ);
-        wc_ShaUpdate(&sha, conLen, sizeof(conLen));
-        /* in buffer */
-        wc_ShaUpdate(&sha, in, sz);
-        wc_ShaFinal(&sha, result);
-        /* outer */
-        wc_ShaUpdate(&sha, macSecret, digestSz);
-        wc_ShaUpdate(&sha, PAD2, padSz);
-        wc_ShaUpdate(&sha, result, digestSz);
-        wc_ShaFinal(&sha, digest);
-    }
-    return 0;
-}
-
-#ifndef NO_CERTS
-static void BuildMD5_CertVerify(WOLFSSL* ssl, byte* digest)
-{
-    byte md5_result[MD5_DIGEST_SIZE];
-
-#ifdef WOLFSSL_SMALL_STACK
-        Md5* md5   = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        Md5* md5_2 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#else
-        Md5 md5[1];
-        Md5 md5_2[1];
-#endif
-
-    /* make md5 inner */
-    md5[0] = ssl->hsHashes->hashMd5 ; /* Save current position */
-    wc_Md5Update(&ssl->hsHashes->hashMd5, ssl->arrays->masterSecret,SECRET_LEN);
-    wc_Md5Update(&ssl->hsHashes->hashMd5, PAD1, PAD_MD5);
-    wc_Md5GetHash(&ssl->hsHashes->hashMd5, md5_result);
-    wc_Md5RestorePos(&ssl->hsHashes->hashMd5, md5) ; /* Restore current position */
-
-    /* make md5 outer */
-    wc_InitMd5(md5_2) ;
-    wc_Md5Update(md5_2, ssl->arrays->masterSecret, SECRET_LEN);
-    wc_Md5Update(md5_2, PAD2, PAD_MD5);
-    wc_Md5Update(md5_2, md5_result, MD5_DIGEST_SIZE);
-
-    wc_Md5Final(md5_2, digest);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(md5_2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-}
-
-
-static void BuildSHA_CertVerify(WOLFSSL* ssl, byte* digest)
-{
-    byte sha_result[SHA_DIGEST_SIZE];
-
-#ifdef WOLFSSL_SMALL_STACK
-        Sha* sha   = (Sha*)XMALLOC(sizeof(Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        Sha* sha2 = (Sha*)XMALLOC(sizeof(Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#else
-        Sha sha[1];
-        Sha sha2[1];
-#endif
-
-    /* make sha inner */
-    sha[0] = ssl->hsHashes->hashSha ; /* Save current position */
-    wc_ShaUpdate(&ssl->hsHashes->hashSha, ssl->arrays->masterSecret,SECRET_LEN);
-    wc_ShaUpdate(&ssl->hsHashes->hashSha, PAD1, PAD_SHA);
-    wc_ShaGetHash(&ssl->hsHashes->hashSha, sha_result);
-    wc_ShaRestorePos(&ssl->hsHashes->hashSha, sha) ; /* Restore current position */
-
-    /* make sha outer */
-    wc_InitSha(sha2) ;
-    wc_ShaUpdate(sha2, ssl->arrays->masterSecret,SECRET_LEN);
-    wc_ShaUpdate(sha2, PAD2, PAD_SHA);
-    wc_ShaUpdate(sha2, sha_result, SHA_DIGEST_SIZE);
-
-    wc_ShaFinal(sha2, digest);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(sha2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-}
-#endif /* NO_CERTS */
-#endif /* NO_OLD_TLS */
-
-
-#ifndef NO_CERTS
-
-static int BuildCertHashes(WOLFSSL* ssl, Hashes* hashes)
-{
-    /* store current states, building requires get_digest which resets state */
-    #ifdef WOLFSSL_SHA384
-        Sha384 sha384 = ssl->hsHashes->hashSha384;
-    #endif
-    #ifdef WOLFSSL_SHA512
-        Sha512 sha512 = ssl->hsHashes->hashSha512;
-    #endif
-
-    if (ssl->options.tls) {
-#if ! defined( NO_OLD_TLS )
-        wc_Md5GetHash(&ssl->hsHashes->hashMd5, hashes->md5);
-        wc_ShaGetHash(&ssl->hsHashes->hashSha, hashes->sha);
-#endif
-        if (IsAtLeastTLSv1_2(ssl)) {
-            int ret;
-
-            #ifndef NO_SHA256
-                ret = wc_Sha256GetHash(&ssl->hsHashes->hashSha256,hashes->sha256);
-                if (ret != 0)
-                    return ret;
-            #endif
-            #ifdef WOLFSSL_SHA384
-                ret = wc_Sha384Final(&ssl->hsHashes->hashSha384,hashes->sha384);
-                if (ret != 0)
-                    return ret;
-            #endif
-            #ifdef WOLFSSL_SHA512
-                ret = wc_Sha512Final(&ssl->hsHashes->hashSha512,hashes->sha512);
-                if (ret != 0)
-                    return ret;
-            #endif
-        }
-    }
-#if ! defined( NO_OLD_TLS )
-    else {
-        BuildMD5_CertVerify(ssl, hashes->md5);
-        BuildSHA_CertVerify(ssl, hashes->sha);
-    }
-
-    /* restore */
-#endif
-    if (IsAtLeastTLSv1_2(ssl)) {
-        #ifdef WOLFSSL_SHA384
-            ssl->hsHashes->hashSha384 = sha384;
-        #endif
-        #ifdef WOLFSSL_SHA512
-            ssl->hsHashes->hashSha512 = sha512;
-        #endif
-    }
-
-    return 0;
-}
-
-#endif /* WOLFSSL_LEANPSK */
-
-/* Build SSL Message, encrypted */
-static int BuildMessage(WOLFSSL* ssl, byte* output, int outSz,
-                        const byte* input, int inSz, int type)
-{
-#ifdef HAVE_TRUNCATED_HMAC
-    word32 digestSz = min(ssl->specs.hash_size,
-                ssl->truncated_hmac ? TRUNCATED_HMAC_SZ : ssl->specs.hash_size);
-#else
-    word32 digestSz = ssl->specs.hash_size;
-#endif
-    word32 sz = RECORD_HEADER_SZ + inSz + digestSz;
-    word32 pad  = 0, i;
-    word32 idx  = RECORD_HEADER_SZ;
-    word32 ivSz = 0;      /* TLSv1.1  IV */
-    word32 headerSz = RECORD_HEADER_SZ;
-    word16 size;
-    byte               iv[AES_BLOCK_SIZE];                  /* max size */
-    int ret        = 0;
-    int atomicUser = 0;
-
-#ifdef WOLFSSL_DTLS
-    if (ssl->options.dtls) {
-        sz       += DTLS_RECORD_EXTRA;
-        idx      += DTLS_RECORD_EXTRA;
-        headerSz += DTLS_RECORD_EXTRA;
-    }
-#endif
-
-#ifdef ATOMIC_USER
-    if (ssl->ctx->MacEncryptCb)
-        atomicUser = 1;
-#endif
-
-    if (ssl->specs.cipher_type == block) {
-        word32 blockSz = ssl->specs.block_size;
-        if (ssl->options.tls1_1) {
-            ivSz = blockSz;
-            sz  += ivSz;
-
-            if (ivSz > (word32)sizeof(iv))
-                return BUFFER_E;
-
-            ret = wc_RNG_GenerateBlock(ssl->rng, iv, ivSz);
-            if (ret != 0)
-                return ret;
-
-        }
-        sz += 1;       /* pad byte */
-        pad = (sz - headerSz) % blockSz;
-        pad = blockSz - pad;
-        sz += pad;
-    }
-
-#ifdef HAVE_AEAD
-    if (ssl->specs.cipher_type == aead) {
-        if (ssl->specs.bulk_cipher_algorithm != wolfssl_chacha)
-            ivSz = AEAD_EXP_IV_SZ;
-
-        sz += (ivSz + ssl->specs.aead_mac_size - digestSz);
-        XMEMCPY(iv, ssl->keys.aead_exp_IV, AEAD_EXP_IV_SZ);
-    }
-#endif
-    if (sz > (word32)outSz) {
-        WOLFSSL_MSG("Oops, want to write past output buffer size");
-        return BUFFER_E;
-    }
-    size = (word16)(sz - headerSz);    /* include mac and digest */
-    AddRecordHeader(output, size, (byte)type, ssl);
-
-    /* write to output */
-    if (ivSz) {
-        XMEMCPY(output + idx, iv, min(ivSz, sizeof(iv)));
-        idx += ivSz;
-    }
-    XMEMCPY(output + idx, input, inSz);
-    idx += inSz;
-
-    if (type == handshake) {
-        ret = HashOutput(ssl, output, headerSz + inSz, ivSz);
-        if (ret != 0)
-            return ret;
-    }
-
-    if (ssl->specs.cipher_type == block) {
-        word32 tmpIdx = idx + digestSz;
-
-        for (i = 0; i <= pad; i++)
-            output[tmpIdx++] = (byte)pad; /* pad byte gets pad value too */
-    }
-
-    if (atomicUser) {   /* User Record Layer Callback handling */
-#ifdef ATOMIC_USER
-        if ( (ret = ssl->ctx->MacEncryptCb(ssl, output + idx,
-                        output + headerSz + ivSz, inSz, type, 0,
-                        output + headerSz, output + headerSz, size,
-                        ssl->MacEncryptCtx)) != 0)
-            return ret;
-#endif
-    }
-    else {
-        if (ssl->specs.cipher_type != aead) {
-#ifdef HAVE_TRUNCATED_HMAC
-            if (ssl->truncated_hmac && ssl->specs.hash_size > digestSz) {
-            #ifdef WOLFSSL_SMALL_STACK
-                byte* hmac = NULL;
-            #else
-                byte  hmac[MAX_DIGEST_SIZE];
-            #endif
-
-            #ifdef WOLFSSL_SMALL_STACK
-                hmac = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-                if (hmac == NULL)
-                    return MEMORY_E;
-            #endif
-
-                ret = ssl->hmac(ssl, hmac, output + headerSz + ivSz, inSz,
-                                                                       type, 0);
-                XMEMCPY(output + idx, hmac, digestSz);
-
-            #ifdef WOLFSSL_SMALL_STACK
-                XFREE(hmac, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #endif
-            } else
-#endif
-                ret = ssl->hmac(ssl, output+idx, output + headerSz + ivSz, inSz,
-                                                                       type, 0);
-        }
-        if (ret != 0)
-            return ret;
-
-        if ( (ret = Encrypt(ssl, output + headerSz, output+headerSz,size)) != 0)
-            return ret;
-    }
-
-    return sz;
-}
-
-
-int SendFinished(WOLFSSL* ssl)
-{
-    int              sendSz,
-                     finishedSz = ssl->options.tls ? TLS_FINISHED_SZ :
-                                                     FINISHED_SZ;
-    byte             input[FINISHED_SZ + DTLS_HANDSHAKE_HEADER_SZ];  /* max */
-    byte            *output;
-    Hashes*          hashes;
-    int              ret;
-    int              headerSz = HANDSHAKE_HEADER_SZ;
-    int              outputSz;
-
-    #ifdef WOLFSSL_DTLS
-        word32 sequence_number = ssl->keys.dtls_sequence_number;
-        word16 epoch           = ssl->keys.dtls_epoch;
-    #endif
-
-    /* setup encrypt keys */
-    if ((ret = SetKeysSide(ssl, ENCRYPT_SIDE_ONLY)) != 0)
-        return ret;
-
-    /* check for available size */
-    outputSz = sizeof(input) + MAX_MSG_EXTRA;
-    if ((ret = CheckAvailableSize(ssl, outputSz)) != 0)
-        return ret;
-
-    #ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            /* Send Finished message with the next epoch, but don't commit that
-             * change until the other end confirms its reception. */
-            headerSz += DTLS_HANDSHAKE_EXTRA;
-            ssl->keys.dtls_epoch++;
-            ssl->keys.dtls_sequence_number = 0;  /* reset after epoch change */
-        }
-    #endif
-
-    /* get ouput buffer */
-    output = ssl->buffers.outputBuffer.buffer +
-             ssl->buffers.outputBuffer.length;
-
-    AddHandShakeHeader(input, finishedSz, finished, ssl);
-
-    /* make finished hashes */
-    hashes = (Hashes*)&input[headerSz];
-    ret = BuildFinished(ssl, hashes,
-                     ssl->options.side == WOLFSSL_CLIENT_END ? client : server);
-    if (ret != 0) return ret;
-
-#ifdef HAVE_SECURE_RENEGOTIATION
-    if (ssl->secure_renegotiation) {
-        if (ssl->options.side == WOLFSSL_CLIENT_END)
-            XMEMCPY(ssl->secure_renegotiation->client_verify_data, hashes,
-                    TLS_FINISHED_SZ);
-        else
-            XMEMCPY(ssl->secure_renegotiation->server_verify_data, hashes,
-                    TLS_FINISHED_SZ);
-    }
-#endif
-
-    sendSz = BuildMessage(ssl, output, outputSz, input, headerSz + finishedSz,
-                          handshake);
-    if (sendSz < 0)
-        return BUILD_MSG_ERROR;
-
-    #ifdef WOLFSSL_DTLS
-    if (ssl->options.dtls) {
-        ssl->keys.dtls_epoch = epoch;
-        ssl->keys.dtls_sequence_number = sequence_number;
-    }
-    #endif
-
-    if (!ssl->options.resuming) {
-#ifndef NO_SESSION_CACHE
-        AddSession(ssl);    /* just try */
-#endif
-        if (ssl->options.side == WOLFSSL_SERVER_END) {
-            ssl->options.handShakeState = HANDSHAKE_DONE;
-            ssl->options.handShakeDone  = 1;
-            #ifdef WOLFSSL_DTLS
-                if (ssl->options.dtls) {
-                    /* Other side will soon receive our Finished, go to next
-                     * epoch. */
-                    ssl->keys.dtls_epoch++;
-                    ssl->keys.dtls_sequence_number = 1;
-                }
-            #endif
-        }
-    }
-    else {
-        if (ssl->options.side == WOLFSSL_CLIENT_END) {
-            ssl->options.handShakeState = HANDSHAKE_DONE;
-            ssl->options.handShakeDone  = 1;
-            #ifdef WOLFSSL_DTLS
-                if (ssl->options.dtls) {
-                    /* Other side will soon receive our Finished, go to next
-                     * epoch. */
-                    ssl->keys.dtls_epoch++;
-                    ssl->keys.dtls_sequence_number = 1;
-                }
-            #endif
-        }
-    }
-    #ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0)
-                return ret;
-        }
-    #endif
-
-    #ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn) AddPacketName("Finished", &ssl->handShakeInfo);
-        if (ssl->toInfoOn)
-            AddPacketInfo("Finished", &ssl->timeoutInfo, output, sendSz,
-                          ssl->heap);
-    #endif
-
-    ssl->buffers.outputBuffer.length += sendSz;
-
-    return SendBuffered(ssl);
-}
-
-#ifndef NO_CERTS
-int SendCertificate(WOLFSSL* ssl)
-{
-    int    sendSz, length, ret = 0;
-    word32 i = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ;
-    word32 certSz, listSz;
-    byte*  output = 0;
-
-    if (ssl->options.usingPSK_cipher || ssl->options.usingAnon_cipher)
-        return 0;  /* not needed */
-
-    if (ssl->options.sendVerify == SEND_BLANK_CERT) {
-        certSz = 0;
-        length = CERT_HEADER_SZ;
-        listSz = 0;
-    }
-    else {
-        certSz = ssl->buffers.certificate.length;
-        /* list + cert size */
-        length = certSz + 2 * CERT_HEADER_SZ;
-        listSz = certSz + CERT_HEADER_SZ;
-
-        /* may need to send rest of chain, already has leading size(s) */
-        if (ssl->buffers.certChain.buffer) {
-            length += ssl->buffers.certChain.length;
-            listSz += ssl->buffers.certChain.length;
-        }
-    }
-    sendSz = length + RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ;
-
-    #ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-            i      += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-        }
-    #endif
-
-    if (ssl->keys.encryptionOn)
-        sendSz += MAX_MSG_EXTRA;
-
-    /* check for available size */
-    if ((ret = CheckAvailableSize(ssl, sendSz)) != 0)
-        return ret;
-
-    /* get ouput buffer */
-    output = ssl->buffers.outputBuffer.buffer +
-             ssl->buffers.outputBuffer.length;
-
-    AddHeaders(output, length, certificate, ssl);
-
-    /* list total */
-    c32to24(listSz, output + i);
-    i += CERT_HEADER_SZ;
-
-    /* member */
-    if (certSz) {
-        c32to24(certSz, output + i);
-        i += CERT_HEADER_SZ;
-        XMEMCPY(output + i, ssl->buffers.certificate.buffer, certSz);
-        i += certSz;
-
-        /* send rest of chain? */
-        if (ssl->buffers.certChain.buffer) {
-            XMEMCPY(output + i, ssl->buffers.certChain.buffer,
-                                ssl->buffers.certChain.length);
-            i += ssl->buffers.certChain.length;
-        }
-    }
-
-    if (ssl->keys.encryptionOn) {
-        byte* input;
-        int   inputSz = i - RECORD_HEADER_SZ; /* build msg adds rec hdr */
-
-        input = (byte*)XMALLOC(inputSz, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER);
-        if (input == NULL)
-            return MEMORY_E;
-
-        XMEMCPY(input, output + RECORD_HEADER_SZ, inputSz);
-        sendSz = BuildMessage(ssl, output, sendSz, input,inputSz,handshake);
-        XFREE(input, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER);
-
-        if (sendSz < 0)
-            return sendSz;
-    } else {
-        ret = HashOutput(ssl, output, sendSz, 0);
-        if (ret != 0)
-            return ret;
-    }
-
-    #ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0)
-                return ret;
-        }
-    #endif
-
-    #ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn) AddPacketName("Certificate", &ssl->handShakeInfo);
-        if (ssl->toInfoOn)
-            AddPacketInfo("Certificate", &ssl->timeoutInfo, output, sendSz,
-                           ssl->heap);
-    #endif
-
-    if (ssl->options.side == WOLFSSL_SERVER_END)
-        ssl->options.serverState = SERVER_CERT_COMPLETE;
-
-    ssl->buffers.outputBuffer.length += sendSz;
-    if (ssl->options.groupMessages)
-        return 0;
-    else
-        return SendBuffered(ssl);
-}
-
-
-int SendCertificateRequest(WOLFSSL* ssl)
-{
-    byte   *output;
-    int    ret;
-    int    sendSz;
-    word32 i = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ;
-
-    int  typeTotal = 1;  /* only 1 for now */
-    int  reqSz = ENUM_LEN + typeTotal + REQ_HEADER_SZ;  /* add auth later */
-
-    if (IsAtLeastTLSv1_2(ssl))
-        reqSz += LENGTH_SZ + ssl->suites->hashSigAlgoSz;
-
-    if (ssl->options.usingPSK_cipher || ssl->options.usingAnon_cipher)
-        return 0;  /* not needed */
-
-    sendSz = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ + reqSz;
-
-    #ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-            i      += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-        }
-    #endif
-    /* check for available size */
-    if ((ret = CheckAvailableSize(ssl, sendSz)) != 0)
-        return ret;
-
-    /* get ouput buffer */
-    output = ssl->buffers.outputBuffer.buffer +
-             ssl->buffers.outputBuffer.length;
-
-    AddHeaders(output, reqSz, certificate_request, ssl);
-
-    /* write to output */
-    output[i++] = (byte)typeTotal;  /* # of types */
-#ifdef HAVE_ECC
-    if (ssl->options.cipherSuite0 == ECC_BYTE &&
-                     ssl->specs.sig_algo == ecc_dsa_sa_algo) {
-        output[i++] = ecdsa_sign;
-    } else
-#endif /* HAVE_ECC */
-    {
-        output[i++] = rsa_sign;
-    }
-
-    /* supported hash/sig */
-    if (IsAtLeastTLSv1_2(ssl)) {
-        c16toa(ssl->suites->hashSigAlgoSz, &output[i]);
-        i += LENGTH_SZ;
-
-        XMEMCPY(&output[i],
-                         ssl->suites->hashSigAlgo, ssl->suites->hashSigAlgoSz);
-        i += ssl->suites->hashSigAlgoSz;
-    }
-
-    c16toa(0, &output[i]);  /* auth's */
-    /* if add more to output, adjust i
-    i += REQ_HEADER_SZ; */
-
-    #ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0)
-                return ret;
-        }
-    #endif
-
-    ret = HashOutput(ssl, output, sendSz, 0);
-    if (ret != 0)
-        return ret;
-
-    #ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn)
-            AddPacketName("CertificateRequest", &ssl->handShakeInfo);
-        if (ssl->toInfoOn)
-            AddPacketInfo("CertificateRequest", &ssl->timeoutInfo, output,
-                          sendSz, ssl->heap);
-    #endif
-    ssl->buffers.outputBuffer.length += sendSz;
-    if (ssl->options.groupMessages)
-        return 0;
-    else
-        return SendBuffered(ssl);
-}
-#endif /* !NO_CERTS */
-
-
-int SendData(WOLFSSL* ssl, const void* data, int sz)
-{
-    int sent = 0,  /* plainText size */
-        sendSz,
-        ret,
-        dtlsExtra = 0;
-
-    if (ssl->error == WANT_WRITE)
-        ssl->error = 0;
-
-    if (ssl->options.handShakeState != HANDSHAKE_DONE) {
-        int err;
-        WOLFSSL_MSG("handshake not complete, trying to finish");
-        if ( (err = wolfSSL_negotiate(ssl)) != SSL_SUCCESS)
-            return  err;
-    }
-
-    /* last time system socket output buffer was full, try again to send */
-    if (ssl->buffers.outputBuffer.length > 0) {
-        WOLFSSL_MSG("output buffer was full, trying to send again");
-        if ( (ssl->error = SendBuffered(ssl)) < 0) {
-            WOLFSSL_ERROR(ssl->error);
-            if (ssl->error == SOCKET_ERROR_E && ssl->options.connReset)
-                return 0;     /* peer reset */
-            return ssl->error;
-        }
-        else {
-            /* advance sent to previous sent + plain size just sent */
-            sent = ssl->buffers.prevSent + ssl->buffers.plainSz;
-            WOLFSSL_MSG("sent write buffered data");
-
-            if (sent > sz) {
-                WOLFSSL_MSG("error: write() after WANT_WRITE with short size");
-                return ssl->error = BAD_FUNC_ARG;
-            }
-        }
-    }
-
-#ifdef WOLFSSL_DTLS
-    if (ssl->options.dtls) {
-        dtlsExtra = DTLS_RECORD_EXTRA;
-    }
-#endif
-
-    for (;;) {
-#ifdef HAVE_MAX_FRAGMENT
-        int   len = min(sz - sent, min(ssl->max_fragment, OUTPUT_RECORD_SIZE));
-#else
-        int   len = min(sz - sent, OUTPUT_RECORD_SIZE);
-#endif
-        byte* out;
-        byte* sendBuffer = (byte*)data + sent;  /* may switch on comp */
-        int   buffSz = len;                     /* may switch on comp */
-        int   outputSz;
-#ifdef HAVE_LIBZ
-        byte  comp[MAX_RECORD_SIZE + MAX_COMP_EXTRA];
-#endif
-
-        if (sent == sz) break;
-
-#ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            len    = min(len, MAX_UDP_SIZE);
-            buffSz = len;
-        }
-#endif
-
-        /* check for available size */
-        outputSz = len + COMP_EXTRA + dtlsExtra + MAX_MSG_EXTRA;
-        if ((ret = CheckAvailableSize(ssl, outputSz)) != 0)
-            return ssl->error = ret;
-
-        /* get ouput buffer */
-        out = ssl->buffers.outputBuffer.buffer +
-              ssl->buffers.outputBuffer.length;
-
-#ifdef HAVE_LIBZ
-        if (ssl->options.usingCompression) {
-            buffSz = myCompress(ssl, sendBuffer, buffSz, comp, sizeof(comp));
-            if (buffSz < 0) {
-                return buffSz;
-            }
-            sendBuffer = comp;
-        }
-#endif
-        sendSz = BuildMessage(ssl, out, outputSz, sendBuffer, buffSz,
-                              application_data);
-        if (sendSz < 0)
-            return BUILD_MSG_ERROR;
-
-        ssl->buffers.outputBuffer.length += sendSz;
-
-        if ( (ret = SendBuffered(ssl)) < 0) {
-            WOLFSSL_ERROR(ret);
-            /* store for next call if WANT_WRITE or user embedSend() that
-               doesn't present like WANT_WRITE */
-            ssl->buffers.plainSz  = len;
-            ssl->buffers.prevSent = sent;
-            if (ret == SOCKET_ERROR_E && ssl->options.connReset)
-                return 0;  /* peer reset */
-            return ssl->error = ret;
-        }
-
-        sent += len;
-
-        /* only one message per attempt */
-        if (ssl->options.partialWrite == 1) {
-            WOLFSSL_MSG("Paritial Write on, only sending one record");
-            break;
-        }
-    }
-
-    return sent;
-}
-
-/* process input data */
-int ReceiveData(WOLFSSL* ssl, byte* output, int sz, int peek)
-{
-    int size;
-
-    WOLFSSL_ENTER("ReceiveData()");
-
-    if (ssl->error == WANT_READ)
-        ssl->error = 0;
-
-    if (ssl->error != 0 && ssl->error != WANT_WRITE) {
-        WOLFSSL_MSG("User calling wolfSSL_read in error state, not allowed");
-        return ssl->error;
-    }
-
-    if (ssl->options.handShakeState != HANDSHAKE_DONE) {
-        int err;
-        WOLFSSL_MSG("Handshake not complete, trying to finish");
-        if ( (err = wolfSSL_negotiate(ssl)) != SSL_SUCCESS)
-            return  err;
-    }
-
-#ifdef HAVE_SECURE_RENEGOTIATION
-startScr:
-    if (ssl->secure_renegotiation && ssl->secure_renegotiation->startScr) {
-        int err;
-        ssl->secure_renegotiation->startScr = 0;  /* only start once */
-        WOLFSSL_MSG("Need to start scr, server requested");
-        if ( (err = wolfSSL_Rehandshake(ssl)) != SSL_SUCCESS)
-            return  err;
-    }
-#endif
-
-    while (ssl->buffers.clearOutputBuffer.length == 0) {
-        if ( (ssl->error = ProcessReply(ssl)) < 0) {
-            WOLFSSL_ERROR(ssl->error);
-            if (ssl->error == ZERO_RETURN) {
-                WOLFSSL_MSG("Zero return, no more data coming");
-                return 0;         /* no more data coming */
-            }
-            if (ssl->error == SOCKET_ERROR_E) {
-                if (ssl->options.connReset || ssl->options.isClosed) {
-                    WOLFSSL_MSG("Peer reset or closed, connection done");
-                    ssl->error = SOCKET_PEER_CLOSED_E;
-                    WOLFSSL_ERROR(ssl->error);
-                    return 0;     /* peer reset or closed */
-                }
-            }
-            return ssl->error;
-        }
-        #ifdef HAVE_SECURE_RENEGOTIATION
-            if (ssl->secure_renegotiation &&
-                ssl->secure_renegotiation->startScr) {
-                goto startScr;
-            }
-        #endif
-    }
-
-    if (sz < (int)ssl->buffers.clearOutputBuffer.length)
-        size = sz;
-    else
-        size = ssl->buffers.clearOutputBuffer.length;
-
-    XMEMCPY(output, ssl->buffers.clearOutputBuffer.buffer, size);
-
-    if (peek == 0) {
-        ssl->buffers.clearOutputBuffer.length -= size;
-        ssl->buffers.clearOutputBuffer.buffer += size;
-    }
-
-    if (ssl->buffers.clearOutputBuffer.length == 0 &&
-                                           ssl->buffers.inputBuffer.dynamicFlag)
-       ShrinkInputBuffer(ssl, NO_FORCED_FREE);
-
-    WOLFSSL_LEAVE("ReceiveData()", size);
-    return size;
-}
-
-
-/* send alert message */
-int SendAlert(WOLFSSL* ssl, int severity, int type)
-{
-    byte input[ALERT_SIZE];
-    byte *output;
-    int  sendSz;
-    int  ret;
-    int  outputSz;
-    int  dtlsExtra = 0;
-
-    /* if sendalert is called again for nonbloking */
-    if (ssl->options.sendAlertState != 0) {
-        ret = SendBuffered(ssl);
-        if (ret == 0)
-            ssl->options.sendAlertState = 0;
-        return ret;
-    }
-
-   #ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls)
-           dtlsExtra = DTLS_RECORD_EXTRA;
-   #endif
-
-    /* check for available size */
-    outputSz = ALERT_SIZE + MAX_MSG_EXTRA + dtlsExtra;
-    if ((ret = CheckAvailableSize(ssl, outputSz)) != 0)
-        return ret;
-
-    /* get ouput buffer */
-    output = ssl->buffers.outputBuffer.buffer +
-             ssl->buffers.outputBuffer.length;
-
-    input[0] = (byte)severity;
-    input[1] = (byte)type;
-    ssl->alert_history.last_tx.code = type;
-    ssl->alert_history.last_tx.level = severity;
-    if (severity == alert_fatal) {
-        ssl->options.isClosed = 1;  /* Don't send close_notify */
-    }
-
-    /* only send encrypted alert if handshake actually complete, otherwise
-       other side may not be able to handle it */
-    if (ssl->keys.encryptionOn && ssl->options.handShakeDone)
-        sendSz = BuildMessage(ssl, output, outputSz, input, ALERT_SIZE, alert);
-    else {
-
-        AddRecordHeader(output, ALERT_SIZE, alert, ssl);
-        output += RECORD_HEADER_SZ;
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls)
-                output += DTLS_RECORD_EXTRA;
-        #endif
-        XMEMCPY(output, input, ALERT_SIZE);
-
-        sendSz = RECORD_HEADER_SZ + ALERT_SIZE;
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls)
-                sendSz += DTLS_RECORD_EXTRA;
-        #endif
-    }
-    if (sendSz < 0)
-        return BUILD_MSG_ERROR;
-
-    #ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn)
-            AddPacketName("Alert", &ssl->handShakeInfo);
-        if (ssl->toInfoOn)
-            AddPacketInfo("Alert", &ssl->timeoutInfo, output, sendSz,ssl->heap);
-    #endif
-
-    ssl->buffers.outputBuffer.length += sendSz;
-    ssl->options.sendAlertState = 1;
-
-    return SendBuffered(ssl);
-}
-
-const char* wolfSSL_ERR_reason_error_string(unsigned long e)
-{
-#ifdef NO_ERROR_STRINGS
-
-    (void)e;
-    return "no support for error strings built in";
-
-#else
-
-    int error = (int)e;
-
-    /* pass to wolfCrypt */
-    if (error < MAX_CODE_E && error > MIN_CODE_E) {
-        return wc_GetErrorString(error);
-    }
-
-    switch (error) {
-
-    case UNSUPPORTED_SUITE :
-        return "unsupported cipher suite";
-
-    case INPUT_CASE_ERROR :
-        return "input state error";
-
-    case PREFIX_ERROR :
-        return "bad index to key rounds";
-
-    case MEMORY_ERROR :
-        return "out of memory";
-
-    case VERIFY_FINISHED_ERROR :
-        return "verify problem on finished";
-
-    case VERIFY_MAC_ERROR :
-        return "verify mac problem";
-
-    case PARSE_ERROR :
-        return "parse error on header";
-
-    case SIDE_ERROR :
-        return "wrong client/server type";
-
-    case NO_PEER_CERT :
-        return "peer didn't send cert";
-
-    case UNKNOWN_HANDSHAKE_TYPE :
-        return "weird handshake type";
-
-    case SOCKET_ERROR_E :
-        return "error state on socket";
-
-    case SOCKET_NODATA :
-        return "expected data, not there";
-
-    case INCOMPLETE_DATA :
-        return "don't have enough data to complete task";
-
-    case UNKNOWN_RECORD_TYPE :
-        return "unknown type in record hdr";
-
-    case DECRYPT_ERROR :
-        return "error during decryption";
-
-    case FATAL_ERROR :
-        return "revcd alert fatal error";
-
-    case ENCRYPT_ERROR :
-        return "error during encryption";
-
-    case FREAD_ERROR :
-        return "fread problem";
-
-    case NO_PEER_KEY :
-        return "need peer's key";
-
-    case NO_PRIVATE_KEY :
-        return "need the private key";
-
-    case NO_DH_PARAMS :
-        return "server missing DH params";
-
-    case RSA_PRIVATE_ERROR :
-        return "error during rsa priv op";
-
-    case MATCH_SUITE_ERROR :
-        return "can't match cipher suite";
-
-    case BUILD_MSG_ERROR :
-        return "build message failure";
-
-    case BAD_HELLO :
-        return "client hello malformed";
-
-    case DOMAIN_NAME_MISMATCH :
-        return "peer subject name mismatch";
-
-    case WANT_READ :
-    case SSL_ERROR_WANT_READ :
-        return "non-blocking socket wants data to be read";
-
-    case NOT_READY_ERROR :
-        return "handshake layer not ready yet, complete first";
-
-    case PMS_VERSION_ERROR :
-        return "premaster secret version mismatch error";
-
-    case VERSION_ERROR :
-        return "record layer version error";
-
-    case WANT_WRITE :
-    case SSL_ERROR_WANT_WRITE :
-        return "non-blocking socket write buffer full";
-
-    case BUFFER_ERROR :
-        return "malformed buffer input error";
-
-    case VERIFY_CERT_ERROR :
-        return "verify problem on certificate";
-
-    case VERIFY_SIGN_ERROR :
-        return "verify problem based on signature";
-
-    case CLIENT_ID_ERROR :
-        return "psk client identity error";
-
-    case SERVER_HINT_ERROR:
-        return "psk server hint error";
-
-    case PSK_KEY_ERROR:
-        return "psk key callback error";
-
-    case NTRU_KEY_ERROR:
-        return "NTRU key error";
-
-    case NTRU_DRBG_ERROR:
-        return "NTRU drbg error";
-
-    case NTRU_ENCRYPT_ERROR:
-        return "NTRU encrypt error";
-
-    case NTRU_DECRYPT_ERROR:
-        return "NTRU decrypt error";
-
-    case ZLIB_INIT_ERROR:
-        return "zlib init error";
-
-    case ZLIB_COMPRESS_ERROR:
-        return "zlib compress error";
-
-    case ZLIB_DECOMPRESS_ERROR:
-        return "zlib decompress error";
-
-    case GETTIME_ERROR:
-        return "gettimeofday() error";
-
-    case GETITIMER_ERROR:
-        return "getitimer() error";
-
-    case SIGACT_ERROR:
-        return "sigaction() error";
-
-    case SETITIMER_ERROR:
-        return "setitimer() error";
-
-    case LENGTH_ERROR:
-        return "record layer length error";
-
-    case PEER_KEY_ERROR:
-        return "cant decode peer key";
-
-    case ZERO_RETURN:
-    case SSL_ERROR_ZERO_RETURN:
-        return "peer sent close notify alert";
-
-    case ECC_CURVETYPE_ERROR:
-        return "Bad ECC Curve Type or unsupported";
-
-    case ECC_CURVE_ERROR:
-        return "Bad ECC Curve or unsupported";
-
-    case ECC_PEERKEY_ERROR:
-        return "Bad ECC Peer Key";
-
-    case ECC_MAKEKEY_ERROR:
-        return "ECC Make Key failure";
-
-    case ECC_EXPORT_ERROR:
-        return "ECC Export Key failure";
-
-    case ECC_SHARED_ERROR:
-        return "ECC DHE shared failure";
-
-    case NOT_CA_ERROR:
-        return "Not a CA by basic constraint error";
-
-    case BAD_PATH_ERROR:
-        return "Bad path for opendir error";
-
-    case BAD_CERT_MANAGER_ERROR:
-        return "Bad Cert Manager error";
-
-    case OCSP_CERT_REVOKED:
-        return "OCSP Cert revoked";
-
-    case CRL_CERT_REVOKED:
-        return "CRL Cert revoked";
-
-    case CRL_MISSING:
-        return "CRL missing, not loaded";
-
-    case MONITOR_RUNNING_E:
-        return "CRL monitor already running";
-
-    case THREAD_CREATE_E:
-        return "Thread creation problem";
-
-    case OCSP_NEED_URL:
-        return "OCSP need URL";
-
-    case OCSP_CERT_UNKNOWN:
-        return "OCSP Cert unknown";
-
-    case OCSP_LOOKUP_FAIL:
-        return "OCSP Responder lookup fail";
-
-    case MAX_CHAIN_ERROR:
-        return "Maximum Chain Depth Exceeded";
-
-    case COOKIE_ERROR:
-        return "DTLS Cookie Error";
-
-    case SEQUENCE_ERROR:
-        return "DTLS Sequence Error";
-
-    case SUITES_ERROR:
-        return "Suites Pointer Error";
-
-    case SSL_NO_PEM_HEADER:
-        return "No PEM Header Error";
-
-    case OUT_OF_ORDER_E:
-        return "Out of order message, fatal";
-
-    case BAD_KEA_TYPE_E:
-        return "Bad KEA type found";
-
-    case SANITY_CIPHER_E:
-        return "Sanity check on ciphertext failed";
-
-    case RECV_OVERFLOW_E:
-        return "Receive callback returned more than requested";
-
-    case GEN_COOKIE_E:
-        return "Generate Cookie Error";
-
-    case NO_PEER_VERIFY:
-        return "Need peer certificate verify Error";
-
-    case FWRITE_ERROR:
-        return "fwrite Error";
-
-    case CACHE_MATCH_ERROR:
-        return "Cache restore header match Error";
-
-    case UNKNOWN_SNI_HOST_NAME_E:
-        return "Unrecognized host name Error";
-
-    case KEYUSE_SIGNATURE_E:
-        return "Key Use digitalSignature not set Error";
-
-    case KEYUSE_ENCIPHER_E:
-        return "Key Use keyEncipherment not set Error";
-
-    case EXTKEYUSE_AUTH_E:
-        return "Ext Key Use server/client auth not set Error";
-
-    case SEND_OOB_READ_E:
-        return "Send Callback Out of Bounds Read Error";
-
-    case SECURE_RENEGOTIATION_E:
-        return "Invalid Renegotiation Error";
-
-    case SESSION_TICKET_LEN_E:
-        return "Session Ticket Too Long Error";
-
-    case SESSION_TICKET_EXPECT_E:
-        return "Session Ticket Error";
-
-    case SCR_DIFFERENT_CERT_E:
-        return "Peer sent different cert during SCR";
-
-    case SESSION_SECRET_CB_E:
-        return "Session Secret Callback Error";
-
-    case NO_CHANGE_CIPHER_E:
-        return "Finished received from peer before Change Cipher Error";
-
-    case SANITY_MSG_E:
-        return "Sanity Check on message order Error";
-
-    case DUPLICATE_MSG_E:
-        return "Duplicate HandShake message Error";
-
-    case SNI_UNSUPPORTED:
-        return "Protocol version does not support SNI Error";
-
-    case SOCKET_PEER_CLOSED_E:
-        return "Peer closed underlying transport Error";
-
-    case BAD_TICKET_KEY_CB_SZ:
-        return "Bad user session ticket key callback Size Error";
-
-    case BAD_TICKET_MSG_SZ:
-        return "Bad session ticket message Size Error";
-
-    case BAD_TICKET_ENCRYPT:
-        return "Bad user ticket callback encrypt Error";
-
-    case DH_KEY_SIZE_E:
-        return "DH key too small Error";
-
-    default :
-        return "unknown error number";
-    }
-
-#endif /* NO_ERROR_STRINGS */
-}
-
-void SetErrorString(int error, char* str)
-{
-    XSTRNCPY(str, wolfSSL_ERR_reason_error_string(error), WOLFSSL_MAX_ERROR_SZ);
-}
-
-
-/* be sure to add to cipher_name_idx too !!!! */
-static const char* const cipher_names[] =
-{
-#ifdef BUILD_SSL_RSA_WITH_RC4_128_SHA
-    "RC4-SHA",
-#endif
-
-#ifdef BUILD_SSL_RSA_WITH_RC4_128_MD5
-    "RC4-MD5",
-#endif
-
-#ifdef BUILD_SSL_RSA_WITH_3DES_EDE_CBC_SHA
-    "DES-CBC3-SHA",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA
-    "AES128-SHA",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA
-    "AES256-SHA",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_NULL_SHA
-    "NULL-SHA",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_NULL_SHA256
-    "NULL-SHA256",
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA
-    "DHE-RSA-AES128-SHA",
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA
-    "DHE-RSA-AES256-SHA",
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384
-    "DHE-PSK-AES256-GCM-SHA384",
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256
-    "DHE-PSK-AES128-GCM-SHA256",
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_GCM_SHA384
-    "PSK-AES256-GCM-SHA384",
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_GCM_SHA256
-    "PSK-AES128-GCM-SHA256",
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384
-    "DHE-PSK-AES256-CBC-SHA384",
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256
-    "DHE-PSK-AES128-CBC-SHA256",
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA384
-    "PSK-AES256-CBC-SHA384",
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA256
-    "PSK-AES128-CBC-SHA256",
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA
-    "PSK-AES128-CBC-SHA",
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA
-    "PSK-AES256-CBC-SHA",
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_CCM
-    "DHE-PSK-AES128-CCM",
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_CCM
-    "DHE-PSK-AES256-CCM",
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CCM
-    "PSK-AES128-CCM",
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CCM
-    "PSK-AES256-CCM",
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CCM_8
-    "PSK-AES128-CCM-8",
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CCM_8
-    "PSK-AES256-CCM-8",
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_NULL_SHA384
-    "DHE-PSK-NULL-SHA384",
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_NULL_SHA256
-    "DHE-PSK-NULL-SHA256",
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_NULL_SHA384
-    "PSK-NULL-SHA384",
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_NULL_SHA256
-    "PSK-NULL-SHA256",
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_NULL_SHA
-    "PSK-NULL-SHA",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_HC_128_MD5
-    "HC128-MD5",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_HC_128_SHA
-    "HC128-SHA",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_HC_128_B2B256
-    "HC128-B2B256",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_B2B256
-    "AES128-B2B256",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_B2B256
-    "AES256-B2B256",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_RABBIT_SHA
-    "RABBIT-SHA",
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_RC4_128_SHA
-    "NTRU-RC4-SHA",
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA
-    "NTRU-DES-CBC3-SHA",
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_AES_128_CBC_SHA
-    "NTRU-AES128-SHA",
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_AES_256_CBC_SHA
-    "NTRU-AES256-SHA",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CCM_8
-    "AES128-CCM-8",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CCM_8
-    "AES256-CCM-8",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
-    "ECDHE-ECDSA-AES128-CCM-8",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8
-    "ECDHE-ECDSA-AES256-CCM-8",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
-    "ECDHE-RSA-AES128-SHA",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
-    "ECDHE-RSA-AES256-SHA",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
-    "ECDHE-ECDSA-AES128-SHA",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
-    "ECDHE-ECDSA-AES256-SHA",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_RC4_128_SHA
-    "ECDHE-RSA-RC4-SHA",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
-    "ECDHE-RSA-DES-CBC3-SHA",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
-    "ECDHE-ECDSA-RC4-SHA",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
-    "ECDHE-ECDSA-DES-CBC3-SHA",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA256
-    "AES128-SHA256",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA256
-    "AES256-SHA256",
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
-    "DHE-RSA-AES128-SHA256",
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
-    "DHE-RSA-AES256-SHA256",
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
-    "ECDH-RSA-AES128-SHA",
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
-    "ECDH-RSA-AES256-SHA",
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
-    "ECDH-ECDSA-AES128-SHA",
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
-    "ECDH-ECDSA-AES256-SHA",
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_RC4_128_SHA
-    "ECDH-RSA-RC4-SHA",
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
-    "ECDH-RSA-DES-CBC3-SHA",
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_RC4_128_SHA
-    "ECDH-ECDSA-RC4-SHA",
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
-    "ECDH-ECDSA-DES-CBC3-SHA",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_GCM_SHA256
-    "AES128-GCM-SHA256",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_GCM_SHA384
-    "AES256-GCM-SHA384",
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
-    "DHE-RSA-AES128-GCM-SHA256",
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
-    "DHE-RSA-AES256-GCM-SHA384",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
-    "ECDHE-RSA-AES128-GCM-SHA256",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
-    "ECDHE-RSA-AES256-GCM-SHA384",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
-    "ECDHE-ECDSA-AES128-GCM-SHA256",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
-    "ECDHE-ECDSA-AES256-GCM-SHA384",
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
-    "ECDH-RSA-AES128-GCM-SHA256",
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
-    "ECDH-RSA-AES256-GCM-SHA384",
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
-    "ECDH-ECDSA-AES128-GCM-SHA256",
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
-    "ECDH-ECDSA-AES256-GCM-SHA384",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA
-    "CAMELLIA128-SHA",
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
-    "DHE-RSA-CAMELLIA128-SHA",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA
-    "CAMELLIA256-SHA",
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
-    "DHE-RSA-CAMELLIA256-SHA",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256
-    "CAMELLIA128-SHA256",
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
-    "DHE-RSA-CAMELLIA128-SHA256",
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256
-    "CAMELLIA256-SHA256",
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256
-    "DHE-RSA-CAMELLIA256-SHA256",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
-    "ECDHE-RSA-AES128-SHA256",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
-    "ECDHE-ECDSA-AES128-SHA256",
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
-    "ECDH-RSA-AES128-SHA256",
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
-    "ECDH-ECDSA-AES128-SHA256",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
-    "ECDHE-RSA-AES256-SHA384",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
-    "ECDHE-ECDSA-AES256-SHA384",
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
-    "ECDH-RSA-AES256-SHA384",
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
-    "ECDH-ECDSA-AES256-SHA384",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
-    "ECDHE-RSA-CHACHA20-POLY1305",
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
-    "ECDHE-ECDSA-CHACHA20-POLY1305",
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256
-    "DHE-RSA-CHACHA20-POLY1305",
-#endif
-
-#ifdef BUILD_TLS_DH_anon_WITH_AES_128_CBC_SHA
-    "ADH-AES128-SHA",
-#endif
-
-#ifdef HAVE_RENEGOTIATION_INDICATION
-    "RENEGOTIATION-INFO",
-#endif
-};
-
-
-/* cipher suite number that matches above name table */
-static int cipher_name_idx[] =
-{
-
-#ifdef BUILD_SSL_RSA_WITH_RC4_128_SHA
-    SSL_RSA_WITH_RC4_128_SHA,
-#endif
-
-#ifdef BUILD_SSL_RSA_WITH_RC4_128_MD5
-    SSL_RSA_WITH_RC4_128_MD5,
-#endif
-
-#ifdef BUILD_SSL_RSA_WITH_3DES_EDE_CBC_SHA
-    SSL_RSA_WITH_3DES_EDE_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA
-    TLS_RSA_WITH_AES_128_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA
-    TLS_RSA_WITH_AES_256_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_NULL_SHA
-    TLS_RSA_WITH_NULL_SHA,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_NULL_SHA256
-    TLS_RSA_WITH_NULL_SHA256,
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA
-    TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA
-    TLS_DHE_RSA_WITH_AES_256_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384
-    TLS_DHE_PSK_WITH_AES_256_GCM_SHA384,
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256
-    TLS_DHE_PSK_WITH_AES_128_GCM_SHA256,
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_GCM_SHA384
-    TLS_PSK_WITH_AES_256_GCM_SHA384,
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_GCM_SHA256
-    TLS_PSK_WITH_AES_128_GCM_SHA256,
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384
-    TLS_DHE_PSK_WITH_AES_256_CBC_SHA384,
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256
-    TLS_DHE_PSK_WITH_AES_128_CBC_SHA256,
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA384
-    TLS_PSK_WITH_AES_256_CBC_SHA384,
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA256
-    TLS_PSK_WITH_AES_128_CBC_SHA256,
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA
-    TLS_PSK_WITH_AES_128_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA
-    TLS_PSK_WITH_AES_256_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_CCM
-    TLS_DHE_PSK_WITH_AES_128_CCM,
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_CCM
-    TLS_DHE_PSK_WITH_AES_256_CCM,
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CCM
-    TLS_PSK_WITH_AES_128_CCM,
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CCM
-    TLS_PSK_WITH_AES_256_CCM,
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CCM_8
-    TLS_PSK_WITH_AES_128_CCM_8,
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CCM_8
-    TLS_PSK_WITH_AES_256_CCM_8,
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_NULL_SHA384
-    TLS_DHE_PSK_WITH_NULL_SHA384,
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_NULL_SHA256
-    TLS_DHE_PSK_WITH_NULL_SHA256,
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_NULL_SHA384
-    TLS_PSK_WITH_NULL_SHA384,
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_NULL_SHA256
-    TLS_PSK_WITH_NULL_SHA256,
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_NULL_SHA
-    TLS_PSK_WITH_NULL_SHA,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_HC_128_MD5
-    TLS_RSA_WITH_HC_128_MD5,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_HC_128_SHA
-    TLS_RSA_WITH_HC_128_SHA,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_HC_128_B2B256
-    TLS_RSA_WITH_HC_128_B2B256,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_B2B256
-    TLS_RSA_WITH_AES_128_CBC_B2B256,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_B2B256
-    TLS_RSA_WITH_AES_256_CBC_B2B256,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_RABBIT_SHA
-    TLS_RSA_WITH_RABBIT_SHA,
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_RC4_128_SHA
-    TLS_NTRU_RSA_WITH_RC4_128_SHA,
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA
-    TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_AES_128_CBC_SHA
-    TLS_NTRU_RSA_WITH_AES_128_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_AES_256_CBC_SHA
-    TLS_NTRU_RSA_WITH_AES_256_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CCM_8
-    TLS_RSA_WITH_AES_128_CCM_8,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CCM_8
-    TLS_RSA_WITH_AES_256_CCM_8,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
-    TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8
-    TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
-    TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
-    TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
-    TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
-    TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_RC4_128_SHA
-    TLS_ECDHE_RSA_WITH_RC4_128_SHA,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
-    TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
-    TLS_ECDHE_ECDSA_WITH_RC4_128_SHA,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
-    TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA256
-    TLS_RSA_WITH_AES_128_CBC_SHA256,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA256
-    TLS_RSA_WITH_AES_256_CBC_SHA256,
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
-    TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
-    TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
-    TLS_ECDH_RSA_WITH_AES_128_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
-    TLS_ECDH_RSA_WITH_AES_256_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
-    TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
-    TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_RC4_128_SHA
-    TLS_ECDH_RSA_WITH_RC4_128_SHA,
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
-    TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_RC4_128_SHA
-    TLS_ECDH_ECDSA_WITH_RC4_128_SHA,
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
-    TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_GCM_SHA256
-    TLS_RSA_WITH_AES_128_GCM_SHA256,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_GCM_SHA384
-    TLS_RSA_WITH_AES_256_GCM_SHA384,
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
-    TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
-    TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
-    TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
-    TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
-    TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
-    TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
-    TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256,
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
-    TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384,
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
-    TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
-    TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA
-    TLS_RSA_WITH_CAMELLIA_128_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
-    TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA
-    TLS_RSA_WITH_CAMELLIA_256_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
-    TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256
-    TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256,
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
-    TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256
-    TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256,
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256
-    TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
-    TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
-    TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
-    TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256,
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
-    TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
-    TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
-    TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
-    TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384,
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
-    TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
-    TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
-    TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256
-    TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
-#endif
-
-#ifdef BUILD_TLS_DH_anon_WITH_AES_128_CBC_SHA
-    TLS_DH_anon_WITH_AES_128_CBC_SHA,
-#endif
-
-#ifdef HAVE_RENEGOTIATION_INDICATION
-    TLS_EMPTY_RENEGOTIATION_INFO_SCSV,
-#endif
-};
-
-
-/* returns the cipher_names array */
-const char* const* GetCipherNames(void)
-{
-    return cipher_names;
-}
-
-
-/* returns the size of the cipher_names array */
-int GetCipherNamesSize(void)
-{
-    return (int)(sizeof(cipher_names) / sizeof(char*));
-}
-
-
-/**
-Set the enabled cipher suites.
-
-@param [out] suites Suites structure.
-@param [in]  list   List of cipher suites, only supports full name from
-                    cipher_name[] delimited by ':'.
-
-@return true on success, else false.
-*/
-int SetCipherList(Suites* suites, const char* list)
-{
-    int       ret          = 0;
-    int       idx          = 0;
-    int       haveRSAsig   = 0;
-    int       haveECDSAsig = 0;
-    int       haveAnon     = 0;
-    const int suiteSz      = GetCipherNamesSize();
-    char*     next         = (char*)list;
-
-    if (suites == NULL || list == NULL) {
-        WOLFSSL_MSG("SetCipherList parameter error");
-        return 0;
-    }
-
-    if (next[0] == 0 || XSTRNCMP(next, "ALL", 3) == 0)
-        return 1; /* wolfSSL defualt */
-
-    do {
-        char*  current = next;
-        char   name[MAX_SUITE_NAME + 1];
-        int    i;
-        word32 length;
-
-        next   = XSTRSTR(next, ":");
-        length = min(sizeof(name), !next ? (word32)XSTRLEN(current) /* last */
-                                         : (word32)(next - current));
-
-        XSTRNCPY(name, current, length);
-        name[(length == sizeof(name)) ? length - 1 : length] = 0;
-
-        for (i = 0; i < suiteSz; i++) {
-            if (XSTRNCMP(name, cipher_names[i], sizeof(name)) == 0) {
-                suites->suites[idx++] = (XSTRSTR(name, "CHACHA")) ? CHACHA_BYTE
-                                      : (XSTRSTR(name, "EC"))     ? ECC_BYTE
-                                      : (XSTRSTR(name, "CCM"))    ? ECC_BYTE
-                                      : 0x00; /* normal */
-
-                suites->suites[idx++] = (byte)cipher_name_idx[i];
-
-                /* The suites are either ECDSA, RSA, PSK, or Anon. The RSA
-                 * suites don't necessarily have RSA in the name. */
-                if ((haveECDSAsig == 0) && XSTRSTR(name, "ECDSA"))
-                    haveECDSAsig = 1;
-                else if (XSTRSTR(name, "ADH"))
-                    haveAnon = 1;
-                else if ((haveRSAsig == 0) && (XSTRSTR(name, "PSK") == NULL))
-                    haveRSAsig = 1;
-
-                ret = 1; /* found at least one */
-                break;
-            }
-        }
-    }
-    while (next++); /* ++ needed to skip ':' */
-
-    if (ret) {
-        suites->setSuites = 1;
-        suites->suiteSz   = (word16)idx;
-        InitSuitesHashSigAlgo(suites, haveECDSAsig, haveRSAsig, haveAnon);
-    }
-
-    return ret;
-}
-
-
-static void PickHashSigAlgo(WOLFSSL* ssl,
-                             const byte* hashSigAlgo, word32 hashSigAlgoSz)
-{
-    word32 i;
-
-    ssl->suites->sigAlgo = ssl->specs.sig_algo;
-    ssl->suites->hashAlgo = sha_mac;
-
-    /* i+1 since peek a byte ahead for type */
-    for (i = 0; (i+1) < hashSigAlgoSz; i += 2) {
-        if (hashSigAlgo[i+1] == ssl->specs.sig_algo) {
-            if (hashSigAlgo[i] == sha_mac) {
-                break;
-            }
-            #ifndef NO_SHA256
-            else if (hashSigAlgo[i] == sha256_mac) {
-                ssl->suites->hashAlgo = sha256_mac;
-                break;
-            }
-            #endif
-            #ifdef WOLFSSL_SHA384
-            else if (hashSigAlgo[i] == sha384_mac) {
-                ssl->suites->hashAlgo = sha384_mac;
-                break;
-            }
-            #endif
-            #ifdef WOLFSSL_SHA512
-            else if (hashSigAlgo[i] == sha512_mac) {
-                ssl->suites->hashAlgo = sha512_mac;
-                break;
-            }
-            #endif
-        }
-    }
-}
-
-
-#ifdef WOLFSSL_CALLBACKS
-
-    /* Initialisze HandShakeInfo */
-    void InitHandShakeInfo(HandShakeInfo* info)
-    {
-        int i;
-
-        info->cipherName[0] = 0;
-        for (i = 0; i < MAX_PACKETS_HANDSHAKE; i++)
-            info->packetNames[i][0] = 0;
-        info->numberPackets = 0;
-        info->negotiationError = 0;
-    }
-
-    /* Set Final HandShakeInfo parameters */
-    void FinishHandShakeInfo(HandShakeInfo* info, const WOLFSSL* ssl)
-    {
-        int i;
-        int sz = sizeof(cipher_name_idx)/sizeof(int);
-
-        for (i = 0; i < sz; i++)
-            if (ssl->options.cipherSuite == (byte)cipher_name_idx[i]) {
-                if (ssl->options.cipherSuite0 == ECC_BYTE)
-                    continue;   /* ECC suites at end */
-                XSTRNCPY(info->cipherName, cipher_names[i], MAX_CIPHERNAME_SZ);
-                break;
-            }
-
-        /* error max and min are negative numbers */
-        if (ssl->error <= MIN_PARAM_ERR && ssl->error >= MAX_PARAM_ERR)
-            info->negotiationError = ssl->error;
-    }
-
-
-    /* Add name to info packet names, increase packet name count */
-    void AddPacketName(const char* name, HandShakeInfo* info)
-    {
-        if (info->numberPackets < MAX_PACKETS_HANDSHAKE) {
-            XSTRNCPY(info->packetNames[info->numberPackets++], name,
-                    MAX_PACKETNAME_SZ);
-        }
-    }
-
-
-    /* Initialisze TimeoutInfo */
-    void InitTimeoutInfo(TimeoutInfo* info)
-    {
-        int i;
-
-        info->timeoutName[0] = 0;
-        info->flags          = 0;
-
-        for (i = 0; i < MAX_PACKETS_HANDSHAKE; i++) {
-            info->packets[i].packetName[0]     = 0;
-            info->packets[i].timestamp.tv_sec  = 0;
-            info->packets[i].timestamp.tv_usec = 0;
-            info->packets[i].bufferValue       = 0;
-            info->packets[i].valueSz           = 0;
-        }
-        info->numberPackets        = 0;
-        info->timeoutValue.tv_sec  = 0;
-        info->timeoutValue.tv_usec = 0;
-    }
-
-
-    /* Free TimeoutInfo */
-    void FreeTimeoutInfo(TimeoutInfo* info, void* heap)
-    {
-        int i;
-        (void)heap;
-        for (i = 0; i < MAX_PACKETS_HANDSHAKE; i++)
-            if (info->packets[i].bufferValue) {
-                XFREE(info->packets[i].bufferValue, heap, DYNAMIC_TYPE_INFO);
-                info->packets[i].bufferValue = 0;
-            }
-
-    }
-
-
-    /* Add PacketInfo to TimeoutInfo */
-    void AddPacketInfo(const char* name, TimeoutInfo* info, const byte* data,
-                       int sz, void* heap)
-    {
-        if (info->numberPackets < (MAX_PACKETS_HANDSHAKE - 1)) {
-            Timeval currTime;
-
-            /* may add name after */
-            if (name)
-                XSTRNCPY(info->packets[info->numberPackets].packetName, name,
-                        MAX_PACKETNAME_SZ);
-
-            /* add data, put in buffer if bigger than static buffer */
-            info->packets[info->numberPackets].valueSz = sz;
-            if (sz < MAX_VALUE_SZ)
-                XMEMCPY(info->packets[info->numberPackets].value, data, sz);
-            else {
-                info->packets[info->numberPackets].bufferValue =
-                           XMALLOC(sz, heap, DYNAMIC_TYPE_INFO);
-                if (!info->packets[info->numberPackets].bufferValue)
-                    /* let next alloc catch, just don't fill, not fatal here  */
-                    info->packets[info->numberPackets].valueSz = 0;
-                else
-                    XMEMCPY(info->packets[info->numberPackets].bufferValue,
-                           data, sz);
-            }
-            gettimeofday(&currTime, 0);
-            info->packets[info->numberPackets].timestamp.tv_sec  =
-                                                             currTime.tv_sec;
-            info->packets[info->numberPackets].timestamp.tv_usec =
-                                                             currTime.tv_usec;
-            info->numberPackets++;
-        }
-    }
-
-
-    /* Add packet name to previsouly added packet info */
-    void AddLateName(const char* name, TimeoutInfo* info)
-    {
-        /* make sure we have a valid previous one */
-        if (info->numberPackets > 0 && info->numberPackets <
-                                                        MAX_PACKETS_HANDSHAKE) {
-            XSTRNCPY(info->packets[info->numberPackets - 1].packetName, name,
-                    MAX_PACKETNAME_SZ);
-        }
-    }
-
-    /* Add record header to previsouly added packet info */
-    void AddLateRecordHeader(const RecordLayerHeader* rl, TimeoutInfo* info)
-    {
-        /* make sure we have a valid previous one */
-        if (info->numberPackets > 0 && info->numberPackets <
-                                                        MAX_PACKETS_HANDSHAKE) {
-            if (info->packets[info->numberPackets - 1].bufferValue)
-                XMEMCPY(info->packets[info->numberPackets - 1].bufferValue, rl,
-                       RECORD_HEADER_SZ);
-            else
-                XMEMCPY(info->packets[info->numberPackets - 1].value, rl,
-                       RECORD_HEADER_SZ);
-        }
-    }
-
-#endif /* WOLFSSL_CALLBACKS */
-
-
-
-/* client only parts */
-#ifndef NO_WOLFSSL_CLIENT
-
-    int SendClientHello(WOLFSSL* ssl)
-    {
-        byte              *output;
-        word32             length, idx = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ;
-        int                sendSz;
-        int                idSz = ssl->options.resuming
-                                ? ssl->session.sessionIDSz
-                                : 0;
-        int                ret;
-
-        if (ssl->suites == NULL) {
-            WOLFSSL_MSG("Bad suites pointer in SendClientHello");
-            return SUITES_ERROR;
-        }
-
-#ifdef HAVE_SESSION_TICKET
-        if (ssl->options.resuming && ssl->session.ticketLen > 0) {
-            SessionTicket* ticket;
-
-            ticket = TLSX_SessionTicket_Create(0,
-                                   ssl->session.ticket, ssl->session.ticketLen);
-            if (ticket == NULL) return MEMORY_E;
-
-            ret = TLSX_UseSessionTicket(&ssl->extensions, ticket);
-            if (ret != SSL_SUCCESS) return ret;
-
-            idSz = 0;
-        }
-#endif
-
-        length = VERSION_SZ + RAN_LEN
-               + idSz + ENUM_LEN
-               + ssl->suites->suiteSz + SUITE_LEN
-               + COMP_LEN + ENUM_LEN;
-
-#ifdef HAVE_TLS_EXTENSIONS
-        length += TLSX_GetRequestSize(ssl);
-#else
-        if (IsAtLeastTLSv1_2(ssl) && ssl->suites->hashSigAlgoSz) {
-            length += ssl->suites->hashSigAlgoSz + HELLO_EXT_SZ;
-        }
-#endif
-        sendSz = length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ;
-
-#ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            length += ENUM_LEN;   /* cookie */
-            if (ssl->arrays->cookieSz != 0) length += ssl->arrays->cookieSz;
-            sendSz  = length + DTLS_HANDSHAKE_HEADER_SZ + DTLS_RECORD_HEADER_SZ;
-            idx    += DTLS_HANDSHAKE_EXTRA + DTLS_RECORD_EXTRA;
-        }
-#endif
-
-        if (ssl->keys.encryptionOn)
-            sendSz += MAX_MSG_EXTRA;
-
-        /* check for available size */
-        if ((ret = CheckAvailableSize(ssl, sendSz)) != 0)
-            return ret;
-
-        /* get ouput buffer */
-        output = ssl->buffers.outputBuffer.buffer +
-                 ssl->buffers.outputBuffer.length;
-
-        AddHeaders(output, length, client_hello, ssl);
-
-            /* client hello, first version */
-        output[idx++] = ssl->version.major;
-        output[idx++] = ssl->version.minor;
-        ssl->chVersion = ssl->version;  /* store in case changed */
-
-            /* then random */
-        if (ssl->options.connectState == CONNECT_BEGIN) {
-            ret = wc_RNG_GenerateBlock(ssl->rng, output + idx, RAN_LEN);
-            if (ret != 0)
-                return ret;
-
-                /* store random */
-            XMEMCPY(ssl->arrays->clientRandom, output + idx, RAN_LEN);
-        } else {
-#ifdef WOLFSSL_DTLS
-                /* send same random on hello again */
-            XMEMCPY(output + idx, ssl->arrays->clientRandom, RAN_LEN);
-#endif
-        }
-        idx += RAN_LEN;
-
-            /* then session id */
-        output[idx++] = (byte)idSz;
-        if (idSz) {
-            XMEMCPY(output + idx, ssl->session.sessionID,
-                                                      ssl->session.sessionIDSz);
-            idx += ssl->session.sessionIDSz;
-        }
-
-            /* then DTLS cookie */
-#ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            byte cookieSz = ssl->arrays->cookieSz;
-
-            output[idx++] = cookieSz;
-            if (cookieSz) {
-                XMEMCPY(&output[idx], ssl->arrays->cookie, cookieSz);
-                idx += cookieSz;
-            }
-        }
-#endif
-            /* then cipher suites */
-        c16toa(ssl->suites->suiteSz, output + idx);
-        idx += 2;
-        XMEMCPY(output + idx, &ssl->suites->suites, ssl->suites->suiteSz);
-        idx += ssl->suites->suiteSz;
-
-            /* last, compression */
-        output[idx++] = COMP_LEN;
-        if (ssl->options.usingCompression)
-            output[idx++] = ZLIB_COMPRESSION;
-        else
-            output[idx++] = NO_COMPRESSION;
-
-#ifdef HAVE_TLS_EXTENSIONS
-        idx += TLSX_WriteRequest(ssl, output + idx);
-
-        (void)idx; /* suppress analyzer warning, keep idx current */
-#else
-        if (IsAtLeastTLSv1_2(ssl) && ssl->suites->hashSigAlgoSz)
-        {
-            int i;
-            /* add in the extensions length */
-            c16toa(HELLO_EXT_LEN + ssl->suites->hashSigAlgoSz, output + idx);
-            idx += 2;
-
-            c16toa(HELLO_EXT_SIG_ALGO, output + idx);
-            idx += 2;
-            c16toa(HELLO_EXT_SIGALGO_SZ+ssl->suites->hashSigAlgoSz, output+idx);
-            idx += 2;
-            c16toa(ssl->suites->hashSigAlgoSz, output + idx);
-            idx += 2;
-            for (i = 0; i < ssl->suites->hashSigAlgoSz; i++, idx++) {
-                output[idx] = ssl->suites->hashSigAlgo[i];
-            }
-        }
-#endif
-
-        if (ssl->keys.encryptionOn) {
-            byte* input;
-            int   inputSz = idx - RECORD_HEADER_SZ; /* build msg adds rec hdr */
-
-            input = (byte*)XMALLOC(inputSz, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER);
-            if (input == NULL)
-                return MEMORY_E;
-
-            XMEMCPY(input, output + RECORD_HEADER_SZ, inputSz);
-            sendSz = BuildMessage(ssl, output, sendSz, input,inputSz,handshake);
-            XFREE(input, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER);
-
-            if (sendSz < 0)
-                return sendSz;
-        } else {
-            ret = HashOutput(ssl, output, sendSz, 0);
-            if (ret != 0)
-                return ret;
-        }
-
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls) {
-                if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0)
-                    return ret;
-            }
-        #endif
-
-        ssl->options.clientState = CLIENT_HELLO_COMPLETE;
-
-#ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn) AddPacketName("ClientHello", &ssl->handShakeInfo);
-        if (ssl->toInfoOn)
-            AddPacketInfo("ClientHello", &ssl->timeoutInfo, output, sendSz,
-                          ssl->heap);
-#endif
-
-        ssl->buffers.outputBuffer.length += sendSz;
-
-        return SendBuffered(ssl);
-    }
-
-
-    static int DoHelloVerifyRequest(WOLFSSL* ssl, const byte* input,
-                                    word32* inOutIdx, word32 size)
-    {
-        ProtocolVersion pv;
-        byte            cookieSz;
-        word32          begin = *inOutIdx;
-
-#ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn) AddPacketName("HelloVerifyRequest",
-                                         &ssl->handShakeInfo);
-        if (ssl->toInfoOn) AddLateName("HelloVerifyRequest", &ssl->timeoutInfo);
-#endif
-
-#ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            DtlsPoolReset(ssl);
-        }
-#endif
-
-        if ((*inOutIdx - begin) + OPAQUE16_LEN + OPAQUE8_LEN > size)
-            return BUFFER_ERROR;
-
-        XMEMCPY(&pv, input + *inOutIdx, OPAQUE16_LEN);
-        *inOutIdx += OPAQUE16_LEN;
-
-        cookieSz = input[(*inOutIdx)++];
-
-        if (cookieSz) {
-            if ((*inOutIdx - begin) + cookieSz > size)
-                return BUFFER_ERROR;
-
-#ifdef WOLFSSL_DTLS
-            if (cookieSz <= MAX_COOKIE_LEN) {
-                XMEMCPY(ssl->arrays->cookie, input + *inOutIdx, cookieSz);
-                ssl->arrays->cookieSz = cookieSz;
-            }
-#endif
-            *inOutIdx += cookieSz;
-        }
-
-        ssl->options.serverState = SERVER_HELLOVERIFYREQUEST_COMPLETE;
-        return 0;
-    }
-
-
-    static INLINE int DSH_CheckSessionId(WOLFSSL* ssl)
-    {
-        int ret = 0;
-
-#ifdef HAVE_SECRET_CALLBACK
-        /* If a session secret callback exists, we are using that
-         * key instead of the saved session key. */
-        ret = ret || (ssl->sessionSecretCb != NULL);
-#endif
-
-#ifdef HAVE_SESSION_TICKET
-        /* server may send blank ticket which may not be expected to indicate
-         * exisiting one ok but will also be sending a new one */
-        ret = ret || (ssl->session.ticketLen > 0);
-#endif
-
-        ret = ret ||
-              (ssl->options.haveSessionId && XMEMCMP(ssl->arrays->sessionID,
-                                          ssl->session.sessionID, ID_LEN) == 0);
-
-        return ret;
-    }
-
-    static int DoServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
-                             word32 helloSz)
-    {
-        byte            cs0;   /* cipher suite bytes 0, 1 */
-        byte            cs1;
-        ProtocolVersion pv;
-        byte            compression;
-        word32          i = *inOutIdx;
-        word32          begin = i;
-
-#ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn) AddPacketName("ServerHello", &ssl->handShakeInfo);
-        if (ssl->toInfoOn) AddLateName("ServerHello", &ssl->timeoutInfo);
-#endif
-
-        /* protocol version, random and session id length check */
-        if (OPAQUE16_LEN + RAN_LEN + OPAQUE8_LEN > helloSz)
-            return BUFFER_ERROR;
-
-        /* protocol version */
-        XMEMCPY(&pv, input + i, OPAQUE16_LEN);
-        i += OPAQUE16_LEN;
-
-        if (pv.minor > ssl->version.minor) {
-            WOLFSSL_MSG("Server using higher version, fatal error");
-            return VERSION_ERROR;
-        }
-        else if (pv.minor < ssl->version.minor) {
-            WOLFSSL_MSG("server using lower version");
-
-            if (!ssl->options.downgrade) {
-                WOLFSSL_MSG("    no downgrade allowed, fatal error");
-                return VERSION_ERROR;
-            }
-            if (pv.minor < ssl->options.minDowngrade) {
-                WOLFSSL_MSG("    version below minimum allowed, fatal error");
-                return VERSION_ERROR;
-            }
-
-            #ifdef HAVE_SECURE_RENEGOTIATION
-                if (ssl->secure_renegotiation &&
-                                         ssl->secure_renegotiation->enabled &&
-                                         ssl->options.handShakeDone) {
-                    WOLFSSL_MSG("Server changed version during scr");
-                    return VERSION_ERROR;
-                }
-            #endif
-
-            if (pv.minor == SSLv3_MINOR) {
-                /* turn off tls */
-                WOLFSSL_MSG("    downgrading to SSLv3");
-                ssl->options.tls    = 0;
-                ssl->options.tls1_1 = 0;
-                ssl->version.minor  = SSLv3_MINOR;
-            }
-            else if (pv.minor == TLSv1_MINOR) {
-                /* turn off tls 1.1+ */
-                WOLFSSL_MSG("    downgrading to TLSv1");
-                ssl->options.tls1_1 = 0;
-                ssl->version.minor  = TLSv1_MINOR;
-            }
-            else if (pv.minor == TLSv1_1_MINOR) {
-                WOLFSSL_MSG("    downgrading to TLSv1.1");
-                ssl->version.minor  = TLSv1_1_MINOR;
-            }
-        }
-
-        /* random */
-        XMEMCPY(ssl->arrays->serverRandom, input + i, RAN_LEN);
-        i += RAN_LEN;
-
-        /* session id */
-        ssl->arrays->sessionIDSz = input[i++];
-
-        if (ssl->arrays->sessionIDSz > ID_LEN) {
-            WOLFSSL_MSG("Invalid session ID size");
-            ssl->arrays->sessionIDSz = 0;
-            return BUFFER_ERROR;
-        }
-        else if (ssl->arrays->sessionIDSz) {
-            if ((i - begin) + ssl->arrays->sessionIDSz > helloSz)
-                return BUFFER_ERROR;
-
-            XMEMCPY(ssl->arrays->sessionID, input + i,
-                                                      ssl->arrays->sessionIDSz);
-            i += ssl->arrays->sessionIDSz;
-            ssl->options.haveSessionId = 1;
-        }
-
-
-        /* suite and compression */
-        if ((i - begin) + OPAQUE16_LEN + OPAQUE8_LEN > helloSz)
-            return BUFFER_ERROR;
-
-        cs0 = input[i++];
-        cs1 = input[i++];
-
-#ifdef HAVE_SECURE_RENEGOTIATION
-        if (ssl->secure_renegotiation && ssl->secure_renegotiation->enabled &&
-                                         ssl->options.handShakeDone) {
-            if (ssl->options.cipherSuite0 != cs0 ||
-                ssl->options.cipherSuite  != cs1) {
-                WOLFSSL_MSG("Server changed cipher suite during scr");
-                return MATCH_SUITE_ERROR;
-            }
-        }
-#endif
-
-        ssl->options.cipherSuite0 = cs0;
-        ssl->options.cipherSuite  = cs1;
-        compression = input[i++];
-
-        if (compression != ZLIB_COMPRESSION && ssl->options.usingCompression) {
-            WOLFSSL_MSG("Server refused compression, turning off");
-            ssl->options.usingCompression = 0;  /* turn off if server refused */
-        }
-
-        *inOutIdx = i;
-
-        /* tls extensions */
-        if ( (i - begin) < helloSz) {
-#ifdef HAVE_TLS_EXTENSIONS
-            if (TLSX_SupportExtensions(ssl)) {
-                int    ret = 0;
-                word16 totalExtSz;
-
-                if ((i - begin) + OPAQUE16_LEN > helloSz)
-                    return BUFFER_ERROR;
-
-                ato16(&input[i], &totalExtSz);
-                i += OPAQUE16_LEN;
-
-                if ((i - begin) + totalExtSz > helloSz)
-                    return BUFFER_ERROR;
-
-                if ((ret = TLSX_Parse(ssl, (byte *) input + i,
-                                                          totalExtSz, 0, NULL)))
-                    return ret;
-
-                i += totalExtSz;
-                *inOutIdx = i;
-            }
-            else
-#endif
-                *inOutIdx = begin + helloSz; /* skip extensions */
-        }
-
-        ssl->options.serverState = SERVER_HELLO_COMPLETE;
-
-        if (ssl->keys.encryptionOn) {
-            *inOutIdx += ssl->keys.padSz;
-        }
-
-#ifdef HAVE_SECRET_CALLBACK
-        if (ssl->sessionSecretCb != NULL) {
-            int secretSz = SECRET_LEN, ret;
-            ret = ssl->sessionSecretCb(ssl, ssl->session.masterSecret,
-                                              &secretSz, ssl->sessionSecretCtx);
-            if (ret != 0 || secretSz != SECRET_LEN)
-                return SESSION_SECRET_CB_E;
-        }
-#endif /* HAVE_SECRET_CALLBACK */
-
-        if (ssl->options.resuming) {
-            if (DSH_CheckSessionId(ssl)) {
-                if (SetCipherSpecs(ssl) == 0) {
-                    int ret = -1;
-
-                    XMEMCPY(ssl->arrays->masterSecret,
-                            ssl->session.masterSecret, SECRET_LEN);
-                    #ifdef NO_OLD_TLS
-                        ret = DeriveTlsKeys(ssl);
-                    #else
-                        #ifndef NO_TLS
-                            if (ssl->options.tls)
-                                ret = DeriveTlsKeys(ssl);
-                        #endif
-                            if (!ssl->options.tls)
-                                ret = DeriveKeys(ssl);
-                    #endif
-                    ssl->options.serverState = SERVER_HELLODONE_COMPLETE;
-
-                    return ret;
-                }
-                else {
-                    WOLFSSL_MSG("Unsupported cipher suite, DoServerHello");
-                    return UNSUPPORTED_SUITE;
-                }
-            }
-            else {
-                WOLFSSL_MSG("Server denied resumption attempt");
-                ssl->options.resuming = 0; /* server denied resumption try */
-            }
-        }
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls) {
-                DtlsPoolReset(ssl);
-            }
-        #endif
-
-        return SetCipherSpecs(ssl);
-    }
-
-
-    /* Make sure client setup is valid for this suite, true on success */
-    int VerifyClientSuite(WOLFSSL* ssl)
-    {
-        int  havePSK = 0;
-        byte first   = ssl->options.cipherSuite0;
-        byte second  = ssl->options.cipherSuite;
-
-        WOLFSSL_ENTER("VerifyClientSuite");
-
-        #ifndef NO_PSK
-            havePSK = ssl->options.havePSK;
-        #endif
-
-        if (CipherRequires(first, second, REQUIRES_PSK)) {
-            WOLFSSL_MSG("Requires PSK");
-            if (havePSK == 0) {
-                WOLFSSL_MSG("Don't have PSK");
-                return 0;
-            }
-        }
-
-        return 1;  /* success */
-    }
-
-
-#ifndef NO_CERTS
-    /* just read in and ignore for now TODO: */
-    static int DoCertificateRequest(WOLFSSL* ssl, const byte* input, word32*
-                                    inOutIdx, word32 size)
-    {
-        word16 len;
-        word32 begin = *inOutIdx;
-
-        #ifdef WOLFSSL_CALLBACKS
-            if (ssl->hsInfoOn)
-                AddPacketName("CertificateRequest", &ssl->handShakeInfo);
-            if (ssl->toInfoOn)
-                AddLateName("CertificateRequest", &ssl->timeoutInfo);
-        #endif
-
-        if ((*inOutIdx - begin) + OPAQUE8_LEN > size)
-            return BUFFER_ERROR;
-
-        len = input[(*inOutIdx)++];
-
-        if ((*inOutIdx - begin) + len > size)
-            return BUFFER_ERROR;
-
-        /* types, read in here */
-        *inOutIdx += len;
-
-        /* signature and hash signature algorithm */
-        if (IsAtLeastTLSv1_2(ssl)) {
-            if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-                return BUFFER_ERROR;
-
-            ato16(input + *inOutIdx, &len);
-            *inOutIdx += OPAQUE16_LEN;
-
-            if ((*inOutIdx - begin) + len > size)
-                return BUFFER_ERROR;
-
-            PickHashSigAlgo(ssl, input + *inOutIdx, len);
-            *inOutIdx += len;
-        }
-
-        /* authorities */
-        if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-            return BUFFER_ERROR;
-
-        ato16(input + *inOutIdx, &len);
-        *inOutIdx += OPAQUE16_LEN;
-
-        if ((*inOutIdx - begin) + len > size)
-            return BUFFER_ERROR;
-
-        while (len) {
-            word16 dnSz;
-
-            if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-                return BUFFER_ERROR;
-
-            ato16(input + *inOutIdx, &dnSz);
-            *inOutIdx += OPAQUE16_LEN;
-
-            if ((*inOutIdx - begin) + dnSz > size)
-                return BUFFER_ERROR;
-
-            *inOutIdx += dnSz;
-            len -= OPAQUE16_LEN + dnSz;
-        }
-
-        /* don't send client cert or cert verify if user hasn't provided
-           cert and private key */
-        if (ssl->buffers.certificate.buffer && ssl->buffers.key.buffer)
-            ssl->options.sendVerify = SEND_CERT;
-        else if (IsTLS(ssl))
-            ssl->options.sendVerify = SEND_BLANK_CERT;
-
-        if (ssl->keys.encryptionOn)
-            *inOutIdx += ssl->keys.padSz;
-
-        return 0;
-    }
-#endif /* !NO_CERTS */
-
-
-#ifdef HAVE_ECC
-
-    static int CheckCurveId(int oid)
-    {
-        int ret = 0;
-
-        switch (oid) {
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC160)
-            case WOLFSSL_ECC_SECP160R1:
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC192)
-            case WOLFSSL_ECC_SECP192R1:
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC224)
-            case WOLFSSL_ECC_SECP224R1:
-#endif
-#if defined(HAVE_ALL_CURVES) || !defined(NO_ECC256)
-            case WOLFSSL_ECC_SECP256R1:
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC384)
-            case WOLFSSL_ECC_SECP384R1:
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC521)
-            case WOLFSSL_ECC_SECP521R1:
-#endif
-                break;
-
-            default:
-                ret = -1;
-        }
-
-        return ret;
-    }
-
-#endif /* HAVE_ECC */
-
-    static int DoServerKeyExchange(WOLFSSL* ssl, const byte* input,
-                                   word32* inOutIdx, word32 size)
-    {
-        word16 length = 0;
-        word32 begin  = *inOutIdx;
-        int    ret    = 0;
-        #define ERROR_OUT(err, eLabel) do { ret = err; goto eLabel; } while(0)
-
-        (void)length; /* shut up compiler warnings */
-        (void)begin;
-        (void)ssl;
-        (void)input;
-        (void)size;
-        (void)ret;
-
-    #ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn)
-            AddPacketName("ServerKeyExchange", &ssl->handShakeInfo);
-        if (ssl->toInfoOn)
-            AddLateName("ServerKeyExchange", &ssl->timeoutInfo);
-    #endif
-
-    #ifndef NO_PSK
-        if (ssl->specs.kea == psk_kea) {
-
-            if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-                return BUFFER_ERROR;
-
-            ato16(input + *inOutIdx, &length);
-            *inOutIdx += OPAQUE16_LEN;
-
-            if ((*inOutIdx - begin) + length > size)
-                return BUFFER_ERROR;
-
-            XMEMCPY(ssl->arrays->server_hint, input + *inOutIdx,
-                   min(length, MAX_PSK_ID_LEN));
-
-            ssl->arrays->server_hint[min(length, MAX_PSK_ID_LEN - 1)] = 0;
-            *inOutIdx += length;
-
-            return 0;
-        }
-    #endif
-    #ifndef NO_DH
-        if (ssl->specs.kea == diffie_hellman_kea)
-        {
-        /* p */
-        if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-            return BUFFER_ERROR;
-
-        ato16(input + *inOutIdx, &length);
-        *inOutIdx += OPAQUE16_LEN;
-
-        if ((*inOutIdx - begin) + length > size)
-            return BUFFER_ERROR;
-
-        if (length < ssl->options.minDhKeySz) {
-            WOLFSSL_MSG("Server using a DH key that is too small");
-            SendAlert(ssl, alert_fatal, handshake_failure);
-            return DH_KEY_SIZE_E;
-        }
-
-        ssl->buffers.serverDH_P.buffer = (byte*) XMALLOC(length, ssl->heap,
-                                                         DYNAMIC_TYPE_DH);
-
-        if (ssl->buffers.serverDH_P.buffer)
-            ssl->buffers.serverDH_P.length = length;
-        else
-            return MEMORY_ERROR;
-
-        XMEMCPY(ssl->buffers.serverDH_P.buffer, input + *inOutIdx, length);
-        *inOutIdx += length;
-
-        ssl->options.dhKeySz = length;
-
-        /* g */
-        if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-            return BUFFER_ERROR;
-
-        ato16(input + *inOutIdx, &length);
-        *inOutIdx += OPAQUE16_LEN;
-
-        if ((*inOutIdx - begin) + length > size)
-            return BUFFER_ERROR;
-
-        ssl->buffers.serverDH_G.buffer = (byte*) XMALLOC(length, ssl->heap,
-                                                         DYNAMIC_TYPE_DH);
-
-        if (ssl->buffers.serverDH_G.buffer)
-            ssl->buffers.serverDH_G.length = length;
-        else
-            return MEMORY_ERROR;
-
-        XMEMCPY(ssl->buffers.serverDH_G.buffer, input + *inOutIdx, length);
-        *inOutIdx += length;
-
-        /* pub */
-        if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-            return BUFFER_ERROR;
-
-        ato16(input + *inOutIdx, &length);
-        *inOutIdx += OPAQUE16_LEN;
-
-        if ((*inOutIdx - begin) + length > size)
-            return BUFFER_ERROR;
-
-        ssl->buffers.serverDH_Pub.buffer = (byte*) XMALLOC(length, ssl->heap,
-                                                           DYNAMIC_TYPE_DH);
-
-        if (ssl->buffers.serverDH_Pub.buffer)
-            ssl->buffers.serverDH_Pub.length = length;
-        else
-            return MEMORY_ERROR;
-
-        XMEMCPY(ssl->buffers.serverDH_Pub.buffer, input + *inOutIdx, length);
-        *inOutIdx += length;
-        }  /* dh_kea */
-    #endif /* NO_DH */
-
-    #ifdef HAVE_ECC
-        if (ssl->specs.kea == ecc_diffie_hellman_kea)
-        {
-        byte b;
-
-        if ((*inOutIdx - begin) + ENUM_LEN + OPAQUE16_LEN + OPAQUE8_LEN > size)
-            return BUFFER_ERROR;
-
-        b = input[(*inOutIdx)++];
-
-        if (b != named_curve)
-            return ECC_CURVETYPE_ERROR;
-
-        *inOutIdx += 1;   /* curve type, eat leading 0 */
-        b = input[(*inOutIdx)++];
-
-        if (CheckCurveId(b) != 0) {
-            return ECC_CURVE_ERROR;
-        }
-
-        length = input[(*inOutIdx)++];
-
-        if ((*inOutIdx - begin) + length > size)
-            return BUFFER_ERROR;
-
-        if (ssl->peerEccKey == NULL) {
-            /* alloc/init on demand */
-            ssl->peerEccKey = (ecc_key*)XMALLOC(sizeof(ecc_key),
-                                              ssl->ctx->heap, DYNAMIC_TYPE_ECC);
-            if (ssl->peerEccKey == NULL) {
-                WOLFSSL_MSG("PeerEccKey Memory error");
-                return MEMORY_E;
-            }
-            wc_ecc_init(ssl->peerEccKey);
-        } else if (ssl->peerEccKeyPresent) {  /* don't leak on reuse */
-            wc_ecc_free(ssl->peerEccKey);
-            ssl->peerEccKeyPresent = 0;
-            wc_ecc_init(ssl->peerEccKey);
-        }
-
-        if (wc_ecc_import_x963(input + *inOutIdx, length, ssl->peerEccKey) != 0)
-            return ECC_PEERKEY_ERROR;
-
-        *inOutIdx += length;
-        ssl->peerEccKeyPresent = 1;
-        }
-    #endif /* HAVE_ECC */
-
-    #if !defined(NO_DH) && !defined(NO_PSK)
-    if (ssl->specs.kea == dhe_psk_kea) {
-        if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-            return BUFFER_ERROR;
-
-        ato16(input + *inOutIdx, &length);
-        *inOutIdx += OPAQUE16_LEN;
-
-        if ((*inOutIdx - begin) + length > size)
-            return BUFFER_ERROR;
-
-        XMEMCPY(ssl->arrays->server_hint, input + *inOutIdx,
-               min(length, MAX_PSK_ID_LEN));
-
-        ssl->arrays->server_hint[min(length, MAX_PSK_ID_LEN - 1)] = 0;
-        *inOutIdx += length;
-
-        /* p */
-        if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-            return BUFFER_ERROR;
-
-        ato16(input + *inOutIdx, &length);
-        *inOutIdx += OPAQUE16_LEN;
-
-        if ((*inOutIdx - begin) + length > size)
-            return BUFFER_ERROR;
-
-        if (length < ssl->options.minDhKeySz) {
-            WOLFSSL_MSG("Server using a DH key that is too small");
-            SendAlert(ssl, alert_fatal, handshake_failure);
-            return DH_KEY_SIZE_E;
-        }
-
-        ssl->buffers.serverDH_P.buffer = (byte*) XMALLOC(length, ssl->heap,
-                                                         DYNAMIC_TYPE_DH);
-
-        if (ssl->buffers.serverDH_P.buffer)
-            ssl->buffers.serverDH_P.length = length;
-        else
-            return MEMORY_ERROR;
-
-        XMEMCPY(ssl->buffers.serverDH_P.buffer, input + *inOutIdx, length);
-        *inOutIdx += length;
-
-        ssl->options.dhKeySz = length;
-
-        /* g */
-        if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-            return BUFFER_ERROR;
-
-        ato16(input + *inOutIdx, &length);
-        *inOutIdx += OPAQUE16_LEN;
-
-        if ((*inOutIdx - begin) + length > size)
-            return BUFFER_ERROR;
-
-        ssl->buffers.serverDH_G.buffer = (byte*) XMALLOC(length, ssl->heap,
-                                                         DYNAMIC_TYPE_DH);
-
-        if (ssl->buffers.serverDH_G.buffer)
-            ssl->buffers.serverDH_G.length = length;
-        else
-            return MEMORY_ERROR;
-
-        XMEMCPY(ssl->buffers.serverDH_G.buffer, input + *inOutIdx, length);
-        *inOutIdx += length;
-
-        /* pub */
-        if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-            return BUFFER_ERROR;
-
-        ato16(input + *inOutIdx, &length);
-        *inOutIdx += OPAQUE16_LEN;
-
-        if ((*inOutIdx - begin) + length > size)
-            return BUFFER_ERROR;
-
-        ssl->buffers.serverDH_Pub.buffer = (byte*) XMALLOC(length, ssl->heap,
-                                                           DYNAMIC_TYPE_DH);
-
-        if (ssl->buffers.serverDH_Pub.buffer)
-            ssl->buffers.serverDH_Pub.length = length;
-        else
-            return MEMORY_ERROR;
-
-        XMEMCPY(ssl->buffers.serverDH_Pub.buffer, input + *inOutIdx, length);
-        *inOutIdx += length;
-    }
-    #endif /* !NO_DH || !NO_PSK */
-
-    #if !defined(NO_DH) || defined(HAVE_ECC)
-    if (!ssl->options.usingAnon_cipher &&
-        (ssl->specs.kea == ecc_diffie_hellman_kea ||
-         ssl->specs.kea == diffie_hellman_kea))
-    {
-#ifndef NO_OLD_TLS
-#ifdef WOLFSSL_SMALL_STACK
-        Md5*    md5 = NULL;
-        Sha*    sha = NULL;
-#else
-        Md5     md5[1];
-        Sha     sha[1];
-#endif
-#endif
-#ifndef NO_SHA256
-#ifdef WOLFSSL_SMALL_STACK
-        Sha256* sha256  = NULL;
-        byte*   hash256 = NULL;
-#else
-        Sha256  sha256[1];
-        byte    hash256[SHA256_DIGEST_SIZE];
-#endif
-#endif
-#ifdef WOLFSSL_SHA384
-#ifdef WOLFSSL_SMALL_STACK
-        Sha384* sha384  = NULL;
-        byte*   hash384 = NULL;
-#else
-        Sha384  sha384[1];
-        byte    hash384[SHA384_DIGEST_SIZE];
-#endif
-#endif
-#ifdef WOLFSSL_SHA512
-#ifdef WOLFSSL_SMALL_STACK
-        Sha512* sha512  = NULL;
-        byte*   hash512 = NULL;
-#else
-        Sha512  sha512[1];
-        byte    hash512[SHA512_DIGEST_SIZE];
-#endif
-#endif
-#ifdef WOLFSSL_SMALL_STACK
-        byte*   hash          = NULL;
-        byte*   messageVerify = NULL;
-#else
-        byte    hash[FINISHED_SZ];
-        byte    messageVerify[MAX_DH_SZ];
-#endif
-        byte    hashAlgo = sha_mac;
-        byte    sigAlgo  = ssl->specs.sig_algo;
-        word16  verifySz = (word16) (*inOutIdx - begin);
-
-#ifndef NO_OLD_TLS
-        byte doMd5 = 0;
-        byte doSha = 0;
-#endif
-#ifndef NO_SHA256
-        byte doSha256 = 0;
-#endif
-#ifdef WOLFSSL_SHA384
-        byte doSha384 = 0;
-#endif
-#ifdef WOLFSSL_SHA512
-        byte doSha512 = 0;
-#endif
-
-        (void)hash;
-        (void)sigAlgo;
-        (void)hashAlgo;
-
-        /* save message for hash verify */
-        if (verifySz > MAX_DH_SZ)
-            ERROR_OUT(BUFFER_ERROR, done);
-
-    #ifdef WOLFSSL_SMALL_STACK
-        messageVerify = (byte*)XMALLOC(MAX_DH_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-        if (messageVerify == NULL)
-            ERROR_OUT(MEMORY_E, done);
-    #endif
-
-        XMEMCPY(messageVerify, input + begin, verifySz);
-
-        if (IsAtLeastTLSv1_2(ssl)) {
-            byte setHash = 0;
-            if ((*inOutIdx - begin) + ENUM_LEN + ENUM_LEN > size)
-                ERROR_OUT(BUFFER_ERROR, done);
-
-            hashAlgo = input[(*inOutIdx)++];
-            sigAlgo  = input[(*inOutIdx)++];
-
-            switch (hashAlgo) {
-                case sha512_mac:
-                    #ifdef WOLFSSL_SHA512
-                        doSha512 = 1;
-                        setHash  = 1;
-                    #endif
-                    break;
-
-                case sha384_mac:
-                    #ifdef WOLFSSL_SHA384
-                        doSha384 = 1;
-                        setHash  = 1;
-                    #endif
-                    break;
-
-                case sha256_mac:
-                    #ifndef NO_SHA256
-                        doSha256 = 1;
-                        setHash  = 1;
-                    #endif
-                    break;
-
-                case sha_mac:
-                    #ifndef NO_OLD_TLS
-                        doSha = 1;
-                        setHash  = 1;
-                    #endif
-                    break;
-
-                default:
-                    ERROR_OUT(ALGO_ID_E, done);
-            }
-
-            if (setHash == 0) {
-                ERROR_OUT(ALGO_ID_E, done);
-            }
-
-        } else {
-            /* only using sha and md5 for rsa */
-            #ifndef NO_OLD_TLS
-                doSha = 1;
-                if (sigAlgo == rsa_sa_algo) {
-                    doMd5 = 1;
-                }
-            #else
-                ERROR_OUT(ALGO_ID_E, done);
-            #endif
-        }
-
-        /* signature */
-        if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-            ERROR_OUT(BUFFER_ERROR, done);
-
-        ato16(input + *inOutIdx, &length);
-        *inOutIdx += OPAQUE16_LEN;
-
-        if ((*inOutIdx - begin) + length > size)
-            ERROR_OUT(BUFFER_ERROR, done);
-
-        /* inOutIdx updated at the end of the function */
-
-        /* verify signature */
-    #ifdef WOLFSSL_SMALL_STACK
-        hash = (byte*)XMALLOC(FINISHED_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (hash == NULL)
-            ERROR_OUT(MEMORY_E, done);
-    #endif
-
-#ifndef NO_OLD_TLS
-        /* md5 */
-    #ifdef WOLFSSL_SMALL_STACK
-        if (doMd5) {
-            md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            if (md5 == NULL)
-                ERROR_OUT(MEMORY_E, done);
-        }
-    #endif
-        if (doMd5) {
-            wc_InitMd5(md5);
-            wc_Md5Update(md5, ssl->arrays->clientRandom, RAN_LEN);
-            wc_Md5Update(md5, ssl->arrays->serverRandom, RAN_LEN);
-            wc_Md5Update(md5, messageVerify, verifySz);
-            wc_Md5Final(md5, hash);
-        }
-        /* sha */
-    #ifdef WOLFSSL_SMALL_STACK
-        if (doSha) {
-            sha = (Sha*)XMALLOC(sizeof(Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            if (sha == NULL)
-                ERROR_OUT(MEMORY_E, done);
-        }
-    #endif
-        if (doSha) {
-            ret = wc_InitSha(sha);
-            if (ret != 0) goto done;
-            wc_ShaUpdate(sha, ssl->arrays->clientRandom, RAN_LEN);
-            wc_ShaUpdate(sha, ssl->arrays->serverRandom, RAN_LEN);
-            wc_ShaUpdate(sha, messageVerify, verifySz);
-            wc_ShaFinal(sha, hash + MD5_DIGEST_SIZE);
-        }
-#endif
-
-#ifndef NO_SHA256
-    #ifdef WOLFSSL_SMALL_STACK
-        if (doSha256) {
-            sha256 = (Sha256*)XMALLOC(sizeof(Sha256), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            hash256 = (byte*)XMALLOC(SHA256_DIGEST_SIZE, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            if (sha256 == NULL || hash256 == NULL)
-                ERROR_OUT(MEMORY_E, done);
-        }
-    #endif
-        if (doSha256) {
-            if (!(ret = wc_InitSha256(sha256))
-            &&  !(ret = wc_Sha256Update(sha256, ssl->arrays->clientRandom,
-                                        RAN_LEN))
-            &&  !(ret = wc_Sha256Update(sha256, ssl->arrays->serverRandom,
-                                        RAN_LEN))
-            &&  !(ret = wc_Sha256Update(sha256, messageVerify, verifySz)))
-                  ret = wc_Sha256Final(sha256, hash256);
-            if (ret != 0) goto done;
-        }
-#endif
-
-#ifdef WOLFSSL_SHA384
-    #ifdef WOLFSSL_SMALL_STACK
-        if (doSha384) {
-            sha384 = (Sha384*)XMALLOC(sizeof(Sha384), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            hash384 = (byte*)XMALLOC(SHA384_DIGEST_SIZE, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            if (sha384 == NULL || hash384 == NULL)
-                ERROR_OUT(MEMORY_E, done);
-        }
-    #endif
-        if (doSha384) {
-            if (!(ret = wc_InitSha384(sha384))
-            &&  !(ret = wc_Sha384Update(sha384, ssl->arrays->clientRandom,
-                                        RAN_LEN))
-            &&  !(ret = wc_Sha384Update(sha384, ssl->arrays->serverRandom,
-                                        RAN_LEN))
-            &&  !(ret = wc_Sha384Update(sha384, messageVerify, verifySz)))
-                  ret = wc_Sha384Final(sha384, hash384);
-            if (ret != 0) goto done;
-        }
-#endif
-
-#ifdef WOLFSSL_SHA512
-    #ifdef WOLFSSL_SMALL_STACK
-        if (doSha512) {
-            sha512 = (Sha512*)XMALLOC(sizeof(Sha512), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            hash512 = (byte*)XMALLOC(SHA512_DIGEST_SIZE, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            if (sha512 == NULL || hash512 == NULL)
-                ERROR_OUT(MEMORY_E, done);
-        }
-    #endif
-        if (doSha512) {
-            if (!(ret = wc_InitSha512(sha512))
-            &&  !(ret = wc_Sha512Update(sha512, ssl->arrays->clientRandom,
-                                        RAN_LEN))
-            &&  !(ret = wc_Sha512Update(sha512, ssl->arrays->serverRandom,
-                                        RAN_LEN))
-            &&  !(ret = wc_Sha512Update(sha512, messageVerify, verifySz)))
-                  ret = wc_Sha512Final(sha512, hash512);
-            if (ret != 0) goto done;
-        }
-#endif
-
-#ifndef NO_RSA
-        /* rsa */
-        if (sigAlgo == rsa_sa_algo)
-        {
-            byte*  out        = NULL;
-            byte   doUserRsa  = 0;
-            word32 verifiedSz = 0;
-
-            #ifdef HAVE_PK_CALLBACKS
-                if (ssl->ctx->RsaVerifyCb)
-                    doUserRsa = 1;
-            #endif /*HAVE_PK_CALLBACKS */
-
-            if (ssl->peerRsaKey == NULL || !ssl->peerRsaKeyPresent)
-                ERROR_OUT(NO_PEER_KEY, done);
-
-            if (doUserRsa) {
-            #ifdef HAVE_PK_CALLBACKS
-                verifiedSz = ssl->ctx->RsaVerifyCb(ssl,
-                                                 (byte *)input + *inOutIdx,
-                                                 length, &out,
-                                                 ssl->buffers.peerRsaKey.buffer,
-                                                 ssl->buffers.peerRsaKey.length,
-                                                 ssl->RsaVerifyCtx);
-            #endif /*HAVE_PK_CALLBACKS */
-            }
-            else
-                verifiedSz = wc_RsaSSL_VerifyInline((byte *)input + *inOutIdx,
-                                                 length, &out, ssl->peerRsaKey);
-
-            if (IsAtLeastTLSv1_2(ssl)) {
-                word32 encSigSz;
-#ifndef NO_OLD_TLS
-                byte*  digest = &hash[MD5_DIGEST_SIZE];
-                int    typeH = SHAh;
-                int    digestSz = SHA_DIGEST_SIZE;
-#else
-                byte*  digest = hash256;
-                int    typeH =  SHA256h;
-                int    digestSz = SHA256_DIGEST_SIZE;
-#endif
-#ifdef WOLFSSL_SMALL_STACK
-                byte*  encodedSig = NULL;
-#else
-                byte   encodedSig[MAX_ENCODED_SIG_SZ];
-#endif
-
-                if (hashAlgo == sha_mac) {
-                    #ifndef NO_SHA
-                        digest   = &hash[MD5_DIGEST_SIZE];
-                        typeH    = SHAh;
-                        digestSz = SHA_DIGEST_SIZE;
-                    #endif
-                }
-                else if (hashAlgo == sha256_mac) {
-                    #ifndef NO_SHA256
-                        digest   = hash256;
-                        typeH    = SHA256h;
-                        digestSz = SHA256_DIGEST_SIZE;
-                    #endif
-                }
-                else if (hashAlgo == sha384_mac) {
-                    #ifdef WOLFSSL_SHA384
-                        digest   = hash384;
-                        typeH    = SHA384h;
-                        digestSz = SHA384_DIGEST_SIZE;
-                    #endif
-                }
-                else if (hashAlgo == sha512_mac) {
-                    #ifdef WOLFSSL_SHA512
-                        digest   = hash512;
-                        typeH    = SHA512h;
-                        digestSz = SHA512_DIGEST_SIZE;
-                    #endif
-                }
-
-            #ifdef WOLFSSL_SMALL_STACK
-                encodedSig = (byte*)XMALLOC(MAX_ENCODED_SIG_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-                if (encodedSig == NULL)
-                    ERROR_OUT(MEMORY_E, done);
-            #endif
-
-                if (digest == NULL)
-                    ERROR_OUT(ALGO_ID_E, done);
-                encSigSz = wc_EncodeSignature(encodedSig, digest, digestSz,
-                                              typeH);
-                if (encSigSz != verifiedSz || !out || XMEMCMP(out, encodedSig,
-                                        min(encSigSz, MAX_ENCODED_SIG_SZ)) != 0)
-                    ret = VERIFY_SIGN_ERROR;
-
-            #ifdef WOLFSSL_SMALL_STACK
-                XFREE(encodedSig, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #endif
-                if (ret != 0)
-                    goto done;
-            }
-            else if (verifiedSz != FINISHED_SZ || !out || XMEMCMP(out,
-                                                        hash, FINISHED_SZ) != 0)
-                ERROR_OUT(VERIFY_SIGN_ERROR, done);
-        } else
-#endif
-#ifdef HAVE_ECC
-        /* ecdsa */
-        if (sigAlgo == ecc_dsa_sa_algo) {
-            int verify = 0;
-#ifndef NO_OLD_TLS
-            byte* digest = &hash[MD5_DIGEST_SIZE];
-            word32 digestSz = SHA_DIGEST_SIZE;
-#else
-            byte* digest = hash256;
-            word32 digestSz = SHA256_DIGEST_SIZE;
-#endif
-            byte doUserEcc = 0;
-
-            #ifdef HAVE_PK_CALLBACKS
-                if (ssl->ctx->EccVerifyCb)
-                    doUserEcc = 1;
-            #endif
-
-            if (!ssl->peerEccDsaKeyPresent)
-                ERROR_OUT(NO_PEER_KEY, done);
-
-            if (IsAtLeastTLSv1_2(ssl)) {
-                if (hashAlgo == sha_mac) {
-                    #ifndef NO_SHA
-                        digest   = &hash[MD5_DIGEST_SIZE];
-                        digestSz = SHA_DIGEST_SIZE;
-                    #endif
-                }
-                else if (hashAlgo == sha256_mac) {
-                    #ifndef NO_SHA256
-                        digest   = hash256;
-                        digestSz = SHA256_DIGEST_SIZE;
-                    #endif
-                }
-                else if (hashAlgo == sha384_mac) {
-                    #ifdef WOLFSSL_SHA384
-                        digest   = hash384;
-                        digestSz = SHA384_DIGEST_SIZE;
-                    #endif
-                }
-                else if (hashAlgo == sha512_mac) {
-                    #ifdef WOLFSSL_SHA512
-                        digest   = hash512;
-                        digestSz = SHA512_DIGEST_SIZE;
-                    #endif
-                }
-            }
-            if (doUserEcc) {
-            #ifdef HAVE_PK_CALLBACKS
-                ret = ssl->ctx->EccVerifyCb(ssl, input + *inOutIdx, length,
-                                            digest, digestSz,
-                                            ssl->buffers.peerEccDsaKey.buffer,
-                                            ssl->buffers.peerEccDsaKey.length,
-                                            &verify, ssl->EccVerifyCtx);
-            #endif
-            }
-            else {
-                ret = wc_ecc_verify_hash(input + *inOutIdx, length,
-                                 digest, digestSz, &verify, ssl->peerEccDsaKey);
-            }
-            if (ret != 0 || verify == 0)
-                ERROR_OUT(VERIFY_SIGN_ERROR, done);
-        }
-        else
-#endif /* HAVE_ECC */
-            ERROR_OUT(ALGO_ID_E, done);
-
-        /* signature length */
-        *inOutIdx += length;
-
-        ssl->options.serverState = SERVER_KEYEXCHANGE_COMPLETE;
-
-    done:
-#ifdef WOLFSSL_SMALL_STACK
-    #ifndef NO_OLD_TLS
-        XFREE(md5,           NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(sha,           NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-    #ifndef NO_SHA256
-        XFREE(sha256,        NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(hash256,       NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-    #ifdef WOLFSSL_SHA384
-        XFREE(sha384,        NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(hash384,       NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-    #ifdef WOLFSSL_SHA512
-        XFREE(sha512,        NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(hash512,       NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-        XFREE(hash,          NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(messageVerify, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        if (ret != 0)
-            return ret;
-    }
-
-    if (ssl->keys.encryptionOn) {
-        *inOutIdx += ssl->keys.padSz;
-    }
-
-    return 0;
-#else  /* !NO_DH or HAVE_ECC */
-        return NOT_COMPILED_IN;  /* not supported by build */
-#endif /* !NO_DH or HAVE_ECC */
-
-        #undef ERROR_OUT
-    }
-
-
-    int SendClientKeyExchange(WOLFSSL* ssl)
-    {
-#ifdef WOLFSSL_SMALL_STACK
-        byte*  encSecret = NULL;
-#else
-        byte   encSecret[MAX_ENCRYPT_SZ];
-#endif
-        word32 encSz = 0;
-        word32 idx = 0;
-        int    ret = 0;
-        byte   doUserRsa = 0;
-
-        (void)doUserRsa;
-
-#ifdef HAVE_PK_CALLBACKS
-    #ifndef NO_RSA
-        if (ssl->ctx->RsaEncCb)
-            doUserRsa = 1;
-    #endif /* NO_RSA */
-#endif /*HAVE_PK_CALLBACKS */
-
-    #ifdef WOLFSSL_SMALL_STACK
-        encSecret = (byte*)XMALLOC(MAX_ENCRYPT_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-        if (encSecret == NULL)
-            return MEMORY_E;
-    #endif
-
-        switch (ssl->specs.kea) {
-        #ifndef NO_RSA
-            case rsa_kea:
-                ret = wc_RNG_GenerateBlock(ssl->rng, ssl->arrays->preMasterSecret,
-                                                                    SECRET_LEN);
-                if (ret != 0) {
-                #ifdef WOLFSSL_SMALL_STACK
-                    XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                #endif
-                    return ret;
-                }
-
-                ssl->arrays->preMasterSecret[0] = ssl->chVersion.major;
-                ssl->arrays->preMasterSecret[1] = ssl->chVersion.minor;
-                ssl->arrays->preMasterSz = SECRET_LEN;
-
-                if (ssl->peerRsaKey == NULL || ssl->peerRsaKeyPresent == 0) {
-                #ifdef WOLFSSL_SMALL_STACK
-                    XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                #endif
-                    return NO_PEER_KEY;
-                }
-
-                if (doUserRsa) {
-                #ifdef HAVE_PK_CALLBACKS
-                    #ifndef NO_RSA
-                        encSz = MAX_ENCRYPT_SZ;
-                        ret = ssl->ctx->RsaEncCb(ssl,
-                                            ssl->arrays->preMasterSecret,
-                                            SECRET_LEN,
-                                            encSecret, &encSz,
-                                            ssl->buffers.peerRsaKey.buffer,
-                                            ssl->buffers.peerRsaKey.length,
-                                            ssl->RsaEncCtx);
-                    #endif /* NO_RSA */
-                #endif /*HAVE_PK_CALLBACKS */
-                }
-                else {
-                    ret = wc_RsaPublicEncrypt(ssl->arrays->preMasterSecret,
-                                 SECRET_LEN, encSecret, MAX_ENCRYPT_SZ,
-                                 ssl->peerRsaKey, ssl->rng);
-                    if (ret > 0) {
-                        encSz = ret;
-                        ret = 0;   /* set success to 0 */
-                    }
-                }
-                break;
-        #endif
-        #ifndef NO_DH
-            case diffie_hellman_kea:
-                {
-                    buffer  serverP   = ssl->buffers.serverDH_P;
-                    buffer  serverG   = ssl->buffers.serverDH_G;
-                    buffer  serverPub = ssl->buffers.serverDH_Pub;
-                #ifdef WOLFSSL_SMALL_STACK
-                    byte*   priv = NULL;
-                #else
-                    byte    priv[ENCRYPT_LEN];
-                #endif
-                    word32  privSz = 0;
-                    DhKey   key;
-
-                    if (serverP.buffer == 0 || serverG.buffer == 0 ||
-                                               serverPub.buffer == 0) {
-                    #ifdef WOLFSSL_SMALL_STACK
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                    #endif
-                        return NO_PEER_KEY;
-                    }
-
-                #ifdef WOLFSSL_SMALL_STACK
-                    priv = (byte*)XMALLOC(ENCRYPT_LEN, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-                    if (priv == NULL) {
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                        return MEMORY_E;
-                    }
-                #endif
-
-                    wc_InitDhKey(&key);
-                    ret = wc_DhSetKey(&key, serverP.buffer, serverP.length,
-                                   serverG.buffer, serverG.length);
-                    if (ret == 0)
-                        /* for DH, encSecret is Yc, agree is pre-master */
-                        ret = wc_DhGenerateKeyPair(&key, ssl->rng, priv, &privSz,
-                                                encSecret, &encSz);
-                    if (ret == 0)
-                        ret = wc_DhAgree(&key, ssl->arrays->preMasterSecret,
-                                      &ssl->arrays->preMasterSz, priv, privSz,
-                                      serverPub.buffer, serverPub.length);
-                #ifdef WOLFSSL_SMALL_STACK
-                    XFREE(priv, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                #endif
-                    wc_FreeDhKey(&key);
-                }
-                break;
-        #endif /* NO_DH */
-        #ifndef NO_PSK
-            case psk_kea:
-                {
-                    byte* pms = ssl->arrays->preMasterSecret;
-
-                    ssl->arrays->psk_keySz = ssl->options.client_psk_cb(ssl,
-                        ssl->arrays->server_hint, ssl->arrays->client_identity,
-                        MAX_PSK_ID_LEN, ssl->arrays->psk_key, MAX_PSK_KEY_LEN);
-                    if (ssl->arrays->psk_keySz == 0 ||
-                        ssl->arrays->psk_keySz > MAX_PSK_KEY_LEN) {
-                    #ifdef WOLFSSL_SMALL_STACK
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                    #endif
-                        return PSK_KEY_ERROR;
-                    }
-                    encSz = (word32)XSTRLEN(ssl->arrays->client_identity);
-                    if (encSz > MAX_PSK_ID_LEN) {
-                    #ifdef WOLFSSL_SMALL_STACK
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                    #endif
-                        return CLIENT_ID_ERROR;
-                    }
-                    XMEMCPY(encSecret, ssl->arrays->client_identity, encSz);
-
-                    /* make psk pre master secret */
-                    /* length of key + length 0s + length of key + key */
-                    c16toa((word16)ssl->arrays->psk_keySz, pms);
-                    pms += 2;
-                    XMEMSET(pms, 0, ssl->arrays->psk_keySz);
-                    pms += ssl->arrays->psk_keySz;
-                    c16toa((word16)ssl->arrays->psk_keySz, pms);
-                    pms += 2;
-                    XMEMCPY(pms, ssl->arrays->psk_key, ssl->arrays->psk_keySz);
-                    ssl->arrays->preMasterSz = ssl->arrays->psk_keySz * 2 + 4;
-                    ForceZero(ssl->arrays->psk_key, ssl->arrays->psk_keySz);
-                    ssl->arrays->psk_keySz = 0; /* No further need */
-                }
-                break;
-        #endif /* NO_PSK */
-        #if !defined(NO_DH) && !defined(NO_PSK)
-            case dhe_psk_kea:
-                {
-                    byte* pms = ssl->arrays->preMasterSecret;
-                    byte* es  = encSecret;
-                    buffer  serverP   = ssl->buffers.serverDH_P;
-                    buffer  serverG   = ssl->buffers.serverDH_G;
-                    buffer  serverPub = ssl->buffers.serverDH_Pub;
-                #ifdef WOLFSSL_SMALL_STACK
-                    byte*   priv = NULL;
-                #else
-                    byte    priv[ENCRYPT_LEN];
-                #endif
-                    word32  privSz = 0;
-                    word32  pubSz = 0;
-                    word32  esSz = 0;
-                    DhKey   key;
-
-                    if (serverP.buffer == 0 || serverG.buffer == 0 ||
-                                               serverPub.buffer == 0) {
-                    #ifdef WOLFSSL_SMALL_STACK
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                    #endif
-                        return NO_PEER_KEY;
-                    }
-
-                    ssl->arrays->psk_keySz = ssl->options.client_psk_cb(ssl,
-                         ssl->arrays->server_hint, ssl->arrays->client_identity,
-                         MAX_PSK_ID_LEN, ssl->arrays->psk_key, MAX_PSK_KEY_LEN);
-                    if (ssl->arrays->psk_keySz == 0 ||
-                                     ssl->arrays->psk_keySz > MAX_PSK_KEY_LEN) {
-                    #ifdef WOLFSSL_SMALL_STACK
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                    #endif
-                        return PSK_KEY_ERROR;
-                    }
-                    esSz = (word32)XSTRLEN(ssl->arrays->client_identity);
-
-                    if (esSz > MAX_PSK_ID_LEN) {
-                    #ifdef WOLFSSL_SMALL_STACK
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                    #endif
-                        return CLIENT_ID_ERROR;
-                    }
-
-                #ifdef WOLFSSL_SMALL_STACK
-                    priv = (byte*)XMALLOC(ENCRYPT_LEN, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-                    if (priv == NULL) {
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                        return MEMORY_E;
-                    }
-                #endif
-                    c16toa((word16)esSz, es);
-                    es += OPAQUE16_LEN;
-                    XMEMCPY(es, ssl->arrays->client_identity, esSz);
-                    es += esSz;
-                    encSz = esSz + OPAQUE16_LEN;
-
-                    wc_InitDhKey(&key);
-                    ret = wc_DhSetKey(&key, serverP.buffer, serverP.length,
-                                   serverG.buffer, serverG.length);
-                    if (ret == 0)
-                        /* for DH, encSecret is Yc, agree is pre-master */
-                        ret = wc_DhGenerateKeyPair(&key, ssl->rng, priv, &privSz,
-                                                es + OPAQUE16_LEN, &pubSz);
-                    if (ret == 0)
-                        ret = wc_DhAgree(&key, pms + OPAQUE16_LEN,
-                                      &ssl->arrays->preMasterSz, priv, privSz,
-                                      serverPub.buffer, serverPub.length);
-                    wc_FreeDhKey(&key);
-                #ifdef WOLFSSL_SMALL_STACK
-                    XFREE(priv, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                #endif
-                    if (ret != 0) {
-                    #ifdef WOLFSSL_SMALL_STACK
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                    #endif
-                        return ret;
-                    }
-
-                    c16toa((word16)pubSz, es);
-                    encSz += pubSz + OPAQUE16_LEN;
-                    c16toa((word16)ssl->arrays->preMasterSz, pms);
-                    ssl->arrays->preMasterSz += OPAQUE16_LEN;
-                    pms += ssl->arrays->preMasterSz;
-
-                    /* make psk pre master secret */
-                    /* length of key + length 0s + length of key + key */
-                    c16toa((word16)ssl->arrays->psk_keySz, pms);
-                    pms += OPAQUE16_LEN;
-                    XMEMCPY(pms, ssl->arrays->psk_key, ssl->arrays->psk_keySz);
-                    ssl->arrays->preMasterSz +=
-                                          ssl->arrays->psk_keySz + OPAQUE16_LEN;
-                    ForceZero(ssl->arrays->psk_key, ssl->arrays->psk_keySz);
-                    ssl->arrays->psk_keySz = 0; /* No further need */
-                }
-                break;
-        #endif /* !NO_DH && !NO_PSK */
-        #ifdef HAVE_NTRU
-            case ntru_kea:
-                {
-                    word32 rc;
-                    word16 cipherLen = MAX_ENCRYPT_SZ;
-                    DRBG_HANDLE drbg;
-                    static uint8_t const wolfsslStr[] = {
-                        'C', 'y', 'a', 'S', 'S', 'L', ' ', 'N', 'T', 'R', 'U'
-                    };
-
-                    ret = wc_RNG_GenerateBlock(ssl->rng,
-                                      ssl->arrays->preMasterSecret, SECRET_LEN);
-                    if (ret != 0) {
-                    #ifdef WOLFSSL_SMALL_STACK
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                    #endif
-                        return ret;
-                    }
-
-                    ssl->arrays->preMasterSz = SECRET_LEN;
-
-                    if (ssl->peerNtruKeyPresent == 0) {
-                    #ifdef WOLFSSL_SMALL_STACK
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                    #endif
-                        return NO_PEER_KEY;
-                    }
-
-                    rc = ntru_crypto_drbg_instantiate(MAX_NTRU_BITS, wolfsslStr,
-                                                 sizeof(wolfsslStr), GetEntropy,
-                                                 &drbg);
-                    if (rc != DRBG_OK) {
-                    #ifdef WOLFSSL_SMALL_STACK
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                    #endif
-                        return NTRU_DRBG_ERROR;
-                    }
-
-                    rc = ntru_crypto_ntru_encrypt(drbg, ssl->peerNtruKeyLen,
-                                                  ssl->peerNtruKey,
-                                                  ssl->arrays->preMasterSz,
-                                                  ssl->arrays->preMasterSecret,
-                                                  &cipherLen, encSecret);
-                    ntru_crypto_drbg_uninstantiate(drbg);
-                    if (rc != NTRU_OK) {
-                    #ifdef WOLFSSL_SMALL_STACK
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                    #endif
-                        return NTRU_ENCRYPT_ERROR;
-                    }
-
-                    encSz = cipherLen;
-                    ret = 0;
-                }
-                break;
-        #endif /* HAVE_NTRU */
-        #ifdef HAVE_ECC
-            case ecc_diffie_hellman_kea:
-                {
-                    ecc_key  myKey;
-                    ecc_key* peerKey = NULL;
-                    word32   size = MAX_ENCRYPT_SZ;
-
-                    if (ssl->specs.static_ecdh) {
-                        /* TODO: EccDsa is really fixed Ecc change naming */
-                        if (!ssl->peerEccDsaKey || !ssl->peerEccDsaKeyPresent ||
-                                                   !ssl->peerEccDsaKey->dp) {
-                        #ifdef WOLFSSL_SMALL_STACK
-                            XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                        #endif
-                            return NO_PEER_KEY;
-                        }
-                        peerKey = ssl->peerEccDsaKey;
-                    }
-                    else {
-                        if (!ssl->peerEccKey || !ssl->peerEccKeyPresent ||
-                                                !ssl->peerEccKey->dp) {
-                        #ifdef WOLFSSL_SMALL_STACK
-                            XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                        #endif
-                            return NO_PEER_KEY;
-                        }
-                        peerKey = ssl->peerEccKey;
-                    }
-
-                    if (peerKey == NULL) {
-                    #ifdef WOLFSSL_SMALL_STACK
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                    #endif
-                        return NO_PEER_KEY;
-                    }
-
-                    wc_ecc_init(&myKey);
-                    ret = wc_ecc_make_key(ssl->rng, peerKey->dp->size, &myKey);
-                    if (ret != 0) {
-                    #ifdef WOLFSSL_SMALL_STACK
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                    #endif
-                        return ECC_MAKEKEY_ERROR;
-                    }
-
-                    /* precede export with 1 byte length */
-                    ret = wc_ecc_export_x963(&myKey, encSecret + 1, &size);
-                    encSecret[0] = (byte)size;
-                    encSz = size + 1;
-
-                    if (ret != 0)
-                        ret = ECC_EXPORT_ERROR;
-                    else {
-                        size = sizeof(ssl->arrays->preMasterSecret);
-                        ret  = wc_ecc_shared_secret(&myKey, peerKey,
-                                                 ssl->arrays->preMasterSecret, &size);
-                        if (ret != 0)
-                            ret = ECC_SHARED_ERROR;
-                    }
-
-                    ssl->arrays->preMasterSz = size;
-                    wc_ecc_free(&myKey);
-                }
-                break;
-        #endif /* HAVE_ECC */
-            default:
-            #ifdef WOLFSSL_SMALL_STACK
-                XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #endif
-                return ALGO_ID_E; /* unsupported kea */
-        }
-
-        if (ret == 0) {
-            byte              *output;
-            int                sendSz;
-            word32             tlsSz = 0;
-
-            if (ssl->options.tls || ssl->specs.kea == diffie_hellman_kea)
-                tlsSz = 2;
-
-            if (ssl->specs.kea == ecc_diffie_hellman_kea ||
-                ssl->specs.kea == dhe_psk_kea)  /* always off */
-                tlsSz = 0;
-
-            sendSz = encSz + tlsSz + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ;
-            idx    = HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ;
-
-            #ifdef WOLFSSL_DTLS
-                if (ssl->options.dtls) {
-                    sendSz += DTLS_HANDSHAKE_EXTRA + DTLS_RECORD_EXTRA;
-                    idx    += DTLS_HANDSHAKE_EXTRA + DTLS_RECORD_EXTRA;
-                }
-            #endif
-
-            if (ssl->keys.encryptionOn)
-                sendSz += MAX_MSG_EXTRA;
-
-            /* check for available size */
-            if ((ret = CheckAvailableSize(ssl, sendSz)) != 0) {
-            #ifdef WOLFSSL_SMALL_STACK
-                XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #endif
-                return ret;
-            }
-
-            /* get ouput buffer */
-            output = ssl->buffers.outputBuffer.buffer +
-                     ssl->buffers.outputBuffer.length;
-
-            AddHeaders(output, encSz + tlsSz, client_key_exchange, ssl);
-
-            if (tlsSz) {
-                c16toa((word16)encSz, &output[idx]);
-                idx += 2;
-            }
-            XMEMCPY(output + idx, encSecret, encSz);
-            idx += encSz;
-
-            if (ssl->keys.encryptionOn) {
-                byte* input;
-                int   inputSz = idx-RECORD_HEADER_SZ; /* buildmsg adds rechdr */
-
-                input = (byte*)XMALLOC(inputSz, ssl->heap,
-                                       DYNAMIC_TYPE_TMP_BUFFER);
-                if (input == NULL) {
-                #ifdef WOLFSSL_SMALL_STACK
-                    XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                #endif
-                    return MEMORY_E;
-                }
-
-                XMEMCPY(input, output + RECORD_HEADER_SZ, inputSz);
-                sendSz = BuildMessage(ssl, output, sendSz, input, inputSz,
-                                      handshake);
-                XFREE(input, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER);
-                if (sendSz < 0) {
-                #ifdef WOLFSSL_SMALL_STACK
-                    XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                #endif
-                    return sendSz;
-                }
-            } else {
-                ret = HashOutput(ssl, output, sendSz, 0);
-                if (ret != 0) {
-                #ifdef WOLFSSL_SMALL_STACK
-                    XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                #endif
-                    return ret;
-                }
-            }
-
-            #ifdef WOLFSSL_DTLS
-                if (ssl->options.dtls) {
-                    if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) {
-                    #ifdef WOLFSSL_SMALL_STACK
-                        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                    #endif
-                        return ret;
-                    }
-                }
-            #endif
-
-            #ifdef WOLFSSL_CALLBACKS
-                if (ssl->hsInfoOn)
-                    AddPacketName("ClientKeyExchange", &ssl->handShakeInfo);
-                if (ssl->toInfoOn)
-                    AddPacketInfo("ClientKeyExchange", &ssl->timeoutInfo,
-                                  output, sendSz, ssl->heap);
-            #endif
-
-            ssl->buffers.outputBuffer.length += sendSz;
-
-            if (ssl->options.groupMessages)
-                ret = 0;
-            else
-                ret = SendBuffered(ssl);
-        }
-
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-
-        if (ret == 0 || ret == WANT_WRITE) {
-            int tmpRet = MakeMasterSecret(ssl);
-            if (tmpRet != 0)
-                ret = tmpRet;   /* save WANT_WRITE unless more serious */
-            ssl->options.clientState = CLIENT_KEYEXCHANGE_COMPLETE;
-        }
-        /* No further need for PMS */
-        ForceZero(ssl->arrays->preMasterSecret, ssl->arrays->preMasterSz);
-        ssl->arrays->preMasterSz = 0;
-
-        return ret;
-    }
-
-#ifndef NO_CERTS
-    int SendCertificateVerify(WOLFSSL* ssl)
-    {
-        byte              *output;
-        int                sendSz = MAX_CERT_VERIFY_SZ, length, ret;
-        word32             idx = 0;
-        word32             sigOutSz = 0;
-#ifndef NO_RSA
-        RsaKey             key;
-        int                initRsaKey = 0;
-#endif
-        int                usingEcc = 0;
-#ifdef HAVE_ECC
-        ecc_key            eccKey;
-#endif
-
-        (void)idx;
-
-        if (ssl->options.sendVerify == SEND_BLANK_CERT)
-            return 0;  /* sent blank cert, can't verify */
-
-        if (ssl->keys.encryptionOn)
-            sendSz += MAX_MSG_EXTRA;
-
-        /* check for available size */
-        if ((ret = CheckAvailableSize(ssl, sendSz)) != 0)
-            return ret;
-
-        /* get ouput buffer */
-        output = ssl->buffers.outputBuffer.buffer +
-                 ssl->buffers.outputBuffer.length;
-
-        ret = BuildCertHashes(ssl, &ssl->hsHashes->certHashes);
-        if (ret != 0)
-            return ret;
-
-#ifdef HAVE_ECC
-        wc_ecc_init(&eccKey);
-#endif
-#ifndef NO_RSA
-        ret = wc_InitRsaKey(&key, ssl->heap);
-        if (ret == 0) initRsaKey = 1;
-        if (ret == 0)
-            ret = wc_RsaPrivateKeyDecode(ssl->buffers.key.buffer, &idx, &key,
-                                      ssl->buffers.key.length);
-        if (ret == 0)
-            sigOutSz = wc_RsaEncryptSize(&key);
-        else
-#endif
-        {
-    #ifdef HAVE_ECC
-            WOLFSSL_MSG("Trying ECC client cert, RSA didn't work");
-
-            idx = 0;
-            ret = wc_EccPrivateKeyDecode(ssl->buffers.key.buffer, &idx, &eccKey,
-                                      ssl->buffers.key.length);
-            if (ret == 0) {
-                WOLFSSL_MSG("Using ECC client cert");
-                usingEcc = 1;
-                sigOutSz = MAX_ENCODED_SIG_SZ;
-            }
-            else {
-                WOLFSSL_MSG("Bad client cert type");
-            }
-    #endif
-        }
-        if (ret == 0) {
-            byte*  verify = (byte*)&output[RECORD_HEADER_SZ +
-                                           HANDSHAKE_HEADER_SZ];
-#ifndef NO_OLD_TLS
-            byte*  signBuffer = ssl->hsHashes->certHashes.md5;
-#else
-            byte*  signBuffer = NULL;
-#endif
-            word32 signSz = FINISHED_SZ;
-            word32 extraSz = 0;  /* tls 1.2 hash/sig */
-#ifdef WOLFSSL_SMALL_STACK
-            byte*  encodedSig = NULL;
-#else
-            byte   encodedSig[MAX_ENCODED_SIG_SZ];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-            encodedSig = (byte*)XMALLOC(MAX_ENCODED_SIG_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            if (encodedSig == NULL) {
-            #ifndef NO_RSA
-                if (initRsaKey)
-                    wc_FreeRsaKey(&key);
-            #endif
-            #ifdef HAVE_ECC
-                wc_ecc_free(&eccKey);
-            #endif
-                return MEMORY_E;
-            }
-#endif
-
-            (void)encodedSig;
-            (void)signSz;
-            (void)signBuffer;
-
-            #ifdef WOLFSSL_DTLS
-                if (ssl->options.dtls)
-                    verify += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-            #endif
-            length = sigOutSz;
-            if (IsAtLeastTLSv1_2(ssl)) {
-                verify[0] = ssl->suites->hashAlgo;
-                verify[1] = usingEcc ? ecc_dsa_sa_algo : rsa_sa_algo;
-                extraSz = HASH_SIG_SIZE;
-            }
-
-            if (usingEcc) {
-#ifdef HAVE_ECC
-                word32 localSz = MAX_ENCODED_SIG_SZ;
-                word32 digestSz;
-                byte*  digest;
-                byte   doUserEcc = 0;
-#ifndef NO_OLD_TLS
-                /* old tls default */
-                digestSz = SHA_DIGEST_SIZE;
-                digest   = ssl->hsHashes->certHashes.sha;
-#else
-                /* new tls default */
-                digestSz = SHA256_DIGEST_SIZE;
-                digest   = ssl->hsHashes->certHashes.sha256;
-#endif
-
-                #ifdef HAVE_PK_CALLBACKS
-                    #ifdef HAVE_ECC
-                        if (ssl->ctx->EccSignCb)
-                            doUserEcc = 1;
-                    #endif /* HAVE_ECC */
-                #endif /*HAVE_PK_CALLBACKS */
-
-                if (IsAtLeastTLSv1_2(ssl)) {
-                    if (ssl->suites->hashAlgo == sha_mac) {
-                        #ifndef NO_SHA
-                            digest = ssl->hsHashes->certHashes.sha;
-                            digestSz = SHA_DIGEST_SIZE;
-                        #endif
-                    }
-                    else if (ssl->suites->hashAlgo == sha256_mac) {
-                        #ifndef NO_SHA256
-                            digest = ssl->hsHashes->certHashes.sha256;
-                            digestSz = SHA256_DIGEST_SIZE;
-                        #endif
-                    }
-                    else if (ssl->suites->hashAlgo == sha384_mac) {
-                        #ifdef WOLFSSL_SHA384
-                            digest = ssl->hsHashes->certHashes.sha384;
-                            digestSz = SHA384_DIGEST_SIZE;
-                        #endif
-                    }
-                    else if (ssl->suites->hashAlgo == sha512_mac) {
-                        #ifdef WOLFSSL_SHA512
-                            digest = ssl->hsHashes->certHashes.sha512;
-                            digestSz = SHA512_DIGEST_SIZE;
-                        #endif
-                    }
-                }
-
-                if (doUserEcc) {
-                #ifdef HAVE_PK_CALLBACKS
-                    #ifdef HAVE_ECC
-                        ret = ssl->ctx->EccSignCb(ssl, digest, digestSz,
-                                        encodedSig, &localSz,
-                                        ssl->buffers.key.buffer,
-                                        ssl->buffers.key.length,
-                                        ssl->EccSignCtx);
-                    #endif /* HAVE_ECC */
-                #endif /*HAVE_PK_CALLBACKS */
-                }
-                else {
-                    ret = wc_ecc_sign_hash(digest, digestSz, encodedSig,
-                                        &localSz, ssl->rng, &eccKey);
-                }
-                if (ret == 0) {
-                    length = localSz;
-                    c16toa((word16)length, verify + extraSz); /* prepend hdr */
-                    XMEMCPY(verify + extraSz + VERIFY_HEADER,encodedSig,length);
-                }
-#endif
-            }
-#ifndef NO_RSA
-            else {
-                byte doUserRsa = 0;
-
-                #ifdef HAVE_PK_CALLBACKS
-                    if (ssl->ctx->RsaSignCb)
-                        doUserRsa = 1;
-                #endif /*HAVE_PK_CALLBACKS */
-
-                if (IsAtLeastTLSv1_2(ssl)) {
-                    /*
-                     * MSVC Compiler complains because it can not
-                     * guarantee any of the conditionals will succeed in
-                     * assigning a value before wc_EncodeSignature executes.
-                     */
-                    byte* digest    = NULL;
-                    int   digestSz  = 0;
-                    int   typeH     = 0;
-                    int   didSet    = 0;
-
-                    if (ssl->suites->hashAlgo == sha_mac) {
-                        #ifndef NO_SHA
-                            digest   = ssl->hsHashes->certHashes.sha;
-                            typeH    = SHAh;
-                            digestSz = SHA_DIGEST_SIZE;
-                            didSet   = 1;
-                        #endif
-                    }
-                    else if (ssl->suites->hashAlgo == sha256_mac) {
-                        #ifndef NO_SHA256
-                            digest   = ssl->hsHashes->certHashes.sha256;
-                            typeH    = SHA256h;
-                            digestSz = SHA256_DIGEST_SIZE;
-                            didSet   = 1;
-                        #endif
-                    }
-                    else if (ssl->suites->hashAlgo == sha384_mac) {
-                        #ifdef WOLFSSL_SHA384
-                            digest   = ssl->hsHashes->certHashes.sha384;
-                            typeH    = SHA384h;
-                            digestSz = SHA384_DIGEST_SIZE;
-                            didSet   = 1;
-                        #endif
-                    }
-                    else if (ssl->suites->hashAlgo == sha512_mac) {
-                        #ifdef WOLFSSL_SHA512
-                            digest   = ssl->hsHashes->certHashes.sha512;
-                            typeH    = SHA512h;
-                            digestSz = SHA512_DIGEST_SIZE;
-                            didSet   = 1;
-                        #endif
-                    }
-
-                    if (didSet == 0) {
-                        /* defaults */
-                        #ifndef NO_OLD_TLS
-                            digest = ssl->hsHashes->certHashes.sha;
-                            digestSz = SHA_DIGEST_SIZE;
-                            typeH = SHAh;
-                        #else
-                            digest = ssl->hsHashes->certHashes.sha256;
-                            digestSz = SHA256_DIGEST_SIZE;
-                            typeH = SHA256h;
-                        #endif
-                    }
-
-                    signSz = wc_EncodeSignature(encodedSig, digest,digestSz,typeH);
-                    signBuffer = encodedSig;
-                }
-
-                c16toa((word16)length, verify + extraSz); /* prepend hdr */
-                if (doUserRsa) {
-                #ifdef HAVE_PK_CALLBACKS
-                    #ifndef NO_RSA
-                        word32 ioLen = ENCRYPT_LEN;
-                        ret = ssl->ctx->RsaSignCb(ssl, signBuffer, signSz,
-                                            verify + extraSz + VERIFY_HEADER,
-                                            &ioLen,
-                                            ssl->buffers.key.buffer,
-                                            ssl->buffers.key.length,
-                                            ssl->RsaSignCtx);
-                    #endif /* NO_RSA */
-                #endif /*HAVE_PK_CALLBACKS */
-                }
-                else {
-                    ret = wc_RsaSSL_Sign(signBuffer, signSz, verify + extraSz +
-                                  VERIFY_HEADER, ENCRYPT_LEN, &key, ssl->rng);
-                }
-
-                if (ret > 0)
-                    ret = 0;  /* RSA reset */
-            }
-#endif
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(encodedSig, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-            if (ret == 0) {
-                AddHeaders(output, length + extraSz + VERIFY_HEADER,
-                           certificate_verify, ssl);
-
-                sendSz = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ + length +
-                         extraSz + VERIFY_HEADER;
-
-                #ifdef WOLFSSL_DTLS
-                    if (ssl->options.dtls) {
-                        sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-                    }
-                #endif
-
-                if (ssl->keys.encryptionOn) {
-                    byte* input;
-                    int   inputSz = sendSz - RECORD_HEADER_SZ;
-                                    /* build msg adds rec hdr */
-                    input = (byte*)XMALLOC(inputSz, ssl->heap,
-                                           DYNAMIC_TYPE_TMP_BUFFER);
-                    if (input == NULL)
-                        ret = MEMORY_E;
-                    else {
-                        XMEMCPY(input, output + RECORD_HEADER_SZ, inputSz);
-                        sendSz = BuildMessage(ssl, output,
-                                              MAX_CERT_VERIFY_SZ +MAX_MSG_EXTRA,
-                                              input, inputSz, handshake);
-                        XFREE(input, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER);
-
-                        if (sendSz < 0)
-                            ret = sendSz;
-                    }
-                } else {
-                    ret = HashOutput(ssl, output, sendSz, 0);
-                }
-
-                #ifdef WOLFSSL_DTLS
-                    if (ssl->options.dtls) {
-                        if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0)
-                            return ret;
-                    }
-                #endif
-            }
-        }
-#ifndef NO_RSA
-        if (initRsaKey)
-            wc_FreeRsaKey(&key);
-#endif
-#ifdef HAVE_ECC
-        wc_ecc_free(&eccKey);
-#endif
-
-        if (ret == 0) {
-            #ifdef WOLFSSL_CALLBACKS
-                if (ssl->hsInfoOn)
-                    AddPacketName("CertificateVerify", &ssl->handShakeInfo);
-                if (ssl->toInfoOn)
-                    AddPacketInfo("CertificateVerify", &ssl->timeoutInfo,
-                                  output, sendSz, ssl->heap);
-            #endif
-            ssl->buffers.outputBuffer.length += sendSz;
-            if (ssl->options.groupMessages)
-                return 0;
-            else
-                return SendBuffered(ssl);
-        }
-        else
-            return ret;
-    }
-#endif /* NO_CERTS */
-
-#ifdef HAVE_SESSION_TICKET
-int DoSessionTicket(WOLFSSL* ssl,
-                               const byte* input, word32* inOutIdx, word32 size)
-{
-    word32 begin = *inOutIdx;
-    word32 lifetime;
-    word16 length;
-
-    if (ssl->expect_session_ticket == 0) {
-        WOLFSSL_MSG("Unexpected session ticket");
-        return SESSION_TICKET_EXPECT_E;
-    }
-
-    if ((*inOutIdx - begin) + OPAQUE32_LEN > size)
-        return BUFFER_ERROR;
-
-    ato32(input + *inOutIdx, &lifetime);
-    *inOutIdx += OPAQUE32_LEN;
-
-    if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-        return BUFFER_ERROR;
-
-    ato16(input + *inOutIdx, &length);
-    *inOutIdx += OPAQUE16_LEN;
-
-    if (length > sizeof(ssl->session.ticket))
-        return SESSION_TICKET_LEN_E;
-
-    if ((*inOutIdx - begin) + length > size)
-        return BUFFER_ERROR;
-
-    /* If the received ticket including its length is greater than
-     * a length value, the save it. Otherwise, don't save it. */
-    if (length > 0) {
-        XMEMCPY(ssl->session.ticket, input + *inOutIdx, length);
-        *inOutIdx += length;
-        ssl->session.ticketLen = length;
-        ssl->timeout = lifetime;
-        if (ssl->session_ticket_cb != NULL) {
-            ssl->session_ticket_cb(ssl,
-                                   ssl->session.ticket, ssl->session.ticketLen,
-                                   ssl->session_ticket_ctx);
-        }
-        /* Create a fake sessionID based on the ticket, this will
-         * supercede the existing session cache info. */
-        ssl->options.haveSessionId = 1;
-        XMEMCPY(ssl->arrays->sessionID,
-                                 ssl->session.ticket + length - ID_LEN, ID_LEN);
-#ifndef NO_SESSION_CACHE
-        AddSession(ssl);
-#endif
-
-    }
-    else {
-        ssl->session.ticketLen = 0;
-    }
-
-    if (ssl->keys.encryptionOn) {
-        *inOutIdx += ssl->keys.padSz;
-    }
-
-    ssl->expect_session_ticket = 0;
-
-    return 0;
-}
-#endif /* HAVE_SESSION_TICKET */
-
-#endif /* NO_WOLFSSL_CLIENT */
-
-
-#ifndef NO_WOLFSSL_SERVER
-
-    int SendServerHello(WOLFSSL* ssl)
-    {
-        byte              *output;
-        word32             length, idx = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ;
-        int                sendSz;
-        int                ret;
-        byte               sessIdSz = ID_LEN;
-
-        length = VERSION_SZ + RAN_LEN
-               + ID_LEN + ENUM_LEN
-               + SUITE_LEN
-               + ENUM_LEN;
-
-#ifdef HAVE_TLS_EXTENSIONS
-        length += TLSX_GetResponseSize(ssl);
-
-    #ifdef HAVE_SESSION_TICKET
-        if (ssl->options.useTicket && ssl->arrays->sessionIDSz == 0) {
-            /* no session id */
-            length  -= ID_LEN;
-            sessIdSz = 0;
-        }
-    #endif /* HAVE_SESSION_TICKET */
-#endif
-
-        /* check for avalaible size */
-        if ((ret = CheckAvailableSize(ssl, MAX_HELLO_SZ)) != 0)
-            return ret;
-
-        /* get ouput buffer */
-        output = ssl->buffers.outputBuffer.buffer +
-                 ssl->buffers.outputBuffer.length;
-
-        sendSz = length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ;
-        AddHeaders(output, length, server_hello, ssl);
-
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls) {
-                idx    += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-                sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-            }
-        #endif
-        /* now write to output */
-            /* first version */
-        output[idx++] = ssl->version.major;
-        output[idx++] = ssl->version.minor;
-
-            /* then random */
-        if (!ssl->options.resuming) {
-            ret = wc_RNG_GenerateBlock(ssl->rng, ssl->arrays->serverRandom,
-                                                                       RAN_LEN);
-            if (ret != 0)
-                return ret;
-        }
-
-        XMEMCPY(output + idx, ssl->arrays->serverRandom, RAN_LEN);
-        idx += RAN_LEN;
-
-#ifdef SHOW_SECRETS
-        {
-            int j;
-            printf("server random: ");
-            for (j = 0; j < RAN_LEN; j++)
-                printf("%02x", ssl->arrays->serverRandom[j]);
-            printf("\n");
-        }
-#endif
-            /* then session id */
-        output[idx++] = sessIdSz;
-        if (sessIdSz) {
-
-            if (!ssl->options.resuming) {
-                ret = wc_RNG_GenerateBlock(ssl->rng, ssl->arrays->sessionID,
-                                           sessIdSz);
-                if (ret != 0) return ret;
-            }
-
-            XMEMCPY(output + idx, ssl->arrays->sessionID, sessIdSz);
-            idx += sessIdSz;
-        }
-
-            /* then cipher suite */
-        output[idx++] = ssl->options.cipherSuite0;
-        output[idx++] = ssl->options.cipherSuite;
-
-            /* then compression */
-        if (ssl->options.usingCompression)
-            output[idx++] = ZLIB_COMPRESSION;
-        else
-            output[idx++] = NO_COMPRESSION;
-
-            /* last, extensions */
-#ifdef HAVE_TLS_EXTENSIONS
-        TLSX_WriteResponse(ssl, output + idx);
-#endif
-
-        ssl->buffers.outputBuffer.length += sendSz;
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls) {
-                if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0)
-                    return ret;
-            }
-        #endif
-
-        ret = HashOutput(ssl, output, sendSz, 0);
-        if (ret != 0)
-            return ret;
-
-        #ifdef WOLFSSL_CALLBACKS
-            if (ssl->hsInfoOn)
-                AddPacketName("ServerHello", &ssl->handShakeInfo);
-            if (ssl->toInfoOn)
-                AddPacketInfo("ServerHello", &ssl->timeoutInfo, output, sendSz,
-                              ssl->heap);
-        #endif
-
-        ssl->options.serverState = SERVER_HELLO_COMPLETE;
-
-        if (ssl->options.groupMessages)
-            return 0;
-        else
-            return SendBuffered(ssl);
-    }
-
-
-#ifdef HAVE_ECC
-
-    static byte SetCurveId(int size)
-    {
-        switch(size) {
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC160)
-            case 20:
-                return WOLFSSL_ECC_SECP160R1;
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC192)
-            case 24:
-                return WOLFSSL_ECC_SECP192R1;
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC224)
-            case 28:
-                return WOLFSSL_ECC_SECP224R1;
-#endif
-#if defined(HAVE_ALL_CURVES) || !defined(NO_ECC256)
-            case 32:
-                return WOLFSSL_ECC_SECP256R1;
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC384)
-            case 48:
-                return WOLFSSL_ECC_SECP384R1;
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC521)
-            case 66:
-                return WOLFSSL_ECC_SECP521R1;
-#endif
-            default:
-                return 0;
-        }
-    }
-
-#endif /* HAVE_ECC */
-
-
-    int SendServerKeyExchange(WOLFSSL* ssl)
-    {
-        int ret = 0;
-        (void)ssl;
-        #define ERROR_OUT(err, eLabel) do { ret = err; goto eLabel; } while(0)
-
-    #ifndef NO_PSK
-        if (ssl->specs.kea == psk_kea)
-        {
-            byte    *output;
-            word32   length, idx = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ;
-            int      sendSz;
-            if (ssl->arrays->server_hint[0] == 0) return 0; /* don't send */
-
-            /* include size part */
-            length = (word32)XSTRLEN(ssl->arrays->server_hint);
-            if (length > MAX_PSK_ID_LEN)
-                return SERVER_HINT_ERROR;
-
-            length += HINT_LEN_SZ;
-            sendSz = length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ;
-
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls) {
-                sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-                idx    += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-            }
-        #endif
-            /* check for available size */
-            if ((ret = CheckAvailableSize(ssl, sendSz)) != 0)
-               return ret;
-
-            /* get ouput buffer */
-            output = ssl->buffers.outputBuffer.buffer +
-                     ssl->buffers.outputBuffer.length;
-
-            AddHeaders(output, length, server_key_exchange, ssl);
-
-            /* key data */
-            c16toa((word16)(length - HINT_LEN_SZ), output + idx);
-            idx += HINT_LEN_SZ;
-            XMEMCPY(output + idx, ssl->arrays->server_hint,length -HINT_LEN_SZ);
-
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls)
-                if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0)
-                    return ret;
-        #endif
-
-            ret = HashOutput(ssl, output, sendSz, 0);
-            if (ret != 0)
-                return ret;
-
-        #ifdef WOLFSSL_CALLBACKS
-            if (ssl->hsInfoOn)
-                AddPacketName("ServerKeyExchange", &ssl->handShakeInfo);
-            if (ssl->toInfoOn)
-                AddPacketInfo("ServerKeyExchange", &ssl->timeoutInfo, output,
-                                                             sendSz, ssl->heap);
-        #endif
-
-            ssl->buffers.outputBuffer.length += sendSz;
-            if (ssl->options.groupMessages)
-                ret = 0;
-            else
-                ret = SendBuffered(ssl);
-            ssl->options.serverState = SERVER_KEYEXCHANGE_COMPLETE;
-        }
-    #endif /*NO_PSK */
-
-    #if !defined(NO_DH) && !defined(NO_PSK)
-        if (ssl->specs.kea == dhe_psk_kea) {
-            byte    *output;
-            word32   length, idx = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ;
-            word32   hintLen;
-            int      sendSz;
-            DhKey    dhKey;
-
-            if (ssl->buffers.serverDH_P.buffer == NULL ||
-                ssl->buffers.serverDH_G.buffer == NULL)
-                return NO_DH_PARAMS;
-
-            if (ssl->buffers.serverDH_Pub.buffer == NULL) {
-                ssl->buffers.serverDH_Pub.buffer = (byte*)XMALLOC(
-                        ssl->buffers.serverDH_P.length + 2, ssl->ctx->heap,
-                        DYNAMIC_TYPE_DH);
-                if (ssl->buffers.serverDH_Pub.buffer == NULL)
-                    return MEMORY_E;
-            }
-
-            if (ssl->buffers.serverDH_Priv.buffer == NULL) {
-                ssl->buffers.serverDH_Priv.buffer = (byte*)XMALLOC(
-                        ssl->buffers.serverDH_P.length + 2, ssl->ctx->heap,
-                        DYNAMIC_TYPE_DH);
-                if (ssl->buffers.serverDH_Priv.buffer == NULL)
-                    return MEMORY_E;
-            }
-
-            wc_InitDhKey(&dhKey);
-            ret = wc_DhSetKey(&dhKey, ssl->buffers.serverDH_P.buffer,
-                                   ssl->buffers.serverDH_P.length,
-                                   ssl->buffers.serverDH_G.buffer,
-                                   ssl->buffers.serverDH_G.length);
-            if (ret == 0)
-                ret = wc_DhGenerateKeyPair(&dhKey, ssl->rng,
-                                         ssl->buffers.serverDH_Priv.buffer,
-                                        &ssl->buffers.serverDH_Priv.length,
-                                         ssl->buffers.serverDH_Pub.buffer,
-                                        &ssl->buffers.serverDH_Pub.length);
-            wc_FreeDhKey(&dhKey);
-            if (ret != 0)
-                return ret;
-
-            length = LENGTH_SZ * 3 + /* p, g, pub */
-                     ssl->buffers.serverDH_P.length +
-                     ssl->buffers.serverDH_G.length +
-                     ssl->buffers.serverDH_Pub.length;
-
-            /* include size part */
-            hintLen = (word32)XSTRLEN(ssl->arrays->server_hint);
-            if (hintLen > MAX_PSK_ID_LEN)
-                return SERVER_HINT_ERROR;
-            length += hintLen + HINT_LEN_SZ;
-            sendSz = length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ;
-
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls) {
-                sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-                idx    += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-            }
-        #endif
-
-            /* check for available size */
-            if ((ret = CheckAvailableSize(ssl, sendSz)) != 0)
-               return ret;
-
-            /* get ouput buffer */
-            output = ssl->buffers.outputBuffer.buffer +
-                     ssl->buffers.outputBuffer.length;
-
-            AddHeaders(output, length, server_key_exchange, ssl);
-
-            /* key data */
-            c16toa((word16)hintLen, output + idx);
-            idx += HINT_LEN_SZ;
-            XMEMCPY(output + idx, ssl->arrays->server_hint, hintLen);
-            idx += hintLen;
-
-            /* add p, g, pub */
-            c16toa((word16)ssl->buffers.serverDH_P.length, output + idx);
-            idx += LENGTH_SZ;
-            XMEMCPY(output + idx, ssl->buffers.serverDH_P.buffer,
-                                  ssl->buffers.serverDH_P.length);
-            idx += ssl->buffers.serverDH_P.length;
-
-            /*  g */
-            c16toa((word16)ssl->buffers.serverDH_G.length, output + idx);
-            idx += LENGTH_SZ;
-            XMEMCPY(output + idx, ssl->buffers.serverDH_G.buffer,
-                                  ssl->buffers.serverDH_G.length);
-            idx += ssl->buffers.serverDH_G.length;
-
-            /*  pub */
-            c16toa((word16)ssl->buffers.serverDH_Pub.length, output + idx);
-            idx += LENGTH_SZ;
-            XMEMCPY(output + idx, ssl->buffers.serverDH_Pub.buffer,
-                                  ssl->buffers.serverDH_Pub.length);
-            idx += ssl->buffers.serverDH_Pub.length;
-            (void)idx; /* suppress analyzer warning, and keep idx current */
-
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls)
-                if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0)
-                    return ret;
-        #endif
-
-            ret = HashOutput(ssl, output, sendSz, 0);
-
-            if (ret != 0)
-                return ret;
-
-        #ifdef WOLFSSL_CALLBACKS
-            if (ssl->hsInfoOn)
-                AddPacketName("ServerKeyExchange", &ssl->handShakeInfo);
-            if (ssl->toInfoOn)
-                AddPacketInfo("ServerKeyExchange", &ssl->timeoutInfo, output,
-                                                             sendSz, ssl->heap);
-        #endif
-
-            ssl->buffers.outputBuffer.length += sendSz;
-            if (ssl->options.groupMessages)
-                ret = 0;
-            else
-                ret = SendBuffered(ssl);
-            ssl->options.serverState = SERVER_KEYEXCHANGE_COMPLETE;
-        }
-    #endif /* !NO_DH && !NO_PSK */
-
-    #ifdef HAVE_ECC
-        if (ssl->specs.kea == ecc_diffie_hellman_kea)
-        {
-            byte    *output;
-            word32   length, idx = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ;
-            int      sendSz;
-            word32   sigSz;
-            word32   preSigSz, preSigIdx;
-        #ifndef NO_RSA
-            RsaKey   rsaKey;
-        #endif
-            ecc_key  dsaKey;
-        #ifdef WOLFSSL_SMALL_STACK
-            byte*    exportBuf = NULL;
-        #else
-            byte     exportBuf[MAX_EXPORT_ECC_SZ];
-        #endif
-            word32   expSz = MAX_EXPORT_ECC_SZ;
-
-        #ifndef NO_OLD_TLS
-            byte doMd5 = 0;
-            byte doSha = 0;
-        #endif
-        #ifndef NO_SHA256
-            byte doSha256 = 0;
-        #endif
-        #ifdef WOLFSSL_SHA384
-            byte doSha384 = 0;
-        #endif
-        #ifdef WOLFSSL_SHA512
-            byte doSha512 = 0;
-        #endif
-
-            if (ssl->specs.static_ecdh) {
-                WOLFSSL_MSG("Using Static ECDH, not sending ServerKeyExchagne");
-                return 0;
-            }
-
-            /* curve type, named curve, length(1) */
-            length = ENUM_LEN + CURVE_LEN + ENUM_LEN;
-            /* pub key size */
-            WOLFSSL_MSG("Using ephemeral ECDH");
-
-            /* need ephemeral key now, create it if missing */
-            if (ssl->eccTempKey == NULL) {
-                /* alloc/init on demand */
-                ssl->eccTempKey = (ecc_key*)XMALLOC(sizeof(ecc_key),
-                                              ssl->ctx->heap, DYNAMIC_TYPE_ECC);
-                if (ssl->eccTempKey == NULL) {
-                    WOLFSSL_MSG("EccTempKey Memory error");
-                    return MEMORY_E;
-                }
-                wc_ecc_init(ssl->eccTempKey);
-            }
-            if (ssl->eccTempKeyPresent == 0) {
-                if (wc_ecc_make_key(ssl->rng, ssl->eccTempKeySz,
-                                 ssl->eccTempKey) != 0) {
-                    return ECC_MAKEKEY_ERROR;
-                }
-                ssl->eccTempKeyPresent = 1;
-            }
-
-        #ifdef WOLFSSL_SMALL_STACK
-            exportBuf = (byte*)XMALLOC(MAX_EXPORT_ECC_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            if (exportBuf == NULL)
-                return MEMORY_E;
-        #endif
-
-            if (wc_ecc_export_x963(ssl->eccTempKey, exportBuf, &expSz) != 0)
-                ERROR_OUT(ECC_EXPORT_ERROR, done_a);
-            length += expSz;
-
-            preSigSz  = length;
-            preSigIdx = idx;
-
-        #ifndef NO_RSA
-            ret = wc_InitRsaKey(&rsaKey, ssl->heap);
-            if (ret != 0)
-                goto done_a;
-        #endif
-
-            wc_ecc_init(&dsaKey);
-
-            /* sig length */
-            length += LENGTH_SZ;
-
-            if (!ssl->buffers.key.buffer) {
-            #ifndef NO_RSA
-                wc_FreeRsaKey(&rsaKey);
-            #endif
-                wc_ecc_free(&dsaKey);
-                ERROR_OUT(NO_PRIVATE_KEY, done_a);
-            }
-
-        #ifndef NO_RSA
-            if (ssl->specs.sig_algo == rsa_sa_algo) {
-                /* rsa sig size */
-                word32 i = 0;
-                ret = wc_RsaPrivateKeyDecode(ssl->buffers.key.buffer, &i,
-                                          &rsaKey, ssl->buffers.key.length);
-                if (ret != 0)
-                    goto done_a;
-                sigSz = wc_RsaEncryptSize(&rsaKey);
-            } else
-        #endif
-
-            if (ssl->specs.sig_algo == ecc_dsa_sa_algo) {
-                /* ecdsa sig size */
-                word32 i = 0;
-                ret = wc_EccPrivateKeyDecode(ssl->buffers.key.buffer, &i,
-                                          &dsaKey, ssl->buffers.key.length);
-                if (ret != 0)
-                    goto done_a;
-                sigSz = wc_ecc_sig_size(&dsaKey);  /* worst case estimate */
-            }
-            else {
-            #ifndef NO_RSA
-                wc_FreeRsaKey(&rsaKey);
-            #endif
-                wc_ecc_free(&dsaKey);
-                ERROR_OUT(ALGO_ID_E, done_a);  /* unsupported type */
-            }
-            length += sigSz;
-
-            if (IsAtLeastTLSv1_2(ssl))
-                length += HASH_SIG_SIZE;
-
-            sendSz = length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ;
-
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls) {
-                sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-                idx    += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-                preSigIdx = idx;
-            }
-        #endif
-            /* check for available size */
-            if ((ret = CheckAvailableSize(ssl, sendSz)) != 0) {
-            #ifndef NO_RSA
-                wc_FreeRsaKey(&rsaKey);
-            #endif
-                wc_ecc_free(&dsaKey);
-                goto done_a;
-            }
-
-            /* get ouput buffer */
-            output = ssl->buffers.outputBuffer.buffer +
-                     ssl->buffers.outputBuffer.length;
-
-            /* record and message headers will be added below, when we're sure
-               of the sig length */
-
-            /* key exchange data */
-            output[idx++] = named_curve;
-            output[idx++] = 0x00;          /* leading zero */
-            output[idx++] = SetCurveId(wc_ecc_size(ssl->eccTempKey));
-            output[idx++] = (byte)expSz;
-            XMEMCPY(output + idx, exportBuf, expSz);
-            idx += expSz;
-            if (IsAtLeastTLSv1_2(ssl)) {
-                byte setHash = 0;
-
-                output[idx++] = ssl->suites->hashAlgo;
-                output[idx++] = ssl->suites->sigAlgo;
-
-                switch (ssl->suites->hashAlgo) {
-                    case sha512_mac:
-                        #ifdef WOLFSSL_SHA512
-                            doSha512 = 1;
-                            setHash  = 1;
-                        #endif
-                        break;
-
-                    case sha384_mac:
-                        #ifdef WOLFSSL_SHA384
-                            doSha384 = 1;
-                            setHash  = 1;
-                        #endif
-                        break;
-
-                    case sha256_mac:
-                        #ifndef NO_SHA256
-                            doSha256 = 1;
-                            setHash  = 1;
-                        #endif
-                        break;
-
-                    case sha_mac:
-                        #ifndef NO_OLD_TLS
-                            doSha = 1;
-                            setHash  = 1;
-                        #endif
-                        break;
-
-                    default:
-                        WOLFSSL_MSG("Bad hash sig algo");
-                        break;
-                }
-
-                if (setHash == 0) {
-                    #ifndef NO_RSA
-                        wc_FreeRsaKey(&rsaKey);
-                    #endif
-                    wc_ecc_free(&dsaKey);
-                    ERROR_OUT(ALGO_ID_E, done_a);
-                }
-            } else {
-                /* only using sha and md5 for rsa */
-                #ifndef NO_OLD_TLS
-                    doSha = 1;
-                    if (ssl->suites->sigAlgo == rsa_sa_algo) {
-                        doMd5 = 1;
-                    }
-                #else
-                    #ifndef NO_RSA
-                        wc_FreeRsaKey(&rsaKey);
-                    #endif
-                    wc_ecc_free(&dsaKey);
-                    ERROR_OUT(ALGO_ID_E, done_a);
-                #endif
-            }
-
-            /* Signtaure length will be written later, when we're sure what it
-               is */
-
-        #ifdef HAVE_FUZZER
-            if (ssl->fuzzerCb)
-                ssl->fuzzerCb(ssl, output + preSigIdx, preSigSz, FUZZ_SIGNATURE,
-                              ssl->fuzzerCtx);
-        #endif
-
-            /* do signature */
-            {
-        #ifndef NO_OLD_TLS
-            #ifdef WOLFSSL_SMALL_STACK
-                Md5*   md5  = NULL;
-                Sha*   sha  = NULL;
-            #else
-                Md5    md5[1];
-                Sha    sha[1];
-            #endif
-        #endif
-            #ifdef WOLFSSL_SMALL_STACK
-                byte*  hash = NULL;
-            #else
-                byte   hash[FINISHED_SZ];
-            #endif
-        #ifndef NO_SHA256
-            #ifdef WOLFSSL_SMALL_STACK
-                Sha256* sha256  = NULL;
-                byte*   hash256 = NULL;
-            #else
-                Sha256  sha256[1];
-                byte    hash256[SHA256_DIGEST_SIZE];
-            #endif
-        #endif
-        #ifdef WOLFSSL_SHA384
-            #ifdef WOLFSSL_SMALL_STACK
-                Sha384* sha384  = NULL;
-                byte*   hash384 = NULL;
-            #else
-                Sha384  sha384[1];
-                byte    hash384[SHA384_DIGEST_SIZE];
-            #endif
-        #endif
-        #ifdef WOLFSSL_SHA512
-            #ifdef WOLFSSL_SMALL_STACK
-                Sha512* sha512  = NULL;
-                byte*   hash512 = NULL;
-            #else
-                Sha512  sha512[1];
-                byte    hash512[SHA512_DIGEST_SIZE];
-            #endif
-        #endif
-
-            #ifdef WOLFSSL_SMALL_STACK
-                hash = (byte*)XMALLOC(FINISHED_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-                if (hash == NULL)
-                    ERROR_OUT(MEMORY_E, done_a);
-            #endif
-
-        #ifndef NO_OLD_TLS
-                /* md5 */
-            #ifdef WOLFSSL_SMALL_STACK
-                if (doMd5) {
-                    md5 = (Md5*)XMALLOC(sizeof(Md5), NULL,
-                                        DYNAMIC_TYPE_TMP_BUFFER);
-                    if (md5 == NULL)
-                        ERROR_OUT(MEMORY_E, done_a2);
-                }
-            #endif
-                if (doMd5) {
-                    wc_InitMd5(md5);
-                    wc_Md5Update(md5, ssl->arrays->clientRandom, RAN_LEN);
-                    wc_Md5Update(md5, ssl->arrays->serverRandom, RAN_LEN);
-                    wc_Md5Update(md5, output + preSigIdx, preSigSz);
-                    wc_Md5Final(md5, hash);
-                }
-                /* sha */
-            #ifdef WOLFSSL_SMALL_STACK
-                if (doSha) {
-                    sha = (Sha*)XMALLOC(sizeof(Sha), NULL,
-                                        DYNAMIC_TYPE_TMP_BUFFER);
-                    if (sha == NULL)
-                        ERROR_OUT(MEMORY_E, done_a2);
-                }
-            #endif
-                if (doSha) {
-                    ret = wc_InitSha(sha);
-                    if (ret != 0) goto done_a2;
-                    wc_ShaUpdate(sha, ssl->arrays->clientRandom, RAN_LEN);
-                    wc_ShaUpdate(sha, ssl->arrays->serverRandom, RAN_LEN);
-                    wc_ShaUpdate(sha, output + preSigIdx, preSigSz);
-                    wc_ShaFinal(sha, &hash[MD5_DIGEST_SIZE]);
-                }
-        #endif
-
-        #ifndef NO_SHA256
-            #ifdef WOLFSSL_SMALL_STACK
-                if (doSha256) {
-                    sha256 = (Sha256*)XMALLOC(sizeof(Sha256), NULL,
-                                              DYNAMIC_TYPE_TMP_BUFFER);
-                    hash256 = (byte*)XMALLOC(SHA256_DIGEST_SIZE, NULL,
-                                             DYNAMIC_TYPE_TMP_BUFFER);
-                    if (sha256 == NULL || hash256 == NULL)
-                        ERROR_OUT(MEMORY_E, done_a2);
-                }
-            #endif
-
-                if (doSha256) {
-                    if (!(ret = wc_InitSha256(sha256))
-                    &&  !(ret = wc_Sha256Update(sha256,
-                                            ssl->arrays->clientRandom, RAN_LEN))
-                    &&  !(ret = wc_Sha256Update(sha256,
-                                            ssl->arrays->serverRandom, RAN_LEN))
-                    &&  !(ret = wc_Sha256Update(sha256,
-                                            output + preSigIdx, preSigSz)))
-                        ret = wc_Sha256Final(sha256, hash256);
-
-                    if (ret != 0) goto done_a2;
-                }
-        #endif
-
-        #ifdef WOLFSSL_SHA384
-            #ifdef WOLFSSL_SMALL_STACK
-                if (doSha384) {
-                    sha384 = (Sha384*)XMALLOC(sizeof(Sha384), NULL,
-                                              DYNAMIC_TYPE_TMP_BUFFER);
-                    hash384 = (byte*)XMALLOC(SHA384_DIGEST_SIZE, NULL,
-                                             DYNAMIC_TYPE_TMP_BUFFER);
-                    if (sha384 == NULL || hash384 == NULL)
-                        ERROR_OUT(MEMORY_E, done_a2);
-                }
-            #endif
-
-                if (doSha384) {
-                    if (!(ret = wc_InitSha384(sha384))
-                    &&  !(ret = wc_Sha384Update(sha384,
-                                            ssl->arrays->clientRandom, RAN_LEN))
-                    &&  !(ret = wc_Sha384Update(sha384,
-                                            ssl->arrays->serverRandom, RAN_LEN))
-                    &&  !(ret = wc_Sha384Update(sha384,
-                                            output + preSigIdx, preSigSz)))
-                        ret = wc_Sha384Final(sha384, hash384);
-
-                    if (ret != 0) goto done_a2;
-                }
-        #endif
-
-        #ifdef WOLFSSL_SHA512
-            #ifdef WOLFSSL_SMALL_STACK
-                if (doSha512) {
-                    sha512 = (Sha512*)XMALLOC(sizeof(Sha512), NULL,
-                                              DYNAMIC_TYPE_TMP_BUFFER);
-                    hash512 = (byte*)XMALLOC(SHA512_DIGEST_SIZE, NULL,
-                                             DYNAMIC_TYPE_TMP_BUFFER);
-                    if (sha512 == NULL || hash512 == NULL)
-                        ERROR_OUT(MEMORY_E, done_a2);
-                }
-            #endif
-
-                if (doSha512) {
-                    if (!(ret = wc_InitSha512(sha512))
-                    &&  !(ret = wc_Sha512Update(sha512,
-                                            ssl->arrays->clientRandom, RAN_LEN))
-                    &&  !(ret = wc_Sha512Update(sha512,
-                                            ssl->arrays->serverRandom, RAN_LEN))
-                    &&  !(ret = wc_Sha512Update(sha512,
-                                            output + preSigIdx, preSigSz)))
-                        ret = wc_Sha512Final(sha512, hash512);
-
-                    if (ret != 0) goto done_a2;
-                }
-        #endif
-
-            #ifndef NO_RSA
-                if (ssl->suites->sigAlgo == rsa_sa_algo) {
-                    byte*  signBuffer = hash;
-                    word32 signSz     = FINISHED_SZ;
-                    byte   doUserRsa = 0;
-                #ifdef WOLFSSL_SMALL_STACK
-                    byte*  encodedSig = NULL;
-                #else
-                    byte   encodedSig[MAX_ENCODED_SIG_SZ];
-                #endif
-
-                #ifdef HAVE_PK_CALLBACKS
-                    if (ssl->ctx->RsaSignCb)
-                        doUserRsa = 1;
-                #endif
-
-                #ifdef WOLFSSL_SMALL_STACK
-                    encodedSig = (byte*)XMALLOC(MAX_ENCODED_SIG_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-                    if (encodedSig == NULL)
-                        ERROR_OUT(MEMORY_E, done_a2);
-                #endif
-
-                    if (IsAtLeastTLSv1_2(ssl)) {
-                        byte* digest   = &hash[MD5_DIGEST_SIZE];
-                        int   typeH    = SHAh;
-                        int   digestSz = SHA_DIGEST_SIZE;
-
-                        if (ssl->suites->hashAlgo == sha256_mac) {
-                        #ifndef NO_SHA256
-                            digest   = hash256;
-                            typeH    = SHA256h;
-                            digestSz = SHA256_DIGEST_SIZE;
-                        #endif
-                        }
-                        else if (ssl->suites->hashAlgo == sha384_mac) {
-                        #ifdef WOLFSSL_SHA384
-                            digest   = hash384;
-                            typeH    = SHA384h;
-                            digestSz = SHA384_DIGEST_SIZE;
-                        #endif
-                        }
-                        else if (ssl->suites->hashAlgo == sha512_mac) {
-                        #ifdef WOLFSSL_SHA512
-                            digest   = hash512;
-                            typeH    = SHA512h;
-                            digestSz = SHA512_DIGEST_SIZE;
-                        #endif
-                        }
-
-                        if (digest == NULL) {
-                            #ifndef NO_RSA
-                                wc_FreeRsaKey(&rsaKey);
-                            #endif
-                            wc_ecc_free(&dsaKey);
-                            ERROR_OUT(ALGO_ID_E, done_a2);
-                        }
-                        signSz = wc_EncodeSignature(encodedSig, digest,
-                                                    digestSz, typeH);
-                        signBuffer = encodedSig;
-                    }
-                    /* write sig size here */
-                    c16toa((word16)sigSz, output + idx);
-                    idx += LENGTH_SZ;
-
-                    if (doUserRsa) {
-                    #ifdef HAVE_PK_CALLBACKS
-                        word32 ioLen = sigSz;
-                        ret = ssl->ctx->RsaSignCb(ssl, signBuffer, signSz,
-                                            output + idx, &ioLen,
-                                            ssl->buffers.key.buffer,
-                                            ssl->buffers.key.length,
-                                            ssl->RsaSignCtx);
-                    #endif /*HAVE_PK_CALLBACKS */
-                    }
-                    else
-                        ret = wc_RsaSSL_Sign(signBuffer, signSz, output + idx,
-                                          sigSz, &rsaKey, ssl->rng);
-
-                    wc_FreeRsaKey(&rsaKey);
-                    wc_ecc_free(&dsaKey);
-
-                #ifdef WOLFSSL_SMALL_STACK
-                    XFREE(encodedSig, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                #endif
-
-                    if (ret < 0)
-                        goto done_a2;
-                } else
-            #endif
-
-                if (ssl->suites->sigAlgo == ecc_dsa_sa_algo) {
-                #ifndef NO_OLD_TLS
-                    byte* digest = &hash[MD5_DIGEST_SIZE];
-                    word32 digestSz = SHA_DIGEST_SIZE;
-                #else
-                    byte* digest = hash256;
-                    word32 digestSz = SHA256_DIGEST_SIZE;
-                #endif
-                    word32 sz = sigSz;
-                    byte   doUserEcc = 0;
-
-                #if defined(HAVE_PK_CALLBACKS) && defined(HAVE_ECC)
-                    if (ssl->ctx->EccSignCb)
-                        doUserEcc = 1;
-                #endif
-
-                    if (IsAtLeastTLSv1_2(ssl)) {
-                        if (ssl->suites->hashAlgo == sha_mac) {
-                        #ifndef NO_SHA
-                            digest   = &hash[MD5_DIGEST_SIZE];
-                            digestSz = SHA_DIGEST_SIZE;
-                        #endif
-                        }
-                        else if (ssl->suites->hashAlgo == sha256_mac) {
-                        #ifndef NO_SHA256
-                            digest   = hash256;
-                            digestSz = SHA256_DIGEST_SIZE;
-                        #endif
-                        }
-                        else if (ssl->suites->hashAlgo == sha384_mac) {
-                        #ifdef WOLFSSL_SHA384
-                            digest   = hash384;
-                            digestSz = SHA384_DIGEST_SIZE;
-                        #endif
-                        }
-                        else if (ssl->suites->hashAlgo == sha512_mac) {
-                        #ifdef WOLFSSL_SHA512
-                            digest   = hash512;
-                            digestSz = SHA512_DIGEST_SIZE;
-                        #endif
-                        }
-                    }
-
-                    if (doUserEcc) {
-                    #if defined(HAVE_PK_CALLBACKS) && defined(HAVE_ECC)
-                        ret = ssl->ctx->EccSignCb(ssl, digest, digestSz,
-                                                  output + LENGTH_SZ + idx, &sz,
-                                                  ssl->buffers.key.buffer,
-                                                  ssl->buffers.key.length,
-                                                  ssl->EccSignCtx);
-                    #endif
-                    }
-                    else {
-                        ret = wc_ecc_sign_hash(digest, digestSz,
-                              output + LENGTH_SZ + idx, &sz, ssl->rng, &dsaKey);
-                    }
-                #ifndef NO_RSA
-                    wc_FreeRsaKey(&rsaKey);
-                #endif
-                    wc_ecc_free(&dsaKey);
-
-                    if (ret < 0)
-                        goto done_a2;
-
-                    /* Now that we know the real sig size, write it. */
-                    c16toa((word16)sz, output + idx);
-
-                    /* And adjust length and sendSz from estimates */
-                    length += sz - sigSz;
-                    sendSz += sz - sigSz;
-                }
-
-            done_a2:
-        #ifdef WOLFSSL_SMALL_STACK
-            #ifndef NO_OLD_TLS
-                XFREE(md5,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                XFREE(sha,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #endif
-                XFREE(hash,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #ifndef NO_SHA256
-                XFREE(sha256,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                XFREE(hash256, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #endif
-            #ifdef WOLFSSL_SHA384
-                XFREE(sha384,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                XFREE(hash384, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #endif
-            #ifdef WOLFSSL_SHA512
-                XFREE(sha512,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                XFREE(hash512, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #endif
-        #endif
-
-                if (ret < 0)
-                    goto done_a;
-            }
-
-            AddHeaders(output, length, server_key_exchange, ssl);
-
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls)
-                if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0)
-                    goto done_a;
-        #endif
-
-            if ((ret = HashOutput(ssl, output, sendSz, 0)) != 0)
-                goto done_a;
-
-        #ifdef WOLFSSL_CALLBACKS
-            if (ssl->hsInfoOn)
-                AddPacketName("ServerKeyExchange", &ssl->handShakeInfo);
-            if (ssl->toInfoOn)
-                AddPacketInfo("ServerKeyExchange", &ssl->timeoutInfo,
-                              output, sendSz, ssl->heap);
-        #endif
-
-            ssl->buffers.outputBuffer.length += sendSz;
-            if (ssl->options.groupMessages)
-                ret = 0;
-            else
-                ret = SendBuffered(ssl);
-            ssl->options.serverState = SERVER_KEYEXCHANGE_COMPLETE;
-
-        done_a:
-        #ifdef WOLFSSL_SMALL_STACK
-            XFREE(exportBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        #endif
-
-            return ret;
-        }
-    #endif /* HAVE_ECC */
-
-    #if !defined(NO_DH) && !defined(NO_RSA)
-        if (ssl->specs.kea == diffie_hellman_kea) {
-            byte    *output;
-            word32   length = 0, idx = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ;
-            int      sendSz;
-            word32   sigSz = 0, i = 0;
-            word32   preSigSz = 0, preSigIdx = 0;
-            RsaKey   rsaKey;
-            DhKey    dhKey;
-
-            if (ssl->buffers.serverDH_P.buffer == NULL ||
-                ssl->buffers.serverDH_G.buffer == NULL)
-                return NO_DH_PARAMS;
-
-            if (ssl->buffers.serverDH_Pub.buffer == NULL) {
-                ssl->buffers.serverDH_Pub.buffer = (byte*)XMALLOC(
-                        ssl->buffers.serverDH_P.length + 2, ssl->ctx->heap,
-                        DYNAMIC_TYPE_DH);
-                if (ssl->buffers.serverDH_Pub.buffer == NULL)
-                    return MEMORY_E;
-            }
-
-            if (ssl->buffers.serverDH_Priv.buffer == NULL) {
-                ssl->buffers.serverDH_Priv.buffer = (byte*)XMALLOC(
-                        ssl->buffers.serverDH_P.length + 2, ssl->ctx->heap,
-                        DYNAMIC_TYPE_DH);
-                if (ssl->buffers.serverDH_Priv.buffer == NULL)
-                    return MEMORY_E;
-            }
-
-            wc_InitDhKey(&dhKey);
-            ret = wc_DhSetKey(&dhKey, ssl->buffers.serverDH_P.buffer,
-                                   ssl->buffers.serverDH_P.length,
-                                   ssl->buffers.serverDH_G.buffer,
-                                   ssl->buffers.serverDH_G.length);
-            if (ret == 0)
-                ret = wc_DhGenerateKeyPair(&dhKey, ssl->rng,
-                                         ssl->buffers.serverDH_Priv.buffer,
-                                        &ssl->buffers.serverDH_Priv.length,
-                                         ssl->buffers.serverDH_Pub.buffer,
-                                        &ssl->buffers.serverDH_Pub.length);
-            wc_FreeDhKey(&dhKey);
-
-            if (ret != 0) return ret;
-
-            length = LENGTH_SZ * 3;  /* p, g, pub */
-            length += ssl->buffers.serverDH_P.length +
-                      ssl->buffers.serverDH_G.length +
-                      ssl->buffers.serverDH_Pub.length;
-
-            preSigIdx = idx;
-            preSigSz  = length;
-
-            if (!ssl->options.usingAnon_cipher) {
-                ret = wc_InitRsaKey(&rsaKey, ssl->heap);
-                if (ret != 0) return ret;
-
-                /* sig length */
-                length += LENGTH_SZ;
-
-                if (!ssl->buffers.key.buffer)
-                    return NO_PRIVATE_KEY;
-
-                ret = wc_RsaPrivateKeyDecode(ssl->buffers.key.buffer, &i, &rsaKey,
-                                          ssl->buffers.key.length);
-                if (ret == 0) {
-                    sigSz = wc_RsaEncryptSize(&rsaKey);
-                    length += sigSz;
-                }
-                else {
-                    wc_FreeRsaKey(&rsaKey);
-                    return ret;
-                }
-
-                if (IsAtLeastTLSv1_2(ssl))
-                    length += HASH_SIG_SIZE;
-            }
-
-            sendSz = length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ;
-
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls) {
-                sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-                idx    += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-                preSigIdx = idx;
-            }
-        #endif
-
-            /* check for available size */
-            if ((ret = CheckAvailableSize(ssl, sendSz)) != 0) {
-                if (!ssl->options.usingAnon_cipher)
-                    wc_FreeRsaKey(&rsaKey);
-                return ret;
-            }
-
-            /* get ouput buffer */
-            output = ssl->buffers.outputBuffer.buffer +
-                     ssl->buffers.outputBuffer.length;
-
-            AddHeaders(output, length, server_key_exchange, ssl);
-
-            /* add p, g, pub */
-            c16toa((word16)ssl->buffers.serverDH_P.length, output + idx);
-            idx += LENGTH_SZ;
-            XMEMCPY(output + idx, ssl->buffers.serverDH_P.buffer,
-                                  ssl->buffers.serverDH_P.length);
-            idx += ssl->buffers.serverDH_P.length;
-
-            /*  g */
-            c16toa((word16)ssl->buffers.serverDH_G.length, output + idx);
-            idx += LENGTH_SZ;
-            XMEMCPY(output + idx, ssl->buffers.serverDH_G.buffer,
-                                  ssl->buffers.serverDH_G.length);
-            idx += ssl->buffers.serverDH_G.length;
-
-            /*  pub */
-            c16toa((word16)ssl->buffers.serverDH_Pub.length, output + idx);
-            idx += LENGTH_SZ;
-            XMEMCPY(output + idx, ssl->buffers.serverDH_Pub.buffer,
-                                  ssl->buffers.serverDH_Pub.length);
-            idx += ssl->buffers.serverDH_Pub.length;
-
-        #ifdef HAVE_FUZZER
-            if (ssl->fuzzerCb)
-                ssl->fuzzerCb(ssl, output + preSigIdx, preSigSz, FUZZ_SIGNATURE,
-                        ssl->fuzzerCtx);
-        #endif
-
-            /* Add signature */
-            if (!ssl->options.usingAnon_cipher) {
-        #ifndef NO_OLD_TLS
-            #ifdef WOLFSSL_SMALL_STACK
-                Md5*   md5  = NULL;
-                Sha*   sha  = NULL;
-            #else
-                Md5    md5[1];
-                Sha    sha[1];
-            #endif
-        #endif
-            #ifdef WOLFSSL_SMALL_STACK
-                byte*  hash = NULL;
-            #else
-                byte   hash[FINISHED_SZ];
-            #endif
-        #ifndef NO_SHA256
-            #ifdef WOLFSSL_SMALL_STACK
-                Sha256* sha256  = NULL;
-                byte*   hash256 = NULL;
-            #else
-                Sha256  sha256[1];
-                byte    hash256[SHA256_DIGEST_SIZE];
-            #endif
-        #endif
-        #ifdef WOLFSSL_SHA384
-            #ifdef WOLFSSL_SMALL_STACK
-                Sha384* sha384  = NULL;
-                byte*   hash384 = NULL;
-            #else
-                Sha384  sha384[1];
-                byte    hash384[SHA384_DIGEST_SIZE];
-            #endif
-        #endif
-        #ifdef WOLFSSL_SHA512
-            #ifdef WOLFSSL_SMALL_STACK
-                Sha512* sha512  = NULL;
-                byte*   hash512 = NULL;
-            #else
-                Sha512  sha512[1];
-                byte    hash512[SHA512_DIGEST_SIZE];
-            #endif
-        #endif
-
-        #ifndef NO_OLD_TLS
-            byte doMd5 = 0;
-            byte doSha = 0;
-        #endif
-        #ifndef NO_SHA256
-            byte doSha256 = 0;
-        #endif
-        #ifdef WOLFSSL_SHA384
-            byte doSha384 = 0;
-        #endif
-        #ifdef WOLFSSL_SHA512
-            byte doSha512 = 0;
-        #endif
-
-            /* Add hash/signature algo ID */
-            if (IsAtLeastTLSv1_2(ssl)) {
-                byte setHash = 0;
-
-                output[idx++] = ssl->suites->hashAlgo;
-                output[idx++] = ssl->suites->sigAlgo;
-
-                switch (ssl->suites->hashAlgo) {
-                    case sha512_mac:
-                        #ifdef WOLFSSL_SHA512
-                            doSha512 = 1;
-                            setHash  = 1;
-                        #endif
-                        break;
-
-                    case sha384_mac:
-                        #ifdef WOLFSSL_SHA384
-                            doSha384 = 1;
-                            setHash  = 1;
-                        #endif
-                        break;
-
-                    case sha256_mac:
-                        #ifndef NO_SHA256
-                            doSha256 = 1;
-                            setHash  = 1;
-                        #endif
-                        break;
-
-                    case sha_mac:
-                        #ifndef NO_OLD_TLS
-                            doSha = 1;
-                            setHash  = 1;
-                        #endif
-                        break;
-
-                    default:
-                        WOLFSSL_MSG("Bad hash sig algo");
-                        break;
-                }
-
-                if (setHash == 0) {
-                    wc_FreeRsaKey(&rsaKey);
-                    return ALGO_ID_E;
-                }
-            } else {
-                /* only using sha and md5 for rsa */
-                #ifndef NO_OLD_TLS
-                    doSha = 1;
-                    if (ssl->suites->sigAlgo == rsa_sa_algo) {
-                        doMd5 = 1;
-                    }
-                #else
-                    wc_FreeRsaKey(&rsaKey);
-                    return ALGO_ID_E;
-                #endif
-            }
-
-            /* signature size */
-            c16toa((word16)sigSz, output + idx);
-            idx += LENGTH_SZ;
-
-            /* do signature */
-            #ifdef WOLFSSL_SMALL_STACK
-                hash = (byte*)XMALLOC(FINISHED_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-                if (hash == NULL)
-                    return MEMORY_E; /* No heap commitment before this point,
-                                        from now on, the resources are freed
-                                        at done_b. */
-            #endif
-
-        #ifndef NO_OLD_TLS
-                /* md5 */
-            #ifdef WOLFSSL_SMALL_STACK
-                if (doMd5) {
-                    md5 = (Md5*)XMALLOC(sizeof(Md5), NULL,
-                                        DYNAMIC_TYPE_TMP_BUFFER);
-                    if (md5 == NULL)
-                        ERROR_OUT(MEMORY_E, done_b);
-                }
-            #endif
-                if (doMd5) {
-                    wc_InitMd5(md5);
-                    wc_Md5Update(md5, ssl->arrays->clientRandom, RAN_LEN);
-                    wc_Md5Update(md5, ssl->arrays->serverRandom, RAN_LEN);
-                    wc_Md5Update(md5, output + preSigIdx, preSigSz);
-                    wc_Md5Final(md5, hash);
-                }
-
-                /* sha */
-            #ifdef WOLFSSL_SMALL_STACK
-                if (doSha) {
-                    sha = (Sha*)XMALLOC(sizeof(Sha), NULL,
-                                        DYNAMIC_TYPE_TMP_BUFFER);
-                    if (sha == NULL)
-                        ERROR_OUT(MEMORY_E, done_b);
-                }
-            #endif
-
-                if (doSha) {
-                    if ((ret = wc_InitSha(sha)) != 0)
-                        goto done_b;
-                    wc_ShaUpdate(sha, ssl->arrays->clientRandom, RAN_LEN);
-                    wc_ShaUpdate(sha, ssl->arrays->serverRandom, RAN_LEN);
-                    wc_ShaUpdate(sha, output + preSigIdx, preSigSz);
-                    wc_ShaFinal(sha, &hash[MD5_DIGEST_SIZE]);
-                }
-        #endif
-
-        #ifndef NO_SHA256
-            #ifdef WOLFSSL_SMALL_STACK
-                if (doSha256) {
-                    sha256 = (Sha256*)XMALLOC(sizeof(Sha256), NULL,
-                                              DYNAMIC_TYPE_TMP_BUFFER);
-                    hash256 = (byte*)XMALLOC(SHA256_DIGEST_SIZE, NULL,
-                                             DYNAMIC_TYPE_TMP_BUFFER);
-                    if (sha256 == NULL || hash256 == NULL)
-                        ERROR_OUT(MEMORY_E, done_b);
-                }
-            #endif
-
-                if (doSha256) {
-                    if (!(ret = wc_InitSha256(sha256))
-                    &&  !(ret = wc_Sha256Update(sha256,
-                                            ssl->arrays->clientRandom, RAN_LEN))
-                    &&  !(ret = wc_Sha256Update(sha256,
-                                            ssl->arrays->serverRandom, RAN_LEN))
-                    &&  !(ret = wc_Sha256Update(sha256,
-                                            output + preSigIdx, preSigSz)))
-                        ret = wc_Sha256Final(sha256, hash256);
-
-                    if (ret != 0) goto done_b;
-                }
-            #endif
-
-        #ifdef WOLFSSL_SHA384
-            #ifdef WOLFSSL_SMALL_STACK
-                if (doSha384) {
-                    sha384 = (Sha384*)XMALLOC(sizeof(Sha384), NULL,
-                                              DYNAMIC_TYPE_TMP_BUFFER);
-                    hash384 = (byte*)XMALLOC(SHA384_DIGEST_SIZE, NULL,
-                                             DYNAMIC_TYPE_TMP_BUFFER);
-                    if (sha384 == NULL || hash384 == NULL)
-                        ERROR_OUT(MEMORY_E, done_b);
-                }
-            #endif
-
-                if (doSha384) {
-                    if (!(ret = wc_InitSha384(sha384))
-                    &&  !(ret = wc_Sha384Update(sha384,
-                                            ssl->arrays->clientRandom, RAN_LEN))
-                    &&  !(ret = wc_Sha384Update(sha384,
-                                            ssl->arrays->serverRandom, RAN_LEN))
-                    &&  !(ret = wc_Sha384Update(sha384,
-                                            output + preSigIdx, preSigSz)))
-                        ret = wc_Sha384Final(sha384, hash384);
-
-                    if (ret != 0) goto done_b;
-                }
-        #endif
-
-        #ifdef WOLFSSL_SHA512
-            #ifdef WOLFSSL_SMALL_STACK
-                if (doSha512) {
-                    sha512 = (Sha512*)XMALLOC(sizeof(Sha512), NULL,
-                                              DYNAMIC_TYPE_TMP_BUFFER);
-                    hash512 = (byte*)XMALLOC(SHA512_DIGEST_SIZE, NULL,
-                                             DYNAMIC_TYPE_TMP_BUFFER);
-                    if (sha512 == NULL || hash512 == NULL)
-                        ERROR_OUT(MEMORY_E, done_b);
-                }
-            #endif
-
-                if (doSha512) {
-                    if (!(ret = wc_InitSha512(sha512))
-                    &&  !(ret = wc_Sha512Update(sha512,
-                                            ssl->arrays->clientRandom, RAN_LEN))
-                    &&  !(ret = wc_Sha512Update(sha512,
-                                            ssl->arrays->serverRandom, RAN_LEN))
-                    &&  !(ret = wc_Sha512Update(sha512,
-                                            output + preSigIdx, preSigSz)))
-                        ret = wc_Sha512Final(sha512, hash512);
-
-                    if (ret != 0) goto done_b;
-                }
-        #endif
-
-            #ifndef NO_RSA
-                if (ssl->suites->sigAlgo == rsa_sa_algo) {
-                    byte*  signBuffer = hash;
-                    word32 signSz     = FINISHED_SZ;
-                #ifdef WOLFSSL_SMALL_STACK
-                    byte*  encodedSig = NULL;
-                #else
-                    byte   encodedSig[MAX_ENCODED_SIG_SZ];
-                #endif
-                    byte   doUserRsa = 0;
-
-                #ifdef HAVE_PK_CALLBACKS
-                    if (ssl->ctx->RsaSignCb)
-                        doUserRsa = 1;
-                #endif
-
-                #ifdef WOLFSSL_SMALL_STACK
-                    encodedSig = (byte*)XMALLOC(MAX_ENCODED_SIG_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-                    if (encodedSig == NULL)
-                        ERROR_OUT(MEMORY_E, done_b);
-                #endif
-
-                    if (IsAtLeastTLSv1_2(ssl)) {
-                        byte* digest   = &hash[MD5_DIGEST_SIZE];
-                        int   typeH    = SHAh;
-                        int   digestSz = SHA_DIGEST_SIZE;
-
-                        if (ssl->suites->hashAlgo == sha256_mac) {
-                        #ifndef NO_SHA256
-                            digest   = hash256;
-                            typeH    = SHA256h;
-                            digestSz = SHA256_DIGEST_SIZE;
-                        #endif
-                        }
-                        else if (ssl->suites->hashAlgo == sha384_mac) {
-                        #ifdef WOLFSSL_SHA384
-                            digest   = hash384;
-                            typeH    = SHA384h;
-                            digestSz = SHA384_DIGEST_SIZE;
-                        #endif
-                        }
-                        else if (ssl->suites->hashAlgo == sha512_mac) {
-                        #ifdef WOLFSSL_SHA512
-                            digest   = hash512;
-                            typeH    = SHA512h;
-                            digestSz = SHA512_DIGEST_SIZE;
-                        #endif
-                        }
-
-                        if (digest == NULL) {
-                            ret = ALGO_ID_E;
-                        } else {
-                            signSz = wc_EncodeSignature(encodedSig, digest,
-                                                        digestSz, typeH);
-                            signBuffer = encodedSig;
-                        }
-                    }
-                    if (doUserRsa && ret == 0) {
-                    #ifdef HAVE_PK_CALLBACKS
-                        word32 ioLen = sigSz;
-                        ret = ssl->ctx->RsaSignCb(ssl, signBuffer, signSz,
-                                                  output + idx, &ioLen,
-                                                  ssl->buffers.key.buffer,
-                                                  ssl->buffers.key.length,
-                                                  ssl->RsaSignCtx);
-                    #endif
-                    } else if (ret == 0) {
-                        ret = wc_RsaSSL_Sign(signBuffer, signSz, output + idx,
-                                          sigSz, &rsaKey, ssl->rng);
-                    }
-
-                    wc_FreeRsaKey(&rsaKey);
-
-                #ifdef WOLFSSL_SMALL_STACK
-                    XFREE(encodedSig, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                #endif
-                }
-            #endif
-
-            done_b:
-        #ifdef WOLFSSL_SMALL_STACK
-            #ifndef NO_OLD_TLS
-                XFREE(md5,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                XFREE(sha,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #endif
-                XFREE(hash,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #ifndef NO_SHA256
-                XFREE(sha256,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                XFREE(hash256, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #endif
-            #ifdef WOLFSSL_SHA384
-                XFREE(sha384,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                XFREE(hash384, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #endif
-            #ifdef WOLFSSL_SHA512
-                XFREE(sha512,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                XFREE(hash512, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #endif
-        #endif
-
-                if (ret < 0) return ret;
-            }
-
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls)
-                if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0)
-                    return ret;
-        #endif
-
-            if ((ret = HashOutput(ssl, output, sendSz, 0)) != 0)
-                return ret;
-
-        #ifdef WOLFSSL_CALLBACKS
-            if (ssl->hsInfoOn)
-                AddPacketName("ServerKeyExchange", &ssl->handShakeInfo);
-            if (ssl->toInfoOn)
-                AddPacketInfo("ServerKeyExchange", &ssl->timeoutInfo,
-                              output, sendSz, ssl->heap);
-        #endif
-
-            ssl->buffers.outputBuffer.length += sendSz;
-            if (ssl->options.groupMessages)
-                ret = 0;
-            else
-                ret = SendBuffered(ssl);
-            ssl->options.serverState = SERVER_KEYEXCHANGE_COMPLETE;
-        }
-    #endif /* NO_DH */
-
-        return ret;
-        #undef ERROR_OUT
-    }
-
-
-    /* Make sure server cert/key are valid for this suite, true on success */
-    static int VerifyServerSuite(WOLFSSL* ssl, word16 idx)
-    {
-        int  haveRSA = !ssl->options.haveStaticECC;
-        int  havePSK = 0;
-        byte first;
-        byte second;
-
-        WOLFSSL_ENTER("VerifyServerSuite");
-
-        if (ssl->suites == NULL) {
-            WOLFSSL_MSG("Suites pointer error");
-            return 0;
-        }
-
-        first   = ssl->suites->suites[idx];
-        second  = ssl->suites->suites[idx+1];
-
-        #ifndef NO_PSK
-            havePSK = ssl->options.havePSK;
-        #endif
-
-        if (ssl->options.haveNTRU)
-            haveRSA = 0;
-
-        if (CipherRequires(first, second, REQUIRES_RSA)) {
-            WOLFSSL_MSG("Requires RSA");
-            if (haveRSA == 0) {
-                WOLFSSL_MSG("Don't have RSA");
-                return 0;
-            }
-        }
-
-        if (CipherRequires(first, second, REQUIRES_DHE)) {
-            WOLFSSL_MSG("Requires DHE");
-            if (ssl->options.haveDH == 0) {
-                WOLFSSL_MSG("Don't have DHE");
-                return 0;
-            }
-        }
-
-        if (CipherRequires(first, second, REQUIRES_ECC_DSA)) {
-            WOLFSSL_MSG("Requires ECCDSA");
-            if (ssl->options.haveECDSAsig == 0) {
-                WOLFSSL_MSG("Don't have ECCDSA");
-                return 0;
-            }
-        }
-
-        if (CipherRequires(first, second, REQUIRES_ECC_STATIC)) {
-            WOLFSSL_MSG("Requires static ECC");
-            if (ssl->options.haveStaticECC == 0) {
-                WOLFSSL_MSG("Don't have static ECC");
-                return 0;
-            }
-        }
-
-        if (CipherRequires(first, second, REQUIRES_PSK)) {
-            WOLFSSL_MSG("Requires PSK");
-            if (havePSK == 0) {
-                WOLFSSL_MSG("Don't have PSK");
-                return 0;
-            }
-        }
-
-        if (CipherRequires(first, second, REQUIRES_NTRU)) {
-            WOLFSSL_MSG("Requires NTRU");
-            if (ssl->options.haveNTRU == 0) {
-                WOLFSSL_MSG("Don't have NTRU");
-                return 0;
-            }
-        }
-
-        if (CipherRequires(first, second, REQUIRES_RSA_SIG)) {
-            WOLFSSL_MSG("Requires RSA Signature");
-            if (ssl->options.side == WOLFSSL_SERVER_END &&
-                                           ssl->options.haveECDSAsig == 1) {
-                WOLFSSL_MSG("Don't have RSA Signature");
-                return 0;
-            }
-        }
-
-#ifdef HAVE_SUPPORTED_CURVES
-        if (!TLSX_ValidateEllipticCurves(ssl, first, second)) {
-            WOLFSSL_MSG("Don't have matching curves");
-                return 0;
-        }
-#endif
-
-        /* ECCDHE is always supported if ECC on */
-
-        return 1;
-    }
-
-
-    static int MatchSuite(WOLFSSL* ssl, Suites* peerSuites)
-    {
-        word16 i, j;
-
-        WOLFSSL_ENTER("MatchSuite");
-
-        /* & 0x1 equivalent % 2 */
-        if (peerSuites->suiteSz == 0 || peerSuites->suiteSz & 0x1)
-            return MATCH_SUITE_ERROR;
-
-        if (ssl->suites == NULL)
-            return SUITES_ERROR;
-        /* start with best, if a match we are good */
-        for (i = 0; i < ssl->suites->suiteSz; i += 2)
-            for (j = 0; j < peerSuites->suiteSz; j += 2)
-                if (ssl->suites->suites[i]   == peerSuites->suites[j] &&
-                    ssl->suites->suites[i+1] == peerSuites->suites[j+1] ) {
-
-                    if (VerifyServerSuite(ssl, i)) {
-                        int result;
-                        WOLFSSL_MSG("Verified suite validity");
-                        ssl->options.cipherSuite0 = ssl->suites->suites[i];
-                        ssl->options.cipherSuite  = ssl->suites->suites[i+1];
-                        result = SetCipherSpecs(ssl);
-                        if (result == 0)
-                            PickHashSigAlgo(ssl, peerSuites->hashSigAlgo,
-                                                 peerSuites->hashSigAlgoSz);
-                        return result;
-                    }
-                    else {
-                        WOLFSSL_MSG("Could not verify suite validity, continue");
-                    }
-                }
-
-        return MATCH_SUITE_ERROR;
-    }
-
-
-#ifdef OLD_HELLO_ALLOWED
-
-    /* process old style client hello, deprecate? */
-    int ProcessOldClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
-                              word32 inSz, word16 sz)
-    {
-        word32          idx = *inOutIdx;
-        word16          sessionSz;
-        word16          randomSz;
-        word16          i, j;
-        ProtocolVersion pv;
-        Suites          clSuites;
-
-        (void)inSz;
-        WOLFSSL_MSG("Got old format client hello");
-#ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn)
-            AddPacketName("ClientHello", &ssl->handShakeInfo);
-        if (ssl->toInfoOn)
-            AddLateName("ClientHello", &ssl->timeoutInfo);
-#endif
-
-        /* manually hash input since different format */
-#ifndef NO_OLD_TLS
-#ifndef NO_MD5
-        wc_Md5Update(&ssl->hsHashes->hashMd5, input + idx, sz);
-#endif
-#ifndef NO_SHA
-        wc_ShaUpdate(&ssl->hsHashes->hashSha, input + idx, sz);
-#endif
-#endif
-#ifndef NO_SHA256
-        if (IsAtLeastTLSv1_2(ssl)) {
-            int shaRet = wc_Sha256Update(&ssl->hsHashes->hashSha256,
-                                         input + idx, sz);
-            if (shaRet != 0)
-                return shaRet;
-        }
-#endif
-
-        /* does this value mean client_hello? */
-        idx++;
-
-        /* version */
-        pv.major = input[idx++];
-        pv.minor = input[idx++];
-        ssl->chVersion = pv;  /* store */
-
-        if (ssl->version.minor > pv.minor) {
-            byte haveRSA = 0;
-            byte havePSK = 0;
-            if (!ssl->options.downgrade) {
-                WOLFSSL_MSG("Client trying to connect with lesser version");
-                return VERSION_ERROR;
-            }
-            if (pv.minor < ssl->options.minDowngrade) {
-                WOLFSSL_MSG("    version below minimum allowed, fatal error");
-                return VERSION_ERROR;
-            }
-            if (pv.minor == SSLv3_MINOR) {
-                /* turn off tls */
-                WOLFSSL_MSG("    downgrading to SSLv3");
-                ssl->options.tls    = 0;
-                ssl->options.tls1_1 = 0;
-                ssl->version.minor  = SSLv3_MINOR;
-            }
-            else if (pv.minor == TLSv1_MINOR) {
-                WOLFSSL_MSG("    downgrading to TLSv1");
-                /* turn off tls 1.1+ */
-                ssl->options.tls1_1 = 0;
-                ssl->version.minor  = TLSv1_MINOR;
-            }
-            else if (pv.minor == TLSv1_1_MINOR) {
-                WOLFSSL_MSG("    downgrading to TLSv1.1");
-                ssl->version.minor  = TLSv1_1_MINOR;
-            }
-#ifndef NO_RSA
-            haveRSA = 1;
-#endif
-#ifndef NO_PSK
-            havePSK = ssl->options.havePSK;
-#endif
-
-            InitSuites(ssl->suites, ssl->version, haveRSA, havePSK,
-                       ssl->options.haveDH, ssl->options.haveNTRU,
-                       ssl->options.haveECDSAsig, ssl->options.haveStaticECC,
-                       ssl->options.side);
-        }
-
-        /* suite size */
-        ato16(&input[idx], &clSuites.suiteSz);
-        idx += 2;
-
-        if (clSuites.suiteSz > MAX_SUITE_SZ)
-            return BUFFER_ERROR;
-        clSuites.hashSigAlgoSz = 0;
-
-        /* session size */
-        ato16(&input[idx], &sessionSz);
-        idx += 2;
-
-        if (sessionSz > ID_LEN)
-            return BUFFER_ERROR;
-
-        /* random size */
-        ato16(&input[idx], &randomSz);
-        idx += 2;
-
-        if (randomSz > RAN_LEN)
-            return BUFFER_ERROR;
-
-        /* suites */
-        for (i = 0, j = 0; i < clSuites.suiteSz; i += 3) {
-            byte first = input[idx++];
-            if (!first) { /* implicit: skip sslv2 type */
-                XMEMCPY(&clSuites.suites[j], &input[idx], 2);
-                j += 2;
-            }
-            idx += 2;
-        }
-        clSuites.suiteSz = j;
-
-        /* session id */
-        if (sessionSz) {
-            XMEMCPY(ssl->arrays->sessionID, input + idx, sessionSz);
-            ssl->arrays->sessionIDSz = (byte)sessionSz;
-            idx += sessionSz;
-            ssl->options.resuming = 1;
-        }
-
-        /* random */
-        if (randomSz < RAN_LEN)
-            XMEMSET(ssl->arrays->clientRandom, 0, RAN_LEN - randomSz);
-        XMEMCPY(&ssl->arrays->clientRandom[RAN_LEN - randomSz], input + idx,
-               randomSz);
-        idx += randomSz;
-
-        if (ssl->options.usingCompression)
-            ssl->options.usingCompression = 0;  /* turn off */
-
-        ssl->options.clientState = CLIENT_HELLO_COMPLETE;
-        *inOutIdx = idx;
-
-        ssl->options.haveSessionId = 1;
-        /* DoClientHello uses same resume code */
-        if (ssl->options.resuming) {  /* let's try */
-            int ret = -1;
-            WOLFSSL_SESSION* session = GetSession(ssl,
-                                                  ssl->arrays->masterSecret);
-            #ifdef HAVE_SESSION_TICKET
-                if (ssl->options.useTicket == 1) {
-                    session = &ssl->session;
-                }
-            #endif
-
-            if (!session) {
-                WOLFSSL_MSG("Session lookup for resume failed");
-                ssl->options.resuming = 0;
-            } else {
-                if (MatchSuite(ssl, &clSuites) < 0) {
-                    WOLFSSL_MSG("Unsupported cipher suite, OldClientHello");
-                    return UNSUPPORTED_SUITE;
-                }
-                #ifdef SESSION_CERTS
-                    ssl->session = *session; /* restore session certs. */
-                #endif
-
-                ret = wc_RNG_GenerateBlock(ssl->rng, ssl->arrays->serverRandom,
-                                                                       RAN_LEN);
-                if (ret != 0)
-                    return ret;
-
-                #ifdef NO_OLD_TLS
-                    ret = DeriveTlsKeys(ssl);
-                #else
-                    #ifndef NO_TLS
-                        if (ssl->options.tls)
-                            ret = DeriveTlsKeys(ssl);
-                    #endif
-                        if (!ssl->options.tls)
-                            ret = DeriveKeys(ssl);
-                #endif
-                ssl->options.clientState = CLIENT_KEYEXCHANGE_COMPLETE;
-
-                return ret;
-            }
-        }
-
-        return MatchSuite(ssl, &clSuites);
-    }
-
-#endif /* OLD_HELLO_ALLOWED */
-
-
-    static int DoClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
-                             word32 helloSz)
-    {
-        byte            b;
-        ProtocolVersion pv;
-        Suites          clSuites;
-        word32          i = *inOutIdx;
-        word32          begin = i;
-
-#ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn) AddPacketName("ClientHello", &ssl->handShakeInfo);
-        if (ssl->toInfoOn) AddLateName("ClientHello", &ssl->timeoutInfo);
-#endif
-
-        /* protocol version, random and session id length check */
-        if ((i - begin) + OPAQUE16_LEN + RAN_LEN + OPAQUE8_LEN > helloSz)
-            return BUFFER_ERROR;
-
-        /* protocol version */
-        XMEMCPY(&pv, input + i, OPAQUE16_LEN);
-        ssl->chVersion = pv;   /* store */
-        i += OPAQUE16_LEN;
-
-        if (ssl->version.minor > pv.minor) {
-            byte haveRSA = 0;
-            byte havePSK = 0;
-
-            if (!ssl->options.downgrade) {
-                WOLFSSL_MSG("Client trying to connect with lesser version");
-                return VERSION_ERROR;
-            }
-            if (pv.minor < ssl->options.minDowngrade) {
-                WOLFSSL_MSG("    version below minimum allowed, fatal error");
-                return VERSION_ERROR;
-            }
-
-            if (pv.minor == SSLv3_MINOR) {
-                /* turn off tls */
-                WOLFSSL_MSG("    downgrading to SSLv3");
-                ssl->options.tls    = 0;
-                ssl->options.tls1_1 = 0;
-                ssl->version.minor  = SSLv3_MINOR;
-            }
-            else if (pv.minor == TLSv1_MINOR) {
-                /* turn off tls 1.1+ */
-                WOLFSSL_MSG("    downgrading to TLSv1");
-                ssl->options.tls1_1 = 0;
-                ssl->version.minor  = TLSv1_MINOR;
-            }
-            else if (pv.minor == TLSv1_1_MINOR) {
-                WOLFSSL_MSG("    downgrading to TLSv1.1");
-                ssl->version.minor  = TLSv1_1_MINOR;
-            }
-#ifndef NO_RSA
-            haveRSA = 1;
-#endif
-#ifndef NO_PSK
-            havePSK = ssl->options.havePSK;
-#endif
-            InitSuites(ssl->suites, ssl->version, haveRSA, havePSK,
-                       ssl->options.haveDH, ssl->options.haveNTRU,
-                       ssl->options.haveECDSAsig, ssl->options.haveStaticECC,
-                       ssl->options.side);
-        }
-
-        /* random */
-        XMEMCPY(ssl->arrays->clientRandom, input + i, RAN_LEN);
-        i += RAN_LEN;
-
-#ifdef SHOW_SECRETS
-        {
-            int j;
-            printf("client random: ");
-            for (j = 0; j < RAN_LEN; j++)
-                printf("%02x", ssl->arrays->clientRandom[j]);
-            printf("\n");
-        }
-#endif
-
-        /* session id */
-        b = input[i++];
-
-        if (b == ID_LEN) {
-            if ((i - begin) + ID_LEN > helloSz)
-                return BUFFER_ERROR;
-
-            XMEMCPY(ssl->arrays->sessionID, input + i, ID_LEN);
-            ssl->arrays->sessionIDSz = ID_LEN;
-            i += ID_LEN;
-            ssl->options.resuming = 1; /* client wants to resume */
-            WOLFSSL_MSG("Client wants to resume session");
-        }
-        else if (b) {
-            WOLFSSL_MSG("Invalid session ID size");
-            return BUFFER_ERROR; /* session ID nor 0 neither 32 bytes long */
-        }
-
-        #ifdef WOLFSSL_DTLS
-            /* cookie */
-            if (ssl->options.dtls) {
-
-                if ((i - begin) + OPAQUE8_LEN > helloSz)
-                    return BUFFER_ERROR;
-
-                b = input[i++];
-
-                if (b) {
-                    byte cookie[MAX_COOKIE_LEN];
-
-                    if (b > MAX_COOKIE_LEN)
-                        return BUFFER_ERROR;
-
-                    if ((i - begin) + b > helloSz)
-                        return BUFFER_ERROR;
-
-                    if (ssl->ctx->CBIOCookie == NULL) {
-                        WOLFSSL_MSG("Your Cookie callback is null, please set");
-                        return COOKIE_ERROR;
-                    }
-
-                    if ((ssl->ctx->CBIOCookie(ssl, cookie, COOKIE_SZ,
-                                              ssl->IOCB_CookieCtx) != COOKIE_SZ)
-                            || (b != COOKIE_SZ)
-                            || (XMEMCMP(cookie, input + i, b) != 0)) {
-                        return COOKIE_ERROR;
-                    }
-
-                    i += b;
-                }
-            }
-        #endif
-
-        /* suites */
-        if ((i - begin) + OPAQUE16_LEN > helloSz)
-            return BUFFER_ERROR;
-
-        ato16(&input[i], &clSuites.suiteSz);
-        i += OPAQUE16_LEN;
-
-        /* suites and compression length check */
-        if ((i - begin) + clSuites.suiteSz + OPAQUE8_LEN > helloSz)
-            return BUFFER_ERROR;
-
-        if (clSuites.suiteSz > MAX_SUITE_SZ)
-            return BUFFER_ERROR;
-
-        XMEMCPY(clSuites.suites, input + i, clSuites.suiteSz);
-        i += clSuites.suiteSz;
-        clSuites.hashSigAlgoSz = 0;
-
-        /* compression length */
-        b = input[i++];
-
-        if ((i - begin) + b > helloSz)
-            return BUFFER_ERROR;
-
-        if (ssl->options.usingCompression) {
-            int match = 0;
-
-            while (b--) {
-                byte comp = input[i++];
-
-                if (comp == ZLIB_COMPRESSION)
-                    match = 1;
-            }
-
-            if (!match) {
-                WOLFSSL_MSG("Not matching compression, turning off");
-                ssl->options.usingCompression = 0;  /* turn off */
-            }
-        }
-        else
-            i += b; /* ignore, since we're not on */
-
-        *inOutIdx = i;
-
-        /* tls extensions */
-        if ((i - begin) < helloSz) {
-#ifdef HAVE_TLS_EXTENSIONS
-            if (TLSX_SupportExtensions(ssl)) {
-                int ret = 0;
-#else
-            if (IsAtLeastTLSv1_2(ssl)) {
-#endif
-                /* Process the hello extension. Skip unsupported. */
-                word16 totalExtSz;
-
-                if ((i - begin) + OPAQUE16_LEN > helloSz)
-                    return BUFFER_ERROR;
-
-                ato16(&input[i], &totalExtSz);
-                i += OPAQUE16_LEN;
-
-                if ((i - begin) + totalExtSz > helloSz)
-                    return BUFFER_ERROR;
-
-#ifdef HAVE_TLS_EXTENSIONS
-                if ((ret = TLSX_Parse(ssl, (byte *) input + i,
-                                                     totalExtSz, 1, &clSuites)))
-                    return ret;
-
-                i += totalExtSz;
-#else
-                while (totalExtSz) {
-                    word16 extId, extSz;
-
-                    if (OPAQUE16_LEN + OPAQUE16_LEN > totalExtSz)
-                        return BUFFER_ERROR;
-
-                    ato16(&input[i], &extId);
-                    i += OPAQUE16_LEN;
-                    ato16(&input[i], &extSz);
-                    i += OPAQUE16_LEN;
-
-                    if (OPAQUE16_LEN + OPAQUE16_LEN + extSz > totalExtSz)
-                        return BUFFER_ERROR;
-
-                    if (extId == HELLO_EXT_SIG_ALGO) {
-                        ato16(&input[i], &clSuites.hashSigAlgoSz);
-                        i += OPAQUE16_LEN;
-
-                        if (OPAQUE16_LEN + clSuites.hashSigAlgoSz > extSz)
-                            return BUFFER_ERROR;
-
-                        XMEMCPY(clSuites.hashSigAlgo, &input[i],
-                            min(clSuites.hashSigAlgoSz, HELLO_EXT_SIGALGO_MAX));
-                        i += clSuites.hashSigAlgoSz;
-
-                        if (clSuites.hashSigAlgoSz > HELLO_EXT_SIGALGO_MAX)
-                            clSuites.hashSigAlgoSz = HELLO_EXT_SIGALGO_MAX;
-                    }
-                    else
-                        i += extSz;
-
-                    totalExtSz -= OPAQUE16_LEN + OPAQUE16_LEN + extSz;
-                }
-#endif
-                *inOutIdx = i;
-            }
-            else
-                *inOutIdx = begin + helloSz; /* skip extensions */
-        }
-
-        ssl->options.clientState   = CLIENT_HELLO_COMPLETE;
-        ssl->options.haveSessionId = 1;
-
-        /* ProcessOld uses same resume code */
-        if (ssl->options.resuming && (!ssl->options.dtls ||
-               ssl->options.acceptState == HELLO_VERIFY_SENT)) { /* let's try */
-            int ret = -1;
-            WOLFSSL_SESSION* session = GetSession(ssl,
-                                                  ssl->arrays->masterSecret);
-            #ifdef HAVE_SESSION_TICKET
-                if (ssl->options.useTicket == 1) {
-                    session = &ssl->session;
-                }
-            #endif
-
-            if (!session) {
-                WOLFSSL_MSG("Session lookup for resume failed");
-                ssl->options.resuming = 0;
-            }
-            else {
-                if (MatchSuite(ssl, &clSuites) < 0) {
-                    WOLFSSL_MSG("Unsupported cipher suite, ClientHello");
-                    return UNSUPPORTED_SUITE;
-                }
-                #ifdef SESSION_CERTS
-                    ssl->session = *session; /* restore session certs. */
-                #endif
-
-                ret = wc_RNG_GenerateBlock(ssl->rng, ssl->arrays->serverRandom,
-                                                                       RAN_LEN);
-                if (ret != 0)
-                    return ret;
-
-                #ifdef NO_OLD_TLS
-                    ret = DeriveTlsKeys(ssl);
-                #else
-                    #ifndef NO_TLS
-                        if (ssl->options.tls)
-                            ret = DeriveTlsKeys(ssl);
-                    #endif
-                        if (!ssl->options.tls)
-                            ret = DeriveKeys(ssl);
-                #endif
-                ssl->options.clientState = CLIENT_KEYEXCHANGE_COMPLETE;
-
-                return ret;
-            }
-        }
-        return MatchSuite(ssl, &clSuites);
-    }
-
-#if !defined(NO_RSA) || defined(HAVE_ECC)
-    static int DoCertificateVerify(WOLFSSL* ssl, byte* input, word32* inOutIdx,
-                                   word32 size)
-    {
-        word16      sz = 0;
-        int         ret = VERIFY_CERT_ERROR;   /* start in error state */
-        byte        hashAlgo = sha_mac;
-        byte        sigAlgo = anonymous_sa_algo;
-        word32      begin = *inOutIdx;
-
-        #ifdef WOLFSSL_CALLBACKS
-            if (ssl->hsInfoOn)
-                AddPacketName("CertificateVerify", &ssl->handShakeInfo);
-            if (ssl->toInfoOn)
-                AddLateName("CertificateVerify", &ssl->timeoutInfo);
-        #endif
-
-
-        if (IsAtLeastTLSv1_2(ssl)) {
-            if ((*inOutIdx - begin) + ENUM_LEN + ENUM_LEN > size)
-                return BUFFER_ERROR;
-
-            hashAlgo = input[(*inOutIdx)++];
-            sigAlgo  = input[(*inOutIdx)++];
-        }
-
-        if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-            return BUFFER_ERROR;
-
-        ato16(input + *inOutIdx, &sz);
-        *inOutIdx += OPAQUE16_LEN;
-
-        if ((*inOutIdx - begin) + sz > size || sz > ENCRYPT_LEN)
-            return BUFFER_ERROR;
-
-        /* RSA */
-#ifndef NO_RSA
-        if (ssl->peerRsaKey != NULL && ssl->peerRsaKeyPresent != 0) {
-            byte* out       = NULL;
-            int   outLen    = 0;
-            byte  doUserRsa = 0;
-
-            #ifdef HAVE_PK_CALLBACKS
-                if (ssl->ctx->RsaVerifyCb)
-                    doUserRsa = 1;
-            #endif /*HAVE_PK_CALLBACKS */
-
-            WOLFSSL_MSG("Doing RSA peer cert verify");
-
-            if (doUserRsa) {
-            #ifdef HAVE_PK_CALLBACKS
-                outLen = ssl->ctx->RsaVerifyCb(ssl, input + *inOutIdx, sz,
-                                            &out,
-                                            ssl->buffers.peerRsaKey.buffer,
-                                            ssl->buffers.peerRsaKey.length,
-                                            ssl->RsaVerifyCtx);
-            #endif /*HAVE_PK_CALLBACKS */
-            }
-            else {
-                outLen = wc_RsaSSL_VerifyInline(input + *inOutIdx, sz, &out,
-                                                               ssl->peerRsaKey);
-            }
-
-            if (IsAtLeastTLSv1_2(ssl)) {
-#ifdef WOLFSSL_SMALL_STACK
-                byte*  encodedSig = NULL;
-#else
-                byte   encodedSig[MAX_ENCODED_SIG_SZ];
-#endif
-                word32 sigSz;
-                byte*  digest = ssl->hsHashes->certHashes.sha;
-                int    typeH = SHAh;
-                int    digestSz = SHA_DIGEST_SIZE;
-
-#ifdef WOLFSSL_SMALL_STACK
-                encodedSig = (byte*)XMALLOC(MAX_ENCODED_SIG_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-                if (encodedSig == NULL)
-                    return MEMORY_E;
-#endif
-
-                if (sigAlgo != rsa_sa_algo) {
-                    WOLFSSL_MSG("Oops, peer sent RSA key but not in verify");
-                }
-
-                if (hashAlgo == sha256_mac) {
-                    #ifndef NO_SHA256
-                        digest = ssl->hsHashes->certHashes.sha256;
-                        typeH    = SHA256h;
-                        digestSz = SHA256_DIGEST_SIZE;
-                    #endif
-                }
-                else if (hashAlgo == sha384_mac) {
-                    #ifdef WOLFSSL_SHA384
-                        digest = ssl->hsHashes->certHashes.sha384;
-                        typeH    = SHA384h;
-                        digestSz = SHA384_DIGEST_SIZE;
-                    #endif
-                }
-                else if (hashAlgo == sha512_mac) {
-                    #ifdef WOLFSSL_SHA512
-                        digest = ssl->hsHashes->certHashes.sha512;
-                        typeH    = SHA512h;
-                        digestSz = SHA512_DIGEST_SIZE;
-                    #endif
-                }
-
-                sigSz = wc_EncodeSignature(encodedSig, digest, digestSz, typeH);
-
-                if (outLen == (int)sigSz && out && XMEMCMP(out, encodedSig,
-                                           min(sigSz, MAX_ENCODED_SIG_SZ)) == 0)
-                    ret = 0; /* verified */
-
-#ifdef WOLFSSL_SMALL_STACK
-                XFREE(encodedSig, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            }
-            else {
-                if (outLen == FINISHED_SZ && out && XMEMCMP(out,
-                                            &ssl->hsHashes->certHashes,
-                                            FINISHED_SZ) == 0) {
-                    ret = 0; /* verified */
-                }
-            }
-        }
-#endif
-#ifdef HAVE_ECC
-        if (ssl->peerEccDsaKeyPresent) {
-            int verify =  0;
-            int err    = -1;
-            byte* digest = ssl->hsHashes->certHashes.sha;
-            word32 digestSz = SHA_DIGEST_SIZE;
-            byte doUserEcc = 0;
-
-            #ifdef HAVE_PK_CALLBACKS
-                if (ssl->ctx->EccVerifyCb)
-                    doUserEcc = 1;
-            #endif
-
-            WOLFSSL_MSG("Doing ECC peer cert verify");
-
-            if (IsAtLeastTLSv1_2(ssl)) {
-                if (sigAlgo != ecc_dsa_sa_algo) {
-                    WOLFSSL_MSG("Oops, peer sent ECC key but not in verify");
-                }
-
-                if (hashAlgo == sha256_mac) {
-                    #ifndef NO_SHA256
-                        digest = ssl->hsHashes->certHashes.sha256;
-                        digestSz = SHA256_DIGEST_SIZE;
-                    #endif
-                }
-                else if (hashAlgo == sha384_mac) {
-                    #ifdef WOLFSSL_SHA384
-                        digest = ssl->hsHashes->certHashes.sha384;
-                        digestSz = SHA384_DIGEST_SIZE;
-                    #endif
-                }
-                else if (hashAlgo == sha512_mac) {
-                    #ifdef WOLFSSL_SHA512
-                        digest = ssl->hsHashes->certHashes.sha512;
-                        digestSz = SHA512_DIGEST_SIZE;
-                    #endif
-                }
-            }
-
-            if (doUserEcc) {
-            #ifdef HAVE_PK_CALLBACKS
-                ret = ssl->ctx->EccVerifyCb(ssl, input + *inOutIdx, sz, digest,
-                                            digestSz,
-                                            ssl->buffers.peerEccDsaKey.buffer,
-                                            ssl->buffers.peerEccDsaKey.length,
-                                            &verify, ssl->EccVerifyCtx);
-            #endif
-            }
-            else {
-                err = wc_ecc_verify_hash(input + *inOutIdx, sz, digest,
-                                         digestSz, &verify, ssl->peerEccDsaKey);
-            }
-
-            if (err == 0 && verify == 1)
-               ret = 0; /* verified */
-        }
-#endif
-        *inOutIdx += sz;
-
-        if (ret == 0)
-            ssl->options.havePeerVerify = 1;
-
-        return ret;
-    }
-#endif /* !NO_RSA || HAVE_ECC */
-
-    int SendServerHelloDone(WOLFSSL* ssl)
-    {
-        byte              *output;
-        int                sendSz = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ;
-        int                ret;
-
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls)
-                sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA;
-        #endif
-        /* check for available size */
-        if ((ret = CheckAvailableSize(ssl, sendSz)) != 0)
-            return ret;
-
-        /* get ouput buffer */
-        output = ssl->buffers.outputBuffer.buffer +
-                 ssl->buffers.outputBuffer.length;
-
-        AddHeaders(output, 0, server_hello_done, ssl);
-
-        #ifdef WOLFSSL_DTLS
-            if (ssl->options.dtls) {
-                if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0)
-                    return 0;
-            }
-        #endif
-
-        ret = HashOutput(ssl, output, sendSz, 0);
-            if (ret != 0)
-                return ret;
-
-#ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn)
-            AddPacketName("ServerHelloDone", &ssl->handShakeInfo);
-        if (ssl->toInfoOn)
-            AddPacketInfo("ServerHelloDone", &ssl->timeoutInfo, output, sendSz,
-                          ssl->heap);
-#endif
-        ssl->options.serverState = SERVER_HELLODONE_COMPLETE;
-
-        ssl->buffers.outputBuffer.length += sendSz;
-
-        return SendBuffered(ssl);
-    }
-
-
-#ifdef HAVE_SESSION_TICKET
-
-#define WOLFSSL_TICKET_FIXED_SZ (WOLFSSL_TICKET_NAME_SZ + \
-                WOLFSSL_TICKET_IV_SZ + WOLFSSL_TICKET_MAC_SZ + LENGTH_SZ)
-#define WOLFSSL_TICKET_ENC_SZ (SESSION_TICKET_LEN - WOLFSSL_TICKET_FIXED_SZ)
-
-    /* our ticket format */
-    typedef struct InternalTicket {
-        ProtocolVersion pv;                    /* version when ticket created */
-        byte            suite[SUITE_LEN];      /* cipher suite when created */
-        byte            msecret[SECRET_LEN];   /* master secret */
-        word32          timestamp;             /* born on */
-    } InternalTicket;
-
-    /* fit within SESSION_TICKET_LEN */
-    typedef struct ExternalTicket {
-        byte key_name[WOLFSSL_TICKET_NAME_SZ];  /* key context name */
-        byte iv[WOLFSSL_TICKET_IV_SZ];          /* this ticket's iv */
-        byte enc_len[LENGTH_SZ];                /* encrypted length */
-        byte enc_ticket[WOLFSSL_TICKET_ENC_SZ]; /* encrypted internal ticket */
-        byte mac[WOLFSSL_TICKET_MAC_SZ];        /* total mac */
-        /* !! if add to structure, add to TICKET_FIXED_SZ !! */
-    } ExternalTicket;
-
-    /* create a new session ticket, 0 on success */
-    static int CreateTicket(WOLFSSL* ssl)
-    {
-        InternalTicket  it;
-        ExternalTicket* et = (ExternalTicket*)ssl->session.ticket;
-        int encLen;
-        int ret;
-        byte zeros[WOLFSSL_TICKET_MAC_SZ];   /* biggest cmp size */
-
-        /* build internal */
-        it.pv.major = ssl->version.major;
-        it.pv.minor = ssl->version.minor;
-
-        it.suite[0] = ssl->options.cipherSuite0;
-        it.suite[1] = ssl->options.cipherSuite;
-
-        XMEMCPY(it.msecret, ssl->arrays->masterSecret, SECRET_LEN);
-        c32toa(LowResTimer(), (byte*)&it.timestamp);
-
-        /* build external */
-        XMEMCPY(et->enc_ticket, &it, sizeof(InternalTicket));
-
-        /* encrypt */
-        encLen = WOLFSSL_TICKET_ENC_SZ;  /* max size user can use */
-        ret = ssl->ctx->ticketEncCb(ssl, et->key_name, et->iv, et->mac, 1,
-                                    et->enc_ticket, sizeof(InternalTicket),
-                                    &encLen, ssl->ctx->ticketEncCtx);
-        if (ret == WOLFSSL_TICKET_RET_OK) {
-            if (encLen < (int)sizeof(InternalTicket) ||
-                encLen > WOLFSSL_TICKET_ENC_SZ) {
-                WOLFSSL_MSG("Bad user ticket encrypt size");
-                return BAD_TICKET_KEY_CB_SZ;
-            }
-
-            /* sanity checks on encrypt callback */
-
-            /* internal ticket can't be the same if encrypted */
-            if (XMEMCMP(et->enc_ticket, &it, sizeof(InternalTicket)) == 0) {
-                WOLFSSL_MSG("User ticket encrypt didn't encrypt");
-                return BAD_TICKET_ENCRYPT;
-            }
-
-            XMEMSET(zeros, 0, sizeof(zeros));
-
-            /* name */
-            if (XMEMCMP(et->key_name, zeros, WOLFSSL_TICKET_NAME_SZ) == 0) {
-                WOLFSSL_MSG("User ticket encrypt didn't set name");
-                return BAD_TICKET_ENCRYPT;
-            }
-
-            /* iv */
-            if (XMEMCMP(et->iv, zeros, WOLFSSL_TICKET_IV_SZ) == 0) {
-                WOLFSSL_MSG("User ticket encrypt didn't set iv");
-                return BAD_TICKET_ENCRYPT;
-            }
-
-            /* mac */
-            if (XMEMCMP(et->mac, zeros, WOLFSSL_TICKET_MAC_SZ) == 0) {
-                WOLFSSL_MSG("User ticket encrypt didn't set mac");
-                return BAD_TICKET_ENCRYPT;
-            }
-
-            /* set size */
-            c16toa((word16)encLen, et->enc_len);
-            ssl->session.ticketLen = (word16)(encLen + WOLFSSL_TICKET_FIXED_SZ);
-            if (encLen < WOLFSSL_TICKET_ENC_SZ) {
-                /* move mac up since whole enc buffer not used */
-                XMEMMOVE(et->enc_ticket +encLen, et->mac,WOLFSSL_TICKET_MAC_SZ);
-            }
-        }
-
-        return ret;
-    }
-
-
-    /* Parse ticket sent by client, returns callback return value */
-    int DoClientTicket(WOLFSSL* ssl, const byte* input, word32 len)
-    {
-        ExternalTicket* et;
-        InternalTicket* it;
-        int             ret;
-        int             outLen;
-        word16          inLen;
-
-        if (len > SESSION_TICKET_LEN ||
-             len < (word32)(sizeof(InternalTicket) + WOLFSSL_TICKET_FIXED_SZ)) {
-            return BAD_TICKET_MSG_SZ;
-        }
-
-        et = (ExternalTicket*)input;
-        it = (InternalTicket*)et->enc_ticket;
-
-        /* decrypt */
-        ato16(et->enc_len, &inLen);
-        if (inLen > (word16)(len - WOLFSSL_TICKET_FIXED_SZ)) {
-            return BAD_TICKET_MSG_SZ;
-        }
-        outLen = inLen;   /* may be reduced by user padding */
-        ret = ssl->ctx->ticketEncCb(ssl, et->key_name, et->iv,
-                                    et->enc_ticket + inLen, 0,
-                                    et->enc_ticket, inLen, &outLen,
-                                    ssl->ctx->ticketEncCtx);
-        if (ret == WOLFSSL_TICKET_RET_FATAL || ret < 0) return ret;
-        if (outLen > inLen || outLen < (int)sizeof(InternalTicket)) {
-            WOLFSSL_MSG("Bad user ticket decrypt len");
-            return BAD_TICKET_KEY_CB_SZ;
-        }
-
-        /* get master secret */
-        if (ret == WOLFSSL_TICKET_RET_OK || ret == WOLFSSL_TICKET_RET_CREATE)
-            XMEMCPY(ssl->arrays->masterSecret, it->msecret, SECRET_LEN);
-
-        return ret;
-    }
-
-
-    /* send Session Ticket */
-    int SendTicket(WOLFSSL* ssl)
-    {
-        byte*              output;
-        int                ret;
-        int                sendSz;
-        word32             length = SESSION_HINT_SZ + LENGTH_SZ;
-        word32             idx    = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ;
-
-    #ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            length += DTLS_RECORD_EXTRA;
-            idx    += DTLS_RECORD_EXTRA;
-        }
-    #endif
-
-        if (ssl->options.createTicket) {
-            ret = CreateTicket(ssl);
-            if (ret != 0) return ret;
-        }
-
-        length += ssl->session.ticketLen;
-        sendSz = length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ;
-
-        /* check for available size */
-        if ((ret = CheckAvailableSize(ssl, sendSz)) != 0)
-            return ret;
-
-        /* get ouput buffer */
-        output = ssl->buffers.outputBuffer.buffer +
-                 ssl->buffers.outputBuffer.length;
-
-        AddHeaders(output, length, session_ticket, ssl);
-
-        /* hint */
-        c32toa(ssl->ctx->ticketHint, output + idx);
-        idx += SESSION_HINT_SZ;
-
-        /* length */
-        c16toa(ssl->session.ticketLen, output + idx);
-        idx += LENGTH_SZ;
-
-        /* ticket */
-        XMEMCPY(output + idx, ssl->session.ticket, ssl->session.ticketLen);
-        /* idx += ssl->session.ticketLen; */
-
-        ret = HashOutput(ssl, output, sendSz, 0);
-        if (ret != 0) return ret;
-        ssl->buffers.outputBuffer.length += sendSz;
-
-        return SendBuffered(ssl);
-    }
-
-#endif /* HAVE_SESSION_TICKET */
-
-
-#ifdef WOLFSSL_DTLS
-    int SendHelloVerifyRequest(WOLFSSL* ssl)
-    {
-        byte* output;
-        byte  cookieSz = COOKIE_SZ;
-        int   length = VERSION_SZ + ENUM_LEN + cookieSz;
-        int   idx    = DTLS_RECORD_HEADER_SZ + DTLS_HANDSHAKE_HEADER_SZ;
-        int   sendSz = length + idx;
-        int   ret;
-
-        /* check for available size */
-        if ((ret = CheckAvailableSize(ssl, sendSz)) != 0)
-            return ret;
-
-        /* get ouput buffer */
-        output = ssl->buffers.outputBuffer.buffer +
-                 ssl->buffers.outputBuffer.length;
-
-        AddHeaders(output, length, hello_verify_request, ssl);
-
-        output[idx++] =  ssl->chVersion.major;
-        output[idx++] =  ssl->chVersion.minor;
-
-        output[idx++] = cookieSz;
-        if (ssl->ctx->CBIOCookie == NULL) {
-            WOLFSSL_MSG("Your Cookie callback is null, please set");
-            return COOKIE_ERROR;
-        }
-        if ((ret = ssl->ctx->CBIOCookie(ssl, output + idx, cookieSz,
-                                        ssl->IOCB_CookieCtx)) < 0)
-            return ret;
-
-        ret = HashOutput(ssl, output, sendSz, 0);
-        if (ret != 0)
-            return ret;
-
-#ifdef WOLFSSL_CALLBACKS
-        if (ssl->hsInfoOn)
-            AddPacketName("HelloVerifyRequest", &ssl->handShakeInfo);
-        if (ssl->toInfoOn)
-            AddPacketInfo("HelloVerifyRequest", &ssl->timeoutInfo, output,
-                          sendSz, ssl->heap);
-#endif
-        ssl->options.serverState = SERVER_HELLOVERIFYREQUEST_COMPLETE;
-
-        ssl->buffers.outputBuffer.length += sendSz;
-
-        return SendBuffered(ssl);
-    }
-#endif
-
-    static int DoClientKeyExchange(WOLFSSL* ssl, byte* input, word32* inOutIdx,
-                                                                    word32 size)
-    {
-        int    ret = 0;
-        word32 length = 0;
-        byte*  out = NULL;
-        word32 begin = *inOutIdx;
-
-        (void)length; /* shut up compiler warnings */
-        (void)out;
-        (void)input;
-        (void)size;
-        (void)begin;
-
-        if (ssl->options.side != WOLFSSL_SERVER_END) {
-            WOLFSSL_MSG("Client received client keyexchange, attack?");
-            WOLFSSL_ERROR(ssl->error = SIDE_ERROR);
-            return SSL_FATAL_ERROR;
-        }
-
-        if (ssl->options.clientState < CLIENT_HELLO_COMPLETE) {
-            WOLFSSL_MSG("Client sending keyexchange at wrong time");
-            SendAlert(ssl, alert_fatal, unexpected_message);
-            return OUT_OF_ORDER_E;
-        }
-
-        #ifndef NO_CERTS
-            if (ssl->options.verifyPeer && ssl->options.failNoCert)
-                if (!ssl->options.havePeerCert) {
-                    WOLFSSL_MSG("client didn't present peer cert");
-                    return NO_PEER_CERT;
-                }
-        #endif
-
-        #ifdef WOLFSSL_CALLBACKS
-            if (ssl->hsInfoOn)
-                AddPacketName("ClientKeyExchange", &ssl->handShakeInfo);
-            if (ssl->toInfoOn)
-                AddLateName("ClientKeyExchange", &ssl->timeoutInfo);
-        #endif
-
-        switch (ssl->specs.kea) {
-        #ifndef NO_RSA
-            case rsa_kea:
-            {
-                word32 idx = 0;
-                RsaKey key;
-                byte   doUserRsa = 0;
-
-                #ifdef HAVE_PK_CALLBACKS
-                    if (ssl->ctx->RsaDecCb)
-                        doUserRsa = 1;
-                #endif
-
-                ret = wc_InitRsaKey(&key, ssl->heap);
-                if (ret != 0) return ret;
-
-                if (ssl->buffers.key.buffer)
-                    ret = wc_RsaPrivateKeyDecode(ssl->buffers.key.buffer, &idx,
-                                             &key, ssl->buffers.key.length);
-                else
-                    return NO_PRIVATE_KEY;
-
-                if (ret == 0) {
-                    length = wc_RsaEncryptSize(&key);
-                    ssl->arrays->preMasterSz = SECRET_LEN;
-
-                    if (ssl->options.tls) {
-                        word16 check;
-
-                        if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-                            return BUFFER_ERROR;
-
-                        ato16(input + *inOutIdx, &check);
-                        *inOutIdx += OPAQUE16_LEN;
-
-                        if ((word32) check != length) {
-                            WOLFSSL_MSG("RSA explicit size doesn't match");
-                            wc_FreeRsaKey(&key);
-                            return RSA_PRIVATE_ERROR;
-                        }
-                    }
-
-                    if ((*inOutIdx - begin) + length > size) {
-                        WOLFSSL_MSG("RSA message too big");
-                        wc_FreeRsaKey(&key);
-                        return BUFFER_ERROR;
-                    }
-
-                    if (doUserRsa) {
-                        #ifdef HAVE_PK_CALLBACKS
-                            ret = ssl->ctx->RsaDecCb(ssl,
-                                        input + *inOutIdx, length, &out,
-                                        ssl->buffers.key.buffer,
-                                        ssl->buffers.key.length,
-                                        ssl->RsaDecCtx);
-                        #endif
-                    }
-                    else {
-                        ret = wc_RsaPrivateDecryptInline(input + *inOutIdx, length,
-                                                                    &out, &key);
-                    }
-
-                    *inOutIdx += length;
-
-                    if (ret == SECRET_LEN) {
-                        XMEMCPY(ssl->arrays->preMasterSecret, out, SECRET_LEN);
-                        if (ssl->arrays->preMasterSecret[0] !=
-                                                           ssl->chVersion.major
-                            || ssl->arrays->preMasterSecret[1] !=
-                                                           ssl->chVersion.minor)
-                            ret = PMS_VERSION_ERROR;
-                        else
-                            ret = MakeMasterSecret(ssl);
-                    }
-                    else {
-                        ret = RSA_PRIVATE_ERROR;
-                    }
-                }
-
-                wc_FreeRsaKey(&key);
-            }
-            break;
-        #endif
-        #ifndef NO_PSK
-            case psk_kea:
-            {
-                byte* pms = ssl->arrays->preMasterSecret;
-                word16 ci_sz;
-
-                if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-                    return BUFFER_ERROR;
-
-                ato16(input + *inOutIdx, &ci_sz);
-                *inOutIdx += OPAQUE16_LEN;
-
-                if (ci_sz > MAX_PSK_ID_LEN)
-                    return CLIENT_ID_ERROR;
-
-                if ((*inOutIdx - begin) + ci_sz > size)
-                    return BUFFER_ERROR;
-
-                XMEMCPY(ssl->arrays->client_identity, input + *inOutIdx, ci_sz);
-                *inOutIdx += ci_sz;
-
-                ssl->arrays->client_identity[min(ci_sz, MAX_PSK_ID_LEN-1)] = 0;
-                ssl->arrays->psk_keySz = ssl->options.server_psk_cb(ssl,
-                    ssl->arrays->client_identity, ssl->arrays->psk_key,
-                    MAX_PSK_KEY_LEN);
-
-                if (ssl->arrays->psk_keySz == 0 ||
-                                       ssl->arrays->psk_keySz > MAX_PSK_KEY_LEN)
-                    return PSK_KEY_ERROR;
-
-                /* make psk pre master secret */
-                /* length of key + length 0s + length of key + key */
-                c16toa((word16) ssl->arrays->psk_keySz, pms);
-                pms += OPAQUE16_LEN;
-
-                XMEMSET(pms, 0, ssl->arrays->psk_keySz);
-                pms += ssl->arrays->psk_keySz;
-
-                c16toa((word16) ssl->arrays->psk_keySz, pms);
-                pms += OPAQUE16_LEN;
-
-                XMEMCPY(pms, ssl->arrays->psk_key, ssl->arrays->psk_keySz);
-                ssl->arrays->preMasterSz = ssl->arrays->psk_keySz * 2 + 4;
-
-                ret = MakeMasterSecret(ssl);
-
-                /* No further need for PSK */
-                ForceZero(ssl->arrays->psk_key, ssl->arrays->psk_keySz);
-                ssl->arrays->psk_keySz = 0;
-            }
-            break;
-        #endif /* NO_PSK */
-        #ifdef HAVE_NTRU
-            case ntru_kea:
-            {
-                word16 cipherLen;
-                word16 plainLen = sizeof(ssl->arrays->preMasterSecret);
-
-                if (!ssl->buffers.key.buffer)
-                    return NO_PRIVATE_KEY;
-
-                if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-                    return BUFFER_ERROR;
-
-                ato16(input + *inOutIdx, &cipherLen);
-                *inOutIdx += OPAQUE16_LEN;
-
-                if (cipherLen > MAX_NTRU_ENCRYPT_SZ)
-                    return NTRU_KEY_ERROR;
-
-                if ((*inOutIdx - begin) + cipherLen > size)
-                    return BUFFER_ERROR;
-
-                if (NTRU_OK != ntru_crypto_ntru_decrypt(
-                            (word16) ssl->buffers.key.length,
-                            ssl->buffers.key.buffer, cipherLen,
-                            input + *inOutIdx, &plainLen,
-                            ssl->arrays->preMasterSecret))
-                    return NTRU_DECRYPT_ERROR;
-
-                if (plainLen != SECRET_LEN)
-                    return NTRU_DECRYPT_ERROR;
-
-                *inOutIdx += cipherLen;
-
-                ssl->arrays->preMasterSz = plainLen;
-                ret = MakeMasterSecret(ssl);
-            }
-            break;
-        #endif /* HAVE_NTRU */
-        #ifdef HAVE_ECC
-            case ecc_diffie_hellman_kea:
-            {
-                if ((*inOutIdx - begin) + OPAQUE8_LEN > size)
-                    return BUFFER_ERROR;
-
-                length = input[(*inOutIdx)++];
-
-                if ((*inOutIdx - begin) + length > size)
-                    return BUFFER_ERROR;
-
-                if (ssl->peerEccKey == NULL) {
-                    /* alloc/init on demand */
-                    ssl->peerEccKey = (ecc_key*)XMALLOC(sizeof(ecc_key),
-                                              ssl->ctx->heap, DYNAMIC_TYPE_ECC);
-                    if (ssl->peerEccKey == NULL) {
-                        WOLFSSL_MSG("PeerEccKey Memory error");
-                        return MEMORY_E;
-                    }
-                    wc_ecc_init(ssl->peerEccKey);
-                } else if (ssl->peerEccKeyPresent) {  /* don't leak on reuse */
-                    wc_ecc_free(ssl->peerEccKey);
-                    ssl->peerEccKeyPresent = 0;
-                    wc_ecc_init(ssl->peerEccKey);
-                }
-
-                if (wc_ecc_import_x963(input + *inOutIdx, length, ssl->peerEccKey))
-                    return ECC_PEERKEY_ERROR;
-
-                *inOutIdx += length;
-                ssl->peerEccKeyPresent = 1;
-
-                length = sizeof(ssl->arrays->preMasterSecret);
-
-                if (ssl->specs.static_ecdh) {
-                    ecc_key staticKey;
-                    word32 i = 0;
-
-                    wc_ecc_init(&staticKey);
-                    ret = wc_EccPrivateKeyDecode(ssl->buffers.key.buffer, &i,
-                                           &staticKey, ssl->buffers.key.length);
-
-                    if (ret == 0)
-                        ret = wc_ecc_shared_secret(&staticKey, ssl->peerEccKey,
-                                         ssl->arrays->preMasterSecret, &length);
-
-                    wc_ecc_free(&staticKey);
-                }
-                else {
-                    if (ssl->eccTempKeyPresent == 0) {
-                        WOLFSSL_MSG("Ecc ephemeral key not made correctly");
-                        ret = ECC_MAKEKEY_ERROR;
-                    } else {
-                        ret = wc_ecc_shared_secret(ssl->eccTempKey,ssl->peerEccKey,
-                                         ssl->arrays->preMasterSecret, &length);
-                    }
-                }
-
-                if (ret != 0)
-                    return ECC_SHARED_ERROR;
-
-                ssl->arrays->preMasterSz = length;
-                ret = MakeMasterSecret(ssl);
-            }
-            break;
-        #endif /* HAVE_ECC */
-        #ifndef NO_DH
-            case diffie_hellman_kea:
-            {
-                word16 clientPubSz;
-                DhKey  dhKey;
-
-                if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-                    return BUFFER_ERROR;
-
-                ato16(input + *inOutIdx, &clientPubSz);
-                *inOutIdx += OPAQUE16_LEN;
-
-                if ((*inOutIdx - begin) + clientPubSz > size)
-                    return BUFFER_ERROR;
-
-                wc_InitDhKey(&dhKey);
-                ret = wc_DhSetKey(&dhKey, ssl->buffers.serverDH_P.buffer,
-                                       ssl->buffers.serverDH_P.length,
-                                       ssl->buffers.serverDH_G.buffer,
-                                       ssl->buffers.serverDH_G.length);
-                if (ret == 0)
-                    ret = wc_DhAgree(&dhKey, ssl->arrays->preMasterSecret,
-                                         &ssl->arrays->preMasterSz,
-                                          ssl->buffers.serverDH_Priv.buffer,
-                                          ssl->buffers.serverDH_Priv.length,
-                                          input + *inOutIdx, clientPubSz);
-                wc_FreeDhKey(&dhKey);
-
-                *inOutIdx += clientPubSz;
-
-                if (ret == 0)
-                    ret = MakeMasterSecret(ssl);
-            }
-            break;
-        #endif /* NO_DH */
-        #if !defined(NO_DH) && !defined(NO_PSK)
-            case dhe_psk_kea:
-            {
-                byte* pms = ssl->arrays->preMasterSecret;
-                word16 clientSz;
-                DhKey  dhKey;
-
-                /* Read in the PSK hint */
-                if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-                    return BUFFER_ERROR;
-
-                ato16(input + *inOutIdx, &clientSz);
-                *inOutIdx += OPAQUE16_LEN;
-                if (clientSz > MAX_PSK_ID_LEN)
-                    return CLIENT_ID_ERROR;
-
-                if ((*inOutIdx - begin) + clientSz > size)
-                    return BUFFER_ERROR;
-
-                XMEMCPY(ssl->arrays->client_identity,
-                                                   input + *inOutIdx, clientSz);
-                *inOutIdx += clientSz;
-                ssl->arrays->client_identity[min(clientSz, MAX_PSK_ID_LEN-1)] =
-                                                                              0;
-
-                /* Read in the DHE business */
-                if ((*inOutIdx - begin) + OPAQUE16_LEN > size)
-                    return BUFFER_ERROR;
-
-                ato16(input + *inOutIdx, &clientSz);
-                *inOutIdx += OPAQUE16_LEN;
-
-                if ((*inOutIdx - begin) + clientSz > size)
-                    return BUFFER_ERROR;
-
-                wc_InitDhKey(&dhKey);
-                ret = wc_DhSetKey(&dhKey, ssl->buffers.serverDH_P.buffer,
-                                       ssl->buffers.serverDH_P.length,
-                                       ssl->buffers.serverDH_G.buffer,
-                                       ssl->buffers.serverDH_G.length);
-                if (ret == 0)
-                    ret = wc_DhAgree(&dhKey, pms + OPAQUE16_LEN,
-                                          &ssl->arrays->preMasterSz,
-                                          ssl->buffers.serverDH_Priv.buffer,
-                                          ssl->buffers.serverDH_Priv.length,
-                                          input + *inOutIdx, clientSz);
-                wc_FreeDhKey(&dhKey);
-
-                *inOutIdx += clientSz;
-                c16toa((word16)ssl->arrays->preMasterSz, pms);
-                ssl->arrays->preMasterSz += OPAQUE16_LEN;
-                pms += ssl->arrays->preMasterSz;
-
-                /* Use the PSK hint to look up the PSK and add it to the
-                 * preMasterSecret here. */
-                ssl->arrays->psk_keySz = ssl->options.server_psk_cb(ssl,
-                    ssl->arrays->client_identity, ssl->arrays->psk_key,
-                    MAX_PSK_KEY_LEN);
-
-                if (ssl->arrays->psk_keySz == 0 ||
-                                       ssl->arrays->psk_keySz > MAX_PSK_KEY_LEN)
-                    return PSK_KEY_ERROR;
-
-                c16toa((word16) ssl->arrays->psk_keySz, pms);
-                pms += OPAQUE16_LEN;
-
-                XMEMCPY(pms, ssl->arrays->psk_key, ssl->arrays->psk_keySz);
-                ssl->arrays->preMasterSz +=
-                                          ssl->arrays->psk_keySz + OPAQUE16_LEN;
-                if (ret == 0)
-                    ret = MakeMasterSecret(ssl);
-
-                /* No further need for PSK */
-                ForceZero(ssl->arrays->psk_key, ssl->arrays->psk_keySz);
-                ssl->arrays->psk_keySz = 0;
-            }
-            break;
-        #endif /* !NO_DH && !NO_PSK */
-            default:
-            {
-                WOLFSSL_MSG("Bad kea type");
-                ret = BAD_KEA_TYPE_E;
-            }
-            break;
-        }
-
-        /* No further need for PMS */
-        ForceZero(ssl->arrays->preMasterSecret, ssl->arrays->preMasterSz);
-        ssl->arrays->preMasterSz = 0;
-
-        if (ret == 0) {
-            ssl->options.clientState = CLIENT_KEYEXCHANGE_COMPLETE;
-            #ifndef NO_CERTS
-                if (ssl->options.verifyPeer)
-                    ret = BuildCertHashes(ssl, &ssl->hsHashes->certHashes);
-            #endif
-        }
-
-        return ret;
-    }
-
-#endif /* NO_WOLFSSL_SERVER */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/src/io.c b/FreeRTOS-Plus/Source/WolfSSL/src/io.c
deleted file mode 100755
index 1950566..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/src/io.c
+++ /dev/null
@@ -1,1141 +0,0 @@
-/* io.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef _WIN32_WCE
-    /* On WinCE winsock2.h must be included before windows.h for socket stuff */
-    #include 
-#endif
-
-#include 
-#include 
-
-
-/* if user writes own I/O callbacks they can define WOLFSSL_USER_IO to remove
-   automatic setting of default I/O functions EmbedSend() and EmbedReceive()
-   but they'll still need SetCallback xxx() at end of file 
-*/
-#ifndef WOLFSSL_USER_IO
-
-#ifdef HAVE_LIBZ
-    #include "zlib.h"
-#endif
-
-#ifndef USE_WINDOWS_API
-    #ifdef WOLFSSL_LWIP
-        /* lwIP needs to be configured to use sockets API in this mode */
-        /* LWIP_SOCKET 1 in lwip/opt.h or in build */
-        #include "lwip/sockets.h"
-        #include 
-        #ifndef LWIP_PROVIDE_ERRNO
-            #define LWIP_PROVIDE_ERRNO 1
-        #endif
-    #elif defined(FREESCALE_MQX)
-        #include 
-        #include 
-    #elif defined(WOLFSSL_MDK_ARM)
-        #if defined(WOLFSSL_MDK5)
-            #include "cmsis_os.h"
-            #include "rl_fs.h" 
-            #include "rl_net.h" 
-        #else
-            #include 
-        #endif
-        #undef RNG
-        #include "WOLFSSL_MDK_ARM.h"
-        #undef RNG
-        #define RNG wolfSSL_RNG 
-        /* for avoiding name conflict in "stm32f2xx.h" */
-        static int errno;
-    #elif defined(WOLFSSL_TIRTOS)
-        #include 
-    #elif defined(WOLFSSL_IAR_ARM)
-        /* nothing */
-    #else
-        #include 
-        #include 
-        #ifndef EBSNET
-            #include 
-        #endif
-        #include 
-        #if !(defined(DEVKITPRO) || defined(HAVE_RTP_SYS) || defined(EBSNET)) \
-            && !(defined(WOLFSSL_PICOTCP))
-            #include 
-            #include 
-            #include 
-            #include 
-            #ifdef __PPU
-                #include 
-            #else
-                #include 
-            #endif
-        #endif
-        #ifdef HAVE_RTP_SYS
-            #include 
-        #endif
-        #ifdef EBSNET
-            #include "rtipapi.h"  /* errno */
-            #include "socket.h"
-        #endif
-    #endif
-#endif /* USE_WINDOWS_API */
-
-#ifdef __sun
-    #include 
-#endif
-
-#ifdef USE_WINDOWS_API 
-    /* no epipe yet */
-    #ifndef WSAEPIPE
-        #define WSAEPIPE       -12345
-    #endif
-    #define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
-    #define SOCKET_EAGAIN      WSAETIMEDOUT
-    #define SOCKET_ECONNRESET  WSAECONNRESET
-    #define SOCKET_EINTR       WSAEINTR
-    #define SOCKET_EPIPE       WSAEPIPE
-    #define SOCKET_ECONNREFUSED WSAENOTCONN
-    #define SOCKET_ECONNABORTED WSAECONNABORTED
-    #define close(s) closesocket(s)
-#elif defined(__PPU)
-    #define SOCKET_EWOULDBLOCK SYS_NET_EWOULDBLOCK
-    #define SOCKET_EAGAIN      SYS_NET_EAGAIN
-    #define SOCKET_ECONNRESET  SYS_NET_ECONNRESET
-    #define SOCKET_EINTR       SYS_NET_EINTR
-    #define SOCKET_EPIPE       SYS_NET_EPIPE
-    #define SOCKET_ECONNREFUSED SYS_NET_ECONNREFUSED
-    #define SOCKET_ECONNABORTED SYS_NET_ECONNABORTED
-#elif defined(FREESCALE_MQX)
-    /* RTCS doesn't have an EWOULDBLOCK error */
-    #define SOCKET_EWOULDBLOCK EAGAIN
-    #define SOCKET_EAGAIN      EAGAIN
-    #define SOCKET_ECONNRESET  RTCSERR_TCP_CONN_RESET
-    #define SOCKET_EINTR       EINTR
-    #define SOCKET_EPIPE       EPIPE
-    #define SOCKET_ECONNREFUSED RTCSERR_TCP_CONN_REFUSED
-    #define SOCKET_ECONNABORTED RTCSERR_TCP_CONN_ABORTED
-#elif defined(WOLFSSL_MDK_ARM)
-    #if defined(WOLFSSL_MDK5)
-        #define SOCKET_EWOULDBLOCK BSD_ERROR_WOULDBLOCK
-        #define SOCKET_EAGAIN      BSD_ERROR_LOCKED
-        #define SOCKET_ECONNRESET  BSD_ERROR_CLOSED
-        #define SOCKET_EINTR       BSD_ERROR
-        #define SOCKET_EPIPE       BSD_ERROR
-        #define SOCKET_ECONNREFUSED BSD_ERROR
-        #define SOCKET_ECONNABORTED BSD_ERROR
-    #else
-        #define SOCKET_EWOULDBLOCK SCK_EWOULDBLOCK
-        #define SOCKET_EAGAIN      SCK_ELOCKED
-        #define SOCKET_ECONNRESET  SCK_ECLOSED
-        #define SOCKET_EINTR       SCK_ERROR
-        #define SOCKET_EPIPE       SCK_ERROR
-        #define SOCKET_ECONNREFUSED SCK_ERROR
-        #define SOCKET_ECONNABORTED SCK_ERROR
-    #endif
-#elif defined(WOLFSSL_PICOTCP)
-    #define SOCKET_EWOULDBLOCK  PICO_ERR_EAGAIN
-    #define SOCKET_EAGAIN       PICO_ERR_EAGAIN
-    #define SOCKET_ECONNRESET   PICO_ERR_ECONNRESET
-    #define SOCKET_EINTR        PICO_ERR_EINTR
-    #define SOCKET_EPIPE        PICO_ERR_EIO
-    #define SOCKET_ECONNREFUSED PICO_ERR_ECONNREFUSED
-    #define SOCKET_ECONNABORTED PICO_ERR_ESHUTDOWN
-#else
-    #define SOCKET_EWOULDBLOCK EWOULDBLOCK
-    #define SOCKET_EAGAIN      EAGAIN
-    #define SOCKET_ECONNRESET  ECONNRESET
-    #define SOCKET_EINTR       EINTR
-    #define SOCKET_EPIPE       EPIPE
-    #define SOCKET_ECONNREFUSED ECONNREFUSED
-    #define SOCKET_ECONNABORTED ECONNABORTED
-#endif /* USE_WINDOWS_API */
-
-
-#ifdef DEVKITPRO
-    /* from network.h */
-    int net_send(int, const void*, int, unsigned int);
-    int net_recv(int, void*, int, unsigned int);
-    #define SEND_FUNCTION net_send
-    #define RECV_FUNCTION net_recv
-#elif defined(WOLFSSL_LWIP)
-    #define SEND_FUNCTION lwip_send
-    #define RECV_FUNCTION lwip_recv
-#elif defined(WOLFSSL_PICOTCP)
-    #define SEND_FUNCTION pico_send
-    #define RECV_FUNCTION pico_recv
-#else
-    #define SEND_FUNCTION send
-    #define RECV_FUNCTION recv
-#endif
-
-
-/* Translates return codes returned from 
- * send() and recv() if need be. 
- */
-static INLINE int TranslateReturnCode(int old, int sd)
-{
-    (void)sd;
-
-#ifdef FREESCALE_MQX
-    if (old == 0) {
-        errno = SOCKET_EWOULDBLOCK;
-        return -1;  /* convert to BSD style wouldblock as error */
-    }
-
-    if (old < 0) {
-        errno = RTCS_geterror(sd);
-        if (errno == RTCSERR_TCP_CONN_CLOSING)
-            return 0;   /* convert to BSD style closing */
-    }
-#endif
-
-    return old;
-}
-
-static INLINE int LastError(void)
-{
-#ifdef USE_WINDOWS_API 
-    return WSAGetLastError();
-#elif defined(EBSNET)
-    return xn_getlasterror();
-#else
-    return errno;
-#endif
-}
-
-/* The receive embedded callback
- *  return : nb bytes read, or error
- */
-int EmbedReceive(WOLFSSL *ssl, char *buf, int sz, void *ctx)
-{
-    int recvd;
-    int err;
-    int sd = *(int*)ctx;
-
-#ifdef WOLFSSL_DTLS
-    {
-        int dtls_timeout = wolfSSL_dtls_get_current_timeout(ssl);
-        if (wolfSSL_dtls(ssl)
-                     && !wolfSSL_get_using_nonblock(ssl)
-                     && dtls_timeout != 0) {
-            #ifdef USE_WINDOWS_API
-                DWORD timeout = dtls_timeout * 1000;
-            #else
-                struct timeval timeout;
-                XMEMSET(&timeout, 0, sizeof(timeout));
-                timeout.tv_sec = dtls_timeout;
-            #endif
-            if (setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout,
-                           sizeof(timeout)) != 0) {
-                WOLFSSL_MSG("setsockopt rcvtimeo failed");
-            }
-        }
-    }
-#endif
-
-    recvd = (int)RECV_FUNCTION(sd, buf, sz, ssl->rflags);
-
-    recvd = TranslateReturnCode(recvd, sd);
-
-    if (recvd < 0) {
-        err = LastError();
-        WOLFSSL_MSG("Embed Receive error");
-
-        if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
-            if (!wolfSSL_dtls(ssl) || wolfSSL_get_using_nonblock(ssl)) {
-                WOLFSSL_MSG("    Would block");
-                return WOLFSSL_CBIO_ERR_WANT_READ;
-            }
-            else {
-                WOLFSSL_MSG("    Socket timeout");
-                return WOLFSSL_CBIO_ERR_TIMEOUT;
-            }
-        }
-        else if (err == SOCKET_ECONNRESET) {
-            WOLFSSL_MSG("    Connection reset");
-            return WOLFSSL_CBIO_ERR_CONN_RST;
-        }
-        else if (err == SOCKET_EINTR) {
-            WOLFSSL_MSG("    Socket interrupted");
-            return WOLFSSL_CBIO_ERR_ISR;
-        }
-        else if (err == SOCKET_ECONNREFUSED) {
-            WOLFSSL_MSG("    Connection refused");
-            return WOLFSSL_CBIO_ERR_WANT_READ;
-        }
-        else if (err == SOCKET_ECONNABORTED) {
-            WOLFSSL_MSG("    Connection aborted");
-            return WOLFSSL_CBIO_ERR_CONN_CLOSE;
-        }
-        else {
-            WOLFSSL_MSG("    General error");
-            return WOLFSSL_CBIO_ERR_GENERAL;
-        }
-    }
-    else if (recvd == 0) {
-        WOLFSSL_MSG("Embed receive connection closed");
-        return WOLFSSL_CBIO_ERR_CONN_CLOSE;
-    }
-
-    return recvd;
-}
-
-/* The send embedded callback
- *  return : nb bytes sent, or error
- */
-int EmbedSend(WOLFSSL* ssl, char *buf, int sz, void *ctx)
-{
-    int sd = *(int*)ctx;
-    int sent;
-    int len = sz;
-    int err;
-
-    sent = (int)SEND_FUNCTION(sd, &buf[sz - len], len, ssl->wflags);
-
-    if (sent < 0) {
-        err = LastError();
-        WOLFSSL_MSG("Embed Send error");
-
-        if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
-            WOLFSSL_MSG("    Would Block");
-            return WOLFSSL_CBIO_ERR_WANT_WRITE;
-        }
-        else if (err == SOCKET_ECONNRESET) {
-            WOLFSSL_MSG("    Connection reset");
-            return WOLFSSL_CBIO_ERR_CONN_RST;
-        }
-        else if (err == SOCKET_EINTR) {
-            WOLFSSL_MSG("    Socket interrupted");
-            return WOLFSSL_CBIO_ERR_ISR;
-        }
-        else if (err == SOCKET_EPIPE) {
-            WOLFSSL_MSG("    Socket EPIPE");
-            return WOLFSSL_CBIO_ERR_CONN_CLOSE;
-        }
-        else {
-            WOLFSSL_MSG("    General error");
-            return WOLFSSL_CBIO_ERR_GENERAL;
-        }
-    }
- 
-    return sent;
-}
-
-
-#ifdef WOLFSSL_DTLS
-
-#include 
-
-#ifdef USE_WINDOWS_API
-   #define XSOCKLENT int
-#else
-   #define XSOCKLENT socklen_t
-#endif
-
-#define SENDTO_FUNCTION sendto
-#define RECVFROM_FUNCTION recvfrom
-
-
-/* The receive embedded callback
- *  return : nb bytes read, or error
- */
-int EmbedReceiveFrom(WOLFSSL *ssl, char *buf, int sz, void *ctx)
-{
-    WOLFSSL_DTLS_CTX* dtlsCtx = (WOLFSSL_DTLS_CTX*)ctx;
-    int recvd;
-    int err;
-    int sd = dtlsCtx->fd;
-    int dtls_timeout = wolfSSL_dtls_get_current_timeout(ssl);
-    struct sockaddr_storage peer;
-    XSOCKLENT peerSz = sizeof(peer);
-
-    WOLFSSL_ENTER("EmbedReceiveFrom()");
-
-    if (!wolfSSL_get_using_nonblock(ssl) && dtls_timeout != 0) {
-        #ifdef USE_WINDOWS_API
-            DWORD timeout = dtls_timeout * 1000;
-        #else
-            struct timeval timeout;
-            XMEMSET(&timeout, 0, sizeof(timeout));
-            timeout.tv_sec = dtls_timeout;
-        #endif
-        if (setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout,
-                       sizeof(timeout)) != 0) {
-                WOLFSSL_MSG("setsockopt rcvtimeo failed");
-        }
-    }
-
-    recvd = (int)RECVFROM_FUNCTION(sd, buf, sz, ssl->rflags,
-                                  (struct sockaddr*)&peer, &peerSz);
-
-    recvd = TranslateReturnCode(recvd, sd);
-
-    if (recvd < 0) {
-        err = LastError();
-        WOLFSSL_MSG("Embed Receive From error");
-
-        if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
-            if (wolfSSL_get_using_nonblock(ssl)) {
-                WOLFSSL_MSG("    Would block");
-                return WOLFSSL_CBIO_ERR_WANT_READ;
-            }
-            else {
-                WOLFSSL_MSG("    Socket timeout");
-                return WOLFSSL_CBIO_ERR_TIMEOUT;
-            }
-        }
-        else if (err == SOCKET_ECONNRESET) {
-            WOLFSSL_MSG("    Connection reset");
-            return WOLFSSL_CBIO_ERR_CONN_RST;
-        }
-        else if (err == SOCKET_EINTR) {
-            WOLFSSL_MSG("    Socket interrupted");
-            return WOLFSSL_CBIO_ERR_ISR;
-        }
-        else if (err == SOCKET_ECONNREFUSED) {
-            WOLFSSL_MSG("    Connection refused");
-            return WOLFSSL_CBIO_ERR_WANT_READ;
-        }
-        else {
-            WOLFSSL_MSG("    General error");
-            return WOLFSSL_CBIO_ERR_GENERAL;
-        }
-    }
-    else {
-        if (dtlsCtx->peer.sz > 0
-                && peerSz != (XSOCKLENT)dtlsCtx->peer.sz
-                && memcmp(&peer, dtlsCtx->peer.sa, peerSz) != 0) {
-            WOLFSSL_MSG("    Ignored packet from invalid peer");
-            return WOLFSSL_CBIO_ERR_WANT_READ;
-        }
-    }
-
-    return recvd;
-}
-
-
-/* The send embedded callback
- *  return : nb bytes sent, or error
- */
-int EmbedSendTo(WOLFSSL* ssl, char *buf, int sz, void *ctx)
-{
-    WOLFSSL_DTLS_CTX* dtlsCtx = (WOLFSSL_DTLS_CTX*)ctx;
-    int sd = dtlsCtx->fd;
-    int sent;
-    int len = sz;
-    int err;
-
-    WOLFSSL_ENTER("EmbedSendTo()");
-
-    sent = (int)SENDTO_FUNCTION(sd, &buf[sz - len], len, ssl->wflags,
-                                (const struct sockaddr*)dtlsCtx->peer.sa,
-                                dtlsCtx->peer.sz);
-    if (sent < 0) {
-        err = LastError();
-        WOLFSSL_MSG("Embed Send To error");
-
-        if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
-            WOLFSSL_MSG("    Would Block");
-            return WOLFSSL_CBIO_ERR_WANT_WRITE;
-        }
-        else if (err == SOCKET_ECONNRESET) {
-            WOLFSSL_MSG("    Connection reset");
-            return WOLFSSL_CBIO_ERR_CONN_RST;
-        }
-        else if (err == SOCKET_EINTR) {
-            WOLFSSL_MSG("    Socket interrupted");
-            return WOLFSSL_CBIO_ERR_ISR;
-        }
-        else if (err == SOCKET_EPIPE) {
-            WOLFSSL_MSG("    Socket EPIPE");
-            return WOLFSSL_CBIO_ERR_CONN_CLOSE;
-        }
-        else {
-            WOLFSSL_MSG("    General error");
-            return WOLFSSL_CBIO_ERR_GENERAL;
-        }
-    }
- 
-    return sent;
-}
-
-
-/* The DTLS Generate Cookie callback
- *  return : number of bytes copied into buf, or error
- */
-int EmbedGenerateCookie(WOLFSSL* ssl, byte *buf, int sz, void *ctx)
-{
-    int sd = ssl->wfd;
-    struct sockaddr_storage peer;
-    XSOCKLENT peerSz = sizeof(peer);
-    byte digest[SHA_DIGEST_SIZE];
-    int  ret = 0;
-
-    (void)ctx;
-
-    XMEMSET(&peer, 0, sizeof(peer));
-    if (getpeername(sd, (struct sockaddr*)&peer, &peerSz) != 0) {
-        WOLFSSL_MSG("getpeername failed in EmbedGenerateCookie");
-        return GEN_COOKIE_E;
-    }
-
-    ret = wc_ShaHash((byte*)&peer, peerSz, digest);
-    if (ret != 0)
-        return ret;
-
-    if (sz > SHA_DIGEST_SIZE)
-        sz = SHA_DIGEST_SIZE;
-    XMEMCPY(buf, digest, sz);
-
-    return sz;
-}
-
-#endif /* WOLFSSL_DTLS */
-
-#ifdef HAVE_OCSP
-
-
-static int Word16ToString(char* d, word16 number)
-{
-    int i = 0;
-
-    if (d != NULL) {
-        word16 order = 10000;
-        word16 digit;
-
-        if (number == 0) {
-            d[i++] = '0';
-        }
-        else {
-            while (order) {
-                digit = number / order;
-                if (i > 0 || digit != 0) {
-                    d[i++] = (char)digit + '0';
-                }
-                if (digit != 0)
-                    number %= digit * order;
-                if (order > 1)
-                    order /= 10;
-                else
-                    order = 0;
-            }
-        }
-        d[i] = 0;
-    }
-
-    return i;
-}
-
-
-static int tcp_connect(SOCKET_T* sockfd, const char* ip, word16 port)
-{
-    struct sockaddr_storage addr;
-    int sockaddr_len = sizeof(struct sockaddr_in);
-    XMEMSET(&addr, 0, sizeof(addr));
-
-    #ifdef HAVE_GETADDRINFO
-    {
-        struct addrinfo hints;
-        struct addrinfo* answer = NULL;
-        char strPort[6];
-
-        XMEMSET(&hints, 0, sizeof(hints));
-        hints.ai_family = AF_UNSPEC;
-        hints.ai_socktype = SOCK_STREAM;
-        hints.ai_protocol = IPPROTO_TCP;
-
-        if (Word16ToString(strPort, port) == 0) {
-            WOLFSSL_MSG("invalid port number for OCSP responder");
-            return -1;
-        }
-
-        if (getaddrinfo(ip, strPort, &hints, &answer) < 0 || answer == NULL) {
-            WOLFSSL_MSG("no addr info for OCSP responder");
-            return -1;
-        }
-
-        sockaddr_len = answer->ai_addrlen;
-        XMEMCPY(&addr, answer->ai_addr, sockaddr_len);
-        freeaddrinfo(answer);
-
-    }
-    #else /* HAVE_GETADDRINFO */
-    {
-        struct hostent* entry = gethostbyname(ip);
-        struct sockaddr_in *sin = (struct sockaddr_in *)&addr;
-
-        if (entry) {
-            sin->sin_family = AF_INET;
-            sin->sin_port = htons(port);
-            XMEMCPY(&sin->sin_addr.s_addr, entry->h_addr_list[0],
-                                                               entry->h_length);
-        }
-        else {
-            WOLFSSL_MSG("no addr info for OCSP responder");
-            return -1;
-        }
-    }
-    #endif /* HAVE_GETADDRINFO */
-
-    *sockfd = socket(addr.ss_family, SOCK_STREAM, 0);
-
-#ifdef USE_WINDOWS_API
-    if (*sockfd == INVALID_SOCKET) {
-        WOLFSSL_MSG("bad socket fd, out of fds?");
-        return -1;
-    }
-#else
-     if (*sockfd < 0) {
-         WOLFSSL_MSG("bad socket fd, out of fds?");
-         return -1;
-     }
-#endif
-
-    if (connect(*sockfd, (struct sockaddr *)&addr, sockaddr_len) != 0) {
-        WOLFSSL_MSG("OCSP responder tcp connect failed");
-        return -1;
-    }
-
-    return 0;
-}
-
-
-static int build_http_request(const char* domainName, const char* path,
-                                    int ocspReqSz, byte* buf, int bufSize)
-{
-    word32 domainNameLen, pathLen, ocspReqSzStrLen, completeLen;
-    char ocspReqSzStr[6];
-
-    domainNameLen = (word32)XSTRLEN(domainName);
-    pathLen = (word32)XSTRLEN(path);
-    ocspReqSzStrLen = Word16ToString(ocspReqSzStr, (word16)ocspReqSz);
-
-    completeLen = domainNameLen + pathLen + ocspReqSzStrLen + 84;
-    if (completeLen > (word32)bufSize)
-        return 0;
-
-    XSTRNCPY((char*)buf, "POST ", 5);
-    buf += 5;
-    XSTRNCPY((char*)buf, path, pathLen);
-    buf += pathLen;
-    XSTRNCPY((char*)buf, " HTTP/1.1\r\nHost: ", 17);
-    buf += 17;
-    XSTRNCPY((char*)buf, domainName, domainNameLen);
-    buf += domainNameLen;
-    XSTRNCPY((char*)buf, "\r\nContent-Length: ", 18);
-    buf += 18;
-    XSTRNCPY((char*)buf, ocspReqSzStr, ocspReqSzStrLen);
-    buf += ocspReqSzStrLen;
-    XSTRNCPY((char*)buf,
-                      "\r\nContent-Type: application/ocsp-request\r\n\r\n", 44);
-
-    return completeLen;
-}
-
-
-static int decode_url(const char* url, int urlSz,
-    char* outName, char* outPath, word16* outPort)
-{
-    int result = -1;
-
-    if (outName != NULL && outPath != NULL && outPort != NULL)
-    {
-        if (url == NULL || urlSz == 0)
-        {
-            *outName = 0;
-            *outPath = 0;
-            *outPort = 0;
-        }
-        else
-        {
-            int i, cur;
-    
-            /* need to break the url down into scheme, address, and port */
-            /*     "http://example.com:8080/" */
-            /*     "http://[::1]:443/"        */
-            if (XSTRNCMP(url, "http://", 7) == 0) {
-                cur = 7;
-            } else cur = 0;
-    
-            i = 0;
-            if (url[cur] == '[') {
-                cur++;
-                /* copy until ']' */
-                while (url[cur] != 0 && url[cur] != ']' && cur < urlSz) {
-                    outName[i++] = url[cur++];
-                }
-                cur++; /* skip ']' */
-            }
-            else {
-                while (url[cur] != 0 && url[cur] != ':' &&
-                                               url[cur] != '/' && cur < urlSz) {
-                    outName[i++] = url[cur++];
-                }
-            }
-            outName[i] = 0;
-            /* Need to pick out the path after the domain name */
-    
-            if (cur < urlSz && url[cur] == ':') {
-                char port[6];
-                int j;
-                word32 bigPort = 0;
-                i = 0;
-                cur++;
-                while (cur < urlSz && url[cur] != 0 && url[cur] != '/' &&
-                        i < 6) {
-                    port[i++] = url[cur++];
-                }
-    
-                for (j = 0; j < i; j++) {
-                    if (port[j] < '0' || port[j] > '9') return -1;
-                    bigPort = (bigPort * 10) + (port[j] - '0');
-                }
-                *outPort = (word16)bigPort;
-            }
-            else
-                *outPort = 80;
-    
-            if (cur < urlSz && url[cur] == '/') {
-                i = 0;
-                while (cur < urlSz && url[cur] != 0 && i < 80) {
-                    outPath[i++] = url[cur++];
-                }
-                outPath[i] = 0;
-            }
-            else {
-                outPath[0] = '/';
-                outPath[1] = 0;
-            }
-            result = 0;
-        }
-    }
-
-    return result;
-}
-
-
-/* return: >0 OCSP Response Size
- *         -1 error */
-static int process_http_response(int sfd, byte** respBuf,
-                                                  byte* httpBuf, int httpBufSz)
-{
-    int result;
-    int len = 0;
-    char *start, *end;
-    byte *recvBuf = NULL;
-    int recvBufSz = 0;
-    enum phr_state { phr_init, phr_http_start, phr_have_length,
-                     phr_have_type, phr_wait_end, phr_http_end
-    } state = phr_init;
-
-    start = end = NULL;
-    do {
-        if (end == NULL) {
-            result = (int)recv(sfd, (char*)httpBuf+len, httpBufSz-len-1, 0);
-            if (result > 0) {
-                len += result;
-                start = (char*)httpBuf;
-                start[len] = 0;
-            }
-            else {
-                WOLFSSL_MSG("process_http_response recv http from peer failed");
-                return -1;
-            }
-        }
-        end = XSTRSTR(start, "\r\n");
-
-        if (end == NULL) {
-            if (len != 0)
-                XMEMMOVE(httpBuf, start, len);
-            start = end = NULL;
-        }
-        else if (end == start) {
-            if (state == phr_wait_end) {
-                state = phr_http_end;
-                len -= 2;
-                start += 2;
-             }
-             else {
-                WOLFSSL_MSG("process_http_response header ended early");
-                return -1;
-             }
-        }
-        else {
-            *end = 0;
-            len -= (int)(end - start) + 2;
-                /* adjust len to remove the first line including the /r/n */
-
-            if (XSTRNCASECMP(start, "HTTP/1", 6) == 0) {
-                start += 9;
-                if (XSTRNCASECMP(start, "200 OK", 6) != 0 ||
-                                                           state != phr_init) {
-                    WOLFSSL_MSG("process_http_response not OK");
-                    return -1;
-                }
-                state = phr_http_start;
-            }
-            else if (XSTRNCASECMP(start, "Content-Type:", 13) == 0) {
-                start += 13;
-                while (*start == ' ' && *start != '\0') start++;
-                if (XSTRNCASECMP(start, "application/ocsp-response", 25) != 0) {
-                    WOLFSSL_MSG("process_http_response not ocsp-response");
-                    return -1;
-                }
-                
-                if (state == phr_http_start) state = phr_have_type;
-                else if (state == phr_have_length) state = phr_wait_end;
-                else {
-                    WOLFSSL_MSG("process_http_response type invalid state");
-                    return -1;
-                }
-            }
-            else if (XSTRNCASECMP(start, "Content-Length:", 15) == 0) {
-                start += 15;
-                while (*start == ' ' && *start != '\0') start++;
-                recvBufSz = atoi(start);
-
-                if (state == phr_http_start) state = phr_have_length;
-                else if (state == phr_have_type) state = phr_wait_end;
-                else {
-                    WOLFSSL_MSG("process_http_response length invalid state");
-                    return -1;
-                }
-            }
-            
-            start = end + 2;
-        }
-    } while (state != phr_http_end);
-
-    recvBuf = (byte*)XMALLOC(recvBufSz, NULL, DYNAMIC_TYPE_IN_BUFFER);
-    if (recvBuf == NULL) {
-        WOLFSSL_MSG("process_http_response couldn't create response buffer");
-        return -1;
-    }
-
-    /* copy the remainder of the httpBuf into the respBuf */
-    if (len != 0)
-        XMEMCPY(recvBuf, start, len);
-
-    /* receive the OCSP response data */
-    do {
-        result = (int)recv(sfd, (char*)recvBuf+len, recvBufSz-len, 0);
-        if (result > 0)
-            len += result;
-        else {
-            WOLFSSL_MSG("process_http_response recv ocsp from peer failed");
-            return -1;
-        }
-    } while (len != recvBufSz);
-
-    *respBuf = recvBuf;
-    return recvBufSz;
-}
-
-
-#define SCRATCH_BUFFER_SIZE 512
-
-int EmbedOcspLookup(void* ctx, const char* url, int urlSz,
-                        byte* ocspReqBuf, int ocspReqSz, byte** ocspRespBuf)
-{
-    SOCKET_T sfd = 0;
-    word16   port;
-    int      ret = -1;
-#ifdef WOLFSSL_SMALL_STACK
-    char*    path;
-    char*    domainName;
-#else
-    char     path[80];
-    char     domainName[80];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    path = (char*)XMALLOC(80, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (path == NULL)
-        return -1;
-    
-    domainName = (char*)XMALLOC(80, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (domainName == NULL) {
-        XFREE(path, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return -1;
-    }
-#endif
-
-    (void)ctx;
-
-    if (ocspReqBuf == NULL || ocspReqSz == 0) {
-        WOLFSSL_MSG("OCSP request is required for lookup");
-    }
-    else if (ocspRespBuf == NULL) {
-        WOLFSSL_MSG("Cannot save OCSP response");
-    }
-    else if (decode_url(url, urlSz, domainName, path, &port) < 0) {
-        WOLFSSL_MSG("Unable to decode OCSP URL");
-    }
-    else {
-        /* Note, the library uses the EmbedOcspRespFree() callback to
-         * free this buffer. */
-        int   httpBufSz = SCRATCH_BUFFER_SIZE;
-        byte* httpBuf   = (byte*)XMALLOC(httpBufSz, NULL, 
-                                                        DYNAMIC_TYPE_IN_BUFFER);
-
-        if (httpBuf == NULL) {
-            WOLFSSL_MSG("Unable to create OCSP response buffer");
-        }
-        else {
-            httpBufSz = build_http_request(domainName, path, ocspReqSz,
-                                                            httpBuf, httpBufSz);
-
-            if ((tcp_connect(&sfd, domainName, port) != 0) || (sfd <= 0)) {
-                WOLFSSL_MSG("OCSP Responder connection failed");
-            }
-            else if ((int)send(sfd, (char*)httpBuf, httpBufSz, 0) !=
-                                                                    httpBufSz) {
-                WOLFSSL_MSG("OCSP http request failed");
-            }
-            else if ((int)send(sfd, (char*)ocspReqBuf, ocspReqSz, 0) !=
-                                                                    ocspReqSz) {
-                WOLFSSL_MSG("OCSP ocsp request failed");
-            }
-            else {
-                ret = process_http_response(sfd, ocspRespBuf, httpBuf,
-                                                           SCRATCH_BUFFER_SIZE);
-            }
-
-            close(sfd);
-            XFREE(httpBuf, NULL, DYNAMIC_TYPE_IN_BUFFER);
-        }
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(path,       NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(domainName, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-void EmbedOcspRespFree(void* ctx, byte *resp)
-{
-    (void)ctx;
-
-    if (resp)
-        XFREE(resp, NULL, DYNAMIC_TYPE_IN_BUFFER);
-}
-
-
-#endif
-
-#endif /* WOLFSSL_USER_IO */
-
-WOLFSSL_API void wolfSSL_SetIORecv(WOLFSSL_CTX *ctx, CallbackIORecv CBIORecv)
-{
-    ctx->CBIORecv = CBIORecv;
-}
-
-
-WOLFSSL_API void wolfSSL_SetIOSend(WOLFSSL_CTX *ctx, CallbackIOSend CBIOSend)
-{
-    ctx->CBIOSend = CBIOSend;
-}
-
-
-WOLFSSL_API void wolfSSL_SetIOReadCtx(WOLFSSL* ssl, void *rctx)
-{
-	ssl->IOCB_ReadCtx = rctx;
-}
-
-
-WOLFSSL_API void wolfSSL_SetIOWriteCtx(WOLFSSL* ssl, void *wctx)
-{
-	ssl->IOCB_WriteCtx = wctx;
-}
-
-
-WOLFSSL_API void* wolfSSL_GetIOReadCtx(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->IOCB_ReadCtx;
-
-    return NULL;
-}
-
-
-WOLFSSL_API void* wolfSSL_GetIOWriteCtx(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->IOCB_WriteCtx;
-
-    return NULL;
-}
-
-
-WOLFSSL_API void wolfSSL_SetIOReadFlags(WOLFSSL* ssl, int flags)
-{
-    ssl->rflags = flags; 
-}
-
-
-WOLFSSL_API void wolfSSL_SetIOWriteFlags(WOLFSSL* ssl, int flags)
-{
-    ssl->wflags = flags;
-}
-
-
-#ifdef WOLFSSL_DTLS
-
-WOLFSSL_API void wolfSSL_CTX_SetGenCookie(WOLFSSL_CTX* ctx, CallbackGenCookie cb)
-{
-    ctx->CBIOCookie = cb;
-}
-
-
-WOLFSSL_API void wolfSSL_SetCookieCtx(WOLFSSL* ssl, void *ctx)
-{
-	ssl->IOCB_CookieCtx = ctx;
-}
-
-
-WOLFSSL_API void* wolfSSL_GetCookieCtx(WOLFSSL* ssl)
-{
-    if (ssl)
-	    return ssl->IOCB_CookieCtx;
-
-    return NULL;
-}
-
-#endif /* WOLFSSL_DTLS */
-
-
-#ifdef HAVE_NETX
-
-/* The NetX receive callback
- *  return :  bytes read, or error
- */
-int NetX_Receive(WOLFSSL *ssl, char *buf, int sz, void *ctx)
-{
-    NetX_Ctx* nxCtx = (NetX_Ctx*)ctx;
-    ULONG left;
-    ULONG total;
-    ULONG copied = 0;
-    UINT  status;
-
-    if (nxCtx == NULL || nxCtx->nxSocket == NULL) {
-        WOLFSSL_MSG("NetX Recv NULL parameters");
-        return WOLFSSL_CBIO_ERR_GENERAL;
-    }
-
-    if (nxCtx->nxPacket == NULL) {
-        status = nx_tcp_socket_receive(nxCtx->nxSocket, &nxCtx->nxPacket,
-                                       nxCtx->nxWait);
-        if (status != NX_SUCCESS) {
-            WOLFSSL_MSG("NetX Recv receive error");
-            return WOLFSSL_CBIO_ERR_GENERAL;
-        }
-    }
-
-    if (nxCtx->nxPacket) {
-        status = nx_packet_length_get(nxCtx->nxPacket, &total);
-        if (status != NX_SUCCESS) {
-            WOLFSSL_MSG("NetX Recv length get error");
-            return WOLFSSL_CBIO_ERR_GENERAL;
-        }
-
-        left = total - nxCtx->nxOffset;
-        status = nx_packet_data_extract_offset(nxCtx->nxPacket, nxCtx->nxOffset,
-                                               buf, sz, &copied);
-        if (status != NX_SUCCESS) {
-            WOLFSSL_MSG("NetX Recv data extract offset error");
-            return WOLFSSL_CBIO_ERR_GENERAL;
-        }
-
-        nxCtx->nxOffset += copied;
-
-        if (copied == left) {
-            WOLFSSL_MSG("NetX Recv Drained packet");
-            nx_packet_release(nxCtx->nxPacket);
-            nxCtx->nxPacket = NULL;
-            nxCtx->nxOffset = 0;
-        }
-    }
-
-    return copied;
-}
-
-
-/* The NetX send callback
- *  return : bytes sent, or error
- */
-int NetX_Send(WOLFSSL* ssl, char *buf, int sz, void *ctx)
-{
-    NetX_Ctx*       nxCtx = (NetX_Ctx*)ctx;
-    NX_PACKET*      packet;
-    NX_PACKET_POOL* pool;   /* shorthand */
-    UINT            status;
-
-    if (nxCtx == NULL || nxCtx->nxSocket == NULL) {
-        WOLFSSL_MSG("NetX Send NULL parameters");
-        return WOLFSSL_CBIO_ERR_GENERAL;
-    }
-
-    pool = nxCtx->nxSocket->nx_tcp_socket_ip_ptr->nx_ip_default_packet_pool;
-    status = nx_packet_allocate(pool, &packet, NX_TCP_PACKET,
-                                nxCtx->nxWait);
-    if (status != NX_SUCCESS) {
-        WOLFSSL_MSG("NetX Send packet alloc error");
-        return WOLFSSL_CBIO_ERR_GENERAL;
-    }
-
-    status = nx_packet_data_append(packet, buf, sz, pool, nxCtx->nxWait);
-    if (status != NX_SUCCESS) {
-        nx_packet_release(packet);
-        WOLFSSL_MSG("NetX Send data append error");
-        return WOLFSSL_CBIO_ERR_GENERAL;
-    }
-
-    status = nx_tcp_socket_send(nxCtx->nxSocket, packet, nxCtx->nxWait);
-    if (status != NX_SUCCESS) {
-        nx_packet_release(packet);
-        WOLFSSL_MSG("NetX Send socket send error");
-        return WOLFSSL_CBIO_ERR_GENERAL;
-    }
-
-    return sz;
-}
-
-
-/* like set_fd, but for default NetX context */
-void wolfSSL_SetIO_NetX(WOLFSSL* ssl, NX_TCP_SOCKET* nxSocket, ULONG waitOption)
-{
-    if (ssl) {
-        ssl->nxCtx.nxSocket = nxSocket;
-        ssl->nxCtx.nxWait   = waitOption;
-    }
-}
-
-#endif /* HAVE_NETX */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/src/keys.c b/FreeRTOS-Plus/Source/WolfSSL/src/keys.c
deleted file mode 100755
index b06debb..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/src/keys.c
+++ /dev/null
@@ -1,2735 +0,0 @@
-/* keys.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/* Name change compatibility layer no longer needs to be included here */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#include 
-#include 
-#if defined(SHOW_SECRETS) || defined(CHACHA_AEAD_TEST)
-    #ifdef FREESCALE_MQX
-        #include 
-    #else
-        #include 
-    #endif
-#endif
-
-
-int SetCipherSpecs(WOLFSSL* ssl)
-{
-#ifndef NO_WOLFSSL_CLIENT
-    if (ssl->options.side == WOLFSSL_CLIENT_END) {
-        /* server side verified before SetCipherSpecs call */
-        if (VerifyClientSuite(ssl) != 1) {
-            WOLFSSL_MSG("SetCipherSpecs() client has an unusuable suite");
-            return UNSUPPORTED_SUITE;
-        }
-    }
-#endif /* NO_WOLFSSL_CLIENT */
-
-    /* Chacha extensions, 0xcc */
-    if (ssl->options.cipherSuite0 == CHACHA_BYTE) {
-    
-    switch (ssl->options.cipherSuite) {
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
-    case TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
-        ssl->specs.bulk_cipher_algorithm = wolfssl_chacha;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = CHACHA20_256_KEY_SIZE;
-        ssl->specs.block_size            = CHACHA20_BLOCK_SIZE;
-        ssl->specs.iv_size               = CHACHA20_IV_SIZE;
-        ssl->specs.aead_mac_size         = POLY1305_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
-    case TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:
-        ssl->specs.bulk_cipher_algorithm = wolfssl_chacha;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = CHACHA20_256_KEY_SIZE;
-        ssl->specs.block_size            = CHACHA20_BLOCK_SIZE;
-        ssl->specs.iv_size               = CHACHA20_IV_SIZE;
-        ssl->specs.aead_mac_size         = POLY1305_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256
-    case TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
-        ssl->specs.bulk_cipher_algorithm = wolfssl_chacha;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = CHACHA20_256_KEY_SIZE;
-        ssl->specs.block_size            = CHACHA20_BLOCK_SIZE;
-        ssl->specs.iv_size               = CHACHA20_IV_SIZE;
-        ssl->specs.aead_mac_size         = POLY1305_AUTH_SZ;
-
-        break;
-#endif
-    default:
-        WOLFSSL_MSG("Unsupported cipher suite, SetCipherSpecs ChaCha");
-        return UNSUPPORTED_SUITE;
-    }
-    }
-
-    /* ECC extensions, or AES-CCM */
-    if (ssl->options.cipherSuite0 == ECC_BYTE) {
-    
-    switch (ssl->options.cipherSuite) {
-
-#ifdef HAVE_ECC
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
-    case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-    break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
-    case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-    break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
-    case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-    break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
-    case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-    break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
-    case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-    break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
-    case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-    break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
-    case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-    break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
-    case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-    break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
-    case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
-    case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
-    case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = DES3_KEY_SIZE;
-        ssl->specs.block_size            = DES_BLOCK_SIZE;
-        ssl->specs.iv_size               = DES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
-    case TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = DES3_KEY_SIZE;
-        ssl->specs.block_size            = DES_BLOCK_SIZE;
-        ssl->specs.iv_size               = DES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_RC4_128_SHA
-    case TLS_ECDHE_RSA_WITH_RC4_128_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_rc4;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = RC4_KEY_SIZE;
-        ssl->specs.iv_size               = 0;
-        ssl->specs.block_size            = 0;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_RC4_128_SHA
-    case TLS_ECDH_RSA_WITH_RC4_128_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_rc4;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = RC4_KEY_SIZE;
-        ssl->specs.iv_size               = 0;
-        ssl->specs.block_size            = 0;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
-    case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = DES3_KEY_SIZE;
-        ssl->specs.block_size            = DES_BLOCK_SIZE;
-        ssl->specs.iv_size               = DES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
-    case TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = DES3_KEY_SIZE;
-        ssl->specs.block_size            = DES_BLOCK_SIZE;
-        ssl->specs.iv_size               = DES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
-    case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_rc4;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = RC4_KEY_SIZE;
-        ssl->specs.iv_size               = 0;
-        ssl->specs.block_size            = 0;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_RC4_128_SHA
-    case TLS_ECDH_ECDSA_WITH_RC4_128_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_rc4;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = RC4_KEY_SIZE;
-        ssl->specs.iv_size               = 0;
-        ssl->specs.block_size            = 0;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
-    case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
-    case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
-    case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
-    case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
-    case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
-    case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
-    case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
-    case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
-    case TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
-    case TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
-    case TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
-    case TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
-    case TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
-    case TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 1;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
-    case TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_CCM_8_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8
-    case TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = ecc_diffie_hellman_kea;
-        ssl->specs.sig_algo              = ecc_dsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_CCM_8_AUTH_SZ;
-
-        break;
-#endif
-#endif /* HAVE_ECC */
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CCM_8
-    case TLS_RSA_WITH_AES_128_CCM_8 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_CCM_8_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CCM_8
-    case TLS_RSA_WITH_AES_256_CCM_8 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_CCM_8_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CCM_8
-    case TLS_PSK_WITH_AES_128_CCM_8 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_CCM_8_AUTH_SZ;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CCM_8
-    case TLS_PSK_WITH_AES_256_CCM_8 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_CCM_8_AUTH_SZ;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CCM
-    case TLS_PSK_WITH_AES_128_CCM :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_CCM_16_AUTH_SZ;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CCM
-    case TLS_PSK_WITH_AES_256_CCM :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_CCM_16_AUTH_SZ;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_CCM
-    case TLS_DHE_PSK_WITH_AES_128_CCM :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = dhe_psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_CCM_16_AUTH_SZ;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_CCM
-    case TLS_DHE_PSK_WITH_AES_256_CCM :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = dhe_psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_CCM_16_AUTH_SZ;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-    default:
-        WOLFSSL_MSG("Unsupported cipher suite, SetCipherSpecs ECC");
-        return UNSUPPORTED_SUITE;
-    }   /* switch */
-    }   /* if     */
-    if (ssl->options.cipherSuite0 != ECC_BYTE && 
-            ssl->options.cipherSuite0 != CHACHA_BYTE) {   /* normal suites */
-    switch (ssl->options.cipherSuite) {
-
-#ifdef BUILD_SSL_RSA_WITH_RC4_128_SHA
-    case SSL_RSA_WITH_RC4_128_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_rc4;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = RC4_KEY_SIZE;
-        ssl->specs.iv_size               = 0;
-        ssl->specs.block_size            = 0;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_RC4_128_SHA
-    case TLS_NTRU_RSA_WITH_RC4_128_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_rc4;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ntru_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = RC4_KEY_SIZE;
-        ssl->specs.iv_size               = 0;
-        ssl->specs.block_size            = 0;
-
-        break;
-#endif
-
-#ifdef BUILD_SSL_RSA_WITH_RC4_128_MD5
-    case SSL_RSA_WITH_RC4_128_MD5 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_rc4;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = md5_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = MD5_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_MD5;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = RC4_KEY_SIZE;
-        ssl->specs.iv_size               = 0;
-        ssl->specs.block_size            = 0;
-
-        break;
-#endif
-
-#ifdef BUILD_SSL_RSA_WITH_3DES_EDE_CBC_SHA
-    case SSL_RSA_WITH_3DES_EDE_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = DES3_KEY_SIZE;
-        ssl->specs.block_size            = DES_BLOCK_SIZE;
-        ssl->specs.iv_size               = DES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA
-    case TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ntru_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = DES3_KEY_SIZE;
-        ssl->specs.block_size            = DES_BLOCK_SIZE;
-        ssl->specs.iv_size               = DES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA
-    case TLS_RSA_WITH_AES_128_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA256
-    case TLS_RSA_WITH_AES_128_CBC_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_NULL_SHA
-    case TLS_RSA_WITH_NULL_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = 0;
-        ssl->specs.block_size            = 0;
-        ssl->specs.iv_size               = 0;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_NULL_SHA256
-    case TLS_RSA_WITH_NULL_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = 0;
-        ssl->specs.block_size            = 0;
-        ssl->specs.iv_size               = 0;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_AES_128_CBC_SHA
-    case TLS_NTRU_RSA_WITH_AES_128_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ntru_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA
-    case TLS_RSA_WITH_AES_256_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA256
-    case TLS_RSA_WITH_AES_256_CBC_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_NTRU_RSA_WITH_AES_256_CBC_SHA
-    case TLS_NTRU_RSA_WITH_AES_256_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = ntru_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_GCM_SHA256
-    case TLS_PSK_WITH_AES_128_GCM_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_GCM_SHA384
-    case TLS_PSK_WITH_AES_256_GCM_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256
-    case TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = dhe_psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384
-    case TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = dhe_psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA256
-    case TLS_PSK_WITH_AES_128_CBC_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA384
-    case TLS_PSK_WITH_AES_256_CBC_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256
-    case TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = dhe_psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384
-    case TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = dhe_psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA
-    case TLS_PSK_WITH_AES_128_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA
-    case TLS_PSK_WITH_AES_256_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_NULL_SHA256
-    case TLS_PSK_WITH_NULL_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = 0;
-        ssl->specs.block_size            = 0;
-        ssl->specs.iv_size               = 0;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_NULL_SHA384
-    case TLS_PSK_WITH_NULL_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = 0;
-        ssl->specs.block_size            = 0;
-        ssl->specs.iv_size               = 0;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_PSK_WITH_NULL_SHA
-    case TLS_PSK_WITH_NULL_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = 0;
-        ssl->specs.block_size            = 0;
-        ssl->specs.iv_size               = 0;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_NULL_SHA256
-    case TLS_DHE_PSK_WITH_NULL_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = dhe_psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = 0;
-        ssl->specs.block_size            = 0;
-        ssl->specs.iv_size               = 0;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_PSK_WITH_NULL_SHA384
-    case TLS_DHE_PSK_WITH_NULL_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = dhe_psk_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = 0;
-        ssl->specs.block_size            = 0;
-        ssl->specs.iv_size               = 0;
-
-        ssl->options.usingPSK_cipher     = 1;
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
-    case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
-    case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA
-    case TLS_DHE_RSA_WITH_AES_128_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA
-    case TLS_DHE_RSA_WITH_AES_256_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_HC_128_MD5
-    case TLS_RSA_WITH_HC_128_MD5 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_hc128;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = md5_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = MD5_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_MD5;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = HC_128_KEY_SIZE;
-        ssl->specs.block_size            = 0;
-        ssl->specs.iv_size               = HC_128_IV_SIZE;
-
-        break;
-#endif
-            
-#ifdef BUILD_TLS_RSA_WITH_HC_128_SHA
-        case TLS_RSA_WITH_HC_128_SHA :
-            ssl->specs.bulk_cipher_algorithm = wolfssl_hc128;
-            ssl->specs.cipher_type           = stream;
-            ssl->specs.mac_algorithm         = sha_mac;
-            ssl->specs.kea                   = rsa_kea;
-            ssl->specs.sig_algo              = rsa_sa_algo;
-            ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-            ssl->specs.pad_size              = PAD_SHA;
-            ssl->specs.static_ecdh           = 0;
-            ssl->specs.key_size              = HC_128_KEY_SIZE;
-            ssl->specs.block_size            = 0;
-            ssl->specs.iv_size               = HC_128_IV_SIZE;
-            
-            break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_HC_128_B2B256
-        case TLS_RSA_WITH_HC_128_B2B256:
-            ssl->specs.bulk_cipher_algorithm = wolfssl_hc128;
-            ssl->specs.cipher_type           = stream;
-            ssl->specs.mac_algorithm         = blake2b_mac;
-            ssl->specs.kea                   = rsa_kea;
-            ssl->specs.sig_algo              = rsa_sa_algo;
-            ssl->specs.hash_size             = BLAKE2B_256;
-            ssl->specs.pad_size              = PAD_SHA;
-            ssl->specs.static_ecdh           = 0;
-            ssl->specs.key_size              = HC_128_KEY_SIZE;
-            ssl->specs.block_size            = 0;
-            ssl->specs.iv_size               = HC_128_IV_SIZE;
-            
-            break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_B2B256
-        case TLS_RSA_WITH_AES_128_CBC_B2B256:
-            ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-            ssl->specs.cipher_type           = block;
-            ssl->specs.mac_algorithm         = blake2b_mac;
-            ssl->specs.kea                   = rsa_kea;
-            ssl->specs.sig_algo              = rsa_sa_algo;
-            ssl->specs.hash_size             = BLAKE2B_256;
-            ssl->specs.pad_size              = PAD_SHA;
-            ssl->specs.static_ecdh           = 0;
-            ssl->specs.key_size              = AES_128_KEY_SIZE;
-            ssl->specs.iv_size               = AES_IV_SIZE;
-            ssl->specs.block_size            = AES_BLOCK_SIZE;
-            
-            break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_B2B256
-        case TLS_RSA_WITH_AES_256_CBC_B2B256:
-            ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-            ssl->specs.cipher_type           = block;
-            ssl->specs.mac_algorithm         = blake2b_mac;
-            ssl->specs.kea                   = rsa_kea;
-            ssl->specs.sig_algo              = rsa_sa_algo;
-            ssl->specs.hash_size             = BLAKE2B_256;
-            ssl->specs.pad_size              = PAD_SHA;
-            ssl->specs.static_ecdh           = 0;
-            ssl->specs.key_size              = AES_256_KEY_SIZE;
-            ssl->specs.iv_size               = AES_IV_SIZE;
-            ssl->specs.block_size            = AES_BLOCK_SIZE;
-            
-            break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_RABBIT_SHA
-    case TLS_RSA_WITH_RABBIT_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_rabbit;
-        ssl->specs.cipher_type           = stream;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = RABBIT_KEY_SIZE;
-        ssl->specs.block_size            = 0;
-        ssl->specs.iv_size               = RABBIT_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_128_GCM_SHA256
-    case TLS_RSA_WITH_AES_128_GCM_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_AES_256_GCM_SHA384
-    case TLS_RSA_WITH_AES_256_GCM_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
-    case TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
-    case TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm;
-        ssl->specs.cipher_type           = aead;
-        ssl->specs.mac_algorithm         = sha384_mac;
-        ssl->specs.kea                   = diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA384_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_256_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AEAD_IMP_IV_SZ;
-        ssl->specs.aead_mac_size         = AES_GCM_AUTH_SZ;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA
-    case TLS_RSA_WITH_CAMELLIA_128_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_camellia;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = CAMELLIA_128_KEY_SIZE;
-        ssl->specs.block_size            = CAMELLIA_BLOCK_SIZE;
-        ssl->specs.iv_size               = CAMELLIA_IV_SIZE;
-
-        break;
-#endif
-    
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA
-    case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_camellia;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = CAMELLIA_256_KEY_SIZE;
-        ssl->specs.block_size            = CAMELLIA_BLOCK_SIZE;
-        ssl->specs.iv_size               = CAMELLIA_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256
-    case TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_camellia;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = CAMELLIA_128_KEY_SIZE;
-        ssl->specs.block_size            = CAMELLIA_BLOCK_SIZE;
-        ssl->specs.iv_size               = CAMELLIA_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256
-    case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_camellia;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = rsa_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = CAMELLIA_256_KEY_SIZE;
-        ssl->specs.block_size            = CAMELLIA_BLOCK_SIZE;
-        ssl->specs.iv_size               = CAMELLIA_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
-    case TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_camellia;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = CAMELLIA_128_KEY_SIZE;
-        ssl->specs.block_size            = CAMELLIA_BLOCK_SIZE;
-        ssl->specs.iv_size               = CAMELLIA_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
-    case TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_camellia;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = CAMELLIA_256_KEY_SIZE;
-        ssl->specs.block_size            = CAMELLIA_BLOCK_SIZE;
-        ssl->specs.iv_size               = CAMELLIA_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
-    case TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_camellia;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = CAMELLIA_128_KEY_SIZE;
-        ssl->specs.block_size            = CAMELLIA_BLOCK_SIZE;
-        ssl->specs.iv_size               = CAMELLIA_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256
-    case TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_camellia;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha256_mac;
-        ssl->specs.kea                   = diffie_hellman_kea;
-        ssl->specs.sig_algo              = rsa_sa_algo;
-        ssl->specs.hash_size             = SHA256_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = CAMELLIA_256_KEY_SIZE;
-        ssl->specs.block_size            = CAMELLIA_BLOCK_SIZE;
-        ssl->specs.iv_size               = CAMELLIA_IV_SIZE;
-
-        break;
-#endif
-
-#ifdef BUILD_TLS_DH_anon_WITH_AES_128_CBC_SHA
-    case TLS_DH_anon_WITH_AES_128_CBC_SHA :
-        ssl->specs.bulk_cipher_algorithm = wolfssl_aes;
-        ssl->specs.cipher_type           = block;
-        ssl->specs.mac_algorithm         = sha_mac;
-        ssl->specs.kea                   = diffie_hellman_kea;
-        ssl->specs.sig_algo              = anonymous_sa_algo;
-        ssl->specs.hash_size             = SHA_DIGEST_SIZE;
-        ssl->specs.pad_size              = PAD_SHA;
-        ssl->specs.static_ecdh           = 0;
-        ssl->specs.key_size              = AES_128_KEY_SIZE;
-        ssl->specs.block_size            = AES_BLOCK_SIZE;
-        ssl->specs.iv_size               = AES_IV_SIZE;
-
-        ssl->options.usingAnon_cipher    = 1;
-        break;
-#endif
-
-    default:
-        WOLFSSL_MSG("Unsupported cipher suite, SetCipherSpecs");
-        return UNSUPPORTED_SUITE;
-    }  /* switch */
-    }  /* if ECC / Normal suites else */
-
-    /* set TLS if it hasn't been turned off */
-    if (ssl->version.major == 3 && ssl->version.minor >= 1) {
-#ifndef NO_TLS
-        ssl->options.tls = 1;
-        ssl->hmac = TLS_hmac;
-        if (ssl->version.minor >= 2)
-            ssl->options.tls1_1 = 1;
-#endif
-    }
-
-#ifdef WOLFSSL_DTLS
-    if (ssl->options.dtls)
-        ssl->hmac = TLS_hmac;
-#endif
-
-    return 0;
-}
-
-
-enum KeyStuff {
-    MASTER_ROUNDS = 3,
-    PREFIX        = 3,     /* up to three letters for master prefix */
-    KEY_PREFIX    = 7      /* up to 7 prefix letters for key rounds */
-
-
-};
-
-#ifndef NO_OLD_TLS
-/* true or false, zero for error */
-static int SetPrefix(byte* sha_input, int idx)
-{
-    switch (idx) {
-    case 0:
-        XMEMCPY(sha_input, "A", 1);
-        break;
-    case 1:
-        XMEMCPY(sha_input, "BB", 2);
-        break;
-    case 2:
-        XMEMCPY(sha_input, "CCC", 3);
-        break;
-    case 3:
-        XMEMCPY(sha_input, "DDDD", 4);
-        break;
-    case 4:
-        XMEMCPY(sha_input, "EEEEE", 5);
-        break;
-    case 5:
-        XMEMCPY(sha_input, "FFFFFF", 6);
-        break;
-    case 6:
-        XMEMCPY(sha_input, "GGGGGGG", 7);
-        break;
-    default:
-        WOLFSSL_MSG("Set Prefix error, bad input");
-        return 0; 
-    }
-    return 1;
-}
-#endif
-
-
-static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
-                   int side, void* heap, int devId)
-{
-#ifdef BUILD_ARC4
-    word32 sz = specs->key_size;
-    if (specs->bulk_cipher_algorithm == wolfssl_rc4) {
-        if (enc && enc->arc4 == NULL)
-            enc->arc4 = (Arc4*)XMALLOC(sizeof(Arc4), heap, DYNAMIC_TYPE_CIPHER);
-        if (enc && enc->arc4 == NULL)
-            return MEMORY_E;
-        if (dec && dec->arc4 == NULL)
-            dec->arc4 = (Arc4*)XMALLOC(sizeof(Arc4), heap, DYNAMIC_TYPE_CIPHER);
-        if (dec && dec->arc4 == NULL)
-            return MEMORY_E;
-#ifdef HAVE_CAVIUM
-        if (devId != NO_CAVIUM_DEVICE) {
-            if (enc) {
-                if (Arc4InitCavium(enc->arc4, devId) != 0) {
-                    WOLFSSL_MSG("Arc4InitCavium failed in SetKeys");
-                    return CAVIUM_INIT_E;
-                }
-            }
-            if (dec) {
-                if (Arc4InitCavium(dec->arc4, devId) != 0) {
-                    WOLFSSL_MSG("Arc4InitCavium failed in SetKeys");
-                    return CAVIUM_INIT_E;
-                }
-            }
-        }
-#endif
-        if (side == WOLFSSL_CLIENT_END) {
-            if (enc)
-                wc_Arc4SetKey(enc->arc4, keys->client_write_key, sz);
-            if (dec)
-                wc_Arc4SetKey(dec->arc4, keys->server_write_key, sz);
-        }
-        else {
-            if (enc)
-                wc_Arc4SetKey(enc->arc4, keys->server_write_key, sz);
-            if (dec)
-                wc_Arc4SetKey(dec->arc4, keys->client_write_key, sz);
-        }
-        if (enc)
-            enc->setup = 1;
-        if (dec)
-            dec->setup = 1;
-    }
-#endif
-
-    
-#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
-    if (specs->bulk_cipher_algorithm == wolfssl_chacha) {
-        int chachaRet;
-        if (enc && enc->chacha == NULL)
-            enc->chacha =
-                    (ChaCha*)XMALLOC(sizeof(ChaCha), heap, DYNAMIC_TYPE_CIPHER);
-        if (enc && enc->chacha == NULL)
-            return MEMORY_E;
-        if (dec && dec->chacha == NULL)
-            dec->chacha =
-                    (ChaCha*)XMALLOC(sizeof(ChaCha), heap, DYNAMIC_TYPE_CIPHER);
-        if (dec && dec->chacha == NULL)
-            return MEMORY_E;
-        if (side == WOLFSSL_CLIENT_END) {
-            if (enc) {
-                chachaRet = wc_Chacha_SetKey(enc->chacha, keys->client_write_key,
-                                          specs->key_size);
-                XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV,
-                        AEAD_IMP_IV_SZ);
-                if (chachaRet != 0) return chachaRet;
-            }
-            if (dec) {
-                chachaRet = wc_Chacha_SetKey(dec->chacha, keys->server_write_key,
-                                          specs->key_size);
-                XMEMCPY(keys->aead_dec_imp_IV, keys->server_write_IV,
-                        AEAD_IMP_IV_SZ);
-                if (chachaRet != 0) return chachaRet;
-            }
-        }
-        else {
-            if (enc) {
-                chachaRet = wc_Chacha_SetKey(enc->chacha, keys->server_write_key,
-                                          specs->key_size);
-                XMEMCPY(keys->aead_enc_imp_IV, keys->server_write_IV,
-                        AEAD_IMP_IV_SZ);
-                if (chachaRet != 0) return chachaRet;
-            }
-            if (dec) {
-                chachaRet = wc_Chacha_SetKey(dec->chacha, keys->client_write_key,
-                                          specs->key_size);
-                XMEMCPY(keys->aead_dec_imp_IV, keys->client_write_IV,
-                        AEAD_IMP_IV_SZ);
-                if (chachaRet != 0) return chachaRet;
-            }
-        }
-
-        if (enc)
-            enc->setup = 1;
-        if (dec)
-            dec->setup = 1;
-    }
-#endif
-
-#ifdef HAVE_HC128
-    if (specs->bulk_cipher_algorithm == wolfssl_hc128) {
-        int hcRet;
-        if (enc && enc->hc128 == NULL)
-            enc->hc128 =
-                      (HC128*)XMALLOC(sizeof(HC128), heap, DYNAMIC_TYPE_CIPHER);
-        if (enc && enc->hc128 == NULL)
-            return MEMORY_E;
-        if (dec && dec->hc128 == NULL)
-            dec->hc128 =
-                      (HC128*)XMALLOC(sizeof(HC128), heap, DYNAMIC_TYPE_CIPHER);
-        if (dec && dec->hc128 == NULL)
-            return MEMORY_E;
-        if (side == WOLFSSL_CLIENT_END) {
-            if (enc) {
-                hcRet = wc_Hc128_SetKey(enc->hc128, keys->client_write_key,
-                                     keys->client_write_IV);
-                if (hcRet != 0) return hcRet;
-            }
-            if (dec) {
-                hcRet = wc_Hc128_SetKey(dec->hc128, keys->server_write_key,
-                                     keys->server_write_IV);
-                if (hcRet != 0) return hcRet;
-            }
-        }
-        else {
-            if (enc) {
-                hcRet = wc_Hc128_SetKey(enc->hc128, keys->server_write_key,
-                                     keys->server_write_IV);
-                if (hcRet != 0) return hcRet;
-            }
-            if (dec) {
-                hcRet = wc_Hc128_SetKey(dec->hc128, keys->client_write_key,
-                                     keys->client_write_IV);
-                if (hcRet != 0) return hcRet;
-            }
-        }
-        if (enc)
-            enc->setup = 1;
-        if (dec)
-            dec->setup = 1;
-    }
-#endif
-    
-#ifdef BUILD_RABBIT
-    if (specs->bulk_cipher_algorithm == wolfssl_rabbit) {
-        int rabRet;
-        if (enc && enc->rabbit == NULL)
-            enc->rabbit =
-                    (Rabbit*)XMALLOC(sizeof(Rabbit), heap, DYNAMIC_TYPE_CIPHER);
-        if (enc && enc->rabbit == NULL)
-            return MEMORY_E;
-        if (dec && dec->rabbit == NULL)
-            dec->rabbit =
-                    (Rabbit*)XMALLOC(sizeof(Rabbit), heap, DYNAMIC_TYPE_CIPHER);
-        if (dec && dec->rabbit == NULL)
-            return MEMORY_E;
-        if (side == WOLFSSL_CLIENT_END) {
-            if (enc) {
-                rabRet = wc_RabbitSetKey(enc->rabbit, keys->client_write_key,
-                                      keys->client_write_IV);
-                if (rabRet != 0) return rabRet;
-            }
-            if (dec) {
-                rabRet = wc_RabbitSetKey(dec->rabbit, keys->server_write_key,
-                                      keys->server_write_IV);
-                if (rabRet != 0) return rabRet;
-            }
-        }
-        else {
-            if (enc) {
-                rabRet = wc_RabbitSetKey(enc->rabbit, keys->server_write_key,
-                                      keys->server_write_IV);
-                if (rabRet != 0) return rabRet;
-            }
-            if (dec) {
-                rabRet = wc_RabbitSetKey(dec->rabbit, keys->client_write_key,
-                                      keys->client_write_IV);
-                if (rabRet != 0) return rabRet;
-            }
-        }
-        if (enc)
-            enc->setup = 1;
-        if (dec)
-            dec->setup = 1;
-    }
-#endif
-    
-#ifdef BUILD_DES3
-    if (specs->bulk_cipher_algorithm == wolfssl_triple_des) {
-        int desRet = 0;
-
-        if (enc && enc->des3 == NULL)
-            enc->des3 = (Des3*)XMALLOC(sizeof(Des3), heap, DYNAMIC_TYPE_CIPHER);
-        if (enc && enc->des3 == NULL)
-            return MEMORY_E;
-        if (dec && dec->des3 == NULL)
-            dec->des3 = (Des3*)XMALLOC(sizeof(Des3), heap, DYNAMIC_TYPE_CIPHER);
-        if (dec && dec->des3 == NULL)
-            return MEMORY_E;
-#ifdef HAVE_CAVIUM
-        if (devId != NO_CAVIUM_DEVICE) {
-            if (enc) {
-                if (Des3_InitCavium(enc->des3, devId) != 0) {
-                    WOLFSSL_MSG("Des3_InitCavium failed in SetKeys");
-                    return CAVIUM_INIT_E;
-                }
-            }
-            if (dec) {
-                if (Des3_InitCavium(dec->des3, devId) != 0) {
-                    WOLFSSL_MSG("Des3_InitCavium failed in SetKeys");
-                    return CAVIUM_INIT_E;
-                }
-            }
-        }
-#endif
-        if (side == WOLFSSL_CLIENT_END) {
-            if (enc) {
-                desRet = wc_Des3_SetKey(enc->des3, keys->client_write_key,
-                                     keys->client_write_IV, DES_ENCRYPTION);
-                if (desRet != 0) return desRet;
-            }
-            if (dec) {
-                desRet = wc_Des3_SetKey(dec->des3, keys->server_write_key,
-                                     keys->server_write_IV, DES_DECRYPTION);
-                if (desRet != 0) return desRet;
-            }
-        }
-        else {
-            if (enc) {
-                desRet = wc_Des3_SetKey(enc->des3, keys->server_write_key,
-                                     keys->server_write_IV, DES_ENCRYPTION);
-                if (desRet != 0) return desRet;
-            }
-            if (dec) {
-                desRet = wc_Des3_SetKey(dec->des3, keys->client_write_key,
-                                     keys->client_write_IV, DES_DECRYPTION);
-                if (desRet != 0) return desRet;
-            }
-        }
-        if (enc)
-            enc->setup = 1;
-        if (dec)
-            dec->setup = 1;
-    }
-#endif
-
-#ifdef BUILD_AES
-    if (specs->bulk_cipher_algorithm == wolfssl_aes) {
-        int aesRet = 0;
-
-        if (enc && enc->aes == NULL)
-            enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
-        if (enc && enc->aes == NULL)
-            return MEMORY_E;
-        if (dec && dec->aes == NULL)
-            dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
-        if (dec && dec->aes == NULL)
-            return MEMORY_E;
-#ifdef HAVE_CAVIUM
-        if (devId != NO_CAVIUM_DEVICE) {
-            if (enc) {
-                if (wc_AesInitCavium(enc->aes, devId) != 0) {
-                    WOLFSSL_MSG("AesInitCavium failed in SetKeys");
-                    return CAVIUM_INIT_E;
-                }
-            }
-            if (dec) {
-                if (wc_AesInitCavium(dec->aes, devId) != 0) {
-                    WOLFSSL_MSG("AesInitCavium failed in SetKeys");
-                    return CAVIUM_INIT_E;
-                }
-            }
-        }
-#endif
-        if (side == WOLFSSL_CLIENT_END) {
-            if (enc) {
-                aesRet = wc_AesSetKey(enc->aes, keys->client_write_key,
-                                   specs->key_size, keys->client_write_IV,
-                                   AES_ENCRYPTION);
-                if (aesRet != 0) return aesRet;
-            }
-            if (dec) {
-                aesRet = wc_AesSetKey(dec->aes, keys->server_write_key,
-                                   specs->key_size, keys->server_write_IV,
-                                   AES_DECRYPTION);
-                if (aesRet != 0) return aesRet;
-            }
-        }
-        else {
-            if (enc) {
-                aesRet = wc_AesSetKey(enc->aes, keys->server_write_key,
-                                   specs->key_size, keys->server_write_IV,
-                                   AES_ENCRYPTION);
-                if (aesRet != 0) return aesRet;
-            }
-            if (dec) {
-                aesRet = wc_AesSetKey(dec->aes, keys->client_write_key,
-                                   specs->key_size, keys->client_write_IV,
-                                   AES_DECRYPTION);
-                if (aesRet != 0) return aesRet;
-            }
-        }
-        if (enc)
-            enc->setup = 1;
-        if (dec)
-            dec->setup = 1;
-    }
-#endif
-
-#ifdef BUILD_AESGCM
-    if (specs->bulk_cipher_algorithm == wolfssl_aes_gcm) {
-        int gcmRet;
-
-        if (enc && enc->aes == NULL)
-            enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
-        if (enc && enc->aes == NULL)
-            return MEMORY_E;
-        if (dec && dec->aes == NULL)
-            dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
-        if (dec && dec->aes == NULL)
-            return MEMORY_E;
-
-        if (side == WOLFSSL_CLIENT_END) {
-            if (enc) {
-                gcmRet = wc_AesGcmSetKey(enc->aes, keys->client_write_key,
-                                      specs->key_size);
-                if (gcmRet != 0) return gcmRet;
-                XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV,
-                        AEAD_IMP_IV_SZ);
-            }
-            if (dec) {
-                gcmRet = wc_AesGcmSetKey(dec->aes, keys->server_write_key,
-                                      specs->key_size);
-                if (gcmRet != 0) return gcmRet;
-                XMEMCPY(keys->aead_dec_imp_IV, keys->server_write_IV,
-                        AEAD_IMP_IV_SZ);
-            }
-        }
-        else {
-            if (enc) {
-                gcmRet = wc_AesGcmSetKey(enc->aes, keys->server_write_key,
-                                      specs->key_size);
-                if (gcmRet != 0) return gcmRet;
-                XMEMCPY(keys->aead_enc_imp_IV, keys->server_write_IV,
-                        AEAD_IMP_IV_SZ);
-            }
-            if (dec) {
-                gcmRet = wc_AesGcmSetKey(dec->aes, keys->client_write_key,
-                                      specs->key_size);
-                if (gcmRet != 0) return gcmRet;
-                XMEMCPY(keys->aead_dec_imp_IV, keys->client_write_IV,
-                        AEAD_IMP_IV_SZ);
-            }
-        }
-        if (enc)
-            enc->setup = 1;
-        if (dec)
-            dec->setup = 1;
-    }
-#endif
-
-#ifdef HAVE_AESCCM
-    if (specs->bulk_cipher_algorithm == wolfssl_aes_ccm) {
-        if (enc && enc->aes == NULL)
-            enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
-        if (enc && enc->aes == NULL)
-            return MEMORY_E;
-        if (dec && dec->aes == NULL)
-            dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
-        if (dec && dec->aes == NULL)
-            return MEMORY_E;
-
-        if (side == WOLFSSL_CLIENT_END) {
-            if (enc) {
-                wc_AesCcmSetKey(enc->aes, keys->client_write_key, specs->key_size);
-                XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV,
-                        AEAD_IMP_IV_SZ);
-            }
-            if (dec) {
-                wc_AesCcmSetKey(dec->aes, keys->server_write_key, specs->key_size);
-                XMEMCPY(keys->aead_dec_imp_IV, keys->server_write_IV,
-                        AEAD_IMP_IV_SZ);
-            }
-        }
-        else {
-            if (enc) {
-                wc_AesCcmSetKey(enc->aes, keys->server_write_key, specs->key_size);
-                XMEMCPY(keys->aead_enc_imp_IV, keys->server_write_IV,
-                        AEAD_IMP_IV_SZ);
-            }
-            if (dec) {
-                wc_AesCcmSetKey(dec->aes, keys->client_write_key, specs->key_size);
-                XMEMCPY(keys->aead_dec_imp_IV, keys->client_write_IV,
-                        AEAD_IMP_IV_SZ);
-            }
-        }
-        if (enc)
-            enc->setup = 1;
-        if (dec)
-            dec->setup = 1;
-    }
-#endif
-
-#ifdef HAVE_CAMELLIA
-    if (specs->bulk_cipher_algorithm == wolfssl_camellia) {
-        int camRet;
-
-        if (enc && enc->cam == NULL)
-            enc->cam =
-                (Camellia*)XMALLOC(sizeof(Camellia), heap, DYNAMIC_TYPE_CIPHER);
-        if (enc && enc->cam == NULL)
-            return MEMORY_E;
-
-        if (dec && dec->cam == NULL)
-            dec->cam =
-                (Camellia*)XMALLOC(sizeof(Camellia), heap, DYNAMIC_TYPE_CIPHER);
-        if (dec && dec->cam == NULL)
-            return MEMORY_E;
-
-        if (side == WOLFSSL_CLIENT_END) {
-            if (enc) {
-                camRet = wc_CamelliaSetKey(enc->cam, keys->client_write_key,
-                                        specs->key_size, keys->client_write_IV);
-                if (camRet != 0) return camRet;
-            }
-            if (dec) {
-                camRet = wc_CamelliaSetKey(dec->cam, keys->server_write_key,
-                                        specs->key_size, keys->server_write_IV);
-                if (camRet != 0) return camRet;
-            }
-        }
-        else {
-            if (enc) {
-                camRet = wc_CamelliaSetKey(enc->cam, keys->server_write_key,
-                                        specs->key_size, keys->server_write_IV);
-                if (camRet != 0) return camRet;
-            }
-            if (dec) {
-                camRet = wc_CamelliaSetKey(dec->cam, keys->client_write_key,
-                                        specs->key_size, keys->client_write_IV);
-                if (camRet != 0) return camRet;
-            }
-        }
-        if (enc)
-            enc->setup = 1;
-        if (dec)
-            dec->setup = 1;
-    }
-#endif
-
-#ifdef HAVE_NULL_CIPHER
-    if (specs->bulk_cipher_algorithm == wolfssl_cipher_null) {
-        if (enc)
-            enc->setup = 1;
-        if (dec)
-            dec->setup = 1;
-    }
-#endif
-
-    if (enc)
-        keys->sequence_number      = 0;
-    if (dec)
-        keys->peer_sequence_number = 0;
-    (void)side;
-    (void)heap;
-    (void)enc;
-    (void)dec;
-    (void)specs;
-    (void)devId;
-
-    return 0;
-}
-
-
-#ifdef HAVE_ONE_TIME_AUTH
-/* set one time authentication keys */
-static int SetAuthKeys(OneTimeAuth* authentication, Keys* keys,
-                       CipherSpecs* specs, void* heap, int devId)
-{
-
-#ifdef HAVE_POLY1305
-        /* set up memory space for poly1305 */
-        if (authentication && authentication->poly1305 == NULL)
-            authentication->poly1305 =
-                (Poly1305*)XMALLOC(sizeof(Poly1305), heap, DYNAMIC_TYPE_CIPHER);
-        if (authentication && authentication->poly1305 == NULL)
-            return MEMORY_E;
-        if (authentication)
-            authentication->setup = 1;
-#endif
-        (void)heap;
-        (void)keys;
-        (void)specs;
-        (void)devId;
-
-        return 0;
-}
-#endif /* HAVE_ONE_TIME_AUTH */
-
-
-/* Set wc_encrypt/wc_decrypt or both sides of key setup
- * note: use wc_encrypt to avoid shadowing global encrypt
- * declared in unistd.h
- */
-int SetKeysSide(WOLFSSL* ssl, enum encrypt_side side)
-{
-    int devId = NO_CAVIUM_DEVICE, ret, copy = 0;
-    Ciphers* wc_encrypt = NULL;
-    Ciphers* wc_decrypt = NULL;
-    Keys*    keys    = &ssl->keys;
-
-    (void)copy;
-
-#ifdef HAVE_CAVIUM
-    devId = ssl->devId;
-#endif
-
-#ifdef HAVE_SECURE_RENEGOTIATION
-    if (ssl->secure_renegotiation && ssl->secure_renegotiation->cache_status) {
-        keys = &ssl->secure_renegotiation->tmp_keys;
-        copy = 1;
-    }
-#endif /* HAVE_SECURE_RENEGOTIATION */
-
-    switch (side) {
-        case ENCRYPT_SIDE_ONLY:
-            wc_encrypt = &ssl->encrypt;
-            break;
-
-        case DECRYPT_SIDE_ONLY:
-            wc_decrypt = &ssl->decrypt;
-            break;
-
-        case ENCRYPT_AND_DECRYPT_SIDE:
-            wc_encrypt = &ssl->encrypt;
-            wc_decrypt = &ssl->decrypt;
-            break;
-
-        default:
-            return BAD_FUNC_ARG;
-    }
-
-#ifdef HAVE_ONE_TIME_AUTH
-    if (!ssl->auth.setup && ssl->specs.bulk_cipher_algorithm == wolfssl_chacha){
-        ret = SetAuthKeys(&ssl->auth, keys, &ssl->specs, ssl->heap, devId);
-        if (ret != 0)
-           return ret;
-    }
-#endif
-
-    ret = SetKeys(wc_encrypt, wc_decrypt, keys, &ssl->specs, ssl->options.side,
-                  ssl->heap, devId);
-
-#ifdef HAVE_SECURE_RENEGOTIATION
-    if (copy) {
-        int clientCopy = 0;
-
-        if (ssl->options.side == WOLFSSL_CLIENT_END && wc_encrypt)
-            clientCopy = 1;
-        else if (ssl->options.side == WOLFSSL_SERVER_END && wc_decrypt)
-            clientCopy = 1;
-
-        if (clientCopy) {
-            XMEMCPY(ssl->keys.client_write_MAC_secret,
-                    keys->client_write_MAC_secret, MAX_DIGEST_SIZE);
-            XMEMCPY(ssl->keys.client_write_key,
-                    keys->client_write_key, AES_256_KEY_SIZE);
-            XMEMCPY(ssl->keys.client_write_IV,
-                    keys->client_write_IV, AES_IV_SIZE);
-        } else {
-            XMEMCPY(ssl->keys.server_write_MAC_secret,
-                    keys->server_write_MAC_secret, MAX_DIGEST_SIZE);
-            XMEMCPY(ssl->keys.server_write_key,
-                    keys->server_write_key, AES_256_KEY_SIZE);
-            XMEMCPY(ssl->keys.server_write_IV,
-                    keys->server_write_IV, AES_IV_SIZE);
-        }
-        if (wc_encrypt) {
-            ssl->keys.sequence_number = keys->sequence_number;
-            #ifdef HAVE_AEAD
-                if (ssl->specs.cipher_type == aead) {
-                    /* Initialize the AES-GCM/CCM explicit IV to a zero. */
-                    XMEMCPY(ssl->keys.aead_exp_IV, keys->aead_exp_IV,
-                            AEAD_EXP_IV_SZ);
-
-                    /* Initialize encrypt implicit IV by encrypt side */
-                    if (ssl->options.side == WOLFSSL_CLIENT_END) {
-                        XMEMCPY(ssl->keys.aead_enc_imp_IV,
-                                keys->client_write_IV, AEAD_IMP_IV_SZ);
-                    } else {
-                        XMEMCPY(ssl->keys.aead_enc_imp_IV,
-                                keys->server_write_IV, AEAD_IMP_IV_SZ);
-                    }
-                }
-            #endif
-        }
-        if (wc_decrypt) {
-            ssl->keys.peer_sequence_number = keys->peer_sequence_number;
-            #ifdef HAVE_AEAD
-                if (ssl->specs.cipher_type == aead) {
-                    /* Initialize decrypt implicit IV by decrypt side */
-                    if (ssl->options.side == WOLFSSL_SERVER_END) {
-                        XMEMCPY(ssl->keys.aead_dec_imp_IV,
-                                keys->client_write_IV, AEAD_IMP_IV_SZ);
-                    } else {
-                        XMEMCPY(ssl->keys.aead_dec_imp_IV,
-                                keys->server_write_IV, AEAD_IMP_IV_SZ);
-                    }
-                }
-            #endif
-        }
-        ssl->secure_renegotiation->cache_status++;
-    }
-#endif /* HAVE_SECURE_RENEGOTIATION */
-
-    return ret;
-}
-
-
-/* TLS can call too */
-int StoreKeys(WOLFSSL* ssl, const byte* keyData)
-{
-    int sz, i = 0;
-    Keys* keys = &ssl->keys;
-
-#ifdef HAVE_SECURE_RENEGOTIATION
-    if (ssl->secure_renegotiation && ssl->secure_renegotiation->cache_status ==
-                                                            SCR_CACHE_NEEDED) {
-        keys = &ssl->secure_renegotiation->tmp_keys;
-        ssl->secure_renegotiation->cache_status++;
-    }
-#endif /* HAVE_SECURE_RENEGOTIATION */
-
-    if (ssl->specs.cipher_type != aead) {
-        sz = ssl->specs.hash_size;
-        XMEMCPY(keys->client_write_MAC_secret,&keyData[i], sz);
-        i += sz;
-        XMEMCPY(keys->server_write_MAC_secret,&keyData[i], sz);
-        i += sz;
-    }
-    sz = ssl->specs.key_size;
-    XMEMCPY(keys->client_write_key, &keyData[i], sz);
-    i += sz;
-    XMEMCPY(keys->server_write_key, &keyData[i], sz);
-    i += sz;
-
-    sz = ssl->specs.iv_size;
-    XMEMCPY(keys->client_write_IV, &keyData[i], sz);
-    i += sz;
-    XMEMCPY(keys->server_write_IV, &keyData[i], sz);
-
-#ifdef HAVE_AEAD
-    if (ssl->specs.cipher_type == aead) {
-        /* Initialize the AES-GCM/CCM explicit IV to a zero. */
-        XMEMSET(keys->aead_exp_IV, 0, AEAD_EXP_IV_SZ);
-    }
-#endif
-
-    return 0;
-}
-
-#ifndef NO_OLD_TLS
-int DeriveKeys(WOLFSSL* ssl)
-{
-    int    length = 2 * ssl->specs.hash_size + 
-                    2 * ssl->specs.key_size  +
-                    2 * ssl->specs.iv_size;
-    int    rounds = (length + MD5_DIGEST_SIZE - 1 ) / MD5_DIGEST_SIZE, i;
-    int    ret = 0;
-    
-#ifdef WOLFSSL_SMALL_STACK
-    byte*  shaOutput;
-    byte*  md5Input;
-    byte*  shaInput;
-    byte*  keyData;
-    Md5*   md5;
-    Sha*   sha;
-#else
-    byte   shaOutput[SHA_DIGEST_SIZE];
-    byte   md5Input[SECRET_LEN + SHA_DIGEST_SIZE];
-    byte   shaInput[KEY_PREFIX + SECRET_LEN + 2 * RAN_LEN];
-    byte   keyData[KEY_PREFIX * MD5_DIGEST_SIZE];
-    Md5    md5[1];
-    Sha    sha[1];
-#endif
-    
-#ifdef WOLFSSL_SMALL_STACK
-    shaOutput = (byte*)XMALLOC(SHA_DIGEST_SIZE, 
-                                            NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    md5Input  = (byte*)XMALLOC(SECRET_LEN + SHA_DIGEST_SIZE,
-                                            NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    shaInput  = (byte*)XMALLOC(KEY_PREFIX + SECRET_LEN + 2 * RAN_LEN,
-                                            NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    keyData   = (byte*)XMALLOC(KEY_PREFIX * MD5_DIGEST_SIZE,
-                                            NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    md5       =  (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    sha       =  (Sha*)XMALLOC(sizeof(Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    
-    if (shaOutput == NULL || md5Input == NULL || shaInput == NULL ||
-        keyData   == NULL || md5      == NULL || sha      == NULL) {
-        if (shaOutput) XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (md5Input)  XFREE(md5Input,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (shaInput)  XFREE(shaInput,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (keyData)   XFREE(keyData,   NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (md5)       XFREE(md5,       NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (sha)       XFREE(sha,       NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        
-        return MEMORY_E;
-    }
-#endif
-
-    wc_InitMd5(md5);
-
-    ret = wc_InitSha(sha);
-
-    if (ret == 0) {
-        XMEMCPY(md5Input, ssl->arrays->masterSecret, SECRET_LEN);
-
-        for (i = 0; i < rounds; ++i) {
-            int j   = i + 1;
-            int idx = j;
-
-            if (!SetPrefix(shaInput, i)) {
-                ret = PREFIX_ERROR;
-                break;
-            }
-
-            XMEMCPY(shaInput + idx, ssl->arrays->masterSecret, SECRET_LEN);
-            idx += SECRET_LEN;
-            XMEMCPY(shaInput + idx, ssl->arrays->serverRandom, RAN_LEN);
-            idx += RAN_LEN;
-            XMEMCPY(shaInput + idx, ssl->arrays->clientRandom, RAN_LEN);
-
-            wc_ShaUpdate(sha, shaInput, (KEY_PREFIX + SECRET_LEN + 2 * RAN_LEN)
-                                                              - KEY_PREFIX + j);
-            wc_ShaFinal(sha, shaOutput);
-
-            XMEMCPY(md5Input + SECRET_LEN, shaOutput, SHA_DIGEST_SIZE);
-            wc_Md5Update(md5, md5Input, SECRET_LEN + SHA_DIGEST_SIZE);
-            wc_Md5Final(md5, keyData + i * MD5_DIGEST_SIZE);
-        }
-
-        if (ret == 0)
-            ret = StoreKeys(ssl, keyData);
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(md5Input,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(shaInput,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(keyData,   NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(md5,       NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(sha,       NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-static int CleanPreMaster(WOLFSSL* ssl)
-{
-    int i, ret, sz = ssl->arrays->preMasterSz;
-
-    for (i = 0; i < sz; i++)
-        ssl->arrays->preMasterSecret[i] = 0;
-
-    ret = wc_RNG_GenerateBlock(ssl->rng, ssl->arrays->preMasterSecret, sz);
-    if (ret != 0)
-        return ret;
-
-    for (i = 0; i < sz; i++)
-        ssl->arrays->preMasterSecret[i] = 0;
-
-    return 0;
-}
-
-
-/* Create and store the master secret see page 32, 6.1 */
-static int MakeSslMasterSecret(WOLFSSL* ssl)
-{
-    int    i, ret;
-    word32 idx;
-    word32 pmsSz = ssl->arrays->preMasterSz;
-
-#ifdef WOLFSSL_SMALL_STACK
-    byte*  shaOutput;
-    byte*  md5Input;
-    byte*  shaInput;
-    Md5*   md5;
-    Sha*   sha;
-#else
-    byte   shaOutput[SHA_DIGEST_SIZE];
-    byte   md5Input[ENCRYPT_LEN + SHA_DIGEST_SIZE];
-    byte   shaInput[PREFIX + ENCRYPT_LEN + 2 * RAN_LEN];
-    Md5    md5[1];
-    Sha    sha[1];
-#endif
-
-#ifdef SHOW_SECRETS
-    {
-        word32 j;
-        printf("pre master secret: ");
-        for (j = 0; j < pmsSz; j++)
-            printf("%02x", ssl->arrays->preMasterSecret[j]);
-        printf("\n");
-    }
-#endif
-    
-#ifdef WOLFSSL_SMALL_STACK
-    shaOutput = (byte*)XMALLOC(SHA_DIGEST_SIZE, 
-                                            NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    md5Input  = (byte*)XMALLOC(ENCRYPT_LEN + SHA_DIGEST_SIZE,
-                                            NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    shaInput  = (byte*)XMALLOC(PREFIX + ENCRYPT_LEN + 2 * RAN_LEN,
-                                            NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    md5       =  (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    sha       =  (Sha*)XMALLOC(sizeof(Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    
-    if (shaOutput == NULL || md5Input == NULL || shaInput == NULL ||
-                             md5      == NULL || sha      == NULL) {
-        if (shaOutput) XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (md5Input)  XFREE(md5Input,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (shaInput)  XFREE(shaInput,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (md5)       XFREE(md5,       NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (sha)       XFREE(sha,       NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        
-        return MEMORY_E;
-    }
-#endif
-
-    wc_InitMd5(md5);
-    
-    ret = wc_InitSha(sha);
-    
-    if (ret == 0) {
-        XMEMCPY(md5Input, ssl->arrays->preMasterSecret, pmsSz);
-
-        for (i = 0; i < MASTER_ROUNDS; ++i) {
-            byte prefix[KEY_PREFIX];      /* only need PREFIX bytes but static */
-            if (!SetPrefix(prefix, i)) {  /* analysis thinks will overrun      */
-                ret = PREFIX_ERROR;
-                break;
-            }
-
-            idx = 0;
-            XMEMCPY(shaInput, prefix, i + 1);
-            idx += i + 1;
-
-            XMEMCPY(shaInput + idx, ssl->arrays->preMasterSecret, pmsSz);
-            idx += pmsSz;
-            XMEMCPY(shaInput + idx, ssl->arrays->clientRandom, RAN_LEN);
-            idx += RAN_LEN;
-            XMEMCPY(shaInput + idx, ssl->arrays->serverRandom, RAN_LEN);
-            idx += RAN_LEN;
-            wc_ShaUpdate(sha, shaInput, idx);
-            wc_ShaFinal(sha, shaOutput);
-
-            idx = pmsSz;  /* preSz */
-            XMEMCPY(md5Input + idx, shaOutput, SHA_DIGEST_SIZE);
-            idx += SHA_DIGEST_SIZE;
-            wc_Md5Update(md5, md5Input, idx);
-            wc_Md5Final(md5, &ssl->arrays->masterSecret[i * MD5_DIGEST_SIZE]);
-        }
-
-#ifdef SHOW_SECRETS
-        {
-            word32 j;
-            printf("master secret: ");
-            for (j = 0; j < SECRET_LEN; j++)
-                printf("%02x", ssl->arrays->masterSecret[j]);
-            printf("\n");
-        }
-#endif
-
-        if (ret == 0)
-            ret = DeriveKeys(ssl);
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(md5Input,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(shaInput,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(md5,       NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(sha,       NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-    
-    if (ret == 0)
-        ret = CleanPreMaster(ssl);
-    else
-        CleanPreMaster(ssl);
-
-    return ret;
-}
-#endif
-
-
-/* Master wrapper, doesn't use SSL stack space in TLS mode */
-int MakeMasterSecret(WOLFSSL* ssl)
-{
-#ifdef NO_OLD_TLS
-    return MakeTlsMasterSecret(ssl);
-#elif !defined(NO_TLS)
-    if (ssl->options.tls) return MakeTlsMasterSecret(ssl);
-#endif
-
-#ifndef NO_OLD_TLS
-    return MakeSslMasterSecret(ssl);
-#endif
-}
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/src/ocsp.c b/FreeRTOS-Plus/Source/WolfSSL/src/ocsp.c
deleted file mode 100755
index 1794d63..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/src/ocsp.c
+++ /dev/null
@@ -1,303 +0,0 @@
-/* ocsp.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-  /* Name change compatibility layer no longer needs to be included here */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef HAVE_OCSP
-
-#include 
-#include 
-#include 
-
-
-int InitOCSP(WOLFSSL_OCSP* ocsp, WOLFSSL_CERT_MANAGER* cm)
-{
-    WOLFSSL_ENTER("InitOCSP");
-    XMEMSET(ocsp, 0, sizeof(*ocsp));
-    ocsp->cm = cm;
-    if (InitMutex(&ocsp->ocspLock) != 0)
-        return BAD_MUTEX_E;
-
-    return 0;
-}
-
-
-static int InitOCSP_Entry(OCSP_Entry* ocspe, DecodedCert* cert)
-{
-    WOLFSSL_ENTER("InitOCSP_Entry");
-
-    XMEMSET(ocspe, 0, sizeof(*ocspe));
-    XMEMCPY(ocspe->issuerHash, cert->issuerHash, SHA_DIGEST_SIZE);
-    XMEMCPY(ocspe->issuerKeyHash, cert->issuerKeyHash, SHA_DIGEST_SIZE);
-
-    return 0;
-}
-
-
-static void FreeOCSP_Entry(OCSP_Entry* ocspe)
-{
-    CertStatus* tmp = ocspe->status;
-
-    WOLFSSL_ENTER("FreeOCSP_Entry");
-
-    while (tmp) {
-        CertStatus* next = tmp->next;
-        XFREE(tmp, NULL, DYNAMIC_TYPE_OCSP_STATUS);
-        tmp = next;
-    }
-}
-
-
-void FreeOCSP(WOLFSSL_OCSP* ocsp, int dynamic)
-{
-    OCSP_Entry* tmp = ocsp->ocspList;
-
-    WOLFSSL_ENTER("FreeOCSP");
-
-    while (tmp) {
-        OCSP_Entry* next = tmp->next;
-        FreeOCSP_Entry(tmp);
-        XFREE(tmp, NULL, DYNAMIC_TYPE_OCSP_ENTRY);
-        tmp = next;
-    }
-
-    FreeMutex(&ocsp->ocspLock);
-    if (dynamic)
-        XFREE(ocsp, NULL, DYNAMIC_TYPE_OCSP);
-}
-
-
-static int xstat2err(int stat)
-{
-    switch (stat) {
-        case CERT_GOOD:
-            return 0;
-        case CERT_REVOKED:
-            return OCSP_CERT_REVOKED;
-        default:
-            return OCSP_CERT_UNKNOWN;
-    }
-}
-
-
-int CheckCertOCSP(WOLFSSL_OCSP* ocsp, DecodedCert* cert)
-{
-    byte* ocspReqBuf = NULL;
-    int ocspReqSz = 2048;
-    byte* ocspRespBuf = NULL;
-    int result = -1;
-    OCSP_Entry* ocspe;
-    CertStatus* certStatus = NULL;
-    const char *url;
-    int urlSz;
-#ifdef WOLFSSL_SMALL_STACK
-    CertStatus* newStatus;
-    OcspRequest* ocspRequest;
-    OcspResponse* ocspResponse;
-#else
-    CertStatus newStatus[1];
-    OcspRequest ocspRequest[1];
-    OcspResponse ocspResponse[1];
-#endif
-
-    WOLFSSL_ENTER("CheckCertOCSP");
-
-    if (LockMutex(&ocsp->ocspLock) != 0) {
-        WOLFSSL_LEAVE("CheckCertOCSP", BAD_MUTEX_E);
-        return BAD_MUTEX_E;
-    }
-
-    ocspe = ocsp->ocspList;
-    while (ocspe) {
-        if (XMEMCMP(ocspe->issuerHash, cert->issuerHash, SHA_DIGEST_SIZE) == 0
-            && XMEMCMP(ocspe->issuerKeyHash, cert->issuerKeyHash,
-                                                        SHA_DIGEST_SIZE) == 0)
-            break;
-        else
-            ocspe = ocspe->next;
-    }
-
-    if (ocspe == NULL) {
-        ocspe = (OCSP_Entry*)XMALLOC(sizeof(OCSP_Entry),
-                                                NULL, DYNAMIC_TYPE_OCSP_ENTRY);
-        if (ocspe != NULL) {
-            InitOCSP_Entry(ocspe, cert);
-            ocspe->next = ocsp->ocspList;
-            ocsp->ocspList = ocspe;
-        }
-        else {
-            UnLockMutex(&ocsp->ocspLock);
-            WOLFSSL_LEAVE("CheckCertOCSP", MEMORY_ERROR);
-            return MEMORY_ERROR;
-        }
-    }
-    else {
-        certStatus = ocspe->status;
-        while (certStatus) {
-            if (certStatus->serialSz == cert->serialSz &&
-                 XMEMCMP(certStatus->serial, cert->serial, cert->serialSz) == 0)
-                break;
-            else
-                certStatus = certStatus->next;
-        }
-    }
-
-    if (certStatus != NULL) {
-        if (!ValidateDate(certStatus->thisDate,
-                                        certStatus->thisDateFormat, BEFORE) ||
-            (certStatus->nextDate[0] == 0) ||
-            !ValidateDate(certStatus->nextDate,
-                                        certStatus->nextDateFormat, AFTER)) {
-            WOLFSSL_MSG("\tinvalid status date, looking up cert");
-        }
-        else {
-            result = xstat2err(certStatus->status);
-            UnLockMutex(&ocsp->ocspLock);
-            WOLFSSL_LEAVE("CheckCertOCSP", result);
-            return result;
-        }
-    }
-
-    UnLockMutex(&ocsp->ocspLock);
-
-    if (ocsp->cm->ocspUseOverrideURL) {
-        url = ocsp->cm->ocspOverrideURL;
-        if (url != NULL && url[0] != '\0')
-            urlSz = (int)XSTRLEN(url);
-        else
-            return OCSP_NEED_URL;
-    }
-    else if (cert->extAuthInfoSz != 0 && cert->extAuthInfo != NULL) {
-        url = (const char *)cert->extAuthInfo;
-        urlSz = cert->extAuthInfoSz;
-    }
-    else {
-        /* cert doesn't have extAuthInfo, assuming CERT_GOOD */
-        return 0;
-    }
-
-    ocspReqBuf = (byte*)XMALLOC(ocspReqSz, NULL, DYNAMIC_TYPE_IN_BUFFER);
-    if (ocspReqBuf == NULL) {
-        WOLFSSL_LEAVE("CheckCertOCSP", MEMORY_ERROR);
-        return MEMORY_ERROR;
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    newStatus = (CertStatus*)XMALLOC(sizeof(CertStatus), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    ocspRequest = (OcspRequest*)XMALLOC(sizeof(OcspRequest), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    ocspResponse = (OcspResponse*)XMALLOC(sizeof(OcspResponse), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-
-    if (newStatus == NULL || ocspRequest == NULL || ocspResponse == NULL) {
-        if (newStatus)    XFREE(newStatus,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (ocspRequest)  XFREE(ocspRequest,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (ocspResponse) XFREE(ocspResponse, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-        XFREE(ocspReqBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-        WOLFSSL_LEAVE("CheckCertOCSP", MEMORY_ERROR);
-        return MEMORY_E;
-    }
-#endif
-
-    InitOcspRequest(ocspRequest, cert, ocsp->cm->ocspSendNonce,
-                                                         ocspReqBuf, ocspReqSz);
-    ocspReqSz = EncodeOcspRequest(ocspRequest);
-    
-    if (ocsp->cm->ocspIOCb)
-        result = ocsp->cm->ocspIOCb(ocsp->cm->ocspIOCtx, url, urlSz,
-                                           ocspReqBuf, ocspReqSz, &ocspRespBuf);
-
-    if (result >= 0 && ocspRespBuf) {
-        XMEMSET(newStatus, 0, sizeof(CertStatus));
-
-        InitOcspResponse(ocspResponse, newStatus, ocspRespBuf, result);
-        OcspResponseDecode(ocspResponse);
-    
-        if (ocspResponse->responseStatus != OCSP_SUCCESSFUL)
-            result = OCSP_LOOKUP_FAIL;
-        else {
-            if (CompareOcspReqResp(ocspRequest, ocspResponse) == 0) {
-                result = xstat2err(ocspResponse->status->status);
-
-                if (LockMutex(&ocsp->ocspLock) != 0)
-                    result = BAD_MUTEX_E;
-                else {
-                    if (certStatus != NULL)
-                        /* Replace existing certificate entry with updated */
-                        XMEMCPY(certStatus, newStatus, sizeof(CertStatus));
-                    else {
-                        /* Save new certificate entry */
-                        certStatus = (CertStatus*)XMALLOC(sizeof(CertStatus),
-                                          NULL, DYNAMIC_TYPE_OCSP_STATUS);
-                        if (certStatus != NULL) {
-                            XMEMCPY(certStatus, newStatus, sizeof(CertStatus));
-                            certStatus->next = ocspe->status;
-                            ocspe->status = certStatus;
-                            ocspe->totalStatus++;
-                        }
-                    }
-
-                    UnLockMutex(&ocsp->ocspLock);
-                }
-            }
-            else
-                result = OCSP_LOOKUP_FAIL;
-        }
-    }
-    else
-        result = OCSP_LOOKUP_FAIL;
-
-    XFREE(ocspReqBuf, NULL, DYNAMIC_TYPE_IN_BUFFER);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(newStatus,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(ocspRequest,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(ocspResponse, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    if (ocspRespBuf != NULL && ocsp->cm->ocspRespFreeCb)
-        ocsp->cm->ocspRespFreeCb(ocsp->cm->ocspIOCtx, ocspRespBuf);
-
-    WOLFSSL_LEAVE("CheckCertOCSP", result);
-    return result;
-}
-
-
-#else /* HAVE_OCSP */
-
-
-#ifdef _MSC_VER
-    /* 4206 warning for blank file */
-    #pragma warning(disable: 4206)
-#endif
-
-
-#endif /* HAVE_OCSP */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/src/sniffer.c b/FreeRTOS-Plus/Source/WolfSSL/src/sniffer.c
deleted file mode 100755
index b961f7b..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/src/sniffer.c
+++ /dev/null
@@ -1,2948 +0,0 @@
-/* sniffer.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef WOLFSSL_SNIFFER
-
-#include 
-#include 
-
-#ifndef _WIN32
-  #include 
-#endif
-
-#ifdef _WIN32
-    #define SNPRINTF _snprintf
-#else
-    #define SNPRINTF snprintf
-#endif
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-static INLINE word32 min(word32 a, word32 b)
-{
-    return a > b ? b : a;
-}
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-#ifndef WOLFSSL_SNIFFER_TIMEOUT
-    #define WOLFSSL_SNIFFER_TIMEOUT 900
-    /* Cache unclosed Sessions for 15 minutes since last used */
-#endif
-
-/* Misc constants */
-enum {
-    MAX_SERVER_ADDRESS = 128, /* maximum server address length */
-    MAX_SERVER_NAME    = 128, /* maximum server name length */
-    MAX_ERROR_LEN      = 80,  /* maximum error length */
-    ETHER_IF_ADDR_LEN  = 6,   /* ethernet interface address length */
-    LOCAL_IF_ADDR_LEN  = 4,   /* localhost interface address length, !windows */
-    TCP_PROTO          = 6,   /* TCP_PROTOCOL */
-    IP_HDR_SZ          = 20,  /* IP header legnth, min */
-    TCP_HDR_SZ         = 20,  /* TCP header legnth, min */
-    IPV4               = 4,   /* IP version 4 */
-    TCP_PROTOCOL       = 6,   /* TCP Protocol id */
-    TRACE_MSG_SZ       = 80,  /* Trace Message buffer size */
-    HASH_SIZE          = 499, /* Session Hash Table Rows */
-    PSEUDO_HDR_SZ      = 12,  /* TCP Pseudo Header size in bytes */
-    FATAL_ERROR_STATE  =  1,  /* SnifferSession fatal error state */
-    TICKET_HINT_LEN    = 4,   /* Session Ticket Hint length */
-    EXT_TYPE_SZ        = 2,   /* Extension length */
-    MAX_INPUT_SZ       = MAX_RECORD_SIZE + COMP_EXTRA + MAX_MSG_EXTRA +
-                         MTU_EXTRA,  /* Max input sz of reassembly */
-    TICKET_EXT_ID      = 0x23 /* Session Ticket Extension ID */
-};
-
-
-#ifdef _WIN32
-
-static HMODULE dllModule;  /* for error string resources */
-
-BOOL APIENTRY DllMain( HMODULE hModule,
-                       DWORD  ul_reason_for_call,
-                       LPVOID lpReserved
-                     )
-{
-	static int didInit = 0;
-
-    switch (ul_reason_for_call)
-    {
-    case DLL_PROCESS_ATTACH:
-		if (didInit == 0) {
-            dllModule = hModule;
-			ssl_InitSniffer();
-			didInit = 1;
-		}
-        break;
-    case DLL_THREAD_ATTACH:
-        break;
-    case DLL_THREAD_DETACH:
-        break;
-    case DLL_PROCESS_DETACH:
-		if (didInit) {
-			ssl_FreeSniffer();
-			didInit = 0;
-		}
-        break;
-    }
-    return TRUE;
-}
-
-#endif /* _WIN32 */
-
-
-static int TraceOn = 0;         /* Trace is off by default */
-static FILE* TraceFile = 0;
-
-
-/* windows uses .rc table for this */
-#ifndef _WIN32
-
-static const char* const msgTable[] =
-{
-    /* 1 */
-    "Out of Memory",
-    "New SSL Sniffer Server Registered",
-    "Checking IP Header",
-    "SSL Sniffer Server Not Registered",
-    "Checking TCP Header",
-
-    /* 6 */
-    "SSL Sniffer Server Port Not Registered",
-    "RSA Private Decrypt Error",
-    "RSA Private Decode Error",
-    "Set Cipher Spec Error",
-    "Server Hello Input Malformed",
-
-    /* 11 */
-    "Couldn't Resume Session Error",
-    "Server Did Resumption",
-    "Client Hello Input Malformed",
-    "Client Trying to Resume",
-    "Handshake Input Malformed",
-
-    /* 16 */
-    "Got Hello Verify msg",
-    "Got Server Hello msg",
-    "Got Cert Request msg",
-    "Got Server Key Exchange msg",
-    "Got Cert msg",
-
-    /* 21 */
-    "Got Server Hello Done msg",
-    "Got Finished msg",
-    "Got Client Hello msg",
-    "Got Client Key Exchange msg",
-    "Got Cert Verify msg",
-
-    /* 26 */
-    "Got Unknown Handshake msg",
-    "New SSL Sniffer Session created",
-    "Couldn't create new SSL",
-    "Got a Packet to decode",
-    "No data present",
-
-    /* 31 */
-    "Session Not Found",
-    "Got an Old Client Hello msg",
-    "Old Client Hello Input Malformed",
-    "Old Client Hello OK",
-    "Bad Old Client Hello",
-
-    /* 36 */
-    "Bad Record Header",
-    "Record Header Input Malformed",
-    "Got a HandShake msg",
-    "Bad HandShake msg",
-    "Got a Change Cipher Spec msg",
-
-    /* 41 */
-    "Got Application Data msg",
-    "Bad Application Data",
-    "Got an Alert msg",
-    "Another msg to Process",
-    "Removing Session From Table",
-    
-    /* 46 */
-    "Bad Key File",
-    "Wrong IP Version",
-    "Wrong Protocol type",
-    "Packet Short for header processing",
-    "Got Unknown Record Type",
-    
-    /* 51 */
-    "Can't Open Trace File",
-    "Session in Fatal Error State",
-    "Partial SSL record received",
-    "Buffer Error, malformed input",
-    "Added to Partial Input",
-    
-    /* 56 */
-    "Received a Duplicate Packet",
-    "Received an Out of Order Packet",
-    "Received an Overlap Duplicate Packet",
-    "Received an Overlap Reassembly Begin Duplicate Packet",
-    "Received an Overlap Reassembly End Duplicate Packet",
-
-    /* 61 */
-    "Missed the Client Hello Entirely",
-    "Got Hello Request msg",
-    "Got Session Ticket msg",
-    "Bad Input",
-    "Bad Decrypt Type",
-
-    /* 66 */
-    "Bad Finished Message Processing",
-    "Bad Compression Type",
-    "Bad DeriveKeys Error",
-    "Saw ACK for Missing Packet Error",
-    "Bad Decrypt Operation",
-
-    /* 71 */
-    "Decrypt Keys Not Set Up",
-    "Late Key Load Error",
-    "Got Certificate Status msg",
-    "RSA Key Missing Error"
-};
-
-
-/* *nix version uses table above */
-static void GetError(int idx, char* str)
-{
-    XSTRNCPY(str, msgTable[idx - 1], MAX_ERROR_LEN);
-}
-
-
-#else /* _WIN32 */
-
-
-/* Windows version uses .rc table */
-static void GetError(int idx, char* buffer)
-{
-    if (!LoadStringA(dllModule, idx, buffer, MAX_ERROR_LEN))
-        buffer[0] = 0;
-}
-
-
-#endif /* _WIN32 */
-
-
-/* Packet Buffer for reassembly list and ready list */
-typedef struct PacketBuffer {
-    word32  begin;      /* relative sequence begin */
-    word32  end;        /* relative sequence end   */
-    byte*   data;       /* actual data             */
-    struct PacketBuffer* next; /* next on reassembly list or ready list */
-} PacketBuffer;
-
-
-#ifdef HAVE_SNI
-
-/* NamedKey maps a SNI name to a specific private key */
-typedef struct NamedKey {
-    char             name[MAX_SERVER_NAME];      /* server DNS name */
-    word32           nameSz;                     /* size of server DNS name */
-    byte*            key;                        /* DER private key */
-    word32           keySz;                      /* size of DER private key */
-    struct NamedKey* next;                       /* for list */
-} NamedKey;
-
-#endif
-
-
-/* Sniffer Server holds info for each server/port monitored */
-typedef struct SnifferServer {
-    SSL_CTX*       ctx;                          /* SSL context */
-    char           address[MAX_SERVER_ADDRESS];  /* passed in server address */
-    word32         server;                       /* netowrk order address */
-    int            port;                         /* server port */
-#ifdef HAVE_SNI
-    NamedKey*      namedKeys;                    /* mapping of names and keys */
-    wolfSSL_Mutex   namedKeysMutex;               /* mutex for namedKey list */
-#endif
-    struct SnifferServer* next;                  /* for list */
-} SnifferServer;
-
-
-/* Session Flags */
-typedef struct Flags {
-    byte           side;            /* which end is current packet headed */
-    byte           serverCipherOn;  /* indicates whether cipher is active */
-    byte           clientCipherOn;  /* indicates whether cipher is active */
-    byte           resuming;        /* did this session come from resumption */
-    byte           cached;          /* have we cached this session yet */
-    byte           clientHello;     /* processed client hello yet, for SSLv2 */
-    byte           finCount;        /* get both FINs before removing */
-    byte           fatalError;      /* fatal error state */
-} Flags;
-
-
-/* Out of Order FIN caputre */
-typedef struct FinCaputre {
-    word32 cliFinSeq;               /* client relative sequence FIN  0 is no */
-    word32 srvFinSeq;               /* server relative sequence FIN, 0 is no */
-    byte   cliCounted;              /* did we count yet, detects duplicates */
-    byte   srvCounted;              /* did we count yet, detects duplicates */
-} FinCaputre;
-
-
-/* Sniffer Session holds info for each client/server SSL/TLS session */
-typedef struct SnifferSession {
-    SnifferServer* context;         /* server context */
-    SSL*           sslServer;       /* SSL server side decode */
-    SSL*           sslClient;       /* SSL client side decode */
-    word32         server;          /* server address in network byte order */
-    word32         client;          /* client address in network byte order */
-    word16         srvPort;         /* server port */
-    word16         cliPort;         /* client port */
-    word32         cliSeqStart;     /* client start sequence */
-    word32         srvSeqStart;     /* server start sequence */
-    word32         cliExpected;     /* client expected sequence (relative) */
-    word32         srvExpected;     /* server expected sequence (relative) */
-    FinCaputre     finCaputre;      /* retain out of order FIN s */
-    Flags          flags;           /* session flags */
-    time_t         lastUsed;          /* last used ticks */
-    PacketBuffer*  cliReassemblyList; /* client out of order packets */
-    PacketBuffer*  srvReassemblyList; /* server out of order packets */
-    struct SnifferSession* next;      /* for hash table list */
-    byte*          ticketID;          /* mac ID of session ticket */
-} SnifferSession;
-
-
-/* Sniffer Server List and mutex */
-static SnifferServer* ServerList = 0;
-static wolfSSL_Mutex ServerListMutex;
-
-
-/* Session Hash Table, mutex, and count */
-static SnifferSession* SessionTable[HASH_SIZE];
-static wolfSSL_Mutex SessionMutex;
-static int SessionCount = 0;
-
-
-/* Initialize overall Sniffer */
-void ssl_InitSniffer(void)
-{
-    wolfSSL_Init();
-    InitMutex(&ServerListMutex);
-    InitMutex(&SessionMutex);
-}
-
-
-#ifdef HAVE_SNI
-
-/* Free Named Key and the zero out the private key it holds */
-static void FreeNamedKey(NamedKey* in)
-{
-    if (in) {
-        if (in->key) {
-            ForceZero(in->key, in->keySz);
-            free(in->key);
-        }
-        free(in);
-    }
-}
-
-
-static void FreeNamedKeyList(NamedKey* in)
-{
-    NamedKey* next;
-
-    while (in) {
-        next = in->next;
-        FreeNamedKey(in);
-        in = next;
-    }
-}
-
-#endif
-
-
-/* Free Sniffer Server's resources/self */
-static void FreeSnifferServer(SnifferServer* srv)
-{
-    if (srv) {
-#ifdef HAVE_SNI
-        LockMutex(&srv->namedKeysMutex);
-        FreeNamedKeyList(srv->namedKeys);
-        UnLockMutex(&srv->namedKeysMutex);
-        FreeMutex(&srv->namedKeysMutex);
-#endif
-        SSL_CTX_free(srv->ctx);
-    }
-    free(srv);
-}
-
-
-/* free PacketBuffer's resources/self */
-static void FreePacketBuffer(PacketBuffer* del)
-{
-    if (del) {
-        free(del->data);
-        free(del);
-    }
-}
-
-
-/* remove PacketBuffer List */
-static void FreePacketList(PacketBuffer* in)
-{
-    if (in) {
-        PacketBuffer* del;
-        PacketBuffer* packet = in;
-        
-        while (packet) {
-            del = packet;
-            packet = packet->next;
-            FreePacketBuffer(del);
-        }
-    }
-}
-
-
-/* Free Sniffer Session's resources/self */
-static void FreeSnifferSession(SnifferSession* session)
-{
-    if (session) {
-        SSL_free(session->sslClient);
-        SSL_free(session->sslServer);
-        
-        FreePacketList(session->cliReassemblyList);
-        FreePacketList(session->srvReassemblyList);
-
-        free(session->ticketID);
-    }
-    free(session);
-}
-
-
-/* Free overall Sniffer */
-void ssl_FreeSniffer(void)
-{
-    SnifferServer*  srv;
-    SnifferServer*  removeServer;
-    SnifferSession* session;
-    SnifferSession* removeSession;
-    int i;
-
-    LockMutex(&ServerListMutex);
-    LockMutex(&SessionMutex);
-    
-    srv = ServerList;
-    while (srv) {
-        removeServer = srv;
-        srv = srv->next;
-        FreeSnifferServer(removeServer);
-    }
-
-    for (i = 0; i < HASH_SIZE; i++) {
-        session = SessionTable[i];
-        while (session) {
-            removeSession = session;
-            session = session->next;
-            FreeSnifferSession(removeSession);
-        }
-    }
-
-    UnLockMutex(&SessionMutex);
-    UnLockMutex(&ServerListMutex);
-
-    FreeMutex(&SessionMutex);
-    FreeMutex(&ServerListMutex);
-
-    if (TraceFile) {
-        TraceOn = 0;
-        fclose(TraceFile);
-        TraceFile = NULL;
-    }
-
-    wolfSSL_Cleanup();
-}
-
-
-/* Initialize a SnifferServer */
-static void InitSnifferServer(SnifferServer* sniffer)
-{
-    sniffer->ctx = 0;
-    XMEMSET(sniffer->address, 0, MAX_SERVER_ADDRESS);
-    sniffer->server   = 0;
-    sniffer->port     = 0;
-#ifdef HAVE_SNI
-    sniffer->namedKeys = 0;
-    InitMutex(&sniffer->namedKeysMutex);
-#endif
-    sniffer->next     = 0;
-}
-
-
-/* Initialize session flags */
-static void InitFlags(Flags* flags)
-{
-    flags->side           = 0;
-    flags->serverCipherOn = 0;
-    flags->clientCipherOn = 0;
-    flags->resuming       = 0;
-    flags->cached         = 0;
-    flags->clientHello    = 0;
-    flags->finCount       = 0;
-    flags->fatalError     = 0;
-}
-
-
-/* Initialize FIN Capture */
-static void InitFinCapture(FinCaputre* cap)
-{
-    cap->cliFinSeq  = 0;
-    cap->srvFinSeq  = 0;
-    cap->cliCounted = 0;
-    cap->srvCounted = 0;
-}
-
-
-/* Initialize a Sniffer Session */
-static void InitSession(SnifferSession* session)
-{
-    session->context        = 0;
-    session->sslServer      = 0;
-    session->sslClient      = 0;
-    session->server         = 0;
-    session->client         = 0;
-    session->srvPort        = 0;
-    session->cliPort        = 0;
-    session->cliSeqStart    = 0;
-    session->srvSeqStart    = 0;
-    session->cliExpected    = 0;
-    session->srvExpected    = 0;
-    session->lastUsed       = 0;
-    session->cliReassemblyList = 0;
-    session->srvReassemblyList = 0;
-    session->next           = 0;
-    session->ticketID       = 0;
-    
-    InitFlags(&session->flags);
-    InitFinCapture(&session->finCaputre);
-}
-
-
-/* IP Info from IP Header */
-typedef struct IpInfo {
-    int    length;        /* length of this header */
-    int    total;         /* total length of fragment */
-    word32 src;           /* network order source address */
-    word32 dst;           /* network order destination address */
-} IpInfo;
-
-
-/* TCP Info from TCP Header */
-typedef struct TcpInfo {
-    int    srcPort;       /* source port */
-    int    dstPort;       /* source port */
-    int    length;        /* length of this header */
-    word32 sequence;      /* sequence number */
-    word32 ackNumber;     /* ack number */
-    byte   fin;           /* FIN set */
-    byte   rst;           /* RST set */
-    byte   syn;           /* SYN set */
-    byte   ack;           /* ACK set */
-} TcpInfo;
-
-
-/* Tcp Pseudo Header for Checksum calculation */
-typedef struct TcpPseudoHdr {
-    word32  src;        /* source address */
-    word32  dst;        /* destination address */
-    byte    rsv;        /* reserved, always 0 */
-    byte    protocol;   /* IP protocol */
-    word16  legnth;     /* tcp header length + data length (doesn't include */
-                        /* pseudo header length) network order */
-} TcpPseudoHdr;
-
-
-/* Password Setting Callback */
-static int SetPassword(char* passwd, int sz, int rw, void* userdata)
-{
-    (void)rw;
-    XSTRNCPY(passwd, (const char*)userdata, sz);
-    return (int)XSTRLEN((const char*)userdata);
-}
-
-
-/* Ethernet Header */
-typedef struct EthernetHdr {
-    byte   dst[ETHER_IF_ADDR_LEN];    /* destination host address */ 
-    byte   src[ETHER_IF_ADDR_LEN];    /* source  host address */ 
-    word16 type;                      /* IP, ARP, etc */ 
-} EthernetHdr;
-
-
-/* IP Header */
-typedef struct IpHdr {
-    byte    ver_hl;              /* version/header length */
-    byte    tos;                 /* type of service */
-    word16  length;              /* total length */
-    word16  id;                  /* identification */
-    word16  offset;              /* fragment offset field */
-    byte    ttl;                 /* time to live */
-    byte    protocol;            /* protocol */
-    word16  sum;                 /* checksum */
-    word32  src;                 /* source address */
-    word32  dst;                 /* destination address */
-} IpHdr;
-
-
-#define IP_HL(ip)      ( (((ip)->ver_hl) & 0x0f) * 4)
-#define IP_V(ip)       ( ((ip)->ver_hl) >> 4)
-
-/* TCP Header */
-typedef struct TcpHdr {
-    word16  srcPort;            /* source port */
-    word16  dstPort;            /* destination port */
-    word32  sequence;           /* sequence number */ 
-    word32  ack;                /* acknoledgment number */ 
-    byte    offset;             /* data offset, reserved */
-    byte    flags;              /* option flags */
-    word16  window;             /* window */
-    word16  sum;                /* checksum */
-    word16  urgent;             /* urgent pointer */
-} TcpHdr;
-
-#define TCP_LEN(tcp)  ( (((tcp)->offset & 0xf0) >> 4) * 4)
-#define TCP_FIN 0x01
-#define TCP_SYN 0x02
-#define TCP_RST 0x04
-#define TCP_ACK 0x10
-
-
-
-
-
-/* Use platform specific GetError to write to tracfile if tracing */ 
-static void Trace(int idx) 
-{
-    if (TraceOn) {
-        char myBuffer[MAX_ERROR_LEN];
-        GetError(idx, myBuffer);
-        fprintf(TraceFile, "\t%s\n", myBuffer);
-#ifdef DEBUG_SNIFFER
-        fprintf(stderr,    "\t%s\n", myBuffer);
-#endif
-    }
-}
-
-
-/* Show TimeStamp for beginning of packet Trace */
-static void TraceHeader(void)
-{
-    if (TraceOn) {
-        time_t ticks = time(NULL);
-        fprintf(TraceFile, "\n%s", ctime(&ticks));
-    }
-}
-
-
-/* Show Set Server info for Trace */
-static void TraceSetServer(const char* srv, int port, const char* keyFile)
-{
-    if (TraceOn) {
-        fprintf(TraceFile, "\tTrying to install a new Sniffer Server with\n");
-        fprintf(TraceFile, "\tserver: %s, port: %d, keyFile: %s\n", srv, port,
-                                                                    keyFile);
-    }
-}
-
-
-#ifdef HAVE_SNI
-
-/* Show Set Named Server info for Trace */
-static void TraceSetNamedServer(const char* name,
-                                 const char* srv, int port, const char* keyFile)
-{
-    if (TraceOn) {
-        fprintf(TraceFile, "\tTrying to install a new Sniffer Server with\n");
-        fprintf(TraceFile, "\tname: %s, server: %s, port: %d, keyFile: %s\n",
-                                                      name, srv, port, keyFile);
-    }
-}
-
-#endif
-
-
-/* Trace got packet number */
-static void TracePacket(void)
-{
-    if (TraceOn) {
-        static word32 packetNumber = 0;
-        fprintf(TraceFile, "\tGot a Packet to decode, packet %u\n",
-                ++packetNumber);
-    }
-}
-
-
-/* Convert network byte order address into human readable */
-static char* IpToS(word32 addr, char* str)
-{
-    byte* p = (byte*)&addr;
-    
-    SNPRINTF(str, TRACE_MSG_SZ, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
-    
-    return str;
-}
-
-
-/* Show destination and source address from Ip Hdr for packet Trace */
-static void TraceIP(IpHdr* iphdr)
-{
-    if (TraceOn) {
-        char src[TRACE_MSG_SZ];
-        char dst[TRACE_MSG_SZ];
-        fprintf(TraceFile, "\tdst:%s src:%s\n", IpToS(iphdr->dst, dst),
-                IpToS(iphdr->src, src));
-    }
-}
-
-
-/* Show destination and source port from Tcp Hdr for packet Trace */
-static void TraceTcp(TcpHdr* tcphdr)
-{
-    if (TraceOn) {
-        fprintf(TraceFile, "\tdstPort:%u srcPort:%u\n", ntohs(tcphdr->dstPort),
-                ntohs(tcphdr->srcPort));
-    }
-}
-
-
-/* Show sequence and payload length for Trace */
-static void TraceSequence(word32 seq, int len)
-{
-    if (TraceOn) {
-        fprintf(TraceFile, "\tSequence:%u, payload length:%d\n", seq, len);
-    }
-}
-
-
-/* Show sequence and payload length for Trace */
-static void TraceAck(word32 ack, word32 expected)
-{
-    if (TraceOn) {
-        fprintf(TraceFile, "\tAck:%u Expected:%u\n", ack, expected);
-    }
-}
-
-
-/* Show relative expected and relative received sequences */
-static void TraceRelativeSequence(word32 expected, word32 got)
-{
-    if (TraceOn) {
-        fprintf(TraceFile, "\tExpected sequence:%u, received sequence:%u\n",
-                expected, got);
-    }
-}
-
-
-/* Show server sequence startup from SYN */
-static void TraceServerSyn(word32 seq)
-{
-    if (TraceOn) {
-        fprintf(TraceFile, "\tServer SYN, Sequence Start:%u\n", seq);
-    }
-}
-
-
-/* Show client sequence startup from SYN */
-static void TraceClientSyn(word32 seq)
-{
-    if (TraceOn) {
-        fprintf(TraceFile, "\tClient SYN, Sequence Start:%u\n", seq);
-    }
-}
-
-
-/* Show client FIN capture */
-static void TraceClientFin(word32 finSeq, word32 relSeq)
-{
-    if (TraceOn) {
-        fprintf(TraceFile, "\tClient FIN capture:%u, current SEQ:%u\n",
-                finSeq, relSeq);
-    }
-}
-
-
-/* Show server FIN capture */
-static void TraceServerFin(word32 finSeq, word32 relSeq)
-{
-    if (TraceOn) {
-        fprintf(TraceFile, "\tServer FIN capture:%u, current SEQ:%u\n",
-                finSeq, relSeq);
-    }
-}
-
-
-/* Show number of SSL data bytes decoded, could be 0 (ok) */
-static void TraceGotData(int bytes)
-{
-    if (TraceOn) {
-        fprintf(TraceFile, "\t%d bytes of SSL App data processed\n", bytes);
-    }
-}
-
-
-/* Show bytes added to old SSL App data */
-static void TraceAddedData(int newBytes, int existingBytes)
-{
-    if (TraceOn) {
-        fprintf(TraceFile,
-                "\t%d bytes added to %d exisiting bytes in User Buffer\n",
-                newBytes, existingBytes);
-    }
-}
-
-
-/* Show Stale Session */
-static void TraceStaleSession(void)
-{
-    if (TraceOn) {
-        fprintf(TraceFile, "\tFound a stale session\n");
-    }
-}
-
-
-/* Show Finding Stale Sessions */
-static void TraceFindingStale(void)
-{
-    if (TraceOn) {
-        fprintf(TraceFile, "\tTrying to find Stale Sessions\n");
-    }
-}
-
-
-/* Show Removed Session */
-static void TraceRemovedSession(void)
-{
-    if (TraceOn) {
-        fprintf(TraceFile, "\tRemoved it\n");
-    }
-}
-
-
-/* Set user error string */
-static void SetError(int idx, char* error, SnifferSession* session, int fatal)
-{
-    GetError(idx, error);
-    Trace(idx);
-    if (session && fatal == FATAL_ERROR_STATE)
-        session->flags.fatalError = 1;
-}
-
-
-/* See if this IPV4 network order address has been registered */
-/* return 1 is true, 0 is false */
-static int IsServerRegistered(word32 addr)
-{
-    int ret = 0;     /* false */
-    SnifferServer* sniffer;
-
-    LockMutex(&ServerListMutex);
-    
-    sniffer = ServerList;
-    while (sniffer) {
-        if (sniffer->server == addr) {
-            ret = 1;
-            break;
-        }
-        sniffer = sniffer->next;
-    }
-    
-    UnLockMutex(&ServerListMutex);
-
-    return ret;
-}
-
-
-/* See if this port has been registered to watch */
-/* return 1 is true, 0 is false */
-static int IsPortRegistered(word32 port)
-{
-    int ret = 0;    /* false */
-    SnifferServer* sniffer;
-    
-    LockMutex(&ServerListMutex);
-    
-    sniffer = ServerList;
-    while (sniffer) {
-        if (sniffer->port == (int)port) {
-            ret = 1; 
-            break;
-        }
-        sniffer = sniffer->next;
-    }
-    
-    UnLockMutex(&ServerListMutex);
-
-    return ret;
-}
-
-
-/* Get SnifferServer from IP and Port */
-static SnifferServer* GetSnifferServer(IpInfo* ipInfo, TcpInfo* tcpInfo)
-{
-    SnifferServer* sniffer;
-    
-    LockMutex(&ServerListMutex);
-    
-    sniffer = ServerList;
-    while (sniffer) {
-        if (sniffer->port == tcpInfo->srcPort && sniffer->server == ipInfo->src)
-            break;
-        if (sniffer->port == tcpInfo->dstPort && sniffer->server == ipInfo->dst)
-            break;
-        sniffer = sniffer->next;
-    }
-    
-    UnLockMutex(&ServerListMutex);
-    
-    return sniffer;
-}
-
-
-/* Hash the Session Info, return hash row */
-static word32 SessionHash(IpInfo* ipInfo, TcpInfo* tcpInfo)
-{
-    word32 hash = ipInfo->src * ipInfo->dst;
-    hash *= tcpInfo->srcPort * tcpInfo->dstPort;
-    
-    return hash % HASH_SIZE;
-}
-
-
-/* Get Exisiting SnifferSession from IP and Port */
-static SnifferSession* GetSnifferSession(IpInfo* ipInfo, TcpInfo* tcpInfo)
-{
-    SnifferSession* session;
-    time_t          currTime = time(NULL); 
-    word32          row = SessionHash(ipInfo, tcpInfo);
-
-    assert(row <= HASH_SIZE);
-    
-    LockMutex(&SessionMutex);
-    
-    session = SessionTable[row];
-    while (session) {
-        if (session->server == ipInfo->src && session->client == ipInfo->dst &&
-                    session->srvPort == tcpInfo->srcPort &&
-                    session->cliPort == tcpInfo->dstPort)
-            break;
-        if (session->client == ipInfo->src && session->server == ipInfo->dst &&
-                    session->cliPort == tcpInfo->srcPort &&
-                    session->srvPort == tcpInfo->dstPort)
-            break;
-        
-        session = session->next;
-    }
-
-    if (session)
-        session->lastUsed= currTime; /* keep session alive, remove stale will */
-                                     /* leave alone */   
-    UnLockMutex(&SessionMutex);
-    
-    /* determine side */
-    if (session) {
-        if (ipInfo->dst == session->context->server &&
-            tcpInfo->dstPort == session->context->port)
-            session->flags.side = WOLFSSL_SERVER_END;
-        else
-            session->flags.side = WOLFSSL_CLIENT_END;
-    }    
-    
-    return session;
-}
-
-
-#ifdef HAVE_SNI
-
-static int LoadKeyFile(byte** keyBuf, word32* keyBufSz,
-                const char* keyFile, int typeKey,
-                const char* password)
-{
-    byte* loadBuf;
-    byte* saveBuf;
-    long fileSz = 0;
-    int saveBufSz;
-    XFILE file;
-    int ret;
-
-    if (keyBuf == NULL || keyBufSz == NULL || keyFile == NULL) {
-        return -1;
-    }
-
-    file = XFOPEN(keyFile, "rb");
-    if (file == XBADFILE) return -1;
-    XFSEEK(file, 0, XSEEK_END);
-    fileSz = XFTELL(file);
-    XREWIND(file);
-
-    loadBuf = (byte*)malloc(fileSz);
-    if (loadBuf == NULL) {
-        XFCLOSE(file);
-        return -1;
-    }
-
-    ret = (int)XFREAD(loadBuf, fileSz, 1, file);
-    XFCLOSE(file);
-
-    if (typeKey == SSL_FILETYPE_PEM) {
-        saveBuf = (byte*)malloc(fileSz);
-
-        saveBufSz = wolfSSL_KeyPemToDer(loadBuf, (int)fileSz,
-                                                saveBuf, (int)fileSz, password);
-        free(loadBuf);
-
-        *keyBuf = saveBuf;
-        *keyBufSz = (word32)saveBufSz;
-    }
-    else {
-        *keyBuf = loadBuf;
-        *keyBufSz = (word32)fileSz;
-    }
-
-
-    if (ret < 0) {
-        return -1;
-    }
-
-    return ret;
-}
-
-#endif
-
-
-static int SetNamedPrivateKey(const char* name, const char* address, int port,
-            const char* keyFile, int typeKey, const char* password, char* error)
-{
-    SnifferServer* sniffer;
-    int            ret;
-    int            type = (typeKey == FILETYPE_PEM) ? SSL_FILETYPE_PEM :
-                                                      SSL_FILETYPE_ASN1;
-    int            isNew = 0;
-    word32         serverIp;
-
-#ifdef HAVE_SNI
-    NamedKey* namedKey = NULL;
-#endif
-
-    (void)name;
-#ifdef HAVE_SNI
-    if (name != NULL) {
-        namedKey = (NamedKey*)malloc(sizeof(NamedKey));
-        if (namedKey == NULL) {
-            SetError(MEMORY_STR, error, NULL, 0);
-            return -1;
-        }
-        XMEMSET(namedKey, 0, sizeof(NamedKey));
-
-        namedKey->nameSz = (word32)XSTRLEN(name);
-        XSTRNCPY(namedKey->name, name, sizeof(namedKey->name));
-        if (namedKey->nameSz >= sizeof(namedKey->name)) {
-            namedKey->nameSz = sizeof(namedKey->name) - 1;
-            namedKey->name[namedKey->nameSz] = '\0';
-        }
-
-        ret = LoadKeyFile(&namedKey->key, &namedKey->keySz,
-                          keyFile, type, password);
-        if (ret < 0) {
-            SetError(KEY_FILE_STR, error, NULL, 0);
-            FreeNamedKey(namedKey);
-            return -1;
-        }
-    }
-#endif
-
-    serverIp = inet_addr(address);
-    sniffer = ServerList;
-    while (sniffer != NULL &&
-           (sniffer->server != serverIp || sniffer->port != port)) {
-        sniffer = sniffer->next;
-    }
-
-    if (sniffer == NULL) {
-        isNew = 1;
-        sniffer = (SnifferServer*)malloc(sizeof(SnifferServer));
-        if (sniffer == NULL) {
-            SetError(MEMORY_STR, error, NULL, 0);
-#ifdef HAVE_SNI
-            FreeNamedKey(namedKey);
-#endif
-            return -1;
-        }
-        InitSnifferServer(sniffer);
-
-        XSTRNCPY(sniffer->address, address, MAX_SERVER_ADDRESS-1);
-        sniffer->address[MAX_SERVER_ADDRESS-1] = '\0';
-        sniffer->server = serverIp;
-        sniffer->port = port;
-
-        sniffer->ctx = SSL_CTX_new(SSLv3_client_method());
-        if (!sniffer->ctx) {
-            SetError(MEMORY_STR, error, NULL, 0);
-#ifdef HAVE_SNI
-            FreeNamedKey(namedKey);
-#endif
-            FreeSnifferServer(sniffer);
-            return -1;
-        }
-    }
-
-    if (name == NULL) {
-        if (password) {
-            SSL_CTX_set_default_passwd_cb(sniffer->ctx, SetPassword);
-            SSL_CTX_set_default_passwd_cb_userdata(
-                                                 sniffer->ctx, (void*)password);
-        }
-        ret = SSL_CTX_use_PrivateKey_file(sniffer->ctx, keyFile, type);
-        if (ret != SSL_SUCCESS) {
-            SetError(KEY_FILE_STR, error, NULL, 0);
-            if (isNew)
-                FreeSnifferServer(sniffer);
-            return -1;
-        }
-    }
-#ifdef HAVE_SNI
-    else {
-        LockMutex(&sniffer->namedKeysMutex);
-        namedKey->next = sniffer->namedKeys;
-        sniffer->namedKeys = namedKey;
-        UnLockMutex(&sniffer->namedKeysMutex);
-    }
-#endif
-
-    if (isNew) {
-        sniffer->next = ServerList;
-        ServerList = sniffer;
-    }
-
-    return 0;
-}
-
-
-#ifdef HAVE_SNI
-
-/* Sets the private key for a specific name, server and port  */
-/* returns 0 on success, -1 on error */
-int ssl_SetNamedPrivateKey(const char* name,
-                           const char* address, int port,
-                           const char* keyFile, int typeKey,
-                           const char* password, char* error)
-{
-    int ret;
-
-    TraceHeader();
-    TraceSetNamedServer(name, address, port, keyFile);
-
-    LockMutex(&ServerListMutex);
-    ret = SetNamedPrivateKey(name, address, port, keyFile,
-                             typeKey, password, error);
-    UnLockMutex(&ServerListMutex);
-
-    if (ret == 0)
-        Trace(NEW_SERVER_STR);
-
-    return ret;
-}
-
-#endif
-
-
-/* Sets the private key for a specific server and port  */
-/* returns 0 on success, -1 on error */
-int ssl_SetPrivateKey(const char* address, int port, const char* keyFile,
-                      int typeKey, const char* password, char* error)
-{
-    int ret;
-
-    TraceHeader();
-    TraceSetServer(address, port, keyFile);
-
-    LockMutex(&ServerListMutex);
-    ret = SetNamedPrivateKey(NULL, address, port, keyFile,
-                             typeKey, password, error);
-    UnLockMutex(&ServerListMutex);
-
-    if (ret == 0)
-        Trace(NEW_SERVER_STR);
-
-    return ret;
-}
-
-
-/* Check IP Header for IPV4, TCP, and a registered server address */
-/* returns 0 on success, -1 on error */
-static int CheckIpHdr(IpHdr* iphdr, IpInfo* info, int length, char* error)
-{
-    int    version = IP_V(iphdr);
-
-    TraceIP(iphdr);
-    Trace(IP_CHECK_STR);
-
-    if (version != IPV4) {
-        SetError(BAD_IPVER_STR, error, NULL, 0); 
-        return -1;
-    }
-
-    if (iphdr->protocol != TCP_PROTOCOL) { 
-        SetError(BAD_PROTO_STR, error, NULL, 0);
-        return -1;
-    }
-
-    if (!IsServerRegistered(iphdr->src) && !IsServerRegistered(iphdr->dst)) {
-        SetError(SERVER_NOT_REG_STR, error, NULL, 0);
-        return -1;
-    }
-
-    info->length  = IP_HL(iphdr);
-    info->total   = ntohs(iphdr->length);
-    info->src     = iphdr->src;
-    info->dst     = iphdr->dst;
-
-    if (info->total == 0)
-        info->total = length;  /* reassembled may be off */
-
-    return 0;
-}
-
-
-/* Check TCP Header for a registered port */
-/* returns 0 on success, -1 on error */
-static int CheckTcpHdr(TcpHdr* tcphdr, TcpInfo* info, char* error)
-{
-    TraceTcp(tcphdr);
-    Trace(TCP_CHECK_STR);
-    info->srcPort   = ntohs(tcphdr->srcPort);
-    info->dstPort   = ntohs(tcphdr->dstPort);
-    info->length    = TCP_LEN(tcphdr);
-    info->sequence  = ntohl(tcphdr->sequence);
-    info->fin       = tcphdr->flags & TCP_FIN;
-    info->rst       = tcphdr->flags & TCP_RST;
-    info->syn       = tcphdr->flags & TCP_SYN;
-    info->ack       = tcphdr->flags & TCP_ACK;
-    if (info->ack)
-        info->ackNumber = ntohl(tcphdr->ack); 
-
-    if (!IsPortRegistered(info->srcPort) && !IsPortRegistered(info->dstPort)) {
-        SetError(SERVER_PORT_NOT_REG_STR, error, NULL, 0);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-/* Decode Record Layer Header */
-static int GetRecordHeader(const byte* input, RecordLayerHeader* rh, int* size)
-{
-    XMEMCPY(rh, input, RECORD_HEADER_SZ);
-    *size = (rh->length[0] << 8) | rh->length[1];
-
-    if (*size > (MAX_RECORD_SIZE + COMP_EXTRA + MAX_MSG_EXTRA))
-        return LENGTH_ERROR;
-
-    return 0;
-}
-
-
-/* Process Client Key Exchange, RSA only */
-static int ProcessClientKeyExchange(const byte* input, int* sslBytes,
-                                    SnifferSession* session, char* error)
-{
-    word32 idx = 0;
-    RsaKey key;
-    int    ret;
-
-    if (session->sslServer->buffers.key.buffer == NULL ||
-        session->sslServer->buffers.key.length == 0) {
-
-        SetError(RSA_KEY_MISSING_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-    ret = wc_InitRsaKey(&key, 0);
-    if (ret == 0)
-        ret = wc_RsaPrivateKeyDecode(session->sslServer->buffers.key.buffer,
-                          &idx, &key, session->sslServer->buffers.key.length);
-    if (ret == 0) {
-        int length = wc_RsaEncryptSize(&key);
-
-        if (IsTLS(session->sslServer))
-            input += 2;     /* tls pre length */
-
-        if (length > *sslBytes) {
-            SetError(PARTIAL_INPUT_STR, error, session, FATAL_ERROR_STATE);
-            wc_FreeRsaKey(&key);
-            return -1;
-        }
-        ret = wc_RsaPrivateDecrypt(input, length,
-                  session->sslServer->arrays->preMasterSecret,SECRET_LEN, &key);
-
-        if (ret != SECRET_LEN) {
-            SetError(RSA_DECRYPT_STR, error, session, FATAL_ERROR_STATE);
-            wc_FreeRsaKey(&key);
-            return -1;
-        }
-        ret = 0;  /* not in error state */
-        session->sslServer->arrays->preMasterSz = SECRET_LEN;
-
-        /* store for client side as well */
-        XMEMCPY(session->sslClient->arrays->preMasterSecret,
-               session->sslServer->arrays->preMasterSecret, SECRET_LEN);
-        session->sslClient->arrays->preMasterSz = SECRET_LEN;
-
-        #ifdef SHOW_SECRETS
-        {
-            int i;
-            printf("pre master secret: ");
-            for (i = 0; i < SECRET_LEN; i++)
-                printf("%02x", session->sslServer->arrays->preMasterSecret[i]);
-            printf("\n");
-        }
-        #endif
-    }
-    else {
-        SetError(RSA_DECODE_STR, error, session, FATAL_ERROR_STATE);
-        wc_FreeRsaKey(&key);
-        return -1;
-    }
-
-    if (SetCipherSpecs(session->sslServer) != 0) {
-        SetError(BAD_CIPHER_SPEC_STR, error, session, FATAL_ERROR_STATE);
-        wc_FreeRsaKey(&key);
-        return -1;
-    }
-
-    if (SetCipherSpecs(session->sslClient) != 0) {
-        SetError(BAD_CIPHER_SPEC_STR, error, session, FATAL_ERROR_STATE);
-        wc_FreeRsaKey(&key);
-        return -1;
-    }
-
-    ret  = MakeMasterSecret(session->sslServer);
-    ret += MakeMasterSecret(session->sslClient);
-    ret += SetKeysSide(session->sslServer, ENCRYPT_AND_DECRYPT_SIDE);
-    ret += SetKeysSide(session->sslClient, ENCRYPT_AND_DECRYPT_SIDE);
-
-    if (ret != 0) {
-        SetError(BAD_DERIVE_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-
-#ifdef SHOW_SECRETS
-    {
-        int i;
-        printf("server master secret: ");
-        for (i = 0; i < SECRET_LEN; i++)
-            printf("%02x", session->sslServer->arrays->masterSecret[i]);
-        printf("\n");
-
-        printf("client master secret: ");
-        for (i = 0; i < SECRET_LEN; i++)
-            printf("%02x", session->sslClient->arrays->masterSecret[i]);
-        printf("\n");
-
-        printf("server suite = %d\n", session->sslServer->options.cipherSuite);
-        printf("client suite = %d\n", session->sslClient->options.cipherSuite);
-    }
-#endif
-
-    wc_FreeRsaKey(&key);
-    return ret;
-}
-
-
-/* Process Session Ticket */
-static int ProcessSessionTicket(const byte* input, int* sslBytes,
-                                SnifferSession* session, char* error)
-{
-    word16 len;
-
-    /* make sure can read through hint and len */
-    if (TICKET_HINT_LEN + LENGTH_SZ > *sslBytes) {
-        SetError(BAD_INPUT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-
-    input     += TICKET_HINT_LEN;  /* skip over hint */
-    *sslBytes -= TICKET_HINT_LEN;
-
-    len = (word16)((input[0] << 8) | input[1]);
-    input     += LENGTH_SZ;
-    *sslBytes -= LENGTH_SZ;
-
-    /* make sure can read through ticket */
-    if (len > *sslBytes || len < ID_LEN) {
-        SetError(BAD_INPUT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-
-    /* store session with macID as sessionID */
-    session->sslServer->options.haveSessionId = 1;
-    XMEMCPY(session->sslServer->arrays->sessionID, input + len - ID_LEN,ID_LEN);
-
-    return 0;
-}
-
-
-/* Process Server Hello */
-static int ProcessServerHello(const byte* input, int* sslBytes,
-                              SnifferSession* session, char* error)
-{
-    ProtocolVersion pv;
-    byte            b;
-    int             toRead = VERSION_SZ + RAN_LEN + ENUM_LEN;
-    int             doResume     = 0;
-
-    /* make sure we didn't miss ClientHello */
-    if (session->flags.clientHello == 0) {
-        SetError(MISSED_CLIENT_HELLO_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-
-    /* make sure can read through session len */
-    if (toRead > *sslBytes) {
-        SetError(SERVER_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-
-    XMEMCPY(&pv, input, VERSION_SZ);
-    input     += VERSION_SZ;
-    *sslBytes -= VERSION_SZ;
-
-    session->sslServer->version = pv;
-    session->sslClient->version = pv;
-
-    XMEMCPY(session->sslServer->arrays->serverRandom, input, RAN_LEN);
-    XMEMCPY(session->sslClient->arrays->serverRandom, input, RAN_LEN);
-    input    += RAN_LEN;
-    *sslBytes -= RAN_LEN;
-
-    b = *input++;
-    *sslBytes -= 1;
-
-    /* make sure can read through compression */
-    if ( (b + SUITE_LEN + ENUM_LEN) > *sslBytes) {
-        SetError(SERVER_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-    if (b) {
-        XMEMCPY(session->sslServer->arrays->sessionID, input, ID_LEN);
-        session->sslServer->options.haveSessionId = 1;
-    }
-    input     += b;
-    *sslBytes -= b;
-
-    /* cipher suite */
-    b = *input++;  /* first byte, ECC or not */
-    session->sslServer->options.cipherSuite0 = b;
-    session->sslClient->options.cipherSuite0 = b;
-    b = *input++;
-    session->sslServer->options.cipherSuite = b;
-    session->sslClient->options.cipherSuite = b;
-    *sslBytes -= SUITE_LEN;
-
-    /* compression */
-    b = *input++;
-    *sslBytes -= ENUM_LEN;
-
-    if (b) {
-        SetError(BAD_COMPRESSION_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-
-    if (session->sslServer->options.haveSessionId &&
-            XMEMCMP(session->sslServer->arrays->sessionID,
-                    session->sslClient->arrays->sessionID, ID_LEN) == 0)
-        doResume = 1;
-    else if (session->sslClient->options.haveSessionId == 0 &&
-             session->sslServer->options.haveSessionId == 0 &&
-             session->ticketID)
-        doResume = 1;
-
-    if (session->ticketID && doResume) {
-        /* use ticketID to retrieve from session, prefer over sessionID */
-        XMEMCPY(session->sslServer->arrays->sessionID,session->ticketID,ID_LEN);
-        session->sslServer->options.haveSessionId = 1;  /* may not have
-                                                           actual sessionID */
-    }
-
-    if (doResume ) {
-        int ret = 0;
-        SSL_SESSION* resume = GetSession(session->sslServer,
-                                      session->sslServer->arrays->masterSecret);
-        if (resume == NULL) {
-            SetError(BAD_SESSION_RESUME_STR, error, session, FATAL_ERROR_STATE);
-            return -1;
-        }
-        /* make sure client has master secret too */
-        XMEMCPY(session->sslClient->arrays->masterSecret,
-               session->sslServer->arrays->masterSecret, SECRET_LEN);
-        session->flags.resuming = 1;
-
-        Trace(SERVER_DID_RESUMPTION_STR);
-        if (SetCipherSpecs(session->sslServer) != 0) {
-            SetError(BAD_CIPHER_SPEC_STR, error, session, FATAL_ERROR_STATE);
-            return -1;
-        }
-
-        if (SetCipherSpecs(session->sslClient) != 0) {
-            SetError(BAD_CIPHER_SPEC_STR, error, session, FATAL_ERROR_STATE);
-            return -1;
-        }
-
-        if (session->sslServer->options.tls) {
-            ret =  DeriveTlsKeys(session->sslServer);
-            ret += DeriveTlsKeys(session->sslClient);
-        }
-        else {
-            ret =  DeriveKeys(session->sslServer);
-            ret += DeriveKeys(session->sslClient);
-        }
-        ret += SetKeysSide(session->sslServer, ENCRYPT_AND_DECRYPT_SIDE);
-        ret += SetKeysSide(session->sslClient, ENCRYPT_AND_DECRYPT_SIDE);
-
-        if (ret != 0) {
-            SetError(BAD_DERIVE_STR, error, session, FATAL_ERROR_STATE);
-            return -1;
-        }
-    }
-#ifdef SHOW_SECRETS
-    {
-        int i;
-        printf("cipher suite = 0x%02x\n",
-               session->sslServer->options.cipherSuite);
-        printf("server random: ");
-        for (i = 0; i < RAN_LEN; i++)
-            printf("%02x", session->sslServer->arrays->serverRandom[i]);
-        printf("\n");
-    }
-#endif
-    return 0;
-}
-
-
-/* Process normal Client Hello */
-static int ProcessClientHello(const byte* input, int* sslBytes,
-                              SnifferSession* session, char* error)
-{
-    byte   bLen;
-    word16 len;
-    int    toRead = VERSION_SZ + RAN_LEN + ENUM_LEN;
-
-#ifdef HAVE_SNI
-    {
-        byte name[MAX_SERVER_NAME];
-        word32 nameSz = sizeof(name);
-        int ret;
-
-        ret = wolfSSL_SNI_GetFromBuffer(
-                             input - HANDSHAKE_HEADER_SZ - RECORD_HEADER_SZ,
-                             *sslBytes + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ,
-                             WOLFSSL_SNI_HOST_NAME, name, &nameSz);
-
-        if (ret == SSL_SUCCESS) {
-            NamedKey* namedKey;
-
-            if (nameSz >= sizeof(name))
-                nameSz = sizeof(name) - 1;
-            name[nameSz] = 0;
-            LockMutex(&session->context->namedKeysMutex);
-            namedKey = session->context->namedKeys;
-            while (namedKey != NULL) {
-                if (nameSz == namedKey->nameSz &&
-                           XSTRNCMP((char*)name, namedKey->name, nameSz) == 0) {
-                    if (wolfSSL_use_PrivateKey_buffer(session->sslServer,
-                                            namedKey->key, namedKey->keySz,
-                                            SSL_FILETYPE_ASN1) != SSL_SUCCESS) {
-                        UnLockMutex(&session->context->namedKeysMutex);
-                        SetError(CLIENT_HELLO_LATE_KEY_STR, error, session,
-                                                             FATAL_ERROR_STATE);
-                        return -1;
-                    }
-                    break;
-                }
-                else
-                    namedKey = namedKey->next;
-            }
-            UnLockMutex(&session->context->namedKeysMutex);
-        }
-    }
-#endif
-
-    session->flags.clientHello = 1;  /* don't process again */
-
-    /* make sure can read up to session len */
-    if (toRead > *sslBytes) {
-        SetError(CLIENT_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-
-    /* skip, get negotiated one from server hello */
-    input     += VERSION_SZ;
-    *sslBytes -= VERSION_SZ;
-
-    XMEMCPY(session->sslServer->arrays->clientRandom, input, RAN_LEN);
-    XMEMCPY(session->sslClient->arrays->clientRandom, input, RAN_LEN);
-
-    input     += RAN_LEN;
-    *sslBytes -= RAN_LEN;
-
-    /* store session in case trying to resume */
-    bLen = *input++;
-    *sslBytes -= ENUM_LEN;
-    if (bLen) {
-        if (ID_LEN > *sslBytes) {
-            SetError(CLIENT_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE);
-            return -1;
-        }
-        Trace(CLIENT_RESUME_TRY_STR);
-        XMEMCPY(session->sslClient->arrays->sessionID, input, ID_LEN);
-        session->sslClient->options.haveSessionId = 1;
-    }
-#ifdef SHOW_SECRETS
-    {
-        int i;
-        printf("client random: ");
-        for (i = 0; i < RAN_LEN; i++)
-            printf("%02x", session->sslServer->arrays->clientRandom[i]);
-        printf("\n");
-    }
-#endif
-
-    input     += bLen;
-    *sslBytes -= bLen;
-
-    /* skip cipher suites */
-    /* make sure can read len */
-    if (SUITE_LEN > *sslBytes) {
-        SetError(CLIENT_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-    len = (word16)((input[0] << 8) | input[1]);
-    input     += SUITE_LEN;
-    *sslBytes -= SUITE_LEN;
-    /* make sure can read suites + comp len */
-    if (len + ENUM_LEN > *sslBytes) {
-        SetError(CLIENT_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-    input     += len;
-    *sslBytes -= len;
-
-    /* skip compression */
-    bLen       = *input++;
-    *sslBytes -= ENUM_LEN;
-    /* make sure can read len */
-    if (bLen > *sslBytes) {
-        SetError(CLIENT_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-    input     += bLen;
-    *sslBytes -= bLen;
-  
-    if (*sslBytes == 0) {
-        /* no extensions */
-        return 0;
-    }
-    
-    /* skip extensions until session ticket */
-    /* make sure can read len */
-    if (SUITE_LEN > *sslBytes) {
-        SetError(CLIENT_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-    len = (word16)((input[0] << 8) | input[1]);
-    input     += SUITE_LEN;
-    *sslBytes -= SUITE_LEN;
-    /* make sure can read through all extensions */
-    if (len > *sslBytes) {
-        SetError(CLIENT_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-
-    while (len > EXT_TYPE_SZ + LENGTH_SZ) {
-        byte   extType[EXT_TYPE_SZ];
-        word16 extLen;
-
-        extType[0] = input[0];
-        extType[1] = input[1];
-        input     += EXT_TYPE_SZ;
-        *sslBytes -= EXT_TYPE_SZ;
-
-        extLen = (word16)((input[0] << 8) | input[1]);
-        input     += LENGTH_SZ;
-        *sslBytes -= LENGTH_SZ;
-
-        /* make sure can read through individual extension */
-        if (extLen > *sslBytes) {
-            SetError(CLIENT_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE);
-            return -1;
-        }
-
-        if (extType[0] == 0x00 && extType[1] == TICKET_EXT_ID) {
-
-            /* make sure can read through ticket if there is a non blank one */
-            if (extLen && extLen < ID_LEN) {
-                SetError(CLIENT_HELLO_INPUT_STR, error, session,
-                         FATAL_ERROR_STATE);
-                return -1;
-            }
-
-            if (extLen) {
-                if (session->ticketID == 0) {
-                    session->ticketID = (byte*)malloc(ID_LEN);
-                    if (session->ticketID == 0) {
-                        SetError(MEMORY_STR, error, session,
-                                 FATAL_ERROR_STATE);
-                        return -1;
-                    }
-                }
-                XMEMCPY(session->ticketID, input + extLen - ID_LEN, ID_LEN);
-            }
-        }
-
-        input     += extLen;
-        *sslBytes -= extLen;
-        len       -= extLen + EXT_TYPE_SZ + LENGTH_SZ;
-    }
-
-    return 0;
-}
-
-
-/* Process Finished */
-static int ProcessFinished(const byte* input, int size, int* sslBytes,
-                           SnifferSession* session, char* error)
-{
-    SSL*   ssl;
-    word32 inOutIdx = 0;
-    int    ret;
-                
-    if (session->flags.side == WOLFSSL_SERVER_END)
-        ssl = session->sslServer;
-    else
-        ssl = session->sslClient;
-
-    ret = DoFinished(ssl, input, &inOutIdx, (word32) size, (word32) *sslBytes,
-                                                                         SNIFF);
-    *sslBytes -= (int)inOutIdx;
-
-    if (ret < 0) {
-        SetError(BAD_FINISHED_MSG, error, session, FATAL_ERROR_STATE);
-        return ret;
-    }
-                
-    if (ret == 0 && session->flags.cached == 0) {
-        if (session->sslServer->options.haveSessionId) {
-            WOLFSSL_SESSION* sess = GetSession(session->sslServer, NULL);
-            if (sess == NULL)
-                AddSession(session->sslServer);  /* don't re add */
-            session->flags.cached = 1;
-         }
-    }
-
-    /* If receiving a finished message from one side, free the resources
-     * from the other side's tracker. */
-    if (session->flags.side == WOLFSSL_SERVER_END)
-        FreeHandshakeResources(session->sslClient);
-    else
-        FreeHandshakeResources(session->sslServer);
-
-    return ret;
-}
-
-
-/* Process HandShake input */
-static int DoHandShake(const byte* input, int* sslBytes,
-                       SnifferSession* session, char* error)
-{
-    byte type;
-    int  size;
-    int  ret = 0;
-    int  startBytes;
-
-    if (*sslBytes < HANDSHAKE_HEADER_SZ) {
-        SetError(HANDSHAKE_INPUT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-    type = input[0];
-    size = (input[1] << 16) | (input[2] << 8) | input[3];
-    
-    input     += HANDSHAKE_HEADER_SZ;
-    *sslBytes -= HANDSHAKE_HEADER_SZ;
-    startBytes = *sslBytes;
-
-    if (*sslBytes < size) {
-        SetError(HANDSHAKE_INPUT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-    
-    switch (type) {
-        case hello_verify_request:
-            Trace(GOT_HELLO_VERIFY_STR);
-            break;
-        case hello_request:
-            Trace(GOT_HELLO_REQUEST_STR);
-            break;
-        case session_ticket:
-            Trace(GOT_SESSION_TICKET_STR);
-            ret = ProcessSessionTicket(input, sslBytes, session, error);
-            break;
-        case server_hello:
-            Trace(GOT_SERVER_HELLO_STR);
-            ret = ProcessServerHello(input, sslBytes, session, error);
-            break;
-        case certificate_request:
-            Trace(GOT_CERT_REQ_STR);
-            break;
-        case server_key_exchange:
-            Trace(GOT_SERVER_KEY_EX_STR);
-            /* can't know temp key passively */
-            SetError(BAD_CIPHER_SPEC_STR, error, session, FATAL_ERROR_STATE);
-            ret = -1;
-            break;
-        case certificate:
-            Trace(GOT_CERT_STR);
-            break;
-        case server_hello_done:
-            Trace(GOT_SERVER_HELLO_DONE_STR);
-            break;
-        case finished:
-            Trace(GOT_FINISHED_STR);
-            ret = ProcessFinished(input, size, sslBytes, session, error);
-            break;
-        case client_hello:
-            Trace(GOT_CLIENT_HELLO_STR);
-            ret = ProcessClientHello(input, sslBytes, session, error);
-            break;
-        case client_key_exchange:
-            Trace(GOT_CLIENT_KEY_EX_STR);
-            ret = ProcessClientKeyExchange(input, sslBytes, session, error);
-            break;
-        case certificate_verify:
-            Trace(GOT_CERT_VER_STR);
-            break;
-        case certificate_status:
-            Trace(GOT_CERT_STATUS_STR);
-            break;
-        default:
-            SetError(GOT_UNKNOWN_HANDSHAKE_STR, error, session, 0);
-            return -1;
-    }
-
-    *sslBytes = startBytes - size;  /* actual bytes of full process */
-
-    return ret;
-}
-
-
-/* Decrypt input into plain output, 0 on success */
-static int Decrypt(SSL* ssl, byte* output, const byte* input, word32 sz)
-{
-    int ret = 0;
-
-    switch (ssl->specs.bulk_cipher_algorithm) {
-        #ifdef BUILD_ARC4
-        case wolfssl_rc4:
-            wc_Arc4Process(ssl->decrypt.arc4, output, input, sz);
-            break;
-        #endif
-            
-        #ifdef BUILD_DES3
-        case wolfssl_triple_des:
-            ret = wc_Des3_CbcDecrypt(ssl->decrypt.des3, output, input, sz);
-            break;
-        #endif
-            
-        #ifdef BUILD_AES
-        case wolfssl_aes:
-            ret = wc_AesCbcDecrypt(ssl->decrypt.aes, output, input, sz);
-            break;
-        #endif
-            
-        #ifdef HAVE_HC128
-        case wolfssl_hc128:
-            wc_Hc128_Process(ssl->decrypt.hc128, output, input, sz);
-            break;
-        #endif
-            
-        #ifdef BUILD_RABBIT
-        case wolfssl_rabbit:
-            wc_RabbitProcess(ssl->decrypt.rabbit, output, input, sz);
-            break;
-        #endif
-
-        #ifdef HAVE_CAMELLIA 
-        case wolfssl_camellia:
-            wc_CamelliaCbcDecrypt(ssl->decrypt.cam, output, input, sz);
-            break;
-        #endif
-
-        default:
-            Trace(BAD_DECRYPT_TYPE);
-            ret = -1;
-            break;
-    }
-
-    return ret;
-}
-
-
-/* Decrypt input message into output, adjust output steam if needed */
-static const byte* DecryptMessage(SSL* ssl, const byte* input, word32 sz,
-                                  byte* output, int* error, int* advance)
-{
-    int ivExtra = 0;
-
-    int ret = Decrypt(ssl, output, input, sz);
-    if (ret != 0) {
-        *error = ret;
-        return NULL;
-    }
-    ssl->keys.encryptSz = sz;
-    if (ssl->options.tls1_1 && ssl->specs.cipher_type == block) {
-        output += ssl->specs.block_size;     /* go past TLSv1.1 IV */
-        ivExtra = ssl->specs.block_size;
-        *advance = ssl->specs.block_size;
-    }
-
-    ssl->keys.padSz = ssl->specs.hash_size;
-
-    if (ssl->specs.cipher_type == block)
-        ssl->keys.padSz += *(output + sz - ivExtra - 1) + 1;
-    
-    return output;
-}
-
-
-/* remove session from table, use rowHint if no info (means we have a lock) */
-static void RemoveSession(SnifferSession* session, IpInfo* ipInfo,
-                        TcpInfo* tcpInfo, word32 rowHint)
-{
-    SnifferSession* previous = 0;
-    SnifferSession* current;
-    word32          row = rowHint;
-    int             haveLock = 0;
-   
-    if (ipInfo && tcpInfo)
-        row = SessionHash(ipInfo, tcpInfo);
-    else
-        haveLock = 1;
-    
-    assert(row <= HASH_SIZE);
-    Trace(REMOVE_SESSION_STR);
-    
-    if (!haveLock)
-        LockMutex(&SessionMutex);
-    
-    current = SessionTable[row];
-    
-    while (current) {
-        if (current == session) {
-            if (previous)
-                previous->next = current->next;
-            else
-                SessionTable[row] = current->next;
-            FreeSnifferSession(session);
-            TraceRemovedSession();
-            break;
-        }
-        previous = current;
-        current  = current->next;
-    }
-    
-    if (!haveLock)
-        UnLockMutex(&SessionMutex);
-}
-
-
-/* Remove stale sessions from the Session Table, have a lock */
-static void RemoveStaleSessions(void)
-{
-    word32 i;
-    SnifferSession* session;
-    
-    for (i = 0; i < HASH_SIZE; i++) {
-        session = SessionTable[i];
-        while (session) {
-            SnifferSession* next = session->next; 
-            if (time(NULL) >= session->lastUsed + WOLFSSL_SNIFFER_TIMEOUT) {
-                TraceStaleSession();
-                RemoveSession(session, NULL, NULL, i);
-            }
-            session = next;
-        }
-    }
-}
-
-
-/* Create a new Sniffer Session */
-static SnifferSession* CreateSession(IpInfo* ipInfo, TcpInfo* tcpInfo,
-                                     char* error)
-{
-    SnifferSession* session = 0;
-    int row;
-        
-    Trace(NEW_SESSION_STR);
-    /* create a new one */
-    session = (SnifferSession*)malloc(sizeof(SnifferSession));
-    if (session == NULL) {
-        SetError(MEMORY_STR, error, NULL, 0);
-        return 0;
-    }
-    InitSession(session);
-    session->server  = ipInfo->dst;
-    session->client  = ipInfo->src;
-    session->srvPort = (word16)tcpInfo->dstPort;
-    session->cliPort = (word16)tcpInfo->srcPort;
-    session->cliSeqStart = tcpInfo->sequence;
-    session->cliExpected = 1;  /* relative */
-    session->lastUsed= time(NULL);
-                
-    session->context = GetSnifferServer(ipInfo, tcpInfo);
-    if (session->context == NULL) {
-        SetError(SERVER_NOT_REG_STR, error, NULL, 0);
-        free(session);
-        return 0;
-    }
-        
-    session->sslServer = SSL_new(session->context->ctx);
-    if (session->sslServer == NULL) {
-        SetError(BAD_NEW_SSL_STR, error, session, FATAL_ERROR_STATE);
-        free(session);
-        return 0;
-    }
-    session->sslClient = SSL_new(session->context->ctx);
-    if (session->sslClient == NULL) {
-        SSL_free(session->sslServer);
-        session->sslServer = 0;
-
-        SetError(BAD_NEW_SSL_STR, error, session, FATAL_ERROR_STATE);
-        free(session);
-        return 0;
-    }
-    /* put server back into server mode */
-    session->sslServer->options.side = WOLFSSL_SERVER_END;
-        
-    row = SessionHash(ipInfo, tcpInfo);
-    
-    /* add it to the session table */
-    LockMutex(&SessionMutex);
-        
-    session->next = SessionTable[row];
-    SessionTable[row] = session;
-    
-    SessionCount++;
-    
-    if ( (SessionCount % HASH_SIZE) == 0) {
-        TraceFindingStale();
-        RemoveStaleSessions();
-    }
-        
-    UnLockMutex(&SessionMutex);
-        
-    /* determine headed side */
-    if (ipInfo->dst == session->context->server &&
-        tcpInfo->dstPort == session->context->port)
-        session->flags.side = WOLFSSL_SERVER_END;
-    else
-        session->flags.side = WOLFSSL_CLIENT_END;        
-    
-    return session;
-}
-
-
-#ifdef OLD_HELLO_ALLOWED
-
-/* Process Old Client Hello Input */
-static int DoOldHello(SnifferSession* session, const byte* sslFrame,
-                      int* rhSize, int* sslBytes, char* error)
-{
-    const byte* input = sslFrame;
-    byte        b0, b1;
-    word32      idx = 0;
-    int         ret;
-
-    Trace(GOT_OLD_CLIENT_HELLO_STR);
-    session->flags.clientHello = 1;    /* don't process again */
-    b0 = *input++;
-    b1 = *input++;
-    *sslBytes -= 2;
-    *rhSize = ((b0 & 0x7f) << 8) | b1;
-
-    if (*rhSize > *sslBytes) {
-        SetError(OLD_CLIENT_INPUT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-
-    ret = ProcessOldClientHello(session->sslServer, input, &idx, *sslBytes,
-                                (word16)*rhSize);    
-    if (ret < 0 && ret != MATCH_SUITE_ERROR) {
-        SetError(BAD_OLD_CLIENT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-    
-    Trace(OLD_CLIENT_OK_STR);
-    XMEMCPY(session->sslClient->arrays->clientRandom,
-           session->sslServer->arrays->clientRandom, RAN_LEN);
-    
-    *sslBytes -= *rhSize;
-    return 0;
-}
-
-#endif /* OLD_HELLO_ALLOWED */
-
-
-#if 0
-/* Calculate the TCP checksum, see RFC 1071 */
-/* return 0 for success, -1 on error */
-/* can be called from decode() with
-   TcpChecksum(&ipInfo, &tcpInfo, sslBytes, packet + ipInfo.length);
-   could also add a 64bit version if type available and using this
-*/
-int TcpChecksum(IpInfo* ipInfo, TcpInfo* tcpInfo, int dataLen,
-                const byte* packet)
-{
-    TcpPseudoHdr  pseudo;
-    int           count = PSEUDO_HDR_SZ;
-    const word16* data = (word16*)&pseudo;
-    word32        sum = 0;
-    word16        checksum;
-    
-    pseudo.src = ipInfo->src;
-    pseudo.dst = ipInfo->dst;
-    pseudo.rsv = 0;
-    pseudo.protocol = TCP_PROTO;
-    pseudo.legnth = htons(tcpInfo->length + dataLen);
-    
-    /* pseudo header sum */
-    while (count >= 2) {
-        sum   += *data++;
-        count -= 2;
-    }
-    
-    count = tcpInfo->length + dataLen;
-    data = (word16*)packet;
-    
-    /* main sum */
-    while (count > 1) {
-        sum   += *data++;
-        count -=2;
-    }
-    
-    /* get left-over, if any */
-    packet = (byte*)data;
-    if (count > 0) {
-        sum += *packet;
-    }
-    
-    /* fold 32bit sum into 16 bits */
-    while (sum >> 16)
-        sum = (sum & 0xffff) + (sum >> 16);
-    
-    checksum = (word16)~sum;
-    /* checksum should now equal 0, since included already calcd checksum */
-    /* field, but tcp checksum offloading could negate calculation */
-    if (checksum == 0)
-        return 0;
-    return -1;
-}
-#endif
-
-
-/* Check IP and TCP headers, set payload */
-/* returns 0 on success, -1 on error */
-static int CheckHeaders(IpInfo* ipInfo, TcpInfo* tcpInfo, const byte* packet,
-                  int length, const byte** sslFrame, int* sslBytes, char* error)
-{
-    TraceHeader();
-    TracePacket();
-
-    /* ip header */
-    if (length < IP_HDR_SZ) {
-        SetError(PACKET_HDR_SHORT_STR, error, NULL, 0);
-        return -1;
-    }
-    if (CheckIpHdr((IpHdr*)packet, ipInfo, length, error) != 0)
-        return -1;
-   
-    /* tcp header */ 
-    if (length < (ipInfo->length + TCP_HDR_SZ)) {
-        SetError(PACKET_HDR_SHORT_STR, error, NULL, 0);
-        return -1;
-    }
-    if (CheckTcpHdr((TcpHdr*)(packet + ipInfo->length), tcpInfo, error) != 0)
-        return -1;
-   
-    /* setup */ 
-    *sslFrame = packet + ipInfo->length + tcpInfo->length;
-    if (*sslFrame > packet + length) {
-        SetError(PACKET_HDR_SHORT_STR, error, NULL, 0);
-        return -1;
-    }
-    *sslBytes = (int)(packet + length - *sslFrame);
-    
-    return 0;
-}
-
-
-/* Create or Find existing session */
-/* returns 0 on success (continue), -1 on error, 1 on success (end) */
-static int CheckSession(IpInfo* ipInfo, TcpInfo* tcpInfo, int sslBytes,
-                        SnifferSession** session, char* error)
-{
-    /* create a new SnifferSession on client SYN */
-    if (tcpInfo->syn && !tcpInfo->ack) {
-        TraceClientSyn(tcpInfo->sequence);
-        *session = CreateSession(ipInfo, tcpInfo, error);
-        if (*session == NULL) {
-            *session = GetSnifferSession(ipInfo, tcpInfo);
-            /* already had exisiting, so OK */
-            if (*session)
-                return 1;
-            
-            SetError(MEMORY_STR, error, NULL, 0);
-            return -1;
-        }
-        return 1;
-    }
-    /* get existing sniffer session */
-    else {
-        *session = GetSnifferSession(ipInfo, tcpInfo);
-        if (*session == NULL) {
-            /* don't worry about extraneous RST or duplicate FINs */
-            if (tcpInfo->fin || tcpInfo->rst)
-                return 1;
-            /* don't worry about duplicate ACKs either */
-            if (sslBytes == 0 && tcpInfo->ack)
-                return 1;
-            
-            SetError(BAD_SESSION_STR, error, NULL, 0);
-            return -1;
-        }        
-    }
-    return 0;
-}
-
-
-/* Create a Packet Buffer from *begin - end, adjust new *begin and bytesLeft */
-static PacketBuffer* CreateBuffer(word32* begin, word32 end, const byte* data,
-                                  int* bytesLeft)
-{
-    PacketBuffer* pb;
-    
-    int added = end - *begin + 1;
-    assert(*begin <= end);
-    
-    pb = (PacketBuffer*)malloc(sizeof(PacketBuffer));
-    if (pb == NULL) return NULL;
-    
-    pb->next  = 0;
-    pb->begin = *begin;
-    pb->end   = end;
-    pb->data = (byte*)malloc(added);
-    
-    if (pb->data == NULL) {
-        free(pb);
-        return NULL;
-    }
-    XMEMCPY(pb->data, data, added);
-    
-    *bytesLeft -= added;
-    *begin      = pb->end + 1;
-    
-    return pb;
-}
-
-
-/* Add sslFrame to Reassembly List */
-/* returns 1 (end) on success, -1, on error */
-static int AddToReassembly(byte from, word32 seq, const byte* sslFrame,
-                           int sslBytes, SnifferSession* session, char* error)
-{
-    PacketBuffer*  add;
-    PacketBuffer** front = (from == WOLFSSL_SERVER_END) ?
-                       &session->cliReassemblyList: &session->srvReassemblyList;
-    PacketBuffer*  curr = *front;
-    PacketBuffer*  prev = curr;
-    
-    word32  startSeq = seq;
-    word32  added;
-    int     bytesLeft = sslBytes;  /* could be overlapping fragment */
-
-    /* if list is empty add full frame to front */
-    if (!curr) {
-        add = CreateBuffer(&seq, seq + sslBytes - 1, sslFrame, &bytesLeft);
-        if (add == NULL) {
-            SetError(MEMORY_STR, error, session, FATAL_ERROR_STATE);
-            return -1;
-        }
-        *front = add;
-        return 1;
-    }
-    
-    /* add to front if before current front, up to next->begin */
-    if (seq < curr->begin) {
-        word32 end = seq + sslBytes - 1;
-        
-        if (end >= curr->begin)
-            end = curr->begin - 1;
-        
-        add = CreateBuffer(&seq, end, sslFrame, &bytesLeft);
-        if (add == NULL) {
-            SetError(MEMORY_STR, error, session, FATAL_ERROR_STATE);
-            return -1;
-        }
-        add->next = curr;
-        *front = add;
-    }
-    
-    /* while we have bytes left, try to find a gap to fill */
-    while (bytesLeft > 0) {
-        /* get previous packet in list */
-        while (curr && (seq >= curr->begin)) {
-            prev = curr;
-            curr = curr->next;
-        }
-        
-        /* don't add  duplicate data */
-        if (prev->end >= seq) {
-            if ( (seq + bytesLeft - 1) <= prev->end)
-                return 1;
-            seq = prev->end + 1;
-            bytesLeft = startSeq + sslBytes - seq;
-        }
-        
-        if (!curr)
-            /* we're at the end */
-            added = bytesLeft;
-        else 
-            /* we're in between two frames */
-            added = min((word32)bytesLeft, curr->begin - seq);
-        
-        /* data already there */
-        if (added == 0)
-            continue;
-        
-        add = CreateBuffer(&seq, seq + added - 1, &sslFrame[seq - startSeq],
-                           &bytesLeft);
-        if (add == NULL) {
-            SetError(MEMORY_STR, error, session, FATAL_ERROR_STATE);
-            return -1;
-        }
-        add->next  = prev->next;
-        prev->next = add;
-    }
-    return 1;
-}
-
-
-/* Add out of order FIN capture */
-/* returns 1 for success (end) */
-static int AddFinCapture(SnifferSession* session, word32 sequence)
-{
-    if (session->flags.side == WOLFSSL_SERVER_END) {
-        if (session->finCaputre.cliCounted == 0)
-            session->finCaputre.cliFinSeq = sequence;
-    }
-    else {
-        if (session->finCaputre.srvCounted == 0)
-            session->finCaputre.srvFinSeq = sequence;
-    }
-    return 1;
-}
-
-
-/* Adjust incoming sequence based on side */
-/* returns 0 on success (continue), -1 on error, 1 on success (end) */
-static int AdjustSequence(TcpInfo* tcpInfo, SnifferSession* session,
-                          int* sslBytes, const byte** sslFrame, char* error)
-{
-    word32  seqStart = (session->flags.side == WOLFSSL_SERVER_END) ? 
-                                     session->cliSeqStart :session->srvSeqStart;
-    word32  real     = tcpInfo->sequence - seqStart;
-    word32* expected = (session->flags.side == WOLFSSL_SERVER_END) ?
-                                  &session->cliExpected : &session->srvExpected;
-    PacketBuffer* reassemblyList = (session->flags.side == WOLFSSL_SERVER_END) ?
-                        session->cliReassemblyList : session->srvReassemblyList;
-    
-    /* handle rollover of sequence */
-    if (tcpInfo->sequence < seqStart)
-        real = 0xffffffffU - seqStart + tcpInfo->sequence;
-        
-    TraceRelativeSequence(*expected, real);
-    
-    if (real < *expected) {
-        Trace(DUPLICATE_STR);
-        if (real + *sslBytes > *expected) {
-            int overlap = *expected - real;
-            Trace(OVERLAP_DUPLICATE_STR);
-                
-            /* adjust to expected, remove duplicate */
-            *sslFrame += overlap;
-            *sslBytes -= overlap;
-                
-            if (reassemblyList) {
-                word32 newEnd = *expected + *sslBytes;
-                    
-                if (newEnd > reassemblyList->begin) {
-                    Trace(OVERLAP_REASSEMBLY_BEGIN_STR);
-                    
-                    /* remove bytes already on reassembly list */
-                    *sslBytes -= newEnd - reassemblyList->begin;
-                }
-                if (newEnd > reassemblyList->end) {
-                    Trace(OVERLAP_REASSEMBLY_END_STR);
-                    
-                    /* may be past reassembly list end (could have more on list)
-                       so try to add what's past the front->end */
-                    AddToReassembly(session->flags.side, reassemblyList->end +1,
-                                *sslFrame + reassemblyList->end - *expected + 1,
-                                 newEnd - reassemblyList->end, session, error);
-                }
-            }
-        }
-        else
-            return 1;
-    }
-    else if (real > *expected) {
-        Trace(OUT_OF_ORDER_STR);
-        if (*sslBytes > 0)
-            return AddToReassembly(session->flags.side, real, *sslFrame,
-                                   *sslBytes, session, error);
-        else if (tcpInfo->fin)
-            return AddFinCapture(session, real);
-    }
-    /* got expected sequence */
-    *expected += *sslBytes;
-    if (tcpInfo->fin)
-        *expected += 1;
-    
-    return 0;
-}
-
-
-/* Check latest ack number for missing packets
-   return 0 ok, <0 on error */
-static int CheckAck(TcpInfo* tcpInfo, SnifferSession* session)
-{
-    if (tcpInfo->ack) {
-        word32  seqStart = (session->flags.side == WOLFSSL_SERVER_END) ? 
-                                     session->srvSeqStart :session->cliSeqStart;
-        word32  real     = tcpInfo->ackNumber - seqStart;
-        word32  expected = (session->flags.side == WOLFSSL_SERVER_END) ?
-                                  session->srvExpected : session->cliExpected;
-    
-        /* handle rollover of sequence */
-        if (tcpInfo->ackNumber < seqStart)
-            real = 0xffffffffU - seqStart + tcpInfo->ackNumber;
-        
-        TraceAck(real, expected);
-
-        if (real > expected)
-            return -1;  /* we missed a packet, ACKing data we never saw */
-    }
-    return 0;
-}
-
-
-/* Check TCP Sequence status */
-/* returns 0 on success (continue), -1 on error, 1 on success (end) */
-static int CheckSequence(IpInfo* ipInfo, TcpInfo* tcpInfo,
-                         SnifferSession* session, int* sslBytes,
-                         const byte** sslFrame, char* error)
-{
-    int actualLen;
-    
-    /* init SEQ from server to client */
-    if (tcpInfo->syn && tcpInfo->ack) {
-        session->srvSeqStart = tcpInfo->sequence;
-        session->srvExpected = 1;
-        TraceServerSyn(tcpInfo->sequence);
-        return 1;
-    }
-    
-    /* adjust potential ethernet trailer */
-    actualLen = ipInfo->total - ipInfo->length - tcpInfo->length;
-    if (*sslBytes > actualLen) {
-        *sslBytes = actualLen;
-    }
-    
-    TraceSequence(tcpInfo->sequence, *sslBytes);
-    if (CheckAck(tcpInfo, session) < 0) {
-        SetError(ACK_MISSED_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-    
-    return AdjustSequence(tcpInfo, session, sslBytes, sslFrame, error);    
-}
-
-
-/* Check Status before record processing */
-/* returns 0 on success (continue), -1 on error, 1 on success (end) */
-static int CheckPreRecord(IpInfo* ipInfo, TcpInfo* tcpInfo,
-                          const byte** sslFrame, SnifferSession** session,
-                          int* sslBytes, const byte** end, char* error)
-{
-    word32 length;
-    SSL*  ssl = ((*session)->flags.side == WOLFSSL_SERVER_END) ?
-                                  (*session)->sslServer : (*session)->sslClient;
-    /* remove SnifferSession on 2nd FIN or RST */
-    if (tcpInfo->fin || tcpInfo->rst) {
-        /* flag FIN and RST */
-        if (tcpInfo->fin)
-            (*session)->flags.finCount += 1;
-        else if (tcpInfo->rst)
-            (*session)->flags.finCount += 2;
-        
-        if ((*session)->flags.finCount >= 2) {
-            RemoveSession(*session, ipInfo, tcpInfo, 0);
-            *session = NULL;
-            return 1;
-        }
-    }
-    
-    if ((*session)->flags.fatalError == FATAL_ERROR_STATE) {
-        SetError(FATAL_ERROR_STR, error, NULL, 0);
-        return -1;
-    }
-    
-    if (*sslBytes == 0) {
-        Trace(NO_DATA_STR);
-        return 1;
-    }
-    
-    /* if current partial data, add to end of partial */
-    if ( (length = ssl->buffers.inputBuffer.length) ) {
-        Trace(PARTIAL_ADD_STR);
-        
-        if ( (*sslBytes + length) > ssl->buffers.inputBuffer.bufferSize) {
-            if (GrowInputBuffer(ssl, *sslBytes, length) < 0) {
-                SetError(MEMORY_STR, error, *session, FATAL_ERROR_STATE);
-                return -1;
-            }
-        }
-        XMEMCPY(&ssl->buffers.inputBuffer.buffer[length], *sslFrame, *sslBytes);
-        *sslBytes += length;
-        ssl->buffers.inputBuffer.length = *sslBytes;
-        *sslFrame = ssl->buffers.inputBuffer.buffer;
-        *end = *sslFrame + *sslBytes;
-    }
-
-    if ((*session)->flags.clientHello == 0 && **sslFrame != handshake) {
-        /* Sanity check the packet for an old style client hello. */
-        int rhSize = (((*sslFrame)[0] & 0x7f) << 8) | ((*sslFrame)[1]);
-
-        if ((rhSize <= (*sslBytes - 2)) &&
-            (*sslFrame)[2] == OLD_HELLO_ID && (*sslFrame)[3] == SSLv3_MAJOR) {
-#ifdef OLD_HELLO_ALLOWED
-        int ret = DoOldHello(*session, *sslFrame, &rhSize, sslBytes, error);
-        if (ret < 0)
-            return -1;  /* error already set */
-        if (*sslBytes <= 0)
-            return 1;
-#endif
-        }
-        else {
-#ifdef STARTTLS_ALLOWED
-            return 1;
-#endif
-        }
-    }
-
-    return 0;
-}
-
-
-/* See if input on the reassembly list is ready for consuming */
-/* returns 1 for TRUE, 0 for FALSE */
-static int HaveMoreInput(SnifferSession* session, const byte** sslFrame,
-                         int* sslBytes, const byte** end, char* error)
-{
-    /* sequence and reassembly based on from, not to */
-    int            moreInput = 0;
-    PacketBuffer** front = (session->flags.side == WOLFSSL_SERVER_END) ?
-                      &session->cliReassemblyList : &session->srvReassemblyList;
-    word32*        expected = (session->flags.side == WOLFSSL_SERVER_END) ?
-                                  &session->cliExpected : &session->srvExpected;
-    /* buffer is on receiving end */
-    word32*        length = (session->flags.side == WOLFSSL_SERVER_END) ?
-                               &session->sslServer->buffers.inputBuffer.length :
-                               &session->sslClient->buffers.inputBuffer.length;
-    byte*          myBuffer = (session->flags.side == WOLFSSL_SERVER_END) ?
-                                session->sslServer->buffers.inputBuffer.buffer :
-                                session->sslClient->buffers.inputBuffer.buffer;
-    word32       bufferSize = (session->flags.side == WOLFSSL_SERVER_END) ?
-                            session->sslServer->buffers.inputBuffer.bufferSize :
-                            session->sslClient->buffers.inputBuffer.bufferSize;
-    SSL*               ssl  = (session->flags.side == WOLFSSL_SERVER_END) ?
-                            session->sslServer : session->sslClient;
-    
-    while (*front && ((*front)->begin == *expected) ) {
-        word32 room = bufferSize - *length;
-        word32 packetLen = (*front)->end - (*front)->begin + 1;
-
-        if (packetLen > room && bufferSize < MAX_INPUT_SZ) {
-            if (GrowInputBuffer(ssl, packetLen, *length) < 0) {
-                SetError(MEMORY_STR, error, session, FATAL_ERROR_STATE);
-                return 0;
-            }
-        }
-        
-        if (packetLen <= room) {
-            PacketBuffer* del = *front;
-            
-            XMEMCPY(&myBuffer[*length], (*front)->data, packetLen);
-            *length   += packetLen;
-            *expected += packetLen;
-            
-            /* remove used packet */
-            *front = (*front)->next;
-            FreePacketBuffer(del);
-            
-            moreInput = 1;
-        }
-        else
-            break;
-    }
-    if (moreInput) {
-        *sslFrame = myBuffer;
-        *sslBytes = *length;
-        *end      = myBuffer + *length;
-    }
-    return moreInput;
-}
-                         
-
-
-/* Process Message(s) from sslFrame */
-/* return Number of bytes on success, 0 for no data yet, and -1 on error */
-static int ProcessMessage(const byte* sslFrame, SnifferSession* session,
-                          int sslBytes, byte* data, const byte* end,char* error)
-{
-    const byte*       sslBegin = sslFrame;
-    const byte*       recordEnd;   /* end of record indicator */
-    const byte*       inRecordEnd; /* indictor from input stream not decrypt */
-    RecordLayerHeader rh;
-    int               rhSize = 0;
-    int               ret;
-    int               errCode = 0;
-    int               decoded = 0;      /* bytes stored for user in data */
-    int               notEnough;        /* notEnough bytes yet flag */
-    int               decrypted = 0;    /* was current msg decrypted */
-    SSL*              ssl = (session->flags.side == WOLFSSL_SERVER_END) ?
-                                        session->sslServer : session->sslClient;
-doMessage:
-    notEnough = 0;
-    if (sslBytes < 0) {
-        SetError(PACKET_HDR_SHORT_STR, error, session, FATAL_ERROR_STATE);
-        return -1;
-    }
-    if (sslBytes >= RECORD_HEADER_SZ) {
-        if (GetRecordHeader(sslFrame, &rh, &rhSize) != 0) {
-            SetError(BAD_RECORD_HDR_STR, error, session, FATAL_ERROR_STATE);
-            return -1;
-        }
-    }
-    else
-        notEnough = 1;
-
-    if (notEnough || rhSize > (sslBytes - RECORD_HEADER_SZ)) {
-        /* don't have enough input yet to process full SSL record */
-        Trace(PARTIAL_INPUT_STR);
-        
-        /* store partial if not there already or we advanced */
-        if (ssl->buffers.inputBuffer.length == 0 || sslBegin != sslFrame) {
-            if (sslBytes > (int)ssl->buffers.inputBuffer.bufferSize) {
-                if (GrowInputBuffer(ssl, sslBytes, 0) < 0) { 
-                    SetError(MEMORY_STR, error, session, FATAL_ERROR_STATE);
-                    return -1;
-                }
-            }
-            XMEMMOVE(ssl->buffers.inputBuffer.buffer, sslFrame, sslBytes);
-            ssl->buffers.inputBuffer.length = sslBytes;
-        }
-        if (HaveMoreInput(session, &sslFrame, &sslBytes, &end, error))
-            goto doMessage;
-        return decoded;
-    }
-    sslFrame += RECORD_HEADER_SZ;
-    sslBytes -= RECORD_HEADER_SZ;
-    recordEnd = sslFrame + rhSize;   /* may have more than one record */
-    inRecordEnd = recordEnd;
-    
-    /* decrypt if needed */
-    if ((session->flags.side == WOLFSSL_SERVER_END &&
-                                               session->flags.serverCipherOn)
-     || (session->flags.side == WOLFSSL_CLIENT_END &&
-                                               session->flags.clientCipherOn)) {
-        int ivAdvance = 0;  /* TLSv1.1 advance amount */
-        if (ssl->decrypt.setup != 1) {
-            SetError(DECRYPT_KEYS_NOT_SETUP, error, session, FATAL_ERROR_STATE);
-            return -1;
-        }
-        if (CheckAvailableSize(ssl, rhSize) < 0) {
-            SetError(MEMORY_STR, error, session, FATAL_ERROR_STATE);
-            return -1;
-        }
-        sslFrame = DecryptMessage(ssl, sslFrame, rhSize,
-                                  ssl->buffers.outputBuffer.buffer, &errCode,
-                                  &ivAdvance);
-        recordEnd = sslFrame - ivAdvance + rhSize;  /* sslFrame moved so
-                                                       should recordEnd */
-        decrypted = 1;
-        if (errCode != 0) {
-            SetError(BAD_DECRYPT, error, session, FATAL_ERROR_STATE);
-            return -1;
-        }
-    }
-
-doPart:
-            
-    switch ((enum ContentType)rh.type) {
-        case handshake:
-            {
-                int startIdx = sslBytes;
-                int used;
-
-                Trace(GOT_HANDSHAKE_STR);
-                ret = DoHandShake(sslFrame, &sslBytes, session, error);
-                if (ret != 0) {
-                    if (session->flags.fatalError == 0)
-                        SetError(BAD_HANDSHAKE_STR, error, session,
-                                 FATAL_ERROR_STATE);
-                    return -1;
-                }
-
-                /* DoHandShake now fully decrements sslBytes to remaining */
-                used = startIdx - sslBytes;
-                sslFrame += used;
-                if (decrypted)
-                    sslFrame += ssl->keys.padSz;
-            }
-            break;
-        case change_cipher_spec:
-            if (session->flags.side == WOLFSSL_SERVER_END)
-                session->flags.serverCipherOn = 1;
-            else
-                session->flags.clientCipherOn = 1;
-            Trace(GOT_CHANGE_CIPHER_STR);
-            ssl->options.handShakeState = HANDSHAKE_DONE;
-            ssl->options.handShakeDone  = 1;
-
-            sslFrame += 1;
-            sslBytes -= 1;
-
-            break;
-        case application_data:
-            Trace(GOT_APP_DATA_STR);
-            {
-                word32 inOutIdx = 0;
-                    
-                ret = DoApplicationData(ssl, (byte*)sslFrame, &inOutIdx);
-                if (ret == 0) {
-                    ret = ssl->buffers.clearOutputBuffer.length;
-                    TraceGotData(ret);
-                    if (ret) {  /* may be blank message */
-                        XMEMCPY(&data[decoded],
-                               ssl->buffers.clearOutputBuffer.buffer, ret);
-                        TraceAddedData(ret, decoded);
-                        decoded += ret;
-                        ssl->buffers.clearOutputBuffer.length = 0;
-                    }
-                }
-                else {
-                    SetError(BAD_APP_DATA_STR, error,session,FATAL_ERROR_STATE);
-                    return -1;
-                }
-                if (ssl->buffers.outputBuffer.dynamicFlag)
-                    ShrinkOutputBuffer(ssl);
-
-                sslFrame += inOutIdx;
-                sslBytes -= inOutIdx;
-            }
-            break;
-        case alert:
-            Trace(GOT_ALERT_STR);
-            sslFrame += rhSize;
-            sslBytes -= rhSize;
-            break;
-        case no_type:
-        default:
-            SetError(GOT_UNKNOWN_RECORD_STR, error, session, FATAL_ERROR_STATE);
-            return -1;
-    }
-
-    /* do we have another msg in record ? */
-    if (sslFrame < recordEnd) {
-        Trace(ANOTHER_MSG_STR);
-        goto doPart;
-    }
-
-    /* back to input stream instead of potential decrypt buffer */
-    recordEnd = inRecordEnd;
-
-    /* do we have more records ? */
-    if (recordEnd < end) {
-        Trace(ANOTHER_MSG_STR);
-        sslFrame = recordEnd;
-        sslBytes = (int)(end - recordEnd);
-        goto doMessage;
-    }
-    
-    /* clear used input */
-    ssl->buffers.inputBuffer.length = 0;
-    
-    /* could have more input ready now */
-    if (HaveMoreInput(session, &sslFrame, &sslBytes, &end, error))
-        goto doMessage;
-
-    if (ssl->buffers.inputBuffer.dynamicFlag)
-        ShrinkInputBuffer(ssl, NO_FORCED_FREE);
-    
-    return decoded;
-}
-
-
-/* See if we need to process any pending FIN captures */
-static void CheckFinCapture(IpInfo* ipInfo, TcpInfo* tcpInfo, 
-                            SnifferSession* session)
-{
-    if (session->finCaputre.cliFinSeq && session->finCaputre.cliFinSeq <= 
-                                         session->cliExpected) {
-        if (session->finCaputre.cliCounted == 0) {
-            session->flags.finCount += 1;
-            session->finCaputre.cliCounted = 1;
-            TraceClientFin(session->finCaputre.cliFinSeq, session->cliExpected);
-        }
-    }
-        
-    if (session->finCaputre.srvFinSeq && session->finCaputre.srvFinSeq <= 
-                                         session->srvExpected) {
-        if (session->finCaputre.srvCounted == 0) {
-            session->flags.finCount += 1;
-            session->finCaputre.srvCounted = 1;
-            TraceServerFin(session->finCaputre.srvFinSeq, session->srvExpected);
-        }
-    }
-                
-    if (session->flags.finCount >= 2) 
-        RemoveSession(session, ipInfo, tcpInfo, 0);
-}
-
-
-/* If session is in fatal error state free resources now 
-   return true if removed, 0 otherwise */
-static int RemoveFatalSession(IpInfo* ipInfo, TcpInfo* tcpInfo,
-                              SnifferSession* session, char* error)
-{
-    if (session && session->flags.fatalError == FATAL_ERROR_STATE) {
-        RemoveSession(session, ipInfo, tcpInfo, 0);
-        SetError(FATAL_ERROR_STR, error, NULL, 0);
-        return 1;
-    }
-    return 0;
-}
-
-
-/* Passes in an IP/TCP packet for decoding (ethernet/localhost frame) removed */
-/* returns Number of bytes on success, 0 for no data yet, and -1 on error */
-int ssl_DecodePacket(const byte* packet, int length, byte* data, char* error)
-{
-    TcpInfo           tcpInfo;
-    IpInfo            ipInfo;
-    const byte*       sslFrame;
-    const byte*       end = packet + length;
-    int               sslBytes;                /* ssl bytes unconsumed */
-    int               ret;
-    SnifferSession*   session = 0;
-
-    if (CheckHeaders(&ipInfo, &tcpInfo, packet, length, &sslFrame, &sslBytes,
-                     error) != 0)
-        return -1;
-    
-    ret = CheckSession(&ipInfo, &tcpInfo, sslBytes, &session, error);
-    if (RemoveFatalSession(&ipInfo, &tcpInfo, session, error)) return -1;
-    else if (ret == -1) return -1;
-    else if (ret ==  1) return  0;   /* done for now */
-    
-    ret = CheckSequence(&ipInfo, &tcpInfo, session, &sslBytes, &sslFrame,error);
-    if (RemoveFatalSession(&ipInfo, &tcpInfo, session, error)) return -1;
-    else if (ret == -1) return -1;
-    else if (ret ==  1) return  0;   /* done for now */
-    
-    ret = CheckPreRecord(&ipInfo, &tcpInfo, &sslFrame, &session, &sslBytes,
-                         &end, error);
-    if (RemoveFatalSession(&ipInfo, &tcpInfo, session, error)) return -1;
-    else if (ret == -1) return -1;
-    else if (ret ==  1) return  0;   /* done for now */
-
-    ret = ProcessMessage(sslFrame, session, sslBytes, data, end, error);
-    if (RemoveFatalSession(&ipInfo, &tcpInfo, session, error)) return -1;
-    CheckFinCapture(&ipInfo, &tcpInfo, session);
-    return ret;
-}
-
-
-/* Enables (if traceFile)/ Disables debug tracing */
-/* returns 0 on success, -1 on error */
-int ssl_Trace(const char* traceFile, char* error)
-{
-    if (traceFile) {
-        TraceFile = fopen(traceFile, "a");
-        if (!TraceFile) {
-            SetError(BAD_TRACE_FILE_STR, error, NULL, 0);
-            return -1;
-        }
-        TraceOn = 1;
-    }
-    else 
-        TraceOn = 0;
-
-    return 0;
-}
-
-
-
-
-#endif /* WOLFSSL_SNIFFER */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/src/ssl.c b/FreeRTOS-Plus/Source/WolfSSL/src/ssl.c
deleted file mode 100755
index 139e343..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/src/ssl.c
+++ /dev/null
@@ -1,12937 +0,0 @@
-/* ssl.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef HAVE_ERRNO_H
-    #include 
-#endif
-
-#include 
-#include 
-#include 
-
-#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
-    #include 
-#endif
-
-#ifdef OPENSSL_EXTRA
-    /* openssl headers begin */
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    /* openssl headers end, wolfssl internal headers next */
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #ifdef WOLFSSL_SHA512
-        #include 
-    #endif
-#endif
-
-#ifndef NO_FILESYSTEM
-    #if !defined(USE_WINDOWS_API) && !defined(NO_WOLFSSL_DIR) \
-            && !defined(EBSNET)
-        #include 
-        #include 
-    #endif
-    #ifdef EBSNET
-        #include "vfapi.h"
-        #include "vfile.h"
-    #endif
-#endif /* NO_FILESYSTEM */
-
-#ifndef TRUE
-    #define TRUE  1
-#endif
-#ifndef FALSE
-    #define FALSE 0
-#endif
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSSL_HAVE_MIN */
-
-#ifndef WOLFSSL_HAVE_MAX
-#define WOLFSSL_HAVE_MAX
-
-#ifdef WOLFSSL_DTLS
-    static INLINE word32 max(word32 a, word32 b)
-    {
-        return a > b ? a : b;
-    }
-#endif /* WOLFSSL_DTLS */
-
-#endif /* WOLFSSL_HAVE_MAX */
-
-
-#ifndef WOLFSSL_LEANPSK
-char* mystrnstr(const char* s1, const char* s2, unsigned int n)
-{
-    unsigned int s2_len = (unsigned int)XSTRLEN(s2);
-
-    if (s2_len == 0)
-        return (char*)s1;
-
-    while (n >= s2_len && s1[0]) {
-        if (s1[0] == s2[0])
-            if (XMEMCMP(s1, s2, s2_len) == 0)
-                return (char*)s1;
-        s1++;
-        n--;
-    }
-
-    return NULL;
-}
-#endif
-
-
-/* prevent multiple mutex initializations */
-static volatile int initRefCount = 0;
-static wolfSSL_Mutex count_mutex;   /* init ref count mutex */
-
-
-WOLFSSL_CTX* wolfSSL_CTX_new(WOLFSSL_METHOD* method)
-{
-    WOLFSSL_CTX* ctx = NULL;
-
-    WOLFSSL_ENTER("WOLFSSL_CTX_new");
-
-    if (initRefCount == 0)
-        wolfSSL_Init(); /* user no longer forced to call Init themselves */
-
-    if (method == NULL)
-        return ctx;
-
-    ctx = (WOLFSSL_CTX*) XMALLOC(sizeof(WOLFSSL_CTX), 0, DYNAMIC_TYPE_CTX);
-    if (ctx) {
-        if (InitSSL_Ctx(ctx, method) < 0) {
-            WOLFSSL_MSG("Init CTX failed");
-            wolfSSL_CTX_free(ctx);
-            ctx = NULL;
-        }
-    }
-    else {
-        WOLFSSL_MSG("Alloc CTX failed, method freed");
-        XFREE(method, NULL, DYNAMIC_TYPE_METHOD);
-    }
-
-    WOLFSSL_LEAVE("WOLFSSL_CTX_new", 0);
-    return ctx;
-}
-
-
-void wolfSSL_CTX_free(WOLFSSL_CTX* ctx)
-{
-    WOLFSSL_ENTER("SSL_CTX_free");
-    if (ctx)
-        FreeSSL_Ctx(ctx);
-    WOLFSSL_LEAVE("SSL_CTX_free", 0);
-}
-
-
-WOLFSSL* wolfSSL_new(WOLFSSL_CTX* ctx)
-{
-    WOLFSSL* ssl = NULL;
-    int ret = 0;
-
-    (void)ret;
-    WOLFSSL_ENTER("SSL_new");
-
-    if (ctx == NULL)
-        return ssl;
-
-    ssl = (WOLFSSL*) XMALLOC(sizeof(WOLFSSL), ctx->heap,DYNAMIC_TYPE_SSL);
-    if (ssl)
-        if ( (ret = InitSSL(ssl, ctx)) < 0) {
-            FreeSSL(ssl);
-            ssl = 0;
-        }
-
-    WOLFSSL_LEAVE("SSL_new", ret);
-    return ssl;
-}
-
-
-void wolfSSL_free(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("SSL_free");
-    if (ssl)
-        FreeSSL(ssl);
-    WOLFSSL_LEAVE("SSL_free", 0);
-}
-
-#ifdef HAVE_POLY1305
-/* set if to use old poly 1 for yes 0 to use new poly */
-int wolfSSL_use_old_poly(WOLFSSL* ssl, int value)
-{
-    WOLFSSL_ENTER("SSL_use_old_poly");
-    ssl->options.oldPoly = value;
-    WOLFSSL_LEAVE("SSL_use_old_poly", 0);
-    return 0;
-}
-#endif
-
-int wolfSSL_set_fd(WOLFSSL* ssl, int fd)
-{
-    WOLFSSL_ENTER("SSL_set_fd");
-    ssl->rfd = fd;      /* not used directly to allow IO callbacks */
-    ssl->wfd = fd;
-
-    ssl->IOCB_ReadCtx  = &ssl->rfd;
-    ssl->IOCB_WriteCtx = &ssl->wfd;
-
-    #ifdef WOLFSSL_DTLS
-        if (ssl->options.dtls) {
-            ssl->IOCB_ReadCtx = &ssl->buffers.dtlsCtx;
-            ssl->IOCB_WriteCtx = &ssl->buffers.dtlsCtx;
-            ssl->buffers.dtlsCtx.fd = fd;
-        }
-    #endif
-
-    WOLFSSL_LEAVE("SSL_set_fd", SSL_SUCCESS);
-    return SSL_SUCCESS;
-}
-
-
-/**
-  * Get the name of cipher at priotity level passed in.
-  */
-char* wolfSSL_get_cipher_list(int priority)
-{
-    const char* const* ciphers = GetCipherNames();
-
-    if (priority >= GetCipherNamesSize() || priority < 0) {
-        return 0;
-    }
-
-    return (char*)ciphers[priority];
-}
-
-
-int wolfSSL_get_ciphers(char* buf, int len)
-{
-    const char* const* ciphers = GetCipherNames();
-    int  totalInc = 0;
-    int  step     = 0;
-    char delim    = ':';
-    int  size     = GetCipherNamesSize();
-    int  i;
-
-    if (buf == NULL || len <= 0)
-        return BAD_FUNC_ARG;
-
-    /* Add each member to the buffer delimitted by a : */
-    for (i = 0; i < size; i++) {
-        step = (int)(XSTRLEN(ciphers[i]) + 1);  /* delimiter */
-        totalInc += step;
-
-        /* Check to make sure buf is large enough and will not overflow */
-        if (totalInc < len) {
-            XSTRNCPY(buf, ciphers[i], XSTRLEN(ciphers[i]));
-            buf += XSTRLEN(ciphers[i]);
-
-            if (i < size - 1)
-                *buf++ = delim;
-        }
-        else
-            return BUFFER_E;
-    }
-    return SSL_SUCCESS;
-}
-
-
-int wolfSSL_get_fd(const WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("SSL_get_fd");
-    WOLFSSL_LEAVE("SSL_get_fd", ssl->rfd);
-    return ssl->rfd;
-}
-
-
-int wolfSSL_get_using_nonblock(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("wolfSSL_get_using_nonblock");
-    WOLFSSL_LEAVE("wolfSSL_get_using_nonblock", ssl->options.usingNonblock);
-    return ssl->options.usingNonblock;
-}
-
-
-int wolfSSL_dtls(WOLFSSL* ssl)
-{
-    return ssl->options.dtls;
-}
-
-
-#ifndef WOLFSSL_LEANPSK
-void wolfSSL_set_using_nonblock(WOLFSSL* ssl, int nonblock)
-{
-    WOLFSSL_ENTER("wolfSSL_set_using_nonblock");
-    ssl->options.usingNonblock = (nonblock != 0);
-}
-
-
-int wolfSSL_dtls_set_peer(WOLFSSL* ssl, void* peer, unsigned int peerSz)
-{
-#ifdef WOLFSSL_DTLS
-    void* sa = (void*)XMALLOC(peerSz, ssl->heap, DYNAMIC_TYPE_SOCKADDR);
-    if (sa != NULL) {
-        if (ssl->buffers.dtlsCtx.peer.sa != NULL)
-            XFREE(ssl->buffers.dtlsCtx.peer.sa,ssl->heap,DYNAMIC_TYPE_SOCKADDR);
-        XMEMCPY(sa, peer, peerSz);
-        ssl->buffers.dtlsCtx.peer.sa = sa;
-        ssl->buffers.dtlsCtx.peer.sz = peerSz;
-        return SSL_SUCCESS;
-    }
-    return SSL_FAILURE;
-#else
-    (void)ssl;
-    (void)peer;
-    (void)peerSz;
-    return SSL_NOT_IMPLEMENTED;
-#endif
-}
-
-int wolfSSL_dtls_get_peer(WOLFSSL* ssl, void* peer, unsigned int* peerSz)
-{
-#ifdef WOLFSSL_DTLS
-    if (peer != NULL && peerSz != NULL
-            && *peerSz >= ssl->buffers.dtlsCtx.peer.sz) {
-        *peerSz = ssl->buffers.dtlsCtx.peer.sz;
-        XMEMCPY(peer, ssl->buffers.dtlsCtx.peer.sa, *peerSz);
-        return SSL_SUCCESS;
-    }
-    return SSL_FAILURE;
-#else
-    (void)ssl;
-    (void)peer;
-    (void)peerSz;
-    return SSL_NOT_IMPLEMENTED;
-#endif
-}
-#endif /* WOLFSSL_LEANPSK */
-
-
-/* return underlyig connect or accept, SSL_SUCCESS on ok */
-int wolfSSL_negotiate(WOLFSSL* ssl)
-{
-    int err = SSL_FATAL_ERROR;
-
-    WOLFSSL_ENTER("wolfSSL_negotiate");
-#ifndef NO_WOLFSSL_SERVER
-    if (ssl->options.side == WOLFSSL_SERVER_END)
-        err = wolfSSL_accept(ssl);
-#endif
-
-#ifndef NO_WOLFSSL_CLIENT
-    if (ssl->options.side == WOLFSSL_CLIENT_END)
-        err = wolfSSL_connect(ssl);
-#endif
-
-    WOLFSSL_LEAVE("wolfSSL_negotiate", err);
-
-    return err;
-}
-
-
-#ifndef WOLFSSL_LEANPSK
-/* object size based on build */
-int wolfSSL_GetObjectSize(void)
-{
-#ifdef SHOW_SIZES
-    printf("sizeof suites           = %lu\n", sizeof(Suites));
-    printf("sizeof ciphers(2)       = %lu\n", sizeof(Ciphers));
-#ifndef NO_RC4
-    printf("    sizeof arc4         = %lu\n", sizeof(Arc4));
-#endif
-    printf("    sizeof aes          = %lu\n", sizeof(Aes));
-#ifndef NO_DES3
-    printf("    sizeof des3         = %lu\n", sizeof(Des3));
-#endif
-#ifndef NO_RABBIT
-    printf("    sizeof rabbit       = %lu\n", sizeof(Rabbit));
-#endif
-#ifdef HAVE_CHACHA
-    printf("    sizeof chacha       = %lu\n", sizeof(Chacha));
-#endif
-    printf("sizeof cipher specs     = %lu\n", sizeof(CipherSpecs));
-    printf("sizeof keys             = %lu\n", sizeof(Keys));
-    printf("sizeof Hashes(2)        = %lu\n", sizeof(Hashes));
-#ifndef NO_MD5
-    printf("    sizeof MD5          = %lu\n", sizeof(Md5));
-#endif
-#ifndef NO_SHA
-    printf("    sizeof SHA          = %lu\n", sizeof(Sha));
-#endif
-#ifndef NO_SHA256
-    printf("    sizeof SHA256       = %lu\n", sizeof(Sha256));
-#endif
-#ifdef WOLFSSL_SHA384
-    printf("    sizeof SHA384       = %lu\n", sizeof(Sha384));
-#endif
-#ifdef WOLFSSL_SHA384
-    printf("    sizeof SHA512       = %lu\n", sizeof(Sha512));
-#endif
-    printf("sizeof Buffers          = %lu\n", sizeof(Buffers));
-    printf("sizeof Options          = %lu\n", sizeof(Options));
-    printf("sizeof Arrays           = %lu\n", sizeof(Arrays));
-#ifndef NO_RSA
-    printf("sizeof RsaKey           = %lu\n", sizeof(RsaKey));
-#endif
-#ifdef HAVE_ECC
-    printf("sizeof ecc_key          = %lu\n", sizeof(ecc_key));
-#endif
-    printf("sizeof WOLFSSL_CIPHER    = %lu\n", sizeof(WOLFSSL_CIPHER));
-    printf("sizeof WOLFSSL_SESSION   = %lu\n", sizeof(WOLFSSL_SESSION));
-    printf("sizeof WOLFSSL           = %lu\n", sizeof(WOLFSSL));
-    printf("sizeof WOLFSSL_CTX       = %lu\n", sizeof(WOLFSSL_CTX));
-#endif
-
-    return sizeof(WOLFSSL);
-}
-#endif
-
-
-#ifndef NO_DH
-/* server Diffie-Hellman parameters, SSL_SUCCESS on ok */
-int wolfSSL_SetTmpDH(WOLFSSL* ssl, const unsigned char* p, int pSz,
-                    const unsigned char* g, int gSz)
-{
-    byte havePSK = 0;
-    byte haveRSA = 1;
-
-    WOLFSSL_ENTER("wolfSSL_SetTmpDH");
-    if (ssl == NULL || p == NULL || g == NULL) return BAD_FUNC_ARG;
-
-    if (pSz < ssl->options.minDhKeySz)
-        return DH_KEY_SIZE_E;
-
-    if (ssl->options.side != WOLFSSL_SERVER_END)
-        return SIDE_ERROR;
-
-    if (ssl->buffers.serverDH_P.buffer && ssl->buffers.weOwnDH)
-        XFREE(ssl->buffers.serverDH_P.buffer, ssl->ctx->heap, DYNAMIC_TYPE_DH);
-    if (ssl->buffers.serverDH_G.buffer && ssl->buffers.weOwnDH)
-        XFREE(ssl->buffers.serverDH_G.buffer, ssl->ctx->heap, DYNAMIC_TYPE_DH);
-
-    ssl->buffers.weOwnDH = 1;  /* SSL owns now */
-    ssl->buffers.serverDH_P.buffer = (byte*)XMALLOC(pSz, ssl->ctx->heap,
-                                                    DYNAMIC_TYPE_DH);
-    if (ssl->buffers.serverDH_P.buffer == NULL)
-        return MEMORY_E;
-
-    ssl->buffers.serverDH_G.buffer = (byte*)XMALLOC(gSz, ssl->ctx->heap,
-                                                    DYNAMIC_TYPE_DH);
-    if (ssl->buffers.serverDH_G.buffer == NULL) {
-        XFREE(ssl->buffers.serverDH_P.buffer, ssl->ctx->heap, DYNAMIC_TYPE_DH);
-        return MEMORY_E;
-    }
-
-    ssl->buffers.serverDH_P.length = pSz;
-    ssl->buffers.serverDH_G.length = gSz;
-
-    XMEMCPY(ssl->buffers.serverDH_P.buffer, p, pSz);
-    XMEMCPY(ssl->buffers.serverDH_G.buffer, g, gSz);
-
-    ssl->options.haveDH = 1;
-    #ifndef NO_PSK
-        havePSK = ssl->options.havePSK;
-    #endif
-    #ifdef NO_RSA
-        haveRSA = 0;
-    #endif
-    InitSuites(ssl->suites, ssl->version, haveRSA, havePSK, ssl->options.haveDH,
-               ssl->options.haveNTRU, ssl->options.haveECDSAsig,
-               ssl->options.haveStaticECC, ssl->options.side);
-
-    WOLFSSL_LEAVE("wolfSSL_SetTmpDH", 0);
-    return SSL_SUCCESS;
-}
-
-/* server ctx Diffie-Hellman parameters, SSL_SUCCESS on ok */
-int wolfSSL_CTX_SetTmpDH(WOLFSSL_CTX* ctx, const unsigned char* p, int pSz,
-                         const unsigned char* g, int gSz)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_SetTmpDH");
-    if (ctx == NULL || p == NULL || g == NULL) return BAD_FUNC_ARG;
-
-    if (pSz < ctx->minDhKeySz)
-        return DH_KEY_SIZE_E;
-
-    XFREE(ctx->serverDH_P.buffer, ctx->heap, DYNAMIC_TYPE_DH);
-    XFREE(ctx->serverDH_G.buffer, ctx->heap, DYNAMIC_TYPE_DH);
-
-    ctx->serverDH_P.buffer = (byte*)XMALLOC(pSz, ctx->heap,DYNAMIC_TYPE_DH);
-    if (ctx->serverDH_P.buffer == NULL)
-       return MEMORY_E;
-
-    ctx->serverDH_G.buffer = (byte*)XMALLOC(gSz, ctx->heap,DYNAMIC_TYPE_DH);
-    if (ctx->serverDH_G.buffer == NULL) {
-        XFREE(ctx->serverDH_P.buffer, ctx->heap, DYNAMIC_TYPE_DH);
-        return MEMORY_E;
-    }
-
-    ctx->serverDH_P.length = pSz;
-    ctx->serverDH_G.length = gSz;
-
-    XMEMCPY(ctx->serverDH_P.buffer, p, pSz);
-    XMEMCPY(ctx->serverDH_G.buffer, g, gSz);
-
-    ctx->haveDH = 1;
-
-    WOLFSSL_LEAVE("wolfSSL_CTX_SetTmpDH", 0);
-    return SSL_SUCCESS;
-}
-
-#endif /* !NO_DH */
-
-
-int wolfSSL_write(WOLFSSL* ssl, const void* data, int sz)
-{
-    int ret;
-
-    WOLFSSL_ENTER("SSL_write()");
-
-    if (ssl == NULL || data == NULL || sz < 0)
-        return BAD_FUNC_ARG;
-
-#ifdef HAVE_ERRNO_H
-    errno = 0;
-#endif
-
-    ret = SendData(ssl, data, sz);
-
-    WOLFSSL_LEAVE("SSL_write()", ret);
-
-    if (ret < 0)
-        return SSL_FATAL_ERROR;
-    else
-        return ret;
-}
-
-
-static int wolfSSL_read_internal(WOLFSSL* ssl, void* data, int sz, int peek)
-{
-    int ret;
-
-    WOLFSSL_ENTER("wolfSSL_read_internal()");
-
-    if (ssl == NULL || data == NULL || sz < 0)
-        return BAD_FUNC_ARG;
-
-#ifdef HAVE_ERRNO_H
-        errno = 0;
-#endif
-#ifdef WOLFSSL_DTLS
-    if (ssl->options.dtls)
-        ssl->dtls_expected_rx = max(sz + 100, MAX_MTU);
-#endif
-
-#ifdef HAVE_MAX_FRAGMENT
-    ret = ReceiveData(ssl, (byte*)data,
-                     min(sz, min(ssl->max_fragment, OUTPUT_RECORD_SIZE)), peek);
-#else
-    ret = ReceiveData(ssl, (byte*)data, min(sz, OUTPUT_RECORD_SIZE), peek);
-#endif
-
-    WOLFSSL_LEAVE("wolfSSL_read_internal()", ret);
-
-    if (ret < 0)
-        return SSL_FATAL_ERROR;
-    else
-        return ret;
-}
-
-
-int wolfSSL_peek(WOLFSSL* ssl, void* data, int sz)
-{
-    WOLFSSL_ENTER("wolfSSL_peek()");
-
-    return wolfSSL_read_internal(ssl, data, sz, TRUE);
-}
-
-
-int wolfSSL_read(WOLFSSL* ssl, void* data, int sz)
-{
-    WOLFSSL_ENTER("wolfSSL_read()");
-
-    return wolfSSL_read_internal(ssl, data, sz, FALSE);
-}
-
-
-#ifdef HAVE_CAVIUM
-
-/* let's use cavium, SSL_SUCCESS on ok */
-int wolfSSL_UseCavium(WOLFSSL* ssl, int devId)
-{
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    ssl->devId = devId;
-
-    return SSL_SUCCESS;
-}
-
-
-/* let's use cavium, SSL_SUCCESS on ok */
-int wolfSSL_CTX_UseCavium(WOLFSSL_CTX* ctx, int devId)
-{
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-    ctx->devId = devId;
-
-    return SSL_SUCCESS;
-}
-
-
-#endif /* HAVE_CAVIUM */
-
-#ifdef HAVE_SNI
-
-int wolfSSL_UseSNI(WOLFSSL* ssl, byte type, const void* data, word16 size)
-{
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    return TLSX_UseSNI(&ssl->extensions, type, data, size);
-}
-
-int wolfSSL_CTX_UseSNI(WOLFSSL_CTX* ctx, byte type, const void* data, word16 size)
-{
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-    return TLSX_UseSNI(&ctx->extensions, type, data, size);
-}
-
-#ifndef NO_WOLFSSL_SERVER
-
-void wolfSSL_SNI_SetOptions(WOLFSSL* ssl, byte type, byte options)
-{
-    if (ssl && ssl->extensions)
-        TLSX_SNI_SetOptions(ssl->extensions, type, options);
-}
-
-void wolfSSL_CTX_SNI_SetOptions(WOLFSSL_CTX* ctx, byte type, byte options)
-{
-    if (ctx && ctx->extensions)
-        TLSX_SNI_SetOptions(ctx->extensions, type, options);
-}
-
-byte wolfSSL_SNI_Status(WOLFSSL* ssl, byte type)
-{
-    return TLSX_SNI_Status(ssl ? ssl->extensions : NULL, type);
-}
-
-word16 wolfSSL_SNI_GetRequest(WOLFSSL* ssl, byte type, void** data)
-{
-    if (data)
-        *data = NULL;
-
-    if (ssl && ssl->extensions)
-        return TLSX_SNI_GetRequest(ssl->extensions, type, data);
-
-    return 0;
-}
-
-int wolfSSL_SNI_GetFromBuffer(const byte* clientHello, word32 helloSz, byte type,
-                                                     byte* sni, word32* inOutSz)
-{
-    if (clientHello && helloSz > 0 && sni && inOutSz && *inOutSz > 0)
-        return TLSX_SNI_GetFromBuffer(clientHello, helloSz, type, sni, inOutSz);
-
-    return BAD_FUNC_ARG;
-}
-
-#endif /* NO_WOLFSSL_SERVER */
-
-#endif /* HAVE_SNI */
-
-
-#ifdef HAVE_MAX_FRAGMENT
-#ifndef NO_WOLFSSL_CLIENT
-int wolfSSL_UseMaxFragment(WOLFSSL* ssl, byte mfl)
-{
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    return TLSX_UseMaxFragment(&ssl->extensions, mfl);
-}
-
-int wolfSSL_CTX_UseMaxFragment(WOLFSSL_CTX* ctx, byte mfl)
-{
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-    return TLSX_UseMaxFragment(&ctx->extensions, mfl);
-}
-#endif /* NO_WOLFSSL_CLIENT */
-#endif /* HAVE_MAX_FRAGMENT */
-
-#ifdef HAVE_TRUNCATED_HMAC
-#ifndef NO_WOLFSSL_CLIENT
-int wolfSSL_UseTruncatedHMAC(WOLFSSL* ssl)
-{
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    return TLSX_UseTruncatedHMAC(&ssl->extensions);
-}
-
-int wolfSSL_CTX_UseTruncatedHMAC(WOLFSSL_CTX* ctx)
-{
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-    return TLSX_UseTruncatedHMAC(&ctx->extensions);
-}
-#endif /* NO_WOLFSSL_CLIENT */
-#endif /* HAVE_TRUNCATED_HMAC */
-
-/* Elliptic Curves */
-#ifdef HAVE_SUPPORTED_CURVES
-#ifndef NO_WOLFSSL_CLIENT
-
-int wolfSSL_UseSupportedCurve(WOLFSSL* ssl, word16 name)
-{
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    switch (name) {
-        case WOLFSSL_ECC_SECP160R1:
-        case WOLFSSL_ECC_SECP192R1:
-        case WOLFSSL_ECC_SECP224R1:
-        case WOLFSSL_ECC_SECP256R1:
-        case WOLFSSL_ECC_SECP384R1:
-        case WOLFSSL_ECC_SECP521R1:
-            break;
-
-        default:
-            return BAD_FUNC_ARG;
-    }
-
-    return TLSX_UseSupportedCurve(&ssl->extensions, name);
-}
-
-int wolfSSL_CTX_UseSupportedCurve(WOLFSSL_CTX* ctx, word16 name)
-{
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-    switch (name) {
-        case WOLFSSL_ECC_SECP160R1:
-        case WOLFSSL_ECC_SECP192R1:
-        case WOLFSSL_ECC_SECP224R1:
-        case WOLFSSL_ECC_SECP256R1:
-        case WOLFSSL_ECC_SECP384R1:
-        case WOLFSSL_ECC_SECP521R1:
-            break;
-
-        default:
-            return BAD_FUNC_ARG;
-    }
-
-    return TLSX_UseSupportedCurve(&ctx->extensions, name);
-}
-
-#endif /* NO_WOLFSSL_CLIENT */
-#endif /* HAVE_SUPPORTED_CURVES */
-
-/* Secure Renegotiation */
-#ifdef HAVE_SECURE_RENEGOTIATION
-
-/* user is forcing ability to use secure renegotiation, we discourage it */
-int wolfSSL_UseSecureRenegotiation(WOLFSSL* ssl)
-{
-    int ret = BAD_FUNC_ARG;
-
-    if (ssl)
-        ret = TLSX_UseSecureRenegotiation(&ssl->extensions);
-
-    if (ret == SSL_SUCCESS) {
-        TLSX* extension = TLSX_Find(ssl->extensions, SECURE_RENEGOTIATION);
-        
-        if (extension)
-            ssl->secure_renegotiation = (SecureRenegotiation*)extension->data;
-    }
-
-    return ret;
-}
-
-
-/* do a secure renegotiation handshake, user forced, we discourage */
-int wolfSSL_Rehandshake(WOLFSSL* ssl)
-{
-    int ret;
-
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    if (ssl->secure_renegotiation == NULL) {
-        WOLFSSL_MSG("Secure Renegotiation not forced on by user");
-        return SECURE_RENEGOTIATION_E;
-    }
-
-    if (ssl->secure_renegotiation->enabled == 0) {
-        WOLFSSL_MSG("Secure Renegotiation not enabled at extension level");
-        return SECURE_RENEGOTIATION_E;
-    }
-
-    if (ssl->options.handShakeState != HANDSHAKE_DONE) {
-        WOLFSSL_MSG("Can't renegotiate until previous handshake complete");
-        return SECURE_RENEGOTIATION_E;
-    }
-
-#ifndef NO_FORCE_SCR_SAME_SUITE
-    /* force same suite */
-    if (ssl->suites) {
-        ssl->suites->suiteSz = SUITE_LEN;
-        ssl->suites->suites[0] = ssl->options.cipherSuite0;
-        ssl->suites->suites[1] = ssl->options.cipherSuite;
-    }
-#endif
-
-    /* reset handshake states */
-    ssl->options.serverState = NULL_STATE;
-    ssl->options.clientState = NULL_STATE;
-    ssl->options.connectState  = CONNECT_BEGIN;
-    ssl->options.acceptState   = ACCEPT_BEGIN;
-    ssl->options.handShakeState = NULL_STATE;
-    ssl->options.processReply  = 0;  /* TODO, move states in internal.h */
-
-    XMEMSET(&ssl->msgsReceived, 0, sizeof(ssl->msgsReceived));
-
-    ssl->secure_renegotiation->cache_status = SCR_CACHE_NEEDED;
-
-#ifndef NO_OLD_TLS
-#ifndef NO_MD5
-    wc_InitMd5(&ssl->hsHashes->hashMd5);
-#endif
-#ifndef NO_SHA
-    ret = wc_InitSha(&ssl->hsHashes->hashSha);
-    if (ret !=0)
-        return ret;
-#endif
-#endif /* NO_OLD_TLS */
-#ifndef NO_SHA256
-    ret = wc_InitSha256(&ssl->hsHashes->hashSha256);
-    if (ret !=0)
-        return ret;
-#endif
-#ifdef WOLFSSL_SHA384
-    ret = wc_InitSha384(&ssl->hsHashes->hashSha384);
-    if (ret !=0)
-        return ret;
-#endif
-#ifdef WOLFSSL_SHA512
-    ret = wc_InitSha512(&ssl->hsHashes->hashSha512);
-    if (ret !=0)
-        return ret;
-#endif
-
-    ret = wolfSSL_negotiate(ssl);
-    return ret;
-}
-
-#endif /* HAVE_SECURE_RENEGOTIATION */
-
-/* Session Ticket */
-#if !defined(NO_WOLFSSL_SERVER) && defined(HAVE_SESSION_TICKET)
-/* SSL_SUCCESS on ok */
-int wolfSSL_CTX_set_TicketEncCb(WOLFSSL_CTX* ctx, SessionTicketEncCb cb)
-{
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-    ctx->ticketEncCb = cb;
-
-    return SSL_SUCCESS;
-}
-
-/* set hint interval, SSL_SUCCESS on ok */
-int wolfSSL_CTX_set_TicketHint(WOLFSSL_CTX* ctx, int hint)
-{
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-    ctx->ticketHint = hint;
-
-    return SSL_SUCCESS;
-}
-
-/* set user context, SSL_SUCCESS on ok */
-int wolfSSL_CTX_set_TicketEncCtx(WOLFSSL_CTX* ctx, void* userCtx)
-{
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-    ctx->ticketEncCtx = userCtx;
-
-    return SSL_SUCCESS;
-}
-
-#endif /* !defined(NO_WOLFSSL_CLIENT) && defined(HAVE_SESSION_TICKET) */
-
-/* Session Ticket */
-#if !defined(NO_WOLFSSL_CLIENT) && defined(HAVE_SESSION_TICKET)
-int wolfSSL_UseSessionTicket(WOLFSSL* ssl)
-{
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    return TLSX_UseSessionTicket(&ssl->extensions, NULL);
-}
-
-int wolfSSL_CTX_UseSessionTicket(WOLFSSL_CTX* ctx)
-{
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-    return TLSX_UseSessionTicket(&ctx->extensions, NULL);
-}
-
-WOLFSSL_API int wolfSSL_get_SessionTicket(WOLFSSL* ssl, byte* buf, word32* bufSz)
-{
-    if (ssl == NULL || buf == NULL || bufSz == NULL || *bufSz == 0)
-        return BAD_FUNC_ARG;
-
-    if (ssl->session.ticketLen <= *bufSz) {
-        XMEMCPY(buf, ssl->session.ticket, ssl->session.ticketLen);
-        *bufSz = ssl->session.ticketLen;
-    }
-    else
-        *bufSz = 0;
-
-    return SSL_SUCCESS;
-}
-
-WOLFSSL_API int wolfSSL_set_SessionTicket(WOLFSSL* ssl, byte* buf, word32 bufSz)
-{
-    if (ssl == NULL || (buf == NULL && bufSz > 0))
-        return BAD_FUNC_ARG;
-
-    if (bufSz > 0)
-        XMEMCPY(ssl->session.ticket, buf, bufSz);
-    ssl->session.ticketLen = (word16)bufSz;
-
-    return SSL_SUCCESS;
-}
-
-
-WOLFSSL_API int wolfSSL_set_SessionTicket_cb(WOLFSSL* ssl,
-                                            CallbackSessionTicket cb, void* ctx)
-{
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    ssl->session_ticket_cb = cb;
-    ssl->session_ticket_ctx = ctx;
-
-    return SSL_SUCCESS;
-}
-#endif
-
-#ifndef WOLFSSL_LEANPSK
-
-int wolfSSL_send(WOLFSSL* ssl, const void* data, int sz, int flags)
-{
-    int ret;
-    int oldFlags;
-
-    WOLFSSL_ENTER("wolfSSL_send()");
-
-    if (ssl == NULL || data == NULL || sz < 0)
-        return BAD_FUNC_ARG;
-
-    oldFlags = ssl->wflags;
-
-    ssl->wflags = flags;
-    ret = wolfSSL_write(ssl, data, sz);
-    ssl->wflags = oldFlags;
-
-    WOLFSSL_LEAVE("wolfSSL_send()", ret);
-
-    return ret;
-}
-
-
-int wolfSSL_recv(WOLFSSL* ssl, void* data, int sz, int flags)
-{
-    int ret;
-    int oldFlags;
-
-    WOLFSSL_ENTER("wolfSSL_recv()");
-
-    if (ssl == NULL || data == NULL || sz < 0)
-        return BAD_FUNC_ARG;
-
-    oldFlags = ssl->rflags;
-
-    ssl->rflags = flags;
-    ret = wolfSSL_read(ssl, data, sz);
-    ssl->rflags = oldFlags;
-
-    WOLFSSL_LEAVE("wolfSSL_recv()", ret);
-
-    return ret;
-}
-#endif
-
-
-/* SSL_SUCCESS on ok */
-int wolfSSL_shutdown(WOLFSSL* ssl)
-{
-    int  ret = SSL_FATAL_ERROR;
-    byte tmp;
-    WOLFSSL_ENTER("SSL_shutdown()");
-
-    if (ssl == NULL)
-        return SSL_FATAL_ERROR;
-
-    if (ssl->options.quietShutdown) {
-        WOLFSSL_MSG("quiet shutdown, no close notify sent");
-        return SSL_SUCCESS;
-    }
-
-    /* try to send close notify, not an error if can't */
-    if (!ssl->options.isClosed && !ssl->options.connReset &&
-                                  !ssl->options.sentNotify) {
-        ssl->error = SendAlert(ssl, alert_warning, close_notify);
-        if (ssl->error < 0) {
-            WOLFSSL_ERROR(ssl->error);
-            return SSL_FATAL_ERROR;
-        }
-        ssl->options.sentNotify = 1;  /* don't send close_notify twice */
-        if (ssl->options.closeNotify)
-            ret = SSL_SUCCESS;
-        else
-            ret = SSL_SHUTDOWN_NOT_DONE;
-
-        WOLFSSL_LEAVE("SSL_shutdown()", ret);
-        return ret;
-    }
-
-    /* call wolfSSL_shutdown again for bidirectional shudown */
-    if (ssl->options.sentNotify && !ssl->options.closeNotify) {
-        ret = wolfSSL_read(ssl, &tmp, 0);
-        if (ret < 0) {
-            WOLFSSL_ERROR(ssl->error);
-            ret = SSL_FATAL_ERROR;
-        } else if (ssl->options.closeNotify) {
-            ssl->error = SSL_ERROR_SYSCALL;   /* simulate OpenSSL behavior */
-            ret = SSL_SUCCESS;
-        }
-    }
-
-    WOLFSSL_LEAVE("SSL_shutdown()", ret);
-
-    return ret;
-}
-
-
-int wolfSSL_get_error(WOLFSSL* ssl, int ret)
-{
-    WOLFSSL_ENTER("SSL_get_error");
-
-    if (ret > 0)
-        return SSL_ERROR_NONE;
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    WOLFSSL_LEAVE("SSL_get_error", ssl->error);
-
-    /* make sure converted types are handled in SetErrorString() too */
-    if (ssl->error == WANT_READ)
-        return SSL_ERROR_WANT_READ;         /* convert to OpenSSL type */
-    else if (ssl->error == WANT_WRITE)
-        return SSL_ERROR_WANT_WRITE;        /* convert to OpenSSL type */
-    else if (ssl->error == ZERO_RETURN)
-        return SSL_ERROR_ZERO_RETURN;       /* convert to OpenSSL type */
-    return ssl->error;
-}
-
-
-/* retrive alert history, SSL_SUCCESS on ok */
-int wolfSSL_get_alert_history(WOLFSSL* ssl, WOLFSSL_ALERT_HISTORY *h)
-{
-    if (ssl && h) {
-        *h = ssl->alert_history;
-    }
-    return SSL_SUCCESS;
-}
-
-
-/* return TRUE if current error is want read */
-int wolfSSL_want_read(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("SSL_want_read");
-    if (ssl->error == WANT_READ)
-        return 1;
-
-    return 0;
-}
-
-
-/* return TRUE if current error is want write */
-int wolfSSL_want_write(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("SSL_want_write");
-    if (ssl->error == WANT_WRITE)
-        return 1;
-
-    return 0;
-}
-
-
-char* wolfSSL_ERR_error_string(unsigned long errNumber, char* data)
-{
-    static const char* msg = "Please supply a buffer for error string";
-
-    WOLFSSL_ENTER("ERR_error_string");
-    if (data) {
-        SetErrorString((int)errNumber, data);
-        return data;
-    }
-
-    return (char*)msg;
-}
-
-
-void wolfSSL_ERR_error_string_n(unsigned long e, char* buf, unsigned long len)
-{
-    WOLFSSL_ENTER("wolfSSL_ERR_error_string_n");
-    if (len >= WOLFSSL_MAX_ERROR_SZ)
-        wolfSSL_ERR_error_string(e, buf);
-    else {
-        char tmp[WOLFSSL_MAX_ERROR_SZ];
-
-        WOLFSSL_MSG("Error buffer too short, truncating");
-        if (len) {
-            wolfSSL_ERR_error_string(e, tmp);
-            XMEMCPY(buf, tmp, len-1);
-            buf[len-1] = '\0';
-        }
-    }
-}
-
-
-/* don't free temporary arrays at end of handshake */
-void wolfSSL_KeepArrays(WOLFSSL* ssl)
-{
-    if (ssl)
-        ssl->options.saveArrays = 1;
-}
-
-
-/* user doesn't need temporary arrays anymore, Free */
-void wolfSSL_FreeArrays(WOLFSSL* ssl)
-{
-    if (ssl && ssl->options.handShakeState == HANDSHAKE_DONE) {
-        ssl->options.saveArrays = 0;
-        FreeArrays(ssl, 1);
-    }
-}
-
-
-const byte* wolfSSL_GetMacSecret(WOLFSSL* ssl, int verify)
-{
-    if (ssl == NULL)
-        return NULL;
-
-    if ( (ssl->options.side == WOLFSSL_CLIENT_END && !verify) ||
-         (ssl->options.side == WOLFSSL_SERVER_END &&  verify) )
-        return ssl->keys.client_write_MAC_secret;
-    else
-        return ssl->keys.server_write_MAC_secret;
-}
-
-
-#ifdef ATOMIC_USER
-
-void  wolfSSL_CTX_SetMacEncryptCb(WOLFSSL_CTX* ctx, CallbackMacEncrypt cb)
-{
-    if (ctx)
-        ctx->MacEncryptCb = cb;
-}
-
-
-void  wolfSSL_SetMacEncryptCtx(WOLFSSL* ssl, void *ctx)
-{
-    if (ssl)
-        ssl->MacEncryptCtx = ctx;
-}
-
-
-void* wolfSSL_GetMacEncryptCtx(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->MacEncryptCtx;
-
-    return NULL;
-}
-
-
-void  wolfSSL_CTX_SetDecryptVerifyCb(WOLFSSL_CTX* ctx, CallbackDecryptVerify cb)
-{
-    if (ctx)
-        ctx->DecryptVerifyCb = cb;
-}
-
-
-void  wolfSSL_SetDecryptVerifyCtx(WOLFSSL* ssl, void *ctx)
-{
-    if (ssl)
-        ssl->DecryptVerifyCtx = ctx;
-}
-
-
-void* wolfSSL_GetDecryptVerifyCtx(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->DecryptVerifyCtx;
-
-    return NULL;
-}
-
-
-const byte* wolfSSL_GetClientWriteKey(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->keys.client_write_key;
-
-    return NULL;
-}
-
-
-const byte* wolfSSL_GetClientWriteIV(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->keys.client_write_IV;
-
-    return NULL;
-}
-
-
-const byte* wolfSSL_GetServerWriteKey(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->keys.server_write_key;
-
-    return NULL;
-}
-
-
-const byte* wolfSSL_GetServerWriteIV(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->keys.server_write_IV;
-
-    return NULL;
-}
-
-
-int wolfSSL_GetKeySize(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->specs.key_size;
-
-    return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_GetIVSize(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->specs.iv_size;
-
-    return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_GetBulkCipher(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->specs.bulk_cipher_algorithm;
-
-    return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_GetCipherType(WOLFSSL* ssl)
-{
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    if (ssl->specs.cipher_type == block)
-        return WOLFSSL_BLOCK_TYPE;
-    if (ssl->specs.cipher_type == stream)
-        return WOLFSSL_STREAM_TYPE;
-    if (ssl->specs.cipher_type == aead)
-        return WOLFSSL_AEAD_TYPE;
-
-    return -1;
-}
-
-
-int wolfSSL_GetCipherBlockSize(WOLFSSL* ssl)
-{
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    return ssl->specs.block_size;
-}
-
-
-int wolfSSL_GetAeadMacSize(WOLFSSL* ssl)
-{
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    return ssl->specs.aead_mac_size;
-}
-
-
-int wolfSSL_IsTLSv1_1(WOLFSSL* ssl)
-{
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    if (ssl->options.tls1_1)
-        return 1;
-
-    return 0;
-}
-
-
-int wolfSSL_GetSide(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->options.side;
-
-    return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_GetHmacSize(WOLFSSL* ssl)
-{
-    /* AEAD ciphers don't have HMAC keys */
-    if (ssl)
-        return (ssl->specs.cipher_type != aead) ? ssl->specs.hash_size : 0;
-
-    return BAD_FUNC_ARG;
-}
-
-#endif /* ATOMIC_USER */
-
-#ifndef NO_CERTS
-
-WOLFSSL_CERT_MANAGER* wolfSSL_CertManagerNew(void)
-{
-    WOLFSSL_CERT_MANAGER* cm = NULL;
-
-    WOLFSSL_ENTER("wolfSSL_CertManagerNew");
-
-    cm = (WOLFSSL_CERT_MANAGER*) XMALLOC(sizeof(WOLFSSL_CERT_MANAGER), 0,
-                                        DYNAMIC_TYPE_CERT_MANAGER);
-    if (cm) {
-        XMEMSET(cm, 0, sizeof(WOLFSSL_CERT_MANAGER));
-
-        if (InitMutex(&cm->caLock) != 0) {
-            WOLFSSL_MSG("Bad mutex init");
-            wolfSSL_CertManagerFree(cm);
-            return NULL;
-        }
-    }
-
-    return cm;
-}
-
-
-void wolfSSL_CertManagerFree(WOLFSSL_CERT_MANAGER* cm)
-{
-    WOLFSSL_ENTER("wolfSSL_CertManagerFree");
-
-    if (cm) {
-        #ifdef HAVE_CRL
-            if (cm->crl)
-                FreeCRL(cm->crl, 1);
-        #endif
-        #ifdef HAVE_OCSP
-            if (cm->ocsp)
-                FreeOCSP(cm->ocsp, 1);
-        #endif
-        FreeSignerTable(cm->caTable, CA_TABLE_SIZE, NULL);
-        FreeMutex(&cm->caLock);
-        XFREE(cm, NULL, DYNAMIC_TYPE_CERT_MANAGER);
-    }
-
-}
-
-
-/* Unload the CA signer list */
-int wolfSSL_CertManagerUnloadCAs(WOLFSSL_CERT_MANAGER* cm)
-{
-    WOLFSSL_ENTER("wolfSSL_CertManagerUnloadCAs");
-
-    if (cm == NULL)
-        return BAD_FUNC_ARG;
-
-    if (LockMutex(&cm->caLock) != 0)
-        return BAD_MUTEX_E;
-
-    FreeSignerTable(cm->caTable, CA_TABLE_SIZE, NULL);
-
-    UnLockMutex(&cm->caLock);
-
-
-    return SSL_SUCCESS;
-}
-
-
-/* Return bytes written to buff or < 0 for error */
-int wolfSSL_CertPemToDer(const unsigned char* pem, int pemSz,
-                        unsigned char* buff, int buffSz,
-                        int type)
-{
-    int            eccKey = 0;
-    int            ret;
-    buffer         der;
-#ifdef WOLFSSL_SMALL_STACK
-    EncryptedInfo* info = NULL;
-#else
-    EncryptedInfo  info[1];
-#endif
-
-    WOLFSSL_ENTER("wolfSSL_CertPemToDer");
-
-    if (pem == NULL || buff == NULL || buffSz <= 0) {
-        WOLFSSL_MSG("Bad pem der args");
-        return BAD_FUNC_ARG;
-    }
-
-    if (type != CERT_TYPE && type != CA_TYPE && type != CERTREQ_TYPE) {
-        WOLFSSL_MSG("Bad cert type");
-        return BAD_FUNC_ARG;
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (info == NULL)
-        return MEMORY_E;
-#endif
-
-    info->set      = 0;
-    info->ctx      = NULL;
-    info->consumed = 0;
-    der.buffer     = NULL;
-
-    ret = PemToDer(pem, pemSz, type, &der, NULL, info, &eccKey);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    if (ret < 0) {
-        WOLFSSL_MSG("Bad Pem To Der");
-    }
-    else {
-        if (der.length <= (word32)buffSz) {
-            XMEMCPY(buff, der.buffer, der.length);
-            ret = der.length;
-        }
-        else {
-            WOLFSSL_MSG("Bad der length");
-            ret = BAD_FUNC_ARG;
-        }
-    }
-
-    XFREE(der.buffer, NULL, DYNAMIC_TYPE_KEY);
-
-    return ret;
-}
-
-
-#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
-
-/* our KeyPemToDer password callback, password in userData */
-static INLINE int OurPasswordCb(char* passwd, int sz, int rw, void* userdata)
-{
-    (void)rw;
-
-    if (userdata == NULL)
-        return 0;
-
-    XSTRNCPY(passwd, (char*)userdata, sz);
-    return min((word32)sz, (word32)XSTRLEN((char*)userdata));
-}
-
-#endif /* OPENSSL_EXTRA || HAVE_WEBSERVER */
-
-
-/* Return bytes written to buff or < 0 for error */
-int wolfSSL_KeyPemToDer(const unsigned char* pem, int pemSz, unsigned char* buff,
-                       int buffSz, const char* pass)
-{
-    int            eccKey = 0;
-    int            ret;
-    buffer         der;
-#ifdef WOLFSSL_SMALL_STACK
-    EncryptedInfo* info = NULL;
-#else
-    EncryptedInfo  info[1];
-#endif
-
-    (void)pass;
-
-    WOLFSSL_ENTER("wolfSSL_KeyPemToDer");
-
-    if (pem == NULL || buff == NULL || buffSz <= 0) {
-        WOLFSSL_MSG("Bad pem der args");
-        return BAD_FUNC_ARG;
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (info == NULL)
-        return MEMORY_E;
-#endif
-
-    info->set      = 0;
-    info->ctx      = NULL;
-    info->consumed = 0;
-    der.buffer     = NULL;
-
-#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
-    if (pass) {
-        info->ctx = wolfSSL_CTX_new(wolfSSLv23_client_method());
-        if (info->ctx == NULL) {
-        #ifdef WOLFSSL_SMALL_STACK
-            XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        #endif
-            return MEMORY_E;
-        }
-
-        wolfSSL_CTX_set_default_passwd_cb(info->ctx, OurPasswordCb);
-        wolfSSL_CTX_set_default_passwd_cb_userdata(info->ctx, (void*)pass);
-    }
-#endif
-
-    ret = PemToDer(pem, pemSz, PRIVATEKEY_TYPE, &der, NULL, info, &eccKey);
-
-    if (info->ctx)
-        wolfSSL_CTX_free(info->ctx);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    if (ret < 0) {
-        WOLFSSL_MSG("Bad Pem To Der");
-    }
-    else {
-        if (der.length <= (word32)buffSz) {
-            XMEMCPY(buff, der.buffer, der.length);
-            ret = der.length;
-        }
-        else {
-            WOLFSSL_MSG("Bad der length");
-            ret = BAD_FUNC_ARG;
-        }
-    }
-
-    XFREE(der.buffer, NULL, DYNAMIC_TYPE_KEY);
-
-    return ret;
-}
-
-
-#endif /* !NO_CERTS */
-
-
-
-#if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
-
-void wolfSSL_ERR_print_errors_fp(FILE* fp, int err)
-{
-    char data[WOLFSSL_MAX_ERROR_SZ + 1];
-
-    WOLFSSL_ENTER("wolfSSL_ERR_print_errors_fp");
-    SetErrorString(err, data);
-    fprintf(fp, "%s", data);
-}
-
-#endif
-
-
-int wolfSSL_pending(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("SSL_pending");
-    return ssl->buffers.clearOutputBuffer.length;
-}
-
-
-#ifndef WOLFSSL_LEANPSK
-/* trun on handshake group messages for context */
-int wolfSSL_CTX_set_group_messages(WOLFSSL_CTX* ctx)
-{
-    if (ctx == NULL)
-       return BAD_FUNC_ARG;
-
-    ctx->groupMessages = 1;
-
-    return SSL_SUCCESS;
-}
-#endif
-
-
-#ifndef NO_WOLFSSL_CLIENT
-/* connect enough to get peer cert chain */
-int wolfSSL_connect_cert(WOLFSSL* ssl)
-{
-    int  ret;
-
-    if (ssl == NULL)
-        return SSL_FAILURE;
-
-    ssl->options.certOnly = 1;
-    ret = wolfSSL_connect(ssl);
-    ssl->options.certOnly   = 0;
-
-    return ret;
-}
-#endif
-
-
-#ifndef WOLFSSL_LEANPSK
-/* trun on handshake group messages for ssl object */
-int wolfSSL_set_group_messages(WOLFSSL* ssl)
-{
-    if (ssl == NULL)
-       return BAD_FUNC_ARG;
-
-    ssl->options.groupMessages = 1;
-
-    return SSL_SUCCESS;
-}
-
-
-/* make minVersion the internal equivilant SSL version */
-static int SetMinVersionHelper(byte* minVersion, int version)
-{
-    switch (version) {
-#ifndef NO_OLD_TLS
-        case WOLFSSL_SSLV3:
-            *minVersion = SSLv3_MINOR;
-            break;
-#endif
-
-#ifndef NO_TLS
-    #ifndef NO_OLD_TLS
-        case WOLFSSL_TLSV1:
-            *minVersion = TLSv1_MINOR;
-            break;
-
-        case WOLFSSL_TLSV1_1:
-            *minVersion = TLSv1_1_MINOR;
-            break;
-    #endif
-        case WOLFSSL_TLSV1_2:
-            *minVersion = TLSv1_2_MINOR;
-            break;
-#endif
-
-        default:
-            WOLFSSL_MSG("Bad function argument");
-            return BAD_FUNC_ARG;
-    }
-
-    return SSL_SUCCESS;
-}
-
-
-/* Set minimum downgrade version allowed, SSL_SUCCESS on ok */
-int wolfSSL_CTX_SetMinVersion(WOLFSSL_CTX* ctx, int version)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_SetMinVersion");
-
-    if (ctx == NULL) {
-        WOLFSSL_MSG("Bad function argument");
-        return BAD_FUNC_ARG;
-    }
-
-    return SetMinVersionHelper(&ctx->minDowngrade, version);
-}
-
-
-/* Set minimum downgrade version allowed, SSL_SUCCESS on ok */
-int wolfSSL_SetMinVersion(WOLFSSL* ssl, int version)
-{
-    WOLFSSL_ENTER("wolfSSL_SetMinVersion");
-
-    if (ssl == NULL) {
-        WOLFSSL_MSG("Bad function argument");
-        return BAD_FUNC_ARG;
-    }
-
-    return SetMinVersionHelper(&ssl->options.minDowngrade, version);
-}
-
-
-int wolfSSL_SetVersion(WOLFSSL* ssl, int version)
-{
-    byte haveRSA = 1;
-    byte havePSK = 0;
-
-    WOLFSSL_ENTER("wolfSSL_SetVersion");
-
-    if (ssl == NULL) {
-        WOLFSSL_MSG("Bad function argument");
-        return BAD_FUNC_ARG;
-    }
-
-    switch (version) {
-#ifndef NO_OLD_TLS
-        case WOLFSSL_SSLV3:
-            ssl->version = MakeSSLv3();
-            break;
-#endif
-
-#ifndef NO_TLS
-    #ifndef NO_OLD_TLS
-        case WOLFSSL_TLSV1:
-            ssl->version = MakeTLSv1();
-            break;
-
-        case WOLFSSL_TLSV1_1:
-            ssl->version = MakeTLSv1_1();
-            break;
-    #endif
-        case WOLFSSL_TLSV1_2:
-            ssl->version = MakeTLSv1_2();
-            break;
-#endif
-
-        default:
-            WOLFSSL_MSG("Bad function argument");
-            return BAD_FUNC_ARG;
-    }
-
-    #ifdef NO_RSA
-        haveRSA = 0;
-    #endif
-    #ifndef NO_PSK
-        havePSK = ssl->options.havePSK;
-    #endif
-
-    InitSuites(ssl->suites, ssl->version, haveRSA, havePSK, ssl->options.haveDH,
-                ssl->options.haveNTRU, ssl->options.haveECDSAsig,
-                ssl->options.haveStaticECC, ssl->options.side);
-
-    return SSL_SUCCESS;
-}
-#endif /* !leanpsk */
-
-
-#if !defined(NO_CERTS) || !defined(NO_SESSION_CACHE)
-
-/* Make a work from the front of random hash */
-static INLINE word32 MakeWordFromHash(const byte* hashID)
-{
-    return (hashID[0] << 24) | (hashID[1] << 16) | (hashID[2] <<  8) |
-            hashID[3];
-}
-
-#endif /* !NO_CERTS || !NO_SESSION_CACHE */
-
-
-#ifndef NO_CERTS
-
-/* hash is the SHA digest of name, just use first 32 bits as hash */
-static INLINE word32 HashSigner(const byte* hash)
-{
-    return MakeWordFromHash(hash) % CA_TABLE_SIZE;
-}
-
-
-/* does CA already exist on signer list */
-int AlreadySigner(WOLFSSL_CERT_MANAGER* cm, byte* hash)
-{
-    Signer* signers;
-    int     ret = 0;
-    word32  row = HashSigner(hash);
-
-    if (LockMutex(&cm->caLock) != 0)
-        return  ret;
-    signers = cm->caTable[row];
-    while (signers) {
-        byte* subjectHash;
-        #ifndef NO_SKID
-            subjectHash = signers->subjectKeyIdHash;
-        #else
-            subjectHash = signers->subjectNameHash;
-        #endif
-        if (XMEMCMP(hash, subjectHash, SIGNER_DIGEST_SIZE) == 0) {
-            ret = 1;
-            break;
-        }
-        signers = signers->next;
-    }
-    UnLockMutex(&cm->caLock);
-
-    return ret;
-}
-
-
-/* return CA if found, otherwise NULL */
-Signer* GetCA(void* vp, byte* hash)
-{
-    WOLFSSL_CERT_MANAGER* cm = (WOLFSSL_CERT_MANAGER*)vp;
-    Signer* ret = NULL;
-    Signer* signers;
-    word32  row = HashSigner(hash);
-
-    if (cm == NULL)
-        return NULL;
-
-    if (LockMutex(&cm->caLock) != 0)
-        return ret;
-
-    signers = cm->caTable[row];
-    while (signers) {
-        byte* subjectHash;
-        #ifndef NO_SKID
-            subjectHash = signers->subjectKeyIdHash;
-        #else
-            subjectHash = signers->subjectNameHash;
-        #endif
-        if (XMEMCMP(hash, subjectHash, SIGNER_DIGEST_SIZE) == 0) {
-            ret = signers;
-            break;
-        }
-        signers = signers->next;
-    }
-    UnLockMutex(&cm->caLock);
-
-    return ret;
-}
-
-
-#ifndef NO_SKID
-/* return CA if found, otherwise NULL. Walk through hash table. */
-Signer* GetCAByName(void* vp, byte* hash)
-{
-    WOLFSSL_CERT_MANAGER* cm = (WOLFSSL_CERT_MANAGER*)vp;
-    Signer* ret = NULL;
-    Signer* signers;
-    word32  row;
-
-    if (cm == NULL)
-        return NULL;
-
-    if (LockMutex(&cm->caLock) != 0)
-        return ret;
-
-    for (row = 0; row < CA_TABLE_SIZE && ret == NULL; row++) {
-        signers = cm->caTable[row];
-        while (signers && ret == NULL) {
-            if (XMEMCMP(hash,
-                           signers->subjectNameHash, SIGNER_DIGEST_SIZE) == 0) {
-                ret = signers;
-            }
-            signers = signers->next;
-        }
-    }
-    UnLockMutex(&cm->caLock);
-
-    return ret;
-}
-#endif
-
-
-/* owns der, internal now uses too */
-/* type flag ids from user or from chain received during verify
-   don't allow chain ones to be added w/o isCA extension */
-int AddCA(WOLFSSL_CERT_MANAGER* cm, buffer der, int type, int verify)
-{
-    int         ret;
-    Signer*     signer = 0;
-    word32      row;
-    byte*       subjectHash;
-#ifdef WOLFSSL_SMALL_STACK
-    DecodedCert* cert = NULL;
-#else
-    DecodedCert  cert[1];
-#endif
-
-    WOLFSSL_MSG("Adding a CA");
-
-#ifdef WOLFSSL_SMALL_STACK
-    cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (cert == NULL)
-        return MEMORY_E;
-#endif
-
-    InitDecodedCert(cert, der.buffer, der.length, cm->heap);
-    ret = ParseCert(cert, CA_TYPE, verify, cm);
-    WOLFSSL_MSG("    Parsed new CA");
-
-#ifndef NO_SKID
-    subjectHash = cert->extSubjKeyId;
-#else
-    subjectHash = cert->subjectHash;
-#endif
-
-    if (ret == 0 && cert->isCA == 0 && type != WOLFSSL_USER_CA) {
-        WOLFSSL_MSG("    Can't add as CA if not actually one");
-        ret = NOT_CA_ERROR;
-    }
-#ifndef ALLOW_INVALID_CERTSIGN
-    else if (ret == 0 && cert->isCA == 1 && type != WOLFSSL_USER_CA &&
-                              (cert->extKeyUsage & KEYUSE_KEY_CERT_SIGN) == 0) {
-        /* Intermediate CA certs are required to have the keyCertSign
-        * extension set. User loaded root certs are not. */
-        WOLFSSL_MSG("    Doesn't have key usage certificate signing");
-        ret = NOT_CA_ERROR;
-    }
-#endif
-    else if (ret == 0 && AlreadySigner(cm, subjectHash)) {
-        WOLFSSL_MSG("    Already have this CA, not adding again");
-        (void)ret;
-    }
-    else if (ret == 0) {
-        /* take over signer parts */
-        signer = MakeSigner(cm->heap);
-        if (!signer)
-            ret = MEMORY_ERROR;
-        else {
-            signer->keyOID         = cert->keyOID;
-            signer->publicKey      = cert->publicKey;
-            signer->pubKeySize     = cert->pubKeySize;
-            signer->nameLen        = cert->subjectCNLen;
-            signer->name           = cert->subjectCN;
-        #ifndef IGNORE_NAME_CONSTRAINTS
-            signer->permittedNames = cert->permittedNames;
-            signer->excludedNames  = cert->excludedNames;
-        #endif
-        #ifndef NO_SKID
-            XMEMCPY(signer->subjectKeyIdHash, cert->extSubjKeyId,
-                                                            SIGNER_DIGEST_SIZE);
-        #endif
-            XMEMCPY(signer->subjectNameHash, cert->subjectHash,
-                                                            SIGNER_DIGEST_SIZE);
-            signer->keyUsage = cert->extKeyUsageSet ? cert->extKeyUsage
-                                                    : 0xFFFF;
-            signer->next    = NULL; /* If Key Usage not set, all uses valid. */
-            cert->publicKey = 0;    /* in case lock fails don't free here.   */
-            cert->subjectCN = 0;
-        #ifndef IGNORE_NAME_CONSTRAINTS
-            cert->permittedNames = NULL;
-            cert->excludedNames = NULL;
-        #endif
-
-        #ifndef NO_SKID
-            row = HashSigner(signer->subjectKeyIdHash);
-        #else
-            row = HashSigner(signer->subjectNameHash);
-        #endif
-
-            if (LockMutex(&cm->caLock) == 0) {
-                signer->next = cm->caTable[row];
-                cm->caTable[row] = signer;   /* takes ownership */
-                UnLockMutex(&cm->caLock);
-                if (cm->caCacheCallback)
-                    cm->caCacheCallback(der.buffer, (int)der.length, type);
-            }
-            else {
-                WOLFSSL_MSG("    CA Mutex Lock failed");
-                ret = BAD_MUTEX_E;
-                FreeSigner(signer, cm->heap);
-            }
-        }
-    }
-
-    WOLFSSL_MSG("    Freeing Parsed CA");
-    FreeDecodedCert(cert);
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-    WOLFSSL_MSG("    Freeing der CA");
-    XFREE(der.buffer, cm->heap, DYNAMIC_TYPE_CA);
-    WOLFSSL_MSG("        OK Freeing der CA");
-
-    WOLFSSL_LEAVE("AddCA", ret);
-
-    return ret == 0 ? SSL_SUCCESS : ret;
-}
-
-#endif /* !NO_CERTS */
-
-
-#ifndef NO_SESSION_CACHE
-
-    /* basic config gives a cache with 33 sessions, adequate for clients and
-       embedded servers
-
-       MEDIUM_SESSION_CACHE allows 1055 sessions, adequate for servers that
-       aren't under heavy load, basically allows 200 new sessions per minute
-
-       BIG_SESSION_CACHE yields 20,027 sessions
-
-       HUGE_SESSION_CACHE yields 65,791 sessions, for servers under heavy load,
-       allows over 13,000 new sessions per minute or over 200 new sessions per
-       second
-
-       SMALL_SESSION_CACHE only stores 6 sessions, good for embedded clients
-       or systems where the default of nearly 3kB is too much RAM, this define
-       uses less than 500 bytes RAM
-
-       default SESSION_CACHE stores 33 sessions (no XXX_SESSION_CACHE defined)
-    */
-    #ifdef HUGE_SESSION_CACHE
-        #define SESSIONS_PER_ROW 11
-        #define SESSION_ROWS 5981
-    #elif defined(BIG_SESSION_CACHE)
-        #define SESSIONS_PER_ROW 7
-        #define SESSION_ROWS 2861
-    #elif defined(MEDIUM_SESSION_CACHE)
-        #define SESSIONS_PER_ROW 5
-        #define SESSION_ROWS 211
-    #elif defined(SMALL_SESSION_CACHE)
-        #define SESSIONS_PER_ROW 2
-        #define SESSION_ROWS 3
-    #else
-        #define SESSIONS_PER_ROW 3
-        #define SESSION_ROWS 11
-    #endif
-
-    typedef struct SessionRow {
-        int nextIdx;                           /* where to place next one   */
-        int totalCount;                        /* sessions ever on this row */
-        WOLFSSL_SESSION Sessions[SESSIONS_PER_ROW];
-    } SessionRow;
-
-    static SessionRow SessionCache[SESSION_ROWS];
-
-    #if defined(WOLFSSL_SESSION_STATS) && defined(WOLFSSL_PEAK_SESSIONS)
-        static word32 PeakSessions;
-    #endif
-
-    static wolfSSL_Mutex session_mutex;   /* SessionCache mutex */
-
-    #ifndef NO_CLIENT_CACHE
-
-        typedef struct ClientSession {
-            word16 serverRow;            /* SessionCache Row id */
-            word16 serverIdx;            /* SessionCache Idx (column) */
-        } ClientSession;
-
-        typedef struct ClientRow {
-            int nextIdx;                /* where to place next one   */
-            int totalCount;             /* sessions ever on this row */
-            ClientSession Clients[SESSIONS_PER_ROW];
-        } ClientRow;
-
-        static ClientRow ClientCache[SESSION_ROWS];  /* Client Cache */
-                                                     /* uses session mutex */
-    #endif  /* NO_CLIENT_CACHE */
-
-#endif /* NO_SESSION_CACHE */
-
-
-int wolfSSL_Init(void)
-{
-    int ret = SSL_SUCCESS;
-
-    WOLFSSL_ENTER("wolfSSL_Init");
-
-    if (initRefCount == 0) {
-#ifndef NO_SESSION_CACHE
-        if (InitMutex(&session_mutex) != 0)
-            ret = BAD_MUTEX_E;
-#endif
-        if (InitMutex(&count_mutex) != 0)
-            ret = BAD_MUTEX_E;
-    }
-    if (ret == SSL_SUCCESS) {
-        if (LockMutex(&count_mutex) != 0) {
-            WOLFSSL_MSG("Bad Lock Mutex count");
-            return BAD_MUTEX_E;
-        }
-        initRefCount++;
-        UnLockMutex(&count_mutex);
-    }
-
-    return ret;
-}
-
-
-#ifndef NO_CERTS
-
-static const char* BEGIN_CERT         = "-----BEGIN CERTIFICATE-----";
-static const char* END_CERT           = "-----END CERTIFICATE-----";
-static const char* BEGIN_CERT_REQ     = "-----BEGIN CERTIFICATE REQUEST-----";
-static const char* END_CERT_REQ       = "-----END CERTIFICATE REQUEST-----";
-static const char* BEGIN_DH_PARAM     = "-----BEGIN DH PARAMETERS-----";
-static const char* END_DH_PARAM       = "-----END DH PARAMETERS-----";
-static const char* BEGIN_X509_CRL     = "-----BEGIN X509 CRL-----";
-static const char* END_X509_CRL       = "-----END X509 CRL-----";
-static const char* BEGIN_RSA_PRIV     = "-----BEGIN RSA PRIVATE KEY-----";
-static const char* END_RSA_PRIV       = "-----END RSA PRIVATE KEY-----";
-static const char* BEGIN_PRIV_KEY     = "-----BEGIN PRIVATE KEY-----";
-static const char* END_PRIV_KEY       = "-----END PRIVATE KEY-----";
-static const char* BEGIN_ENC_PRIV_KEY = "-----BEGIN ENCRYPTED PRIVATE KEY-----";
-static const char* END_ENC_PRIV_KEY   = "-----END ENCRYPTED PRIVATE KEY-----";
-static const char* BEGIN_EC_PRIV      = "-----BEGIN EC PRIVATE KEY-----";
-static const char* END_EC_PRIV        = "-----END EC PRIVATE KEY-----";
-static const char* BEGIN_DSA_PRIV     = "-----BEGIN DSA PRIVATE KEY-----";
-static const char* END_DSA_PRIV       = "-----END DSA PRIVATE KEY-----";
-
-/* Remove PEM header/footer, convert to ASN1, store any encrypted data
-   info->consumed tracks of PEM bytes consumed in case multiple parts */
-int PemToDer(const unsigned char* buff, long longSz, int type,
-                  buffer* der, void* heap, EncryptedInfo* info, int* eccKey)
-{
-    const char* header      = NULL;
-    const char* footer      = NULL;
-    char*       headerEnd;
-    char*       footerEnd;
-    char*       consumedEnd;
-    char*       bufferEnd   = (char*)(buff + longSz);
-    long        neededSz;
-    int         ret         = 0;
-    int         dynamicType = 0;
-    int         sz          = (int)longSz;
-
-    switch (type) {
-        case CA_TYPE:       /* same as below */
-        case CERT_TYPE:     header= BEGIN_CERT;     footer= END_CERT;     break;
-        case CRL_TYPE:      header= BEGIN_X509_CRL; footer= END_X509_CRL; break;
-        case DH_PARAM_TYPE: header= BEGIN_DH_PARAM; footer= END_DH_PARAM; break;
-        case CERTREQ_TYPE:  header= BEGIN_CERT_REQ; footer= END_CERT_REQ; break;
-        default:            header= BEGIN_RSA_PRIV; footer= END_RSA_PRIV; break;
-    }
-    
-    switch (type) {
-        case CA_TYPE:   dynamicType = DYNAMIC_TYPE_CA;   break;
-        case CERT_TYPE: dynamicType = DYNAMIC_TYPE_CERT; break;
-        case CRL_TYPE:  dynamicType = DYNAMIC_TYPE_CRL;  break;
-        default:        dynamicType = DYNAMIC_TYPE_KEY;  break;
-    }
-
-    /* find header */
-    for (;;) {
-        headerEnd = XSTRNSTR((char*)buff, header, sz);
-        
-        if (headerEnd || type != PRIVATEKEY_TYPE) {
-            break;
-        } else if (header == BEGIN_RSA_PRIV) {
-                   header =  BEGIN_PRIV_KEY;       footer = END_PRIV_KEY;
-        } else if (header == BEGIN_PRIV_KEY) {
-                   header =  BEGIN_ENC_PRIV_KEY;   footer = END_ENC_PRIV_KEY;
-        } else if (header == BEGIN_ENC_PRIV_KEY) {
-                   header =  BEGIN_EC_PRIV;        footer = END_EC_PRIV;
-        } else if (header == BEGIN_EC_PRIV) {
-                   header =  BEGIN_DSA_PRIV;       footer = END_DSA_PRIV;
-        } else
-            break;
-    }
-
-    if (!headerEnd) {
-        WOLFSSL_MSG("Couldn't find PEM header");
-        return SSL_NO_PEM_HEADER;
-    }
-
-    headerEnd += XSTRLEN(header);
-
-    /* eat end of line */
-    if (headerEnd[0] == '\n')
-        headerEnd++;
-    else if (headerEnd[1] == '\n')
-        headerEnd += 2;
-    else
-        return SSL_BAD_FILE;
-
-    if (type == PRIVATEKEY_TYPE) {
-        if (eccKey)
-            *eccKey = header == BEGIN_EC_PRIV;      
-    }
-
-#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
-    {
-        /* remove encrypted header if there */
-        char encHeader[] = "Proc-Type";
-        char* line = XSTRNSTR(headerEnd, encHeader, PEM_LINE_LEN);
-        if (line) {
-            char* newline;
-            char* finish;
-            char* start  = XSTRNSTR(line, "DES", PEM_LINE_LEN);
-
-            if (!start)
-                start = XSTRNSTR(line, "AES", PEM_LINE_LEN);
-
-            if (!start) return SSL_BAD_FILE;
-            if (!info)  return SSL_BAD_FILE;
-
-            finish = XSTRNSTR(start, ",", PEM_LINE_LEN);
-
-            if (start && finish && (start < finish)) {
-                newline = XSTRNSTR(finish, "\r", PEM_LINE_LEN);
-
-                XMEMCPY(info->name, start, finish - start);
-                info->name[finish - start] = 0;
-                XMEMCPY(info->iv, finish + 1, sizeof(info->iv));
-
-                if (!newline) newline = XSTRNSTR(finish, "\n", PEM_LINE_LEN);
-                if (newline && (newline > finish)) {
-                    info->ivSz = (word32)(newline - (finish + 1));
-                    info->set = 1;
-                }
-                else
-                    return SSL_BAD_FILE;
-            }
-            else
-                return SSL_BAD_FILE;
-
-            /* eat blank line */
-            while (*newline == '\r' || *newline == '\n')
-                newline++;
-            headerEnd = newline;
-        }
-    }
-#endif /* OPENSSL_EXTRA || HAVE_WEBSERVER */
-
-    /* find footer */
-    footerEnd = XSTRNSTR((char*)buff, footer, sz);
-    if (!footerEnd)
-        return SSL_BAD_FILE;
-
-    consumedEnd = footerEnd + XSTRLEN(footer);
-
-    if (consumedEnd < bufferEnd) {  /* handle no end of line on last line */
-        /* eat end of line */
-        if (consumedEnd[0] == '\n')
-            consumedEnd++;
-        else if (consumedEnd[1] == '\n')
-            consumedEnd += 2;
-        else
-            return SSL_BAD_FILE;
-    }
-
-    if (info)
-        info->consumed = (long)(consumedEnd - (char*)buff);
-
-    /* set up der buffer */
-    neededSz = (long)(footerEnd - headerEnd);
-    if (neededSz > sz || neededSz < 0)
-        return SSL_BAD_FILE;
-
-    der->buffer = (byte*)XMALLOC(neededSz, heap, dynamicType);
-    if (!der->buffer)
-        return MEMORY_ERROR;
-
-    der->length = (word32)neededSz;
-
-    if (Base64_Decode((byte*)headerEnd, (word32)neededSz, der->buffer,
-                                                              &der->length) < 0)
-        return SSL_BAD_FILE;
-
-    if (header == BEGIN_PRIV_KEY) {
-        /* pkcs8 key, convert and adjust length */
-        if ((ret = ToTraditional(der->buffer, der->length)) < 0)
-            return ret;
-
-        der->length = ret;
-        return 0;
-    }
-
-#if (defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)) && !defined(NO_PWDBASED)
-    if (header == BEGIN_ENC_PRIV_KEY) {
-        int   passwordSz;
-    #ifdef WOLFSSL_SMALL_STACK
-        char* password = NULL;
-    #else
-        char  password[80];
-    #endif
-
-        if (!info || !info->ctx || !info->ctx->passwd_cb)
-            return SSL_BAD_FILE;  /* no callback error */
-
-    #ifdef WOLFSSL_SMALL_STACK
-        password = (char*)XMALLOC(80, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (password == NULL)
-            return MEMORY_E;
-    #endif
-        passwordSz = info->ctx->passwd_cb(password, sizeof(password), 0,
-                                                           info->ctx->userdata);
-        /* convert and adjust length */
-        ret = ToTraditionalEnc(der->buffer, der->length, password, passwordSz);
-
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(password, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-
-        if (ret < 0)
-            return ret;
-
-        der->length = ret;
-        return 0;
-    }
-#endif
-
-    return 0;
-}
-
-
-/* process the buffer buff, legnth sz, into ctx of format and type
-   used tracks bytes consumed, userChain specifies a user cert chain
-   to pass during the handshake */
-static int ProcessBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff,
-                         long sz, int format, int type, WOLFSSL* ssl,
-                         long* used, int userChain)
-{
-    buffer        der;        /* holds DER or RAW (for NTRU) */
-    int           ret;
-    int           dynamicType = 0;
-    int           eccKey = 0;
-    int           rsaKey = 0;
-    void*         heap = ctx ? ctx->heap : NULL;
-#ifdef WOLFSSL_SMALL_STACK
-    EncryptedInfo* info = NULL;
-#else
-    EncryptedInfo  info[1];
-#endif
-
-    (void)dynamicType;
-    (void)rsaKey;
-
-    if (used)
-        *used = sz;     /* used bytes default to sz, PEM chain may shorten*/
-
-    if (format != SSL_FILETYPE_ASN1 && format != SSL_FILETYPE_PEM
-                                    && format != SSL_FILETYPE_RAW)
-        return SSL_BAD_FILETYPE;
-
-    if (ctx == NULL && ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    if (type == CA_TYPE)
-        dynamicType = DYNAMIC_TYPE_CA;
-    else if (type == CERT_TYPE)
-        dynamicType = DYNAMIC_TYPE_CERT;
-    else
-        dynamicType = DYNAMIC_TYPE_KEY;
-
-#ifdef WOLFSSL_SMALL_STACK
-    info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (info == NULL)
-        return MEMORY_E;
-#endif
-
-    info->set      = 0;
-    info->ctx      = ctx;
-    info->consumed = 0;
-    der.buffer     = 0;
-
-    if (format == SSL_FILETYPE_PEM) {
-        ret = PemToDer(buff, sz, type, &der, heap, info, &eccKey);
-        if (ret < 0) {
-        #ifdef WOLFSSL_SMALL_STACK
-            XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        #endif
-            XFREE(der.buffer, heap, dynamicType);
-            return ret;
-        }
-
-        if (used)
-            *used = info->consumed;
-
-        /* we may have a user cert chain, try to consume */
-        if (userChain && type == CERT_TYPE && info->consumed < sz) {
-        #ifdef WOLFSSL_SMALL_STACK
-            byte   staticBuffer[1];                 /* force heap usage */
-        #else
-            byte   staticBuffer[FILE_BUFFER_SIZE];  /* tmp chain buffer */
-        #endif
-            byte*  chainBuffer = staticBuffer;
-            byte*  shrinked    = NULL;   /* shrinked to size chainBuffer
-                                          * or staticBuffer */
-            int    dynamicBuffer = 0;
-            word32 bufferSz = sizeof(staticBuffer);
-            long   consumed = info->consumed;
-            word32 idx = 0;
-            int    gotOne = 0;
-
-            if ( (sz - consumed) > (int)bufferSz) {
-                WOLFSSL_MSG("Growing Tmp Chain Buffer");
-                bufferSz = (word32)(sz - consumed);
-                           /* will shrink to actual size */
-                chainBuffer = (byte*)XMALLOC(bufferSz, heap, DYNAMIC_TYPE_FILE);
-                if (chainBuffer == NULL) {
-                #ifdef WOLFSSL_SMALL_STACK
-                    XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                #endif
-                    XFREE(der.buffer, heap, dynamicType);
-                    return MEMORY_E;
-                }
-                dynamicBuffer = 1;
-            }
-
-            WOLFSSL_MSG("Processing Cert Chain");
-            while (consumed < sz) {
-                buffer part;
-                info->consumed = 0;
-                part.buffer = 0;
-
-                ret = PemToDer(buff + consumed, sz - consumed, type, &part,
-                                                           heap, info, &eccKey);
-                if (ret == 0) {
-                    gotOne = 1;
-                    if ( (idx + part.length) > bufferSz) {
-                        WOLFSSL_MSG("   Cert Chain bigger than buffer");
-                        ret = BUFFER_E;
-                    }
-                    else {
-                        c32to24(part.length, &chainBuffer[idx]);
-                        idx += CERT_HEADER_SZ;
-                        XMEMCPY(&chainBuffer[idx], part.buffer,part.length);
-                        idx += part.length;
-                        consumed  += info->consumed;
-                        if (used)
-                            *used += info->consumed;
-                    }
-                }
-
-                XFREE(part.buffer, heap, dynamicType);
-
-                if (ret == SSL_NO_PEM_HEADER && gotOne) {
-                    WOLFSSL_MSG("We got one good PEM so stuff at end ok");
-                    break;
-                }
-
-                if (ret < 0) {
-                    WOLFSSL_MSG("   Error in Cert in Chain");
-                    if (dynamicBuffer)
-                        XFREE(chainBuffer, heap, DYNAMIC_TYPE_FILE);
-                #ifdef WOLFSSL_SMALL_STACK
-                    XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                #endif
-                    XFREE(der.buffer, heap, dynamicType);
-                    return ret;
-                }
-                WOLFSSL_MSG("   Consumed another Cert in Chain");
-            }
-            WOLFSSL_MSG("Finished Processing Cert Chain");
-
-            /* only retain actual size used */
-            shrinked = (byte*)XMALLOC(idx, heap, dynamicType);
-            if (shrinked) {
-                if (ssl) {
-                    if (ssl->buffers.certChain.buffer &&
-                                                  ssl->buffers.weOwnCertChain) {
-                        XFREE(ssl->buffers.certChain.buffer, heap,
-                              dynamicType);
-                    }
-                    ssl->buffers.certChain.buffer = shrinked;
-                    ssl->buffers.certChain.length = idx;
-                    XMEMCPY(ssl->buffers.certChain.buffer, chainBuffer,idx);
-                    ssl->buffers.weOwnCertChain = 1;
-                } else if (ctx) {
-                    if (ctx->certChain.buffer)
-                        XFREE(ctx->certChain.buffer, heap, dynamicType);
-                    ctx->certChain.buffer = shrinked;
-                    ctx->certChain.length = idx;
-                    XMEMCPY(ctx->certChain.buffer, chainBuffer, idx);
-                }
-            }
-
-            if (dynamicBuffer)
-                XFREE(chainBuffer, heap, DYNAMIC_TYPE_FILE);
-
-            if (shrinked == NULL) {
-            #ifdef WOLFSSL_SMALL_STACK
-                XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            #endif
-                XFREE(der.buffer, heap, dynamicType);
-                return MEMORY_E;
-            }
-        }
-    }
-    else {  /* ASN1 (DER) or RAW (NTRU) */
-        der.buffer = (byte*) XMALLOC(sz, heap, dynamicType);
-        if (!der.buffer) {
-        #ifdef WOLFSSL_SMALL_STACK
-            XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        #endif
-            return MEMORY_ERROR;
-        }
-
-        XMEMCPY(der.buffer, buff, sz);
-        der.length = (word32)sz;
-    }
-
-#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
-    if (info->set) {
-        /* decrypt */
-        int   passwordSz;
-#ifdef WOLFSSL_SMALL_STACK
-        char* password = NULL;
-        byte* key      = NULL;
-        byte* iv       = NULL;
-#else
-        char  password[80];
-        byte  key[AES_256_KEY_SIZE];
-        #ifndef NO_MD5
-        byte  iv[AES_IV_SIZE];
-        #endif
-#endif
-
-    #ifdef WOLFSSL_SMALL_STACK
-        password = (char*)XMALLOC(80, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        key      = (byte*)XMALLOC(AES_256_KEY_SIZE, NULL,
-                                                   DYNAMIC_TYPE_TMP_BUFFER);
-        iv       = (byte*)XMALLOC(AES_IV_SIZE, NULL, 
-                                                   DYNAMIC_TYPE_TMP_BUFFER);
-
-        if (password == NULL || key == NULL || iv == NULL) {
-            XFREE(password, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(key,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(iv,       NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            ret = MEMORY_E;
-        }
-        else
-    #endif
-        if (!ctx || !ctx->passwd_cb) {
-            ret = NO_PASSWORD;
-        }
-        else {
-            passwordSz = ctx->passwd_cb(password, sizeof(password), 0,
-                                                             ctx->userdata);
-
-            /* use file's salt for key derivation, hex decode first */
-            if (Base16_Decode(info->iv, info->ivSz, info->iv, &info->ivSz)
-                                                                         != 0) {
-                ret = ASN_INPUT_E;
-            }
-#ifndef NO_MD5
-            else if ((ret = EVP_BytesToKey(info->name, "MD5", info->iv,
-                           (byte*)password, passwordSz, 1, key, iv)) <= 0) {
-                /* empty */
-            }
-#endif
-#ifndef NO_DES3
-            else if (XSTRNCMP(info->name, "DES-CBC", 7) == 0) {
-                ret = wc_Des_CbcDecryptWithKey(der.buffer, der.buffer, der.length,
-                                                                 key, info->iv);
-            }
-            else if (XSTRNCMP(info->name, "DES-EDE3-CBC", 13) == 0) {
-                ret = wc_Des3_CbcDecryptWithKey(der.buffer, der.buffer, der.length,
-                                                                 key, info->iv);
-            }
-#endif
-#ifndef NO_AES
-            else if (XSTRNCMP(info->name, "AES-128-CBC", 13) == 0) {
-                ret = wc_AesCbcDecryptWithKey(der.buffer, der.buffer, der.length,
-                                               key, AES_128_KEY_SIZE, info->iv);
-            }
-            else if (XSTRNCMP(info->name, "AES-192-CBC", 13) == 0) {
-                ret = wc_AesCbcDecryptWithKey(der.buffer, der.buffer, der.length,
-                                               key, AES_192_KEY_SIZE, info->iv);
-            }
-            else if (XSTRNCMP(info->name, "AES-256-CBC", 13) == 0) {
-                ret = wc_AesCbcDecryptWithKey(der.buffer, der.buffer, der.length,
-                                               key, AES_256_KEY_SIZE, info->iv);
-            }
-#endif
-            else {
-                ret = SSL_BAD_FILE;
-            }
-        }
-
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(password, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(key,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(iv,       NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-
-        if (ret != 0) {
-        #ifdef WOLFSSL_SMALL_STACK
-            XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        #endif
-            XFREE(der.buffer, heap, dynamicType);
-            return ret;
-        }
-    }
-#endif /* OPENSSL_EXTRA || HAVE_WEBSERVER */
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    if (type == CA_TYPE) {
-        if (ctx == NULL) {
-            WOLFSSL_MSG("Need context for CA load");
-            XFREE(der.buffer, heap, dynamicType);
-            return BAD_FUNC_ARG;
-        }
-        return AddCA(ctx->cm, der, WOLFSSL_USER_CA, ctx->verifyPeer);
-                                                      /* takes der over */
-    }
-    else if (type == CERT_TYPE) {
-        if (ssl) {
-            if (ssl->buffers.weOwnCert && ssl->buffers.certificate.buffer)
-                XFREE(ssl->buffers.certificate.buffer, heap, dynamicType);
-            ssl->buffers.certificate = der;
-            ssl->buffers.weOwnCert = 1;
-        }
-        else if (ctx) {
-            if (ctx->certificate.buffer)
-                XFREE(ctx->certificate.buffer, heap, dynamicType);
-            ctx->certificate = der;     /* takes der over */
-        }
-    }
-    else if (type == PRIVATEKEY_TYPE) {
-        if (ssl) {
-            if (ssl->buffers.weOwnKey && ssl->buffers.key.buffer)
-                XFREE(ssl->buffers.key.buffer, heap, dynamicType);
-            ssl->buffers.key = der;
-            ssl->buffers.weOwnKey = 1;
-        }
-        else if (ctx) {
-            if (ctx->privateKey.buffer)
-                XFREE(ctx->privateKey.buffer, heap, dynamicType);
-            ctx->privateKey = der;      /* takes der over */
-        }
-    }
-    else {
-        XFREE(der.buffer, heap, dynamicType);
-        return SSL_BAD_CERTTYPE;
-    }
-
-    if (type == PRIVATEKEY_TYPE && format != SSL_FILETYPE_RAW) {
-    #ifndef NO_RSA
-        if (!eccKey) {
-            /* make sure RSA key can be used */
-            word32 idx = 0;
-        #ifdef WOLFSSL_SMALL_STACK
-            RsaKey* key = NULL;
-        #else
-            RsaKey  key[1];
-        #endif
-
-        #ifdef WOLFSSL_SMALL_STACK
-            key = (RsaKey*)XMALLOC(sizeof(RsaKey), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            if (key == NULL)
-                return MEMORY_E;
-        #endif
-
-            ret = wc_InitRsaKey(key, 0);
-            if (ret == 0) {
-                if (wc_RsaPrivateKeyDecode(der.buffer, &idx, key, der.length) !=
-                                                                            0) {
-                #ifdef HAVE_ECC
-                    /* could have DER ECC (or pkcs8 ecc), no easy way to tell */
-                    eccKey = 1;  /* so try it out */
-                #endif
-                    if (!eccKey)
-                        ret = SSL_BAD_FILE;
-                } else {
-                    rsaKey = 1;
-                    (void)rsaKey;  /* for no ecc builds */
-                }
-            }
-
-            wc_FreeRsaKey(key);
-
-        #ifdef WOLFSSL_SMALL_STACK
-            XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        #endif
-
-            if (ret != 0)
-                return ret;
-        }
-    #endif
-    #ifdef HAVE_ECC
-        if (!rsaKey) {
-            /* make sure ECC key can be used */
-            word32  idx = 0;
-            ecc_key key;
-
-            wc_ecc_init(&key);
-            if (wc_EccPrivateKeyDecode(der.buffer,&idx,&key,der.length) != 0) {
-                wc_ecc_free(&key);
-                return SSL_BAD_FILE;
-            }
-            wc_ecc_free(&key);
-            eccKey = 1;
-            if (ctx)
-                ctx->haveStaticECC = 1;
-            if (ssl)
-                ssl->options.haveStaticECC = 1;
-        }
-    #endif /* HAVE_ECC */
-    }
-    else if (type == CERT_TYPE) {
-    #ifdef WOLFSSL_SMALL_STACK
-        DecodedCert* cert = NULL;
-    #else
-        DecodedCert  cert[1];
-    #endif
-
-    #ifdef WOLFSSL_SMALL_STACK
-        cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-        if (cert == NULL)
-            return MEMORY_E;
-    #endif
-
-        WOLFSSL_MSG("Checking cert signature type");
-        InitDecodedCert(cert, der.buffer, der.length, heap);
-
-        if (DecodeToKey(cert, 0) < 0) {
-            WOLFSSL_MSG("Decode to key failed");
-        #ifdef WOLFSSL_SMALL_STACK
-            XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        #endif
-            return SSL_BAD_FILE;
-        }
-        switch (cert->signatureOID) {
-            case CTC_SHAwECDSA:
-            case CTC_SHA256wECDSA:
-            case CTC_SHA384wECDSA:
-            case CTC_SHA512wECDSA:
-                WOLFSSL_MSG("ECDSA cert signature");
-                if (ctx)
-                    ctx->haveECDSAsig = 1;
-                if (ssl)
-                    ssl->options.haveECDSAsig = 1;
-                break;
-            default:
-                WOLFSSL_MSG("Not ECDSA cert signature");
-                break;
-        }
-
-    #ifdef HAVE_ECC
-        if (ctx)
-            ctx->pkCurveOID = cert->pkCurveOID;
-        if (ssl)
-            ssl->pkCurveOID = cert->pkCurveOID;
-    #endif
-
-        FreeDecodedCert(cert);
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-    }
-
-    return SSL_SUCCESS;
-}
-
-
-/* CA PEM file for verification, may have multiple/chain certs to process */
-static int ProcessChainBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff,
-                            long sz, int format, int type, WOLFSSL* ssl)
-{
-    long used   = 0;
-    int  ret    = 0;
-    int  gotOne = 0;
-
-    WOLFSSL_MSG("Processing CA PEM file");
-    while (used < sz) {
-        long consumed = 0;
-
-        ret = ProcessBuffer(ctx, buff + used, sz - used, format, type, ssl,
-                            &consumed, 0);
-
-        if (ret == SSL_NO_PEM_HEADER && gotOne) {
-            WOLFSSL_MSG("We got one good PEM file so stuff at end ok");
-            ret = SSL_SUCCESS;
-            break;
-        }
-
-        if (ret < 0)
-            break;
-
-        WOLFSSL_MSG("   Processed a CA");
-        gotOne = 1;
-        used += consumed;
-    }
-
-    return ret;
-}
-
-
-/* Verify the ceritficate, SSL_SUCCESS for ok, < 0 for error */
-int wolfSSL_CertManagerVerifyBuffer(WOLFSSL_CERT_MANAGER* cm, const byte* buff,
-                                   long sz, int format)
-{
-    int ret = 0;
-    buffer der;
-#ifdef WOLFSSL_SMALL_STACK
-    DecodedCert* cert = NULL;
-#else
-    DecodedCert  cert[1];
-#endif
-
-    WOLFSSL_ENTER("wolfSSL_CertManagerVerifyBuffer");
-
-#ifdef WOLFSSL_SMALL_STACK
-    cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (cert == NULL)
-        return MEMORY_E;
-#endif
-
-    der.buffer = NULL;
-    der.length = 0;
-
-    if (format == SSL_FILETYPE_PEM) {
-        int eccKey = 0; /* not used */
-    #ifdef WOLFSSL_SMALL_STACK
-        EncryptedInfo* info = NULL;
-    #else
-        EncryptedInfo  info[1];
-    #endif
-
-    #ifdef WOLFSSL_SMALL_STACK
-        info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-        if (info == NULL) {
-            XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            return MEMORY_E;
-        }
-    #endif
-
-        info->set      = 0;
-        info->ctx      = NULL;
-        info->consumed = 0;
-
-        ret = PemToDer(buff, sz, CERT_TYPE, &der, cm->heap, info, &eccKey);
-
-        if (ret == 0)
-            InitDecodedCert(cert, der.buffer, der.length, cm->heap);
-
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-    }
-    else
-        InitDecodedCert(cert, (byte*)buff, (word32)sz, cm->heap);
-
-    if (ret == 0)
-        ret = ParseCertRelative(cert, CERT_TYPE, 1, cm);
-
-#ifdef HAVE_CRL
-    if (ret == 0 && cm->crlEnabled)
-        ret = CheckCertCRL(cm->crl, cert);
-#endif
-
-    FreeDecodedCert(cert);
-
-    XFREE(der.buffer, cm->heap, DYNAMIC_TYPE_CERT);
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret == 0 ? SSL_SUCCESS : ret;
-}
-
-
-/* turn on OCSP if off and compiled in, set options */
-int wolfSSL_CertManagerEnableOCSP(WOLFSSL_CERT_MANAGER* cm, int options)
-{
-    int ret = SSL_SUCCESS;
-
-    (void)options;
-
-    WOLFSSL_ENTER("wolfSSL_CertManagerEnableOCSP");
-    if (cm == NULL)
-        return BAD_FUNC_ARG;
-
-    #ifdef HAVE_OCSP
-        if (cm->ocsp == NULL) {
-            cm->ocsp = (WOLFSSL_OCSP*)XMALLOC(sizeof(WOLFSSL_OCSP), cm->heap,
-                                                             DYNAMIC_TYPE_OCSP);
-            if (cm->ocsp == NULL)
-                return MEMORY_E;
-
-            if (InitOCSP(cm->ocsp, cm) != 0) {
-                WOLFSSL_MSG("Init OCSP failed");
-                FreeOCSP(cm->ocsp, 1);
-                cm->ocsp = NULL;
-                return SSL_FAILURE;
-            }
-        }
-        cm->ocspEnabled = 1;
-        if (options & WOLFSSL_OCSP_URL_OVERRIDE)
-            cm->ocspUseOverrideURL = 1;
-        if (options & WOLFSSL_OCSP_NO_NONCE)
-            cm->ocspSendNonce = 0;
-        else
-            cm->ocspSendNonce = 1;
-        if (options & WOLFSSL_OCSP_CHECKALL)
-            cm->ocspCheckAll = 1;
-        #ifndef WOLFSSL_USER_IO
-            cm->ocspIOCb = EmbedOcspLookup;
-            cm->ocspRespFreeCb = EmbedOcspRespFree;
-        #endif /* WOLFSSL_USER_IO */
-    #else
-        ret = NOT_COMPILED_IN;
-    #endif
-
-    return ret;
-}
-
-
-int wolfSSL_CertManagerDisableOCSP(WOLFSSL_CERT_MANAGER* cm)
-{
-    WOLFSSL_ENTER("wolfSSL_CertManagerDisableOCSP");
-    if (cm == NULL)
-        return BAD_FUNC_ARG;
-
-    cm->ocspEnabled = 0;
-
-    return SSL_SUCCESS;
-}
-
-
-#ifdef HAVE_OCSP
-
-
-/* check CRL if enabled, SSL_SUCCESS  */
-int wolfSSL_CertManagerCheckOCSP(WOLFSSL_CERT_MANAGER* cm, byte* der, int sz)
-{
-    int ret;
-#ifdef WOLFSSL_SMALL_STACK
-    DecodedCert* cert = NULL;
-#else
-    DecodedCert  cert[1];
-#endif
-
-    WOLFSSL_ENTER("wolfSSL_CertManagerCheckOCSP");
-
-    if (cm == NULL)
-        return BAD_FUNC_ARG;
-
-    if (cm->ocspEnabled == 0)
-        return SSL_SUCCESS;
-
-#ifdef WOLFSSL_SMALL_STACK
-    cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (cert == NULL)
-        return MEMORY_E;
-#endif
-
-    InitDecodedCert(cert, der, sz, NULL);
-
-    if ((ret = ParseCertRelative(cert, CERT_TYPE, NO_VERIFY, cm)) != 0) {
-        WOLFSSL_MSG("ParseCert failed");
-    }
-    else if ((ret = CheckCertOCSP(cm->ocsp, cert)) != 0) {
-        WOLFSSL_MSG("CheckCertOCSP failed");
-    }
-
-    FreeDecodedCert(cert);
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret == 0 ? SSL_SUCCESS : ret;
-}
-
-
-int wolfSSL_CertManagerSetOCSPOverrideURL(WOLFSSL_CERT_MANAGER* cm,
-                                                                const char* url)
-{
-    WOLFSSL_ENTER("wolfSSL_CertManagerSetOCSPOverrideURL");
-    if (cm == NULL)
-        return BAD_FUNC_ARG;
-
-    XFREE(cm->ocspOverrideURL, cm->heap, 0);
-    if (url != NULL) {
-        int urlSz = (int)XSTRLEN(url) + 1;
-        cm->ocspOverrideURL = (char*)XMALLOC(urlSz, cm->heap, 0);
-        if (cm->ocspOverrideURL != NULL) {
-            XMEMCPY(cm->ocspOverrideURL, url, urlSz);
-        }
-        else
-            return MEMORY_E;
-    }
-    else
-        cm->ocspOverrideURL = NULL;
-
-    return SSL_SUCCESS;
-}
-
-
-int wolfSSL_CertManagerSetOCSP_Cb(WOLFSSL_CERT_MANAGER* cm,
-                        CbOCSPIO ioCb, CbOCSPRespFree respFreeCb, void* ioCbCtx)
-{
-    WOLFSSL_ENTER("wolfSSL_CertManagerSetOCSP_Cb");
-    if (cm == NULL)
-        return BAD_FUNC_ARG;
-
-    cm->ocspIOCb = ioCb;
-    cm->ocspRespFreeCb = respFreeCb;
-    cm->ocspIOCtx = ioCbCtx;
-
-    return SSL_SUCCESS;
-}
-
-
-int wolfSSL_EnableOCSP(WOLFSSL* ssl, int options)
-{
-    WOLFSSL_ENTER("wolfSSL_EnableOCSP");
-    if (ssl)
-        return wolfSSL_CertManagerEnableOCSP(ssl->ctx->cm, options);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_DisableOCSP(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("wolfSSL_DisableOCSP");
-    if (ssl)
-        return wolfSSL_CertManagerDisableOCSP(ssl->ctx->cm);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_SetOCSP_OverrideURL(WOLFSSL* ssl, const char* url)
-{
-    WOLFSSL_ENTER("wolfSSL_SetOCSP_OverrideURL");
-    if (ssl)
-        return wolfSSL_CertManagerSetOCSPOverrideURL(ssl->ctx->cm, url);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_SetOCSP_Cb(WOLFSSL* ssl,
-                        CbOCSPIO ioCb, CbOCSPRespFree respFreeCb, void* ioCbCtx)
-{
-    WOLFSSL_ENTER("wolfSSL_SetOCSP_Cb");
-    if (ssl)
-        return wolfSSL_CertManagerSetOCSP_Cb(ssl->ctx->cm,
-                                                     ioCb, respFreeCb, ioCbCtx);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_CTX_EnableOCSP(WOLFSSL_CTX* ctx, int options)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_EnableOCSP");
-    if (ctx)
-        return wolfSSL_CertManagerEnableOCSP(ctx->cm, options);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_CTX_DisableOCSP(WOLFSSL_CTX* ctx)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_DisableOCSP");
-    if (ctx)
-        return wolfSSL_CertManagerDisableOCSP(ctx->cm);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_CTX_SetOCSP_OverrideURL(WOLFSSL_CTX* ctx, const char* url)
-{
-    WOLFSSL_ENTER("wolfSSL_SetOCSP_OverrideURL");
-    if (ctx)
-        return wolfSSL_CertManagerSetOCSPOverrideURL(ctx->cm, url);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_CTX_SetOCSP_Cb(WOLFSSL_CTX* ctx,
-                        CbOCSPIO ioCb, CbOCSPRespFree respFreeCb, void* ioCbCtx)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_SetOCSP_Cb");
-    if (ctx)
-        return wolfSSL_CertManagerSetOCSP_Cb(ctx->cm, ioCb, respFreeCb, ioCbCtx);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-#endif /* HAVE_OCSP */
-
-
-#ifndef NO_FILESYSTEM
-
-    #if defined(WOLFSSL_MDK_ARM)
-        extern FILE * wolfSSL_fopen(const char *name, const char *mode) ;
-        #define XFOPEN     wolfSSL_fopen
-    #else
-        #define XFOPEN     fopen
-    #endif
-
-/* process a file with name fname into ctx of format and type
-   userChain specifies a user certificate chain to pass during handshake */
-int ProcessFile(WOLFSSL_CTX* ctx, const char* fname, int format, int type,
-                WOLFSSL* ssl, int userChain, WOLFSSL_CRL* crl)
-{
-#ifdef WOLFSSL_SMALL_STACK
-    byte   staticBuffer[1]; /* force heap usage */
-#else
-    byte   staticBuffer[FILE_BUFFER_SIZE];
-#endif
-    byte*  myBuffer = staticBuffer;
-    int    dynamic = 0;
-    int    ret;
-    long   sz = 0;
-    XFILE  file;
-    void*  heapHint = ctx ? ctx->heap : NULL;
-
-    (void)crl;
-    (void)heapHint;
-
-    if (fname == NULL) return SSL_BAD_FILE;
-
-    file = XFOPEN(fname, "rb");
-    if (file == XBADFILE) return SSL_BAD_FILE;
-    XFSEEK(file, 0, XSEEK_END);
-    sz = XFTELL(file);
-    XREWIND(file);
-
-    if (sz > (long)sizeof(staticBuffer)) {
-        WOLFSSL_MSG("Getting dynamic buffer");
-        myBuffer = (byte*)XMALLOC(sz, heapHint, DYNAMIC_TYPE_FILE);
-        if (myBuffer == NULL) {
-            XFCLOSE(file);
-            return SSL_BAD_FILE;
-        }
-        dynamic = 1;
-    }
-    else if (sz < 0) {
-        XFCLOSE(file);
-        return SSL_BAD_FILE;
-    }
-
-    if ( (ret = (int)XFREAD(myBuffer, sz, 1, file)) < 0)
-        ret = SSL_BAD_FILE;
-    else {
-        if (type == CA_TYPE && format == SSL_FILETYPE_PEM)
-            ret = ProcessChainBuffer(ctx, myBuffer, sz, format, type, ssl);
-#ifdef HAVE_CRL
-        else if (type == CRL_TYPE)
-            ret = BufferLoadCRL(crl, myBuffer, sz, format);
-#endif
-        else
-            ret = ProcessBuffer(ctx, myBuffer, sz, format, type, ssl, NULL,
-                                userChain);
-    }
-
-    XFCLOSE(file);
-    if (dynamic)
-        XFREE(myBuffer, heapHint, DYNAMIC_TYPE_FILE);
-
-    return ret;
-}
-
-
-/* loads file then loads each file in path, no c_rehash */
-int wolfSSL_CTX_load_verify_locations(WOLFSSL_CTX* ctx, const char* file,
-                                     const char* path)
-{
-    int ret = SSL_SUCCESS;
-
-    WOLFSSL_ENTER("wolfSSL_CTX_load_verify_locations");
-    (void)path;
-
-    if (ctx == NULL || (file == NULL && path == NULL) )
-        return SSL_FAILURE;
-
-    if (file)
-        ret = ProcessFile(ctx, file, SSL_FILETYPE_PEM, CA_TYPE, NULL, 0, NULL);
-
-    if (ret == SSL_SUCCESS && path) {
-        /* try to load each regular file in path */
-    #ifdef USE_WINDOWS_API
-        WIN32_FIND_DATAA FindFileData;
-        HANDLE hFind;
-    #ifdef WOLFSSL_SMALL_STACK
-        char*  name = NULL;
-    #else
-        char   name[MAX_FILENAME_SZ];
-    #endif
-
-    #ifdef WOLFSSL_SMALL_STACK
-        name = (char*)XMALLOC(MAX_FILENAME_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (name == NULL)
-            return MEMORY_E;
-    #endif
-
-        XMEMSET(name, 0, MAX_FILENAME_SZ);
-        XSTRNCPY(name, path, MAX_FILENAME_SZ - 4);
-        XSTRNCAT(name, "\\*", 3);
-
-        hFind = FindFirstFileA(name, &FindFileData);
-        if (hFind == INVALID_HANDLE_VALUE) {
-            WOLFSSL_MSG("FindFirstFile for path verify locations failed");
-        #ifdef WOLFSSL_SMALL_STACK
-            XFREE(name, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        #endif
-            return BAD_PATH_ERROR;
-        }
-
-        do {
-            if (FindFileData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY) {
-                XSTRNCPY(name, path, MAX_FILENAME_SZ/2 - 3);
-                XSTRNCAT(name, "\\", 2);
-                XSTRNCAT(name, FindFileData.cFileName, MAX_FILENAME_SZ/2);
-
-                ret = ProcessFile(ctx, name, SSL_FILETYPE_PEM, CA_TYPE, NULL,0,
-                                                                          NULL);
-            }
-        } while (ret == SSL_SUCCESS && FindNextFileA(hFind, &FindFileData));
-
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(name, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-
-        FindClose(hFind);
-    #elif !defined(NO_WOLFSSL_DIR)
-        struct dirent* entry;
-        DIR*   dir = opendir(path);
-    #ifdef WOLFSSL_SMALL_STACK
-        char*  name = NULL;
-    #else
-        char   name[MAX_FILENAME_SZ];
-    #endif
-
-        if (dir == NULL) {
-            WOLFSSL_MSG("opendir path verify locations failed");
-            return BAD_PATH_ERROR;
-        }
-
-    #ifdef WOLFSSL_SMALL_STACK
-        name = (char*)XMALLOC(MAX_FILENAME_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (name == NULL)
-            return MEMORY_E;
-    #endif
-
-        while ( ret == SSL_SUCCESS && (entry = readdir(dir)) != NULL) {
-            struct stat s;
-
-            XMEMSET(name, 0, MAX_FILENAME_SZ);
-            XSTRNCPY(name, path, MAX_FILENAME_SZ/2 - 2);
-            XSTRNCAT(name, "/", 1);
-            XSTRNCAT(name, entry->d_name, MAX_FILENAME_SZ/2);
-
-            if (stat(name, &s) != 0) {
-                WOLFSSL_MSG("stat on name failed");
-                ret = BAD_PATH_ERROR;
-            } else if (s.st_mode & S_IFREG)
-                ret = ProcessFile(ctx, name, SSL_FILETYPE_PEM, CA_TYPE, NULL,0,
-                                                                          NULL);
-        }
-
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(name, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-
-        closedir(dir);
-    #endif
-    }
-
-    return ret;
-}
-
-
-/* Verify the ceritficate, SSL_SUCCESS for ok, < 0 for error */
-int wolfSSL_CertManagerVerify(WOLFSSL_CERT_MANAGER* cm, const char* fname,
-                             int format)
-{
-    int    ret = SSL_FATAL_ERROR;
-#ifdef WOLFSSL_SMALL_STACK
-    byte   staticBuffer[1]; /* force heap usage */
-#else
-    byte   staticBuffer[FILE_BUFFER_SIZE];
-#endif
-    byte*  myBuffer = staticBuffer;
-    int    dynamic = 0;
-    long   sz = 0;
-    XFILE  file = XFOPEN(fname, "rb");
-
-    WOLFSSL_ENTER("wolfSSL_CertManagerVerify");
-
-    if (file == XBADFILE) return SSL_BAD_FILE;
-    XFSEEK(file, 0, XSEEK_END);
-    sz = XFTELL(file);
-    XREWIND(file);
-
-    if (sz > MAX_WOLFSSL_FILE_SIZE || sz < 0) {
-        WOLFSSL_MSG("CertManagerVerify file bad size");
-        XFCLOSE(file);
-        return SSL_BAD_FILE;
-    }
-
-    if (sz > (long)sizeof(staticBuffer)) {
-        WOLFSSL_MSG("Getting dynamic buffer");
-        myBuffer = (byte*) XMALLOC(sz, cm->heap, DYNAMIC_TYPE_FILE);
-        if (myBuffer == NULL) {
-            XFCLOSE(file);
-            return SSL_BAD_FILE;
-        }
-        dynamic = 1;
-    }
-
-    if ( (ret = (int)XFREAD(myBuffer, sz, 1, file)) < 0)
-        ret = SSL_BAD_FILE;
-    else
-        ret = wolfSSL_CertManagerVerifyBuffer(cm, myBuffer, sz, format);
-
-    XFCLOSE(file);
-    if (dynamic)
-        XFREE(myBuffer, cm->heap, DYNAMIC_TYPE_FILE);
-
-    return ret;
-}
-
-
-static INLINE WOLFSSL_METHOD* cm_pick_method(void)
-{
-    #ifndef NO_WOLFSSL_CLIENT
-        #ifdef NO_OLD_TLS
-            return wolfTLSv1_2_client_method();
-        #else
-            return wolfSSLv3_client_method();
-        #endif      
-    #elif !defined(NO_WOLFSSL_SERVER)
-        #ifdef NO_OLD_TLS
-            return wolfTLSv1_2_server_method();
-        #else
-            return wolfSSLv3_server_method();
-        #endif
-    #else
-        return NULL;
-    #endif
-}
-
-
-/* like load verify locations, 1 for success, < 0 for error */
-int wolfSSL_CertManagerLoadCA(WOLFSSL_CERT_MANAGER* cm, const char* file,
-                             const char* path)
-{
-    int ret = SSL_FATAL_ERROR;
-    WOLFSSL_CTX* tmp;
-
-    WOLFSSL_ENTER("wolfSSL_CertManagerLoadCA");
-
-    if (cm == NULL) {
-        WOLFSSL_MSG("No CertManager error");
-        return ret;
-    }
-    tmp = wolfSSL_CTX_new(cm_pick_method());
-
-    if (tmp == NULL) {
-        WOLFSSL_MSG("CTX new failed");
-        return ret;
-    }
-
-    /* for tmp use */
-    wolfSSL_CertManagerFree(tmp->cm);
-    tmp->cm = cm;
-
-    ret = wolfSSL_CTX_load_verify_locations(tmp, file, path);
-
-    /* don't loose our good one */
-    tmp->cm = NULL;
-    wolfSSL_CTX_free(tmp);
-
-    return ret;
-}
-
-
-
-/* turn on CRL if off and compiled in, set options */
-int wolfSSL_CertManagerEnableCRL(WOLFSSL_CERT_MANAGER* cm, int options)
-{
-    int ret = SSL_SUCCESS;
-
-    (void)options;
-
-    WOLFSSL_ENTER("wolfSSL_CertManagerEnableCRL");
-    if (cm == NULL)
-        return BAD_FUNC_ARG;
-
-    #ifdef HAVE_CRL
-        if (cm->crl == NULL) {
-            cm->crl = (WOLFSSL_CRL*)XMALLOC(sizeof(WOLFSSL_CRL), cm->heap,
-                                           DYNAMIC_TYPE_CRL);
-            if (cm->crl == NULL)
-                return MEMORY_E;
-
-            if (InitCRL(cm->crl, cm) != 0) {
-                WOLFSSL_MSG("Init CRL failed");
-                FreeCRL(cm->crl, 1);
-                cm->crl = NULL;
-                return SSL_FAILURE;
-            }
-        }
-        cm->crlEnabled = 1;
-        if (options & WOLFSSL_CRL_CHECKALL)
-            cm->crlCheckAll = 1;
-    #else
-        ret = NOT_COMPILED_IN;
-    #endif
-
-    return ret;
-}
-
-
-int wolfSSL_CertManagerDisableCRL(WOLFSSL_CERT_MANAGER* cm)
-{
-    WOLFSSL_ENTER("wolfSSL_CertManagerDisableCRL");
-    if (cm == NULL)
-        return BAD_FUNC_ARG;
-
-    cm->crlEnabled = 0;
-
-    return SSL_SUCCESS;
-}
-
-
-int wolfSSL_CTX_check_private_key(WOLFSSL_CTX* ctx)
-{
-    /* TODO: check private against public for RSA match */
-    (void)ctx;
-    WOLFSSL_ENTER("SSL_CTX_check_private_key");
-    return SSL_SUCCESS;
-}
-
-
-#ifdef HAVE_CRL
-
-
-/* check CRL if enabled, SSL_SUCCESS  */
-int wolfSSL_CertManagerCheckCRL(WOLFSSL_CERT_MANAGER* cm, byte* der, int sz)
-{
-    int ret = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    DecodedCert* cert = NULL;
-#else
-    DecodedCert  cert[1];
-#endif
-
-    WOLFSSL_ENTER("wolfSSL_CertManagerCheckCRL");
-
-    if (cm == NULL)
-        return BAD_FUNC_ARG;
-
-    if (cm->crlEnabled == 0)
-        return SSL_SUCCESS;
-
-#ifdef WOLFSSL_SMALL_STACK
-    cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (cert == NULL)
-        return MEMORY_E;
-#endif
-
-    InitDecodedCert(cert, der, sz, NULL);
-
-    if ((ret = ParseCertRelative(cert, CERT_TYPE, NO_VERIFY, cm)) != 0) {
-        WOLFSSL_MSG("ParseCert failed");
-    }
-    else if ((ret = CheckCertCRL(cm->crl, cert)) != 0) {
-        WOLFSSL_MSG("CheckCertCRL failed");
-    }
-
-    FreeDecodedCert(cert);
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret == 0 ? SSL_SUCCESS : ret;
-}
-
-
-int wolfSSL_CertManagerSetCRL_Cb(WOLFSSL_CERT_MANAGER* cm, CbMissingCRL cb)
-{
-    WOLFSSL_ENTER("wolfSSL_CertManagerSetCRL_Cb");
-    if (cm == NULL)
-        return BAD_FUNC_ARG;
-
-    cm->cbMissingCRL = cb;
-
-    return SSL_SUCCESS;
-}
-
-
-int wolfSSL_CertManagerLoadCRL(WOLFSSL_CERT_MANAGER* cm, const char* path,
-                              int type, int monitor)
-{
-    WOLFSSL_ENTER("wolfSSL_CertManagerLoadCRL");
-    if (cm == NULL)
-        return BAD_FUNC_ARG;
-
-    if (cm->crl == NULL) {
-        if (wolfSSL_CertManagerEnableCRL(cm, 0) != SSL_SUCCESS) {
-            WOLFSSL_MSG("Enable CRL failed");
-            return SSL_FATAL_ERROR;
-        }
-    }
-
-    return LoadCRL(cm->crl, path, type, monitor);
-}
-
-
-int wolfSSL_EnableCRL(WOLFSSL* ssl, int options)
-{
-    WOLFSSL_ENTER("wolfSSL_EnableCRL");
-    if (ssl)
-        return wolfSSL_CertManagerEnableCRL(ssl->ctx->cm, options);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_DisableCRL(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("wolfSSL_DisableCRL");
-    if (ssl)
-        return wolfSSL_CertManagerDisableCRL(ssl->ctx->cm);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_LoadCRL(WOLFSSL* ssl, const char* path, int type, int monitor)
-{
-    WOLFSSL_ENTER("wolfSSL_LoadCRL");
-    if (ssl)
-        return wolfSSL_CertManagerLoadCRL(ssl->ctx->cm, path, type, monitor);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_SetCRL_Cb(WOLFSSL* ssl, CbMissingCRL cb)
-{
-    WOLFSSL_ENTER("wolfSSL_SetCRL_Cb");
-    if (ssl)
-        return wolfSSL_CertManagerSetCRL_Cb(ssl->ctx->cm, cb);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_CTX_EnableCRL(WOLFSSL_CTX* ctx, int options)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_EnableCRL");
-    if (ctx)
-        return wolfSSL_CertManagerEnableCRL(ctx->cm, options);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_CTX_DisableCRL(WOLFSSL_CTX* ctx)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_DisableCRL");
-    if (ctx)
-        return wolfSSL_CertManagerDisableCRL(ctx->cm);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_CTX_LoadCRL(WOLFSSL_CTX* ctx, const char* path, int type, int monitor)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_LoadCRL");
-    if (ctx)
-        return wolfSSL_CertManagerLoadCRL(ctx->cm, path, type, monitor);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_CTX_SetCRL_Cb(WOLFSSL_CTX* ctx, CbMissingCRL cb)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_SetCRL_Cb");
-    if (ctx)
-        return wolfSSL_CertManagerSetCRL_Cb(ctx->cm, cb);
-    else
-        return BAD_FUNC_ARG;
-}
-
-
-#endif /* HAVE_CRL */
-
-
-#ifdef WOLFSSL_DER_LOAD
-
-/* Add format parameter to allow DER load of CA files */
-int wolfSSL_CTX_der_load_verify_locations(WOLFSSL_CTX* ctx, const char* file,
-                                         int format)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_der_load_verify_locations");
-    if (ctx == NULL || file == NULL)
-        return SSL_FAILURE;
-
-    if (ProcessFile(ctx, file, format, CA_TYPE, NULL, 0, NULL) == SSL_SUCCESS)
-        return SSL_SUCCESS;
-
-    return SSL_FAILURE;
-}
-
-#endif /* WOLFSSL_DER_LOAD */
-
-
-#ifdef WOLFSSL_CERT_GEN
-
-/* load pem cert from file into der buffer, return der size or error */
-int wolfSSL_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz)
-{
-#ifdef WOLFSSL_SMALL_STACK
-    EncryptedInfo* info = NULL;
-    byte   staticBuffer[1]; /* force XMALLOC */
-#else
-    EncryptedInfo info[1];
-    byte   staticBuffer[FILE_BUFFER_SIZE];
-#endif
-    byte*  fileBuf = staticBuffer;
-    int    dynamic = 0;
-    int    ret     = 0;
-    int    ecc     = 0;
-    long   sz      = 0;
-    XFILE  file    = XFOPEN(fileName, "rb");
-    buffer converted;
-
-    WOLFSSL_ENTER("wolfSSL_PemCertToDer");
-
-    if (file == XBADFILE)
-        ret = SSL_BAD_FILE;
-    else {
-        XFSEEK(file, 0, XSEEK_END);
-        sz = XFTELL(file);
-        XREWIND(file);
-
-        if (sz < 0) {
-            ret = SSL_BAD_FILE;
-        }
-        else if (sz > (long)sizeof(staticBuffer)) {
-            fileBuf = (byte*)XMALLOC(sz, 0, DYNAMIC_TYPE_FILE);
-            if (fileBuf == NULL)
-                ret = MEMORY_E;
-            else
-                dynamic = 1;
-        }
-
-        converted.buffer = 0;
-
-        if (ret == 0) {
-            if ( (ret = (int)XFREAD(fileBuf, sz, 1, file)) < 0)
-                ret = SSL_BAD_FILE;
-            else {
-            #ifdef WOLFSSL_SMALL_STACK
-                info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-                if (info == NULL)
-                    ret = MEMORY_E;
-                else
-            #endif
-                {
-                    ret = PemToDer(fileBuf, sz, CA_TYPE, &converted, 0, info,
-                                                                          &ecc);
-                #ifdef WOLFSSL_SMALL_STACK
-                    XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                #endif
-                }
-            }
-
-            if (ret == 0) {
-                if (converted.length < (word32)derSz) {
-                    XMEMCPY(derBuf, converted.buffer, converted.length);
-                    ret = converted.length;
-                }
-                else
-                    ret = BUFFER_E;
-            }
-
-            XFREE(converted.buffer, 0, DYNAMIC_TYPE_CA);
-        }
-
-        XFCLOSE(file);
-        if (dynamic)
-            XFREE(fileBuf, 0, DYNAMIC_TYPE_FILE);
-    }
-
-    return ret;
-}
-
-#endif /* WOLFSSL_CERT_GEN */
-
-
-int wolfSSL_CTX_use_certificate_file(WOLFSSL_CTX* ctx, const char* file,
-                                    int format)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_use_certificate_file");
-    if (ProcessFile(ctx, file, format, CERT_TYPE, NULL, 0, NULL) == SSL_SUCCESS)
-        return SSL_SUCCESS;
-
-    return SSL_FAILURE;
-}
-
-
-int wolfSSL_CTX_use_PrivateKey_file(WOLFSSL_CTX* ctx, const char* file,int format)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_use_PrivateKey_file");
-    if (ProcessFile(ctx, file, format, PRIVATEKEY_TYPE, NULL, 0, NULL)
-                    == SSL_SUCCESS)
-        return SSL_SUCCESS;
-
-    return SSL_FAILURE;
-}
-
-
-/* get cert chaining depth using ssl struct */
-long wolfSSL_get_verify_depth(WOLFSSL* ssl)
-{
-    if(ssl == NULL) {
-        return BAD_FUNC_ARG;
-    }
-    return MAX_CHAIN_DEPTH;
-}
-
-
-/* get cert chaining depth using ctx struct */
-long wolfSSL_CTX_get_verify_depth(WOLFSSL_CTX* ctx)
-{
-    if(ctx == NULL) {
-        return BAD_FUNC_ARG;
-    }
-    return MAX_CHAIN_DEPTH;
-}
-
-
-int wolfSSL_CTX_use_certificate_chain_file(WOLFSSL_CTX* ctx, const char* file)
-{
-   /* procces up to MAX_CHAIN_DEPTH plus subject cert */
-   WOLFSSL_ENTER("wolfSSL_CTX_use_certificate_chain_file");
-   if (ProcessFile(ctx, file, SSL_FILETYPE_PEM,CERT_TYPE,NULL,1, NULL)
-                   == SSL_SUCCESS)
-       return SSL_SUCCESS;
-
-   return SSL_FAILURE;
-}
-
-
-#ifndef NO_DH
-
-/* server wrapper for ctx or ssl Diffie-Hellman parameters */
-static int wolfSSL_SetTmpDH_buffer_wrapper(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
-                                  const unsigned char* buf, long sz, int format)
-{
-    buffer der;
-    int    ret      = 0;
-    int    weOwnDer = 0;
-    word32 pSz = MAX_DH_SIZE;
-    word32 gSz = MAX_DH_SIZE;
-#ifdef WOLFSSL_SMALL_STACK
-    byte*  p = NULL;
-    byte*  g = NULL;
-#else
-    byte   p[MAX_DH_SIZE];
-    byte   g[MAX_DH_SIZE];
-#endif
-
-    der.buffer = (byte*)buf;
-    der.length = (word32)sz;
-
-#ifdef WOLFSSL_SMALL_STACK
-    p = (byte*)XMALLOC(pSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    g = (byte*)XMALLOC(gSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-    if (p == NULL || g == NULL) {
-        XFREE(p, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(g, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#endif
-
-    if (format != SSL_FILETYPE_ASN1 && format != SSL_FILETYPE_PEM)
-        ret = SSL_BAD_FILETYPE;
-    else {
-        if (format == SSL_FILETYPE_PEM) {
-            der.buffer = NULL;
-            ret = PemToDer(buf, sz, DH_PARAM_TYPE, &der, ctx->heap, NULL,NULL);
-            weOwnDer = 1;
-        }
-        
-        if (ret == 0) {
-            if (wc_DhParamsLoad(der.buffer, der.length, p, &pSz, g, &gSz) < 0)
-                ret = SSL_BAD_FILETYPE;
-            else if (ssl)
-                ret = wolfSSL_SetTmpDH(ssl, p, pSz, g, gSz);
-            else
-                ret = wolfSSL_CTX_SetTmpDH(ctx, p, pSz, g, gSz);
-        }
-    }
-
-    if (weOwnDer)
-        XFREE(der.buffer, ctx->heap, DYNAMIC_TYPE_KEY);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(p, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(g, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-/* server Diffie-Hellman parameters, SSL_SUCCESS on ok */
-int wolfSSL_SetTmpDH_buffer(WOLFSSL* ssl, const unsigned char* buf, long sz,
-                           int format)
-{
-    return wolfSSL_SetTmpDH_buffer_wrapper(ssl->ctx, ssl, buf, sz, format);
-}
-
-
-/* server ctx Diffie-Hellman parameters, SSL_SUCCESS on ok */
-int wolfSSL_CTX_SetTmpDH_buffer(WOLFSSL_CTX* ctx, const unsigned char* buf,
-                               long sz, int format)
-{
-    return wolfSSL_SetTmpDH_buffer_wrapper(ctx, NULL, buf, sz, format);
-}
-
-
-/* server Diffie-Hellman parameters */
-static int wolfSSL_SetTmpDH_file_wrapper(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
-                                        const char* fname, int format)
-{
-#ifdef WOLFSSL_SMALL_STACK
-    byte   staticBuffer[1]; /* force heap usage */
-#else
-    byte   staticBuffer[FILE_BUFFER_SIZE];
-#endif
-    byte*  myBuffer = staticBuffer;
-    int    dynamic = 0;
-    int    ret;
-    long   sz = 0;
-    XFILE  file = XFOPEN(fname, "rb");
-
-    if (file == XBADFILE) return SSL_BAD_FILE;
-    XFSEEK(file, 0, XSEEK_END);
-    sz = XFTELL(file);
-    XREWIND(file);
-
-    if (sz > (long)sizeof(staticBuffer)) {
-        WOLFSSL_MSG("Getting dynamic buffer");
-        myBuffer = (byte*) XMALLOC(sz, ctx->heap, DYNAMIC_TYPE_FILE);
-        if (myBuffer == NULL) {
-            XFCLOSE(file);
-            return SSL_BAD_FILE;
-        }
-        dynamic = 1;
-    }
-    else if (sz < 0) {
-        XFCLOSE(file);
-        return SSL_BAD_FILE;
-    }
-
-    if ( (ret = (int)XFREAD(myBuffer, sz, 1, file)) < 0)
-        ret = SSL_BAD_FILE;
-    else {
-        if (ssl)
-            ret = wolfSSL_SetTmpDH_buffer(ssl, myBuffer, sz, format);
-        else
-            ret = wolfSSL_CTX_SetTmpDH_buffer(ctx, myBuffer, sz, format);
-    }
-
-    XFCLOSE(file);
-    if (dynamic)
-        XFREE(myBuffer, ctx->heap, DYNAMIC_TYPE_FILE);
-
-    return ret;
-}
-
-/* server Diffie-Hellman parameters */
-int wolfSSL_SetTmpDH_file(WOLFSSL* ssl, const char* fname, int format)
-{
-    return wolfSSL_SetTmpDH_file_wrapper(ssl->ctx, ssl, fname, format);
-}
-
-
-/* server Diffie-Hellman parameters */
-int wolfSSL_CTX_SetTmpDH_file(WOLFSSL_CTX* ctx, const char* fname, int format)
-{
-    return wolfSSL_SetTmpDH_file_wrapper(ctx, NULL, fname, format);
-}
-
-
-int wolfSSL_CTX_SetMinDhKey_Sz(WOLFSSL_CTX* ctx, word16 keySz)
-{
-    if (ctx == NULL || keySz > 16000 || keySz % 8 != 0)
-        return BAD_FUNC_ARG;
-
-    ctx->minDhKeySz = keySz / 8;
-    return SSL_SUCCESS;
-}
-
-
-int wolfSSL_SetMinDhKey_Sz(WOLFSSL* ssl, word16 keySz)
-{
-    if (ssl == NULL || keySz > 16000 || keySz % 8 != 0)
-        return BAD_FUNC_ARG;
-
-    ssl->options.minDhKeySz = keySz / 8;
-    return SSL_SUCCESS;
-}
-
-
-int wolfSSL_GetDhKey_Sz(WOLFSSL* ssl)
-{
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    return (ssl->options.dhKeySz * 8);
-}
-
-
-#endif /* NO_DH */
-
-
-#ifdef OPENSSL_EXTRA
-/* put SSL type in extra for now, not very common */
-
-int wolfSSL_use_certificate_file(WOLFSSL* ssl, const char* file, int format)
-{
-    WOLFSSL_ENTER("wolfSSL_use_certificate_file");
-    if (ProcessFile(ssl->ctx, file, format, CERT_TYPE, ssl, 0, NULL)
-                    == SSL_SUCCESS)
-        return SSL_SUCCESS;
-
-    return SSL_FAILURE;
-}
-
-
-int wolfSSL_use_PrivateKey_file(WOLFSSL* ssl, const char* file, int format)
-{
-    WOLFSSL_ENTER("wolfSSL_use_PrivateKey_file");
-    if (ProcessFile(ssl->ctx, file, format, PRIVATEKEY_TYPE, ssl, 0, NULL)
-                                                                 == SSL_SUCCESS)
-        return SSL_SUCCESS;
-
-    return SSL_FAILURE;
-}
-
-
-int wolfSSL_use_certificate_chain_file(WOLFSSL* ssl, const char* file)
-{
-   /* procces up to MAX_CHAIN_DEPTH plus subject cert */
-   WOLFSSL_ENTER("wolfSSL_use_certificate_chain_file");
-   if (ProcessFile(ssl->ctx, file, SSL_FILETYPE_PEM, CERT_TYPE, ssl, 1, NULL)
-                                                                 == SSL_SUCCESS)
-       return SSL_SUCCESS;
-
-   return SSL_FAILURE;
-}
-
-
-
-#ifdef HAVE_ECC
-
-/* Set Temp CTX EC-DHE size in octets, should be 20 - 66 for 160 - 521 bit */
-int wolfSSL_CTX_SetTmpEC_DHE_Sz(WOLFSSL_CTX* ctx, word16 sz)
-{
-    if (ctx == NULL || sz < ECC_MINSIZE || sz > ECC_MAXSIZE)
-        return BAD_FUNC_ARG;
-
-    ctx->eccTempKeySz = sz;
-
-    return SSL_SUCCESS;
-}
-
-
-/* Set Temp SSL EC-DHE size in octets, should be 20 - 66 for 160 - 521 bit */
-int wolfSSL_SetTmpEC_DHE_Sz(WOLFSSL* ssl, word16 sz)
-{
-    if (ssl == NULL || sz < ECC_MINSIZE || sz > ECC_MAXSIZE)
-        return BAD_FUNC_ARG;
-
-    ssl->eccTempKeySz = sz;
-
-    return SSL_SUCCESS;
-}
-
-#endif /* HAVE_ECC */
-
-
-
-
-int wolfSSL_CTX_use_RSAPrivateKey_file(WOLFSSL_CTX* ctx,const char* file,
-                                   int format)
-{
-    WOLFSSL_ENTER("SSL_CTX_use_RSAPrivateKey_file");
-
-    return wolfSSL_CTX_use_PrivateKey_file(ctx, file, format);
-}
-
-
-int wolfSSL_use_RSAPrivateKey_file(WOLFSSL* ssl, const char* file, int format)
-{
-    WOLFSSL_ENTER("wolfSSL_use_RSAPrivateKey_file");
-
-    return wolfSSL_use_PrivateKey_file(ssl, file, format);
-}
-
-#endif /* OPENSSL_EXTRA */
-
-#ifdef HAVE_NTRU
-
-int wolfSSL_CTX_use_NTRUPrivateKey_file(WOLFSSL_CTX* ctx, const char* file)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_use_NTRUPrivateKey_file");
-    if (ctx == NULL)
-        return SSL_FAILURE;
-
-    if (ProcessFile(ctx, file, SSL_FILETYPE_RAW, PRIVATEKEY_TYPE, NULL, 0, NULL)
-                         == SSL_SUCCESS) {
-        ctx->haveNTRU = 1;
-        return SSL_SUCCESS;
-    }
-
-    return SSL_FAILURE;
-}
-
-#endif /* HAVE_NTRU */
-
-
-#endif /* NO_FILESYSTEM */
-
-
-void wolfSSL_CTX_set_verify(WOLFSSL_CTX* ctx, int mode, VerifyCallback vc)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_set_verify");
-    if (mode & SSL_VERIFY_PEER) {
-        ctx->verifyPeer = 1;
-        ctx->verifyNone = 0;  /* in case perviously set */
-    }
-
-    if (mode == SSL_VERIFY_NONE) {
-        ctx->verifyNone = 1;
-        ctx->verifyPeer = 0;  /* in case previously set */
-    }
-
-    if (mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)
-        ctx->failNoCert = 1;
-
-    ctx->verifyCallback = vc;
-}
-
-
-void wolfSSL_set_verify(WOLFSSL* ssl, int mode, VerifyCallback vc)
-{
-    WOLFSSL_ENTER("wolfSSL_set_verify");
-    if (mode & SSL_VERIFY_PEER) {
-        ssl->options.verifyPeer = 1;
-        ssl->options.verifyNone = 0;  /* in case perviously set */
-    }
-
-    if (mode == SSL_VERIFY_NONE) {
-        ssl->options.verifyNone = 1;
-        ssl->options.verifyPeer = 0;  /* in case previously set */
-    }
-
-    if (mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)
-        ssl->options.failNoCert = 1;
-
-    ssl->verifyCallback = vc;
-}
-
-
-/* store user ctx for verify callback */
-void wolfSSL_SetCertCbCtx(WOLFSSL* ssl, void* ctx)
-{
-    WOLFSSL_ENTER("wolfSSL_SetCertCbCtx");
-    if (ssl)
-        ssl->verifyCbCtx = ctx;
-}
-
-
-/* store context CA Cache addition callback */
-void wolfSSL_CTX_SetCACb(WOLFSSL_CTX* ctx, CallbackCACache cb)
-{
-    if (ctx && ctx->cm)
-        ctx->cm->caCacheCallback = cb;
-}
-
-
-#if defined(PERSIST_CERT_CACHE)
-
-#if !defined(NO_FILESYSTEM)
-
-/* Persist cert cache to file */
-int wolfSSL_CTX_save_cert_cache(WOLFSSL_CTX* ctx, const char* fname)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_save_cert_cache");
-
-    if (ctx == NULL || fname == NULL)
-        return BAD_FUNC_ARG;
-
-    return CM_SaveCertCache(ctx->cm, fname);
-}
-
-
-/* Persist cert cache from file */
-int wolfSSL_CTX_restore_cert_cache(WOLFSSL_CTX* ctx, const char* fname)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_restore_cert_cache");
-
-    if (ctx == NULL || fname == NULL)
-        return BAD_FUNC_ARG;
-
-    return CM_RestoreCertCache(ctx->cm, fname);
-}
-
-#endif /* NO_FILESYSTEM */
-
-/* Persist cert cache to memory */
-int wolfSSL_CTX_memsave_cert_cache(WOLFSSL_CTX* ctx, void* mem, int sz, int* used)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_memsave_cert_cache");
-
-    if (ctx == NULL || mem == NULL || used == NULL || sz <= 0)
-        return BAD_FUNC_ARG;
-
-    return CM_MemSaveCertCache(ctx->cm, mem, sz, used);
-}
-
-
-/* Restore cert cache from memory */
-int wolfSSL_CTX_memrestore_cert_cache(WOLFSSL_CTX* ctx, const void* mem, int sz)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_memrestore_cert_cache");
-
-    if (ctx == NULL || mem == NULL || sz <= 0)
-        return BAD_FUNC_ARG;
-
-    return CM_MemRestoreCertCache(ctx->cm, mem, sz);
-}
-
-
-/* get how big the the cert cache save buffer needs to be */
-int wolfSSL_CTX_get_cert_cache_memsize(WOLFSSL_CTX* ctx)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_get_cert_cache_memsize");
-
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-    return CM_GetCertCacheMemSize(ctx->cm);
-}
-
-#endif /* PERSISTE_CERT_CACHE */
-#endif /* !NO_CERTS */
-
-
-#ifndef NO_SESSION_CACHE
-
-WOLFSSL_SESSION* wolfSSL_get_session(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("SSL_get_session");
-    if (ssl)
-        return GetSession(ssl, 0);
-
-    return NULL;
-}
-
-
-int wolfSSL_set_session(WOLFSSL* ssl, WOLFSSL_SESSION* session)
-{
-    WOLFSSL_ENTER("SSL_set_session");
-    if (session)
-        return SetSession(ssl, session);
-
-    return SSL_FAILURE;
-}
-
-
-#ifndef NO_CLIENT_CACHE
-
-/* Associate client session with serverID, find existing or store for saving
-   if newSession flag on, don't reuse existing session
-   SSL_SUCCESS on ok */
-int wolfSSL_SetServerID(WOLFSSL* ssl, const byte* id, int len, int newSession)
-{
-    WOLFSSL_SESSION* session = NULL;
-
-    WOLFSSL_ENTER("wolfSSL_SetServerID");
-
-    if (ssl == NULL || id == NULL || len <= 0)
-        return BAD_FUNC_ARG;
-
-    if (newSession == 0) {
-        session = GetSessionClient(ssl, id, len);
-        if (session) {
-            if (SetSession(ssl, session) != SSL_SUCCESS) {
-                WOLFSSL_MSG("SetSession failed");
-                session = NULL;
-            }
-        }
-    }
-
-    if (session == NULL) {
-        WOLFSSL_MSG("Valid ServerID not cached already");
-
-        ssl->session.idLen = (word16)min(SERVER_ID_LEN, (word32)len);
-        XMEMCPY(ssl->session.serverID, id, ssl->session.idLen);
-    }
-
-    return SSL_SUCCESS;
-}
-
-#endif /* NO_CLIENT_CACHE */
-
-#if defined(PERSIST_SESSION_CACHE)
-
-/* for persistance, if changes to layout need to increment and modify
-   save_session_cache() and restore_session_cache and memory versions too */
-#define WOLFSSL_CACHE_VERSION 2
-
-/* Session Cache Header information */
-typedef struct {
-    int version;     /* cache layout version id */
-    int rows;        /* session rows */
-    int columns;     /* session columns */
-    int sessionSz;   /* sizeof WOLFSSL_SESSION */
-} cache_header_t;
-
-/* current persistence layout is:
-
-   1) cache_header_t
-   2) SessionCache
-   3) ClientCache
-
-   update WOLFSSL_CACHE_VERSION if change layout for the following
-   PERSISTENT_SESSION_CACHE functions
-*/
-
-
-/* get how big the the session cache save buffer needs to be */
-int wolfSSL_get_session_cache_memsize(void)
-{
-    int sz  = (int)(sizeof(SessionCache) + sizeof(cache_header_t));
-
-    #ifndef NO_CLIENT_CACHE
-        sz += (int)(sizeof(ClientCache));
-    #endif
-
-    return sz;
-}
-
-
-/* Persist session cache to memory */
-int wolfSSL_memsave_session_cache(void* mem, int sz)
-{
-    int i;
-    cache_header_t cache_header;
-    SessionRow*    row  = (SessionRow*)((byte*)mem + sizeof(cache_header));
-#ifndef NO_CLIENT_CACHE
-    ClientRow*     clRow;
-#endif
-
-    WOLFSSL_ENTER("wolfSSL_memsave_session_cache");
-
-    if (sz < wolfSSL_get_session_cache_memsize()) {
-        WOLFSSL_MSG("Memory buffer too small");
-        return BUFFER_E;
-    }
-
-    cache_header.version   = WOLFSSL_CACHE_VERSION;
-    cache_header.rows      = SESSION_ROWS;
-    cache_header.columns   = SESSIONS_PER_ROW;
-    cache_header.sessionSz = (int)sizeof(WOLFSSL_SESSION);
-    XMEMCPY(mem, &cache_header, sizeof(cache_header));
-
-    if (LockMutex(&session_mutex) != 0) {
-        WOLFSSL_MSG("Session cache mutex lock failed");
-        return BAD_MUTEX_E;
-    }
-
-    for (i = 0; i < cache_header.rows; ++i)
-        XMEMCPY(row++, SessionCache + i, sizeof(SessionRow));
-
-#ifndef NO_CLIENT_CACHE
-    clRow = (ClientRow*)row;
-    for (i = 0; i < cache_header.rows; ++i)
-        XMEMCPY(clRow++, ClientCache + i, sizeof(ClientRow));
-#endif
-
-    UnLockMutex(&session_mutex);
-
-    WOLFSSL_LEAVE("wolfSSL_memsave_session_cache", SSL_SUCCESS);
-
-    return SSL_SUCCESS;
-}
-
-
-/* Restore the persistant session cache from memory */
-int wolfSSL_memrestore_session_cache(const void* mem, int sz)
-{
-    int    i;
-    cache_header_t cache_header;
-    SessionRow*    row  = (SessionRow*)((byte*)mem + sizeof(cache_header));
-#ifndef NO_CLIENT_CACHE
-    ClientRow*     clRow;
-#endif
-
-    WOLFSSL_ENTER("wolfSSL_memrestore_session_cache");
-
-    if (sz < wolfSSL_get_session_cache_memsize()) {
-        WOLFSSL_MSG("Memory buffer too small");
-        return BUFFER_E;
-    }
-
-    XMEMCPY(&cache_header, mem, sizeof(cache_header));
-    if (cache_header.version   != WOLFSSL_CACHE_VERSION ||
-        cache_header.rows      != SESSION_ROWS ||
-        cache_header.columns   != SESSIONS_PER_ROW ||
-        cache_header.sessionSz != (int)sizeof(WOLFSSL_SESSION)) {
-
-        WOLFSSL_MSG("Session cache header match failed");
-        return CACHE_MATCH_ERROR;
-    }
-
-    if (LockMutex(&session_mutex) != 0) {
-        WOLFSSL_MSG("Session cache mutex lock failed");
-        return BAD_MUTEX_E;
-    }
-
-    for (i = 0; i < cache_header.rows; ++i)
-        XMEMCPY(SessionCache + i, row++, sizeof(SessionRow));
-
-#ifndef NO_CLIENT_CACHE
-    clRow = (ClientRow*)row;
-    for (i = 0; i < cache_header.rows; ++i)
-        XMEMCPY(ClientCache + i, clRow++, sizeof(ClientRow));
-#endif
-
-    UnLockMutex(&session_mutex);
-
-    WOLFSSL_LEAVE("wolfSSL_memrestore_session_cache", SSL_SUCCESS);
-
-    return SSL_SUCCESS;
-}
-
-#if !defined(NO_FILESYSTEM)
-
-/* Persist session cache to file */
-/* doesn't use memsave because of additional memory use */
-int wolfSSL_save_session_cache(const char *fname)
-{
-    XFILE  file;
-    int    ret;
-    int    rc = SSL_SUCCESS;
-    int    i;
-    cache_header_t cache_header;
-
-    WOLFSSL_ENTER("wolfSSL_save_session_cache");
-
-    file = XFOPEN(fname, "w+b");
-    if (file == XBADFILE) {
-        WOLFSSL_MSG("Couldn't open session cache save file");
-        return SSL_BAD_FILE;
-    }
-    cache_header.version   = WOLFSSL_CACHE_VERSION;
-    cache_header.rows      = SESSION_ROWS;
-    cache_header.columns   = SESSIONS_PER_ROW;
-    cache_header.sessionSz = (int)sizeof(WOLFSSL_SESSION);
-
-    /* cache header */
-    ret = (int)XFWRITE(&cache_header, sizeof cache_header, 1, file);
-    if (ret != 1) {
-        WOLFSSL_MSG("Session cache header file write failed");
-        XFCLOSE(file);
-        return FWRITE_ERROR;
-    }
-
-    if (LockMutex(&session_mutex) != 0) {
-        WOLFSSL_MSG("Session cache mutex lock failed");
-        XFCLOSE(file);
-        return BAD_MUTEX_E;
-    }
-
-    /* session cache */
-    for (i = 0; i < cache_header.rows; ++i) {
-        ret = (int)XFWRITE(SessionCache + i, sizeof(SessionRow), 1, file);
-        if (ret != 1) {
-            WOLFSSL_MSG("Session cache member file write failed");
-            rc = FWRITE_ERROR;
-            break;
-        }
-    }
-
-#ifndef NO_CLIENT_CACHE
-    /* client cache */
-    for (i = 0; i < cache_header.rows; ++i) {
-        ret = (int)XFWRITE(ClientCache + i, sizeof(ClientRow), 1, file);
-        if (ret != 1) {
-            WOLFSSL_MSG("Client cache member file write failed");
-            rc = FWRITE_ERROR;
-            break;
-        }
-    }
-#endif /* NO_CLIENT_CACHE */
-
-    UnLockMutex(&session_mutex);
-
-    XFCLOSE(file);
-    WOLFSSL_LEAVE("wolfSSL_save_session_cache", rc);
-
-    return rc;
-}
-
-
-/* Restore the persistant session cache from file */
-/* doesn't use memstore because of additional memory use */
-int wolfSSL_restore_session_cache(const char *fname)
-{
-    XFILE  file;
-    int    rc = SSL_SUCCESS;
-    int    ret;
-    int    i;
-    cache_header_t cache_header;
-
-    WOLFSSL_ENTER("wolfSSL_restore_session_cache");
-
-    file = XFOPEN(fname, "rb");
-    if (file == XBADFILE) {
-        WOLFSSL_MSG("Couldn't open session cache save file");
-        return SSL_BAD_FILE;
-    }
-    /* cache header */
-    ret = (int)XFREAD(&cache_header, sizeof cache_header, 1, file);
-    if (ret != 1) {
-        WOLFSSL_MSG("Session cache header file read failed");
-        XFCLOSE(file);
-        return FREAD_ERROR;
-    }
-    if (cache_header.version   != WOLFSSL_CACHE_VERSION ||
-        cache_header.rows      != SESSION_ROWS ||
-        cache_header.columns   != SESSIONS_PER_ROW ||
-        cache_header.sessionSz != (int)sizeof(WOLFSSL_SESSION)) {
-
-        WOLFSSL_MSG("Session cache header match failed");
-        XFCLOSE(file);
-        return CACHE_MATCH_ERROR;
-    }
-
-    if (LockMutex(&session_mutex) != 0) {
-        WOLFSSL_MSG("Session cache mutex lock failed");
-        XFCLOSE(file);
-        return BAD_MUTEX_E;
-    }
-
-    /* session cache */
-    for (i = 0; i < cache_header.rows; ++i) {
-        ret = (int)XFREAD(SessionCache + i, sizeof(SessionRow), 1, file);
-        if (ret != 1) {
-            WOLFSSL_MSG("Session cache member file read failed");
-            XMEMSET(SessionCache, 0, sizeof SessionCache);
-            rc = FREAD_ERROR;
-            break;
-        }
-    }
-
-#ifndef NO_CLIENT_CACHE
-    /* client cache */
-    for (i = 0; i < cache_header.rows; ++i) {
-        ret = (int)XFREAD(ClientCache + i, sizeof(ClientRow), 1, file);
-        if (ret != 1) {
-            WOLFSSL_MSG("Client cache member file read failed");
-            XMEMSET(ClientCache, 0, sizeof ClientCache);
-            rc = FREAD_ERROR;
-            break;
-        }
-    }
-
-#endif /* NO_CLIENT_CACHE */
-
-    UnLockMutex(&session_mutex);
-
-    XFCLOSE(file);
-    WOLFSSL_LEAVE("wolfSSL_restore_session_cache", rc);
-
-    return rc;
-}
-
-#endif /* !NO_FILESYSTEM */
-#endif /* PERSIST_SESSION_CACHE */
-#endif /* NO_SESSION_CACHE */
-
-
-void wolfSSL_load_error_strings(void)   /* compatibility only */
-{}
-
-
-int wolfSSL_library_init(void)
-{
-    WOLFSSL_ENTER("SSL_library_init");
-    if (wolfSSL_Init() == SSL_SUCCESS)
-        return SSL_SUCCESS;
-    else
-        return SSL_FATAL_ERROR;
-}
-
-
-#ifdef HAVE_SECRET_CALLBACK
-
-int wolfSSL_set_session_secret_cb(WOLFSSL* ssl, SessionSecretCb cb, void* ctx)
-{
-    WOLFSSL_ENTER("wolfSSL_set_session_secret_cb");
-    if (ssl == NULL)
-        return SSL_FATAL_ERROR;
-
-    ssl->sessionSecretCb = cb;
-    ssl->sessionSecretCtx = ctx;
-    /* If using a pre-set key, assume session resumption. */
-    ssl->session.sessionIDSz = 0;
-    ssl->options.resuming = 1;
-
-    return SSL_SUCCESS;
-}
-
-#endif
-
-
-#ifndef NO_SESSION_CACHE
-
-/* on by default if built in but allow user to turn off */
-long wolfSSL_CTX_set_session_cache_mode(WOLFSSL_CTX* ctx, long mode)
-{
-    WOLFSSL_ENTER("SSL_CTX_set_session_cache_mode");
-    if (mode == SSL_SESS_CACHE_OFF)
-        ctx->sessionCacheOff = 1;
-
-    if (mode == SSL_SESS_CACHE_NO_AUTO_CLEAR)
-        ctx->sessionCacheFlushOff = 1;
-
-    return SSL_SUCCESS;
-}
-
-#endif /* NO_SESSION_CACHE */
-
-
-#if !defined(NO_CERTS)
-#if defined(PERSIST_CERT_CACHE)
-
-
-#define WOLFSSL_CACHE_CERT_VERSION 1
-
-typedef struct {
-    int version;                 /* cache cert layout version id */
-    int rows;                    /* hash table rows, CA_TABLE_SIZE */
-    int columns[CA_TABLE_SIZE];  /* columns per row on list */
-    int signerSz;                /* sizeof Signer object */
-} CertCacheHeader;
-
-/* current cert persistance layout is:
-
-   1) CertCacheHeader
-   2) caTable
-
-   update WOLFSSL_CERT_CACHE_VERSION if change layout for the following
-   PERSIST_CERT_CACHE functions
-*/
-
-
-/* Return memory needed to persist this signer, have lock */
-static INLINE int GetSignerMemory(Signer* signer)
-{
-    int sz = sizeof(signer->pubKeySize) + sizeof(signer->keyOID)
-           + sizeof(signer->nameLen)    + sizeof(signer->subjectNameHash);
-
-#if !defined(NO_SKID)
-        sz += (int)sizeof(signer->subjectKeyIdHash);
-#endif
-
-    /* add dynamic bytes needed */
-    sz += signer->pubKeySize;
-    sz += signer->nameLen;
-
-    return sz;
-}
-
-
-/* Return memory needed to persist this row, have lock */
-static INLINE int GetCertCacheRowMemory(Signer* row)
-{
-    int sz = 0;
-
-    while (row) {
-        sz += GetSignerMemory(row);
-        row = row->next;
-    }
-
-    return sz;
-}
-
-
-/* get the size of persist cert cache, have lock */
-static INLINE int GetCertCacheMemSize(WOLFSSL_CERT_MANAGER* cm)
-{
-    int sz;
-    int i;
-
-    sz = sizeof(CertCacheHeader);
-
-    for (i = 0; i < CA_TABLE_SIZE; i++)
-        sz += GetCertCacheRowMemory(cm->caTable[i]);
-
-    return sz;
-}
-
-
-/* Store cert cache header columns with number of items per list, have lock */
-static INLINE void SetCertHeaderColumns(WOLFSSL_CERT_MANAGER* cm, int* columns)
-{
-    int     i;
-    Signer* row;
-
-    for (i = 0; i < CA_TABLE_SIZE; i++) {
-        int count = 0;
-        row = cm->caTable[i];
-
-        while (row) {
-            ++count;
-            row = row->next;
-        }
-        columns[i] = count;
-    }
-}
-
-
-/* Restore whole cert row from memory, have lock, return bytes consumed,
-   < 0 on error, have lock */
-static INLINE int RestoreCertRow(WOLFSSL_CERT_MANAGER* cm, byte* current,
-                                 int row, int listSz, const byte* end)
-{
-    int idx = 0;
-
-    if (listSz < 0) {
-        WOLFSSL_MSG("Row header corrupted, negative value");
-        return PARSE_ERROR;
-    }
-
-    while (listSz) {
-        Signer* signer;
-        byte*   start = current + idx;  /* for end checks on this signer */
-        int     minSz = sizeof(signer->pubKeySize) + sizeof(signer->keyOID) +
-                      sizeof(signer->nameLen) + sizeof(signer->subjectNameHash);
-        #ifndef NO_SKID
-                minSz += (int)sizeof(signer->subjectKeyIdHash);
-        #endif
-
-        if (start + minSz > end) {
-            WOLFSSL_MSG("Would overread restore buffer");
-            return BUFFER_E;
-        }
-        signer = MakeSigner(cm->heap);
-        if (signer == NULL)
-            return MEMORY_E;
-
-        /* pubKeySize */
-        XMEMCPY(&signer->pubKeySize, current + idx, sizeof(signer->pubKeySize));
-        idx += (int)sizeof(signer->pubKeySize);
-
-        /* keyOID */
-        XMEMCPY(&signer->keyOID, current + idx, sizeof(signer->keyOID));
-        idx += (int)sizeof(signer->keyOID);
-
-        /* pulicKey */
-        if (start + minSz + signer->pubKeySize > end) {
-            WOLFSSL_MSG("Would overread restore buffer");
-            FreeSigner(signer, cm->heap);
-            return BUFFER_E;
-        }
-        signer->publicKey = (byte*)XMALLOC(signer->pubKeySize, cm->heap,
-                                           DYNAMIC_TYPE_KEY);
-        if (signer->publicKey == NULL) {
-            FreeSigner(signer, cm->heap);
-            return MEMORY_E;
-        }
-
-        XMEMCPY(signer->publicKey, current + idx, signer->pubKeySize);
-        idx += signer->pubKeySize;
-
-        /* nameLen */
-        XMEMCPY(&signer->nameLen, current + idx, sizeof(signer->nameLen));
-        idx += (int)sizeof(signer->nameLen);
-
-        /* name */
-        if (start + minSz + signer->pubKeySize + signer->nameLen > end) {
-            WOLFSSL_MSG("Would overread restore buffer");
-            FreeSigner(signer, cm->heap);
-            return BUFFER_E;
-        }
-        signer->name = (char*)XMALLOC(signer->nameLen, cm->heap,
-                                      DYNAMIC_TYPE_SUBJECT_CN);
-        if (signer->name == NULL) {
-            FreeSigner(signer, cm->heap);
-            return MEMORY_E;
-        }
-
-        XMEMCPY(signer->name, current + idx, signer->nameLen);
-        idx += signer->nameLen;
-
-        /* subjectNameHash */
-        XMEMCPY(signer->subjectNameHash, current + idx, SIGNER_DIGEST_SIZE);
-        idx += SIGNER_DIGEST_SIZE;
-
-        #ifndef NO_SKID
-            /* subjectKeyIdHash */
-            XMEMCPY(signer->subjectKeyIdHash, current + idx,SIGNER_DIGEST_SIZE);
-            idx += SIGNER_DIGEST_SIZE;
-        #endif
-
-        signer->next = cm->caTable[row];
-        cm->caTable[row] = signer;
-
-        --listSz;
-    }
-
-    return idx;
-}
-
-
-/* Store whole cert row into memory, have lock, return bytes added */
-static INLINE int StoreCertRow(WOLFSSL_CERT_MANAGER* cm, byte* current, int row)
-{
-    int     added  = 0;
-    Signer* list   = cm->caTable[row];
-
-    while (list) {
-        XMEMCPY(current + added, &list->pubKeySize, sizeof(list->pubKeySize));
-        added += (int)sizeof(list->pubKeySize);
-
-        XMEMCPY(current + added, &list->keyOID,     sizeof(list->keyOID));
-        added += (int)sizeof(list->keyOID);
-
-        XMEMCPY(current + added, list->publicKey, list->pubKeySize);
-        added += list->pubKeySize;
-
-        XMEMCPY(current + added, &list->nameLen, sizeof(list->nameLen));
-        added += (int)sizeof(list->nameLen);
-
-        XMEMCPY(current + added, list->name, list->nameLen);
-        added += list->nameLen;
-
-        XMEMCPY(current + added, list->subjectNameHash, SIGNER_DIGEST_SIZE);
-        added += SIGNER_DIGEST_SIZE;
-
-        #ifndef NO_SKID
-            XMEMCPY(current + added, list->subjectKeyIdHash,SIGNER_DIGEST_SIZE);
-            added += SIGNER_DIGEST_SIZE;
-        #endif
-
-        list = list->next;
-    }
-
-    return added;
-}
-
-
-/* Persist cert cache to memory, have lock */
-static INLINE int DoMemSaveCertCache(WOLFSSL_CERT_MANAGER* cm, void* mem, int sz)
-{
-    int realSz;
-    int ret = SSL_SUCCESS;
-    int i;
-
-    WOLFSSL_ENTER("DoMemSaveCertCache");
-
-    realSz = GetCertCacheMemSize(cm);
-    if (realSz > sz) {
-        WOLFSSL_MSG("Mem output buffer too small");
-        ret = BUFFER_E;
-    }
-    else {
-        byte*           current;
-        CertCacheHeader hdr;
-
-        hdr.version  = WOLFSSL_CACHE_CERT_VERSION;
-        hdr.rows     = CA_TABLE_SIZE;
-        SetCertHeaderColumns(cm, hdr.columns);
-        hdr.signerSz = (int)sizeof(Signer);
-
-        XMEMCPY(mem, &hdr, sizeof(CertCacheHeader));
-        current = (byte*)mem + sizeof(CertCacheHeader);
-
-        for (i = 0; i < CA_TABLE_SIZE; ++i)
-            current += StoreCertRow(cm, current, i);
-    }
-
-    return ret;
-}
-
-
-#if !defined(NO_FILESYSTEM)
-
-/* Persist cert cache to file */
-int CM_SaveCertCache(WOLFSSL_CERT_MANAGER* cm, const char* fname)
-{
-    XFILE file;
-    int   rc = SSL_SUCCESS;
-    int   memSz;
-    byte* mem;
-
-    WOLFSSL_ENTER("CM_SaveCertCache");
-
-    file = XFOPEN(fname, "w+b");
-    if (file == XBADFILE) {
-       WOLFSSL_MSG("Couldn't open cert cache save file");
-       return SSL_BAD_FILE;
-    }
-
-    if (LockMutex(&cm->caLock) != 0) {
-        WOLFSSL_MSG("LockMutex on caLock failed");
-        XFCLOSE(file);
-        return BAD_MUTEX_E;
-    }
-
-    memSz = GetCertCacheMemSize(cm);
-    mem   = (byte*)XMALLOC(memSz, cm->heap, DYNAMIC_TYPE_TMP_BUFFER);
-    if (mem == NULL) {
-        WOLFSSL_MSG("Alloc for tmp buffer failed");
-        rc = MEMORY_E;
-    } else {
-        rc = DoMemSaveCertCache(cm, mem, memSz);
-        if (rc == SSL_SUCCESS) {
-            int ret = (int)XFWRITE(mem, memSz, 1, file);
-            if (ret != 1) {
-                WOLFSSL_MSG("Cert cache file write failed");
-                rc = FWRITE_ERROR;
-            }
-        }
-        XFREE(mem, cm->heap, DYNAMIC_TYPE_TMP_BUFFER);
-    }
-
-    UnLockMutex(&cm->caLock);
-    XFCLOSE(file);
-
-    return rc;
-}
-
-
-/* Restore cert cache from file */
-int CM_RestoreCertCache(WOLFSSL_CERT_MANAGER* cm, const char* fname)
-{
-    XFILE file;
-    int   rc = SSL_SUCCESS;
-    int   ret;
-    int   memSz;
-    byte* mem;
-
-    WOLFSSL_ENTER("CM_RestoreCertCache");
-
-    file = XFOPEN(fname, "rb");
-    if (file == XBADFILE) {
-       WOLFSSL_MSG("Couldn't open cert cache save file");
-       return SSL_BAD_FILE;
-    }
-
-    XFSEEK(file, 0, XSEEK_END);
-    memSz = (int)XFTELL(file);
-    XREWIND(file);
-
-    if (memSz <= 0) {
-        WOLFSSL_MSG("Bad file size");
-        XFCLOSE(file);
-        return SSL_BAD_FILE;
-    }
-
-    mem = (byte*)XMALLOC(memSz, cm->heap, DYNAMIC_TYPE_TMP_BUFFER);
-    if (mem == NULL) {
-        WOLFSSL_MSG("Alloc for tmp buffer failed");
-        XFCLOSE(file);
-        return MEMORY_E;
-    }
-
-    ret = (int)XFREAD(mem, memSz, 1, file);
-    if (ret != 1) {
-        WOLFSSL_MSG("Cert file read error");
-        rc = FREAD_ERROR;
-    } else {
-        rc = CM_MemRestoreCertCache(cm, mem, memSz);
-        if (rc != SSL_SUCCESS) {
-            WOLFSSL_MSG("Mem restore cert cache failed");
-        }
-    }
-
-    XFREE(mem, cm->heap, DYNAMIC_TYPE_TMP_BUFFER);
-    XFCLOSE(file);
-
-    return rc;
-}
-
-#endif /* NO_FILESYSTEM */
-
-
-/* Persist cert cache to memory */
-int CM_MemSaveCertCache(WOLFSSL_CERT_MANAGER* cm, void* mem, int sz, int* used)
-{
-    int ret = SSL_SUCCESS;
-
-    WOLFSSL_ENTER("CM_MemSaveCertCache");
-
-    if (LockMutex(&cm->caLock) != 0) {
-        WOLFSSL_MSG("LockMutex on caLock failed");
-        return BAD_MUTEX_E;
-    }
-
-    ret = DoMemSaveCertCache(cm, mem, sz);
-    if (ret == SSL_SUCCESS)
-        *used  = GetCertCacheMemSize(cm);
-
-    UnLockMutex(&cm->caLock);
-
-    return ret;
-}
-
-
-/* Restore cert cache from memory */
-int CM_MemRestoreCertCache(WOLFSSL_CERT_MANAGER* cm, const void* mem, int sz)
-{
-    int ret = SSL_SUCCESS;
-    int i;
-    CertCacheHeader* hdr = (CertCacheHeader*)mem;
-    byte*            current = (byte*)mem + sizeof(CertCacheHeader);
-    byte*            end     = (byte*)mem + sz;  /* don't go over */
-
-    WOLFSSL_ENTER("CM_MemRestoreCertCache");
-
-    if (current > end) {
-        WOLFSSL_MSG("Cert Cache Memory buffer too small");
-        return BUFFER_E;
-    }
-
-    if (hdr->version  != WOLFSSL_CACHE_CERT_VERSION ||
-        hdr->rows     != CA_TABLE_SIZE ||
-        hdr->signerSz != (int)sizeof(Signer)) {
-
-        WOLFSSL_MSG("Cert Cache Memory header mismatch");
-        return CACHE_MATCH_ERROR;
-    }
-
-    if (LockMutex(&cm->caLock) != 0) {
-        WOLFSSL_MSG("LockMutex on caLock failed");
-        return BAD_MUTEX_E;
-    }
-
-    FreeSignerTable(cm->caTable, CA_TABLE_SIZE, cm->heap);
-
-    for (i = 0; i < CA_TABLE_SIZE; ++i) {
-        int added = RestoreCertRow(cm, current, i, hdr->columns[i], end);
-        if (added < 0) {
-            WOLFSSL_MSG("RestoreCertRow error");
-            ret = added;
-            break;
-        }
-        current += added;
-    }
-
-    UnLockMutex(&cm->caLock);
-
-    return ret;
-}
-
-
-/* get how big the the cert cache save buffer needs to be */
-int CM_GetCertCacheMemSize(WOLFSSL_CERT_MANAGER* cm)
-{
-    int sz;
-
-    WOLFSSL_ENTER("CM_GetCertCacheMemSize");
-
-    if (LockMutex(&cm->caLock) != 0) {
-        WOLFSSL_MSG("LockMutex on caLock failed");
-        return BAD_MUTEX_E;
-    }
-
-    sz = GetCertCacheMemSize(cm);
-
-    UnLockMutex(&cm->caLock);
-
-    return sz;
-}
-
-#endif /* PERSIST_CERT_CACHE */
-#endif /* NO_CERTS */
-
-
-int wolfSSL_CTX_set_cipher_list(WOLFSSL_CTX* ctx, const char* list)
-{
-    WOLFSSL_ENTER("wolfSSL_CTX_set_cipher_list");
-
-    /* alloc/init on demand only */
-    if (ctx->suites == NULL) {
-        ctx->suites = (Suites*)XMALLOC(sizeof(Suites), ctx->heap,
-                                       DYNAMIC_TYPE_SUITES);
-        if (ctx->suites == NULL) {
-            WOLFSSL_MSG("Memory alloc for Suites failed");
-            return SSL_FAILURE;
-        }
-        XMEMSET(ctx->suites, 0, sizeof(Suites));
-    }
-
-    return (SetCipherList(ctx->suites, list)) ? SSL_SUCCESS : SSL_FAILURE;
-}
-
-
-int wolfSSL_set_cipher_list(WOLFSSL* ssl, const char* list)
-{
-    WOLFSSL_ENTER("wolfSSL_set_cipher_list");
-    return (SetCipherList(ssl->suites, list)) ? SSL_SUCCESS : SSL_FAILURE;
-}
-
-
-#ifndef WOLFSSL_LEANPSK
-#ifdef WOLFSSL_DTLS
-
-int wolfSSL_dtls_get_current_timeout(WOLFSSL* ssl)
-{
-    (void)ssl;
-
-    return ssl->dtls_timeout;
-}
-
-
-/* user may need to alter init dtls recv timeout, SSL_SUCCESS on ok */
-int wolfSSL_dtls_set_timeout_init(WOLFSSL* ssl, int timeout)
-{
-    if (ssl == NULL || timeout < 0)
-        return BAD_FUNC_ARG;
-
-    if (timeout > ssl->dtls_timeout_max) {
-        WOLFSSL_MSG("Can't set dtls timeout init greater than dtls timeout max");
-        return BAD_FUNC_ARG;
-    }
-
-    ssl->dtls_timeout_init = timeout;
-    ssl->dtls_timeout = timeout;
-
-    return SSL_SUCCESS;
-}
-
-
-/* user may need to alter max dtls recv timeout, SSL_SUCCESS on ok */
-int wolfSSL_dtls_set_timeout_max(WOLFSSL* ssl, int timeout)
-{
-    if (ssl == NULL || timeout < 0)
-        return BAD_FUNC_ARG;
-
-    if (timeout < ssl->dtls_timeout_init) {
-        WOLFSSL_MSG("Can't set dtls timeout max less than dtls timeout init");
-        return BAD_FUNC_ARG;
-    }
-
-    ssl->dtls_timeout_max = timeout;
-
-    return SSL_SUCCESS;
-}
-
-
-int wolfSSL_dtls_got_timeout(WOLFSSL* ssl)
-{
-    int result = SSL_SUCCESS;
-
-    DtlsMsgListDelete(ssl->dtls_msg_list, ssl->heap);
-    ssl->dtls_msg_list = NULL;
-    if (DtlsPoolTimeout(ssl) < 0 || DtlsPoolSend(ssl) < 0) {
-        result = SSL_FATAL_ERROR;
-    }
-    return result;
-}
-
-#endif /* DTLS */
-#endif /* LEANPSK */
-
-
-/* client only parts */
-#ifndef NO_WOLFSSL_CLIENT
-
-    #ifndef NO_OLD_TLS
-    WOLFSSL_METHOD* wolfSSLv3_client_method(void)
-    {
-        WOLFSSL_METHOD* method =
-                              (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
-                                                       DYNAMIC_TYPE_METHOD);
-        WOLFSSL_ENTER("SSLv3_client_method");
-        if (method)
-            InitSSL_Method(method, MakeSSLv3());
-        return method;
-    }
-    #endif
-
-    #ifdef WOLFSSL_DTLS
-
-        #ifndef NO_OLD_TLS
-        WOLFSSL_METHOD* wolfDTLSv1_client_method(void)
-        {
-            WOLFSSL_METHOD* method =
-                              (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
-                                                       DYNAMIC_TYPE_METHOD);
-            WOLFSSL_ENTER("DTLSv1_client_method");
-            if (method)
-                InitSSL_Method(method, MakeDTLSv1());
-            return method;
-        }
-        #endif  /* NO_OLD_TLS */
-
-        WOLFSSL_METHOD* wolfDTLSv1_2_client_method(void)
-        {
-            WOLFSSL_METHOD* method =
-                              (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
-                                                       DYNAMIC_TYPE_METHOD);
-            WOLFSSL_ENTER("DTLSv1_2_client_method");
-            if (method)
-                InitSSL_Method(method, MakeDTLSv1_2());
-            return method;
-        }
-    #endif
-
-
-    /* please see note at top of README if you get an error from connect */
-    int wolfSSL_connect(WOLFSSL* ssl)
-    {
-        int neededState;
-
-        WOLFSSL_ENTER("SSL_connect()");
-
-        #ifdef HAVE_ERRNO_H
-            errno = 0;
-        #endif
-
-        if (ssl->options.side != WOLFSSL_CLIENT_END) {
-            WOLFSSL_ERROR(ssl->error = SIDE_ERROR);
-            return SSL_FATAL_ERROR;
-        }
-
-        #ifdef WOLFSSL_DTLS
-            if (ssl->version.major == DTLS_MAJOR) {
-                ssl->options.dtls   = 1;
-                ssl->options.tls    = 1;
-                ssl->options.tls1_1 = 1;
-
-                if (DtlsPoolInit(ssl) != 0) {
-                    ssl->error = MEMORY_ERROR;
-                    WOLFSSL_ERROR(ssl->error);
-                    return SSL_FATAL_ERROR;
-                }
-            }
-        #endif
-
-        if (ssl->buffers.outputBuffer.length > 0) {
-            if ( (ssl->error = SendBuffered(ssl)) == 0) {
-                ssl->options.connectState++;
-                WOLFSSL_MSG("connect state: Advanced from buffered send");
-            }
-            else {
-                WOLFSSL_ERROR(ssl->error);
-                return SSL_FATAL_ERROR;
-            }
-        }
-
-        switch (ssl->options.connectState) {
-
-        case CONNECT_BEGIN :
-            /* always send client hello first */
-            if ( (ssl->error = SendClientHello(ssl)) != 0) {
-                WOLFSSL_ERROR(ssl->error);
-                return SSL_FATAL_ERROR;
-            }
-            ssl->options.connectState = CLIENT_HELLO_SENT;
-            WOLFSSL_MSG("connect state: CLIENT_HELLO_SENT");
-
-        case CLIENT_HELLO_SENT :
-            neededState = ssl->options.resuming ? SERVER_FINISHED_COMPLETE :
-                                          SERVER_HELLODONE_COMPLETE;
-            #ifdef WOLFSSL_DTLS
-                /* In DTLS, when resuming, we can go straight to FINISHED,
-                 * or do a cookie exchange and then skip to FINISHED, assume
-                 * we need the cookie exchange first. */
-                if (ssl->options.dtls)
-                    neededState = SERVER_HELLOVERIFYREQUEST_COMPLETE;
-            #endif
-            /* get response */
-            while (ssl->options.serverState < neededState) {
-                if ( (ssl->error = ProcessReply(ssl)) < 0) {
-                    WOLFSSL_ERROR(ssl->error);
-                    return SSL_FATAL_ERROR;
-                }
-                /* if resumption failed, reset needed state */
-                else if (neededState == SERVER_FINISHED_COMPLETE)
-                    if (!ssl->options.resuming) {
-                        if (!ssl->options.dtls)
-                            neededState = SERVER_HELLODONE_COMPLETE;
-                        else
-                            neededState = SERVER_HELLOVERIFYREQUEST_COMPLETE;
-                    }
-            }
-
-            ssl->options.connectState = HELLO_AGAIN;
-            WOLFSSL_MSG("connect state: HELLO_AGAIN");
-
-        case HELLO_AGAIN :
-            if (ssl->options.certOnly)
-                return SSL_SUCCESS;
-
-            #ifdef WOLFSSL_DTLS
-                if (ssl->options.dtls) {
-                    /* re-init hashes, exclude first hello and verify request */
-#ifndef NO_OLD_TLS
-                    wc_InitMd5(&ssl->hsHashes->hashMd5);
-                    if ( (ssl->error = wc_InitSha(&ssl->hsHashes->hashSha))
-                                                                         != 0) {
-                        WOLFSSL_ERROR(ssl->error);
-                        return SSL_FATAL_ERROR;
-                    }
-#endif
-                    if (IsAtLeastTLSv1_2(ssl)) {
-                        #ifndef NO_SHA256
-                            if ( (ssl->error = wc_InitSha256(
-                                            &ssl->hsHashes->hashSha256)) != 0) {
-                                WOLFSSL_ERROR(ssl->error);
-                                return SSL_FATAL_ERROR;
-                            }
-                        #endif
-                        #ifdef WOLFSSL_SHA384
-                            if ( (ssl->error = wc_InitSha384(
-                                            &ssl->hsHashes->hashSha384)) != 0) {
-                                WOLFSSL_ERROR(ssl->error);
-                                return SSL_FATAL_ERROR;
-                            }
-                        #endif
-                        #ifdef WOLFSSL_SHA512
-                            if ( (ssl->error = wc_InitSha512(
-                                            &ssl->hsHashes->hashSha512)) != 0) {
-                                WOLFSSL_ERROR(ssl->error);
-                                return SSL_FATAL_ERROR;
-                            }
-                        #endif
-                    }
-                    if ( (ssl->error = SendClientHello(ssl)) != 0) {
-                        WOLFSSL_ERROR(ssl->error);
-                        return SSL_FATAL_ERROR;
-                    }
-                }
-            #endif
-
-            ssl->options.connectState = HELLO_AGAIN_REPLY;
-            WOLFSSL_MSG("connect state: HELLO_AGAIN_REPLY");
-
-        case HELLO_AGAIN_REPLY :
-            #ifdef WOLFSSL_DTLS
-                if (ssl->options.dtls) {
-                    neededState = ssl->options.resuming ?
-                           SERVER_FINISHED_COMPLETE : SERVER_HELLODONE_COMPLETE;
-
-                    /* get response */
-                    while (ssl->options.serverState < neededState) {
-                        if ( (ssl->error = ProcessReply(ssl)) < 0) {
-                                WOLFSSL_ERROR(ssl->error);
-                                return SSL_FATAL_ERROR;
-                        }
-                        /* if resumption failed, reset needed state */
-                        else if (neededState == SERVER_FINISHED_COMPLETE)
-                            if (!ssl->options.resuming)
-                                neededState = SERVER_HELLODONE_COMPLETE;
-                    }
-                }
-            #endif
-
-            ssl->options.connectState = FIRST_REPLY_DONE;
-            WOLFSSL_MSG("connect state: FIRST_REPLY_DONE");
-
-        case FIRST_REPLY_DONE :
-            #ifndef NO_CERTS
-                if (ssl->options.sendVerify) {
-                    if ( (ssl->error = SendCertificate(ssl)) != 0) {
-                        WOLFSSL_ERROR(ssl->error);
-                        return SSL_FATAL_ERROR;
-                    }
-                    WOLFSSL_MSG("sent: certificate");
-                }
-
-            #endif
-            ssl->options.connectState = FIRST_REPLY_FIRST;
-            WOLFSSL_MSG("connect state: FIRST_REPLY_FIRST");
-
-        case FIRST_REPLY_FIRST :
-            if (!ssl->options.resuming) {
-                if ( (ssl->error = SendClientKeyExchange(ssl)) != 0) {
-                    WOLFSSL_ERROR(ssl->error);
-                    return SSL_FATAL_ERROR;
-                }
-                WOLFSSL_MSG("sent: client key exchange");
-            }
-
-            ssl->options.connectState = FIRST_REPLY_SECOND;
-            WOLFSSL_MSG("connect state: FIRST_REPLY_SECOND");
-
-        case FIRST_REPLY_SECOND :
-            #ifndef NO_CERTS
-                if (ssl->options.sendVerify) {
-                    if ( (ssl->error = SendCertificateVerify(ssl)) != 0) {
-                        WOLFSSL_ERROR(ssl->error);
-                        return SSL_FATAL_ERROR;
-                    }
-                    WOLFSSL_MSG("sent: certificate verify");
-                }
-            #endif
-            ssl->options.connectState = FIRST_REPLY_THIRD;
-            WOLFSSL_MSG("connect state: FIRST_REPLY_THIRD");
-
-        case FIRST_REPLY_THIRD :
-            if ( (ssl->error = SendChangeCipher(ssl)) != 0) {
-                WOLFSSL_ERROR(ssl->error);
-                return SSL_FATAL_ERROR;
-            }
-            WOLFSSL_MSG("sent: change cipher spec");
-            ssl->options.connectState = FIRST_REPLY_FOURTH;
-            WOLFSSL_MSG("connect state: FIRST_REPLY_FOURTH");
-
-        case FIRST_REPLY_FOURTH :
-            if ( (ssl->error = SendFinished(ssl)) != 0) {
-                WOLFSSL_ERROR(ssl->error);
-                return SSL_FATAL_ERROR;
-            }
-            WOLFSSL_MSG("sent: finished");
-            ssl->options.connectState = FINISHED_DONE;
-            WOLFSSL_MSG("connect state: FINISHED_DONE");
-
-        case FINISHED_DONE :
-            /* get response */
-            while (ssl->options.serverState < SERVER_FINISHED_COMPLETE)
-                if ( (ssl->error = ProcessReply(ssl)) < 0) {
-                    WOLFSSL_ERROR(ssl->error);
-                    return SSL_FATAL_ERROR;
-                }
-
-            ssl->options.connectState = SECOND_REPLY_DONE;
-            WOLFSSL_MSG("connect state: SECOND_REPLY_DONE");
-
-        case SECOND_REPLY_DONE:
-#ifndef NO_HANDSHAKE_DONE_CB
-            if (ssl->hsDoneCb) {
-                int cbret = ssl->hsDoneCb(ssl, ssl->hsDoneCtx);
-                if (cbret < 0) {
-                    ssl->error = cbret;
-                    WOLFSSL_MSG("HandShake Done Cb don't continue error");
-                    return SSL_FATAL_ERROR;
-                }
-            }
-#endif /* NO_HANDSHAKE_DONE_CB */
-            FreeHandshakeResources(ssl);
-            WOLFSSL_LEAVE("SSL_connect()", SSL_SUCCESS);
-            return SSL_SUCCESS;
-
-        default:
-            WOLFSSL_MSG("Unknown connect state ERROR");
-            return SSL_FATAL_ERROR; /* unknown connect state */
-        }
-    }
-
-#endif /* NO_WOLFSSL_CLIENT */
-
-
-/* server only parts */
-#ifndef NO_WOLFSSL_SERVER
-
-    #ifndef NO_OLD_TLS
-    WOLFSSL_METHOD* wolfSSLv3_server_method(void)
-    {
-        WOLFSSL_METHOD* method =
-                              (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
-                                                       DYNAMIC_TYPE_METHOD);
-        WOLFSSL_ENTER("SSLv3_server_method");
-        if (method) {
-            InitSSL_Method(method, MakeSSLv3());
-            method->side = WOLFSSL_SERVER_END;
-        }
-        return method;
-    }
-    #endif
-
-
-    #ifdef WOLFSSL_DTLS
-
-        #ifndef NO_OLD_TLS
-        WOLFSSL_METHOD* wolfDTLSv1_server_method(void)
-        {
-            WOLFSSL_METHOD* method =
-                              (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD),
-                                                        0, DYNAMIC_TYPE_METHOD);
-            WOLFSSL_ENTER("DTLSv1_server_method");
-            if (method) {
-                InitSSL_Method(method, MakeDTLSv1());
-                method->side = WOLFSSL_SERVER_END;
-            }
-            return method;
-        }
-        #endif /* NO_OLD_TLS */
-
-        WOLFSSL_METHOD* wolfDTLSv1_2_server_method(void)
-        {
-            WOLFSSL_METHOD* method =
-                              (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD),
-                                                        0, DYNAMIC_TYPE_METHOD);
-            WOLFSSL_ENTER("DTLSv1_2_server_method");
-            if (method) {
-                InitSSL_Method(method, MakeDTLSv1_2());
-                method->side = WOLFSSL_SERVER_END;
-            }
-            return method;
-        }
-    #endif
-
-
-    int wolfSSL_accept(WOLFSSL* ssl)
-    {
-        byte havePSK = 0;
-        byte haveAnon = 0;
-        WOLFSSL_ENTER("SSL_accept()");
-
-        #ifdef HAVE_ERRNO_H
-            errno = 0;
-        #endif
-
-        #ifndef NO_PSK
-            havePSK = ssl->options.havePSK;
-        #endif
-        (void)havePSK;
-
-        #ifdef HAVE_ANON
-            haveAnon = ssl->options.haveAnon;
-        #endif
-        (void)haveAnon;
-
-        if (ssl->options.side != WOLFSSL_SERVER_END) {
-            WOLFSSL_ERROR(ssl->error = SIDE_ERROR);
-            return SSL_FATAL_ERROR;
-        }
-
-        #ifndef NO_CERTS
-            /* in case used set_accept_state after init */
-            if (!havePSK && !haveAnon &&
-                            (ssl->buffers.certificate.buffer == NULL ||
-                             ssl->buffers.key.buffer == NULL)) {
-                WOLFSSL_MSG("accept error: don't have server cert and key");
-                ssl->error = NO_PRIVATE_KEY;
-                WOLFSSL_ERROR(ssl->error);
-                return SSL_FATAL_ERROR;
-            }
-        #endif
-
-        #ifdef WOLFSSL_DTLS
-            if (ssl->version.major == DTLS_MAJOR) {
-                ssl->options.dtls   = 1;
-                ssl->options.tls    = 1;
-                ssl->options.tls1_1 = 1;
-
-                if (DtlsPoolInit(ssl) != 0) {
-                    ssl->error = MEMORY_ERROR;
-                    WOLFSSL_ERROR(ssl->error);
-                    return SSL_FATAL_ERROR;
-                }
-            }
-        #endif
-
-        if (ssl->buffers.outputBuffer.length > 0) {
-            if ( (ssl->error = SendBuffered(ssl)) == 0) {
-                ssl->options.acceptState++;
-                WOLFSSL_MSG("accept state: Advanced from buffered send");
-            }
-            else {
-                WOLFSSL_ERROR(ssl->error);
-                return SSL_FATAL_ERROR;
-            }
-        }
-
-        switch (ssl->options.acceptState) {
-
-        case ACCEPT_BEGIN :
-            /* get response */
-            while (ssl->options.clientState < CLIENT_HELLO_COMPLETE)
-                if ( (ssl->error = ProcessReply(ssl)) < 0) {
-                    WOLFSSL_ERROR(ssl->error);
-                    return SSL_FATAL_ERROR;
-                }
-            ssl->options.acceptState = ACCEPT_CLIENT_HELLO_DONE;
-            WOLFSSL_MSG("accept state ACCEPT_CLIENT_HELLO_DONE");
-
-        case ACCEPT_CLIENT_HELLO_DONE :
-            #ifdef WOLFSSL_DTLS
-                if (ssl->options.dtls)
-                    if ( (ssl->error = SendHelloVerifyRequest(ssl)) != 0) {
-                        WOLFSSL_ERROR(ssl->error);
-                        return SSL_FATAL_ERROR;
-                    }
-            #endif
-            ssl->options.acceptState = HELLO_VERIFY_SENT;
-            WOLFSSL_MSG("accept state HELLO_VERIFY_SENT");
-
-        case HELLO_VERIFY_SENT:
-            #ifdef WOLFSSL_DTLS
-                if (ssl->options.dtls) {
-                    ssl->options.clientState = NULL_STATE;  /* get again */
-                    /* reset messages received */
-                    XMEMSET(&ssl->msgsReceived, 0, sizeof(ssl->msgsReceived));
-                    /* re-init hashes, exclude first hello and verify request */
-#ifndef NO_OLD_TLS
-                    wc_InitMd5(&ssl->hsHashes->hashMd5);
-                    if ( (ssl->error = wc_InitSha(&ssl->hsHashes->hashSha))
-                                                                         != 0) {
-                        WOLFSSL_ERROR(ssl->error);
-                        return SSL_FATAL_ERROR;
-                    }
-#endif
-                    if (IsAtLeastTLSv1_2(ssl)) {
-                        #ifndef NO_SHA256
-                            if ( (ssl->error = wc_InitSha256(
-                                            &ssl->hsHashes->hashSha256)) != 0) {
-                               WOLFSSL_ERROR(ssl->error);
-                               return SSL_FATAL_ERROR;
-                            }
-                        #endif
-                        #ifdef WOLFSSL_SHA384
-                            if ( (ssl->error = wc_InitSha384(
-                                            &ssl->hsHashes->hashSha384)) != 0) {
-                               WOLFSSL_ERROR(ssl->error);
-                               return SSL_FATAL_ERROR;
-                            }
-                        #endif
-                        #ifdef WOLFSSL_SHA512
-                            if ( (ssl->error = wc_InitSha512(
-                                            &ssl->hsHashes->hashSha512)) != 0) {
-                               WOLFSSL_ERROR(ssl->error);
-                               return SSL_FATAL_ERROR;
-                            }
-                        #endif
-                    }
-
-                    while (ssl->options.clientState < CLIENT_HELLO_COMPLETE)
-                        if ( (ssl->error = ProcessReply(ssl)) < 0) {
-                            WOLFSSL_ERROR(ssl->error);
-                            return SSL_FATAL_ERROR;
-                        }
-                }
-            #endif
-            ssl->options.acceptState = ACCEPT_FIRST_REPLY_DONE;
-            WOLFSSL_MSG("accept state ACCEPT_FIRST_REPLY_DONE");
-
-        case ACCEPT_FIRST_REPLY_DONE :
-            if ( (ssl->error = SendServerHello(ssl)) != 0) {
-                WOLFSSL_ERROR(ssl->error);
-                return SSL_FATAL_ERROR;
-            }
-            ssl->options.acceptState = SERVER_HELLO_SENT;
-            WOLFSSL_MSG("accept state SERVER_HELLO_SENT");
-
-        case SERVER_HELLO_SENT :
-            #ifndef NO_CERTS
-                if (!ssl->options.resuming)
-                    if ( (ssl->error = SendCertificate(ssl)) != 0) {
-                        WOLFSSL_ERROR(ssl->error);
-                        return SSL_FATAL_ERROR;
-                    }
-            #endif
-            ssl->options.acceptState = CERT_SENT;
-            WOLFSSL_MSG("accept state CERT_SENT");
-
-        case CERT_SENT :
-            if (!ssl->options.resuming)
-                if ( (ssl->error = SendServerKeyExchange(ssl)) != 0) {
-                    WOLFSSL_ERROR(ssl->error);
-                    return SSL_FATAL_ERROR;
-                }
-            ssl->options.acceptState = KEY_EXCHANGE_SENT;
-            WOLFSSL_MSG("accept state KEY_EXCHANGE_SENT");
-
-        case KEY_EXCHANGE_SENT :
-            #ifndef NO_CERTS
-                if (!ssl->options.resuming)
-                    if (ssl->options.verifyPeer)
-                        if ( (ssl->error = SendCertificateRequest(ssl)) != 0) {
-                            WOLFSSL_ERROR(ssl->error);
-                            return SSL_FATAL_ERROR;
-                        }
-            #endif
-            ssl->options.acceptState = CERT_REQ_SENT;
-            WOLFSSL_MSG("accept state CERT_REQ_SENT");
-
-        case CERT_REQ_SENT :
-            if (!ssl->options.resuming)
-                if ( (ssl->error = SendServerHelloDone(ssl)) != 0) {
-                    WOLFSSL_ERROR(ssl->error);
-                    return SSL_FATAL_ERROR;
-                }
-            ssl->options.acceptState = SERVER_HELLO_DONE;
-            WOLFSSL_MSG("accept state SERVER_HELLO_DONE");
-
-        case SERVER_HELLO_DONE :
-            if (!ssl->options.resuming) {
-                while (ssl->options.clientState < CLIENT_FINISHED_COMPLETE)
-                    if ( (ssl->error = ProcessReply(ssl)) < 0) {
-                        WOLFSSL_ERROR(ssl->error);
-                        return SSL_FATAL_ERROR;
-                    }
-            }
-            ssl->options.acceptState = ACCEPT_SECOND_REPLY_DONE;
-            WOLFSSL_MSG("accept state  ACCEPT_SECOND_REPLY_DONE");
-
-        case ACCEPT_SECOND_REPLY_DONE :
-#ifdef HAVE_SESSION_TICKET
-            if (ssl->options.createTicket) {
-                if ( (ssl->error = SendTicket(ssl)) != 0) {
-                    WOLFSSL_ERROR(ssl->error);
-                    return SSL_FATAL_ERROR;
-                }
-            }
-#endif /* HAVE_SESSION_TICKET */
-            ssl->options.acceptState = TICKET_SENT;
-            WOLFSSL_MSG("accept state  TICKET_SENT");
-
-        case TICKET_SENT:
-            if ( (ssl->error = SendChangeCipher(ssl)) != 0) {
-                WOLFSSL_ERROR(ssl->error);
-                return SSL_FATAL_ERROR;
-            }
-            ssl->options.acceptState = CHANGE_CIPHER_SENT;
-            WOLFSSL_MSG("accept state  CHANGE_CIPHER_SENT");
-
-        case CHANGE_CIPHER_SENT :
-            if ( (ssl->error = SendFinished(ssl)) != 0) {
-                WOLFSSL_ERROR(ssl->error);
-                return SSL_FATAL_ERROR;
-            }
-
-            ssl->options.acceptState = ACCEPT_FINISHED_DONE;
-            WOLFSSL_MSG("accept state ACCEPT_FINISHED_DONE");
-
-        case ACCEPT_FINISHED_DONE :
-            if (ssl->options.resuming)
-                while (ssl->options.clientState < CLIENT_FINISHED_COMPLETE)
-                    if ( (ssl->error = ProcessReply(ssl)) < 0) {
-                        WOLFSSL_ERROR(ssl->error);
-                        return SSL_FATAL_ERROR;
-                    }
-
-            ssl->options.acceptState = ACCEPT_THIRD_REPLY_DONE;
-            WOLFSSL_MSG("accept state ACCEPT_THIRD_REPLY_DONE");
-
-        case ACCEPT_THIRD_REPLY_DONE :
-#ifndef NO_HANDSHAKE_DONE_CB
-            if (ssl->hsDoneCb) {
-                int cbret = ssl->hsDoneCb(ssl, ssl->hsDoneCtx);
-                if (cbret < 0) {
-                    ssl->error = cbret;
-                    WOLFSSL_MSG("HandShake Done Cb don't continue error");
-                    return SSL_FATAL_ERROR;
-                }
-            }
-#endif /* NO_HANDSHAKE_DONE_CB */
-            FreeHandshakeResources(ssl);
-            WOLFSSL_LEAVE("SSL_accept()", SSL_SUCCESS);
-            return SSL_SUCCESS;
-
-        default :
-            WOLFSSL_MSG("Unknown accept state ERROR");
-            return SSL_FATAL_ERROR;
-        }
-    }
-
-#endif /* NO_WOLFSSL_SERVER */
-
-
-#ifndef NO_HANDSHAKE_DONE_CB
-
-int wolfSSL_SetHsDoneCb(WOLFSSL* ssl, HandShakeDoneCb cb, void* user_ctx)
-{
-    WOLFSSL_ENTER("wolfSSL_SetHsDoneCb");
-
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    ssl->hsDoneCb  = cb;
-    ssl->hsDoneCtx = user_ctx;
-
-
-    return SSL_SUCCESS;
-}
-
-#endif /* NO_HANDSHAKE_DONE_CB */
-
-
-int wolfSSL_Cleanup(void)
-{
-    int ret = SSL_SUCCESS;
-    int release = 0;
-
-    WOLFSSL_ENTER("wolfSSL_Cleanup");
-
-    if (initRefCount == 0)
-        return ret;  /* possibly no init yet, but not failure either way */
-
-    if (LockMutex(&count_mutex) != 0) {
-        WOLFSSL_MSG("Bad Lock Mutex count");
-        return BAD_MUTEX_E;
-    }
-
-    release = initRefCount-- == 1;
-    if (initRefCount < 0)
-        initRefCount = 0;
-
-    UnLockMutex(&count_mutex);
-
-    if (!release)
-        return ret;
-
-#ifndef NO_SESSION_CACHE
-    if (FreeMutex(&session_mutex) != 0)
-        ret = BAD_MUTEX_E;
-#endif
-    if (FreeMutex(&count_mutex) != 0)
-        ret = BAD_MUTEX_E;
-
-#if defined(HAVE_ECC) && defined(FP_ECC)
-    wc_ecc_fp_free();
-#endif
-
-    return ret;
-}
-
-
-#ifndef NO_SESSION_CACHE
-
-
-/* some session IDs aren't random afterall, let's make them random */
-static INLINE word32 HashSession(const byte* sessionID, word32 len, int* error)
-{
-    byte digest[MAX_DIGEST_SIZE];
-
-#ifndef NO_MD5
-    *error =  wc_Md5Hash(sessionID, len, digest);
-#elif !defined(NO_SHA)
-    *error =  wc_ShaHash(sessionID, len, digest);
-#elif !defined(NO_SHA256)
-    *error =  wc_Sha256Hash(sessionID, len, digest);
-#else
-    #error "We need a digest to hash the session IDs"
-#endif
-
-    return *error == 0 ? MakeWordFromHash(digest) : 0; /* 0 on failure */
-}
-
-
-void wolfSSL_flush_sessions(WOLFSSL_CTX* ctx, long tm)
-{
-    /* static table now, no flusing needed */
-    (void)ctx;
-    (void)tm;
-}
-
-
-/* set ssl session timeout in seconds */
-int wolfSSL_set_timeout(WOLFSSL* ssl, unsigned int to)
-{
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    ssl->timeout = to;
-
-    return SSL_SUCCESS;
-}
-
-
-/* set ctx session timeout in seconds */
-int wolfSSL_CTX_set_timeout(WOLFSSL_CTX* ctx, unsigned int to)
-{
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-    ctx->timeout = to;
-
-    return SSL_SUCCESS;
-}
-
-
-#ifndef NO_CLIENT_CACHE
-
-/* Get Session from Client cache based on id/len, return NULL on failure */
-WOLFSSL_SESSION* GetSessionClient(WOLFSSL* ssl, const byte* id, int len)
-{
-    WOLFSSL_SESSION* ret = NULL;
-    word32          row;
-    int             idx;
-    int             count;
-    int             error = 0;
-
-    WOLFSSL_ENTER("GetSessionClient");
-
-    if (ssl->options.side == WOLFSSL_SERVER_END)
-        return NULL;
-
-    len = min(SERVER_ID_LEN, (word32)len);
-    row = HashSession(id, len, &error) % SESSION_ROWS;
-    if (error != 0) {
-        WOLFSSL_MSG("Hash session failed");
-        return NULL;
-    }
-
-    if (LockMutex(&session_mutex) != 0) {
-        WOLFSSL_MSG("Lock session mutex failed");
-        return NULL;
-    }
-
-    /* start from most recently used */
-    count = min((word32)ClientCache[row].totalCount, SESSIONS_PER_ROW);
-    idx = ClientCache[row].nextIdx - 1;
-    if (idx < 0)
-        idx = SESSIONS_PER_ROW - 1; /* if back to front, the previous was end */
-
-    for (; count > 0; --count, idx = idx ? idx - 1 : SESSIONS_PER_ROW - 1) {
-        WOLFSSL_SESSION* current;
-        ClientSession   clSess;
-
-        if (idx >= SESSIONS_PER_ROW || idx < 0) { /* sanity check */
-            WOLFSSL_MSG("Bad idx");
-            break;
-        }
-
-        clSess = ClientCache[row].Clients[idx];
-
-        current = &SessionCache[clSess.serverRow].Sessions[clSess.serverIdx];
-        if (XMEMCMP(current->serverID, id, len) == 0) {
-            WOLFSSL_MSG("Found a serverid match for client");
-            if (LowResTimer() < (current->bornOn + current->timeout)) {
-                WOLFSSL_MSG("Session valid");
-                ret = current;
-                break;
-            } else {
-                WOLFSSL_MSG("Session timed out");  /* could have more for id */
-            }
-        } else {
-            WOLFSSL_MSG("ServerID not a match from client table");
-        }
-    }
-
-    UnLockMutex(&session_mutex);
-
-    return ret;
-}
-
-#endif /* NO_CLIENT_CACHE */
-
-
-WOLFSSL_SESSION* GetSession(WOLFSSL* ssl, byte* masterSecret)
-{
-    WOLFSSL_SESSION* ret = 0;
-    const byte*  id = NULL;
-    word32       row;
-    int          idx;
-    int          count;
-    int          error = 0;
-
-    if (ssl->options.sessionCacheOff)
-        return NULL;
-
-    if (ssl->options.haveSessionId == 0)
-        return NULL;
-
-#ifdef HAVE_SESSION_TICKET
-    if (ssl->options.side == WOLFSSL_SERVER_END && ssl->options.useTicket == 1)
-        return NULL;
-#endif
-
-    if (ssl->arrays)
-        id = ssl->arrays->sessionID;
-    else
-        id = ssl->session.sessionID;
-
-    row = HashSession(id, ID_LEN, &error) % SESSION_ROWS;
-    if (error != 0) {
-        WOLFSSL_MSG("Hash session failed");
-        return NULL;
-    }
-
-    if (LockMutex(&session_mutex) != 0)
-        return 0;
-
-    /* start from most recently used */
-    count = min((word32)SessionCache[row].totalCount, SESSIONS_PER_ROW);
-    idx = SessionCache[row].nextIdx - 1;
-    if (idx < 0)
-        idx = SESSIONS_PER_ROW - 1; /* if back to front, the previous was end */
-
-    for (; count > 0; --count, idx = idx ? idx - 1 : SESSIONS_PER_ROW - 1) {
-        WOLFSSL_SESSION* current;
-
-        if (idx >= SESSIONS_PER_ROW || idx < 0) { /* sanity check */
-            WOLFSSL_MSG("Bad idx");
-            break;
-        }
-
-        current = &SessionCache[row].Sessions[idx];
-        if (XMEMCMP(current->sessionID, id, ID_LEN) == 0) {
-            WOLFSSL_MSG("Found a session match");
-            if (LowResTimer() < (current->bornOn + current->timeout)) {
-                WOLFSSL_MSG("Session valid");
-                ret = current;
-                if (masterSecret)
-                    XMEMCPY(masterSecret, current->masterSecret, SECRET_LEN);
-            } else {
-                WOLFSSL_MSG("Session timed out");
-            }
-            break;  /* no more sessionIDs whether valid or not that match */
-        } else {
-            WOLFSSL_MSG("SessionID not a match at this idx");
-        }
-    }
-
-    UnLockMutex(&session_mutex);
-
-    return ret;
-}
-
-
-int SetSession(WOLFSSL* ssl, WOLFSSL_SESSION* session)
-{
-    if (ssl->options.sessionCacheOff)
-        return SSL_FAILURE;
-
-    if (LowResTimer() < (session->bornOn + session->timeout)) {
-        ssl->session  = *session;
-        ssl->options.resuming = 1;
-
-#ifdef SESSION_CERTS
-        ssl->version              = session->version;
-        ssl->options.cipherSuite0 = session->cipherSuite0;
-        ssl->options.cipherSuite  = session->cipherSuite;
-#endif
-
-        return SSL_SUCCESS;
-    }
-    return SSL_FAILURE;  /* session timed out */
-}
-
-
-#ifdef WOLFSSL_SESSION_STATS
-static int get_locked_session_stats(word32* active, word32* total,
-                                    word32* peak);
-#endif
-
-int AddSession(WOLFSSL* ssl)
-{
-    word32 row, idx;
-    int    error = 0;
-
-    if (ssl->options.sessionCacheOff)
-        return 0;
-
-    if (ssl->options.haveSessionId == 0)
-        return 0;
-
-#ifdef HAVE_SESSION_TICKET
-    if (ssl->options.side == WOLFSSL_SERVER_END && ssl->options.useTicket == 1)
-        return 0;
-#endif
-
-    row = HashSession(ssl->arrays->sessionID, ID_LEN, &error) % SESSION_ROWS;
-    if (error != 0) {
-        WOLFSSL_MSG("Hash session failed");
-        return error;
-    }
-
-    if (LockMutex(&session_mutex) != 0)
-        return BAD_MUTEX_E;
-
-    idx = SessionCache[row].nextIdx++;
-#ifdef SESSION_INDEX
-    ssl->sessionIndex = (row << SESSIDX_ROW_SHIFT) | idx;
-#endif
-
-    XMEMCPY(SessionCache[row].Sessions[idx].masterSecret,
-           ssl->arrays->masterSecret, SECRET_LEN);
-    XMEMCPY(SessionCache[row].Sessions[idx].sessionID, ssl->arrays->sessionID,
-           ID_LEN);
-    SessionCache[row].Sessions[idx].sessionIDSz = ssl->arrays->sessionIDSz;
-
-    SessionCache[row].Sessions[idx].timeout = ssl->timeout;
-    SessionCache[row].Sessions[idx].bornOn  = LowResTimer();
-
-#ifdef HAVE_SESSION_TICKET
-    SessionCache[row].Sessions[idx].ticketLen     = ssl->session.ticketLen;
-    XMEMCPY(SessionCache[row].Sessions[idx].ticket,
-                                   ssl->session.ticket, ssl->session.ticketLen);
-#endif
-
-#ifdef SESSION_CERTS
-    SessionCache[row].Sessions[idx].chain.count = ssl->session.chain.count;
-    XMEMCPY(SessionCache[row].Sessions[idx].chain.certs,
-           ssl->session.chain.certs, sizeof(x509_buffer) * MAX_CHAIN_DEPTH);
-
-    SessionCache[row].Sessions[idx].version      = ssl->version;
-    SessionCache[row].Sessions[idx].cipherSuite0 = ssl->options.cipherSuite0;
-    SessionCache[row].Sessions[idx].cipherSuite  = ssl->options.cipherSuite;
-#endif /* SESSION_CERTS */
-
-    SessionCache[row].totalCount++;
-    if (SessionCache[row].nextIdx == SESSIONS_PER_ROW)
-        SessionCache[row].nextIdx = 0;
-
-#ifndef NO_CLIENT_CACHE
-    if (ssl->options.side == WOLFSSL_CLIENT_END && ssl->session.idLen) {
-        word32 clientRow, clientIdx;
-
-        WOLFSSL_MSG("Adding client cache entry");
-
-        SessionCache[row].Sessions[idx].idLen = ssl->session.idLen;
-        XMEMCPY(SessionCache[row].Sessions[idx].serverID, ssl->session.serverID,
-                ssl->session.idLen);
-
-        clientRow = HashSession(ssl->session.serverID, ssl->session.idLen,
-                                &error) % SESSION_ROWS;
-        if (error != 0) {
-            WOLFSSL_MSG("Hash session failed");
-        } else {
-            clientIdx = ClientCache[clientRow].nextIdx++;
-
-            ClientCache[clientRow].Clients[clientIdx].serverRow = (word16)row;
-            ClientCache[clientRow].Clients[clientIdx].serverIdx = (word16)idx;
-
-            ClientCache[clientRow].totalCount++;
-            if (ClientCache[clientRow].nextIdx == SESSIONS_PER_ROW)
-                ClientCache[clientRow].nextIdx = 0;
-        }
-    }
-    else
-        SessionCache[row].Sessions[idx].idLen = 0;
-#endif /* NO_CLIENT_CACHE */
-
-#if defined(WOLFSSL_SESSION_STATS) && defined(WOLFSSL_PEAK_SESSIONS)
-    if (error == 0) {
-        word32 active = 0;
-
-        error = get_locked_session_stats(&active, NULL, NULL);
-        if (error == SSL_SUCCESS) {
-            error = 0;  /* back to this function ok */
-
-            if (active > PeakSessions)
-                PeakSessions = active;
-        }
-    }
-#endif /* defined(WOLFSSL_SESSION_STATS) && defined(WOLFSSL_PEAK_SESSIONS) */
-
-    if (UnLockMutex(&session_mutex) != 0)
-        return BAD_MUTEX_E;
-
-    return error;
-}
-
-
-#ifdef SESSION_INDEX
-
-int wolfSSL_GetSessionIndex(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("wolfSSL_GetSessionIndex");
-    WOLFSSL_LEAVE("wolfSSL_GetSessionIndex", ssl->sessionIndex);
-    return ssl->sessionIndex;
-}
-
-
-int wolfSSL_GetSessionAtIndex(int idx, WOLFSSL_SESSION* session)
-{
-    int row, col, result = SSL_FAILURE;
-
-    WOLFSSL_ENTER("wolfSSL_GetSessionAtIndex");
-
-    row = idx >> SESSIDX_ROW_SHIFT;
-    col = idx & SESSIDX_IDX_MASK;
-
-    if (LockMutex(&session_mutex) != 0) {
-        return BAD_MUTEX_E;
-    }
-
-    if (row < SESSION_ROWS &&
-        col < (int)min(SessionCache[row].totalCount, SESSIONS_PER_ROW)) {
-        XMEMCPY(session,
-                 &SessionCache[row].Sessions[col], sizeof(WOLFSSL_SESSION));
-        result = SSL_SUCCESS;
-    }
-
-    if (UnLockMutex(&session_mutex) != 0)
-        result = BAD_MUTEX_E;
-
-    WOLFSSL_LEAVE("wolfSSL_GetSessionAtIndex", result);
-    return result;
-}
-
-#endif /* SESSION_INDEX */
-
-#if defined(SESSION_INDEX) && defined(SESSION_CERTS)
-
-WOLFSSL_X509_CHAIN* wolfSSL_SESSION_get_peer_chain(WOLFSSL_SESSION* session)
-{
-    WOLFSSL_X509_CHAIN* chain = NULL;
-
-    WOLFSSL_ENTER("wolfSSL_SESSION_get_peer_chain");
-    if (session)
-        chain = &session->chain;
-
-    WOLFSSL_LEAVE("wolfSSL_SESSION_get_peer_chain", chain ? 1 : 0);
-    return chain;
-}
-
-#endif /* SESSION_INDEX && SESSION_CERTS */
-
-
-#ifdef WOLFSSL_SESSION_STATS
-
-/* requires session_mutex lock held, SSL_SUCCESS on ok */
-static int get_locked_session_stats(word32* active, word32* total, word32* peak)
-{
-    int result = SSL_SUCCESS;
-    int i;
-    int count;
-    int idx;
-    word32 now   = 0;
-    word32 seen  = 0;
-    word32 ticks = LowResTimer();
-
-    (void)peak;
-
-    WOLFSSL_ENTER("get_locked_session_stats");
-
-    for (i = 0; i < SESSION_ROWS; i++) {
-        seen += SessionCache[i].totalCount;
-
-        if (active == NULL)
-            continue;  /* no need to calculate what we can't set */
-
-        count = min((word32)SessionCache[i].totalCount, SESSIONS_PER_ROW);
-        idx   = SessionCache[i].nextIdx - 1;
-        if (idx < 0)
-            idx = SESSIONS_PER_ROW - 1; /* if back to front previous was end */
-
-        for (; count > 0; --count, idx = idx ? idx - 1 : SESSIONS_PER_ROW - 1) {
-            if (idx >= SESSIONS_PER_ROW || idx < 0) {  /* sanity check */
-                WOLFSSL_MSG("Bad idx");
-                break;
-            }
-
-            /* if not expried then good */
-            if (ticks < (SessionCache[i].Sessions[idx].bornOn +
-                         SessionCache[i].Sessions[idx].timeout) ) {
-                now++;
-            }
-        }
-    }
-
-    if (active)
-        *active = now;
-
-    if (total)
-        *total = seen;
-
-#ifdef WOLFSSL_PEAK_SESSIONS
-    if (peak)
-        *peak = PeakSessions;
-#endif
-
-    WOLFSSL_LEAVE("get_locked_session_stats", result);
-
-    return result;
-}
-
-
-/* return SSL_SUCCESS on ok */
-int wolfSSL_get_session_stats(word32* active, word32* total, word32* peak,
-                              word32* maxSessions)
-{
-    int result = SSL_SUCCESS;
-
-    WOLFSSL_ENTER("wolfSSL_get_session_stats");
-
-    if (maxSessions) {
-        *maxSessions = SESSIONS_PER_ROW * SESSION_ROWS;
-
-        if (active == NULL && total == NULL && peak == NULL)
-            return result;  /* we're done */
-    }
-
-    /* user must provide at least one query value */
-    if (active == NULL && total == NULL && peak == NULL)
-        return BAD_FUNC_ARG;
-
-    if (LockMutex(&session_mutex) != 0) {
-        return BAD_MUTEX_E;
-    }
-
-    result = get_locked_session_stats(active, total, peak);
-
-    if (UnLockMutex(&session_mutex) != 0)
-        result = BAD_MUTEX_E;
-
-    WOLFSSL_LEAVE("wolfSSL_get_session_stats", result);
-
-    return result;
-}
-
-#endif /* WOLFSSL_SESSION_STATS */
-
-
-    #ifdef PRINT_SESSION_STATS
-
-    /* SSL_SUCCESS on ok */
-    int wolfSSL_PrintSessionStats(void)
-    {
-        word32 totalSessionsSeen = 0;
-        word32 totalSessionsNow = 0;
-        word32 peak = 0;
-        word32 maxSessions = 0;
-        int    i;
-        int    ret;
-        double E;               /* expected freq */
-        double chiSquare = 0;
-
-        ret = wolfSSL_get_session_stats(&totalSessionsNow, &totalSessionsSeen,
-                                        &peak, &maxSessions);
-        if (ret != SSL_SUCCESS)
-            return ret;
-        printf("Total Sessions Seen = %d\n", totalSessionsSeen);
-        printf("Total Sessions Now  = %d\n", totalSessionsNow);
-#ifdef WOLFSSL_PEAK_SESSIONS
-        printf("Peak  Sessions      = %d\n", peak);
-#endif
-        printf("Max   Sessions      = %d\n", maxSessions);
-
-        E = (double)totalSessionsSeen / SESSION_ROWS;
-
-        for (i = 0; i < SESSION_ROWS; i++) {
-            double diff = SessionCache[i].totalCount - E;
-            diff *= diff;                /* square    */
-            diff /= E;                   /* normalize */
-
-            chiSquare += diff;
-        }
-        printf("  chi-square = %5.1f, d.f. = %d\n", chiSquare,
-                                                     SESSION_ROWS - 1);
-        #if (SESSION_ROWS == 11)
-            printf(" .05 p value =  18.3, chi-square should be less\n");
-        #elif (SESSION_ROWS == 211)
-            printf(".05 p value  = 244.8, chi-square should be less\n");
-        #elif (SESSION_ROWS == 5981)
-            printf(".05 p value  = 6161.0, chi-square should be less\n");
-        #elif (SESSION_ROWS == 3)
-            printf(".05 p value  =   6.0, chi-square should be less\n");
-        #elif (SESSION_ROWS == 2861)
-            printf(".05 p value  = 2985.5, chi-square should be less\n");
-        #endif
-        printf("\n");
-
-        return ret;
-    }
-
-    #endif /* SESSION_STATS */
-
-#else  /* NO_SESSION_CACHE */
-
-/* No session cache version */
-WOLFSSL_SESSION* GetSession(WOLFSSL* ssl, byte* masterSecret)
-{
-    (void)ssl;
-    (void)masterSecret;
-
-    return NULL;
-}
-
-#endif /* NO_SESSION_CACHE */
-
-
-/* call before SSL_connect, if verifying will add name check to
-   date check and signature check */
-int wolfSSL_check_domain_name(WOLFSSL* ssl, const char* dn)
-{
-    WOLFSSL_ENTER("wolfSSL_check_domain_name");
-    if (ssl->buffers.domainName.buffer)
-        XFREE(ssl->buffers.domainName.buffer, ssl->heap, DYNAMIC_TYPE_DOMAIN);
-
-    ssl->buffers.domainName.length = (word32)XSTRLEN(dn) + 1;
-    ssl->buffers.domainName.buffer = (byte*) XMALLOC(
-                ssl->buffers.domainName.length, ssl->heap, DYNAMIC_TYPE_DOMAIN);
-
-    if (ssl->buffers.domainName.buffer) {
-        XSTRNCPY((char*)ssl->buffers.domainName.buffer, dn,
-                ssl->buffers.domainName.length);
-        return SSL_SUCCESS;
-    }
-    else {
-        ssl->error = MEMORY_ERROR;
-        return SSL_FAILURE;
-    }
-}
-
-
-/* turn on wolfSSL zlib compression
-   returns SSL_SUCCESS for success, else error (not built in)
-*/
-int wolfSSL_set_compression(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("wolfSSL_set_compression");
-    (void)ssl;
-#ifdef HAVE_LIBZ
-    ssl->options.usingCompression = 1;
-    return SSL_SUCCESS;
-#else
-    return NOT_COMPILED_IN;
-#endif
-}
-
-
-#ifndef USE_WINDOWS_API
-    #ifndef NO_WRITEV
-
-        /* simulate writev semantics, doesn't actually do block at a time though
-           because of SSL_write behavior and because front adds may be small */
-        int wolfSSL_writev(WOLFSSL* ssl, const struct iovec* iov, int iovcnt)
-        {
-        #ifdef WOLFSSL_SMALL_STACK
-            byte   staticBuffer[1]; /* force heap usage */
-        #else
-            byte   staticBuffer[FILE_BUFFER_SIZE];
-        #endif
-            byte* myBuffer  = staticBuffer;
-            int   dynamic   = 0;
-            int   sending   = 0;
-            int   idx       = 0;
-            int   i;
-            int   ret;
-
-            WOLFSSL_ENTER("wolfSSL_writev");
-
-            for (i = 0; i < iovcnt; i++)
-                sending += (int)iov[i].iov_len;
-
-            if (sending > (int)sizeof(staticBuffer)) {
-                myBuffer = (byte*)XMALLOC(sending, ssl->heap,
-                                                           DYNAMIC_TYPE_WRITEV);
-                if (!myBuffer)
-                    return MEMORY_ERROR;
-
-                dynamic = 1;
-            }
-
-            for (i = 0; i < iovcnt; i++) {
-                XMEMCPY(&myBuffer[idx], iov[i].iov_base, iov[i].iov_len);
-                idx += (int)iov[i].iov_len;
-            }
-
-            ret = wolfSSL_write(ssl, myBuffer, sending);
-
-            if (dynamic)
-                XFREE(myBuffer, ssl->heap, DYNAMIC_TYPE_WRITEV);
-
-            return ret;
-        }
-    #endif
-#endif
-
-
-#ifdef WOLFSSL_CALLBACKS
-
-    typedef struct itimerval Itimerval;
-
-    /* don't keep calling simple functions while setting up timer and singals
-       if no inlining these are the next best */
-
-    #define AddTimes(a, b, c)                       \
-        do {                                        \
-            c.tv_sec  = a.tv_sec  + b.tv_sec;       \
-            c.tv_usec = a.tv_usec + b.tv_usec;      \
-            if (c.tv_usec >=  1000000) {            \
-                c.tv_sec++;                         \
-                c.tv_usec -= 1000000;               \
-            }                                       \
-        } while (0)
-
-
-    #define SubtractTimes(a, b, c)                  \
-        do {                                        \
-            c.tv_sec  = a.tv_sec  - b.tv_sec;       \
-            c.tv_usec = a.tv_usec - b.tv_usec;      \
-            if (c.tv_usec < 0) {                    \
-                c.tv_sec--;                         \
-                c.tv_usec += 1000000;               \
-            }                                       \
-        } while (0)
-
-    #define CmpTimes(a, b, cmp)                     \
-        ((a.tv_sec  ==  b.tv_sec) ?                 \
-            (a.tv_usec cmp b.tv_usec) :             \
-            (a.tv_sec  cmp b.tv_sec))               \
-
-
-    /* do nothing handler */
-    static void myHandler(int signo)
-    {
-        (void)signo;
-        return;
-    }
-
-
-    static int wolfSSL_ex_wrapper(WOLFSSL* ssl, HandShakeCallBack hsCb,
-                                 TimeoutCallBack toCb, Timeval timeout)
-    {
-        int       ret        = SSL_FATAL_ERROR;
-        int       oldTimerOn = 0;   /* was timer already on */
-        Timeval   startTime;
-        Timeval   endTime;
-        Timeval   totalTime;
-        Itimerval myTimeout;
-        Itimerval oldTimeout; /* if old timer adjust from total time to reset */
-        struct sigaction act, oact;
-
-        #define ERR_OUT(x) { ssl->hsInfoOn = 0; ssl->toInfoOn = 0; return x; }
-
-        if (hsCb) {
-            ssl->hsInfoOn = 1;
-            InitHandShakeInfo(&ssl->handShakeInfo);
-        }
-        if (toCb) {
-            ssl->toInfoOn = 1;
-            InitTimeoutInfo(&ssl->timeoutInfo);
-
-            if (gettimeofday(&startTime, 0) < 0)
-                ERR_OUT(GETTIME_ERROR);
-
-            /* use setitimer to simulate getitimer, init 0 myTimeout */
-            myTimeout.it_interval.tv_sec  = 0;
-            myTimeout.it_interval.tv_usec = 0;
-            myTimeout.it_value.tv_sec     = 0;
-            myTimeout.it_value.tv_usec    = 0;
-            if (setitimer(ITIMER_REAL, &myTimeout, &oldTimeout) < 0)
-                ERR_OUT(SETITIMER_ERROR);
-
-            if (oldTimeout.it_value.tv_sec || oldTimeout.it_value.tv_usec) {
-                oldTimerOn = 1;
-
-                /* is old timer going to expire before ours */
-                if (CmpTimes(oldTimeout.it_value, timeout, <)) {
-                    timeout.tv_sec  = oldTimeout.it_value.tv_sec;
-                    timeout.tv_usec = oldTimeout.it_value.tv_usec;
-                }
-            }
-            myTimeout.it_value.tv_sec  = timeout.tv_sec;
-            myTimeout.it_value.tv_usec = timeout.tv_usec;
-
-            /* set up signal handler, don't restart socket send/recv */
-            act.sa_handler = myHandler;
-            sigemptyset(&act.sa_mask);
-            act.sa_flags = 0;
-#ifdef SA_INTERRUPT
-            act.sa_flags |= SA_INTERRUPT;
-#endif
-            if (sigaction(SIGALRM, &act, &oact) < 0)
-                ERR_OUT(SIGACT_ERROR);
-
-            if (setitimer(ITIMER_REAL, &myTimeout, 0) < 0)
-                ERR_OUT(SETITIMER_ERROR);
-        }
-
-        /* do main work */
-#ifndef NO_WOLFSSL_CLIENT
-        if (ssl->options.side == WOLFSSL_CLIENT_END)
-            ret = wolfSSL_connect(ssl);
-#endif
-#ifndef NO_WOLFSSL_SERVER
-        if (ssl->options.side == WOLFSSL_SERVER_END)
-            ret = wolfSSL_accept(ssl);
-#endif
-
-        /* do callbacks */
-        if (toCb) {
-            if (oldTimerOn) {
-                gettimeofday(&endTime, 0);
-                SubtractTimes(endTime, startTime, totalTime);
-                /* adjust old timer for elapsed time */
-                if (CmpTimes(totalTime, oldTimeout.it_value, <))
-                    SubtractTimes(oldTimeout.it_value, totalTime,
-                                  oldTimeout.it_value);
-                else {
-                    /* reset value to interval, may be off */
-                    oldTimeout.it_value.tv_sec = oldTimeout.it_interval.tv_sec;
-                    oldTimeout.it_value.tv_usec =oldTimeout.it_interval.tv_usec;
-                }
-                /* keep iter the same whether there or not */
-            }
-            /* restore old handler */
-            if (sigaction(SIGALRM, &oact, 0) < 0)
-                ret = SIGACT_ERROR;    /* more pressing error, stomp */
-            else
-                /* use old settings which may turn off (expired or not there) */
-                if (setitimer(ITIMER_REAL, &oldTimeout, 0) < 0)
-                    ret = SETITIMER_ERROR;
-
-            /* if we had a timeout call callback */
-            if (ssl->timeoutInfo.timeoutName[0]) {
-                ssl->timeoutInfo.timeoutValue.tv_sec  = timeout.tv_sec;
-                ssl->timeoutInfo.timeoutValue.tv_usec = timeout.tv_usec;
-                (toCb)(&ssl->timeoutInfo);
-            }
-            /* clean up */
-            FreeTimeoutInfo(&ssl->timeoutInfo, ssl->heap);
-            ssl->toInfoOn = 0;
-        }
-        if (hsCb) {
-            FinishHandShakeInfo(&ssl->handShakeInfo, ssl);
-            (hsCb)(&ssl->handShakeInfo);
-            ssl->hsInfoOn = 0;
-        }
-        return ret;
-    }
-
-
-#ifndef NO_WOLFSSL_CLIENT
-
-    int wolfSSL_connect_ex(WOLFSSL* ssl, HandShakeCallBack hsCb,
-                          TimeoutCallBack toCb, Timeval timeout)
-    {
-        WOLFSSL_ENTER("wolfSSL_connect_ex");
-        return wolfSSL_ex_wrapper(ssl, hsCb, toCb, timeout);
-    }
-
-#endif
-
-
-#ifndef NO_WOLFSSL_SERVER
-
-    int wolfSSL_accept_ex(WOLFSSL* ssl, HandShakeCallBack hsCb,
-                         TimeoutCallBack toCb,Timeval timeout)
-    {
-        WOLFSSL_ENTER("wolfSSL_accept_ex");
-        return wolfSSL_ex_wrapper(ssl, hsCb, toCb, timeout);
-    }
-
-#endif
-
-#endif /* WOLFSSL_CALLBACKS */
-
-
-#ifndef NO_PSK
-
-    void wolfSSL_CTX_set_psk_client_callback(WOLFSSL_CTX* ctx,
-                                         psk_client_callback cb)
-    {
-        WOLFSSL_ENTER("SSL_CTX_set_psk_client_callback");
-        ctx->havePSK = 1;
-        ctx->client_psk_cb = cb;
-    }
-
-
-    void wolfSSL_set_psk_client_callback(WOLFSSL* ssl, psk_client_callback cb)
-    {
-        byte haveRSA = 1;
-
-        WOLFSSL_ENTER("SSL_set_psk_client_callback");
-        ssl->options.havePSK = 1;
-        ssl->options.client_psk_cb = cb;
-
-        #ifdef NO_RSA
-            haveRSA = 0;
-        #endif
-        InitSuites(ssl->suites, ssl->version, haveRSA, TRUE,
-                   ssl->options.haveDH, ssl->options.haveNTRU,
-                   ssl->options.haveECDSAsig, ssl->options.haveStaticECC,
-                   ssl->options.side);
-    }
-
-
-    void wolfSSL_CTX_set_psk_server_callback(WOLFSSL_CTX* ctx,
-                                         psk_server_callback cb)
-    {
-        WOLFSSL_ENTER("SSL_CTX_set_psk_server_callback");
-        ctx->havePSK = 1;
-        ctx->server_psk_cb = cb;
-    }
-
-
-    void wolfSSL_set_psk_server_callback(WOLFSSL* ssl, psk_server_callback cb)
-    {
-        byte haveRSA = 1;
-
-        WOLFSSL_ENTER("SSL_set_psk_server_callback");
-        ssl->options.havePSK = 1;
-        ssl->options.server_psk_cb = cb;
-
-        #ifdef NO_RSA
-            haveRSA = 0;
-        #endif
-        InitSuites(ssl->suites, ssl->version, haveRSA, TRUE,
-                   ssl->options.haveDH, ssl->options.haveNTRU,
-                   ssl->options.haveECDSAsig, ssl->options.haveStaticECC,
-                   ssl->options.side);
-    }
-
-
-    const char* wolfSSL_get_psk_identity_hint(const WOLFSSL* ssl)
-    {
-        WOLFSSL_ENTER("SSL_get_psk_identity_hint");
-
-        if (ssl == NULL || ssl->arrays == NULL)
-            return NULL;
-
-        return ssl->arrays->server_hint;
-    }
-
-
-    const char* wolfSSL_get_psk_identity(const WOLFSSL* ssl)
-    {
-        WOLFSSL_ENTER("SSL_get_psk_identity");
-
-        if (ssl == NULL || ssl->arrays == NULL)
-            return NULL;
-
-        return ssl->arrays->client_identity;
-    }
-
-
-    int wolfSSL_CTX_use_psk_identity_hint(WOLFSSL_CTX* ctx, const char* hint)
-    {
-        WOLFSSL_ENTER("SSL_CTX_use_psk_identity_hint");
-        if (hint == 0)
-            ctx->server_hint[0] = 0;
-        else {
-            XSTRNCPY(ctx->server_hint, hint, MAX_PSK_ID_LEN);
-            ctx->server_hint[MAX_PSK_ID_LEN - 1] = '\0';
-        }
-        return SSL_SUCCESS;
-    }
-
-
-    int wolfSSL_use_psk_identity_hint(WOLFSSL* ssl, const char* hint)
-    {
-        WOLFSSL_ENTER("SSL_use_psk_identity_hint");
-
-        if (ssl == NULL || ssl->arrays == NULL)
-            return SSL_FAILURE;
-
-        if (hint == 0)
-            ssl->arrays->server_hint[0] = 0;
-        else {
-            XSTRNCPY(ssl->arrays->server_hint, hint, MAX_PSK_ID_LEN);
-            ssl->arrays->server_hint[MAX_PSK_ID_LEN - 1] = '\0';
-        }
-        return SSL_SUCCESS;
-    }
-
-#endif /* NO_PSK */
-
-
-#ifdef HAVE_ANON
-
-    int wolfSSL_CTX_allow_anon_cipher(WOLFSSL_CTX* ctx)
-    {
-        WOLFSSL_ENTER("wolfSSL_CTX_allow_anon_cipher");
-
-        if (ctx == NULL)
-            return SSL_FAILURE;
-
-        ctx->haveAnon = 1;
-
-        return SSL_SUCCESS;
-    }
-
-#endif /* HAVE_ANON */
-
-
-#ifndef NO_CERTS
-/* used to be defined on NO_FILESYSTEM only, but are generally useful */
-
-    /* wolfSSL extension allows DER files to be loaded from buffers as well */
-    int wolfSSL_CTX_load_verify_buffer(WOLFSSL_CTX* ctx, const unsigned char* in,
-                                      long sz, int format)
-    {
-        WOLFSSL_ENTER("wolfSSL_CTX_load_verify_buffer");
-        if (format == SSL_FILETYPE_PEM)
-            return ProcessChainBuffer(ctx, in, sz, format, CA_TYPE, NULL);
-        else
-            return ProcessBuffer(ctx, in, sz, format, CA_TYPE, NULL,NULL,0);
-    }
-
-
-    int wolfSSL_CTX_use_certificate_buffer(WOLFSSL_CTX* ctx,
-                                 const unsigned char* in, long sz, int format)
-    {
-        WOLFSSL_ENTER("wolfSSL_CTX_use_certificate_buffer");
-        return ProcessBuffer(ctx, in, sz, format, CERT_TYPE, NULL, NULL, 0);
-    }
-
-
-    int wolfSSL_CTX_use_PrivateKey_buffer(WOLFSSL_CTX* ctx,
-                                 const unsigned char* in, long sz, int format)
-    {
-        WOLFSSL_ENTER("wolfSSL_CTX_use_PrivateKey_buffer");
-        return ProcessBuffer(ctx, in, sz, format, PRIVATEKEY_TYPE, NULL,NULL,0);
-    }
-
-
-    int wolfSSL_CTX_use_certificate_chain_buffer(WOLFSSL_CTX* ctx,
-                                 const unsigned char* in, long sz)
-    {
-        WOLFSSL_ENTER("wolfSSL_CTX_use_certificate_chain_buffer");
-        return ProcessBuffer(ctx, in, sz, SSL_FILETYPE_PEM, CERT_TYPE, NULL,
-                             NULL, 1);
-    }
-
-    int wolfSSL_use_certificate_buffer(WOLFSSL* ssl,
-                                 const unsigned char* in, long sz, int format)
-    {
-        WOLFSSL_ENTER("wolfSSL_use_certificate_buffer");
-        return ProcessBuffer(ssl->ctx, in, sz, format,CERT_TYPE,ssl,NULL,0);
-    }
-
-
-    int wolfSSL_use_PrivateKey_buffer(WOLFSSL* ssl,
-                                 const unsigned char* in, long sz, int format)
-    {
-        WOLFSSL_ENTER("wolfSSL_use_PrivateKey_buffer");
-        return ProcessBuffer(ssl->ctx, in, sz, format, PRIVATEKEY_TYPE,
-                             ssl, NULL, 0);
-    }
-
-
-    int wolfSSL_use_certificate_chain_buffer(WOLFSSL* ssl,
-                                 const unsigned char* in, long sz)
-    {
-        WOLFSSL_ENTER("wolfSSL_use_certificate_chain_buffer");
-        return ProcessBuffer(ssl->ctx, in, sz, SSL_FILETYPE_PEM, CERT_TYPE,
-                             ssl, NULL, 1);
-    }
-
-
-    /* unload any certs or keys that SSL owns, leave CTX as is
-       SSL_SUCCESS on ok */
-    int wolfSSL_UnloadCertsKeys(WOLFSSL* ssl)
-    {
-        if (ssl == NULL) {
-            WOLFSSL_MSG("Null function arg");
-            return BAD_FUNC_ARG;
-        }
-
-        if (ssl->buffers.weOwnCert) {
-            WOLFSSL_MSG("Unloading cert");
-            XFREE(ssl->buffers.certificate.buffer, ssl->heap,DYNAMIC_TYPE_CERT);
-            ssl->buffers.weOwnCert = 0;
-            ssl->buffers.certificate.length = 0;
-            ssl->buffers.certificate.buffer = NULL;
-        }
-
-        if (ssl->buffers.weOwnCertChain) {
-            WOLFSSL_MSG("Unloading cert chain");
-            XFREE(ssl->buffers.certChain.buffer, ssl->heap,DYNAMIC_TYPE_CERT);
-            ssl->buffers.weOwnCertChain = 0;
-            ssl->buffers.certChain.length = 0;
-            ssl->buffers.certChain.buffer = NULL;
-        }
-
-        if (ssl->buffers.weOwnKey) {
-            WOLFSSL_MSG("Unloading key");
-            XFREE(ssl->buffers.key.buffer, ssl->heap, DYNAMIC_TYPE_KEY);
-            ssl->buffers.weOwnKey = 0;
-            ssl->buffers.key.length = 0;
-            ssl->buffers.key.buffer = NULL;
-        }
-
-        return SSL_SUCCESS;
-    }
-
-
-    int wolfSSL_CTX_UnloadCAs(WOLFSSL_CTX* ctx)
-    {
-        WOLFSSL_ENTER("wolfSSL_CTX_UnloadCAs");
-
-        if (ctx == NULL)
-            return BAD_FUNC_ARG;
-
-        return wolfSSL_CertManagerUnloadCAs(ctx->cm);
-    }
-
-/* old NO_FILESYSTEM end */
-#endif /* !NO_CERTS */
-
-
-#if defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS)
-
-
-    int wolfSSL_add_all_algorithms(void)
-    {
-        WOLFSSL_ENTER("wolfSSL_add_all_algorithms");
-        wolfSSL_Init();
-        return SSL_SUCCESS;
-    }
-
-
-    long wolfSSL_CTX_sess_set_cache_size(WOLFSSL_CTX* ctx, long sz)
-    {
-        /* cache size fixed at compile time in wolfSSL */
-        (void)ctx;
-        (void)sz;
-        return 0;
-    }
-
-
-    void wolfSSL_CTX_set_quiet_shutdown(WOLFSSL_CTX* ctx, int mode)
-    {
-        WOLFSSL_ENTER("wolfSSL_CTX_set_quiet_shutdown");
-        if (mode)
-            ctx->quietShutdown = 1;
-    }
-
-
-    void wolfSSL_set_quiet_shutdown(WOLFSSL* ssl, int mode)
-    {
-        WOLFSSL_ENTER("wolfSSL_CTX_set_quiet_shutdown");
-        if (mode)
-            ssl->options.quietShutdown = 1;
-    }
-
-
-    void wolfSSL_set_bio(WOLFSSL* ssl, WOLFSSL_BIO* rd, WOLFSSL_BIO* wr)
-    {
-        WOLFSSL_ENTER("SSL_set_bio");
-        wolfSSL_set_rfd(ssl, rd->fd);
-        wolfSSL_set_wfd(ssl, wr->fd);
-
-        ssl->biord = rd;
-        ssl->biowr = wr;
-    }
-
-
-    void wolfSSL_CTX_set_client_CA_list(WOLFSSL_CTX* ctx,
-                                       STACK_OF(WOLFSSL_X509_NAME)* names)
-    {
-        (void)ctx;
-        (void)names;
-    }
-
-
-    STACK_OF(WOLFSSL_X509_NAME)* wolfSSL_load_client_CA_file(const char* fname)
-    {
-        (void)fname;
-        return 0;
-    }
-
-
-    int wolfSSL_CTX_set_default_verify_paths(WOLFSSL_CTX* ctx)
-    {
-        /* TODO:, not needed in goahead */
-        (void)ctx;
-        return SSL_NOT_IMPLEMENTED;
-    }
-
-
-    /* keyblock size in bytes or -1 */
-    int wolfSSL_get_keyblock_size(WOLFSSL* ssl)
-    {
-        if (ssl == NULL)
-            return SSL_FATAL_ERROR;
-
-        return 2 * (ssl->specs.key_size + ssl->specs.iv_size +
-                    ssl->specs.hash_size);
-    }
-
-
-    /* store keys returns SSL_SUCCESS or -1 on error */
-    int wolfSSL_get_keys(WOLFSSL* ssl, unsigned char** ms, unsigned int* msLen,
-                                     unsigned char** sr, unsigned int* srLen,
-                                     unsigned char** cr, unsigned int* crLen)
-    {
-        if (ssl == NULL || ssl->arrays == NULL)
-            return SSL_FATAL_ERROR;
-
-        *ms = ssl->arrays->masterSecret;
-        *sr = ssl->arrays->serverRandom;
-        *cr = ssl->arrays->clientRandom;
-
-        *msLen = SECRET_LEN;
-        *srLen = RAN_LEN;
-        *crLen = RAN_LEN;
-
-        return SSL_SUCCESS;
-    }
-
-
-    void wolfSSL_set_accept_state(WOLFSSL* ssl)
-    {
-        byte haveRSA = 1;
-        byte havePSK = 0;
-
-        WOLFSSL_ENTER("SSL_set_accept_state");
-        ssl->options.side = WOLFSSL_SERVER_END;
-        /* reset suites in case user switched */
-
-        #ifdef NO_RSA
-            haveRSA = 0;
-        #endif
-        #ifndef NO_PSK
-            havePSK = ssl->options.havePSK;
-        #endif
-        InitSuites(ssl->suites, ssl->version, haveRSA, havePSK,
-                   ssl->options.haveDH, ssl->options.haveNTRU,
-                   ssl->options.haveECDSAsig, ssl->options.haveStaticECC,
-                   ssl->options.side);
-    }
-#endif
-
-    /* return true if connection established */
-    int wolfSSL_is_init_finished(WOLFSSL* ssl)
-    {
-        if (ssl == NULL)
-            return 0;
-
-        if (ssl->options.handShakeState == HANDSHAKE_DONE)
-            return 1;
-
-        return 0;
-    }
-
-#if defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS)
-    void wolfSSL_CTX_set_tmp_rsa_callback(WOLFSSL_CTX* ctx,
-                                      WOLFSSL_RSA*(*f)(WOLFSSL*, int, int))
-    {
-        /* wolfSSL verifies all these internally */
-        (void)ctx;
-        (void)f;
-    }
-
-
-    void wolfSSL_set_shutdown(WOLFSSL* ssl, int opt)
-    {
-        (void)ssl;
-        (void)opt;
-    }
-
-
-    long wolfSSL_CTX_set_options(WOLFSSL_CTX* ctx, long opt)
-    {
-        /* goahead calls with 0, do nothing */
-        WOLFSSL_ENTER("SSL_CTX_set_options");
-        (void)ctx;
-        return opt;
-    }
-
-
-    int wolfSSL_set_rfd(WOLFSSL* ssl, int rfd)
-    {
-        WOLFSSL_ENTER("SSL_set_rfd");
-        ssl->rfd = rfd;      /* not used directly to allow IO callbacks */
-
-        ssl->IOCB_ReadCtx  = &ssl->rfd;
-
-        return SSL_SUCCESS;
-    }
-
-
-    int wolfSSL_set_wfd(WOLFSSL* ssl, int wfd)
-    {
-        WOLFSSL_ENTER("SSL_set_wfd");
-        ssl->wfd = wfd;      /* not used directly to allow IO callbacks */
-
-        ssl->IOCB_WriteCtx  = &ssl->wfd;
-
-        return SSL_SUCCESS;
-    }
-
-
-    WOLFSSL_RSA* wolfSSL_RSA_generate_key(int len, unsigned long bits,
-                                          void(*f)(int, int, void*), void* data)
-    {
-        /* no tmp key needed, actual generation not supported */
-        WOLFSSL_ENTER("RSA_generate_key");
-        (void)len;
-        (void)bits;
-        (void)f;
-        (void)data;
-        return NULL;
-    }
-
-
-
-    WOLFSSL_X509* wolfSSL_X509_STORE_CTX_get_current_cert(
-                                                     WOLFSSL_X509_STORE_CTX* ctx)
-    {
-        (void)ctx;
-        return 0;
-    }
-
-
-    int wolfSSL_X509_STORE_CTX_get_error(WOLFSSL_X509_STORE_CTX* ctx)
-    {
-        if (ctx != NULL)
-            return ctx->error;
-        return 0;
-    }
-
-
-    int wolfSSL_X509_STORE_CTX_get_error_depth(WOLFSSL_X509_STORE_CTX* ctx)
-    {
-        (void)ctx;
-        return 0;
-    }
-
-
-    WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_buffer(void)
-    {
-        static WOLFSSL_BIO_METHOD meth;
-
-        WOLFSSL_ENTER("BIO_f_buffer");
-        meth.type = BIO_BUFFER;
-
-        return &meth;
-    }
-
-
-    long wolfSSL_BIO_set_write_buffer_size(WOLFSSL_BIO* bio, long size)
-    {
-        /* wolfSSL has internal buffer, compatibility only */
-        WOLFSSL_ENTER("BIO_set_write_buffer_size");
-        (void)bio;
-        return size;
-    }
-
-
-    WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_ssl(void)
-    {
-        static WOLFSSL_BIO_METHOD meth;
-
-        WOLFSSL_ENTER("BIO_f_ssl");
-        meth.type = BIO_SSL;
-
-        return &meth;
-    }
-
-
-    WOLFSSL_BIO* wolfSSL_BIO_new_socket(int sfd, int closeF)
-    {
-        WOLFSSL_BIO* bio = (WOLFSSL_BIO*) XMALLOC(sizeof(WOLFSSL_BIO), 0,
-                                                DYNAMIC_TYPE_OPENSSL);
-
-        WOLFSSL_ENTER("BIO_new_socket");
-        if (bio) {
-            bio->type  = BIO_SOCKET;
-            bio->close = (byte)closeF;
-            bio->eof   = 0;
-            bio->ssl   = 0;
-            bio->fd    = sfd;
-            bio->prev  = 0;
-            bio->next  = 0;
-            bio->mem   = NULL;
-            bio->memLen = 0;
-        }
-        return bio;
-    }
-
-
-    int wolfSSL_BIO_eof(WOLFSSL_BIO* b)
-    {
-        WOLFSSL_ENTER("BIO_eof");
-        if (b->eof)
-            return 1;
-
-        return 0;
-    }
-
-
-    long wolfSSL_BIO_set_ssl(WOLFSSL_BIO* b, WOLFSSL* ssl, int closeF)
-    {
-        WOLFSSL_ENTER("BIO_set_ssl");
-        b->ssl   = ssl;
-        b->close = (byte)closeF;
-    /* add to ssl for bio free if SSL_free called before/instead of free_all? */
-
-        return 0;
-    }
-
-
-    WOLFSSL_BIO* wolfSSL_BIO_new(WOLFSSL_BIO_METHOD* method)
-    {
-        WOLFSSL_BIO* bio = (WOLFSSL_BIO*) XMALLOC(sizeof(WOLFSSL_BIO), 0,
-                                                DYNAMIC_TYPE_OPENSSL);
-        WOLFSSL_ENTER("BIO_new");
-        if (bio) {
-            bio->type   = method->type;
-            bio->close  = 0;
-            bio->eof    = 0;
-            bio->ssl    = NULL;
-            bio->mem    = NULL;
-            bio->memLen = 0;
-            bio->fd     = 0;
-            bio->prev   = NULL;
-            bio->next   = NULL;
-        }
-        return bio;
-    }
-
-
-    int wolfSSL_BIO_get_mem_data(WOLFSSL_BIO* bio, const byte** p)
-    {
-        if (bio == NULL || p == NULL)
-            return SSL_FATAL_ERROR;
-
-        *p = bio->mem;
-
-        return bio->memLen;
-    }
-
-
-    WOLFSSL_BIO* wolfSSL_BIO_new_mem_buf(void* buf, int len)
-    {
-        WOLFSSL_BIO* bio = NULL;
-        if (buf == NULL)
-            return bio;
-
-        bio = wolfSSL_BIO_new(wolfSSL_BIO_s_mem());
-        if (bio == NULL)
-            return bio;
-
-        bio->memLen = len;
-        bio->mem    = (byte*)XMALLOC(len, 0, DYNAMIC_TYPE_OPENSSL);
-        if (bio->mem == NULL) {
-            XFREE(bio, 0, DYNAMIC_TYPE_OPENSSL);
-            return NULL;
-        }
-
-        XMEMCPY(bio->mem, buf, len);
-
-        return bio;
-    }
-
-
-#ifdef USE_WINDOWS_API
-    #define CloseSocket(s) closesocket(s)
-#elif defined(WOLFSSL_MDK_ARM)
-    #define CloseSocket(s) closesocket(s)
-    extern int closesocket(int) ;
-#else
-    #define CloseSocket(s) close(s)
-#endif
-
-    int wolfSSL_BIO_free(WOLFSSL_BIO* bio)
-    {
-        /* unchain?, doesn't matter in goahead since from free all */
-        WOLFSSL_ENTER("BIO_free");
-        if (bio) {
-            if (bio->close) {
-                if (bio->ssl)
-                    wolfSSL_free(bio->ssl);
-                if (bio->fd)
-                    CloseSocket(bio->fd);
-            }
-            if (bio->mem)
-                XFREE(bio->mem, 0, DYNAMIC_TYPE_OPENSSL);
-            XFREE(bio, 0, DYNAMIC_TYPE_OPENSSL);
-        }
-        return 0;
-    }
-
-
-    int wolfSSL_BIO_free_all(WOLFSSL_BIO* bio)
-    {
-        WOLFSSL_ENTER("BIO_free_all");
-        while (bio) {
-            WOLFSSL_BIO* next = bio->next;
-            wolfSSL_BIO_free(bio);
-            bio = next;
-        }
-        return 0;
-    }
-
-
-    int wolfSSL_BIO_read(WOLFSSL_BIO* bio, void* buf, int len)
-    {
-        int  ret;
-        WOLFSSL* ssl = 0;
-        WOLFSSL_BIO* front = bio;
-
-        WOLFSSL_ENTER("BIO_read");
-        /* already got eof, again is error */
-        if (front->eof)
-            return SSL_FATAL_ERROR;
-
-        while(bio && ((ssl = bio->ssl) == 0) )
-            bio = bio->next;
-
-        if (ssl == 0) return BAD_FUNC_ARG;
-
-        ret = wolfSSL_read(ssl, buf, len);
-        if (ret == 0)
-            front->eof = 1;
-        else if (ret < 0) {
-            int err = wolfSSL_get_error(ssl, 0);
-            if ( !(err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) )
-                front->eof = 1;
-        }
-        return ret;
-    }
-
-
-    int wolfSSL_BIO_write(WOLFSSL_BIO* bio, const void* data, int len)
-    {
-        int  ret;
-        WOLFSSL* ssl = 0;
-        WOLFSSL_BIO* front = bio;
-
-        WOLFSSL_ENTER("BIO_write");
-        /* already got eof, again is error */
-        if (front->eof)
-            return SSL_FATAL_ERROR;
-
-        while(bio && ((ssl = bio->ssl) == 0) )
-            bio = bio->next;
-
-        if (ssl == 0) return BAD_FUNC_ARG;
-
-        ret = wolfSSL_write(ssl, data, len);
-        if (ret == 0)
-            front->eof = 1;
-        else if (ret < 0) {
-            int err = wolfSSL_get_error(ssl, 0);
-            if ( !(err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) )
-                front->eof = 1;
-        }
-
-        return ret;
-    }
-
-
-    WOLFSSL_BIO* wolfSSL_BIO_push(WOLFSSL_BIO* top, WOLFSSL_BIO* append)
-    {
-        WOLFSSL_ENTER("BIO_push");
-        top->next    = append;
-        append->prev = top;
-
-        return top;
-    }
-
-
-    int wolfSSL_BIO_flush(WOLFSSL_BIO* bio)
-    {
-        /* for wolfSSL no flushing needed */
-        WOLFSSL_ENTER("BIO_flush");
-        (void)bio;
-        return 1;
-    }
-
-
-#endif /* OPENSSL_EXTRA || GOAHEAD_WS */
-
-
-#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
-
-    void wolfSSL_CTX_set_default_passwd_cb_userdata(WOLFSSL_CTX* ctx,
-                                                   void* userdata)
-    {
-        WOLFSSL_ENTER("SSL_CTX_set_default_passwd_cb_userdata");
-        ctx->userdata = userdata;
-    }
-
-
-    void wolfSSL_CTX_set_default_passwd_cb(WOLFSSL_CTX* ctx, pem_password_cb cb)
-    {
-        WOLFSSL_ENTER("SSL_CTX_set_default_passwd_cb");
-        ctx->passwd_cb = cb;
-    }
-
-    int wolfSSL_num_locks(void)
-    {
-        return 0;
-    }
-
-    void wolfSSL_set_locking_callback(void (*f)(int, int, const char*, int))
-    {
-        (void)f;
-    }
-
-    void wolfSSL_set_id_callback(unsigned long (*f)(void))
-    {
-        (void)f;
-    }
-
-    unsigned long wolfSSL_ERR_get_error(void)
-    {
-        /* TODO: */
-        return 0;
-    }
-
-#ifndef NO_MD5
-
-    int wolfSSL_EVP_BytesToKey(const WOLFSSL_EVP_CIPHER* type,
-                       const WOLFSSL_EVP_MD* md, const byte* salt,
-                       const byte* data, int sz, int count, byte* key, byte* iv)
-    {
-        int  keyLen = 0;
-        int  ivLen  = 0;
-        int  j;
-        int  keyLeft;
-        int  ivLeft;
-        int  keyOutput = 0;
-        byte digest[MD5_DIGEST_SIZE];
-    #ifdef WOLFSSL_SMALL_STACK
-        Md5* md5 = NULL;
-    #else
-        Md5  md5[1];
-    #endif
-
-    #ifdef WOLFSSL_SMALL_STACK
-        md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (md5 == NULL)
-            return 0;
-    #endif
-
-        WOLFSSL_ENTER("EVP_BytesToKey");
-        wc_InitMd5(md5);
-
-        /* only support MD5 for now */
-        if (XSTRNCMP(md, "MD5", 3) != 0) return 0;
-
-        /* only support CBC DES and AES for now */
-        if (XSTRNCMP(type, "DES-CBC", 7) == 0) {
-            keyLen = DES_KEY_SIZE;
-            ivLen  = DES_IV_SIZE;
-        }
-        else if (XSTRNCMP(type, "DES-EDE3-CBC", 12) == 0) {
-            keyLen = DES3_KEY_SIZE;
-            ivLen  = DES_IV_SIZE;
-        }
-        else if (XSTRNCMP(type, "AES-128-CBC", 11) == 0) {
-            keyLen = AES_128_KEY_SIZE;
-            ivLen  = AES_IV_SIZE;
-        }
-        else if (XSTRNCMP(type, "AES-192-CBC", 11) == 0) {
-            keyLen = AES_192_KEY_SIZE;
-            ivLen  = AES_IV_SIZE;
-        }
-        else if (XSTRNCMP(type, "AES-256-CBC", 11) == 0) {
-            keyLen = AES_256_KEY_SIZE;
-            ivLen  = AES_IV_SIZE;
-        }
-        else {
-        #ifdef WOLFSSL_SMALL_STACK
-            XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        #endif
-            return 0;
-        }
-
-        keyLeft   = keyLen;
-        ivLeft    = ivLen;
-
-        while (keyOutput < (keyLen + ivLen)) {
-            int digestLeft = MD5_DIGEST_SIZE;
-            /* D_(i - 1) */
-            if (keyOutput)                      /* first time D_0 is empty */
-                wc_Md5Update(md5, digest, MD5_DIGEST_SIZE);
-            /* data */
-            wc_Md5Update(md5, data, sz);
-            /* salt */
-            if (salt)
-                wc_Md5Update(md5, salt, EVP_SALT_SIZE);
-            wc_Md5Final(md5, digest);
-            /* count */
-            for (j = 1; j < count; j++) {
-                wc_Md5Update(md5, digest, MD5_DIGEST_SIZE);
-                wc_Md5Final(md5, digest);
-            }
-
-            if (keyLeft) {
-                int store = min(keyLeft, MD5_DIGEST_SIZE);
-                XMEMCPY(&key[keyLen - keyLeft], digest, store);
-
-                keyOutput  += store;
-                keyLeft    -= store;
-                digestLeft -= store;
-            }
-
-            if (ivLeft && digestLeft) {
-                int store = min(ivLeft, digestLeft);
-                XMEMCPY(&iv[ivLen - ivLeft], &digest[MD5_DIGEST_SIZE -
-                                                    digestLeft], store);
-                keyOutput += store;
-                ivLeft    -= store;
-            }
-        }
-
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-
-        return keyOutput == (keyLen + ivLen) ? keyOutput : 0;
-    }
-
-#endif /* NO_MD5 */
-
-#endif /* OPENSSL_EXTRA || HAVE_WEBSERVER */
-
-
-#ifdef OPENSSL_EXTRA
-
-    unsigned long wolfSSLeay(void)
-    {
-        return SSLEAY_VERSION_NUMBER;
-    }
-
-
-    const char* wolfSSLeay_version(int type)
-    {
-        static const char* version = "SSLeay wolfSSL compatibility";
-        (void)type;
-        return version;
-    }
-
-
-#ifndef NO_MD5
-    void wolfSSL_MD5_Init(WOLFSSL_MD5_CTX* md5)
-    {
-        typedef char md5_test[sizeof(MD5_CTX) >= sizeof(Md5) ? 1 : -1];
-        (void)sizeof(md5_test);
-
-        WOLFSSL_ENTER("MD5_Init");
-        wc_InitMd5((Md5*)md5);
-    }
-
-
-    void wolfSSL_MD5_Update(WOLFSSL_MD5_CTX* md5, const void* input,
-                           unsigned long sz)
-    {
-        WOLFSSL_ENTER("wolfSSL_MD5_Update");
-        wc_Md5Update((Md5*)md5, (const byte*)input, (word32)sz);
-    }
-
-
-    void wolfSSL_MD5_Final(byte* input, WOLFSSL_MD5_CTX* md5)
-    {
-        WOLFSSL_ENTER("MD5_Final");
-        wc_Md5Final((Md5*)md5, input);
-    }
-#endif /* NO_MD5 */
-
-
-#ifndef NO_SHA
-    void wolfSSL_SHA_Init(WOLFSSL_SHA_CTX* sha)
-    {
-        typedef char sha_test[sizeof(SHA_CTX) >= sizeof(Sha) ? 1 : -1];
-        (void)sizeof(sha_test);
-
-        WOLFSSL_ENTER("SHA_Init");
-        wc_InitSha((Sha*)sha);  /* OpenSSL compat, no ret */
-    }
-
-
-    void wolfSSL_SHA_Update(WOLFSSL_SHA_CTX* sha, const void* input,
-                           unsigned long sz)
-    {
-        WOLFSSL_ENTER("SHA_Update");
-        wc_ShaUpdate((Sha*)sha, (const byte*)input, (word32)sz);
-    }
-
-
-    void wolfSSL_SHA_Final(byte* input, WOLFSSL_SHA_CTX* sha)
-    {
-        WOLFSSL_ENTER("SHA_Final");
-        wc_ShaFinal((Sha*)sha, input);
-    }
-
-
-    void wolfSSL_SHA1_Init(WOLFSSL_SHA_CTX* sha)
-    {
-        WOLFSSL_ENTER("SHA1_Init");
-        SHA_Init(sha);
-    }
-
-
-    void wolfSSL_SHA1_Update(WOLFSSL_SHA_CTX* sha, const void* input,
-                            unsigned long sz)
-    {
-        WOLFSSL_ENTER("SHA1_Update");
-        SHA_Update(sha, input, sz);
-    }
-
-
-    void wolfSSL_SHA1_Final(byte* input, WOLFSSL_SHA_CTX* sha)
-    {
-        WOLFSSL_ENTER("SHA1_Final");
-        SHA_Final(input, sha);
-    }
-#endif /* NO_SHA */
-
-
-    void wolfSSL_SHA256_Init(WOLFSSL_SHA256_CTX* sha256)
-    {
-        typedef char sha_test[sizeof(SHA256_CTX) >= sizeof(Sha256) ? 1 : -1];
-        (void)sizeof(sha_test);
-
-        WOLFSSL_ENTER("SHA256_Init");
-        wc_InitSha256((Sha256*)sha256);  /* OpenSSL compat, no error */
-    }
-
-
-    void wolfSSL_SHA256_Update(WOLFSSL_SHA256_CTX* sha, const void* input,
-                              unsigned long sz)
-    {
-        WOLFSSL_ENTER("SHA256_Update");
-        wc_Sha256Update((Sha256*)sha, (const byte*)input, (word32)sz);
-        /* OpenSSL compat, no error */
-    }
-
-
-    void wolfSSL_SHA256_Final(byte* input, WOLFSSL_SHA256_CTX* sha)
-    {
-        WOLFSSL_ENTER("SHA256_Final");
-        wc_Sha256Final((Sha256*)sha, input);
-        /* OpenSSL compat, no error */
-    }
-
-
-    #ifdef WOLFSSL_SHA384
-
-    void wolfSSL_SHA384_Init(WOLFSSL_SHA384_CTX* sha)
-    {
-        typedef char sha_test[sizeof(SHA384_CTX) >= sizeof(Sha384) ? 1 : -1];
-        (void)sizeof(sha_test);
-
-        WOLFSSL_ENTER("SHA384_Init");
-        wc_InitSha384((Sha384*)sha);   /* OpenSSL compat, no error */
-    }
-
-
-    void wolfSSL_SHA384_Update(WOLFSSL_SHA384_CTX* sha, const void* input,
-                           unsigned long sz)
-    {
-        WOLFSSL_ENTER("SHA384_Update");
-        wc_Sha384Update((Sha384*)sha, (const byte*)input, (word32)sz);
-        /* OpenSSL compat, no error */
-    }
-
-
-    void wolfSSL_SHA384_Final(byte* input, WOLFSSL_SHA384_CTX* sha)
-    {
-        WOLFSSL_ENTER("SHA384_Final");
-        wc_Sha384Final((Sha384*)sha, input);
-        /* OpenSSL compat, no error */
-    }
-
-    #endif /* WOLFSSL_SHA384 */
-
-
-   #ifdef WOLFSSL_SHA512
-
-    void wolfSSL_SHA512_Init(WOLFSSL_SHA512_CTX* sha)
-    {
-        typedef char sha_test[sizeof(SHA512_CTX) >= sizeof(Sha512) ? 1 : -1];
-        (void)sizeof(sha_test);
-
-        WOLFSSL_ENTER("SHA512_Init");
-        wc_InitSha512((Sha512*)sha);  /* OpenSSL compat, no error */
-    }
-
-
-    void wolfSSL_SHA512_Update(WOLFSSL_SHA512_CTX* sha, const void* input,
-                           unsigned long sz)
-    {
-        WOLFSSL_ENTER("SHA512_Update");
-        wc_Sha512Update((Sha512*)sha, (const byte*)input, (word32)sz);
-        /* OpenSSL compat, no error */
-    }
-
-
-    void wolfSSL_SHA512_Final(byte* input, WOLFSSL_SHA512_CTX* sha)
-    {
-        WOLFSSL_ENTER("SHA512_Final");
-        wc_Sha512Final((Sha512*)sha, input);
-        /* OpenSSL compat, no error */
-    }
-
-    #endif /* WOLFSSL_SHA512 */
-
-
-    #ifndef NO_MD5
-
-    const WOLFSSL_EVP_MD* wolfSSL_EVP_md5(void)
-    {
-        static const char* type = "MD5";
-        WOLFSSL_ENTER("EVP_md5");
-        return type;
-    }
-
-    #endif /* NO_MD5 */
-
-
-#ifndef NO_SHA
-    const WOLFSSL_EVP_MD* wolfSSL_EVP_sha1(void)
-    {
-        static const char* type = "SHA";
-        WOLFSSL_ENTER("EVP_sha1");
-        return type;
-    }
-#endif /* NO_SHA */
-
-
-    const WOLFSSL_EVP_MD* wolfSSL_EVP_sha256(void)
-    {
-        static const char* type = "SHA256";
-        WOLFSSL_ENTER("EVP_sha256");
-        return type;
-    }
-
-    #ifdef WOLFSSL_SHA384
-
-    const WOLFSSL_EVP_MD* wolfSSL_EVP_sha384(void)
-    {
-        static const char* type = "SHA384";
-        WOLFSSL_ENTER("EVP_sha384");
-        return type;
-    }
-
-    #endif /* WOLFSSL_SHA384 */
-
-    #ifdef WOLFSSL_SHA512
-
-    const WOLFSSL_EVP_MD* wolfSSL_EVP_sha512(void)
-    {
-        static const char* type = "SHA512";
-        WOLFSSL_ENTER("EVP_sha512");
-        return type;
-    }
-
-    #endif /* WOLFSSL_SHA512 */
-
-
-    void wolfSSL_EVP_MD_CTX_init(WOLFSSL_EVP_MD_CTX* ctx)
-    {
-        WOLFSSL_ENTER("EVP_CIPHER_MD_CTX_init");
-        (void)ctx;
-        /* do nothing */
-    }
-
-
-    const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_cbc(void)
-    {
-        static const char* type = "AES128-CBC";
-        WOLFSSL_ENTER("wolfSSL_EVP_aes_128_cbc");
-        return type;
-    }
-
-
-    const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_cbc(void)
-    {
-        static const char* type = "AES192-CBC";
-        WOLFSSL_ENTER("wolfSSL_EVP_aes_192_cbc");
-        return type;
-    }
-
-
-    const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_cbc(void)
-    {
-        static const char* type = "AES256-CBC";
-        WOLFSSL_ENTER("wolfSSL_EVP_aes_256_cbc");
-        return type;
-    }
-
-
-    const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_ctr(void)
-    {
-        static const char* type = "AES128-CTR";
-        WOLFSSL_ENTER("wolfSSL_EVP_aes_128_ctr");
-        return type;
-    }
-
-
-    const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_ctr(void)
-    {
-        static const char* type = "AES192-CTR";
-        WOLFSSL_ENTER("wolfSSL_EVP_aes_192_ctr");
-        return type;
-    }
-
-
-    const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_ctr(void)
-    {
-        static const char* type = "AES256-CTR";
-        WOLFSSL_ENTER("wolfSSL_EVP_aes_256_ctr");
-        return type;
-    }
-
-
-    const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_cbc(void)
-    {
-        static const char* type = "DES-CBC";
-        WOLFSSL_ENTER("wolfSSL_EVP_des_cbc");
-        return type;
-    }
-
-
-    const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_ede3_cbc(void)
-    {
-        static const char* type = "DES-EDE3-CBC";
-        WOLFSSL_ENTER("wolfSSL_EVP_des_ede3_cbc");
-        return type;
-    }
-
-
-    const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_rc4(void)
-    {
-        static const char* type = "ARC4";
-        WOLFSSL_ENTER("wolfSSL_EVP_rc4");
-        return type;
-    }
-
-
-    const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_enc_null(void)
-    {
-        static const char* type = "NULL";
-        WOLFSSL_ENTER("wolfSSL_EVP_enc_null");
-        return type;
-    }
-
-
-    int wolfSSL_EVP_MD_CTX_cleanup(WOLFSSL_EVP_MD_CTX* ctx)
-    {
-        WOLFSSL_ENTER("EVP_MD_CTX_cleanup");
-        (void)ctx;
-        return 0;
-    }
-
-
-
-    void wolfSSL_EVP_CIPHER_CTX_init(WOLFSSL_EVP_CIPHER_CTX* ctx)
-    {
-        WOLFSSL_ENTER("EVP_CIPHER_CTX_init");
-        if (ctx) {
-            ctx->cipherType = 0xff;   /* no init */
-            ctx->keyLen     = 0;
-            ctx->enc        = 1;      /* start in encrypt mode */
-        }
-    }
-
-
-    /* SSL_SUCCESS on ok */
-    int wolfSSL_EVP_CIPHER_CTX_cleanup(WOLFSSL_EVP_CIPHER_CTX* ctx)
-    {
-        WOLFSSL_ENTER("EVP_CIPHER_CTX_cleanup");
-        if (ctx) {
-            ctx->cipherType = 0xff;  /* no more init */
-            ctx->keyLen     = 0;
-        }
-
-        return SSL_SUCCESS;
-    }
-
-
-    /* SSL_SUCCESS on ok */
-    int  wolfSSL_EVP_CipherInit(WOLFSSL_EVP_CIPHER_CTX* ctx,
-                               const WOLFSSL_EVP_CIPHER* type, byte* key,
-                               byte* iv, int enc)
-    {
-#if defined(NO_AES) && defined(NO_DES3)
-        (void)iv;
-        (void)enc;
-#else
-        int ret = 0;
-#endif
-
-        WOLFSSL_ENTER("wolfSSL_EVP_CipherInit");
-        if (ctx == NULL) {
-            WOLFSSL_MSG("no ctx");
-            return 0;   /* failure */
-        }
-
-        if (type == NULL && ctx->cipherType == 0xff) {
-            WOLFSSL_MSG("no type set");
-            return 0;   /* failure */
-        }
-
-#ifndef NO_AES
-        if (ctx->cipherType == AES_128_CBC_TYPE || (type &&
-                                       XSTRNCMP(type, "AES128-CBC", 10) == 0)) {
-            WOLFSSL_MSG("AES-128-CBC");
-            ctx->cipherType = AES_128_CBC_TYPE;
-            ctx->keyLen     = 16;
-            if (enc == 0 || enc == 1)
-                ctx->enc = enc ? 1 : 0;
-            if (key) {
-                ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv,
-                                ctx->enc ? AES_ENCRYPTION : AES_DECRYPTION);
-                if (ret != 0)
-                    return ret;
-            }
-            if (iv && key == NULL) {
-                ret = wc_AesSetIV(&ctx->cipher.aes, iv);
-                if (ret != 0)
-                    return ret;
-            }
-        }
-        else if (ctx->cipherType == AES_192_CBC_TYPE || (type &&
-                                       XSTRNCMP(type, "AES192-CBC", 10) == 0)) {
-            WOLFSSL_MSG("AES-192-CBC");
-            ctx->cipherType = AES_192_CBC_TYPE;
-            ctx->keyLen     = 24;
-            if (enc == 0 || enc == 1)
-                ctx->enc = enc ? 1 : 0;
-            if (key) {
-                ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv,
-                                ctx->enc ? AES_ENCRYPTION : AES_DECRYPTION);
-                if (ret != 0)
-                    return ret;
-            }
-            if (iv && key == NULL) {
-                ret = wc_AesSetIV(&ctx->cipher.aes, iv);
-                if (ret != 0)
-                    return ret;
-            }
-        }
-        else if (ctx->cipherType == AES_256_CBC_TYPE || (type &&
-                                       XSTRNCMP(type, "AES256-CBC", 10) == 0)) {
-            WOLFSSL_MSG("AES-256-CBC");
-            ctx->cipherType = AES_256_CBC_TYPE;
-            ctx->keyLen     = 32;
-            if (enc == 0 || enc == 1)
-                ctx->enc = enc ? 1 : 0;
-            if (key) {
-                ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv,
-                                ctx->enc ? AES_ENCRYPTION : AES_DECRYPTION);
-                if (ret != 0)
-                    return ret;
-            }
-            if (iv && key == NULL) {
-                ret = wc_AesSetIV(&ctx->cipher.aes, iv);
-                if (ret != 0)
-                    return ret;
-            }
-        }
-#ifdef WOLFSSL_AES_COUNTER
-        else if (ctx->cipherType == AES_128_CTR_TYPE || (type &&
-                                       XSTRNCMP(type, "AES128-CTR", 10) == 0)) {
-            WOLFSSL_MSG("AES-128-CTR");
-            ctx->cipherType = AES_128_CTR_TYPE;
-            ctx->keyLen     = 16;
-            if (enc == 0 || enc == 1)
-                ctx->enc = enc ? 1 : 0;
-            if (key) {
-                ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv,
-                                AES_ENCRYPTION);
-                if (ret != 0)
-                    return ret;
-            }
-            if (iv && key == NULL) {
-                ret = wc_AesSetIV(&ctx->cipher.aes, iv);
-                if (ret != 0)
-                    return ret;
-            }
-        }
-        else if (ctx->cipherType == AES_192_CTR_TYPE || (type &&
-                                       XSTRNCMP(type, "AES192-CTR", 10) == 0)) {
-            WOLFSSL_MSG("AES-192-CTR");
-            ctx->cipherType = AES_192_CTR_TYPE;
-            ctx->keyLen     = 24;
-            if (enc == 0 || enc == 1)
-                ctx->enc = enc ? 1 : 0;
-            if (key) {
-                ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv,
-                                AES_ENCRYPTION);
-                if (ret != 0)
-                    return ret;
-            }
-            if (iv && key == NULL) {
-                ret = wc_AesSetIV(&ctx->cipher.aes, iv);
-                if (ret != 0)
-                    return ret;
-            }
-        }
-        else if (ctx->cipherType == AES_256_CTR_TYPE || (type &&
-                                       XSTRNCMP(type, "AES256-CTR", 10) == 0)) {
-            WOLFSSL_MSG("AES-256-CTR");
-            ctx->cipherType = AES_256_CTR_TYPE;
-            ctx->keyLen     = 32;
-            if (enc == 0 || enc == 1)
-                ctx->enc = enc ? 1 : 0;
-            if (key) {
-                ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv,
-                                AES_ENCRYPTION);
-                if (ret != 0)
-                    return ret;
-            }
-            if (iv && key == NULL) {
-                ret = wc_AesSetIV(&ctx->cipher.aes, iv);
-                if (ret != 0)
-                    return ret;
-            }
-        }
-#endif /* WOLFSSL_AES_CTR */
-#endif /* NO_AES */
-
-#ifndef NO_DES3
-        else if (ctx->cipherType == DES_CBC_TYPE || (type &&
-                                       XSTRNCMP(type, "DES-CBC", 7) == 0)) {
-            WOLFSSL_MSG("DES-CBC");
-            ctx->cipherType = DES_CBC_TYPE;
-            ctx->keyLen     = 8;
-            if (enc == 0 || enc == 1)
-                ctx->enc = enc ? 1 : 0;
-            if (key) {
-                ret = wc_Des_SetKey(&ctx->cipher.des, key, iv,
-                          ctx->enc ? DES_ENCRYPTION : DES_DECRYPTION);
-                if (ret != 0)
-                    return ret;
-            }
-
-            if (iv && key == NULL)
-                wc_Des_SetIV(&ctx->cipher.des, iv);
-        }
-        else if (ctx->cipherType == DES_EDE3_CBC_TYPE || (type &&
-                                     XSTRNCMP(type, "DES-EDE3-CBC", 11) == 0)) {
-            WOLFSSL_MSG("DES-EDE3-CBC");
-            ctx->cipherType = DES_EDE3_CBC_TYPE;
-            ctx->keyLen     = 24;
-            if (enc == 0 || enc == 1)
-                ctx->enc = enc ? 1 : 0;
-            if (key) {
-                ret = wc_Des3_SetKey(&ctx->cipher.des3, key, iv,
-                          ctx->enc ? DES_ENCRYPTION : DES_DECRYPTION);
-                if (ret != 0)
-                    return ret;
-            }
-
-            if (iv && key == NULL) {
-                ret = wc_Des3_SetIV(&ctx->cipher.des3, iv);
-                if (ret != 0)
-                    return ret;
-            }
-        }
-#endif /* NO_DES3 */
-#ifndef NO_RC4
-        else if (ctx->cipherType == ARC4_TYPE || (type &&
-                                     XSTRNCMP(type, "ARC4", 4) == 0)) {
-            WOLFSSL_MSG("ARC4");
-            ctx->cipherType = ARC4_TYPE;
-            if (ctx->keyLen == 0)  /* user may have already set */
-                ctx->keyLen = 16;  /* default to 128 */
-            if (key)
-                wc_Arc4SetKey(&ctx->cipher.arc4, key, ctx->keyLen);
-        }
-#endif /* NO_RC4 */
-        else if (ctx->cipherType == NULL_CIPHER_TYPE || (type &&
-                                     XSTRNCMP(type, "NULL", 4) == 0)) {
-            WOLFSSL_MSG("NULL cipher");
-            ctx->cipherType = NULL_CIPHER_TYPE;
-            ctx->keyLen = 0;
-        }
-        else
-            return 0;   /* failure */
-
-
-        return SSL_SUCCESS;
-    }
-
-
-    /* SSL_SUCCESS on ok */
-    int wolfSSL_EVP_CIPHER_CTX_key_length(WOLFSSL_EVP_CIPHER_CTX* ctx)
-    {
-        WOLFSSL_ENTER("wolfSSL_EVP_CIPHER_CTX_key_length");
-        if (ctx)
-            return ctx->keyLen;
-
-        return 0;   /* failure */
-    }
-
-
-    /* SSL_SUCCESS on ok */
-    int wolfSSL_EVP_CIPHER_CTX_set_key_length(WOLFSSL_EVP_CIPHER_CTX* ctx,
-                                             int keylen)
-    {
-        WOLFSSL_ENTER("wolfSSL_EVP_CIPHER_CTX_set_key_length");
-        if (ctx)
-            ctx->keyLen = keylen;
-        else
-            return 0;  /* failure */
-
-        return SSL_SUCCESS;
-    }
-
-
-    /* SSL_SUCCESS on ok */
-    int wolfSSL_EVP_Cipher(WOLFSSL_EVP_CIPHER_CTX* ctx, byte* dst, byte* src,
-                          word32 len)
-    {
-        int ret = 0;
-        WOLFSSL_ENTER("wolfSSL_EVP_Cipher");
-
-        if (ctx == NULL || dst == NULL || src == NULL) {
-            WOLFSSL_MSG("Bad function argument");
-            return 0;  /* failure */
-        }
-
-        if (ctx->cipherType == 0xff) {
-            WOLFSSL_MSG("no init");
-            return 0;  /* failure */
-        }
-
-        switch (ctx->cipherType) {
-
-#ifndef NO_AES
-            case AES_128_CBC_TYPE :
-            case AES_192_CBC_TYPE :
-            case AES_256_CBC_TYPE :
-                WOLFSSL_MSG("AES CBC");
-                if (ctx->enc)
-                    ret = wc_AesCbcEncrypt(&ctx->cipher.aes, dst, src, len);
-                else
-                    ret = wc_AesCbcDecrypt(&ctx->cipher.aes, dst, src, len);
-                break;
-
-#ifdef WOLFSSL_AES_COUNTER
-            case AES_128_CTR_TYPE :
-            case AES_192_CTR_TYPE :
-            case AES_256_CTR_TYPE :
-                    WOLFSSL_MSG("AES CTR");
-                    wc_AesCtrEncrypt(&ctx->cipher.aes, dst, src, len);
-                break;
-#endif
-#endif /* NO_AES */
-
-#ifndef NO_DES3
-            case DES_CBC_TYPE :
-                if (ctx->enc)
-                    wc_Des_CbcEncrypt(&ctx->cipher.des, dst, src, len);
-                else
-                    wc_Des_CbcDecrypt(&ctx->cipher.des, dst, src, len);
-                break;
-
-            case DES_EDE3_CBC_TYPE :
-                if (ctx->enc)
-                    ret = wc_Des3_CbcEncrypt(&ctx->cipher.des3, dst, src, len);
-                else
-                    ret = wc_Des3_CbcDecrypt(&ctx->cipher.des3, dst, src, len);
-                break;
-#endif
-
-#ifndef NO_RC4
-            case ARC4_TYPE :
-                wc_Arc4Process(&ctx->cipher.arc4, dst, src, len);
-                break;
-#endif
-
-            case NULL_CIPHER_TYPE :
-                XMEMCPY(dst, src, len);
-                break;
-
-            default: {
-                WOLFSSL_MSG("bad type");
-                return 0;  /* failure */
-            }
-        }
-
-        if (ret != 0) {
-            WOLFSSL_MSG("wolfSSL_EVP_Cipher failure");
-            return 0;  /* failuer */
-        }
-
-        WOLFSSL_MSG("wolfSSL_EVP_Cipher success");
-        return SSL_SUCCESS;  /* success */
-    }
-
-
-    /* store for external read of iv, SSL_SUCCESS on success */
-    int  wolfSSL_StoreExternalIV(WOLFSSL_EVP_CIPHER_CTX* ctx)
-    {
-        WOLFSSL_ENTER("wolfSSL_StoreExternalIV");
-
-        if (ctx == NULL) {
-            WOLFSSL_MSG("Bad function argument");
-            return SSL_FATAL_ERROR;
-        }
-
-        switch (ctx->cipherType) {
-
-#ifndef NO_AES
-            case AES_128_CBC_TYPE :
-            case AES_192_CBC_TYPE :
-            case AES_256_CBC_TYPE :
-                WOLFSSL_MSG("AES CBC");
-                memcpy(ctx->iv, &ctx->cipher.aes.reg, AES_BLOCK_SIZE);
-                break;
-
-#ifdef WOLFSSL_AES_COUNTER
-            case AES_128_CTR_TYPE :
-            case AES_192_CTR_TYPE :
-            case AES_256_CTR_TYPE :
-                WOLFSSL_MSG("AES CTR");
-                memcpy(ctx->iv, &ctx->cipher.aes.reg, AES_BLOCK_SIZE);
-                break;
-#endif /* WOLFSSL_AES_COUNTER */
-
-#endif /* NO_AES */
-
-#ifndef NO_DES3
-            case DES_CBC_TYPE :
-                WOLFSSL_MSG("DES CBC");
-                memcpy(ctx->iv, &ctx->cipher.des.reg, DES_BLOCK_SIZE);
-                break;
-
-            case DES_EDE3_CBC_TYPE :
-                WOLFSSL_MSG("DES EDE3 CBC");
-                memcpy(ctx->iv, &ctx->cipher.des3.reg, DES_BLOCK_SIZE);
-                break;
-#endif
-
-            case ARC4_TYPE :
-                WOLFSSL_MSG("ARC4");
-                break;
-
-            case NULL_CIPHER_TYPE :
-                WOLFSSL_MSG("NULL");
-                break;
-
-            default: {
-                WOLFSSL_MSG("bad type");
-                return SSL_FATAL_ERROR;
-            }
-        }
-        return SSL_SUCCESS;
-    }
-
-
-    /* set internal IV from external, SSL_SUCCESS on success */
-    int  wolfSSL_SetInternalIV(WOLFSSL_EVP_CIPHER_CTX* ctx)
-    {
-
-        WOLFSSL_ENTER("wolfSSL_SetInternalIV");
-
-        if (ctx == NULL) {
-            WOLFSSL_MSG("Bad function argument");
-            return SSL_FATAL_ERROR;
-        }
-
-        switch (ctx->cipherType) {
-
-#ifndef NO_AES
-            case AES_128_CBC_TYPE :
-            case AES_192_CBC_TYPE :
-            case AES_256_CBC_TYPE :
-                WOLFSSL_MSG("AES CBC");
-                memcpy(&ctx->cipher.aes.reg, ctx->iv, AES_BLOCK_SIZE);
-                break;
-
-#ifdef WOLFSSL_AES_COUNTER
-            case AES_128_CTR_TYPE :
-            case AES_192_CTR_TYPE :
-            case AES_256_CTR_TYPE :
-                WOLFSSL_MSG("AES CTR");
-                memcpy(&ctx->cipher.aes.reg, ctx->iv, AES_BLOCK_SIZE);
-                break;
-#endif
-
-#endif /* NO_AES */
-
-#ifndef NO_DES3
-            case DES_CBC_TYPE :
-                WOLFSSL_MSG("DES CBC");
-                memcpy(&ctx->cipher.des.reg, ctx->iv, DES_BLOCK_SIZE);
-                break;
-
-            case DES_EDE3_CBC_TYPE :
-                WOLFSSL_MSG("DES EDE3 CBC");
-                memcpy(&ctx->cipher.des3.reg, ctx->iv, DES_BLOCK_SIZE);
-                break;
-#endif
-
-            case ARC4_TYPE :
-                WOLFSSL_MSG("ARC4");
-                break;
-
-            case NULL_CIPHER_TYPE :
-                WOLFSSL_MSG("NULL");
-                break;
-
-            default: {
-                WOLFSSL_MSG("bad type");
-                return SSL_FATAL_ERROR;
-            }
-        }
-        return SSL_SUCCESS;
-    }
-
-
-    /* SSL_SUCCESS on ok */
-    int wolfSSL_EVP_DigestInit(WOLFSSL_EVP_MD_CTX* ctx, const WOLFSSL_EVP_MD* type)
-    {
-        WOLFSSL_ENTER("EVP_DigestInit");
-        if (XSTRNCMP(type, "SHA256", 6) == 0) {
-             ctx->macType = SHA256;
-             wolfSSL_SHA256_Init((SHA256_CTX*)&ctx->hash);
-        }
-    #ifdef WOLFSSL_SHA384
-        else if (XSTRNCMP(type, "SHA384", 6) == 0) {
-             ctx->macType = SHA384;
-             wolfSSL_SHA384_Init((SHA384_CTX*)&ctx->hash);
-        }
-    #endif
-    #ifdef WOLFSSL_SHA512
-        else if (XSTRNCMP(type, "SHA512", 6) == 0) {
-             ctx->macType = SHA512;
-             wolfSSL_SHA512_Init((SHA512_CTX*)&ctx->hash);
-        }
-    #endif
-    #ifndef NO_MD5
-        else if (XSTRNCMP(type, "MD5", 3) == 0) {
-            ctx->macType = MD5;
-            wolfSSL_MD5_Init((MD5_CTX*)&ctx->hash);
-        }
-    #endif
-    #ifndef NO_SHA
-        /* has to be last since would pick or 256, 384, or 512 too */
-        else if (XSTRNCMP(type, "SHA", 3) == 0) {
-             ctx->macType = SHA;
-             wolfSSL_SHA_Init((SHA_CTX*)&ctx->hash);
-        }
-    #endif /* NO_SHA */
-        else
-             return BAD_FUNC_ARG;
-
-        return SSL_SUCCESS;
-    }
-
-
-    /* SSL_SUCCESS on ok */
-    int wolfSSL_EVP_DigestUpdate(WOLFSSL_EVP_MD_CTX* ctx, const void* data,
-                                unsigned long sz)
-    {
-        WOLFSSL_ENTER("EVP_DigestUpdate");
-
-        switch (ctx->macType) {
-#ifndef NO_MD5
-            case MD5:
-                wolfSSL_MD5_Update((MD5_CTX*)&ctx->hash, data,
-                                  (unsigned long)sz);
-                break;
-#endif
-#ifndef NO_SHA
-            case SHA:
-                wolfSSL_SHA_Update((SHA_CTX*)&ctx->hash, data,
-                                  (unsigned long)sz);
-                break;
-#endif
-#ifndef NO_SHA256
-            case SHA256:
-                wolfSSL_SHA256_Update((SHA256_CTX*)&ctx->hash, data,
-                                     (unsigned long)sz);
-                break;
-#endif
-#ifdef WOLFSSL_SHA384
-            case SHA384:
-                wolfSSL_SHA384_Update((SHA384_CTX*)&ctx->hash, data,
-                                     (unsigned long)sz);
-                break;
-#endif
-#ifdef WOLFSSL_SHA512
-            case SHA512:
-                wolfSSL_SHA512_Update((SHA512_CTX*)&ctx->hash, data,
-                                     (unsigned long)sz);
-                break;
-#endif
-            default:
-                return BAD_FUNC_ARG;
-        }
-
-        return SSL_SUCCESS;
-    }
-
-
-    /* SSL_SUCCESS on ok */
-    int wolfSSL_EVP_DigestFinal(WOLFSSL_EVP_MD_CTX* ctx, unsigned char* md,
-                               unsigned int* s)
-    {
-        WOLFSSL_ENTER("EVP_DigestFinal");
-        switch (ctx->macType) {
-#ifndef NO_MD5
-            case MD5:
-                wolfSSL_MD5_Final(md, (MD5_CTX*)&ctx->hash);
-                if (s) *s = MD5_DIGEST_SIZE;
-                break;
-#endif
-#ifndef NO_SHA
-            case SHA:
-                wolfSSL_SHA_Final(md, (SHA_CTX*)&ctx->hash);
-                if (s) *s = SHA_DIGEST_SIZE;
-                break;
-#endif
-#ifndef NO_SHA256
-            case SHA256:
-                wolfSSL_SHA256_Final(md, (SHA256_CTX*)&ctx->hash);
-                if (s) *s = SHA256_DIGEST_SIZE;
-                break;
-#endif
-#ifdef WOLFSSL_SHA384
-            case SHA384:
-                wolfSSL_SHA384_Final(md, (SHA384_CTX*)&ctx->hash);
-                if (s) *s = SHA384_DIGEST_SIZE;
-                break;
-#endif
-#ifdef WOLFSSL_SHA512
-            case SHA512:
-                wolfSSL_SHA512_Final(md, (SHA512_CTX*)&ctx->hash);
-                if (s) *s = SHA512_DIGEST_SIZE;
-                break;
-#endif
-            default:
-                return BAD_FUNC_ARG;
-        }
-
-        return SSL_SUCCESS;
-    }
-
-
-    /* SSL_SUCCESS on ok */
-    int wolfSSL_EVP_DigestFinal_ex(WOLFSSL_EVP_MD_CTX* ctx, unsigned char* md,
-                                  unsigned int* s)
-    {
-        WOLFSSL_ENTER("EVP_DigestFinal_ex");
-        return EVP_DigestFinal(ctx, md, s);
-    }
-
-
-    unsigned char* wolfSSL_HMAC(const WOLFSSL_EVP_MD* evp_md, const void* key,
-                               int key_len, const unsigned char* d, int n,
-                               unsigned char* md, unsigned int* md_len)
-    {
-        int type;
-        unsigned char* ret = NULL;
-#ifdef WOLFSSL_SMALL_STACK
-        Hmac* hmac = NULL;
-#else
-        Hmac  hmac[1];
-#endif
-
-        WOLFSSL_ENTER("HMAC");
-        if (!md)
-            return NULL;  /* no static buffer support */
-
-        if (XSTRNCMP(evp_md, "MD5", 3) == 0)
-            type = MD5;
-        else if (XSTRNCMP(evp_md, "SHA", 3) == 0)
-            type = SHA;
-        else
-            return NULL;
-
-    #ifdef WOLFSSL_SMALL_STACK
-        hmac = (Hmac*)XMALLOC(sizeof(Hmac), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (hmac == NULL)
-            return NULL;
-    #endif
-
-        if (wc_HmacSetKey(hmac, type, (const byte*)key, key_len) == 0)
-            if (wc_HmacUpdate(hmac, d, n) == 0)
-                if (wc_HmacFinal(hmac, md) == 0) {
-                    if (md_len)
-                        *md_len = (type == MD5) ? (int)MD5_DIGEST_SIZE
-                                                : (int)SHA_DIGEST_SIZE;
-                    ret = md;
-                }
-
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(hmac, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-
-        return ret;
-    }
-
-    void wolfSSL_ERR_clear_error(void)
-    {
-        /* TODO: */
-    }
-
-
-    int wolfSSL_RAND_status(void)
-    {
-        return SSL_SUCCESS;  /* wolfCrypt provides enough seed internally */
-    }
-
-
-
-    void wolfSSL_RAND_add(const void* add, int len, double entropy)
-    {
-        (void)add;
-        (void)len;
-        (void)entropy;
-
-        /* wolfSSL seeds/adds internally, use explicit RNG if you want
-           to take control */
-    }
-
-
-#ifndef NO_DES3
-    /* SSL_SUCCESS on ok */
-    int wolfSSL_DES_key_sched(WOLFSSL_const_DES_cblock* key,
-                             WOLFSSL_DES_key_schedule* schedule)
-    {
-        WOLFSSL_ENTER("DES_key_sched");
-        XMEMCPY(schedule, key, sizeof(const_DES_cblock));
-        return SSL_SUCCESS;
-    }
-
-
-    void wolfSSL_DES_cbc_encrypt(const unsigned char* input,
-                     unsigned char* output, long length,
-                     WOLFSSL_DES_key_schedule* schedule, WOLFSSL_DES_cblock* ivec,
-                     int enc)
-    {
-        Des myDes;
-
-        WOLFSSL_ENTER("DES_cbc_encrypt");
-
-        /* OpenSSL compat, no ret */
-        wc_Des_SetKey(&myDes, (const byte*)schedule, (const byte*)ivec, !enc);
-
-        if (enc)
-            wc_Des_CbcEncrypt(&myDes, output, input, (word32)length);
-        else
-            wc_Des_CbcDecrypt(&myDes, output, input, (word32)length);
-    }
-
-
-    /* correctly sets ivec for next call */
-    void wolfSSL_DES_ncbc_encrypt(const unsigned char* input,
-                     unsigned char* output, long length,
-                     WOLFSSL_DES_key_schedule* schedule, WOLFSSL_DES_cblock* ivec,
-                     int enc)
-    {
-        Des myDes;
-
-        WOLFSSL_ENTER("DES_ncbc_encrypt");
-
-        /* OpenSSL compat, no ret */
-        wc_Des_SetKey(&myDes, (const byte*)schedule, (const byte*)ivec, !enc);
-
-        if (enc)
-            wc_Des_CbcEncrypt(&myDes, output, input, (word32)length);
-        else
-            wc_Des_CbcDecrypt(&myDes, output, input, (word32)length);
-
-        XMEMCPY(ivec, output + length - sizeof(DES_cblock), sizeof(DES_cblock));
-    }
-
-#endif /* NO_DES3 */
-
-
-    void wolfSSL_ERR_free_strings(void)
-    {
-        /* handled internally */
-    }
-
-
-    void wolfSSL_ERR_remove_state(unsigned long state)
-    {
-        /* TODO: GetErrors().Remove(); */
-        (void)state;
-    }
-
-
-    void wolfSSL_EVP_cleanup(void)
-    {
-        /* nothing to do here */
-    }
-
-
-    void wolfSSL_cleanup_all_ex_data(void)
-    {
-        /* nothing to do here */
-    }
-
-
-    int wolfSSL_clear(WOLFSSL* ssl)
-    {
-        (void)ssl;
-        /* TODO: GetErrors().Remove(); */
-        return SSL_SUCCESS;
-    }
-
-
-    long wolfSSL_SSL_SESSION_set_timeout(WOLFSSL_SESSION* ses, long t)
-    {
-        word32 tmptime;
-        if (!ses || t < 0)
-            return BAD_FUNC_ARG;
-
-        tmptime = t & 0xFFFFFFFF;
-
-        ses->timeout = tmptime;
-
-        return SSL_SUCCESS;
-    }
-
-
-    long wolfSSL_CTX_set_mode(WOLFSSL_CTX* ctx, long mode)
-    {
-        /* SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER is wolfSSL default mode */
-
-        WOLFSSL_ENTER("SSL_CTX_set_mode");
-        if (mode == SSL_MODE_ENABLE_PARTIAL_WRITE)
-            ctx->partialWrite = 1;
-
-        return mode;
-    }
-
-
-    long wolfSSL_SSL_get_mode(WOLFSSL* ssl)
-    {
-        /* TODO: */
-        (void)ssl;
-        return 0;
-    }
-
-
-    long wolfSSL_CTX_get_mode(WOLFSSL_CTX* ctx)
-    {
-        /* TODO: */
-        (void)ctx;
-        return 0;
-    }
-
-
-    void wolfSSL_CTX_set_default_read_ahead(WOLFSSL_CTX* ctx, int m)
-    {
-        /* TODO: maybe? */
-        (void)ctx;
-        (void)m;
-    }
-
-
-    int wolfSSL_CTX_set_session_id_context(WOLFSSL_CTX* ctx,
-                                       const unsigned char* sid_ctx,
-                                       unsigned int sid_ctx_len)
-    {
-        /* No application specific context needed for wolfSSL */
-        (void)ctx;
-        (void)sid_ctx;
-        (void)sid_ctx_len;
-        return SSL_SUCCESS;
-    }
-
-
-    long wolfSSL_CTX_sess_get_cache_size(WOLFSSL_CTX* ctx)
-    {
-        /* TODO: maybe? */
-        (void)ctx;
-        return (~0);
-    }
-
-    unsigned long wolfSSL_ERR_get_error_line_data(const char** file, int* line,
-                                          const char** data, int *flags)
-    {
-        /* Not implemented */
-        (void)file;
-        (void)line;
-        (void)data;
-        (void)flags;
-        return 0;
-    }
-
-#endif /* OPENSSL_EXTRA */
-
-
-#if defined(KEEP_PEER_CERT)
-
-    WOLFSSL_X509* wolfSSL_get_peer_certificate(WOLFSSL* ssl)
-    {
-        WOLFSSL_ENTER("SSL_get_peer_certificate");
-        if (ssl->peerCert.issuer.sz)
-            return &ssl->peerCert;
-        else
-            return 0;
-    }
-
-#endif /* KEEP_PEER_CERT */
-
-
-#if defined(KEEP_PEER_CERT) || defined(SESSION_CERTS)
-
-    void wolfSSL_FreeX509(WOLFSSL_X509* x509)
-    {
-        WOLFSSL_ENTER("wolfSSL_FreeX509");
-        FreeX509(x509);
-    }
-
-
-    /* return the next, if any, altname from the peer cert */
-    char* wolfSSL_X509_get_next_altname(WOLFSSL_X509* cert)
-    {
-        char* ret = NULL;
-        WOLFSSL_ENTER("wolfSSL_X509_get_next_altname");
-
-        /* don't have any to work with */
-        if (cert == NULL || cert->altNames == NULL)
-            return NULL;
-
-        /* already went through them */
-        if (cert->altNamesNext == NULL)
-            return NULL;
-
-        ret = cert->altNamesNext->name;
-        cert->altNamesNext = cert->altNamesNext->next;
-
-        return ret;
-    }
-
-
-    WOLFSSL_X509_NAME* wolfSSL_X509_get_issuer_name(WOLFSSL_X509* cert)
-    {
-        WOLFSSL_ENTER("X509_get_issuer_name");
-        return &cert->issuer;
-    }
-
-
-    WOLFSSL_X509_NAME* wolfSSL_X509_get_subject_name(WOLFSSL_X509* cert)
-    {
-        WOLFSSL_ENTER("X509_get_subject_name");
-        return &cert->subject;
-    }
-
-
-    int wolfSSL_X509_get_isCA(WOLFSSL_X509* x509)
-    {
-        int isCA = 0;
-
-        WOLFSSL_ENTER("wolfSSL_X509_get_isCA");
-
-        if (x509 != NULL)
-            isCA = x509->isCa;
-
-        WOLFSSL_LEAVE("wolfSSL_X509_get_isCA", isCA);
-
-        return isCA;
-    }
-
-
-#ifdef OPENSSL_EXTRA
-    int wolfSSL_X509_ext_isSet_by_NID(WOLFSSL_X509* x509, int nid)
-    {
-        int isSet = 0;
-
-        WOLFSSL_ENTER("wolfSSL_X509_ext_isSet_by_NID");
-
-        if (x509 != NULL) {
-            switch (nid) {
-                case BASIC_CA_OID: isSet = x509->basicConstSet; break;
-                case ALT_NAMES_OID: isSet = x509->subjAltNameSet; break;
-                case AUTH_KEY_OID: isSet = x509->authKeyIdSet; break;
-                case SUBJ_KEY_OID: isSet = x509->subjKeyIdSet; break;
-                case KEY_USAGE_OID: isSet = x509->keyUsageSet; break;
-                #ifdef WOLFSSL_SEP
-                    case CERT_POLICY_OID: isSet = x509->certPolicySet; break;
-                #endif /* WOLFSSL_SEP */
-            }
-        }
-
-        WOLFSSL_LEAVE("wolfSSL_X509_ext_isSet_by_NID", isSet);
-
-        return isSet;
-    }
-
-
-    int wolfSSL_X509_ext_get_critical_by_NID(WOLFSSL_X509* x509, int nid)
-    {
-        int crit = 0;
-
-        WOLFSSL_ENTER("wolfSSL_X509_ext_get_critical_by_NID");
-
-        if (x509 != NULL) {
-            switch (nid) {
-                case BASIC_CA_OID: crit = x509->basicConstCrit; break;
-                case ALT_NAMES_OID: crit = x509->subjAltNameCrit; break;
-                case AUTH_KEY_OID: crit = x509->authKeyIdCrit; break;
-                case SUBJ_KEY_OID: crit = x509->subjKeyIdCrit; break;
-                case KEY_USAGE_OID: crit = x509->keyUsageCrit; break;
-                #ifdef WOLFSSL_SEP
-                    case CERT_POLICY_OID: crit = x509->certPolicyCrit; break;
-                #endif /* WOLFSSL_SEP */
-            }
-        }
-
-        WOLFSSL_LEAVE("wolfSSL_X509_ext_get_critical_by_NID", crit);
-
-        return crit;
-    }
-
-
-    int wolfSSL_X509_get_isSet_pathLength(WOLFSSL_X509* x509)
-    {
-        int isSet = 0;
-
-        WOLFSSL_ENTER("wolfSSL_X509_get_isSet_pathLength");
-
-        if (x509 != NULL)
-            isSet = x509->basicConstPlSet;
-
-        WOLFSSL_LEAVE("wolfSSL_X509_get_isSet_pathLength", isSet);
-
-        return isSet;
-    }
-
-
-    word32 wolfSSL_X509_get_pathLength(WOLFSSL_X509* x509)
-    {
-        word32 pathLength = 0;
-
-        WOLFSSL_ENTER("wolfSSL_X509_get_pathLength");
-
-        if (x509 != NULL)
-            pathLength = x509->pathLength;
-
-        WOLFSSL_LEAVE("wolfSSL_X509_get_pathLength", pathLength);
-
-        return pathLength;
-    }
-
-
-    unsigned int wolfSSL_X509_get_keyUsage(WOLFSSL_X509* x509)
-    {
-        word16 usage = 0;
-
-        WOLFSSL_ENTER("wolfSSL_X509_get_keyUsage");
-
-        if (x509 != NULL)
-            usage = x509->keyUsage;
-
-        WOLFSSL_LEAVE("wolfSSL_X509_get_keyUsage", usage);
-
-        return usage;
-    }
-
-
-    byte* wolfSSL_X509_get_authorityKeyID(
-                                      WOLFSSL_X509* x509, byte* dst, int* dstLen)
-    {
-        byte *id = NULL;
-        int copySz = 0;
-
-        WOLFSSL_ENTER("wolfSSL_X509_get_authorityKeyID");
-
-        if (x509 != NULL) {
-            if (x509->authKeyIdSet) {
-                copySz = min(dstLen != NULL ? *dstLen : 0,
-                                                        (int)x509->authKeyIdSz);
-                id = x509->authKeyId;
-            }
-
-            if (dst != NULL && dstLen != NULL && id != NULL && copySz > 0) {
-                XMEMCPY(dst, id, copySz);
-                id = dst;
-                *dstLen = copySz;
-            }
-        }
-
-        WOLFSSL_LEAVE("wolfSSL_X509_get_authorityKeyID", copySz);
-
-        return id;
-    }
-
-
-    byte* wolfSSL_X509_get_subjectKeyID(
-                                      WOLFSSL_X509* x509, byte* dst, int* dstLen)
-    {
-        byte *id = NULL;
-        int copySz = 0;
-
-        WOLFSSL_ENTER("wolfSSL_X509_get_subjectKeyID");
-
-        if (x509 != NULL) {
-            if (x509->subjKeyIdSet) {
-                copySz = min(dstLen != NULL ? *dstLen : 0,
-                                                        (int)x509->subjKeyIdSz);
-                id = x509->subjKeyId;
-            }
-
-            if (dst != NULL && dstLen != NULL && id != NULL && copySz > 0) {
-                XMEMCPY(dst, id, copySz);
-                id = dst;
-                *dstLen = copySz;
-            }
-        }
-
-        WOLFSSL_LEAVE("wolfSSL_X509_get_subjectKeyID", copySz);
-
-        return id;
-    }
-
-
-    int wolfSSL_X509_NAME_entry_count(WOLFSSL_X509_NAME* name)
-    {
-        int count = 0;
-
-        WOLFSSL_ENTER("wolfSSL_X509_NAME_entry_count");
-
-        if (name != NULL)
-            count = name->fullName.entryCount;
-
-        WOLFSSL_LEAVE("wolfSSL_X509_NAME_entry_count", count);
-        return count;
-    }
-
-
-    int wolfSSL_X509_NAME_get_text_by_NID(WOLFSSL_X509_NAME* name,
-                                                    int nid, char* buf, int len)
-    {
-        char *text = NULL;
-        int textSz = 0;
-
-        WOLFSSL_ENTER("wolfSSL_X509_NAME_get_text_by_NID");
-
-        switch (nid) {
-            case ASN_COMMON_NAME:
-                text = name->fullName.fullName + name->fullName.cnIdx;
-                textSz = name->fullName.cnLen;
-                break;
-            case ASN_SUR_NAME:
-                text = name->fullName.fullName + name->fullName.snIdx;
-                textSz = name->fullName.snLen;
-                break;
-            case ASN_SERIAL_NUMBER:
-                text = name->fullName.fullName + name->fullName.serialIdx;
-                textSz = name->fullName.serialLen;
-                break;
-            case ASN_COUNTRY_NAME:
-                text = name->fullName.fullName + name->fullName.cIdx;
-                textSz = name->fullName.cLen;
-                break;
-            case ASN_LOCALITY_NAME:
-                text = name->fullName.fullName + name->fullName.lIdx;
-                textSz = name->fullName.lLen;
-                break;
-            case ASN_STATE_NAME:
-                text = name->fullName.fullName + name->fullName.stIdx;
-                textSz = name->fullName.stLen;
-                break;
-            case ASN_ORG_NAME:
-                text = name->fullName.fullName + name->fullName.oIdx;
-                textSz = name->fullName.oLen;
-                break;
-            case ASN_ORGUNIT_NAME:
-                text = name->fullName.fullName + name->fullName.ouIdx;
-                textSz = name->fullName.ouLen;
-                break;
-            default:
-                break;
-        }
-
-        if (buf != NULL && text != NULL) {
-            textSz = min(textSz, len);
-            XMEMCPY(buf, text, textSz);
-            buf[textSz] = '\0';
-        }
-
-        WOLFSSL_LEAVE("wolfSSL_X509_NAME_get_text_by_NID", textSz);
-        return textSz;
-    }
-#endif
-
-
-    /* copy name into in buffer, at most sz bytes, if buffer is null will
-       malloc buffer, call responsible for freeing                     */
-    char* wolfSSL_X509_NAME_oneline(WOLFSSL_X509_NAME* name, char* in, int sz)
-    {
-        int copySz = min(sz, name->sz);
-
-        WOLFSSL_ENTER("wolfSSL_X509_NAME_oneline");
-        if (!name->sz) return in;
-
-        if (!in) {
-            in = (char*)XMALLOC(name->sz, 0, DYNAMIC_TYPE_OPENSSL);
-            if (!in ) return in;
-            copySz = name->sz;
-        }
-
-        if (copySz == 0)
-            return in;
-
-        XMEMCPY(in, name->name, copySz - 1);
-        in[copySz - 1] = 0;
-
-        return in;
-    }
-
-
-    int wolfSSL_X509_get_signature_type(WOLFSSL_X509* x509)
-    {
-        int type = 0;
-
-        WOLFSSL_ENTER("wolfSSL_X509_get_signature_type");
-
-        if (x509 != NULL)
-            type = x509->sigOID;
-
-        return type;
-    }
-
-
-    int wolfSSL_X509_get_signature(WOLFSSL_X509* x509,
-                                                 unsigned char* buf, int* bufSz)
-    {
-        WOLFSSL_ENTER("wolfSSL_X509_get_signature");
-        if (x509 == NULL || bufSz == NULL || *bufSz < (int)x509->sig.length)
-            return SSL_FATAL_ERROR;
-
-        if (buf != NULL)
-            XMEMCPY(buf, x509->sig.buffer, x509->sig.length);
-        *bufSz = x509->sig.length;
-
-        return SSL_SUCCESS;
-    }
-
-
-    /* write X509 serial number in unsigned binary to buffer
-       buffer needs to be at least EXTERNAL_SERIAL_SIZE (32) for all cases
-       return SSL_SUCCESS on success */
-    int wolfSSL_X509_get_serial_number(WOLFSSL_X509* x509, byte* in, int* inOutSz)
-    {
-        WOLFSSL_ENTER("wolfSSL_X509_get_serial_number");
-        if (x509 == NULL || in == NULL ||
-                                   inOutSz == NULL || *inOutSz < x509->serialSz)
-            return BAD_FUNC_ARG;
-
-        XMEMCPY(in, x509->serial, x509->serialSz);
-        *inOutSz = x509->serialSz;
-
-        return SSL_SUCCESS;
-    }
-
-
-    const byte* wolfSSL_X509_get_der(WOLFSSL_X509* x509, int* outSz)
-    {
-        WOLFSSL_ENTER("wolfSSL_X509_get_der");
-
-        if (x509 == NULL || outSz == NULL)
-            return NULL;
-
-        *outSz = (int)x509->derCert.length;
-        return x509->derCert.buffer;
-    }
-
-
-    int wolfSSL_X509_version(WOLFSSL_X509* x509)
-    {
-        WOLFSSL_ENTER("wolfSSL_X509_version");
-
-        if (x509 == NULL)
-            return 0;
-
-        return x509->version;
-    }
-
-
-    const byte* wolfSSL_X509_notBefore(WOLFSSL_X509* x509)
-    {
-        WOLFSSL_ENTER("wolfSSL_X509_notBefore");
-
-        if (x509 == NULL)
-            return NULL;
-
-        return x509->notBefore;
-    }
-
-
-    const byte* wolfSSL_X509_notAfter(WOLFSSL_X509* x509)
-    {
-        WOLFSSL_ENTER("wolfSSL_X509_notAfter");
-
-        if (x509 == NULL)
-            return NULL;
-
-        return x509->notAfter;
-    }
-
-
-#ifdef WOLFSSL_SEP
-
-/* copy oid into in buffer, at most *inOutSz bytes, if buffer is null will
-   malloc buffer, call responsible for freeing. Actual size returned in
-   *inOutSz. Requires inOutSz be non-null */
-byte* wolfSSL_X509_get_device_type(WOLFSSL_X509* x509, byte* in, int *inOutSz)
-{
-    int copySz;
-
-    WOLFSSL_ENTER("wolfSSL_X509_get_dev_type");
-    if (inOutSz == NULL) return NULL;
-    if (!x509->deviceTypeSz) return in;
-
-    copySz = min(*inOutSz, x509->deviceTypeSz);
-
-    if (!in) {
-        in = (byte*)XMALLOC(x509->deviceTypeSz, 0, DYNAMIC_TYPE_OPENSSL);
-        if (!in) return in;
-        copySz = x509->deviceTypeSz;
-    }
-
-    XMEMCPY(in, x509->deviceType, copySz);
-    *inOutSz = copySz;
-
-    return in;
-}
-
-
-byte* wolfSSL_X509_get_hw_type(WOLFSSL_X509* x509, byte* in, int* inOutSz)
-{
-    int copySz;
-
-    WOLFSSL_ENTER("wolfSSL_X509_get_hw_type");
-    if (inOutSz == NULL) return NULL;
-    if (!x509->hwTypeSz) return in;
-
-    copySz = min(*inOutSz, x509->hwTypeSz);
-
-    if (!in) {
-        in = (byte*)XMALLOC(x509->hwTypeSz, 0, DYNAMIC_TYPE_OPENSSL);
-        if (!in) return in;
-        copySz = x509->hwTypeSz;
-    }
-
-    XMEMCPY(in, x509->hwType, copySz);
-    *inOutSz = copySz;
-
-    return in;
-}
-
-
-byte* wolfSSL_X509_get_hw_serial_number(WOLFSSL_X509* x509,byte* in,int* inOutSz)
-{
-    int copySz;
-
-    WOLFSSL_ENTER("wolfSSL_X509_get_hw_serial_number");
-    if (inOutSz == NULL) return NULL;
-    if (!x509->hwTypeSz) return in;
-
-    copySz = min(*inOutSz, x509->hwSerialNumSz);
-
-    if (!in) {
-        in = (byte*)XMALLOC(x509->hwSerialNumSz, 0, DYNAMIC_TYPE_OPENSSL);
-        if (!in) return in;
-        copySz = x509->hwSerialNumSz;
-    }
-
-    XMEMCPY(in, x509->hwSerialNum, copySz);
-    *inOutSz = copySz;
-
-    return in;
-}
-
-#endif /* WOLFSSL_SEP */
-
-
-WOLFSSL_X509* wolfSSL_X509_d2i(WOLFSSL_X509** x509, const byte* in, int len)
-{
-    WOLFSSL_X509 *newX509 = NULL;
-
-    WOLFSSL_ENTER("wolfSSL_X509_d2i");
-
-    if (in != NULL && len != 0) {
-    #ifdef WOLFSSL_SMALL_STACK
-        DecodedCert* cert = NULL;
-    #else
-        DecodedCert  cert[1];
-    #endif
-
-    #ifdef WOLFSSL_SMALL_STACK
-        cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-        if (cert == NULL)
-            return NULL;
-    #endif
-
-        InitDecodedCert(cert, (byte*)in, len, NULL);
-        if (ParseCertRelative(cert, CERT_TYPE, 0, NULL) == 0) {
-            newX509 = (WOLFSSL_X509*)XMALLOC(sizeof(WOLFSSL_X509),
-                                                       NULL, DYNAMIC_TYPE_X509);
-            if (newX509 != NULL) {
-                InitX509(newX509, 1);
-                if (CopyDecodedToX509(newX509, cert) != 0) {
-                    XFREE(newX509, NULL, DYNAMIC_TYPE_X509);
-                    newX509 = NULL;
-                }
-            }
-        }
-        FreeDecodedCert(cert);
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-    }
-
-    if (x509 != NULL)
-        *x509 = newX509;
-
-    return newX509;
-}
-
-
-#ifndef NO_FILESYSTEM
-
-#ifndef NO_STDIO_FILESYSTEM
-
-WOLFSSL_X509* wolfSSL_X509_d2i_fp(WOLFSSL_X509** x509, XFILE file)
-{
-    WOLFSSL_X509* newX509 = NULL;
-
-    WOLFSSL_ENTER("wolfSSL_X509_d2i_fp");
-
-    if (file != XBADFILE) {
-        byte* fileBuffer = NULL;
-        long sz = 0;
-
-        XFSEEK(file, 0, XSEEK_END);
-        sz = XFTELL(file);
-        XREWIND(file);
-
-        if (sz < 0) {
-            WOLFSSL_MSG("Bad tell on FILE");
-            return NULL;
-        }
-
-        fileBuffer = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE);
-        if (fileBuffer != NULL) {
-            int ret = (int)XFREAD(fileBuffer, sz, 1, file);
-            if (ret > 0) {
-                newX509 = wolfSSL_X509_d2i(NULL, fileBuffer, (int)sz);
-            }
-            XFREE(fileBuffer, NULL, DYNAMIC_TYPE_FILE);
-        }
-    }
-
-    if (x509 != NULL)
-        *x509 = newX509;
-
-    return newX509;
-}
-
-#endif /* NO_STDIO_FILESYSTEM */
-
-WOLFSSL_X509* wolfSSL_X509_load_certificate_file(const char* fname, int format)
-{
-#ifdef WOLFSSL_SMALL_STACK
-    byte  staticBuffer[1]; /* force heap usage */
-#else
-    byte  staticBuffer[FILE_BUFFER_SIZE];
-#endif
-    byte* fileBuffer = staticBuffer;
-    int   dynamic = 0;
-    int   ret;
-    long  sz = 0;
-    XFILE file;
-
-    WOLFSSL_X509* x509 = NULL;
-    buffer der;
-
-    WOLFSSL_ENTER("wolfSSL_X509_load_certificate");
-
-    /* Check the inputs */
-    if ((fname == NULL) ||
-        (format != SSL_FILETYPE_ASN1 && format != SSL_FILETYPE_PEM))
-        return NULL;
-
-    file = XFOPEN(fname, "rb");
-    if (file == XBADFILE)
-        return NULL;
-
-    XFSEEK(file, 0, XSEEK_END);
-    sz = XFTELL(file);
-    XREWIND(file);
-
-    if (sz > (long)sizeof(staticBuffer)) {
-        fileBuffer = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE);
-        if (fileBuffer == NULL) {
-            XFCLOSE(file);
-            return NULL;
-        }
-        dynamic = 1;
-    }
-    else if (sz < 0) {
-        XFCLOSE(file);
-        return NULL;
-    }
-
-    ret = (int)XFREAD(fileBuffer, sz, 1, file);
-    if (ret < 0) {
-        XFCLOSE(file);
-        if (dynamic)
-            XFREE(fileBuffer, NULL, DYNAMIC_TYPE_FILE);
-        return NULL;
-    }
-
-    XFCLOSE(file);
-
-    der.buffer = NULL;
-    der.length = 0;
-
-    if (format == SSL_FILETYPE_PEM) {
-        int ecc = 0;
-    #ifdef WOLFSSL_SMALL_STACK
-        EncryptedInfo* info = NULL;
-    #else
-        EncryptedInfo  info[1];
-    #endif
-
-    #ifdef WOLFSSL_SMALL_STACK
-        info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-        if (info == NULL) {
-            if (dynamic)
-                XFREE(fileBuffer, NULL, DYNAMIC_TYPE_FILE);
-
-            return NULL;
-        }
-    #endif
-
-        info->set = 0;
-        info->ctx = NULL;
-        info->consumed = 0;
-
-        if (PemToDer(fileBuffer, sz, CERT_TYPE, &der, NULL, info, &ecc) != 0)
-        {
-            /* Only time this should fail, and leave `der` with a buffer
-               is when the Base64 Decode fails. Release `der.buffer` in
-               that case. */
-            if (der.buffer != NULL) {
-                XFREE(der.buffer, NULL, DYNAMIC_TYPE_CERT);
-                der.buffer = NULL;
-            }
-        }
-
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-    }
-    else {
-        der.buffer = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_CERT);
-        if (der.buffer != NULL) {
-            XMEMCPY(der.buffer, fileBuffer, sz);
-            der.length = (word32)sz;
-        }
-    }
-
-    if (dynamic)
-        XFREE(fileBuffer, NULL, DYNAMIC_TYPE_FILE);
-
-    /* At this point we want `der` to have the certificate in DER format */
-    /* ready to be decoded. */
-    if (der.buffer != NULL) {
-    #ifdef WOLFSSL_SMALL_STACK
-        DecodedCert* cert = NULL;
-    #else
-        DecodedCert  cert[1];
-    #endif
-
-    #ifdef WOLFSSL_SMALL_STACK
-        cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-        if (cert != NULL)
-    #endif
-        {
-            InitDecodedCert(cert, der.buffer, der.length, NULL);
-            if (ParseCertRelative(cert, CERT_TYPE, 0, NULL) == 0) {
-                x509 = (WOLFSSL_X509*)XMALLOC(sizeof(WOLFSSL_X509), NULL,
-                                                             DYNAMIC_TYPE_X509);
-                if (x509 != NULL) {
-                    InitX509(x509, 1);
-                    if (CopyDecodedToX509(x509, cert) != 0) {
-                        XFREE(x509, NULL, DYNAMIC_TYPE_X509);
-                        x509 = NULL;
-                    }
-                }
-            }
-
-            FreeDecodedCert(cert);
-        #ifdef WOLFSSL_SMALL_STACK
-            XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        #endif
-        }
-
-        XFREE(der.buffer, NULL, DYNAMIC_TYPE_CERT);
-    }
-
-    return x509;
-}
-
-#endif /* NO_FILESYSTEM */
-
-#endif /* KEEP_PEER_CERT || SESSION_CERTS */
-
-
-#ifdef OPENSSL_EXTRA
-int wolfSSL_set_ex_data(WOLFSSL* ssl, int idx, void* data)
-{
-#ifdef FORTRESS
-    if (ssl != NULL && idx < MAX_EX_DATA)
-    {
-        ssl->ex_data[idx] = data;
-        return SSL_SUCCESS;
-    }
-#else
-    (void)ssl;
-    (void)idx;
-    (void)data;
-#endif
-    return SSL_FAILURE;
-}
-
-
-int wolfSSL_set_session_id_context(WOLFSSL* ssl, const unsigned char* id,
-                               unsigned int len)
-{
-    (void)ssl;
-    (void)id;
-    (void)len;
-    return 0;
-}
-
-
-void wolfSSL_set_connect_state(WOLFSSL* ssl)
-{
-    (void)ssl;
-    /* client by default */
-}
-#endif
-
-int wolfSSL_get_shutdown(const WOLFSSL* ssl)
-{
-    return (ssl->options.isClosed  ||
-            ssl->options.connReset ||
-            ssl->options.sentNotify);
-}
-
-
-int wolfSSL_session_reused(WOLFSSL* ssl)
-{
-    return ssl->options.resuming;
-}
-
-#ifdef OPENSSL_EXTRA
-void wolfSSL_SESSION_free(WOLFSSL_SESSION* session)
-{
-    (void)session;
-}
-#endif
-
-const char* wolfSSL_get_version(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("SSL_get_version");
-    if (ssl->version.major == SSLv3_MAJOR) {
-        switch (ssl->version.minor) {
-            case SSLv3_MINOR :
-                return "SSLv3";
-            case TLSv1_MINOR :
-                return "TLSv1";
-            case TLSv1_1_MINOR :
-                return "TLSv1.1";
-            case TLSv1_2_MINOR :
-                return "TLSv1.2";
-            default:
-                return "unknown";
-        }
-    }
-    else if (ssl->version.major == DTLS_MAJOR) {
-        switch (ssl->version.minor) {
-            case DTLS_MINOR :
-                return "DTLS";
-            case DTLSv1_2_MINOR :
-                return "DTLSv1.2";
-            default:
-                return "unknown";
-        }
-    }
-    return "unknown";
-}
-
-
-/* current library version */
-const char* wolfSSL_lib_version(void)
-{
-    return LIBWOLFSSL_VERSION_STRING;
-}
-
-
-/* current library version in hex */
-word32 wolfSSL_lib_version_hex(void)
-{
-    return LIBWOLFSSL_VERSION_HEX;
-}
-
-
-int wolfSSL_get_current_cipher_suite(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("SSL_get_current_cipher_suite");
-    if (ssl)
-        return (ssl->options.cipherSuite0 << 8) | ssl->options.cipherSuite;
-    return 0;
-}
-
-WOLFSSL_CIPHER* wolfSSL_get_current_cipher(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("SSL_get_current_cipher");
-    if (ssl)
-        return &ssl->cipher;
-    else
-        return NULL;
-}
-
-
-const char* wolfSSL_CIPHER_get_name(const WOLFSSL_CIPHER* cipher)
-{
-    (void)cipher;
-
-    WOLFSSL_ENTER("SSL_CIPHER_get_name");
-#ifndef NO_ERROR_STRINGS
-    if (cipher) {
-#if defined(HAVE_CHACHA)
-        if (cipher->ssl->options.cipherSuite0 == CHACHA_BYTE) {
-        /* ChaCha suites */
-        switch (cipher->ssl->options.cipherSuite) {
-#ifdef HAVE_CHACHA
-#ifndef NO_RSA
-            case TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 :
-                return "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256";
-
-            case TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 :
-                return "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256";
-#endif
-            case TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 :
-                return "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256";
-#endif
-            }
-        }
-#endif
-
-#if defined(HAVE_ECC) || defined(HAVE_AESCCM)
-        /* Awkwardly, the ECC cipher suites use the ECC_BYTE as expected,
-         * but the AES-CCM cipher suites also use it, even the ones that
-         * aren't ECC. */
-        if (cipher->ssl->options.cipherSuite0 == ECC_BYTE) {
-        /* ECC suites */
-        switch (cipher->ssl->options.cipherSuite) {
-#ifdef HAVE_ECC
-#ifndef NO_RSA
-            case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 :
-                return "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256";
-#endif
-            case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 :
-                return "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256";
-#ifndef NO_RSA
-            case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 :
-                return "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256";
-#endif
-            case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 :
-                return "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256";
-#ifndef NO_RSA
-            case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 :
-                return "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384";
-#endif
-            case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 :
-                return "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384";
-#ifndef NO_RSA
-            case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 :
-                return "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384";
-#endif
-            case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 :
-                return "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384";
-#ifndef NO_SHA
-#ifndef NO_RSA
-            case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA :
-                return "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA";
-            case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA :
-                return "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA";
-#endif
-            case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA :
-                return "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA";
-            case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA :
-                return "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA";
-#ifndef NO_RC4
-    #ifndef NO_RSA
-            case TLS_ECDHE_RSA_WITH_RC4_128_SHA :
-                return "TLS_ECDHE_RSA_WITH_RC4_128_SHA";
-    #endif
-            case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA :
-                return "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA";
-#endif
-#ifndef NO_DES3
-    #ifndef NO_RSA
-            case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA :
-                return "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA";
-    #endif
-            case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA :
-                return "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA";
-#endif
-
-#ifndef NO_RSA
-            case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA :
-                return "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA";
-            case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA :
-                return "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA";
-#endif
-            case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA :
-                return "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA";
-            case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA :
-                return "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA";
-#ifndef NO_RC4
-    #ifndef NO_RSA
-            case TLS_ECDH_RSA_WITH_RC4_128_SHA :
-                return "TLS_ECDH_RSA_WITH_RC4_128_SHA";
-    #endif
-            case TLS_ECDH_ECDSA_WITH_RC4_128_SHA :
-                return "TLS_ECDH_ECDSA_WITH_RC4_128_SHA";
-#endif
-#ifndef NO_DES3
-    #ifndef NO_RSA
-            case TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA :
-                return "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA";
-    #endif
-            case TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA :
-                return "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA";
-#endif
-#endif /* NO_SHA */
-
-#ifdef HAVE_AESGCM
-#ifndef NO_RSA
-            case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 :
-                return "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256";
-            case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 :
-                return "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384";
-#endif
-            case TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 :
-                return "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256";
-            case TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 :
-                return "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384";
-#ifndef NO_RSA
-            case TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 :
-                return "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256";
-            case TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 :
-                return "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384";
-#endif
-            case TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 :
-                return "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256";
-            case TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 :
-                return "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384";
-#endif
-#endif /* HAVE_ECC */
-
-#ifdef HAVE_AESCCM
-#ifndef NO_RSA
-            case TLS_RSA_WITH_AES_128_CCM_8 :
-                return "TLS_RSA_WITH_AES_128_CCM_8";
-            case TLS_RSA_WITH_AES_256_CCM_8 :
-                return "TLS_RSA_WITH_AES_256_CCM_8";
-#endif
-#ifndef NO_PSK
-            case TLS_PSK_WITH_AES_128_CCM_8 :
-                return "TLS_PSK_WITH_AES_128_CCM_8";
-            case TLS_PSK_WITH_AES_256_CCM_8 :
-                return "TLS_PSK_WITH_AES_256_CCM_8";
-            case TLS_PSK_WITH_AES_128_CCM :
-                return "TLS_PSK_WITH_AES_128_CCM";
-            case TLS_PSK_WITH_AES_256_CCM :
-                return "TLS_PSK_WITH_AES_256_CCM";
-            case TLS_DHE_PSK_WITH_AES_128_CCM :
-                return "TLS_DHE_PSK_WITH_AES_128_CCM";
-            case TLS_DHE_PSK_WITH_AES_256_CCM :
-                return "TLS_DHE_PSK_WITH_AES_256_CCM";
-#endif
-#ifdef HAVE_ECC
-            case TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8:
-                return "TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8";
-            case TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 :
-                return "TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8";
-#endif
-#endif
-
-            default:
-                return "NONE";
-        }
-        }
-#endif  /* ECC */
-        if (cipher->ssl->options.cipherSuite0 != ECC_BYTE &&
-            cipher->ssl->options.cipherSuite0 != CHACHA_BYTE) {
-
-            /* normal suites */
-        switch (cipher->ssl->options.cipherSuite) {
-#ifndef NO_RSA
-#ifndef NO_RC4
-    #ifndef NO_SHA
-            case SSL_RSA_WITH_RC4_128_SHA :
-                return "SSL_RSA_WITH_RC4_128_SHA";
-    #endif
-    #ifndef NO_MD5
-            case SSL_RSA_WITH_RC4_128_MD5 :
-                return "SSL_RSA_WITH_RC4_128_MD5";
-    #endif
-#endif
-#ifndef NO_SHA
-    #ifndef NO_DES3
-            case SSL_RSA_WITH_3DES_EDE_CBC_SHA :
-                return "SSL_RSA_WITH_3DES_EDE_CBC_SHA";
-    #endif
-            case TLS_RSA_WITH_AES_128_CBC_SHA :
-                return "TLS_RSA_WITH_AES_128_CBC_SHA";
-            case TLS_RSA_WITH_AES_256_CBC_SHA :
-                return "TLS_RSA_WITH_AES_256_CBC_SHA";
-#endif
-            case TLS_RSA_WITH_AES_128_CBC_SHA256 :
-                return "TLS_RSA_WITH_AES_128_CBC_SHA256";
-            case TLS_RSA_WITH_AES_256_CBC_SHA256 :
-                return "TLS_RSA_WITH_AES_256_CBC_SHA256";
-    #ifdef HAVE_BLAKE2
-            case TLS_RSA_WITH_AES_128_CBC_B2B256:
-                return "TLS_RSA_WITH_AES_128_CBC_B2B256";
-            case TLS_RSA_WITH_AES_256_CBC_B2B256:
-                return "TLS_RSA_WITH_AES_256_CBC_B2B256";
-    #endif
-#ifndef NO_SHA
-            case TLS_RSA_WITH_NULL_SHA :
-                return "TLS_RSA_WITH_NULL_SHA";
-#endif
-            case TLS_RSA_WITH_NULL_SHA256 :
-                return "TLS_RSA_WITH_NULL_SHA256";
-#endif /* NO_RSA */
-#ifndef NO_PSK
-#ifndef NO_SHA
-            case TLS_PSK_WITH_AES_128_CBC_SHA :
-                return "TLS_PSK_WITH_AES_128_CBC_SHA";
-            case TLS_PSK_WITH_AES_256_CBC_SHA :
-                return "TLS_PSK_WITH_AES_256_CBC_SHA";
-#endif
-#ifndef NO_SHA256
-            case TLS_PSK_WITH_AES_128_CBC_SHA256 :
-                return "TLS_PSK_WITH_AES_128_CBC_SHA256";
-            case TLS_PSK_WITH_NULL_SHA256 :
-                return "TLS_PSK_WITH_NULL_SHA256";
-            case TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 :
-                return "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256";
-            case TLS_DHE_PSK_WITH_NULL_SHA256 :
-                return "TLS_DHE_PSK_WITH_NULL_SHA256";
-    #ifdef HAVE_AESGCM
-            case TLS_PSK_WITH_AES_128_GCM_SHA256 :
-                return "TLS_PSK_WITH_AES_128_GCM_SHA256";
-            case TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 :
-                return "TLS_DHE_PSK_WITH_AES_128_GCM_SHA256";
-    #endif
-#endif
-#ifdef WOLFSSL_SHA384
-            case TLS_PSK_WITH_AES_256_CBC_SHA384 :
-                return "TLS_PSK_WITH_AES_256_CBC_SHA384";
-            case TLS_PSK_WITH_NULL_SHA384 :
-                return "TLS_PSK_WITH_NULL_SHA384";
-            case TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 :
-                return "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384";
-            case TLS_DHE_PSK_WITH_NULL_SHA384 :
-                return "TLS_DHE_PSK_WITH_NULL_SHA384";
-    #ifdef HAVE_AESGCM
-            case TLS_PSK_WITH_AES_256_GCM_SHA384 :
-                return "TLS_PSK_WITH_AES_256_GCM_SHA384";
-            case TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 :
-                return "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384";
-    #endif
-#endif
-#ifndef NO_SHA
-            case TLS_PSK_WITH_NULL_SHA :
-                return "TLS_PSK_WITH_NULL_SHA";
-#endif
-#endif /* NO_PSK */
-#ifndef NO_RSA
-            case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 :
-                return "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256";
-            case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 :
-                return "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256";
-#ifndef NO_SHA
-            case TLS_DHE_RSA_WITH_AES_128_CBC_SHA :
-                return "TLS_DHE_RSA_WITH_AES_128_CBC_SHA";
-            case TLS_DHE_RSA_WITH_AES_256_CBC_SHA :
-                return "TLS_DHE_RSA_WITH_AES_256_CBC_SHA";
-#endif
-#ifndef NO_HC128
-    #ifndef NO_MD5
-            case TLS_RSA_WITH_HC_128_MD5 :
-                return "TLS_RSA_WITH_HC_128_MD5";
-    #endif
-    #ifndef NO_SHA
-            case TLS_RSA_WITH_HC_128_SHA :
-                return "TLS_RSA_WITH_HC_128_SHA";
-    #endif
-    #ifdef HAVE_BLAKE2
-            case TLS_RSA_WITH_HC_128_B2B256:
-                return "TLS_RSA_WITH_HC_128_B2B256";
-    #endif
-#endif /* NO_HC128 */
-#ifndef NO_SHA
-    #ifndef NO_RABBIT
-            case TLS_RSA_WITH_RABBIT_SHA :
-                return "TLS_RSA_WITH_RABBIT_SHA";
-    #endif
-    #ifdef HAVE_NTRU
-        #ifndef NO_RC4
-            case TLS_NTRU_RSA_WITH_RC4_128_SHA :
-                return "TLS_NTRU_RSA_WITH_RC4_128_SHA";
-        #endif
-        #ifndef NO_DES3
-            case TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA :
-                return "TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA";
-        #endif
-            case TLS_NTRU_RSA_WITH_AES_128_CBC_SHA :
-                return "TLS_NTRU_RSA_WITH_AES_128_CBC_SHA";
-            case TLS_NTRU_RSA_WITH_AES_256_CBC_SHA :
-                return "TLS_NTRU_RSA_WITH_AES_256_CBC_SHA";
-    #endif /* HAVE_NTRU */
-#endif /* NO_SHA */
-            case TLS_RSA_WITH_AES_128_GCM_SHA256 :
-                return "TLS_RSA_WITH_AES_128_GCM_SHA256";
-            case TLS_RSA_WITH_AES_256_GCM_SHA384 :
-                return "TLS_RSA_WITH_AES_256_GCM_SHA384";
-            case TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 :
-                return "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256";
-            case TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 :
-                return "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384";
-#ifndef NO_SHA
-            case TLS_RSA_WITH_CAMELLIA_128_CBC_SHA :
-                return "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA";
-            case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA :
-                return "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA";
-#endif
-            case TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 :
-                return "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256";
-            case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 :
-                return "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256";
-#ifndef NO_SHA
-            case TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA :
-                return "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA";
-            case TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA :
-                return "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA";
-#endif
-            case TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 :
-                return "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256";
-            case TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 :
-                return "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256";
-#endif /* NO_RSA */
-#ifdef BUILD_TLS_DH_anon_WITH_AES_128_CBC_SHA
-            case TLS_DH_anon_WITH_AES_128_CBC_SHA :
-                return "TLS_DH_anon_WITH_AES_128_CBC_SHA";
-#endif
-            default:
-                return "NONE";
-        }  /* switch */
-        }  /* normal / ECC */
-    }
-#endif /* NO_ERROR_STRINGS */
-    return "NONE";
-}
-
-
-const char* wolfSSL_get_cipher(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("wolfSSL_get_cipher");
-    return wolfSSL_CIPHER_get_name(wolfSSL_get_current_cipher(ssl));
-}
-
-#ifdef OPENSSL_EXTRA
-
-
-
-char* wolfSSL_CIPHER_description(WOLFSSL_CIPHER* cipher, char* in, int len)
-{
-    (void)cipher;
-    (void)in;
-    (void)len;
-    return 0;
-}
-
-
-WOLFSSL_SESSION* wolfSSL_get1_session(WOLFSSL* ssl)  /* what's ref count */
-{
-    (void)ssl;
-    return 0;
-}
-
-
-void wolfSSL_X509_free(WOLFSSL_X509* buf)
-{
-    FreeX509(buf);
-}
-
-
-/* was do nothing */
-/*
-void OPENSSL_free(void* buf)
-{
-    (void)buf;
-}
-*/
-
-
-int wolfSSL_OCSP_parse_url(char* url, char** host, char** port, char** path,
-                   int* ssl)
-{
-    (void)url;
-    (void)host;
-    (void)port;
-    (void)path;
-    (void)ssl;
-    return 0;
-}
-
-
-WOLFSSL_METHOD* wolfSSLv2_client_method(void)
-{
-    return 0;
-}
-
-
-WOLFSSL_METHOD* wolfSSLv2_server_method(void)
-{
-    return 0;
-}
-
-
-#ifndef NO_MD4
-
-void wolfSSL_MD4_Init(WOLFSSL_MD4_CTX* md4)
-{
-    /* make sure we have a big enough buffer */
-    typedef char ok[sizeof(md4->buffer) >= sizeof(Md4) ? 1 : -1];
-    (void) sizeof(ok);
-
-    WOLFSSL_ENTER("MD4_Init");
-    wc_InitMd4((Md4*)md4);
-}
-
-
-void wolfSSL_MD4_Update(WOLFSSL_MD4_CTX* md4, const void* data,
-                       unsigned long len)
-{
-    WOLFSSL_ENTER("MD4_Update");
-    wc_Md4Update((Md4*)md4, (const byte*)data, (word32)len);
-}
-
-
-void wolfSSL_MD4_Final(unsigned char* digest, WOLFSSL_MD4_CTX* md4)
-{
-    WOLFSSL_ENTER("MD4_Final");
-    wc_Md4Final((Md4*)md4, digest);
-}
-
-#endif /* NO_MD4 */
-
-
-WOLFSSL_BIO* wolfSSL_BIO_pop(WOLFSSL_BIO* top)
-{
-    (void)top;
-    return 0;
-}
-
-
-int wolfSSL_BIO_pending(WOLFSSL_BIO* bio)
-{
-    (void)bio;
-    return 0;
-}
-
-
-
-WOLFSSL_BIO_METHOD* wolfSSL_BIO_s_mem(void)
-{
-    static WOLFSSL_BIO_METHOD meth;
-
-    WOLFSSL_ENTER("BIO_s_mem");
-    meth.type = BIO_MEMORY;
-
-    return &meth;
-}
-
-
-WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_base64(void)
-{
-    return 0;
-}
-
-
-void wolfSSL_BIO_set_flags(WOLFSSL_BIO* bio, int flags)
-{
-    (void)bio;
-    (void)flags;
-}
-
-
-
-void wolfSSL_RAND_screen(void)
-{
-
-}
-
-
-const char* wolfSSL_RAND_file_name(char* fname, unsigned long len)
-{
-    (void)fname;
-    (void)len;
-    return 0;
-}
-
-
-int wolfSSL_RAND_write_file(const char* fname)
-{
-    (void)fname;
-    return 0;
-}
-
-
-int wolfSSL_RAND_load_file(const char* fname, long len)
-{
-    (void)fname;
-    /* wolfCrypt provides enough entropy internally or will report error */
-    if (len == -1)
-        return 1024;
-    else
-        return (int)len;
-}
-
-
-int wolfSSL_RAND_egd(const char* path)
-{
-    (void)path;
-    return 0;
-}
-
-
-
-WOLFSSL_COMP_METHOD* wolfSSL_COMP_zlib(void)
-{
-    return 0;
-}
-
-
-WOLFSSL_COMP_METHOD* wolfSSL_COMP_rle(void)
-{
-    return 0;
-}
-
-
-int wolfSSL_COMP_add_compression_method(int method, void* data)
-{
-    (void)method;
-    (void)data;
-    return 0;
-}
-
-
-
-int wolfSSL_get_ex_new_index(long idx, void* data, void* cb1, void* cb2,
-                         void* cb3)
-{
-    (void)idx;
-    (void)data;
-    (void)cb1;
-    (void)cb2;
-    (void)cb3;
-    return 0;
-}
-
-
-void wolfSSL_set_dynlock_create_callback(WOLFSSL_dynlock_value* (*f)(
-                                                          const char*, int))
-{
-    (void)f;
-}
-
-
-void wolfSSL_set_dynlock_lock_callback(
-             void (*f)(int, WOLFSSL_dynlock_value*, const char*, int))
-{
-    (void)f;
-}
-
-
-void wolfSSL_set_dynlock_destroy_callback(
-                  void (*f)(WOLFSSL_dynlock_value*, const char*, int))
-{
-    (void)f;
-}
-
-
-
-const char* wolfSSL_X509_verify_cert_error_string(long err)
-{
-    (void)err;
-    return 0;
-}
-
-
-
-int wolfSSL_X509_LOOKUP_add_dir(WOLFSSL_X509_LOOKUP* lookup, const char* dir,
-                               long len)
-{
-    (void)lookup;
-    (void)dir;
-    (void)len;
-    return 0;
-}
-
-
-int wolfSSL_X509_LOOKUP_load_file(WOLFSSL_X509_LOOKUP* lookup,
-                                 const char* file, long len)
-{
-    (void)lookup;
-    (void)file;
-    (void)len;
-    return 0;
-}
-
-
-WOLFSSL_X509_LOOKUP_METHOD* wolfSSL_X509_LOOKUP_hash_dir(void)
-{
-    return 0;
-}
-
-
-WOLFSSL_X509_LOOKUP_METHOD* wolfSSL_X509_LOOKUP_file(void)
-{
-    return 0;
-}
-
-
-
-WOLFSSL_X509_LOOKUP* wolfSSL_X509_STORE_add_lookup(WOLFSSL_X509_STORE* store,
-                                               WOLFSSL_X509_LOOKUP_METHOD* m)
-{
-    (void)store;
-    (void)m;
-    return 0;
-}
-
-
-int wolfSSL_X509_STORE_add_cert(WOLFSSL_X509_STORE* store, WOLFSSL_X509* x509)
-{
-    int result = SSL_FATAL_ERROR;
-
-    WOLFSSL_ENTER("wolfSSL_X509_STORE_add_cert");
-    if (store != NULL && store->cm != NULL && x509 != NULL) {
-        buffer derCert;
-        derCert.buffer = (byte*)XMALLOC(x509->derCert.length,
-                                                   NULL, DYNAMIC_TYPE_CERT);
-        if (derCert.buffer != NULL) {
-            derCert.length = x509->derCert.length;
-                /* AddCA() frees the buffer. */
-            XMEMCPY(derCert.buffer,
-                                x509->derCert.buffer, x509->derCert.length);
-            result = AddCA(store->cm, derCert, WOLFSSL_USER_CA, 1);
-            if (result != SSL_SUCCESS) result = SSL_FATAL_ERROR;
-        }
-    }
-
-    WOLFSSL_LEAVE("wolfSSL_X509_STORE_add_cert", result);
-    return result;
-}
-
-
-WOLFSSL_X509_STORE* wolfSSL_X509_STORE_new(void)
-{
-    WOLFSSL_X509_STORE* store = NULL;
-
-    store = (WOLFSSL_X509_STORE*)XMALLOC(sizeof(WOLFSSL_X509_STORE), NULL, 0);
-    if (store != NULL) {
-        store->cm = wolfSSL_CertManagerNew();
-        if (store->cm == NULL) {
-            XFREE(store, NULL, 0);
-            store = NULL;
-        }
-    }
-
-    return store;
-}
-
-
-void wolfSSL_X509_STORE_free(WOLFSSL_X509_STORE* store)
-{
-    if (store != NULL) {
-        if (store->cm != NULL)
-        wolfSSL_CertManagerFree(store->cm);
-        XFREE(store, NULL, 0);
-    }
-}
-
-
-int wolfSSL_X509_STORE_set_default_paths(WOLFSSL_X509_STORE* store)
-{
-    (void)store;
-    return SSL_SUCCESS;
-}
-
-
-int wolfSSL_X509_STORE_get_by_subject(WOLFSSL_X509_STORE_CTX* ctx, int idx,
-                            WOLFSSL_X509_NAME* name, WOLFSSL_X509_OBJECT* obj)
-{
-    (void)ctx;
-    (void)idx;
-    (void)name;
-    (void)obj;
-    return 0;
-}
-
-
-WOLFSSL_X509_STORE_CTX* wolfSSL_X509_STORE_CTX_new(void)
-{
-    WOLFSSL_X509_STORE_CTX* ctx = (WOLFSSL_X509_STORE_CTX*)XMALLOC(
-                                    sizeof(WOLFSSL_X509_STORE_CTX), NULL, 0);
-
-    if (ctx != NULL)
-        wolfSSL_X509_STORE_CTX_init(ctx, NULL, NULL, NULL);
-
-    return ctx;
-}
-
-
-int wolfSSL_X509_STORE_CTX_init(WOLFSSL_X509_STORE_CTX* ctx,
-     WOLFSSL_X509_STORE* store, WOLFSSL_X509* x509, STACK_OF(WOLFSSL_X509)* sk)
-{
-    (void)sk;
-    if (ctx != NULL) {
-        ctx->store = store;
-        ctx->current_cert = x509;
-        ctx->domain = NULL;
-        ctx->ex_data = NULL;
-        ctx->userCtx = NULL;
-        ctx->error = 0;
-        ctx->error_depth = 0;
-        ctx->discardSessionCerts = 0;
-        return SSL_SUCCESS;
-    }
-    return SSL_FATAL_ERROR;
-}
-
-
-void wolfSSL_X509_STORE_CTX_free(WOLFSSL_X509_STORE_CTX* ctx)
-{
-    if (ctx != NULL) {
-        if (ctx->store != NULL)
-            wolfSSL_X509_STORE_free(ctx->store);
-        if (ctx->current_cert != NULL)
-            wolfSSL_FreeX509(ctx->current_cert);
-        XFREE(ctx, NULL, 0);
-    }
-}
-
-
-void wolfSSL_X509_STORE_CTX_cleanup(WOLFSSL_X509_STORE_CTX* ctx)
-{
-    (void)ctx;
-}
-
-
-int wolfSSL_X509_verify_cert(WOLFSSL_X509_STORE_CTX* ctx)
-{
-    if (ctx != NULL && ctx->store != NULL && ctx->store->cm != NULL
-                                             && ctx->current_cert != NULL) {
-        return wolfSSL_CertManagerVerifyBuffer(ctx->store->cm,
-                    ctx->current_cert->derCert.buffer,
-                    ctx->current_cert->derCert.length,
-                    SSL_FILETYPE_ASN1);
-    }
-    return SSL_FATAL_ERROR;
-}
-
-
-WOLFSSL_ASN1_TIME* wolfSSL_X509_CRL_get_lastUpdate(WOLFSSL_X509_CRL* crl)
-{
-    (void)crl;
-    return 0;
-}
-
-
-WOLFSSL_ASN1_TIME* wolfSSL_X509_CRL_get_nextUpdate(WOLFSSL_X509_CRL* crl)
-{
-    (void)crl;
-    return 0;
-}
-
-
-
-WOLFSSL_EVP_PKEY* wolfSSL_X509_get_pubkey(WOLFSSL_X509* x509)
-{
-    WOLFSSL_EVP_PKEY* key = NULL;
-    if (x509 != NULL) {
-        key = (WOLFSSL_EVP_PKEY*)XMALLOC(
-                    sizeof(WOLFSSL_EVP_PKEY), NULL, DYNAMIC_TYPE_PUBLIC_KEY);
-        if (key != NULL) {
-            key->type = x509->pubKeyOID;
-            key->save_type = 0;
-            key->pkey.ptr = (char*)XMALLOC(
-                        x509->pubKey.length, NULL, DYNAMIC_TYPE_PUBLIC_KEY);
-            if (key->pkey.ptr == NULL) {
-                XFREE(key, NULL, DYNAMIC_TYPE_PUBLIC_KEY);
-                return NULL;
-            }
-            XMEMCPY(key->pkey.ptr,
-                                  x509->pubKey.buffer, x509->pubKey.length);
-            key->pkey_sz = x509->pubKey.length;
-            #ifdef HAVE_ECC
-                key->pkey_curve = (int)x509->pkCurveOID;
-            #endif /* HAVE_ECC */
-        }
-    }
-    return key;
-}
-
-
-int wolfSSL_X509_CRL_verify(WOLFSSL_X509_CRL* crl, WOLFSSL_EVP_PKEY* key)
-{
-    (void)crl;
-    (void)key;
-    return 0;
-}
-
-
-void wolfSSL_X509_STORE_CTX_set_error(WOLFSSL_X509_STORE_CTX* ctx, int err)
-{
-    (void)ctx;
-    (void)err;
-}
-
-
-void wolfSSL_X509_OBJECT_free_contents(WOLFSSL_X509_OBJECT* obj)
-{
-    (void)obj;
-}
-
-
-void wolfSSL_EVP_PKEY_free(WOLFSSL_EVP_PKEY* key)
-{
-    if (key != NULL) {
-        if (key->pkey.ptr != NULL)
-            XFREE(key->pkey.ptr, NULL, 0);
-        XFREE(key, NULL, 0);
-    }
-}
-
-
-int wolfSSL_X509_cmp_current_time(const WOLFSSL_ASN1_TIME* asnTime)
-{
-    (void)asnTime;
-    return 0;
-}
-
-
-int wolfSSL_sk_X509_REVOKED_num(WOLFSSL_X509_REVOKED* revoked)
-{
-    (void)revoked;
-    return 0;
-}
-
-
-
-WOLFSSL_X509_REVOKED* wolfSSL_X509_CRL_get_REVOKED(WOLFSSL_X509_CRL* crl)
-{
-    (void)crl;
-    return 0;
-}
-
-
-WOLFSSL_X509_REVOKED* wolfSSL_sk_X509_REVOKED_value(
-                                    WOLFSSL_X509_REVOKED* revoked, int value)
-{
-    (void)revoked;
-    (void)value;
-    return 0;
-}
-
-
-
-WOLFSSL_ASN1_INTEGER* wolfSSL_X509_get_serialNumber(WOLFSSL_X509* x509)
-{
-    (void)x509;
-    return 0;
-}
-
-
-int wolfSSL_ASN1_TIME_print(WOLFSSL_BIO* bio, const WOLFSSL_ASN1_TIME* asnTime)
-{
-    (void)bio;
-    (void)asnTime;
-    return 0;
-}
-
-
-
-int wolfSSL_ASN1_INTEGER_cmp(const WOLFSSL_ASN1_INTEGER* a,
-                            const WOLFSSL_ASN1_INTEGER* b)
-{
-    (void)a;
-    (void)b;
-    return 0;
-}
-
-
-long wolfSSL_ASN1_INTEGER_get(const WOLFSSL_ASN1_INTEGER* i)
-{
-    (void)i;
-    return 0;
-}
-
-
-
-void* wolfSSL_X509_STORE_CTX_get_ex_data(WOLFSSL_X509_STORE_CTX* ctx, int idx)
-{
-#ifdef FORTRESS
-    if (ctx != NULL && idx == 0)
-        return ctx->ex_data;
-#else
-    (void)ctx;
-    (void)idx;
-#endif
-    return 0;
-}
-
-
-int wolfSSL_get_ex_data_X509_STORE_CTX_idx(void)
-{
-    return 0;
-}
-
-
-void* wolfSSL_get_ex_data(const WOLFSSL* ssl, int idx)
-{
-#ifdef FORTRESS
-    if (ssl != NULL && idx < MAX_EX_DATA)
-        return ssl->ex_data[idx];
-#else
-    (void)ssl;
-    (void)idx;
-#endif
-    return 0;
-}
-
-
-void wolfSSL_CTX_set_info_callback(WOLFSSL_CTX* ctx, void (*f)(void))
-{
-    (void)ctx;
-    (void)f;
-}
-
-
-unsigned long wolfSSL_ERR_peek_error(void)
-{
-    return 0;
-}
-
-
-int wolfSSL_ERR_GET_REASON(int err)
-{
-    (void)err;
-    return 0;
-}
-
-
-char* wolfSSL_alert_type_string_long(int alertID)
-{
-    (void)alertID;
-    return 0;
-}
-
-
-char* wolfSSL_alert_desc_string_long(int alertID)
-{
-    (void)alertID;
-    return 0;
-}
-
-
-char* wolfSSL_state_string_long(WOLFSSL* ssl)
-{
-    (void)ssl;
-    return 0;
-}
-
-
-int wolfSSL_PEM_def_callback(char* name, int num, int w, void* key)
-{
-    (void)name;
-    (void)num;
-    (void)w;
-    (void)key;
-    return 0;
-}
-
-
-long wolfSSL_CTX_sess_accept(WOLFSSL_CTX* ctx)
-{
-    (void)ctx;
-    return 0;
-}
-
-
-long wolfSSL_CTX_sess_connect(WOLFSSL_CTX* ctx)
-{
-    (void)ctx;
-    return 0;
-}
-
-
-long wolfSSL_CTX_sess_accept_good(WOLFSSL_CTX* ctx)
-{
-    (void)ctx;
-    return 0;
-}
-
-
-long wolfSSL_CTX_sess_connect_good(WOLFSSL_CTX* ctx)
-{
-    (void)ctx;
-    return 0;
-}
-
-
-long wolfSSL_CTX_sess_accept_renegotiate(WOLFSSL_CTX* ctx)
-{
-    (void)ctx;
-    return 0;
-}
-
-
-long wolfSSL_CTX_sess_connect_renegotiate(WOLFSSL_CTX* ctx)
-{
-    (void)ctx;
-    return 0;
-}
-
-
-long wolfSSL_CTX_sess_hits(WOLFSSL_CTX* ctx)
-{
-    (void)ctx;
-    return 0;
-}
-
-
-long wolfSSL_CTX_sess_cb_hits(WOLFSSL_CTX* ctx)
-{
-    (void)ctx;
-    return 0;
-}
-
-
-long wolfSSL_CTX_sess_cache_full(WOLFSSL_CTX* ctx)
-{
-    (void)ctx;
-    return 0;
-}
-
-
-long wolfSSL_CTX_sess_misses(WOLFSSL_CTX* ctx)
-{
-    (void)ctx;
-    return 0;
-}
-
-
-long wolfSSL_CTX_sess_timeouts(WOLFSSL_CTX* ctx)
-{
-    (void)ctx;
-    return 0;
-}
-
-
-long wolfSSL_CTX_sess_number(WOLFSSL_CTX* ctx)
-{
-    (void)ctx;
-    return 0;
-}
-
-#ifndef NO_DES3
-
-void wolfSSL_DES_set_key_unchecked(WOLFSSL_const_DES_cblock* myDes,
-                                               WOLFSSL_DES_key_schedule* key)
-{
-    (void)myDes;
-    (void)key;
-}
-
-
-void wolfSSL_DES_set_odd_parity(WOLFSSL_DES_cblock* myDes)
-{
-    (void)myDes;
-}
-
-
-void wolfSSL_DES_ecb_encrypt(WOLFSSL_DES_cblock* desa,
-             WOLFSSL_DES_cblock* desb, WOLFSSL_DES_key_schedule* key, int len)
-{
-    (void)desa;
-    (void)desb;
-    (void)key;
-    (void)len;
-}
-
-#endif /* NO_DES3 */
-
-int wolfSSL_BIO_printf(WOLFSSL_BIO* bio, const char* format, ...)
-{
-    (void)bio;
-    (void)format;
-    return 0;
-}
-
-
-int wolfSSL_ASN1_UTCTIME_print(WOLFSSL_BIO* bio, const WOLFSSL_ASN1_UTCTIME* a)
-{
-    (void)bio;
-    (void)a;
-    return 0;
-}
-
-
-int  wolfSSL_sk_num(WOLFSSL_X509_REVOKED* rev)
-{
-    (void)rev;
-    return 0;
-}
-
-
-void* wolfSSL_sk_value(WOLFSSL_X509_REVOKED* rev, int i)
-{
-    (void)rev;
-    (void)i;
-    return 0;
-}
-
-
-/* stunnel 4.28 needs */
-void* wolfSSL_CTX_get_ex_data(const WOLFSSL_CTX* ctx, int d)
-{
-    (void)ctx;
-    (void)d;
-    return 0;
-}
-
-
-int wolfSSL_CTX_set_ex_data(WOLFSSL_CTX* ctx, int d, void* p)
-{
-    (void)ctx;
-    (void)d;
-    (void)p;
-    return SSL_SUCCESS;
-}
-
-
-void wolfSSL_CTX_sess_set_get_cb(WOLFSSL_CTX* ctx,
-                    WOLFSSL_SESSION*(*f)(WOLFSSL*, unsigned char*, int, int*))
-{
-    (void)ctx;
-    (void)f;
-}
-
-
-void wolfSSL_CTX_sess_set_new_cb(WOLFSSL_CTX* ctx,
-                             int (*f)(WOLFSSL*, WOLFSSL_SESSION*))
-{
-    (void)ctx;
-    (void)f;
-}
-
-
-void wolfSSL_CTX_sess_set_remove_cb(WOLFSSL_CTX* ctx, void (*f)(WOLFSSL_CTX*,
-                                                        WOLFSSL_SESSION*))
-{
-    (void)ctx;
-    (void)f;
-}
-
-
-int wolfSSL_i2d_SSL_SESSION(WOLFSSL_SESSION* sess, unsigned char** p)
-{
-    (void)sess;
-    (void)p;
-    return sizeof(WOLFSSL_SESSION);
-}
-
-
-WOLFSSL_SESSION* wolfSSL_d2i_SSL_SESSION(WOLFSSL_SESSION** sess,
-                                const unsigned char** p, long i)
-{
-    (void)p;
-    (void)i;
-    if (sess)
-        return *sess;
-    return NULL;
-}
-
-
-long wolfSSL_SESSION_get_timeout(const WOLFSSL_SESSION* sess)
-{
-    WOLFSSL_ENTER("wolfSSL_SESSION_get_timeout");
-    return sess->timeout;
-}
-
-
-long wolfSSL_SESSION_get_time(const WOLFSSL_SESSION* sess)
-{
-    WOLFSSL_ENTER("wolfSSL_SESSION_get_time");
-    return sess->bornOn;
-}
-
-
-int wolfSSL_CTX_get_ex_new_index(long idx, void* arg, void* a, void* b,
-                                void* c)
-{
-    (void)idx;
-    (void)arg;
-    (void)a;
-    (void)b;
-    (void)c;
-    return 0;
-}
-
-#endif /* OPENSSL_EXTRA */
-
-
-#ifdef KEEP_PEER_CERT
-char*  wolfSSL_X509_get_subjectCN(WOLFSSL_X509* x509)
-{
-    if (x509 == NULL)
-        return NULL;
-
-    return x509->subjectCN;
-}
-#endif /* KEEP_PEER_CERT */
-
-#ifdef OPENSSL_EXTRA
-
-#ifdef FORTRESS
-int wolfSSL_cmp_peer_cert_to_file(WOLFSSL* ssl, const char *fname)
-{
-    int ret = SSL_FATAL_ERROR;
-
-    WOLFSSL_ENTER("wolfSSL_cmp_peer_cert_to_file");
-    if (ssl != NULL && fname != NULL)
-    {
-    #ifdef WOLFSSL_SMALL_STACK
-        EncryptedInfo* info = NULL;
-        byte           staticBuffer[1]; /* force heap usage */
-    #else
-        EncryptedInfo  info[1];
-        byte           staticBuffer[FILE_BUFFER_SIZE];
-    #endif
-        byte*          myBuffer  = staticBuffer;
-        int            dynamic   = 0;
-        XFILE          file      = XBADFILE;
-        long           sz        = 0;
-        int            eccKey    = 0;
-        WOLFSSL_CTX*    ctx       = ssl->ctx;
-        WOLFSSL_X509*   peer_cert = &ssl->peerCert;
-        buffer         fileDer;
-
-        file = XFOPEN(fname, "rb");
-        if (file == XBADFILE)
-            return SSL_BAD_FILE;
-
-        XFSEEK(file, 0, XSEEK_END);
-        sz = XFTELL(file);
-        XREWIND(file);
-
-        if (sz > (long)sizeof(staticBuffer)) {
-            WOLFSSL_MSG("Getting dynamic buffer");
-            myBuffer = (byte*)XMALLOC(sz, ctx->heap, DYNAMIC_TYPE_FILE);
-            dynamic = 1;
-        }
-
-    #ifdef WOLFSSL_SMALL_STACK
-        info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL,
-                                                   DYNAMIC_TYPE_TMP_BUFFER);
-        if (info == NULL)
-            ret = MEMORY_E;
-        else
-    #endif
-        {
-            info->set = 0;
-            info->ctx = ctx;
-            info->consumed = 0;
-            fileDer.buffer = 0;
-
-            if ((myBuffer != NULL) &&
-                (sz > 0) &&
-                (XFREAD(myBuffer, sz, 1, file) > 0) &&
-                (PemToDer(myBuffer, sz, CERT_TYPE,
-                          &fileDer, ctx->heap, info, &eccKey) == 0) &&
-                (fileDer.length != 0) &&
-                (fileDer.length == peer_cert->derCert.length) &&
-                (XMEMCMP(peer_cert->derCert.buffer, fileDer.buffer,
-                                                    fileDer.length) == 0))
-            {
-                ret = 0;
-            }
-
-        #ifdef WOLFSSL_SMALL_STACK
-            XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        #endif
-        }
-
-        XFREE(fileDer.buffer, ctx->heap, DYNAMIC_TYPE_CERT);
-        if (dynamic)
-            XFREE(myBuffer, ctx->heap, DYNAMIC_TYPE_FILE);
-
-        XFCLOSE(file);
-    }
-
-    return ret;
-}
-#endif
-
-
-static RNG globalRNG;
-static int initGlobalRNG = 0;
-
-/* SSL_SUCCESS on ok */
-int wolfSSL_RAND_seed(const void* seed, int len)
-{
-
-    WOLFSSL_MSG("wolfSSL_RAND_seed");
-
-    (void)seed;
-    (void)len;
-
-    if (initGlobalRNG == 0) {
-        if (wc_InitRng(&globalRNG) < 0) {
-            WOLFSSL_MSG("wolfSSL Init Global RNG failed");
-            return 0;
-        }
-        initGlobalRNG = 1;
-    }
-
-    return SSL_SUCCESS;
-}
-
-
-/* SSL_SUCCESS on ok */
-int wolfSSL_RAND_bytes(unsigned char* buf, int num)
-{
-    int    ret = 0;
-    int    initTmpRng = 0;
-    RNG*   rng = NULL;
-#ifdef WOLFSSL_SMALL_STACK
-    RNG*   tmpRNG = NULL;
-#else
-    RNG    tmpRNG[1];
-#endif
-
-    WOLFSSL_ENTER("RAND_bytes");
-
-#ifdef WOLFSSL_SMALL_STACK
-    tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (tmpRNG == NULL)
-        return ret;
-#endif
-
-    if (wc_InitRng(tmpRNG) == 0) {
-        rng = tmpRNG;
-        initTmpRng = 1;
-    }
-    else if (initGlobalRNG)
-        rng = &globalRNG;
-
-    if (rng) {
-        if (wc_RNG_GenerateBlock(rng, buf, num) != 0)
-            WOLFSSL_MSG("Bad wc_RNG_GenerateBlock");
-        else
-            ret = SSL_SUCCESS;
-    }
-
-    if (initTmpRng)
-        wc_FreeRng(tmpRNG);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-WOLFSSL_BN_CTX* wolfSSL_BN_CTX_new(void)
-{
-    static int ctx;  /* wolfcrypt doesn't now need ctx */
-
-    WOLFSSL_MSG("wolfSSL_BN_CTX_new");
-
-    return (WOLFSSL_BN_CTX*)&ctx;
-}
-
-void wolfSSL_BN_CTX_init(WOLFSSL_BN_CTX* ctx)
-{
-    (void)ctx;
-    WOLFSSL_MSG("wolfSSL_BN_CTX_init");
-}
-
-
-void wolfSSL_BN_CTX_free(WOLFSSL_BN_CTX* ctx)
-{
-    (void)ctx;
-    WOLFSSL_MSG("wolfSSL_BN_CTX_free");
-
-    /* do free since static ctx that does nothing */
-}
-
-
-static void InitwolfSSL_BigNum(WOLFSSL_BIGNUM* bn)
-{
-    WOLFSSL_MSG("InitwolfSSL_BigNum");
-    if (bn) {
-        bn->neg      = 0;
-        bn->internal = NULL;
-    }
-}
-
-
-WOLFSSL_BIGNUM* wolfSSL_BN_new(void)
-{
-    WOLFSSL_BIGNUM* external;
-    mp_int*        mpi;
-
-    WOLFSSL_MSG("wolfSSL_BN_new");
-
-    mpi = (mp_int*) XMALLOC(sizeof(mp_int), NULL, DYNAMIC_TYPE_BIGINT);
-    if (mpi == NULL) {
-        WOLFSSL_MSG("wolfSSL_BN_new malloc mpi failure");
-        return NULL;
-    }
-
-    external = (WOLFSSL_BIGNUM*) XMALLOC(sizeof(WOLFSSL_BIGNUM), NULL,
-                                        DYNAMIC_TYPE_BIGINT);
-    if (external == NULL) {
-        WOLFSSL_MSG("wolfSSL_BN_new malloc WOLFSSL_BIGNUM failure");
-        XFREE(mpi, NULL, DYNAMIC_TYPE_BIGINT);
-        return NULL;
-    }
-
-    InitwolfSSL_BigNum(external);
-    external->internal = mpi;
-    if (mp_init(mpi) != MP_OKAY) {
-        wolfSSL_BN_free(external);
-        return NULL;
-    }
-
-    return external;
-}
-
-
-void wolfSSL_BN_free(WOLFSSL_BIGNUM* bn)
-{
-    WOLFSSL_MSG("wolfSSL_BN_free");
-    if (bn) {
-        if (bn->internal) {
-            mp_clear((mp_int*)bn->internal);
-            XFREE(bn->internal, NULL, DYNAMIC_TYPE_BIGINT);
-            bn->internal = NULL;
-        }
-        XFREE(bn, NULL, DYNAMIC_TYPE_BIGINT);
-    }
-}
-
-
-void wolfSSL_BN_clear_free(WOLFSSL_BIGNUM* bn)
-{
-    WOLFSSL_MSG("wolfSSL_BN_clear_free");
-
-    wolfSSL_BN_free(bn);
-}
-
-
-/* SSL_SUCCESS on ok */
-int wolfSSL_BN_sub(WOLFSSL_BIGNUM* r, const WOLFSSL_BIGNUM* a,
-                  const WOLFSSL_BIGNUM* b)
-{
-    WOLFSSL_MSG("wolfSSL_BN_sub");
-
-    if (r == NULL || a == NULL || b == NULL)
-        return 0;
-
-    if (mp_sub((mp_int*)a->internal,(mp_int*)b->internal,
-               (mp_int*)r->internal) == MP_OKAY)
-        return SSL_SUCCESS;
-
-    WOLFSSL_MSG("wolfSSL_BN_sub mp_sub failed");
-    return 0;
-}
-
-
-/* SSL_SUCCESS on ok */
-int wolfSSL_BN_mod(WOLFSSL_BIGNUM* r, const WOLFSSL_BIGNUM* a,
-                  const WOLFSSL_BIGNUM* b, const WOLFSSL_BN_CTX* c)
-{
-    (void)c;
-    WOLFSSL_MSG("wolfSSL_BN_mod");
-
-    if (r == NULL || a == NULL || b == NULL)
-        return 0;
-
-    if (mp_mod((mp_int*)a->internal,(mp_int*)b->internal,
-               (mp_int*)r->internal) == MP_OKAY)
-        return SSL_SUCCESS;
-
-    WOLFSSL_MSG("wolfSSL_BN_mod mp_mod failed");
-    return 0;
-}
-
-
-const WOLFSSL_BIGNUM* wolfSSL_BN_value_one(void)
-{
-    static WOLFSSL_BIGNUM* bn_one = NULL;
-
-    WOLFSSL_MSG("wolfSSL_BN_value_one");
-
-    if (bn_one == NULL) {
-        bn_one = wolfSSL_BN_new();
-        if (bn_one)
-            mp_set_int((mp_int*)bn_one->internal, 1);
-    }
-
-    return bn_one;
-}
-
-
-int wolfSSL_BN_num_bytes(const WOLFSSL_BIGNUM* bn)
-{
-    WOLFSSL_MSG("wolfSSL_BN_num_bytes");
-
-    if (bn == NULL || bn->internal == NULL)
-        return 0;
-
-    return mp_unsigned_bin_size((mp_int*)bn->internal);
-}
-
-
-int wolfSSL_BN_num_bits(const WOLFSSL_BIGNUM* bn)
-{
-    WOLFSSL_MSG("wolfSSL_BN_num_bits");
-
-    if (bn == NULL || bn->internal == NULL)
-        return 0;
-
-    return mp_count_bits((mp_int*)bn->internal);
-}
-
-
-int wolfSSL_BN_is_zero(const WOLFSSL_BIGNUM* bn)
-{
-    WOLFSSL_MSG("wolfSSL_BN_is_zero");
-
-    if (bn == NULL || bn->internal == NULL)
-        return 0;
-
-    return mp_iszero((mp_int*)bn->internal);
-}
-
-
-int wolfSSL_BN_is_one(const WOLFSSL_BIGNUM* bn)
-{
-    WOLFSSL_MSG("wolfSSL_BN_is_one");
-
-    if (bn == NULL || bn->internal == NULL)
-        return 0;
-
-    if (mp_cmp_d((mp_int*)bn->internal, 1) == 0)
-        return 1;
-
-    return 0;
-}
-
-
-int wolfSSL_BN_is_odd(const WOLFSSL_BIGNUM* bn)
-{
-    WOLFSSL_MSG("wolfSSL_BN_is_odd");
-
-    if (bn == NULL || bn->internal == NULL)
-        return 0;
-
-    return mp_isodd((mp_int*)bn->internal);
-}
-
-
-int wolfSSL_BN_cmp(const WOLFSSL_BIGNUM* a, const WOLFSSL_BIGNUM* b)
-{
-    WOLFSSL_MSG("wolfSSL_BN_cmp");
-
-    if (a == NULL || a->internal == NULL || b == NULL || b->internal ==NULL)
-        return 0;
-
-    return mp_cmp((mp_int*)a->internal, (mp_int*)b->internal);
-}
-
-
-int wolfSSL_BN_bn2bin(const WOLFSSL_BIGNUM* bn, unsigned char* r)
-{
-    WOLFSSL_MSG("wolfSSL_BN_bn2bin");
-
-    if (bn == NULL || bn->internal == NULL) {
-        WOLFSSL_MSG("NULL bn error");
-        return SSL_FATAL_ERROR;
-    }
-
-    if (r == NULL)
-        return mp_unsigned_bin_size((mp_int*)bn->internal);
-
-    if (mp_to_unsigned_bin((mp_int*)bn->internal, r) != MP_OKAY) {
-        WOLFSSL_MSG("mp_to_unsigned_bin error");
-        return SSL_FATAL_ERROR;
-    }
-
-    return mp_unsigned_bin_size((mp_int*)bn->internal);
-}
-
-
-WOLFSSL_BIGNUM* wolfSSL_BN_bin2bn(const unsigned char* str, int len,
-                            WOLFSSL_BIGNUM* ret)
-{
-    WOLFSSL_MSG("wolfSSL_BN_bin2bn");
-
-    if (ret && ret->internal) {
-        if (mp_read_unsigned_bin((mp_int*)ret->internal, str, len) != 0) {
-            WOLFSSL_MSG("mp_read_unsigned_bin failure");
-            return NULL;
-        }
-    }
-    else {
-        WOLFSSL_MSG("wolfSSL_BN_bin2bn wants return bignum");
-    }
-
-    return ret;
-}
-
-
-int wolfSSL_mask_bits(WOLFSSL_BIGNUM* bn, int n)
-{
-    (void)bn;
-    (void)n;
-    WOLFSSL_MSG("wolfSSL_BN_mask_bits");
-
-    return SSL_FATAL_ERROR;
-}
-
-
-/* SSL_SUCCESS on ok */
-int wolfSSL_BN_rand(WOLFSSL_BIGNUM* bn, int bits, int top, int bottom)
-{
-    int           ret    = 0;
-    int           len    = bits / 8;
-    int           initTmpRng = 0;
-    RNG*          rng    = NULL;
-#ifdef WOLFSSL_SMALL_STACK
-    RNG*          tmpRNG = NULL;
-    byte*         buff   = NULL;
-#else
-    RNG           tmpRNG[1];
-    byte          buff[1024];
-#endif
-
-    (void)top;
-    (void)bottom;
-    WOLFSSL_MSG("wolfSSL_BN_rand");
-
-    if (bits % 8)
-        len++;
-
-#ifdef WOLFSSL_SMALL_STACK
-    buff   = (byte*)XMALLOC(1024,        NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    tmpRNG = (RNG*) XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (buff == NULL || tmpRNG == NULL) {
-        XFREE(buff,   NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return ret;
-    }
-#endif
-
-    if (bn == NULL || bn->internal == NULL)
-        WOLFSSL_MSG("Bad function arguments");
-    else if (wc_InitRng(tmpRNG) == 0) {
-        rng = tmpRNG;
-        initTmpRng = 1;
-    }
-    else if (initGlobalRNG)
-        rng = &globalRNG;
-
-    if (rng) {
-        if (wc_RNG_GenerateBlock(rng, buff, len) != 0)
-            WOLFSSL_MSG("Bad wc_RNG_GenerateBlock");
-        else {
-            buff[0]     |= 0x80 | 0x40;
-            buff[len-1] |= 0x01;
-
-            if (mp_read_unsigned_bin((mp_int*)bn->internal,buff,len) != MP_OKAY)
-                WOLFSSL_MSG("mp read bin failed");
-            else
-                ret = SSL_SUCCESS;
-        }
-    }
-
-    if (initTmpRng)
-        wc_FreeRng(tmpRNG);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(buff,   NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-int wolfSSL_BN_is_bit_set(const WOLFSSL_BIGNUM* bn, int n)
-{
-    (void)bn;
-    (void)n;
-
-    WOLFSSL_MSG("wolfSSL_BN_is_bit_set");
-
-    return 0;
-}
-
-
-/* SSL_SUCCESS on ok */
-int wolfSSL_BN_hex2bn(WOLFSSL_BIGNUM** bn, const char* str)
-{
-    int     ret     = 0;
-    word32  decSz   = 1024;
-#ifdef WOLFSSL_SMALL_STACK
-    byte*   decoded = NULL;
-#else
-    byte    decoded[1024];
-#endif
-
-    WOLFSSL_MSG("wolfSSL_BN_hex2bn");
-
-#ifdef WOLFSSL_SMALL_STACK
-    decoded = (byte*)XMALLOC(decSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (decoded == NULL)
-        return ret;
-#endif
-
-    if (str == NULL)
-        WOLFSSL_MSG("Bad function argument");
-    else if (Base16_Decode((byte*)str, (int)XSTRLEN(str), decoded, &decSz) < 0)
-        WOLFSSL_MSG("Bad Base16_Decode error");
-    else if (bn == NULL)
-        ret = decSz;
-    else {
-        if (*bn == NULL)
-            *bn = wolfSSL_BN_new();
-
-        if (*bn == NULL)
-            WOLFSSL_MSG("BN new failed");
-        else if (wolfSSL_BN_bin2bn(decoded, decSz, *bn) == NULL)
-            WOLFSSL_MSG("Bad bin2bn error");
-        else
-            ret = SSL_SUCCESS;
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(decoded, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-WOLFSSL_BIGNUM* wolfSSL_BN_dup(const WOLFSSL_BIGNUM* bn)
-{
-    WOLFSSL_BIGNUM* ret;
-
-    WOLFSSL_MSG("wolfSSL_BN_dup");
-
-    if (bn == NULL || bn->internal == NULL) {
-        WOLFSSL_MSG("bn NULL error");
-        return NULL;
-    }
-
-    ret = wolfSSL_BN_new();
-    if (ret == NULL) {
-        WOLFSSL_MSG("bn new error");
-        return NULL;
-    }
-
-    if (mp_copy((mp_int*)bn->internal, (mp_int*)ret->internal) != MP_OKAY) {
-        WOLFSSL_MSG("mp_copy error");
-        wolfSSL_BN_free(ret);
-        return NULL;
-    }
-
-    return ret;
-}
-
-
-WOLFSSL_BIGNUM* wolfSSL_BN_copy(WOLFSSL_BIGNUM* r, const WOLFSSL_BIGNUM* bn)
-{
-    (void)r;
-    (void)bn;
-
-    WOLFSSL_MSG("wolfSSL_BN_copy");
-
-    return NULL;
-}
-
-
-int wolfSSL_BN_set_word(WOLFSSL_BIGNUM* bn, unsigned long w)
-{
-    (void)bn;
-    (void)w;
-
-    WOLFSSL_MSG("wolfSSL_BN_set_word");
-
-    return SSL_FATAL_ERROR;
-}
-
-
-int wolfSSL_BN_dec2bn(WOLFSSL_BIGNUM** bn, const char* str)
-{
-    (void)bn;
-    (void)str;
-
-    WOLFSSL_MSG("wolfSSL_BN_dec2bn");
-
-    return SSL_FATAL_ERROR;
-}
-
-
-char* wolfSSL_BN_bn2dec(const WOLFSSL_BIGNUM* bn)
-{
-    (void)bn;
-
-    WOLFSSL_MSG("wolfSSL_BN_bn2dec");
-
-    return NULL;
-}
-
-
-#ifndef NO_DH
-
-static void InitwolfSSL_DH(WOLFSSL_DH* dh)
-{
-    if (dh) {
-        dh->p        = NULL;
-        dh->g        = NULL;
-        dh->pub_key  = NULL;
-        dh->priv_key = NULL;
-        dh->internal = NULL;
-        dh->inSet    = 0;
-        dh->exSet    = 0;
-    }
-}
-
-
-WOLFSSL_DH* wolfSSL_DH_new(void)
-{
-    WOLFSSL_DH* external;
-    DhKey*     key;
-
-    WOLFSSL_MSG("wolfSSL_DH_new");
-
-    key = (DhKey*) XMALLOC(sizeof(DhKey), NULL, DYNAMIC_TYPE_DH);
-    if (key == NULL) {
-        WOLFSSL_MSG("wolfSSL_DH_new malloc DhKey failure");
-        return NULL;
-    }
-
-    external = (WOLFSSL_DH*) XMALLOC(sizeof(WOLFSSL_DH), NULL,
-                                    DYNAMIC_TYPE_DH);
-    if (external == NULL) {
-        WOLFSSL_MSG("wolfSSL_DH_new malloc WOLFSSL_DH failure");
-        XFREE(key, NULL, DYNAMIC_TYPE_DH);
-        return NULL;
-    }
-
-    InitwolfSSL_DH(external);
-    wc_InitDhKey(key);
-    external->internal = key;
-
-    return external;
-}
-
-
-void wolfSSL_DH_free(WOLFSSL_DH* dh)
-{
-    WOLFSSL_MSG("wolfSSL_DH_free");
-
-    if (dh) {
-        if (dh->internal) {
-            wc_FreeDhKey((DhKey*)dh->internal);
-            XFREE(dh->internal, NULL, DYNAMIC_TYPE_DH);
-            dh->internal = NULL;
-        }
-        wolfSSL_BN_free(dh->priv_key);
-        wolfSSL_BN_free(dh->pub_key);
-        wolfSSL_BN_free(dh->g);
-        wolfSSL_BN_free(dh->p);
-        InitwolfSSL_DH(dh);  /* set back to NULLs for safety */
-
-        XFREE(dh, NULL, DYNAMIC_TYPE_DH);
-    }
-}
-
-
-static int SetDhInternal(WOLFSSL_DH* dh)
-{
-    int            ret = SSL_FATAL_ERROR;
-    int            pSz = 1024;
-    int            gSz = 1024;
-#ifdef WOLFSSL_SMALL_STACK
-    unsigned char* p   = NULL;
-    unsigned char* g   = NULL;
-#else
-    unsigned char  p[1024];
-    unsigned char  g[1024];
-#endif
-
-    WOLFSSL_ENTER("SetDhInternal");
-
-    if (dh == NULL || dh->p == NULL || dh->g == NULL)
-        WOLFSSL_MSG("Bad function arguments");
-    else if (wolfSSL_BN_bn2bin(dh->p, NULL) > pSz)
-        WOLFSSL_MSG("Bad p internal size");
-    else if (wolfSSL_BN_bn2bin(dh->g, NULL) > gSz)
-        WOLFSSL_MSG("Bad g internal size");
-    else {
-    #ifdef WOLFSSL_SMALL_STACK
-        p = (unsigned char*)XMALLOC(pSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        g = (unsigned char*)XMALLOC(gSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-        if (p == NULL || g == NULL) {
-            XFREE(p, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(g, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            return ret;
-        }
-    #endif
-
-        pSz = wolfSSL_BN_bn2bin(dh->p, p);
-        gSz = wolfSSL_BN_bn2bin(dh->g, g);
-
-        if (pSz <= 0 || gSz <= 0)
-            WOLFSSL_MSG("Bad BN2bin set");
-        else if (wc_DhSetKey((DhKey*)dh->internal, p, pSz, g, gSz) < 0)
-            WOLFSSL_MSG("Bad DH SetKey");
-        else {
-            dh->inSet = 1;
-            ret = 0;
-        }
-
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(p, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(g, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-    }
-
-
-    return ret;
-}
-
-
-int wolfSSL_DH_size(WOLFSSL_DH* dh)
-{
-    WOLFSSL_MSG("wolfSSL_DH_size");
-
-    if (dh == NULL)
-        return 0;
-
-    return wolfSSL_BN_num_bytes(dh->p);
-}
-
-
-/* return SSL_SUCCESS on ok, else 0 */
-int wolfSSL_DH_generate_key(WOLFSSL_DH* dh)
-{
-    int            ret    = 0;
-    word32         pubSz  = 768;
-    word32         privSz = 768;
-    int            initTmpRng = 0;
-    RNG*           rng    = NULL;
-#ifdef WOLFSSL_SMALL_STACK
-    unsigned char* pub    = NULL;
-    unsigned char* priv   = NULL;
-    RNG*           tmpRNG = NULL;
-#else
-    unsigned char  pub [768];
-    unsigned char  priv[768];
-    RNG            tmpRNG[1];
-#endif
-
-    WOLFSSL_MSG("wolfSSL_DH_generate_key");
-
-#ifdef WOLFSSL_SMALL_STACK
-    tmpRNG = (RNG*)XMALLOC(sizeof(RNG),      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    pub    = (unsigned char*)XMALLOC(pubSz,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    priv   = (unsigned char*)XMALLOC(privSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-    if (tmpRNG == NULL || pub == NULL || priv == NULL) {
-        XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(pub,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(priv,   NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return ret;
-    }
-#endif
-
-    if (dh == NULL || dh->p == NULL || dh->g == NULL)
-        WOLFSSL_MSG("Bad function arguments");
-    else if (dh->inSet == 0 && SetDhInternal(dh) < 0)
-            WOLFSSL_MSG("Bad DH set internal");
-    else if (wc_InitRng(tmpRNG) == 0) {
-        rng = tmpRNG;
-        initTmpRng = 1;
-    }
-    else {
-        WOLFSSL_MSG("Bad RNG Init, trying global");
-        if (initGlobalRNG == 0)
-            WOLFSSL_MSG("Global RNG no Init");
-        else
-            rng = &globalRNG;
-    }
-
-    if (rng) {
-       if (wc_DhGenerateKeyPair((DhKey*)dh->internal, rng, priv, &privSz,
-                                                               pub, &pubSz) < 0)
-            WOLFSSL_MSG("Bad wc_DhGenerateKeyPair");
-       else {
-            if (dh->pub_key)
-                wolfSSL_BN_free(dh->pub_key);
-   
-            dh->pub_key = wolfSSL_BN_new();
-            if (dh->pub_key == NULL) {
-                WOLFSSL_MSG("Bad DH new pub");
-            }
-            if (dh->priv_key)
-                wolfSSL_BN_free(dh->priv_key);
-
-            dh->priv_key = wolfSSL_BN_new();
-
-            if (dh->priv_key == NULL) {
-                WOLFSSL_MSG("Bad DH new priv");
-            }
-
-            if (dh->pub_key && dh->priv_key) {
-               if (wolfSSL_BN_bin2bn(pub, pubSz, dh->pub_key) == NULL)
-                   WOLFSSL_MSG("Bad DH bn2bin error pub");
-               else if (wolfSSL_BN_bin2bn(priv, privSz, dh->priv_key) == NULL)
-                   WOLFSSL_MSG("Bad DH bn2bin error priv");
-               else
-                   ret = SSL_SUCCESS;
-            }
-        }
-    }
-
-    if (initTmpRng)
-        wc_FreeRng(tmpRNG);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(pub,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(priv,   NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-/* return key size on ok, 0 otherwise */
-int wolfSSL_DH_compute_key(unsigned char* key, WOLFSSL_BIGNUM* otherPub,
-                          WOLFSSL_DH* dh)
-{
-    int            ret    = 0;
-    word32         keySz  = 0;
-    word32         pubSz  = 1024;
-    word32         privSz = 1024;
-#ifdef WOLFSSL_SMALL_STACK
-    unsigned char* pub    = NULL;
-    unsigned char* priv   = NULL;
-#else
-    unsigned char  pub [1024];
-    unsigned char  priv[1024];
-#endif
-
-    WOLFSSL_MSG("wolfSSL_DH_compute_key");
-
-#ifdef WOLFSSL_SMALL_STACK
-    pub = (unsigned char*)XMALLOC(pubSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (pub == NULL)
-        return ret;
-
-    priv = (unsigned char*)XMALLOC(privSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (priv == NULL) {
-        XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return 0;
-    }
-#endif
-
-    if (dh == NULL || dh->priv_key == NULL || otherPub == NULL)
-        WOLFSSL_MSG("Bad function arguments");
-    else if ((keySz = (word32)DH_size(dh)) == 0)
-        WOLFSSL_MSG("Bad DH_size");
-    else if (wolfSSL_BN_bn2bin(dh->priv_key, NULL) > (int)privSz)
-        WOLFSSL_MSG("Bad priv internal size");
-    else if (wolfSSL_BN_bn2bin(otherPub, NULL) > (int)pubSz)
-        WOLFSSL_MSG("Bad otherPub size");
-    else {
-        privSz = wolfSSL_BN_bn2bin(dh->priv_key, priv);
-        pubSz  = wolfSSL_BN_bn2bin(otherPub, pub);
-
-        if (privSz <= 0 || pubSz <= 0)
-            WOLFSSL_MSG("Bad BN2bin set");
-        else if (wc_DhAgree((DhKey*)dh->internal, key, &keySz, priv, privSz, pub,
-                                                                     pubSz) < 0)
-            WOLFSSL_MSG("wc_DhAgree failed");
-        else
-            ret = (int)keySz;
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(pub,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(priv, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-#endif /* NO_DH */
-
-
-#ifndef NO_DSA
-static void InitwolfSSL_DSA(WOLFSSL_DSA* dsa)
-{
-    if (dsa) {
-        dsa->p        = NULL;
-        dsa->q        = NULL;
-        dsa->g        = NULL;
-        dsa->pub_key  = NULL;
-        dsa->priv_key = NULL;
-        dsa->internal = NULL;
-        dsa->inSet    = 0;
-        dsa->exSet    = 0;
-    }
-}
-
-
-WOLFSSL_DSA* wolfSSL_DSA_new(void)
-{
-    WOLFSSL_DSA* external;
-    DsaKey*     key;
-
-    WOLFSSL_MSG("wolfSSL_DSA_new");
-
-    key = (DsaKey*) XMALLOC(sizeof(DsaKey), NULL, DYNAMIC_TYPE_DSA);
-    if (key == NULL) {
-        WOLFSSL_MSG("wolfSSL_DSA_new malloc DsaKey failure");
-        return NULL;
-    }
-
-    external = (WOLFSSL_DSA*) XMALLOC(sizeof(WOLFSSL_DSA), NULL,
-                                    DYNAMIC_TYPE_DSA);
-    if (external == NULL) {
-        WOLFSSL_MSG("wolfSSL_DSA_new malloc WOLFSSL_DSA failure");
-        XFREE(key, NULL, DYNAMIC_TYPE_DSA);
-        return NULL;
-    }
-
-    InitwolfSSL_DSA(external);
-    InitDsaKey(key);
-    external->internal = key;
-
-    return external;
-}
-
-
-void wolfSSL_DSA_free(WOLFSSL_DSA* dsa)
-{
-    WOLFSSL_MSG("wolfSSL_DSA_free");
-
-    if (dsa) {
-        if (dsa->internal) {
-            FreeDsaKey((DsaKey*)dsa->internal);
-            XFREE(dsa->internal, NULL, DYNAMIC_TYPE_DSA);
-            dsa->internal = NULL;
-        }
-        wolfSSL_BN_free(dsa->priv_key);
-        wolfSSL_BN_free(dsa->pub_key);
-        wolfSSL_BN_free(dsa->g);
-        wolfSSL_BN_free(dsa->q);
-        wolfSSL_BN_free(dsa->p);
-        InitwolfSSL_DSA(dsa);  /* set back to NULLs for safety */
-
-        XFREE(dsa, NULL, DYNAMIC_TYPE_DSA);
-    }
-}
-
-
-int wolfSSL_DSA_generate_key(WOLFSSL_DSA* dsa)
-{
-    (void)dsa;
-
-    WOLFSSL_MSG("wolfSSL_DSA_generate_key");
-
-    return 0;  /* key gen not needed by server */
-}
-
-
-int wolfSSL_DSA_generate_parameters_ex(WOLFSSL_DSA* dsa, int bits,
-               unsigned char* seed, int seedLen, int* counterRet,
-               unsigned long* hRet, void* cb)
-{
-    (void)dsa;
-    (void)bits;
-    (void)seed;
-    (void)seedLen;
-    (void)counterRet;
-    (void)hRet;
-    (void)cb;
-
-    WOLFSSL_MSG("wolfSSL_DSA_generate_parameters_ex");
-
-    return 0;  /* key gen not needed by server */
-}
-#endif /* NO_DSA */
-
-#ifndef NO_RSA
-static void InitwolfSSL_Rsa(WOLFSSL_RSA* rsa)
-{
-    if (rsa) {
-        rsa->n        = NULL;
-        rsa->e        = NULL;
-        rsa->d        = NULL;
-        rsa->p        = NULL;
-        rsa->q        = NULL;
-        rsa->dmp1     = NULL;
-        rsa->dmq1     = NULL;
-        rsa->iqmp     = NULL;
-        rsa->internal = NULL;
-        rsa->inSet    = 0;
-        rsa->exSet    = 0;
-    }
-}
-
-
-WOLFSSL_RSA* wolfSSL_RSA_new(void)
-{
-    WOLFSSL_RSA* external;
-    RsaKey*     key;
-
-    WOLFSSL_MSG("wolfSSL_RSA_new");
-
-    key = (RsaKey*) XMALLOC(sizeof(RsaKey), NULL, DYNAMIC_TYPE_RSA);
-    if (key == NULL) {
-        WOLFSSL_MSG("wolfSSL_RSA_new malloc RsaKey failure");
-        return NULL;
-    }
-
-    external = (WOLFSSL_RSA*) XMALLOC(sizeof(WOLFSSL_RSA), NULL,
-                                     DYNAMIC_TYPE_RSA);
-    if (external == NULL) {
-        WOLFSSL_MSG("wolfSSL_RSA_new malloc WOLFSSL_RSA failure");
-        XFREE(key, NULL, DYNAMIC_TYPE_RSA);
-        return NULL;
-    }
-
-    InitwolfSSL_Rsa(external);
-    if (wc_InitRsaKey(key, NULL) != 0) {
-        WOLFSSL_MSG("InitRsaKey WOLFSSL_RSA failure");
-        XFREE(external, NULL, DYNAMIC_TYPE_RSA);
-        XFREE(key, NULL, DYNAMIC_TYPE_RSA);
-        return NULL;
-    }
-    external->internal = key;
-
-    return external;
-}
-
-
-void wolfSSL_RSA_free(WOLFSSL_RSA* rsa)
-{
-    WOLFSSL_MSG("wolfSSL_RSA_free");
-
-    if (rsa) {
-        if (rsa->internal) {
-            wc_FreeRsaKey((RsaKey*)rsa->internal);
-            XFREE(rsa->internal, NULL, DYNAMIC_TYPE_RSA);
-            rsa->internal = NULL;
-        }
-        wolfSSL_BN_free(rsa->iqmp);
-        wolfSSL_BN_free(rsa->dmq1);
-        wolfSSL_BN_free(rsa->dmp1);
-        wolfSSL_BN_free(rsa->q);
-        wolfSSL_BN_free(rsa->p);
-        wolfSSL_BN_free(rsa->d);
-        wolfSSL_BN_free(rsa->e);
-        wolfSSL_BN_free(rsa->n);
-        InitwolfSSL_Rsa(rsa);  /* set back to NULLs for safety */
-
-        XFREE(rsa, NULL, DYNAMIC_TYPE_RSA);
-    }
-}
-#endif /* NO_RSA */
-
-
-#if !defined(NO_RSA) || !defined(NO_DSA)
-static int SetIndividualExternal(WOLFSSL_BIGNUM** bn, mp_int* mpi)
-{
-    WOLFSSL_MSG("Entering SetIndividualExternal");
-
-    if (mpi == NULL) {
-        WOLFSSL_MSG("mpi NULL error");
-        return SSL_FATAL_ERROR;
-    }
-
-    if (*bn == NULL) {
-        *bn = wolfSSL_BN_new();
-        if (*bn == NULL) {
-            WOLFSSL_MSG("SetIndividualExternal alloc failed");
-            return SSL_FATAL_ERROR;
-        }
-    }
-
-    if (mp_copy(mpi, (mp_int*)((*bn)->internal)) != MP_OKAY) {
-        WOLFSSL_MSG("mp_copy error");
-        return SSL_FATAL_ERROR;
-    }
-
-    return 0;
-}
-#endif /* !NO_RSA && !NO_DSA */
-
-
-#ifndef NO_DSA
-static int SetDsaExternal(WOLFSSL_DSA* dsa)
-{
-    DsaKey* key;
-    WOLFSSL_MSG("Entering SetDsaExternal");
-
-    if (dsa == NULL || dsa->internal == NULL) {
-        WOLFSSL_MSG("dsa key NULL error");
-        return SSL_FATAL_ERROR;
-    }
-
-    key = (DsaKey*)dsa->internal;
-
-    if (SetIndividualExternal(&dsa->p, &key->p) < 0) {
-        WOLFSSL_MSG("dsa p key error");
-        return SSL_FATAL_ERROR;
-    }
-
-    if (SetIndividualExternal(&dsa->q, &key->q) < 0) {
-        WOLFSSL_MSG("dsa q key error");
-        return SSL_FATAL_ERROR;
-    }
-
-    if (SetIndividualExternal(&dsa->g, &key->g) < 0) {
-        WOLFSSL_MSG("dsa g key error");
-        return SSL_FATAL_ERROR;
-    }
-
-    if (SetIndividualExternal(&dsa->pub_key, &key->y) < 0) {
-        WOLFSSL_MSG("dsa y key error");
-        return SSL_FATAL_ERROR;
-    }
-
-    if (SetIndividualExternal(&dsa->priv_key, &key->x) < 0) {
-        WOLFSSL_MSG("dsa x key error");
-        return SSL_FATAL_ERROR;
-    }
-
-    dsa->exSet = 1;
-
-    return 0;
-}
-#endif /* NO_DSA */
-
-
-#ifndef NO_RSA
-static int SetRsaExternal(WOLFSSL_RSA* rsa)
-{
-    RsaKey* key;
-    WOLFSSL_MSG("Entering SetRsaExternal");
-
-    if (rsa == NULL || rsa->internal == NULL) {
-        WOLFSSL_MSG("rsa key NULL error");
-        return SSL_FATAL_ERROR;
-    }
-
-    key = (RsaKey*)rsa->internal;
-
-    if (SetIndividualExternal(&rsa->n, &key->n) < 0) {
-        WOLFSSL_MSG("rsa n key error");
-        return SSL_FATAL_ERROR;
-    }
-
-    if (SetIndividualExternal(&rsa->e, &key->e) < 0) {
-        WOLFSSL_MSG("rsa e key error");
-        return SSL_FATAL_ERROR;
-    }
-
-    if (SetIndividualExternal(&rsa->d, &key->d) < 0) {
-        WOLFSSL_MSG("rsa d key error");
-        return SSL_FATAL_ERROR;
-    }
-
-    if (SetIndividualExternal(&rsa->p, &key->p) < 0) {
-        WOLFSSL_MSG("rsa p key error");
-        return SSL_FATAL_ERROR;
-    }
-
-    if (SetIndividualExternal(&rsa->q, &key->q) < 0) {
-        WOLFSSL_MSG("rsa q key error");
-        return SSL_FATAL_ERROR;
-    }
-
-    if (SetIndividualExternal(&rsa->dmp1, &key->dP) < 0) {
-        WOLFSSL_MSG("rsa dP key error");
-        return SSL_FATAL_ERROR;
-    }
-
-    if (SetIndividualExternal(&rsa->dmq1, &key->dQ) < 0) {
-        WOLFSSL_MSG("rsa dQ key error");
-        return SSL_FATAL_ERROR;
-    }
-
-    if (SetIndividualExternal(&rsa->iqmp, &key->u) < 0) {
-        WOLFSSL_MSG("rsa u key error");
-        return SSL_FATAL_ERROR;
-    }
-
-    rsa->exSet = 1;
-
-    return 0;
-}
-
-
-/* SSL_SUCCESS on ok */
-int wolfSSL_RSA_generate_key_ex(WOLFSSL_RSA* rsa, int bits, WOLFSSL_BIGNUM* bn,
-                               void* cb)
-{
-    int ret = SSL_FATAL_ERROR;
-
-    WOLFSSL_MSG("wolfSSL_RSA_generate_key_ex");
-
-    (void)rsa;
-    (void)bits;
-    (void)cb;
-    (void)bn;
-
-#ifdef WOLFSSL_KEY_GEN
-    {
-    #ifdef WOLFSSL_SMALL_STACK
-        RNG* rng = NULL;
-    #else
-        RNG  rng[1];
-    #endif
-
-    #ifdef WOLFSSL_SMALL_STACK
-        rng = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (rng == NULL)
-            return SSL_FATAL_ERROR;
-    #endif
-
-        if (wc_InitRng(rng) < 0)
-            WOLFSSL_MSG("RNG init failed");
-        else if (wc_MakeRsaKey((RsaKey*)rsa->internal, bits, 65537, rng) < 0)
-            WOLFSSL_MSG("wc_MakeRsaKey failed");
-        else if (SetRsaExternal(rsa) < 0)
-            WOLFSSL_MSG("SetRsaExternal failed");
-        else {
-            rsa->inSet = 1;
-            ret = SSL_SUCCESS;
-        }
-
-        wc_FreeRng(rng);
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(rng, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-    }
-#else
-    WOLFSSL_MSG("No Key Gen built in");
-#endif
-    return ret;
-}
-
-
-/* SSL_SUCCESS on ok */
-int wolfSSL_RSA_blinding_on(WOLFSSL_RSA* rsa, WOLFSSL_BN_CTX* bn)
-{
-    (void)rsa;
-    (void)bn;
-
-    WOLFSSL_MSG("wolfSSL_RSA_blinding_on");
-
-    return SSL_SUCCESS;  /* on by default */
-}
-
-
-int wolfSSL_RSA_public_encrypt(int len, unsigned char* fr,
-                            unsigned char* to, WOLFSSL_RSA* rsa, int padding)
-{
-    (void)len;
-    (void)fr;
-    (void)to;
-    (void)rsa;
-    (void)padding;
-
-    WOLFSSL_MSG("wolfSSL_RSA_public_encrypt");
-
-    return SSL_FATAL_ERROR;
-}
-
-
-int wolfSSL_RSA_private_decrypt(int len, unsigned char* fr,
-                            unsigned char* to, WOLFSSL_RSA* rsa, int padding)
-{
-    (void)len;
-    (void)fr;
-    (void)to;
-    (void)rsa;
-    (void)padding;
-
-    WOLFSSL_MSG("wolfSSL_RSA_private_decrypt");
-
-    return SSL_FATAL_ERROR;
-}
-
-
-int wolfSSL_RSA_size(const WOLFSSL_RSA* rsa)
-{
-    WOLFSSL_MSG("wolfSSL_RSA_size");
-
-    if (rsa == NULL)
-        return 0;
-
-    return wolfSSL_BN_num_bytes(rsa->n);
-}
-#endif /* NO_RSA */
-
-
-#ifndef NO_DSA
-/* return SSL_SUCCESS on success, < 0 otherwise */
-int wolfSSL_DSA_do_sign(const unsigned char* d, unsigned char* sigRet,
-                       WOLFSSL_DSA* dsa)
-{
-    int    ret = SSL_FATAL_ERROR;
-    int    initTmpRng = 0;
-    RNG*   rng = NULL;
-#ifdef WOLFSSL_SMALL_STACK
-    RNG*   tmpRNG = NULL;
-#else
-    RNG    tmpRNG[1];
-#endif
-
-    WOLFSSL_MSG("wolfSSL_DSA_do_sign");
-
-    if (d == NULL || sigRet == NULL || dsa == NULL)
-        WOLFSSL_MSG("Bad function arguments");
-    else if (dsa->inSet == 0)
-        WOLFSSL_MSG("No DSA internal set");
-    else {
-    #ifdef WOLFSSL_SMALL_STACK
-        tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (tmpRNG == NULL)
-            return SSL_FATAL_ERROR;
-    #endif
-
-        if (wc_InitRng(tmpRNG) == 0) {
-            rng = tmpRNG;
-            initTmpRng = 1;
-        }
-        else {
-            WOLFSSL_MSG("Bad RNG Init, trying global");
-            if (initGlobalRNG == 0)
-                WOLFSSL_MSG("Global RNG no Init");
-            else
-                rng = &globalRNG;
-        }
-
-        if (rng) {
-            if (DsaSign(d, sigRet, (DsaKey*)dsa->internal, rng) < 0)
-                WOLFSSL_MSG("DsaSign failed");
-            else
-                ret = SSL_SUCCESS;
-        }
-
-        if (initTmpRng)
-            wc_FreeRng(tmpRNG);
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-    }
-
-    return ret;
-}
-#endif /* NO_DSA */
-
-
-#ifndef NO_RSA
-/* return SSL_SUCCES on ok, 0 otherwise */
-int wolfSSL_RSA_sign(int type, const unsigned char* m,
-                           unsigned int mLen, unsigned char* sigRet,
-                           unsigned int* sigLen, WOLFSSL_RSA* rsa)
-{
-    word32 outLen;    
-    word32 signSz;
-    int    initTmpRng = 0;
-    RNG*   rng        = NULL;
-    int    ret        = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    RNG*   tmpRNG     = NULL;
-    byte*  encodedSig = NULL;
-#else
-    RNG    tmpRNG[1];
-    byte   encodedSig[MAX_ENCODED_SIG_SZ];
-#endif
-
-    WOLFSSL_MSG("wolfSSL_RSA_sign");
-
-    if (m == NULL || sigRet == NULL || sigLen == NULL || rsa == NULL)
-        WOLFSSL_MSG("Bad function arguments");
-    else if (rsa->inSet == 0)
-        WOLFSSL_MSG("No RSA internal set");
-    else if (type != NID_md5 && type != NID_sha1)
-        WOLFSSL_MSG("Bad md type");
-    else {
-        outLen = (word32)wolfSSL_BN_num_bytes(rsa->n);
-
-    #ifdef WOLFSSL_SMALL_STACK
-        tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (tmpRNG == NULL)
-            return 0;
-
-        encodedSig = (byte*)XMALLOC(MAX_ENCODED_SIG_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-        if (encodedSig == NULL) {
-            XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            return 0;
-        }
-    #endif
-
-        if (outLen == 0)
-            WOLFSSL_MSG("Bad RSA size");
-        else if (wc_InitRng(tmpRNG) == 0) {
-            rng = tmpRNG;
-            initTmpRng = 1;
-        }
-        else {
-            WOLFSSL_MSG("Bad RNG Init, trying global");
-
-            if (initGlobalRNG == 0)
-                WOLFSSL_MSG("Global RNG no Init");
-            else
-                rng = &globalRNG;
-        }
-    }
-
-    if (rng) {
-        type = (type == NID_md5) ? MD5h : SHAh;
-
-        signSz = wc_EncodeSignature(encodedSig, m, mLen, type);
-        if (signSz == 0) {
-            WOLFSSL_MSG("Bad Encode Signature");
-        }
-        else {
-            *sigLen = wc_RsaSSL_Sign(encodedSig, signSz, sigRet, outLen,
-                                  (RsaKey*)rsa->internal, rng);
-            if (*sigLen <= 0)
-                WOLFSSL_MSG("Bad Rsa Sign");
-            else
-                ret = SSL_SUCCESS;
-        }
-
-    }
-
-    if (initTmpRng)
-        wc_FreeRng(tmpRNG);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(tmpRNG,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(encodedSig, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    WOLFSSL_MSG("wolfSSL_RSA_sign success");
-    return ret;
-}
-
-
-int wolfSSL_RSA_public_decrypt(int flen, unsigned char* from,
-                          unsigned char* to, WOLFSSL_RSA* rsa, int padding)
-{
-    (void)flen;
-    (void)from;
-    (void)to;
-    (void)rsa;
-    (void)padding;
-
-    WOLFSSL_MSG("wolfSSL_RSA_public_decrypt");
-
-    return SSL_FATAL_ERROR;
-}
-
-
-/* generate p-1 and q-1, SSL_SUCCESS on ok */
-int wolfSSL_RSA_GenAdd(WOLFSSL_RSA* rsa)
-{
-    int    err;
-    mp_int tmp;
-
-    WOLFSSL_MSG("wolfSSL_RsaGenAdd");
-
-    if (rsa == NULL || rsa->p == NULL || rsa->q == NULL || rsa->d == NULL ||
-                       rsa->dmp1 == NULL || rsa->dmq1 == NULL) {
-        WOLFSSL_MSG("rsa no init error");
-        return SSL_FATAL_ERROR;
-    }
-
-    if (mp_init(&tmp) != MP_OKAY) {
-        WOLFSSL_MSG("mp_init error");
-        return SSL_FATAL_ERROR;
-    }
-
-    err = mp_sub_d((mp_int*)rsa->p->internal, 1, &tmp);
-    if (err != MP_OKAY) {
-        WOLFSSL_MSG("mp_sub_d error");
-    }
-    else
-        err = mp_mod((mp_int*)rsa->d->internal, &tmp,
-                     (mp_int*)rsa->dmp1->internal);
-
-    if (err != MP_OKAY) {
-        WOLFSSL_MSG("mp_mod error");
-    }
-    else
-        err = mp_sub_d((mp_int*)rsa->q->internal, 1, &tmp);
-    if (err != MP_OKAY) {
-        WOLFSSL_MSG("mp_sub_d error");
-    }
-    else
-        err = mp_mod((mp_int*)rsa->d->internal, &tmp,
-                     (mp_int*)rsa->dmq1->internal);
-
-    mp_clear(&tmp);
-
-    if (err == MP_OKAY)
-        return SSL_SUCCESS;
-    else
-        return SSL_FATAL_ERROR;
-}
-#endif /* NO_RSA */
-
-
-void wolfSSL_HMAC_Init(WOLFSSL_HMAC_CTX* ctx, const void* key, int keylen,
-                  const EVP_MD* type)
-{
-    WOLFSSL_MSG("wolfSSL_HMAC_Init");
-
-    if (ctx == NULL) {
-        WOLFSSL_MSG("no ctx on init");
-        return;
-    }
-
-    if (type) {
-        WOLFSSL_MSG("init has type");
-
-        if (XSTRNCMP(type, "MD5", 3) == 0) {
-            WOLFSSL_MSG("md5 hmac");
-            ctx->type = MD5;
-        }
-        else if (XSTRNCMP(type, "SHA256", 6) == 0) {
-            WOLFSSL_MSG("sha256 hmac");
-            ctx->type = SHA256;
-        }
-
-        /* has to be last since would pick or 256, 384, or 512 too */
-        else if (XSTRNCMP(type, "SHA", 3) == 0) {
-            WOLFSSL_MSG("sha hmac");
-            ctx->type = SHA;
-        }
-        else {
-            WOLFSSL_MSG("bad init type");
-        }
-    }
-
-    if (key && keylen) {
-        WOLFSSL_MSG("keying hmac");
-        wc_HmacSetKey(&ctx->hmac, ctx->type, (const byte*)key, (word32)keylen);
-        /* OpenSSL compat, no error */
-    }
-}
-
-
-void wolfSSL_HMAC_Update(WOLFSSL_HMAC_CTX* ctx, const unsigned char* data,
-                    int len)
-{
-    WOLFSSL_MSG("wolfSSL_HMAC_Update");
-
-    if (ctx && data) {
-        WOLFSSL_MSG("updating hmac");
-        wc_HmacUpdate(&ctx->hmac, data, (word32)len);
-        /* OpenSSL compat, no error */
-    }
-}
-
-
-void wolfSSL_HMAC_Final(WOLFSSL_HMAC_CTX* ctx, unsigned char* hash,
-                   unsigned int* len)
-{
-    WOLFSSL_MSG("wolfSSL_HMAC_Final");
-
-    if (ctx && hash) {
-        WOLFSSL_MSG("final hmac");
-        wc_HmacFinal(&ctx->hmac, hash);
-        /* OpenSSL compat, no error */
-
-        if (len) {
-            WOLFSSL_MSG("setting output len");
-            switch (ctx->type) {
-                case MD5:
-                    *len = MD5_DIGEST_SIZE;
-                    break;
-
-                case SHA:
-                    *len = SHA_DIGEST_SIZE;
-                    break;
-
-                case SHA256:
-                    *len = SHA256_DIGEST_SIZE;
-                    break;
-
-                default:
-                    WOLFSSL_MSG("bad hmac type");
-            }
-        }
-    }
-}
-
-
-void wolfSSL_HMAC_cleanup(WOLFSSL_HMAC_CTX* ctx)
-{
-    (void)ctx;
-
-    WOLFSSL_MSG("wolfSSL_HMAC_cleanup");
-}
-
-
-const WOLFSSL_EVP_MD* wolfSSL_EVP_get_digestbynid(int id)
-{
-    WOLFSSL_MSG("wolfSSL_get_digestbynid");
-
-    switch(id) {
-#ifndef NO_MD5
-        case NID_md5:
-            return wolfSSL_EVP_md5();
-#endif
-#ifndef NO_SHA
-        case NID_sha1:
-            return wolfSSL_EVP_sha1();
-#endif
-        default:
-            WOLFSSL_MSG("Bad digest id value");
-    }
-
-    return NULL;
-}
-
-
-WOLFSSL_RSA* wolfSSL_EVP_PKEY_get1_RSA(WOLFSSL_EVP_PKEY* key)
-{
-    (void)key;
-    WOLFSSL_MSG("wolfSSL_EVP_PKEY_get1_RSA");
-
-    return NULL;
-}
-
-
-WOLFSSL_DSA* wolfSSL_EVP_PKEY_get1_DSA(WOLFSSL_EVP_PKEY* key)
-{
-    (void)key;
-    WOLFSSL_MSG("wolfSSL_EVP_PKEY_get1_DSA");
-
-    return NULL;
-}
-
-
-void* wolfSSL_EVP_X_STATE(const WOLFSSL_EVP_CIPHER_CTX* ctx)
-{
-    WOLFSSL_MSG("wolfSSL_EVP_X_STATE");
-
-    if (ctx) {
-        switch (ctx->cipherType) {
-            case ARC4_TYPE:
-                WOLFSSL_MSG("returning arc4 state");
-                return (void*)&ctx->cipher.arc4.x;
-
-            default:
-                WOLFSSL_MSG("bad x state type");
-                return 0;
-        }
-    }
-
-    return NULL;
-}
-
-
-int wolfSSL_EVP_X_STATE_LEN(const WOLFSSL_EVP_CIPHER_CTX* ctx)
-{
-    WOLFSSL_MSG("wolfSSL_EVP_X_STATE_LEN");
-
-    if (ctx) {
-        switch (ctx->cipherType) {
-            case ARC4_TYPE:
-                WOLFSSL_MSG("returning arc4 state size");
-                return sizeof(Arc4);
-
-            default:
-                WOLFSSL_MSG("bad x state type");
-                return 0;
-        }
-    }
-
-    return 0;
-}
-
-
-#ifndef NO_DES3
-
-void wolfSSL_3des_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset,
-                            unsigned char* iv, int len)
-{
-    (void)len;
-
-    WOLFSSL_MSG("wolfSSL_3des_iv");
-
-    if (ctx == NULL || iv == NULL) {
-        WOLFSSL_MSG("Bad function argument");
-        return;
-    }
-
-    if (doset)
-        wc_Des3_SetIV(&ctx->cipher.des3, iv);  /* OpenSSL compat, no ret */
-    else
-        memcpy(iv, &ctx->cipher.des3.reg, DES_BLOCK_SIZE);
-}
-
-#endif /* NO_DES3 */
-
-
-#ifndef NO_AES
-
-void wolfSSL_aes_ctr_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset,
-                      unsigned char* iv, int len)
-{
-    (void)len;
-
-    WOLFSSL_MSG("wolfSSL_aes_ctr_iv");
-
-    if (ctx == NULL || iv == NULL) {
-        WOLFSSL_MSG("Bad function argument");
-        return;
-    }
-
-    if (doset)
-        wc_AesSetIV(&ctx->cipher.aes, iv);  /* OpenSSL compat, no ret */
-    else
-        memcpy(iv, &ctx->cipher.aes.reg, AES_BLOCK_SIZE);
-}
-
-#endif /* NO_AES */
-
-
-const WOLFSSL_EVP_MD* wolfSSL_EVP_ripemd160(void)
-{
-    WOLFSSL_MSG("wolfSSL_ripemd160");
-
-    return NULL;
-}
-
-
-int wolfSSL_EVP_MD_size(const WOLFSSL_EVP_MD* type)
-{
-    WOLFSSL_MSG("wolfSSL_EVP_MD_size");
-
-    if (type == NULL) {
-        WOLFSSL_MSG("No md type arg");
-        return BAD_FUNC_ARG;
-    }
-
-    if (XSTRNCMP(type, "SHA256", 6) == 0) {
-        return SHA256_DIGEST_SIZE;
-    }
-#ifndef NO_MD5
-    else if (XSTRNCMP(type, "MD5", 3) == 0) {
-        return MD5_DIGEST_SIZE;
-    }
-#endif
-#ifdef WOLFSSL_SHA384
-    else if (XSTRNCMP(type, "SHA384", 6) == 0) {
-        return SHA384_DIGEST_SIZE;
-    }
-#endif
-#ifdef WOLFSSL_SHA512
-    else if (XSTRNCMP(type, "SHA512", 6) == 0) {
-        return SHA512_DIGEST_SIZE;
-    }
-#endif
-#ifndef NO_SHA
-    /* has to be last since would pick or 256, 384, or 512 too */
-    else if (XSTRNCMP(type, "SHA", 3) == 0) {
-        return SHA_DIGEST_SIZE;
-    }
-#endif
-
-    return BAD_FUNC_ARG;
-}
-
-
-int wolfSSL_EVP_CIPHER_CTX_iv_length(const WOLFSSL_EVP_CIPHER_CTX* ctx)
-{
-    WOLFSSL_MSG("wolfSSL_EVP_CIPHER_CTX_iv_length");
-
-    switch (ctx->cipherType) {
-
-        case AES_128_CBC_TYPE :
-        case AES_192_CBC_TYPE :
-        case AES_256_CBC_TYPE :
-            WOLFSSL_MSG("AES CBC");
-            return AES_BLOCK_SIZE;
-
-#ifdef WOLFSSL_AES_COUNTER
-        case AES_128_CTR_TYPE :
-        case AES_192_CTR_TYPE :
-        case AES_256_CTR_TYPE :
-            WOLFSSL_MSG("AES CTR");
-            return AES_BLOCK_SIZE;
-#endif
-
-        case DES_CBC_TYPE :
-            WOLFSSL_MSG("DES CBC");
-            return DES_BLOCK_SIZE;
-
-        case DES_EDE3_CBC_TYPE :
-            WOLFSSL_MSG("DES EDE3 CBC");
-            return DES_BLOCK_SIZE;
-
-        case ARC4_TYPE :
-            WOLFSSL_MSG("ARC4");
-            return 0;
-
-        case NULL_CIPHER_TYPE :
-            WOLFSSL_MSG("NULL");
-            return 0;
-
-        default: {
-            WOLFSSL_MSG("bad type");
-        }
-    }
-    return 0;
-}
-
-
-void wolfSSL_OPENSSL_free(void* p)
-{
-    WOLFSSL_MSG("wolfSSL_OPENSSL_free");
-
-    XFREE(p, NULL, 0);
-}
-
-
-int wolfSSL_PEM_write_bio_RSAPrivateKey(WOLFSSL_BIO* bio, RSA* rsa,
-                                  const EVP_CIPHER* cipher,
-                                  unsigned char* passwd, int len,
-                                  pem_password_cb cb, void* arg)
-{
-    (void)bio;
-    (void)rsa;
-    (void)cipher;
-    (void)passwd;
-    (void)len;
-    (void)cb;
-    (void)arg;
-
-    WOLFSSL_MSG("wolfSSL_PEM_write_bio_RSAPrivateKey");
-
-    return SSL_FATAL_ERROR;
-}
-
-
-
-int wolfSSL_PEM_write_bio_DSAPrivateKey(WOLFSSL_BIO* bio, DSA* rsa,
-                                  const EVP_CIPHER* cipher,
-                                  unsigned char* passwd, int len,
-                                  pem_password_cb cb, void* arg)
-{
-    (void)bio;
-    (void)rsa;
-    (void)cipher;
-    (void)passwd;
-    (void)len;
-    (void)cb;
-    (void)arg;
-
-    WOLFSSL_MSG("wolfSSL_PEM_write_bio_DSAPrivateKey");
-
-    return SSL_FATAL_ERROR;
-}
-
-
-
-WOLFSSL_EVP_PKEY* wolfSSL_PEM_read_bio_PrivateKey(WOLFSSL_BIO* bio,
-                    WOLFSSL_EVP_PKEY** key, pem_password_cb cb, void* arg)
-{
-    (void)bio;
-    (void)key;
-    (void)cb;
-    (void)arg;
-
-    WOLFSSL_MSG("wolfSSL_PEM_read_bio_PrivateKey");
-
-    return NULL;
-}
-
-
-
-#ifndef NO_RSA
-/* Load RSA from Der, SSL_SUCCESS on success < 0 on error */
-int wolfSSL_RSA_LoadDer(WOLFSSL_RSA* rsa, const unsigned char* der,  int derSz)
-{
-    word32 idx = 0;
-    int    ret;
-
-    WOLFSSL_ENTER("wolfSSL_RSA_LoadDer");
-
-    if (rsa == NULL || rsa->internal == NULL || der == NULL || derSz <= 0) {
-        WOLFSSL_MSG("Bad function arguments");
-        return BAD_FUNC_ARG;
-    }
-
-    ret = wc_RsaPrivateKeyDecode(der, &idx, (RsaKey*)rsa->internal, derSz);
-    if (ret < 0) {
-        WOLFSSL_MSG("RsaPrivateKeyDecode failed");
-        return ret;
-    }
-
-    if (SetRsaExternal(rsa) < 0) {
-        WOLFSSL_MSG("SetRsaExternal failed");
-        return SSL_FATAL_ERROR;
-    }
-
-    rsa->inSet = 1;
-
-    return SSL_SUCCESS;
-}
-#endif /* NO_RSA */
-
-
-#ifndef NO_DSA
-/* Load DSA from Der, SSL_SUCCESS on success < 0 on error */
-int wolfSSL_DSA_LoadDer(WOLFSSL_DSA* dsa, const unsigned char* der,  int derSz)
-{
-    word32 idx = 0;
-    int    ret;
-
-    WOLFSSL_ENTER("wolfSSL_DSA_LoadDer");
-
-    if (dsa == NULL || dsa->internal == NULL || der == NULL || derSz <= 0) {
-        WOLFSSL_MSG("Bad function arguments");
-        return BAD_FUNC_ARG;
-    }
-
-    ret = DsaPrivateKeyDecode(der, &idx, (DsaKey*)dsa->internal, derSz);
-    if (ret < 0) {
-        WOLFSSL_MSG("DsaPrivateKeyDecode failed");
-        return ret;
-    }
-
-    if (SetDsaExternal(dsa) < 0) {
-        WOLFSSL_MSG("SetDsaExternal failed");
-        return SSL_FATAL_ERROR;
-    }
-
-    dsa->inSet = 1;
-
-    return SSL_SUCCESS;
-}
-#endif /* NO_DSA */
-
-
-
-
-#endif /* OPENSSL_EXTRA */
-
-
-#ifdef SESSION_CERTS
-
-
-/* Get peer's certificate chain */
-WOLFSSL_X509_CHAIN* wolfSSL_get_peer_chain(WOLFSSL* ssl)
-{
-    WOLFSSL_ENTER("wolfSSL_get_peer_chain");
-    if (ssl)
-        return &ssl->session.chain;
-
-    return 0;
-}
-
-
-/* Get peer's certificate chain total count */
-int wolfSSL_get_chain_count(WOLFSSL_X509_CHAIN* chain)
-{
-    WOLFSSL_ENTER("wolfSSL_get_chain_count");
-    if (chain)
-        return chain->count;
-
-    return 0;
-}
-
-
-/* Get peer's ASN.1 DER ceritifcate at index (idx) length in bytes */
-int wolfSSL_get_chain_length(WOLFSSL_X509_CHAIN* chain, int idx)
-{
-    WOLFSSL_ENTER("wolfSSL_get_chain_length");
-    if (chain)
-        return chain->certs[idx].length;
-
-    return 0;
-}
-
-
-/* Get peer's ASN.1 DER ceritifcate at index (idx) */
-byte* wolfSSL_get_chain_cert(WOLFSSL_X509_CHAIN* chain, int idx)
-{
-    WOLFSSL_ENTER("wolfSSL_get_chain_cert");
-    if (chain)
-        return chain->certs[idx].buffer;
-
-    return 0;
-}
-
-
-/* Get peer's wolfSSL X509 ceritifcate at index (idx) */
-WOLFSSL_X509* wolfSSL_get_chain_X509(WOLFSSL_X509_CHAIN* chain, int idx)
-{
-    int          ret;
-    WOLFSSL_X509* x509 = NULL;
-#ifdef WOLFSSL_SMALL_STACK
-    DecodedCert* cert = NULL;
-#else
-    DecodedCert  cert[1];
-#endif
-
-    WOLFSSL_ENTER("wolfSSL_get_chain_X509");
-    if (chain != NULL) {
-    #ifdef WOLFSSL_SMALL_STACK
-        cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-        if (cert != NULL)
-    #endif
-        {
-            InitDecodedCert(cert, chain->certs[idx].buffer,
-                                  chain->certs[idx].length, NULL);
-
-            if ((ret = ParseCertRelative(cert, CERT_TYPE, 0, NULL)) != 0)
-                WOLFSSL_MSG("Failed to parse cert");
-            else {
-                x509 = (WOLFSSL_X509*)XMALLOC(sizeof(WOLFSSL_X509), NULL,
-                                                             DYNAMIC_TYPE_X509);
-                if (x509 == NULL) {
-                    WOLFSSL_MSG("Failed alloc X509");
-                }
-                else {
-                    InitX509(x509, 1);
-
-                    if ((ret = CopyDecodedToX509(x509, cert)) != 0) {
-                        WOLFSSL_MSG("Failed to copy decoded");
-                        XFREE(x509, NULL, DYNAMIC_TYPE_X509);
-                        x509 = NULL;
-                    }
-                }
-            }
-
-            FreeDecodedCert(cert);
-        #ifdef WOLFSSL_SMALL_STACK
-            XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        #endif
-        }
-    }
-
-    return x509;
-}
-
-
-/* Get peer's PEM ceritifcate at index (idx), output to buffer if inLen big
-   enough else return error (-1), output length is in *outLen
-   SSL_SUCCESS on ok */
-int  wolfSSL_get_chain_cert_pem(WOLFSSL_X509_CHAIN* chain, int idx,
-                               unsigned char* buf, int inLen, int* outLen)
-{
-    const char header[] = "-----BEGIN CERTIFICATE-----\n";
-    const char footer[] = "-----END CERTIFICATE-----\n";
-
-    int headerLen = sizeof(header) - 1;
-    int footerLen = sizeof(footer) - 1;
-    int i;
-    int err;
-
-    WOLFSSL_ENTER("wolfSSL_get_chain_cert_pem");
-    if (!chain || !outLen || !buf)
-        return BAD_FUNC_ARG;
-
-    /* don't even try if inLen too short */
-    if (inLen < headerLen + footerLen + chain->certs[idx].length)
-        return BAD_FUNC_ARG;
-
-    /* header */
-    XMEMCPY(buf, header, headerLen);
-    i = headerLen;
-
-    /* body */
-    *outLen = inLen;  /* input to Base64_Encode */
-    if ( (err = Base64_Encode(chain->certs[idx].buffer,
-                       chain->certs[idx].length, buf + i, (word32*)outLen)) < 0)
-        return err;
-    i += *outLen;
-
-    /* footer */
-    if ( (i + footerLen) > inLen)
-        return BAD_FUNC_ARG;
-    XMEMCPY(buf + i, footer, footerLen);
-    *outLen += headerLen + footerLen;
-
-    return SSL_SUCCESS;
-}
-
-
-/* get session ID */
-const byte* wolfSSL_get_sessionID(const WOLFSSL_SESSION* session)
-{
-    WOLFSSL_ENTER("wolfSSL_get_sessionID");
-    if (session)
-        return session->sessionID;
-
-    return NULL;
-}
-
-
-#endif /* SESSION_CERTS */
-
-#ifdef HAVE_FUZZER
-void wolfSSL_SetFuzzerCb(WOLFSSL* ssl, CallbackFuzzer cbf, void* fCtx)
-{
-    if (ssl) {
-        ssl->fuzzerCb  = cbf;
-        ssl->fuzzerCtx = fCtx;
-    }
-}
-#endif
-
-#ifndef NO_CERTS
-#ifdef  HAVE_PK_CALLBACKS
-
-#ifdef HAVE_ECC
-
-void  wolfSSL_CTX_SetEccSignCb(WOLFSSL_CTX* ctx, CallbackEccSign cb)
-{
-    if (ctx)
-        ctx->EccSignCb = cb;
-}
-
-
-void  wolfSSL_SetEccSignCtx(WOLFSSL* ssl, void *ctx)
-{
-    if (ssl)
-        ssl->EccSignCtx = ctx;
-}
-
-
-void* wolfSSL_GetEccSignCtx(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->EccSignCtx;
-
-    return NULL;
-}
-
-
-void  wolfSSL_CTX_SetEccVerifyCb(WOLFSSL_CTX* ctx, CallbackEccVerify cb)
-{
-    if (ctx)
-        ctx->EccVerifyCb = cb;
-}
-
-
-void  wolfSSL_SetEccVerifyCtx(WOLFSSL* ssl, void *ctx)
-{
-    if (ssl)
-        ssl->EccVerifyCtx = ctx;
-}
-
-
-void* wolfSSL_GetEccVerifyCtx(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->EccVerifyCtx;
-
-    return NULL;
-}
-
-#endif /* HAVE_ECC */
-
-#ifndef NO_RSA
-
-void  wolfSSL_CTX_SetRsaSignCb(WOLFSSL_CTX* ctx, CallbackRsaSign cb)
-{
-    if (ctx)
-        ctx->RsaSignCb = cb;
-}
-
-
-void  wolfSSL_SetRsaSignCtx(WOLFSSL* ssl, void *ctx)
-{
-    if (ssl)
-        ssl->RsaSignCtx = ctx;
-}
-
-
-void* wolfSSL_GetRsaSignCtx(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->RsaSignCtx;
-
-    return NULL;
-}
-
-
-void  wolfSSL_CTX_SetRsaVerifyCb(WOLFSSL_CTX* ctx, CallbackRsaVerify cb)
-{
-    if (ctx)
-        ctx->RsaVerifyCb = cb;
-}
-
-
-void  wolfSSL_SetRsaVerifyCtx(WOLFSSL* ssl, void *ctx)
-{
-    if (ssl)
-        ssl->RsaVerifyCtx = ctx;
-}
-
-
-void* wolfSSL_GetRsaVerifyCtx(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->RsaVerifyCtx;
-
-    return NULL;
-}
-
-void  wolfSSL_CTX_SetRsaEncCb(WOLFSSL_CTX* ctx, CallbackRsaEnc cb)
-{
-    if (ctx)
-        ctx->RsaEncCb = cb;
-}
-
-
-void  wolfSSL_SetRsaEncCtx(WOLFSSL* ssl, void *ctx)
-{
-    if (ssl)
-        ssl->RsaEncCtx = ctx;
-}
-
-
-void* wolfSSL_GetRsaEncCtx(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->RsaEncCtx;
-
-    return NULL;
-}
-
-void  wolfSSL_CTX_SetRsaDecCb(WOLFSSL_CTX* ctx, CallbackRsaDec cb)
-{
-    if (ctx)
-        ctx->RsaDecCb = cb;
-}
-
-
-void  wolfSSL_SetRsaDecCtx(WOLFSSL* ssl, void *ctx)
-{
-    if (ssl)
-        ssl->RsaDecCtx = ctx;
-}
-
-
-void* wolfSSL_GetRsaDecCtx(WOLFSSL* ssl)
-{
-    if (ssl)
-        return ssl->RsaDecCtx;
-
-    return NULL;
-}
-
-
-#endif /* NO_RSA */
-
-#endif /* HAVE_PK_CALLBACKS */
-#endif /* NO_CERTS */
-
-
-#ifdef WOLFSSL_HAVE_WOLFSCEP
-    /* Used by autoconf to see if wolfSCEP is available */
-    void wolfSSL_wolfSCEP(void) {}
-#endif
-
-
-#ifdef WOLFSSL_HAVE_CERT_SERVICE
-    /* Used by autoconf to see if cert service is available */
-    void wolfSSL_cert_service(void) {}
-#endif
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/src/tls.c b/FreeRTOS-Plus/Source/WolfSSL/src/tls.c
deleted file mode 100755
index f4c76d7..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/src/tls.c
+++ /dev/null
@@ -1,2446 +0,0 @@
-/* tls.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-
-
-#ifndef NO_TLS
-
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-
-#ifdef WOLFSSL_SHA384
-    #define P_HASH_MAX_SIZE SHA384_DIGEST_SIZE
-#else
-    #define P_HASH_MAX_SIZE SHA256_DIGEST_SIZE
-#endif
-
-/* compute p_hash for MD5, SHA-1, SHA-256, or SHA-384 for TLSv1 PRF */
-static int p_hash(byte* result, word32 resLen, const byte* secret,
-                   word32 secLen, const byte* seed, word32 seedLen, int hash)
-{
-    word32 len = P_HASH_MAX_SIZE;
-    word32 times;
-    word32 lastLen;
-    word32 lastTime;
-    word32 i;
-    word32 idx = 0;
-    int    ret = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    byte*  previous;
-    byte*  current;
-    Hmac*  hmac;
-#else
-    byte   previous[P_HASH_MAX_SIZE];  /* max size */
-    byte   current[P_HASH_MAX_SIZE];   /* max size */
-    Hmac   hmac[1];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    previous = (byte*)XMALLOC(P_HASH_MAX_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    current  = (byte*)XMALLOC(P_HASH_MAX_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    hmac     = (Hmac*)XMALLOC(sizeof(Hmac),    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-    if (previous == NULL || current == NULL || hmac == NULL) {
-        if (previous) XFREE(previous, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (current)  XFREE(current,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (hmac)     XFREE(hmac,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-        return MEMORY_E;
-    }
-#endif
-
-    switch (hash) {
-        #ifndef NO_MD5
-            case md5_mac:
-                hash = MD5;
-                len  = MD5_DIGEST_SIZE;
-            break;
-        #endif
-
-        #ifndef NO_SHA256
-            case sha256_mac:
-                hash = SHA256;
-                len  = SHA256_DIGEST_SIZE;
-            break;
-        #endif
-
-        #ifdef WOLFSSL_SHA384
-            case sha384_mac:
-                hash = SHA384;
-                len  = SHA384_DIGEST_SIZE;
-            break;
-        #endif
-
-        #ifndef NO_SHA
-            case sha_mac:
-            default:
-                hash = SHA;
-                len  = SHA_DIGEST_SIZE;
-            break;
-        #endif
-    }
-
-    times   = resLen / len;
-    lastLen = resLen % len;
-
-    if (lastLen)
-        times += 1;
-
-    lastTime = times - 1;
-
-    if ((ret = wc_HmacSetKey(hmac, hash, secret, secLen)) == 0) {
-        if ((ret = wc_HmacUpdate(hmac, seed, seedLen)) == 0) { /* A0 = seed */
-            if ((ret = wc_HmacFinal(hmac, previous)) == 0) {   /* A1 */
-                for (i = 0; i < times; i++) {
-                    ret = wc_HmacUpdate(hmac, previous, len);
-                    if (ret != 0)
-                        break;
-                    ret = wc_HmacUpdate(hmac, seed, seedLen);
-                    if (ret != 0)
-                        break;
-                    ret = wc_HmacFinal(hmac, current);
-                    if (ret != 0)
-                        break;
-
-                    if ((i == lastTime) && lastLen)
-                        XMEMCPY(&result[idx], current,
-                                                 min(lastLen, P_HASH_MAX_SIZE));
-                    else {
-                        XMEMCPY(&result[idx], current, len);
-                        idx += len;
-                        ret = wc_HmacUpdate(hmac, previous, len);
-                        if (ret != 0)
-                            break;
-                        ret = wc_HmacFinal(hmac, previous);
-                        if (ret != 0)
-                            break;
-                    }
-                }
-            }
-        }
-    }
-
-    ForceZero(previous,  P_HASH_MAX_SIZE);
-    ForceZero(current,   P_HASH_MAX_SIZE);
-    ForceZero(hmac,      sizeof(Hmac));
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(previous, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(current,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(hmac,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-#undef P_HASH_MAX_SIZE
-
-
-#ifndef NO_OLD_TLS
-
-/* calculate XOR for TLSv1 PRF */
-static INLINE void get_xor(byte *digest, word32 digLen, byte* md5, byte* sha)
-{
-    word32 i;
-
-    for (i = 0; i < digLen; i++)
-        digest[i] = md5[i] ^ sha[i];
-}
-
-
-/* compute TLSv1 PRF (pseudo random function using HMAC) */
-static int doPRF(byte* digest, word32 digLen, const byte* secret,word32 secLen,
-                 const byte* label, word32 labLen, const byte* seed,
-                 word32 seedLen)
-{
-    int    ret  = 0;
-    word32 half = (secLen + 1) / 2;
-
-#ifdef WOLFSSL_SMALL_STACK
-    byte* md5_half;
-    byte* sha_half;
-    byte* labelSeed;
-    byte* md5_result;
-    byte* sha_result;
-#else
-    byte  md5_half[MAX_PRF_HALF];     /* half is real size */
-    byte  sha_half[MAX_PRF_HALF];     /* half is real size */
-    byte  labelSeed[MAX_PRF_LABSEED]; /* labLen + seedLen is real size */
-    byte  md5_result[MAX_PRF_DIG];    /* digLen is real size */
-    byte  sha_result[MAX_PRF_DIG];    /* digLen is real size */
-#endif
-
-    if (half > MAX_PRF_HALF)
-        return BUFFER_E;
-    if (labLen + seedLen > MAX_PRF_LABSEED)
-        return BUFFER_E;
-    if (digLen > MAX_PRF_DIG)
-        return BUFFER_E;
-
-#ifdef WOLFSSL_SMALL_STACK
-    md5_half   = (byte*)XMALLOC(MAX_PRF_HALF,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    sha_half   = (byte*)XMALLOC(MAX_PRF_HALF,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    labelSeed  = (byte*)XMALLOC(MAX_PRF_LABSEED, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    md5_result = (byte*)XMALLOC(MAX_PRF_DIG,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    sha_result = (byte*)XMALLOC(MAX_PRF_DIG,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-    if (md5_half == NULL || sha_half == NULL || labelSeed == NULL ||
-                                     md5_result == NULL || sha_result == NULL) {
-        if (md5_half)   XFREE(md5_half,   NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (sha_half)   XFREE(sha_half,   NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (labelSeed)  XFREE(labelSeed,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (md5_result) XFREE(md5_result, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (sha_result) XFREE(sha_result, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-        return MEMORY_E;
-    }
-#endif
-
-    XMEMSET(md5_result, 0, digLen);
-    XMEMSET(sha_result, 0, digLen);
-
-    XMEMCPY(md5_half, secret, half);
-    XMEMCPY(sha_half, secret + half - secLen % 2, half);
-
-    XMEMCPY(labelSeed, label, labLen);
-    XMEMCPY(labelSeed + labLen, seed, seedLen);
-
-    if ((ret = p_hash(md5_result, digLen, md5_half, half, labelSeed,
-                                             labLen + seedLen, md5_mac)) == 0) {
-        if ((ret = p_hash(sha_result, digLen, sha_half, half, labelSeed,
-                                             labLen + seedLen, sha_mac)) == 0) {
-            get_xor(digest, digLen, md5_result, sha_result);
-        }
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(md5_half,   NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(sha_half,   NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(labelSeed,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(md5_result, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(sha_result, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-#endif
-
-
-/* Wrapper to call straight thru to p_hash in TSL 1.2 cases to remove stack
-   use */
-static int PRF(byte* digest, word32 digLen, const byte* secret, word32 secLen,
-            const byte* label, word32 labLen, const byte* seed, word32 seedLen,
-            int useAtLeastSha256, int hash_type)
-{
-    int ret = 0;
-
-    if (useAtLeastSha256) {
-#ifdef WOLFSSL_SMALL_STACK
-        byte* labelSeed;
-#else
-        byte labelSeed[MAX_PRF_LABSEED]; /* labLen + seedLen is real size */
-#endif
-
-        if (labLen + seedLen > MAX_PRF_LABSEED)
-            return BUFFER_E;
-
-#ifdef WOLFSSL_SMALL_STACK
-        labelSeed = (byte*)XMALLOC(MAX_PRF_LABSEED, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-        if (labelSeed == NULL)
-           return MEMORY_E;
-#endif
-
-        XMEMCPY(labelSeed, label, labLen);
-        XMEMCPY(labelSeed + labLen, seed, seedLen);
-
-        /* If a cipher suite wants an algorithm better than sha256, it
-         * should use better. */
-        if (hash_type < sha256_mac)
-            hash_type = sha256_mac;
-        ret = p_hash(digest, digLen, secret, secLen, labelSeed,
-                     labLen + seedLen, hash_type);
-
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(labelSeed, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-    }
-#ifndef NO_OLD_TLS
-    else {
-        ret = doPRF(digest, digLen, secret, secLen, label, labLen, seed,
-                    seedLen);
-    }
-#endif
-
-    return ret;
-}
-
-
-#ifdef WOLFSSL_SHA384
-    #define HSHASH_SZ SHA384_DIGEST_SIZE
-#else
-    #define HSHASH_SZ FINISHED_SZ
-#endif
-
-
-int BuildTlsFinished(WOLFSSL* ssl, Hashes* hashes, const byte* sender)
-{
-    const byte* side;
-    byte        handshake_hash[HSHASH_SZ];
-    word32      hashSz = FINISHED_SZ;
-
-#ifndef NO_OLD_TLS
-    wc_Md5GetHash(&ssl->hsHashes->hashMd5, handshake_hash);
-    wc_ShaGetHash(&ssl->hsHashes->hashSha, &handshake_hash[MD5_DIGEST_SIZE]);
-#endif
-
-    if (IsAtLeastTLSv1_2(ssl)) {
-#ifndef NO_SHA256
-        if (ssl->specs.mac_algorithm <= sha256_mac) {
-            int ret = wc_Sha256GetHash(&ssl->hsHashes->hashSha256,handshake_hash);
-
-            if (ret != 0)
-                return ret;
-
-            hashSz = SHA256_DIGEST_SIZE;
-        }
-#endif
-#ifdef WOLFSSL_SHA384
-        if (ssl->specs.mac_algorithm == sha384_mac) {
-            int ret = wc_Sha384Final(&ssl->hsHashes->hashSha384,handshake_hash);
-
-            if (ret != 0)
-                return ret;
-
-            hashSz = SHA384_DIGEST_SIZE;
-        }
-#endif
-    }
-
-    if ( XSTRNCMP((const char*)sender, (const char*)client, SIZEOF_SENDER) == 0)
-        side = tls_client;
-    else
-        side = tls_server;
-
-    return PRF((byte*)hashes, TLS_FINISHED_SZ, ssl->arrays->masterSecret,
-               SECRET_LEN, side, FINISHED_LABEL_SZ, handshake_hash, hashSz,
-               IsAtLeastTLSv1_2(ssl), ssl->specs.mac_algorithm);
-}
-
-
-#ifndef NO_OLD_TLS
-
-ProtocolVersion MakeTLSv1(void)
-{
-    ProtocolVersion pv;
-    pv.major = SSLv3_MAJOR;
-    pv.minor = TLSv1_MINOR;
-
-    return pv;
-}
-
-
-ProtocolVersion MakeTLSv1_1(void)
-{
-    ProtocolVersion pv;
-    pv.major = SSLv3_MAJOR;
-    pv.minor = TLSv1_1_MINOR;
-
-    return pv;
-}
-
-#endif
-
-
-ProtocolVersion MakeTLSv1_2(void)
-{
-    ProtocolVersion pv;
-    pv.major = SSLv3_MAJOR;
-    pv.minor = TLSv1_2_MINOR;
-
-    return pv;
-}
-
-
-static const byte master_label[MASTER_LABEL_SZ + 1] = "master secret";
-static const byte key_label   [KEY_LABEL_SZ + 1]    = "key expansion";
-
-
-/* External facing wrapper so user can call as well, 0 on success */
-int wolfSSL_DeriveTlsKeys(byte* key_data, word32 keyLen,
-                         const byte* ms, word32 msLen,
-                         const byte* sr, const byte* cr,
-                         int tls1_2, int hash_type)
-{
-    byte  seed[SEED_LEN];
-
-    XMEMCPY(seed,           sr, RAN_LEN);
-    XMEMCPY(seed + RAN_LEN, cr, RAN_LEN);
-
-    return PRF(key_data, keyLen, ms, msLen, key_label, KEY_LABEL_SZ,
-               seed, SEED_LEN, tls1_2, hash_type);
-}
-
-
-int DeriveTlsKeys(WOLFSSL* ssl)
-{
-    int   ret;
-    int   length = 2 * ssl->specs.hash_size +
-                   2 * ssl->specs.key_size  +
-                   2 * ssl->specs.iv_size;
-#ifdef WOLFSSL_SMALL_STACK
-    byte* key_data;
-#else
-    byte  key_data[MAX_PRF_DIG];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    key_data = (byte*)XMALLOC(MAX_PRF_DIG, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (key_data == NULL) {
-        return MEMORY_E;
-    }
-#endif
-
-    ret = wolfSSL_DeriveTlsKeys(key_data, length,
-                           ssl->arrays->masterSecret, SECRET_LEN,
-                           ssl->arrays->serverRandom, ssl->arrays->clientRandom,
-                           IsAtLeastTLSv1_2(ssl), ssl->specs.mac_algorithm);
-    if (ret == 0)
-        ret = StoreKeys(ssl, key_data);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(key_data, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-/* External facing wrapper so user can call as well, 0 on success */
-int wolfSSL_MakeTlsMasterSecret(byte* ms, word32 msLen,
-                               const byte* pms, word32 pmsLen,
-                               const byte* cr, const byte* sr,
-                               int tls1_2, int hash_type)
-{
-    byte  seed[SEED_LEN];
-
-    XMEMCPY(seed,           cr, RAN_LEN);
-    XMEMCPY(seed + RAN_LEN, sr, RAN_LEN);
-
-    return PRF(ms, msLen, pms, pmsLen, master_label, MASTER_LABEL_SZ,
-               seed, SEED_LEN, tls1_2, hash_type);
-}
-
-
-int MakeTlsMasterSecret(WOLFSSL* ssl)
-{
-    int   ret;
-
-    ret = wolfSSL_MakeTlsMasterSecret(ssl->arrays->masterSecret, SECRET_LEN,
-              ssl->arrays->preMasterSecret, ssl->arrays->preMasterSz,
-              ssl->arrays->clientRandom, ssl->arrays->serverRandom,
-              IsAtLeastTLSv1_2(ssl), ssl->specs.mac_algorithm);
-
-    if (ret == 0) {
-    #ifdef SHOW_SECRETS
-        int i;
-
-        printf("master secret: ");
-        for (i = 0; i < SECRET_LEN; i++)
-            printf("%02x", ssl->arrays->masterSecret[i]);
-        printf("\n");
-    #endif
-
-        ret = DeriveTlsKeys(ssl);
-    }
-
-    return ret;
-}
-
-
-/* Used by EAP-TLS and EAP-TTLS to derive keying material from
- * the master_secret. */
-int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* msk, unsigned int len,
-                                                              const char* label)
-{
-    int   ret;
-#ifdef WOLFSSL_SMALL_STACK
-    byte* seed;
-#else
-    byte  seed[SEED_LEN];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    seed = (byte*)XMALLOC(SEED_LEN, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (seed == NULL)
-        return MEMORY_E;
-#endif
-
-    /*
-     * As per RFC-5281, the order of the client and server randoms is reversed
-     * from that used by the TLS protocol to derive keys.
-     */
-    XMEMCPY(seed,           ssl->arrays->clientRandom, RAN_LEN);
-    XMEMCPY(seed + RAN_LEN, ssl->arrays->serverRandom, RAN_LEN);
-
-    ret = PRF((byte*)msk, len, ssl->arrays->masterSecret, SECRET_LEN,
-              (const byte *)label, (word32)strlen(label), seed, SEED_LEN,
-              IsAtLeastTLSv1_2(ssl), ssl->specs.mac_algorithm);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(seed, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-/*** next for static INLINE s copied internal.c ***/
-
-/* convert 16 bit integer to opaque */
-static INLINE void c16toa(word16 u16, byte* c)
-{
-    c[0] = (u16 >> 8) & 0xff;
-    c[1] =  u16 & 0xff;
-}
-
-#ifdef HAVE_TLS_EXTENSIONS
-/* convert opaque to 16 bit integer */
-static INLINE void ato16(const byte* c, word16* u16)
-{
-    *u16 = (c[0] << 8) | (c[1]);
-}
-
-#ifdef HAVE_SNI
-/* convert a 24 bit integer into a 32 bit one */
-static INLINE void c24to32(const word24 u24, word32* u32)
-{
-    *u32 = (u24[0] << 16) | (u24[1] << 8) | u24[2];
-}
-#endif
-#endif
-
-/* convert 32 bit integer to opaque */
-static INLINE void c32toa(word32 u32, byte* c)
-{
-    c[0] = (u32 >> 24) & 0xff;
-    c[1] = (u32 >> 16) & 0xff;
-    c[2] = (u32 >>  8) & 0xff;
-    c[3] =  u32 & 0xff;
-}
-
-
-static INLINE word32 GetSEQIncrement(WOLFSSL* ssl, int verify)
-{
-#ifdef WOLFSSL_DTLS
-    if (ssl->options.dtls) {
-        if (verify)
-            return ssl->keys.dtls_state.curSeq; /* explicit from peer */
-        else
-            return ssl->keys.dtls_sequence_number - 1; /* already incremented */
-    }
-#endif
-    if (verify)
-        return ssl->keys.peer_sequence_number++;
-    else
-        return ssl->keys.sequence_number++;
-}
-
-
-#ifdef WOLFSSL_DTLS
-
-static INLINE word32 GetEpoch(WOLFSSL* ssl, int verify)
-{
-    if (verify)
-        return ssl->keys.dtls_state.curEpoch;
-    else
-        return ssl->keys.dtls_epoch;
-}
-
-#endif /* WOLFSSL_DTLS */
-
-
-/*** end copy ***/
-
-
-/* return HMAC digest type in wolfSSL format */
-int wolfSSL_GetHmacType(WOLFSSL* ssl)
-{
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-    switch (ssl->specs.mac_algorithm) {
-        #ifndef NO_MD5
-        case md5_mac:
-        {
-            return MD5;
-        }
-        #endif
-        #ifndef NO_SHA256
-        case sha256_mac:
-        {
-            return SHA256;
-        }
-        #endif
-        #ifdef WOLFSSL_SHA384
-        case sha384_mac:
-        {
-            return SHA384;
-        }
-
-        #endif
-        #ifndef NO_SHA
-        case sha_mac:
-        {
-            return SHA;
-        }
-        #endif
-        #ifdef HAVE_BLAKE2
-        case blake2b_mac:
-        {
-            return BLAKE2B_ID;
-        }
-        #endif
-        default:
-        {
-            return SSL_FATAL_ERROR;
-        }
-    }
-}
-
-
-int wolfSSL_SetTlsHmacInner(WOLFSSL* ssl, byte* inner, word32 sz, int content,
-                           int verify)
-{
-    if (ssl == NULL || inner == NULL)
-        return BAD_FUNC_ARG;
-
-    XMEMSET(inner, 0, WOLFSSL_TLS_HMAC_INNER_SZ);
-
-#ifdef WOLFSSL_DTLS
-    if (ssl->options.dtls)
-        c16toa((word16)GetEpoch(ssl, verify), inner);
-#endif
-    c32toa(GetSEQIncrement(ssl, verify), &inner[sizeof(word32)]);
-    inner[SEQ_SZ] = (byte)content;
-    inner[SEQ_SZ + ENUM_LEN]            = ssl->version.major;
-    inner[SEQ_SZ + ENUM_LEN + ENUM_LEN] = ssl->version.minor;
-    c16toa((word16)sz, inner + SEQ_SZ + ENUM_LEN + VERSION_SZ);
-
-    return 0;
-}
-
-
-/* TLS type HMAC */
-int TLS_hmac(WOLFSSL* ssl, byte* digest, const byte* in, word32 sz,
-              int content, int verify)
-{
-    Hmac hmac;
-    int  ret;
-    byte myInner[WOLFSSL_TLS_HMAC_INNER_SZ];
-
-    if (ssl == NULL)
-        return BAD_FUNC_ARG;
-
-#ifdef HAVE_FUZZER
-    if (ssl->fuzzerCb)
-        ssl->fuzzerCb(ssl, in, sz, FUZZ_HMAC, ssl->fuzzerCtx);
-#endif
-
-    wolfSSL_SetTlsHmacInner(ssl, myInner, sz, content, verify);
-
-    ret = wc_HmacSetKey(&hmac, wolfSSL_GetHmacType(ssl),
-                     wolfSSL_GetMacSecret(ssl, verify), ssl->specs.hash_size);
-    if (ret != 0)
-        return ret;
-    ret = wc_HmacUpdate(&hmac, myInner, sizeof(myInner));
-    if (ret != 0)
-        return ret;
-    ret = wc_HmacUpdate(&hmac, in, sz);                                /* content */
-    if (ret != 0)
-        return ret;
-    ret = wc_HmacFinal(&hmac, digest);
-    if (ret != 0)
-        return ret;
-
-    return 0;
-}
-
-#ifdef HAVE_TLS_EXTENSIONS
-
-
-/** Supports up to 64 flags. Update as needed. */
-#define SEMAPHORE_SIZE 8
-
-
-static INLINE word16 TLSX_ToSemaphore(word16 type)
-{
-    switch (type) {
-        case SECURE_RENEGOTIATION:
-            return 63;
-
-        default:
-            if (type > 62) {
-                /* This message SHOULD only happens during the adding of
-                   new TLS extensions in which its IANA number overflows
-                   the current semaphore's range, or if its number already
-                   is assigned to be used by another extension.
-                   Use this check value for the new extension and decrement
-                   the check value by one. */
-                WOLFSSL_MSG("### TLSX semaphore colision or overflow detected!");
-            }
-    }
-
-    return type;
-}
-
-
-#define IS_OFF(semaphore, light) \
-    ((semaphore)[(light) / 8] ^  (byte) (0x01 << ((light) % 8)))
-
-
-#define TURN_ON(semaphore, light) \
-    ((semaphore)[(light) / 8] |= (byte) (0x01 << ((light) % 8)))
-
-
-static int TLSX_Push(TLSX** list, TLSX_Type type, void* data)
-{
-    TLSX* extension;
-
-    extension = (TLSX*)XMALLOC(sizeof(TLSX), 0, DYNAMIC_TYPE_TLSX);
-    if (extension == NULL)
-        return MEMORY_E;
-
-    extension->type = type;
-    extension->data = data;
-    extension->resp = 0;
-    extension->next = *list;
-    *list = extension;
-
-    /* remove duplicated extensions, there should be only one of each type. */
-    do {
-        if (extension->next && extension->next->type == type) {
-            TLSX *next = extension->next;
-
-            extension->next = next->next;
-            next->next = NULL;
-
-            TLSX_FreeAll(next);
-
-            /* there is no way to occur more than */
-            /* two extensions of the same type.   */
-            break;
-        }
-    } while ((extension = extension->next));
-
-    return 0;
-}
-
-
-#ifndef NO_WOLFSSL_SERVER
-
-void TLSX_SetResponse(WOLFSSL* ssl, TLSX_Type type);
-
-void TLSX_SetResponse(WOLFSSL* ssl, TLSX_Type type)
-{
-    TLSX *ext = TLSX_Find(ssl->extensions, type);
-
-    if (ext)
-        ext->resp = 1;
-}
-
-#endif
-
-/* SNI - Server Name Indication */
-
-#ifdef HAVE_SNI
-
-static void TLSX_SNI_Free(SNI* sni)
-{
-    if (sni) {
-        switch (sni->type) {
-            case WOLFSSL_SNI_HOST_NAME:
-                XFREE(sni->data.host_name, 0, DYNAMIC_TYPE_TLSX);
-            break;
-        }
-
-        XFREE(sni, 0, DYNAMIC_TYPE_TLSX);
-    }
-}
-
-static void TLSX_SNI_FreeAll(SNI* list)
-{
-    SNI* sni;
-
-    while ((sni = list)) {
-        list = sni->next;
-        TLSX_SNI_Free(sni);
-    }
-}
-
-static int TLSX_SNI_Append(SNI** list, byte type, const void* data, word16 size)
-{
-    SNI* sni;
-
-    if (list == NULL)
-        return BAD_FUNC_ARG;
-
-    if ((sni = XMALLOC(sizeof(SNI), 0, DYNAMIC_TYPE_TLSX)) == NULL)
-        return MEMORY_E;
-
-    switch (type) {
-        case WOLFSSL_SNI_HOST_NAME: {
-            sni->data.host_name = XMALLOC(size + 1, 0, DYNAMIC_TYPE_TLSX);
-
-            if (sni->data.host_name) {
-                XSTRNCPY(sni->data.host_name, (const char*)data, size);
-                sni->data.host_name[size] = 0;
-            } else {
-                XFREE(sni, 0, DYNAMIC_TYPE_TLSX);
-                return MEMORY_E;
-            }
-        }
-        break;
-
-        default: /* invalid type */
-            XFREE(sni, 0, DYNAMIC_TYPE_TLSX);
-            return BAD_FUNC_ARG;
-    }
-
-    sni->type = type;
-    sni->next = *list;
-
-#ifndef NO_WOLFSSL_SERVER
-    sni->options = 0;
-    sni->status  = WOLFSSL_SNI_NO_MATCH;
-#endif
-
-    *list = sni;
-
-    return 0;
-}
-
-static word16 TLSX_SNI_GetSize(SNI* list)
-{
-    SNI* sni;
-    word16 length = OPAQUE16_LEN; /* list length */
-
-    while ((sni = list)) {
-        list = sni->next;
-
-        length += ENUM_LEN + OPAQUE16_LEN; /* sni type + sni length */
-
-        switch (sni->type) {
-            case WOLFSSL_SNI_HOST_NAME:
-                length += XSTRLEN((char*)sni->data.host_name);
-            break;
-        }
-    }
-
-    return length;
-}
-
-static word16 TLSX_SNI_Write(SNI* list, byte* output)
-{
-    SNI* sni;
-    word16 length = 0;
-    word16 offset = OPAQUE16_LEN; /* list length offset */
-
-    while ((sni = list)) {
-        list = sni->next;
-
-        output[offset++] = sni->type; /* sni type */
-
-        switch (sni->type) {
-            case WOLFSSL_SNI_HOST_NAME:
-                length = XSTRLEN((char*)sni->data.host_name);
-
-                c16toa(length, output + offset); /* sni length */
-                offset += OPAQUE16_LEN;
-
-                XMEMCPY(output + offset, sni->data.host_name, length);
-
-                offset += length;
-            break;
-        }
-    }
-
-    c16toa(offset - OPAQUE16_LEN, output); /* writing list length */
-
-    return offset;
-}
-
-static SNI* TLSX_SNI_Find(SNI *list, byte type)
-{
-    SNI *sni = list;
-
-    while (sni && sni->type != type)
-        sni = sni->next;
-
-    return sni;
-}
-
-#ifndef NO_WOLFSSL_SERVER
-static void TLSX_SNI_SetStatus(TLSX* extensions, byte type, byte status)
-{
-    TLSX* extension = TLSX_Find(extensions, SERVER_NAME_INDICATION);
-    SNI* sni = TLSX_SNI_Find(extension ? extension->data : NULL, type);
-
-    if (sni) {
-        sni->status = status;
-        WOLFSSL_MSG("SNI did match!");
-    }
-}
-
-byte TLSX_SNI_Status(TLSX* extensions, byte type)
-{
-    TLSX* extension = TLSX_Find(extensions, SERVER_NAME_INDICATION);
-    SNI* sni = TLSX_SNI_Find(extension ? extension->data : NULL, type);
-
-    if (sni)
-        return sni->status;
-
-    return 0;
-}
-#endif
-
-static int TLSX_SNI_Parse(WOLFSSL* ssl, byte* input, word16 length,
-                                                                 byte isRequest)
-{
-#ifndef NO_WOLFSSL_SERVER
-    word16 size = 0;
-    word16 offset = 0;
-#endif
-
-    TLSX *extension = TLSX_Find(ssl->extensions, SERVER_NAME_INDICATION);
-
-    if (!extension)
-        extension = TLSX_Find(ssl->ctx->extensions, SERVER_NAME_INDICATION);
-
-    if (!extension || !extension->data)
-        return isRequest ? 0 : BUFFER_ERROR; /* not using SNI OR unexpected
-                                                SNI response from server. */
-
-    if (!isRequest)
-        return length ? BUFFER_ERROR : 0; /* SNI response must be empty!
-                                             Nothing else to do. */
-
-#ifndef NO_WOLFSSL_SERVER
-
-    if (OPAQUE16_LEN > length)
-        return BUFFER_ERROR;
-
-    ato16(input, &size);
-    offset += OPAQUE16_LEN;
-
-    /* validating sni list length */
-    if (length != OPAQUE16_LEN + size)
-        return BUFFER_ERROR;
-
-    for (size = 0; offset < length; offset += size) {
-        SNI *sni;
-        byte type = input[offset++];
-
-        if (offset + OPAQUE16_LEN > length)
-            return BUFFER_ERROR;
-
-        ato16(input + offset, &size);
-        offset += OPAQUE16_LEN;
-
-        if (offset + size > length)
-            return BUFFER_ERROR;
-
-        if (!(sni = TLSX_SNI_Find((SNI*)extension->data, type))) {
-            continue; /* not using this SNI type */
-        }
-
-        switch(type) {
-            case WOLFSSL_SNI_HOST_NAME: {
-                byte matched = (XSTRLEN(sni->data.host_name) == size)
-                            && (XSTRNCMP(sni->data.host_name,
-                                       (const char*)input + offset, size) == 0);
-
-                if (matched || sni->options & WOLFSSL_SNI_ANSWER_ON_MISMATCH) {
-                    int r = TLSX_UseSNI(&ssl->extensions,
-                                                    type, input + offset, size);
-
-                    if (r != SSL_SUCCESS) return r; /* throw error */
-
-                    TLSX_SNI_SetStatus(ssl->extensions, type,
-                      matched ? WOLFSSL_SNI_REAL_MATCH : WOLFSSL_SNI_FAKE_MATCH);
-
-                } else if (!(sni->options & WOLFSSL_SNI_CONTINUE_ON_MISMATCH)) {
-                    SendAlert(ssl, alert_fatal, unrecognized_name);
-
-                    return UNKNOWN_SNI_HOST_NAME_E;
-                }
-                break;
-            }
-        }
-
-        TLSX_SetResponse(ssl, SERVER_NAME_INDICATION);
-    }
-
-#endif
-
-    return 0;
-}
-
-int TLSX_UseSNI(TLSX** extensions, byte type, const void* data, word16 size)
-{
-    TLSX* extension = TLSX_Find(*extensions, SERVER_NAME_INDICATION);
-    SNI*  sni       = NULL;
-    int   ret       = 0;
-
-    if (extensions == NULL || data == NULL)
-        return BAD_FUNC_ARG;
-
-    if ((ret = TLSX_SNI_Append(&sni, type, data, size)) != 0)
-        return ret;
-
-    if (!extension) {
-        if ((ret = TLSX_Push(extensions, SERVER_NAME_INDICATION, (void*)sni))
-                                                                         != 0) {
-            TLSX_SNI_Free(sni);
-            return ret;
-        }
-    }
-    else {
-        /* push new SNI object to extension data. */
-        sni->next = (SNI*)extension->data;
-        extension->data = (void*)sni;
-
-        /* look for another server name of the same type to remove */
-        do {
-            if (sni->next && sni->next->type == type) {
-                SNI *next = sni->next;
-
-                sni->next = next->next;
-                TLSX_SNI_Free(next);
-
-                break;
-            }
-        } while ((sni = sni->next));
-    }
-
-    return SSL_SUCCESS;
-}
-
-#ifndef NO_WOLFSSL_SERVER
-word16 TLSX_SNI_GetRequest(TLSX* extensions, byte type, void** data)
-{
-    TLSX* extension = TLSX_Find(extensions, SERVER_NAME_INDICATION);
-    SNI* sni = TLSX_SNI_Find(extension ? extension->data : NULL, type);
-
-    if (sni && sni->status != WOLFSSL_SNI_NO_MATCH) {
-        switch (sni->type) {
-            case WOLFSSL_SNI_HOST_NAME:
-                *data = sni->data.host_name;
-                return XSTRLEN(*data);
-        }
-    }
-
-    return 0;
-}
-
-void TLSX_SNI_SetOptions(TLSX* extensions, byte type, byte options)
-{
-    TLSX* extension = TLSX_Find(extensions, SERVER_NAME_INDICATION);
-    SNI* sni = TLSX_SNI_Find(extension ? extension->data : NULL, type);
-
-    if (sni)
-        sni->options = options;
-}
-
-int TLSX_SNI_GetFromBuffer(const byte* clientHello, word32 helloSz,
-                           byte type, byte* sni, word32* inOutSz)
-{
-    word32 offset = 0;
-    word32 len32  = 0;
-    word16 len16  = 0;
-
-    if (helloSz < RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ + CLIENT_HELLO_FIRST)
-        return INCOMPLETE_DATA;
-
-    /* TLS record header */
-    if ((enum ContentType) clientHello[offset++] != handshake)
-        return BUFFER_ERROR;
-
-    if (clientHello[offset++] != SSLv3_MAJOR)
-        return BUFFER_ERROR;
-
-    if (clientHello[offset++] < TLSv1_MINOR)
-        return SNI_UNSUPPORTED;
-
-    ato16(clientHello + offset, &len16);
-    offset += OPAQUE16_LEN;
-
-    if (offset + len16 > helloSz)
-        return INCOMPLETE_DATA;
-
-    /* Handshake header */
-    if ((enum HandShakeType) clientHello[offset] != client_hello)
-        return BUFFER_ERROR;
-
-    c24to32(clientHello + offset + 1, &len32);
-    offset += HANDSHAKE_HEADER_SZ;
-
-    if (offset + len32 > helloSz)
-        return BUFFER_ERROR;
-
-    /* client hello */
-    offset += VERSION_SZ + RAN_LEN; /* version, random */
-
-    if (helloSz < offset + clientHello[offset])
-        return BUFFER_ERROR;
-
-    offset += ENUM_LEN + clientHello[offset]; /* skip session id */
-
-    /* cypher suites */
-    if (helloSz < offset + OPAQUE16_LEN)
-        return BUFFER_ERROR;
-
-    ato16(clientHello + offset, &len16);
-    offset += OPAQUE16_LEN;
-
-    if (helloSz < offset + len16)
-        return BUFFER_ERROR;
-
-    offset += len16; /* skip cypher suites */
-
-    /* compression methods */
-    if (helloSz < offset + 1)
-        return BUFFER_ERROR;
-
-    if (helloSz < offset + clientHello[offset])
-        return BUFFER_ERROR;
-
-    offset += ENUM_LEN + clientHello[offset]; /* skip compression methods */
-
-    /* extensions */
-    if (helloSz < offset + OPAQUE16_LEN)
-        return 0; /* no extensions in client hello. */
-
-    ato16(clientHello + offset, &len16);
-    offset += OPAQUE16_LEN;
-
-    if (helloSz < offset + len16)
-        return BUFFER_ERROR;
-
-    while (len16 >= OPAQUE16_LEN + OPAQUE16_LEN) {
-        word16 extType;
-        word16 extLen;
-
-        ato16(clientHello + offset, &extType);
-        offset += OPAQUE16_LEN;
-
-        ato16(clientHello + offset, &extLen);
-        offset += OPAQUE16_LEN;
-
-        if (helloSz < offset + extLen)
-            return BUFFER_ERROR;
-
-        if (extType != SERVER_NAME_INDICATION) {
-            offset += extLen; /* skip extension */
-        } else {
-            word16 listLen;
-
-            ato16(clientHello + offset, &listLen);
-            offset += OPAQUE16_LEN;
-
-            if (helloSz < offset + listLen)
-                return BUFFER_ERROR;
-
-            while (listLen > ENUM_LEN + OPAQUE16_LEN) {
-                byte   sniType = clientHello[offset++];
-                word16 sniLen;
-
-                ato16(clientHello + offset, &sniLen);
-                offset += OPAQUE16_LEN;
-
-                if (helloSz < offset + sniLen)
-                    return BUFFER_ERROR;
-
-                if (sniType != type) {
-                    offset  += sniLen;
-                    listLen -= min(ENUM_LEN + OPAQUE16_LEN + sniLen, listLen);
-                    continue;
-                }
-
-                *inOutSz = min(sniLen, *inOutSz);
-                XMEMCPY(sni, clientHello + offset, *inOutSz);
-
-                return SSL_SUCCESS;
-            }
-        }
-
-        len16 -= min(2 * OPAQUE16_LEN + extLen, len16);
-    }
-
-    return len16 ? BUFFER_ERROR : 0;
-}
-
-#endif
-
-#define SNI_FREE_ALL TLSX_SNI_FreeAll
-#define SNI_GET_SIZE TLSX_SNI_GetSize
-#define SNI_WRITE    TLSX_SNI_Write
-#define SNI_PARSE    TLSX_SNI_Parse
-
-#else
-
-#define SNI_FREE_ALL(list)
-#define SNI_GET_SIZE(list)    0
-#define SNI_WRITE(a, b)       0
-#define SNI_PARSE(a, b, c, d) 0
-
-#endif /* HAVE_SNI */
-
-#ifdef HAVE_MAX_FRAGMENT
-
-static word16 TLSX_MFL_Write(byte* data, byte* output)
-{
-    output[0] = data[0];
-
-    return ENUM_LEN;
-}
-
-static int TLSX_MFL_Parse(WOLFSSL* ssl, byte* input, word16 length,
-                                                                 byte isRequest)
-{
-    if (length != ENUM_LEN)
-        return BUFFER_ERROR;
-
-    switch (*input) {
-        case WOLFSSL_MFL_2_9 : ssl->max_fragment =  512; break;
-        case WOLFSSL_MFL_2_10: ssl->max_fragment = 1024; break;
-        case WOLFSSL_MFL_2_11: ssl->max_fragment = 2048; break;
-        case WOLFSSL_MFL_2_12: ssl->max_fragment = 4096; break;
-        case WOLFSSL_MFL_2_13: ssl->max_fragment = 8192; break;
-
-        default:
-            SendAlert(ssl, alert_fatal, illegal_parameter);
-
-            return UNKNOWN_MAX_FRAG_LEN_E;
-    }
-
-#ifndef NO_WOLFSSL_SERVER
-    if (isRequest) {
-        int r = TLSX_UseMaxFragment(&ssl->extensions, *input);
-
-        if (r != SSL_SUCCESS) return r; /* throw error */
-
-        TLSX_SetResponse(ssl, MAX_FRAGMENT_LENGTH);
-    }
-#endif
-
-    return 0;
-}
-
-int TLSX_UseMaxFragment(TLSX** extensions, byte mfl)
-{
-    byte* data = NULL;
-    int   ret  = 0;
-
-    if (extensions == NULL)
-        return BAD_FUNC_ARG;
-
-    if (mfl < WOLFSSL_MFL_2_9 || WOLFSSL_MFL_2_13 < mfl)
-        return BAD_FUNC_ARG;
-
-    if ((data = XMALLOC(ENUM_LEN, 0, DYNAMIC_TYPE_TLSX)) == NULL)
-        return MEMORY_E;
-
-    data[0] = mfl;
-
-    /* push new MFL extension. */
-    if ((ret = TLSX_Push(extensions, MAX_FRAGMENT_LENGTH, data)) != 0) {
-        XFREE(data, 0, DYNAMIC_TYPE_TLSX);
-        return ret;
-    }
-
-    return SSL_SUCCESS;
-}
-
-
-#define MFL_FREE_ALL(data) XFREE(data, 0, DYNAMIC_TYPE_TLSX)
-#define MFL_GET_SIZE(data) ENUM_LEN
-#define MFL_WRITE          TLSX_MFL_Write
-#define MFL_PARSE          TLSX_MFL_Parse
-
-#else
-
-#define MFL_FREE_ALL(a)
-#define MFL_GET_SIZE(a)       0
-#define MFL_WRITE(a, b)       0
-#define MFL_PARSE(a, b, c, d) 0
-
-#endif /* HAVE_MAX_FRAGMENT */
-
-#ifdef HAVE_TRUNCATED_HMAC
-
-static int TLSX_THM_Parse(WOLFSSL* ssl, byte* input, word16 length,
-                                                                 byte isRequest)
-{
-    if (length != 0 || input == NULL)
-        return BUFFER_ERROR;
-
-#ifndef NO_WOLFSSL_SERVER
-    if (isRequest) {
-        int r = TLSX_UseTruncatedHMAC(&ssl->extensions);
-
-        if (r != SSL_SUCCESS) return r; /* throw error */
-
-        TLSX_SetResponse(ssl, TRUNCATED_HMAC);
-    }
-#endif
-
-    ssl->truncated_hmac = 1;
-
-    return 0;
-}
-
-int TLSX_UseTruncatedHMAC(TLSX** extensions)
-{
-    int ret = 0;
-
-    if (extensions == NULL)
-        return BAD_FUNC_ARG;
-
-    if ((ret = TLSX_Push(extensions, TRUNCATED_HMAC, NULL)) != 0)
-        return ret;
-
-    return SSL_SUCCESS;
-}
-
-#define THM_PARSE TLSX_THM_Parse
-
-#else
-
-#define THM_PARSE(a, b, c, d) 0
-
-#endif /* HAVE_TRUNCATED_HMAC */
-
-#ifdef HAVE_SUPPORTED_CURVES
-
-#ifndef HAVE_ECC
-#error Elliptic Curves Extension requires Elliptic Curve Cryptography. \
-       Use --enable-ecc in the configure script or define HAVE_ECC.
-#endif
-
-static void TLSX_EllipticCurve_FreeAll(EllipticCurve* list)
-{
-    EllipticCurve* curve;
-
-    while ((curve = list)) {
-        list = curve->next;
-        XFREE(curve, 0, DYNAMIC_TYPE_TLSX);
-    }
-}
-
-static int TLSX_EllipticCurve_Append(EllipticCurve** list, word16 name)
-{
-    EllipticCurve* curve;
-
-    if (list == NULL)
-        return BAD_FUNC_ARG;
-
-    if ((curve = XMALLOC(sizeof(EllipticCurve), 0, DYNAMIC_TYPE_TLSX)) == NULL)
-        return MEMORY_E;
-
-    curve->name = name;
-    curve->next = *list;
-
-    *list = curve;
-
-    return 0;
-}
-
-#ifndef NO_WOLFSSL_CLIENT
-
-static void TLSX_EllipticCurve_ValidateRequest(WOLFSSL* ssl, byte* semaphore)
-{
-    int i;
-
-    for (i = 0; i < ssl->suites->suiteSz; i+= 2)
-        if (ssl->suites->suites[i] == ECC_BYTE)
-            return;
-
-    /* No elliptic curve suite found */
-    TURN_ON(semaphore, TLSX_ToSemaphore(ELLIPTIC_CURVES));
-}
-
-static word16 TLSX_EllipticCurve_GetSize(EllipticCurve* list)
-{
-    EllipticCurve* curve;
-    word16 length = OPAQUE16_LEN; /* list length */
-
-    while ((curve = list)) {
-        list = curve->next;
-        length += OPAQUE16_LEN; /* curve length */
-    }
-
-    return length;
-}
-
-static word16 TLSX_EllipticCurve_WriteR(EllipticCurve* curve, byte* output);
-static word16 TLSX_EllipticCurve_WriteR(EllipticCurve* curve, byte* output)
-{
-    word16 offset = 0;
-
-    if (!curve)
-        return offset;
-
-    offset = TLSX_EllipticCurve_WriteR(curve->next, output);
-    c16toa(curve->name, output + offset);
-
-    return OPAQUE16_LEN + offset;
-}
-
-static word16 TLSX_EllipticCurve_Write(EllipticCurve* list, byte* output)
-{
-    word16 length = TLSX_EllipticCurve_WriteR(list, output + OPAQUE16_LEN);
-
-    c16toa(length, output); /* writing list length */
-
-    return OPAQUE16_LEN + length;
-}
-
-#endif /* NO_WOLFSSL_CLIENT */
-#ifndef NO_WOLFSSL_SERVER
-
-static int TLSX_EllipticCurve_Parse(WOLFSSL* ssl, byte* input, word16 length,
-                                                                 byte isRequest)
-{
-    word16 offset;
-    word16 name;
-    int r;
-
-    (void) isRequest; /* shut up compiler! */
-
-    if (OPAQUE16_LEN > length || length % OPAQUE16_LEN)
-        return BUFFER_ERROR;
-
-    ato16(input, &offset);
-
-    /* validating curve list length */
-    if (length != OPAQUE16_LEN + offset)
-        return BUFFER_ERROR;
-
-    while (offset) {
-        ato16(input + offset, &name);
-        offset -= OPAQUE16_LEN;
-
-        r = TLSX_UseSupportedCurve(&ssl->extensions, name);
-
-        if (r != SSL_SUCCESS) return r; /* throw error */
-    }
-
-    return 0;
-}
-
-int TLSX_ValidateEllipticCurves(WOLFSSL* ssl, byte first, byte second) {
-    TLSX*          extension = (first == ECC_BYTE)
-                             ? TLSX_Find(ssl->extensions, ELLIPTIC_CURVES)
-                             : NULL;
-    EllipticCurve* curve     = NULL;
-    word32         oid       = 0;
-    word16         octets    = 0; /* acording to 'ecc_set_type ecc_sets[];' */
-    int            sig       = 0; /* valitade signature */
-    int            key       = 0; /* validate key       */
-
-    (void)oid;
-    (void)octets;
-
-    if (!extension)
-        return 1; /* no suite restriction */
-
-    for (curve = extension->data; curve && !(sig && key); curve = curve->next) {
-
-        switch (curve->name) {
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC160)
-            case WOLFSSL_ECC_SECP160R1: oid = ECC_160R1; octets = 20; break;
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC192)
-            case WOLFSSL_ECC_SECP192R1: oid = ECC_192R1; octets = 24; break;
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC224)
-            case WOLFSSL_ECC_SECP224R1: oid = ECC_224R1; octets = 28; break;
-#endif
-#if defined(HAVE_ALL_CURVES) || !defined(NO_ECC256)
-            case WOLFSSL_ECC_SECP256R1: oid = ECC_256R1; octets = 32; break;
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC384)
-            case WOLFSSL_ECC_SECP384R1: oid = ECC_384R1; octets = 48; break;
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC521)
-            case WOLFSSL_ECC_SECP521R1: oid = ECC_521R1; octets = 66; break;
-#endif
-            default: continue; /* unsupported curve */
-        }
-
-        switch (second) {
-#ifndef NO_DSA
-            /* ECDHE_ECDSA */
-            case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA:
-            case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA:
-            case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA:
-            case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA:
-            case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256:
-            case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384:
-            case TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:
-            case TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:
-            case TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8:
-            case TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8:
-                sig |= ssl->pkCurveOID == oid;
-                key |= ssl->eccTempKeySz == octets;
-            break;
-
-            /* ECDH_ECDSA */
-            case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA:
-            case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA:
-            case TLS_ECDH_ECDSA_WITH_RC4_128_SHA:
-            case TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA:
-            case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256:
-            case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384:
-            case TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256:
-            case TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384:
-                sig |= ssl->pkCurveOID == oid;
-                key |= ssl->pkCurveOID == oid;
-            break;
-#endif
-#ifndef NO_RSA
-            /* ECDHE_RSA */
-            case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA:
-            case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:
-            case TLS_ECDHE_RSA_WITH_RC4_128_SHA:
-            case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA:
-            case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:
-            case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384:
-            case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:
-            case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:
-                sig = 1;
-                key |= ssl->eccTempKeySz == octets;
-            break;
-
-            /* ECDH_RSA */
-            case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA:
-            case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA:
-            case TLS_ECDH_RSA_WITH_RC4_128_SHA:
-            case TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA:
-            case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256:
-            case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384:
-            case TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256:
-            case TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384:
-                sig = 1;
-                key |= ssl->pkCurveOID == oid;
-            break;
-#endif
-            default:
-                sig = 1;
-                key = 1;
-            break;
-        }
-    }
-
-    return sig && key;
-}
-
-#endif /* NO_WOLFSSL_SERVER */
-
-int TLSX_UseSupportedCurve(TLSX** extensions, word16 name)
-{
-    TLSX*          extension = TLSX_Find(*extensions, ELLIPTIC_CURVES);
-    EllipticCurve* curve     = NULL;
-    int            ret       = 0;
-
-    if (extensions == NULL)
-        return BAD_FUNC_ARG;
-
-    if ((ret = TLSX_EllipticCurve_Append(&curve, name)) != 0)
-        return ret;
-
-    if (!extension) {
-        if ((ret = TLSX_Push(extensions, ELLIPTIC_CURVES, curve)) != 0) {
-            XFREE(curve, 0, DYNAMIC_TYPE_TLSX);
-            return ret;
-        }
-    }
-    else {
-        /* push new EllipticCurve object to extension data. */
-        curve->next = (EllipticCurve*)extension->data;
-        extension->data = (void*)curve;
-
-        /* look for another curve of the same name to remove (replacement) */
-        do {
-            if (curve->next && curve->next->name == name) {
-                EllipticCurve *next = curve->next;
-
-                curve->next = next->next;
-                XFREE(next, 0, DYNAMIC_TYPE_TLSX);
-
-                break;
-            }
-        } while ((curve = curve->next));
-    }
-
-    return SSL_SUCCESS;
-}
-
-#define EC_FREE_ALL         TLSX_EllipticCurve_FreeAll
-#define EC_VALIDATE_REQUEST TLSX_EllipticCurve_ValidateRequest
-
-#ifndef NO_WOLFSSL_CLIENT
-#define EC_GET_SIZE TLSX_EllipticCurve_GetSize
-#define EC_WRITE    TLSX_EllipticCurve_Write
-#else
-#define EC_GET_SIZE(list)         0
-#define EC_WRITE(a, b)            0
-#endif
-
-#ifndef NO_WOLFSSL_SERVER
-#define EC_PARSE TLSX_EllipticCurve_Parse
-#else
-#define EC_PARSE(a, b, c, d)      0
-#endif
-
-#else
-
-#define EC_FREE_ALL(list)
-#define EC_GET_SIZE(list)         0
-#define EC_WRITE(a, b)            0
-#define EC_PARSE(a, b, c, d)      0
-#define EC_VALIDATE_REQUEST(a, b)
-
-#endif /* HAVE_SUPPORTED_CURVES */
-
-#ifdef HAVE_SECURE_RENEGOTIATION
-
-static byte TLSX_SecureRenegotiation_GetSize(SecureRenegotiation* data,
-                                                                  int isRequest)
-{
-    byte length = OPAQUE8_LEN; /* empty info length */
-
-    if (data->enabled) {
-        /* client sends client_verify_data only */
-        length += TLS_FINISHED_SZ;
-
-        /* server also sends server_verify_data */
-        if (!isRequest)
-            length += TLS_FINISHED_SZ;
-    }
-
-    return length;
-}
-
-static word16 TLSX_SecureRenegotiation_Write(SecureRenegotiation* data,
-                                                    byte* output, int isRequest)
-{
-    word16 offset = OPAQUE8_LEN; /* RenegotiationInfo length */
-
-    if (data->enabled) {
-        /* client sends client_verify_data only */
-        XMEMCPY(output + offset, data->client_verify_data, TLS_FINISHED_SZ);
-        offset += TLS_FINISHED_SZ;
-
-        /* server also sends server_verify_data */
-        if (!isRequest) {
-            XMEMCPY(output + offset, data->server_verify_data, TLS_FINISHED_SZ);
-            offset += TLS_FINISHED_SZ;
-        }
-    }
-
-    output[0] = offset - 1;  /* info length - self */
-
-    return offset;
-}
-
-static int TLSX_SecureRenegotiation_Parse(WOLFSSL* ssl, byte* input,
-                                                  word16 length, byte isRequest)
-{
-    int ret = SECURE_RENEGOTIATION_E;
-
-    if (length >= OPAQUE8_LEN) {
-        if (ssl->secure_renegotiation == NULL) {
-        #ifndef NO_WOLFSSL_SERVER
-            if (isRequest && *input == 0) {
-                ret = 0;  /* don't reply, user didn't enable */
-            }
-        #endif
-        }
-        else if (isRequest) {
-        #ifndef NO_WOLFSSL_SERVER
-            if (*input == TLS_FINISHED_SZ) {
-                /* TODO compare client_verify_data */
-                ret = 0;
-            }
-        #endif
-        }
-        else {
-        #ifndef NO_WOLFSSL_CLIENT
-            if (!ssl->secure_renegotiation->enabled) {
-                if (*input == 0) {
-                    ssl->secure_renegotiation->enabled = 1;
-                    ret = 0;
-                }
-            }
-            else if (*input == 2 * TLS_FINISHED_SZ) {
-                /* TODO compare client_verify_data and server_verify_data */
-                ret = 0;
-            }
-        #endif
-        }
-    }
-
-    if (ret != 0) {
-        /* TODO: turn on fatal error at ssl level too */
-        SendAlert(ssl, alert_fatal, handshake_failure);
-    }
-
-    return ret;
-}
-
-int TLSX_UseSecureRenegotiation(TLSX** extensions)
-{
-    int ret = 0;
-    SecureRenegotiation* data = NULL;
-
-    data = (SecureRenegotiation*)XMALLOC(sizeof(SecureRenegotiation), NULL,
-                                                             DYNAMIC_TYPE_TLSX);
-    if (data == NULL)
-        return MEMORY_E;
-
-    XMEMSET(data, 0, sizeof(SecureRenegotiation));
-
-    ret = TLSX_Push(extensions, SECURE_RENEGOTIATION, data);
-    if (ret != 0) {
-        XFREE(data, 0, DYNAMIC_TYPE_TLSX);
-        return ret;
-    }
-
-    return SSL_SUCCESS;
-}
-
-
-#define SCR_FREE_ALL(data) XFREE(data, NULL, DYNAMIC_TYPE_TLSX)
-#define SCR_GET_SIZE       TLSX_SecureRenegotiation_GetSize
-#define SCR_WRITE          TLSX_SecureRenegotiation_Write
-#define SCR_PARSE          TLSX_SecureRenegotiation_Parse
-
-#else
-
-#define SCR_FREE_ALL(a)
-#define SCR_GET_SIZE(a, b)    0
-#define SCR_WRITE(a, b, c)    0
-#define SCR_PARSE(a, b, c, d) 0
-
-#endif /* HAVE_SECURE_RENEGOTIATION */
-
-#ifdef HAVE_SESSION_TICKET
-
-static void TLSX_SessionTicket_ValidateRequest(WOLFSSL* ssl)
-{
-    TLSX*          extension = TLSX_Find(ssl->extensions, SESSION_TICKET);
-    SessionTicket* ticket    = extension ? extension->data : NULL;
-
-    if (ticket) {
-        /* TODO validate ticket timeout here! */
-        if (ticket->lifetime == 0xfffffff) {
-            /* send empty ticket on timeout */
-            TLSX_UseSessionTicket(&ssl->extensions, NULL);
-        }
-    }
-}
-
-
-static word16 TLSX_SessionTicket_GetSize(SessionTicket* ticket, int isRequest)
-{
-    (void)isRequest;
-    return ticket ? ticket->size : 0;
-}
-
-static word16 TLSX_SessionTicket_Write(SessionTicket* ticket, byte* output,
-                                                                  int isRequest)
-{
-    word16 offset = 0; /* empty ticket */
-
-    if (isRequest && ticket) {
-        XMEMCPY(output + offset, ticket->data, ticket->size);
-        offset += ticket->size;
-    }
-
-    return offset;
-}
-
-
-static int TLSX_SessionTicket_Parse(WOLFSSL* ssl, byte* input, word16 length,
-                                                                 byte isRequest)
-{
-    int ret = 0;
-
-    if (!isRequest) {
-        /* client side */
-        if (length != 0)
-            return BUFFER_ERROR;
-
-        ssl->expect_session_ticket = 1;
-    }
-#ifndef NO_WOLFSSL_SERVER
-    else {
-        /* server side */
-        if (ssl->ctx->ticketEncCb == NULL) {
-            WOLFSSL_MSG("Client sent session ticket, server has no callback");
-            return 0;
-        }
-
-        if (length == 0) {
-            /* blank ticket */
-            ret = TLSX_UseSessionTicket(&ssl->extensions, NULL);
-            if (ret == SSL_SUCCESS) {
-                ret = 0;
-                TLSX_SetResponse(ssl, SESSION_TICKET);  /* send blank ticket */
-                ssl->options.createTicket = 1;  /* will send ticket msg */
-                ssl->options.useTicket    = 1;
-            }
-        } else {
-            /* got actual ticket from client */
-            ret = DoClientTicket(ssl, input, length);
-            if (ret == WOLFSSL_TICKET_RET_OK) {    /* use ticket to resume */
-                WOLFSSL_MSG("Using exisitng client ticket");
-                ssl->options.useTicket = 1;
-                ssl->options.resuming  = 1;
-            } else if (ret == WOLFSSL_TICKET_RET_CREATE) {
-                WOLFSSL_MSG("Using existing client ticket, creating new one");
-                ret = TLSX_UseSessionTicket(&ssl->extensions, NULL);
-                if (ret == SSL_SUCCESS) {
-                    ret = 0;
-                    TLSX_SetResponse(ssl, SESSION_TICKET);
-                                                    /* send blank ticket */
-                    ssl->options.createTicket = 1;  /* will send ticket msg */
-                    ssl->options.useTicket    = 1;
-                    ssl->options.resuming     = 1;
-                }
-            } else if (ret == WOLFSSL_TICKET_RET_REJECT) {
-                WOLFSSL_MSG("Process client ticket rejected, not using");
-                ret = 0;  /* not fatal */
-            } else if (ret == WOLFSSL_TICKET_RET_FATAL || ret < 0) {
-                WOLFSSL_MSG("Process client ticket fatal error, not using");
-            }
-        }
-    }
-#endif /* NO_WOLFSSL_SERVER */
-
-    return ret;
-}
-
-WOLFSSL_LOCAL SessionTicket* TLSX_SessionTicket_Create(word32 lifetime,
-                                                       byte* data, word16 size)
-{
-    SessionTicket* ticket = (SessionTicket*)XMALLOC(sizeof(SessionTicket),
-                                                       NULL, DYNAMIC_TYPE_TLSX);
-    if (ticket) {
-        ticket->data = (byte*)XMALLOC(size, NULL, DYNAMIC_TYPE_TLSX);
-        if (ticket->data == NULL) {
-            XFREE(ticket, NULL, DYNAMIC_TYPE_TLSX);
-            return NULL;
-        }
-
-        XMEMCPY(ticket->data, data, size);
-        ticket->size     = size;
-        ticket->lifetime = lifetime;
-    }
-
-    return ticket;
-}
-WOLFSSL_LOCAL void TLSX_SessionTicket_Free(SessionTicket* ticket)
-{
-    if (ticket) {
-        XFREE(ticket->data, NULL, DYNAMIC_TYPE_TLSX);
-        XFREE(ticket,       NULL, DYNAMIC_TYPE_TLSX);
-    }
-}
-
-int TLSX_UseSessionTicket(TLSX** extensions, SessionTicket* ticket)
-{
-    int ret = 0;
-
-    if (extensions == NULL)
-        return BAD_FUNC_ARG;
-
-    /* If the ticket is NULL, the client will request a new ticket from the
-       server. Otherwise, the client will use it in the next client hello. */
-    if ((ret = TLSX_Push(extensions, SESSION_TICKET, (void*)ticket)) != 0)
-        return ret;
-
-    return SSL_SUCCESS;
-}
-
-#define STK_VALIDATE_REQUEST TLSX_SessionTicket_ValidateRequest
-#define STK_GET_SIZE         TLSX_SessionTicket_GetSize
-#define STK_WRITE            TLSX_SessionTicket_Write
-#define STK_PARSE            TLSX_SessionTicket_Parse
-
-#else
-
-#define STK_VALIDATE_REQUEST(a)
-#define STK_GET_SIZE(a, b)      0
-#define STK_WRITE(a, b, c)      0
-#define STK_PARSE(a, b, c, d)   0
-
-#endif /* HAVE_SESSION_TICKET */
-
-
-TLSX* TLSX_Find(TLSX* list, TLSX_Type type)
-{
-    TLSX* extension = list;
-
-    while (extension && extension->type != type)
-        extension = extension->next;
-
-    return extension;
-}
-
-void TLSX_FreeAll(TLSX* list)
-{
-    TLSX* extension;
-
-    while ((extension = list)) {
-        list = extension->next;
-
-        switch (extension->type) {
-            case SERVER_NAME_INDICATION:
-                SNI_FREE_ALL((SNI*)extension->data);
-                break;
-
-            case MAX_FRAGMENT_LENGTH:
-                MFL_FREE_ALL(extension->data);
-                break;
-
-            case TRUNCATED_HMAC:
-                /* Nothing to do. */
-                break;
-
-            case ELLIPTIC_CURVES:
-                EC_FREE_ALL(extension->data);
-                break;
-
-            case SECURE_RENEGOTIATION:
-                SCR_FREE_ALL(extension->data);
-                break;
-
-            case SESSION_TICKET:
-                /* Nothing to do. */
-                break;
-        }
-
-        XFREE(extension, 0, DYNAMIC_TYPE_TLSX);
-    }
-}
-
-int TLSX_SupportExtensions(WOLFSSL* ssl) {
-    return ssl && (IsTLS(ssl) || ssl->version.major == DTLS_MAJOR);
-}
-
-static word16 TLSX_GetSize(TLSX* list, byte* semaphore, byte isRequest)
-{
-    TLSX* extension;
-    word16 length = 0;
-
-    while ((extension = list)) {
-        list = extension->next;
-
-        if (!isRequest && !extension->resp)
-            continue; /* skip! */
-
-        if (!IS_OFF(semaphore, TLSX_ToSemaphore(extension->type)))
-            continue; /* skip! */
-
-        /* type + data length */
-        length += HELLO_EXT_TYPE_SZ + OPAQUE16_LEN;
-
-        switch (extension->type) {
-            case SERVER_NAME_INDICATION:
-                if (isRequest)
-                    length += SNI_GET_SIZE(extension->data);
-                break;
-            case MAX_FRAGMENT_LENGTH:
-                length += MFL_GET_SIZE(extension->data);
-                break;
-
-            case TRUNCATED_HMAC:
-                /* empty extension. */
-                break;
-
-            case ELLIPTIC_CURVES:
-                length += EC_GET_SIZE(extension->data);
-                break;
-
-            case SECURE_RENEGOTIATION:
-                length += SCR_GET_SIZE(extension->data, isRequest);
-                break;
-
-            case SESSION_TICKET:
-                length += STK_GET_SIZE(extension->data, isRequest);
-                break;
-        }
-
-        TURN_ON(semaphore, TLSX_ToSemaphore(extension->type));
-    }
-
-    return length;
-}
-
-static word16 TLSX_Write(TLSX* list, byte* output, byte* semaphore,
-                                                                 byte isRequest)
-{
-    TLSX* extension;
-    word16 offset = 0;
-    word16 length_offset = 0;
-
-    while ((extension = list)) {
-        list = extension->next;
-
-        if (!isRequest && !extension->resp)
-            continue; /* skip! */
-
-        if (!IS_OFF(semaphore, TLSX_ToSemaphore(extension->type)))
-            continue; /* skip! */
-
-        /* extension type */
-        c16toa(extension->type, output + offset);
-        offset += HELLO_EXT_TYPE_SZ + OPAQUE16_LEN;
-        length_offset = offset;
-
-        /* extension data should be written internally */
-        switch (extension->type) {
-            case SERVER_NAME_INDICATION:
-                if (isRequest)
-                    offset += SNI_WRITE(extension->data, output + offset);
-                break;
-
-            case MAX_FRAGMENT_LENGTH:
-                offset += MFL_WRITE(extension->data, output + offset);
-                break;
-
-            case TRUNCATED_HMAC:
-                /* empty extension. */
-                break;
-
-            case ELLIPTIC_CURVES:
-                offset += EC_WRITE(extension->data, output + offset);
-                break;
-
-            case SECURE_RENEGOTIATION:
-                offset += SCR_WRITE(extension->data, output + offset,
-                                                                     isRequest);
-                break;
-
-            case SESSION_TICKET:
-                offset += STK_WRITE(extension->data, output + offset,
-                                                                     isRequest);
-                break;
-        }
-
-        /* writing extension data length */
-        c16toa(offset - length_offset, output + length_offset - OPAQUE16_LEN);
-
-        TURN_ON(semaphore, TLSX_ToSemaphore(extension->type));
-    }
-
-    return offset;
-}
-
-#ifndef NO_WOLFSSL_CLIENT
-
-word16 TLSX_GetRequestSize(WOLFSSL* ssl)
-{
-    word16 length = 0;
-
-    if (TLSX_SupportExtensions(ssl)) {
-        byte semaphore[SEMAPHORE_SIZE] = {0};
-
-        EC_VALIDATE_REQUEST(ssl, semaphore);
-        STK_VALIDATE_REQUEST(ssl);
-
-        if (ssl->extensions)
-            length += TLSX_GetSize(ssl->extensions, semaphore, 1);
-
-        if (ssl->ctx && ssl->ctx->extensions)
-            length += TLSX_GetSize(ssl->ctx->extensions, semaphore, 1);
-
-        if (IsAtLeastTLSv1_2(ssl) && ssl->suites->hashSigAlgoSz)
-            length += ssl->suites->hashSigAlgoSz + HELLO_EXT_LEN;
-    }
-
-    if (length)
-        length += OPAQUE16_LEN; /* for total length storage */
-
-    return length;
-}
-
-word16 TLSX_WriteRequest(WOLFSSL* ssl, byte* output)
-{
-    word16 offset = 0;
-
-    if (TLSX_SupportExtensions(ssl) && output) {
-        byte semaphore[SEMAPHORE_SIZE] = {0};
-
-        offset += OPAQUE16_LEN; /* extensions length */
-
-        EC_VALIDATE_REQUEST(ssl, semaphore);
-
-        if (ssl->extensions)
-            offset += TLSX_Write(ssl->extensions, output + offset,
-                                                                  semaphore, 1);
-
-        if (ssl->ctx && ssl->ctx->extensions)
-            offset += TLSX_Write(ssl->ctx->extensions, output + offset,
-                                                                  semaphore, 1);
-
-        if (IsAtLeastTLSv1_2(ssl) && ssl->suites->hashSigAlgoSz)
-        {
-            int i;
-            /* extension type */
-            c16toa(HELLO_EXT_SIG_ALGO, output + offset);
-            offset += HELLO_EXT_TYPE_SZ;
-
-            /* extension data length */
-            c16toa(OPAQUE16_LEN + ssl->suites->hashSigAlgoSz, output + offset);
-            offset += OPAQUE16_LEN;
-
-            /* sig algos length */
-            c16toa(ssl->suites->hashSigAlgoSz, output + offset);
-            offset += OPAQUE16_LEN;
-
-            /* sig algos */
-            for (i = 0; i < ssl->suites->hashSigAlgoSz; i++, offset++)
-                output[offset] = ssl->suites->hashSigAlgo[i];
-        }
-
-        if (offset > OPAQUE16_LEN)
-            c16toa(offset - OPAQUE16_LEN, output); /* extensions length */
-    }
-
-    return offset;
-}
-
-#endif /* NO_WOLFSSL_CLIENT */
-
-#ifndef NO_WOLFSSL_SERVER
-
-word16 TLSX_GetResponseSize(WOLFSSL* ssl)
-{
-    word16 length = 0;
-    byte semaphore[SEMAPHORE_SIZE] = {0};
-
-    if (TLSX_SupportExtensions(ssl))
-        length += TLSX_GetSize(ssl->extensions, semaphore, 0);
-
-    /* All the response data is set at the ssl object only, so no ctx here. */
-
-    if (length)
-        length += OPAQUE16_LEN; /* for total length storage */
-
-    return length;
-}
-
-word16 TLSX_WriteResponse(WOLFSSL *ssl, byte* output)
-{
-    word16 offset = 0;
-
-    if (TLSX_SupportExtensions(ssl) && output) {
-        byte semaphore[SEMAPHORE_SIZE] = {0};
-
-        offset += OPAQUE16_LEN; /* extensions length */
-
-        offset += TLSX_Write(ssl->extensions, output + offset, semaphore, 0);
-
-        if (offset > OPAQUE16_LEN)
-            c16toa(offset - OPAQUE16_LEN, output); /* extensions length */
-    }
-
-    return offset;
-}
-
-#endif /* NO_WOLFSSL_SERVER */
-
-int TLSX_Parse(WOLFSSL* ssl, byte* input, word16 length, byte isRequest,
-                                                                 Suites *suites)
-{
-    int ret = 0;
-    word16 offset = 0;
-
-    if (!ssl || !input || (isRequest && !suites))
-        return BAD_FUNC_ARG;
-
-    while (ret == 0 && offset < length) {
-        word16 type;
-        word16 size;
-
-        if (length - offset < HELLO_EXT_TYPE_SZ + OPAQUE16_LEN)
-            return BUFFER_ERROR;
-
-        ato16(input + offset, &type);
-        offset += HELLO_EXT_TYPE_SZ;
-
-        ato16(input + offset, &size);
-        offset += OPAQUE16_LEN;
-
-        if (offset + size > length)
-            return BUFFER_ERROR;
-
-        switch (type) {
-            case SERVER_NAME_INDICATION:
-                WOLFSSL_MSG("SNI extension received");
-
-                ret = SNI_PARSE(ssl, input + offset, size, isRequest);
-                break;
-
-            case MAX_FRAGMENT_LENGTH:
-                WOLFSSL_MSG("Max Fragment Length extension received");
-
-                ret = MFL_PARSE(ssl, input + offset, size, isRequest);
-                break;
-
-            case TRUNCATED_HMAC:
-                WOLFSSL_MSG("Truncated HMAC extension received");
-
-                ret = THM_PARSE(ssl, input + offset, size, isRequest);
-                break;
-
-            case ELLIPTIC_CURVES:
-                WOLFSSL_MSG("Elliptic Curves extension received");
-
-                ret = EC_PARSE(ssl, input + offset, size, isRequest);
-                break;
-
-            case SECURE_RENEGOTIATION:
-                WOLFSSL_MSG("Secure Renegotiation extension received");
-
-                ret = SCR_PARSE(ssl, input + offset, size, isRequest);
-                break;
-
-            case SESSION_TICKET:
-                WOLFSSL_MSG("Session Ticket extension received");
-
-                ret = STK_PARSE(ssl, input + offset, size, isRequest);
-                break;
-
-            case HELLO_EXT_SIG_ALGO:
-                if (isRequest) {
-                    /* do not mess with offset inside the switch! */
-                    if (IsAtLeastTLSv1_2(ssl)) {
-                        ato16(input + offset, &suites->hashSigAlgoSz);
-
-                        if (suites->hashSigAlgoSz > size - OPAQUE16_LEN)
-                            return BUFFER_ERROR;
-
-                        XMEMCPY(suites->hashSigAlgo,
-                                input + offset + OPAQUE16_LEN,
-                                min(suites->hashSigAlgoSz,
-                                                        HELLO_EXT_SIGALGO_MAX));
-                    }
-                } else {
-                    WOLFSSL_MSG("Servers MUST NOT send SIG ALGO extension.");
-                }
-
-                break;
-        }
-
-        /* offset should be updated here! */
-        offset += size;
-    }
-
-    return ret;
-}
-
-/* undefining semaphore macros */
-#undef IS_OFF
-#undef TURN_ON
-#undef SEMAPHORE_SIZE
-
-#endif
-
-
-#ifndef NO_WOLFSSL_CLIENT
-
-#ifndef NO_OLD_TLS
-
-    WOLFSSL_METHOD* wolfTLSv1_client_method(void)
-    {
-        WOLFSSL_METHOD* method =
-                             (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
-                                                      DYNAMIC_TYPE_METHOD);
-        if (method)
-            InitSSL_Method(method, MakeTLSv1());
-        return method;
-    }
-
-
-    WOLFSSL_METHOD* wolfTLSv1_1_client_method(void)
-    {
-        WOLFSSL_METHOD* method =
-                              (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
-                                                       DYNAMIC_TYPE_METHOD);
-        if (method)
-            InitSSL_Method(method, MakeTLSv1_1());
-        return method;
-    }
-
-#endif /* !NO_OLD_TLS */
-
-#ifndef NO_SHA256   /* can't use without SHA256 */
-
-    WOLFSSL_METHOD* wolfTLSv1_2_client_method(void)
-    {
-        WOLFSSL_METHOD* method =
-                              (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
-                                                       DYNAMIC_TYPE_METHOD);
-        if (method)
-            InitSSL_Method(method, MakeTLSv1_2());
-        return method;
-    }
-
-#endif
-
-
-    WOLFSSL_METHOD* wolfSSLv23_client_method(void)
-    {
-        WOLFSSL_METHOD* method =
-                              (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
-                                                       DYNAMIC_TYPE_METHOD);
-        if (method) {
-#ifndef NO_SHA256         /* 1.2 requires SHA256 */
-            InitSSL_Method(method, MakeTLSv1_2());
-#else
-            InitSSL_Method(method, MakeTLSv1_1());
-#endif
-#ifndef NO_OLD_TLS
-            method->downgrade = 1;
-#endif
-        }
-        return method;
-    }
-
-
-#endif /* NO_WOLFSSL_CLIENT */
-
-
-
-#ifndef NO_WOLFSSL_SERVER
-
-#ifndef NO_OLD_TLS
-
-    WOLFSSL_METHOD* wolfTLSv1_server_method(void)
-    {
-        WOLFSSL_METHOD* method =
-                              (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
-                                                       DYNAMIC_TYPE_METHOD);
-        if (method) {
-            InitSSL_Method(method, MakeTLSv1());
-            method->side = WOLFSSL_SERVER_END;
-        }
-        return method;
-    }
-
-
-    WOLFSSL_METHOD* wolfTLSv1_1_server_method(void)
-    {
-        WOLFSSL_METHOD* method =
-                              (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
-                                                       DYNAMIC_TYPE_METHOD);
-        if (method) {
-            InitSSL_Method(method, MakeTLSv1_1());
-            method->side = WOLFSSL_SERVER_END;
-        }
-        return method;
-    }
-
-#endif /* !NO_OLD_TLS */
-
-#ifndef NO_SHA256   /* can't use without SHA256 */
-
-    WOLFSSL_METHOD* wolfTLSv1_2_server_method(void)
-    {
-        WOLFSSL_METHOD* method =
-                              (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
-                                                       DYNAMIC_TYPE_METHOD);
-        if (method) {
-            InitSSL_Method(method, MakeTLSv1_2());
-            method->side = WOLFSSL_SERVER_END;
-        }
-        return method;
-    }
-
-#endif
-
-
-    WOLFSSL_METHOD* wolfSSLv23_server_method(void)
-    {
-        WOLFSSL_METHOD* method =
-                              (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
-                                                       DYNAMIC_TYPE_METHOD);
-        if (method) {
-#ifndef NO_SHA256         /* 1.2 requires SHA256 */
-            InitSSL_Method(method, MakeTLSv1_2());
-#else
-            InitSSL_Method(method, MakeTLSv1_1());
-#endif
-            method->side      = WOLFSSL_SERVER_END;
-#ifndef NO_OLD_TLS
-            method->downgrade = 1;
-#endif /* !NO_OLD_TLS */
-        }
-        return method;
-    }
-
-
-
-#endif /* NO_WOLFSSL_SERVER */
-#endif /* NO_TLS */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSniffer.vcproj b/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSniffer.vcproj
deleted file mode 100755
index 6892157..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSniffer.vcproj
+++ /dev/null
@@ -1,206 +0,0 @@
-
-
-	
-		
-	
-	
-	
-	
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-	
-	
-	
-	
-		
-			
-			
-		
-		
-			
-			
-		
-		
-			
-			
-		
-	
-	
-	
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSniffer.vcxproj b/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSniffer.vcxproj
deleted file mode 100755
index 56404e9..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSniffer.vcxproj
+++ /dev/null
@@ -1,187 +0,0 @@
-
-
-  
-    
-      Debug
-      Win32
-    
-    
-      Debug
-      x64
-    
-    
-      Release
-      Win32
-    
-    
-      Release
-      x64
-    
-  
-  
-    {34FAE5A6-2B0F-4B55-86FE-0C43E4810F4D}
-    sslSniffer
-    Win32Proj
-  
-  
-  
-    DynamicLibrary
-    v110
-    Unicode
-    true
-  
-  
-    DynamicLibrary
-    v110
-    Unicode
-    true
-  
-  
-    DynamicLibrary
-    v110
-    Unicode
-  
-  
-    DynamicLibrary
-    v110
-    Unicode
-  
-  
-  
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-  
-    <_ProjectFileVersion>11.0.61030.0
-  
-  
-    $(SolutionDir)$(Configuration)\
-    $(Configuration)\obj\
-    true
-  
-  
-    true
-    $(SolutionDir)$(Platform)\$(Configuration)\
-    $(Platform)\$(Configuration)\obj\
-  
-  
-    $(SolutionDir)$(Configuration)\
-    $(Configuration)\obj\
-    false
-  
-  
-    false
-    $(SolutionDir)$(Platform)\$(Configuration)\
-    $(Platform)\$(Configuration)\obj\
-  
-  
-    
-      Disabled
-      ../;%(AdditionalIncludeDirectories)
-      OPENSSL_EXTRA;WOLFSSL_RIPEMD;WOLFSSL_SHA512;NO_PSK;WOLFSSL_SNIFFER;SSL_SNIFFER_EXPORTS;%(PreprocessorDefinitions)
-      true
-      EnableFastChecks
-      MultiThreadedDebugDLL
-      
-      Level3
-      EditAndContinue
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Windows
-      MachineX86
-      false
-    
-  
-  
-    
-      Disabled
-      ../;%(AdditionalIncludeDirectories)
-      OPENSSL_EXTRA;WOLFSSL_RIPEMD;WOLFSSL_SHA512;NO_PSK;WOLFSSL_SNIFFER;SSL_SNIFFER_EXPORTS;%(PreprocessorDefinitions)
-      EnableFastChecks
-      MultiThreadedDebugDLL
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Windows
-    
-  
-  
-    
-      MaxSpeed
-      true
-      ../;%(AdditionalIncludeDirectories)
-      OPENSSL_EXTRA;WOLFSSL_RIPEMD;WOLFSSL_SHA512;NO_PSK;WOLFSSL_SNIFFER;SSL_SNIFFER_EXPORTS;%(PreprocessorDefinitions)
-      MultiThreadedDLL
-      true
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Windows
-      true
-      true
-      MachineX86
-      false
-    
-  
-  
-    
-      MaxSpeed
-      true
-      ../;%(AdditionalIncludeDirectories)
-      OPENSSL_EXTRA;WOLFSSL_RIPEMD;WOLFSSL_SHA512;NO_PSK;WOLFSSL_SNIFFER;SSL_SNIFFER_EXPORTS;%(PreprocessorDefinitions)
-      MultiThreadedDLL
-      true
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Windows
-      true
-      true
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-      {73973223-5ee8-41ca-8e88-1d60e89a237b}
-      false
-    
-  
-  
-  
-  
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSnifferTest/include.am b/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSnifferTest/include.am
deleted file mode 100755
index 222777c..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSnifferTest/include.am
+++ /dev/null
@@ -1,14 +0,0 @@
-# vim:ft=automake
-# included from Top Level Makefile.am
-# All paths should be given relative to the root
-
-if BUILD_SNIFFTEST
-noinst_PROGRAMS += sslSniffer/sslSnifferTest/snifftest
-sslSniffer_sslSnifferTest_snifftest_SOURCES = sslSniffer/sslSnifferTest/snifftest.c
-sslSniffer_sslSnifferTest_snifftest_LDADD        = src/libwolfssl.la -lpcap
-sslSniffer_sslSnifferTest_snifftest_DEPENDENCIES = src/libwolfssl.la
-endif
-EXTRA_DIST += sslSniffer/sslSniffer.vcproj
-EXTRA_DIST += sslSniffer/sslSniffer.vcxproj
-EXTRA_DIST += sslSniffer/sslSnifferTest/sslSniffTest.vcproj
-DISTCLEANFILES+= sslSniffer/sslSnifferTest/.libs/snifftest
diff --git a/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSnifferTest/snifftest.c b/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSnifferTest/snifftest.c
deleted file mode 100755
index 8ffe24d..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSnifferTest/snifftest.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/* snifftest.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef _WIN32
-    #define WOLFSSL_SNIFFER
-#endif
-
-#ifndef WOLFSSL_SNIFFER
-
-/* blank build */
-#include 
-#include 
-int main(void)
-{
-    printf("do ./configure --enable-sniffer to enable build support\n");
-    return EXIT_SUCCESS;
-}
-
-#else
-/* do a full build */
-
-#ifdef _MSC_VER
-	/* builds on *nix too, for scanf device and port */
-	#define _CRT_SECURE_NO_WARNINGS
-#endif
-
-#include      /* pcap stuff */
-#include          /* printf */
-#include         /* EXIT_SUCCESS */
-#include         /* strcmp */
-#include         /* signal */
-
-#include 
-
-
-#ifndef _WIN32
-    #include     /* AF_INET */
-    #include 
-#endif
-
-typedef unsigned char byte;
-
-enum {
-    ETHER_IF_FRAME_LEN = 14,   /* ethernet interface frame length */
-    NULL_IF_FRAME_LEN =   4,   /* no link interface frame length  */
-};
-
-
-pcap_t* pcap = NULL;
-pcap_if_t* alldevs = NULL;
-
-
-static void FreeAll(void)
-{
-    if (pcap)
-        pcap_close(pcap);
-    if (alldevs)
-        pcap_freealldevs(alldevs);
-#ifndef _WIN32
-    ssl_FreeSniffer();
-#endif
-}
-
-static void sig_handler(const int sig) 
-{
-    printf("SIGINT handled = %d.\n", sig);
-    FreeAll();
-    if (sig)
-        exit(EXIT_SUCCESS);
-}
-
-
-static void err_sys(const char* msg)
-{
-	fprintf(stderr, "%s\n", msg);
-    if (msg)
-	    exit(EXIT_FAILURE);
-}
-
-
-#ifdef _WIN32
-	#define SNPRINTF _snprintf
-#else
-	#define SNPRINTF snprintf
-#endif
-
-
-static char* iptos(unsigned int addr)
-{
-	static char    output[32];
-	byte *p = (byte*)&addr;
-
-	SNPRINTF(output, sizeof(output), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
-
-	return output;
-}
-
-
-int main(int argc, char** argv)
-{
-    int          ret = 0;
-    int          hadBadPacket = 0;
-	int		     inum;
-	int		     port;
-    int          saveFile = 0;
-	int		     i = 0;
-    int          frame = ETHER_IF_FRAME_LEN; 
-    char         err[PCAP_ERRBUF_SIZE];
-	char         filter[32];
-	const char  *server = NULL;
-	struct       bpf_program fp;
-	pcap_if_t   *d;
-	pcap_addr_t *a;
-
-    signal(SIGINT, sig_handler);
-
-#ifndef _WIN32
-    ssl_InitSniffer();   /* dll load on Windows */
-#endif
-    ssl_Trace("./tracefile.txt", err);
-
-    if (argc == 1) {
-        /* normal case, user chooses device and port */
-
-	    if (pcap_findalldevs(&alldevs, err) == -1)
-		    err_sys("Error in pcap_findalldevs");
-
-	    for (d = alldevs; d; d=d->next) {
-		    printf("%d. %s", ++i, d->name);
-		    if (d->description)
-			    printf(" (%s)\n", d->description);
-		    else
-			    printf(" (No description available)\n");
-	    }
-
-	    if (i == 0)
-		    err_sys("No interfaces found! Make sure pcap or WinPcap is"
-                    " installed correctly and you have sufficient permissions");
-
-	    printf("Enter the interface number (1-%d): ", i);
-	    ret = scanf("%d", &inum);
-        if (ret != 1)
-            printf("scanf port failed\n");
-
-	    if (inum < 1 || inum > i)
-		    err_sys("Interface number out of range");
-
-	    /* Jump to the selected adapter */
-	    for (d = alldevs, i = 0; i < inum - 1; d = d->next, i++);
-
-	    pcap = pcap_create(d->name, err);
-
-        if (pcap == NULL) printf("pcap_create failed %s\n", err);
-
-	    /* get an IPv4 address */
-	    for (a = d->addresses; a; a = a->next) {
-		    switch(a->addr->sa_family)
-		    {
-			    case AF_INET:
-				    server = 
-                        iptos(((struct sockaddr_in *)a->addr)->sin_addr.s_addr);
-				    printf("server = %s\n", server);
-				    break;
-
-                default:
-                    break;
-		    }
-	    }
-	    if (server == NULL)
-		    err_sys("Unable to get device IPv4 address");
-
-        ret = pcap_set_snaplen(pcap, 65536);
-        if (ret != 0) printf("pcap_set_snaplen failed %s\n", pcap_geterr(pcap));
-
-        ret = pcap_set_timeout(pcap, 1000); 
-        if (ret != 0) printf("pcap_set_timeout failed %s\n", pcap_geterr(pcap));
-
-        ret = pcap_set_buffer_size(pcap, 1000000); 
-        if (ret != 0)
-		    printf("pcap_set_buffer_size failed %s\n", pcap_geterr(pcap));
-
-        ret = pcap_set_promisc(pcap, 1); 
-        if (ret != 0) printf("pcap_set_promisc failed %s\n", pcap_geterr(pcap));
-
-
-        ret = pcap_activate(pcap);
-        if (ret != 0) printf("pcap_activate failed %s\n", pcap_geterr(pcap));
-
-	    printf("Enter the port to scan: ");
-	    ret = scanf("%d", &port);
-        if (ret != 1)
-            printf("scanf port failed\n");
-
-	    SNPRINTF(filter, sizeof(filter), "tcp and port %d", port);
-
-	    ret = pcap_compile(pcap, &fp, filter, 0, 0);
-        if (ret != 0) printf("pcap_compile failed %s\n", pcap_geterr(pcap));
-
-        ret = pcap_setfilter(pcap, &fp);
-        if (ret != 0) printf("pcap_setfilter failed %s\n", pcap_geterr(pcap));
-
-        ret = ssl_SetPrivateKey(server, port, "../../certs/server-key.pem",
-                               FILETYPE_PEM, NULL, err);
-        if (ret != 0) {
-            printf("Please run directly from sslSniffer/sslSnifferTest dir\n");
-        }
-
-#ifdef HAVE_SNI
-        {
-            char altName[128];
-
-            printf("Enter alternate SNI: ");
-            ret = scanf("%s", altName);
-
-            if (strnlen(altName, 128) > 0) {
-                ret = ssl_SetNamedPrivateKey(altName,
-                                   server, port, "../../certs/server-key.pem",
-                                   FILETYPE_PEM, NULL, err);
-                if (ret != 0) {
-                    printf("Please run directly from "
-                           "sslSniffer/sslSnifferTest dir\n");
-                }
-            }
-        }
-#endif
-    }
-    else if (argc >= 3) {
-        saveFile = 1;
-        pcap = pcap_open_offline(argv[1], err);
-        if (pcap == NULL) {
-            printf("pcap_open_offline failed %s\n", err);
-            ret = -1;
-        }
-        else {
-            const char* passwd = NULL;
-            /* defaults for server and port */
-            port = 443;
-            server = "127.0.0.1";
-
-            if (argc >= 4)
-                server = argv[3];
-
-            if (argc >= 5)
-                port = atoi(argv[4]);
-
-            if (argc >= 6)
-                passwd = argv[5];
-
-            ret = ssl_SetPrivateKey(server, port, argv[2],
-                                    FILETYPE_PEM, passwd, err);
-        }
-    }
-    else {
-        /* usage error */
-        printf( "usage: ./snifftest or ./snifftest dump pemKey"
-                " [server] [port] [password]\n");
-        exit(EXIT_FAILURE);
-    }
-
-    if (ret != 0)
-        err_sys(err);
-
-    if (pcap_datalink(pcap) == DLT_NULL) 
-        frame = NULL_IF_FRAME_LEN;
-
-    while (1) {
-        static int packetNumber = 0;
-        struct pcap_pkthdr header;
-        const unsigned char* packet = pcap_next(pcap, &header);
-        packetNumber++;
-        if (packet) {
-
-            byte data[65535+16384];  /* may have a partial 16k record cached */
-
-            if (header.caplen > 40)  { /* min ip(20) + min tcp(20) */
-				packet        += frame;
-				header.caplen -= frame;					
-            }
-            else
-                continue;
-
-            ret = ssl_DecodePacket(packet, header.caplen, data, err);
-            if (ret < 0) {
-                printf("ssl_Decode ret = %d, %s\n", ret, err);
-                hadBadPacket = 1;
-            }
-            if (ret > 0) {
-                data[ret] = 0;
-				printf("SSL App Data(%d:%d):%s\n", packetNumber, ret, data);
-            }
-        }
-        else if (saveFile)
-            break;      /* we're done reading file */
-    }
-    FreeAll();
-
-    return hadBadPacket ? EXIT_FAILURE : EXIT_SUCCESS;
-}
-
-#endif /* full build */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSnifferTest/sslSniffTest.vcproj b/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSnifferTest/sslSniffTest.vcproj
deleted file mode 100755
index ff9977f..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/sslSniffer/sslSnifferTest/sslSniffTest.vcproj
+++ /dev/null
@@ -1,199 +0,0 @@
-
-
-	
-		
-	
-	
-	
-	
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-	
-	
-	
-	
-		
-			
-			
-		
-		
-		
-		
-		
-	
-	
-	
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/stamp-h.in b/FreeRTOS-Plus/Source/WolfSSL/stamp-h.in
deleted file mode 100755
index e69de29..0000000
diff --git a/FreeRTOS-Plus/Source/WolfSSL/support/include.am b/FreeRTOS-Plus/Source/WolfSSL/support/include.am
deleted file mode 100755
index db3ed73..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/support/include.am
+++ /dev/null
@@ -1,10 +0,0 @@
-# vim:ft=automake
-# All paths should be given relative to the root
-#
-
-EXTRA_DIST += support/wolfssl.pc
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = support/wolfssl.pc
-	     
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/support/wolfssl.pc b/FreeRTOS-Plus/Source/WolfSSL/support/wolfssl.pc
deleted file mode 100755
index 277eb17..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/support/wolfssl.pc
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=/usr/local
-exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include
-
-Name: wolfssl
-Description: wolfssl C library.
-Version: 3.6.0
-Libs: -L${libdir} -lwolfssl
-Cflags: -I${includedir}
diff --git a/FreeRTOS-Plus/Source/WolfSSL/support/wolfssl.pc.in b/FreeRTOS-Plus/Source/WolfSSL/support/wolfssl.pc.in
deleted file mode 100755
index e8cb694..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/support/wolfssl.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: wolfssl
-Description: wolfssl C library.
-Version: @VERSION@
-Libs: -L${libdir} -lwolfssl
-Cflags: -I${includedir}
diff --git a/FreeRTOS-Plus/Source/WolfSSL/swig/PythonBuild.sh b/FreeRTOS-Plus/Source/WolfSSL/swig/PythonBuild.sh
deleted file mode 100755
index ae4ac45..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/swig/PythonBuild.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-echo
-swig -python wolfssl.i
-pythonIncludes=`python-config --includes`
-pythonLibs=`python-config --libs`
-gcc -c -fpic wolfssl_wrap.c -I$pythonIncludes
-gcc -c -fpic wolfssl_adds.c 
-gcc -shared -flat_namespace  wolfssl_adds.o  wolfssl_wrap.o -lwolfssl $pythonLibs -o _wolfssl.so
-python runme.py
diff --git a/FreeRTOS-Plus/Source/WolfSSL/swig/README b/FreeRTOS-Plus/Source/WolfSSL/swig/README
deleted file mode 100755
index d71cdb2..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/swig/README
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-Initial swig interface file
-
-Please send questions to support@wolfssl.com
-
-
-
-**Python Support**
-
-    For Linux, OS X, or *nix
-
-1) build wolfSSL with fpic on Linux, not needed on OS X
-    ./configure --disable-shared CFLAGS=-fpic
-    make
-    sudo make install
-
-
-2) start the example server from the root directory
-    ./examples/server/server -d
-
-3) run ./PythonBuild.sh from this directory it will
-    a) build the swig wrapper file
-    b) compile the swig wrapper and wolfssl wrapper files
-    c) place them into a wolfssl shared library for python
-    d) run runme.py which will connect to the wolfSSL server, write a
-       string, then read the result and output it
-
-
-    Windows only
-
-1) Make sure the install path to wolfssl doesn't have any spaces anywhere in the
-   directory path because swig doesn't like that
-2) Have python for Windows installed, note install directory
-3) Have swigwin installed, note install directory
-4) Make sure swigwin install direcotry is added to PATH env. variable
-5) Make sure env. variables PYTHON_INCLUDE and PYTHON_LIB are set correctly e.g.
-    PYTHON_INCLUE="c:\Python26\include"
-    PYTHON_LIB="c:\Python26\libs\python26.lib"
-6) Build python_wolfssl in Release mode only, Debug build fails to find a debug
-    python library that isn't included by default
-7) The outputs _wolfssl.pyd and wolfssl.py are the wolfssl import library
-8) Can now run python runme.py from the swig directory
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/swig/include.am b/FreeRTOS-Plus/Source/WolfSSL/swig/include.am
deleted file mode 100755
index 3bd4c09..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/swig/include.am
+++ /dev/null
@@ -1,12 +0,0 @@
-# vim:ft=automake
-# All paths should be given relative to the root
-
-EXTRA_DIST+= \
-	     swig/PythonBuild.sh \
-	     swig/README \
-	     swig/wolfssl.i \
-	     swig/wolfssl_adds.c \
-	     swig/python_wolfssl.vcproj \
-	     swig/rsasign.py \
-	     swig/runme.py
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/swig/python_wolfssl.vcproj b/FreeRTOS-Plus/Source/WolfSSL/swig/python_wolfssl.vcproj
deleted file mode 100755
index 6af2d36..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/swig/python_wolfssl.vcproj
+++ /dev/null
@@ -1,225 +0,0 @@
-
-
-	
-		
-	
-	
-	
-	
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-	
-	
-	
-	
-		
-			
-			
-			
-			
-		
-		
-		
-		
-		
-		
-			
-				
-			
-			
-				
-			
-		
-	
-	
-	
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/swig/rsasign.py b/FreeRTOS-Plus/Source/WolfSSL/swig/rsasign.py
deleted file mode 100755
index c1c69d0..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/swig/rsasign.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# file: rsasign.py
-
-import wolfssl
-
-
-# start Random Number Generator
-rng = wolfssl.GetRng()
-if rng == None:
-    print "Couldn't get an RNG"
-    exit(-1)
-
-# load RSA private key in DER format
-key = wolfssl.GetRsaPrivateKey("../certs/client-key.der")
-if key == None:
-    print "Couldn't load DER private key file"
-    exit(-1)
-
-# Make byte Arrays and fill input
-signOutput = wolfssl.byteArray(128)   # 128 allows 1024 bit private key
-signStr    = wolfssl.byteArray(25)    # input can't be larger then key size
-                                     # 64 for 512 bit 128 for 1024 bit
-wolfssl.FillSignStr(signStr, "Everybody gets Friday off", 25)
-
-# Do RSA Sign
-signedSize = wolfssl.RsaSSL_Sign(signStr, 25, signOutput, 128, key, rng)
-
-# Show output
-print "Signed Size = ", signedSize, " signed array = ", wolfssl.cdata(signOutput, signedSize)
-
-# let's verify this worked
-signVerify = wolfssl.byteArray(signedSize)
-verifySize = wolfssl.RsaSSL_Verify(signOutput, signedSize, signVerify, signedSize, key)
-
-print "Verify Size = ", verifySize, " verify array = ", wolfssl.cdata(signVerify, verifySize)
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/swig/runme.py b/FreeRTOS-Plus/Source/WolfSSL/swig/runme.py
deleted file mode 100755
index 90fc431..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/swig/runme.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# file: runme.py
-
-import wolfssl
-
-print ""
-print "Trying to connect to the example server -d..."
-
-wolfssl.wolfSSL_Init()
-#wolfssl.wolfSSL_Debugging_ON()
-ctx = wolfssl.wolfSSL_CTX_new(wolfssl.wolfTLSv1_2_client_method())
-if ctx == None:
-    print "Couldn't get SSL CTX for TLSv1.2"
-    exit(-1)
-
-ret = wolfssl.wolfSSL_CTX_load_verify_locations(ctx, "../certs/ca-cert.pem", None)
-if ret != wolfssl.SSL_SUCCESS:
-    print "Couldn't do SSL_CTX_load_verify_locations "
-    print "error string = ", ret
-    exit(-1)
-
-ssl = wolfssl.wolfSSL_new(ctx)
-ret = wolfssl.wolfSSL_swig_connect(ssl, "localhost", 11111)
-
-if ret != wolfssl.SSL_SUCCESS:
-    print "Couldn't do SSL connect"
-    err    = wolfssl.wolfSSL_get_error(ssl, 0)
-    if ret == -2:
-        print "tcp error, is example server running?"
-    else:
-        print "error string = ", wolfssl.wolfSSL_error_string(err)
-    exit(-1)
-
-print "...Connected"
-written = wolfssl.wolfSSL_write(ssl, "hello from python\r\n", 19)
-
-if written > 0:
-    print "Wrote ", written, " bytes"
-
-byteArray = wolfssl.byteArray(100)
-readBytes = wolfssl.wolfSSL_read(ssl, byteArray, 100)
-
-print "server reply: ", wolfssl.cdata(byteArray, readBytes)
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/swig/wolfssl.i b/FreeRTOS-Plus/Source/WolfSSL/swig/wolfssl.i
deleted file mode 100755
index a03e79c..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/swig/wolfssl.i
+++ /dev/null
@@ -1,63 +0,0 @@
-/* wolfssl.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-%module wolfssl
-%{
-    #include 
-    #include 
-
-    /* defn adds */
-    char* wolfSSL_error_string(int err);
-    int   wolfSSL_swig_connect(WOLFSSL*, const char* server, int port);
-    RNG*  GetRng(void);
-    RsaKey* GetRsaPrivateKey(const char* file);
-    void    FillSignStr(unsigned char*, const char*, int);
-%}
-
-
-WOLFSSL_METHOD* wolfTLSv1_2_client_method(void);
-WOLFSSL_CTX*    wolfSSL_CTX_new(WOLFSSL_METHOD*);
-int             wolfSSL_CTX_load_verify_locations(WOLFSSL_CTX*, const char*, const char*);
-WOLFSSL*        wolfSSL_new(WOLFSSL_CTX*);
-int             wolfSSL_get_error(WOLFSSL*, int);
-int             wolfSSL_write(WOLFSSL*, const char*, int);
-int             wolfSSL_Debugging_ON(void);
-int             wolfSSL_Init(void);
-char*           wolfSSL_error_string(int);
-int             wolfSSL_swig_connect(WOLFSSL*, const char* server, int port);
-
-int         wc_RsaSSL_Sign(const unsigned char* in, int inLen, unsigned char* out, int outLen, RsaKey* key, RNG* rng);
-
-int         wc_RsaSSL_Verify(const unsigned char* in, int inLen, unsigned char* out, int outLen, RsaKey* key);
-
-RNG* GetRng(void);
-RsaKey* GetRsaPrivateKey(const char* file);
-void    FillSignStr(unsigned char*, const char*, int);
-
-%include carrays.i
-%include cdata.i
-%array_class(unsigned char, byteArray);
-int         wolfSSL_read(WOLFSSL*, unsigned char*, int);
-
-
-#define    SSL_FAILURE      0
-#define    SSL_SUCCESS      1
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/swig/wolfssl_adds.c b/FreeRTOS-Plus/Source/WolfSSL/swig/wolfssl_adds.c
deleted file mode 100755
index e12ccac..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/swig/wolfssl_adds.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/* wolfssl_adds.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef _WIN32
-    #define HAVE_CONFIG_H
-#endif
-
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-
-#ifdef _WIN32
-    #include 
-    #include 
-    #ifdef TEST_IPV6            /* don't require newer SDK for IPV4 */
-	    #include 
-        #include 
-    #endif
-    #define SOCKET_T int
-#else
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #ifdef NON_BLOCKING
-        #include 
-    #endif
-    #ifdef TEST_IPV6
-        #include 
-    #endif
-    #define SOCKET_T unsigned int
-#endif /* _WIN32 */
-
-#ifdef _MSC_VER
-    /* disable conversion warning */
-    /* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
-    #pragma warning(disable:4244 4996)
-#endif
-
-#if defined(__MACH__) || defined(_WIN32)
-    #ifndef _SOCKLEN_T
-        typedef int socklen_t;
-    #endif
-#endif
-
-
-/* HPUX doesn't use socklent_t for third parameter to accept */
-#if !defined(__hpux__)
-    typedef socklen_t* ACCEPT_THIRD_T;
-#else
-    typedef int*       ACCEPT_THIRD_T;
-#endif
-
-
-#ifdef _WIN32
-    #define CloseSocket(s) closesocket(s)
-    #define StartTCP() { WSADATA wsd; WSAStartup(0x0002, &wsd); }
-#else
-    #define CloseSocket(s) close(s)
-    #define StartTCP()
-#endif
-
-
-#ifdef TEST_IPV6
-    typedef struct sockaddr_in6 SOCKADDR_IN_T;
-    #define AF_INET_V    AF_INET6
-#else
-    typedef struct sockaddr_in  SOCKADDR_IN_T;
-    #define AF_INET_V    AF_INET
-#endif
-
-
-enum {
-    SSL_BLOCKING    = 2,
-    SSL_NONBLOCKING = 4
-};
-
-
-static int tcp_socket(SOCKET_T* sockfd, SOCKADDR_IN_T* addr, const char* peer,
-                       short port)
-{
-    const char* host = peer;
-
-    /* peer could be in human readable form */
-    if (isalpha(peer[0])) {
-        struct hostent* entry = gethostbyname(peer);
-
-        if (entry) {
-            struct sockaddr_in tmp;
-            memset(&tmp, 0, sizeof(struct sockaddr_in));
-            memcpy(&tmp.sin_addr.s_addr, entry->h_addr_list[0],entry->h_length);
-            host = inet_ntoa(tmp.sin_addr);
-        }
-        else
-            return -1;   /* no entry for host */
-    }
-
-    *sockfd = socket(AF_INET, SOCK_STREAM, 0);
-    memset(addr, 0, sizeof(SOCKADDR_IN_T));
-
-    addr->sin_family = AF_INET;
-    addr->sin_port = htons(port);
-    addr->sin_addr.s_addr = inet_addr(host);
-
-#ifdef SO_NOSIGPIPE
-    {
-        int on = 1;
-        socklen_t len = sizeof(on);
-        setsockopt(*sockfd, SOL_SOCKET, SO_NOSIGPIPE, &on, len);
-    }
-#endif
-
-    return 0;
-}
-
-
-static int tcp_connect(SOCKET_T* sockfd, const char* ip, short port)
-{
-    SOCKADDR_IN_T addr;
-    int ret = tcp_socket(sockfd, &addr, ip, port);
-    if (ret != 0) return ret;
-
-    if (connect(*sockfd, (const struct sockaddr*)&addr, sizeof(addr)) != 0)
-        return -2; /* can't connect */
-
-    return 0;
-}
-
-
-int wolfSSL_swig_connect(WOLFSSL* ssl, const char* server, int port)
-{
-    SOCKET_T sockfd;
-    int ret = tcp_connect(&sockfd, server, port);
-    if (ret != 0) return ret;
-
-    wolfSSL_set_fd(ssl, sockfd);
-
-    return wolfSSL_connect(ssl);
-}
-
-
-char* wolfSSL_error_string(int err)
-{
-    static char buffer[WOLFSSL_MAX_ERROR_SZ];
-
-    return wolfSSL_ERR_error_string(err, buffer);
-}
-
-
-RNG* GetRng(void)
-{
-    RNG* rng = (RNG*)malloc(sizeof(RNG));
-
-    if (rng)
-        if (wc_InitRng(rng) != 0) {
-            free(rng);
-            rng = 0;
-        }
-
-    return rng;
-}
-
-
-RsaKey* GetRsaPrivateKey(const char* keyFile)
-{
-    RsaKey* key = (RsaKey*)malloc(sizeof(RsaKey));
-
-    if (key) {
-        byte   tmp[1024];
-        size_t bytes;
-        int    ret;
-        word32 idx = 0;
-        FILE*  file = fopen(keyFile, "rb");
-
-        if (!file) {
-            free(key);
-            return 0;
-        }
-
-        bytes = fread(tmp, 1, sizeof(tmp), file);
-        fclose(file);
-        wc_InitRsaKey(key, 0);
-
-        ret = wc_RsaPrivateKeyDecode(tmp, &idx, key, (word32)bytes);
-        if (ret != 0) {
-            wc_FreeRsaKey(key);
-            free(key);
-            return 0;
-        }
-    }
-    return key;
-}
-
-
-void FillSignStr(unsigned char* dst, const char* src, int size)
-{
-    memcpy(dst, src, size);
-}
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/tests/api.c b/FreeRTOS-Plus/Source/WolfSSL/tests/api.c
deleted file mode 100755
index 216a9ad..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/tests/api.c
+++ /dev/null
@@ -1,1176 +0,0 @@
-/* api.c API unit tests
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/*----------------------------------------------------------------------------*
- | Includes
- *----------------------------------------------------------------------------*/
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-#ifdef HAVE_ECC
-    #include    /* wc_ecc_fp_free */
-#endif
-#include 
-
-#include 
-#include   /* compatibility layer */
-#include 
-#include 
-
-/*----------------------------------------------------------------------------*
- | Constants
- *----------------------------------------------------------------------------*/
-
-#define TEST_SUCCESS    (1)
-#define TEST_FAIL       (0)
-
-#define testingFmt "   %s:"
-#define resultFmt  " %s\n"
-static const char* passed = "passed";
-static const char* failed = "failed";
-
-#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
-static const char* bogusFile  = "/dev/null";
-#endif
-
-/*----------------------------------------------------------------------------*
- | Setup
- *----------------------------------------------------------------------------*/
-
-static int test_wolfSSL_Init(void)
-{
-    int result;
-
-    printf(testingFmt, "wolfSSL_Init()");
-    result = wolfSSL_Init();
-    printf(resultFmt, result == SSL_SUCCESS ? passed : failed);
-
-    return result;
-}
-
-
-static int test_wolfSSL_Cleanup(void)
-{
-    int result;
-
-    printf(testingFmt, "wolfSSL_Cleanup()");
-    result = wolfSSL_Cleanup();
-    printf(resultFmt, result == SSL_SUCCESS ? passed : failed);
-
-    return result;
-}
-
-/*----------------------------------------------------------------------------*
- | Method Allocators
- *----------------------------------------------------------------------------*/
-
-static void test_wolfSSL_Method_Allocators(void)
-{
-    #define TEST_METHOD_ALLOCATOR(allocator, condition) \
-        do {                                            \
-            WOLFSSL_METHOD *method;                      \
-            condition(method = allocator());            \
-            XFREE(method, 0, DYNAMIC_TYPE_METHOD);      \
-        } while(0)
-
-    #define TEST_VALID_METHOD_ALLOCATOR(a) \
-            TEST_METHOD_ALLOCATOR(a, AssertNotNull)
-
-    #define TEST_INVALID_METHOD_ALLOCATOR(a) \
-            TEST_METHOD_ALLOCATOR(a, AssertNull)
-
-#ifndef NO_OLD_TLS
-    TEST_VALID_METHOD_ALLOCATOR(wolfSSLv3_server_method);
-    TEST_VALID_METHOD_ALLOCATOR(wolfSSLv3_client_method);
-    TEST_VALID_METHOD_ALLOCATOR(wolfTLSv1_server_method);
-    TEST_VALID_METHOD_ALLOCATOR(wolfTLSv1_client_method);
-    TEST_VALID_METHOD_ALLOCATOR(wolfTLSv1_1_server_method);
-    TEST_VALID_METHOD_ALLOCATOR(wolfTLSv1_1_client_method);
-#endif
-    TEST_VALID_METHOD_ALLOCATOR(wolfTLSv1_2_server_method);
-    TEST_VALID_METHOD_ALLOCATOR(wolfTLSv1_2_client_method);
-    TEST_VALID_METHOD_ALLOCATOR(wolfSSLv23_client_method);
-
-#ifdef WOLFSSL_DTLS
-    #ifndef NO_OLD_TLS
-        TEST_VALID_METHOD_ALLOCATOR(wolfDTLSv1_server_method);
-        TEST_VALID_METHOD_ALLOCATOR(wolfDTLSv1_client_method);
-    #endif
-    TEST_VALID_METHOD_ALLOCATOR(wolfDTLSv1_2_server_method);
-    TEST_VALID_METHOD_ALLOCATOR(wolfDTLSv1_2_client_method);
-#endif
-
-#ifdef OPENSSL_EXTRA
-    TEST_INVALID_METHOD_ALLOCATOR(wolfSSLv2_server_method);
-    TEST_INVALID_METHOD_ALLOCATOR(wolfSSLv2_client_method);
-#endif
-}
-
-/*----------------------------------------------------------------------------*
- | Context
- *----------------------------------------------------------------------------*/
-
-static void test_wolfSSL_CTX_new(WOLFSSL_METHOD *method)
-{
-    WOLFSSL_CTX *ctx;
-    
-    AssertNull(ctx = wolfSSL_CTX_new(NULL));
-    
-    AssertNotNull(method);
-    AssertNotNull(ctx = wolfSSL_CTX_new(method));
-
-    wolfSSL_CTX_free(ctx);
-}
-
-
-static void test_wolfSSL_CTX_use_certificate_file(void)
-{
-#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
-    WOLFSSL_CTX *ctx;
-
-    AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method()));
-
-    /* invalid context */
-    AssertFalse(wolfSSL_CTX_use_certificate_file(NULL, svrCert, 
-                                                             SSL_FILETYPE_PEM));
-    /* invalid cert file */
-    AssertFalse(wolfSSL_CTX_use_certificate_file(ctx, bogusFile, 
-                                                             SSL_FILETYPE_PEM));
-    /* invalid cert type */
-    AssertFalse(wolfSSL_CTX_use_certificate_file(ctx, svrCert, 9999));
-
-#ifdef NO_RSA
-    /* rsa needed */
-    AssertFalse(wolfSSL_CTX_use_certificate_file(ctx, svrCert,SSL_FILETYPE_PEM));
-#else
-    /* success */
-    AssertTrue(wolfSSL_CTX_use_certificate_file(ctx, svrCert, SSL_FILETYPE_PEM));
-#endif
-
-    wolfSSL_CTX_free(ctx);
-#endif
-}
-
-
-static void test_wolfSSL_CTX_use_PrivateKey_file(void)
-{
-#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
-    WOLFSSL_CTX *ctx;
-
-    AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method()));
-
-    /* invalid context */
-    AssertFalse(wolfSSL_CTX_use_PrivateKey_file(NULL, svrKey, 
-                                                             SSL_FILETYPE_PEM));
-    /* invalid key file */
-    AssertFalse(wolfSSL_CTX_use_PrivateKey_file(ctx, bogusFile, 
-                                                             SSL_FILETYPE_PEM));
-    /* invalid key type */
-    AssertFalse(wolfSSL_CTX_use_PrivateKey_file(ctx, svrKey, 9999));
-
-    /* success */
-#ifdef NO_RSA
-    /* rsa needed */
-    AssertFalse(wolfSSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM));
-#else
-    /* success */
-    AssertTrue(wolfSSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM));
-#endif
-
-    wolfSSL_CTX_free(ctx);
-#endif
-}
-
-
-static void test_wolfSSL_CTX_load_verify_locations(void)
-{
-#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
-    WOLFSSL_CTX *ctx;
-
-    AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()));
-    
-    /* invalid context */
-    AssertFalse(wolfSSL_CTX_load_verify_locations(NULL, caCert, 0));
-
-    /* invalid ca file */
-    AssertFalse(wolfSSL_CTX_load_verify_locations(ctx, NULL,      0));
-    AssertFalse(wolfSSL_CTX_load_verify_locations(ctx, bogusFile, 0));
-
-#ifndef WOLFSSL_TIRTOS
-    /* invalid path */
-    /* not working... investigate! */
-    /* AssertFalse(wolfSSL_CTX_load_verify_locations(ctx, caCert, bogusFile)); */
-#endif
-
-    /* success */
-    AssertTrue(wolfSSL_CTX_load_verify_locations(ctx, caCert, 0));
-
-    wolfSSL_CTX_free(ctx);
-#endif
-}
-
-/*----------------------------------------------------------------------------*
- | SSL
- *----------------------------------------------------------------------------*/
-
-static void test_server_wolfSSL_new(void)
-{
-#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA)
-    WOLFSSL_CTX *ctx;
-    WOLFSSL_CTX *ctx_nocert;
-    WOLFSSL *ssl;
-
-    AssertNotNull(ctx_nocert = wolfSSL_CTX_new(wolfSSLv23_server_method()));
-    AssertNotNull(ctx        = wolfSSL_CTX_new(wolfSSLv23_server_method()));
-
-    AssertTrue(wolfSSL_CTX_use_certificate_file(ctx, svrCert, SSL_FILETYPE_PEM));
-    AssertTrue(wolfSSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM));
-
-    /* invalid context */
-    AssertNull(ssl = wolfSSL_new(NULL));
-    AssertNull(ssl = wolfSSL_new(ctx_nocert));
-
-    /* success */
-    AssertNotNull(ssl = wolfSSL_new(ctx));
-
-    wolfSSL_free(ssl);
-    wolfSSL_CTX_free(ctx);
-    wolfSSL_CTX_free(ctx_nocert);
-#endif
-}
-
-
-static void test_client_wolfSSL_new(void)
-{
-#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA)
-    WOLFSSL_CTX *ctx;
-    WOLFSSL_CTX *ctx_nocert;
-    WOLFSSL *ssl;
-
-    AssertNotNull(ctx_nocert = wolfSSL_CTX_new(wolfSSLv23_client_method()));
-    AssertNotNull(ctx        = wolfSSL_CTX_new(wolfSSLv23_client_method()));
-
-    AssertTrue(wolfSSL_CTX_load_verify_locations(ctx, caCert, 0));
-    
-    /* invalid context */
-    AssertNull(ssl = wolfSSL_new(NULL));
-
-    /* success */
-    AssertNotNull(ssl = wolfSSL_new(ctx_nocert));
-    wolfSSL_free(ssl);
-    
-    /* success */
-    AssertNotNull(ssl = wolfSSL_new(ctx));
-    wolfSSL_free(ssl);
-    
-    wolfSSL_CTX_free(ctx);
-    wolfSSL_CTX_free(ctx_nocert);
-#endif
-}
-
-/*----------------------------------------------------------------------------*
- | IO
- *----------------------------------------------------------------------------*/
-#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \
-    !defined(NO_RSA)        && !defined(SINGLE_THREADED)
-#define HAVE_IO_TESTS_DEPENDENCIES
-#endif
-
-/* helper functions */
-#ifdef HAVE_IO_TESTS_DEPENDENCIES
-static THREAD_RETURN WOLFSSL_THREAD test_server_nofail(void* args)
-{
-    SOCKET_T sockfd = 0;
-    SOCKET_T clientfd = 0;
-    word16 port = wolfSSLPort;
-
-    WOLFSSL_METHOD* method = 0;
-    WOLFSSL_CTX* ctx = 0;
-    WOLFSSL* ssl = 0;
-
-    char msg[] = "I hear you fa shizzle!";
-    char input[1024];
-    int idx;
-
-#ifdef WOLFSSL_TIRTOS
-    fdOpenSession(Task_self());
-#endif
-
-    ((func_args*)args)->return_code = TEST_FAIL;
-    method = wolfSSLv23_server_method();
-    ctx = wolfSSL_CTX_new(method);
-
-#if defined(NO_MAIN_DRIVER) && !defined(USE_WINDOWS_API) && \
-   !defined(WOLFSSL_SNIFFER) && !defined(WOLFSSL_MDK_SHELL) && \
-   !defined(WOLFSSL_TIRTOS)
-    port = 0;
-#endif
-
-    wolfSSL_CTX_set_verify(ctx,
-                          SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
-
-#ifdef OPENSSL_EXTRA
-    wolfSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
-#endif
-
-    if (wolfSSL_CTX_load_verify_locations(ctx, cliCert, 0) != SSL_SUCCESS)
-    {
-        /*err_sys("can't load ca file, Please run from wolfSSL home dir");*/
-        goto done;
-    }
-    if (wolfSSL_CTX_use_certificate_file(ctx, svrCert, SSL_FILETYPE_PEM)
-            != SSL_SUCCESS)
-    {
-        /*err_sys("can't load server cert chain file, "
-                "Please run from wolfSSL home dir");*/
-        goto done;
-    }
-    if (wolfSSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM)
-            != SSL_SUCCESS)
-    {
-        /*err_sys("can't load server key file, "
-                "Please run from wolfSSL home dir");*/
-        goto done;
-    }
-    
-    ssl = wolfSSL_new(ctx);
-    tcp_accept(&sockfd, &clientfd, (func_args*)args, port, 0, 0, 0);
-    CloseSocket(sockfd);
-
-    wolfSSL_set_fd(ssl, clientfd);
-
-#ifdef NO_PSK
-    #if !defined(NO_FILESYSTEM) && !defined(NO_DH)
-        wolfSSL_SetTmpDH_file(ssl, dhParam, SSL_FILETYPE_PEM);
-    #elif !defined(NO_DH)
-        SetDH(ssl);  /* will repick suites with DHE, higher priority than PSK */
-    #endif
-#endif
-
-    if (wolfSSL_accept(ssl) != SSL_SUCCESS)
-    {
-        int err = wolfSSL_get_error(ssl, 0);
-        char buffer[WOLFSSL_MAX_ERROR_SZ];
-        printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buffer));
-        /*err_sys("SSL_accept failed");*/
-        goto done;
-    }
-
-    idx = wolfSSL_read(ssl, input, sizeof(input)-1);
-    if (idx > 0) {
-        input[idx] = 0;
-        printf("Client message: %s\n", input);
-    }
-    
-    if (wolfSSL_write(ssl, msg, sizeof(msg)) != sizeof(msg))
-    {
-        /*err_sys("SSL_write failed");*/
-#ifdef WOLFSSL_TIRTOS
-        return;
-#else
-        return 0;
-#endif
-    }
-
-#ifdef WOLFSSL_TIRTOS
-    Task_yield();
-#endif
-
-done:
-    wolfSSL_shutdown(ssl);
-    wolfSSL_free(ssl);
-    wolfSSL_CTX_free(ctx);
-    
-    CloseSocket(clientfd);
-    ((func_args*)args)->return_code = TEST_SUCCESS;
-
-#ifdef WOLFSSL_TIRTOS
-    fdCloseSession(Task_self());
-#endif
-
-#if defined(NO_MAIN_DRIVER) && defined(HAVE_ECC) && defined(FP_ECC) \
-                            && defined(HAVE_THREAD_LS)
-    wc_ecc_fp_free();  /* free per thread cache */
-#endif
-
-#ifndef WOLFSSL_TIRTOS
-    return 0;
-#endif
-}
-
-
-static void test_client_nofail(void* args)
-{
-    SOCKET_T sockfd = 0;
-
-    WOLFSSL_METHOD*  method  = 0;
-    WOLFSSL_CTX*     ctx     = 0;
-    WOLFSSL*         ssl     = 0;
-
-    char msg[64] = "hello wolfssl!";
-    char reply[1024];
-    int  input;
-    int  msgSz = (int)strlen(msg);
-
-#ifdef WOLFSSL_TIRTOS
-    fdOpenSession(Task_self());
-#endif
-
-    ((func_args*)args)->return_code = TEST_FAIL;
-    method = wolfSSLv23_client_method();
-    ctx = wolfSSL_CTX_new(method);
-
-#ifdef OPENSSL_EXTRA
-    wolfSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
-#endif
-
-    if (wolfSSL_CTX_load_verify_locations(ctx, caCert, 0) != SSL_SUCCESS)
-    {
-        /* err_sys("can't load ca file, Please run from wolfSSL home dir");*/
-        goto done2;
-    }
-    if (wolfSSL_CTX_use_certificate_file(ctx, cliCert, SSL_FILETYPE_PEM)
-            != SSL_SUCCESS)
-    {
-        /*err_sys("can't load client cert file, "
-                "Please run from wolfSSL home dir");*/
-        goto done2;
-    }
-    if (wolfSSL_CTX_use_PrivateKey_file(ctx, cliKey, SSL_FILETYPE_PEM)
-            != SSL_SUCCESS)
-    {
-        /*err_sys("can't load client key file, "
-                "Please run from wolfSSL home dir");*/
-        goto done2;
-    }
-
-    tcp_connect(&sockfd, wolfSSLIP, ((func_args*)args)->signal->port, 0);
-
-    ssl = wolfSSL_new(ctx);
-    wolfSSL_set_fd(ssl, sockfd);
-    if (wolfSSL_connect(ssl) != SSL_SUCCESS)
-    {
-        int  err = wolfSSL_get_error(ssl, 0);
-        char buffer[WOLFSSL_MAX_ERROR_SZ];
-        printf("err = %d, %s\n", err, wolfSSL_ERR_error_string(err, buffer));
-        /*printf("SSL_connect failed");*/
-        goto done2;
-    }
-
-    if (wolfSSL_write(ssl, msg, msgSz) != msgSz)
-    {
-        /*err_sys("SSL_write failed");*/
-        goto done2;
-    }
-
-    input = wolfSSL_read(ssl, reply, sizeof(reply)-1);
-    if (input > 0)
-    {
-        reply[input] = 0;
-        printf("Server response: %s\n", reply);
-    }
-
-done2:
-    wolfSSL_free(ssl);
-    wolfSSL_CTX_free(ctx);
-    
-    CloseSocket(sockfd);
-    ((func_args*)args)->return_code = TEST_SUCCESS;
-
-#ifdef WOLFSSL_TIRTOS
-    fdCloseSession(Task_self());
-#endif
-
-    return;
-}
-
-/* SNI helper functions */
-#ifdef HAVE_SNI
-
-static THREAD_RETURN WOLFSSL_THREAD run_wolfssl_server(void* args)
-{
-    callback_functions* callbacks = ((func_args*)args)->callbacks;
-
-    WOLFSSL_CTX* ctx = wolfSSL_CTX_new(callbacks->method());
-    WOLFSSL*     ssl = NULL;
-    SOCKET_T    sfd = 0;
-    SOCKET_T    cfd = 0;
-    word16      port = wolfSSLPort;
-
-    char msg[] = "I hear you fa shizzle!";
-    int  len   = (int) XSTRLEN(msg);
-    char input[1024];
-    int  idx;
-
-#ifdef WOLFSSL_TIRTOS
-    fdOpenSession(Task_self());
-#endif
-    ((func_args*)args)->return_code = TEST_FAIL;
-
-#if defined(NO_MAIN_DRIVER) && !defined(USE_WINDOWS_API) && \
-   !defined(WOLFSSL_SNIFFER) && !defined(WOLFSSL_MDK_SHELL) && \
-   !defined(WOLFSSL_TIRTOS)
-    port = 0;
-#endif
-
-    wolfSSL_CTX_set_verify(ctx,
-                          SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
-
-#ifdef OPENSSL_EXTRA
-    wolfSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
-#endif
-
-
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_CTX_load_verify_locations(ctx, cliCert, 0));
-
-    AssertIntEQ(SSL_SUCCESS,
-               wolfSSL_CTX_use_certificate_file(ctx, svrCert, SSL_FILETYPE_PEM));
-
-    AssertIntEQ(SSL_SUCCESS,
-                 wolfSSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM));
-
-    if (callbacks->ctx_ready)
-        callbacks->ctx_ready(ctx);
-
-    ssl = wolfSSL_new(ctx);
-
-    tcp_accept(&sfd, &cfd, (func_args*)args, port, 0, 0, 0);
-    CloseSocket(sfd);
-
-    wolfSSL_set_fd(ssl, cfd);
-
-#ifdef NO_PSK
-    #if !defined(NO_FILESYSTEM) && !defined(NO_DH)
-        wolfSSL_SetTmpDH_file(ssl, dhParam, SSL_FILETYPE_PEM);
-    #elif !defined(NO_DH)
-        SetDH(ssl);  /* will repick suites with DHE, higher priority than PSK */
-    #endif
-#endif
-
-    if (callbacks->ssl_ready)
-        callbacks->ssl_ready(ssl);
-
-    /* AssertIntEQ(SSL_SUCCESS, wolfSSL_accept(ssl)); */
-    if (wolfSSL_accept(ssl) != SSL_SUCCESS) {
-        int err = wolfSSL_get_error(ssl, 0);
-        char buffer[WOLFSSL_MAX_ERROR_SZ];
-        printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buffer));
-
-    } else {
-        if (0 < (idx = wolfSSL_read(ssl, input, sizeof(input)-1))) {
-            input[idx] = 0;
-            printf("Client message: %s\n", input);
-        }
-
-        AssertIntEQ(len, wolfSSL_write(ssl, msg, len));
-#ifdef WOLFSSL_TIRTOS
-        Task_yield();
-#endif
-        wolfSSL_shutdown(ssl);
-    }
-
-    if (callbacks->on_result)
-        callbacks->on_result(ssl);
-
-    wolfSSL_free(ssl);
-    wolfSSL_CTX_free(ctx);
-    CloseSocket(cfd);
-
-    ((func_args*)args)->return_code = TEST_SUCCESS;
-
-#ifdef WOLFSSL_TIRTOS
-    fdCloseSession(Task_self());
-#endif
-
-#if defined(NO_MAIN_DRIVER) && defined(HAVE_ECC) && defined(FP_ECC) \
-                            && defined(HAVE_THREAD_LS)
-    wc_ecc_fp_free();  /* free per thread cache */
-#endif
-
-#ifndef WOLFSSL_TIRTOS
-    return 0;
-#endif
-}
-
-
-static void run_wolfssl_client(void* args)
-{
-    callback_functions* callbacks = ((func_args*)args)->callbacks;
-
-    WOLFSSL_CTX* ctx = wolfSSL_CTX_new(callbacks->method());
-    WOLFSSL*     ssl = NULL;
-    SOCKET_T    sfd = 0;
-
-    char msg[] = "hello wolfssl server!";
-    int  len   = (int) XSTRLEN(msg);
-    char input[1024];
-    int  idx;
-
-#ifdef WOLFSSL_TIRTOS
-    fdOpenSession(Task_self());
-#endif
-
-    ((func_args*)args)->return_code = TEST_FAIL;
-
-#ifdef OPENSSL_EXTRA
-    wolfSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
-#endif
-
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_CTX_load_verify_locations(ctx, caCert, 0));
-
-    AssertIntEQ(SSL_SUCCESS,
-               wolfSSL_CTX_use_certificate_file(ctx, cliCert, SSL_FILETYPE_PEM));
-
-    AssertIntEQ(SSL_SUCCESS,
-                 wolfSSL_CTX_use_PrivateKey_file(ctx, cliKey, SSL_FILETYPE_PEM));
-
-    if (callbacks->ctx_ready)
-        callbacks->ctx_ready(ctx);
-
-    tcp_connect(&sfd, wolfSSLIP, ((func_args*)args)->signal->port, 0);
-
-    ssl = wolfSSL_new(ctx);
-    wolfSSL_set_fd(ssl, sfd);
-
-    if (callbacks->ssl_ready)
-        callbacks->ssl_ready(ssl);
-
-    if (wolfSSL_connect(ssl) != SSL_SUCCESS) {
-        int err = wolfSSL_get_error(ssl, 0);
-        char buffer[WOLFSSL_MAX_ERROR_SZ];
-        printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buffer));
-
-    } else {
-        AssertIntEQ(len, wolfSSL_write(ssl, msg, len));
-
-        if (0 < (idx = wolfSSL_read(ssl, input, sizeof(input)-1))) {
-            input[idx] = 0;
-            printf("Server response: %s\n", input);
-        }
-    }
-
-    if (callbacks->on_result)
-        callbacks->on_result(ssl);
-
-    wolfSSL_free(ssl);
-    wolfSSL_CTX_free(ctx);
-    CloseSocket(sfd);
-    ((func_args*)args)->return_code = TEST_SUCCESS;
-
-#ifdef WOLFSSL_TIRTOS
-    fdCloseSession(Task_self());
-#endif
-}
-
-#endif /* HAVE_SNI */
-#endif /* io tests dependencies */
-
-
-static void test_wolfSSL_read_write(void)
-{
-#ifdef HAVE_IO_TESTS_DEPENDENCIES
-    /* The unit testing for read and write shall happen simutaneously, since
-     * one can't do anything with one without the other. (Except for a failure
-     * test case.) This function will call all the others that will set up,
-     * execute, and report their test findings.
-     *
-     * Set up the success case first. This function will become the template
-     * for the other tests. This should eventually be renamed
-     *
-     * The success case isn't interesting, how can this fail?
-     * - Do not give the client context a CA certificate. The connect should
-     *   fail. Do not need server for this?
-     * - Using NULL for the ssl object on server. Do not need client for this.
-     * - Using NULL for the ssl object on client. Do not need server for this.
-     * - Good ssl objects for client and server. Client write() without server
-     *   read().
-     * - Good ssl objects for client and server. Server write() without client
-     *   read().
-     * - Forgetting the password callback?
-    */
-    tcp_ready ready;
-    func_args client_args;
-    func_args server_args;
-    THREAD_TYPE serverThread;
-
-#ifdef WOLFSSL_TIRTOS
-    fdOpenSession(Task_self());
-#endif
-
-    StartTCP();
-    InitTcpReady(&ready);
-    
-    server_args.signal = &ready;
-    client_args.signal = &ready;
-    
-    start_thread(test_server_nofail, &server_args, &serverThread);
-    wait_tcp_ready(&server_args);
-    test_client_nofail(&client_args);
-    join_thread(serverThread);
-
-    AssertTrue(client_args.return_code);
-    AssertTrue(server_args.return_code);
-
-    FreeTcpReady(&ready);
-
-#ifdef WOLFSSL_TIRTOS
-    fdOpenSession(Task_self());
-#endif
-
-#endif
-}
-
-/*----------------------------------------------------------------------------*
- | TLS extensions tests
- *----------------------------------------------------------------------------*/
-
-#ifdef HAVE_SNI
-static void use_SNI_at_ctx(WOLFSSL_CTX* ctx)
-{
-    byte type = WOLFSSL_SNI_HOST_NAME;
-    char name[] = "www.yassl.com";
-
-    AssertIntEQ(SSL_SUCCESS,
-                    wolfSSL_CTX_UseSNI(ctx, type, (void *) name, XSTRLEN(name)));
-}
-
-static void use_SNI_at_ssl(WOLFSSL* ssl)
-{
-    byte type = WOLFSSL_SNI_HOST_NAME;
-    char name[] = "www.yassl.com";
-
-    AssertIntEQ(SSL_SUCCESS,
-                        wolfSSL_UseSNI(ssl, type, (void *) name, XSTRLEN(name)));
-}
-
-static void different_SNI_at_ssl(WOLFSSL* ssl)
-{
-    byte type = WOLFSSL_SNI_HOST_NAME;
-    char name[] = "ww2.yassl.com";
-
-    AssertIntEQ(SSL_SUCCESS,
-                        wolfSSL_UseSNI(ssl, type, (void *) name, XSTRLEN(name)));
-}
-
-static void use_SNI_WITH_CONTINUE_at_ssl(WOLFSSL* ssl)
-{
-    byte type = WOLFSSL_SNI_HOST_NAME;
-
-    use_SNI_at_ssl(ssl);
-
-    wolfSSL_SNI_SetOptions(ssl, type, WOLFSSL_SNI_CONTINUE_ON_MISMATCH);
-}
-
-static void use_SNI_WITH_FAKE_ANSWER_at_ssl(WOLFSSL* ssl)
-{
-    byte type = WOLFSSL_SNI_HOST_NAME;
-
-    use_SNI_at_ssl(ssl);
-
-    wolfSSL_SNI_SetOptions(ssl, type, WOLFSSL_SNI_ANSWER_ON_MISMATCH);
-}
-
-static void verify_SNI_abort_on_client(WOLFSSL* ssl)
-{
-    AssertIntEQ(FATAL_ERROR, wolfSSL_get_error(ssl, 0));
-}
-
-static void verify_SNI_abort_on_server(WOLFSSL* ssl)
-{
-    AssertIntEQ(UNKNOWN_SNI_HOST_NAME_E, wolfSSL_get_error(ssl, 0));
-}
-
-static void verify_SNI_no_matching(WOLFSSL* ssl)
-{
-    byte  type    = WOLFSSL_SNI_HOST_NAME;
-    char* request = (char*) &type; /* to be overwriten */
-
-    AssertIntEQ(WOLFSSL_SNI_NO_MATCH, wolfSSL_SNI_Status(ssl, type));
-
-    AssertNotNull(request);
-    AssertIntEQ(0, wolfSSL_SNI_GetRequest(ssl, type, (void**) &request));
-    AssertNull(request);
-}
-
-static void verify_SNI_real_matching(WOLFSSL* ssl)
-{
-    byte   type    = WOLFSSL_SNI_HOST_NAME;
-    char*  request = NULL;
-    char   name[]  = "www.yassl.com";
-    word16 length  = XSTRLEN(name);
-
-    AssertIntEQ(WOLFSSL_SNI_REAL_MATCH, wolfSSL_SNI_Status(ssl, type));
-
-    AssertIntEQ(length, wolfSSL_SNI_GetRequest(ssl, type, (void**) &request));
-    AssertNotNull(request);
-    AssertStrEQ(name, request);
-}
-
-static void verify_SNI_fake_matching(WOLFSSL* ssl)
-{
-    byte   type    = WOLFSSL_SNI_HOST_NAME;
-    char*  request = NULL;
-    char   name[]  = "ww2.yassl.com";
-    word16 length  = XSTRLEN(name);
-
-    AssertIntEQ(WOLFSSL_SNI_FAKE_MATCH, wolfSSL_SNI_Status(ssl, type));
-
-    AssertIntEQ(length, wolfSSL_SNI_GetRequest(ssl, type, (void**) &request));
-    AssertNotNull(request);
-    AssertStrEQ(name, request);
-}
-
-static void test_wolfSSL_SNI_GetFromBuffer(void)
-{
-    byte buffer[] = { /* www.paypal.com */
-        0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0x00, 0x60, 0x03, 0x03, 0x5c,
-        0xc4, 0xb3, 0x8c, 0x87, 0xef, 0xa4, 0x09, 0xe0, 0x02, 0xab, 0x86, 0xca,
-        0x76, 0xf0, 0x9e, 0x01, 0x65, 0xf6, 0xa6, 0x06, 0x13, 0x1d, 0x0f, 0xa5,
-        0x79, 0xb0, 0xd4, 0x77, 0x22, 0xeb, 0x1a, 0x00, 0x00, 0x16, 0x00, 0x6b,
-        0x00, 0x67, 0x00, 0x39, 0x00, 0x33, 0x00, 0x3d, 0x00, 0x3c, 0x00, 0x35,
-        0x00, 0x2f, 0x00, 0x05, 0x00, 0x04, 0x00, 0x0a, 0x01, 0x00, 0x00, 0x21,
-        0x00, 0x00, 0x00, 0x13, 0x00, 0x11, 0x00, 0x00, 0x0e, 0x77, 0x77, 0x77,
-        0x2e, 0x70, 0x61, 0x79, 0x70, 0x61, 0x6c, 0x2e, 0x63, 0x6f, 0x6d, 0x00,
-        0x0d, 0x00, 0x06, 0x00, 0x04, 0x04, 0x01, 0x02, 0x01
-    };
-
-    byte buffer2[] = { /* api.textmate.org */
-        0x16, 0x03, 0x01, 0x00, 0xc6, 0x01, 0x00, 0x00, 0xc2, 0x03, 0x03, 0x52,
-        0x8b, 0x7b, 0xca, 0x69, 0xec, 0x97, 0xd5, 0x08, 0x03, 0x50, 0xfe, 0x3b,
-        0x99, 0xc3, 0x20, 0xce, 0xa5, 0xf6, 0x99, 0xa5, 0x71, 0xf9, 0x57, 0x7f,
-        0x04, 0x38, 0xf6, 0x11, 0x0b, 0xb8, 0xd3, 0x00, 0x00, 0x5e, 0x00, 0xff,
-        0xc0, 0x24, 0xc0, 0x23, 0xc0, 0x0a, 0xc0, 0x09, 0xc0, 0x07, 0xc0, 0x08,
-        0xc0, 0x28, 0xc0, 0x27, 0xc0, 0x14, 0xc0, 0x13, 0xc0, 0x11, 0xc0, 0x12,
-        0xc0, 0x26, 0xc0, 0x25, 0xc0, 0x2a, 0xc0, 0x29, 0xc0, 0x05, 0xc0, 0x04,
-        0xc0, 0x02, 0xc0, 0x03, 0xc0, 0x0f, 0xc0, 0x0e, 0xc0, 0x0c, 0xc0, 0x0d,
-        0x00, 0x3d, 0x00, 0x3c, 0x00, 0x2f, 0x00, 0x05, 0x00, 0x04, 0x00, 0x35,
-        0x00, 0x0a, 0x00, 0x67, 0x00, 0x6b, 0x00, 0x33, 0x00, 0x39, 0x00, 0x16,
-        0x00, 0xaf, 0x00, 0xae, 0x00, 0x8d, 0x00, 0x8c, 0x00, 0x8a, 0x00, 0x8b,
-        0x00, 0xb1, 0x00, 0xb0, 0x00, 0x2c, 0x00, 0x3b, 0x01, 0x00, 0x00, 0x3b,
-        0x00, 0x00, 0x00, 0x15, 0x00, 0x13, 0x00, 0x00, 0x10, 0x61, 0x70, 0x69,
-        0x2e, 0x74, 0x65, 0x78, 0x74, 0x6d, 0x61, 0x74, 0x65, 0x2e, 0x6f, 0x72,
-        0x67, 0x00, 0x0a, 0x00, 0x08, 0x00, 0x06, 0x00, 0x17, 0x00, 0x18, 0x00,
-        0x19, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, 0x00, 0x0d, 0x00, 0x0c, 0x00,
-        0x0a, 0x05, 0x01, 0x04, 0x01, 0x02, 0x01, 0x04, 0x03, 0x02, 0x03
-    };
-
-    byte buffer3[] = { /* no sni extension */
-        0x16, 0x03, 0x03, 0x00, 0x4d, 0x01, 0x00, 0x00, 0x49, 0x03, 0x03, 0xea,
-        0xa1, 0x9f, 0x60, 0xdd, 0x52, 0x12, 0x13, 0xbd, 0x84, 0x34, 0xd5, 0x1c,
-        0x38, 0x25, 0xa8, 0x97, 0xd2, 0xd5, 0xc6, 0x45, 0xaf, 0x1b, 0x08, 0xe4,
-        0x1e, 0xbb, 0xdf, 0x9d, 0x39, 0xf0, 0x65, 0x00, 0x00, 0x16, 0x00, 0x6b,
-        0x00, 0x67, 0x00, 0x39, 0x00, 0x33, 0x00, 0x3d, 0x00, 0x3c, 0x00, 0x35,
-        0x00, 0x2f, 0x00, 0x05, 0x00, 0x04, 0x00, 0x0a, 0x01, 0x00, 0x00, 0x0a,
-        0x00, 0x0d, 0x00, 0x06, 0x00, 0x04, 0x04, 0x01, 0x02, 0x01
-    };
-
-    byte buffer4[] = { /* last extension has zero size */
-        0x16, 0x03, 0x01, 0x00, 0xba, 0x01, 0x00, 0x00,
-        0xb6, 0x03, 0x03, 0x83, 0xa3, 0xe6, 0xdc, 0x16, 0xa1, 0x43, 0xe9, 0x45,
-        0x15, 0xbd, 0x64, 0xa9, 0xb6, 0x07, 0xb4, 0x50, 0xc6, 0xdd, 0xff, 0xc2,
-        0xd3, 0x0d, 0x4f, 0x36, 0xb4, 0x41, 0x51, 0x61, 0xc1, 0xa5, 0x9e, 0x00,
-        0x00, 0x28, 0xcc, 0x14, 0xcc, 0x13, 0xc0, 0x2b, 0xc0, 0x2f, 0x00, 0x9e,
-        0xc0, 0x0a, 0xc0, 0x09, 0xc0, 0x13, 0xc0, 0x14, 0xc0, 0x07, 0xc0, 0x11,
-        0x00, 0x33, 0x00, 0x32, 0x00, 0x39, 0x00, 0x9c, 0x00, 0x2f, 0x00, 0x35,
-        0x00, 0x0a, 0x00, 0x05, 0x00, 0x04, 0x01, 0x00, 0x00, 0x65, 0xff, 0x01,
-        0x00, 0x01, 0x00, 0x00, 0x0a, 0x00, 0x08, 0x00, 0x06, 0x00, 0x17, 0x00,
-        0x18, 0x00, 0x19, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, 0x00, 0x23, 0x00,
-        0x00, 0x33, 0x74, 0x00, 0x00, 0x00, 0x10, 0x00, 0x1b, 0x00, 0x19, 0x06,
-        0x73, 0x70, 0x64, 0x79, 0x2f, 0x33, 0x08, 0x73, 0x70, 0x64, 0x79, 0x2f,
-        0x33, 0x2e, 0x31, 0x08, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x31,
-        0x75, 0x50, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00,
-        0x00, 0x00, 0x0d, 0x00, 0x12, 0x00, 0x10, 0x04, 0x01, 0x05, 0x01, 0x02,
-        0x01, 0x04, 0x03, 0x05, 0x03, 0x02, 0x03, 0x04, 0x02, 0x02, 0x02, 0x00,
-        0x12, 0x00, 0x00
-    };
-
-    byte result[32] = {0};
-    word32 length   = 32;
-
-    AssertIntEQ(0, wolfSSL_SNI_GetFromBuffer(buffer4, sizeof(buffer4),
-                                                           0, result, &length));
-
-    AssertIntEQ(0, wolfSSL_SNI_GetFromBuffer(buffer3, sizeof(buffer3),
-                                                           0, result, &length));
-
-    AssertIntEQ(0, wolfSSL_SNI_GetFromBuffer(buffer2, sizeof(buffer2),
-                                                           1, result, &length));
-
-    AssertIntEQ(BUFFER_ERROR, wolfSSL_SNI_GetFromBuffer(buffer, sizeof(buffer),
-                                                           0, result, &length));
-    buffer[0] = 0x16;
-
-    AssertIntEQ(BUFFER_ERROR, wolfSSL_SNI_GetFromBuffer(buffer, sizeof(buffer),
-                                                           0, result, &length));
-    buffer[1] = 0x03;
-
-    AssertIntEQ(SNI_UNSUPPORTED, wolfSSL_SNI_GetFromBuffer(buffer, 
-                                           sizeof(buffer), 0, result, &length));
-    buffer[2] = 0x03;
-
-    AssertIntEQ(INCOMPLETE_DATA, wolfSSL_SNI_GetFromBuffer(buffer,
-                                           sizeof(buffer), 0, result, &length));
-    buffer[4] = 0x64;
-
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_SNI_GetFromBuffer(buffer, sizeof(buffer),
-                                                           0, result, &length));
-    result[length] = 0;
-    AssertStrEQ("www.paypal.com", (const char*) result);
-
-    length = 32;
-
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_SNI_GetFromBuffer(buffer2, sizeof(buffer2),
-                                                           0, result, &length));
-    result[length] = 0;
-    AssertStrEQ("api.textmate.org", (const char*) result);
-}
-
-static void test_wolfSSL_client_server(callback_functions* client_callbacks,
-                                      callback_functions* server_callbacks)
-{
-#ifdef HAVE_IO_TESTS_DEPENDENCIES
-    tcp_ready ready;
-    func_args client_args;
-    func_args server_args;
-    THREAD_TYPE serverThread;
-
-    StartTCP();
-
-    client_args.callbacks = client_callbacks;
-    server_args.callbacks = server_callbacks;
-
-#ifdef WOLFSSL_TIRTOS
-    fdOpenSession(Task_self());
-#endif
-
-    /* RUN Server side */
-    InitTcpReady(&ready);
-    server_args.signal = &ready;
-    client_args.signal = &ready;
-    start_thread(run_wolfssl_server, &server_args, &serverThread);
-    wait_tcp_ready(&server_args);
-
-    /* RUN Client side */
-    run_wolfssl_client(&client_args);
-    join_thread(serverThread);
-
-    FreeTcpReady(&ready);
-#ifdef WOLFSSL_TIRTOS
-    fdCloseSession(Task_self());
-#endif
-    
-#else
-    (void)client_callbacks;
-    (void)server_callbacks;
-#endif
-}
-
-#endif /* HAVE_SNI */
-
-static void test_wolfSSL_UseSNI(void)
-{
-#ifdef HAVE_SNI
-    callback_functions client_callbacks = {wolfSSLv23_client_method, 0, 0, 0};
-    callback_functions server_callbacks = {wolfSSLv23_server_method, 0, 0, 0};
-
-    WOLFSSL_CTX *ctx = wolfSSL_CTX_new(wolfSSLv23_client_method());
-    WOLFSSL     *ssl = wolfSSL_new(ctx);
-
-    AssertNotNull(ctx);
-    AssertNotNull(ssl);
-
-    /* error cases */
-    AssertIntNE(SSL_SUCCESS,
-                    wolfSSL_CTX_UseSNI(NULL, 0, (void *) "ctx", XSTRLEN("ctx")));
-    AssertIntNE(SSL_SUCCESS,
-                    wolfSSL_UseSNI(    NULL, 0, (void *) "ssl", XSTRLEN("ssl")));
-    AssertIntNE(SSL_SUCCESS,
-                    wolfSSL_CTX_UseSNI(ctx, -1, (void *) "ctx", XSTRLEN("ctx")));
-    AssertIntNE(SSL_SUCCESS,
-                    wolfSSL_UseSNI(    ssl, -1, (void *) "ssl", XSTRLEN("ssl")));
-    AssertIntNE(SSL_SUCCESS,
-                    wolfSSL_CTX_UseSNI(ctx,  0, (void *) NULL,  XSTRLEN("ctx")));
-    AssertIntNE(SSL_SUCCESS,
-                    wolfSSL_UseSNI(    ssl,  0, (void *) NULL,  XSTRLEN("ssl")));
-
-    /* success case */
-    AssertIntEQ(SSL_SUCCESS,
-                    wolfSSL_CTX_UseSNI(ctx,  0, (void *) "ctx", XSTRLEN("ctx")));
-    AssertIntEQ(SSL_SUCCESS,
-                    wolfSSL_UseSNI(    ssl,  0, (void *) "ssl", XSTRLEN("ssl")));
-
-    wolfSSL_free(ssl);
-    wolfSSL_CTX_free(ctx);
-
-    /* Testing success case at ctx */
-    client_callbacks.ctx_ready = server_callbacks.ctx_ready = use_SNI_at_ctx;
-    server_callbacks.on_result = verify_SNI_real_matching;
-
-    test_wolfSSL_client_server(&client_callbacks, &server_callbacks);
-
-    /* Testing success case at ssl */
-    client_callbacks.ctx_ready = server_callbacks.ctx_ready = NULL;
-    client_callbacks.ssl_ready = server_callbacks.ssl_ready = use_SNI_at_ssl;
-
-    test_wolfSSL_client_server(&client_callbacks, &server_callbacks);
-
-    /* Testing default mismatch behaviour */
-    client_callbacks.ssl_ready = different_SNI_at_ssl;
-    client_callbacks.on_result = verify_SNI_abort_on_client;
-    server_callbacks.on_result = verify_SNI_abort_on_server;
-
-    test_wolfSSL_client_server(&client_callbacks, &server_callbacks);
-    client_callbacks.on_result = NULL;
-
-    /* Testing continue on mismatch */
-    client_callbacks.ssl_ready = different_SNI_at_ssl;
-    server_callbacks.ssl_ready = use_SNI_WITH_CONTINUE_at_ssl;
-    server_callbacks.on_result = verify_SNI_no_matching;
-
-    test_wolfSSL_client_server(&client_callbacks, &server_callbacks);
-
-    /* Testing fake answer on mismatch */
-    server_callbacks.ssl_ready = use_SNI_WITH_FAKE_ANSWER_at_ssl;
-    server_callbacks.on_result = verify_SNI_fake_matching;
-
-    test_wolfSSL_client_server(&client_callbacks, &server_callbacks);
-
-    test_wolfSSL_SNI_GetFromBuffer();
-#endif
-}
-
-static void test_wolfSSL_UseMaxFragment(void)
-{
-#ifdef HAVE_MAX_FRAGMENT
-    WOLFSSL_CTX *ctx = wolfSSL_CTX_new(wolfSSLv23_client_method());
-    WOLFSSL     *ssl = wolfSSL_new(ctx);
-
-    AssertNotNull(ctx);
-    AssertNotNull(ssl);
-
-    /* error cases */
-    AssertIntNE(SSL_SUCCESS, wolfSSL_CTX_UseMaxFragment(NULL, WOLFSSL_MFL_2_9));
-    AssertIntNE(SSL_SUCCESS, wolfSSL_UseMaxFragment(    NULL, WOLFSSL_MFL_2_9));
-    AssertIntNE(SSL_SUCCESS, wolfSSL_CTX_UseMaxFragment(ctx, 0));
-    AssertIntNE(SSL_SUCCESS, wolfSSL_CTX_UseMaxFragment(ctx, 6));
-    AssertIntNE(SSL_SUCCESS, wolfSSL_UseMaxFragment(ssl, 0));
-    AssertIntNE(SSL_SUCCESS, wolfSSL_UseMaxFragment(ssl, 6));
-
-    /* success case */
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_CTX_UseMaxFragment(ctx,  WOLFSSL_MFL_2_9));
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_CTX_UseMaxFragment(ctx,  WOLFSSL_MFL_2_10));
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_CTX_UseMaxFragment(ctx,  WOLFSSL_MFL_2_11));
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_CTX_UseMaxFragment(ctx,  WOLFSSL_MFL_2_12));
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_CTX_UseMaxFragment(ctx,  WOLFSSL_MFL_2_13));
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_UseMaxFragment(    ssl,  WOLFSSL_MFL_2_9));
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_UseMaxFragment(    ssl,  WOLFSSL_MFL_2_10));
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_UseMaxFragment(    ssl,  WOLFSSL_MFL_2_11));
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_UseMaxFragment(    ssl,  WOLFSSL_MFL_2_12));
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_UseMaxFragment(    ssl,  WOLFSSL_MFL_2_13));
-
-    wolfSSL_free(ssl);
-    wolfSSL_CTX_free(ctx);
-#endif
-}
-
-static void test_wolfSSL_UseTruncatedHMAC(void)
-{
-#ifdef HAVE_TRUNCATED_HMAC
-    WOLFSSL_CTX *ctx = wolfSSL_CTX_new(wolfSSLv23_client_method());
-    WOLFSSL     *ssl = wolfSSL_new(ctx);
-
-    AssertNotNull(ctx);
-    AssertNotNull(ssl);
-
-    /* error cases */
-    AssertIntNE(SSL_SUCCESS, wolfSSL_CTX_UseTruncatedHMAC(NULL));
-    AssertIntNE(SSL_SUCCESS, wolfSSL_UseTruncatedHMAC(NULL));
-
-    /* success case */
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_CTX_UseTruncatedHMAC(ctx));
-    AssertIntEQ(SSL_SUCCESS, wolfSSL_UseTruncatedHMAC(ssl));
-
-    wolfSSL_free(ssl);
-    wolfSSL_CTX_free(ctx);
-#endif
-}
-
-static void test_wolfSSL_UseSupportedCurve(void)
-{
-#ifdef HAVE_SUPPORTED_CURVES
-    WOLFSSL_CTX *ctx = wolfSSL_CTX_new(wolfSSLv23_client_method());
-    WOLFSSL     *ssl = wolfSSL_new(ctx);
-
-    AssertNotNull(ctx);
-    AssertNotNull(ssl);
-
-#ifndef NO_WOLFSSL_CLIENT
-    /* error cases */
-    AssertIntNE(SSL_SUCCESS,
-                      wolfSSL_CTX_UseSupportedCurve(NULL, WOLFSSL_ECC_SECP256R1));
-    AssertIntNE(SSL_SUCCESS, wolfSSL_CTX_UseSupportedCurve(ctx,  0));
-
-    AssertIntNE(SSL_SUCCESS,
-                          wolfSSL_UseSupportedCurve(NULL, WOLFSSL_ECC_SECP256R1));
-    AssertIntNE(SSL_SUCCESS, wolfSSL_UseSupportedCurve(ssl,  0));
-
-    /* success case */
-    AssertIntEQ(SSL_SUCCESS,
-                       wolfSSL_CTX_UseSupportedCurve(ctx, WOLFSSL_ECC_SECP256R1));
-    AssertIntEQ(SSL_SUCCESS,
-                           wolfSSL_UseSupportedCurve(ssl, WOLFSSL_ECC_SECP256R1));
-#endif
-
-    wolfSSL_free(ssl);
-    wolfSSL_CTX_free(ctx);
-#endif
-}
-
-/*----------------------------------------------------------------------------*
- | Main
- *----------------------------------------------------------------------------*/
-
-void ApiTest(void)
-{
-    printf(" Begin API Tests\n");
-    test_wolfSSL_Init();
-
-    test_wolfSSL_Method_Allocators();
-    test_wolfSSL_CTX_new(wolfSSLv23_server_method());
-    test_wolfSSL_CTX_use_certificate_file();
-    test_wolfSSL_CTX_use_PrivateKey_file();
-    test_wolfSSL_CTX_load_verify_locations();
-    test_server_wolfSSL_new();
-    test_client_wolfSSL_new();
-    test_wolfSSL_read_write();
-
-    /* TLS extensions tests */
-    test_wolfSSL_UseSNI();
-    test_wolfSSL_UseMaxFragment();
-    test_wolfSSL_UseTruncatedHMAC();
-    test_wolfSSL_UseSupportedCurve();
-
-    test_wolfSSL_Cleanup();
-    printf(" End API Tests\n");
-}
diff --git a/FreeRTOS-Plus/Source/WolfSSL/tests/hash.c b/FreeRTOS-Plus/Source/WolfSSL/tests/hash.c
deleted file mode 100755
index e28a71a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/tests/hash.c
+++ /dev/null
@@ -1,855 +0,0 @@
-/* hash.c has unit tests
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-typedef struct testVector {
-    const char*  input;
-    const char*  output; 
-    size_t inLen;
-    size_t outLen;
-} testVector;
-
-int  md4_test(void);
-int  md5_test(void);
-int  sha_test(void);
-int  sha256_test(void);
-int  sha512_test(void);
-int  sha384_test(void);
-int  ripemd_test(void);
-int  hmac_md5_test(void);
-int  hmac_sha_test(void);
-int  hmac_sha256_test(void);
-int  hmac_sha384_test(void);
-
-int HashTest(void)
-{
-    int ret = 0;
-
-    printf(" Begin HASH Tests\n");
-
-#ifndef NO_MD4
-    if ( (ret = md4_test()) ) {
-        printf( "   MD4      test failed!\n");
-        return ret; 
-    } else
-        printf( "   MD4      test passed!\n");
-#endif
-
-#ifndef NO_MD5
-    if ( (ret = md5_test()) ) {
-        printf( "   MD5      test failed!\n");
-        return ret; 
-    } else
-        printf( "   MD5      test passed!\n");
-#endif
-    
-#ifndef NO_SHA
-    if ( (ret = sha_test()) ) {
-        printf( "   SHA      test failed!\n");
-        return ret; 
-    } else
-        printf( "   SHA      test passed!\n");
-#endif
-    
-#ifndef NO_SHA256
-    if ( (ret = sha256_test()) ) {
-        printf( "   SHA-256  test failed!\n");
-        return ret; 
-    } else
-        printf( "   SHA-256  test passed!\n");
-#endif
-
-#ifdef WOLFSSL_SHA512
-    if ( (ret = sha512_test()) ) {
-        printf( "   SHA-512  test failed!\n");
-        return ret; 
-    } else
-        printf( "   SHA-512  test passed!\n");
-#endif
-
-#ifdef WOLFSSL_SHA384
-    if ( (ret = sha384_test()) ) {
-        printf( "   SHA-384  test failed!\n");
-        return ret; 
-    } else
-        printf( "   SHA-384  test passed!\n");
-#endif
-
-#ifdef WOLFSSL_RIPEMD
-    if ( (ret = ripemd_test()) ) {
-        printf( "   RIPEMD   test failed!\n");
-        return ret; 
-    } else
-        printf( "   RIPEMD   test passed!\n");
-#endif
-
-#ifndef NO_HMAC
-    #ifndef NO_MD5
-        if ( (ret = hmac_md5_test()) ) {
-            printf( "   HMAC-MD5 test failed!\n");
-            return ret; 
-        } else
-            printf( "   HMAC-MD5 test passed!\n");
-    #endif
-
-    #ifndef NO_SHA
-    if ( (ret = hmac_sha_test()) ) 
-        printf( "   HMAC-SHA test failed!\n");
-    else
-        printf( "   HMAC-SHA test passed!\n");
-    #endif
-
-    #ifndef NO_SHA256
-        if ( (ret = hmac_sha256_test()) ) 
-            printf( "   HMAC-SHA256 test failed!\n");
-        else
-            printf( "   HMAC-SHA256 test passed!\n");
-    #endif
-
-    #ifdef WOLFSSL_SHA384
-        if ( (ret = hmac_sha384_test()) ) 
-            printf( "   HMAC-SHA384 test failed!\n");
-        else
-            printf( "   HMAC-SHA384 test passed!\n");
-    #endif
-#endif
-
-    printf(" End HASH Tests\n");
-    
-    return 0;
-}
-
-#ifndef NO_MD4
-
-int md4_test(void)
-{
-    Md4  md4;
-    byte hash[MD4_DIGEST_SIZE];
-
-    testVector a, b, c, d, e, f, g;
-    testVector test_md4[7];
-    int times = sizeof(test_md4) / sizeof(testVector), i;
-
-    a.input  = "";
-    a.output = "\x31\xd6\xcf\xe0\xd1\x6a\xe9\x31\xb7\x3c\x59\xd7\xe0\xc0\x89" 
-               "\xc0";
-    a.inLen  = strlen(a.input);
-    a.outLen = strlen(a.output);
-
-    b.input  = "a";
-    b.output = "\xbd\xe5\x2c\xb3\x1d\xe3\x3e\x46\x24\x5e\x05\xfb\xdb\xd6\xfb" 
-               "\x24";
-    b.inLen  = strlen(b.input);
-    b.outLen = strlen(b.output);
-
-    c.input  = "abc";
-    c.output = "\xa4\x48\x01\x7a\xaf\x21\xd8\x52\x5f\xc1\x0a\xe8\x7a\xa6\x72" 
-               "\x9d";
-    c.inLen  = strlen(c.input);
-    c.outLen = strlen(c.output);
-
-    d.input  = "message digest";
-    d.output = "\xd9\x13\x0a\x81\x64\x54\x9f\xe8\x18\x87\x48\x06\xe1\xc7\x01" 
-               "\x4b";
-    d.inLen  = strlen(d.input);
-    d.outLen = strlen(d.output);
-
-    e.input  = "abcdefghijklmnopqrstuvwxyz";
-    e.output = "\xd7\x9e\x1c\x30\x8a\xa5\xbb\xcd\xee\xa8\xed\x63\xdf\x41\x2d" 
-               "\xa9";
-    e.inLen  = strlen(e.input);
-    e.outLen = strlen(e.output);
-
-    f.input  = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345"
-               "6789";
-    f.output = "\x04\x3f\x85\x82\xf2\x41\xdb\x35\x1c\xe6\x27\xe1\x53\xe7\xf0" 
-               "\xe4";
-    f.inLen  = strlen(f.input);
-    f.outLen = strlen(f.output);
-
-    g.input  = "1234567890123456789012345678901234567890123456789012345678"
-               "9012345678901234567890";
-    g.output = "\xe3\x3b\x4d\xdc\x9c\x38\xf2\x19\x9c\x3e\x7b\x16\x4f\xcc\x05" 
-               "\x36";
-    g.inLen  = strlen(g.input);
-    g.outLen = strlen(g.output);
-
-    test_md4[0] = a;
-    test_md4[1] = b;
-    test_md4[2] = c;
-    test_md4[3] = d;
-    test_md4[4] = e;
-    test_md4[5] = f;
-    test_md4[6] = g;
-
-    wc_InitMd4(&md4);
-
-    for (i = 0; i < times; ++i) {
-        wc_Md4Update(&md4, (byte*)test_md4[i].input, (word32)test_md4[i].inLen);
-        wc_Md4Final(&md4, hash);
-
-        if (memcmp(hash, test_md4[i].output, MD4_DIGEST_SIZE) != 0)
-            return -205 - i;
-    }
-
-    return 0;
-}
-
-#endif /* NO_MD4 */
-
-#ifndef NO_MD5
-
-int md5_test(void)
-{
-    Md5  md5;
-    byte hash[MD5_DIGEST_SIZE];
-
-    testVector a, b, c, d, e;
-    testVector test_md5[5];
-    int times = sizeof(test_md5) / sizeof(testVector), i;
-
-    a.input  = "abc";
-    a.output = "\x90\x01\x50\x98\x3c\xd2\x4f\xb0\xd6\x96\x3f\x7d\x28\xe1\x7f"
-               "\x72";
-    a.inLen  = strlen(a.input);
-    a.outLen = strlen(a.output);
-
-    b.input  = "message digest";
-    b.output = "\xf9\x6b\x69\x7d\x7c\xb7\x93\x8d\x52\x5a\x2f\x31\xaa\xf1\x61"
-               "\xd0";
-    b.inLen  = strlen(b.input);
-    b.outLen = strlen(b.output);
-
-    c.input  = "abcdefghijklmnopqrstuvwxyz";
-    c.output = "\xc3\xfc\xd3\xd7\x61\x92\xe4\x00\x7d\xfb\x49\x6c\xca\x67\xe1"
-               "\x3b";
-    c.inLen  = strlen(c.input);
-    c.outLen = strlen(c.output);
-
-    d.input  = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345"
-               "6789";
-    d.output = "\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d"
-               "\x9f";
-    d.inLen  = strlen(d.input);
-    d.outLen = strlen(d.output);
-
-    e.input  = "1234567890123456789012345678901234567890123456789012345678"
-               "9012345678901234567890";
-    e.output = "\x57\xed\xf4\xa2\x2b\xe3\xc9\x55\xac\x49\xda\x2e\x21\x07\xb6"
-               "\x7a";
-    e.inLen  = strlen(e.input);
-    e.outLen = strlen(e.output);
-
-    test_md5[0] = a;
-    test_md5[1] = b;
-    test_md5[2] = c;
-    test_md5[3] = d;
-    test_md5[4] = e;
-
-    wc_InitMd5(&md5);
-
-    for (i = 0; i < times; ++i) {
-        wc_Md5Update(&md5, (byte*)test_md5[i].input, (word32)test_md5[i].inLen);
-        wc_Md5Final(&md5, hash);
-
-        if (memcmp(hash, test_md5[i].output, MD5_DIGEST_SIZE) != 0)
-            return -5 - i;
-    }
-
-    return 0;
-}
-
-#endif /* NO_MD5 */
-
-#ifndef NO_SHA
-int sha_test(void)
-{
-    Sha  sha;
-    byte hash[SHA_DIGEST_SIZE];
-
-    testVector a, b, c, d;
-    testVector test_sha[4];
-    int ret   = 0;
-    int times = sizeof(test_sha) / sizeof(struct testVector), i;
-
-    a.input  = "abc";
-    a.output = "\xA9\x99\x3E\x36\x47\x06\x81\x6A\xBA\x3E\x25\x71\x78\x50\xC2"
-               "\x6C\x9C\xD0\xD8\x9D";
-    a.inLen  = strlen(a.input);
-    a.outLen = strlen(a.output);
-
-    b.input  = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
-    b.output = "\x84\x98\x3E\x44\x1C\x3B\xD2\x6E\xBA\xAE\x4A\xA1\xF9\x51\x29"
-               "\xE5\xE5\x46\x70\xF1";
-    b.inLen  = strlen(b.input);
-    b.outLen = strlen(b.output);
-
-    c.input  = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-               "aaaaaa";
-    c.output = "\x00\x98\xBA\x82\x4B\x5C\x16\x42\x7B\xD7\xA1\x12\x2A\x5A\x44"
-               "\x2A\x25\xEC\x64\x4D";
-    c.inLen  = strlen(c.input);
-    c.outLen = strlen(c.output);
-
-    d.input  = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-               "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-               "aaaaaaaaaa";
-    d.output = "\xAD\x5B\x3F\xDB\xCB\x52\x67\x78\xC2\x83\x9D\x2F\x15\x1E\xA7"
-               "\x53\x99\x5E\x26\xA0";
-    d.inLen  = strlen(d.input);
-    d.outLen = strlen(d.output);
-
-    test_sha[0] = a;
-    test_sha[1] = b;
-    test_sha[2] = c;
-    test_sha[3] = d;
-
-    ret = wc_InitSha(&sha);
-    if (ret != 0)
-        return ret;
-
-    for (i = 0; i < times; ++i) {
-        wc_ShaUpdate(&sha, (byte*)test_sha[i].input, (word32)test_sha[i].inLen);
-        wc_ShaFinal(&sha, hash);
-
-        if (memcmp(hash, test_sha[i].output, SHA_DIGEST_SIZE) != 0)
-            return -10 - i;
-    }
-
-    return 0;
-}
-#endif /* NO_SHA */
-
-#ifndef NO_SHA256
-int sha256_test(void)
-{
-    Sha256 sha;
-    byte   hash[SHA256_DIGEST_SIZE];
-
-    testVector a, b;
-    testVector test_sha[2];
-    int ret;
-    int times = sizeof(test_sha) / sizeof(struct testVector), i;
-
-    a.input  = "abc";
-    a.output = "\xBA\x78\x16\xBF\x8F\x01\xCF\xEA\x41\x41\x40\xDE\x5D\xAE\x22"
-               "\x23\xB0\x03\x61\xA3\x96\x17\x7A\x9C\xB4\x10\xFF\x61\xF2\x00"
-               "\x15\xAD";
-    a.inLen  = strlen(a.input);
-    a.outLen = strlen(a.output);
-
-    b.input  = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
-    b.output = "\x24\x8D\x6A\x61\xD2\x06\x38\xB8\xE5\xC0\x26\x93\x0C\x3E\x60"
-               "\x39\xA3\x3C\xE4\x59\x64\xFF\x21\x67\xF6\xEC\xED\xD4\x19\xDB"
-               "\x06\xC1";
-    b.inLen  = strlen(b.input);
-    b.outLen = strlen(b.output);
-
-    test_sha[0] = a;
-    test_sha[1] = b;
-
-    ret = wc_InitSha256(&sha);
-    if (ret != 0)
-        return ret;
-
-    for (i = 0; i < times; ++i) {
-        ret = wc_Sha256Update(&sha, (byte*)test_sha[i].input,(word32)test_sha[i].inLen);
-        if (ret != 0)
-            return ret;
-
-        ret = wc_Sha256Final(&sha, hash);
-        if (ret != 0)
-            return ret;
-
-        if (memcmp(hash, test_sha[i].output, SHA256_DIGEST_SIZE) != 0)
-            return -10 - i;
-    }
-
-    return 0;
-}
-#endif
-
-#ifdef WOLFSSL_SHA512
-int sha512_test(void)
-{
-    Sha512 sha;
-    byte   hash[SHA512_DIGEST_SIZE];
-
-    testVector a, b;
-    testVector test_sha[2];
-    int times = sizeof(test_sha) / sizeof(struct testVector), i;
-    int ret;
-
-    a.input  = "abc";
-    a.output = "\xdd\xaf\x35\xa1\x93\x61\x7a\xba\xcc\x41\x73\x49\xae\x20\x41"
-               "\x31\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2\x0a\x9e\xee\xe6\x4b\x55"
-               "\xd3\x9a\x21\x92\x99\x2a\x27\x4f\xc1\xa8\x36\xba\x3c\x23\xa3"
-               "\xfe\xeb\xbd\x45\x4d\x44\x23\x64\x3c\xe8\x0e\x2a\x9a\xc9\x4f"
-               "\xa5\x4c\xa4\x9f";
-    a.inLen  = strlen(a.input);
-    a.outLen = strlen(a.output);
-
-    b.input  = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi"
-               "jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
-    b.output = "\x8e\x95\x9b\x75\xda\xe3\x13\xda\x8c\xf4\xf7\x28\x14\xfc\x14"
-               "\x3f\x8f\x77\x79\xc6\xeb\x9f\x7f\xa1\x72\x99\xae\xad\xb6\x88"
-               "\x90\x18\x50\x1d\x28\x9e\x49\x00\xf7\xe4\x33\x1b\x99\xde\xc4"
-               "\xb5\x43\x3a\xc7\xd3\x29\xee\xb6\xdd\x26\x54\x5e\x96\xe5\x5b"
-               "\x87\x4b\xe9\x09"; 
-    b.inLen  = strlen(b.input);
-    b.outLen = strlen(b.output);
-
-    test_sha[0] = a;
-    test_sha[1] = b;
-
-    ret = wc_InitSha512(&sha);
-    if (ret != 0)
-        return ret;
-
-    for (i = 0; i < times; ++i) {
-        ret = wc_Sha512Update(&sha, (byte*)test_sha[i].input,(word32)test_sha[i].inLen);
-        if (ret != 0)
-            return ret;
-
-        ret = wc_Sha512Final(&sha, hash);
-        if (ret != 0)
-            return ret;
-
-        if (memcmp(hash, test_sha[i].output, SHA512_DIGEST_SIZE) != 0)
-            return -10 - i;
-    }
-
-    return 0;
-}
-#endif
-
-#ifdef WOLFSSL_SHA384
-int sha384_test()
-{
-    Sha384 sha;
-    byte   hash[SHA384_DIGEST_SIZE];
-
-    testVector a, b;
-    testVector test_sha[2];
-    int times = sizeof(test_sha) / sizeof(struct testVector), i;
-    int ret;
-
-    a.input  = "abc";
-    a.output = "\xcb\x00\x75\x3f\x45\xa3\x5e\x8b\xb5\xa0\x3d\x69\x9a\xc6\x50"
-               "\x07\x27\x2c\x32\xab\x0e\xde\xd1\x63\x1a\x8b\x60\x5a\x43\xff"
-               "\x5b\xed\x80\x86\x07\x2b\xa1\xe7\xcc\x23\x58\xba\xec\xa1\x34"
-               "\xc8\x25\xa7";
-    a.inLen  = strlen(a.input);
-    a.outLen = strlen(a.output);
-
-    b.input  = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi"
-               "jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
-    b.output = "\x09\x33\x0c\x33\xf7\x11\x47\xe8\x3d\x19\x2f\xc7\x82\xcd\x1b"
-               "\x47\x53\x11\x1b\x17\x3b\x3b\x05\xd2\x2f\xa0\x80\x86\xe3\xb0"
-               "\xf7\x12\xfc\xc7\xc7\x1a\x55\x7e\x2d\xb9\x66\xc3\xe9\xfa\x91"
-               "\x74\x60\x39";
-    b.inLen  = strlen(b.input);
-    b.outLen = strlen(b.output);
-
-    test_sha[0] = a;
-    test_sha[1] = b;
-
-    ret = wc_InitSha384(&sha);
-    if (ret != 0)
-        return ret;
-
-    for (i = 0; i < times; ++i) {
-        ret = wc_Sha384Update(&sha, (byte*)test_sha[i].input,(word32)test_sha[i].inLen);
-        if (ret != 0)
-            return ret;
-
-        ret = wc_Sha384Final(&sha, hash);
-        if (ret != 0)
-            return ret;
-
-        if (memcmp(hash, test_sha[i].output, SHA384_DIGEST_SIZE) != 0)
-            return -10 - i;
-    }
-
-    return 0;
-}
-#endif
-
-#ifdef WOLFSSL_RIPEMD
-int ripemd_test(void)
-{
-    RipeMd  ripemd;
-    byte hash[RIPEMD_DIGEST_SIZE];
-
-    testVector a, b, c, d;
-    testVector test_ripemd[4];
-    int times = sizeof(test_ripemd) / sizeof(struct testVector), i;
-
-    a.input  = "abc";
-    a.output = "\x8e\xb2\x08\xf7\xe0\x5d\x98\x7a\x9b\x04\x4a\x8e\x98\xc6"
-               "\xb0\x87\xf1\x5a\x0b\xfc";
-    a.inLen  = strlen(a.input);
-    a.outLen = strlen(a.output);
-
-    b.input  = "message digest";
-    b.output = "\x5d\x06\x89\xef\x49\xd2\xfa\xe5\x72\xb8\x81\xb1\x23\xa8"
-               "\x5f\xfa\x21\x59\x5f\x36";
-    b.inLen  = strlen(b.input);
-    b.outLen = strlen(b.output);
-
-    c.input  = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; 
-    c.output = "\x12\xa0\x53\x38\x4a\x9c\x0c\x88\xe4\x05\xa0\x6c\x27\xdc"
-               "\xf4\x9a\xda\x62\xeb\x2b";
-    c.inLen  = strlen(c.input);
-    c.outLen = strlen(c.output);
-
-    d.input  = "12345678901234567890123456789012345678901234567890123456"
-               "789012345678901234567890";
-    d.output = "\x9b\x75\x2e\x45\x57\x3d\x4b\x39\xf4\xdb\xd3\x32\x3c\xab"
-               "\x82\xbf\x63\x32\x6b\xfb"; 
-    d.inLen  = strlen(d.input);
-    d.outLen = strlen(d.output);
-
-    test_ripemd[0] = a;
-    test_ripemd[1] = b;
-    test_ripemd[2] = c;
-    test_ripemd[3] = d;
-
-    wc_InitRipeMd(&ripemd);
-
-    for (i = 0; i < times; ++i) {
-        wc_RipeMdUpdate(&ripemd, (byte*)test_ripemd[i].input,
-                     (word32)test_ripemd[i].inLen);
-        wc_RipeMdFinal(&ripemd, hash);
-
-        if (memcmp(hash, test_ripemd[i].output, RIPEMD_DIGEST_SIZE) != 0)
-            return -10 - i;
-    }
-
-    return 0;
-}
-#endif /* WOLFSSL_RIPEMD */
-
-#if !defined(NO_HMAC) && !defined(NO_MD5)
-int hmac_md5_test(void)
-{
-    Hmac hmac;
-    byte hash[MD5_DIGEST_SIZE];
-
-    const char* keys[]=
-    {
-        "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
-        "Jefe",
-        "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
-    };
-
-    testVector a, b, c;
-    testVector test_hmac[3];
-
-    int ret;
-    int times = sizeof(test_hmac) / sizeof(testVector), i;
-
-    a.input  = "Hi There";
-    a.output = "\x92\x94\x72\x7a\x36\x38\xbb\x1c\x13\xf4\x8e\xf8\x15\x8b\xfc"
-               "\x9d";
-    a.inLen  = strlen(a.input);
-    a.outLen = strlen(a.output);
-
-    b.input  = "what do ya want for nothing?";
-    b.output = "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7"
-               "\x38";
-    b.inLen  = strlen(b.input);
-    b.outLen = strlen(b.output);
-
-    c.input  = "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD";
-    c.output = "\x56\xbe\x34\x52\x1d\x14\x4c\x88\xdb\xb8\xc7\x33\xf0\xe8\xb3"
-               "\xf6";
-    c.inLen  = strlen(c.input);
-    c.outLen = strlen(c.output);
-
-    test_hmac[0] = a;
-    test_hmac[1] = b;
-    test_hmac[2] = c;
-
-    for (i = 0; i < times; ++i) {
-#if defined(HAVE_FIPS)
-        if (i == 1)
-            continue; /* fips not allowed */
-#endif
-        ret = wc_HmacSetKey(&hmac, MD5, (byte*)keys[i], (word32)strlen(keys[i]));
-        if (ret != 0)
-            return -4014;
-        ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
-                   (word32)test_hmac[i].inLen);
-        if (ret != 0)
-            return -4015;
-        ret = wc_HmacFinal(&hmac, hash);
-        if (ret != 0)
-            return -4016;
-
-        if (memcmp(hash, test_hmac[i].output, MD5_DIGEST_SIZE) != 0)
-            return -20 - i;
-    }
-
-    return 0;
-}
-#endif
-
-#if !defined(NO_HMAC) && !defined(NO_SHA)
-int hmac_sha_test(void)
-{
-    Hmac hmac;
-    byte hash[SHA_DIGEST_SIZE];
-
-    const char* keys[]=
-    {
-        "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
-                                                                "\x0b\x0b\x0b",
-        "Jefe",
-        "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
-                                                                "\xAA\xAA\xAA"
-    };
-
-    testVector a, b, c;
-    testVector test_hmac[3];
-
-    int ret;
-    int times = sizeof(test_hmac) / sizeof(testVector), i;
-
-    a.input  = "Hi There";
-    a.output = "\xb6\x17\x31\x86\x55\x05\x72\x64\xe2\x8b\xc0\xb6\xfb\x37\x8c"
-               "\x8e\xf1\x46\xbe\x00";
-    a.inLen  = strlen(a.input);
-    a.outLen = strlen(a.output);
-
-    b.input  = "what do ya want for nothing?";
-    b.output = "\xef\xfc\xdf\x6a\xe5\xeb\x2f\xa2\xd2\x74\x16\xd5\xf1\x84\xdf"
-               "\x9c\x25\x9a\x7c\x79";
-    b.inLen  = strlen(b.input);
-    b.outLen = strlen(b.output);
-
-    c.input  = "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD";
-    c.output = "\x12\x5d\x73\x42\xb9\xac\x11\xcd\x91\xa3\x9a\xf4\x8a\xa1\x7b"
-               "\x4f\x63\xf1\x75\xd3";
-    c.inLen  = strlen(c.input);
-    c.outLen = strlen(c.output);
-
-    test_hmac[0] = a;
-    test_hmac[1] = b;
-    test_hmac[2] = c;
-
-    for (i = 0; i < times; ++i) {
-#if defined(HAVE_FIPS)
-        if (i == 1)
-            continue; /* fips not allowed */
-#endif
-        ret = wc_HmacSetKey(&hmac, SHA, (byte*)keys[i], (word32)strlen(keys[i]));
-        if (ret != 0)
-            return -4017;
-        ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
-                   (word32)test_hmac[i].inLen);
-        if (ret != 0)
-            return -4018;
-        ret = wc_HmacFinal(&hmac, hash);
-        if (ret != 0)
-            return -4019;
-
-        if (memcmp(hash, test_hmac[i].output, SHA_DIGEST_SIZE) != 0)
-            return -20 - i;
-    }
-
-    return 0;
-}
-#endif
-
-#if !defined(NO_HMAC) && !defined(NO_SHA256)
-int hmac_sha256_test(void)
-{
-    Hmac hmac;
-    byte hash[SHA256_DIGEST_SIZE];
-
-    const char* keys[]=
-    {
-        "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
-                                                                "\x0b\x0b\x0b",
-        "Jefe",
-        "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
-                                                                "\xAA\xAA\xAA"
-    };
-
-    testVector a, b, c;
-    testVector test_hmac[3];
-
-    int ret;
-    int times = sizeof(test_hmac) / sizeof(testVector), i;
-
-    a.input  = "Hi There";
-    a.output = "\xb0\x34\x4c\x61\xd8\xdb\x38\x53\x5c\xa8\xaf\xce\xaf\x0b\xf1"
-               "\x2b\x88\x1d\xc2\x00\xc9\x83\x3d\xa7\x26\xe9\x37\x6c\x2e\x32"
-               "\xcf\xf7";
-    a.inLen  = strlen(a.input);
-    a.outLen = strlen(a.output);
-
-    b.input  = "what do ya want for nothing?";
-    b.output = "\x5b\xdc\xc1\x46\xbf\x60\x75\x4e\x6a\x04\x24\x26\x08\x95\x75"
-               "\xc7\x5a\x00\x3f\x08\x9d\x27\x39\x83\x9d\xec\x58\xb9\x64\xec"
-               "\x38\x43";
-    b.inLen  = strlen(b.input);
-    b.outLen = strlen(b.output);
-
-    c.input  = "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD";
-    c.output = "\x77\x3e\xa9\x1e\x36\x80\x0e\x46\x85\x4d\xb8\xeb\xd0\x91\x81"
-               "\xa7\x29\x59\x09\x8b\x3e\xf8\xc1\x22\xd9\x63\x55\x14\xce\xd5"
-               "\x65\xfe";
-    c.inLen  = strlen(c.input);
-    c.outLen = strlen(c.output);
-
-    test_hmac[0] = a;
-    test_hmac[1] = b;
-    test_hmac[2] = c;
-
-    for (i = 0; i < times; ++i) {
-#if defined(HAVE_FIPS)
-        if (i == 1)
-            continue; /* fips not allowed */
-#endif
-        ret = wc_HmacSetKey(&hmac,SHA256, (byte*)keys[i], (word32)strlen(keys[i]));
-        if (ret != 0)
-            return -4020;
-        ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
-                   (word32)test_hmac[i].inLen);
-        if (ret != 0)
-            return -4021;
-        ret = wc_HmacFinal(&hmac, hash);
-        if (ret != 0)
-            return -4022;
-
-        if (memcmp(hash, test_hmac[i].output, SHA256_DIGEST_SIZE) != 0)
-            return -20 - i;
-    }
-
-    return 0;
-}
-#endif
-
-
-#if !defined(NO_HMAC) && defined(WOLFSSL_SHA384)
-int hmac_sha384_test(void)
-{
-    Hmac hmac;
-    byte hash[SHA384_DIGEST_SIZE];
-
-    const char* keys[]=
-    {
-        "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
-                                                                "\x0b\x0b\x0b",
-        "Jefe",
-        "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
-                                                                "\xAA\xAA\xAA"
-    };
-
-    testVector a, b, c;
-    testVector test_hmac[3];
-
-    int ret;
-    int times = sizeof(test_hmac) / sizeof(testVector), i;
-
-    a.input  = "Hi There";
-    a.output = "\xaf\xd0\x39\x44\xd8\x48\x95\x62\x6b\x08\x25\xf4\xab\x46\x90"
-               "\x7f\x15\xf9\xda\xdb\xe4\x10\x1e\xc6\x82\xaa\x03\x4c\x7c\xeb"
-               "\xc5\x9c\xfa\xea\x9e\xa9\x07\x6e\xde\x7f\x4a\xf1\x52\xe8\xb2"
-               "\xfa\x9c\xb6";
-    a.inLen  = strlen(a.input);
-    a.outLen = strlen(a.output);
-
-    b.input  = "what do ya want for nothing?";
-    b.output = "\xaf\x45\xd2\xe3\x76\x48\x40\x31\x61\x7f\x78\xd2\xb5\x8a\x6b"
-               "\x1b\x9c\x7e\xf4\x64\xf5\xa0\x1b\x47\xe4\x2e\xc3\x73\x63\x22"
-               "\x44\x5e\x8e\x22\x40\xca\x5e\x69\xe2\xc7\x8b\x32\x39\xec\xfa"
-               "\xb2\x16\x49";
-    b.inLen  = strlen(b.input);
-    b.outLen = strlen(b.output);
-
-    c.input  = "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD";
-    c.output = "\x88\x06\x26\x08\xd3\xe6\xad\x8a\x0a\xa2\xac\xe0\x14\xc8\xa8"
-               "\x6f\x0a\xa6\x35\xd9\x47\xac\x9f\xeb\xe8\x3e\xf4\xe5\x59\x66"
-               "\x14\x4b\x2a\x5a\xb3\x9d\xc1\x38\x14\xb9\x4e\x3a\xb6\xe1\x01"
-               "\xa3\x4f\x27";
-    c.inLen  = strlen(c.input);
-    c.outLen = strlen(c.output);
-
-    test_hmac[0] = a;
-    test_hmac[1] = b;
-    test_hmac[2] = c;
-
-    for (i = 0; i < times; ++i) {
-#if defined(HAVE_FIPS)
-        if (i == 1)
-            continue; /* fips not allowed */
-#endif
-        ret = wc_HmacSetKey(&hmac,SHA384, (byte*)keys[i], (word32)strlen(keys[i]));
-        if (ret != 0)
-            return -4023;
-        ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
-                   (word32)test_hmac[i].inLen);
-        if (ret != 0)
-            return -4024;
-        ret = wc_HmacFinal(&hmac, hash);
-        if (ret != 0)
-            return -4025;
-
-        if (memcmp(hash, test_hmac[i].output, SHA384_DIGEST_SIZE) != 0)
-            return -20 - i;
-    }
-
-    return 0;
-}
-#endif
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/tests/include.am b/FreeRTOS-Plus/Source/WolfSSL/tests/include.am
deleted file mode 100755
index 0064585..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/tests/include.am
+++ /dev/null
@@ -1,23 +0,0 @@
-# vim:ft=automake
-# included from Top Level Makefile.am
-# All paths should be given relative to the root
-
-
-if BUILD_EXAMPLES
-check_PROGRAMS += tests/unit.test
-noinst_PROGRAMS += tests/unit.test
-tests_unit_test_SOURCES = \
-                  tests/unit.c \
-                  tests/api.c \
-                  tests/suites.c \
-                  tests/hash.c \
-                  examples/client/client.c \
-                  examples/server/server.c
-tests_unit_test_CFLAGS       = -DNO_MAIN_DRIVER $(AM_CFLAGS)
-tests_unit_test_LDADD        = src/libwolfssl.la
-tests_unit_test_DEPENDENCIES = src/libwolfssl.la
-endif
-EXTRA_DIST += tests/unit.h
-EXTRA_DIST += tests/test.conf \
-              tests/test-dtls.conf
-DISTCLEANFILES+= tests/.libs/unit.test
diff --git a/FreeRTOS-Plus/Source/WolfSSL/tests/suites.c b/FreeRTOS-Plus/Source/WolfSSL/tests/suites.c
deleted file mode 100755
index d1abc19..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/tests/suites.c
+++ /dev/null
@@ -1,468 +0,0 @@
-/* suites.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-
-#define MAX_ARGS 40
-#define MAX_COMMAND_SZ 240
-#define MAX_SUITE_SZ 80 
-#define NOT_BUILT_IN -123
-#ifdef NO_OLD_TLS
-    #define VERSION_TOO_OLD -124
-#endif
-
-#include "examples/client/client.h"
-#include "examples/server/server.h"
-
-
-static WOLFSSL_CTX* cipherSuiteCtx = NULL;
-static char nonblockFlag[] = "-N";
-static char noVerifyFlag[] = "-d";
-static char portFlag[] = "-p";
-static char flagSep[] = " ";
-static char svrPort[] = "0";
-
-
-#ifdef NO_OLD_TLS
-/* if the protocol version is less than tls 1.2 return 1, else 0 */
-static int IsOldTlsVersion(const char* line)
-{
-    const char* find = "-v ";
-    char* begin = strstr(line, find);
-
-    if (begin) {
-        int version = -1;
-
-        begin += 3;
-
-        version = atoi(begin);
-
-        if (version < 3)
-            return 1;
-    }
-
-    return 0;
-} 
-#endif /* NO_OLD_TLS */
-
-
-/* if the cipher suite on line is valid store in suite and return 1, else 0 */
-static int IsValidCipherSuite(const char* line, char* suite)
-{
-    int  found = 0;
-    int  valid = 0;
-
-    const char* find = "-l ";
-    const char* begin = strstr(line, find);
-    const char* end;
-
-    suite[0] = '\0';
-
-    if (begin) {
-        begin += 3;
-
-        end = strstr(begin, " ");
-
-        if (end) {
-            long len = end - begin;
-            if (len > MAX_SUITE_SZ) {
-                printf("suite too long!\n");
-                return 0;
-            }
-            memcpy(suite, begin, len);
-            suite[len] = '\0';
-        }
-        else
-            strncpy(suite, begin, MAX_SUITE_SZ);
-
-        suite[MAX_SUITE_SZ] = '\0';
-        found = 1;
-    }
-
-    if (found) {
-        if (wolfSSL_CTX_set_cipher_list(cipherSuiteCtx, suite) == SSL_SUCCESS)
-            valid = 1;
-    }
-
-    return valid;
-}
-
-
-static int execute_test_case(int svr_argc, char** svr_argv,
-                              int cli_argc, char** cli_argv,
-                              int addNoVerify, int addNonBlocking)
-{
-#ifdef WOLFSSL_TIRTOS
-    func_args cliArgs = {0};
-    func_args svrArgs = {0};
-    cliArgs.argc = cli_argc;
-    cliArgs.argv = cli_argv;
-    svrArgs.argc = svr_argc;
-    svrArgs.argv = svr_argv;
-#else
-    func_args cliArgs = {cli_argc, cli_argv, 0, NULL, NULL};
-    func_args svrArgs = {svr_argc, svr_argv, 0, NULL, NULL};
-#endif
-
-    tcp_ready   ready;
-    THREAD_TYPE serverThread;
-    char        commandLine[MAX_COMMAND_SZ];
-    char        cipherSuite[MAX_SUITE_SZ+1];
-    int         i;
-    size_t      added = 0;
-    static      int tests = 1;
-
-    commandLine[0] = '\0';
-    for (i = 0; i < svr_argc; i++) {
-        added += strlen(svr_argv[i]) + 2;
-        if (added >= MAX_COMMAND_SZ) {
-            printf("server command line too long\n"); 
-            break;
-        }
-        strcat(commandLine, svr_argv[i]);
-        strcat(commandLine, flagSep);
-    }
-
-    if (IsValidCipherSuite(commandLine, cipherSuite) == 0) {
-        #ifdef DEBUG_SUITE_TESTS
-            printf("cipher suite %s not supported in build\n", cipherSuite);
-        #endif
-        return NOT_BUILT_IN;
-    }
-
-#ifdef NO_OLD_TLS
-    if (IsOldTlsVersion(commandLine) == 1) {
-        #ifdef DEBUG_SUITE_TESTS
-            printf("protocol version on line %s is too old\n", commandLine);
-        #endif
-        return VERSION_TOO_OLD;
-    }
-#endif
-
-    if (addNoVerify) {
-        printf("repeating test with client cert request off\n"); 
-        added += 4;   /* -d plus space plus terminator */
-        if (added >= MAX_COMMAND_SZ || svr_argc >= MAX_ARGS)
-            printf("server command line too long\n");
-        else {
-            svr_argv[svr_argc++] = noVerifyFlag;
-            svrArgs.argc = svr_argc;
-            strcat(commandLine, noVerifyFlag);
-            strcat(commandLine, flagSep);
-        }
-    }
-    if (addNonBlocking) {
-        printf("repeating test with non blocking on\n"); 
-        added += 4;   /* -N plus terminator */
-        if (added >= MAX_COMMAND_SZ || svr_argc >= MAX_ARGS)
-            printf("server command line too long\n");
-        else {
-            svr_argv[svr_argc++] = nonblockFlag;
-            svrArgs.argc = svr_argc;
-            strcat(commandLine, nonblockFlag);
-            strcat(commandLine, flagSep);
-        }
-    }
-    #if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_TIRTOS)
-        /* add port 0 */
-        if (svr_argc + 2 > MAX_ARGS)
-            printf("cannot add the magic port number flag to server\n");
-        else
-        {
-            svr_argv[svr_argc++] = portFlag;
-            svr_argv[svr_argc++] = svrPort;
-            svrArgs.argc = svr_argc;
-        }
-    #endif
-    printf("trying server command line[%d]: %s\n", tests, commandLine);
-
-    commandLine[0] = '\0';
-    added = 0;
-    for (i = 0; i < cli_argc; i++) {
-        added += strlen(cli_argv[i]) + 2;
-        if (added >= MAX_COMMAND_SZ) {
-            printf("client command line too long\n"); 
-            break;
-        }
-        strcat(commandLine, cli_argv[i]);
-        strcat(commandLine, flagSep);
-    }
-    if (addNonBlocking) {
-        added += 4;   /* -N plus space plus terminator  */
-        if (added >= MAX_COMMAND_SZ)
-            printf("client command line too long\n");
-        else  {
-            cli_argv[cli_argc++] = nonblockFlag;
-            strcat(commandLine, nonblockFlag);
-            strcat(commandLine, flagSep);
-            cliArgs.argc = cli_argc;
-        }
-    }
-    printf("trying client command line[%d]: %s\n", tests++, commandLine);
-
-    InitTcpReady(&ready);
-
-#ifdef WOLFSSL_TIRTOS
-    fdOpenSession(Task_self());
-#endif
-
-    /* start server */
-    svrArgs.signal = &ready;
-    start_thread(server_test, &svrArgs, &serverThread);
-    wait_tcp_ready(&svrArgs);
-    #if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_TIRTOS)
-        if (ready.port != 0)
-        {
-            if (cli_argc + 2 > MAX_ARGS)
-                printf("cannot add the magic port number flag to client\n");
-            else {
-                char portNumber[8];
-                snprintf(portNumber, sizeof(portNumber), "%d", ready.port);
-                cli_argv[cli_argc++] = portFlag;
-                cli_argv[cli_argc++] = portNumber;
-                cliArgs.argc = cli_argc;
-            }
-        }
-    #endif
-    /* start client */
-    client_test(&cliArgs);
-
-    /* verify results */ 
-    if (cliArgs.return_code != 0) {
-        printf("client_test failed\n");
-        exit(EXIT_FAILURE);
-    }
-
-    join_thread(serverThread);
-    if (svrArgs.return_code != 0) { 
-        printf("server_test failed\n");
-        exit(EXIT_FAILURE);
-    }
-
-#ifdef WOLFSSL_TIRTOS
-    fdCloseSession(Task_self());
-#endif
-    FreeTcpReady(&ready);
-    
-    return 0;
-}
-
-static void test_harness(void* vargs)
-{
-    func_args* args = (func_args*)vargs;
-    char* script;
-    long  sz, len;
-    int   cliMode = 0;   /* server or client command flag, server first */
-    int   ret;
-    FILE* file;
-    char* svrArgs[MAX_ARGS];
-    int   svrArgsSz;
-    char* cliArgs[MAX_ARGS];
-    int   cliArgsSz;
-    char* cursor;
-    char* comment;
-    const char* fname = "tests/test.conf";
-
-    if (args->argc == 1) {
-        printf("notice: using default file %s\n", fname);
-    }
-    else if(args->argc != 2) {
-        printf("usage: harness [FILE]\n");
-        args->return_code = 1;
-        return;
-    }
-    else {
-        fname = args->argv[1];
-    }
-
-    file = fopen(fname, "r");
-    if (file == NULL) {
-        fprintf(stderr, "unable to open %s\n", fname);
-        args->return_code = 1;
-        return;
-    }
-    fseek(file, 0, SEEK_END);
-    sz = ftell(file);
-    rewind(file);
-    if (sz <= 0) {
-        fprintf(stderr, "%s is empty\n", fname);
-        fclose(file);
-        args->return_code = 1;
-        return;
-    }
-
-    script = (char*)malloc(sz+1);
-    if (script == 0) {
-        fprintf(stderr, "unable to allocte script buffer\n");
-        fclose(file);
-        args->return_code = 1;
-        return;
-    }
-
-    len = fread(script, 1, sz, file);
-    if (len != sz) {
-        fprintf(stderr, "read error\n");
-        fclose(file);
-        free(script);
-        args->return_code = 1;
-        return;
-    }
-    
-    fclose(file);
-    script[sz] = 0;
-
-    cursor = script;
-    svrArgsSz = 1;
-    svrArgs[0] = args->argv[0];
-    cliArgsSz = 1;
-    cliArgs[0] = args->argv[0];
-
-    while (*cursor != 0) {
-        int do_it = 0;
-
-        switch (*cursor) {
-            case '\n':
-                /* A blank line triggers test case execution or switches
-                   to client mode if we don't have the client command yet */
-                if (cliMode == 0)
-                    cliMode = 1;  /* switch to client mode processing */
-                else
-                    do_it = 1;    /* Do It, we have server and client */
-                cursor++;
-                break;
-            case '#':
-                /* Ignore lines that start with a #. */
-                comment = strsep(&cursor, "\n");
-#ifdef DEBUG_SUITE_TESTS
-                printf("%s\n", comment);
-#else
-                (void)comment;
-#endif
-                break;
-            case '-':
-                /* Parameters start with a -. They end in either a newline
-                 * or a space. Capture until either, save in Args list. */
-                if (cliMode)
-                    cliArgs[cliArgsSz++] = strsep(&cursor, " \n");
-                else
-                    svrArgs[svrArgsSz++] = strsep(&cursor, " \n");
-                break;
-            default:
-                /* Anything from cursor until end of line that isn't the above
-                 * is data for a paramter. Just up until the next newline in
-                 * the Args list. */
-                if (cliMode)
-                    cliArgs[cliArgsSz++] = strsep(&cursor, "\n");
-                else
-                    svrArgs[svrArgsSz++] = strsep(&cursor, "\n");
-                if (*cursor == 0)  /* eof */
-                    do_it = 1; 
-        }
-
-        if (svrArgsSz == MAX_ARGS || cliArgsSz == MAX_ARGS) {
-            fprintf(stderr, "too many arguments, forcing test run\n");
-            do_it = 1;
-        }
-
-        if (do_it) {
-            ret = execute_test_case(svrArgsSz, svrArgs, cliArgsSz, cliArgs,0,0);
-            /* don't repeat if not supported in build */
-            if (ret == 0) {
-                execute_test_case(svrArgsSz, svrArgs, cliArgsSz, cliArgs, 0, 1);
-                execute_test_case(svrArgsSz, svrArgs, cliArgsSz, cliArgs, 1, 0);
-                execute_test_case(svrArgsSz, svrArgs, cliArgsSz, cliArgs, 1, 1);
-            }
-            svrArgsSz = 1;
-            cliArgsSz = 1;
-            cliMode   = 0;
-        }
-    }
-
-    free(script);
-    args->return_code = 0;
-}
-
-
-int SuiteTest(void)
-{
-    func_args args;
-    char argv0[2][80];
-    char* myArgv[2];
-
-    printf(" Begin Cipher Suite Tests\n");
-
-    /* setup */
-    myArgv[0] = argv0[0];
-    myArgv[1] = argv0[1];
-    args.argv = myArgv;
-    strcpy(argv0[0], "SuiteTest");
-
-    (void)test_harness;
-
-    cipherSuiteCtx = wolfSSL_CTX_new(wolfTLSv1_2_client_method());
-    if (cipherSuiteCtx == NULL) {
-        printf("can't get cipher suite ctx\n");
-        exit(EXIT_FAILURE);  
-    }
-
-    /* default case */
-    args.argc = 1;
-    printf("starting default cipher suite tests\n");
-    test_harness(&args);
-    if (args.return_code != 0) {
-        printf("error from script %d\n", args.return_code);
-        exit(EXIT_FAILURE);  
-    }
-
-    /* any extra cases will need another argument */
-    args.argc = 2;
-
-#ifdef WOLFSSL_DTLS 
-    /* add dtls extra suites */
-    strcpy(argv0[1], "tests/test-dtls.conf");
-    printf("starting dtls extra cipher suite tests\n");
-    test_harness(&args);
-    if (args.return_code != 0) {
-        printf("error from script %d\n", args.return_code);
-        exit(EXIT_FAILURE);  
-    }
-#endif
-
-    printf(" End Cipher Suite Tests\n");
-
-    wolfSSL_CTX_free(cipherSuiteCtx);
-    wolfSSL_Cleanup();
-
-    return args.return_code;
-}
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/tests/test-dtls.conf b/FreeRTOS-Plus/Source/WolfSSL/tests/test-dtls.conf
deleted file mode 100755
index 7a9c041..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/tests/test-dtls.conf
+++ /dev/null
@@ -1,908 +0,0 @@
-# server DTLSv1 DHE-RSA-CHACHA20-POLY1305
--u
--v 2
--l DHE-RSA-CHACHA20-POLY1305
-
-# client DTLSv1 DHE-RSA-CHACHA20-POLY1305
--u
--v 2
--l DHE-RSA-CHACHA20-POLY1305
-
-# server DTLSv1 ECDHE-RSA-CHACHA20-POLY1305
--u
--v 2 
--l ECDHE-RSA-CHACHA20-POLY1305
-
-# client DTLSv1 ECDHE-RSA-CHACHA20-POLY1305
--u
--v 2
--l ECDHE-RSA-CHACHA20-POLY1305
-
-# server DTLSv1 ECDHE-EDCSA-CHACHA20-POLY1305
--u
--v 2
--l ECDHE-ECDSA-CHACHA20-POLY1305
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1 ECDHE-ECDSA-CHACHA20-POLY1305
--u
--v 2
--l ECDHE-ECDSA-CHACHA20-POLY1305
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 DHE-RSA-CHACHA20-POLY1305
--u
--v 3
--l DHE-RSA-CHACHA20-POLY1305
-
-# client DTLSv1.2 DHE-RSA-CHACHA20-POLY1305
--u
--v 3
--l DHE-RSA-CHACHA20-POLY1305
-
-# server DTLSv1.2 ECDHE-RSA-CHACHA20-POLY1305
--u
--v 3 
--l ECDHE-RSA-CHACHA20-POLY1305
-
-# client DTLSv1.2 ECDHE-RSA-CHACHA20-POLY1305
--u
--v 3
--l ECDHE-RSA-CHACHA20-POLY1305
-
-# server DTLSv1.2 ECDHE-EDCSA-CHACHA20-POLY1305
--u
--v 3
--l ECDHE-ECDSA-CHACHA20-POLY1305
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDHE-ECDSA-CHACHA20-POLY1305
--u
--v 3
--l ECDHE-ECDSA-CHACHA20-POLY1305
--A ./certs/server-ecc.pem
-
-# server DTLSv1 RC4-SHA
--u
--v 2
--l RC4-SHA
-
-# client DTLSv1 RC4-SHA
--u
--v 2
--l RC4-SHA
-
-# server DTLSv1.2 RC4-SHA
--u
--v 3
--l RC4-SHA
-
-# client DTLSv1.2 RC4-SHA
--u
--v 3
--l RC4-SHA
-
-# server DTLSv1 DES-CBC3-SHA
--u
--v 2
--l DES-CBC3-SHA
-
-# client DTLSv1 DES-CBC3-SHA
--u
--v 2
--l DES-CBC3-SHA
-
-# server DTLSv1.2 DES-CBC3-SHA
--u
--v 3
--l DES-CBC3-SHA
-
-# client DTLSv1.2 DES-CBC3-SHA
--u
--v 3
--l DES-CBC3-SHA
-
-# server DTLSv1 AES128-SHA
--u
--v 2
--l AES128-SHA
-
-# client DTLSv1 AES128-SHA
--u
--v 2
--l AES128-SHA
-
-# server DTLSv1.2 AES128-SHA
--u
--v 3
--l AES128-SHA
-
-# client DTLSv1.2 AES128-SHA
--u
--v 3
--l AES128-SHA
-
-# server DTLSv1 AES256-SHA
--u
--v 2
--l AES256-SHA
-
-# client DTLSv1 AES256-SHA
--u
--v 2
--l AES256-SHA
-
-# server DTLSv1.2 AES256-SHA
--u
--v 3
--l AES256-SHA
-
-# client DTLSv1.2 AES256-SHA
--u
--v 3
--l AES256-SHA
-
-# server DTLSv1 AES128-SHA256
--u
--v 2
--l AES128-SHA256
-
-# client DTLSv1 AES128-SHA256
--u
--v 2
--l AES128-SHA256
-
-# server DTLSv1.2 AES128-SHA256
--u
--v 3
--l AES128-SHA256
-
-# client DTLSv1.2 AES128-SHA256
--u
--v 3
--l AES128-SHA256
-
-# server DTLSv1 AES256-SHA256
--u
--v 2
--l AES256-SHA256
-
-# client DTLSv1 AES256-SHA256
--u
--v 2
--l AES256-SHA256
-
-# server DTLSv1.2 AES256-SHA256
--u
--v 3
--l AES256-SHA256
-
-# client DTLSv1.2 AES256-SHA256
--u
--v 3
--l AES256-SHA256
-
-# server DTLSv1 ECDHE-RSA-RC4
--u
--v 2
--l ECDHE-RSA-RC4-SHA
-
-# client DTLSv1 ECDHE-RSA-RC4
--u
--v 2
--l ECDHE-RSA-RC4-SHA
-
-# server DTLSv1.1 ECDHE-RSA-DES3
--u
--v 2
--l ECDHE-RSA-DES-CBC3-SHA
-
-# client DTLSv1.1 ECDHE-RSA-DES3
--u
--v 2
--l ECDHE-RSA-DES-CBC3-SHA
-
-# server DTLSv1.1 ECDHE-RSA-AES128 
--u
--v 2
--l ECDHE-RSA-AES128-SHA
-
-# client DTLSv1.1 ECDHE-RSA-AES128 
--u
--v 2
--l ECDHE-RSA-AES128-SHA
-
-# server DTLSv1.1 ECDHE-RSA-AES256
--u
--v 2
--l ECDHE-RSA-AES256-SHA
-
-# client DTLSv1.1 ECDHE-RSA-AES256
--u
--v 2
--l ECDHE-RSA-AES256-SHA
-
-# server DTLSv1.2 ECDHE-RSA-RC4
--u
--v 3
--l ECDHE-RSA-RC4-SHA
-
-# client DTLSv1.2 ECDHE-RSA-RC4
--u
--v 3
--l ECDHE-RSA-RC4-SHA
-
-# server DTLSv1.2 ECDHE-RSA-DES3
--u
--v 3
--l ECDHE-RSA-DES-CBC3-SHA
-
-# client DTLSv1.2 ECDHE-RSA-DES3
--u
--v 3
--l ECDHE-RSA-DES-CBC3-SHA
-
-# server DTLSv1.2 ECDHE-RSA-AES128 
--u
--v 3
--l ECDHE-RSA-AES128-SHA
-
-# client DTLSv1.2 ECDHE-RSA-AES128 
--u
--v 3
--l ECDHE-RSA-AES128-SHA
-
-# server DTLSv1.2 ECDHE-RSA-AES128-SHA256
--u
--v 3
--l ECDHE-RSA-AES128-SHA256
-
-# client DTLSv1.2 ECDHE-RSA-AES128-SHA256 
--u
--v 3
--l ECDHE-RSA-AES128-SHA256
-
-# server DTLSv1.2 ECDHE-RSA-AES256
--u
--v 3
--l ECDHE-RSA-AES256-SHA
-
-# client DTLSv1.2 ECDHE-RSA-AES256
--u
--v 3
--l ECDHE-RSA-AES256-SHA
-
-# server DTLSv1.1 ECDHE-EDCSA-RC4
--u
--v 2
--l ECDHE-ECDSA-RC4-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.1 ECDHE-ECDSA-RC4
--u
--v 2
--l ECDHE-ECDSA-RC4-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.1 ECDHE-ECDSA-DES3
--u
--v 2
--l ECDHE-ECDSA-DES-CBC3-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.1 ECDHE-ECDSA-DES3
--u
--v 2
--l ECDHE-ECDSA-DES-CBC3-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.1 ECDHE-ECDSA-AES128 
--u
--v 2
--l ECDHE-ECDSA-AES128-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.1 ECDHE-ECDSA-AES128 
--u
--v 2
--l ECDHE-ECDSA-AES128-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.1 ECDHE-ECDSA-AES256
--u
--v 2
--l ECDHE-ECDSA-AES256-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.1 ECDHE-ECDSA-AES256
--u
--v 2
--l ECDHE-ECDSA-AES256-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDHE-ECDSA-RC4
--u
--v 3
--l ECDHE-ECDSA-RC4-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDHE-ECDSA-RC4
--u
--v 3
--l ECDHE-ECDSA-RC4-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDHE-ECDSA-DES3
--u
--v 3
--l ECDHE-ECDSA-DES-CBC3-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDHE-ECDSA-DES3
--u
--v 3
--l ECDHE-ECDSA-DES-CBC3-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDHE-ECDSA-AES128 
--u
--v 3
--l ECDHE-ECDSA-AES128-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDHE-ECDSA-AES128 
--u
--v 3
--l ECDHE-ECDSA-AES128-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDHE-ECDSA-AES128-SHA256
--u
--v 3
--l ECDHE-ECDSA-AES128-SHA256
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDHE-ECDSA-AES128-SHA256
--u
--v 3
--l ECDHE-ECDSA-AES128-SHA256
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDHE-ECDSA-AES256
--u
--v 3
--l ECDHE-ECDSA-AES256-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDHE-ECDSA-AES256
--u
--v 3
--l ECDHE-ECDSA-AES256-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.1 ECDH-RSA-RC4
--u
--v 2
--l ECDH-RSA-RC4-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.1 ECDH-RSA-RC4
--u
--v 2
--l ECDH-RSA-RC4-SHA
-
-# server DTLSv1.1 ECDH-RSA-DES3
--u
--v 2
--l ECDH-RSA-DES-CBC3-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.1 ECDH-RSA-DES3
--u
--v 2
--l ECDH-RSA-DES-CBC3-SHA
-
-# server DTLSv1.1 ECDH-RSA-AES128 
--u
--v 2
--l ECDH-RSA-AES128-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.1 ECDH-RSA-AES128 
--u
--v 2
--l ECDH-RSA-AES128-SHA
-
-# server DTLSv1.1 ECDH-RSA-AES256
--u
--v 2
--l ECDH-RSA-AES256-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.1 ECDH-RSA-AES256
--u
--v 2
--l ECDH-RSA-AES256-SHA
-
-# server DTLSv1.2 ECDH-RSA-RC4
--u
--v 3
--l ECDH-RSA-RC4-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-RSA-RC4
--u
--v 3
--l ECDH-RSA-RC4-SHA
-
-# server DTLSv1.2 ECDH-RSA-DES3
--u
--v 3
--l ECDH-RSA-DES-CBC3-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-RSA-DES3
--u
--v 3
--l ECDH-RSA-DES-CBC3-SHA
-
-# server DTLSv1.2 ECDH-RSA-AES128 
--u
--v 3
--l ECDH-RSA-AES128-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-RSA-AES128 
--u
--v 3
--l ECDH-RSA-AES128-SHA
-
-# server DTLSv1.2 ECDH-RSA-AES128-SHA256 
--u
--v 3
--l ECDH-RSA-AES128-SHA256
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-RSA-AES128-SHA256 
--u
--v 3
--l ECDH-RSA-AES128-SHA256
-
-# server DTLSv1.2 ECDH-RSA-AES256
--u
--v 3
--l ECDH-RSA-AES256-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-RSA-AES256
--u
--v 3
--l ECDH-RSA-AES256-SHA
-
-# server DTLSv1.1 ECDH-EDCSA-RC4
--u
--v 2
--l ECDH-ECDSA-RC4-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.1 ECDH-ECDSA-RC4
--u
--v 2
--l ECDH-ECDSA-RC4-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.1 ECDH-ECDSA-DES3
--u
--v 2
--l ECDH-ECDSA-DES-CBC3-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.1 ECDH-ECDSA-DES3
--u
--v 2
--l ECDH-ECDSA-DES-CBC3-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.1 ECDH-ECDSA-AES128 
--u
--v 2
--l ECDH-ECDSA-AES128-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.1 ECDH-ECDSA-AES128 
--u
--v 2
--l ECDH-ECDSA-AES128-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.1 ECDH-ECDSA-AES256
--u
--v 2
--l ECDH-ECDSA-AES256-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.1 ECDH-ECDSA-AES256
--u
--v 2
--l ECDH-ECDSA-AES256-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDHE-ECDSA-RC4
--u
--v 3
--l ECDH-ECDSA-RC4-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-ECDSA-RC4
--u
--v 3
--l ECDH-ECDSA-RC4-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDH-ECDSA-DES3
--u
--v 3
--l ECDH-ECDSA-DES-CBC3-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-ECDSA-DES3
--u
--v 3
--l ECDH-ECDSA-DES-CBC3-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDH-ECDSA-AES128 
--u
--v 3
--l ECDH-ECDSA-AES128-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-ECDSA-AES128 
--u
--v 3
--l ECDH-ECDSA-AES128-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDH-ECDSA-AES128-SHA256
--u
--v 3
--l ECDH-ECDSA-AES128-SHA256
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-ECDSA-AES128-SHA256 
--u
--v 3
--l ECDH-ECDSA-AES128-SHA256
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDH-ECDSA-AES256
--u
--v 3
--l ECDH-ECDSA-AES256-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-ECDSA-AES256
--u
--v 3
--l ECDH-ECDSA-AES256-SHA
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDHE-RSA-AES256-SHA384 
--u
--v 3
--l ECDHE-RSA-AES256-SHA384
-
-# client DTLSv1.2 ECDHE-RSA-AES256-SHA384 
--u
--v 3
--l ECDHE-RSA-AES256-SHA384
-
-# server DTLSv1.2 ECDHE-ECDSA-AES256-SHA384
--u
--v 3
--l ECDHE-ECDSA-AES256-SHA384
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDHE-ECDSA-AES256-SHA384
--u
--v 3
--l ECDHE-ECDSA-AES256-SHA384
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDH-RSA-AES256-SHA384 
--u
--v 3
--l ECDH-RSA-AES256-SHA384
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-RSA-AES256-SHA384 
--u
--v 3
--l ECDH-RSA-AES256-SHA384
-
-# server DTLSv1.2 ECDH-ECDSA-AES256-SHA384
--u
--v 3
--l ECDH-ECDSA-AES256-SHA384
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-ECDSA-AES256-SHA384 
--u
--v 3
--l ECDH-ECDSA-AES256-SHA384
--A ./certs/server-ecc.pem
-
-# server DTLSv1 PSK-AES128
--s
--u
--v 2
--l PSK-AES128-CBC-SHA
-
-# client DTLSv1 PSK-AES128
--s
--u
--v 2
--l PSK-AES128-CBC-SHA
-
-# server DTLSv1 PSK-AES256
--s
--u
--v 2
--l PSK-AES256-CBC-SHA
-
-# client DTLSv1 PSK-AES256
--s
--u
--v 2
--l PSK-AES256-CBC-SHA
-
-# server DTLSv1.2 PSK-AES128
--s
--u
--v 3
--l PSK-AES128-CBC-SHA
-
-# client DTLSv1.2 PSK-AES128
--s
--u
--v 3
--l PSK-AES128-CBC-SHA
-
-# server DTLSv1.2 PSK-AES256
--s
--u
--v 3
--l PSK-AES256-CBC-SHA
-
-# client DTLSv1.2 PSK-AES256
--s
--u
--v 3
--l PSK-AES256-CBC-SHA
-
-# server DTLSv1.2 PSK-AES128-SHA256
--s
--u
--v 3
--l PSK-AES128-CBC-SHA256
-
-# client DTLSv1.2 PSK-AES128-SHA256
--s
--u
--v 3
--l PSK-AES128-CBC-SHA256
-
-# server DTLSv1.2 PSK-AES256-SHA384
--s
--u
--v 3
--l PSK-AES256-CBC-SHA384
-
-# client DTLSv1.2 PSK-AES256-SHA384
--s
--u
--v 3
--l PSK-AES256-CBC-SHA384
-
-# server DTLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 
--u
--v 3
--l ECDHE-ECDSA-AES128-GCM-SHA256
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 
--u
--v 3
--l ECDHE-ECDSA-AES128-GCM-SHA256
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384
--u
--v 3
--l ECDHE-ECDSA-AES256-GCM-SHA384
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384
--u
--v 3
--l ECDHE-ECDSA-AES256-GCM-SHA384
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDH-ECDSA-AES128-GCM-SHA256 
--u
--v 3
--l ECDH-ECDSA-AES128-GCM-SHA256
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-ECDSA-AES128-GCM-SHA256 
--u
--v 3
--l ECDH-ECDSA-AES128-GCM-SHA256
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDH-ECDSA-AES256-GCM-SHA384
--u
--v 3
--l ECDH-ECDSA-AES256-GCM-SHA384
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-ECDSA-AES256-GCM-SHA384
--u
--v 3
--l ECDH-ECDSA-AES256-GCM-SHA384
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 
--u
--v 3
--l ECDHE-RSA-AES128-GCM-SHA256
-
-# client DTLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 
--u
--v 3
--l ECDHE-RSA-AES128-GCM-SHA256
-
-# server DTLSv1.2 ECDHE-RSA-AES256-GCM-SHA384
--u
--v 3
--l ECDHE-RSA-AES256-GCM-SHA384
-
-# client DTLSv1.2 ECDHE-RSA-AES256-GCM-SHA384
--u
--v 3
--l ECDHE-RSA-AES256-GCM-SHA384
-
-# server DTLSv1.2 ECDH-RSA-AES128-GCM-SHA256 
--u
--v 3
--l ECDH-RSA-AES128-GCM-SHA256
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-RSA-AES128-GCM-SHA256 
--u
--v 3
--l ECDH-RSA-AES128-GCM-SHA256
-
-# server DTLSv1.2 ECDH-RSA-AES256-GCM-SHA384
--u
--v 3
--l ECDH-RSA-AES256-GCM-SHA384
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDH-RSA-AES256-GCM-SHA384
--u
--v 3
--l ECDH-RSA-AES256-GCM-SHA384
-
-# server DTLSv1.2 PSK-AES128-GCM-SHA256
--u
--s
--v 3
--l PSK-AES128-GCM-SHA256
-
-# client DTLSv1.2 PSK-AES128-GCM-SHA256
--u
--s
--v 3
--l PSK-AES128-GCM-SHA256
-
-# server DTLSv1.2 PSK-AES256-GCM-SHA384
--u
--s
--v 3
--l PSK-AES256-GCM-SHA384
-
-# client DTLSv1.2 PSK-AES256-GCM-SHA384
--u
--s
--v 3
--l PSK-AES256-GCM-SHA384
-
-# server DTLSv1.2 ECDHE-ECDSA-AES128-CCM-8
--u
--v 3
--l ECDHE-ECDSA-AES128-CCM-8
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDHE-ECDSA-AES128-CCM-8
--u
--v 3
--l ECDHE-ECDSA-AES128-CCM-8
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ECDHE-ECDSA-AES256-CCM-8
--u
--v 3
--l ECDHE-ECDSA-AES256-CCM-8
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client DTLSv1.2 ECDHE-ECDSA-AES256-CCM-8
--u
--v 3
--l ECDHE-ECDSA-AES256-CCM-8
--A ./certs/server-ecc.pem
-
-# server DTLSv1.2 ADH-AES128-SHA
--u
--a
--v 3
--l ADH-AES128-SHA
-
-# client DTLSv1.2 ADH-AES128-SHA
--u
--a
--v 3
--l ADH-AES128-SHA
-
-# server DTLSv1.0 ADH-AES128-SHA
--u
--a
--v 2
--l ADH-AES128-SHA
-
-# client DTLSv1.0 ADH-AES128-SHA
--u
--a
--v 2
--l ADH-AES128-SHA
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/tests/test.conf b/FreeRTOS-Plus/Source/WolfSSL/tests/test.conf
deleted file mode 100755
index c949c20..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/tests/test.conf
+++ /dev/null
@@ -1,2035 +0,0 @@
-# server TLSv1 DHE-RSA-CHACHA20-POLY1305
--v 1
--l DHE-RSA-CHACHA20-POLY1305
-
-# client TLSv1 DHE-RSA-CHACHA20-POLY1305
--v 1
--l DHE-RSA-CHACHA20-POLY1305
-
-# server TLSv1 ECDHE-EDCSA-CHACHA20-POLY1305
--v 1
--l ECDHE-ECDSA-CHACHA20-POLY1305
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1 ECDHE-ECDSA-CHACHA20-POLY1305
--v 1
--l ECDHE-ECDSA-CHACHA20-POLY1305
--A ./certs/server-ecc.pem
-
-# server TLSv1 ECDHE-RSA-CHACHA20-POLY1305
--v 1 
--l ECDHE-RSA-CHACHA20-POLY1305
-
-# client TLSv1 ECDHE-RSA-CHACHA20-POLY1305
--v 1
--l ECDHE-RSA-CHACHA20-POLY1305
-
-# server TLSv1.1 DHE-RSA-CHACHA20-POLY1305
--v 2
--l DHE-RSA-CHACHA20-POLY1305
-
-# client TLSv1.1 DHE-RSA-CHACHA20-POLY1305
--v 2
--l DHE-RSA-CHACHA20-POLY1305
-
-# server TLSv1.1 ECDHE-RSA-CHACHA20-POLY1305
--v 2 
--l ECDHE-RSA-CHACHA20-POLY1305
-
-# client TLSv1.1 ECDHE-RSA-CHACHA20-POLY1305
--v 2
--l ECDHE-RSA-CHACHA20-POLY1305
-
-# server TLSv1.1 ECDHE-EDCSA-CHACHA20-POLY1305
--v 2
--l ECDHE-ECDSA-CHACHA20-POLY1305
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.1 ECDHE-ECDSA-CHACHA20-POLY1305
--v 2
--l ECDHE-ECDSA-CHACHA20-POLY1305
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 DHE-RSA-CHACHA20-POLY1305
--v 3
--l DHE-RSA-CHACHA20-POLY1305
-
-# client TLSv1.2 DHE-RSA-CHACHA20-POLY1305
--v 3
--l DHE-RSA-CHACHA20-POLY1305
-
-# server TLSv1.2 ECDHE-RSA-CHACHA20-POLY1305
--v 3 
--l ECDHE-RSA-CHACHA20-POLY1305
-
-# client TLSv1.2 ECDHE-RSA-CHACHA20-POLY1305
--v 3
--l ECDHE-RSA-CHACHA20-POLY1305
-
-# server TLSv1.2 ECDHE-EDCSA-CHACHA20-POLY1305
--v 3
--l ECDHE-ECDSA-CHACHA20-POLY1305
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDHE-ECDSA-CHACHA20-POLY1305
--v 3
--l ECDHE-ECDSA-CHACHA20-POLY1305
--A ./certs/server-ecc.pem
-
-# server SSLv3 RC4-SHA
--v 0
--l RC4-SHA
-
-# client SSLv3 RC4-SHA
--v 0
--l RC4-SHA
-
-# server SSLv3 RC4-MD5
--v 0
--l RC4-MD5
-
-# client SSLv3 RC4-MD5
--v 0
--l RC4-MD5
-
-# server SSLv3 DES-CBC3-SHA
--v 0
--l DES-CBC3-SHA
-
-# client SSLv3 DES-CBC3-SHA
--v 0
--l DES-CBC3-SHA
-
-# server TLSv1 RC4-SHA
--v 1
--l RC4-SHA
-
-# client TLSv1 RC4-SHA
--v 1
--l RC4-SHA
-
-# server TLSv1 RC4-MD5
--v 1
--l RC4-MD5
-
-# client TLSv1 RC4-MD5
--v 1
--l RC4-MD5
-
-# server TLSv1 DES-CBC3-SHA
--v 1
--l DES-CBC3-SHA
-
-# client TLSv1 DES-CBC3-SHA
--v 1
--l DES-CBC3-SHA
-
-# server TLSv1 AES128-SHA
--v 1
--l AES128-SHA
-
-# client TLSv1 AES128-SHA
--v 1
--l AES128-SHA
-
-# server TLSv1 AES256-SHA
--v 1
--l AES256-SHA
-
-# client TLSv1 AES256-SHA
--v 1
--l AES256-SHA
-
-# server TLSv1 AES128-SHA256
--v 1
--l AES128-SHA256
-
-# client TLSv1 AES128-SHA256
--v 1
--l AES128-SHA256
-
-# server TLSv1 AES256-SHA256
--v 1
--l AES256-SHA256
-
-# client TLSv1 AES256-SHA256
--v 1
--l AES256-SHA256
-
-# server TLSv1.1 RC4-SHA
--v 2
--l RC4-SHA
-
-# client TLSv1.1 RC4-SHA
--v 2
--l RC4-SHA
-
-# server TLSv1.1 RC4-MD5
--v 2
--l RC4-MD5
-
-# client TLSv1.1 RC4-MD5
--v 2
--l RC4-MD5
-
-# server TLSv1.1 DES-CBC3-SHA
--v 2
--l DES-CBC3-SHA
-
-# client TLSv1.1 DES-CBC3-SHA
--v 2
--l DES-CBC3-SHA
-
-# server TLSv1.1 AES128-SHA
--v 2
--l AES128-SHA
-
-# client TLSv1.1 AES128-SHA
--v 2
--l AES128-SHA
-
-# server TLSv1.1 AES256-SHA
--v 2
--l AES256-SHA
-
-# client TLSv1.1 AES256-SHA
--v 2
--l AES256-SHA
-
-# server TLSv1.1 AES128-SHA256
--v 2
--l AES128-SHA256
-
-# client TLSv1.1 AES128-SHA256
--v 2
--l AES128-SHA256
-
-# server TLSv1.1 AES256-SHA256
--v 2
--l AES256-SHA256
-
-# client TLSv1.1 AES256-SHA256
--v 2
--l AES256-SHA256
-
-# server TLSv1.2 RC4-SHA
--v 3
--l RC4-SHA
-
-# client TLSv1.2 RC4-SHA
--v 3
--l RC4-SHA
-
-# server TLSv1.2 RC4-MD5
--v 3
--l RC4-MD5
-
-# client TLSv1.2 RC4-MD5
--v 3
--l RC4-MD5
-
-# server TLSv1.2 DES-CBC3-SHA
--v 3
--l DES-CBC3-SHA
-
-# client TLSv1.2 DES-CBC3-SHA
--v 3
--l DES-CBC3-SHA
-
-# server TLSv1.2 AES128-SHA
--v 3
--l AES128-SHA
-
-# client TLSv1.2 AES128-SHA
--v 3
--l AES128-SHA
-
-# server TLSv1.2 AES256-SHA
--v 3
--l AES256-SHA
-
-# client TLSv1.2 AES256-SHA
--v 3
--l AES256-SHA
-
-# server TLSv1.2 AES128-SHA256
--v 3
--l AES128-SHA256
-
-# client TLSv1.2 AES128-SHA256
--v 3
--l AES128-SHA256
-
-# server TLSv1.2 AES256-SHA256
--v 3
--l AES256-SHA256
-
-# client TLSv1.2 AES256-SHA256
--v 3
--l AES256-SHA256
-
-# server TLSv1 ECDHE-RSA-RC4
--v 1
--l ECDHE-RSA-RC4-SHA
-
-# client TLSv1 ECDHE-RSA-RC4
--v 1
--l ECDHE-RSA-RC4-SHA
-
-# server TLSv1 ECDHE-RSA-DES3
--v 1
--l ECDHE-RSA-DES-CBC3-SHA
-
-# client TLSv1 ECDHE-RSA-DES3
--v 1
--l ECDHE-RSA-DES-CBC3-SHA
-
-# server TLSv1 ECDHE-RSA-AES128 
--v 1
--l ECDHE-RSA-AES128-SHA
-
-# client TLSv1 ECDHE-RSA-AES128 
--v 1
--l ECDHE-RSA-AES128-SHA
-
-# server TLSv1 ECDHE-RSA-AES256
--v 1
--l ECDHE-RSA-AES256-SHA
-
-# client TLSv1 ECDHE-RSA-AES256
--v 1
--l ECDHE-RSA-AES256-SHA
-
-# server TLSv1.1 ECDHE-RSA-RC4
--v 2
--l ECDHE-RSA-RC4-SHA
-
-# client TLSv1.1 ECDHE-RSA-RC4
--v 2
--l ECDHE-RSA-RC4-SHA
-
-# server TLSv1.1 ECDHE-RSA-DES3
--v 2
--l ECDHE-RSA-DES-CBC3-SHA
-
-# client TLSv1.1 ECDHE-RSA-DES3
--v 2
--l ECDHE-RSA-DES-CBC3-SHA
-
-# server TLSv1.1 ECDHE-RSA-AES128 
--v 2
--l ECDHE-RSA-AES128-SHA
-
-# client TLSv1.1 ECDHE-RSA-AES128 
--v 2
--l ECDHE-RSA-AES128-SHA
-
-# server TLSv1.1 ECDHE-RSA-AES256
--v 2
--l ECDHE-RSA-AES256-SHA
-
-# client TLSv1.1 ECDHE-RSA-AES256
--v 2
--l ECDHE-RSA-AES256-SHA
-
-# server TLSv1.2 ECDHE-RSA-RC4
--v 3
--l ECDHE-RSA-RC4-SHA
-
-# client TLSv1.2 ECDHE-RSA-RC4
--v 3
--l ECDHE-RSA-RC4-SHA
-
-# server TLSv1.2 ECDHE-RSA-DES3
--v 3
--l ECDHE-RSA-DES-CBC3-SHA
-
-# client TLSv1.2 ECDHE-RSA-DES3
--v 3
--l ECDHE-RSA-DES-CBC3-SHA
-
-# server TLSv1.2 ECDHE-RSA-AES128 
--v 3
--l ECDHE-RSA-AES128-SHA
-
-# client TLSv1.2 ECDHE-RSA-AES128 
--v 3
--l ECDHE-RSA-AES128-SHA
-
-# server TLSv1.2 ECDHE-RSA-AES128-SHA256
--v 3
--l ECDHE-RSA-AES128-SHA256
-
-# client TLSv1.2 ECDHE-RSA-AES128-SHA256 
--v 3
--l ECDHE-RSA-AES128-SHA256
-
-# server TLSv1.2 ECDHE-RSA-AES256
--v 3
--l ECDHE-RSA-AES256-SHA
-
-# client TLSv1.2 ECDHE-RSA-AES256
--v 3
--l ECDHE-RSA-AES256-SHA
-
-# server TLSv1 ECDHE-ECDSA-RC4
--v 1
--l ECDHE-ECDSA-RC4-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1 ECDHE-ECDSA-RC4
--v 1
--l ECDHE-ECDSA-RC4-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1 ECDHE-ECDSA-DES3
--v 1
--l ECDHE-ECDSA-DES-CBC3-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1 ECDHE-ECDSA-DES3
--v 1
--l ECDHE-ECDSA-DES-CBC3-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1 ECDHE-ECDSA-AES128 
--v 1
--l ECDHE-ECDSA-AES128-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1 ECDHE-ECDSA-AES128 
--v 1
--l ECDHE-ECDSA-AES128-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1 ECDHE-ECDSA-AES256
--v 1
--l ECDHE-ECDSA-AES256-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1 ECDHE-ECDSA-AES256
--v 1
--l ECDHE-ECDSA-AES256-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.1 ECDHE-EDCSA-RC4
--v 2
--l ECDHE-ECDSA-RC4-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.1 ECDHE-ECDSA-RC4
--v 2
--l ECDHE-ECDSA-RC4-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.1 ECDHE-ECDSA-DES3
--v 2
--l ECDHE-ECDSA-DES-CBC3-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.1 ECDHE-ECDSA-DES3
--v 2
--l ECDHE-ECDSA-DES-CBC3-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.1 ECDHE-ECDSA-AES128 
--v 2
--l ECDHE-ECDSA-AES128-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.1 ECDHE-ECDSA-AES128 
--v 2
--l ECDHE-ECDSA-AES128-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.1 ECDHE-ECDSA-AES256
--v 2
--l ECDHE-ECDSA-AES256-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.1 ECDHE-ECDSA-AES256
--v 2
--l ECDHE-ECDSA-AES256-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDHE-ECDSA-RC4
--v 3
--l ECDHE-ECDSA-RC4-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDHE-ECDSA-RC4
--v 3
--l ECDHE-ECDSA-RC4-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDHE-ECDSA-DES3
--v 3
--l ECDHE-ECDSA-DES-CBC3-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDHE-ECDSA-DES3
--v 3
--l ECDHE-ECDSA-DES-CBC3-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDHE-ECDSA-AES128 
--v 3
--l ECDHE-ECDSA-AES128-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDHE-ECDSA-AES128 
--v 3
--l ECDHE-ECDSA-AES128-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDHE-ECDSA-AES128-SHA256
--v 3
--l ECDHE-ECDSA-AES128-SHA256
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDHE-ECDSA-AES128-SHA256
--v 3
--l ECDHE-ECDSA-AES128-SHA256
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDHE-ECDSA-AES256
--v 3
--l ECDHE-ECDSA-AES256-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDHE-ECDSA-AES256
--v 3
--l ECDHE-ECDSA-AES256-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1 ECDH-RSA-RC4
--v 1
--l ECDH-RSA-RC4-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1 ECDH-RSA-RC4
--v 1
--l ECDH-RSA-RC4-SHA
-
-# server TLSv1 ECDH-RSA-DES3
--v 1
--l ECDH-RSA-DES-CBC3-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1 ECDH-RSA-DES3
--v 1
--l ECDH-RSA-DES-CBC3-SHA
-
-# server TLSv1 ECDH-RSA-AES128 
--v 1
--l ECDH-RSA-AES128-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1 ECDH-RSA-AES128 
--v 1
--l ECDH-RSA-AES128-SHA
-
-# server TLSv1 ECDH-RSA-AES256
--v 1
--l ECDH-RSA-AES256-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1 ECDH-RSA-AES256
--v 1
--l ECDH-RSA-AES256-SHA
-
-# server TLSv1.1 ECDH-RSA-RC4
--v 2
--l ECDH-RSA-RC4-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.1 ECDH-RSA-RC4
--v 2
--l ECDH-RSA-RC4-SHA
-
-# server TLSv1.1 ECDH-RSA-DES3
--v 2
--l ECDH-RSA-DES-CBC3-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.1 ECDH-RSA-DES3
--v 2
--l ECDH-RSA-DES-CBC3-SHA
-
-# server TLSv1.1 ECDH-RSA-AES128 
--v 2
--l ECDH-RSA-AES128-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.1 ECDH-RSA-AES128 
--v 2
--l ECDH-RSA-AES128-SHA
-
-# server TLSv1.1 ECDH-RSA-AES256
--v 2
--l ECDH-RSA-AES256-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.1 ECDH-RSA-AES256
--v 2
--l ECDH-RSA-AES256-SHA
-
-# server TLSv1.2 ECDH-RSA-RC4
--v 3
--l ECDH-RSA-RC4-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-RSA-RC4
--v 3
--l ECDH-RSA-RC4-SHA
-
-# server TLSv1.2 ECDH-RSA-DES3
--v 3
--l ECDH-RSA-DES-CBC3-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-RSA-DES3
--v 3
--l ECDH-RSA-DES-CBC3-SHA
-
-# server TLSv1.2 ECDH-RSA-AES128 
--v 3
--l ECDH-RSA-AES128-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-RSA-AES128 
--v 3
--l ECDH-RSA-AES128-SHA
-
-# server TLSv1.2 ECDH-RSA-AES128-SHA256 
--v 3
--l ECDH-RSA-AES128-SHA256
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-RSA-AES128-SHA256 
--v 3
--l ECDH-RSA-AES128-SHA256
-
-# server TLSv1.2 ECDH-RSA-AES256
--v 3
--l ECDH-RSA-AES256-SHA
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-RSA-AES256
--v 3
--l ECDH-RSA-AES256-SHA
-
-# server TLSv1 ECDH-ECDSA-RC4
--v 1
--l ECDH-ECDSA-RC4-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1 ECDH-ECDSA-RC4
--v 1
--l ECDH-ECDSA-RC4-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1 ECDH-ECDSA-DES3
--v 1
--l ECDH-ECDSA-DES-CBC3-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1 ECDH-ECDSA-DES3
--v 1
--l ECDH-ECDSA-DES-CBC3-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1 ECDH-ECDSA-AES128 
--v 1
--l ECDH-ECDSA-AES128-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1 ECDH-ECDSA-AES128 
--v 1
--l ECDH-ECDSA-AES128-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1 ECDH-ECDSA-AES256
--v 1
--l ECDH-ECDSA-AES256-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1 ECDH-ECDSA-AES256
--v 1
--l ECDH-ECDSA-AES256-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.1 ECDH-EDCSA-RC4
--v 2
--l ECDH-ECDSA-RC4-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.1 ECDH-ECDSA-RC4
--v 2
--l ECDH-ECDSA-RC4-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.1 ECDH-ECDSA-DES3
--v 2
--l ECDH-ECDSA-DES-CBC3-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.1 ECDH-ECDSA-DES3
--v 2
--l ECDH-ECDSA-DES-CBC3-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.1 ECDH-ECDSA-AES128 
--v 2
--l ECDH-ECDSA-AES128-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.1 ECDH-ECDSA-AES128 
--v 2
--l ECDH-ECDSA-AES128-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.1 ECDH-ECDSA-AES256
--v 2
--l ECDH-ECDSA-AES256-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.1 ECDH-ECDSA-AES256
--v 2
--l ECDH-ECDSA-AES256-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDHE-ECDSA-RC4
--v 3
--l ECDH-ECDSA-RC4-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-ECDSA-RC4
--v 3
--l ECDH-ECDSA-RC4-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDH-ECDSA-DES3
--v 3
--l ECDH-ECDSA-DES-CBC3-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-ECDSA-DES3
--v 3
--l ECDH-ECDSA-DES-CBC3-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDH-ECDSA-AES128 
--v 3
--l ECDH-ECDSA-AES128-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-ECDSA-AES128 
--v 3
--l ECDH-ECDSA-AES128-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDH-ECDSA-AES128-SHA256
--v 3
--l ECDH-ECDSA-AES128-SHA256
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-ECDSA-AES128-SHA256 
--v 3
--l ECDH-ECDSA-AES128-SHA256
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDH-ECDSA-AES256
--v 3
--l ECDH-ECDSA-AES256-SHA
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-ECDSA-AES256
--v 3
--l ECDH-ECDSA-AES256-SHA
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDHE-RSA-AES256-SHA384
--v 3
--l ECDHE-RSA-AES256-SHA384
-
-# client TLSv1.2 ECDHE-RSA-AES256-SHA384 
--v 3
--l ECDHE-RSA-AES256-SHA384
-
-# server TLSv1.2 ECDHE-ECDSA-AES256-SHA384
--v 3
--l ECDHE-ECDSA-AES256-SHA384
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDHE-ECDSA-AES256-SHA384
--v 3
--l ECDHE-ECDSA-AES256-SHA384
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDH-RSA-AES256-SHA384 
--v 3
--l ECDH-RSA-AES256-SHA384
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-RSA-AES256-SHA384 
--v 3
--l ECDH-RSA-AES256-SHA384
-
-# server TLSv1.2 ECDH-ECDSA-AES256-SHA384
--v 3
--l ECDH-ECDSA-AES256-SHA384
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-ECDSA-AES256-SHA384 
--v 3
--l ECDH-ECDSA-AES256-SHA384
--A ./certs/server-ecc.pem
-
-# server TLSv1 HC128-SHA
--v 1
--l HC128-SHA
-
-# client TLSv1 HC128-SHA
--v 1
--l HC128-SHA
-
-# server TLSv1 HC128-MD5
--v 1
--l HC128-MD5
-
-# client TLSv1 HC128-MD5
--v 1
--l HC128-MD5
-
-# server TLSv1 HC128-B2B256
--v 1
--l HC128-B2B256
-
-# client TLSv1 HC128-B2B256
--v 1
--l HC128-B2B256
-
-# server TLSv1 AES128-B2B256
--v 1
--l AES128-B2B256
-
-# client TLSv1 AES128-B2B256
--v 1
--l AES128-B2B256
-
-# server TLSv1 AES256-B2B256
--v 1
--l AES256-B2B256
-
-# client TLSv1 AES256-B2B256
--v 1
--l AES256-B2B256
-
-# server TLSv1.1 HC128-SHA
--v 2
--l HC128-SHA
-
-# client TLSv1.1 HC128-SHA
--v 2
--l HC128-SHA
-
-# server TLSv1.1 HC128-MD5
--v 2
--l HC128-MD5
-
-# client TLSv1.1 HC128-MD5
--v 2
--l HC128-MD5
-
-# server TLSv1.1 HC128-B2B256
--v 2
--l HC128-B2B256
-
-# client TLSv1.1 HC128-B2B256
--v 2
--l HC128-B2B256
-
-# server TLSv1.1 AES128-B2B256
--v 2
--l AES128-B2B256
-
-# client TLSv1.1 AES128-B2B256
--v 2
--l AES128-B2B256
-
-# server TLSv1.1 AES256-B2B256
--v 2
--l AES256-B2B256
-
-# client TLSv1.1 AES256-B2B256
--v 2
--l AES256-B2B256
-
-# server TLSv1.2 HC128-SHA
--v 3
--l HC128-SHA
-
-# client TLSv1.2 HC128-SHA
--v 3
--l HC128-SHA
-
-# server TLSv1.2 HC128-MD5
--v 3
--l HC128-MD5
-
-# client TLSv1.2 HC128-MD5
--v 3
--l HC128-MD5
-
-# server TLSv1.2 HC128-B2B256
--v 3
--l HC128-B2B256
-
-# client TLSv1.2 HC128-B2B256
--v 3
--l HC128-B2B256
-
-# server TLSv1.2 AES128-B2B256
--v 3
--l AES128-B2B256
-
-# client TLSv1.2 AES128-B2B256
--v 3
--l AES128-B2B256
-
-# server TLSv1.2 AES256-B2B256
--v 3
--l AES256-B2B256
-
-# client TLSv1.2 AES256-B2B256
--v 3
--l AES256-B2B256
-
-# server TLSv1 RABBIT-SHA
--v 1
--l RABBIT-SHA
-
-# client TLSv1 RABBIT-SHA
--v 1
--l RABBIT-SHA
-
-# server TLSv1.1 RABBIT-SHA
--v 2
--l RABBIT-SHA
-
-# client TLSv1.1 RABBIT-SHA
--v 2
--l RABBIT-SHA
-
-# server TLSv1.2 RABBIT-SHA
--v 3
--l RABBIT-SHA
-
-# client TLSv1.2 RABBIT-SHA
--v 3
--l RABBIT-SHA
-
-# server TLSv1 NTRU_RC4
--v 1
--l NTRU-RC4-SHA
--n
--c ./certs/ntru-cert.pem
--k ./certs/ntru-key.raw
-
-# client TLSv1 NTRU_RC4
--v 1
--l NTRU-RC4-SHA
-
-# server TLSv1 NTRU_DES3
--v 1
--l NTRU-DES-CBC3-SHA
--n
--c ./certs/ntru-cert.pem
--k ./certs/ntru-key.raw
-
-# client TLSv1 NTRU_DES3
--v 1
--l NTRU-DES-CBC3-SHA
-
-# server TLSv1 NTRU_AES128
--v 1
--l NTRU-AES128-SHA
--n
--c ./certs/ntru-cert.pem
--k ./certs/ntru-key.raw
-
-# client TLSv1 NTRU_AES128
--v 1
--l NTRU-AES128-SHA
-
-# server TLSv1 NTRU_AES256
--v 1
--l NTRU-AES256-SHA
--n
--c ./certs/ntru-cert.pem
--k ./certs/ntru-key.raw
-
-# client TLSv1 NTRU_AES256
--v 1
--l NTRU-AES256-SHA
-
-# server TLSv1.1 NTRU_RC4
--v 2
--l NTRU-RC4-SHA
--n
--c ./certs/ntru-cert.pem
--k ./certs/ntru-key.raw
-
-# client TLSv1.1 NTRU_RC4
--v 2
--l NTRU-RC4-SHA
-
-# server TLSv1.1 NTRU_DES3
--v 2
--l NTRU-DES-CBC3-SHA
--n
--c ./certs/ntru-cert.pem
--k ./certs/ntru-key.raw
-
-# client TLSv1.1 NTRU_DES3
--v 2
--l NTRU-DES-CBC3-SHA
-
-# server TLSv1.1 NTRU_AES128
--v 2
--l NTRU-AES128-SHA
--n
--c ./certs/ntru-cert.pem
--k ./certs/ntru-key.raw
-
-# client TLSv1.1 NTRU_AES128
--v 2
--l NTRU-AES128-SHA
-
-# server TLSv1.1 NTRU_AES256
--v 2
--l NTRU-AES256-SHA
--n
--c ./certs/ntru-cert.pem
--k ./certs/ntru-key.raw
-
-# client TLSv1.1 NTRU_AES256
--v 2
--l NTRU-AES256-SHA
-
-# server TLSv1.2 NTRU_RC4
--v 3
--l NTRU-RC4-SHA
--n
--c ./certs/ntru-cert.pem
--k ./certs/ntru-key.raw
-
-# client TLSv1.2 NTRU_RC4
--v 3
--l NTRU-RC4-SHA
-
-# server TLSv1.2 NTRU_DES3
--v 3
--l NTRU-DES-CBC3-SHA
--n
--c ./certs/ntru-cert.pem
--k ./certs/ntru-key.raw
-
-# client TLSv1.2 NTRU_DES3
--v 3
--l NTRU-DES-CBC3-SHA
-
-# server TLSv1.2 NTRU_AES128
--v 3
--l NTRU-AES128-SHA
--n
--c ./certs/ntru-cert.pem
--k ./certs/ntru-key.raw
-
-# client TLSv1.2 NTRU_AES128
--v 3
--l NTRU-AES128-SHA
-
-# server TLSv1.2 NTRU_AES256
--v 3
--l NTRU-AES256-SHA
--n
--c ./certs/ntru-cert.pem
--k ./certs/ntru-key.raw
-
-# client TLSv1.2 NTRU_AES256
--v 3
--l NTRU-AES256-SHA
-
-# server TLSv1 DHE AES128
--v 1
--l DHE-RSA-AES128-SHA
-
-# client TLSv1 DHE AES128
--v 1
--l DHE-RSA-AES128-SHA
-
-# server TLSv1 DHE AES256
--v 1
--l DHE-RSA-AES256-SHA
-
-# client TLSv1 DHE AES256
--v 1
--l DHE-RSA-AES256-SHA
-
-# server TLSv1 DHE AES128-SHA256
--v 1
--l DHE-RSA-AES128-SHA256
-
-# client TLSv1 DHE AES128-SHA256
--v 1
--l DHE-RSA-AES128-SHA256
-
-# server TLSv1 DHE AES256-SHA256
--v 1
--l DHE-RSA-AES256-SHA256
-
-# client TLSv1 DHE AES256-SHA256
--v 1
--l DHE-RSA-AES256-SHA256
-
-# server TLSv1.1 DHE AES128
--v 2
--l DHE-RSA-AES128-SHA
-
-# client TLSv1.1 DHE AES128
--v 2
--l DHE-RSA-AES128-SHA
-
-# server TLSv1.1 DHE AES256
--v 2
--l DHE-RSA-AES256-SHA
-
-# client TLSv1.1 DHE AES256
--v 2
--l DHE-RSA-AES256-SHA
-
-# server TLSv1.1 DHE AES128-SHA256
--v 2
--l DHE-RSA-AES128-SHA256
-
-# client TLSv1.1 DHE AES128-SHA256
--v 2
--l DHE-RSA-AES128-SHA256
-
-# server TLSv1.1 DHE AES256-SHA256
--v 2
--l DHE-RSA-AES256-SHA256
-
-# client TLSv1.1 DHE AES256-SHA256
--v 2
--l DHE-RSA-AES256-SHA256
-
-# server TLSv1.2 DHE AES128
--v 3
--l DHE-RSA-AES128-SHA
-
-# client TLSv1.2 DHE AES128
--v 3
--l DHE-RSA-AES128-SHA
-
-# server TLSv1.2 DHE AES256
--v 3
--l DHE-RSA-AES256-SHA
-
-# client TLSv1.2 DHE AES256
--v 3
--l DHE-RSA-AES256-SHA
-
-# server TLSv1.2 DHE AES128-SHA256
--v 3
--l DHE-RSA-AES128-SHA256
-
-# client TLSv1.2 DHE AES128-SHA256
--v 3
--l DHE-RSA-AES128-SHA256
-
-# server TLSv1.2 DHE AES256-SHA256
--v 3
--l DHE-RSA-AES256-SHA256
-
-# client TLSv1.2 DHE AES256-SHA256
--v 3
--l DHE-RSA-AES256-SHA256
-
-# server TLSv1 PSK-AES128
--s
--v 1
--l PSK-AES128-CBC-SHA
-
-# client TLSv1 PSK-AES128
--s
--v 1
--l PSK-AES128-CBC-SHA
-
-# server TLSv1 PSK-AES256
--s
--v 1
--l PSK-AES256-CBC-SHA
-
-# client TLSv1 PSK-AES256
--s
--v 1
--l PSK-AES256-CBC-SHA
-
-# server TLSv1.1 PSK-AES128
--s
--v 2
--l PSK-AES128-CBC-SHA
-
-# client TLSv1.1 PSK-AES128
--s
--v 2
--l PSK-AES128-CBC-SHA
-
-# server TLSv1.1 PSK-AES256
--s
--v 2
--l PSK-AES256-CBC-SHA
-
-# client TLSv1.1 PSK-AES256
--s
--v 2
--l PSK-AES256-CBC-SHA
-
-# server TLSv1.2 PSK-AES128
--s
--v 3
--l PSK-AES128-CBC-SHA
-
-# client TLSv1.2 PSK-AES128
--s
--v 3
--l PSK-AES128-CBC-SHA
-
-# server TLSv1.2 PSK-AES256
--s
--v 3
--l PSK-AES256-CBC-SHA
-
-# client TLSv1.2 PSK-AES256
--s
--v 3
--l PSK-AES256-CBC-SHA
-
-# server TLSv1.0 PSK-AES128-SHA256
--s
--v 1
--l PSK-AES128-CBC-SHA256
-
-# client TLSv1.0 PSK-AES128-SHA256
--s
--v 1
--l PSK-AES128-CBC-SHA256
-
-# server TLSv1.1 PSK-AES128-SHA256
--s
--v 2
--l PSK-AES128-CBC-SHA256
-
-# client TLSv1.1 PSK-AES128-SHA256
--s
--v 2
--l PSK-AES128-CBC-SHA256
-
-# server TLSv1.2 PSK-AES128-SHA256
--s
--v 3
--l PSK-AES128-CBC-SHA256
-
-# client TLSv1.2 PSK-AES128-SHA256
--s
--v 3
--l PSK-AES128-CBC-SHA256
-
-# server TLSv1.0 PSK-AES256-SHA384
--s
--v 1
--l PSK-AES256-CBC-SHA384
-
-# client TLSv1.0 PSK-AES256-SHA384
--s
--v 1
--l PSK-AES256-CBC-SHA384
-
-# server TLSv1.1 PSK-AES256-SHA384
--s
--v 2
--l PSK-AES256-CBC-SHA384
-
-# client TLSv1.1 PSK-AES256-SHA384
--s
--v 2
--l PSK-AES256-CBC-SHA384
-
-# server TLSv1.2 PSK-AES256-SHA384
--s
--v 3
--l PSK-AES256-CBC-SHA384
-
-# client TLSv1.2 PSK-AES256-SHA384
--s
--v 3
--l PSK-AES256-CBC-SHA384
-
-# server TLSv1.0 PSK-NULL
--s
--v 1
--l PSK-NULL-SHA
-
-# client TLSv1.0 PSK-NULL
--s
--v 1
--l PSK-NULL-SHA
-
-# server TLSv1.1 PSK-NULL
--s
--v 2
--l PSK-NULL-SHA
-
-# client TLSv1.1 PSK-NULL
--s
--v 2
--l PSK-NULL-SHA
-
-# server TLSv1.2 PSK-NULL
--s
--v 3
--l PSK-NULL-SHA
-
-# client TLSv1.2 PSK-NULL
--s
--v 3
--l PSK-NULL-SHA
-
-# server TLSv1.2 PSK-NULL-SHA256
--s
--v 3
--l PSK-NULL-SHA256
-
-# client TLSv1.2 PSK-NULL-SHA256
--s
--v 3
--l PSK-NULL-SHA256
-
-# server TLSv1.2 PSK-NULL-SHA384
--s
--v 3
--l PSK-NULL-SHA384
-
-# client TLSv1.2 PSK-NULL-SHA384
--s
--v 3
--l PSK-NULL-SHA384
-
-# server TLSv1.2 PSK-NULL
--s
--v 3
--l PSK-NULL-SHA
-
-# client TLSv1.2 PSK-NULL
--s
--v 3
--l PSK-NULL-SHA
-
-# server TLSv1.2 PSK-NULL-SHA256
--s
--v 3
--l PSK-NULL-SHA256
-
-# client TLSv1.2 PSK-NULL-SHA256
--s
--v 3
--l PSK-NULL-SHA256
-
-# server TLSv1.0 RSA-NULL-SHA
--v 1
--l NULL-SHA
-
-# client TLSv1.0 RSA-NULL-SHA
--v 1
--l NULL-SHA
-
-# server TLSv1.1 RSA-NULL-SHA
--v 2
--l NULL-SHA
-
-# client TLSv1.1 RSA-NULL-SHA
--v 2
--l NULL-SHA
-
-# server TLSv1.2 RSA-NULL-SHA
--v 3
--l NULL-SHA
-
-# client TLSv1.2 RSA-NULL-SHA
--v 3
--l NULL-SHA
-
-# server TLSv1.0 RSA-NULL-SHA256
--v 1
--l NULL-SHA256
-
-# client TLSv1.0 RSA-NULL-SHA256
--v 1
--l NULL-SHA256
-
-# server TLSv1.1 RSA-NULL-SHA256
--v 2
--l NULL-SHA256
-
-# client TLSv1.1 RSA-NULL-SHA256
--v 2
--l NULL-SHA256
-
-# server TLSv1.2 RSA-NULL-SHA256
--v 3
--l NULL-SHA256
-
-# client TLSv1.2 RSA-NULL-SHA256
--v 3
--l NULL-SHA256
-
-# server TLSv1 CAMELLIA128-SHA
--v 1
--l CAMELLIA128-SHA
-
-# client TLSv1 CAMELLIA128-SHA
--v 1
--l CAMELLIA128-SHA
-
-# server TLSv1 CAMELLIA256-SHA
--v 1
--l CAMELLIA256-SHA
-
-# client TLSv1 CAMELLIA256-SHA
--v 1
--l CAMELLIA256-SHA
-
-# server TLSv1 CAMELLIA128-SHA256
--v 1
--l CAMELLIA128-SHA256
-
-# client TLSv1 CAMELLIA128-SHA256
--v 1
--l CAMELLIA128-SHA256
-
-# server TLSv1 CAMELLIA256-SHA256
--v 1
--l CAMELLIA256-SHA256
-
-# client TLSv1 CAMELLIA256-SHA256
--v 1
--l CAMELLIA256-SHA256
-
-# server TLSv1.1 CAMELLIA128-SHA
--v 2
--l CAMELLIA128-SHA
-
-# client TLSv1.1 CAMELLIA128-SHA
--v 2
--l CAMELLIA128-SHA
-
-# server TLSv1.1 CAMELLIA256-SHA
--v 2
--l CAMELLIA256-SHA
-
-# client TLSv1.1 CAMELLIA256-SHA
--v 2
--l CAMELLIA256-SHA
-
-# server TLSv1.1 CAMELLIA128-SHA256
--v 2
--l CAMELLIA128-SHA256
-
-# client TLSv1.1 CAMELLIA128-SHA256
--v 2
--l CAMELLIA128-SHA256
-
-# server TLSv1.1 CAMELLIA256-SHA256
--v 2
--l CAMELLIA256-SHA256
-
-# client TLSv1.1 CAMELLIA256-SHA256
--v 2
--l CAMELLIA256-SHA256
-
-# server TLSv1.2 CAMELLIA128-SHA
--v 3
--l CAMELLIA128-SHA
-
-# client TLSv1.2 CAMELLIA128-SHA
--v 3
--l CAMELLIA128-SHA
-
-# server TLSv1.2 CAMELLIA256-SHA
--v 3
--l CAMELLIA256-SHA
-
-# client TLSv1.2 CAMELLIA256-SHA
--v 3
--l CAMELLIA256-SHA
-
-# server TLSv1.2 CAMELLIA128-SHA256
--v 3
--l CAMELLIA128-SHA256
-
-# client TLSv1.2 CAMELLIA128-SHA256
--v 3
--l CAMELLIA128-SHA256
-
-# server TLSv1.2 CAMELLIA256-SHA256
--v 3
--l CAMELLIA256-SHA256
-
-# client TLSv1.2 CAMELLIA256-SHA256
--v 3
--l CAMELLIA256-SHA256
-
-# server TLSv1 DHE-RSA-CAMELLIA128-SHA
--v 1
--l DHE-RSA-CAMELLIA128-SHA
-
-# client TLSv1 DHE-RSA-CAMELLIA128-SHA
--v 1
--l DHE-RSA-CAMELLIA128-SHA
-
-# server TLSv1 DHE-RSA-CAMELLIA256-SHA
--v 1
--l DHE-RSA-CAMELLIA256-SHA
-
-# client TLSv1 DHE-RSA-CAMELLIA256-SHA
--v 1
--l DHE-RSA-CAMELLIA256-SHA
-
-# server TLSv1 DHE-RSA-CAMELLIA128-SHA256
--v 1
--l DHE-RSA-CAMELLIA128-SHA256
-
-# client TLSv1 DHE-RSA-CAMELLIA128-SHA256
--v 1
--l DHE-RSA-CAMELLIA128-SHA256
-
-# server TLSv1 DHE-RSA-CAMELLIA256-SHA256
--v 1
--l DHE-RSA-CAMELLIA256-SHA256
-
-# client TLSv1 DHE-RSA-CAMELLIA256-SHA256
--v 1
--l DHE-RSA-CAMELLIA256-SHA256
-
-# server TLSv1.1 DHE-RSA-CAMELLIA128-SHA
--v 2
--l DHE-RSA-CAMELLIA128-SHA
-
-# client TLSv1.1 DHE-RSA-CAMELLIA128-SHA
--v 2
--l DHE-RSA-CAMELLIA128-SHA
-
-# server TLSv1.1 DHE-RSA-CAMELLIA256-SHA
--v 2
--l DHE-RSA-CAMELLIA256-SHA
-
-# client TLSv1.1 DHE-RSA-CAMELLIA256-SHA
--v 2
--l DHE-RSA-CAMELLIA256-SHA
-
-# server TLSv1.1 DHE-RSA-CAMELLIA128-SHA256
--v 2
--l DHE-RSA-CAMELLIA128-SHA256
-
-# client TLSv1.1 DHE-RSA-CAMELLIA128-SHA256
--v 2
--l DHE-RSA-CAMELLIA128-SHA256
-
-# server TLSv1.1 DHE-RSA-CAMELLIA256-SHA256
--v 2
--l DHE-RSA-CAMELLIA256-SHA256
-
-# client TLSv1.1 DHE-RSA-CAMELLIA256-SHA256
--v 2
--l DHE-RSA-CAMELLIA256-SHA256
-
-# server TLSv1.2 DHE-RSA-CAMELLIA128-SHA
--v 3
--l DHE-RSA-CAMELLIA128-SHA
-
-# client TLSv1.2 DHE-RSA-CAMELLIA128-SHA
--v 3
--l DHE-RSA-CAMELLIA128-SHA
-
-# server TLSv1.2 DHE-RSA-CAMELLIA256-SHA
--v 3
--l DHE-RSA-CAMELLIA256-SHA
-
-# client TLSv1.2 DHE-RSA-CAMELLIA256-SHA
--v 3
--l DHE-RSA-CAMELLIA256-SHA
-
-# server TLSv1.2 DHE-RSA-CAMELLIA128-SHA256
--v 3
--l DHE-RSA-CAMELLIA128-SHA256
-
-# client TLSv1.2 DHE-RSA-CAMELLIA128-SHA256
--v 3
--l DHE-RSA-CAMELLIA128-SHA256
-
-# server TLSv1.2 DHE-RSA-CAMELLIA256-SHA256
--v 3
--l DHE-RSA-CAMELLIA256-SHA256
-
-# client TLSv1.2 DHE-RSA-CAMELLIA256-SHA256
--v 3
--l DHE-RSA-CAMELLIA256-SHA256
-
-# server TLSv1.2 RSA-AES128-GCM-SHA256 
--v 3
--l AES128-GCM-SHA256
-
-# client TLSv1.2 RSA-AES128-GCM-SHA256 
--v 3
--l AES128-GCM-SHA256
-
-# server TLSv1.2 RSA-AES256-GCM-SHA384
--v 3
--l AES256-GCM-SHA384
-
-# client TLSv1.2 RSA-AES256-GCM-SHA384
--v 3
--l AES256-GCM-SHA384
-
-# server TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 
--v 3
--l ECDHE-ECDSA-AES128-GCM-SHA256
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 
--v 3
--l ECDHE-ECDSA-AES128-GCM-SHA256
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384
--v 3
--l ECDHE-ECDSA-AES256-GCM-SHA384
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384
--v 3
--l ECDHE-ECDSA-AES256-GCM-SHA384
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDH-ECDSA-AES128-GCM-SHA256 
--v 3
--l ECDH-ECDSA-AES128-GCM-SHA256
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-ECDSA-AES128-GCM-SHA256 
--v 3
--l ECDH-ECDSA-AES128-GCM-SHA256
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDH-ECDSA-AES256-GCM-SHA384
--v 3
--l ECDH-ECDSA-AES256-GCM-SHA384
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-ECDSA-AES256-GCM-SHA384
--v 3
--l ECDH-ECDSA-AES256-GCM-SHA384
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 
--v 3
--l ECDHE-RSA-AES128-GCM-SHA256
-
-# client TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 
--v 3
--l ECDHE-RSA-AES128-GCM-SHA256
-
-# server TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384
--v 3
--l ECDHE-RSA-AES256-GCM-SHA384
-
-# client TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384
--v 3
--l ECDHE-RSA-AES256-GCM-SHA384
-
-# server TLSv1.2 ECDH-RSA-AES128-GCM-SHA256 
--v 3
--l ECDH-RSA-AES128-GCM-SHA256
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-RSA-AES128-GCM-SHA256 
--v 3
--l ECDH-RSA-AES128-GCM-SHA256
-
-# server TLSv1.2 ECDH-RSA-AES256-GCM-SHA384
--v 3
--l ECDH-RSA-AES256-GCM-SHA384
--c ./certs/server-ecc-rsa.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDH-RSA-AES256-GCM-SHA384
--v 3
--l ECDH-RSA-AES256-GCM-SHA384
-
-# server TLSv1.2 DHE-RSA-AES128-GCM-SHA256 
--v 3
--l DHE-RSA-AES128-GCM-SHA256
-
-# client TLSv1.2 DHE-RSA-AES128-GCM-SHA256 
--v 3
--l DHE-RSA-AES128-GCM-SHA256
-
-# server TLSv1.2 DHE-RSA-AES256-GCM-SHA384
--v 3
--l DHE-RSA-AES256-GCM-SHA384
-
-# client TLSv1.2 DHE-RSA-AES256-GCM-SHA384
--v 3
--l DHE-RSA-AES256-GCM-SHA384
-
-# server TLSv1.2 PSK-AES128-GCM-SHA256
--s
--v 3
--l PSK-AES128-GCM-SHA256
-
-# client TLSv1.2 PSK-AES128-GCM-SHA256
--s
--v 3
--l PSK-AES128-GCM-SHA256
-
-# server TLSv1.2 PSK-AES256-GCM-SHA384
--s
--v 3
--l PSK-AES256-GCM-SHA384
-
-# client TLSv1.2 PSK-AES256-GCM-SHA384
--s
--v 3
--l PSK-AES256-GCM-SHA384
-
-# server TLSv1.2 AES128-CCM-8
--v 3
--l AES128-CCM-8
-
-# client TLSv1.2 AES128-CCM-8
--v 3
--l AES128-CCM-8
-
-# server TLSv1.2 AES256-CCM-8
--v 3
--l AES256-CCM-8
-
-# client TLSv1.2 AES256-CCM-8
--v 3
--l AES256-CCM-8
-
-# server TLSv1.2 ECDHE-ECDSA-AES128-CCM-8
--v 3
--l ECDHE-ECDSA-AES128-CCM-8
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDHE-ECDSA-AES128-CCM-8
--v 3
--l ECDHE-ECDSA-AES128-CCM-8
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 ECDHE-ECDSA-AES256-CCM-8
--v 3
--l ECDHE-ECDSA-AES256-CCM-8
--c ./certs/server-ecc.pem
--k ./certs/ecc-key.pem
-
-# client TLSv1.2 ECDHE-ECDSA-AES256-CCM-8
--v 3
--l ECDHE-ECDSA-AES256-CCM-8
--A ./certs/server-ecc.pem
-
-# server TLSv1.2 PSK-AES128-CCM
--s
--v 3
--l PSK-AES128-CCM
-
-# client TLSv1.2 PSK-AES128-CCM
--s
--v 3
--l PSK-AES128-CCM
-
-# server TLSv1.2 PSK-AES256-CCM
--s
--v 3
--l PSK-AES256-CCM
-
-# client TLSv1.2 PSK-AES256-CCM
--s
--v 3
--l PSK-AES256-CCM
-
-# server TLSv1.2 PSK-AES128-CCM-8
--s
--v 3
--l PSK-AES128-CCM-8
-
-# client TLSv1.2 PSK-AES128-CCM-8
--s
--v 3
--l PSK-AES128-CCM-8
-
-# server TLSv1.2 PSK-AES256-CCM-8
--s
--v 3
--l PSK-AES256-CCM-8
-
-# client TLSv1.2 PSK-AES256-CCM-8
--s
--v 3
--l PSK-AES256-CCM-8
-
-# server TLSv1.0 DHE-PSK-AES128-CBC-SHA256
--s
--v 1
--l DHE-PSK-AES128-CBC-SHA256
-
-# client TLSv1.0 DHE-PSK-AES128-CBC-SHA256
--s
--v 1
--l DHE-PSK-AES128-CBC-SHA256
-
-# server TLSv1.1 DHE-PSK-AES128-CBC-SHA256
--s
--v 2
--l DHE-PSK-AES128-CBC-SHA256
-
-# client TLSv1.1 DHE-PSK-AES128-CBC-SHA256
--s
--v 2
--l DHE-PSK-AES128-CBC-SHA256
-
-# server TLSv1.2 DHE-PSK-AES128-CBC-SHA256
--s
--v 3
--l DHE-PSK-AES128-CBC-SHA256
-
-# client TLSv1.2 DHE-PSK-AES128-CBC-SHA256
--s
--v 3
--l DHE-PSK-AES128-CBC-SHA256
-
-# server TLSv1.0 DHE-PSK-AES256-CBC-SHA384
--s
--v 1
--l DHE-PSK-AES256-CBC-SHA384
-
-# client TLSv1.0 DHE-PSK-AES256-CBC-SHA384
--s
--v 1
--l DHE-PSK-AES256-CBC-SHA384
-
-# server TLSv1.1 DHE-PSK-AES256-CBC-SHA384
--s
--v 2
--l DHE-PSK-AES256-CBC-SHA384
-
-# client TLSv1.1 DHE-PSK-AES256-CBC-SHA384
--s
--v 2
--l DHE-PSK-AES256-CBC-SHA384
-
-# server TLSv1.2 DHE-PSK-AES256-CBC-SHA384
--s
--v 3
--l DHE-PSK-AES256-CBC-SHA384
-
-# client TLSv1.2 DHE-PSK-AES256-CBC-SHA384
--s
--v 3
--l DHE-PSK-AES256-CBC-SHA384
-
-# server TLSv1.0 DHE-PSK-NULL-SHA256
--s
--v 1
--l DHE-PSK-NULL-SHA256
-
-# client TLSv1.0 DHE-PSK-NULL-SHA256
--s
--v 1
--l DHE-PSK-NULL-SHA256
-
-# server TLSv1.1 DHE-PSK-NULL-SHA256
--s
--v 2
--l DHE-PSK-NULL-SHA256
-
-# client TLSv1.1 DHE-PSK-NULL-SHA256
--s
--v 2
--l DHE-PSK-NULL-SHA256
-
-# server TLSv1.2 DHE-PSK-NULL-SHA256
--s
--v 3
--l DHE-PSK-NULL-SHA256
-
-# client TLSv1.2 DHE-PSK-NULL-SHA256
--s
--v 3
--l DHE-PSK-NULL-SHA256
-
-# server TLSv1.0 DHE-PSK-NULL-SHA384
--s
--v 1
--l DHE-PSK-NULL-SHA384
-
-# client TLSv1.0 DHE-PSK-NULL-SHA384
--s
--v 1
--l DHE-PSK-NULL-SHA384
-
-# server TLSv1.1 DHE-PSK-NULL-SHA384
--s
--v 2
--l DHE-PSK-NULL-SHA384
-
-# client TLSv1.1 DHE-PSK-NULL-SHA384
--s
--v 2
--l DHE-PSK-NULL-SHA384
-
-# server TLSv1.2 DHE-PSK-NULL-SHA384
--s
--v 3
--l DHE-PSK-NULL-SHA384
-
-# client TLSv1.2 DHE-PSK-NULL-SHA384
--s
--v 3
--l DHE-PSK-NULL-SHA384
-
-# server TLSv1.2 DHE-PSK-AES128-GCM-SHA256
--s
--v 3
--l DHE-PSK-AES128-GCM-SHA256
-
-# client TLSv1.2 DHE-PSK-AES128-GCM-SHA256
--s
--v 3
--l DHE-PSK-AES128-GCM-SHA256
-
-# server TLSv1.2 DHE-PSK-AES256-GCM-SHA384
--s
--v 3
--l DHE-PSK-AES256-GCM-SHA384
-
-# client TLSv1.2 DHE-PSK-AES256-GCM-SHA384
--s
--v 3
--l DHE-PSK-AES256-GCM-SHA384
-
-# server TLSv1.2 DHE-PSK-AES128-CCM
--s
--v 3
--l DHE-PSK-AES128-CCM
-
-# client TLSv1.2 DHE-PSK-AES128-CCM
--s
--v 3
--l DHE-PSK-AES128-CCM
-
-# server TLSv1.2 DHE-PSK-AES256-CCM
--s
--v 3
--l DHE-PSK-AES256-CCM
-
-# client TLSv1.2 DHE-PSK-AES256-CCM
--s
--v 3
--l DHE-PSK-AES256-CCM
-
-# server TLSv1.2 ADH-AES128-SHA
--a
--v 3
--l ADH-AES128-SHA
-
-# client TLSv1.2 ADH-AES128-SHA
--a
--v 3
--l ADH-AES128-SHA
-
-# server TLSv1.1 ADH-AES128-SHA
--a
--v 2
--l ADH-AES128-SHA
-
-# client TLSv1.1 ADH-AES128-SHA
--a
--v 2
--l ADH-AES128-SHA
-
-# server TLSv1.0 ADH-AES128-SHA
--a
--v 1
--l ADH-AES128-SHA
-
-# client TLSv1.0 ADH-AES128-SHA
--a
--v 1
--l ADH-AES128-SHA
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/tests/unit.c b/FreeRTOS-Plus/Source/WolfSSL/tests/unit.c
deleted file mode 100755
index d66f84c..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/tests/unit.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/* unit.c unit tests driver */
-
-/* Name change compatibility layer no longer need to be included here */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#include 
-#include 
-
-
-int myoptind = 0;
-char* myoptarg = NULL;
-int unit_test(int argc, char** argv);
-
-#ifndef NO_TESTSUITE_MAIN_DRIVER
-int main(int argc, char** argv)
-{
-    return unit_test(argc, argv);
-}
-#endif
-
-int unit_test(int argc, char** argv)
-{
-    int ret;
-
-    (void)argc;
-    (void)argv;
-    printf("starting unit tests...\n");
-
-#ifdef HAVE_CAVIUM
-    ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID);
-    if (ret != 0)
-        err_sys("Cavium OpenNitroxDevice failed");
-#endif /* HAVE_CAVIUM */
-
-#ifndef WOLFSSL_TIRTOS
-    if (CurrentDir("tests") || CurrentDir("_build"))
-        ChangeDirBack(1);
-    else if (CurrentDir("Debug") || CurrentDir("Release"))
-        ChangeDirBack(3);
-#endif
-
-    ApiTest();
-
-    if ( (ret = HashTest()) != 0){
-        printf("hash test failed with %d\n", ret);
-        return ret;
-    }
-
-#ifndef SINGLE_THREADED
-    if ( (ret = SuiteTest()) != 0){
-        printf("suite test failed with %d\n", ret);
-        return ret;
-    }
-#endif
-
-#ifdef HAVE_CAVIUM
-        CspShutdown(CAVIUM_DEV_ID);
-#endif
-
-    return 0;
-}
-
-
-
-void wait_tcp_ready(func_args* args)
-{
-#ifdef SINGLE_THREADED
-    (void)args;
-#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
-    pthread_mutex_lock(&args->signal->mutex);
-    
-    if (!args->signal->ready)
-        pthread_cond_wait(&args->signal->cond, &args->signal->mutex);
-    args->signal->ready = 0; /* reset */
-
-    pthread_mutex_unlock(&args->signal->mutex);
-#else
-    (void)args;
-#endif
-}
-
-
-void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
-{
-#ifdef SINGLE_THREADED
-    (void)fun;
-    (void)args;
-    (void)thread;
-#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
-    pthread_create(thread, 0, fun, args);
-    return;
-#elif defined (WOLFSSL_TIRTOS)
-    /* Initialize the defaults and set the parameters. */
-    Task_Params taskParams;
-    Task_Params_init(&taskParams);
-    taskParams.arg0 = (UArg)args;
-    taskParams.stackSize = 65535;
-    *thread = Task_create((Task_FuncPtr)fun, &taskParams, NULL);
-    if (*thread == NULL) {
-        printf("Failed to create new Task\n");
-    }
-    Task_yield();
-#else
-    *thread = (THREAD_TYPE)_beginthreadex(0, 0, fun, args, 0, 0);
-#endif
-}
-
-
-void join_thread(THREAD_TYPE thread)
-{
-#ifdef SINGLE_THREADED
-    (void)thread;
-#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
-    pthread_join(thread, 0);
-#elif defined (WOLFSSL_TIRTOS)
-    while(1) {
-        if (Task_getMode(thread) == Task_Mode_TERMINATED) {
-            Task_sleep(5);
-            break;
-        }
-        Task_yield();
-    }
-#else
-    int res = WaitForSingleObject((HANDLE)thread, INFINITE);
-    assert(res == WAIT_OBJECT_0);
-    res = CloseHandle((HANDLE)thread);
-    assert(res);
-#endif
-}
-
-
-void InitTcpReady(tcp_ready* ready)
-{
-    ready->ready = 0;
-    ready->port = 0;
-#ifdef SINGLE_THREADED
-#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
-      pthread_mutex_init(&ready->mutex, 0);
-      pthread_cond_init(&ready->cond, 0);
-#endif
-}
-
-
-void FreeTcpReady(tcp_ready* ready)
-{
-#ifdef SINGLE_THREADED
-    (void)ready;
-#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
-    pthread_mutex_destroy(&ready->mutex);
-    pthread_cond_destroy(&ready->cond);
-#else
-    (void)ready;
-#endif
-}
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/tests/unit.h b/FreeRTOS-Plus/Source/WolfSSL/tests/unit.h
deleted file mode 100755
index ab8fbc2..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/tests/unit.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* unit.h unit tests driver */
-
-#ifndef CyaSSL_UNIT_H
-#define CyaSSL_UNIT_H
-
-#include 
-#include     /* thread and tcp stuff */
-
-#define Fail(description, result) do {                                         \
-    printf("\nERROR - %s line %d failed with:", __FILE__, __LINE__);           \
-    printf("\n\n    test:   "); printf description;                            \
-    printf("\n\n    result: "); printf result;                                 \
-    abort();                                                                   \
-} while(0)
-
-#define Assert(test, description, result) if (!(test)) Fail(description, result)
-
-#define AssertTrue(x)    Assert( (x), ("%s is true",     #x), (#x " => FALSE"))
-#define AssertFalse(x)   Assert(!(x), ("%s is false",    #x), (#x " => TRUE"))
-#define AssertNotNull(x) Assert( (x), ("%s is not null", #x), (#x " => NULL"))
-
-#define AssertNull(x) do {                                                     \
-    void* _x = (void *) (x);                                                   \
-                                                                               \
-    Assert(!_x, ("%s is null", #x), (#x " => %p", _x));                        \
-} while(0)
-
-#define AssertInt(x, y, op, er) do {                                           \
-    int _x = x;                                                                \
-    int _y = y;                                                                \
-                                                                               \
-    Assert(_x op _y, ("%s " #op " %s", #x, #y), ("%d " #er " %d", _x, _y));    \
-} while(0)
-
-#define AssertIntEQ(x, y) AssertInt(x, y, ==, !=)
-#define AssertIntNE(x, y) AssertInt(x, y, !=, ==)
-#define AssertIntGT(x, y) AssertInt(x, y,  >, <=)
-#define AssertIntLT(x, y) AssertInt(x, y,  <, >=)
-#define AssertIntGE(x, y) AssertInt(x, y, >=,  <)
-#define AssertIntLE(x, y) AssertInt(x, y, <=,  >)
-
-#define AssertStr(x, y, op, er) do {                                           \
-    const char* _x = x;                                                        \
-    const char* _y = y;                                                        \
-    int   _z = strcmp(_x, _y);                                                 \
-                                                                               \
-    Assert(_z op 0, ("%s " #op " %s", #x, #y),                                 \
-                                            ("\"%s\" " #er " \"%s\"", _x, _y));\
-} while(0)
-
-#define AssertStrEQ(x, y) AssertStr(x, y, ==, !=)
-#define AssertStrNE(x, y) AssertStr(x, y, !=, ==)
-#define AssertStrGT(x, y) AssertStr(x, y,  >, <=)
-#define AssertStrLT(x, y) AssertStr(x, y,  <, >=)
-#define AssertStrGE(x, y) AssertStr(x, y, >=,  <)
-#define AssertStrLE(x, y) AssertStr(x, y, <=,  >)
-
-
-void ApiTest(void);
-int SuiteTest(void);
-int HashTest(void);
-
-
-#endif /* CyaSSL_UNIT_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/testsuite/include.am b/FreeRTOS-Plus/Source/WolfSSL/testsuite/include.am
deleted file mode 100755
index 62edb4a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/testsuite/include.am
+++ /dev/null
@@ -1,26 +0,0 @@
-# vim:ft=automake
-# included from Top Level Makefile.am
-# All paths should be given relative to the root
-
-
-if BUILD_EXAMPLES
-check_PROGRAMS += testsuite/testsuite.test
-noinst_PROGRAMS += testsuite/testsuite.test
-testsuite_testsuite_test_SOURCES = \
-			      wolfcrypt/test/test.c \
-			      examples/client/client.c \
-			      examples/echoclient/echoclient.c \
-			      examples/echoserver/echoserver.c \
-			      examples/server/server.c \
-			      testsuite/testsuite.c
-testsuite_testsuite_test_CFLAGS       = -DNO_MAIN_DRIVER $(AM_CFLAGS)
-testsuite_testsuite_test_LDADD        = src/libwolfssl.la
-testsuite_testsuite_test_DEPENDENCIES = src/libwolfssl.la
-endif
-EXTRA_DIST += testsuite/testsuite.sln
-EXTRA_DIST += testsuite/testsuite-ntru.vcproj
-EXTRA_DIST += testsuite/testsuite.vcproj
-EXTRA_DIST += testsuite/testsuite.vcxproj
-EXTRA_DIST += input
-EXTRA_DIST += quit
-DISTCLEANFILES+= testsuite/.libs/testsuite.test
diff --git a/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite-ntru.vcproj b/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite-ntru.vcproj
deleted file mode 100755
index 72499c8..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite-ntru.vcproj
+++ /dev/null
@@ -1,219 +0,0 @@
-
-
-	
-		
-	
-	
-	
-	
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-	
-	
-	
-	
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-		
-		
-		
-		
-	
-	
-	
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite.c b/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite.c
deleted file mode 100755
index 4146878..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite.c
+++ /dev/null
@@ -1,445 +0,0 @@
-/* testsuite.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#include 
-#include 
-#include "wolfcrypt/test/test.h"
-
-#ifndef SINGLE_THREADED
-
-#include 
-#include 
-
-#include "examples/echoclient/echoclient.h"
-#include "examples/echoserver/echoserver.h"
-#include "examples/server/server.h"
-#include "examples/client/client.h"
-
-
-void file_test(const char* file, byte* hash);
-
-void simple_test(func_args*);
-
-enum {
-    NUMARGS = 3
-};
-
-static const char *outputName;
-
-int myoptind = 0;
-char* myoptarg = NULL;
-
-
-#ifndef NO_TESTSUITE_MAIN_DRIVER
-
-    static int testsuite_test(int argc, char** argv);
-
-    int main(int argc, char** argv)
-    {
-        return testsuite_test(argc, argv);
-    }
-
-#endif /* NO_TESTSUITE_MAIN_DRIVER */
-
-
-int testsuite_test(int argc, char** argv)
-{
-    func_args server_args;
-
-    tcp_ready ready;
-    THREAD_TYPE serverThread;
-
-#ifndef USE_WINDOWS_API
-    char tempName[] = "/tmp/output-XXXXXX";
-    int len = 18;
-    int num = 6;
-#else
-    char tempName[] = "fnXXXXXX";
-    int len = 8;
-    int num = 6;
-#endif
-
-#ifdef HAVE_CAVIUM
-        int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID);
-        if (ret != 0)
-            err_sys("Cavium OpenNitroxDevice failed");
-#endif /* HAVE_CAVIUM */
-
-    StartTCP();
-
-    server_args.argc = argc;
-    server_args.argv = argv;
-
-    wolfSSL_Init();
-#if defined(DEBUG_WOLFSSL) && !defined(HAVE_VALGRIND)
-    wolfSSL_Debugging_ON();
-#endif
-
-#if !defined(WOLFSSL_TIRTOS)
-    if (CurrentDir("testsuite") || CurrentDir("_build"))
-        ChangeDirBack(1);
-    else if (CurrentDir("Debug") || CurrentDir("Release"))
-        ChangeDirBack(3);          /* Xcode->Preferences->Locations->Locations*/
-                                   /* Derived Data Advanced -> Custom  */
-                                   /* Relative to Workspace, Build/Products */
-                                   /* Debug or Release */
-#endif
-
-#ifdef WOLFSSL_TIRTOS
-    fdOpenSession(Task_self());
-#endif
-
-    server_args.signal = &ready;
-    InitTcpReady(&ready);
-
-    /* wc_ test */
-    wolfcrypt_test(&server_args);
-    if (server_args.return_code != 0) return server_args.return_code;
- 
-    /* Simple wolfSSL client server test */
-    simple_test(&server_args);
-    if (server_args.return_code != 0) return server_args.return_code;
-
-    /* Echo input wolfSSL client server test */
-    start_thread(echoserver_test, &server_args, &serverThread);
-    wait_tcp_ready(&server_args);
-    {
-        func_args echo_args;
-        char* myArgv[NUMARGS];
-
-        char argc0[32];
-        char argc1[32];
-        char argc2[32];
-
-        myArgv[0] = argc0;
-        myArgv[1] = argc1;
-        myArgv[2] = argc2;
-
-        echo_args.argc = 3;
-        echo_args.argv = myArgv;
-
-        /* Create unique file name */
-        outputName = mymktemp(tempName, len, num);
-        if (outputName == NULL) {
-            printf("Could not create unique file name");
-            return EXIT_FAILURE;
-        }
-
-        strcpy(echo_args.argv[0], "echoclient");
-        strcpy(echo_args.argv[1], "input");
-        strcpy(echo_args.argv[2], outputName);
-
-        /* Share the signal, it has the new port number in it. */
-        echo_args.signal = server_args.signal;
-
-        /* make sure OK */
-        echoclient_test(&echo_args);
-        if (echo_args.return_code != 0) return echo_args.return_code;
-
-#ifdef WOLFSSL_DTLS
-        wait_tcp_ready(&server_args);
-#endif
-        /* send quit to echoserver */
-        echo_args.argc = 2;
-        strcpy(echo_args.argv[1], "quit");
-
-        echoclient_test(&echo_args);
-        if (echo_args.return_code != 0) return echo_args.return_code;
-        join_thread(serverThread);
-        if (server_args.return_code != 0) return server_args.return_code;
-    }
-
-    /* show ciphers */
-    {
-        char ciphers[1024];
-        XMEMSET(ciphers, 0, sizeof(ciphers));
-        wolfSSL_get_ciphers(ciphers, sizeof(ciphers)-1);
-        printf("ciphers = %s\n", ciphers);
-    }
-
-    /* validate output equals input */
-    {
-        byte input[SHA256_DIGEST_SIZE];
-        byte output[SHA256_DIGEST_SIZE];
-
-        file_test("input",  input);
-        file_test(outputName, output);
-        remove(outputName);
-        if (memcmp(input, output, sizeof(input)) != 0)
-            return EXIT_FAILURE;
-    }
-
-    wolfSSL_Cleanup();
-    FreeTcpReady(&ready);
-
-#ifdef WOLFSSL_TIRTOS
-    fdCloseSession(Task_self());
-#endif
-
-#ifdef HAVE_CAVIUM
-        CspShutdown(CAVIUM_DEV_ID);
-#endif
-    printf("\nAll tests passed!\n");
-    return EXIT_SUCCESS;
-}
-
-void simple_test(func_args* args)
-{
-    THREAD_TYPE serverThread;
-
-    func_args svrArgs;
-    char *svrArgv[9];
-    char argc0s[32];
-    char argc1s[32];
-    char argc2s[32];
-    char argc3s[32];
-    char argc4s[32];
-    char argc5s[32];
-    char argc6s[32];
-    char argc7s[32];
-    char argc8s[32];
-
-    func_args cliArgs;
-    char *cliArgv[NUMARGS];
-    char argc0c[32];
-    char argc1c[32];
-    char argc2c[32];
-
-    svrArgv[0] = argc0s;
-    svrArgv[1] = argc1s;
-    svrArgv[2] = argc2s;
-    svrArgv[3] = argc3s;
-    svrArgv[4] = argc4s;
-    svrArgv[5] = argc5s;
-    svrArgv[6] = argc6s;
-    svrArgv[7] = argc7s;
-    svrArgv[8] = argc8s;
-    cliArgv[0] = argc0c;
-    cliArgv[1] = argc1c;
-    cliArgv[2] = argc2c;
-
-    svrArgs.argc = 1;
-    svrArgs.argv = svrArgv;
-    svrArgs.return_code = 0;
-    cliArgs.argc = 1;
-    cliArgs.argv = cliArgv;
-    cliArgs.return_code = 0;
-
-    strcpy(svrArgs.argv[0], "SimpleServer");
-    #if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_SNIFFER)  && \
-                                     !defined(WOLFSSL_TIRTOS)
-        strcpy(svrArgs.argv[svrArgs.argc++], "-p");
-        strcpy(svrArgs.argv[svrArgs.argc++], "0");
-    #endif
-    #ifdef HAVE_NTRU
-        strcpy(svrArgs.argv[svrArgs.argc++], "-d");
-        strcpy(svrArgs.argv[svrArgs.argc++], "-n");
-        strcpy(svrArgs.argv[svrArgs.argc++], "-c");
-        strcpy(svrArgs.argv[svrArgs.argc++], "./certs/ntru-cert.pem");
-        strcpy(svrArgs.argv[svrArgs.argc++], "-k");
-        strcpy(svrArgs.argv[svrArgs.argc++], "./certs/ntru-key.raw");
-    #endif
-    /* Set the last arg later, when it is known. */
-
-    args->return_code = 0;
-    svrArgs.signal = args->signal;
-    start_thread(server_test, &svrArgs, &serverThread);
-    wait_tcp_ready(&svrArgs);
-
-    /* Setting the actual port number. */
-    strcpy(cliArgs.argv[0], "SimpleClient");
-    #ifndef USE_WINDOWS_API
-        cliArgs.argc = NUMARGS;
-        strcpy(cliArgs.argv[1], "-p");
-        snprintf(cliArgs.argv[2], sizeof(argc2c), "%d", svrArgs.signal->port);
-    #endif
-
-    client_test(&cliArgs);
-    if (cliArgs.return_code != 0) {
-        args->return_code = cliArgs.return_code;
-        return;
-    }
-    join_thread(serverThread);
-    if (svrArgs.return_code != 0) args->return_code = svrArgs.return_code;
-}
-
-
-void wait_tcp_ready(func_args* args)
-{
-#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
-    pthread_mutex_lock(&args->signal->mutex);
-
-    if (!args->signal->ready)
-        pthread_cond_wait(&args->signal->cond, &args->signal->mutex);
-    args->signal->ready = 0; /* reset */
-
-    pthread_mutex_unlock(&args->signal->mutex);
-#else
-    (void)args;
-#endif
-}
-
-
-void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
-{
-#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
-    pthread_create(thread, 0, fun, args);
-    return;
-#elif defined(WOLFSSL_TIRTOS)
-    /* Initialize the defaults and set the parameters. */
-    Task_Params taskParams;
-    Task_Params_init(&taskParams);
-    taskParams.arg0 = (UArg)args;
-    taskParams.stackSize = 65535;
-    *thread = Task_create((Task_FuncPtr)fun, &taskParams, NULL);
-    if (*thread == NULL) {
-        printf("Failed to create new Task\n");
-    }
-    Task_yield();
-#else
-    *thread = (THREAD_TYPE)_beginthreadex(0, 0, fun, args, 0, 0);
-#endif
-}
-
-
-void join_thread(THREAD_TYPE thread)
-{
-#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
-    pthread_join(thread, 0);
-#elif defined(WOLFSSL_TIRTOS)
-    while(1) {
-        if (Task_getMode(thread) == Task_Mode_TERMINATED) {
-		    Task_sleep(5);
-            break;
-        }
-        Task_yield();
-    }
-#else
-    int res = WaitForSingleObject((HANDLE)thread, INFINITE);
-    assert(res == WAIT_OBJECT_0);
-    res = CloseHandle((HANDLE)thread);
-    assert(res);
-#endif
-}
-
-
-void InitTcpReady(tcp_ready* ready)
-{
-    ready->ready = 0;
-    ready->port = 0;
-#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
-      pthread_mutex_init(&ready->mutex, 0);
-      pthread_cond_init(&ready->cond, 0);
-#endif
-}
-
-
-void FreeTcpReady(tcp_ready* ready)
-{
-#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
-    pthread_mutex_destroy(&ready->mutex);
-    pthread_cond_destroy(&ready->cond);
-#else
-    (void)ready;
-#endif
-}
-
-
-void file_test(const char* file, byte* check)
-{
-    FILE* f;
-    int   i = 0, j, ret;
-    Sha256   sha256;
-    byte  buf[1024];
-    byte  shasum[SHA256_DIGEST_SIZE];
-
-    ret = wc_InitSha256(&sha256);
-    if (ret != 0) {
-        printf("Can't wc_InitSha256 %d\n", ret);
-        return;
-    }
-    if( !( f = fopen( file, "rb" ) )) {
-        printf("Can't open %s\n", file);
-        return;
-    }
-    while( ( i = (int)fread(buf, 1, sizeof(buf), f )) > 0 ) {
-        ret = wc_Sha256Update(&sha256, buf, i);
-        if (ret != 0) {
-            printf("Can't wc_Sha256Update %d\n", ret);
-            return;
-        }
-    }
-
-    ret = wc_Sha256Final(&sha256, shasum);
-    if (ret != 0) {
-        printf("Can't wc_Sha256Final %d\n", ret);
-        return;
-    }
-
-    memcpy(check, shasum, sizeof(shasum));
-
-    for(j = 0; j < SHA256_DIGEST_SIZE; ++j )
-        printf( "%02x", shasum[j] );
-
-    printf("  %s\n", file);
-
-    fclose(f);
-}
-
-
-#else /* SINGLE_THREADED */
-
-
-int myoptind = 0;
-char* myoptarg = NULL;
-
-
-int main(int argc, char** argv)
-{
-    func_args server_args;
-
-    server_args.argc = argc;
-    server_args.argv = argv;
-
-    if (CurrentDir("testsuite") || CurrentDir("_build"))
-        ChangeDirBack(1);
-    else if (CurrentDir("Debug") || CurrentDir("Release"))
-        ChangeDirBack(3);          /* Xcode->Preferences->Locations->Locations*/
-                                   /* Derived Data Advanced -> Custom  */
-                                   /* Relative to Workspace, Build/Products */
-                                   /* Debug or Release */
-
-    wolfcrypt_test(&server_args);
-    if (server_args.return_code != 0) return server_args.return_code;
-
-    printf("\nAll tests passed!\n");
-    return EXIT_SUCCESS;
-}
-
-
-#endif /* SINGLE_THREADED */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite.sln b/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite.sln
deleted file mode 100755
index b89dcc1..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual C++ Express 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsuite", "testsuite.vcproj", "{9D4D8446-CE91-4F7A-AFF2-90D0B5DCD717}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{9D4D8446-CE91-4F7A-AFF2-90D0B5DCD717}.Debug|Win32.ActiveCfg = Debug|Win32
-		{9D4D8446-CE91-4F7A-AFF2-90D0B5DCD717}.Debug|Win32.Build.0 = Debug|Win32
-		{9D4D8446-CE91-4F7A-AFF2-90D0B5DCD717}.Release|Win32.ActiveCfg = Release|Win32
-		{9D4D8446-CE91-4F7A-AFF2-90D0B5DCD717}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
diff --git a/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite.vcproj b/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite.vcproj
deleted file mode 100755
index 9d521ce..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite.vcproj
+++ /dev/null
@@ -1,217 +0,0 @@
-
-
-	
-		
-	
-	
-	
-	
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-	
-	
-	
-	
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-		
-		
-		
-		
-	
-	
-	
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite.vcxproj b/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite.vcxproj
deleted file mode 100755
index 484a875..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/testsuite/testsuite.vcxproj
+++ /dev/null
@@ -1,337 +0,0 @@
-
-
-  
-    
-      Debug
-      Win32
-    
-    
-      Debug
-      x64
-    
-    
-      DLL Debug
-      Win32
-    
-    
-      DLL Debug
-      x64
-    
-    
-      DLL Release
-      Win32
-    
-    
-      DLL Release
-      x64
-    
-    
-      Release
-      Win32
-    
-    
-      Release
-      x64
-    
-  
-  
-    {611E8971-46E0-4D0A-B5A1-632C3B00CB80}
-    testsuite
-    Win32Proj
-  
-  
-  
-    Application
-    v110
-    Unicode
-    true
-  
-  
-    Application
-    v110
-    Unicode
-    true
-  
-  
-    Application
-    v110
-    Unicode
-    true
-  
-  
-    Application
-    v110
-    Unicode
-    true
-  
-  
-    Application
-    v110
-    Unicode
-  
-  
-    Application
-    v110
-    Unicode
-  
-  
-    Application
-    v110
-    Unicode
-  
-  
-    Application
-    v110
-    Unicode
-  
-  
-  
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-    
-  
-  
-  
-    <_ProjectFileVersion>11.0.61030.0
-  
-  
-    $(SolutionDir)$(Configuration)\
-    $(Configuration)\obj\
-    true
-  
-  
-    $(SolutionDir)$(Configuration)\
-    $(Configuration)\obj\
-    true
-  
-  
-    true
-    $(SolutionDir)$(Platform)\$(Configuration)\
-    $(Platform)\$(Configuration)\obj\
-  
-  
-    true
-    $(SolutionDir)$(Platform)\$(Configuration)\
-    $(Platform)\$(Configuration)\obj\
-  
-  
-    $(SolutionDir)$(Configuration)\
-    $(Configuration)\obj\
-    false
-  
-  
-    $(SolutionDir)$(Configuration)\
-    $(Configuration)\obj\
-    false
-  
-  
-    false
-    $(SolutionDir)$(Platform)\$(Configuration)\
-    $(Platform)\$(Configuration)\obj\
-  
-  
-    false
-    $(SolutionDir)$(Platform)\$(Configuration)\
-    $(Platform)\$(Configuration)\obj\
-  
-  
-    
-      Disabled
-      ../;%(AdditionalIncludeDirectories)
-      NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)
-      true
-      EnableFastChecks
-      MultiThreadedDebugDLL
-      
-      Level3
-      EditAndContinue
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      MachineX86
-    false
-    
-  
-  
-    
-      Disabled
-      ../;%(AdditionalIncludeDirectories)
-      NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions)
-      true
-      EnableFastChecks
-      MultiThreadedDebugDLL
-      
-      
-      Level3
-      EditAndContinue
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      MachineX86
-    
-  
-  
-    
-      Disabled
-      ../;%(AdditionalIncludeDirectories)
-      NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)
-      EnableFastChecks
-      MultiThreadedDebugDLL
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-    
-  
-  
-    
-      Disabled
-      ../;%(AdditionalIncludeDirectories)
-      NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions)
-      EnableFastChecks
-      MultiThreadedDebugDLL
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-    
-  
-  
-    
-      MaxSpeed
-      true
-      ../;%(AdditionalIncludeDirectories)
-      NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)
-      MultiThreadedDLL
-      true
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      true
-      true
-      MachineX86
-      false
-    
-  
-  
-    
-      MaxSpeed
-      true
-      ../;%(AdditionalIncludeDirectories)
-      NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions)
-      MultiThreadedDLL
-      true
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      true
-      true
-      MachineX86
-    
-  
-  
-    
-      MaxSpeed
-      true
-      ../;%(AdditionalIncludeDirectories)
-      NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)
-      MultiThreadedDLL
-      true
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      true
-      true
-    
-  
-  
-    
-      MaxSpeed
-      true
-      ../;%(AdditionalIncludeDirectories)
-      NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;NO_PSK;WOLFSSL_DLL;%(PreprocessorDefinitions)
-      MultiThreadedDLL
-      true
-      
-      
-      Level3
-      ProgramDatabase
-    
-    
-      Ws2_32.lib;%(AdditionalDependencies)
-      true
-      Console
-      true
-      true
-    
-  
-  
-    
-    
-    
-    
-    
-    
-  
-  
-    
-      {73973223-5ee8-41ca-8e88-1d60e89a237b}
-      false
-    
-  
-  
-  
-  
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/valgrind-error.sh b/FreeRTOS-Plus/Source/WolfSSL/valgrind-error.sh
deleted file mode 100755
index 7f7441c..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/valgrind-error.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-#
-#
-# Our valgrind "error" wrapper.
-
-valgrind --leak-check=full -q "$@" 2> valgrind.tmp
-
-result="$?"
-
-# verify no errors
-
-output="`cat valgrind.tmp`"
-
-if [ "$output" != "" ]; then
-    cat valgrind.tmp >&2
-    result=1
-fi
-
-rm valgrind.tmp
-
-exit $result
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/benchmark/benchmark.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/benchmark/benchmark.c
deleted file mode 100755
index f284774..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/benchmark/benchmark.c
+++ /dev/null
@@ -1,1910 +0,0 @@
-/* benchmark.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/* wolfCrypt benchmark */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#include 
-
-#ifdef FREESCALE_MQX
-    #include 
-    #include 
-#else
-    #include 
-#endif
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#ifdef HAVE_ECC
-    #include 
-#endif
-#ifdef HAVE_CURVE25519
-    #include 
-#endif
-#ifdef HAVE_ED25519
-    #include 
-#endif
-
-#include 
-#ifdef HAVE_CAVIUM
-    #include "cavium_sysdep.h"
-    #include "cavium_common.h"
-    #include "cavium_ioctl.h"
-#endif
-#ifdef HAVE_NTRU
-    #include "ntru_crypto.h"
-#endif
-
-#if defined(WOLFSSL_MDK_ARM)
-    extern FILE * wolfSSL_fopen(const char *fname, const char *mode) ;
-    #define fopen wolfSSL_fopen
-#endif
-
-#if defined(__GNUC__) && defined(__x86_64__) && !defined(NO_ASM)
-    #define HAVE_GET_CYCLES
-    static INLINE word64 get_intel_cycles(void);
-    static word64 total_cycles;
-    #define BEGIN_INTEL_CYCLES total_cycles = get_intel_cycles();
-    #define END_INTEL_CYCLES   total_cycles = get_intel_cycles() - total_cycles;
-    #define SHOW_INTEL_CYCLES  printf(" Cycles per byte = %6.2f", \
-                               (float)total_cycles / (numBlocks*sizeof(plain)));
-#else
-    #define BEGIN_INTEL_CYCLES
-    #define END_INTEL_CYCLES
-    #define SHOW_INTEL_CYCLES
-#endif
-
-/* let's use buffers, we have them */
-#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
-    #define USE_CERT_BUFFERS_2048
-#endif
-
-#if defined(USE_CERT_BUFFERS_1024) || defined(USE_CERT_BUFFERS_2048) \
-                                   || !defined(NO_DH)
-    /* include test cert and key buffers for use with NO_FILESYSTEM */
-    #if defined(WOLFSSL_MDK_ARM)
-        #include "cert_data.h" /* use certs_test.c for initial data, 
-                                      so other commands can share the data. */
-    #else
-        #include 
-    #endif
-#endif
-
-
-#ifdef HAVE_BLAKE2
-    #include 
-    void bench_blake2(void);
-#endif
-
-#ifdef _MSC_VER
-    /* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
-    #pragma warning(disable: 4996)
-#endif
-
-
-void bench_des(void);
-void bench_arc4(void);
-void bench_hc128(void);
-void bench_rabbit(void);
-void bench_chacha(void);
-void bench_chacha20_poly1305_aead(void);
-void bench_aes(int);
-void bench_aesgcm(void);
-void bench_aesccm(void);
-void bench_aesctr(void);
-void bench_poly1305(void);
-void bench_camellia(void);
-
-void bench_md5(void);
-void bench_sha(void);
-void bench_sha256(void);
-void bench_sha384(void);
-void bench_sha512(void);
-void bench_ripemd(void);
-
-void bench_rsa(void);
-void bench_rsaKeyGen(void);
-void bench_dh(void);
-#ifdef HAVE_ECC
-void bench_eccKeyGen(void);
-void bench_eccKeyAgree(void);
-#endif
-#ifdef HAVE_CURVE25519
-void bench_curve25519KeyGen(void);
-void bench_curve25519KeyAgree(void);
-#endif
-#ifdef HAVE_ED25519
-void bench_ed25519KeyGen(void);
-void bench_ed25519KeySign(void);
-#endif
-#ifdef HAVE_NTRU
-void bench_ntru(void);
-void bench_ntruKeyGen(void);
-#endif
-
-double current_time(int);
-
-
-#ifdef HAVE_CAVIUM
-
-static int OpenNitroxDevice(int dma_mode,int dev_id)
-{
-   Csp1CoreAssignment core_assign;
-   Uint32             device;
-
-   if (CspInitialize(CAVIUM_DIRECT,CAVIUM_DEV_ID))
-      return -1;
-   if (Csp1GetDevType(&device))
-      return -1;
-   if (device != NPX_DEVICE) {
-      if (ioctl(gpkpdev_hdlr[CAVIUM_DEV_ID], IOCTL_CSP1_GET_CORE_ASSIGNMENT,
-                (Uint32 *)&core_assign)!= 0)
-         return -1;
-   }
-   CspShutdown(CAVIUM_DEV_ID);
-
-   return CspInitialize(dma_mode, dev_id);
-}
-
-#endif
-
-#if defined(DEBUG_WOLFSSL) && !defined(HAVE_VALGRIND)
-    WOLFSSL_API int wolfSSL_Debugging_ON();
-#endif
-
-#if !defined(NO_RSA) || !defined(NO_DH) \
-                                || defined(WOLFSSL_KEYGEN) || defined(HAVE_ECC)
-    #define HAVE_LOCAL_RNG
-    static RNG rng;
-#endif
-
-/* use kB instead of mB for embedded benchmarking */
-#ifdef BENCH_EMBEDDED
-    static byte plain [1024];
-#else
-    static byte plain [1024*1024];
-#endif
-
-
-/* use kB instead of mB for embedded benchmarking */
-#ifdef BENCH_EMBEDDED
-    static byte cipher[1024];
-#else
-    static byte cipher[1024*1024];
-#endif
-
-
-static const XGEN_ALIGN byte key[] =
-{
-    0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
-    0xfe,0xde,0xba,0x98,0x76,0x54,0x32,0x10,
-    0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67
-};
-
-static const XGEN_ALIGN byte iv[] =
-{
-    0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef,
-    0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
-    0x11,0x21,0x31,0x41,0x51,0x61,0x71,0x81
-};
-
-
-/* so embedded projects can pull in tests on their own */
-#if !defined(NO_MAIN_DRIVER)
-
-int main(int argc, char** argv)
-
-{
-  (void)argc;
-  (void)argv;
-#else
-int benchmark_test(void *args) 
-{
-#endif
-
-    #if defined(DEBUG_WOLFSSL) && !defined(HAVE_VALGRIND)
-        wolfSSL_Debugging_ON();
-    #endif
-
-    (void)plain;
-    (void)cipher;
-    (void)key;
-    (void)iv;
-
-	#ifdef HAVE_CAVIUM
-    int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID);
-    if (ret != 0) {
-        printf("Cavium OpenNitroxDevice failed\n");
-        exit(-1);
-    }
-#endif /* HAVE_CAVIUM */
-
-#if defined(HAVE_LOCAL_RNG)
-    {
-        int rngRet = wc_InitRng(&rng);
-        if (rngRet < 0) {
-            printf("InitRNG failed\n");
-            return rngRet;
-        }
-    }
-#endif
-
-#ifndef NO_AES
-    bench_aes(0);
-    bench_aes(1);
-#endif
-#ifdef HAVE_AESGCM
-    bench_aesgcm();
-#endif
-
-#ifdef WOLFSSL_AES_COUNTER
-    bench_aesctr();
-#endif
-
-#ifdef HAVE_AESCCM
-    bench_aesccm();
-#endif
-#ifdef HAVE_CAMELLIA
-    bench_camellia();
-#endif
-#ifndef NO_RC4
-    bench_arc4();
-#endif
-#ifdef HAVE_HC128
-    bench_hc128();
-#endif
-#ifndef NO_RABBIT
-    bench_rabbit();
-#endif
-#ifdef HAVE_CHACHA
-    bench_chacha();
-#endif
-#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
-    bench_chacha20_poly1305_aead();
-#endif
-#ifndef NO_DES3
-    bench_des();
-#endif
-    
-    printf("\n");
-
-#ifndef NO_MD5
-    bench_md5();
-#endif
-#ifdef HAVE_POLY1305
-    bench_poly1305();
-#endif
-#ifndef NO_SHA
-    bench_sha();
-#endif
-#ifndef NO_SHA256
-    bench_sha256();
-#endif
-#ifdef WOLFSSL_SHA384
-    bench_sha384();
-#endif
-#ifdef WOLFSSL_SHA512
-    bench_sha512();
-#endif
-#ifdef WOLFSSL_RIPEMD
-    bench_ripemd();
-#endif
-#ifdef HAVE_BLAKE2
-    bench_blake2();
-#endif
-
-    printf("\n");
-
-#ifndef NO_RSA
-    bench_rsa();
-#endif
-
-#ifdef HAVE_NTRU
-    bench_ntru();
-#endif
-
-#ifndef NO_DH
-    bench_dh();
-#endif
-
-#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA)
-    bench_rsaKeyGen();
-#endif
-
-#ifdef HAVE_NTRU
-    bench_ntruKeyGen();
-#endif
-
-#ifdef HAVE_ECC
-    bench_eccKeyGen();
-    bench_eccKeyAgree();
-    #if defined(FP_ECC)
-        wc_ecc_fp_free();
-    #endif
-#endif
-
-#ifdef HAVE_CURVE25519
-    bench_curve25519KeyGen();
-    bench_curve25519KeyAgree();
-#endif
-
-#ifdef HAVE_ED25519
-    bench_ed25519KeyGen();
-    bench_ed25519KeySign();
-#endif
-
-#if defined(HAVE_LOCAL_RNG)
-    wc_FreeRng(&rng);
-#endif
-
-    return 0;
-}
-
-
-#ifdef BENCH_EMBEDDED
-enum BenchmarkBounds {
-    numBlocks  = 25, /* how many kB to test (en/de)cryption */
-    ntimes     = 1,
-    genTimes   = 5,  /* public key iterations */
-    agreeTimes = 5
-};
-static const char blockType[] = "kB";   /* used in printf output */
-#else
-enum BenchmarkBounds {
-    numBlocks  = 50,  /* how many megs to test (en/de)cryption */
-    ntimes     = 100,
-    genTimes   = 100,
-    agreeTimes = 100
-};
-static const char blockType[] = "megs"; /* used in printf output */
-#endif
-
-
-#ifndef NO_AES
-
-void bench_aes(int show)
-{
-    Aes    enc;
-    double start, total, persec;
-    int    i;
-    int    ret;
-
-#ifdef HAVE_CAVIUM
-    if (wc_AesInitCavium(&enc, CAVIUM_DEV_ID) != 0) {
-        printf("aes init cavium failed\n");
-        return;
-    }
-#endif
-
-    ret = wc_AesSetKey(&enc, key, 16, iv, AES_ENCRYPTION);
-    if (ret != 0) {
-        printf("AesSetKey failed, ret = %d\n", ret);
-        return;
-    }
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for(i = 0; i < numBlocks; i++)
-        wc_AesCbcEncrypt(&enc, plain, cipher, sizeof(plain));
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    if (show) {
-        printf("AES      %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                                  blockType, total, persec);
-        SHOW_INTEL_CYCLES
-        printf("\n");
-    }
-#ifdef HAVE_CAVIUM
-    wc_AesFreeCavium(&enc);
-#endif
-}
-#endif
-
-
-#if defined(HAVE_AESGCM) || defined(HAVE_AESCCM)
-    static byte additional[13];
-    static byte tag[16];
-#endif
-
-
-#ifdef HAVE_AESGCM
-void bench_aesgcm(void)
-{
-    Aes    enc;
-    double start, total, persec;
-    int    i;
-
-    wc_AesGcmSetKey(&enc, key, 16);
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for(i = 0; i < numBlocks; i++)
-        wc_AesGcmEncrypt(&enc, cipher, plain, sizeof(plain), iv, 12,
-                        tag, 16, additional, 13);
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("AES-GCM  %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-}
-#endif
-
-#ifdef WOLFSSL_AES_COUNTER
-void bench_aesctr(void)
-{
-    Aes    enc;
-    double start, total, persec;
-    int    i;
-
-    wc_AesSetKeyDirect(&enc, key, AES_BLOCK_SIZE, iv, AES_ENCRYPTION);
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for(i = 0; i < numBlocks; i++)
-        wc_AesCtrEncrypt(&enc, plain, cipher, sizeof(plain));
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("AES-CTR  %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-}
-#endif
-
-
-
-#ifdef HAVE_AESCCM
-void bench_aesccm(void)
-{
-    Aes    enc;
-    double start, total, persec;
-    int    i;
-
-    wc_AesCcmSetKey(&enc, key, 16);
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for(i = 0; i < numBlocks; i++)
-        wc_AesCcmEncrypt(&enc, cipher, plain, sizeof(plain), iv, 12,
-                        tag, 16, additional, 13);
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("AES-CCM  %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-}
-#endif
-
-
-#ifdef HAVE_POLY1305
-void bench_poly1305()
-{
-    Poly1305    enc;
-    byte   mac[16];
-    double start, total, persec;
-    int    i;
-    int    ret;
-
-
-    ret = wc_Poly1305SetKey(&enc, key, 32);
-    if (ret != 0) {
-        printf("Poly1305SetKey failed, ret = %d\n", ret);
-        return;
-    }
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for(i = 0; i < numBlocks; i++)
-        wc_Poly1305Update(&enc, plain, sizeof(plain));
-
-    wc_Poly1305Final(&enc, mac);
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("POLY1305 %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                                  blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-}
-#endif /* HAVE_POLY1305 */
-
-
-#ifdef HAVE_CAMELLIA
-void bench_camellia(void)
-{
-    Camellia cam;
-    double start, total, persec;
-    int    i, ret;
-
-    ret = wc_CamelliaSetKey(&cam, key, 16, iv);
-    if (ret != 0) {
-        printf("CamelliaSetKey failed, ret = %d\n", ret);
-        return;
-    }
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for(i = 0; i < numBlocks; i++)
-        wc_CamelliaCbcEncrypt(&cam, plain, cipher, sizeof(plain));
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("Camellia %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-}
-#endif
-
-
-#ifndef NO_DES3
-void bench_des(void)
-{
-    Des3   enc;
-    double start, total, persec;
-    int    i, ret;
-
-#ifdef HAVE_CAVIUM
-    if (wc_Des3_InitCavium(&enc, CAVIUM_DEV_ID) != 0)
-        printf("des3 init cavium failed\n");
-#endif
-    ret = wc_Des3_SetKey(&enc, key, iv, DES_ENCRYPTION);
-    if (ret != 0) {
-        printf("Des3_SetKey failed, ret = %d\n", ret);
-        return;
-    }
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for(i = 0; i < numBlocks; i++)
-        wc_Des3_CbcEncrypt(&enc, plain, cipher, sizeof(plain));
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("3DES     %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-#ifdef HAVE_CAVIUM
-    wc_Des3_FreeCavium(&enc);
-#endif
-}
-#endif
-
-
-#ifndef NO_RC4
-void bench_arc4(void)
-{
-    Arc4   enc;
-    double start, total, persec;
-    int    i;
-    
-#ifdef HAVE_CAVIUM
-    if (wc_Arc4InitCavium(&enc, CAVIUM_DEV_ID) != 0)
-        printf("arc4 init cavium failed\n");
-#endif
-
-    wc_Arc4SetKey(&enc, key, 16);
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for(i = 0; i < numBlocks; i++)
-        wc_Arc4Process(&enc, cipher, plain, sizeof(plain));
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("ARC4     %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-#ifdef HAVE_CAVIUM
-    wc_Arc4FreeCavium(&enc);
-#endif
-}
-#endif
-
-
-#ifdef HAVE_HC128
-void bench_hc128(void)
-{
-    HC128  enc;
-    double start, total, persec;
-    int    i;
-    
-    wc_Hc128_SetKey(&enc, key, iv);
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for(i = 0; i < numBlocks; i++)
-        wc_Hc128_Process(&enc, cipher, plain, sizeof(plain));
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("HC128    %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-}
-#endif /* HAVE_HC128 */
-
-
-#ifndef NO_RABBIT
-void bench_rabbit(void)
-{
-    Rabbit  enc;
-    double start, total, persec;
-    int    i;
-    
-    wc_RabbitSetKey(&enc, key, iv);
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for(i = 0; i < numBlocks; i++)
-        wc_RabbitProcess(&enc, cipher, plain, sizeof(plain));
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("RABBIT   %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-}
-#endif /* NO_RABBIT */
-
-
-#ifdef HAVE_CHACHA
-void bench_chacha(void)
-{
-    ChaCha enc;
-    double start, total, persec;
-    int    i;
-
-    wc_Chacha_SetKey(&enc, key, 16);
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for (i = 0; i < numBlocks; i++) {
-        wc_Chacha_SetIV(&enc, iv, 0);
-        wc_Chacha_Process(&enc, cipher, plain, sizeof(plain));
-    }
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("CHACHA   %d %s took %5.3f seconds, %8.3f MB/s", numBlocks, blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-
-}
-#endif /* HAVE_CHACHA*/
-
-#if( defined( HAVE_CHACHA ) && defined( HAVE_POLY1305 ) )
-void bench_chacha20_poly1305_aead(void)
-{
-    double start, total, persec;
-    int    i;
-
-    byte authTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE];
-    XMEMSET( authTag, 0, sizeof( authTag ) );
-
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for (i = 0; i < numBlocks; i++)
-    {
-        wc_ChaCha20Poly1305_Encrypt(key, iv, NULL, 0, plain, sizeof(plain),
-                                    cipher, authTag );
-    }
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("CHA-POLY %d %s took %5.3f seconds, %8.3f MB/s",
-           numBlocks, blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-
-}
-#endif /* HAVE_CHACHA && HAVE_POLY1305 */
-
-
-#ifndef NO_MD5
-void bench_md5(void)
-{
-    Md5    hash;
-    byte   digest[MD5_DIGEST_SIZE];
-    double start, total, persec;
-    int    i;
-
-    wc_InitMd5(&hash);
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for(i = 0; i < numBlocks; i++)
-        wc_Md5Update(&hash, plain, sizeof(plain));
-   
-    wc_Md5Final(&hash, digest);
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("MD5      %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-}
-#endif /* NO_MD5 */
-
-
-#ifndef NO_SHA
-void bench_sha(void)
-{
-    Sha    hash;
-    byte   digest[SHA_DIGEST_SIZE];
-    double start, total, persec;
-    int    i, ret;
-        
-    ret = wc_InitSha(&hash);
-    if (ret != 0) {
-        printf("InitSha failed, ret = %d\n", ret);
-        return;
-    }
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-    
-    for(i = 0; i < numBlocks; i++)
-        wc_ShaUpdate(&hash, plain, sizeof(plain));
-   
-    wc_ShaFinal(&hash, digest);
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("SHA      %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-}
-#endif /* NO_SHA */
-
-
-#ifndef NO_SHA256
-void bench_sha256(void)
-{
-    Sha256 hash;
-    byte   digest[SHA256_DIGEST_SIZE];
-    double start, total, persec;
-    int    i, ret;
-
-    ret = wc_InitSha256(&hash);
-    if (ret != 0) {
-        printf("InitSha256 failed, ret = %d\n", ret);
-        return;
-    }
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for(i = 0; i < numBlocks; i++) {
-        ret = wc_Sha256Update(&hash, plain, sizeof(plain));
-        if (ret != 0) {
-            printf("Sha256Update failed, ret = %d\n", ret);
-            return;
-        }
-    }
-
-    ret = wc_Sha256Final(&hash, digest);
-    if (ret != 0) {
-        printf("Sha256Final failed, ret = %d\n", ret);
-        return;
-    }
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("SHA-256  %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-}
-#endif
-
-#ifdef WOLFSSL_SHA384
-void bench_sha384(void)
-{
-    Sha384 hash;
-    byte   digest[SHA384_DIGEST_SIZE];
-    double start, total, persec;
-    int    i, ret;
-
-    ret = wc_InitSha384(&hash);
-    if (ret != 0) {
-        printf("InitSha384 failed, ret = %d\n", ret);
-        return;
-    }
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-
-    for(i = 0; i < numBlocks; i++) {
-        ret = wc_Sha384Update(&hash, plain, sizeof(plain));
-        if (ret != 0) {
-            printf("Sha384Update failed, ret = %d\n", ret);
-            return;
-        }
-    }
-
-    ret = wc_Sha384Final(&hash, digest);
-    if (ret != 0) {
-        printf("Sha384Final failed, ret = %d\n", ret);
-        return;
-    }
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("SHA-384  %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-}
-#endif
-
-#ifdef WOLFSSL_SHA512
-void bench_sha512(void)
-{
-    Sha512 hash;
-    byte   digest[SHA512_DIGEST_SIZE];
-    double start, total, persec;
-    int    i, ret;
-        
-    ret = wc_InitSha512(&hash);
-    if (ret != 0) {
-        printf("InitSha512 failed, ret = %d\n", ret);
-        return;
-    }
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-    
-    for(i = 0; i < numBlocks; i++) {
-        ret = wc_Sha512Update(&hash, plain, sizeof(plain));
-        if (ret != 0) {
-            printf("Sha512Update failed, ret = %d\n", ret);
-            return;
-        }
-    }
-
-    ret = wc_Sha512Final(&hash, digest);
-    if (ret != 0) {
-        printf("Sha512Final failed, ret = %d\n", ret);
-        return;
-    }
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("SHA-512  %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-}
-#endif
-
-#ifdef WOLFSSL_RIPEMD
-void bench_ripemd(void)
-{
-    RipeMd hash;
-    byte   digest[RIPEMD_DIGEST_SIZE];
-    double start, total, persec;
-    int    i;
-        
-    wc_InitRipeMd(&hash);
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-    
-    for(i = 0; i < numBlocks; i++)
-        wc_RipeMdUpdate(&hash, plain, sizeof(plain));
-   
-    wc_RipeMdFinal(&hash, digest);
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("RIPEMD   %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-}
-#endif
-
-
-#ifdef HAVE_BLAKE2
-void bench_blake2(void)
-{
-    Blake2b b2b;
-    byte    digest[64];
-    double  start, total, persec;
-    int     i, ret;
-       
-    ret = wc_InitBlake2b(&b2b, 64);
-    if (ret != 0) {
-        printf("InitBlake2b failed, ret = %d\n", ret);
-        return;
-    }
-    start = current_time(1);
-    BEGIN_INTEL_CYCLES
-    
-    for(i = 0; i < numBlocks; i++) {
-        ret = wc_Blake2bUpdate(&b2b, plain, sizeof(plain));
-        if (ret != 0) {
-            printf("Blake2bUpdate failed, ret = %d\n", ret);
-            return;
-        }
-    }
-   
-    ret = wc_Blake2bFinal(&b2b, digest, 64);
-    if (ret != 0) {
-        printf("Blake2bFinal failed, ret = %d\n", ret);
-        return;
-    }
-
-    END_INTEL_CYCLES
-    total = current_time(0) - start;
-    persec = 1 / total * numBlocks;
-#ifdef BENCH_EMBEDDED
-    /* since using kB, convert to MB/s */
-    persec = persec / 1024;
-#endif
-
-    printf("BLAKE2b  %d %s took %5.3f seconds, %8.3f MB/s", numBlocks,
-                                              blockType, total, persec);
-    SHOW_INTEL_CYCLES
-    printf("\n");
-}
-#endif
-
-
-#ifndef NO_RSA
-
-
-#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
-    #if defined(WOLFSSL_MDK_SHELL)
-        static char *certRSAname = "certs/rsa2048.der";
-        /* set by shell command */
-        static void set_Bench_RSA_File(char * cert) { certRSAname = cert ; }
-    #elif defined(FREESCALE_MQX)
-        static char *certRSAname = "a:\\certs\\rsa2048.der";
-    #else
-        static const char *certRSAname = "certs/rsa2048.der";
-    #endif
-#endif
-
-void bench_rsa(void)
-{
-    int    i;
-    int    ret;
-    size_t bytes;
-    word32 idx = 0;
-    const byte* tmp;
-
-    byte      message[] = "Everyone gets Friday off.";
-    byte      enc[256];  /* for up to 2048 bit */
-    const int len = (int)strlen((char*)message);
-    double    start, total, each, milliEach;
-
-    RsaKey rsaKey;
-    int    rsaKeySz = 2048; /* used in printf */
-
-#ifdef USE_CERT_BUFFERS_1024
-    tmp = rsa_key_der_1024;
-    bytes = sizeof_rsa_key_der_1024;
-    rsaKeySz = 1024;
-#elif defined(USE_CERT_BUFFERS_2048)
-    tmp = rsa_key_der_2048;
-    bytes = sizeof_rsa_key_der_2048;
-#else
-    #error "need a cert buffer size"
-#endif /* USE_CERT_BUFFERS */
-
-
-#ifdef HAVE_CAVIUM
-    if (wc_RsaInitCavium(&rsaKey, CAVIUM_DEV_ID) != 0)
-        printf("RSA init cavium failed\n");
-#endif
-    ret = wc_InitRsaKey(&rsaKey, 0);
-    if (ret < 0) {
-        printf("InitRsaKey failed\n");
-        return;
-    }
-    ret = wc_RsaPrivateKeyDecode(tmp, &idx, &rsaKey, (word32)bytes);
-
-    start = current_time(1);
-
-    for (i = 0; i < ntimes; i++)
-        ret = wc_RsaPublicEncrypt(message,len,enc,sizeof(enc), &rsaKey, &rng);
-
-    total = current_time(0) - start;
-    each  = total / ntimes;   /* per second   */
-    milliEach = each * 1000; /* milliseconds */
-
-    printf("RSA %d encryption took %6.3f milliseconds, avg over %d"
-           " iterations\n", rsaKeySz, milliEach, ntimes);
-
-    if (ret < 0) {
-        printf("Rsa Public Encrypt failed\n");
-        return;
-    }
-
-    start = current_time(1);
-
-    for (i = 0; i < ntimes; i++) {
-         byte  out[256];  /* for up to 2048 bit */
-         wc_RsaPrivateDecrypt(enc, (word32)ret, out, sizeof(out), &rsaKey);
-    }
-
-    total = current_time(0) - start;
-    each  = total / ntimes;   /* per second   */
-    milliEach = each * 1000; /* milliseconds */
-
-    printf("RSA %d decryption took %6.3f milliseconds, avg over %d"
-           " iterations\n", rsaKeySz, milliEach, ntimes);
-
-    wc_FreeRsaKey(&rsaKey);
-#ifdef HAVE_CAVIUM
-    wc_RsaFreeCavium(&rsaKey);
-#endif
-}
-#endif
-
-
-#ifndef NO_DH
-
-
-#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
-    #if defined(WOLFSSL_MDK_SHELL)
-        static char *certDHname = "certs/dh2048.der";
-        /* set by shell command */
-        void set_Bench_DH_File(char * cert) { certDHname = cert ; }
-    #elif defined(FREESCALE_MQX)
-        static char *certDHname = "a:\\certs\\dh2048.der";
-    #elif defined(NO_ASN)
-        /* do nothing, but don't need a file */
-    #else
-        static const char *certDHname = "certs/dh2048.der";
-    #endif
-#endif
-
-void bench_dh(void)
-{
-    int    i ;
-    size_t bytes;
-    word32 idx = 0, pubSz, privSz = 0, pubSz2, privSz2, agreeSz;
-    const byte* tmp;
-
-    byte   pub[256];    /* for 2048 bit */
-    byte   pub2[256];   /* for 2048 bit */
-    byte   agree[256];  /* for 2048 bit */
-    byte   priv[32];    /* for 2048 bit */
-    byte   priv2[32];   /* for 2048 bit */
-
-    double start, total, each, milliEach;
-    DhKey  dhKey;
-    int    dhKeySz = 2048; /* used in printf */
-
-    (void)idx;
-    (void)tmp;
-
-
-#ifdef USE_CERT_BUFFERS_1024
-    tmp = dh_key_der_1024;
-    bytes = sizeof_dh_key_der_1024;
-    dhKeySz = 1024;
-#elif defined(USE_CERT_BUFFERS_2048)
-    tmp = dh_key_der_2048;
-    bytes = sizeof_dh_key_der_2048;
-#elif defined(NO_ASN)
-    dhKeySz = 1024;
-    /* do nothing, but don't use default FILE */
-#else
-    #error "need to define a cert buffer size"
-#endif /* USE_CERT_BUFFERS */
-
-		
-    wc_InitDhKey(&dhKey);
-#ifdef NO_ASN
-    bytes = wc_DhSetKey(&dhKey, dh_p, sizeof(dh_p), dh_g, sizeof(dh_g));
-#else
-    bytes = wc_DhKeyDecode(tmp, &idx, &dhKey, (word32)bytes);
-#endif
-    if (bytes != 0) {
-        printf("dhekydecode failed, can't benchmark\n");
-        return;
-    }
-
-    start = current_time(1);
-
-    for (i = 0; i < ntimes; i++)
-        wc_DhGenerateKeyPair(&dhKey, &rng, priv, &privSz, pub, &pubSz);
-
-    total = current_time(0) - start;
-    each  = total / ntimes;   /* per second   */
-    milliEach = each * 1000; /* milliseconds */
-
-    printf("DH  %d key generation  %6.3f milliseconds, avg over %d"
-           " iterations\n", dhKeySz, milliEach, ntimes);
-
-    wc_DhGenerateKeyPair(&dhKey, &rng, priv2, &privSz2, pub2, &pubSz2);
-    start = current_time(1);
-
-    for (i = 0; i < ntimes; i++)
-        wc_DhAgree(&dhKey, agree, &agreeSz, priv, privSz, pub2, pubSz2);
-
-    total = current_time(0) - start;
-    each  = total / ntimes;   /* per second   */
-    milliEach = each * 1000; /* milliseconds */
-
-    printf("DH  %d key agreement   %6.3f milliseconds, avg over %d"
-           " iterations\n", dhKeySz, milliEach, ntimes);
-
-    wc_FreeDhKey(&dhKey);
-}
-#endif
-
-#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA)
-void bench_rsaKeyGen(void)
-{
-    RsaKey genKey;
-    double start, total, each, milliEach;
-    int    i;
-  
-    /* 1024 bit */ 
-    start = current_time(1);
-
-    for(i = 0; i < genTimes; i++) {
-        wc_InitRsaKey(&genKey, 0); 
-        wc_MakeRsaKey(&genKey, 1024, 65537, &rng);
-        wc_FreeRsaKey(&genKey);
-    }
-
-    total = current_time(0) - start;
-    each  = total / genTimes;  /* per second  */
-    milliEach = each * 1000;   /* millisconds */
-    printf("\n");
-    printf("RSA 1024 key generation  %6.3f milliseconds, avg over %d"
-           " iterations\n", milliEach, genTimes);
-
-    /* 2048 bit */
-    start = current_time(1);
-
-    for(i = 0; i < genTimes; i++) {
-        wc_InitRsaKey(&genKey, 0); 
-        wc_MakeRsaKey(&genKey, 2048, 65537, &rng);
-        wc_FreeRsaKey(&genKey);
-    }
-
-    total = current_time(0) - start;
-    each  = total / genTimes;  /* per second  */
-    milliEach = each * 1000;   /* millisconds */
-    printf("RSA 2048 key generation  %6.3f milliseconds, avg over %d"
-           " iterations\n", milliEach, genTimes);
-}
-#endif /* WOLFSSL_KEY_GEN */
-#ifdef HAVE_NTRU
-byte GetEntropy(ENTROPY_CMD cmd, byte* out);
-
-byte GetEntropy(ENTROPY_CMD cmd, byte* out)
-{
-    if (cmd == INIT)
-        return (wc_InitRng(&rng) == 0) ? 1 : 0;
-
-    if (out == NULL)
-        return 0;
-
-    if (cmd == GET_BYTE_OF_ENTROPY)
-        return (wc_RNG_GenerateBlock(&rng, out, 1) == 0) ? 1 : 0;
-
-    if (cmd == GET_NUM_BYTES_PER_BYTE_OF_ENTROPY) {
-        *out = 1;
-        return 1;
-    }
-
-    return 0;
-}
-
-void bench_ntru(void)
-{
-    int    i;
-    double start, total, each, milliEach;
-
-    byte   public_key[557];
-    word16 public_key_len = sizeof(public_key);
-    byte   private_key[607];
-    word16 private_key_len = sizeof(private_key);
-
-    byte ciphertext[552];
-    word16 ciphertext_len;
-    byte plaintext[16];
-    word16 plaintext_len;
-
-    DRBG_HANDLE drbg;
-    static byte const aes_key[] = {
-        0xf3, 0xe9, 0x87, 0xbb, 0x18, 0x08, 0x3c, 0xaa,
-        0x7b, 0x12, 0x49, 0x88, 0xaf, 0xb3, 0x22, 0xd8
-    };
-
-    static byte const cyasslStr[] = {
-        'C', 'y', 'a', 'S', 'S', 'L', ' ', 'N', 'T', 'R', 'U'
-    };
-
-    word32 rc = ntru_crypto_drbg_instantiate(112, cyasslStr, sizeof(cyasslStr),
-                                            (ENTROPY_FN) GetEntropy, &drbg);
-    if(rc != DRBG_OK) {
-        printf("NTRU drbg instantiate failed\n");
-        return;
-    }
-
-    rc = ntru_crypto_ntru_encrypt_keygen(drbg, NTRU_EES401EP2, 
-        &public_key_len, NULL, &private_key_len, NULL);
-    if (rc != NTRU_OK) {
-        ntru_crypto_drbg_uninstantiate(drbg);
-        printf("NTRU failed to get key lengths\n");
-        return;
-    }
-
-    rc = ntru_crypto_ntru_encrypt_keygen(drbg, NTRU_EES401EP2, &public_key_len,
-                                     public_key, &private_key_len, 
-                                     private_key);
-
-    ntru_crypto_drbg_uninstantiate(drbg);
-
-    if (rc != NTRU_OK) {
-        ntru_crypto_drbg_uninstantiate(drbg);
-        printf("NTRU keygen failed\n");
-        return;
-    }
-
-    rc = ntru_crypto_drbg_instantiate(112, NULL, 0, (ENTROPY_FN)GetEntropy,
-                                      &drbg);
-    if (rc != DRBG_OK) {
-        printf("NTRU error occurred during DRBG instantiation\n");
-        return;
-    }
-
-    rc = ntru_crypto_ntru_encrypt(drbg, public_key_len, public_key, sizeof(
-        aes_key), aes_key, &ciphertext_len, NULL);
-
-    if (rc != NTRU_OK) {
-        printf("NTRU error occurred requesting the buffer size needed\n");
-        return;
-    }
-    start = current_time(1);
-
-    for (i = 0; i < ntimes; i++) {
-
-        rc = ntru_crypto_ntru_encrypt(drbg, public_key_len, public_key, sizeof(
-            aes_key), aes_key, &ciphertext_len, ciphertext);
-
-        if (rc != NTRU_OK) {
-            printf("NTRU encrypt error\n");
-            return;
-        }
-
-    }
-    rc = ntru_crypto_drbg_uninstantiate(drbg);
-
-    if (rc != DRBG_OK) {
-        printf("NTRU error occurred uninstantiating the DRBG\n");
-        return;
-    }
-
-    total = current_time(0) - start;
-    each  = total / ntimes;   /* per second   */
-    milliEach = each * 1000; /* milliseconds */
-
-    printf("NTRU 112 encryption took %6.3f milliseconds, avg over %d"
-           " iterations\n", milliEach, ntimes);
-
-
-    rc = ntru_crypto_ntru_decrypt(private_key_len, private_key, ciphertext_len,
-                                  ciphertext, &plaintext_len, NULL);
-
-    if (rc != NTRU_OK) {
-        printf("NTRU decrypt error occurred getting the buffer size needed\n");
-        return;
-    }
-
-    plaintext_len = sizeof(plaintext);
-    start = current_time(1);
-
-    for (i = 0; i < ntimes; i++) {
-        rc = ntru_crypto_ntru_decrypt(private_key_len, private_key,
-                                      ciphertext_len, ciphertext,
-                                      &plaintext_len, plaintext);
-
-        if (rc != NTRU_OK) {
-            printf("NTRU error occurred decrypting the key\n");
-            return;
-        }
-    }
-
-    total = current_time(0) - start;
-    each  = total / ntimes;   /* per second   */
-    milliEach = each * 1000; /* milliseconds */
-
-    printf("NTRU 112 decryption took %6.3f milliseconds, avg over %d"
-           " iterations\n", milliEach, ntimes);
-}
-
-void bench_ntruKeyGen(void)
-{
-    double start, total, each, milliEach;
-    int    i;
-
-    byte   public_key[557]; /* 2048 key equivalent to rsa */
-    word16 public_key_len = sizeof(public_key);
-    byte   private_key[607];
-    word16 private_key_len = sizeof(private_key);
-
-    DRBG_HANDLE drbg;
-    static uint8_t const pers_str[] = {
-                'C', 'y', 'a', 'S', 'S', 'L', ' ', 't', 'e', 's', 't'
-    };
-
-    word32 rc = ntru_crypto_drbg_instantiate(112, pers_str, sizeof(pers_str),
-                                             GetEntropy, &drbg);
-    if(rc != DRBG_OK) {
-        printf("NTRU drbg instantiate failed\n");
-        return;
-    }
-
-    start = current_time(1);
-
-    for(i = 0; i < genTimes; i++) {
-        ntru_crypto_ntru_encrypt_keygen(drbg, NTRU_EES401EP2, &public_key_len,
-                                     public_key, &private_key_len, 
-                                     private_key);
-    }
-
-    total = current_time(0) - start;
-
-    rc = ntru_crypto_drbg_uninstantiate(drbg);
-
-    if (rc != NTRU_OK) {
-        printf("NTRU drbg uninstantiate failed\n");
-        return;
-    }
-
-    each = total / genTimes;
-    milliEach = each * 1000;
-
-    printf("\n");
-    printf("NTRU 112 key generation  %6.3f milliseconds, avg over %d"
-        " iterations\n", milliEach, genTimes);
-
-}
-#endif
-
-#ifdef HAVE_ECC 
-void bench_eccKeyGen(void)
-{
-    ecc_key genKey;
-    double start, total, each, milliEach;
-    int    i;
-  
-    /* 256 bit */ 
-    start = current_time(1);
-
-    for(i = 0; i < genTimes; i++) {
-        wc_ecc_init(&genKey);
-        wc_ecc_make_key(&rng, 32, &genKey);
-        wc_ecc_free(&genKey);
-    }
-
-    total = current_time(0) - start;
-    each  = total / genTimes;  /* per second  */
-    milliEach = each * 1000;   /* millisconds */
-    printf("\n");
-    printf("ECC  256 key generation  %6.3f milliseconds, avg over %d"
-           " iterations\n", milliEach, genTimes);
-}
-
-
-void bench_eccKeyAgree(void)
-{
-    ecc_key genKey, genKey2;
-    double start, total, each, milliEach;
-    int    i, ret;
-    byte   shared[32];
-    byte   sig[64+16];  /* der encoding too */
-    byte   digest[32];
-    word32 x = 0;
-
-    wc_ecc_init(&genKey);
-    wc_ecc_init(&genKey2);
-
-    ret = wc_ecc_make_key(&rng, 32, &genKey);
-    if (ret != 0) {
-        printf("ecc_make_key failed\n");
-        return;
-    }
-    ret = wc_ecc_make_key(&rng, 32, &genKey2);
-    if (ret != 0) {
-        printf("ecc_make_key failed\n");
-        return;
-    }
-
-    /* 256 bit */
-    start = current_time(1);
-
-    for(i = 0; i < agreeTimes; i++) {
-        x = sizeof(shared);
-        ret = wc_ecc_shared_secret(&genKey, &genKey2, shared, &x);
-        if (ret != 0) {
-            printf("ecc_shared_secret failed\n");
-            return;
-        }
-    }
-
-    total = current_time(0) - start;
-    each  = total / agreeTimes;  /* per second  */
-    milliEach = each * 1000;   /* millisconds */
-    printf("EC-DHE   key agreement   %6.3f milliseconds, avg over %d"
-           " iterations\n", milliEach, agreeTimes);
-
-    /* make dummy digest */
-    for (i = 0; i < (int)sizeof(digest); i++)
-        digest[i] = (byte)i;
-
-
-    start = current_time(1);
-
-    for(i = 0; i < agreeTimes; i++) {
-        x = sizeof(sig);
-        ret = wc_ecc_sign_hash(digest, sizeof(digest), sig, &x, &rng, &genKey);
-        if (ret != 0) {
-            printf("ecc_sign_hash failed\n");
-            return; 
-        }
-    }
-
-    total = current_time(0) - start;
-    each  = total / agreeTimes;  /* per second  */
-    milliEach = each * 1000;   /* millisconds */
-    printf("EC-DSA   sign   time     %6.3f milliseconds, avg over %d"
-           " iterations\n", milliEach, agreeTimes);
-
-    start = current_time(1);
-
-    for(i = 0; i < agreeTimes; i++) {
-        int verify = 0;
-        ret = wc_ecc_verify_hash(sig, x, digest, sizeof(digest), &verify, &genKey);
-        if (ret != 0) {
-            printf("ecc_verify_hash failed\n");
-            return; 
-        }
-    }
-
-    total = current_time(0) - start;
-    each  = total / agreeTimes;  /* per second  */
-    milliEach = each * 1000;     /* millisconds */
-    printf("EC-DSA   verify time     %6.3f milliseconds, avg over %d"
-           " iterations\n", milliEach, agreeTimes);
-
-    wc_ecc_free(&genKey2);
-    wc_ecc_free(&genKey);
-}
-#endif /* HAVE_ECC */
-
-#ifdef HAVE_CURVE25519
-void bench_curve25519KeyGen(void)
-{
-    curve25519_key genKey;
-    double start, total, each, milliEach;
-    int    i;
-
-    /* 256 bit */
-    start = current_time(1);
-
-    for(i = 0; i < genTimes; i++) {
-        wc_curve25519_make_key(&rng, 32, &genKey);
-        wc_curve25519_free(&genKey);
-    }
-
-    total = current_time(0) - start;
-    each  = total / genTimes;  /* per second  */
-    milliEach = each * 1000;   /* millisconds */
-    printf("\n");
-    printf("CURVE25519 256 key generation %6.3f milliseconds, avg over %d"
-           " iterations\n", milliEach, genTimes);
-}
-
-
-void bench_curve25519KeyAgree(void)
-{
-    curve25519_key genKey, genKey2;
-    double start, total, each, milliEach;
-    int    i, ret;
-    byte   shared[32];
-    word32 x = 0;
-
-    wc_curve25519_init(&genKey);
-    wc_curve25519_init(&genKey2);
-
-    ret = wc_curve25519_make_key(&rng, 32, &genKey);
-    if (ret != 0) {
-        printf("curve25519_make_key failed\n");
-        return;
-    }
-    ret = wc_curve25519_make_key(&rng, 32, &genKey2);
-    if (ret != 0) {
-        printf("curve25519_make_key failed\n");
-        return;
-    }
-
-    /* 256 bit */
-    start = current_time(1);
-
-    for(i = 0; i < agreeTimes; i++) {
-        x = sizeof(shared);
-        ret = wc_curve25519_shared_secret(&genKey, &genKey2, shared, &x);
-        if (ret != 0) {
-            printf("curve25519_shared_secret failed\n");
-            return;
-        }
-    }
-
-    total = current_time(0) - start;
-    each  = total / agreeTimes;  /* per second  */
-    milliEach = each * 1000;   /* millisconds */
-    printf("CURVE25519 key agreement      %6.3f milliseconds, avg over %d"
-           " iterations\n", milliEach, agreeTimes);
-
-    wc_curve25519_free(&genKey2);
-    wc_curve25519_free(&genKey);
-}
-#endif /* HAVE_CURVE25519 */
-
-#ifdef HAVE_ED25519
-void bench_ed25519KeyGen(void)
-{
-    ed25519_key genKey;
-    double start, total, each, milliEach;
-    int    i;
-
-    /* 256 bit */
-    start = current_time(1);
-
-    for(i = 0; i < genTimes; i++) {
-        wc_ed25519_init(&genKey);
-        wc_ed25519_make_key(&rng, 32, &genKey);
-        wc_ed25519_free(&genKey);
-    }
-
-    total = current_time(0) - start;
-    each  = total / genTimes;  /* per second  */
-    milliEach = each * 1000;   /* millisconds */
-    printf("\n");
-    printf("ED25519  key generation  %6.3f milliseconds, avg over %d"
-           " iterations\n", milliEach, genTimes);
-}
-
-
-void bench_ed25519KeySign(void)
-{
-    ed25519_key genKey;
-    double start, total, each, milliEach;
-    int    i, ret;
-    byte   sig[ED25519_SIG_SIZE];
-    byte   msg[512];
-    word32 x = 0;
-
-    wc_ed25519_init(&genKey);
-
-    ret = wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &genKey);
-    if (ret != 0) {
-        printf("ed25519_make_key failed\n");
-        return;
-    }
-    /* make dummy msg */
-    for (i = 0; i < (int)sizeof(msg); i++)
-        msg[i] = (byte)i;
-
-
-    start = current_time(1);
-
-    for(i = 0; i < agreeTimes; i++) {
-        x = sizeof(sig);
-        ret = wc_ed25519_sign_msg(msg, sizeof(msg), sig, &x, &genKey);
-        if (ret != 0) {
-            printf("ed25519_sign_msg failed\n");
-            return;
-        }
-    }
-
-    total = current_time(0) - start;
-    each  = total / agreeTimes;  /* per second  */
-    milliEach = each * 1000;   /* millisconds */
-    printf("ED25519  sign   time     %6.3f milliseconds, avg over %d"
-           " iterations\n", milliEach, agreeTimes);
-
-    start = current_time(1);
-
-    for(i = 0; i < agreeTimes; i++) {
-        int verify = 0;
-        ret = wc_ed25519_verify_msg(sig, x, msg, sizeof(msg), &verify,
-                                    &genKey);
-        if (ret != 0 || verify != 1) {
-            printf("ed25519_verify_msg failed\n");
-            return;
-        }
-    }
-
-    total = current_time(0) - start;
-    each  = total / agreeTimes;  /* per second  */
-    milliEach = each * 1000;     /* millisconds */
-    printf("ED25519  verify time     %6.3f milliseconds, avg over %d"
-           " iterations\n", milliEach, agreeTimes);
-
-    wc_ed25519_free(&genKey);
-}
-#endif /* HAVE_ED25519 */
-
-
-#ifdef _WIN32
-
-    #define WIN32_LEAN_AND_MEAN
-    #include 
-
-    double current_time(int reset)
-    {
-        static int init = 0;
-        static LARGE_INTEGER freq;
-    
-        LARGE_INTEGER count;
-
-        (void)reset;
-
-        if (!init) {
-            QueryPerformanceFrequency(&freq);
-            init = 1;
-        }
-
-        QueryPerformanceCounter(&count);
-
-        return (double)count.QuadPart / freq.QuadPart;
-    }
-
-#elif defined MICROCHIP_PIC32
-    #if defined(WOLFSSL_MICROCHIP_PIC32MZ)
-        #define CLOCK 80000000.0
-    #else
-        #include 
-        #define CLOCK 40000000.0
-    #endif
-
-    double current_time(int reset)
-    {
-        unsigned int ns;
-
-        if (reset) {
-            WriteCoreTimer(0);
-        }
-
-        /* get timer in ns */
-        ns = ReadCoreTimer();
-
-        /* return seconds as a double */
-        return ( ns / CLOCK * 2.0);
-    }
-
-#elif defined(WOLFSSL_IAR_ARM_TIME) || defined (WOLFSSL_MDK_ARM) || defined(WOLFSSL_USER_CURRTIME)
-    extern   double current_time(int reset);
-    
-#elif defined FREERTOS
-
-    double current_time(int reset)
-    {
-        portTickType tickCount;
-
-        (void) reset;
-
-        /* tick count == ms, if configTICK_RATE_HZ is set to 1000 */
-        tickCount = xTaskGetTickCount();
-        return (double)tickCount / 1000;
-    }
-
-#elif defined (WOLFSSL_TIRTOS)
-
-    extern double current_time(int reset);
-
-#elif defined(FREESCALE_MQX)
-
-    double current_time(int reset)
-    {
-        TIME_STRUCT tv;
-        _time_get(&tv);
-
-        return (double)tv.SECONDS + (double)tv.MILLISECONDS / 1000;
-    }
-
-#else
-
-    #include 
-
-    double current_time(int reset)
-    {
-        struct timeval tv;
-
-        (void)reset;
-
-        gettimeofday(&tv, 0);
-
-        return (double)tv.tv_sec + (double)tv.tv_usec / 1000000;
-    }
-
-#endif /* _WIN32 */
-
-#ifdef HAVE_GET_CYCLES
-
-static INLINE word64 get_intel_cycles(void)
-{
-    unsigned int lo_c, hi_c;
-    __asm__ __volatile__ (
-        "cpuid\n\t"
-        "rdtsc"
-            : "=a"(lo_c), "=d"(hi_c)   /* out */
-            : "a"(0)                   /* in */
-            : "%ebx", "%ecx");         /* clobber */
-    return ((word64)lo_c) | (((word64)hi_c) << 32);
-}
-
-#endif /* HAVE_GET_CYCLES */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/benchmark/benchmark.sln b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/benchmark/benchmark.sln
deleted file mode 100755
index e3e9483..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/benchmark/benchmark.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual C++ Express 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "benchmark", "benchmark.vcproj", "{615AEC46-5595-4DEA-9490-DBD5DE0F8772}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{615AEC46-5595-4DEA-9490-DBD5DE0F8772}.Debug|Win32.ActiveCfg = Debug|Win32
-		{615AEC46-5595-4DEA-9490-DBD5DE0F8772}.Debug|Win32.Build.0 = Debug|Win32
-		{615AEC46-5595-4DEA-9490-DBD5DE0F8772}.Release|Win32.ActiveCfg = Release|Win32
-		{615AEC46-5595-4DEA-9490-DBD5DE0F8772}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/benchmark/benchmark.vcproj b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/benchmark/benchmark.vcproj
deleted file mode 100755
index 5db23c3..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/benchmark/benchmark.vcproj
+++ /dev/null
@@ -1,195 +0,0 @@
-
-
-	
-		
-	
-	
-	
-	
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-	
-	
-	
-	
-		
-		
-		
-		
-		
-			
-			
-		
-	
-	
-	
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/benchmark/include.am b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/benchmark/include.am
deleted file mode 100755
index db70ba7..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/benchmark/include.am
+++ /dev/null
@@ -1,10 +0,0 @@
-# vim:ft=automake
-# All paths should be given relative to the root
-
-noinst_PROGRAMS += wolfcrypt/benchmark/benchmark
-wolfcrypt_benchmark_benchmark_SOURCES      = wolfcrypt/benchmark/benchmark.c
-wolfcrypt_benchmark_benchmark_LDADD        = src/libwolfssl.la
-wolfcrypt_benchmark_benchmark_DEPENDENCIES = src/libwolfssl.la
-EXTRA_DIST += wolfcrypt/benchmark/benchmark.sln 
-EXTRA_DIST += wolfcrypt/benchmark/benchmark.vcproj
-DISTCLEANFILES+= wolfcrypt/benchmark/.libs/benchmark
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/aes.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/aes.c
deleted file mode 100755
index 85f01a0..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/aes.c
+++ /dev/null
@@ -1,3897 +0,0 @@
-/* aes.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef NO_AES
-
-#include 
-
-#ifdef HAVE_FIPS
-int wc_AesSetKey(Aes* aes, const byte* key, word32 len, const byte* iv,
-                          int dir)
-{
-    return AesSetKey_fips(aes, key, len, iv, dir);
-}
-
-
-int wc_AesSetIV(Aes* aes, const byte* iv)
-{
-    return AesSetIV_fips(aes, iv);
-}
-
-
-int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-{
-    return AesCbcEncrypt_fips(aes, out, in, sz);
-}
-
-
-int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-{
-    return AesCbcDecrypt_fips(aes, out, in, sz);
-}
-
-
-int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
-                                 const byte* key, word32 keySz, const byte* iv)
-{
-    return AesCbcDecryptWithKey(out, in, inSz, key, keySz, iv);
-}
-
-
-/* AES-CTR */
-#ifdef WOLFSSL_AES_COUNTER
-void wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-{
-    AesCtrEncrypt(aes, out, in, sz);
-}
-#endif
-
-/* AES-DIRECT */
-#if defined(WOLFSSL_AES_DIRECT)
-void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
-{
-    AesEncryptDirect(aes, out, in);
-}
-
-
-void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in)
-{
-    AesDecryptDirect(aes, out, in);
-}
-
-
-int wc_AesSetKeyDirect(Aes* aes, const byte* key, word32 len,
-                                const byte* iv, int dir)
-{
-    return AesSetKeyDirect(aes, key, len, iv, dir);
-}
-#endif
-
-
-#ifdef HAVE_AESGCM
-int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
-{
-    return AesGcmSetKey_fips(aes, key, len);
-}
-
-
-int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
-                              const byte* iv, word32 ivSz,
-                              byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz)
-{
-    return AesGcmEncrypt_fips(aes, out, in, sz, iv, ivSz, authTag, authTagSz,
-                              authIn, authInSz);
-}
-
-
-int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
-                              const byte* iv, word32 ivSz,
-                              const byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz)
-{
-    return AesGcmDecrypt_fips(aes, out, in, sz, iv, ivSz, authTag, authTagSz,
-                              authIn, authInSz);
-}
-
-
-int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len)
-{
-    return GmacSetKey(gmac, key, len);
-}
-
-
-int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
-                              const byte* authIn, word32 authInSz,
-                              byte* authTag, word32 authTagSz)
-{
-    return GmacUpdate(gmac, iv, ivSz, authIn, authInSz,
-                      authTag, authTagSz);
-}
-
-#endif /* HAVE_AESGCM */
-#ifdef HAVE_AESCCM
-void wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz)
-{
-    AesCcmSetKey(aes, key, keySz);
-}
-
-
-void wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
-                              const byte* nonce, word32 nonceSz,
-                              byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz)
-{
-    AesCcmEncrypt(aes, out, in, inSz, nonce, nonceSz, authTag, authTagSz,
-                  authIn, authInSz);
-}
-
-
-int  wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
-                              const byte* nonce, word32 nonceSz,
-                              const byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz)
-{
-    return AesCcmDecrypt(aes, out, in, inSz, nonce, nonceSz, authTag, authTagSz,
-                         authIn, authInSz);
-}
-#endif /* HAVE_AESCCM */
-
-#ifdef HAVE_CAVIUM
-int  wc_AesInitCavium(Aes* aes, int i)
-{
-    return AesInitCavium(aes, i);
-}
-
-
-void wc_AesFreeCavium(Aes* aes)
-{
-    AesFreeCavium(aes);
-}
-#endif
-#else /* HAVE_FIPS */
-
-#ifdef WOLFSSL_TI_CRYPT
-#include 
-#else
-
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-#ifdef DEBUG_AESNI
-    #include 
-#endif
-
-
-#ifdef _MSC_VER
-    /* 4127 warning constant while(1)  */
-    #pragma warning(disable: 4127)
-#endif
-
-
-#if defined(STM32F2_CRYPTO)
-     /* STM32F2 hardware AES support for CBC, CTR modes through the STM32F2
-      * Standard Peripheral Library. Documentation located in STM32F2xx
-      * Standard Peripheral Library document (See note in README).
-      * NOTE: no support for AES-GCM/CCM/Direct */
-    #include "stm32f2xx.h"
-    #include "stm32f2xx_cryp.h"
-#elif defined(HAVE_COLDFIRE_SEC)
-    /* Freescale Coldfire SEC support for CBC mode.
-     * NOTE: no support for AES-CTR/GCM/CCM/Direct */
-    #include 
-    #include "sec.h"
-    #include "mcf5475_sec.h"
-    #include "mcf5475_siu.h"
-#elif defined(FREESCALE_MMCAU)
-    /* Freescale mmCAU hardware AES support for Direct, CBC, CCM, GCM modes
-     * through the CAU/mmCAU library. Documentation located in
-     * ColdFire/ColdFire+ CAU and Kinetis mmCAU Software Library User
-     * Guide (See note in README).
-     * NOTE: no support for AES-CTR */
-    #include "cau_api.h"
-#elif defined(WOLFSSL_PIC32MZ_CRYPT)
-    /* NOTE: no support for AES-CCM/Direct */
-    #define DEBUG_WOLFSSL
-    #include "wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h"
-#elif defined(HAVE_CAVIUM)
-    #include 
-    #include "cavium_common.h"
-
-    /* still leave SW crypto available */
-    #define NEED_AES_TABLES
-
-    static int  wc_AesCaviumSetKey(Aes* aes, const byte* key, word32 length,
-                                const byte* iv);
-    static int  wc_AesCaviumCbcEncrypt(Aes* aes, byte* out, const byte* in,
-                                    word32 length);
-    static int  wc_AesCaviumCbcDecrypt(Aes* aes, byte* out, const byte* in,
-                                    word32 length);
-#else
-    /* using CTaoCrypt software AES implementation */
-    #define NEED_AES_TABLES
-#endif /* STM32F2_CRYPTO */
-
-
-#ifdef NEED_AES_TABLES
-
-static const word32 rcon[] = {
-    0x01000000, 0x02000000, 0x04000000, 0x08000000,
-    0x10000000, 0x20000000, 0x40000000, 0x80000000,
-    0x1B000000, 0x36000000,
-    /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
-};
-
-static const word32 Te[5][256] = {
-{
-    0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,
-    0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U,
-    0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU,
-    0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU,
-    0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U,
-    0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU,
-    0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU,
-    0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU,
-    0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU,
-    0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU,
-    0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U,
-    0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU,
-    0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU,
-    0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U,
-    0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU,
-    0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU,
-    0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU,
-    0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU,
-    0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU,
-    0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U,
-    0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU,
-    0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU,
-    0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU,
-    0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU,
-    0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U,
-    0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U,
-    0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U,
-    0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U,
-    0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU,
-    0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U,
-    0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U,
-    0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU,
-    0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU,
-    0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U,
-    0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U,
-    0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U,
-    0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU,
-    0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U,
-    0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU,
-    0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U,
-    0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU,
-    0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U,
-    0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U,
-    0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU,
-    0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U,
-    0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U,
-    0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U,
-    0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U,
-    0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U,
-    0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U,
-    0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U,
-    0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U,
-    0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU,
-    0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U,
-    0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U,
-    0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U,
-    0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U,
-    0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U,
-    0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U,
-    0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU,
-    0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U,
-    0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U,
-    0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U,
-    0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU,
-},
-{
-    0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU,
-    0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U,
-    0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU,
-    0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U,
-    0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU,
-    0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U,
-    0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU,
-    0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U,
-    0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U,
-    0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU,
-    0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U,
-    0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U,
-    0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U,
-    0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU,
-    0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U,
-    0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U,
-    0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU,
-    0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U,
-    0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U,
-    0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U,
-    0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU,
-    0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU,
-    0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U,
-    0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU,
-    0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU,
-    0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U,
-    0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU,
-    0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U,
-    0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU,
-    0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U,
-    0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U,
-    0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U,
-    0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU,
-    0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U,
-    0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU,
-    0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U,
-    0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU,
-    0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U,
-    0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U,
-    0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU,
-    0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU,
-    0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU,
-    0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U,
-    0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U,
-    0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU,
-    0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U,
-    0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU,
-    0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U,
-    0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU,
-    0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U,
-    0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU,
-    0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU,
-    0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U,
-    0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU,
-    0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U,
-    0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU,
-    0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U,
-    0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U,
-    0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U,
-    0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU,
-    0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU,
-    0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U,
-    0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU,
-    0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U,
-},
-{
-    0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU,
-    0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U,
-    0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU,
-    0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U,
-    0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU,
-    0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U,
-    0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU,
-    0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U,
-    0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U,
-    0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU,
-    0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U,
-    0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U,
-    0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U,
-    0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU,
-    0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U,
-    0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U,
-    0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU,
-    0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U,
-    0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U,
-    0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U,
-    0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU,
-    0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU,
-    0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U,
-    0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU,
-    0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU,
-    0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U,
-    0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU,
-    0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U,
-    0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU,
-    0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U,
-    0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U,
-    0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U,
-    0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU,
-    0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U,
-    0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU,
-    0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U,
-    0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU,
-    0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U,
-    0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U,
-    0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU,
-    0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU,
-    0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU,
-    0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U,
-    0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U,
-    0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU,
-    0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U,
-    0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU,
-    0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U,
-    0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU,
-    0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U,
-    0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU,
-    0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU,
-    0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U,
-    0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU,
-    0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U,
-    0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU,
-    0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U,
-    0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U,
-    0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U,
-    0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU,
-    0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU,
-    0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U,
-    0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU,
-    0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U,
-},
-{
-    0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U,
-    0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U,
-    0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U,
-    0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU,
-    0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU,
-    0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU,
-    0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U,
-    0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU,
-    0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU,
-    0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U,
-    0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U,
-    0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU,
-    0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU,
-    0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU,
-    0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU,
-    0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU,
-    0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U,
-    0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU,
-    0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU,
-    0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U,
-    0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U,
-    0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U,
-    0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U,
-    0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U,
-    0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU,
-    0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U,
-    0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU,
-    0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU,
-    0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U,
-    0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U,
-    0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U,
-    0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU,
-    0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U,
-    0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU,
-    0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU,
-    0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U,
-    0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U,
-    0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU,
-    0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U,
-    0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU,
-    0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U,
-    0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U,
-    0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U,
-    0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U,
-    0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU,
-    0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U,
-    0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU,
-    0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U,
-    0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU,
-    0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U,
-    0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU,
-    0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU,
-    0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU,
-    0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU,
-    0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U,
-    0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U,
-    0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U,
-    0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U,
-    0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U,
-    0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U,
-    0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU,
-    0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U,
-    0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU,
-    0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU,
-},
-{
-    0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU,
-    0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U,
-    0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU,
-    0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U,
-    0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU,
-    0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U,
-    0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU,
-    0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U,
-    0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U,
-    0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU,
-    0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U,
-    0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U,
-    0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U,
-    0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU,
-    0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U,
-    0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U,
-    0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU,
-    0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U,
-    0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U,
-    0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U,
-    0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU,
-    0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU,
-    0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U,
-    0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU,
-    0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU,
-    0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U,
-    0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU,
-    0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U,
-    0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU,
-    0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U,
-    0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U,
-    0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U,
-    0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU,
-    0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U,
-    0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU,
-    0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U,
-    0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU,
-    0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U,
-    0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U,
-    0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU,
-    0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU,
-    0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU,
-    0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U,
-    0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U,
-    0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU,
-    0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U,
-    0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU,
-    0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U,
-    0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU,
-    0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U,
-    0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU,
-    0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU,
-    0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U,
-    0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU,
-    0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U,
-    0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU,
-    0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U,
-    0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U,
-    0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U,
-    0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU,
-    0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU,
-    0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U,
-    0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU,
-    0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U,
-}
-};
-
-static const word32 Td[5][256] = {
-{
-    0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U,
-    0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U,
-    0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U,
-    0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU,
-    0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U,
-    0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U,
-    0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU,
-    0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U,
-    0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU,
-    0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U,
-    0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U,
-    0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U,
-    0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U,
-    0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU,
-    0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U,
-    0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU,
-    0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U,
-    0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU,
-    0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U,
-    0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U,
-    0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U,
-    0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU,
-    0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U,
-    0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU,
-    0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U,
-    0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU,
-    0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U,
-    0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU,
-    0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU,
-    0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U,
-    0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU,
-    0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U,
-    0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU,
-    0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U,
-    0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U,
-    0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U,
-    0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU,
-    0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U,
-    0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U,
-    0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU,
-    0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U,
-    0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U,
-    0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U,
-    0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U,
-    0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U,
-    0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU,
-    0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U,
-    0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U,
-    0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U,
-    0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U,
-    0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U,
-    0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU,
-    0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU,
-    0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU,
-    0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU,
-    0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U,
-    0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U,
-    0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU,
-    0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU,
-    0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U,
-    0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU,
-    0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U,
-    0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U,
-    0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U,
-},
-{
-    0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU,
-    0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U,
-    0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU,
-    0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U,
-    0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U,
-    0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U,
-    0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U,
-    0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U,
-    0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U,
-    0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU,
-    0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU,
-    0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU,
-    0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U,
-    0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU,
-    0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U,
-    0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U,
-    0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U,
-    0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU,
-    0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU,
-    0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U,
-    0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU,
-    0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U,
-    0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU,
-    0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU,
-    0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U,
-    0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U,
-    0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U,
-    0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU,
-    0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U,
-    0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU,
-    0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U,
-    0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U,
-    0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U,
-    0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU,
-    0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U,
-    0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U,
-    0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U,
-    0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U,
-    0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U,
-    0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U,
-    0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU,
-    0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU,
-    0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U,
-    0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU,
-    0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U,
-    0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU,
-    0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU,
-    0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U,
-    0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU,
-    0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U,
-    0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U,
-    0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U,
-    0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U,
-    0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U,
-    0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U,
-    0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U,
-    0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU,
-    0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U,
-    0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U,
-    0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU,
-    0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U,
-    0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U,
-    0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U,
-    0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U,
-},
-{
-    0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U,
-    0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U,
-    0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U,
-    0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U,
-    0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU,
-    0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U,
-    0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U,
-    0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U,
-    0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U,
-    0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU,
-    0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U,
-    0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U,
-    0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU,
-    0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U,
-    0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U,
-    0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U,
-    0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U,
-    0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U,
-    0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U,
-    0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU,
-
-    0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U,
-    0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U,
-    0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U,
-    0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U,
-    0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U,
-    0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU,
-    0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU,
-    0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U,
-    0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU,
-    0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U,
-    0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU,
-    0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU,
-    0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU,
-    0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU,
-    0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U,
-    0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U,
-    0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U,
-    0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U,
-    0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U,
-    0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U,
-    0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U,
-    0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU,
-    0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU,
-    0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U,
-    0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U,
-    0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU,
-    0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU,
-    0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U,
-    0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U,
-    0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U,
-    0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U,
-    0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U,
-    0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U,
-    0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U,
-    0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU,
-    0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U,
-    0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U,
-    0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U,
-    0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U,
-    0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U,
-    0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U,
-    0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU,
-    0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U,
-    0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U,
-},
-{
-    0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU,
-    0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU,
-    0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U,
-    0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U,
-    0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU,
-    0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU,
-    0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U,
-    0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU,
-    0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U,
-    0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU,
-    0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U,
-    0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U,
-    0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U,
-    0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U,
-    0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U,
-    0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU,
-    0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU,
-    0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U,
-    0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U,
-    0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU,
-    0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU,
-    0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U,
-    0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U,
-    0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U,
-    0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U,
-    0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU,
-    0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U,
-    0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U,
-    0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU,
-    0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU,
-    0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U,
-    0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U,
-    0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U,
-    0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU,
-    0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U,
-    0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U,
-    0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U,
-    0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U,
-    0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U,
-    0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U,
-    0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U,
-    0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU,
-    0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U,
-    0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U,
-    0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU,
-    0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU,
-    0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U,
-    0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU,
-    0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U,
-    0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U,
-    0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U,
-    0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U,
-    0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U,
-    0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U,
-    0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU,
-    0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU,
-    0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU,
-    0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU,
-    0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U,
-    0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U,
-    0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U,
-    0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU,
-    0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U,
-    0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U,
-},
-{
-    0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U,
-    0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U,
-    0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU,
-    0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU,
-    0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U,
-    0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U,
-    0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U,
-    0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU,
-    0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U,
-    0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU,
-    0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU,
-    0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU,
-    0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U,
-    0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U,
-    0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U,
-    0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U,
-    0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U,
-    0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U,
-    0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU,
-    0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U,
-    0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U,
-    0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU,
-    0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U,
-    0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U,
-    0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U,
-    0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU,
-    0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U,
-    0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U,
-    0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU,
-    0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U,
-    0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U,
-    0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU,
-    0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U,
-    0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU,
-    0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU,
-    0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U,
-    0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U,
-    0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U,
-    0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U,
-    0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU,
-    0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U,
-    0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U,
-    0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU,
-    0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU,
-    0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU,
-    0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U,
-    0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU,
-    0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U,
-    0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U,
-    0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U,
-    0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U,
-    0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU,
-    0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U,
-    0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU,
-    0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU,
-    0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU,
-    0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU,
-    0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U,
-    0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU,
-    0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U,
-    0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU,
-    0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U,
-    0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U,
-    0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU,
-}
-};
-
-#define GETBYTE(x, y) (word32)((byte)((x) >> (8 * (y))))
-
-#ifdef WOLFSSL_AESNI
-
-/* Each platform needs to query info type 1 from cpuid to see if aesni is
- * supported. Also, let's setup a macro for proper linkage w/o ABI conflicts
- */
-
-#ifndef _MSC_VER
-
-    #define cpuid(reg, func)\
-        __asm__ __volatile__ ("cpuid":\
-             "=a" (reg[0]), "=b" (reg[1]), "=c" (reg[2]), "=d" (reg[3]) :\
-             "a" (func));
-
-    #define XASM_LINK(f) asm(f)
-#else
-
-    #include 
-    #define cpuid(a,b) __cpuid((int*)a,b)
-
-    #define XASM_LINK(f)
-
-#endif /* _MSC_VER */
-
-
-static int Check_CPU_support_AES(void)
-{
-    unsigned int reg[4];  /* put a,b,c,d into 0,1,2,3 */
-    cpuid(reg, 1);        /* query info 1 */
-
-    if (reg[2] & 0x2000000)
-        return 1;
-
-    return 0;
-}
-
-static int checkAESNI = 0;
-static int haveAESNI  = 0;
-
-
-/* tell C compiler these are asm functions in case any mix up of ABI underscore
-   prefix between clang/gcc/llvm etc */
-void AES_CBC_encrypt(const unsigned char* in, unsigned char* out,
-                     unsigned char* ivec, unsigned long length,
-                     const unsigned char* KS, int nr)
-                     XASM_LINK("AES_CBC_encrypt");
-
-
-void AES_CBC_decrypt(const unsigned char* in, unsigned char* out,
-                     unsigned char* ivec, unsigned long length,
-                     const unsigned char* KS, int nr)
-                     XASM_LINK("AES_CBC_decrypt");
-
-void AES_ECB_encrypt(const unsigned char* in, unsigned char* out,
-                     unsigned long length, const unsigned char* KS, int nr)
-                     XASM_LINK("AES_ECB_encrypt");
-
-
-void AES_ECB_decrypt(const unsigned char* in, unsigned char* out,
-                     unsigned long length, const unsigned char* KS, int nr)
-                     XASM_LINK("AES_ECB_decrypt");
-
-void AES_128_Key_Expansion(const unsigned char* userkey,
-                           unsigned char* key_schedule)
-                           XASM_LINK("AES_128_Key_Expansion");
-
-void AES_192_Key_Expansion(const unsigned char* userkey,
-                           unsigned char* key_schedule)
-                           XASM_LINK("AES_192_Key_Expansion");
-
-void AES_256_Key_Expansion(const unsigned char* userkey,
-                           unsigned char* key_schedule)
-                           XASM_LINK("AES_256_Key_Expansion");
-
-
-static int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
-                               Aes* aes)
-{
-    if (!userKey || !aes)
-        return BAD_FUNC_ARG;
-
-    if (bits == 128) {
-       AES_128_Key_Expansion (userKey,(byte*)aes->key); aes->rounds = 10;
-       return 0;
-    }
-    else if (bits == 192) {
-       AES_192_Key_Expansion (userKey,(byte*)aes->key); aes->rounds = 12;
-       return 0;
-    }
-    else if (bits == 256) {
-       AES_256_Key_Expansion (userKey,(byte*)aes->key); aes->rounds = 14;
-       return 0;
-    }
-    return BAD_FUNC_ARG;
-}
-
-
-static int AES_set_decrypt_key(const unsigned char* userKey, const int bits,
-                               Aes* aes)
-{
-    int nr;
-    Aes temp_key;
-    __m128i *Key_Schedule = (__m128i*)aes->key;
-    __m128i *Temp_Key_Schedule = (__m128i*)temp_key.key;
-
-    if (!userKey || !aes)
-        return BAD_FUNC_ARG;
-
-    if (AES_set_encrypt_key(userKey,bits,&temp_key) == BAD_FUNC_ARG)
-        return BAD_FUNC_ARG;
-
-    nr = temp_key.rounds;
-    aes->rounds = nr;
-
-    Key_Schedule[nr] = Temp_Key_Schedule[0];
-    Key_Schedule[nr-1] = _mm_aesimc_si128(Temp_Key_Schedule[1]);
-    Key_Schedule[nr-2] = _mm_aesimc_si128(Temp_Key_Schedule[2]);
-    Key_Schedule[nr-3] = _mm_aesimc_si128(Temp_Key_Schedule[3]);
-    Key_Schedule[nr-4] = _mm_aesimc_si128(Temp_Key_Schedule[4]);
-    Key_Schedule[nr-5] = _mm_aesimc_si128(Temp_Key_Schedule[5]);
-    Key_Schedule[nr-6] = _mm_aesimc_si128(Temp_Key_Schedule[6]);
-    Key_Schedule[nr-7] = _mm_aesimc_si128(Temp_Key_Schedule[7]);
-    Key_Schedule[nr-8] = _mm_aesimc_si128(Temp_Key_Schedule[8]);
-    Key_Schedule[nr-9] = _mm_aesimc_si128(Temp_Key_Schedule[9]);
-
-    if(nr>10) {
-        Key_Schedule[nr-10] = _mm_aesimc_si128(Temp_Key_Schedule[10]);
-        Key_Schedule[nr-11] = _mm_aesimc_si128(Temp_Key_Schedule[11]);
-    }
-
-    if(nr>12) {
-        Key_Schedule[nr-12] = _mm_aesimc_si128(Temp_Key_Schedule[12]);
-        Key_Schedule[nr-13] = _mm_aesimc_si128(Temp_Key_Schedule[13]);
-    }
-
-    Key_Schedule[0] = Temp_Key_Schedule[nr];
-
-    return 0;
-}
-
-
-
-#endif /* WOLFSSL_AESNI */
-
-
-static void wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
-{
-    word32 s0, s1, s2, s3;
-    word32 t0, t1, t2, t3;
-    word32 r = aes->rounds >> 1;
-
-    const word32* rk = aes->key;
-    if (r > 7 || r == 0) {
-        WOLFSSL_MSG("AesEncrypt encountered improper key, set it up");
-        return;  /* stop instead of segfaulting, set up your keys! */
-    }
-#ifdef WOLFSSL_AESNI
-    if (haveAESNI && aes->use_aesni) {
-        #ifdef DEBUG_AESNI
-            printf("about to aes encrypt\n");
-            printf("in  = %p\n", inBlock);
-            printf("out = %p\n", outBlock);
-            printf("aes->key = %p\n", aes->key);
-            printf("aes->rounds = %d\n", aes->rounds);
-            printf("sz = %d\n", AES_BLOCK_SIZE);
-        #endif
-
-        /* check alignment, decrypt doesn't need alignment */
-        if ((wolfssl_word)inBlock % 16) {
-        #ifndef NO_WOLFSSL_ALLOC_ALIGN
-            byte* tmp = (byte*)XMALLOC(AES_BLOCK_SIZE, NULL,
-                                                      DYNAMIC_TYPE_TMP_BUFFER);
-            if (tmp == NULL) return;
-
-            XMEMCPY(tmp, inBlock, AES_BLOCK_SIZE);
-            AES_ECB_encrypt(tmp, tmp, AES_BLOCK_SIZE, (byte*)aes->key,
-                            aes->rounds);
-            XMEMCPY(outBlock, tmp, AES_BLOCK_SIZE);
-            XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            return;
-        #else
-            WOLFSSL_MSG("AES-ECB encrypt with bad alignment");
-            return;
-        #endif
-        }
-
-        AES_ECB_encrypt(inBlock, outBlock, AES_BLOCK_SIZE, (byte*)aes->key,
-                        aes->rounds);
-
-        return;
-    }
-    else {
-        #ifdef DEBUG_AESNI
-            printf("Skipping AES-NI\n");
-        #endif
-    }
-#endif
-
-    /*
-     * map byte array block to cipher state
-     * and add initial round key:
-     */
-    XMEMCPY(&s0, inBlock,                  sizeof(s0));
-    XMEMCPY(&s1, inBlock + sizeof(s0),     sizeof(s1));
-    XMEMCPY(&s2, inBlock + 2 * sizeof(s0), sizeof(s2));
-    XMEMCPY(&s3, inBlock + 3 * sizeof(s0), sizeof(s3));
-
-    #ifdef LITTLE_ENDIAN_ORDER
-        s0 = ByteReverseWord32(s0);
-        s1 = ByteReverseWord32(s1);
-        s2 = ByteReverseWord32(s2);
-        s3 = ByteReverseWord32(s3);
-    #endif
-
-    s0 ^= rk[0];
-    s1 ^= rk[1];
-    s2 ^= rk[2];
-    s3 ^= rk[3];
-
-    /*
-     * Nr - 1 full rounds:
-     */
-
-    for (;;) {
-        t0 =
-            Te[0][GETBYTE(s0, 3)]  ^
-            Te[1][GETBYTE(s1, 2)]  ^
-            Te[2][GETBYTE(s2, 1)]  ^
-            Te[3][GETBYTE(s3, 0)]  ^
-            rk[4];
-        t1 =
-            Te[0][GETBYTE(s1, 3)]  ^
-            Te[1][GETBYTE(s2, 2)]  ^
-            Te[2][GETBYTE(s3, 1)]  ^
-            Te[3][GETBYTE(s0, 0)]  ^
-            rk[5];
-        t2 =
-            Te[0][GETBYTE(s2, 3)] ^
-            Te[1][GETBYTE(s3, 2)]  ^
-            Te[2][GETBYTE(s0, 1)]  ^
-            Te[3][GETBYTE(s1, 0)]  ^
-            rk[6];
-        t3 =
-            Te[0][GETBYTE(s3, 3)] ^
-            Te[1][GETBYTE(s0, 2)]  ^
-            Te[2][GETBYTE(s1, 1)]  ^
-            Te[3][GETBYTE(s2, 0)]  ^
-            rk[7];
-
-        rk += 8;
-        if (--r == 0) {
-            break;
-        }
-
-        s0 =
-            Te[0][GETBYTE(t0, 3)] ^
-            Te[1][GETBYTE(t1, 2)] ^
-            Te[2][GETBYTE(t2, 1)] ^
-            Te[3][GETBYTE(t3, 0)] ^
-            rk[0];
-        s1 =
-            Te[0][GETBYTE(t1, 3)] ^
-            Te[1][GETBYTE(t2, 2)] ^
-            Te[2][GETBYTE(t3, 1)] ^
-            Te[3][GETBYTE(t0, 0)] ^
-            rk[1];
-        s2 =
-            Te[0][GETBYTE(t2, 3)] ^
-            Te[1][GETBYTE(t3, 2)] ^
-            Te[2][GETBYTE(t0, 1)] ^
-            Te[3][GETBYTE(t1, 0)] ^
-            rk[2];
-        s3 =
-            Te[0][GETBYTE(t3, 3)] ^
-            Te[1][GETBYTE(t0, 2)] ^
-            Te[2][GETBYTE(t1, 1)] ^
-            Te[3][GETBYTE(t2, 0)] ^
-            rk[3];
-    }
-
-    /*
-     * apply last round and
-     * map cipher state to byte array block:
-     */
-
-    s0 =
-        (Te[4][GETBYTE(t0, 3)] & 0xff000000) ^
-        (Te[4][GETBYTE(t1, 2)] & 0x00ff0000) ^
-        (Te[4][GETBYTE(t2, 1)] & 0x0000ff00) ^
-        (Te[4][GETBYTE(t3, 0)] & 0x000000ff) ^
-        rk[0];
-    s1 =
-        (Te[4][GETBYTE(t1, 3)] & 0xff000000) ^
-        (Te[4][GETBYTE(t2, 2)] & 0x00ff0000) ^
-        (Te[4][GETBYTE(t3, 1)] & 0x0000ff00) ^
-        (Te[4][GETBYTE(t0, 0)] & 0x000000ff) ^
-        rk[1];
-    s2 =
-        (Te[4][GETBYTE(t2, 3)] & 0xff000000) ^
-        (Te[4][GETBYTE(t3, 2)] & 0x00ff0000) ^
-        (Te[4][GETBYTE(t0, 1)] & 0x0000ff00) ^
-        (Te[4][GETBYTE(t1, 0)] & 0x000000ff) ^
-        rk[2];
-    s3 =
-        (Te[4][GETBYTE(t3, 3)] & 0xff000000) ^
-        (Te[4][GETBYTE(t0, 2)] & 0x00ff0000) ^
-        (Te[4][GETBYTE(t1, 1)] & 0x0000ff00) ^
-        (Te[4][GETBYTE(t2, 0)] & 0x000000ff) ^
-        rk[3];
-
-    /* write out */
-    #ifdef LITTLE_ENDIAN_ORDER
-        s0 = ByteReverseWord32(s0);
-        s1 = ByteReverseWord32(s1);
-        s2 = ByteReverseWord32(s2);
-        s3 = ByteReverseWord32(s3);
-    #endif
-
-    XMEMCPY(outBlock,                  &s0, sizeof(s0));
-    XMEMCPY(outBlock + sizeof(s0),     &s1, sizeof(s1));
-    XMEMCPY(outBlock + 2 * sizeof(s0), &s2, sizeof(s2));
-    XMEMCPY(outBlock + 3 * sizeof(s0), &s3, sizeof(s3));
-}
-
-static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
-{
-    word32 s0, s1, s2, s3;
-    word32 t0, t1, t2, t3;
-    word32 r = aes->rounds >> 1;
-
-    const word32* rk = aes->key;
-    if (r > 7 || r == 0) {
-        WOLFSSL_MSG("AesDecrypt encountered improper key, set it up");
-        return;  /* stop instead of segfaulting, set up your keys! */
-    }
-#ifdef WOLFSSL_AESNI
-    if (haveAESNI && aes->use_aesni) {
-        #ifdef DEBUG_AESNI
-            printf("about to aes decrypt\n");
-            printf("in  = %p\n", inBlock);
-            printf("out = %p\n", outBlock);
-            printf("aes->key = %p\n", aes->key);
-            printf("aes->rounds = %d\n", aes->rounds);
-            printf("sz = %d\n", AES_BLOCK_SIZE);
-        #endif
-
-        /* if input and output same will overwrite input iv */
-        XMEMCPY(aes->tmp, inBlock, AES_BLOCK_SIZE);
-        AES_ECB_decrypt(inBlock, outBlock, AES_BLOCK_SIZE, (byte*)aes->key,
-                        aes->rounds);
-        return;
-    }
-    else {
-        #ifdef DEBUG_AESNI
-            printf("Skipping AES-NI\n");
-        #endif
-    }
-#endif
-
-    /*
-     * map byte array block to cipher state
-     * and add initial round key:
-     */
-    XMEMCPY(&s0, inBlock,                  sizeof(s0));
-    XMEMCPY(&s1, inBlock + sizeof(s0),     sizeof(s1));
-    XMEMCPY(&s2, inBlock + 2 * sizeof(s0), sizeof(s2));
-    XMEMCPY(&s3, inBlock + 3 * sizeof(s0), sizeof(s3));
-
-    #ifdef LITTLE_ENDIAN_ORDER
-        s0 = ByteReverseWord32(s0);
-        s1 = ByteReverseWord32(s1);
-        s2 = ByteReverseWord32(s2);
-        s3 = ByteReverseWord32(s3);
-    #endif
-
-    s0 ^= rk[0];
-    s1 ^= rk[1];
-    s2 ^= rk[2];
-    s3 ^= rk[3];
-
-    /*
-     * Nr - 1 full rounds:
-     */
-
-    for (;;) {
-        t0 =
-            Td[0][GETBYTE(s0, 3)] ^
-            Td[1][GETBYTE(s3, 2)] ^
-            Td[2][GETBYTE(s2, 1)] ^
-            Td[3][GETBYTE(s1, 0)] ^
-            rk[4];
-        t1 =
-            Td[0][GETBYTE(s1, 3)] ^
-            Td[1][GETBYTE(s0, 2)] ^
-            Td[2][GETBYTE(s3, 1)] ^
-            Td[3][GETBYTE(s2, 0)] ^
-            rk[5];
-        t2 =
-            Td[0][GETBYTE(s2, 3)] ^
-            Td[1][GETBYTE(s1, 2)] ^
-            Td[2][GETBYTE(s0, 1)] ^
-            Td[3][GETBYTE(s3, 0)] ^
-            rk[6];
-        t3 =
-            Td[0][GETBYTE(s3, 3)] ^
-            Td[1][GETBYTE(s2, 2)] ^
-            Td[2][GETBYTE(s1, 1)] ^
-            Td[3][GETBYTE(s0, 0)] ^
-            rk[7];
-
-        rk += 8;
-        if (--r == 0) {
-            break;
-        }
-
-        s0 =
-            Td[0][GETBYTE(t0, 3)] ^
-            Td[1][GETBYTE(t3, 2)] ^
-            Td[2][GETBYTE(t2, 1)] ^
-            Td[3][GETBYTE(t1, 0)] ^
-            rk[0];
-        s1 =
-            Td[0][GETBYTE(t1, 3)] ^
-            Td[1][GETBYTE(t0, 2)] ^
-            Td[2][GETBYTE(t3, 1)] ^
-            Td[3][GETBYTE(t2, 0)] ^
-            rk[1];
-        s2 =
-            Td[0][GETBYTE(t2, 3)] ^
-            Td[1][GETBYTE(t1, 2)] ^
-            Td[2][GETBYTE(t0, 1)] ^
-            Td[3][GETBYTE(t3, 0)] ^
-            rk[2];
-        s3 =
-            Td[0][GETBYTE(t3, 3)] ^
-            Td[1][GETBYTE(t2, 2)] ^
-            Td[2][GETBYTE(t1, 1)] ^
-            Td[3][GETBYTE(t0, 0)] ^
-            rk[3];
-    }
-    /*
-     * apply last round and
-     * map cipher state to byte array block:
-     */
-    s0 =
-        (Td[4][GETBYTE(t0, 3)] & 0xff000000) ^
-        (Td[4][GETBYTE(t3, 2)] & 0x00ff0000) ^
-        (Td[4][GETBYTE(t2, 1)] & 0x0000ff00) ^
-        (Td[4][GETBYTE(t1, 0)] & 0x000000ff) ^
-        rk[0];
-    s1 =
-        (Td[4][GETBYTE(t1, 3)] & 0xff000000) ^
-        (Td[4][GETBYTE(t0, 2)] & 0x00ff0000) ^
-        (Td[4][GETBYTE(t3, 1)] & 0x0000ff00) ^
-        (Td[4][GETBYTE(t2, 0)] & 0x000000ff) ^
-        rk[1];
-    s2 =
-        (Td[4][GETBYTE(t2, 3)] & 0xff000000) ^
-        (Td[4][GETBYTE(t1, 2)] & 0x00ff0000) ^
-        (Td[4][GETBYTE(t0, 1)] & 0x0000ff00) ^
-        (Td[4][GETBYTE(t3, 0)] & 0x000000ff) ^
-        rk[2];
-    s3 =
-        (Td[4][GETBYTE(t3, 3)] & 0xff000000) ^
-        (Td[4][GETBYTE(t2, 2)] & 0x00ff0000) ^
-        (Td[4][GETBYTE(t1, 1)] & 0x0000ff00) ^
-        (Td[4][GETBYTE(t0, 0)] & 0x000000ff) ^
-        rk[3];
-
-    /* write out */
-    #ifdef LITTLE_ENDIAN_ORDER
-        s0 = ByteReverseWord32(s0);
-        s1 = ByteReverseWord32(s1);
-        s2 = ByteReverseWord32(s2);
-        s3 = ByteReverseWord32(s3);
-    #endif
-
-    XMEMCPY(outBlock,                  &s0, sizeof(s0));
-    XMEMCPY(outBlock + sizeof(s0),     &s1, sizeof(s1));
-    XMEMCPY(outBlock + 2 * sizeof(s0), &s2, sizeof(s2));
-    XMEMCPY(outBlock + 3 * sizeof(s0), &s3, sizeof(s3));
-}
-
-#endif /* NEED_AES_TABLES */
-
-
-/* wc_AesSetKey */
-#ifdef STM32F2_CRYPTO
-    int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen, const byte* iv,
-                  int dir)
-    {
-        word32 *rk = aes->key;
-
-        if (!((keylen == 16) || (keylen == 24) || (keylen == 32)))
-            return BAD_FUNC_ARG;
-
-        aes->rounds = keylen/4 + 6;
-        XMEMCPY(rk, userKey, keylen);
-        ByteReverseWords(rk, rk, keylen);
-
-        return wc_AesSetIV(aes, iv);
-    }
-
-    int wc_AesSetKeyDirect(Aes* aes, const byte* userKey, word32 keylen,
-                        const byte* iv, int dir)
-    {
-        return wc_AesSetKey(aes, userKey, keylen, iv, dir);
-    }
-
-#elif defined(HAVE_COLDFIRE_SEC)
-    #if defined (HAVE_THREADX)
-        #include "memory_pools.h"
-        extern TX_BYTE_POOL mp_ncached;  /* Non Cached memory pool */
-    #endif
-
-    #define AES_BUFFER_SIZE (AES_BLOCK_SIZE * 64)
-    static unsigned char *AESBuffIn = NULL;
-    static unsigned char *AESBuffOut = NULL;
-    static byte *secReg;
-    static byte *secKey;
-    static volatile SECdescriptorType *secDesc;
-
-    static wolfSSL_Mutex Mutex_AesSEC;
-
-    #define SEC_DESC_AES_CBC_ENCRYPT 0x60300010
-    #define SEC_DESC_AES_CBC_DECRYPT 0x60200010
-
-    extern volatile unsigned char __MBAR[];
-
-    int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen, const byte* iv,
-                  int dir)
-    {
-        if (AESBuffIn == NULL) {
-            #if defined (HAVE_THREADX)
-			    int s1, s2, s3, s4, s5 ;
-                s5 = tx_byte_allocate(&mp_ncached,(void *)&secDesc,
-                                      sizeof(SECdescriptorType), TX_NO_WAIT);
-                s1 = tx_byte_allocate(&mp_ncached, (void *)&AESBuffIn,
-                                      AES_BUFFER_SIZE, TX_NO_WAIT);
-                s2 = tx_byte_allocate(&mp_ncached, (void *)&AESBuffOut,
-                                      AES_BUFFER_SIZE, TX_NO_WAIT);
-                s3 = tx_byte_allocate(&mp_ncached, (void *)&secKey,
-                                      AES_BLOCK_SIZE*2, TX_NO_WAIT);
-                s4 = tx_byte_allocate(&mp_ncached, (void *)&secReg,
-                                      AES_BLOCK_SIZE, TX_NO_WAIT);
-
-                if(s1 || s2 || s3 || s4 || s5)
-                    return BAD_FUNC_ARG;
-            #else
-                #warning "Allocate non-Cache buffers"
-            #endif
-
-            InitMutex(&Mutex_AesSEC);
-        }
-
-        if (!((keylen == 16) || (keylen == 24) || (keylen == 32)))
-            return BAD_FUNC_ARG;
-
-        if (aes == NULL)
-            return BAD_FUNC_ARG;
-
-        aes->rounds = keylen/4 + 6;
-        XMEMCPY(aes->key, userKey, keylen);
-
-        if (iv)
-            XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE);
-
-        return 0;
-    }
-#elif defined(FREESCALE_MMCAU)
-    int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen, const byte* iv,
-                  int dir)
-    {
-        byte *rk = (byte*)aes->key;
-
-        if (!((keylen == 16) || (keylen == 24) || (keylen == 32)))
-            return BAD_FUNC_ARG;
-
-        if (rk == NULL)
-            return BAD_FUNC_ARG;
-
-        aes->rounds = keylen/4 + 6;
-        cau_aes_set_key(userKey, keylen*8, rk);
-
-        return wc_AesSetIV(aes, iv);
-    }
-
-    int wc_AesSetKeyDirect(Aes* aes, const byte* userKey, word32 keylen,
-                        const byte* iv, int dir)
-    {
-        return wc_AesSetKey(aes, userKey, keylen, iv, dir);
-    }
-#else
-    static int wc_AesSetKeyLocal(Aes* aes, const byte* userKey, word32 keylen,
-                const byte* iv, int dir)
-    {
-        word32 temp, *rk = aes->key;
-        unsigned int i = 0;
-
-        #ifdef WOLFSSL_AESNI
-            aes->use_aesni = 0;
-        #endif /* WOLFSSL_AESNI */
-        #ifdef WOLFSSL_AES_COUNTER
-            aes->left = 0;
-        #endif /* WOLFSSL_AES_COUNTER */
-
-        aes->rounds = keylen/4 + 6;
-
-        XMEMCPY(rk, userKey, keylen);
-        #ifdef LITTLE_ENDIAN_ORDER
-            ByteReverseWords(rk, rk, keylen);
-        #endif
-
-        #ifdef WOLFSSL_PIC32MZ_CRYPT
-        {
-            word32 *akey1 = aes->key_ce;
-            word32 *areg = aes->iv_ce ;
-            aes->keylen = keylen ;
-            XMEMCPY(akey1, userKey, keylen);
-            if (iv)
-                XMEMCPY(areg, iv, AES_BLOCK_SIZE);
-            else
-                XMEMSET(areg,  0, AES_BLOCK_SIZE);
-        }
-        #endif
-
-        switch(keylen)
-        {
-        case 16:
-            while (1)
-            {
-                temp  = rk[3];
-                rk[4] = rk[0] ^
-                    (Te[4][GETBYTE(temp, 2)] & 0xff000000) ^
-                    (Te[4][GETBYTE(temp, 1)] & 0x00ff0000) ^
-                    (Te[4][GETBYTE(temp, 0)] & 0x0000ff00) ^
-                    (Te[4][GETBYTE(temp, 3)] & 0x000000ff) ^
-                    rcon[i];
-                rk[5] = rk[1] ^ rk[4];
-                rk[6] = rk[2] ^ rk[5];
-                rk[7] = rk[3] ^ rk[6];
-                if (++i == 10)
-                    break;
-                rk += 4;
-            }
-            break;
-
-        case 24:
-            /* for (;;) here triggers a bug in VC60 SP4 w/ Pro Pack */
-            while (1)
-            {
-                temp = rk[ 5];
-                rk[ 6] = rk[ 0] ^
-                    (Te[4][GETBYTE(temp, 2)] & 0xff000000) ^
-                    (Te[4][GETBYTE(temp, 1)] & 0x00ff0000) ^
-                    (Te[4][GETBYTE(temp, 0)] & 0x0000ff00) ^
-                    (Te[4][GETBYTE(temp, 3)] & 0x000000ff) ^
-                    rcon[i];
-                rk[ 7] = rk[ 1] ^ rk[ 6];
-                rk[ 8] = rk[ 2] ^ rk[ 7];
-                rk[ 9] = rk[ 3] ^ rk[ 8];
-                if (++i == 8)
-                    break;
-                rk[10] = rk[ 4] ^ rk[ 9];
-                rk[11] = rk[ 5] ^ rk[10];
-                rk += 6;
-            }
-            break;
-
-        case 32:
-            while (1)
-            {
-                temp = rk[ 7];
-                rk[ 8] = rk[ 0] ^
-                    (Te[4][GETBYTE(temp, 2)] & 0xff000000) ^
-                    (Te[4][GETBYTE(temp, 1)] & 0x00ff0000) ^
-                    (Te[4][GETBYTE(temp, 0)] & 0x0000ff00) ^
-                    (Te[4][GETBYTE(temp, 3)] & 0x000000ff) ^
-                    rcon[i];
-                rk[ 9] = rk[ 1] ^ rk[ 8];
-                rk[10] = rk[ 2] ^ rk[ 9];
-                rk[11] = rk[ 3] ^ rk[10];
-                if (++i == 7)
-                    break;
-                temp = rk[11];
-                rk[12] = rk[ 4] ^
-                    (Te[4][GETBYTE(temp, 3)] & 0xff000000) ^
-                    (Te[4][GETBYTE(temp, 2)] & 0x00ff0000) ^
-                    (Te[4][GETBYTE(temp, 1)] & 0x0000ff00) ^
-                    (Te[4][GETBYTE(temp, 0)] & 0x000000ff);
-                rk[13] = rk[ 5] ^ rk[12];
-                rk[14] = rk[ 6] ^ rk[13];
-                rk[15] = rk[ 7] ^ rk[14];
-
-                rk += 8;
-            }
-            break;
-
-        default:
-            return BAD_FUNC_ARG;
-        }
-
-        if (dir == AES_DECRYPTION)
-        {
-            unsigned int j;
-            rk = aes->key;
-
-            /* invert the order of the round keys: */
-            for (i = 0, j = 4* aes->rounds; i < j; i += 4, j -= 4) {
-                temp = rk[i    ]; rk[i    ] = rk[j    ]; rk[j    ] = temp;
-                temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;
-                temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;
-                temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp;
-            }
-            /* apply the inverse MixColumn transform to all round keys but the
-               first and the last: */
-            for (i = 1; i < aes->rounds; i++) {
-                rk += 4;
-                rk[0] =
-                    Td[0][Te[4][GETBYTE(rk[0], 3)] & 0xff] ^
-                    Td[1][Te[4][GETBYTE(rk[0], 2)] & 0xff] ^
-                    Td[2][Te[4][GETBYTE(rk[0], 1)] & 0xff] ^
-                    Td[3][Te[4][GETBYTE(rk[0], 0)] & 0xff];
-                rk[1] =
-                    Td[0][Te[4][GETBYTE(rk[1], 3)] & 0xff] ^
-                    Td[1][Te[4][GETBYTE(rk[1], 2)] & 0xff] ^
-                    Td[2][Te[4][GETBYTE(rk[1], 1)] & 0xff] ^
-                    Td[3][Te[4][GETBYTE(rk[1], 0)] & 0xff];
-                rk[2] =
-                    Td[0][Te[4][GETBYTE(rk[2], 3)] & 0xff] ^
-                    Td[1][Te[4][GETBYTE(rk[2], 2)] & 0xff] ^
-                    Td[2][Te[4][GETBYTE(rk[2], 1)] & 0xff] ^
-                    Td[3][Te[4][GETBYTE(rk[2], 0)] & 0xff];
-                rk[3] =
-                    Td[0][Te[4][GETBYTE(rk[3], 3)] & 0xff] ^
-                    Td[1][Te[4][GETBYTE(rk[3], 2)] & 0xff] ^
-                    Td[2][Te[4][GETBYTE(rk[3], 1)] & 0xff] ^
-                    Td[3][Te[4][GETBYTE(rk[3], 0)] & 0xff];
-            }
-        }
-
-        return wc_AesSetIV(aes, iv);
-    }
-
-    int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen, const byte* iv,
-                  int dir)
-    {
-
-        if (!((keylen == 16) || (keylen == 24) || (keylen == 32)))
-            return BAD_FUNC_ARG;
-
-        #ifdef HAVE_CAVIUM
-        if (aes->magic == WOLFSSL_AES_CAVIUM_MAGIC)
-            return wc_AesCaviumSetKey(aes, userKey, keylen, iv);
-        #endif
-
-        #ifdef WOLFSSL_AESNI
-        if (checkAESNI == 0) {
-            haveAESNI  = Check_CPU_support_AES();
-            checkAESNI = 1;
-        }
-        if (haveAESNI) {
-            aes->use_aesni = 1;
-            if (iv)
-                XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE);
-            if (dir == AES_ENCRYPTION)
-                return AES_set_encrypt_key(userKey, keylen * 8, aes);
-            else
-                return AES_set_decrypt_key(userKey, keylen * 8, aes);
-        }
-        #endif /* WOLFSSL_AESNI */
-
-        return wc_AesSetKeyLocal(aes, userKey, keylen, iv, dir);
-    }
-
-    #if defined(WOLFSSL_AES_DIRECT) || defined(WOLFSSL_AES_COUNTER)
-
-    /* AES-CTR and AES-DIRECT need to use this for key setup, no aesni yet */
-    int wc_AesSetKeyDirect(Aes* aes, const byte* userKey, word32 keylen,
-                        const byte* iv, int dir)
-    {
-        return wc_AesSetKeyLocal(aes, userKey, keylen, iv, dir);
-    }
-
-    #endif /* WOLFSSL_AES_DIRECT || WOLFSSL_AES_COUNTER */
-#endif /* STM32F2_CRYPTO, wc_AesSetKey block */
-
-
-/* wc_AesSetIV is shared between software and hardware */
-int wc_AesSetIV(Aes* aes, const byte* iv)
-{
-    if (aes == NULL)
-        return BAD_FUNC_ARG;
-
-    if (iv)
-        XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE);
-    else
-        XMEMSET(aes->reg,  0, AES_BLOCK_SIZE);
-
-    return 0;
-}
-
-
-int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
-                                  const byte* key, word32 keySz, const byte* iv)
-{
-    int  ret = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    Aes* aes = NULL;
-#else
-    Aes  aes[1];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    aes = (Aes*)XMALLOC(sizeof(Aes), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (aes == NULL)
-        return MEMORY_E;
-#endif
-
-    ret = wc_AesSetKey(aes, key, keySz, iv, AES_DECRYPTION);
-    if (ret == 0)
-        ret = wc_AesCbcDecrypt(aes, out, in, inSz); 
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(aes, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-/* AES-DIRECT */
-#if defined(WOLFSSL_AES_DIRECT)
-    #if defined(FREESCALE_MMCAU)
-
-        /* Allow direct access to one block encrypt */
-        void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
-        {
-            byte* key;
-            key = (byte*)aes->key;
-
-            return cau_aes_encrypt(in, key, aes->rounds, out);
-        }
-
-        /* Allow direct access to one block decrypt */
-        void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in)
-        {
-            byte* key;
-            key = (byte*)aes->key;
-
-            return cau_aes_decrypt(in, key, aes->rounds, out);
-        }
-
-    #elif defined(STM32F2_CRYPTO)
-        #error "STM32F2 crypto doesn't yet support AES direct"
-
-    #elif defined(HAVE_COLDFIRE_SEC)
-        #error "Coldfire SEC doesn't yet support AES direct"
-
-    #elif defined(WOLFSSL_PIC32MZ_CRYPT)
-        #error "PIC32MZ doesn't yet support AES direct"
-
-    #else
-        /* Allow direct access to one block encrypt */
-        void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
-        {
-            wc_AesEncrypt(aes, in, out);
-        }
-
-        /* Allow direct access to one block decrypt */
-        void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in)
-        {
-            wc_AesDecrypt(aes, in, out);
-        }
-
-    #endif /* FREESCALE_MMCAU, AES direct block */
-#endif /* WOLFSSL_AES_DIRECT */
-
-
-/* AES-CBC */
-#ifdef STM32F2_CRYPTO
-    int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-    {
-        word32 *enc_key, *iv;
-        CRYP_InitTypeDef AES_CRYP_InitStructure;
-        CRYP_KeyInitTypeDef AES_CRYP_KeyInitStructure;
-        CRYP_IVInitTypeDef AES_CRYP_IVInitStructure;
-
-        enc_key = aes->key;
-        iv = aes->reg;
-
-        /* crypto structure initialization */
-        CRYP_KeyStructInit(&AES_CRYP_KeyInitStructure);
-        CRYP_StructInit(&AES_CRYP_InitStructure);
-        CRYP_IVStructInit(&AES_CRYP_IVInitStructure);
-
-        /* reset registers to their default values */
-        CRYP_DeInit();
-
-        /* load key into correct registers */
-        switch(aes->rounds)
-        {
-            case 10: /* 128-bit key */
-                AES_CRYP_InitStructure.CRYP_KeySize = CRYP_KeySize_128b;
-                AES_CRYP_KeyInitStructure.CRYP_Key2Left  = enc_key[0];
-                AES_CRYP_KeyInitStructure.CRYP_Key2Right = enc_key[1];
-                AES_CRYP_KeyInitStructure.CRYP_Key3Left  = enc_key[2];
-                AES_CRYP_KeyInitStructure.CRYP_Key3Right = enc_key[3];
-                break;
-
-            case 12: /* 192-bit key */
-                AES_CRYP_InitStructure.CRYP_KeySize = CRYP_KeySize_192b;
-                AES_CRYP_KeyInitStructure.CRYP_Key1Left  = enc_key[0];
-                AES_CRYP_KeyInitStructure.CRYP_Key1Right = enc_key[1];
-                AES_CRYP_KeyInitStructure.CRYP_Key2Left  = enc_key[2];
-                AES_CRYP_KeyInitStructure.CRYP_Key2Right = enc_key[3];
-                AES_CRYP_KeyInitStructure.CRYP_Key3Left  = enc_key[4];
-                AES_CRYP_KeyInitStructure.CRYP_Key3Right = enc_key[5];
-                break;
-
-            case 14: /* 256-bit key */
-                AES_CRYP_InitStructure.CRYP_KeySize = CRYP_KeySize_256b;
-                AES_CRYP_KeyInitStructure.CRYP_Key0Left  = enc_key[0];
-                AES_CRYP_KeyInitStructure.CRYP_Key0Right = enc_key[1];
-                AES_CRYP_KeyInitStructure.CRYP_Key1Left  = enc_key[2];
-                AES_CRYP_KeyInitStructure.CRYP_Key1Right = enc_key[3];
-                AES_CRYP_KeyInitStructure.CRYP_Key2Left  = enc_key[4];
-                AES_CRYP_KeyInitStructure.CRYP_Key2Right = enc_key[5];
-                AES_CRYP_KeyInitStructure.CRYP_Key3Left  = enc_key[6];
-                AES_CRYP_KeyInitStructure.CRYP_Key3Right = enc_key[7];
-                break;
-
-            default:
-                break;
-        }
-        CRYP_KeyInit(&AES_CRYP_KeyInitStructure);
-
-        /* set iv */
-        ByteReverseWords(iv, iv, AES_BLOCK_SIZE);
-        AES_CRYP_IVInitStructure.CRYP_IV0Left  = iv[0];
-        AES_CRYP_IVInitStructure.CRYP_IV0Right = iv[1];
-        AES_CRYP_IVInitStructure.CRYP_IV1Left  = iv[2];
-        AES_CRYP_IVInitStructure.CRYP_IV1Right = iv[3];
-        CRYP_IVInit(&AES_CRYP_IVInitStructure);
-
-        /* set direction, mode, and datatype */
-        AES_CRYP_InitStructure.CRYP_AlgoDir  = CRYP_AlgoDir_Encrypt;
-        AES_CRYP_InitStructure.CRYP_AlgoMode = CRYP_AlgoMode_AES_CBC;
-        AES_CRYP_InitStructure.CRYP_DataType = CRYP_DataType_8b;
-        CRYP_Init(&AES_CRYP_InitStructure);
-
-        /* enable crypto processor */
-        CRYP_Cmd(ENABLE);
-
-        while (sz > 0)
-        {
-            /* flush IN/OUT FIFOs */
-            CRYP_FIFOFlush();
-
-            CRYP_DataIn(*(uint32_t*)&in[0]);
-            CRYP_DataIn(*(uint32_t*)&in[4]);
-            CRYP_DataIn(*(uint32_t*)&in[8]);
-            CRYP_DataIn(*(uint32_t*)&in[12]);
-
-            /* wait until the complete message has been processed */
-            while(CRYP_GetFlagStatus(CRYP_FLAG_BUSY) != RESET) {}
-
-            *(uint32_t*)&out[0]  = CRYP_DataOut();
-            *(uint32_t*)&out[4]  = CRYP_DataOut();
-            *(uint32_t*)&out[8]  = CRYP_DataOut();
-            *(uint32_t*)&out[12] = CRYP_DataOut();
-
-            /* store iv for next call */
-            XMEMCPY(aes->reg, out + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
-
-            sz  -= 16;
-            in  += 16;
-            out += 16;
-        }
-
-        /* disable crypto processor */
-        CRYP_Cmd(DISABLE);
-
-        return 0;
-    }
-
-    int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-    {
-        word32 *dec_key, *iv;
-        CRYP_InitTypeDef AES_CRYP_InitStructure;
-        CRYP_KeyInitTypeDef AES_CRYP_KeyInitStructure;
-        CRYP_IVInitTypeDef AES_CRYP_IVInitStructure;
-
-        dec_key = aes->key;
-        iv = aes->reg;
-
-        /* crypto structure initialization */
-        CRYP_KeyStructInit(&AES_CRYP_KeyInitStructure);
-        CRYP_StructInit(&AES_CRYP_InitStructure);
-        CRYP_IVStructInit(&AES_CRYP_IVInitStructure);
-
-        /* if input and output same will overwrite input iv */
-        XMEMCPY(aes->tmp, in + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
-
-        /* reset registers to their default values */
-        CRYP_DeInit();
-
-        /* load key into correct registers */
-        switch(aes->rounds)
-        {
-            case 10: /* 128-bit key */
-                AES_CRYP_InitStructure.CRYP_KeySize = CRYP_KeySize_128b;
-                AES_CRYP_KeyInitStructure.CRYP_Key2Left  = dec_key[0];
-                AES_CRYP_KeyInitStructure.CRYP_Key2Right = dec_key[1];
-                AES_CRYP_KeyInitStructure.CRYP_Key3Left  = dec_key[2];
-                AES_CRYP_KeyInitStructure.CRYP_Key3Right = dec_key[3];
-                break;
-
-            case 12: /* 192-bit key */
-                AES_CRYP_InitStructure.CRYP_KeySize = CRYP_KeySize_192b;
-                AES_CRYP_KeyInitStructure.CRYP_Key1Left  = dec_key[0];
-                AES_CRYP_KeyInitStructure.CRYP_Key1Right = dec_key[1];
-                AES_CRYP_KeyInitStructure.CRYP_Key2Left  = dec_key[2];
-                AES_CRYP_KeyInitStructure.CRYP_Key2Right = dec_key[3];
-                AES_CRYP_KeyInitStructure.CRYP_Key3Left  = dec_key[4];
-                AES_CRYP_KeyInitStructure.CRYP_Key3Right = dec_key[5];
-                break;
-
-            case 14: /* 256-bit key */
-                AES_CRYP_InitStructure.CRYP_KeySize = CRYP_KeySize_256b;
-                AES_CRYP_KeyInitStructure.CRYP_Key0Left  = dec_key[0];
-                AES_CRYP_KeyInitStructure.CRYP_Key0Right = dec_key[1];
-                AES_CRYP_KeyInitStructure.CRYP_Key1Left  = dec_key[2];
-                AES_CRYP_KeyInitStructure.CRYP_Key1Right = dec_key[3];
-                AES_CRYP_KeyInitStructure.CRYP_Key2Left  = dec_key[4];
-                AES_CRYP_KeyInitStructure.CRYP_Key2Right = dec_key[5];
-                AES_CRYP_KeyInitStructure.CRYP_Key3Left  = dec_key[6];
-                AES_CRYP_KeyInitStructure.CRYP_Key3Right = dec_key[7];
-                break;
-
-            default:
-                break;
-        }
-
-        /* set direction, mode, and datatype for key preparation */
-        AES_CRYP_InitStructure.CRYP_AlgoDir  = CRYP_AlgoDir_Decrypt;
-        AES_CRYP_InitStructure.CRYP_AlgoMode = CRYP_AlgoMode_AES_Key;
-        AES_CRYP_InitStructure.CRYP_DataType = CRYP_DataType_32b;
-        CRYP_Init(&AES_CRYP_InitStructure);
-        CRYP_KeyInit(&AES_CRYP_KeyInitStructure);
-
-        /* enable crypto processor */
-        CRYP_Cmd(ENABLE);
-
-        /* wait until key has been prepared */
-        while(CRYP_GetFlagStatus(CRYP_FLAG_BUSY) != RESET) {}
-
-        /* set direction, mode, and datatype for decryption */
-        AES_CRYP_InitStructure.CRYP_AlgoDir  = CRYP_AlgoDir_Decrypt;
-        AES_CRYP_InitStructure.CRYP_AlgoMode = CRYP_AlgoMode_AES_CBC;
-        AES_CRYP_InitStructure.CRYP_DataType = CRYP_DataType_8b;
-        CRYP_Init(&AES_CRYP_InitStructure);
-
-        /* set iv */
-        ByteReverseWords(iv, iv, AES_BLOCK_SIZE);
-
-        AES_CRYP_IVInitStructure.CRYP_IV0Left  = iv[0];
-        AES_CRYP_IVInitStructure.CRYP_IV0Right = iv[1];
-        AES_CRYP_IVInitStructure.CRYP_IV1Left  = iv[2];
-        AES_CRYP_IVInitStructure.CRYP_IV1Right = iv[3];
-        CRYP_IVInit(&AES_CRYP_IVInitStructure);
-
-        /* enable crypto processor */
-        CRYP_Cmd(ENABLE);
-
-        while (sz > 0)
-        {
-            /* flush IN/OUT FIFOs */
-            CRYP_FIFOFlush();
-
-            CRYP_DataIn(*(uint32_t*)&in[0]);
-            CRYP_DataIn(*(uint32_t*)&in[4]);
-            CRYP_DataIn(*(uint32_t*)&in[8]);
-            CRYP_DataIn(*(uint32_t*)&in[12]);
-
-            /* wait until the complete message has been processed */
-            while(CRYP_GetFlagStatus(CRYP_FLAG_BUSY) != RESET) {}
-
-            *(uint32_t*)&out[0]  = CRYP_DataOut();
-            *(uint32_t*)&out[4]  = CRYP_DataOut();
-            *(uint32_t*)&out[8]  = CRYP_DataOut();
-            *(uint32_t*)&out[12] = CRYP_DataOut();
-
-            /* store iv for next call */
-            XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE);
-
-            sz -= 16;
-            in += 16;
-            out += 16;
-        }
-
-        /* disable crypto processor */
-        CRYP_Cmd(DISABLE);
-
-        return 0;
-    }
-
-#elif defined(HAVE_COLDFIRE_SEC)
-    static int wc_AesCbcCrypt(Aes* aes, byte* po, const byte* pi, word32 sz,
-                           word32 descHeader)
-    {
-        #ifdef DEBUG_WOLFSSL
-            int i; int stat1, stat2; int ret;
-	    #endif
-
-        int size;
-        volatile int v;
-
-        if ((pi == NULL) || (po == NULL))
-            return BAD_FUNC_ARG;    /*wrong pointer*/
-
-        LockMutex(&Mutex_AesSEC);
-
-        /* Set descriptor for SEC */
-        secDesc->length1 = 0x0;
-        secDesc->pointer1 = NULL;
-
-        secDesc->length2 = AES_BLOCK_SIZE;
-        secDesc->pointer2 = (byte *)secReg; /* Initial Vector */
-
-        switch(aes->rounds) {
-            case 10: secDesc->length3 = 16 ; break ;
-            case 12: secDesc->length3 = 24 ; break ;
-            case 14: secDesc->length3 = 32 ; break ;
-        }
-        XMEMCPY(secKey, aes->key, secDesc->length3);
-
-        secDesc->pointer3 = (byte *)secKey;
-        secDesc->pointer4 = AESBuffIn;
-        secDesc->pointer5 = AESBuffOut;
-        secDesc->length6 = 0x0;
-        secDesc->pointer6 = NULL;
-        secDesc->length7 = 0x0;
-        secDesc->pointer7 = NULL;
-        secDesc->nextDescriptorPtr = NULL;
-
-        while (sz) {
-            secDesc->header = descHeader;
-            XMEMCPY(secReg, aes->reg, AES_BLOCK_SIZE);
-            if ((sz % AES_BUFFER_SIZE) == sz) {
-                size = sz;
-                sz = 0;
-            } else {
-                size = AES_BUFFER_SIZE;
-                sz -= AES_BUFFER_SIZE;
-            }
-            secDesc->length4 = size;
-            secDesc->length5 = size;
-
-            XMEMCPY(AESBuffIn, pi, size);
-            if(descHeader == SEC_DESC_AES_CBC_DECRYPT) {
-                XMEMCPY((void*)aes->tmp, (void*)&(pi[size-AES_BLOCK_SIZE]),
-                        AES_BLOCK_SIZE);
-            }
-
-            /* Point SEC to the location of the descriptor */
-            MCF_SEC_FR0 = (uint32)secDesc;
-            /* Initialize SEC and wait for encryption to complete */
-            MCF_SEC_CCCR0 = 0x0000001a;
-            /* poll SISR to determine when channel is complete */
-            v=0;
-
-            while ((secDesc->header>> 24) != 0xff) v++;
-
-            #ifdef DEBUG_WOLFSSL
-                ret = MCF_SEC_SISRH;
-                stat1 = MCF_SEC_AESSR;
-                stat2 = MCF_SEC_AESISR;
-                if (ret & 0xe0000000) {
-                    db_printf("Aes_Cbc(i=%d):ISRH=%08x, AESSR=%08x, "
-                              "AESISR=%08x\n", i, ret, stat1, stat2);
-                }
-            #endif
-
-            XMEMCPY(po, AESBuffOut, size);
-
-            if (descHeader == SEC_DESC_AES_CBC_ENCRYPT) {
-                XMEMCPY((void*)aes->reg, (void*)&(po[size-AES_BLOCK_SIZE]),
-                        AES_BLOCK_SIZE);
-            } else {
-                XMEMCPY((void*)aes->reg, (void*)aes->tmp, AES_BLOCK_SIZE);
-            }
-
-            pi += size;
-            po += size;
-        }
-
-        UnLockMutex(&Mutex_AesSEC);
-        return 0;
-    }
-
-    int wc_AesCbcEncrypt(Aes* aes, byte* po, const byte* pi, word32 sz)
-    {
-        return (wc_AesCbcCrypt(aes, po, pi, sz, SEC_DESC_AES_CBC_ENCRYPT));
-    }
-
-    int wc_AesCbcDecrypt(Aes* aes, byte* po, const byte* pi, word32 sz)
-    {
-        return (wc_AesCbcCrypt(aes, po, pi, sz, SEC_DESC_AES_CBC_DECRYPT));
-    }
-
-#elif defined(FREESCALE_MMCAU)
-    int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-    {
-        int i;
-        int offset = 0;
-        int len = sz;
-
-        byte *iv, *enc_key;
-        byte temp_block[AES_BLOCK_SIZE];
-
-        iv      = (byte*)aes->reg;
-        enc_key = (byte*)aes->key;
-
-        if ((wolfssl_word)out % WOLFSSL_MMCAU_ALIGNMENT) {
-            WOLFSSL_MSG("Bad cau_aes_encrypt alignment");
-            return BAD_ALIGN_E;
-        }
-
-        while (len > 0)
-        {
-            XMEMCPY(temp_block, in + offset, AES_BLOCK_SIZE);
-
-            /* XOR block with IV for CBC */
-            for (i = 0; i < AES_BLOCK_SIZE; i++)
-                temp_block[i] ^= iv[i];
-
-            cau_aes_encrypt(temp_block, enc_key, aes->rounds, out + offset);
-
-            len    -= AES_BLOCK_SIZE;
-            offset += AES_BLOCK_SIZE;
-
-            /* store IV for next block */
-            XMEMCPY(iv, out + offset - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
-        }
-
-        return 0;
-    }
-
-    int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-    {
-        int i;
-        int offset = 0;
-        int len = sz;
-
-        byte* iv, *dec_key;
-        byte temp_block[AES_BLOCK_SIZE];
-
-        iv      = (byte*)aes->reg;
-        dec_key = (byte*)aes->key;
-
-        if ((wolfssl_word)out % WOLFSSL_MMCAU_ALIGNMENT) {
-            WOLFSSL_MSG("Bad cau_aes_decrypt alignment");
-            return BAD_ALIGN_E;
-        }
-
-        while (len > 0)
-        {
-            XMEMCPY(temp_block, in + offset, AES_BLOCK_SIZE);
-
-            cau_aes_decrypt(in + offset, dec_key, aes->rounds, out + offset);
-
-            /* XOR block with IV for CBC */
-            for (i = 0; i < AES_BLOCK_SIZE; i++)
-                (out + offset)[i] ^= iv[i];
-
-            /* store IV for next block */
-            XMEMCPY(iv, temp_block, AES_BLOCK_SIZE);
-
-            len    -= AES_BLOCK_SIZE;
-            offset += AES_BLOCK_SIZE;
-        }
-
-        return 0;
-    }
-
-#elif defined(WOLFSSL_PIC32MZ_CRYPT)
-    /* core hardware crypt engine driver */
-    static void wc_AesCrypt(Aes *aes, byte* out, const byte* in, word32 sz,
-                                            int dir, int algo, int cryptoalgo)
-    {
-        securityAssociation *sa_p ;
-        bufferDescriptor *bd_p ;
-
-        volatile securityAssociation sa __attribute__((aligned (8)));
-        volatile bufferDescriptor bd __attribute__((aligned (8)));
-        volatile int k ;
-
-        /* get uncached address */
-        sa_p = KVA0_TO_KVA1(&sa) ;
-        bd_p = KVA0_TO_KVA1(&bd) ;
-
-        /* Sync cache and physical memory */
-        if(PIC32MZ_IF_RAM(in)) {
-            XMEMCPY((void *)KVA0_TO_KVA1(in), (void *)in, sz);
-        }
-        XMEMSET((void *)KVA0_TO_KVA1(out), 0, sz);
-        /* Set up the Security Association */
-        XMEMSET((byte *)KVA0_TO_KVA1(&sa), 0, sizeof(sa));
-        sa_p->SA_CTRL.ALGO = algo ; /* AES */
-        sa_p->SA_CTRL.LNC = 1;
-        sa_p->SA_CTRL.LOADIV = 1;
-        sa_p->SA_CTRL.FB = 1;
-        sa_p->SA_CTRL.ENCTYPE = dir ; /* Encryption/Decryption */
-        sa_p->SA_CTRL.CRYPTOALGO = cryptoalgo;
-
-        if(cryptoalgo == PIC32_CRYPTOALGO_AES_GCM){
-            switch(aes->keylen) {
-            case 32:
-                sa_p->SA_CTRL.KEYSIZE = PIC32_AES_KEYSIZE_256 ;
-                break ;
-            case 24:
-                sa_p->SA_CTRL.KEYSIZE = PIC32_AES_KEYSIZE_192 ;
-                break ;
-            case 16:
-                sa_p->SA_CTRL.KEYSIZE = PIC32_AES_KEYSIZE_128 ;
-                break ;
-            }
-        } else
-            sa_p->SA_CTRL.KEYSIZE = PIC32_AES_KEYSIZE_128 ;
-
-        ByteReverseWords(
-        (word32 *)KVA0_TO_KVA1(sa.SA_ENCKEY + 8 - aes->keylen/sizeof(word32)),
-                         (word32 *)aes->key_ce, aes->keylen);
-        ByteReverseWords(
-        (word32*)KVA0_TO_KVA1(sa.SA_ENCIV), (word32 *)aes->iv_ce, 16);
-
-        XMEMSET((byte *)KVA0_TO_KVA1(&bd), 0, sizeof(bd));
-        /* Set up the Buffer Descriptor */
-        bd_p->BD_CTRL.BUFLEN = sz;
-        if(cryptoalgo == PIC32_CRYPTOALGO_AES_GCM) {
-            if(sz % 0x10)
-                bd_p->BD_CTRL.BUFLEN = (sz/0x10 + 1) * 0x10 ;
-        }
-        bd_p->BD_CTRL.LIFM = 1;
-        bd_p->BD_CTRL.SA_FETCH_EN = 1;
-        bd_p->BD_CTRL.LAST_BD = 1;
-        bd_p->BD_CTRL.DESC_EN = 1;
-
-        bd_p->SA_ADDR = (unsigned int)KVA_TO_PA(&sa) ;
-        bd_p->SRCADDR = (unsigned int)KVA_TO_PA(in) ;
-        bd_p->DSTADDR = (unsigned int)KVA_TO_PA(out);
-        bd_p->MSGLEN = sz ;
-
-        CECON = 1 << 6;
-        while (CECON);
-
-        /* Run the engine */
-        CEBDPADDR = (unsigned int)KVA_TO_PA(&bd) ;
-        CEINTEN = 0x07;
-        CECON = 0x27;
-
-        WAIT_ENGINE ;
-
-        if((cryptoalgo == PIC32_CRYPTOALGO_CBC) ||
-           (cryptoalgo == PIC32_CRYPTOALGO_TCBC)||
-           (cryptoalgo == PIC32_CRYPTOALGO_RCBC)) {
-            /* set iv for the next call */
-            if(dir == PIC32_ENCRYPTION) {
-                XMEMCPY((void *)aes->iv_ce,
-                        (void*)KVA0_TO_KVA1(out + sz - AES_BLOCK_SIZE),
-                        AES_BLOCK_SIZE) ;
-            } else {
-                ByteReverseWords((word32*)aes->iv_ce,
-                        (word32 *)KVA0_TO_KVA1(in + sz - AES_BLOCK_SIZE),
-                        AES_BLOCK_SIZE);
-            }
-        }
-        XMEMCPY((byte *)out, (byte *)KVA0_TO_KVA1(out), sz) ;
-        ByteReverseWords((word32*)out, (word32 *)out, sz);
-    }
-
-    int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-    {
-        wc_AesCrypt(aes, out, in, sz, PIC32_ENCRYPTION, PIC32_ALGO_AES,
-                                                      PIC32_CRYPTOALGO_RCBC );
-        return 0 ;
-    }
-
-    int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-    {
-        wc_AesCrypt(aes, out, in, sz, PIC32_DECRYPTION, PIC32_ALGO_AES,
-                                                      PIC32_CRYPTOALGO_RCBC);
-        return 0 ;
-    }
-
-#else
-    int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-    {
-        word32 blocks = sz / AES_BLOCK_SIZE;
-
-    #ifdef HAVE_CAVIUM
-        if (aes->magic == WOLFSSL_AES_CAVIUM_MAGIC)
-            return wc_AesCaviumCbcEncrypt(aes, out, in, sz);
-    #endif
-
-    #ifdef WOLFSSL_AESNI
-        if (haveAESNI) {
-            #ifdef DEBUG_AESNI
-                printf("about to aes cbc encrypt\n");
-                printf("in  = %p\n", in);
-                printf("out = %p\n", out);
-                printf("aes->key = %p\n", aes->key);
-                printf("aes->reg = %p\n", aes->reg);
-                printf("aes->rounds = %d\n", aes->rounds);
-                printf("sz = %d\n", sz);
-            #endif
-
-            /* check alignment, decrypt doesn't need alignment */
-            if ((wolfssl_word)in % 16) {
-            #ifndef NO_WOLFSSL_ALLOC_ALIGN
-                byte* tmp = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                WOLFSSL_MSG("AES-CBC encrypt with bad alignment");
-                if (tmp == NULL) return MEMORY_E;
-
-                XMEMCPY(tmp, in, sz);
-                AES_CBC_encrypt(tmp, tmp, (byte*)aes->reg, sz, (byte*)aes->key,
-                            aes->rounds);
-                /* store iv for next call */
-                XMEMCPY(aes->reg, tmp + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
-
-                XMEMCPY(out, tmp, sz);
-                XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                return 0;
-            #else
-                return BAD_ALIGN_E;
-            #endif
-            }
-
-            AES_CBC_encrypt(in, out, (byte*)aes->reg, sz, (byte*)aes->key,
-                            aes->rounds);
-            /* store iv for next call */
-            XMEMCPY(aes->reg, out + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
-
-            return 0;
-        }
-    #endif
-
-        while (blocks--) {
-            xorbuf((byte*)aes->reg, in, AES_BLOCK_SIZE);
-            wc_AesEncrypt(aes, (byte*)aes->reg, (byte*)aes->reg);
-            XMEMCPY(out, aes->reg, AES_BLOCK_SIZE);
-
-            out += AES_BLOCK_SIZE;
-            in  += AES_BLOCK_SIZE;
-        }
-
-        return 0;
-    }
-
-    int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-    {
-        word32 blocks = sz / AES_BLOCK_SIZE;
-
-    #ifdef HAVE_CAVIUM
-        if (aes->magic == WOLFSSL_AES_CAVIUM_MAGIC)
-            return wc_AesCaviumCbcDecrypt(aes, out, in, sz);
-    #endif
-
-    #ifdef WOLFSSL_AESNI
-        if (haveAESNI) {
-            #ifdef DEBUG_AESNI
-                printf("about to aes cbc decrypt\n");
-                printf("in  = %p\n", in);
-                printf("out = %p\n", out);
-                printf("aes->key = %p\n", aes->key);
-                printf("aes->reg = %p\n", aes->reg);
-                printf("aes->rounds = %d\n", aes->rounds);
-                printf("sz = %d\n", sz);
-            #endif
-
-            /* if input and output same will overwrite input iv */
-            XMEMCPY(aes->tmp, in + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
-            AES_CBC_decrypt(in, out, (byte*)aes->reg, sz, (byte*)aes->key,
-                            aes->rounds);
-            /* store iv for next call */
-            XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE);
-            return 0;
-        }
-    #endif
-
-        while (blocks--) {
-            XMEMCPY(aes->tmp, in, AES_BLOCK_SIZE);
-            wc_AesDecrypt(aes, (byte*)aes->tmp, out);
-            xorbuf(out, (byte*)aes->reg, AES_BLOCK_SIZE);
-            XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE);
-
-            out += AES_BLOCK_SIZE;
-            in  += AES_BLOCK_SIZE;
-        }
-
-        return 0;
-    }
-
-#endif /* STM32F2_CRYPTO, AES-CBC block */
-
-/* AES-CTR */
-#ifdef WOLFSSL_AES_COUNTER
-
-    #ifdef STM32F2_CRYPTO
-        void wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-        {
-            word32 *enc_key, *iv;
-            CRYP_InitTypeDef AES_CRYP_InitStructure;
-            CRYP_KeyInitTypeDef AES_CRYP_KeyInitStructure;
-            CRYP_IVInitTypeDef AES_CRYP_IVInitStructure;
-
-            enc_key = aes->key;
-            iv = aes->reg;
-
-            /* crypto structure initialization */
-            CRYP_KeyStructInit(&AES_CRYP_KeyInitStructure);
-            CRYP_StructInit(&AES_CRYP_InitStructure);
-            CRYP_IVStructInit(&AES_CRYP_IVInitStructure);
-
-            /* reset registers to their default values */
-            CRYP_DeInit();
-
-            /* load key into correct registers */
-            switch(aes->rounds)
-            {
-                case 10: /* 128-bit key */
-                    AES_CRYP_InitStructure.CRYP_KeySize = CRYP_KeySize_128b;
-                    AES_CRYP_KeyInitStructure.CRYP_Key2Left  = enc_key[0];
-                    AES_CRYP_KeyInitStructure.CRYP_Key2Right = enc_key[1];
-                    AES_CRYP_KeyInitStructure.CRYP_Key3Left  = enc_key[2];
-                    AES_CRYP_KeyInitStructure.CRYP_Key3Right = enc_key[3];
-                    break;
-
-                case 12: /* 192-bit key */
-                    AES_CRYP_InitStructure.CRYP_KeySize = CRYP_KeySize_192b;
-                    AES_CRYP_KeyInitStructure.CRYP_Key1Left  = enc_key[0];
-                    AES_CRYP_KeyInitStructure.CRYP_Key1Right = enc_key[1];
-                    AES_CRYP_KeyInitStructure.CRYP_Key2Left  = enc_key[2];
-                    AES_CRYP_KeyInitStructure.CRYP_Key2Right = enc_key[3];
-                    AES_CRYP_KeyInitStructure.CRYP_Key3Left  = enc_key[4];
-                    AES_CRYP_KeyInitStructure.CRYP_Key3Right = enc_key[5];
-                    break;
-
-                case 14: /* 256-bit key */
-                    AES_CRYP_InitStructure.CRYP_KeySize = CRYP_KeySize_256b;
-                    AES_CRYP_KeyInitStructure.CRYP_Key0Left  = enc_key[0];
-                    AES_CRYP_KeyInitStructure.CRYP_Key0Right = enc_key[1];
-                    AES_CRYP_KeyInitStructure.CRYP_Key1Left  = enc_key[2];
-                    AES_CRYP_KeyInitStructure.CRYP_Key1Right = enc_key[3];
-                    AES_CRYP_KeyInitStructure.CRYP_Key2Left  = enc_key[4];
-                    AES_CRYP_KeyInitStructure.CRYP_Key2Right = enc_key[5];
-                    AES_CRYP_KeyInitStructure.CRYP_Key3Left  = enc_key[6];
-                    AES_CRYP_KeyInitStructure.CRYP_Key3Right = enc_key[7];
-                    break;
-
-                default:
-                    break;
-            }
-            CRYP_KeyInit(&AES_CRYP_KeyInitStructure);
-
-            /* set iv */
-            ByteReverseWords(iv, iv, AES_BLOCK_SIZE);
-            AES_CRYP_IVInitStructure.CRYP_IV0Left  = iv[0];
-            AES_CRYP_IVInitStructure.CRYP_IV0Right = iv[1];
-            AES_CRYP_IVInitStructure.CRYP_IV1Left  = iv[2];
-            AES_CRYP_IVInitStructure.CRYP_IV1Right = iv[3];
-            CRYP_IVInit(&AES_CRYP_IVInitStructure);
-
-            /* set direction, mode, and datatype */
-            AES_CRYP_InitStructure.CRYP_AlgoDir  = CRYP_AlgoDir_Encrypt;
-            AES_CRYP_InitStructure.CRYP_AlgoMode = CRYP_AlgoMode_AES_CTR;
-            AES_CRYP_InitStructure.CRYP_DataType = CRYP_DataType_8b;
-            CRYP_Init(&AES_CRYP_InitStructure);
-
-            /* enable crypto processor */
-            CRYP_Cmd(ENABLE);
-
-            while (sz > 0)
-            {
-                /* flush IN/OUT FIFOs */
-                CRYP_FIFOFlush();
-
-                CRYP_DataIn(*(uint32_t*)&in[0]);
-                CRYP_DataIn(*(uint32_t*)&in[4]);
-                CRYP_DataIn(*(uint32_t*)&in[8]);
-                CRYP_DataIn(*(uint32_t*)&in[12]);
-
-                /* wait until the complete message has been processed */
-                while(CRYP_GetFlagStatus(CRYP_FLAG_BUSY) != RESET) {}
-
-                *(uint32_t*)&out[0]  = CRYP_DataOut();
-                *(uint32_t*)&out[4]  = CRYP_DataOut();
-                *(uint32_t*)&out[8]  = CRYP_DataOut();
-                *(uint32_t*)&out[12] = CRYP_DataOut();
-
-                /* store iv for next call */
-                XMEMCPY(aes->reg, out + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
-
-                sz  -= 16;
-                in  += 16;
-                out += 16;
-            }
-
-            /* disable crypto processor */
-            CRYP_Cmd(DISABLE);
-        }
-
-    #elif defined(WOLFSSL_PIC32MZ_CRYPT)
-        void wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-        {
-            int i ;
-            char out_block[AES_BLOCK_SIZE] ;
-            int odd ;
-            int even ;
-            char *tmp ; /* (char *)aes->tmp, for short */
-
-            tmp = (char *)aes->tmp ;
-            if(aes->left) {
-                if((aes->left + sz) >= AES_BLOCK_SIZE){
-                    odd = AES_BLOCK_SIZE - aes->left ;
-                } else {
-                    odd = sz ;
-                }
-                XMEMCPY(tmp+aes->left, in, odd) ;
-                if((odd+aes->left) == AES_BLOCK_SIZE){
-                    wc_AesCrypt(aes, out_block, tmp, AES_BLOCK_SIZE,
-                        PIC32_ENCRYPTION, PIC32_ALGO_AES, PIC32_CRYPTOALGO_RCTR);
-                    XMEMCPY(out, out_block+aes->left, odd) ;
-                    aes->left = 0 ;
-                    XMEMSET(tmp, 0x0, AES_BLOCK_SIZE) ;
-                    /* Increment IV */
-                    for (i = AES_BLOCK_SIZE - 1; i >= 0; i--) {
-                        if (++((byte *)aes->iv_ce)[i])
-                            break ;
-                    }
-                }
-                in += odd ;
-                out+= odd ;
-                sz -= odd ;
-            }
-            odd = sz % AES_BLOCK_SIZE ;  /* if there is tail flagment */
-            if(sz / AES_BLOCK_SIZE) {
-                even = (sz/AES_BLOCK_SIZE)*AES_BLOCK_SIZE ;
-                wc_AesCrypt(aes, out, in, even, PIC32_ENCRYPTION, PIC32_ALGO_AES,
-                                                        PIC32_CRYPTOALGO_RCTR);
-                out += even ;
-                in  += even ;
-                do {  /* Increment IV */
-                    for (i = AES_BLOCK_SIZE - 1; i >= 0; i--) {
-                        if (++((byte *)aes->iv_ce)[i])
-                            break ;
-                    }
-                    even -= AES_BLOCK_SIZE ;
-                } while((int)even > 0) ;
-            }
-            if(odd) {
-                XMEMSET(tmp+aes->left, 0x0, AES_BLOCK_SIZE - aes->left) ;
-                XMEMCPY(tmp+aes->left, in, odd) ;
-                wc_AesCrypt(aes, out_block, tmp, AES_BLOCK_SIZE,
-                        PIC32_ENCRYPTION, PIC32_ALGO_AES, PIC32_CRYPTOALGO_RCTR);
-                XMEMCPY(out, out_block+aes->left,odd) ;
-                aes->left += odd ;
-            }
-        }
-
-    #elif defined(HAVE_COLDFIRE_SEC)
-        #error "Coldfire SEC doesn't currently support AES-CTR mode"
-
-    #elif defined(FREESCALE_MMCAU)
-        #error "Freescale mmCAU doesn't currently support AES-CTR mode"
-
-    #else
-        /* Increment AES counter */
-        static INLINE void IncrementAesCounter(byte* inOutCtr)
-        {
-            int i;
-
-            /* in network byte order so start at end and work back */
-            for (i = AES_BLOCK_SIZE - 1; i >= 0; i--) {
-                if (++inOutCtr[i])  /* we're done unless we overflow */
-                    return;
-            }
-        }
-
-        void wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-        {
-            byte* tmp = (byte*)aes->tmp + AES_BLOCK_SIZE - aes->left;
-
-            /* consume any unused bytes left in aes->tmp */
-            while (aes->left && sz) {
-               *(out++) = *(in++) ^ *(tmp++);
-               aes->left--;
-               sz--;
-            }
-
-            /* do as many block size ops as possible */
-            while (sz >= AES_BLOCK_SIZE) {
-                wc_AesEncrypt(aes, (byte*)aes->reg, out);
-                IncrementAesCounter((byte*)aes->reg);
-                xorbuf(out, in, AES_BLOCK_SIZE);
-
-                out += AES_BLOCK_SIZE;
-                in  += AES_BLOCK_SIZE;
-                sz  -= AES_BLOCK_SIZE;
-                aes->left = 0;
-            }
-
-            /* handle non block size remaining and sotre unused byte count in left */
-            if (sz) {
-                wc_AesEncrypt(aes, (byte*)aes->reg, (byte*)aes->tmp);
-                IncrementAesCounter((byte*)aes->reg);
-
-                aes->left = AES_BLOCK_SIZE;
-                tmp = (byte*)aes->tmp;
-
-                while (sz--) {
-                    *(out++) = *(in++) ^ *(tmp++);
-                    aes->left--;
-                }
-            }
-        }
-
-    #endif /* STM32F2_CRYPTO, AES-CTR block */
-
-#endif /* WOLFSSL_AES_COUNTER */
-
-#ifdef HAVE_AESGCM
-
-/*
- * The IV for AES GCM, stored in struct Aes's member reg, is comprised of
- * three parts in order:
- *   1. The implicit IV. This is generated from the PRF using the shared
- *      secrets between endpoints. It is 4 bytes long.
- *   2. The explicit IV. This is set by the user of the AES. It needs to be
- *      unique for each call to encrypt. The explicit IV is shared with the
- *      other end of the transaction in the clear.
- *   3. The counter. Each block of data is encrypted with its own sequence
- *      number counter.
- */
-
-#ifdef STM32F2_CRYPTO
-    #error "STM32F2 crypto doesn't currently support AES-GCM mode"
-
-#elif defined(HAVE_COLDFIRE_SEC)
-    #error "Coldfire SEC doesn't currently support AES-GCM mode"
-
-#endif
-
-enum {
-    CTR_SZ = 4
-};
-
-
-static INLINE void InitGcmCounter(byte* inOutCtr)
-{
-    inOutCtr[AES_BLOCK_SIZE - 4] = 0;
-    inOutCtr[AES_BLOCK_SIZE - 3] = 0;
-    inOutCtr[AES_BLOCK_SIZE - 2] = 0;
-    inOutCtr[AES_BLOCK_SIZE - 1] = 1;
-}
-
-
-static INLINE void IncrementGcmCounter(byte* inOutCtr)
-{
-    int i;
-
-    /* in network byte order so start at end and work back */
-    for (i = AES_BLOCK_SIZE - 1; i >= AES_BLOCK_SIZE - CTR_SZ; i--) {
-        if (++inOutCtr[i])  /* we're done unless we overflow */
-            return;
-    }
-}
-
-
-#if defined(GCM_SMALL) || defined(GCM_TABLE)
-
-static INLINE void FlattenSzInBits(byte* buf, word32 sz)
-{
-    /* Multiply the sz by 8 */
-    word32 szHi = (sz >> (8*sizeof(sz) - 3));
-    sz <<= 3;
-
-    /* copy over the words of the sz into the destination buffer */
-    buf[0] = (szHi >> 24) & 0xff;
-    buf[1] = (szHi >> 16) & 0xff;
-    buf[2] = (szHi >>  8) & 0xff;
-    buf[3] = szHi & 0xff;
-    buf[4] = (sz >> 24) & 0xff;
-    buf[5] = (sz >> 16) & 0xff;
-    buf[6] = (sz >>  8) & 0xff;
-    buf[7] = sz & 0xff;
-}
-
-
-static INLINE void RIGHTSHIFTX(byte* x)
-{
-    int i;
-    int carryOut = 0;
-    int carryIn = 0;
-    int borrow = x[15] & 0x01;
-
-    for (i = 0; i < AES_BLOCK_SIZE; i++) {
-        carryOut = x[i] & 0x01;
-        x[i] = (x[i] >> 1) | (carryIn ? 0x80 : 0);
-        carryIn = carryOut;
-    }
-    if (borrow) x[0] ^= 0xE1;
-}
-
-#endif /* defined(GCM_SMALL) || defined(GCM_TABLE) */
-
-
-#ifdef GCM_TABLE
-
-static void GenerateM0(Aes* aes)
-{
-    int i, j;
-    byte (*m)[AES_BLOCK_SIZE] = aes->M0;
-
-    XMEMCPY(m[128], aes->H, AES_BLOCK_SIZE);
-
-    for (i = 64; i > 0; i /= 2) {
-        XMEMCPY(m[i], m[i*2], AES_BLOCK_SIZE);
-        RIGHTSHIFTX(m[i]);
-    }
-
-    for (i = 2; i < 256; i *= 2) {
-        for (j = 1; j < i; j++) {
-            XMEMCPY(m[i+j], m[i], AES_BLOCK_SIZE);
-            xorbuf(m[i+j], m[j], AES_BLOCK_SIZE);
-        }
-    }
-
-    XMEMSET(m[0], 0, AES_BLOCK_SIZE);
-}
-
-#endif /* GCM_TABLE */
-
-
-int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
-{
-    int  ret;
-    byte iv[AES_BLOCK_SIZE];
-
-    #ifdef FREESCALE_MMCAU
-        byte* rk = (byte*)aes->key;
-    #endif
-
-    if (!((len == 16) || (len == 24) || (len == 32)))
-        return BAD_FUNC_ARG;
-
-    XMEMSET(iv, 0, AES_BLOCK_SIZE);
-    ret = wc_AesSetKey(aes, key, len, iv, AES_ENCRYPTION);
-
-    if (ret == 0) {
-    #ifdef FREESCALE_MMCAU
-        cau_aes_encrypt(iv, rk, aes->rounds, aes->H);
-    #else
-        wc_AesEncrypt(aes, iv, aes->H);
-    #endif
-    #ifdef GCM_TABLE
-        GenerateM0(aes);
-    #endif /* GCM_TABLE */
-    }
-
-    return ret;
-}
-
-
-#if defined(GCM_SMALL)
-
-static void GMULT(byte* X, byte* Y)
-{
-    byte Z[AES_BLOCK_SIZE];
-    byte V[AES_BLOCK_SIZE];
-    int i, j;
-
-    XMEMSET(Z, 0, AES_BLOCK_SIZE);
-    XMEMCPY(V, X, AES_BLOCK_SIZE);
-    for (i = 0; i < AES_BLOCK_SIZE; i++)
-    {
-        byte y = Y[i];
-        for (j = 0; j < 8; j++)
-        {
-            if (y & 0x80) {
-                xorbuf(Z, V, AES_BLOCK_SIZE);
-            }
-
-            RIGHTSHIFTX(V);
-            y = y << 1;
-        }
-    }
-    XMEMCPY(X, Z, AES_BLOCK_SIZE);
-}
-
-
-static void GHASH(Aes* aes, const byte* a, word32 aSz,
-                                const byte* c, word32 cSz, byte* s, word32 sSz)
-{
-    byte x[AES_BLOCK_SIZE];
-    byte scratch[AES_BLOCK_SIZE];
-    word32 blocks, partial;
-    byte* h = aes->H;
-
-    XMEMSET(x, 0, AES_BLOCK_SIZE);
-
-    /* Hash in A, the Additional Authentication Data */
-    if (aSz != 0 && a != NULL) {
-        blocks = aSz / AES_BLOCK_SIZE;
-        partial = aSz % AES_BLOCK_SIZE;
-        while (blocks--) {
-            xorbuf(x, a, AES_BLOCK_SIZE);
-            GMULT(x, h);
-            a += AES_BLOCK_SIZE;
-        }
-        if (partial != 0) {
-            XMEMSET(scratch, 0, AES_BLOCK_SIZE);
-            XMEMCPY(scratch, a, partial);
-            xorbuf(x, scratch, AES_BLOCK_SIZE);
-            GMULT(x, h);
-        }
-    }
-
-    /* Hash in C, the Ciphertext */
-    if (cSz != 0 && c != NULL) {
-        blocks = cSz / AES_BLOCK_SIZE;
-        partial = cSz % AES_BLOCK_SIZE;
-        while (blocks--) {
-            xorbuf(x, c, AES_BLOCK_SIZE);
-            GMULT(x, h);
-            c += AES_BLOCK_SIZE;
-        }
-        if (partial != 0) {
-            XMEMSET(scratch, 0, AES_BLOCK_SIZE);
-            XMEMCPY(scratch, c, partial);
-            xorbuf(x, scratch, AES_BLOCK_SIZE);
-            GMULT(x, h);
-        }
-    }
-
-    /* Hash in the lengths of A and C in bits */
-    FlattenSzInBits(&scratch[0], aSz);
-    FlattenSzInBits(&scratch[8], cSz);
-    xorbuf(x, scratch, AES_BLOCK_SIZE);
-    GMULT(x, h);
-
-    /* Copy the result into s. */
-    XMEMCPY(s, x, sSz);
-}
-
-/* end GCM_SMALL */
-#elif defined(GCM_TABLE)
-
-static const byte R[256][2] = {
-    {0x00, 0x00}, {0x01, 0xc2}, {0x03, 0x84}, {0x02, 0x46},
-    {0x07, 0x08}, {0x06, 0xca}, {0x04, 0x8c}, {0x05, 0x4e},
-    {0x0e, 0x10}, {0x0f, 0xd2}, {0x0d, 0x94}, {0x0c, 0x56},
-    {0x09, 0x18}, {0x08, 0xda}, {0x0a, 0x9c}, {0x0b, 0x5e},
-    {0x1c, 0x20}, {0x1d, 0xe2}, {0x1f, 0xa4}, {0x1e, 0x66},
-    {0x1b, 0x28}, {0x1a, 0xea}, {0x18, 0xac}, {0x19, 0x6e},
-    {0x12, 0x30}, {0x13, 0xf2}, {0x11, 0xb4}, {0x10, 0x76},
-    {0x15, 0x38}, {0x14, 0xfa}, {0x16, 0xbc}, {0x17, 0x7e},
-    {0x38, 0x40}, {0x39, 0x82}, {0x3b, 0xc4}, {0x3a, 0x06},
-    {0x3f, 0x48}, {0x3e, 0x8a}, {0x3c, 0xcc}, {0x3d, 0x0e},
-    {0x36, 0x50}, {0x37, 0x92}, {0x35, 0xd4}, {0x34, 0x16},
-    {0x31, 0x58}, {0x30, 0x9a}, {0x32, 0xdc}, {0x33, 0x1e},
-    {0x24, 0x60}, {0x25, 0xa2}, {0x27, 0xe4}, {0x26, 0x26},
-    {0x23, 0x68}, {0x22, 0xaa}, {0x20, 0xec}, {0x21, 0x2e},
-    {0x2a, 0x70}, {0x2b, 0xb2}, {0x29, 0xf4}, {0x28, 0x36},
-    {0x2d, 0x78}, {0x2c, 0xba}, {0x2e, 0xfc}, {0x2f, 0x3e},
-    {0x70, 0x80}, {0x71, 0x42}, {0x73, 0x04}, {0x72, 0xc6},
-    {0x77, 0x88}, {0x76, 0x4a}, {0x74, 0x0c}, {0x75, 0xce},
-    {0x7e, 0x90}, {0x7f, 0x52}, {0x7d, 0x14}, {0x7c, 0xd6},
-    {0x79, 0x98}, {0x78, 0x5a}, {0x7a, 0x1c}, {0x7b, 0xde},
-    {0x6c, 0xa0}, {0x6d, 0x62}, {0x6f, 0x24}, {0x6e, 0xe6},
-    {0x6b, 0xa8}, {0x6a, 0x6a}, {0x68, 0x2c}, {0x69, 0xee},
-    {0x62, 0xb0}, {0x63, 0x72}, {0x61, 0x34}, {0x60, 0xf6},
-    {0x65, 0xb8}, {0x64, 0x7a}, {0x66, 0x3c}, {0x67, 0xfe},
-    {0x48, 0xc0}, {0x49, 0x02}, {0x4b, 0x44}, {0x4a, 0x86},
-    {0x4f, 0xc8}, {0x4e, 0x0a}, {0x4c, 0x4c}, {0x4d, 0x8e},
-    {0x46, 0xd0}, {0x47, 0x12}, {0x45, 0x54}, {0x44, 0x96},
-    {0x41, 0xd8}, {0x40, 0x1a}, {0x42, 0x5c}, {0x43, 0x9e},
-    {0x54, 0xe0}, {0x55, 0x22}, {0x57, 0x64}, {0x56, 0xa6},
-    {0x53, 0xe8}, {0x52, 0x2a}, {0x50, 0x6c}, {0x51, 0xae},
-    {0x5a, 0xf0}, {0x5b, 0x32}, {0x59, 0x74}, {0x58, 0xb6},
-    {0x5d, 0xf8}, {0x5c, 0x3a}, {0x5e, 0x7c}, {0x5f, 0xbe},
-    {0xe1, 0x00}, {0xe0, 0xc2}, {0xe2, 0x84}, {0xe3, 0x46},
-    {0xe6, 0x08}, {0xe7, 0xca}, {0xe5, 0x8c}, {0xe4, 0x4e},
-    {0xef, 0x10}, {0xee, 0xd2}, {0xec, 0x94}, {0xed, 0x56},
-    {0xe8, 0x18}, {0xe9, 0xda}, {0xeb, 0x9c}, {0xea, 0x5e},
-    {0xfd, 0x20}, {0xfc, 0xe2}, {0xfe, 0xa4}, {0xff, 0x66},
-    {0xfa, 0x28}, {0xfb, 0xea}, {0xf9, 0xac}, {0xf8, 0x6e},
-    {0xf3, 0x30}, {0xf2, 0xf2}, {0xf0, 0xb4}, {0xf1, 0x76},
-    {0xf4, 0x38}, {0xf5, 0xfa}, {0xf7, 0xbc}, {0xf6, 0x7e},
-    {0xd9, 0x40}, {0xd8, 0x82}, {0xda, 0xc4}, {0xdb, 0x06},
-    {0xde, 0x48}, {0xdf, 0x8a}, {0xdd, 0xcc}, {0xdc, 0x0e},
-    {0xd7, 0x50}, {0xd6, 0x92}, {0xd4, 0xd4}, {0xd5, 0x16},
-    {0xd0, 0x58}, {0xd1, 0x9a}, {0xd3, 0xdc}, {0xd2, 0x1e},
-    {0xc5, 0x60}, {0xc4, 0xa2}, {0xc6, 0xe4}, {0xc7, 0x26},
-    {0xc2, 0x68}, {0xc3, 0xaa}, {0xc1, 0xec}, {0xc0, 0x2e},
-    {0xcb, 0x70}, {0xca, 0xb2}, {0xc8, 0xf4}, {0xc9, 0x36},
-    {0xcc, 0x78}, {0xcd, 0xba}, {0xcf, 0xfc}, {0xce, 0x3e},
-    {0x91, 0x80}, {0x90, 0x42}, {0x92, 0x04}, {0x93, 0xc6},
-    {0x96, 0x88}, {0x97, 0x4a}, {0x95, 0x0c}, {0x94, 0xce},
-    {0x9f, 0x90}, {0x9e, 0x52}, {0x9c, 0x14}, {0x9d, 0xd6},
-    {0x98, 0x98}, {0x99, 0x5a}, {0x9b, 0x1c}, {0x9a, 0xde},
-    {0x8d, 0xa0}, {0x8c, 0x62}, {0x8e, 0x24}, {0x8f, 0xe6},
-    {0x8a, 0xa8}, {0x8b, 0x6a}, {0x89, 0x2c}, {0x88, 0xee},
-    {0x83, 0xb0}, {0x82, 0x72}, {0x80, 0x34}, {0x81, 0xf6},
-    {0x84, 0xb8}, {0x85, 0x7a}, {0x87, 0x3c}, {0x86, 0xfe},
-    {0xa9, 0xc0}, {0xa8, 0x02}, {0xaa, 0x44}, {0xab, 0x86},
-    {0xae, 0xc8}, {0xaf, 0x0a}, {0xad, 0x4c}, {0xac, 0x8e},
-    {0xa7, 0xd0}, {0xa6, 0x12}, {0xa4, 0x54}, {0xa5, 0x96},
-    {0xa0, 0xd8}, {0xa1, 0x1a}, {0xa3, 0x5c}, {0xa2, 0x9e},
-    {0xb5, 0xe0}, {0xb4, 0x22}, {0xb6, 0x64}, {0xb7, 0xa6},
-    {0xb2, 0xe8}, {0xb3, 0x2a}, {0xb1, 0x6c}, {0xb0, 0xae},
-    {0xbb, 0xf0}, {0xba, 0x32}, {0xb8, 0x74}, {0xb9, 0xb6},
-    {0xbc, 0xf8}, {0xbd, 0x3a}, {0xbf, 0x7c}, {0xbe, 0xbe} };
-
-
-static void GMULT(byte *x, byte m[256][AES_BLOCK_SIZE])
-{
-    int i, j;
-    byte Z[AES_BLOCK_SIZE];
-    byte a;
-
-    XMEMSET(Z, 0, sizeof(Z));
-
-    for (i = 15; i > 0; i--) {
-        xorbuf(Z, m[x[i]], AES_BLOCK_SIZE);
-        a = Z[15];
-
-        for (j = 15; j > 0; j--) {
-            Z[j] = Z[j-1];
-        }
-
-        Z[0] = R[a][0];
-        Z[1] ^= R[a][1];
-    }
-    xorbuf(Z, m[x[0]], AES_BLOCK_SIZE);
-
-    XMEMCPY(x, Z, AES_BLOCK_SIZE);
-}
-
-
-static void GHASH(Aes* aes, const byte* a, word32 aSz,
-                                const byte* c, word32 cSz, byte* s, word32 sSz)
-{
-    byte x[AES_BLOCK_SIZE];
-    byte scratch[AES_BLOCK_SIZE];
-    word32 blocks, partial;
-
-    XMEMSET(x, 0, AES_BLOCK_SIZE);
-
-    /* Hash in A, the Additional Authentication Data */
-    if (aSz != 0 && a != NULL) {
-        blocks = aSz / AES_BLOCK_SIZE;
-        partial = aSz % AES_BLOCK_SIZE;
-        while (blocks--) {
-            xorbuf(x, a, AES_BLOCK_SIZE);
-            GMULT(x, aes->M0);
-            a += AES_BLOCK_SIZE;
-        }
-        if (partial != 0) {
-            XMEMSET(scratch, 0, AES_BLOCK_SIZE);
-            XMEMCPY(scratch, a, partial);
-            xorbuf(x, scratch, AES_BLOCK_SIZE);
-            GMULT(x, aes->M0);
-        }
-    }
-
-    /* Hash in C, the Ciphertext */
-    if (cSz != 0 && c != NULL) {
-        blocks = cSz / AES_BLOCK_SIZE;
-        partial = cSz % AES_BLOCK_SIZE;
-        while (blocks--) {
-            xorbuf(x, c, AES_BLOCK_SIZE);
-            GMULT(x, aes->M0);
-            c += AES_BLOCK_SIZE;
-        }
-        if (partial != 0) {
-            XMEMSET(scratch, 0, AES_BLOCK_SIZE);
-            XMEMCPY(scratch, c, partial);
-            xorbuf(x, scratch, AES_BLOCK_SIZE);
-            GMULT(x, aes->M0);
-        }
-    }
-
-    /* Hash in the lengths of A and C in bits */
-    FlattenSzInBits(&scratch[0], aSz);
-    FlattenSzInBits(&scratch[8], cSz);
-    xorbuf(x, scratch, AES_BLOCK_SIZE);
-    GMULT(x, aes->M0);
-
-    /* Copy the result into s. */
-    XMEMCPY(s, x, sSz);
-}
-
-/* end GCM_TABLE */
-#elif defined(WORD64_AVAILABLE) && !defined(GCM_WORD32)
-
-static void GMULT(word64* X, word64* Y)
-{
-    word64 Z[2] = {0,0};
-    word64 V[2] ; 
-    int i, j;
-    V[0] = X[0] ;  V[1] = X[1] ;
-
-    for (i = 0; i < 2; i++)
-    {
-        word64 y = Y[i];
-        for (j = 0; j < 64; j++)
-        {
-            if (y & 0x8000000000000000ULL) {
-                Z[0] ^= V[0];
-                Z[1] ^= V[1];
-            }
-
-            if (V[1] & 0x0000000000000001) {
-                V[1] >>= 1;
-                V[1] |= ((V[0] & 0x0000000000000001) ? 0x8000000000000000ULL : 0);
-                V[0] >>= 1;
-                V[0] ^= 0xE100000000000000ULL;
-            }
-            else {
-                V[1] >>= 1;
-                V[1] |= ((V[0] & 0x0000000000000001) ? 0x8000000000000000ULL : 0);
-                V[0] >>= 1;
-            }
-            y <<= 1;
-        }
-    }
-    X[0] = Z[0];
-    X[1] = Z[1];
-}
-
-
-static void GHASH(Aes* aes, const byte* a, word32 aSz,
-                                const byte* c, word32 cSz, byte* s, word32 sSz)
-{
-    word64 x[2] = {0,0};
-    word32 blocks, partial;
-    word64 bigH[2];
-
-    XMEMCPY(bigH, aes->H, AES_BLOCK_SIZE);
-    #ifdef LITTLE_ENDIAN_ORDER
-        ByteReverseWords64(bigH, bigH, AES_BLOCK_SIZE); 
-    #endif
-
-    /* Hash in A, the Additional Authentication Data */
-    if (aSz != 0 && a != NULL) {
-        word64 bigA[2];
-        blocks = aSz / AES_BLOCK_SIZE;
-        partial = aSz % AES_BLOCK_SIZE;
-        while (blocks--) {
-            XMEMCPY(bigA, a, AES_BLOCK_SIZE);
-            #ifdef LITTLE_ENDIAN_ORDER
-                ByteReverseWords64(bigA, bigA, AES_BLOCK_SIZE);
-            #endif
-            x[0] ^= bigA[0];
-            x[1] ^= bigA[1];
-            GMULT(x, bigH);
-            a += AES_BLOCK_SIZE;
-        }
-        if (partial != 0) {
-            XMEMSET(bigA, 0, AES_BLOCK_SIZE);
-            XMEMCPY(bigA, a, partial);
-            #ifdef LITTLE_ENDIAN_ORDER
-                ByteReverseWords64(bigA, bigA, AES_BLOCK_SIZE);
-            #endif
-            x[0] ^= bigA[0];
-            x[1] ^= bigA[1];
-            GMULT(x, bigH);
-        }
-    }
-
-    /* Hash in C, the Ciphertext */
-    if (cSz != 0 && c != NULL) {
-        word64 bigC[2];
-        blocks = cSz / AES_BLOCK_SIZE;
-        partial = cSz % AES_BLOCK_SIZE;
-        while (blocks--) {
-            XMEMCPY(bigC, c, AES_BLOCK_SIZE);
-            #ifdef LITTLE_ENDIAN_ORDER
-                ByteReverseWords64(bigC, bigC, AES_BLOCK_SIZE);
-            #endif
-            x[0] ^= bigC[0];
-            x[1] ^= bigC[1];
-            GMULT(x, bigH);
-            c += AES_BLOCK_SIZE;
-        }
-        if (partial != 0) {
-            XMEMSET(bigC, 0, AES_BLOCK_SIZE);
-            XMEMCPY(bigC, c, partial);
-            #ifdef LITTLE_ENDIAN_ORDER
-                ByteReverseWords64(bigC, bigC, AES_BLOCK_SIZE);
-            #endif
-            x[0] ^= bigC[0];
-            x[1] ^= bigC[1];
-            GMULT(x, bigH);
-        }
-    }
-
-    /* Hash in the lengths in bits of A and C */
-    {
-        word64 len[2] ; 
-        len[0] = aSz ; len[1] = cSz;
-
-        /* Lengths are in bytes. Convert to bits. */
-        len[0] *= 8;
-        len[1] *= 8;
-
-        x[0] ^= len[0];
-        x[1] ^= len[1];
-        GMULT(x, bigH);
-    }
-    #ifdef LITTLE_ENDIAN_ORDER
-        ByteReverseWords64(x, x, AES_BLOCK_SIZE);
-    #endif
-    XMEMCPY(s, x, sSz);
-}
-
-/* end defined(WORD64_AVAILABLE) && !defined(GCM_WORD32) */
-#else /* GCM_WORD32 */
-
-static void GMULT(word32* X, word32* Y)
-{
-    word32 Z[4] = {0,0,0,0};
-    word32 V[4] ;
-    int i, j;
-
-    V[0] = X[0];  V[1] = X[1]; V[2] =  X[2]; V[3] =  X[3];
-
-    for (i = 0; i < 4; i++)
-    {
-        word32 y = Y[i];
-        for (j = 0; j < 32; j++)
-        {
-            if (y & 0x80000000) {
-                Z[0] ^= V[0];
-                Z[1] ^= V[1];
-                Z[2] ^= V[2];
-                Z[3] ^= V[3];
-            }
-
-            if (V[3] & 0x00000001) {
-                V[3] >>= 1;
-                V[3] |= ((V[2] & 0x00000001) ? 0x80000000 : 0);
-                V[2] >>= 1;
-                V[2] |= ((V[1] & 0x00000001) ? 0x80000000 : 0);
-                V[1] >>= 1;
-                V[1] |= ((V[0] & 0x00000001) ? 0x80000000 : 0);
-                V[0] >>= 1;
-                V[0] ^= 0xE1000000;
-            } else {
-                V[3] >>= 1;
-                V[3] |= ((V[2] & 0x00000001) ? 0x80000000 : 0);
-                V[2] >>= 1;
-                V[2] |= ((V[1] & 0x00000001) ? 0x80000000 : 0);
-                V[1] >>= 1;
-                V[1] |= ((V[0] & 0x00000001) ? 0x80000000 : 0);
-                V[0] >>= 1;
-            }
-            y <<= 1;
-        }
-    }
-    X[0] = Z[0];
-    X[1] = Z[1];
-    X[2] = Z[2];
-    X[3] = Z[3];
-}
-
-
-static void GHASH(Aes* aes, const byte* a, word32 aSz,
-                                const byte* c, word32 cSz, byte* s, word32 sSz)
-{
-    word32 x[4] = {0,0,0,0};
-    word32 blocks, partial;
-    word32 bigH[4];
-
-    XMEMCPY(bigH, aes->H, AES_BLOCK_SIZE);
-    #ifdef LITTLE_ENDIAN_ORDER
-        ByteReverseWords(bigH, bigH, AES_BLOCK_SIZE);
-    #endif
-
-    /* Hash in A, the Additional Authentication Data */
-    if (aSz != 0 && a != NULL) {
-        word32 bigA[4];
-        blocks = aSz / AES_BLOCK_SIZE;
-        partial = aSz % AES_BLOCK_SIZE;
-        while (blocks--) {
-            XMEMCPY(bigA, a, AES_BLOCK_SIZE);
-            #ifdef LITTLE_ENDIAN_ORDER
-                ByteReverseWords(bigA, bigA, AES_BLOCK_SIZE);
-            #endif
-            x[0] ^= bigA[0];
-            x[1] ^= bigA[1];
-            x[2] ^= bigA[2];
-            x[3] ^= bigA[3];
-            GMULT(x, bigH);
-            a += AES_BLOCK_SIZE;
-        }
-        if (partial != 0) {
-            XMEMSET(bigA, 0, AES_BLOCK_SIZE);
-            XMEMCPY(bigA, a, partial);
-            #ifdef LITTLE_ENDIAN_ORDER
-                ByteReverseWords(bigA, bigA, AES_BLOCK_SIZE);
-            #endif
-            x[0] ^= bigA[0];
-            x[1] ^= bigA[1];
-            x[2] ^= bigA[2];
-            x[3] ^= bigA[3];
-            GMULT(x, bigH);
-        }
-    }
-
-    /* Hash in C, the Ciphertext */
-    if (cSz != 0 && c != NULL) {
-        word32 bigC[4];
-        blocks = cSz / AES_BLOCK_SIZE;
-        partial = cSz % AES_BLOCK_SIZE;
-        while (blocks--) {
-            XMEMCPY(bigC, c, AES_BLOCK_SIZE);
-            #ifdef LITTLE_ENDIAN_ORDER
-                ByteReverseWords(bigC, bigC, AES_BLOCK_SIZE);
-            #endif
-            x[0] ^= bigC[0];
-            x[1] ^= bigC[1];
-            x[2] ^= bigC[2];
-            x[3] ^= bigC[3];
-            GMULT(x, bigH);
-            c += AES_BLOCK_SIZE;
-        }
-        if (partial != 0) {
-            XMEMSET(bigC, 0, AES_BLOCK_SIZE);
-            XMEMCPY(bigC, c, partial);
-            #ifdef LITTLE_ENDIAN_ORDER
-                ByteReverseWords(bigC, bigC, AES_BLOCK_SIZE);
-            #endif
-            x[0] ^= bigC[0];
-            x[1] ^= bigC[1];
-            x[2] ^= bigC[2];
-            x[3] ^= bigC[3];
-            GMULT(x, bigH);
-        }
-    }
-
-    /* Hash in the lengths in bits of A and C */
-    {
-        word32 len[4];
-
-        /* Lengths are in bytes. Convert to bits. */
-        len[0] = (aSz >> (8*sizeof(aSz) - 3));
-        len[1] = aSz << 3;
-        len[2] = (cSz >> (8*sizeof(cSz) - 3));
-        len[3] = cSz << 3;
-
-        x[0] ^= len[0];
-        x[1] ^= len[1];
-        x[2] ^= len[2];
-        x[3] ^= len[3];
-        GMULT(x, bigH);
-    }
-    #ifdef LITTLE_ENDIAN_ORDER
-        ByteReverseWords(x, x, AES_BLOCK_SIZE);
-    #endif
-    XMEMCPY(s, x, sSz);
-}
-
-#endif /* end GCM_WORD32 */
-
-
-int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
-                   const byte* iv, word32 ivSz,
-                   byte* authTag, word32 authTagSz,
-                   const byte* authIn, word32 authInSz)
-{
-    word32 blocks = sz / AES_BLOCK_SIZE;
-    word32 partial = sz % AES_BLOCK_SIZE;
-    const byte* p = in;
-    byte* c = out;
-    byte counter[AES_BLOCK_SIZE];
-    byte *ctr ;
-    byte scratch[AES_BLOCK_SIZE];
-
-#ifdef FREESCALE_MMCAU
-    byte* key = (byte*)aes->key;
-#endif
-
-    WOLFSSL_ENTER("AesGcmEncrypt");
-
-#ifdef WOLFSSL_PIC32MZ_CRYPT
-    ctr = (char *)aes->iv_ce ;
-#else
-    ctr = counter ;
-#endif
-
-    XMEMSET(ctr, 0, AES_BLOCK_SIZE);
-    XMEMCPY(ctr, iv, ivSz);
-    InitGcmCounter(ctr);
-
-#ifdef WOLFSSL_PIC32MZ_CRYPT
-    if(blocks)
-        wc_AesCrypt(aes, out, in, blocks*AES_BLOCK_SIZE,
-             PIC32_ENCRYPTION, PIC32_ALGO_AES, PIC32_CRYPTOALGO_AES_GCM );
-#endif
-    while (blocks--) {
-        IncrementGcmCounter(ctr);
-        #ifndef WOLFSSL_PIC32MZ_CRYPT
-            #ifdef FREESCALE_MMCAU
-                cau_aes_encrypt(ctr, key, aes->rounds, scratch);
-            #else
-                wc_AesEncrypt(aes, ctr, scratch);
-            #endif
-        xorbuf(scratch, p, AES_BLOCK_SIZE);
-        XMEMCPY(c, scratch, AES_BLOCK_SIZE);
-        #endif
-        p += AES_BLOCK_SIZE;
-        c += AES_BLOCK_SIZE;
-    }
-
-    if (partial != 0) {
-        IncrementGcmCounter(ctr);
-        #ifdef FREESCALE_MMCAU
-            cau_aes_encrypt(ctr, key, aes->rounds, scratch);
-        #else
-            wc_AesEncrypt(aes, ctr, scratch);
-        #endif
-        xorbuf(scratch, p, partial);
-        XMEMCPY(c, scratch, partial);
-
-    }
-
-    GHASH(aes, authIn, authInSz, out, sz, authTag, authTagSz);
-    InitGcmCounter(ctr);
-    #ifdef FREESCALE_MMCAU
-        cau_aes_encrypt(ctr, key, aes->rounds, scratch);
-    #else
-        wc_AesEncrypt(aes, ctr, scratch);
-    #endif
-    xorbuf(authTag, scratch, authTagSz);
-
-    return 0;
-}
-
-
-int  wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
-                   const byte* iv, word32 ivSz,
-                   const byte* authTag, word32 authTagSz,
-                   const byte* authIn, word32 authInSz)
-{
-    word32 blocks = sz / AES_BLOCK_SIZE;
-    word32 partial = sz % AES_BLOCK_SIZE;
-    const byte* c = in;
-    byte* p = out;
-    byte counter[AES_BLOCK_SIZE];
-    byte *ctr ;
-    byte scratch[AES_BLOCK_SIZE];
-
-#ifdef FREESCALE_MMCAU
-    byte* key = (byte*)aes->key;
-#endif
-
-    WOLFSSL_ENTER("AesGcmDecrypt");
-
-#ifdef WOLFSSL_PIC32MZ_CRYPT
-    ctr = (char *)aes->iv_ce ;
-#else
-    ctr = counter ;
-#endif
-
-    XMEMSET(ctr, 0, AES_BLOCK_SIZE);
-    XMEMCPY(ctr, iv, ivSz);
-    InitGcmCounter(ctr);
-
-    /* Calculate the authTag again using the received auth data and the
-     * cipher text. */
-    {
-        byte Tprime[AES_BLOCK_SIZE];
-        byte EKY0[AES_BLOCK_SIZE];
-
-        GHASH(aes, authIn, authInSz, in, sz, Tprime, sizeof(Tprime));
-        #ifdef FREESCALE_MMCAU
-            cau_aes_encrypt(ctr, key, aes->rounds, EKY0);
-        #else
-            wc_AesEncrypt(aes, ctr, EKY0);
-        #endif
-        xorbuf(Tprime, EKY0, sizeof(Tprime));
-
-        if (ConstantCompare(authTag, Tprime, authTagSz) != 0) {
-            return AES_GCM_AUTH_E;
-        }
-    }
-
-#ifdef WOLFSSL_PIC32MZ_CRYPT
-    if(blocks)
-        wc_AesCrypt(aes, out, in, blocks*AES_BLOCK_SIZE,
-             PIC32_DECRYPTION, PIC32_ALGO_AES, PIC32_CRYPTOALGO_AES_GCM );
-#endif
-
-    while (blocks--) {
-        IncrementGcmCounter(ctr);
-        #ifndef WOLFSSL_PIC32MZ_CRYPT
-            #ifdef FREESCALE_MMCAU
-                cau_aes_encrypt(ctr, key, aes->rounds, scratch);
-            #else
-                wc_AesEncrypt(aes, ctr, scratch);
-            #endif
-        xorbuf(scratch, c, AES_BLOCK_SIZE);
-        XMEMCPY(p, scratch, AES_BLOCK_SIZE);
-        #endif
-        p += AES_BLOCK_SIZE;
-        c += AES_BLOCK_SIZE;
-    }
-    if (partial != 0) {
-        IncrementGcmCounter(ctr);
-        #ifdef FREESCALE_MMCAU
-            cau_aes_encrypt(ctr, key, aes->rounds, scratch);
-        #else
-            wc_AesEncrypt(aes, ctr, scratch);
-        #endif
-        xorbuf(scratch, c, partial);
-        XMEMCPY(p, scratch, partial);
-    }
-    return 0;
-}
-
-
-
-WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len)
-{
-    return wc_AesGcmSetKey(&gmac->aes, key, len);
-}
-
-
-WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
-                              const byte* authIn, word32 authInSz,
-                              byte* authTag, word32 authTagSz)
-{
-    return wc_AesGcmEncrypt(&gmac->aes, NULL, NULL, 0, iv, ivSz,
-                                         authTag, authTagSz, authIn, authInSz);
-}
-
-#endif /* HAVE_AESGCM */
-
-
-#ifdef HAVE_AESCCM
-
-#ifdef STM32F2_CRYPTO
-    #error "STM32F2 crypto doesn't currently support AES-CCM mode"
-
-#elif defined(HAVE_COLDFIRE_SEC)
-    #error "Coldfire SEC doesn't currently support AES-CCM mode"
-
-#elif defined(WOLFSSL_PIC32MZ_CRYPT)
-    #error "PIC32MZ doesn't currently support AES-CCM mode"
-
-#endif
-
-void wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz)
-{
-    byte nonce[AES_BLOCK_SIZE];
-
-    if (!((keySz == 16) || (keySz == 24) || (keySz == 32)))
-        return;
-
-    XMEMSET(nonce, 0, sizeof(nonce));
-    wc_AesSetKey(aes, key, keySz, nonce, AES_ENCRYPTION);
-}
-
-
-static void roll_x(Aes* aes, const byte* in, word32 inSz, byte* out)
-{
-    #ifdef FREESCALE_MMCAU
-        byte* key = (byte*)aes->key;
-    #endif
-
-    /* process the bulk of the data */
-    while (inSz >= AES_BLOCK_SIZE) {
-        xorbuf(out, in, AES_BLOCK_SIZE);
-        in += AES_BLOCK_SIZE;
-        inSz -= AES_BLOCK_SIZE;
-
-        #ifdef FREESCALE_MMCAU
-            cau_aes_encrypt(out, key, aes->rounds, out);
-        #else
-            wc_AesEncrypt(aes, out, out);
-        #endif
-    }
-
-    /* process remainder of the data */
-    if (inSz > 0) {
-        xorbuf(out, in, inSz);
-        #ifdef FREESCALE_MMCAU
-            cau_aes_encrypt(out, key, aes->rounds, out);
-        #else
-            wc_AesEncrypt(aes, out, out);
-        #endif
-    }
-}
-
-
-static void roll_auth(Aes* aes, const byte* in, word32 inSz, byte* out)
-{
-    word32 authLenSz;
-    word32 remainder;
-
-    #ifdef FREESCALE_MMCAU
-        byte* key = (byte*)aes->key;
-    #endif
-
-    /* encode the length in */
-    if (inSz <= 0xFEFF) {
-        authLenSz = 2;
-        out[0] ^= ((inSz & 0xFF00) >> 8);
-        out[1] ^=  (inSz & 0x00FF);
-    }
-    else if (inSz <= 0xFFFFFFFF) {
-        authLenSz = 6;
-        out[0] ^= 0xFF; out[1] ^= 0xFE;
-        out[2] ^= ((inSz & 0xFF000000) >> 24);
-        out[3] ^= ((inSz & 0x00FF0000) >> 16);
-        out[4] ^= ((inSz & 0x0000FF00) >>  8);
-        out[5] ^=  (inSz & 0x000000FF);
-    }
-    /* Note, the protocol handles auth data up to 2^64, but we are
-     * using 32-bit sizes right now, so the bigger data isn't handled
-     * else if (inSz <= 0xFFFFFFFFFFFFFFFF) {} */
-    else
-        return;
-
-    /* start fill out the rest of the first block */
-    remainder = AES_BLOCK_SIZE - authLenSz;
-    if (inSz >= remainder) {
-        /* plenty of bulk data to fill the remainder of this block */
-        xorbuf(out + authLenSz, in, remainder);
-        inSz -= remainder;
-        in += remainder;
-    }
-    else {
-        /* not enough bulk data, copy what is available, and pad zero */
-        xorbuf(out + authLenSz, in, inSz);
-        inSz = 0;
-    }
-    #ifdef FREESCALE_MMCAU
-        cau_aes_encrypt(out, key, aes->rounds, out);
-    #else
-        wc_AesEncrypt(aes, out, out);
-    #endif
-
-    if (inSz > 0)
-        roll_x(aes, in, inSz, out);
-}
-
-
-static INLINE void AesCcmCtrInc(byte* B, word32 lenSz)
-{
-    word32 i;
-
-    for (i = 0; i < lenSz; i++) {
-        if (++B[AES_BLOCK_SIZE - 1 - i] != 0) return;
-    }
-}
-
-
-void wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
-                   const byte* nonce, word32 nonceSz,
-                   byte* authTag, word32 authTagSz,
-                   const byte* authIn, word32 authInSz)
-{
-    byte A[AES_BLOCK_SIZE];
-    byte B[AES_BLOCK_SIZE];
-    byte lenSz;
-    word32 i;
-
-    #ifdef FREESCALE_MMCAU
-        byte* key = (byte*)aes->key;
-    #endif
-
-    XMEMCPY(B+1, nonce, nonceSz);
-    lenSz = AES_BLOCK_SIZE - 1 - (byte)nonceSz;
-    B[0] = (authInSz > 0 ? 64 : 0)
-         + (8 * (((byte)authTagSz - 2) / 2))
-         + (lenSz - 1);
-    for (i = 0; i < lenSz; i++)
-        B[AES_BLOCK_SIZE - 1 - i] = (inSz >> (8 * i)) & 0xFF;
-
-    #ifdef FREESCALE_MMCAU
-        cau_aes_encrypt(B, key, aes->rounds, A);
-    #else
-        wc_AesEncrypt(aes, B, A);
-    #endif
-    if (authInSz > 0)
-        roll_auth(aes, authIn, authInSz, A);
-    if (inSz > 0)
-        roll_x(aes, in, inSz, A);
-    XMEMCPY(authTag, A, authTagSz);
-
-    B[0] = lenSz - 1;
-    for (i = 0; i < lenSz; i++)
-        B[AES_BLOCK_SIZE - 1 - i] = 0;
-    #ifdef FREESCALE_MMCAU
-        cau_aes_encrypt(B, key, aes->rounds, A);
-    #else
-        wc_AesEncrypt(aes, B, A);
-    #endif
-    xorbuf(authTag, A, authTagSz);
-
-    B[15] = 1;
-    while (inSz >= AES_BLOCK_SIZE) {
-        #ifdef FREESCALE_MMCAU
-            cau_aes_encrypt(B, key, aes->rounds, A);
-        #else
-            wc_AesEncrypt(aes, B, A);
-        #endif
-        xorbuf(A, in, AES_BLOCK_SIZE);
-        XMEMCPY(out, A, AES_BLOCK_SIZE);
-
-        AesCcmCtrInc(B, lenSz);
-        inSz -= AES_BLOCK_SIZE;
-        in += AES_BLOCK_SIZE;
-        out += AES_BLOCK_SIZE;
-    }
-    if (inSz > 0) {
-        #ifdef FREESCALE_MMCAU
-            cau_aes_encrypt(B, key, aes->rounds, A);
-        #else
-            wc_AesEncrypt(aes, B, A);
-        #endif
-        xorbuf(A, in, inSz);
-        XMEMCPY(out, A, inSz);
-    }
-
-    ForceZero(A, AES_BLOCK_SIZE);
-    ForceZero(B, AES_BLOCK_SIZE);
-}
-
-
-int  wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
-                   const byte* nonce, word32 nonceSz,
-                   const byte* authTag, word32 authTagSz,
-                   const byte* authIn, word32 authInSz)
-{
-    byte A[AES_BLOCK_SIZE];
-    byte B[AES_BLOCK_SIZE];
-    byte* o;
-    byte lenSz;
-    word32 i, oSz;
-    int result = 0;
-
-    #ifdef FREESCALE_MMCAU
-        byte* key = (byte*)aes->key;
-    #endif
-
-    o = out;
-    oSz = inSz;
-    XMEMCPY(B+1, nonce, nonceSz);
-    lenSz = AES_BLOCK_SIZE - 1 - (byte)nonceSz;
-
-    B[0] = lenSz - 1;
-    for (i = 0; i < lenSz; i++)
-        B[AES_BLOCK_SIZE - 1 - i] = 0;
-    B[15] = 1;
-
-    while (oSz >= AES_BLOCK_SIZE) {
-        #ifdef FREESCALE_MMCAU
-            cau_aes_encrypt(B, key, aes->rounds, A);
-        #else
-            wc_AesEncrypt(aes, B, A);
-        #endif
-        xorbuf(A, in, AES_BLOCK_SIZE);
-        XMEMCPY(o, A, AES_BLOCK_SIZE);
-
-        AesCcmCtrInc(B, lenSz);
-        oSz -= AES_BLOCK_SIZE;
-        in += AES_BLOCK_SIZE;
-        o += AES_BLOCK_SIZE;
-    }
-    if (inSz > 0) {
-        #ifdef FREESCALE_MMCAU
-            cau_aes_encrypt(B, key, aes->rounds, A);
-        #else
-            wc_AesEncrypt(aes, B, A);
-        #endif
-        xorbuf(A, in, oSz);
-        XMEMCPY(o, A, oSz);
-    }
-
-    for (i = 0; i < lenSz; i++)
-        B[AES_BLOCK_SIZE - 1 - i] = 0;
-    #ifdef FREESCALE_MMCAU
-        cau_aes_encrypt(B, key, aes->rounds, A);
-    #else
-        wc_AesEncrypt(aes, B, A);
-    #endif
-
-    o = out;
-    oSz = inSz;
-
-    B[0] = (authInSz > 0 ? 64 : 0)
-         + (8 * (((byte)authTagSz - 2) / 2))
-         + (lenSz - 1);
-    for (i = 0; i < lenSz; i++)
-        B[AES_BLOCK_SIZE - 1 - i] = (inSz >> (8 * i)) & 0xFF;
-
-    #ifdef FREESCALE_MMCAU
-        cau_aes_encrypt(B, key, aes->rounds, A);
-    #else
-        wc_AesEncrypt(aes, B, A);
-    #endif
-    if (authInSz > 0)
-        roll_auth(aes, authIn, authInSz, A);
-    if (inSz > 0)
-        roll_x(aes, o, oSz, A);
-
-    B[0] = lenSz - 1;
-    for (i = 0; i < lenSz; i++)
-        B[AES_BLOCK_SIZE - 1 - i] = 0;
-    #ifdef FREESCALE_MMCAU
-        cau_aes_encrypt(B, key, aes->rounds, B);
-    #else
-        wc_AesEncrypt(aes, B, B);
-    #endif
-    xorbuf(A, B, authTagSz);
-
-    if (ConstantCompare(A, authTag, authTagSz) != 0) {
-        /* If the authTag check fails, don't keep the decrypted data.
-         * Unfortunately, you need the decrypted data to calculate the
-         * check value. */
-        XMEMSET(out, 0, inSz);
-        result = AES_CCM_AUTH_E;
-    }
-
-    ForceZero(A, AES_BLOCK_SIZE);
-    ForceZero(B, AES_BLOCK_SIZE);
-    o = NULL;
-
-    return result;
-}
-
-#endif /* HAVE_AESCCM */
-
-
-#ifdef HAVE_CAVIUM
-
-#include 
-#include "cavium_common.h"
-
-/* Initiliaze Aes for use with Nitrox device */
-int wc_AesInitCavium(Aes* aes, int devId)
-{
-    if (aes == NULL)
-        return -1;
-
-    if (CspAllocContext(CONTEXT_SSL, &aes->contextHandle, devId) != 0)
-        return -1;
-
-    aes->devId = devId;
-    aes->magic = WOLFSSL_AES_CAVIUM_MAGIC;
-
-    return 0;
-}
-
-
-/* Free Aes from use with Nitrox device */
-void wc_AesFreeCavium(Aes* aes)
-{
-    if (aes == NULL)
-        return;
-
-    if (aes->magic != WOLFSSL_AES_CAVIUM_MAGIC)
-        return;
-
-    CspFreeContext(CONTEXT_SSL, aes->contextHandle, aes->devId);
-    aes->magic = 0;
-}
-
-
-static int wc_AesCaviumSetKey(Aes* aes, const byte* key, word32 length,
-                           const byte* iv)
-{
-    if (aes == NULL)
-        return -1;
-
-    XMEMCPY(aes->key, key, length);   /* key still holds key, iv still in reg */
-    if (length == 16)
-        aes->type = AES_128;
-    else if (length == 24)
-        aes->type = AES_192;
-    else if (length == 32)
-        aes->type = AES_256;
-
-    return wc_AesSetIV(aes, iv);
-}
-
-
-static int AesCaviumCbcEncrypt(Aes* aes, byte* out, const byte* in,
-                               word32 length)
-{
-    wolfssl_word offset = 0;
-    word32 requestId;
-
-    while (length > WOLFSSL_MAX_16BIT) {
-        word16 slen = (word16)WOLFSSL_MAX_16BIT;
-        if (CspEncryptAes(CAVIUM_BLOCKING, aes->contextHandle, CAVIUM_NO_UPDATE,
-                          aes->type, slen, (byte*)in + offset, out + offset,
-                          (byte*)aes->reg, (byte*)aes->key, &requestId,
-                          aes->devId) != 0) {
-            WOLFSSL_MSG("Bad Cavium Aes Encrypt");
-            return -1;
-        }
-        length -= WOLFSSL_MAX_16BIT;
-        offset += WOLFSSL_MAX_16BIT;
-        XMEMCPY(aes->reg, out + offset - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
-    }
-    if (length) {
-        word16 slen = (word16)length;
-        if (CspEncryptAes(CAVIUM_BLOCKING, aes->contextHandle, CAVIUM_NO_UPDATE,
-                          aes->type, slen, (byte*)in + offset, out + offset,
-                          (byte*)aes->reg, (byte*)aes->key, &requestId,
-                          aes->devId) != 0) {
-            WOLFSSL_MSG("Bad Cavium Aes Encrypt");
-            return -1;
-        }
-        XMEMCPY(aes->reg, out + offset+length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
-    }
-    return 0;
-}
-
-static int AesCaviumCbcDecrypt(Aes* aes, byte* out, const byte* in,
-                               word32 length)
-{
-    word32 requestId;
-    wolfssl_word offset = 0;
-
-    while (length > WOLFSSL_MAX_16BIT) {
-        word16 slen = (word16)WOLFSSL_MAX_16BIT;
-        XMEMCPY(aes->tmp, in + offset + slen - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
-        if (CspDecryptAes(CAVIUM_BLOCKING, aes->contextHandle, CAVIUM_NO_UPDATE,
-                          aes->type, slen, (byte*)in + offset, out + offset,
-                          (byte*)aes->reg, (byte*)aes->key, &requestId,
-                          aes->devId) != 0) {
-            WOLFSSL_MSG("Bad Cavium Aes Decrypt");
-            return -1;
-        }
-        length -= WOLFSSL_MAX_16BIT;
-        offset += WOLFSSL_MAX_16BIT;
-        XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE);
-    }
-    if (length) {
-        word16 slen = (word16)length;
-        XMEMCPY(aes->tmp, in + offset + slen - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
-        if (CspDecryptAes(CAVIUM_BLOCKING, aes->contextHandle, CAVIUM_NO_UPDATE,
-                          aes->type, slen, (byte*)in + offset, out + offset,
-                          (byte*)aes->reg, (byte*)aes->key, &requestId,
-                          aes->devId) != 0) {
-            WOLFSSL_MSG("Bad Cavium Aes Decrypt");
-            return -1;
-        }
-        XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE);
-    }
-    return 0;
-}
-
-#endif /* HAVE_CAVIUM */
-
-#endif /* WOLFSSL_TI_CRYPT */
-
-#endif /* HAVE_FIPS */
-
-#endif /* NO_AES */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/aes_asm.asm b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/aes_asm.asm
deleted file mode 100755
index a95f631..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/aes_asm.asm
+++ /dev/null
@@ -1,972 +0,0 @@
-;	/*aes_asm . asm
-;	*
-;	*Copyright[C]2006	-2014	wolfSSL	Inc	.
-;	*
-;	*This	file	is	part	of	wolfssl. (formerly known as CyaSSL)
-;	*
-;	*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-1301,USA
-;	*/
-;
-;
-;	/*See	IntelA	dvanced	Encryption	Standard[AES]Instructions	Set	White	Paper
-;	*by	Israel,Intel	Mobility	Group	Development	Center,Israel	Shay	Gueron
-;	*/
-;
-;   /* This file is in intel asm syntax, see .s for at&t syntax */
-;
-;	/*
-;	AES_CBC_encrypt[const	,unsigned	char*in
-;	unsigned	,char*out
-;	unsigned	,char	ivec+16
-;	unsigned	,long	length
-;	const	,unsigned	char*KS
-;	int	nr]
-;	*/
-_text SEGMENT
-AES_CBC_encrypt PROC
-;#	parameter	1:	rdi
-;#	parameter	2:	rsi
-;#	parameter	3:	rdx
-;#	parameter	4:	rcx
-;#	parameter	5:	r8
-;#	parameter	6:	r9d
-
-; save rdi and rsi to rax and r11, restore before ret
-	mov rax,rdi
-	mov r11,rsi
-
-; convert to what we had for att&t convention
-	mov rdi,rcx
-	mov rsi,rdx
-	mov rdx,r8
-	mov rcx,r9
-	mov r8,[rsp+40]
-	mov r9d,[rsp+48]
-
-	mov	r10,rcx
-	shr	rcx,4
-	shl	r10,60
-	je	NO_PARTS
-	add	rcx,1
-NO_PARTS:
-	sub	rsi,16
-	movdqa	xmm1,[rdx]
-LOOP_1:
-	pxor	xmm1,[rdi]
-	pxor	xmm1,[r8]
-	add	rsi,16
-	add	rdi,16
-	cmp	r9d,12
-	aesenc	xmm1,16[r8]
-	aesenc	xmm1,32[r8]
-	aesenc	xmm1,48[r8]
-	aesenc	xmm1,64[r8]
-	aesenc	xmm1,80[r8]
-	aesenc	xmm1,96[r8]
-	aesenc	xmm1,112[r8]
-	aesenc	xmm1,128[r8]
-	aesenc	xmm1,144[r8]
-	movdqa	xmm2,160[r8]
-	jb	LAST
-	cmp	r9d,14
-
-	aesenc	xmm1,160[r8]
-	aesenc	xmm1,176[r8]
-	movdqa	xmm2,192[r8]
-	jb	LAST
-	aesenc	xmm1,192[r8]
-	aesenc	xmm1,208[r8]
-	movdqa	xmm2,224[r8]
-LAST:
-	dec	rcx
-	aesenclast	xmm1,xmm2
-	movdqu	[rsi],xmm1
-	jne	LOOP_1
-	; restore non volatile rdi,rsi
-	mov rdi,rax
-	mov rsi,r11
-	ret
-AES_CBC_encrypt ENDP
-
-
-
-;	/*
-;	AES_CBC_decrypt[const	,unsigned	char*in
-;	unsigned	,char*out
-;	unsigned	,char	ivec+16
-;	unsigned	,long	length
-;	const	,unsigned	char*KS
-;	int	nr]
-;	*/
-;	.	globl	AES_CBC_decrypt
-AES_CBC_decrypt PROC
-;#	parameter	1:	rdi
-;#	parameter	2:	rsi
-;#	parameter	3:	rdx
-;#	parameter	4:	rcx
-;#	parameter	5:	r8
-;#	parameter	6:	r9d
-
-; save rdi and rsi to rax and r11, restore before ret
-	mov rax,rdi
-	mov r11,rsi
-
-; convert to what we had for att&t convention
-	mov rdi,rcx
-	mov rsi,rdx
-	mov rdx,r8
-	mov rcx,r9
-	mov r8,[rsp+40]
-	mov r9d,[rsp+48]
-
-; on microsoft xmm6-xmm15 are non volaitle, let's save on stack and restore at end
-	sub rsp,8+8*16  ; 8 = align stack , 8 xmm6-12,15 16 bytes each
-	movdqa [rsp+0], xmm6
-	movdqa [rsp+16], xmm7
-	movdqa [rsp+32], xmm8
-	movdqa [rsp+48], xmm9
-	movdqa [rsp+64], xmm10
-	movdqa [rsp+80], xmm11
-	movdqa [rsp+96], xmm12
-	movdqa [rsp+112], xmm15
-
-	mov	r10,rcx
-	shr	rcx,4
-	shl	r10,60
-	je	DNO_PARTS_4
-	add	rcx,1
-DNO_PARTS_4:
-	mov	r10,rcx
-	shl	r10,62
-	shr	r10,62
-	shr	rcx,2
-	movdqu xmm5,[rdx]
-	je	DREMAINDER_4
-	sub	rsi,64
-DLOOP_4:
-	movdqu  xmm1,[rdi]
-	movdqu	xmm2,16[rdi]
-	movdqu	xmm3,32[rdi]
-	movdqu	xmm4,48[rdi]
-	movdqa	xmm6,xmm1
-	movdqa	xmm7,xmm2
-	movdqa	xmm8,xmm3
-	movdqa	xmm15,xmm4
-	movdqa  xmm9,[r8]
-	movdqa	xmm10,16[r8]
-	movdqa	xmm11,32[r8]
-	movdqa	xmm12,48[r8]
-	pxor	xmm1,xmm9
-	pxor	xmm2,xmm9
-	pxor	xmm3,xmm9
-
-	pxor	xmm4,xmm9
-	aesdec	xmm1,xmm10
-	aesdec	xmm2,xmm10
-	aesdec	xmm3,xmm10
-	aesdec	xmm4,xmm10
-	aesdec	xmm1,xmm11
-	aesdec	xmm2,xmm11
-	aesdec	xmm3,xmm11
-	aesdec	xmm4,xmm11
-	aesdec	xmm1,xmm12
-	aesdec	xmm2,xmm12
-	aesdec	xmm3,xmm12
-	aesdec	xmm4,xmm12
-	movdqa	xmm9,64[r8]
-	movdqa	xmm10,80[r8]
-	movdqa	xmm11,96[r8]
-	movdqa	xmm12,112[r8]
-	aesdec	xmm1,xmm9
-	aesdec	xmm2,xmm9
-	aesdec	xmm3,xmm9
-	aesdec	xmm4,xmm9
-	aesdec	xmm1,xmm10
-	aesdec	xmm2,xmm10
-	aesdec	xmm3,xmm10
-	aesdec	xmm4,xmm10
-	aesdec	xmm1,xmm11
-	aesdec	xmm2,xmm11
-	aesdec	xmm3,xmm11
-	aesdec	xmm4,xmm11
-	aesdec	xmm1,xmm12
-	aesdec	xmm2,xmm12
-	aesdec	xmm3,xmm12
-	aesdec	xmm4,xmm12
-	movdqa	xmm9,128[r8]
-	movdqa	xmm10,144[r8]
-	movdqa	xmm11,160[r8]
-	cmp	r9d,12
-	aesdec	xmm1,xmm9
-	aesdec	xmm2,xmm9
-	aesdec	xmm3,xmm9
-	aesdec	xmm4,xmm9
-	aesdec	xmm1,xmm10
-	aesdec	xmm2,xmm10
-	aesdec	xmm3,xmm10
-	aesdec	xmm4,xmm10
-	jb	DLAST_4
-	movdqa	xmm9,160[r8]
-	movdqa	xmm10,176[r8]
-	movdqa	xmm11,192[r8]
-	cmp	r9d,14
-	aesdec	xmm1,xmm9
-	aesdec	xmm2,xmm9
-	aesdec	xmm3,xmm9
-	aesdec	xmm4,xmm9
-	aesdec	xmm1,xmm10
-	aesdec	xmm2,xmm10
-	aesdec	xmm3,xmm10
-	aesdec	xmm4,xmm10
-	jb	DLAST_4
-
-	movdqa	xmm9,192[r8]
-	movdqa	xmm10,208[r8]
-	movdqa	xmm11,224[r8]
-	aesdec	xmm1,xmm9
-	aesdec	xmm2,xmm9
-	aesdec	xmm3,xmm9
-	aesdec	xmm4,xmm9
-	aesdec	xmm1,xmm10
-	aesdec	xmm2,xmm10
-	aesdec	xmm3,xmm10
-	aesdec	xmm4,xmm10
-DLAST_4:
-	add	rdi,64
-	add	rsi,64
-	dec	rcx
-	aesdeclast	xmm1,xmm11
-	aesdeclast	xmm2,xmm11
-	aesdeclast	xmm3,xmm11
-	aesdeclast	xmm4,xmm11
-	pxor	xmm1,xmm5
-	pxor	xmm2,xmm6
-	pxor	xmm3,xmm7
-	pxor	xmm4,xmm8
-	movdqu	[rsi],xmm1
-	movdqu	16[rsi],xmm2
-	movdqu	32[rsi],xmm3
-	movdqu	48[rsi],xmm4
-	movdqa	xmm5,xmm15
-	jne	DLOOP_4
-	add	rsi,64
-DREMAINDER_4:
-	cmp	r10,0
-	je	DEND_4
-DLOOP_4_2:
-	movdqu  xmm1,[rdi]
-	movdqa	xmm15,xmm1
-	add	rdi,16
-	pxor	xmm1,[r8]
-	movdqu	xmm2,160[r8]
-	cmp	r9d,12
-	aesdec	xmm1,16[r8]
-	aesdec	xmm1,32[r8]
-	aesdec	xmm1,48[r8]
-	aesdec	xmm1,64[r8]
-	aesdec	xmm1,80[r8]
-	aesdec	xmm1,96[r8]
-	aesdec	xmm1,112[r8]
-	aesdec	xmm1,128[r8]
-	aesdec	xmm1,144[r8]
-	jb	DLAST_4_2
-	movdqu	xmm2,192[r8]
-	cmp	r9d,14
-	aesdec	xmm1,160[r8]
-	aesdec	xmm1,176[r8]
-	jb	DLAST_4_2
-	movdqu	xmm2,224[r8]
-	aesdec	xmm1,192[r8]
-	aesdec	xmm1,208[r8]
-DLAST_4_2:
-	aesdeclast	xmm1,xmm2
-	pxor	xmm1,xmm5
-	movdqa	xmm5,xmm15
-	movdqu	[rsi],xmm1
-
-	add	rsi,16
-	dec	r10
-	jne	DLOOP_4_2
-DEND_4:
-	; restore non volatile rdi,rsi
-	mov rdi,rax
-	mov rsi,r11
-	; restore non volatile xmms from stack
-	movdqa xmm6, [rsp+0]
-	movdqa xmm7, [rsp+16]
-	movdqa xmm8, [rsp+32]
-	movdqa xmm9, [rsp+48]
-	movdqa xmm10, [rsp+64]
-	movdqa xmm11, [rsp+80]
-	movdqa xmm12, [rsp+96]
-	movdqa xmm15, [rsp+112]
-	add rsp,8+8*16 ; 8 = align stack , 8 xmm6-12,15 16 bytes each
-	ret
-AES_CBC_decrypt ENDP
-
-;	/*
-;	AES_ECB_encrypt[const	,unsigned	char*in
-;	unsigned	,char*out
-;	unsigned	,long	length
-;	const	,unsigned	char*KS
-;	int	nr]
-;	*/
-;	.	globl	AES_ECB_encrypt
-AES_ECB_encrypt PROC
-;#	parameter	1:	rdi
-;#	parameter	2:	rsi
-;#	parameter	3:	rdx
-;#	parameter	4:	rcx
-;#	parameter	5:	r8d
-
-; save rdi and rsi to rax and r11, restore before ret
-	mov rax,rdi
-	mov r11,rsi
-
-; convert to what we had for att&t convention
-    mov rdi,rcx
-	mov rsi,rdx
-	mov rdx,r8
-	mov rcx,r9
-	mov r8d,[rsp+40]
-
-; on microsoft xmm6-xmm15 are non volaitle, let's save on stack and restore at end
-	sub rsp,8+4*16  ; 8 = align stack , 4 xmm9-12, 16 bytes each
-	movdqa [rsp+0], xmm9
-	movdqa [rsp+16], xmm10
-	movdqa [rsp+32], xmm11
-	movdqa [rsp+48], xmm12
-
-
-	mov	r10,rdx
-	shr	rdx,4
-	shl	r10,60
-	je	EECB_NO_PARTS_4
-	add	rdx,1
-EECB_NO_PARTS_4:
-	mov	r10,rdx
-	shl	r10,62
-	shr	r10,62
-	shr	rdx,2
-	je	EECB_REMAINDER_4
-	sub	rsi,64
-EECB_LOOP_4:
-	movdqu  xmm1,[rdi]
-	movdqu	xmm2,16[rdi]
-	movdqu	xmm3,32[rdi]
-	movdqu	xmm4,48[rdi]
-	movdqa  xmm9,[rcx]
-	movdqa	xmm10,16[rcx]
-	movdqa	xmm11,32[rcx]
-	movdqa	xmm12,48[rcx]
-	pxor	xmm1,xmm9
-	pxor	xmm2,xmm9
-	pxor	xmm3,xmm9
-	pxor	xmm4,xmm9
-	aesenc	xmm1,xmm10
-	aesenc	xmm2,xmm10
-	aesenc	xmm3,xmm10
-	aesenc	xmm4,xmm10
-	aesenc	xmm1,xmm11
-	aesenc	xmm2,xmm11
-	aesenc	xmm3,xmm11
-	aesenc	xmm4,xmm11
-	aesenc	xmm1,xmm12
-	aesenc	xmm2,xmm12
-	aesenc	xmm3,xmm12
-	aesenc	xmm4,xmm12
-	movdqa	xmm9,64[rcx]
-	movdqa	xmm10,80[rcx]
-	movdqa	xmm11,96[rcx]
-	movdqa	xmm12,112[rcx]
-	aesenc	xmm1,xmm9
-	aesenc	xmm2,xmm9
-	aesenc	xmm3,xmm9
-	aesenc	xmm4,xmm9
-	aesenc	xmm1,xmm10
-	aesenc	xmm2,xmm10
-	aesenc	xmm3,xmm10
-	aesenc	xmm4,xmm10
-	aesenc	xmm1,xmm11
-	aesenc	xmm2,xmm11
-	aesenc	xmm3,xmm11
-	aesenc	xmm4,xmm11
-	aesenc	xmm1,xmm12
-	aesenc	xmm2,xmm12
-	aesenc	xmm3,xmm12
-	aesenc	xmm4,xmm12
-	movdqa	xmm9,128[rcx]
-	movdqa	xmm10,144[rcx]
-	movdqa	xmm11,160[rcx]
-	cmp	r8d,12
-	aesenc	xmm1,xmm9
-	aesenc	xmm2,xmm9
-	aesenc	xmm3,xmm9
-	aesenc	xmm4,xmm9
-	aesenc	xmm1,xmm10
-	aesenc	xmm2,xmm10
-	aesenc	xmm3,xmm10
-	aesenc	xmm4,xmm10
-	jb	EECB_LAST_4
-	movdqa	xmm9,160[rcx]
-	movdqa	xmm10,176[rcx]
-	movdqa	xmm11,192[rcx]
-	cmp	r8d,14
-	aesenc	xmm1,xmm9
-	aesenc	xmm2,xmm9
-	aesenc	xmm3,xmm9
-	aesenc	xmm4,xmm9
-	aesenc	xmm1,xmm10
-	aesenc	xmm2,xmm10
-	aesenc	xmm3,xmm10
-	aesenc	xmm4,xmm10
-	jb	EECB_LAST_4
-	movdqa	xmm9,192[rcx]
-	movdqa	xmm10,208[rcx]
-	movdqa	xmm11,224[rcx]
-	aesenc	xmm1,xmm9
-	aesenc	xmm2,xmm9
-	aesenc	xmm3,xmm9
-	aesenc	xmm4,xmm9
-	aesenc	xmm1,xmm10
-	aesenc	xmm2,xmm10
-	aesenc	xmm3,xmm10
-	aesenc	xmm4,xmm10
-EECB_LAST_4:
-	add	rdi,64
-	add	rsi,64
-	dec	rdx
-	aesenclast	xmm1,xmm11
-	aesenclast	xmm2,xmm11
-	aesenclast	xmm3,xmm11
-	aesenclast	xmm4,xmm11
-	movdqu	[rsi],xmm1
-	movdqu	16[rsi],xmm2
-	movdqu	32[rsi],xmm3
-	movdqu	48[rsi],xmm4
-	jne	EECB_LOOP_4
-	add	rsi,64
-EECB_REMAINDER_4:
-	cmp	r10,0
-	je	EECB_END_4
-EECB_LOOP_4_2:
-	movdqu  xmm1,[rdi]
-	add	rdi,16
-	pxor	xmm1,[rcx]
-	movdqu	xmm2,160[rcx]
-	aesenc	xmm1,16[rcx]
-	aesenc	xmm1,32[rcx]
-	aesenc	xmm1,48[rcx]
-	aesenc	xmm1,64[rcx]
-	aesenc	xmm1,80[rcx]
-	aesenc	xmm1,96[rcx]
-	aesenc	xmm1,112[rcx]
-	aesenc	xmm1,128[rcx]
-	aesenc	xmm1,144[rcx]
-	cmp	r8d,12
-	jb	EECB_LAST_4_2
-	movdqu	xmm2,192[rcx]
-	aesenc	xmm1,160[rcx]
-	aesenc	xmm1,176[rcx]
-	cmp	r8d,14
-	jb	EECB_LAST_4_2
-	movdqu	xmm2,224[rcx]
-	aesenc	xmm1,192[rcx]
-	aesenc	xmm1,208[rcx]
-EECB_LAST_4_2:
-	aesenclast	xmm1,xmm2
-	movdqu	[rsi],xmm1
-	add	rsi,16
-	dec	r10
-	jne	EECB_LOOP_4_2
-EECB_END_4:
-	; restore non volatile rdi,rsi
-	mov rdi,rax
-	mov rsi,r11
-	; restore non volatile xmms from stack
-	movdqa xmm9, [rsp+0]
-	movdqa xmm10, [rsp+16]
-	movdqa xmm11, [rsp+32]
-	movdqa xmm12, [rsp+48]
-	add rsp,8+4*16 ; 8 = align stack , 4 xmm9-12 16 bytes each
-	ret
-AES_ECB_encrypt ENDP
-
-;	/*
-;	AES_ECB_decrypt[const	,unsigned	char*in
-;	unsigned	,char*out
-;	unsigned	,long	length
-;	const	,unsigned	char*KS
-;	int	nr]
-;	*/
-;	.	globl	AES_ECB_decrypt
-AES_ECB_decrypt PROC
-;#	parameter	1:	rdi
-;#	parameter	2:	rsi
-;#	parameter	3:	rdx
-;#	parameter	4:	rcx
-;#	parameter	5:	r8d
-
-; save rdi and rsi to rax and r11, restore before ret
-	mov rax,rdi
-	mov r11,rsi
-
-; convert to what we had for att&t convention
-	mov rdi,rcx
-	mov rsi,rdx
-	mov rdx,r8
-	mov rcx,r9
-	mov r8d,[rsp+40]
-
-; on microsoft xmm6-xmm15 are non volaitle, let's save on stack and restore at end
-	sub rsp,8+4*16  ; 8 = align stack , 4 xmm9-12, 16 bytes each
-	movdqa [rsp+0], xmm9
-	movdqa [rsp+16], xmm10
-	movdqa [rsp+32], xmm11
-	movdqa [rsp+48], xmm12
-
-	mov	r10,rdx
-	shr	rdx,4
-	shl	r10,60
-	je	DECB_NO_PARTS_4
-	add	rdx,1
-DECB_NO_PARTS_4:
-	mov	r10,rdx
-	shl	r10,62
-	shr	r10,62
-	shr	rdx,2
-	je	DECB_REMAINDER_4
-	sub	rsi,64
-DECB_LOOP_4:
-	movdqu  xmm1,[rdi]
-	movdqu	xmm2,16[rdi]
-	movdqu	xmm3,32[rdi]
-	movdqu	xmm4,48[rdi]
-	movdqa  xmm9,[rcx]
-	movdqa	xmm10,16[rcx]
-	movdqa	xmm11,32[rcx]
-	movdqa	xmm12,48[rcx]
-	pxor	xmm1,xmm9
-	pxor	xmm2,xmm9
-	pxor	xmm3,xmm9
-	pxor	xmm4,xmm9
-	aesdec	xmm1,xmm10
-	aesdec	xmm2,xmm10
-	aesdec	xmm3,xmm10
-	aesdec	xmm4,xmm10
-	aesdec	xmm1,xmm11
-	aesdec	xmm2,xmm11
-	aesdec	xmm3,xmm11
-	aesdec	xmm4,xmm11
-	aesdec	xmm1,xmm12
-	aesdec	xmm2,xmm12
-	aesdec	xmm3,xmm12
-	aesdec	xmm4,xmm12
-	movdqa	xmm9,64[rcx]
-	movdqa	xmm10,80[rcx]
-	movdqa	xmm11,96[rcx]
-	movdqa	xmm12,112[rcx]
-	aesdec	xmm1,xmm9
-	aesdec	xmm2,xmm9
-	aesdec	xmm3,xmm9
-	aesdec	xmm4,xmm9
-	aesdec	xmm1,xmm10
-	aesdec	xmm2,xmm10
-	aesdec	xmm3,xmm10
-	aesdec	xmm4,xmm10
-	aesdec	xmm1,xmm11
-	aesdec	xmm2,xmm11
-	aesdec	xmm3,xmm11
-	aesdec	xmm4,xmm11
-	aesdec	xmm1,xmm12
-	aesdec	xmm2,xmm12
-	aesdec	xmm3,xmm12
-	aesdec	xmm4,xmm12
-	movdqa	xmm9,128[rcx]
-	movdqa	xmm10,144[rcx]
-	movdqa	xmm11,160[rcx]
-	cmp	r8d,12
-	aesdec	xmm1,xmm9
-	aesdec	xmm2,xmm9
-	aesdec	xmm3,xmm9
-	aesdec	xmm4,xmm9
-	aesdec	xmm1,xmm10
-	aesdec	xmm2,xmm10
-	aesdec	xmm3,xmm10
-	aesdec	xmm4,xmm10
-	jb	DECB_LAST_4
-	movdqa	xmm9,160[rcx]
-	movdqa	xmm10,176[rcx]
-	movdqa	xmm11,192[rcx]
-	cmp	r8d,14
-	aesdec	xmm1,xmm9
-	aesdec	xmm2,xmm9
-	aesdec	xmm3,xmm9
-	aesdec	xmm4,xmm9
-	aesdec	xmm1,xmm10
-	aesdec	xmm2,xmm10
-	aesdec	xmm3,xmm10
-	aesdec	xmm4,xmm10
-	jb	DECB_LAST_4
-	movdqa	xmm9,192[rcx]
-	movdqa	xmm10,208[rcx]
-	movdqa	xmm11,224[rcx]
-	aesdec	xmm1,xmm9
-	aesdec	xmm2,xmm9
-	aesdec	xmm3,xmm9
-	aesdec	xmm4,xmm9
-	aesdec	xmm1,xmm10
-	aesdec	xmm2,xmm10
-	aesdec	xmm3,xmm10
-	aesdec	xmm4,xmm10
-DECB_LAST_4:
-	add	rdi,64
-	add	rsi,64
-	dec	rdx
-	aesdeclast	xmm1,xmm11
-	aesdeclast	xmm2,xmm11
-	aesdeclast	xmm3,xmm11
-	aesdeclast	xmm4,xmm11
-	movdqu	[rsi],xmm1
-	movdqu	16[rsi],xmm2
-	movdqu	32[rsi],xmm3
-	movdqu	48[rsi],xmm4
-	jne	DECB_LOOP_4
-	add	rsi,64
-DECB_REMAINDER_4:
-	cmp	r10,0
-	je	DECB_END_4
-DECB_LOOP_4_2:
-	movdqu  xmm1,[rdi]
-	add	rdi,16
-	pxor	xmm1,[rcx]
-	movdqu	xmm2,160[rcx]
-	cmp	r8d,12
-	aesdec	xmm1,16[rcx]
-	aesdec	xmm1,32[rcx]
-	aesdec	xmm1,48[rcx]
-	aesdec	xmm1,64[rcx]
-	aesdec	xmm1,80[rcx]
-	aesdec	xmm1,96[rcx]
-	aesdec	xmm1,112[rcx]
-	aesdec	xmm1,128[rcx]
-	aesdec	xmm1,144[rcx]
-	jb	DECB_LAST_4_2
-	cmp	r8d,14
-	movdqu	xmm2,192[rcx]
-	aesdec	xmm1,160[rcx]
-	aesdec	xmm1,176[rcx]
-	jb	DECB_LAST_4_2
-	movdqu	xmm2,224[rcx]
-	aesdec	xmm1,192[rcx]
-	aesdec	xmm1,208[rcx]
-DECB_LAST_4_2:
-	aesdeclast	xmm1,xmm2
-	movdqu	[rsi],xmm1
-	add	rsi,16
-	dec	r10
-	jne	DECB_LOOP_4_2
-DECB_END_4:
-	; restore non volatile rdi,rsi
-	mov rdi,rax
-	mov rsi,r11
-	; restore non volatile xmms from stack
-	movdqa xmm9, [rsp+0]
-	movdqa xmm10, [rsp+16]
-	movdqa xmm11, [rsp+32]
-	movdqa xmm12, [rsp+48]
-	add rsp,8+4*16 ; 8 = align stack , 4 xmm9-12 16 bytes each
-	ret
-AES_ECB_decrypt ENDP
-
-
-
-;	/*
-;	void	,AES_128_Key_Expansion[const	unsigned	char*userkey
-;	unsigned	char*key_schedule]/
-;	*/
-;	.	align	16,0x90
-;	.	globl	AES_128_Key_Expansion
-AES_128_Key_Expansion PROC
-;#	parameter	1:	rdi
-;#	parameter	2:	rsi
-
-; save rdi and rsi to rax and r11, restore before ret
-	mov rax,rdi
-	mov r11,rsi
-
-; convert to what we had for att&t convention
-	mov rdi,rcx
-	mov rsi,rdx
-
-	mov	dword ptr 240[rsi],10
-
-	movdqu	xmm1,[rdi]
-	movdqa	[rsi],xmm1
-
-
-ASSISTS:
-	aeskeygenassist	xmm2,xmm1,1
-	call	PREPARE_ROUNDKEY_128
-	movdqa	16[rsi],xmm1
-
-	aeskeygenassist	xmm2,xmm1,2
-	call	PREPARE_ROUNDKEY_128
-	movdqa	32[rsi],xmm1
-
-	aeskeygenassist	xmm2,xmm1,4
-	call	PREPARE_ROUNDKEY_128
-	movdqa	48[rsi],xmm1
-
-	aeskeygenassist	xmm2,xmm1,8
-	call	PREPARE_ROUNDKEY_128
-	movdqa	64[rsi],xmm1
-
-	aeskeygenassist	xmm2,xmm1,16
-	call	PREPARE_ROUNDKEY_128
-	movdqa	80[rsi],xmm1
-
-	aeskeygenassist	xmm2,xmm1,32
-	call	PREPARE_ROUNDKEY_128
-	movdqa	96[rsi],xmm1
-
-	aeskeygenassist	xmm2,xmm1,64
-	call	PREPARE_ROUNDKEY_128
-	movdqa	112[rsi],xmm1
-	aeskeygenassist	xmm2,xmm1,80h
-	call	PREPARE_ROUNDKEY_128
-	movdqa	128[rsi],xmm1
-	aeskeygenassist	xmm2,xmm1,1bh
-	call	PREPARE_ROUNDKEY_128
-	movdqa	144[rsi],xmm1
-	aeskeygenassist	xmm2,xmm1,36h
-	call	PREPARE_ROUNDKEY_128
-	movdqa	160[rsi],xmm1
-	; restore non volatile rdi,rsi
-	mov rdi,rax
-	mov rsi,r11
-	ret
-
-PREPARE_ROUNDKEY_128:
-	pshufd	xmm2,xmm2,255
-	movdqa	xmm3,xmm1
-	pslldq	xmm3,4
-	pxor	xmm1,xmm3
-	pslldq	xmm3,4
-	pxor	xmm1,xmm3
-	pslldq	xmm3,4
-	pxor	xmm1,xmm3
-	pxor	xmm1,xmm2
-	ret
-AES_128_Key_Expansion ENDP
-
-;	/*
-;	void	,AES_192_Key_Expansion[const	unsigned	char*userkey
-;	unsigned	char*key]
-;	*/
-;	.	globl	AES_192_Key_Expansion
-AES_192_Key_Expansion PROC
-;#	parameter	1:	rdi
-;#	parameter	2:	rsi
-
-; save rdi and rsi to rax and r11, restore before ret
-	mov rax,rdi
-	mov r11,rsi
-
-; convert to what we had for att&t convention
-    mov rdi,rcx
-	mov rsi,rdx
-
-; on microsoft xmm6-xmm15 are non volaitle, let's save on stack and restore at end
-	sub rsp,8+1*16  ; 8 = align stack , 1 xmm6, 16 bytes each
-	movdqa [rsp+0], xmm6
-
-	movdqu  xmm1,[rdi]
-	movdqu	xmm3,16[rdi]
-	movdqa	[rsi],xmm1
-	movdqa	xmm5,xmm3
-
-	aeskeygenassist	xmm2,xmm3,1h
-	call	PREPARE_ROUNDKEY_192
-	shufpd	xmm5,xmm1,0
-	movdqa	16[rsi],xmm5
-	movdqa	xmm6,xmm1
-	shufpd	xmm6,xmm3,1
-	movdqa	32[rsi],xmm6
-
-	aeskeygenassist	xmm2,xmm3,2h
-	call	PREPARE_ROUNDKEY_192
-	movdqa	48[rsi],xmm1
-	movdqa	xmm5,xmm3
-
-	aeskeygenassist	xmm2,xmm3,4h
-	call	PREPARE_ROUNDKEY_192
-	shufpd	xmm5,xmm1,0
-	movdqa	64[rsi],xmm5
-	movdqa	xmm6,xmm1
-	shufpd	xmm6,xmm3,1
-	movdqa	80[rsi],xmm6
-
-	aeskeygenassist	xmm2,xmm3,8h
-	call	PREPARE_ROUNDKEY_192
-	movdqa	96[rsi],xmm1
-	movdqa	xmm5,xmm3
-
-	aeskeygenassist	xmm2,xmm3,10h
-	call	PREPARE_ROUNDKEY_192
-	shufpd	xmm5,xmm1,0
-	movdqa	112[rsi],xmm5
-	movdqa	xmm6,xmm1
-	shufpd	xmm6,xmm3,1
-	movdqa	128[rsi],xmm6
-
-	aeskeygenassist	xmm2,xmm3,20h
-	call	PREPARE_ROUNDKEY_192
-	movdqa	144[rsi],xmm1
-	movdqa	xmm5,xmm3
-
-	aeskeygenassist	xmm2,xmm3,40h
-	call	PREPARE_ROUNDKEY_192
-	shufpd	xmm5,xmm1,0
-	movdqa	160[rsi],xmm5
-	movdqa	xmm6,xmm1
-	shufpd	xmm6,xmm3,1
-	movdqa	176[rsi],xmm6
-
-	aeskeygenassist	xmm2,xmm3,80h
-	call	PREPARE_ROUNDKEY_192
-	movdqa	192[rsi],xmm1
-	movdqa	208[rsi],xmm3
-	; restore non volatile rdi,rsi
-	mov rdi,rax
-	mov rsi,r11
-; restore non volatile xmms from stack
-	movdqa xmm6, [rsp+0]
-	add rsp,8+1*16 ; 8 = align stack , 1 xmm6 16 bytes each
-	ret
-
-PREPARE_ROUNDKEY_192:
-	pshufd	xmm2,xmm2,55h
-	movdqu	xmm4,xmm1
-	pslldq	xmm4,4
-	pxor	xmm1,xmm4
-
-	pslldq	xmm4,4
-	pxor	xmm1,xmm4
-	pslldq	xmm4,4
-	pxor	xmm1,xmm4
-	pxor	xmm1,xmm2
-	pshufd	xmm2,xmm1,0ffh
-	movdqu	xmm4,xmm3
-	pslldq	xmm4,4
-	pxor	xmm3,xmm4
-	pxor	xmm3,xmm2
-	ret
-AES_192_Key_Expansion ENDP
-
-;	/*
-;	void	,AES_256_Key_Expansion[const	unsigned	char*userkey
-;	unsigned	char*key]
-;	*/
-;	.	globl	AES_256_Key_Expansion
-AES_256_Key_Expansion PROC
-;#	parameter	1:	rdi
-;#	parameter	2:	rsi
-
-; save rdi and rsi to rax and r11, restore before ret
-	mov rax,rdi
-	mov r11,rsi
-
-; convert to what we had for att&t convention
-    mov rdi,rcx
-	mov rsi,rdx
-
-	movdqu  xmm1,[rdi]
-	movdqu	xmm3,16[rdi]
-	movdqa	[rsi],xmm1
-	movdqa	16[rsi],xmm3
-
-	aeskeygenassist	xmm2,xmm3,1h
-	call	MAKE_RK256_a
-	movdqa	32[rsi],xmm1
-	aeskeygenassist	xmm2,xmm1,0h
-	call	MAKE_RK256_b
-	movdqa	48[rsi],xmm3
-	aeskeygenassist	xmm2,xmm3,2h
-	call	MAKE_RK256_a
-	movdqa	64[rsi],xmm1
-	aeskeygenassist	xmm2,xmm1,0h
-	call	MAKE_RK256_b
-	movdqa	80[rsi],xmm3
-	aeskeygenassist	xmm2,xmm3,4h
-	call	MAKE_RK256_a
-	movdqa	96[rsi],xmm1
-	aeskeygenassist	xmm2,xmm1,0h
-	call	MAKE_RK256_b
-	movdqa	112[rsi],xmm3
-	aeskeygenassist	xmm2,xmm3,8h
-	call	MAKE_RK256_a
-	movdqa	128[rsi],xmm1
-	aeskeygenassist	xmm2,xmm1,0h
-	call	MAKE_RK256_b
-	movdqa	144[rsi],xmm3
-	aeskeygenassist	xmm2,xmm3,10h
-	call	MAKE_RK256_a
-	movdqa	160[rsi],xmm1
-	aeskeygenassist	xmm2,xmm1,0h
-	call	MAKE_RK256_b
-	movdqa	176[rsi],xmm3
-	aeskeygenassist	xmm2,xmm3,20h
-	call	MAKE_RK256_a
-	movdqa	192[rsi],xmm1
-
-	aeskeygenassist	xmm2,xmm1,0h
-	call	MAKE_RK256_b
-	movdqa	208[rsi],xmm3
-	aeskeygenassist	xmm2,xmm3,40h
-	call	MAKE_RK256_a
-	movdqa	224[rsi],xmm1
-
-	; restore non volatile rdi,rsi
-	mov rdi,rax
-	mov rsi,r11
-	ret
-AES_256_Key_Expansion ENDP
-
-MAKE_RK256_a:
-	pshufd	xmm2,xmm2,0ffh
-	movdqa	xmm4,xmm1
-	pslldq	xmm4,4
-	pxor	xmm1,xmm4
-	pslldq	xmm4,4
-	pxor	xmm1,xmm4
-	pslldq	xmm4,4
-	pxor	xmm1,xmm4
-	pxor	xmm1,xmm2
-	ret
-
-MAKE_RK256_b:
-	pshufd	xmm2,xmm2,0aah
-	movdqa	xmm4,xmm3
-	pslldq	xmm4,4
-	pxor	xmm3,xmm4
-	pslldq	xmm4,4
-	pxor	xmm3,xmm4
-	pslldq	xmm4,4
-	pxor	xmm3,xmm4
-	pxor	xmm3,xmm2
-	ret
-
-END
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/aes_asm.s b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/aes_asm.s
deleted file mode 100755
index b50c7ff..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/aes_asm.s
+++ /dev/null
@@ -1,816 +0,0 @@
-/* aes_asm.s
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-/* See Intel® Advanced Encryption Standard (AES) Instructions Set White Paper
- * by Intel Mobility Group, Israel Development Center, Israel Shay Gueron
- */
-
-/* This file is in at&t asm syntax, see .asm for intel syntax */
-
-
-/*
-AES_CBC_encrypt (const unsigned char *in,
-	unsigned char *out,
-	unsigned char ivec[16],
-	unsigned long length,
-	const unsigned char *KS,
-	int nr)
-*/
-.globl AES_CBC_encrypt
-AES_CBC_encrypt:
-# parameter 1: %rdi
-# parameter 2: %rsi
-# parameter 3: %rdx
-# parameter 4: %rcx
-# parameter 5: %r8
-# parameter 6: %r9d
-movq	%rcx, %r10
-shrq	$4, %rcx
-shlq	$60, %r10
-je	NO_PARTS
-addq	$1, %rcx
-NO_PARTS:
-subq	$16, %rsi
-movdqa	(%rdx), %xmm1
-LOOP:
-pxor	(%rdi), %xmm1
-pxor	(%r8), %xmm1
-addq	$16,%rsi
-addq	$16,%rdi
-cmpl	$12, %r9d
-aesenc	16(%r8),%xmm1
-aesenc	32(%r8),%xmm1
-aesenc	48(%r8),%xmm1
-aesenc	64(%r8),%xmm1
-aesenc	80(%r8),%xmm1
-aesenc	96(%r8),%xmm1
-aesenc	112(%r8),%xmm1
-aesenc	128(%r8),%xmm1
-aesenc	144(%r8),%xmm1
-movdqa	160(%r8),%xmm2
-jb	LAST
-cmpl	$14, %r9d
-
-aesenc	160(%r8),%xmm1
-aesenc	176(%r8),%xmm1
-movdqa	192(%r8),%xmm2
-jb	LAST
-aesenc	192(%r8),%xmm1
-aesenc	208(%r8),%xmm1
-movdqa	224(%r8),%xmm2
-LAST:
-decq	%rcx
-aesenclast %xmm2,%xmm1
-movdqu	%xmm1,(%rsi)
-jne	LOOP
-ret
-
-
-
-
-/*
-AES_CBC_decrypt (const unsigned char *in,
-  unsigned char *out,
-  unsigned char ivec[16],
-  unsigned long length,
-  const unsigned char *KS,
-  int nr)
-*/
-.globl AES_CBC_decrypt
-AES_CBC_decrypt:
-# parameter 1: %rdi
-# parameter 2: %rsi
-# parameter 3: %rdx
-# parameter 4: %rcx
-# parameter 5: %r8
-# parameter 6: %r9d
-
-movq    %rcx, %r10
-shrq $4, %rcx
-shlq   $60, %r10
-je    DNO_PARTS_4
-addq    $1, %rcx
-DNO_PARTS_4:
-movq   %rcx, %r10
-shlq    $62, %r10
-shrq  $62, %r10
-shrq  $2, %rcx
-movdqu (%rdx),%xmm5
-je DREMAINDER_4
-subq   $64, %rsi
-DLOOP_4:
-movdqu (%rdi), %xmm1
-movdqu  16(%rdi), %xmm2
-movdqu  32(%rdi), %xmm3
-movdqu  48(%rdi), %xmm4
-movdqa  %xmm1, %xmm6
-movdqa %xmm2, %xmm7
-movdqa %xmm3, %xmm8
-movdqa %xmm4, %xmm15
-movdqa    (%r8), %xmm9
-movdqa 16(%r8), %xmm10
-movdqa  32(%r8), %xmm11
-movdqa  48(%r8), %xmm12
-pxor    %xmm9, %xmm1
-pxor   %xmm9, %xmm2
-pxor   %xmm9, %xmm3
-
-pxor    %xmm9, %xmm4
-aesdec %xmm10, %xmm1
-aesdec    %xmm10, %xmm2
-aesdec    %xmm10, %xmm3
-aesdec    %xmm10, %xmm4
-aesdec    %xmm11, %xmm1
-aesdec    %xmm11, %xmm2
-aesdec    %xmm11, %xmm3
-aesdec    %xmm11, %xmm4
-aesdec    %xmm12, %xmm1
-aesdec    %xmm12, %xmm2
-aesdec    %xmm12, %xmm3
-aesdec    %xmm12, %xmm4
-movdqa    64(%r8), %xmm9
-movdqa   80(%r8), %xmm10
-movdqa  96(%r8), %xmm11
-movdqa  112(%r8), %xmm12
-aesdec %xmm9, %xmm1
-aesdec %xmm9, %xmm2
-aesdec %xmm9, %xmm3
-aesdec %xmm9, %xmm4
-aesdec %xmm10, %xmm1
-aesdec    %xmm10, %xmm2
-aesdec    %xmm10, %xmm3
-aesdec    %xmm10, %xmm4
-aesdec    %xmm11, %xmm1
-aesdec    %xmm11, %xmm2
-aesdec    %xmm11, %xmm3
-aesdec    %xmm11, %xmm4
-aesdec    %xmm12, %xmm1
-aesdec    %xmm12, %xmm2
-aesdec    %xmm12, %xmm3
-aesdec    %xmm12, %xmm4
-movdqa    128(%r8), %xmm9
-movdqa  144(%r8), %xmm10
-movdqa 160(%r8), %xmm11
-cmpl   $12, %r9d
-aesdec  %xmm9, %xmm1
-aesdec %xmm9, %xmm2
-aesdec %xmm9, %xmm3
-aesdec %xmm9, %xmm4
-aesdec %xmm10, %xmm1
-aesdec    %xmm10, %xmm2
-aesdec    %xmm10, %xmm3
-aesdec    %xmm10, %xmm4
-jb    DLAST_4
-movdqa  160(%r8), %xmm9
-movdqa  176(%r8), %xmm10
-movdqa 192(%r8), %xmm11
-cmpl   $14, %r9d
-aesdec  %xmm9, %xmm1
-aesdec %xmm9, %xmm2
-aesdec %xmm9, %xmm3
-aesdec %xmm9, %xmm4
-aesdec %xmm10, %xmm1
-aesdec    %xmm10, %xmm2
-aesdec    %xmm10, %xmm3
-aesdec    %xmm10, %xmm4
-jb    DLAST_4
-
-movdqa  192(%r8), %xmm9
-movdqa  208(%r8), %xmm10
-movdqa 224(%r8), %xmm11
-aesdec %xmm9, %xmm1
-aesdec %xmm9, %xmm2
-aesdec %xmm9, %xmm3
-aesdec %xmm9, %xmm4
-aesdec %xmm10, %xmm1
-aesdec    %xmm10, %xmm2
-aesdec    %xmm10, %xmm3
-aesdec    %xmm10, %xmm4
-DLAST_4:
-addq   $64, %rdi
-addq    $64, %rsi
-decq  %rcx
-aesdeclast %xmm11, %xmm1
-aesdeclast %xmm11, %xmm2
-aesdeclast %xmm11, %xmm3
-aesdeclast %xmm11, %xmm4
-pxor   %xmm5 ,%xmm1
-pxor    %xmm6 ,%xmm2
-pxor   %xmm7 ,%xmm3
-pxor   %xmm8 ,%xmm4
-movdqu %xmm1, (%rsi)
-movdqu    %xmm2, 16(%rsi)
-movdqu  %xmm3, 32(%rsi)
-movdqu  %xmm4, 48(%rsi)
-movdqa  %xmm15,%xmm5
-jne    DLOOP_4
-addq    $64, %rsi
-DREMAINDER_4:
-cmpq    $0, %r10
-je  DEND_4
-DLOOP_4_2:
-movdqu  (%rdi), %xmm1
-movdqa    %xmm1 ,%xmm15
-addq  $16, %rdi
-pxor  (%r8), %xmm1
-movdqu 160(%r8), %xmm2
-cmpl    $12, %r9d
-aesdec    16(%r8), %xmm1
-aesdec   32(%r8), %xmm1
-aesdec   48(%r8), %xmm1
-aesdec   64(%r8), %xmm1
-aesdec   80(%r8), %xmm1
-aesdec   96(%r8), %xmm1
-aesdec   112(%r8), %xmm1
-aesdec  128(%r8), %xmm1
-aesdec  144(%r8), %xmm1
-jb  DLAST_4_2
-movdqu    192(%r8), %xmm2
-cmpl    $14, %r9d
-aesdec    160(%r8), %xmm1
-aesdec  176(%r8), %xmm1
-jb  DLAST_4_2
-movdqu    224(%r8), %xmm2
-aesdec  192(%r8), %xmm1
-aesdec  208(%r8), %xmm1
-DLAST_4_2:
-aesdeclast %xmm2, %xmm1
-pxor    %xmm5, %xmm1
-movdqa %xmm15, %xmm5
-movdqu    %xmm1, (%rsi)
-
-addq    $16, %rsi
-decq    %r10
-jne DLOOP_4_2
-DEND_4:
-ret
-
-
-/*
-AES_ECB_encrypt (const unsigned char *in,
-	unsigned char *out,
-	unsigned long length,
-	const unsigned char *KS,
-	int nr)
-*/
-.globl AES_ECB_encrypt
-AES_ECB_encrypt:
-# parameter 1: %rdi
-# parameter 2: %rsi
-# parameter 3: %rdx
-# parameter 4: %rcx
-# parameter 5: %r8d
-        movq    %rdx, %r10
-        shrq    $4, %rdx
-        shlq    $60, %r10
-        je      EECB_NO_PARTS_4
-        addq    $1, %rdx
-EECB_NO_PARTS_4:
-        movq    %rdx, %r10
-        shlq    $62, %r10
-        shrq    $62, %r10
-        shrq    $2, %rdx
-        je      EECB_REMAINDER_4
-        subq    $64, %rsi
-EECB_LOOP_4:
-        movdqu  (%rdi), %xmm1
-        movdqu  16(%rdi), %xmm2
-        movdqu  32(%rdi), %xmm3
-        movdqu  48(%rdi), %xmm4
-        movdqa  (%rcx), %xmm9
-        movdqa  16(%rcx), %xmm10
-        movdqa  32(%rcx), %xmm11
-        movdqa  48(%rcx), %xmm12
-        pxor    %xmm9, %xmm1
-        pxor    %xmm9, %xmm2
-        pxor    %xmm9, %xmm3
-        pxor    %xmm9, %xmm4
-        aesenc  %xmm10, %xmm1
-        aesenc  %xmm10, %xmm2
-        aesenc  %xmm10, %xmm3
-        aesenc  %xmm10, %xmm4
-        aesenc  %xmm11, %xmm1
-        aesenc  %xmm11, %xmm2
-        aesenc  %xmm11, %xmm3
-        aesenc  %xmm11, %xmm4
-        aesenc  %xmm12, %xmm1
-        aesenc  %xmm12, %xmm2
-        aesenc  %xmm12, %xmm3
-        aesenc  %xmm12, %xmm4
-        movdqa  64(%rcx), %xmm9
-        movdqa  80(%rcx), %xmm10
-        movdqa  96(%rcx), %xmm11
-        movdqa  112(%rcx), %xmm12
-        aesenc  %xmm9, %xmm1
-        aesenc  %xmm9, %xmm2
-        aesenc  %xmm9, %xmm3
-        aesenc  %xmm9, %xmm4
-        aesenc  %xmm10, %xmm1
-        aesenc  %xmm10, %xmm2
-        aesenc  %xmm10, %xmm3
-        aesenc  %xmm10, %xmm4
-        aesenc  %xmm11, %xmm1
-        aesenc  %xmm11, %xmm2
-        aesenc  %xmm11, %xmm3
-        aesenc  %xmm11, %xmm4
-        aesenc  %xmm12, %xmm1
-        aesenc  %xmm12, %xmm2
-        aesenc  %xmm12, %xmm3
-        aesenc  %xmm12, %xmm4
-        movdqa  128(%rcx), %xmm9
-        movdqa  144(%rcx), %xmm10
-        movdqa  160(%rcx), %xmm11
-        cmpl    $12, %r8d
-        aesenc  %xmm9, %xmm1
-        aesenc  %xmm9, %xmm2
-        aesenc  %xmm9, %xmm3
-        aesenc  %xmm9, %xmm4
-        aesenc  %xmm10, %xmm1
-        aesenc  %xmm10, %xmm2
-        aesenc  %xmm10, %xmm3
-        aesenc  %xmm10, %xmm4
-        jb      EECB_LAST_4
-        movdqa  160(%rcx), %xmm9
-        movdqa  176(%rcx), %xmm10
-        movdqa  192(%rcx), %xmm11
-        cmpl    $14, %r8d
-        aesenc  %xmm9, %xmm1
-        aesenc  %xmm9, %xmm2
-        aesenc  %xmm9, %xmm3
-        aesenc  %xmm9, %xmm4
-        aesenc  %xmm10, %xmm1
-        aesenc  %xmm10, %xmm2
-        aesenc  %xmm10, %xmm3
-        aesenc  %xmm10, %xmm4
-        jb      EECB_LAST_4
-        movdqa  192(%rcx), %xmm9
-        movdqa  208(%rcx), %xmm10
-        movdqa  224(%rcx), %xmm11
-        aesenc  %xmm9, %xmm1
-        aesenc  %xmm9, %xmm2
-        aesenc  %xmm9, %xmm3
-        aesenc  %xmm9, %xmm4
-        aesenc  %xmm10, %xmm1
-        aesenc  %xmm10, %xmm2
-        aesenc  %xmm10, %xmm3
-        aesenc  %xmm10, %xmm4
-EECB_LAST_4:
-        addq    $64, %rdi
-        addq    $64, %rsi
-        decq    %rdx
-        aesenclast %xmm11, %xmm1
-        aesenclast %xmm11, %xmm2
-        aesenclast %xmm11, %xmm3
-        aesenclast %xmm11, %xmm4
-        movdqu  %xmm1, (%rsi)
-        movdqu  %xmm2, 16(%rsi)
-        movdqu  %xmm3, 32(%rsi)
-        movdqu  %xmm4, 48(%rsi)
-        jne     EECB_LOOP_4
-        addq    $64, %rsi
-EECB_REMAINDER_4:
-        cmpq    $0, %r10
-        je      EECB_END_4
-EECB_LOOP_4_2:
-        movdqu  (%rdi), %xmm1
-        addq    $16, %rdi
-        pxor    (%rcx), %xmm1
-        movdqu  160(%rcx), %xmm2
-        aesenc  16(%rcx), %xmm1
-        aesenc  32(%rcx), %xmm1
-        aesenc  48(%rcx), %xmm1
-        aesenc  64(%rcx), %xmm1
-        aesenc  80(%rcx), %xmm1
-        aesenc  96(%rcx), %xmm1
-        aesenc  112(%rcx), %xmm1
-        aesenc  128(%rcx), %xmm1
-        aesenc  144(%rcx), %xmm1
-        cmpl    $12, %r8d
-        jb      EECB_LAST_4_2
-        movdqu  192(%rcx), %xmm2
-        aesenc  160(%rcx), %xmm1
-        aesenc  176(%rcx), %xmm1
-        cmpl    $14, %r8d
-        jb      EECB_LAST_4_2
-        movdqu  224(%rcx), %xmm2
-        aesenc  192(%rcx), %xmm1
-        aesenc  208(%rcx), %xmm1
-EECB_LAST_4_2:
-        aesenclast %xmm2, %xmm1
-        movdqu  %xmm1, (%rsi)
-        addq    $16, %rsi
-        decq    %r10
-        jne     EECB_LOOP_4_2
-EECB_END_4:
-        ret
-
-
-/*
-AES_ECB_decrypt (const unsigned char *in,
-  unsigned char *out,
-  unsigned long length,
-  const unsigned char *KS,
-  int nr)
-*/
-.globl AES_ECB_decrypt
-AES_ECB_decrypt:
-# parameter 1: %rdi
-# parameter 2: %rsi
-# parameter 3: %rdx
-# parameter 4: %rcx
-# parameter 5: %r8d
-
-        movq    %rdx, %r10
-        shrq    $4, %rdx
-        shlq    $60, %r10
-        je      DECB_NO_PARTS_4
-        addq    $1, %rdx
-DECB_NO_PARTS_4:
-        movq    %rdx, %r10
-        shlq    $62, %r10
-        shrq    $62, %r10
-        shrq    $2, %rdx
-        je      DECB_REMAINDER_4
-        subq    $64, %rsi
-DECB_LOOP_4:
-        movdqu  (%rdi), %xmm1
-        movdqu  16(%rdi), %xmm2
-        movdqu  32(%rdi), %xmm3
-        movdqu  48(%rdi), %xmm4
-        movdqa  (%rcx), %xmm9
-        movdqa  16(%rcx), %xmm10
-        movdqa  32(%rcx), %xmm11
-        movdqa  48(%rcx), %xmm12
-        pxor    %xmm9, %xmm1
-        pxor    %xmm9, %xmm2
-        pxor    %xmm9, %xmm3
-        pxor    %xmm9, %xmm4
-        aesdec  %xmm10, %xmm1
-        aesdec  %xmm10, %xmm2
-        aesdec  %xmm10, %xmm3
-        aesdec  %xmm10, %xmm4
-        aesdec  %xmm11, %xmm1
-        aesdec  %xmm11, %xmm2
-        aesdec  %xmm11, %xmm3
-        aesdec  %xmm11, %xmm4
-        aesdec  %xmm12, %xmm1
-        aesdec  %xmm12, %xmm2
-        aesdec  %xmm12, %xmm3
-        aesdec  %xmm12, %xmm4
-        movdqa  64(%rcx), %xmm9
-        movdqa  80(%rcx), %xmm10
-        movdqa  96(%rcx), %xmm11
-        movdqa  112(%rcx), %xmm12
-        aesdec  %xmm9, %xmm1
-        aesdec  %xmm9, %xmm2
-        aesdec  %xmm9, %xmm3
-        aesdec  %xmm9, %xmm4
-        aesdec  %xmm10, %xmm1
-        aesdec  %xmm10, %xmm2
-        aesdec  %xmm10, %xmm3
-        aesdec  %xmm10, %xmm4
-        aesdec  %xmm11, %xmm1
-        aesdec  %xmm11, %xmm2
-        aesdec  %xmm11, %xmm3
-        aesdec  %xmm11, %xmm4
-        aesdec  %xmm12, %xmm1
-        aesdec  %xmm12, %xmm2
-        aesdec  %xmm12, %xmm3
-        aesdec  %xmm12, %xmm4
-        movdqa  128(%rcx), %xmm9
-        movdqa  144(%rcx), %xmm10
-        movdqa  160(%rcx), %xmm11
-        cmpl    $12, %r8d
-        aesdec  %xmm9, %xmm1
-        aesdec  %xmm9, %xmm2
-        aesdec  %xmm9, %xmm3
-        aesdec  %xmm9, %xmm4
-        aesdec  %xmm10, %xmm1
-        aesdec  %xmm10, %xmm2
-        aesdec  %xmm10, %xmm3
-        aesdec  %xmm10, %xmm4
-        jb      DECB_LAST_4
-        movdqa  160(%rcx), %xmm9
-        movdqa  176(%rcx), %xmm10
-        movdqa  192(%rcx), %xmm11
-        cmpl    $14, %r8d
-        aesdec  %xmm9, %xmm1
-        aesdec  %xmm9, %xmm2
-        aesdec  %xmm9, %xmm3
-        aesdec  %xmm9, %xmm4
-        aesdec  %xmm10, %xmm1
-        aesdec  %xmm10, %xmm2
-        aesdec  %xmm10, %xmm3
-        aesdec  %xmm10, %xmm4
-        jb      DECB_LAST_4
-        movdqa  192(%rcx), %xmm9
-        movdqa  208(%rcx), %xmm10
-        movdqa  224(%rcx), %xmm11
-        aesdec  %xmm9, %xmm1
-        aesdec  %xmm9, %xmm2
-        aesdec  %xmm9, %xmm3
-        aesdec  %xmm9, %xmm4
-        aesdec  %xmm10, %xmm1
-        aesdec  %xmm10, %xmm2
-        aesdec  %xmm10, %xmm3
-        aesdec  %xmm10, %xmm4
-DECB_LAST_4:
-        addq    $64, %rdi
-        addq    $64, %rsi
-        decq    %rdx
-        aesdeclast %xmm11, %xmm1
-        aesdeclast %xmm11, %xmm2
-        aesdeclast %xmm11, %xmm3
-        aesdeclast %xmm11, %xmm4
-        movdqu  %xmm1, (%rsi)
-        movdqu  %xmm2, 16(%rsi)
-        movdqu  %xmm3, 32(%rsi)
-        movdqu  %xmm4, 48(%rsi)
-        jne     DECB_LOOP_4
-        addq    $64, %rsi
-DECB_REMAINDER_4:
-        cmpq    $0, %r10
-        je      DECB_END_4
-DECB_LOOP_4_2:
-        movdqu  (%rdi), %xmm1
-        addq    $16, %rdi
-        pxor    (%rcx), %xmm1
-        movdqu  160(%rcx), %xmm2
-        cmpl    $12, %r8d
-        aesdec  16(%rcx), %xmm1
-        aesdec  32(%rcx), %xmm1
-        aesdec  48(%rcx), %xmm1
-        aesdec  64(%rcx), %xmm1
-        aesdec  80(%rcx), %xmm1
-        aesdec  96(%rcx), %xmm1
-        aesdec  112(%rcx), %xmm1
-        aesdec  128(%rcx), %xmm1
-        aesdec  144(%rcx), %xmm1
-        jb      DECB_LAST_4_2
-        cmpl    $14, %r8d
-        movdqu  192(%rcx), %xmm2
-        aesdec  160(%rcx), %xmm1
-        aesdec  176(%rcx), %xmm1
-        jb      DECB_LAST_4_2
-        movdqu  224(%rcx), %xmm2
-        aesdec  192(%rcx), %xmm1
-        aesdec  208(%rcx), %xmm1
-DECB_LAST_4_2:
-        aesdeclast %xmm2, %xmm1
-        movdqu  %xmm1, (%rsi)
-        addq    $16, %rsi
-        decq    %r10
-        jne     DECB_LOOP_4_2
-DECB_END_4:
-        ret
-
-
-
-
-/*
-void AES_128_Key_Expansion(const unsigned char* userkey,
-   unsigned char* key_schedule);
-*/
-.align  16,0x90
-.globl AES_128_Key_Expansion
-AES_128_Key_Expansion:
-# parameter 1: %rdi
-# parameter 2: %rsi
-movl    $10, 240(%rsi)
-
-movdqu  (%rdi), %xmm1
-movdqa    %xmm1, (%rsi)
-
-
-ASSISTS:
-aeskeygenassist $1, %xmm1, %xmm2
-call PREPARE_ROUNDKEY_128
-movdqa %xmm1, 16(%rsi)
-aeskeygenassist $2, %xmm1, %xmm2
-call PREPARE_ROUNDKEY_128
-movdqa %xmm1, 32(%rsi)
-aeskeygenassist $4, %xmm1, %xmm2
-call PREPARE_ROUNDKEY_128
-movdqa %xmm1, 48(%rsi)
-aeskeygenassist $8, %xmm1, %xmm2
-call PREPARE_ROUNDKEY_128
-movdqa %xmm1, 64(%rsi)
-aeskeygenassist $16, %xmm1, %xmm2
-call PREPARE_ROUNDKEY_128
-movdqa %xmm1, 80(%rsi)
-aeskeygenassist $32, %xmm1, %xmm2
-call PREPARE_ROUNDKEY_128
-movdqa %xmm1, 96(%rsi)
-aeskeygenassist $64, %xmm1, %xmm2
-call PREPARE_ROUNDKEY_128
-movdqa %xmm1, 112(%rsi)
-aeskeygenassist $0x80, %xmm1, %xmm2
-call PREPARE_ROUNDKEY_128
-movdqa %xmm1, 128(%rsi)
-aeskeygenassist $0x1b, %xmm1, %xmm2
-call PREPARE_ROUNDKEY_128
-movdqa %xmm1, 144(%rsi)
-aeskeygenassist $0x36, %xmm1, %xmm2
-call PREPARE_ROUNDKEY_128
-movdqa %xmm1, 160(%rsi)
-ret
-
-PREPARE_ROUNDKEY_128:
-pshufd $255, %xmm2, %xmm2
-movdqa %xmm1, %xmm3
-pslldq $4, %xmm3
-pxor %xmm3, %xmm1
-pslldq $4, %xmm3
-pxor %xmm3, %xmm1
-pslldq $4, %xmm3
-pxor %xmm3, %xmm1
-pxor %xmm2, %xmm1
-ret
-
-
-/*
-void AES_192_Key_Expansion (const unsigned char *userkey,
-  unsigned char *key)
-*/
-.globl AES_192_Key_Expansion
-AES_192_Key_Expansion:
-# parameter 1: %rdi
-# parameter 2: %rsi
-
-movdqu (%rdi), %xmm1
-movdqu 16(%rdi), %xmm3
-movdqa %xmm1, (%rsi)
-movdqa %xmm3, %xmm5
-
-aeskeygenassist $0x1, %xmm3, %xmm2
-call PREPARE_ROUNDKEY_192
-shufpd $0, %xmm1, %xmm5
-movdqa %xmm5, 16(%rsi)
-movdqa %xmm1, %xmm6
-shufpd $1, %xmm3, %xmm6
-movdqa %xmm6, 32(%rsi)
-
-aeskeygenassist $0x2, %xmm3, %xmm2
-call PREPARE_ROUNDKEY_192
-movdqa %xmm1, 48(%rsi)
-movdqa %xmm3, %xmm5
-
-aeskeygenassist $0x4, %xmm3, %xmm2
-call PREPARE_ROUNDKEY_192
-shufpd $0, %xmm1, %xmm5
-movdqa %xmm5, 64(%rsi)
-movdqa %xmm1, %xmm6
-shufpd $1, %xmm3, %xmm6
-movdqa %xmm6, 80(%rsi)
-
-aeskeygenassist $0x8, %xmm3, %xmm2
-call PREPARE_ROUNDKEY_192
-movdqa %xmm1, 96(%rsi)
-movdqa %xmm3, %xmm5
-
-aeskeygenassist $0x10, %xmm3, %xmm2
-call PREPARE_ROUNDKEY_192
-shufpd $0, %xmm1, %xmm5
-movdqa %xmm5, 112(%rsi)
-movdqa %xmm1, %xmm6
-shufpd $1, %xmm3, %xmm6
-movdqa %xmm6, 128(%rsi)
-
-aeskeygenassist $0x20, %xmm3, %xmm2
-call PREPARE_ROUNDKEY_192
-movdqa %xmm1, 144(%rsi)
-movdqa %xmm3, %xmm5
-
-aeskeygenassist $0x40, %xmm3, %xmm2
-call PREPARE_ROUNDKEY_192
-shufpd $0, %xmm1, %xmm5
-movdqa %xmm5, 160(%rsi)
-movdqa %xmm1, %xmm6
-shufpd $1, %xmm3, %xmm6
-movdqa %xmm6, 176(%rsi)
-
-aeskeygenassist $0x80, %xmm3, %xmm2
-call PREPARE_ROUNDKEY_192
-movdqa %xmm1, 192(%rsi)
-movdqa %xmm3, 208(%rsi)
-ret
-
-PREPARE_ROUNDKEY_192:
-pshufd $0x55, %xmm2, %xmm2
-movdqu %xmm1, %xmm4
-pslldq $4, %xmm4
-pxor   %xmm4, %xmm1
-
-pslldq $4, %xmm4
-pxor   %xmm4, %xmm1
-pslldq $4, %xmm4
-pxor  %xmm4, %xmm1
-pxor   %xmm2, %xmm1
-pshufd $0xff, %xmm1, %xmm2
-movdqu %xmm3, %xmm4
-pslldq $4, %xmm4
-pxor   %xmm4, %xmm3
-pxor   %xmm2, %xmm3
-ret
- 
-
-/*
-void AES_256_Key_Expansion (const unsigned char *userkey,
-  unsigned char *key)
-*/
-.globl AES_256_Key_Expansion
-AES_256_Key_Expansion:
-# parameter 1: %rdi
-# parameter 2: %rsi
-
-movdqu (%rdi), %xmm1
-movdqu 16(%rdi), %xmm3
-movdqa %xmm1, (%rsi)
-movdqa %xmm3, 16(%rsi)
-
-aeskeygenassist $0x1, %xmm3, %xmm2
-call MAKE_RK256_a
-movdqa %xmm1, 32(%rsi)
-aeskeygenassist $0x0, %xmm1, %xmm2
-call MAKE_RK256_b
-movdqa %xmm3, 48(%rsi)
-aeskeygenassist $0x2, %xmm3, %xmm2
-call MAKE_RK256_a
-movdqa %xmm1, 64(%rsi)
-aeskeygenassist $0x0, %xmm1, %xmm2
-call MAKE_RK256_b
-movdqa %xmm3, 80(%rsi)
-aeskeygenassist $0x4, %xmm3, %xmm2
-call MAKE_RK256_a
-movdqa %xmm1, 96(%rsi)
-aeskeygenassist $0x0, %xmm1, %xmm2
-call MAKE_RK256_b
-movdqa %xmm3, 112(%rsi)
-aeskeygenassist $0x8, %xmm3, %xmm2
-call MAKE_RK256_a
-movdqa %xmm1, 128(%rsi)
-aeskeygenassist $0x0, %xmm1, %xmm2
-call MAKE_RK256_b
-movdqa %xmm3, 144(%rsi)
-aeskeygenassist $0x10, %xmm3, %xmm2
-call MAKE_RK256_a
-movdqa %xmm1, 160(%rsi)
-aeskeygenassist $0x0, %xmm1, %xmm2
-call MAKE_RK256_b
-movdqa %xmm3, 176(%rsi)
-aeskeygenassist $0x20, %xmm3, %xmm2
-call MAKE_RK256_a
-movdqa %xmm1, 192(%rsi)
-
-aeskeygenassist $0x0, %xmm1, %xmm2
-call MAKE_RK256_b
-movdqa %xmm3, 208(%rsi)
-aeskeygenassist $0x40, %xmm3, %xmm2
-call MAKE_RK256_a
-movdqa %xmm1, 224(%rsi)
-
-ret
-
-MAKE_RK256_a:
-pshufd $0xff, %xmm2, %xmm2
-movdqa %xmm1, %xmm4
-pslldq $4, %xmm4
-pxor   %xmm4, %xmm1
-pslldq $4, %xmm4
-pxor  %xmm4, %xmm1
-pslldq $4, %xmm4
-pxor  %xmm4, %xmm1
-pxor   %xmm2, %xmm1
-ret
-
-MAKE_RK256_b:
-pshufd $0xaa, %xmm2, %xmm2
-movdqa %xmm3, %xmm4
-pslldq $4, %xmm4
-pxor   %xmm4, %xmm3
-pslldq $4, %xmm4
-pxor  %xmm4, %xmm3
-pslldq $4, %xmm4
-pxor  %xmm4, %xmm3
-pxor   %xmm2, %xmm3
-ret
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/arc4.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/arc4.c
deleted file mode 100755
index 21ed2e7..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/arc4.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/* arc4.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef NO_RC4
-
-#include 
-
-#ifdef HAVE_CAVIUM
-    static void wc_Arc4CaviumSetKey(Arc4* arc4, const byte* key, word32 length);
-    static void wc_Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,
-                                  word32 length);
-#endif
-
-
-void wc_Arc4SetKey(Arc4* arc4, const byte* key, word32 length)
-{
-    word32 i;
-    word32 keyIndex = 0, stateIndex = 0;
-
-#ifdef HAVE_CAVIUM
-    if (arc4->magic == WOLFSSL_ARC4_CAVIUM_MAGIC)
-        return wc_Arc4CaviumSetKey(arc4, key, length);
-#endif
-
-    arc4->x = 1;
-    arc4->y = 0;
-
-    for (i = 0; i < ARC4_STATE_SIZE; i++)
-        arc4->state[i] = (byte)i;
-
-    for (i = 0; i < ARC4_STATE_SIZE; i++) {
-        word32 a = arc4->state[i];
-        stateIndex += key[keyIndex] + a;
-        stateIndex &= 0xFF;
-        arc4->state[i] = arc4->state[stateIndex];
-        arc4->state[stateIndex] = (byte)a;
-
-        if (++keyIndex >= length)
-            keyIndex = 0;
-    }
-}
-
-
-static INLINE byte MakeByte(word32* x, word32* y, byte* s)
-{
-    word32 a = s[*x], b;
-    *y = (*y+a) & 0xff;
-
-    b = s[*y];
-    s[*x] = (byte)b;
-    s[*y] = (byte)a;
-    *x = (*x+1) & 0xff;
-
-    return s[(a+b) & 0xff];
-}
-
-
-void wc_Arc4Process(Arc4* arc4, byte* out, const byte* in, word32 length)
-{
-    word32 x;
-    word32 y;
-
-#ifdef HAVE_CAVIUM
-    if (arc4->magic == WOLFSSL_ARC4_CAVIUM_MAGIC)
-        return wc_Arc4CaviumProcess(arc4, out, in, length);
-#endif
-
-    x = arc4->x;
-    y = arc4->y;
-
-    while(length--)
-        *out++ = *in++ ^ MakeByte(&x, &y, arc4->state);
-
-    arc4->x = (byte)x;
-    arc4->y = (byte)y;
-}
-
-
-#ifdef HAVE_CAVIUM
-
-#include 
-#include "cavium_common.h"
-
-/* Initiliaze Arc4 for use with Nitrox device */
-int wc_Arc4InitCavium(Arc4* arc4, int devId)
-{
-    if (arc4 == NULL)
-        return -1;
-
-    if (CspAllocContext(CONTEXT_SSL, &arc4->contextHandle, devId) != 0)
-        return -1;
-
-    arc4->devId = devId;
-    arc4->magic = WOLFSSL_ARC4_CAVIUM_MAGIC;
-
-    return 0;
-}
-
-
-/* Free Arc4 from use with Nitrox device */
-void wc_Arc4FreeCavium(Arc4* arc4)
-{
-    if (arc4 == NULL)
-        return;
-
-    if (arc4->magic != WOLFSSL_ARC4_CAVIUM_MAGIC)
-        return;
-
-    CspFreeContext(CONTEXT_SSL, arc4->contextHandle, arc4->devId);
-    arc4->magic = 0;
-}
-
-
-static void wc_Arc4CaviumSetKey(Arc4* arc4, const byte* key, word32 length)
-{
-    word32 requestId;
-
-    if (CspInitializeRc4(CAVIUM_BLOCKING, arc4->contextHandle, length,
-                         (byte*)key, &requestId, arc4->devId) != 0) {
-        WOLFSSL_MSG("Bad Cavium Arc4 Init");
-    }
-}
-
-
-static void wc_Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,
-                              word32 length)
-{
-    wolfssl_word offset = 0;
-    word32 requestId;
-
-    while (length > WOLFSSL_MAX_16BIT) {
-        word16 slen = (word16)WOLFSSL_MAX_16BIT;
-        if (CspEncryptRc4(CAVIUM_BLOCKING, arc4->contextHandle,CAVIUM_UPDATE,
-                          slen, (byte*)in + offset, out + offset, &requestId,
-                          arc4->devId) != 0) {
-            WOLFSSL_MSG("Bad Cavium Arc4 Encrypt");
-        }
-        length -= WOLFSSL_MAX_16BIT;
-        offset += WOLFSSL_MAX_16BIT;
-    }
-    if (length) {
-        word16 slen = (word16)length;
-        if (CspEncryptRc4(CAVIUM_BLOCKING, arc4->contextHandle,CAVIUM_UPDATE,
-                          slen, (byte*)in + offset, out + offset, &requestId,
-                          arc4->devId) != 0) {
-            WOLFSSL_MSG("Bad Cavium Arc4 Encrypt");
-        }
-    }
-}
-
-#endif /* HAVE_CAVIUM */
-
-#endif /* NO_RC4 */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/asm.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/asm.c
deleted file mode 100755
index 9f84585..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/asm.c
+++ /dev/null
@@ -1,1618 +0,0 @@
-/* asm.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-/*
- * Based on public domain TomsFastMath 0.10 by Tom St Denis, tomstdenis@iahu.ca,
- * http://math.libtomcrypt.com
- */
-
-
-/******************************************************************/
-/* fp_montgomery_reduce.c asm or generic */
-
-
-/* Each platform needs to query info type 1 from cpuid to see if aesni is
- * supported. Also, let's setup a macro for proper linkage w/o ABI conflicts
- */
-
-#if defined(HAVE_INTEL_MULX)
-#ifndef _MSC_VER
-    #define cpuid(reg, leaf, sub)\
-            __asm__ __volatile__ ("cpuid":\
-             "=a" (reg[0]), "=b" (reg[1]), "=c" (reg[2]), "=d" (reg[3]) :\
-             "a" (leaf), "c"(sub));
-
-    #define XASM_LINK(f) asm(f)
-#else
-
-    #include 
-    #define cpuid(a,b) __cpuid((int*)a,b)
-
-    #define XASM_LINK(f)
-
-#endif /* _MSC_VER */
-
-#define EAX 0
-#define EBX 1
-#define ECX 2 
-#define EDX 3
-    
-#define CPUID_AVX1   0x1
-#define CPUID_AVX2   0x2
-#define CPUID_RDRAND 0x4
-#define CPUID_RDSEED 0x8
-#define CPUID_BMI2   0x10   /* MULX, RORX */
-#define CPUID_ADX    0x20   /* ADCX, ADOX */
-
-#define IS_INTEL_AVX1       (cpuid_flags&CPUID_AVX1)
-#define IS_INTEL_AVX2       (cpuid_flags&CPUID_AVX2)
-#define IS_INTEL_BMI2       (cpuid_flags&CPUID_BMI2)
-#define IS_INTEL_ADX        (cpuid_flags&CPUID_ADX)
-#define IS_INTEL_RDRAND     (cpuid_flags&CPUID_RDRAND)
-#define IS_INTEL_RDSEED     (cpuid_flags&CPUID_RDSEED)
-#define SET_FLAGS         
-
-static word32 cpuid_check = 0 ;
-static word32 cpuid_flags = 0 ;
-
-static word32 cpuid_flag(word32 leaf, word32 sub, word32 num, word32 bit) {
-    int got_intel_cpu=0;
-    unsigned int reg[5]; 
-    
-    reg[4] = '\0' ;
-    cpuid(reg, 0, 0);  
-    if(memcmp((char *)&(reg[EBX]), "Genu", 4) == 0 &&  
-                memcmp((char *)&(reg[EDX]), "ineI", 4) == 0 &&  
-                memcmp((char *)&(reg[ECX]), "ntel", 4) == 0) {  
-        got_intel_cpu = 1;  
-    }    
-    if (got_intel_cpu) {
-        cpuid(reg, leaf, sub);
-        return((reg[num]>>bit)&0x1) ;
-    }
-    return 0 ;
-}
-
-INLINE static int set_cpuid_flags(void) {  
-    if(cpuid_check == 0) {
-        if(cpuid_flag(7, 0, EBX, 8)){  cpuid_flags |= CPUID_BMI2 ; }
-        if(cpuid_flag(7, 0, EBX,19)){  cpuid_flags |= CPUID_ADX  ; }
-		cpuid_check = 1 ;
-		return 0 ;
-    }
-    return 1 ;
-}
-
-#define RETURN return
-#define IF_HAVE_INTEL_MULX(func, ret)    \
-   if(cpuid_check==0)set_cpuid_flags() ; \
-   if(IS_INTEL_BMI2 && IS_INTEL_ADX){  func;  ret ;  }
-
-#else
-    #define IF_HAVE_INTEL_MULX(func, ret)
-#endif
-
-#if defined(TFM_X86) && !defined(TFM_SSE2) 
-/* x86-32 code */
-
-#define MONT_START 
-#define MONT_FINI
-#define LOOP_END
-#define LOOP_START \
-   mu = c[x] * mp
-
-#define INNERMUL                                          \
-__asm__(                                                      \
-   "movl %5,%%eax \n\t"                                   \
-   "mull %4       \n\t"                                   \
-   "addl %1,%%eax \n\t"                                   \
-   "adcl $0,%%edx \n\t"                                   \
-   "addl %%eax,%0 \n\t"                                   \
-   "adcl $0,%%edx \n\t"                                   \
-   "movl %%edx,%1 \n\t"                                   \
-:"=g"(_c[LO]), "=r"(cy)                                   \
-:"0"(_c[LO]), "1"(cy), "g"(mu), "g"(*tmpm++)              \
-: "%eax", "%edx", "cc")
-
-#define PROPCARRY                           \
-__asm__(                                        \
-   "addl   %1,%0    \n\t"                   \
-   "setb   %%al     \n\t"                   \
-   "movzbl %%al,%1 \n\t"                    \
-:"=g"(_c[LO]), "=r"(cy)                     \
-:"0"(_c[LO]), "1"(cy)                       \
-: "%eax", "cc")
-
-/******************************************************************/
-#elif defined(TFM_X86_64)
-/* x86-64 code */
-
-#define MONT_START 
-#define MONT_FINI
-#define LOOP_END
-#define LOOP_START \
-   mu = c[x] * mp;
-
-#define INNERMUL                                          \
-__asm__(                                                      \
-   "movq %5,%%rax \n\t"                                   \
-   "mulq %4       \n\t"                                   \
-   "addq %1,%%rax \n\t"                                   \
-   "adcq $0,%%rdx \n\t"                                   \
-   "addq %%rax,%0 \n\t"                                   \
-   "adcq $0,%%rdx \n\t"                                   \
-   "movq %%rdx,%1 \n\t"                                   \
-:"=g"(_c[LO]), "=r"(cy)                                   \
-:"0"(_c[LO]), "1"(cy), "r"(mu), "r"(*tmpm++)              \
-: "%rax", "%rdx", "cc")
-
-#if defined(HAVE_INTEL_MULX)
-#define MULX_INIT(a0, c0, cy)\
-    __asm__ volatile(                                     \
-             "xorq  %%r10, %%r10\n\t"                     \
-             "movq  %1,%%rdx\n\t"                         \
-             "addq  %2, %0\n\t"       /* c0+=cy; Set CF, OF */ \
-             "adoxq %%r10, %%r10\n\t" /* Reset   OF */    \
-             :"+m"(c0):"r"(a0),"r"(cy):"%r8","%r9", "%r10","%r11","%r12","%rdx") ; \
-
-#define MULX_INNERMUL_R1(c0, c1, pre, rdx)\
-   {                                                      \
-    __asm__  volatile (                                   \
-         "movq  %3, %%rdx\n\t"                            \
-         "mulx  %%r11,%%r9, %%r8 \n\t"                    \
-         "movq  %2, %%r12\n\t"                            \
-         "adoxq  %%r9,%0     \n\t"                        \
-         "adcxq  %%r8,%1     \n\t"                        \
-         :"+r"(c0),"+r"(c1):"m"(pre),"r"(rdx):"%r8","%r9", "%r10", "%r11","%r12","%rdx"    \
-    ); }
-    
-
-#define MULX_INNERMUL_R2(c0, c1, pre, rdx)\
-   {                                                      \
-    __asm__  volatile (                                   \
-         "movq  %3, %%rdx\n\t"                            \
-         "mulx  %%r12,%%r9, %%r8 \n\t"                    \
-         "movq  %2, %%r11\n\t"                            \
-         "adoxq  %%r9,%0     \n\t"                        \
-         "adcxq  %%r8,%1     \n\t"                        \
-         :"+r"(c0),"+r"(c1):"m"(pre),"r"(rdx):"%r8","%r9", "%r10", "%r11","%r12","%rdx"    \
-    ); }
-
-#define MULX_LOAD_R1(val)\
-    __asm__  volatile (                                   \
-        "movq %0, %%r11\n\t"\
-        ::"m"(val):"%r8","%r9", "%r10", "%r11","%r12","%rdx"\
-) ;
-
-#define MULX_INNERMUL_LAST(c0, c1, rdx)\
-   {                                                      \
-    __asm__  volatile (                                   \
-         "movq   %2, %%rdx\n\t"                           \
-         "mulx   %%r12,%%r9, %%r8 \n\t"                   \
-         "movq   $0, %%r10      \n\t"                     \
-         "adoxq  %%r10, %%r9   \n\t"                      \
-         "adcq   $0,%%r8       \n\t"                      \
-         "addq   %%r9,%0       \n\t"                      \
-         "adcq   $0,%%r8       \n\t"                      \
-         "movq   %%r8,%1       \n\t"                      \
-         :"+m"(c0),"=m"(c1):"r"(rdx):"%r8","%r9","%r10", "%r11", "%r12","%rdx"\
-    ); }
-
-#define MULX_INNERMUL8(x,y,z,cy)\
-{       word64 rdx = y ;\
-        MULX_LOAD_R1(x[0]) ;\
-        MULX_INIT(y, _c0, cy) ; /* rdx=y; z0+=cy; */ \
-        MULX_INNERMUL_R1(_c0, _c1, x[1], rdx) ;\
-        MULX_INNERMUL_R2(_c1, _c2, x[2], rdx) ;\
-        MULX_INNERMUL_R1(_c2, _c3, x[3], rdx) ;\
-        MULX_INNERMUL_R2(_c3, _c4, x[4], rdx) ;\
-        MULX_INNERMUL_R1(_c4, _c5, x[5], rdx) ;\
-        MULX_INNERMUL_R2(_c5, _c6, x[6], rdx) ;\
-        MULX_INNERMUL_R1(_c6, _c7, x[7], rdx) ;\
-        MULX_INNERMUL_LAST(_c7, cy, rdx) ;\
-}
-#define INNERMUL8_MULX \
-{\
-    MULX_INNERMUL8(tmpm, mu, _c, cy);\
-}
-#endif
-
-#define INNERMUL8 \
- __asm__(                  \
- "movq 0(%5),%%rax    \n\t"  \
- "movq 0(%2),%%r10    \n\t"  \
- "movq 0x8(%5),%%r11  \n\t"  \
- "mulq %4             \n\t"  \
- "addq %%r10,%%rax    \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq 0x8(%2),%%r10  \n\t"  \
- "addq %3,%%rax       \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq %%rax,0(%0)    \n\t"  \
- "movq %%rdx,%1       \n\t"  \
- \
- "movq %%r11,%%rax    \n\t"  \
- "movq 0x10(%5),%%r11 \n\t"  \
- "mulq %4             \n\t"  \
- "addq %%r10,%%rax    \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq 0x10(%2),%%r10 \n\t"  \
- "addq %3,%%rax       \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq %%rax,0x8(%0)  \n\t"  \
- "movq %%rdx,%1       \n\t"  \
- \
- "movq %%r11,%%rax    \n\t"  \
- "movq 0x18(%5),%%r11 \n\t"  \
- "mulq %4             \n\t"  \
- "addq %%r10,%%rax    \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq 0x18(%2),%%r10 \n\t"  \
- "addq %3,%%rax       \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq %%rax,0x10(%0) \n\t"  \
- "movq %%rdx,%1       \n\t"  \
- \
- "movq %%r11,%%rax    \n\t"  \
- "movq 0x20(%5),%%r11 \n\t"  \
- "mulq %4             \n\t"  \
- "addq %%r10,%%rax    \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq 0x20(%2),%%r10 \n\t"  \
- "addq %3,%%rax       \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq %%rax,0x18(%0) \n\t"  \
- "movq %%rdx,%1       \n\t"  \
- \
- "movq %%r11,%%rax    \n\t"  \
- "movq 0x28(%5),%%r11 \n\t"  \
- "mulq %4             \n\t"  \
- "addq %%r10,%%rax    \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq 0x28(%2),%%r10 \n\t"  \
- "addq %3,%%rax       \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq %%rax,0x20(%0) \n\t"  \
- "movq %%rdx,%1       \n\t"  \
- \
- "movq %%r11,%%rax    \n\t"  \
- "movq 0x30(%5),%%r11 \n\t"  \
- "mulq %4             \n\t"  \
- "addq %%r10,%%rax    \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq 0x30(%2),%%r10 \n\t"  \
- "addq %3,%%rax       \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq %%rax,0x28(%0) \n\t"  \
- "movq %%rdx,%1       \n\t"  \
- \
- "movq %%r11,%%rax    \n\t"  \
- "movq 0x38(%5),%%r11 \n\t"  \
- "mulq %4             \n\t"  \
- "addq %%r10,%%rax    \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq 0x38(%2),%%r10 \n\t"  \
- "addq %3,%%rax       \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq %%rax,0x30(%0) \n\t"  \
- "movq %%rdx,%1       \n\t"  \
- \
- "movq %%r11,%%rax    \n\t"  \
- "mulq %4             \n\t"  \
- "addq %%r10,%%rax    \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "addq %3,%%rax       \n\t"  \
- "adcq $0,%%rdx       \n\t"  \
- "movq %%rax,0x38(%0) \n\t"  \
- "movq %%rdx,%1       \n\t"  \
- \
-:"=r"(_c), "=r"(cy)                    \
-: "0"(_c),  "1"(cy), "g"(mu), "r"(tmpm)\
-: "%rax", "%rdx", "%r10", "%r11", "cc")\
-
-#define PROPCARRY                           \
-__asm__(                                        \
-   "addq   %1,%0    \n\t"                   \
-   "setb   %%al     \n\t"                   \
-   "movzbq %%al,%1 \n\t"                    \
-:"=g"(_c[LO]), "=r"(cy)                     \
-:"0"(_c[LO]), "1"(cy)                       \
-: "%rax", "cc")
-
-/******************************************************************/
-#elif defined(TFM_SSE2)  
-/* SSE2 code (assumes 32-bit fp_digits) */
-/* XMM register assignments:
- * xmm0  *tmpm++, then Mu * (*tmpm++)
- * xmm1  c[x], then Mu
- * xmm2  mp
- * xmm3  cy
- * xmm4  _c[LO]
- */
-
-#define MONT_START \
-   __asm__("movd %0,%%mm2"::"g"(mp))
-
-#define MONT_FINI \
-   __asm__("emms")
-
-#define LOOP_START          \
-__asm__(                        \
-"movd %0,%%mm1        \n\t" \
-"pxor %%mm3,%%mm3     \n\t" \
-"pmuludq %%mm2,%%mm1  \n\t" \
-:: "g"(c[x]))
-
-/* pmuludq on mmx registers does a 32x32->64 multiply. */
-#define INNERMUL               \
-__asm__(                           \
-   "movd %1,%%mm4        \n\t" \
-   "movd %2,%%mm0        \n\t" \
-   "paddq %%mm4,%%mm3    \n\t" \
-   "pmuludq %%mm1,%%mm0  \n\t" \
-   "paddq %%mm0,%%mm3    \n\t" \
-   "movd %%mm3,%0        \n\t" \
-   "psrlq $32, %%mm3     \n\t" \
-:"=g"(_c[LO]) : "0"(_c[LO]), "g"(*tmpm++) );
-
-#define INNERMUL8 \
-__asm__(                           \
-   "movd 0(%1),%%mm4     \n\t" \
-   "movd 0(%2),%%mm0     \n\t" \
-   "paddq %%mm4,%%mm3    \n\t" \
-   "pmuludq %%mm1,%%mm0  \n\t" \
-   "movd 4(%2),%%mm5     \n\t" \
-   "paddq %%mm0,%%mm3    \n\t" \
-   "movd 4(%1),%%mm6     \n\t" \
-   "movd %%mm3,0(%0)     \n\t" \
-   "psrlq $32, %%mm3     \n\t" \
-\
-   "paddq %%mm6,%%mm3    \n\t" \
-   "pmuludq %%mm1,%%mm5  \n\t" \
-   "movd 8(%2),%%mm6     \n\t" \
-   "paddq %%mm5,%%mm3    \n\t" \
-   "movd 8(%1),%%mm7     \n\t" \
-   "movd %%mm3,4(%0)     \n\t" \
-   "psrlq $32, %%mm3     \n\t" \
-\
-   "paddq %%mm7,%%mm3    \n\t" \
-   "pmuludq %%mm1,%%mm6  \n\t" \
-   "movd 12(%2),%%mm7    \n\t" \
-   "paddq %%mm6,%%mm3    \n\t" \
-   "movd 12(%1),%%mm5     \n\t" \
-   "movd %%mm3,8(%0)     \n\t" \
-   "psrlq $32, %%mm3     \n\t" \
-\
-   "paddq %%mm5,%%mm3    \n\t" \
-   "pmuludq %%mm1,%%mm7  \n\t" \
-   "movd 16(%2),%%mm5    \n\t" \
-   "paddq %%mm7,%%mm3    \n\t" \
-   "movd 16(%1),%%mm6    \n\t" \
-   "movd %%mm3,12(%0)    \n\t" \
-   "psrlq $32, %%mm3     \n\t" \
-\
-   "paddq %%mm6,%%mm3    \n\t" \
-   "pmuludq %%mm1,%%mm5  \n\t" \
-   "movd 20(%2),%%mm6    \n\t" \
-   "paddq %%mm5,%%mm3    \n\t" \
-   "movd 20(%1),%%mm7    \n\t" \
-   "movd %%mm3,16(%0)    \n\t" \
-   "psrlq $32, %%mm3     \n\t" \
-\
-   "paddq %%mm7,%%mm3    \n\t" \
-   "pmuludq %%mm1,%%mm6  \n\t" \
-   "movd 24(%2),%%mm7    \n\t" \
-   "paddq %%mm6,%%mm3    \n\t" \
-   "movd 24(%1),%%mm5     \n\t" \
-   "movd %%mm3,20(%0)    \n\t" \
-   "psrlq $32, %%mm3     \n\t" \
-\
-   "paddq %%mm5,%%mm3    \n\t" \
-   "pmuludq %%mm1,%%mm7  \n\t" \
-   "movd 28(%2),%%mm5    \n\t" \
-   "paddq %%mm7,%%mm3    \n\t" \
-   "movd 28(%1),%%mm6    \n\t" \
-   "movd %%mm3,24(%0)    \n\t" \
-   "psrlq $32, %%mm3     \n\t" \
-\
-   "paddq %%mm6,%%mm3    \n\t" \
-   "pmuludq %%mm1,%%mm5  \n\t" \
-   "paddq %%mm5,%%mm3    \n\t" \
-   "movd %%mm3,28(%0)    \n\t" \
-   "psrlq $32, %%mm3     \n\t" \
-:"=r"(_c) : "0"(_c), "r"(tmpm) );
-
-/* TAO switched tmpm from "g" to "r" after gcc tried to index the indexed stack
-   pointer */
-
-#define LOOP_END \
-__asm__( "movd %%mm3,%0  \n" :"=r"(cy))
-
-#define PROPCARRY                           \
-__asm__(                                        \
-   "addl   %1,%0    \n\t"                   \
-   "setb   %%al     \n\t"                   \
-   "movzbl %%al,%1 \n\t"                    \
-:"=g"(_c[LO]), "=r"(cy)                     \
-:"0"(_c[LO]), "1"(cy)                       \
-: "%eax", "cc")
-
-/******************************************************************/
-#elif defined(TFM_ARM)
-   /* ARMv4 code */
-
-#define MONT_START 
-#define MONT_FINI
-#define LOOP_END
-#define LOOP_START \
-   mu = c[x] * mp
-
-
-#ifdef __thumb__
-
-#define INNERMUL                    \
-__asm__(                                \
-    " LDR    r0,%1            \n\t" \
-    " ADDS   r0,r0,%0         \n\t" \
-    " ITE    CS               \n\t" \
-    " MOVCS  %0,#1            \n\t" \
-    " MOVCC  %0,#0            \n\t" \
-    " UMLAL  r0,%0,%3,%4      \n\t" \
-    " STR    r0,%1            \n\t" \
-:"=r"(cy),"=m"(_c[0]):"0"(cy),"r"(mu),"r"(*tmpm++),"m"(_c[0]):"r0","cc");
-
-#define PROPCARRY                  \
-__asm__(                               \
-    " LDR   r0,%1            \n\t" \
-    " ADDS  r0,r0,%0         \n\t" \
-    " STR   r0,%1            \n\t" \
-    " ITE   CS               \n\t" \
-    " MOVCS %0,#1            \n\t" \
-    " MOVCC %0,#0            \n\t" \
-:"=r"(cy),"=m"(_c[0]):"0"(cy),"m"(_c[0]):"r0","cc");
-
-
-/* TAO thumb mode uses ite (if then else) to detect carry directly
- * fixed unmatched constraint warning by changing 1 to m  */
-
-#else  /* __thumb__ */
-
-#define INNERMUL                    \
-__asm__(                                \
-    " LDR    r0,%1            \n\t" \
-    " ADDS   r0,r0,%0         \n\t" \
-    " MOVCS  %0,#1            \n\t" \
-    " MOVCC  %0,#0            \n\t" \
-    " UMLAL  r0,%0,%3,%4      \n\t" \
-    " STR    r0,%1            \n\t" \
-:"=r"(cy),"=m"(_c[0]):"0"(cy),"r"(mu),"r"(*tmpm++),"1"(_c[0]):"r0","cc");
-
-#define PROPCARRY                  \
-__asm__(                               \
-    " LDR   r0,%1            \n\t" \
-    " ADDS  r0,r0,%0         \n\t" \
-    " STR   r0,%1            \n\t" \
-    " MOVCS %0,#1            \n\t" \
-    " MOVCC %0,#0            \n\t" \
-:"=r"(cy),"=m"(_c[0]):"0"(cy),"1"(_c[0]):"r0","cc");
-
-#endif /* __thumb__ */
-
-#elif defined(TFM_PPC32)
-
-/* PPC32 */
-#define MONT_START 
-#define MONT_FINI
-#define LOOP_END
-#define LOOP_START \
-   mu = c[x] * mp
-
-#define INNERMUL                     \
-__asm__(                                 \
-   " mullw    16,%3,%4       \n\t"   \
-   " mulhwu   17,%3,%4       \n\t"   \
-   " addc     16,16,%0       \n\t"   \
-   " addze    17,17          \n\t"   \
-   " lwz      18,%1          \n\t"   \
-   " addc     16,16,18       \n\t"   \
-   " addze    %0,17          \n\t"   \
-   " stw      16,%1          \n\t"   \
-:"=r"(cy),"=m"(_c[0]):"0"(cy),"r"(mu),"r"(tmpm[0]),"1"(_c[0]):"16", "17", "18","cc"); ++tmpm;
-
-#define PROPCARRY                    \
-__asm__(                                 \
-   " lwz      16,%1         \n\t"    \
-   " addc     16,16,%0      \n\t"    \
-   " stw      16,%1         \n\t"    \
-   " xor      %0,%0,%0      \n\t"    \
-   " addze    %0,%0         \n\t"    \
-:"=r"(cy),"=m"(_c[0]):"0"(cy),"1"(_c[0]):"16","cc");
-
-#elif defined(TFM_PPC64)
-
-/* PPC64 */
-#define MONT_START 
-#define MONT_FINI
-#define LOOP_END
-#define LOOP_START \
-   mu = c[x] * mp
-
-#define INNERMUL                     \
-__asm__(                                 \
-   " mulld    16,%3,%4       \n\t"   \
-   " mulhdu   17,%3,%4       \n\t"   \
-   " addc     16,16,%0       \n\t"   \
-   " addze    17,17          \n\t"   \
-   " ldx      18,0,%1        \n\t"   \
-   " addc     16,16,18       \n\t"   \
-   " addze    %0,17          \n\t"   \
-   " sdx      16,0,%1        \n\t"   \
-:"=r"(cy),"=m"(_c[0]):"0"(cy),"r"(mu),"r"(tmpm[0]),"1"(_c[0]):"16", "17", "18","cc"); ++tmpm;
-
-#define PROPCARRY                    \
-__asm__(                                 \
-   " ldx      16,0,%1       \n\t"    \
-   " addc     16,16,%0      \n\t"    \
-   " sdx      16,0,%1       \n\t"    \
-   " xor      %0,%0,%0      \n\t"    \
-   " addze    %0,%0         \n\t"    \
-:"=r"(cy),"=m"(_c[0]):"0"(cy),"1"(_c[0]):"16","cc");
-
-/******************************************************************/
-
-#elif defined(TFM_AVR32)
-
-/* AVR32 */
-#define MONT_START 
-#define MONT_FINI
-#define LOOP_END
-#define LOOP_START \
-   mu = c[x] * mp
-
-#define INNERMUL                    \
-__asm__(                                \
-    " ld.w   r2,%1            \n\t" \
-    " add    r2,%0            \n\t" \
-    " eor    r3,r3            \n\t" \
-    " acr    r3               \n\t" \
-    " macu.d r2,%3,%4         \n\t" \
-    " st.w   %1,r2            \n\t" \
-    " mov    %0,r3            \n\t" \
-:"=r"(cy),"=r"(_c):"0"(cy),"r"(mu),"r"(*tmpm++),"1"(_c):"r2","r3");
-
-#define PROPCARRY                    \
-__asm__(                                 \
-   " ld.w     r2,%1         \n\t"    \
-   " add      r2,%0         \n\t"    \
-   " st.w     %1,r2         \n\t"    \
-   " eor      %0,%0         \n\t"    \
-   " acr      %0            \n\t"    \
-:"=r"(cy),"=r"(&_c[0]):"0"(cy),"1"(&_c[0]):"r2","cc");
-
-#else
-
-/* ISO C code */
-#define MONT_START 
-#define MONT_FINI
-#define LOOP_END
-#define LOOP_START \
-   mu = c[x] * mp
-
-#define INNERMUL                                      \
-   do { fp_word t;                                    \
-   t  = ((fp_word)_c[0] + (fp_word)cy) +              \
-                (((fp_word)mu) * ((fp_word)*tmpm++)); \
-   _c[0] = (fp_digit)t;                               \
-   cy = (fp_digit)(t >> DIGIT_BIT);                   \
-   } while (0)
-
-#define PROPCARRY \
-   do { fp_digit t = _c[0] += cy; cy = (t < cy); } while (0)
-
-#endif
-/******************************************************************/
-
-
-#define LO  0
-/* end fp_montogomery_reduce.c asm */
-
-
-/* start fp_sqr_comba.c asm */
-#if defined(TFM_X86)
-
-/* x86-32 optimized */
-
-#define COMBA_START
-
-#define CLEAR_CARRY \
-   c0 = c1 = c2 = 0;
-
-#define COMBA_STORE(x) \
-   x = c0;
-
-#define COMBA_STORE2(x) \
-   x = c1;
-
-#define CARRY_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-#define COMBA_FINI
-
-#define SQRADD(i, j)                                      \
-__asm__(                                            \
-     "movl  %6,%%eax     \n\t"                            \
-     "mull  %%eax        \n\t"                            \
-     "addl  %%eax,%0     \n\t"                            \
-     "adcl  %%edx,%1     \n\t"                            \
-     "adcl  $0,%2        \n\t"                            \
-     :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i) :"%eax","%edx","cc");
-
-#define SQRADD2(i, j)                                     \
-__asm__(                                            \
-     "movl  %6,%%eax     \n\t"                            \
-     "mull  %7           \n\t"                            \
-     "addl  %%eax,%0     \n\t"                            \
-     "adcl  %%edx,%1     \n\t"                            \
-     "adcl  $0,%2        \n\t"                            \
-     "addl  %%eax,%0     \n\t"                            \
-     "adcl  %%edx,%1     \n\t"                            \
-     "adcl  $0,%2        \n\t"                            \
-     :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i), "m"(j)  :"%eax","%edx", "cc");
-
-#define SQRADDSC(i, j)                                    \
-__asm__(                                                     \
-     "movl  %3,%%eax     \n\t"                            \
-     "mull  %4           \n\t"                            \
-     "movl  %%eax,%0     \n\t"                            \
-     "movl  %%edx,%1     \n\t"                            \
-     "xorl  %2,%2        \n\t"                            \
-     :"=r"(sc0), "=r"(sc1), "=r"(sc2): "g"(i), "g"(j) :"%eax","%edx","cc");
-
-/* TAO removed sc0,1,2 as input to remove warning so %6,%7 become %3,%4 */
-
-#define SQRADDAC(i, j)                                    \
-__asm__(                                                     \
-     "movl  %6,%%eax     \n\t"                            \
-     "mull  %7           \n\t"                            \
-     "addl  %%eax,%0     \n\t"                            \
-     "adcl  %%edx,%1     \n\t"                            \
-     "adcl  $0,%2        \n\t"                            \
-     :"=r"(sc0), "=r"(sc1), "=r"(sc2): "0"(sc0), "1"(sc1), "2"(sc2), "g"(i), "g"(j) :"%eax","%edx","cc");
-
-#define SQRADDDB                                          \
-__asm__(                                                     \
-     "addl %6,%0         \n\t"                            \
-     "adcl %7,%1         \n\t"                            \
-     "adcl %8,%2         \n\t"                            \
-     "addl %6,%0         \n\t"                            \
-     "adcl %7,%1         \n\t"                            \
-     "adcl %8,%2         \n\t"                            \
-     :"=r"(c0), "=r"(c1), "=r"(c2) : "0"(c0), "1"(c1), "2"(c2), "r"(sc0), "r"(sc1), "r"(sc2) : "cc");
-
-#elif defined(TFM_X86_64)
-/* x86-64 optimized */
-
-#define COMBA_START
-
-#define CLEAR_CARRY \
-   c0 = c1 = c2 = 0;
-
-#define COMBA_STORE(x) \
-   x = c0;
-
-#define COMBA_STORE2(x) \
-   x = c1;
-
-#define CARRY_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-#define COMBA_FINI
-
-#define SQRADD(i, j)                                      \
-__asm__(                                                     \
-     "movq  %6,%%rax     \n\t"                            \
-     "mulq  %%rax        \n\t"                            \
-     "addq  %%rax,%0     \n\t"                            \
-     "adcq  %%rdx,%1     \n\t"                            \
-     "adcq  $0,%2        \n\t"                            \
-     :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "g"(i) :"%rax","%rdx","cc");
-
-#define SQRADD2(i, j)                                     \
-__asm__(                                                     \
-     "movq  %6,%%rax     \n\t"                            \
-     "mulq  %7           \n\t"                            \
-     "addq  %%rax,%0     \n\t"                            \
-     "adcq  %%rdx,%1     \n\t"                            \
-     "adcq  $0,%2        \n\t"                            \
-     "addq  %%rax,%0     \n\t"                            \
-     "adcq  %%rdx,%1     \n\t"                            \
-     "adcq  $0,%2        \n\t"                            \
-     :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "g"(i), "g"(j)  :"%rax","%rdx","cc");
-
-#define SQRADDSC(i, j)                                    \
-__asm__(                                                     \
-     "movq  %3,%%rax     \n\t"                            \
-     "mulq  %4           \n\t"                            \
-     "movq  %%rax,%0     \n\t"                            \
-     "movq  %%rdx,%1     \n\t"                            \
-     "xorq  %2,%2        \n\t"                            \
-     :"=r"(sc0), "=r"(sc1), "=r"(sc2): "g"(i), "g"(j) :"%rax","%rdx","cc");
-
-/* TAO removed sc0,1,2 as input to remove warning so %6,%7 become %3,%4 */
-
-#define SQRADDAC(i, j)                                                         \
-__asm__(                                                     \
-     "movq  %6,%%rax     \n\t"                            \
-     "mulq  %7           \n\t"                            \
-     "addq  %%rax,%0     \n\t"                            \
-     "adcq  %%rdx,%1     \n\t"                            \
-     "adcq  $0,%2        \n\t"                            \
-     :"=r"(sc0), "=r"(sc1), "=r"(sc2): "0"(sc0), "1"(sc1), "2"(sc2), "g"(i), "g"(j) :"%rax","%rdx","cc");
-
-#define SQRADDDB                                          \
-__asm__(                                                     \
-     "addq %6,%0         \n\t"                            \
-     "adcq %7,%1         \n\t"                            \
-     "adcq %8,%2         \n\t"                            \
-     "addq %6,%0         \n\t"                            \
-     "adcq %7,%1         \n\t"                            \
-     "adcq %8,%2         \n\t"                            \
-     :"=r"(c0), "=r"(c1), "=r"(c2) : "0"(c0), "1"(c1), "2"(c2), "r"(sc0), "r"(sc1), "r"(sc2) : "cc");
-
-#elif defined(TFM_SSE2)
-
-/* SSE2 Optimized */
-#define COMBA_START
-
-#define CLEAR_CARRY \
-   c0 = c1 = c2 = 0;
-
-#define COMBA_STORE(x) \
-   x = c0;
-
-#define COMBA_STORE2(x) \
-   x = c1;
-
-#define CARRY_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-#define COMBA_FINI \
-   __asm__("emms");
-
-#define SQRADD(i, j)                                      \
-__asm__(                                            \
-     "movd  %6,%%mm0     \n\t"                            \
-     "pmuludq %%mm0,%%mm0\n\t"                            \
-     "movd  %%mm0,%%eax  \n\t"                            \
-     "psrlq $32,%%mm0    \n\t"                            \
-     "addl  %%eax,%0     \n\t"                            \
-     "movd  %%mm0,%%eax  \n\t"                            \
-     "adcl  %%eax,%1     \n\t"                            \
-     "adcl  $0,%2        \n\t"                            \
-     :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i) :"%eax","cc");
-
-#define SQRADD2(i, j)                                     \
-__asm__(                                            \
-     "movd  %6,%%mm0     \n\t"                            \
-     "movd  %7,%%mm1     \n\t"                            \
-     "pmuludq %%mm1,%%mm0\n\t"                            \
-     "movd  %%mm0,%%eax  \n\t"                            \
-     "psrlq $32,%%mm0    \n\t"                            \
-     "movd  %%mm0,%%edx  \n\t"                            \
-     "addl  %%eax,%0     \n\t"                            \
-     "adcl  %%edx,%1     \n\t"                            \
-     "adcl  $0,%2        \n\t"                            \
-     "addl  %%eax,%0     \n\t"                            \
-     "adcl  %%edx,%1     \n\t"                            \
-     "adcl  $0,%2        \n\t"                            \
-     :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i), "m"(j)  :"%eax","%edx","cc");
-
-#define SQRADDSC(i, j)                                                         \
-__asm__(                                            \
-     "movd  %3,%%mm0     \n\t"                            \
-     "movd  %4,%%mm1     \n\t"                            \
-     "pmuludq %%mm1,%%mm0\n\t"                            \
-     "movd  %%mm0,%0     \n\t"                            \
-     "psrlq $32,%%mm0    \n\t"                            \
-     "movd  %%mm0,%1     \n\t"                            \
-     "xorl  %2,%2        \n\t"                            \
-     :"=r"(sc0), "=r"(sc1), "=r"(sc2): "m"(i), "m"(j));
-
-/* TAO removed sc0,1,2 as input to remove warning so %6,%7 become %3,%4 */
-
-#define SQRADDAC(i, j)                                                         \
-__asm__(                                            \
-     "movd  %6,%%mm0     \n\t"                            \
-     "movd  %7,%%mm1     \n\t"                            \
-     "pmuludq %%mm1,%%mm0\n\t"                            \
-     "movd  %%mm0,%%eax  \n\t"                            \
-     "psrlq $32,%%mm0    \n\t"                            \
-     "movd  %%mm0,%%edx  \n\t"                            \
-     "addl  %%eax,%0     \n\t"                            \
-     "adcl  %%edx,%1     \n\t"                            \
-     "adcl  $0,%2        \n\t"                            \
-     :"=r"(sc0), "=r"(sc1), "=r"(sc2): "0"(sc0), "1"(sc1), "2"(sc2), "m"(i), "m"(j)  :"%eax","%edx","cc");
-
-#define SQRADDDB                                          \
-__asm__(                                                     \
-     "addl %6,%0         \n\t"                            \
-     "adcl %7,%1         \n\t"                            \
-     "adcl %8,%2         \n\t"                            \
-     "addl %6,%0         \n\t"                            \
-     "adcl %7,%1         \n\t"                            \
-     "adcl %8,%2         \n\t"                            \
-     :"=r"(c0), "=r"(c1), "=r"(c2) : "0"(c0), "1"(c1), "2"(c2), "r"(sc0), "r"(sc1), "r"(sc2) : "cc");
-
-#elif defined(TFM_ARM)
-
-/* ARM code */
-
-#define COMBA_START
-
-#define CLEAR_CARRY \
-   c0 = c1 = c2 = 0;
-
-#define COMBA_STORE(x) \
-   x = c0;
-
-#define COMBA_STORE2(x) \
-   x = c1;
-
-#define CARRY_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-#define COMBA_FINI
-
-/* multiplies point i and j, updates carry "c1" and digit c2 */
-#define SQRADD(i, j)                                             \
-__asm__(                                                             \
-"  UMULL  r0,r1,%6,%6              \n\t"                         \
-"  ADDS   %0,%0,r0                 \n\t"                         \
-"  ADCS   %1,%1,r1                 \n\t"                         \
-"  ADC    %2,%2,#0                 \n\t"                         \
-:"=r"(c0), "=r"(c1), "=r"(c2) : "0"(c0), "1"(c1), "2"(c2), "r"(i) : "r0", "r1", "cc");
-	
-/* for squaring some of the terms are doubled... */
-#define SQRADD2(i, j)                                            \
-__asm__(                                                             \
-"  UMULL  r0,r1,%6,%7              \n\t"                         \
-"  ADDS   %0,%0,r0                 \n\t"                         \
-"  ADCS   %1,%1,r1                 \n\t"                         \
-"  ADC    %2,%2,#0                 \n\t"                         \
-"  ADDS   %0,%0,r0                 \n\t"                         \
-"  ADCS   %1,%1,r1                 \n\t"                         \
-"  ADC    %2,%2,#0                 \n\t"                         \
-:"=r"(c0), "=r"(c1), "=r"(c2) : "0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j) : "r0", "r1", "cc");
-
-#define SQRADDSC(i, j)                                           \
-__asm__(                                                             \
-"  UMULL  %0,%1,%3,%4              \n\t"                         \
-"  SUB    %2,%2,%2                 \n\t"                         \
-:"=r"(sc0), "=r"(sc1), "=r"(sc2) : "r"(i), "r"(j) : "cc");
-
-/* TAO removed sc0,1,2 as input to remove warning so %6,%7 become %3,%4 */
-
-#define SQRADDAC(i, j)                                           \
-__asm__(                                                             \
-"  UMULL  r0,r1,%6,%7              \n\t"                         \
-"  ADDS   %0,%0,r0                 \n\t"                         \
-"  ADCS   %1,%1,r1                 \n\t"                         \
-"  ADC    %2,%2,#0                 \n\t"                         \
-:"=r"(sc0), "=r"(sc1), "=r"(sc2) : "0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j) : "r0", "r1", "cc");
-
-#define SQRADDDB                                                 \
-__asm__(                                                             \
-"  ADDS  %0,%0,%3                     \n\t"                      \
-"  ADCS  %1,%1,%4                     \n\t"                      \
-"  ADC   %2,%2,%5                     \n\t"                      \
-"  ADDS  %0,%0,%3                     \n\t"                      \
-"  ADCS  %1,%1,%4                     \n\t"                      \
-"  ADC   %2,%2,%5                     \n\t"                      \
-:"=r"(c0), "=r"(c1), "=r"(c2) : "r"(sc0), "r"(sc1), "r"(sc2), "0"(c0), "1"(c1), "2"(c2) : "cc");
-
-#elif defined(TFM_PPC32)
-
-/* PPC32 */
-
-#define COMBA_START
-
-#define CLEAR_CARRY \
-   c0 = c1 = c2 = 0;
-
-#define COMBA_STORE(x) \
-   x = c0;
-
-#define COMBA_STORE2(x) \
-   x = c1;
-
-#define CARRY_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-#define COMBA_FINI
-
-/* multiplies point i and j, updates carry "c1" and digit c2 */
-#define SQRADD(i, j)             \
-__asm__(                             \
-   " mullw  16,%6,%6       \n\t" \
-   " addc   %0,%0,16       \n\t" \
-   " mulhwu 16,%6,%6       \n\t" \
-   " adde   %1,%1,16       \n\t" \
-   " addze  %2,%2          \n\t" \
-:"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i):"16","cc");
-
-/* for squaring some of the terms are doubled... */
-#define SQRADD2(i, j)            \
-__asm__(                             \
-   " mullw  16,%6,%7       \n\t" \
-   " mulhwu 17,%6,%7       \n\t" \
-   " addc   %0,%0,16       \n\t" \
-   " adde   %1,%1,17       \n\t" \
-   " addze  %2,%2          \n\t" \
-   " addc   %0,%0,16       \n\t" \
-   " adde   %1,%1,17       \n\t" \
-   " addze  %2,%2          \n\t" \
-:"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"16", "17","cc");
-
-#define SQRADDSC(i, j)            \
-__asm__(                              \
-   " mullw  %0,%6,%7        \n\t" \
-   " mulhwu %1,%6,%7        \n\t" \
-   " xor    %2,%2,%2        \n\t" \
-:"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i),"r"(j) : "cc");
-
-#define SQRADDAC(i, j)           \
-__asm__(                             \
-   " mullw  16,%6,%7       \n\t" \
-   " addc   %0,%0,16       \n\t" \
-   " mulhwu 16,%6,%7       \n\t" \
-   " adde   %1,%1,16       \n\t" \
-   " addze  %2,%2          \n\t" \
-:"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j):"16", "cc");
-
-#define SQRADDDB                  \
-__asm__(                              \
-   " addc   %0,%0,%3        \n\t" \
-   " adde   %1,%1,%4        \n\t" \
-   " adde   %2,%2,%5        \n\t" \
-   " addc   %0,%0,%3        \n\t" \
-   " adde   %1,%1,%4        \n\t" \
-   " adde   %2,%2,%5        \n\t" \
-:"=r"(c0), "=r"(c1), "=r"(c2) : "r"(sc0), "r"(sc1), "r"(sc2), "0"(c0), "1"(c1), "2"(c2) : "cc");
-
-#elif defined(TFM_PPC64)
-/* PPC64 */
-
-#define COMBA_START
-
-#define CLEAR_CARRY \
-   c0 = c1 = c2 = 0;
-
-#define COMBA_STORE(x) \
-   x = c0;
-
-#define COMBA_STORE2(x) \
-   x = c1;
-
-#define CARRY_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-#define COMBA_FINI
-
-/* multiplies point i and j, updates carry "c1" and digit c2 */
-#define SQRADD(i, j)             \
-__asm__(                             \
-   " mulld  16,%6,%6       \n\t" \
-   " addc   %0,%0,16       \n\t" \
-   " mulhdu 16,%6,%6       \n\t" \
-   " adde   %1,%1,16       \n\t" \
-   " addze  %2,%2          \n\t" \
-:"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i):"16","cc");
-
-/* for squaring some of the terms are doubled... */
-#define SQRADD2(i, j)            \
-__asm__(                             \
-   " mulld  16,%6,%7       \n\t" \
-   " mulhdu 17,%6,%7       \n\t" \
-   " addc   %0,%0,16       \n\t" \
-   " adde   %1,%1,17       \n\t" \
-   " addze  %2,%2          \n\t" \
-   " addc   %0,%0,16       \n\t" \
-   " adde   %1,%1,17       \n\t" \
-   " addze  %2,%2          \n\t" \
-:"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"16", "17","cc");
-
-#define SQRADDSC(i, j)            \
-__asm__(                              \
-   " mulld  %0,%6,%7        \n\t" \
-   " mulhdu %1,%6,%7        \n\t" \
-   " xor    %2,%2,%2        \n\t" \
-:"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i),"r"(j) : "cc");
-
-#define SQRADDAC(i, j)           \
-__asm__(                             \
-   " mulld  16,%6,%7       \n\t" \
-   " addc   %0,%0,16       \n\t" \
-   " mulhdu 16,%6,%7       \n\t" \
-   " adde   %1,%1,16       \n\t" \
-   " addze  %2,%2          \n\t" \
-:"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j):"16", "cc");
-
-#define SQRADDDB                  \
-__asm__(                              \
-   " addc   %0,%0,%3        \n\t" \
-   " adde   %1,%1,%4        \n\t" \
-   " adde   %2,%2,%5        \n\t" \
-   " addc   %0,%0,%3        \n\t" \
-   " adde   %1,%1,%4        \n\t" \
-   " adde   %2,%2,%5        \n\t" \
-:"=r"(c0), "=r"(c1), "=r"(c2) : "r"(sc0), "r"(sc1), "r"(sc2), "0"(c0), "1"(c1), "2"(c2) : "cc");
-
-
-#elif defined(TFM_AVR32)
-
-/* AVR32 */
-
-#define COMBA_START
-
-#define CLEAR_CARRY \
-   c0 = c1 = c2 = 0;
-
-#define COMBA_STORE(x) \
-   x = c0;
-
-#define COMBA_STORE2(x) \
-   x = c1;
-
-#define CARRY_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-#define COMBA_FINI
-
-/* multiplies point i and j, updates carry "c1" and digit c2 */
-#define SQRADD(i, j)             \
-__asm__(                             \
-   " mulu.d r2,%6,%6       \n\t" \
-   " add    %0,%0,r2       \n\t" \
-   " adc    %1,%1,r3       \n\t" \
-   " acr    %2             \n\t" \
-:"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i):"r2","r3");
-
-/* for squaring some of the terms are doubled... */
-#define SQRADD2(i, j)            \
-__asm__(                             \
-   " mulu.d r2,%6,%7       \n\t" \
-   " add    %0,%0,r2       \n\t" \
-   " adc    %1,%1,r3       \n\t" \
-   " acr    %2,            \n\t" \
-   " add    %0,%0,r2       \n\t" \
-   " adc    %1,%1,r3       \n\t" \
-   " acr    %2,            \n\t" \
-:"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"r2", "r3");
-
-#define SQRADDSC(i, j)            \
-__asm__(                              \
-   " mulu.d r2,%6,%7        \n\t" \
-   " mov    %0,r2           \n\t" \
-   " mov    %1,r3           \n\t" \
-   " eor    %2,%2           \n\t" \
-:"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i),"r"(j) : "r2", "r3");
-
-#define SQRADDAC(i, j)           \
-__asm__(                             \
-   " mulu.d r2,%6,%7       \n\t" \
-   " add    %0,%0,r2       \n\t" \
-   " adc    %1,%1,r3       \n\t" \
-   " acr    %2             \n\t" \
-:"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j):"r2", "r3");
-
-#define SQRADDDB                  \
-__asm__(                              \
-   " add    %0,%0,%3        \n\t" \
-   " adc    %1,%1,%4        \n\t" \
-   " adc    %2,%2,%5        \n\t" \
-   " add    %0,%0,%3        \n\t" \
-   " adc    %1,%1,%4        \n\t" \
-   " adc    %2,%2,%5        \n\t" \
-:"=r"(c0), "=r"(c1), "=r"(c2) : "r"(sc0), "r"(sc1), "r"(sc2), "0"(c0), "1"(c1), "2"(c2) : "cc");
-
-
-#else
-
-#define TFM_ISO
-
-/* ISO C portable code */
-
-#define COMBA_START
-
-#define CLEAR_CARRY \
-   c0 = c1 = c2 = 0;
-
-#define COMBA_STORE(x) \
-   x = c0;
-
-#define COMBA_STORE2(x) \
-   x = c1;
-
-#define CARRY_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-#define COMBA_FINI
-
-/* multiplies point i and j, updates carry "c1" and digit c2 */
-#define SQRADD(i, j)                                 \
-   do { fp_word t;                                   \
-   t = c0 + ((fp_word)i) * ((fp_word)j);  c0 = (fp_digit)t;    \
-   t = c1 + (t >> DIGIT_BIT);             c1 = (fp_digit)t;    \
-                                          c2 +=(fp_digit) (t >> DIGIT_BIT); \
-   } while (0);
-  
-
-/* for squaring some of the terms are doubled... */
-#define SQRADD2(i, j)                                                 \
-   do { fp_word t;                                                    \
-   t  = ((fp_word)i) * ((fp_word)j);                                  \
-   tt = (fp_word)c0 + t;                 c0 = (fp_digit)tt;           \
-   tt = (fp_word)c1 + (tt >> DIGIT_BIT); c1 = (fp_digit)tt;           \
-                                         c2 +=(fp_digit)( tt >> DIGIT_BIT);    \
-   tt = (fp_word)c0 + t;                 c0 = (fp_digit)tt;                    \
-   tt = (fp_word)c1 + (tt >> DIGIT_BIT); c1 = (fp_digit)tt;            \
-                                         c2 +=(fp_digit) (tt >> DIGIT_BIT);    \
-   } while (0);
-
-#define SQRADDSC(i, j)                                                         \
-   do { fp_word t;                                                             \
-      t =  ((fp_word)i) * ((fp_word)j);                                        \
-      sc0 = (fp_digit)t; sc1 = (t >> DIGIT_BIT); sc2 = 0;                      \
-   } while (0);
-
-#define SQRADDAC(i, j)                                                         \
-   do { fp_word t;                                                             \
-   t = sc0 + ((fp_word)i) * ((fp_word)j);  sc0 =  (fp_digit)t;                 \
-   t = sc1 + (t >> DIGIT_BIT);             sc1 =  (fp_digit)t;                 \
-                                           sc2 += (fp_digit)(t >> DIGIT_BIT);  \
-   } while (0);
-
-#define SQRADDDB                                                               \
-   do { fp_word t;                                                             \
-   t = ((fp_word)sc0) + ((fp_word)sc0) + c0; c0 = (fp_digit)t;                 \
-   t = ((fp_word)sc1) + ((fp_word)sc1) + c1 + (t >> DIGIT_BIT);                \
-                                             c1 = (fp_digit)t;                 \
-   c2 = c2 + (fp_digit)(((fp_word)sc2) + ((fp_word)sc2) + (t >> DIGIT_BIT));   \
-   } while (0);
-
-#endif
-
-#ifdef TFM_SMALL_SET
-    #include "fp_sqr_comba_small_set.i"
-#endif
-
-#if defined(TFM_SQR3)
-    #include "fp_sqr_comba_3.i"
-#endif
-#if defined(TFM_SQR4)
-    #include "fp_sqr_comba_4.i"
-#endif
-#if defined(TFM_SQR6)
-    #include "fp_sqr_comba_6.i"
-#endif
-#if defined(TFM_SQR7)
-    #include "fp_sqr_comba_7.i"
-#endif
-#if defined(TFM_SQR8)
-    #include "fp_sqr_comba_8.i"
-#endif
-#if defined(TFM_SQR9)
-    #include "fp_sqr_comba_9.i"
-#endif
-#if defined(TFM_SQR12)
-    #include "fp_sqr_comba_12.i"
-#endif
-#if defined(TFM_SQR17)
-    #include "fp_sqr_comba_17.i"
-#endif
-#if defined(TFM_SQR20)
-    #include "fp_sqr_comba_20.i"
-#endif
-#if defined(TFM_SQR24)
-    #include "fp_sqr_comba_24.i"
-#endif
-#if defined(TFM_SQR28)
-    #include "fp_sqr_comba_28.i"
-#endif
-#if defined(TFM_SQR32)
-    #include "fp_sqr_comba_32.i"
-#endif
-#if defined(TFM_SQR48)
-    #include "fp_sqr_comba_48.i"
-#endif
-#if defined(TFM_SQR64)
-    #include "fp_sqr_comba_64.i"
-#endif
-/* end fp_sqr_comba.c asm */
-
-/* start fp_mul_comba.c asm */
-/* these are the combas.  Worship them. */
-#if defined(TFM_X86)
-/* Generic x86 optimized code */
-
-/* anything you need at the start */
-#define COMBA_START
-
-/* clear the chaining variables */
-#define COMBA_CLEAR \
-   c0 = c1 = c2 = 0;
-
-/* forward the carry to the next digit */
-#define COMBA_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-/* store the first sum */
-#define COMBA_STORE(x) \
-   x = c0;
-
-/* store the second sum [carry] */
-#define COMBA_STORE2(x) \
-   x = c1;
-
-/* anything you need at the end */
-#define COMBA_FINI
-
-/* this should multiply i and j  */
-#define MULADD(i, j)                                      \
-__asm__(                                                      \
-     "movl  %6,%%eax     \n\t"                            \
-     "mull  %7           \n\t"                            \
-     "addl  %%eax,%0     \n\t"                            \
-     "adcl  %%edx,%1     \n\t"                            \
-     "adcl  $0,%2        \n\t"                            \
-     :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i), "m"(j)  :"%eax","%edx","cc");
-
-#elif defined(TFM_X86_64)
-/* x86-64 optimized */
-
-/* anything you need at the start */
-#define COMBA_START
-
-/* clear the chaining variables */
-#define COMBA_CLEAR \
-   c0 = c1 = c2 = 0;
-
-/* forward the carry to the next digit */
-#define COMBA_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-/* store the first sum */
-#define COMBA_STORE(x) \
-   x = c0;
-
-/* store the second sum [carry] */
-#define COMBA_STORE2(x) \
-   x = c1;
-
-/* anything you need at the end */
-#define COMBA_FINI
-
-/* this should multiply i and j  */
-#define MULADD(i, j)                                      \
-__asm__  (                                                    \
-     "movq  %6,%%rax     \n\t"                            \
-     "mulq  %7           \n\t"                            \
-     "addq  %%rax,%0     \n\t"                            \
-     "adcq  %%rdx,%1     \n\t"                            \
-     "adcq  $0,%2        \n\t"                            \
-     :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "g"(i), "g"(j)  :"%rax","%rdx","cc");
-
-
-#if defined(HAVE_INTEL_MULX)
-#define MULADD_MULX(b0, c0, c1, rdx)\
-    __asm__  volatile (                                   \
-         "movq   %3, %%rdx\n\t"                           \
-         "mulx  %2,%%r9, %%r8 \n\t"                       \
-         "adoxq  %%r9,%0     \n\t"                        \
-         "adcxq  %%r8,%1     \n\t"                        \
-         :"+r"(c0),"+r"(c1):"r"(b0), "r"(rdx):"%r8","%r9","%r10","%rdx"\
-    )
-
-
-#define MULADD_MULX_ADD_CARRY(c0, c1)\
-    __asm__ volatile(\
-    "mov $0, %%r10\n\t"\
-    "movq %1, %%r8\n\t"\
-    "adox %%r10, %0\n\t"\
-    "adcx %%r10, %1\n\t"\
-    :"+r"(c0),"+r"(c1)::"%r8","%r9","%r10","%rdx") ;
-
-#define MULADD_SET_A(a0)\
-    __asm__ volatile("add $0, %%r8\n\t"                   \
-             "movq  %0,%%rdx\n\t"                         \
-             ::"r"(a0):"%r8","%r9","%r10","%rdx") ;
-
-#define MULADD_BODY(a,b,c)\
-    {   word64 rdx = a->dp[ix] ;      \
-        cp = &(c->dp[iz]) ;           \
-        c0 = cp[0] ; c1 = cp[1];      \
-        MULADD_SET_A(rdx) ;           \
-        MULADD_MULX(b0, c0, c1, rdx) ;\
-        cp[0]=c0; c0=cp[2];           \
-        MULADD_MULX(b1, c1, c0, rdx) ;\
-        cp[1]=c1; c1=cp[3];           \
-        MULADD_MULX(b2, c0, c1, rdx) ;\
-        cp[2]=c0; c0=cp[4];           \
-        MULADD_MULX(b3, c1, c0, rdx) ;\
-        cp[3]=c1; c1=cp[5];           \
-        MULADD_MULX_ADD_CARRY(c0, c1);\
-        cp[4]=c0; cp[5]=c1;           \
-    }
-
-#define TFM_INTEL_MUL_COMBA(a, b, c)\
-  for(ix=0; ixdp[ix]=0 ; \
-  for(iy=0; (iyused); iy+=4) {    \
-    fp_digit *bp ;                    \
-    bp = &(b->dp[iy+0]) ;             \
-    fp_digit b0 = bp[0] , b1= bp[1],  \
-             b2= bp[2], b3= bp[3];    \
-    ix=0, iz=iy;                      \
-    while(ixused) {               \
-        fp_digit c0, c1;              \
-        fp_digit *cp ;                \
-        MULADD_BODY(a,b,c);           \
-        ix++ ; iz++ ;                 \
-    }                                 \
-};
-#endif
-
-#elif defined(TFM_SSE2)
-/* use SSE2 optimizations */
-
-/* anything you need at the start */
-#define COMBA_START
-
-/* clear the chaining variables */
-#define COMBA_CLEAR \
-   c0 = c1 = c2 = 0;
-
-/* forward the carry to the next digit */
-#define COMBA_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-/* store the first sum */
-#define COMBA_STORE(x) \
-   x = c0;
-
-/* store the second sum [carry] */
-#define COMBA_STORE2(x) \
-   x = c1;
-
-/* anything you need at the end */
-#define COMBA_FINI \
-   __asm__("emms");
-
-/* this should multiply i and j  */
-#define MULADD(i, j)                                     \
-__asm__(                                                     \
-    "movd  %6,%%mm0     \n\t"                            \
-    "movd  %7,%%mm1     \n\t"                            \
-    "pmuludq %%mm1,%%mm0\n\t"                            \
-    "movd  %%mm0,%%eax  \n\t"                            \
-    "psrlq $32,%%mm0    \n\t"                            \
-    "addl  %%eax,%0     \n\t"                            \
-    "movd  %%mm0,%%eax  \n\t"                            \
-    "adcl  %%eax,%1     \n\t"                            \
-    "adcl  $0,%2        \n\t"                            \
-    :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i), "m"(j)  :"%eax","cc");
-
-#elif defined(TFM_ARM)
-/* ARM code */
-
-#define COMBA_START 
-
-#define COMBA_CLEAR \
-   c0 = c1 = c2 = 0;
-
-#define COMBA_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-#define COMBA_STORE(x) \
-   x = c0;
-
-#define COMBA_STORE2(x) \
-   x = c1;
-
-#define COMBA_FINI
-
-#define MULADD(i, j)                                          \
-__asm__(                                                          \
-"  UMULL  r0,r1,%6,%7           \n\t"                         \
-"  ADDS   %0,%0,r0              \n\t"                         \
-"  ADCS   %1,%1,r1              \n\t"                         \
-"  ADC    %2,%2,#0              \n\t"                         \
-:"=r"(c0), "=r"(c1), "=r"(c2) : "0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j) : "r0", "r1", "cc");
-
-#elif defined(TFM_PPC32)
-/* For 32-bit PPC */
-
-#define COMBA_START
-
-#define COMBA_CLEAR \
-   c0 = c1 = c2 = 0;
-
-#define COMBA_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-#define COMBA_STORE(x) \
-   x = c0;
-
-#define COMBA_STORE2(x) \
-   x = c1;
-
-#define COMBA_FINI 
-   
-/* untested: will mulhwu change the flags?  Docs say no */
-#define MULADD(i, j)              \
-__asm__(                              \
-   " mullw  16,%6,%7       \n\t" \
-   " addc   %0,%0,16       \n\t" \
-   " mulhwu 16,%6,%7       \n\t" \
-   " adde   %1,%1,16       \n\t" \
-   " addze  %2,%2          \n\t" \
-:"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"16");
-
-#elif defined(TFM_PPC64)
-/* For 64-bit PPC */
-
-#define COMBA_START
-
-#define COMBA_CLEAR \
-   c0 = c1 = c2 = 0;
-
-#define COMBA_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-#define COMBA_STORE(x) \
-   x = c0;
-
-#define COMBA_STORE2(x) \
-   x = c1;
-
-#define COMBA_FINI 
-   
-/* untested: will mulhwu change the flags?  Docs say no */
-#define MULADD(i, j)              \
-____asm__(                              \
-   " mulld  16,%6,%7       \n\t" \
-   " addc   %0,%0,16       \n\t" \
-   " mulhdu 16,%6,%7       \n\t" \
-   " adde   %1,%1,16       \n\t" \
-   " addze  %2,%2          \n\t" \
-:"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"16");
-
-#elif defined(TFM_AVR32)
-
-/* ISO C code */
-
-#define COMBA_START
-
-#define COMBA_CLEAR \
-   c0 = c1 = c2 = 0;
-
-#define COMBA_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-#define COMBA_STORE(x) \
-   x = c0;
-
-#define COMBA_STORE2(x) \
-   x = c1;
-
-#define COMBA_FINI 
-   
-#define MULADD(i, j)             \
-____asm__(                             \
-   " mulu.d r2,%6,%7        \n\t"\
-   " add    %0,r2           \n\t"\
-   " adc    %1,%1,r3        \n\t"\
-   " acr    %2              \n\t"\
-:"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"r2","r3");
-
-#else
-/* ISO C code */
-
-#define COMBA_START
-
-#define COMBA_CLEAR \
-   c0 = c1 = c2 = 0;
-
-#define COMBA_FORWARD \
-   do { c0 = c1; c1 = c2; c2 = 0; } while (0);
-
-#define COMBA_STORE(x) \
-   x = c0;
-
-#define COMBA_STORE2(x) \
-   x = c1;
-
-#define COMBA_FINI 
-   
-#define MULADD(i, j)                                                                                                                                  \
-   do { fp_word t;                                                    \
-   t = (fp_word)c0 + ((fp_word)i) * ((fp_word)j); c0 = (fp_digit)t;   \
-   t = (fp_word)c1 + (t >> DIGIT_BIT);                                \
-   c1 = (fp_digit)t; c2 += (fp_digit)(t >> DIGIT_BIT);                \
-   } while (0);
-
-#endif
-
-
-#ifdef TFM_SMALL_SET
-    #include "fp_mul_comba_small_set.i"
-#endif
-
-#if defined(TFM_MUL3)
-    #include "fp_mul_comba_3.i"
-#endif
-#if defined(TFM_MUL4)
-    #include "fp_mul_comba_4.i"
-#endif
-#if defined(TFM_MUL6)
-    #include "fp_mul_comba_6.i"
-#endif
-#if defined(TFM_MUL7)
-    #include "fp_mul_comba_7.i"
-#endif
-#if defined(TFM_MUL8)
-    #include "fp_mul_comba_8.i"
-#endif
-#if defined(TFM_MUL9)
-    #include "fp_mul_comba_9.i"
-#endif
-#if defined(TFM_MUL12)
-    #include "fp_mul_comba_12.i"
-#endif
-#if defined(TFM_MUL17)
-    #include "fp_mul_comba_17.i"
-#endif
-#if defined(TFM_MUL20)
-    #include "fp_mul_comba_20.i"
-#endif
-#if defined(TFM_MUL24)
-    #include "fp_mul_comba_24.i"
-#endif
-#if defined(TFM_MUL28)
-    #include "fp_mul_comba_28.i"
-#endif
-#if defined(TFM_MUL32)
-    #include "fp_mul_comba_32.i"
-#endif
-#if defined(TFM_MUL48)
-    #include "fp_mul_comba_48.i"
-#endif
-#if defined(TFM_MUL64)
-    #include "fp_mul_comba_64.i"
-#endif
-
-/* end fp_mul_comba.c asm */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/asn.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/asn.c
deleted file mode 100755
index e3d9ff4..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/asn.c
+++ /dev/null
@@ -1,7795 +0,0 @@
-/* asn.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef NO_ASN
-
-#ifdef HAVE_RTP_SYS
-    #include "os.h"           /* dc_rtc_api needs    */
-    #include "dc_rtc_api.h"   /* to get current time */
-#endif
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-
-#ifndef NO_RC4
-    #include 
-#endif
-
-#ifdef HAVE_NTRU
-    #include "ntru_crypto.h"
-#endif
-
-#if defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384)
-    #include 
-#endif
-
-#ifndef NO_SHA256
-    #include 
-#endif
-
-#ifdef HAVE_ECC
-    #include 
-#endif
-
-#ifdef WOLFSSL_DEBUG_ENCODING
-    #ifdef FREESCALE_MQX
-        #include 
-    #else
-        #include 
-    #endif
-#endif
-
-#ifdef _MSC_VER
-    /* 4996 warning to use MS extensions e.g., strcpy_s instead of XSTRNCPY */
-    #pragma warning(disable: 4996)
-#endif
-
-
-#ifndef TRUE
-    #define TRUE  1
-#endif
-#ifndef FALSE
-    #define FALSE 0
-#endif
-
-
-#ifdef HAVE_RTP_SYS
-    /* uses parital  structures */
-    #define XTIME(tl)  (0)
-    #define XGMTIME(c, t) my_gmtime((c))
-    #define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
-#elif defined(MICRIUM)
-    #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
-        #define XVALIDATE_DATE(d,f,t) NetSecure_ValidateDateHandler((d),(f),(t))
-    #else
-        #define XVALIDATE_DATE(d, f, t) (0)
-    #endif
-    #define NO_TIME_H
-    /* since Micrium not defining XTIME or XGMTIME, CERT_GEN not available */
-#elif defined(MICROCHIP_TCPIP_V5) || defined(MICROCHIP_TCPIP)
-    #include 
-    #define XTIME(t1) pic32_time((t1))
-    #define XGMTIME(c, t) gmtime((c))
-    #define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
-#elif defined(FREESCALE_MQX)
-    #define XTIME(t1)  mqx_time((t1))
-    #define XGMTIME(c, t) mqx_gmtime((c), (t))
-    #define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
-#elif defined(WOLFSSL_MDK_ARM)
-    #if defined(WOLFSSL_MDK5)
-        #include "cmsis_os.h"
-    #else
-        #include 
-    #endif
-    #undef RNG
-    #include "wolfssl_MDK_ARM.h"
-    #undef RNG
-    #define RNG wolfSSL_RNG /*for avoiding name conflict in "stm32f2xx.h" */
-    #define XTIME(tl)  (0)
-    #define XGMTIME(c, t) wolfssl_MDK_gmtime((c))
-    #define XVALIDATE_DATE(d, f, t)  ValidateDate((d), (f), (t))
-#elif defined(USER_TIME)
-    /* user time, and gmtime compatible functions, there is a gmtime 
-       implementation here that WINCE uses, so really just need some ticks
-       since the EPOCH 
-    */
-
-    struct tm {
-    int tm_sec;     /* seconds after the minute [0-60] */
-    int tm_min;     /* minutes after the hour [0-59] */
-    int tm_hour;    /* hours since midnight [0-23] */
-    int tm_mday;    /* day of the month [1-31] */
-    int tm_mon;     /* months since January [0-11] */
-    int tm_year;    /* years since 1900 */
-    int tm_wday;    /* days since Sunday [0-6] */
-    int tm_yday;    /* days since January 1 [0-365] */
-    int tm_isdst;   /* Daylight Savings Time flag */
-    long    tm_gmtoff;  /* offset from CUT in seconds */
-    char    *tm_zone;   /* timezone abbreviation */
-    };
-    typedef long time_t;
-
-    /* forward declaration */
-    struct tm* gmtime(const time_t* timer);
-    extern time_t XTIME(time_t * timer);
-
-    #define XGMTIME(c, t) gmtime((c))
-    #define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
-
-    #ifdef STACK_TRAP
-        /* for stack trap tracking, don't call os gmtime on OS X/linux,
-           uses a lot of stack spce */
-        extern time_t time(time_t * timer);
-        #define XTIME(tl)  time((tl))
-    #endif /* STACK_TRAP */
-
-#elif defined(TIME_OVERRIDES)
-    /* user would like to override time() and gmtime() functionality */
-
-    #ifndef HAVE_TIME_T_TYPE
-        typedef long time_t;
-    #endif
-    extern time_t XTIME(time_t * timer);
-
-    #ifndef HAVE_TM_TYPE
-        struct tm {
-            int  tm_sec;     /* seconds after the minute [0-60] */
-            int  tm_min;     /* minutes after the hour [0-59] */
-            int  tm_hour;    /* hours since midnight [0-23] */
-            int  tm_mday;    /* day of the month [1-31] */
-            int  tm_mon;     /* months since January [0-11] */
-            int  tm_year;    /* years since 1900 */
-            int  tm_wday;    /* days since Sunday [0-6] */
-            int  tm_yday;    /* days since January 1 [0-365] */
-            int  tm_isdst;   /* Daylight Savings Time flag */
-            long tm_gmtoff;  /* offset from CUT in seconds */
-            char *tm_zone;   /* timezone abbreviation */
-        };
-    #endif
-    extern struct tm* XGMTIME(const time_t* timer, struct tm* tmp);
-
-    #ifndef HAVE_VALIDATE_DATE
-        #define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
-    #endif
-#else
-    /* default */
-    /* uses complete  facility */
-    #include 
-    #define XTIME(tl)     time((tl))
-    #define XGMTIME(c, t) gmtime((c))
-    #define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
-#endif
-
-
-#ifdef _WIN32_WCE
-/* no time() or gmtime() even though in time.h header?? */
-
-#include 
-
-
-time_t time(time_t* timer)
-{
-    SYSTEMTIME     sysTime;
-    FILETIME       fTime;
-    ULARGE_INTEGER intTime;
-    time_t         localTime;
-
-    if (timer == NULL)
-        timer = &localTime;
-
-    GetSystemTime(&sysTime);
-    SystemTimeToFileTime(&sysTime, &fTime);
-
-    XMEMCPY(&intTime, &fTime, sizeof(FILETIME));
-    /* subtract EPOCH */
-    intTime.QuadPart -= 0x19db1ded53e8000;
-    /* to secs */
-    intTime.QuadPart /= 10000000;
-    *timer = (time_t)intTime.QuadPart;
-
-    return *timer;
-}
-
-#endif /*  _WIN32_WCE */
-#if defined( _WIN32_WCE ) || defined( USER_TIME )
-
-struct tm* gmtime(const time_t* timer)
-{
-    #define YEAR0          1900
-    #define EPOCH_YEAR     1970
-    #define SECS_DAY       (24L * 60L * 60L)
-    #define LEAPYEAR(year) (!((year) % 4) && (((year) % 100) || !((year) %400)))
-    #define YEARSIZE(year) (LEAPYEAR(year) ? 366 : 365)
-
-    static const int _ytab[2][12] =
-    {
-        {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
-        {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
-    };
-
-    static struct tm st_time;
-    struct tm* ret = &st_time;
-    time_t secs = *timer;
-    unsigned long dayclock, dayno;
-    int year = EPOCH_YEAR;
-
-    dayclock = (unsigned long)secs % SECS_DAY;
-    dayno    = (unsigned long)secs / SECS_DAY;
-
-    ret->tm_sec  = (int) dayclock % 60;
-    ret->tm_min  = (int)(dayclock % 3600) / 60;
-    ret->tm_hour = (int) dayclock / 3600;
-    ret->tm_wday = (int) (dayno + 4) % 7;        /* day 0 a Thursday */
-
-    while(dayno >= (unsigned long)YEARSIZE(year)) {
-        dayno -= YEARSIZE(year);
-        year++;
-    }
-
-    ret->tm_year = year - YEAR0;
-    ret->tm_yday = (int)dayno;
-    ret->tm_mon  = 0;
-
-    while(dayno >= (unsigned long)_ytab[LEAPYEAR(year)][ret->tm_mon]) {
-        dayno -= _ytab[LEAPYEAR(year)][ret->tm_mon];
-        ret->tm_mon++;
-    }
-
-    ret->tm_mday  = (int)++dayno;
-    ret->tm_isdst = 0;
-
-    return ret;
-}
-
-#endif /* _WIN32_WCE  || USER_TIME */
-
-
-#ifdef HAVE_RTP_SYS
-
-#define YEAR0          1900
-
-struct tm* my_gmtime(const time_t* timer)       /* has a gmtime() but hangs */
-{
-    static struct tm st_time;
-    struct tm* ret = &st_time;
-
-    DC_RTC_CALENDAR cal;
-    dc_rtc_time_get(&cal, TRUE);
-
-    ret->tm_year  = cal.year - YEAR0;       /* gm starts at 1900 */
-    ret->tm_mon   = cal.month - 1;          /* gm starts at 0 */
-    ret->tm_mday  = cal.day;
-    ret->tm_hour  = cal.hour;
-    ret->tm_min   = cal.minute;
-    ret->tm_sec   = cal.second;
-
-    return ret;
-}
-
-#endif /* HAVE_RTP_SYS */
-
-
-#if defined(MICROCHIP_TCPIP_V5) || defined(MICROCHIP_TCPIP)
-
-/*
- * time() is just a stub in Microchip libraries. We need our own
- * implementation. Use SNTP client to get seconds since epoch.
- */
-time_t pic32_time(time_t* timer)
-{
-#ifdef MICROCHIP_TCPIP_V5
-    DWORD sec = 0;
-#else
-    uint32_t sec = 0;
-#endif
-    time_t localTime;
-
-    if (timer == NULL)
-        timer = &localTime;
-
-#ifdef MICROCHIP_MPLAB_HARMONY
-    sec = TCPIP_SNTP_UTCSecondsGet();
-#else
-    sec = SNTPGetUTCSeconds();
-#endif
-    *timer = (time_t) sec;
-
-    return *timer;
-}
-
-#endif /* MICROCHIP_TCPIP */
-
-
-#ifdef FREESCALE_MQX
-
-time_t mqx_time(time_t* timer)
-{
-    time_t localTime;
-    TIME_STRUCT time_s;
-
-    if (timer == NULL)
-        timer = &localTime;
-
-    _time_get(&time_s);
-    *timer = (time_t) time_s.SECONDS;
-
-    return *timer;
-}
-
-/* CodeWarrior GCC toolchain only has gmtime_r(), no gmtime() */
-struct tm* mqx_gmtime(const time_t* clock, struct tm* tmpTime)
-{
-    return gmtime_r(clock, tmpTime);
-}
-
-#endif /* FREESCALE_MQX */
-
-#ifdef WOLFSSL_TIRTOS
-
-time_t XTIME(time_t * timer)
-{
-    time_t sec = 0;
-
-    sec = (time_t) Seconds_get();
-
-    if (timer != NULL)
-        *timer = sec;
-
-    return sec;
-}
-
-#endif /* WOLFSSL_TIRTOS */
-
-static INLINE word32 btoi(byte b)
-{
-    return b - 0x30;
-}
-
-
-/* two byte date/time, add to value */
-static INLINE void GetTime(int* value, const byte* date, int* idx)
-{
-    int i = *idx;
-
-    *value += btoi(date[i++]) * 10;
-    *value += btoi(date[i++]);
-
-    *idx = i;
-}
-
-
-#if defined(MICRIUM)
-
-CPU_INT32S NetSecure_ValidateDateHandler(CPU_INT08U *date, CPU_INT08U format,
-                                         CPU_INT08U dateType)
-{
-    CPU_BOOLEAN  rtn_code;
-    CPU_INT32S   i;
-    CPU_INT32S   val;    
-    CPU_INT16U   year;
-    CPU_INT08U   month;
-    CPU_INT16U   day;
-    CPU_INT08U   hour;
-    CPU_INT08U   min;
-    CPU_INT08U   sec;
-
-    i    = 0;
-    year = 0u;
-
-    if (format == ASN_UTC_TIME) {
-        if (btoi(date[0]) >= 5)
-            year = 1900;
-        else
-            year = 2000;
-    }
-    else  { /* format == GENERALIZED_TIME */
-        year += btoi(date[i++]) * 1000;
-        year += btoi(date[i++]) * 100;
-    }    
-
-    val = year;
-    GetTime(&val, date, &i);
-    year = (CPU_INT16U)val;
-
-    val = 0;
-    GetTime(&val, date, &i);   
-    month = (CPU_INT08U)val;   
-
-    val = 0;
-    GetTime(&val, date, &i);  
-    day = (CPU_INT16U)val;
-
-    val = 0;
-    GetTime(&val, date, &i);  
-    hour = (CPU_INT08U)val;
-
-    val = 0;
-    GetTime(&val, date, &i);  
-    min = (CPU_INT08U)val;
-
-    val = 0;
-    GetTime(&val, date, &i);  
-    sec = (CPU_INT08U)val;
-
-    return NetSecure_ValidateDate(year, month, day, hour, min, sec, dateType); 
-}
-
-#endif /* MICRIUM */
-
-
-WOLFSSL_LOCAL int GetLength(const byte* input, word32* inOutIdx, int* len,
-                           word32 maxIdx)
-{
-    int     length = 0;
-    word32  i = *inOutIdx;
-    byte    b;
-
-    *len = 0;    /* default length */
-
-    if ( (i+1) > maxIdx) {   /* for first read */
-        WOLFSSL_MSG("GetLength bad index on input");
-        return BUFFER_E;
-    }
-
-    b = input[i++];
-    if (b >= ASN_LONG_LENGTH) {        
-        word32 bytes = b & 0x7F;
-
-        if ( (i+bytes) > maxIdx) {   /* for reading bytes */
-            WOLFSSL_MSG("GetLength bad long length");
-            return BUFFER_E;
-        }
-
-        while (bytes--) {
-            b = input[i++];
-            length = (length << 8) | b;
-        }
-    }
-    else
-        length = b;
-    
-    if ( (i+length) > maxIdx) {   /* for user of length */
-        WOLFSSL_MSG("GetLength value exceeds buffer length");
-        return BUFFER_E;
-    }
-
-    *inOutIdx = i;
-    if (length > 0)
-        *len = length;
-
-    return length;
-}
-
-
-WOLFSSL_LOCAL int GetSequence(const byte* input, word32* inOutIdx, int* len,
-                           word32 maxIdx)
-{
-    int    length = -1;
-    word32 idx    = *inOutIdx;
-
-    if (input[idx++] != (ASN_SEQUENCE | ASN_CONSTRUCTED) ||
-            GetLength(input, &idx, &length, maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    *len      = length;
-    *inOutIdx = idx;
-
-    return length;
-}
-
-
-WOLFSSL_LOCAL int GetSet(const byte* input, word32* inOutIdx, int* len,
-                        word32 maxIdx)
-{
-    int    length = -1;
-    word32 idx    = *inOutIdx;
-
-    if (input[idx++] != (ASN_SET | ASN_CONSTRUCTED) ||
-            GetLength(input, &idx, &length, maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    *len      = length;
-    *inOutIdx = idx;
-
-    return length;
-}
-
-
-/* winodws header clash for WinCE using GetVersion */
-WOLFSSL_LOCAL int GetMyVersion(const byte* input, word32* inOutIdx, int* version)
-{
-    word32 idx = *inOutIdx;
-
-    WOLFSSL_ENTER("GetMyVersion");
-
-    if (input[idx++] != ASN_INTEGER)
-        return ASN_PARSE_E;
-
-    if (input[idx++] != 0x01)
-        return ASN_VERSION_E;
-
-    *version  = input[idx++];
-    *inOutIdx = idx;
-
-    return *version;
-}
-
-
-#ifndef NO_PWDBASED
-/* Get small count integer, 32 bits or less */
-static int GetShortInt(const byte* input, word32* inOutIdx, int* number)
-{
-    word32 idx = *inOutIdx;
-    word32 len;
-
-    *number = 0;
-
-    if (input[idx++] != ASN_INTEGER)
-        return ASN_PARSE_E;
-
-    len = input[idx++];
-    if (len > 4)
-        return ASN_PARSE_E;
-
-    while (len--) {
-        *number  = *number << 8 | input[idx++];
-    }
-
-    *inOutIdx = idx;
-
-    return *number;
-}
-#endif /* !NO_PWDBASED */
-
-
-/* May not have one, not an error */
-static int GetExplicitVersion(const byte* input, word32* inOutIdx, int* version)
-{
-    word32 idx = *inOutIdx;
-
-    WOLFSSL_ENTER("GetExplicitVersion");
-    if (input[idx++] == (ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED)) {
-        *inOutIdx = ++idx;  /* eat header */
-        return GetMyVersion(input, inOutIdx, version);
-    }
-
-    /* go back as is */
-    *version = 0;
-
-    return 0;
-}
-
-
-WOLFSSL_LOCAL int GetInt(mp_int* mpi, const byte* input, word32* inOutIdx,
-                  word32 maxIdx)
-{
-    word32 i = *inOutIdx;
-    byte   b = input[i++];
-    int    length;
-
-    if (b != ASN_INTEGER)
-        return ASN_PARSE_E;
-
-    if (GetLength(input, &i, &length, maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    if ( (b = input[i++]) == 0x00)
-        length--;
-    else
-        i--;
-
-    if (mp_init(mpi) != MP_OKAY)
-        return MP_INIT_E;
-
-    if (mp_read_unsigned_bin(mpi, (byte*)input + i, length) != 0) {
-        mp_clear(mpi);
-        return ASN_GETINT_E;
-    }
-
-    *inOutIdx = i + length;
-    return 0;
-}
-
-
-static int GetObjectId(const byte* input, word32* inOutIdx, word32* oid,
-                     word32 maxIdx)
-{
-    int    length;
-    word32 i = *inOutIdx;
-    byte   b;
-    *oid = 0;
-    
-    b = input[i++];
-    if (b != ASN_OBJECT_ID) 
-        return ASN_OBJECT_ID_E;
-    
-    if (GetLength(input, &i, &length, maxIdx) < 0)
-        return ASN_PARSE_E;
-    
-    while(length--)
-        *oid += input[i++];
-    /* just sum it up for now */
-    
-    *inOutIdx = i;
-    
-    return 0;
-}
-
-
-WOLFSSL_LOCAL int GetAlgoId(const byte* input, word32* inOutIdx, word32* oid,
-                     word32 maxIdx)
-{
-    int    length;
-    word32 i = *inOutIdx;
-    byte   b;
-    *oid = 0;
-   
-    WOLFSSL_ENTER("GetAlgoId");
-
-    if (GetSequence(input, &i, &length, maxIdx) < 0)
-        return ASN_PARSE_E;
-    
-    b = input[i++];
-    if (b != ASN_OBJECT_ID) 
-        return ASN_OBJECT_ID_E;
-    
-    if (GetLength(input, &i, &length, maxIdx) < 0)
-        return ASN_PARSE_E;
-    
-    while(length--) {
-        /* odd HC08 compiler behavior here when input[i++] */
-        *oid += input[i];
-        i++;
-    }
-    /* just sum it up for now */
-    
-    /* could have NULL tag and 0 terminator, but may not */
-    b = input[i++];
-    
-    if (b == ASN_TAG_NULL) {
-        b = input[i++];
-        if (b != 0)
-            return ASN_EXPECT_0_E;
-    }
-    else
-    /* go back, didn't have it */
-        i--;
-    
-    *inOutIdx = i;
-    
-    return 0;
-}
-
-#ifndef NO_RSA
-
-
-#ifdef HAVE_CAVIUM
-
-static int GetCaviumInt(byte** buff, word16* buffSz, const byte* input,
-                        word32* inOutIdx, word32 maxIdx, void* heap)
-{
-    word32 i = *inOutIdx;
-    byte   b = input[i++];
-    int    length;
-
-    if (b != ASN_INTEGER)
-        return ASN_PARSE_E;
-
-    if (GetLength(input, &i, &length, maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    if ( (b = input[i++]) == 0x00)
-        length--;
-    else
-        i--;
-
-    *buffSz = (word16)length;
-    *buff   = XMALLOC(*buffSz, heap, DYNAMIC_TYPE_CAVIUM_RSA);
-    if (*buff == NULL)
-        return MEMORY_E;
-
-    XMEMCPY(*buff, input + i, *buffSz);
-
-    *inOutIdx = i + length;
-    return 0;
-}
-
-static int CaviumRsaPrivateKeyDecode(const byte* input, word32* inOutIdx,
-                                     RsaKey* key, word32 inSz)
-{
-    int   version, length;
-    void* h = key->heap;
-
-    if (GetSequence(input, inOutIdx, &length, inSz) < 0)
-        return ASN_PARSE_E;
-
-    if (GetMyVersion(input, inOutIdx, &version) < 0)
-        return ASN_PARSE_E;
-
-    key->type = RSA_PRIVATE;
-
-    if (GetCaviumInt(&key->c_n,  &key->c_nSz,   input, inOutIdx, inSz, h) < 0 ||
-        GetCaviumInt(&key->c_e,  &key->c_eSz,   input, inOutIdx, inSz, h) < 0 ||
-        GetCaviumInt(&key->c_d,  &key->c_dSz,   input, inOutIdx, inSz, h) < 0 ||
-        GetCaviumInt(&key->c_p,  &key->c_pSz,   input, inOutIdx, inSz, h) < 0 ||
-        GetCaviumInt(&key->c_q,  &key->c_qSz,   input, inOutIdx, inSz, h) < 0 ||
-        GetCaviumInt(&key->c_dP, &key->c_dP_Sz, input, inOutIdx, inSz, h) < 0 ||
-        GetCaviumInt(&key->c_dQ, &key->c_dQ_Sz, input, inOutIdx, inSz, h) < 0 ||
-        GetCaviumInt(&key->c_u,  &key->c_uSz,   input, inOutIdx, inSz, h) < 0 )
-            return ASN_RSA_KEY_E;
-
-    return 0;
-}
-
-
-#endif /* HAVE_CAVIUM */
-
-int wc_RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, RsaKey* key,
-                        word32 inSz)
-{
-    int    version, length;
-
-#ifdef HAVE_CAVIUM
-    if (key->magic == WOLFSSL_RSA_CAVIUM_MAGIC)
-        return CaviumRsaPrivateKeyDecode(input, inOutIdx, key, inSz);
-#endif
-
-    if (GetSequence(input, inOutIdx, &length, inSz) < 0)
-        return ASN_PARSE_E;
-
-    if (GetMyVersion(input, inOutIdx, &version) < 0)
-        return ASN_PARSE_E;
-
-    key->type = RSA_PRIVATE;
-
-    if (GetInt(&key->n,  input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->e,  input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->d,  input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->p,  input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->q,  input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->dP, input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->dQ, input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->u,  input, inOutIdx, inSz) < 0 )  return ASN_RSA_KEY_E;
-
-    return 0;
-}
-
-#endif /* NO_RSA */
-
-/* Remove PKCS8 header, move beginning of traditional to beginning of input */
-int ToTraditional(byte* input, word32 sz)
-{
-    word32 inOutIdx = 0, oid;
-    int    version, length;
-
-    if (GetSequence(input, &inOutIdx, &length, sz) < 0)
-        return ASN_PARSE_E;
-
-    if (GetMyVersion(input, &inOutIdx, &version) < 0)
-        return ASN_PARSE_E;
-
-    if (GetAlgoId(input, &inOutIdx, &oid, sz) < 0)
-        return ASN_PARSE_E;
-
-    if (input[inOutIdx] == ASN_OBJECT_ID) {
-        /* pkcs8 ecc uses slightly different format */
-        inOutIdx++;  /* past id */
-        if (GetLength(input, &inOutIdx, &length, sz) < 0)
-            return ASN_PARSE_E;
-        inOutIdx += length;  /* over sub id, key input will verify */
-    }
-
-    if (input[inOutIdx++] != ASN_OCTET_STRING)
-        return ASN_PARSE_E;
-
-    if (GetLength(input, &inOutIdx, &length, sz) < 0)
-        return ASN_PARSE_E;
-
-    XMEMMOVE(input, input + inOutIdx, length);
-
-    return length;
-}
-
-
-#ifndef NO_PWDBASED
-
-/* Check To see if PKCS version algo is supported, set id if it is return 0
-   < 0 on error */
-static int CheckAlgo(int first, int second, int* id, int* version)
-{
-    *id      = ALGO_ID_E;
-    *version = PKCS5;   /* default */
-
-    if (first == 1) {
-        switch (second) {
-        case 1:
-            *id = PBE_SHA1_RC4_128;
-            *version = PKCS12;
-            return 0;
-        case 3:
-            *id = PBE_SHA1_DES3;
-            *version = PKCS12;
-            return 0;
-        default:
-            return ALGO_ID_E;
-        }
-    }
-
-    if (first != PKCS5)
-        return ASN_INPUT_E;  /* VERSION ERROR */
-
-    if (second == PBES2) {
-        *version = PKCS5v2;
-        return 0;
-    }
-
-    switch (second) {
-    case 3:                   /* see RFC 2898 for ids */
-        *id = PBE_MD5_DES;
-        return 0;
-    case 10:
-        *id = PBE_SHA1_DES;
-        return 0;
-    default:
-        return ALGO_ID_E;
-
-    }
-}
-
-
-/* Check To see if PKCS v2 algo is supported, set id if it is return 0
-   < 0 on error */
-static int CheckAlgoV2(int oid, int* id)
-{
-    switch (oid) {
-    case 69:
-        *id = PBE_SHA1_DES;
-        return 0;
-    case 652:
-        *id = PBE_SHA1_DES3;
-        return 0;
-    default:
-        return ALGO_ID_E;
-
-    }
-}
-
-
-/* Decrypt intput in place from parameters based on id */
-static int DecryptKey(const char* password, int passwordSz, byte* salt,
-                      int saltSz, int iterations, int id, byte* input,
-                      int length, int version, byte* cbcIv)
-{
-    int typeH;
-    int derivedLen;
-    int decryptionType;
-    int ret = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    byte* key;
-#else
-    byte key[MAX_KEY_SIZE];
-#endif
-
-    switch (id) {
-        case PBE_MD5_DES:
-            typeH = MD5;
-            derivedLen = 16;           /* may need iv for v1.5 */
-            decryptionType = DES_TYPE;
-            break;
-
-        case PBE_SHA1_DES:
-            typeH = SHA;
-            derivedLen = 16;           /* may need iv for v1.5 */
-            decryptionType = DES_TYPE;
-            break;
-
-        case PBE_SHA1_DES3:
-            typeH = SHA;
-            derivedLen = 32;           /* may need iv for v1.5 */
-            decryptionType = DES3_TYPE;
-            break;
-
-        case PBE_SHA1_RC4_128:
-            typeH = SHA;
-            derivedLen = 16;
-            decryptionType = RC4_TYPE;
-            break;
-
-        default:
-            return ALGO_ID_E;
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    key = (byte*)XMALLOC(MAX_KEY_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (key == NULL)
-        return MEMORY_E;
-#endif
-
-    if (version == PKCS5v2)
-        ret = wc_PBKDF2(key, (byte*)password, passwordSz, salt, saltSz, iterations,
-               derivedLen, typeH);
-#ifndef NO_SHA
-    else if (version == PKCS5)
-        ret = wc_PBKDF1(key, (byte*)password, passwordSz, salt, saltSz, iterations,
-               derivedLen, typeH);
-#endif
-    else if (version == PKCS12) {
-        int  i, idx = 0;
-        byte unicodePasswd[MAX_UNICODE_SZ];
-
-        if ( (passwordSz * 2 + 2) > (int)sizeof(unicodePasswd)) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return UNICODE_SIZE_E; 
-        }
-
-        for (i = 0; i < passwordSz; i++) {
-            unicodePasswd[idx++] = 0x00;
-            unicodePasswd[idx++] = (byte)password[i];
-        }
-        /* add trailing NULL */
-        unicodePasswd[idx++] = 0x00;
-        unicodePasswd[idx++] = 0x00;
-
-        ret =  wc_PKCS12_PBKDF(key, unicodePasswd, idx, salt, saltSz,
-                            iterations, derivedLen, typeH, 1);
-        if (decryptionType != RC4_TYPE)
-            ret += wc_PKCS12_PBKDF(cbcIv, unicodePasswd, idx, salt, saltSz,
-                                iterations, 8, typeH, 2);
-    }
-    else {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ALGO_ID_E;
-    }
-
-    if (ret != 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ret;
-    }
-
-    switch (decryptionType) {
-#ifndef NO_DES3
-        case DES_TYPE:
-        {
-            Des    dec;
-            byte*  desIv = key + 8;
-
-            if (version == PKCS5v2 || version == PKCS12)
-                desIv = cbcIv;
-
-            ret = wc_Des_SetKey(&dec, key, desIv, DES_DECRYPTION);
-            if (ret != 0) {
-#ifdef WOLFSSL_SMALL_STACK
-                XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-                return ret;
-            }
-
-            wc_Des_CbcDecrypt(&dec, input, input, length);
-            break;
-        }
-
-        case DES3_TYPE:
-        {
-            Des3   dec;
-            byte*  desIv = key + 24;
-
-            if (version == PKCS5v2 || version == PKCS12)
-                desIv = cbcIv;
-            ret = wc_Des3_SetKey(&dec, key, desIv, DES_DECRYPTION);
-            if (ret != 0) {
-#ifdef WOLFSSL_SMALL_STACK
-                XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-                return ret;
-            }
-            ret = wc_Des3_CbcDecrypt(&dec, input, input, length);
-            if (ret != 0) {
-#ifdef WOLFSSL_SMALL_STACK
-                XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-                return ret;
-            }
-            break;
-        }
-#endif
-#ifndef NO_RC4
-        case RC4_TYPE:
-        {
-            Arc4    dec;
-
-            wc_Arc4SetKey(&dec, key, derivedLen);
-            wc_Arc4Process(&dec, input, input, length);
-            break;
-        }
-#endif
-
-        default:
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ALGO_ID_E; 
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return 0;
-}
-
-
-/* Remove Encrypted PKCS8 header, move beginning of traditional to beginning
-   of input */
-int ToTraditionalEnc(byte* input, word32 sz,const char* password,int passwordSz)
-{
-    word32 inOutIdx = 0, oid;
-    int    first, second, length, version, saltSz, id;
-    int    iterations = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    byte*  salt = NULL;
-    byte*  cbcIv = NULL;
-#else
-    byte   salt[MAX_SALT_SIZE];
-    byte   cbcIv[MAX_IV_SIZE];
-#endif
-    
-    if (GetSequence(input, &inOutIdx, &length, sz) < 0)
-        return ASN_PARSE_E;
-
-    if (GetAlgoId(input, &inOutIdx, &oid, sz) < 0)
-        return ASN_PARSE_E;
-    
-    first  = input[inOutIdx - 2];   /* PKCS version alwyas 2nd to last byte */
-    second = input[inOutIdx - 1];   /* version.algo, algo id last byte */
-
-    if (CheckAlgo(first, second, &id, &version) < 0)
-        return ASN_INPUT_E;  /* Algo ID error */
-
-    if (version == PKCS5v2) {
-
-        if (GetSequence(input, &inOutIdx, &length, sz) < 0)
-            return ASN_PARSE_E;
-
-        if (GetAlgoId(input, &inOutIdx, &oid, sz) < 0)
-            return ASN_PARSE_E;
-
-        if (oid != PBKDF2_OID)
-            return ASN_PARSE_E;
-    }
-
-    if (GetSequence(input, &inOutIdx, &length, sz) < 0)
-        return ASN_PARSE_E;
-
-    if (input[inOutIdx++] != ASN_OCTET_STRING)
-        return ASN_PARSE_E;
-    
-    if (GetLength(input, &inOutIdx, &saltSz, sz) < 0)
-        return ASN_PARSE_E;
-
-    if (saltSz > MAX_SALT_SIZE)
-        return ASN_PARSE_E;
-     
-#ifdef WOLFSSL_SMALL_STACK
-    salt = (byte*)XMALLOC(MAX_SALT_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (salt == NULL)
-        return MEMORY_E;
-#endif
-
-    XMEMCPY(salt, &input[inOutIdx], saltSz);
-    inOutIdx += saltSz;
-
-    if (GetShortInt(input, &inOutIdx, &iterations) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(salt,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ASN_PARSE_E;
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    cbcIv = (byte*)XMALLOC(MAX_IV_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (cbcIv == NULL) {
-        XFREE(salt,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#endif
-
-    if (version == PKCS5v2) {
-        /* get encryption algo */
-        if (GetAlgoId(input, &inOutIdx, &oid, sz) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(salt,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(cbcIv, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ASN_PARSE_E;
-        }
-
-        if (CheckAlgoV2(oid, &id) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(salt,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(cbcIv, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ASN_PARSE_E;  /* PKCS v2 algo id error */
-        }
-
-        if (input[inOutIdx++] != ASN_OCTET_STRING) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(salt,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(cbcIv, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ASN_PARSE_E;
-        }
-    
-        if (GetLength(input, &inOutIdx, &length, sz) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(salt,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(cbcIv, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ASN_PARSE_E;
-        }
-
-        XMEMCPY(cbcIv, &input[inOutIdx], length);
-        inOutIdx += length;
-    }
-
-    if (input[inOutIdx++] != ASN_OCTET_STRING) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(salt,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(cbcIv, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ASN_PARSE_E;
-    }
-
-    if (GetLength(input, &inOutIdx, &length, sz) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(salt,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(cbcIv, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ASN_PARSE_E;
-    }
-
-    if (DecryptKey(password, passwordSz, salt, saltSz, iterations, id,
-                   input + inOutIdx, length, version, cbcIv) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(salt,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(cbcIv, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ASN_INPUT_E;  /* decrypt failure */
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(salt,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(cbcIv, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    XMEMMOVE(input, input + inOutIdx, length);
-    return ToTraditional(input, length);
-}
-
-#endif /* NO_PWDBASED */
-
-#ifndef NO_RSA
-
-int wc_RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey* key,
-                       word32 inSz)
-{
-    int    length;
-
-    if (GetSequence(input, inOutIdx, &length, inSz) < 0)
-        return ASN_PARSE_E;
-
-    key->type = RSA_PUBLIC;
-
-#if defined(OPENSSL_EXTRA) || defined(RSA_DECODE_EXTRA)
-    {
-    byte b = input[*inOutIdx];
-    if (b != ASN_INTEGER) {
-        /* not from decoded cert, will have algo id, skip past */
-        if (GetSequence(input, inOutIdx, &length, inSz) < 0)
-            return ASN_PARSE_E;
-        
-        b = input[(*inOutIdx)++];
-        if (b != ASN_OBJECT_ID) 
-            return ASN_OBJECT_ID_E;
-        
-        if (GetLength(input, inOutIdx, &length, inSz) < 0)
-            return ASN_PARSE_E;
-        
-        *inOutIdx += length;   /* skip past */
-        
-        /* could have NULL tag and 0 terminator, but may not */
-        b = input[(*inOutIdx)++];
-        
-        if (b == ASN_TAG_NULL) {
-            b = input[(*inOutIdx)++];
-            if (b != 0) 
-                return ASN_EXPECT_0_E;
-        }
-        else
-        /* go back, didn't have it */
-            (*inOutIdx)--;
-        
-        /* should have bit tag length and seq next */
-        b = input[(*inOutIdx)++];
-        if (b != ASN_BIT_STRING)
-            return ASN_BITSTR_E;
-        
-        if (GetLength(input, inOutIdx, &length, inSz) < 0)
-            return ASN_PARSE_E;
-        
-        /* could have 0 */
-        b = input[(*inOutIdx)++];
-        if (b != 0)
-            (*inOutIdx)--;
-        
-        if (GetSequence(input, inOutIdx, &length, inSz) < 0)
-            return ASN_PARSE_E;
-    }  /* end if */
-    }  /* openssl var block */
-#endif /* OPENSSL_EXTRA */
-
-    if (GetInt(&key->n,  input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->e,  input, inOutIdx, inSz) < 0 )  return ASN_RSA_KEY_E;
-
-    return 0;
-}
-
-/* import RSA public key elements (n, e) into RsaKey structure (key) */
-int wc_RsaPublicKeyDecodeRaw(const byte* n, word32 nSz, const byte* e,
-                             word32 eSz, RsaKey* key)
-{
-    if (n == NULL || e == NULL || key == NULL)
-        return BAD_FUNC_ARG;
-
-    key->type = RSA_PUBLIC;
-
-    if (mp_init(&key->n) != MP_OKAY)
-        return MP_INIT_E;
-
-    if (mp_read_unsigned_bin(&key->n, n, nSz) != 0) {
-        mp_clear(&key->n);
-        return ASN_GETINT_E;
-    }
-
-    if (mp_init(&key->e) != MP_OKAY) {
-        mp_clear(&key->n);
-        return MP_INIT_E;
-    }
-
-    if (mp_read_unsigned_bin(&key->e, e, eSz) != 0) {
-        mp_clear(&key->n);
-        mp_clear(&key->e);
-        return ASN_GETINT_E;
-    }
-
-    return 0;
-}
-
-#endif
-
-#ifndef NO_DH
-
-int wc_DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key, word32 inSz)
-{
-    int    length;
-
-    if (GetSequence(input, inOutIdx, &length, inSz) < 0)
-        return ASN_PARSE_E;
-
-    if (GetInt(&key->p,  input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->g,  input, inOutIdx, inSz) < 0 )  return ASN_DH_KEY_E;
-
-    return 0;
-}
-
-
-int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p, word32* pInOutSz,
-                 byte* g, word32* gInOutSz)
-{
-    word32 i = 0;
-    byte   b;
-    int    length;
-
-    if (GetSequence(input, &i, &length, inSz) < 0)
-        return ASN_PARSE_E;
-
-    b = input[i++];
-    if (b != ASN_INTEGER)
-        return ASN_PARSE_E;
-
-    if (GetLength(input, &i, &length, inSz) < 0)
-        return ASN_PARSE_E;
-
-    if ( (b = input[i++]) == 0x00)
-        length--;
-    else
-        i--;
-
-    if (length <= (int)*pInOutSz) {
-        XMEMCPY(p, &input[i], length);
-        *pInOutSz = length;
-    }
-    else
-        return BUFFER_E;
-
-    i += length;
-
-    b = input[i++];
-    if (b != ASN_INTEGER)
-        return ASN_PARSE_E;
-
-    if (GetLength(input, &i, &length, inSz) < 0)
-        return ASN_PARSE_E;
-
-    if (length <= (int)*gInOutSz) {
-        XMEMCPY(g, &input[i], length);
-        *gInOutSz = length;
-    }
-    else
-        return BUFFER_E;
-
-    return 0;
-}
-
-#endif /* NO_DH */
-
-
-#ifndef NO_DSA
-
-int DsaPublicKeyDecode(const byte* input, word32* inOutIdx, DsaKey* key,
-                        word32 inSz)
-{
-    int    length;
-
-    if (GetSequence(input, inOutIdx, &length, inSz) < 0)
-        return ASN_PARSE_E;
-
-    if (GetInt(&key->p,  input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->q,  input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->g,  input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->y,  input, inOutIdx, inSz) < 0 )  return ASN_DH_KEY_E;
-
-    key->type = DSA_PUBLIC;
-    return 0;
-}
-
-
-int DsaPrivateKeyDecode(const byte* input, word32* inOutIdx, DsaKey* key,
-                        word32 inSz)
-{
-    int    length, version;
-
-    if (GetSequence(input, inOutIdx, &length, inSz) < 0)
-        return ASN_PARSE_E;
-
-    if (GetMyVersion(input, inOutIdx, &version) < 0)
-        return ASN_PARSE_E;
-
-    if (GetInt(&key->p,  input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->q,  input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->g,  input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->y,  input, inOutIdx, inSz) < 0 ||
-        GetInt(&key->x,  input, inOutIdx, inSz) < 0 )  return ASN_DH_KEY_E;
-
-    key->type = DSA_PRIVATE;
-    return 0;
-}
-
-#endif /* NO_DSA */
-
-
-void InitDecodedCert(DecodedCert* cert, byte* source, word32 inSz, void* heap)
-{
-    cert->publicKey       = 0;
-    cert->pubKeySize      = 0;
-    cert->pubKeyStored    = 0;
-    cert->version         = 0;
-    cert->signature       = 0;
-    cert->subjectCN       = 0;
-    cert->subjectCNLen    = 0;
-    cert->subjectCNEnc    = CTC_UTF8;
-    cert->subjectCNStored = 0;
-    cert->weOwnAltNames   = 0;
-    cert->altNames        = NULL;
-#ifndef IGNORE_NAME_CONSTRAINTS
-    cert->altEmailNames   = NULL;
-    cert->permittedNames  = NULL;
-    cert->excludedNames   = NULL;
-#endif /* IGNORE_NAME_CONSTRAINTS */
-    cert->issuer[0]       = '\0';
-    cert->subject[0]      = '\0';
-    cert->source          = source;  /* don't own */
-    cert->srcIdx          = 0;
-    cert->maxIdx          = inSz;    /* can't go over this index */
-    cert->heap            = heap;
-    XMEMSET(cert->serial, 0, EXTERNAL_SERIAL_SIZE);
-    cert->serialSz        = 0;
-    cert->extensions      = 0;
-    cert->extensionsSz    = 0;
-    cert->extensionsIdx   = 0;
-    cert->extAuthInfo     = NULL;
-    cert->extAuthInfoSz   = 0;
-    cert->extCrlInfo      = NULL;
-    cert->extCrlInfoSz    = 0;
-    XMEMSET(cert->extSubjKeyId, 0, KEYID_SIZE);
-    cert->extSubjKeyIdSet = 0;
-    XMEMSET(cert->extAuthKeyId, 0, KEYID_SIZE);
-    cert->extAuthKeyIdSet = 0;
-    cert->extKeyUsageSet  = 0;
-    cert->extKeyUsage     = 0;
-    cert->extExtKeyUsageSet = 0;
-    cert->extExtKeyUsage    = 0;
-    cert->isCA            = 0;
-#ifdef HAVE_PKCS7
-    cert->issuerRaw       = NULL;
-    cert->issuerRawLen    = 0;
-#endif
-#ifdef WOLFSSL_CERT_GEN
-    cert->subjectSN       = 0;
-    cert->subjectSNLen    = 0;
-    cert->subjectSNEnc    = CTC_UTF8;
-    cert->subjectC        = 0;
-    cert->subjectCLen     = 0;
-    cert->subjectCEnc     = CTC_PRINTABLE;
-    cert->subjectL        = 0;
-    cert->subjectLLen     = 0;
-    cert->subjectLEnc     = CTC_UTF8;
-    cert->subjectST       = 0;
-    cert->subjectSTLen    = 0;
-    cert->subjectSTEnc    = CTC_UTF8;
-    cert->subjectO        = 0;
-    cert->subjectOLen     = 0;
-    cert->subjectOEnc     = CTC_UTF8;
-    cert->subjectOU       = 0;
-    cert->subjectOULen    = 0;
-    cert->subjectOUEnc    = CTC_UTF8;
-    cert->subjectEmail    = 0;
-    cert->subjectEmailLen = 0;
-#endif /* WOLFSSL_CERT_GEN */
-    cert->beforeDate      = NULL;
-    cert->beforeDateLen   = 0;
-    cert->afterDate       = NULL;
-    cert->afterDateLen    = 0;
-#ifdef OPENSSL_EXTRA
-    XMEMSET(&cert->issuerName, 0, sizeof(DecodedName));
-    XMEMSET(&cert->subjectName, 0, sizeof(DecodedName));
-    cert->extBasicConstSet = 0;
-    cert->extBasicConstCrit = 0;
-    cert->extBasicConstPlSet = 0;
-    cert->pathLength = 0;
-    cert->extSubjAltNameSet = 0;
-    cert->extSubjAltNameCrit = 0;
-    cert->extAuthKeyIdCrit = 0;
-    cert->extSubjKeyIdCrit = 0;
-    cert->extKeyUsageCrit = 0;
-    cert->extExtKeyUsageCrit = 0;
-    cert->extExtKeyUsageSrc = NULL;
-    cert->extExtKeyUsageSz = 0;
-    cert->extExtKeyUsageCount = 0;
-    cert->extAuthKeyIdSrc = NULL;
-    cert->extAuthKeyIdSz = 0;
-    cert->extSubjKeyIdSrc = NULL;
-    cert->extSubjKeyIdSz = 0;
-#endif /* OPENSSL_EXTRA */
-#if defined(OPENSSL_EXTRA) || !defined(IGNORE_NAME_CONSTRAINTS)
-    cert->extNameConstraintSet = 0;
-#endif /* OPENSSL_EXTRA || !IGNORE_NAME_CONSTRAINTS */
-#ifdef HAVE_ECC
-    cert->pkCurveOID = 0;
-#endif /* HAVE_ECC */
-#ifdef WOLFSSL_SEP
-    cert->deviceTypeSz = 0;
-    cert->deviceType = NULL;
-    cert->hwTypeSz = 0;
-    cert->hwType = NULL;
-    cert->hwSerialNumSz = 0;
-    cert->hwSerialNum = NULL;
-    #ifdef OPENSSL_EXTRA
-        cert->extCertPolicySet = 0;
-        cert->extCertPolicyCrit = 0;
-    #endif /* OPENSSL_EXTRA */
-#endif /* WOLFSSL_SEP */
-}
-
-
-void FreeAltNames(DNS_entry* altNames, void* heap)
-{
-    (void)heap;
-
-    while (altNames) {
-        DNS_entry* tmp = altNames->next;
-
-        XFREE(altNames->name, heap, DYNAMIC_TYPE_ALTNAME);
-        XFREE(altNames,       heap, DYNAMIC_TYPE_ALTNAME);
-        altNames = tmp;
-    }
-}
-
-#ifndef IGNORE_NAME_CONSTRAINTS
-
-void FreeNameSubtrees(Base_entry* names, void* heap)
-{
-    (void)heap;
-
-    while (names) {
-        Base_entry* tmp = names->next;
-
-        XFREE(names->name, heap, DYNAMIC_TYPE_ALTNAME);
-        XFREE(names,       heap, DYNAMIC_TYPE_ALTNAME);
-        names = tmp;
-    }
-}
-
-#endif /* IGNORE_NAME_CONSTRAINTS */
-
-void FreeDecodedCert(DecodedCert* cert)
-{
-    if (cert->subjectCNStored == 1)
-        XFREE(cert->subjectCN, cert->heap, DYNAMIC_TYPE_SUBJECT_CN);
-    if (cert->pubKeyStored == 1)
-        XFREE(cert->publicKey, cert->heap, DYNAMIC_TYPE_PUBLIC_KEY);
-    if (cert->weOwnAltNames && cert->altNames)
-        FreeAltNames(cert->altNames, cert->heap);
-#ifndef IGNORE_NAME_CONSTRAINTS
-    if (cert->altEmailNames)
-        FreeAltNames(cert->altEmailNames, cert->heap);
-    if (cert->permittedNames)
-        FreeNameSubtrees(cert->permittedNames, cert->heap);
-    if (cert->excludedNames)
-        FreeNameSubtrees(cert->excludedNames, cert->heap);
-#endif /* IGNORE_NAME_CONSTRAINTS */
-#ifdef WOLFSSL_SEP
-    XFREE(cert->deviceType, cert->heap, 0);
-    XFREE(cert->hwType, cert->heap, 0);
-    XFREE(cert->hwSerialNum, cert->heap, 0);
-#endif /* WOLFSSL_SEP */
-#ifdef OPENSSL_EXTRA
-    if (cert->issuerName.fullName != NULL)
-        XFREE(cert->issuerName.fullName, NULL, DYNAMIC_TYPE_X509);
-    if (cert->subjectName.fullName != NULL)
-        XFREE(cert->subjectName.fullName, NULL, DYNAMIC_TYPE_X509);
-#endif /* OPENSSL_EXTRA */
-}
-
-
-static int GetCertHeader(DecodedCert* cert)
-{
-    int ret = 0, len;
-    byte serialTmp[EXTERNAL_SERIAL_SIZE];
-#if defined(WOLFSSL_SMALL_STACK) && defined(USE_FAST_MATH)
-    mp_int* mpi = NULL;
-#else
-    mp_int stack_mpi;
-    mp_int* mpi = &stack_mpi;
-#endif
-
-    if (GetSequence(cert->source, &cert->srcIdx, &len, cert->maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    cert->certBegin = cert->srcIdx;
-
-    if (GetSequence(cert->source, &cert->srcIdx, &len, cert->maxIdx) < 0)
-        return ASN_PARSE_E;
-    cert->sigIndex = len + cert->srcIdx;
-
-    if (GetExplicitVersion(cert->source, &cert->srcIdx, &cert->version) < 0)
-        return ASN_PARSE_E;
-
-#if defined(WOLFSSL_SMALL_STACK) && defined(USE_FAST_MATH)
-    mpi = (mp_int*)XMALLOC(sizeof(mp_int), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (mpi == NULL)
-        return MEMORY_E;
-#endif
-
-    if (GetInt(mpi, cert->source, &cert->srcIdx, cert->maxIdx) < 0) {
-#if defined(WOLFSSL_SMALL_STACK) && defined(USE_FAST_MATH)
-        XFREE(mpi, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ASN_PARSE_E;
-    }
-
-    len = mp_unsigned_bin_size(mpi);
-    if (len < (int)sizeof(serialTmp)) {
-        if ( (ret = mp_to_unsigned_bin(mpi, serialTmp)) == MP_OKAY) {
-            XMEMCPY(cert->serial, serialTmp, len);
-            cert->serialSz = len;
-        }
-    }
-    mp_clear(mpi);
-
-#if defined(WOLFSSL_SMALL_STACK) && defined(USE_FAST_MATH)
-    XFREE(mpi, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-#if !defined(NO_RSA)
-/* Store Rsa Key, may save later, Dsa could use in future */
-static int StoreRsaKey(DecodedCert* cert)
-{
-    int    length;
-    word32 recvd = cert->srcIdx;
-
-    if (GetSequence(cert->source, &cert->srcIdx, &length, cert->maxIdx) < 0)
-        return ASN_PARSE_E;
-   
-    recvd = cert->srcIdx - recvd;
-    length += recvd;
-
-    while (recvd--)
-       cert->srcIdx--;
-
-    cert->pubKeySize = length;
-    cert->publicKey = cert->source + cert->srcIdx;
-    cert->srcIdx += length;
-
-    return 0;
-}
-#endif
-
-
-#ifdef HAVE_ECC
-
-    /* return 0 on sucess if the ECC curve oid sum is supported */
-    static int CheckCurve(word32 oid)
-    {
-        int ret = 0;
-
-        switch (oid) {
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC160)
-            case ECC_160R1:
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC192)
-            case ECC_192R1:
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC224)
-            case ECC_224R1:
-#endif
-#if defined(HAVE_ALL_CURVES) || !defined(NO_ECC256)
-            case ECC_256R1:
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC384)
-            case ECC_384R1:
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC521)
-            case ECC_521R1:
-#endif
-                break;
-
-            default:
-                ret = ALGO_ID_E;
-        }
-
-        return ret;
-    }
-
-#endif /* HAVE_ECC */
-
-
-static int GetKey(DecodedCert* cert)
-{
-    int length;
-#ifdef HAVE_NTRU
-    int tmpIdx = cert->srcIdx;
-#endif
-
-    if (GetSequence(cert->source, &cert->srcIdx, &length, cert->maxIdx) < 0)
-        return ASN_PARSE_E;
-   
-    if (GetAlgoId(cert->source, &cert->srcIdx, &cert->keyOID, cert->maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    switch (cert->keyOID) {
-   #ifndef NO_RSA
-        case RSAk:
-        {
-            byte b = cert->source[cert->srcIdx++];
-            if (b != ASN_BIT_STRING)
-                return ASN_BITSTR_E;
-
-            if (GetLength(cert->source,&cert->srcIdx,&length,cert->maxIdx) < 0)
-                return ASN_PARSE_E;
-            b = cert->source[cert->srcIdx++];
-            if (b != 0x00)
-                return ASN_EXPECT_0_E;
-    
-            return StoreRsaKey(cert);
-        }
-
-    #endif /* NO_RSA */
-    #ifdef HAVE_NTRU
-        case NTRUk:
-        {
-            const byte* key = &cert->source[tmpIdx];
-            byte*       next = (byte*)key;
-            word16      keyLen;
-            word32      rc;
-            word32      remaining = cert->maxIdx - cert->srcIdx;
-#ifdef WOLFSSL_SMALL_STACK
-            byte*       keyBlob = NULL;
-#else
-            byte        keyBlob[MAX_NTRU_KEY_SZ];
-#endif
-            rc = ntru_crypto_ntru_encrypt_subjectPublicKeyInfo2PublicKey(key,
-                                &keyLen, NULL, &next, &remaining);
-            if (rc != NTRU_OK)
-                return ASN_NTRU_KEY_E;
-            if (keyLen > MAX_NTRU_KEY_SZ)
-                return ASN_NTRU_KEY_E;
-
-#ifdef WOLFSSL_SMALL_STACK
-            keyBlob = (byte*)XMALLOC(MAX_NTRU_KEY_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            if (keyBlob == NULL)
-                return MEMORY_E;
-#endif
-
-            rc = ntru_crypto_ntru_encrypt_subjectPublicKeyInfo2PublicKey(key,
-                                &keyLen, keyBlob, &next, &remaining);
-            if (rc != NTRU_OK) {
-#ifdef WOLFSSL_SMALL_STACK
-                XFREE(keyBlob, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-                return ASN_NTRU_KEY_E;
-            }
-
-            if ( (next - key) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-                XFREE(keyBlob, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-                return ASN_NTRU_KEY_E;
-            }
-
-            cert->srcIdx = tmpIdx + (int)(next - key);
-
-            cert->publicKey = (byte*) XMALLOC(keyLen, cert->heap,
-                                              DYNAMIC_TYPE_PUBLIC_KEY);
-            if (cert->publicKey == NULL) {
-#ifdef WOLFSSL_SMALL_STACK
-                XFREE(keyBlob, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-                return MEMORY_E;
-            }
-            XMEMCPY(cert->publicKey, keyBlob, keyLen);
-            cert->pubKeyStored = 1;
-            cert->pubKeySize   = keyLen;
-
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(keyBlob, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-            return 0;
-        }
-    #endif /* HAVE_NTRU */
-    #ifdef HAVE_ECC
-        case ECDSAk:
-        {
-            int    oidSz = 0;
-            byte   b = cert->source[cert->srcIdx++];
-        
-            if (b != ASN_OBJECT_ID) 
-                return ASN_OBJECT_ID_E;
-
-            if (GetLength(cert->source,&cert->srcIdx,&oidSz,cert->maxIdx) < 0)
-                return ASN_PARSE_E;
-
-            while(oidSz--)
-                cert->pkCurveOID += cert->source[cert->srcIdx++];
-
-            if (CheckCurve(cert->pkCurveOID) < 0)
-                return ECC_CURVE_OID_E;
-
-            /* key header */
-            b = cert->source[cert->srcIdx++];
-            if (b != ASN_BIT_STRING)
-                return ASN_BITSTR_E;
-
-            if (GetLength(cert->source,&cert->srcIdx,&length,cert->maxIdx) < 0)
-                return ASN_PARSE_E;
-            b = cert->source[cert->srcIdx++];
-            if (b != 0x00)
-                return ASN_EXPECT_0_E;
-
-            /* actual key, use length - 1 since ate preceding 0 */
-            length -= 1;
-
-            cert->publicKey = (byte*) XMALLOC(length, cert->heap,
-                                              DYNAMIC_TYPE_PUBLIC_KEY);
-            if (cert->publicKey == NULL)
-                return MEMORY_E;
-            XMEMCPY(cert->publicKey, &cert->source[cert->srcIdx], length);
-            cert->pubKeyStored = 1;
-            cert->pubKeySize   = length;
-
-            cert->srcIdx += length;
-
-            return 0;
-        }
-    #endif /* HAVE_ECC */
-        default:
-            return ASN_UNKNOWN_OID_E;
-    }
-}
-
-
-/* process NAME, either issuer or subject */
-static int GetName(DecodedCert* cert, int nameType)
-{
-    int    length;  /* length of all distinguished names */
-    int    dummy;
-    int    ret;
-    char*  full;
-    byte*  hash;
-    word32 idx;
-    #ifdef OPENSSL_EXTRA
-        DecodedName* dName =
-                  (nameType == ISSUER) ? &cert->issuerName : &cert->subjectName;
-    #endif /* OPENSSL_EXTRA */
-
-    WOLFSSL_MSG("Getting Cert Name");
-
-    if (nameType == ISSUER) {
-        full = cert->issuer;
-        hash = cert->issuerHash;
-    }
-    else {
-        full = cert->subject;
-        hash = cert->subjectHash;
-    }
-
-    if (cert->source[cert->srcIdx] == ASN_OBJECT_ID) {
-        WOLFSSL_MSG("Trying optional prefix...");
-
-        if (GetLength(cert->source, &cert->srcIdx, &length, cert->maxIdx) < 0)
-            return ASN_PARSE_E;
-
-        cert->srcIdx += length;
-        WOLFSSL_MSG("Got optional prefix");
-    }
-
-    /* For OCSP, RFC2560 section 4.1.1 states the issuer hash should be
-     * calculated over the entire DER encoding of the Name field, including
-     * the tag and length. */
-    idx = cert->srcIdx;
-    if (GetSequence(cert->source, &cert->srcIdx, &length, cert->maxIdx) < 0)
-        return ASN_PARSE_E;
-
-#ifdef NO_SHA
-    ret = wc_Sha256Hash(&cert->source[idx], length + cert->srcIdx - idx, hash);
-#else
-    ret = wc_ShaHash(&cert->source[idx], length + cert->srcIdx - idx, hash);
-#endif
-    if (ret != 0)
-        return ret;
-
-    length += cert->srcIdx;
-    idx = 0;
-
-#ifdef HAVE_PKCS7
-    /* store pointer to raw issuer */
-    if (nameType == ISSUER) {
-        cert->issuerRaw = &cert->source[cert->srcIdx];
-        cert->issuerRawLen = length - cert->srcIdx;
-    }
-#endif
-#ifndef IGNORE_NAME_CONSTRAINTS
-    if (nameType == SUBJECT) {
-        cert->subjectRaw = &cert->source[cert->srcIdx];
-        cert->subjectRawLen = length - cert->srcIdx;
-    }
-#endif
-
-    while (cert->srcIdx < (word32)length) {
-        byte   b;
-        byte   joint[2];
-        byte   tooBig = FALSE;
-        int    oidSz;
-
-        if (GetSet(cert->source, &cert->srcIdx, &dummy, cert->maxIdx) < 0) {
-            WOLFSSL_MSG("Cert name lacks set header, trying sequence");
-        }
-
-        if (GetSequence(cert->source, &cert->srcIdx, &dummy, cert->maxIdx) < 0)
-            return ASN_PARSE_E;
-
-        b = cert->source[cert->srcIdx++];
-        if (b != ASN_OBJECT_ID) 
-            return ASN_OBJECT_ID_E;
-
-        if (GetLength(cert->source, &cert->srcIdx, &oidSz, cert->maxIdx) < 0)
-            return ASN_PARSE_E;
-
-        XMEMCPY(joint, &cert->source[cert->srcIdx], sizeof(joint));
-
-        /* v1 name types */
-        if (joint[0] == 0x55 && joint[1] == 0x04) {
-            byte   id;
-            byte   copy = FALSE;
-            int    strLen;
-
-            cert->srcIdx += 2;
-            id = cert->source[cert->srcIdx++]; 
-            b  = cert->source[cert->srcIdx++]; /* encoding */
-
-            if (GetLength(cert->source, &cert->srcIdx, &strLen,
-                          cert->maxIdx) < 0)
-                return ASN_PARSE_E;
-
-            if ( (strLen + 14) > (int)(ASN_NAME_MAX - idx)) {
-                /* include biggest pre fix header too 4 = "/serialNumber=" */
-                WOLFSSL_MSG("ASN Name too big, skipping");
-                tooBig = TRUE;
-            }
-
-            if (id == ASN_COMMON_NAME) {
-                if (nameType == SUBJECT) {
-                    cert->subjectCN = (char *)&cert->source[cert->srcIdx];
-                    cert->subjectCNLen = strLen;
-                    cert->subjectCNEnc = b;
-                }
-
-                if (!tooBig) {
-                    XMEMCPY(&full[idx], "/CN=", 4);
-                    idx += 4;
-                    copy = TRUE;
-                }
-                #ifdef OPENSSL_EXTRA
-                    dName->cnIdx = cert->srcIdx;
-                    dName->cnLen = strLen;
-                #endif /* OPENSSL_EXTRA */
-            }
-            else if (id == ASN_SUR_NAME) {
-                if (!tooBig) {
-                    XMEMCPY(&full[idx], "/SN=", 4);
-                    idx += 4;
-                    copy = TRUE;
-                }
-                #ifdef WOLFSSL_CERT_GEN
-                    if (nameType == SUBJECT) {
-                        cert->subjectSN = (char*)&cert->source[cert->srcIdx];
-                        cert->subjectSNLen = strLen;
-                        cert->subjectSNEnc = b;
-                    }
-                #endif /* WOLFSSL_CERT_GEN */
-                #ifdef OPENSSL_EXTRA
-                    dName->snIdx = cert->srcIdx;
-                    dName->snLen = strLen;
-                #endif /* OPENSSL_EXTRA */
-            }
-            else if (id == ASN_COUNTRY_NAME) {
-                if (!tooBig) {
-                    XMEMCPY(&full[idx], "/C=", 3);
-                    idx += 3;
-                    copy = TRUE;
-                }
-                #ifdef WOLFSSL_CERT_GEN
-                    if (nameType == SUBJECT) {
-                        cert->subjectC = (char*)&cert->source[cert->srcIdx];
-                        cert->subjectCLen = strLen;
-                        cert->subjectCEnc = b;
-                    }
-                #endif /* WOLFSSL_CERT_GEN */
-                #ifdef OPENSSL_EXTRA
-                    dName->cIdx = cert->srcIdx;
-                    dName->cLen = strLen;
-                #endif /* OPENSSL_EXTRA */
-            }
-            else if (id == ASN_LOCALITY_NAME) {
-                if (!tooBig) {
-                    XMEMCPY(&full[idx], "/L=", 3);
-                    idx += 3;
-                    copy = TRUE;
-                }
-                #ifdef WOLFSSL_CERT_GEN
-                    if (nameType == SUBJECT) {
-                        cert->subjectL = (char*)&cert->source[cert->srcIdx];
-                        cert->subjectLLen = strLen;
-                        cert->subjectLEnc = b;
-                    }
-                #endif /* WOLFSSL_CERT_GEN */
-                #ifdef OPENSSL_EXTRA
-                    dName->lIdx = cert->srcIdx;
-                    dName->lLen = strLen;
-                #endif /* OPENSSL_EXTRA */
-            }
-            else if (id == ASN_STATE_NAME) {
-                if (!tooBig) {
-                    XMEMCPY(&full[idx], "/ST=", 4);
-                    idx += 4;
-                    copy = TRUE;
-                }
-                #ifdef WOLFSSL_CERT_GEN
-                    if (nameType == SUBJECT) {
-                        cert->subjectST = (char*)&cert->source[cert->srcIdx];
-                        cert->subjectSTLen = strLen;
-                        cert->subjectSTEnc = b;
-                    }
-                #endif /* WOLFSSL_CERT_GEN */
-                #ifdef OPENSSL_EXTRA
-                    dName->stIdx = cert->srcIdx;
-                    dName->stLen = strLen;
-                #endif /* OPENSSL_EXTRA */
-            }
-            else if (id == ASN_ORG_NAME) {
-                if (!tooBig) {
-                    XMEMCPY(&full[idx], "/O=", 3);
-                    idx += 3;
-                    copy = TRUE;
-                }
-                #ifdef WOLFSSL_CERT_GEN
-                    if (nameType == SUBJECT) {
-                        cert->subjectO = (char*)&cert->source[cert->srcIdx];
-                        cert->subjectOLen = strLen;
-                        cert->subjectOEnc = b;
-                    }
-                #endif /* WOLFSSL_CERT_GEN */
-                #ifdef OPENSSL_EXTRA
-                    dName->oIdx = cert->srcIdx;
-                    dName->oLen = strLen;
-                #endif /* OPENSSL_EXTRA */
-            }
-            else if (id == ASN_ORGUNIT_NAME) {
-                if (!tooBig) {
-                    XMEMCPY(&full[idx], "/OU=", 4);
-                    idx += 4;
-                    copy = TRUE;
-                }
-                #ifdef WOLFSSL_CERT_GEN
-                    if (nameType == SUBJECT) {
-                        cert->subjectOU = (char*)&cert->source[cert->srcIdx];
-                        cert->subjectOULen = strLen;
-                        cert->subjectOUEnc = b;
-                    }
-                #endif /* WOLFSSL_CERT_GEN */
-                #ifdef OPENSSL_EXTRA
-                    dName->ouIdx = cert->srcIdx;
-                    dName->ouLen = strLen;
-                #endif /* OPENSSL_EXTRA */
-            }
-            else if (id == ASN_SERIAL_NUMBER) {
-                if (!tooBig) {
-                   XMEMCPY(&full[idx], "/serialNumber=", 14);
-                   idx += 14;
-                   copy = TRUE;
-                }
-                #ifdef OPENSSL_EXTRA
-                    dName->snIdx = cert->srcIdx;
-                    dName->snLen = strLen;
-                #endif /* OPENSSL_EXTRA */
-            }
-
-            if (copy && !tooBig) {
-                XMEMCPY(&full[idx], &cert->source[cert->srcIdx], strLen);
-                idx += strLen;
-            }
-
-            cert->srcIdx += strLen;
-        }
-        else {
-            /* skip */
-            byte email = FALSE;
-            byte uid   = FALSE;
-            int  adv;
-
-            if (joint[0] == 0x2a && joint[1] == 0x86)  /* email id hdr */
-                email = TRUE;
-
-            if (joint[0] == 0x9  && joint[1] == 0x92)  /* uid id hdr */
-                uid = TRUE;
-
-            cert->srcIdx += oidSz + 1;
-
-            if (GetLength(cert->source, &cert->srcIdx, &adv, cert->maxIdx) < 0)
-                return ASN_PARSE_E;
-
-            if (adv > (int)(ASN_NAME_MAX - idx)) {
-                WOLFSSL_MSG("ASN name too big, skipping");
-                tooBig = TRUE;
-            }
-
-            if (email) {
-                if ( (14 + adv) > (int)(ASN_NAME_MAX - idx)) {
-                    WOLFSSL_MSG("ASN name too big, skipping");
-                    tooBig = TRUE;
-                }
-                if (!tooBig) {
-                    XMEMCPY(&full[idx], "/emailAddress=", 14);
-                    idx += 14;
-                }
-
-                #ifdef WOLFSSL_CERT_GEN
-                    if (nameType == SUBJECT) {
-                        cert->subjectEmail = (char*)&cert->source[cert->srcIdx];
-                        cert->subjectEmailLen = adv;
-                    }
-                #endif /* WOLFSSL_CERT_GEN */
-                #ifdef OPENSSL_EXTRA
-                    dName->emailIdx = cert->srcIdx;
-                    dName->emailLen = adv;
-                #endif /* OPENSSL_EXTRA */
-                #ifndef IGNORE_NAME_CONSTRAINTS
-                    {
-                        DNS_entry* emailName = NULL;
-
-                        emailName = (DNS_entry*)XMALLOC(sizeof(DNS_entry),
-                                              cert->heap, DYNAMIC_TYPE_ALTNAME);
-                        if (emailName == NULL) {
-                            WOLFSSL_MSG("\tOut of Memory");
-                            return MEMORY_E;
-                        }
-                        emailName->name = (char*)XMALLOC(adv + 1,
-                                              cert->heap, DYNAMIC_TYPE_ALTNAME);
-                        if (emailName->name == NULL) {
-                            WOLFSSL_MSG("\tOut of Memory");
-                            return MEMORY_E;
-                        }
-                        XMEMCPY(emailName->name,
-                                              &cert->source[cert->srcIdx], adv);
-                        emailName->name[adv] = 0;
-
-                        emailName->next = cert->altEmailNames;
-                        cert->altEmailNames = emailName;
-                    }
-                #endif /* IGNORE_NAME_CONSTRAINTS */
-                if (!tooBig) {
-                    XMEMCPY(&full[idx], &cert->source[cert->srcIdx], adv);
-                    idx += adv;
-                }
-            }
-
-            if (uid) {
-                if ( (5 + adv) > (int)(ASN_NAME_MAX - idx)) {
-                    WOLFSSL_MSG("ASN name too big, skipping");
-                    tooBig = TRUE;
-                }
-                if (!tooBig) {
-                    XMEMCPY(&full[idx], "/UID=", 5);
-                    idx += 5;
-
-                    XMEMCPY(&full[idx], &cert->source[cert->srcIdx], adv);
-                    idx += adv;
-                }
-                #ifdef OPENSSL_EXTRA
-                    dName->uidIdx = cert->srcIdx;
-                    dName->uidLen = adv;
-                #endif /* OPENSSL_EXTRA */
-            }
-
-            cert->srcIdx += adv;
-        }
-    }
-    full[idx++] = 0;
-
-    #ifdef OPENSSL_EXTRA
-    {
-        int totalLen = 0;
-
-        if (dName->cnLen != 0)
-            totalLen += dName->cnLen + 4;
-        if (dName->snLen != 0)
-            totalLen += dName->snLen + 4;
-        if (dName->cLen != 0)
-            totalLen += dName->cLen + 3;
-        if (dName->lLen != 0)
-            totalLen += dName->lLen + 3;
-        if (dName->stLen != 0)
-            totalLen += dName->stLen + 4;
-        if (dName->oLen != 0)
-            totalLen += dName->oLen + 3;
-        if (dName->ouLen != 0)
-            totalLen += dName->ouLen + 4;
-        if (dName->emailLen != 0)
-            totalLen += dName->emailLen + 14;
-        if (dName->uidLen != 0)
-            totalLen += dName->uidLen + 5;
-        if (dName->serialLen != 0)
-            totalLen += dName->serialLen + 14;
-
-        dName->fullName = (char*)XMALLOC(totalLen + 1, NULL, DYNAMIC_TYPE_X509);
-        if (dName->fullName != NULL) {
-            idx = 0;
-
-            if (dName->cnLen != 0) {
-                dName->entryCount++;
-                XMEMCPY(&dName->fullName[idx], "/CN=", 4);
-                idx += 4;
-                XMEMCPY(&dName->fullName[idx],
-                                     &cert->source[dName->cnIdx], dName->cnLen);
-                dName->cnIdx = idx;
-                idx += dName->cnLen;
-            }
-            if (dName->snLen != 0) {
-                dName->entryCount++;
-                XMEMCPY(&dName->fullName[idx], "/SN=", 4);
-                idx += 4;
-                XMEMCPY(&dName->fullName[idx],
-                                     &cert->source[dName->snIdx], dName->snLen);
-                dName->snIdx = idx;
-                idx += dName->snLen;
-            }
-            if (dName->cLen != 0) {
-                dName->entryCount++;
-                XMEMCPY(&dName->fullName[idx], "/C=", 3);
-                idx += 3;
-                XMEMCPY(&dName->fullName[idx],
-                                       &cert->source[dName->cIdx], dName->cLen);
-                dName->cIdx = idx;
-                idx += dName->cLen;
-            }
-            if (dName->lLen != 0) {
-                dName->entryCount++;
-                XMEMCPY(&dName->fullName[idx], "/L=", 3);
-                idx += 3;
-                XMEMCPY(&dName->fullName[idx],
-                                       &cert->source[dName->lIdx], dName->lLen);
-                dName->lIdx = idx;
-                idx += dName->lLen;
-            }
-            if (dName->stLen != 0) {
-                dName->entryCount++;
-                XMEMCPY(&dName->fullName[idx], "/ST=", 4);
-                idx += 4;
-                XMEMCPY(&dName->fullName[idx],
-                                     &cert->source[dName->stIdx], dName->stLen);
-                dName->stIdx = idx;
-                idx += dName->stLen;
-            }
-            if (dName->oLen != 0) {
-                dName->entryCount++;
-                XMEMCPY(&dName->fullName[idx], "/O=", 3);
-                idx += 3;
-                XMEMCPY(&dName->fullName[idx],
-                                       &cert->source[dName->oIdx], dName->oLen);
-                dName->oIdx = idx;
-                idx += dName->oLen;
-            }
-            if (dName->ouLen != 0) {
-                dName->entryCount++;
-                XMEMCPY(&dName->fullName[idx], "/OU=", 4);
-                idx += 4;
-                XMEMCPY(&dName->fullName[idx],
-                                     &cert->source[dName->ouIdx], dName->ouLen);
-                dName->ouIdx = idx;
-                idx += dName->ouLen;
-            }
-            if (dName->emailLen != 0) {
-                dName->entryCount++;
-                XMEMCPY(&dName->fullName[idx], "/emailAddress=", 14);
-                idx += 14;
-                XMEMCPY(&dName->fullName[idx],
-                               &cert->source[dName->emailIdx], dName->emailLen);
-                dName->emailIdx = idx;
-                idx += dName->emailLen;
-            }
-            if (dName->uidLen != 0) {
-                dName->entryCount++;
-                XMEMCPY(&dName->fullName[idx], "/UID=", 5);
-                idx += 5;
-                XMEMCPY(&dName->fullName[idx],
-                                   &cert->source[dName->uidIdx], dName->uidLen);
-                dName->uidIdx = idx;
-                idx += dName->uidLen;
-            }
-            if (dName->serialLen != 0) {
-                dName->entryCount++;
-                XMEMCPY(&dName->fullName[idx], "/serialNumber=", 14);
-                idx += 14;
-                XMEMCPY(&dName->fullName[idx],
-                             &cert->source[dName->serialIdx], dName->serialLen);
-                dName->serialIdx = idx;
-                idx += dName->serialLen;
-            }
-            dName->fullName[idx] = '\0';
-            dName->fullNameLen = totalLen;
-        }
-    }
-    #endif /* OPENSSL_EXTRA */
-
-    return 0;
-}
-
-
-#ifndef NO_TIME_H
-
-/* to the second */
-static int DateGreaterThan(const struct tm* a, const struct tm* b)
-{
-    if (a->tm_year > b->tm_year)
-        return 1;
-
-    if (a->tm_year == b->tm_year && a->tm_mon > b->tm_mon)
-        return 1;
-    
-    if (a->tm_year == b->tm_year && a->tm_mon == b->tm_mon &&
-           a->tm_mday > b->tm_mday)
-        return 1;
-
-    if (a->tm_year == b->tm_year && a->tm_mon == b->tm_mon &&
-        a->tm_mday == b->tm_mday && a->tm_hour > b->tm_hour)
-        return 1;
-
-    if (a->tm_year == b->tm_year && a->tm_mon == b->tm_mon &&
-        a->tm_mday == b->tm_mday && a->tm_hour == b->tm_hour &&
-        a->tm_min > b->tm_min)
-        return 1;
-
-    if (a->tm_year == b->tm_year && a->tm_mon == b->tm_mon &&
-        a->tm_mday == b->tm_mday && a->tm_hour == b->tm_hour &&
-        a->tm_min  == b->tm_min  && a->tm_sec > b->tm_sec)
-        return 1;
-
-    return 0; /* false */
-}
-
-
-static INLINE int DateLessThan(const struct tm* a, const struct tm* b)
-{
-    return DateGreaterThan(b,a);
-}
-
-
-/* like atoi but only use first byte */
-/* Make sure before and after dates are valid */
-int ValidateDate(const byte* date, byte format, int dateType)
-{
-    time_t ltime;
-    struct tm  certTime;
-    struct tm* localTime;
-    struct tm* tmpTime = NULL;
-    int    i = 0;
-
-#if defined(FREESCALE_MQX) || defined(TIME_OVERRIDES)
-    struct tm tmpTimeStorage;
-    tmpTime = &tmpTimeStorage;
-#else
-    (void)tmpTime;
-#endif
-
-    ltime = XTIME(0);
-    XMEMSET(&certTime, 0, sizeof(certTime));
-
-    if (format == ASN_UTC_TIME) {
-        if (btoi(date[0]) >= 5)
-            certTime.tm_year = 1900;
-        else
-            certTime.tm_year = 2000;
-    }
-    else  { /* format == GENERALIZED_TIME */
-        certTime.tm_year += btoi(date[i++]) * 1000;
-        certTime.tm_year += btoi(date[i++]) * 100;
-    }
-
-    /* adjust tm_year, tm_mon */
-    GetTime((int*)&certTime.tm_year, date, &i); certTime.tm_year -= 1900;
-    GetTime((int*)&certTime.tm_mon,  date, &i); certTime.tm_mon  -= 1;
-    GetTime((int*)&certTime.tm_mday, date, &i);
-    GetTime((int*)&certTime.tm_hour, date, &i);
-    GetTime((int*)&certTime.tm_min,  date, &i);
-    GetTime((int*)&certTime.tm_sec,  date, &i);
-
-        if (date[i] != 'Z') {     /* only Zulu supported for this profile */
-        WOLFSSL_MSG("Only Zulu time supported for this profile");
-        return 0;
-    }
-
-    localTime = XGMTIME(<ime, tmpTime);
-
-    if (dateType == BEFORE) {
-        if (DateLessThan(localTime, &certTime))
-            return 0;
-    }
-    else
-        if (DateGreaterThan(localTime, &certTime))
-            return 0;
-
-    return 1;
-}
-
-#endif /* NO_TIME_H */
-
-
-static int GetDate(DecodedCert* cert, int dateType)
-{
-    int    length;
-    byte   date[MAX_DATE_SIZE];
-    byte   b;
-    word32 startIdx = 0;
-
-    if (dateType == BEFORE)
-        cert->beforeDate = &cert->source[cert->srcIdx];
-    else
-        cert->afterDate = &cert->source[cert->srcIdx];
-    startIdx = cert->srcIdx;
-
-    b = cert->source[cert->srcIdx++];
-    if (b != ASN_UTC_TIME && b != ASN_GENERALIZED_TIME)
-        return ASN_TIME_E;
-
-    if (GetLength(cert->source, &cert->srcIdx, &length, cert->maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    if (length > MAX_DATE_SIZE || length < MIN_DATE_SIZE)
-        return ASN_DATE_SZ_E;
-
-    XMEMCPY(date, &cert->source[cert->srcIdx], length);
-    cert->srcIdx += length;
-
-    if (dateType == BEFORE)
-        cert->beforeDateLen = cert->srcIdx - startIdx;
-    else
-        cert->afterDateLen  = cert->srcIdx - startIdx;
-
-    if (!XVALIDATE_DATE(date, b, dateType)) {
-        if (dateType == BEFORE)
-            return ASN_BEFORE_DATE_E;
-        else
-            return ASN_AFTER_DATE_E;
-    }
-
-    return 0;
-}
-
-
-static int GetValidity(DecodedCert* cert, int verify)
-{
-    int length;
-    int badDate = 0;
-
-    if (GetSequence(cert->source, &cert->srcIdx, &length, cert->maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    if (GetDate(cert, BEFORE) < 0 && verify)
-        badDate = ASN_BEFORE_DATE_E;           /* continue parsing */
-    
-    if (GetDate(cert, AFTER) < 0 && verify)
-        return ASN_AFTER_DATE_E;
-   
-    if (badDate != 0)
-        return badDate;
-
-    return 0;
-}
-
-
-int DecodeToKey(DecodedCert* cert, int verify)
-{
-    int badDate = 0;
-    int ret;
-
-    if ( (ret = GetCertHeader(cert)) < 0)
-        return ret;
-
-    WOLFSSL_MSG("Got Cert Header");
-
-    if ( (ret = GetAlgoId(cert->source, &cert->srcIdx, &cert->signatureOID,
-                          cert->maxIdx)) < 0)
-        return ret;
-
-    WOLFSSL_MSG("Got Algo ID");
-
-    if ( (ret = GetName(cert, ISSUER)) < 0)
-        return ret;
-
-    if ( (ret = GetValidity(cert, verify)) < 0)
-        badDate = ret;
-
-    if ( (ret = GetName(cert, SUBJECT)) < 0)
-        return ret;
-
-    WOLFSSL_MSG("Got Subject Name");
-
-    if ( (ret = GetKey(cert)) < 0)
-        return ret;
-
-    WOLFSSL_MSG("Got Key");
-
-    if (badDate != 0)
-        return badDate;
-
-    return ret;
-}
-
-
-static int GetSignature(DecodedCert* cert)
-{
-    int    length;
-    byte   b = cert->source[cert->srcIdx++];
-
-    if (b != ASN_BIT_STRING)
-        return ASN_BITSTR_E;
-
-    if (GetLength(cert->source, &cert->srcIdx, &length, cert->maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    cert->sigLength = length;
-
-    b = cert->source[cert->srcIdx++];
-    if (b != 0x00)
-        return ASN_EXPECT_0_E;
-
-    cert->sigLength--;
-    cert->signature = &cert->source[cert->srcIdx];
-    cert->srcIdx += cert->sigLength;
-
-    return 0;
-}
-
-
-static word32 SetDigest(const byte* digest, word32 digSz, byte* output)
-{
-    output[0] = ASN_OCTET_STRING;
-    output[1] = (byte)digSz;
-    XMEMCPY(&output[2], digest, digSz);
-
-    return digSz + 2;
-} 
-
-
-static word32 BytePrecision(word32 value)
-{
-    word32 i;
-    for (i = sizeof(value); i; --i)
-        if (value >> ((i - 1) * WOLFSSL_BIT_SIZE))
-            break;
-
-    return i;
-}
-
-
-WOLFSSL_LOCAL word32 SetLength(word32 length, byte* output)
-{
-    word32 i = 0, j;
-
-    if (length < ASN_LONG_LENGTH)
-        output[i++] = (byte)length;
-    else {
-        output[i++] = (byte)(BytePrecision(length) | ASN_LONG_LENGTH);
-      
-        for (j = BytePrecision(length); j; --j) {
-            output[i] = (byte)(length >> ((j - 1) * WOLFSSL_BIT_SIZE));
-            i++;
-        }
-    }
-
-    return i;
-}
-
-
-WOLFSSL_LOCAL word32 SetSequence(word32 len, byte* output)
-{
-    output[0] = ASN_SEQUENCE | ASN_CONSTRUCTED;
-    return SetLength(len, output + 1) + 1;
-}
-
-WOLFSSL_LOCAL word32 SetOctetString(word32 len, byte* output)
-{
-    output[0] = ASN_OCTET_STRING;
-    return SetLength(len, output + 1) + 1;
-}
-
-/* Write a set header to output */
-WOLFSSL_LOCAL word32 SetSet(word32 len, byte* output)
-{
-    output[0] = ASN_SET | ASN_CONSTRUCTED;
-    return SetLength(len, output + 1) + 1;
-}
-
-WOLFSSL_LOCAL word32 SetImplicit(byte tag, byte number, word32 len, byte* output)
-{
-
-    output[0] = ((tag == ASN_SEQUENCE || tag == ASN_SET) ? ASN_CONSTRUCTED : 0)
-                    | ASN_CONTEXT_SPECIFIC | number;
-    return SetLength(len, output + 1) + 1;
-}
-
-WOLFSSL_LOCAL word32 SetExplicit(byte number, word32 len, byte* output)
-{
-    output[0] = ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | number;
-    return SetLength(len, output + 1) + 1;
-}
-
-
-#if defined(HAVE_ECC) && (defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN))
-
-static word32 SetCurve(ecc_key* key, byte* output)
-{
-
-    /* curve types */
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC192)
-    static const byte ECC_192v1_AlgoID[] = { 0x2a, 0x86, 0x48, 0xCE, 0x3d,
-                                             0x03, 0x01, 0x01};
-#endif
-#if defined(HAVE_ALL_CURVES) || !defined(NO_ECC256)
-    static const byte ECC_256v1_AlgoID[] = { 0x2a, 0x86, 0x48, 0xCE, 0x3d,
-                                            0x03, 0x01, 0x07};
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC160)
-    static const byte ECC_160r1_AlgoID[] = { 0x2b, 0x81, 0x04, 0x00,
-                                             0x02};
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC224)
-    static const byte ECC_224r1_AlgoID[] = { 0x2b, 0x81, 0x04, 0x00,
-                                             0x21};
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC384)
-    static const byte ECC_384r1_AlgoID[] = { 0x2b, 0x81, 0x04, 0x00,
-                                             0x22};
-#endif
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC521)
-    static const byte ECC_521r1_AlgoID[] = { 0x2b, 0x81, 0x04, 0x00,
-                                             0x23};
-#endif
-
-    int    oidSz = 0;
-    int    idx = 0;
-    int    lenSz = 0;
-    const  byte* oid = 0;
-
-    output[0] = ASN_OBJECT_ID;
-    idx++;
-
-    switch (key->dp->size) {
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC160)
-        case 20:
-            oidSz = sizeof(ECC_160r1_AlgoID);
-            oid   =        ECC_160r1_AlgoID;
-            break;
-#endif
-
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC192)
-        case 24:
-            oidSz = sizeof(ECC_192v1_AlgoID);
-            oid   =        ECC_192v1_AlgoID;
-            break;
-#endif
-
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC224)
-        case 28:
-            oidSz = sizeof(ECC_224r1_AlgoID);
-            oid   =        ECC_224r1_AlgoID;
-            break;
-#endif
-
-#if defined(HAVE_ALL_CURVES) || !defined(NO_ECC256)
-        case 32:
-            oidSz = sizeof(ECC_256v1_AlgoID);
-            oid   =        ECC_256v1_AlgoID;
-            break;
-#endif
-
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC384)
-        case 48:
-            oidSz = sizeof(ECC_384r1_AlgoID);
-            oid   =        ECC_384r1_AlgoID;
-            break;
-#endif
-
-#if defined(HAVE_ALL_CURVES) || defined(HAVE_ECC521)
-        case 66:
-            oidSz = sizeof(ECC_521r1_AlgoID);
-            oid   =        ECC_521r1_AlgoID;
-            break;
-#endif
-
-        default:
-            return ASN_UNKNOWN_OID_E;
-    }
-    lenSz = SetLength(oidSz, output+idx);
-    idx += lenSz;
-
-    XMEMCPY(output+idx, oid, oidSz);
-    idx += oidSz;
-
-    return idx;
-}
-
-#endif /* HAVE_ECC && WOLFSSL_CERT_GEN */
-
-
-WOLFSSL_LOCAL word32 SetAlgoID(int algoOID, byte* output, int type, int curveSz)
-{
-    /* adding TAG_NULL and 0 to end */
-    
-    /* hashTypes */
-    static const byte shaAlgoID[]    = { 0x2b, 0x0e, 0x03, 0x02, 0x1a,
-                                         0x05, 0x00 };
-    static const byte sha256AlgoID[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,
-                                         0x04, 0x02, 0x01, 0x05, 0x00 };
-    static const byte sha384AlgoID[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,
-                                         0x04, 0x02, 0x02, 0x05, 0x00 };
-    static const byte sha512AlgoID[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,
-                                         0x04, 0x02, 0x03, 0x05, 0x00 };
-    static const byte md5AlgoID[]    = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
-                                         0x02, 0x05, 0x05, 0x00  };
-    static const byte md2AlgoID[]    = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
-                                         0x02, 0x02, 0x05, 0x00};
-
-    /* blkTypes, no NULL tags because IV is there instead */
-    static const byte desCbcAlgoID[]  = { 0x2B, 0x0E, 0x03, 0x02, 0x07 };
-    static const byte des3CbcAlgoID[] = { 0x2A, 0x86, 0x48, 0x86, 0xF7,
-                                          0x0D, 0x03, 0x07 };
-
-    /* RSA sigTypes */
-    #ifndef NO_RSA
-        static const byte md5wRSA_AlgoID[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7,
-                                            0x0d, 0x01, 0x01, 0x04, 0x05, 0x00};
-        static const byte shawRSA_AlgoID[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7,
-                                            0x0d, 0x01, 0x01, 0x05, 0x05, 0x00};
-        static const byte sha256wRSA_AlgoID[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7,
-                                            0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00};
-        static const byte sha384wRSA_AlgoID[] = {0x2a, 0x86, 0x48, 0x86, 0xf7,
-                                            0x0d, 0x01, 0x01, 0x0c, 0x05, 0x00};
-        static const byte sha512wRSA_AlgoID[] = {0x2a, 0x86, 0x48, 0x86, 0xf7,
-                                            0x0d, 0x01, 0x01, 0x0d, 0x05, 0x00};
-    #endif /* NO_RSA */
- 
-    /* ECDSA sigTypes */
-    #ifdef HAVE_ECC 
-        static const byte shawECDSA_AlgoID[] = { 0x2a, 0x86, 0x48, 0xCE, 0x3d,
-                                                 0x04, 0x01, 0x05, 0x00};
-        static const byte sha256wECDSA_AlgoID[] = { 0x2a, 0x86, 0x48, 0xCE,0x3d,
-                                                 0x04, 0x03, 0x02, 0x05, 0x00};
-        static const byte sha384wECDSA_AlgoID[] = { 0x2a, 0x86, 0x48, 0xCE,0x3d,
-                                                 0x04, 0x03, 0x03, 0x05, 0x00};
-        static const byte sha512wECDSA_AlgoID[] = { 0x2a, 0x86, 0x48, 0xCE,0x3d,
-                                                 0x04, 0x03, 0x04, 0x05, 0x00};
-    #endif /* HAVE_ECC */
- 
-    /* RSA keyType */
-    #ifndef NO_RSA
-        static const byte RSA_AlgoID[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
-                                            0x01, 0x01, 0x01, 0x05, 0x00};
-    #endif /* NO_RSA */
-
-    #ifdef HAVE_ECC 
-        /* ECC keyType */
-        /* no tags, so set tagSz smaller later */
-        static const byte ECC_AlgoID[] = { 0x2a, 0x86, 0x48, 0xCE, 0x3d,
-                                           0x02, 0x01};
-    #endif /* HAVE_ECC */
-
-    int    algoSz = 0;
-    int    tagSz  = 2;   /* tag null and terminator */
-    word32 idSz, seqSz;
-    const  byte* algoName = 0;
-    byte ID_Length[MAX_LENGTH_SZ];
-    byte seqArray[MAX_SEQ_SZ + 1];  /* add object_id to end */
-
-    if (type == hashType) {
-        switch (algoOID) {
-        case SHAh:
-            algoSz = sizeof(shaAlgoID);
-            algoName = shaAlgoID;
-            break;
-
-        case SHA256h:
-            algoSz = sizeof(sha256AlgoID);
-            algoName = sha256AlgoID;
-            break;
-
-        case SHA384h:
-            algoSz = sizeof(sha384AlgoID);
-            algoName = sha384AlgoID;
-            break;
-
-        case SHA512h:
-            algoSz = sizeof(sha512AlgoID);
-            algoName = sha512AlgoID;
-            break;
-
-        case MD2h:
-            algoSz = sizeof(md2AlgoID);
-            algoName = md2AlgoID;
-            break;
-
-        case MD5h:
-            algoSz = sizeof(md5AlgoID);
-            algoName = md5AlgoID;
-            break;
-
-        default:
-            WOLFSSL_MSG("Unknown Hash Algo");
-            return 0;  /* UNKOWN_HASH_E; */
-        }
-    }
-    else if (type == blkType) {
-        switch (algoOID) {
-        case DESb:
-            algoSz = sizeof(desCbcAlgoID);
-            algoName = desCbcAlgoID;
-            tagSz = 0;
-            break;
-        case DES3b:
-            algoSz = sizeof(des3CbcAlgoID);
-            algoName = des3CbcAlgoID;
-            tagSz = 0;
-            break;
-        default:
-            WOLFSSL_MSG("Unknown Block Algo");
-            return 0;
-        }
-    }
-    else if (type == sigType) {    /* sigType */
-        switch (algoOID) {
-        #ifndef NO_RSA
-            case CTC_MD5wRSA:
-                algoSz = sizeof(md5wRSA_AlgoID);
-                algoName = md5wRSA_AlgoID;
-                break;
-
-            case CTC_SHAwRSA:
-                algoSz = sizeof(shawRSA_AlgoID);
-                algoName = shawRSA_AlgoID;
-                break;
-
-            case CTC_SHA256wRSA:
-                algoSz = sizeof(sha256wRSA_AlgoID);
-                algoName = sha256wRSA_AlgoID;
-                break;
-
-            case CTC_SHA384wRSA:
-                algoSz = sizeof(sha384wRSA_AlgoID);
-                algoName = sha384wRSA_AlgoID;
-                break;
-
-            case CTC_SHA512wRSA:
-                algoSz = sizeof(sha512wRSA_AlgoID);
-                algoName = sha512wRSA_AlgoID;
-                break;
-        #endif /* NO_RSA */
-        #ifdef HAVE_ECC 
-            case CTC_SHAwECDSA:
-                algoSz = sizeof(shawECDSA_AlgoID);
-                algoName = shawECDSA_AlgoID;
-                break;
-
-            case CTC_SHA256wECDSA:
-                algoSz = sizeof(sha256wECDSA_AlgoID);
-                algoName = sha256wECDSA_AlgoID;
-                break;
-
-            case CTC_SHA384wECDSA:
-                algoSz = sizeof(sha384wECDSA_AlgoID);
-                algoName = sha384wECDSA_AlgoID;
-                break;
-
-            case CTC_SHA512wECDSA:
-                algoSz = sizeof(sha512wECDSA_AlgoID);
-                algoName = sha512wECDSA_AlgoID;
-                break;
-        #endif /* HAVE_ECC */
-        default:
-            WOLFSSL_MSG("Unknown Signature Algo");
-            return 0;
-        }
-    }
-    else if (type == keyType) {    /* keyType */
-        switch (algoOID) {
-        #ifndef NO_RSA
-            case RSAk:
-                algoSz = sizeof(RSA_AlgoID);
-                algoName = RSA_AlgoID;
-                break;
-        #endif /* NO_RSA */
-        #ifdef HAVE_ECC 
-            case ECDSAk:
-                algoSz = sizeof(ECC_AlgoID);
-                algoName = ECC_AlgoID;
-                tagSz = 0;
-                break;
-        #endif /* HAVE_ECC */
-        default:
-            WOLFSSL_MSG("Unknown Key Algo");
-            return 0;
-        }
-    }
-    else {
-        WOLFSSL_MSG("Unknown Algo type");
-        return 0;
-    }
-
-    idSz  = SetLength(algoSz - tagSz, ID_Length); /* don't include tags */
-    seqSz = SetSequence(idSz + algoSz + 1 + curveSz, seqArray); 
-                 /* +1 for object id, curveID of curveSz follows for ecc */
-    seqArray[seqSz++] = ASN_OBJECT_ID;
-
-    XMEMCPY(output, seqArray, seqSz);
-    XMEMCPY(output + seqSz, ID_Length, idSz);
-    XMEMCPY(output + seqSz + idSz, algoName, algoSz);
-
-    return seqSz + idSz + algoSz;
-
-}
-
-
-word32 wc_EncodeSignature(byte* out, const byte* digest, word32 digSz,
-                          int hashOID)
-{
-    byte digArray[MAX_ENCODED_DIG_SZ];
-    byte algoArray[MAX_ALGO_SZ];
-    byte seqArray[MAX_SEQ_SZ];
-    word32 encDigSz, algoSz, seqSz;
-
-    encDigSz = SetDigest(digest, digSz, digArray);
-    algoSz   = SetAlgoID(hashOID, algoArray, hashType, 0);
-    seqSz    = SetSequence(encDigSz + algoSz, seqArray);
-
-    XMEMCPY(out, seqArray, seqSz);
-    XMEMCPY(out + seqSz, algoArray, algoSz);
-    XMEMCPY(out + seqSz + algoSz, digArray, encDigSz);
-
-    return encDigSz + algoSz + seqSz;
-}
-
-
-int wc_GetCTC_HashOID(int type)
-{
-    switch (type) {
-#ifdef WOLFSSL_MD2
-        case MD2:
-            return MD2h;
-#endif
-#ifndef NO_MD5
-        case MD5:
-            return MD5h;
-#endif
-#ifndef NO_SHA
-        case SHA:
-            return SHAh;
-#endif
-#ifndef NO_SHA256
-        case SHA256:
-            return SHA256h;
-#endif
-#ifdef WOLFSSL_SHA384
-        case SHA384:
-            return SHA384h;
-#endif
-#ifdef WOLFSSL_SHA512
-        case SHA512:
-            return SHA512h;
-#endif
-        default:
-            return 0;
-    };
-}
-
-
-/* return true (1) or false (0) for Confirmation */
-static int ConfirmSignature(const byte* buf, word32 bufSz,
-    const byte* key, word32 keySz, word32 keyOID,
-    const byte* sig, word32 sigSz, word32 sigOID,
-    void* heap)
-{
-    int  typeH = 0, digestSz = 0, ret = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    byte* digest;
-#else
-    byte digest[MAX_DIGEST_SIZE];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    digest = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (digest == NULL)
-        return 0; /* not confirmed */
-#endif
-
-    (void)key;
-    (void)keySz;
-    (void)sig;
-    (void)sigSz;
-    (void)heap;
-
-    switch (sigOID) {
-    #ifndef NO_MD5
-        case CTC_MD5wRSA:
-        if (wc_Md5Hash(buf, bufSz, digest) == 0) {
-            typeH    = MD5h;
-            digestSz = MD5_DIGEST_SIZE;
-        }
-        break;
-    #endif
-    #if defined(WOLFSSL_MD2)
-        case CTC_MD2wRSA:
-        if (wc_Md2Hash(buf, bufSz, digest) == 0) {
-            typeH    = MD2h;
-            digestSz = MD2_DIGEST_SIZE;
-        }
-        break;
-    #endif
-    #ifndef NO_SHA
-        case CTC_SHAwRSA:
-        case CTC_SHAwDSA:
-        case CTC_SHAwECDSA:
-        if (wc_ShaHash(buf, bufSz, digest) == 0) {    
-            typeH    = SHAh;
-            digestSz = SHA_DIGEST_SIZE;                
-        }
-        break;
-    #endif
-    #ifndef NO_SHA256
-        case CTC_SHA256wRSA:
-        case CTC_SHA256wECDSA:
-        if (wc_Sha256Hash(buf, bufSz, digest) == 0) {    
-            typeH    = SHA256h;
-            digestSz = SHA256_DIGEST_SIZE;
-        }
-        break;
-    #endif
-    #ifdef WOLFSSL_SHA512
-        case CTC_SHA512wRSA:
-        case CTC_SHA512wECDSA:
-        if (wc_Sha512Hash(buf, bufSz, digest) == 0) {    
-            typeH    = SHA512h;
-            digestSz = SHA512_DIGEST_SIZE;
-        }
-        break;
-    #endif
-    #ifdef WOLFSSL_SHA384
-        case CTC_SHA384wRSA:
-        case CTC_SHA384wECDSA:
-        if (wc_Sha384Hash(buf, bufSz, digest) == 0) {    
-            typeH    = SHA384h;
-            digestSz = SHA384_DIGEST_SIZE;
-        }            
-        break;
-    #endif
-        default:
-            WOLFSSL_MSG("Verify Signautre has unsupported type");
-    }
-    
-    if (typeH == 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(digest, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return 0; /* not confirmed */
-    }
-
-    switch (keyOID) {
-    #ifndef NO_RSA
-        case RSAk:
-        {
-            word32 idx = 0;
-            int    encodedSigSz, verifySz;
-            byte*  out;
-#ifdef WOLFSSL_SMALL_STACK
-            RsaKey* pubKey;
-            byte* plain;
-            byte* encodedSig;
-#else
-            RsaKey pubKey[1];
-            byte plain[MAX_ENCODED_SIG_SZ];
-            byte encodedSig[MAX_ENCODED_SIG_SZ];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-            pubKey = (RsaKey*)XMALLOC(sizeof(RsaKey), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            plain = (byte*)XMALLOC(MAX_ENCODED_SIG_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            encodedSig = (byte*)XMALLOC(MAX_ENCODED_SIG_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            
-            if (pubKey == NULL || plain == NULL || encodedSig == NULL) {
-                WOLFSSL_MSG("Failed to allocate memory at ConfirmSignature");
-                
-                if (pubKey)
-                    XFREE(pubKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                if (plain)
-                    XFREE(plain, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                if (encodedSig)
-                    XFREE(encodedSig, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                
-                break; /* not confirmed */
-            }
-#endif
-
-            if (sigSz > MAX_ENCODED_SIG_SZ) {
-                WOLFSSL_MSG("Verify Signautre is too big");
-            }
-            else if (wc_InitRsaKey(pubKey, heap) != 0) {
-                WOLFSSL_MSG("InitRsaKey failed");
-            }
-            else if (wc_RsaPublicKeyDecode(key, &idx, pubKey, keySz) < 0) {
-                WOLFSSL_MSG("ASN Key decode error RSA");
-            }
-            else {
-                XMEMCPY(plain, sig, sigSz);
-
-                if ((verifySz = wc_RsaSSL_VerifyInline(plain, sigSz, &out,
-                                                                 pubKey)) < 0) {
-                    WOLFSSL_MSG("Rsa SSL verify error");
-                }
-                else {
-                    /* make sure we're right justified */
-                    encodedSigSz =
-                        wc_EncodeSignature(encodedSig, digest, digestSz, typeH);
-                    if (encodedSigSz != verifySz ||
-                                XMEMCMP(out, encodedSig, encodedSigSz) != 0) {
-                        WOLFSSL_MSG("Rsa SSL verify match encode error");
-                    }
-                    else
-                        ret = 1; /* match */
-
-                    #ifdef WOLFSSL_DEBUG_ENCODING
-                    {
-                        int x;
-
-                        printf("wolfssl encodedSig:\n");
-
-                        for (x = 0; x < encodedSigSz; x++) {
-                            printf("%02x ", encodedSig[x]);
-                            if ( (x % 16) == 15)
-                                printf("\n");
-                        }
-
-                        printf("\n");
-                        printf("actual digest:\n");
-
-                        for (x = 0; x < verifySz; x++) {
-                            printf("%02x ", out[x]);
-                            if ( (x % 16) == 15)
-                                printf("\n");
-                        }
-
-                        printf("\n");
-                    }
-                    #endif /* WOLFSSL_DEBUG_ENCODING */
-
-                }
-
-            }
-
-            wc_FreeRsaKey(pubKey);
-
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(pubKey,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(plain,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(encodedSig, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            break;
-        }
-
-    #endif /* NO_RSA */
-    #ifdef HAVE_ECC
-        case ECDSAk:
-        {
-            int verify = 0;
-#ifdef WOLFSSL_SMALL_STACK
-            ecc_key* pubKey;
-#else
-            ecc_key pubKey[1];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-            pubKey = (ecc_key*)XMALLOC(sizeof(ecc_key), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            if (pubKey == NULL) {
-                WOLFSSL_MSG("Failed to allocate pubKey");
-                break; /* not confirmed */
-            }
-#endif
-
-            if (wc_ecc_init(pubKey) < 0) {
-                WOLFSSL_MSG("Failed to initialize key");
-                break; /* not confirmed */
-            }
-            if (wc_ecc_import_x963(key, keySz, pubKey) < 0) {
-                WOLFSSL_MSG("ASN Key import error ECC");
-            }
-            else {   
-                if (wc_ecc_verify_hash(sig, sigSz, digest, digestSz, &verify,
-                                                                pubKey) != 0) {
-                    WOLFSSL_MSG("ECC verify hash error");
-                }
-                else if (1 != verify) {
-                    WOLFSSL_MSG("ECC Verify didn't match");
-                } else
-                    ret = 1; /* match */
-
-            }
-            wc_ecc_free(pubKey);
-
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(pubKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            break;
-        }
-    #endif /* HAVE_ECC */
-        default:
-            WOLFSSL_MSG("Verify Key type unknown");
-    }
-    
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(digest, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-#ifndef IGNORE_NAME_CONSTRAINTS
-
-static int MatchBaseName(int type, const char* name, int nameSz,
-                                                   const char* base, int baseSz)
-{
-    if (base == NULL || baseSz <= 0 || name == NULL || nameSz <= 0 ||
-            name[0] == '.' || nameSz < baseSz ||
-            (type != ASN_RFC822_TYPE && type != ASN_DNS_TYPE))
-        return 0;
-
-    /* If an email type, handle special cases where the base is only
-     * a domain, or is an email address itself. */
-    if (type == ASN_RFC822_TYPE) {
-        const char* p = NULL;
-        int count = 0;
-
-        if (base[0] != '.') {
-            p = base;
-            count = 0;
-
-            /* find the '@' in the base */
-            while (*p != '@' && count < baseSz) {
-                count++;
-                p++;
-            }
-
-            /* No '@' in base, reset p to NULL */
-            if (count >= baseSz)
-                p = NULL;
-        }
-
-        if (p == NULL) {
-            /* Base isn't an email address, it is a domain name,
-             * wind the name forward one character past its '@'. */
-            p = name;
-            count = 0;
-            while (*p != '@' && count < baseSz) {
-                count++;
-                p++;
-            }
-
-            if (count < baseSz && *p == '@') {
-                name = p + 1;
-                nameSz -= count + 1;
-            }
-        }
-    }
-
-    if ((type == ASN_DNS_TYPE || type == ASN_RFC822_TYPE) && base[0] == '.') {
-        int szAdjust = nameSz - baseSz;
-        name += szAdjust;
-        nameSz -= szAdjust;
-    }
-
-    while (nameSz > 0) {
-        if (XTOLOWER((unsigned char)*name++) != 
-                                               XTOLOWER((unsigned char)*base++))
-            return 0;
-        nameSz--;
-    }
-
-    return 1;
-}
-
-
-static int ConfirmNameConstraints(Signer* signer, DecodedCert* cert)
-{
-    if (signer == NULL || cert == NULL)
-        return 0;
-
-    /* Check against the excluded list */
-    if (signer->excludedNames) {
-        Base_entry* base = signer->excludedNames;
-
-        while (base != NULL) {
-            if (base->type == ASN_DNS_TYPE) {
-                DNS_entry* name = cert->altNames;
-                while (name != NULL) {
-                    if (MatchBaseName(ASN_DNS_TYPE,
-                                          name->name, (int)XSTRLEN(name->name),
-                                          base->name, base->nameSz))
-                        return 0;
-                    name = name->next;
-                }
-            }
-            else if (base->type == ASN_RFC822_TYPE) {
-                DNS_entry* name = cert->altEmailNames;
-                while (name != NULL) {
-                    if (MatchBaseName(ASN_RFC822_TYPE,
-                                          name->name, (int)XSTRLEN(name->name),
-                                          base->name, base->nameSz))
-                        return 0;
-
-                    name = name->next;
-                }
-            }
-            else if (base->type == ASN_DIR_TYPE) {
-                if (cert->subjectRawLen == base->nameSz &&
-                    XMEMCMP(cert->subjectRaw, base->name, base->nameSz) == 0) {
-
-                    return 0;
-                }
-            }
-            base = base->next;
-        }
-    }
-
-    /* Check against the permitted list */
-    if (signer->permittedNames != NULL) {
-        int needDns = 0;
-        int matchDns = 0;
-        int needEmail = 0;
-        int matchEmail = 0;
-        int needDir = 0;
-        int matchDir = 0;
-        Base_entry* base = signer->permittedNames;
-
-        while (base != NULL) {
-            if (base->type == ASN_DNS_TYPE) {
-                DNS_entry* name = cert->altNames;
-
-                if (name != NULL)
-                    needDns = 1;
-
-                while (name != NULL) {
-                    matchDns = MatchBaseName(ASN_DNS_TYPE,
-                                          name->name, (int)XSTRLEN(name->name),
-                                          base->name, base->nameSz);
-                    name = name->next;
-                }
-            }
-            else if (base->type == ASN_RFC822_TYPE) {
-                DNS_entry* name = cert->altEmailNames;
-
-                if (name != NULL)
-                    needEmail = 1;
-
-                while (name != NULL) {
-                    matchEmail = MatchBaseName(ASN_DNS_TYPE,
-                                          name->name, (int)XSTRLEN(name->name),
-                                          base->name, base->nameSz);
-                    name = name->next;
-                }
-            }
-            else if (base->type == ASN_DIR_TYPE) {
-                needDir = 1;
-                if (cert->subjectRaw != NULL &&
-                    cert->subjectRawLen == base->nameSz &&
-                    XMEMCMP(cert->subjectRaw, base->name, base->nameSz) == 0) {
-
-                    matchDir = 1;
-                }
-            }
-            base = base->next;
-        }
-
-        if ((needDns && !matchDns) || (needEmail && !matchEmail) ||
-            (needDir && !matchDir)) {
-
-            return 0;
-        }
-    }
-
-    return 1;
-}
-
-#endif /* IGNORE_NAME_CONSTRAINTS */
-
-
-static int DecodeAltNames(byte* input, int sz, DecodedCert* cert)
-{
-    word32 idx = 0;
-    int length = 0;
-
-    WOLFSSL_ENTER("DecodeAltNames");
-
-    if (GetSequence(input, &idx, &length, sz) < 0) {
-        WOLFSSL_MSG("\tBad Sequence");
-        return ASN_PARSE_E;
-    }
-
-    cert->weOwnAltNames = 1;
-
-    while (length > 0) {
-        byte       b = input[idx++];
-
-        length--;
-
-        /* Save DNS Type names in the altNames list. */
-        /* Save Other Type names in the cert's OidMap */
-        if (b == (ASN_CONTEXT_SPECIFIC | ASN_DNS_TYPE)) {
-            DNS_entry* dnsEntry;
-            int strLen;
-            word32 lenStartIdx = idx;
-
-            if (GetLength(input, &idx, &strLen, sz) < 0) {
-                WOLFSSL_MSG("\tfail: str length");
-                return ASN_PARSE_E;
-            }
-            length -= (idx - lenStartIdx);
-
-            dnsEntry = (DNS_entry*)XMALLOC(sizeof(DNS_entry), cert->heap,
-                                        DYNAMIC_TYPE_ALTNAME);
-            if (dnsEntry == NULL) {
-                WOLFSSL_MSG("\tOut of Memory");
-                return ASN_PARSE_E;
-            }
-
-            dnsEntry->name = (char*)XMALLOC(strLen + 1, cert->heap,
-                                         DYNAMIC_TYPE_ALTNAME);
-            if (dnsEntry->name == NULL) {
-                WOLFSSL_MSG("\tOut of Memory");
-                XFREE(dnsEntry, cert->heap, DYNAMIC_TYPE_ALTNAME);
-                return ASN_PARSE_E;
-            }
-
-            XMEMCPY(dnsEntry->name, &input[idx], strLen);
-            dnsEntry->name[strLen] = '\0';
-
-            dnsEntry->next = cert->altNames;
-            cert->altNames = dnsEntry;
-
-            length -= strLen;
-            idx    += strLen;
-        }
-#ifndef IGNORE_NAME_CONSTRAINTS
-        else if (b == (ASN_CONTEXT_SPECIFIC | ASN_RFC822_TYPE)) {
-            DNS_entry* emailEntry;
-            int strLen;
-            word32 lenStartIdx = idx;
-
-            if (GetLength(input, &idx, &strLen, sz) < 0) {
-                WOLFSSL_MSG("\tfail: str length");
-                return ASN_PARSE_E;
-            }
-            length -= (idx - lenStartIdx);
-
-            emailEntry = (DNS_entry*)XMALLOC(sizeof(DNS_entry), cert->heap,
-                                        DYNAMIC_TYPE_ALTNAME);
-            if (emailEntry == NULL) {
-                WOLFSSL_MSG("\tOut of Memory");
-                return ASN_PARSE_E;
-            }
-
-            emailEntry->name = (char*)XMALLOC(strLen + 1, cert->heap,
-                                         DYNAMIC_TYPE_ALTNAME);
-            if (emailEntry->name == NULL) {
-                WOLFSSL_MSG("\tOut of Memory");
-                XFREE(emailEntry, cert->heap, DYNAMIC_TYPE_ALTNAME);
-                return ASN_PARSE_E;
-            }
-
-            XMEMCPY(emailEntry->name, &input[idx], strLen);
-            emailEntry->name[strLen] = '\0';
-
-            emailEntry->next = cert->altEmailNames;
-            cert->altEmailNames = emailEntry;
-
-            length -= strLen;
-            idx    += strLen;
-        }
-#endif /* IGNORE_NAME_CONSTRAINTS */
-#ifdef WOLFSSL_SEP
-        else if (b == (ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED | ASN_OTHER_TYPE))
-        {
-            int strLen;
-            word32 lenStartIdx = idx;
-            word32 oid = 0;
-
-            if (GetLength(input, &idx, &strLen, sz) < 0) {
-                WOLFSSL_MSG("\tfail: other name length");
-                return ASN_PARSE_E;
-            }
-            /* Consume the rest of this sequence. */
-            length -= (strLen + idx - lenStartIdx);
-
-            if (GetObjectId(input, &idx, &oid, sz) < 0) {
-                WOLFSSL_MSG("\tbad OID");
-                return ASN_PARSE_E;
-            }
-
-            if (oid != HW_NAME_OID) {
-                WOLFSSL_MSG("\tincorrect OID");
-                return ASN_PARSE_E;
-            }
-
-            if (input[idx++] != (ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED)) {
-                WOLFSSL_MSG("\twrong type");
-                return ASN_PARSE_E;
-            }
-
-            if (GetLength(input, &idx, &strLen, sz) < 0) {
-                WOLFSSL_MSG("\tfail: str len");
-                return ASN_PARSE_E;
-            }
-
-            if (GetSequence(input, &idx, &strLen, sz) < 0) {
-                WOLFSSL_MSG("\tBad Sequence");
-                return ASN_PARSE_E;
-            }
-
-            if (input[idx++] != ASN_OBJECT_ID) {
-                WOLFSSL_MSG("\texpected OID");
-                return ASN_PARSE_E;
-            }
-
-            if (GetLength(input, &idx, &strLen, sz) < 0) {
-                WOLFSSL_MSG("\tfailed: str len");
-                return ASN_PARSE_E;
-            }
-
-            cert->hwType = (byte*)XMALLOC(strLen, cert->heap, 0);
-            if (cert->hwType == NULL) {
-                WOLFSSL_MSG("\tOut of Memory");
-                return MEMORY_E;
-            }
-
-            XMEMCPY(cert->hwType, &input[idx], strLen);
-            cert->hwTypeSz = strLen;
-            idx += strLen;
-
-            if (input[idx++] != ASN_OCTET_STRING) {
-                WOLFSSL_MSG("\texpected Octet String");
-                return ASN_PARSE_E;
-            }
-
-            if (GetLength(input, &idx, &strLen, sz) < 0) {
-                WOLFSSL_MSG("\tfailed: str len");
-                return ASN_PARSE_E;
-            }
-
-            cert->hwSerialNum = (byte*)XMALLOC(strLen + 1, cert->heap, 0);
-            if (cert->hwSerialNum == NULL) {
-                WOLFSSL_MSG("\tOut of Memory");
-                return MEMORY_E;
-            }
-
-            XMEMCPY(cert->hwSerialNum, &input[idx], strLen);
-            cert->hwSerialNum[strLen] = '\0';
-            cert->hwSerialNumSz = strLen;
-            idx += strLen;
-        }
-#endif /* WOLFSSL_SEP */
-        else {
-            int strLen;
-            word32 lenStartIdx = idx;
-
-            WOLFSSL_MSG("\tUnsupported name type, skipping");
-
-            if (GetLength(input, &idx, &strLen, sz) < 0) {
-                WOLFSSL_MSG("\tfail: unsupported name length");
-                return ASN_PARSE_E;
-            }
-            length -= (strLen + idx - lenStartIdx);
-            idx += strLen;
-        }
-    }
-    return 0;
-}
-
-
-static int DecodeBasicCaConstraint(byte* input, int sz, DecodedCert* cert)
-{
-    word32 idx = 0;
-    int length = 0;
-
-    WOLFSSL_ENTER("DecodeBasicCaConstraint");
-    if (GetSequence(input, &idx, &length, sz) < 0) {
-        WOLFSSL_MSG("\tfail: bad SEQUENCE");
-        return ASN_PARSE_E;
-    }
-
-    if (length == 0)
-        return 0;
-
-    /* If the basic ca constraint is false, this extension may be named, but
-     * left empty. So, if the length is 0, just return. */
-
-    if (input[idx++] != ASN_BOOLEAN)
-    {
-        WOLFSSL_MSG("\tfail: constraint not BOOLEAN");
-        return ASN_PARSE_E;
-    }
-
-    if (GetLength(input, &idx, &length, sz) < 0)
-    {
-        WOLFSSL_MSG("\tfail: length");
-        return ASN_PARSE_E;
-    }
-
-    if (input[idx++])
-        cert->isCA = 1;
-
-    #ifdef OPENSSL_EXTRA
-        /* If there isn't any more data, return. */
-        if (idx >= (word32)sz)
-            return 0;
-
-        /* Anything left should be the optional pathlength */
-        if (input[idx++] != ASN_INTEGER) {
-            WOLFSSL_MSG("\tfail: pathlen not INTEGER");
-            return ASN_PARSE_E;
-        }
-
-        if (input[idx++] != 1) {
-            WOLFSSL_MSG("\tfail: pathlen too long");
-            return ASN_PARSE_E;
-        }
-
-        cert->pathLength = input[idx];
-        cert->extBasicConstPlSet = 1;
-    #endif /* OPENSSL_EXTRA */
-
-    return 0;
-}
-
-
-#define CRLDP_FULL_NAME 0
-    /* From RFC3280 SS4.2.1.14, Distribution Point Name*/
-#define GENERALNAME_URI 6
-    /* From RFC3280 SS4.2.1.7, GeneralName */
-
-static int DecodeCrlDist(byte* input, int sz, DecodedCert* cert)
-{
-    word32 idx = 0;
-    int length = 0;
-
-    WOLFSSL_ENTER("DecodeCrlDist");
-
-    /* Unwrap the list of Distribution Points*/
-    if (GetSequence(input, &idx, &length, sz) < 0)
-        return ASN_PARSE_E;
-
-    /* Unwrap a single Distribution Point */
-    if (GetSequence(input, &idx, &length, sz) < 0)
-        return ASN_PARSE_E;
-
-    /* The Distribution Point has three explicit optional members
-     *  First check for a DistributionPointName
-     */
-    if (input[idx] == (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 0))
-    {
-        idx++;
-        if (GetLength(input, &idx, &length, sz) < 0)
-            return ASN_PARSE_E;
-
-        if (input[idx] == 
-                    (ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED | CRLDP_FULL_NAME))
-        {
-            idx++;
-            if (GetLength(input, &idx, &length, sz) < 0)
-                return ASN_PARSE_E;
-
-            if (input[idx] == (ASN_CONTEXT_SPECIFIC | GENERALNAME_URI))
-            {
-                idx++;
-                if (GetLength(input, &idx, &length, sz) < 0)
-                    return ASN_PARSE_E;
-
-                cert->extCrlInfoSz = length;
-                cert->extCrlInfo = input + idx;
-                idx += length;
-            }
-            else
-                /* This isn't a URI, skip it. */
-                idx += length;
-        }
-        else
-            /* This isn't a FULLNAME, skip it. */
-            idx += length;
-    }
-
-    /* Check for reasonFlags */
-    if (idx < (word32)sz &&
-        input[idx] == (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 1))
-    {
-        idx++;
-        if (GetLength(input, &idx, &length, sz) < 0)
-            return ASN_PARSE_E;
-        idx += length;
-    }
-
-    /* Check for cRLIssuer */
-    if (idx < (word32)sz &&
-        input[idx] == (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 2))
-    {
-        idx++;
-        if (GetLength(input, &idx, &length, sz) < 0)
-            return ASN_PARSE_E;
-        idx += length;
-    }
-
-    if (idx < (word32)sz)
-    {
-        WOLFSSL_MSG("\tThere are more CRL Distribution Point records, "
-                   "but we only use the first one.");
-    }
-
-    return 0;
-}
-
-
-static int DecodeAuthInfo(byte* input, int sz, DecodedCert* cert)
-/*
- *  Read the first of the Authority Information Access records. If there are
- *  any issues, return without saving the record.
- */
-{
-    word32 idx = 0;
-    int length = 0;
-    byte b;
-    word32 oid;
-
-    WOLFSSL_ENTER("DecodeAuthInfo");
-
-    /* Unwrap the list of AIAs */
-    if (GetSequence(input, &idx, &length, sz) < 0)
-        return ASN_PARSE_E;
-
-    while (idx < (word32)sz) {
-        /* Unwrap a single AIA */
-        if (GetSequence(input, &idx, &length, sz) < 0)
-            return ASN_PARSE_E;
-
-        oid = 0;
-        if (GetObjectId(input, &idx, &oid, sz) < 0)
-            return ASN_PARSE_E;
-
-        /* Only supporting URIs right now. */
-        b = input[idx++];
-        if (GetLength(input, &idx, &length, sz) < 0)
-            return ASN_PARSE_E;
-
-        if (b == (ASN_CONTEXT_SPECIFIC | GENERALNAME_URI) &&
-            oid == AIA_OCSP_OID)
-        {
-            cert->extAuthInfoSz = length;
-            cert->extAuthInfo = input + idx;
-            break;
-        }
-        idx += length;
-    }
-
-    return 0;
-}
-
-
-static int DecodeAuthKeyId(byte* input, int sz, DecodedCert* cert)
-{
-    word32 idx = 0;
-    int length = 0, ret = 0;
-
-    WOLFSSL_ENTER("DecodeAuthKeyId");
-
-    if (GetSequence(input, &idx, &length, sz) < 0) {
-        WOLFSSL_MSG("\tfail: should be a SEQUENCE\n");
-        return ASN_PARSE_E;
-    }
-
-    if (input[idx++] != (ASN_CONTEXT_SPECIFIC | 0)) {
-        WOLFSSL_MSG("\tinfo: OPTIONAL item 0, not available\n");
-        return 0;
-    }
-
-    if (GetLength(input, &idx, &length, sz) < 0) {
-        WOLFSSL_MSG("\tfail: extension data length");
-        return ASN_PARSE_E;
-    }
-
-    #ifdef OPENSSL_EXTRA
-        cert->extAuthKeyIdSrc = &input[idx];
-        cert->extAuthKeyIdSz = length;
-    #endif /* OPENSSL_EXTRA */
-
-    if (length == KEYID_SIZE) {
-        XMEMCPY(cert->extAuthKeyId, input + idx, length);
-    }
-    else {
-    #ifdef NO_SHA
-        ret = wc_Sha256Hash(input + idx, length, cert->extAuthKeyId);
-    #else
-        ret = wc_ShaHash(input + idx, length, cert->extAuthKeyId);
-    #endif
-    }
-
-    return ret;
-}
-
-
-static int DecodeSubjKeyId(byte* input, int sz, DecodedCert* cert)
-{
-    word32 idx = 0;
-    int length = 0, ret = 0;
-
-    WOLFSSL_ENTER("DecodeSubjKeyId");
-
-    if (input[idx++] != ASN_OCTET_STRING) {
-        WOLFSSL_MSG("\tfail: should be an OCTET STRING");
-        return ASN_PARSE_E;
-    }
-
-    if (GetLength(input, &idx, &length, sz) < 0) {
-        WOLFSSL_MSG("\tfail: extension data length");
-        return ASN_PARSE_E;
-    }
-
-    #ifdef OPENSSL_EXTRA
-        cert->extSubjKeyIdSrc = &input[idx];
-        cert->extSubjKeyIdSz = length;
-    #endif /* OPENSSL_EXTRA */
-
-    if (length == SIGNER_DIGEST_SIZE) {
-        XMEMCPY(cert->extSubjKeyId, input + idx, length);
-    }
-    else {
-    #ifdef NO_SHA
-        ret = wc_Sha256Hash(input + idx, length, cert->extSubjKeyId);
-    #else
-        ret = wc_ShaHash(input + idx, length, cert->extSubjKeyId);
-    #endif
-    }
-
-    return ret;
-}
-
-
-static int DecodeKeyUsage(byte* input, int sz, DecodedCert* cert)
-{
-    word32 idx = 0;
-    int length;
-    byte unusedBits;
-    WOLFSSL_ENTER("DecodeKeyUsage");
-
-    if (input[idx++] != ASN_BIT_STRING) {
-        WOLFSSL_MSG("\tfail: key usage expected bit string");
-        return ASN_PARSE_E;
-    }
-
-    if (GetLength(input, &idx, &length, sz) < 0) {
-        WOLFSSL_MSG("\tfail: key usage bad length");
-        return ASN_PARSE_E;
-    }
-
-    unusedBits = input[idx++];
-    length--;
-
-    if (length == 2) {
-        cert->extKeyUsage = (word16)((input[idx] << 8) | input[idx+1]);
-        cert->extKeyUsage >>= unusedBits;
-    }
-    else if (length == 1)
-        cert->extKeyUsage = (word16)(input[idx] << 1);
-
-    return 0;
-}
-
-
-static int DecodeExtKeyUsage(byte* input, int sz, DecodedCert* cert)
-{
-    word32 idx = 0, oid;
-    int length;
-
-    WOLFSSL_ENTER("DecodeExtKeyUsage");
-
-    if (GetSequence(input, &idx, &length, sz) < 0) {
-        WOLFSSL_MSG("\tfail: should be a SEQUENCE");
-        return ASN_PARSE_E;
-    }
-
-    #ifdef OPENSSL_EXTRA
-        cert->extExtKeyUsageSrc = input + idx;
-        cert->extExtKeyUsageSz = length;
-    #endif
-
-    while (idx < (word32)sz) {
-        if (GetObjectId(input, &idx, &oid, sz) < 0)
-            return ASN_PARSE_E;
-
-        switch (oid) {
-            case EKU_ANY_OID:
-                cert->extExtKeyUsage |= EXTKEYUSE_ANY;
-                break;
-            case EKU_SERVER_AUTH_OID:
-                cert->extExtKeyUsage |= EXTKEYUSE_SERVER_AUTH;
-                break;
-            case EKU_CLIENT_AUTH_OID:
-                cert->extExtKeyUsage |= EXTKEYUSE_CLIENT_AUTH;
-                break;
-            case EKU_OCSP_SIGN_OID:
-                cert->extExtKeyUsage |= EXTKEYUSE_OCSP_SIGN;
-                break;
-        }
-
-        #ifdef OPENSSL_EXTRA
-            cert->extExtKeyUsageCount++;
-        #endif
-    }
-
-    return 0;
-}
-
-
-#ifndef IGNORE_NAME_CONSTRAINTS
-static int DecodeSubtree(byte* input, int sz, Base_entry** head, void* heap)
-{
-    word32 idx = 0;
-
-    (void)heap;
-
-    while (idx < (word32)sz) {
-        int seqLength, strLength;
-        word32 nameIdx;
-        byte b;
-
-        if (GetSequence(input, &idx, &seqLength, sz) < 0) {
-            WOLFSSL_MSG("\tfail: should be a SEQUENCE");
-            return ASN_PARSE_E;
-        }
-
-        nameIdx = idx;
-        b = input[nameIdx++];
-        if (GetLength(input, &nameIdx, &strLength, sz) <= 0) {
-            WOLFSSL_MSG("\tinvalid length");
-            return ASN_PARSE_E;
-        }
-
-        if (b == (ASN_CONTEXT_SPECIFIC | ASN_DNS_TYPE) ||
-            b == (ASN_CONTEXT_SPECIFIC | ASN_RFC822_TYPE) ||
-            b == (ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED | ASN_DIR_TYPE)) {
-
-            Base_entry* entry = (Base_entry*)XMALLOC(sizeof(Base_entry),
-                                                    heap, DYNAMIC_TYPE_ALTNAME);
-
-            if (entry == NULL) {
-                WOLFSSL_MSG("allocate error");
-                return MEMORY_E;
-            }
-
-            entry->name = (char*)XMALLOC(strLength, heap, DYNAMIC_TYPE_ALTNAME);
-            if (entry->name == NULL) {
-                WOLFSSL_MSG("allocate error");
-                return MEMORY_E;
-            }
-
-            XMEMCPY(entry->name, &input[nameIdx], strLength);
-            entry->nameSz = strLength;
-            entry->type = b & 0x0F;
-
-            entry->next = *head;
-            *head = entry;
-        }
-
-        idx += seqLength;
-    }
-
-    return 0;
-}
-
-
-static int DecodeNameConstraints(byte* input, int sz, DecodedCert* cert)
-{
-    word32 idx = 0;
-    int length = 0;
-
-    WOLFSSL_ENTER("DecodeNameConstraints");
-
-    if (GetSequence(input, &idx, &length, sz) < 0) {
-        WOLFSSL_MSG("\tfail: should be a SEQUENCE");
-        return ASN_PARSE_E;
-    }
-
-    while (idx < (word32)sz) {
-        byte b = input[idx++];
-        Base_entry** subtree = NULL;
-
-        if (GetLength(input, &idx, &length, sz) <= 0) {
-            WOLFSSL_MSG("\tinvalid length");
-            return ASN_PARSE_E;
-        }
-
-        if (b == (ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED | 0))
-            subtree = &cert->permittedNames;
-        else if (b == (ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED | 1))
-            subtree = &cert->excludedNames;
-        else {
-            WOLFSSL_MSG("\tinvalid subtree");
-            return ASN_PARSE_E;
-        }
-
-        DecodeSubtree(input + idx, length, subtree, cert->heap);
-
-        idx += length;
-    }
-
-    return 0;
-}
-#endif /* IGNORE_NAME_CONSTRAINTS */
-
-
-#ifdef WOLFSSL_SEP
-    static int DecodeCertPolicy(byte* input, int sz, DecodedCert* cert)
-    {
-        word32 idx = 0;
-        int length = 0;
-
-        WOLFSSL_ENTER("DecodeCertPolicy");
-
-        /* Unwrap certificatePolicies */
-        if (GetSequence(input, &idx, &length, sz) < 0) {
-            WOLFSSL_MSG("\tdeviceType isn't OID");
-            return ASN_PARSE_E;
-        }
-
-        if (GetSequence(input, &idx, &length, sz) < 0) {
-            WOLFSSL_MSG("\tdeviceType isn't OID");
-            return ASN_PARSE_E;
-        }
-
-        if (input[idx++] != ASN_OBJECT_ID) {
-            WOLFSSL_MSG("\tdeviceType isn't OID");
-            return ASN_PARSE_E;
-        }
-
-        if (GetLength(input, &idx, &length, sz) < 0) {
-            WOLFSSL_MSG("\tCouldn't read length of deviceType");
-            return ASN_PARSE_E;
-        }
-
-        if (length > 0) {
-            cert->deviceType = (byte*)XMALLOC(length, cert->heap, 0);
-            if (cert->deviceType == NULL) {
-                WOLFSSL_MSG("\tCouldn't alloc memory for deviceType");
-                return MEMORY_E;
-            }
-            cert->deviceTypeSz = length;
-            XMEMCPY(cert->deviceType, input + idx, length);
-        }
-
-        WOLFSSL_LEAVE("DecodeCertPolicy", 0);
-        return 0;
-    }
-#endif /* WOLFSSL_SEP */
-
-
-static int DecodeCertExtensions(DecodedCert* cert)
-/*
- *  Processing the Certificate Extensions. This does not modify the current
- *  index. It is works starting with the recorded extensions pointer.
- */
-{
-    word32 idx = 0;
-    int sz = cert->extensionsSz;
-    byte* input = cert->extensions;
-    int length;
-    word32 oid;
-    byte critical = 0;
-    byte criticalFail = 0;
-
-    WOLFSSL_ENTER("DecodeCertExtensions");
-
-    if (input == NULL || sz == 0)
-        return BAD_FUNC_ARG;
-
-    if (input[idx++] != ASN_EXTENSIONS)
-        return ASN_PARSE_E;
-
-    if (GetLength(input, &idx, &length, sz) < 0)
-        return ASN_PARSE_E;
-
-    if (GetSequence(input, &idx, &length, sz) < 0)
-        return ASN_PARSE_E;
-    
-    while (idx < (word32)sz) {
-        if (GetSequence(input, &idx, &length, sz) < 0) {
-            WOLFSSL_MSG("\tfail: should be a SEQUENCE");
-            return ASN_PARSE_E;
-        }
-
-        oid = 0;
-        if (GetObjectId(input, &idx, &oid, sz) < 0) {
-            WOLFSSL_MSG("\tfail: OBJECT ID");
-            return ASN_PARSE_E;
-        }
-
-        /* check for critical flag */
-        critical = 0;
-        if (input[idx] == ASN_BOOLEAN) {
-            int boolLength = 0;
-            idx++;
-            if (GetLength(input, &idx, &boolLength, sz) < 0) {
-                WOLFSSL_MSG("\tfail: critical boolean length");
-                return ASN_PARSE_E;
-            }
-            if (input[idx++])
-                critical = 1;
-        }
-
-        /* process the extension based on the OID */
-        if (input[idx++] != ASN_OCTET_STRING) {
-            WOLFSSL_MSG("\tfail: should be an OCTET STRING");
-            return ASN_PARSE_E;
-        }
-
-        if (GetLength(input, &idx, &length, sz) < 0) {
-            WOLFSSL_MSG("\tfail: extension data length");
-            return ASN_PARSE_E;
-        }
-
-        switch (oid) {
-            case BASIC_CA_OID:
-                #ifdef OPENSSL_EXTRA
-                    cert->extBasicConstSet = 1;
-                    cert->extBasicConstCrit = critical;
-                #endif
-                if (DecodeBasicCaConstraint(&input[idx], length, cert) < 0)
-                    return ASN_PARSE_E;
-                break;
-
-            case CRL_DIST_OID:
-                if (DecodeCrlDist(&input[idx], length, cert) < 0)
-                    return ASN_PARSE_E;
-                break;
-
-            case AUTH_INFO_OID:
-                if (DecodeAuthInfo(&input[idx], length, cert) < 0)
-                    return ASN_PARSE_E;
-                break;
-
-            case ALT_NAMES_OID:
-                #ifdef OPENSSL_EXTRA
-                    cert->extSubjAltNameSet = 1;
-                    cert->extSubjAltNameCrit = critical;
-                #endif
-                if (DecodeAltNames(&input[idx], length, cert) < 0)
-                    return ASN_PARSE_E;
-                break;
-
-            case AUTH_KEY_OID:
-                cert->extAuthKeyIdSet = 1;
-                #ifdef OPENSSL_EXTRA
-                    cert->extAuthKeyIdCrit = critical;
-                #endif
-                if (DecodeAuthKeyId(&input[idx], length, cert) < 0)
-                    return ASN_PARSE_E;
-                break;
-
-            case SUBJ_KEY_OID:
-                cert->extSubjKeyIdSet = 1;
-                #ifdef OPENSSL_EXTRA
-                    cert->extSubjKeyIdCrit = critical;
-                #endif
-                if (DecodeSubjKeyId(&input[idx], length, cert) < 0)
-                    return ASN_PARSE_E;
-                break;
-
-            case CERT_POLICY_OID:
-                WOLFSSL_MSG("Certificate Policy extension not supported yet.");
-                #ifdef WOLFSSL_SEP
-                    #ifdef OPENSSL_EXTRA
-                        cert->extCertPolicySet = 1;
-                        cert->extCertPolicyCrit = critical;
-                    #endif
-                    if (DecodeCertPolicy(&input[idx], length, cert) < 0)
-                        return ASN_PARSE_E;
-                #endif
-                break;
-
-            case KEY_USAGE_OID:
-                cert->extKeyUsageSet = 1;
-                #ifdef OPENSSL_EXTRA
-                    cert->extKeyUsageCrit = critical;
-                #endif
-                if (DecodeKeyUsage(&input[idx], length, cert) < 0)
-                    return ASN_PARSE_E;
-                break;
-
-            case EXT_KEY_USAGE_OID:
-                cert->extExtKeyUsageSet = 1;
-                #ifdef OPENSSL_EXTRA
-                    cert->extExtKeyUsageCrit = critical;
-                #endif
-                if (DecodeExtKeyUsage(&input[idx], length, cert) < 0)
-                    return ASN_PARSE_E;
-                break;
-
-            #ifndef IGNORE_NAME_CONSTRAINTS
-            case NAME_CONS_OID:
-                cert->extNameConstraintSet = 1;
-                #ifdef OPENSSL_EXTRA
-                    cert->extNameConstraintCrit = critical;
-                #endif
-                if (DecodeNameConstraints(&input[idx], length, cert) < 0)
-                    return ASN_PARSE_E;
-                break;
-            #endif /* IGNORE_NAME_CONSTRAINTS */
-
-            case INHIBIT_ANY_OID:
-                WOLFSSL_MSG("Inhibit anyPolicy extension not supported yet.");
-                break;
-
-            default:
-                /* While it is a failure to not support critical extensions,
-                 * still parse the certificate ignoring the unsupported
-                 * extention to allow caller to accept it with the verify
-                 * callback. */
-                if (critical)
-                    criticalFail = 1;
-                break;
-        }
-        idx += length;
-    }
-
-    return criticalFail ? ASN_CRIT_EXT_E : 0;
-}
-
-
-int ParseCert(DecodedCert* cert, int type, int verify, void* cm)
-{
-    int   ret;
-    char* ptr;
-
-    ret = ParseCertRelative(cert, type, verify, cm);
-    if (ret < 0)
-        return ret;
-
-    if (cert->subjectCNLen > 0) {
-        ptr = (char*) XMALLOC(cert->subjectCNLen + 1, cert->heap,
-                              DYNAMIC_TYPE_SUBJECT_CN);
-        if (ptr == NULL)
-            return MEMORY_E;
-        XMEMCPY(ptr, cert->subjectCN, cert->subjectCNLen);
-        ptr[cert->subjectCNLen] = '\0';
-        cert->subjectCN = ptr;
-        cert->subjectCNStored = 1;
-    }
-
-    if (cert->keyOID == RSAk &&
-                          cert->publicKey != NULL  && cert->pubKeySize > 0) {
-        ptr = (char*) XMALLOC(cert->pubKeySize, cert->heap,
-                              DYNAMIC_TYPE_PUBLIC_KEY);
-        if (ptr == NULL)
-            return MEMORY_E;
-        XMEMCPY(ptr, cert->publicKey, cert->pubKeySize);
-        cert->publicKey = (byte *)ptr;
-        cert->pubKeyStored = 1;
-    }
-
-    return ret;
-}
-
-
-/* from SSL proper, for locking can't do find here anymore */
-#ifdef __cplusplus
-    extern "C" {
-#endif
-    WOLFSSL_LOCAL Signer* GetCA(void* signers, byte* hash);
-    #ifndef NO_SKID
-        WOLFSSL_LOCAL Signer* GetCAByName(void* signers, byte* hash);
-    #endif
-#ifdef __cplusplus
-    } 
-#endif
-
-
-int ParseCertRelative(DecodedCert* cert, int type, int verify, void* cm)
-{
-    word32 confirmOID;
-    int    ret;
-    int    badDate     = 0;
-    int    criticalExt = 0;
-
-    if ((ret = DecodeToKey(cert, verify)) < 0) {
-        if (ret == ASN_BEFORE_DATE_E || ret == ASN_AFTER_DATE_E)
-            badDate = ret;
-        else
-            return ret;
-    }
-
-    WOLFSSL_MSG("Parsed Past Key");
-
-    if (cert->srcIdx < cert->sigIndex) {
-        #ifndef ALLOW_V1_EXTENSIONS
-            if (cert->version < 2) {
-                WOLFSSL_MSG("    v1 and v2 certs not allowed extensions");
-                return ASN_VERSION_E;
-            }
-        #endif
-        /* save extensions */
-        cert->extensions    = &cert->source[cert->srcIdx];
-        cert->extensionsSz  =  cert->sigIndex - cert->srcIdx;
-        cert->extensionsIdx = cert->srcIdx;   /* for potential later use */
-
-        if ((ret = DecodeCertExtensions(cert)) < 0) {
-            if (ret == ASN_CRIT_EXT_E)
-                criticalExt = ret;
-            else
-                return ret;
-        }
-
-        /* advance past extensions */
-        cert->srcIdx =  cert->sigIndex;
-    }
-
-    if ((ret = GetAlgoId(cert->source, &cert->srcIdx, &confirmOID,
-                         cert->maxIdx)) < 0)
-        return ret;
-
-    if ((ret = GetSignature(cert)) < 0)
-        return ret;
-
-    if (confirmOID != cert->signatureOID)
-        return ASN_SIG_OID_E;
-
-    #ifndef NO_SKID
-        if (cert->extSubjKeyIdSet == 0
-                          && cert->publicKey != NULL && cert->pubKeySize > 0) {
-        #ifdef NO_SHA
-            ret = wc_Sha256Hash(cert->publicKey, cert->pubKeySize,
-                                                            cert->extSubjKeyId);
-        #else
-            ret = wc_ShaHash(cert->publicKey, cert->pubKeySize,
-                                                            cert->extSubjKeyId);
-        #endif
-            if (ret != 0)
-                return ret;
-        }
-    #endif
-
-    if (verify && type != CA_TYPE) {
-        Signer* ca = NULL;
-        #ifndef NO_SKID
-            if (cert->extAuthKeyIdSet)
-                ca = GetCA(cm, cert->extAuthKeyId);
-            if (ca == NULL)
-                ca = GetCAByName(cm, cert->issuerHash);
-        #else /* NO_SKID */
-            ca = GetCA(cm, cert->issuerHash);
-        #endif /* NO SKID */
-        WOLFSSL_MSG("About to verify certificate signature");
- 
-        if (ca) {
-#ifdef HAVE_OCSP
-            /* Need the ca's public key hash for OCSP */
-    #ifdef NO_SHA
-            ret = wc_Sha256Hash(ca->publicKey, ca->pubKeySize,
-                                cert->issuerKeyHash);
-    #else /* NO_SHA */
-            ret = wc_ShaHash(ca->publicKey, ca->pubKeySize,
-                                cert->issuerKeyHash);
-    #endif /* NO_SHA */
-            if (ret != 0)
-                return ret;
-#endif /* HAVE_OCSP */
-            /* try to confirm/verify signature */
-            if (!ConfirmSignature(cert->source + cert->certBegin,
-                        cert->sigIndex - cert->certBegin,
-                    ca->publicKey, ca->pubKeySize, ca->keyOID,
-                    cert->signature, cert->sigLength, cert->signatureOID,
-                    cert->heap)) {
-                WOLFSSL_MSG("Confirm signature failed");
-                return ASN_SIG_CONFIRM_E;
-            }
-#ifndef IGNORE_NAME_CONSTRAINTS
-            /* check that this cert's name is permitted by the signer's
-             * name constraints */
-            if (!ConfirmNameConstraints(ca, cert)) {
-                WOLFSSL_MSG("Confirm name constraint failed");
-                return ASN_NAME_INVALID_E;
-            }
-#endif /* IGNORE_NAME_CONSTRAINTS */
-        }
-        else {
-            /* no signer */
-            WOLFSSL_MSG("No CA signer to verify with");
-            return ASN_NO_SIGNER_E;
-        }
-    }
-
-    if (badDate != 0)
-        return badDate;
-
-    if (criticalExt != 0)
-        return criticalExt;
-
-    return 0;
-}
-
-
-/* Create and init an new signer */
-Signer* MakeSigner(void* heap)
-{
-    Signer* signer = (Signer*) XMALLOC(sizeof(Signer), heap,
-                                       DYNAMIC_TYPE_SIGNER);
-    if (signer) {
-        signer->pubKeySize = 0;
-        signer->keyOID     = 0;
-        signer->publicKey  = NULL;
-        signer->nameLen    = 0;
-        signer->name       = NULL;
-        #ifndef IGNORE_NAME_CONSTRAINTS
-            signer->permittedNames = NULL;
-            signer->excludedNames = NULL;
-        #endif /* IGNORE_NAME_CONSTRAINTS */
-        signer->next       = NULL;
-    }
-    (void)heap;
-
-    return signer;
-}
-
-
-/* Free an individual signer */
-void FreeSigner(Signer* signer, void* heap)
-{
-    XFREE(signer->name, heap, DYNAMIC_TYPE_SUBJECT_CN);
-    XFREE(signer->publicKey, heap, DYNAMIC_TYPE_PUBLIC_KEY);
-    #ifndef IGNORE_NAME_CONSTRAINTS
-        if (signer->permittedNames)
-            FreeNameSubtrees(signer->permittedNames, heap);
-        if (signer->excludedNames)
-            FreeNameSubtrees(signer->excludedNames, heap);
-    #endif
-    XFREE(signer, heap, DYNAMIC_TYPE_SIGNER);
-
-    (void)heap;
-}
-
-
-/* Free the whole singer table with number of rows */
-void FreeSignerTable(Signer** table, int rows, void* heap)
-{
-    int i;
-
-    for (i = 0; i < rows; i++) {
-        Signer* signer = table[i];
-        while (signer) {
-            Signer* next = signer->next;
-            FreeSigner(signer, heap);
-            signer = next;
-        }
-        table[i] = NULL;
-    }
-}
-
-
-WOLFSSL_LOCAL int SetMyVersion(word32 version, byte* output, int header)
-{
-    int i = 0;
-
-    if (header) {
-        output[i++] = ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED;
-        output[i++] = ASN_BIT_STRING;
-    }
-    output[i++] = ASN_INTEGER;
-    output[i++] = 0x01;
-    output[i++] = (byte)version;
-
-    return i;
-}
-
-
-WOLFSSL_LOCAL int SetSerialNumber(const byte* sn, word32 snSz, byte* output)
-{
-    int result = 0;
-
-    WOLFSSL_ENTER("SetSerialNumber");
-
-    if (snSz <= EXTERNAL_SERIAL_SIZE) {
-        output[0] = ASN_INTEGER;
-        /* The serial number is always positive. When encoding the
-         * INTEGER, if the MSB is 1, add a padding zero to keep the
-         * number positive. */
-        if (sn[0] & 0x80) {
-            output[1] = (byte)snSz + 1;
-            output[2] = 0;
-            XMEMCPY(&output[3], sn, snSz);
-            result = snSz + 3;
-        }
-        else {
-            output[1] = (byte)snSz;
-            XMEMCPY(&output[2], sn, snSz);
-            result = snSz + 2;
-        }
-    }
-    return result;
-}
-
-
-
-
-#if defined(WOLFSSL_KEY_GEN) || defined(WOLFSSL_CERT_GEN)
-
-/* convert der buffer to pem into output, can't do inplace, der and output
-   need to be different */
-int wc_DerToPem(const byte* der, word32 derSz, byte* output, word32 outSz,
-             int type)
-{
-#ifdef WOLFSSL_SMALL_STACK
-    char* header = NULL;
-    char* footer = NULL;
-#else
-    char header[80];
-    char footer[80];
-#endif
-
-    int headerLen = 80;
-    int footerLen = 80;
-    int i;
-    int err;
-    int outLen;   /* return length or error */
-
-    if (der == output)      /* no in place conversion */
-        return BAD_FUNC_ARG;
-
-#ifdef WOLFSSL_SMALL_STACK
-    header = (char*)XMALLOC(headerLen, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (header == NULL)
-        return MEMORY_E;
-    
-    footer = (char*)XMALLOC(footerLen, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (footer == NULL) {
-        XFREE(header, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#endif
-
-    if (type == CERT_TYPE) {
-        XSTRNCPY(header, "-----BEGIN CERTIFICATE-----\n", headerLen);
-        XSTRNCPY(footer, "-----END CERTIFICATE-----\n",   footerLen);
-    }
-    else if (type == PRIVATEKEY_TYPE) {
-        XSTRNCPY(header, "-----BEGIN RSA PRIVATE KEY-----\n", headerLen);
-        XSTRNCPY(footer, "-----END RSA PRIVATE KEY-----\n",   footerLen);
-    }
-    #ifdef HAVE_ECC
-    else if (type == ECC_PRIVATEKEY_TYPE) {
-        XSTRNCPY(header, "-----BEGIN EC PRIVATE KEY-----\n", headerLen);
-        XSTRNCPY(footer, "-----END EC PRIVATE KEY-----\n",   footerLen);
-    }
-    #endif
-    #ifdef WOLFSSL_CERT_REQ
-    else if (type == CERTREQ_TYPE)
-    {
-        XSTRNCPY(header,
-                       "-----BEGIN CERTIFICATE REQUEST-----\n", headerLen);
-        XSTRNCPY(footer, "-----END CERTIFICATE REQUEST-----\n", footerLen);
-    }
-    #endif
-    else {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(header, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(footer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return BAD_FUNC_ARG;
-    }
-
-    headerLen = (int)XSTRLEN(header);
-    footerLen = (int)XSTRLEN(footer);
-
-    if (!der || !output) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(header, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(footer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return BAD_FUNC_ARG;
-    }
-
-    /* don't even try if outSz too short */
-    if (outSz < headerLen + footerLen + derSz) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(header, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(footer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return BAD_FUNC_ARG;
-    }
-
-    /* header */
-    XMEMCPY(output, header, headerLen);
-    i = headerLen;
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(header, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    /* body */
-    outLen = outSz - (headerLen + footerLen);  /* input to Base64_Encode */
-    if ( (err = Base64_Encode(der, derSz, output + i, (word32*)&outLen)) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(footer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return err;
-    }
-    i += outLen;
-
-    /* footer */
-    if ( (i + footerLen) > (int)outSz) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(footer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return BAD_FUNC_ARG;
-    }
-    XMEMCPY(output + i, footer, footerLen);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(footer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return outLen + headerLen + footerLen;
-}
-
-
-#endif /* WOLFSSL_KEY_GEN || WOLFSSL_CERT_GEN */
-
-
-#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA)
-
-
-static mp_int* GetRsaInt(RsaKey* key, int idx)
-{
-    if (idx == 0)
-        return &key->n;
-    if (idx == 1)
-        return &key->e;
-    if (idx == 2)
-        return &key->d;
-    if (idx == 3)
-        return &key->p;
-    if (idx == 4)
-        return &key->q;
-    if (idx == 5)
-        return &key->dP;
-    if (idx == 6)
-        return &key->dQ;
-    if (idx == 7)
-        return &key->u;
-
-    return NULL;
-}
-
-
-/* Release Tmp RSA resources */
-static INLINE void FreeTmpRsas(byte** tmps, void* heap)
-{
-    int i;
-
-    (void)heap;
-
-    for (i = 0; i < RSA_INTS; i++) 
-        XFREE(tmps[i], heap, DYNAMIC_TYPE_RSA);
-}
-
-
-/* Convert RsaKey key to DER format, write to output (inLen), return bytes
-   written */
-int wc_RsaKeyToDer(RsaKey* key, byte* output, word32 inLen)
-{
-    word32 seqSz, verSz, rawLen, intTotalLen = 0;
-    word32 sizes[RSA_INTS];
-    int    i, j, outLen, ret = 0;
-
-    byte  seq[MAX_SEQ_SZ];
-    byte  ver[MAX_VERSION_SZ];
-    byte* tmps[RSA_INTS];
-
-    if (!key || !output)
-        return BAD_FUNC_ARG;
-
-    if (key->type != RSA_PRIVATE)
-        return BAD_FUNC_ARG;
-
-    for (i = 0; i < RSA_INTS; i++)
-        tmps[i] = NULL;
-
-    /* write all big ints from key to DER tmps */
-    for (i = 0; i < RSA_INTS; i++) {
-        mp_int* keyInt = GetRsaInt(key, i);
-        rawLen = mp_unsigned_bin_size(keyInt);
-        tmps[i] = (byte*)XMALLOC(rawLen + MAX_SEQ_SZ, key->heap,
-                                 DYNAMIC_TYPE_RSA);
-        if (tmps[i] == NULL) {
-            ret = MEMORY_E;
-            break;
-        }
-
-        tmps[i][0] = ASN_INTEGER;
-        sizes[i] = SetLength(rawLen, tmps[i] + 1) + 1;  /* int tag */
-
-        if (sizes[i] <= MAX_SEQ_SZ) {
-            int err = mp_to_unsigned_bin(keyInt, tmps[i] + sizes[i]);
-            if (err == MP_OKAY) {
-                sizes[i] += rawLen;
-                intTotalLen += sizes[i];
-            }
-            else {
-                ret = err;
-                break;
-            }
-        }
-        else {
-            ret = ASN_INPUT_E;
-            break;
-        }
-    }
-
-    if (ret != 0) {
-        FreeTmpRsas(tmps, key->heap);
-        return ret;
-    }
-
-    /* make headers */
-    verSz = SetMyVersion(0, ver, FALSE);
-    seqSz = SetSequence(verSz + intTotalLen, seq);
-
-    outLen = seqSz + verSz + intTotalLen;
-    if (outLen > (int)inLen)
-        return BAD_FUNC_ARG;
-
-    /* write to output */
-    XMEMCPY(output, seq, seqSz);
-    j = seqSz;
-    XMEMCPY(output + j, ver, verSz);
-    j += verSz;
-
-    for (i = 0; i < RSA_INTS; i++) {
-        XMEMCPY(output + j, tmps[i], sizes[i]);
-        j += sizes[i];
-    }
-    FreeTmpRsas(tmps, key->heap);
-
-    return outLen;
-}
-
-#endif /* WOLFSSL_KEY_GEN && !NO_RSA */
-
-
-#if defined(WOLFSSL_CERT_GEN) && !defined(NO_RSA)
-
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-
-/* Initialize and Set Certficate defaults:
-   version    = 3 (0x2)
-   serial     = 0
-   sigType    = SHA_WITH_RSA
-   issuer     = blank
-   daysValid  = 500
-   selfSigned = 1 (true) use subject as issuer
-   subject    = blank
-*/
-void wc_InitCert(Cert* cert)
-{
-    cert->version    = 2;   /* version 3 is hex 2 */
-    cert->sigType    = CTC_SHAwRSA;
-    cert->daysValid  = 500;
-    cert->selfSigned = 1;
-    cert->isCA       = 0;
-    cert->bodySz     = 0;
-#ifdef WOLFSSL_ALT_NAMES
-    cert->altNamesSz   = 0;
-    cert->beforeDateSz = 0;
-    cert->afterDateSz  = 0;
-#endif
-    cert->keyType    = RSA_KEY;
-    XMEMSET(cert->serial, 0, CTC_SERIAL_SIZE);
-
-    cert->issuer.country[0] = '\0';
-    cert->issuer.countryEnc = CTC_PRINTABLE;
-    cert->issuer.state[0] = '\0';
-    cert->issuer.stateEnc = CTC_UTF8;
-    cert->issuer.locality[0] = '\0';
-    cert->issuer.localityEnc = CTC_UTF8;
-    cert->issuer.sur[0] = '\0';
-    cert->issuer.surEnc = CTC_UTF8;
-    cert->issuer.org[0] = '\0';
-    cert->issuer.orgEnc = CTC_UTF8;
-    cert->issuer.unit[0] = '\0';
-    cert->issuer.unitEnc = CTC_UTF8;
-    cert->issuer.commonName[0] = '\0';
-    cert->issuer.commonNameEnc = CTC_UTF8;
-    cert->issuer.email[0] = '\0';
-
-    cert->subject.country[0] = '\0';
-    cert->subject.countryEnc = CTC_PRINTABLE;
-    cert->subject.state[0] = '\0';
-    cert->subject.stateEnc = CTC_UTF8;
-    cert->subject.locality[0] = '\0';
-    cert->subject.localityEnc = CTC_UTF8;
-    cert->subject.sur[0] = '\0';
-    cert->subject.surEnc = CTC_UTF8;
-    cert->subject.org[0] = '\0';
-    cert->subject.orgEnc = CTC_UTF8;
-    cert->subject.unit[0] = '\0';
-    cert->subject.unitEnc = CTC_UTF8;
-    cert->subject.commonName[0] = '\0';
-    cert->subject.commonNameEnc = CTC_UTF8;
-    cert->subject.email[0] = '\0';
-
-#ifdef WOLFSSL_CERT_REQ
-    cert->challengePw[0] ='\0';
-#endif
-}
-
-
-/* DER encoded x509 Certificate */
-typedef struct DerCert {
-    byte size[MAX_LENGTH_SZ];          /* length encoded */
-    byte version[MAX_VERSION_SZ];      /* version encoded */
-    byte serial[CTC_SERIAL_SIZE + MAX_LENGTH_SZ]; /* serial number encoded */
-    byte sigAlgo[MAX_ALGO_SZ];         /* signature algo encoded */
-    byte issuer[ASN_NAME_MAX];         /* issuer  encoded */
-    byte subject[ASN_NAME_MAX];        /* subject encoded */
-    byte validity[MAX_DATE_SIZE*2 + MAX_SEQ_SZ*2];  /* before and after dates */
-    byte publicKey[MAX_PUBLIC_KEY_SZ]; /* rsa / ntru public key encoded */
-    byte ca[MAX_CA_SZ];                /* basic constraint CA true size */
-    byte extensions[MAX_EXTENSIONS_SZ];  /* all extensions */
-#ifdef WOLFSSL_CERT_REQ
-    byte attrib[MAX_ATTRIB_SZ];        /* Cert req attributes encoded */
-#endif
-    int  sizeSz;                       /* encoded size length */
-    int  versionSz;                    /* encoded version length */
-    int  serialSz;                     /* encoded serial length */
-    int  sigAlgoSz;                    /* enocded sig alog length */
-    int  issuerSz;                     /* encoded issuer length */
-    int  subjectSz;                    /* encoded subject length */
-    int  validitySz;                   /* encoded validity length */
-    int  publicKeySz;                  /* encoded public key length */
-    int  caSz;                         /* encoded CA extension length */
-    int  extensionsSz;                 /* encoded extensions total length */
-    int  total;                        /* total encoded lengths */
-#ifdef WOLFSSL_CERT_REQ
-    int  attribSz;
-#endif
-} DerCert;
-
-
-#ifdef WOLFSSL_CERT_REQ
-
-/* Write a set header to output */
-static word32 SetUTF8String(word32 len, byte* output)
-{
-    output[0] = ASN_UTF8STRING;
-    return SetLength(len, output + 1) + 1;
-}
-
-#endif /* WOLFSSL_CERT_REQ */
-
-
-/* Write a serial number to output */
-static int SetSerial(const byte* serial, byte* output)
-{
-    int length = 0;
-
-    output[length++] = ASN_INTEGER;
-    length += SetLength(CTC_SERIAL_SIZE, &output[length]);
-    XMEMCPY(&output[length], serial, CTC_SERIAL_SIZE);
-
-    return length + CTC_SERIAL_SIZE;
-}
-
-
-#ifdef HAVE_ECC 
-
-
-/* Write a public ECC key to output */
-static int SetEccPublicKey(byte* output, ecc_key* key)
-{
-    byte len[MAX_LENGTH_SZ + 1];  /* trailing 0 */
-    int  algoSz;
-    int  curveSz;
-    int  lenSz;
-    int  idx;
-    word32 pubSz = ECC_BUFSIZE;
-#ifdef WOLFSSL_SMALL_STACK
-    byte* algo = NULL;
-    byte* curve = NULL;
-    byte* pub = NULL;
-#else
-    byte algo[MAX_ALGO_SZ];
-    byte curve[MAX_ALGO_SZ];
-    byte pub[ECC_BUFSIZE];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    pub = (byte*)XMALLOC(ECC_BUFSIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (pub == NULL)
-        return MEMORY_E;
-#endif
-
-    int ret = wc_ecc_export_x963(key, pub, &pubSz);
-    if (ret != 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ret;
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    curve = (byte*)XMALLOC(MAX_ALGO_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (curve == NULL) {
-        XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#endif
-
-    /* headers */
-    curveSz = SetCurve(key, curve);
-    if (curveSz <= 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(curve, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(pub,   NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return curveSz;
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    algo = (byte*)XMALLOC(MAX_ALGO_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (algo == NULL) {
-        XFREE(curve, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(pub,   NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#endif
-
-    algoSz  = SetAlgoID(ECDSAk, algo, keyType, curveSz);
-    lenSz   = SetLength(pubSz + 1, len);
-    len[lenSz++] = 0;   /* trailing 0 */
-
-    /* write */
-    idx = SetSequence(pubSz + curveSz + lenSz + 1 + algoSz, output);
-        /* 1 is for ASN_BIT_STRING */
-    /* algo */
-    XMEMCPY(output + idx, algo, algoSz);
-    idx += algoSz;
-    /* curve */
-    XMEMCPY(output + idx, curve, curveSz);
-    idx += curveSz;
-    /* bit string */
-    output[idx++] = ASN_BIT_STRING;
-    /* length */
-    XMEMCPY(output + idx, len, lenSz);
-    idx += lenSz;
-    /* pub */
-    XMEMCPY(output + idx, pub, pubSz);
-    idx += pubSz;
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(algo,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(curve, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(pub,   NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return idx;
-}
-
-
-#endif /* HAVE_ECC */
-
-
-/* Write a public RSA key to output */
-static int SetRsaPublicKey(byte* output, RsaKey* key)
-{
-#ifdef WOLFSSL_SMALL_STACK
-    byte* n = NULL;
-    byte* e = NULL;
-    byte* algo = NULL;
-#else
-    byte n[MAX_RSA_INT_SZ];
-    byte e[MAX_RSA_E_SZ];
-    byte algo[MAX_ALGO_SZ];
-#endif
-    byte seq[MAX_SEQ_SZ];
-    byte len[MAX_LENGTH_SZ + 1];  /* trailing 0 */
-    int  nSz;
-    int  eSz;
-    int  algoSz;
-    int  seqSz;
-    int  lenSz;
-    int  idx;
-    int  rawLen;
-    int  leadingBit;
-    int  err;
-
-    /* n */
-#ifdef WOLFSSL_SMALL_STACK
-    n = (byte*)XMALLOC(MAX_RSA_INT_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (n == NULL)
-        return MEMORY_E;
-#endif
-
-    leadingBit = mp_leading_bit(&key->n);
-    rawLen = mp_unsigned_bin_size(&key->n) + leadingBit;
-    n[0] = ASN_INTEGER;
-    nSz  = SetLength(rawLen, n + 1) + 1;  /* int tag */
-
-    if ( (nSz + rawLen) < MAX_RSA_INT_SZ) {
-        if (leadingBit)
-            n[nSz] = 0;
-        err = mp_to_unsigned_bin(&key->n, n + nSz + leadingBit);
-        if (err == MP_OKAY)
-            nSz += rawLen;
-        else {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(n, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return MP_TO_E;
-        }
-    }
-    else {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(n, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return BUFFER_E;
-    }
-
-    /* e */
-#ifdef WOLFSSL_SMALL_STACK
-    e = (byte*)XMALLOC(MAX_RSA_E_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (e == NULL) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(n, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return MEMORY_E;
-    }
-#endif
-
-    leadingBit = mp_leading_bit(&key->e);
-    rawLen = mp_unsigned_bin_size(&key->e) + leadingBit;
-    e[0] = ASN_INTEGER;
-    eSz  = SetLength(rawLen, e + 1) + 1;  /* int tag */
-
-    if ( (eSz + rawLen) < MAX_RSA_E_SZ) {
-        if (leadingBit)
-            e[eSz] = 0;
-        err = mp_to_unsigned_bin(&key->e, e + eSz + leadingBit);
-        if (err == MP_OKAY)
-            eSz += rawLen;
-        else {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(n, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(e, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return MP_TO_E;
-        }
-    }
-    else {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(n, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(e, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return BUFFER_E;
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    algo = (byte*)XMALLOC(MAX_ALGO_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (algo == NULL) {
-        XFREE(n, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(e, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#endif
-
-    /* headers */
-    algoSz = SetAlgoID(RSAk, algo, keyType, 0);
-    seqSz  = SetSequence(nSz + eSz, seq);
-    lenSz  = SetLength(seqSz + nSz + eSz + 1, len);
-    len[lenSz++] = 0;   /* trailing 0 */
-
-    /* write */
-    idx = SetSequence(nSz + eSz + seqSz + lenSz + 1 + algoSz, output);
-        /* 1 is for ASN_BIT_STRING */
-    /* algo */
-    XMEMCPY(output + idx, algo, algoSz);
-    idx += algoSz;
-    /* bit string */
-    output[idx++] = ASN_BIT_STRING;
-    /* length */
-    XMEMCPY(output + idx, len, lenSz);
-    idx += lenSz;
-    /* seq */
-    XMEMCPY(output + idx, seq, seqSz);
-    idx += seqSz;
-    /* n */
-    XMEMCPY(output + idx, n, nSz);
-    idx += nSz;
-    /* e */
-    XMEMCPY(output + idx, e, eSz);
-    idx += eSz;
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(n,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(e,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(algo, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return idx;
-}
-
-
-static INLINE byte itob(int number)
-{
-    return (byte)number + 0x30;
-}
-
-
-/* write time to output, format */
-static void SetTime(struct tm* date, byte* output)
-{
-    int i = 0;
-
-    output[i++] = itob((date->tm_year % 10000) / 1000);
-    output[i++] = itob((date->tm_year % 1000)  /  100);
-    output[i++] = itob((date->tm_year % 100)   /   10);
-    output[i++] = itob( date->tm_year % 10);
-
-    output[i++] = itob(date->tm_mon / 10);
-    output[i++] = itob(date->tm_mon % 10);
-
-    output[i++] = itob(date->tm_mday / 10);
-    output[i++] = itob(date->tm_mday % 10);
-
-    output[i++] = itob(date->tm_hour / 10);
-    output[i++] = itob(date->tm_hour % 10);
-
-    output[i++] = itob(date->tm_min / 10);
-    output[i++] = itob(date->tm_min % 10);
-
-    output[i++] = itob(date->tm_sec / 10);
-    output[i++] = itob(date->tm_sec % 10);
-    
-    output[i] = 'Z';  /* Zulu profile */
-}
-
-
-#ifdef WOLFSSL_ALT_NAMES
-
-/* Copy Dates from cert, return bytes written */
-static int CopyValidity(byte* output, Cert* cert)
-{
-    int seqSz;
-
-    WOLFSSL_ENTER("CopyValidity");
-
-    /* headers and output */
-    seqSz = SetSequence(cert->beforeDateSz + cert->afterDateSz, output);
-    XMEMCPY(output + seqSz, cert->beforeDate, cert->beforeDateSz);
-    XMEMCPY(output + seqSz + cert->beforeDateSz, cert->afterDate,
-                                                 cert->afterDateSz);
-    return seqSz + cert->beforeDateSz + cert->afterDateSz;
-}
-
-#endif
-
-
-/* for systems where mktime() doesn't normalize fully */
-static void RebuildTime(time_t* in, struct tm* out)
-{
-    #ifdef FREESCALE_MQX
-        out = localtime_r(in, out);
-    #else
-        (void)in;
-        (void)out;
-    #endif
-}
-
-
-/* Set Date validity from now until now + daysValid */
-static int SetValidity(byte* output, int daysValid)
-{
-    byte before[MAX_DATE_SIZE];
-    byte  after[MAX_DATE_SIZE];
-
-    int beforeSz;
-    int afterSz;
-    int seqSz;
-
-    time_t     ticks;
-    time_t     normalTime;
-    struct tm* now;
-    struct tm* tmpTime = NULL;
-    struct tm  local;
-
-#if defined(FREESCALE_MQX) || defined(TIME_OVERRIDES)
-    /* for use with gmtime_r */
-    struct tm tmpTimeStorage;
-    tmpTime = &tmpTimeStorage;
-#else
-    (void)tmpTime;
-#endif
-
-    ticks = XTIME(0);
-    now   = XGMTIME(&ticks, tmpTime);
-
-    /* before now */
-    local = *now;
-    before[0] = ASN_GENERALIZED_TIME;
-    beforeSz  = SetLength(ASN_GEN_TIME_SZ, before + 1) + 1;  /* gen tag */
-
-    /* subtract 1 day for more compliance */
-    local.tm_mday -= 1;
-    normalTime = mktime(&local);
-    RebuildTime(&normalTime, &local);
-
-    /* adjust */
-    local.tm_year += 1900;
-    local.tm_mon  +=    1;
-
-    SetTime(&local, before + beforeSz);
-    beforeSz += ASN_GEN_TIME_SZ;
-
-    /* after now + daysValid */
-    local = *now;
-    after[0] = ASN_GENERALIZED_TIME;
-    afterSz  = SetLength(ASN_GEN_TIME_SZ, after + 1) + 1;  /* gen tag */
-
-    /* add daysValid */
-    local.tm_mday += daysValid;
-    normalTime = mktime(&local);
-    RebuildTime(&normalTime, &local);
-
-    /* adjust */
-    local.tm_year += 1900;
-    local.tm_mon  +=    1;
-
-    SetTime(&local, after + afterSz);
-    afterSz += ASN_GEN_TIME_SZ;
-
-    /* headers and output */
-    seqSz = SetSequence(beforeSz + afterSz, output);
-    XMEMCPY(output + seqSz, before, beforeSz);
-    XMEMCPY(output + seqSz + beforeSz, after, afterSz);
-
-    return seqSz + beforeSz + afterSz;
-}
-
-
-/* ASN Encoded Name field */
-typedef struct EncodedName {
-    int  nameLen;                /* actual string value length */
-    int  totalLen;               /* total encoded length */
-    int  type;                   /* type of name */
-    int  used;                   /* are we actually using this one */
-    byte encoded[CTC_NAME_SIZE * 2]; /* encoding */
-} EncodedName;
-
-
-/* Get Which Name from index */
-static const char* GetOneName(CertName* name, int idx)
-{
-    switch (idx) {
-    case 0:
-       return name->country;
-
-    case 1:
-       return name->state;
-
-    case 2:
-       return name->locality;
-
-    case 3:
-       return name->sur;
-
-    case 4:
-       return name->org;
-
-    case 5:
-       return name->unit;
-
-    case 6:
-       return name->commonName;
-
-    case 7:
-       return name->email;
-
-    default:
-       return 0;
-    }
-}
-
-
-/* Get Which Name Encoding from index */
-static char GetNameType(CertName* name, int idx)
-{
-    switch (idx) {
-    case 0:
-       return name->countryEnc;
-
-    case 1:
-       return name->stateEnc;
-
-    case 2:
-       return name->localityEnc;
-
-    case 3:
-       return name->surEnc;
-
-    case 4:
-       return name->orgEnc;
-
-    case 5:
-       return name->unitEnc;
-
-    case 6:
-       return name->commonNameEnc;
-
-    default:
-       return 0;
-    }
-}
-
-
-/* Get ASN Name from index */
-static byte GetNameId(int idx)
-{
-    switch (idx) {
-    case 0:
-       return ASN_COUNTRY_NAME;
-
-    case 1:
-       return ASN_STATE_NAME;
-
-    case 2:
-       return ASN_LOCALITY_NAME;
-
-    case 3:
-       return ASN_SUR_NAME;
-
-    case 4:
-       return ASN_ORG_NAME;
-
-    case 5:
-       return ASN_ORGUNIT_NAME;
-
-    case 6:
-       return ASN_COMMON_NAME;
-
-    case 7:
-       /* email uses different id type */
-       return 0;
-
-    default:
-       return 0;
-    }
-}
-
-
-/* encode all extensions, return total bytes written */
-static int SetExtensions(byte* output, const byte* ext, int extSz, int header)
-{
-    byte sequence[MAX_SEQ_SZ];
-    byte len[MAX_LENGTH_SZ];
-
-    int sz = 0;
-    int seqSz = SetSequence(extSz, sequence);
-
-    if (header) {
-        int lenSz = SetLength(seqSz + extSz, len);
-        output[0] = ASN_EXTENSIONS; /* extensions id */
-        sz++;
-        XMEMCPY(&output[sz], len, lenSz);  /* length */
-        sz += lenSz;
-    }
-    XMEMCPY(&output[sz], sequence, seqSz);  /* sequence */
-    sz += seqSz;
-    XMEMCPY(&output[sz], ext, extSz);  /* extensions */
-    sz += extSz;
-
-    return sz;
-}
-
-
-/* encode CA basic constraint true, return total bytes written */
-static int SetCa(byte* output)
-{
-    static const byte ca[] = { 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04,
-                               0x05, 0x30, 0x03, 0x01, 0x01, 0xff };
-    
-    XMEMCPY(output, ca, sizeof(ca));
-
-    return (int)sizeof(ca);
-}
-
-
-/* encode CertName into output, return total bytes written */
-static int SetName(byte* output, CertName* name)
-{
-    int          totalBytes = 0, i, idx;
-#ifdef WOLFSSL_SMALL_STACK
-    EncodedName* names = NULL;
-#else
-    EncodedName  names[NAME_ENTRIES];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    names = (EncodedName*)XMALLOC(sizeof(EncodedName) * NAME_ENTRIES, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (names == NULL)
-        return MEMORY_E;
-#endif
-
-    for (i = 0; i < NAME_ENTRIES; i++) {
-        const char* nameStr = GetOneName(name, i);
-        if (nameStr) {
-            /* bottom up */
-            byte firstLen[MAX_LENGTH_SZ];
-            byte secondLen[MAX_LENGTH_SZ];
-            byte sequence[MAX_SEQ_SZ];
-            byte set[MAX_SET_SZ];
-
-            int email = i == (NAME_ENTRIES - 1) ? 1 : 0;
-            int strLen  = (int)XSTRLEN(nameStr);
-            int thisLen = strLen;
-            int firstSz, secondSz, seqSz, setSz;
-
-            if (strLen == 0) { /* no user data for this item */
-                names[i].used = 0;
-                continue;
-            }
-
-            secondSz = SetLength(strLen, secondLen);
-            thisLen += secondSz;
-            if (email) {
-                thisLen += EMAIL_JOINT_LEN;
-                thisLen ++;                               /* id type */
-                firstSz  = SetLength(EMAIL_JOINT_LEN, firstLen);
-            }
-            else {
-                thisLen++;                                 /* str type */
-                thisLen++;                                 /* id  type */
-                thisLen += JOINT_LEN;    
-                firstSz = SetLength(JOINT_LEN + 1, firstLen);
-            }
-            thisLen += firstSz;
-            thisLen++;                                /* object id */
-
-            seqSz = SetSequence(thisLen, sequence);
-            thisLen += seqSz;
-            setSz = SetSet(thisLen, set);
-            thisLen += setSz;
-
-            if (thisLen > (int)sizeof(names[i].encoded)) {
-#ifdef WOLFSSL_SMALL_STACK
-                XFREE(names, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-                return BUFFER_E;
-            }
-
-            /* store it */
-            idx = 0;
-            /* set */
-            XMEMCPY(names[i].encoded, set, setSz);
-            idx += setSz;
-            /* seq */
-            XMEMCPY(names[i].encoded + idx, sequence, seqSz);
-            idx += seqSz;
-            /* asn object id */
-            names[i].encoded[idx++] = ASN_OBJECT_ID;
-            /* first length */
-            XMEMCPY(names[i].encoded + idx, firstLen, firstSz);
-            idx += firstSz;
-            if (email) {
-                const byte EMAIL_OID[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
-                                           0x01, 0x09, 0x01, 0x16 };
-                /* email joint id */
-                XMEMCPY(names[i].encoded + idx, EMAIL_OID, sizeof(EMAIL_OID));
-                idx += (int)sizeof(EMAIL_OID);
-            }
-            else {
-                /* joint id */
-                byte bType = GetNameId(i);
-                names[i].encoded[idx++] = 0x55;
-                names[i].encoded[idx++] = 0x04;
-                /* id type */
-                names[i].encoded[idx++] = bType; 
-                /* str type */
-                names[i].encoded[idx++] = GetNameType(name, i);
-            }
-            /* second length */
-            XMEMCPY(names[i].encoded + idx, secondLen, secondSz);
-            idx += secondSz;
-            /* str value */
-            XMEMCPY(names[i].encoded + idx, nameStr, strLen);
-            idx += strLen;
-
-            totalBytes += idx;
-            names[i].totalLen = idx;
-            names[i].used = 1;
-        }
-        else
-            names[i].used = 0;
-    }
-
-    /* header */
-    idx = SetSequence(totalBytes, output);
-    totalBytes += idx;
-    if (totalBytes > ASN_NAME_MAX) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(names, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return BUFFER_E;
-    }
-
-    for (i = 0; i < NAME_ENTRIES; i++) {
-        if (names[i].used) {
-            XMEMCPY(output + idx, names[i].encoded, names[i].totalLen);
-            idx += names[i].totalLen;
-        }
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(names, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return totalBytes;
-}
-
-/* encode info from cert into DER encoded format */
-static int EncodeCert(Cert* cert, DerCert* der, RsaKey* rsaKey, ecc_key* eccKey,
-                      RNG* rng, const byte* ntruKey, word16 ntruSz)
-{
-    int ret;
-
-    (void)eccKey;
-    (void)ntruKey;
-    (void)ntruSz;
-
-    /* init */
-    XMEMSET(der, 0, sizeof(DerCert));
-
-    /* version */
-    der->versionSz = SetMyVersion(cert->version, der->version, TRUE);
-
-    /* serial number */
-    ret = wc_RNG_GenerateBlock(rng, cert->serial, CTC_SERIAL_SIZE);
-    if (ret != 0)
-        return ret;
-
-    cert->serial[0] = 0x01;   /* ensure positive */
-    der->serialSz  = SetSerial(cert->serial, der->serial);
-
-    /* signature algo */
-    der->sigAlgoSz = SetAlgoID(cert->sigType, der->sigAlgo, sigType, 0);
-    if (der->sigAlgoSz == 0)
-        return ALGO_ID_E;
-
-    /* public key */
-    if (cert->keyType == RSA_KEY) {
-        if (rsaKey == NULL)
-            return PUBLIC_KEY_E;
-        der->publicKeySz = SetRsaPublicKey(der->publicKey, rsaKey);
-        if (der->publicKeySz <= 0)
-            return PUBLIC_KEY_E;
-    }
-
-#ifdef HAVE_ECC
-    if (cert->keyType == ECC_KEY) {
-        if (eccKey == NULL)
-            return PUBLIC_KEY_E;
-        der->publicKeySz = SetEccPublicKey(der->publicKey, eccKey);
-        if (der->publicKeySz <= 0)
-            return PUBLIC_KEY_E;
-    }
-#endif /* HAVE_ECC */
-
-#ifdef HAVE_NTRU
-    if (cert->keyType == NTRU_KEY) {
-        word32 rc;
-        word16 encodedSz;
-
-        rc  = ntru_crypto_ntru_encrypt_publicKey2SubjectPublicKeyInfo( ntruSz,
-                                                   ntruKey, &encodedSz, NULL);
-        if (rc != NTRU_OK)
-            return PUBLIC_KEY_E;
-        if (encodedSz > MAX_PUBLIC_KEY_SZ)
-            return PUBLIC_KEY_E;
-
-        rc  = ntru_crypto_ntru_encrypt_publicKey2SubjectPublicKeyInfo( ntruSz,
-                                         ntruKey, &encodedSz, der->publicKey);
-        if (rc != NTRU_OK)
-            return PUBLIC_KEY_E;
-
-        der->publicKeySz = encodedSz;
-    }
-#endif /* HAVE_NTRU */
-
-    der->validitySz = 0;
-#ifdef WOLFSSL_ALT_NAMES
-    /* date validity copy ? */
-    if (cert->beforeDateSz && cert->afterDateSz) {
-        der->validitySz = CopyValidity(der->validity, cert);
-        if (der->validitySz == 0)
-            return DATE_E;
-    }
-#endif
-
-    /* date validity */
-    if (der->validitySz == 0) {
-        der->validitySz = SetValidity(der->validity, cert->daysValid);
-        if (der->validitySz == 0)
-            return DATE_E;
-    }
-
-    /* subject name */
-    der->subjectSz = SetName(der->subject, &cert->subject);
-    if (der->subjectSz == 0)
-        return SUBJECT_E;
-
-    /* issuer name */
-    der->issuerSz = SetName(der->issuer, cert->selfSigned ?
-             &cert->subject : &cert->issuer);
-    if (der->issuerSz == 0)
-        return ISSUER_E;
-
-    /* CA */
-    if (cert->isCA) {
-        der->caSz = SetCa(der->ca);
-        if (der->caSz == 0)
-            return CA_TRUE_E;
-    }
-    else
-        der->caSz = 0;
-
-    /* extensions, just CA now */
-    if (cert->isCA) {
-        der->extensionsSz = SetExtensions(der->extensions,
-                                          der->ca, der->caSz, TRUE);
-        if (der->extensionsSz == 0)
-            return EXTENSIONS_E;
-    }
-    else
-        der->extensionsSz = 0;
-
-#ifdef WOLFSSL_ALT_NAMES
-    if (der->extensionsSz == 0 && cert->altNamesSz) {
-        der->extensionsSz = SetExtensions(der->extensions, cert->altNames,
-                                          cert->altNamesSz, TRUE);
-        if (der->extensionsSz == 0)
-            return EXTENSIONS_E;
-    }
-#endif
-
-    der->total = der->versionSz + der->serialSz + der->sigAlgoSz +
-        der->publicKeySz + der->validitySz + der->subjectSz + der->issuerSz +
-        der->extensionsSz;
-
-    return 0;
-}
-
-
-/* write DER encoded cert to buffer, size already checked */
-static int WriteCertBody(DerCert* der, byte* buffer)
-{
-    int idx;
-
-    /* signed part header */
-    idx = SetSequence(der->total, buffer);
-    /* version */
-    XMEMCPY(buffer + idx, der->version, der->versionSz);
-    idx += der->versionSz;
-    /* serial */
-    XMEMCPY(buffer + idx, der->serial, der->serialSz);
-    idx += der->serialSz;
-    /* sig algo */
-    XMEMCPY(buffer + idx, der->sigAlgo, der->sigAlgoSz);
-    idx += der->sigAlgoSz;
-    /* issuer */
-    XMEMCPY(buffer + idx, der->issuer, der->issuerSz);
-    idx += der->issuerSz;
-    /* validity */
-    XMEMCPY(buffer + idx, der->validity, der->validitySz);
-    idx += der->validitySz;
-    /* subject */
-    XMEMCPY(buffer + idx, der->subject, der->subjectSz);
-    idx += der->subjectSz;
-    /* public key */
-    XMEMCPY(buffer + idx, der->publicKey, der->publicKeySz);
-    idx += der->publicKeySz;
-    if (der->extensionsSz) {
-        /* extensions */
-        XMEMCPY(buffer + idx, der->extensions, min(der->extensionsSz,
-                                                   sizeof(der->extensions)));
-        idx += der->extensionsSz;
-    }
-
-    return idx;
-}
-
-
-/* Make RSA signature from buffer (sz), write to sig (sigSz) */
-static int MakeSignature(const byte* buffer, int sz, byte* sig, int sigSz,
-                         RsaKey* rsaKey, ecc_key* eccKey, RNG* rng,
-                         int sigAlgoType)
-{
-    int encSigSz, digestSz, typeH = 0, ret = 0;
-    byte digest[SHA256_DIGEST_SIZE]; /* max size */
-#ifdef WOLFSSL_SMALL_STACK
-    byte* encSig;
-#else
-    byte encSig[MAX_ENCODED_DIG_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ];
-#endif
-
-    (void)digest;
-    (void)digestSz;
-    (void)encSig;
-    (void)encSigSz;
-    (void)typeH;
-
-    (void)buffer;
-    (void)sz;
-    (void)sig;
-    (void)sigSz;
-    (void)rsaKey;
-    (void)eccKey;
-    (void)rng;
-
-    switch (sigAlgoType) {
-    #ifndef NO_MD5
-        case CTC_MD5wRSA:
-        if ((ret = wc_Md5Hash(buffer, sz, digest)) == 0) {
-            typeH    = MD5h;
-            digestSz = MD5_DIGEST_SIZE;
-        }
-        break;
-    #endif
-    #ifndef NO_SHA
-        case CTC_SHAwRSA:
-        case CTC_SHAwECDSA:
-        if ((ret = wc_ShaHash(buffer, sz, digest)) == 0) {
-            typeH    = SHAh;
-            digestSz = SHA_DIGEST_SIZE;          
-        }
-        break;
-    #endif
-    #ifndef NO_SHA256
-        case CTC_SHA256wRSA:
-        case CTC_SHA256wECDSA:
-        if ((ret = wc_Sha256Hash(buffer, sz, digest)) == 0) {
-            typeH    = SHA256h;
-            digestSz = SHA256_DIGEST_SIZE;
-        }
-        break;
-    #endif
-        default:
-            WOLFSSL_MSG("MakeSignautre called with unsupported type");
-            ret = ALGO_ID_E;
-    }
-    
-    if (ret != 0)
-        return ret;
-    
-#ifdef WOLFSSL_SMALL_STACK
-    encSig = (byte*)XMALLOC(MAX_ENCODED_DIG_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ,
-                                                 NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (encSig == NULL)
-        return MEMORY_E;
-#endif
-    
-    ret = ALGO_ID_E;
-    
-#ifndef NO_RSA
-    if (rsaKey) {
-        /* signature */
-        encSigSz = wc_EncodeSignature(encSig, digest, digestSz, typeH);
-        ret = wc_RsaSSL_Sign(encSig, encSigSz, sig, sigSz, rsaKey, rng);
-    }
-#endif
-    
-#ifdef HAVE_ECC
-    if (!rsaKey && eccKey) {
-        word32 outSz = sigSz;
-        ret = wc_ecc_sign_hash(digest, digestSz, sig, &outSz, rng, eccKey);
-
-        if (ret == 0)
-            ret = outSz;
-    }
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(encSig, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-/* add signature to end of buffer, size of buffer assumed checked, return
-   new length */
-static int AddSignature(byte* buffer, int bodySz, const byte* sig, int sigSz,
-                        int sigAlgoType)
-{
-    byte seq[MAX_SEQ_SZ];
-    int  idx = bodySz, seqSz;
-
-    /* algo */
-    idx += SetAlgoID(sigAlgoType, buffer + idx, sigType, 0);
-    /* bit string */
-    buffer[idx++] = ASN_BIT_STRING;
-    /* length */
-    idx += SetLength(sigSz + 1, buffer + idx);
-    buffer[idx++] = 0;   /* trailing 0 */
-    /* signature */
-    XMEMCPY(buffer + idx, sig, sigSz);
-    idx += sigSz;
-
-    /* make room for overall header */
-    seqSz = SetSequence(idx, seq);
-    XMEMMOVE(buffer + seqSz, buffer, idx);
-    XMEMCPY(buffer, seq, seqSz);
-
-    return idx + seqSz;
-}
-
-
-/* Make an x509 Certificate v3 any key type from cert input, write to buffer */
-static int MakeAnyCert(Cert* cert, byte* derBuffer, word32 derSz,
-                       RsaKey* rsaKey, ecc_key* eccKey, RNG* rng,
-                       const byte* ntruKey, word16 ntruSz)
-{
-    int ret;
-#ifdef WOLFSSL_SMALL_STACK
-    DerCert* der;
-#else
-    DerCert der[1];
-#endif
-
-    cert->keyType = eccKey ? ECC_KEY : (rsaKey ? RSA_KEY : NTRU_KEY);
-
-#ifdef WOLFSSL_SMALL_STACK
-    der = (DerCert*)XMALLOC(sizeof(DerCert), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (der == NULL)
-        return MEMORY_E;
-#endif
-
-    ret = EncodeCert(cert, der, rsaKey, eccKey, rng, ntruKey, ntruSz);
-
-    if (ret == 0) {
-        if (der->total + MAX_SEQ_SZ * 2 > (int)derSz)
-            ret = BUFFER_E;
-        else
-            ret = cert->bodySz = WriteCertBody(der, derBuffer);
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(der, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-/* Make an x509 Certificate v3 RSA or ECC from cert input, write to buffer */
-int wc_MakeCert(Cert* cert, byte* derBuffer, word32 derSz, RsaKey* rsaKey,
-             ecc_key* eccKey, RNG* rng)
-{
-    return MakeAnyCert(cert, derBuffer, derSz, rsaKey, eccKey, rng, NULL, 0);
-}
-
-
-#ifdef HAVE_NTRU
-
-int wc_MakeNtruCert(Cert* cert, byte* derBuffer, word32 derSz,
-                  const byte* ntruKey, word16 keySz, RNG* rng)
-{
-    return MakeAnyCert(cert, derBuffer, derSz, NULL, NULL, rng, ntruKey, keySz);
-}
-
-#endif /* HAVE_NTRU */
-
-
-#ifdef WOLFSSL_CERT_REQ
-
-static int SetReqAttrib(byte* output, char* pw, int extSz)
-{
-    static const byte cpOid[] =
-        { ASN_OBJECT_ID, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
-                         0x09, 0x07 };
-    static const byte erOid[] =
-        { ASN_OBJECT_ID, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
-                         0x09, 0x0e };
-
-    int sz      = 0; /* overall size */
-    int cpSz    = 0; /* Challenge Password section size */
-    int cpSeqSz = 0;
-    int cpSetSz = 0;
-    int cpStrSz = 0;
-    int pwSz    = 0;
-    int erSz    = 0; /* Extension Request section size */
-    int erSeqSz = 0;
-    int erSetSz = 0;
-    byte cpSeq[MAX_SEQ_SZ];
-    byte cpSet[MAX_SET_SZ];
-    byte cpStr[MAX_PRSTR_SZ];
-    byte erSeq[MAX_SEQ_SZ];
-    byte erSet[MAX_SET_SZ];
-
-    output[0] = 0xa0;
-    sz++;
-
-    if (pw && pw[0]) {
-        pwSz = (int)XSTRLEN(pw);
-        cpStrSz = SetUTF8String(pwSz, cpStr);
-        cpSetSz = SetSet(cpStrSz + pwSz, cpSet);
-        cpSeqSz = SetSequence(sizeof(cpOid) + cpSetSz + cpStrSz + pwSz, cpSeq);
-        cpSz = cpSeqSz + sizeof(cpOid) + cpSetSz + cpStrSz + pwSz;
-    }
-
-    if (extSz) {
-        erSetSz = SetSet(extSz, erSet);
-        erSeqSz = SetSequence(erSetSz + sizeof(erOid) + extSz, erSeq);
-        erSz = extSz + erSetSz + erSeqSz + sizeof(erOid);
-    }
-
-    /* Put the pieces together. */
-    sz += SetLength(cpSz + erSz, &output[sz]);
-
-    if (cpSz) {
-        XMEMCPY(&output[sz], cpSeq, cpSeqSz);
-        sz += cpSeqSz;
-        XMEMCPY(&output[sz], cpOid, sizeof(cpOid));
-        sz += sizeof(cpOid);
-        XMEMCPY(&output[sz], cpSet, cpSetSz);
-        sz += cpSetSz;
-        XMEMCPY(&output[sz], cpStr, cpStrSz);
-        sz += cpStrSz;
-        XMEMCPY(&output[sz], pw, pwSz);
-        sz += pwSz;
-    }
-
-    if (erSz) {
-        XMEMCPY(&output[sz], erSeq, erSeqSz);
-        sz += erSeqSz;
-        XMEMCPY(&output[sz], erOid, sizeof(erOid));
-        sz += sizeof(erOid);
-        XMEMCPY(&output[sz], erSet, erSetSz);
-        sz += erSetSz;
-        /* The actual extension data will be tacked onto the output later. */
-    }
-
-    return sz;
-}
-
-
-/* encode info from cert into DER encoded format */
-static int EncodeCertReq(Cert* cert, DerCert* der,
-                         RsaKey* rsaKey, ecc_key* eccKey)
-{
-    (void)eccKey;
-
-    /* init */
-    XMEMSET(der, 0, sizeof(DerCert));
-
-    /* version */
-    der->versionSz = SetMyVersion(cert->version, der->version, FALSE);
-
-    /* subject name */
-    der->subjectSz = SetName(der->subject, &cert->subject);
-    if (der->subjectSz == 0)
-        return SUBJECT_E;
-
-    /* public key */
-    if (cert->keyType == RSA_KEY) {
-        if (rsaKey == NULL)
-            return PUBLIC_KEY_E;
-        der->publicKeySz = SetRsaPublicKey(der->publicKey, rsaKey);
-        if (der->publicKeySz <= 0)
-            return PUBLIC_KEY_E;
-    }
-
-#ifdef HAVE_ECC
-    if (cert->keyType == ECC_KEY) {
-        if (eccKey == NULL)
-            return PUBLIC_KEY_E;
-        der->publicKeySz = SetEccPublicKey(der->publicKey, eccKey);
-        if (der->publicKeySz <= 0)
-            return PUBLIC_KEY_E;
-    }
-#endif /* HAVE_ECC */
-
-    /* CA */
-    if (cert->isCA) {
-        der->caSz = SetCa(der->ca);
-        if (der->caSz == 0)
-            return CA_TRUE_E;
-    }
-    else
-        der->caSz = 0;
-
-    /* extensions, just CA now */
-    if (cert->isCA) {
-        der->extensionsSz = SetExtensions(der->extensions,
-                                          der->ca, der->caSz, FALSE);
-        if (der->extensionsSz == 0)
-            return EXTENSIONS_E;
-    }
-    else
-        der->extensionsSz = 0;
-
-    der->attribSz = SetReqAttrib(der->attrib,
-                                 cert->challengePw, der->extensionsSz);
-    if (der->attribSz == 0)
-        return REQ_ATTRIBUTE_E;
-
-    der->total = der->versionSz + der->subjectSz + der->publicKeySz +
-        der->extensionsSz + der->attribSz;
-
-    return 0;
-}
-
-
-/* write DER encoded cert req to buffer, size already checked */
-static int WriteCertReqBody(DerCert* der, byte* buffer)
-{
-    int idx;
-
-    /* signed part header */
-    idx = SetSequence(der->total, buffer);
-    /* version */
-    XMEMCPY(buffer + idx, der->version, der->versionSz);
-    idx += der->versionSz;
-    /* subject */
-    XMEMCPY(buffer + idx, der->subject, der->subjectSz);
-    idx += der->subjectSz;
-    /* public key */
-    XMEMCPY(buffer + idx, der->publicKey, der->publicKeySz);
-    idx += der->publicKeySz;
-    /* attributes */
-    XMEMCPY(buffer + idx, der->attrib, der->attribSz);
-    idx += der->attribSz;
-    /* extensions */
-    if (der->extensionsSz) {
-        XMEMCPY(buffer + idx, der->extensions, min(der->extensionsSz,
-                                                   sizeof(der->extensions)));
-        idx += der->extensionsSz;
-    }
-
-    return idx;
-}
-
-
-int wc_MakeCertReq(Cert* cert, byte* derBuffer, word32 derSz,
-                RsaKey* rsaKey, ecc_key* eccKey)
-{
-    int ret;
-#ifdef WOLFSSL_SMALL_STACK
-    DerCert* der;
-#else
-    DerCert der[1];
-#endif
-
-    cert->keyType = eccKey ? ECC_KEY : RSA_KEY;
-
-#ifdef WOLFSSL_SMALL_STACK
-    der = (DerCert*)XMALLOC(sizeof(DerCert), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (der == NULL)
-        return MEMORY_E;
-#endif
-
-    ret = EncodeCertReq(cert, der, rsaKey, eccKey);
-
-    if (ret == 0) {
-        if (der->total + MAX_SEQ_SZ * 2 > (int)derSz)
-            ret = BUFFER_E;
-        else
-            ret = cert->bodySz = WriteCertReqBody(der, derBuffer);
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(der, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-#endif /* WOLFSSL_CERT_REQ */
-
-
-int wc_SignCert(int requestSz, int sType, byte* buffer, word32 buffSz,
-             RsaKey* rsaKey, ecc_key* eccKey, RNG* rng)
-{
-    int sigSz;
-#ifdef WOLFSSL_SMALL_STACK
-    byte* sig;
-#else
-    byte sig[MAX_ENCODED_SIG_SZ];
-#endif
-
-    if (requestSz < 0)
-        return requestSz;
-
-#ifdef WOLFSSL_SMALL_STACK
-    sig = (byte*)XMALLOC(MAX_ENCODED_SIG_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (sig == NULL)
-        return MEMORY_E;
-#endif
-
-    sigSz = MakeSignature(buffer, requestSz, sig, MAX_ENCODED_SIG_SZ, rsaKey,
-                          eccKey, rng, sType);
-
-    if (sigSz >= 0) {
-        if (requestSz + MAX_SEQ_SZ * 2 + sigSz > (int)buffSz)
-            sigSz = BUFFER_E;
-        else
-            sigSz = AddSignature(buffer, requestSz, sig, sigSz, sType);
-    }
-    
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(sig, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return sigSz;
-}
-
-
-int wc_MakeSelfCert(Cert* cert, byte* buffer, word32 buffSz, RsaKey* key, RNG* rng)
-{
-    int ret = wc_MakeCert(cert, buffer, buffSz, key, NULL, rng);
-
-    if (ret < 0)
-        return ret;
-
-    return wc_SignCert(cert->bodySz, cert->sigType, buffer, buffSz, key, NULL,rng);
-}
-
-
-#ifdef WOLFSSL_ALT_NAMES 
-
-/* Set Alt Names from der cert, return 0 on success */
-static int SetAltNamesFromCert(Cert* cert, const byte* der, int derSz)
-{
-    int ret;
-#ifdef WOLFSSL_SMALL_STACK
-    DecodedCert* decoded;
-#else
-    DecodedCert decoded[1];
-#endif
-
-    if (derSz < 0)
-        return derSz;
-
-#ifdef WOLFSSL_SMALL_STACK
-    decoded = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (decoded == NULL)
-        return MEMORY_E;
-#endif
-    
-    InitDecodedCert(decoded, (byte*)der, derSz, 0);
-    ret = ParseCertRelative(decoded, CA_TYPE, NO_VERIFY, 0);
-
-    if (ret < 0) {
-        WOLFSSL_MSG("ParseCertRelative error");
-    }
-    else if (decoded->extensions) {
-        byte   b;
-        int    length;
-        word32 maxExtensionsIdx;
-
-        decoded->srcIdx = decoded->extensionsIdx;
-        b = decoded->source[decoded->srcIdx++];
-        
-        if (b != ASN_EXTENSIONS) {
-            ret = ASN_PARSE_E;
-        }
-        else if (GetLength(decoded->source, &decoded->srcIdx, &length,
-                                                         decoded->maxIdx) < 0) {
-            ret = ASN_PARSE_E;
-        }
-        else if (GetSequence(decoded->source, &decoded->srcIdx, &length,
-                                                         decoded->maxIdx) < 0) {
-            ret = ASN_PARSE_E;
-        }
-        else {
-            maxExtensionsIdx = decoded->srcIdx + length;
-
-            while (decoded->srcIdx < maxExtensionsIdx) {
-                word32 oid;
-                word32 startIdx = decoded->srcIdx;
-                word32 tmpIdx;
-
-                if (GetSequence(decoded->source, &decoded->srcIdx, &length,
-                            decoded->maxIdx) < 0) {
-                    ret = ASN_PARSE_E;
-                    break;
-                }
-
-                tmpIdx = decoded->srcIdx;
-                decoded->srcIdx = startIdx;
-
-                if (GetAlgoId(decoded->source, &decoded->srcIdx, &oid,
-                              decoded->maxIdx) < 0) {
-                    ret = ASN_PARSE_E;
-                    break;
-                }
-
-                if (oid == ALT_NAMES_OID) {
-                    cert->altNamesSz = length + (tmpIdx - startIdx);
-
-                    if (cert->altNamesSz < (int)sizeof(cert->altNames))
-                        XMEMCPY(cert->altNames, &decoded->source[startIdx],
-                                cert->altNamesSz);
-                    else {
-                        cert->altNamesSz = 0;
-                        WOLFSSL_MSG("AltNames extensions too big");
-                        ret = ALT_NAME_E;
-                        break;
-                    }
-                }
-                decoded->srcIdx = tmpIdx + length;
-            }
-        }
-    }
-
-    FreeDecodedCert(decoded);
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(decoded, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret < 0 ? ret : 0;
-}
-
-
-/* Set Dates from der cert, return 0 on success */
-static int SetDatesFromCert(Cert* cert, const byte* der, int derSz)
-{
-    int ret;
-#ifdef WOLFSSL_SMALL_STACK
-    DecodedCert* decoded;
-#else
-    DecodedCert decoded[1];
-#endif
-
-    WOLFSSL_ENTER("SetDatesFromCert");
-    if (derSz < 0)
-        return derSz;
-    
-#ifdef WOLFSSL_SMALL_STACK
-    decoded = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (decoded == NULL)
-        return MEMORY_E;
-#endif
-
-    InitDecodedCert(decoded, (byte*)der, derSz, 0);
-    ret = ParseCertRelative(decoded, CA_TYPE, NO_VERIFY, 0);
-
-    if (ret < 0) {
-        WOLFSSL_MSG("ParseCertRelative error");
-    }
-    else if (decoded->beforeDate == NULL || decoded->afterDate == NULL) {
-        WOLFSSL_MSG("Couldn't extract dates");
-        ret = -1;
-    }
-    else if (decoded->beforeDateLen > MAX_DATE_SIZE || 
-                                        decoded->afterDateLen > MAX_DATE_SIZE) {
-        WOLFSSL_MSG("Bad date size");
-        ret = -1;
-    }
-    else {
-        XMEMCPY(cert->beforeDate, decoded->beforeDate, decoded->beforeDateLen);
-        XMEMCPY(cert->afterDate,  decoded->afterDate,  decoded->afterDateLen);
-
-        cert->beforeDateSz = decoded->beforeDateLen;
-        cert->afterDateSz  = decoded->afterDateLen;
-    }
-
-    FreeDecodedCert(decoded);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(decoded, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret < 0 ? ret : 0;
-}
-
-
-#endif /* WOLFSSL_ALT_NAMES && !NO_RSA */
-
-
-/* Set cn name from der buffer, return 0 on success */
-static int SetNameFromCert(CertName* cn, const byte* der, int derSz)
-{
-    int ret, sz;
-#ifdef WOLFSSL_SMALL_STACK
-    DecodedCert* decoded;
-#else
-    DecodedCert decoded[1];
-#endif
-
-    if (derSz < 0)
-        return derSz;
-
-#ifdef WOLFSSL_SMALL_STACK
-    decoded = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (decoded == NULL)
-        return MEMORY_E;
-#endif
-
-    InitDecodedCert(decoded, (byte*)der, derSz, 0);
-    ret = ParseCertRelative(decoded, CA_TYPE, NO_VERIFY, 0);
-
-    if (ret < 0) {
-        WOLFSSL_MSG("ParseCertRelative error");
-    }
-    else {
-        if (decoded->subjectCN) {
-            sz = (decoded->subjectCNLen < CTC_NAME_SIZE) ? decoded->subjectCNLen
-                                                         : CTC_NAME_SIZE - 1;
-            strncpy(cn->commonName, decoded->subjectCN, CTC_NAME_SIZE);
-            cn->commonName[sz] = 0;
-            cn->commonNameEnc = decoded->subjectCNEnc;
-        }
-        if (decoded->subjectC) {
-            sz = (decoded->subjectCLen < CTC_NAME_SIZE) ? decoded->subjectCLen
-                                                        : CTC_NAME_SIZE - 1;
-            strncpy(cn->country, decoded->subjectC, CTC_NAME_SIZE);
-            cn->country[sz] = 0;
-            cn->countryEnc = decoded->subjectCEnc;
-        }
-        if (decoded->subjectST) {
-            sz = (decoded->subjectSTLen < CTC_NAME_SIZE) ? decoded->subjectSTLen
-                                                         : CTC_NAME_SIZE - 1;
-            strncpy(cn->state, decoded->subjectST, CTC_NAME_SIZE);
-            cn->state[sz] = 0;
-            cn->stateEnc = decoded->subjectSTEnc;
-        }
-        if (decoded->subjectL) {
-            sz = (decoded->subjectLLen < CTC_NAME_SIZE) ? decoded->subjectLLen
-                                                        : CTC_NAME_SIZE - 1;
-            strncpy(cn->locality, decoded->subjectL, CTC_NAME_SIZE);
-            cn->locality[sz] = 0;
-            cn->localityEnc = decoded->subjectLEnc;
-        }
-        if (decoded->subjectO) {
-            sz = (decoded->subjectOLen < CTC_NAME_SIZE) ? decoded->subjectOLen
-                                                        : CTC_NAME_SIZE - 1;
-            strncpy(cn->org, decoded->subjectO, CTC_NAME_SIZE);
-            cn->org[sz] = 0;
-            cn->orgEnc = decoded->subjectOEnc;
-        }
-        if (decoded->subjectOU) {
-            sz = (decoded->subjectOULen < CTC_NAME_SIZE) ? decoded->subjectOULen
-                                                         : CTC_NAME_SIZE - 1;
-            strncpy(cn->unit, decoded->subjectOU, CTC_NAME_SIZE);
-            cn->unit[sz] = 0;
-            cn->unitEnc = decoded->subjectOUEnc;
-        }
-        if (decoded->subjectSN) {
-            sz = (decoded->subjectSNLen < CTC_NAME_SIZE) ? decoded->subjectSNLen
-                                                         : CTC_NAME_SIZE - 1;
-            strncpy(cn->sur, decoded->subjectSN, CTC_NAME_SIZE);
-            cn->sur[sz] = 0;
-            cn->surEnc = decoded->subjectSNEnc;
-        }
-        if (decoded->subjectEmail) {
-            sz = (decoded->subjectEmailLen < CTC_NAME_SIZE)
-               ?  decoded->subjectEmailLen : CTC_NAME_SIZE - 1;
-            strncpy(cn->email, decoded->subjectEmail, CTC_NAME_SIZE);
-            cn->email[sz] = 0;
-        }
-    }
-
-    FreeDecodedCert(decoded);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(decoded, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret < 0 ? ret : 0;
-}
-
-
-#ifndef NO_FILESYSTEM
-
-/* Set cert issuer from issuerFile in PEM */
-int wc_SetIssuer(Cert* cert, const char* issuerFile)
-{
-    int         ret;
-    int         derSz;
-    byte*       der = (byte*)XMALLOC(EIGHTK_BUF, NULL, DYNAMIC_TYPE_CERT);
-
-    if (der == NULL) {
-        WOLFSSL_MSG("wc_SetIssuer OOF Problem");
-        return MEMORY_E;
-    }
-    derSz = wolfSSL_PemCertToDer(issuerFile, der, EIGHTK_BUF);
-    cert->selfSigned = 0;
-    ret = SetNameFromCert(&cert->issuer, der, derSz);
-    XFREE(der, NULL, DYNAMIC_TYPE_CERT);
-
-    return ret;
-}
-
-
-/* Set cert subject from subjectFile in PEM */
-int wc_SetSubject(Cert* cert, const char* subjectFile)
-{
-    int         ret;
-    int         derSz;
-    byte*       der = (byte*)XMALLOC(EIGHTK_BUF, NULL, DYNAMIC_TYPE_CERT);
-
-    if (der == NULL) {
-        WOLFSSL_MSG("wc_SetSubject OOF Problem");
-        return MEMORY_E;
-    }
-    derSz = wolfSSL_PemCertToDer(subjectFile, der, EIGHTK_BUF);
-    ret = SetNameFromCert(&cert->subject, der, derSz);
-    XFREE(der, NULL, DYNAMIC_TYPE_CERT);
-
-    return ret;
-}
-
-
-#ifdef WOLFSSL_ALT_NAMES
-
-/* Set atl names from file in PEM */
-int wc_SetAltNames(Cert* cert, const char* file)
-{
-    int         ret;
-    int         derSz;
-    byte*       der = (byte*)XMALLOC(EIGHTK_BUF, NULL, DYNAMIC_TYPE_CERT);
-
-    if (der == NULL) {
-        WOLFSSL_MSG("wc_SetAltNames OOF Problem");
-        return MEMORY_E;
-    }
-    derSz = wolfSSL_PemCertToDer(file, der, EIGHTK_BUF);
-    ret = SetAltNamesFromCert(cert, der, derSz);
-    XFREE(der, NULL, DYNAMIC_TYPE_CERT);
-
-    return ret;
-}
-
-#endif /* WOLFSSL_ALT_NAMES */
-
-#endif /* NO_FILESYSTEM */
-
-/* Set cert issuer from DER buffer */
-int wc_SetIssuerBuffer(Cert* cert, const byte* der, int derSz)
-{
-    cert->selfSigned = 0;
-    return SetNameFromCert(&cert->issuer, der, derSz);
-}
-
-
-/* Set cert subject from DER buffer */
-int wc_SetSubjectBuffer(Cert* cert, const byte* der, int derSz)
-{
-    return SetNameFromCert(&cert->subject, der, derSz);
-}
-
-
-#ifdef WOLFSSL_ALT_NAMES
-
-/* Set cert alt names from DER buffer */
-int wc_SetAltNamesBuffer(Cert* cert, const byte* der, int derSz)
-{
-    return SetAltNamesFromCert(cert, der, derSz);
-}
-
-/* Set cert dates from DER buffer */
-int wc_SetDatesBuffer(Cert* cert, const byte* der, int derSz)
-{
-    return SetDatesFromCert(cert, der, derSz);
-}
-
-#endif /* WOLFSSL_ALT_NAMES */
-
-#endif /* WOLFSSL_CERT_GEN */
-
-
-#ifdef HAVE_ECC
-
-/* Der Encode r & s ints into out, outLen is (in/out) size */
-int StoreECC_DSA_Sig(byte* out, word32* outLen, mp_int* r, mp_int* s)
-{
-    word32 idx = 0;
-    word32 rSz;                           /* encoding size */
-    word32 sSz;
-    word32 headerSz = 4;   /* 2*ASN_TAG + 2*LEN(ENUM) */
-
-    /* If the leading bit on the INTEGER is a 1, add a leading zero */
-    int rLeadingZero = mp_leading_bit(r);
-    int sLeadingZero = mp_leading_bit(s);
-    int rLen = mp_unsigned_bin_size(r);   /* big int size */
-    int sLen = mp_unsigned_bin_size(s);
-    int err;
-
-    if (*outLen < (rLen + rLeadingZero + sLen + sLeadingZero +
-                   headerSz + 2))  /* SEQ_TAG + LEN(ENUM) */
-        return BAD_FUNC_ARG;
-
-    idx = SetSequence(rLen+rLeadingZero+sLen+sLeadingZero+headerSz, out);
-
-    /* store r */
-    out[idx++] = ASN_INTEGER;
-    rSz = SetLength(rLen + rLeadingZero, &out[idx]);
-    idx += rSz;
-    if (rLeadingZero)
-        out[idx++] = 0;
-    err = mp_to_unsigned_bin(r, &out[idx]);
-    if (err != MP_OKAY) return err;
-    idx += rLen;
-
-    /* store s */
-    out[idx++] = ASN_INTEGER;
-    sSz = SetLength(sLen + sLeadingZero, &out[idx]);
-    idx += sSz;
-    if (sLeadingZero)
-        out[idx++] = 0;
-    err = mp_to_unsigned_bin(s, &out[idx]);
-    if (err != MP_OKAY) return err;
-    idx += sLen;
-
-    *outLen = idx;
-
-    return 0;
-}
-
-
-/* Der Decode ECC-DSA Signautre, r & s stored as big ints */
-int DecodeECC_DSA_Sig(const byte* sig, word32 sigLen, mp_int* r, mp_int* s)
-{
-    word32 idx = 0;
-    int    len = 0;
-
-    if (GetSequence(sig, &idx, &len, sigLen) < 0)
-        return ASN_ECC_KEY_E;
-
-    if ((word32)len > (sigLen - idx))
-        return ASN_ECC_KEY_E;
-
-    if (GetInt(r, sig, &idx, sigLen) < 0)
-        return ASN_ECC_KEY_E;
-
-    if (GetInt(s, sig, &idx, sigLen) < 0)
-        return ASN_ECC_KEY_E;
-
-    return 0;
-}
-
-
-int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key,
-                        word32 inSz)
-{
-    word32 oid = 0;
-    int    version, length;
-    int    privSz, pubSz;
-    byte   b;
-    int    ret = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    byte* priv;
-    byte* pub;
-#else
-    byte priv[ECC_MAXSIZE];
-    byte pub[ECC_MAXSIZE * 2 + 1]; /* public key has two parts plus header */
-#endif
-
-    if (input == NULL || inOutIdx == NULL || key == NULL || inSz == 0)
-        return BAD_FUNC_ARG;
-
-    if (GetSequence(input, inOutIdx, &length, inSz) < 0)
-        return ASN_PARSE_E;
-
-    if (GetMyVersion(input, inOutIdx, &version) < 0)
-        return ASN_PARSE_E;
-
-    b = input[*inOutIdx];
-    *inOutIdx += 1;
-
-    /* priv type */
-    if (b != 4 && b != 6 && b != 7) 
-        return ASN_PARSE_E;
-
-    if (GetLength(input, inOutIdx, &length, inSz) < 0)
-        return ASN_PARSE_E;
-
-    if (length > ECC_MAXSIZE)
-        return BUFFER_E;
-
-#ifdef WOLFSSL_SMALL_STACK
-    priv = (byte*)XMALLOC(ECC_MAXSIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (priv == NULL)
-        return MEMORY_E;
-    
-    pub = (byte*)XMALLOC(ECC_MAXSIZE * 2 + 1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (pub == NULL) {
-        XFREE(priv, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#endif
-
-    /* priv key */
-    privSz = length;
-    XMEMCPY(priv, &input[*inOutIdx], privSz);
-    *inOutIdx += length;
-
-    /* prefix 0, may have */
-    b = input[*inOutIdx];
-    if (b == ECC_PREFIX_0) {
-        *inOutIdx += 1;
-
-        if (GetLength(input, inOutIdx, &length, inSz) < 0)
-            ret = ASN_PARSE_E;
-        else {
-            /* object id */
-            b = input[*inOutIdx];
-            *inOutIdx += 1;
-
-            if (b != ASN_OBJECT_ID) {
-                ret = ASN_OBJECT_ID_E;
-            }
-            else if (GetLength(input, inOutIdx, &length, inSz) < 0) {
-                ret = ASN_PARSE_E;
-            }
-            else {
-                while(length--) {
-                    oid += input[*inOutIdx];
-                    *inOutIdx += 1;
-                }
-                if (CheckCurve(oid) < 0)
-                    ret = ECC_CURVE_OID_E;
-            }
-        }
-    }
-
-    if (ret == 0) {
-        /* prefix 1 */
-        b = input[*inOutIdx];
-        *inOutIdx += 1;
-
-        if (b != ECC_PREFIX_1) {
-            ret = ASN_ECC_KEY_E;
-        }
-        else if (GetLength(input, inOutIdx, &length, inSz) < 0) {
-            ret = ASN_PARSE_E;
-        }
-        else {
-            /* key header */
-            b = input[*inOutIdx];
-            *inOutIdx += 1;
-            
-            if (b != ASN_BIT_STRING) {
-                ret = ASN_BITSTR_E;
-            }
-            else if (GetLength(input, inOutIdx, &length, inSz) < 0) {
-                ret = ASN_PARSE_E;
-            }
-            else {
-                b = input[*inOutIdx];
-                *inOutIdx += 1;
-
-                if (b != 0x00) {
-                    ret = ASN_EXPECT_0_E;
-                }
-                else {
-                    /* pub key */
-                    pubSz = length - 1;  /* null prefix */
-                    if (pubSz < (ECC_MAXSIZE*2 + 1)) {
-                        XMEMCPY(pub, &input[*inOutIdx], pubSz);
-                        *inOutIdx += length;
-                        ret = wc_ecc_import_private_key(priv, privSz, pub, pubSz,
-                                                     key);
-                    } else
-                        ret = BUFFER_E;
-                }
-            }
-        }
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(priv, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(pub,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-#ifdef WOLFSSL_KEY_GEN
-
-/* Write a Private ecc key to DER format, length on success else < 0 */
-int wc_EccKeyToDer(ecc_key* key, byte* output, word32 inLen)
-{
-    byte   curve[MAX_ALGO_SZ];
-    byte   ver[MAX_VERSION_SZ];
-    byte   seq[MAX_SEQ_SZ];
-    int    ret;
-    int    curveSz;
-    int    verSz;
-    int    privHdrSz  = ASN_ECC_HEADER_SZ;
-    int    pubHdrSz   = ASN_ECC_CONTEXT_SZ + ASN_ECC_HEADER_SZ;
-    int    curveHdrSz = ASN_ECC_CONTEXT_SZ;
-    word32 seqSz;
-    word32 idx = 0;
-    word32 pubSz = ECC_BUFSIZE;
-    word32 privSz;
-    word32 totalSz;
-
-    if (key == NULL || output == NULL || inLen == 0)
-        return BAD_FUNC_ARG;
-
-    ret = wc_ecc_export_x963(key, NULL, &pubSz);
-    if (ret != LENGTH_ONLY_E) {
-        return ret;
-    }
-    curveSz = SetCurve(key, curve);
-    if (curveSz < 0) {
-        return curveSz;
-    }
-
-    privSz = key->dp->size;
-
-    verSz = SetMyVersion(1, ver, FALSE);
-    if (verSz < 0) {
-        return verSz;
-    }
-
-    totalSz = verSz + privSz + privHdrSz + curveSz + curveHdrSz +
-              pubSz + pubHdrSz + 1;  /* plus null byte b4 public */
-    seqSz = SetSequence(totalSz, seq);
-    totalSz += seqSz;
-
-    if (totalSz > inLen) {
-        return BUFFER_E;
-    }
-
-    /* write it out */
-    /* seq */
-    XMEMCPY(output + idx, seq, seqSz);
-    idx += seqSz;
-
-   /* ver */
-    XMEMCPY(output + idx, ver, verSz);
-    idx += verSz;
-
-    /* private */
-    output[idx++] = ASN_OCTET_STRING;
-    output[idx++] = (byte)privSz;
-    ret = wc_ecc_export_private_only(key, output + idx, &privSz);
-    if (ret < 0) {
-        return ret;
-    }
-    idx += privSz;
-
-    /* curve */
-    output[idx++] = ECC_PREFIX_0;
-    output[idx++] = (byte)curveSz;
-    XMEMCPY(output + idx, curve, curveSz);
-    idx += curveSz;
-
-    /* public */
-    output[idx++] = ECC_PREFIX_1;
-    output[idx++] = (byte)pubSz + ASN_ECC_CONTEXT_SZ + 1;  /* plus null byte */
-    output[idx++] = ASN_BIT_STRING;
-    output[idx++] = (byte)pubSz + 1;  /* plus null byte */
-    output[idx++] = (byte)0;          /* null byte */
-    ret = wc_ecc_export_x963(key, output + idx, &pubSz);
-    if (ret != 0) {
-        return ret;
-    }
-    /* idx += pubSz if do more later */
-
-    return totalSz;
-}
-
-#endif /* WOLFSSL_KEY_GEN */
-
-#endif  /* HAVE_ECC */
-
-
-#if defined(HAVE_OCSP) || defined(HAVE_CRL)
-
-/* Get raw Date only, no processing, 0 on success */
-static int GetBasicDate(const byte* source, word32* idx, byte* date,
-                        byte* format, int maxIdx)
-{
-    int    length;
-
-    WOLFSSL_ENTER("GetBasicDate");
-
-    *format = source[*idx];
-    *idx += 1;
-    if (*format != ASN_UTC_TIME && *format != ASN_GENERALIZED_TIME)
-        return ASN_TIME_E;
-
-    if (GetLength(source, idx, &length, maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    if (length > MAX_DATE_SIZE || length < MIN_DATE_SIZE)
-        return ASN_DATE_SZ_E;
-
-    XMEMCPY(date, &source[*idx], length);
-    *idx += length;
-
-    return 0;
-}
-
-#endif
-
-
-#ifdef HAVE_OCSP
-
-static int GetEnumerated(const byte* input, word32* inOutIdx, int *value)
-{
-    word32 idx = *inOutIdx;
-    word32 len;
-
-    WOLFSSL_ENTER("GetEnumerated");
-
-    *value = 0;
-
-    if (input[idx++] != ASN_ENUMERATED)
-        return ASN_PARSE_E;
-
-    len = input[idx++];
-    if (len > 4)
-        return ASN_PARSE_E;
-
-    while (len--) {
-        *value  = *value << 8 | input[idx++];
-    }
-
-    *inOutIdx = idx;
-
-    return *value;
-}
-
-
-static int DecodeSingleResponse(byte* source,
-                            word32* ioIndex, OcspResponse* resp, word32 size)
-{
-    word32 idx = *ioIndex, prevIndex, oid;
-    int length, wrapperSz;
-    CertStatus* cs = resp->status;
-
-    WOLFSSL_ENTER("DecodeSingleResponse");
-
-    /* Outer wrapper of the SEQUENCE OF Single Responses. */
-    if (GetSequence(source, &idx, &wrapperSz, size) < 0)
-        return ASN_PARSE_E;
-
-    prevIndex = idx;
-
-    /* When making a request, we only request one status on one certificate
-     * at a time. There should only be one SingleResponse */
-
-    /* Wrapper around the Single Response */
-    if (GetSequence(source, &idx, &length, size) < 0)
-        return ASN_PARSE_E;
-
-    /* Wrapper around the CertID */
-    if (GetSequence(source, &idx, &length, size) < 0)
-        return ASN_PARSE_E;
-    /* Skip the hash algorithm */
-    if (GetAlgoId(source, &idx, &oid, size) < 0)
-        return ASN_PARSE_E;
-    /* Save reference to the hash of CN */
-    if (source[idx++] != ASN_OCTET_STRING)
-        return ASN_PARSE_E;
-    if (GetLength(source, &idx, &length, size) < 0)
-        return ASN_PARSE_E;
-    resp->issuerHash = source + idx;
-    idx += length;
-    /* Save reference to the hash of the issuer public key */
-    if (source[idx++] != ASN_OCTET_STRING)
-        return ASN_PARSE_E;
-    if (GetLength(source, &idx, &length, size) < 0)
-        return ASN_PARSE_E;
-    resp->issuerKeyHash = source + idx;
-    idx += length;
-
-    /* Read the serial number, it is handled as a string, not as a 
-     * proper number. Just XMEMCPY the data over, rather than load it
-     * as an mp_int. */
-    if (source[idx++] != ASN_INTEGER)
-        return ASN_PARSE_E;
-    if (GetLength(source, &idx, &length, size) < 0)
-        return ASN_PARSE_E;
-    if (length <= EXTERNAL_SERIAL_SIZE)
-    {
-        if (source[idx] == 0)
-        {
-            idx++;
-            length--;
-        }
-        XMEMCPY(cs->serial, source + idx, length);
-        cs->serialSz = length;
-    }
-    else
-    {
-        return ASN_GETINT_E;
-    }
-    idx += length;
-
-    /* CertStatus */
-    switch (source[idx++])
-    {
-        case (ASN_CONTEXT_SPECIFIC | CERT_GOOD):
-            cs->status = CERT_GOOD;
-            idx++;
-            break;
-        case (ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED | CERT_REVOKED):
-            cs->status = CERT_REVOKED;
-            if (GetLength(source, &idx, &length, size) < 0)
-                return ASN_PARSE_E;
-            idx += length;
-            break;
-        case (ASN_CONTEXT_SPECIFIC | CERT_UNKNOWN):
-            cs->status = CERT_UNKNOWN;
-            idx++;
-            break;
-        default:
-            return ASN_PARSE_E;
-    }
-
-    if (GetBasicDate(source, &idx, cs->thisDate,
-                                                &cs->thisDateFormat, size) < 0)
-        return ASN_PARSE_E;
-    if (!XVALIDATE_DATE(cs->thisDate, cs->thisDateFormat, BEFORE))
-        return ASN_BEFORE_DATE_E;
-    
-    /* The following items are optional. Only check for them if there is more
-     * unprocessed data in the singleResponse wrapper. */
-    
-    if (((int)(idx - prevIndex) < wrapperSz) &&
-        (source[idx] == (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 0)))
-    {
-        idx++;
-        if (GetLength(source, &idx, &length, size) < 0)
-            return ASN_PARSE_E;
-        if (GetBasicDate(source, &idx, cs->nextDate,
-                                                &cs->nextDateFormat, size) < 0)
-            return ASN_PARSE_E;
-    }
-    if (((int)(idx - prevIndex) < wrapperSz) &&
-        (source[idx] == (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 1)))
-    {
-        idx++;
-        if (GetLength(source, &idx, &length, size) < 0)
-            return ASN_PARSE_E;
-        idx += length;
-    }
-
-    *ioIndex = idx;
-
-    return 0;
-}
-
-static int DecodeOcspRespExtensions(byte* source,
-                            word32* ioIndex, OcspResponse* resp, word32 sz)
-{
-    word32 idx = *ioIndex;
-    int length;
-    int ext_bound; /* boundary index for the sequence of extensions */
-    word32 oid;
-
-    WOLFSSL_ENTER("DecodeOcspRespExtensions");
-
-    if (source[idx++] != (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 1))
-        return ASN_PARSE_E;
-
-    if (GetLength(source, &idx, &length, sz) < 0) return ASN_PARSE_E;
-
-    if (GetSequence(source, &idx, &length, sz) < 0) return ASN_PARSE_E;
-   
-    ext_bound = idx + length;
-
-    while (idx < (word32)ext_bound) {
-        if (GetSequence(source, &idx, &length, sz) < 0) {
-            WOLFSSL_MSG("\tfail: should be a SEQUENCE");
-            return ASN_PARSE_E;
-        }
-
-        oid = 0;
-        if (GetObjectId(source, &idx, &oid, sz) < 0) {
-            WOLFSSL_MSG("\tfail: OBJECT ID");
-            return ASN_PARSE_E;
-        }
-
-        /* check for critical flag */
-        if (source[idx] == ASN_BOOLEAN) {
-            WOLFSSL_MSG("\tfound optional critical flag, moving past");
-            idx += (ASN_BOOL_SIZE + 1);
-        }
-
-        /* process the extension based on the OID */
-        if (source[idx++] != ASN_OCTET_STRING) {
-            WOLFSSL_MSG("\tfail: should be an OCTET STRING");
-            return ASN_PARSE_E;
-        }
-
-        if (GetLength(source, &idx, &length, sz) < 0) {
-            WOLFSSL_MSG("\tfail: extension data length");
-            return ASN_PARSE_E;
-        }
-
-        if (oid == OCSP_NONCE_OID) {
-            resp->nonce = source + idx;
-            resp->nonceSz = length;
-        }
-
-        idx += length;
-    }
-
-    *ioIndex = idx;
-    return 0;
-}
-
-
-static int DecodeResponseData(byte* source,
-                            word32* ioIndex, OcspResponse* resp, word32 size)
-{
-    word32 idx = *ioIndex, prev_idx;
-    int length;
-    int version;
-    word32 responderId = 0;
-
-    WOLFSSL_ENTER("DecodeResponseData");
-
-    resp->response = source + idx;
-    prev_idx = idx;
-    if (GetSequence(source, &idx, &length, size) < 0)
-        return ASN_PARSE_E;
-    resp->responseSz = length + idx - prev_idx;
-
-    /* Get version. It is an EXPLICIT[0] DEFAULT(0) value. If this
-     * item isn't an EXPLICIT[0], then set version to zero and move
-     * onto the next item.
-     */
-    if (source[idx] == (ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED))
-    {    
-        idx += 2; /* Eat the value and length */
-        if (GetMyVersion(source, &idx, &version) < 0)
-            return ASN_PARSE_E;
-    } else
-        version = 0;
-
-    responderId = source[idx++];
-    if ((responderId == (ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED | 1)) ||
-        (responderId == (ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED | 2)))
-    {
-        if (GetLength(source, &idx, &length, size) < 0)
-            return ASN_PARSE_E;
-        idx += length;
-    }
-    else
-        return ASN_PARSE_E;
-    
-    /* save pointer to the producedAt time */
-    if (GetBasicDate(source, &idx, resp->producedDate,
-                                        &resp->producedDateFormat, size) < 0)
-        return ASN_PARSE_E;
-
-    if (DecodeSingleResponse(source, &idx, resp, size) < 0)
-        return ASN_PARSE_E;
-
-    if (DecodeOcspRespExtensions(source, &idx, resp, size) < 0)
-        return ASN_PARSE_E;
-
-    *ioIndex = idx;
-    return 0;
-}
-
-
-static int DecodeCerts(byte* source,
-                            word32* ioIndex, OcspResponse* resp, word32 size)
-{
-    word32 idx = *ioIndex;
-
-    WOLFSSL_ENTER("DecodeCerts");
-
-    if (source[idx++] == (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC))
-    {
-        int length;
-
-        if (GetLength(source, &idx, &length, size) < 0)
-            return ASN_PARSE_E;
-
-        if (GetSequence(source, &idx, &length, size) < 0)
-            return ASN_PARSE_E;
-
-        resp->cert = source + idx;
-        resp->certSz = length;
-
-        idx += length;
-    }
-    *ioIndex = idx;
-    return 0;
-}
-
-static int DecodeBasicOcspResponse(byte* source,
-                            word32* ioIndex, OcspResponse* resp, word32 size)
-{
-    int length;
-    word32 idx = *ioIndex;
-    word32 end_index;
-
-    WOLFSSL_ENTER("DecodeBasicOcspResponse");
-
-    if (GetSequence(source, &idx, &length, size) < 0)
-        return ASN_PARSE_E;
-
-    if (idx + length > size)
-        return ASN_INPUT_E;
-    end_index = idx + length;
-
-    if (DecodeResponseData(source, &idx, resp, size) < 0)
-        return ASN_PARSE_E;
-    
-    /* Get the signature algorithm */
-    if (GetAlgoId(source, &idx, &resp->sigOID, size) < 0)
-        return ASN_PARSE_E;
-
-    /* Obtain pointer to the start of the signature, and save the size */
-    if (source[idx++] == ASN_BIT_STRING)
-    {
-        int sigLength = 0;
-        if (GetLength(source, &idx, &sigLength, size) < 0)
-            return ASN_PARSE_E;
-        resp->sigSz = sigLength;
-        resp->sig = source + idx;
-        idx += sigLength;
-    }
-
-    /*
-     * Check the length of the BasicOcspResponse against the current index to
-     * see if there are certificates, they are optional.
-     */
-    if (idx < end_index)
-    {
-        DecodedCert cert;
-        int ret;
-
-        if (DecodeCerts(source, &idx, resp, size) < 0)
-            return ASN_PARSE_E;
-
-        InitDecodedCert(&cert, resp->cert, resp->certSz, 0);
-        ret = ParseCertRelative(&cert, CA_TYPE, NO_VERIFY, 0);
-        if (ret < 0)
-            return ret;
-
-        ret = ConfirmSignature(resp->response, resp->responseSz,
-                            cert.publicKey, cert.pubKeySize, cert.keyOID,
-                            resp->sig, resp->sigSz, resp->sigOID, NULL);
-        FreeDecodedCert(&cert);
-
-        if (ret == 0)
-        {
-            WOLFSSL_MSG("\tOCSP Confirm signature failed");
-            return ASN_OCSP_CONFIRM_E;
-        }
-    }
-
-    *ioIndex = idx;
-    return 0;
-}
-
-
-void InitOcspResponse(OcspResponse* resp, CertStatus* status,
-                                                    byte* source, word32 inSz)
-{
-    WOLFSSL_ENTER("InitOcspResponse");
-
-    resp->responseStatus = -1;
-    resp->response = NULL;
-    resp->responseSz = 0;
-    resp->producedDateFormat = 0;
-    resp->issuerHash = NULL;
-    resp->issuerKeyHash = NULL;
-    resp->sig = NULL;
-    resp->sigSz = 0;
-    resp->sigOID = 0;
-    resp->status = status;
-    resp->nonce = NULL;
-    resp->nonceSz = 0;
-    resp->source = source;
-    resp->maxIdx = inSz;
-}
-
-
-int OcspResponseDecode(OcspResponse* resp)
-{
-    int length = 0;
-    word32 idx = 0;
-    byte* source = resp->source;
-    word32 size = resp->maxIdx;
-    word32 oid;
-
-    WOLFSSL_ENTER("OcspResponseDecode");
-
-    /* peel the outer SEQUENCE wrapper */
-    if (GetSequence(source, &idx, &length, size) < 0)
-        return ASN_PARSE_E;
-    
-    /* First get the responseStatus, an ENUMERATED */
-    if (GetEnumerated(source, &idx, &resp->responseStatus) < 0)
-        return ASN_PARSE_E;
-
-    if (resp->responseStatus != OCSP_SUCCESSFUL)
-        return 0;
-
-    /* Next is an EXPLICIT record called ResponseBytes, OPTIONAL */
-    if (idx >= size)
-        return ASN_INPUT_E;
-    if (source[idx++] != (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC))
-        return ASN_PARSE_E;
-    if (GetLength(source, &idx, &length, size) < 0)
-        return ASN_PARSE_E;
-
-    /* Get the responseBytes SEQUENCE */
-    if (GetSequence(source, &idx, &length, size) < 0)
-        return ASN_PARSE_E;
-
-    /* Check ObjectID for the resposeBytes */
-    if (GetObjectId(source, &idx, &oid, size) < 0)
-        return ASN_PARSE_E;
-    if (oid != OCSP_BASIC_OID)
-        return ASN_PARSE_E;
-    if (source[idx++] != ASN_OCTET_STRING)
-        return ASN_PARSE_E;
-
-    if (GetLength(source, &idx, &length, size) < 0)
-        return ASN_PARSE_E;
-
-    if (DecodeBasicOcspResponse(source, &idx, resp, size) < 0)
-        return ASN_PARSE_E;
-    
-    return 0;
-}
-
-
-static word32 SetOcspReqExtensions(word32 extSz, byte* output,
-                                            const byte* nonce, word32 nonceSz)
-{
-    static const byte NonceObjId[] = { 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07,
-                                       0x30, 0x01, 0x02 };
-    byte seqArray[5][MAX_SEQ_SZ];
-    word32 seqSz[5], totalSz;
-
-    WOLFSSL_ENTER("SetOcspReqExtensions");
-
-    if (nonce == NULL || nonceSz == 0) return 0;
-    
-    seqArray[0][0] = ASN_OCTET_STRING;
-    seqSz[0] = 1 + SetLength(nonceSz, &seqArray[0][1]);
-
-    seqArray[1][0] = ASN_OBJECT_ID;
-    seqSz[1] = 1 + SetLength(sizeof(NonceObjId), &seqArray[1][1]);
-
-    totalSz = seqSz[0] + seqSz[1] + nonceSz + (word32)sizeof(NonceObjId);
-
-    seqSz[2] = SetSequence(totalSz, seqArray[2]);
-    totalSz += seqSz[2];
-
-    seqSz[3] = SetSequence(totalSz, seqArray[3]);
-    totalSz += seqSz[3];
-
-    seqArray[4][0] = (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 2);
-    seqSz[4] = 1 + SetLength(totalSz, &seqArray[4][1]);
-    totalSz += seqSz[4];
-
-    if (totalSz < extSz)
-    {
-        totalSz = 0;
-        XMEMCPY(output + totalSz, seqArray[4], seqSz[4]);
-        totalSz += seqSz[4];
-        XMEMCPY(output + totalSz, seqArray[3], seqSz[3]);
-        totalSz += seqSz[3];
-        XMEMCPY(output + totalSz, seqArray[2], seqSz[2]);
-        totalSz += seqSz[2];
-        XMEMCPY(output + totalSz, seqArray[1], seqSz[1]);
-        totalSz += seqSz[1];
-        XMEMCPY(output + totalSz, NonceObjId, sizeof(NonceObjId));
-        totalSz += (word32)sizeof(NonceObjId);
-        XMEMCPY(output + totalSz, seqArray[0], seqSz[0]);
-        totalSz += seqSz[0];
-        XMEMCPY(output + totalSz, nonce, nonceSz);
-        totalSz += nonceSz;
-    }
-
-    return totalSz;
-}
-
-
-int EncodeOcspRequest(OcspRequest* req)
-{
-    byte seqArray[5][MAX_SEQ_SZ];
-    /* The ASN.1 of the OCSP Request is an onion of sequences */
-    byte algoArray[MAX_ALGO_SZ];
-    byte issuerArray[MAX_ENCODED_DIG_SZ];
-    byte issuerKeyArray[MAX_ENCODED_DIG_SZ];
-    byte snArray[MAX_SN_SZ];
-    byte extArray[MAX_OCSP_EXT_SZ];
-    byte* output = req->dest;
-    word32 seqSz[5], algoSz, issuerSz, issuerKeySz, snSz, extSz, totalSz;
-    int i;
-
-    WOLFSSL_ENTER("EncodeOcspRequest");
-
-#ifdef NO_SHA
-    algoSz = SetAlgoID(SHA256h, algoArray, hashType, 0);
-#else
-    algoSz = SetAlgoID(SHAh, algoArray, hashType, 0);
-#endif
-
-    req->issuerHash = req->cert->issuerHash;
-    issuerSz = SetDigest(req->cert->issuerHash, KEYID_SIZE, issuerArray);
-
-    req->issuerKeyHash = req->cert->issuerKeyHash;
-    issuerKeySz = SetDigest(req->cert->issuerKeyHash,
-                                                    KEYID_SIZE, issuerKeyArray);
-
-    req->serial = req->cert->serial;
-    req->serialSz = req->cert->serialSz;
-    snSz = SetSerialNumber(req->cert->serial, req->cert->serialSz, snArray);
-
-    extSz = 0;
-    if (req->useNonce) {
-        RNG rng;
-        if (wc_InitRng(&rng) != 0) {
-            WOLFSSL_MSG("\tCannot initialize RNG. Skipping the OSCP Nonce.");
-        } else {
-            if (wc_RNG_GenerateBlock(&rng, req->nonce, MAX_OCSP_NONCE_SZ) != 0)
-                WOLFSSL_MSG("\tCannot run RNG. Skipping the OSCP Nonce.");
-            else {
-                req->nonceSz = MAX_OCSP_NONCE_SZ;
-                extSz = SetOcspReqExtensions(MAX_OCSP_EXT_SZ, extArray,
-                                                      req->nonce, req->nonceSz);
-            }
-            wc_FreeRng(&rng);
-        }
-    }
-
-    totalSz = algoSz + issuerSz + issuerKeySz + snSz;
-
-    for (i = 4; i >= 0; i--) {
-        seqSz[i] = SetSequence(totalSz, seqArray[i]);
-        totalSz += seqSz[i];
-        if (i == 2) totalSz += extSz;
-    }
-    totalSz = 0;
-    for (i = 0; i < 5; i++) {
-        XMEMCPY(output + totalSz, seqArray[i], seqSz[i]);
-        totalSz += seqSz[i];
-    }
-    XMEMCPY(output + totalSz, algoArray, algoSz);
-    totalSz += algoSz;
-    XMEMCPY(output + totalSz, issuerArray, issuerSz);
-    totalSz += issuerSz;
-    XMEMCPY(output + totalSz, issuerKeyArray, issuerKeySz);
-    totalSz += issuerKeySz;
-    XMEMCPY(output + totalSz, snArray, snSz);
-    totalSz += snSz;
-    if (extSz != 0) {
-        XMEMCPY(output + totalSz, extArray, extSz);
-        totalSz += extSz;
-    }
-
-    return totalSz;
-}
-
-
-void InitOcspRequest(OcspRequest* req, DecodedCert* cert, byte useNonce,
-                                                    byte* dest, word32 destSz)
-{
-    WOLFSSL_ENTER("InitOcspRequest");
-
-    req->cert = cert;
-    req->useNonce = useNonce;
-    req->nonceSz = 0;
-    req->issuerHash = NULL;
-    req->issuerKeyHash = NULL;
-    req->serial = NULL;
-    req->dest = dest;
-    req->destSz = destSz;
-}
-
-
-int CompareOcspReqResp(OcspRequest* req, OcspResponse* resp)
-{
-    int cmp;
-
-    WOLFSSL_ENTER("CompareOcspReqResp");
-
-    if (req == NULL)
-    {
-        WOLFSSL_MSG("\tReq missing");
-        return -1;
-    }
-
-    if (resp == NULL)
-    {
-        WOLFSSL_MSG("\tResp missing");
-        return 1;
-    }
-
-    /* Nonces are not critical. The responder may not necessarily add
-     * the nonce to the response. */
-    if (req->useNonce && resp->nonceSz != 0) {
-        cmp = req->nonceSz - resp->nonceSz;
-        if (cmp != 0)
-        {
-            WOLFSSL_MSG("\tnonceSz mismatch");
-            return cmp;
-        }
-    
-        cmp = XMEMCMP(req->nonce, resp->nonce, req->nonceSz);
-        if (cmp != 0)
-        {
-            WOLFSSL_MSG("\tnonce mismatch");
-            return cmp;
-        }
-    }
-
-    cmp = XMEMCMP(req->issuerHash, resp->issuerHash, KEYID_SIZE);
-    if (cmp != 0)
-    {
-        WOLFSSL_MSG("\tissuerHash mismatch");
-        return cmp;
-    }
-
-    cmp = XMEMCMP(req->issuerKeyHash, resp->issuerKeyHash, KEYID_SIZE);
-    if (cmp != 0)
-    {
-        WOLFSSL_MSG("\tissuerKeyHash mismatch");
-        return cmp;
-    }
-
-    cmp = req->serialSz - resp->status->serialSz;
-    if (cmp != 0)
-    {
-        WOLFSSL_MSG("\tserialSz mismatch");
-        return cmp;
-    }
-
-    cmp = XMEMCMP(req->serial, resp->status->serial, req->serialSz);
-    if (cmp != 0)
-    {
-        WOLFSSL_MSG("\tserial mismatch");
-        return cmp;
-    }
-
-    return 0;
-}
-
-#endif
-
-
-/* store SHA hash of NAME */
-WOLFSSL_LOCAL int GetNameHash(const byte* source, word32* idx, byte* hash,
-                             int maxIdx)
-{
-    int    length;  /* length of all distinguished names */
-    int    ret;
-    word32 dummy;
-
-    WOLFSSL_ENTER("GetNameHash");
-
-    if (source[*idx] == ASN_OBJECT_ID) {
-        WOLFSSL_MSG("Trying optional prefix...");
-
-        if (GetLength(source, idx, &length, maxIdx) < 0)
-            return ASN_PARSE_E;
-
-        *idx += length;
-        WOLFSSL_MSG("Got optional prefix");
-    }
-
-    /* For OCSP, RFC2560 section 4.1.1 states the issuer hash should be
-     * calculated over the entire DER encoding of the Name field, including
-     * the tag and length. */
-    dummy = *idx;
-    if (GetSequence(source, idx, &length, maxIdx) < 0)
-        return ASN_PARSE_E;
-
-#ifdef NO_SHA
-    ret = wc_Sha256Hash(source + dummy, length + *idx - dummy, hash);
-#else
-    ret = wc_ShaHash(source + dummy, length + *idx - dummy, hash);
-#endif
-
-    *idx += length;
-
-    return ret;
-}
-
-
-#ifdef HAVE_CRL
-
-/* initialize decoded CRL */
-void InitDecodedCRL(DecodedCRL* dcrl)
-{
-    WOLFSSL_MSG("InitDecodedCRL");
-
-    dcrl->certBegin    = 0;
-    dcrl->sigIndex     = 0;
-    dcrl->sigLength    = 0;
-    dcrl->signatureOID = 0;
-    dcrl->certs        = NULL;
-    dcrl->totalCerts   = 0;
-}
-
-
-/* free decoded CRL resources */
-void FreeDecodedCRL(DecodedCRL* dcrl)
-{
-    RevokedCert* tmp = dcrl->certs;
-
-    WOLFSSL_MSG("FreeDecodedCRL");
-
-    while(tmp) {
-        RevokedCert* next = tmp->next;
-        XFREE(tmp, NULL, DYNAMIC_TYPE_REVOKED);
-        tmp = next;
-    }
-}
-
-
-/* Get Revoked Cert list, 0 on success */
-static int GetRevoked(const byte* buff, word32* idx, DecodedCRL* dcrl,
-                      int maxIdx)
-{
-    int    len;
-    word32 end;
-    byte   b;
-    RevokedCert* rc;
-
-    WOLFSSL_ENTER("GetRevoked");
-
-    if (GetSequence(buff, idx, &len, maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    end = *idx + len;
-
-    /* get serial number */
-    b = buff[*idx];
-    *idx += 1;
-
-    if (b != ASN_INTEGER) {
-        WOLFSSL_MSG("Expecting Integer");
-        return ASN_PARSE_E;
-    }
-
-    if (GetLength(buff, idx, &len, maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    if (len > EXTERNAL_SERIAL_SIZE) {
-        WOLFSSL_MSG("Serial Size too big");
-        return ASN_PARSE_E;
-    }
-
-    rc = (RevokedCert*)XMALLOC(sizeof(RevokedCert), NULL, DYNAMIC_TYPE_CRL);
-    if (rc == NULL) {
-        WOLFSSL_MSG("Alloc Revoked Cert failed");
-        return MEMORY_E;
-    }
-
-    XMEMCPY(rc->serialNumber, &buff[*idx], len);
-    rc->serialSz = len;
-
-    /* add to list */
-    rc->next = dcrl->certs;
-    dcrl->certs = rc;
-    dcrl->totalCerts++;
-
-    *idx += len;
-
-    /* get date */
-    b = buff[*idx];
-    *idx += 1;
-
-    if (b != ASN_UTC_TIME && b != ASN_GENERALIZED_TIME) {
-        WOLFSSL_MSG("Expecting Date");
-        return ASN_PARSE_E;
-    }
-
-    if (GetLength(buff, idx, &len, maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    /* skip for now */
-    *idx += len;
-
-    if (*idx != end)  /* skip extensions */
-        *idx = end;
-
-    return 0;
-}
-
-
-/* Get CRL Signature, 0 on success */
-static int GetCRL_Signature(const byte* source, word32* idx, DecodedCRL* dcrl,
-                            int maxIdx)
-{
-    int    length;
-    byte   b;
-
-    WOLFSSL_ENTER("GetCRL_Signature");
-
-    b = source[*idx];
-    *idx += 1;
-    if (b != ASN_BIT_STRING)
-        return ASN_BITSTR_E;
-
-    if (GetLength(source, idx, &length, maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    dcrl->sigLength = length;
-
-    b = source[*idx];
-    *idx += 1;
-    if (b != 0x00)
-        return ASN_EXPECT_0_E;
-
-    dcrl->sigLength--;
-    dcrl->signature = (byte*)&source[*idx];
-
-    *idx += dcrl->sigLength;
-
-    return 0;
-}
-
-
-/* prase crl buffer into decoded state, 0 on success */
-int ParseCRL(DecodedCRL* dcrl, const byte* buff, word32 sz, void* cm)
-{
-    int     version, len;
-    word32  oid, idx = 0;
-    Signer* ca = NULL;
-
-    WOLFSSL_MSG("ParseCRL");
-
-    /* raw crl hash */
-    /* hash here if needed for optimized comparisons
-     * Sha     sha;
-     * wc_InitSha(&sha);
-     * wc_ShaUpdate(&sha, buff, sz);
-     * wc_ShaFinal(&sha, dcrl->crlHash); */
-
-    if (GetSequence(buff, &idx, &len, sz) < 0)
-        return ASN_PARSE_E;
-
-    dcrl->certBegin = idx;
-
-    if (GetSequence(buff, &idx, &len, sz) < 0)
-        return ASN_PARSE_E;
-    dcrl->sigIndex = len + idx;
-
-    /* may have version */
-    if (buff[idx] == ASN_INTEGER) {
-        if (GetMyVersion(buff, &idx, &version) < 0)
-            return ASN_PARSE_E;
-    }
-
-    if (GetAlgoId(buff, &idx, &oid, sz) < 0)
-        return ASN_PARSE_E;
-
-    if (GetNameHash(buff, &idx, dcrl->issuerHash, sz) < 0)
-        return ASN_PARSE_E;
-
-    if (GetBasicDate(buff, &idx, dcrl->lastDate, &dcrl->lastDateFormat, sz) < 0)
-        return ASN_PARSE_E;
-
-    if (GetBasicDate(buff, &idx, dcrl->nextDate, &dcrl->nextDateFormat, sz) < 0)
-        return ASN_PARSE_E;
-
-    if (!XVALIDATE_DATE(dcrl->nextDate, dcrl->nextDateFormat, AFTER)) {
-        WOLFSSL_MSG("CRL after date is no longer valid");
-        return ASN_AFTER_DATE_E;
-    }
-
-    if (idx != dcrl->sigIndex && buff[idx] != CRL_EXTENSIONS) {
-        if (GetSequence(buff, &idx, &len, sz) < 0)
-            return ASN_PARSE_E;
-
-        len += idx;
-
-        while (idx < (word32)len) {
-            if (GetRevoked(buff, &idx, dcrl, sz) < 0)
-                return ASN_PARSE_E;
-        }
-    }
-
-    if (idx != dcrl->sigIndex)
-        idx = dcrl->sigIndex;   /* skip extensions */
-
-    if (GetAlgoId(buff, &idx, &dcrl->signatureOID, sz) < 0)
-        return ASN_PARSE_E;
-
-    if (GetCRL_Signature(buff, &idx, dcrl, sz) < 0)
-        return ASN_PARSE_E;
-
-    /* openssl doesn't add skid by default for CRLs cause firefox chokes
-       we're not assuming it's available yet */
-    #if !defined(NO_SKID) && defined(CRL_SKID_READY)
-        if (dcrl->extAuthKeyIdSet)
-            ca = GetCA(cm, dcrl->extAuthKeyId);
-        if (ca == NULL)
-            ca = GetCAByName(cm, dcrl->issuerHash);
-    #else /* NO_SKID */
-        ca = GetCA(cm, dcrl->issuerHash);
-    #endif /* NO_SKID */
-    WOLFSSL_MSG("About to verify CRL signature");
-
-    if (ca) {
-        WOLFSSL_MSG("Found CRL issuer CA");
-        /* try to confirm/verify signature */
-        #ifndef IGNORE_KEY_EXTENSIONS
-            if ((ca->keyUsage & KEYUSE_CRL_SIGN) == 0) {
-                WOLFSSL_MSG("CA cannot sign CRLs");
-                return ASN_CRL_NO_SIGNER_E;
-            }
-        #endif /* IGNORE_KEY_EXTENSIONS */
-        if (!ConfirmSignature(buff + dcrl->certBegin,
-                dcrl->sigIndex - dcrl->certBegin,
-                ca->publicKey, ca->pubKeySize, ca->keyOID,
-                dcrl->signature, dcrl->sigLength, dcrl->signatureOID, NULL)) {
-            WOLFSSL_MSG("CRL Confirm signature failed");
-            return ASN_CRL_CONFIRM_E;
-        }
-    }
-    else {
-        WOLFSSL_MSG("Did NOT find CRL issuer CA");
-        return ASN_CRL_NO_SIGNER_E;
-    }
-
-    return 0;
-}
-
-#endif /* HAVE_CRL */
-#endif
-
-#ifdef WOLFSSL_SEP
-
-
-
-#endif /* WOLFSSL_SEP */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/blake2b.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/blake2b.c
deleted file mode 100755
index 6ae5afd..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/blake2b.c
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
-   BLAKE2 reference source code package - reference C implementations
-
-   Written in 2012 by Samuel Neves 
-
-   To the extent possible under law, the author(s) have dedicated all copyright
-   and related and neighboring rights to this software to the public domain
-   worldwide. This software is distributed without any warranty.
-
-   You should have received a copy of the CC0 Public Domain Dedication along with
-   this software. If not, see .
-*/
-/* blake2b.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef HAVE_BLAKE2
-
-#include 
-#include 
-
-
-static const word64 blake2b_IV[8] =
-{
-  0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL,
-  0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
-  0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
-  0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
-};
-
-static const byte blake2b_sigma[12][16] =
-{
-  {  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15 } ,
-  { 14, 10,  4,  8,  9, 15, 13,  6,  1, 12,  0,  2, 11,  7,  5,  3 } ,
-  { 11,  8, 12,  0,  5,  2, 15, 13, 10, 14,  3,  6,  7,  1,  9,  4 } ,
-  {  7,  9,  3,  1, 13, 12, 11, 14,  2,  6,  5, 10,  4,  0, 15,  8 } ,
-  {  9,  0,  5,  7,  2,  4, 10, 15, 14,  1, 11, 12,  6,  8,  3, 13 } ,
-  {  2, 12,  6, 10,  0, 11,  8,  3,  4, 13,  7,  5, 15, 14,  1,  9 } ,
-  { 12,  5,  1, 15, 14, 13,  4, 10,  0,  7,  6,  3,  9,  2,  8, 11 } ,
-  { 13, 11,  7, 14, 12,  1,  3,  9,  5,  0, 15,  4,  8,  6,  2, 10 } ,
-  {  6, 15, 14,  9, 11,  3,  0,  8, 12,  2, 13,  7,  1,  4, 10,  5 } ,
-  { 10,  2,  8,  4,  7,  6,  1,  5, 15, 11,  9, 14,  3, 12, 13 , 0 } ,
-  {  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15 } ,
-  { 14, 10,  4,  8,  9, 15, 13,  6,  1, 12,  0,  2, 11,  7,  5,  3 }
-};
-
-
-static INLINE int blake2b_set_lastnode( blake2b_state *S )
-{
-  S->f[1] = ~0ULL;
-  return 0;
-}
-
-/* Some helper functions, not necessarily useful */
-static INLINE int blake2b_set_lastblock( blake2b_state *S )
-{
-  if( S->last_node ) blake2b_set_lastnode( S );
-
-  S->f[0] = ~0ULL;
-  return 0;
-}
-
-static INLINE int blake2b_increment_counter( blake2b_state *S, const word64
-                                             inc )
-{
-  S->t[0] += inc;
-  S->t[1] += ( S->t[0] < inc );
-  return 0;
-}
-
-static INLINE int blake2b_init0( blake2b_state *S )
-{
-  int i;
-  XMEMSET( S, 0, sizeof( blake2b_state ) );
-
-  for( i = 0; i < 8; ++i ) S->h[i] = blake2b_IV[i];
-
-  return 0;
-}
-
-/* init xors IV with input parameter block */
-int blake2b_init_param( blake2b_state *S, const blake2b_param *P )
-{
-  word32 i;
-  blake2b_init0( S );
-  byte *p = ( byte * )( P );
-
-  /* IV XOR ParamBlock */
-  for( i = 0; i < 8; ++i )
-    S->h[i] ^= load64( p + sizeof( S->h[i] ) * i );
-
-  return 0;
-}
-
-
-
-int blake2b_init( blake2b_state *S, const byte outlen )
-{
-  blake2b_param P[1];
-
-  if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
-
-  P->digest_length = outlen;
-  P->key_length    = 0;
-  P->fanout        = 1;
-  P->depth         = 1;
-  store32( &P->leaf_length, 0 );
-  store64( &P->node_offset, 0 );
-  P->node_depth    = 0;
-  P->inner_length  = 0;
-  XMEMSET( P->reserved, 0, sizeof( P->reserved ) );
-  XMEMSET( P->salt,     0, sizeof( P->salt ) );
-  XMEMSET( P->personal, 0, sizeof( P->personal ) );
-  return blake2b_init_param( S, P );
-}
-
-
-int blake2b_init_key( blake2b_state *S, const byte outlen, const void *key,
-                      const byte keylen )
-{
-  blake2b_param P[1];
-
-  if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
-
-  if ( !key || !keylen || keylen > BLAKE2B_KEYBYTES ) return -1;
-
-  P->digest_length = outlen;
-  P->key_length    = keylen;
-  P->fanout        = 1;
-  P->depth         = 1;
-  store32( &P->leaf_length, 0 );
-  store64( &P->node_offset, 0 );
-  P->node_depth    = 0;
-  P->inner_length  = 0;
-  XMEMSET( P->reserved, 0, sizeof( P->reserved ) );
-  XMEMSET( P->salt,     0, sizeof( P->salt ) );
-  XMEMSET( P->personal, 0, sizeof( P->personal ) );
-
-  if( blake2b_init_param( S, P ) < 0 ) return -1;
-
-  {
-#ifdef WOLFSSL_SMALL_STACK
-    byte* block;
-
-    block = (byte*)XMALLOC(BLAKE2B_BLOCKBYTES, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-    if ( block == NULL ) return -1;
-#else
-    byte block[BLAKE2B_BLOCKBYTES];
-#endif
-
-    XMEMSET( block, 0, BLAKE2B_BLOCKBYTES );
-    XMEMCPY( block, key, keylen );
-    blake2b_update( S, block, BLAKE2B_BLOCKBYTES );
-    secure_zero_memory( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from */
-                                                     /* memory */
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(block, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-  }
-  return 0;
-}
-
-static int blake2b_compress( blake2b_state *S,
-                             const byte block[BLAKE2B_BLOCKBYTES] )
-{
-  int i;
-
-#ifdef WOLFSSL_SMALL_STACK
-  word64* m;
-  word64* v;
-
-  m = (word64*)XMALLOC(sizeof(word64) * 16, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-  if ( m == NULL ) return -1;
-
-  v = (word64*)XMALLOC(sizeof(word64) * 16, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-  if ( v == NULL )
-  {
-    XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    return -1;
-  }
-#else
-  word64 m[16];
-  word64 v[16];
-#endif
-
-  for( i = 0; i < 16; ++i )
-    m[i] = load64( block + i * sizeof( m[i] ) );
-
-  for( i = 0; i < 8; ++i )
-    v[i] = S->h[i];
-
-  v[ 8] = blake2b_IV[0];
-  v[ 9] = blake2b_IV[1];
-  v[10] = blake2b_IV[2];
-  v[11] = blake2b_IV[3];
-  v[12] = S->t[0] ^ blake2b_IV[4];
-  v[13] = S->t[1] ^ blake2b_IV[5];
-  v[14] = S->f[0] ^ blake2b_IV[6];
-  v[15] = S->f[1] ^ blake2b_IV[7];
-#define G(r,i,a,b,c,d) \
-  do { \
-    a = a + b + m[blake2b_sigma[r][2*i+0]]; \
-    d = rotr64(d ^ a, 32); \
-    c = c + d; \
-    b = rotr64(b ^ c, 24); \
-    a = a + b + m[blake2b_sigma[r][2*i+1]]; \
-    d = rotr64(d ^ a, 16); \
-    c = c + d; \
-    b = rotr64(b ^ c, 63); \
-  } while(0)
-#define ROUND(r)  \
-  do { \
-    G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \
-    G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \
-    G(r,2,v[ 2],v[ 6],v[10],v[14]); \
-    G(r,3,v[ 3],v[ 7],v[11],v[15]); \
-    G(r,4,v[ 0],v[ 5],v[10],v[15]); \
-    G(r,5,v[ 1],v[ 6],v[11],v[12]); \
-    G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \
-    G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \
-  } while(0)
-  ROUND( 0 );
-  ROUND( 1 );
-  ROUND( 2 );
-  ROUND( 3 );
-  ROUND( 4 );
-  ROUND( 5 );
-  ROUND( 6 );
-  ROUND( 7 );
-  ROUND( 8 );
-  ROUND( 9 );
-  ROUND( 10 );
-  ROUND( 11 );
-
-  for( i = 0; i < 8; ++i )
-    S->h[i] = S->h[i] ^ v[i] ^ v[i + 8];
-
-#undef G
-#undef ROUND
-
-#ifdef WOLFSSL_SMALL_STACK
-  XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-  XFREE(v, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-  return 0;
-}
-
-/* inlen now in bytes */
-int blake2b_update( blake2b_state *S, const byte *in, word64 inlen )
-{
-  while( inlen > 0 )
-  {
-    word64 left = S->buflen;
-    word64 fill = 2 * BLAKE2B_BLOCKBYTES - left;
-
-    if( inlen > fill )
-    {
-      XMEMCPY( S->buf + left, in, (wolfssl_word)fill ); /* Fill buffer */
-      S->buflen += fill;
-      blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
-
-      if ( blake2b_compress( S, S->buf ) < 0 ) return -1; /* Compress */
-
-      XMEMCPY( S->buf, S->buf + BLAKE2B_BLOCKBYTES, BLAKE2B_BLOCKBYTES );
-              /* Shift buffer left */
-      S->buflen -= BLAKE2B_BLOCKBYTES;
-      in += fill;
-      inlen -= fill;
-    }
-    else /* inlen <= fill */
-    {
-      XMEMCPY( S->buf + left, in, (wolfssl_word)inlen );
-      S->buflen += inlen; /* Be lazy, do not compress */
-      in += inlen;
-      inlen -= inlen;
-    }
-  }
-
-  return 0;
-}
-
-/* Is this correct? */
-int blake2b_final( blake2b_state *S, byte *out, byte outlen )
-{
-  byte buffer[BLAKE2B_OUTBYTES];
-  int     i;
-
-  if( S->buflen > BLAKE2B_BLOCKBYTES )
-  {
-    blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
-
-    if ( blake2b_compress( S, S->buf ) < 0 ) return -1;
-
-    S->buflen -= BLAKE2B_BLOCKBYTES;
-    XMEMCPY( S->buf, S->buf + BLAKE2B_BLOCKBYTES, (wolfssl_word)S->buflen );
-  }
-
-  blake2b_increment_counter( S, S->buflen );
-  blake2b_set_lastblock( S );
-  XMEMSET( S->buf + S->buflen, 0, (wolfssl_word)(2 * BLAKE2B_BLOCKBYTES - S->buflen) );
-         /* Padding */
-  if ( blake2b_compress( S, S->buf ) < 0 ) return -1;
-
-  for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
-    store64( buffer + sizeof( S->h[i] ) * i, S->h[i] );
-
-  XMEMCPY( out, buffer, outlen );
-  return 0;
-}
-
-/* inlen, at least, should be word64. Others can be size_t. */
-int blake2b( byte *out, const void *in, const void *key, const byte outlen,
-             const word64 inlen, byte keylen )
-{
-  blake2b_state S[1];
-
-  /* Verify parameters */
-  if ( NULL == in ) return -1;
-
-  if ( NULL == out ) return -1;
-
-  if( NULL == key ) keylen = 0;
-
-  if( keylen > 0 )
-  {
-    if( blake2b_init_key( S, outlen, key, keylen ) < 0 ) return -1;
-  }
-  else
-  {
-    if( blake2b_init( S, outlen ) < 0 ) return -1;
-  }
-
-  if ( blake2b_update( S, ( byte * )in, inlen ) < 0) return -1;
-
-  return blake2b_final( S, out, outlen );
-}
-
-#if defined(BLAKE2B_SELFTEST)
-#include 
-#include "blake2-kat.h"
-int main( int argc, char **argv )
-{
-  byte key[BLAKE2B_KEYBYTES];
-  byte buf[KAT_LENGTH];
-
-  for( word32 i = 0; i < BLAKE2B_KEYBYTES; ++i )
-    key[i] = ( byte )i;
-
-  for( word32 i = 0; i < KAT_LENGTH; ++i )
-    buf[i] = ( byte )i;
-
-  for( word32 i = 0; i < KAT_LENGTH; ++i )
-  {
-    byte hash[BLAKE2B_OUTBYTES];
-    if ( blake2b( hash, buf, key, BLAKE2B_OUTBYTES, i, BLAKE2B_KEYBYTES ) < 0 )
-    {
-      puts( "error" );
-      return -1;
-    }
-
-    if( 0 != memcmp( hash, blake2b_keyed_kat[i], BLAKE2B_OUTBYTES ) )
-    {
-      puts( "error" );
-      return -1;
-    }
-  }
-
-  puts( "ok" );
-  return 0;
-}
-#endif
-
-
-/* wolfCrypt API */
-
-/* Init Blake2b digest, track size incase final doesn't want to "remember" */
-int wc_InitBlake2b(Blake2b* b2b, word32 digestSz)
-{
-    b2b->digestSz = digestSz;
-
-    return blake2b_init(b2b->S, (byte)digestSz);
-}
-
-
-/* Blake2b Update */
-int wc_Blake2bUpdate(Blake2b* b2b, const byte* data, word32 sz)
-{
-    return blake2b_update(b2b->S, data, sz);
-}
-
-
-/* Blake2b Final, if pass in zero size we use init digestSz */
-int wc_Blake2bFinal(Blake2b* b2b, byte* final, word32 requestSz)
-{
-    word32 sz = requestSz ? requestSz : b2b->digestSz;
-
-    return blake2b_final(b2b->S, final, (byte)sz);
-}
-
-
-/* end CTaoCrypt API */
-
-#endif  /* HAVE_BLAKE2 */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/camellia.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/camellia.c
deleted file mode 100755
index 071019c..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/camellia.c
+++ /dev/null
@@ -1,1620 +0,0 @@
-/* camellia.c ver 1.2.0
- *
- * Copyright (c) 2006,2007
- * NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer as
- *   the first lines of this file unmodified.
- * 2. Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY NTT ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL NTT BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* camellia.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/*
- * Algorithm Specification 
- *  http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef HAVE_CAMELLIA
-
-#include 
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-/* u32 must be 32bit word */
-typedef unsigned int u32;
-typedef unsigned char u8;
-
-/* key constants */
-
-#define CAMELLIA_SIGMA1L ((u32)0xA09E667FL)
-#define CAMELLIA_SIGMA1R ((u32)0x3BCC908BL)
-#define CAMELLIA_SIGMA2L ((u32)0xB67AE858L)
-#define CAMELLIA_SIGMA2R ((u32)0x4CAA73B2L)
-#define CAMELLIA_SIGMA3L ((u32)0xC6EF372FL)
-#define CAMELLIA_SIGMA3R ((u32)0xE94F82BEL)
-#define CAMELLIA_SIGMA4L ((u32)0x54FF53A5L)
-#define CAMELLIA_SIGMA4R ((u32)0xF1D36F1CL)
-#define CAMELLIA_SIGMA5L ((u32)0x10E527FAL)
-#define CAMELLIA_SIGMA5R ((u32)0xDE682D1DL)
-#define CAMELLIA_SIGMA6L ((u32)0xB05688C2L)
-#define CAMELLIA_SIGMA6R ((u32)0xB3E6C1FDL)
-
-/*
- *  macros
- */
-
-
-#if defined(_MSC_VER)
-
-# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
-# define GETU32(p) SWAP(*((u32 *)(p)))
-# define PUTU32(ct, st) {*((u32 *)(ct)) = SWAP((st));}
-
-#else /* not MS-VC */
-
-# define GETU32(pt)				\
-    (((u32)(pt)[0] << 24)			\
-     ^ ((u32)(pt)[1] << 16)			\
-     ^ ((u32)(pt)[2] <<  8)			\
-     ^ ((u32)(pt)[3]))
-
-# define PUTU32(ct, st)  {			\
-	(ct)[0] = (u8)((st) >> 24);		\
-	(ct)[1] = (u8)((st) >> 16);		\
-	(ct)[2] = (u8)((st) >>  8);		\
-	(ct)[3] = (u8)(st); }
-
-#endif
-
-#define CamelliaSubkeyL(INDEX) (subkey[(INDEX)*2])
-#define CamelliaSubkeyR(INDEX) (subkey[(INDEX)*2 + 1])
-
-/* rotation right shift 1byte */
-#define CAMELLIA_RR8(x) (((x) >> 8) + ((x) << 24))
-/* rotation left shift 1bit */
-#define CAMELLIA_RL1(x) (((x) << 1) + ((x) >> 31))
-/* rotation left shift 1byte */
-#define CAMELLIA_RL8(x) (((x) << 8) + ((x) >> 24))
-
-#define CAMELLIA_ROLDQ(ll, lr, rl, rr, w0, w1, bits)	\
-    do {						\
-	w0 = ll;					\
-	ll = (ll << bits) + (lr >> (32 - bits));	\
-	lr = (lr << bits) + (rl >> (32 - bits));	\
-	rl = (rl << bits) + (rr >> (32 - bits));	\
-	rr = (rr << bits) + (w0 >> (32 - bits));	\
-    } while(0)
-
-#define CAMELLIA_ROLDQo32(ll, lr, rl, rr, w0, w1, bits)	\
-    do {						\
-	w0 = ll;					\
-	w1 = lr;					\
-	ll = (lr << (bits - 32)) + (rl >> (64 - bits));	\
-	lr = (rl << (bits - 32)) + (rr >> (64 - bits));	\
-	rl = (rr << (bits - 32)) + (w0 >> (64 - bits));	\
-	rr = (w0 << (bits - 32)) + (w1 >> (64 - bits));	\
-    } while(0)
-
-#define CAMELLIA_SP1110(INDEX) (camellia_sp1110[(INDEX)])
-#define CAMELLIA_SP0222(INDEX) (camellia_sp0222[(INDEX)])
-#define CAMELLIA_SP3033(INDEX) (camellia_sp3033[(INDEX)])
-#define CAMELLIA_SP4404(INDEX) (camellia_sp4404[(INDEX)])
-
-#define CAMELLIA_F(xl, xr, kl, kr, yl, yr, il, ir, t0, t1)	\
-    do {							\
-	il = xl ^ kl;						\
-	ir = xr ^ kr;						\
-	t0 = il >> 16;						\
-	t1 = ir >> 16;						\
-	yl = CAMELLIA_SP1110(ir & 0xff)				\
-	    ^ CAMELLIA_SP0222((t1 >> 8) & 0xff)			\
-	    ^ CAMELLIA_SP3033(t1 & 0xff)			\
-	    ^ CAMELLIA_SP4404((ir >> 8) & 0xff);		\
-	yr = CAMELLIA_SP1110((t0 >> 8) & 0xff)			\
-	    ^ CAMELLIA_SP0222(t0 & 0xff)			\
-	    ^ CAMELLIA_SP3033((il >> 8) & 0xff)			\
-	    ^ CAMELLIA_SP4404(il & 0xff);			\
-	yl ^= yr;						\
-	yr = CAMELLIA_RR8(yr);					\
-	yr ^= yl;						\
-    } while(0)
-
-
-/*
- * for speed up
- *
- */
-#define CAMELLIA_FLS(ll, lr, rl, rr, kll, klr, krl, krr, t0, t1, t2, t3) \
-    do {								\
-	t0 = kll;							\
-	t0 &= ll;							\
-	lr ^= CAMELLIA_RL1(t0);						\
-	t1 = klr;							\
-	t1 |= lr;							\
-	ll ^= t1;							\
-									\
-	t2 = krr;							\
-	t2 |= rr;							\
-	rl ^= t2;							\
-	t3 = krl;							\
-	t3 &= rl;							\
-	rr ^= CAMELLIA_RL1(t3);						\
-    } while(0)
-
-#define CAMELLIA_ROUNDSM(xl, xr, kl, kr, yl, yr, il, ir, t0, t1)	\
-    do {								\
-	ir = CAMELLIA_SP1110(xr & 0xff)					\
-	    ^ CAMELLIA_SP0222((xr >> 24) & 0xff)			\
-	    ^ CAMELLIA_SP3033((xr >> 16) & 0xff)			\
-	    ^ CAMELLIA_SP4404((xr >> 8) & 0xff);			\
-	il = CAMELLIA_SP1110((xl >> 24) & 0xff)				\
-	    ^ CAMELLIA_SP0222((xl >> 16) & 0xff)			\
-	    ^ CAMELLIA_SP3033((xl >> 8) & 0xff)				\
-	    ^ CAMELLIA_SP4404(xl & 0xff);				\
-	il ^= kl;							\
-	ir ^= kr;							\
-	ir ^= il;							\
-	il = CAMELLIA_RR8(il);						\
-	il ^= ir;							\
-	yl ^= ir;							\
-	yr ^= il;							\
-    } while(0)
-
-
-static const u32 camellia_sp1110[256] = {
-    0x70707000,0x82828200,0x2c2c2c00,0xececec00,
-    0xb3b3b300,0x27272700,0xc0c0c000,0xe5e5e500,
-    0xe4e4e400,0x85858500,0x57575700,0x35353500,
-    0xeaeaea00,0x0c0c0c00,0xaeaeae00,0x41414100,
-    0x23232300,0xefefef00,0x6b6b6b00,0x93939300,
-    0x45454500,0x19191900,0xa5a5a500,0x21212100,
-    0xededed00,0x0e0e0e00,0x4f4f4f00,0x4e4e4e00,
-    0x1d1d1d00,0x65656500,0x92929200,0xbdbdbd00,
-    0x86868600,0xb8b8b800,0xafafaf00,0x8f8f8f00,
-    0x7c7c7c00,0xebebeb00,0x1f1f1f00,0xcecece00,
-    0x3e3e3e00,0x30303000,0xdcdcdc00,0x5f5f5f00,
-    0x5e5e5e00,0xc5c5c500,0x0b0b0b00,0x1a1a1a00,
-    0xa6a6a600,0xe1e1e100,0x39393900,0xcacaca00,
-    0xd5d5d500,0x47474700,0x5d5d5d00,0x3d3d3d00,
-    0xd9d9d900,0x01010100,0x5a5a5a00,0xd6d6d600,
-    0x51515100,0x56565600,0x6c6c6c00,0x4d4d4d00,
-    0x8b8b8b00,0x0d0d0d00,0x9a9a9a00,0x66666600,
-    0xfbfbfb00,0xcccccc00,0xb0b0b000,0x2d2d2d00,
-    0x74747400,0x12121200,0x2b2b2b00,0x20202000,
-    0xf0f0f000,0xb1b1b100,0x84848400,0x99999900,
-    0xdfdfdf00,0x4c4c4c00,0xcbcbcb00,0xc2c2c200,
-    0x34343400,0x7e7e7e00,0x76767600,0x05050500,
-    0x6d6d6d00,0xb7b7b700,0xa9a9a900,0x31313100,
-    0xd1d1d100,0x17171700,0x04040400,0xd7d7d700,
-    0x14141400,0x58585800,0x3a3a3a00,0x61616100,
-    0xdedede00,0x1b1b1b00,0x11111100,0x1c1c1c00,
-    0x32323200,0x0f0f0f00,0x9c9c9c00,0x16161600,
-    0x53535300,0x18181800,0xf2f2f200,0x22222200,
-    0xfefefe00,0x44444400,0xcfcfcf00,0xb2b2b200,
-    0xc3c3c300,0xb5b5b500,0x7a7a7a00,0x91919100,
-    0x24242400,0x08080800,0xe8e8e800,0xa8a8a800,
-    0x60606000,0xfcfcfc00,0x69696900,0x50505000,
-    0xaaaaaa00,0xd0d0d000,0xa0a0a000,0x7d7d7d00,
-    0xa1a1a100,0x89898900,0x62626200,0x97979700,
-    0x54545400,0x5b5b5b00,0x1e1e1e00,0x95959500,
-    0xe0e0e000,0xffffff00,0x64646400,0xd2d2d200,
-    0x10101000,0xc4c4c400,0x00000000,0x48484800,
-    0xa3a3a300,0xf7f7f700,0x75757500,0xdbdbdb00,
-    0x8a8a8a00,0x03030300,0xe6e6e600,0xdadada00,
-    0x09090900,0x3f3f3f00,0xdddddd00,0x94949400,
-    0x87878700,0x5c5c5c00,0x83838300,0x02020200,
-    0xcdcdcd00,0x4a4a4a00,0x90909000,0x33333300,
-    0x73737300,0x67676700,0xf6f6f600,0xf3f3f300,
-    0x9d9d9d00,0x7f7f7f00,0xbfbfbf00,0xe2e2e200,
-    0x52525200,0x9b9b9b00,0xd8d8d800,0x26262600,
-    0xc8c8c800,0x37373700,0xc6c6c600,0x3b3b3b00,
-    0x81818100,0x96969600,0x6f6f6f00,0x4b4b4b00,
-    0x13131300,0xbebebe00,0x63636300,0x2e2e2e00,
-    0xe9e9e900,0x79797900,0xa7a7a700,0x8c8c8c00,
-    0x9f9f9f00,0x6e6e6e00,0xbcbcbc00,0x8e8e8e00,
-    0x29292900,0xf5f5f500,0xf9f9f900,0xb6b6b600,
-    0x2f2f2f00,0xfdfdfd00,0xb4b4b400,0x59595900,
-    0x78787800,0x98989800,0x06060600,0x6a6a6a00,
-    0xe7e7e700,0x46464600,0x71717100,0xbababa00,
-    0xd4d4d400,0x25252500,0xababab00,0x42424200,
-    0x88888800,0xa2a2a200,0x8d8d8d00,0xfafafa00,
-    0x72727200,0x07070700,0xb9b9b900,0x55555500,
-    0xf8f8f800,0xeeeeee00,0xacacac00,0x0a0a0a00,
-    0x36363600,0x49494900,0x2a2a2a00,0x68686800,
-    0x3c3c3c00,0x38383800,0xf1f1f100,0xa4a4a400,
-    0x40404000,0x28282800,0xd3d3d300,0x7b7b7b00,
-    0xbbbbbb00,0xc9c9c900,0x43434300,0xc1c1c100,
-    0x15151500,0xe3e3e300,0xadadad00,0xf4f4f400,
-    0x77777700,0xc7c7c700,0x80808000,0x9e9e9e00,
-};
-
-static const u32 camellia_sp0222[256] = {
-    0x00e0e0e0,0x00050505,0x00585858,0x00d9d9d9,
-    0x00676767,0x004e4e4e,0x00818181,0x00cbcbcb,
-    0x00c9c9c9,0x000b0b0b,0x00aeaeae,0x006a6a6a,
-    0x00d5d5d5,0x00181818,0x005d5d5d,0x00828282,
-    0x00464646,0x00dfdfdf,0x00d6d6d6,0x00272727,
-    0x008a8a8a,0x00323232,0x004b4b4b,0x00424242,
-    0x00dbdbdb,0x001c1c1c,0x009e9e9e,0x009c9c9c,
-    0x003a3a3a,0x00cacaca,0x00252525,0x007b7b7b,
-    0x000d0d0d,0x00717171,0x005f5f5f,0x001f1f1f,
-    0x00f8f8f8,0x00d7d7d7,0x003e3e3e,0x009d9d9d,
-    0x007c7c7c,0x00606060,0x00b9b9b9,0x00bebebe,
-    0x00bcbcbc,0x008b8b8b,0x00161616,0x00343434,
-    0x004d4d4d,0x00c3c3c3,0x00727272,0x00959595,
-    0x00ababab,0x008e8e8e,0x00bababa,0x007a7a7a,
-    0x00b3b3b3,0x00020202,0x00b4b4b4,0x00adadad,
-    0x00a2a2a2,0x00acacac,0x00d8d8d8,0x009a9a9a,
-    0x00171717,0x001a1a1a,0x00353535,0x00cccccc,
-    0x00f7f7f7,0x00999999,0x00616161,0x005a5a5a,
-    0x00e8e8e8,0x00242424,0x00565656,0x00404040,
-    0x00e1e1e1,0x00636363,0x00090909,0x00333333,
-    0x00bfbfbf,0x00989898,0x00979797,0x00858585,
-    0x00686868,0x00fcfcfc,0x00ececec,0x000a0a0a,
-    0x00dadada,0x006f6f6f,0x00535353,0x00626262,
-    0x00a3a3a3,0x002e2e2e,0x00080808,0x00afafaf,
-    0x00282828,0x00b0b0b0,0x00747474,0x00c2c2c2,
-    0x00bdbdbd,0x00363636,0x00222222,0x00383838,
-    0x00646464,0x001e1e1e,0x00393939,0x002c2c2c,
-    0x00a6a6a6,0x00303030,0x00e5e5e5,0x00444444,
-    0x00fdfdfd,0x00888888,0x009f9f9f,0x00656565,
-    0x00878787,0x006b6b6b,0x00f4f4f4,0x00232323,
-    0x00484848,0x00101010,0x00d1d1d1,0x00515151,
-    0x00c0c0c0,0x00f9f9f9,0x00d2d2d2,0x00a0a0a0,
-    0x00555555,0x00a1a1a1,0x00414141,0x00fafafa,
-    0x00434343,0x00131313,0x00c4c4c4,0x002f2f2f,
-    0x00a8a8a8,0x00b6b6b6,0x003c3c3c,0x002b2b2b,
-    0x00c1c1c1,0x00ffffff,0x00c8c8c8,0x00a5a5a5,
-    0x00202020,0x00898989,0x00000000,0x00909090,
-    0x00474747,0x00efefef,0x00eaeaea,0x00b7b7b7,
-    0x00151515,0x00060606,0x00cdcdcd,0x00b5b5b5,
-    0x00121212,0x007e7e7e,0x00bbbbbb,0x00292929,
-    0x000f0f0f,0x00b8b8b8,0x00070707,0x00040404,
-    0x009b9b9b,0x00949494,0x00212121,0x00666666,
-    0x00e6e6e6,0x00cecece,0x00ededed,0x00e7e7e7,
-    0x003b3b3b,0x00fefefe,0x007f7f7f,0x00c5c5c5,
-    0x00a4a4a4,0x00373737,0x00b1b1b1,0x004c4c4c,
-    0x00919191,0x006e6e6e,0x008d8d8d,0x00767676,
-    0x00030303,0x002d2d2d,0x00dedede,0x00969696,
-    0x00262626,0x007d7d7d,0x00c6c6c6,0x005c5c5c,
-    0x00d3d3d3,0x00f2f2f2,0x004f4f4f,0x00191919,
-    0x003f3f3f,0x00dcdcdc,0x00797979,0x001d1d1d,
-    0x00525252,0x00ebebeb,0x00f3f3f3,0x006d6d6d,
-    0x005e5e5e,0x00fbfbfb,0x00696969,0x00b2b2b2,
-    0x00f0f0f0,0x00313131,0x000c0c0c,0x00d4d4d4,
-    0x00cfcfcf,0x008c8c8c,0x00e2e2e2,0x00757575,
-    0x00a9a9a9,0x004a4a4a,0x00575757,0x00848484,
-    0x00111111,0x00454545,0x001b1b1b,0x00f5f5f5,
-    0x00e4e4e4,0x000e0e0e,0x00737373,0x00aaaaaa,
-    0x00f1f1f1,0x00dddddd,0x00595959,0x00141414,
-    0x006c6c6c,0x00929292,0x00545454,0x00d0d0d0,
-    0x00787878,0x00707070,0x00e3e3e3,0x00494949,
-    0x00808080,0x00505050,0x00a7a7a7,0x00f6f6f6,
-    0x00777777,0x00939393,0x00868686,0x00838383,
-    0x002a2a2a,0x00c7c7c7,0x005b5b5b,0x00e9e9e9,
-    0x00eeeeee,0x008f8f8f,0x00010101,0x003d3d3d,
-};
-
-static const u32 camellia_sp3033[256] = {
-    0x38003838,0x41004141,0x16001616,0x76007676,
-    0xd900d9d9,0x93009393,0x60006060,0xf200f2f2,
-    0x72007272,0xc200c2c2,0xab00abab,0x9a009a9a,
-    0x75007575,0x06000606,0x57005757,0xa000a0a0,
-    0x91009191,0xf700f7f7,0xb500b5b5,0xc900c9c9,
-    0xa200a2a2,0x8c008c8c,0xd200d2d2,0x90009090,
-    0xf600f6f6,0x07000707,0xa700a7a7,0x27002727,
-    0x8e008e8e,0xb200b2b2,0x49004949,0xde00dede,
-    0x43004343,0x5c005c5c,0xd700d7d7,0xc700c7c7,
-    0x3e003e3e,0xf500f5f5,0x8f008f8f,0x67006767,
-    0x1f001f1f,0x18001818,0x6e006e6e,0xaf00afaf,
-    0x2f002f2f,0xe200e2e2,0x85008585,0x0d000d0d,
-    0x53005353,0xf000f0f0,0x9c009c9c,0x65006565,
-    0xea00eaea,0xa300a3a3,0xae00aeae,0x9e009e9e,
-    0xec00ecec,0x80008080,0x2d002d2d,0x6b006b6b,
-    0xa800a8a8,0x2b002b2b,0x36003636,0xa600a6a6,
-    0xc500c5c5,0x86008686,0x4d004d4d,0x33003333,
-    0xfd00fdfd,0x66006666,0x58005858,0x96009696,
-    0x3a003a3a,0x09000909,0x95009595,0x10001010,
-    0x78007878,0xd800d8d8,0x42004242,0xcc00cccc,
-    0xef00efef,0x26002626,0xe500e5e5,0x61006161,
-    0x1a001a1a,0x3f003f3f,0x3b003b3b,0x82008282,
-    0xb600b6b6,0xdb00dbdb,0xd400d4d4,0x98009898,
-    0xe800e8e8,0x8b008b8b,0x02000202,0xeb00ebeb,
-    0x0a000a0a,0x2c002c2c,0x1d001d1d,0xb000b0b0,
-    0x6f006f6f,0x8d008d8d,0x88008888,0x0e000e0e,
-    0x19001919,0x87008787,0x4e004e4e,0x0b000b0b,
-    0xa900a9a9,0x0c000c0c,0x79007979,0x11001111,
-    0x7f007f7f,0x22002222,0xe700e7e7,0x59005959,
-    0xe100e1e1,0xda00dada,0x3d003d3d,0xc800c8c8,
-    0x12001212,0x04000404,0x74007474,0x54005454,
-    0x30003030,0x7e007e7e,0xb400b4b4,0x28002828,
-    0x55005555,0x68006868,0x50005050,0xbe00bebe,
-    0xd000d0d0,0xc400c4c4,0x31003131,0xcb00cbcb,
-    0x2a002a2a,0xad00adad,0x0f000f0f,0xca00caca,
-    0x70007070,0xff00ffff,0x32003232,0x69006969,
-    0x08000808,0x62006262,0x00000000,0x24002424,
-    0xd100d1d1,0xfb00fbfb,0xba00baba,0xed00eded,
-    0x45004545,0x81008181,0x73007373,0x6d006d6d,
-    0x84008484,0x9f009f9f,0xee00eeee,0x4a004a4a,
-    0xc300c3c3,0x2e002e2e,0xc100c1c1,0x01000101,
-    0xe600e6e6,0x25002525,0x48004848,0x99009999,
-    0xb900b9b9,0xb300b3b3,0x7b007b7b,0xf900f9f9,
-    0xce00cece,0xbf00bfbf,0xdf00dfdf,0x71007171,
-    0x29002929,0xcd00cdcd,0x6c006c6c,0x13001313,
-    0x64006464,0x9b009b9b,0x63006363,0x9d009d9d,
-    0xc000c0c0,0x4b004b4b,0xb700b7b7,0xa500a5a5,
-    0x89008989,0x5f005f5f,0xb100b1b1,0x17001717,
-    0xf400f4f4,0xbc00bcbc,0xd300d3d3,0x46004646,
-    0xcf00cfcf,0x37003737,0x5e005e5e,0x47004747,
-    0x94009494,0xfa00fafa,0xfc00fcfc,0x5b005b5b,
-    0x97009797,0xfe00fefe,0x5a005a5a,0xac00acac,
-    0x3c003c3c,0x4c004c4c,0x03000303,0x35003535,
-    0xf300f3f3,0x23002323,0xb800b8b8,0x5d005d5d,
-    0x6a006a6a,0x92009292,0xd500d5d5,0x21002121,
-    0x44004444,0x51005151,0xc600c6c6,0x7d007d7d,
-    0x39003939,0x83008383,0xdc00dcdc,0xaa00aaaa,
-    0x7c007c7c,0x77007777,0x56005656,0x05000505,
-    0x1b001b1b,0xa400a4a4,0x15001515,0x34003434,
-    0x1e001e1e,0x1c001c1c,0xf800f8f8,0x52005252,
-    0x20002020,0x14001414,0xe900e9e9,0xbd00bdbd,
-    0xdd00dddd,0xe400e4e4,0xa100a1a1,0xe000e0e0,
-    0x8a008a8a,0xf100f1f1,0xd600d6d6,0x7a007a7a,
-    0xbb00bbbb,0xe300e3e3,0x40004040,0x4f004f4f,
-};
-
-static const u32 camellia_sp4404[256] = {
-    0x70700070,0x2c2c002c,0xb3b300b3,0xc0c000c0,
-    0xe4e400e4,0x57570057,0xeaea00ea,0xaeae00ae,
-    0x23230023,0x6b6b006b,0x45450045,0xa5a500a5,
-    0xeded00ed,0x4f4f004f,0x1d1d001d,0x92920092,
-    0x86860086,0xafaf00af,0x7c7c007c,0x1f1f001f,
-    0x3e3e003e,0xdcdc00dc,0x5e5e005e,0x0b0b000b,
-    0xa6a600a6,0x39390039,0xd5d500d5,0x5d5d005d,
-    0xd9d900d9,0x5a5a005a,0x51510051,0x6c6c006c,
-    0x8b8b008b,0x9a9a009a,0xfbfb00fb,0xb0b000b0,
-    0x74740074,0x2b2b002b,0xf0f000f0,0x84840084,
-    0xdfdf00df,0xcbcb00cb,0x34340034,0x76760076,
-    0x6d6d006d,0xa9a900a9,0xd1d100d1,0x04040004,
-    0x14140014,0x3a3a003a,0xdede00de,0x11110011,
-    0x32320032,0x9c9c009c,0x53530053,0xf2f200f2,
-    0xfefe00fe,0xcfcf00cf,0xc3c300c3,0x7a7a007a,
-    0x24240024,0xe8e800e8,0x60600060,0x69690069,
-    0xaaaa00aa,0xa0a000a0,0xa1a100a1,0x62620062,
-    0x54540054,0x1e1e001e,0xe0e000e0,0x64640064,
-    0x10100010,0x00000000,0xa3a300a3,0x75750075,
-    0x8a8a008a,0xe6e600e6,0x09090009,0xdddd00dd,
-    0x87870087,0x83830083,0xcdcd00cd,0x90900090,
-    0x73730073,0xf6f600f6,0x9d9d009d,0xbfbf00bf,
-    0x52520052,0xd8d800d8,0xc8c800c8,0xc6c600c6,
-    0x81810081,0x6f6f006f,0x13130013,0x63630063,
-    0xe9e900e9,0xa7a700a7,0x9f9f009f,0xbcbc00bc,
-    0x29290029,0xf9f900f9,0x2f2f002f,0xb4b400b4,
-    0x78780078,0x06060006,0xe7e700e7,0x71710071,
-    0xd4d400d4,0xabab00ab,0x88880088,0x8d8d008d,
-    0x72720072,0xb9b900b9,0xf8f800f8,0xacac00ac,
-    0x36360036,0x2a2a002a,0x3c3c003c,0xf1f100f1,
-    0x40400040,0xd3d300d3,0xbbbb00bb,0x43430043,
-    0x15150015,0xadad00ad,0x77770077,0x80800080,
-    0x82820082,0xecec00ec,0x27270027,0xe5e500e5,
-    0x85850085,0x35350035,0x0c0c000c,0x41410041,
-    0xefef00ef,0x93930093,0x19190019,0x21210021,
-    0x0e0e000e,0x4e4e004e,0x65650065,0xbdbd00bd,
-    0xb8b800b8,0x8f8f008f,0xebeb00eb,0xcece00ce,
-    0x30300030,0x5f5f005f,0xc5c500c5,0x1a1a001a,
-    0xe1e100e1,0xcaca00ca,0x47470047,0x3d3d003d,
-    0x01010001,0xd6d600d6,0x56560056,0x4d4d004d,
-    0x0d0d000d,0x66660066,0xcccc00cc,0x2d2d002d,
-    0x12120012,0x20200020,0xb1b100b1,0x99990099,
-    0x4c4c004c,0xc2c200c2,0x7e7e007e,0x05050005,
-    0xb7b700b7,0x31310031,0x17170017,0xd7d700d7,
-    0x58580058,0x61610061,0x1b1b001b,0x1c1c001c,
-    0x0f0f000f,0x16160016,0x18180018,0x22220022,
-    0x44440044,0xb2b200b2,0xb5b500b5,0x91910091,
-    0x08080008,0xa8a800a8,0xfcfc00fc,0x50500050,
-    0xd0d000d0,0x7d7d007d,0x89890089,0x97970097,
-    0x5b5b005b,0x95950095,0xffff00ff,0xd2d200d2,
-    0xc4c400c4,0x48480048,0xf7f700f7,0xdbdb00db,
-    0x03030003,0xdada00da,0x3f3f003f,0x94940094,
-    0x5c5c005c,0x02020002,0x4a4a004a,0x33330033,
-    0x67670067,0xf3f300f3,0x7f7f007f,0xe2e200e2,
-    0x9b9b009b,0x26260026,0x37370037,0x3b3b003b,
-    0x96960096,0x4b4b004b,0xbebe00be,0x2e2e002e,
-    0x79790079,0x8c8c008c,0x6e6e006e,0x8e8e008e,
-    0xf5f500f5,0xb6b600b6,0xfdfd00fd,0x59590059,
-    0x98980098,0x6a6a006a,0x46460046,0xbaba00ba,
-    0x25250025,0x42420042,0xa2a200a2,0xfafa00fa,
-    0x07070007,0x55550055,0xeeee00ee,0x0a0a000a,
-    0x49490049,0x68680068,0x38380038,0xa4a400a4,
-    0x28280028,0x7b7b007b,0xc9c900c9,0xc1c100c1,
-    0xe3e300e3,0xf4f400f4,0xc7c700c7,0x9e9e009e,
-};
-
-
-/**
- * Stuff related to the Camellia key schedule
- */
-#define subl(x) subL[(x)]
-#define subr(x) subR[(x)]
-
-static int camellia_setup128(const unsigned char *key, u32 *subkey)
-{
-    u32 kll, klr, krl, krr;
-    u32 il, ir, t0, t1, w0, w1;
-    u32 kw4l, kw4r, dw, tl, tr;
-
-#ifdef WOLFSSL_SMALL_STACK
-    u32* subL;
-    u32* subR;
-
-    subL = (u32*) XMALLOC(sizeof(u32) * 26, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (subL == NULL)
-        return MEMORY_E;
-
-    subR = (u32*) XMALLOC(sizeof(u32) * 26, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (subR == NULL) {
-        XFREE(subL, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#else
-    u32 subL[26];
-    u32 subR[26];
-#endif
-
-    /**
-     *  k == kll || klr || krl || krr (|| is concatination)
-     */
-    kll = GETU32(key     );
-    klr = GETU32(key +  4);
-    krl = GETU32(key +  8);
-    krr = GETU32(key + 12);
-    /**
-     * generate KL dependent subkeys
-     */
-    subl(0) = kll; subr(0) = klr;
-    subl(1) = krl; subr(1) = krr;
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
-    subl(4) = kll; subr(4) = klr;
-    subl(5) = krl; subr(5) = krr;
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 30);
-    subl(10) = kll; subr(10) = klr;
-    subl(11) = krl; subr(11) = krr;
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
-    subl(13) = krl; subr(13) = krr;
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
-    subl(16) = kll; subr(16) = klr;
-    subl(17) = krl; subr(17) = krr;
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
-    subl(18) = kll; subr(18) = klr;
-    subl(19) = krl; subr(19) = krr;
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
-    subl(22) = kll; subr(22) = klr;
-    subl(23) = krl; subr(23) = krr;
-
-    /* generate KA */
-    kll = subl(0); klr = subr(0);
-    krl = subl(1); krr = subr(1);
-    CAMELLIA_F(kll, klr,
-	       CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R,
-	       w0, w1, il, ir, t0, t1);
-    krl ^= w0; krr ^= w1;
-    CAMELLIA_F(krl, krr,
-	       CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R,
-	       kll, klr, il, ir, t0, t1);
-    CAMELLIA_F(kll, klr,
-	       CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R,
-	       krl, krr, il, ir, t0, t1);
-    krl ^= w0; krr ^= w1;
-    CAMELLIA_F(krl, krr,
-	       CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R,
-	       w0, w1, il, ir, t0, t1);
-    kll ^= w0; klr ^= w1;
-
-    /* generate KA dependent subkeys */
-    subl(2) = kll; subr(2) = klr;
-    subl(3) = krl; subr(3) = krr;
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
-    subl(6) = kll; subr(6) = klr;
-    subl(7) = krl; subr(7) = krr;
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
-    subl(8) = kll; subr(8) = klr;
-    subl(9) = krl; subr(9) = krr;
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
-    subl(12) = kll; subr(12) = klr;
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
-    subl(14) = kll; subr(14) = klr;
-    subl(15) = krl; subr(15) = krr;
-    CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 34);
-    subl(20) = kll; subr(20) = klr;
-    subl(21) = krl; subr(21) = krr;
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
-    subl(24) = kll; subr(24) = klr;
-    subl(25) = krl; subr(25) = krr;
-
-
-    /* absorb kw2 to other subkeys */
-    subl(3) ^= subl(1); subr(3) ^= subr(1);
-    subl(5) ^= subl(1); subr(5) ^= subr(1);
-    subl(7) ^= subl(1); subr(7) ^= subr(1);
-    subl(1) ^= subr(1) & ~subr(9);
-    dw = subl(1) & subl(9), subr(1) ^= CAMELLIA_RL1(dw);
-    subl(11) ^= subl(1); subr(11) ^= subr(1);
-    subl(13) ^= subl(1); subr(13) ^= subr(1);
-    subl(15) ^= subl(1); subr(15) ^= subr(1);
-    subl(1) ^= subr(1) & ~subr(17);
-    dw = subl(1) & subl(17), subr(1) ^= CAMELLIA_RL1(dw);
-    subl(19) ^= subl(1); subr(19) ^= subr(1);
-    subl(21) ^= subl(1); subr(21) ^= subr(1);
-    subl(23) ^= subl(1); subr(23) ^= subr(1);
-    subl(24) ^= subl(1); subr(24) ^= subr(1);
-
-    /* absorb kw4 to other subkeys */
-    kw4l = subl(25); kw4r = subr(25);
-    subl(22) ^= kw4l; subr(22) ^= kw4r;
-    subl(20) ^= kw4l; subr(20) ^= kw4r;
-    subl(18) ^= kw4l; subr(18) ^= kw4r;
-    kw4l ^= kw4r & ~subr(16);
-    dw = kw4l & subl(16), kw4r ^= CAMELLIA_RL1(dw);
-    subl(14) ^= kw4l; subr(14) ^= kw4r;
-    subl(12) ^= kw4l; subr(12) ^= kw4r;
-    subl(10) ^= kw4l; subr(10) ^= kw4r;
-    kw4l ^= kw4r & ~subr(8);
-    dw = kw4l & subl(8), kw4r ^= CAMELLIA_RL1(dw);
-    subl(6) ^= kw4l; subr(6) ^= kw4r;
-    subl(4) ^= kw4l; subr(4) ^= kw4r;
-    subl(2) ^= kw4l; subr(2) ^= kw4r;
-    subl(0) ^= kw4l; subr(0) ^= kw4r;
-
-    /* key XOR is end of F-function */
-    CamelliaSubkeyL(0) = subl(0) ^ subl(2);
-    CamelliaSubkeyR(0) = subr(0) ^ subr(2);
-    CamelliaSubkeyL(2) = subl(3);
-    CamelliaSubkeyR(2) = subr(3);
-    CamelliaSubkeyL(3) = subl(2) ^ subl(4);
-    CamelliaSubkeyR(3) = subr(2) ^ subr(4);
-    CamelliaSubkeyL(4) = subl(3) ^ subl(5);
-    CamelliaSubkeyR(4) = subr(3) ^ subr(5);
-    CamelliaSubkeyL(5) = subl(4) ^ subl(6);
-    CamelliaSubkeyR(5) = subr(4) ^ subr(6);
-    CamelliaSubkeyL(6) = subl(5) ^ subl(7);
-    CamelliaSubkeyR(6) = subr(5) ^ subr(7);
-    tl = subl(10) ^ (subr(10) & ~subr(8));
-    dw = tl & subl(8), tr = subr(10) ^ CAMELLIA_RL1(dw);
-    CamelliaSubkeyL(7) = subl(6) ^ tl;
-    CamelliaSubkeyR(7) = subr(6) ^ tr;
-    CamelliaSubkeyL(8) = subl(8);
-    CamelliaSubkeyR(8) = subr(8);
-    CamelliaSubkeyL(9) = subl(9);
-    CamelliaSubkeyR(9) = subr(9);
-    tl = subl(7) ^ (subr(7) & ~subr(9));
-    dw = tl & subl(9), tr = subr(7) ^ CAMELLIA_RL1(dw);
-    CamelliaSubkeyL(10) = tl ^ subl(11);
-    CamelliaSubkeyR(10) = tr ^ subr(11);
-    CamelliaSubkeyL(11) = subl(10) ^ subl(12);
-    CamelliaSubkeyR(11) = subr(10) ^ subr(12);
-    CamelliaSubkeyL(12) = subl(11) ^ subl(13);
-    CamelliaSubkeyR(12) = subr(11) ^ subr(13);
-    CamelliaSubkeyL(13) = subl(12) ^ subl(14);
-    CamelliaSubkeyR(13) = subr(12) ^ subr(14);
-    CamelliaSubkeyL(14) = subl(13) ^ subl(15);
-    CamelliaSubkeyR(14) = subr(13) ^ subr(15);
-    tl = subl(18) ^ (subr(18) & ~subr(16));
-    dw = tl & subl(16),	tr = subr(18) ^ CAMELLIA_RL1(dw);
-    CamelliaSubkeyL(15) = subl(14) ^ tl;
-    CamelliaSubkeyR(15) = subr(14) ^ tr;
-    CamelliaSubkeyL(16) = subl(16);
-    CamelliaSubkeyR(16) = subr(16);
-    CamelliaSubkeyL(17) = subl(17);
-    CamelliaSubkeyR(17) = subr(17);
-    tl = subl(15) ^ (subr(15) & ~subr(17));
-    dw = tl & subl(17),	tr = subr(15) ^ CAMELLIA_RL1(dw);
-    CamelliaSubkeyL(18) = tl ^ subl(19);
-    CamelliaSubkeyR(18) = tr ^ subr(19);
-    CamelliaSubkeyL(19) = subl(18) ^ subl(20);
-    CamelliaSubkeyR(19) = subr(18) ^ subr(20);
-    CamelliaSubkeyL(20) = subl(19) ^ subl(21);
-    CamelliaSubkeyR(20) = subr(19) ^ subr(21);
-    CamelliaSubkeyL(21) = subl(20) ^ subl(22);
-    CamelliaSubkeyR(21) = subr(20) ^ subr(22);
-    CamelliaSubkeyL(22) = subl(21) ^ subl(23);
-    CamelliaSubkeyR(22) = subr(21) ^ subr(23);
-    CamelliaSubkeyL(23) = subl(22);
-    CamelliaSubkeyR(23) = subr(22);
-    CamelliaSubkeyL(24) = subl(24) ^ subl(23);
-    CamelliaSubkeyR(24) = subr(24) ^ subr(23);
-
-    /* apply the inverse of the last half of P-function */
-    dw = CamelliaSubkeyL(2) ^ CamelliaSubkeyR(2), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(2) = CamelliaSubkeyL(2) ^ dw, CamelliaSubkeyL(2) = dw;
-    dw = CamelliaSubkeyL(3) ^ CamelliaSubkeyR(3), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(3) = CamelliaSubkeyL(3) ^ dw, CamelliaSubkeyL(3) = dw;
-    dw = CamelliaSubkeyL(4) ^ CamelliaSubkeyR(4), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(4) = CamelliaSubkeyL(4) ^ dw, CamelliaSubkeyL(4) = dw;
-    dw = CamelliaSubkeyL(5) ^ CamelliaSubkeyR(5), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(5) = CamelliaSubkeyL(5) ^ dw, CamelliaSubkeyL(5) = dw;
-    dw = CamelliaSubkeyL(6) ^ CamelliaSubkeyR(6), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(6) = CamelliaSubkeyL(6) ^ dw, CamelliaSubkeyL(6) = dw;
-    dw = CamelliaSubkeyL(7) ^ CamelliaSubkeyR(7), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(7) = CamelliaSubkeyL(7) ^ dw, CamelliaSubkeyL(7) = dw;
-    dw = CamelliaSubkeyL(10) ^ CamelliaSubkeyR(10), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(10) = CamelliaSubkeyL(10) ^ dw, CamelliaSubkeyL(10) = dw;
-    dw = CamelliaSubkeyL(11) ^ CamelliaSubkeyR(11), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(11) = CamelliaSubkeyL(11) ^ dw, CamelliaSubkeyL(11) = dw;
-    dw = CamelliaSubkeyL(12) ^ CamelliaSubkeyR(12), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(12) = CamelliaSubkeyL(12) ^ dw, CamelliaSubkeyL(12) = dw;
-    dw = CamelliaSubkeyL(13) ^ CamelliaSubkeyR(13), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(13) = CamelliaSubkeyL(13) ^ dw, CamelliaSubkeyL(13) = dw;
-    dw = CamelliaSubkeyL(14) ^ CamelliaSubkeyR(14), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(14) = CamelliaSubkeyL(14) ^ dw, CamelliaSubkeyL(14) = dw;
-    dw = CamelliaSubkeyL(15) ^ CamelliaSubkeyR(15), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(15) = CamelliaSubkeyL(15) ^ dw, CamelliaSubkeyL(15) = dw;
-    dw = CamelliaSubkeyL(18) ^ CamelliaSubkeyR(18), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(18) = CamelliaSubkeyL(18) ^ dw, CamelliaSubkeyL(18) = dw;
-    dw = CamelliaSubkeyL(19) ^ CamelliaSubkeyR(19), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(19) = CamelliaSubkeyL(19) ^ dw, CamelliaSubkeyL(19) = dw;
-    dw = CamelliaSubkeyL(20) ^ CamelliaSubkeyR(20), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(20) = CamelliaSubkeyL(20) ^ dw, CamelliaSubkeyL(20) = dw;
-    dw = CamelliaSubkeyL(21) ^ CamelliaSubkeyR(21), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(21) = CamelliaSubkeyL(21) ^ dw, CamelliaSubkeyL(21) = dw;
-    dw = CamelliaSubkeyL(22) ^ CamelliaSubkeyR(22), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(22) = CamelliaSubkeyL(22) ^ dw, CamelliaSubkeyL(22) = dw;
-    dw = CamelliaSubkeyL(23) ^ CamelliaSubkeyR(23), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(23) = CamelliaSubkeyL(23) ^ dw, CamelliaSubkeyL(23) = dw;
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(subL, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(subR, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return 0;
-}
-
-static int camellia_setup256(const unsigned char *key, u32 *subkey)
-{
-    u32 kll,klr,krl,krr;           /* left half of key */
-    u32 krll,krlr,krrl,krrr;       /* right half of key */
-    u32 il, ir, t0, t1, w0, w1;    /* temporary variables */
-    u32 kw4l, kw4r, dw, tl, tr;
-
-#ifdef WOLFSSL_SMALL_STACK
-    u32* subL;
-    u32* subR;
-
-    subL = (u32*) XMALLOC(sizeof(u32) * 34, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (subL == NULL)
-        return MEMORY_E;
-
-    subR = (u32*) XMALLOC(sizeof(u32) * 34, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (subR == NULL) {
-        XFREE(subL, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#else
-    u32 subL[34];
-    u32 subR[34];
-#endif
-
-    /**
-     *  key = (kll || klr || krl || krr || krll || krlr || krrl || krrr)
-     *  (|| is concatination)
-     */
-
-    kll  = GETU32(key     );
-    klr  = GETU32(key +  4);
-    krl  = GETU32(key +  8);
-    krr  = GETU32(key + 12);
-    krll = GETU32(key + 16);
-    krlr = GETU32(key + 20);
-    krrl = GETU32(key + 24);
-    krrr = GETU32(key + 28);
-
-    /* generate KL dependent subkeys */
-    subl(0) = kll; subr(0) = klr;
-    subl(1) = krl; subr(1) = krr;
-    CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 45);
-    subl(12) = kll; subr(12) = klr;
-    subl(13) = krl; subr(13) = krr;
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
-    subl(16) = kll; subr(16) = klr;
-    subl(17) = krl; subr(17) = krr;
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
-    subl(22) = kll; subr(22) = klr;
-    subl(23) = krl; subr(23) = krr;
-    CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 34);
-    subl(30) = kll; subr(30) = klr;
-    subl(31) = krl; subr(31) = krr;
-
-    /* generate KR dependent subkeys */
-    CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 15);
-    subl(4) = krll; subr(4) = krlr;
-    subl(5) = krrl; subr(5) = krrr;
-    CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 15);
-    subl(8) = krll; subr(8) = krlr;
-    subl(9) = krrl; subr(9) = krrr;
-    CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
-    subl(18) = krll; subr(18) = krlr;
-    subl(19) = krrl; subr(19) = krrr;
-    CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 34);
-    subl(26) = krll; subr(26) = krlr;
-    subl(27) = krrl; subr(27) = krrr;
-    CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 34);
-
-    /* generate KA */
-    kll = subl(0) ^ krll; klr = subr(0) ^ krlr;
-    krl = subl(1) ^ krrl; krr = subr(1) ^ krrr;
-    CAMELLIA_F(kll, klr,
-	       CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R,
-	       w0, w1, il, ir, t0, t1);
-    krl ^= w0; krr ^= w1;
-    CAMELLIA_F(krl, krr,
-	       CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R,
-	       kll, klr, il, ir, t0, t1);
-    kll ^= krll; klr ^= krlr;
-    CAMELLIA_F(kll, klr,
-	       CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R,
-	       krl, krr, il, ir, t0, t1);
-    krl ^= w0 ^ krrl; krr ^= w1 ^ krrr;
-    CAMELLIA_F(krl, krr,
-	       CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R,
-	       w0, w1, il, ir, t0, t1);
-    kll ^= w0; klr ^= w1;
-
-    /* generate KB */
-    krll ^= kll; krlr ^= klr;
-    krrl ^= krl; krrr ^= krr;
-    CAMELLIA_F(krll, krlr,
-	       CAMELLIA_SIGMA5L, CAMELLIA_SIGMA5R,
-	       w0, w1, il, ir, t0, t1);
-    krrl ^= w0; krrr ^= w1;
-    CAMELLIA_F(krrl, krrr,
-	       CAMELLIA_SIGMA6L, CAMELLIA_SIGMA6R,
-	       w0, w1, il, ir, t0, t1);
-    krll ^= w0; krlr ^= w1;
-
-    /* generate KA dependent subkeys */
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
-    subl(6) = kll; subr(6) = klr;
-    subl(7) = krl; subr(7) = krr;
-    CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 30);
-    subl(14) = kll; subr(14) = klr;
-    subl(15) = krl; subr(15) = krr;
-    subl(24) = klr; subr(24) = krl;
-    subl(25) = krr; subr(25) = kll;
-    CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 49);
-    subl(28) = kll; subr(28) = klr;
-    subl(29) = krl; subr(29) = krr;
-
-    /* generate KB dependent subkeys */
-    subl(2) = krll; subr(2) = krlr;
-    subl(3) = krrl; subr(3) = krrr;
-    CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
-    subl(10) = krll; subr(10) = krlr;
-    subl(11) = krrl; subr(11) = krrr;
-    CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
-    subl(20) = krll; subr(20) = krlr;
-    subl(21) = krrl; subr(21) = krrr;
-    CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 51);
-    subl(32) = krll; subr(32) = krlr;
-    subl(33) = krrl; subr(33) = krrr;
-
-    /* absorb kw2 to other subkeys */
-    subl(3) ^= subl(1); subr(3) ^= subr(1);
-    subl(5) ^= subl(1); subr(5) ^= subr(1);
-    subl(7) ^= subl(1); subr(7) ^= subr(1);
-    subl(1) ^= subr(1) & ~subr(9);
-    dw = subl(1) & subl(9), subr(1) ^= CAMELLIA_RL1(dw);
-    subl(11) ^= subl(1); subr(11) ^= subr(1);
-    subl(13) ^= subl(1); subr(13) ^= subr(1);
-    subl(15) ^= subl(1); subr(15) ^= subr(1);
-    subl(1) ^= subr(1) & ~subr(17);
-    dw = subl(1) & subl(17), subr(1) ^= CAMELLIA_RL1(dw);
-    subl(19) ^= subl(1); subr(19) ^= subr(1);
-    subl(21) ^= subl(1); subr(21) ^= subr(1);
-    subl(23) ^= subl(1); subr(23) ^= subr(1);
-    subl(1) ^= subr(1) & ~subr(25);
-    dw = subl(1) & subl(25), subr(1) ^= CAMELLIA_RL1(dw);
-    subl(27) ^= subl(1); subr(27) ^= subr(1);
-    subl(29) ^= subl(1); subr(29) ^= subr(1);
-    subl(31) ^= subl(1); subr(31) ^= subr(1);
-    subl(32) ^= subl(1); subr(32) ^= subr(1);
-
-    /* absorb kw4 to other subkeys */
-    kw4l = subl(33); kw4r = subr(33);
-    subl(30) ^= kw4l; subr(30) ^= kw4r;
-    subl(28) ^= kw4l; subr(28) ^= kw4r;
-    subl(26) ^= kw4l; subr(26) ^= kw4r;
-    kw4l ^= kw4r & ~subr(24);
-    dw = kw4l & subl(24), kw4r ^= CAMELLIA_RL1(dw);
-    subl(22) ^= kw4l; subr(22) ^= kw4r;
-    subl(20) ^= kw4l; subr(20) ^= kw4r;
-    subl(18) ^= kw4l; subr(18) ^= kw4r;
-    kw4l ^= kw4r & ~subr(16);
-    dw = kw4l & subl(16), kw4r ^= CAMELLIA_RL1(dw);
-    subl(14) ^= kw4l; subr(14) ^= kw4r;
-    subl(12) ^= kw4l; subr(12) ^= kw4r;
-    subl(10) ^= kw4l; subr(10) ^= kw4r;
-    kw4l ^= kw4r & ~subr(8);
-    dw = kw4l & subl(8), kw4r ^= CAMELLIA_RL1(dw);
-    subl(6) ^= kw4l; subr(6) ^= kw4r;
-    subl(4) ^= kw4l; subr(4) ^= kw4r;
-    subl(2) ^= kw4l; subr(2) ^= kw4r;
-    subl(0) ^= kw4l; subr(0) ^= kw4r;
-
-    /* key XOR is end of F-function */
-    CamelliaSubkeyL(0) = subl(0) ^ subl(2);
-    CamelliaSubkeyR(0) = subr(0) ^ subr(2);
-    CamelliaSubkeyL(2) = subl(3);
-    CamelliaSubkeyR(2) = subr(3);
-    CamelliaSubkeyL(3) = subl(2) ^ subl(4);
-    CamelliaSubkeyR(3) = subr(2) ^ subr(4);
-    CamelliaSubkeyL(4) = subl(3) ^ subl(5);
-    CamelliaSubkeyR(4) = subr(3) ^ subr(5);
-    CamelliaSubkeyL(5) = subl(4) ^ subl(6);
-    CamelliaSubkeyR(5) = subr(4) ^ subr(6);
-    CamelliaSubkeyL(6) = subl(5) ^ subl(7);
-    CamelliaSubkeyR(6) = subr(5) ^ subr(7);
-    tl = subl(10) ^ (subr(10) & ~subr(8));
-    dw = tl & subl(8), tr = subr(10) ^ CAMELLIA_RL1(dw);
-    CamelliaSubkeyL(7) = subl(6) ^ tl;
-    CamelliaSubkeyR(7) = subr(6) ^ tr;
-    CamelliaSubkeyL(8) = subl(8);
-    CamelliaSubkeyR(8) = subr(8);
-    CamelliaSubkeyL(9) = subl(9);
-    CamelliaSubkeyR(9) = subr(9);
-    tl = subl(7) ^ (subr(7) & ~subr(9));
-    dw = tl & subl(9), tr = subr(7) ^ CAMELLIA_RL1(dw);
-    CamelliaSubkeyL(10) = tl ^ subl(11);
-    CamelliaSubkeyR(10) = tr ^ subr(11);
-    CamelliaSubkeyL(11) = subl(10) ^ subl(12);
-    CamelliaSubkeyR(11) = subr(10) ^ subr(12);
-    CamelliaSubkeyL(12) = subl(11) ^ subl(13);
-    CamelliaSubkeyR(12) = subr(11) ^ subr(13);
-    CamelliaSubkeyL(13) = subl(12) ^ subl(14);
-    CamelliaSubkeyR(13) = subr(12) ^ subr(14);
-    CamelliaSubkeyL(14) = subl(13) ^ subl(15);
-    CamelliaSubkeyR(14) = subr(13) ^ subr(15);
-    tl = subl(18) ^ (subr(18) & ~subr(16));
-    dw = tl & subl(16), tr = subr(18) ^ CAMELLIA_RL1(dw);
-    CamelliaSubkeyL(15) = subl(14) ^ tl;
-    CamelliaSubkeyR(15) = subr(14) ^ tr;
-    CamelliaSubkeyL(16) = subl(16);
-    CamelliaSubkeyR(16) = subr(16);
-    CamelliaSubkeyL(17) = subl(17);
-    CamelliaSubkeyR(17) = subr(17);
-    tl = subl(15) ^ (subr(15) & ~subr(17));
-    dw = tl & subl(17), tr = subr(15) ^ CAMELLIA_RL1(dw);
-    CamelliaSubkeyL(18) = tl ^ subl(19);
-    CamelliaSubkeyR(18) = tr ^ subr(19);
-    CamelliaSubkeyL(19) = subl(18) ^ subl(20);
-    CamelliaSubkeyR(19) = subr(18) ^ subr(20);
-    CamelliaSubkeyL(20) = subl(19) ^ subl(21);
-    CamelliaSubkeyR(20) = subr(19) ^ subr(21);
-    CamelliaSubkeyL(21) = subl(20) ^ subl(22);
-    CamelliaSubkeyR(21) = subr(20) ^ subr(22);
-    CamelliaSubkeyL(22) = subl(21) ^ subl(23);
-    CamelliaSubkeyR(22) = subr(21) ^ subr(23);
-    tl = subl(26) ^ (subr(26) & ~subr(24));
-    dw = tl & subl(24), tr = subr(26) ^ CAMELLIA_RL1(dw);
-    CamelliaSubkeyL(23) = subl(22) ^ tl;
-    CamelliaSubkeyR(23) = subr(22) ^ tr;
-    CamelliaSubkeyL(24) = subl(24);
-    CamelliaSubkeyR(24) = subr(24);
-    CamelliaSubkeyL(25) = subl(25);
-    CamelliaSubkeyR(25) = subr(25);
-    tl = subl(23) ^ (subr(23) &  ~subr(25));
-    dw = tl & subl(25), tr = subr(23) ^ CAMELLIA_RL1(dw);
-    CamelliaSubkeyL(26) = tl ^ subl(27);
-    CamelliaSubkeyR(26) = tr ^ subr(27);
-    CamelliaSubkeyL(27) = subl(26) ^ subl(28);
-    CamelliaSubkeyR(27) = subr(26) ^ subr(28);
-    CamelliaSubkeyL(28) = subl(27) ^ subl(29);
-    CamelliaSubkeyR(28) = subr(27) ^ subr(29);
-    CamelliaSubkeyL(29) = subl(28) ^ subl(30);
-    CamelliaSubkeyR(29) = subr(28) ^ subr(30);
-    CamelliaSubkeyL(30) = subl(29) ^ subl(31);
-    CamelliaSubkeyR(30) = subr(29) ^ subr(31);
-    CamelliaSubkeyL(31) = subl(30);
-    CamelliaSubkeyR(31) = subr(30);
-    CamelliaSubkeyL(32) = subl(32) ^ subl(31);
-    CamelliaSubkeyR(32) = subr(32) ^ subr(31);
-
-    /* apply the inverse of the last half of P-function */
-    dw = CamelliaSubkeyL(2) ^ CamelliaSubkeyR(2), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(2) = CamelliaSubkeyL(2) ^ dw, CamelliaSubkeyL(2) = dw;
-    dw = CamelliaSubkeyL(3) ^ CamelliaSubkeyR(3), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(3) = CamelliaSubkeyL(3) ^ dw, CamelliaSubkeyL(3) = dw;
-    dw = CamelliaSubkeyL(4) ^ CamelliaSubkeyR(4), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(4) = CamelliaSubkeyL(4) ^ dw, CamelliaSubkeyL(4) = dw;
-    dw = CamelliaSubkeyL(5) ^ CamelliaSubkeyR(5), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(5) = CamelliaSubkeyL(5) ^ dw, CamelliaSubkeyL(5) = dw;
-    dw = CamelliaSubkeyL(6) ^ CamelliaSubkeyR(6), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(6) = CamelliaSubkeyL(6) ^ dw, CamelliaSubkeyL(6) = dw;
-    dw = CamelliaSubkeyL(7) ^ CamelliaSubkeyR(7), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(7) = CamelliaSubkeyL(7) ^ dw, CamelliaSubkeyL(7) = dw;
-    dw = CamelliaSubkeyL(10) ^ CamelliaSubkeyR(10), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(10) = CamelliaSubkeyL(10) ^ dw, CamelliaSubkeyL(10) = dw;
-    dw = CamelliaSubkeyL(11) ^ CamelliaSubkeyR(11), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(11) = CamelliaSubkeyL(11) ^ dw, CamelliaSubkeyL(11) = dw;
-    dw = CamelliaSubkeyL(12) ^ CamelliaSubkeyR(12), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(12) = CamelliaSubkeyL(12) ^ dw, CamelliaSubkeyL(12) = dw;
-    dw = CamelliaSubkeyL(13) ^ CamelliaSubkeyR(13), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(13) = CamelliaSubkeyL(13) ^ dw, CamelliaSubkeyL(13) = dw;
-    dw = CamelliaSubkeyL(14) ^ CamelliaSubkeyR(14), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(14) = CamelliaSubkeyL(14) ^ dw, CamelliaSubkeyL(14) = dw;
-    dw = CamelliaSubkeyL(15) ^ CamelliaSubkeyR(15), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(15) = CamelliaSubkeyL(15) ^ dw, CamelliaSubkeyL(15) = dw;
-    dw = CamelliaSubkeyL(18) ^ CamelliaSubkeyR(18), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(18) = CamelliaSubkeyL(18) ^ dw, CamelliaSubkeyL(18) = dw;
-    dw = CamelliaSubkeyL(19) ^ CamelliaSubkeyR(19), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(19) = CamelliaSubkeyL(19) ^ dw, CamelliaSubkeyL(19) = dw;
-    dw = CamelliaSubkeyL(20) ^ CamelliaSubkeyR(20), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(20) = CamelliaSubkeyL(20) ^ dw, CamelliaSubkeyL(20) = dw;
-    dw = CamelliaSubkeyL(21) ^ CamelliaSubkeyR(21), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(21) = CamelliaSubkeyL(21) ^ dw, CamelliaSubkeyL(21) = dw;
-    dw = CamelliaSubkeyL(22) ^ CamelliaSubkeyR(22), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(22) = CamelliaSubkeyL(22) ^ dw, CamelliaSubkeyL(22) = dw;
-    dw = CamelliaSubkeyL(23) ^ CamelliaSubkeyR(23), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(23) = CamelliaSubkeyL(23) ^ dw, CamelliaSubkeyL(23) = dw;
-    dw = CamelliaSubkeyL(26) ^ CamelliaSubkeyR(26), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(26) = CamelliaSubkeyL(26) ^ dw, CamelliaSubkeyL(26) = dw;
-    dw = CamelliaSubkeyL(27) ^ CamelliaSubkeyR(27), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(27) = CamelliaSubkeyL(27) ^ dw, CamelliaSubkeyL(27) = dw;
-    dw = CamelliaSubkeyL(28) ^ CamelliaSubkeyR(28), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(28) = CamelliaSubkeyL(28) ^ dw, CamelliaSubkeyL(28) = dw;
-    dw = CamelliaSubkeyL(29) ^ CamelliaSubkeyR(29), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(29) = CamelliaSubkeyL(29) ^ dw, CamelliaSubkeyL(29) = dw;
-    dw = CamelliaSubkeyL(30) ^ CamelliaSubkeyR(30), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(30) = CamelliaSubkeyL(30) ^ dw, CamelliaSubkeyL(30) = dw;
-    dw = CamelliaSubkeyL(31) ^ CamelliaSubkeyR(31), dw = CAMELLIA_RL8(dw);
-    CamelliaSubkeyR(31) = CamelliaSubkeyL(31) ^ dw,CamelliaSubkeyL(31) = dw;
-    
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(subL, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(subR, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return 0;
-}
-
-static int camellia_setup192(const unsigned char *key, u32 *subkey)
-{
-    unsigned char kk[32];
-    u32 krll, krlr, krrl,krrr;
-
-    memcpy(kk, key, 24);
-    memcpy((unsigned char *)&krll, key+16,4);
-    memcpy((unsigned char *)&krlr, key+20,4);
-    krrl = ~krll;
-    krrr = ~krlr;
-    memcpy(kk+24, (unsigned char *)&krrl, 4);
-    memcpy(kk+28, (unsigned char *)&krrr, 4);
-
-    return camellia_setup256(kk, subkey);
-}
-
-
-/**
- * Stuff related to camellia encryption/decryption
- *
- * "io" must be 4byte aligned and big-endian data.
- */
-static void camellia_encrypt128(const u32 *subkey, u32 *io)
-{
-    u32 il, ir, t0, t1;
-
-    /* pre whitening but absorb kw2*/
-    io[0] ^= CamelliaSubkeyL(0);
-    io[1] ^= CamelliaSubkeyR(0);
-    /* main iteration */
-
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(2),CamelliaSubkeyR(2),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(3),CamelliaSubkeyR(3),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(4),CamelliaSubkeyR(4),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(5),CamelliaSubkeyR(5),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(6),CamelliaSubkeyR(6),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(7),CamelliaSubkeyR(7),
-		     io[0],io[1],il,ir,t0,t1);
-
-    CAMELLIA_FLS(io[0],io[1],io[2],io[3],
-		 CamelliaSubkeyL(8),CamelliaSubkeyR(8),
-		 CamelliaSubkeyL(9),CamelliaSubkeyR(9),
-		 t0,t1,il,ir);
-
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(10),CamelliaSubkeyR(10),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(11),CamelliaSubkeyR(11),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(12),CamelliaSubkeyR(12),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(13),CamelliaSubkeyR(13),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(14),CamelliaSubkeyR(14),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(15),CamelliaSubkeyR(15),
-		     io[0],io[1],il,ir,t0,t1);
-
-    CAMELLIA_FLS(io[0],io[1],io[2],io[3],
-		 CamelliaSubkeyL(16),CamelliaSubkeyR(16),
-		 CamelliaSubkeyL(17),CamelliaSubkeyR(17),
-		 t0,t1,il,ir);
-
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(18),CamelliaSubkeyR(18),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(19),CamelliaSubkeyR(19),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(20),CamelliaSubkeyR(20),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(21),CamelliaSubkeyR(21),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(22),CamelliaSubkeyR(22),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(23),CamelliaSubkeyR(23),
-		     io[0],io[1],il,ir,t0,t1);
-
-    /* post whitening but kw4 */
-    io[2] ^= CamelliaSubkeyL(24);
-    io[3] ^= CamelliaSubkeyR(24);
-
-    t0 = io[0];
-    t1 = io[1];
-    io[0] = io[2];
-    io[1] = io[3];
-    io[2] = t0;
-    io[3] = t1;
-	
-    return;
-}
-
-static void camellia_decrypt128(const u32 *subkey, u32 *io)
-{
-    u32 il,ir,t0,t1;               /* temporary valiables */
-    
-    /* pre whitening but absorb kw2*/
-    io[0] ^= CamelliaSubkeyL(24);
-    io[1] ^= CamelliaSubkeyR(24);
-
-    /* main iteration */
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(23),CamelliaSubkeyR(23),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(22),CamelliaSubkeyR(22),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(21),CamelliaSubkeyR(21),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(20),CamelliaSubkeyR(20),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(19),CamelliaSubkeyR(19),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(18),CamelliaSubkeyR(18),
-		     io[0],io[1],il,ir,t0,t1);
-
-    CAMELLIA_FLS(io[0],io[1],io[2],io[3],
-		 CamelliaSubkeyL(17),CamelliaSubkeyR(17),
-		 CamelliaSubkeyL(16),CamelliaSubkeyR(16),
-		 t0,t1,il,ir);
-
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(15),CamelliaSubkeyR(15),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(14),CamelliaSubkeyR(14),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(13),CamelliaSubkeyR(13),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(12),CamelliaSubkeyR(12),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(11),CamelliaSubkeyR(11),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(10),CamelliaSubkeyR(10),
-		     io[0],io[1],il,ir,t0,t1);
-
-    CAMELLIA_FLS(io[0],io[1],io[2],io[3],
-		 CamelliaSubkeyL(9),CamelliaSubkeyR(9),
-		 CamelliaSubkeyL(8),CamelliaSubkeyR(8),
-		 t0,t1,il,ir);
-
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(7),CamelliaSubkeyR(7),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(6),CamelliaSubkeyR(6),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(5),CamelliaSubkeyR(5),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(4),CamelliaSubkeyR(4),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(3),CamelliaSubkeyR(3),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(2),CamelliaSubkeyR(2),
-		     io[0],io[1],il,ir,t0,t1);
-
-    /* post whitening but kw4 */
-    io[2] ^= CamelliaSubkeyL(0);
-    io[3] ^= CamelliaSubkeyR(0);
-
-    t0 = io[0];
-    t1 = io[1];
-    io[0] = io[2];
-    io[1] = io[3];
-    io[2] = t0;
-    io[3] = t1;
-
-    return;
-}
-
-/**
- * stuff for 192 and 256bit encryption/decryption
- */
-static void camellia_encrypt256(const u32 *subkey, u32 *io)
-{
-    u32 il,ir,t0,t1;           /* temporary valiables */
-
-    /* pre whitening but absorb kw2*/
-    io[0] ^= CamelliaSubkeyL(0);
-    io[1] ^= CamelliaSubkeyR(0);
-
-    /* main iteration */
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(2),CamelliaSubkeyR(2),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(3),CamelliaSubkeyR(3),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(4),CamelliaSubkeyR(4),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(5),CamelliaSubkeyR(5),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(6),CamelliaSubkeyR(6),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(7),CamelliaSubkeyR(7),
-		     io[0],io[1],il,ir,t0,t1);
-
-    CAMELLIA_FLS(io[0],io[1],io[2],io[3],
-		 CamelliaSubkeyL(8),CamelliaSubkeyR(8),
-		 CamelliaSubkeyL(9),CamelliaSubkeyR(9),
-		 t0,t1,il,ir);
-
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(10),CamelliaSubkeyR(10),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(11),CamelliaSubkeyR(11),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(12),CamelliaSubkeyR(12),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(13),CamelliaSubkeyR(13),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(14),CamelliaSubkeyR(14),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(15),CamelliaSubkeyR(15),
-		     io[0],io[1],il,ir,t0,t1);
-
-    CAMELLIA_FLS(io[0],io[1],io[2],io[3],
-		 CamelliaSubkeyL(16),CamelliaSubkeyR(16),
-		 CamelliaSubkeyL(17),CamelliaSubkeyR(17),
-		 t0,t1,il,ir);
-
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(18),CamelliaSubkeyR(18),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(19),CamelliaSubkeyR(19),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(20),CamelliaSubkeyR(20),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(21),CamelliaSubkeyR(21),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(22),CamelliaSubkeyR(22),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(23),CamelliaSubkeyR(23),
-		     io[0],io[1],il,ir,t0,t1);
-
-    CAMELLIA_FLS(io[0],io[1],io[2],io[3],
-		 CamelliaSubkeyL(24),CamelliaSubkeyR(24),
-		 CamelliaSubkeyL(25),CamelliaSubkeyR(25),
-		 t0,t1,il,ir);
-
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(26),CamelliaSubkeyR(26),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(27),CamelliaSubkeyR(27),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(28),CamelliaSubkeyR(28),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(29),CamelliaSubkeyR(29),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(30),CamelliaSubkeyR(30),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(31),CamelliaSubkeyR(31),
-		     io[0],io[1],il,ir,t0,t1);
-
-    /* post whitening but kw4 */
-    io[2] ^= CamelliaSubkeyL(32);
-    io[3] ^= CamelliaSubkeyR(32);
-
-    t0 = io[0];
-    t1 = io[1];
-    io[0] = io[2];
-    io[1] = io[3];
-    io[2] = t0;
-    io[3] = t1;
-
-    return;
-}
-
-static void camellia_decrypt256(const u32 *subkey, u32 *io)
-{
-    u32 il,ir,t0,t1;           /* temporary valiables */
-
-    /* pre whitening but absorb kw2*/
-    io[0] ^= CamelliaSubkeyL(32);
-    io[1] ^= CamelliaSubkeyR(32);
-	
-    /* main iteration */
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(31),CamelliaSubkeyR(31),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(30),CamelliaSubkeyR(30),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(29),CamelliaSubkeyR(29),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(28),CamelliaSubkeyR(28),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(27),CamelliaSubkeyR(27),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(26),CamelliaSubkeyR(26),
-		     io[0],io[1],il,ir,t0,t1);
-
-    CAMELLIA_FLS(io[0],io[1],io[2],io[3],
-		 CamelliaSubkeyL(25),CamelliaSubkeyR(25),
-		 CamelliaSubkeyL(24),CamelliaSubkeyR(24),
-		 t0,t1,il,ir);
-
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(23),CamelliaSubkeyR(23),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(22),CamelliaSubkeyR(22),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(21),CamelliaSubkeyR(21),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(20),CamelliaSubkeyR(20),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(19),CamelliaSubkeyR(19),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(18),CamelliaSubkeyR(18),
-		     io[0],io[1],il,ir,t0,t1);
-
-    CAMELLIA_FLS(io[0],io[1],io[2],io[3],
-		 CamelliaSubkeyL(17),CamelliaSubkeyR(17),
-		 CamelliaSubkeyL(16),CamelliaSubkeyR(16),
-		 t0,t1,il,ir);
-
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(15),CamelliaSubkeyR(15),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(14),CamelliaSubkeyR(14),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(13),CamelliaSubkeyR(13),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(12),CamelliaSubkeyR(12),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(11),CamelliaSubkeyR(11),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(10),CamelliaSubkeyR(10),
-		     io[0],io[1],il,ir,t0,t1);
-
-    CAMELLIA_FLS(io[0],io[1],io[2],io[3],
-		 CamelliaSubkeyL(9),CamelliaSubkeyR(9),
-		 CamelliaSubkeyL(8),CamelliaSubkeyR(8),
-		 t0,t1,il,ir);
-
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(7),CamelliaSubkeyR(7),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(6),CamelliaSubkeyR(6),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(5),CamelliaSubkeyR(5),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(4),CamelliaSubkeyR(4),
-		     io[0],io[1],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[0],io[1],
-		     CamelliaSubkeyL(3),CamelliaSubkeyR(3),
-		     io[2],io[3],il,ir,t0,t1);
-    CAMELLIA_ROUNDSM(io[2],io[3],
-		     CamelliaSubkeyL(2),CamelliaSubkeyR(2),
-		     io[0],io[1],il,ir,t0,t1);
-
-    /* post whitening but kw4 */
-    io[2] ^= CamelliaSubkeyL(0);
-    io[3] ^= CamelliaSubkeyR(0);
-
-    t0 = io[0];
-    t1 = io[1];
-    io[0] = io[2];
-    io[1] = io[3];
-    io[2] = t0;
-    io[3] = t1;
-
-    return;
-}
-
-/***
- *
- * API for compatibility
- */
-
-static void Camellia_EncryptBlock(const int keyBitLength, 
-			   const unsigned char *plaintext, 
-			   const KEY_TABLE_TYPE keyTable, 
-			   unsigned char *ciphertext)
-{
-    u32 tmp[4];
-
-    tmp[0] = GETU32(plaintext);
-    tmp[1] = GETU32(plaintext + 4);
-    tmp[2] = GETU32(plaintext + 8);
-    tmp[3] = GETU32(plaintext + 12);
-
-    switch (keyBitLength) {
-    case 128:
-	camellia_encrypt128(keyTable, tmp);
-	break;
-    case 192:
-	/* fall through */
-    case 256:
-	camellia_encrypt256(keyTable, tmp);
-	break;
-    default:
-	break;
-    }
-
-    PUTU32(ciphertext, tmp[0]);
-    PUTU32(ciphertext + 4, tmp[1]);
-    PUTU32(ciphertext + 8, tmp[2]);
-    PUTU32(ciphertext + 12, tmp[3]);
-}
-
-static void Camellia_DecryptBlock(const int keyBitLength, 
-			   const unsigned char *ciphertext, 
-			   const KEY_TABLE_TYPE keyTable, 
-			   unsigned char *plaintext)
-{
-    u32 tmp[4];
-
-    tmp[0] = GETU32(ciphertext);
-    tmp[1] = GETU32(ciphertext + 4);
-    tmp[2] = GETU32(ciphertext + 8);
-    tmp[3] = GETU32(ciphertext + 12);
-
-    switch (keyBitLength) {
-    case 128:
-	camellia_decrypt128(keyTable, tmp);
-	break;
-    case 192:
-	/* fall through */
-    case 256:
-	camellia_decrypt256(keyTable, tmp);
-	break;
-    default:
-	break;
-    }
-    PUTU32(plaintext, tmp[0]);
-    PUTU32(plaintext + 4, tmp[1]);
-    PUTU32(plaintext + 8, tmp[2]);
-    PUTU32(plaintext + 12, tmp[3]);
-}
-
-
-
-/* wolfCrypt wrappers to the Camellia code */
-
-int wc_CamelliaSetKey(Camellia* cam, const byte* key, word32 len, const byte* iv)
-{
-    int ret = 0;
-
-    if (cam == NULL) return BAD_FUNC_ARG;
-
-    XMEMSET(cam->key, 0, sizeof(KEY_TABLE_TYPE));
-
-    switch (len) {
-        case 16:
-        	ret = camellia_setup128(key, cam->key);
-            break;
-        case 24:
-        	ret = camellia_setup192(key, cam->key);
-            break;
-        case 32:
-            ret = camellia_setup256(key, cam->key);
-            break;
-        default:
-            return BAD_FUNC_ARG;
-    }
-
-    if (ret != 0)
-        return ret;
-
-    cam->keySz = len * 8;
-
-    return wc_CamelliaSetIV(cam, iv);
-}
-
-
-int wc_CamelliaSetIV(Camellia* cam, const byte* iv)
-{
-    if (cam == NULL)
-        return BAD_FUNC_ARG;
-
-    if (iv)
-        XMEMCPY(cam->reg, iv, CAMELLIA_BLOCK_SIZE);
-    else
-        XMEMSET(cam->reg,  0, CAMELLIA_BLOCK_SIZE);
-
-    return 0;
-}
-
-
-void wc_CamelliaEncryptDirect(Camellia* cam, byte* out, const byte* in)
-{
-    Camellia_EncryptBlock(cam->keySz, in, cam->key, out);
-}
-
-
-void wc_CamelliaDecryptDirect(Camellia* cam, byte* out, const byte* in)
-{
-    Camellia_DecryptBlock(cam->keySz, in, cam->key, out);
-}
-
-
-void wc_CamelliaCbcEncrypt(Camellia* cam, byte* out, const byte* in, word32 sz)
-{
-    word32 blocks = sz / CAMELLIA_BLOCK_SIZE;
-
-    while (blocks--) {
-        xorbuf((byte*)cam->reg, in, CAMELLIA_BLOCK_SIZE);
-        Camellia_EncryptBlock(cam->keySz, (byte*)cam->reg,
-                                                     cam->key, (byte*)cam->reg);
-        XMEMCPY(out, cam->reg, CAMELLIA_BLOCK_SIZE);
-
-        out += CAMELLIA_BLOCK_SIZE;
-        in  += CAMELLIA_BLOCK_SIZE;
-    }
-}
-
-
-void wc_CamelliaCbcDecrypt(Camellia* cam, byte* out, const byte* in, word32 sz)
-{
-    word32 blocks = sz / CAMELLIA_BLOCK_SIZE;
-
-    while (blocks--) {
-        XMEMCPY(cam->tmp, in, CAMELLIA_BLOCK_SIZE);
-        Camellia_DecryptBlock(cam->keySz, (byte*)cam->tmp, cam->key, out);
-        xorbuf(out, (byte*)cam->reg, CAMELLIA_BLOCK_SIZE);
-        XMEMCPY(cam->reg, cam->tmp, CAMELLIA_BLOCK_SIZE);
-
-        out += CAMELLIA_BLOCK_SIZE;
-        in  += CAMELLIA_BLOCK_SIZE;
-    }
-}
-
-
-#endif /* HAVE_CAMELLIA */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/chacha.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/chacha.c
deleted file mode 100755
index 4e95bdb..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/chacha.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/* chacha.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- *
- *  based from
- *  chacha-ref.c version 20080118
- *  D. J. Bernstein
- *  Public domain.
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef HAVE_CHACHA
-
-#include 
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-#ifdef CHACHA_AEAD_TEST
-    #include 
-#endif
-
-#ifdef BIG_ENDIAN_ORDER
-    #define LITTLE32(x) ByteReverseWord32(x)
-#else
-    #define LITTLE32(x) (x)
-#endif
-
-/* Number of rounds */
-#define ROUNDS  20
-
-#define U32C(v) (v##U)
-#define U32V(v) ((word32)(v) & U32C(0xFFFFFFFF))
-#define U8TO32_LITTLE(p) LITTLE32(((word32*)(p))[0])
-
-#define ROTATE(v,c) rotlFixed(v, c)
-#define XOR(v,w)    ((v) ^ (w))
-#define PLUS(v,w)   (U32V((v) + (w)))
-#define PLUSONE(v)  (PLUS((v),1))
-
-#define QUARTERROUND(a,b,c,d) \
-  x[a] = PLUS(x[a],x[b]); x[d] = ROTATE(XOR(x[d],x[a]),16); \
-  x[c] = PLUS(x[c],x[d]); x[b] = ROTATE(XOR(x[b],x[c]),12); \
-  x[a] = PLUS(x[a],x[b]); x[d] = ROTATE(XOR(x[d],x[a]), 8); \
-  x[c] = PLUS(x[c],x[d]); x[b] = ROTATE(XOR(x[b],x[c]), 7);
-
-
-/**
-  * Set up iv(nonce). Earlier versions used 64 bits instead of 96, this version
-  * uses the typical AEAD 96 bit nonce and can do record sizes of 256 GB.
-  */
-int wc_Chacha_SetIV(ChaCha* ctx, const byte* inIv, word32 counter)
-{
-    word32 temp[3];       /* used for alignment of memory */
-
-#ifdef CHACHA_AEAD_TEST
-    word32 i;
-    printf("NONCE : ");
-    for (i = 0; i < 12; i++) {
-        printf("%02x", inIv[i]);
-    }
-    printf("\n\n");
-#endif
-
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-    XMEMCPY(temp, inIv, 12);
-
-    ctx->X[12] = LITTLE32(counter); /* block counter */
-    ctx->X[13] = LITTLE32(temp[0]); /* fixed variable from nonce */
-    ctx->X[14] = LITTLE32(temp[1]); /* counter from nonce */
-    ctx->X[15] = LITTLE32(temp[2]); /* counter from nonce */
-
-    return 0;
-}
-
-/* "expand 32-byte k" as unsigned 32 byte */
-static const word32 sigma[4] = {0x61707865, 0x3320646e, 0x79622d32, 0x6b206574};
-/* "expand 16-byte k" as unsigned 16 byte */
-static const word32 tau[4] = {0x61707865, 0x3120646e, 0x79622d36, 0x6b206574};
-
-/**
-  * Key setup. 8 word iv (nonce)
-  */
-int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz)
-{
-    const word32* constants;
-    const byte*   k;
-
-#ifdef XSTREAM_ALIGN
-    word32 alignKey[8];
-#endif
-
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-    if (keySz != 16 && keySz != 32)
-        return BAD_FUNC_ARG;
-
-#ifdef XSTREAM_ALIGN
-    if ((wolfssl_word)key % 4) {
-        WOLFSSL_MSG("wc_ChachaSetKey unaligned key");
-        XMEMCPY(alignKey, key, keySz);
-        k = (byte*)alignKey;
-    }
-    else {
-        k = key;
-    }
-#else
-    k = key;
-#endif /* XSTREAM_ALIGN */
-
-#ifdef CHACHA_AEAD_TEST
-    word32 i;
-    printf("ChaCha key used :\n");
-    for (i = 0; i < keySz; i++) {
-        printf("%02x", key[i]);
-        if ((i + 1) % 8 == 0)
-           printf("\n");
-    }
-    printf("\n\n");
-#endif
-
-    ctx->X[4] = U8TO32_LITTLE(k +  0);
-    ctx->X[5] = U8TO32_LITTLE(k +  4);
-    ctx->X[6] = U8TO32_LITTLE(k +  8);
-    ctx->X[7] = U8TO32_LITTLE(k + 12);
-    if (keySz == 32) {
-        k += 16;
-        constants = sigma;
-    }
-    else {
-        constants = tau;
-    }
-    ctx->X[ 8] = U8TO32_LITTLE(k +  0);
-    ctx->X[ 9] = U8TO32_LITTLE(k +  4);
-    ctx->X[10] = U8TO32_LITTLE(k +  8);
-    ctx->X[11] = U8TO32_LITTLE(k + 12);
-    ctx->X[ 0] = constants[0];
-    ctx->X[ 1] = constants[1];
-    ctx->X[ 2] = constants[2];
-    ctx->X[ 3] = constants[3];
-
-    return 0;
-}
-
-/**
-  * Converts word into bytes with rotations having been done.
-  */
-static INLINE void wc_Chacha_wordtobyte(word32 output[16], const word32 input[16])
-{
-    word32 x[16];
-    word32 i;
-
-    for (i = 0; i < 16; i++) {
-        x[i] = input[i];
-    }
-
-    for (i = (ROUNDS); i > 0; i -= 2) {
-        QUARTERROUND(0, 4,  8, 12)
-        QUARTERROUND(1, 5,  9, 13)
-        QUARTERROUND(2, 6, 10, 14)
-        QUARTERROUND(3, 7, 11, 15)
-        QUARTERROUND(0, 5, 10, 15)
-        QUARTERROUND(1, 6, 11, 12)
-        QUARTERROUND(2, 7,  8, 13)
-        QUARTERROUND(3, 4,  9, 14)
-    }
-
-    for (i = 0; i < 16; i++) {
-        x[i] = PLUS(x[i], input[i]);
-    }
-
-    for (i = 0; i < 16; i++) {
-        output[i] = LITTLE32(x[i]);
-    }
-}
-
-/**
-  * Encrypt a stream of bytes
-  */
-static void wc_Chacha_encrypt_bytes(ChaCha* ctx, const byte* m, byte* c,
-                                 word32 bytes)
-{
-    byte*  output;
-    word32 temp[16]; /* used to make sure aligned */
-    word32 i;
-
-    output = (byte*)temp;
-
-    if (!bytes) return;
-    for (;;) {
-        wc_Chacha_wordtobyte(temp, ctx->X);
-        ctx->X[12] = PLUSONE(ctx->X[12]);
-        if (bytes <= 64) {
-            for (i = 0; i < bytes; ++i) {
-                c[i] = m[i] ^ output[i];
-            }
-            return;
-        }
-        for (i = 0; i < 64; ++i) {
-            c[i] = m[i] ^ output[i];
-        }
-        bytes -= 64;
-        c += 64;
-        m += 64;
-    }
-}
-
-/**
-  * API to encrypt/decrypt a message of any size.
-  */
-int wc_Chacha_Process(ChaCha* ctx, byte* output, const byte* input, word32 msglen)
-{
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-    wc_Chacha_encrypt_bytes(ctx, input, output, msglen);
-
-    return 0;
-}
-
-#endif /* HAVE_CHACHA*/
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/chacha20_poly1305.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/chacha20_poly1305.c
deleted file mode 100755
index 4a2b1be..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/chacha20_poly1305.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/* chacha.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#ifdef NO_INLINE
-#include 
-#else
-#include 
-#endif
-
-#ifdef CHACHA_AEAD_TEST
-#include 
-#endif
-
-#define CHACHA20_POLY1305_AEAD_INITIAL_COUNTER  0
-#define CHACHA20_POLY1305_MAC_PADDING_ALIGNMENT 16
-
-static void word32ToLittle64(const word32 inLittle32, byte outLittle64[8]);
-static int calculateAuthTag(
-                  const byte inAuthKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
-                  const byte* inAAD, const word32 inAADLen,
-                  const byte *inCiphertext, const word32 inCiphertextLen,
-                  byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE]);
-
-int wc_ChaCha20Poly1305_Encrypt(
-                const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
-                const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
-                const byte* inAAD, const word32 inAADLen,
-                const byte* inPlaintext, const word32 inPlaintextLen,
-                byte* outCiphertext,
-                byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE])
-{
-    int err;
-    byte poly1305Key[CHACHA20_POLY1305_AEAD_KEYSIZE];
-    ChaCha chaChaCtx;
-
-    /* Validate function arguments */
-
-    if (!inKey || !inIV ||
-        !inPlaintext || !inPlaintextLen ||
-        !outCiphertext ||
-        !outAuthTag)
-    {
-        return BAD_FUNC_ARG;
-    }
-
-    XMEMSET(poly1305Key, 0, sizeof(poly1305Key));
-
-    /* Create the Poly1305 key */
-    err = wc_Chacha_SetKey(&chaChaCtx, inKey, CHACHA20_POLY1305_AEAD_KEYSIZE);
-    if (err != 0) return err;
-
-    err = wc_Chacha_SetIV(&chaChaCtx, inIV,
-                           CHACHA20_POLY1305_AEAD_INITIAL_COUNTER);
-    if (err != 0) return err;
-
-    err = wc_Chacha_Process(&chaChaCtx, poly1305Key, poly1305Key,
-                             CHACHA20_POLY1305_AEAD_KEYSIZE);
-    if (err != 0) return err;
-
-    /* Encrypt the plaintext using ChaCha20 */
-    err = wc_Chacha_Process(&chaChaCtx, outCiphertext, inPlaintext,
-                            inPlaintextLen);
-    /* Calculate the Poly1305 auth tag */
-    if (err == 0)
-        err = calculateAuthTag(poly1305Key,
-                               inAAD, inAADLen,
-                               outCiphertext, inPlaintextLen,
-                               outAuthTag);
-    ForceZero(poly1305Key, sizeof(poly1305Key));
-
-    return err;
-}
-
-
-int wc_ChaCha20Poly1305_Decrypt(
-                const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
-                const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
-                const byte* inAAD, const word32 inAADLen,
-                const byte* inCiphertext, const word32 inCiphertextLen,
-                const byte inAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE],
-                byte* outPlaintext)
-{
-    int err;
-    byte poly1305Key[CHACHA20_POLY1305_AEAD_KEYSIZE];
-    ChaCha chaChaCtx;
-    byte calculatedAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE];
-
-    /* Validate function arguments */
-
-    if (!inKey || !inIV ||
-        !inCiphertext || !inCiphertextLen ||
-        !inAuthTag ||
-        !outPlaintext)
-    {
-        return BAD_FUNC_ARG;
-    }
-
-    XMEMSET(calculatedAuthTag, 0, sizeof(calculatedAuthTag));
-    XMEMSET(poly1305Key, 0, sizeof(poly1305Key));
-
-    /* Create the Poly1305 key */
-    err = wc_Chacha_SetKey(&chaChaCtx, inKey, CHACHA20_POLY1305_AEAD_KEYSIZE);
-    if (err != 0) return err;
-
-    err = wc_Chacha_SetIV(&chaChaCtx, inIV,
-                           CHACHA20_POLY1305_AEAD_INITIAL_COUNTER);
-    if (err != 0) return err;
-
-    err = wc_Chacha_Process(&chaChaCtx, poly1305Key, poly1305Key,
-                             CHACHA20_POLY1305_AEAD_KEYSIZE);
-    if (err != 0) return err;
-
-    /* Calculate the Poly1305 auth tag */
-    err = calculateAuthTag(poly1305Key,
-                           inAAD, inAADLen,
-                           inCiphertext, inCiphertextLen,
-                           calculatedAuthTag);
-
-    /* Compare the calculated auth tag with the received one */
-    if (err == 0 && ConstantCompare(inAuthTag, calculatedAuthTag,
-                                    CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE) != 0)
-    {
-        err = MAC_CMP_FAILED_E;
-    }
-
-    /* Decrypt the received ciphertext */
-    if (err == 0)
-        err = wc_Chacha_Process(&chaChaCtx, outPlaintext, inCiphertext,
-                                inCiphertextLen);
-    ForceZero(poly1305Key, sizeof(poly1305Key));
-
-    return err;
-}
-
-
-static int calculateAuthTag(
-                const byte inAuthKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
-                const byte *inAAD, const word32 inAADLen,
-                const byte *inCiphertext, const word32 inCiphertextLen,
-                 byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE])
-{
-    int err;
-    Poly1305 poly1305Ctx;
-    byte padding[CHACHA20_POLY1305_MAC_PADDING_ALIGNMENT - 1];
-    word32 paddingLen;
-    byte little64[8];
-
-    XMEMSET(padding, 0, sizeof(padding));
-
-    /* Initialize Poly1305 */
-
-    err = wc_Poly1305SetKey(&poly1305Ctx, inAuthKey,
-                            CHACHA20_POLY1305_AEAD_KEYSIZE);
-    if (err)
-    {
-        return err;
-    }
-
-    /* Create the authTag by MAC'ing the following items: */
-
-    /* -- AAD */
-
-    if (inAAD && inAADLen)
-    {
-        err = wc_Poly1305Update(&poly1305Ctx, inAAD, inAADLen);
-
-        /* -- padding1: pad the AAD to 16 bytes */
-
-        paddingLen = -inAADLen & (CHACHA20_POLY1305_MAC_PADDING_ALIGNMENT - 1);
-        if (paddingLen)
-        {
-            err += wc_Poly1305Update(&poly1305Ctx, padding, paddingLen);
-        }
-
-        if (err)
-        {
-            return err;
-        }
-    }
-
-    /* -- Ciphertext */
-
-    err = wc_Poly1305Update(&poly1305Ctx, inCiphertext, inCiphertextLen);
-    if (err)
-    {
-        return err;
-    }
-
-    /* -- padding2: pad the ciphertext to 16 bytes */
-
-    paddingLen = -inCiphertextLen &
-                                  (CHACHA20_POLY1305_MAC_PADDING_ALIGNMENT - 1);
-    if (paddingLen)
-    {
-        err = wc_Poly1305Update(&poly1305Ctx, padding, paddingLen);
-        if (err)
-        {
-            return err;
-        }
-    }
-
-    /* -- AAD length as a 64-bit little endian integer */
-
-    word32ToLittle64(inAADLen, little64);
-
-    err = wc_Poly1305Update(&poly1305Ctx, little64, sizeof(little64));
-    if (err)
-    {
-        return err;
-    }
-
-    /* -- Ciphertext length as a 64-bit little endian integer */
-
-    word32ToLittle64(inCiphertextLen, little64);
-
-    err = wc_Poly1305Update(&poly1305Ctx, little64, sizeof(little64));
-    if (err)
-    {
-        return err;
-    }
-
-    /* Finalize the auth tag */
-
-    err = wc_Poly1305Final(&poly1305Ctx, outAuthTag);
-
-    return err;
-}
-
-
-static void word32ToLittle64(const word32 inLittle32, byte outLittle64[8])
-{
-    XMEMSET(outLittle64, 0, 8);
-
-    outLittle64[0] = (inLittle32 & 0x000000FF);
-    outLittle64[1] = (inLittle32 & 0x0000FF00) >> 8;
-    outLittle64[2] = (inLittle32 & 0x00FF0000) >> 16;
-    outLittle64[3] = (inLittle32 & 0xFF000000) >> 24;
-}
-
-
-#endif /* HAVE_CHACHA && HAVE_POLY1305 */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/coding.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/coding.c
deleted file mode 100755
index 6ead79c..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/coding.c
+++ /dev/null
@@ -1,399 +0,0 @@
-/* coding.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef NO_CODING
-
-#include 
-#include 
-#include 
-
-
-enum {
-    BAD         = 0xFF,  /* invalid encoding */
-    PAD         = '=',
-    PEM_LINE_SZ = 64
-};
-
-
-static
-const byte base64Decode[] = { 62, BAD, BAD, BAD, 63,   /* + starts at 0x2B */
-                              52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
-                              BAD, BAD, BAD, BAD, BAD, BAD, BAD,
-                              0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-                              10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
-                              20, 21, 22, 23, 24, 25,
-                              BAD, BAD, BAD, BAD, BAD, BAD,
-                              26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
-                              36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
-                              46, 47, 48, 49, 50, 51
-                            };
-
-
-int Base64_Decode(const byte* in, word32 inLen, byte* out, word32* outLen)
-{
-    word32 i = 0;
-    word32 j = 0;
-    word32 plainSz = inLen - ((inLen + (PEM_LINE_SZ - 1)) / PEM_LINE_SZ );
-    const byte maxIdx = (byte)sizeof(base64Decode) + 0x2B - 1;
-
-    plainSz = (plainSz * 3 + 3) / 4;
-    if (plainSz > *outLen) return BAD_FUNC_ARG;
-
-    while (inLen > 3) {
-        byte b1, b2, b3;
-        byte e1 = in[j++];
-        byte e2 = in[j++];
-        byte e3 = in[j++];
-        byte e4 = in[j++];
-
-        int pad3 = 0;
-        int pad4 = 0;
-
-        if (e1 == 0)            /* end file 0's */
-            break;
-        if (e3 == PAD)
-            pad3 = 1;
-        if (e4 == PAD)
-            pad4 = 1;
-
-        if (e1 < 0x2B || e2 < 0x2B || e3 < 0x2B || e4 < 0x2B) {
-            WOLFSSL_MSG("Bad Base64 Decode data, too small");
-            return ASN_INPUT_E;
-        }
-
-        if (e1 > maxIdx || e2 > maxIdx || e3 > maxIdx || e4 > maxIdx) {
-            WOLFSSL_MSG("Bad Base64 Decode data, too big");
-            return ASN_INPUT_E;
-        }
-
-        e1 = base64Decode[e1 - 0x2B];
-        e2 = base64Decode[e2 - 0x2B];
-        e3 = (e3 == PAD) ? 0 : base64Decode[e3 - 0x2B];
-        e4 = (e4 == PAD) ? 0 : base64Decode[e4 - 0x2B];
-
-        b1 = (byte)((e1 << 2) | (e2 >> 4));
-        b2 = (byte)(((e2 & 0xF) << 4) | (e3 >> 2));
-        b3 = (byte)(((e3 & 0x3) << 6) | e4);
-
-        out[i++] = b1;
-        if (!pad3)
-            out[i++] = b2;
-        if (!pad4)
-            out[i++] = b3;
-        else
-            break;
-
-        inLen -= 4;
-        if (inLen && (in[j] == ' ' || in[j] == '\r' || in[j] == '\n')) {
-            byte endLine = in[j++];
-            inLen--;
-            while (inLen && endLine == ' ') {   /* allow trailing whitespace */
-                endLine = in[j++];
-                inLen--;
-            }
-            if (endLine == '\r') {
-                if (inLen) {
-                    endLine = in[j++];
-                    inLen--;
-                }
-            }
-            if (endLine != '\n') {
-                WOLFSSL_MSG("Bad end of line in Base64 Decode");
-                return ASN_INPUT_E;
-            }
-        }
-    }
-    *outLen = i;
-
-    return 0;
-}
-
-
-#if defined(WOLFSSL_BASE64_ENCODE)
-
-static
-const byte base64Encode[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
-                              'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
-                              'U', 'V', 'W', 'X', 'Y', 'Z',
-                              'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
-                              'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
-                              'u', 'v', 'w', 'x', 'y', 'z',
-                              '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
-                              '+', '/'
-                            };
-
-
-/* make sure *i (idx) won't exceed max, store and possibly escape to out,
- * raw means use e w/o decode,  0 on success */
-static int CEscape(int escaped, byte e, byte* out, word32* i, word32 max,
-                  int raw)
-{
-    int    doEscape = 0;
-    word32 needed = 1;
-    word32 idx = *i;
-
-    byte basic;
-    byte plus    = 0;
-    byte equals  = 0;
-    byte newline = 0;
-
-    if (raw)
-        basic = e;
-    else
-        basic = base64Encode[e];
-
-    /* check whether to escape */
-    if (escaped) {
-        switch ((char)basic) {
-            case '+' :
-                plus     = 1;
-                doEscape = 1;
-                needed  += 2;
-                break;
-            case '=' :
-                equals   = 1;
-                doEscape = 1;
-                needed  += 2;
-                break;
-            case '\n' :
-                newline  = 1;
-                doEscape = 1;
-                needed  += 2;
-                break;
-            default:
-                /* do nothing */
-                break;
-        }
-    }
-
-    /* check size */
-    if ( (idx+needed) > max) {
-        WOLFSSL_MSG("Escape buffer max too small");
-        return BUFFER_E;
-    }
-
-    /* store it */
-    if (doEscape == 0) {
-        out[idx++] = basic;
-    }
-    else {
-        out[idx++] = '%';  /* start escape */
-
-        if (plus) {
-            out[idx++] = '2';
-            out[idx++] = 'B';
-        }
-        else if (equals) {
-            out[idx++] = '3';
-            out[idx++] = 'D';
-        }
-        else if (newline) {
-            out[idx++] = '0';
-            out[idx++] = 'A';
-        }
-
-    }
-    *i = idx;
-
-    return 0;
-}
-
-
-/* internal worker, handles both escaped and normal line endings */
-static int DoBase64_Encode(const byte* in, word32 inLen, byte* out,
-                           word32* outLen, int escaped)
-{
-    int    ret = 0;
-    word32 i = 0,
-           j = 0,
-           n = 0;   /* new line counter */
-
-    word32 outSz = (inLen + 3 - 1) / 3 * 4;
-    word32 addSz = (outSz + PEM_LINE_SZ - 1) / PEM_LINE_SZ;  /* new lines */
-
-    if (escaped)
-        addSz *= 3;   /* instead of just \n, we're doing %0A triplet */
-
-    outSz += addSz;
-
-    /* if escaped we can't predetermine size for one pass encoding, but
-     * make sure we have enough if no escapes are in input */
-    if (outSz > *outLen) return BAD_FUNC_ARG;
-    
-    while (inLen > 2) {
-        byte b1 = in[j++];
-        byte b2 = in[j++];
-        byte b3 = in[j++];
-
-        /* encoded idx */
-        byte e1 = b1 >> 2;
-        byte e2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));
-        byte e3 = (byte)(((b2 & 0xF) << 2) | (b3 >> 6));
-        byte e4 = b3 & 0x3F;
-
-        /* store */
-        ret = CEscape(escaped, e1, out, &i, *outLen, 0);
-        if (ret != 0) break;
-        ret = CEscape(escaped, e2, out, &i, *outLen, 0);
-        if (ret != 0) break;
-        ret = CEscape(escaped, e3, out, &i, *outLen, 0);
-        if (ret != 0) break;
-        ret = CEscape(escaped, e4, out, &i, *outLen, 0);
-        if (ret != 0) break;
-
-        inLen -= 3;
-
-        if ((++n % (PEM_LINE_SZ / 4)) == 0 && inLen) {
-            ret = CEscape(escaped, '\n', out, &i, *outLen, 1);
-            if (ret != 0) break;
-        }
-    }
-
-    /* last integral */
-    if (inLen && ret == 0) {
-        int twoBytes = (inLen == 2);
-
-        byte b1 = in[j++];
-        byte b2 = (twoBytes) ? in[j++] : 0;
-
-        byte e1 = b1 >> 2;
-        byte e2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));
-        byte e3 = (byte)((b2 & 0xF) << 2);
-
-        ret = CEscape(escaped, e1, out, &i, *outLen, 0);
-        if (ret == 0) 
-            ret = CEscape(escaped, e2, out, &i, *outLen, 0);
-        if (ret == 0) {
-            /* third */
-            if (twoBytes)
-                ret = CEscape(escaped, e3, out, &i, *outLen, 0);
-            else 
-                ret = CEscape(escaped, '=', out, &i, *outLen, 1);
-        }
-        /* fourth always pad */
-        if (ret == 0)
-            ret = CEscape(escaped, '=', out, &i, *outLen, 1);
-    } 
-
-    if (ret == 0) 
-        ret = CEscape(escaped, '\n', out, &i, *outLen, 1);
-
-    if (i != outSz && escaped == 0 && ret == 0)
-        return ASN_INPUT_E; 
-
-    *outLen = i;
-    return ret; 
-}
-
-
-/* Base64 Encode, PEM style, with \n line endings */
-int Base64_Encode(const byte* in, word32 inLen, byte* out, word32* outLen)
-{
-    return DoBase64_Encode(in, inLen, out, outLen, 0);
-}
-
-
-/* Base64 Encode, with %0A esacped line endings instead of \n */
-int Base64_EncodeEsc(const byte* in, word32 inLen, byte* out, word32* outLen)
-{
-    return DoBase64_Encode(in, inLen, out, outLen, 1);
-}
-
-
-#endif  /* defined(WOLFSSL_BASE64_ENCODE) */
-
-
-#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) || defined(HAVE_FIPS)
-
-static
-const byte hexDecode[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-                           BAD, BAD, BAD, BAD, BAD, BAD, BAD,
-                           10, 11, 12, 13, 14, 15,  /* upper case A-F */
-                           BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD,
-                           BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD,
-                           BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD,
-                           BAD, BAD,  /* G - ` */
-                           10, 11, 12, 13, 14, 15   /* lower case a-f */
-                         };  /* A starts at 0x41 not 0x3A */
-
-int Base16_Decode(const byte* in, word32 inLen, byte* out, word32* outLen)
-{
-    word32 inIdx  = 0;
-    word32 outIdx = 0;
-
-    if (inLen == 1 && *outLen && in) {
-        byte b = in[inIdx++] - 0x30;  /* 0 starts at 0x30 */
-
-        /* sanity check */
-        if (b >=  sizeof(hexDecode)/sizeof(hexDecode[0]))
-            return ASN_INPUT_E;
-
-        b  = hexDecode[b];
-
-        if (b == BAD)
-            return ASN_INPUT_E;
-        
-        out[outIdx++] = b;
-
-        *outLen = outIdx;
-        return 0;
-    }
-
-    if (inLen % 2)
-        return BAD_FUNC_ARG;
-
-    if (*outLen < (inLen / 2))
-        return BAD_FUNC_ARG;
-
-    while (inLen) {
-        byte b  = in[inIdx++] - 0x30;  /* 0 starts at 0x30 */
-        byte b2 = in[inIdx++] - 0x30;
-
-        /* sanity checks */
-        if (b >=  sizeof(hexDecode)/sizeof(hexDecode[0]))
-            return ASN_INPUT_E;
-        if (b2 >= sizeof(hexDecode)/sizeof(hexDecode[0]))
-            return ASN_INPUT_E;
-
-        b  = hexDecode[b];
-        b2 = hexDecode[b2];
-
-        if (b == BAD || b2 == BAD)
-            return ASN_INPUT_E;
-        
-        out[outIdx++] = (byte)((b << 4) | b2);
-        inLen -= 2;
-    }
-
-    *outLen = outIdx;
-    return 0;
-}
-
-
-#endif /* (OPENSSL_EXTRA) || (HAVE_WEBSERVER) || (HAVE_FIPS) */
-
-#endif /* NO_CODING */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/compress.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/compress.c
deleted file mode 100755
index a01c071..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/compress.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/* compress.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- wc_*
- * 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-1301, USA
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef HAVE_LIBZ
-
-
-#include 
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-#include 
-
-
-/* alloc user allocs to work with zlib */
-static void* myAlloc(void* opaque, unsigned int item, unsigned int size)
-{
-    (void)opaque;
-    return XMALLOC(item * size, opaque, DYNAMIC_TYPE_LIBZ);
-}
-
-
-static void myFree(void* opaque, void* memory)
-{
-    (void)opaque;
-    XFREE(memory, opaque, DYNAMIC_TYPE_LIBZ);
-}
-
-
-#ifdef HAVE_MCAPI
-    #define DEFLATE_DEFAULT_WINDOWBITS  11
-    #define DEFLATE_DEFAULT_MEMLEVEL     1
-#else
-    #define DEFLATE_DEFAULT_WINDOWBITS 15
-    #define DEFLATE_DEFAULT_MEMLEVEL    8
-#endif
-
-
-int wc_Compress(byte* out, word32 outSz, const byte* in, word32 inSz, word32 flags)
-/*
- * out - pointer to destination buffer
- * outSz - size of destination buffer
- * in - pointer to source buffer to compress
- * inSz - size of source to compress
- * flags - flags to control how compress operates 
- *
- * return:
- *    negative - error code
- *    positive - bytes stored in out buffer
- * 
- * Note, the output buffer still needs to be larger than the input buffer.
- * The right chunk of data won't compress at all, and the lookup table will
- * add to the size of the output. The libz code says the compressed
- * buffer should be srcSz + 0.1% + 12.
- */
-{
-    z_stream stream;
-    int result = 0;
-
-    stream.next_in = (Bytef*)in;
-    stream.avail_in = (uInt)inSz;
-#ifdef MAXSEG_64K
-    /* Check for source > 64K on 16-bit machine: */
-    if ((uLong)stream.avail_in != inSz) return COMPRESS_INIT_E;
-#endif
-    stream.next_out = out;
-    stream.avail_out = (uInt)outSz;
-    if ((uLong)stream.avail_out != outSz) return COMPRESS_INIT_E;
-
-    stream.zalloc = (alloc_func)myAlloc;
-    stream.zfree = (free_func)myFree;
-    stream.opaque = (voidpf)0;
-
-    if (deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
-                     DEFLATE_DEFAULT_WINDOWBITS, DEFLATE_DEFAULT_MEMLEVEL,
-                     flags ? Z_FIXED : Z_DEFAULT_STRATEGY) != Z_OK)
-        return COMPRESS_INIT_E;
-
-    if (deflate(&stream, Z_FINISH) != Z_STREAM_END) {
-        deflateEnd(&stream);
-        return COMPRESS_E;
-    }
-
-    result = (int)stream.total_out;
-
-    if (deflateEnd(&stream) != Z_OK)
-        result = COMPRESS_E;
-
-    return result;
-}
-
-
-int wc_DeCompress(byte* out, word32 outSz, const byte* in, word32 inSz)
-/*
- * out - pointer to destination buffer
- * outSz - size of destination buffer
- * in - pointer to source buffer to compress
- * inSz - size of source to compress
- * flags - flags to control how compress operates 
- *
- * return:
- *    negative - error code
- *    positive - bytes stored in out buffer
- */ 
-{
-    z_stream stream;
-    int result = 0;
-
-    stream.next_in = (Bytef*)in;
-    stream.avail_in = (uInt)inSz;
-    /* Check for source > 64K on 16-bit machine: */
-    if ((uLong)stream.avail_in != inSz) return DECOMPRESS_INIT_E;
-
-    stream.next_out = out;
-    stream.avail_out = (uInt)outSz;
-    if ((uLong)stream.avail_out != outSz) return DECOMPRESS_INIT_E;
-
-    stream.zalloc = (alloc_func)myAlloc;
-    stream.zfree = (free_func)myFree;
-    stream.opaque = (voidpf)0;
-
-    if (inflateInit2(&stream, DEFLATE_DEFAULT_WINDOWBITS) != Z_OK)
-        return DECOMPRESS_INIT_E;
-
-    if (inflate(&stream, Z_FINISH) != Z_STREAM_END) {
-        inflateEnd(&stream);
-        return DECOMPRESS_E;
-    }
-    
-    result = (int)stream.total_out;
-
-    if (inflateEnd(&stream) != Z_OK)
-        result = DECOMPRESS_E;
-
-    return result;
-}
-
-
-#endif /* HAVE_LIBZ */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/curve25519.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/curve25519.c
deleted file mode 100755
index b745a04..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/curve25519.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/* curve25519.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
- /* Based On Daniel J Bernstein's curve25519 Public Domain ref10 work. */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef HAVE_CURVE25519
-
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-const curve25519_set_type curve25519_sets[] = {
-{
-        32,
-        "CURVE25519",
-}
-};
-
-
-
-int wc_curve25519_make_key(RNG* rng, int keysize, curve25519_key* key)
-{
-  unsigned char basepoint[CURVE25519_KEYSIZE] = {9};
-  unsigned char n[CURVE25519_KEYSIZE];
-  unsigned char p[CURVE25519_KEYSIZE];
-  int  i;
-  int  ret;
-
-  if (key == NULL || rng == NULL)
-      return ECC_BAD_ARG_E;
-
-  /* currently only a key size of 32 bytes is used */
-  if (keysize != CURVE25519_KEYSIZE)
-      return ECC_BAD_ARG_E;
-
-  /* get random number from RNG */
-  ret = wc_RNG_GenerateBlock(rng, n, keysize);
-  if (ret != 0)
-      return ret;
-
-  for (i = 0; i < keysize; ++i) key->k.point[i] = n[i];
-  key->k.point[ 0] &= 248;
-  key->k.point[31] &= 127;
-  key->k.point[31] |= 64;
-
-  /* compute public key */
-  ret = curve25519(p, key->k.point, basepoint);
-
-  /* store keys in big endian format */
-  for (i = 0; i < keysize; ++i) n[i] = key->k.point[i];
-  for (i = 0; i < keysize; ++i) {
-      key->p.point[keysize - i - 1] = p[i];
-      key->k.point[keysize - i - 1] = n[i];
-  }
-
-  ForceZero(n, keysize);
-  ForceZero(p, keysize);
-
-  return ret;
-}
-
-
-int wc_curve25519_shared_secret(curve25519_key* private_key,
-                                curve25519_key* public_key,
-                                byte* out, word32* outlen)
-{
-    unsigned char k[CURVE25519_KEYSIZE];
-    unsigned char p[CURVE25519_KEYSIZE];
-    unsigned char o[CURVE25519_KEYSIZE];
-    int ret = 0;
-    int i;
-
-    /* sanity check */
-    if (private_key == NULL || public_key == NULL || out == NULL ||
-            outlen == NULL)
-        return BAD_FUNC_ARG;
-
-    /* avoid implementation fingerprinting */
-    if (public_key->p.point[0] > 0x7F)
-        return ECC_BAD_ARG_E;
-
-    XMEMSET(p,   0, sizeof(p));
-    XMEMSET(k,   0, sizeof(k));
-    XMEMSET(out, 0, CURVE25519_KEYSIZE);
-
-    for (i = 0; i < CURVE25519_KEYSIZE; ++i) {
-        p[i] = public_key->p.point [CURVE25519_KEYSIZE - i - 1];
-        k[i] = private_key->k.point[CURVE25519_KEYSIZE - i - 1];
-    }
-
-    ret     = curve25519(o , k, p);
-    *outlen = CURVE25519_KEYSIZE;
-
-    for (i = 0; i < CURVE25519_KEYSIZE; ++i) {
-        out[i] = o[CURVE25519_KEYSIZE - i -1];
-    }
-
-    ForceZero(p, sizeof(p));
-    ForceZero(k, sizeof(k));
-    ForceZero(o, sizeof(o));
-
-    return ret;
-}
-
-
-/* curve25519 uses a serialized string for key representation */
-int wc_curve25519_export_public(curve25519_key* key, byte* out, word32* outLen)
-{
-    word32 keySz;
-
-    if (key == NULL || out == NULL || outLen == NULL)
-        return BAD_FUNC_ARG;
-
-    /* check size of outgoing key */
-    keySz  = wc_curve25519_size(key);
-
-    /* copy in public key */
-    XMEMCPY(out, key->p.point, keySz);
-    *outLen = keySz;
-
-    return 0;
-}
-
-/* import curve25519 public key
-   return 0 on success */
-int wc_curve25519_import_public(const byte* in, word32 inLen,
-                                curve25519_key* key)
-{
-    word32 keySz;
-
-    /* sanity check */
-    if (key == NULL || in == NULL)
-        return ECC_BAD_ARG_E;
-
-    /* check size of incoming keys */
-    keySz = wc_curve25519_size(key);
-    if (inLen != keySz)
-       return ECC_BAD_ARG_E;
-
-    XMEMCPY(key->p.point, in, inLen);
-
-    key->dp = &curve25519_sets[0];
-
-    return 0;
-}
-
-
-/* export curve25519 private key only raw, outLen is in/out size
-   return 0 on success */
-int wc_curve25519_export_private_raw(curve25519_key* key, byte* out,
-                                     word32* outLen)
-{
-    word32 keySz;
-
-    /* sanity check */
-    if (key == NULL || out == NULL || outLen == NULL)
-        return ECC_BAD_ARG_E;
-
-    keySz = wc_curve25519_size(key);
-    *outLen = keySz;
-    XMEMSET(out, 0, keySz);
-    XMEMCPY(out, key->k.point, keySz);
-
-    return 0;
-}
-
-
-/* curve25519 private key import.
-   Public key to match private key needs to be imported too */
-int wc_curve25519_import_private_raw(const byte* priv, word32 privSz,
-                             const byte* pub, word32 pubSz, curve25519_key* key)
-{
-    int ret = 0;
-    word32 keySz;
-
-    /* sanity check */
-    if (key == NULL || priv == NULL || pub == NULL)
-        return ECC_BAD_ARG_E;
-
-    /* check size of incoming keys */
-    keySz = wc_curve25519_size(key);
-    if (privSz != keySz || pubSz != keySz)
-       return ECC_BAD_ARG_E;
-
-    XMEMCPY(key->k.point, priv, privSz);
-    XMEMCPY(key->p.point, pub, pubSz);
-
-    return ret;
-}
-
-
-int wc_curve25519_init(curve25519_key* key)
-{
-    word32 keySz;
-
-    if (key == NULL)
-       return ECC_BAD_ARG_E;
-
-    /* currently the format for curve25519 */
-    key->dp = &curve25519_sets[0];
-    keySz   = key->dp->size;
-
-    XMEMSET(key->k.point, 0, keySz);
-    XMEMSET(key->p.point, 0, keySz);
-
-    return 0;
-}
-
-
-/* Clean the memory of a key */
-void wc_curve25519_free(curve25519_key* key)
-{
-   if (key == NULL)
-       return;
-
-   key->dp = NULL;
-   ForceZero(key->p.point, sizeof(key->p.point));
-   ForceZero(key->k.point, sizeof(key->k.point));
-}
-
-
-/* get key size */
-int wc_curve25519_size(curve25519_key* key)
-{
-    if (key == NULL) return 0;
-
-    return key->dp->size;
-}
-
-#endif /*HAVE_CURVE25519*/
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/des3.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/des3.c
deleted file mode 100755
index f886ecd..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/des3.c
+++ /dev/null
@@ -1,1678 +0,0 @@
-/* des3.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef NO_DES3
-
-#include 
-
-#ifdef HAVE_FIPS
-#ifdef HAVE_CAVIUM
-    static int wc_Des3_CaviumSetKey(Des3* des3, const byte* key, const byte* iv);
-    static int wc_Des3_CaviumCbcEncrypt(Des3* des3, byte* out, const byte* in,
-                                      word32 length);
-    static int wc_Des3_CaviumCbcDecrypt(Des3* des3, byte* out, const byte* in,
-                                      word32 length);
-#endif
-
-int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
-{
-    return Des_SetKey(des, key, iv, dir);
-}
-
-
-int wc_Des3_SetKey(Des3* des, const byte* key, const byte* iv, int dir)
-{
-    return Des3_SetKey_fips(des, key, iv, dir);
-}
-
-
-int wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
-{
-    return Des_CbcEncrypt(des, out, in, sz);
-}
-
-
-int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
-{
-    return Des_CbcDecrypt(des, out, in, sz);
-}
-
-
-int wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
-{
-    return Des3_CbcEncrypt_fips(des, out, in, sz);
-}
-
-
-int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz)
-{
-    return Des3_CbcDecrypt_fips(des, out, in, sz);
-}
-
-
-#ifdef WOLFSSL_DES_ECB
-
-/* One block, compatibility only */
-int wc_Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz)
-{
-    return Des_EcbEncrypt(des, out, in, sz);
-}
-
-#endif /* WOLFSSL_DES_ECB */
-
-
-void wc_Des_SetIV(Des* des, const byte* iv)
-{
-    Des_SetIV(des, iv);
-}
-
-
-int wc_Des_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
-                                                const byte* key, const byte* iv)
-{
-    return Des_CbcDecryptWithKey(out, in, sz, key, iv);
-}
-
-
-int wc_Des3_SetIV(Des3* des, const byte* iv)
-{
-    return Des3_SetIV_fips(des, iv);
-}
-
-
-int wc_Des3_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
-                                                const byte* key, const byte* iv)
-{
-    return Des3_CbcDecryptWithKey(out, in, sz, key, iv);
-}
-
-
-#ifdef HAVE_CAVIUM
-
-/* Initiliaze Des3 for use with Nitrox device */
-int wc_Des3_InitCavium(Des3* des3, int devId)
-{
-    return Des3_InitCavium(des3, devId);
-}
-
-
-/* Free Des3 from use with Nitrox device */
-void wc_Des3_FreeCavium(Des3* des3)
-{
-    Des3_FreeCavium(des3);
-}
-
-
-#endif /* HAVE_CAVIUM */
-#else /* build without fips */
-
-#if defined(WOLFSSL_TI_CRYPT)
-    #include 
-#else
-
-#include 
-#include 
-
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-
-#ifdef HAVE_CAVIUM
-    static int wc_Des3_CaviumSetKey(Des3* des3, const byte* key, const byte* iv);
-    static int wc_Des3_CaviumCbcEncrypt(Des3* des3, byte* out, const byte* in,
-                                      word32 length);
-    static int wc_Des3_CaviumCbcDecrypt(Des3* des3, byte* out, const byte* in,
-                                      word32 length);
-#endif
-
-
-
-
-#ifdef STM32F2_CRYPTO
-    /*
-     * STM32F2 hardware DES/3DES support through the STM32F2 standard
-     * peripheral library. Documentation located in STM32F2xx Standard
-     * Peripheral Library document (See note in README).
-     */
-    #include "stm32f2xx.h"
-		#include "stm32f2xx_cryp.h"
-
-    int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
-    {
-        word32 *dkey = des->key;
-
-        XMEMCPY(dkey, key, 8);
-        ByteReverseWords(dkey, dkey, 8);
-
-        wc_Des_SetIV(des, iv);
-
-        return 0;
-    }
-
-    int wc_Des3_SetKey(Des3* des, const byte* key, const byte* iv, int dir)
-    {
-        word32 *dkey1 = des->key[0];
-        word32 *dkey2 = des->key[1];
-        word32 *dkey3 = des->key[2];
-
-        XMEMCPY(dkey1, key, 8);         /* set key 1 */
-        XMEMCPY(dkey2, key + 8, 8);     /* set key 2 */
-        XMEMCPY(dkey3, key + 16, 8);    /* set key 3 */
-
-        ByteReverseWords(dkey1, dkey1, 8);
-        ByteReverseWords(dkey2, dkey2, 8);
-        ByteReverseWords(dkey3, dkey3, 8);
-
-        return wc_Des3_SetIV(des, iv);
-    }
-
-    void DesCrypt(Des* des, byte* out, const byte* in, word32 sz,
-                  int dir, int mode)
-    {
-        word32 *dkey, *iv;
-        CRYP_InitTypeDef DES_CRYP_InitStructure;
-        CRYP_KeyInitTypeDef DES_CRYP_KeyInitStructure;
-        CRYP_IVInitTypeDef DES_CRYP_IVInitStructure;
-
-        dkey = des->key;
-        iv = des->reg;
-
-        /* crypto structure initialization */
-        CRYP_KeyStructInit(&DES_CRYP_KeyInitStructure);
-        CRYP_StructInit(&DES_CRYP_InitStructure);
-        CRYP_IVStructInit(&DES_CRYP_IVInitStructure);
-
-        /* reset registers to their default values */
-        CRYP_DeInit();
-
-        /* set direction, mode, and datatype */
-        if (dir == DES_ENCRYPTION) {
-            DES_CRYP_InitStructure.CRYP_AlgoDir  = CRYP_AlgoDir_Encrypt;
-        } else { /* DES_DECRYPTION */
-            DES_CRYP_InitStructure.CRYP_AlgoDir  = CRYP_AlgoDir_Decrypt;
-        }
-
-        if (mode == DES_CBC) {
-            DES_CRYP_InitStructure.CRYP_AlgoMode = CRYP_AlgoMode_DES_CBC;
-        } else { /* DES_ECB */
-            DES_CRYP_InitStructure.CRYP_AlgoMode = CRYP_AlgoMode_DES_ECB;
-        }
-
-        DES_CRYP_InitStructure.CRYP_DataType = CRYP_DataType_8b;
-        CRYP_Init(&DES_CRYP_InitStructure);
-
-        /* load key into correct registers */
-        DES_CRYP_KeyInitStructure.CRYP_Key1Left  = dkey[0];
-        DES_CRYP_KeyInitStructure.CRYP_Key1Right = dkey[1];
-        CRYP_KeyInit(&DES_CRYP_KeyInitStructure);
-
-        /* set iv */
-        ByteReverseWords(iv, iv, DES_BLOCK_SIZE);
-        DES_CRYP_IVInitStructure.CRYP_IV0Left  = iv[0];
-        DES_CRYP_IVInitStructure.CRYP_IV0Right = iv[1];
-        CRYP_IVInit(&DES_CRYP_IVInitStructure);
-
-        /* enable crypto processor */
-        CRYP_Cmd(ENABLE);
-
-        while (sz > 0)
-        {
-            /* flush IN/OUT FIFOs */
-            CRYP_FIFOFlush();
-
-            /* if input and output same will overwrite input iv */
-            XMEMCPY(des->tmp, in + sz - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
-
-            CRYP_DataIn(*(uint32_t*)&in[0]);
-            CRYP_DataIn(*(uint32_t*)&in[4]);
-
-            /* wait until the complete message has been processed */
-            while(CRYP_GetFlagStatus(CRYP_FLAG_BUSY) != RESET) {}
-
-            *(uint32_t*)&out[0]  = CRYP_DataOut();
-            *(uint32_t*)&out[4]  = CRYP_DataOut();
-
-            /* store iv for next call */
-            XMEMCPY(des->reg, des->tmp, DES_BLOCK_SIZE);
-
-            sz  -= DES_BLOCK_SIZE;
-            in  += DES_BLOCK_SIZE;
-            out += DES_BLOCK_SIZE;
-        }
-
-        /* disable crypto processor */
-        CRYP_Cmd(DISABLE);
-    }
-
-    int wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
-    {
-        DesCrypt(des, out, in, sz, DES_ENCRYPTION, DES_CBC);
-        return 0;
-    }
-
-    int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
-    {
-        DesCrypt(des, out, in, sz, DES_DECRYPTION, DES_CBC);
-        return 0;
-    }
-
-    int wc_Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz)
-    {
-        DesCrypt(des, out, in, sz, DES_ENCRYPTION, DES_ECB);
-        return 0;
-    }
-
-    void Des3Crypt(Des3* des, byte* out, const byte* in, word32 sz,
-                   int dir)
-    {
-        word32 *dkey1, *dkey2, *dkey3, *iv;
-        CRYP_InitTypeDef DES3_CRYP_InitStructure;
-        CRYP_KeyInitTypeDef DES3_CRYP_KeyInitStructure;
-        CRYP_IVInitTypeDef DES3_CRYP_IVInitStructure;
-
-        dkey1 = des->key[0];
-        dkey2 = des->key[1];
-        dkey3 = des->key[2];
-        iv = des->reg;
-
-        /* crypto structure initialization */
-        CRYP_KeyStructInit(&DES3_CRYP_KeyInitStructure);
-        CRYP_StructInit(&DES3_CRYP_InitStructure);
-        CRYP_IVStructInit(&DES3_CRYP_IVInitStructure);
-
-        /* reset registers to their default values */
-        CRYP_DeInit();
-
-        /* set direction, mode, and datatype */
-        if (dir == DES_ENCRYPTION) {
-            DES3_CRYP_InitStructure.CRYP_AlgoDir  = CRYP_AlgoDir_Encrypt;
-        } else {
-            DES3_CRYP_InitStructure.CRYP_AlgoDir  = CRYP_AlgoDir_Decrypt;
-        }
-
-        DES3_CRYP_InitStructure.CRYP_AlgoMode = CRYP_AlgoMode_TDES_CBC;
-        DES3_CRYP_InitStructure.CRYP_DataType = CRYP_DataType_8b;
-        CRYP_Init(&DES3_CRYP_InitStructure);
-
-        /* load key into correct registers */
-        DES3_CRYP_KeyInitStructure.CRYP_Key1Left  = dkey1[0];
-        DES3_CRYP_KeyInitStructure.CRYP_Key1Right = dkey1[1];
-        DES3_CRYP_KeyInitStructure.CRYP_Key2Left  = dkey2[0];
-        DES3_CRYP_KeyInitStructure.CRYP_Key2Right = dkey2[1];
-        DES3_CRYP_KeyInitStructure.CRYP_Key3Left  = dkey3[0];
-        DES3_CRYP_KeyInitStructure.CRYP_Key3Right = dkey3[1];
-        CRYP_KeyInit(&DES3_CRYP_KeyInitStructure);
-
-        /* set iv */
-        ByteReverseWords(iv, iv, DES_BLOCK_SIZE);
-        DES3_CRYP_IVInitStructure.CRYP_IV0Left  = iv[0];
-        DES3_CRYP_IVInitStructure.CRYP_IV0Right = iv[1];
-        CRYP_IVInit(&DES3_CRYP_IVInitStructure);
-
-        /* enable crypto processor */
-        CRYP_Cmd(ENABLE);
-
-        while (sz > 0)
-        {
-            /* flush IN/OUT FIFOs */
-            CRYP_FIFOFlush();
-
-            CRYP_DataIn(*(uint32_t*)&in[0]);
-            CRYP_DataIn(*(uint32_t*)&in[4]);
-
-            /* wait until the complete message has been processed */
-            while(CRYP_GetFlagStatus(CRYP_FLAG_BUSY) != RESET) {}
-
-            *(uint32_t*)&out[0]  = CRYP_DataOut();
-            *(uint32_t*)&out[4]  = CRYP_DataOut();
-
-            /* store iv for next call */
-            XMEMCPY(des->reg, out + sz - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
-
-            sz  -= DES_BLOCK_SIZE;
-            in  += DES_BLOCK_SIZE;
-            out += DES_BLOCK_SIZE;
-        }
-
-        /* disable crypto processor */
-        CRYP_Cmd(DISABLE);
-
-    }
-
-    int wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
-    {
-        Des3Crypt(des, out, in, sz, DES_ENCRYPTION);
-        return 0;
-    }
-
-    int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz)
-    {
-        Des3Crypt(des, out, in, sz, DES_DECRYPTION);
-        return 0;
-    }
-
-#elif defined(HAVE_COLDFIRE_SEC)
-
-#include 
-
-#include "sec.h"
-#include "mcf5475_sec.h"
-#include "mcf5475_siu.h"
-
-#if defined (HAVE_THREADX)
-#include "memory_pools.h"
-extern TX_BYTE_POOL mp_ncached;  /* Non Cached memory pool */
-#endif
-
-#define DES_BUFFER_SIZE (DES_BLOCK_SIZE * 64)
-static unsigned char *desBuffIn = NULL ;
-static unsigned char *desBuffOut = NULL ;
-static byte *secIV ; 
-static byte *secKey ; 
-static volatile SECdescriptorType *secDesc ;
-
-static wolfSSL_Mutex Mutex_DesSEC ;
-
-#define SEC_DESC_DES_CBC_ENCRYPT  0x20500010
-#define SEC_DESC_DES_CBC_DECRYPT  0x20400010
-#define SEC_DESC_DES3_CBC_ENCRYPT 0x20700010
-#define SEC_DESC_DES3_CBC_DECRYPT 0x20600010
-
-#define DES_IVLEN 8
-#define DES_KEYLEN 8
-#define DES3_IVLEN 8
-#define DES3_KEYLEN 24
-
-extern volatile unsigned char __MBAR[];
-
-static void wc_Des_Cbc(byte* out, const byte* in, word32 sz, 
-                    byte *key, byte *iv, word32 desc)
-{
-    #ifdef DEBUG_WOLFSSL
-    int ret ;  int stat1,stat2 ; 
-	  #endif
-    int size ;
-    volatile int v ;
- 
-    LockMutex(&Mutex_DesSEC) ;
-    
-    secDesc->length1 = 0x0;
-    secDesc->pointer1 = NULL;
-    if((desc==SEC_DESC_DES_CBC_ENCRYPT)||(desc==SEC_DESC_DES_CBC_DECRYPT)){
-        secDesc->length2 = DES_IVLEN ;  
-        secDesc->length3 = DES_KEYLEN ;
-    } else {
-        secDesc->length2 = DES3_IVLEN ; 
-        secDesc->length3 = DES3_KEYLEN ;
-    }
-    secDesc->pointer2 = secIV ;
-    secDesc->pointer3 = secKey;
-    secDesc->pointer4 = desBuffIn ;
-    secDesc->pointer5 = desBuffOut ;
-    secDesc->length6 = 0; 
-    secDesc->pointer6 = NULL; 
-    secDesc->length7 = 0x0;
-    secDesc->pointer7 = NULL;
-    secDesc->nextDescriptorPtr = NULL ; 
-    
-    while(sz) {
-        XMEMCPY(secIV, iv, secDesc->length2) ;
-        if((sz%DES_BUFFER_SIZE) == sz) {
-            size = sz ;
-            sz = 0 ;
-        } else {
-            size = DES_BUFFER_SIZE ;
-            sz -= DES_BUFFER_SIZE ;
-        }
-        
-        XMEMCPY(desBuffIn, in, size) ;
-        XMEMCPY(secKey, key, secDesc->length3) ;
-        
-        secDesc->header = desc ;
-        secDesc->length4 = size;
-        secDesc->length5 = size;
-        /* Point SEC to the location of the descriptor */
-        MCF_SEC_FR0 = (uint32)secDesc;
-        /* Initialize SEC and wait for encryption to complete */
-        MCF_SEC_CCCR0 = 0x0000001a;
-        /* poll SISR to determine when channel is complete */
-        v=0 ;
-        while((secDesc->header>> 24) != 0xff) {
-            if(v++ > 1000)break ;
-        }
-				
-#ifdef DEBUG_WOLFSSL
-        ret = MCF_SEC_SISRH;
-        stat1 = MCF_SEC_DSR ; 
-        stat2 = MCF_SEC_DISR ; 
-        if(ret & 0xe0000000) {
-            /* db_printf("Des_Cbc(%x):ISRH=%08x, DSR=%08x, DISR=%08x\n", desc, ret, stat1, stat2) ; */
-        }
-#endif
-				
-        XMEMCPY(out, desBuffOut, size) ;
-
-        if((desc==SEC_DESC_DES3_CBC_ENCRYPT)||(desc==SEC_DESC_DES_CBC_ENCRYPT)) {
-            XMEMCPY((void*)iv, (void*)&(out[size-secDesc->length2]), secDesc->length2) ;
-        } else {
-            XMEMCPY((void*)iv, (void*)&(in[size-secDesc->length2]), secDesc->length2) ;
-        }
-        
-        in  += size ;   
-        out += size ;
-                
-    }
-    UnLockMutex(&Mutex_DesSEC) ;
-    
-}
-
-
-int wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
-{
-    wc_Des_Cbc(out, in, sz,  (byte *)des->key,  (byte *)des->reg, SEC_DESC_DES_CBC_ENCRYPT) ;
-    return 0;
-}
-
-int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
-{
-    wc_Des_Cbc(out, in, sz,   (byte *)des->key,  (byte *)des->reg, SEC_DESC_DES_CBC_DECRYPT) ;
-    return 0;
-}
-
-int wc_Des3_CbcEncrypt(Des3* des3, byte* out, const byte* in, word32 sz)
-{
-    wc_Des_Cbc(out, in, sz,  (byte *)des3->key,  (byte *)des3->reg, SEC_DESC_DES3_CBC_ENCRYPT) ;
-	  return 0;
-}
-
-
-int wc_Des3_CbcDecrypt(Des3* des3, byte* out, const byte* in, word32 sz)
-{
-    wc_Des_Cbc(out, in, sz,   (byte *)des3->key,  (byte *)des3->reg, SEC_DESC_DES3_CBC_DECRYPT) ;
-	  return 0;
-}
-
-static void setParity(byte *buf, int len) 
-{
-    int i, j ;
-    byte v ;
-    int bits ;
-
-    for(i=0; i> 1 ;
-        buf[i] = v << 1 ;
-        bits = 0 ;
-        for(j=0; j<7; j++)
-        {
-            bits += (v&0x1) ;
-            v = v >> 1 ;
-        }
-        buf[i] |= (1 - (bits&0x1)) ;
-    }
-    
-}
-
-
-int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
-{
-    if(desBuffIn == NULL) {
-        #if defined (HAVE_THREADX)
-			  int s1, s2, s3, s4, s5 ;
-        s5 = tx_byte_allocate(&mp_ncached,(void *)&secDesc, 
-                                                     sizeof(SECdescriptorType), TX_NO_WAIT);
-        s1 = tx_byte_allocate(&mp_ncached,(void *)&desBuffIn,  DES_BUFFER_SIZE, TX_NO_WAIT);
-        s2 = tx_byte_allocate(&mp_ncached,(void *)&desBuffOut, DES_BUFFER_SIZE, TX_NO_WAIT);
-        /* Don't know des or des3 to be used. Allocate larger buffers */
-        s3 = tx_byte_allocate(&mp_ncached,(void *)&secKey,     DES3_KEYLEN,TX_NO_WAIT);
-        s4 = tx_byte_allocate(&mp_ncached,(void *)&secIV,      DES3_IVLEN,  TX_NO_WAIT);              
-        #else
-        #warning "Allocate non-Cache buffers"
-        #endif
-        
-        InitMutex(&Mutex_DesSEC) ;
-    }
-     
-    XMEMCPY(des->key, key, DES_KEYLEN);  
-    setParity((byte *)des->key, DES_KEYLEN) ;  
-		
-    if (iv) {
-        XMEMCPY(des->reg, iv, DES_IVLEN);
-    }   else {
-        XMEMSET(des->reg, 0x0, DES_IVLEN) ;
-    }
-		return 0;
-}
-
-int wc_Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
-{
-    
-    if(desBuffIn == NULL) {
-        #if defined (HAVE_THREADX)
-			  int s1, s2, s3, s4, s5 ;
-        s5 = tx_byte_allocate(&mp_ncached,(void *)&secDesc, 
-                                                     sizeof(SECdescriptorType), TX_NO_WAIT);
-        s1 = tx_byte_allocate(&mp_ncached,(void *)&desBuffIn,  DES_BUFFER_SIZE, TX_NO_WAIT);
-        s2 = tx_byte_allocate(&mp_ncached,(void *)&desBuffOut, DES_BUFFER_SIZE, TX_NO_WAIT);
-        s3 = tx_byte_allocate(&mp_ncached,(void *)&secKey,     DES3_KEYLEN,TX_NO_WAIT);
-        s4 = tx_byte_allocate(&mp_ncached,(void *)&secIV,      DES3_IVLEN,  TX_NO_WAIT);              
-        #else
-        #warning "Allocate non-Cache buffers"
-        #endif
-        
-        InitMutex(&Mutex_DesSEC) ;
-    }
-    
-    XMEMCPY(des3->key[0], key, DES3_KEYLEN); 
-    setParity((byte *)des3->key[0], DES3_KEYLEN) ;  
-		
-    if (iv) {
-        XMEMCPY(des3->reg, iv, DES3_IVLEN);
-    }   else {
-        XMEMSET(des3->reg, 0x0, DES3_IVLEN) ;
-    }
-    return 0;
-
-}
-
-#elif defined FREESCALE_MMCAU
-    /*
-     * Freescale mmCAU hardware DES/3DES support through the CAU/mmCAU library.
-     * Documentation located in ColdFire/ColdFire+ CAU and Kinetis mmCAU
-     * Software Library User Guide (See note in README).
-     */
-    #include "cau_api.h"
-
-    const unsigned char parityLookup[128] =
-    {
-        1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,
-        0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,
-        0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,
-        1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0
-     };
-
-    int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
-    {
-        int i = 0;
-        byte* dkey = (byte*)des->key;
-
-        XMEMCPY(dkey, key, 8);
-
-        wc_Des_SetIV(des, iv);
-
-        /* fix key parity, if needed */
-        for (i = 0; i < 8; i++) {
-            dkey[i] = ((dkey[i] & 0xFE) | parityLookup[dkey[i] >> 1]);
-        }
-
-        return 0;
-    }
-
-    int wc_Des3_SetKey(Des3* des, const byte* key, const byte* iv, int dir)
-    {
-        int i = 0, ret = 0;
-        byte* dkey1 = (byte*)des->key[0];
-        byte* dkey2 = (byte*)des->key[1];
-        byte* dkey3 = (byte*)des->key[2];
-
-        XMEMCPY(dkey1, key, 8);         /* set key 1 */
-        XMEMCPY(dkey2, key + 8, 8);     /* set key 2 */
-        XMEMCPY(dkey3, key + 16, 8);    /* set key 3 */
-
-        ret = wc_Des3_SetIV(des, iv);
-        if (ret != 0)
-            return ret;
-
-        /* fix key parity if needed */
-        for (i = 0; i < 8; i++)
-           dkey1[i] = ((dkey1[i] & 0xFE) | parityLookup[dkey1[i] >> 1]);
-
-        for (i = 0; i < 8; i++)
-           dkey2[i] = ((dkey2[i] & 0xFE) | parityLookup[dkey2[i] >> 1]);
-
-        for (i = 0; i < 8; i++)
-           dkey3[i] = ((dkey3[i] & 0xFE) | parityLookup[dkey3[i] >> 1]);
-
-        return ret;
-    }
-
-    int wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
-    {
-        int i;
-        int offset = 0;
-        int len = sz;
-        byte *iv;
-        byte temp_block[DES_BLOCK_SIZE];
-
-        iv = (byte*)des->reg;
-
-        if ((wolfssl_word)out % WOLFSSL_MMCAU_ALIGNMENT) {
-            WOLFSSL_MSG("Bad cau_des_encrypt alignment"); 
-            return BAD_ALIGN_E;
-        }
-
-        while (len > 0)
-        {
-            XMEMCPY(temp_block, in + offset, DES_BLOCK_SIZE);
-
-            /* XOR block with IV for CBC */
-            for (i = 0; i < DES_BLOCK_SIZE; i++)
-                temp_block[i] ^= iv[i];
-
-            cau_des_encrypt(temp_block, (byte*)des->key, out + offset);
-
-            len    -= DES_BLOCK_SIZE;
-            offset += DES_BLOCK_SIZE;
-
-            /* store IV for next block */
-            XMEMCPY(iv, out + offset - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
-        }
-
-        return 0;
-    }
-
-    int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
-    {
-        int i;
-        int offset = 0;
-        int len = sz;
-        byte* iv;
-        byte temp_block[DES_BLOCK_SIZE];
-
-        iv = (byte*)des->reg;
-
-        if ((wolfssl_word)out % WOLFSSL_MMCAU_ALIGNMENT) {
-            WOLFSSL_MSG("Bad cau_des_decrypt alignment"); 
-            return BAD_ALIGN_E;
-        }
-
-        while (len > 0)
-        {
-            XMEMCPY(temp_block, in + offset, DES_BLOCK_SIZE);
-
-            cau_des_decrypt(in + offset, (byte*)des->key, out + offset);
-
-            /* XOR block with IV for CBC */
-            for (i = 0; i < DES_BLOCK_SIZE; i++)
-                (out + offset)[i] ^= iv[i];
-
-            /* store IV for next block */
-            XMEMCPY(iv, temp_block, DES_BLOCK_SIZE);
-
-            len     -= DES_BLOCK_SIZE;
-            offset += DES_BLOCK_SIZE;
-        }
-
-        return 0;
-    }
-
-    int wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
-    {
-        int i;
-        int offset = 0;
-        int len = sz;
-
-        byte *iv;
-        byte temp_block[DES_BLOCK_SIZE];
-
-        iv = (byte*)des->reg;
-
-        if ((wolfssl_word)out % WOLFSSL_MMCAU_ALIGNMENT) {
-            WOLFSSL_MSG("Bad 3ede cau_des_encrypt alignment"); 
-            return BAD_ALIGN_E;
-        }
-
-        while (len > 0)
-        {
-            XMEMCPY(temp_block, in + offset, DES_BLOCK_SIZE);
-
-            /* XOR block with IV for CBC */
-            for (i = 0; i < DES_BLOCK_SIZE; i++)
-                temp_block[i] ^= iv[i];
-
-            cau_des_encrypt(temp_block  , (byte*)des->key[0], out + offset);
-            cau_des_decrypt(out + offset, (byte*)des->key[1], out + offset);
-            cau_des_encrypt(out + offset, (byte*)des->key[2], out + offset);
-
-            len    -= DES_BLOCK_SIZE;
-            offset += DES_BLOCK_SIZE;
-
-            /* store IV for next block */
-            XMEMCPY(iv, out + offset - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
-        }
-
-        return 0;
-    }
-
-    int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz)
-    {
-        int i;
-        int offset = 0;
-        int len = sz;
-
-        byte* iv;
-        byte temp_block[DES_BLOCK_SIZE];
-
-        iv = (byte*)des->reg;
-
-        if ((wolfssl_word)out % WOLFSSL_MMCAU_ALIGNMENT) {
-            WOLFSSL_MSG("Bad 3ede cau_des_decrypt alignment"); 
-            return BAD_ALIGN_E;
-        }
-
-        while (len > 0)
-        {
-            XMEMCPY(temp_block, in + offset, DES_BLOCK_SIZE);
-
-            cau_des_decrypt(in + offset , (byte*)des->key[2], out + offset);
-            cau_des_encrypt(out + offset, (byte*)des->key[1], out + offset);
-            cau_des_decrypt(out + offset, (byte*)des->key[0], out + offset);
-
-            /* XOR block with IV for CBC */
-            for (i = 0; i < DES_BLOCK_SIZE; i++)
-                (out + offset)[i] ^= iv[i];
-
-            /* store IV for next block */
-            XMEMCPY(iv, temp_block, DES_BLOCK_SIZE);
-
-            len    -= DES_BLOCK_SIZE;
-            offset += DES_BLOCK_SIZE;
-        }
-
-        return 0;
-    }
-
-
-#elif defined(WOLFSSL_PIC32MZ_CRYPT)
-
-    #include "wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h"
-
-void wc_Des_SetIV(Des* des, const byte* iv);
-int  wc_Des3_SetIV(Des3* des, const byte* iv);
-
-    int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
-    {
-        word32 *dkey = des->key ;
-        word32 *dreg = des->reg ;
-
-        XMEMCPY((byte *)dkey, (byte *)key, 8);
-        ByteReverseWords(dkey, dkey, 8);
-        XMEMCPY((byte *)dreg, (byte *)iv, 8);
-        ByteReverseWords(dreg, dreg, 8);
-
-        return 0;
-    }
-
-    int wc_Des3_SetKey(Des3* des, const byte* key, const byte* iv, int dir)
-    {
-        word32 *dkey1 = des->key[0];
-        word32 *dreg = des->reg ;
-
-        XMEMCPY(dkey1, key, 24);
-        ByteReverseWords(dkey1, dkey1, 24);
-        XMEMCPY(dreg, iv, 8);
-        ByteReverseWords(dreg, dreg, 8) ;
-
-        return 0;
-    }
-
-    void DesCrypt(word32 *key, word32 *iv, byte* out, const byte* in, word32 sz,
-                  int dir, int algo, int cryptoalgo)
-    {
-        securityAssociation *sa_p ;
-        bufferDescriptor *bd_p ;
-        const byte *in_p, *in_l ;
-        byte *out_p, *out_l ;
-        volatile securityAssociation sa __attribute__((aligned (8)));
-        volatile bufferDescriptor bd __attribute__((aligned (8)));
-        volatile int k ;
-        
-        /* get uncached address */
-
-        in_l = in;
-        out_l = out ;
-        sa_p = KVA0_TO_KVA1(&sa) ; 
-        bd_p = KVA0_TO_KVA1(&bd) ;
-        in_p = KVA0_TO_KVA1(in_l) ;
-        out_p= KVA0_TO_KVA1(out_l);
-        
-        if(PIC32MZ_IF_RAM(in_p))
-            XMEMCPY((void *)in_p, (void *)in, sz);
-        XMEMSET((void *)out_p, 0, sz);
-
-        /* Set up the Security Association */
-        XMEMSET((byte *)KVA0_TO_KVA1(&sa), 0, sizeof(sa));
-        sa_p->SA_CTRL.ALGO = algo ; 
-        sa_p->SA_CTRL.LNC = 1;
-        sa_p->SA_CTRL.LOADIV = 1;
-        sa_p->SA_CTRL.FB = 1;
-        sa_p->SA_CTRL.ENCTYPE = dir ; /* Encryption/Decryption */
-        sa_p->SA_CTRL.CRYPTOALGO = cryptoalgo;
-        sa_p->SA_CTRL.KEYSIZE = 1 ; /* KEY is 192 bits */
-        XMEMCPY((byte *)KVA0_TO_KVA1(&sa.SA_ENCKEY[algo==PIC32_ALGO_TDES ? 2 : 6]),
-                (byte *)key, algo==PIC32_ALGO_TDES ? 24 : 8);
-        XMEMCPY((byte *)KVA0_TO_KVA1(&sa.SA_ENCIV[2]), (byte *)iv, 8);
-
-        XMEMSET((byte *)KVA0_TO_KVA1(&bd), 0, sizeof(bd));
-        /* Set up the Buffer Descriptor */
-        bd_p->BD_CTRL.BUFLEN = sz;
-        bd_p->BD_CTRL.LIFM = 1;
-        bd_p->BD_CTRL.SA_FETCH_EN = 1;
-        bd_p->BD_CTRL.LAST_BD = 1;
-        bd_p->BD_CTRL.DESC_EN = 1;
-    
-        bd_p->SA_ADDR = (unsigned int)KVA_TO_PA(&sa) ; /* (unsigned int)sa_p; */
-        bd_p->SRCADDR = (unsigned int)KVA_TO_PA(in) ; /* (unsigned int)in_p; */
-        bd_p->DSTADDR = (unsigned int)KVA_TO_PA(out); /* (unsigned int)out_p; */
-        bd_p->NXTPTR = (unsigned int)KVA_TO_PA(&bd);
-        bd_p->MSGLEN = sz ;
-        
-        /* Fire in the hole! */
-        CECON = 1 << 6;
-        while (CECON);
-        
-        /* Run the engine */
-        CEBDPADDR = (unsigned int)KVA_TO_PA(&bd) ; /* (unsigned int)bd_p ; */
-        CEINTEN = 0x07;
-        CECON = 0x27;
-
-        WAIT_ENGINE ;
-
-        if((cryptoalgo == PIC32_CRYPTOALGO_CBC) ||
-           (cryptoalgo == PIC32_CRYPTOALGO_TCBC)||
-           (cryptoalgo == PIC32_CRYPTOALGO_RCBC)) {
-            /* set iv for the next call */
-            if(dir == PIC32_ENCRYPTION) {
-	        XMEMCPY((void *)iv, (void*)&(out_p[sz-DES_IVLEN]), DES_IVLEN) ;
-	        } else {
-                ByteReverseWords((word32*)iv, (word32 *)&(in_p[sz-DES_IVLEN]),
-                                 DES_IVLEN);
-	        }
-
-        }
-
-        ByteReverseWords((word32*)out, (word32 *)KVA0_TO_KVA1(out), sz);
-    }
-
-    int wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
-    {
-        DesCrypt(des->key, des->reg, out, in, sz, 
-                PIC32_ENCRYPTION, PIC32_ALGO_DES, PIC32_CRYPTOALGO_CBC );
-        return 0;
-    }
-
-    int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
-    {
-        DesCrypt(des->key, des->reg, out, in, sz, 
-                PIC32_DECRYPTION, PIC32_ALGO_DES, PIC32_CRYPTOALGO_CBC);
-        return 0;
-    }
-
-    int wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
-    {
-        DesCrypt(des->key[0], des->reg, out, in, sz, 
-                PIC32_ENCRYPTION, PIC32_ALGO_TDES, PIC32_CRYPTOALGO_TCBC);
-        return 0;
-    }
-
-    int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz)
-    {
-        DesCrypt(des->key[0], des->reg, out, in, sz, 
-                PIC32_DECRYPTION, PIC32_ALGO_TDES, PIC32_CRYPTOALGO_TCBC);
-        return 0;
-    }
-    
-#else /* CTaoCrypt software implementation */
-
-/* permuted choice table (key) */
-static const byte pc1[] = {
-       57, 49, 41, 33, 25, 17,  9,
-        1, 58, 50, 42, 34, 26, 18,
-       10,  2, 59, 51, 43, 35, 27,
-       19, 11,  3, 60, 52, 44, 36,
-
-       63, 55, 47, 39, 31, 23, 15,
-        7, 62, 54, 46, 38, 30, 22,
-       14,  6, 61, 53, 45, 37, 29,
-       21, 13,  5, 28, 20, 12,  4
-};
-
-/* number left rotations of pc1 */
-static const byte totrot[] = {
-       1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28
-};
-
-/* permuted choice key (table) */
-static const byte pc2[] = {
-       14, 17, 11, 24,  1,  5,
-        3, 28, 15,  6, 21, 10,
-       23, 19, 12,  4, 26,  8,
-       16,  7, 27, 20, 13,  2,
-       41, 52, 31, 37, 47, 55,
-       30, 40, 51, 45, 33, 48,
-       44, 49, 39, 56, 34, 53,
-       46, 42, 50, 36, 29, 32
-};
-
-/* End of DES-defined tables */
-
-/* bit 0 is left-most in byte */
-static const int bytebit[] = {
-       0200,0100,040,020,010,04,02,01
-};
-
-static const word32 Spbox[8][64] = {
-{
-0x01010400,0x00000000,0x00010000,0x01010404,
-0x01010004,0x00010404,0x00000004,0x00010000,
-0x00000400,0x01010400,0x01010404,0x00000400,
-0x01000404,0x01010004,0x01000000,0x00000004,
-0x00000404,0x01000400,0x01000400,0x00010400,
-0x00010400,0x01010000,0x01010000,0x01000404,
-0x00010004,0x01000004,0x01000004,0x00010004,
-0x00000000,0x00000404,0x00010404,0x01000000,
-0x00010000,0x01010404,0x00000004,0x01010000,
-0x01010400,0x01000000,0x01000000,0x00000400,
-0x01010004,0x00010000,0x00010400,0x01000004,
-0x00000400,0x00000004,0x01000404,0x00010404,
-0x01010404,0x00010004,0x01010000,0x01000404,
-0x01000004,0x00000404,0x00010404,0x01010400,
-0x00000404,0x01000400,0x01000400,0x00000000,
-0x00010004,0x00010400,0x00000000,0x01010004},
-{
-0x80108020,0x80008000,0x00008000,0x00108020,
-0x00100000,0x00000020,0x80100020,0x80008020,
-0x80000020,0x80108020,0x80108000,0x80000000,
-0x80008000,0x00100000,0x00000020,0x80100020,
-0x00108000,0x00100020,0x80008020,0x00000000,
-0x80000000,0x00008000,0x00108020,0x80100000,
-0x00100020,0x80000020,0x00000000,0x00108000,
-0x00008020,0x80108000,0x80100000,0x00008020,
-0x00000000,0x00108020,0x80100020,0x00100000,
-0x80008020,0x80100000,0x80108000,0x00008000,
-0x80100000,0x80008000,0x00000020,0x80108020,
-0x00108020,0x00000020,0x00008000,0x80000000,
-0x00008020,0x80108000,0x00100000,0x80000020,
-0x00100020,0x80008020,0x80000020,0x00100020,
-0x00108000,0x00000000,0x80008000,0x00008020,
-0x80000000,0x80100020,0x80108020,0x00108000},
-{
-0x00000208,0x08020200,0x00000000,0x08020008,
-0x08000200,0x00000000,0x00020208,0x08000200,
-0x00020008,0x08000008,0x08000008,0x00020000,
-0x08020208,0x00020008,0x08020000,0x00000208,
-0x08000000,0x00000008,0x08020200,0x00000200,
-0x00020200,0x08020000,0x08020008,0x00020208,
-0x08000208,0x00020200,0x00020000,0x08000208,
-0x00000008,0x08020208,0x00000200,0x08000000,
-0x08020200,0x08000000,0x00020008,0x00000208,
-0x00020000,0x08020200,0x08000200,0x00000000,
-0x00000200,0x00020008,0x08020208,0x08000200,
-0x08000008,0x00000200,0x00000000,0x08020008,
-0x08000208,0x00020000,0x08000000,0x08020208,
-0x00000008,0x00020208,0x00020200,0x08000008,
-0x08020000,0x08000208,0x00000208,0x08020000,
-0x00020208,0x00000008,0x08020008,0x00020200},
-{
-0x00802001,0x00002081,0x00002081,0x00000080,
-0x00802080,0x00800081,0x00800001,0x00002001,
-0x00000000,0x00802000,0x00802000,0x00802081,
-0x00000081,0x00000000,0x00800080,0x00800001,
-0x00000001,0x00002000,0x00800000,0x00802001,
-0x00000080,0x00800000,0x00002001,0x00002080,
-0x00800081,0x00000001,0x00002080,0x00800080,
-0x00002000,0x00802080,0x00802081,0x00000081,
-0x00800080,0x00800001,0x00802000,0x00802081,
-0x00000081,0x00000000,0x00000000,0x00802000,
-0x00002080,0x00800080,0x00800081,0x00000001,
-0x00802001,0x00002081,0x00002081,0x00000080,
-0x00802081,0x00000081,0x00000001,0x00002000,
-0x00800001,0x00002001,0x00802080,0x00800081,
-0x00002001,0x00002080,0x00800000,0x00802001,
-0x00000080,0x00800000,0x00002000,0x00802080},
-{
-0x00000100,0x02080100,0x02080000,0x42000100,
-0x00080000,0x00000100,0x40000000,0x02080000,
-0x40080100,0x00080000,0x02000100,0x40080100,
-0x42000100,0x42080000,0x00080100,0x40000000,
-0x02000000,0x40080000,0x40080000,0x00000000,
-0x40000100,0x42080100,0x42080100,0x02000100,
-0x42080000,0x40000100,0x00000000,0x42000000,
-0x02080100,0x02000000,0x42000000,0x00080100,
-0x00080000,0x42000100,0x00000100,0x02000000,
-0x40000000,0x02080000,0x42000100,0x40080100,
-0x02000100,0x40000000,0x42080000,0x02080100,
-0x40080100,0x00000100,0x02000000,0x42080000,
-0x42080100,0x00080100,0x42000000,0x42080100,
-0x02080000,0x00000000,0x40080000,0x42000000,
-0x00080100,0x02000100,0x40000100,0x00080000,
-0x00000000,0x40080000,0x02080100,0x40000100},
-{
-0x20000010,0x20400000,0x00004000,0x20404010,
-0x20400000,0x00000010,0x20404010,0x00400000,
-0x20004000,0x00404010,0x00400000,0x20000010,
-0x00400010,0x20004000,0x20000000,0x00004010,
-0x00000000,0x00400010,0x20004010,0x00004000,
-0x00404000,0x20004010,0x00000010,0x20400010,
-0x20400010,0x00000000,0x00404010,0x20404000,
-0x00004010,0x00404000,0x20404000,0x20000000,
-0x20004000,0x00000010,0x20400010,0x00404000,
-0x20404010,0x00400000,0x00004010,0x20000010,
-0x00400000,0x20004000,0x20000000,0x00004010,
-0x20000010,0x20404010,0x00404000,0x20400000,
-0x00404010,0x20404000,0x00000000,0x20400010,
-0x00000010,0x00004000,0x20400000,0x00404010,
-0x00004000,0x00400010,0x20004010,0x00000000,
-0x20404000,0x20000000,0x00400010,0x20004010},
-{
-0x00200000,0x04200002,0x04000802,0x00000000,
-0x00000800,0x04000802,0x00200802,0x04200800,
-0x04200802,0x00200000,0x00000000,0x04000002,
-0x00000002,0x04000000,0x04200002,0x00000802,
-0x04000800,0x00200802,0x00200002,0x04000800,
-0x04000002,0x04200000,0x04200800,0x00200002,
-0x04200000,0x00000800,0x00000802,0x04200802,
-0x00200800,0x00000002,0x04000000,0x00200800,
-0x04000000,0x00200800,0x00200000,0x04000802,
-0x04000802,0x04200002,0x04200002,0x00000002,
-0x00200002,0x04000000,0x04000800,0x00200000,
-0x04200800,0x00000802,0x00200802,0x04200800,
-0x00000802,0x04000002,0x04200802,0x04200000,
-0x00200800,0x00000000,0x00000002,0x04200802,
-0x00000000,0x00200802,0x04200000,0x00000800,
-0x04000002,0x04000800,0x00000800,0x00200002},
-{
-0x10001040,0x00001000,0x00040000,0x10041040,
-0x10000000,0x10001040,0x00000040,0x10000000,
-0x00040040,0x10040000,0x10041040,0x00041000,
-0x10041000,0x00041040,0x00001000,0x00000040,
-0x10040000,0x10000040,0x10001000,0x00001040,
-0x00041000,0x00040040,0x10040040,0x10041000,
-0x00001040,0x00000000,0x00000000,0x10040040,
-0x10000040,0x10001000,0x00041040,0x00040000,
-0x00041040,0x00040000,0x10041000,0x00001000,
-0x00000040,0x10040040,0x00001000,0x00041040,
-0x10001000,0x00000040,0x10000040,0x10040000,
-0x10040040,0x10000000,0x00040000,0x10001040,
-0x00000000,0x10041040,0x00040040,0x10000040,
-0x10040000,0x10001000,0x10001040,0x00000000,
-0x10041040,0x00041000,0x00041000,0x00001040,
-0x00001040,0x00040040,0x10000000,0x10041000}
-};
-
-
-static INLINE void IPERM(word32* left, word32* right)
-{
-    word32 work;
-
-    *right = rotlFixed(*right, 4U);
-    work = (*left ^ *right) & 0xf0f0f0f0;
-    *left ^= work;
-
-    *right = rotrFixed(*right^work, 20U);
-    work = (*left ^ *right) & 0xffff0000;
-    *left ^= work;
-
-    *right = rotrFixed(*right^work, 18U);
-    work = (*left ^ *right) & 0x33333333;
-    *left ^= work;
-
-    *right = rotrFixed(*right^work, 6U);
-    work = (*left ^ *right) & 0x00ff00ff;
-    *left ^= work;
-
-    *right = rotlFixed(*right^work, 9U);
-    work = (*left ^ *right) & 0xaaaaaaaa;
-    *left = rotlFixed(*left^work, 1U);
-    *right ^= work;
-}
-
-
-static INLINE void FPERM(word32* left, word32* right)
-{
-    word32 work;
-
-    *right = rotrFixed(*right, 1U);
-    work = (*left ^ *right) & 0xaaaaaaaa;
-    *right ^= work;
-
-    *left = rotrFixed(*left^work, 9U);
-    work = (*left ^ *right) & 0x00ff00ff;
-    *right ^= work;
-
-    *left = rotlFixed(*left^work, 6U);
-    work = (*left ^ *right) & 0x33333333;
-    *right ^= work;
-
-    *left = rotlFixed(*left^work, 18U);
-    work = (*left ^ *right) & 0xffff0000;
-    *right ^= work;
-
-    *left = rotlFixed(*left^work, 20U);
-    work = (*left ^ *right) & 0xf0f0f0f0;
-    *right ^= work;
-
-    *left = rotrFixed(*left^work, 4U);
-}
-
-
-static int DesSetKey(const byte* key, int dir, word32* out)
-{
-#ifdef WOLFSSL_SMALL_STACK
-    byte* buffer = (byte*)XMALLOC(56+56+8, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-    if (buffer == NULL)
-        return MEMORY_E;
-#else
-    byte buffer[56+56+8];
-#endif
-
-    {
-        byte* const  pc1m = buffer;               /* place to modify pc1 into */
-        byte* const  pcr  = pc1m + 56;            /* place to rotate pc1 into */
-        byte* const  ks   = pcr  + 56;
-        register int i, j, l;
-        int          m;
-
-        for (j = 0; j < 56; j++) {             /* convert pc1 to bits of key  */
-            l = pc1[j] - 1;                    /* integer bit location        */
-            m = l & 07;                        /* find bit                    */
-            pc1m[j] = (key[l >> 3] &           /* find which key byte l is in */
-                bytebit[m])                    /* and which bit of that byte  */
-                ? 1 : 0;                       /* and store 1-bit result      */
-        }
-
-        for (i = 0; i < 16; i++) {            /* key chunk for each iteration */
-            XMEMSET(ks, 0, 8);                /* Clear key schedule */
-
-            for (j = 0; j < 56; j++)          /* rotate pc1 the right amount  */
-                pcr[j] =
-                      pc1m[(l = j + totrot[i]) < (j < 28 ? 28 : 56) ? l : l-28];
-
-            /* rotate left and right halves independently */
-            for (j = 0; j < 48; j++) {        /* select bits individually     */
-                if (pcr[pc2[j] - 1]) {        /* check bit that goes to ks[j] */
-                    l= j % 6;                 /* mask it in if it's there     */
-                    ks[j/6] |= bytebit[l] >> 2;
-                }
-            }
-
-            /* Now convert to odd/even interleaved form for use in F */
-            out[2*i] = ((word32) ks[0] << 24)
-                     | ((word32) ks[2] << 16)
-                     | ((word32) ks[4] << 8)
-                     | ((word32) ks[6]);
-
-            out[2*i + 1] = ((word32) ks[1] << 24)
-                         | ((word32) ks[3] << 16)
-                         | ((word32) ks[5] << 8)
-                         | ((word32) ks[7]);
-        }
-
-        /* reverse key schedule order */
-        if (dir == DES_DECRYPTION) {
-            for (i = 0; i < 16; i += 2) {
-                word32 swap = out[i];
-                out[i] = out[DES_KS_SIZE - 2 - i];
-                out[DES_KS_SIZE - 2 - i] = swap;
-    
-                swap = out[i + 1];
-                out[i + 1] = out[DES_KS_SIZE - 1 - i];
-                out[DES_KS_SIZE - 1 - i] = swap;
-            }
-        }
-
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-    }
-
-    return 0;
-}
-
-
-static INLINE int Reverse(int dir)
-{
-    return !dir;
-}
-
-
-int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
-{
-    wc_Des_SetIV(des, iv);
-
-    return DesSetKey(key, dir, des->key);
-}
-
-
-int wc_Des3_SetKey(Des3* des, const byte* key, const byte* iv, int dir)
-{
-    int ret;
-
-#ifdef HAVE_CAVIUM
-    if (des->magic == WOLFSSL_3DES_CAVIUM_MAGIC)
-        return wc_Des3_CaviumSetKey(des, key, iv);
-#endif
-
-    ret = DesSetKey(key + (dir == DES_ENCRYPTION ? 0:16), dir, des->key[0]);
-    if (ret != 0)
-        return ret;
-
-    ret = DesSetKey(key + 8, Reverse(dir), des->key[1]);
-    if (ret != 0)
-        return ret;
-
-    ret = DesSetKey(key + (dir == DES_DECRYPTION ? 0:16), dir, des->key[2]);
-    if (ret != 0)
-        return ret;
-
-    return wc_Des3_SetIV(des, iv);
-}
-
-
-static void DesRawProcessBlock(word32* lIn, word32* rIn, const word32* kptr)
-{
-    word32 l = *lIn, r = *rIn, i;
-
-    for (i=0; i<8; i++)
-    {
-        word32 work = rotrFixed(r, 4U) ^ kptr[4*i+0];
-        l ^= Spbox[6][(work) & 0x3f]
-          ^  Spbox[4][(work >> 8) & 0x3f]
-          ^  Spbox[2][(work >> 16) & 0x3f]
-          ^  Spbox[0][(work >> 24) & 0x3f];
-        work = r ^ kptr[4*i+1];
-        l ^= Spbox[7][(work) & 0x3f]
-          ^  Spbox[5][(work >> 8) & 0x3f]
-          ^  Spbox[3][(work >> 16) & 0x3f]
-          ^  Spbox[1][(work >> 24) & 0x3f];
-
-        work = rotrFixed(l, 4U) ^ kptr[4*i+2];
-        r ^= Spbox[6][(work) & 0x3f]
-          ^  Spbox[4][(work >> 8) & 0x3f]
-          ^  Spbox[2][(work >> 16) & 0x3f]
-          ^  Spbox[0][(work >> 24) & 0x3f];
-        work = l ^ kptr[4*i+3];
-        r ^= Spbox[7][(work) & 0x3f]
-          ^  Spbox[5][(work >> 8) & 0x3f]
-          ^  Spbox[3][(work >> 16) & 0x3f]
-          ^  Spbox[1][(work >> 24) & 0x3f];
-    }
-
-    *lIn = l; *rIn = r;
-}
-
-
-static void DesProcessBlock(Des* des, const byte* in, byte* out)
-{
-    word32 l, r;
-
-    XMEMCPY(&l, in, sizeof(l));
-    XMEMCPY(&r, in + sizeof(l), sizeof(r));
-    #ifdef LITTLE_ENDIAN_ORDER
-        l = ByteReverseWord32(l);
-        r = ByteReverseWord32(r);
-    #endif
-    IPERM(&l,&r);
-    
-    DesRawProcessBlock(&l, &r, des->key);   
-
-    FPERM(&l,&r);
-    #ifdef LITTLE_ENDIAN_ORDER
-        l = ByteReverseWord32(l);
-        r = ByteReverseWord32(r);
-    #endif
-    XMEMCPY(out, &r, sizeof(r));
-    XMEMCPY(out + sizeof(r), &l, sizeof(l));
-}
-
-
-static void Des3ProcessBlock(Des3* des, const byte* in, byte* out)
-{
-    word32 l, r;
-
-    XMEMCPY(&l, in, sizeof(l));
-    XMEMCPY(&r, in + sizeof(l), sizeof(r));
-    #ifdef LITTLE_ENDIAN_ORDER
-        l = ByteReverseWord32(l);
-        r = ByteReverseWord32(r);
-    #endif
-    IPERM(&l,&r);
-    
-    DesRawProcessBlock(&l, &r, des->key[0]);   
-    DesRawProcessBlock(&r, &l, des->key[1]);   
-    DesRawProcessBlock(&l, &r, des->key[2]);   
-
-    FPERM(&l,&r);
-    #ifdef LITTLE_ENDIAN_ORDER
-        l = ByteReverseWord32(l);
-        r = ByteReverseWord32(r);
-    #endif
-    XMEMCPY(out, &r, sizeof(r));
-    XMEMCPY(out + sizeof(r), &l, sizeof(l));
-}
-
-
-int wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
-{
-    word32 blocks = sz / DES_BLOCK_SIZE;
-
-    while (blocks--) {
-        xorbuf((byte*)des->reg, in, DES_BLOCK_SIZE);
-        DesProcessBlock(des, (byte*)des->reg, (byte*)des->reg);
-        XMEMCPY(out, des->reg, DES_BLOCK_SIZE);
-
-        out += DES_BLOCK_SIZE;
-        in  += DES_BLOCK_SIZE; 
-    }
-    return 0;
-}
-
-
-int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
-{
-    word32 blocks = sz / DES_BLOCK_SIZE;
-    byte   hold[DES_BLOCK_SIZE];
-
-    while (blocks--) {
-        XMEMCPY(des->tmp, in, DES_BLOCK_SIZE);
-        DesProcessBlock(des, (byte*)des->tmp, out);
-        xorbuf(out, (byte*)des->reg, DES_BLOCK_SIZE);
-
-        XMEMCPY(hold, des->reg, DES_BLOCK_SIZE);
-        XMEMCPY(des->reg, des->tmp, DES_BLOCK_SIZE);
-        XMEMCPY(des->tmp, hold, DES_BLOCK_SIZE);
-
-        out += DES_BLOCK_SIZE;
-        in  += DES_BLOCK_SIZE; 
-    }
-    return 0;
-}
-
-
-int wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
-{
-    word32 blocks;
-
-#ifdef HAVE_CAVIUM
-    if (des->magic == WOLFSSL_3DES_CAVIUM_MAGIC)
-        return wc_Des3_CaviumCbcEncrypt(des, out, in, sz);
-#endif
-
-    blocks = sz / DES_BLOCK_SIZE;
-    while (blocks--) {
-        xorbuf((byte*)des->reg, in, DES_BLOCK_SIZE);
-        Des3ProcessBlock(des, (byte*)des->reg, (byte*)des->reg);
-        XMEMCPY(out, des->reg, DES_BLOCK_SIZE);
-
-        out += DES_BLOCK_SIZE;
-        in  += DES_BLOCK_SIZE; 
-    }
-    return 0;
-}
-
-
-int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz)
-{
-    word32 blocks;
-
-#ifdef HAVE_CAVIUM
-    if (des->magic == WOLFSSL_3DES_CAVIUM_MAGIC)
-        return wc_Des3_CaviumCbcDecrypt(des, out, in, sz);
-#endif
-
-    blocks = sz / DES_BLOCK_SIZE;
-    while (blocks--) {
-        XMEMCPY(des->tmp, in, DES_BLOCK_SIZE);
-        Des3ProcessBlock(des, (byte*)des->tmp, out);
-        xorbuf(out, (byte*)des->reg, DES_BLOCK_SIZE);
-        XMEMCPY(des->reg, des->tmp, DES_BLOCK_SIZE);
-
-        out += DES_BLOCK_SIZE;
-        in  += DES_BLOCK_SIZE; 
-    }
-    return 0;
-}
-
-#ifdef WOLFSSL_DES_ECB
-
-/* One block, compatibility only */
-int wc_Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz)
-{
-    word32 blocks = sz / DES_BLOCK_SIZE;
-
-    while (blocks--) {
-        DesProcessBlock(des, in, out);
-
-        out += DES_BLOCK_SIZE;
-        in  += DES_BLOCK_SIZE; 
-    }
-    return 0;
-}
-
-#endif /* WOLFSSL_DES_ECB */
-
-#endif /* STM32F2_CRYPTO */
-
-void wc_Des_SetIV(Des* des, const byte* iv)
-{
-    if (des && iv)
-        XMEMCPY(des->reg, iv, DES_BLOCK_SIZE);
-    else if (des)
-        XMEMSET(des->reg,  0, DES_BLOCK_SIZE);
-}
-
-
-int wc_Des_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
-                                                const byte* key, const byte* iv)
-{
-    int ret  = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    Des* des = NULL;
-#else
-    Des  des[1];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    des = (Des*)XMALLOC(sizeof(Des), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (des == NULL)
-        return MEMORY_E;
-#endif
-
-    ret = wc_Des_SetKey(des, key, iv, DES_DECRYPTION);
-    if (ret == 0)
-        ret = wc_Des_CbcDecrypt(des, out, in, sz); 
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(des, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-int wc_Des3_SetIV(Des3* des, const byte* iv)
-{
-    if (des && iv)
-        XMEMCPY(des->reg, iv, DES_BLOCK_SIZE);
-    else if (des)
-        XMEMSET(des->reg,  0, DES_BLOCK_SIZE);
-
-    return 0;
-}
-
-
-int wc_Des3_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
-                                                const byte* key, const byte* iv)
-{
-    int ret    = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    Des3* des3 = NULL;
-#else
-    Des3  des3[1];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    des3 = (Des3*)XMALLOC(sizeof(Des3), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (des3 == NULL)
-        return MEMORY_E;
-#endif
-
-    ret = wc_Des3_SetKey(des3, key, iv, DES_DECRYPTION);
-    if (ret == 0)
-        ret = wc_Des3_CbcDecrypt(des3, out, in, sz); 
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(des3, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-#ifdef HAVE_CAVIUM
-
-#include "cavium_common.h"
-
-/* Initiliaze Des3 for use with Nitrox device */
-int wc_Des3_InitCavium(Des3* des3, int devId)
-{
-    if (des3 == NULL)
-        return -1;
-
-    if (CspAllocContext(CONTEXT_SSL, &des3->contextHandle, devId) != 0)
-        return -1;
-
-    des3->devId = devId;
-    des3->magic = WOLFSSL_3DES_CAVIUM_MAGIC;
-   
-    return 0;
-}
-
-
-/* Free Des3 from use with Nitrox device */
-void wc_Des3_FreeCavium(Des3* des3)
-{
-    if (des3 == NULL)
-        return;
-
-    if (des3->magic != WOLFSSL_3DES_CAVIUM_MAGIC)
-        return;
-
-    CspFreeContext(CONTEXT_SSL, des3->contextHandle, des3->devId);
-    des3->magic = 0;
-}
-
-
-static int wc_Des3_CaviumSetKey(Des3* des3, const byte* key, const byte* iv)
-{
-    if (des3 == NULL)
-        return -1;
-
-    /* key[0] holds key, iv in reg */
-    XMEMCPY(des3->key[0], key, DES_BLOCK_SIZE*3);
-
-    return wc_Des3_SetIV(des3, iv);
-}
-
-
-static int wc_Des3_CaviumCbcEncrypt(Des3* des3, byte* out, const byte* in,
-                                  word32 length)
-{
-    wolfssl_word offset = 0;
-    word32 requestId;
-   
-    while (length > WOLFSSL_MAX_16BIT) {
-        word16 slen = (word16)WOLFSSL_MAX_16BIT;
-        if (CspEncrypt3Des(CAVIUM_BLOCKING, des3->contextHandle,
-                           CAVIUM_NO_UPDATE, slen, (byte*)in + offset,
-                           out + offset, (byte*)des3->reg, (byte*)des3->key[0],
-                           &requestId, des3->devId) != 0) {
-            WOLFSSL_MSG("Bad Cavium 3DES Cbc Encrypt");
-            return -1;
-        }
-        length -= WOLFSSL_MAX_16BIT;
-        offset += WOLFSSL_MAX_16BIT;
-        XMEMCPY(des3->reg, out + offset - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
-    }
-    if (length) {
-        word16 slen = (word16)length;
-
-        if (CspEncrypt3Des(CAVIUM_BLOCKING, des3->contextHandle,
-                           CAVIUM_NO_UPDATE, slen, (byte*)in + offset,
-                           out + offset, (byte*)des3->reg, (byte*)des3->key[0],
-                           &requestId, des3->devId) != 0) {
-            WOLFSSL_MSG("Bad Cavium 3DES Cbc Encrypt");
-            return -1;
-        }
-        XMEMCPY(des3->reg, out+offset+length - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
-    }
-    return 0;
-}
-
-static int wc_Des3_CaviumCbcDecrypt(Des3* des3, byte* out, const byte* in,
-                                 word32 length)
-{
-    word32 requestId;
-    wolfssl_word offset = 0;
-
-    while (length > WOLFSSL_MAX_16BIT) {
-        word16 slen = (word16)WOLFSSL_MAX_16BIT;
-        XMEMCPY(des3->tmp, in + offset + slen - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
-        if (CspDecrypt3Des(CAVIUM_BLOCKING, des3->contextHandle,
-                           CAVIUM_NO_UPDATE, slen, (byte*)in+offset, out+offset,
-                           (byte*)des3->reg, (byte*)des3->key[0], &requestId,
-                           des3->devId) != 0) {
-            WOLFSSL_MSG("Bad Cavium 3Des Decrypt");
-            return -1;
-        }
-        length -= WOLFSSL_MAX_16BIT;
-        offset += WOLFSSL_MAX_16BIT;
-        XMEMCPY(des3->reg, des3->tmp, DES_BLOCK_SIZE);
-    }
-    if (length) {
-        word16 slen = (word16)length;
-        XMEMCPY(des3->tmp, in + offset + slen - DES_BLOCK_SIZE,DES_BLOCK_SIZE);
-        if (CspDecrypt3Des(CAVIUM_BLOCKING, des3->contextHandle,
-                           CAVIUM_NO_UPDATE, slen, (byte*)in+offset, out+offset,
-                           (byte*)des3->reg, (byte*)des3->key[0], &requestId,
-                           des3->devId) != 0) {
-            WOLFSSL_MSG("Bad Cavium 3Des Decrypt");
-            return -1;
-        }
-        XMEMCPY(des3->reg, des3->tmp, DES_BLOCK_SIZE);
-    }
-    return 0;
-}
-
-#endif /* HAVE_CAVIUM */
-#endif /* WOLFSSL_TI_CRYPT */
-#endif /* HAVE_FIPS */
-#endif /* NO_DES3 */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/dh.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/dh.c
deleted file mode 100755
index bc4ce11..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/dh.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/* dh.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef NO_DH
-
-#include 
-#include 
-
-#ifndef USER_MATH_LIB
-    #include 
-    #define XPOW(x,y) pow((x),(y))
-    #define XLOG(x)   log((x))
-#else
-    /* user's own math lib */
-#endif
-
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-
-void wc_InitDhKey(DhKey* key)
-{
-    (void)key;
-/* TomsFastMath doesn't use memory allocation */
-#ifndef USE_FAST_MATH
-    key->p.dp = 0;
-    key->g.dp = 0;
-#endif
-}
-
-
-void wc_FreeDhKey(DhKey* key)
-{
-    (void)key;
-/* TomsFastMath doesn't use memory allocation */
-#ifndef USE_FAST_MATH
-    mp_clear(&key->p);
-    mp_clear(&key->g);
-#endif
-}
-
-
-static word32 DiscreteLogWorkFactor(word32 n)
-{
-    /* assuming discrete log takes about the same time as factoring */
-    if (n<5)
-        return 0;
-    else
-        return (word32)(2.4 * XPOW((double)n, 1.0/3.0) *
-                XPOW(XLOG((double)n), 2.0/3.0) - 5);
-}
-
-
-static int GeneratePrivate(DhKey* key, RNG* rng, byte* priv, word32* privSz)
-{
-    int ret;
-    word32 sz = mp_unsigned_bin_size(&key->p);
-    sz = min(sz, 2 * DiscreteLogWorkFactor(sz * WOLFSSL_BIT_SIZE) /
-                                           WOLFSSL_BIT_SIZE + 1);
-
-    ret = wc_RNG_GenerateBlock(rng, priv, sz);
-    if (ret != 0)
-        return ret;
-
-    priv[0] |= 0x0C;
-
-    *privSz = sz;
-
-    return 0;
-}
-
-
-static int GeneratePublic(DhKey* key, const byte* priv, word32 privSz,
-                          byte* pub, word32* pubSz)
-{
-    int ret = 0;
-
-    mp_int x; 
-    mp_int y;
-
-    if (mp_init_multi(&x, &y, 0, 0, 0, 0) != MP_OKAY)
-        return MP_INIT_E;
-
-    if (mp_read_unsigned_bin(&x, priv, privSz) != MP_OKAY)
-        ret = MP_READ_E;
-
-    if (ret == 0 && mp_exptmod(&key->g, &x, &key->p, &y) != MP_OKAY)
-        ret = MP_EXPTMOD_E;
-
-    if (ret == 0 && mp_to_unsigned_bin(&y, pub) != MP_OKAY)
-        ret = MP_TO_E;
-
-    if (ret == 0)
-        *pubSz = mp_unsigned_bin_size(&y);
-
-    mp_clear(&y);
-    mp_clear(&x);
-
-    return ret;
-}
-
-
-int wc_DhGenerateKeyPair(DhKey* key, RNG* rng, byte* priv, word32* privSz,
-                      byte* pub, word32* pubSz)
-{
-    int ret = GeneratePrivate(key, rng, priv, privSz);
-
-    return (ret != 0) ? ret : GeneratePublic(key, priv, *privSz, pub, pubSz);
-}
-
-int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz, const byte* priv,
-            word32 privSz, const byte* otherPub, word32 pubSz)
-{
-    int ret = 0;
-
-    mp_int x; 
-    mp_int y;
-    mp_int z;
-
-    if (mp_init_multi(&x, &y, &z, 0, 0, 0) != MP_OKAY)
-        return MP_INIT_E;
-
-    if (mp_read_unsigned_bin(&x, priv, privSz) != MP_OKAY)
-        ret = MP_READ_E;
-
-    if (ret == 0 && mp_read_unsigned_bin(&y, otherPub, pubSz) != MP_OKAY)
-        ret = MP_READ_E;
-
-    if (ret == 0 && mp_exptmod(&y, &x, &key->p, &z) != MP_OKAY)
-        ret = MP_EXPTMOD_E;
-
-    if (ret == 0 && mp_to_unsigned_bin(&z, agree) != MP_OKAY)
-        ret = MP_TO_E;
-
-    if (ret == 0)
-        *agreeSz = mp_unsigned_bin_size(&z);
-
-    mp_clear(&z);
-    mp_clear(&y);
-    mp_clear(&x);
-
-    return ret;
-}
-
-
-/* not in asn anymore since no actual asn types used */
-int wc_DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
-                word32 gSz)
-{
-    if (key == NULL || p == NULL || g == NULL || pSz == 0 || gSz == 0)
-        return BAD_FUNC_ARG;
-
-    /* may have leading 0 */
-    if (p[0] == 0) {
-        pSz--; p++;
-    }
-
-    if (g[0] == 0) {
-        gSz--; g++;
-    }
-
-    if (mp_init(&key->p) != MP_OKAY)
-        return MP_INIT_E;
-    if (mp_read_unsigned_bin(&key->p, p, pSz) != 0) {
-        mp_clear(&key->p);
-        return ASN_DH_KEY_E;
-    }
-
-    if (mp_init(&key->g) != MP_OKAY) {
-        mp_clear(&key->p);
-        return MP_INIT_E;
-    }
-    if (mp_read_unsigned_bin(&key->g, g, gSz) != 0) {
-        mp_clear(&key->g);
-        mp_clear(&key->p);
-        return ASN_DH_KEY_E;
-    }
-
-    return 0;
-}
-
-
-#endif /* NO_DH */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/dsa.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/dsa.c
deleted file mode 100755
index f2124b1..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/dsa.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/* dsa.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef NO_DSA
-
-#include 
-#include 
-#include 
-#include 
-
-
-enum {
-    DSA_HALF_SIZE = 20,   /* r and s size  */
-    DSA_SIG_SIZE  = 40    /* signature size */
-};
-
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-
-void wc_InitDsaKey(DsaKey* key)
-{
-    key->type = -1;  /* haven't decided yet */
-
-/* TomsFastMath doesn't use memory allocation */
-#ifndef USE_FAST_MATH
-    key->p.dp = 0;   /* public  alloc parts */
-    key->q.dp = 0;    
-    key->g.dp = 0;    
-    key->y.dp = 0;    
-
-    key->x.dp = 0;   /* private alloc parts */
-#endif
-}
-
-
-void wc_FreeDsaKey(DsaKey* key)
-{
-    (void)key;
-/* TomsFastMath doesn't use memory allocation */
-#ifndef USE_FAST_MATH
-    if (key->type == DSA_PRIVATE)
-        mp_clear(&key->x);
-    mp_clear(&key->y);
-    mp_clear(&key->g);
-    mp_clear(&key->q);
-    mp_clear(&key->p);
-#endif
-}
-
-
-int wc_DsaSign(const byte* digest, byte* out, DsaKey* key, RNG* rng)
-{
-    mp_int k, kInv, r, s, H;
-    int    ret, sz;
-    byte   buffer[DSA_HALF_SIZE];
-
-    sz = min(sizeof(buffer), mp_unsigned_bin_size(&key->q));
-
-    /* generate k */
-    ret = wc_RNG_GenerateBlock(rng, buffer, sz);
-    if (ret != 0)
-        return ret;
-
-    buffer[0] |= 0x0C;
-
-    if (mp_init_multi(&k, &kInv, &r, &s, &H, 0) != MP_OKAY)
-        return MP_INIT_E;
-
-    if (mp_read_unsigned_bin(&k, buffer, sz) != MP_OKAY)
-        ret = MP_READ_E;
-
-    if (ret == 0 && mp_cmp_d(&k, 1) != MP_GT)
-        ret = MP_CMP_E;
-
-    /* inverse k mod q */
-    if (ret == 0 && mp_invmod(&k, &key->q, &kInv) != MP_OKAY)
-        ret = MP_INVMOD_E;
-
-    /* generate r, r = (g exp k mod p) mod q */
-    if (ret == 0 && mp_exptmod(&key->g, &k, &key->p, &r) != MP_OKAY)
-        ret = MP_EXPTMOD_E;
-
-    if (ret == 0 && mp_mod(&r, &key->q, &r) != MP_OKAY)
-        ret = MP_MOD_E;
-
-    /* generate H from sha digest */
-    if (ret == 0 && mp_read_unsigned_bin(&H, digest,SHA_DIGEST_SIZE) != MP_OKAY)
-        ret = MP_READ_E;
-
-    /* generate s, s = (kInv * (H + x*r)) % q */
-    if (ret == 0 && mp_mul(&key->x, &r, &s) != MP_OKAY)
-        ret = MP_MUL_E;
-
-    if (ret == 0 && mp_add(&s, &H, &s) != MP_OKAY)
-        ret = MP_ADD_E;
-
-    if (ret == 0 && mp_mulmod(&s, &kInv, &key->q, &s) != MP_OKAY)
-        ret = MP_MULMOD_E;
-
-    /* write out */
-    if (ret == 0)  {
-        int rSz = mp_unsigned_bin_size(&r);
-        int sSz = mp_unsigned_bin_size(&s);
-
-        if (rSz == DSA_HALF_SIZE - 1) {
-            out[0] = 0;
-            out++;
-        }
-
-        if (mp_to_unsigned_bin(&r, out) != MP_OKAY)
-            ret = MP_TO_E;
-        else {
-            if (sSz == DSA_HALF_SIZE - 1) {
-                out[rSz] = 0;
-                out++;
-            }    
-            ret = mp_to_unsigned_bin(&s, out + rSz);
-        }
-    }
-
-    mp_clear(&H);
-    mp_clear(&s);
-    mp_clear(&r);
-    mp_clear(&kInv);
-    mp_clear(&k);
-
-    return ret;
-}
-
-
-int wc_DsaVerify(const byte* digest, const byte* sig, DsaKey* key, int* answer)
-{
-    mp_int w, u1, u2, v, r, s;
-    int    ret = 0;
-
-    if (mp_init_multi(&w, &u1, &u2, &v, &r, &s) != MP_OKAY)
-        return MP_INIT_E;
-
-    /* set r and s from signature */
-    if (mp_read_unsigned_bin(&r, sig, DSA_HALF_SIZE) != MP_OKAY ||
-        mp_read_unsigned_bin(&s, sig + DSA_HALF_SIZE, DSA_HALF_SIZE) != MP_OKAY)
-        ret = MP_READ_E;
-
-    /* sanity checks */
-    if (ret == 0) {
-        if (mp_iszero(&r) == MP_YES || mp_iszero(&s) == MP_YES ||
-                mp_cmp(&r, &key->q) != MP_LT || mp_cmp(&s, &key->q) != MP_LT) {
-            ret = MP_ZERO_E;
-        }
-    }
-
-    /* put H into u1 from sha digest */
-    if (ret == 0 && mp_read_unsigned_bin(&u1,digest,SHA_DIGEST_SIZE) != MP_OKAY)
-        ret = MP_READ_E;
-
-    /* w = s invmod q */
-    if (ret == 0 && mp_invmod(&s, &key->q, &w) != MP_OKAY)
-        ret = MP_INVMOD_E;
-
-    /* u1 = (H * w) % q */
-    if (ret == 0 && mp_mulmod(&u1, &w, &key->q, &u1) != MP_OKAY)
-        ret = MP_MULMOD_E;
-
-    /* u2 = (r * w) % q */
-    if (ret == 0 && mp_mulmod(&r, &w, &key->q, &u2) != MP_OKAY)
-        ret = MP_MULMOD_E;
-
-    /* verify v = ((g^u1 * y^u2) mod p) mod q */
-    if (ret == 0 && mp_exptmod(&key->g, &u1, &key->p, &u1) != MP_OKAY)
-        ret = MP_EXPTMOD_E;
-
-    if (ret == 0 && mp_exptmod(&key->y, &u2, &key->p, &u2) != MP_OKAY)
-        ret = MP_EXPTMOD_E;
-
-    if (ret == 0 && mp_mulmod(&u1, &u2, &key->p, &v) != MP_OKAY)
-        ret = MP_MULMOD_E;
-
-    if (ret == 0 && mp_mod(&v, &key->q, &v) != MP_OKAY)
-        ret = MP_MULMOD_E;
-
-    /* do they match */
-    if (ret == 0 && mp_cmp(&r, &v) == MP_EQ)
-        *answer = 1;
-    else
-        *answer = 0;
-
-    mp_clear(&s);
-    mp_clear(&r);
-    mp_clear(&u1);
-    mp_clear(&u2);
-    mp_clear(&w);
-    mp_clear(&v);
-
-    return ret;
-}
-
-
-#endif /* NO_DSA */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ecc.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ecc.c
deleted file mode 100755
index 897d46a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ecc.c
+++ /dev/null
@@ -1,5186 +0,0 @@
-/* ecc.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-/* in case user set HAVE_ECC there */
-#include 
-
-#ifdef HAVE_ECC
-
-#include 
-#include 
-#include 
-
-#ifdef HAVE_ECC_ENCRYPT
-    #include 
-    #include 
-#endif
-
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-/* map
-
-   ptmul -> mulmod
-
-*/
-
-
-/* p256 curve on by default whether user curves or not */
-#if defined(HAVE_ECC112) || defined(HAVE_ALL_CURVES)
-    #define ECC112
-#endif
-#if defined(HAVE_ECC128) || defined(HAVE_ALL_CURVES)
-    #define ECC128
-#endif
-#if defined(HAVE_ECC160) || defined(HAVE_ALL_CURVES)
-    #define ECC160
-#endif
-#if defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)
-    #define ECC192
-#endif
-#if defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES)
-    #define ECC224
-#endif
-#if !defined(NO_ECC256)  || defined(HAVE_ALL_CURVES)
-    #define ECC256
-#endif
-#if defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES)
-    #define ECC384
-#endif
-#if defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES)
-    #define ECC521
-#endif
-
-
-
-/* This holds the key settings.  ***MUST*** be organized by size from
-   smallest to largest. */
-
-const ecc_set_type ecc_sets[] = {
-#ifdef ECC112
-{
-        14,
-        "SECP112R1",
-        "DB7C2ABF62E35E668076BEAD208B",
-        "DB7C2ABF62E35E668076BEAD2088",
-        "659EF8BA043916EEDE8911702B22",
-        "DB7C2ABF62E35E7628DFAC6561C5",
-        "09487239995A5EE76B55F9C2F098",
-        "A89CE5AF8724C0A23E0E0FF77500"
-},
-#endif
-#ifdef ECC128
-{
-        16,
-        "SECP128R1",
-        "FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF",
-        "FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC",
-        "E87579C11079F43DD824993C2CEE5ED3",
-        "FFFFFFFE0000000075A30D1B9038A115",
-        "161FF7528B899B2D0C28607CA52C5B86",
-        "CF5AC8395BAFEB13C02DA292DDED7A83",
-},
-#endif
-#ifdef ECC160
-{
-        20,
-        "SECP160R1",
-        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF",
-        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC",
-        "1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45",
-        "0100000000000000000001F4C8F927AED3CA752257",
-        "4A96B5688EF573284664698968C38BB913CBFC82",
-        "23A628553168947D59DCC912042351377AC5FB32",
-},
-#endif
-#ifdef ECC192
-{
-        24,
-        "ECC-192",
-        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF",
-        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC",
-        "64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1",
-        "FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831",
-        "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012",
-        "7192B95FFC8DA78631011ED6B24CDD573F977A11E794811",
-},
-#endif
-#ifdef ECC224
-{
-        28,
-        "ECC-224",
-        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001",
-        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE",
-        "B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4",
-        "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D",
-        "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21",
-        "BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",
-},
-#endif
-#ifdef ECC256
-{
-        32,
-        "ECC-256",
-        "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF",
-        "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC",
-        "5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B",
-        "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551",
-        "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296",
-        "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",
-},
-#endif
-#ifdef ECC384
-{
-        48,
-        "ECC-384",
-        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF",
-        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC",
-        "B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF",
-        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973",
-        "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7",
-        "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F",
-},
-#endif
-#ifdef ECC521
-{
-        66,
-        "ECC-521",
-        "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
-        "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC",
-        "51953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00",
-        "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409",
-        "C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66",
-        "11839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650",
-},
-#endif
-{
-   0,
-   NULL, NULL, NULL, NULL, NULL, NULL, NULL
-}
-};
-
-
-ecc_point* ecc_new_point(void);
-void ecc_del_point(ecc_point* p);
-int  ecc_map(ecc_point*, mp_int*, mp_digit*);
-int  ecc_projective_add_point(ecc_point* P, ecc_point* Q, ecc_point* R,
-                              mp_int* modulus, mp_digit* mp);
-int  ecc_projective_dbl_point(ecc_point* P, ecc_point* R, mp_int* modulus,
-                              mp_digit* mp);
-static int ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R, mp_int* modulus,
-                      int map);
-static int ecc_check_pubkey_order(ecc_key* key, mp_int* prime, mp_int* order);
-#ifdef ECC_SHAMIR
-static int ecc_mul2add(ecc_point* A, mp_int* kA, ecc_point* B, mp_int* kB,
-                       ecc_point* C, mp_int* modulus);
-#endif
-
-int mp_jacobi(mp_int* a, mp_int* p, int* c);
-int mp_sqrtmod_prime(mp_int* n, mp_int* prime, mp_int* ret);
-int mp_submod(mp_int* a, mp_int* b, mp_int* c, mp_int* d);
-
-#ifdef HAVE_COMP_KEY
-static int wc_ecc_export_x963_compressed(ecc_key*, byte* out, word32* outLen);
-#endif
-
-/* helper for either lib */
-static int get_digit_count(mp_int* a)
-{
-    if (a == NULL)
-        return 0;
-
-    return a->used;
-}
-
-/* helper for either lib */
-static mp_digit get_digit(mp_int* a, int n)
-{
-    if (a == NULL)
-        return 0;
-
-    return (n >= a->used || n < 0) ? 0 : a->dp[n];
-}
-
-
-#if defined(USE_FAST_MATH)
-
-/* fast math accelerated version, but not for fp ecc yet */
-
-/**
-   Add two ECC points
-   P        The point to add
-   Q        The point to add
-   R        [out] The destination of the double
-   modulus  The modulus of the field the ECC curve is in
-   mp       The "b" value from montgomery_setup()
-   return   MP_OKAY on success
-*/
-int ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R,
-                             mp_int* modulus, mp_digit* mp)
-{
-   fp_int t1, t2, x, y, z;
-   int    err;
-
-   if (P == NULL || Q == NULL || R == NULL || modulus == NULL || mp == NULL)
-       return ECC_BAD_ARG_E;
-
-   if ((err = mp_init_multi(&t1, &t2, &x, &y, &z, NULL)) != MP_OKAY) {
-      return err;
-   }
-
-   /* should we dbl instead? */
-   fp_sub(modulus, Q->y, &t1);
-   if ( (fp_cmp(P->x, Q->x) == FP_EQ) && 
-        (get_digit_count(Q->z) && fp_cmp(P->z, Q->z) == FP_EQ) &&
-        (fp_cmp(P->y, Q->y) == FP_EQ || fp_cmp(P->y, &t1) == FP_EQ)) {
-        return ecc_projective_dbl_point(P, R, modulus, mp);
-   }
-
-   fp_copy(P->x, &x);
-   fp_copy(P->y, &y);
-   fp_copy(P->z, &z);
-
-   /* if Z is one then these are no-operations */
-   if (get_digit_count(Q->z)) {
-      /* T1 = Z' * Z' */
-      fp_sqr(Q->z, &t1);
-      fp_montgomery_reduce(&t1, modulus, *mp);
-      /* X = X * T1 */
-      fp_mul(&t1, &x, &x);
-      fp_montgomery_reduce(&x, modulus, *mp);
-      /* T1 = Z' * T1 */
-      fp_mul(Q->z, &t1, &t1);
-      fp_montgomery_reduce(&t1, modulus, *mp);
-      /* Y = Y * T1 */
-      fp_mul(&t1, &y, &y);
-      fp_montgomery_reduce(&y, modulus, *mp);
-   }
-
-   /* T1 = Z*Z */
-   fp_sqr(&z, &t1);
-   fp_montgomery_reduce(&t1, modulus, *mp);
-   /* T2 = X' * T1 */
-   fp_mul(Q->x, &t1, &t2);
-   fp_montgomery_reduce(&t2, modulus, *mp);
-   /* T1 = Z * T1 */
-   fp_mul(&z, &t1, &t1);
-   fp_montgomery_reduce(&t1, modulus, *mp);
-   /* T1 = Y' * T1 */
-   fp_mul(Q->y, &t1, &t1);
-   fp_montgomery_reduce(&t1, modulus, *mp);
-
-   /* Y = Y - T1 */
-   fp_sub(&y, &t1, &y);
-   if (fp_cmp_d(&y, 0) == FP_LT) {
-      fp_add(&y, modulus, &y);
-   }
-   /* T1 = 2T1 */
-   fp_add(&t1, &t1, &t1);
-   if (fp_cmp(&t1, modulus) != FP_LT) {
-      fp_sub(&t1, modulus, &t1);
-   }
-   /* T1 = Y + T1 */
-   fp_add(&t1, &y, &t1);
-   if (fp_cmp(&t1, modulus) != FP_LT) {
-      fp_sub(&t1, modulus, &t1);
-   }
-   /* X = X - T2 */
-   fp_sub(&x, &t2, &x);
-   if (fp_cmp_d(&x, 0) == FP_LT) {
-      fp_add(&x, modulus, &x);
-   }
-   /* T2 = 2T2 */
-   fp_add(&t2, &t2, &t2);
-   if (fp_cmp(&t2, modulus) != FP_LT) {
-      fp_sub(&t2, modulus, &t2);
-   }
-   /* T2 = X + T2 */
-   fp_add(&t2, &x, &t2);
-   if (fp_cmp(&t2, modulus) != FP_LT) {
-      fp_sub(&t2, modulus, &t2);
-   }
-
-   /* if Z' != 1 */
-   if (get_digit_count(Q->z)) {
-      /* Z = Z * Z' */
-      fp_mul(&z, Q->z, &z);
-      fp_montgomery_reduce(&z, modulus, *mp);
-   }
-
-   /* Z = Z * X */
-   fp_mul(&z, &x, &z);
-   fp_montgomery_reduce(&z, modulus, *mp);
-
-   /* T1 = T1 * X  */
-   fp_mul(&t1, &x, &t1);
-   fp_montgomery_reduce(&t1, modulus, *mp);
-   /* X = X * X */
-   fp_sqr(&x, &x);
-   fp_montgomery_reduce(&x, modulus, *mp);
-   /* T2 = T2 * x */
-   fp_mul(&t2, &x, &t2);
-   fp_montgomery_reduce(&t2, modulus, *mp);
-   /* T1 = T1 * X  */
-   fp_mul(&t1, &x, &t1);
-   fp_montgomery_reduce(&t1, modulus, *mp);
- 
-   /* X = Y*Y */
-   fp_sqr(&y, &x);
-   fp_montgomery_reduce(&x, modulus, *mp);
-   /* X = X - T2 */
-   fp_sub(&x, &t2, &x);
-   if (fp_cmp_d(&x, 0) == FP_LT) {
-      fp_add(&x, modulus, &x);
-   }
-
-   /* T2 = T2 - X */
-   fp_sub(&t2, &x, &t2);
-   if (fp_cmp_d(&t2, 0) == FP_LT) {
-      fp_add(&t2, modulus, &t2);
-   } 
-   /* T2 = T2 - X */
-   fp_sub(&t2, &x, &t2);
-   if (fp_cmp_d(&t2, 0) == FP_LT) {
-      fp_add(&t2, modulus, &t2);
-   }
-   /* T2 = T2 * Y */
-   fp_mul(&t2, &y, &t2);
-   fp_montgomery_reduce(&t2, modulus, *mp);
-   /* Y = T2 - T1 */
-   fp_sub(&t2, &t1, &y);
-   if (fp_cmp_d(&y, 0) == FP_LT) {
-      fp_add(&y, modulus, &y);
-   }
-   /* Y = Y/2 */
-   if (fp_isodd(&y)) {
-      fp_add(&y, modulus, &y);
-   }
-   fp_div_2(&y, &y);
-
-   fp_copy(&x, R->x);
-   fp_copy(&y, R->y);
-   fp_copy(&z, R->z);
-   
-   return MP_OKAY;
-}
-
-
-/**
-   Double an ECC point
-   P   The point to double
-   R   [out] The destination of the double
-   modulus  The modulus of the field the ECC curve is in
-   mp       The "b" value from montgomery_setup()
-   return   MP_OKAY on success
-*/
-int ecc_projective_dbl_point(ecc_point *P, ecc_point *R, mp_int* modulus,
-                             mp_digit* mp)
-{
-   fp_int   t1, t2;
-   int      err;
-
-   if (P == NULL || R == NULL || modulus == NULL || mp == NULL)
-       return ECC_BAD_ARG_E;
-
-   if (P != R) {
-      fp_copy(P->x, R->x);
-      fp_copy(P->y, R->y);
-      fp_copy(P->z, R->z);
-   }
-
-   if ((err = mp_init_multi(&t1, &t2, NULL, NULL, NULL, NULL)) != MP_OKAY) {
-      return err;
-   }
-
-   /* t1 = Z * Z */
-   fp_sqr(R->z, &t1);
-   fp_montgomery_reduce(&t1, modulus, *mp);
-   /* Z = Y * Z */
-   fp_mul(R->z, R->y, R->z);
-   fp_montgomery_reduce(R->z, modulus, *mp);
-   /* Z = 2Z */
-   fp_add(R->z, R->z, R->z);
-   if (fp_cmp(R->z, modulus) != FP_LT) {
-      fp_sub(R->z, modulus, R->z);
-   }
-   
-   /* &t2 = X - T1 */
-   fp_sub(R->x, &t1, &t2);
-   if (fp_cmp_d(&t2, 0) == FP_LT) {
-      fp_add(&t2, modulus, &t2);
-   }
-   /* T1 = X + T1 */
-   fp_add(&t1, R->x, &t1);
-   if (fp_cmp(&t1, modulus) != FP_LT) {
-      fp_sub(&t1, modulus, &t1);
-   }
-   /* T2 = T1 * T2 */
-   fp_mul(&t1, &t2, &t2);
-   fp_montgomery_reduce(&t2, modulus, *mp);
-   /* T1 = 2T2 */
-   fp_add(&t2, &t2, &t1);
-   if (fp_cmp(&t1, modulus) != FP_LT) {
-      fp_sub(&t1, modulus, &t1);
-   }
-   /* T1 = T1 + T2 */
-   fp_add(&t1, &t2, &t1);
-   if (fp_cmp(&t1, modulus) != FP_LT) {
-      fp_sub(&t1, modulus, &t1);
-   }
-
-   /* Y = 2Y */
-   fp_add(R->y, R->y, R->y);
-   if (fp_cmp(R->y, modulus) != FP_LT) {
-      fp_sub(R->y, modulus, R->y);
-   }
-   /* Y = Y * Y */
-   fp_sqr(R->y, R->y);
-   fp_montgomery_reduce(R->y, modulus, *mp);
-   /* T2 = Y * Y */
-   fp_sqr(R->y, &t2);
-   fp_montgomery_reduce(&t2, modulus, *mp);
-   /* T2 = T2/2 */
-   if (fp_isodd(&t2)) {
-      fp_add(&t2, modulus, &t2);
-   }
-   fp_div_2(&t2, &t2);
-   /* Y = Y * X */
-   fp_mul(R->y, R->x, R->y);
-   fp_montgomery_reduce(R->y, modulus, *mp);
-
-   /* X  = T1 * T1 */
-   fp_sqr(&t1, R->x);
-   fp_montgomery_reduce(R->x, modulus, *mp);
-   /* X = X - Y */
-   fp_sub(R->x, R->y, R->x);
-   if (fp_cmp_d(R->x, 0) == FP_LT) {
-      fp_add(R->x, modulus, R->x);
-   }
-   /* X = X - Y */
-   fp_sub(R->x, R->y, R->x);
-   if (fp_cmp_d(R->x, 0) == FP_LT) {
-      fp_add(R->x, modulus, R->x);
-   }
-
-   /* Y = Y - X */     
-   fp_sub(R->y, R->x, R->y);
-   if (fp_cmp_d(R->y, 0) == FP_LT) {
-      fp_add(R->y, modulus, R->y);
-   }
-   /* Y = Y * T1 */
-   fp_mul(R->y, &t1, R->y);
-   fp_montgomery_reduce(R->y, modulus, *mp);
-   /* Y = Y - T2 */
-   fp_sub(R->y, &t2, R->y);
-   if (fp_cmp_d(R->y, 0) == FP_LT) {
-      fp_add(R->y, modulus, R->y);
-   }
- 
-   return MP_OKAY;
-}
-
-#else /* USE_FAST_MATH */
-
-/**
-   Add two ECC points
-   P        The point to add
-   Q        The point to add
-   R        [out] The destination of the double
-   modulus  The modulus of the field the ECC curve is in
-   mp       The "b" value from montgomery_setup()
-   return   MP_OKAY on success
-*/
-int ecc_projective_add_point(ecc_point* P, ecc_point* Q, ecc_point* R,
-                             mp_int* modulus, mp_digit* mp)
-{
-   mp_int t1;
-   mp_int t2;
-   mp_int x;
-   mp_int y;
-   mp_int z;
-   int    err;
-
-   if (P == NULL || Q == NULL || R == NULL || modulus == NULL || mp == NULL)
-       return ECC_BAD_ARG_E;
-
-   if ((err = mp_init_multi(&t1, &t2, &x, &y, &z, NULL)) != MP_OKAY) {
-      return err;
-   }
-   
-   /* should we dbl instead? */
-   err = mp_sub(modulus, Q->y, &t1);
-
-   if (err == MP_OKAY) {
-       if ( (mp_cmp(P->x, Q->x) == MP_EQ) && 
-            (get_digit_count(Q->z) && mp_cmp(P->z, Q->z) == MP_EQ) &&
-            (mp_cmp(P->y, Q->y) == MP_EQ || mp_cmp(P->y, &t1) == MP_EQ)) {
-                mp_clear(&t1);
-                mp_clear(&t2);
-                mp_clear(&x);
-                mp_clear(&y);
-                mp_clear(&z);
-
-                return ecc_projective_dbl_point(P, R, modulus, mp);
-       }
-   }
-
-   if (err == MP_OKAY)
-       err = mp_copy(P->x, &x);
-   if (err == MP_OKAY)
-       err = mp_copy(P->y, &y);
-   if (err == MP_OKAY)
-       err = mp_copy(P->z, &z);
-
-   /* if Z is one then these are no-operations */
-   if (err == MP_OKAY) {
-       if (get_digit_count(Q->z)) {
-           /* T1 = Z' * Z' */
-           err = mp_sqr(Q->z, &t1);
-           if (err == MP_OKAY)
-               err = mp_montgomery_reduce(&t1, modulus, *mp);
-
-           /* X = X * T1 */
-           if (err == MP_OKAY)
-               err = mp_mul(&t1, &x, &x);
-           if (err == MP_OKAY)
-               err = mp_montgomery_reduce(&x, modulus, *mp);
-
-           /* T1 = Z' * T1 */
-           if (err == MP_OKAY)
-               err = mp_mul(Q->z, &t1, &t1);
-           if (err == MP_OKAY)
-               err = mp_montgomery_reduce(&t1, modulus, *mp);
-
-           /* Y = Y * T1 */
-           if (err == MP_OKAY)
-               err = mp_mul(&t1, &y, &y);
-           if (err == MP_OKAY)
-               err = mp_montgomery_reduce(&y, modulus, *mp);
-       }
-   }
-
-   /* T1 = Z*Z */
-   if (err == MP_OKAY)
-       err = mp_sqr(&z, &t1);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(&t1, modulus, *mp);
-
-   /* T2 = X' * T1 */
-   if (err == MP_OKAY)
-       err = mp_mul(Q->x, &t1, &t2);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(&t2, modulus, *mp);
-
-   /* T1 = Z * T1 */
-   if (err == MP_OKAY)
-       err = mp_mul(&z, &t1, &t1);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(&t1, modulus, *mp);
-
-   /* T1 = Y' * T1 */
-   if (err == MP_OKAY)
-       err = mp_mul(Q->y, &t1, &t1);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(&t1, modulus, *mp);
-
-   /* Y = Y - T1 */
-   if (err == MP_OKAY)
-       err = mp_sub(&y, &t1, &y);
-   if (err == MP_OKAY) {
-       if (mp_cmp_d(&y, 0) == MP_LT)
-           err = mp_add(&y, modulus, &y);
-   }
-   /* T1 = 2T1 */
-   if (err == MP_OKAY)
-       err = mp_add(&t1, &t1, &t1);
-   if (err == MP_OKAY) {
-       if (mp_cmp(&t1, modulus) != MP_LT)
-           err = mp_sub(&t1, modulus, &t1);
-   }
-   /* T1 = Y + T1 */
-   if (err == MP_OKAY)
-       err = mp_add(&t1, &y, &t1);
-   if (err == MP_OKAY) {
-       if (mp_cmp(&t1, modulus) != MP_LT)
-           err = mp_sub(&t1, modulus, &t1);
-   }
-   /* X = X - T2 */
-   if (err == MP_OKAY)
-       err = mp_sub(&x, &t2, &x);
-   if (err == MP_OKAY) {
-       if (mp_cmp_d(&x, 0) == MP_LT)
-           err = mp_add(&x, modulus, &x);
-   }
-   /* T2 = 2T2 */
-   if (err == MP_OKAY)
-       err = mp_add(&t2, &t2, &t2);
-   if (err == MP_OKAY) {
-       if (mp_cmp(&t2, modulus) != MP_LT)
-           err = mp_sub(&t2, modulus, &t2);
-   }
-   /* T2 = X + T2 */
-   if (err == MP_OKAY)
-       err = mp_add(&t2, &x, &t2);
-   if (err == MP_OKAY) {
-       if (mp_cmp(&t2, modulus) != MP_LT)
-           err = mp_sub(&t2, modulus, &t2);
-   }
-
-   if (err == MP_OKAY) {
-       if (get_digit_count(Q->z)) {
-           /* Z = Z * Z' */
-           err = mp_mul(&z, Q->z, &z);
-           if (err == MP_OKAY)
-               err = mp_montgomery_reduce(&z, modulus, *mp);
-       }
-   }
-
-   /* Z = Z * X */
-   if (err == MP_OKAY)
-       err = mp_mul(&z, &x, &z);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(&z, modulus, *mp);
-
-   /* T1 = T1 * X  */
-   if (err == MP_OKAY)
-       err = mp_mul(&t1, &x, &t1);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(&t1, modulus, *mp);
-
-   /* X = X * X */
-   if (err == MP_OKAY)
-       err = mp_sqr(&x, &x);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(&x, modulus, *mp);
-   
-   /* T2 = T2 * x */
-   if (err == MP_OKAY)
-       err = mp_mul(&t2, &x, &t2);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(&t2, modulus, *mp);
-
-   /* T1 = T1 * X  */
-   if (err == MP_OKAY)
-       err = mp_mul(&t1, &x, &t1);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(&t1, modulus, *mp);
- 
-   /* X = Y*Y */
-   if (err == MP_OKAY)
-       err = mp_sqr(&y, &x);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(&x, modulus, *mp);
-
-   /* X = X - T2 */
-   if (err == MP_OKAY)
-       err = mp_sub(&x, &t2, &x);
-   if (err == MP_OKAY) {
-       if (mp_cmp_d(&x, 0) == MP_LT)
-           err = mp_add(&x, modulus, &x);
-   }
-   /* T2 = T2 - X */
-   if (err == MP_OKAY)
-       err = mp_sub(&t2, &x, &t2);
-   if (err == MP_OKAY) {
-       if (mp_cmp_d(&t2, 0) == MP_LT)
-           err = mp_add(&t2, modulus, &t2);
-   } 
-   /* T2 = T2 - X */
-   if (err == MP_OKAY)
-       err = mp_sub(&t2, &x, &t2);
-   if (err == MP_OKAY) {
-       if (mp_cmp_d(&t2, 0) == MP_LT)
-           err = mp_add(&t2, modulus, &t2);
-   }
-   /* T2 = T2 * Y */
-   if (err == MP_OKAY)
-       err = mp_mul(&t2, &y, &t2);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(&t2, modulus, *mp);
-
-   /* Y = T2 - T1 */
-   if (err == MP_OKAY)
-       err = mp_sub(&t2, &t1, &y);
-   if (err == MP_OKAY) {
-       if (mp_cmp_d(&y, 0) == MP_LT)
-           err = mp_add(&y, modulus, &y);
-   }
-   /* Y = Y/2 */
-   if (err == MP_OKAY) {
-       if (mp_isodd(&y))
-           err = mp_add(&y, modulus, &y);
-   }
-   if (err == MP_OKAY)
-       err = mp_div_2(&y, &y);
-
-   if (err == MP_OKAY)
-       err = mp_copy(&x, R->x);
-   if (err == MP_OKAY)
-       err = mp_copy(&y, R->y);
-   if (err == MP_OKAY)
-       err = mp_copy(&z, R->z);
-
-   /* clean up */
-   mp_clear(&t1);
-   mp_clear(&t2);
-   mp_clear(&x);
-   mp_clear(&y);
-   mp_clear(&z);
-
-   return err;
-}
-
-
-/**
-   Double an ECC point
-   P   The point to double
-   R   [out] The destination of the double
-   modulus  The modulus of the field the ECC curve is in
-   mp       The "b" value from montgomery_setup()
-   return   MP_OKAY on success
-*/
-int ecc_projective_dbl_point(ecc_point *P, ecc_point *R, mp_int* modulus,
-                             mp_digit* mp)
-{
-   mp_int t1;
-   mp_int t2;
-   int    err;
-
-   if (P == NULL || R == NULL || modulus == NULL || mp == NULL)
-       return ECC_BAD_ARG_E;
-
-   if ((err = mp_init_multi(&t1, &t2, NULL, NULL, NULL, NULL)) != MP_OKAY) {
-      return err;
-   }
-
-   if (P != R) {
-      err = mp_copy(P->x, R->x);
-      if (err == MP_OKAY)
-          err = mp_copy(P->y, R->y);
-      if (err == MP_OKAY)
-          err = mp_copy(P->z, R->z);
-   }
-
-   /* t1 = Z * Z */
-   if (err == MP_OKAY)
-       err = mp_sqr(R->z, &t1);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(&t1, modulus, *mp);
-
-   /* Z = Y * Z */
-   if (err == MP_OKAY)
-       err = mp_mul(R->z, R->y, R->z);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(R->z, modulus, *mp);
-
-   /* Z = 2Z */
-   if (err == MP_OKAY)
-       err = mp_add(R->z, R->z, R->z);
-   if (err == MP_OKAY) {
-       if (mp_cmp(R->z, modulus) != MP_LT)
-           err = mp_sub(R->z, modulus, R->z);
-   }
-
-   /* T2 = X - T1 */
-   if (err == MP_OKAY)
-       err = mp_sub(R->x, &t1, &t2);
-   if (err == MP_OKAY) {
-       if (mp_cmp_d(&t2, 0) == MP_LT)
-           err = mp_add(&t2, modulus, &t2);
-   }
-   /* T1 = X + T1 */
-   if (err == MP_OKAY)
-       err = mp_add(&t1, R->x, &t1);
-   if (err == MP_OKAY) {
-       if (mp_cmp(&t1, modulus) != MP_LT)
-           err = mp_sub(&t1, modulus, &t1);
-   }
-   /* T2 = T1 * T2 */
-   if (err == MP_OKAY)
-       err = mp_mul(&t1, &t2, &t2);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(&t2, modulus, *mp);
-
-   /* T1 = 2T2 */
-   if (err == MP_OKAY)
-       err = mp_add(&t2, &t2, &t1);
-   if (err == MP_OKAY) {
-       if (mp_cmp(&t1, modulus) != MP_LT)
-           err = mp_sub(&t1, modulus, &t1);
-   }
-   /* T1 = T1 + T2 */
-   if (err == MP_OKAY)
-       err = mp_add(&t1, &t2, &t1);
-   if (err == MP_OKAY) {
-       if (mp_cmp(&t1, modulus) != MP_LT)
-           err = mp_sub(&t1, modulus, &t1);
-   }
-   /* Y = 2Y */
-   if (err == MP_OKAY)
-       err = mp_add(R->y, R->y, R->y);
-   if (err == MP_OKAY) {
-       if (mp_cmp(R->y, modulus) != MP_LT)
-           err = mp_sub(R->y, modulus, R->y);
-   }
-   /* Y = Y * Y */
-   if (err == MP_OKAY)
-       err = mp_sqr(R->y, R->y);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(R->y, modulus, *mp);
-   
-   /* T2 = Y * Y */
-   if (err == MP_OKAY)
-       err = mp_sqr(R->y, &t2);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(&t2, modulus, *mp);
-
-   /* T2 = T2/2 */
-   if (err == MP_OKAY) {
-       if (mp_isodd(&t2))
-           err = mp_add(&t2, modulus, &t2);
-   }
-   if (err == MP_OKAY)
-       err = mp_div_2(&t2, &t2);
-   
-   /* Y = Y * X */
-   if (err == MP_OKAY)
-       err = mp_mul(R->y, R->x, R->y);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(R->y, modulus, *mp);
-
-   /* X  = T1 * T1 */
-   if (err == MP_OKAY)
-       err = mp_sqr(&t1, R->x);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(R->x, modulus, *mp);
-
-   /* X = X - Y */
-   if (err == MP_OKAY)
-       err = mp_sub(R->x, R->y, R->x);
-   if (err == MP_OKAY) {
-       if (mp_cmp_d(R->x, 0) == MP_LT)
-           err = mp_add(R->x, modulus, R->x);
-   }
-   /* X = X - Y */
-   if (err == MP_OKAY)
-       err = mp_sub(R->x, R->y, R->x);
-   if (err == MP_OKAY) {
-       if (mp_cmp_d(R->x, 0) == MP_LT)
-           err = mp_add(R->x, modulus, R->x);
-   }
-   /* Y = Y - X */     
-   if (err == MP_OKAY)
-       err = mp_sub(R->y, R->x, R->y);
-   if (err == MP_OKAY) {
-       if (mp_cmp_d(R->y, 0) == MP_LT)
-           err = mp_add(R->y, modulus, R->y);
-   }
-   /* Y = Y * T1 */
-   if (err == MP_OKAY)
-       err = mp_mul(R->y, &t1, R->y);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(R->y, modulus, *mp);
-
-   /* Y = Y - T2 */
-   if (err == MP_OKAY)
-       err = mp_sub(R->y, &t2, R->y);
-   if (err == MP_OKAY) {
-       if (mp_cmp_d(R->y, 0) == MP_LT)
-           err = mp_add(R->y, modulus, R->y);
-   }
-
-   /* clean up */ 
-   mp_clear(&t1);
-   mp_clear(&t2);
-
-   return err;
-}
-
-#endif /* USE_FAST_MATH */
-
-/**
-  Map a projective jacbobian point back to affine space
-  P        [in/out] The point to map
-  modulus  The modulus of the field the ECC curve is in
-  mp       The "b" value from montgomery_setup()
-  return   MP_OKAY on success
-*/
-int ecc_map(ecc_point* P, mp_int* modulus, mp_digit* mp)
-{
-   mp_int t1;
-   mp_int t2;
-   int    err;
-
-   if (P == NULL || mp == NULL || modulus == NULL)
-       return ECC_BAD_ARG_E;
-
-   /* special case for point at infinity */
-   if (mp_cmp_d(P->z, 0) == MP_EQ) {
-       mp_set(P->x, 0);
-       mp_set(P->y, 0);
-       mp_set(P->z, 1);
-       return MP_OKAY;
-   }
-
-   if ((err = mp_init_multi(&t1, &t2, NULL, NULL, NULL, NULL)) != MP_OKAY) {
-      return MEMORY_E;
-   }
-
-   /* first map z back to normal */
-   err = mp_montgomery_reduce(P->z, modulus, *mp);
-
-   /* get 1/z */
-   if (err == MP_OKAY)
-       err = mp_invmod(P->z, modulus, &t1);
- 
-   /* get 1/z^2 and 1/z^3 */
-   if (err == MP_OKAY)
-       err = mp_sqr(&t1, &t2);
-   if (err == MP_OKAY)
-       err = mp_mod(&t2, modulus, &t2);
-   if (err == MP_OKAY)
-       err = mp_mul(&t1, &t2, &t1);
-   if (err == MP_OKAY)
-       err = mp_mod(&t1, modulus, &t1);
-
-   /* multiply against x/y */
-   if (err == MP_OKAY)
-       err = mp_mul(P->x, &t2, P->x);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(P->x, modulus, *mp);
-   if (err == MP_OKAY)
-       err = mp_mul(P->y, &t1, P->y);
-   if (err == MP_OKAY)
-       err = mp_montgomery_reduce(P->y, modulus, *mp);
-   
-   if (err == MP_OKAY)
-       mp_set(P->z, 1);
-
-   /* clean up */
-   mp_clear(&t1);
-   mp_clear(&t2);
-
-   return err;
-}
-
-
-#ifndef ECC_TIMING_RESISTANT
-
-/* size of sliding window, don't change this! */
-#define WINSIZE 4
-
-/**
-   Perform a point multiplication 
-   k    The scalar to multiply by
-   G    The base point
-   R    [out] Destination for kG
-   modulus  The modulus of the field the ECC curve is in
-   map      Boolean whether to map back to affine or not
-                (1==map, 0 == leave in projective)
-   return MP_OKAY on success
-*/
-#ifdef FP_ECC
-static int normal_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R,
-                             mp_int* modulus, int map)
-#else
-static int ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R, mp_int* modulus,
-                      int map)
-#endif
-{
-   ecc_point *tG, *M[8];
-   int           i, j, err;
-   mp_int        mu;
-   mp_digit      mp;
-   mp_digit      buf;
-   int           first = 1, bitbuf = 0, bitcpy = 0, bitcnt = 0, mode = 0,
-                 digidx = 0;
-
-   if (k == NULL || G == NULL || R == NULL || modulus == NULL)
-       return ECC_BAD_ARG_E;
-
-   /* init montgomery reduction */
-   if ((err = mp_montgomery_setup(modulus, &mp)) != MP_OKAY) {
-      return err;
-   }
-   if ((err = mp_init(&mu)) != MP_OKAY) {
-      return err;
-   }
-   if ((err = mp_montgomery_calc_normalization(&mu, modulus)) != MP_OKAY) {
-      mp_clear(&mu);
-      return err;
-   }
-  
-  /* alloc ram for window temps */
-  for (i = 0; i < 8; i++) {
-      M[i] = ecc_new_point();
-      if (M[i] == NULL) {
-         for (j = 0; j < i; j++) {
-             ecc_del_point(M[j]);
-         }
-         mp_clear(&mu);
-         return MEMORY_E;
-      }
-  }
-
-   /* make a copy of G incase R==G */
-   tG = ecc_new_point();
-   if (tG == NULL)
-       err = MEMORY_E;
-
-   /* tG = G  and convert to montgomery */
-   if (err == MP_OKAY) {
-       if (mp_cmp_d(&mu, 1) == MP_EQ) {
-           err = mp_copy(G->x, tG->x);
-           if (err == MP_OKAY)
-               err = mp_copy(G->y, tG->y);
-           if (err == MP_OKAY)
-               err = mp_copy(G->z, tG->z);
-       } else {
-           err = mp_mulmod(G->x, &mu, modulus, tG->x);
-           if (err == MP_OKAY)
-               err = mp_mulmod(G->y, &mu, modulus, tG->y);
-           if (err == MP_OKAY)
-               err = mp_mulmod(G->z, &mu, modulus, tG->z);
-       }
-   }
-   mp_clear(&mu);
-   
-   /* calc the M tab, which holds kG for k==8..15 */
-   /* M[0] == 8G */
-   if (err == MP_OKAY)
-       err = ecc_projective_dbl_point(tG, M[0], modulus, &mp);
-   if (err == MP_OKAY)
-       err = ecc_projective_dbl_point(M[0], M[0], modulus, &mp);
-   if (err == MP_OKAY)
-       err = ecc_projective_dbl_point(M[0], M[0], modulus, &mp);
-
-   /* now find (8+k)G for k=1..7 */
-   if (err == MP_OKAY)
-       for (j = 9; j < 16; j++) {
-           err = ecc_projective_add_point(M[j-9], tG, M[j-8], modulus, &mp);
-           if (err != MP_OKAY) break;
-       }
-
-   /* setup sliding window */
-   if (err == MP_OKAY) {
-       mode   = 0;
-       bitcnt = 1;
-       buf    = 0;
-       digidx = get_digit_count(k) - 1;
-       bitcpy = bitbuf = 0;
-       first  = 1;
-
-       /* perform ops */
-       for (;;) {
-           /* grab next digit as required */
-           if (--bitcnt == 0) {
-               if (digidx == -1) {
-                   break;
-               }
-               buf    = get_digit(k, digidx);
-               bitcnt = (int) DIGIT_BIT; 
-               --digidx;
-           }
-
-           /* grab the next msb from the ltiplicand */
-           i = (int)(buf >> (DIGIT_BIT - 1)) & 1;
-           buf <<= 1;
-
-           /* skip leading zero bits */
-           if (mode == 0 && i == 0)
-               continue;
-
-           /* if the bit is zero and mode == 1 then we double */
-           if (mode == 1 && i == 0) {
-               err = ecc_projective_dbl_point(R, R, modulus, &mp);
-               if (err != MP_OKAY) break;
-               continue;
-           }
-
-           /* else we add it to the window */
-           bitbuf |= (i << (WINSIZE - ++bitcpy));
-           mode = 2;
-
-           if (bitcpy == WINSIZE) {
-               /* if this is the first window we do a simple copy */
-               if (first == 1) {
-                   /* R = kG [k = first window] */
-                   err = mp_copy(M[bitbuf-8]->x, R->x);
-                   if (err != MP_OKAY) break;
-
-                   err = mp_copy(M[bitbuf-8]->y, R->y);
-                   if (err != MP_OKAY) break;
-
-                   err = mp_copy(M[bitbuf-8]->z, R->z);
-                   first = 0;
-               } else {
-                   /* normal window */
-                   /* ok window is filled so double as required and add  */
-                   /* double first */
-                   for (j = 0; j < WINSIZE; j++) {
-                       err = ecc_projective_dbl_point(R, R, modulus, &mp);
-                       if (err != MP_OKAY) break;
-                   }
-                   if (err != MP_OKAY) break;  /* out of first for(;;) */
-
-                   /* then add, bitbuf will be 8..15 [8..2^WINSIZE] guaranted */
-                   err = ecc_projective_add_point(R,M[bitbuf-8],R,modulus,&mp);
-               }
-               if (err != MP_OKAY) break;
-               /* empty window and reset */
-               bitcpy = bitbuf = 0;
-               mode = 1;
-           }
-       }
-   }
-
-   /* if bits remain then double/add */
-   if (err == MP_OKAY) {
-       if (mode == 2 && bitcpy > 0) {
-           /* double then add */
-           for (j = 0; j < bitcpy; j++) {
-               /* only double if we have had at least one add first */
-               if (first == 0) {
-                   err = ecc_projective_dbl_point(R, R, modulus, &mp);
-                   if (err != MP_OKAY) break;
-               }
-
-               bitbuf <<= 1;
-               if ((bitbuf & (1 << WINSIZE)) != 0) {
-                   if (first == 1) {
-                       /* first add, so copy */
-                       err = mp_copy(tG->x, R->x);
-                       if (err != MP_OKAY) break;
-
-                       err = mp_copy(tG->y, R->y);
-                       if (err != MP_OKAY) break;
-
-                       err = mp_copy(tG->z, R->z);
-                       if (err != MP_OKAY) break;
-                       first = 0;
-                   } else {
-                       /* then add */
-                       err = ecc_projective_add_point(R, tG, R, modulus, &mp);
-                       if (err != MP_OKAY) break;
-                   }
-               }
-           }
-       }
-   }
-
-   /* map R back from projective space */
-   if (err == MP_OKAY && map)
-       err = ecc_map(R, modulus, &mp);
-
-   mp_clear(&mu);
-   ecc_del_point(tG);
-   for (i = 0; i < 8; i++) {
-       ecc_del_point(M[i]);
-   }
-   return err;
-}
-
-#undef WINSIZE
-
-#else /* ECC_TIMING_RESISTANT */
-
-/**
-   Perform a point multiplication  (timing resistant)
-   k    The scalar to multiply by
-   G    The base point
-   R    [out] Destination for kG
-   modulus  The modulus of the field the ECC curve is in
-   map      Boolean whether to map back to affine or not
-            (1==map, 0 == leave in projective)
-   return MP_OKAY on success
-*/
-#ifdef FP_ECC
-static int normal_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R,
-                             mp_int* modulus, int map)
-#else
-static int ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R, mp_int* modulus,
-                      int map)
-#endif
-{
-   ecc_point    *tG, *M[3];
-   int           i, j, err;
-   mp_int        mu;
-   mp_digit      mp;
-   mp_digit      buf;
-   int           bitcnt = 0, mode = 0, digidx = 0;
-
-   if (k == NULL || G == NULL || R == NULL || modulus == NULL)
-       return ECC_BAD_ARG_E;
-
-   /* init montgomery reduction */
-   if ((err = mp_montgomery_setup(modulus, &mp)) != MP_OKAY) {
-      return err;
-   }
-   if ((err = mp_init(&mu)) != MP_OKAY) {
-      return err;
-   }
-   if ((err = mp_montgomery_calc_normalization(&mu, modulus)) != MP_OKAY) {
-      mp_clear(&mu);
-      return err;
-   }
-
-  /* alloc ram for window temps */
-  for (i = 0; i < 3; i++) {
-      M[i] = ecc_new_point();
-      if (M[i] == NULL) {
-         for (j = 0; j < i; j++) {
-             ecc_del_point(M[j]);
-         }
-         mp_clear(&mu);
-         return MEMORY_E;
-      }
-  }
-
-   /* make a copy of G incase R==G */
-   tG = ecc_new_point();
-   if (tG == NULL)
-       err = MEMORY_E;
-
-   /* tG = G  and convert to montgomery */
-   if (err == MP_OKAY) {
-       err = mp_mulmod(G->x, &mu, modulus, tG->x);
-       if (err == MP_OKAY)
-           err = mp_mulmod(G->y, &mu, modulus, tG->y);
-       if (err == MP_OKAY)
-           err = mp_mulmod(G->z, &mu, modulus, tG->z);
-   }
-   mp_clear(&mu);
-
-   /* calc the M tab */
-   /* M[0] == G */
-   if (err == MP_OKAY)
-       err = mp_copy(tG->x, M[0]->x);
-   if (err == MP_OKAY)
-       err = mp_copy(tG->y, M[0]->y);
-   if (err == MP_OKAY)
-       err = mp_copy(tG->z, M[0]->z);
-
-   /* M[1] == 2G */
-   if (err == MP_OKAY)
-       err = ecc_projective_dbl_point(tG, M[1], modulus, &mp);
-
-   /* setup sliding window */
-   mode   = 0;
-   bitcnt = 1;
-   buf    = 0;
-   digidx = get_digit_count(k) - 1;
-
-   /* perform ops */
-   if (err == MP_OKAY) {
-       for (;;) {
-           /* grab next digit as required */
-           if (--bitcnt == 0) {
-               if (digidx == -1) {
-                   break;
-               }
-               buf = get_digit(k, digidx);
-               bitcnt = (int) DIGIT_BIT;
-               --digidx;
-           }
-
-           /* grab the next msb from the ltiplicand */
-           i = (buf >> (DIGIT_BIT - 1)) & 1;
-           buf <<= 1;
-
-           if (mode == 0 && i == 0) {
-               /* dummy operations */
-               if (err == MP_OKAY)
-                   err = ecc_projective_add_point(M[0], M[1], M[2], modulus,
-                                                  &mp);
-               if (err == MP_OKAY)
-                   err = ecc_projective_dbl_point(M[1], M[2], modulus, &mp);
-               if (err == MP_OKAY)
-                   continue;
-           }
-
-           if (mode == 0 && i == 1) {
-               mode = 1;
-               /* dummy operations */
-               if (err == MP_OKAY)
-                   err = ecc_projective_add_point(M[0], M[1], M[2], modulus,
-                                                  &mp);
-               if (err == MP_OKAY)
-                   err = ecc_projective_dbl_point(M[1], M[2], modulus, &mp);
-               if (err == MP_OKAY)
-                   continue;
-           }
-
-           if (err == MP_OKAY)
-               err = ecc_projective_add_point(M[0], M[1], M[i^1], modulus, &mp);
-           if (err == MP_OKAY)
-               err = ecc_projective_dbl_point(M[i], M[i], modulus, &mp);
-           if (err != MP_OKAY)
-               break;
-       } /* end for */
-   }
-
-   /* copy result out */
-   if (err == MP_OKAY)
-       err = mp_copy(M[0]->x, R->x);
-   if (err == MP_OKAY)
-       err = mp_copy(M[0]->y, R->y);
-   if (err == MP_OKAY)
-       err = mp_copy(M[0]->z, R->z);
-
-   /* map R back from projective space */
-   if (err == MP_OKAY && map)
-      err = ecc_map(R, modulus, &mp);
-
-   /* done */
-   mp_clear(&mu);
-   ecc_del_point(tG);
-   for (i = 0; i < 3; i++) {
-       ecc_del_point(M[i]);
-   }
-   return err;
-}
-
-#endif /* ECC_TIMING_RESISTANT */
-
-
-#ifdef ALT_ECC_SIZE
-
-static void alt_fp_init(fp_int* a)
-{
-    a->size = FP_SIZE_ECC;
-    fp_zero(a);
-}
-
-#endif /* ALT_ECC_SIZE */
-
-
-/**
-   Allocate a new ECC point
-   return A newly allocated point or NULL on error 
-*/
-ecc_point* ecc_new_point(void)
-{
-   ecc_point* p;
-
-   p = (ecc_point*)XMALLOC(sizeof(ecc_point), 0, DYNAMIC_TYPE_ECC);
-   if (p == NULL) {
-      return NULL;
-   }
-   XMEMSET(p, 0, sizeof(ecc_point));
-
-#ifndef USE_FAST_MATH
-   p->x->dp = NULL;
-   p->y->dp = NULL;
-   p->z->dp = NULL;
-#endif
-
-#ifndef ALT_ECC_SIZE
-   if (mp_init_multi(p->x, p->y, p->z, NULL, NULL, NULL) != MP_OKAY) {
-      XFREE(p, 0, DYNAMIC_TYPE_ECC);
-      return NULL;
-   }
-#else
-   p->x = (mp_int*)&p->xyz[0];
-   p->y = (mp_int*)&p->xyz[1];
-   p->z = (mp_int*)&p->xyz[2];
-   alt_fp_init(p->x);
-   alt_fp_init(p->y);
-   alt_fp_init(p->z);
-#endif
-
-   return p;
-}
-
-/** Free an ECC point from memory
-  p   The point to free
-*/
-void ecc_del_point(ecc_point* p)
-{
-   /* prevents free'ing null arguments */
-   if (p != NULL) {
-      mp_clear(p->x);
-      mp_clear(p->y);
-      mp_clear(p->z);
-      XFREE(p, 0, DYNAMIC_TYPE_ECC);
-   }
-}
-
-
-/** Returns whether an ECC idx is valid or not
-  n      The idx number to check
-  return 1 if valid, 0 if not
-*/  
-static int ecc_is_valid_idx(int n)
-{
-   int x;
-
-   for (x = 0; ecc_sets[x].size != 0; x++)
-       ;
-   /* -1 is a valid index --- indicating that the domain params
-      were supplied by the user */
-   if ((n >= -1) && (n < x)) {
-      return 1;
-   }
-   return 0;
-}
-
-
-/**
-  Create an ECC shared secret between two keys
-  private_key      The private ECC key
-  public_key       The public key
-  out              [out] Destination of the shared secret
-                   Conforms to EC-DH from ANSI X9.63
-  outlen           [in/out] The max size and resulting size of the shared secret
-  return           MP_OKAY if successful
-*/
-int wc_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte* out,
-                      word32* outlen)
-{
-   word32         x = 0;
-   ecc_point*     result;
-   mp_int         prime;
-   int            err;
-
-   if (private_key == NULL || public_key == NULL || out == NULL ||
-                                                    outlen == NULL)
-       return BAD_FUNC_ARG;
-
-   /* type valid? */
-   if (private_key->type != ECC_PRIVATEKEY) {
-      return ECC_BAD_ARG_E;
-   }
-
-   if (ecc_is_valid_idx(private_key->idx) == 0 ||
-       ecc_is_valid_idx(public_key->idx)  == 0)
-      return ECC_BAD_ARG_E;
-
-   if (XSTRNCMP(private_key->dp->name, public_key->dp->name, ECC_MAXNAME) != 0)
-      return ECC_BAD_ARG_E;
-
-   /* make new point */
-   result = ecc_new_point();
-   if (result == NULL) {
-      return MEMORY_E;
-   }
-
-   if ((err = mp_init(&prime)) != MP_OKAY) {
-      ecc_del_point(result);
-      return err;
-   }
-
-   err = mp_read_radix(&prime, (char *)private_key->dp->prime, 16);
-
-   if (err == MP_OKAY)
-       err = ecc_mulmod(&private_key->k, &public_key->pubkey, result, &prime,1);
-
-   if (err == MP_OKAY) {
-       x = mp_unsigned_bin_size(&prime);
-       if (*outlen < x)
-          err = BUFFER_E;
-   }
-
-   if (err == MP_OKAY) {
-       XMEMSET(out, 0, x);
-       err = mp_to_unsigned_bin(result->x,out + (x -
-                                              mp_unsigned_bin_size(result->x)));
-       *outlen = x;
-   }
-
-   mp_clear(&prime);
-   ecc_del_point(result);
-
-   return err;
-}
-
-
-/* return 1 if point is at infinity, 0 if not, < 0 on error */
-static int ecc_point_is_at_infinity(ecc_point* p)
-{
-    if (p == NULL)
-        return BAD_FUNC_ARG;
-
-    if (get_digit_count(p->x) == 0 && get_digit_count(p->y) == 0)
-        return 1;
-
-    return 0;
-}
-
-
-int wc_ecc_make_key_ex(RNG* rng, ecc_key* key, const ecc_set_type* dp);
-
-/**
-  Make a new ECC key 
-  rng          An active RNG state
-  keysize      The keysize for the new key (in octets from 20 to 65 bytes)
-  key          [out] Destination of the newly created key
-  return       MP_OKAY if successful,
-                       upon error all allocated memory will be freed
-*/
-int wc_ecc_make_key(RNG* rng, int keysize, ecc_key* key)
-{
-   int x, err;
-
-   if (key == NULL || rng == NULL)
-       return ECC_BAD_ARG_E;
-
-   /* find key size */
-   for (x = 0; (keysize > ecc_sets[x].size) && (ecc_sets[x].size != 0); x++)
-       ;
-   keysize = ecc_sets[x].size;
-
-   if (keysize > ECC_MAXSIZE || ecc_sets[x].size == 0) {
-      return BAD_FUNC_ARG;
-   }
-   err = wc_ecc_make_key_ex(rng, key, &ecc_sets[x]);
-   key->idx = x;
-
-   return err;
-}
-
-int wc_ecc_make_key_ex(RNG* rng, ecc_key* key, const ecc_set_type* dp)
-{
-   int            err;
-   ecc_point*     base;
-   mp_int         prime;
-   mp_int         order;
-#ifdef WOLFSSL_SMALL_STACK
-   byte*          buf;
-#else
-   byte           buf[ECC_MAXSIZE];
-#endif
-   int            keysize;
-   int            po_init = 0;  /* prime order Init flag for clear */
-
-   if (key == NULL || rng == NULL || dp == NULL)
-       return ECC_BAD_ARG_E;
-
-#ifdef WOLFSSL_SMALL_STACK
-   buf = (byte*)XMALLOC(ECC_MAXSIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-   if (buf == NULL)
-       return MEMORY_E;
-#endif
-
-   key->idx = -1;
-   key->dp  = dp;
-   keysize  = dp->size;
-
-   /* allocate ram */
-   base = NULL;
-
-   /* make up random string */
-   err = wc_RNG_GenerateBlock(rng, buf, keysize);
-   if (err == 0)
-       buf[0] |= 0x0c;
-
-   /* setup the key variables */
-   if (err == 0) {
-#ifndef ALT_ECC_SIZE
-       err = mp_init_multi(key->pubkey.x, key->pubkey.y, key->pubkey.z,
-                            &key->k, &prime, &order);
-#else
-       key->pubkey.x = (mp_int*)&key->pubkey.xyz[0];
-       key->pubkey.y = (mp_int*)&key->pubkey.xyz[1];
-       key->pubkey.z = (mp_int*)&key->pubkey.xyz[2];
-       alt_fp_init(key->pubkey.x);
-       alt_fp_init(key->pubkey.y);
-       alt_fp_init(key->pubkey.z);
-       err = mp_init_multi(&key->k, &prime, &order, NULL, NULL, NULL);
-#endif
-       if (err != MP_OKAY)
-           err = MEMORY_E;
-       else
-           po_init = 1;
-   }
-
-   if (err == MP_OKAY) {
-       base = ecc_new_point();
-       if (base == NULL)
-           err = MEMORY_E;
-   }
-
-   /* read in the specs for this key */
-   if (err == MP_OKAY) 
-       err = mp_read_radix(&prime,   (char *)key->dp->prime, 16);
-   if (err == MP_OKAY) 
-       err = mp_read_radix(&order,   (char *)key->dp->order, 16);
-   if (err == MP_OKAY) 
-       err = mp_read_radix(base->x, (char *)key->dp->Gx, 16);
-   if (err == MP_OKAY) 
-       err = mp_read_radix(base->y, (char *)key->dp->Gy, 16);
-   
-   if (err == MP_OKAY) 
-       mp_set(base->z, 1);
-   if (err == MP_OKAY) 
-       err = mp_read_unsigned_bin(&key->k, (byte*)buf, keysize);
-
-   /* the key should be smaller than the order of base point */
-   if (err == MP_OKAY) { 
-       if (mp_cmp(&key->k, &order) != MP_LT)
-           err = mp_mod(&key->k, &order, &key->k);
-   }
-   /* make the public key */
-   if (err == MP_OKAY)
-       err = ecc_mulmod(&key->k, base, &key->pubkey, &prime, 1);
-
-#ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
-   /* validate the public key, order * pubkey = point at infinity */
-   if (err == MP_OKAY)
-       err = ecc_check_pubkey_order(key, &prime, &order);
-#endif /* WOLFSSL_VALIDATE_KEYGEN */
-
-   if (err == MP_OKAY)
-       key->type = ECC_PRIVATEKEY;
-
-   if (err != MP_OKAY) {
-       /* clean up */
-       mp_clear(key->pubkey.x);
-       mp_clear(key->pubkey.y);
-       mp_clear(key->pubkey.z);
-       mp_clear(&key->k);
-   }
-   ecc_del_point(base);
-   if (po_init) {
-       mp_clear(&prime);
-       mp_clear(&order);
-   }
-
-   ForceZero(buf, ECC_MAXSIZE);
-#ifdef WOLFSSL_SMALL_STACK
-   XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-   return err;
-}
-
-
-/* Setup dynamic pointers is using normal math for proper freeing */
-int wc_ecc_init(ecc_key* key)
-{
-    (void)key;
-
-#ifndef USE_FAST_MATH
-    key->pubkey.x->dp = NULL;
-    key->pubkey.y->dp = NULL;
-    key->pubkey.z->dp = NULL;
-
-    key->k.dp = NULL;
-#endif
-
-#ifdef ALT_ECC_SIZE
-    if (mp_init(&key->k) != MP_OKAY)
-        return MEMORY_E;
-
-    key->pubkey.x = (mp_int*)&key->pubkey.xyz[0];
-    key->pubkey.y = (mp_int*)&key->pubkey.xyz[1];
-    key->pubkey.z = (mp_int*)&key->pubkey.xyz[2];
-    alt_fp_init(key->pubkey.x);
-    alt_fp_init(key->pubkey.y);
-    alt_fp_init(key->pubkey.z);
-#endif
-
-    return 0;
-}
-
-
-/**
-  Sign a message digest
-  in        The message digest to sign
-  inlen     The length of the digest
-  out       [out] The destination for the signature
-  outlen    [in/out] The max size and resulting size of the signature
-  key       A private ECC key
-  return    MP_OKAY if successful
-*/
-int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen, 
-                  RNG* rng, ecc_key* key)
-{
-   mp_int        r;
-   mp_int        s;
-   mp_int        e;
-   mp_int        p;
-   int           err;
-
-   if (in == NULL || out == NULL || outlen == NULL || key == NULL || rng ==NULL)
-       return ECC_BAD_ARG_E;
-
-   /* is this a private key? */
-   if (key->type != ECC_PRIVATEKEY) {
-      return ECC_BAD_ARG_E;
-   }
-   
-   /* is the IDX valid ?  */
-   if (ecc_is_valid_idx(key->idx) != 1) {
-      return ECC_BAD_ARG_E;
-   }
-
-   /* get the hash and load it as a bignum into 'e' */
-   /* init the bignums */
-   if ((err = mp_init_multi(&r, &s, &p, &e, NULL, NULL)) != MP_OKAY) { 
-      return err;
-   }
-   err = mp_read_radix(&p, (char *)key->dp->order, 16);
-
-   if (err == MP_OKAY) {
-       /* we may need to truncate if hash is longer than key size */
-       word32 orderBits = mp_count_bits(&p);
-
-       /* truncate down to byte size, may be all that's needed */
-       if ( (WOLFSSL_BIT_SIZE * inlen) > orderBits)
-           inlen = (orderBits + WOLFSSL_BIT_SIZE - 1)/WOLFSSL_BIT_SIZE;
-       err = mp_read_unsigned_bin(&e, (byte*)in, inlen);
-
-       /* may still need bit truncation too */
-       if (err == MP_OKAY && (WOLFSSL_BIT_SIZE * inlen) > orderBits)
-           mp_rshb(&e, WOLFSSL_BIT_SIZE - (orderBits & 0x7));
-   }
-
-   /* make up a key and export the public copy */
-   if (err == MP_OKAY) {
-       int loop_check = 0;
-       ecc_key pubkey;
-       wc_ecc_init(&pubkey);
-       for (;;) {
-           if (++loop_check > 64) {
-                err = RNG_FAILURE_E;
-                break;
-           }
-           err = wc_ecc_make_key_ex(rng, &pubkey, key->dp);
-           if (err != MP_OKAY) break;
-
-           /* find r = x1 mod n */
-           err = mp_mod(pubkey.pubkey.x, &p, &r);
-           if (err != MP_OKAY) break;
-
-           if (mp_iszero(&r) == MP_YES) {
-               mp_clear(pubkey.pubkey.x);
-               mp_clear(pubkey.pubkey.y);
-               mp_clear(pubkey.pubkey.z);
-               mp_clear(&pubkey.k);
-           }
-           else { 
-               /* find s = (e + xr)/k */
-               err = mp_invmod(&pubkey.k, &p, &pubkey.k);
-               if (err != MP_OKAY) break;
-
-               err = mp_mulmod(&key->k, &r, &p, &s);   /* s = xr */
-               if (err != MP_OKAY) break;
-           
-               err = mp_add(&e, &s, &s);               /* s = e +  xr */
-               if (err != MP_OKAY) break;
-
-               err = mp_mod(&s, &p, &s);               /* s = e +  xr */
-               if (err != MP_OKAY) break;
-
-               err = mp_mulmod(&s, &pubkey.k, &p, &s); /* s = (e + xr)/k */
-               if (err != MP_OKAY) break;
-
-               if (mp_iszero(&s) == MP_NO)
-                   break;
-            }
-       }
-       wc_ecc_free(&pubkey);
-   }
-
-   /* store as SEQUENCE { r, s -- integer } */
-   if (err == MP_OKAY)
-       err = StoreECC_DSA_Sig(out, outlen, &r, &s);
-
-   mp_clear(&r);
-   mp_clear(&s);
-   mp_clear(&p);
-   mp_clear(&e);
-
-   return err;
-}
-
-
-/**
-  Free an ECC key from memory
-  key   The key you wish to free
-*/
-void wc_ecc_free(ecc_key* key)
-{
-   if (key == NULL)
-       return;
-
-   mp_clear(key->pubkey.x);
-   mp_clear(key->pubkey.y);
-   mp_clear(key->pubkey.z);
-   mp_clear(&key->k);
-}
-
-
-#ifdef USE_FAST_MATH
-    #define GEN_MEM_ERR FP_MEM
-#else
-    #define GEN_MEM_ERR MP_MEM
-#endif
-
-#ifdef ECC_SHAMIR
-
-/** Computes kA*A + kB*B = C using Shamir's Trick
-  A        First point to multiply
-  kA       What to multiple A by
-  B        Second point to multiply
-  kB       What to multiple B by
-  C        [out] Destination point (can overlap with A or B)
-  modulus  Modulus for curve 
-  return MP_OKAY on success
-*/
-#ifdef FP_ECC
-static int normal_ecc_mul2add(ecc_point* A, mp_int* kA,
-                             ecc_point* B, mp_int* kB,
-                             ecc_point* C, mp_int* modulus)
-#else
-static int ecc_mul2add(ecc_point* A, mp_int* kA,
-                    ecc_point* B, mp_int* kB,
-                    ecc_point* C, mp_int* modulus)
-#endif
-{
-  ecc_point*     precomp[16];
-  unsigned       bitbufA, bitbufB, lenA, lenB, len, x, y, nA, nB, nibble;
-  unsigned char* tA;
-  unsigned char* tB;
-  int            err = MP_OKAY, first;
-  int            muInit    = 0;
-  int            tableInit = 0;
-  mp_digit mp;
-  mp_int   mu;
- 
-  /* argchks */
-  if (A == NULL || kA == NULL || B == NULL || kB == NULL || C == NULL || 
-                   modulus == NULL)
-    return ECC_BAD_ARG_E;
-
-
-  /* allocate memory */
-  tA = (unsigned char*)XMALLOC(ECC_BUFSIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-  if (tA == NULL) {
-     return GEN_MEM_ERR;
-  }
-  tB = (unsigned char*)XMALLOC(ECC_BUFSIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-  if (tB == NULL) {
-     XFREE(tA, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-     return GEN_MEM_ERR;
-  }
-  XMEMSET(tA, 0, ECC_BUFSIZE);
-  XMEMSET(tB, 0, ECC_BUFSIZE);
-
-  /* get sizes */
-  lenA = mp_unsigned_bin_size(kA);
-  lenB = mp_unsigned_bin_size(kB);
-  len  = MAX(lenA, lenB);
-
-  /* sanity check */
-  if ((lenA > ECC_BUFSIZE) || (lenB > ECC_BUFSIZE)) {
-     err = BAD_FUNC_ARG;
-  }
-
-  if (err == MP_OKAY) {
-    /* extract and justify kA */
-    err = mp_to_unsigned_bin(kA, (len - lenA) + tA);
-
-    /* extract and justify kB */
-    if (err == MP_OKAY)
-        err = mp_to_unsigned_bin(kB, (len - lenB) + tB);
-
-    /* allocate the table */
-    if (err == MP_OKAY) {
-        for (x = 0; x < 16; x++) {
-            precomp[x] = ecc_new_point();
-            if (precomp[x] == NULL) {
-                for (y = 0; y < x; ++y) {
-                    ecc_del_point(precomp[y]);
-                }
-                err = GEN_MEM_ERR;
-                break;
-            }
-        }
-    }
-  }
-
-  if (err == MP_OKAY)
-    tableInit = 1;
-
-  if (err == MP_OKAY)
-   /* init montgomery reduction */
-   err = mp_montgomery_setup(modulus, &mp);
-
-  if (err == MP_OKAY)
-    err = mp_init(&mu);
-  if (err == MP_OKAY)
-    muInit = 1;
-
-  if (err == MP_OKAY)
-    err = mp_montgomery_calc_normalization(&mu, modulus);
-
-  if (err == MP_OKAY)
-    /* copy ones ... */
-    err = mp_mulmod(A->x, &mu, modulus, precomp[1]->x);
-
-  if (err == MP_OKAY)
-    err = mp_mulmod(A->y, &mu, modulus, precomp[1]->y);
-  if (err == MP_OKAY)
-    err = mp_mulmod(A->z, &mu, modulus, precomp[1]->z);
-
-  if (err == MP_OKAY)
-    err = mp_mulmod(B->x, &mu, modulus, precomp[1<<2]->x);
-  if (err == MP_OKAY)
-    err = mp_mulmod(B->y, &mu, modulus, precomp[1<<2]->y);
-  if (err == MP_OKAY)
-    err = mp_mulmod(B->z, &mu, modulus, precomp[1<<2]->z);
-
-  if (err == MP_OKAY)
-    /* precomp [i,0](A + B) table */
-    err = ecc_projective_dbl_point(precomp[1], precomp[2], modulus, &mp);
-
-  if (err == MP_OKAY)
-    err = ecc_projective_add_point(precomp[1], precomp[2], precomp[3],
-                                   modulus, &mp);
-  if (err == MP_OKAY)
-    /* precomp [0,i](A + B) table */
-    err = ecc_projective_dbl_point(precomp[1<<2], precomp[2<<2], modulus, &mp);
-
-  if (err == MP_OKAY)
-    err = ecc_projective_add_point(precomp[1<<2], precomp[2<<2], precomp[3<<2],
-                                   modulus, &mp);
-
-  if (err == MP_OKAY) {
-    /* precomp [i,j](A + B) table (i != 0, j != 0) */
-    for (x = 1; x < 4; x++) {
-        for (y = 1; y < 4; y++) {
-            if (err == MP_OKAY)
-                err = ecc_projective_add_point(precomp[x], precomp[(y<<2)],
-                                               precomp[x+(y<<2)], modulus, &mp);
-        }
-    } 
-  }  
-
-  if (err == MP_OKAY) {
-    nibble  = 3;
-    first   = 1;
-    bitbufA = tA[0];
-    bitbufB = tB[0];
-
-    /* for every byte of the multiplicands */
-    for (x = -1;; ) {
-        /* grab a nibble */
-        if (++nibble == 4) {
-            ++x; if (x == len) break;
-            bitbufA = tA[x];
-            bitbufB = tB[x];
-            nibble  = 0;
-        }
-
-        /* extract two bits from both, shift/update */
-        nA = (bitbufA >> 6) & 0x03;
-        nB = (bitbufB >> 6) & 0x03;
-        bitbufA = (bitbufA << 2) & 0xFF;   
-        bitbufB = (bitbufB << 2) & 0xFF;   
-
-        /* if both zero, if first, continue */
-        if ((nA == 0) && (nB == 0) && (first == 1)) {
-            continue;
-        }
-
-        /* double twice, only if this isn't the first */
-        if (first == 0) {
-            /* double twice */
-            if (err == MP_OKAY)
-                err = ecc_projective_dbl_point(C, C, modulus, &mp);
-            if (err == MP_OKAY)
-                err = ecc_projective_dbl_point(C, C, modulus, &mp);
-            else
-                break;
-        }
-
-        /* if not both zero */
-        if ((nA != 0) || (nB != 0)) {
-            if (first == 1) {
-                /* if first, copy from table */
-                first = 0;
-                if (err == MP_OKAY)
-                    err = mp_copy(precomp[nA + (nB<<2)]->x, C->x);
-
-                if (err == MP_OKAY)
-                    err = mp_copy(precomp[nA + (nB<<2)]->y, C->y);
-
-                if (err == MP_OKAY)
-                    err = mp_copy(precomp[nA + (nB<<2)]->z, C->z);
-                else
-                    break;
-            } else {
-                /* if not first, add from table */
-                if (err == MP_OKAY)
-                    err = ecc_projective_add_point(C, precomp[nA + (nB<<2)], C,
-                                                   modulus, &mp);
-                else
-                    break;
-            }
-        }
-    }
-  }
-
-  if (err == MP_OKAY)
-    /* reduce to affine */
-    err = ecc_map(C, modulus, &mp);
-
-  /* clean up */
-  if (muInit)
-    mp_clear(&mu);
-
-  if (tableInit) {
-    for (x = 0; x < 16; x++) {
-       ecc_del_point(precomp[x]);
-    }
-  }
-   ForceZero(tA, ECC_BUFSIZE);
-   ForceZero(tB, ECC_BUFSIZE);
-   XFREE(tA, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-   XFREE(tB, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-   return err;
-}
-
-
-#endif /* ECC_SHAMIR */
-
-
-
-/* verify 
- *
- * w  = s^-1 mod n
- * u1 = xw 
- * u2 = rw
- * X = u1*G + u2*Q
- * v = X_x1 mod n
- * accept if v == r
- */
-
-/**
-   Verify an ECC signature
-   sig         The signature to verify
-   siglen      The length of the signature (octets)
-   hash        The hash (message digest) that was signed
-   hashlen     The length of the hash (octets)
-   stat        Result of signature, 1==valid, 0==invalid
-   key         The corresponding public ECC key
-   return      MP_OKAY if successful (even if the signature is not valid)
-*/
-int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
-                    word32 hashlen, int* stat, ecc_key* key)
-{
-   ecc_point    *mG, *mQ;
-   mp_int        r;
-   mp_int        s;
-   mp_int        v;
-   mp_int        w;
-   mp_int        u1;
-   mp_int        u2;
-   mp_int        e;
-   mp_int        p;
-   mp_int        m;
-   int           err;
-
-   if (sig == NULL || hash == NULL || stat == NULL || key == NULL)
-       return ECC_BAD_ARG_E; 
-
-   /* default to invalid signature */
-   *stat = 0;
-
-   /* is the IDX valid ?  */
-   if (ecc_is_valid_idx(key->idx) != 1) {
-      return ECC_BAD_ARG_E;
-   }
-
-   /* allocate ints */
-   if ((err = mp_init_multi(&v, &w, &u1, &u2, &p, &e)) != MP_OKAY) {
-      return MEMORY_E;
-   }
-
-   if ((err = mp_init(&m)) != MP_OKAY) {
-      mp_clear(&v);
-      mp_clear(&w);
-      mp_clear(&u1);
-      mp_clear(&u2);
-      mp_clear(&p);
-      mp_clear(&e);
-      return MEMORY_E;
-   }
-
-   /* allocate points */
-   mG = ecc_new_point();
-   mQ = ecc_new_point();
-   if (mQ  == NULL || mG == NULL)
-      err = MEMORY_E;
-
-   /* Note, DecodeECC_DSA_Sig() calls mp_init() on r and s.
-    * If either of those don't allocate correctly, none of
-    * the rest of this function will execute, and everything
-    * gets cleaned up at the end. */
-   XMEMSET(&r, 0, sizeof(r));
-   XMEMSET(&s, 0, sizeof(s));
-   if (err == MP_OKAY)
-       err = DecodeECC_DSA_Sig(sig, siglen, &r, &s);
-
-   /* get the order */
-   if (err == MP_OKAY)
-       err = mp_read_radix(&p, (char *)key->dp->order, 16);
-
-   /* get the modulus */
-   if (err == MP_OKAY)
-       err = mp_read_radix(&m, (char *)key->dp->prime, 16);
-
-   /* check for zero */
-   if (err == MP_OKAY) {
-       if (mp_iszero(&r) || mp_iszero(&s) || mp_cmp(&r, &p) != MP_LT ||
-                                             mp_cmp(&s, &p) != MP_LT)
-           err = MP_ZERO_E; 
-   }
-   /* read hash */
-   if (err == MP_OKAY) {
-       /* we may need to truncate if hash is longer than key size */
-       unsigned int orderBits = mp_count_bits(&p);
-
-       /* truncate down to byte size, may be all that's needed */
-       if ( (WOLFSSL_BIT_SIZE * hashlen) > orderBits)
-           hashlen = (orderBits + WOLFSSL_BIT_SIZE - 1)/WOLFSSL_BIT_SIZE;
-       err = mp_read_unsigned_bin(&e, hash, hashlen);
-
-       /* may still need bit truncation too */
-       if (err == MP_OKAY && (WOLFSSL_BIT_SIZE * hashlen) > orderBits)
-           mp_rshb(&e, WOLFSSL_BIT_SIZE - (orderBits & 0x7));
-   }
-
-   /*  w  = s^-1 mod n */
-   if (err == MP_OKAY)
-       err = mp_invmod(&s, &p, &w);
-
-   /* u1 = ew */
-   if (err == MP_OKAY)
-       err = mp_mulmod(&e, &w, &p, &u1);
-
-   /* u2 = rw */
-   if (err == MP_OKAY)
-       err = mp_mulmod(&r, &w, &p, &u2);
-
-   /* find mG and mQ */
-   if (err == MP_OKAY)
-       err = mp_read_radix(mG->x, (char *)key->dp->Gx, 16);
-
-   if (err == MP_OKAY)
-       err = mp_read_radix(mG->y, (char *)key->dp->Gy, 16);
-   if (err == MP_OKAY)
-       mp_set(mG->z, 1);
-
-   if (err == MP_OKAY)
-       err = mp_copy(key->pubkey.x, mQ->x);
-   if (err == MP_OKAY)
-       err = mp_copy(key->pubkey.y, mQ->y);
-   if (err == MP_OKAY)
-       err = mp_copy(key->pubkey.z, mQ->z);
-
-#ifndef ECC_SHAMIR
-    {
-       mp_digit      mp;
-
-       /* compute u1*mG + u2*mQ = mG */
-       if (err == MP_OKAY)
-           err = ecc_mulmod(&u1, mG, mG, &m, 0);
-       if (err == MP_OKAY)
-           err = ecc_mulmod(&u2, mQ, mQ, &m, 0);
-  
-       /* find the montgomery mp */
-       if (err == MP_OKAY)
-           err = mp_montgomery_setup(&m, &mp);
-
-       /* add them */
-       if (err == MP_OKAY)
-           err = ecc_projective_add_point(mQ, mG, mG, &m, &mp);
-   
-       /* reduce */
-       if (err == MP_OKAY)
-           err = ecc_map(mG, &m, &mp);
-    }
-#else
-       /* use Shamir's trick to compute u1*mG + u2*mQ using half the doubles */
-       if (err == MP_OKAY)
-           err = ecc_mul2add(mG, &u1, mQ, &u2, mG, &m);
-#endif /* ECC_SHAMIR */ 
-
-   /* v = X_x1 mod n */
-   if (err == MP_OKAY)
-       err = mp_mod(mG->x, &p, &v);
-
-   /* does v == r */
-   if (err == MP_OKAY) {
-       if (mp_cmp(&v, &r) == MP_EQ)
-           *stat = 1;
-   }
-
-   ecc_del_point(mG);
-   ecc_del_point(mQ);
-
-   mp_clear(&r);
-   mp_clear(&s);
-   mp_clear(&v);
-   mp_clear(&w);
-   mp_clear(&u1);
-   mp_clear(&u2);
-   mp_clear(&p);
-   mp_clear(&e);
-   mp_clear(&m);
-
-   return err;
-}
-
-
-/* export public ECC key in ANSI X9.63 format */
-int wc_ecc_export_x963(ecc_key* key, byte* out, word32* outLen)
-{
-#ifdef WOLFSSL_SMALL_STACK
-   byte*  buf;
-#else
-   byte   buf[ECC_BUFSIZE];
-#endif
-   word32 numlen;
-   int    ret = MP_OKAY;
-
-   /* return length needed only */
-   if (key != NULL && out == NULL && outLen != NULL) {
-      numlen = key->dp->size;
-      *outLen = 1 + 2*numlen;
-      return LENGTH_ONLY_E;
-   }
-
-   if (key == NULL || out == NULL || outLen == NULL)
-      return ECC_BAD_ARG_E;
-
-   if (ecc_is_valid_idx(key->idx) == 0) {
-      return ECC_BAD_ARG_E;
-   }
-   numlen = key->dp->size;
-
-   if (*outLen < (1 + 2*numlen)) {
-      *outLen = 1 + 2*numlen;
-      return BUFFER_E;
-   }
-
-   /* store byte 0x04 */
-   out[0] = 0x04;
-
-#ifdef WOLFSSL_SMALL_STACK
-   buf = (byte*)XMALLOC(ECC_BUFSIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-   if (buf == NULL)
-      return MEMORY_E;
-#endif
-
-   do {
-      /* pad and store x */
-      XMEMSET(buf, 0, ECC_BUFSIZE);
-      ret = mp_to_unsigned_bin(key->pubkey.x,
-                         buf + (numlen - mp_unsigned_bin_size(key->pubkey.x)));
-      if (ret != MP_OKAY)
-         break;
-      XMEMCPY(out+1, buf, numlen);
-
-      /* pad and store y */
-      XMEMSET(buf, 0, ECC_BUFSIZE);
-      ret = mp_to_unsigned_bin(key->pubkey.y,
-                         buf + (numlen - mp_unsigned_bin_size(key->pubkey.y)));
-      if (ret != MP_OKAY)
-         break;
-      XMEMCPY(out+1+numlen, buf, numlen);
-
-      *outLen = 1 + 2*numlen;
-   } while (0);
-
-#ifdef WOLFSSL_SMALL_STACK
-   XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-   return ret;
-}
-
-
-/* export public ECC key in ANSI X9.63 format, extended with
- * compression option */
-int wc_ecc_export_x963_ex(ecc_key* key, byte* out, word32* outLen, int compressed)
-{
-    if (compressed == 0)
-        return wc_ecc_export_x963(key, out, outLen);
-#ifdef HAVE_COMP_KEY
-    else
-        return wc_ecc_export_x963_compressed(key, out, outLen);
-#endif
-
-    return NOT_COMPILED_IN;
-}
-
-
-/* is ec point on curve descriped by dp ? */
-static int ecc_is_point(const ecc_set_type* dp, ecc_point* ecp, mp_int* prime)
-{
-   mp_int b, t1, t2;
-   int err;
-
-   if ((err = mp_init_multi(&b, &t1, &t2, NULL, NULL, NULL)) != MP_OKAY) {
-      return err;
-   }
-
-   /* load  b */
-   err = mp_read_radix(&b, dp->Bf, 16);
-
-   /* compute y^2 */
-   if (err == MP_OKAY)
-       err = mp_sqr(ecp->y, &t1);
-
-   /* compute x^3 */
-   if (err == MP_OKAY)
-       err = mp_sqr(ecp->x, &t2);
-   if (err == MP_OKAY)
-       err = mp_mod(&t2, prime, &t2);
-   if (err == MP_OKAY)
-       err = mp_mul(ecp->x, &t2, &t2);
-
-   /* compute y^2 - x^3 */
-   if (err == MP_OKAY)
-       err = mp_sub(&t1, &t2, &t1);
-
-   /* compute y^2 - x^3 + 3x */
-   if (err == MP_OKAY)
-       err = mp_add(&t1, ecp->x, &t1);
-   if (err == MP_OKAY)
-       err = mp_add(&t1, ecp->x, &t1);
-   if (err == MP_OKAY)
-       err = mp_add(&t1, ecp->x, &t1);
-   if (err == MP_OKAY)
-       err = mp_mod(&t1, prime, &t1);
-
-   while (err == MP_OKAY && mp_cmp_d(&t1, 0) == MP_LT) {
-      err = mp_add(&t1, prime, &t1);
-   }
-   while (err == MP_OKAY && mp_cmp(&t1, prime) != MP_LT) {
-      err = mp_sub(&t1, prime, &t1);
-   }
-
-   /* compare to b */
-   if (err == MP_OKAY) {
-       if (mp_cmp(&t1, &b) != MP_EQ) {
-          err = MP_VAL;
-       } else {
-          err = MP_OKAY;
-       }
-   }
-
-   mp_clear(&b);
-   mp_clear(&t1);
-   mp_clear(&t2);
-
-   return err;
-}
-
-
-/* validate privkey * generator == pubkey, 0 on success */
-static int ecc_check_privkey_gen(ecc_key* key, mp_int* prime)
-{
-    ecc_point* base = NULL;
-    ecc_point* res  = NULL;
-    int        err;
-
-    if (key == NULL)
-        return BAD_FUNC_ARG;
-
-    base = ecc_new_point();
-    if (base == NULL)
-        return MEMORY_E;
-
-    /* set up base generator */
-    err = mp_read_radix(base->x, (char*)key->dp->Gx, 16);
-    if (err == MP_OKAY)
-        err = mp_read_radix(base->y, (char*)key->dp->Gy, 16);
-    if (err == MP_OKAY)
-        mp_set(base->z, 1);
-
-    if (err == MP_OKAY) {
-        res = ecc_new_point();
-        if (res == NULL)
-            err = MEMORY_E;
-        else {
-            err = ecc_mulmod(&key->k, base, res, prime, 1);
-            if (err == MP_OKAY) {
-                /* compare result to public key */
-                if (mp_cmp(res->x, key->pubkey.x) != MP_EQ ||
-                    mp_cmp(res->y, key->pubkey.y) != MP_EQ ||
-                    mp_cmp(res->z, key->pubkey.z) != MP_EQ) {
-                    /* didn't match */
-                    err = ECC_PRIV_KEY_E;
-                }
-            }
-        }
-    }
-
-    ecc_del_point(res);
-    ecc_del_point(base);
-
-    return err;
-}
-
-
-#ifdef WOLFSSL_VALIDATE_ECC_IMPORT
-
-/* check privkey generator helper, creates prime needed */
-static int ecc_check_privkey_gen_helper(ecc_key* key)
-{
-    mp_int prime;
-    int    err;
-
-    if (key == NULL)
-        return BAD_FUNC_ARG;
-
-    err = mp_init(&prime);
-    if (err != MP_OKAY)
-        return err;
-
-    err = mp_read_radix(&prime, (char*)key->dp->prime, 16);
-
-    if (err == MP_OKAY);
-        err = ecc_check_privkey_gen(key, &prime);
-
-    mp_clear(&prime);
-
-    return err;
-}
-
-#endif /* WOLFSSL_VALIDATE_ECC_IMPORT */
-
-
-/* validate order * pubkey = point at infinity, 0 on success */
-static int ecc_check_pubkey_order(ecc_key* key, mp_int* prime, mp_int* order)
-{
-    ecc_point* inf = NULL;
-    int        err;
-
-    if (key == NULL)
-        return BAD_FUNC_ARG;
-
-    inf = ecc_new_point();
-    if (inf == NULL)
-        err = MEMORY_E;
-    else {
-        err = ecc_mulmod(order, &key->pubkey, inf, prime, 1);
-        if (err == MP_OKAY && !ecc_point_is_at_infinity(inf))
-            err = ECC_INF_E;
-    }
-
-    ecc_del_point(inf);
-
-    return err;
-}
-
-
-/* perform sanity checks on ec key validity, 0 on success */
-int wc_ecc_check_key(ecc_key* key)
-{
-    mp_int prime;  /* used by multiple calls so let's cache */
-    mp_int order;  /* other callers have, so let's gen here */
-    int    err;
-
-    if (key == NULL)
-        return BAD_FUNC_ARG;
-
-    /* pubkey point cannot be at inifinity */
-    if (ecc_point_is_at_infinity(&key->pubkey))
-        return ECC_INF_E;
-
-    err = mp_init_multi(&prime, &order, NULL, NULL, NULL, NULL);
-    if (err != MP_OKAY)
-        return err;
-
-    err = mp_read_radix(&prime, (char*)key->dp->prime, 16);
-
-    /* make sure point is actually on curve */
-    if (err == MP_OKAY)
-        err = ecc_is_point(key->dp, &key->pubkey, &prime);
-
-    if (err == MP_OKAY)
-        err = mp_read_radix(&order, (char*)key->dp->order, 16);
-
-    /* pubkey * order must be at infinity */
-    if (err == MP_OKAY)
-        err = ecc_check_pubkey_order(key, &prime, &order);
-
-    /* private * base generator must equal pubkey */
-    if (err == MP_OKAY && key->type == ECC_PRIVATEKEY)
-        err = ecc_check_privkey_gen(key, &prime);
-
-    mp_clear(&order);
-    mp_clear(&prime);
-
-    return err;
-}
-
-
-/* import public ECC key in ANSI X9.63 format */
-int wc_ecc_import_x963(const byte* in, word32 inLen, ecc_key* key)
-{
-   int x, err;
-   int compressed = 0;
-   
-   if (in == NULL || key == NULL)
-       return ECC_BAD_ARG_E;
-
-   /* must be odd */
-   if ((inLen & 1) == 0) {
-      return ECC_BAD_ARG_E;
-   }
-
-   /* init key */
-#ifdef ALT_ECC_SIZE
-   key->pubkey.x = (mp_int*)&key->pubkey.xyz[0];
-   key->pubkey.y = (mp_int*)&key->pubkey.xyz[1];
-   key->pubkey.z = (mp_int*)&key->pubkey.xyz[2];
-   alt_fp_init(key->pubkey.x);
-   alt_fp_init(key->pubkey.y);
-   alt_fp_init(key->pubkey.z);
-   err = mp_init(&key->k);
-#else
-   err = mp_init_multi(key->pubkey.x, key->pubkey.y, key->pubkey.z, &key->k,
-                     NULL, NULL);
-#endif
-   if (err != MP_OKAY)
-      return MEMORY_E;
-
-   /* check for 4, 2, or 3 */
-   if (in[0] != 0x04 && in[0] != 0x02 && in[0] != 0x03) {
-      err = ASN_PARSE_E;
-   }
-
-   if (in[0] == 0x02 || in[0] == 0x03) {
-#ifdef HAVE_COMP_KEY
-       compressed = 1;
-#else
-       err = NOT_COMPILED_IN;
-#endif
-   }
-
-   if (err == MP_OKAY) {
-      /* determine the idx */
-
-      if (compressed)
-          inLen = (inLen-1)*2 + 1;  /* used uncompressed len */
-
-      for (x = 0; ecc_sets[x].size != 0; x++) {
-         if ((unsigned)ecc_sets[x].size >= ((inLen-1)>>1)) {
-            break;
-         }
-      }
-      if (ecc_sets[x].size == 0) {
-         err = ASN_PARSE_E;
-      } else {
-          /* set the idx */
-          key->idx  = x;
-          key->dp = &ecc_sets[x];
-          key->type = ECC_PUBLICKEY;
-      }
-   }
-
-   /* read data */
-   if (err == MP_OKAY)
-       err = mp_read_unsigned_bin(key->pubkey.x, (byte*)in+1, (inLen-1)>>1);
-
-#ifdef HAVE_COMP_KEY
-   if (err == MP_OKAY && compressed == 1) {   /* build y */
-        mp_int t1, t2, prime, a, b;
-
-        if (mp_init_multi(&t1, &t2, &prime, &a, &b, NULL) != MP_OKAY)
-            err = MEMORY_E;
-
-        /* load prime */
-        if (err == MP_OKAY)
-            err = mp_read_radix(&prime, (char *)key->dp->prime, 16);
-
-        /* load a */
-        if (err == MP_OKAY)
-            err = mp_read_radix(&a, (char *)key->dp->Af, 16);
-
-        /* load b */
-        if (err == MP_OKAY)
-            err = mp_read_radix(&b, (char *)key->dp->Bf, 16);
-
-        /* compute x^3 */
-        if (err == MP_OKAY)
-            err = mp_sqr(key->pubkey.x, &t1);
-
-        if (err == MP_OKAY)
-            err = mp_mulmod(&t1, key->pubkey.x, &prime, &t1);
-
-        /* compute x^3 + a*x */
-        if (err == MP_OKAY)
-            err = mp_mulmod(&a, key->pubkey.x, &prime, &t2);
-
-        if (err == MP_OKAY)
-            err = mp_add(&t1, &t2, &t1);
-
-        /* compute x^3 + a*x + b */
-        if (err == MP_OKAY)
-            err = mp_add(&t1, &b, &t1);
-
-        /* compute sqrt(x^3 + a*x + b) */
-        if (err == MP_OKAY)
-            err = mp_sqrtmod_prime(&t1, &prime, &t2);
-
-        /* adjust y */
-        if (err == MP_OKAY) {
-            if ((mp_isodd(&t2) && in[0] == 0x03) ||
-               (!mp_isodd(&t2) && in[0] == 0x02)) {
-                err = mp_mod(&t2, &prime, key->pubkey.y);
-            }
-            else {
-                err = mp_submod(&prime, &t2, &prime, key->pubkey.y);
-            }
-        }
-
-        mp_clear(&a);
-        mp_clear(&b);
-        mp_clear(&prime);
-        mp_clear(&t2);
-        mp_clear(&t1);
-   }
-#endif
-
-   if (err == MP_OKAY && compressed == 0)
-       err = mp_read_unsigned_bin(key->pubkey.y, (byte*)in+1+((inLen-1)>>1),
-                                  (inLen-1)>>1);
-   if (err == MP_OKAY)
-       mp_set(key->pubkey.z, 1);
-
-#ifdef WOLFSSL_VALIDATE_ECC_IMPORT
-   if (err == MP_OKAY)
-       err = wc_ecc_check_key(key);
-#endif
-
-   if (err != MP_OKAY) {
-       mp_clear(key->pubkey.x);
-       mp_clear(key->pubkey.y);
-       mp_clear(key->pubkey.z);
-       mp_clear(&key->k);
-   }
-
-   return err;
-}
-
-
-/* export ecc private key only raw, outLen is in/out size 
-   return MP_OKAY on success */
-int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen)
-{
-   word32 numlen;
-
-   if (key == NULL || out == NULL || outLen == NULL)
-       return ECC_BAD_ARG_E;
-
-   if (ecc_is_valid_idx(key->idx) == 0) {
-      return ECC_BAD_ARG_E;
-   }
-   numlen = key->dp->size;
-
-   if (*outLen < numlen) {
-      *outLen = numlen;
-      return BUFFER_E;
-   }
-   *outLen = numlen; 
-   XMEMSET(out, 0, *outLen);
-   return mp_to_unsigned_bin(&key->k, out + (numlen -
-                                             mp_unsigned_bin_size(&key->k)));
-}
-
-
-/* ecc private key import, public key in ANSI X9.63 format, private raw */
-int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub,
-                           word32 pubSz, ecc_key* key)
-{
-    int ret = wc_ecc_import_x963(pub, pubSz, key);
-    if (ret != 0)
-        return ret;
-
-    key->type = ECC_PRIVATEKEY;
-
-    ret = mp_read_unsigned_bin(&key->k, priv, privSz);
-
-#ifdef WOLFSSL_VALIDATE_ECC_IMPORT
-    if (ret == MP_OKAY)
-        ret = ecc_check_privkey_gen_helper(key);
-#endif
-
-    return ret;
-}
-
-/**
-   Convert ECC R,S to signature
-   r       R component of signature
-   s       S component of signature
-   out     DER-encoded ECDSA signature
-   outlen  [in/out] output buffer size, output signature size
-   return  MP_OKAY on success
-*/
-int wc_ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* outlen)
-{
-    int err;
-    mp_int rtmp;
-    mp_int stmp;
-
-    if (r == NULL || s == NULL || out == NULL || outlen == NULL)
-        return ECC_BAD_ARG_E;
-
-    err = mp_init_multi(&rtmp, &stmp, NULL, NULL, NULL, NULL);
-    if (err != MP_OKAY)
-        return err;
-
-    err = mp_read_radix(&rtmp, r, 16);
-    if (err == MP_OKAY)
-        err = mp_read_radix(&stmp, s, 16);
-
-    /* convert mp_ints to ECDSA sig, initializes rtmp and stmp internally */
-    if (err == MP_OKAY)
-        err = StoreECC_DSA_Sig(out, outlen, &rtmp, &stmp);
-
-    if (err == MP_OKAY) {
-        if (mp_iszero(&rtmp) || mp_iszero(&stmp))
-            err = MP_ZERO_E;
-    }
-
-    mp_clear(&rtmp);
-    mp_clear(&stmp);
-
-    return err;
-}
-
-/**
-   Import raw ECC key
-   key       The destination ecc_key structure
-   qx        x component of base point, as ASCII hex string
-   qy        y component of base point, as ASCII hex string
-   d         private key, as ASCII hex string
-   curveName ECC curve name, from ecc_sets[]
-   return    MP_OKAY on success
-*/
-int wc_ecc_import_raw(ecc_key* key, const char* qx, const char* qy,
-                   const char* d, const char* curveName)
-{
-    int err, x;
-
-    if (key == NULL || qx == NULL || qy == NULL || d == NULL ||
-        curveName == NULL)
-        return ECC_BAD_ARG_E;
-
-    /* init key */
-#ifdef ALT_ECC_SIZE
-    key->pubkey.x = (mp_int*)&key->pubkey.xyz[0];
-    key->pubkey.y = (mp_int*)&key->pubkey.xyz[1];
-    key->pubkey.z = (mp_int*)&key->pubkey.xyz[2];
-    alt_fp_init(key->pubkey.x);
-    alt_fp_init(key->pubkey.y);
-    alt_fp_init(key->pubkey.z);
-    err = mp_init(&key->k);
-#else
-    err = mp_init_multi(key->pubkey.x, key->pubkey.y, key->pubkey.z, &key->k,
-                      NULL, NULL);
-#endif
-    if (err != MP_OKAY)
-        return MEMORY_E;
-
-    /* read Qx */
-    if (err == MP_OKAY)
-        err = mp_read_radix(key->pubkey.x, qx, 16);
-
-    /* read Qy */
-    if (err == MP_OKAY)
-        err = mp_read_radix(key->pubkey.y, qy, 16);
-
-    if (err == MP_OKAY)
-        mp_set(key->pubkey.z, 1);
-
-    /* read and set the curve */
-    if (err == MP_OKAY) {
-        for (x = 0; ecc_sets[x].size != 0; x++) {
-            if (XSTRNCMP(ecc_sets[x].name, curveName,
-                         XSTRLEN(curveName)) == 0) {
-                break;
-            }
-        }
-        if (ecc_sets[x].size == 0) {
-            err = ASN_PARSE_E;
-        } else {
-            /* set the curve */
-            key->idx = x;
-            key->dp = &ecc_sets[x];
-            key->type = ECC_PUBLICKEY;
-        }
-    }
-
-    /* import private key */
-    if (err == MP_OKAY) {
-        key->type = ECC_PRIVATEKEY;
-        err = mp_read_radix(&key->k, d, 16);
-    }
-
-#ifdef WOLFSSL_VALIDATE_ECC_IMPORT
-    if (err == MP_OKAY)
-        err = wc_ecc_check_key(key);
-#endif
-
-    if (err != MP_OKAY) {
-        mp_clear(key->pubkey.x);
-        mp_clear(key->pubkey.y);
-        mp_clear(key->pubkey.z);
-        mp_clear(&key->k);
-    }
-
-    return err;
-}
-
-
-/* key size in octets */
-int wc_ecc_size(ecc_key* key)
-{
-    if (key == NULL) return 0;
-
-    return key->dp->size;
-}
-
-
-/* worst case estimate, check actual return from wc_ecc_sign_hash for actual value
-   of signature size in octets */
-int wc_ecc_sig_size(ecc_key* key)
-{
-    int sz = wc_ecc_size(key);
-    if (sz <= 0)
-        return sz;
-
-    return sz * 2 + SIG_HEADER_SZ + 4;  /* (4) worst case estimate */
-}
-
-
-#ifdef FP_ECC
-
-/* fixed point ECC cache */
-/* number of entries in the cache */
-#ifndef FP_ENTRIES
-    #define FP_ENTRIES 16
-#endif
-
-/* number of bits in LUT */
-#ifndef FP_LUT
-    #define FP_LUT     8U
-#endif
-
-#ifdef ECC_SHAMIR
-    /* Sharmir requires a bigger LUT, TAO */
-    #if (FP_LUT > 12) || (FP_LUT < 4)
-        #error FP_LUT must be between 4 and 12 inclusively
-    #endif
-#else
-    #if (FP_LUT > 12) || (FP_LUT < 2)
-        #error FP_LUT must be between 2 and 12 inclusively
-    #endif
-#endif
-
-
-/** Our FP cache */
-typedef struct {
-   ecc_point* g;               /* cached COPY of base point */
-   ecc_point* LUT[1U< 6
-   { 1, 0, 0 }, { 2, 1, 64 }, { 2, 2, 64 }, { 3, 3, 64 }, { 2, 4, 64 }, { 3, 5, 64 }, { 3, 6, 64 }, { 4, 7, 64 }, 
-   { 2, 8, 64 }, { 3, 9, 64 }, { 3, 10, 64 }, { 4, 11, 64 }, { 3, 12, 64 }, { 4, 13, 64 }, { 4, 14, 64 }, { 5, 15, 64 }, 
-   { 2, 16, 64 }, { 3, 17, 64 }, { 3, 18, 64 }, { 4, 19, 64 }, { 3, 20, 64 }, { 4, 21, 64 }, { 4, 22, 64 }, { 5, 23, 64 }, 
-   { 3, 24, 64 }, { 4, 25, 64 }, { 4, 26, 64 }, { 5, 27, 64 }, { 4, 28, 64 }, { 5, 29, 64 }, { 5, 30, 64 }, { 6, 31, 64 }, 
-   { 2, 32, 64 }, { 3, 33, 64 }, { 3, 34, 64 }, { 4, 35, 64 }, { 3, 36, 64 }, { 4, 37, 64 }, { 4, 38, 64 }, { 5, 39, 64 }, 
-   { 3, 40, 64 }, { 4, 41, 64 }, { 4, 42, 64 }, { 5, 43, 64 }, { 4, 44, 64 }, { 5, 45, 64 }, { 5, 46, 64 }, { 6, 47, 64 }, 
-   { 3, 48, 64 }, { 4, 49, 64 }, { 4, 50, 64 }, { 5, 51, 64 }, { 4, 52, 64 }, { 5, 53, 64 }, { 5, 54, 64 }, { 6, 55, 64 }, 
-   { 4, 56, 64 }, { 5, 57, 64 }, { 5, 58, 64 }, { 6, 59, 64 }, { 5, 60, 64 }, { 6, 61, 64 }, { 6, 62, 64 }, { 7, 63, 64 }, 
-#if FP_LUT > 7
-   { 1, 0, 0 }, { 2, 1, 128 }, { 2, 2, 128 }, { 3, 3, 128 }, { 2, 4, 128 }, { 3, 5, 128 }, { 3, 6, 128 }, { 4, 7, 128 }, 
-   { 2, 8, 128 }, { 3, 9, 128 }, { 3, 10, 128 }, { 4, 11, 128 }, { 3, 12, 128 }, { 4, 13, 128 }, { 4, 14, 128 }, { 5, 15, 128 }, 
-   { 2, 16, 128 }, { 3, 17, 128 }, { 3, 18, 128 }, { 4, 19, 128 }, { 3, 20, 128 }, { 4, 21, 128 }, { 4, 22, 128 }, { 5, 23, 128 }, 
-   { 3, 24, 128 }, { 4, 25, 128 }, { 4, 26, 128 }, { 5, 27, 128 }, { 4, 28, 128 }, { 5, 29, 128 }, { 5, 30, 128 }, { 6, 31, 128 }, 
-   { 2, 32, 128 }, { 3, 33, 128 }, { 3, 34, 128 }, { 4, 35, 128 }, { 3, 36, 128 }, { 4, 37, 128 }, { 4, 38, 128 }, { 5, 39, 128 }, 
-   { 3, 40, 128 }, { 4, 41, 128 }, { 4, 42, 128 }, { 5, 43, 128 }, { 4, 44, 128 }, { 5, 45, 128 }, { 5, 46, 128 }, { 6, 47, 128 }, 
-   { 3, 48, 128 }, { 4, 49, 128 }, { 4, 50, 128 }, { 5, 51, 128 }, { 4, 52, 128 }, { 5, 53, 128 }, { 5, 54, 128 }, { 6, 55, 128 }, 
-   { 4, 56, 128 }, { 5, 57, 128 }, { 5, 58, 128 }, { 6, 59, 128 }, { 5, 60, 128 }, { 6, 61, 128 }, { 6, 62, 128 }, { 7, 63, 128 }, 
-   { 2, 64, 128 }, { 3, 65, 128 }, { 3, 66, 128 }, { 4, 67, 128 }, { 3, 68, 128 }, { 4, 69, 128 }, { 4, 70, 128 }, { 5, 71, 128 }, 
-   { 3, 72, 128 }, { 4, 73, 128 }, { 4, 74, 128 }, { 5, 75, 128 }, { 4, 76, 128 }, { 5, 77, 128 }, { 5, 78, 128 }, { 6, 79, 128 }, 
-   { 3, 80, 128 }, { 4, 81, 128 }, { 4, 82, 128 }, { 5, 83, 128 }, { 4, 84, 128 }, { 5, 85, 128 }, { 5, 86, 128 }, { 6, 87, 128 }, 
-   { 4, 88, 128 }, { 5, 89, 128 }, { 5, 90, 128 }, { 6, 91, 128 }, { 5, 92, 128 }, { 6, 93, 128 }, { 6, 94, 128 }, { 7, 95, 128 }, 
-   { 3, 96, 128 }, { 4, 97, 128 }, { 4, 98, 128 }, { 5, 99, 128 }, { 4, 100, 128 }, { 5, 101, 128 }, { 5, 102, 128 }, { 6, 103, 128 }, 
-   { 4, 104, 128 }, { 5, 105, 128 }, { 5, 106, 128 }, { 6, 107, 128 }, { 5, 108, 128 }, { 6, 109, 128 }, { 6, 110, 128 }, { 7, 111, 128 }, 
-   { 4, 112, 128 }, { 5, 113, 128 }, { 5, 114, 128 }, { 6, 115, 128 }, { 5, 116, 128 }, { 6, 117, 128 }, { 6, 118, 128 }, { 7, 119, 128 }, 
-   { 5, 120, 128 }, { 6, 121, 128 }, { 6, 122, 128 }, { 7, 123, 128 }, { 6, 124, 128 }, { 7, 125, 128 }, { 7, 126, 128 }, { 8, 127, 128 }, 
-#if FP_LUT > 8
-   { 1, 0, 0 }, { 2, 1, 256 }, { 2, 2, 256 }, { 3, 3, 256 }, { 2, 4, 256 }, { 3, 5, 256 }, { 3, 6, 256 }, { 4, 7, 256 }, 
-   { 2, 8, 256 }, { 3, 9, 256 }, { 3, 10, 256 }, { 4, 11, 256 }, { 3, 12, 256 }, { 4, 13, 256 }, { 4, 14, 256 }, { 5, 15, 256 }, 
-   { 2, 16, 256 }, { 3, 17, 256 }, { 3, 18, 256 }, { 4, 19, 256 }, { 3, 20, 256 }, { 4, 21, 256 }, { 4, 22, 256 }, { 5, 23, 256 }, 
-   { 3, 24, 256 }, { 4, 25, 256 }, { 4, 26, 256 }, { 5, 27, 256 }, { 4, 28, 256 }, { 5, 29, 256 }, { 5, 30, 256 }, { 6, 31, 256 }, 
-   { 2, 32, 256 }, { 3, 33, 256 }, { 3, 34, 256 }, { 4, 35, 256 }, { 3, 36, 256 }, { 4, 37, 256 }, { 4, 38, 256 }, { 5, 39, 256 }, 
-   { 3, 40, 256 }, { 4, 41, 256 }, { 4, 42, 256 }, { 5, 43, 256 }, { 4, 44, 256 }, { 5, 45, 256 }, { 5, 46, 256 }, { 6, 47, 256 }, 
-   { 3, 48, 256 }, { 4, 49, 256 }, { 4, 50, 256 }, { 5, 51, 256 }, { 4, 52, 256 }, { 5, 53, 256 }, { 5, 54, 256 }, { 6, 55, 256 }, 
-   { 4, 56, 256 }, { 5, 57, 256 }, { 5, 58, 256 }, { 6, 59, 256 }, { 5, 60, 256 }, { 6, 61, 256 }, { 6, 62, 256 }, { 7, 63, 256 }, 
-   { 2, 64, 256 }, { 3, 65, 256 }, { 3, 66, 256 }, { 4, 67, 256 }, { 3, 68, 256 }, { 4, 69, 256 }, { 4, 70, 256 }, { 5, 71, 256 }, 
-   { 3, 72, 256 }, { 4, 73, 256 }, { 4, 74, 256 }, { 5, 75, 256 }, { 4, 76, 256 }, { 5, 77, 256 }, { 5, 78, 256 }, { 6, 79, 256 }, 
-   { 3, 80, 256 }, { 4, 81, 256 }, { 4, 82, 256 }, { 5, 83, 256 }, { 4, 84, 256 }, { 5, 85, 256 }, { 5, 86, 256 }, { 6, 87, 256 }, 
-   { 4, 88, 256 }, { 5, 89, 256 }, { 5, 90, 256 }, { 6, 91, 256 }, { 5, 92, 256 }, { 6, 93, 256 }, { 6, 94, 256 }, { 7, 95, 256 }, 
-   { 3, 96, 256 }, { 4, 97, 256 }, { 4, 98, 256 }, { 5, 99, 256 }, { 4, 100, 256 }, { 5, 101, 256 }, { 5, 102, 256 }, { 6, 103, 256 }, 
-   { 4, 104, 256 }, { 5, 105, 256 }, { 5, 106, 256 }, { 6, 107, 256 }, { 5, 108, 256 }, { 6, 109, 256 }, { 6, 110, 256 }, { 7, 111, 256 }, 
-   { 4, 112, 256 }, { 5, 113, 256 }, { 5, 114, 256 }, { 6, 115, 256 }, { 5, 116, 256 }, { 6, 117, 256 }, { 6, 118, 256 }, { 7, 119, 256 }, 
-   { 5, 120, 256 }, { 6, 121, 256 }, { 6, 122, 256 }, { 7, 123, 256 }, { 6, 124, 256 }, { 7, 125, 256 }, { 7, 126, 256 }, { 8, 127, 256 }, 
-   { 2, 128, 256 }, { 3, 129, 256 }, { 3, 130, 256 }, { 4, 131, 256 }, { 3, 132, 256 }, { 4, 133, 256 }, { 4, 134, 256 }, { 5, 135, 256 }, 
-   { 3, 136, 256 }, { 4, 137, 256 }, { 4, 138, 256 }, { 5, 139, 256 }, { 4, 140, 256 }, { 5, 141, 256 }, { 5, 142, 256 }, { 6, 143, 256 }, 
-   { 3, 144, 256 }, { 4, 145, 256 }, { 4, 146, 256 }, { 5, 147, 256 }, { 4, 148, 256 }, { 5, 149, 256 }, { 5, 150, 256 }, { 6, 151, 256 }, 
-   { 4, 152, 256 }, { 5, 153, 256 }, { 5, 154, 256 }, { 6, 155, 256 }, { 5, 156, 256 }, { 6, 157, 256 }, { 6, 158, 256 }, { 7, 159, 256 }, 
-   { 3, 160, 256 }, { 4, 161, 256 }, { 4, 162, 256 }, { 5, 163, 256 }, { 4, 164, 256 }, { 5, 165, 256 }, { 5, 166, 256 }, { 6, 167, 256 }, 
-   { 4, 168, 256 }, { 5, 169, 256 }, { 5, 170, 256 }, { 6, 171, 256 }, { 5, 172, 256 }, { 6, 173, 256 }, { 6, 174, 256 }, { 7, 175, 256 }, 
-   { 4, 176, 256 }, { 5, 177, 256 }, { 5, 178, 256 }, { 6, 179, 256 }, { 5, 180, 256 }, { 6, 181, 256 }, { 6, 182, 256 }, { 7, 183, 256 }, 
-   { 5, 184, 256 }, { 6, 185, 256 }, { 6, 186, 256 }, { 7, 187, 256 }, { 6, 188, 256 }, { 7, 189, 256 }, { 7, 190, 256 }, { 8, 191, 256 }, 
-   { 3, 192, 256 }, { 4, 193, 256 }, { 4, 194, 256 }, { 5, 195, 256 }, { 4, 196, 256 }, { 5, 197, 256 }, { 5, 198, 256 }, { 6, 199, 256 }, 
-   { 4, 200, 256 }, { 5, 201, 256 }, { 5, 202, 256 }, { 6, 203, 256 }, { 5, 204, 256 }, { 6, 205, 256 }, { 6, 206, 256 }, { 7, 207, 256 }, 
-   { 4, 208, 256 }, { 5, 209, 256 }, { 5, 210, 256 }, { 6, 211, 256 }, { 5, 212, 256 }, { 6, 213, 256 }, { 6, 214, 256 }, { 7, 215, 256 }, 
-   { 5, 216, 256 }, { 6, 217, 256 }, { 6, 218, 256 }, { 7, 219, 256 }, { 6, 220, 256 }, { 7, 221, 256 }, { 7, 222, 256 }, { 8, 223, 256 }, 
-   { 4, 224, 256 }, { 5, 225, 256 }, { 5, 226, 256 }, { 6, 227, 256 }, { 5, 228, 256 }, { 6, 229, 256 }, { 6, 230, 256 }, { 7, 231, 256 }, 
-   { 5, 232, 256 }, { 6, 233, 256 }, { 6, 234, 256 }, { 7, 235, 256 }, { 6, 236, 256 }, { 7, 237, 256 }, { 7, 238, 256 }, { 8, 239, 256 }, 
-   { 5, 240, 256 }, { 6, 241, 256 }, { 6, 242, 256 }, { 7, 243, 256 }, { 6, 244, 256 }, { 7, 245, 256 }, { 7, 246, 256 }, { 8, 247, 256 }, 
-   { 6, 248, 256 }, { 7, 249, 256 }, { 7, 250, 256 }, { 8, 251, 256 }, { 7, 252, 256 }, { 8, 253, 256 }, { 8, 254, 256 }, { 9, 255, 256 }, 
-#if FP_LUT > 9
-   { 1, 0, 0 }, { 2, 1, 512 }, { 2, 2, 512 }, { 3, 3, 512 }, { 2, 4, 512 }, { 3, 5, 512 }, { 3, 6, 512 }, { 4, 7, 512 }, 
-   { 2, 8, 512 }, { 3, 9, 512 }, { 3, 10, 512 }, { 4, 11, 512 }, { 3, 12, 512 }, { 4, 13, 512 }, { 4, 14, 512 }, { 5, 15, 512 }, 
-   { 2, 16, 512 }, { 3, 17, 512 }, { 3, 18, 512 }, { 4, 19, 512 }, { 3, 20, 512 }, { 4, 21, 512 }, { 4, 22, 512 }, { 5, 23, 512 }, 
-   { 3, 24, 512 }, { 4, 25, 512 }, { 4, 26, 512 }, { 5, 27, 512 }, { 4, 28, 512 }, { 5, 29, 512 }, { 5, 30, 512 }, { 6, 31, 512 }, 
-   { 2, 32, 512 }, { 3, 33, 512 }, { 3, 34, 512 }, { 4, 35, 512 }, { 3, 36, 512 }, { 4, 37, 512 }, { 4, 38, 512 }, { 5, 39, 512 }, 
-   { 3, 40, 512 }, { 4, 41, 512 }, { 4, 42, 512 }, { 5, 43, 512 }, { 4, 44, 512 }, { 5, 45, 512 }, { 5, 46, 512 }, { 6, 47, 512 }, 
-   { 3, 48, 512 }, { 4, 49, 512 }, { 4, 50, 512 }, { 5, 51, 512 }, { 4, 52, 512 }, { 5, 53, 512 }, { 5, 54, 512 }, { 6, 55, 512 }, 
-   { 4, 56, 512 }, { 5, 57, 512 }, { 5, 58, 512 }, { 6, 59, 512 }, { 5, 60, 512 }, { 6, 61, 512 }, { 6, 62, 512 }, { 7, 63, 512 }, 
-   { 2, 64, 512 }, { 3, 65, 512 }, { 3, 66, 512 }, { 4, 67, 512 }, { 3, 68, 512 }, { 4, 69, 512 }, { 4, 70, 512 }, { 5, 71, 512 }, 
-   { 3, 72, 512 }, { 4, 73, 512 }, { 4, 74, 512 }, { 5, 75, 512 }, { 4, 76, 512 }, { 5, 77, 512 }, { 5, 78, 512 }, { 6, 79, 512 }, 
-   { 3, 80, 512 }, { 4, 81, 512 }, { 4, 82, 512 }, { 5, 83, 512 }, { 4, 84, 512 }, { 5, 85, 512 }, { 5, 86, 512 }, { 6, 87, 512 }, 
-   { 4, 88, 512 }, { 5, 89, 512 }, { 5, 90, 512 }, { 6, 91, 512 }, { 5, 92, 512 }, { 6, 93, 512 }, { 6, 94, 512 }, { 7, 95, 512 }, 
-   { 3, 96, 512 }, { 4, 97, 512 }, { 4, 98, 512 }, { 5, 99, 512 }, { 4, 100, 512 }, { 5, 101, 512 }, { 5, 102, 512 }, { 6, 103, 512 }, 
-   { 4, 104, 512 }, { 5, 105, 512 }, { 5, 106, 512 }, { 6, 107, 512 }, { 5, 108, 512 }, { 6, 109, 512 }, { 6, 110, 512 }, { 7, 111, 512 }, 
-   { 4, 112, 512 }, { 5, 113, 512 }, { 5, 114, 512 }, { 6, 115, 512 }, { 5, 116, 512 }, { 6, 117, 512 }, { 6, 118, 512 }, { 7, 119, 512 }, 
-   { 5, 120, 512 }, { 6, 121, 512 }, { 6, 122, 512 }, { 7, 123, 512 }, { 6, 124, 512 }, { 7, 125, 512 }, { 7, 126, 512 }, { 8, 127, 512 }, 
-   { 2, 128, 512 }, { 3, 129, 512 }, { 3, 130, 512 }, { 4, 131, 512 }, { 3, 132, 512 }, { 4, 133, 512 }, { 4, 134, 512 }, { 5, 135, 512 }, 
-   { 3, 136, 512 }, { 4, 137, 512 }, { 4, 138, 512 }, { 5, 139, 512 }, { 4, 140, 512 }, { 5, 141, 512 }, { 5, 142, 512 }, { 6, 143, 512 }, 
-   { 3, 144, 512 }, { 4, 145, 512 }, { 4, 146, 512 }, { 5, 147, 512 }, { 4, 148, 512 }, { 5, 149, 512 }, { 5, 150, 512 }, { 6, 151, 512 }, 
-   { 4, 152, 512 }, { 5, 153, 512 }, { 5, 154, 512 }, { 6, 155, 512 }, { 5, 156, 512 }, { 6, 157, 512 }, { 6, 158, 512 }, { 7, 159, 512 }, 
-   { 3, 160, 512 }, { 4, 161, 512 }, { 4, 162, 512 }, { 5, 163, 512 }, { 4, 164, 512 }, { 5, 165, 512 }, { 5, 166, 512 }, { 6, 167, 512 }, 
-   { 4, 168, 512 }, { 5, 169, 512 }, { 5, 170, 512 }, { 6, 171, 512 }, { 5, 172, 512 }, { 6, 173, 512 }, { 6, 174, 512 }, { 7, 175, 512 }, 
-   { 4, 176, 512 }, { 5, 177, 512 }, { 5, 178, 512 }, { 6, 179, 512 }, { 5, 180, 512 }, { 6, 181, 512 }, { 6, 182, 512 }, { 7, 183, 512 }, 
-   { 5, 184, 512 }, { 6, 185, 512 }, { 6, 186, 512 }, { 7, 187, 512 }, { 6, 188, 512 }, { 7, 189, 512 }, { 7, 190, 512 }, { 8, 191, 512 }, 
-   { 3, 192, 512 }, { 4, 193, 512 }, { 4, 194, 512 }, { 5, 195, 512 }, { 4, 196, 512 }, { 5, 197, 512 }, { 5, 198, 512 }, { 6, 199, 512 }, 
-   { 4, 200, 512 }, { 5, 201, 512 }, { 5, 202, 512 }, { 6, 203, 512 }, { 5, 204, 512 }, { 6, 205, 512 }, { 6, 206, 512 }, { 7, 207, 512 }, 
-   { 4, 208, 512 }, { 5, 209, 512 }, { 5, 210, 512 }, { 6, 211, 512 }, { 5, 212, 512 }, { 6, 213, 512 }, { 6, 214, 512 }, { 7, 215, 512 }, 
-   { 5, 216, 512 }, { 6, 217, 512 }, { 6, 218, 512 }, { 7, 219, 512 }, { 6, 220, 512 }, { 7, 221, 512 }, { 7, 222, 512 }, { 8, 223, 512 }, 
-   { 4, 224, 512 }, { 5, 225, 512 }, { 5, 226, 512 }, { 6, 227, 512 }, { 5, 228, 512 }, { 6, 229, 512 }, { 6, 230, 512 }, { 7, 231, 512 }, 
-   { 5, 232, 512 }, { 6, 233, 512 }, { 6, 234, 512 }, { 7, 235, 512 }, { 6, 236, 512 }, { 7, 237, 512 }, { 7, 238, 512 }, { 8, 239, 512 }, 
-   { 5, 240, 512 }, { 6, 241, 512 }, { 6, 242, 512 }, { 7, 243, 512 }, { 6, 244, 512 }, { 7, 245, 512 }, { 7, 246, 512 }, { 8, 247, 512 }, 
-   { 6, 248, 512 }, { 7, 249, 512 }, { 7, 250, 512 }, { 8, 251, 512 }, { 7, 252, 512 }, { 8, 253, 512 }, { 8, 254, 512 }, { 9, 255, 512 }, 
-   { 2, 256, 512 }, { 3, 257, 512 }, { 3, 258, 512 }, { 4, 259, 512 }, { 3, 260, 512 }, { 4, 261, 512 }, { 4, 262, 512 }, { 5, 263, 512 }, 
-   { 3, 264, 512 }, { 4, 265, 512 }, { 4, 266, 512 }, { 5, 267, 512 }, { 4, 268, 512 }, { 5, 269, 512 }, { 5, 270, 512 }, { 6, 271, 512 }, 
-   { 3, 272, 512 }, { 4, 273, 512 }, { 4, 274, 512 }, { 5, 275, 512 }, { 4, 276, 512 }, { 5, 277, 512 }, { 5, 278, 512 }, { 6, 279, 512 }, 
-   { 4, 280, 512 }, { 5, 281, 512 }, { 5, 282, 512 }, { 6, 283, 512 }, { 5, 284, 512 }, { 6, 285, 512 }, { 6, 286, 512 }, { 7, 287, 512 }, 
-   { 3, 288, 512 }, { 4, 289, 512 }, { 4, 290, 512 }, { 5, 291, 512 }, { 4, 292, 512 }, { 5, 293, 512 }, { 5, 294, 512 }, { 6, 295, 512 }, 
-   { 4, 296, 512 }, { 5, 297, 512 }, { 5, 298, 512 }, { 6, 299, 512 }, { 5, 300, 512 }, { 6, 301, 512 }, { 6, 302, 512 }, { 7, 303, 512 }, 
-   { 4, 304, 512 }, { 5, 305, 512 }, { 5, 306, 512 }, { 6, 307, 512 }, { 5, 308, 512 }, { 6, 309, 512 }, { 6, 310, 512 }, { 7, 311, 512 }, 
-   { 5, 312, 512 }, { 6, 313, 512 }, { 6, 314, 512 }, { 7, 315, 512 }, { 6, 316, 512 }, { 7, 317, 512 }, { 7, 318, 512 }, { 8, 319, 512 }, 
-   { 3, 320, 512 }, { 4, 321, 512 }, { 4, 322, 512 }, { 5, 323, 512 }, { 4, 324, 512 }, { 5, 325, 512 }, { 5, 326, 512 }, { 6, 327, 512 }, 
-   { 4, 328, 512 }, { 5, 329, 512 }, { 5, 330, 512 }, { 6, 331, 512 }, { 5, 332, 512 }, { 6, 333, 512 }, { 6, 334, 512 }, { 7, 335, 512 }, 
-   { 4, 336, 512 }, { 5, 337, 512 }, { 5, 338, 512 }, { 6, 339, 512 }, { 5, 340, 512 }, { 6, 341, 512 }, { 6, 342, 512 }, { 7, 343, 512 }, 
-   { 5, 344, 512 }, { 6, 345, 512 }, { 6, 346, 512 }, { 7, 347, 512 }, { 6, 348, 512 }, { 7, 349, 512 }, { 7, 350, 512 }, { 8, 351, 512 }, 
-   { 4, 352, 512 }, { 5, 353, 512 }, { 5, 354, 512 }, { 6, 355, 512 }, { 5, 356, 512 }, { 6, 357, 512 }, { 6, 358, 512 }, { 7, 359, 512 }, 
-   { 5, 360, 512 }, { 6, 361, 512 }, { 6, 362, 512 }, { 7, 363, 512 }, { 6, 364, 512 }, { 7, 365, 512 }, { 7, 366, 512 }, { 8, 367, 512 }, 
-   { 5, 368, 512 }, { 6, 369, 512 }, { 6, 370, 512 }, { 7, 371, 512 }, { 6, 372, 512 }, { 7, 373, 512 }, { 7, 374, 512 }, { 8, 375, 512 }, 
-   { 6, 376, 512 }, { 7, 377, 512 }, { 7, 378, 512 }, { 8, 379, 512 }, { 7, 380, 512 }, { 8, 381, 512 }, { 8, 382, 512 }, { 9, 383, 512 }, 
-   { 3, 384, 512 }, { 4, 385, 512 }, { 4, 386, 512 }, { 5, 387, 512 }, { 4, 388, 512 }, { 5, 389, 512 }, { 5, 390, 512 }, { 6, 391, 512 }, 
-   { 4, 392, 512 }, { 5, 393, 512 }, { 5, 394, 512 }, { 6, 395, 512 }, { 5, 396, 512 }, { 6, 397, 512 }, { 6, 398, 512 }, { 7, 399, 512 }, 
-   { 4, 400, 512 }, { 5, 401, 512 }, { 5, 402, 512 }, { 6, 403, 512 }, { 5, 404, 512 }, { 6, 405, 512 }, { 6, 406, 512 }, { 7, 407, 512 }, 
-   { 5, 408, 512 }, { 6, 409, 512 }, { 6, 410, 512 }, { 7, 411, 512 }, { 6, 412, 512 }, { 7, 413, 512 }, { 7, 414, 512 }, { 8, 415, 512 }, 
-   { 4, 416, 512 }, { 5, 417, 512 }, { 5, 418, 512 }, { 6, 419, 512 }, { 5, 420, 512 }, { 6, 421, 512 }, { 6, 422, 512 }, { 7, 423, 512 }, 
-   { 5, 424, 512 }, { 6, 425, 512 }, { 6, 426, 512 }, { 7, 427, 512 }, { 6, 428, 512 }, { 7, 429, 512 }, { 7, 430, 512 }, { 8, 431, 512 }, 
-   { 5, 432, 512 }, { 6, 433, 512 }, { 6, 434, 512 }, { 7, 435, 512 }, { 6, 436, 512 }, { 7, 437, 512 }, { 7, 438, 512 }, { 8, 439, 512 }, 
-   { 6, 440, 512 }, { 7, 441, 512 }, { 7, 442, 512 }, { 8, 443, 512 }, { 7, 444, 512 }, { 8, 445, 512 }, { 8, 446, 512 }, { 9, 447, 512 }, 
-   { 4, 448, 512 }, { 5, 449, 512 }, { 5, 450, 512 }, { 6, 451, 512 }, { 5, 452, 512 }, { 6, 453, 512 }, { 6, 454, 512 }, { 7, 455, 512 }, 
-   { 5, 456, 512 }, { 6, 457, 512 }, { 6, 458, 512 }, { 7, 459, 512 }, { 6, 460, 512 }, { 7, 461, 512 }, { 7, 462, 512 }, { 8, 463, 512 }, 
-   { 5, 464, 512 }, { 6, 465, 512 }, { 6, 466, 512 }, { 7, 467, 512 }, { 6, 468, 512 }, { 7, 469, 512 }, { 7, 470, 512 }, { 8, 471, 512 }, 
-   { 6, 472, 512 }, { 7, 473, 512 }, { 7, 474, 512 }, { 8, 475, 512 }, { 7, 476, 512 }, { 8, 477, 512 }, { 8, 478, 512 }, { 9, 479, 512 }, 
-   { 5, 480, 512 }, { 6, 481, 512 }, { 6, 482, 512 }, { 7, 483, 512 }, { 6, 484, 512 }, { 7, 485, 512 }, { 7, 486, 512 }, { 8, 487, 512 }, 
-   { 6, 488, 512 }, { 7, 489, 512 }, { 7, 490, 512 }, { 8, 491, 512 }, { 7, 492, 512 }, { 8, 493, 512 }, { 8, 494, 512 }, { 9, 495, 512 }, 
-   { 6, 496, 512 }, { 7, 497, 512 }, { 7, 498, 512 }, { 8, 499, 512 }, { 7, 500, 512 }, { 8, 501, 512 }, { 8, 502, 512 }, { 9, 503, 512 }, 
-   { 7, 504, 512 }, { 8, 505, 512 }, { 8, 506, 512 }, { 9, 507, 512 }, { 8, 508, 512 }, { 9, 509, 512 }, { 9, 510, 512 }, { 10, 511, 512 }, 
-#if FP_LUT > 10
-   { 1, 0, 0 }, { 2, 1, 1024 }, { 2, 2, 1024 }, { 3, 3, 1024 }, { 2, 4, 1024 }, { 3, 5, 1024 }, { 3, 6, 1024 }, { 4, 7, 1024 }, 
-   { 2, 8, 1024 }, { 3, 9, 1024 }, { 3, 10, 1024 }, { 4, 11, 1024 }, { 3, 12, 1024 }, { 4, 13, 1024 }, { 4, 14, 1024 }, { 5, 15, 1024 }, 
-   { 2, 16, 1024 }, { 3, 17, 1024 }, { 3, 18, 1024 }, { 4, 19, 1024 }, { 3, 20, 1024 }, { 4, 21, 1024 }, { 4, 22, 1024 }, { 5, 23, 1024 }, 
-   { 3, 24, 1024 }, { 4, 25, 1024 }, { 4, 26, 1024 }, { 5, 27, 1024 }, { 4, 28, 1024 }, { 5, 29, 1024 }, { 5, 30, 1024 }, { 6, 31, 1024 }, 
-   { 2, 32, 1024 }, { 3, 33, 1024 }, { 3, 34, 1024 }, { 4, 35, 1024 }, { 3, 36, 1024 }, { 4, 37, 1024 }, { 4, 38, 1024 }, { 5, 39, 1024 }, 
-   { 3, 40, 1024 }, { 4, 41, 1024 }, { 4, 42, 1024 }, { 5, 43, 1024 }, { 4, 44, 1024 }, { 5, 45, 1024 }, { 5, 46, 1024 }, { 6, 47, 1024 }, 
-   { 3, 48, 1024 }, { 4, 49, 1024 }, { 4, 50, 1024 }, { 5, 51, 1024 }, { 4, 52, 1024 }, { 5, 53, 1024 }, { 5, 54, 1024 }, { 6, 55, 1024 }, 
-   { 4, 56, 1024 }, { 5, 57, 1024 }, { 5, 58, 1024 }, { 6, 59, 1024 }, { 5, 60, 1024 }, { 6, 61, 1024 }, { 6, 62, 1024 }, { 7, 63, 1024 }, 
-   { 2, 64, 1024 }, { 3, 65, 1024 }, { 3, 66, 1024 }, { 4, 67, 1024 }, { 3, 68, 1024 }, { 4, 69, 1024 }, { 4, 70, 1024 }, { 5, 71, 1024 }, 
-   { 3, 72, 1024 }, { 4, 73, 1024 }, { 4, 74, 1024 }, { 5, 75, 1024 }, { 4, 76, 1024 }, { 5, 77, 1024 }, { 5, 78, 1024 }, { 6, 79, 1024 }, 
-   { 3, 80, 1024 }, { 4, 81, 1024 }, { 4, 82, 1024 }, { 5, 83, 1024 }, { 4, 84, 1024 }, { 5, 85, 1024 }, { 5, 86, 1024 }, { 6, 87, 1024 }, 
-   { 4, 88, 1024 }, { 5, 89, 1024 }, { 5, 90, 1024 }, { 6, 91, 1024 }, { 5, 92, 1024 }, { 6, 93, 1024 }, { 6, 94, 1024 }, { 7, 95, 1024 }, 
-   { 3, 96, 1024 }, { 4, 97, 1024 }, { 4, 98, 1024 }, { 5, 99, 1024 }, { 4, 100, 1024 }, { 5, 101, 1024 }, { 5, 102, 1024 }, { 6, 103, 1024 }, 
-   { 4, 104, 1024 }, { 5, 105, 1024 }, { 5, 106, 1024 }, { 6, 107, 1024 }, { 5, 108, 1024 }, { 6, 109, 1024 }, { 6, 110, 1024 }, { 7, 111, 1024 }, 
-   { 4, 112, 1024 }, { 5, 113, 1024 }, { 5, 114, 1024 }, { 6, 115, 1024 }, { 5, 116, 1024 }, { 6, 117, 1024 }, { 6, 118, 1024 }, { 7, 119, 1024 }, 
-   { 5, 120, 1024 }, { 6, 121, 1024 }, { 6, 122, 1024 }, { 7, 123, 1024 }, { 6, 124, 1024 }, { 7, 125, 1024 }, { 7, 126, 1024 }, { 8, 127, 1024 }, 
-   { 2, 128, 1024 }, { 3, 129, 1024 }, { 3, 130, 1024 }, { 4, 131, 1024 }, { 3, 132, 1024 }, { 4, 133, 1024 }, { 4, 134, 1024 }, { 5, 135, 1024 }, 
-   { 3, 136, 1024 }, { 4, 137, 1024 }, { 4, 138, 1024 }, { 5, 139, 1024 }, { 4, 140, 1024 }, { 5, 141, 1024 }, { 5, 142, 1024 }, { 6, 143, 1024 }, 
-   { 3, 144, 1024 }, { 4, 145, 1024 }, { 4, 146, 1024 }, { 5, 147, 1024 }, { 4, 148, 1024 }, { 5, 149, 1024 }, { 5, 150, 1024 }, { 6, 151, 1024 }, 
-   { 4, 152, 1024 }, { 5, 153, 1024 }, { 5, 154, 1024 }, { 6, 155, 1024 }, { 5, 156, 1024 }, { 6, 157, 1024 }, { 6, 158, 1024 }, { 7, 159, 1024 }, 
-   { 3, 160, 1024 }, { 4, 161, 1024 }, { 4, 162, 1024 }, { 5, 163, 1024 }, { 4, 164, 1024 }, { 5, 165, 1024 }, { 5, 166, 1024 }, { 6, 167, 1024 }, 
-   { 4, 168, 1024 }, { 5, 169, 1024 }, { 5, 170, 1024 }, { 6, 171, 1024 }, { 5, 172, 1024 }, { 6, 173, 1024 }, { 6, 174, 1024 }, { 7, 175, 1024 }, 
-   { 4, 176, 1024 }, { 5, 177, 1024 }, { 5, 178, 1024 }, { 6, 179, 1024 }, { 5, 180, 1024 }, { 6, 181, 1024 }, { 6, 182, 1024 }, { 7, 183, 1024 }, 
-   { 5, 184, 1024 }, { 6, 185, 1024 }, { 6, 186, 1024 }, { 7, 187, 1024 }, { 6, 188, 1024 }, { 7, 189, 1024 }, { 7, 190, 1024 }, { 8, 191, 1024 }, 
-   { 3, 192, 1024 }, { 4, 193, 1024 }, { 4, 194, 1024 }, { 5, 195, 1024 }, { 4, 196, 1024 }, { 5, 197, 1024 }, { 5, 198, 1024 }, { 6, 199, 1024 }, 
-   { 4, 200, 1024 }, { 5, 201, 1024 }, { 5, 202, 1024 }, { 6, 203, 1024 }, { 5, 204, 1024 }, { 6, 205, 1024 }, { 6, 206, 1024 }, { 7, 207, 1024 }, 
-   { 4, 208, 1024 }, { 5, 209, 1024 }, { 5, 210, 1024 }, { 6, 211, 1024 }, { 5, 212, 1024 }, { 6, 213, 1024 }, { 6, 214, 1024 }, { 7, 215, 1024 }, 
-   { 5, 216, 1024 }, { 6, 217, 1024 }, { 6, 218, 1024 }, { 7, 219, 1024 }, { 6, 220, 1024 }, { 7, 221, 1024 }, { 7, 222, 1024 }, { 8, 223, 1024 }, 
-   { 4, 224, 1024 }, { 5, 225, 1024 }, { 5, 226, 1024 }, { 6, 227, 1024 }, { 5, 228, 1024 }, { 6, 229, 1024 }, { 6, 230, 1024 }, { 7, 231, 1024 }, 
-   { 5, 232, 1024 }, { 6, 233, 1024 }, { 6, 234, 1024 }, { 7, 235, 1024 }, { 6, 236, 1024 }, { 7, 237, 1024 }, { 7, 238, 1024 }, { 8, 239, 1024 }, 
-   { 5, 240, 1024 }, { 6, 241, 1024 }, { 6, 242, 1024 }, { 7, 243, 1024 }, { 6, 244, 1024 }, { 7, 245, 1024 }, { 7, 246, 1024 }, { 8, 247, 1024 }, 
-   { 6, 248, 1024 }, { 7, 249, 1024 }, { 7, 250, 1024 }, { 8, 251, 1024 }, { 7, 252, 1024 }, { 8, 253, 1024 }, { 8, 254, 1024 }, { 9, 255, 1024 }, 
-   { 2, 256, 1024 }, { 3, 257, 1024 }, { 3, 258, 1024 }, { 4, 259, 1024 }, { 3, 260, 1024 }, { 4, 261, 1024 }, { 4, 262, 1024 }, { 5, 263, 1024 }, 
-   { 3, 264, 1024 }, { 4, 265, 1024 }, { 4, 266, 1024 }, { 5, 267, 1024 }, { 4, 268, 1024 }, { 5, 269, 1024 }, { 5, 270, 1024 }, { 6, 271, 1024 }, 
-   { 3, 272, 1024 }, { 4, 273, 1024 }, { 4, 274, 1024 }, { 5, 275, 1024 }, { 4, 276, 1024 }, { 5, 277, 1024 }, { 5, 278, 1024 }, { 6, 279, 1024 }, 
-   { 4, 280, 1024 }, { 5, 281, 1024 }, { 5, 282, 1024 }, { 6, 283, 1024 }, { 5, 284, 1024 }, { 6, 285, 1024 }, { 6, 286, 1024 }, { 7, 287, 1024 }, 
-   { 3, 288, 1024 }, { 4, 289, 1024 }, { 4, 290, 1024 }, { 5, 291, 1024 }, { 4, 292, 1024 }, { 5, 293, 1024 }, { 5, 294, 1024 }, { 6, 295, 1024 }, 
-   { 4, 296, 1024 }, { 5, 297, 1024 }, { 5, 298, 1024 }, { 6, 299, 1024 }, { 5, 300, 1024 }, { 6, 301, 1024 }, { 6, 302, 1024 }, { 7, 303, 1024 }, 
-   { 4, 304, 1024 }, { 5, 305, 1024 }, { 5, 306, 1024 }, { 6, 307, 1024 }, { 5, 308, 1024 }, { 6, 309, 1024 }, { 6, 310, 1024 }, { 7, 311, 1024 }, 
-   { 5, 312, 1024 }, { 6, 313, 1024 }, { 6, 314, 1024 }, { 7, 315, 1024 }, { 6, 316, 1024 }, { 7, 317, 1024 }, { 7, 318, 1024 }, { 8, 319, 1024 }, 
-   { 3, 320, 1024 }, { 4, 321, 1024 }, { 4, 322, 1024 }, { 5, 323, 1024 }, { 4, 324, 1024 }, { 5, 325, 1024 }, { 5, 326, 1024 }, { 6, 327, 1024 }, 
-   { 4, 328, 1024 }, { 5, 329, 1024 }, { 5, 330, 1024 }, { 6, 331, 1024 }, { 5, 332, 1024 }, { 6, 333, 1024 }, { 6, 334, 1024 }, { 7, 335, 1024 }, 
-   { 4, 336, 1024 }, { 5, 337, 1024 }, { 5, 338, 1024 }, { 6, 339, 1024 }, { 5, 340, 1024 }, { 6, 341, 1024 }, { 6, 342, 1024 }, { 7, 343, 1024 }, 
-   { 5, 344, 1024 }, { 6, 345, 1024 }, { 6, 346, 1024 }, { 7, 347, 1024 }, { 6, 348, 1024 }, { 7, 349, 1024 }, { 7, 350, 1024 }, { 8, 351, 1024 }, 
-   { 4, 352, 1024 }, { 5, 353, 1024 }, { 5, 354, 1024 }, { 6, 355, 1024 }, { 5, 356, 1024 }, { 6, 357, 1024 }, { 6, 358, 1024 }, { 7, 359, 1024 }, 
-   { 5, 360, 1024 }, { 6, 361, 1024 }, { 6, 362, 1024 }, { 7, 363, 1024 }, { 6, 364, 1024 }, { 7, 365, 1024 }, { 7, 366, 1024 }, { 8, 367, 1024 }, 
-   { 5, 368, 1024 }, { 6, 369, 1024 }, { 6, 370, 1024 }, { 7, 371, 1024 }, { 6, 372, 1024 }, { 7, 373, 1024 }, { 7, 374, 1024 }, { 8, 375, 1024 }, 
-   { 6, 376, 1024 }, { 7, 377, 1024 }, { 7, 378, 1024 }, { 8, 379, 1024 }, { 7, 380, 1024 }, { 8, 381, 1024 }, { 8, 382, 1024 }, { 9, 383, 1024 }, 
-   { 3, 384, 1024 }, { 4, 385, 1024 }, { 4, 386, 1024 }, { 5, 387, 1024 }, { 4, 388, 1024 }, { 5, 389, 1024 }, { 5, 390, 1024 }, { 6, 391, 1024 }, 
-   { 4, 392, 1024 }, { 5, 393, 1024 }, { 5, 394, 1024 }, { 6, 395, 1024 }, { 5, 396, 1024 }, { 6, 397, 1024 }, { 6, 398, 1024 }, { 7, 399, 1024 }, 
-   { 4, 400, 1024 }, { 5, 401, 1024 }, { 5, 402, 1024 }, { 6, 403, 1024 }, { 5, 404, 1024 }, { 6, 405, 1024 }, { 6, 406, 1024 }, { 7, 407, 1024 }, 
-   { 5, 408, 1024 }, { 6, 409, 1024 }, { 6, 410, 1024 }, { 7, 411, 1024 }, { 6, 412, 1024 }, { 7, 413, 1024 }, { 7, 414, 1024 }, { 8, 415, 1024 }, 
-   { 4, 416, 1024 }, { 5, 417, 1024 }, { 5, 418, 1024 }, { 6, 419, 1024 }, { 5, 420, 1024 }, { 6, 421, 1024 }, { 6, 422, 1024 }, { 7, 423, 1024 }, 
-   { 5, 424, 1024 }, { 6, 425, 1024 }, { 6, 426, 1024 }, { 7, 427, 1024 }, { 6, 428, 1024 }, { 7, 429, 1024 }, { 7, 430, 1024 }, { 8, 431, 1024 }, 
-   { 5, 432, 1024 }, { 6, 433, 1024 }, { 6, 434, 1024 }, { 7, 435, 1024 }, { 6, 436, 1024 }, { 7, 437, 1024 }, { 7, 438, 1024 }, { 8, 439, 1024 }, 
-   { 6, 440, 1024 }, { 7, 441, 1024 }, { 7, 442, 1024 }, { 8, 443, 1024 }, { 7, 444, 1024 }, { 8, 445, 1024 }, { 8, 446, 1024 }, { 9, 447, 1024 }, 
-   { 4, 448, 1024 }, { 5, 449, 1024 }, { 5, 450, 1024 }, { 6, 451, 1024 }, { 5, 452, 1024 }, { 6, 453, 1024 }, { 6, 454, 1024 }, { 7, 455, 1024 }, 
-   { 5, 456, 1024 }, { 6, 457, 1024 }, { 6, 458, 1024 }, { 7, 459, 1024 }, { 6, 460, 1024 }, { 7, 461, 1024 }, { 7, 462, 1024 }, { 8, 463, 1024 }, 
-   { 5, 464, 1024 }, { 6, 465, 1024 }, { 6, 466, 1024 }, { 7, 467, 1024 }, { 6, 468, 1024 }, { 7, 469, 1024 }, { 7, 470, 1024 }, { 8, 471, 1024 }, 
-   { 6, 472, 1024 }, { 7, 473, 1024 }, { 7, 474, 1024 }, { 8, 475, 1024 }, { 7, 476, 1024 }, { 8, 477, 1024 }, { 8, 478, 1024 }, { 9, 479, 1024 }, 
-   { 5, 480, 1024 }, { 6, 481, 1024 }, { 6, 482, 1024 }, { 7, 483, 1024 }, { 6, 484, 1024 }, { 7, 485, 1024 }, { 7, 486, 1024 }, { 8, 487, 1024 }, 
-   { 6, 488, 1024 }, { 7, 489, 1024 }, { 7, 490, 1024 }, { 8, 491, 1024 }, { 7, 492, 1024 }, { 8, 493, 1024 }, { 8, 494, 1024 }, { 9, 495, 1024 }, 
-   { 6, 496, 1024 }, { 7, 497, 1024 }, { 7, 498, 1024 }, { 8, 499, 1024 }, { 7, 500, 1024 }, { 8, 501, 1024 }, { 8, 502, 1024 }, { 9, 503, 1024 }, 
-   { 7, 504, 1024 }, { 8, 505, 1024 }, { 8, 506, 1024 }, { 9, 507, 1024 }, { 8, 508, 1024 }, { 9, 509, 1024 }, { 9, 510, 1024 }, { 10, 511, 1024 }, 
-   { 2, 512, 1024 }, { 3, 513, 1024 }, { 3, 514, 1024 }, { 4, 515, 1024 }, { 3, 516, 1024 }, { 4, 517, 1024 }, { 4, 518, 1024 }, { 5, 519, 1024 }, 
-   { 3, 520, 1024 }, { 4, 521, 1024 }, { 4, 522, 1024 }, { 5, 523, 1024 }, { 4, 524, 1024 }, { 5, 525, 1024 }, { 5, 526, 1024 }, { 6, 527, 1024 }, 
-   { 3, 528, 1024 }, { 4, 529, 1024 }, { 4, 530, 1024 }, { 5, 531, 1024 }, { 4, 532, 1024 }, { 5, 533, 1024 }, { 5, 534, 1024 }, { 6, 535, 1024 }, 
-   { 4, 536, 1024 }, { 5, 537, 1024 }, { 5, 538, 1024 }, { 6, 539, 1024 }, { 5, 540, 1024 }, { 6, 541, 1024 }, { 6, 542, 1024 }, { 7, 543, 1024 }, 
-   { 3, 544, 1024 }, { 4, 545, 1024 }, { 4, 546, 1024 }, { 5, 547, 1024 }, { 4, 548, 1024 }, { 5, 549, 1024 }, { 5, 550, 1024 }, { 6, 551, 1024 }, 
-   { 4, 552, 1024 }, { 5, 553, 1024 }, { 5, 554, 1024 }, { 6, 555, 1024 }, { 5, 556, 1024 }, { 6, 557, 1024 }, { 6, 558, 1024 }, { 7, 559, 1024 }, 
-   { 4, 560, 1024 }, { 5, 561, 1024 }, { 5, 562, 1024 }, { 6, 563, 1024 }, { 5, 564, 1024 }, { 6, 565, 1024 }, { 6, 566, 1024 }, { 7, 567, 1024 }, 
-   { 5, 568, 1024 }, { 6, 569, 1024 }, { 6, 570, 1024 }, { 7, 571, 1024 }, { 6, 572, 1024 }, { 7, 573, 1024 }, { 7, 574, 1024 }, { 8, 575, 1024 }, 
-   { 3, 576, 1024 }, { 4, 577, 1024 }, { 4, 578, 1024 }, { 5, 579, 1024 }, { 4, 580, 1024 }, { 5, 581, 1024 }, { 5, 582, 1024 }, { 6, 583, 1024 }, 
-   { 4, 584, 1024 }, { 5, 585, 1024 }, { 5, 586, 1024 }, { 6, 587, 1024 }, { 5, 588, 1024 }, { 6, 589, 1024 }, { 6, 590, 1024 }, { 7, 591, 1024 }, 
-   { 4, 592, 1024 }, { 5, 593, 1024 }, { 5, 594, 1024 }, { 6, 595, 1024 }, { 5, 596, 1024 }, { 6, 597, 1024 }, { 6, 598, 1024 }, { 7, 599, 1024 }, 
-   { 5, 600, 1024 }, { 6, 601, 1024 }, { 6, 602, 1024 }, { 7, 603, 1024 }, { 6, 604, 1024 }, { 7, 605, 1024 }, { 7, 606, 1024 }, { 8, 607, 1024 }, 
-   { 4, 608, 1024 }, { 5, 609, 1024 }, { 5, 610, 1024 }, { 6, 611, 1024 }, { 5, 612, 1024 }, { 6, 613, 1024 }, { 6, 614, 1024 }, { 7, 615, 1024 }, 
-   { 5, 616, 1024 }, { 6, 617, 1024 }, { 6, 618, 1024 }, { 7, 619, 1024 }, { 6, 620, 1024 }, { 7, 621, 1024 }, { 7, 622, 1024 }, { 8, 623, 1024 }, 
-   { 5, 624, 1024 }, { 6, 625, 1024 }, { 6, 626, 1024 }, { 7, 627, 1024 }, { 6, 628, 1024 }, { 7, 629, 1024 }, { 7, 630, 1024 }, { 8, 631, 1024 }, 
-   { 6, 632, 1024 }, { 7, 633, 1024 }, { 7, 634, 1024 }, { 8, 635, 1024 }, { 7, 636, 1024 }, { 8, 637, 1024 }, { 8, 638, 1024 }, { 9, 639, 1024 }, 
-   { 3, 640, 1024 }, { 4, 641, 1024 }, { 4, 642, 1024 }, { 5, 643, 1024 }, { 4, 644, 1024 }, { 5, 645, 1024 }, { 5, 646, 1024 }, { 6, 647, 1024 }, 
-   { 4, 648, 1024 }, { 5, 649, 1024 }, { 5, 650, 1024 }, { 6, 651, 1024 }, { 5, 652, 1024 }, { 6, 653, 1024 }, { 6, 654, 1024 }, { 7, 655, 1024 }, 
-   { 4, 656, 1024 }, { 5, 657, 1024 }, { 5, 658, 1024 }, { 6, 659, 1024 }, { 5, 660, 1024 }, { 6, 661, 1024 }, { 6, 662, 1024 }, { 7, 663, 1024 }, 
-   { 5, 664, 1024 }, { 6, 665, 1024 }, { 6, 666, 1024 }, { 7, 667, 1024 }, { 6, 668, 1024 }, { 7, 669, 1024 }, { 7, 670, 1024 }, { 8, 671, 1024 }, 
-   { 4, 672, 1024 }, { 5, 673, 1024 }, { 5, 674, 1024 }, { 6, 675, 1024 }, { 5, 676, 1024 }, { 6, 677, 1024 }, { 6, 678, 1024 }, { 7, 679, 1024 }, 
-   { 5, 680, 1024 }, { 6, 681, 1024 }, { 6, 682, 1024 }, { 7, 683, 1024 }, { 6, 684, 1024 }, { 7, 685, 1024 }, { 7, 686, 1024 }, { 8, 687, 1024 }, 
-   { 5, 688, 1024 }, { 6, 689, 1024 }, { 6, 690, 1024 }, { 7, 691, 1024 }, { 6, 692, 1024 }, { 7, 693, 1024 }, { 7, 694, 1024 }, { 8, 695, 1024 }, 
-   { 6, 696, 1024 }, { 7, 697, 1024 }, { 7, 698, 1024 }, { 8, 699, 1024 }, { 7, 700, 1024 }, { 8, 701, 1024 }, { 8, 702, 1024 }, { 9, 703, 1024 }, 
-   { 4, 704, 1024 }, { 5, 705, 1024 }, { 5, 706, 1024 }, { 6, 707, 1024 }, { 5, 708, 1024 }, { 6, 709, 1024 }, { 6, 710, 1024 }, { 7, 711, 1024 }, 
-   { 5, 712, 1024 }, { 6, 713, 1024 }, { 6, 714, 1024 }, { 7, 715, 1024 }, { 6, 716, 1024 }, { 7, 717, 1024 }, { 7, 718, 1024 }, { 8, 719, 1024 }, 
-   { 5, 720, 1024 }, { 6, 721, 1024 }, { 6, 722, 1024 }, { 7, 723, 1024 }, { 6, 724, 1024 }, { 7, 725, 1024 }, { 7, 726, 1024 }, { 8, 727, 1024 }, 
-   { 6, 728, 1024 }, { 7, 729, 1024 }, { 7, 730, 1024 }, { 8, 731, 1024 }, { 7, 732, 1024 }, { 8, 733, 1024 }, { 8, 734, 1024 }, { 9, 735, 1024 }, 
-   { 5, 736, 1024 }, { 6, 737, 1024 }, { 6, 738, 1024 }, { 7, 739, 1024 }, { 6, 740, 1024 }, { 7, 741, 1024 }, { 7, 742, 1024 }, { 8, 743, 1024 }, 
-   { 6, 744, 1024 }, { 7, 745, 1024 }, { 7, 746, 1024 }, { 8, 747, 1024 }, { 7, 748, 1024 }, { 8, 749, 1024 }, { 8, 750, 1024 }, { 9, 751, 1024 }, 
-   { 6, 752, 1024 }, { 7, 753, 1024 }, { 7, 754, 1024 }, { 8, 755, 1024 }, { 7, 756, 1024 }, { 8, 757, 1024 }, { 8, 758, 1024 }, { 9, 759, 1024 }, 
-   { 7, 760, 1024 }, { 8, 761, 1024 }, { 8, 762, 1024 }, { 9, 763, 1024 }, { 8, 764, 1024 }, { 9, 765, 1024 }, { 9, 766, 1024 }, { 10, 767, 1024 }, 
-   { 3, 768, 1024 }, { 4, 769, 1024 }, { 4, 770, 1024 }, { 5, 771, 1024 }, { 4, 772, 1024 }, { 5, 773, 1024 }, { 5, 774, 1024 }, { 6, 775, 1024 }, 
-   { 4, 776, 1024 }, { 5, 777, 1024 }, { 5, 778, 1024 }, { 6, 779, 1024 }, { 5, 780, 1024 }, { 6, 781, 1024 }, { 6, 782, 1024 }, { 7, 783, 1024 }, 
-   { 4, 784, 1024 }, { 5, 785, 1024 }, { 5, 786, 1024 }, { 6, 787, 1024 }, { 5, 788, 1024 }, { 6, 789, 1024 }, { 6, 790, 1024 }, { 7, 791, 1024 }, 
-   { 5, 792, 1024 }, { 6, 793, 1024 }, { 6, 794, 1024 }, { 7, 795, 1024 }, { 6, 796, 1024 }, { 7, 797, 1024 }, { 7, 798, 1024 }, { 8, 799, 1024 }, 
-   { 4, 800, 1024 }, { 5, 801, 1024 }, { 5, 802, 1024 }, { 6, 803, 1024 }, { 5, 804, 1024 }, { 6, 805, 1024 }, { 6, 806, 1024 }, { 7, 807, 1024 }, 
-   { 5, 808, 1024 }, { 6, 809, 1024 }, { 6, 810, 1024 }, { 7, 811, 1024 }, { 6, 812, 1024 }, { 7, 813, 1024 }, { 7, 814, 1024 }, { 8, 815, 1024 }, 
-   { 5, 816, 1024 }, { 6, 817, 1024 }, { 6, 818, 1024 }, { 7, 819, 1024 }, { 6, 820, 1024 }, { 7, 821, 1024 }, { 7, 822, 1024 }, { 8, 823, 1024 }, 
-   { 6, 824, 1024 }, { 7, 825, 1024 }, { 7, 826, 1024 }, { 8, 827, 1024 }, { 7, 828, 1024 }, { 8, 829, 1024 }, { 8, 830, 1024 }, { 9, 831, 1024 }, 
-   { 4, 832, 1024 }, { 5, 833, 1024 }, { 5, 834, 1024 }, { 6, 835, 1024 }, { 5, 836, 1024 }, { 6, 837, 1024 }, { 6, 838, 1024 }, { 7, 839, 1024 }, 
-   { 5, 840, 1024 }, { 6, 841, 1024 }, { 6, 842, 1024 }, { 7, 843, 1024 }, { 6, 844, 1024 }, { 7, 845, 1024 }, { 7, 846, 1024 }, { 8, 847, 1024 }, 
-   { 5, 848, 1024 }, { 6, 849, 1024 }, { 6, 850, 1024 }, { 7, 851, 1024 }, { 6, 852, 1024 }, { 7, 853, 1024 }, { 7, 854, 1024 }, { 8, 855, 1024 }, 
-   { 6, 856, 1024 }, { 7, 857, 1024 }, { 7, 858, 1024 }, { 8, 859, 1024 }, { 7, 860, 1024 }, { 8, 861, 1024 }, { 8, 862, 1024 }, { 9, 863, 1024 }, 
-   { 5, 864, 1024 }, { 6, 865, 1024 }, { 6, 866, 1024 }, { 7, 867, 1024 }, { 6, 868, 1024 }, { 7, 869, 1024 }, { 7, 870, 1024 }, { 8, 871, 1024 }, 
-   { 6, 872, 1024 }, { 7, 873, 1024 }, { 7, 874, 1024 }, { 8, 875, 1024 }, { 7, 876, 1024 }, { 8, 877, 1024 }, { 8, 878, 1024 }, { 9, 879, 1024 }, 
-   { 6, 880, 1024 }, { 7, 881, 1024 }, { 7, 882, 1024 }, { 8, 883, 1024 }, { 7, 884, 1024 }, { 8, 885, 1024 }, { 8, 886, 1024 }, { 9, 887, 1024 }, 
-   { 7, 888, 1024 }, { 8, 889, 1024 }, { 8, 890, 1024 }, { 9, 891, 1024 }, { 8, 892, 1024 }, { 9, 893, 1024 }, { 9, 894, 1024 }, { 10, 895, 1024 }, 
-   { 4, 896, 1024 }, { 5, 897, 1024 }, { 5, 898, 1024 }, { 6, 899, 1024 }, { 5, 900, 1024 }, { 6, 901, 1024 }, { 6, 902, 1024 }, { 7, 903, 1024 }, 
-   { 5, 904, 1024 }, { 6, 905, 1024 }, { 6, 906, 1024 }, { 7, 907, 1024 }, { 6, 908, 1024 }, { 7, 909, 1024 }, { 7, 910, 1024 }, { 8, 911, 1024 }, 
-   { 5, 912, 1024 }, { 6, 913, 1024 }, { 6, 914, 1024 }, { 7, 915, 1024 }, { 6, 916, 1024 }, { 7, 917, 1024 }, { 7, 918, 1024 }, { 8, 919, 1024 }, 
-   { 6, 920, 1024 }, { 7, 921, 1024 }, { 7, 922, 1024 }, { 8, 923, 1024 }, { 7, 924, 1024 }, { 8, 925, 1024 }, { 8, 926, 1024 }, { 9, 927, 1024 }, 
-   { 5, 928, 1024 }, { 6, 929, 1024 }, { 6, 930, 1024 }, { 7, 931, 1024 }, { 6, 932, 1024 }, { 7, 933, 1024 }, { 7, 934, 1024 }, { 8, 935, 1024 }, 
-   { 6, 936, 1024 }, { 7, 937, 1024 }, { 7, 938, 1024 }, { 8, 939, 1024 }, { 7, 940, 1024 }, { 8, 941, 1024 }, { 8, 942, 1024 }, { 9, 943, 1024 }, 
-   { 6, 944, 1024 }, { 7, 945, 1024 }, { 7, 946, 1024 }, { 8, 947, 1024 }, { 7, 948, 1024 }, { 8, 949, 1024 }, { 8, 950, 1024 }, { 9, 951, 1024 }, 
-   { 7, 952, 1024 }, { 8, 953, 1024 }, { 8, 954, 1024 }, { 9, 955, 1024 }, { 8, 956, 1024 }, { 9, 957, 1024 }, { 9, 958, 1024 }, { 10, 959, 1024 }, 
-   { 5, 960, 1024 }, { 6, 961, 1024 }, { 6, 962, 1024 }, { 7, 963, 1024 }, { 6, 964, 1024 }, { 7, 965, 1024 }, { 7, 966, 1024 }, { 8, 967, 1024 }, 
-   { 6, 968, 1024 }, { 7, 969, 1024 }, { 7, 970, 1024 }, { 8, 971, 1024 }, { 7, 972, 1024 }, { 8, 973, 1024 }, { 8, 974, 1024 }, { 9, 975, 1024 }, 
-   { 6, 976, 1024 }, { 7, 977, 1024 }, { 7, 978, 1024 }, { 8, 979, 1024 }, { 7, 980, 1024 }, { 8, 981, 1024 }, { 8, 982, 1024 }, { 9, 983, 1024 }, 
-   { 7, 984, 1024 }, { 8, 985, 1024 }, { 8, 986, 1024 }, { 9, 987, 1024 }, { 8, 988, 1024 }, { 9, 989, 1024 }, { 9, 990, 1024 }, { 10, 991, 1024 }, 
-   { 6, 992, 1024 }, { 7, 993, 1024 }, { 7, 994, 1024 }, { 8, 995, 1024 }, { 7, 996, 1024 }, { 8, 997, 1024 }, { 8, 998, 1024 }, { 9, 999, 1024 }, 
-   { 7, 1000, 1024 }, { 8, 1001, 1024 }, { 8, 1002, 1024 }, { 9, 1003, 1024 }, { 8, 1004, 1024 }, { 9, 1005, 1024 }, { 9, 1006, 1024 }, { 10, 1007, 1024 }, 
-   { 7, 1008, 1024 }, { 8, 1009, 1024 }, { 8, 1010, 1024 }, { 9, 1011, 1024 }, { 8, 1012, 1024 }, { 9, 1013, 1024 }, { 9, 1014, 1024 }, { 10, 1015, 1024 }, 
-   { 8, 1016, 1024 }, { 9, 1017, 1024 }, { 9, 1018, 1024 }, { 10, 1019, 1024 }, { 9, 1020, 1024 }, { 10, 1021, 1024 }, { 10, 1022, 1024 }, { 11, 1023, 1024 }, 
-#if FP_LUT > 11
-   { 1, 0, 0 }, { 2, 1, 2048 }, { 2, 2, 2048 }, { 3, 3, 2048 }, { 2, 4, 2048 }, { 3, 5, 2048 }, { 3, 6, 2048 }, { 4, 7, 2048 }, 
-   { 2, 8, 2048 }, { 3, 9, 2048 }, { 3, 10, 2048 }, { 4, 11, 2048 }, { 3, 12, 2048 }, { 4, 13, 2048 }, { 4, 14, 2048 }, { 5, 15, 2048 }, 
-   { 2, 16, 2048 }, { 3, 17, 2048 }, { 3, 18, 2048 }, { 4, 19, 2048 }, { 3, 20, 2048 }, { 4, 21, 2048 }, { 4, 22, 2048 }, { 5, 23, 2048 }, 
-   { 3, 24, 2048 }, { 4, 25, 2048 }, { 4, 26, 2048 }, { 5, 27, 2048 }, { 4, 28, 2048 }, { 5, 29, 2048 }, { 5, 30, 2048 }, { 6, 31, 2048 }, 
-   { 2, 32, 2048 }, { 3, 33, 2048 }, { 3, 34, 2048 }, { 4, 35, 2048 }, { 3, 36, 2048 }, { 4, 37, 2048 }, { 4, 38, 2048 }, { 5, 39, 2048 }, 
-   { 3, 40, 2048 }, { 4, 41, 2048 }, { 4, 42, 2048 }, { 5, 43, 2048 }, { 4, 44, 2048 }, { 5, 45, 2048 }, { 5, 46, 2048 }, { 6, 47, 2048 }, 
-   { 3, 48, 2048 }, { 4, 49, 2048 }, { 4, 50, 2048 }, { 5, 51, 2048 }, { 4, 52, 2048 }, { 5, 53, 2048 }, { 5, 54, 2048 }, { 6, 55, 2048 }, 
-   { 4, 56, 2048 }, { 5, 57, 2048 }, { 5, 58, 2048 }, { 6, 59, 2048 }, { 5, 60, 2048 }, { 6, 61, 2048 }, { 6, 62, 2048 }, { 7, 63, 2048 }, 
-   { 2, 64, 2048 }, { 3, 65, 2048 }, { 3, 66, 2048 }, { 4, 67, 2048 }, { 3, 68, 2048 }, { 4, 69, 2048 }, { 4, 70, 2048 }, { 5, 71, 2048 }, 
-   { 3, 72, 2048 }, { 4, 73, 2048 }, { 4, 74, 2048 }, { 5, 75, 2048 }, { 4, 76, 2048 }, { 5, 77, 2048 }, { 5, 78, 2048 }, { 6, 79, 2048 }, 
-   { 3, 80, 2048 }, { 4, 81, 2048 }, { 4, 82, 2048 }, { 5, 83, 2048 }, { 4, 84, 2048 }, { 5, 85, 2048 }, { 5, 86, 2048 }, { 6, 87, 2048 }, 
-   { 4, 88, 2048 }, { 5, 89, 2048 }, { 5, 90, 2048 }, { 6, 91, 2048 }, { 5, 92, 2048 }, { 6, 93, 2048 }, { 6, 94, 2048 }, { 7, 95, 2048 }, 
-   { 3, 96, 2048 }, { 4, 97, 2048 }, { 4, 98, 2048 }, { 5, 99, 2048 }, { 4, 100, 2048 }, { 5, 101, 2048 }, { 5, 102, 2048 }, { 6, 103, 2048 }, 
-   { 4, 104, 2048 }, { 5, 105, 2048 }, { 5, 106, 2048 }, { 6, 107, 2048 }, { 5, 108, 2048 }, { 6, 109, 2048 }, { 6, 110, 2048 }, { 7, 111, 2048 }, 
-   { 4, 112, 2048 }, { 5, 113, 2048 }, { 5, 114, 2048 }, { 6, 115, 2048 }, { 5, 116, 2048 }, { 6, 117, 2048 }, { 6, 118, 2048 }, { 7, 119, 2048 }, 
-   { 5, 120, 2048 }, { 6, 121, 2048 }, { 6, 122, 2048 }, { 7, 123, 2048 }, { 6, 124, 2048 }, { 7, 125, 2048 }, { 7, 126, 2048 }, { 8, 127, 2048 }, 
-   { 2, 128, 2048 }, { 3, 129, 2048 }, { 3, 130, 2048 }, { 4, 131, 2048 }, { 3, 132, 2048 }, { 4, 133, 2048 }, { 4, 134, 2048 }, { 5, 135, 2048 }, 
-   { 3, 136, 2048 }, { 4, 137, 2048 }, { 4, 138, 2048 }, { 5, 139, 2048 }, { 4, 140, 2048 }, { 5, 141, 2048 }, { 5, 142, 2048 }, { 6, 143, 2048 }, 
-   { 3, 144, 2048 }, { 4, 145, 2048 }, { 4, 146, 2048 }, { 5, 147, 2048 }, { 4, 148, 2048 }, { 5, 149, 2048 }, { 5, 150, 2048 }, { 6, 151, 2048 }, 
-   { 4, 152, 2048 }, { 5, 153, 2048 }, { 5, 154, 2048 }, { 6, 155, 2048 }, { 5, 156, 2048 }, { 6, 157, 2048 }, { 6, 158, 2048 }, { 7, 159, 2048 }, 
-   { 3, 160, 2048 }, { 4, 161, 2048 }, { 4, 162, 2048 }, { 5, 163, 2048 }, { 4, 164, 2048 }, { 5, 165, 2048 }, { 5, 166, 2048 }, { 6, 167, 2048 }, 
-   { 4, 168, 2048 }, { 5, 169, 2048 }, { 5, 170, 2048 }, { 6, 171, 2048 }, { 5, 172, 2048 }, { 6, 173, 2048 }, { 6, 174, 2048 }, { 7, 175, 2048 }, 
-   { 4, 176, 2048 }, { 5, 177, 2048 }, { 5, 178, 2048 }, { 6, 179, 2048 }, { 5, 180, 2048 }, { 6, 181, 2048 }, { 6, 182, 2048 }, { 7, 183, 2048 }, 
-   { 5, 184, 2048 }, { 6, 185, 2048 }, { 6, 186, 2048 }, { 7, 187, 2048 }, { 6, 188, 2048 }, { 7, 189, 2048 }, { 7, 190, 2048 }, { 8, 191, 2048 }, 
-   { 3, 192, 2048 }, { 4, 193, 2048 }, { 4, 194, 2048 }, { 5, 195, 2048 }, { 4, 196, 2048 }, { 5, 197, 2048 }, { 5, 198, 2048 }, { 6, 199, 2048 }, 
-   { 4, 200, 2048 }, { 5, 201, 2048 }, { 5, 202, 2048 }, { 6, 203, 2048 }, { 5, 204, 2048 }, { 6, 205, 2048 }, { 6, 206, 2048 }, { 7, 207, 2048 }, 
-   { 4, 208, 2048 }, { 5, 209, 2048 }, { 5, 210, 2048 }, { 6, 211, 2048 }, { 5, 212, 2048 }, { 6, 213, 2048 }, { 6, 214, 2048 }, { 7, 215, 2048 }, 
-   { 5, 216, 2048 }, { 6, 217, 2048 }, { 6, 218, 2048 }, { 7, 219, 2048 }, { 6, 220, 2048 }, { 7, 221, 2048 }, { 7, 222, 2048 }, { 8, 223, 2048 }, 
-   { 4, 224, 2048 }, { 5, 225, 2048 }, { 5, 226, 2048 }, { 6, 227, 2048 }, { 5, 228, 2048 }, { 6, 229, 2048 }, { 6, 230, 2048 }, { 7, 231, 2048 }, 
-   { 5, 232, 2048 }, { 6, 233, 2048 }, { 6, 234, 2048 }, { 7, 235, 2048 }, { 6, 236, 2048 }, { 7, 237, 2048 }, { 7, 238, 2048 }, { 8, 239, 2048 }, 
-   { 5, 240, 2048 }, { 6, 241, 2048 }, { 6, 242, 2048 }, { 7, 243, 2048 }, { 6, 244, 2048 }, { 7, 245, 2048 }, { 7, 246, 2048 }, { 8, 247, 2048 }, 
-   { 6, 248, 2048 }, { 7, 249, 2048 }, { 7, 250, 2048 }, { 8, 251, 2048 }, { 7, 252, 2048 }, { 8, 253, 2048 }, { 8, 254, 2048 }, { 9, 255, 2048 }, 
-   { 2, 256, 2048 }, { 3, 257, 2048 }, { 3, 258, 2048 }, { 4, 259, 2048 }, { 3, 260, 2048 }, { 4, 261, 2048 }, { 4, 262, 2048 }, { 5, 263, 2048 }, 
-   { 3, 264, 2048 }, { 4, 265, 2048 }, { 4, 266, 2048 }, { 5, 267, 2048 }, { 4, 268, 2048 }, { 5, 269, 2048 }, { 5, 270, 2048 }, { 6, 271, 2048 }, 
-   { 3, 272, 2048 }, { 4, 273, 2048 }, { 4, 274, 2048 }, { 5, 275, 2048 }, { 4, 276, 2048 }, { 5, 277, 2048 }, { 5, 278, 2048 }, { 6, 279, 2048 }, 
-   { 4, 280, 2048 }, { 5, 281, 2048 }, { 5, 282, 2048 }, { 6, 283, 2048 }, { 5, 284, 2048 }, { 6, 285, 2048 }, { 6, 286, 2048 }, { 7, 287, 2048 }, 
-   { 3, 288, 2048 }, { 4, 289, 2048 }, { 4, 290, 2048 }, { 5, 291, 2048 }, { 4, 292, 2048 }, { 5, 293, 2048 }, { 5, 294, 2048 }, { 6, 295, 2048 }, 
-   { 4, 296, 2048 }, { 5, 297, 2048 }, { 5, 298, 2048 }, { 6, 299, 2048 }, { 5, 300, 2048 }, { 6, 301, 2048 }, { 6, 302, 2048 }, { 7, 303, 2048 }, 
-   { 4, 304, 2048 }, { 5, 305, 2048 }, { 5, 306, 2048 }, { 6, 307, 2048 }, { 5, 308, 2048 }, { 6, 309, 2048 }, { 6, 310, 2048 }, { 7, 311, 2048 }, 
-   { 5, 312, 2048 }, { 6, 313, 2048 }, { 6, 314, 2048 }, { 7, 315, 2048 }, { 6, 316, 2048 }, { 7, 317, 2048 }, { 7, 318, 2048 }, { 8, 319, 2048 }, 
-   { 3, 320, 2048 }, { 4, 321, 2048 }, { 4, 322, 2048 }, { 5, 323, 2048 }, { 4, 324, 2048 }, { 5, 325, 2048 }, { 5, 326, 2048 }, { 6, 327, 2048 }, 
-   { 4, 328, 2048 }, { 5, 329, 2048 }, { 5, 330, 2048 }, { 6, 331, 2048 }, { 5, 332, 2048 }, { 6, 333, 2048 }, { 6, 334, 2048 }, { 7, 335, 2048 }, 
-   { 4, 336, 2048 }, { 5, 337, 2048 }, { 5, 338, 2048 }, { 6, 339, 2048 }, { 5, 340, 2048 }, { 6, 341, 2048 }, { 6, 342, 2048 }, { 7, 343, 2048 }, 
-   { 5, 344, 2048 }, { 6, 345, 2048 }, { 6, 346, 2048 }, { 7, 347, 2048 }, { 6, 348, 2048 }, { 7, 349, 2048 }, { 7, 350, 2048 }, { 8, 351, 2048 }, 
-   { 4, 352, 2048 }, { 5, 353, 2048 }, { 5, 354, 2048 }, { 6, 355, 2048 }, { 5, 356, 2048 }, { 6, 357, 2048 }, { 6, 358, 2048 }, { 7, 359, 2048 }, 
-   { 5, 360, 2048 }, { 6, 361, 2048 }, { 6, 362, 2048 }, { 7, 363, 2048 }, { 6, 364, 2048 }, { 7, 365, 2048 }, { 7, 366, 2048 }, { 8, 367, 2048 }, 
-   { 5, 368, 2048 }, { 6, 369, 2048 }, { 6, 370, 2048 }, { 7, 371, 2048 }, { 6, 372, 2048 }, { 7, 373, 2048 }, { 7, 374, 2048 }, { 8, 375, 2048 }, 
-   { 6, 376, 2048 }, { 7, 377, 2048 }, { 7, 378, 2048 }, { 8, 379, 2048 }, { 7, 380, 2048 }, { 8, 381, 2048 }, { 8, 382, 2048 }, { 9, 383, 2048 }, 
-   { 3, 384, 2048 }, { 4, 385, 2048 }, { 4, 386, 2048 }, { 5, 387, 2048 }, { 4, 388, 2048 }, { 5, 389, 2048 }, { 5, 390, 2048 }, { 6, 391, 2048 }, 
-   { 4, 392, 2048 }, { 5, 393, 2048 }, { 5, 394, 2048 }, { 6, 395, 2048 }, { 5, 396, 2048 }, { 6, 397, 2048 }, { 6, 398, 2048 }, { 7, 399, 2048 }, 
-   { 4, 400, 2048 }, { 5, 401, 2048 }, { 5, 402, 2048 }, { 6, 403, 2048 }, { 5, 404, 2048 }, { 6, 405, 2048 }, { 6, 406, 2048 }, { 7, 407, 2048 }, 
-   { 5, 408, 2048 }, { 6, 409, 2048 }, { 6, 410, 2048 }, { 7, 411, 2048 }, { 6, 412, 2048 }, { 7, 413, 2048 }, { 7, 414, 2048 }, { 8, 415, 2048 }, 
-   { 4, 416, 2048 }, { 5, 417, 2048 }, { 5, 418, 2048 }, { 6, 419, 2048 }, { 5, 420, 2048 }, { 6, 421, 2048 }, { 6, 422, 2048 }, { 7, 423, 2048 }, 
-   { 5, 424, 2048 }, { 6, 425, 2048 }, { 6, 426, 2048 }, { 7, 427, 2048 }, { 6, 428, 2048 }, { 7, 429, 2048 }, { 7, 430, 2048 }, { 8, 431, 2048 }, 
-   { 5, 432, 2048 }, { 6, 433, 2048 }, { 6, 434, 2048 }, { 7, 435, 2048 }, { 6, 436, 2048 }, { 7, 437, 2048 }, { 7, 438, 2048 }, { 8, 439, 2048 }, 
-   { 6, 440, 2048 }, { 7, 441, 2048 }, { 7, 442, 2048 }, { 8, 443, 2048 }, { 7, 444, 2048 }, { 8, 445, 2048 }, { 8, 446, 2048 }, { 9, 447, 2048 }, 
-   { 4, 448, 2048 }, { 5, 449, 2048 }, { 5, 450, 2048 }, { 6, 451, 2048 }, { 5, 452, 2048 }, { 6, 453, 2048 }, { 6, 454, 2048 }, { 7, 455, 2048 }, 
-   { 5, 456, 2048 }, { 6, 457, 2048 }, { 6, 458, 2048 }, { 7, 459, 2048 }, { 6, 460, 2048 }, { 7, 461, 2048 }, { 7, 462, 2048 }, { 8, 463, 2048 }, 
-   { 5, 464, 2048 }, { 6, 465, 2048 }, { 6, 466, 2048 }, { 7, 467, 2048 }, { 6, 468, 2048 }, { 7, 469, 2048 }, { 7, 470, 2048 }, { 8, 471, 2048 }, 
-   { 6, 472, 2048 }, { 7, 473, 2048 }, { 7, 474, 2048 }, { 8, 475, 2048 }, { 7, 476, 2048 }, { 8, 477, 2048 }, { 8, 478, 2048 }, { 9, 479, 2048 }, 
-   { 5, 480, 2048 }, { 6, 481, 2048 }, { 6, 482, 2048 }, { 7, 483, 2048 }, { 6, 484, 2048 }, { 7, 485, 2048 }, { 7, 486, 2048 }, { 8, 487, 2048 }, 
-   { 6, 488, 2048 }, { 7, 489, 2048 }, { 7, 490, 2048 }, { 8, 491, 2048 }, { 7, 492, 2048 }, { 8, 493, 2048 }, { 8, 494, 2048 }, { 9, 495, 2048 }, 
-   { 6, 496, 2048 }, { 7, 497, 2048 }, { 7, 498, 2048 }, { 8, 499, 2048 }, { 7, 500, 2048 }, { 8, 501, 2048 }, { 8, 502, 2048 }, { 9, 503, 2048 }, 
-   { 7, 504, 2048 }, { 8, 505, 2048 }, { 8, 506, 2048 }, { 9, 507, 2048 }, { 8, 508, 2048 }, { 9, 509, 2048 }, { 9, 510, 2048 }, { 10, 511, 2048 }, 
-   { 2, 512, 2048 }, { 3, 513, 2048 }, { 3, 514, 2048 }, { 4, 515, 2048 }, { 3, 516, 2048 }, { 4, 517, 2048 }, { 4, 518, 2048 }, { 5, 519, 2048 }, 
-   { 3, 520, 2048 }, { 4, 521, 2048 }, { 4, 522, 2048 }, { 5, 523, 2048 }, { 4, 524, 2048 }, { 5, 525, 2048 }, { 5, 526, 2048 }, { 6, 527, 2048 }, 
-   { 3, 528, 2048 }, { 4, 529, 2048 }, { 4, 530, 2048 }, { 5, 531, 2048 }, { 4, 532, 2048 }, { 5, 533, 2048 }, { 5, 534, 2048 }, { 6, 535, 2048 }, 
-   { 4, 536, 2048 }, { 5, 537, 2048 }, { 5, 538, 2048 }, { 6, 539, 2048 }, { 5, 540, 2048 }, { 6, 541, 2048 }, { 6, 542, 2048 }, { 7, 543, 2048 }, 
-   { 3, 544, 2048 }, { 4, 545, 2048 }, { 4, 546, 2048 }, { 5, 547, 2048 }, { 4, 548, 2048 }, { 5, 549, 2048 }, { 5, 550, 2048 }, { 6, 551, 2048 }, 
-   { 4, 552, 2048 }, { 5, 553, 2048 }, { 5, 554, 2048 }, { 6, 555, 2048 }, { 5, 556, 2048 }, { 6, 557, 2048 }, { 6, 558, 2048 }, { 7, 559, 2048 }, 
-   { 4, 560, 2048 }, { 5, 561, 2048 }, { 5, 562, 2048 }, { 6, 563, 2048 }, { 5, 564, 2048 }, { 6, 565, 2048 }, { 6, 566, 2048 }, { 7, 567, 2048 }, 
-   { 5, 568, 2048 }, { 6, 569, 2048 }, { 6, 570, 2048 }, { 7, 571, 2048 }, { 6, 572, 2048 }, { 7, 573, 2048 }, { 7, 574, 2048 }, { 8, 575, 2048 }, 
-   { 3, 576, 2048 }, { 4, 577, 2048 }, { 4, 578, 2048 }, { 5, 579, 2048 }, { 4, 580, 2048 }, { 5, 581, 2048 }, { 5, 582, 2048 }, { 6, 583, 2048 }, 
-   { 4, 584, 2048 }, { 5, 585, 2048 }, { 5, 586, 2048 }, { 6, 587, 2048 }, { 5, 588, 2048 }, { 6, 589, 2048 }, { 6, 590, 2048 }, { 7, 591, 2048 }, 
-   { 4, 592, 2048 }, { 5, 593, 2048 }, { 5, 594, 2048 }, { 6, 595, 2048 }, { 5, 596, 2048 }, { 6, 597, 2048 }, { 6, 598, 2048 }, { 7, 599, 2048 }, 
-   { 5, 600, 2048 }, { 6, 601, 2048 }, { 6, 602, 2048 }, { 7, 603, 2048 }, { 6, 604, 2048 }, { 7, 605, 2048 }, { 7, 606, 2048 }, { 8, 607, 2048 }, 
-   { 4, 608, 2048 }, { 5, 609, 2048 }, { 5, 610, 2048 }, { 6, 611, 2048 }, { 5, 612, 2048 }, { 6, 613, 2048 }, { 6, 614, 2048 }, { 7, 615, 2048 }, 
-   { 5, 616, 2048 }, { 6, 617, 2048 }, { 6, 618, 2048 }, { 7, 619, 2048 }, { 6, 620, 2048 }, { 7, 621, 2048 }, { 7, 622, 2048 }, { 8, 623, 2048 }, 
-   { 5, 624, 2048 }, { 6, 625, 2048 }, { 6, 626, 2048 }, { 7, 627, 2048 }, { 6, 628, 2048 }, { 7, 629, 2048 }, { 7, 630, 2048 }, { 8, 631, 2048 }, 
-   { 6, 632, 2048 }, { 7, 633, 2048 }, { 7, 634, 2048 }, { 8, 635, 2048 }, { 7, 636, 2048 }, { 8, 637, 2048 }, { 8, 638, 2048 }, { 9, 639, 2048 }, 
-   { 3, 640, 2048 }, { 4, 641, 2048 }, { 4, 642, 2048 }, { 5, 643, 2048 }, { 4, 644, 2048 }, { 5, 645, 2048 }, { 5, 646, 2048 }, { 6, 647, 2048 }, 
-   { 4, 648, 2048 }, { 5, 649, 2048 }, { 5, 650, 2048 }, { 6, 651, 2048 }, { 5, 652, 2048 }, { 6, 653, 2048 }, { 6, 654, 2048 }, { 7, 655, 2048 }, 
-   { 4, 656, 2048 }, { 5, 657, 2048 }, { 5, 658, 2048 }, { 6, 659, 2048 }, { 5, 660, 2048 }, { 6, 661, 2048 }, { 6, 662, 2048 }, { 7, 663, 2048 }, 
-   { 5, 664, 2048 }, { 6, 665, 2048 }, { 6, 666, 2048 }, { 7, 667, 2048 }, { 6, 668, 2048 }, { 7, 669, 2048 }, { 7, 670, 2048 }, { 8, 671, 2048 }, 
-   { 4, 672, 2048 }, { 5, 673, 2048 }, { 5, 674, 2048 }, { 6, 675, 2048 }, { 5, 676, 2048 }, { 6, 677, 2048 }, { 6, 678, 2048 }, { 7, 679, 2048 }, 
-   { 5, 680, 2048 }, { 6, 681, 2048 }, { 6, 682, 2048 }, { 7, 683, 2048 }, { 6, 684, 2048 }, { 7, 685, 2048 }, { 7, 686, 2048 }, { 8, 687, 2048 }, 
-   { 5, 688, 2048 }, { 6, 689, 2048 }, { 6, 690, 2048 }, { 7, 691, 2048 }, { 6, 692, 2048 }, { 7, 693, 2048 }, { 7, 694, 2048 }, { 8, 695, 2048 }, 
-   { 6, 696, 2048 }, { 7, 697, 2048 }, { 7, 698, 2048 }, { 8, 699, 2048 }, { 7, 700, 2048 }, { 8, 701, 2048 }, { 8, 702, 2048 }, { 9, 703, 2048 }, 
-   { 4, 704, 2048 }, { 5, 705, 2048 }, { 5, 706, 2048 }, { 6, 707, 2048 }, { 5, 708, 2048 }, { 6, 709, 2048 }, { 6, 710, 2048 }, { 7, 711, 2048 }, 
-   { 5, 712, 2048 }, { 6, 713, 2048 }, { 6, 714, 2048 }, { 7, 715, 2048 }, { 6, 716, 2048 }, { 7, 717, 2048 }, { 7, 718, 2048 }, { 8, 719, 2048 }, 
-   { 5, 720, 2048 }, { 6, 721, 2048 }, { 6, 722, 2048 }, { 7, 723, 2048 }, { 6, 724, 2048 }, { 7, 725, 2048 }, { 7, 726, 2048 }, { 8, 727, 2048 }, 
-   { 6, 728, 2048 }, { 7, 729, 2048 }, { 7, 730, 2048 }, { 8, 731, 2048 }, { 7, 732, 2048 }, { 8, 733, 2048 }, { 8, 734, 2048 }, { 9, 735, 2048 }, 
-   { 5, 736, 2048 }, { 6, 737, 2048 }, { 6, 738, 2048 }, { 7, 739, 2048 }, { 6, 740, 2048 }, { 7, 741, 2048 }, { 7, 742, 2048 }, { 8, 743, 2048 }, 
-   { 6, 744, 2048 }, { 7, 745, 2048 }, { 7, 746, 2048 }, { 8, 747, 2048 }, { 7, 748, 2048 }, { 8, 749, 2048 }, { 8, 750, 2048 }, { 9, 751, 2048 }, 
-   { 6, 752, 2048 }, { 7, 753, 2048 }, { 7, 754, 2048 }, { 8, 755, 2048 }, { 7, 756, 2048 }, { 8, 757, 2048 }, { 8, 758, 2048 }, { 9, 759, 2048 }, 
-   { 7, 760, 2048 }, { 8, 761, 2048 }, { 8, 762, 2048 }, { 9, 763, 2048 }, { 8, 764, 2048 }, { 9, 765, 2048 }, { 9, 766, 2048 }, { 10, 767, 2048 }, 
-   { 3, 768, 2048 }, { 4, 769, 2048 }, { 4, 770, 2048 }, { 5, 771, 2048 }, { 4, 772, 2048 }, { 5, 773, 2048 }, { 5, 774, 2048 }, { 6, 775, 2048 }, 
-   { 4, 776, 2048 }, { 5, 777, 2048 }, { 5, 778, 2048 }, { 6, 779, 2048 }, { 5, 780, 2048 }, { 6, 781, 2048 }, { 6, 782, 2048 }, { 7, 783, 2048 }, 
-   { 4, 784, 2048 }, { 5, 785, 2048 }, { 5, 786, 2048 }, { 6, 787, 2048 }, { 5, 788, 2048 }, { 6, 789, 2048 }, { 6, 790, 2048 }, { 7, 791, 2048 }, 
-   { 5, 792, 2048 }, { 6, 793, 2048 }, { 6, 794, 2048 }, { 7, 795, 2048 }, { 6, 796, 2048 }, { 7, 797, 2048 }, { 7, 798, 2048 }, { 8, 799, 2048 }, 
-   { 4, 800, 2048 }, { 5, 801, 2048 }, { 5, 802, 2048 }, { 6, 803, 2048 }, { 5, 804, 2048 }, { 6, 805, 2048 }, { 6, 806, 2048 }, { 7, 807, 2048 }, 
-   { 5, 808, 2048 }, { 6, 809, 2048 }, { 6, 810, 2048 }, { 7, 811, 2048 }, { 6, 812, 2048 }, { 7, 813, 2048 }, { 7, 814, 2048 }, { 8, 815, 2048 }, 
-   { 5, 816, 2048 }, { 6, 817, 2048 }, { 6, 818, 2048 }, { 7, 819, 2048 }, { 6, 820, 2048 }, { 7, 821, 2048 }, { 7, 822, 2048 }, { 8, 823, 2048 }, 
-   { 6, 824, 2048 }, { 7, 825, 2048 }, { 7, 826, 2048 }, { 8, 827, 2048 }, { 7, 828, 2048 }, { 8, 829, 2048 }, { 8, 830, 2048 }, { 9, 831, 2048 }, 
-   { 4, 832, 2048 }, { 5, 833, 2048 }, { 5, 834, 2048 }, { 6, 835, 2048 }, { 5, 836, 2048 }, { 6, 837, 2048 }, { 6, 838, 2048 }, { 7, 839, 2048 }, 
-   { 5, 840, 2048 }, { 6, 841, 2048 }, { 6, 842, 2048 }, { 7, 843, 2048 }, { 6, 844, 2048 }, { 7, 845, 2048 }, { 7, 846, 2048 }, { 8, 847, 2048 }, 
-   { 5, 848, 2048 }, { 6, 849, 2048 }, { 6, 850, 2048 }, { 7, 851, 2048 }, { 6, 852, 2048 }, { 7, 853, 2048 }, { 7, 854, 2048 }, { 8, 855, 2048 }, 
-   { 6, 856, 2048 }, { 7, 857, 2048 }, { 7, 858, 2048 }, { 8, 859, 2048 }, { 7, 860, 2048 }, { 8, 861, 2048 }, { 8, 862, 2048 }, { 9, 863, 2048 }, 
-   { 5, 864, 2048 }, { 6, 865, 2048 }, { 6, 866, 2048 }, { 7, 867, 2048 }, { 6, 868, 2048 }, { 7, 869, 2048 }, { 7, 870, 2048 }, { 8, 871, 2048 }, 
-   { 6, 872, 2048 }, { 7, 873, 2048 }, { 7, 874, 2048 }, { 8, 875, 2048 }, { 7, 876, 2048 }, { 8, 877, 2048 }, { 8, 878, 2048 }, { 9, 879, 2048 }, 
-   { 6, 880, 2048 }, { 7, 881, 2048 }, { 7, 882, 2048 }, { 8, 883, 2048 }, { 7, 884, 2048 }, { 8, 885, 2048 }, { 8, 886, 2048 }, { 9, 887, 2048 }, 
-   { 7, 888, 2048 }, { 8, 889, 2048 }, { 8, 890, 2048 }, { 9, 891, 2048 }, { 8, 892, 2048 }, { 9, 893, 2048 }, { 9, 894, 2048 }, { 10, 895, 2048 }, 
-   { 4, 896, 2048 }, { 5, 897, 2048 }, { 5, 898, 2048 }, { 6, 899, 2048 }, { 5, 900, 2048 }, { 6, 901, 2048 }, { 6, 902, 2048 }, { 7, 903, 2048 }, 
-   { 5, 904, 2048 }, { 6, 905, 2048 }, { 6, 906, 2048 }, { 7, 907, 2048 }, { 6, 908, 2048 }, { 7, 909, 2048 }, { 7, 910, 2048 }, { 8, 911, 2048 }, 
-   { 5, 912, 2048 }, { 6, 913, 2048 }, { 6, 914, 2048 }, { 7, 915, 2048 }, { 6, 916, 2048 }, { 7, 917, 2048 }, { 7, 918, 2048 }, { 8, 919, 2048 }, 
-   { 6, 920, 2048 }, { 7, 921, 2048 }, { 7, 922, 2048 }, { 8, 923, 2048 }, { 7, 924, 2048 }, { 8, 925, 2048 }, { 8, 926, 2048 }, { 9, 927, 2048 }, 
-   { 5, 928, 2048 }, { 6, 929, 2048 }, { 6, 930, 2048 }, { 7, 931, 2048 }, { 6, 932, 2048 }, { 7, 933, 2048 }, { 7, 934, 2048 }, { 8, 935, 2048 }, 
-   { 6, 936, 2048 }, { 7, 937, 2048 }, { 7, 938, 2048 }, { 8, 939, 2048 }, { 7, 940, 2048 }, { 8, 941, 2048 }, { 8, 942, 2048 }, { 9, 943, 2048 }, 
-   { 6, 944, 2048 }, { 7, 945, 2048 }, { 7, 946, 2048 }, { 8, 947, 2048 }, { 7, 948, 2048 }, { 8, 949, 2048 }, { 8, 950, 2048 }, { 9, 951, 2048 }, 
-   { 7, 952, 2048 }, { 8, 953, 2048 }, { 8, 954, 2048 }, { 9, 955, 2048 }, { 8, 956, 2048 }, { 9, 957, 2048 }, { 9, 958, 2048 }, { 10, 959, 2048 }, 
-   { 5, 960, 2048 }, { 6, 961, 2048 }, { 6, 962, 2048 }, { 7, 963, 2048 }, { 6, 964, 2048 }, { 7, 965, 2048 }, { 7, 966, 2048 }, { 8, 967, 2048 }, 
-   { 6, 968, 2048 }, { 7, 969, 2048 }, { 7, 970, 2048 }, { 8, 971, 2048 }, { 7, 972, 2048 }, { 8, 973, 2048 }, { 8, 974, 2048 }, { 9, 975, 2048 }, 
-   { 6, 976, 2048 }, { 7, 977, 2048 }, { 7, 978, 2048 }, { 8, 979, 2048 }, { 7, 980, 2048 }, { 8, 981, 2048 }, { 8, 982, 2048 }, { 9, 983, 2048 }, 
-   { 7, 984, 2048 }, { 8, 985, 2048 }, { 8, 986, 2048 }, { 9, 987, 2048 }, { 8, 988, 2048 }, { 9, 989, 2048 }, { 9, 990, 2048 }, { 10, 991, 2048 }, 
-   { 6, 992, 2048 }, { 7, 993, 2048 }, { 7, 994, 2048 }, { 8, 995, 2048 }, { 7, 996, 2048 }, { 8, 997, 2048 }, { 8, 998, 2048 }, { 9, 999, 2048 }, 
-   { 7, 1000, 2048 }, { 8, 1001, 2048 }, { 8, 1002, 2048 }, { 9, 1003, 2048 }, { 8, 1004, 2048 }, { 9, 1005, 2048 }, { 9, 1006, 2048 }, { 10, 1007, 2048 }, 
-   { 7, 1008, 2048 }, { 8, 1009, 2048 }, { 8, 1010, 2048 }, { 9, 1011, 2048 }, { 8, 1012, 2048 }, { 9, 1013, 2048 }, { 9, 1014, 2048 }, { 10, 1015, 2048 }, 
-   { 8, 1016, 2048 }, { 9, 1017, 2048 }, { 9, 1018, 2048 }, { 10, 1019, 2048 }, { 9, 1020, 2048 }, { 10, 1021, 2048 }, { 10, 1022, 2048 }, { 11, 1023, 2048 }, 
-   { 2, 1024, 2048 }, { 3, 1025, 2048 }, { 3, 1026, 2048 }, { 4, 1027, 2048 }, { 3, 1028, 2048 }, { 4, 1029, 2048 }, { 4, 1030, 2048 }, { 5, 1031, 2048 }, 
-   { 3, 1032, 2048 }, { 4, 1033, 2048 }, { 4, 1034, 2048 }, { 5, 1035, 2048 }, { 4, 1036, 2048 }, { 5, 1037, 2048 }, { 5, 1038, 2048 }, { 6, 1039, 2048 }, 
-   { 3, 1040, 2048 }, { 4, 1041, 2048 }, { 4, 1042, 2048 }, { 5, 1043, 2048 }, { 4, 1044, 2048 }, { 5, 1045, 2048 }, { 5, 1046, 2048 }, { 6, 1047, 2048 }, 
-   { 4, 1048, 2048 }, { 5, 1049, 2048 }, { 5, 1050, 2048 }, { 6, 1051, 2048 }, { 5, 1052, 2048 }, { 6, 1053, 2048 }, { 6, 1054, 2048 }, { 7, 1055, 2048 }, 
-   { 3, 1056, 2048 }, { 4, 1057, 2048 }, { 4, 1058, 2048 }, { 5, 1059, 2048 }, { 4, 1060, 2048 }, { 5, 1061, 2048 }, { 5, 1062, 2048 }, { 6, 1063, 2048 }, 
-   { 4, 1064, 2048 }, { 5, 1065, 2048 }, { 5, 1066, 2048 }, { 6, 1067, 2048 }, { 5, 1068, 2048 }, { 6, 1069, 2048 }, { 6, 1070, 2048 }, { 7, 1071, 2048 }, 
-   { 4, 1072, 2048 }, { 5, 1073, 2048 }, { 5, 1074, 2048 }, { 6, 1075, 2048 }, { 5, 1076, 2048 }, { 6, 1077, 2048 }, { 6, 1078, 2048 }, { 7, 1079, 2048 }, 
-   { 5, 1080, 2048 }, { 6, 1081, 2048 }, { 6, 1082, 2048 }, { 7, 1083, 2048 }, { 6, 1084, 2048 }, { 7, 1085, 2048 }, { 7, 1086, 2048 }, { 8, 1087, 2048 }, 
-   { 3, 1088, 2048 }, { 4, 1089, 2048 }, { 4, 1090, 2048 }, { 5, 1091, 2048 }, { 4, 1092, 2048 }, { 5, 1093, 2048 }, { 5, 1094, 2048 }, { 6, 1095, 2048 }, 
-   { 4, 1096, 2048 }, { 5, 1097, 2048 }, { 5, 1098, 2048 }, { 6, 1099, 2048 }, { 5, 1100, 2048 }, { 6, 1101, 2048 }, { 6, 1102, 2048 }, { 7, 1103, 2048 }, 
-   { 4, 1104, 2048 }, { 5, 1105, 2048 }, { 5, 1106, 2048 }, { 6, 1107, 2048 }, { 5, 1108, 2048 }, { 6, 1109, 2048 }, { 6, 1110, 2048 }, { 7, 1111, 2048 }, 
-   { 5, 1112, 2048 }, { 6, 1113, 2048 }, { 6, 1114, 2048 }, { 7, 1115, 2048 }, { 6, 1116, 2048 }, { 7, 1117, 2048 }, { 7, 1118, 2048 }, { 8, 1119, 2048 }, 
-   { 4, 1120, 2048 }, { 5, 1121, 2048 }, { 5, 1122, 2048 }, { 6, 1123, 2048 }, { 5, 1124, 2048 }, { 6, 1125, 2048 }, { 6, 1126, 2048 }, { 7, 1127, 2048 }, 
-   { 5, 1128, 2048 }, { 6, 1129, 2048 }, { 6, 1130, 2048 }, { 7, 1131, 2048 }, { 6, 1132, 2048 }, { 7, 1133, 2048 }, { 7, 1134, 2048 }, { 8, 1135, 2048 }, 
-   { 5, 1136, 2048 }, { 6, 1137, 2048 }, { 6, 1138, 2048 }, { 7, 1139, 2048 }, { 6, 1140, 2048 }, { 7, 1141, 2048 }, { 7, 1142, 2048 }, { 8, 1143, 2048 }, 
-   { 6, 1144, 2048 }, { 7, 1145, 2048 }, { 7, 1146, 2048 }, { 8, 1147, 2048 }, { 7, 1148, 2048 }, { 8, 1149, 2048 }, { 8, 1150, 2048 }, { 9, 1151, 2048 }, 
-   { 3, 1152, 2048 }, { 4, 1153, 2048 }, { 4, 1154, 2048 }, { 5, 1155, 2048 }, { 4, 1156, 2048 }, { 5, 1157, 2048 }, { 5, 1158, 2048 }, { 6, 1159, 2048 }, 
-   { 4, 1160, 2048 }, { 5, 1161, 2048 }, { 5, 1162, 2048 }, { 6, 1163, 2048 }, { 5, 1164, 2048 }, { 6, 1165, 2048 }, { 6, 1166, 2048 }, { 7, 1167, 2048 }, 
-   { 4, 1168, 2048 }, { 5, 1169, 2048 }, { 5, 1170, 2048 }, { 6, 1171, 2048 }, { 5, 1172, 2048 }, { 6, 1173, 2048 }, { 6, 1174, 2048 }, { 7, 1175, 2048 }, 
-   { 5, 1176, 2048 }, { 6, 1177, 2048 }, { 6, 1178, 2048 }, { 7, 1179, 2048 }, { 6, 1180, 2048 }, { 7, 1181, 2048 }, { 7, 1182, 2048 }, { 8, 1183, 2048 }, 
-   { 4, 1184, 2048 }, { 5, 1185, 2048 }, { 5, 1186, 2048 }, { 6, 1187, 2048 }, { 5, 1188, 2048 }, { 6, 1189, 2048 }, { 6, 1190, 2048 }, { 7, 1191, 2048 }, 
-   { 5, 1192, 2048 }, { 6, 1193, 2048 }, { 6, 1194, 2048 }, { 7, 1195, 2048 }, { 6, 1196, 2048 }, { 7, 1197, 2048 }, { 7, 1198, 2048 }, { 8, 1199, 2048 }, 
-   { 5, 1200, 2048 }, { 6, 1201, 2048 }, { 6, 1202, 2048 }, { 7, 1203, 2048 }, { 6, 1204, 2048 }, { 7, 1205, 2048 }, { 7, 1206, 2048 }, { 8, 1207, 2048 }, 
-   { 6, 1208, 2048 }, { 7, 1209, 2048 }, { 7, 1210, 2048 }, { 8, 1211, 2048 }, { 7, 1212, 2048 }, { 8, 1213, 2048 }, { 8, 1214, 2048 }, { 9, 1215, 2048 }, 
-   { 4, 1216, 2048 }, { 5, 1217, 2048 }, { 5, 1218, 2048 }, { 6, 1219, 2048 }, { 5, 1220, 2048 }, { 6, 1221, 2048 }, { 6, 1222, 2048 }, { 7, 1223, 2048 }, 
-   { 5, 1224, 2048 }, { 6, 1225, 2048 }, { 6, 1226, 2048 }, { 7, 1227, 2048 }, { 6, 1228, 2048 }, { 7, 1229, 2048 }, { 7, 1230, 2048 }, { 8, 1231, 2048 }, 
-   { 5, 1232, 2048 }, { 6, 1233, 2048 }, { 6, 1234, 2048 }, { 7, 1235, 2048 }, { 6, 1236, 2048 }, { 7, 1237, 2048 }, { 7, 1238, 2048 }, { 8, 1239, 2048 }, 
-   { 6, 1240, 2048 }, { 7, 1241, 2048 }, { 7, 1242, 2048 }, { 8, 1243, 2048 }, { 7, 1244, 2048 }, { 8, 1245, 2048 }, { 8, 1246, 2048 }, { 9, 1247, 2048 }, 
-   { 5, 1248, 2048 }, { 6, 1249, 2048 }, { 6, 1250, 2048 }, { 7, 1251, 2048 }, { 6, 1252, 2048 }, { 7, 1253, 2048 }, { 7, 1254, 2048 }, { 8, 1255, 2048 }, 
-   { 6, 1256, 2048 }, { 7, 1257, 2048 }, { 7, 1258, 2048 }, { 8, 1259, 2048 }, { 7, 1260, 2048 }, { 8, 1261, 2048 }, { 8, 1262, 2048 }, { 9, 1263, 2048 }, 
-   { 6, 1264, 2048 }, { 7, 1265, 2048 }, { 7, 1266, 2048 }, { 8, 1267, 2048 }, { 7, 1268, 2048 }, { 8, 1269, 2048 }, { 8, 1270, 2048 }, { 9, 1271, 2048 }, 
-   { 7, 1272, 2048 }, { 8, 1273, 2048 }, { 8, 1274, 2048 }, { 9, 1275, 2048 }, { 8, 1276, 2048 }, { 9, 1277, 2048 }, { 9, 1278, 2048 }, { 10, 1279, 2048 }, 
-   { 3, 1280, 2048 }, { 4, 1281, 2048 }, { 4, 1282, 2048 }, { 5, 1283, 2048 }, { 4, 1284, 2048 }, { 5, 1285, 2048 }, { 5, 1286, 2048 }, { 6, 1287, 2048 }, 
-   { 4, 1288, 2048 }, { 5, 1289, 2048 }, { 5, 1290, 2048 }, { 6, 1291, 2048 }, { 5, 1292, 2048 }, { 6, 1293, 2048 }, { 6, 1294, 2048 }, { 7, 1295, 2048 }, 
-   { 4, 1296, 2048 }, { 5, 1297, 2048 }, { 5, 1298, 2048 }, { 6, 1299, 2048 }, { 5, 1300, 2048 }, { 6, 1301, 2048 }, { 6, 1302, 2048 }, { 7, 1303, 2048 }, 
-   { 5, 1304, 2048 }, { 6, 1305, 2048 }, { 6, 1306, 2048 }, { 7, 1307, 2048 }, { 6, 1308, 2048 }, { 7, 1309, 2048 }, { 7, 1310, 2048 }, { 8, 1311, 2048 }, 
-   { 4, 1312, 2048 }, { 5, 1313, 2048 }, { 5, 1314, 2048 }, { 6, 1315, 2048 }, { 5, 1316, 2048 }, { 6, 1317, 2048 }, { 6, 1318, 2048 }, { 7, 1319, 2048 }, 
-   { 5, 1320, 2048 }, { 6, 1321, 2048 }, { 6, 1322, 2048 }, { 7, 1323, 2048 }, { 6, 1324, 2048 }, { 7, 1325, 2048 }, { 7, 1326, 2048 }, { 8, 1327, 2048 }, 
-   { 5, 1328, 2048 }, { 6, 1329, 2048 }, { 6, 1330, 2048 }, { 7, 1331, 2048 }, { 6, 1332, 2048 }, { 7, 1333, 2048 }, { 7, 1334, 2048 }, { 8, 1335, 2048 }, 
-   { 6, 1336, 2048 }, { 7, 1337, 2048 }, { 7, 1338, 2048 }, { 8, 1339, 2048 }, { 7, 1340, 2048 }, { 8, 1341, 2048 }, { 8, 1342, 2048 }, { 9, 1343, 2048 }, 
-   { 4, 1344, 2048 }, { 5, 1345, 2048 }, { 5, 1346, 2048 }, { 6, 1347, 2048 }, { 5, 1348, 2048 }, { 6, 1349, 2048 }, { 6, 1350, 2048 }, { 7, 1351, 2048 }, 
-   { 5, 1352, 2048 }, { 6, 1353, 2048 }, { 6, 1354, 2048 }, { 7, 1355, 2048 }, { 6, 1356, 2048 }, { 7, 1357, 2048 }, { 7, 1358, 2048 }, { 8, 1359, 2048 }, 
-   { 5, 1360, 2048 }, { 6, 1361, 2048 }, { 6, 1362, 2048 }, { 7, 1363, 2048 }, { 6, 1364, 2048 }, { 7, 1365, 2048 }, { 7, 1366, 2048 }, { 8, 1367, 2048 }, 
-   { 6, 1368, 2048 }, { 7, 1369, 2048 }, { 7, 1370, 2048 }, { 8, 1371, 2048 }, { 7, 1372, 2048 }, { 8, 1373, 2048 }, { 8, 1374, 2048 }, { 9, 1375, 2048 }, 
-   { 5, 1376, 2048 }, { 6, 1377, 2048 }, { 6, 1378, 2048 }, { 7, 1379, 2048 }, { 6, 1380, 2048 }, { 7, 1381, 2048 }, { 7, 1382, 2048 }, { 8, 1383, 2048 }, 
-   { 6, 1384, 2048 }, { 7, 1385, 2048 }, { 7, 1386, 2048 }, { 8, 1387, 2048 }, { 7, 1388, 2048 }, { 8, 1389, 2048 }, { 8, 1390, 2048 }, { 9, 1391, 2048 }, 
-   { 6, 1392, 2048 }, { 7, 1393, 2048 }, { 7, 1394, 2048 }, { 8, 1395, 2048 }, { 7, 1396, 2048 }, { 8, 1397, 2048 }, { 8, 1398, 2048 }, { 9, 1399, 2048 }, 
-   { 7, 1400, 2048 }, { 8, 1401, 2048 }, { 8, 1402, 2048 }, { 9, 1403, 2048 }, { 8, 1404, 2048 }, { 9, 1405, 2048 }, { 9, 1406, 2048 }, { 10, 1407, 2048 }, 
-   { 4, 1408, 2048 }, { 5, 1409, 2048 }, { 5, 1410, 2048 }, { 6, 1411, 2048 }, { 5, 1412, 2048 }, { 6, 1413, 2048 }, { 6, 1414, 2048 }, { 7, 1415, 2048 }, 
-   { 5, 1416, 2048 }, { 6, 1417, 2048 }, { 6, 1418, 2048 }, { 7, 1419, 2048 }, { 6, 1420, 2048 }, { 7, 1421, 2048 }, { 7, 1422, 2048 }, { 8, 1423, 2048 }, 
-   { 5, 1424, 2048 }, { 6, 1425, 2048 }, { 6, 1426, 2048 }, { 7, 1427, 2048 }, { 6, 1428, 2048 }, { 7, 1429, 2048 }, { 7, 1430, 2048 }, { 8, 1431, 2048 }, 
-   { 6, 1432, 2048 }, { 7, 1433, 2048 }, { 7, 1434, 2048 }, { 8, 1435, 2048 }, { 7, 1436, 2048 }, { 8, 1437, 2048 }, { 8, 1438, 2048 }, { 9, 1439, 2048 }, 
-   { 5, 1440, 2048 }, { 6, 1441, 2048 }, { 6, 1442, 2048 }, { 7, 1443, 2048 }, { 6, 1444, 2048 }, { 7, 1445, 2048 }, { 7, 1446, 2048 }, { 8, 1447, 2048 }, 
-   { 6, 1448, 2048 }, { 7, 1449, 2048 }, { 7, 1450, 2048 }, { 8, 1451, 2048 }, { 7, 1452, 2048 }, { 8, 1453, 2048 }, { 8, 1454, 2048 }, { 9, 1455, 2048 }, 
-   { 6, 1456, 2048 }, { 7, 1457, 2048 }, { 7, 1458, 2048 }, { 8, 1459, 2048 }, { 7, 1460, 2048 }, { 8, 1461, 2048 }, { 8, 1462, 2048 }, { 9, 1463, 2048 }, 
-   { 7, 1464, 2048 }, { 8, 1465, 2048 }, { 8, 1466, 2048 }, { 9, 1467, 2048 }, { 8, 1468, 2048 }, { 9, 1469, 2048 }, { 9, 1470, 2048 }, { 10, 1471, 2048 }, 
-   { 5, 1472, 2048 }, { 6, 1473, 2048 }, { 6, 1474, 2048 }, { 7, 1475, 2048 }, { 6, 1476, 2048 }, { 7, 1477, 2048 }, { 7, 1478, 2048 }, { 8, 1479, 2048 }, 
-   { 6, 1480, 2048 }, { 7, 1481, 2048 }, { 7, 1482, 2048 }, { 8, 1483, 2048 }, { 7, 1484, 2048 }, { 8, 1485, 2048 }, { 8, 1486, 2048 }, { 9, 1487, 2048 }, 
-   { 6, 1488, 2048 }, { 7, 1489, 2048 }, { 7, 1490, 2048 }, { 8, 1491, 2048 }, { 7, 1492, 2048 }, { 8, 1493, 2048 }, { 8, 1494, 2048 }, { 9, 1495, 2048 }, 
-   { 7, 1496, 2048 }, { 8, 1497, 2048 }, { 8, 1498, 2048 }, { 9, 1499, 2048 }, { 8, 1500, 2048 }, { 9, 1501, 2048 }, { 9, 1502, 2048 }, { 10, 1503, 2048 }, 
-   { 6, 1504, 2048 }, { 7, 1505, 2048 }, { 7, 1506, 2048 }, { 8, 1507, 2048 }, { 7, 1508, 2048 }, { 8, 1509, 2048 }, { 8, 1510, 2048 }, { 9, 1511, 2048 }, 
-   { 7, 1512, 2048 }, { 8, 1513, 2048 }, { 8, 1514, 2048 }, { 9, 1515, 2048 }, { 8, 1516, 2048 }, { 9, 1517, 2048 }, { 9, 1518, 2048 }, { 10, 1519, 2048 }, 
-   { 7, 1520, 2048 }, { 8, 1521, 2048 }, { 8, 1522, 2048 }, { 9, 1523, 2048 }, { 8, 1524, 2048 }, { 9, 1525, 2048 }, { 9, 1526, 2048 }, { 10, 1527, 2048 }, 
-   { 8, 1528, 2048 }, { 9, 1529, 2048 }, { 9, 1530, 2048 }, { 10, 1531, 2048 }, { 9, 1532, 2048 }, { 10, 1533, 2048 }, { 10, 1534, 2048 }, { 11, 1535, 2048 }, 
-   { 3, 1536, 2048 }, { 4, 1537, 2048 }, { 4, 1538, 2048 }, { 5, 1539, 2048 }, { 4, 1540, 2048 }, { 5, 1541, 2048 }, { 5, 1542, 2048 }, { 6, 1543, 2048 }, 
-   { 4, 1544, 2048 }, { 5, 1545, 2048 }, { 5, 1546, 2048 }, { 6, 1547, 2048 }, { 5, 1548, 2048 }, { 6, 1549, 2048 }, { 6, 1550, 2048 }, { 7, 1551, 2048 }, 
-   { 4, 1552, 2048 }, { 5, 1553, 2048 }, { 5, 1554, 2048 }, { 6, 1555, 2048 }, { 5, 1556, 2048 }, { 6, 1557, 2048 }, { 6, 1558, 2048 }, { 7, 1559, 2048 }, 
-   { 5, 1560, 2048 }, { 6, 1561, 2048 }, { 6, 1562, 2048 }, { 7, 1563, 2048 }, { 6, 1564, 2048 }, { 7, 1565, 2048 }, { 7, 1566, 2048 }, { 8, 1567, 2048 }, 
-   { 4, 1568, 2048 }, { 5, 1569, 2048 }, { 5, 1570, 2048 }, { 6, 1571, 2048 }, { 5, 1572, 2048 }, { 6, 1573, 2048 }, { 6, 1574, 2048 }, { 7, 1575, 2048 }, 
-   { 5, 1576, 2048 }, { 6, 1577, 2048 }, { 6, 1578, 2048 }, { 7, 1579, 2048 }, { 6, 1580, 2048 }, { 7, 1581, 2048 }, { 7, 1582, 2048 }, { 8, 1583, 2048 }, 
-   { 5, 1584, 2048 }, { 6, 1585, 2048 }, { 6, 1586, 2048 }, { 7, 1587, 2048 }, { 6, 1588, 2048 }, { 7, 1589, 2048 }, { 7, 1590, 2048 }, { 8, 1591, 2048 }, 
-   { 6, 1592, 2048 }, { 7, 1593, 2048 }, { 7, 1594, 2048 }, { 8, 1595, 2048 }, { 7, 1596, 2048 }, { 8, 1597, 2048 }, { 8, 1598, 2048 }, { 9, 1599, 2048 }, 
-   { 4, 1600, 2048 }, { 5, 1601, 2048 }, { 5, 1602, 2048 }, { 6, 1603, 2048 }, { 5, 1604, 2048 }, { 6, 1605, 2048 }, { 6, 1606, 2048 }, { 7, 1607, 2048 }, 
-   { 5, 1608, 2048 }, { 6, 1609, 2048 }, { 6, 1610, 2048 }, { 7, 1611, 2048 }, { 6, 1612, 2048 }, { 7, 1613, 2048 }, { 7, 1614, 2048 }, { 8, 1615, 2048 }, 
-   { 5, 1616, 2048 }, { 6, 1617, 2048 }, { 6, 1618, 2048 }, { 7, 1619, 2048 }, { 6, 1620, 2048 }, { 7, 1621, 2048 }, { 7, 1622, 2048 }, { 8, 1623, 2048 }, 
-   { 6, 1624, 2048 }, { 7, 1625, 2048 }, { 7, 1626, 2048 }, { 8, 1627, 2048 }, { 7, 1628, 2048 }, { 8, 1629, 2048 }, { 8, 1630, 2048 }, { 9, 1631, 2048 }, 
-   { 5, 1632, 2048 }, { 6, 1633, 2048 }, { 6, 1634, 2048 }, { 7, 1635, 2048 }, { 6, 1636, 2048 }, { 7, 1637, 2048 }, { 7, 1638, 2048 }, { 8, 1639, 2048 }, 
-   { 6, 1640, 2048 }, { 7, 1641, 2048 }, { 7, 1642, 2048 }, { 8, 1643, 2048 }, { 7, 1644, 2048 }, { 8, 1645, 2048 }, { 8, 1646, 2048 }, { 9, 1647, 2048 }, 
-   { 6, 1648, 2048 }, { 7, 1649, 2048 }, { 7, 1650, 2048 }, { 8, 1651, 2048 }, { 7, 1652, 2048 }, { 8, 1653, 2048 }, { 8, 1654, 2048 }, { 9, 1655, 2048 }, 
-   { 7, 1656, 2048 }, { 8, 1657, 2048 }, { 8, 1658, 2048 }, { 9, 1659, 2048 }, { 8, 1660, 2048 }, { 9, 1661, 2048 }, { 9, 1662, 2048 }, { 10, 1663, 2048 }, 
-   { 4, 1664, 2048 }, { 5, 1665, 2048 }, { 5, 1666, 2048 }, { 6, 1667, 2048 }, { 5, 1668, 2048 }, { 6, 1669, 2048 }, { 6, 1670, 2048 }, { 7, 1671, 2048 }, 
-   { 5, 1672, 2048 }, { 6, 1673, 2048 }, { 6, 1674, 2048 }, { 7, 1675, 2048 }, { 6, 1676, 2048 }, { 7, 1677, 2048 }, { 7, 1678, 2048 }, { 8, 1679, 2048 }, 
-   { 5, 1680, 2048 }, { 6, 1681, 2048 }, { 6, 1682, 2048 }, { 7, 1683, 2048 }, { 6, 1684, 2048 }, { 7, 1685, 2048 }, { 7, 1686, 2048 }, { 8, 1687, 2048 }, 
-   { 6, 1688, 2048 }, { 7, 1689, 2048 }, { 7, 1690, 2048 }, { 8, 1691, 2048 }, { 7, 1692, 2048 }, { 8, 1693, 2048 }, { 8, 1694, 2048 }, { 9, 1695, 2048 }, 
-   { 5, 1696, 2048 }, { 6, 1697, 2048 }, { 6, 1698, 2048 }, { 7, 1699, 2048 }, { 6, 1700, 2048 }, { 7, 1701, 2048 }, { 7, 1702, 2048 }, { 8, 1703, 2048 }, 
-   { 6, 1704, 2048 }, { 7, 1705, 2048 }, { 7, 1706, 2048 }, { 8, 1707, 2048 }, { 7, 1708, 2048 }, { 8, 1709, 2048 }, { 8, 1710, 2048 }, { 9, 1711, 2048 }, 
-   { 6, 1712, 2048 }, { 7, 1713, 2048 }, { 7, 1714, 2048 }, { 8, 1715, 2048 }, { 7, 1716, 2048 }, { 8, 1717, 2048 }, { 8, 1718, 2048 }, { 9, 1719, 2048 }, 
-   { 7, 1720, 2048 }, { 8, 1721, 2048 }, { 8, 1722, 2048 }, { 9, 1723, 2048 }, { 8, 1724, 2048 }, { 9, 1725, 2048 }, { 9, 1726, 2048 }, { 10, 1727, 2048 }, 
-   { 5, 1728, 2048 }, { 6, 1729, 2048 }, { 6, 1730, 2048 }, { 7, 1731, 2048 }, { 6, 1732, 2048 }, { 7, 1733, 2048 }, { 7, 1734, 2048 }, { 8, 1735, 2048 }, 
-   { 6, 1736, 2048 }, { 7, 1737, 2048 }, { 7, 1738, 2048 }, { 8, 1739, 2048 }, { 7, 1740, 2048 }, { 8, 1741, 2048 }, { 8, 1742, 2048 }, { 9, 1743, 2048 }, 
-   { 6, 1744, 2048 }, { 7, 1745, 2048 }, { 7, 1746, 2048 }, { 8, 1747, 2048 }, { 7, 1748, 2048 }, { 8, 1749, 2048 }, { 8, 1750, 2048 }, { 9, 1751, 2048 }, 
-   { 7, 1752, 2048 }, { 8, 1753, 2048 }, { 8, 1754, 2048 }, { 9, 1755, 2048 }, { 8, 1756, 2048 }, { 9, 1757, 2048 }, { 9, 1758, 2048 }, { 10, 1759, 2048 }, 
-   { 6, 1760, 2048 }, { 7, 1761, 2048 }, { 7, 1762, 2048 }, { 8, 1763, 2048 }, { 7, 1764, 2048 }, { 8, 1765, 2048 }, { 8, 1766, 2048 }, { 9, 1767, 2048 }, 
-   { 7, 1768, 2048 }, { 8, 1769, 2048 }, { 8, 1770, 2048 }, { 9, 1771, 2048 }, { 8, 1772, 2048 }, { 9, 1773, 2048 }, { 9, 1774, 2048 }, { 10, 1775, 2048 }, 
-   { 7, 1776, 2048 }, { 8, 1777, 2048 }, { 8, 1778, 2048 }, { 9, 1779, 2048 }, { 8, 1780, 2048 }, { 9, 1781, 2048 }, { 9, 1782, 2048 }, { 10, 1783, 2048 }, 
-   { 8, 1784, 2048 }, { 9, 1785, 2048 }, { 9, 1786, 2048 }, { 10, 1787, 2048 }, { 9, 1788, 2048 }, { 10, 1789, 2048 }, { 10, 1790, 2048 }, { 11, 1791, 2048 }, 
-   { 4, 1792, 2048 }, { 5, 1793, 2048 }, { 5, 1794, 2048 }, { 6, 1795, 2048 }, { 5, 1796, 2048 }, { 6, 1797, 2048 }, { 6, 1798, 2048 }, { 7, 1799, 2048 }, 
-   { 5, 1800, 2048 }, { 6, 1801, 2048 }, { 6, 1802, 2048 }, { 7, 1803, 2048 }, { 6, 1804, 2048 }, { 7, 1805, 2048 }, { 7, 1806, 2048 }, { 8, 1807, 2048 }, 
-   { 5, 1808, 2048 }, { 6, 1809, 2048 }, { 6, 1810, 2048 }, { 7, 1811, 2048 }, { 6, 1812, 2048 }, { 7, 1813, 2048 }, { 7, 1814, 2048 }, { 8, 1815, 2048 }, 
-   { 6, 1816, 2048 }, { 7, 1817, 2048 }, { 7, 1818, 2048 }, { 8, 1819, 2048 }, { 7, 1820, 2048 }, { 8, 1821, 2048 }, { 8, 1822, 2048 }, { 9, 1823, 2048 }, 
-   { 5, 1824, 2048 }, { 6, 1825, 2048 }, { 6, 1826, 2048 }, { 7, 1827, 2048 }, { 6, 1828, 2048 }, { 7, 1829, 2048 }, { 7, 1830, 2048 }, { 8, 1831, 2048 }, 
-   { 6, 1832, 2048 }, { 7, 1833, 2048 }, { 7, 1834, 2048 }, { 8, 1835, 2048 }, { 7, 1836, 2048 }, { 8, 1837, 2048 }, { 8, 1838, 2048 }, { 9, 1839, 2048 }, 
-   { 6, 1840, 2048 }, { 7, 1841, 2048 }, { 7, 1842, 2048 }, { 8, 1843, 2048 }, { 7, 1844, 2048 }, { 8, 1845, 2048 }, { 8, 1846, 2048 }, { 9, 1847, 2048 }, 
-   { 7, 1848, 2048 }, { 8, 1849, 2048 }, { 8, 1850, 2048 }, { 9, 1851, 2048 }, { 8, 1852, 2048 }, { 9, 1853, 2048 }, { 9, 1854, 2048 }, { 10, 1855, 2048 }, 
-   { 5, 1856, 2048 }, { 6, 1857, 2048 }, { 6, 1858, 2048 }, { 7, 1859, 2048 }, { 6, 1860, 2048 }, { 7, 1861, 2048 }, { 7, 1862, 2048 }, { 8, 1863, 2048 }, 
-   { 6, 1864, 2048 }, { 7, 1865, 2048 }, { 7, 1866, 2048 }, { 8, 1867, 2048 }, { 7, 1868, 2048 }, { 8, 1869, 2048 }, { 8, 1870, 2048 }, { 9, 1871, 2048 }, 
-   { 6, 1872, 2048 }, { 7, 1873, 2048 }, { 7, 1874, 2048 }, { 8, 1875, 2048 }, { 7, 1876, 2048 }, { 8, 1877, 2048 }, { 8, 1878, 2048 }, { 9, 1879, 2048 }, 
-   { 7, 1880, 2048 }, { 8, 1881, 2048 }, { 8, 1882, 2048 }, { 9, 1883, 2048 }, { 8, 1884, 2048 }, { 9, 1885, 2048 }, { 9, 1886, 2048 }, { 10, 1887, 2048 }, 
-   { 6, 1888, 2048 }, { 7, 1889, 2048 }, { 7, 1890, 2048 }, { 8, 1891, 2048 }, { 7, 1892, 2048 }, { 8, 1893, 2048 }, { 8, 1894, 2048 }, { 9, 1895, 2048 }, 
-   { 7, 1896, 2048 }, { 8, 1897, 2048 }, { 8, 1898, 2048 }, { 9, 1899, 2048 }, { 8, 1900, 2048 }, { 9, 1901, 2048 }, { 9, 1902, 2048 }, { 10, 1903, 2048 }, 
-   { 7, 1904, 2048 }, { 8, 1905, 2048 }, { 8, 1906, 2048 }, { 9, 1907, 2048 }, { 8, 1908, 2048 }, { 9, 1909, 2048 }, { 9, 1910, 2048 }, { 10, 1911, 2048 }, 
-   { 8, 1912, 2048 }, { 9, 1913, 2048 }, { 9, 1914, 2048 }, { 10, 1915, 2048 }, { 9, 1916, 2048 }, { 10, 1917, 2048 }, { 10, 1918, 2048 }, { 11, 1919, 2048 }, 
-   { 5, 1920, 2048 }, { 6, 1921, 2048 }, { 6, 1922, 2048 }, { 7, 1923, 2048 }, { 6, 1924, 2048 }, { 7, 1925, 2048 }, { 7, 1926, 2048 }, { 8, 1927, 2048 }, 
-   { 6, 1928, 2048 }, { 7, 1929, 2048 }, { 7, 1930, 2048 }, { 8, 1931, 2048 }, { 7, 1932, 2048 }, { 8, 1933, 2048 }, { 8, 1934, 2048 }, { 9, 1935, 2048 }, 
-   { 6, 1936, 2048 }, { 7, 1937, 2048 }, { 7, 1938, 2048 }, { 8, 1939, 2048 }, { 7, 1940, 2048 }, { 8, 1941, 2048 }, { 8, 1942, 2048 }, { 9, 1943, 2048 }, 
-   { 7, 1944, 2048 }, { 8, 1945, 2048 }, { 8, 1946, 2048 }, { 9, 1947, 2048 }, { 8, 1948, 2048 }, { 9, 1949, 2048 }, { 9, 1950, 2048 }, { 10, 1951, 2048 }, 
-   { 6, 1952, 2048 }, { 7, 1953, 2048 }, { 7, 1954, 2048 }, { 8, 1955, 2048 }, { 7, 1956, 2048 }, { 8, 1957, 2048 }, { 8, 1958, 2048 }, { 9, 1959, 2048 }, 
-   { 7, 1960, 2048 }, { 8, 1961, 2048 }, { 8, 1962, 2048 }, { 9, 1963, 2048 }, { 8, 1964, 2048 }, { 9, 1965, 2048 }, { 9, 1966, 2048 }, { 10, 1967, 2048 }, 
-   { 7, 1968, 2048 }, { 8, 1969, 2048 }, { 8, 1970, 2048 }, { 9, 1971, 2048 }, { 8, 1972, 2048 }, { 9, 1973, 2048 }, { 9, 1974, 2048 }, { 10, 1975, 2048 }, 
-   { 8, 1976, 2048 }, { 9, 1977, 2048 }, { 9, 1978, 2048 }, { 10, 1979, 2048 }, { 9, 1980, 2048 }, { 10, 1981, 2048 }, { 10, 1982, 2048 }, { 11, 1983, 2048 }, 
-   { 6, 1984, 2048 }, { 7, 1985, 2048 }, { 7, 1986, 2048 }, { 8, 1987, 2048 }, { 7, 1988, 2048 }, { 8, 1989, 2048 }, { 8, 1990, 2048 }, { 9, 1991, 2048 }, 
-   { 7, 1992, 2048 }, { 8, 1993, 2048 }, { 8, 1994, 2048 }, { 9, 1995, 2048 }, { 8, 1996, 2048 }, { 9, 1997, 2048 }, { 9, 1998, 2048 }, { 10, 1999, 2048 }, 
-   { 7, 2000, 2048 }, { 8, 2001, 2048 }, { 8, 2002, 2048 }, { 9, 2003, 2048 }, { 8, 2004, 2048 }, { 9, 2005, 2048 }, { 9, 2006, 2048 }, { 10, 2007, 2048 }, 
-   { 8, 2008, 2048 }, { 9, 2009, 2048 }, { 9, 2010, 2048 }, { 10, 2011, 2048 }, { 9, 2012, 2048 }, { 10, 2013, 2048 }, { 10, 2014, 2048 }, { 11, 2015, 2048 }, 
-   { 7, 2016, 2048 }, { 8, 2017, 2048 }, { 8, 2018, 2048 }, { 9, 2019, 2048 }, { 8, 2020, 2048 }, { 9, 2021, 2048 }, { 9, 2022, 2048 }, { 10, 2023, 2048 }, 
-   { 8, 2024, 2048 }, { 9, 2025, 2048 }, { 9, 2026, 2048 }, { 10, 2027, 2048 }, { 9, 2028, 2048 }, { 10, 2029, 2048 }, { 10, 2030, 2048 }, { 11, 2031, 2048 }, 
-   { 8, 2032, 2048 }, { 9, 2033, 2048 }, { 9, 2034, 2048 }, { 10, 2035, 2048 }, { 9, 2036, 2048 }, { 10, 2037, 2048 }, { 10, 2038, 2048 }, { 11, 2039, 2048 }, 
-   { 9, 2040, 2048 }, { 10, 2041, 2048 }, { 10, 2042, 2048 }, { 11, 2043, 2048 }, { 10, 2044, 2048 }, { 11, 2045, 2048 }, { 11, 2046, 2048 }, { 12, 2047, 2048 }, 
-#endif
-#endif
-#endif
-#endif
-#endif
-#endif
-};
-
-/* find a hole and free as required, return -1 if no hole found */
-static int find_hole(void)
-{
-   unsigned x;
-   int      y, z;
-   for (z = -1, y = INT_MAX, x = 0; x < FP_ENTRIES; x++) {
-       if (fp_cache[x].lru_count < y && fp_cache[x].lock == 0) {
-          z = x;
-          y = fp_cache[x].lru_count;
-       }
-   }
-
-   /* decrease all */
-   for (x = 0; x < FP_ENTRIES; x++) {
-      if (fp_cache[x].lru_count > 3) {
-         --(fp_cache[x].lru_count);
-      }
-   }
-
-   /* free entry z */
-   if (z >= 0 && fp_cache[z].g) {
-      mp_clear(&fp_cache[z].mu);
-      ecc_del_point(fp_cache[z].g);
-      fp_cache[z].g  = NULL;
-      for (x = 0; x < (1U<x, g->x) == MP_EQ && 
-          mp_cmp(fp_cache[x].g->y, g->y) == MP_EQ && 
-          mp_cmp(fp_cache[x].g->z, g->z) == MP_EQ) {
-         break;
-      }
-   }
-   if (x == FP_ENTRIES) {
-      x = -1;
-   }
-   return x;
-}
-
-/* add a new base to the cache */
-static int add_entry(int idx, ecc_point *g)
-{
-   unsigned x, y;
-
-   /* allocate base and LUT */
-   fp_cache[idx].g = ecc_new_point();
-   if (fp_cache[idx].g == NULL) {
-      return GEN_MEM_ERR;
-   }
-
-   /* copy x and y */
-   if ((mp_copy(g->x, fp_cache[idx].g->x) != MP_OKAY) ||
-       (mp_copy(g->y, fp_cache[idx].g->y) != MP_OKAY) ||
-       (mp_copy(g->z, fp_cache[idx].g->z) != MP_OKAY)) {
-      ecc_del_point(fp_cache[idx].g);
-      fp_cache[idx].g = NULL;
-      return GEN_MEM_ERR;
-   }              
-
-   for (x = 0; x < (1U<x, mu, modulus,
-                  fp_cache[idx].LUT[1]->x) != MP_OKAY) || 
-         (mp_mulmod(fp_cache[idx].g->y, mu, modulus,
-                  fp_cache[idx].LUT[1]->y) != MP_OKAY) || 
-         (mp_mulmod(fp_cache[idx].g->z, mu, modulus,
-                  fp_cache[idx].LUT[1]->z) != MP_OKAY)) {
-       err = MP_MULMOD_E; 
-     }
-   }
-       
-   /* make all single bit entries */
-   for (x = 1; x < FP_LUT; x++) {
-      if (err != MP_OKAY)
-          break;
-      if ((mp_copy(fp_cache[idx].LUT[1<<(x-1)]->x,
-                   fp_cache[idx].LUT[1<x) != MP_OKAY) || 
-          (mp_copy(fp_cache[idx].LUT[1<<(x-1)]->y,
-                   fp_cache[idx].LUT[1<y) != MP_OKAY) || 
-          (mp_copy(fp_cache[idx].LUT[1<<(x-1)]->z,
-                   fp_cache[idx].LUT[1<z) != MP_OKAY)){
-          err = MP_INIT_E;
-          break;
-      } else {
-          
-         /* now double it bitlen/FP_LUT times */
-         for (y = 0; y < lut_gap; y++) {
-             if ((err = ecc_projective_dbl_point(fp_cache[idx].LUT[1<z, modulus, *mp);
- 
-       /* invert it */
-       if (err == MP_OKAY)
-         err = mp_invmod(fp_cache[idx].LUT[x]->z, modulus,
-                         fp_cache[idx].LUT[x]->z);
-
-       if (err == MP_OKAY)
-         /* now square it */
-         err = mp_sqrmod(fp_cache[idx].LUT[x]->z, modulus, &tmp);
-       
-       if (err == MP_OKAY)
-         /* fix x */
-         err = mp_mulmod(fp_cache[idx].LUT[x]->x, &tmp, modulus,
-                         fp_cache[idx].LUT[x]->x);
-
-       if (err == MP_OKAY)
-         /* get 1/z^3 */
-         err = mp_mulmod(&tmp, fp_cache[idx].LUT[x]->z, modulus, &tmp);
-
-       if (err == MP_OKAY)
-         /* fix y */
-         err = mp_mulmod(fp_cache[idx].LUT[x]->y, &tmp, modulus,
-                         fp_cache[idx].LUT[x]->y);
-
-       if (err == MP_OKAY)
-         /* free z */
-         mp_clear(fp_cache[idx].LUT[x]->z);
-   }
-   mp_clear(&tmp);
-
-   if (err == MP_OKAY)
-     return MP_OKAY;
-
-   /* err cleanup */
-   for (y = 0; y < (1U< mp_unsigned_bin_size(modulus)) {
-      mp_int order;
-      if (mp_init(&order) != MP_OKAY) {
-        mp_clear(&tk);
-        return MP_INIT_E;
-      }
-
-      /* find order */
-      y = mp_unsigned_bin_size(modulus);
-      for (x = 0; ecc_sets[x].size; x++) {
-         if (y <= (unsigned)ecc_sets[x].size) break;
-      }
-   
-      /* back off if we are on the 521 bit curve */
-      if (y == 66) --x;
-      
-      if ((err = mp_read_radix(&order, ecc_sets[x].order, 16)) != MP_OKAY) {
-         mp_clear(&order);
-         mp_clear(&tk);
-         return err;
-      }
-
-      /* k must be less than modulus */
-      if (mp_cmp(k, &order) != MP_LT) {
-         if ((err = mp_mod(k, &order, &tk)) != MP_OKAY) {
-            mp_clear(&tk);
-            mp_clear(&order);
-            return err;
-         }
-      } else {
-         mp_copy(k, &tk);
-      }
-      mp_clear(&order);
-   } else {
-      mp_copy(k, &tk);
-   }       
-   
-   /* get bitlen and round up to next multiple of FP_LUT */
-   bitlen  = mp_unsigned_bin_size(modulus) << 3;
-   x       = bitlen % FP_LUT;
-   if (x) {
-      bitlen += FP_LUT - x;
-   }  
-   lut_gap = bitlen / FP_LUT;
-        
-   /* get the k value */
-   if (mp_unsigned_bin_size(&tk) > (int)(KB_SIZE - 2)) {
-      mp_clear(&tk);
-      return BUFFER_E;
-   }
-   
-   /* store k */
-#ifdef WOLFSSL_SMALL_STACK
-   kb = (unsigned char*)XMALLOC(KB_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-   if (kb == NULL)
-      return MEMORY_E;
-#endif
-
-   XMEMSET(kb, 0, KB_SIZE);
-   if ((err = mp_to_unsigned_bin(&tk, kb)) != MP_OKAY) {
-      mp_clear(&tk);
-   }
-   else {
-      /* let's reverse kb so it's little endian */
-      x = 0;
-      y = mp_unsigned_bin_size(&tk) - 1;
-      mp_clear(&tk);
-
-      while ((unsigned)x < y) {
-         z = kb[x]; kb[x] = kb[y]; kb[y] = z;
-         ++x; --y;
-      }
-
-      /* at this point we can start, yipee */
-      first = 1;
-      for (x = lut_gap-1; x >= 0; x--) {
-          /* extract FP_LUT bits from kb spread out by lut_gap bits and offset
-             by x bits from the start */
-          bitpos = x;
-          for (y = z = 0; y < FP_LUT; y++) {
-             z |= ((kb[bitpos>>3] >> (bitpos&7)) & 1) << y;
-             bitpos += lut_gap;  /* it's y*lut_gap + x, but here we can avoid
-                                    the mult in each loop */
-          }
-
-          /* double if not first */
-          if (!first) {
-             if ((err = ecc_projective_dbl_point(R, R, modulus,
-                                                              mp)) != MP_OKAY) {
-                break;
-             }
-          }
-
-          /* add if not first, otherwise copy */
-          if (!first && z) {
-             if ((err = ecc_projective_add_point(R, fp_cache[idx].LUT[z], R,
-                                                     modulus, mp)) != MP_OKAY) {
-                break;
-             }
-          } else if (z) {
-             if ((mp_copy(fp_cache[idx].LUT[z]->x, R->x) != MP_OKAY) ||
-                 (mp_copy(fp_cache[idx].LUT[z]->y, R->y) != MP_OKAY) ||
-                 (mp_copy(&fp_cache[idx].mu,       R->z) != MP_OKAY)) {
-                 err = GEN_MEM_ERR;
-                 break;
-             }
-                 first = 0;
-          }
-      }
-   }
-
-   if (err == MP_OKAY) {
-      z = 0;
-      ForceZero(kb, KB_SIZE);
-      /* map R back from projective space */
-      if (map) {
-         err = ecc_map(R, modulus, mp);
-      } else {
-         err = MP_OKAY;
-      }
-   }
-
-#ifdef WOLFSSL_SMALL_STACK
-   XFREE(kb, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-#undef KB_SIZE
-
-   return err;
-}
-
-#ifdef ECC_SHAMIR
-/* perform a fixed point ECC mulmod */
-static int accel_fp_mul2add(int idx1, int idx2, 
-                            mp_int* kA, mp_int* kB,
-                            ecc_point *R, mp_int* modulus, mp_digit* mp)
-{
-#define KB_SIZE 128
-
-#ifdef WOLFSSL_SMALL_STACK
-   unsigned char* kb[2];
-#else
-   unsigned char kb[2][128];
-#endif
-   int      x;
-   unsigned y, z, err, bitlen, bitpos, lut_gap, first, zA, zB;
-   mp_int tka;
-   mp_int tkb;
-   mp_int order;
-
-   if (mp_init_multi(&tka, &tkb, 0, 0, 0, 0) != MP_OKAY)
-       return MP_INIT_E;
-
-   /* if it's smaller than modulus we fine */
-   if (mp_unsigned_bin_size(kA) > mp_unsigned_bin_size(modulus)) {
-      /* find order */
-      y = mp_unsigned_bin_size(modulus);
-      for (x = 0; ecc_sets[x].size; x++) {
-         if (y <= (unsigned)ecc_sets[x].size) break;
-      }
-   
-      /* back off if we are on the 521 bit curve */
-      if (y == 66) --x;
-      
-      if ((err = mp_init(&order)) != MP_OKAY) {
-         mp_clear(&tkb);
-         mp_clear(&tka);
-         return err;
-      }      
-      if ((err = mp_read_radix(&order, ecc_sets[x].order, 16)) != MP_OKAY) {
-         mp_clear(&tkb);
-         mp_clear(&tka);
-         mp_clear(&order);
-         return err;
-      }
-
-      /* kA must be less than modulus */
-      if (mp_cmp(kA, &order) != MP_LT) {
-         if ((err = mp_mod(kA, &order, &tka)) != MP_OKAY) {
-            mp_clear(&tkb);
-            mp_clear(&tka);
-            mp_clear(&order);
-            return err;
-         }
-      } else {
-         mp_copy(kA, &tka);
-      }
-      mp_clear(&order);
-   } else {
-      mp_copy(kA, &tka);
-   }       
-
-   /* if it's smaller than modulus we fine */
-   if (mp_unsigned_bin_size(kB) > mp_unsigned_bin_size(modulus)) {
-      /* find order */
-      y = mp_unsigned_bin_size(modulus);
-      for (x = 0; ecc_sets[x].size; x++) {
-         if (y <= (unsigned)ecc_sets[x].size) break;
-      }
-   
-      /* back off if we are on the 521 bit curve */
-      if (y == 66) --x;
-      
-      if ((err = mp_init(&order)) != MP_OKAY) {
-         mp_clear(&tkb);
-         mp_clear(&tka);
-         return err;
-      }      
-      if ((err = mp_read_radix(&order, ecc_sets[x].order, 16)) != MP_OKAY) {
-         mp_clear(&tkb);
-         mp_clear(&tka);
-         mp_clear(&order);
-         return err;
-      }
-
-      /* kB must be less than modulus */
-      if (mp_cmp(kB, &order) != MP_LT) {
-         if ((err = mp_mod(kB, &order, &tkb)) != MP_OKAY) {
-            mp_clear(&tkb);
-            mp_clear(&tka);
-            mp_clear(&order);
-            return err;
-         }
-      } else {
-         mp_copy(kB, &tkb);
-      }
-      mp_clear(&order);
-   } else {
-      mp_copy(kB, &tkb);
-   }     
-
-   /* get bitlen and round up to next multiple of FP_LUT */
-   bitlen  = mp_unsigned_bin_size(modulus) << 3;
-   x       = bitlen % FP_LUT;
-   if (x) {
-      bitlen += FP_LUT - x;
-   }  
-   lut_gap = bitlen / FP_LUT;
-        
-   /* get the k value */
-   if ((mp_unsigned_bin_size(&tka) > (int)(KB_SIZE - 2)) ||
-       (mp_unsigned_bin_size(&tkb) > (int)(KB_SIZE - 2))  ) {
-      mp_clear(&tka);
-      mp_clear(&tkb);
-      return BUFFER_E;
-   }
-   
-   /* store k */
-#ifdef WOLFSSL_SMALL_STACK
-   kb[0] = (unsigned char*)XMALLOC(KB_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-   if (kb[0] == NULL)
-      return MEMORY_E;
-#endif
-
-   XMEMSET(kb[0], 0, KB_SIZE);
-   if ((err = mp_to_unsigned_bin(&tka, kb[0])) != MP_OKAY) {
-      mp_clear(&tka);
-      mp_clear(&tkb);
-      XFREE(kb[0], NULL, DYNAMIC_TYPE_TMP_BUFFER);
-      return err;
-   }
-   
-   /* let's reverse kb so it's little endian */
-   x = 0;
-   y = mp_unsigned_bin_size(&tka) - 1;
-   mp_clear(&tka);
-   while ((unsigned)x < y) {
-      z = kb[0][x]; kb[0][x] = kb[0][y]; kb[0][y] = z;
-      ++x; --y;
-   }      
-   
-   /* store b */
-#ifdef WOLFSSL_SMALL_STACK
-   kb[1] = (unsigned char*)XMALLOC(KB_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-   if (kb[1] == NULL) {
-      XFREE(kb[0], NULL, DYNAMIC_TYPE_TMP_BUFFER);
-      return MEMORY_E;
-   }
-#endif
-
-   XMEMSET(kb[1], 0, KB_SIZE);
-   if ((err = mp_to_unsigned_bin(&tkb, kb[1])) != MP_OKAY) {
-      mp_clear(&tkb);
-   }
-   else {
-      x = 0;
-      y = mp_unsigned_bin_size(&tkb) - 1;
-      mp_clear(&tkb);
-      while ((unsigned)x < y) {
-         z = kb[1][x]; kb[1][x] = kb[1][y]; kb[1][y] = z;
-         ++x; --y;
-      }
-
-      /* at this point we can start, yipee */
-      first = 1;
-      for (x = lut_gap-1; x >= 0; x--) {
-          /* extract FP_LUT bits from kb spread out by lut_gap bits and
-             offset by x bits from the start */
-          bitpos = x;
-          for (y = zA = zB = 0; y < FP_LUT; y++) {
-             zA |= ((kb[0][bitpos>>3] >> (bitpos&7)) & 1) << y;
-             zB |= ((kb[1][bitpos>>3] >> (bitpos&7)) & 1) << y;
-             bitpos += lut_gap;    /* it's y*lut_gap + x, but here we can avoid
-                                      the mult in each loop */
-          }
-
-          /* double if not first */
-          if (!first) {
-             if ((err = ecc_projective_dbl_point(R, R, modulus,
-                                                              mp)) != MP_OKAY) {
-                break;
-             }
-          }
-
-          /* add if not first, otherwise copy */
-          if (!first) {
-             if (zA) {
-                if ((err = ecc_projective_add_point(R, fp_cache[idx1].LUT[zA],
-                                                  R, modulus, mp)) != MP_OKAY) {
-                   break;
-                }
-             }
-             if (zB) {
-                if ((err = ecc_projective_add_point(R, fp_cache[idx2].LUT[zB],
-                                                  R, modulus, mp)) != MP_OKAY) {
-                   break;
-                }
-             }
-          } else {
-             if (zA) {
-                 if ((mp_copy(fp_cache[idx1].LUT[zA]->x, R->x) != MP_OKAY) ||
-                    (mp_copy(fp_cache[idx1].LUT[zA]->y,  R->y) != MP_OKAY) ||
-                    (mp_copy(&fp_cache[idx1].mu,         R->z) != MP_OKAY)) {
-                     err = GEN_MEM_ERR;
-                     break;
-                 }
-                    first = 0;
-             }
-             if (zB && first == 0) {
-                if (zB) {
-                   if ((err = ecc_projective_add_point(R,
-                           fp_cache[idx2].LUT[zB], R, modulus, mp)) != MP_OKAY){
-                      break;
-                   }
-                }
-             } else if (zB && first == 1) {
-                 if ((mp_copy(fp_cache[idx2].LUT[zB]->x, R->x) != MP_OKAY) ||
-                    (mp_copy(fp_cache[idx2].LUT[zB]->y, R->y) != MP_OKAY) ||
-                    (mp_copy(&fp_cache[idx2].mu,        R->z) != MP_OKAY)) {
-                     err = GEN_MEM_ERR;
-                     break;
-                 }
-                    first = 0;
-             }
-          }
-      }
-   }
-
-   ForceZero(kb[0], KB_SIZE);
-   ForceZero(kb[1], KB_SIZE);
-
-#ifdef WOLFSSL_SMALL_STACK
-   XFREE(kb[0], NULL, DYNAMIC_TYPE_TMP_BUFFER);
-   XFREE(kb[1], NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-#undef KB_SIZE
-
-   return ecc_map(R, modulus, mp);
-}
-
-/** ECC Fixed Point mulmod global
-  Computes kA*A + kB*B = C using Shamir's Trick
-  A        First point to multiply
-  kA       What to multiple A by
-  B        Second point to multiply
-  kB       What to multiple B by
-  C        [out] Destination point (can overlap with A or B)
-  modulus  Modulus for curve 
-  return MP_OKAY on success
-*/ 
-int ecc_mul2add(ecc_point* A, mp_int* kA,
-                ecc_point* B, mp_int* kB,
-                ecc_point* C, mp_int* modulus)
-{
-   int  idx1 = -1, idx2 = -1, err = MP_OKAY, mpInit = 0;
-   mp_digit mp;
-   mp_int   mu;
-  
-   err = mp_init(&mu);
-   if (err != MP_OKAY)
-       return err;
-
-#ifndef HAVE_THREAD_LS
-   if (initMutex == 0) {
-        InitMutex(&ecc_fp_lock);
-        initMutex = 1;
-   }
-   if (LockMutex(&ecc_fp_lock) != 0)
-      return BAD_MUTEX_E;
-#endif /* HAVE_THREAD_LS */
-
-      /* find point */
-      idx1 = find_base(A);
-
-      /* no entry? */
-      if (idx1 == -1) {
-         /* find hole and add it */
-         if ((idx1 = find_hole()) >= 0) {
-            err = add_entry(idx1, A);
-         }
-      }
-      if (err == MP_OKAY && idx1 != -1) {
-         /* increment LRU */
-         ++(fp_cache[idx1].lru_count);
-      }
-
-      if (err == MP_OKAY)
-        /* find point */
-        idx2 = find_base(B);
-
-      if (err == MP_OKAY) {
-        /* no entry? */
-        if (idx2 == -1) {
-           /* find hole and add it */
-           if ((idx2 = find_hole()) >= 0)
-              err = add_entry(idx2, B);
-         }
-      }
-
-      if (err == MP_OKAY && idx2 != -1) {
-         /* increment LRU */
-         ++(fp_cache[idx2].lru_count);
-      }
-
-      if (err == MP_OKAY) {
-        /* if it's 2 build the LUT, if it's higher just use the LUT */
-        if (idx1 >= 0 && fp_cache[idx1].lru_count == 2) {
-           /* compute mp */
-           err = mp_montgomery_setup(modulus, &mp);
-
-           if (err == MP_OKAY) {
-             mpInit = 1;
-             err = mp_montgomery_calc_normalization(&mu, modulus);
-           }
-                 
-           if (err == MP_OKAY)
-             /* build the LUT */
-               err = build_lut(idx1, modulus, &mp, &mu);
-        }
-      }
-
-      if (err == MP_OKAY) {
-        /* if it's 2 build the LUT, if it's higher just use the LUT */
-        if (idx2 >= 0 && fp_cache[idx2].lru_count == 2) {
-           if (mpInit == 0) {
-                /* compute mp */
-                err = mp_montgomery_setup(modulus, &mp);
-                if (err == MP_OKAY) {
-                    mpInit = 1;
-                    err = mp_montgomery_calc_normalization(&mu, modulus);
-                }
-            }
-                 
-            if (err == MP_OKAY) 
-            /* build the LUT */
-              err = build_lut(idx2, modulus, &mp, &mu);
-        }
-      }
-
-
-      if (err == MP_OKAY) {
-        if (idx1 >=0 && idx2 >= 0 && fp_cache[idx1].lru_count >= 2 &&
-                                     fp_cache[idx2].lru_count >= 2) {
-           if (mpInit == 0) {
-              /* compute mp */
-              err = mp_montgomery_setup(modulus, &mp);
-           }
-           if (err == MP_OKAY)
-             err = accel_fp_mul2add(idx1, idx2, kA, kB, C, modulus, &mp);
-        } else {
-           err = normal_ecc_mul2add(A, kA, B, kB, C, modulus);
-        }
-    }
-
-#ifndef HAVE_THREAD_LS
-    UnLockMutex(&ecc_fp_lock);
-#endif /* HAVE_THREAD_LS */
-    mp_clear(&mu);
-
-    return err;
-}
-#endif
-
-/** ECC Fixed Point mulmod global
-    k        The multiplicand
-    G        Base point to multiply
-    R        [out] Destination of product
-    modulus  The modulus for the curve
-    map      [boolean] If non-zero maps the point back to affine co-ordinates,
-             otherwise it's left in jacobian-montgomery form
-    return MP_OKAY if successful
-*/   
-int ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R, mp_int* modulus,
-               int map)
-{
-   int   idx, err = MP_OKAY;
-   mp_digit mp;
-   mp_int   mu;
-   int      mpSetup = 0;
-
-   if (mp_init(&mu) != MP_OKAY)
-       return MP_INIT_E;
-   
-#ifndef HAVE_THREAD_LS
-   if (initMutex == 0) {
-        InitMutex(&ecc_fp_lock);
-        initMutex = 1;
-   }
-   
-   if (LockMutex(&ecc_fp_lock) != 0)
-      return BAD_MUTEX_E;
-#endif /* HAVE_THREAD_LS */
-
-      /* find point */
-      idx = find_base(G);
-
-      /* no entry? */
-      if (idx == -1) {
-         /* find hole and add it */
-         idx = find_hole();
-
-         if (idx >= 0)
-            err = add_entry(idx, G);
-      }
-      if (err == MP_OKAY && idx >= 0) {
-         /* increment LRU */
-         ++(fp_cache[idx].lru_count);
-      }
-
-
-      if (err == MP_OKAY) { 
-        /* if it's 2 build the LUT, if it's higher just use the LUT */
-        if (idx >= 0 && fp_cache[idx].lru_count == 2) {
-           /* compute mp */
-           err = mp_montgomery_setup(modulus, &mp);
-
-           if (err == MP_OKAY) {
-             /* compute mu */
-             mpSetup = 1;
-             err = mp_montgomery_calc_normalization(&mu, modulus);
-           }
-                 
-           if (err == MP_OKAY) 
-             /* build the LUT */
-             err = build_lut(idx, modulus, &mp, &mu);
-        }
-      }
-
-      if (err == MP_OKAY) { 
-        if (idx >= 0 && fp_cache[idx].lru_count >= 2) {
-           if (mpSetup == 0) {
-              /* compute mp */
-              err = mp_montgomery_setup(modulus, &mp);
-           }
-           if (err == MP_OKAY)
-             err = accel_fp_mul(idx, k, R, modulus, &mp, map);
-        } else {
-           err = normal_ecc_mulmod(k, G, R, modulus, map);
-        }
-     }
-
-#ifndef HAVE_THREAD_LS
-    UnLockMutex(&ecc_fp_lock);
-#endif /* HAVE_THREAD_LS */
-    mp_clear(&mu);
-
-    return err;
-}
-
-/* helper function for freeing the cache ...
-   must be called with the cache mutex locked */
-static void wc_ecc_fp_free_cache(void)
-{
-   unsigned x, y;
-   for (x = 0; x < FP_ENTRIES; x++) {
-      if (fp_cache[x].g != NULL) {
-         for (y = 0; y < (1U<protocol == 0)
-        return NULL;
-
-    if (ctx->protocol == REQ_RESP_CLIENT) {
-        if (ctx->cliSt == ecCLI_INIT) {
-            ctx->cliSt =  ecCLI_SALT_GET;
-            return ctx->clientSalt;
-        }
-        else {
-            ctx->cliSt = ecCLI_BAD_STATE;
-            return NULL;
-        }
-    }
-    else if (ctx->protocol == REQ_RESP_SERVER) {
-        if (ctx->srvSt == ecSRV_INIT) {
-            ctx->srvSt =  ecSRV_SALT_GET;
-            return ctx->serverSalt;
-        }
-        else {
-            ctx->srvSt = ecSRV_BAD_STATE;
-            return NULL;
-        }
-    }
-
-    return NULL;
-}
-
-
-/* optional set info, can be called before or after set_peer_salt */
-int wc_ecc_ctx_set_info(ecEncCtx* ctx, const byte* info, int sz)
-{
-    if (ctx == NULL || info == 0 || sz < 0)
-        return BAD_FUNC_ARG;
-
-    ctx->kdfInfo   = info;
-    ctx->kdfInfoSz = sz;
-
-    return 0;
-}
-
-
-static const char* exchange_info = "Secure Message Exchange";
-
-int wc_ecc_ctx_set_peer_salt(ecEncCtx* ctx, const byte* salt)
-{
-    byte tmp[EXCHANGE_SALT_SZ/2];
-    int  halfSz = EXCHANGE_SALT_SZ/2;
-
-    if (ctx == NULL || ctx->protocol == 0 || salt == NULL)
-        return BAD_FUNC_ARG;
-
-    if (ctx->protocol == REQ_RESP_CLIENT) {
-        XMEMCPY(ctx->serverSalt, salt, EXCHANGE_SALT_SZ);
-        if (ctx->cliSt == ecCLI_SALT_GET)
-            ctx->cliSt =  ecCLI_SALT_SET;
-        else {
-            ctx->cliSt =  ecCLI_BAD_STATE;
-            return BAD_ENC_STATE_E;
-        }
-    }
-    else {
-        XMEMCPY(ctx->clientSalt, salt, EXCHANGE_SALT_SZ);
-        if (ctx->srvSt == ecSRV_SALT_GET)
-            ctx->srvSt =  ecSRV_SALT_SET;
-        else {
-            ctx->srvSt =  ecSRV_BAD_STATE;
-            return BAD_ENC_STATE_E;
-        }
-    }
-
-    /* mix half and half */
-    /* tmp stores 2nd half of client before overwrite */
-    XMEMCPY(tmp, ctx->clientSalt + halfSz, halfSz);
-    XMEMCPY(ctx->clientSalt + halfSz, ctx->serverSalt, halfSz);
-    XMEMCPY(ctx->serverSalt, tmp, halfSz);
-
-    ctx->kdfSalt   = ctx->clientSalt;
-    ctx->kdfSaltSz = EXCHANGE_SALT_SZ;
-
-    ctx->macSalt   = ctx->serverSalt;
-    ctx->macSaltSz = EXCHANGE_SALT_SZ;
-
-    if (ctx->kdfInfo == NULL) {
-        /* default info */
-        ctx->kdfInfo   = (const byte*)exchange_info;
-        ctx->kdfInfoSz = EXCHANGE_INFO_SZ;
-    }
-
-    return 0;
-}
-
-
-static int ecc_ctx_set_salt(ecEncCtx* ctx, int flags, RNG* rng)
-{
-    byte* saltBuffer = NULL;
-
-    if (ctx == NULL || rng == NULL || flags == 0) 
-        return BAD_FUNC_ARG;
-
-    saltBuffer = (flags == REQ_RESP_CLIENT) ? ctx->clientSalt : ctx->serverSalt;
-
-    return wc_RNG_GenerateBlock(rng, saltBuffer, EXCHANGE_SALT_SZ);
-}
-
-
-static void ecc_ctx_init(ecEncCtx* ctx, int flags)
-{
-    if (ctx) {
-        XMEMSET(ctx, 0, sizeof(ecEncCtx));
-
-        ctx->encAlgo  = ecAES_128_CBC;
-        ctx->kdfAlgo  = ecHKDF_SHA256;
-        ctx->macAlgo  = ecHMAC_SHA256;
-        ctx->protocol = (byte)flags;
-
-        if (flags == REQ_RESP_CLIENT)
-            ctx->cliSt = ecCLI_INIT;
-        if (flags == REQ_RESP_SERVER)
-            ctx->srvSt = ecSRV_INIT;
-    }
-}
-
-
-/* allow ecc context reset so user doesn't have to init/free for resue */
-int wc_ecc_ctx_reset(ecEncCtx* ctx, RNG* rng)
-{
-    if (ctx == NULL || rng == NULL)
-        return BAD_FUNC_ARG;
-
-    ecc_ctx_init(ctx, ctx->protocol);
-    return ecc_ctx_set_salt(ctx, ctx->protocol, rng);
-}
-
-
-/* alloc/init and set defaults, return new Context  */
-ecEncCtx* wc_ecc_ctx_new(int flags, RNG* rng)
-{
-    int       ret = 0;
-    ecEncCtx* ctx = (ecEncCtx*)XMALLOC(sizeof(ecEncCtx), 0, DYNAMIC_TYPE_ECC);
-
-    if (ctx)
-        ctx->protocol = (byte)flags;
-
-    ret = wc_ecc_ctx_reset(ctx, rng);
-    if (ret != 0) {
-        wc_ecc_ctx_free(ctx);
-        ctx = NULL;
-    }
-
-    return ctx;
-}
-
-
-/* free any resources, clear any keys */
-void wc_ecc_ctx_free(ecEncCtx* ctx)
-{
-    if (ctx) {
-        ForceZero(ctx, sizeof(ecEncCtx));
-        XFREE(ctx, 0, DYNAMIC_TYPE_ECC);
-    }
-}
-
-
-static int ecc_get_key_sizes(ecEncCtx* ctx, int* encKeySz, int* ivSz,
-                             int* keysLen, word32* digestSz, word32* blockSz)
-{
-    if (ctx) {
-        switch (ctx->encAlgo) {
-            case ecAES_128_CBC:
-                *encKeySz = KEY_SIZE_128;
-                *ivSz     = IV_SIZE_64;
-                *blockSz  = AES_BLOCK_SIZE;
-                break;
-            default:
-                return BAD_FUNC_ARG;
-        }
-
-        switch (ctx->macAlgo) {
-            case ecHMAC_SHA256:
-                *digestSz = SHA256_DIGEST_SIZE;
-                break;
-            default:
-                return BAD_FUNC_ARG;
-        }
-    } else
-        return BAD_FUNC_ARG;
-
-    *keysLen  = *encKeySz + *ivSz + *digestSz;
-
-    return 0;
-}
-
-
-/* ecc encrypt with shared secret run through kdf
-   ctx holds non default algos and inputs
-   msgSz should be the right size for encAlgo, i.e., already padded 
-   return 0 on success */
-int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
-                word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx)
-{
-    int          ret;
-    word32       blockSz;
-    word32       digestSz;
-    ecEncCtx     localCtx;
-#ifdef WOLFSSL_SMALL_STACK
-    byte*        sharedSecret;
-    byte*        keys;
-#else
-    byte         sharedSecret[ECC_MAXSIZE];  /* 521 max size */
-    byte         keys[ECC_BUFSIZE];         /* max size */
-#endif
-    word32       sharedSz = ECC_MAXSIZE;
-    int          keysLen;
-    int          encKeySz;
-    int          ivSz;
-    int          offset = 0;         /* keys offset if doing msg exchange */
-    byte*        encKey;
-    byte*        encIv;
-    byte*        macKey;
-
-    if (privKey == NULL || pubKey == NULL || msg == NULL || out == NULL ||
-                           outSz  == NULL)
-        return BAD_FUNC_ARG;
-
-    if (ctx == NULL) {  /* use defaults */
-        ecc_ctx_init(&localCtx, 0);
-        ctx = &localCtx;  
-    }
-        
-    ret = ecc_get_key_sizes(ctx, &encKeySz, &ivSz, &keysLen, &digestSz,
-                            &blockSz);
-    if (ret != 0)
-        return ret;
-
-    if (ctx->protocol == REQ_RESP_SERVER) {
-        offset = keysLen;
-        keysLen *= 2;
-
-        if (ctx->srvSt != ecSRV_RECV_REQ)
-            return BAD_ENC_STATE_E;
-
-        ctx->srvSt = ecSRV_BAD_STATE; /* we're done no more ops allowed */
-    }
-    else if (ctx->protocol == REQ_RESP_CLIENT) {
-        if (ctx->cliSt != ecCLI_SALT_SET)
-            return BAD_ENC_STATE_E;
-
-        ctx->cliSt = ecCLI_SENT_REQ; /* only do this once */
-    }
-        
-    if (keysLen > ECC_BUFSIZE) /* keys size */
-        return BUFFER_E;
-        
-    if ( (msgSz%blockSz) != 0)
-        return BAD_PADDING_E;
-
-    if (*outSz < (msgSz + digestSz))
-        return BUFFER_E;
-
-#ifdef WOLFSSL_SMALL_STACK
-    sharedSecret = (byte*)XMALLOC(ECC_MAXSIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (sharedSecret == NULL)
-        return MEMORY_E;
-
-    keys = (byte*)XMALLOC(ECC_BUFSIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (keys == NULL) {
-        XFREE(sharedSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#endif
-
-    ret = wc_ecc_shared_secret(privKey, pubKey, sharedSecret, &sharedSz);
-
-    if (ret == 0) {
-       switch (ctx->kdfAlgo) {
-           case ecHKDF_SHA256 :
-               ret = wc_HKDF(SHA256, sharedSecret, sharedSz, ctx->kdfSalt,
-                          ctx->kdfSaltSz, ctx->kdfInfo, ctx->kdfInfoSz,
-                          keys, keysLen);
-               break;
-
-           default:
-               ret = BAD_FUNC_ARG;
-               break;
-       }
-    }
-
-    if (ret == 0) {
-       encKey = keys + offset;
-       encIv  = encKey + encKeySz;
-       macKey = encKey + encKeySz + ivSz;
-
-       switch (ctx->encAlgo) {
-           case ecAES_128_CBC:
-               {
-                   Aes aes;
-                   ret = wc_AesSetKey(&aes, encKey, KEY_SIZE_128, encIv,
-                                                                AES_ENCRYPTION);
-                   if (ret != 0)
-                       break;
-                   ret = wc_AesCbcEncrypt(&aes, out, msg, msgSz);
-               }
-               break;
-
-           default:
-               ret = BAD_FUNC_ARG;
-               break;
-       }
-    }
-
-    if (ret == 0) {
-       switch (ctx->macAlgo) {
-           case ecHMAC_SHA256:
-               {
-                   Hmac hmac;
-                   ret = wc_HmacSetKey(&hmac, SHA256, macKey, SHA256_DIGEST_SIZE);
-                   if (ret != 0)
-                       break;
-                   ret = wc_HmacUpdate(&hmac, out, msgSz);
-                   if (ret != 0)
-                       break;
-                   ret = wc_HmacUpdate(&hmac, ctx->macSalt, ctx->macSaltSz);
-                   if (ret != 0)
-                       break;
-                   ret = wc_HmacFinal(&hmac, out+msgSz);
-               }
-               break;
-
-           default:
-               ret = BAD_FUNC_ARG;
-               break;
-       }
-    }
-
-    if (ret == 0)
-       *outSz = msgSz + digestSz;
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(sharedSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(keys, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-/* ecc decrypt with shared secret run through kdf
-   ctx holds non default algos and inputs
-   return 0 on success */
-int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
-                word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx)
-{
-    int          ret;
-    word32       blockSz;
-    word32       digestSz;
-    ecEncCtx     localCtx;
-#ifdef WOLFSSL_SMALL_STACK
-    byte*        sharedSecret;
-    byte*        keys;
-#else
-    byte         sharedSecret[ECC_MAXSIZE];  /* 521 max size */
-    byte         keys[ECC_BUFSIZE];         /* max size */
-#endif
-    word32       sharedSz = ECC_MAXSIZE;
-    int          keysLen;
-    int          encKeySz;
-    int          ivSz;
-    int          offset = 0;       /* in case using msg exchange */
-    byte*        encKey;
-    byte*        encIv;
-    byte*        macKey;
-
-    if (privKey == NULL || pubKey == NULL || msg == NULL || out == NULL ||
-                           outSz  == NULL)
-        return BAD_FUNC_ARG;
-
-    if (ctx == NULL) {  /* use defaults */
-        ecc_ctx_init(&localCtx, 0);
-        ctx = &localCtx;  
-    }
-        
-    ret = ecc_get_key_sizes(ctx, &encKeySz, &ivSz, &keysLen, &digestSz,
-                            &blockSz);
-    if (ret != 0)
-        return ret;
-        
-    if (ctx->protocol == REQ_RESP_CLIENT) {
-        offset = keysLen;
-        keysLen *= 2;
-
-        if (ctx->cliSt != ecCLI_SENT_REQ)
-            return BAD_ENC_STATE_E;
-
-        ctx->cliSt = ecSRV_BAD_STATE; /* we're done no more ops allowed */
-    }
-    else if (ctx->protocol == REQ_RESP_SERVER) {
-        if (ctx->srvSt != ecSRV_SALT_SET)
-            return BAD_ENC_STATE_E;
-
-        ctx->srvSt = ecSRV_RECV_REQ; /* only do this once */
-    }
-        
-    if (keysLen > ECC_BUFSIZE) /* keys size */
-        return BUFFER_E;
-        
-    if ( ((msgSz-digestSz) % blockSz) != 0)
-        return BAD_PADDING_E;
-
-    if (*outSz < (msgSz - digestSz))
-        return BUFFER_E;
-
-#ifdef WOLFSSL_SMALL_STACK
-    sharedSecret = (byte*)XMALLOC(ECC_MAXSIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (sharedSecret == NULL)
-        return MEMORY_E;
-
-    keys = (byte*)XMALLOC(ECC_BUFSIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (keys == NULL) {
-        XFREE(sharedSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#endif
-
-    ret = wc_ecc_shared_secret(privKey, pubKey, sharedSecret, &sharedSz);
-
-    if (ret == 0) {
-       switch (ctx->kdfAlgo) {
-           case ecHKDF_SHA256 :
-               ret = wc_HKDF(SHA256, sharedSecret, sharedSz, ctx->kdfSalt,
-                          ctx->kdfSaltSz, ctx->kdfInfo, ctx->kdfInfoSz,
-                          keys, keysLen);
-               break;
-
-           default:
-               ret = BAD_FUNC_ARG;
-               break;
-       }
-    }
-
-    if (ret == 0) {
-       encKey = keys + offset;
-       encIv  = encKey + encKeySz;
-       macKey = encKey + encKeySz + ivSz;
-
-       switch (ctx->macAlgo) {
-           case ecHMAC_SHA256:
-               {
-                   byte verify[SHA256_DIGEST_SIZE];
-                   Hmac hmac;
-                   ret = wc_HmacSetKey(&hmac, SHA256, macKey, SHA256_DIGEST_SIZE);
-                   if (ret != 0)
-                       break;
-                   ret = wc_HmacUpdate(&hmac, msg, msgSz-digestSz);
-                   if (ret != 0)
-                       break;
-                   ret = wc_HmacUpdate(&hmac, ctx->macSalt, ctx->macSaltSz);
-                   if (ret != 0)
-                       break;
-                   ret = wc_HmacFinal(&hmac, verify);
-                   if (ret != 0)
-                       break;
-                   if (memcmp(verify, msg + msgSz - digestSz, digestSz) != 0)
-                       ret = -1;
-               }
-               break;
-
-           default:
-               ret = BAD_FUNC_ARG;
-               break;
-       }
-    }
-
-    if (ret == 0) {
-       switch (ctx->encAlgo) {
-           case ecAES_128_CBC:
-               {
-                   Aes aes;
-                   ret = wc_AesSetKey(&aes, encKey, KEY_SIZE_128, encIv,
-                                                                AES_DECRYPTION);
-                   if (ret != 0)
-                       break;
-                   ret = wc_AesCbcDecrypt(&aes, out, msg, msgSz-digestSz);
-               }
-               break;
-
-           default:
-               ret = BAD_FUNC_ARG;
-               break;
-       }
-    }
-
-    if (ret == 0)
-       *outSz = msgSz - digestSz;
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(sharedSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(keys, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-
-#endif /* HAVE_ECC_ENCRYPT */
-
-
-#ifdef HAVE_COMP_KEY
-
-/* computes the jacobi c = (a | n) (or Legendre if n is prime)
- * HAC pp. 73 Algorithm 2.149
- */
-int mp_jacobi(mp_int* a, mp_int* p, int* c)
-{
-  mp_int   a1, p1;
-  int      k, s, r, res;
-  mp_digit residue;
-
-  /* if p <= 0 return MP_VAL */
-  if (mp_cmp_d(p, 0) != MP_GT) {
-     return MP_VAL;
-  }
-
-  /* step 1.  if a == 0, return 0 */
-  if (mp_iszero (a) == 1) {
-    *c = 0;
-    return MP_OKAY;
-  }
-
-  /* step 2.  if a == 1, return 1 */
-  if (mp_cmp_d (a, 1) == MP_EQ) {
-    *c = 1;
-    return MP_OKAY;
-  }
-
-  /* default */
-  s = 0;
-
-  /* step 3.  write a = a1 * 2**k  */
-  if ((res = mp_init_copy (&a1, a)) != MP_OKAY) {
-    return res;
-  }
-
-  if ((res = mp_init (&p1)) != MP_OKAY) {
-    mp_clear(&a1);
-    return res;
-  }
-
-  /* divide out larger power of two */
-  k = mp_cnt_lsb(&a1);
-  res = mp_div_2d(&a1, k, &a1, NULL);
-
-  if (res == MP_OKAY) {
-    /* step 4.  if e is even set s=1 */
-    if ((k & 1) == 0) {
-      s = 1;
-    } else {
-      /* else set s=1 if p = 1/7 (mod 8) or s=-1 if p = 3/5 (mod 8) */
-      residue = p->dp[0] & 7;
-
-      if (residue == 1 || residue == 7) {
-        s = 1;
-      } else if (residue == 3 || residue == 5) {
-        s = -1;
-      }
-    }
-
-    /* step 5.  if p == 3 (mod 4) *and* a1 == 3 (mod 4) then s = -s */
-    if ( ((p->dp[0] & 3) == 3) && ((a1.dp[0] & 3) == 3)) {
-      s = -s;
-    }
-  }
-
-  if (res == MP_OKAY) {
-    /* if a1 == 1 we're done */
-    if (mp_cmp_d (&a1, 1) == MP_EQ) {
-      *c = s;
-    } else {
-      /* n1 = n mod a1 */
-      res = mp_mod (p, &a1, &p1);
-      if (res == MP_OKAY)
-        res = mp_jacobi (&p1, &a1, &r);
-
-      if (res == MP_OKAY)
-      *c = s * r;
-    }
-  }
-
-  /* done */
-  mp_clear (&p1);
-  mp_clear (&a1);
-
-  return res;
-}
-
-
-int mp_sqrtmod_prime(mp_int* n, mp_int* prime, mp_int* ret)
-{
-  int res, legendre, done = 0;
-  mp_int t1, C, Q, S, Z, M, T, R, two;
-  mp_digit i;
-
-  /* first handle the simple cases */
-  if (mp_cmp_d(n, 0) == MP_EQ) {
-    mp_zero(ret);
-    return MP_OKAY;
-  }
-  if (mp_cmp_d(prime, 2) == MP_EQ)       return MP_VAL; /* prime must be odd */
-  /* TAO removed
-  if ((res = mp_jacobi(n, prime, &legendre)) != MP_OKAY)      return res;
-  if (legendre == -1)  return MP_VAL; */ /* quadratic non-residue mod prime */
-
-  if ((res = mp_init_multi(&t1, &C, &Q, &S, &Z, &M)) != MP_OKAY)
-    return res;
-
-  if ((res = mp_init_multi(&T, &R, &two, NULL, NULL, NULL))
-                          != MP_OKAY) {
-    mp_clear(&t1); mp_clear(&C); mp_clear(&Q); mp_clear(&S); mp_clear(&Z);
-    mp_clear(&M);
-    return res;
-  }
-
-  /* SPECIAL CASE: if prime mod 4 == 3
-   * compute directly: res = n^(prime+1)/4 mod prime
-   * Handbook of Applied Cryptography algorithm 3.36
-   */
-  res = mp_mod_d(prime, 4, &i);
-  if (res == MP_OKAY && i == 3) {
-    res = mp_add_d(prime, 1, &t1);
-
-    if (res == MP_OKAY)
-      res = mp_div_2(&t1, &t1);
-    if (res == MP_OKAY)
-      res = mp_div_2(&t1, &t1);
-    if (res == MP_OKAY)
-      res = mp_exptmod(n, &t1, prime, ret);
-
-    done = 1;
-  }
-
-  /* NOW: TonelliShanks algorithm */
-
- if (res == MP_OKAY && done == 0) {
-
-   /* factor out powers of 2 from prime-1, defining Q and S
-    *                                      as: prime-1 = Q*2^S */
-    res = mp_copy(prime, &Q);
-    if (res == MP_OKAY)
-      res = mp_sub_d(&Q, 1, &Q);
-    /* Q = prime - 1 */
-    if (res == MP_OKAY)
-      mp_zero(&S);
-    /* S = 0 */
-    while (res == MP_OKAY && mp_iseven(&Q)) {
-      res = mp_div_2(&Q, &Q);
-      /* Q = Q / 2 */
-      if (res == MP_OKAY)
-        res = mp_add_d(&S, 1, &S);
-        /* S = S + 1 */
-    }
-
-    /* find a Z such that the Legendre symbol (Z|prime) == -1 */
-    if (res == MP_OKAY)
-      res = mp_set_int(&Z, 2);
-    /* Z = 2 */
-    while (res == MP_OKAY) {
-      res = mp_jacobi(&Z, prime, &legendre);
-      if (res == MP_OKAY && legendre == -1)
-        break;
-      if (res == MP_OKAY)
-        res = mp_add_d(&Z, 1, &Z);
-        /* Z = Z + 1 */
-    }
-
-    if (res == MP_OKAY)
-      res = mp_exptmod(&Z, &Q, prime, &C);
-      /* C = Z ^ Q mod prime */
-    if (res == MP_OKAY)
-      res = mp_add_d(&Q, 1, &t1);
-    if (res == MP_OKAY)
-      res = mp_div_2(&t1, &t1);
-      /* t1 = (Q + 1) / 2 */
-    if (res == MP_OKAY)
-      res = mp_exptmod(n, &t1, prime, &R);
-    /* R = n ^ ((Q + 1) / 2) mod prime */
-    if (res == MP_OKAY)
-      res = mp_exptmod(n, &Q, prime, &T);
-    /* T = n ^ Q mod prime */
-    if (res == MP_OKAY)
-      res = mp_copy(&S, &M);
-    /* M = S */
-    if (res == MP_OKAY)
-      res = mp_set_int(&two, 2);
-
-    while (res == MP_OKAY && done == 0) {
-      res = mp_copy(&T, &t1);
-      i = 0;
-      while (res == MP_OKAY) {
-        if (mp_cmp_d(&t1, 1) == MP_EQ)
-            break;
-        res = mp_exptmod(&t1, &two, prime, &t1);
-        if (res == MP_OKAY)
-          i++;
-      }
-      if (res == MP_OKAY && i == 0) {
-        mp_copy(&R, ret);
-        res = MP_OKAY;
-        done = 1;
-      }
-
-      if (done == 0) {
-        if (res == MP_OKAY)
-          res = mp_sub_d(&M, i, &t1);
-        if (res == MP_OKAY)
-          res = mp_sub_d(&t1, 1, &t1);
-        if (res == MP_OKAY)
-          res = mp_exptmod(&two, &t1, prime, &t1);
-        /* t1 = 2 ^ (M - i - 1) */
-        if (res == MP_OKAY)
-          res = mp_exptmod(&C, &t1, prime, &t1);
-        /* t1 = C ^ (2 ^ (M - i - 1)) mod prime */
-        if (res == MP_OKAY)
-          res = mp_sqrmod(&t1, prime, &C);
-        /* C = (t1 * t1) mod prime */
-        if (res == MP_OKAY)
-          res = mp_mulmod(&R, &t1, prime, &R);
-        /* R = (R * t1) mod prime */
-        if (res == MP_OKAY)
-          res = mp_mulmod(&T, &C, prime, &T);
-        /* T = (T * C) mod prime */
-        if (res == MP_OKAY)
-          mp_set(&M, i);
-        /* M = i */
-      }
-    }
-  }
-
-  /* done */
-  mp_clear(&t1);
-  mp_clear(&C);
-  mp_clear(&Q);
-  mp_clear(&S);
-  mp_clear(&Z);
-  mp_clear(&M);
-  mp_clear(&T);
-  mp_clear(&R);
-  mp_clear(&two);
-
-  return res;
-}
-
-
-/* export public ECC key in ANSI X9.63 format compressed */
-int wc_ecc_export_x963_compressed(ecc_key* key, byte* out, word32* outLen)
-{
-   word32 numlen;
-   int    ret = MP_OKAY;
-
-   if (key == NULL || out == NULL || outLen == NULL)
-       return ECC_BAD_ARG_E;
-
-   if (ecc_is_valid_idx(key->idx) == 0) {
-      return ECC_BAD_ARG_E;
-   }
-   numlen = key->dp->size;
-
-   if (*outLen < (1 + numlen)) {
-      *outLen = 1 + numlen;
-      return BUFFER_E;
-   }
-
-   /* store first byte */
-   out[0] = mp_isodd(key->pubkey.y) ? 0x03 : 0x02;
-
-   /* pad and store x */
-   XMEMSET(out+1, 0, numlen);
-   ret = mp_to_unsigned_bin(key->pubkey.x,
-                       out+1 + (numlen - mp_unsigned_bin_size(key->pubkey.x)));
-   *outLen = 1 + numlen;
-   return ret;
-}
-
-
-/* d = a - b (mod c) */
-int mp_submod(mp_int* a, mp_int* b, mp_int* c, mp_int* d)
-{
-  int     res;
-  mp_int  t;
-
-  if ((res = mp_init (&t)) != MP_OKAY) {
-    return res;
-  }
-
-  if ((res = mp_sub (a, b, &t)) != MP_OKAY) {
-    mp_clear (&t);
-    return res;
-  }
-  res = mp_mod (&t, c, d);
-  mp_clear (&t);
-
-  return res;
-}
-
-
-#endif /* HAVE_COMP_KEY */
-
-#endif /* HAVE_ECC */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ecc_fp.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ecc_fp.c
deleted file mode 100755
index c8acf93..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ecc_fp.c
+++ /dev/null
@@ -1 +0,0 @@
-/* dummy ecc_fp.c for dist */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ed25519.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ed25519.c
deleted file mode 100755
index ba0dcbe..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ed25519.c
+++ /dev/null
@@ -1,370 +0,0 @@
-/* ed25519.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
- /* Based On Daniel J Bernstein's ed25519 Public Domain ref10 work. */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-/* in case user set HAVE_ED25519 there */
-#include 
-
-#ifdef HAVE_ED25519
-
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-
-/*
-    generate an ed25519 key pair.
-    returns 0 on success
- */
-int wc_ed25519_make_key(RNG* rng, int keySz, ed25519_key* key)
-{
-    byte  az[64];
-    int   ret;
-    ge_p3 A;
-
-    if (rng == NULL || key == NULL)
-        return BAD_FUNC_ARG;
-
-    /* ed25519 has 32 byte key sizes */
-    if (keySz != ED25519_KEY_SIZE)
-        return BAD_FUNC_ARG;
-
-    ret = 0;
-    ret |= wc_RNG_GenerateBlock(rng, key->k, 32);
-    ret |= wc_Sha512Hash(key->k, 32, az);
-    az[0] &= 248;
-    az[31] &= 63;
-    az[31] |= 64;
-
-    ge_scalarmult_base(&A, az);
-    ge_p3_tobytes(key->p, &A);
-    XMEMMOVE(key->k + 32, key->p, 32);
-
-    return ret;
-}
-
-
-/*
-    in     contains the message to sign
-    inlen  is the length of the message to sign
-    out    is the buffer to write the signature
-    outlen [in/out] input size of out buf
-                    output gets set as the final length of out
-    key    is the ed25519 key to use when signing
-    return 0 on success
- */
-int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out,
-                        word32 *outlen, ed25519_key* key)
-{
-    ge_p3  R;
-    byte   nonce[SHA512_DIGEST_SIZE];
-    byte   hram[SHA512_DIGEST_SIZE];
-    byte   az[64];
-    word32 sigSz;
-    Sha512 sha;
-    int    ret = 0;
-
-    /* sanity check on arguments */
-    if (in == NULL || out == NULL || outlen == NULL || key == NULL)
-        return BAD_FUNC_ARG;
-
-    /* check and set up out length */
-    ret   = 0;
-    sigSz = wc_ed25519_sig_size(key);
-    if (*outlen < sigSz)
-        return BAD_FUNC_ARG;
-    *outlen = sigSz;
-
-    /* step 1: create nonce to use where nonce is r in
-       r = H(h_b, ... ,h_2b-1,M) */
-    ret |= wc_Sha512Hash(key->k,32,az);
-    az[0]  &= 248;
-    az[31] &= 63;
-    az[31] |= 64;
-    ret |= wc_InitSha512(&sha);
-    ret |= wc_Sha512Update(&sha, az + 32, 32);
-    ret |= wc_Sha512Update(&sha, in, inlen);
-    ret |= wc_Sha512Final(&sha, nonce);
-    sc_reduce(nonce);
-
-    /* step 2: computing R = rB where rB is the scalar multiplication of
-       r and B */
-    ge_scalarmult_base(&R,nonce);
-    ge_p3_tobytes(out,&R);
-
-    /* step 3: hash R + public key + message getting H(R,A,M) then
-       creating S = (r + H(R,A,M)a) mod l */
-    ret |= wc_InitSha512(&sha);
-    ret |= wc_Sha512Update(&sha, out, 32);
-    ret |= wc_Sha512Update(&sha, key->p, 32);
-    ret |= wc_Sha512Update(&sha, in, inlen);
-    ret |= wc_Sha512Final(&sha, hram);
-    sc_reduce(hram);
-    sc_muladd(out + 32, hram, az, nonce);
-
-    return ret;
-}
-
-
-/*
-   sig     is array of bytes containing the signature
-   siglen  is the length of sig byte array
-   msg     the array of bytes containing the message
-   msglen  length of msg array
-   stat    will be 1 on successful verify and 0 on unsuccessful
-*/
-int wc_ed25519_verify_msg(byte* sig, word32 siglen, const byte* msg,
-                          word32 msglen, int* stat, ed25519_key* key)
-{
-    byte   rcheck[32];
-    byte   h[SHA512_DIGEST_SIZE];
-    ge_p3  A;
-    ge_p2  R;
-    word32 sigSz;
-    int    ret;
-    Sha512 sha;
-
-    /* sanity check on arguments */
-    if (sig == NULL || msg == NULL || stat == NULL || key == NULL)
-        return BAD_FUNC_ARG;
-
-    ret   = 0;
-    *stat = 0;
-    sigSz = wc_ed25519_size(key);
-
-    /* check on basics needed to verify signature */
-    if (siglen < sigSz)
-        return BAD_FUNC_ARG;
-    if (sig[63] & 224)
-        return BAD_FUNC_ARG;
-
-    /* uncompress A (public key), test if valid, and negate it */
-    if (ge_frombytes_negate_vartime(&A, key->p) != 0)
-        return BAD_FUNC_ARG;
-
-    /* find H(R,A,M) and store it as h */
-    ret |= wc_InitSha512(&sha);
-    ret |= wc_Sha512Update(&sha, sig,    32);
-    ret |= wc_Sha512Update(&sha, key->p, 32);
-    ret |= wc_Sha512Update(&sha, msg,    msglen);
-    ret |= wc_Sha512Final(&sha,  h);
-    sc_reduce(h);
-
-    /*
-       Uses a fast single-signature verification SB = R + H(R,A,M)A becomes
-       SB - H(R,A,M)A saving decompression of R
-    */
-    ret |= ge_double_scalarmult_vartime(&R, h, &A, sig + 32);
-    ge_tobytes(rcheck, &R);
-
-    /* comparison of R created to R in sig */
-    ret  |= ConstantCompare(rcheck, sig, 32);
-
-    *stat = (ret == 0)? 1: 0;
-
-    return ret;
-}
-
-
-/* initialize information and memory for key */
-int wc_ed25519_init(ed25519_key* key)
-{
-    if (key == NULL)
-        return BAD_FUNC_ARG;
-
-    XMEMSET(key, 0, sizeof(ed25519_key));
-
-    return 0;
-}
-
-
-/* clear memory of key */
-void wc_ed25519_free(ed25519_key* key)
-{
-    if (key == NULL)
-        return;
-
-    ForceZero(key, sizeof(ed25519_key));
-}
-
-
-/*
-    outLen should contain the size of out buffer when input. outLen is than set
-    to the final output length.
-    returns 0 on success
- */
-int wc_ed25519_export_public(ed25519_key* key, byte* out, word32* outLen)
-{
-    word32 keySz;
-
-    /* sanity check on arguments */
-    if (key == NULL || out == NULL || outLen == NULL)
-        return BAD_FUNC_ARG;
-
-    keySz = wc_ed25519_size(key);
-    if (*outLen < keySz) {
-        *outLen = keySz;
-        return BUFFER_E;
-    }
-    *outLen = keySz;
-    XMEMCPY(out, key->p, keySz);
-
-    return 0;
-}
-
-
-/*
-    Imports a compressed/uncompressed public key.
-    in    the byte array containing the public key
-    inLen the length of the byte array being passed in
-    key   ed25519 key struct to put the public key in
- */
-int wc_ed25519_import_public(const byte* in, word32 inLen, ed25519_key* key)
-{
-    word32 keySz;
-    int    ret;
-
-    /* sanity check on arguments */
-    if (in == NULL || key == NULL)
-        return BAD_FUNC_ARG;
-
-    keySz = wc_ed25519_size(key);
-
-    if (inLen < keySz)
-        return BAD_FUNC_ARG;
-
-    /* compressed prefix according to draft
-       http://www.ietf.org/id/draft-koch-eddsa-for-openpgp-02.txt */
-    if (in[0] == 0x40) {
-        /* key is stored in compressed format so just copy in */
-        XMEMCPY(key->p, (in + 1), keySz);
-        return 0;
-    }
-
-    /* importing uncompressed public key */
-    if (in[0] == 0x04) {
-        /* pass in (x,y) and store compressed key */
-        ret = ge_compress_key(key->p, (in+1), (in+1+keySz), keySz);
-        return ret;
-    }
-
-    /* if not specified compressed or uncompressed check key size
-       if key size is equal to compressed key size copy in key */
-    if (inLen == keySz) {
-        XMEMCPY(key->p, in, keySz);
-        return 0;
-    }
-
-    /* bad public key format */
-    return BAD_FUNC_ARG;
-}
-
-
-/*
-    For importing a private key and its associated public key.
- */
-int wc_ed25519_import_private_key(const byte* priv, word32 privSz,
-                                const byte* pub, word32 pubSz, ed25519_key* key)
-{
-    word32 keySz;
-    int    ret;
-
-    /* sanity check on arguments */
-    if (priv == NULL || pub == NULL || key == NULL)
-        return BAD_FUNC_ARG;
-
-    keySz = wc_ed25519_size(key);
-
-    /* key size check */
-    if (privSz < keySz || pubSz < keySz)
-        return BAD_FUNC_ARG;
-
-    XMEMCPY(key->k, priv, keySz);
-    ret = wc_ed25519_import_public(pub, pubSz, key);
-    XMEMCPY((key->k + keySz), key->p, keySz);
-
-    return ret;
-}
-
-
-/*
-    outLen should contain the size of out buffer when input. outLen is than set
-    to the final output length.
-    returns 0 on success
- */
-int wc_ed25519_export_private_only(ed25519_key* key, byte* out, word32* outLen)
-{
-    word32 keySz;
-
-    /* sanity checks on arguments */
-    if (key == NULL || out == NULL || outLen == NULL)
-        return BAD_FUNC_ARG;
-
-    keySz = wc_ed25519_size(key);
-    if (*outLen < keySz) {
-        *outLen = keySz;
-        return BUFFER_E;
-    }
-    *outLen = keySz;
-    XMEMCPY(out, key->k, keySz);
-
-    return 0;
-}
-
-
-/* is the compressed key size in bytes */
-int wc_ed25519_size(ed25519_key* key)
-{
-    word32 keySz;
-
-    if (key == NULL)
-        return BAD_FUNC_ARG;
-
-    keySz = ED25519_KEY_SIZE;
-
-    return keySz;
-}
-
-
-/* returns the size of signature in bytes */
-int wc_ed25519_sig_size(ed25519_key* key)
-{
-    word32 sigSz;
-
-    if (key == NULL)
-        return BAD_FUNC_ARG;
-
-    sigSz = ED25519_SIG_SIZE;
-
-    return sigSz;
-}
-
-#endif /* HAVE_ED25519 */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/error.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/error.c
deleted file mode 100755
index 7d1d5eb..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/error.c
+++ /dev/null
@@ -1,343 +0,0 @@
-/* error.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#include 
-
-#ifdef _MSC_VER
-    /* 4996 warning to use MS extensions e.g., strcpy_s instead of XSTRNCPY */
-    #pragma warning(disable: 4996)
-#endif
-
-const char* wc_GetErrorString(int error)
-{
-#ifdef NO_ERROR_STRINGS
-
-    (void)error;
-    return "no support for error strings built in";
-
-#else
-
-    switch (error) {
-
-    case OPEN_RAN_E :
-        return "opening random device error";
-
-    case READ_RAN_E :
-        return "reading random device error";
-
-    case WINCRYPT_E :
-        return "windows crypt init error";
-
-    case CRYPTGEN_E :
-        return "windows crypt generation error";
-
-    case RAN_BLOCK_E :
-        return "random device read would block error";
-
-    case BAD_MUTEX_E :
-        return "Bad mutex, operation failed";
-
-    case MP_INIT_E :
-        return "mp_init error state";
-
-    case MP_READ_E :
-        return "mp_read error state";
-
-    case MP_EXPTMOD_E :
-        return "mp_exptmod error state";
-
-    case MP_TO_E :
-        return "mp_to_xxx error state, can't convert";
-
-    case MP_SUB_E :
-        return "mp_sub error state, can't subtract";
-
-    case MP_ADD_E :
-        return "mp_add error state, can't add";
-
-    case MP_MUL_E :
-        return "mp_mul error state, can't multiply";
-
-    case MP_MULMOD_E :
-        return "mp_mulmod error state, can't multiply mod";
-
-    case MP_MOD_E :
-        return "mp_mod error state, can't mod";
-
-    case MP_INVMOD_E :
-        return "mp_invmod error state, can't inv mod";
-
-    case MP_CMP_E :
-        return "mp_cmp error state";
-
-    case MP_ZERO_E :
-        return "mp zero result, not expected";
-
-    case MEMORY_E :
-        return "out of memory error";
-
-    case RSA_WRONG_TYPE_E :
-        return "RSA wrong block type for RSA function";
-
-    case RSA_BUFFER_E :
-        return "RSA buffer error, output too small or input too big";
-
-    case BUFFER_E :
-        return "Buffer error, output too small or input too big";
-
-    case ALGO_ID_E :
-        return "Setting Cert AlogID error";
-
-    case PUBLIC_KEY_E :
-        return "Setting Cert Public Key error";
-
-    case DATE_E :
-        return "Setting Cert Date validity error";
-
-    case SUBJECT_E :
-        return "Setting Cert Subject name error";
-
-    case ISSUER_E :
-        return "Setting Cert Issuer name error";
-
-    case CA_TRUE_E :
-        return "Setting basic constraint CA true error";
-
-    case EXTENSIONS_E :
-        return "Setting extensions error";
-
-    case ASN_PARSE_E :
-        return "ASN parsing error, invalid input";
-
-    case ASN_VERSION_E :
-        return "ASN version error, invalid number";
-
-    case ASN_GETINT_E :
-        return "ASN get big int error, invalid data";
-
-    case ASN_RSA_KEY_E :
-        return "ASN key init error, invalid input";
-
-    case ASN_OBJECT_ID_E :
-        return "ASN object id error, invalid id";
-
-    case ASN_TAG_NULL_E :
-        return "ASN tag error, not null";
-
-    case ASN_EXPECT_0_E :
-        return "ASN expect error, not zero";
-
-    case ASN_BITSTR_E :
-        return "ASN bit string error, wrong id";
-
-    case ASN_UNKNOWN_OID_E :
-        return "ASN oid error, unknown sum id";
-
-    case ASN_DATE_SZ_E :
-        return "ASN date error, bad size";
-
-    case ASN_BEFORE_DATE_E :
-        return "ASN date error, current date before";
-
-    case ASN_AFTER_DATE_E :
-        return "ASN date error, current date after";
-
-    case ASN_SIG_OID_E :
-        return "ASN signature error, mismatched oid";
-
-    case ASN_TIME_E :
-        return "ASN time error, unkown time type";
-
-    case ASN_INPUT_E :
-        return "ASN input error, not enough data";
-
-    case ASN_SIG_CONFIRM_E :
-        return "ASN sig error, confirm failure";
-
-    case ASN_SIG_HASH_E :
-        return "ASN sig error, unsupported hash type";
-
-    case ASN_SIG_KEY_E :
-        return "ASN sig error, unsupported key type";
-
-    case ASN_DH_KEY_E :
-        return "ASN key init error, invalid input";
-
-    case ASN_NTRU_KEY_E :
-        return "ASN NTRU key decode error, invalid input";
-
-    case ASN_CRIT_EXT_E:
-        return "X.509 Critical extension ignored";
-
-    case ECC_BAD_ARG_E :
-        return "ECC input argument wrong type, invalid input";
-
-    case ASN_ECC_KEY_E :
-        return "ECC ASN1 bad key data, invalid input";
-
-    case ECC_CURVE_OID_E :
-        return "ECC curve sum OID unsupported, invalid input";
-
-    case BAD_FUNC_ARG :
-        return "Bad function argument";
-
-    case NOT_COMPILED_IN :
-        return "Feature not compiled in";
-
-    case UNICODE_SIZE_E :
-        return "Unicode password too big";
-
-    case NO_PASSWORD :
-        return "No password provided by user";
-
-    case ALT_NAME_E :
-        return "Alt Name problem, too big";
-
-    case AES_GCM_AUTH_E:
-        return "AES-GCM Authentication check fail";
-
-    case AES_CCM_AUTH_E:
-        return "AES-CCM Authentication check fail";
-
-    case CAVIUM_INIT_E:
-        return "Cavium Init type error";
-
-    case COMPRESS_INIT_E:
-        return "Compress Init error";
-
-    case COMPRESS_E:
-        return "Compress error";
-
-    case DECOMPRESS_INIT_E:
-        return "DeCompress Init error";
-
-    case DECOMPRESS_E:
-        return "DeCompress error";
-
-    case BAD_ALIGN_E:
-        return "Bad alignment error, no alloc help";
-
-    case ASN_NO_SIGNER_E :
-        return "ASN no signer error to confirm failure";
-
-    case ASN_CRL_CONFIRM_E :
-        return "ASN CRL sig error, confirm failure";
-
-    case ASN_CRL_NO_SIGNER_E :
-        return "ASN CRL no signer error to confirm failure";
-
-    case ASN_OCSP_CONFIRM_E :
-        return "ASN OCSP sig error, confirm failure";
-
-    case BAD_ENC_STATE_E:
-        return "Bad ecc encrypt state operation";
-
-    case BAD_PADDING_E:
-        return "Bad padding, message wrong length";
-
-    case REQ_ATTRIBUTE_E:
-        return "Setting cert request attributes error";
-
-    case PKCS7_OID_E:
-        return "PKCS#7 error: mismatched OID value";
-
-    case PKCS7_RECIP_E:
-        return "PKCS#7 error: no matching recipient found";
-
-    case FIPS_NOT_ALLOWED_E:
-        return "FIPS mode not allowed error";
-
-    case ASN_NAME_INVALID_E:
-        return "Name Constraint error";
-
-    case RNG_FAILURE_E:
-        return "Random Number Generator failed";
-
-    case HMAC_MIN_KEYLEN_E:
-        return "FIPS Mode HMAC Minimum Key Length error";
-
-    case RSA_PAD_E:
-        return "Rsa Padding error";
-
-    case LENGTH_ONLY_E:
-        return "Output length only set, not for other use error";
-
-    case IN_CORE_FIPS_E:
-        return "In Core Integrity check FIPS error";
-
-    case AES_KAT_FIPS_E:
-        return "AES Known Answer Test check FIPS error";
-
-    case DES3_KAT_FIPS_E:
-        return "DES3 Known Answer Test check FIPS error";
-
-    case HMAC_KAT_FIPS_E:
-        return "HMAC Known Answer Test check FIPS error";
-
-    case RSA_KAT_FIPS_E:
-        return "RSA Known Answer Test check FIPS error";
-
-    case DRBG_KAT_FIPS_E:
-        return "DRBG Known Answer Test check FIPS error";
-
-    case DRBG_CONT_FIPS_E:
-        return "DRBG Continuous Test FIPS error";
-
-    case AESGCM_KAT_FIPS_E:
-        return "AESGCM Known Answer Test check FIPS error";
-
-    case THREAD_STORE_KEY_E:
-        return "Thread Storage Key Create error";
-
-    case THREAD_STORE_SET_E:
-        return "Thread Storage Set error";
-
-    case MAC_CMP_FAILED_E:
-        return "MAC comparison failed";
-
-    case IS_POINT_E:
-        return "ECC is point on curve failed";
-
-    case ECC_INF_E:
-        return " ECC point at infinity error";
-
-    case ECC_PRIV_KEY_E:
-        return " ECC private key is not valid error";
-
-    default:
-        return "unknown error number";
-
-    }
-
-#endif /* NO_ERROR_STRINGS */
-
-}
-
-void wc_ErrorString(int error, char* buffer)
-{
-    XSTRNCPY(buffer, wc_GetErrorString(error), WOLFSSL_MAX_ERROR_SZ);
-}
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fe_low_mem.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fe_low_mem.c
deleted file mode 100755
index 80834f5..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fe_low_mem.c
+++ /dev/null
@@ -1,596 +0,0 @@
-/* fe_low_mem.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/* Based from Daniel Beer's public domain word. */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#if defined(HAVE_ED25519) || defined(HAVE_CURVE25519)
-
-#include 
-
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-
-void fprime_copy(byte *x, const byte *a)
-{
-    int i;
-    for (i = 0; i < F25519_SIZE; i++)
-        x[i] = a[i];
-}
-
-
-void fe_copy(fe x, const fe a)
-{
-    int i;
-    for (i = 0; i < F25519_SIZE; i++)
-        x[i] = a[i];
-}
-
-
-/* Double an X-coordinate */
-static void xc_double(byte *x3, byte *z3,
-		      const byte *x1, const byte *z1)
-{
-	/* Explicit formulas database: dbl-1987-m
-	 *
-	 * source 1987 Montgomery "Speeding the Pollard and elliptic
-	 *   curve methods of factorization", page 261, fourth display
-	 * compute X3 = (X1^2-Z1^2)^2
-	 * compute Z3 = 4 X1 Z1 (X1^2 + a X1 Z1 + Z1^2)
-	 */
-	byte x1sq[F25519_SIZE];
-	byte z1sq[F25519_SIZE];
-	byte x1z1[F25519_SIZE];
-	byte a[F25519_SIZE];
-
-	fe_mul__distinct(x1sq, x1, x1);
-	fe_mul__distinct(z1sq, z1, z1);
-	fe_mul__distinct(x1z1, x1, z1);
-
-	fe_sub(a, x1sq, z1sq);
-	fe_mul__distinct(x3, a, a);
-
-	fe_mul_c(a, x1z1, 486662);
-	fe_add(a, x1sq, a);
-	fe_add(a, z1sq, a);
-	fe_mul__distinct(x1sq, x1z1, a);
-	fe_mul_c(z3, x1sq, 4);
-}
-
-
-/* Differential addition */
-static void xc_diffadd(byte *x5, byte *z5,
-		       const byte *x1, const byte *z1,
-		       const byte *x2, const byte *z2,
-		       const byte *x3, const byte *z3)
-{
-	/* Explicit formulas database: dbl-1987-m3
-	 *
-	 * source 1987 Montgomery "Speeding the Pollard and elliptic curve
-	 *   methods of factorization", page 261, fifth display, plus
-	 *   common-subexpression elimination
-	 * compute A = X2+Z2
-	 * compute B = X2-Z2
-	 * compute C = X3+Z3
-	 * compute D = X3-Z3
-	 * compute DA = D A
-	 * compute CB = C B
-	 * compute X5 = Z1(DA+CB)^2
-	 * compute Z5 = X1(DA-CB)^2
-	 */
-	byte da[F25519_SIZE];
-	byte cb[F25519_SIZE];
-	byte a[F25519_SIZE];
-	byte b[F25519_SIZE];
-
-	fe_add(a, x2, z2);
-	fe_sub(b, x3, z3); /* D */
-	fe_mul__distinct(da, a, b);
-
-	fe_sub(b, x2, z2);
-	fe_add(a, x3, z3); /* C */
-	fe_mul__distinct(cb, a, b);
-
-	fe_add(a, da, cb);
-	fe_mul__distinct(b, a, a);
-	fe_mul__distinct(x5, z1, b);
-
-	fe_sub(a, da, cb);
-	fe_mul__distinct(b, a, a);
-	fe_mul__distinct(z5, x1, b);
-}
-
-
-int curve25519(byte *result, byte *e, byte *q)
-{
-	/* Current point: P_m */
-	byte xm[F25519_SIZE];
-	byte zm[F25519_SIZE] = {1};
-
-	/* Predecessor: P_(m-1) */
-	byte xm1[F25519_SIZE] = {1};
-	byte zm1[F25519_SIZE] = {0};
-
-	int i;
-
-	/* Note: bit 254 is assumed to be 1 */
-	fe_copy(xm, q);
-
-	for (i = 253; i >= 0; i--) {
-		const int bit = (e[i >> 3] >> (i & 7)) & 1;
-		byte xms[F25519_SIZE];
-		byte zms[F25519_SIZE];
-
-		/* From P_m and P_(m-1), compute P_(2m) and P_(2m-1) */
-		xc_diffadd(xm1, zm1, q, f25519_one, xm, zm, xm1, zm1);
-		xc_double(xm, zm, xm, zm);
-
-		/* Compute P_(2m+1) */
-		xc_diffadd(xms, zms, xm1, zm1, xm, zm, q, f25519_one);
-
-		/* Select:
-		 *   bit = 1 --> (P_(2m+1), P_(2m))
-		 *   bit = 0 --> (P_(2m), P_(2m-1))
-		 */
-		fe_select(xm1, xm1, xm, bit);
-		fe_select(zm1, zm1, zm, bit);
-		fe_select(xm, xm, xms, bit);
-		fe_select(zm, zm, zms, bit);
-	}
-
-	/* Freeze out of projective coordinates */
-	fe_inv__distinct(zm1, zm);
-	fe_mul__distinct(result, zm1, xm);
-	fe_normalize(result);
-    return 0;
-}
-
-
-static void raw_add(byte *x, const byte *p)
-{
-	word16 c = 0;
-	int i;
-
-	for (i = 0; i < F25519_SIZE; i++) {
-		c += ((word16)x[i]) + ((word16)p[i]);
-		x[i] = c;
-		c >>= 8;
-	}
-}
-
-
-static void raw_try_sub(byte *x, const byte *p)
-{
-	byte minusp[F25519_SIZE];
-	word16 c = 0;
-	int i;
-
-	for (i = 0; i < F25519_SIZE; i++) {
-		c = ((word16)x[i]) - ((word16)p[i]) - c;
-		minusp[i] = c;
-		c = (c >> 8) & 1;
-	}
-
-	fprime_select(x, minusp, x, c);
-}
-
-
-static int prime_msb(const byte *p)
-{
-    int i;
-    byte x;
-    int shift = 1;
-    int z     = F25519_SIZE - 1;
-
-   /*
-       Test for any hot bits.
-       As soon as one instance is incountered set shift to 0.
-    */
-	for (i = F25519_SIZE - 1; i >= 0; i--) {
-        shift &= ((shift ^ ((-p[i] | p[i]) >> 7)) & 1);
-        z -= shift;
-    }
-	x = p[z];
-	z <<= 3;
-    shift = 1;
-    for (i = 0; i < 8; i++) {
-        shift &= ((-(x >> i) | (x >> i)) >> (7 - i) & 1);
-        z += shift;
-    }
-
-	return z - 1;
-}
-
-
-void fprime_select(byte *dst, const byte *zero, const byte *one, byte condition)
-{
-	const byte mask = -condition;
-	int i;
-
-	for (i = 0; i < F25519_SIZE; i++)
-		dst[i] = zero[i] ^ (mask & (one[i] ^ zero[i]));
-}
-
-
-void fprime_add(byte *r, const byte *a, const byte *modulus)
-{
-	raw_add(r, a);
-	raw_try_sub(r, modulus);
-}
-
-
-void fprime_sub(byte *r, const byte *a, const byte *modulus)
-{
-	raw_add(r, modulus);
-	raw_try_sub(r, a);
-	raw_try_sub(r, modulus);
-}
-
-
-void fprime_mul(byte *r, const byte *a, const byte *b,
-		const byte *modulus)
-{
-	word16 c = 0;
-	int i,j;
-
-	XMEMSET(r, 0, F25519_SIZE);
-
-	for (i = prime_msb(modulus); i >= 0; i--) {
-		const byte bit = (b[i >> 3] >> (i & 7)) & 1;
-		byte plusa[F25519_SIZE];
-
-	    for (j = 0; j < F25519_SIZE; j++) {
-		    c |= ((word16)r[j]) << 1;
-		    r[j] = c;
-		    c >>= 8;
-	    }
-		raw_try_sub(r, modulus);
-
-		fprime_copy(plusa, r);
-		fprime_add(plusa, a, modulus);
-
-		fprime_select(r, r, plusa, bit);
-	}
-}
-
-
-void fe_load(byte *x, word32 c)
-{
-	word32 i;
-
-	for (i = 0; i < sizeof(c); i++) {
-		x[i] = c;
-		c >>= 8;
-	}
-
-	for (; i < F25519_SIZE; i++)
-		x[i] = 0;
-}
-
-
-void fe_normalize(byte *x)
-{
-	byte minusp[F25519_SIZE];
-	word16 c;
-	int i;
-
-	/* Reduce using 2^255 = 19 mod p */
-	c = (x[31] >> 7) * 19;
-	x[31] &= 127;
-
-	for (i = 0; i < F25519_SIZE; i++) {
-		c += x[i];
-		x[i] = c;
-		c >>= 8;
-	}
-
-	/* The number is now less than 2^255 + 18, and therefore less than
-	 * 2p. Try subtracting p, and conditionally load the subtracted
-	 * value if underflow did not occur.
-	 */
-	c = 19;
-
-	for (i = 0; i + 1 < F25519_SIZE; i++) {
-		c += x[i];
-		minusp[i] = c;
-		c >>= 8;
-	}
-
-	c += ((word16)x[i]) - 128;
-	minusp[31] = c;
-
-	/* Load x-p if no underflow */
-	fe_select(x, minusp, x, (c >> 15) & 1);
-}
-
-
-void fe_select(byte *dst,
-		   const byte *zero, const byte *one,
-		   byte condition)
-{
-	const byte mask = -condition;
-	int i;
-
-	for (i = 0; i < F25519_SIZE; i++)
-		dst[i] = zero[i] ^ (mask & (one[i] ^ zero[i]));
-}
-
-
-void fe_add(fe r, const fe a, const fe b)
-{
-	word16 c = 0;
-	int i;
-
-	/* Add */
-	for (i = 0; i < F25519_SIZE; i++) {
-		c >>= 8;
-		c += ((word16)a[i]) + ((word16)b[i]);
-		r[i] = c;
-	}
-
-	/* Reduce with 2^255 = 19 mod p */
-	r[31] &= 127;
-	c = (c >> 7) * 19;
-
-	for (i = 0; i < F25519_SIZE; i++) {
-		c += r[i];
-		r[i] = c;
-		c >>= 8;
-	}
-}
-
-
-void fe_sub(fe r, const fe a, const fe b)
-{
-	word32 c = 0;
-	int i;
-
-	/* Calculate a + 2p - b, to avoid underflow */
-	c = 218;
-	for (i = 0; i + 1 < F25519_SIZE; i++) {
-		c += 65280 + ((word32)a[i]) - ((word32)b[i]);
-		r[i] = c;
-		c >>= 8;
-	}
-
-	c += ((word32)a[31]) - ((word32)b[31]);
-	r[31] = c & 127;
-	c = (c >> 7) * 19;
-
-	for (i = 0; i < F25519_SIZE; i++) {
-		c += r[i];
-		r[i] = c;
-		c >>= 8;
-	}
-}
-
-
-void fe_neg(fe r, const fe a)
-{
-	word32 c = 0;
-	int i;
-
-	/* Calculate 2p - a, to avoid underflow */
-	c = 218;
-	for (i = 0; i + 1 < F25519_SIZE; i++) {
-		c += 65280 - ((word32)a[i]);
-		r[i] = c;
-		c >>= 8;
-	}
-
-	c -= ((word32)a[31]);
-	r[31] = c & 127;
-	c = (c >> 7) * 19;
-
-	for (i = 0; i < F25519_SIZE; i++) {
-		c += r[i];
-		r[i] = c;
-		c >>= 8;
-	}
-}
-
-
-void fe_mul__distinct(byte *r, const byte *a, const byte *b)
-{
-	word32 c = 0;
-	int i;
-
-	for (i = 0; i < F25519_SIZE; i++) {
-		int j;
-
-		c >>= 8;
-		for (j = 0; j <= i; j++)
-			c += ((word32)a[j]) * ((word32)b[i - j]);
-
-		for (; j < F25519_SIZE; j++)
-			c += ((word32)a[j]) *
-			     ((word32)b[i + F25519_SIZE - j]) * 38;
-
-		r[i] = c;
-	}
-
-	r[31] &= 127;
-	c = (c >> 7) * 19;
-
-	for (i = 0; i < F25519_SIZE; i++) {
-		c += r[i];
-		r[i] = c;
-		c >>= 8;
-	}
-}
-
-
-void fe_mul(fe r, const fe a, const fe b)
-{
-	byte tmp[F25519_SIZE];
-
-	fe_mul__distinct(tmp, a, b);
-	fe_copy(r, tmp);
-}
-
-
-void fe_mul_c(byte *r, const byte *a, word32 b)
-{
-	word32 c = 0;
-	int i;
-
-	for (i = 0; i < F25519_SIZE; i++) {
-		c >>= 8;
-		c += b * ((word32)a[i]);
-		r[i] = c;
-	}
-
-	r[31] &= 127;
-	c >>= 7;
-	c *= 19;
-
-	for (i = 0; i < F25519_SIZE; i++) {
-		c += r[i];
-		r[i] = c;
-		c >>= 8;
-	}
-}
-
-
-void fe_inv__distinct(byte *r, const byte *x)
-{
-	byte s[F25519_SIZE];
-	int i;
-
-	/* This is a prime field, so by Fermat's little theorem:
-	 *
-	 *     x^(p-1) = 1 mod p
-	 *
-	 * Therefore, raise to (p-2) = 2^255-21 to get a multiplicative
-	 * inverse.
-	 *
-	 * This is a 255-bit binary number with the digits:
-	 *
-	 *     11111111... 01011
-	 *
-	 * We compute the result by the usual binary chain, but
-	 * alternate between keeping the accumulator in r and s, so as
-	 * to avoid copying temporaries.
-	 */
-
-	/* 1 1 */
-	fe_mul__distinct(s, x, x);
-	fe_mul__distinct(r, s, x);
-
-	/* 1 x 248 */
-	for (i = 0; i < 248; i++) {
-		fe_mul__distinct(s, r, r);
-		fe_mul__distinct(r, s, x);
-	}
-
-	/* 0 */
-	fe_mul__distinct(s, r, r);
-
-	/* 1 */
-	fe_mul__distinct(r, s, s);
-	fe_mul__distinct(s, r, x);
-
-	/* 0 */
-	fe_mul__distinct(r, s, s);
-
-	/* 1 */
-	fe_mul__distinct(s, r, r);
-	fe_mul__distinct(r, s, x);
-
-	/* 1 */
-	fe_mul__distinct(s, r, r);
-	fe_mul__distinct(r, s, x);
-}
-
-
-void fe_invert(fe r, const fe x)
-{
-	byte tmp[F25519_SIZE];
-
-	fe_inv__distinct(tmp, x);
-	fe_copy(r, tmp);
-}
-
-
-/* Raise x to the power of (p-5)/8 = 2^252-3, using s for temporary
- * storage.
- */
-static void exp2523(byte *r, const byte *x, byte *s)
-{
-	int i;
-
-	/* This number is a 252-bit number with the binary expansion:
-	 *
-	 *     111111... 01
-	 */
-
-	/* 1 1 */
-	fe_mul__distinct(r, x, x);
-	fe_mul__distinct(s, r, x);
-
-	/* 1 x 248 */
-	for (i = 0; i < 248; i++) {
-		fe_mul__distinct(r, s, s);
-		fe_mul__distinct(s, r, x);
-	}
-
-	/* 0 */
-	fe_mul__distinct(r, s, s);
-
-	/* 1 */
-	fe_mul__distinct(s, r, r);
-	fe_mul__distinct(r, s, x);
-}
-
-
-void fe_sqrt(byte *r, const byte *a)
-{
-	byte v[F25519_SIZE];
-	byte i[F25519_SIZE];
-	byte x[F25519_SIZE];
-	byte y[F25519_SIZE];
-
-	/* v = (2a)^((p-5)/8) [x = 2a] */
-	fe_mul_c(x, a, 2);
-	exp2523(v, x, y);
-
-	/* i = 2av^2 - 1 */
-	fe_mul__distinct(y, v, v);
-	fe_mul__distinct(i, x, y);
-	fe_load(y, 1);
-	fe_sub(i, i, y);
-
-	/* r = avi */
-	fe_mul__distinct(x, v, a);
-	fe_mul__distinct(r, x, i);
-}
-
-#endif /* HAVE_CURVE25519 or HAVE_ED25519 */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fe_operations.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fe_operations.c
deleted file mode 100755
index da07c95..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fe_operations.c
+++ /dev/null
@@ -1,1397 +0,0 @@
-/* fe_operations.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
- /* Based On Daniel J Bernstein's curve25519 Public Domain ref10 work. */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#if defined(HAVE_ED25519) || defined(HAVE_CURVE25519)
-
-#include 
-#include 
-
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-/*
-fe means field element.
-Here the field is \Z/(2^255-19).
-An element t, entries t[0]...t[9], represents the integer
-t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9].
-Bounds on each t[i] vary depending on context.
-*/
-
-uint64_t load_3(const unsigned char *in)
-{
-  uint64_t result;
-  result = (uint64_t) in[0];
-  result |= ((uint64_t) in[1]) << 8;
-  result |= ((uint64_t) in[2]) << 16;
-  return result;
-}
-
-
-uint64_t load_4(const unsigned char *in)
-{
-  uint64_t result;
-  result = (uint64_t) in[0];
-  result |= ((uint64_t) in[1]) << 8;
-  result |= ((uint64_t) in[2]) << 16;
-  result |= ((uint64_t) in[3]) << 24;
-  return result;
-}
-
-
-/*
-h = 1
-*/
-
-void fe_1(fe h)
-{
-  h[0] = 1;
-  h[1] = 0;
-  h[2] = 0;
-  h[3] = 0;
-  h[4] = 0;
-  h[5] = 0;
-  h[6] = 0;
-  h[7] = 0;
-  h[8] = 0;
-  h[9] = 0;
-}
-
-
-/*
-h = 0
-*/
-
-void fe_0(fe h)
-{
-  h[0] = 0;
-  h[1] = 0;
-  h[2] = 0;
-  h[3] = 0;
-  h[4] = 0;
-  h[5] = 0;
-  h[6] = 0;
-  h[7] = 0;
-  h[8] = 0;
-  h[9] = 0;
-}
-
-
-int curve25519(byte* q, byte* n, byte* p)
-{
-  unsigned char e[32];
-  unsigned int i;
-  fe x1;
-  fe x2;
-  fe z2;
-  fe x3;
-  fe z3;
-  fe tmp0;
-  fe tmp1;
-  int pos;
-  unsigned int swap;
-  unsigned int b;
-
-  for (i = 0;i < 32;++i) e[i] = n[i];
-  e[0] &= 248;
-  e[31] &= 127;
-  e[31] |= 64;
-
-  fe_frombytes(x1,p);
-  fe_1(x2);
-  fe_0(z2);
-  fe_copy(x3,x1);
-  fe_1(z3);
-
-  swap = 0;
-  for (pos = 254;pos >= 0;--pos) {
-    b = e[pos / 8] >> (pos & 7);
-    b &= 1;
-    swap ^= b;
-    fe_cswap(x2,x3,swap);
-    fe_cswap(z2,z3,swap);
-    swap = b;
-
-    /* montgomery */
-	fe_sub(tmp0,x3,z3);
-	fe_sub(tmp1,x2,z2);
-	fe_add(x2,x2,z2);
-	fe_add(z2,x3,z3);
-	fe_mul(z3,tmp0,x2);
-	fe_mul(z2,z2,tmp1);
-	fe_sq(tmp0,tmp1);
-	fe_sq(tmp1,x2);
-	fe_add(x3,z3,z2);
-	fe_sub(z2,z3,z2);
-	fe_mul(x2,tmp1,tmp0);
-	fe_sub(tmp1,tmp1,tmp0);
-	fe_sq(z2,z2);
-	fe_mul121666(z3,tmp1);
-	fe_sq(x3,x3);
-	fe_add(tmp0,tmp0,z3);
-	fe_mul(z3,x1,z2);
-	fe_mul(z2,tmp1,tmp0);
-  }
-  fe_cswap(x2,x3,swap);
-  fe_cswap(z2,z3,swap);
-
-  fe_invert(z2,z2);
-  fe_mul(x2,x2,z2);
-  fe_tobytes(q,x2);
-
-  return 0;
-}
-
-
-/*
-h = f * f
-Can overlap h with f.
-
-Preconditions:
-   |f| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc.
-
-Postconditions:
-   |h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc.
-*/
-
-/*
-See fe_mul.c for discussion of implementation strategy.
-*/
-
-void fe_sq(fe h,const fe f)
-{
-  int32_t f0 = f[0];
-  int32_t f1 = f[1];
-  int32_t f2 = f[2];
-  int32_t f3 = f[3];
-  int32_t f4 = f[4];
-  int32_t f5 = f[5];
-  int32_t f6 = f[6];
-  int32_t f7 = f[7];
-  int32_t f8 = f[8];
-  int32_t f9 = f[9];
-  int32_t f0_2 = 2 * f0;
-  int32_t f1_2 = 2 * f1;
-  int32_t f2_2 = 2 * f2;
-  int32_t f3_2 = 2 * f3;
-  int32_t f4_2 = 2 * f4;
-  int32_t f5_2 = 2 * f5;
-  int32_t f6_2 = 2 * f6;
-  int32_t f7_2 = 2 * f7;
-  int32_t f5_38 = 38 * f5; /* 1.959375*2^30 */
-  int32_t f6_19 = 19 * f6; /* 1.959375*2^30 */
-  int32_t f7_38 = 38 * f7; /* 1.959375*2^30 */
-  int32_t f8_19 = 19 * f8; /* 1.959375*2^30 */
-  int32_t f9_38 = 38 * f9; /* 1.959375*2^30 */
-  int64_t f0f0    = f0   * (int64_t) f0;
-  int64_t f0f1_2  = f0_2 * (int64_t) f1;
-  int64_t f0f2_2  = f0_2 * (int64_t) f2;
-  int64_t f0f3_2  = f0_2 * (int64_t) f3;
-  int64_t f0f4_2  = f0_2 * (int64_t) f4;
-  int64_t f0f5_2  = f0_2 * (int64_t) f5;
-  int64_t f0f6_2  = f0_2 * (int64_t) f6;
-  int64_t f0f7_2  = f0_2 * (int64_t) f7;
-  int64_t f0f8_2  = f0_2 * (int64_t) f8;
-  int64_t f0f9_2  = f0_2 * (int64_t) f9;
-  int64_t f1f1_2  = f1_2 * (int64_t) f1;
-  int64_t f1f2_2  = f1_2 * (int64_t) f2;
-  int64_t f1f3_4  = f1_2 * (int64_t) f3_2;
-  int64_t f1f4_2  = f1_2 * (int64_t) f4;
-  int64_t f1f5_4  = f1_2 * (int64_t) f5_2;
-  int64_t f1f6_2  = f1_2 * (int64_t) f6;
-  int64_t f1f7_4  = f1_2 * (int64_t) f7_2;
-  int64_t f1f8_2  = f1_2 * (int64_t) f8;
-  int64_t f1f9_76 = f1_2 * (int64_t) f9_38;
-  int64_t f2f2    = f2   * (int64_t) f2;
-  int64_t f2f3_2  = f2_2 * (int64_t) f3;
-  int64_t f2f4_2  = f2_2 * (int64_t) f4;
-  int64_t f2f5_2  = f2_2 * (int64_t) f5;
-  int64_t f2f6_2  = f2_2 * (int64_t) f6;
-  int64_t f2f7_2  = f2_2 * (int64_t) f7;
-  int64_t f2f8_38 = f2_2 * (int64_t) f8_19;
-  int64_t f2f9_38 = f2   * (int64_t) f9_38;
-  int64_t f3f3_2  = f3_2 * (int64_t) f3;
-  int64_t f3f4_2  = f3_2 * (int64_t) f4;
-  int64_t f3f5_4  = f3_2 * (int64_t) f5_2;
-  int64_t f3f6_2  = f3_2 * (int64_t) f6;
-  int64_t f3f7_76 = f3_2 * (int64_t) f7_38;
-  int64_t f3f8_38 = f3_2 * (int64_t) f8_19;
-  int64_t f3f9_76 = f3_2 * (int64_t) f9_38;
-  int64_t f4f4    = f4   * (int64_t) f4;
-  int64_t f4f5_2  = f4_2 * (int64_t) f5;
-  int64_t f4f6_38 = f4_2 * (int64_t) f6_19;
-  int64_t f4f7_38 = f4   * (int64_t) f7_38;
-  int64_t f4f8_38 = f4_2 * (int64_t) f8_19;
-  int64_t f4f9_38 = f4   * (int64_t) f9_38;
-  int64_t f5f5_38 = f5   * (int64_t) f5_38;
-  int64_t f5f6_38 = f5_2 * (int64_t) f6_19;
-  int64_t f5f7_76 = f5_2 * (int64_t) f7_38;
-  int64_t f5f8_38 = f5_2 * (int64_t) f8_19;
-  int64_t f5f9_76 = f5_2 * (int64_t) f9_38;
-  int64_t f6f6_19 = f6   * (int64_t) f6_19;
-  int64_t f6f7_38 = f6   * (int64_t) f7_38;
-  int64_t f6f8_38 = f6_2 * (int64_t) f8_19;
-  int64_t f6f9_38 = f6   * (int64_t) f9_38;
-  int64_t f7f7_38 = f7   * (int64_t) f7_38;
-  int64_t f7f8_38 = f7_2 * (int64_t) f8_19;
-  int64_t f7f9_76 = f7_2 * (int64_t) f9_38;
-  int64_t f8f8_19 = f8   * (int64_t) f8_19;
-  int64_t f8f9_38 = f8   * (int64_t) f9_38;
-  int64_t f9f9_38 = f9   * (int64_t) f9_38;
-  int64_t h0 = f0f0  +f1f9_76+f2f8_38+f3f7_76+f4f6_38+f5f5_38;
-  int64_t h1 = f0f1_2+f2f9_38+f3f8_38+f4f7_38+f5f6_38;
-  int64_t h2 = f0f2_2+f1f1_2 +f3f9_76+f4f8_38+f5f7_76+f6f6_19;
-  int64_t h3 = f0f3_2+f1f2_2 +f4f9_38+f5f8_38+f6f7_38;
-  int64_t h4 = f0f4_2+f1f3_4 +f2f2   +f5f9_76+f6f8_38+f7f7_38;
-  int64_t h5 = f0f5_2+f1f4_2 +f2f3_2 +f6f9_38+f7f8_38;
-  int64_t h6 = f0f6_2+f1f5_4 +f2f4_2 +f3f3_2 +f7f9_76+f8f8_19;
-  int64_t h7 = f0f7_2+f1f6_2 +f2f5_2 +f3f4_2 +f8f9_38;
-  int64_t h8 = f0f8_2+f1f7_4 +f2f6_2 +f3f5_4 +f4f4   +f9f9_38;
-  int64_t h9 = f0f9_2+f1f8_2 +f2f7_2 +f3f6_2 +f4f5_2;
-  int64_t carry0;
-  int64_t carry1;
-  int64_t carry2;
-  int64_t carry3;
-  int64_t carry4;
-  int64_t carry5;
-  int64_t carry6;
-  int64_t carry7;
-  int64_t carry8;
-  int64_t carry9;
-
-  carry0 = (h0 + (int64_t) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
-  carry4 = (h4 + (int64_t) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26;
-
-  carry1 = (h1 + (int64_t) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25;
-  carry5 = (h5 + (int64_t) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25;
-
-  carry2 = (h2 + (int64_t) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26;
-  carry6 = (h6 + (int64_t) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26;
-
-  carry3 = (h3 + (int64_t) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25;
-  carry7 = (h7 + (int64_t) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25;
-
-  carry4 = (h4 + (int64_t) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26;
-  carry8 = (h8 + (int64_t) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26;
-
-  carry9 = (h9 + (int64_t) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25;
-
-  carry0 = (h0 + (int64_t) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
-
-  h[0] = (int32_t)h0;
-  h[1] = (int32_t)h1;
-  h[2] = (int32_t)h2;
-  h[3] = (int32_t)h3;
-  h[4] = (int32_t)h4;
-  h[5] = (int32_t)h5;
-  h[6] = (int32_t)h6;
-  h[7] = (int32_t)h7;
-  h[8] = (int32_t)h8;
-  h[9] = (int32_t)h9;
-}
-
-
-/*
-h = f + g
-Can overlap h with f or g.
-
-Preconditions:
-   |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
-   |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
-
-Postconditions:
-   |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
-*/
-
-void fe_add(fe h,const fe f,const fe g)
-{
-  int32_t f0 = f[0];
-  int32_t f1 = f[1];
-  int32_t f2 = f[2];
-  int32_t f3 = f[3];
-  int32_t f4 = f[4];
-  int32_t f5 = f[5];
-  int32_t f6 = f[6];
-  int32_t f7 = f[7];
-  int32_t f8 = f[8];
-  int32_t f9 = f[9];
-  int32_t g0 = g[0];
-  int32_t g1 = g[1];
-  int32_t g2 = g[2];
-  int32_t g3 = g[3];
-  int32_t g4 = g[4];
-  int32_t g5 = g[5];
-  int32_t g6 = g[6];
-  int32_t g7 = g[7];
-  int32_t g8 = g[8];
-  int32_t g9 = g[9];
-  int32_t h0 = f0 + g0;
-  int32_t h1 = f1 + g1;
-  int32_t h2 = f2 + g2;
-  int32_t h3 = f3 + g3;
-  int32_t h4 = f4 + g4;
-  int32_t h5 = f5 + g5;
-  int32_t h6 = f6 + g6;
-  int32_t h7 = f7 + g7;
-  int32_t h8 = f8 + g8;
-  int32_t h9 = f9 + g9;
-  h[0] = h0;
-  h[1] = h1;
-  h[2] = h2;
-  h[3] = h3;
-  h[4] = h4;
-  h[5] = h5;
-  h[6] = h6;
-  h[7] = h7;
-  h[8] = h8;
-  h[9] = h9;
-}
-
-
-/*
-Preconditions:
-  |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
-
-Write p=2^255-19; q=floor(h/p).
-Basic claim: q = floor(2^(-255)(h + 19 2^(-25)h9 + 2^(-1))).
-
-Proof:
-  Have |h|<=p so |q|<=1 so |19^2 2^(-255) q|<1/4.
-  Also have |h-2^230 h9|<2^231 so |19 2^(-255)(h-2^230 h9)|<1/4.
-
-  Write y=2^(-1)-19^2 2^(-255)q-19 2^(-255)(h-2^230 h9).
-  Then 0> 25;
-  q = (h0 + q) >> 26;
-  q = (h1 + q) >> 25;
-  q = (h2 + q) >> 26;
-  q = (h3 + q) >> 25;
-  q = (h4 + q) >> 26;
-  q = (h5 + q) >> 25;
-  q = (h6 + q) >> 26;
-  q = (h7 + q) >> 25;
-  q = (h8 + q) >> 26;
-  q = (h9 + q) >> 25;
-
-  /* Goal: Output h-(2^255-19)q, which is between 0 and 2^255-20. */
-  h0 += 19 * q;
-  /* Goal: Output h-2^255 q, which is between 0 and 2^255-20. */
-
-  carry0 = h0 >> 26; h1 += carry0; h0 -= carry0 << 26;
-  carry1 = h1 >> 25; h2 += carry1; h1 -= carry1 << 25;
-  carry2 = h2 >> 26; h3 += carry2; h2 -= carry2 << 26;
-  carry3 = h3 >> 25; h4 += carry3; h3 -= carry3 << 25;
-  carry4 = h4 >> 26; h5 += carry4; h4 -= carry4 << 26;
-  carry5 = h5 >> 25; h6 += carry5; h5 -= carry5 << 25;
-  carry6 = h6 >> 26; h7 += carry6; h6 -= carry6 << 26;
-  carry7 = h7 >> 25; h8 += carry7; h7 -= carry7 << 25;
-  carry8 = h8 >> 26; h9 += carry8; h8 -= carry8 << 26;
-  carry9 = h9 >> 25;               h9 -= carry9 << 25;
-                  /* h10 = carry9 */
-
-  /*
-  Goal: Output h0+...+2^255 h10-2^255 q, which is between 0 and 2^255-20.
-  Have h0+...+2^230 h9 between 0 and 2^255-1;
-  evidently 2^255 h10-2^255 q = 0.
-  Goal: Output h0+...+2^230 h9.
-  */
-
-  s[0] = h0 >> 0;
-  s[1] = h0 >> 8;
-  s[2] = h0 >> 16;
-  s[3] = (h0 >> 24) | (h1 << 2);
-  s[4] = h1 >> 6;
-  s[5] = h1 >> 14;
-  s[6] = (h1 >> 22) | (h2 << 3);
-  s[7] = h2 >> 5;
-  s[8] = h2 >> 13;
-  s[9] = (h2 >> 21) | (h3 << 5);
-  s[10] = h3 >> 3;
-  s[11] = h3 >> 11;
-  s[12] = (h3 >> 19) | (h4 << 6);
-  s[13] = h4 >> 2;
-  s[14] = h4 >> 10;
-  s[15] = h4 >> 18;
-  s[16] = h5 >> 0;
-  s[17] = h5 >> 8;
-  s[18] = h5 >> 16;
-  s[19] = (h5 >> 24) | (h6 << 1);
-  s[20] = h6 >> 7;
-  s[21] = h6 >> 15;
-  s[22] = (h6 >> 23) | (h7 << 3);
-  s[23] = h7 >> 5;
-  s[24] = h7 >> 13;
-  s[25] = (h7 >> 21) | (h8 << 4);
-  s[26] = h8 >> 4;
-  s[27] = h8 >> 12;
-  s[28] = (h8 >> 20) | (h9 << 6);
-  s[29] = h9 >> 2;
-  s[30] = h9 >> 10;
-  s[31] = h9 >> 18;
-}
-
-
-/*
-h = f - g
-Can overlap h with f or g.
-
-Preconditions:
-   |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
-   |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
-
-Postconditions:
-   |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
-*/
-
-void fe_sub(fe h,const fe f,const fe g)
-{
-  int32_t f0 = f[0];
-  int32_t f1 = f[1];
-  int32_t f2 = f[2];
-  int32_t f3 = f[3];
-  int32_t f4 = f[4];
-  int32_t f5 = f[5];
-  int32_t f6 = f[6];
-  int32_t f7 = f[7];
-  int32_t f8 = f[8];
-  int32_t f9 = f[9];
-  int32_t g0 = g[0];
-  int32_t g1 = g[1];
-  int32_t g2 = g[2];
-  int32_t g3 = g[3];
-  int32_t g4 = g[4];
-  int32_t g5 = g[5];
-  int32_t g6 = g[6];
-  int32_t g7 = g[7];
-  int32_t g8 = g[8];
-  int32_t g9 = g[9];
-  int32_t h0 = f0 - g0;
-  int32_t h1 = f1 - g1;
-  int32_t h2 = f2 - g2;
-  int32_t h3 = f3 - g3;
-  int32_t h4 = f4 - g4;
-  int32_t h5 = f5 - g5;
-  int32_t h6 = f6 - g6;
-  int32_t h7 = f7 - g7;
-  int32_t h8 = f8 - g8;
-  int32_t h9 = f9 - g9;
-  h[0] = h0;
-  h[1] = h1;
-  h[2] = h2;
-  h[3] = h3;
-  h[4] = h4;
-  h[5] = h5;
-  h[6] = h6;
-  h[7] = h7;
-  h[8] = h8;
-  h[9] = h9;
-}
-
-
-/*
-Ignores top bit of h.
-*/
-
-void fe_frombytes(fe h,const unsigned char *s)
-{
-  int64_t h0 = load_4(s);
-  int64_t h1 = load_3(s + 4) << 6;
-  int64_t h2 = load_3(s + 7) << 5;
-  int64_t h3 = load_3(s + 10) << 3;
-  int64_t h4 = load_3(s + 13) << 2;
-  int64_t h5 = load_4(s + 16);
-  int64_t h6 = load_3(s + 20) << 7;
-  int64_t h7 = load_3(s + 23) << 5;
-  int64_t h8 = load_3(s + 26) << 4;
-  int64_t h9 = (load_3(s + 29) & 8388607) << 2;
-  int64_t carry0;
-  int64_t carry1;
-  int64_t carry2;
-  int64_t carry3;
-  int64_t carry4;
-  int64_t carry5;
-  int64_t carry6;
-  int64_t carry7;
-  int64_t carry8;
-  int64_t carry9;
-
-  carry9 = (h9 + (int64_t) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25;
-  carry1 = (h1 + (int64_t) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25;
-  carry3 = (h3 + (int64_t) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25;
-  carry5 = (h5 + (int64_t) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25;
-  carry7 = (h7 + (int64_t) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25;
-
-  carry0 = (h0 + (int64_t) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
-  carry2 = (h2 + (int64_t) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26;
-  carry4 = (h4 + (int64_t) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26;
-  carry6 = (h6 + (int64_t) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26;
-  carry8 = (h8 + (int64_t) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26;
-
-  h[0] = (int32_t)h0;
-  h[1] = (int32_t)h1;
-  h[2] = (int32_t)h2;
-  h[3] = (int32_t)h3;
-  h[4] = (int32_t)h4;
-  h[5] = (int32_t)h5;
-  h[6] = (int32_t)h6;
-  h[7] = (int32_t)h7;
-  h[8] = (int32_t)h8;
-  h[9] = (int32_t)h9;
-}
-
-
-void fe_invert(fe out,const fe z)
-{
-  fe t0;
-  fe t1;
-  fe t2;
-  fe t3;
-  int i;
-
-  /* pow225521 */
-  fe_sq(t0,z); for (i = 1;i < 1;++i) fe_sq(t0,t0);
-  fe_sq(t1,t0); for (i = 1;i < 2;++i) fe_sq(t1,t1);
-  fe_mul(t1,z,t1);
-  fe_mul(t0,t0,t1);
-  fe_sq(t2,t0); for (i = 1;i < 1;++i) fe_sq(t2,t2);
-  fe_mul(t1,t1,t2);
-  fe_sq(t2,t1); for (i = 1;i < 5;++i) fe_sq(t2,t2);
-  fe_mul(t1,t2,t1);
-  fe_sq(t2,t1); for (i = 1;i < 10;++i) fe_sq(t2,t2);
-  fe_mul(t2,t2,t1);
-  fe_sq(t3,t2); for (i = 1;i < 20;++i) fe_sq(t3,t3);
-  fe_mul(t2,t3,t2);
-  fe_sq(t2,t2); for (i = 1;i < 10;++i) fe_sq(t2,t2);
-  fe_mul(t1,t2,t1);
-  fe_sq(t2,t1); for (i = 1;i < 50;++i) fe_sq(t2,t2);
-  fe_mul(t2,t2,t1);
-  fe_sq(t3,t2); for (i = 1;i < 100;++i) fe_sq(t3,t3);
-  fe_mul(t2,t3,t2);
-  fe_sq(t2,t2); for (i = 1;i < 50;++i) fe_sq(t2,t2);
-  fe_mul(t1,t2,t1);
-  fe_sq(t1,t1); for (i = 1;i < 5;++i) fe_sq(t1,t1);
-  fe_mul(out,t1,t0);
-
-  return;
-}
-
-
-/*
-h = f
-*/
-
-void fe_copy(fe h,const fe f)
-{
-  int32_t f0 = f[0];
-  int32_t f1 = f[1];
-  int32_t f2 = f[2];
-  int32_t f3 = f[3];
-  int32_t f4 = f[4];
-  int32_t f5 = f[5];
-  int32_t f6 = f[6];
-  int32_t f7 = f[7];
-  int32_t f8 = f[8];
-  int32_t f9 = f[9];
-  h[0] = f0;
-  h[1] = f1;
-  h[2] = f2;
-  h[3] = f3;
-  h[4] = f4;
-  h[5] = f5;
-  h[6] = f6;
-  h[7] = f7;
-  h[8] = f8;
-  h[9] = f9;
-}
-
-
-/*
-h = f * g
-Can overlap h with f or g.
-
-Preconditions:
-   |f| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc.
-   |g| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc.
-
-Postconditions:
-   |h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc.
-*/
-
-/*
-Notes on implementation strategy:
-
-Using schoolbook multiplication.
-Karatsuba would save a little in some cost models.
-
-Most multiplications by 2 and 19 are 32-bit precomputations;
-cheaper than 64-bit postcomputations.
-
-There is one remaining multiplication by 19 in the carry chain;
-one *19 precomputation can be merged into this,
-but the resulting data flow is considerably less clean.
-
-There are 12 carries below.
-10 of them are 2-way parallelizable and vectorizable.
-Can get away with 11 carries, but then data flow is much deeper.
-
-With tighter constraints on inputs can squeeze carries into int32.
-*/
-
-void fe_mul(fe h,const fe f,const fe g)
-{
-  int32_t f0 = f[0];
-  int32_t f1 = f[1];
-  int32_t f2 = f[2];
-  int32_t f3 = f[3];
-  int32_t f4 = f[4];
-  int32_t f5 = f[5];
-  int32_t f6 = f[6];
-  int32_t f7 = f[7];
-  int32_t f8 = f[8];
-  int32_t f9 = f[9];
-  int32_t g0 = g[0];
-  int32_t g1 = g[1];
-  int32_t g2 = g[2];
-  int32_t g3 = g[3];
-  int32_t g4 = g[4];
-  int32_t g5 = g[5];
-  int32_t g6 = g[6];
-  int32_t g7 = g[7];
-  int32_t g8 = g[8];
-  int32_t g9 = g[9];
-  int32_t g1_19 = 19 * g1; /* 1.959375*2^29 */
-  int32_t g2_19 = 19 * g2; /* 1.959375*2^30; still ok */
-  int32_t g3_19 = 19 * g3;
-  int32_t g4_19 = 19 * g4;
-  int32_t g5_19 = 19 * g5;
-  int32_t g6_19 = 19 * g6;
-  int32_t g7_19 = 19 * g7;
-  int32_t g8_19 = 19 * g8;
-  int32_t g9_19 = 19 * g9;
-  int32_t f1_2 = 2 * f1;
-  int32_t f3_2 = 2 * f3;
-  int32_t f5_2 = 2 * f5;
-  int32_t f7_2 = 2 * f7;
-  int32_t f9_2 = 2 * f9;
-  int64_t f0g0    = f0   * (int64_t) g0;
-  int64_t f0g1    = f0   * (int64_t) g1;
-  int64_t f0g2    = f0   * (int64_t) g2;
-  int64_t f0g3    = f0   * (int64_t) g3;
-  int64_t f0g4    = f0   * (int64_t) g4;
-  int64_t f0g5    = f0   * (int64_t) g5;
-  int64_t f0g6    = f0   * (int64_t) g6;
-  int64_t f0g7    = f0   * (int64_t) g7;
-  int64_t f0g8    = f0   * (int64_t) g8;
-  int64_t f0g9    = f0   * (int64_t) g9;
-  int64_t f1g0    = f1   * (int64_t) g0;
-  int64_t f1g1_2  = f1_2 * (int64_t) g1;
-  int64_t f1g2    = f1   * (int64_t) g2;
-  int64_t f1g3_2  = f1_2 * (int64_t) g3;
-  int64_t f1g4    = f1   * (int64_t) g4;
-  int64_t f1g5_2  = f1_2 * (int64_t) g5;
-  int64_t f1g6    = f1   * (int64_t) g6;
-  int64_t f1g7_2  = f1_2 * (int64_t) g7;
-  int64_t f1g8    = f1   * (int64_t) g8;
-  int64_t f1g9_38 = f1_2 * (int64_t) g9_19;
-  int64_t f2g0    = f2   * (int64_t) g0;
-  int64_t f2g1    = f2   * (int64_t) g1;
-  int64_t f2g2    = f2   * (int64_t) g2;
-  int64_t f2g3    = f2   * (int64_t) g3;
-  int64_t f2g4    = f2   * (int64_t) g4;
-  int64_t f2g5    = f2   * (int64_t) g5;
-  int64_t f2g6    = f2   * (int64_t) g6;
-  int64_t f2g7    = f2   * (int64_t) g7;
-  int64_t f2g8_19 = f2   * (int64_t) g8_19;
-  int64_t f2g9_19 = f2   * (int64_t) g9_19;
-  int64_t f3g0    = f3   * (int64_t) g0;
-  int64_t f3g1_2  = f3_2 * (int64_t) g1;
-  int64_t f3g2    = f3   * (int64_t) g2;
-  int64_t f3g3_2  = f3_2 * (int64_t) g3;
-  int64_t f3g4    = f3   * (int64_t) g4;
-  int64_t f3g5_2  = f3_2 * (int64_t) g5;
-  int64_t f3g6    = f3   * (int64_t) g6;
-  int64_t f3g7_38 = f3_2 * (int64_t) g7_19;
-  int64_t f3g8_19 = f3   * (int64_t) g8_19;
-  int64_t f3g9_38 = f3_2 * (int64_t) g9_19;
-  int64_t f4g0    = f4   * (int64_t) g0;
-  int64_t f4g1    = f4   * (int64_t) g1;
-  int64_t f4g2    = f4   * (int64_t) g2;
-  int64_t f4g3    = f4   * (int64_t) g3;
-  int64_t f4g4    = f4   * (int64_t) g4;
-  int64_t f4g5    = f4   * (int64_t) g5;
-  int64_t f4g6_19 = f4   * (int64_t) g6_19;
-  int64_t f4g7_19 = f4   * (int64_t) g7_19;
-  int64_t f4g8_19 = f4   * (int64_t) g8_19;
-  int64_t f4g9_19 = f4   * (int64_t) g9_19;
-  int64_t f5g0    = f5   * (int64_t) g0;
-  int64_t f5g1_2  = f5_2 * (int64_t) g1;
-  int64_t f5g2    = f5   * (int64_t) g2;
-  int64_t f5g3_2  = f5_2 * (int64_t) g3;
-  int64_t f5g4    = f5   * (int64_t) g4;
-  int64_t f5g5_38 = f5_2 * (int64_t) g5_19;
-  int64_t f5g6_19 = f5   * (int64_t) g6_19;
-  int64_t f5g7_38 = f5_2 * (int64_t) g7_19;
-  int64_t f5g8_19 = f5   * (int64_t) g8_19;
-  int64_t f5g9_38 = f5_2 * (int64_t) g9_19;
-  int64_t f6g0    = f6   * (int64_t) g0;
-  int64_t f6g1    = f6   * (int64_t) g1;
-  int64_t f6g2    = f6   * (int64_t) g2;
-  int64_t f6g3    = f6   * (int64_t) g3;
-  int64_t f6g4_19 = f6   * (int64_t) g4_19;
-  int64_t f6g5_19 = f6   * (int64_t) g5_19;
-  int64_t f6g6_19 = f6   * (int64_t) g6_19;
-  int64_t f6g7_19 = f6   * (int64_t) g7_19;
-  int64_t f6g8_19 = f6   * (int64_t) g8_19;
-  int64_t f6g9_19 = f6   * (int64_t) g9_19;
-  int64_t f7g0    = f7   * (int64_t) g0;
-  int64_t f7g1_2  = f7_2 * (int64_t) g1;
-  int64_t f7g2    = f7   * (int64_t) g2;
-  int64_t f7g3_38 = f7_2 * (int64_t) g3_19;
-  int64_t f7g4_19 = f7   * (int64_t) g4_19;
-  int64_t f7g5_38 = f7_2 * (int64_t) g5_19;
-  int64_t f7g6_19 = f7   * (int64_t) g6_19;
-  int64_t f7g7_38 = f7_2 * (int64_t) g7_19;
-  int64_t f7g8_19 = f7   * (int64_t) g8_19;
-  int64_t f7g9_38 = f7_2 * (int64_t) g9_19;
-  int64_t f8g0    = f8   * (int64_t) g0;
-  int64_t f8g1    = f8   * (int64_t) g1;
-  int64_t f8g2_19 = f8   * (int64_t) g2_19;
-  int64_t f8g3_19 = f8   * (int64_t) g3_19;
-  int64_t f8g4_19 = f8   * (int64_t) g4_19;
-  int64_t f8g5_19 = f8   * (int64_t) g5_19;
-  int64_t f8g6_19 = f8   * (int64_t) g6_19;
-  int64_t f8g7_19 = f8   * (int64_t) g7_19;
-  int64_t f8g8_19 = f8   * (int64_t) g8_19;
-  int64_t f8g9_19 = f8   * (int64_t) g9_19;
-  int64_t f9g0    = f9   * (int64_t) g0;
-  int64_t f9g1_38 = f9_2 * (int64_t) g1_19;
-  int64_t f9g2_19 = f9   * (int64_t) g2_19;
-  int64_t f9g3_38 = f9_2 * (int64_t) g3_19;
-  int64_t f9g4_19 = f9   * (int64_t) g4_19;
-  int64_t f9g5_38 = f9_2 * (int64_t) g5_19;
-  int64_t f9g6_19 = f9   * (int64_t) g6_19;
-  int64_t f9g7_38 = f9_2 * (int64_t) g7_19;
-  int64_t f9g8_19 = f9   * (int64_t) g8_19;
-  int64_t f9g9_38 = f9_2 * (int64_t) g9_19;
-  int64_t h0 = f0g0+f1g9_38+f2g8_19+f3g7_38+f4g6_19+f5g5_38+f6g4_19+f7g3_38+f8g2_19+f9g1_38;
-  int64_t h1 = f0g1+f1g0   +f2g9_19+f3g8_19+f4g7_19+f5g6_19+f6g5_19+f7g4_19+f8g3_19+f9g2_19;
-  int64_t h2 = f0g2+f1g1_2 +f2g0   +f3g9_38+f4g8_19+f5g7_38+f6g6_19+f7g5_38+f8g4_19+f9g3_38;
-  int64_t h3 = f0g3+f1g2   +f2g1   +f3g0   +f4g9_19+f5g8_19+f6g7_19+f7g6_19+f8g5_19+f9g4_19;
-  int64_t h4 = f0g4+f1g3_2 +f2g2   +f3g1_2 +f4g0   +f5g9_38+f6g8_19+f7g7_38+f8g6_19+f9g5_38;
-  int64_t h5 = f0g5+f1g4   +f2g3   +f3g2   +f4g1   +f5g0   +f6g9_19+f7g8_19+f8g7_19+f9g6_19;
-  int64_t h6 = f0g6+f1g5_2 +f2g4   +f3g3_2 +f4g2   +f5g1_2 +f6g0   +f7g9_38+f8g8_19+f9g7_38;
-  int64_t h7 = f0g7+f1g6   +f2g5   +f3g4   +f4g3   +f5g2   +f6g1   +f7g0   +f8g9_19+f9g8_19;
-  int64_t h8 = f0g8+f1g7_2 +f2g6   +f3g5_2 +f4g4   +f5g3_2 +f6g2   +f7g1_2 +f8g0   +f9g9_38;
-  int64_t h9 = f0g9+f1g8   +f2g7   +f3g6   +f4g5   +f5g4   +f6g3   +f7g2   +f8g1   +f9g0   ;
-  int64_t carry0;
-  int64_t carry1;
-  int64_t carry2;
-  int64_t carry3;
-  int64_t carry4;
-  int64_t carry5;
-  int64_t carry6;
-  int64_t carry7;
-  int64_t carry8;
-  int64_t carry9;
-
-  /*
-  |h0| <= (1.65*1.65*2^52*(1+19+19+19+19)+1.65*1.65*2^50*(38+38+38+38+38))
-    i.e. |h0| <= 1.4*2^60; narrower ranges for h2, h4, h6, h8
-  |h1| <= (1.65*1.65*2^51*(1+1+19+19+19+19+19+19+19+19))
-    i.e. |h1| <= 1.7*2^59; narrower ranges for h3, h5, h7, h9
-  */
-
-  carry0 = (h0 + (int64_t) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
-  carry4 = (h4 + (int64_t) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26;
-  /* |h0| <= 2^25 */
-  /* |h4| <= 2^25 */
-  /* |h1| <= 1.71*2^59 */
-  /* |h5| <= 1.71*2^59 */
-
-  carry1 = (h1 + (int64_t) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25;
-  carry5 = (h5 + (int64_t) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25;
-  /* |h1| <= 2^24; from now on fits into int32 */
-  /* |h5| <= 2^24; from now on fits into int32 */
-  /* |h2| <= 1.41*2^60 */
-  /* |h6| <= 1.41*2^60 */
-
-  carry2 = (h2 + (int64_t) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26;
-  carry6 = (h6 + (int64_t) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26;
-  /* |h2| <= 2^25; from now on fits into int32 unchanged */
-  /* |h6| <= 2^25; from now on fits into int32 unchanged */
-  /* |h3| <= 1.71*2^59 */
-  /* |h7| <= 1.71*2^59 */
-
-  carry3 = (h3 + (int64_t) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25;
-  carry7 = (h7 + (int64_t) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25;
-  /* |h3| <= 2^24; from now on fits into int32 unchanged */
-  /* |h7| <= 2^24; from now on fits into int32 unchanged */
-  /* |h4| <= 1.72*2^34 */
-  /* |h8| <= 1.41*2^60 */
-
-  carry4 = (h4 + (int64_t) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26;
-  carry8 = (h8 + (int64_t) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26;
-  /* |h4| <= 2^25; from now on fits into int32 unchanged */
-  /* |h8| <= 2^25; from now on fits into int32 unchanged */
-  /* |h5| <= 1.01*2^24 */
-  /* |h9| <= 1.71*2^59 */
-
-  carry9 = (h9 + (int64_t) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25;
-  /* |h9| <= 2^24; from now on fits into int32 unchanged */
-  /* |h0| <= 1.1*2^39 */
-
-  carry0 = (h0 + (int64_t) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
-  /* |h0| <= 2^25; from now on fits into int32 unchanged */
-  /* |h1| <= 1.01*2^24 */
-
-  h[0] = (int32_t)h0;
-  h[1] = (int32_t)h1;
-  h[2] = (int32_t)h2;
-  h[3] = (int32_t)h3;
-  h[4] = (int32_t)h4;
-  h[5] = (int32_t)h5;
-  h[6] = (int32_t)h6;
-  h[7] = (int32_t)h7;
-  h[8] = (int32_t)h8;
-  h[9] = (int32_t)h9;
-}
-
-
-/*
-Replace (f,g) with (g,f) if b == 1;
-replace (f,g) with (f,g) if b == 0.
-
-Preconditions: b in {0,1}.
-*/
-
-void fe_cswap(fe f,fe g,unsigned int b)
-{
-  int32_t f0 = f[0];
-  int32_t f1 = f[1];
-  int32_t f2 = f[2];
-  int32_t f3 = f[3];
-  int32_t f4 = f[4];
-  int32_t f5 = f[5];
-  int32_t f6 = f[6];
-  int32_t f7 = f[7];
-  int32_t f8 = f[8];
-  int32_t f9 = f[9];
-  int32_t g0 = g[0];
-  int32_t g1 = g[1];
-  int32_t g2 = g[2];
-  int32_t g3 = g[3];
-  int32_t g4 = g[4];
-  int32_t g5 = g[5];
-  int32_t g6 = g[6];
-  int32_t g7 = g[7];
-  int32_t g8 = g[8];
-  int32_t g9 = g[9];
-  int32_t x0 = f0 ^ g0;
-  int32_t x1 = f1 ^ g1;
-  int32_t x2 = f2 ^ g2;
-  int32_t x3 = f3 ^ g3;
-  int32_t x4 = f4 ^ g4;
-  int32_t x5 = f5 ^ g5;
-  int32_t x6 = f6 ^ g6;
-  int32_t x7 = f7 ^ g7;
-  int32_t x8 = f8 ^ g8;
-  int32_t x9 = f9 ^ g9;
-  b = -b;
-  x0 &= b;
-  x1 &= b;
-  x2 &= b;
-  x3 &= b;
-  x4 &= b;
-  x5 &= b;
-  x6 &= b;
-  x7 &= b;
-  x8 &= b;
-  x9 &= b;
-  f[0] = f0 ^ x0;
-  f[1] = f1 ^ x1;
-  f[2] = f2 ^ x2;
-  f[3] = f3 ^ x3;
-  f[4] = f4 ^ x4;
-  f[5] = f5 ^ x5;
-  f[6] = f6 ^ x6;
-  f[7] = f7 ^ x7;
-  f[8] = f8 ^ x8;
-  f[9] = f9 ^ x9;
-  g[0] = g0 ^ x0;
-  g[1] = g1 ^ x1;
-  g[2] = g2 ^ x2;
-  g[3] = g3 ^ x3;
-  g[4] = g4 ^ x4;
-  g[5] = g5 ^ x5;
-  g[6] = g6 ^ x6;
-  g[7] = g7 ^ x7;
-  g[8] = g8 ^ x8;
-  g[9] = g9 ^ x9;
-}
-
-
-/*
-h = f * 121666
-Can overlap h with f.
-
-Preconditions:
-   |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
-
-Postconditions:
-   |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
-*/
-
-void fe_mul121666(fe h,fe f)
-{
-  int32_t f0 = f[0];
-  int32_t f1 = f[1];
-  int32_t f2 = f[2];
-  int32_t f3 = f[3];
-  int32_t f4 = f[4];
-  int32_t f5 = f[5];
-  int32_t f6 = f[6];
-  int32_t f7 = f[7];
-  int32_t f8 = f[8];
-  int32_t f9 = f[9];
-  int64_t h0 = f0 * (int64_t) 121666;
-  int64_t h1 = f1 * (int64_t) 121666;
-  int64_t h2 = f2 * (int64_t) 121666;
-  int64_t h3 = f3 * (int64_t) 121666;
-  int64_t h4 = f4 * (int64_t) 121666;
-  int64_t h5 = f5 * (int64_t) 121666;
-  int64_t h6 = f6 * (int64_t) 121666;
-  int64_t h7 = f7 * (int64_t) 121666;
-  int64_t h8 = f8 * (int64_t) 121666;
-  int64_t h9 = f9 * (int64_t) 121666;
-  int64_t carry0;
-  int64_t carry1;
-  int64_t carry2;
-  int64_t carry3;
-  int64_t carry4;
-  int64_t carry5;
-  int64_t carry6;
-  int64_t carry7;
-  int64_t carry8;
-  int64_t carry9;
-
-  carry9 = (h9 + (int64_t) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25;
-  carry1 = (h1 + (int64_t) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25;
-  carry3 = (h3 + (int64_t) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25;
-  carry5 = (h5 + (int64_t) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25;
-  carry7 = (h7 + (int64_t) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25;
-
-  carry0 = (h0 + (int64_t) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
-  carry2 = (h2 + (int64_t) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26;
-  carry4 = (h4 + (int64_t) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26;
-  carry6 = (h6 + (int64_t) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26;
-  carry8 = (h8 + (int64_t) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26;
-
-  h[0] = (int32_t)h0;
-  h[1] = (int32_t)h1;
-  h[2] = (int32_t)h2;
-  h[3] = (int32_t)h3;
-  h[4] = (int32_t)h4;
-  h[5] = (int32_t)h5;
-  h[6] = (int32_t)h6;
-  h[7] = (int32_t)h7;
-  h[8] = (int32_t)h8;
-  h[9] = (int32_t)h9;
-}
-
-
-/*
-h = 2 * f * f
-Can overlap h with f.
-
-Preconditions:
-   |f| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc.
-
-Postconditions:
-   |h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc.
-*/
-
-/*
-See fe_mul.c for discussion of implementation strategy.
-*/
-
-void fe_sq2(fe h,const fe f)
-{
-  int32_t f0 = f[0];
-  int32_t f1 = f[1];
-  int32_t f2 = f[2];
-  int32_t f3 = f[3];
-  int32_t f4 = f[4];
-  int32_t f5 = f[5];
-  int32_t f6 = f[6];
-  int32_t f7 = f[7];
-  int32_t f8 = f[8];
-  int32_t f9 = f[9];
-  int32_t f0_2 = 2 * f0;
-  int32_t f1_2 = 2 * f1;
-  int32_t f2_2 = 2 * f2;
-  int32_t f3_2 = 2 * f3;
-  int32_t f4_2 = 2 * f4;
-  int32_t f5_2 = 2 * f5;
-  int32_t f6_2 = 2 * f6;
-  int32_t f7_2 = 2 * f7;
-  int32_t f5_38 = 38 * f5; /* 1.959375*2^30 */
-  int32_t f6_19 = 19 * f6; /* 1.959375*2^30 */
-  int32_t f7_38 = 38 * f7; /* 1.959375*2^30 */
-  int32_t f8_19 = 19 * f8; /* 1.959375*2^30 */
-  int32_t f9_38 = 38 * f9; /* 1.959375*2^30 */
-  int64_t f0f0    = f0   * (int64_t) f0;
-  int64_t f0f1_2  = f0_2 * (int64_t) f1;
-  int64_t f0f2_2  = f0_2 * (int64_t) f2;
-  int64_t f0f3_2  = f0_2 * (int64_t) f3;
-  int64_t f0f4_2  = f0_2 * (int64_t) f4;
-  int64_t f0f5_2  = f0_2 * (int64_t) f5;
-  int64_t f0f6_2  = f0_2 * (int64_t) f6;
-  int64_t f0f7_2  = f0_2 * (int64_t) f7;
-  int64_t f0f8_2  = f0_2 * (int64_t) f8;
-  int64_t f0f9_2  = f0_2 * (int64_t) f9;
-  int64_t f1f1_2  = f1_2 * (int64_t) f1;
-  int64_t f1f2_2  = f1_2 * (int64_t) f2;
-  int64_t f1f3_4  = f1_2 * (int64_t) f3_2;
-  int64_t f1f4_2  = f1_2 * (int64_t) f4;
-  int64_t f1f5_4  = f1_2 * (int64_t) f5_2;
-  int64_t f1f6_2  = f1_2 * (int64_t) f6;
-  int64_t f1f7_4  = f1_2 * (int64_t) f7_2;
-  int64_t f1f8_2  = f1_2 * (int64_t) f8;
-  int64_t f1f9_76 = f1_2 * (int64_t) f9_38;
-  int64_t f2f2    = f2   * (int64_t) f2;
-  int64_t f2f3_2  = f2_2 * (int64_t) f3;
-  int64_t f2f4_2  = f2_2 * (int64_t) f4;
-  int64_t f2f5_2  = f2_2 * (int64_t) f5;
-  int64_t f2f6_2  = f2_2 * (int64_t) f6;
-  int64_t f2f7_2  = f2_2 * (int64_t) f7;
-  int64_t f2f8_38 = f2_2 * (int64_t) f8_19;
-  int64_t f2f9_38 = f2   * (int64_t) f9_38;
-  int64_t f3f3_2  = f3_2 * (int64_t) f3;
-  int64_t f3f4_2  = f3_2 * (int64_t) f4;
-  int64_t f3f5_4  = f3_2 * (int64_t) f5_2;
-  int64_t f3f6_2  = f3_2 * (int64_t) f6;
-  int64_t f3f7_76 = f3_2 * (int64_t) f7_38;
-  int64_t f3f8_38 = f3_2 * (int64_t) f8_19;
-  int64_t f3f9_76 = f3_2 * (int64_t) f9_38;
-  int64_t f4f4    = f4   * (int64_t) f4;
-  int64_t f4f5_2  = f4_2 * (int64_t) f5;
-  int64_t f4f6_38 = f4_2 * (int64_t) f6_19;
-  int64_t f4f7_38 = f4   * (int64_t) f7_38;
-  int64_t f4f8_38 = f4_2 * (int64_t) f8_19;
-  int64_t f4f9_38 = f4   * (int64_t) f9_38;
-  int64_t f5f5_38 = f5   * (int64_t) f5_38;
-  int64_t f5f6_38 = f5_2 * (int64_t) f6_19;
-  int64_t f5f7_76 = f5_2 * (int64_t) f7_38;
-  int64_t f5f8_38 = f5_2 * (int64_t) f8_19;
-  int64_t f5f9_76 = f5_2 * (int64_t) f9_38;
-  int64_t f6f6_19 = f6   * (int64_t) f6_19;
-  int64_t f6f7_38 = f6   * (int64_t) f7_38;
-  int64_t f6f8_38 = f6_2 * (int64_t) f8_19;
-  int64_t f6f9_38 = f6   * (int64_t) f9_38;
-  int64_t f7f7_38 = f7   * (int64_t) f7_38;
-  int64_t f7f8_38 = f7_2 * (int64_t) f8_19;
-  int64_t f7f9_76 = f7_2 * (int64_t) f9_38;
-  int64_t f8f8_19 = f8   * (int64_t) f8_19;
-  int64_t f8f9_38 = f8   * (int64_t) f9_38;
-  int64_t f9f9_38 = f9   * (int64_t) f9_38;
-  int64_t h0 = f0f0  +f1f9_76+f2f8_38+f3f7_76+f4f6_38+f5f5_38;
-  int64_t h1 = f0f1_2+f2f9_38+f3f8_38+f4f7_38+f5f6_38;
-  int64_t h2 = f0f2_2+f1f1_2 +f3f9_76+f4f8_38+f5f7_76+f6f6_19;
-  int64_t h3 = f0f3_2+f1f2_2 +f4f9_38+f5f8_38+f6f7_38;
-  int64_t h4 = f0f4_2+f1f3_4 +f2f2   +f5f9_76+f6f8_38+f7f7_38;
-  int64_t h5 = f0f5_2+f1f4_2 +f2f3_2 +f6f9_38+f7f8_38;
-  int64_t h6 = f0f6_2+f1f5_4 +f2f4_2 +f3f3_2 +f7f9_76+f8f8_19;
-  int64_t h7 = f0f7_2+f1f6_2 +f2f5_2 +f3f4_2 +f8f9_38;
-  int64_t h8 = f0f8_2+f1f7_4 +f2f6_2 +f3f5_4 +f4f4   +f9f9_38;
-  int64_t h9 = f0f9_2+f1f8_2 +f2f7_2 +f3f6_2 +f4f5_2;
-  int64_t carry0;
-  int64_t carry1;
-  int64_t carry2;
-  int64_t carry3;
-  int64_t carry4;
-  int64_t carry5;
-  int64_t carry6;
-  int64_t carry7;
-  int64_t carry8;
-  int64_t carry9;
-
-  h0 += h0;
-  h1 += h1;
-  h2 += h2;
-  h3 += h3;
-  h4 += h4;
-  h5 += h5;
-  h6 += h6;
-  h7 += h7;
-  h8 += h8;
-  h9 += h9;
-
-  carry0 = (h0 + (int64_t) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
-  carry4 = (h4 + (int64_t) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26;
-
-  carry1 = (h1 + (int64_t) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25;
-  carry5 = (h5 + (int64_t) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25;
-
-  carry2 = (h2 + (int64_t) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26;
-  carry6 = (h6 + (int64_t) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26;
-
-  carry3 = (h3 + (int64_t) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25;
-  carry7 = (h7 + (int64_t) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25;
-
-  carry4 = (h4 + (int64_t) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26;
-  carry8 = (h8 + (int64_t) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26;
-
-  carry9 = (h9 + (int64_t) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25;
-
-  carry0 = (h0 + (int64_t) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
-
-  h[0] = (int32_t)h0;
-  h[1] = (int32_t)h1;
-  h[2] = (int32_t)h2;
-  h[3] = (int32_t)h3;
-  h[4] = (int32_t)h4;
-  h[5] = (int32_t)h5;
-  h[6] = (int32_t)h6;
-  h[7] = (int32_t)h7;
-  h[8] = (int32_t)h8;
-  h[9] = (int32_t)h9;
-}
-
-
-void fe_pow22523(fe out,const fe z)
-{
-  fe t0;
-  fe t1;
-  fe t2;
-  int i;
-
-  fe_sq(t0,z); for (i = 1;i < 1;++i) fe_sq(t0,t0);
-  fe_sq(t1,t0); for (i = 1;i < 2;++i) fe_sq(t1,t1);
-  fe_mul(t1,z,t1);
-  fe_mul(t0,t0,t1);
-  fe_sq(t0,t0); for (i = 1;i < 1;++i) fe_sq(t0,t0);
-  fe_mul(t0,t1,t0);
-  fe_sq(t1,t0); for (i = 1;i < 5;++i) fe_sq(t1,t1);
-  fe_mul(t0,t1,t0);
-  fe_sq(t1,t0); for (i = 1;i < 10;++i) fe_sq(t1,t1);
-  fe_mul(t1,t1,t0);
-  fe_sq(t2,t1); for (i = 1;i < 20;++i) fe_sq(t2,t2);
-  fe_mul(t1,t2,t1);
-  fe_sq(t1,t1); for (i = 1;i < 10;++i) fe_sq(t1,t1);
-  fe_mul(t0,t1,t0);
-  fe_sq(t1,t0); for (i = 1;i < 50;++i) fe_sq(t1,t1);
-  fe_mul(t1,t1,t0);
-  fe_sq(t2,t1); for (i = 1;i < 100;++i) fe_sq(t2,t2);
-  fe_mul(t1,t2,t1);
-  fe_sq(t1,t1); for (i = 1;i < 50;++i) fe_sq(t1,t1);
-  fe_mul(t0,t1,t0);
-  fe_sq(t0,t0); for (i = 1;i < 2;++i) fe_sq(t0,t0);
-  fe_mul(out,t0,z);
-
-  return;
-}
-
-
-/*
-h = -f
-
-Preconditions:
-   |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
-
-Postconditions:
-   |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
-*/
-
-void fe_neg(fe h,const fe f)
-{
-  int32_t f0 = f[0];
-  int32_t f1 = f[1];
-  int32_t f2 = f[2];
-  int32_t f3 = f[3];
-  int32_t f4 = f[4];
-  int32_t f5 = f[5];
-  int32_t f6 = f[6];
-  int32_t f7 = f[7];
-  int32_t f8 = f[8];
-  int32_t f9 = f[9];
-  int32_t h0 = -f0;
-  int32_t h1 = -f1;
-  int32_t h2 = -f2;
-  int32_t h3 = -f3;
-  int32_t h4 = -f4;
-  int32_t h5 = -f5;
-  int32_t h6 = -f6;
-  int32_t h7 = -f7;
-  int32_t h8 = -f8;
-  int32_t h9 = -f9;
-  h[0] = h0;
-  h[1] = h1;
-  h[2] = h2;
-  h[3] = h3;
-  h[4] = h4;
-  h[5] = h5;
-  h[6] = h6;
-  h[7] = h7;
-  h[8] = h8;
-  h[9] = h9;
-}
-
-
-/*
-Preconditions:
-   |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
-*/
-
-static const unsigned char zero[32];
-
-int fe_isnonzero(const fe f)
-{
-  unsigned char s[32];
-  fe_tobytes(s,f);
-  return ConstantCompare(s,zero,32);
-}
-
-
-/*
-return 1 if f is in {1,3,5,...,q-2}
-return 0 if f is in {0,2,4,...,q-1}
-
-Preconditions:
-   |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
-*/
-
-int fe_isnegative(const fe f)
-{
-  unsigned char s[32];
-  fe_tobytes(s,f);
-  return s[0] & 1;
-}
-
-
-/*
-Replace (f,g) with (g,g) if b == 1;
-replace (f,g) with (f,g) if b == 0.
-
-Preconditions: b in {0,1}.
-*/
-
-void fe_cmov(fe f,const fe g,unsigned int b)
-{
-  int32_t f0 = f[0];
-  int32_t f1 = f[1];
-  int32_t f2 = f[2];
-  int32_t f3 = f[3];
-  int32_t f4 = f[4];
-  int32_t f5 = f[5];
-  int32_t f6 = f[6];
-  int32_t f7 = f[7];
-  int32_t f8 = f[8];
-  int32_t f9 = f[9];
-  int32_t g0 = g[0];
-  int32_t g1 = g[1];
-  int32_t g2 = g[2];
-  int32_t g3 = g[3];
-  int32_t g4 = g[4];
-  int32_t g5 = g[5];
-  int32_t g6 = g[6];
-  int32_t g7 = g[7];
-  int32_t g8 = g[8];
-  int32_t g9 = g[9];
-  int32_t x0 = f0 ^ g0;
-  int32_t x1 = f1 ^ g1;
-  int32_t x2 = f2 ^ g2;
-  int32_t x3 = f3 ^ g3;
-  int32_t x4 = f4 ^ g4;
-  int32_t x5 = f5 ^ g5;
-  int32_t x6 = f6 ^ g6;
-  int32_t x7 = f7 ^ g7;
-  int32_t x8 = f8 ^ g8;
-  int32_t x9 = f9 ^ g9;
-  b = -b;
-  x0 &= b;
-  x1 &= b;
-  x2 &= b;
-  x3 &= b;
-  x4 &= b;
-  x5 &= b;
-  x6 &= b;
-  x7 &= b;
-  x8 &= b;
-  x9 &= b;
-  f[0] = f0 ^ x0;
-  f[1] = f1 ^ x1;
-  f[2] = f2 ^ x2;
-  f[3] = f3 ^ x3;
-  f[4] = f4 ^ x4;
-  f[5] = f5 ^ x5;
-  f[6] = f6 ^ x6;
-  f[7] = f7 ^ x7;
-  f[8] = f8 ^ x8;
-  f[9] = f9 ^ x9;
-}
-#endif /* HAVE ED25519 or CURVE25519 */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mont_small.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mont_small.i
deleted file mode 100755
index c4a339b..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mont_small.i
+++ /dev/null
@@ -1,3860 +0,0 @@
-/* fp_mont_small.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SMALL_MONT_SET
-/* computes x/R == x (mod N) via Montgomery Reduction */
-void fp_montgomery_reduce_small(fp_int *a, fp_int *m, fp_digit mp)
-{
-   fp_digit c[FP_SIZE], *_c, *tmpm, mu, cy;
-   int      oldused, x, y, pa;
-
-#if defined(USE_MEMSET)
-   /* now zero the buff */
-   memset(c, 0, sizeof c);
-#endif
-   pa = m->used;
-
-   /* copy the input */
-   oldused = a->used;
-   for (x = 0; x < oldused; x++) {
-       c[x] = a->dp[x];
-   }
-#if !defined(USE_MEMSET)
-   for (; x < 2*pa+3; x++) {
-       c[x] = 0;
-   }
-#endif
-   MONT_START;
-
-   switch (pa) {
-      case 1:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 2:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 3:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 2; cy   = 0;
-            LOOP_START;
-            _c   = c + 2;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 4:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 2; cy   = 0;
-            LOOP_START;
-            _c   = c + 2;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 3; cy   = 0;
-            LOOP_START;
-            _c   = c + 3;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 5:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 2; cy   = 0;
-            LOOP_START;
-            _c   = c + 2;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 3; cy   = 0;
-            LOOP_START;
-            _c   = c + 3;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 4; cy   = 0;
-            LOOP_START;
-            _c   = c + 4;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 6:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 2; cy   = 0;
-            LOOP_START;
-            _c   = c + 2;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 3; cy   = 0;
-            LOOP_START;
-            _c   = c + 3;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 4; cy   = 0;
-            LOOP_START;
-            _c   = c + 4;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 5; cy   = 0;
-            LOOP_START;
-            _c   = c + 5;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 7:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 2; cy   = 0;
-            LOOP_START;
-            _c   = c + 2;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 3; cy   = 0;
-            LOOP_START;
-            _c   = c + 3;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 4; cy   = 0;
-            LOOP_START;
-            _c   = c + 4;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 5; cy   = 0;
-            LOOP_START;
-            _c   = c + 5;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 6; cy   = 0;
-            LOOP_START;
-            _c   = c + 6;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 8:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 2; cy   = 0;
-            LOOP_START;
-            _c   = c + 2;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 3; cy   = 0;
-            LOOP_START;
-            _c   = c + 3;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 4; cy   = 0;
-            LOOP_START;
-            _c   = c + 4;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 5; cy   = 0;
-            LOOP_START;
-            _c   = c + 5;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 6; cy   = 0;
-            LOOP_START;
-            _c   = c + 6;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 7; cy   = 0;
-            LOOP_START;
-            _c   = c + 7;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 9:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 2; cy   = 0;
-            LOOP_START;
-            _c   = c + 2;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 3; cy   = 0;
-            LOOP_START;
-            _c   = c + 3;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 4; cy   = 0;
-            LOOP_START;
-            _c   = c + 4;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 5; cy   = 0;
-            LOOP_START;
-            _c   = c + 5;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 6; cy   = 0;
-            LOOP_START;
-            _c   = c + 6;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 7; cy   = 0;
-            LOOP_START;
-            _c   = c + 7;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 8; cy   = 0;
-            LOOP_START;
-            _c   = c + 8;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 10:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 2; cy   = 0;
-            LOOP_START;
-            _c   = c + 2;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 3; cy   = 0;
-            LOOP_START;
-            _c   = c + 3;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 4; cy   = 0;
-            LOOP_START;
-            _c   = c + 4;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 5; cy   = 0;
-            LOOP_START;
-            _c   = c + 5;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 6; cy   = 0;
-            LOOP_START;
-            _c   = c + 6;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 7; cy   = 0;
-            LOOP_START;
-            _c   = c + 7;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 8; cy   = 0;
-            LOOP_START;
-            _c   = c + 8;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 9; cy   = 0;
-            LOOP_START;
-            _c   = c + 9;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 11:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 2; cy   = 0;
-            LOOP_START;
-            _c   = c + 2;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 3; cy   = 0;
-            LOOP_START;
-            _c   = c + 3;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 4; cy   = 0;
-            LOOP_START;
-            _c   = c + 4;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 5; cy   = 0;
-            LOOP_START;
-            _c   = c + 5;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 6; cy   = 0;
-            LOOP_START;
-            _c   = c + 6;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 7; cy   = 0;
-            LOOP_START;
-            _c   = c + 7;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 8; cy   = 0;
-            LOOP_START;
-            _c   = c + 8;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 9; cy   = 0;
-            LOOP_START;
-            _c   = c + 9;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 10; cy   = 0;
-            LOOP_START;
-            _c   = c + 10;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 12:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 2; cy   = 0;
-            LOOP_START;
-            _c   = c + 2;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 3; cy   = 0;
-            LOOP_START;
-            _c   = c + 3;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 4; cy   = 0;
-            LOOP_START;
-            _c   = c + 4;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 5; cy   = 0;
-            LOOP_START;
-            _c   = c + 5;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 6; cy   = 0;
-            LOOP_START;
-            _c   = c + 6;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 7; cy   = 0;
-            LOOP_START;
-            _c   = c + 7;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 8; cy   = 0;
-            LOOP_START;
-            _c   = c + 8;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 9; cy   = 0;
-            LOOP_START;
-            _c   = c + 9;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 10; cy   = 0;
-            LOOP_START;
-            _c   = c + 10;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 11; cy   = 0;
-            LOOP_START;
-            _c   = c + 11;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 13:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 2; cy   = 0;
-            LOOP_START;
-            _c   = c + 2;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 3; cy   = 0;
-            LOOP_START;
-            _c   = c + 3;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 4; cy   = 0;
-            LOOP_START;
-            _c   = c + 4;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 5; cy   = 0;
-            LOOP_START;
-            _c   = c + 5;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 6; cy   = 0;
-            LOOP_START;
-            _c   = c + 6;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 7; cy   = 0;
-            LOOP_START;
-            _c   = c + 7;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 8; cy   = 0;
-            LOOP_START;
-            _c   = c + 8;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 9; cy   = 0;
-            LOOP_START;
-            _c   = c + 9;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 10; cy   = 0;
-            LOOP_START;
-            _c   = c + 10;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 11; cy   = 0;
-            LOOP_START;
-            _c   = c + 11;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 12; cy   = 0;
-            LOOP_START;
-            _c   = c + 12;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 14:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 2; cy   = 0;
-            LOOP_START;
-            _c   = c + 2;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 3; cy   = 0;
-            LOOP_START;
-            _c   = c + 3;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 4; cy   = 0;
-            LOOP_START;
-            _c   = c + 4;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 5; cy   = 0;
-            LOOP_START;
-            _c   = c + 5;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 6; cy   = 0;
-            LOOP_START;
-            _c   = c + 6;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 7; cy   = 0;
-            LOOP_START;
-            _c   = c + 7;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 8; cy   = 0;
-            LOOP_START;
-            _c   = c + 8;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 9; cy   = 0;
-            LOOP_START;
-            _c   = c + 9;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 10; cy   = 0;
-            LOOP_START;
-            _c   = c + 10;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 11; cy   = 0;
-            LOOP_START;
-            _c   = c + 11;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 12; cy   = 0;
-            LOOP_START;
-            _c   = c + 12;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 13; cy   = 0;
-            LOOP_START;
-            _c   = c + 13;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 15:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 2; cy   = 0;
-            LOOP_START;
-            _c   = c + 2;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 3; cy   = 0;
-            LOOP_START;
-            _c   = c + 3;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 4; cy   = 0;
-            LOOP_START;
-            _c   = c + 4;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 5; cy   = 0;
-            LOOP_START;
-            _c   = c + 5;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 6; cy   = 0;
-            LOOP_START;
-            _c   = c + 6;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 7; cy   = 0;
-            LOOP_START;
-            _c   = c + 7;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 8; cy   = 0;
-            LOOP_START;
-            _c   = c + 8;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 9; cy   = 0;
-            LOOP_START;
-            _c   = c + 9;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 10; cy   = 0;
-            LOOP_START;
-            _c   = c + 10;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 11; cy   = 0;
-            LOOP_START;
-            _c   = c + 11;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 12; cy   = 0;
-            LOOP_START;
-            _c   = c + 12;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 13; cy   = 0;
-            LOOP_START;
-            _c   = c + 13;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 14; cy   = 0;
-            LOOP_START;
-            _c   = c + 14;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-      case 16:
-            x = 0; cy   = 0;
-            LOOP_START;
-            _c   = c + 0;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 1; cy   = 0;
-            LOOP_START;
-            _c   = c + 1;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 2; cy   = 0;
-            LOOP_START;
-            _c   = c + 2;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 3; cy   = 0;
-            LOOP_START;
-            _c   = c + 3;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 4; cy   = 0;
-            LOOP_START;
-            _c   = c + 4;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 5; cy   = 0;
-            LOOP_START;
-            _c   = c + 5;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 6; cy   = 0;
-            LOOP_START;
-            _c   = c + 6;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 7; cy   = 0;
-            LOOP_START;
-            _c   = c + 7;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 8; cy   = 0;
-            LOOP_START;
-            _c   = c + 8;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 9; cy   = 0;
-            LOOP_START;
-            _c   = c + 9;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 10; cy   = 0;
-            LOOP_START;
-            _c   = c + 10;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 11; cy   = 0;
-            LOOP_START;
-            _c   = c + 11;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 12; cy   = 0;
-            LOOP_START;
-            _c   = c + 12;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 13; cy   = 0;
-            LOOP_START;
-            _c   = c + 13;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 14; cy   = 0;
-            LOOP_START;
-            _c   = c + 14;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-            x = 15; cy   = 0;
-            LOOP_START;
-            _c   = c + 15;
-            tmpm = m->dp;
-#ifdef INNERMUL8
-            INNERMUL8; _c += 8; tmpm += 8;
-            INNERMUL8; _c += 8; tmpm += 8;
-#else
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-            INNERMUL; ++_c;
-#endif
-            LOOP_END;
-            while (cy) {
-               PROPCARRY;
-               ++_c;
-            }
-         break;
-  }
-  /* now copy out */
-  _c   = c + pa;
-  tmpm = a->dp;
-  for (x = 0; x < pa+1; x++) {
-     *tmpm++ = *_c++;
-  }
-
-  for (; x < oldused; x++)   {
-     *tmpm++ = 0;
-  }
-
-  MONT_FINI;
-
-  a->used = pa+1;
-  fp_clamp(a);
-
-  /* if A >= m then A = A - m */
-  if (fp_cmp_mag (a, m) != FP_LT) {
-    s_fp_sub (a, m, a);
-  }
-}
-
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_12.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_12.i
deleted file mode 100755
index b25ce5c..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_12.i
+++ /dev/null
@@ -1,130 +0,0 @@
-/* fp_mul_comba_12.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_MUL12
-void fp_mul_comba12(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[24];
-
-   memcpy(at, A->dp, 12 * sizeof(fp_digit));
-   memcpy(at+12, B->dp, 12 * sizeof(fp_digit));
-   COMBA_START;
-
-   COMBA_CLEAR;
-   /* 0 */
-   MULADD(at[0], at[12]); 
-   COMBA_STORE(C->dp[0]);
-   /* 1 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[13]);    MULADD(at[1], at[12]); 
-   COMBA_STORE(C->dp[1]);
-   /* 2 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[14]);    MULADD(at[1], at[13]);    MULADD(at[2], at[12]); 
-   COMBA_STORE(C->dp[2]);
-   /* 3 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[15]);    MULADD(at[1], at[14]);    MULADD(at[2], at[13]);    MULADD(at[3], at[12]); 
-   COMBA_STORE(C->dp[3]);
-   /* 4 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[16]);    MULADD(at[1], at[15]);    MULADD(at[2], at[14]);    MULADD(at[3], at[13]);    MULADD(at[4], at[12]); 
-   COMBA_STORE(C->dp[4]);
-   /* 5 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[17]);    MULADD(at[1], at[16]);    MULADD(at[2], at[15]);    MULADD(at[3], at[14]);    MULADD(at[4], at[13]);    MULADD(at[5], at[12]); 
-   COMBA_STORE(C->dp[5]);
-   /* 6 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[18]);    MULADD(at[1], at[17]);    MULADD(at[2], at[16]);    MULADD(at[3], at[15]);    MULADD(at[4], at[14]);    MULADD(at[5], at[13]);    MULADD(at[6], at[12]); 
-   COMBA_STORE(C->dp[6]);
-   /* 7 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[19]);    MULADD(at[1], at[18]);    MULADD(at[2], at[17]);    MULADD(at[3], at[16]);    MULADD(at[4], at[15]);    MULADD(at[5], at[14]);    MULADD(at[6], at[13]);    MULADD(at[7], at[12]); 
-   COMBA_STORE(C->dp[7]);
-   /* 8 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[20]);    MULADD(at[1], at[19]);    MULADD(at[2], at[18]);    MULADD(at[3], at[17]);    MULADD(at[4], at[16]);    MULADD(at[5], at[15]);    MULADD(at[6], at[14]);    MULADD(at[7], at[13]);    MULADD(at[8], at[12]); 
-   COMBA_STORE(C->dp[8]);
-   /* 9 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[21]);    MULADD(at[1], at[20]);    MULADD(at[2], at[19]);    MULADD(at[3], at[18]);    MULADD(at[4], at[17]);    MULADD(at[5], at[16]);    MULADD(at[6], at[15]);    MULADD(at[7], at[14]);    MULADD(at[8], at[13]);    MULADD(at[9], at[12]); 
-   COMBA_STORE(C->dp[9]);
-   /* 10 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[22]);    MULADD(at[1], at[21]);    MULADD(at[2], at[20]);    MULADD(at[3], at[19]);    MULADD(at[4], at[18]);    MULADD(at[5], at[17]);    MULADD(at[6], at[16]);    MULADD(at[7], at[15]);    MULADD(at[8], at[14]);    MULADD(at[9], at[13]);    MULADD(at[10], at[12]); 
-   COMBA_STORE(C->dp[10]);
-   /* 11 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[23]);    MULADD(at[1], at[22]);    MULADD(at[2], at[21]);    MULADD(at[3], at[20]);    MULADD(at[4], at[19]);    MULADD(at[5], at[18]);    MULADD(at[6], at[17]);    MULADD(at[7], at[16]);    MULADD(at[8], at[15]);    MULADD(at[9], at[14]);    MULADD(at[10], at[13]);    MULADD(at[11], at[12]); 
-   COMBA_STORE(C->dp[11]);
-   /* 12 */
-   COMBA_FORWARD;
-   MULADD(at[1], at[23]);    MULADD(at[2], at[22]);    MULADD(at[3], at[21]);    MULADD(at[4], at[20]);    MULADD(at[5], at[19]);    MULADD(at[6], at[18]);    MULADD(at[7], at[17]);    MULADD(at[8], at[16]);    MULADD(at[9], at[15]);    MULADD(at[10], at[14]);    MULADD(at[11], at[13]); 
-   COMBA_STORE(C->dp[12]);
-   /* 13 */
-   COMBA_FORWARD;
-   MULADD(at[2], at[23]);    MULADD(at[3], at[22]);    MULADD(at[4], at[21]);    MULADD(at[5], at[20]);    MULADD(at[6], at[19]);    MULADD(at[7], at[18]);    MULADD(at[8], at[17]);    MULADD(at[9], at[16]);    MULADD(at[10], at[15]);    MULADD(at[11], at[14]); 
-   COMBA_STORE(C->dp[13]);
-   /* 14 */
-   COMBA_FORWARD;
-   MULADD(at[3], at[23]);    MULADD(at[4], at[22]);    MULADD(at[5], at[21]);    MULADD(at[6], at[20]);    MULADD(at[7], at[19]);    MULADD(at[8], at[18]);    MULADD(at[9], at[17]);    MULADD(at[10], at[16]);    MULADD(at[11], at[15]); 
-   COMBA_STORE(C->dp[14]);
-   /* 15 */
-   COMBA_FORWARD;
-   MULADD(at[4], at[23]);    MULADD(at[5], at[22]);    MULADD(at[6], at[21]);    MULADD(at[7], at[20]);    MULADD(at[8], at[19]);    MULADD(at[9], at[18]);    MULADD(at[10], at[17]);    MULADD(at[11], at[16]); 
-   COMBA_STORE(C->dp[15]);
-   /* 16 */
-   COMBA_FORWARD;
-   MULADD(at[5], at[23]);    MULADD(at[6], at[22]);    MULADD(at[7], at[21]);    MULADD(at[8], at[20]);    MULADD(at[9], at[19]);    MULADD(at[10], at[18]);    MULADD(at[11], at[17]); 
-   COMBA_STORE(C->dp[16]);
-   /* 17 */
-   COMBA_FORWARD;
-   MULADD(at[6], at[23]);    MULADD(at[7], at[22]);    MULADD(at[8], at[21]);    MULADD(at[9], at[20]);    MULADD(at[10], at[19]);    MULADD(at[11], at[18]); 
-   COMBA_STORE(C->dp[17]);
-   /* 18 */
-   COMBA_FORWARD;
-   MULADD(at[7], at[23]);    MULADD(at[8], at[22]);    MULADD(at[9], at[21]);    MULADD(at[10], at[20]);    MULADD(at[11], at[19]); 
-   COMBA_STORE(C->dp[18]);
-   /* 19 */
-   COMBA_FORWARD;
-   MULADD(at[8], at[23]);    MULADD(at[9], at[22]);    MULADD(at[10], at[21]);    MULADD(at[11], at[20]); 
-   COMBA_STORE(C->dp[19]);
-   /* 20 */
-   COMBA_FORWARD;
-   MULADD(at[9], at[23]);    MULADD(at[10], at[22]);    MULADD(at[11], at[21]); 
-   COMBA_STORE(C->dp[20]);
-   /* 21 */
-   COMBA_FORWARD;
-   MULADD(at[10], at[23]);    MULADD(at[11], at[22]); 
-   COMBA_STORE(C->dp[21]);
-   /* 22 */
-   COMBA_FORWARD;
-   MULADD(at[11], at[23]); 
-   COMBA_STORE(C->dp[22]);
-   COMBA_STORE2(C->dp[23]);
-   C->used = 24;
-   C->sign = A->sign ^ B->sign;
-   fp_clamp(C);
-   COMBA_FINI;
-}
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_17.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_17.i
deleted file mode 100755
index fe12f06..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_17.i
+++ /dev/null
@@ -1,170 +0,0 @@
-/* fp_mul_comba_17.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_MUL17
-void fp_mul_comba17(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[34];
-
-   memcpy(at, A->dp, 17 * sizeof(fp_digit));
-   memcpy(at+17, B->dp, 17 * sizeof(fp_digit));
-   COMBA_START;
-
-   COMBA_CLEAR;
-   /* 0 */
-   MULADD(at[0], at[17]); 
-   COMBA_STORE(C->dp[0]);
-   /* 1 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[18]);    MULADD(at[1], at[17]); 
-   COMBA_STORE(C->dp[1]);
-   /* 2 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[19]);    MULADD(at[1], at[18]);    MULADD(at[2], at[17]); 
-   COMBA_STORE(C->dp[2]);
-   /* 3 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[20]);    MULADD(at[1], at[19]);    MULADD(at[2], at[18]);    MULADD(at[3], at[17]); 
-   COMBA_STORE(C->dp[3]);
-   /* 4 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[21]);    MULADD(at[1], at[20]);    MULADD(at[2], at[19]);    MULADD(at[3], at[18]);    MULADD(at[4], at[17]); 
-   COMBA_STORE(C->dp[4]);
-   /* 5 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[22]);    MULADD(at[1], at[21]);    MULADD(at[2], at[20]);    MULADD(at[3], at[19]);    MULADD(at[4], at[18]);    MULADD(at[5], at[17]); 
-   COMBA_STORE(C->dp[5]);
-   /* 6 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[23]);    MULADD(at[1], at[22]);    MULADD(at[2], at[21]);    MULADD(at[3], at[20]);    MULADD(at[4], at[19]);    MULADD(at[5], at[18]);    MULADD(at[6], at[17]); 
-   COMBA_STORE(C->dp[6]);
-   /* 7 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[24]);    MULADD(at[1], at[23]);    MULADD(at[2], at[22]);    MULADD(at[3], at[21]);    MULADD(at[4], at[20]);    MULADD(at[5], at[19]);    MULADD(at[6], at[18]);    MULADD(at[7], at[17]); 
-   COMBA_STORE(C->dp[7]);
-   /* 8 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[25]);    MULADD(at[1], at[24]);    MULADD(at[2], at[23]);    MULADD(at[3], at[22]);    MULADD(at[4], at[21]);    MULADD(at[5], at[20]);    MULADD(at[6], at[19]);    MULADD(at[7], at[18]);    MULADD(at[8], at[17]); 
-   COMBA_STORE(C->dp[8]);
-   /* 9 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[26]);    MULADD(at[1], at[25]);    MULADD(at[2], at[24]);    MULADD(at[3], at[23]);    MULADD(at[4], at[22]);    MULADD(at[5], at[21]);    MULADD(at[6], at[20]);    MULADD(at[7], at[19]);    MULADD(at[8], at[18]);    MULADD(at[9], at[17]); 
-   COMBA_STORE(C->dp[9]);
-   /* 10 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[27]);    MULADD(at[1], at[26]);    MULADD(at[2], at[25]);    MULADD(at[3], at[24]);    MULADD(at[4], at[23]);    MULADD(at[5], at[22]);    MULADD(at[6], at[21]);    MULADD(at[7], at[20]);    MULADD(at[8], at[19]);    MULADD(at[9], at[18]);    MULADD(at[10], at[17]); 
-   COMBA_STORE(C->dp[10]);
-   /* 11 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[28]);    MULADD(at[1], at[27]);    MULADD(at[2], at[26]);    MULADD(at[3], at[25]);    MULADD(at[4], at[24]);    MULADD(at[5], at[23]);    MULADD(at[6], at[22]);    MULADD(at[7], at[21]);    MULADD(at[8], at[20]);    MULADD(at[9], at[19]);    MULADD(at[10], at[18]);    MULADD(at[11], at[17]); 
-   COMBA_STORE(C->dp[11]);
-   /* 12 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[29]);    MULADD(at[1], at[28]);    MULADD(at[2], at[27]);    MULADD(at[3], at[26]);    MULADD(at[4], at[25]);    MULADD(at[5], at[24]);    MULADD(at[6], at[23]);    MULADD(at[7], at[22]);    MULADD(at[8], at[21]);    MULADD(at[9], at[20]);    MULADD(at[10], at[19]);    MULADD(at[11], at[18]);    MULADD(at[12], at[17]); 
-   COMBA_STORE(C->dp[12]);
-   /* 13 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[30]);    MULADD(at[1], at[29]);    MULADD(at[2], at[28]);    MULADD(at[3], at[27]);    MULADD(at[4], at[26]);    MULADD(at[5], at[25]);    MULADD(at[6], at[24]);    MULADD(at[7], at[23]);    MULADD(at[8], at[22]);    MULADD(at[9], at[21]);    MULADD(at[10], at[20]);    MULADD(at[11], at[19]);    MULADD(at[12], at[18]);    MULADD(at[13], at[17]); 
-   COMBA_STORE(C->dp[13]);
-   /* 14 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[31]);    MULADD(at[1], at[30]);    MULADD(at[2], at[29]);    MULADD(at[3], at[28]);    MULADD(at[4], at[27]);    MULADD(at[5], at[26]);    MULADD(at[6], at[25]);    MULADD(at[7], at[24]);    MULADD(at[8], at[23]);    MULADD(at[9], at[22]);    MULADD(at[10], at[21]);    MULADD(at[11], at[20]);    MULADD(at[12], at[19]);    MULADD(at[13], at[18]);    MULADD(at[14], at[17]); 
-   COMBA_STORE(C->dp[14]);
-   /* 15 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[32]);    MULADD(at[1], at[31]);    MULADD(at[2], at[30]);    MULADD(at[3], at[29]);    MULADD(at[4], at[28]);    MULADD(at[5], at[27]);    MULADD(at[6], at[26]);    MULADD(at[7], at[25]);    MULADD(at[8], at[24]);    MULADD(at[9], at[23]);    MULADD(at[10], at[22]);    MULADD(at[11], at[21]);    MULADD(at[12], at[20]);    MULADD(at[13], at[19]);    MULADD(at[14], at[18]);    MULADD(at[15], at[17]); 
-   COMBA_STORE(C->dp[15]);
-   /* 16 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[33]);    MULADD(at[1], at[32]);    MULADD(at[2], at[31]);    MULADD(at[3], at[30]);    MULADD(at[4], at[29]);    MULADD(at[5], at[28]);    MULADD(at[6], at[27]);    MULADD(at[7], at[26]);    MULADD(at[8], at[25]);    MULADD(at[9], at[24]);    MULADD(at[10], at[23]);    MULADD(at[11], at[22]);    MULADD(at[12], at[21]);    MULADD(at[13], at[20]);    MULADD(at[14], at[19]);    MULADD(at[15], at[18]);    MULADD(at[16], at[17]); 
-   COMBA_STORE(C->dp[16]);
-   /* 17 */
-   COMBA_FORWARD;
-   MULADD(at[1], at[33]);    MULADD(at[2], at[32]);    MULADD(at[3], at[31]);    MULADD(at[4], at[30]);    MULADD(at[5], at[29]);    MULADD(at[6], at[28]);    MULADD(at[7], at[27]);    MULADD(at[8], at[26]);    MULADD(at[9], at[25]);    MULADD(at[10], at[24]);    MULADD(at[11], at[23]);    MULADD(at[12], at[22]);    MULADD(at[13], at[21]);    MULADD(at[14], at[20]);    MULADD(at[15], at[19]);    MULADD(at[16], at[18]); 
-   COMBA_STORE(C->dp[17]);
-   /* 18 */
-   COMBA_FORWARD;
-   MULADD(at[2], at[33]);    MULADD(at[3], at[32]);    MULADD(at[4], at[31]);    MULADD(at[5], at[30]);    MULADD(at[6], at[29]);    MULADD(at[7], at[28]);    MULADD(at[8], at[27]);    MULADD(at[9], at[26]);    MULADD(at[10], at[25]);    MULADD(at[11], at[24]);    MULADD(at[12], at[23]);    MULADD(at[13], at[22]);    MULADD(at[14], at[21]);    MULADD(at[15], at[20]);    MULADD(at[16], at[19]); 
-   COMBA_STORE(C->dp[18]);
-   /* 19 */
-   COMBA_FORWARD;
-   MULADD(at[3], at[33]);    MULADD(at[4], at[32]);    MULADD(at[5], at[31]);    MULADD(at[6], at[30]);    MULADD(at[7], at[29]);    MULADD(at[8], at[28]);    MULADD(at[9], at[27]);    MULADD(at[10], at[26]);    MULADD(at[11], at[25]);    MULADD(at[12], at[24]);    MULADD(at[13], at[23]);    MULADD(at[14], at[22]);    MULADD(at[15], at[21]);    MULADD(at[16], at[20]); 
-   COMBA_STORE(C->dp[19]);
-   /* 20 */
-   COMBA_FORWARD;
-   MULADD(at[4], at[33]);    MULADD(at[5], at[32]);    MULADD(at[6], at[31]);    MULADD(at[7], at[30]);    MULADD(at[8], at[29]);    MULADD(at[9], at[28]);    MULADD(at[10], at[27]);    MULADD(at[11], at[26]);    MULADD(at[12], at[25]);    MULADD(at[13], at[24]);    MULADD(at[14], at[23]);    MULADD(at[15], at[22]);    MULADD(at[16], at[21]); 
-   COMBA_STORE(C->dp[20]);
-   /* 21 */
-   COMBA_FORWARD;
-   MULADD(at[5], at[33]);    MULADD(at[6], at[32]);    MULADD(at[7], at[31]);    MULADD(at[8], at[30]);    MULADD(at[9], at[29]);    MULADD(at[10], at[28]);    MULADD(at[11], at[27]);    MULADD(at[12], at[26]);    MULADD(at[13], at[25]);    MULADD(at[14], at[24]);    MULADD(at[15], at[23]);    MULADD(at[16], at[22]); 
-   COMBA_STORE(C->dp[21]);
-   /* 22 */
-   COMBA_FORWARD;
-   MULADD(at[6], at[33]);    MULADD(at[7], at[32]);    MULADD(at[8], at[31]);    MULADD(at[9], at[30]);    MULADD(at[10], at[29]);    MULADD(at[11], at[28]);    MULADD(at[12], at[27]);    MULADD(at[13], at[26]);    MULADD(at[14], at[25]);    MULADD(at[15], at[24]);    MULADD(at[16], at[23]); 
-   COMBA_STORE(C->dp[22]);
-   /* 23 */
-   COMBA_FORWARD;
-   MULADD(at[7], at[33]);    MULADD(at[8], at[32]);    MULADD(at[9], at[31]);    MULADD(at[10], at[30]);    MULADD(at[11], at[29]);    MULADD(at[12], at[28]);    MULADD(at[13], at[27]);    MULADD(at[14], at[26]);    MULADD(at[15], at[25]);    MULADD(at[16], at[24]); 
-   COMBA_STORE(C->dp[23]);
-   /* 24 */
-   COMBA_FORWARD;
-   MULADD(at[8], at[33]);    MULADD(at[9], at[32]);    MULADD(at[10], at[31]);    MULADD(at[11], at[30]);    MULADD(at[12], at[29]);    MULADD(at[13], at[28]);    MULADD(at[14], at[27]);    MULADD(at[15], at[26]);    MULADD(at[16], at[25]); 
-   COMBA_STORE(C->dp[24]);
-   /* 25 */
-   COMBA_FORWARD;
-   MULADD(at[9], at[33]);    MULADD(at[10], at[32]);    MULADD(at[11], at[31]);    MULADD(at[12], at[30]);    MULADD(at[13], at[29]);    MULADD(at[14], at[28]);    MULADD(at[15], at[27]);    MULADD(at[16], at[26]); 
-   COMBA_STORE(C->dp[25]);
-   /* 26 */
-   COMBA_FORWARD;
-   MULADD(at[10], at[33]);    MULADD(at[11], at[32]);    MULADD(at[12], at[31]);    MULADD(at[13], at[30]);    MULADD(at[14], at[29]);    MULADD(at[15], at[28]);    MULADD(at[16], at[27]); 
-   COMBA_STORE(C->dp[26]);
-   /* 27 */
-   COMBA_FORWARD;
-   MULADD(at[11], at[33]);    MULADD(at[12], at[32]);    MULADD(at[13], at[31]);    MULADD(at[14], at[30]);    MULADD(at[15], at[29]);    MULADD(at[16], at[28]); 
-   COMBA_STORE(C->dp[27]);
-   /* 28 */
-   COMBA_FORWARD;
-   MULADD(at[12], at[33]);    MULADD(at[13], at[32]);    MULADD(at[14], at[31]);    MULADD(at[15], at[30]);    MULADD(at[16], at[29]); 
-   COMBA_STORE(C->dp[28]);
-   /* 29 */
-   COMBA_FORWARD;
-   MULADD(at[13], at[33]);    MULADD(at[14], at[32]);    MULADD(at[15], at[31]);    MULADD(at[16], at[30]); 
-   COMBA_STORE(C->dp[29]);
-   /* 30 */
-   COMBA_FORWARD;
-   MULADD(at[14], at[33]);    MULADD(at[15], at[32]);    MULADD(at[16], at[31]); 
-   COMBA_STORE(C->dp[30]);
-   /* 31 */
-   COMBA_FORWARD;
-   MULADD(at[15], at[33]);    MULADD(at[16], at[32]); 
-   COMBA_STORE(C->dp[31]);
-   /* 32 */
-   COMBA_FORWARD;
-   MULADD(at[16], at[33]); 
-   COMBA_STORE(C->dp[32]);
-   COMBA_STORE2(C->dp[33]);
-   C->used = 34;
-   C->sign = A->sign ^ B->sign;
-   fp_clamp(C);
-   COMBA_FINI;
-}
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_20.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_20.i
deleted file mode 100755
index cd07e5d..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_20.i
+++ /dev/null
@@ -1,193 +0,0 @@
-/* fp_mul_comba_20.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef TFM_MUL20
-void fp_mul_comba20(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[40];
-   
-   memcpy(at, A->dp, 20 * sizeof(fp_digit));
-   memcpy(at+20, B->dp, 20 * sizeof(fp_digit));
-   COMBA_START;
-
-   COMBA_CLEAR;
-   /* 0 */
-   MULADD(at[0], at[20]); 
-   COMBA_STORE(C->dp[0]);
-   /* 1 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[21]);    MULADD(at[1], at[20]); 
-   COMBA_STORE(C->dp[1]);
-   /* 2 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[22]);    MULADD(at[1], at[21]);    MULADD(at[2], at[20]); 
-   COMBA_STORE(C->dp[2]);
-   /* 3 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[23]);    MULADD(at[1], at[22]);    MULADD(at[2], at[21]);    MULADD(at[3], at[20]); 
-   COMBA_STORE(C->dp[3]);
-   /* 4 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[24]);    MULADD(at[1], at[23]);    MULADD(at[2], at[22]);    MULADD(at[3], at[21]);    MULADD(at[4], at[20]); 
-   COMBA_STORE(C->dp[4]);
-   /* 5 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[25]);    MULADD(at[1], at[24]);    MULADD(at[2], at[23]);    MULADD(at[3], at[22]);    MULADD(at[4], at[21]);    MULADD(at[5], at[20]); 
-   COMBA_STORE(C->dp[5]);
-   /* 6 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[26]);    MULADD(at[1], at[25]);    MULADD(at[2], at[24]);    MULADD(at[3], at[23]);    MULADD(at[4], at[22]);    MULADD(at[5], at[21]);    MULADD(at[6], at[20]); 
-   COMBA_STORE(C->dp[6]);
-   /* 7 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[27]);    MULADD(at[1], at[26]);    MULADD(at[2], at[25]);    MULADD(at[3], at[24]);    MULADD(at[4], at[23]);    MULADD(at[5], at[22]);    MULADD(at[6], at[21]);    MULADD(at[7], at[20]); 
-   COMBA_STORE(C->dp[7]);
-   /* 8 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[28]);    MULADD(at[1], at[27]);    MULADD(at[2], at[26]);    MULADD(at[3], at[25]);    MULADD(at[4], at[24]);    MULADD(at[5], at[23]);    MULADD(at[6], at[22]);    MULADD(at[7], at[21]);    MULADD(at[8], at[20]); 
-   COMBA_STORE(C->dp[8]);
-   /* 9 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[29]);    MULADD(at[1], at[28]);    MULADD(at[2], at[27]);    MULADD(at[3], at[26]);    MULADD(at[4], at[25]);    MULADD(at[5], at[24]);    MULADD(at[6], at[23]);    MULADD(at[7], at[22]);    MULADD(at[8], at[21]);    MULADD(at[9], at[20]); 
-   COMBA_STORE(C->dp[9]);
-   /* 10 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[30]);    MULADD(at[1], at[29]);    MULADD(at[2], at[28]);    MULADD(at[3], at[27]);    MULADD(at[4], at[26]);    MULADD(at[5], at[25]);    MULADD(at[6], at[24]);    MULADD(at[7], at[23]);    MULADD(at[8], at[22]);    MULADD(at[9], at[21]);    MULADD(at[10], at[20]); 
-   COMBA_STORE(C->dp[10]);
-   /* 11 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[31]);    MULADD(at[1], at[30]);    MULADD(at[2], at[29]);    MULADD(at[3], at[28]);    MULADD(at[4], at[27]);    MULADD(at[5], at[26]);    MULADD(at[6], at[25]);    MULADD(at[7], at[24]);    MULADD(at[8], at[23]);    MULADD(at[9], at[22]);    MULADD(at[10], at[21]);    MULADD(at[11], at[20]); 
-   COMBA_STORE(C->dp[11]);
-   /* 12 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[32]);    MULADD(at[1], at[31]);    MULADD(at[2], at[30]);    MULADD(at[3], at[29]);    MULADD(at[4], at[28]);    MULADD(at[5], at[27]);    MULADD(at[6], at[26]);    MULADD(at[7], at[25]);    MULADD(at[8], at[24]);    MULADD(at[9], at[23]);    MULADD(at[10], at[22]);    MULADD(at[11], at[21]);    MULADD(at[12], at[20]); 
-   COMBA_STORE(C->dp[12]);
-   /* 13 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[33]);    MULADD(at[1], at[32]);    MULADD(at[2], at[31]);    MULADD(at[3], at[30]);    MULADD(at[4], at[29]);    MULADD(at[5], at[28]);    MULADD(at[6], at[27]);    MULADD(at[7], at[26]);    MULADD(at[8], at[25]);    MULADD(at[9], at[24]);    MULADD(at[10], at[23]);    MULADD(at[11], at[22]);    MULADD(at[12], at[21]);    MULADD(at[13], at[20]); 
-   COMBA_STORE(C->dp[13]);
-   /* 14 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[34]);    MULADD(at[1], at[33]);    MULADD(at[2], at[32]);    MULADD(at[3], at[31]);    MULADD(at[4], at[30]);    MULADD(at[5], at[29]);    MULADD(at[6], at[28]);    MULADD(at[7], at[27]);    MULADD(at[8], at[26]);    MULADD(at[9], at[25]);    MULADD(at[10], at[24]);    MULADD(at[11], at[23]);    MULADD(at[12], at[22]);    MULADD(at[13], at[21]);    MULADD(at[14], at[20]); 
-   COMBA_STORE(C->dp[14]);
-   /* 15 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[35]);    MULADD(at[1], at[34]);    MULADD(at[2], at[33]);    MULADD(at[3], at[32]);    MULADD(at[4], at[31]);    MULADD(at[5], at[30]);    MULADD(at[6], at[29]);    MULADD(at[7], at[28]);    MULADD(at[8], at[27]);    MULADD(at[9], at[26]);    MULADD(at[10], at[25]);    MULADD(at[11], at[24]);    MULADD(at[12], at[23]);    MULADD(at[13], at[22]);    MULADD(at[14], at[21]);    MULADD(at[15], at[20]); 
-   COMBA_STORE(C->dp[15]);
-   /* 16 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[36]);    MULADD(at[1], at[35]);    MULADD(at[2], at[34]);    MULADD(at[3], at[33]);    MULADD(at[4], at[32]);    MULADD(at[5], at[31]);    MULADD(at[6], at[30]);    MULADD(at[7], at[29]);    MULADD(at[8], at[28]);    MULADD(at[9], at[27]);    MULADD(at[10], at[26]);    MULADD(at[11], at[25]);    MULADD(at[12], at[24]);    MULADD(at[13], at[23]);    MULADD(at[14], at[22]);    MULADD(at[15], at[21]);    MULADD(at[16], at[20]); 
-   COMBA_STORE(C->dp[16]);
-   /* 17 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[37]);    MULADD(at[1], at[36]);    MULADD(at[2], at[35]);    MULADD(at[3], at[34]);    MULADD(at[4], at[33]);    MULADD(at[5], at[32]);    MULADD(at[6], at[31]);    MULADD(at[7], at[30]);    MULADD(at[8], at[29]);    MULADD(at[9], at[28]);    MULADD(at[10], at[27]);    MULADD(at[11], at[26]);    MULADD(at[12], at[25]);    MULADD(at[13], at[24]);    MULADD(at[14], at[23]);    MULADD(at[15], at[22]);    MULADD(at[16], at[21]);    MULADD(at[17], at[20]); 
-   COMBA_STORE(C->dp[17]);
-   /* 18 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[38]);    MULADD(at[1], at[37]);    MULADD(at[2], at[36]);    MULADD(at[3], at[35]);    MULADD(at[4], at[34]);    MULADD(at[5], at[33]);    MULADD(at[6], at[32]);    MULADD(at[7], at[31]);    MULADD(at[8], at[30]);    MULADD(at[9], at[29]);    MULADD(at[10], at[28]);    MULADD(at[11], at[27]);    MULADD(at[12], at[26]);    MULADD(at[13], at[25]);    MULADD(at[14], at[24]);    MULADD(at[15], at[23]);    MULADD(at[16], at[22]);    MULADD(at[17], at[21]);    MULADD(at[18], at[20]); 
-   COMBA_STORE(C->dp[18]);
-   /* 19 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[39]);    MULADD(at[1], at[38]);    MULADD(at[2], at[37]);    MULADD(at[3], at[36]);    MULADD(at[4], at[35]);    MULADD(at[5], at[34]);    MULADD(at[6], at[33]);    MULADD(at[7], at[32]);    MULADD(at[8], at[31]);    MULADD(at[9], at[30]);    MULADD(at[10], at[29]);    MULADD(at[11], at[28]);    MULADD(at[12], at[27]);    MULADD(at[13], at[26]);    MULADD(at[14], at[25]);    MULADD(at[15], at[24]);    MULADD(at[16], at[23]);    MULADD(at[17], at[22]);    MULADD(at[18], at[21]);    MULADD(at[19], at[20]); 
-   COMBA_STORE(C->dp[19]);
-   /* 20 */
-   COMBA_FORWARD;
-   MULADD(at[1], at[39]);    MULADD(at[2], at[38]);    MULADD(at[3], at[37]);    MULADD(at[4], at[36]);    MULADD(at[5], at[35]);    MULADD(at[6], at[34]);    MULADD(at[7], at[33]);    MULADD(at[8], at[32]);    MULADD(at[9], at[31]);    MULADD(at[10], at[30]);    MULADD(at[11], at[29]);    MULADD(at[12], at[28]);    MULADD(at[13], at[27]);    MULADD(at[14], at[26]);    MULADD(at[15], at[25]);    MULADD(at[16], at[24]);    MULADD(at[17], at[23]);    MULADD(at[18], at[22]);    MULADD(at[19], at[21]); 
-   COMBA_STORE(C->dp[20]);
-   /* 21 */
-   COMBA_FORWARD;
-   MULADD(at[2], at[39]);    MULADD(at[3], at[38]);    MULADD(at[4], at[37]);    MULADD(at[5], at[36]);    MULADD(at[6], at[35]);    MULADD(at[7], at[34]);    MULADD(at[8], at[33]);    MULADD(at[9], at[32]);    MULADD(at[10], at[31]);    MULADD(at[11], at[30]);    MULADD(at[12], at[29]);    MULADD(at[13], at[28]);    MULADD(at[14], at[27]);    MULADD(at[15], at[26]);    MULADD(at[16], at[25]);    MULADD(at[17], at[24]);    MULADD(at[18], at[23]);    MULADD(at[19], at[22]); 
-   COMBA_STORE(C->dp[21]);
-   /* 22 */
-   COMBA_FORWARD;
-   MULADD(at[3], at[39]);    MULADD(at[4], at[38]);    MULADD(at[5], at[37]);    MULADD(at[6], at[36]);    MULADD(at[7], at[35]);    MULADD(at[8], at[34]);    MULADD(at[9], at[33]);    MULADD(at[10], at[32]);    MULADD(at[11], at[31]);    MULADD(at[12], at[30]);    MULADD(at[13], at[29]);    MULADD(at[14], at[28]);    MULADD(at[15], at[27]);    MULADD(at[16], at[26]);    MULADD(at[17], at[25]);    MULADD(at[18], at[24]);    MULADD(at[19], at[23]); 
-   COMBA_STORE(C->dp[22]);
-   /* 23 */
-   COMBA_FORWARD;
-   MULADD(at[4], at[39]);    MULADD(at[5], at[38]);    MULADD(at[6], at[37]);    MULADD(at[7], at[36]);    MULADD(at[8], at[35]);    MULADD(at[9], at[34]);    MULADD(at[10], at[33]);    MULADD(at[11], at[32]);    MULADD(at[12], at[31]);    MULADD(at[13], at[30]);    MULADD(at[14], at[29]);    MULADD(at[15], at[28]);    MULADD(at[16], at[27]);    MULADD(at[17], at[26]);    MULADD(at[18], at[25]);    MULADD(at[19], at[24]); 
-   COMBA_STORE(C->dp[23]);
-   /* 24 */
-   COMBA_FORWARD;
-   MULADD(at[5], at[39]);    MULADD(at[6], at[38]);    MULADD(at[7], at[37]);    MULADD(at[8], at[36]);    MULADD(at[9], at[35]);    MULADD(at[10], at[34]);    MULADD(at[11], at[33]);    MULADD(at[12], at[32]);    MULADD(at[13], at[31]);    MULADD(at[14], at[30]);    MULADD(at[15], at[29]);    MULADD(at[16], at[28]);    MULADD(at[17], at[27]);    MULADD(at[18], at[26]);    MULADD(at[19], at[25]); 
-   COMBA_STORE(C->dp[24]);
-   /* 25 */
-   COMBA_FORWARD;
-   MULADD(at[6], at[39]);    MULADD(at[7], at[38]);    MULADD(at[8], at[37]);    MULADD(at[9], at[36]);    MULADD(at[10], at[35]);    MULADD(at[11], at[34]);    MULADD(at[12], at[33]);    MULADD(at[13], at[32]);    MULADD(at[14], at[31]);    MULADD(at[15], at[30]);    MULADD(at[16], at[29]);    MULADD(at[17], at[28]);    MULADD(at[18], at[27]);    MULADD(at[19], at[26]); 
-   COMBA_STORE(C->dp[25]);
-   /* 26 */
-   COMBA_FORWARD;
-   MULADD(at[7], at[39]);    MULADD(at[8], at[38]);    MULADD(at[9], at[37]);    MULADD(at[10], at[36]);    MULADD(at[11], at[35]);    MULADD(at[12], at[34]);    MULADD(at[13], at[33]);    MULADD(at[14], at[32]);    MULADD(at[15], at[31]);    MULADD(at[16], at[30]);    MULADD(at[17], at[29]);    MULADD(at[18], at[28]);    MULADD(at[19], at[27]); 
-   COMBA_STORE(C->dp[26]);
-   /* 27 */
-   COMBA_FORWARD;
-   MULADD(at[8], at[39]);    MULADD(at[9], at[38]);    MULADD(at[10], at[37]);    MULADD(at[11], at[36]);    MULADD(at[12], at[35]);    MULADD(at[13], at[34]);    MULADD(at[14], at[33]);    MULADD(at[15], at[32]);    MULADD(at[16], at[31]);    MULADD(at[17], at[30]);    MULADD(at[18], at[29]);    MULADD(at[19], at[28]); 
-   COMBA_STORE(C->dp[27]);
-   /* 28 */
-   COMBA_FORWARD;
-   MULADD(at[9], at[39]);    MULADD(at[10], at[38]);    MULADD(at[11], at[37]);    MULADD(at[12], at[36]);    MULADD(at[13], at[35]);    MULADD(at[14], at[34]);    MULADD(at[15], at[33]);    MULADD(at[16], at[32]);    MULADD(at[17], at[31]);    MULADD(at[18], at[30]);    MULADD(at[19], at[29]); 
-   COMBA_STORE(C->dp[28]);
-   /* 29 */
-   COMBA_FORWARD;
-   MULADD(at[10], at[39]);    MULADD(at[11], at[38]);    MULADD(at[12], at[37]);    MULADD(at[13], at[36]);    MULADD(at[14], at[35]);    MULADD(at[15], at[34]);    MULADD(at[16], at[33]);    MULADD(at[17], at[32]);    MULADD(at[18], at[31]);    MULADD(at[19], at[30]); 
-   COMBA_STORE(C->dp[29]);
-   /* 30 */
-   COMBA_FORWARD;
-   MULADD(at[11], at[39]);    MULADD(at[12], at[38]);    MULADD(at[13], at[37]);    MULADD(at[14], at[36]);    MULADD(at[15], at[35]);    MULADD(at[16], at[34]);    MULADD(at[17], at[33]);    MULADD(at[18], at[32]);    MULADD(at[19], at[31]); 
-   COMBA_STORE(C->dp[30]);
-   /* 31 */
-   COMBA_FORWARD;
-   MULADD(at[12], at[39]);    MULADD(at[13], at[38]);    MULADD(at[14], at[37]);    MULADD(at[15], at[36]);    MULADD(at[16], at[35]);    MULADD(at[17], at[34]);    MULADD(at[18], at[33]);    MULADD(at[19], at[32]); 
-   COMBA_STORE(C->dp[31]);
-   /* 32 */
-   COMBA_FORWARD;
-   MULADD(at[13], at[39]);    MULADD(at[14], at[38]);    MULADD(at[15], at[37]);    MULADD(at[16], at[36]);    MULADD(at[17], at[35]);    MULADD(at[18], at[34]);    MULADD(at[19], at[33]); 
-   COMBA_STORE(C->dp[32]);
-   /* 33 */
-   COMBA_FORWARD;
-   MULADD(at[14], at[39]);    MULADD(at[15], at[38]);    MULADD(at[16], at[37]);    MULADD(at[17], at[36]);    MULADD(at[18], at[35]);    MULADD(at[19], at[34]); 
-   COMBA_STORE(C->dp[33]);
-   /* 34 */
-   COMBA_FORWARD;
-   MULADD(at[15], at[39]);    MULADD(at[16], at[38]);    MULADD(at[17], at[37]);    MULADD(at[18], at[36]);    MULADD(at[19], at[35]); 
-   COMBA_STORE(C->dp[34]);
-   /* 35 */
-   COMBA_FORWARD;
-   MULADD(at[16], at[39]);    MULADD(at[17], at[38]);    MULADD(at[18], at[37]);    MULADD(at[19], at[36]); 
-   COMBA_STORE(C->dp[35]);
-   /* 36 */
-   COMBA_FORWARD;
-   MULADD(at[17], at[39]);    MULADD(at[18], at[38]);    MULADD(at[19], at[37]); 
-   COMBA_STORE(C->dp[36]);
-   /* 37 */
-   COMBA_FORWARD;
-   MULADD(at[18], at[39]);    MULADD(at[19], at[38]); 
-   COMBA_STORE(C->dp[37]);
-   /* 38 */
-   COMBA_FORWARD;
-   MULADD(at[19], at[39]); 
-   COMBA_STORE(C->dp[38]);
-   COMBA_STORE2(C->dp[39]);
-   C->used = 40;
-   C->sign = A->sign ^ B->sign;
-   fp_clamp(C);
-   COMBA_FINI;
-}
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_24.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_24.i
deleted file mode 100755
index 2576d27..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_24.i
+++ /dev/null
@@ -1,226 +0,0 @@
-/* fp_mul_comba_24.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_MUL24
-void fp_mul_comba24(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[48];
-
-   memcpy(at, A->dp, 24 * sizeof(fp_digit));
-   memcpy(at+24, B->dp, 24 * sizeof(fp_digit));
-   COMBA_START;
-
-   COMBA_CLEAR;
-   /* 0 */
-   MULADD(at[0], at[24]); 
-   COMBA_STORE(C->dp[0]);
-   /* 1 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[25]);    MULADD(at[1], at[24]); 
-   COMBA_STORE(C->dp[1]);
-   /* 2 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[26]);    MULADD(at[1], at[25]);    MULADD(at[2], at[24]); 
-   COMBA_STORE(C->dp[2]);
-   /* 3 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[27]);    MULADD(at[1], at[26]);    MULADD(at[2], at[25]);    MULADD(at[3], at[24]); 
-   COMBA_STORE(C->dp[3]);
-   /* 4 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[28]);    MULADD(at[1], at[27]);    MULADD(at[2], at[26]);    MULADD(at[3], at[25]);    MULADD(at[4], at[24]); 
-   COMBA_STORE(C->dp[4]);
-   /* 5 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[29]);    MULADD(at[1], at[28]);    MULADD(at[2], at[27]);    MULADD(at[3], at[26]);    MULADD(at[4], at[25]);    MULADD(at[5], at[24]); 
-   COMBA_STORE(C->dp[5]);
-   /* 6 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[30]);    MULADD(at[1], at[29]);    MULADD(at[2], at[28]);    MULADD(at[3], at[27]);    MULADD(at[4], at[26]);    MULADD(at[5], at[25]);    MULADD(at[6], at[24]); 
-   COMBA_STORE(C->dp[6]);
-   /* 7 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[31]);    MULADD(at[1], at[30]);    MULADD(at[2], at[29]);    MULADD(at[3], at[28]);    MULADD(at[4], at[27]);    MULADD(at[5], at[26]);    MULADD(at[6], at[25]);    MULADD(at[7], at[24]); 
-   COMBA_STORE(C->dp[7]);
-   /* 8 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[32]);    MULADD(at[1], at[31]);    MULADD(at[2], at[30]);    MULADD(at[3], at[29]);    MULADD(at[4], at[28]);    MULADD(at[5], at[27]);    MULADD(at[6], at[26]);    MULADD(at[7], at[25]);    MULADD(at[8], at[24]); 
-   COMBA_STORE(C->dp[8]);
-   /* 9 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[33]);    MULADD(at[1], at[32]);    MULADD(at[2], at[31]);    MULADD(at[3], at[30]);    MULADD(at[4], at[29]);    MULADD(at[5], at[28]);    MULADD(at[6], at[27]);    MULADD(at[7], at[26]);    MULADD(at[8], at[25]);    MULADD(at[9], at[24]); 
-   COMBA_STORE(C->dp[9]);
-   /* 10 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[34]);    MULADD(at[1], at[33]);    MULADD(at[2], at[32]);    MULADD(at[3], at[31]);    MULADD(at[4], at[30]);    MULADD(at[5], at[29]);    MULADD(at[6], at[28]);    MULADD(at[7], at[27]);    MULADD(at[8], at[26]);    MULADD(at[9], at[25]);    MULADD(at[10], at[24]); 
-   COMBA_STORE(C->dp[10]);
-   /* 11 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[35]);    MULADD(at[1], at[34]);    MULADD(at[2], at[33]);    MULADD(at[3], at[32]);    MULADD(at[4], at[31]);    MULADD(at[5], at[30]);    MULADD(at[6], at[29]);    MULADD(at[7], at[28]);    MULADD(at[8], at[27]);    MULADD(at[9], at[26]);    MULADD(at[10], at[25]);    MULADD(at[11], at[24]); 
-   COMBA_STORE(C->dp[11]);
-   /* 12 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[36]);    MULADD(at[1], at[35]);    MULADD(at[2], at[34]);    MULADD(at[3], at[33]);    MULADD(at[4], at[32]);    MULADD(at[5], at[31]);    MULADD(at[6], at[30]);    MULADD(at[7], at[29]);    MULADD(at[8], at[28]);    MULADD(at[9], at[27]);    MULADD(at[10], at[26]);    MULADD(at[11], at[25]);    MULADD(at[12], at[24]); 
-   COMBA_STORE(C->dp[12]);
-   /* 13 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[37]);    MULADD(at[1], at[36]);    MULADD(at[2], at[35]);    MULADD(at[3], at[34]);    MULADD(at[4], at[33]);    MULADD(at[5], at[32]);    MULADD(at[6], at[31]);    MULADD(at[7], at[30]);    MULADD(at[8], at[29]);    MULADD(at[9], at[28]);    MULADD(at[10], at[27]);    MULADD(at[11], at[26]);    MULADD(at[12], at[25]);    MULADD(at[13], at[24]); 
-   COMBA_STORE(C->dp[13]);
-   /* 14 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[38]);    MULADD(at[1], at[37]);    MULADD(at[2], at[36]);    MULADD(at[3], at[35]);    MULADD(at[4], at[34]);    MULADD(at[5], at[33]);    MULADD(at[6], at[32]);    MULADD(at[7], at[31]);    MULADD(at[8], at[30]);    MULADD(at[9], at[29]);    MULADD(at[10], at[28]);    MULADD(at[11], at[27]);    MULADD(at[12], at[26]);    MULADD(at[13], at[25]);    MULADD(at[14], at[24]); 
-   COMBA_STORE(C->dp[14]);
-   /* 15 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[39]);    MULADD(at[1], at[38]);    MULADD(at[2], at[37]);    MULADD(at[3], at[36]);    MULADD(at[4], at[35]);    MULADD(at[5], at[34]);    MULADD(at[6], at[33]);    MULADD(at[7], at[32]);    MULADD(at[8], at[31]);    MULADD(at[9], at[30]);    MULADD(at[10], at[29]);    MULADD(at[11], at[28]);    MULADD(at[12], at[27]);    MULADD(at[13], at[26]);    MULADD(at[14], at[25]);    MULADD(at[15], at[24]); 
-   COMBA_STORE(C->dp[15]);
-   /* 16 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[40]);    MULADD(at[1], at[39]);    MULADD(at[2], at[38]);    MULADD(at[3], at[37]);    MULADD(at[4], at[36]);    MULADD(at[5], at[35]);    MULADD(at[6], at[34]);    MULADD(at[7], at[33]);    MULADD(at[8], at[32]);    MULADD(at[9], at[31]);    MULADD(at[10], at[30]);    MULADD(at[11], at[29]);    MULADD(at[12], at[28]);    MULADD(at[13], at[27]);    MULADD(at[14], at[26]);    MULADD(at[15], at[25]);    MULADD(at[16], at[24]); 
-   COMBA_STORE(C->dp[16]);
-   /* 17 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[41]);    MULADD(at[1], at[40]);    MULADD(at[2], at[39]);    MULADD(at[3], at[38]);    MULADD(at[4], at[37]);    MULADD(at[5], at[36]);    MULADD(at[6], at[35]);    MULADD(at[7], at[34]);    MULADD(at[8], at[33]);    MULADD(at[9], at[32]);    MULADD(at[10], at[31]);    MULADD(at[11], at[30]);    MULADD(at[12], at[29]);    MULADD(at[13], at[28]);    MULADD(at[14], at[27]);    MULADD(at[15], at[26]);    MULADD(at[16], at[25]);    MULADD(at[17], at[24]); 
-   COMBA_STORE(C->dp[17]);
-   /* 18 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[42]);    MULADD(at[1], at[41]);    MULADD(at[2], at[40]);    MULADD(at[3], at[39]);    MULADD(at[4], at[38]);    MULADD(at[5], at[37]);    MULADD(at[6], at[36]);    MULADD(at[7], at[35]);    MULADD(at[8], at[34]);    MULADD(at[9], at[33]);    MULADD(at[10], at[32]);    MULADD(at[11], at[31]);    MULADD(at[12], at[30]);    MULADD(at[13], at[29]);    MULADD(at[14], at[28]);    MULADD(at[15], at[27]);    MULADD(at[16], at[26]);    MULADD(at[17], at[25]);    MULADD(at[18], at[24]); 
-   COMBA_STORE(C->dp[18]);
-   /* 19 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[43]);    MULADD(at[1], at[42]);    MULADD(at[2], at[41]);    MULADD(at[3], at[40]);    MULADD(at[4], at[39]);    MULADD(at[5], at[38]);    MULADD(at[6], at[37]);    MULADD(at[7], at[36]);    MULADD(at[8], at[35]);    MULADD(at[9], at[34]);    MULADD(at[10], at[33]);    MULADD(at[11], at[32]);    MULADD(at[12], at[31]);    MULADD(at[13], at[30]);    MULADD(at[14], at[29]);    MULADD(at[15], at[28]);    MULADD(at[16], at[27]);    MULADD(at[17], at[26]);    MULADD(at[18], at[25]);    MULADD(at[19], at[24]); 
-   COMBA_STORE(C->dp[19]);
-   /* 20 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[44]);    MULADD(at[1], at[43]);    MULADD(at[2], at[42]);    MULADD(at[3], at[41]);    MULADD(at[4], at[40]);    MULADD(at[5], at[39]);    MULADD(at[6], at[38]);    MULADD(at[7], at[37]);    MULADD(at[8], at[36]);    MULADD(at[9], at[35]);    MULADD(at[10], at[34]);    MULADD(at[11], at[33]);    MULADD(at[12], at[32]);    MULADD(at[13], at[31]);    MULADD(at[14], at[30]);    MULADD(at[15], at[29]);    MULADD(at[16], at[28]);    MULADD(at[17], at[27]);    MULADD(at[18], at[26]);    MULADD(at[19], at[25]);    MULADD(at[20], at[24]); 
-   COMBA_STORE(C->dp[20]);
-   /* 21 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[45]);    MULADD(at[1], at[44]);    MULADD(at[2], at[43]);    MULADD(at[3], at[42]);    MULADD(at[4], at[41]);    MULADD(at[5], at[40]);    MULADD(at[6], at[39]);    MULADD(at[7], at[38]);    MULADD(at[8], at[37]);    MULADD(at[9], at[36]);    MULADD(at[10], at[35]);    MULADD(at[11], at[34]);    MULADD(at[12], at[33]);    MULADD(at[13], at[32]);    MULADD(at[14], at[31]);    MULADD(at[15], at[30]);    MULADD(at[16], at[29]);    MULADD(at[17], at[28]);    MULADD(at[18], at[27]);    MULADD(at[19], at[26]);    MULADD(at[20], at[25]);    MULADD(at[21], at[24]); 
-   COMBA_STORE(C->dp[21]);
-   /* 22 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[46]);    MULADD(at[1], at[45]);    MULADD(at[2], at[44]);    MULADD(at[3], at[43]);    MULADD(at[4], at[42]);    MULADD(at[5], at[41]);    MULADD(at[6], at[40]);    MULADD(at[7], at[39]);    MULADD(at[8], at[38]);    MULADD(at[9], at[37]);    MULADD(at[10], at[36]);    MULADD(at[11], at[35]);    MULADD(at[12], at[34]);    MULADD(at[13], at[33]);    MULADD(at[14], at[32]);    MULADD(at[15], at[31]);    MULADD(at[16], at[30]);    MULADD(at[17], at[29]);    MULADD(at[18], at[28]);    MULADD(at[19], at[27]);    MULADD(at[20], at[26]);    MULADD(at[21], at[25]);    MULADD(at[22], at[24]); 
-   COMBA_STORE(C->dp[22]);
-   /* 23 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[47]);    MULADD(at[1], at[46]);    MULADD(at[2], at[45]);    MULADD(at[3], at[44]);    MULADD(at[4], at[43]);    MULADD(at[5], at[42]);    MULADD(at[6], at[41]);    MULADD(at[7], at[40]);    MULADD(at[8], at[39]);    MULADD(at[9], at[38]);    MULADD(at[10], at[37]);    MULADD(at[11], at[36]);    MULADD(at[12], at[35]);    MULADD(at[13], at[34]);    MULADD(at[14], at[33]);    MULADD(at[15], at[32]);    MULADD(at[16], at[31]);    MULADD(at[17], at[30]);    MULADD(at[18], at[29]);    MULADD(at[19], at[28]);    MULADD(at[20], at[27]);    MULADD(at[21], at[26]);    MULADD(at[22], at[25]);    MULADD(at[23], at[24]); 
-   COMBA_STORE(C->dp[23]);
-   /* 24 */
-   COMBA_FORWARD;
-   MULADD(at[1], at[47]);    MULADD(at[2], at[46]);    MULADD(at[3], at[45]);    MULADD(at[4], at[44]);    MULADD(at[5], at[43]);    MULADD(at[6], at[42]);    MULADD(at[7], at[41]);    MULADD(at[8], at[40]);    MULADD(at[9], at[39]);    MULADD(at[10], at[38]);    MULADD(at[11], at[37]);    MULADD(at[12], at[36]);    MULADD(at[13], at[35]);    MULADD(at[14], at[34]);    MULADD(at[15], at[33]);    MULADD(at[16], at[32]);    MULADD(at[17], at[31]);    MULADD(at[18], at[30]);    MULADD(at[19], at[29]);    MULADD(at[20], at[28]);    MULADD(at[21], at[27]);    MULADD(at[22], at[26]);    MULADD(at[23], at[25]); 
-   COMBA_STORE(C->dp[24]);
-   /* 25 */
-   COMBA_FORWARD;
-   MULADD(at[2], at[47]);    MULADD(at[3], at[46]);    MULADD(at[4], at[45]);    MULADD(at[5], at[44]);    MULADD(at[6], at[43]);    MULADD(at[7], at[42]);    MULADD(at[8], at[41]);    MULADD(at[9], at[40]);    MULADD(at[10], at[39]);    MULADD(at[11], at[38]);    MULADD(at[12], at[37]);    MULADD(at[13], at[36]);    MULADD(at[14], at[35]);    MULADD(at[15], at[34]);    MULADD(at[16], at[33]);    MULADD(at[17], at[32]);    MULADD(at[18], at[31]);    MULADD(at[19], at[30]);    MULADD(at[20], at[29]);    MULADD(at[21], at[28]);    MULADD(at[22], at[27]);    MULADD(at[23], at[26]); 
-   COMBA_STORE(C->dp[25]);
-   /* 26 */
-   COMBA_FORWARD;
-   MULADD(at[3], at[47]);    MULADD(at[4], at[46]);    MULADD(at[5], at[45]);    MULADD(at[6], at[44]);    MULADD(at[7], at[43]);    MULADD(at[8], at[42]);    MULADD(at[9], at[41]);    MULADD(at[10], at[40]);    MULADD(at[11], at[39]);    MULADD(at[12], at[38]);    MULADD(at[13], at[37]);    MULADD(at[14], at[36]);    MULADD(at[15], at[35]);    MULADD(at[16], at[34]);    MULADD(at[17], at[33]);    MULADD(at[18], at[32]);    MULADD(at[19], at[31]);    MULADD(at[20], at[30]);    MULADD(at[21], at[29]);    MULADD(at[22], at[28]);    MULADD(at[23], at[27]); 
-   COMBA_STORE(C->dp[26]);
-   /* 27 */
-   COMBA_FORWARD;
-   MULADD(at[4], at[47]);    MULADD(at[5], at[46]);    MULADD(at[6], at[45]);    MULADD(at[7], at[44]);    MULADD(at[8], at[43]);    MULADD(at[9], at[42]);    MULADD(at[10], at[41]);    MULADD(at[11], at[40]);    MULADD(at[12], at[39]);    MULADD(at[13], at[38]);    MULADD(at[14], at[37]);    MULADD(at[15], at[36]);    MULADD(at[16], at[35]);    MULADD(at[17], at[34]);    MULADD(at[18], at[33]);    MULADD(at[19], at[32]);    MULADD(at[20], at[31]);    MULADD(at[21], at[30]);    MULADD(at[22], at[29]);    MULADD(at[23], at[28]); 
-   COMBA_STORE(C->dp[27]);
-   /* 28 */
-   COMBA_FORWARD;
-   MULADD(at[5], at[47]);    MULADD(at[6], at[46]);    MULADD(at[7], at[45]);    MULADD(at[8], at[44]);    MULADD(at[9], at[43]);    MULADD(at[10], at[42]);    MULADD(at[11], at[41]);    MULADD(at[12], at[40]);    MULADD(at[13], at[39]);    MULADD(at[14], at[38]);    MULADD(at[15], at[37]);    MULADD(at[16], at[36]);    MULADD(at[17], at[35]);    MULADD(at[18], at[34]);    MULADD(at[19], at[33]);    MULADD(at[20], at[32]);    MULADD(at[21], at[31]);    MULADD(at[22], at[30]);    MULADD(at[23], at[29]); 
-   COMBA_STORE(C->dp[28]);
-   /* 29 */
-   COMBA_FORWARD;
-   MULADD(at[6], at[47]);    MULADD(at[7], at[46]);    MULADD(at[8], at[45]);    MULADD(at[9], at[44]);    MULADD(at[10], at[43]);    MULADD(at[11], at[42]);    MULADD(at[12], at[41]);    MULADD(at[13], at[40]);    MULADD(at[14], at[39]);    MULADD(at[15], at[38]);    MULADD(at[16], at[37]);    MULADD(at[17], at[36]);    MULADD(at[18], at[35]);    MULADD(at[19], at[34]);    MULADD(at[20], at[33]);    MULADD(at[21], at[32]);    MULADD(at[22], at[31]);    MULADD(at[23], at[30]); 
-   COMBA_STORE(C->dp[29]);
-   /* 30 */
-   COMBA_FORWARD;
-   MULADD(at[7], at[47]);    MULADD(at[8], at[46]);    MULADD(at[9], at[45]);    MULADD(at[10], at[44]);    MULADD(at[11], at[43]);    MULADD(at[12], at[42]);    MULADD(at[13], at[41]);    MULADD(at[14], at[40]);    MULADD(at[15], at[39]);    MULADD(at[16], at[38]);    MULADD(at[17], at[37]);    MULADD(at[18], at[36]);    MULADD(at[19], at[35]);    MULADD(at[20], at[34]);    MULADD(at[21], at[33]);    MULADD(at[22], at[32]);    MULADD(at[23], at[31]); 
-   COMBA_STORE(C->dp[30]);
-   /* 31 */
-   COMBA_FORWARD;
-   MULADD(at[8], at[47]);    MULADD(at[9], at[46]);    MULADD(at[10], at[45]);    MULADD(at[11], at[44]);    MULADD(at[12], at[43]);    MULADD(at[13], at[42]);    MULADD(at[14], at[41]);    MULADD(at[15], at[40]);    MULADD(at[16], at[39]);    MULADD(at[17], at[38]);    MULADD(at[18], at[37]);    MULADD(at[19], at[36]);    MULADD(at[20], at[35]);    MULADD(at[21], at[34]);    MULADD(at[22], at[33]);    MULADD(at[23], at[32]); 
-   COMBA_STORE(C->dp[31]);
-   /* 32 */
-   COMBA_FORWARD;
-   MULADD(at[9], at[47]);    MULADD(at[10], at[46]);    MULADD(at[11], at[45]);    MULADD(at[12], at[44]);    MULADD(at[13], at[43]);    MULADD(at[14], at[42]);    MULADD(at[15], at[41]);    MULADD(at[16], at[40]);    MULADD(at[17], at[39]);    MULADD(at[18], at[38]);    MULADD(at[19], at[37]);    MULADD(at[20], at[36]);    MULADD(at[21], at[35]);    MULADD(at[22], at[34]);    MULADD(at[23], at[33]); 
-   COMBA_STORE(C->dp[32]);
-   /* 33 */
-   COMBA_FORWARD;
-   MULADD(at[10], at[47]);    MULADD(at[11], at[46]);    MULADD(at[12], at[45]);    MULADD(at[13], at[44]);    MULADD(at[14], at[43]);    MULADD(at[15], at[42]);    MULADD(at[16], at[41]);    MULADD(at[17], at[40]);    MULADD(at[18], at[39]);    MULADD(at[19], at[38]);    MULADD(at[20], at[37]);    MULADD(at[21], at[36]);    MULADD(at[22], at[35]);    MULADD(at[23], at[34]); 
-   COMBA_STORE(C->dp[33]);
-   /* 34 */
-   COMBA_FORWARD;
-   MULADD(at[11], at[47]);    MULADD(at[12], at[46]);    MULADD(at[13], at[45]);    MULADD(at[14], at[44]);    MULADD(at[15], at[43]);    MULADD(at[16], at[42]);    MULADD(at[17], at[41]);    MULADD(at[18], at[40]);    MULADD(at[19], at[39]);    MULADD(at[20], at[38]);    MULADD(at[21], at[37]);    MULADD(at[22], at[36]);    MULADD(at[23], at[35]); 
-   COMBA_STORE(C->dp[34]);
-   /* 35 */
-   COMBA_FORWARD;
-   MULADD(at[12], at[47]);    MULADD(at[13], at[46]);    MULADD(at[14], at[45]);    MULADD(at[15], at[44]);    MULADD(at[16], at[43]);    MULADD(at[17], at[42]);    MULADD(at[18], at[41]);    MULADD(at[19], at[40]);    MULADD(at[20], at[39]);    MULADD(at[21], at[38]);    MULADD(at[22], at[37]);    MULADD(at[23], at[36]); 
-   COMBA_STORE(C->dp[35]);
-   /* 36 */
-   COMBA_FORWARD;
-   MULADD(at[13], at[47]);    MULADD(at[14], at[46]);    MULADD(at[15], at[45]);    MULADD(at[16], at[44]);    MULADD(at[17], at[43]);    MULADD(at[18], at[42]);    MULADD(at[19], at[41]);    MULADD(at[20], at[40]);    MULADD(at[21], at[39]);    MULADD(at[22], at[38]);    MULADD(at[23], at[37]); 
-   COMBA_STORE(C->dp[36]);
-   /* 37 */
-   COMBA_FORWARD;
-   MULADD(at[14], at[47]);    MULADD(at[15], at[46]);    MULADD(at[16], at[45]);    MULADD(at[17], at[44]);    MULADD(at[18], at[43]);    MULADD(at[19], at[42]);    MULADD(at[20], at[41]);    MULADD(at[21], at[40]);    MULADD(at[22], at[39]);    MULADD(at[23], at[38]); 
-   COMBA_STORE(C->dp[37]);
-   /* 38 */
-   COMBA_FORWARD;
-   MULADD(at[15], at[47]);    MULADD(at[16], at[46]);    MULADD(at[17], at[45]);    MULADD(at[18], at[44]);    MULADD(at[19], at[43]);    MULADD(at[20], at[42]);    MULADD(at[21], at[41]);    MULADD(at[22], at[40]);    MULADD(at[23], at[39]); 
-   COMBA_STORE(C->dp[38]);
-   /* 39 */
-   COMBA_FORWARD;
-   MULADD(at[16], at[47]);    MULADD(at[17], at[46]);    MULADD(at[18], at[45]);    MULADD(at[19], at[44]);    MULADD(at[20], at[43]);    MULADD(at[21], at[42]);    MULADD(at[22], at[41]);    MULADD(at[23], at[40]); 
-   COMBA_STORE(C->dp[39]);
-   /* 40 */
-   COMBA_FORWARD;
-   MULADD(at[17], at[47]);    MULADD(at[18], at[46]);    MULADD(at[19], at[45]);    MULADD(at[20], at[44]);    MULADD(at[21], at[43]);    MULADD(at[22], at[42]);    MULADD(at[23], at[41]); 
-   COMBA_STORE(C->dp[40]);
-   /* 41 */
-   COMBA_FORWARD;
-   MULADD(at[18], at[47]);    MULADD(at[19], at[46]);    MULADD(at[20], at[45]);    MULADD(at[21], at[44]);    MULADD(at[22], at[43]);    MULADD(at[23], at[42]); 
-   COMBA_STORE(C->dp[41]);
-   /* 42 */
-   COMBA_FORWARD;
-   MULADD(at[19], at[47]);    MULADD(at[20], at[46]);    MULADD(at[21], at[45]);    MULADD(at[22], at[44]);    MULADD(at[23], at[43]); 
-   COMBA_STORE(C->dp[42]);
-   /* 43 */
-   COMBA_FORWARD;
-   MULADD(at[20], at[47]);    MULADD(at[21], at[46]);    MULADD(at[22], at[45]);    MULADD(at[23], at[44]); 
-   COMBA_STORE(C->dp[43]);
-   /* 44 */
-   COMBA_FORWARD;
-   MULADD(at[21], at[47]);    MULADD(at[22], at[46]);    MULADD(at[23], at[45]); 
-   COMBA_STORE(C->dp[44]);
-   /* 45 */
-   COMBA_FORWARD;
-   MULADD(at[22], at[47]);    MULADD(at[23], at[46]); 
-   COMBA_STORE(C->dp[45]);
-   /* 46 */
-   COMBA_FORWARD;
-   MULADD(at[23], at[47]); 
-   COMBA_STORE(C->dp[46]);
-   COMBA_STORE2(C->dp[47]);
-   C->used = 48;
-   C->sign = A->sign ^ B->sign;
-   fp_clamp(C);
-   COMBA_FINI;
-}
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_28.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_28.i
deleted file mode 100755
index 822dd14..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_28.i
+++ /dev/null
@@ -1,258 +0,0 @@
-/* fp_mul_comba_28.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_MUL28
-void fp_mul_comba28(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[56];
-
-   memcpy(at, A->dp, 28 * sizeof(fp_digit));
-   memcpy(at+28, B->dp, 28 * sizeof(fp_digit));
-   COMBA_START;
-
-   COMBA_CLEAR;
-   /* 0 */
-   MULADD(at[0], at[28]); 
-   COMBA_STORE(C->dp[0]);
-   /* 1 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[29]);    MULADD(at[1], at[28]); 
-   COMBA_STORE(C->dp[1]);
-   /* 2 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[30]);    MULADD(at[1], at[29]);    MULADD(at[2], at[28]); 
-   COMBA_STORE(C->dp[2]);
-   /* 3 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[31]);    MULADD(at[1], at[30]);    MULADD(at[2], at[29]);    MULADD(at[3], at[28]); 
-   COMBA_STORE(C->dp[3]);
-   /* 4 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[32]);    MULADD(at[1], at[31]);    MULADD(at[2], at[30]);    MULADD(at[3], at[29]);    MULADD(at[4], at[28]); 
-   COMBA_STORE(C->dp[4]);
-   /* 5 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[33]);    MULADD(at[1], at[32]);    MULADD(at[2], at[31]);    MULADD(at[3], at[30]);    MULADD(at[4], at[29]);    MULADD(at[5], at[28]); 
-   COMBA_STORE(C->dp[5]);
-   /* 6 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[34]);    MULADD(at[1], at[33]);    MULADD(at[2], at[32]);    MULADD(at[3], at[31]);    MULADD(at[4], at[30]);    MULADD(at[5], at[29]);    MULADD(at[6], at[28]); 
-   COMBA_STORE(C->dp[6]);
-   /* 7 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[35]);    MULADD(at[1], at[34]);    MULADD(at[2], at[33]);    MULADD(at[3], at[32]);    MULADD(at[4], at[31]);    MULADD(at[5], at[30]);    MULADD(at[6], at[29]);    MULADD(at[7], at[28]); 
-   COMBA_STORE(C->dp[7]);
-   /* 8 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[36]);    MULADD(at[1], at[35]);    MULADD(at[2], at[34]);    MULADD(at[3], at[33]);    MULADD(at[4], at[32]);    MULADD(at[5], at[31]);    MULADD(at[6], at[30]);    MULADD(at[7], at[29]);    MULADD(at[8], at[28]); 
-   COMBA_STORE(C->dp[8]);
-   /* 9 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[37]);    MULADD(at[1], at[36]);    MULADD(at[2], at[35]);    MULADD(at[3], at[34]);    MULADD(at[4], at[33]);    MULADD(at[5], at[32]);    MULADD(at[6], at[31]);    MULADD(at[7], at[30]);    MULADD(at[8], at[29]);    MULADD(at[9], at[28]); 
-   COMBA_STORE(C->dp[9]);
-   /* 10 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[38]);    MULADD(at[1], at[37]);    MULADD(at[2], at[36]);    MULADD(at[3], at[35]);    MULADD(at[4], at[34]);    MULADD(at[5], at[33]);    MULADD(at[6], at[32]);    MULADD(at[7], at[31]);    MULADD(at[8], at[30]);    MULADD(at[9], at[29]);    MULADD(at[10], at[28]); 
-   COMBA_STORE(C->dp[10]);
-   /* 11 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[39]);    MULADD(at[1], at[38]);    MULADD(at[2], at[37]);    MULADD(at[3], at[36]);    MULADD(at[4], at[35]);    MULADD(at[5], at[34]);    MULADD(at[6], at[33]);    MULADD(at[7], at[32]);    MULADD(at[8], at[31]);    MULADD(at[9], at[30]);    MULADD(at[10], at[29]);    MULADD(at[11], at[28]); 
-   COMBA_STORE(C->dp[11]);
-   /* 12 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[40]);    MULADD(at[1], at[39]);    MULADD(at[2], at[38]);    MULADD(at[3], at[37]);    MULADD(at[4], at[36]);    MULADD(at[5], at[35]);    MULADD(at[6], at[34]);    MULADD(at[7], at[33]);    MULADD(at[8], at[32]);    MULADD(at[9], at[31]);    MULADD(at[10], at[30]);    MULADD(at[11], at[29]);    MULADD(at[12], at[28]); 
-   COMBA_STORE(C->dp[12]);
-   /* 13 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[41]);    MULADD(at[1], at[40]);    MULADD(at[2], at[39]);    MULADD(at[3], at[38]);    MULADD(at[4], at[37]);    MULADD(at[5], at[36]);    MULADD(at[6], at[35]);    MULADD(at[7], at[34]);    MULADD(at[8], at[33]);    MULADD(at[9], at[32]);    MULADD(at[10], at[31]);    MULADD(at[11], at[30]);    MULADD(at[12], at[29]);    MULADD(at[13], at[28]); 
-   COMBA_STORE(C->dp[13]);
-   /* 14 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[42]);    MULADD(at[1], at[41]);    MULADD(at[2], at[40]);    MULADD(at[3], at[39]);    MULADD(at[4], at[38]);    MULADD(at[5], at[37]);    MULADD(at[6], at[36]);    MULADD(at[7], at[35]);    MULADD(at[8], at[34]);    MULADD(at[9], at[33]);    MULADD(at[10], at[32]);    MULADD(at[11], at[31]);    MULADD(at[12], at[30]);    MULADD(at[13], at[29]);    MULADD(at[14], at[28]); 
-   COMBA_STORE(C->dp[14]);
-   /* 15 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[43]);    MULADD(at[1], at[42]);    MULADD(at[2], at[41]);    MULADD(at[3], at[40]);    MULADD(at[4], at[39]);    MULADD(at[5], at[38]);    MULADD(at[6], at[37]);    MULADD(at[7], at[36]);    MULADD(at[8], at[35]);    MULADD(at[9], at[34]);    MULADD(at[10], at[33]);    MULADD(at[11], at[32]);    MULADD(at[12], at[31]);    MULADD(at[13], at[30]);    MULADD(at[14], at[29]);    MULADD(at[15], at[28]); 
-   COMBA_STORE(C->dp[15]);
-   /* 16 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[44]);    MULADD(at[1], at[43]);    MULADD(at[2], at[42]);    MULADD(at[3], at[41]);    MULADD(at[4], at[40]);    MULADD(at[5], at[39]);    MULADD(at[6], at[38]);    MULADD(at[7], at[37]);    MULADD(at[8], at[36]);    MULADD(at[9], at[35]);    MULADD(at[10], at[34]);    MULADD(at[11], at[33]);    MULADD(at[12], at[32]);    MULADD(at[13], at[31]);    MULADD(at[14], at[30]);    MULADD(at[15], at[29]);    MULADD(at[16], at[28]); 
-   COMBA_STORE(C->dp[16]);
-   /* 17 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[45]);    MULADD(at[1], at[44]);    MULADD(at[2], at[43]);    MULADD(at[3], at[42]);    MULADD(at[4], at[41]);    MULADD(at[5], at[40]);    MULADD(at[6], at[39]);    MULADD(at[7], at[38]);    MULADD(at[8], at[37]);    MULADD(at[9], at[36]);    MULADD(at[10], at[35]);    MULADD(at[11], at[34]);    MULADD(at[12], at[33]);    MULADD(at[13], at[32]);    MULADD(at[14], at[31]);    MULADD(at[15], at[30]);    MULADD(at[16], at[29]);    MULADD(at[17], at[28]); 
-   COMBA_STORE(C->dp[17]);
-   /* 18 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[46]);    MULADD(at[1], at[45]);    MULADD(at[2], at[44]);    MULADD(at[3], at[43]);    MULADD(at[4], at[42]);    MULADD(at[5], at[41]);    MULADD(at[6], at[40]);    MULADD(at[7], at[39]);    MULADD(at[8], at[38]);    MULADD(at[9], at[37]);    MULADD(at[10], at[36]);    MULADD(at[11], at[35]);    MULADD(at[12], at[34]);    MULADD(at[13], at[33]);    MULADD(at[14], at[32]);    MULADD(at[15], at[31]);    MULADD(at[16], at[30]);    MULADD(at[17], at[29]);    MULADD(at[18], at[28]); 
-   COMBA_STORE(C->dp[18]);
-   /* 19 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[47]);    MULADD(at[1], at[46]);    MULADD(at[2], at[45]);    MULADD(at[3], at[44]);    MULADD(at[4], at[43]);    MULADD(at[5], at[42]);    MULADD(at[6], at[41]);    MULADD(at[7], at[40]);    MULADD(at[8], at[39]);    MULADD(at[9], at[38]);    MULADD(at[10], at[37]);    MULADD(at[11], at[36]);    MULADD(at[12], at[35]);    MULADD(at[13], at[34]);    MULADD(at[14], at[33]);    MULADD(at[15], at[32]);    MULADD(at[16], at[31]);    MULADD(at[17], at[30]);    MULADD(at[18], at[29]);    MULADD(at[19], at[28]); 
-   COMBA_STORE(C->dp[19]);
-   /* 20 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[48]);    MULADD(at[1], at[47]);    MULADD(at[2], at[46]);    MULADD(at[3], at[45]);    MULADD(at[4], at[44]);    MULADD(at[5], at[43]);    MULADD(at[6], at[42]);    MULADD(at[7], at[41]);    MULADD(at[8], at[40]);    MULADD(at[9], at[39]);    MULADD(at[10], at[38]);    MULADD(at[11], at[37]);    MULADD(at[12], at[36]);    MULADD(at[13], at[35]);    MULADD(at[14], at[34]);    MULADD(at[15], at[33]);    MULADD(at[16], at[32]);    MULADD(at[17], at[31]);    MULADD(at[18], at[30]);    MULADD(at[19], at[29]);    MULADD(at[20], at[28]); 
-   COMBA_STORE(C->dp[20]);
-   /* 21 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[49]);    MULADD(at[1], at[48]);    MULADD(at[2], at[47]);    MULADD(at[3], at[46]);    MULADD(at[4], at[45]);    MULADD(at[5], at[44]);    MULADD(at[6], at[43]);    MULADD(at[7], at[42]);    MULADD(at[8], at[41]);    MULADD(at[9], at[40]);    MULADD(at[10], at[39]);    MULADD(at[11], at[38]);    MULADD(at[12], at[37]);    MULADD(at[13], at[36]);    MULADD(at[14], at[35]);    MULADD(at[15], at[34]);    MULADD(at[16], at[33]);    MULADD(at[17], at[32]);    MULADD(at[18], at[31]);    MULADD(at[19], at[30]);    MULADD(at[20], at[29]);    MULADD(at[21], at[28]); 
-   COMBA_STORE(C->dp[21]);
-   /* 22 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[50]);    MULADD(at[1], at[49]);    MULADD(at[2], at[48]);    MULADD(at[3], at[47]);    MULADD(at[4], at[46]);    MULADD(at[5], at[45]);    MULADD(at[6], at[44]);    MULADD(at[7], at[43]);    MULADD(at[8], at[42]);    MULADD(at[9], at[41]);    MULADD(at[10], at[40]);    MULADD(at[11], at[39]);    MULADD(at[12], at[38]);    MULADD(at[13], at[37]);    MULADD(at[14], at[36]);    MULADD(at[15], at[35]);    MULADD(at[16], at[34]);    MULADD(at[17], at[33]);    MULADD(at[18], at[32]);    MULADD(at[19], at[31]);    MULADD(at[20], at[30]);    MULADD(at[21], at[29]);    MULADD(at[22], at[28]); 
-   COMBA_STORE(C->dp[22]);
-   /* 23 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[51]);    MULADD(at[1], at[50]);    MULADD(at[2], at[49]);    MULADD(at[3], at[48]);    MULADD(at[4], at[47]);    MULADD(at[5], at[46]);    MULADD(at[6], at[45]);    MULADD(at[7], at[44]);    MULADD(at[8], at[43]);    MULADD(at[9], at[42]);    MULADD(at[10], at[41]);    MULADD(at[11], at[40]);    MULADD(at[12], at[39]);    MULADD(at[13], at[38]);    MULADD(at[14], at[37]);    MULADD(at[15], at[36]);    MULADD(at[16], at[35]);    MULADD(at[17], at[34]);    MULADD(at[18], at[33]);    MULADD(at[19], at[32]);    MULADD(at[20], at[31]);    MULADD(at[21], at[30]);    MULADD(at[22], at[29]);    MULADD(at[23], at[28]); 
-   COMBA_STORE(C->dp[23]);
-   /* 24 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[52]);    MULADD(at[1], at[51]);    MULADD(at[2], at[50]);    MULADD(at[3], at[49]);    MULADD(at[4], at[48]);    MULADD(at[5], at[47]);    MULADD(at[6], at[46]);    MULADD(at[7], at[45]);    MULADD(at[8], at[44]);    MULADD(at[9], at[43]);    MULADD(at[10], at[42]);    MULADD(at[11], at[41]);    MULADD(at[12], at[40]);    MULADD(at[13], at[39]);    MULADD(at[14], at[38]);    MULADD(at[15], at[37]);    MULADD(at[16], at[36]);    MULADD(at[17], at[35]);    MULADD(at[18], at[34]);    MULADD(at[19], at[33]);    MULADD(at[20], at[32]);    MULADD(at[21], at[31]);    MULADD(at[22], at[30]);    MULADD(at[23], at[29]);    MULADD(at[24], at[28]); 
-   COMBA_STORE(C->dp[24]);
-   /* 25 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[53]);    MULADD(at[1], at[52]);    MULADD(at[2], at[51]);    MULADD(at[3], at[50]);    MULADD(at[4], at[49]);    MULADD(at[5], at[48]);    MULADD(at[6], at[47]);    MULADD(at[7], at[46]);    MULADD(at[8], at[45]);    MULADD(at[9], at[44]);    MULADD(at[10], at[43]);    MULADD(at[11], at[42]);    MULADD(at[12], at[41]);    MULADD(at[13], at[40]);    MULADD(at[14], at[39]);    MULADD(at[15], at[38]);    MULADD(at[16], at[37]);    MULADD(at[17], at[36]);    MULADD(at[18], at[35]);    MULADD(at[19], at[34]);    MULADD(at[20], at[33]);    MULADD(at[21], at[32]);    MULADD(at[22], at[31]);    MULADD(at[23], at[30]);    MULADD(at[24], at[29]);    MULADD(at[25], at[28]); 
-   COMBA_STORE(C->dp[25]);
-   /* 26 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[54]);    MULADD(at[1], at[53]);    MULADD(at[2], at[52]);    MULADD(at[3], at[51]);    MULADD(at[4], at[50]);    MULADD(at[5], at[49]);    MULADD(at[6], at[48]);    MULADD(at[7], at[47]);    MULADD(at[8], at[46]);    MULADD(at[9], at[45]);    MULADD(at[10], at[44]);    MULADD(at[11], at[43]);    MULADD(at[12], at[42]);    MULADD(at[13], at[41]);    MULADD(at[14], at[40]);    MULADD(at[15], at[39]);    MULADD(at[16], at[38]);    MULADD(at[17], at[37]);    MULADD(at[18], at[36]);    MULADD(at[19], at[35]);    MULADD(at[20], at[34]);    MULADD(at[21], at[33]);    MULADD(at[22], at[32]);    MULADD(at[23], at[31]);    MULADD(at[24], at[30]);    MULADD(at[25], at[29]);    MULADD(at[26], at[28]); 
-   COMBA_STORE(C->dp[26]);
-   /* 27 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[55]);    MULADD(at[1], at[54]);    MULADD(at[2], at[53]);    MULADD(at[3], at[52]);    MULADD(at[4], at[51]);    MULADD(at[5], at[50]);    MULADD(at[6], at[49]);    MULADD(at[7], at[48]);    MULADD(at[8], at[47]);    MULADD(at[9], at[46]);    MULADD(at[10], at[45]);    MULADD(at[11], at[44]);    MULADD(at[12], at[43]);    MULADD(at[13], at[42]);    MULADD(at[14], at[41]);    MULADD(at[15], at[40]);    MULADD(at[16], at[39]);    MULADD(at[17], at[38]);    MULADD(at[18], at[37]);    MULADD(at[19], at[36]);    MULADD(at[20], at[35]);    MULADD(at[21], at[34]);    MULADD(at[22], at[33]);    MULADD(at[23], at[32]);    MULADD(at[24], at[31]);    MULADD(at[25], at[30]);    MULADD(at[26], at[29]);    MULADD(at[27], at[28]); 
-   COMBA_STORE(C->dp[27]);
-   /* 28 */
-   COMBA_FORWARD;
-   MULADD(at[1], at[55]);    MULADD(at[2], at[54]);    MULADD(at[3], at[53]);    MULADD(at[4], at[52]);    MULADD(at[5], at[51]);    MULADD(at[6], at[50]);    MULADD(at[7], at[49]);    MULADD(at[8], at[48]);    MULADD(at[9], at[47]);    MULADD(at[10], at[46]);    MULADD(at[11], at[45]);    MULADD(at[12], at[44]);    MULADD(at[13], at[43]);    MULADD(at[14], at[42]);    MULADD(at[15], at[41]);    MULADD(at[16], at[40]);    MULADD(at[17], at[39]);    MULADD(at[18], at[38]);    MULADD(at[19], at[37]);    MULADD(at[20], at[36]);    MULADD(at[21], at[35]);    MULADD(at[22], at[34]);    MULADD(at[23], at[33]);    MULADD(at[24], at[32]);    MULADD(at[25], at[31]);    MULADD(at[26], at[30]);    MULADD(at[27], at[29]); 
-   COMBA_STORE(C->dp[28]);
-   /* 29 */
-   COMBA_FORWARD;
-   MULADD(at[2], at[55]);    MULADD(at[3], at[54]);    MULADD(at[4], at[53]);    MULADD(at[5], at[52]);    MULADD(at[6], at[51]);    MULADD(at[7], at[50]);    MULADD(at[8], at[49]);    MULADD(at[9], at[48]);    MULADD(at[10], at[47]);    MULADD(at[11], at[46]);    MULADD(at[12], at[45]);    MULADD(at[13], at[44]);    MULADD(at[14], at[43]);    MULADD(at[15], at[42]);    MULADD(at[16], at[41]);    MULADD(at[17], at[40]);    MULADD(at[18], at[39]);    MULADD(at[19], at[38]);    MULADD(at[20], at[37]);    MULADD(at[21], at[36]);    MULADD(at[22], at[35]);    MULADD(at[23], at[34]);    MULADD(at[24], at[33]);    MULADD(at[25], at[32]);    MULADD(at[26], at[31]);    MULADD(at[27], at[30]); 
-   COMBA_STORE(C->dp[29]);
-   /* 30 */
-   COMBA_FORWARD;
-   MULADD(at[3], at[55]);    MULADD(at[4], at[54]);    MULADD(at[5], at[53]);    MULADD(at[6], at[52]);    MULADD(at[7], at[51]);    MULADD(at[8], at[50]);    MULADD(at[9], at[49]);    MULADD(at[10], at[48]);    MULADD(at[11], at[47]);    MULADD(at[12], at[46]);    MULADD(at[13], at[45]);    MULADD(at[14], at[44]);    MULADD(at[15], at[43]);    MULADD(at[16], at[42]);    MULADD(at[17], at[41]);    MULADD(at[18], at[40]);    MULADD(at[19], at[39]);    MULADD(at[20], at[38]);    MULADD(at[21], at[37]);    MULADD(at[22], at[36]);    MULADD(at[23], at[35]);    MULADD(at[24], at[34]);    MULADD(at[25], at[33]);    MULADD(at[26], at[32]);    MULADD(at[27], at[31]); 
-   COMBA_STORE(C->dp[30]);
-   /* 31 */
-   COMBA_FORWARD;
-   MULADD(at[4], at[55]);    MULADD(at[5], at[54]);    MULADD(at[6], at[53]);    MULADD(at[7], at[52]);    MULADD(at[8], at[51]);    MULADD(at[9], at[50]);    MULADD(at[10], at[49]);    MULADD(at[11], at[48]);    MULADD(at[12], at[47]);    MULADD(at[13], at[46]);    MULADD(at[14], at[45]);    MULADD(at[15], at[44]);    MULADD(at[16], at[43]);    MULADD(at[17], at[42]);    MULADD(at[18], at[41]);    MULADD(at[19], at[40]);    MULADD(at[20], at[39]);    MULADD(at[21], at[38]);    MULADD(at[22], at[37]);    MULADD(at[23], at[36]);    MULADD(at[24], at[35]);    MULADD(at[25], at[34]);    MULADD(at[26], at[33]);    MULADD(at[27], at[32]); 
-   COMBA_STORE(C->dp[31]);
-   /* 32 */
-   COMBA_FORWARD;
-   MULADD(at[5], at[55]);    MULADD(at[6], at[54]);    MULADD(at[7], at[53]);    MULADD(at[8], at[52]);    MULADD(at[9], at[51]);    MULADD(at[10], at[50]);    MULADD(at[11], at[49]);    MULADD(at[12], at[48]);    MULADD(at[13], at[47]);    MULADD(at[14], at[46]);    MULADD(at[15], at[45]);    MULADD(at[16], at[44]);    MULADD(at[17], at[43]);    MULADD(at[18], at[42]);    MULADD(at[19], at[41]);    MULADD(at[20], at[40]);    MULADD(at[21], at[39]);    MULADD(at[22], at[38]);    MULADD(at[23], at[37]);    MULADD(at[24], at[36]);    MULADD(at[25], at[35]);    MULADD(at[26], at[34]);    MULADD(at[27], at[33]); 
-   COMBA_STORE(C->dp[32]);
-   /* 33 */
-   COMBA_FORWARD;
-   MULADD(at[6], at[55]);    MULADD(at[7], at[54]);    MULADD(at[8], at[53]);    MULADD(at[9], at[52]);    MULADD(at[10], at[51]);    MULADD(at[11], at[50]);    MULADD(at[12], at[49]);    MULADD(at[13], at[48]);    MULADD(at[14], at[47]);    MULADD(at[15], at[46]);    MULADD(at[16], at[45]);    MULADD(at[17], at[44]);    MULADD(at[18], at[43]);    MULADD(at[19], at[42]);    MULADD(at[20], at[41]);    MULADD(at[21], at[40]);    MULADD(at[22], at[39]);    MULADD(at[23], at[38]);    MULADD(at[24], at[37]);    MULADD(at[25], at[36]);    MULADD(at[26], at[35]);    MULADD(at[27], at[34]); 
-   COMBA_STORE(C->dp[33]);
-   /* 34 */
-   COMBA_FORWARD;
-   MULADD(at[7], at[55]);    MULADD(at[8], at[54]);    MULADD(at[9], at[53]);    MULADD(at[10], at[52]);    MULADD(at[11], at[51]);    MULADD(at[12], at[50]);    MULADD(at[13], at[49]);    MULADD(at[14], at[48]);    MULADD(at[15], at[47]);    MULADD(at[16], at[46]);    MULADD(at[17], at[45]);    MULADD(at[18], at[44]);    MULADD(at[19], at[43]);    MULADD(at[20], at[42]);    MULADD(at[21], at[41]);    MULADD(at[22], at[40]);    MULADD(at[23], at[39]);    MULADD(at[24], at[38]);    MULADD(at[25], at[37]);    MULADD(at[26], at[36]);    MULADD(at[27], at[35]); 
-   COMBA_STORE(C->dp[34]);
-   /* 35 */
-   COMBA_FORWARD;
-   MULADD(at[8], at[55]);    MULADD(at[9], at[54]);    MULADD(at[10], at[53]);    MULADD(at[11], at[52]);    MULADD(at[12], at[51]);    MULADD(at[13], at[50]);    MULADD(at[14], at[49]);    MULADD(at[15], at[48]);    MULADD(at[16], at[47]);    MULADD(at[17], at[46]);    MULADD(at[18], at[45]);    MULADD(at[19], at[44]);    MULADD(at[20], at[43]);    MULADD(at[21], at[42]);    MULADD(at[22], at[41]);    MULADD(at[23], at[40]);    MULADD(at[24], at[39]);    MULADD(at[25], at[38]);    MULADD(at[26], at[37]);    MULADD(at[27], at[36]); 
-   COMBA_STORE(C->dp[35]);
-   /* 36 */
-   COMBA_FORWARD;
-   MULADD(at[9], at[55]);    MULADD(at[10], at[54]);    MULADD(at[11], at[53]);    MULADD(at[12], at[52]);    MULADD(at[13], at[51]);    MULADD(at[14], at[50]);    MULADD(at[15], at[49]);    MULADD(at[16], at[48]);    MULADD(at[17], at[47]);    MULADD(at[18], at[46]);    MULADD(at[19], at[45]);    MULADD(at[20], at[44]);    MULADD(at[21], at[43]);    MULADD(at[22], at[42]);    MULADD(at[23], at[41]);    MULADD(at[24], at[40]);    MULADD(at[25], at[39]);    MULADD(at[26], at[38]);    MULADD(at[27], at[37]); 
-   COMBA_STORE(C->dp[36]);
-   /* 37 */
-   COMBA_FORWARD;
-   MULADD(at[10], at[55]);    MULADD(at[11], at[54]);    MULADD(at[12], at[53]);    MULADD(at[13], at[52]);    MULADD(at[14], at[51]);    MULADD(at[15], at[50]);    MULADD(at[16], at[49]);    MULADD(at[17], at[48]);    MULADD(at[18], at[47]);    MULADD(at[19], at[46]);    MULADD(at[20], at[45]);    MULADD(at[21], at[44]);    MULADD(at[22], at[43]);    MULADD(at[23], at[42]);    MULADD(at[24], at[41]);    MULADD(at[25], at[40]);    MULADD(at[26], at[39]);    MULADD(at[27], at[38]); 
-   COMBA_STORE(C->dp[37]);
-   /* 38 */
-   COMBA_FORWARD;
-   MULADD(at[11], at[55]);    MULADD(at[12], at[54]);    MULADD(at[13], at[53]);    MULADD(at[14], at[52]);    MULADD(at[15], at[51]);    MULADD(at[16], at[50]);    MULADD(at[17], at[49]);    MULADD(at[18], at[48]);    MULADD(at[19], at[47]);    MULADD(at[20], at[46]);    MULADD(at[21], at[45]);    MULADD(at[22], at[44]);    MULADD(at[23], at[43]);    MULADD(at[24], at[42]);    MULADD(at[25], at[41]);    MULADD(at[26], at[40]);    MULADD(at[27], at[39]); 
-   COMBA_STORE(C->dp[38]);
-   /* 39 */
-   COMBA_FORWARD;
-   MULADD(at[12], at[55]);    MULADD(at[13], at[54]);    MULADD(at[14], at[53]);    MULADD(at[15], at[52]);    MULADD(at[16], at[51]);    MULADD(at[17], at[50]);    MULADD(at[18], at[49]);    MULADD(at[19], at[48]);    MULADD(at[20], at[47]);    MULADD(at[21], at[46]);    MULADD(at[22], at[45]);    MULADD(at[23], at[44]);    MULADD(at[24], at[43]);    MULADD(at[25], at[42]);    MULADD(at[26], at[41]);    MULADD(at[27], at[40]); 
-   COMBA_STORE(C->dp[39]);
-   /* 40 */
-   COMBA_FORWARD;
-   MULADD(at[13], at[55]);    MULADD(at[14], at[54]);    MULADD(at[15], at[53]);    MULADD(at[16], at[52]);    MULADD(at[17], at[51]);    MULADD(at[18], at[50]);    MULADD(at[19], at[49]);    MULADD(at[20], at[48]);    MULADD(at[21], at[47]);    MULADD(at[22], at[46]);    MULADD(at[23], at[45]);    MULADD(at[24], at[44]);    MULADD(at[25], at[43]);    MULADD(at[26], at[42]);    MULADD(at[27], at[41]); 
-   COMBA_STORE(C->dp[40]);
-   /* 41 */
-   COMBA_FORWARD;
-   MULADD(at[14], at[55]);    MULADD(at[15], at[54]);    MULADD(at[16], at[53]);    MULADD(at[17], at[52]);    MULADD(at[18], at[51]);    MULADD(at[19], at[50]);    MULADD(at[20], at[49]);    MULADD(at[21], at[48]);    MULADD(at[22], at[47]);    MULADD(at[23], at[46]);    MULADD(at[24], at[45]);    MULADD(at[25], at[44]);    MULADD(at[26], at[43]);    MULADD(at[27], at[42]); 
-   COMBA_STORE(C->dp[41]);
-   /* 42 */
-   COMBA_FORWARD;
-   MULADD(at[15], at[55]);    MULADD(at[16], at[54]);    MULADD(at[17], at[53]);    MULADD(at[18], at[52]);    MULADD(at[19], at[51]);    MULADD(at[20], at[50]);    MULADD(at[21], at[49]);    MULADD(at[22], at[48]);    MULADD(at[23], at[47]);    MULADD(at[24], at[46]);    MULADD(at[25], at[45]);    MULADD(at[26], at[44]);    MULADD(at[27], at[43]); 
-   COMBA_STORE(C->dp[42]);
-   /* 43 */
-   COMBA_FORWARD;
-   MULADD(at[16], at[55]);    MULADD(at[17], at[54]);    MULADD(at[18], at[53]);    MULADD(at[19], at[52]);    MULADD(at[20], at[51]);    MULADD(at[21], at[50]);    MULADD(at[22], at[49]);    MULADD(at[23], at[48]);    MULADD(at[24], at[47]);    MULADD(at[25], at[46]);    MULADD(at[26], at[45]);    MULADD(at[27], at[44]); 
-   COMBA_STORE(C->dp[43]);
-   /* 44 */
-   COMBA_FORWARD;
-   MULADD(at[17], at[55]);    MULADD(at[18], at[54]);    MULADD(at[19], at[53]);    MULADD(at[20], at[52]);    MULADD(at[21], at[51]);    MULADD(at[22], at[50]);    MULADD(at[23], at[49]);    MULADD(at[24], at[48]);    MULADD(at[25], at[47]);    MULADD(at[26], at[46]);    MULADD(at[27], at[45]); 
-   COMBA_STORE(C->dp[44]);
-   /* 45 */
-   COMBA_FORWARD;
-   MULADD(at[18], at[55]);    MULADD(at[19], at[54]);    MULADD(at[20], at[53]);    MULADD(at[21], at[52]);    MULADD(at[22], at[51]);    MULADD(at[23], at[50]);    MULADD(at[24], at[49]);    MULADD(at[25], at[48]);    MULADD(at[26], at[47]);    MULADD(at[27], at[46]); 
-   COMBA_STORE(C->dp[45]);
-   /* 46 */
-   COMBA_FORWARD;
-   MULADD(at[19], at[55]);    MULADD(at[20], at[54]);    MULADD(at[21], at[53]);    MULADD(at[22], at[52]);    MULADD(at[23], at[51]);    MULADD(at[24], at[50]);    MULADD(at[25], at[49]);    MULADD(at[26], at[48]);    MULADD(at[27], at[47]); 
-   COMBA_STORE(C->dp[46]);
-   /* 47 */
-   COMBA_FORWARD;
-   MULADD(at[20], at[55]);    MULADD(at[21], at[54]);    MULADD(at[22], at[53]);    MULADD(at[23], at[52]);    MULADD(at[24], at[51]);    MULADD(at[25], at[50]);    MULADD(at[26], at[49]);    MULADD(at[27], at[48]); 
-   COMBA_STORE(C->dp[47]);
-   /* 48 */
-   COMBA_FORWARD;
-   MULADD(at[21], at[55]);    MULADD(at[22], at[54]);    MULADD(at[23], at[53]);    MULADD(at[24], at[52]);    MULADD(at[25], at[51]);    MULADD(at[26], at[50]);    MULADD(at[27], at[49]); 
-   COMBA_STORE(C->dp[48]);
-   /* 49 */
-   COMBA_FORWARD;
-   MULADD(at[22], at[55]);    MULADD(at[23], at[54]);    MULADD(at[24], at[53]);    MULADD(at[25], at[52]);    MULADD(at[26], at[51]);    MULADD(at[27], at[50]); 
-   COMBA_STORE(C->dp[49]);
-   /* 50 */
-   COMBA_FORWARD;
-   MULADD(at[23], at[55]);    MULADD(at[24], at[54]);    MULADD(at[25], at[53]);    MULADD(at[26], at[52]);    MULADD(at[27], at[51]); 
-   COMBA_STORE(C->dp[50]);
-   /* 51 */
-   COMBA_FORWARD;
-   MULADD(at[24], at[55]);    MULADD(at[25], at[54]);    MULADD(at[26], at[53]);    MULADD(at[27], at[52]); 
-   COMBA_STORE(C->dp[51]);
-   /* 52 */
-   COMBA_FORWARD;
-   MULADD(at[25], at[55]);    MULADD(at[26], at[54]);    MULADD(at[27], at[53]); 
-   COMBA_STORE(C->dp[52]);
-   /* 53 */
-   COMBA_FORWARD;
-   MULADD(at[26], at[55]);    MULADD(at[27], at[54]); 
-   COMBA_STORE(C->dp[53]);
-   /* 54 */
-   COMBA_FORWARD;
-   MULADD(at[27], at[55]); 
-   COMBA_STORE(C->dp[54]);
-   COMBA_STORE2(C->dp[55]);
-   C->used = 56;
-   C->sign = A->sign ^ B->sign;
-   fp_clamp(C);
-   COMBA_FINI;
-}
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_3.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_3.i
deleted file mode 100755
index 440291e..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_3.i
+++ /dev/null
@@ -1,58 +0,0 @@
-/* fp_mul_comba_3.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_MUL3
-void fp_mul_comba3(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[6];
-
-   memcpy(at, A->dp, 3 * sizeof(fp_digit));
-   memcpy(at+3, B->dp, 3 * sizeof(fp_digit));
-   COMBA_START;
-
-   COMBA_CLEAR;
-   /* 0 */
-   MULADD(at[0], at[3]); 
-   COMBA_STORE(C->dp[0]);
-   /* 1 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[4]);    MULADD(at[1], at[3]); 
-   COMBA_STORE(C->dp[1]);
-   /* 2 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[5]);    MULADD(at[1], at[4]);    MULADD(at[2], at[3]); 
-   COMBA_STORE(C->dp[2]);
-   /* 3 */
-   COMBA_FORWARD;
-   MULADD(at[1], at[5]);    MULADD(at[2], at[4]); 
-   COMBA_STORE(C->dp[3]);
-   /* 4 */
-   COMBA_FORWARD;
-   MULADD(at[2], at[5]); 
-   COMBA_STORE(C->dp[4]);
-   COMBA_STORE2(C->dp[5]);
-   C->used = 6;
-   C->sign = A->sign ^ B->sign;
-   fp_clamp(C);
-   COMBA_FINI;
-}
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_32.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_32.i
deleted file mode 100755
index 905028d..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_32.i
+++ /dev/null
@@ -1,304 +0,0 @@
-/* fp_mul_comba_32.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_MUL32
-void fp_mul_comba32(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[64];
-   int out_size;
-
-   out_size = A->used + B->used;
-   memcpy(at, A->dp, 32 * sizeof(fp_digit));
-   memcpy(at+32, B->dp, 32 * sizeof(fp_digit));
-   COMBA_START;
-
-   COMBA_CLEAR;
-   /* 0 */
-   MULADD(at[0], at[32]); 
-   COMBA_STORE(C->dp[0]);
-   /* 1 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[33]);    MULADD(at[1], at[32]); 
-   COMBA_STORE(C->dp[1]);
-   /* 2 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[34]);    MULADD(at[1], at[33]);    MULADD(at[2], at[32]); 
-   COMBA_STORE(C->dp[2]);
-   /* 3 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[35]);    MULADD(at[1], at[34]);    MULADD(at[2], at[33]);    MULADD(at[3], at[32]); 
-   COMBA_STORE(C->dp[3]);
-   /* 4 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[36]);    MULADD(at[1], at[35]);    MULADD(at[2], at[34]);    MULADD(at[3], at[33]);    MULADD(at[4], at[32]); 
-   COMBA_STORE(C->dp[4]);
-   /* 5 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[37]);    MULADD(at[1], at[36]);    MULADD(at[2], at[35]);    MULADD(at[3], at[34]);    MULADD(at[4], at[33]);    MULADD(at[5], at[32]); 
-   COMBA_STORE(C->dp[5]);
-   /* 6 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[38]);    MULADD(at[1], at[37]);    MULADD(at[2], at[36]);    MULADD(at[3], at[35]);    MULADD(at[4], at[34]);    MULADD(at[5], at[33]);    MULADD(at[6], at[32]); 
-   COMBA_STORE(C->dp[6]);
-   /* 7 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[39]);    MULADD(at[1], at[38]);    MULADD(at[2], at[37]);    MULADD(at[3], at[36]);    MULADD(at[4], at[35]);    MULADD(at[5], at[34]);    MULADD(at[6], at[33]);    MULADD(at[7], at[32]); 
-   COMBA_STORE(C->dp[7]);
-   /* 8 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[40]);    MULADD(at[1], at[39]);    MULADD(at[2], at[38]);    MULADD(at[3], at[37]);    MULADD(at[4], at[36]);    MULADD(at[5], at[35]);    MULADD(at[6], at[34]);    MULADD(at[7], at[33]);    MULADD(at[8], at[32]); 
-   COMBA_STORE(C->dp[8]);
-   /* 9 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[41]);    MULADD(at[1], at[40]);    MULADD(at[2], at[39]);    MULADD(at[3], at[38]);    MULADD(at[4], at[37]);    MULADD(at[5], at[36]);    MULADD(at[6], at[35]);    MULADD(at[7], at[34]);    MULADD(at[8], at[33]);    MULADD(at[9], at[32]); 
-   COMBA_STORE(C->dp[9]);
-   /* 10 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[42]);    MULADD(at[1], at[41]);    MULADD(at[2], at[40]);    MULADD(at[3], at[39]);    MULADD(at[4], at[38]);    MULADD(at[5], at[37]);    MULADD(at[6], at[36]);    MULADD(at[7], at[35]);    MULADD(at[8], at[34]);    MULADD(at[9], at[33]);    MULADD(at[10], at[32]); 
-   COMBA_STORE(C->dp[10]);
-   /* 11 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[43]);    MULADD(at[1], at[42]);    MULADD(at[2], at[41]);    MULADD(at[3], at[40]);    MULADD(at[4], at[39]);    MULADD(at[5], at[38]);    MULADD(at[6], at[37]);    MULADD(at[7], at[36]);    MULADD(at[8], at[35]);    MULADD(at[9], at[34]);    MULADD(at[10], at[33]);    MULADD(at[11], at[32]); 
-   COMBA_STORE(C->dp[11]);
-   /* 12 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[44]);    MULADD(at[1], at[43]);    MULADD(at[2], at[42]);    MULADD(at[3], at[41]);    MULADD(at[4], at[40]);    MULADD(at[5], at[39]);    MULADD(at[6], at[38]);    MULADD(at[7], at[37]);    MULADD(at[8], at[36]);    MULADD(at[9], at[35]);    MULADD(at[10], at[34]);    MULADD(at[11], at[33]);    MULADD(at[12], at[32]); 
-   COMBA_STORE(C->dp[12]);
-   /* 13 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[45]);    MULADD(at[1], at[44]);    MULADD(at[2], at[43]);    MULADD(at[3], at[42]);    MULADD(at[4], at[41]);    MULADD(at[5], at[40]);    MULADD(at[6], at[39]);    MULADD(at[7], at[38]);    MULADD(at[8], at[37]);    MULADD(at[9], at[36]);    MULADD(at[10], at[35]);    MULADD(at[11], at[34]);    MULADD(at[12], at[33]);    MULADD(at[13], at[32]); 
-   COMBA_STORE(C->dp[13]);
-   /* 14 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[46]);    MULADD(at[1], at[45]);    MULADD(at[2], at[44]);    MULADD(at[3], at[43]);    MULADD(at[4], at[42]);    MULADD(at[5], at[41]);    MULADD(at[6], at[40]);    MULADD(at[7], at[39]);    MULADD(at[8], at[38]);    MULADD(at[9], at[37]);    MULADD(at[10], at[36]);    MULADD(at[11], at[35]);    MULADD(at[12], at[34]);    MULADD(at[13], at[33]);    MULADD(at[14], at[32]); 
-   COMBA_STORE(C->dp[14]);
-   /* 15 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[47]);    MULADD(at[1], at[46]);    MULADD(at[2], at[45]);    MULADD(at[3], at[44]);    MULADD(at[4], at[43]);    MULADD(at[5], at[42]);    MULADD(at[6], at[41]);    MULADD(at[7], at[40]);    MULADD(at[8], at[39]);    MULADD(at[9], at[38]);    MULADD(at[10], at[37]);    MULADD(at[11], at[36]);    MULADD(at[12], at[35]);    MULADD(at[13], at[34]);    MULADD(at[14], at[33]);    MULADD(at[15], at[32]); 
-   COMBA_STORE(C->dp[15]);
-   /* 16 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[48]);    MULADD(at[1], at[47]);    MULADD(at[2], at[46]);    MULADD(at[3], at[45]);    MULADD(at[4], at[44]);    MULADD(at[5], at[43]);    MULADD(at[6], at[42]);    MULADD(at[7], at[41]);    MULADD(at[8], at[40]);    MULADD(at[9], at[39]);    MULADD(at[10], at[38]);    MULADD(at[11], at[37]);    MULADD(at[12], at[36]);    MULADD(at[13], at[35]);    MULADD(at[14], at[34]);    MULADD(at[15], at[33]);    MULADD(at[16], at[32]); 
-   COMBA_STORE(C->dp[16]);
-   /* 17 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[49]);    MULADD(at[1], at[48]);    MULADD(at[2], at[47]);    MULADD(at[3], at[46]);    MULADD(at[4], at[45]);    MULADD(at[5], at[44]);    MULADD(at[6], at[43]);    MULADD(at[7], at[42]);    MULADD(at[8], at[41]);    MULADD(at[9], at[40]);    MULADD(at[10], at[39]);    MULADD(at[11], at[38]);    MULADD(at[12], at[37]);    MULADD(at[13], at[36]);    MULADD(at[14], at[35]);    MULADD(at[15], at[34]);    MULADD(at[16], at[33]);    MULADD(at[17], at[32]); 
-   COMBA_STORE(C->dp[17]);
-   /* 18 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[50]);    MULADD(at[1], at[49]);    MULADD(at[2], at[48]);    MULADD(at[3], at[47]);    MULADD(at[4], at[46]);    MULADD(at[5], at[45]);    MULADD(at[6], at[44]);    MULADD(at[7], at[43]);    MULADD(at[8], at[42]);    MULADD(at[9], at[41]);    MULADD(at[10], at[40]);    MULADD(at[11], at[39]);    MULADD(at[12], at[38]);    MULADD(at[13], at[37]);    MULADD(at[14], at[36]);    MULADD(at[15], at[35]);    MULADD(at[16], at[34]);    MULADD(at[17], at[33]);    MULADD(at[18], at[32]); 
-   COMBA_STORE(C->dp[18]);
-   /* 19 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[51]);    MULADD(at[1], at[50]);    MULADD(at[2], at[49]);    MULADD(at[3], at[48]);    MULADD(at[4], at[47]);    MULADD(at[5], at[46]);    MULADD(at[6], at[45]);    MULADD(at[7], at[44]);    MULADD(at[8], at[43]);    MULADD(at[9], at[42]);    MULADD(at[10], at[41]);    MULADD(at[11], at[40]);    MULADD(at[12], at[39]);    MULADD(at[13], at[38]);    MULADD(at[14], at[37]);    MULADD(at[15], at[36]);    MULADD(at[16], at[35]);    MULADD(at[17], at[34]);    MULADD(at[18], at[33]);    MULADD(at[19], at[32]); 
-   COMBA_STORE(C->dp[19]);
-   /* 20 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[52]);    MULADD(at[1], at[51]);    MULADD(at[2], at[50]);    MULADD(at[3], at[49]);    MULADD(at[4], at[48]);    MULADD(at[5], at[47]);    MULADD(at[6], at[46]);    MULADD(at[7], at[45]);    MULADD(at[8], at[44]);    MULADD(at[9], at[43]);    MULADD(at[10], at[42]);    MULADD(at[11], at[41]);    MULADD(at[12], at[40]);    MULADD(at[13], at[39]);    MULADD(at[14], at[38]);    MULADD(at[15], at[37]);    MULADD(at[16], at[36]);    MULADD(at[17], at[35]);    MULADD(at[18], at[34]);    MULADD(at[19], at[33]);    MULADD(at[20], at[32]); 
-   COMBA_STORE(C->dp[20]);
-   /* 21 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[53]);    MULADD(at[1], at[52]);    MULADD(at[2], at[51]);    MULADD(at[3], at[50]);    MULADD(at[4], at[49]);    MULADD(at[5], at[48]);    MULADD(at[6], at[47]);    MULADD(at[7], at[46]);    MULADD(at[8], at[45]);    MULADD(at[9], at[44]);    MULADD(at[10], at[43]);    MULADD(at[11], at[42]);    MULADD(at[12], at[41]);    MULADD(at[13], at[40]);    MULADD(at[14], at[39]);    MULADD(at[15], at[38]);    MULADD(at[16], at[37]);    MULADD(at[17], at[36]);    MULADD(at[18], at[35]);    MULADD(at[19], at[34]);    MULADD(at[20], at[33]);    MULADD(at[21], at[32]); 
-   COMBA_STORE(C->dp[21]);
-   /* 22 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[54]);    MULADD(at[1], at[53]);    MULADD(at[2], at[52]);    MULADD(at[3], at[51]);    MULADD(at[4], at[50]);    MULADD(at[5], at[49]);    MULADD(at[6], at[48]);    MULADD(at[7], at[47]);    MULADD(at[8], at[46]);    MULADD(at[9], at[45]);    MULADD(at[10], at[44]);    MULADD(at[11], at[43]);    MULADD(at[12], at[42]);    MULADD(at[13], at[41]);    MULADD(at[14], at[40]);    MULADD(at[15], at[39]);    MULADD(at[16], at[38]);    MULADD(at[17], at[37]);    MULADD(at[18], at[36]);    MULADD(at[19], at[35]);    MULADD(at[20], at[34]);    MULADD(at[21], at[33]);    MULADD(at[22], at[32]); 
-   COMBA_STORE(C->dp[22]);
-   /* 23 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[55]);    MULADD(at[1], at[54]);    MULADD(at[2], at[53]);    MULADD(at[3], at[52]);    MULADD(at[4], at[51]);    MULADD(at[5], at[50]);    MULADD(at[6], at[49]);    MULADD(at[7], at[48]);    MULADD(at[8], at[47]);    MULADD(at[9], at[46]);    MULADD(at[10], at[45]);    MULADD(at[11], at[44]);    MULADD(at[12], at[43]);    MULADD(at[13], at[42]);    MULADD(at[14], at[41]);    MULADD(at[15], at[40]);    MULADD(at[16], at[39]);    MULADD(at[17], at[38]);    MULADD(at[18], at[37]);    MULADD(at[19], at[36]);    MULADD(at[20], at[35]);    MULADD(at[21], at[34]);    MULADD(at[22], at[33]);    MULADD(at[23], at[32]); 
-   COMBA_STORE(C->dp[23]);
-   /* 24 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[56]);    MULADD(at[1], at[55]);    MULADD(at[2], at[54]);    MULADD(at[3], at[53]);    MULADD(at[4], at[52]);    MULADD(at[5], at[51]);    MULADD(at[6], at[50]);    MULADD(at[7], at[49]);    MULADD(at[8], at[48]);    MULADD(at[9], at[47]);    MULADD(at[10], at[46]);    MULADD(at[11], at[45]);    MULADD(at[12], at[44]);    MULADD(at[13], at[43]);    MULADD(at[14], at[42]);    MULADD(at[15], at[41]);    MULADD(at[16], at[40]);    MULADD(at[17], at[39]);    MULADD(at[18], at[38]);    MULADD(at[19], at[37]);    MULADD(at[20], at[36]);    MULADD(at[21], at[35]);    MULADD(at[22], at[34]);    MULADD(at[23], at[33]);    MULADD(at[24], at[32]); 
-   COMBA_STORE(C->dp[24]);
-   /* 25 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[57]);    MULADD(at[1], at[56]);    MULADD(at[2], at[55]);    MULADD(at[3], at[54]);    MULADD(at[4], at[53]);    MULADD(at[5], at[52]);    MULADD(at[6], at[51]);    MULADD(at[7], at[50]);    MULADD(at[8], at[49]);    MULADD(at[9], at[48]);    MULADD(at[10], at[47]);    MULADD(at[11], at[46]);    MULADD(at[12], at[45]);    MULADD(at[13], at[44]);    MULADD(at[14], at[43]);    MULADD(at[15], at[42]);    MULADD(at[16], at[41]);    MULADD(at[17], at[40]);    MULADD(at[18], at[39]);    MULADD(at[19], at[38]);    MULADD(at[20], at[37]);    MULADD(at[21], at[36]);    MULADD(at[22], at[35]);    MULADD(at[23], at[34]);    MULADD(at[24], at[33]);    MULADD(at[25], at[32]); 
-   COMBA_STORE(C->dp[25]);
-   /* 26 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[58]);    MULADD(at[1], at[57]);    MULADD(at[2], at[56]);    MULADD(at[3], at[55]);    MULADD(at[4], at[54]);    MULADD(at[5], at[53]);    MULADD(at[6], at[52]);    MULADD(at[7], at[51]);    MULADD(at[8], at[50]);    MULADD(at[9], at[49]);    MULADD(at[10], at[48]);    MULADD(at[11], at[47]);    MULADD(at[12], at[46]);    MULADD(at[13], at[45]);    MULADD(at[14], at[44]);    MULADD(at[15], at[43]);    MULADD(at[16], at[42]);    MULADD(at[17], at[41]);    MULADD(at[18], at[40]);    MULADD(at[19], at[39]);    MULADD(at[20], at[38]);    MULADD(at[21], at[37]);    MULADD(at[22], at[36]);    MULADD(at[23], at[35]);    MULADD(at[24], at[34]);    MULADD(at[25], at[33]);    MULADD(at[26], at[32]); 
-   COMBA_STORE(C->dp[26]);
-   /* 27 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[59]);    MULADD(at[1], at[58]);    MULADD(at[2], at[57]);    MULADD(at[3], at[56]);    MULADD(at[4], at[55]);    MULADD(at[5], at[54]);    MULADD(at[6], at[53]);    MULADD(at[7], at[52]);    MULADD(at[8], at[51]);    MULADD(at[9], at[50]);    MULADD(at[10], at[49]);    MULADD(at[11], at[48]);    MULADD(at[12], at[47]);    MULADD(at[13], at[46]);    MULADD(at[14], at[45]);    MULADD(at[15], at[44]);    MULADD(at[16], at[43]);    MULADD(at[17], at[42]);    MULADD(at[18], at[41]);    MULADD(at[19], at[40]);    MULADD(at[20], at[39]);    MULADD(at[21], at[38]);    MULADD(at[22], at[37]);    MULADD(at[23], at[36]);    MULADD(at[24], at[35]);    MULADD(at[25], at[34]);    MULADD(at[26], at[33]);    MULADD(at[27], at[32]); 
-   COMBA_STORE(C->dp[27]);
-   /* 28 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[60]);    MULADD(at[1], at[59]);    MULADD(at[2], at[58]);    MULADD(at[3], at[57]);    MULADD(at[4], at[56]);    MULADD(at[5], at[55]);    MULADD(at[6], at[54]);    MULADD(at[7], at[53]);    MULADD(at[8], at[52]);    MULADD(at[9], at[51]);    MULADD(at[10], at[50]);    MULADD(at[11], at[49]);    MULADD(at[12], at[48]);    MULADD(at[13], at[47]);    MULADD(at[14], at[46]);    MULADD(at[15], at[45]);    MULADD(at[16], at[44]);    MULADD(at[17], at[43]);    MULADD(at[18], at[42]);    MULADD(at[19], at[41]);    MULADD(at[20], at[40]);    MULADD(at[21], at[39]);    MULADD(at[22], at[38]);    MULADD(at[23], at[37]);    MULADD(at[24], at[36]);    MULADD(at[25], at[35]);    MULADD(at[26], at[34]);    MULADD(at[27], at[33]);    MULADD(at[28], at[32]); 
-   COMBA_STORE(C->dp[28]);
-   /* 29 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[61]);    MULADD(at[1], at[60]);    MULADD(at[2], at[59]);    MULADD(at[3], at[58]);    MULADD(at[4], at[57]);    MULADD(at[5], at[56]);    MULADD(at[6], at[55]);    MULADD(at[7], at[54]);    MULADD(at[8], at[53]);    MULADD(at[9], at[52]);    MULADD(at[10], at[51]);    MULADD(at[11], at[50]);    MULADD(at[12], at[49]);    MULADD(at[13], at[48]);    MULADD(at[14], at[47]);    MULADD(at[15], at[46]);    MULADD(at[16], at[45]);    MULADD(at[17], at[44]);    MULADD(at[18], at[43]);    MULADD(at[19], at[42]);    MULADD(at[20], at[41]);    MULADD(at[21], at[40]);    MULADD(at[22], at[39]);    MULADD(at[23], at[38]);    MULADD(at[24], at[37]);    MULADD(at[25], at[36]);    MULADD(at[26], at[35]);    MULADD(at[27], at[34]);    MULADD(at[28], at[33]);    MULADD(at[29], at[32]); 
-   COMBA_STORE(C->dp[29]);
-   /* 30 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[62]);    MULADD(at[1], at[61]);    MULADD(at[2], at[60]);    MULADD(at[3], at[59]);    MULADD(at[4], at[58]);    MULADD(at[5], at[57]);    MULADD(at[6], at[56]);    MULADD(at[7], at[55]);    MULADD(at[8], at[54]);    MULADD(at[9], at[53]);    MULADD(at[10], at[52]);    MULADD(at[11], at[51]);    MULADD(at[12], at[50]);    MULADD(at[13], at[49]);    MULADD(at[14], at[48]);    MULADD(at[15], at[47]);    MULADD(at[16], at[46]);    MULADD(at[17], at[45]);    MULADD(at[18], at[44]);    MULADD(at[19], at[43]);    MULADD(at[20], at[42]);    MULADD(at[21], at[41]);    MULADD(at[22], at[40]);    MULADD(at[23], at[39]);    MULADD(at[24], at[38]);    MULADD(at[25], at[37]);    MULADD(at[26], at[36]);    MULADD(at[27], at[35]);    MULADD(at[28], at[34]);    MULADD(at[29], at[33]);    MULADD(at[30], at[32]); 
-   COMBA_STORE(C->dp[30]);
-   /* 31 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[63]);    MULADD(at[1], at[62]);    MULADD(at[2], at[61]);    MULADD(at[3], at[60]);    MULADD(at[4], at[59]);    MULADD(at[5], at[58]);    MULADD(at[6], at[57]);    MULADD(at[7], at[56]);    MULADD(at[8], at[55]);    MULADD(at[9], at[54]);    MULADD(at[10], at[53]);    MULADD(at[11], at[52]);    MULADD(at[12], at[51]);    MULADD(at[13], at[50]);    MULADD(at[14], at[49]);    MULADD(at[15], at[48]);    MULADD(at[16], at[47]);    MULADD(at[17], at[46]);    MULADD(at[18], at[45]);    MULADD(at[19], at[44]);    MULADD(at[20], at[43]);    MULADD(at[21], at[42]);    MULADD(at[22], at[41]);    MULADD(at[23], at[40]);    MULADD(at[24], at[39]);    MULADD(at[25], at[38]);    MULADD(at[26], at[37]);    MULADD(at[27], at[36]);    MULADD(at[28], at[35]);    MULADD(at[29], at[34]);    MULADD(at[30], at[33]);    MULADD(at[31], at[32]); 
-   COMBA_STORE(C->dp[31]);
-   /* 32 */
-   COMBA_FORWARD;
-   MULADD(at[1], at[63]);    MULADD(at[2], at[62]);    MULADD(at[3], at[61]);    MULADD(at[4], at[60]);    MULADD(at[5], at[59]);    MULADD(at[6], at[58]);    MULADD(at[7], at[57]);    MULADD(at[8], at[56]);    MULADD(at[9], at[55]);    MULADD(at[10], at[54]);    MULADD(at[11], at[53]);    MULADD(at[12], at[52]);    MULADD(at[13], at[51]);    MULADD(at[14], at[50]);    MULADD(at[15], at[49]);    MULADD(at[16], at[48]);    MULADD(at[17], at[47]);    MULADD(at[18], at[46]);    MULADD(at[19], at[45]);    MULADD(at[20], at[44]);    MULADD(at[21], at[43]);    MULADD(at[22], at[42]);    MULADD(at[23], at[41]);    MULADD(at[24], at[40]);    MULADD(at[25], at[39]);    MULADD(at[26], at[38]);    MULADD(at[27], at[37]);    MULADD(at[28], at[36]);    MULADD(at[29], at[35]);    MULADD(at[30], at[34]);    MULADD(at[31], at[33]); 
-   COMBA_STORE(C->dp[32]);
-   /* 33 */
-   COMBA_FORWARD;
-   MULADD(at[2], at[63]);    MULADD(at[3], at[62]);    MULADD(at[4], at[61]);    MULADD(at[5], at[60]);    MULADD(at[6], at[59]);    MULADD(at[7], at[58]);    MULADD(at[8], at[57]);    MULADD(at[9], at[56]);    MULADD(at[10], at[55]);    MULADD(at[11], at[54]);    MULADD(at[12], at[53]);    MULADD(at[13], at[52]);    MULADD(at[14], at[51]);    MULADD(at[15], at[50]);    MULADD(at[16], at[49]);    MULADD(at[17], at[48]);    MULADD(at[18], at[47]);    MULADD(at[19], at[46]);    MULADD(at[20], at[45]);    MULADD(at[21], at[44]);    MULADD(at[22], at[43]);    MULADD(at[23], at[42]);    MULADD(at[24], at[41]);    MULADD(at[25], at[40]);    MULADD(at[26], at[39]);    MULADD(at[27], at[38]);    MULADD(at[28], at[37]);    MULADD(at[29], at[36]);    MULADD(at[30], at[35]);    MULADD(at[31], at[34]); 
-   COMBA_STORE(C->dp[33]);
-   /* 34 */
-   COMBA_FORWARD;
-   MULADD(at[3], at[63]);    MULADD(at[4], at[62]);    MULADD(at[5], at[61]);    MULADD(at[6], at[60]);    MULADD(at[7], at[59]);    MULADD(at[8], at[58]);    MULADD(at[9], at[57]);    MULADD(at[10], at[56]);    MULADD(at[11], at[55]);    MULADD(at[12], at[54]);    MULADD(at[13], at[53]);    MULADD(at[14], at[52]);    MULADD(at[15], at[51]);    MULADD(at[16], at[50]);    MULADD(at[17], at[49]);    MULADD(at[18], at[48]);    MULADD(at[19], at[47]);    MULADD(at[20], at[46]);    MULADD(at[21], at[45]);    MULADD(at[22], at[44]);    MULADD(at[23], at[43]);    MULADD(at[24], at[42]);    MULADD(at[25], at[41]);    MULADD(at[26], at[40]);    MULADD(at[27], at[39]);    MULADD(at[28], at[38]);    MULADD(at[29], at[37]);    MULADD(at[30], at[36]);    MULADD(at[31], at[35]); 
-   COMBA_STORE(C->dp[34]);
-   /* 35 */
-   COMBA_FORWARD;
-   MULADD(at[4], at[63]);    MULADD(at[5], at[62]);    MULADD(at[6], at[61]);    MULADD(at[7], at[60]);    MULADD(at[8], at[59]);    MULADD(at[9], at[58]);    MULADD(at[10], at[57]);    MULADD(at[11], at[56]);    MULADD(at[12], at[55]);    MULADD(at[13], at[54]);    MULADD(at[14], at[53]);    MULADD(at[15], at[52]);    MULADD(at[16], at[51]);    MULADD(at[17], at[50]);    MULADD(at[18], at[49]);    MULADD(at[19], at[48]);    MULADD(at[20], at[47]);    MULADD(at[21], at[46]);    MULADD(at[22], at[45]);    MULADD(at[23], at[44]);    MULADD(at[24], at[43]);    MULADD(at[25], at[42]);    MULADD(at[26], at[41]);    MULADD(at[27], at[40]);    MULADD(at[28], at[39]);    MULADD(at[29], at[38]);    MULADD(at[30], at[37]);    MULADD(at[31], at[36]); 
-   COMBA_STORE(C->dp[35]);
-   /* 36 */
-   COMBA_FORWARD;
-   MULADD(at[5], at[63]);    MULADD(at[6], at[62]);    MULADD(at[7], at[61]);    MULADD(at[8], at[60]);    MULADD(at[9], at[59]);    MULADD(at[10], at[58]);    MULADD(at[11], at[57]);    MULADD(at[12], at[56]);    MULADD(at[13], at[55]);    MULADD(at[14], at[54]);    MULADD(at[15], at[53]);    MULADD(at[16], at[52]);    MULADD(at[17], at[51]);    MULADD(at[18], at[50]);    MULADD(at[19], at[49]);    MULADD(at[20], at[48]);    MULADD(at[21], at[47]);    MULADD(at[22], at[46]);    MULADD(at[23], at[45]);    MULADD(at[24], at[44]);    MULADD(at[25], at[43]);    MULADD(at[26], at[42]);    MULADD(at[27], at[41]);    MULADD(at[28], at[40]);    MULADD(at[29], at[39]);    MULADD(at[30], at[38]);    MULADD(at[31], at[37]); 
-   COMBA_STORE(C->dp[36]);
-   /* 37 */
-   COMBA_FORWARD;
-   MULADD(at[6], at[63]);    MULADD(at[7], at[62]);    MULADD(at[8], at[61]);    MULADD(at[9], at[60]);    MULADD(at[10], at[59]);    MULADD(at[11], at[58]);    MULADD(at[12], at[57]);    MULADD(at[13], at[56]);    MULADD(at[14], at[55]);    MULADD(at[15], at[54]);    MULADD(at[16], at[53]);    MULADD(at[17], at[52]);    MULADD(at[18], at[51]);    MULADD(at[19], at[50]);    MULADD(at[20], at[49]);    MULADD(at[21], at[48]);    MULADD(at[22], at[47]);    MULADD(at[23], at[46]);    MULADD(at[24], at[45]);    MULADD(at[25], at[44]);    MULADD(at[26], at[43]);    MULADD(at[27], at[42]);    MULADD(at[28], at[41]);    MULADD(at[29], at[40]);    MULADD(at[30], at[39]);    MULADD(at[31], at[38]); 
-   COMBA_STORE(C->dp[37]);
-   /* 38 */
-   COMBA_FORWARD;
-   MULADD(at[7], at[63]);    MULADD(at[8], at[62]);    MULADD(at[9], at[61]);    MULADD(at[10], at[60]);    MULADD(at[11], at[59]);    MULADD(at[12], at[58]);    MULADD(at[13], at[57]);    MULADD(at[14], at[56]);    MULADD(at[15], at[55]);    MULADD(at[16], at[54]);    MULADD(at[17], at[53]);    MULADD(at[18], at[52]);    MULADD(at[19], at[51]);    MULADD(at[20], at[50]);    MULADD(at[21], at[49]);    MULADD(at[22], at[48]);    MULADD(at[23], at[47]);    MULADD(at[24], at[46]);    MULADD(at[25], at[45]);    MULADD(at[26], at[44]);    MULADD(at[27], at[43]);    MULADD(at[28], at[42]);    MULADD(at[29], at[41]);    MULADD(at[30], at[40]);    MULADD(at[31], at[39]); 
-   COMBA_STORE(C->dp[38]);
-
-   /* early out at 40 digits, 40*32==1280, or two 640 bit operands */
-   if (out_size <= 40) { COMBA_STORE2(C->dp[39]); C->used = 40; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
-
-   /* 39 */
-   COMBA_FORWARD;
-   MULADD(at[8], at[63]);    MULADD(at[9], at[62]);    MULADD(at[10], at[61]);    MULADD(at[11], at[60]);    MULADD(at[12], at[59]);    MULADD(at[13], at[58]);    MULADD(at[14], at[57]);    MULADD(at[15], at[56]);    MULADD(at[16], at[55]);    MULADD(at[17], at[54]);    MULADD(at[18], at[53]);    MULADD(at[19], at[52]);    MULADD(at[20], at[51]);    MULADD(at[21], at[50]);    MULADD(at[22], at[49]);    MULADD(at[23], at[48]);    MULADD(at[24], at[47]);    MULADD(at[25], at[46]);    MULADD(at[26], at[45]);    MULADD(at[27], at[44]);    MULADD(at[28], at[43]);    MULADD(at[29], at[42]);    MULADD(at[30], at[41]);    MULADD(at[31], at[40]); 
-   COMBA_STORE(C->dp[39]);
-   /* 40 */
-   COMBA_FORWARD;
-   MULADD(at[9], at[63]);    MULADD(at[10], at[62]);    MULADD(at[11], at[61]);    MULADD(at[12], at[60]);    MULADD(at[13], at[59]);    MULADD(at[14], at[58]);    MULADD(at[15], at[57]);    MULADD(at[16], at[56]);    MULADD(at[17], at[55]);    MULADD(at[18], at[54]);    MULADD(at[19], at[53]);    MULADD(at[20], at[52]);    MULADD(at[21], at[51]);    MULADD(at[22], at[50]);    MULADD(at[23], at[49]);    MULADD(at[24], at[48]);    MULADD(at[25], at[47]);    MULADD(at[26], at[46]);    MULADD(at[27], at[45]);    MULADD(at[28], at[44]);    MULADD(at[29], at[43]);    MULADD(at[30], at[42]);    MULADD(at[31], at[41]); 
-   COMBA_STORE(C->dp[40]);
-   /* 41 */
-   COMBA_FORWARD;
-   MULADD(at[10], at[63]);    MULADD(at[11], at[62]);    MULADD(at[12], at[61]);    MULADD(at[13], at[60]);    MULADD(at[14], at[59]);    MULADD(at[15], at[58]);    MULADD(at[16], at[57]);    MULADD(at[17], at[56]);    MULADD(at[18], at[55]);    MULADD(at[19], at[54]);    MULADD(at[20], at[53]);    MULADD(at[21], at[52]);    MULADD(at[22], at[51]);    MULADD(at[23], at[50]);    MULADD(at[24], at[49]);    MULADD(at[25], at[48]);    MULADD(at[26], at[47]);    MULADD(at[27], at[46]);    MULADD(at[28], at[45]);    MULADD(at[29], at[44]);    MULADD(at[30], at[43]);    MULADD(at[31], at[42]); 
-   COMBA_STORE(C->dp[41]);
-   /* 42 */
-   COMBA_FORWARD;
-   MULADD(at[11], at[63]);    MULADD(at[12], at[62]);    MULADD(at[13], at[61]);    MULADD(at[14], at[60]);    MULADD(at[15], at[59]);    MULADD(at[16], at[58]);    MULADD(at[17], at[57]);    MULADD(at[18], at[56]);    MULADD(at[19], at[55]);    MULADD(at[20], at[54]);    MULADD(at[21], at[53]);    MULADD(at[22], at[52]);    MULADD(at[23], at[51]);    MULADD(at[24], at[50]);    MULADD(at[25], at[49]);    MULADD(at[26], at[48]);    MULADD(at[27], at[47]);    MULADD(at[28], at[46]);    MULADD(at[29], at[45]);    MULADD(at[30], at[44]);    MULADD(at[31], at[43]); 
-   COMBA_STORE(C->dp[42]);
-   /* 43 */
-   COMBA_FORWARD;
-   MULADD(at[12], at[63]);    MULADD(at[13], at[62]);    MULADD(at[14], at[61]);    MULADD(at[15], at[60]);    MULADD(at[16], at[59]);    MULADD(at[17], at[58]);    MULADD(at[18], at[57]);    MULADD(at[19], at[56]);    MULADD(at[20], at[55]);    MULADD(at[21], at[54]);    MULADD(at[22], at[53]);    MULADD(at[23], at[52]);    MULADD(at[24], at[51]);    MULADD(at[25], at[50]);    MULADD(at[26], at[49]);    MULADD(at[27], at[48]);    MULADD(at[28], at[47]);    MULADD(at[29], at[46]);    MULADD(at[30], at[45]);    MULADD(at[31], at[44]); 
-   COMBA_STORE(C->dp[43]);
-   /* 44 */
-   COMBA_FORWARD;
-   MULADD(at[13], at[63]);    MULADD(at[14], at[62]);    MULADD(at[15], at[61]);    MULADD(at[16], at[60]);    MULADD(at[17], at[59]);    MULADD(at[18], at[58]);    MULADD(at[19], at[57]);    MULADD(at[20], at[56]);    MULADD(at[21], at[55]);    MULADD(at[22], at[54]);    MULADD(at[23], at[53]);    MULADD(at[24], at[52]);    MULADD(at[25], at[51]);    MULADD(at[26], at[50]);    MULADD(at[27], at[49]);    MULADD(at[28], at[48]);    MULADD(at[29], at[47]);    MULADD(at[30], at[46]);    MULADD(at[31], at[45]); 
-   COMBA_STORE(C->dp[44]);
-   /* 45 */
-   COMBA_FORWARD;
-   MULADD(at[14], at[63]);    MULADD(at[15], at[62]);    MULADD(at[16], at[61]);    MULADD(at[17], at[60]);    MULADD(at[18], at[59]);    MULADD(at[19], at[58]);    MULADD(at[20], at[57]);    MULADD(at[21], at[56]);    MULADD(at[22], at[55]);    MULADD(at[23], at[54]);    MULADD(at[24], at[53]);    MULADD(at[25], at[52]);    MULADD(at[26], at[51]);    MULADD(at[27], at[50]);    MULADD(at[28], at[49]);    MULADD(at[29], at[48]);    MULADD(at[30], at[47]);    MULADD(at[31], at[46]); 
-   COMBA_STORE(C->dp[45]);
-   /* 46 */
-   COMBA_FORWARD;
-   MULADD(at[15], at[63]);    MULADD(at[16], at[62]);    MULADD(at[17], at[61]);    MULADD(at[18], at[60]);    MULADD(at[19], at[59]);    MULADD(at[20], at[58]);    MULADD(at[21], at[57]);    MULADD(at[22], at[56]);    MULADD(at[23], at[55]);    MULADD(at[24], at[54]);    MULADD(at[25], at[53]);    MULADD(at[26], at[52]);    MULADD(at[27], at[51]);    MULADD(at[28], at[50]);    MULADD(at[29], at[49]);    MULADD(at[30], at[48]);    MULADD(at[31], at[47]); 
-   COMBA_STORE(C->dp[46]);
-
-   /* early out at 48 digits, 48*32==1536, or two 768 bit operands */
-   if (out_size <= 48) { COMBA_STORE2(C->dp[47]); C->used = 48; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
-
-   /* 47 */
-   COMBA_FORWARD;
-   MULADD(at[16], at[63]);    MULADD(at[17], at[62]);    MULADD(at[18], at[61]);    MULADD(at[19], at[60]);    MULADD(at[20], at[59]);    MULADD(at[21], at[58]);    MULADD(at[22], at[57]);    MULADD(at[23], at[56]);    MULADD(at[24], at[55]);    MULADD(at[25], at[54]);    MULADD(at[26], at[53]);    MULADD(at[27], at[52]);    MULADD(at[28], at[51]);    MULADD(at[29], at[50]);    MULADD(at[30], at[49]);    MULADD(at[31], at[48]); 
-   COMBA_STORE(C->dp[47]);
-   /* 48 */
-   COMBA_FORWARD;
-   MULADD(at[17], at[63]);    MULADD(at[18], at[62]);    MULADD(at[19], at[61]);    MULADD(at[20], at[60]);    MULADD(at[21], at[59]);    MULADD(at[22], at[58]);    MULADD(at[23], at[57]);    MULADD(at[24], at[56]);    MULADD(at[25], at[55]);    MULADD(at[26], at[54]);    MULADD(at[27], at[53]);    MULADD(at[28], at[52]);    MULADD(at[29], at[51]);    MULADD(at[30], at[50]);    MULADD(at[31], at[49]); 
-   COMBA_STORE(C->dp[48]);
-   /* 49 */
-   COMBA_FORWARD;
-   MULADD(at[18], at[63]);    MULADD(at[19], at[62]);    MULADD(at[20], at[61]);    MULADD(at[21], at[60]);    MULADD(at[22], at[59]);    MULADD(at[23], at[58]);    MULADD(at[24], at[57]);    MULADD(at[25], at[56]);    MULADD(at[26], at[55]);    MULADD(at[27], at[54]);    MULADD(at[28], at[53]);    MULADD(at[29], at[52]);    MULADD(at[30], at[51]);    MULADD(at[31], at[50]); 
-   COMBA_STORE(C->dp[49]);
-   /* 50 */
-   COMBA_FORWARD;
-   MULADD(at[19], at[63]);    MULADD(at[20], at[62]);    MULADD(at[21], at[61]);    MULADD(at[22], at[60]);    MULADD(at[23], at[59]);    MULADD(at[24], at[58]);    MULADD(at[25], at[57]);    MULADD(at[26], at[56]);    MULADD(at[27], at[55]);    MULADD(at[28], at[54]);    MULADD(at[29], at[53]);    MULADD(at[30], at[52]);    MULADD(at[31], at[51]); 
-   COMBA_STORE(C->dp[50]);
-   /* 51 */
-   COMBA_FORWARD;
-   MULADD(at[20], at[63]);    MULADD(at[21], at[62]);    MULADD(at[22], at[61]);    MULADD(at[23], at[60]);    MULADD(at[24], at[59]);    MULADD(at[25], at[58]);    MULADD(at[26], at[57]);    MULADD(at[27], at[56]);    MULADD(at[28], at[55]);    MULADD(at[29], at[54]);    MULADD(at[30], at[53]);    MULADD(at[31], at[52]); 
-   COMBA_STORE(C->dp[51]);
-   /* 52 */
-   COMBA_FORWARD;
-   MULADD(at[21], at[63]);    MULADD(at[22], at[62]);    MULADD(at[23], at[61]);    MULADD(at[24], at[60]);    MULADD(at[25], at[59]);    MULADD(at[26], at[58]);    MULADD(at[27], at[57]);    MULADD(at[28], at[56]);    MULADD(at[29], at[55]);    MULADD(at[30], at[54]);    MULADD(at[31], at[53]); 
-   COMBA_STORE(C->dp[52]);
-   /* 53 */
-   COMBA_FORWARD;
-   MULADD(at[22], at[63]);    MULADD(at[23], at[62]);    MULADD(at[24], at[61]);    MULADD(at[25], at[60]);    MULADD(at[26], at[59]);    MULADD(at[27], at[58]);    MULADD(at[28], at[57]);    MULADD(at[29], at[56]);    MULADD(at[30], at[55]);    MULADD(at[31], at[54]); 
-   COMBA_STORE(C->dp[53]);
-   /* 54 */
-   COMBA_FORWARD;
-   MULADD(at[23], at[63]);    MULADD(at[24], at[62]);    MULADD(at[25], at[61]);    MULADD(at[26], at[60]);    MULADD(at[27], at[59]);    MULADD(at[28], at[58]);    MULADD(at[29], at[57]);    MULADD(at[30], at[56]);    MULADD(at[31], at[55]); 
-   COMBA_STORE(C->dp[54]);
-
-   /* early out at 56 digits, 56*32==1792, or two 896 bit operands */
-   if (out_size <= 56) { COMBA_STORE2(C->dp[55]); C->used = 56; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; }
-
-   /* 55 */
-   COMBA_FORWARD;
-   MULADD(at[24], at[63]);    MULADD(at[25], at[62]);    MULADD(at[26], at[61]);    MULADD(at[27], at[60]);    MULADD(at[28], at[59]);    MULADD(at[29], at[58]);    MULADD(at[30], at[57]);    MULADD(at[31], at[56]); 
-   COMBA_STORE(C->dp[55]);
-   /* 56 */
-   COMBA_FORWARD;
-   MULADD(at[25], at[63]);    MULADD(at[26], at[62]);    MULADD(at[27], at[61]);    MULADD(at[28], at[60]);    MULADD(at[29], at[59]);    MULADD(at[30], at[58]);    MULADD(at[31], at[57]); 
-   COMBA_STORE(C->dp[56]);
-   /* 57 */
-   COMBA_FORWARD;
-   MULADD(at[26], at[63]);    MULADD(at[27], at[62]);    MULADD(at[28], at[61]);    MULADD(at[29], at[60]);    MULADD(at[30], at[59]);    MULADD(at[31], at[58]); 
-   COMBA_STORE(C->dp[57]);
-   /* 58 */
-   COMBA_FORWARD;
-   MULADD(at[27], at[63]);    MULADD(at[28], at[62]);    MULADD(at[29], at[61]);    MULADD(at[30], at[60]);    MULADD(at[31], at[59]); 
-   COMBA_STORE(C->dp[58]);
-   /* 59 */
-   COMBA_FORWARD;
-   MULADD(at[28], at[63]);    MULADD(at[29], at[62]);    MULADD(at[30], at[61]);    MULADD(at[31], at[60]); 
-   COMBA_STORE(C->dp[59]);
-   /* 60 */
-   COMBA_FORWARD;
-   MULADD(at[29], at[63]);    MULADD(at[30], at[62]);    MULADD(at[31], at[61]); 
-   COMBA_STORE(C->dp[60]);
-   /* 61 */
-   COMBA_FORWARD;
-   MULADD(at[30], at[63]);    MULADD(at[31], at[62]); 
-   COMBA_STORE(C->dp[61]);
-   /* 62 */
-   COMBA_FORWARD;
-   MULADD(at[31], at[63]); 
-   COMBA_STORE(C->dp[62]);
-   COMBA_STORE2(C->dp[63]);
-   C->used = 64;
-   C->sign = A->sign ^ B->sign;
-   fp_clamp(C);
-   COMBA_FINI;
-}
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_4.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_4.i
deleted file mode 100755
index e981eb1..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_4.i
+++ /dev/null
@@ -1,66 +0,0 @@
-/* fp_mul_comba_4.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_MUL4
-void fp_mul_comba4(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[8];
-
-   memcpy(at, A->dp, 4 * sizeof(fp_digit));
-   memcpy(at+4, B->dp, 4 * sizeof(fp_digit));
-   COMBA_START;
-
-   COMBA_CLEAR;
-   /* 0 */
-   MULADD(at[0], at[4]); 
-   COMBA_STORE(C->dp[0]);
-   /* 1 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[5]);    MULADD(at[1], at[4]); 
-   COMBA_STORE(C->dp[1]);
-   /* 2 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[6]);    MULADD(at[1], at[5]);    MULADD(at[2], at[4]); 
-   COMBA_STORE(C->dp[2]);
-   /* 3 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[7]);    MULADD(at[1], at[6]);    MULADD(at[2], at[5]);    MULADD(at[3], at[4]); 
-   COMBA_STORE(C->dp[3]);
-   /* 4 */
-   COMBA_FORWARD;
-   MULADD(at[1], at[7]);    MULADD(at[2], at[6]);    MULADD(at[3], at[5]); 
-   COMBA_STORE(C->dp[4]);
-   /* 5 */
-   COMBA_FORWARD;
-   MULADD(at[2], at[7]);    MULADD(at[3], at[6]); 
-   COMBA_STORE(C->dp[5]);
-   /* 6 */
-   COMBA_FORWARD;
-   MULADD(at[3], at[7]); 
-   COMBA_STORE(C->dp[6]);
-   COMBA_STORE2(C->dp[7]);
-   C->used = 8;
-   C->sign = A->sign ^ B->sign;
-   fp_clamp(C);
-   COMBA_FINI;
-}
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_48.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_48.i
deleted file mode 100755
index 79e43b8..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_48.i
+++ /dev/null
@@ -1,418 +0,0 @@
-/* fp_mul_comba_48.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_MUL48
-void fp_mul_comba48(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[96];
-
-   memcpy(at, A->dp, 48 * sizeof(fp_digit));
-   memcpy(at+48, B->dp, 48 * sizeof(fp_digit));
-   COMBA_START;
-
-   COMBA_CLEAR;
-   /* 0 */
-   MULADD(at[0], at[48]); 
-   COMBA_STORE(C->dp[0]);
-   /* 1 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[49]);    MULADD(at[1], at[48]); 
-   COMBA_STORE(C->dp[1]);
-   /* 2 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[50]);    MULADD(at[1], at[49]);    MULADD(at[2], at[48]); 
-   COMBA_STORE(C->dp[2]);
-   /* 3 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[51]);    MULADD(at[1], at[50]);    MULADD(at[2], at[49]);    MULADD(at[3], at[48]); 
-   COMBA_STORE(C->dp[3]);
-   /* 4 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[52]);    MULADD(at[1], at[51]);    MULADD(at[2], at[50]);    MULADD(at[3], at[49]);    MULADD(at[4], at[48]); 
-   COMBA_STORE(C->dp[4]);
-   /* 5 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[53]);    MULADD(at[1], at[52]);    MULADD(at[2], at[51]);    MULADD(at[3], at[50]);    MULADD(at[4], at[49]);    MULADD(at[5], at[48]); 
-   COMBA_STORE(C->dp[5]);
-   /* 6 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[54]);    MULADD(at[1], at[53]);    MULADD(at[2], at[52]);    MULADD(at[3], at[51]);    MULADD(at[4], at[50]);    MULADD(at[5], at[49]);    MULADD(at[6], at[48]); 
-   COMBA_STORE(C->dp[6]);
-   /* 7 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[55]);    MULADD(at[1], at[54]);    MULADD(at[2], at[53]);    MULADD(at[3], at[52]);    MULADD(at[4], at[51]);    MULADD(at[5], at[50]);    MULADD(at[6], at[49]);    MULADD(at[7], at[48]); 
-   COMBA_STORE(C->dp[7]);
-   /* 8 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[56]);    MULADD(at[1], at[55]);    MULADD(at[2], at[54]);    MULADD(at[3], at[53]);    MULADD(at[4], at[52]);    MULADD(at[5], at[51]);    MULADD(at[6], at[50]);    MULADD(at[7], at[49]);    MULADD(at[8], at[48]); 
-   COMBA_STORE(C->dp[8]);
-   /* 9 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[57]);    MULADD(at[1], at[56]);    MULADD(at[2], at[55]);    MULADD(at[3], at[54]);    MULADD(at[4], at[53]);    MULADD(at[5], at[52]);    MULADD(at[6], at[51]);    MULADD(at[7], at[50]);    MULADD(at[8], at[49]);    MULADD(at[9], at[48]); 
-   COMBA_STORE(C->dp[9]);
-   /* 10 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[58]);    MULADD(at[1], at[57]);    MULADD(at[2], at[56]);    MULADD(at[3], at[55]);    MULADD(at[4], at[54]);    MULADD(at[5], at[53]);    MULADD(at[6], at[52]);    MULADD(at[7], at[51]);    MULADD(at[8], at[50]);    MULADD(at[9], at[49]);    MULADD(at[10], at[48]); 
-   COMBA_STORE(C->dp[10]);
-   /* 11 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[59]);    MULADD(at[1], at[58]);    MULADD(at[2], at[57]);    MULADD(at[3], at[56]);    MULADD(at[4], at[55]);    MULADD(at[5], at[54]);    MULADD(at[6], at[53]);    MULADD(at[7], at[52]);    MULADD(at[8], at[51]);    MULADD(at[9], at[50]);    MULADD(at[10], at[49]);    MULADD(at[11], at[48]); 
-   COMBA_STORE(C->dp[11]);
-   /* 12 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[60]);    MULADD(at[1], at[59]);    MULADD(at[2], at[58]);    MULADD(at[3], at[57]);    MULADD(at[4], at[56]);    MULADD(at[5], at[55]);    MULADD(at[6], at[54]);    MULADD(at[7], at[53]);    MULADD(at[8], at[52]);    MULADD(at[9], at[51]);    MULADD(at[10], at[50]);    MULADD(at[11], at[49]);    MULADD(at[12], at[48]); 
-   COMBA_STORE(C->dp[12]);
-   /* 13 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[61]);    MULADD(at[1], at[60]);    MULADD(at[2], at[59]);    MULADD(at[3], at[58]);    MULADD(at[4], at[57]);    MULADD(at[5], at[56]);    MULADD(at[6], at[55]);    MULADD(at[7], at[54]);    MULADD(at[8], at[53]);    MULADD(at[9], at[52]);    MULADD(at[10], at[51]);    MULADD(at[11], at[50]);    MULADD(at[12], at[49]);    MULADD(at[13], at[48]); 
-   COMBA_STORE(C->dp[13]);
-   /* 14 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[62]);    MULADD(at[1], at[61]);    MULADD(at[2], at[60]);    MULADD(at[3], at[59]);    MULADD(at[4], at[58]);    MULADD(at[5], at[57]);    MULADD(at[6], at[56]);    MULADD(at[7], at[55]);    MULADD(at[8], at[54]);    MULADD(at[9], at[53]);    MULADD(at[10], at[52]);    MULADD(at[11], at[51]);    MULADD(at[12], at[50]);    MULADD(at[13], at[49]);    MULADD(at[14], at[48]); 
-   COMBA_STORE(C->dp[14]);
-   /* 15 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[63]);    MULADD(at[1], at[62]);    MULADD(at[2], at[61]);    MULADD(at[3], at[60]);    MULADD(at[4], at[59]);    MULADD(at[5], at[58]);    MULADD(at[6], at[57]);    MULADD(at[7], at[56]);    MULADD(at[8], at[55]);    MULADD(at[9], at[54]);    MULADD(at[10], at[53]);    MULADD(at[11], at[52]);    MULADD(at[12], at[51]);    MULADD(at[13], at[50]);    MULADD(at[14], at[49]);    MULADD(at[15], at[48]); 
-   COMBA_STORE(C->dp[15]);
-   /* 16 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[64]);    MULADD(at[1], at[63]);    MULADD(at[2], at[62]);    MULADD(at[3], at[61]);    MULADD(at[4], at[60]);    MULADD(at[5], at[59]);    MULADD(at[6], at[58]);    MULADD(at[7], at[57]);    MULADD(at[8], at[56]);    MULADD(at[9], at[55]);    MULADD(at[10], at[54]);    MULADD(at[11], at[53]);    MULADD(at[12], at[52]);    MULADD(at[13], at[51]);    MULADD(at[14], at[50]);    MULADD(at[15], at[49]);    MULADD(at[16], at[48]); 
-   COMBA_STORE(C->dp[16]);
-   /* 17 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[65]);    MULADD(at[1], at[64]);    MULADD(at[2], at[63]);    MULADD(at[3], at[62]);    MULADD(at[4], at[61]);    MULADD(at[5], at[60]);    MULADD(at[6], at[59]);    MULADD(at[7], at[58]);    MULADD(at[8], at[57]);    MULADD(at[9], at[56]);    MULADD(at[10], at[55]);    MULADD(at[11], at[54]);    MULADD(at[12], at[53]);    MULADD(at[13], at[52]);    MULADD(at[14], at[51]);    MULADD(at[15], at[50]);    MULADD(at[16], at[49]);    MULADD(at[17], at[48]); 
-   COMBA_STORE(C->dp[17]);
-   /* 18 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[66]);    MULADD(at[1], at[65]);    MULADD(at[2], at[64]);    MULADD(at[3], at[63]);    MULADD(at[4], at[62]);    MULADD(at[5], at[61]);    MULADD(at[6], at[60]);    MULADD(at[7], at[59]);    MULADD(at[8], at[58]);    MULADD(at[9], at[57]);    MULADD(at[10], at[56]);    MULADD(at[11], at[55]);    MULADD(at[12], at[54]);    MULADD(at[13], at[53]);    MULADD(at[14], at[52]);    MULADD(at[15], at[51]);    MULADD(at[16], at[50]);    MULADD(at[17], at[49]);    MULADD(at[18], at[48]); 
-   COMBA_STORE(C->dp[18]);
-   /* 19 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[67]);    MULADD(at[1], at[66]);    MULADD(at[2], at[65]);    MULADD(at[3], at[64]);    MULADD(at[4], at[63]);    MULADD(at[5], at[62]);    MULADD(at[6], at[61]);    MULADD(at[7], at[60]);    MULADD(at[8], at[59]);    MULADD(at[9], at[58]);    MULADD(at[10], at[57]);    MULADD(at[11], at[56]);    MULADD(at[12], at[55]);    MULADD(at[13], at[54]);    MULADD(at[14], at[53]);    MULADD(at[15], at[52]);    MULADD(at[16], at[51]);    MULADD(at[17], at[50]);    MULADD(at[18], at[49]);    MULADD(at[19], at[48]); 
-   COMBA_STORE(C->dp[19]);
-   /* 20 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[68]);    MULADD(at[1], at[67]);    MULADD(at[2], at[66]);    MULADD(at[3], at[65]);    MULADD(at[4], at[64]);    MULADD(at[5], at[63]);    MULADD(at[6], at[62]);    MULADD(at[7], at[61]);    MULADD(at[8], at[60]);    MULADD(at[9], at[59]);    MULADD(at[10], at[58]);    MULADD(at[11], at[57]);    MULADD(at[12], at[56]);    MULADD(at[13], at[55]);    MULADD(at[14], at[54]);    MULADD(at[15], at[53]);    MULADD(at[16], at[52]);    MULADD(at[17], at[51]);    MULADD(at[18], at[50]);    MULADD(at[19], at[49]);    MULADD(at[20], at[48]); 
-   COMBA_STORE(C->dp[20]);
-   /* 21 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[69]);    MULADD(at[1], at[68]);    MULADD(at[2], at[67]);    MULADD(at[3], at[66]);    MULADD(at[4], at[65]);    MULADD(at[5], at[64]);    MULADD(at[6], at[63]);    MULADD(at[7], at[62]);    MULADD(at[8], at[61]);    MULADD(at[9], at[60]);    MULADD(at[10], at[59]);    MULADD(at[11], at[58]);    MULADD(at[12], at[57]);    MULADD(at[13], at[56]);    MULADD(at[14], at[55]);    MULADD(at[15], at[54]);    MULADD(at[16], at[53]);    MULADD(at[17], at[52]);    MULADD(at[18], at[51]);    MULADD(at[19], at[50]);    MULADD(at[20], at[49]);    MULADD(at[21], at[48]); 
-   COMBA_STORE(C->dp[21]);
-   /* 22 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[70]);    MULADD(at[1], at[69]);    MULADD(at[2], at[68]);    MULADD(at[3], at[67]);    MULADD(at[4], at[66]);    MULADD(at[5], at[65]);    MULADD(at[6], at[64]);    MULADD(at[7], at[63]);    MULADD(at[8], at[62]);    MULADD(at[9], at[61]);    MULADD(at[10], at[60]);    MULADD(at[11], at[59]);    MULADD(at[12], at[58]);    MULADD(at[13], at[57]);    MULADD(at[14], at[56]);    MULADD(at[15], at[55]);    MULADD(at[16], at[54]);    MULADD(at[17], at[53]);    MULADD(at[18], at[52]);    MULADD(at[19], at[51]);    MULADD(at[20], at[50]);    MULADD(at[21], at[49]);    MULADD(at[22], at[48]); 
-   COMBA_STORE(C->dp[22]);
-   /* 23 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[71]);    MULADD(at[1], at[70]);    MULADD(at[2], at[69]);    MULADD(at[3], at[68]);    MULADD(at[4], at[67]);    MULADD(at[5], at[66]);    MULADD(at[6], at[65]);    MULADD(at[7], at[64]);    MULADD(at[8], at[63]);    MULADD(at[9], at[62]);    MULADD(at[10], at[61]);    MULADD(at[11], at[60]);    MULADD(at[12], at[59]);    MULADD(at[13], at[58]);    MULADD(at[14], at[57]);    MULADD(at[15], at[56]);    MULADD(at[16], at[55]);    MULADD(at[17], at[54]);    MULADD(at[18], at[53]);    MULADD(at[19], at[52]);    MULADD(at[20], at[51]);    MULADD(at[21], at[50]);    MULADD(at[22], at[49]);    MULADD(at[23], at[48]); 
-   COMBA_STORE(C->dp[23]);
-   /* 24 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[72]);    MULADD(at[1], at[71]);    MULADD(at[2], at[70]);    MULADD(at[3], at[69]);    MULADD(at[4], at[68]);    MULADD(at[5], at[67]);    MULADD(at[6], at[66]);    MULADD(at[7], at[65]);    MULADD(at[8], at[64]);    MULADD(at[9], at[63]);    MULADD(at[10], at[62]);    MULADD(at[11], at[61]);    MULADD(at[12], at[60]);    MULADD(at[13], at[59]);    MULADD(at[14], at[58]);    MULADD(at[15], at[57]);    MULADD(at[16], at[56]);    MULADD(at[17], at[55]);    MULADD(at[18], at[54]);    MULADD(at[19], at[53]);    MULADD(at[20], at[52]);    MULADD(at[21], at[51]);    MULADD(at[22], at[50]);    MULADD(at[23], at[49]);    MULADD(at[24], at[48]); 
-   COMBA_STORE(C->dp[24]);
-   /* 25 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[73]);    MULADD(at[1], at[72]);    MULADD(at[2], at[71]);    MULADD(at[3], at[70]);    MULADD(at[4], at[69]);    MULADD(at[5], at[68]);    MULADD(at[6], at[67]);    MULADD(at[7], at[66]);    MULADD(at[8], at[65]);    MULADD(at[9], at[64]);    MULADD(at[10], at[63]);    MULADD(at[11], at[62]);    MULADD(at[12], at[61]);    MULADD(at[13], at[60]);    MULADD(at[14], at[59]);    MULADD(at[15], at[58]);    MULADD(at[16], at[57]);    MULADD(at[17], at[56]);    MULADD(at[18], at[55]);    MULADD(at[19], at[54]);    MULADD(at[20], at[53]);    MULADD(at[21], at[52]);    MULADD(at[22], at[51]);    MULADD(at[23], at[50]);    MULADD(at[24], at[49]);    MULADD(at[25], at[48]); 
-   COMBA_STORE(C->dp[25]);
-   /* 26 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[74]);    MULADD(at[1], at[73]);    MULADD(at[2], at[72]);    MULADD(at[3], at[71]);    MULADD(at[4], at[70]);    MULADD(at[5], at[69]);    MULADD(at[6], at[68]);    MULADD(at[7], at[67]);    MULADD(at[8], at[66]);    MULADD(at[9], at[65]);    MULADD(at[10], at[64]);    MULADD(at[11], at[63]);    MULADD(at[12], at[62]);    MULADD(at[13], at[61]);    MULADD(at[14], at[60]);    MULADD(at[15], at[59]);    MULADD(at[16], at[58]);    MULADD(at[17], at[57]);    MULADD(at[18], at[56]);    MULADD(at[19], at[55]);    MULADD(at[20], at[54]);    MULADD(at[21], at[53]);    MULADD(at[22], at[52]);    MULADD(at[23], at[51]);    MULADD(at[24], at[50]);    MULADD(at[25], at[49]);    MULADD(at[26], at[48]); 
-   COMBA_STORE(C->dp[26]);
-   /* 27 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[75]);    MULADD(at[1], at[74]);    MULADD(at[2], at[73]);    MULADD(at[3], at[72]);    MULADD(at[4], at[71]);    MULADD(at[5], at[70]);    MULADD(at[6], at[69]);    MULADD(at[7], at[68]);    MULADD(at[8], at[67]);    MULADD(at[9], at[66]);    MULADD(at[10], at[65]);    MULADD(at[11], at[64]);    MULADD(at[12], at[63]);    MULADD(at[13], at[62]);    MULADD(at[14], at[61]);    MULADD(at[15], at[60]);    MULADD(at[16], at[59]);    MULADD(at[17], at[58]);    MULADD(at[18], at[57]);    MULADD(at[19], at[56]);    MULADD(at[20], at[55]);    MULADD(at[21], at[54]);    MULADD(at[22], at[53]);    MULADD(at[23], at[52]);    MULADD(at[24], at[51]);    MULADD(at[25], at[50]);    MULADD(at[26], at[49]);    MULADD(at[27], at[48]); 
-   COMBA_STORE(C->dp[27]);
-   /* 28 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[76]);    MULADD(at[1], at[75]);    MULADD(at[2], at[74]);    MULADD(at[3], at[73]);    MULADD(at[4], at[72]);    MULADD(at[5], at[71]);    MULADD(at[6], at[70]);    MULADD(at[7], at[69]);    MULADD(at[8], at[68]);    MULADD(at[9], at[67]);    MULADD(at[10], at[66]);    MULADD(at[11], at[65]);    MULADD(at[12], at[64]);    MULADD(at[13], at[63]);    MULADD(at[14], at[62]);    MULADD(at[15], at[61]);    MULADD(at[16], at[60]);    MULADD(at[17], at[59]);    MULADD(at[18], at[58]);    MULADD(at[19], at[57]);    MULADD(at[20], at[56]);    MULADD(at[21], at[55]);    MULADD(at[22], at[54]);    MULADD(at[23], at[53]);    MULADD(at[24], at[52]);    MULADD(at[25], at[51]);    MULADD(at[26], at[50]);    MULADD(at[27], at[49]);    MULADD(at[28], at[48]); 
-   COMBA_STORE(C->dp[28]);
-   /* 29 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[77]);    MULADD(at[1], at[76]);    MULADD(at[2], at[75]);    MULADD(at[3], at[74]);    MULADD(at[4], at[73]);    MULADD(at[5], at[72]);    MULADD(at[6], at[71]);    MULADD(at[7], at[70]);    MULADD(at[8], at[69]);    MULADD(at[9], at[68]);    MULADD(at[10], at[67]);    MULADD(at[11], at[66]);    MULADD(at[12], at[65]);    MULADD(at[13], at[64]);    MULADD(at[14], at[63]);    MULADD(at[15], at[62]);    MULADD(at[16], at[61]);    MULADD(at[17], at[60]);    MULADD(at[18], at[59]);    MULADD(at[19], at[58]);    MULADD(at[20], at[57]);    MULADD(at[21], at[56]);    MULADD(at[22], at[55]);    MULADD(at[23], at[54]);    MULADD(at[24], at[53]);    MULADD(at[25], at[52]);    MULADD(at[26], at[51]);    MULADD(at[27], at[50]);    MULADD(at[28], at[49]);    MULADD(at[29], at[48]); 
-   COMBA_STORE(C->dp[29]);
-   /* 30 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[78]);    MULADD(at[1], at[77]);    MULADD(at[2], at[76]);    MULADD(at[3], at[75]);    MULADD(at[4], at[74]);    MULADD(at[5], at[73]);    MULADD(at[6], at[72]);    MULADD(at[7], at[71]);    MULADD(at[8], at[70]);    MULADD(at[9], at[69]);    MULADD(at[10], at[68]);    MULADD(at[11], at[67]);    MULADD(at[12], at[66]);    MULADD(at[13], at[65]);    MULADD(at[14], at[64]);    MULADD(at[15], at[63]);    MULADD(at[16], at[62]);    MULADD(at[17], at[61]);    MULADD(at[18], at[60]);    MULADD(at[19], at[59]);    MULADD(at[20], at[58]);    MULADD(at[21], at[57]);    MULADD(at[22], at[56]);    MULADD(at[23], at[55]);    MULADD(at[24], at[54]);    MULADD(at[25], at[53]);    MULADD(at[26], at[52]);    MULADD(at[27], at[51]);    MULADD(at[28], at[50]);    MULADD(at[29], at[49]);    MULADD(at[30], at[48]); 
-   COMBA_STORE(C->dp[30]);
-   /* 31 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[79]);    MULADD(at[1], at[78]);    MULADD(at[2], at[77]);    MULADD(at[3], at[76]);    MULADD(at[4], at[75]);    MULADD(at[5], at[74]);    MULADD(at[6], at[73]);    MULADD(at[7], at[72]);    MULADD(at[8], at[71]);    MULADD(at[9], at[70]);    MULADD(at[10], at[69]);    MULADD(at[11], at[68]);    MULADD(at[12], at[67]);    MULADD(at[13], at[66]);    MULADD(at[14], at[65]);    MULADD(at[15], at[64]);    MULADD(at[16], at[63]);    MULADD(at[17], at[62]);    MULADD(at[18], at[61]);    MULADD(at[19], at[60]);    MULADD(at[20], at[59]);    MULADD(at[21], at[58]);    MULADD(at[22], at[57]);    MULADD(at[23], at[56]);    MULADD(at[24], at[55]);    MULADD(at[25], at[54]);    MULADD(at[26], at[53]);    MULADD(at[27], at[52]);    MULADD(at[28], at[51]);    MULADD(at[29], at[50]);    MULADD(at[30], at[49]);    MULADD(at[31], at[48]); 
-   COMBA_STORE(C->dp[31]);
-   /* 32 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[80]);    MULADD(at[1], at[79]);    MULADD(at[2], at[78]);    MULADD(at[3], at[77]);    MULADD(at[4], at[76]);    MULADD(at[5], at[75]);    MULADD(at[6], at[74]);    MULADD(at[7], at[73]);    MULADD(at[8], at[72]);    MULADD(at[9], at[71]);    MULADD(at[10], at[70]);    MULADD(at[11], at[69]);    MULADD(at[12], at[68]);    MULADD(at[13], at[67]);    MULADD(at[14], at[66]);    MULADD(at[15], at[65]);    MULADD(at[16], at[64]);    MULADD(at[17], at[63]);    MULADD(at[18], at[62]);    MULADD(at[19], at[61]);    MULADD(at[20], at[60]);    MULADD(at[21], at[59]);    MULADD(at[22], at[58]);    MULADD(at[23], at[57]);    MULADD(at[24], at[56]);    MULADD(at[25], at[55]);    MULADD(at[26], at[54]);    MULADD(at[27], at[53]);    MULADD(at[28], at[52]);    MULADD(at[29], at[51]);    MULADD(at[30], at[50]);    MULADD(at[31], at[49]);    MULADD(at[32], at[48]); 
-   COMBA_STORE(C->dp[32]);
-   /* 33 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[81]);    MULADD(at[1], at[80]);    MULADD(at[2], at[79]);    MULADD(at[3], at[78]);    MULADD(at[4], at[77]);    MULADD(at[5], at[76]);    MULADD(at[6], at[75]);    MULADD(at[7], at[74]);    MULADD(at[8], at[73]);    MULADD(at[9], at[72]);    MULADD(at[10], at[71]);    MULADD(at[11], at[70]);    MULADD(at[12], at[69]);    MULADD(at[13], at[68]);    MULADD(at[14], at[67]);    MULADD(at[15], at[66]);    MULADD(at[16], at[65]);    MULADD(at[17], at[64]);    MULADD(at[18], at[63]);    MULADD(at[19], at[62]);    MULADD(at[20], at[61]);    MULADD(at[21], at[60]);    MULADD(at[22], at[59]);    MULADD(at[23], at[58]);    MULADD(at[24], at[57]);    MULADD(at[25], at[56]);    MULADD(at[26], at[55]);    MULADD(at[27], at[54]);    MULADD(at[28], at[53]);    MULADD(at[29], at[52]);    MULADD(at[30], at[51]);    MULADD(at[31], at[50]);    MULADD(at[32], at[49]);    MULADD(at[33], at[48]); 
-   COMBA_STORE(C->dp[33]);
-   /* 34 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[82]);    MULADD(at[1], at[81]);    MULADD(at[2], at[80]);    MULADD(at[3], at[79]);    MULADD(at[4], at[78]);    MULADD(at[5], at[77]);    MULADD(at[6], at[76]);    MULADD(at[7], at[75]);    MULADD(at[8], at[74]);    MULADD(at[9], at[73]);    MULADD(at[10], at[72]);    MULADD(at[11], at[71]);    MULADD(at[12], at[70]);    MULADD(at[13], at[69]);    MULADD(at[14], at[68]);    MULADD(at[15], at[67]);    MULADD(at[16], at[66]);    MULADD(at[17], at[65]);    MULADD(at[18], at[64]);    MULADD(at[19], at[63]);    MULADD(at[20], at[62]);    MULADD(at[21], at[61]);    MULADD(at[22], at[60]);    MULADD(at[23], at[59]);    MULADD(at[24], at[58]);    MULADD(at[25], at[57]);    MULADD(at[26], at[56]);    MULADD(at[27], at[55]);    MULADD(at[28], at[54]);    MULADD(at[29], at[53]);    MULADD(at[30], at[52]);    MULADD(at[31], at[51]);    MULADD(at[32], at[50]);    MULADD(at[33], at[49]);    MULADD(at[34], at[48]); 
-   COMBA_STORE(C->dp[34]);
-   /* 35 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[83]);    MULADD(at[1], at[82]);    MULADD(at[2], at[81]);    MULADD(at[3], at[80]);    MULADD(at[4], at[79]);    MULADD(at[5], at[78]);    MULADD(at[6], at[77]);    MULADD(at[7], at[76]);    MULADD(at[8], at[75]);    MULADD(at[9], at[74]);    MULADD(at[10], at[73]);    MULADD(at[11], at[72]);    MULADD(at[12], at[71]);    MULADD(at[13], at[70]);    MULADD(at[14], at[69]);    MULADD(at[15], at[68]);    MULADD(at[16], at[67]);    MULADD(at[17], at[66]);    MULADD(at[18], at[65]);    MULADD(at[19], at[64]);    MULADD(at[20], at[63]);    MULADD(at[21], at[62]);    MULADD(at[22], at[61]);    MULADD(at[23], at[60]);    MULADD(at[24], at[59]);    MULADD(at[25], at[58]);    MULADD(at[26], at[57]);    MULADD(at[27], at[56]);    MULADD(at[28], at[55]);    MULADD(at[29], at[54]);    MULADD(at[30], at[53]);    MULADD(at[31], at[52]);    MULADD(at[32], at[51]);    MULADD(at[33], at[50]);    MULADD(at[34], at[49]);    MULADD(at[35], at[48]); 
-   COMBA_STORE(C->dp[35]);
-   /* 36 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[84]);    MULADD(at[1], at[83]);    MULADD(at[2], at[82]);    MULADD(at[3], at[81]);    MULADD(at[4], at[80]);    MULADD(at[5], at[79]);    MULADD(at[6], at[78]);    MULADD(at[7], at[77]);    MULADD(at[8], at[76]);    MULADD(at[9], at[75]);    MULADD(at[10], at[74]);    MULADD(at[11], at[73]);    MULADD(at[12], at[72]);    MULADD(at[13], at[71]);    MULADD(at[14], at[70]);    MULADD(at[15], at[69]);    MULADD(at[16], at[68]);    MULADD(at[17], at[67]);    MULADD(at[18], at[66]);    MULADD(at[19], at[65]);    MULADD(at[20], at[64]);    MULADD(at[21], at[63]);    MULADD(at[22], at[62]);    MULADD(at[23], at[61]);    MULADD(at[24], at[60]);    MULADD(at[25], at[59]);    MULADD(at[26], at[58]);    MULADD(at[27], at[57]);    MULADD(at[28], at[56]);    MULADD(at[29], at[55]);    MULADD(at[30], at[54]);    MULADD(at[31], at[53]);    MULADD(at[32], at[52]);    MULADD(at[33], at[51]);    MULADD(at[34], at[50]);    MULADD(at[35], at[49]);    MULADD(at[36], at[48]); 
-   COMBA_STORE(C->dp[36]);
-   /* 37 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[85]);    MULADD(at[1], at[84]);    MULADD(at[2], at[83]);    MULADD(at[3], at[82]);    MULADD(at[4], at[81]);    MULADD(at[5], at[80]);    MULADD(at[6], at[79]);    MULADD(at[7], at[78]);    MULADD(at[8], at[77]);    MULADD(at[9], at[76]);    MULADD(at[10], at[75]);    MULADD(at[11], at[74]);    MULADD(at[12], at[73]);    MULADD(at[13], at[72]);    MULADD(at[14], at[71]);    MULADD(at[15], at[70]);    MULADD(at[16], at[69]);    MULADD(at[17], at[68]);    MULADD(at[18], at[67]);    MULADD(at[19], at[66]);    MULADD(at[20], at[65]);    MULADD(at[21], at[64]);    MULADD(at[22], at[63]);    MULADD(at[23], at[62]);    MULADD(at[24], at[61]);    MULADD(at[25], at[60]);    MULADD(at[26], at[59]);    MULADD(at[27], at[58]);    MULADD(at[28], at[57]);    MULADD(at[29], at[56]);    MULADD(at[30], at[55]);    MULADD(at[31], at[54]);    MULADD(at[32], at[53]);    MULADD(at[33], at[52]);    MULADD(at[34], at[51]);    MULADD(at[35], at[50]);    MULADD(at[36], at[49]);    MULADD(at[37], at[48]); 
-   COMBA_STORE(C->dp[37]);
-   /* 38 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[86]);    MULADD(at[1], at[85]);    MULADD(at[2], at[84]);    MULADD(at[3], at[83]);    MULADD(at[4], at[82]);    MULADD(at[5], at[81]);    MULADD(at[6], at[80]);    MULADD(at[7], at[79]);    MULADD(at[8], at[78]);    MULADD(at[9], at[77]);    MULADD(at[10], at[76]);    MULADD(at[11], at[75]);    MULADD(at[12], at[74]);    MULADD(at[13], at[73]);    MULADD(at[14], at[72]);    MULADD(at[15], at[71]);    MULADD(at[16], at[70]);    MULADD(at[17], at[69]);    MULADD(at[18], at[68]);    MULADD(at[19], at[67]);    MULADD(at[20], at[66]);    MULADD(at[21], at[65]);    MULADD(at[22], at[64]);    MULADD(at[23], at[63]);    MULADD(at[24], at[62]);    MULADD(at[25], at[61]);    MULADD(at[26], at[60]);    MULADD(at[27], at[59]);    MULADD(at[28], at[58]);    MULADD(at[29], at[57]);    MULADD(at[30], at[56]);    MULADD(at[31], at[55]);    MULADD(at[32], at[54]);    MULADD(at[33], at[53]);    MULADD(at[34], at[52]);    MULADD(at[35], at[51]);    MULADD(at[36], at[50]);    MULADD(at[37], at[49]);    MULADD(at[38], at[48]); 
-   COMBA_STORE(C->dp[38]);
-   /* 39 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[87]);    MULADD(at[1], at[86]);    MULADD(at[2], at[85]);    MULADD(at[3], at[84]);    MULADD(at[4], at[83]);    MULADD(at[5], at[82]);    MULADD(at[6], at[81]);    MULADD(at[7], at[80]);    MULADD(at[8], at[79]);    MULADD(at[9], at[78]);    MULADD(at[10], at[77]);    MULADD(at[11], at[76]);    MULADD(at[12], at[75]);    MULADD(at[13], at[74]);    MULADD(at[14], at[73]);    MULADD(at[15], at[72]);    MULADD(at[16], at[71]);    MULADD(at[17], at[70]);    MULADD(at[18], at[69]);    MULADD(at[19], at[68]);    MULADD(at[20], at[67]);    MULADD(at[21], at[66]);    MULADD(at[22], at[65]);    MULADD(at[23], at[64]);    MULADD(at[24], at[63]);    MULADD(at[25], at[62]);    MULADD(at[26], at[61]);    MULADD(at[27], at[60]);    MULADD(at[28], at[59]);    MULADD(at[29], at[58]);    MULADD(at[30], at[57]);    MULADD(at[31], at[56]);    MULADD(at[32], at[55]);    MULADD(at[33], at[54]);    MULADD(at[34], at[53]);    MULADD(at[35], at[52]);    MULADD(at[36], at[51]);    MULADD(at[37], at[50]);    MULADD(at[38], at[49]);    MULADD(at[39], at[48]); 
-   COMBA_STORE(C->dp[39]);
-   /* 40 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[88]);    MULADD(at[1], at[87]);    MULADD(at[2], at[86]);    MULADD(at[3], at[85]);    MULADD(at[4], at[84]);    MULADD(at[5], at[83]);    MULADD(at[6], at[82]);    MULADD(at[7], at[81]);    MULADD(at[8], at[80]);    MULADD(at[9], at[79]);    MULADD(at[10], at[78]);    MULADD(at[11], at[77]);    MULADD(at[12], at[76]);    MULADD(at[13], at[75]);    MULADD(at[14], at[74]);    MULADD(at[15], at[73]);    MULADD(at[16], at[72]);    MULADD(at[17], at[71]);    MULADD(at[18], at[70]);    MULADD(at[19], at[69]);    MULADD(at[20], at[68]);    MULADD(at[21], at[67]);    MULADD(at[22], at[66]);    MULADD(at[23], at[65]);    MULADD(at[24], at[64]);    MULADD(at[25], at[63]);    MULADD(at[26], at[62]);    MULADD(at[27], at[61]);    MULADD(at[28], at[60]);    MULADD(at[29], at[59]);    MULADD(at[30], at[58]);    MULADD(at[31], at[57]);    MULADD(at[32], at[56]);    MULADD(at[33], at[55]);    MULADD(at[34], at[54]);    MULADD(at[35], at[53]);    MULADD(at[36], at[52]);    MULADD(at[37], at[51]);    MULADD(at[38], at[50]);    MULADD(at[39], at[49]);    MULADD(at[40], at[48]); 
-   COMBA_STORE(C->dp[40]);
-   /* 41 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[89]);    MULADD(at[1], at[88]);    MULADD(at[2], at[87]);    MULADD(at[3], at[86]);    MULADD(at[4], at[85]);    MULADD(at[5], at[84]);    MULADD(at[6], at[83]);    MULADD(at[7], at[82]);    MULADD(at[8], at[81]);    MULADD(at[9], at[80]);    MULADD(at[10], at[79]);    MULADD(at[11], at[78]);    MULADD(at[12], at[77]);    MULADD(at[13], at[76]);    MULADD(at[14], at[75]);    MULADD(at[15], at[74]);    MULADD(at[16], at[73]);    MULADD(at[17], at[72]);    MULADD(at[18], at[71]);    MULADD(at[19], at[70]);    MULADD(at[20], at[69]);    MULADD(at[21], at[68]);    MULADD(at[22], at[67]);    MULADD(at[23], at[66]);    MULADD(at[24], at[65]);    MULADD(at[25], at[64]);    MULADD(at[26], at[63]);    MULADD(at[27], at[62]);    MULADD(at[28], at[61]);    MULADD(at[29], at[60]);    MULADD(at[30], at[59]);    MULADD(at[31], at[58]);    MULADD(at[32], at[57]);    MULADD(at[33], at[56]);    MULADD(at[34], at[55]);    MULADD(at[35], at[54]);    MULADD(at[36], at[53]);    MULADD(at[37], at[52]);    MULADD(at[38], at[51]);    MULADD(at[39], at[50]);    MULADD(at[40], at[49]);    MULADD(at[41], at[48]); 
-   COMBA_STORE(C->dp[41]);
-   /* 42 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[90]);    MULADD(at[1], at[89]);    MULADD(at[2], at[88]);    MULADD(at[3], at[87]);    MULADD(at[4], at[86]);    MULADD(at[5], at[85]);    MULADD(at[6], at[84]);    MULADD(at[7], at[83]);    MULADD(at[8], at[82]);    MULADD(at[9], at[81]);    MULADD(at[10], at[80]);    MULADD(at[11], at[79]);    MULADD(at[12], at[78]);    MULADD(at[13], at[77]);    MULADD(at[14], at[76]);    MULADD(at[15], at[75]);    MULADD(at[16], at[74]);    MULADD(at[17], at[73]);    MULADD(at[18], at[72]);    MULADD(at[19], at[71]);    MULADD(at[20], at[70]);    MULADD(at[21], at[69]);    MULADD(at[22], at[68]);    MULADD(at[23], at[67]);    MULADD(at[24], at[66]);    MULADD(at[25], at[65]);    MULADD(at[26], at[64]);    MULADD(at[27], at[63]);    MULADD(at[28], at[62]);    MULADD(at[29], at[61]);    MULADD(at[30], at[60]);    MULADD(at[31], at[59]);    MULADD(at[32], at[58]);    MULADD(at[33], at[57]);    MULADD(at[34], at[56]);    MULADD(at[35], at[55]);    MULADD(at[36], at[54]);    MULADD(at[37], at[53]);    MULADD(at[38], at[52]);    MULADD(at[39], at[51]);    MULADD(at[40], at[50]);    MULADD(at[41], at[49]);    MULADD(at[42], at[48]); 
-   COMBA_STORE(C->dp[42]);
-   /* 43 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[91]);    MULADD(at[1], at[90]);    MULADD(at[2], at[89]);    MULADD(at[3], at[88]);    MULADD(at[4], at[87]);    MULADD(at[5], at[86]);    MULADD(at[6], at[85]);    MULADD(at[7], at[84]);    MULADD(at[8], at[83]);    MULADD(at[9], at[82]);    MULADD(at[10], at[81]);    MULADD(at[11], at[80]);    MULADD(at[12], at[79]);    MULADD(at[13], at[78]);    MULADD(at[14], at[77]);    MULADD(at[15], at[76]);    MULADD(at[16], at[75]);    MULADD(at[17], at[74]);    MULADD(at[18], at[73]);    MULADD(at[19], at[72]);    MULADD(at[20], at[71]);    MULADD(at[21], at[70]);    MULADD(at[22], at[69]);    MULADD(at[23], at[68]);    MULADD(at[24], at[67]);    MULADD(at[25], at[66]);    MULADD(at[26], at[65]);    MULADD(at[27], at[64]);    MULADD(at[28], at[63]);    MULADD(at[29], at[62]);    MULADD(at[30], at[61]);    MULADD(at[31], at[60]);    MULADD(at[32], at[59]);    MULADD(at[33], at[58]);    MULADD(at[34], at[57]);    MULADD(at[35], at[56]);    MULADD(at[36], at[55]);    MULADD(at[37], at[54]);    MULADD(at[38], at[53]);    MULADD(at[39], at[52]);    MULADD(at[40], at[51]);    MULADD(at[41], at[50]);    MULADD(at[42], at[49]);    MULADD(at[43], at[48]); 
-   COMBA_STORE(C->dp[43]);
-   /* 44 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[92]);    MULADD(at[1], at[91]);    MULADD(at[2], at[90]);    MULADD(at[3], at[89]);    MULADD(at[4], at[88]);    MULADD(at[5], at[87]);    MULADD(at[6], at[86]);    MULADD(at[7], at[85]);    MULADD(at[8], at[84]);    MULADD(at[9], at[83]);    MULADD(at[10], at[82]);    MULADD(at[11], at[81]);    MULADD(at[12], at[80]);    MULADD(at[13], at[79]);    MULADD(at[14], at[78]);    MULADD(at[15], at[77]);    MULADD(at[16], at[76]);    MULADD(at[17], at[75]);    MULADD(at[18], at[74]);    MULADD(at[19], at[73]);    MULADD(at[20], at[72]);    MULADD(at[21], at[71]);    MULADD(at[22], at[70]);    MULADD(at[23], at[69]);    MULADD(at[24], at[68]);    MULADD(at[25], at[67]);    MULADD(at[26], at[66]);    MULADD(at[27], at[65]);    MULADD(at[28], at[64]);    MULADD(at[29], at[63]);    MULADD(at[30], at[62]);    MULADD(at[31], at[61]);    MULADD(at[32], at[60]);    MULADD(at[33], at[59]);    MULADD(at[34], at[58]);    MULADD(at[35], at[57]);    MULADD(at[36], at[56]);    MULADD(at[37], at[55]);    MULADD(at[38], at[54]);    MULADD(at[39], at[53]);    MULADD(at[40], at[52]);    MULADD(at[41], at[51]);    MULADD(at[42], at[50]);    MULADD(at[43], at[49]);    MULADD(at[44], at[48]); 
-   COMBA_STORE(C->dp[44]);
-   /* 45 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[93]);    MULADD(at[1], at[92]);    MULADD(at[2], at[91]);    MULADD(at[3], at[90]);    MULADD(at[4], at[89]);    MULADD(at[5], at[88]);    MULADD(at[6], at[87]);    MULADD(at[7], at[86]);    MULADD(at[8], at[85]);    MULADD(at[9], at[84]);    MULADD(at[10], at[83]);    MULADD(at[11], at[82]);    MULADD(at[12], at[81]);    MULADD(at[13], at[80]);    MULADD(at[14], at[79]);    MULADD(at[15], at[78]);    MULADD(at[16], at[77]);    MULADD(at[17], at[76]);    MULADD(at[18], at[75]);    MULADD(at[19], at[74]);    MULADD(at[20], at[73]);    MULADD(at[21], at[72]);    MULADD(at[22], at[71]);    MULADD(at[23], at[70]);    MULADD(at[24], at[69]);    MULADD(at[25], at[68]);    MULADD(at[26], at[67]);    MULADD(at[27], at[66]);    MULADD(at[28], at[65]);    MULADD(at[29], at[64]);    MULADD(at[30], at[63]);    MULADD(at[31], at[62]);    MULADD(at[32], at[61]);    MULADD(at[33], at[60]);    MULADD(at[34], at[59]);    MULADD(at[35], at[58]);    MULADD(at[36], at[57]);    MULADD(at[37], at[56]);    MULADD(at[38], at[55]);    MULADD(at[39], at[54]);    MULADD(at[40], at[53]);    MULADD(at[41], at[52]);    MULADD(at[42], at[51]);    MULADD(at[43], at[50]);    MULADD(at[44], at[49]);    MULADD(at[45], at[48]); 
-   COMBA_STORE(C->dp[45]);
-   /* 46 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[94]);    MULADD(at[1], at[93]);    MULADD(at[2], at[92]);    MULADD(at[3], at[91]);    MULADD(at[4], at[90]);    MULADD(at[5], at[89]);    MULADD(at[6], at[88]);    MULADD(at[7], at[87]);    MULADD(at[8], at[86]);    MULADD(at[9], at[85]);    MULADD(at[10], at[84]);    MULADD(at[11], at[83]);    MULADD(at[12], at[82]);    MULADD(at[13], at[81]);    MULADD(at[14], at[80]);    MULADD(at[15], at[79]);    MULADD(at[16], at[78]);    MULADD(at[17], at[77]);    MULADD(at[18], at[76]);    MULADD(at[19], at[75]);    MULADD(at[20], at[74]);    MULADD(at[21], at[73]);    MULADD(at[22], at[72]);    MULADD(at[23], at[71]);    MULADD(at[24], at[70]);    MULADD(at[25], at[69]);    MULADD(at[26], at[68]);    MULADD(at[27], at[67]);    MULADD(at[28], at[66]);    MULADD(at[29], at[65]);    MULADD(at[30], at[64]);    MULADD(at[31], at[63]);    MULADD(at[32], at[62]);    MULADD(at[33], at[61]);    MULADD(at[34], at[60]);    MULADD(at[35], at[59]);    MULADD(at[36], at[58]);    MULADD(at[37], at[57]);    MULADD(at[38], at[56]);    MULADD(at[39], at[55]);    MULADD(at[40], at[54]);    MULADD(at[41], at[53]);    MULADD(at[42], at[52]);    MULADD(at[43], at[51]);    MULADD(at[44], at[50]);    MULADD(at[45], at[49]);    MULADD(at[46], at[48]); 
-   COMBA_STORE(C->dp[46]);
-   /* 47 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[95]);    MULADD(at[1], at[94]);    MULADD(at[2], at[93]);    MULADD(at[3], at[92]);    MULADD(at[4], at[91]);    MULADD(at[5], at[90]);    MULADD(at[6], at[89]);    MULADD(at[7], at[88]);    MULADD(at[8], at[87]);    MULADD(at[9], at[86]);    MULADD(at[10], at[85]);    MULADD(at[11], at[84]);    MULADD(at[12], at[83]);    MULADD(at[13], at[82]);    MULADD(at[14], at[81]);    MULADD(at[15], at[80]);    MULADD(at[16], at[79]);    MULADD(at[17], at[78]);    MULADD(at[18], at[77]);    MULADD(at[19], at[76]);    MULADD(at[20], at[75]);    MULADD(at[21], at[74]);    MULADD(at[22], at[73]);    MULADD(at[23], at[72]);    MULADD(at[24], at[71]);    MULADD(at[25], at[70]);    MULADD(at[26], at[69]);    MULADD(at[27], at[68]);    MULADD(at[28], at[67]);    MULADD(at[29], at[66]);    MULADD(at[30], at[65]);    MULADD(at[31], at[64]);    MULADD(at[32], at[63]);    MULADD(at[33], at[62]);    MULADD(at[34], at[61]);    MULADD(at[35], at[60]);    MULADD(at[36], at[59]);    MULADD(at[37], at[58]);    MULADD(at[38], at[57]);    MULADD(at[39], at[56]);    MULADD(at[40], at[55]);    MULADD(at[41], at[54]);    MULADD(at[42], at[53]);    MULADD(at[43], at[52]);    MULADD(at[44], at[51]);    MULADD(at[45], at[50]);    MULADD(at[46], at[49]);    MULADD(at[47], at[48]); 
-   COMBA_STORE(C->dp[47]);
-   /* 48 */
-   COMBA_FORWARD;
-   MULADD(at[1], at[95]);    MULADD(at[2], at[94]);    MULADD(at[3], at[93]);    MULADD(at[4], at[92]);    MULADD(at[5], at[91]);    MULADD(at[6], at[90]);    MULADD(at[7], at[89]);    MULADD(at[8], at[88]);    MULADD(at[9], at[87]);    MULADD(at[10], at[86]);    MULADD(at[11], at[85]);    MULADD(at[12], at[84]);    MULADD(at[13], at[83]);    MULADD(at[14], at[82]);    MULADD(at[15], at[81]);    MULADD(at[16], at[80]);    MULADD(at[17], at[79]);    MULADD(at[18], at[78]);    MULADD(at[19], at[77]);    MULADD(at[20], at[76]);    MULADD(at[21], at[75]);    MULADD(at[22], at[74]);    MULADD(at[23], at[73]);    MULADD(at[24], at[72]);    MULADD(at[25], at[71]);    MULADD(at[26], at[70]);    MULADD(at[27], at[69]);    MULADD(at[28], at[68]);    MULADD(at[29], at[67]);    MULADD(at[30], at[66]);    MULADD(at[31], at[65]);    MULADD(at[32], at[64]);    MULADD(at[33], at[63]);    MULADD(at[34], at[62]);    MULADD(at[35], at[61]);    MULADD(at[36], at[60]);    MULADD(at[37], at[59]);    MULADD(at[38], at[58]);    MULADD(at[39], at[57]);    MULADD(at[40], at[56]);    MULADD(at[41], at[55]);    MULADD(at[42], at[54]);    MULADD(at[43], at[53]);    MULADD(at[44], at[52]);    MULADD(at[45], at[51]);    MULADD(at[46], at[50]);    MULADD(at[47], at[49]); 
-   COMBA_STORE(C->dp[48]);
-   /* 49 */
-   COMBA_FORWARD;
-   MULADD(at[2], at[95]);    MULADD(at[3], at[94]);    MULADD(at[4], at[93]);    MULADD(at[5], at[92]);    MULADD(at[6], at[91]);    MULADD(at[7], at[90]);    MULADD(at[8], at[89]);    MULADD(at[9], at[88]);    MULADD(at[10], at[87]);    MULADD(at[11], at[86]);    MULADD(at[12], at[85]);    MULADD(at[13], at[84]);    MULADD(at[14], at[83]);    MULADD(at[15], at[82]);    MULADD(at[16], at[81]);    MULADD(at[17], at[80]);    MULADD(at[18], at[79]);    MULADD(at[19], at[78]);    MULADD(at[20], at[77]);    MULADD(at[21], at[76]);    MULADD(at[22], at[75]);    MULADD(at[23], at[74]);    MULADD(at[24], at[73]);    MULADD(at[25], at[72]);    MULADD(at[26], at[71]);    MULADD(at[27], at[70]);    MULADD(at[28], at[69]);    MULADD(at[29], at[68]);    MULADD(at[30], at[67]);    MULADD(at[31], at[66]);    MULADD(at[32], at[65]);    MULADD(at[33], at[64]);    MULADD(at[34], at[63]);    MULADD(at[35], at[62]);    MULADD(at[36], at[61]);    MULADD(at[37], at[60]);    MULADD(at[38], at[59]);    MULADD(at[39], at[58]);    MULADD(at[40], at[57]);    MULADD(at[41], at[56]);    MULADD(at[42], at[55]);    MULADD(at[43], at[54]);    MULADD(at[44], at[53]);    MULADD(at[45], at[52]);    MULADD(at[46], at[51]);    MULADD(at[47], at[50]); 
-   COMBA_STORE(C->dp[49]);
-   /* 50 */
-   COMBA_FORWARD;
-   MULADD(at[3], at[95]);    MULADD(at[4], at[94]);    MULADD(at[5], at[93]);    MULADD(at[6], at[92]);    MULADD(at[7], at[91]);    MULADD(at[8], at[90]);    MULADD(at[9], at[89]);    MULADD(at[10], at[88]);    MULADD(at[11], at[87]);    MULADD(at[12], at[86]);    MULADD(at[13], at[85]);    MULADD(at[14], at[84]);    MULADD(at[15], at[83]);    MULADD(at[16], at[82]);    MULADD(at[17], at[81]);    MULADD(at[18], at[80]);    MULADD(at[19], at[79]);    MULADD(at[20], at[78]);    MULADD(at[21], at[77]);    MULADD(at[22], at[76]);    MULADD(at[23], at[75]);    MULADD(at[24], at[74]);    MULADD(at[25], at[73]);    MULADD(at[26], at[72]);    MULADD(at[27], at[71]);    MULADD(at[28], at[70]);    MULADD(at[29], at[69]);    MULADD(at[30], at[68]);    MULADD(at[31], at[67]);    MULADD(at[32], at[66]);    MULADD(at[33], at[65]);    MULADD(at[34], at[64]);    MULADD(at[35], at[63]);    MULADD(at[36], at[62]);    MULADD(at[37], at[61]);    MULADD(at[38], at[60]);    MULADD(at[39], at[59]);    MULADD(at[40], at[58]);    MULADD(at[41], at[57]);    MULADD(at[42], at[56]);    MULADD(at[43], at[55]);    MULADD(at[44], at[54]);    MULADD(at[45], at[53]);    MULADD(at[46], at[52]);    MULADD(at[47], at[51]); 
-   COMBA_STORE(C->dp[50]);
-   /* 51 */
-   COMBA_FORWARD;
-   MULADD(at[4], at[95]);    MULADD(at[5], at[94]);    MULADD(at[6], at[93]);    MULADD(at[7], at[92]);    MULADD(at[8], at[91]);    MULADD(at[9], at[90]);    MULADD(at[10], at[89]);    MULADD(at[11], at[88]);    MULADD(at[12], at[87]);    MULADD(at[13], at[86]);    MULADD(at[14], at[85]);    MULADD(at[15], at[84]);    MULADD(at[16], at[83]);    MULADD(at[17], at[82]);    MULADD(at[18], at[81]);    MULADD(at[19], at[80]);    MULADD(at[20], at[79]);    MULADD(at[21], at[78]);    MULADD(at[22], at[77]);    MULADD(at[23], at[76]);    MULADD(at[24], at[75]);    MULADD(at[25], at[74]);    MULADD(at[26], at[73]);    MULADD(at[27], at[72]);    MULADD(at[28], at[71]);    MULADD(at[29], at[70]);    MULADD(at[30], at[69]);    MULADD(at[31], at[68]);    MULADD(at[32], at[67]);    MULADD(at[33], at[66]);    MULADD(at[34], at[65]);    MULADD(at[35], at[64]);    MULADD(at[36], at[63]);    MULADD(at[37], at[62]);    MULADD(at[38], at[61]);    MULADD(at[39], at[60]);    MULADD(at[40], at[59]);    MULADD(at[41], at[58]);    MULADD(at[42], at[57]);    MULADD(at[43], at[56]);    MULADD(at[44], at[55]);    MULADD(at[45], at[54]);    MULADD(at[46], at[53]);    MULADD(at[47], at[52]); 
-   COMBA_STORE(C->dp[51]);
-   /* 52 */
-   COMBA_FORWARD;
-   MULADD(at[5], at[95]);    MULADD(at[6], at[94]);    MULADD(at[7], at[93]);    MULADD(at[8], at[92]);    MULADD(at[9], at[91]);    MULADD(at[10], at[90]);    MULADD(at[11], at[89]);    MULADD(at[12], at[88]);    MULADD(at[13], at[87]);    MULADD(at[14], at[86]);    MULADD(at[15], at[85]);    MULADD(at[16], at[84]);    MULADD(at[17], at[83]);    MULADD(at[18], at[82]);    MULADD(at[19], at[81]);    MULADD(at[20], at[80]);    MULADD(at[21], at[79]);    MULADD(at[22], at[78]);    MULADD(at[23], at[77]);    MULADD(at[24], at[76]);    MULADD(at[25], at[75]);    MULADD(at[26], at[74]);    MULADD(at[27], at[73]);    MULADD(at[28], at[72]);    MULADD(at[29], at[71]);    MULADD(at[30], at[70]);    MULADD(at[31], at[69]);    MULADD(at[32], at[68]);    MULADD(at[33], at[67]);    MULADD(at[34], at[66]);    MULADD(at[35], at[65]);    MULADD(at[36], at[64]);    MULADD(at[37], at[63]);    MULADD(at[38], at[62]);    MULADD(at[39], at[61]);    MULADD(at[40], at[60]);    MULADD(at[41], at[59]);    MULADD(at[42], at[58]);    MULADD(at[43], at[57]);    MULADD(at[44], at[56]);    MULADD(at[45], at[55]);    MULADD(at[46], at[54]);    MULADD(at[47], at[53]); 
-   COMBA_STORE(C->dp[52]);
-   /* 53 */
-   COMBA_FORWARD;
-   MULADD(at[6], at[95]);    MULADD(at[7], at[94]);    MULADD(at[8], at[93]);    MULADD(at[9], at[92]);    MULADD(at[10], at[91]);    MULADD(at[11], at[90]);    MULADD(at[12], at[89]);    MULADD(at[13], at[88]);    MULADD(at[14], at[87]);    MULADD(at[15], at[86]);    MULADD(at[16], at[85]);    MULADD(at[17], at[84]);    MULADD(at[18], at[83]);    MULADD(at[19], at[82]);    MULADD(at[20], at[81]);    MULADD(at[21], at[80]);    MULADD(at[22], at[79]);    MULADD(at[23], at[78]);    MULADD(at[24], at[77]);    MULADD(at[25], at[76]);    MULADD(at[26], at[75]);    MULADD(at[27], at[74]);    MULADD(at[28], at[73]);    MULADD(at[29], at[72]);    MULADD(at[30], at[71]);    MULADD(at[31], at[70]);    MULADD(at[32], at[69]);    MULADD(at[33], at[68]);    MULADD(at[34], at[67]);    MULADD(at[35], at[66]);    MULADD(at[36], at[65]);    MULADD(at[37], at[64]);    MULADD(at[38], at[63]);    MULADD(at[39], at[62]);    MULADD(at[40], at[61]);    MULADD(at[41], at[60]);    MULADD(at[42], at[59]);    MULADD(at[43], at[58]);    MULADD(at[44], at[57]);    MULADD(at[45], at[56]);    MULADD(at[46], at[55]);    MULADD(at[47], at[54]); 
-   COMBA_STORE(C->dp[53]);
-   /* 54 */
-   COMBA_FORWARD;
-   MULADD(at[7], at[95]);    MULADD(at[8], at[94]);    MULADD(at[9], at[93]);    MULADD(at[10], at[92]);    MULADD(at[11], at[91]);    MULADD(at[12], at[90]);    MULADD(at[13], at[89]);    MULADD(at[14], at[88]);    MULADD(at[15], at[87]);    MULADD(at[16], at[86]);    MULADD(at[17], at[85]);    MULADD(at[18], at[84]);    MULADD(at[19], at[83]);    MULADD(at[20], at[82]);    MULADD(at[21], at[81]);    MULADD(at[22], at[80]);    MULADD(at[23], at[79]);    MULADD(at[24], at[78]);    MULADD(at[25], at[77]);    MULADD(at[26], at[76]);    MULADD(at[27], at[75]);    MULADD(at[28], at[74]);    MULADD(at[29], at[73]);    MULADD(at[30], at[72]);    MULADD(at[31], at[71]);    MULADD(at[32], at[70]);    MULADD(at[33], at[69]);    MULADD(at[34], at[68]);    MULADD(at[35], at[67]);    MULADD(at[36], at[66]);    MULADD(at[37], at[65]);    MULADD(at[38], at[64]);    MULADD(at[39], at[63]);    MULADD(at[40], at[62]);    MULADD(at[41], at[61]);    MULADD(at[42], at[60]);    MULADD(at[43], at[59]);    MULADD(at[44], at[58]);    MULADD(at[45], at[57]);    MULADD(at[46], at[56]);    MULADD(at[47], at[55]); 
-   COMBA_STORE(C->dp[54]);
-   /* 55 */
-   COMBA_FORWARD;
-   MULADD(at[8], at[95]);    MULADD(at[9], at[94]);    MULADD(at[10], at[93]);    MULADD(at[11], at[92]);    MULADD(at[12], at[91]);    MULADD(at[13], at[90]);    MULADD(at[14], at[89]);    MULADD(at[15], at[88]);    MULADD(at[16], at[87]);    MULADD(at[17], at[86]);    MULADD(at[18], at[85]);    MULADD(at[19], at[84]);    MULADD(at[20], at[83]);    MULADD(at[21], at[82]);    MULADD(at[22], at[81]);    MULADD(at[23], at[80]);    MULADD(at[24], at[79]);    MULADD(at[25], at[78]);    MULADD(at[26], at[77]);    MULADD(at[27], at[76]);    MULADD(at[28], at[75]);    MULADD(at[29], at[74]);    MULADD(at[30], at[73]);    MULADD(at[31], at[72]);    MULADD(at[32], at[71]);    MULADD(at[33], at[70]);    MULADD(at[34], at[69]);    MULADD(at[35], at[68]);    MULADD(at[36], at[67]);    MULADD(at[37], at[66]);    MULADD(at[38], at[65]);    MULADD(at[39], at[64]);    MULADD(at[40], at[63]);    MULADD(at[41], at[62]);    MULADD(at[42], at[61]);    MULADD(at[43], at[60]);    MULADD(at[44], at[59]);    MULADD(at[45], at[58]);    MULADD(at[46], at[57]);    MULADD(at[47], at[56]); 
-   COMBA_STORE(C->dp[55]);
-   /* 56 */
-   COMBA_FORWARD;
-   MULADD(at[9], at[95]);    MULADD(at[10], at[94]);    MULADD(at[11], at[93]);    MULADD(at[12], at[92]);    MULADD(at[13], at[91]);    MULADD(at[14], at[90]);    MULADD(at[15], at[89]);    MULADD(at[16], at[88]);    MULADD(at[17], at[87]);    MULADD(at[18], at[86]);    MULADD(at[19], at[85]);    MULADD(at[20], at[84]);    MULADD(at[21], at[83]);    MULADD(at[22], at[82]);    MULADD(at[23], at[81]);    MULADD(at[24], at[80]);    MULADD(at[25], at[79]);    MULADD(at[26], at[78]);    MULADD(at[27], at[77]);    MULADD(at[28], at[76]);    MULADD(at[29], at[75]);    MULADD(at[30], at[74]);    MULADD(at[31], at[73]);    MULADD(at[32], at[72]);    MULADD(at[33], at[71]);    MULADD(at[34], at[70]);    MULADD(at[35], at[69]);    MULADD(at[36], at[68]);    MULADD(at[37], at[67]);    MULADD(at[38], at[66]);    MULADD(at[39], at[65]);    MULADD(at[40], at[64]);    MULADD(at[41], at[63]);    MULADD(at[42], at[62]);    MULADD(at[43], at[61]);    MULADD(at[44], at[60]);    MULADD(at[45], at[59]);    MULADD(at[46], at[58]);    MULADD(at[47], at[57]); 
-   COMBA_STORE(C->dp[56]);
-   /* 57 */
-   COMBA_FORWARD;
-   MULADD(at[10], at[95]);    MULADD(at[11], at[94]);    MULADD(at[12], at[93]);    MULADD(at[13], at[92]);    MULADD(at[14], at[91]);    MULADD(at[15], at[90]);    MULADD(at[16], at[89]);    MULADD(at[17], at[88]);    MULADD(at[18], at[87]);    MULADD(at[19], at[86]);    MULADD(at[20], at[85]);    MULADD(at[21], at[84]);    MULADD(at[22], at[83]);    MULADD(at[23], at[82]);    MULADD(at[24], at[81]);    MULADD(at[25], at[80]);    MULADD(at[26], at[79]);    MULADD(at[27], at[78]);    MULADD(at[28], at[77]);    MULADD(at[29], at[76]);    MULADD(at[30], at[75]);    MULADD(at[31], at[74]);    MULADD(at[32], at[73]);    MULADD(at[33], at[72]);    MULADD(at[34], at[71]);    MULADD(at[35], at[70]);    MULADD(at[36], at[69]);    MULADD(at[37], at[68]);    MULADD(at[38], at[67]);    MULADD(at[39], at[66]);    MULADD(at[40], at[65]);    MULADD(at[41], at[64]);    MULADD(at[42], at[63]);    MULADD(at[43], at[62]);    MULADD(at[44], at[61]);    MULADD(at[45], at[60]);    MULADD(at[46], at[59]);    MULADD(at[47], at[58]); 
-   COMBA_STORE(C->dp[57]);
-   /* 58 */
-   COMBA_FORWARD;
-   MULADD(at[11], at[95]);    MULADD(at[12], at[94]);    MULADD(at[13], at[93]);    MULADD(at[14], at[92]);    MULADD(at[15], at[91]);    MULADD(at[16], at[90]);    MULADD(at[17], at[89]);    MULADD(at[18], at[88]);    MULADD(at[19], at[87]);    MULADD(at[20], at[86]);    MULADD(at[21], at[85]);    MULADD(at[22], at[84]);    MULADD(at[23], at[83]);    MULADD(at[24], at[82]);    MULADD(at[25], at[81]);    MULADD(at[26], at[80]);    MULADD(at[27], at[79]);    MULADD(at[28], at[78]);    MULADD(at[29], at[77]);    MULADD(at[30], at[76]);    MULADD(at[31], at[75]);    MULADD(at[32], at[74]);    MULADD(at[33], at[73]);    MULADD(at[34], at[72]);    MULADD(at[35], at[71]);    MULADD(at[36], at[70]);    MULADD(at[37], at[69]);    MULADD(at[38], at[68]);    MULADD(at[39], at[67]);    MULADD(at[40], at[66]);    MULADD(at[41], at[65]);    MULADD(at[42], at[64]);    MULADD(at[43], at[63]);    MULADD(at[44], at[62]);    MULADD(at[45], at[61]);    MULADD(at[46], at[60]);    MULADD(at[47], at[59]); 
-   COMBA_STORE(C->dp[58]);
-   /* 59 */
-   COMBA_FORWARD;
-   MULADD(at[12], at[95]);    MULADD(at[13], at[94]);    MULADD(at[14], at[93]);    MULADD(at[15], at[92]);    MULADD(at[16], at[91]);    MULADD(at[17], at[90]);    MULADD(at[18], at[89]);    MULADD(at[19], at[88]);    MULADD(at[20], at[87]);    MULADD(at[21], at[86]);    MULADD(at[22], at[85]);    MULADD(at[23], at[84]);    MULADD(at[24], at[83]);    MULADD(at[25], at[82]);    MULADD(at[26], at[81]);    MULADD(at[27], at[80]);    MULADD(at[28], at[79]);    MULADD(at[29], at[78]);    MULADD(at[30], at[77]);    MULADD(at[31], at[76]);    MULADD(at[32], at[75]);    MULADD(at[33], at[74]);    MULADD(at[34], at[73]);    MULADD(at[35], at[72]);    MULADD(at[36], at[71]);    MULADD(at[37], at[70]);    MULADD(at[38], at[69]);    MULADD(at[39], at[68]);    MULADD(at[40], at[67]);    MULADD(at[41], at[66]);    MULADD(at[42], at[65]);    MULADD(at[43], at[64]);    MULADD(at[44], at[63]);    MULADD(at[45], at[62]);    MULADD(at[46], at[61]);    MULADD(at[47], at[60]); 
-   COMBA_STORE(C->dp[59]);
-   /* 60 */
-   COMBA_FORWARD;
-   MULADD(at[13], at[95]);    MULADD(at[14], at[94]);    MULADD(at[15], at[93]);    MULADD(at[16], at[92]);    MULADD(at[17], at[91]);    MULADD(at[18], at[90]);    MULADD(at[19], at[89]);    MULADD(at[20], at[88]);    MULADD(at[21], at[87]);    MULADD(at[22], at[86]);    MULADD(at[23], at[85]);    MULADD(at[24], at[84]);    MULADD(at[25], at[83]);    MULADD(at[26], at[82]);    MULADD(at[27], at[81]);    MULADD(at[28], at[80]);    MULADD(at[29], at[79]);    MULADD(at[30], at[78]);    MULADD(at[31], at[77]);    MULADD(at[32], at[76]);    MULADD(at[33], at[75]);    MULADD(at[34], at[74]);    MULADD(at[35], at[73]);    MULADD(at[36], at[72]);    MULADD(at[37], at[71]);    MULADD(at[38], at[70]);    MULADD(at[39], at[69]);    MULADD(at[40], at[68]);    MULADD(at[41], at[67]);    MULADD(at[42], at[66]);    MULADD(at[43], at[65]);    MULADD(at[44], at[64]);    MULADD(at[45], at[63]);    MULADD(at[46], at[62]);    MULADD(at[47], at[61]); 
-   COMBA_STORE(C->dp[60]);
-   /* 61 */
-   COMBA_FORWARD;
-   MULADD(at[14], at[95]);    MULADD(at[15], at[94]);    MULADD(at[16], at[93]);    MULADD(at[17], at[92]);    MULADD(at[18], at[91]);    MULADD(at[19], at[90]);    MULADD(at[20], at[89]);    MULADD(at[21], at[88]);    MULADD(at[22], at[87]);    MULADD(at[23], at[86]);    MULADD(at[24], at[85]);    MULADD(at[25], at[84]);    MULADD(at[26], at[83]);    MULADD(at[27], at[82]);    MULADD(at[28], at[81]);    MULADD(at[29], at[80]);    MULADD(at[30], at[79]);    MULADD(at[31], at[78]);    MULADD(at[32], at[77]);    MULADD(at[33], at[76]);    MULADD(at[34], at[75]);    MULADD(at[35], at[74]);    MULADD(at[36], at[73]);    MULADD(at[37], at[72]);    MULADD(at[38], at[71]);    MULADD(at[39], at[70]);    MULADD(at[40], at[69]);    MULADD(at[41], at[68]);    MULADD(at[42], at[67]);    MULADD(at[43], at[66]);    MULADD(at[44], at[65]);    MULADD(at[45], at[64]);    MULADD(at[46], at[63]);    MULADD(at[47], at[62]); 
-   COMBA_STORE(C->dp[61]);
-   /* 62 */
-   COMBA_FORWARD;
-   MULADD(at[15], at[95]);    MULADD(at[16], at[94]);    MULADD(at[17], at[93]);    MULADD(at[18], at[92]);    MULADD(at[19], at[91]);    MULADD(at[20], at[90]);    MULADD(at[21], at[89]);    MULADD(at[22], at[88]);    MULADD(at[23], at[87]);    MULADD(at[24], at[86]);    MULADD(at[25], at[85]);    MULADD(at[26], at[84]);    MULADD(at[27], at[83]);    MULADD(at[28], at[82]);    MULADD(at[29], at[81]);    MULADD(at[30], at[80]);    MULADD(at[31], at[79]);    MULADD(at[32], at[78]);    MULADD(at[33], at[77]);    MULADD(at[34], at[76]);    MULADD(at[35], at[75]);    MULADD(at[36], at[74]);    MULADD(at[37], at[73]);    MULADD(at[38], at[72]);    MULADD(at[39], at[71]);    MULADD(at[40], at[70]);    MULADD(at[41], at[69]);    MULADD(at[42], at[68]);    MULADD(at[43], at[67]);    MULADD(at[44], at[66]);    MULADD(at[45], at[65]);    MULADD(at[46], at[64]);    MULADD(at[47], at[63]); 
-   COMBA_STORE(C->dp[62]);
-   /* 63 */
-   COMBA_FORWARD;
-   MULADD(at[16], at[95]);    MULADD(at[17], at[94]);    MULADD(at[18], at[93]);    MULADD(at[19], at[92]);    MULADD(at[20], at[91]);    MULADD(at[21], at[90]);    MULADD(at[22], at[89]);    MULADD(at[23], at[88]);    MULADD(at[24], at[87]);    MULADD(at[25], at[86]);    MULADD(at[26], at[85]);    MULADD(at[27], at[84]);    MULADD(at[28], at[83]);    MULADD(at[29], at[82]);    MULADD(at[30], at[81]);    MULADD(at[31], at[80]);    MULADD(at[32], at[79]);    MULADD(at[33], at[78]);    MULADD(at[34], at[77]);    MULADD(at[35], at[76]);    MULADD(at[36], at[75]);    MULADD(at[37], at[74]);    MULADD(at[38], at[73]);    MULADD(at[39], at[72]);    MULADD(at[40], at[71]);    MULADD(at[41], at[70]);    MULADD(at[42], at[69]);    MULADD(at[43], at[68]);    MULADD(at[44], at[67]);    MULADD(at[45], at[66]);    MULADD(at[46], at[65]);    MULADD(at[47], at[64]); 
-   COMBA_STORE(C->dp[63]);
-   /* 64 */
-   COMBA_FORWARD;
-   MULADD(at[17], at[95]);    MULADD(at[18], at[94]);    MULADD(at[19], at[93]);    MULADD(at[20], at[92]);    MULADD(at[21], at[91]);    MULADD(at[22], at[90]);    MULADD(at[23], at[89]);    MULADD(at[24], at[88]);    MULADD(at[25], at[87]);    MULADD(at[26], at[86]);    MULADD(at[27], at[85]);    MULADD(at[28], at[84]);    MULADD(at[29], at[83]);    MULADD(at[30], at[82]);    MULADD(at[31], at[81]);    MULADD(at[32], at[80]);    MULADD(at[33], at[79]);    MULADD(at[34], at[78]);    MULADD(at[35], at[77]);    MULADD(at[36], at[76]);    MULADD(at[37], at[75]);    MULADD(at[38], at[74]);    MULADD(at[39], at[73]);    MULADD(at[40], at[72]);    MULADD(at[41], at[71]);    MULADD(at[42], at[70]);    MULADD(at[43], at[69]);    MULADD(at[44], at[68]);    MULADD(at[45], at[67]);    MULADD(at[46], at[66]);    MULADD(at[47], at[65]); 
-   COMBA_STORE(C->dp[64]);
-   /* 65 */
-   COMBA_FORWARD;
-   MULADD(at[18], at[95]);    MULADD(at[19], at[94]);    MULADD(at[20], at[93]);    MULADD(at[21], at[92]);    MULADD(at[22], at[91]);    MULADD(at[23], at[90]);    MULADD(at[24], at[89]);    MULADD(at[25], at[88]);    MULADD(at[26], at[87]);    MULADD(at[27], at[86]);    MULADD(at[28], at[85]);    MULADD(at[29], at[84]);    MULADD(at[30], at[83]);    MULADD(at[31], at[82]);    MULADD(at[32], at[81]);    MULADD(at[33], at[80]);    MULADD(at[34], at[79]);    MULADD(at[35], at[78]);    MULADD(at[36], at[77]);    MULADD(at[37], at[76]);    MULADD(at[38], at[75]);    MULADD(at[39], at[74]);    MULADD(at[40], at[73]);    MULADD(at[41], at[72]);    MULADD(at[42], at[71]);    MULADD(at[43], at[70]);    MULADD(at[44], at[69]);    MULADD(at[45], at[68]);    MULADD(at[46], at[67]);    MULADD(at[47], at[66]); 
-   COMBA_STORE(C->dp[65]);
-   /* 66 */
-   COMBA_FORWARD;
-   MULADD(at[19], at[95]);    MULADD(at[20], at[94]);    MULADD(at[21], at[93]);    MULADD(at[22], at[92]);    MULADD(at[23], at[91]);    MULADD(at[24], at[90]);    MULADD(at[25], at[89]);    MULADD(at[26], at[88]);    MULADD(at[27], at[87]);    MULADD(at[28], at[86]);    MULADD(at[29], at[85]);    MULADD(at[30], at[84]);    MULADD(at[31], at[83]);    MULADD(at[32], at[82]);    MULADD(at[33], at[81]);    MULADD(at[34], at[80]);    MULADD(at[35], at[79]);    MULADD(at[36], at[78]);    MULADD(at[37], at[77]);    MULADD(at[38], at[76]);    MULADD(at[39], at[75]);    MULADD(at[40], at[74]);    MULADD(at[41], at[73]);    MULADD(at[42], at[72]);    MULADD(at[43], at[71]);    MULADD(at[44], at[70]);    MULADD(at[45], at[69]);    MULADD(at[46], at[68]);    MULADD(at[47], at[67]); 
-   COMBA_STORE(C->dp[66]);
-   /* 67 */
-   COMBA_FORWARD;
-   MULADD(at[20], at[95]);    MULADD(at[21], at[94]);    MULADD(at[22], at[93]);    MULADD(at[23], at[92]);    MULADD(at[24], at[91]);    MULADD(at[25], at[90]);    MULADD(at[26], at[89]);    MULADD(at[27], at[88]);    MULADD(at[28], at[87]);    MULADD(at[29], at[86]);    MULADD(at[30], at[85]);    MULADD(at[31], at[84]);    MULADD(at[32], at[83]);    MULADD(at[33], at[82]);    MULADD(at[34], at[81]);    MULADD(at[35], at[80]);    MULADD(at[36], at[79]);    MULADD(at[37], at[78]);    MULADD(at[38], at[77]);    MULADD(at[39], at[76]);    MULADD(at[40], at[75]);    MULADD(at[41], at[74]);    MULADD(at[42], at[73]);    MULADD(at[43], at[72]);    MULADD(at[44], at[71]);    MULADD(at[45], at[70]);    MULADD(at[46], at[69]);    MULADD(at[47], at[68]); 
-   COMBA_STORE(C->dp[67]);
-   /* 68 */
-   COMBA_FORWARD;
-   MULADD(at[21], at[95]);    MULADD(at[22], at[94]);    MULADD(at[23], at[93]);    MULADD(at[24], at[92]);    MULADD(at[25], at[91]);    MULADD(at[26], at[90]);    MULADD(at[27], at[89]);    MULADD(at[28], at[88]);    MULADD(at[29], at[87]);    MULADD(at[30], at[86]);    MULADD(at[31], at[85]);    MULADD(at[32], at[84]);    MULADD(at[33], at[83]);    MULADD(at[34], at[82]);    MULADD(at[35], at[81]);    MULADD(at[36], at[80]);    MULADD(at[37], at[79]);    MULADD(at[38], at[78]);    MULADD(at[39], at[77]);    MULADD(at[40], at[76]);    MULADD(at[41], at[75]);    MULADD(at[42], at[74]);    MULADD(at[43], at[73]);    MULADD(at[44], at[72]);    MULADD(at[45], at[71]);    MULADD(at[46], at[70]);    MULADD(at[47], at[69]); 
-   COMBA_STORE(C->dp[68]);
-   /* 69 */
-   COMBA_FORWARD;
-   MULADD(at[22], at[95]);    MULADD(at[23], at[94]);    MULADD(at[24], at[93]);    MULADD(at[25], at[92]);    MULADD(at[26], at[91]);    MULADD(at[27], at[90]);    MULADD(at[28], at[89]);    MULADD(at[29], at[88]);    MULADD(at[30], at[87]);    MULADD(at[31], at[86]);    MULADD(at[32], at[85]);    MULADD(at[33], at[84]);    MULADD(at[34], at[83]);    MULADD(at[35], at[82]);    MULADD(at[36], at[81]);    MULADD(at[37], at[80]);    MULADD(at[38], at[79]);    MULADD(at[39], at[78]);    MULADD(at[40], at[77]);    MULADD(at[41], at[76]);    MULADD(at[42], at[75]);    MULADD(at[43], at[74]);    MULADD(at[44], at[73]);    MULADD(at[45], at[72]);    MULADD(at[46], at[71]);    MULADD(at[47], at[70]); 
-   COMBA_STORE(C->dp[69]);
-   /* 70 */
-   COMBA_FORWARD;
-   MULADD(at[23], at[95]);    MULADD(at[24], at[94]);    MULADD(at[25], at[93]);    MULADD(at[26], at[92]);    MULADD(at[27], at[91]);    MULADD(at[28], at[90]);    MULADD(at[29], at[89]);    MULADD(at[30], at[88]);    MULADD(at[31], at[87]);    MULADD(at[32], at[86]);    MULADD(at[33], at[85]);    MULADD(at[34], at[84]);    MULADD(at[35], at[83]);    MULADD(at[36], at[82]);    MULADD(at[37], at[81]);    MULADD(at[38], at[80]);    MULADD(at[39], at[79]);    MULADD(at[40], at[78]);    MULADD(at[41], at[77]);    MULADD(at[42], at[76]);    MULADD(at[43], at[75]);    MULADD(at[44], at[74]);    MULADD(at[45], at[73]);    MULADD(at[46], at[72]);    MULADD(at[47], at[71]); 
-   COMBA_STORE(C->dp[70]);
-   /* 71 */
-   COMBA_FORWARD;
-   MULADD(at[24], at[95]);    MULADD(at[25], at[94]);    MULADD(at[26], at[93]);    MULADD(at[27], at[92]);    MULADD(at[28], at[91]);    MULADD(at[29], at[90]);    MULADD(at[30], at[89]);    MULADD(at[31], at[88]);    MULADD(at[32], at[87]);    MULADD(at[33], at[86]);    MULADD(at[34], at[85]);    MULADD(at[35], at[84]);    MULADD(at[36], at[83]);    MULADD(at[37], at[82]);    MULADD(at[38], at[81]);    MULADD(at[39], at[80]);    MULADD(at[40], at[79]);    MULADD(at[41], at[78]);    MULADD(at[42], at[77]);    MULADD(at[43], at[76]);    MULADD(at[44], at[75]);    MULADD(at[45], at[74]);    MULADD(at[46], at[73]);    MULADD(at[47], at[72]); 
-   COMBA_STORE(C->dp[71]);
-   /* 72 */
-   COMBA_FORWARD;
-   MULADD(at[25], at[95]);    MULADD(at[26], at[94]);    MULADD(at[27], at[93]);    MULADD(at[28], at[92]);    MULADD(at[29], at[91]);    MULADD(at[30], at[90]);    MULADD(at[31], at[89]);    MULADD(at[32], at[88]);    MULADD(at[33], at[87]);    MULADD(at[34], at[86]);    MULADD(at[35], at[85]);    MULADD(at[36], at[84]);    MULADD(at[37], at[83]);    MULADD(at[38], at[82]);    MULADD(at[39], at[81]);    MULADD(at[40], at[80]);    MULADD(at[41], at[79]);    MULADD(at[42], at[78]);    MULADD(at[43], at[77]);    MULADD(at[44], at[76]);    MULADD(at[45], at[75]);    MULADD(at[46], at[74]);    MULADD(at[47], at[73]); 
-   COMBA_STORE(C->dp[72]);
-   /* 73 */
-   COMBA_FORWARD;
-   MULADD(at[26], at[95]);    MULADD(at[27], at[94]);    MULADD(at[28], at[93]);    MULADD(at[29], at[92]);    MULADD(at[30], at[91]);    MULADD(at[31], at[90]);    MULADD(at[32], at[89]);    MULADD(at[33], at[88]);    MULADD(at[34], at[87]);    MULADD(at[35], at[86]);    MULADD(at[36], at[85]);    MULADD(at[37], at[84]);    MULADD(at[38], at[83]);    MULADD(at[39], at[82]);    MULADD(at[40], at[81]);    MULADD(at[41], at[80]);    MULADD(at[42], at[79]);    MULADD(at[43], at[78]);    MULADD(at[44], at[77]);    MULADD(at[45], at[76]);    MULADD(at[46], at[75]);    MULADD(at[47], at[74]); 
-   COMBA_STORE(C->dp[73]);
-   /* 74 */
-   COMBA_FORWARD;
-   MULADD(at[27], at[95]);    MULADD(at[28], at[94]);    MULADD(at[29], at[93]);    MULADD(at[30], at[92]);    MULADD(at[31], at[91]);    MULADD(at[32], at[90]);    MULADD(at[33], at[89]);    MULADD(at[34], at[88]);    MULADD(at[35], at[87]);    MULADD(at[36], at[86]);    MULADD(at[37], at[85]);    MULADD(at[38], at[84]);    MULADD(at[39], at[83]);    MULADD(at[40], at[82]);    MULADD(at[41], at[81]);    MULADD(at[42], at[80]);    MULADD(at[43], at[79]);    MULADD(at[44], at[78]);    MULADD(at[45], at[77]);    MULADD(at[46], at[76]);    MULADD(at[47], at[75]); 
-   COMBA_STORE(C->dp[74]);
-   /* 75 */
-   COMBA_FORWARD;
-   MULADD(at[28], at[95]);    MULADD(at[29], at[94]);    MULADD(at[30], at[93]);    MULADD(at[31], at[92]);    MULADD(at[32], at[91]);    MULADD(at[33], at[90]);    MULADD(at[34], at[89]);    MULADD(at[35], at[88]);    MULADD(at[36], at[87]);    MULADD(at[37], at[86]);    MULADD(at[38], at[85]);    MULADD(at[39], at[84]);    MULADD(at[40], at[83]);    MULADD(at[41], at[82]);    MULADD(at[42], at[81]);    MULADD(at[43], at[80]);    MULADD(at[44], at[79]);    MULADD(at[45], at[78]);    MULADD(at[46], at[77]);    MULADD(at[47], at[76]); 
-   COMBA_STORE(C->dp[75]);
-   /* 76 */
-   COMBA_FORWARD;
-   MULADD(at[29], at[95]);    MULADD(at[30], at[94]);    MULADD(at[31], at[93]);    MULADD(at[32], at[92]);    MULADD(at[33], at[91]);    MULADD(at[34], at[90]);    MULADD(at[35], at[89]);    MULADD(at[36], at[88]);    MULADD(at[37], at[87]);    MULADD(at[38], at[86]);    MULADD(at[39], at[85]);    MULADD(at[40], at[84]);    MULADD(at[41], at[83]);    MULADD(at[42], at[82]);    MULADD(at[43], at[81]);    MULADD(at[44], at[80]);    MULADD(at[45], at[79]);    MULADD(at[46], at[78]);    MULADD(at[47], at[77]); 
-   COMBA_STORE(C->dp[76]);
-   /* 77 */
-   COMBA_FORWARD;
-   MULADD(at[30], at[95]);    MULADD(at[31], at[94]);    MULADD(at[32], at[93]);    MULADD(at[33], at[92]);    MULADD(at[34], at[91]);    MULADD(at[35], at[90]);    MULADD(at[36], at[89]);    MULADD(at[37], at[88]);    MULADD(at[38], at[87]);    MULADD(at[39], at[86]);    MULADD(at[40], at[85]);    MULADD(at[41], at[84]);    MULADD(at[42], at[83]);    MULADD(at[43], at[82]);    MULADD(at[44], at[81]);    MULADD(at[45], at[80]);    MULADD(at[46], at[79]);    MULADD(at[47], at[78]); 
-   COMBA_STORE(C->dp[77]);
-   /* 78 */
-   COMBA_FORWARD;
-   MULADD(at[31], at[95]);    MULADD(at[32], at[94]);    MULADD(at[33], at[93]);    MULADD(at[34], at[92]);    MULADD(at[35], at[91]);    MULADD(at[36], at[90]);    MULADD(at[37], at[89]);    MULADD(at[38], at[88]);    MULADD(at[39], at[87]);    MULADD(at[40], at[86]);    MULADD(at[41], at[85]);    MULADD(at[42], at[84]);    MULADD(at[43], at[83]);    MULADD(at[44], at[82]);    MULADD(at[45], at[81]);    MULADD(at[46], at[80]);    MULADD(at[47], at[79]); 
-   COMBA_STORE(C->dp[78]);
-   /* 79 */
-   COMBA_FORWARD;
-   MULADD(at[32], at[95]);    MULADD(at[33], at[94]);    MULADD(at[34], at[93]);    MULADD(at[35], at[92]);    MULADD(at[36], at[91]);    MULADD(at[37], at[90]);    MULADD(at[38], at[89]);    MULADD(at[39], at[88]);    MULADD(at[40], at[87]);    MULADD(at[41], at[86]);    MULADD(at[42], at[85]);    MULADD(at[43], at[84]);    MULADD(at[44], at[83]);    MULADD(at[45], at[82]);    MULADD(at[46], at[81]);    MULADD(at[47], at[80]); 
-   COMBA_STORE(C->dp[79]);
-   /* 80 */
-   COMBA_FORWARD;
-   MULADD(at[33], at[95]);    MULADD(at[34], at[94]);    MULADD(at[35], at[93]);    MULADD(at[36], at[92]);    MULADD(at[37], at[91]);    MULADD(at[38], at[90]);    MULADD(at[39], at[89]);    MULADD(at[40], at[88]);    MULADD(at[41], at[87]);    MULADD(at[42], at[86]);    MULADD(at[43], at[85]);    MULADD(at[44], at[84]);    MULADD(at[45], at[83]);    MULADD(at[46], at[82]);    MULADD(at[47], at[81]); 
-   COMBA_STORE(C->dp[80]);
-   /* 81 */
-   COMBA_FORWARD;
-   MULADD(at[34], at[95]);    MULADD(at[35], at[94]);    MULADD(at[36], at[93]);    MULADD(at[37], at[92]);    MULADD(at[38], at[91]);    MULADD(at[39], at[90]);    MULADD(at[40], at[89]);    MULADD(at[41], at[88]);    MULADD(at[42], at[87]);    MULADD(at[43], at[86]);    MULADD(at[44], at[85]);    MULADD(at[45], at[84]);    MULADD(at[46], at[83]);    MULADD(at[47], at[82]); 
-   COMBA_STORE(C->dp[81]);
-   /* 82 */
-   COMBA_FORWARD;
-   MULADD(at[35], at[95]);    MULADD(at[36], at[94]);    MULADD(at[37], at[93]);    MULADD(at[38], at[92]);    MULADD(at[39], at[91]);    MULADD(at[40], at[90]);    MULADD(at[41], at[89]);    MULADD(at[42], at[88]);    MULADD(at[43], at[87]);    MULADD(at[44], at[86]);    MULADD(at[45], at[85]);    MULADD(at[46], at[84]);    MULADD(at[47], at[83]); 
-   COMBA_STORE(C->dp[82]);
-   /* 83 */
-   COMBA_FORWARD;
-   MULADD(at[36], at[95]);    MULADD(at[37], at[94]);    MULADD(at[38], at[93]);    MULADD(at[39], at[92]);    MULADD(at[40], at[91]);    MULADD(at[41], at[90]);    MULADD(at[42], at[89]);    MULADD(at[43], at[88]);    MULADD(at[44], at[87]);    MULADD(at[45], at[86]);    MULADD(at[46], at[85]);    MULADD(at[47], at[84]); 
-   COMBA_STORE(C->dp[83]);
-   /* 84 */
-   COMBA_FORWARD;
-   MULADD(at[37], at[95]);    MULADD(at[38], at[94]);    MULADD(at[39], at[93]);    MULADD(at[40], at[92]);    MULADD(at[41], at[91]);    MULADD(at[42], at[90]);    MULADD(at[43], at[89]);    MULADD(at[44], at[88]);    MULADD(at[45], at[87]);    MULADD(at[46], at[86]);    MULADD(at[47], at[85]); 
-   COMBA_STORE(C->dp[84]);
-   /* 85 */
-   COMBA_FORWARD;
-   MULADD(at[38], at[95]);    MULADD(at[39], at[94]);    MULADD(at[40], at[93]);    MULADD(at[41], at[92]);    MULADD(at[42], at[91]);    MULADD(at[43], at[90]);    MULADD(at[44], at[89]);    MULADD(at[45], at[88]);    MULADD(at[46], at[87]);    MULADD(at[47], at[86]); 
-   COMBA_STORE(C->dp[85]);
-   /* 86 */
-   COMBA_FORWARD;
-   MULADD(at[39], at[95]);    MULADD(at[40], at[94]);    MULADD(at[41], at[93]);    MULADD(at[42], at[92]);    MULADD(at[43], at[91]);    MULADD(at[44], at[90]);    MULADD(at[45], at[89]);    MULADD(at[46], at[88]);    MULADD(at[47], at[87]); 
-   COMBA_STORE(C->dp[86]);
-   /* 87 */
-   COMBA_FORWARD;
-   MULADD(at[40], at[95]);    MULADD(at[41], at[94]);    MULADD(at[42], at[93]);    MULADD(at[43], at[92]);    MULADD(at[44], at[91]);    MULADD(at[45], at[90]);    MULADD(at[46], at[89]);    MULADD(at[47], at[88]); 
-   COMBA_STORE(C->dp[87]);
-   /* 88 */
-   COMBA_FORWARD;
-   MULADD(at[41], at[95]);    MULADD(at[42], at[94]);    MULADD(at[43], at[93]);    MULADD(at[44], at[92]);    MULADD(at[45], at[91]);    MULADD(at[46], at[90]);    MULADD(at[47], at[89]); 
-   COMBA_STORE(C->dp[88]);
-   /* 89 */
-   COMBA_FORWARD;
-   MULADD(at[42], at[95]);    MULADD(at[43], at[94]);    MULADD(at[44], at[93]);    MULADD(at[45], at[92]);    MULADD(at[46], at[91]);    MULADD(at[47], at[90]); 
-   COMBA_STORE(C->dp[89]);
-   /* 90 */
-   COMBA_FORWARD;
-   MULADD(at[43], at[95]);    MULADD(at[44], at[94]);    MULADD(at[45], at[93]);    MULADD(at[46], at[92]);    MULADD(at[47], at[91]); 
-   COMBA_STORE(C->dp[90]);
-   /* 91 */
-   COMBA_FORWARD;
-   MULADD(at[44], at[95]);    MULADD(at[45], at[94]);    MULADD(at[46], at[93]);    MULADD(at[47], at[92]); 
-   COMBA_STORE(C->dp[91]);
-   /* 92 */
-   COMBA_FORWARD;
-   MULADD(at[45], at[95]);    MULADD(at[46], at[94]);    MULADD(at[47], at[93]); 
-   COMBA_STORE(C->dp[92]);
-   /* 93 */
-   COMBA_FORWARD;
-   MULADD(at[46], at[95]);    MULADD(at[47], at[94]); 
-   COMBA_STORE(C->dp[93]);
-   /* 94 */
-   COMBA_FORWARD;
-   MULADD(at[47], at[95]); 
-   COMBA_STORE(C->dp[94]);
-   COMBA_STORE2(C->dp[95]);
-   C->used = 96;
-   C->sign = A->sign ^ B->sign;
-   fp_clamp(C);
-   COMBA_FINI;
-}
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_6.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_6.i
deleted file mode 100755
index 165c270..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_6.i
+++ /dev/null
@@ -1,82 +0,0 @@
-/* fp_mul_comba_6.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_MUL6
-void fp_mul_comba6(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[12];
-
-   memcpy(at, A->dp, 6 * sizeof(fp_digit));
-   memcpy(at+6, B->dp, 6 * sizeof(fp_digit));
-   COMBA_START;
-
-   COMBA_CLEAR;
-   /* 0 */
-   MULADD(at[0], at[6]); 
-   COMBA_STORE(C->dp[0]);
-   /* 1 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[7]);    MULADD(at[1], at[6]); 
-   COMBA_STORE(C->dp[1]);
-   /* 2 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[8]);    MULADD(at[1], at[7]);    MULADD(at[2], at[6]); 
-   COMBA_STORE(C->dp[2]);
-   /* 3 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[9]);    MULADD(at[1], at[8]);    MULADD(at[2], at[7]);    MULADD(at[3], at[6]); 
-   COMBA_STORE(C->dp[3]);
-   /* 4 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[10]);    MULADD(at[1], at[9]);    MULADD(at[2], at[8]);    MULADD(at[3], at[7]);    MULADD(at[4], at[6]); 
-   COMBA_STORE(C->dp[4]);
-   /* 5 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[11]);    MULADD(at[1], at[10]);    MULADD(at[2], at[9]);    MULADD(at[3], at[8]);    MULADD(at[4], at[7]);    MULADD(at[5], at[6]); 
-   COMBA_STORE(C->dp[5]);
-   /* 6 */
-   COMBA_FORWARD;
-   MULADD(at[1], at[11]);    MULADD(at[2], at[10]);    MULADD(at[3], at[9]);    MULADD(at[4], at[8]);    MULADD(at[5], at[7]); 
-   COMBA_STORE(C->dp[6]);
-   /* 7 */
-   COMBA_FORWARD;
-   MULADD(at[2], at[11]);    MULADD(at[3], at[10]);    MULADD(at[4], at[9]);    MULADD(at[5], at[8]); 
-   COMBA_STORE(C->dp[7]);
-   /* 8 */
-   COMBA_FORWARD;
-   MULADD(at[3], at[11]);    MULADD(at[4], at[10]);    MULADD(at[5], at[9]); 
-   COMBA_STORE(C->dp[8]);
-   /* 9 */
-   COMBA_FORWARD;
-   MULADD(at[4], at[11]);    MULADD(at[5], at[10]); 
-   COMBA_STORE(C->dp[9]);
-   /* 10 */
-   COMBA_FORWARD;
-   MULADD(at[5], at[11]); 
-   COMBA_STORE(C->dp[10]);
-   COMBA_STORE2(C->dp[11]);
-   C->used = 12;
-   C->sign = A->sign ^ B->sign;
-   fp_clamp(C);
-   COMBA_FINI;
-}
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_64.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_64.i
deleted file mode 100755
index 76d7c21..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_64.i
+++ /dev/null
@@ -1,546 +0,0 @@
-/* fp_mul_comba_64.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_MUL64
-void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[128];
-
-   memcpy(at, A->dp, 64 * sizeof(fp_digit));
-   memcpy(at+64, B->dp, 64 * sizeof(fp_digit));
-   COMBA_START;
-
-   COMBA_CLEAR;
-   /* 0 */
-   MULADD(at[0], at[64]); 
-   COMBA_STORE(C->dp[0]);
-   /* 1 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[65]);    MULADD(at[1], at[64]); 
-   COMBA_STORE(C->dp[1]);
-   /* 2 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[66]);    MULADD(at[1], at[65]);    MULADD(at[2], at[64]); 
-   COMBA_STORE(C->dp[2]);
-   /* 3 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[67]);    MULADD(at[1], at[66]);    MULADD(at[2], at[65]);    MULADD(at[3], at[64]); 
-   COMBA_STORE(C->dp[3]);
-   /* 4 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[68]);    MULADD(at[1], at[67]);    MULADD(at[2], at[66]);    MULADD(at[3], at[65]);    MULADD(at[4], at[64]); 
-   COMBA_STORE(C->dp[4]);
-   /* 5 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[69]);    MULADD(at[1], at[68]);    MULADD(at[2], at[67]);    MULADD(at[3], at[66]);    MULADD(at[4], at[65]);    MULADD(at[5], at[64]); 
-   COMBA_STORE(C->dp[5]);
-   /* 6 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[70]);    MULADD(at[1], at[69]);    MULADD(at[2], at[68]);    MULADD(at[3], at[67]);    MULADD(at[4], at[66]);    MULADD(at[5], at[65]);    MULADD(at[6], at[64]); 
-   COMBA_STORE(C->dp[6]);
-   /* 7 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[71]);    MULADD(at[1], at[70]);    MULADD(at[2], at[69]);    MULADD(at[3], at[68]);    MULADD(at[4], at[67]);    MULADD(at[5], at[66]);    MULADD(at[6], at[65]);    MULADD(at[7], at[64]); 
-   COMBA_STORE(C->dp[7]);
-   /* 8 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[72]);    MULADD(at[1], at[71]);    MULADD(at[2], at[70]);    MULADD(at[3], at[69]);    MULADD(at[4], at[68]);    MULADD(at[5], at[67]);    MULADD(at[6], at[66]);    MULADD(at[7], at[65]);    MULADD(at[8], at[64]); 
-   COMBA_STORE(C->dp[8]);
-   /* 9 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[73]);    MULADD(at[1], at[72]);    MULADD(at[2], at[71]);    MULADD(at[3], at[70]);    MULADD(at[4], at[69]);    MULADD(at[5], at[68]);    MULADD(at[6], at[67]);    MULADD(at[7], at[66]);    MULADD(at[8], at[65]);    MULADD(at[9], at[64]); 
-   COMBA_STORE(C->dp[9]);
-   /* 10 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[74]);    MULADD(at[1], at[73]);    MULADD(at[2], at[72]);    MULADD(at[3], at[71]);    MULADD(at[4], at[70]);    MULADD(at[5], at[69]);    MULADD(at[6], at[68]);    MULADD(at[7], at[67]);    MULADD(at[8], at[66]);    MULADD(at[9], at[65]);    MULADD(at[10], at[64]); 
-   COMBA_STORE(C->dp[10]);
-   /* 11 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[75]);    MULADD(at[1], at[74]);    MULADD(at[2], at[73]);    MULADD(at[3], at[72]);    MULADD(at[4], at[71]);    MULADD(at[5], at[70]);    MULADD(at[6], at[69]);    MULADD(at[7], at[68]);    MULADD(at[8], at[67]);    MULADD(at[9], at[66]);    MULADD(at[10], at[65]);    MULADD(at[11], at[64]); 
-   COMBA_STORE(C->dp[11]);
-   /* 12 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[76]);    MULADD(at[1], at[75]);    MULADD(at[2], at[74]);    MULADD(at[3], at[73]);    MULADD(at[4], at[72]);    MULADD(at[5], at[71]);    MULADD(at[6], at[70]);    MULADD(at[7], at[69]);    MULADD(at[8], at[68]);    MULADD(at[9], at[67]);    MULADD(at[10], at[66]);    MULADD(at[11], at[65]);    MULADD(at[12], at[64]); 
-   COMBA_STORE(C->dp[12]);
-   /* 13 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[77]);    MULADD(at[1], at[76]);    MULADD(at[2], at[75]);    MULADD(at[3], at[74]);    MULADD(at[4], at[73]);    MULADD(at[5], at[72]);    MULADD(at[6], at[71]);    MULADD(at[7], at[70]);    MULADD(at[8], at[69]);    MULADD(at[9], at[68]);    MULADD(at[10], at[67]);    MULADD(at[11], at[66]);    MULADD(at[12], at[65]);    MULADD(at[13], at[64]); 
-   COMBA_STORE(C->dp[13]);
-   /* 14 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[78]);    MULADD(at[1], at[77]);    MULADD(at[2], at[76]);    MULADD(at[3], at[75]);    MULADD(at[4], at[74]);    MULADD(at[5], at[73]);    MULADD(at[6], at[72]);    MULADD(at[7], at[71]);    MULADD(at[8], at[70]);    MULADD(at[9], at[69]);    MULADD(at[10], at[68]);    MULADD(at[11], at[67]);    MULADD(at[12], at[66]);    MULADD(at[13], at[65]);    MULADD(at[14], at[64]); 
-   COMBA_STORE(C->dp[14]);
-   /* 15 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[79]);    MULADD(at[1], at[78]);    MULADD(at[2], at[77]);    MULADD(at[3], at[76]);    MULADD(at[4], at[75]);    MULADD(at[5], at[74]);    MULADD(at[6], at[73]);    MULADD(at[7], at[72]);    MULADD(at[8], at[71]);    MULADD(at[9], at[70]);    MULADD(at[10], at[69]);    MULADD(at[11], at[68]);    MULADD(at[12], at[67]);    MULADD(at[13], at[66]);    MULADD(at[14], at[65]);    MULADD(at[15], at[64]); 
-   COMBA_STORE(C->dp[15]);
-   /* 16 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[80]);    MULADD(at[1], at[79]);    MULADD(at[2], at[78]);    MULADD(at[3], at[77]);    MULADD(at[4], at[76]);    MULADD(at[5], at[75]);    MULADD(at[6], at[74]);    MULADD(at[7], at[73]);    MULADD(at[8], at[72]);    MULADD(at[9], at[71]);    MULADD(at[10], at[70]);    MULADD(at[11], at[69]);    MULADD(at[12], at[68]);    MULADD(at[13], at[67]);    MULADD(at[14], at[66]);    MULADD(at[15], at[65]);    MULADD(at[16], at[64]); 
-   COMBA_STORE(C->dp[16]);
-   /* 17 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[81]);    MULADD(at[1], at[80]);    MULADD(at[2], at[79]);    MULADD(at[3], at[78]);    MULADD(at[4], at[77]);    MULADD(at[5], at[76]);    MULADD(at[6], at[75]);    MULADD(at[7], at[74]);    MULADD(at[8], at[73]);    MULADD(at[9], at[72]);    MULADD(at[10], at[71]);    MULADD(at[11], at[70]);    MULADD(at[12], at[69]);    MULADD(at[13], at[68]);    MULADD(at[14], at[67]);    MULADD(at[15], at[66]);    MULADD(at[16], at[65]);    MULADD(at[17], at[64]); 
-   COMBA_STORE(C->dp[17]);
-   /* 18 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[82]);    MULADD(at[1], at[81]);    MULADD(at[2], at[80]);    MULADD(at[3], at[79]);    MULADD(at[4], at[78]);    MULADD(at[5], at[77]);    MULADD(at[6], at[76]);    MULADD(at[7], at[75]);    MULADD(at[8], at[74]);    MULADD(at[9], at[73]);    MULADD(at[10], at[72]);    MULADD(at[11], at[71]);    MULADD(at[12], at[70]);    MULADD(at[13], at[69]);    MULADD(at[14], at[68]);    MULADD(at[15], at[67]);    MULADD(at[16], at[66]);    MULADD(at[17], at[65]);    MULADD(at[18], at[64]); 
-   COMBA_STORE(C->dp[18]);
-   /* 19 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[83]);    MULADD(at[1], at[82]);    MULADD(at[2], at[81]);    MULADD(at[3], at[80]);    MULADD(at[4], at[79]);    MULADD(at[5], at[78]);    MULADD(at[6], at[77]);    MULADD(at[7], at[76]);    MULADD(at[8], at[75]);    MULADD(at[9], at[74]);    MULADD(at[10], at[73]);    MULADD(at[11], at[72]);    MULADD(at[12], at[71]);    MULADD(at[13], at[70]);    MULADD(at[14], at[69]);    MULADD(at[15], at[68]);    MULADD(at[16], at[67]);    MULADD(at[17], at[66]);    MULADD(at[18], at[65]);    MULADD(at[19], at[64]); 
-   COMBA_STORE(C->dp[19]);
-   /* 20 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[84]);    MULADD(at[1], at[83]);    MULADD(at[2], at[82]);    MULADD(at[3], at[81]);    MULADD(at[4], at[80]);    MULADD(at[5], at[79]);    MULADD(at[6], at[78]);    MULADD(at[7], at[77]);    MULADD(at[8], at[76]);    MULADD(at[9], at[75]);    MULADD(at[10], at[74]);    MULADD(at[11], at[73]);    MULADD(at[12], at[72]);    MULADD(at[13], at[71]);    MULADD(at[14], at[70]);    MULADD(at[15], at[69]);    MULADD(at[16], at[68]);    MULADD(at[17], at[67]);    MULADD(at[18], at[66]);    MULADD(at[19], at[65]);    MULADD(at[20], at[64]); 
-   COMBA_STORE(C->dp[20]);
-   /* 21 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[85]);    MULADD(at[1], at[84]);    MULADD(at[2], at[83]);    MULADD(at[3], at[82]);    MULADD(at[4], at[81]);    MULADD(at[5], at[80]);    MULADD(at[6], at[79]);    MULADD(at[7], at[78]);    MULADD(at[8], at[77]);    MULADD(at[9], at[76]);    MULADD(at[10], at[75]);    MULADD(at[11], at[74]);    MULADD(at[12], at[73]);    MULADD(at[13], at[72]);    MULADD(at[14], at[71]);    MULADD(at[15], at[70]);    MULADD(at[16], at[69]);    MULADD(at[17], at[68]);    MULADD(at[18], at[67]);    MULADD(at[19], at[66]);    MULADD(at[20], at[65]);    MULADD(at[21], at[64]); 
-   COMBA_STORE(C->dp[21]);
-   /* 22 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[86]);    MULADD(at[1], at[85]);    MULADD(at[2], at[84]);    MULADD(at[3], at[83]);    MULADD(at[4], at[82]);    MULADD(at[5], at[81]);    MULADD(at[6], at[80]);    MULADD(at[7], at[79]);    MULADD(at[8], at[78]);    MULADD(at[9], at[77]);    MULADD(at[10], at[76]);    MULADD(at[11], at[75]);    MULADD(at[12], at[74]);    MULADD(at[13], at[73]);    MULADD(at[14], at[72]);    MULADD(at[15], at[71]);    MULADD(at[16], at[70]);    MULADD(at[17], at[69]);    MULADD(at[18], at[68]);    MULADD(at[19], at[67]);    MULADD(at[20], at[66]);    MULADD(at[21], at[65]);    MULADD(at[22], at[64]); 
-   COMBA_STORE(C->dp[22]);
-   /* 23 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[87]);    MULADD(at[1], at[86]);    MULADD(at[2], at[85]);    MULADD(at[3], at[84]);    MULADD(at[4], at[83]);    MULADD(at[5], at[82]);    MULADD(at[6], at[81]);    MULADD(at[7], at[80]);    MULADD(at[8], at[79]);    MULADD(at[9], at[78]);    MULADD(at[10], at[77]);    MULADD(at[11], at[76]);    MULADD(at[12], at[75]);    MULADD(at[13], at[74]);    MULADD(at[14], at[73]);    MULADD(at[15], at[72]);    MULADD(at[16], at[71]);    MULADD(at[17], at[70]);    MULADD(at[18], at[69]);    MULADD(at[19], at[68]);    MULADD(at[20], at[67]);    MULADD(at[21], at[66]);    MULADD(at[22], at[65]);    MULADD(at[23], at[64]); 
-   COMBA_STORE(C->dp[23]);
-   /* 24 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[88]);    MULADD(at[1], at[87]);    MULADD(at[2], at[86]);    MULADD(at[3], at[85]);    MULADD(at[4], at[84]);    MULADD(at[5], at[83]);    MULADD(at[6], at[82]);    MULADD(at[7], at[81]);    MULADD(at[8], at[80]);    MULADD(at[9], at[79]);    MULADD(at[10], at[78]);    MULADD(at[11], at[77]);    MULADD(at[12], at[76]);    MULADD(at[13], at[75]);    MULADD(at[14], at[74]);    MULADD(at[15], at[73]);    MULADD(at[16], at[72]);    MULADD(at[17], at[71]);    MULADD(at[18], at[70]);    MULADD(at[19], at[69]);    MULADD(at[20], at[68]);    MULADD(at[21], at[67]);    MULADD(at[22], at[66]);    MULADD(at[23], at[65]);    MULADD(at[24], at[64]); 
-   COMBA_STORE(C->dp[24]);
-   /* 25 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[89]);    MULADD(at[1], at[88]);    MULADD(at[2], at[87]);    MULADD(at[3], at[86]);    MULADD(at[4], at[85]);    MULADD(at[5], at[84]);    MULADD(at[6], at[83]);    MULADD(at[7], at[82]);    MULADD(at[8], at[81]);    MULADD(at[9], at[80]);    MULADD(at[10], at[79]);    MULADD(at[11], at[78]);    MULADD(at[12], at[77]);    MULADD(at[13], at[76]);    MULADD(at[14], at[75]);    MULADD(at[15], at[74]);    MULADD(at[16], at[73]);    MULADD(at[17], at[72]);    MULADD(at[18], at[71]);    MULADD(at[19], at[70]);    MULADD(at[20], at[69]);    MULADD(at[21], at[68]);    MULADD(at[22], at[67]);    MULADD(at[23], at[66]);    MULADD(at[24], at[65]);    MULADD(at[25], at[64]); 
-   COMBA_STORE(C->dp[25]);
-   /* 26 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[90]);    MULADD(at[1], at[89]);    MULADD(at[2], at[88]);    MULADD(at[3], at[87]);    MULADD(at[4], at[86]);    MULADD(at[5], at[85]);    MULADD(at[6], at[84]);    MULADD(at[7], at[83]);    MULADD(at[8], at[82]);    MULADD(at[9], at[81]);    MULADD(at[10], at[80]);    MULADD(at[11], at[79]);    MULADD(at[12], at[78]);    MULADD(at[13], at[77]);    MULADD(at[14], at[76]);    MULADD(at[15], at[75]);    MULADD(at[16], at[74]);    MULADD(at[17], at[73]);    MULADD(at[18], at[72]);    MULADD(at[19], at[71]);    MULADD(at[20], at[70]);    MULADD(at[21], at[69]);    MULADD(at[22], at[68]);    MULADD(at[23], at[67]);    MULADD(at[24], at[66]);    MULADD(at[25], at[65]);    MULADD(at[26], at[64]); 
-   COMBA_STORE(C->dp[26]);
-   /* 27 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[91]);    MULADD(at[1], at[90]);    MULADD(at[2], at[89]);    MULADD(at[3], at[88]);    MULADD(at[4], at[87]);    MULADD(at[5], at[86]);    MULADD(at[6], at[85]);    MULADD(at[7], at[84]);    MULADD(at[8], at[83]);    MULADD(at[9], at[82]);    MULADD(at[10], at[81]);    MULADD(at[11], at[80]);    MULADD(at[12], at[79]);    MULADD(at[13], at[78]);    MULADD(at[14], at[77]);    MULADD(at[15], at[76]);    MULADD(at[16], at[75]);    MULADD(at[17], at[74]);    MULADD(at[18], at[73]);    MULADD(at[19], at[72]);    MULADD(at[20], at[71]);    MULADD(at[21], at[70]);    MULADD(at[22], at[69]);    MULADD(at[23], at[68]);    MULADD(at[24], at[67]);    MULADD(at[25], at[66]);    MULADD(at[26], at[65]);    MULADD(at[27], at[64]); 
-   COMBA_STORE(C->dp[27]);
-   /* 28 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[92]);    MULADD(at[1], at[91]);    MULADD(at[2], at[90]);    MULADD(at[3], at[89]);    MULADD(at[4], at[88]);    MULADD(at[5], at[87]);    MULADD(at[6], at[86]);    MULADD(at[7], at[85]);    MULADD(at[8], at[84]);    MULADD(at[9], at[83]);    MULADD(at[10], at[82]);    MULADD(at[11], at[81]);    MULADD(at[12], at[80]);    MULADD(at[13], at[79]);    MULADD(at[14], at[78]);    MULADD(at[15], at[77]);    MULADD(at[16], at[76]);    MULADD(at[17], at[75]);    MULADD(at[18], at[74]);    MULADD(at[19], at[73]);    MULADD(at[20], at[72]);    MULADD(at[21], at[71]);    MULADD(at[22], at[70]);    MULADD(at[23], at[69]);    MULADD(at[24], at[68]);    MULADD(at[25], at[67]);    MULADD(at[26], at[66]);    MULADD(at[27], at[65]);    MULADD(at[28], at[64]); 
-   COMBA_STORE(C->dp[28]);
-   /* 29 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[93]);    MULADD(at[1], at[92]);    MULADD(at[2], at[91]);    MULADD(at[3], at[90]);    MULADD(at[4], at[89]);    MULADD(at[5], at[88]);    MULADD(at[6], at[87]);    MULADD(at[7], at[86]);    MULADD(at[8], at[85]);    MULADD(at[9], at[84]);    MULADD(at[10], at[83]);    MULADD(at[11], at[82]);    MULADD(at[12], at[81]);    MULADD(at[13], at[80]);    MULADD(at[14], at[79]);    MULADD(at[15], at[78]);    MULADD(at[16], at[77]);    MULADD(at[17], at[76]);    MULADD(at[18], at[75]);    MULADD(at[19], at[74]);    MULADD(at[20], at[73]);    MULADD(at[21], at[72]);    MULADD(at[22], at[71]);    MULADD(at[23], at[70]);    MULADD(at[24], at[69]);    MULADD(at[25], at[68]);    MULADD(at[26], at[67]);    MULADD(at[27], at[66]);    MULADD(at[28], at[65]);    MULADD(at[29], at[64]); 
-   COMBA_STORE(C->dp[29]);
-   /* 30 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[94]);    MULADD(at[1], at[93]);    MULADD(at[2], at[92]);    MULADD(at[3], at[91]);    MULADD(at[4], at[90]);    MULADD(at[5], at[89]);    MULADD(at[6], at[88]);    MULADD(at[7], at[87]);    MULADD(at[8], at[86]);    MULADD(at[9], at[85]);    MULADD(at[10], at[84]);    MULADD(at[11], at[83]);    MULADD(at[12], at[82]);    MULADD(at[13], at[81]);    MULADD(at[14], at[80]);    MULADD(at[15], at[79]);    MULADD(at[16], at[78]);    MULADD(at[17], at[77]);    MULADD(at[18], at[76]);    MULADD(at[19], at[75]);    MULADD(at[20], at[74]);    MULADD(at[21], at[73]);    MULADD(at[22], at[72]);    MULADD(at[23], at[71]);    MULADD(at[24], at[70]);    MULADD(at[25], at[69]);    MULADD(at[26], at[68]);    MULADD(at[27], at[67]);    MULADD(at[28], at[66]);    MULADD(at[29], at[65]);    MULADD(at[30], at[64]); 
-   COMBA_STORE(C->dp[30]);
-   /* 31 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[95]);    MULADD(at[1], at[94]);    MULADD(at[2], at[93]);    MULADD(at[3], at[92]);    MULADD(at[4], at[91]);    MULADD(at[5], at[90]);    MULADD(at[6], at[89]);    MULADD(at[7], at[88]);    MULADD(at[8], at[87]);    MULADD(at[9], at[86]);    MULADD(at[10], at[85]);    MULADD(at[11], at[84]);    MULADD(at[12], at[83]);    MULADD(at[13], at[82]);    MULADD(at[14], at[81]);    MULADD(at[15], at[80]);    MULADD(at[16], at[79]);    MULADD(at[17], at[78]);    MULADD(at[18], at[77]);    MULADD(at[19], at[76]);    MULADD(at[20], at[75]);    MULADD(at[21], at[74]);    MULADD(at[22], at[73]);    MULADD(at[23], at[72]);    MULADD(at[24], at[71]);    MULADD(at[25], at[70]);    MULADD(at[26], at[69]);    MULADD(at[27], at[68]);    MULADD(at[28], at[67]);    MULADD(at[29], at[66]);    MULADD(at[30], at[65]);    MULADD(at[31], at[64]); 
-   COMBA_STORE(C->dp[31]);
-   /* 32 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[96]);    MULADD(at[1], at[95]);    MULADD(at[2], at[94]);    MULADD(at[3], at[93]);    MULADD(at[4], at[92]);    MULADD(at[5], at[91]);    MULADD(at[6], at[90]);    MULADD(at[7], at[89]);    MULADD(at[8], at[88]);    MULADD(at[9], at[87]);    MULADD(at[10], at[86]);    MULADD(at[11], at[85]);    MULADD(at[12], at[84]);    MULADD(at[13], at[83]);    MULADD(at[14], at[82]);    MULADD(at[15], at[81]);    MULADD(at[16], at[80]);    MULADD(at[17], at[79]);    MULADD(at[18], at[78]);    MULADD(at[19], at[77]);    MULADD(at[20], at[76]);    MULADD(at[21], at[75]);    MULADD(at[22], at[74]);    MULADD(at[23], at[73]);    MULADD(at[24], at[72]);    MULADD(at[25], at[71]);    MULADD(at[26], at[70]);    MULADD(at[27], at[69]);    MULADD(at[28], at[68]);    MULADD(at[29], at[67]);    MULADD(at[30], at[66]);    MULADD(at[31], at[65]);    MULADD(at[32], at[64]); 
-   COMBA_STORE(C->dp[32]);
-   /* 33 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[97]);    MULADD(at[1], at[96]);    MULADD(at[2], at[95]);    MULADD(at[3], at[94]);    MULADD(at[4], at[93]);    MULADD(at[5], at[92]);    MULADD(at[6], at[91]);    MULADD(at[7], at[90]);    MULADD(at[8], at[89]);    MULADD(at[9], at[88]);    MULADD(at[10], at[87]);    MULADD(at[11], at[86]);    MULADD(at[12], at[85]);    MULADD(at[13], at[84]);    MULADD(at[14], at[83]);    MULADD(at[15], at[82]);    MULADD(at[16], at[81]);    MULADD(at[17], at[80]);    MULADD(at[18], at[79]);    MULADD(at[19], at[78]);    MULADD(at[20], at[77]);    MULADD(at[21], at[76]);    MULADD(at[22], at[75]);    MULADD(at[23], at[74]);    MULADD(at[24], at[73]);    MULADD(at[25], at[72]);    MULADD(at[26], at[71]);    MULADD(at[27], at[70]);    MULADD(at[28], at[69]);    MULADD(at[29], at[68]);    MULADD(at[30], at[67]);    MULADD(at[31], at[66]);    MULADD(at[32], at[65]);    MULADD(at[33], at[64]); 
-   COMBA_STORE(C->dp[33]);
-   /* 34 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[98]);    MULADD(at[1], at[97]);    MULADD(at[2], at[96]);    MULADD(at[3], at[95]);    MULADD(at[4], at[94]);    MULADD(at[5], at[93]);    MULADD(at[6], at[92]);    MULADD(at[7], at[91]);    MULADD(at[8], at[90]);    MULADD(at[9], at[89]);    MULADD(at[10], at[88]);    MULADD(at[11], at[87]);    MULADD(at[12], at[86]);    MULADD(at[13], at[85]);    MULADD(at[14], at[84]);    MULADD(at[15], at[83]);    MULADD(at[16], at[82]);    MULADD(at[17], at[81]);    MULADD(at[18], at[80]);    MULADD(at[19], at[79]);    MULADD(at[20], at[78]);    MULADD(at[21], at[77]);    MULADD(at[22], at[76]);    MULADD(at[23], at[75]);    MULADD(at[24], at[74]);    MULADD(at[25], at[73]);    MULADD(at[26], at[72]);    MULADD(at[27], at[71]);    MULADD(at[28], at[70]);    MULADD(at[29], at[69]);    MULADD(at[30], at[68]);    MULADD(at[31], at[67]);    MULADD(at[32], at[66]);    MULADD(at[33], at[65]);    MULADD(at[34], at[64]); 
-   COMBA_STORE(C->dp[34]);
-   /* 35 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[99]);    MULADD(at[1], at[98]);    MULADD(at[2], at[97]);    MULADD(at[3], at[96]);    MULADD(at[4], at[95]);    MULADD(at[5], at[94]);    MULADD(at[6], at[93]);    MULADD(at[7], at[92]);    MULADD(at[8], at[91]);    MULADD(at[9], at[90]);    MULADD(at[10], at[89]);    MULADD(at[11], at[88]);    MULADD(at[12], at[87]);    MULADD(at[13], at[86]);    MULADD(at[14], at[85]);    MULADD(at[15], at[84]);    MULADD(at[16], at[83]);    MULADD(at[17], at[82]);    MULADD(at[18], at[81]);    MULADD(at[19], at[80]);    MULADD(at[20], at[79]);    MULADD(at[21], at[78]);    MULADD(at[22], at[77]);    MULADD(at[23], at[76]);    MULADD(at[24], at[75]);    MULADD(at[25], at[74]);    MULADD(at[26], at[73]);    MULADD(at[27], at[72]);    MULADD(at[28], at[71]);    MULADD(at[29], at[70]);    MULADD(at[30], at[69]);    MULADD(at[31], at[68]);    MULADD(at[32], at[67]);    MULADD(at[33], at[66]);    MULADD(at[34], at[65]);    MULADD(at[35], at[64]); 
-   COMBA_STORE(C->dp[35]);
-   /* 36 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[100]);    MULADD(at[1], at[99]);    MULADD(at[2], at[98]);    MULADD(at[3], at[97]);    MULADD(at[4], at[96]);    MULADD(at[5], at[95]);    MULADD(at[6], at[94]);    MULADD(at[7], at[93]);    MULADD(at[8], at[92]);    MULADD(at[9], at[91]);    MULADD(at[10], at[90]);    MULADD(at[11], at[89]);    MULADD(at[12], at[88]);    MULADD(at[13], at[87]);    MULADD(at[14], at[86]);    MULADD(at[15], at[85]);    MULADD(at[16], at[84]);    MULADD(at[17], at[83]);    MULADD(at[18], at[82]);    MULADD(at[19], at[81]);    MULADD(at[20], at[80]);    MULADD(at[21], at[79]);    MULADD(at[22], at[78]);    MULADD(at[23], at[77]);    MULADD(at[24], at[76]);    MULADD(at[25], at[75]);    MULADD(at[26], at[74]);    MULADD(at[27], at[73]);    MULADD(at[28], at[72]);    MULADD(at[29], at[71]);    MULADD(at[30], at[70]);    MULADD(at[31], at[69]);    MULADD(at[32], at[68]);    MULADD(at[33], at[67]);    MULADD(at[34], at[66]);    MULADD(at[35], at[65]);    MULADD(at[36], at[64]); 
-   COMBA_STORE(C->dp[36]);
-   /* 37 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[101]);    MULADD(at[1], at[100]);    MULADD(at[2], at[99]);    MULADD(at[3], at[98]);    MULADD(at[4], at[97]);    MULADD(at[5], at[96]);    MULADD(at[6], at[95]);    MULADD(at[7], at[94]);    MULADD(at[8], at[93]);    MULADD(at[9], at[92]);    MULADD(at[10], at[91]);    MULADD(at[11], at[90]);    MULADD(at[12], at[89]);    MULADD(at[13], at[88]);    MULADD(at[14], at[87]);    MULADD(at[15], at[86]);    MULADD(at[16], at[85]);    MULADD(at[17], at[84]);    MULADD(at[18], at[83]);    MULADD(at[19], at[82]);    MULADD(at[20], at[81]);    MULADD(at[21], at[80]);    MULADD(at[22], at[79]);    MULADD(at[23], at[78]);    MULADD(at[24], at[77]);    MULADD(at[25], at[76]);    MULADD(at[26], at[75]);    MULADD(at[27], at[74]);    MULADD(at[28], at[73]);    MULADD(at[29], at[72]);    MULADD(at[30], at[71]);    MULADD(at[31], at[70]);    MULADD(at[32], at[69]);    MULADD(at[33], at[68]);    MULADD(at[34], at[67]);    MULADD(at[35], at[66]);    MULADD(at[36], at[65]);    MULADD(at[37], at[64]); 
-   COMBA_STORE(C->dp[37]);
-   /* 38 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[102]);    MULADD(at[1], at[101]);    MULADD(at[2], at[100]);    MULADD(at[3], at[99]);    MULADD(at[4], at[98]);    MULADD(at[5], at[97]);    MULADD(at[6], at[96]);    MULADD(at[7], at[95]);    MULADD(at[8], at[94]);    MULADD(at[9], at[93]);    MULADD(at[10], at[92]);    MULADD(at[11], at[91]);    MULADD(at[12], at[90]);    MULADD(at[13], at[89]);    MULADD(at[14], at[88]);    MULADD(at[15], at[87]);    MULADD(at[16], at[86]);    MULADD(at[17], at[85]);    MULADD(at[18], at[84]);    MULADD(at[19], at[83]);    MULADD(at[20], at[82]);    MULADD(at[21], at[81]);    MULADD(at[22], at[80]);    MULADD(at[23], at[79]);    MULADD(at[24], at[78]);    MULADD(at[25], at[77]);    MULADD(at[26], at[76]);    MULADD(at[27], at[75]);    MULADD(at[28], at[74]);    MULADD(at[29], at[73]);    MULADD(at[30], at[72]);    MULADD(at[31], at[71]);    MULADD(at[32], at[70]);    MULADD(at[33], at[69]);    MULADD(at[34], at[68]);    MULADD(at[35], at[67]);    MULADD(at[36], at[66]);    MULADD(at[37], at[65]);    MULADD(at[38], at[64]); 
-   COMBA_STORE(C->dp[38]);
-   /* 39 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[103]);    MULADD(at[1], at[102]);    MULADD(at[2], at[101]);    MULADD(at[3], at[100]);    MULADD(at[4], at[99]);    MULADD(at[5], at[98]);    MULADD(at[6], at[97]);    MULADD(at[7], at[96]);    MULADD(at[8], at[95]);    MULADD(at[9], at[94]);    MULADD(at[10], at[93]);    MULADD(at[11], at[92]);    MULADD(at[12], at[91]);    MULADD(at[13], at[90]);    MULADD(at[14], at[89]);    MULADD(at[15], at[88]);    MULADD(at[16], at[87]);    MULADD(at[17], at[86]);    MULADD(at[18], at[85]);    MULADD(at[19], at[84]);    MULADD(at[20], at[83]);    MULADD(at[21], at[82]);    MULADD(at[22], at[81]);    MULADD(at[23], at[80]);    MULADD(at[24], at[79]);    MULADD(at[25], at[78]);    MULADD(at[26], at[77]);    MULADD(at[27], at[76]);    MULADD(at[28], at[75]);    MULADD(at[29], at[74]);    MULADD(at[30], at[73]);    MULADD(at[31], at[72]);    MULADD(at[32], at[71]);    MULADD(at[33], at[70]);    MULADD(at[34], at[69]);    MULADD(at[35], at[68]);    MULADD(at[36], at[67]);    MULADD(at[37], at[66]);    MULADD(at[38], at[65]);    MULADD(at[39], at[64]); 
-   COMBA_STORE(C->dp[39]);
-   /* 40 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[104]);    MULADD(at[1], at[103]);    MULADD(at[2], at[102]);    MULADD(at[3], at[101]);    MULADD(at[4], at[100]);    MULADD(at[5], at[99]);    MULADD(at[6], at[98]);    MULADD(at[7], at[97]);    MULADD(at[8], at[96]);    MULADD(at[9], at[95]);    MULADD(at[10], at[94]);    MULADD(at[11], at[93]);    MULADD(at[12], at[92]);    MULADD(at[13], at[91]);    MULADD(at[14], at[90]);    MULADD(at[15], at[89]);    MULADD(at[16], at[88]);    MULADD(at[17], at[87]);    MULADD(at[18], at[86]);    MULADD(at[19], at[85]);    MULADD(at[20], at[84]);    MULADD(at[21], at[83]);    MULADD(at[22], at[82]);    MULADD(at[23], at[81]);    MULADD(at[24], at[80]);    MULADD(at[25], at[79]);    MULADD(at[26], at[78]);    MULADD(at[27], at[77]);    MULADD(at[28], at[76]);    MULADD(at[29], at[75]);    MULADD(at[30], at[74]);    MULADD(at[31], at[73]);    MULADD(at[32], at[72]);    MULADD(at[33], at[71]);    MULADD(at[34], at[70]);    MULADD(at[35], at[69]);    MULADD(at[36], at[68]);    MULADD(at[37], at[67]);    MULADD(at[38], at[66]);    MULADD(at[39], at[65]);    MULADD(at[40], at[64]); 
-   COMBA_STORE(C->dp[40]);
-   /* 41 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[105]);    MULADD(at[1], at[104]);    MULADD(at[2], at[103]);    MULADD(at[3], at[102]);    MULADD(at[4], at[101]);    MULADD(at[5], at[100]);    MULADD(at[6], at[99]);    MULADD(at[7], at[98]);    MULADD(at[8], at[97]);    MULADD(at[9], at[96]);    MULADD(at[10], at[95]);    MULADD(at[11], at[94]);    MULADD(at[12], at[93]);    MULADD(at[13], at[92]);    MULADD(at[14], at[91]);    MULADD(at[15], at[90]);    MULADD(at[16], at[89]);    MULADD(at[17], at[88]);    MULADD(at[18], at[87]);    MULADD(at[19], at[86]);    MULADD(at[20], at[85]);    MULADD(at[21], at[84]);    MULADD(at[22], at[83]);    MULADD(at[23], at[82]);    MULADD(at[24], at[81]);    MULADD(at[25], at[80]);    MULADD(at[26], at[79]);    MULADD(at[27], at[78]);    MULADD(at[28], at[77]);    MULADD(at[29], at[76]);    MULADD(at[30], at[75]);    MULADD(at[31], at[74]);    MULADD(at[32], at[73]);    MULADD(at[33], at[72]);    MULADD(at[34], at[71]);    MULADD(at[35], at[70]);    MULADD(at[36], at[69]);    MULADD(at[37], at[68]);    MULADD(at[38], at[67]);    MULADD(at[39], at[66]);    MULADD(at[40], at[65]);    MULADD(at[41], at[64]); 
-   COMBA_STORE(C->dp[41]);
-   /* 42 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[106]);    MULADD(at[1], at[105]);    MULADD(at[2], at[104]);    MULADD(at[3], at[103]);    MULADD(at[4], at[102]);    MULADD(at[5], at[101]);    MULADD(at[6], at[100]);    MULADD(at[7], at[99]);    MULADD(at[8], at[98]);    MULADD(at[9], at[97]);    MULADD(at[10], at[96]);    MULADD(at[11], at[95]);    MULADD(at[12], at[94]);    MULADD(at[13], at[93]);    MULADD(at[14], at[92]);    MULADD(at[15], at[91]);    MULADD(at[16], at[90]);    MULADD(at[17], at[89]);    MULADD(at[18], at[88]);    MULADD(at[19], at[87]);    MULADD(at[20], at[86]);    MULADD(at[21], at[85]);    MULADD(at[22], at[84]);    MULADD(at[23], at[83]);    MULADD(at[24], at[82]);    MULADD(at[25], at[81]);    MULADD(at[26], at[80]);    MULADD(at[27], at[79]);    MULADD(at[28], at[78]);    MULADD(at[29], at[77]);    MULADD(at[30], at[76]);    MULADD(at[31], at[75]);    MULADD(at[32], at[74]);    MULADD(at[33], at[73]);    MULADD(at[34], at[72]);    MULADD(at[35], at[71]);    MULADD(at[36], at[70]);    MULADD(at[37], at[69]);    MULADD(at[38], at[68]);    MULADD(at[39], at[67]);    MULADD(at[40], at[66]);    MULADD(at[41], at[65]);    MULADD(at[42], at[64]); 
-   COMBA_STORE(C->dp[42]);
-   /* 43 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[107]);    MULADD(at[1], at[106]);    MULADD(at[2], at[105]);    MULADD(at[3], at[104]);    MULADD(at[4], at[103]);    MULADD(at[5], at[102]);    MULADD(at[6], at[101]);    MULADD(at[7], at[100]);    MULADD(at[8], at[99]);    MULADD(at[9], at[98]);    MULADD(at[10], at[97]);    MULADD(at[11], at[96]);    MULADD(at[12], at[95]);    MULADD(at[13], at[94]);    MULADD(at[14], at[93]);    MULADD(at[15], at[92]);    MULADD(at[16], at[91]);    MULADD(at[17], at[90]);    MULADD(at[18], at[89]);    MULADD(at[19], at[88]);    MULADD(at[20], at[87]);    MULADD(at[21], at[86]);    MULADD(at[22], at[85]);    MULADD(at[23], at[84]);    MULADD(at[24], at[83]);    MULADD(at[25], at[82]);    MULADD(at[26], at[81]);    MULADD(at[27], at[80]);    MULADD(at[28], at[79]);    MULADD(at[29], at[78]);    MULADD(at[30], at[77]);    MULADD(at[31], at[76]);    MULADD(at[32], at[75]);    MULADD(at[33], at[74]);    MULADD(at[34], at[73]);    MULADD(at[35], at[72]);    MULADD(at[36], at[71]);    MULADD(at[37], at[70]);    MULADD(at[38], at[69]);    MULADD(at[39], at[68]);    MULADD(at[40], at[67]);    MULADD(at[41], at[66]);    MULADD(at[42], at[65]);    MULADD(at[43], at[64]); 
-   COMBA_STORE(C->dp[43]);
-   /* 44 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[108]);    MULADD(at[1], at[107]);    MULADD(at[2], at[106]);    MULADD(at[3], at[105]);    MULADD(at[4], at[104]);    MULADD(at[5], at[103]);    MULADD(at[6], at[102]);    MULADD(at[7], at[101]);    MULADD(at[8], at[100]);    MULADD(at[9], at[99]);    MULADD(at[10], at[98]);    MULADD(at[11], at[97]);    MULADD(at[12], at[96]);    MULADD(at[13], at[95]);    MULADD(at[14], at[94]);    MULADD(at[15], at[93]);    MULADD(at[16], at[92]);    MULADD(at[17], at[91]);    MULADD(at[18], at[90]);    MULADD(at[19], at[89]);    MULADD(at[20], at[88]);    MULADD(at[21], at[87]);    MULADD(at[22], at[86]);    MULADD(at[23], at[85]);    MULADD(at[24], at[84]);    MULADD(at[25], at[83]);    MULADD(at[26], at[82]);    MULADD(at[27], at[81]);    MULADD(at[28], at[80]);    MULADD(at[29], at[79]);    MULADD(at[30], at[78]);    MULADD(at[31], at[77]);    MULADD(at[32], at[76]);    MULADD(at[33], at[75]);    MULADD(at[34], at[74]);    MULADD(at[35], at[73]);    MULADD(at[36], at[72]);    MULADD(at[37], at[71]);    MULADD(at[38], at[70]);    MULADD(at[39], at[69]);    MULADD(at[40], at[68]);    MULADD(at[41], at[67]);    MULADD(at[42], at[66]);    MULADD(at[43], at[65]);    MULADD(at[44], at[64]); 
-   COMBA_STORE(C->dp[44]);
-   /* 45 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[109]);    MULADD(at[1], at[108]);    MULADD(at[2], at[107]);    MULADD(at[3], at[106]);    MULADD(at[4], at[105]);    MULADD(at[5], at[104]);    MULADD(at[6], at[103]);    MULADD(at[7], at[102]);    MULADD(at[8], at[101]);    MULADD(at[9], at[100]);    MULADD(at[10], at[99]);    MULADD(at[11], at[98]);    MULADD(at[12], at[97]);    MULADD(at[13], at[96]);    MULADD(at[14], at[95]);    MULADD(at[15], at[94]);    MULADD(at[16], at[93]);    MULADD(at[17], at[92]);    MULADD(at[18], at[91]);    MULADD(at[19], at[90]);    MULADD(at[20], at[89]);    MULADD(at[21], at[88]);    MULADD(at[22], at[87]);    MULADD(at[23], at[86]);    MULADD(at[24], at[85]);    MULADD(at[25], at[84]);    MULADD(at[26], at[83]);    MULADD(at[27], at[82]);    MULADD(at[28], at[81]);    MULADD(at[29], at[80]);    MULADD(at[30], at[79]);    MULADD(at[31], at[78]);    MULADD(at[32], at[77]);    MULADD(at[33], at[76]);    MULADD(at[34], at[75]);    MULADD(at[35], at[74]);    MULADD(at[36], at[73]);    MULADD(at[37], at[72]);    MULADD(at[38], at[71]);    MULADD(at[39], at[70]);    MULADD(at[40], at[69]);    MULADD(at[41], at[68]);    MULADD(at[42], at[67]);    MULADD(at[43], at[66]);    MULADD(at[44], at[65]);    MULADD(at[45], at[64]); 
-   COMBA_STORE(C->dp[45]);
-   /* 46 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[110]);    MULADD(at[1], at[109]);    MULADD(at[2], at[108]);    MULADD(at[3], at[107]);    MULADD(at[4], at[106]);    MULADD(at[5], at[105]);    MULADD(at[6], at[104]);    MULADD(at[7], at[103]);    MULADD(at[8], at[102]);    MULADD(at[9], at[101]);    MULADD(at[10], at[100]);    MULADD(at[11], at[99]);    MULADD(at[12], at[98]);    MULADD(at[13], at[97]);    MULADD(at[14], at[96]);    MULADD(at[15], at[95]);    MULADD(at[16], at[94]);    MULADD(at[17], at[93]);    MULADD(at[18], at[92]);    MULADD(at[19], at[91]);    MULADD(at[20], at[90]);    MULADD(at[21], at[89]);    MULADD(at[22], at[88]);    MULADD(at[23], at[87]);    MULADD(at[24], at[86]);    MULADD(at[25], at[85]);    MULADD(at[26], at[84]);    MULADD(at[27], at[83]);    MULADD(at[28], at[82]);    MULADD(at[29], at[81]);    MULADD(at[30], at[80]);    MULADD(at[31], at[79]);    MULADD(at[32], at[78]);    MULADD(at[33], at[77]);    MULADD(at[34], at[76]);    MULADD(at[35], at[75]);    MULADD(at[36], at[74]);    MULADD(at[37], at[73]);    MULADD(at[38], at[72]);    MULADD(at[39], at[71]);    MULADD(at[40], at[70]);    MULADD(at[41], at[69]);    MULADD(at[42], at[68]);    MULADD(at[43], at[67]);    MULADD(at[44], at[66]);    MULADD(at[45], at[65]);    MULADD(at[46], at[64]); 
-   COMBA_STORE(C->dp[46]);
-   /* 47 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[111]);    MULADD(at[1], at[110]);    MULADD(at[2], at[109]);    MULADD(at[3], at[108]);    MULADD(at[4], at[107]);    MULADD(at[5], at[106]);    MULADD(at[6], at[105]);    MULADD(at[7], at[104]);    MULADD(at[8], at[103]);    MULADD(at[9], at[102]);    MULADD(at[10], at[101]);    MULADD(at[11], at[100]);    MULADD(at[12], at[99]);    MULADD(at[13], at[98]);    MULADD(at[14], at[97]);    MULADD(at[15], at[96]);    MULADD(at[16], at[95]);    MULADD(at[17], at[94]);    MULADD(at[18], at[93]);    MULADD(at[19], at[92]);    MULADD(at[20], at[91]);    MULADD(at[21], at[90]);    MULADD(at[22], at[89]);    MULADD(at[23], at[88]);    MULADD(at[24], at[87]);    MULADD(at[25], at[86]);    MULADD(at[26], at[85]);    MULADD(at[27], at[84]);    MULADD(at[28], at[83]);    MULADD(at[29], at[82]);    MULADD(at[30], at[81]);    MULADD(at[31], at[80]);    MULADD(at[32], at[79]);    MULADD(at[33], at[78]);    MULADD(at[34], at[77]);    MULADD(at[35], at[76]);    MULADD(at[36], at[75]);    MULADD(at[37], at[74]);    MULADD(at[38], at[73]);    MULADD(at[39], at[72]);    MULADD(at[40], at[71]);    MULADD(at[41], at[70]);    MULADD(at[42], at[69]);    MULADD(at[43], at[68]);    MULADD(at[44], at[67]);    MULADD(at[45], at[66]);    MULADD(at[46], at[65]);    MULADD(at[47], at[64]); 
-   COMBA_STORE(C->dp[47]);
-   /* 48 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[112]);    MULADD(at[1], at[111]);    MULADD(at[2], at[110]);    MULADD(at[3], at[109]);    MULADD(at[4], at[108]);    MULADD(at[5], at[107]);    MULADD(at[6], at[106]);    MULADD(at[7], at[105]);    MULADD(at[8], at[104]);    MULADD(at[9], at[103]);    MULADD(at[10], at[102]);    MULADD(at[11], at[101]);    MULADD(at[12], at[100]);    MULADD(at[13], at[99]);    MULADD(at[14], at[98]);    MULADD(at[15], at[97]);    MULADD(at[16], at[96]);    MULADD(at[17], at[95]);    MULADD(at[18], at[94]);    MULADD(at[19], at[93]);    MULADD(at[20], at[92]);    MULADD(at[21], at[91]);    MULADD(at[22], at[90]);    MULADD(at[23], at[89]);    MULADD(at[24], at[88]);    MULADD(at[25], at[87]);    MULADD(at[26], at[86]);    MULADD(at[27], at[85]);    MULADD(at[28], at[84]);    MULADD(at[29], at[83]);    MULADD(at[30], at[82]);    MULADD(at[31], at[81]);    MULADD(at[32], at[80]);    MULADD(at[33], at[79]);    MULADD(at[34], at[78]);    MULADD(at[35], at[77]);    MULADD(at[36], at[76]);    MULADD(at[37], at[75]);    MULADD(at[38], at[74]);    MULADD(at[39], at[73]);    MULADD(at[40], at[72]);    MULADD(at[41], at[71]);    MULADD(at[42], at[70]);    MULADD(at[43], at[69]);    MULADD(at[44], at[68]);    MULADD(at[45], at[67]);    MULADD(at[46], at[66]);    MULADD(at[47], at[65]);    MULADD(at[48], at[64]); 
-   COMBA_STORE(C->dp[48]);
-   /* 49 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[113]);    MULADD(at[1], at[112]);    MULADD(at[2], at[111]);    MULADD(at[3], at[110]);    MULADD(at[4], at[109]);    MULADD(at[5], at[108]);    MULADD(at[6], at[107]);    MULADD(at[7], at[106]);    MULADD(at[8], at[105]);    MULADD(at[9], at[104]);    MULADD(at[10], at[103]);    MULADD(at[11], at[102]);    MULADD(at[12], at[101]);    MULADD(at[13], at[100]);    MULADD(at[14], at[99]);    MULADD(at[15], at[98]);    MULADD(at[16], at[97]);    MULADD(at[17], at[96]);    MULADD(at[18], at[95]);    MULADD(at[19], at[94]);    MULADD(at[20], at[93]);    MULADD(at[21], at[92]);    MULADD(at[22], at[91]);    MULADD(at[23], at[90]);    MULADD(at[24], at[89]);    MULADD(at[25], at[88]);    MULADD(at[26], at[87]);    MULADD(at[27], at[86]);    MULADD(at[28], at[85]);    MULADD(at[29], at[84]);    MULADD(at[30], at[83]);    MULADD(at[31], at[82]);    MULADD(at[32], at[81]);    MULADD(at[33], at[80]);    MULADD(at[34], at[79]);    MULADD(at[35], at[78]);    MULADD(at[36], at[77]);    MULADD(at[37], at[76]);    MULADD(at[38], at[75]);    MULADD(at[39], at[74]);    MULADD(at[40], at[73]);    MULADD(at[41], at[72]);    MULADD(at[42], at[71]);    MULADD(at[43], at[70]);    MULADD(at[44], at[69]);    MULADD(at[45], at[68]);    MULADD(at[46], at[67]);    MULADD(at[47], at[66]);    MULADD(at[48], at[65]);    MULADD(at[49], at[64]); 
-   COMBA_STORE(C->dp[49]);
-   /* 50 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[114]);    MULADD(at[1], at[113]);    MULADD(at[2], at[112]);    MULADD(at[3], at[111]);    MULADD(at[4], at[110]);    MULADD(at[5], at[109]);    MULADD(at[6], at[108]);    MULADD(at[7], at[107]);    MULADD(at[8], at[106]);    MULADD(at[9], at[105]);    MULADD(at[10], at[104]);    MULADD(at[11], at[103]);    MULADD(at[12], at[102]);    MULADD(at[13], at[101]);    MULADD(at[14], at[100]);    MULADD(at[15], at[99]);    MULADD(at[16], at[98]);    MULADD(at[17], at[97]);    MULADD(at[18], at[96]);    MULADD(at[19], at[95]);    MULADD(at[20], at[94]);    MULADD(at[21], at[93]);    MULADD(at[22], at[92]);    MULADD(at[23], at[91]);    MULADD(at[24], at[90]);    MULADD(at[25], at[89]);    MULADD(at[26], at[88]);    MULADD(at[27], at[87]);    MULADD(at[28], at[86]);    MULADD(at[29], at[85]);    MULADD(at[30], at[84]);    MULADD(at[31], at[83]);    MULADD(at[32], at[82]);    MULADD(at[33], at[81]);    MULADD(at[34], at[80]);    MULADD(at[35], at[79]);    MULADD(at[36], at[78]);    MULADD(at[37], at[77]);    MULADD(at[38], at[76]);    MULADD(at[39], at[75]);    MULADD(at[40], at[74]);    MULADD(at[41], at[73]);    MULADD(at[42], at[72]);    MULADD(at[43], at[71]);    MULADD(at[44], at[70]);    MULADD(at[45], at[69]);    MULADD(at[46], at[68]);    MULADD(at[47], at[67]);    MULADD(at[48], at[66]);    MULADD(at[49], at[65]);    MULADD(at[50], at[64]); 
-   COMBA_STORE(C->dp[50]);
-   /* 51 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[115]);    MULADD(at[1], at[114]);    MULADD(at[2], at[113]);    MULADD(at[3], at[112]);    MULADD(at[4], at[111]);    MULADD(at[5], at[110]);    MULADD(at[6], at[109]);    MULADD(at[7], at[108]);    MULADD(at[8], at[107]);    MULADD(at[9], at[106]);    MULADD(at[10], at[105]);    MULADD(at[11], at[104]);    MULADD(at[12], at[103]);    MULADD(at[13], at[102]);    MULADD(at[14], at[101]);    MULADD(at[15], at[100]);    MULADD(at[16], at[99]);    MULADD(at[17], at[98]);    MULADD(at[18], at[97]);    MULADD(at[19], at[96]);    MULADD(at[20], at[95]);    MULADD(at[21], at[94]);    MULADD(at[22], at[93]);    MULADD(at[23], at[92]);    MULADD(at[24], at[91]);    MULADD(at[25], at[90]);    MULADD(at[26], at[89]);    MULADD(at[27], at[88]);    MULADD(at[28], at[87]);    MULADD(at[29], at[86]);    MULADD(at[30], at[85]);    MULADD(at[31], at[84]);    MULADD(at[32], at[83]);    MULADD(at[33], at[82]);    MULADD(at[34], at[81]);    MULADD(at[35], at[80]);    MULADD(at[36], at[79]);    MULADD(at[37], at[78]);    MULADD(at[38], at[77]);    MULADD(at[39], at[76]);    MULADD(at[40], at[75]);    MULADD(at[41], at[74]);    MULADD(at[42], at[73]);    MULADD(at[43], at[72]);    MULADD(at[44], at[71]);    MULADD(at[45], at[70]);    MULADD(at[46], at[69]);    MULADD(at[47], at[68]);    MULADD(at[48], at[67]);    MULADD(at[49], at[66]);    MULADD(at[50], at[65]);    MULADD(at[51], at[64]); 
-   COMBA_STORE(C->dp[51]);
-   /* 52 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[116]);    MULADD(at[1], at[115]);    MULADD(at[2], at[114]);    MULADD(at[3], at[113]);    MULADD(at[4], at[112]);    MULADD(at[5], at[111]);    MULADD(at[6], at[110]);    MULADD(at[7], at[109]);    MULADD(at[8], at[108]);    MULADD(at[9], at[107]);    MULADD(at[10], at[106]);    MULADD(at[11], at[105]);    MULADD(at[12], at[104]);    MULADD(at[13], at[103]);    MULADD(at[14], at[102]);    MULADD(at[15], at[101]);    MULADD(at[16], at[100]);    MULADD(at[17], at[99]);    MULADD(at[18], at[98]);    MULADD(at[19], at[97]);    MULADD(at[20], at[96]);    MULADD(at[21], at[95]);    MULADD(at[22], at[94]);    MULADD(at[23], at[93]);    MULADD(at[24], at[92]);    MULADD(at[25], at[91]);    MULADD(at[26], at[90]);    MULADD(at[27], at[89]);    MULADD(at[28], at[88]);    MULADD(at[29], at[87]);    MULADD(at[30], at[86]);    MULADD(at[31], at[85]);    MULADD(at[32], at[84]);    MULADD(at[33], at[83]);    MULADD(at[34], at[82]);    MULADD(at[35], at[81]);    MULADD(at[36], at[80]);    MULADD(at[37], at[79]);    MULADD(at[38], at[78]);    MULADD(at[39], at[77]);    MULADD(at[40], at[76]);    MULADD(at[41], at[75]);    MULADD(at[42], at[74]);    MULADD(at[43], at[73]);    MULADD(at[44], at[72]);    MULADD(at[45], at[71]);    MULADD(at[46], at[70]);    MULADD(at[47], at[69]);    MULADD(at[48], at[68]);    MULADD(at[49], at[67]);    MULADD(at[50], at[66]);    MULADD(at[51], at[65]);    MULADD(at[52], at[64]); 
-   COMBA_STORE(C->dp[52]);
-   /* 53 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[117]);    MULADD(at[1], at[116]);    MULADD(at[2], at[115]);    MULADD(at[3], at[114]);    MULADD(at[4], at[113]);    MULADD(at[5], at[112]);    MULADD(at[6], at[111]);    MULADD(at[7], at[110]);    MULADD(at[8], at[109]);    MULADD(at[9], at[108]);    MULADD(at[10], at[107]);    MULADD(at[11], at[106]);    MULADD(at[12], at[105]);    MULADD(at[13], at[104]);    MULADD(at[14], at[103]);    MULADD(at[15], at[102]);    MULADD(at[16], at[101]);    MULADD(at[17], at[100]);    MULADD(at[18], at[99]);    MULADD(at[19], at[98]);    MULADD(at[20], at[97]);    MULADD(at[21], at[96]);    MULADD(at[22], at[95]);    MULADD(at[23], at[94]);    MULADD(at[24], at[93]);    MULADD(at[25], at[92]);    MULADD(at[26], at[91]);    MULADD(at[27], at[90]);    MULADD(at[28], at[89]);    MULADD(at[29], at[88]);    MULADD(at[30], at[87]);    MULADD(at[31], at[86]);    MULADD(at[32], at[85]);    MULADD(at[33], at[84]);    MULADD(at[34], at[83]);    MULADD(at[35], at[82]);    MULADD(at[36], at[81]);    MULADD(at[37], at[80]);    MULADD(at[38], at[79]);    MULADD(at[39], at[78]);    MULADD(at[40], at[77]);    MULADD(at[41], at[76]);    MULADD(at[42], at[75]);    MULADD(at[43], at[74]);    MULADD(at[44], at[73]);    MULADD(at[45], at[72]);    MULADD(at[46], at[71]);    MULADD(at[47], at[70]);    MULADD(at[48], at[69]);    MULADD(at[49], at[68]);    MULADD(at[50], at[67]);    MULADD(at[51], at[66]);    MULADD(at[52], at[65]);    MULADD(at[53], at[64]); 
-   COMBA_STORE(C->dp[53]);
-   /* 54 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[118]);    MULADD(at[1], at[117]);    MULADD(at[2], at[116]);    MULADD(at[3], at[115]);    MULADD(at[4], at[114]);    MULADD(at[5], at[113]);    MULADD(at[6], at[112]);    MULADD(at[7], at[111]);    MULADD(at[8], at[110]);    MULADD(at[9], at[109]);    MULADD(at[10], at[108]);    MULADD(at[11], at[107]);    MULADD(at[12], at[106]);    MULADD(at[13], at[105]);    MULADD(at[14], at[104]);    MULADD(at[15], at[103]);    MULADD(at[16], at[102]);    MULADD(at[17], at[101]);    MULADD(at[18], at[100]);    MULADD(at[19], at[99]);    MULADD(at[20], at[98]);    MULADD(at[21], at[97]);    MULADD(at[22], at[96]);    MULADD(at[23], at[95]);    MULADD(at[24], at[94]);    MULADD(at[25], at[93]);    MULADD(at[26], at[92]);    MULADD(at[27], at[91]);    MULADD(at[28], at[90]);    MULADD(at[29], at[89]);    MULADD(at[30], at[88]);    MULADD(at[31], at[87]);    MULADD(at[32], at[86]);    MULADD(at[33], at[85]);    MULADD(at[34], at[84]);    MULADD(at[35], at[83]);    MULADD(at[36], at[82]);    MULADD(at[37], at[81]);    MULADD(at[38], at[80]);    MULADD(at[39], at[79]);    MULADD(at[40], at[78]);    MULADD(at[41], at[77]);    MULADD(at[42], at[76]);    MULADD(at[43], at[75]);    MULADD(at[44], at[74]);    MULADD(at[45], at[73]);    MULADD(at[46], at[72]);    MULADD(at[47], at[71]);    MULADD(at[48], at[70]);    MULADD(at[49], at[69]);    MULADD(at[50], at[68]);    MULADD(at[51], at[67]);    MULADD(at[52], at[66]);    MULADD(at[53], at[65]);    MULADD(at[54], at[64]); 
-   COMBA_STORE(C->dp[54]);
-   /* 55 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[119]);    MULADD(at[1], at[118]);    MULADD(at[2], at[117]);    MULADD(at[3], at[116]);    MULADD(at[4], at[115]);    MULADD(at[5], at[114]);    MULADD(at[6], at[113]);    MULADD(at[7], at[112]);    MULADD(at[8], at[111]);    MULADD(at[9], at[110]);    MULADD(at[10], at[109]);    MULADD(at[11], at[108]);    MULADD(at[12], at[107]);    MULADD(at[13], at[106]);    MULADD(at[14], at[105]);    MULADD(at[15], at[104]);    MULADD(at[16], at[103]);    MULADD(at[17], at[102]);    MULADD(at[18], at[101]);    MULADD(at[19], at[100]);    MULADD(at[20], at[99]);    MULADD(at[21], at[98]);    MULADD(at[22], at[97]);    MULADD(at[23], at[96]);    MULADD(at[24], at[95]);    MULADD(at[25], at[94]);    MULADD(at[26], at[93]);    MULADD(at[27], at[92]);    MULADD(at[28], at[91]);    MULADD(at[29], at[90]);    MULADD(at[30], at[89]);    MULADD(at[31], at[88]);    MULADD(at[32], at[87]);    MULADD(at[33], at[86]);    MULADD(at[34], at[85]);    MULADD(at[35], at[84]);    MULADD(at[36], at[83]);    MULADD(at[37], at[82]);    MULADD(at[38], at[81]);    MULADD(at[39], at[80]);    MULADD(at[40], at[79]);    MULADD(at[41], at[78]);    MULADD(at[42], at[77]);    MULADD(at[43], at[76]);    MULADD(at[44], at[75]);    MULADD(at[45], at[74]);    MULADD(at[46], at[73]);    MULADD(at[47], at[72]);    MULADD(at[48], at[71]);    MULADD(at[49], at[70]);    MULADD(at[50], at[69]);    MULADD(at[51], at[68]);    MULADD(at[52], at[67]);    MULADD(at[53], at[66]);    MULADD(at[54], at[65]);    MULADD(at[55], at[64]); 
-   COMBA_STORE(C->dp[55]);
-   /* 56 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[120]);    MULADD(at[1], at[119]);    MULADD(at[2], at[118]);    MULADD(at[3], at[117]);    MULADD(at[4], at[116]);    MULADD(at[5], at[115]);    MULADD(at[6], at[114]);    MULADD(at[7], at[113]);    MULADD(at[8], at[112]);    MULADD(at[9], at[111]);    MULADD(at[10], at[110]);    MULADD(at[11], at[109]);    MULADD(at[12], at[108]);    MULADD(at[13], at[107]);    MULADD(at[14], at[106]);    MULADD(at[15], at[105]);    MULADD(at[16], at[104]);    MULADD(at[17], at[103]);    MULADD(at[18], at[102]);    MULADD(at[19], at[101]);    MULADD(at[20], at[100]);    MULADD(at[21], at[99]);    MULADD(at[22], at[98]);    MULADD(at[23], at[97]);    MULADD(at[24], at[96]);    MULADD(at[25], at[95]);    MULADD(at[26], at[94]);    MULADD(at[27], at[93]);    MULADD(at[28], at[92]);    MULADD(at[29], at[91]);    MULADD(at[30], at[90]);    MULADD(at[31], at[89]);    MULADD(at[32], at[88]);    MULADD(at[33], at[87]);    MULADD(at[34], at[86]);    MULADD(at[35], at[85]);    MULADD(at[36], at[84]);    MULADD(at[37], at[83]);    MULADD(at[38], at[82]);    MULADD(at[39], at[81]);    MULADD(at[40], at[80]);    MULADD(at[41], at[79]);    MULADD(at[42], at[78]);    MULADD(at[43], at[77]);    MULADD(at[44], at[76]);    MULADD(at[45], at[75]);    MULADD(at[46], at[74]);    MULADD(at[47], at[73]);    MULADD(at[48], at[72]);    MULADD(at[49], at[71]);    MULADD(at[50], at[70]);    MULADD(at[51], at[69]);    MULADD(at[52], at[68]);    MULADD(at[53], at[67]);    MULADD(at[54], at[66]);    MULADD(at[55], at[65]);    MULADD(at[56], at[64]); 
-   COMBA_STORE(C->dp[56]);
-   /* 57 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[121]);    MULADD(at[1], at[120]);    MULADD(at[2], at[119]);    MULADD(at[3], at[118]);    MULADD(at[4], at[117]);    MULADD(at[5], at[116]);    MULADD(at[6], at[115]);    MULADD(at[7], at[114]);    MULADD(at[8], at[113]);    MULADD(at[9], at[112]);    MULADD(at[10], at[111]);    MULADD(at[11], at[110]);    MULADD(at[12], at[109]);    MULADD(at[13], at[108]);    MULADD(at[14], at[107]);    MULADD(at[15], at[106]);    MULADD(at[16], at[105]);    MULADD(at[17], at[104]);    MULADD(at[18], at[103]);    MULADD(at[19], at[102]);    MULADD(at[20], at[101]);    MULADD(at[21], at[100]);    MULADD(at[22], at[99]);    MULADD(at[23], at[98]);    MULADD(at[24], at[97]);    MULADD(at[25], at[96]);    MULADD(at[26], at[95]);    MULADD(at[27], at[94]);    MULADD(at[28], at[93]);    MULADD(at[29], at[92]);    MULADD(at[30], at[91]);    MULADD(at[31], at[90]);    MULADD(at[32], at[89]);    MULADD(at[33], at[88]);    MULADD(at[34], at[87]);    MULADD(at[35], at[86]);    MULADD(at[36], at[85]);    MULADD(at[37], at[84]);    MULADD(at[38], at[83]);    MULADD(at[39], at[82]);    MULADD(at[40], at[81]);    MULADD(at[41], at[80]);    MULADD(at[42], at[79]);    MULADD(at[43], at[78]);    MULADD(at[44], at[77]);    MULADD(at[45], at[76]);    MULADD(at[46], at[75]);    MULADD(at[47], at[74]);    MULADD(at[48], at[73]);    MULADD(at[49], at[72]);    MULADD(at[50], at[71]);    MULADD(at[51], at[70]);    MULADD(at[52], at[69]);    MULADD(at[53], at[68]);    MULADD(at[54], at[67]);    MULADD(at[55], at[66]);    MULADD(at[56], at[65]);    MULADD(at[57], at[64]); 
-   COMBA_STORE(C->dp[57]);
-   /* 58 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[122]);    MULADD(at[1], at[121]);    MULADD(at[2], at[120]);    MULADD(at[3], at[119]);    MULADD(at[4], at[118]);    MULADD(at[5], at[117]);    MULADD(at[6], at[116]);    MULADD(at[7], at[115]);    MULADD(at[8], at[114]);    MULADD(at[9], at[113]);    MULADD(at[10], at[112]);    MULADD(at[11], at[111]);    MULADD(at[12], at[110]);    MULADD(at[13], at[109]);    MULADD(at[14], at[108]);    MULADD(at[15], at[107]);    MULADD(at[16], at[106]);    MULADD(at[17], at[105]);    MULADD(at[18], at[104]);    MULADD(at[19], at[103]);    MULADD(at[20], at[102]);    MULADD(at[21], at[101]);    MULADD(at[22], at[100]);    MULADD(at[23], at[99]);    MULADD(at[24], at[98]);    MULADD(at[25], at[97]);    MULADD(at[26], at[96]);    MULADD(at[27], at[95]);    MULADD(at[28], at[94]);    MULADD(at[29], at[93]);    MULADD(at[30], at[92]);    MULADD(at[31], at[91]);    MULADD(at[32], at[90]);    MULADD(at[33], at[89]);    MULADD(at[34], at[88]);    MULADD(at[35], at[87]);    MULADD(at[36], at[86]);    MULADD(at[37], at[85]);    MULADD(at[38], at[84]);    MULADD(at[39], at[83]);    MULADD(at[40], at[82]);    MULADD(at[41], at[81]);    MULADD(at[42], at[80]);    MULADD(at[43], at[79]);    MULADD(at[44], at[78]);    MULADD(at[45], at[77]);    MULADD(at[46], at[76]);    MULADD(at[47], at[75]);    MULADD(at[48], at[74]);    MULADD(at[49], at[73]);    MULADD(at[50], at[72]);    MULADD(at[51], at[71]);    MULADD(at[52], at[70]);    MULADD(at[53], at[69]);    MULADD(at[54], at[68]);    MULADD(at[55], at[67]);    MULADD(at[56], at[66]);    MULADD(at[57], at[65]);    MULADD(at[58], at[64]); 
-   COMBA_STORE(C->dp[58]);
-   /* 59 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[123]);    MULADD(at[1], at[122]);    MULADD(at[2], at[121]);    MULADD(at[3], at[120]);    MULADD(at[4], at[119]);    MULADD(at[5], at[118]);    MULADD(at[6], at[117]);    MULADD(at[7], at[116]);    MULADD(at[8], at[115]);    MULADD(at[9], at[114]);    MULADD(at[10], at[113]);    MULADD(at[11], at[112]);    MULADD(at[12], at[111]);    MULADD(at[13], at[110]);    MULADD(at[14], at[109]);    MULADD(at[15], at[108]);    MULADD(at[16], at[107]);    MULADD(at[17], at[106]);    MULADD(at[18], at[105]);    MULADD(at[19], at[104]);    MULADD(at[20], at[103]);    MULADD(at[21], at[102]);    MULADD(at[22], at[101]);    MULADD(at[23], at[100]);    MULADD(at[24], at[99]);    MULADD(at[25], at[98]);    MULADD(at[26], at[97]);    MULADD(at[27], at[96]);    MULADD(at[28], at[95]);    MULADD(at[29], at[94]);    MULADD(at[30], at[93]);    MULADD(at[31], at[92]);    MULADD(at[32], at[91]);    MULADD(at[33], at[90]);    MULADD(at[34], at[89]);    MULADD(at[35], at[88]);    MULADD(at[36], at[87]);    MULADD(at[37], at[86]);    MULADD(at[38], at[85]);    MULADD(at[39], at[84]);    MULADD(at[40], at[83]);    MULADD(at[41], at[82]);    MULADD(at[42], at[81]);    MULADD(at[43], at[80]);    MULADD(at[44], at[79]);    MULADD(at[45], at[78]);    MULADD(at[46], at[77]);    MULADD(at[47], at[76]);    MULADD(at[48], at[75]);    MULADD(at[49], at[74]);    MULADD(at[50], at[73]);    MULADD(at[51], at[72]);    MULADD(at[52], at[71]);    MULADD(at[53], at[70]);    MULADD(at[54], at[69]);    MULADD(at[55], at[68]);    MULADD(at[56], at[67]);    MULADD(at[57], at[66]);    MULADD(at[58], at[65]);    MULADD(at[59], at[64]); 
-   COMBA_STORE(C->dp[59]);
-   /* 60 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[124]);    MULADD(at[1], at[123]);    MULADD(at[2], at[122]);    MULADD(at[3], at[121]);    MULADD(at[4], at[120]);    MULADD(at[5], at[119]);    MULADD(at[6], at[118]);    MULADD(at[7], at[117]);    MULADD(at[8], at[116]);    MULADD(at[9], at[115]);    MULADD(at[10], at[114]);    MULADD(at[11], at[113]);    MULADD(at[12], at[112]);    MULADD(at[13], at[111]);    MULADD(at[14], at[110]);    MULADD(at[15], at[109]);    MULADD(at[16], at[108]);    MULADD(at[17], at[107]);    MULADD(at[18], at[106]);    MULADD(at[19], at[105]);    MULADD(at[20], at[104]);    MULADD(at[21], at[103]);    MULADD(at[22], at[102]);    MULADD(at[23], at[101]);    MULADD(at[24], at[100]);    MULADD(at[25], at[99]);    MULADD(at[26], at[98]);    MULADD(at[27], at[97]);    MULADD(at[28], at[96]);    MULADD(at[29], at[95]);    MULADD(at[30], at[94]);    MULADD(at[31], at[93]);    MULADD(at[32], at[92]);    MULADD(at[33], at[91]);    MULADD(at[34], at[90]);    MULADD(at[35], at[89]);    MULADD(at[36], at[88]);    MULADD(at[37], at[87]);    MULADD(at[38], at[86]);    MULADD(at[39], at[85]);    MULADD(at[40], at[84]);    MULADD(at[41], at[83]);    MULADD(at[42], at[82]);    MULADD(at[43], at[81]);    MULADD(at[44], at[80]);    MULADD(at[45], at[79]);    MULADD(at[46], at[78]);    MULADD(at[47], at[77]);    MULADD(at[48], at[76]);    MULADD(at[49], at[75]);    MULADD(at[50], at[74]);    MULADD(at[51], at[73]);    MULADD(at[52], at[72]);    MULADD(at[53], at[71]);    MULADD(at[54], at[70]);    MULADD(at[55], at[69]);    MULADD(at[56], at[68]);    MULADD(at[57], at[67]);    MULADD(at[58], at[66]);    MULADD(at[59], at[65]);    MULADD(at[60], at[64]); 
-   COMBA_STORE(C->dp[60]);
-   /* 61 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[125]);    MULADD(at[1], at[124]);    MULADD(at[2], at[123]);    MULADD(at[3], at[122]);    MULADD(at[4], at[121]);    MULADD(at[5], at[120]);    MULADD(at[6], at[119]);    MULADD(at[7], at[118]);    MULADD(at[8], at[117]);    MULADD(at[9], at[116]);    MULADD(at[10], at[115]);    MULADD(at[11], at[114]);    MULADD(at[12], at[113]);    MULADD(at[13], at[112]);    MULADD(at[14], at[111]);    MULADD(at[15], at[110]);    MULADD(at[16], at[109]);    MULADD(at[17], at[108]);    MULADD(at[18], at[107]);    MULADD(at[19], at[106]);    MULADD(at[20], at[105]);    MULADD(at[21], at[104]);    MULADD(at[22], at[103]);    MULADD(at[23], at[102]);    MULADD(at[24], at[101]);    MULADD(at[25], at[100]);    MULADD(at[26], at[99]);    MULADD(at[27], at[98]);    MULADD(at[28], at[97]);    MULADD(at[29], at[96]);    MULADD(at[30], at[95]);    MULADD(at[31], at[94]);    MULADD(at[32], at[93]);    MULADD(at[33], at[92]);    MULADD(at[34], at[91]);    MULADD(at[35], at[90]);    MULADD(at[36], at[89]);    MULADD(at[37], at[88]);    MULADD(at[38], at[87]);    MULADD(at[39], at[86]);    MULADD(at[40], at[85]);    MULADD(at[41], at[84]);    MULADD(at[42], at[83]);    MULADD(at[43], at[82]);    MULADD(at[44], at[81]);    MULADD(at[45], at[80]);    MULADD(at[46], at[79]);    MULADD(at[47], at[78]);    MULADD(at[48], at[77]);    MULADD(at[49], at[76]);    MULADD(at[50], at[75]);    MULADD(at[51], at[74]);    MULADD(at[52], at[73]);    MULADD(at[53], at[72]);    MULADD(at[54], at[71]);    MULADD(at[55], at[70]);    MULADD(at[56], at[69]);    MULADD(at[57], at[68]);    MULADD(at[58], at[67]);    MULADD(at[59], at[66]);    MULADD(at[60], at[65]);    MULADD(at[61], at[64]); 
-   COMBA_STORE(C->dp[61]);
-   /* 62 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[126]);    MULADD(at[1], at[125]);    MULADD(at[2], at[124]);    MULADD(at[3], at[123]);    MULADD(at[4], at[122]);    MULADD(at[5], at[121]);    MULADD(at[6], at[120]);    MULADD(at[7], at[119]);    MULADD(at[8], at[118]);    MULADD(at[9], at[117]);    MULADD(at[10], at[116]);    MULADD(at[11], at[115]);    MULADD(at[12], at[114]);    MULADD(at[13], at[113]);    MULADD(at[14], at[112]);    MULADD(at[15], at[111]);    MULADD(at[16], at[110]);    MULADD(at[17], at[109]);    MULADD(at[18], at[108]);    MULADD(at[19], at[107]);    MULADD(at[20], at[106]);    MULADD(at[21], at[105]);    MULADD(at[22], at[104]);    MULADD(at[23], at[103]);    MULADD(at[24], at[102]);    MULADD(at[25], at[101]);    MULADD(at[26], at[100]);    MULADD(at[27], at[99]);    MULADD(at[28], at[98]);    MULADD(at[29], at[97]);    MULADD(at[30], at[96]);    MULADD(at[31], at[95]);    MULADD(at[32], at[94]);    MULADD(at[33], at[93]);    MULADD(at[34], at[92]);    MULADD(at[35], at[91]);    MULADD(at[36], at[90]);    MULADD(at[37], at[89]);    MULADD(at[38], at[88]);    MULADD(at[39], at[87]);    MULADD(at[40], at[86]);    MULADD(at[41], at[85]);    MULADD(at[42], at[84]);    MULADD(at[43], at[83]);    MULADD(at[44], at[82]);    MULADD(at[45], at[81]);    MULADD(at[46], at[80]);    MULADD(at[47], at[79]);    MULADD(at[48], at[78]);    MULADD(at[49], at[77]);    MULADD(at[50], at[76]);    MULADD(at[51], at[75]);    MULADD(at[52], at[74]);    MULADD(at[53], at[73]);    MULADD(at[54], at[72]);    MULADD(at[55], at[71]);    MULADD(at[56], at[70]);    MULADD(at[57], at[69]);    MULADD(at[58], at[68]);    MULADD(at[59], at[67]);    MULADD(at[60], at[66]);    MULADD(at[61], at[65]);    MULADD(at[62], at[64]); 
-   COMBA_STORE(C->dp[62]);
-   /* 63 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[127]);    MULADD(at[1], at[126]);    MULADD(at[2], at[125]);    MULADD(at[3], at[124]);    MULADD(at[4], at[123]);    MULADD(at[5], at[122]);    MULADD(at[6], at[121]);    MULADD(at[7], at[120]);    MULADD(at[8], at[119]);    MULADD(at[9], at[118]);    MULADD(at[10], at[117]);    MULADD(at[11], at[116]);    MULADD(at[12], at[115]);    MULADD(at[13], at[114]);    MULADD(at[14], at[113]);    MULADD(at[15], at[112]);    MULADD(at[16], at[111]);    MULADD(at[17], at[110]);    MULADD(at[18], at[109]);    MULADD(at[19], at[108]);    MULADD(at[20], at[107]);    MULADD(at[21], at[106]);    MULADD(at[22], at[105]);    MULADD(at[23], at[104]);    MULADD(at[24], at[103]);    MULADD(at[25], at[102]);    MULADD(at[26], at[101]);    MULADD(at[27], at[100]);    MULADD(at[28], at[99]);    MULADD(at[29], at[98]);    MULADD(at[30], at[97]);    MULADD(at[31], at[96]);    MULADD(at[32], at[95]);    MULADD(at[33], at[94]);    MULADD(at[34], at[93]);    MULADD(at[35], at[92]);    MULADD(at[36], at[91]);    MULADD(at[37], at[90]);    MULADD(at[38], at[89]);    MULADD(at[39], at[88]);    MULADD(at[40], at[87]);    MULADD(at[41], at[86]);    MULADD(at[42], at[85]);    MULADD(at[43], at[84]);    MULADD(at[44], at[83]);    MULADD(at[45], at[82]);    MULADD(at[46], at[81]);    MULADD(at[47], at[80]);    MULADD(at[48], at[79]);    MULADD(at[49], at[78]);    MULADD(at[50], at[77]);    MULADD(at[51], at[76]);    MULADD(at[52], at[75]);    MULADD(at[53], at[74]);    MULADD(at[54], at[73]);    MULADD(at[55], at[72]);    MULADD(at[56], at[71]);    MULADD(at[57], at[70]);    MULADD(at[58], at[69]);    MULADD(at[59], at[68]);    MULADD(at[60], at[67]);    MULADD(at[61], at[66]);    MULADD(at[62], at[65]);    MULADD(at[63], at[64]); 
-   COMBA_STORE(C->dp[63]);
-   /* 64 */
-   COMBA_FORWARD;
-   MULADD(at[1], at[127]);    MULADD(at[2], at[126]);    MULADD(at[3], at[125]);    MULADD(at[4], at[124]);    MULADD(at[5], at[123]);    MULADD(at[6], at[122]);    MULADD(at[7], at[121]);    MULADD(at[8], at[120]);    MULADD(at[9], at[119]);    MULADD(at[10], at[118]);    MULADD(at[11], at[117]);    MULADD(at[12], at[116]);    MULADD(at[13], at[115]);    MULADD(at[14], at[114]);    MULADD(at[15], at[113]);    MULADD(at[16], at[112]);    MULADD(at[17], at[111]);    MULADD(at[18], at[110]);    MULADD(at[19], at[109]);    MULADD(at[20], at[108]);    MULADD(at[21], at[107]);    MULADD(at[22], at[106]);    MULADD(at[23], at[105]);    MULADD(at[24], at[104]);    MULADD(at[25], at[103]);    MULADD(at[26], at[102]);    MULADD(at[27], at[101]);    MULADD(at[28], at[100]);    MULADD(at[29], at[99]);    MULADD(at[30], at[98]);    MULADD(at[31], at[97]);    MULADD(at[32], at[96]);    MULADD(at[33], at[95]);    MULADD(at[34], at[94]);    MULADD(at[35], at[93]);    MULADD(at[36], at[92]);    MULADD(at[37], at[91]);    MULADD(at[38], at[90]);    MULADD(at[39], at[89]);    MULADD(at[40], at[88]);    MULADD(at[41], at[87]);    MULADD(at[42], at[86]);    MULADD(at[43], at[85]);    MULADD(at[44], at[84]);    MULADD(at[45], at[83]);    MULADD(at[46], at[82]);    MULADD(at[47], at[81]);    MULADD(at[48], at[80]);    MULADD(at[49], at[79]);    MULADD(at[50], at[78]);    MULADD(at[51], at[77]);    MULADD(at[52], at[76]);    MULADD(at[53], at[75]);    MULADD(at[54], at[74]);    MULADD(at[55], at[73]);    MULADD(at[56], at[72]);    MULADD(at[57], at[71]);    MULADD(at[58], at[70]);    MULADD(at[59], at[69]);    MULADD(at[60], at[68]);    MULADD(at[61], at[67]);    MULADD(at[62], at[66]);    MULADD(at[63], at[65]); 
-   COMBA_STORE(C->dp[64]);
-   /* 65 */
-   COMBA_FORWARD;
-   MULADD(at[2], at[127]);    MULADD(at[3], at[126]);    MULADD(at[4], at[125]);    MULADD(at[5], at[124]);    MULADD(at[6], at[123]);    MULADD(at[7], at[122]);    MULADD(at[8], at[121]);    MULADD(at[9], at[120]);    MULADD(at[10], at[119]);    MULADD(at[11], at[118]);    MULADD(at[12], at[117]);    MULADD(at[13], at[116]);    MULADD(at[14], at[115]);    MULADD(at[15], at[114]);    MULADD(at[16], at[113]);    MULADD(at[17], at[112]);    MULADD(at[18], at[111]);    MULADD(at[19], at[110]);    MULADD(at[20], at[109]);    MULADD(at[21], at[108]);    MULADD(at[22], at[107]);    MULADD(at[23], at[106]);    MULADD(at[24], at[105]);    MULADD(at[25], at[104]);    MULADD(at[26], at[103]);    MULADD(at[27], at[102]);    MULADD(at[28], at[101]);    MULADD(at[29], at[100]);    MULADD(at[30], at[99]);    MULADD(at[31], at[98]);    MULADD(at[32], at[97]);    MULADD(at[33], at[96]);    MULADD(at[34], at[95]);    MULADD(at[35], at[94]);    MULADD(at[36], at[93]);    MULADD(at[37], at[92]);    MULADD(at[38], at[91]);    MULADD(at[39], at[90]);    MULADD(at[40], at[89]);    MULADD(at[41], at[88]);    MULADD(at[42], at[87]);    MULADD(at[43], at[86]);    MULADD(at[44], at[85]);    MULADD(at[45], at[84]);    MULADD(at[46], at[83]);    MULADD(at[47], at[82]);    MULADD(at[48], at[81]);    MULADD(at[49], at[80]);    MULADD(at[50], at[79]);    MULADD(at[51], at[78]);    MULADD(at[52], at[77]);    MULADD(at[53], at[76]);    MULADD(at[54], at[75]);    MULADD(at[55], at[74]);    MULADD(at[56], at[73]);    MULADD(at[57], at[72]);    MULADD(at[58], at[71]);    MULADD(at[59], at[70]);    MULADD(at[60], at[69]);    MULADD(at[61], at[68]);    MULADD(at[62], at[67]);    MULADD(at[63], at[66]); 
-   COMBA_STORE(C->dp[65]);
-   /* 66 */
-   COMBA_FORWARD;
-   MULADD(at[3], at[127]);    MULADD(at[4], at[126]);    MULADD(at[5], at[125]);    MULADD(at[6], at[124]);    MULADD(at[7], at[123]);    MULADD(at[8], at[122]);    MULADD(at[9], at[121]);    MULADD(at[10], at[120]);    MULADD(at[11], at[119]);    MULADD(at[12], at[118]);    MULADD(at[13], at[117]);    MULADD(at[14], at[116]);    MULADD(at[15], at[115]);    MULADD(at[16], at[114]);    MULADD(at[17], at[113]);    MULADD(at[18], at[112]);    MULADD(at[19], at[111]);    MULADD(at[20], at[110]);    MULADD(at[21], at[109]);    MULADD(at[22], at[108]);    MULADD(at[23], at[107]);    MULADD(at[24], at[106]);    MULADD(at[25], at[105]);    MULADD(at[26], at[104]);    MULADD(at[27], at[103]);    MULADD(at[28], at[102]);    MULADD(at[29], at[101]);    MULADD(at[30], at[100]);    MULADD(at[31], at[99]);    MULADD(at[32], at[98]);    MULADD(at[33], at[97]);    MULADD(at[34], at[96]);    MULADD(at[35], at[95]);    MULADD(at[36], at[94]);    MULADD(at[37], at[93]);    MULADD(at[38], at[92]);    MULADD(at[39], at[91]);    MULADD(at[40], at[90]);    MULADD(at[41], at[89]);    MULADD(at[42], at[88]);    MULADD(at[43], at[87]);    MULADD(at[44], at[86]);    MULADD(at[45], at[85]);    MULADD(at[46], at[84]);    MULADD(at[47], at[83]);    MULADD(at[48], at[82]);    MULADD(at[49], at[81]);    MULADD(at[50], at[80]);    MULADD(at[51], at[79]);    MULADD(at[52], at[78]);    MULADD(at[53], at[77]);    MULADD(at[54], at[76]);    MULADD(at[55], at[75]);    MULADD(at[56], at[74]);    MULADD(at[57], at[73]);    MULADD(at[58], at[72]);    MULADD(at[59], at[71]);    MULADD(at[60], at[70]);    MULADD(at[61], at[69]);    MULADD(at[62], at[68]);    MULADD(at[63], at[67]); 
-   COMBA_STORE(C->dp[66]);
-   /* 67 */
-   COMBA_FORWARD;
-   MULADD(at[4], at[127]);    MULADD(at[5], at[126]);    MULADD(at[6], at[125]);    MULADD(at[7], at[124]);    MULADD(at[8], at[123]);    MULADD(at[9], at[122]);    MULADD(at[10], at[121]);    MULADD(at[11], at[120]);    MULADD(at[12], at[119]);    MULADD(at[13], at[118]);    MULADD(at[14], at[117]);    MULADD(at[15], at[116]);    MULADD(at[16], at[115]);    MULADD(at[17], at[114]);    MULADD(at[18], at[113]);    MULADD(at[19], at[112]);    MULADD(at[20], at[111]);    MULADD(at[21], at[110]);    MULADD(at[22], at[109]);    MULADD(at[23], at[108]);    MULADD(at[24], at[107]);    MULADD(at[25], at[106]);    MULADD(at[26], at[105]);    MULADD(at[27], at[104]);    MULADD(at[28], at[103]);    MULADD(at[29], at[102]);    MULADD(at[30], at[101]);    MULADD(at[31], at[100]);    MULADD(at[32], at[99]);    MULADD(at[33], at[98]);    MULADD(at[34], at[97]);    MULADD(at[35], at[96]);    MULADD(at[36], at[95]);    MULADD(at[37], at[94]);    MULADD(at[38], at[93]);    MULADD(at[39], at[92]);    MULADD(at[40], at[91]);    MULADD(at[41], at[90]);    MULADD(at[42], at[89]);    MULADD(at[43], at[88]);    MULADD(at[44], at[87]);    MULADD(at[45], at[86]);    MULADD(at[46], at[85]);    MULADD(at[47], at[84]);    MULADD(at[48], at[83]);    MULADD(at[49], at[82]);    MULADD(at[50], at[81]);    MULADD(at[51], at[80]);    MULADD(at[52], at[79]);    MULADD(at[53], at[78]);    MULADD(at[54], at[77]);    MULADD(at[55], at[76]);    MULADD(at[56], at[75]);    MULADD(at[57], at[74]);    MULADD(at[58], at[73]);    MULADD(at[59], at[72]);    MULADD(at[60], at[71]);    MULADD(at[61], at[70]);    MULADD(at[62], at[69]);    MULADD(at[63], at[68]); 
-   COMBA_STORE(C->dp[67]);
-   /* 68 */
-   COMBA_FORWARD;
-   MULADD(at[5], at[127]);    MULADD(at[6], at[126]);    MULADD(at[7], at[125]);    MULADD(at[8], at[124]);    MULADD(at[9], at[123]);    MULADD(at[10], at[122]);    MULADD(at[11], at[121]);    MULADD(at[12], at[120]);    MULADD(at[13], at[119]);    MULADD(at[14], at[118]);    MULADD(at[15], at[117]);    MULADD(at[16], at[116]);    MULADD(at[17], at[115]);    MULADD(at[18], at[114]);    MULADD(at[19], at[113]);    MULADD(at[20], at[112]);    MULADD(at[21], at[111]);    MULADD(at[22], at[110]);    MULADD(at[23], at[109]);    MULADD(at[24], at[108]);    MULADD(at[25], at[107]);    MULADD(at[26], at[106]);    MULADD(at[27], at[105]);    MULADD(at[28], at[104]);    MULADD(at[29], at[103]);    MULADD(at[30], at[102]);    MULADD(at[31], at[101]);    MULADD(at[32], at[100]);    MULADD(at[33], at[99]);    MULADD(at[34], at[98]);    MULADD(at[35], at[97]);    MULADD(at[36], at[96]);    MULADD(at[37], at[95]);    MULADD(at[38], at[94]);    MULADD(at[39], at[93]);    MULADD(at[40], at[92]);    MULADD(at[41], at[91]);    MULADD(at[42], at[90]);    MULADD(at[43], at[89]);    MULADD(at[44], at[88]);    MULADD(at[45], at[87]);    MULADD(at[46], at[86]);    MULADD(at[47], at[85]);    MULADD(at[48], at[84]);    MULADD(at[49], at[83]);    MULADD(at[50], at[82]);    MULADD(at[51], at[81]);    MULADD(at[52], at[80]);    MULADD(at[53], at[79]);    MULADD(at[54], at[78]);    MULADD(at[55], at[77]);    MULADD(at[56], at[76]);    MULADD(at[57], at[75]);    MULADD(at[58], at[74]);    MULADD(at[59], at[73]);    MULADD(at[60], at[72]);    MULADD(at[61], at[71]);    MULADD(at[62], at[70]);    MULADD(at[63], at[69]); 
-   COMBA_STORE(C->dp[68]);
-   /* 69 */
-   COMBA_FORWARD;
-   MULADD(at[6], at[127]);    MULADD(at[7], at[126]);    MULADD(at[8], at[125]);    MULADD(at[9], at[124]);    MULADD(at[10], at[123]);    MULADD(at[11], at[122]);    MULADD(at[12], at[121]);    MULADD(at[13], at[120]);    MULADD(at[14], at[119]);    MULADD(at[15], at[118]);    MULADD(at[16], at[117]);    MULADD(at[17], at[116]);    MULADD(at[18], at[115]);    MULADD(at[19], at[114]);    MULADD(at[20], at[113]);    MULADD(at[21], at[112]);    MULADD(at[22], at[111]);    MULADD(at[23], at[110]);    MULADD(at[24], at[109]);    MULADD(at[25], at[108]);    MULADD(at[26], at[107]);    MULADD(at[27], at[106]);    MULADD(at[28], at[105]);    MULADD(at[29], at[104]);    MULADD(at[30], at[103]);    MULADD(at[31], at[102]);    MULADD(at[32], at[101]);    MULADD(at[33], at[100]);    MULADD(at[34], at[99]);    MULADD(at[35], at[98]);    MULADD(at[36], at[97]);    MULADD(at[37], at[96]);    MULADD(at[38], at[95]);    MULADD(at[39], at[94]);    MULADD(at[40], at[93]);    MULADD(at[41], at[92]);    MULADD(at[42], at[91]);    MULADD(at[43], at[90]);    MULADD(at[44], at[89]);    MULADD(at[45], at[88]);    MULADD(at[46], at[87]);    MULADD(at[47], at[86]);    MULADD(at[48], at[85]);    MULADD(at[49], at[84]);    MULADD(at[50], at[83]);    MULADD(at[51], at[82]);    MULADD(at[52], at[81]);    MULADD(at[53], at[80]);    MULADD(at[54], at[79]);    MULADD(at[55], at[78]);    MULADD(at[56], at[77]);    MULADD(at[57], at[76]);    MULADD(at[58], at[75]);    MULADD(at[59], at[74]);    MULADD(at[60], at[73]);    MULADD(at[61], at[72]);    MULADD(at[62], at[71]);    MULADD(at[63], at[70]); 
-   COMBA_STORE(C->dp[69]);
-   /* 70 */
-   COMBA_FORWARD;
-   MULADD(at[7], at[127]);    MULADD(at[8], at[126]);    MULADD(at[9], at[125]);    MULADD(at[10], at[124]);    MULADD(at[11], at[123]);    MULADD(at[12], at[122]);    MULADD(at[13], at[121]);    MULADD(at[14], at[120]);    MULADD(at[15], at[119]);    MULADD(at[16], at[118]);    MULADD(at[17], at[117]);    MULADD(at[18], at[116]);    MULADD(at[19], at[115]);    MULADD(at[20], at[114]);    MULADD(at[21], at[113]);    MULADD(at[22], at[112]);    MULADD(at[23], at[111]);    MULADD(at[24], at[110]);    MULADD(at[25], at[109]);    MULADD(at[26], at[108]);    MULADD(at[27], at[107]);    MULADD(at[28], at[106]);    MULADD(at[29], at[105]);    MULADD(at[30], at[104]);    MULADD(at[31], at[103]);    MULADD(at[32], at[102]);    MULADD(at[33], at[101]);    MULADD(at[34], at[100]);    MULADD(at[35], at[99]);    MULADD(at[36], at[98]);    MULADD(at[37], at[97]);    MULADD(at[38], at[96]);    MULADD(at[39], at[95]);    MULADD(at[40], at[94]);    MULADD(at[41], at[93]);    MULADD(at[42], at[92]);    MULADD(at[43], at[91]);    MULADD(at[44], at[90]);    MULADD(at[45], at[89]);    MULADD(at[46], at[88]);    MULADD(at[47], at[87]);    MULADD(at[48], at[86]);    MULADD(at[49], at[85]);    MULADD(at[50], at[84]);    MULADD(at[51], at[83]);    MULADD(at[52], at[82]);    MULADD(at[53], at[81]);    MULADD(at[54], at[80]);    MULADD(at[55], at[79]);    MULADD(at[56], at[78]);    MULADD(at[57], at[77]);    MULADD(at[58], at[76]);    MULADD(at[59], at[75]);    MULADD(at[60], at[74]);    MULADD(at[61], at[73]);    MULADD(at[62], at[72]);    MULADD(at[63], at[71]); 
-   COMBA_STORE(C->dp[70]);
-   /* 71 */
-   COMBA_FORWARD;
-   MULADD(at[8], at[127]);    MULADD(at[9], at[126]);    MULADD(at[10], at[125]);    MULADD(at[11], at[124]);    MULADD(at[12], at[123]);    MULADD(at[13], at[122]);    MULADD(at[14], at[121]);    MULADD(at[15], at[120]);    MULADD(at[16], at[119]);    MULADD(at[17], at[118]);    MULADD(at[18], at[117]);    MULADD(at[19], at[116]);    MULADD(at[20], at[115]);    MULADD(at[21], at[114]);    MULADD(at[22], at[113]);    MULADD(at[23], at[112]);    MULADD(at[24], at[111]);    MULADD(at[25], at[110]);    MULADD(at[26], at[109]);    MULADD(at[27], at[108]);    MULADD(at[28], at[107]);    MULADD(at[29], at[106]);    MULADD(at[30], at[105]);    MULADD(at[31], at[104]);    MULADD(at[32], at[103]);    MULADD(at[33], at[102]);    MULADD(at[34], at[101]);    MULADD(at[35], at[100]);    MULADD(at[36], at[99]);    MULADD(at[37], at[98]);    MULADD(at[38], at[97]);    MULADD(at[39], at[96]);    MULADD(at[40], at[95]);    MULADD(at[41], at[94]);    MULADD(at[42], at[93]);    MULADD(at[43], at[92]);    MULADD(at[44], at[91]);    MULADD(at[45], at[90]);    MULADD(at[46], at[89]);    MULADD(at[47], at[88]);    MULADD(at[48], at[87]);    MULADD(at[49], at[86]);    MULADD(at[50], at[85]);    MULADD(at[51], at[84]);    MULADD(at[52], at[83]);    MULADD(at[53], at[82]);    MULADD(at[54], at[81]);    MULADD(at[55], at[80]);    MULADD(at[56], at[79]);    MULADD(at[57], at[78]);    MULADD(at[58], at[77]);    MULADD(at[59], at[76]);    MULADD(at[60], at[75]);    MULADD(at[61], at[74]);    MULADD(at[62], at[73]);    MULADD(at[63], at[72]); 
-   COMBA_STORE(C->dp[71]);
-   /* 72 */
-   COMBA_FORWARD;
-   MULADD(at[9], at[127]);    MULADD(at[10], at[126]);    MULADD(at[11], at[125]);    MULADD(at[12], at[124]);    MULADD(at[13], at[123]);    MULADD(at[14], at[122]);    MULADD(at[15], at[121]);    MULADD(at[16], at[120]);    MULADD(at[17], at[119]);    MULADD(at[18], at[118]);    MULADD(at[19], at[117]);    MULADD(at[20], at[116]);    MULADD(at[21], at[115]);    MULADD(at[22], at[114]);    MULADD(at[23], at[113]);    MULADD(at[24], at[112]);    MULADD(at[25], at[111]);    MULADD(at[26], at[110]);    MULADD(at[27], at[109]);    MULADD(at[28], at[108]);    MULADD(at[29], at[107]);    MULADD(at[30], at[106]);    MULADD(at[31], at[105]);    MULADD(at[32], at[104]);    MULADD(at[33], at[103]);    MULADD(at[34], at[102]);    MULADD(at[35], at[101]);    MULADD(at[36], at[100]);    MULADD(at[37], at[99]);    MULADD(at[38], at[98]);    MULADD(at[39], at[97]);    MULADD(at[40], at[96]);    MULADD(at[41], at[95]);    MULADD(at[42], at[94]);    MULADD(at[43], at[93]);    MULADD(at[44], at[92]);    MULADD(at[45], at[91]);    MULADD(at[46], at[90]);    MULADD(at[47], at[89]);    MULADD(at[48], at[88]);    MULADD(at[49], at[87]);    MULADD(at[50], at[86]);    MULADD(at[51], at[85]);    MULADD(at[52], at[84]);    MULADD(at[53], at[83]);    MULADD(at[54], at[82]);    MULADD(at[55], at[81]);    MULADD(at[56], at[80]);    MULADD(at[57], at[79]);    MULADD(at[58], at[78]);    MULADD(at[59], at[77]);    MULADD(at[60], at[76]);    MULADD(at[61], at[75]);    MULADD(at[62], at[74]);    MULADD(at[63], at[73]); 
-   COMBA_STORE(C->dp[72]);
-   /* 73 */
-   COMBA_FORWARD;
-   MULADD(at[10], at[127]);    MULADD(at[11], at[126]);    MULADD(at[12], at[125]);    MULADD(at[13], at[124]);    MULADD(at[14], at[123]);    MULADD(at[15], at[122]);    MULADD(at[16], at[121]);    MULADD(at[17], at[120]);    MULADD(at[18], at[119]);    MULADD(at[19], at[118]);    MULADD(at[20], at[117]);    MULADD(at[21], at[116]);    MULADD(at[22], at[115]);    MULADD(at[23], at[114]);    MULADD(at[24], at[113]);    MULADD(at[25], at[112]);    MULADD(at[26], at[111]);    MULADD(at[27], at[110]);    MULADD(at[28], at[109]);    MULADD(at[29], at[108]);    MULADD(at[30], at[107]);    MULADD(at[31], at[106]);    MULADD(at[32], at[105]);    MULADD(at[33], at[104]);    MULADD(at[34], at[103]);    MULADD(at[35], at[102]);    MULADD(at[36], at[101]);    MULADD(at[37], at[100]);    MULADD(at[38], at[99]);    MULADD(at[39], at[98]);    MULADD(at[40], at[97]);    MULADD(at[41], at[96]);    MULADD(at[42], at[95]);    MULADD(at[43], at[94]);    MULADD(at[44], at[93]);    MULADD(at[45], at[92]);    MULADD(at[46], at[91]);    MULADD(at[47], at[90]);    MULADD(at[48], at[89]);    MULADD(at[49], at[88]);    MULADD(at[50], at[87]);    MULADD(at[51], at[86]);    MULADD(at[52], at[85]);    MULADD(at[53], at[84]);    MULADD(at[54], at[83]);    MULADD(at[55], at[82]);    MULADD(at[56], at[81]);    MULADD(at[57], at[80]);    MULADD(at[58], at[79]);    MULADD(at[59], at[78]);    MULADD(at[60], at[77]);    MULADD(at[61], at[76]);    MULADD(at[62], at[75]);    MULADD(at[63], at[74]); 
-   COMBA_STORE(C->dp[73]);
-   /* 74 */
-   COMBA_FORWARD;
-   MULADD(at[11], at[127]);    MULADD(at[12], at[126]);    MULADD(at[13], at[125]);    MULADD(at[14], at[124]);    MULADD(at[15], at[123]);    MULADD(at[16], at[122]);    MULADD(at[17], at[121]);    MULADD(at[18], at[120]);    MULADD(at[19], at[119]);    MULADD(at[20], at[118]);    MULADD(at[21], at[117]);    MULADD(at[22], at[116]);    MULADD(at[23], at[115]);    MULADD(at[24], at[114]);    MULADD(at[25], at[113]);    MULADD(at[26], at[112]);    MULADD(at[27], at[111]);    MULADD(at[28], at[110]);    MULADD(at[29], at[109]);    MULADD(at[30], at[108]);    MULADD(at[31], at[107]);    MULADD(at[32], at[106]);    MULADD(at[33], at[105]);    MULADD(at[34], at[104]);    MULADD(at[35], at[103]);    MULADD(at[36], at[102]);    MULADD(at[37], at[101]);    MULADD(at[38], at[100]);    MULADD(at[39], at[99]);    MULADD(at[40], at[98]);    MULADD(at[41], at[97]);    MULADD(at[42], at[96]);    MULADD(at[43], at[95]);    MULADD(at[44], at[94]);    MULADD(at[45], at[93]);    MULADD(at[46], at[92]);    MULADD(at[47], at[91]);    MULADD(at[48], at[90]);    MULADD(at[49], at[89]);    MULADD(at[50], at[88]);    MULADD(at[51], at[87]);    MULADD(at[52], at[86]);    MULADD(at[53], at[85]);    MULADD(at[54], at[84]);    MULADD(at[55], at[83]);    MULADD(at[56], at[82]);    MULADD(at[57], at[81]);    MULADD(at[58], at[80]);    MULADD(at[59], at[79]);    MULADD(at[60], at[78]);    MULADD(at[61], at[77]);    MULADD(at[62], at[76]);    MULADD(at[63], at[75]); 
-   COMBA_STORE(C->dp[74]);
-   /* 75 */
-   COMBA_FORWARD;
-   MULADD(at[12], at[127]);    MULADD(at[13], at[126]);    MULADD(at[14], at[125]);    MULADD(at[15], at[124]);    MULADD(at[16], at[123]);    MULADD(at[17], at[122]);    MULADD(at[18], at[121]);    MULADD(at[19], at[120]);    MULADD(at[20], at[119]);    MULADD(at[21], at[118]);    MULADD(at[22], at[117]);    MULADD(at[23], at[116]);    MULADD(at[24], at[115]);    MULADD(at[25], at[114]);    MULADD(at[26], at[113]);    MULADD(at[27], at[112]);    MULADD(at[28], at[111]);    MULADD(at[29], at[110]);    MULADD(at[30], at[109]);    MULADD(at[31], at[108]);    MULADD(at[32], at[107]);    MULADD(at[33], at[106]);    MULADD(at[34], at[105]);    MULADD(at[35], at[104]);    MULADD(at[36], at[103]);    MULADD(at[37], at[102]);    MULADD(at[38], at[101]);    MULADD(at[39], at[100]);    MULADD(at[40], at[99]);    MULADD(at[41], at[98]);    MULADD(at[42], at[97]);    MULADD(at[43], at[96]);    MULADD(at[44], at[95]);    MULADD(at[45], at[94]);    MULADD(at[46], at[93]);    MULADD(at[47], at[92]);    MULADD(at[48], at[91]);    MULADD(at[49], at[90]);    MULADD(at[50], at[89]);    MULADD(at[51], at[88]);    MULADD(at[52], at[87]);    MULADD(at[53], at[86]);    MULADD(at[54], at[85]);    MULADD(at[55], at[84]);    MULADD(at[56], at[83]);    MULADD(at[57], at[82]);    MULADD(at[58], at[81]);    MULADD(at[59], at[80]);    MULADD(at[60], at[79]);    MULADD(at[61], at[78]);    MULADD(at[62], at[77]);    MULADD(at[63], at[76]); 
-   COMBA_STORE(C->dp[75]);
-   /* 76 */
-   COMBA_FORWARD;
-   MULADD(at[13], at[127]);    MULADD(at[14], at[126]);    MULADD(at[15], at[125]);    MULADD(at[16], at[124]);    MULADD(at[17], at[123]);    MULADD(at[18], at[122]);    MULADD(at[19], at[121]);    MULADD(at[20], at[120]);    MULADD(at[21], at[119]);    MULADD(at[22], at[118]);    MULADD(at[23], at[117]);    MULADD(at[24], at[116]);    MULADD(at[25], at[115]);    MULADD(at[26], at[114]);    MULADD(at[27], at[113]);    MULADD(at[28], at[112]);    MULADD(at[29], at[111]);    MULADD(at[30], at[110]);    MULADD(at[31], at[109]);    MULADD(at[32], at[108]);    MULADD(at[33], at[107]);    MULADD(at[34], at[106]);    MULADD(at[35], at[105]);    MULADD(at[36], at[104]);    MULADD(at[37], at[103]);    MULADD(at[38], at[102]);    MULADD(at[39], at[101]);    MULADD(at[40], at[100]);    MULADD(at[41], at[99]);    MULADD(at[42], at[98]);    MULADD(at[43], at[97]);    MULADD(at[44], at[96]);    MULADD(at[45], at[95]);    MULADD(at[46], at[94]);    MULADD(at[47], at[93]);    MULADD(at[48], at[92]);    MULADD(at[49], at[91]);    MULADD(at[50], at[90]);    MULADD(at[51], at[89]);    MULADD(at[52], at[88]);    MULADD(at[53], at[87]);    MULADD(at[54], at[86]);    MULADD(at[55], at[85]);    MULADD(at[56], at[84]);    MULADD(at[57], at[83]);    MULADD(at[58], at[82]);    MULADD(at[59], at[81]);    MULADD(at[60], at[80]);    MULADD(at[61], at[79]);    MULADD(at[62], at[78]);    MULADD(at[63], at[77]); 
-   COMBA_STORE(C->dp[76]);
-   /* 77 */
-   COMBA_FORWARD;
-   MULADD(at[14], at[127]);    MULADD(at[15], at[126]);    MULADD(at[16], at[125]);    MULADD(at[17], at[124]);    MULADD(at[18], at[123]);    MULADD(at[19], at[122]);    MULADD(at[20], at[121]);    MULADD(at[21], at[120]);    MULADD(at[22], at[119]);    MULADD(at[23], at[118]);    MULADD(at[24], at[117]);    MULADD(at[25], at[116]);    MULADD(at[26], at[115]);    MULADD(at[27], at[114]);    MULADD(at[28], at[113]);    MULADD(at[29], at[112]);    MULADD(at[30], at[111]);    MULADD(at[31], at[110]);    MULADD(at[32], at[109]);    MULADD(at[33], at[108]);    MULADD(at[34], at[107]);    MULADD(at[35], at[106]);    MULADD(at[36], at[105]);    MULADD(at[37], at[104]);    MULADD(at[38], at[103]);    MULADD(at[39], at[102]);    MULADD(at[40], at[101]);    MULADD(at[41], at[100]);    MULADD(at[42], at[99]);    MULADD(at[43], at[98]);    MULADD(at[44], at[97]);    MULADD(at[45], at[96]);    MULADD(at[46], at[95]);    MULADD(at[47], at[94]);    MULADD(at[48], at[93]);    MULADD(at[49], at[92]);    MULADD(at[50], at[91]);    MULADD(at[51], at[90]);    MULADD(at[52], at[89]);    MULADD(at[53], at[88]);    MULADD(at[54], at[87]);    MULADD(at[55], at[86]);    MULADD(at[56], at[85]);    MULADD(at[57], at[84]);    MULADD(at[58], at[83]);    MULADD(at[59], at[82]);    MULADD(at[60], at[81]);    MULADD(at[61], at[80]);    MULADD(at[62], at[79]);    MULADD(at[63], at[78]); 
-   COMBA_STORE(C->dp[77]);
-   /* 78 */
-   COMBA_FORWARD;
-   MULADD(at[15], at[127]);    MULADD(at[16], at[126]);    MULADD(at[17], at[125]);    MULADD(at[18], at[124]);    MULADD(at[19], at[123]);    MULADD(at[20], at[122]);    MULADD(at[21], at[121]);    MULADD(at[22], at[120]);    MULADD(at[23], at[119]);    MULADD(at[24], at[118]);    MULADD(at[25], at[117]);    MULADD(at[26], at[116]);    MULADD(at[27], at[115]);    MULADD(at[28], at[114]);    MULADD(at[29], at[113]);    MULADD(at[30], at[112]);    MULADD(at[31], at[111]);    MULADD(at[32], at[110]);    MULADD(at[33], at[109]);    MULADD(at[34], at[108]);    MULADD(at[35], at[107]);    MULADD(at[36], at[106]);    MULADD(at[37], at[105]);    MULADD(at[38], at[104]);    MULADD(at[39], at[103]);    MULADD(at[40], at[102]);    MULADD(at[41], at[101]);    MULADD(at[42], at[100]);    MULADD(at[43], at[99]);    MULADD(at[44], at[98]);    MULADD(at[45], at[97]);    MULADD(at[46], at[96]);    MULADD(at[47], at[95]);    MULADD(at[48], at[94]);    MULADD(at[49], at[93]);    MULADD(at[50], at[92]);    MULADD(at[51], at[91]);    MULADD(at[52], at[90]);    MULADD(at[53], at[89]);    MULADD(at[54], at[88]);    MULADD(at[55], at[87]);    MULADD(at[56], at[86]);    MULADD(at[57], at[85]);    MULADD(at[58], at[84]);    MULADD(at[59], at[83]);    MULADD(at[60], at[82]);    MULADD(at[61], at[81]);    MULADD(at[62], at[80]);    MULADD(at[63], at[79]); 
-   COMBA_STORE(C->dp[78]);
-   /* 79 */
-   COMBA_FORWARD;
-   MULADD(at[16], at[127]);    MULADD(at[17], at[126]);    MULADD(at[18], at[125]);    MULADD(at[19], at[124]);    MULADD(at[20], at[123]);    MULADD(at[21], at[122]);    MULADD(at[22], at[121]);    MULADD(at[23], at[120]);    MULADD(at[24], at[119]);    MULADD(at[25], at[118]);    MULADD(at[26], at[117]);    MULADD(at[27], at[116]);    MULADD(at[28], at[115]);    MULADD(at[29], at[114]);    MULADD(at[30], at[113]);    MULADD(at[31], at[112]);    MULADD(at[32], at[111]);    MULADD(at[33], at[110]);    MULADD(at[34], at[109]);    MULADD(at[35], at[108]);    MULADD(at[36], at[107]);    MULADD(at[37], at[106]);    MULADD(at[38], at[105]);    MULADD(at[39], at[104]);    MULADD(at[40], at[103]);    MULADD(at[41], at[102]);    MULADD(at[42], at[101]);    MULADD(at[43], at[100]);    MULADD(at[44], at[99]);    MULADD(at[45], at[98]);    MULADD(at[46], at[97]);    MULADD(at[47], at[96]);    MULADD(at[48], at[95]);    MULADD(at[49], at[94]);    MULADD(at[50], at[93]);    MULADD(at[51], at[92]);    MULADD(at[52], at[91]);    MULADD(at[53], at[90]);    MULADD(at[54], at[89]);    MULADD(at[55], at[88]);    MULADD(at[56], at[87]);    MULADD(at[57], at[86]);    MULADD(at[58], at[85]);    MULADD(at[59], at[84]);    MULADD(at[60], at[83]);    MULADD(at[61], at[82]);    MULADD(at[62], at[81]);    MULADD(at[63], at[80]); 
-   COMBA_STORE(C->dp[79]);
-   /* 80 */
-   COMBA_FORWARD;
-   MULADD(at[17], at[127]);    MULADD(at[18], at[126]);    MULADD(at[19], at[125]);    MULADD(at[20], at[124]);    MULADD(at[21], at[123]);    MULADD(at[22], at[122]);    MULADD(at[23], at[121]);    MULADD(at[24], at[120]);    MULADD(at[25], at[119]);    MULADD(at[26], at[118]);    MULADD(at[27], at[117]);    MULADD(at[28], at[116]);    MULADD(at[29], at[115]);    MULADD(at[30], at[114]);    MULADD(at[31], at[113]);    MULADD(at[32], at[112]);    MULADD(at[33], at[111]);    MULADD(at[34], at[110]);    MULADD(at[35], at[109]);    MULADD(at[36], at[108]);    MULADD(at[37], at[107]);    MULADD(at[38], at[106]);    MULADD(at[39], at[105]);    MULADD(at[40], at[104]);    MULADD(at[41], at[103]);    MULADD(at[42], at[102]);    MULADD(at[43], at[101]);    MULADD(at[44], at[100]);    MULADD(at[45], at[99]);    MULADD(at[46], at[98]);    MULADD(at[47], at[97]);    MULADD(at[48], at[96]);    MULADD(at[49], at[95]);    MULADD(at[50], at[94]);    MULADD(at[51], at[93]);    MULADD(at[52], at[92]);    MULADD(at[53], at[91]);    MULADD(at[54], at[90]);    MULADD(at[55], at[89]);    MULADD(at[56], at[88]);    MULADD(at[57], at[87]);    MULADD(at[58], at[86]);    MULADD(at[59], at[85]);    MULADD(at[60], at[84]);    MULADD(at[61], at[83]);    MULADD(at[62], at[82]);    MULADD(at[63], at[81]); 
-   COMBA_STORE(C->dp[80]);
-   /* 81 */
-   COMBA_FORWARD;
-   MULADD(at[18], at[127]);    MULADD(at[19], at[126]);    MULADD(at[20], at[125]);    MULADD(at[21], at[124]);    MULADD(at[22], at[123]);    MULADD(at[23], at[122]);    MULADD(at[24], at[121]);    MULADD(at[25], at[120]);    MULADD(at[26], at[119]);    MULADD(at[27], at[118]);    MULADD(at[28], at[117]);    MULADD(at[29], at[116]);    MULADD(at[30], at[115]);    MULADD(at[31], at[114]);    MULADD(at[32], at[113]);    MULADD(at[33], at[112]);    MULADD(at[34], at[111]);    MULADD(at[35], at[110]);    MULADD(at[36], at[109]);    MULADD(at[37], at[108]);    MULADD(at[38], at[107]);    MULADD(at[39], at[106]);    MULADD(at[40], at[105]);    MULADD(at[41], at[104]);    MULADD(at[42], at[103]);    MULADD(at[43], at[102]);    MULADD(at[44], at[101]);    MULADD(at[45], at[100]);    MULADD(at[46], at[99]);    MULADD(at[47], at[98]);    MULADD(at[48], at[97]);    MULADD(at[49], at[96]);    MULADD(at[50], at[95]);    MULADD(at[51], at[94]);    MULADD(at[52], at[93]);    MULADD(at[53], at[92]);    MULADD(at[54], at[91]);    MULADD(at[55], at[90]);    MULADD(at[56], at[89]);    MULADD(at[57], at[88]);    MULADD(at[58], at[87]);    MULADD(at[59], at[86]);    MULADD(at[60], at[85]);    MULADD(at[61], at[84]);    MULADD(at[62], at[83]);    MULADD(at[63], at[82]); 
-   COMBA_STORE(C->dp[81]);
-   /* 82 */
-   COMBA_FORWARD;
-   MULADD(at[19], at[127]);    MULADD(at[20], at[126]);    MULADD(at[21], at[125]);    MULADD(at[22], at[124]);    MULADD(at[23], at[123]);    MULADD(at[24], at[122]);    MULADD(at[25], at[121]);    MULADD(at[26], at[120]);    MULADD(at[27], at[119]);    MULADD(at[28], at[118]);    MULADD(at[29], at[117]);    MULADD(at[30], at[116]);    MULADD(at[31], at[115]);    MULADD(at[32], at[114]);    MULADD(at[33], at[113]);    MULADD(at[34], at[112]);    MULADD(at[35], at[111]);    MULADD(at[36], at[110]);    MULADD(at[37], at[109]);    MULADD(at[38], at[108]);    MULADD(at[39], at[107]);    MULADD(at[40], at[106]);    MULADD(at[41], at[105]);    MULADD(at[42], at[104]);    MULADD(at[43], at[103]);    MULADD(at[44], at[102]);    MULADD(at[45], at[101]);    MULADD(at[46], at[100]);    MULADD(at[47], at[99]);    MULADD(at[48], at[98]);    MULADD(at[49], at[97]);    MULADD(at[50], at[96]);    MULADD(at[51], at[95]);    MULADD(at[52], at[94]);    MULADD(at[53], at[93]);    MULADD(at[54], at[92]);    MULADD(at[55], at[91]);    MULADD(at[56], at[90]);    MULADD(at[57], at[89]);    MULADD(at[58], at[88]);    MULADD(at[59], at[87]);    MULADD(at[60], at[86]);    MULADD(at[61], at[85]);    MULADD(at[62], at[84]);    MULADD(at[63], at[83]); 
-   COMBA_STORE(C->dp[82]);
-   /* 83 */
-   COMBA_FORWARD;
-   MULADD(at[20], at[127]);    MULADD(at[21], at[126]);    MULADD(at[22], at[125]);    MULADD(at[23], at[124]);    MULADD(at[24], at[123]);    MULADD(at[25], at[122]);    MULADD(at[26], at[121]);    MULADD(at[27], at[120]);    MULADD(at[28], at[119]);    MULADD(at[29], at[118]);    MULADD(at[30], at[117]);    MULADD(at[31], at[116]);    MULADD(at[32], at[115]);    MULADD(at[33], at[114]);    MULADD(at[34], at[113]);    MULADD(at[35], at[112]);    MULADD(at[36], at[111]);    MULADD(at[37], at[110]);    MULADD(at[38], at[109]);    MULADD(at[39], at[108]);    MULADD(at[40], at[107]);    MULADD(at[41], at[106]);    MULADD(at[42], at[105]);    MULADD(at[43], at[104]);    MULADD(at[44], at[103]);    MULADD(at[45], at[102]);    MULADD(at[46], at[101]);    MULADD(at[47], at[100]);    MULADD(at[48], at[99]);    MULADD(at[49], at[98]);    MULADD(at[50], at[97]);    MULADD(at[51], at[96]);    MULADD(at[52], at[95]);    MULADD(at[53], at[94]);    MULADD(at[54], at[93]);    MULADD(at[55], at[92]);    MULADD(at[56], at[91]);    MULADD(at[57], at[90]);    MULADD(at[58], at[89]);    MULADD(at[59], at[88]);    MULADD(at[60], at[87]);    MULADD(at[61], at[86]);    MULADD(at[62], at[85]);    MULADD(at[63], at[84]); 
-   COMBA_STORE(C->dp[83]);
-   /* 84 */
-   COMBA_FORWARD;
-   MULADD(at[21], at[127]);    MULADD(at[22], at[126]);    MULADD(at[23], at[125]);    MULADD(at[24], at[124]);    MULADD(at[25], at[123]);    MULADD(at[26], at[122]);    MULADD(at[27], at[121]);    MULADD(at[28], at[120]);    MULADD(at[29], at[119]);    MULADD(at[30], at[118]);    MULADD(at[31], at[117]);    MULADD(at[32], at[116]);    MULADD(at[33], at[115]);    MULADD(at[34], at[114]);    MULADD(at[35], at[113]);    MULADD(at[36], at[112]);    MULADD(at[37], at[111]);    MULADD(at[38], at[110]);    MULADD(at[39], at[109]);    MULADD(at[40], at[108]);    MULADD(at[41], at[107]);    MULADD(at[42], at[106]);    MULADD(at[43], at[105]);    MULADD(at[44], at[104]);    MULADD(at[45], at[103]);    MULADD(at[46], at[102]);    MULADD(at[47], at[101]);    MULADD(at[48], at[100]);    MULADD(at[49], at[99]);    MULADD(at[50], at[98]);    MULADD(at[51], at[97]);    MULADD(at[52], at[96]);    MULADD(at[53], at[95]);    MULADD(at[54], at[94]);    MULADD(at[55], at[93]);    MULADD(at[56], at[92]);    MULADD(at[57], at[91]);    MULADD(at[58], at[90]);    MULADD(at[59], at[89]);    MULADD(at[60], at[88]);    MULADD(at[61], at[87]);    MULADD(at[62], at[86]);    MULADD(at[63], at[85]); 
-   COMBA_STORE(C->dp[84]);
-   /* 85 */
-   COMBA_FORWARD;
-   MULADD(at[22], at[127]);    MULADD(at[23], at[126]);    MULADD(at[24], at[125]);    MULADD(at[25], at[124]);    MULADD(at[26], at[123]);    MULADD(at[27], at[122]);    MULADD(at[28], at[121]);    MULADD(at[29], at[120]);    MULADD(at[30], at[119]);    MULADD(at[31], at[118]);    MULADD(at[32], at[117]);    MULADD(at[33], at[116]);    MULADD(at[34], at[115]);    MULADD(at[35], at[114]);    MULADD(at[36], at[113]);    MULADD(at[37], at[112]);    MULADD(at[38], at[111]);    MULADD(at[39], at[110]);    MULADD(at[40], at[109]);    MULADD(at[41], at[108]);    MULADD(at[42], at[107]);    MULADD(at[43], at[106]);    MULADD(at[44], at[105]);    MULADD(at[45], at[104]);    MULADD(at[46], at[103]);    MULADD(at[47], at[102]);    MULADD(at[48], at[101]);    MULADD(at[49], at[100]);    MULADD(at[50], at[99]);    MULADD(at[51], at[98]);    MULADD(at[52], at[97]);    MULADD(at[53], at[96]);    MULADD(at[54], at[95]);    MULADD(at[55], at[94]);    MULADD(at[56], at[93]);    MULADD(at[57], at[92]);    MULADD(at[58], at[91]);    MULADD(at[59], at[90]);    MULADD(at[60], at[89]);    MULADD(at[61], at[88]);    MULADD(at[62], at[87]);    MULADD(at[63], at[86]); 
-   COMBA_STORE(C->dp[85]);
-   /* 86 */
-   COMBA_FORWARD;
-   MULADD(at[23], at[127]);    MULADD(at[24], at[126]);    MULADD(at[25], at[125]);    MULADD(at[26], at[124]);    MULADD(at[27], at[123]);    MULADD(at[28], at[122]);    MULADD(at[29], at[121]);    MULADD(at[30], at[120]);    MULADD(at[31], at[119]);    MULADD(at[32], at[118]);    MULADD(at[33], at[117]);    MULADD(at[34], at[116]);    MULADD(at[35], at[115]);    MULADD(at[36], at[114]);    MULADD(at[37], at[113]);    MULADD(at[38], at[112]);    MULADD(at[39], at[111]);    MULADD(at[40], at[110]);    MULADD(at[41], at[109]);    MULADD(at[42], at[108]);    MULADD(at[43], at[107]);    MULADD(at[44], at[106]);    MULADD(at[45], at[105]);    MULADD(at[46], at[104]);    MULADD(at[47], at[103]);    MULADD(at[48], at[102]);    MULADD(at[49], at[101]);    MULADD(at[50], at[100]);    MULADD(at[51], at[99]);    MULADD(at[52], at[98]);    MULADD(at[53], at[97]);    MULADD(at[54], at[96]);    MULADD(at[55], at[95]);    MULADD(at[56], at[94]);    MULADD(at[57], at[93]);    MULADD(at[58], at[92]);    MULADD(at[59], at[91]);    MULADD(at[60], at[90]);    MULADD(at[61], at[89]);    MULADD(at[62], at[88]);    MULADD(at[63], at[87]); 
-   COMBA_STORE(C->dp[86]);
-   /* 87 */
-   COMBA_FORWARD;
-   MULADD(at[24], at[127]);    MULADD(at[25], at[126]);    MULADD(at[26], at[125]);    MULADD(at[27], at[124]);    MULADD(at[28], at[123]);    MULADD(at[29], at[122]);    MULADD(at[30], at[121]);    MULADD(at[31], at[120]);    MULADD(at[32], at[119]);    MULADD(at[33], at[118]);    MULADD(at[34], at[117]);    MULADD(at[35], at[116]);    MULADD(at[36], at[115]);    MULADD(at[37], at[114]);    MULADD(at[38], at[113]);    MULADD(at[39], at[112]);    MULADD(at[40], at[111]);    MULADD(at[41], at[110]);    MULADD(at[42], at[109]);    MULADD(at[43], at[108]);    MULADD(at[44], at[107]);    MULADD(at[45], at[106]);    MULADD(at[46], at[105]);    MULADD(at[47], at[104]);    MULADD(at[48], at[103]);    MULADD(at[49], at[102]);    MULADD(at[50], at[101]);    MULADD(at[51], at[100]);    MULADD(at[52], at[99]);    MULADD(at[53], at[98]);    MULADD(at[54], at[97]);    MULADD(at[55], at[96]);    MULADD(at[56], at[95]);    MULADD(at[57], at[94]);    MULADD(at[58], at[93]);    MULADD(at[59], at[92]);    MULADD(at[60], at[91]);    MULADD(at[61], at[90]);    MULADD(at[62], at[89]);    MULADD(at[63], at[88]); 
-   COMBA_STORE(C->dp[87]);
-   /* 88 */
-   COMBA_FORWARD;
-   MULADD(at[25], at[127]);    MULADD(at[26], at[126]);    MULADD(at[27], at[125]);    MULADD(at[28], at[124]);    MULADD(at[29], at[123]);    MULADD(at[30], at[122]);    MULADD(at[31], at[121]);    MULADD(at[32], at[120]);    MULADD(at[33], at[119]);    MULADD(at[34], at[118]);    MULADD(at[35], at[117]);    MULADD(at[36], at[116]);    MULADD(at[37], at[115]);    MULADD(at[38], at[114]);    MULADD(at[39], at[113]);    MULADD(at[40], at[112]);    MULADD(at[41], at[111]);    MULADD(at[42], at[110]);    MULADD(at[43], at[109]);    MULADD(at[44], at[108]);    MULADD(at[45], at[107]);    MULADD(at[46], at[106]);    MULADD(at[47], at[105]);    MULADD(at[48], at[104]);    MULADD(at[49], at[103]);    MULADD(at[50], at[102]);    MULADD(at[51], at[101]);    MULADD(at[52], at[100]);    MULADD(at[53], at[99]);    MULADD(at[54], at[98]);    MULADD(at[55], at[97]);    MULADD(at[56], at[96]);    MULADD(at[57], at[95]);    MULADD(at[58], at[94]);    MULADD(at[59], at[93]);    MULADD(at[60], at[92]);    MULADD(at[61], at[91]);    MULADD(at[62], at[90]);    MULADD(at[63], at[89]); 
-   COMBA_STORE(C->dp[88]);
-   /* 89 */
-   COMBA_FORWARD;
-   MULADD(at[26], at[127]);    MULADD(at[27], at[126]);    MULADD(at[28], at[125]);    MULADD(at[29], at[124]);    MULADD(at[30], at[123]);    MULADD(at[31], at[122]);    MULADD(at[32], at[121]);    MULADD(at[33], at[120]);    MULADD(at[34], at[119]);    MULADD(at[35], at[118]);    MULADD(at[36], at[117]);    MULADD(at[37], at[116]);    MULADD(at[38], at[115]);    MULADD(at[39], at[114]);    MULADD(at[40], at[113]);    MULADD(at[41], at[112]);    MULADD(at[42], at[111]);    MULADD(at[43], at[110]);    MULADD(at[44], at[109]);    MULADD(at[45], at[108]);    MULADD(at[46], at[107]);    MULADD(at[47], at[106]);    MULADD(at[48], at[105]);    MULADD(at[49], at[104]);    MULADD(at[50], at[103]);    MULADD(at[51], at[102]);    MULADD(at[52], at[101]);    MULADD(at[53], at[100]);    MULADD(at[54], at[99]);    MULADD(at[55], at[98]);    MULADD(at[56], at[97]);    MULADD(at[57], at[96]);    MULADD(at[58], at[95]);    MULADD(at[59], at[94]);    MULADD(at[60], at[93]);    MULADD(at[61], at[92]);    MULADD(at[62], at[91]);    MULADD(at[63], at[90]); 
-   COMBA_STORE(C->dp[89]);
-   /* 90 */
-   COMBA_FORWARD;
-   MULADD(at[27], at[127]);    MULADD(at[28], at[126]);    MULADD(at[29], at[125]);    MULADD(at[30], at[124]);    MULADD(at[31], at[123]);    MULADD(at[32], at[122]);    MULADD(at[33], at[121]);    MULADD(at[34], at[120]);    MULADD(at[35], at[119]);    MULADD(at[36], at[118]);    MULADD(at[37], at[117]);    MULADD(at[38], at[116]);    MULADD(at[39], at[115]);    MULADD(at[40], at[114]);    MULADD(at[41], at[113]);    MULADD(at[42], at[112]);    MULADD(at[43], at[111]);    MULADD(at[44], at[110]);    MULADD(at[45], at[109]);    MULADD(at[46], at[108]);    MULADD(at[47], at[107]);    MULADD(at[48], at[106]);    MULADD(at[49], at[105]);    MULADD(at[50], at[104]);    MULADD(at[51], at[103]);    MULADD(at[52], at[102]);    MULADD(at[53], at[101]);    MULADD(at[54], at[100]);    MULADD(at[55], at[99]);    MULADD(at[56], at[98]);    MULADD(at[57], at[97]);    MULADD(at[58], at[96]);    MULADD(at[59], at[95]);    MULADD(at[60], at[94]);    MULADD(at[61], at[93]);    MULADD(at[62], at[92]);    MULADD(at[63], at[91]); 
-   COMBA_STORE(C->dp[90]);
-   /* 91 */
-   COMBA_FORWARD;
-   MULADD(at[28], at[127]);    MULADD(at[29], at[126]);    MULADD(at[30], at[125]);    MULADD(at[31], at[124]);    MULADD(at[32], at[123]);    MULADD(at[33], at[122]);    MULADD(at[34], at[121]);    MULADD(at[35], at[120]);    MULADD(at[36], at[119]);    MULADD(at[37], at[118]);    MULADD(at[38], at[117]);    MULADD(at[39], at[116]);    MULADD(at[40], at[115]);    MULADD(at[41], at[114]);    MULADD(at[42], at[113]);    MULADD(at[43], at[112]);    MULADD(at[44], at[111]);    MULADD(at[45], at[110]);    MULADD(at[46], at[109]);    MULADD(at[47], at[108]);    MULADD(at[48], at[107]);    MULADD(at[49], at[106]);    MULADD(at[50], at[105]);    MULADD(at[51], at[104]);    MULADD(at[52], at[103]);    MULADD(at[53], at[102]);    MULADD(at[54], at[101]);    MULADD(at[55], at[100]);    MULADD(at[56], at[99]);    MULADD(at[57], at[98]);    MULADD(at[58], at[97]);    MULADD(at[59], at[96]);    MULADD(at[60], at[95]);    MULADD(at[61], at[94]);    MULADD(at[62], at[93]);    MULADD(at[63], at[92]); 
-   COMBA_STORE(C->dp[91]);
-   /* 92 */
-   COMBA_FORWARD;
-   MULADD(at[29], at[127]);    MULADD(at[30], at[126]);    MULADD(at[31], at[125]);    MULADD(at[32], at[124]);    MULADD(at[33], at[123]);    MULADD(at[34], at[122]);    MULADD(at[35], at[121]);    MULADD(at[36], at[120]);    MULADD(at[37], at[119]);    MULADD(at[38], at[118]);    MULADD(at[39], at[117]);    MULADD(at[40], at[116]);    MULADD(at[41], at[115]);    MULADD(at[42], at[114]);    MULADD(at[43], at[113]);    MULADD(at[44], at[112]);    MULADD(at[45], at[111]);    MULADD(at[46], at[110]);    MULADD(at[47], at[109]);    MULADD(at[48], at[108]);    MULADD(at[49], at[107]);    MULADD(at[50], at[106]);    MULADD(at[51], at[105]);    MULADD(at[52], at[104]);    MULADD(at[53], at[103]);    MULADD(at[54], at[102]);    MULADD(at[55], at[101]);    MULADD(at[56], at[100]);    MULADD(at[57], at[99]);    MULADD(at[58], at[98]);    MULADD(at[59], at[97]);    MULADD(at[60], at[96]);    MULADD(at[61], at[95]);    MULADD(at[62], at[94]);    MULADD(at[63], at[93]); 
-   COMBA_STORE(C->dp[92]);
-   /* 93 */
-   COMBA_FORWARD;
-   MULADD(at[30], at[127]);    MULADD(at[31], at[126]);    MULADD(at[32], at[125]);    MULADD(at[33], at[124]);    MULADD(at[34], at[123]);    MULADD(at[35], at[122]);    MULADD(at[36], at[121]);    MULADD(at[37], at[120]);    MULADD(at[38], at[119]);    MULADD(at[39], at[118]);    MULADD(at[40], at[117]);    MULADD(at[41], at[116]);    MULADD(at[42], at[115]);    MULADD(at[43], at[114]);    MULADD(at[44], at[113]);    MULADD(at[45], at[112]);    MULADD(at[46], at[111]);    MULADD(at[47], at[110]);    MULADD(at[48], at[109]);    MULADD(at[49], at[108]);    MULADD(at[50], at[107]);    MULADD(at[51], at[106]);    MULADD(at[52], at[105]);    MULADD(at[53], at[104]);    MULADD(at[54], at[103]);    MULADD(at[55], at[102]);    MULADD(at[56], at[101]);    MULADD(at[57], at[100]);    MULADD(at[58], at[99]);    MULADD(at[59], at[98]);    MULADD(at[60], at[97]);    MULADD(at[61], at[96]);    MULADD(at[62], at[95]);    MULADD(at[63], at[94]); 
-   COMBA_STORE(C->dp[93]);
-   /* 94 */
-   COMBA_FORWARD;
-   MULADD(at[31], at[127]);    MULADD(at[32], at[126]);    MULADD(at[33], at[125]);    MULADD(at[34], at[124]);    MULADD(at[35], at[123]);    MULADD(at[36], at[122]);    MULADD(at[37], at[121]);    MULADD(at[38], at[120]);    MULADD(at[39], at[119]);    MULADD(at[40], at[118]);    MULADD(at[41], at[117]);    MULADD(at[42], at[116]);    MULADD(at[43], at[115]);    MULADD(at[44], at[114]);    MULADD(at[45], at[113]);    MULADD(at[46], at[112]);    MULADD(at[47], at[111]);    MULADD(at[48], at[110]);    MULADD(at[49], at[109]);    MULADD(at[50], at[108]);    MULADD(at[51], at[107]);    MULADD(at[52], at[106]);    MULADD(at[53], at[105]);    MULADD(at[54], at[104]);    MULADD(at[55], at[103]);    MULADD(at[56], at[102]);    MULADD(at[57], at[101]);    MULADD(at[58], at[100]);    MULADD(at[59], at[99]);    MULADD(at[60], at[98]);    MULADD(at[61], at[97]);    MULADD(at[62], at[96]);    MULADD(at[63], at[95]); 
-   COMBA_STORE(C->dp[94]);
-   /* 95 */
-   COMBA_FORWARD;
-   MULADD(at[32], at[127]);    MULADD(at[33], at[126]);    MULADD(at[34], at[125]);    MULADD(at[35], at[124]);    MULADD(at[36], at[123]);    MULADD(at[37], at[122]);    MULADD(at[38], at[121]);    MULADD(at[39], at[120]);    MULADD(at[40], at[119]);    MULADD(at[41], at[118]);    MULADD(at[42], at[117]);    MULADD(at[43], at[116]);    MULADD(at[44], at[115]);    MULADD(at[45], at[114]);    MULADD(at[46], at[113]);    MULADD(at[47], at[112]);    MULADD(at[48], at[111]);    MULADD(at[49], at[110]);    MULADD(at[50], at[109]);    MULADD(at[51], at[108]);    MULADD(at[52], at[107]);    MULADD(at[53], at[106]);    MULADD(at[54], at[105]);    MULADD(at[55], at[104]);    MULADD(at[56], at[103]);    MULADD(at[57], at[102]);    MULADD(at[58], at[101]);    MULADD(at[59], at[100]);    MULADD(at[60], at[99]);    MULADD(at[61], at[98]);    MULADD(at[62], at[97]);    MULADD(at[63], at[96]); 
-   COMBA_STORE(C->dp[95]);
-   /* 96 */
-   COMBA_FORWARD;
-   MULADD(at[33], at[127]);    MULADD(at[34], at[126]);    MULADD(at[35], at[125]);    MULADD(at[36], at[124]);    MULADD(at[37], at[123]);    MULADD(at[38], at[122]);    MULADD(at[39], at[121]);    MULADD(at[40], at[120]);    MULADD(at[41], at[119]);    MULADD(at[42], at[118]);    MULADD(at[43], at[117]);    MULADD(at[44], at[116]);    MULADD(at[45], at[115]);    MULADD(at[46], at[114]);    MULADD(at[47], at[113]);    MULADD(at[48], at[112]);    MULADD(at[49], at[111]);    MULADD(at[50], at[110]);    MULADD(at[51], at[109]);    MULADD(at[52], at[108]);    MULADD(at[53], at[107]);    MULADD(at[54], at[106]);    MULADD(at[55], at[105]);    MULADD(at[56], at[104]);    MULADD(at[57], at[103]);    MULADD(at[58], at[102]);    MULADD(at[59], at[101]);    MULADD(at[60], at[100]);    MULADD(at[61], at[99]);    MULADD(at[62], at[98]);    MULADD(at[63], at[97]); 
-   COMBA_STORE(C->dp[96]);
-   /* 97 */
-   COMBA_FORWARD;
-   MULADD(at[34], at[127]);    MULADD(at[35], at[126]);    MULADD(at[36], at[125]);    MULADD(at[37], at[124]);    MULADD(at[38], at[123]);    MULADD(at[39], at[122]);    MULADD(at[40], at[121]);    MULADD(at[41], at[120]);    MULADD(at[42], at[119]);    MULADD(at[43], at[118]);    MULADD(at[44], at[117]);    MULADD(at[45], at[116]);    MULADD(at[46], at[115]);    MULADD(at[47], at[114]);    MULADD(at[48], at[113]);    MULADD(at[49], at[112]);    MULADD(at[50], at[111]);    MULADD(at[51], at[110]);    MULADD(at[52], at[109]);    MULADD(at[53], at[108]);    MULADD(at[54], at[107]);    MULADD(at[55], at[106]);    MULADD(at[56], at[105]);    MULADD(at[57], at[104]);    MULADD(at[58], at[103]);    MULADD(at[59], at[102]);    MULADD(at[60], at[101]);    MULADD(at[61], at[100]);    MULADD(at[62], at[99]);    MULADD(at[63], at[98]); 
-   COMBA_STORE(C->dp[97]);
-   /* 98 */
-   COMBA_FORWARD;
-   MULADD(at[35], at[127]);    MULADD(at[36], at[126]);    MULADD(at[37], at[125]);    MULADD(at[38], at[124]);    MULADD(at[39], at[123]);    MULADD(at[40], at[122]);    MULADD(at[41], at[121]);    MULADD(at[42], at[120]);    MULADD(at[43], at[119]);    MULADD(at[44], at[118]);    MULADD(at[45], at[117]);    MULADD(at[46], at[116]);    MULADD(at[47], at[115]);    MULADD(at[48], at[114]);    MULADD(at[49], at[113]);    MULADD(at[50], at[112]);    MULADD(at[51], at[111]);    MULADD(at[52], at[110]);    MULADD(at[53], at[109]);    MULADD(at[54], at[108]);    MULADD(at[55], at[107]);    MULADD(at[56], at[106]);    MULADD(at[57], at[105]);    MULADD(at[58], at[104]);    MULADD(at[59], at[103]);    MULADD(at[60], at[102]);    MULADD(at[61], at[101]);    MULADD(at[62], at[100]);    MULADD(at[63], at[99]); 
-   COMBA_STORE(C->dp[98]);
-   /* 99 */
-   COMBA_FORWARD;
-   MULADD(at[36], at[127]);    MULADD(at[37], at[126]);    MULADD(at[38], at[125]);    MULADD(at[39], at[124]);    MULADD(at[40], at[123]);    MULADD(at[41], at[122]);    MULADD(at[42], at[121]);    MULADD(at[43], at[120]);    MULADD(at[44], at[119]);    MULADD(at[45], at[118]);    MULADD(at[46], at[117]);    MULADD(at[47], at[116]);    MULADD(at[48], at[115]);    MULADD(at[49], at[114]);    MULADD(at[50], at[113]);    MULADD(at[51], at[112]);    MULADD(at[52], at[111]);    MULADD(at[53], at[110]);    MULADD(at[54], at[109]);    MULADD(at[55], at[108]);    MULADD(at[56], at[107]);    MULADD(at[57], at[106]);    MULADD(at[58], at[105]);    MULADD(at[59], at[104]);    MULADD(at[60], at[103]);    MULADD(at[61], at[102]);    MULADD(at[62], at[101]);    MULADD(at[63], at[100]); 
-   COMBA_STORE(C->dp[99]);
-   /* 100 */
-   COMBA_FORWARD;
-   MULADD(at[37], at[127]);    MULADD(at[38], at[126]);    MULADD(at[39], at[125]);    MULADD(at[40], at[124]);    MULADD(at[41], at[123]);    MULADD(at[42], at[122]);    MULADD(at[43], at[121]);    MULADD(at[44], at[120]);    MULADD(at[45], at[119]);    MULADD(at[46], at[118]);    MULADD(at[47], at[117]);    MULADD(at[48], at[116]);    MULADD(at[49], at[115]);    MULADD(at[50], at[114]);    MULADD(at[51], at[113]);    MULADD(at[52], at[112]);    MULADD(at[53], at[111]);    MULADD(at[54], at[110]);    MULADD(at[55], at[109]);    MULADD(at[56], at[108]);    MULADD(at[57], at[107]);    MULADD(at[58], at[106]);    MULADD(at[59], at[105]);    MULADD(at[60], at[104]);    MULADD(at[61], at[103]);    MULADD(at[62], at[102]);    MULADD(at[63], at[101]); 
-   COMBA_STORE(C->dp[100]);
-   /* 101 */
-   COMBA_FORWARD;
-   MULADD(at[38], at[127]);    MULADD(at[39], at[126]);    MULADD(at[40], at[125]);    MULADD(at[41], at[124]);    MULADD(at[42], at[123]);    MULADD(at[43], at[122]);    MULADD(at[44], at[121]);    MULADD(at[45], at[120]);    MULADD(at[46], at[119]);    MULADD(at[47], at[118]);    MULADD(at[48], at[117]);    MULADD(at[49], at[116]);    MULADD(at[50], at[115]);    MULADD(at[51], at[114]);    MULADD(at[52], at[113]);    MULADD(at[53], at[112]);    MULADD(at[54], at[111]);    MULADD(at[55], at[110]);    MULADD(at[56], at[109]);    MULADD(at[57], at[108]);    MULADD(at[58], at[107]);    MULADD(at[59], at[106]);    MULADD(at[60], at[105]);    MULADD(at[61], at[104]);    MULADD(at[62], at[103]);    MULADD(at[63], at[102]); 
-   COMBA_STORE(C->dp[101]);
-   /* 102 */
-   COMBA_FORWARD;
-   MULADD(at[39], at[127]);    MULADD(at[40], at[126]);    MULADD(at[41], at[125]);    MULADD(at[42], at[124]);    MULADD(at[43], at[123]);    MULADD(at[44], at[122]);    MULADD(at[45], at[121]);    MULADD(at[46], at[120]);    MULADD(at[47], at[119]);    MULADD(at[48], at[118]);    MULADD(at[49], at[117]);    MULADD(at[50], at[116]);    MULADD(at[51], at[115]);    MULADD(at[52], at[114]);    MULADD(at[53], at[113]);    MULADD(at[54], at[112]);    MULADD(at[55], at[111]);    MULADD(at[56], at[110]);    MULADD(at[57], at[109]);    MULADD(at[58], at[108]);    MULADD(at[59], at[107]);    MULADD(at[60], at[106]);    MULADD(at[61], at[105]);    MULADD(at[62], at[104]);    MULADD(at[63], at[103]); 
-   COMBA_STORE(C->dp[102]);
-   /* 103 */
-   COMBA_FORWARD;
-   MULADD(at[40], at[127]);    MULADD(at[41], at[126]);    MULADD(at[42], at[125]);    MULADD(at[43], at[124]);    MULADD(at[44], at[123]);    MULADD(at[45], at[122]);    MULADD(at[46], at[121]);    MULADD(at[47], at[120]);    MULADD(at[48], at[119]);    MULADD(at[49], at[118]);    MULADD(at[50], at[117]);    MULADD(at[51], at[116]);    MULADD(at[52], at[115]);    MULADD(at[53], at[114]);    MULADD(at[54], at[113]);    MULADD(at[55], at[112]);    MULADD(at[56], at[111]);    MULADD(at[57], at[110]);    MULADD(at[58], at[109]);    MULADD(at[59], at[108]);    MULADD(at[60], at[107]);    MULADD(at[61], at[106]);    MULADD(at[62], at[105]);    MULADD(at[63], at[104]); 
-   COMBA_STORE(C->dp[103]);
-   /* 104 */
-   COMBA_FORWARD;
-   MULADD(at[41], at[127]);    MULADD(at[42], at[126]);    MULADD(at[43], at[125]);    MULADD(at[44], at[124]);    MULADD(at[45], at[123]);    MULADD(at[46], at[122]);    MULADD(at[47], at[121]);    MULADD(at[48], at[120]);    MULADD(at[49], at[119]);    MULADD(at[50], at[118]);    MULADD(at[51], at[117]);    MULADD(at[52], at[116]);    MULADD(at[53], at[115]);    MULADD(at[54], at[114]);    MULADD(at[55], at[113]);    MULADD(at[56], at[112]);    MULADD(at[57], at[111]);    MULADD(at[58], at[110]);    MULADD(at[59], at[109]);    MULADD(at[60], at[108]);    MULADD(at[61], at[107]);    MULADD(at[62], at[106]);    MULADD(at[63], at[105]); 
-   COMBA_STORE(C->dp[104]);
-   /* 105 */
-   COMBA_FORWARD;
-   MULADD(at[42], at[127]);    MULADD(at[43], at[126]);    MULADD(at[44], at[125]);    MULADD(at[45], at[124]);    MULADD(at[46], at[123]);    MULADD(at[47], at[122]);    MULADD(at[48], at[121]);    MULADD(at[49], at[120]);    MULADD(at[50], at[119]);    MULADD(at[51], at[118]);    MULADD(at[52], at[117]);    MULADD(at[53], at[116]);    MULADD(at[54], at[115]);    MULADD(at[55], at[114]);    MULADD(at[56], at[113]);    MULADD(at[57], at[112]);    MULADD(at[58], at[111]);    MULADD(at[59], at[110]);    MULADD(at[60], at[109]);    MULADD(at[61], at[108]);    MULADD(at[62], at[107]);    MULADD(at[63], at[106]); 
-   COMBA_STORE(C->dp[105]);
-   /* 106 */
-   COMBA_FORWARD;
-   MULADD(at[43], at[127]);    MULADD(at[44], at[126]);    MULADD(at[45], at[125]);    MULADD(at[46], at[124]);    MULADD(at[47], at[123]);    MULADD(at[48], at[122]);    MULADD(at[49], at[121]);    MULADD(at[50], at[120]);    MULADD(at[51], at[119]);    MULADD(at[52], at[118]);    MULADD(at[53], at[117]);    MULADD(at[54], at[116]);    MULADD(at[55], at[115]);    MULADD(at[56], at[114]);    MULADD(at[57], at[113]);    MULADD(at[58], at[112]);    MULADD(at[59], at[111]);    MULADD(at[60], at[110]);    MULADD(at[61], at[109]);    MULADD(at[62], at[108]);    MULADD(at[63], at[107]); 
-   COMBA_STORE(C->dp[106]);
-   /* 107 */
-   COMBA_FORWARD;
-   MULADD(at[44], at[127]);    MULADD(at[45], at[126]);    MULADD(at[46], at[125]);    MULADD(at[47], at[124]);    MULADD(at[48], at[123]);    MULADD(at[49], at[122]);    MULADD(at[50], at[121]);    MULADD(at[51], at[120]);    MULADD(at[52], at[119]);    MULADD(at[53], at[118]);    MULADD(at[54], at[117]);    MULADD(at[55], at[116]);    MULADD(at[56], at[115]);    MULADD(at[57], at[114]);    MULADD(at[58], at[113]);    MULADD(at[59], at[112]);    MULADD(at[60], at[111]);    MULADD(at[61], at[110]);    MULADD(at[62], at[109]);    MULADD(at[63], at[108]); 
-   COMBA_STORE(C->dp[107]);
-   /* 108 */
-   COMBA_FORWARD;
-   MULADD(at[45], at[127]);    MULADD(at[46], at[126]);    MULADD(at[47], at[125]);    MULADD(at[48], at[124]);    MULADD(at[49], at[123]);    MULADD(at[50], at[122]);    MULADD(at[51], at[121]);    MULADD(at[52], at[120]);    MULADD(at[53], at[119]);    MULADD(at[54], at[118]);    MULADD(at[55], at[117]);    MULADD(at[56], at[116]);    MULADD(at[57], at[115]);    MULADD(at[58], at[114]);    MULADD(at[59], at[113]);    MULADD(at[60], at[112]);    MULADD(at[61], at[111]);    MULADD(at[62], at[110]);    MULADD(at[63], at[109]); 
-   COMBA_STORE(C->dp[108]);
-   /* 109 */
-   COMBA_FORWARD;
-   MULADD(at[46], at[127]);    MULADD(at[47], at[126]);    MULADD(at[48], at[125]);    MULADD(at[49], at[124]);    MULADD(at[50], at[123]);    MULADD(at[51], at[122]);    MULADD(at[52], at[121]);    MULADD(at[53], at[120]);    MULADD(at[54], at[119]);    MULADD(at[55], at[118]);    MULADD(at[56], at[117]);    MULADD(at[57], at[116]);    MULADD(at[58], at[115]);    MULADD(at[59], at[114]);    MULADD(at[60], at[113]);    MULADD(at[61], at[112]);    MULADD(at[62], at[111]);    MULADD(at[63], at[110]); 
-   COMBA_STORE(C->dp[109]);
-   /* 110 */
-   COMBA_FORWARD;
-   MULADD(at[47], at[127]);    MULADD(at[48], at[126]);    MULADD(at[49], at[125]);    MULADD(at[50], at[124]);    MULADD(at[51], at[123]);    MULADD(at[52], at[122]);    MULADD(at[53], at[121]);    MULADD(at[54], at[120]);    MULADD(at[55], at[119]);    MULADD(at[56], at[118]);    MULADD(at[57], at[117]);    MULADD(at[58], at[116]);    MULADD(at[59], at[115]);    MULADD(at[60], at[114]);    MULADD(at[61], at[113]);    MULADD(at[62], at[112]);    MULADD(at[63], at[111]); 
-   COMBA_STORE(C->dp[110]);
-   /* 111 */
-   COMBA_FORWARD;
-   MULADD(at[48], at[127]);    MULADD(at[49], at[126]);    MULADD(at[50], at[125]);    MULADD(at[51], at[124]);    MULADD(at[52], at[123]);    MULADD(at[53], at[122]);    MULADD(at[54], at[121]);    MULADD(at[55], at[120]);    MULADD(at[56], at[119]);    MULADD(at[57], at[118]);    MULADD(at[58], at[117]);    MULADD(at[59], at[116]);    MULADD(at[60], at[115]);    MULADD(at[61], at[114]);    MULADD(at[62], at[113]);    MULADD(at[63], at[112]); 
-   COMBA_STORE(C->dp[111]);
-   /* 112 */
-   COMBA_FORWARD;
-   MULADD(at[49], at[127]);    MULADD(at[50], at[126]);    MULADD(at[51], at[125]);    MULADD(at[52], at[124]);    MULADD(at[53], at[123]);    MULADD(at[54], at[122]);    MULADD(at[55], at[121]);    MULADD(at[56], at[120]);    MULADD(at[57], at[119]);    MULADD(at[58], at[118]);    MULADD(at[59], at[117]);    MULADD(at[60], at[116]);    MULADD(at[61], at[115]);    MULADD(at[62], at[114]);    MULADD(at[63], at[113]); 
-   COMBA_STORE(C->dp[112]);
-   /* 113 */
-   COMBA_FORWARD;
-   MULADD(at[50], at[127]);    MULADD(at[51], at[126]);    MULADD(at[52], at[125]);    MULADD(at[53], at[124]);    MULADD(at[54], at[123]);    MULADD(at[55], at[122]);    MULADD(at[56], at[121]);    MULADD(at[57], at[120]);    MULADD(at[58], at[119]);    MULADD(at[59], at[118]);    MULADD(at[60], at[117]);    MULADD(at[61], at[116]);    MULADD(at[62], at[115]);    MULADD(at[63], at[114]); 
-   COMBA_STORE(C->dp[113]);
-   /* 114 */
-   COMBA_FORWARD;
-   MULADD(at[51], at[127]);    MULADD(at[52], at[126]);    MULADD(at[53], at[125]);    MULADD(at[54], at[124]);    MULADD(at[55], at[123]);    MULADD(at[56], at[122]);    MULADD(at[57], at[121]);    MULADD(at[58], at[120]);    MULADD(at[59], at[119]);    MULADD(at[60], at[118]);    MULADD(at[61], at[117]);    MULADD(at[62], at[116]);    MULADD(at[63], at[115]); 
-   COMBA_STORE(C->dp[114]);
-   /* 115 */
-   COMBA_FORWARD;
-   MULADD(at[52], at[127]);    MULADD(at[53], at[126]);    MULADD(at[54], at[125]);    MULADD(at[55], at[124]);    MULADD(at[56], at[123]);    MULADD(at[57], at[122]);    MULADD(at[58], at[121]);    MULADD(at[59], at[120]);    MULADD(at[60], at[119]);    MULADD(at[61], at[118]);    MULADD(at[62], at[117]);    MULADD(at[63], at[116]); 
-   COMBA_STORE(C->dp[115]);
-   /* 116 */
-   COMBA_FORWARD;
-   MULADD(at[53], at[127]);    MULADD(at[54], at[126]);    MULADD(at[55], at[125]);    MULADD(at[56], at[124]);    MULADD(at[57], at[123]);    MULADD(at[58], at[122]);    MULADD(at[59], at[121]);    MULADD(at[60], at[120]);    MULADD(at[61], at[119]);    MULADD(at[62], at[118]);    MULADD(at[63], at[117]); 
-   COMBA_STORE(C->dp[116]);
-   /* 117 */
-   COMBA_FORWARD;
-   MULADD(at[54], at[127]);    MULADD(at[55], at[126]);    MULADD(at[56], at[125]);    MULADD(at[57], at[124]);    MULADD(at[58], at[123]);    MULADD(at[59], at[122]);    MULADD(at[60], at[121]);    MULADD(at[61], at[120]);    MULADD(at[62], at[119]);    MULADD(at[63], at[118]); 
-   COMBA_STORE(C->dp[117]);
-   /* 118 */
-   COMBA_FORWARD;
-   MULADD(at[55], at[127]);    MULADD(at[56], at[126]);    MULADD(at[57], at[125]);    MULADD(at[58], at[124]);    MULADD(at[59], at[123]);    MULADD(at[60], at[122]);    MULADD(at[61], at[121]);    MULADD(at[62], at[120]);    MULADD(at[63], at[119]); 
-   COMBA_STORE(C->dp[118]);
-   /* 119 */
-   COMBA_FORWARD;
-   MULADD(at[56], at[127]);    MULADD(at[57], at[126]);    MULADD(at[58], at[125]);    MULADD(at[59], at[124]);    MULADD(at[60], at[123]);    MULADD(at[61], at[122]);    MULADD(at[62], at[121]);    MULADD(at[63], at[120]); 
-   COMBA_STORE(C->dp[119]);
-   /* 120 */
-   COMBA_FORWARD;
-   MULADD(at[57], at[127]);    MULADD(at[58], at[126]);    MULADD(at[59], at[125]);    MULADD(at[60], at[124]);    MULADD(at[61], at[123]);    MULADD(at[62], at[122]);    MULADD(at[63], at[121]); 
-   COMBA_STORE(C->dp[120]);
-   /* 121 */
-   COMBA_FORWARD;
-   MULADD(at[58], at[127]);    MULADD(at[59], at[126]);    MULADD(at[60], at[125]);    MULADD(at[61], at[124]);    MULADD(at[62], at[123]);    MULADD(at[63], at[122]); 
-   COMBA_STORE(C->dp[121]);
-   /* 122 */
-   COMBA_FORWARD;
-   MULADD(at[59], at[127]);    MULADD(at[60], at[126]);    MULADD(at[61], at[125]);    MULADD(at[62], at[124]);    MULADD(at[63], at[123]); 
-   COMBA_STORE(C->dp[122]);
-   /* 123 */
-   COMBA_FORWARD;
-   MULADD(at[60], at[127]);    MULADD(at[61], at[126]);    MULADD(at[62], at[125]);    MULADD(at[63], at[124]); 
-   COMBA_STORE(C->dp[123]);
-   /* 124 */
-   COMBA_FORWARD;
-   MULADD(at[61], at[127]);    MULADD(at[62], at[126]);    MULADD(at[63], at[125]); 
-   COMBA_STORE(C->dp[124]);
-   /* 125 */
-   COMBA_FORWARD;
-   MULADD(at[62], at[127]);    MULADD(at[63], at[126]); 
-   COMBA_STORE(C->dp[125]);
-   /* 126 */
-   COMBA_FORWARD;
-   MULADD(at[63], at[127]); 
-   COMBA_STORE(C->dp[126]);
-   COMBA_STORE2(C->dp[127]);
-   C->used = 128;
-   C->sign = A->sign ^ B->sign;
-   fp_clamp(C);
-   COMBA_FINI;
-}
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_7.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_7.i
deleted file mode 100755
index eed8863..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_7.i
+++ /dev/null
@@ -1,90 +0,0 @@
-/* fp_mul_comba_7.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_MUL7
-void fp_mul_comba7(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[14];
-
-   memcpy(at, A->dp, 7 * sizeof(fp_digit));
-   memcpy(at+7, B->dp, 7 * sizeof(fp_digit));
-   COMBA_START;
-
-   COMBA_CLEAR;
-   /* 0 */
-   MULADD(at[0], at[7]); 
-   COMBA_STORE(C->dp[0]);
-   /* 1 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[8]);    MULADD(at[1], at[7]); 
-   COMBA_STORE(C->dp[1]);
-   /* 2 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[9]);    MULADD(at[1], at[8]);    MULADD(at[2], at[7]); 
-   COMBA_STORE(C->dp[2]);
-   /* 3 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[10]);    MULADD(at[1], at[9]);    MULADD(at[2], at[8]);    MULADD(at[3], at[7]); 
-   COMBA_STORE(C->dp[3]);
-   /* 4 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[11]);    MULADD(at[1], at[10]);    MULADD(at[2], at[9]);    MULADD(at[3], at[8]);    MULADD(at[4], at[7]); 
-   COMBA_STORE(C->dp[4]);
-   /* 5 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[12]);    MULADD(at[1], at[11]);    MULADD(at[2], at[10]);    MULADD(at[3], at[9]);    MULADD(at[4], at[8]);    MULADD(at[5], at[7]); 
-   COMBA_STORE(C->dp[5]);
-   /* 6 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[13]);    MULADD(at[1], at[12]);    MULADD(at[2], at[11]);    MULADD(at[3], at[10]);    MULADD(at[4], at[9]);    MULADD(at[5], at[8]);    MULADD(at[6], at[7]); 
-   COMBA_STORE(C->dp[6]);
-   /* 7 */
-   COMBA_FORWARD;
-   MULADD(at[1], at[13]);    MULADD(at[2], at[12]);    MULADD(at[3], at[11]);    MULADD(at[4], at[10]);    MULADD(at[5], at[9]);    MULADD(at[6], at[8]); 
-   COMBA_STORE(C->dp[7]);
-   /* 8 */
-   COMBA_FORWARD;
-   MULADD(at[2], at[13]);    MULADD(at[3], at[12]);    MULADD(at[4], at[11]);    MULADD(at[5], at[10]);    MULADD(at[6], at[9]); 
-   COMBA_STORE(C->dp[8]);
-   /* 9 */
-   COMBA_FORWARD;
-   MULADD(at[3], at[13]);    MULADD(at[4], at[12]);    MULADD(at[5], at[11]);    MULADD(at[6], at[10]); 
-   COMBA_STORE(C->dp[9]);
-   /* 10 */
-   COMBA_FORWARD;
-   MULADD(at[4], at[13]);    MULADD(at[5], at[12]);    MULADD(at[6], at[11]); 
-   COMBA_STORE(C->dp[10]);
-   /* 11 */
-   COMBA_FORWARD;
-   MULADD(at[5], at[13]);    MULADD(at[6], at[12]); 
-   COMBA_STORE(C->dp[11]);
-   /* 12 */
-   COMBA_FORWARD;
-   MULADD(at[6], at[13]); 
-   COMBA_STORE(C->dp[12]);
-   COMBA_STORE2(C->dp[13]);
-   C->used = 14;
-   C->sign = A->sign ^ B->sign;
-   fp_clamp(C);
-   COMBA_FINI;
-}
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_8.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_8.i
deleted file mode 100755
index fa578a8..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_8.i
+++ /dev/null
@@ -1,98 +0,0 @@
-/* fp_mul_comba_8.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_MUL8
-void fp_mul_comba8(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[16];
-
-   memcpy(at, A->dp, 8 * sizeof(fp_digit));
-   memcpy(at+8, B->dp, 8 * sizeof(fp_digit));
-   COMBA_START;
-
-   COMBA_CLEAR;
-   /* 0 */
-   MULADD(at[0], at[8]); 
-   COMBA_STORE(C->dp[0]);
-   /* 1 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[9]);    MULADD(at[1], at[8]); 
-   COMBA_STORE(C->dp[1]);
-   /* 2 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[10]);    MULADD(at[1], at[9]);    MULADD(at[2], at[8]); 
-   COMBA_STORE(C->dp[2]);
-   /* 3 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[11]);    MULADD(at[1], at[10]);    MULADD(at[2], at[9]);    MULADD(at[3], at[8]); 
-   COMBA_STORE(C->dp[3]);
-   /* 4 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[12]);    MULADD(at[1], at[11]);    MULADD(at[2], at[10]);    MULADD(at[3], at[9]);    MULADD(at[4], at[8]); 
-   COMBA_STORE(C->dp[4]);
-   /* 5 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[13]);    MULADD(at[1], at[12]);    MULADD(at[2], at[11]);    MULADD(at[3], at[10]);    MULADD(at[4], at[9]);    MULADD(at[5], at[8]); 
-   COMBA_STORE(C->dp[5]);
-   /* 6 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[14]);    MULADD(at[1], at[13]);    MULADD(at[2], at[12]);    MULADD(at[3], at[11]);    MULADD(at[4], at[10]);    MULADD(at[5], at[9]);    MULADD(at[6], at[8]); 
-   COMBA_STORE(C->dp[6]);
-   /* 7 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[15]);    MULADD(at[1], at[14]);    MULADD(at[2], at[13]);    MULADD(at[3], at[12]);    MULADD(at[4], at[11]);    MULADD(at[5], at[10]);    MULADD(at[6], at[9]);    MULADD(at[7], at[8]); 
-   COMBA_STORE(C->dp[7]);
-   /* 8 */
-   COMBA_FORWARD;
-   MULADD(at[1], at[15]);    MULADD(at[2], at[14]);    MULADD(at[3], at[13]);    MULADD(at[4], at[12]);    MULADD(at[5], at[11]);    MULADD(at[6], at[10]);    MULADD(at[7], at[9]); 
-   COMBA_STORE(C->dp[8]);
-   /* 9 */
-   COMBA_FORWARD;
-   MULADD(at[2], at[15]);    MULADD(at[3], at[14]);    MULADD(at[4], at[13]);    MULADD(at[5], at[12]);    MULADD(at[6], at[11]);    MULADD(at[7], at[10]); 
-   COMBA_STORE(C->dp[9]);
-   /* 10 */
-   COMBA_FORWARD;
-   MULADD(at[3], at[15]);    MULADD(at[4], at[14]);    MULADD(at[5], at[13]);    MULADD(at[6], at[12]);    MULADD(at[7], at[11]); 
-   COMBA_STORE(C->dp[10]);
-   /* 11 */
-   COMBA_FORWARD;
-   MULADD(at[4], at[15]);    MULADD(at[5], at[14]);    MULADD(at[6], at[13]);    MULADD(at[7], at[12]); 
-   COMBA_STORE(C->dp[11]);
-   /* 12 */
-   COMBA_FORWARD;
-   MULADD(at[5], at[15]);    MULADD(at[6], at[14]);    MULADD(at[7], at[13]); 
-   COMBA_STORE(C->dp[12]);
-   /* 13 */
-   COMBA_FORWARD;
-   MULADD(at[6], at[15]);    MULADD(at[7], at[14]); 
-   COMBA_STORE(C->dp[13]);
-   /* 14 */
-   COMBA_FORWARD;
-   MULADD(at[7], at[15]); 
-   COMBA_STORE(C->dp[14]);
-   COMBA_STORE2(C->dp[15]);
-   C->used = 16;
-   C->sign = A->sign ^ B->sign;
-   fp_clamp(C);
-   COMBA_FINI;
-}
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_9.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_9.i
deleted file mode 100755
index 755067f..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_9.i
+++ /dev/null
@@ -1,106 +0,0 @@
-/* fp_mul_comba_9.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_MUL9
-void fp_mul_comba9(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[18];
-
-   memcpy(at, A->dp, 9 * sizeof(fp_digit));
-   memcpy(at+9, B->dp, 9 * sizeof(fp_digit));
-   COMBA_START;
-
-   COMBA_CLEAR;
-   /* 0 */
-   MULADD(at[0], at[9]); 
-   COMBA_STORE(C->dp[0]);
-   /* 1 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[10]);    MULADD(at[1], at[9]); 
-   COMBA_STORE(C->dp[1]);
-   /* 2 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[11]);    MULADD(at[1], at[10]);    MULADD(at[2], at[9]); 
-   COMBA_STORE(C->dp[2]);
-   /* 3 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[12]);    MULADD(at[1], at[11]);    MULADD(at[2], at[10]);    MULADD(at[3], at[9]); 
-   COMBA_STORE(C->dp[3]);
-   /* 4 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[13]);    MULADD(at[1], at[12]);    MULADD(at[2], at[11]);    MULADD(at[3], at[10]);    MULADD(at[4], at[9]); 
-   COMBA_STORE(C->dp[4]);
-   /* 5 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[14]);    MULADD(at[1], at[13]);    MULADD(at[2], at[12]);    MULADD(at[3], at[11]);    MULADD(at[4], at[10]);    MULADD(at[5], at[9]); 
-   COMBA_STORE(C->dp[5]);
-   /* 6 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[15]);    MULADD(at[1], at[14]);    MULADD(at[2], at[13]);    MULADD(at[3], at[12]);    MULADD(at[4], at[11]);    MULADD(at[5], at[10]);    MULADD(at[6], at[9]); 
-   COMBA_STORE(C->dp[6]);
-   /* 7 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[16]);    MULADD(at[1], at[15]);    MULADD(at[2], at[14]);    MULADD(at[3], at[13]);    MULADD(at[4], at[12]);    MULADD(at[5], at[11]);    MULADD(at[6], at[10]);    MULADD(at[7], at[9]); 
-   COMBA_STORE(C->dp[7]);
-   /* 8 */
-   COMBA_FORWARD;
-   MULADD(at[0], at[17]);    MULADD(at[1], at[16]);    MULADD(at[2], at[15]);    MULADD(at[3], at[14]);    MULADD(at[4], at[13]);    MULADD(at[5], at[12]);    MULADD(at[6], at[11]);    MULADD(at[7], at[10]);    MULADD(at[8], at[9]); 
-   COMBA_STORE(C->dp[8]);
-   /* 9 */
-   COMBA_FORWARD;
-   MULADD(at[1], at[17]);    MULADD(at[2], at[16]);    MULADD(at[3], at[15]);    MULADD(at[4], at[14]);    MULADD(at[5], at[13]);    MULADD(at[6], at[12]);    MULADD(at[7], at[11]);    MULADD(at[8], at[10]); 
-   COMBA_STORE(C->dp[9]);
-   /* 10 */
-   COMBA_FORWARD;
-   MULADD(at[2], at[17]);    MULADD(at[3], at[16]);    MULADD(at[4], at[15]);    MULADD(at[5], at[14]);    MULADD(at[6], at[13]);    MULADD(at[7], at[12]);    MULADD(at[8], at[11]); 
-   COMBA_STORE(C->dp[10]);
-   /* 11 */
-   COMBA_FORWARD;
-   MULADD(at[3], at[17]);    MULADD(at[4], at[16]);    MULADD(at[5], at[15]);    MULADD(at[6], at[14]);    MULADD(at[7], at[13]);    MULADD(at[8], at[12]); 
-   COMBA_STORE(C->dp[11]);
-   /* 12 */
-   COMBA_FORWARD;
-   MULADD(at[4], at[17]);    MULADD(at[5], at[16]);    MULADD(at[6], at[15]);    MULADD(at[7], at[14]);    MULADD(at[8], at[13]); 
-   COMBA_STORE(C->dp[12]);
-   /* 13 */
-   COMBA_FORWARD;
-   MULADD(at[5], at[17]);    MULADD(at[6], at[16]);    MULADD(at[7], at[15]);    MULADD(at[8], at[14]); 
-   COMBA_STORE(C->dp[13]);
-   /* 14 */
-   COMBA_FORWARD;
-   MULADD(at[6], at[17]);    MULADD(at[7], at[16]);    MULADD(at[8], at[15]); 
-   COMBA_STORE(C->dp[14]);
-   /* 15 */
-   COMBA_FORWARD;
-   MULADD(at[7], at[17]);    MULADD(at[8], at[16]); 
-   COMBA_STORE(C->dp[15]);
-   /* 16 */
-   COMBA_FORWARD;
-   MULADD(at[8], at[17]); 
-   COMBA_STORE(C->dp[16]);
-   COMBA_STORE2(C->dp[17]);
-   C->used = 18;
-   C->sign = A->sign ^ B->sign;
-   fp_clamp(C);
-   COMBA_FINI;
-}
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_small_set.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_small_set.i
deleted file mode 100755
index deea593..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_mul_comba_small_set.i
+++ /dev/null
@@ -1,1250 +0,0 @@
-/* fp_mul_comba_small_set.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#if defined(TFM_SMALL_SET)
-void fp_mul_comba_small(fp_int *A, fp_int *B, fp_int *C)
-{
-   fp_digit c0, c1, c2, at[32];
-   switch (MAX(A->used, B->used)) { 
-
-   case 1:
-      memcpy(at, A->dp, 1 * sizeof(fp_digit));
-      memcpy(at+1, B->dp, 1 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[1]); 
-      COMBA_STORE(C->dp[0]);
-      COMBA_STORE2(C->dp[1]);
-      C->used = 2;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 2:
-      memcpy(at, A->dp, 2 * sizeof(fp_digit));
-      memcpy(at+2, B->dp, 2 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[2]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[3]);       MULADD(at[1], at[2]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[3]); 
-      COMBA_STORE(C->dp[2]);
-      COMBA_STORE2(C->dp[3]);
-      C->used = 4;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 3:
-      memcpy(at, A->dp, 3 * sizeof(fp_digit));
-      memcpy(at+3, B->dp, 3 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[3]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[4]);       MULADD(at[1], at[3]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[5]);       MULADD(at[1], at[4]);       MULADD(at[2], at[3]); 
-      COMBA_STORE(C->dp[2]);
-      /* 3 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[5]);       MULADD(at[2], at[4]); 
-      COMBA_STORE(C->dp[3]);
-      /* 4 */
-      COMBA_FORWARD;
-      MULADD(at[2], at[5]); 
-      COMBA_STORE(C->dp[4]);
-      COMBA_STORE2(C->dp[5]);
-      C->used = 6;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 4:
-      memcpy(at, A->dp, 4 * sizeof(fp_digit));
-      memcpy(at+4, B->dp, 4 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[4]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[5]);       MULADD(at[1], at[4]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[6]);       MULADD(at[1], at[5]);       MULADD(at[2], at[4]); 
-      COMBA_STORE(C->dp[2]);
-      /* 3 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[7]);       MULADD(at[1], at[6]);       MULADD(at[2], at[5]);       MULADD(at[3], at[4]); 
-      COMBA_STORE(C->dp[3]);
-      /* 4 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[7]);       MULADD(at[2], at[6]);       MULADD(at[3], at[5]); 
-      COMBA_STORE(C->dp[4]);
-      /* 5 */
-      COMBA_FORWARD;
-      MULADD(at[2], at[7]);       MULADD(at[3], at[6]); 
-      COMBA_STORE(C->dp[5]);
-      /* 6 */
-      COMBA_FORWARD;
-      MULADD(at[3], at[7]); 
-      COMBA_STORE(C->dp[6]);
-      COMBA_STORE2(C->dp[7]);
-      C->used = 8;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 5:
-      memcpy(at, A->dp, 5 * sizeof(fp_digit));
-      memcpy(at+5, B->dp, 5 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[5]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[6]);       MULADD(at[1], at[5]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[7]);       MULADD(at[1], at[6]);       MULADD(at[2], at[5]); 
-      COMBA_STORE(C->dp[2]);
-      /* 3 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[8]);       MULADD(at[1], at[7]);       MULADD(at[2], at[6]);       MULADD(at[3], at[5]); 
-      COMBA_STORE(C->dp[3]);
-      /* 4 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[9]);       MULADD(at[1], at[8]);       MULADD(at[2], at[7]);       MULADD(at[3], at[6]);       MULADD(at[4], at[5]); 
-      COMBA_STORE(C->dp[4]);
-      /* 5 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[9]);       MULADD(at[2], at[8]);       MULADD(at[3], at[7]);       MULADD(at[4], at[6]); 
-      COMBA_STORE(C->dp[5]);
-      /* 6 */
-      COMBA_FORWARD;
-      MULADD(at[2], at[9]);       MULADD(at[3], at[8]);       MULADD(at[4], at[7]); 
-      COMBA_STORE(C->dp[6]);
-      /* 7 */
-      COMBA_FORWARD;
-      MULADD(at[3], at[9]);       MULADD(at[4], at[8]); 
-      COMBA_STORE(C->dp[7]);
-      /* 8 */
-      COMBA_FORWARD;
-      MULADD(at[4], at[9]); 
-      COMBA_STORE(C->dp[8]);
-      COMBA_STORE2(C->dp[9]);
-      C->used = 10;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 6:
-      memcpy(at, A->dp, 6 * sizeof(fp_digit));
-      memcpy(at+6, B->dp, 6 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[6]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[7]);       MULADD(at[1], at[6]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[8]);       MULADD(at[1], at[7]);       MULADD(at[2], at[6]); 
-      COMBA_STORE(C->dp[2]);
-      /* 3 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[9]);       MULADD(at[1], at[8]);       MULADD(at[2], at[7]);       MULADD(at[3], at[6]); 
-      COMBA_STORE(C->dp[3]);
-      /* 4 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[10]);       MULADD(at[1], at[9]);       MULADD(at[2], at[8]);       MULADD(at[3], at[7]);       MULADD(at[4], at[6]); 
-      COMBA_STORE(C->dp[4]);
-      /* 5 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[11]);       MULADD(at[1], at[10]);       MULADD(at[2], at[9]);       MULADD(at[3], at[8]);       MULADD(at[4], at[7]);       MULADD(at[5], at[6]); 
-      COMBA_STORE(C->dp[5]);
-      /* 6 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[11]);       MULADD(at[2], at[10]);       MULADD(at[3], at[9]);       MULADD(at[4], at[8]);       MULADD(at[5], at[7]); 
-      COMBA_STORE(C->dp[6]);
-      /* 7 */
-      COMBA_FORWARD;
-      MULADD(at[2], at[11]);       MULADD(at[3], at[10]);       MULADD(at[4], at[9]);       MULADD(at[5], at[8]); 
-      COMBA_STORE(C->dp[7]);
-      /* 8 */
-      COMBA_FORWARD;
-      MULADD(at[3], at[11]);       MULADD(at[4], at[10]);       MULADD(at[5], at[9]); 
-      COMBA_STORE(C->dp[8]);
-      /* 9 */
-      COMBA_FORWARD;
-      MULADD(at[4], at[11]);       MULADD(at[5], at[10]); 
-      COMBA_STORE(C->dp[9]);
-      /* 10 */
-      COMBA_FORWARD;
-      MULADD(at[5], at[11]); 
-      COMBA_STORE(C->dp[10]);
-      COMBA_STORE2(C->dp[11]);
-      C->used = 12;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 7:
-      memcpy(at, A->dp, 7 * sizeof(fp_digit));
-      memcpy(at+7, B->dp, 7 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[7]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[8]);       MULADD(at[1], at[7]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[9]);       MULADD(at[1], at[8]);       MULADD(at[2], at[7]); 
-      COMBA_STORE(C->dp[2]);
-      /* 3 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[10]);       MULADD(at[1], at[9]);       MULADD(at[2], at[8]);       MULADD(at[3], at[7]); 
-      COMBA_STORE(C->dp[3]);
-      /* 4 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[11]);       MULADD(at[1], at[10]);       MULADD(at[2], at[9]);       MULADD(at[3], at[8]);       MULADD(at[4], at[7]); 
-      COMBA_STORE(C->dp[4]);
-      /* 5 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[12]);       MULADD(at[1], at[11]);       MULADD(at[2], at[10]);       MULADD(at[3], at[9]);       MULADD(at[4], at[8]);       MULADD(at[5], at[7]); 
-      COMBA_STORE(C->dp[5]);
-      /* 6 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[13]);       MULADD(at[1], at[12]);       MULADD(at[2], at[11]);       MULADD(at[3], at[10]);       MULADD(at[4], at[9]);       MULADD(at[5], at[8]);       MULADD(at[6], at[7]); 
-      COMBA_STORE(C->dp[6]);
-      /* 7 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[13]);       MULADD(at[2], at[12]);       MULADD(at[3], at[11]);       MULADD(at[4], at[10]);       MULADD(at[5], at[9]);       MULADD(at[6], at[8]); 
-      COMBA_STORE(C->dp[7]);
-      /* 8 */
-      COMBA_FORWARD;
-      MULADD(at[2], at[13]);       MULADD(at[3], at[12]);       MULADD(at[4], at[11]);       MULADD(at[5], at[10]);       MULADD(at[6], at[9]); 
-      COMBA_STORE(C->dp[8]);
-      /* 9 */
-      COMBA_FORWARD;
-      MULADD(at[3], at[13]);       MULADD(at[4], at[12]);       MULADD(at[5], at[11]);       MULADD(at[6], at[10]); 
-      COMBA_STORE(C->dp[9]);
-      /* 10 */
-      COMBA_FORWARD;
-      MULADD(at[4], at[13]);       MULADD(at[5], at[12]);       MULADD(at[6], at[11]); 
-      COMBA_STORE(C->dp[10]);
-      /* 11 */
-      COMBA_FORWARD;
-      MULADD(at[5], at[13]);       MULADD(at[6], at[12]); 
-      COMBA_STORE(C->dp[11]);
-      /* 12 */
-      COMBA_FORWARD;
-      MULADD(at[6], at[13]); 
-      COMBA_STORE(C->dp[12]);
-      COMBA_STORE2(C->dp[13]);
-      C->used = 14;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 8:
-      memcpy(at, A->dp, 8 * sizeof(fp_digit));
-      memcpy(at+8, B->dp, 8 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[8]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[9]);       MULADD(at[1], at[8]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[10]);       MULADD(at[1], at[9]);       MULADD(at[2], at[8]); 
-      COMBA_STORE(C->dp[2]);
-      /* 3 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[11]);       MULADD(at[1], at[10]);       MULADD(at[2], at[9]);       MULADD(at[3], at[8]); 
-      COMBA_STORE(C->dp[3]);
-      /* 4 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[12]);       MULADD(at[1], at[11]);       MULADD(at[2], at[10]);       MULADD(at[3], at[9]);       MULADD(at[4], at[8]); 
-      COMBA_STORE(C->dp[4]);
-      /* 5 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[13]);       MULADD(at[1], at[12]);       MULADD(at[2], at[11]);       MULADD(at[3], at[10]);       MULADD(at[4], at[9]);       MULADD(at[5], at[8]); 
-      COMBA_STORE(C->dp[5]);
-      /* 6 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[14]);       MULADD(at[1], at[13]);       MULADD(at[2], at[12]);       MULADD(at[3], at[11]);       MULADD(at[4], at[10]);       MULADD(at[5], at[9]);       MULADD(at[6], at[8]); 
-      COMBA_STORE(C->dp[6]);
-      /* 7 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[15]);       MULADD(at[1], at[14]);       MULADD(at[2], at[13]);       MULADD(at[3], at[12]);       MULADD(at[4], at[11]);       MULADD(at[5], at[10]);       MULADD(at[6], at[9]);       MULADD(at[7], at[8]); 
-      COMBA_STORE(C->dp[7]);
-      /* 8 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[15]);       MULADD(at[2], at[14]);       MULADD(at[3], at[13]);       MULADD(at[4], at[12]);       MULADD(at[5], at[11]);       MULADD(at[6], at[10]);       MULADD(at[7], at[9]); 
-      COMBA_STORE(C->dp[8]);
-      /* 9 */
-      COMBA_FORWARD;
-      MULADD(at[2], at[15]);       MULADD(at[3], at[14]);       MULADD(at[4], at[13]);       MULADD(at[5], at[12]);       MULADD(at[6], at[11]);       MULADD(at[7], at[10]); 
-      COMBA_STORE(C->dp[9]);
-      /* 10 */
-      COMBA_FORWARD;
-      MULADD(at[3], at[15]);       MULADD(at[4], at[14]);       MULADD(at[5], at[13]);       MULADD(at[6], at[12]);       MULADD(at[7], at[11]); 
-      COMBA_STORE(C->dp[10]);
-      /* 11 */
-      COMBA_FORWARD;
-      MULADD(at[4], at[15]);       MULADD(at[5], at[14]);       MULADD(at[6], at[13]);       MULADD(at[7], at[12]); 
-      COMBA_STORE(C->dp[11]);
-      /* 12 */
-      COMBA_FORWARD;
-      MULADD(at[5], at[15]);       MULADD(at[6], at[14]);       MULADD(at[7], at[13]); 
-      COMBA_STORE(C->dp[12]);
-      /* 13 */
-      COMBA_FORWARD;
-      MULADD(at[6], at[15]);       MULADD(at[7], at[14]); 
-      COMBA_STORE(C->dp[13]);
-      /* 14 */
-      COMBA_FORWARD;
-      MULADD(at[7], at[15]); 
-      COMBA_STORE(C->dp[14]);
-      COMBA_STORE2(C->dp[15]);
-      C->used = 16;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 9:
-      memcpy(at, A->dp, 9 * sizeof(fp_digit));
-      memcpy(at+9, B->dp, 9 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[9]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[10]);       MULADD(at[1], at[9]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[11]);       MULADD(at[1], at[10]);       MULADD(at[2], at[9]); 
-      COMBA_STORE(C->dp[2]);
-      /* 3 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[12]);       MULADD(at[1], at[11]);       MULADD(at[2], at[10]);       MULADD(at[3], at[9]); 
-      COMBA_STORE(C->dp[3]);
-      /* 4 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[13]);       MULADD(at[1], at[12]);       MULADD(at[2], at[11]);       MULADD(at[3], at[10]);       MULADD(at[4], at[9]); 
-      COMBA_STORE(C->dp[4]);
-      /* 5 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[14]);       MULADD(at[1], at[13]);       MULADD(at[2], at[12]);       MULADD(at[3], at[11]);       MULADD(at[4], at[10]);       MULADD(at[5], at[9]); 
-      COMBA_STORE(C->dp[5]);
-      /* 6 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[15]);       MULADD(at[1], at[14]);       MULADD(at[2], at[13]);       MULADD(at[3], at[12]);       MULADD(at[4], at[11]);       MULADD(at[5], at[10]);       MULADD(at[6], at[9]); 
-      COMBA_STORE(C->dp[6]);
-      /* 7 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[16]);       MULADD(at[1], at[15]);       MULADD(at[2], at[14]);       MULADD(at[3], at[13]);       MULADD(at[4], at[12]);       MULADD(at[5], at[11]);       MULADD(at[6], at[10]);       MULADD(at[7], at[9]); 
-      COMBA_STORE(C->dp[7]);
-      /* 8 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[17]);       MULADD(at[1], at[16]);       MULADD(at[2], at[15]);       MULADD(at[3], at[14]);       MULADD(at[4], at[13]);       MULADD(at[5], at[12]);       MULADD(at[6], at[11]);       MULADD(at[7], at[10]);       MULADD(at[8], at[9]); 
-      COMBA_STORE(C->dp[8]);
-      /* 9 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[17]);       MULADD(at[2], at[16]);       MULADD(at[3], at[15]);       MULADD(at[4], at[14]);       MULADD(at[5], at[13]);       MULADD(at[6], at[12]);       MULADD(at[7], at[11]);       MULADD(at[8], at[10]); 
-      COMBA_STORE(C->dp[9]);
-      /* 10 */
-      COMBA_FORWARD;
-      MULADD(at[2], at[17]);       MULADD(at[3], at[16]);       MULADD(at[4], at[15]);       MULADD(at[5], at[14]);       MULADD(at[6], at[13]);       MULADD(at[7], at[12]);       MULADD(at[8], at[11]); 
-      COMBA_STORE(C->dp[10]);
-      /* 11 */
-      COMBA_FORWARD;
-      MULADD(at[3], at[17]);       MULADD(at[4], at[16]);       MULADD(at[5], at[15]);       MULADD(at[6], at[14]);       MULADD(at[7], at[13]);       MULADD(at[8], at[12]); 
-      COMBA_STORE(C->dp[11]);
-      /* 12 */
-      COMBA_FORWARD;
-      MULADD(at[4], at[17]);       MULADD(at[5], at[16]);       MULADD(at[6], at[15]);       MULADD(at[7], at[14]);       MULADD(at[8], at[13]); 
-      COMBA_STORE(C->dp[12]);
-      /* 13 */
-      COMBA_FORWARD;
-      MULADD(at[5], at[17]);       MULADD(at[6], at[16]);       MULADD(at[7], at[15]);       MULADD(at[8], at[14]); 
-      COMBA_STORE(C->dp[13]);
-      /* 14 */
-      COMBA_FORWARD;
-      MULADD(at[6], at[17]);       MULADD(at[7], at[16]);       MULADD(at[8], at[15]); 
-      COMBA_STORE(C->dp[14]);
-      /* 15 */
-      COMBA_FORWARD;
-      MULADD(at[7], at[17]);       MULADD(at[8], at[16]); 
-      COMBA_STORE(C->dp[15]);
-      /* 16 */
-      COMBA_FORWARD;
-      MULADD(at[8], at[17]); 
-      COMBA_STORE(C->dp[16]);
-      COMBA_STORE2(C->dp[17]);
-      C->used = 18;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 10:
-      memcpy(at, A->dp, 10 * sizeof(fp_digit));
-      memcpy(at+10, B->dp, 10 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[10]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[11]);       MULADD(at[1], at[10]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[12]);       MULADD(at[1], at[11]);       MULADD(at[2], at[10]); 
-      COMBA_STORE(C->dp[2]);
-      /* 3 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[13]);       MULADD(at[1], at[12]);       MULADD(at[2], at[11]);       MULADD(at[3], at[10]); 
-      COMBA_STORE(C->dp[3]);
-      /* 4 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[14]);       MULADD(at[1], at[13]);       MULADD(at[2], at[12]);       MULADD(at[3], at[11]);       MULADD(at[4], at[10]); 
-      COMBA_STORE(C->dp[4]);
-      /* 5 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[15]);       MULADD(at[1], at[14]);       MULADD(at[2], at[13]);       MULADD(at[3], at[12]);       MULADD(at[4], at[11]);       MULADD(at[5], at[10]); 
-      COMBA_STORE(C->dp[5]);
-      /* 6 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[16]);       MULADD(at[1], at[15]);       MULADD(at[2], at[14]);       MULADD(at[3], at[13]);       MULADD(at[4], at[12]);       MULADD(at[5], at[11]);       MULADD(at[6], at[10]); 
-      COMBA_STORE(C->dp[6]);
-      /* 7 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[17]);       MULADD(at[1], at[16]);       MULADD(at[2], at[15]);       MULADD(at[3], at[14]);       MULADD(at[4], at[13]);       MULADD(at[5], at[12]);       MULADD(at[6], at[11]);       MULADD(at[7], at[10]); 
-      COMBA_STORE(C->dp[7]);
-      /* 8 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[18]);       MULADD(at[1], at[17]);       MULADD(at[2], at[16]);       MULADD(at[3], at[15]);       MULADD(at[4], at[14]);       MULADD(at[5], at[13]);       MULADD(at[6], at[12]);       MULADD(at[7], at[11]);       MULADD(at[8], at[10]); 
-      COMBA_STORE(C->dp[8]);
-      /* 9 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[19]);       MULADD(at[1], at[18]);       MULADD(at[2], at[17]);       MULADD(at[3], at[16]);       MULADD(at[4], at[15]);       MULADD(at[5], at[14]);       MULADD(at[6], at[13]);       MULADD(at[7], at[12]);       MULADD(at[8], at[11]);       MULADD(at[9], at[10]); 
-      COMBA_STORE(C->dp[9]);
-      /* 10 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[19]);       MULADD(at[2], at[18]);       MULADD(at[3], at[17]);       MULADD(at[4], at[16]);       MULADD(at[5], at[15]);       MULADD(at[6], at[14]);       MULADD(at[7], at[13]);       MULADD(at[8], at[12]);       MULADD(at[9], at[11]); 
-      COMBA_STORE(C->dp[10]);
-      /* 11 */
-      COMBA_FORWARD;
-      MULADD(at[2], at[19]);       MULADD(at[3], at[18]);       MULADD(at[4], at[17]);       MULADD(at[5], at[16]);       MULADD(at[6], at[15]);       MULADD(at[7], at[14]);       MULADD(at[8], at[13]);       MULADD(at[9], at[12]); 
-      COMBA_STORE(C->dp[11]);
-      /* 12 */
-      COMBA_FORWARD;
-      MULADD(at[3], at[19]);       MULADD(at[4], at[18]);       MULADD(at[5], at[17]);       MULADD(at[6], at[16]);       MULADD(at[7], at[15]);       MULADD(at[8], at[14]);       MULADD(at[9], at[13]); 
-      COMBA_STORE(C->dp[12]);
-      /* 13 */
-      COMBA_FORWARD;
-      MULADD(at[4], at[19]);       MULADD(at[5], at[18]);       MULADD(at[6], at[17]);       MULADD(at[7], at[16]);       MULADD(at[8], at[15]);       MULADD(at[9], at[14]); 
-      COMBA_STORE(C->dp[13]);
-      /* 14 */
-      COMBA_FORWARD;
-      MULADD(at[5], at[19]);       MULADD(at[6], at[18]);       MULADD(at[7], at[17]);       MULADD(at[8], at[16]);       MULADD(at[9], at[15]); 
-      COMBA_STORE(C->dp[14]);
-      /* 15 */
-      COMBA_FORWARD;
-      MULADD(at[6], at[19]);       MULADD(at[7], at[18]);       MULADD(at[8], at[17]);       MULADD(at[9], at[16]); 
-      COMBA_STORE(C->dp[15]);
-      /* 16 */
-      COMBA_FORWARD;
-      MULADD(at[7], at[19]);       MULADD(at[8], at[18]);       MULADD(at[9], at[17]); 
-      COMBA_STORE(C->dp[16]);
-      /* 17 */
-      COMBA_FORWARD;
-      MULADD(at[8], at[19]);       MULADD(at[9], at[18]); 
-      COMBA_STORE(C->dp[17]);
-      /* 18 */
-      COMBA_FORWARD;
-      MULADD(at[9], at[19]); 
-      COMBA_STORE(C->dp[18]);
-      COMBA_STORE2(C->dp[19]);
-      C->used = 20;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 11:
-      memcpy(at, A->dp, 11 * sizeof(fp_digit));
-      memcpy(at+11, B->dp, 11 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[11]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[12]);       MULADD(at[1], at[11]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[13]);       MULADD(at[1], at[12]);       MULADD(at[2], at[11]); 
-      COMBA_STORE(C->dp[2]);
-      /* 3 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[14]);       MULADD(at[1], at[13]);       MULADD(at[2], at[12]);       MULADD(at[3], at[11]); 
-      COMBA_STORE(C->dp[3]);
-      /* 4 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[15]);       MULADD(at[1], at[14]);       MULADD(at[2], at[13]);       MULADD(at[3], at[12]);       MULADD(at[4], at[11]); 
-      COMBA_STORE(C->dp[4]);
-      /* 5 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[16]);       MULADD(at[1], at[15]);       MULADD(at[2], at[14]);       MULADD(at[3], at[13]);       MULADD(at[4], at[12]);       MULADD(at[5], at[11]); 
-      COMBA_STORE(C->dp[5]);
-      /* 6 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[17]);       MULADD(at[1], at[16]);       MULADD(at[2], at[15]);       MULADD(at[3], at[14]);       MULADD(at[4], at[13]);       MULADD(at[5], at[12]);       MULADD(at[6], at[11]); 
-      COMBA_STORE(C->dp[6]);
-      /* 7 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[18]);       MULADD(at[1], at[17]);       MULADD(at[2], at[16]);       MULADD(at[3], at[15]);       MULADD(at[4], at[14]);       MULADD(at[5], at[13]);       MULADD(at[6], at[12]);       MULADD(at[7], at[11]); 
-      COMBA_STORE(C->dp[7]);
-      /* 8 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[19]);       MULADD(at[1], at[18]);       MULADD(at[2], at[17]);       MULADD(at[3], at[16]);       MULADD(at[4], at[15]);       MULADD(at[5], at[14]);       MULADD(at[6], at[13]);       MULADD(at[7], at[12]);       MULADD(at[8], at[11]); 
-      COMBA_STORE(C->dp[8]);
-      /* 9 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[20]);       MULADD(at[1], at[19]);       MULADD(at[2], at[18]);       MULADD(at[3], at[17]);       MULADD(at[4], at[16]);       MULADD(at[5], at[15]);       MULADD(at[6], at[14]);       MULADD(at[7], at[13]);       MULADD(at[8], at[12]);       MULADD(at[9], at[11]); 
-      COMBA_STORE(C->dp[9]);
-      /* 10 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[21]);       MULADD(at[1], at[20]);       MULADD(at[2], at[19]);       MULADD(at[3], at[18]);       MULADD(at[4], at[17]);       MULADD(at[5], at[16]);       MULADD(at[6], at[15]);       MULADD(at[7], at[14]);       MULADD(at[8], at[13]);       MULADD(at[9], at[12]);       MULADD(at[10], at[11]); 
-      COMBA_STORE(C->dp[10]);
-      /* 11 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[21]);       MULADD(at[2], at[20]);       MULADD(at[3], at[19]);       MULADD(at[4], at[18]);       MULADD(at[5], at[17]);       MULADD(at[6], at[16]);       MULADD(at[7], at[15]);       MULADD(at[8], at[14]);       MULADD(at[9], at[13]);       MULADD(at[10], at[12]); 
-      COMBA_STORE(C->dp[11]);
-      /* 12 */
-      COMBA_FORWARD;
-      MULADD(at[2], at[21]);       MULADD(at[3], at[20]);       MULADD(at[4], at[19]);       MULADD(at[5], at[18]);       MULADD(at[6], at[17]);       MULADD(at[7], at[16]);       MULADD(at[8], at[15]);       MULADD(at[9], at[14]);       MULADD(at[10], at[13]); 
-      COMBA_STORE(C->dp[12]);
-      /* 13 */
-      COMBA_FORWARD;
-      MULADD(at[3], at[21]);       MULADD(at[4], at[20]);       MULADD(at[5], at[19]);       MULADD(at[6], at[18]);       MULADD(at[7], at[17]);       MULADD(at[8], at[16]);       MULADD(at[9], at[15]);       MULADD(at[10], at[14]); 
-      COMBA_STORE(C->dp[13]);
-      /* 14 */
-      COMBA_FORWARD;
-      MULADD(at[4], at[21]);       MULADD(at[5], at[20]);       MULADD(at[6], at[19]);       MULADD(at[7], at[18]);       MULADD(at[8], at[17]);       MULADD(at[9], at[16]);       MULADD(at[10], at[15]); 
-      COMBA_STORE(C->dp[14]);
-      /* 15 */
-      COMBA_FORWARD;
-      MULADD(at[5], at[21]);       MULADD(at[6], at[20]);       MULADD(at[7], at[19]);       MULADD(at[8], at[18]);       MULADD(at[9], at[17]);       MULADD(at[10], at[16]); 
-      COMBA_STORE(C->dp[15]);
-      /* 16 */
-      COMBA_FORWARD;
-      MULADD(at[6], at[21]);       MULADD(at[7], at[20]);       MULADD(at[8], at[19]);       MULADD(at[9], at[18]);       MULADD(at[10], at[17]); 
-      COMBA_STORE(C->dp[16]);
-      /* 17 */
-      COMBA_FORWARD;
-      MULADD(at[7], at[21]);       MULADD(at[8], at[20]);       MULADD(at[9], at[19]);       MULADD(at[10], at[18]); 
-      COMBA_STORE(C->dp[17]);
-      /* 18 */
-      COMBA_FORWARD;
-      MULADD(at[8], at[21]);       MULADD(at[9], at[20]);       MULADD(at[10], at[19]); 
-      COMBA_STORE(C->dp[18]);
-      /* 19 */
-      COMBA_FORWARD;
-      MULADD(at[9], at[21]);       MULADD(at[10], at[20]); 
-      COMBA_STORE(C->dp[19]);
-      /* 20 */
-      COMBA_FORWARD;
-      MULADD(at[10], at[21]); 
-      COMBA_STORE(C->dp[20]);
-      COMBA_STORE2(C->dp[21]);
-      C->used = 22;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 12:
-      memcpy(at, A->dp, 12 * sizeof(fp_digit));
-      memcpy(at+12, B->dp, 12 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[12]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[13]);       MULADD(at[1], at[12]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[14]);       MULADD(at[1], at[13]);       MULADD(at[2], at[12]); 
-      COMBA_STORE(C->dp[2]);
-      /* 3 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[15]);       MULADD(at[1], at[14]);       MULADD(at[2], at[13]);       MULADD(at[3], at[12]); 
-      COMBA_STORE(C->dp[3]);
-      /* 4 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[16]);       MULADD(at[1], at[15]);       MULADD(at[2], at[14]);       MULADD(at[3], at[13]);       MULADD(at[4], at[12]); 
-      COMBA_STORE(C->dp[4]);
-      /* 5 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[17]);       MULADD(at[1], at[16]);       MULADD(at[2], at[15]);       MULADD(at[3], at[14]);       MULADD(at[4], at[13]);       MULADD(at[5], at[12]); 
-      COMBA_STORE(C->dp[5]);
-      /* 6 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[18]);       MULADD(at[1], at[17]);       MULADD(at[2], at[16]);       MULADD(at[3], at[15]);       MULADD(at[4], at[14]);       MULADD(at[5], at[13]);       MULADD(at[6], at[12]); 
-      COMBA_STORE(C->dp[6]);
-      /* 7 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[19]);       MULADD(at[1], at[18]);       MULADD(at[2], at[17]);       MULADD(at[3], at[16]);       MULADD(at[4], at[15]);       MULADD(at[5], at[14]);       MULADD(at[6], at[13]);       MULADD(at[7], at[12]); 
-      COMBA_STORE(C->dp[7]);
-      /* 8 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[20]);       MULADD(at[1], at[19]);       MULADD(at[2], at[18]);       MULADD(at[3], at[17]);       MULADD(at[4], at[16]);       MULADD(at[5], at[15]);       MULADD(at[6], at[14]);       MULADD(at[7], at[13]);       MULADD(at[8], at[12]); 
-      COMBA_STORE(C->dp[8]);
-      /* 9 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[21]);       MULADD(at[1], at[20]);       MULADD(at[2], at[19]);       MULADD(at[3], at[18]);       MULADD(at[4], at[17]);       MULADD(at[5], at[16]);       MULADD(at[6], at[15]);       MULADD(at[7], at[14]);       MULADD(at[8], at[13]);       MULADD(at[9], at[12]); 
-      COMBA_STORE(C->dp[9]);
-      /* 10 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[22]);       MULADD(at[1], at[21]);       MULADD(at[2], at[20]);       MULADD(at[3], at[19]);       MULADD(at[4], at[18]);       MULADD(at[5], at[17]);       MULADD(at[6], at[16]);       MULADD(at[7], at[15]);       MULADD(at[8], at[14]);       MULADD(at[9], at[13]);       MULADD(at[10], at[12]); 
-      COMBA_STORE(C->dp[10]);
-      /* 11 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[23]);       MULADD(at[1], at[22]);       MULADD(at[2], at[21]);       MULADD(at[3], at[20]);       MULADD(at[4], at[19]);       MULADD(at[5], at[18]);       MULADD(at[6], at[17]);       MULADD(at[7], at[16]);       MULADD(at[8], at[15]);       MULADD(at[9], at[14]);       MULADD(at[10], at[13]);       MULADD(at[11], at[12]); 
-      COMBA_STORE(C->dp[11]);
-      /* 12 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[23]);       MULADD(at[2], at[22]);       MULADD(at[3], at[21]);       MULADD(at[4], at[20]);       MULADD(at[5], at[19]);       MULADD(at[6], at[18]);       MULADD(at[7], at[17]);       MULADD(at[8], at[16]);       MULADD(at[9], at[15]);       MULADD(at[10], at[14]);       MULADD(at[11], at[13]); 
-      COMBA_STORE(C->dp[12]);
-      /* 13 */
-      COMBA_FORWARD;
-      MULADD(at[2], at[23]);       MULADD(at[3], at[22]);       MULADD(at[4], at[21]);       MULADD(at[5], at[20]);       MULADD(at[6], at[19]);       MULADD(at[7], at[18]);       MULADD(at[8], at[17]);       MULADD(at[9], at[16]);       MULADD(at[10], at[15]);       MULADD(at[11], at[14]); 
-      COMBA_STORE(C->dp[13]);
-      /* 14 */
-      COMBA_FORWARD;
-      MULADD(at[3], at[23]);       MULADD(at[4], at[22]);       MULADD(at[5], at[21]);       MULADD(at[6], at[20]);       MULADD(at[7], at[19]);       MULADD(at[8], at[18]);       MULADD(at[9], at[17]);       MULADD(at[10], at[16]);       MULADD(at[11], at[15]); 
-      COMBA_STORE(C->dp[14]);
-      /* 15 */
-      COMBA_FORWARD;
-      MULADD(at[4], at[23]);       MULADD(at[5], at[22]);       MULADD(at[6], at[21]);       MULADD(at[7], at[20]);       MULADD(at[8], at[19]);       MULADD(at[9], at[18]);       MULADD(at[10], at[17]);       MULADD(at[11], at[16]); 
-      COMBA_STORE(C->dp[15]);
-      /* 16 */
-      COMBA_FORWARD;
-      MULADD(at[5], at[23]);       MULADD(at[6], at[22]);       MULADD(at[7], at[21]);       MULADD(at[8], at[20]);       MULADD(at[9], at[19]);       MULADD(at[10], at[18]);       MULADD(at[11], at[17]); 
-      COMBA_STORE(C->dp[16]);
-      /* 17 */
-      COMBA_FORWARD;
-      MULADD(at[6], at[23]);       MULADD(at[7], at[22]);       MULADD(at[8], at[21]);       MULADD(at[9], at[20]);       MULADD(at[10], at[19]);       MULADD(at[11], at[18]); 
-      COMBA_STORE(C->dp[17]);
-      /* 18 */
-      COMBA_FORWARD;
-      MULADD(at[7], at[23]);       MULADD(at[8], at[22]);       MULADD(at[9], at[21]);       MULADD(at[10], at[20]);       MULADD(at[11], at[19]); 
-      COMBA_STORE(C->dp[18]);
-      /* 19 */
-      COMBA_FORWARD;
-      MULADD(at[8], at[23]);       MULADD(at[9], at[22]);       MULADD(at[10], at[21]);       MULADD(at[11], at[20]); 
-      COMBA_STORE(C->dp[19]);
-      /* 20 */
-      COMBA_FORWARD;
-      MULADD(at[9], at[23]);       MULADD(at[10], at[22]);       MULADD(at[11], at[21]); 
-      COMBA_STORE(C->dp[20]);
-      /* 21 */
-      COMBA_FORWARD;
-      MULADD(at[10], at[23]);       MULADD(at[11], at[22]); 
-      COMBA_STORE(C->dp[21]);
-      /* 22 */
-      COMBA_FORWARD;
-      MULADD(at[11], at[23]); 
-      COMBA_STORE(C->dp[22]);
-      COMBA_STORE2(C->dp[23]);
-      C->used = 24;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 13:
-      memcpy(at, A->dp, 13 * sizeof(fp_digit));
-      memcpy(at+13, B->dp, 13 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[13]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[14]);       MULADD(at[1], at[13]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[15]);       MULADD(at[1], at[14]);       MULADD(at[2], at[13]); 
-      COMBA_STORE(C->dp[2]);
-      /* 3 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[16]);       MULADD(at[1], at[15]);       MULADD(at[2], at[14]);       MULADD(at[3], at[13]); 
-      COMBA_STORE(C->dp[3]);
-      /* 4 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[17]);       MULADD(at[1], at[16]);       MULADD(at[2], at[15]);       MULADD(at[3], at[14]);       MULADD(at[4], at[13]); 
-      COMBA_STORE(C->dp[4]);
-      /* 5 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[18]);       MULADD(at[1], at[17]);       MULADD(at[2], at[16]);       MULADD(at[3], at[15]);       MULADD(at[4], at[14]);       MULADD(at[5], at[13]); 
-      COMBA_STORE(C->dp[5]);
-      /* 6 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[19]);       MULADD(at[1], at[18]);       MULADD(at[2], at[17]);       MULADD(at[3], at[16]);       MULADD(at[4], at[15]);       MULADD(at[5], at[14]);       MULADD(at[6], at[13]); 
-      COMBA_STORE(C->dp[6]);
-      /* 7 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[20]);       MULADD(at[1], at[19]);       MULADD(at[2], at[18]);       MULADD(at[3], at[17]);       MULADD(at[4], at[16]);       MULADD(at[5], at[15]);       MULADD(at[6], at[14]);       MULADD(at[7], at[13]); 
-      COMBA_STORE(C->dp[7]);
-      /* 8 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[21]);       MULADD(at[1], at[20]);       MULADD(at[2], at[19]);       MULADD(at[3], at[18]);       MULADD(at[4], at[17]);       MULADD(at[5], at[16]);       MULADD(at[6], at[15]);       MULADD(at[7], at[14]);       MULADD(at[8], at[13]); 
-      COMBA_STORE(C->dp[8]);
-      /* 9 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[22]);       MULADD(at[1], at[21]);       MULADD(at[2], at[20]);       MULADD(at[3], at[19]);       MULADD(at[4], at[18]);       MULADD(at[5], at[17]);       MULADD(at[6], at[16]);       MULADD(at[7], at[15]);       MULADD(at[8], at[14]);       MULADD(at[9], at[13]); 
-      COMBA_STORE(C->dp[9]);
-      /* 10 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[23]);       MULADD(at[1], at[22]);       MULADD(at[2], at[21]);       MULADD(at[3], at[20]);       MULADD(at[4], at[19]);       MULADD(at[5], at[18]);       MULADD(at[6], at[17]);       MULADD(at[7], at[16]);       MULADD(at[8], at[15]);       MULADD(at[9], at[14]);       MULADD(at[10], at[13]); 
-      COMBA_STORE(C->dp[10]);
-      /* 11 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[24]);       MULADD(at[1], at[23]);       MULADD(at[2], at[22]);       MULADD(at[3], at[21]);       MULADD(at[4], at[20]);       MULADD(at[5], at[19]);       MULADD(at[6], at[18]);       MULADD(at[7], at[17]);       MULADD(at[8], at[16]);       MULADD(at[9], at[15]);       MULADD(at[10], at[14]);       MULADD(at[11], at[13]); 
-      COMBA_STORE(C->dp[11]);
-      /* 12 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[25]);       MULADD(at[1], at[24]);       MULADD(at[2], at[23]);       MULADD(at[3], at[22]);       MULADD(at[4], at[21]);       MULADD(at[5], at[20]);       MULADD(at[6], at[19]);       MULADD(at[7], at[18]);       MULADD(at[8], at[17]);       MULADD(at[9], at[16]);       MULADD(at[10], at[15]);       MULADD(at[11], at[14]);       MULADD(at[12], at[13]); 
-      COMBA_STORE(C->dp[12]);
-      /* 13 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[25]);       MULADD(at[2], at[24]);       MULADD(at[3], at[23]);       MULADD(at[4], at[22]);       MULADD(at[5], at[21]);       MULADD(at[6], at[20]);       MULADD(at[7], at[19]);       MULADD(at[8], at[18]);       MULADD(at[9], at[17]);       MULADD(at[10], at[16]);       MULADD(at[11], at[15]);       MULADD(at[12], at[14]); 
-      COMBA_STORE(C->dp[13]);
-      /* 14 */
-      COMBA_FORWARD;
-      MULADD(at[2], at[25]);       MULADD(at[3], at[24]);       MULADD(at[4], at[23]);       MULADD(at[5], at[22]);       MULADD(at[6], at[21]);       MULADD(at[7], at[20]);       MULADD(at[8], at[19]);       MULADD(at[9], at[18]);       MULADD(at[10], at[17]);       MULADD(at[11], at[16]);       MULADD(at[12], at[15]); 
-      COMBA_STORE(C->dp[14]);
-      /* 15 */
-      COMBA_FORWARD;
-      MULADD(at[3], at[25]);       MULADD(at[4], at[24]);       MULADD(at[5], at[23]);       MULADD(at[6], at[22]);       MULADD(at[7], at[21]);       MULADD(at[8], at[20]);       MULADD(at[9], at[19]);       MULADD(at[10], at[18]);       MULADD(at[11], at[17]);       MULADD(at[12], at[16]); 
-      COMBA_STORE(C->dp[15]);
-      /* 16 */
-      COMBA_FORWARD;
-      MULADD(at[4], at[25]);       MULADD(at[5], at[24]);       MULADD(at[6], at[23]);       MULADD(at[7], at[22]);       MULADD(at[8], at[21]);       MULADD(at[9], at[20]);       MULADD(at[10], at[19]);       MULADD(at[11], at[18]);       MULADD(at[12], at[17]); 
-      COMBA_STORE(C->dp[16]);
-      /* 17 */
-      COMBA_FORWARD;
-      MULADD(at[5], at[25]);       MULADD(at[6], at[24]);       MULADD(at[7], at[23]);       MULADD(at[8], at[22]);       MULADD(at[9], at[21]);       MULADD(at[10], at[20]);       MULADD(at[11], at[19]);       MULADD(at[12], at[18]); 
-      COMBA_STORE(C->dp[17]);
-      /* 18 */
-      COMBA_FORWARD;
-      MULADD(at[6], at[25]);       MULADD(at[7], at[24]);       MULADD(at[8], at[23]);       MULADD(at[9], at[22]);       MULADD(at[10], at[21]);       MULADD(at[11], at[20]);       MULADD(at[12], at[19]); 
-      COMBA_STORE(C->dp[18]);
-      /* 19 */
-      COMBA_FORWARD;
-      MULADD(at[7], at[25]);       MULADD(at[8], at[24]);       MULADD(at[9], at[23]);       MULADD(at[10], at[22]);       MULADD(at[11], at[21]);       MULADD(at[12], at[20]); 
-      COMBA_STORE(C->dp[19]);
-      /* 20 */
-      COMBA_FORWARD;
-      MULADD(at[8], at[25]);       MULADD(at[9], at[24]);       MULADD(at[10], at[23]);       MULADD(at[11], at[22]);       MULADD(at[12], at[21]); 
-      COMBA_STORE(C->dp[20]);
-      /* 21 */
-      COMBA_FORWARD;
-      MULADD(at[9], at[25]);       MULADD(at[10], at[24]);       MULADD(at[11], at[23]);       MULADD(at[12], at[22]); 
-      COMBA_STORE(C->dp[21]);
-      /* 22 */
-      COMBA_FORWARD;
-      MULADD(at[10], at[25]);       MULADD(at[11], at[24]);       MULADD(at[12], at[23]); 
-      COMBA_STORE(C->dp[22]);
-      /* 23 */
-      COMBA_FORWARD;
-      MULADD(at[11], at[25]);       MULADD(at[12], at[24]); 
-      COMBA_STORE(C->dp[23]);
-      /* 24 */
-      COMBA_FORWARD;
-      MULADD(at[12], at[25]); 
-      COMBA_STORE(C->dp[24]);
-      COMBA_STORE2(C->dp[25]);
-      C->used = 26;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 14:
-      memcpy(at, A->dp, 14 * sizeof(fp_digit));
-      memcpy(at+14, B->dp, 14 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[14]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[15]);       MULADD(at[1], at[14]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[16]);       MULADD(at[1], at[15]);       MULADD(at[2], at[14]); 
-      COMBA_STORE(C->dp[2]);
-      /* 3 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[17]);       MULADD(at[1], at[16]);       MULADD(at[2], at[15]);       MULADD(at[3], at[14]); 
-      COMBA_STORE(C->dp[3]);
-      /* 4 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[18]);       MULADD(at[1], at[17]);       MULADD(at[2], at[16]);       MULADD(at[3], at[15]);       MULADD(at[4], at[14]); 
-      COMBA_STORE(C->dp[4]);
-      /* 5 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[19]);       MULADD(at[1], at[18]);       MULADD(at[2], at[17]);       MULADD(at[3], at[16]);       MULADD(at[4], at[15]);       MULADD(at[5], at[14]); 
-      COMBA_STORE(C->dp[5]);
-      /* 6 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[20]);       MULADD(at[1], at[19]);       MULADD(at[2], at[18]);       MULADD(at[3], at[17]);       MULADD(at[4], at[16]);       MULADD(at[5], at[15]);       MULADD(at[6], at[14]); 
-      COMBA_STORE(C->dp[6]);
-      /* 7 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[21]);       MULADD(at[1], at[20]);       MULADD(at[2], at[19]);       MULADD(at[3], at[18]);       MULADD(at[4], at[17]);       MULADD(at[5], at[16]);       MULADD(at[6], at[15]);       MULADD(at[7], at[14]); 
-      COMBA_STORE(C->dp[7]);
-      /* 8 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[22]);       MULADD(at[1], at[21]);       MULADD(at[2], at[20]);       MULADD(at[3], at[19]);       MULADD(at[4], at[18]);       MULADD(at[5], at[17]);       MULADD(at[6], at[16]);       MULADD(at[7], at[15]);       MULADD(at[8], at[14]); 
-      COMBA_STORE(C->dp[8]);
-      /* 9 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[23]);       MULADD(at[1], at[22]);       MULADD(at[2], at[21]);       MULADD(at[3], at[20]);       MULADD(at[4], at[19]);       MULADD(at[5], at[18]);       MULADD(at[6], at[17]);       MULADD(at[7], at[16]);       MULADD(at[8], at[15]);       MULADD(at[9], at[14]); 
-      COMBA_STORE(C->dp[9]);
-      /* 10 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[24]);       MULADD(at[1], at[23]);       MULADD(at[2], at[22]);       MULADD(at[3], at[21]);       MULADD(at[4], at[20]);       MULADD(at[5], at[19]);       MULADD(at[6], at[18]);       MULADD(at[7], at[17]);       MULADD(at[8], at[16]);       MULADD(at[9], at[15]);       MULADD(at[10], at[14]); 
-      COMBA_STORE(C->dp[10]);
-      /* 11 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[25]);       MULADD(at[1], at[24]);       MULADD(at[2], at[23]);       MULADD(at[3], at[22]);       MULADD(at[4], at[21]);       MULADD(at[5], at[20]);       MULADD(at[6], at[19]);       MULADD(at[7], at[18]);       MULADD(at[8], at[17]);       MULADD(at[9], at[16]);       MULADD(at[10], at[15]);       MULADD(at[11], at[14]); 
-      COMBA_STORE(C->dp[11]);
-      /* 12 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[26]);       MULADD(at[1], at[25]);       MULADD(at[2], at[24]);       MULADD(at[3], at[23]);       MULADD(at[4], at[22]);       MULADD(at[5], at[21]);       MULADD(at[6], at[20]);       MULADD(at[7], at[19]);       MULADD(at[8], at[18]);       MULADD(at[9], at[17]);       MULADD(at[10], at[16]);       MULADD(at[11], at[15]);       MULADD(at[12], at[14]); 
-      COMBA_STORE(C->dp[12]);
-      /* 13 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[27]);       MULADD(at[1], at[26]);       MULADD(at[2], at[25]);       MULADD(at[3], at[24]);       MULADD(at[4], at[23]);       MULADD(at[5], at[22]);       MULADD(at[6], at[21]);       MULADD(at[7], at[20]);       MULADD(at[8], at[19]);       MULADD(at[9], at[18]);       MULADD(at[10], at[17]);       MULADD(at[11], at[16]);       MULADD(at[12], at[15]);       MULADD(at[13], at[14]); 
-      COMBA_STORE(C->dp[13]);
-      /* 14 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[27]);       MULADD(at[2], at[26]);       MULADD(at[3], at[25]);       MULADD(at[4], at[24]);       MULADD(at[5], at[23]);       MULADD(at[6], at[22]);       MULADD(at[7], at[21]);       MULADD(at[8], at[20]);       MULADD(at[9], at[19]);       MULADD(at[10], at[18]);       MULADD(at[11], at[17]);       MULADD(at[12], at[16]);       MULADD(at[13], at[15]); 
-      COMBA_STORE(C->dp[14]);
-      /* 15 */
-      COMBA_FORWARD;
-      MULADD(at[2], at[27]);       MULADD(at[3], at[26]);       MULADD(at[4], at[25]);       MULADD(at[5], at[24]);       MULADD(at[6], at[23]);       MULADD(at[7], at[22]);       MULADD(at[8], at[21]);       MULADD(at[9], at[20]);       MULADD(at[10], at[19]);       MULADD(at[11], at[18]);       MULADD(at[12], at[17]);       MULADD(at[13], at[16]); 
-      COMBA_STORE(C->dp[15]);
-      /* 16 */
-      COMBA_FORWARD;
-      MULADD(at[3], at[27]);       MULADD(at[4], at[26]);       MULADD(at[5], at[25]);       MULADD(at[6], at[24]);       MULADD(at[7], at[23]);       MULADD(at[8], at[22]);       MULADD(at[9], at[21]);       MULADD(at[10], at[20]);       MULADD(at[11], at[19]);       MULADD(at[12], at[18]);       MULADD(at[13], at[17]); 
-      COMBA_STORE(C->dp[16]);
-      /* 17 */
-      COMBA_FORWARD;
-      MULADD(at[4], at[27]);       MULADD(at[5], at[26]);       MULADD(at[6], at[25]);       MULADD(at[7], at[24]);       MULADD(at[8], at[23]);       MULADD(at[9], at[22]);       MULADD(at[10], at[21]);       MULADD(at[11], at[20]);       MULADD(at[12], at[19]);       MULADD(at[13], at[18]); 
-      COMBA_STORE(C->dp[17]);
-      /* 18 */
-      COMBA_FORWARD;
-      MULADD(at[5], at[27]);       MULADD(at[6], at[26]);       MULADD(at[7], at[25]);       MULADD(at[8], at[24]);       MULADD(at[9], at[23]);       MULADD(at[10], at[22]);       MULADD(at[11], at[21]);       MULADD(at[12], at[20]);       MULADD(at[13], at[19]); 
-      COMBA_STORE(C->dp[18]);
-      /* 19 */
-      COMBA_FORWARD;
-      MULADD(at[6], at[27]);       MULADD(at[7], at[26]);       MULADD(at[8], at[25]);       MULADD(at[9], at[24]);       MULADD(at[10], at[23]);       MULADD(at[11], at[22]);       MULADD(at[12], at[21]);       MULADD(at[13], at[20]); 
-      COMBA_STORE(C->dp[19]);
-      /* 20 */
-      COMBA_FORWARD;
-      MULADD(at[7], at[27]);       MULADD(at[8], at[26]);       MULADD(at[9], at[25]);       MULADD(at[10], at[24]);       MULADD(at[11], at[23]);       MULADD(at[12], at[22]);       MULADD(at[13], at[21]); 
-      COMBA_STORE(C->dp[20]);
-      /* 21 */
-      COMBA_FORWARD;
-      MULADD(at[8], at[27]);       MULADD(at[9], at[26]);       MULADD(at[10], at[25]);       MULADD(at[11], at[24]);       MULADD(at[12], at[23]);       MULADD(at[13], at[22]); 
-      COMBA_STORE(C->dp[21]);
-      /* 22 */
-      COMBA_FORWARD;
-      MULADD(at[9], at[27]);       MULADD(at[10], at[26]);       MULADD(at[11], at[25]);       MULADD(at[12], at[24]);       MULADD(at[13], at[23]); 
-      COMBA_STORE(C->dp[22]);
-      /* 23 */
-      COMBA_FORWARD;
-      MULADD(at[10], at[27]);       MULADD(at[11], at[26]);       MULADD(at[12], at[25]);       MULADD(at[13], at[24]); 
-      COMBA_STORE(C->dp[23]);
-      /* 24 */
-      COMBA_FORWARD;
-      MULADD(at[11], at[27]);       MULADD(at[12], at[26]);       MULADD(at[13], at[25]); 
-      COMBA_STORE(C->dp[24]);
-      /* 25 */
-      COMBA_FORWARD;
-      MULADD(at[12], at[27]);       MULADD(at[13], at[26]); 
-      COMBA_STORE(C->dp[25]);
-      /* 26 */
-      COMBA_FORWARD;
-      MULADD(at[13], at[27]); 
-      COMBA_STORE(C->dp[26]);
-      COMBA_STORE2(C->dp[27]);
-      C->used = 28;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 15:
-      memcpy(at, A->dp, 15 * sizeof(fp_digit));
-      memcpy(at+15, B->dp, 15 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[15]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[16]);       MULADD(at[1], at[15]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[17]);       MULADD(at[1], at[16]);       MULADD(at[2], at[15]); 
-      COMBA_STORE(C->dp[2]);
-      /* 3 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[18]);       MULADD(at[1], at[17]);       MULADD(at[2], at[16]);       MULADD(at[3], at[15]); 
-      COMBA_STORE(C->dp[3]);
-      /* 4 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[19]);       MULADD(at[1], at[18]);       MULADD(at[2], at[17]);       MULADD(at[3], at[16]);       MULADD(at[4], at[15]); 
-      COMBA_STORE(C->dp[4]);
-      /* 5 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[20]);       MULADD(at[1], at[19]);       MULADD(at[2], at[18]);       MULADD(at[3], at[17]);       MULADD(at[4], at[16]);       MULADD(at[5], at[15]); 
-      COMBA_STORE(C->dp[5]);
-      /* 6 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[21]);       MULADD(at[1], at[20]);       MULADD(at[2], at[19]);       MULADD(at[3], at[18]);       MULADD(at[4], at[17]);       MULADD(at[5], at[16]);       MULADD(at[6], at[15]); 
-      COMBA_STORE(C->dp[6]);
-      /* 7 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[22]);       MULADD(at[1], at[21]);       MULADD(at[2], at[20]);       MULADD(at[3], at[19]);       MULADD(at[4], at[18]);       MULADD(at[5], at[17]);       MULADD(at[6], at[16]);       MULADD(at[7], at[15]); 
-      COMBA_STORE(C->dp[7]);
-      /* 8 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[23]);       MULADD(at[1], at[22]);       MULADD(at[2], at[21]);       MULADD(at[3], at[20]);       MULADD(at[4], at[19]);       MULADD(at[5], at[18]);       MULADD(at[6], at[17]);       MULADD(at[7], at[16]);       MULADD(at[8], at[15]); 
-      COMBA_STORE(C->dp[8]);
-      /* 9 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[24]);       MULADD(at[1], at[23]);       MULADD(at[2], at[22]);       MULADD(at[3], at[21]);       MULADD(at[4], at[20]);       MULADD(at[5], at[19]);       MULADD(at[6], at[18]);       MULADD(at[7], at[17]);       MULADD(at[8], at[16]);       MULADD(at[9], at[15]); 
-      COMBA_STORE(C->dp[9]);
-      /* 10 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[25]);       MULADD(at[1], at[24]);       MULADD(at[2], at[23]);       MULADD(at[3], at[22]);       MULADD(at[4], at[21]);       MULADD(at[5], at[20]);       MULADD(at[6], at[19]);       MULADD(at[7], at[18]);       MULADD(at[8], at[17]);       MULADD(at[9], at[16]);       MULADD(at[10], at[15]); 
-      COMBA_STORE(C->dp[10]);
-      /* 11 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[26]);       MULADD(at[1], at[25]);       MULADD(at[2], at[24]);       MULADD(at[3], at[23]);       MULADD(at[4], at[22]);       MULADD(at[5], at[21]);       MULADD(at[6], at[20]);       MULADD(at[7], at[19]);       MULADD(at[8], at[18]);       MULADD(at[9], at[17]);       MULADD(at[10], at[16]);       MULADD(at[11], at[15]); 
-      COMBA_STORE(C->dp[11]);
-      /* 12 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[27]);       MULADD(at[1], at[26]);       MULADD(at[2], at[25]);       MULADD(at[3], at[24]);       MULADD(at[4], at[23]);       MULADD(at[5], at[22]);       MULADD(at[6], at[21]);       MULADD(at[7], at[20]);       MULADD(at[8], at[19]);       MULADD(at[9], at[18]);       MULADD(at[10], at[17]);       MULADD(at[11], at[16]);       MULADD(at[12], at[15]); 
-      COMBA_STORE(C->dp[12]);
-      /* 13 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[28]);       MULADD(at[1], at[27]);       MULADD(at[2], at[26]);       MULADD(at[3], at[25]);       MULADD(at[4], at[24]);       MULADD(at[5], at[23]);       MULADD(at[6], at[22]);       MULADD(at[7], at[21]);       MULADD(at[8], at[20]);       MULADD(at[9], at[19]);       MULADD(at[10], at[18]);       MULADD(at[11], at[17]);       MULADD(at[12], at[16]);       MULADD(at[13], at[15]); 
-      COMBA_STORE(C->dp[13]);
-      /* 14 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[29]);       MULADD(at[1], at[28]);       MULADD(at[2], at[27]);       MULADD(at[3], at[26]);       MULADD(at[4], at[25]);       MULADD(at[5], at[24]);       MULADD(at[6], at[23]);       MULADD(at[7], at[22]);       MULADD(at[8], at[21]);       MULADD(at[9], at[20]);       MULADD(at[10], at[19]);       MULADD(at[11], at[18]);       MULADD(at[12], at[17]);       MULADD(at[13], at[16]);       MULADD(at[14], at[15]); 
-      COMBA_STORE(C->dp[14]);
-      /* 15 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[29]);       MULADD(at[2], at[28]);       MULADD(at[3], at[27]);       MULADD(at[4], at[26]);       MULADD(at[5], at[25]);       MULADD(at[6], at[24]);       MULADD(at[7], at[23]);       MULADD(at[8], at[22]);       MULADD(at[9], at[21]);       MULADD(at[10], at[20]);       MULADD(at[11], at[19]);       MULADD(at[12], at[18]);       MULADD(at[13], at[17]);       MULADD(at[14], at[16]); 
-      COMBA_STORE(C->dp[15]);
-      /* 16 */
-      COMBA_FORWARD;
-      MULADD(at[2], at[29]);       MULADD(at[3], at[28]);       MULADD(at[4], at[27]);       MULADD(at[5], at[26]);       MULADD(at[6], at[25]);       MULADD(at[7], at[24]);       MULADD(at[8], at[23]);       MULADD(at[9], at[22]);       MULADD(at[10], at[21]);       MULADD(at[11], at[20]);       MULADD(at[12], at[19]);       MULADD(at[13], at[18]);       MULADD(at[14], at[17]); 
-      COMBA_STORE(C->dp[16]);
-      /* 17 */
-      COMBA_FORWARD;
-      MULADD(at[3], at[29]);       MULADD(at[4], at[28]);       MULADD(at[5], at[27]);       MULADD(at[6], at[26]);       MULADD(at[7], at[25]);       MULADD(at[8], at[24]);       MULADD(at[9], at[23]);       MULADD(at[10], at[22]);       MULADD(at[11], at[21]);       MULADD(at[12], at[20]);       MULADD(at[13], at[19]);       MULADD(at[14], at[18]); 
-      COMBA_STORE(C->dp[17]);
-      /* 18 */
-      COMBA_FORWARD;
-      MULADD(at[4], at[29]);       MULADD(at[5], at[28]);       MULADD(at[6], at[27]);       MULADD(at[7], at[26]);       MULADD(at[8], at[25]);       MULADD(at[9], at[24]);       MULADD(at[10], at[23]);       MULADD(at[11], at[22]);       MULADD(at[12], at[21]);       MULADD(at[13], at[20]);       MULADD(at[14], at[19]); 
-      COMBA_STORE(C->dp[18]);
-      /* 19 */
-      COMBA_FORWARD;
-      MULADD(at[5], at[29]);       MULADD(at[6], at[28]);       MULADD(at[7], at[27]);       MULADD(at[8], at[26]);       MULADD(at[9], at[25]);       MULADD(at[10], at[24]);       MULADD(at[11], at[23]);       MULADD(at[12], at[22]);       MULADD(at[13], at[21]);       MULADD(at[14], at[20]); 
-      COMBA_STORE(C->dp[19]);
-      /* 20 */
-      COMBA_FORWARD;
-      MULADD(at[6], at[29]);       MULADD(at[7], at[28]);       MULADD(at[8], at[27]);       MULADD(at[9], at[26]);       MULADD(at[10], at[25]);       MULADD(at[11], at[24]);       MULADD(at[12], at[23]);       MULADD(at[13], at[22]);       MULADD(at[14], at[21]); 
-      COMBA_STORE(C->dp[20]);
-      /* 21 */
-      COMBA_FORWARD;
-      MULADD(at[7], at[29]);       MULADD(at[8], at[28]);       MULADD(at[9], at[27]);       MULADD(at[10], at[26]);       MULADD(at[11], at[25]);       MULADD(at[12], at[24]);       MULADD(at[13], at[23]);       MULADD(at[14], at[22]); 
-      COMBA_STORE(C->dp[21]);
-      /* 22 */
-      COMBA_FORWARD;
-      MULADD(at[8], at[29]);       MULADD(at[9], at[28]);       MULADD(at[10], at[27]);       MULADD(at[11], at[26]);       MULADD(at[12], at[25]);       MULADD(at[13], at[24]);       MULADD(at[14], at[23]); 
-      COMBA_STORE(C->dp[22]);
-      /* 23 */
-      COMBA_FORWARD;
-      MULADD(at[9], at[29]);       MULADD(at[10], at[28]);       MULADD(at[11], at[27]);       MULADD(at[12], at[26]);       MULADD(at[13], at[25]);       MULADD(at[14], at[24]); 
-      COMBA_STORE(C->dp[23]);
-      /* 24 */
-      COMBA_FORWARD;
-      MULADD(at[10], at[29]);       MULADD(at[11], at[28]);       MULADD(at[12], at[27]);       MULADD(at[13], at[26]);       MULADD(at[14], at[25]); 
-      COMBA_STORE(C->dp[24]);
-      /* 25 */
-      COMBA_FORWARD;
-      MULADD(at[11], at[29]);       MULADD(at[12], at[28]);       MULADD(at[13], at[27]);       MULADD(at[14], at[26]); 
-      COMBA_STORE(C->dp[25]);
-      /* 26 */
-      COMBA_FORWARD;
-      MULADD(at[12], at[29]);       MULADD(at[13], at[28]);       MULADD(at[14], at[27]); 
-      COMBA_STORE(C->dp[26]);
-      /* 27 */
-      COMBA_FORWARD;
-      MULADD(at[13], at[29]);       MULADD(at[14], at[28]); 
-      COMBA_STORE(C->dp[27]);
-      /* 28 */
-      COMBA_FORWARD;
-      MULADD(at[14], at[29]); 
-      COMBA_STORE(C->dp[28]);
-      COMBA_STORE2(C->dp[29]);
-      C->used = 30;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   case 16:
-      memcpy(at, A->dp, 16 * sizeof(fp_digit));
-      memcpy(at+16, B->dp, 16 * sizeof(fp_digit));
-      COMBA_START;
-
-      COMBA_CLEAR;
-      /* 0 */
-      MULADD(at[0], at[16]); 
-      COMBA_STORE(C->dp[0]);
-      /* 1 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[17]);       MULADD(at[1], at[16]); 
-      COMBA_STORE(C->dp[1]);
-      /* 2 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[18]);       MULADD(at[1], at[17]);       MULADD(at[2], at[16]); 
-      COMBA_STORE(C->dp[2]);
-      /* 3 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[19]);       MULADD(at[1], at[18]);       MULADD(at[2], at[17]);       MULADD(at[3], at[16]); 
-      COMBA_STORE(C->dp[3]);
-      /* 4 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[20]);       MULADD(at[1], at[19]);       MULADD(at[2], at[18]);       MULADD(at[3], at[17]);       MULADD(at[4], at[16]); 
-      COMBA_STORE(C->dp[4]);
-      /* 5 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[21]);       MULADD(at[1], at[20]);       MULADD(at[2], at[19]);       MULADD(at[3], at[18]);       MULADD(at[4], at[17]);       MULADD(at[5], at[16]); 
-      COMBA_STORE(C->dp[5]);
-      /* 6 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[22]);       MULADD(at[1], at[21]);       MULADD(at[2], at[20]);       MULADD(at[3], at[19]);       MULADD(at[4], at[18]);       MULADD(at[5], at[17]);       MULADD(at[6], at[16]); 
-      COMBA_STORE(C->dp[6]);
-      /* 7 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[23]);       MULADD(at[1], at[22]);       MULADD(at[2], at[21]);       MULADD(at[3], at[20]);       MULADD(at[4], at[19]);       MULADD(at[5], at[18]);       MULADD(at[6], at[17]);       MULADD(at[7], at[16]); 
-      COMBA_STORE(C->dp[7]);
-      /* 8 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[24]);       MULADD(at[1], at[23]);       MULADD(at[2], at[22]);       MULADD(at[3], at[21]);       MULADD(at[4], at[20]);       MULADD(at[5], at[19]);       MULADD(at[6], at[18]);       MULADD(at[7], at[17]);       MULADD(at[8], at[16]); 
-      COMBA_STORE(C->dp[8]);
-      /* 9 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[25]);       MULADD(at[1], at[24]);       MULADD(at[2], at[23]);       MULADD(at[3], at[22]);       MULADD(at[4], at[21]);       MULADD(at[5], at[20]);       MULADD(at[6], at[19]);       MULADD(at[7], at[18]);       MULADD(at[8], at[17]);       MULADD(at[9], at[16]); 
-      COMBA_STORE(C->dp[9]);
-      /* 10 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[26]);       MULADD(at[1], at[25]);       MULADD(at[2], at[24]);       MULADD(at[3], at[23]);       MULADD(at[4], at[22]);       MULADD(at[5], at[21]);       MULADD(at[6], at[20]);       MULADD(at[7], at[19]);       MULADD(at[8], at[18]);       MULADD(at[9], at[17]);       MULADD(at[10], at[16]); 
-      COMBA_STORE(C->dp[10]);
-      /* 11 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[27]);       MULADD(at[1], at[26]);       MULADD(at[2], at[25]);       MULADD(at[3], at[24]);       MULADD(at[4], at[23]);       MULADD(at[5], at[22]);       MULADD(at[6], at[21]);       MULADD(at[7], at[20]);       MULADD(at[8], at[19]);       MULADD(at[9], at[18]);       MULADD(at[10], at[17]);       MULADD(at[11], at[16]); 
-      COMBA_STORE(C->dp[11]);
-      /* 12 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[28]);       MULADD(at[1], at[27]);       MULADD(at[2], at[26]);       MULADD(at[3], at[25]);       MULADD(at[4], at[24]);       MULADD(at[5], at[23]);       MULADD(at[6], at[22]);       MULADD(at[7], at[21]);       MULADD(at[8], at[20]);       MULADD(at[9], at[19]);       MULADD(at[10], at[18]);       MULADD(at[11], at[17]);       MULADD(at[12], at[16]); 
-      COMBA_STORE(C->dp[12]);
-      /* 13 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[29]);       MULADD(at[1], at[28]);       MULADD(at[2], at[27]);       MULADD(at[3], at[26]);       MULADD(at[4], at[25]);       MULADD(at[5], at[24]);       MULADD(at[6], at[23]);       MULADD(at[7], at[22]);       MULADD(at[8], at[21]);       MULADD(at[9], at[20]);       MULADD(at[10], at[19]);       MULADD(at[11], at[18]);       MULADD(at[12], at[17]);       MULADD(at[13], at[16]); 
-      COMBA_STORE(C->dp[13]);
-      /* 14 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[30]);       MULADD(at[1], at[29]);       MULADD(at[2], at[28]);       MULADD(at[3], at[27]);       MULADD(at[4], at[26]);       MULADD(at[5], at[25]);       MULADD(at[6], at[24]);       MULADD(at[7], at[23]);       MULADD(at[8], at[22]);       MULADD(at[9], at[21]);       MULADD(at[10], at[20]);       MULADD(at[11], at[19]);       MULADD(at[12], at[18]);       MULADD(at[13], at[17]);       MULADD(at[14], at[16]); 
-      COMBA_STORE(C->dp[14]);
-      /* 15 */
-      COMBA_FORWARD;
-      MULADD(at[0], at[31]);       MULADD(at[1], at[30]);       MULADD(at[2], at[29]);       MULADD(at[3], at[28]);       MULADD(at[4], at[27]);       MULADD(at[5], at[26]);       MULADD(at[6], at[25]);       MULADD(at[7], at[24]);       MULADD(at[8], at[23]);       MULADD(at[9], at[22]);       MULADD(at[10], at[21]);       MULADD(at[11], at[20]);       MULADD(at[12], at[19]);       MULADD(at[13], at[18]);       MULADD(at[14], at[17]);       MULADD(at[15], at[16]); 
-      COMBA_STORE(C->dp[15]);
-      /* 16 */
-      COMBA_FORWARD;
-      MULADD(at[1], at[31]);       MULADD(at[2], at[30]);       MULADD(at[3], at[29]);       MULADD(at[4], at[28]);       MULADD(at[5], at[27]);       MULADD(at[6], at[26]);       MULADD(at[7], at[25]);       MULADD(at[8], at[24]);       MULADD(at[9], at[23]);       MULADD(at[10], at[22]);       MULADD(at[11], at[21]);       MULADD(at[12], at[20]);       MULADD(at[13], at[19]);       MULADD(at[14], at[18]);       MULADD(at[15], at[17]); 
-      COMBA_STORE(C->dp[16]);
-      /* 17 */
-      COMBA_FORWARD;
-      MULADD(at[2], at[31]);       MULADD(at[3], at[30]);       MULADD(at[4], at[29]);       MULADD(at[5], at[28]);       MULADD(at[6], at[27]);       MULADD(at[7], at[26]);       MULADD(at[8], at[25]);       MULADD(at[9], at[24]);       MULADD(at[10], at[23]);       MULADD(at[11], at[22]);       MULADD(at[12], at[21]);       MULADD(at[13], at[20]);       MULADD(at[14], at[19]);       MULADD(at[15], at[18]); 
-      COMBA_STORE(C->dp[17]);
-      /* 18 */
-      COMBA_FORWARD;
-      MULADD(at[3], at[31]);       MULADD(at[4], at[30]);       MULADD(at[5], at[29]);       MULADD(at[6], at[28]);       MULADD(at[7], at[27]);       MULADD(at[8], at[26]);       MULADD(at[9], at[25]);       MULADD(at[10], at[24]);       MULADD(at[11], at[23]);       MULADD(at[12], at[22]);       MULADD(at[13], at[21]);       MULADD(at[14], at[20]);       MULADD(at[15], at[19]); 
-      COMBA_STORE(C->dp[18]);
-      /* 19 */
-      COMBA_FORWARD;
-      MULADD(at[4], at[31]);       MULADD(at[5], at[30]);       MULADD(at[6], at[29]);       MULADD(at[7], at[28]);       MULADD(at[8], at[27]);       MULADD(at[9], at[26]);       MULADD(at[10], at[25]);       MULADD(at[11], at[24]);       MULADD(at[12], at[23]);       MULADD(at[13], at[22]);       MULADD(at[14], at[21]);       MULADD(at[15], at[20]); 
-      COMBA_STORE(C->dp[19]);
-      /* 20 */
-      COMBA_FORWARD;
-      MULADD(at[5], at[31]);       MULADD(at[6], at[30]);       MULADD(at[7], at[29]);       MULADD(at[8], at[28]);       MULADD(at[9], at[27]);       MULADD(at[10], at[26]);       MULADD(at[11], at[25]);       MULADD(at[12], at[24]);       MULADD(at[13], at[23]);       MULADD(at[14], at[22]);       MULADD(at[15], at[21]); 
-      COMBA_STORE(C->dp[20]);
-      /* 21 */
-      COMBA_FORWARD;
-      MULADD(at[6], at[31]);       MULADD(at[7], at[30]);       MULADD(at[8], at[29]);       MULADD(at[9], at[28]);       MULADD(at[10], at[27]);       MULADD(at[11], at[26]);       MULADD(at[12], at[25]);       MULADD(at[13], at[24]);       MULADD(at[14], at[23]);       MULADD(at[15], at[22]); 
-      COMBA_STORE(C->dp[21]);
-      /* 22 */
-      COMBA_FORWARD;
-      MULADD(at[7], at[31]);       MULADD(at[8], at[30]);       MULADD(at[9], at[29]);       MULADD(at[10], at[28]);       MULADD(at[11], at[27]);       MULADD(at[12], at[26]);       MULADD(at[13], at[25]);       MULADD(at[14], at[24]);       MULADD(at[15], at[23]); 
-      COMBA_STORE(C->dp[22]);
-      /* 23 */
-      COMBA_FORWARD;
-      MULADD(at[8], at[31]);       MULADD(at[9], at[30]);       MULADD(at[10], at[29]);       MULADD(at[11], at[28]);       MULADD(at[12], at[27]);       MULADD(at[13], at[26]);       MULADD(at[14], at[25]);       MULADD(at[15], at[24]); 
-      COMBA_STORE(C->dp[23]);
-      /* 24 */
-      COMBA_FORWARD;
-      MULADD(at[9], at[31]);       MULADD(at[10], at[30]);       MULADD(at[11], at[29]);       MULADD(at[12], at[28]);       MULADD(at[13], at[27]);       MULADD(at[14], at[26]);       MULADD(at[15], at[25]); 
-      COMBA_STORE(C->dp[24]);
-      /* 25 */
-      COMBA_FORWARD;
-      MULADD(at[10], at[31]);       MULADD(at[11], at[30]);       MULADD(at[12], at[29]);       MULADD(at[13], at[28]);       MULADD(at[14], at[27]);       MULADD(at[15], at[26]); 
-      COMBA_STORE(C->dp[25]);
-      /* 26 */
-      COMBA_FORWARD;
-      MULADD(at[11], at[31]);       MULADD(at[12], at[30]);       MULADD(at[13], at[29]);       MULADD(at[14], at[28]);       MULADD(at[15], at[27]); 
-      COMBA_STORE(C->dp[26]);
-      /* 27 */
-      COMBA_FORWARD;
-      MULADD(at[12], at[31]);       MULADD(at[13], at[30]);       MULADD(at[14], at[29]);       MULADD(at[15], at[28]); 
-      COMBA_STORE(C->dp[27]);
-      /* 28 */
-      COMBA_FORWARD;
-      MULADD(at[13], at[31]);       MULADD(at[14], at[30]);       MULADD(at[15], at[29]); 
-      COMBA_STORE(C->dp[28]);
-      /* 29 */
-      COMBA_FORWARD;
-      MULADD(at[14], at[31]);       MULADD(at[15], at[30]); 
-      COMBA_STORE(C->dp[29]);
-      /* 30 */
-      COMBA_FORWARD;
-      MULADD(at[15], at[31]); 
-      COMBA_STORE(C->dp[30]);
-      COMBA_STORE2(C->dp[31]);
-      C->used = 32;
-      C->sign = A->sign ^ B->sign;
-      fp_clamp(C);
-      COMBA_FINI;
-      break;
-
-   default:
-      break;
-   }
-}
-
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_12.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_12.i
deleted file mode 100755
index 078b898..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_12.i
+++ /dev/null
@@ -1,159 +0,0 @@
-/* fp_sqr_comba_12.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SQR12
-void fp_sqr_comba12(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[24], c0, c1, c2, sc0, sc1, sc2;
-#ifdef TFM_ISO
-   fp_word tt;
-#endif
-   a = A->dp;
-   COMBA_START; 
-
-   /* clear carries */
-   CLEAR_CARRY;
-
-   /* output 0 */
-   SQRADD(a[0],a[0]);
-   COMBA_STORE(b[0]);
-
-   /* output 1 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[1]); 
-   COMBA_STORE(b[1]);
-
-   /* output 2 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
-   COMBA_STORE(b[2]);
-
-   /* output 3 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
-   COMBA_STORE(b[3]);
-
-   /* output 4 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
-   COMBA_STORE(b[4]);
-
-   /* output 5 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-   COMBA_STORE(b[5]);
-
-   /* output 6 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-   COMBA_STORE(b[6]);
-
-   /* output 7 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-   COMBA_STORE(b[7]);
-
-   /* output 8 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-   COMBA_STORE(b[8]);
-
-   /* output 9 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-   COMBA_STORE(b[9]);
-
-   /* output 10 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-   COMBA_STORE(b[10]);
-
-   /* output 11 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-   COMBA_STORE(b[11]);
-
-   /* output 12 */
-   CARRY_FORWARD;
-   SQRADDSC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-   COMBA_STORE(b[12]);
-
-   /* output 13 */
-   CARRY_FORWARD;
-   SQRADDSC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-   COMBA_STORE(b[13]);
-
-   /* output 14 */
-   CARRY_FORWARD;
-   SQRADDSC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); 
-   COMBA_STORE(b[14]);
-
-   /* output 15 */
-   CARRY_FORWARD;
-   SQRADDSC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; 
-   COMBA_STORE(b[15]);
-
-   /* output 16 */
-   CARRY_FORWARD;
-   SQRADDSC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); 
-   COMBA_STORE(b[16]);
-
-   /* output 17 */
-   CARRY_FORWARD;
-   SQRADDSC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; 
-   COMBA_STORE(b[17]);
-
-   /* output 18 */
-   CARRY_FORWARD;
-   SQRADD2(a[7], a[11]); SQRADD2(a[8], a[10]); SQRADD(a[9], a[9]); 
-   COMBA_STORE(b[18]);
-
-   /* output 19 */
-   CARRY_FORWARD;
-   SQRADD2(a[8], a[11]); SQRADD2(a[9], a[10]); 
-   COMBA_STORE(b[19]);
-
-   /* output 20 */
-   CARRY_FORWARD;
-   SQRADD2(a[9], a[11]); SQRADD(a[10], a[10]); 
-   COMBA_STORE(b[20]);
-
-   /* output 21 */
-   CARRY_FORWARD;
-   SQRADD2(a[10], a[11]); 
-   COMBA_STORE(b[21]);
-
-   /* output 22 */
-   CARRY_FORWARD;
-   SQRADD(a[11], a[11]); 
-   COMBA_STORE(b[22]);
-   COMBA_STORE2(b[23]);
-   COMBA_FINI;
-
-   B->used = 24;
-   B->sign = FP_ZPOS;
-   memcpy(B->dp, b, 24 * sizeof(fp_digit));
-   fp_clamp(B);
-}
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_17.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_17.i
deleted file mode 100755
index d5f4674..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_17.i
+++ /dev/null
@@ -1,210 +0,0 @@
-/* fp_sqr_comba_17.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SQR17
-void fp_sqr_comba17(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[34], c0, c1, c2, sc0, sc1, sc2;
-#ifdef TFM_ISO
-   fp_word tt;
-#endif
-
-   a = A->dp;
-   COMBA_START; 
-
-   /* clear carries */
-   CLEAR_CARRY;
-
-   /* output 0 */
-   SQRADD(a[0],a[0]);
-   COMBA_STORE(b[0]);
-
-   /* output 1 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[1]); 
-   COMBA_STORE(b[1]);
-
-   /* output 2 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
-   COMBA_STORE(b[2]);
-
-   /* output 3 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
-   COMBA_STORE(b[3]);
-
-   /* output 4 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
-   COMBA_STORE(b[4]);
-
-   /* output 5 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-   COMBA_STORE(b[5]);
-
-   /* output 6 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-   COMBA_STORE(b[6]);
-
-   /* output 7 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-   COMBA_STORE(b[7]);
-
-   /* output 8 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-   COMBA_STORE(b[8]);
-
-   /* output 9 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-   COMBA_STORE(b[9]);
-
-   /* output 10 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-   COMBA_STORE(b[10]);
-
-   /* output 11 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-   COMBA_STORE(b[11]);
-
-   /* output 12 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-   COMBA_STORE(b[12]);
-
-   /* output 13 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-   COMBA_STORE(b[13]);
-
-   /* output 14 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); 
-   COMBA_STORE(b[14]);
-
-   /* output 15 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; 
-   COMBA_STORE(b[15]);
-
-   /* output 16 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); 
-   COMBA_STORE(b[16]);
-
-   /* output 17 */
-   CARRY_FORWARD;
-   SQRADDSC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; 
-   COMBA_STORE(b[17]);
-
-   /* output 18 */
-   CARRY_FORWARD;
-   SQRADDSC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); 
-   COMBA_STORE(b[18]);
-
-   /* output 19 */
-   CARRY_FORWARD;
-   SQRADDSC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; 
-   COMBA_STORE(b[19]);
-
-   /* output 20 */
-   CARRY_FORWARD;
-   SQRADDSC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); 
-   COMBA_STORE(b[20]);
-
-   /* output 21 */
-   CARRY_FORWARD;
-   SQRADDSC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; 
-   COMBA_STORE(b[21]);
-
-   /* output 22 */
-   CARRY_FORWARD;
-   SQRADDSC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); 
-   COMBA_STORE(b[22]);
-
-   /* output 23 */
-   CARRY_FORWARD;
-   SQRADDSC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; 
-   COMBA_STORE(b[23]);
-
-   /* output 24 */
-   CARRY_FORWARD;
-   SQRADDSC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); 
-   COMBA_STORE(b[24]);
-
-   /* output 25 */
-   CARRY_FORWARD;
-   SQRADDSC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; 
-   COMBA_STORE(b[25]);
-
-   /* output 26 */
-   CARRY_FORWARD;
-   SQRADDSC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); 
-   COMBA_STORE(b[26]);
-
-   /* output 27 */
-   CARRY_FORWARD;
-   SQRADDSC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; 
-   COMBA_STORE(b[27]);
-
-   /* output 28 */
-   CARRY_FORWARD;
-   SQRADD2(a[12], a[16]); SQRADD2(a[13], a[15]); SQRADD(a[14], a[14]); 
-   COMBA_STORE(b[28]);
-
-   /* output 29 */
-   CARRY_FORWARD;
-   SQRADD2(a[13], a[16]); SQRADD2(a[14], a[15]); 
-   COMBA_STORE(b[29]);
-
-   /* output 30 */
-   CARRY_FORWARD;
-   SQRADD2(a[14], a[16]); SQRADD(a[15], a[15]); 
-   COMBA_STORE(b[30]);
-
-   /* output 31 */
-   CARRY_FORWARD;
-   SQRADD2(a[15], a[16]); 
-   COMBA_STORE(b[31]);
-
-   /* output 32 */
-   CARRY_FORWARD;
-   SQRADD(a[16], a[16]); 
-   COMBA_STORE(b[32]);
-   COMBA_STORE2(b[33]);
-   COMBA_FINI;
-
-   B->used = 34;
-   B->sign = FP_ZPOS;
-   memcpy(B->dp, b, 34 * sizeof(fp_digit));
-   fp_clamp(B);
-}
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_20.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_20.i
deleted file mode 100755
index dcd9f31..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_20.i
+++ /dev/null
@@ -1,240 +0,0 @@
-/* fp_sqr_comba_20.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SQR20
-void fp_sqr_comba20(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[40], c0, c1, c2, sc0, sc1, sc2;
-#ifdef TFM_ISO
-   fp_word   tt;   
-#endif   
-
-   a = A->dp;
-   COMBA_START; 
-
-   /* clear carries */
-   CLEAR_CARRY;
-
-   /* output 0 */
-   SQRADD(a[0],a[0]);
-   COMBA_STORE(b[0]);
-
-   /* output 1 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[1]); 
-   COMBA_STORE(b[1]);
-
-   /* output 2 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
-   COMBA_STORE(b[2]);
-
-   /* output 3 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
-   COMBA_STORE(b[3]);
-
-   /* output 4 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
-   COMBA_STORE(b[4]);
-
-   /* output 5 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-   COMBA_STORE(b[5]);
-
-   /* output 6 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-   COMBA_STORE(b[6]);
-
-   /* output 7 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-   COMBA_STORE(b[7]);
-
-   /* output 8 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-   COMBA_STORE(b[8]);
-
-   /* output 9 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-   COMBA_STORE(b[9]);
-
-   /* output 10 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-   COMBA_STORE(b[10]);
-
-   /* output 11 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-   COMBA_STORE(b[11]);
-
-   /* output 12 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-   COMBA_STORE(b[12]);
-
-   /* output 13 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-   COMBA_STORE(b[13]);
-
-   /* output 14 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); 
-   COMBA_STORE(b[14]);
-
-   /* output 15 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; 
-   COMBA_STORE(b[15]);
-
-   /* output 16 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); 
-   COMBA_STORE(b[16]);
-
-   /* output 17 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[17]); SQRADDAC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; 
-   COMBA_STORE(b[17]);
-
-   /* output 18 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[18]); SQRADDAC(a[1], a[17]); SQRADDAC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); 
-   COMBA_STORE(b[18]);
-
-   /* output 19 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[19]); SQRADDAC(a[1], a[18]); SQRADDAC(a[2], a[17]); SQRADDAC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; 
-   COMBA_STORE(b[19]);
-
-   /* output 20 */
-   CARRY_FORWARD;
-   SQRADDSC(a[1], a[19]); SQRADDAC(a[2], a[18]); SQRADDAC(a[3], a[17]); SQRADDAC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); 
-   COMBA_STORE(b[20]);
-
-   /* output 21 */
-   CARRY_FORWARD;
-   SQRADDSC(a[2], a[19]); SQRADDAC(a[3], a[18]); SQRADDAC(a[4], a[17]); SQRADDAC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; 
-   COMBA_STORE(b[21]);
-
-   /* output 22 */
-   CARRY_FORWARD;
-   SQRADDSC(a[3], a[19]); SQRADDAC(a[4], a[18]); SQRADDAC(a[5], a[17]); SQRADDAC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); 
-   COMBA_STORE(b[22]);
-
-   /* output 23 */
-   CARRY_FORWARD;
-   SQRADDSC(a[4], a[19]); SQRADDAC(a[5], a[18]); SQRADDAC(a[6], a[17]); SQRADDAC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; 
-   COMBA_STORE(b[23]);
-
-   /* output 24 */
-   CARRY_FORWARD;
-   SQRADDSC(a[5], a[19]); SQRADDAC(a[6], a[18]); SQRADDAC(a[7], a[17]); SQRADDAC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); 
-   COMBA_STORE(b[24]);
-
-   /* output 25 */
-   CARRY_FORWARD;
-   SQRADDSC(a[6], a[19]); SQRADDAC(a[7], a[18]); SQRADDAC(a[8], a[17]); SQRADDAC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; 
-   COMBA_STORE(b[25]);
-
-   /* output 26 */
-   CARRY_FORWARD;
-   SQRADDSC(a[7], a[19]); SQRADDAC(a[8], a[18]); SQRADDAC(a[9], a[17]); SQRADDAC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); 
-   COMBA_STORE(b[26]);
-
-   /* output 27 */
-   CARRY_FORWARD;
-   SQRADDSC(a[8], a[19]); SQRADDAC(a[9], a[18]); SQRADDAC(a[10], a[17]); SQRADDAC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; 
-   COMBA_STORE(b[27]);
-
-   /* output 28 */
-   CARRY_FORWARD;
-   SQRADDSC(a[9], a[19]); SQRADDAC(a[10], a[18]); SQRADDAC(a[11], a[17]); SQRADDAC(a[12], a[16]); SQRADDAC(a[13], a[15]); SQRADDDB; SQRADD(a[14], a[14]); 
-   COMBA_STORE(b[28]);
-
-   /* output 29 */
-   CARRY_FORWARD;
-   SQRADDSC(a[10], a[19]); SQRADDAC(a[11], a[18]); SQRADDAC(a[12], a[17]); SQRADDAC(a[13], a[16]); SQRADDAC(a[14], a[15]); SQRADDDB; 
-   COMBA_STORE(b[29]);
-
-   /* output 30 */
-   CARRY_FORWARD;
-   SQRADDSC(a[11], a[19]); SQRADDAC(a[12], a[18]); SQRADDAC(a[13], a[17]); SQRADDAC(a[14], a[16]); SQRADDDB; SQRADD(a[15], a[15]); 
-   COMBA_STORE(b[30]);
-
-   /* output 31 */
-   CARRY_FORWARD;
-   SQRADDSC(a[12], a[19]); SQRADDAC(a[13], a[18]); SQRADDAC(a[14], a[17]); SQRADDAC(a[15], a[16]); SQRADDDB; 
-   COMBA_STORE(b[31]);
-
-   /* output 32 */
-   CARRY_FORWARD;
-   SQRADDSC(a[13], a[19]); SQRADDAC(a[14], a[18]); SQRADDAC(a[15], a[17]); SQRADDDB; SQRADD(a[16], a[16]); 
-   COMBA_STORE(b[32]);
-
-   /* output 33 */
-   CARRY_FORWARD;
-   SQRADDSC(a[14], a[19]); SQRADDAC(a[15], a[18]); SQRADDAC(a[16], a[17]); SQRADDDB; 
-   COMBA_STORE(b[33]);
-
-   /* output 34 */
-   CARRY_FORWARD;
-   SQRADD2(a[15], a[19]); SQRADD2(a[16], a[18]); SQRADD(a[17], a[17]); 
-   COMBA_STORE(b[34]);
-
-   /* output 35 */
-   CARRY_FORWARD;
-   SQRADD2(a[16], a[19]); SQRADD2(a[17], a[18]); 
-   COMBA_STORE(b[35]);
-
-   /* output 36 */
-   CARRY_FORWARD;
-   SQRADD2(a[17], a[19]); SQRADD(a[18], a[18]); 
-   COMBA_STORE(b[36]);
-
-   /* output 37 */
-   CARRY_FORWARD;
-   SQRADD2(a[18], a[19]); 
-   COMBA_STORE(b[37]);
-
-   /* output 38 */
-   CARRY_FORWARD;
-   SQRADD(a[19], a[19]); 
-   COMBA_STORE(b[38]);
-   COMBA_STORE2(b[39]);
-   COMBA_FINI;
-
-   B->used = 40;
-   B->sign = FP_ZPOS;
-   memcpy(B->dp, b, 40 * sizeof(fp_digit));
-   fp_clamp(B);
-}
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_24.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_24.i
deleted file mode 100755
index cf512e3..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_24.i
+++ /dev/null
@@ -1,280 +0,0 @@
-/* fp_sqr_comba_24.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SQR24
-void fp_sqr_comba24(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[48], c0, c1, c2, sc0, sc1, sc2;
-#ifdef TFM_ISO
-   fp_word   tt;   
-#endif   
-
-   a = A->dp;
-   COMBA_START; 
-
-   /* clear carries */
-   CLEAR_CARRY;
-
-   /* output 0 */
-   SQRADD(a[0],a[0]);
-   COMBA_STORE(b[0]);
-
-   /* output 1 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[1]); 
-   COMBA_STORE(b[1]);
-
-   /* output 2 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
-   COMBA_STORE(b[2]);
-
-   /* output 3 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
-   COMBA_STORE(b[3]);
-
-   /* output 4 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
-   COMBA_STORE(b[4]);
-
-   /* output 5 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-   COMBA_STORE(b[5]);
-
-   /* output 6 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-   COMBA_STORE(b[6]);
-
-   /* output 7 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-   COMBA_STORE(b[7]);
-
-   /* output 8 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-   COMBA_STORE(b[8]);
-
-   /* output 9 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-   COMBA_STORE(b[9]);
-
-   /* output 10 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-   COMBA_STORE(b[10]);
-
-   /* output 11 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-   COMBA_STORE(b[11]);
-
-   /* output 12 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-   COMBA_STORE(b[12]);
-
-   /* output 13 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-   COMBA_STORE(b[13]);
-
-   /* output 14 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); 
-   COMBA_STORE(b[14]);
-
-   /* output 15 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; 
-   COMBA_STORE(b[15]);
-
-   /* output 16 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); 
-   COMBA_STORE(b[16]);
-
-   /* output 17 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[17]); SQRADDAC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; 
-   COMBA_STORE(b[17]);
-
-   /* output 18 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[18]); SQRADDAC(a[1], a[17]); SQRADDAC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); 
-   COMBA_STORE(b[18]);
-
-   /* output 19 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[19]); SQRADDAC(a[1], a[18]); SQRADDAC(a[2], a[17]); SQRADDAC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; 
-   COMBA_STORE(b[19]);
-
-   /* output 20 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[20]); SQRADDAC(a[1], a[19]); SQRADDAC(a[2], a[18]); SQRADDAC(a[3], a[17]); SQRADDAC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); 
-   COMBA_STORE(b[20]);
-
-   /* output 21 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[21]); SQRADDAC(a[1], a[20]); SQRADDAC(a[2], a[19]); SQRADDAC(a[3], a[18]); SQRADDAC(a[4], a[17]); SQRADDAC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; 
-   COMBA_STORE(b[21]);
-
-   /* output 22 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[22]); SQRADDAC(a[1], a[21]); SQRADDAC(a[2], a[20]); SQRADDAC(a[3], a[19]); SQRADDAC(a[4], a[18]); SQRADDAC(a[5], a[17]); SQRADDAC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); 
-   COMBA_STORE(b[22]);
-
-   /* output 23 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[23]); SQRADDAC(a[1], a[22]); SQRADDAC(a[2], a[21]); SQRADDAC(a[3], a[20]); SQRADDAC(a[4], a[19]); SQRADDAC(a[5], a[18]); SQRADDAC(a[6], a[17]); SQRADDAC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; 
-   COMBA_STORE(b[23]);
-
-   /* output 24 */
-   CARRY_FORWARD;
-   SQRADDSC(a[1], a[23]); SQRADDAC(a[2], a[22]); SQRADDAC(a[3], a[21]); SQRADDAC(a[4], a[20]); SQRADDAC(a[5], a[19]); SQRADDAC(a[6], a[18]); SQRADDAC(a[7], a[17]); SQRADDAC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); 
-   COMBA_STORE(b[24]);
-
-   /* output 25 */
-   CARRY_FORWARD;
-   SQRADDSC(a[2], a[23]); SQRADDAC(a[3], a[22]); SQRADDAC(a[4], a[21]); SQRADDAC(a[5], a[20]); SQRADDAC(a[6], a[19]); SQRADDAC(a[7], a[18]); SQRADDAC(a[8], a[17]); SQRADDAC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; 
-   COMBA_STORE(b[25]);
-
-   /* output 26 */
-   CARRY_FORWARD;
-   SQRADDSC(a[3], a[23]); SQRADDAC(a[4], a[22]); SQRADDAC(a[5], a[21]); SQRADDAC(a[6], a[20]); SQRADDAC(a[7], a[19]); SQRADDAC(a[8], a[18]); SQRADDAC(a[9], a[17]); SQRADDAC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); 
-   COMBA_STORE(b[26]);
-
-   /* output 27 */
-   CARRY_FORWARD;
-   SQRADDSC(a[4], a[23]); SQRADDAC(a[5], a[22]); SQRADDAC(a[6], a[21]); SQRADDAC(a[7], a[20]); SQRADDAC(a[8], a[19]); SQRADDAC(a[9], a[18]); SQRADDAC(a[10], a[17]); SQRADDAC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; 
-   COMBA_STORE(b[27]);
-
-   /* output 28 */
-   CARRY_FORWARD;
-   SQRADDSC(a[5], a[23]); SQRADDAC(a[6], a[22]); SQRADDAC(a[7], a[21]); SQRADDAC(a[8], a[20]); SQRADDAC(a[9], a[19]); SQRADDAC(a[10], a[18]); SQRADDAC(a[11], a[17]); SQRADDAC(a[12], a[16]); SQRADDAC(a[13], a[15]); SQRADDDB; SQRADD(a[14], a[14]); 
-   COMBA_STORE(b[28]);
-
-   /* output 29 */
-   CARRY_FORWARD;
-   SQRADDSC(a[6], a[23]); SQRADDAC(a[7], a[22]); SQRADDAC(a[8], a[21]); SQRADDAC(a[9], a[20]); SQRADDAC(a[10], a[19]); SQRADDAC(a[11], a[18]); SQRADDAC(a[12], a[17]); SQRADDAC(a[13], a[16]); SQRADDAC(a[14], a[15]); SQRADDDB; 
-   COMBA_STORE(b[29]);
-
-   /* output 30 */
-   CARRY_FORWARD;
-   SQRADDSC(a[7], a[23]); SQRADDAC(a[8], a[22]); SQRADDAC(a[9], a[21]); SQRADDAC(a[10], a[20]); SQRADDAC(a[11], a[19]); SQRADDAC(a[12], a[18]); SQRADDAC(a[13], a[17]); SQRADDAC(a[14], a[16]); SQRADDDB; SQRADD(a[15], a[15]); 
-   COMBA_STORE(b[30]);
-
-   /* output 31 */
-   CARRY_FORWARD;
-   SQRADDSC(a[8], a[23]); SQRADDAC(a[9], a[22]); SQRADDAC(a[10], a[21]); SQRADDAC(a[11], a[20]); SQRADDAC(a[12], a[19]); SQRADDAC(a[13], a[18]); SQRADDAC(a[14], a[17]); SQRADDAC(a[15], a[16]); SQRADDDB; 
-   COMBA_STORE(b[31]);
-
-   /* output 32 */
-   CARRY_FORWARD;
-   SQRADDSC(a[9], a[23]); SQRADDAC(a[10], a[22]); SQRADDAC(a[11], a[21]); SQRADDAC(a[12], a[20]); SQRADDAC(a[13], a[19]); SQRADDAC(a[14], a[18]); SQRADDAC(a[15], a[17]); SQRADDDB; SQRADD(a[16], a[16]); 
-   COMBA_STORE(b[32]);
-
-   /* output 33 */
-   CARRY_FORWARD;
-   SQRADDSC(a[10], a[23]); SQRADDAC(a[11], a[22]); SQRADDAC(a[12], a[21]); SQRADDAC(a[13], a[20]); SQRADDAC(a[14], a[19]); SQRADDAC(a[15], a[18]); SQRADDAC(a[16], a[17]); SQRADDDB; 
-   COMBA_STORE(b[33]);
-
-   /* output 34 */
-   CARRY_FORWARD;
-   SQRADDSC(a[11], a[23]); SQRADDAC(a[12], a[22]); SQRADDAC(a[13], a[21]); SQRADDAC(a[14], a[20]); SQRADDAC(a[15], a[19]); SQRADDAC(a[16], a[18]); SQRADDDB; SQRADD(a[17], a[17]); 
-   COMBA_STORE(b[34]);
-
-   /* output 35 */
-   CARRY_FORWARD;
-   SQRADDSC(a[12], a[23]); SQRADDAC(a[13], a[22]); SQRADDAC(a[14], a[21]); SQRADDAC(a[15], a[20]); SQRADDAC(a[16], a[19]); SQRADDAC(a[17], a[18]); SQRADDDB; 
-   COMBA_STORE(b[35]);
-
-   /* output 36 */
-   CARRY_FORWARD;
-   SQRADDSC(a[13], a[23]); SQRADDAC(a[14], a[22]); SQRADDAC(a[15], a[21]); SQRADDAC(a[16], a[20]); SQRADDAC(a[17], a[19]); SQRADDDB; SQRADD(a[18], a[18]); 
-   COMBA_STORE(b[36]);
-
-   /* output 37 */
-   CARRY_FORWARD;
-   SQRADDSC(a[14], a[23]); SQRADDAC(a[15], a[22]); SQRADDAC(a[16], a[21]); SQRADDAC(a[17], a[20]); SQRADDAC(a[18], a[19]); SQRADDDB; 
-   COMBA_STORE(b[37]);
-
-   /* output 38 */
-   CARRY_FORWARD;
-   SQRADDSC(a[15], a[23]); SQRADDAC(a[16], a[22]); SQRADDAC(a[17], a[21]); SQRADDAC(a[18], a[20]); SQRADDDB; SQRADD(a[19], a[19]); 
-   COMBA_STORE(b[38]);
-
-   /* output 39 */
-   CARRY_FORWARD;
-   SQRADDSC(a[16], a[23]); SQRADDAC(a[17], a[22]); SQRADDAC(a[18], a[21]); SQRADDAC(a[19], a[20]); SQRADDDB; 
-   COMBA_STORE(b[39]);
-
-   /* output 40 */
-   CARRY_FORWARD;
-   SQRADDSC(a[17], a[23]); SQRADDAC(a[18], a[22]); SQRADDAC(a[19], a[21]); SQRADDDB; SQRADD(a[20], a[20]); 
-   COMBA_STORE(b[40]);
-
-   /* output 41 */
-   CARRY_FORWARD;
-   SQRADDSC(a[18], a[23]); SQRADDAC(a[19], a[22]); SQRADDAC(a[20], a[21]); SQRADDDB; 
-   COMBA_STORE(b[41]);
-
-   /* output 42 */
-   CARRY_FORWARD;
-   SQRADD2(a[19], a[23]); SQRADD2(a[20], a[22]); SQRADD(a[21], a[21]); 
-   COMBA_STORE(b[42]);
-
-   /* output 43 */
-   CARRY_FORWARD;
-   SQRADD2(a[20], a[23]); SQRADD2(a[21], a[22]); 
-   COMBA_STORE(b[43]);
-
-   /* output 44 */
-   CARRY_FORWARD;
-   SQRADD2(a[21], a[23]); SQRADD(a[22], a[22]); 
-   COMBA_STORE(b[44]);
-
-   /* output 45 */
-   CARRY_FORWARD;
-   SQRADD2(a[22], a[23]); 
-   COMBA_STORE(b[45]);
-
-   /* output 46 */
-   CARRY_FORWARD;
-   SQRADD(a[23], a[23]); 
-   COMBA_STORE(b[46]);
-   COMBA_STORE2(b[47]);
-   COMBA_FINI;
-
-   B->used = 48;
-   B->sign = FP_ZPOS;
-   memcpy(B->dp, b, 48 * sizeof(fp_digit));
-   fp_clamp(B);
-}
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_28.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_28.i
deleted file mode 100755
index 08e9bc4..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_28.i
+++ /dev/null
@@ -1,320 +0,0 @@
-/* fp_sqr_comba_28.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SQR28
-void fp_sqr_comba28(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[56], c0, c1, c2, sc0, sc1, sc2;
-#ifdef TFM_ISO
-   fp_word   tt;   
-#endif   
-
-   a = A->dp;
-   COMBA_START; 
-
-   /* clear carries */
-   CLEAR_CARRY;
-
-   /* output 0 */
-   SQRADD(a[0],a[0]);
-   COMBA_STORE(b[0]);
-
-   /* output 1 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[1]); 
-   COMBA_STORE(b[1]);
-
-   /* output 2 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
-   COMBA_STORE(b[2]);
-
-   /* output 3 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
-   COMBA_STORE(b[3]);
-
-   /* output 4 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
-   COMBA_STORE(b[4]);
-
-   /* output 5 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-   COMBA_STORE(b[5]);
-
-   /* output 6 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-   COMBA_STORE(b[6]);
-
-   /* output 7 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-   COMBA_STORE(b[7]);
-
-   /* output 8 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-   COMBA_STORE(b[8]);
-
-   /* output 9 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-   COMBA_STORE(b[9]);
-
-   /* output 10 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-   COMBA_STORE(b[10]);
-
-   /* output 11 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-   COMBA_STORE(b[11]);
-
-   /* output 12 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-   COMBA_STORE(b[12]);
-
-   /* output 13 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-   COMBA_STORE(b[13]);
-
-   /* output 14 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); 
-   COMBA_STORE(b[14]);
-
-   /* output 15 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; 
-   COMBA_STORE(b[15]);
-
-   /* output 16 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); 
-   COMBA_STORE(b[16]);
-
-   /* output 17 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[17]); SQRADDAC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; 
-   COMBA_STORE(b[17]);
-
-   /* output 18 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[18]); SQRADDAC(a[1], a[17]); SQRADDAC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); 
-   COMBA_STORE(b[18]);
-
-   /* output 19 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[19]); SQRADDAC(a[1], a[18]); SQRADDAC(a[2], a[17]); SQRADDAC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; 
-   COMBA_STORE(b[19]);
-
-   /* output 20 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[20]); SQRADDAC(a[1], a[19]); SQRADDAC(a[2], a[18]); SQRADDAC(a[3], a[17]); SQRADDAC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); 
-   COMBA_STORE(b[20]);
-
-   /* output 21 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[21]); SQRADDAC(a[1], a[20]); SQRADDAC(a[2], a[19]); SQRADDAC(a[3], a[18]); SQRADDAC(a[4], a[17]); SQRADDAC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; 
-   COMBA_STORE(b[21]);
-
-   /* output 22 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[22]); SQRADDAC(a[1], a[21]); SQRADDAC(a[2], a[20]); SQRADDAC(a[3], a[19]); SQRADDAC(a[4], a[18]); SQRADDAC(a[5], a[17]); SQRADDAC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); 
-   COMBA_STORE(b[22]);
-
-   /* output 23 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[23]); SQRADDAC(a[1], a[22]); SQRADDAC(a[2], a[21]); SQRADDAC(a[3], a[20]); SQRADDAC(a[4], a[19]); SQRADDAC(a[5], a[18]); SQRADDAC(a[6], a[17]); SQRADDAC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; 
-   COMBA_STORE(b[23]);
-
-   /* output 24 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[24]); SQRADDAC(a[1], a[23]); SQRADDAC(a[2], a[22]); SQRADDAC(a[3], a[21]); SQRADDAC(a[4], a[20]); SQRADDAC(a[5], a[19]); SQRADDAC(a[6], a[18]); SQRADDAC(a[7], a[17]); SQRADDAC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); 
-   COMBA_STORE(b[24]);
-
-   /* output 25 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[25]); SQRADDAC(a[1], a[24]); SQRADDAC(a[2], a[23]); SQRADDAC(a[3], a[22]); SQRADDAC(a[4], a[21]); SQRADDAC(a[5], a[20]); SQRADDAC(a[6], a[19]); SQRADDAC(a[7], a[18]); SQRADDAC(a[8], a[17]); SQRADDAC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; 
-   COMBA_STORE(b[25]);
-
-   /* output 26 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[26]); SQRADDAC(a[1], a[25]); SQRADDAC(a[2], a[24]); SQRADDAC(a[3], a[23]); SQRADDAC(a[4], a[22]); SQRADDAC(a[5], a[21]); SQRADDAC(a[6], a[20]); SQRADDAC(a[7], a[19]); SQRADDAC(a[8], a[18]); SQRADDAC(a[9], a[17]); SQRADDAC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); 
-   COMBA_STORE(b[26]);
-
-   /* output 27 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[27]); SQRADDAC(a[1], a[26]); SQRADDAC(a[2], a[25]); SQRADDAC(a[3], a[24]); SQRADDAC(a[4], a[23]); SQRADDAC(a[5], a[22]); SQRADDAC(a[6], a[21]); SQRADDAC(a[7], a[20]); SQRADDAC(a[8], a[19]); SQRADDAC(a[9], a[18]); SQRADDAC(a[10], a[17]); SQRADDAC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; 
-   COMBA_STORE(b[27]);
-
-   /* output 28 */
-   CARRY_FORWARD;
-   SQRADDSC(a[1], a[27]); SQRADDAC(a[2], a[26]); SQRADDAC(a[3], a[25]); SQRADDAC(a[4], a[24]); SQRADDAC(a[5], a[23]); SQRADDAC(a[6], a[22]); SQRADDAC(a[7], a[21]); SQRADDAC(a[8], a[20]); SQRADDAC(a[9], a[19]); SQRADDAC(a[10], a[18]); SQRADDAC(a[11], a[17]); SQRADDAC(a[12], a[16]); SQRADDAC(a[13], a[15]); SQRADDDB; SQRADD(a[14], a[14]); 
-   COMBA_STORE(b[28]);
-
-   /* output 29 */
-   CARRY_FORWARD;
-   SQRADDSC(a[2], a[27]); SQRADDAC(a[3], a[26]); SQRADDAC(a[4], a[25]); SQRADDAC(a[5], a[24]); SQRADDAC(a[6], a[23]); SQRADDAC(a[7], a[22]); SQRADDAC(a[8], a[21]); SQRADDAC(a[9], a[20]); SQRADDAC(a[10], a[19]); SQRADDAC(a[11], a[18]); SQRADDAC(a[12], a[17]); SQRADDAC(a[13], a[16]); SQRADDAC(a[14], a[15]); SQRADDDB; 
-   COMBA_STORE(b[29]);
-
-   /* output 30 */
-   CARRY_FORWARD;
-   SQRADDSC(a[3], a[27]); SQRADDAC(a[4], a[26]); SQRADDAC(a[5], a[25]); SQRADDAC(a[6], a[24]); SQRADDAC(a[7], a[23]); SQRADDAC(a[8], a[22]); SQRADDAC(a[9], a[21]); SQRADDAC(a[10], a[20]); SQRADDAC(a[11], a[19]); SQRADDAC(a[12], a[18]); SQRADDAC(a[13], a[17]); SQRADDAC(a[14], a[16]); SQRADDDB; SQRADD(a[15], a[15]); 
-   COMBA_STORE(b[30]);
-
-   /* output 31 */
-   CARRY_FORWARD;
-   SQRADDSC(a[4], a[27]); SQRADDAC(a[5], a[26]); SQRADDAC(a[6], a[25]); SQRADDAC(a[7], a[24]); SQRADDAC(a[8], a[23]); SQRADDAC(a[9], a[22]); SQRADDAC(a[10], a[21]); SQRADDAC(a[11], a[20]); SQRADDAC(a[12], a[19]); SQRADDAC(a[13], a[18]); SQRADDAC(a[14], a[17]); SQRADDAC(a[15], a[16]); SQRADDDB; 
-   COMBA_STORE(b[31]);
-
-   /* output 32 */
-   CARRY_FORWARD;
-   SQRADDSC(a[5], a[27]); SQRADDAC(a[6], a[26]); SQRADDAC(a[7], a[25]); SQRADDAC(a[8], a[24]); SQRADDAC(a[9], a[23]); SQRADDAC(a[10], a[22]); SQRADDAC(a[11], a[21]); SQRADDAC(a[12], a[20]); SQRADDAC(a[13], a[19]); SQRADDAC(a[14], a[18]); SQRADDAC(a[15], a[17]); SQRADDDB; SQRADD(a[16], a[16]); 
-   COMBA_STORE(b[32]);
-
-   /* output 33 */
-   CARRY_FORWARD;
-   SQRADDSC(a[6], a[27]); SQRADDAC(a[7], a[26]); SQRADDAC(a[8], a[25]); SQRADDAC(a[9], a[24]); SQRADDAC(a[10], a[23]); SQRADDAC(a[11], a[22]); SQRADDAC(a[12], a[21]); SQRADDAC(a[13], a[20]); SQRADDAC(a[14], a[19]); SQRADDAC(a[15], a[18]); SQRADDAC(a[16], a[17]); SQRADDDB; 
-   COMBA_STORE(b[33]);
-
-   /* output 34 */
-   CARRY_FORWARD;
-   SQRADDSC(a[7], a[27]); SQRADDAC(a[8], a[26]); SQRADDAC(a[9], a[25]); SQRADDAC(a[10], a[24]); SQRADDAC(a[11], a[23]); SQRADDAC(a[12], a[22]); SQRADDAC(a[13], a[21]); SQRADDAC(a[14], a[20]); SQRADDAC(a[15], a[19]); SQRADDAC(a[16], a[18]); SQRADDDB; SQRADD(a[17], a[17]); 
-   COMBA_STORE(b[34]);
-
-   /* output 35 */
-   CARRY_FORWARD;
-   SQRADDSC(a[8], a[27]); SQRADDAC(a[9], a[26]); SQRADDAC(a[10], a[25]); SQRADDAC(a[11], a[24]); SQRADDAC(a[12], a[23]); SQRADDAC(a[13], a[22]); SQRADDAC(a[14], a[21]); SQRADDAC(a[15], a[20]); SQRADDAC(a[16], a[19]); SQRADDAC(a[17], a[18]); SQRADDDB; 
-   COMBA_STORE(b[35]);
-
-   /* output 36 */
-   CARRY_FORWARD;
-   SQRADDSC(a[9], a[27]); SQRADDAC(a[10], a[26]); SQRADDAC(a[11], a[25]); SQRADDAC(a[12], a[24]); SQRADDAC(a[13], a[23]); SQRADDAC(a[14], a[22]); SQRADDAC(a[15], a[21]); SQRADDAC(a[16], a[20]); SQRADDAC(a[17], a[19]); SQRADDDB; SQRADD(a[18], a[18]); 
-   COMBA_STORE(b[36]);
-
-   /* output 37 */
-   CARRY_FORWARD;
-   SQRADDSC(a[10], a[27]); SQRADDAC(a[11], a[26]); SQRADDAC(a[12], a[25]); SQRADDAC(a[13], a[24]); SQRADDAC(a[14], a[23]); SQRADDAC(a[15], a[22]); SQRADDAC(a[16], a[21]); SQRADDAC(a[17], a[20]); SQRADDAC(a[18], a[19]); SQRADDDB; 
-   COMBA_STORE(b[37]);
-
-   /* output 38 */
-   CARRY_FORWARD;
-   SQRADDSC(a[11], a[27]); SQRADDAC(a[12], a[26]); SQRADDAC(a[13], a[25]); SQRADDAC(a[14], a[24]); SQRADDAC(a[15], a[23]); SQRADDAC(a[16], a[22]); SQRADDAC(a[17], a[21]); SQRADDAC(a[18], a[20]); SQRADDDB; SQRADD(a[19], a[19]); 
-   COMBA_STORE(b[38]);
-
-   /* output 39 */
-   CARRY_FORWARD;
-   SQRADDSC(a[12], a[27]); SQRADDAC(a[13], a[26]); SQRADDAC(a[14], a[25]); SQRADDAC(a[15], a[24]); SQRADDAC(a[16], a[23]); SQRADDAC(a[17], a[22]); SQRADDAC(a[18], a[21]); SQRADDAC(a[19], a[20]); SQRADDDB; 
-   COMBA_STORE(b[39]);
-
-   /* output 40 */
-   CARRY_FORWARD;
-   SQRADDSC(a[13], a[27]); SQRADDAC(a[14], a[26]); SQRADDAC(a[15], a[25]); SQRADDAC(a[16], a[24]); SQRADDAC(a[17], a[23]); SQRADDAC(a[18], a[22]); SQRADDAC(a[19], a[21]); SQRADDDB; SQRADD(a[20], a[20]); 
-   COMBA_STORE(b[40]);
-
-   /* output 41 */
-   CARRY_FORWARD;
-   SQRADDSC(a[14], a[27]); SQRADDAC(a[15], a[26]); SQRADDAC(a[16], a[25]); SQRADDAC(a[17], a[24]); SQRADDAC(a[18], a[23]); SQRADDAC(a[19], a[22]); SQRADDAC(a[20], a[21]); SQRADDDB; 
-   COMBA_STORE(b[41]);
-
-   /* output 42 */
-   CARRY_FORWARD;
-   SQRADDSC(a[15], a[27]); SQRADDAC(a[16], a[26]); SQRADDAC(a[17], a[25]); SQRADDAC(a[18], a[24]); SQRADDAC(a[19], a[23]); SQRADDAC(a[20], a[22]); SQRADDDB; SQRADD(a[21], a[21]); 
-   COMBA_STORE(b[42]);
-
-   /* output 43 */
-   CARRY_FORWARD;
-   SQRADDSC(a[16], a[27]); SQRADDAC(a[17], a[26]); SQRADDAC(a[18], a[25]); SQRADDAC(a[19], a[24]); SQRADDAC(a[20], a[23]); SQRADDAC(a[21], a[22]); SQRADDDB; 
-   COMBA_STORE(b[43]);
-
-   /* output 44 */
-   CARRY_FORWARD;
-   SQRADDSC(a[17], a[27]); SQRADDAC(a[18], a[26]); SQRADDAC(a[19], a[25]); SQRADDAC(a[20], a[24]); SQRADDAC(a[21], a[23]); SQRADDDB; SQRADD(a[22], a[22]); 
-   COMBA_STORE(b[44]);
-
-   /* output 45 */
-   CARRY_FORWARD;
-   SQRADDSC(a[18], a[27]); SQRADDAC(a[19], a[26]); SQRADDAC(a[20], a[25]); SQRADDAC(a[21], a[24]); SQRADDAC(a[22], a[23]); SQRADDDB; 
-   COMBA_STORE(b[45]);
-
-   /* output 46 */
-   CARRY_FORWARD;
-   SQRADDSC(a[19], a[27]); SQRADDAC(a[20], a[26]); SQRADDAC(a[21], a[25]); SQRADDAC(a[22], a[24]); SQRADDDB; SQRADD(a[23], a[23]); 
-   COMBA_STORE(b[46]);
-
-   /* output 47 */
-   CARRY_FORWARD;
-   SQRADDSC(a[20], a[27]); SQRADDAC(a[21], a[26]); SQRADDAC(a[22], a[25]); SQRADDAC(a[23], a[24]); SQRADDDB; 
-   COMBA_STORE(b[47]);
-
-   /* output 48 */
-   CARRY_FORWARD;
-   SQRADDSC(a[21], a[27]); SQRADDAC(a[22], a[26]); SQRADDAC(a[23], a[25]); SQRADDDB; SQRADD(a[24], a[24]); 
-   COMBA_STORE(b[48]);
-
-   /* output 49 */
-   CARRY_FORWARD;
-   SQRADDSC(a[22], a[27]); SQRADDAC(a[23], a[26]); SQRADDAC(a[24], a[25]); SQRADDDB; 
-   COMBA_STORE(b[49]);
-
-   /* output 50 */
-   CARRY_FORWARD;
-   SQRADD2(a[23], a[27]); SQRADD2(a[24], a[26]); SQRADD(a[25], a[25]); 
-   COMBA_STORE(b[50]);
-
-   /* output 51 */
-   CARRY_FORWARD;
-   SQRADD2(a[24], a[27]); SQRADD2(a[25], a[26]); 
-   COMBA_STORE(b[51]);
-
-   /* output 52 */
-   CARRY_FORWARD;
-   SQRADD2(a[25], a[27]); SQRADD(a[26], a[26]); 
-   COMBA_STORE(b[52]);
-
-   /* output 53 */
-   CARRY_FORWARD;
-   SQRADD2(a[26], a[27]); 
-   COMBA_STORE(b[53]);
-
-   /* output 54 */
-   CARRY_FORWARD;
-   SQRADD(a[27], a[27]); 
-   COMBA_STORE(b[54]);
-   COMBA_STORE2(b[55]);
-   COMBA_FINI;
-
-   B->used = 56;
-   B->sign = FP_ZPOS;
-   memcpy(B->dp, b, 56 * sizeof(fp_digit));
-   fp_clamp(B);
-}
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_3.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_3.i
deleted file mode 100755
index b475409..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_3.i
+++ /dev/null
@@ -1,70 +0,0 @@
-/* fp_sqr_comba_3.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SQR3
-void fp_sqr_comba3(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[6], c0, c1, c2;
-#ifdef TFM_ISO
-   fp_word tt;
-#endif
-
-   a = A->dp;
-   COMBA_START; 
-
-   /* clear carries */
-   CLEAR_CARRY;
-
-   /* output 0 */
-   SQRADD(a[0],a[0]);
-   COMBA_STORE(b[0]);
-
-   /* output 1 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[1]); 
-   COMBA_STORE(b[1]);
-
-   /* output 2 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
-   COMBA_STORE(b[2]);
-
-   /* output 3 */
-   CARRY_FORWARD;
-   SQRADD2(a[1], a[2]); 
-   COMBA_STORE(b[3]);
-
-   /* output 4 */
-   CARRY_FORWARD;
-   SQRADD(a[2], a[2]); 
-   COMBA_STORE(b[4]);
-   COMBA_STORE2(b[5]);
-   COMBA_FINI;
-
-   B->used = 6;
-   B->sign = FP_ZPOS;
-   memcpy(B->dp, b, 6 * sizeof(fp_digit));
-   fp_clamp(B);
-}
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_32.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_32.i
deleted file mode 100755
index 4a35d74..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_32.i
+++ /dev/null
@@ -1,360 +0,0 @@
-/* fp_sqr_comba_32.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SQR32
-void fp_sqr_comba32(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[64], c0, c1, c2, sc0, sc1, sc2;
-#ifdef TFM_ISO
-   fp_word   tt;   
-#endif   
-
-   a = A->dp;
-   COMBA_START; 
-
-   /* clear carries */
-   CLEAR_CARRY;
-
-   /* output 0 */
-   SQRADD(a[0],a[0]);
-   COMBA_STORE(b[0]);
-
-   /* output 1 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[1]); 
-   COMBA_STORE(b[1]);
-
-   /* output 2 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
-   COMBA_STORE(b[2]);
-
-   /* output 3 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
-   COMBA_STORE(b[3]);
-
-   /* output 4 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
-   COMBA_STORE(b[4]);
-
-   /* output 5 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-   COMBA_STORE(b[5]);
-
-   /* output 6 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-   COMBA_STORE(b[6]);
-
-   /* output 7 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-   COMBA_STORE(b[7]);
-
-   /* output 8 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-   COMBA_STORE(b[8]);
-
-   /* output 9 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-   COMBA_STORE(b[9]);
-
-   /* output 10 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-   COMBA_STORE(b[10]);
-
-   /* output 11 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-   COMBA_STORE(b[11]);
-
-   /* output 12 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-   COMBA_STORE(b[12]);
-
-   /* output 13 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-   COMBA_STORE(b[13]);
-
-   /* output 14 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); 
-   COMBA_STORE(b[14]);
-
-   /* output 15 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; 
-   COMBA_STORE(b[15]);
-
-   /* output 16 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); 
-   COMBA_STORE(b[16]);
-
-   /* output 17 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[17]); SQRADDAC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; 
-   COMBA_STORE(b[17]);
-
-   /* output 18 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[18]); SQRADDAC(a[1], a[17]); SQRADDAC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); 
-   COMBA_STORE(b[18]);
-
-   /* output 19 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[19]); SQRADDAC(a[1], a[18]); SQRADDAC(a[2], a[17]); SQRADDAC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; 
-   COMBA_STORE(b[19]);
-
-   /* output 20 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[20]); SQRADDAC(a[1], a[19]); SQRADDAC(a[2], a[18]); SQRADDAC(a[3], a[17]); SQRADDAC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); 
-   COMBA_STORE(b[20]);
-
-   /* output 21 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[21]); SQRADDAC(a[1], a[20]); SQRADDAC(a[2], a[19]); SQRADDAC(a[3], a[18]); SQRADDAC(a[4], a[17]); SQRADDAC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; 
-   COMBA_STORE(b[21]);
-
-   /* output 22 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[22]); SQRADDAC(a[1], a[21]); SQRADDAC(a[2], a[20]); SQRADDAC(a[3], a[19]); SQRADDAC(a[4], a[18]); SQRADDAC(a[5], a[17]); SQRADDAC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); 
-   COMBA_STORE(b[22]);
-
-   /* output 23 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[23]); SQRADDAC(a[1], a[22]); SQRADDAC(a[2], a[21]); SQRADDAC(a[3], a[20]); SQRADDAC(a[4], a[19]); SQRADDAC(a[5], a[18]); SQRADDAC(a[6], a[17]); SQRADDAC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; 
-   COMBA_STORE(b[23]);
-
-   /* output 24 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[24]); SQRADDAC(a[1], a[23]); SQRADDAC(a[2], a[22]); SQRADDAC(a[3], a[21]); SQRADDAC(a[4], a[20]); SQRADDAC(a[5], a[19]); SQRADDAC(a[6], a[18]); SQRADDAC(a[7], a[17]); SQRADDAC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); 
-   COMBA_STORE(b[24]);
-
-   /* output 25 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[25]); SQRADDAC(a[1], a[24]); SQRADDAC(a[2], a[23]); SQRADDAC(a[3], a[22]); SQRADDAC(a[4], a[21]); SQRADDAC(a[5], a[20]); SQRADDAC(a[6], a[19]); SQRADDAC(a[7], a[18]); SQRADDAC(a[8], a[17]); SQRADDAC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; 
-   COMBA_STORE(b[25]);
-
-   /* output 26 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[26]); SQRADDAC(a[1], a[25]); SQRADDAC(a[2], a[24]); SQRADDAC(a[3], a[23]); SQRADDAC(a[4], a[22]); SQRADDAC(a[5], a[21]); SQRADDAC(a[6], a[20]); SQRADDAC(a[7], a[19]); SQRADDAC(a[8], a[18]); SQRADDAC(a[9], a[17]); SQRADDAC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); 
-   COMBA_STORE(b[26]);
-
-   /* output 27 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[27]); SQRADDAC(a[1], a[26]); SQRADDAC(a[2], a[25]); SQRADDAC(a[3], a[24]); SQRADDAC(a[4], a[23]); SQRADDAC(a[5], a[22]); SQRADDAC(a[6], a[21]); SQRADDAC(a[7], a[20]); SQRADDAC(a[8], a[19]); SQRADDAC(a[9], a[18]); SQRADDAC(a[10], a[17]); SQRADDAC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; 
-   COMBA_STORE(b[27]);
-
-   /* output 28 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[28]); SQRADDAC(a[1], a[27]); SQRADDAC(a[2], a[26]); SQRADDAC(a[3], a[25]); SQRADDAC(a[4], a[24]); SQRADDAC(a[5], a[23]); SQRADDAC(a[6], a[22]); SQRADDAC(a[7], a[21]); SQRADDAC(a[8], a[20]); SQRADDAC(a[9], a[19]); SQRADDAC(a[10], a[18]); SQRADDAC(a[11], a[17]); SQRADDAC(a[12], a[16]); SQRADDAC(a[13], a[15]); SQRADDDB; SQRADD(a[14], a[14]); 
-   COMBA_STORE(b[28]);
-
-   /* output 29 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[29]); SQRADDAC(a[1], a[28]); SQRADDAC(a[2], a[27]); SQRADDAC(a[3], a[26]); SQRADDAC(a[4], a[25]); SQRADDAC(a[5], a[24]); SQRADDAC(a[6], a[23]); SQRADDAC(a[7], a[22]); SQRADDAC(a[8], a[21]); SQRADDAC(a[9], a[20]); SQRADDAC(a[10], a[19]); SQRADDAC(a[11], a[18]); SQRADDAC(a[12], a[17]); SQRADDAC(a[13], a[16]); SQRADDAC(a[14], a[15]); SQRADDDB; 
-   COMBA_STORE(b[29]);
-
-   /* output 30 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[30]); SQRADDAC(a[1], a[29]); SQRADDAC(a[2], a[28]); SQRADDAC(a[3], a[27]); SQRADDAC(a[4], a[26]); SQRADDAC(a[5], a[25]); SQRADDAC(a[6], a[24]); SQRADDAC(a[7], a[23]); SQRADDAC(a[8], a[22]); SQRADDAC(a[9], a[21]); SQRADDAC(a[10], a[20]); SQRADDAC(a[11], a[19]); SQRADDAC(a[12], a[18]); SQRADDAC(a[13], a[17]); SQRADDAC(a[14], a[16]); SQRADDDB; SQRADD(a[15], a[15]); 
-   COMBA_STORE(b[30]);
-
-   /* output 31 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[31]); SQRADDAC(a[1], a[30]); SQRADDAC(a[2], a[29]); SQRADDAC(a[3], a[28]); SQRADDAC(a[4], a[27]); SQRADDAC(a[5], a[26]); SQRADDAC(a[6], a[25]); SQRADDAC(a[7], a[24]); SQRADDAC(a[8], a[23]); SQRADDAC(a[9], a[22]); SQRADDAC(a[10], a[21]); SQRADDAC(a[11], a[20]); SQRADDAC(a[12], a[19]); SQRADDAC(a[13], a[18]); SQRADDAC(a[14], a[17]); SQRADDAC(a[15], a[16]); SQRADDDB; 
-   COMBA_STORE(b[31]);
-
-   /* output 32 */
-   CARRY_FORWARD;
-   SQRADDSC(a[1], a[31]); SQRADDAC(a[2], a[30]); SQRADDAC(a[3], a[29]); SQRADDAC(a[4], a[28]); SQRADDAC(a[5], a[27]); SQRADDAC(a[6], a[26]); SQRADDAC(a[7], a[25]); SQRADDAC(a[8], a[24]); SQRADDAC(a[9], a[23]); SQRADDAC(a[10], a[22]); SQRADDAC(a[11], a[21]); SQRADDAC(a[12], a[20]); SQRADDAC(a[13], a[19]); SQRADDAC(a[14], a[18]); SQRADDAC(a[15], a[17]); SQRADDDB; SQRADD(a[16], a[16]); 
-   COMBA_STORE(b[32]);
-
-   /* output 33 */
-   CARRY_FORWARD;
-   SQRADDSC(a[2], a[31]); SQRADDAC(a[3], a[30]); SQRADDAC(a[4], a[29]); SQRADDAC(a[5], a[28]); SQRADDAC(a[6], a[27]); SQRADDAC(a[7], a[26]); SQRADDAC(a[8], a[25]); SQRADDAC(a[9], a[24]); SQRADDAC(a[10], a[23]); SQRADDAC(a[11], a[22]); SQRADDAC(a[12], a[21]); SQRADDAC(a[13], a[20]); SQRADDAC(a[14], a[19]); SQRADDAC(a[15], a[18]); SQRADDAC(a[16], a[17]); SQRADDDB; 
-   COMBA_STORE(b[33]);
-
-   /* output 34 */
-   CARRY_FORWARD;
-   SQRADDSC(a[3], a[31]); SQRADDAC(a[4], a[30]); SQRADDAC(a[5], a[29]); SQRADDAC(a[6], a[28]); SQRADDAC(a[7], a[27]); SQRADDAC(a[8], a[26]); SQRADDAC(a[9], a[25]); SQRADDAC(a[10], a[24]); SQRADDAC(a[11], a[23]); SQRADDAC(a[12], a[22]); SQRADDAC(a[13], a[21]); SQRADDAC(a[14], a[20]); SQRADDAC(a[15], a[19]); SQRADDAC(a[16], a[18]); SQRADDDB; SQRADD(a[17], a[17]); 
-   COMBA_STORE(b[34]);
-
-   /* output 35 */
-   CARRY_FORWARD;
-   SQRADDSC(a[4], a[31]); SQRADDAC(a[5], a[30]); SQRADDAC(a[6], a[29]); SQRADDAC(a[7], a[28]); SQRADDAC(a[8], a[27]); SQRADDAC(a[9], a[26]); SQRADDAC(a[10], a[25]); SQRADDAC(a[11], a[24]); SQRADDAC(a[12], a[23]); SQRADDAC(a[13], a[22]); SQRADDAC(a[14], a[21]); SQRADDAC(a[15], a[20]); SQRADDAC(a[16], a[19]); SQRADDAC(a[17], a[18]); SQRADDDB; 
-   COMBA_STORE(b[35]);
-
-   /* output 36 */
-   CARRY_FORWARD;
-   SQRADDSC(a[5], a[31]); SQRADDAC(a[6], a[30]); SQRADDAC(a[7], a[29]); SQRADDAC(a[8], a[28]); SQRADDAC(a[9], a[27]); SQRADDAC(a[10], a[26]); SQRADDAC(a[11], a[25]); SQRADDAC(a[12], a[24]); SQRADDAC(a[13], a[23]); SQRADDAC(a[14], a[22]); SQRADDAC(a[15], a[21]); SQRADDAC(a[16], a[20]); SQRADDAC(a[17], a[19]); SQRADDDB; SQRADD(a[18], a[18]); 
-   COMBA_STORE(b[36]);
-
-   /* output 37 */
-   CARRY_FORWARD;
-   SQRADDSC(a[6], a[31]); SQRADDAC(a[7], a[30]); SQRADDAC(a[8], a[29]); SQRADDAC(a[9], a[28]); SQRADDAC(a[10], a[27]); SQRADDAC(a[11], a[26]); SQRADDAC(a[12], a[25]); SQRADDAC(a[13], a[24]); SQRADDAC(a[14], a[23]); SQRADDAC(a[15], a[22]); SQRADDAC(a[16], a[21]); SQRADDAC(a[17], a[20]); SQRADDAC(a[18], a[19]); SQRADDDB; 
-   COMBA_STORE(b[37]);
-
-   /* output 38 */
-   CARRY_FORWARD;
-   SQRADDSC(a[7], a[31]); SQRADDAC(a[8], a[30]); SQRADDAC(a[9], a[29]); SQRADDAC(a[10], a[28]); SQRADDAC(a[11], a[27]); SQRADDAC(a[12], a[26]); SQRADDAC(a[13], a[25]); SQRADDAC(a[14], a[24]); SQRADDAC(a[15], a[23]); SQRADDAC(a[16], a[22]); SQRADDAC(a[17], a[21]); SQRADDAC(a[18], a[20]); SQRADDDB; SQRADD(a[19], a[19]); 
-   COMBA_STORE(b[38]);
-
-   /* output 39 */
-   CARRY_FORWARD;
-   SQRADDSC(a[8], a[31]); SQRADDAC(a[9], a[30]); SQRADDAC(a[10], a[29]); SQRADDAC(a[11], a[28]); SQRADDAC(a[12], a[27]); SQRADDAC(a[13], a[26]); SQRADDAC(a[14], a[25]); SQRADDAC(a[15], a[24]); SQRADDAC(a[16], a[23]); SQRADDAC(a[17], a[22]); SQRADDAC(a[18], a[21]); SQRADDAC(a[19], a[20]); SQRADDDB; 
-   COMBA_STORE(b[39]);
-
-   /* output 40 */
-   CARRY_FORWARD;
-   SQRADDSC(a[9], a[31]); SQRADDAC(a[10], a[30]); SQRADDAC(a[11], a[29]); SQRADDAC(a[12], a[28]); SQRADDAC(a[13], a[27]); SQRADDAC(a[14], a[26]); SQRADDAC(a[15], a[25]); SQRADDAC(a[16], a[24]); SQRADDAC(a[17], a[23]); SQRADDAC(a[18], a[22]); SQRADDAC(a[19], a[21]); SQRADDDB; SQRADD(a[20], a[20]); 
-   COMBA_STORE(b[40]);
-
-   /* output 41 */
-   CARRY_FORWARD;
-   SQRADDSC(a[10], a[31]); SQRADDAC(a[11], a[30]); SQRADDAC(a[12], a[29]); SQRADDAC(a[13], a[28]); SQRADDAC(a[14], a[27]); SQRADDAC(a[15], a[26]); SQRADDAC(a[16], a[25]); SQRADDAC(a[17], a[24]); SQRADDAC(a[18], a[23]); SQRADDAC(a[19], a[22]); SQRADDAC(a[20], a[21]); SQRADDDB; 
-   COMBA_STORE(b[41]);
-
-   /* output 42 */
-   CARRY_FORWARD;
-   SQRADDSC(a[11], a[31]); SQRADDAC(a[12], a[30]); SQRADDAC(a[13], a[29]); SQRADDAC(a[14], a[28]); SQRADDAC(a[15], a[27]); SQRADDAC(a[16], a[26]); SQRADDAC(a[17], a[25]); SQRADDAC(a[18], a[24]); SQRADDAC(a[19], a[23]); SQRADDAC(a[20], a[22]); SQRADDDB; SQRADD(a[21], a[21]); 
-   COMBA_STORE(b[42]);
-
-   /* output 43 */
-   CARRY_FORWARD;
-   SQRADDSC(a[12], a[31]); SQRADDAC(a[13], a[30]); SQRADDAC(a[14], a[29]); SQRADDAC(a[15], a[28]); SQRADDAC(a[16], a[27]); SQRADDAC(a[17], a[26]); SQRADDAC(a[18], a[25]); SQRADDAC(a[19], a[24]); SQRADDAC(a[20], a[23]); SQRADDAC(a[21], a[22]); SQRADDDB; 
-   COMBA_STORE(b[43]);
-
-   /* output 44 */
-   CARRY_FORWARD;
-   SQRADDSC(a[13], a[31]); SQRADDAC(a[14], a[30]); SQRADDAC(a[15], a[29]); SQRADDAC(a[16], a[28]); SQRADDAC(a[17], a[27]); SQRADDAC(a[18], a[26]); SQRADDAC(a[19], a[25]); SQRADDAC(a[20], a[24]); SQRADDAC(a[21], a[23]); SQRADDDB; SQRADD(a[22], a[22]); 
-   COMBA_STORE(b[44]);
-
-   /* output 45 */
-   CARRY_FORWARD;
-   SQRADDSC(a[14], a[31]); SQRADDAC(a[15], a[30]); SQRADDAC(a[16], a[29]); SQRADDAC(a[17], a[28]); SQRADDAC(a[18], a[27]); SQRADDAC(a[19], a[26]); SQRADDAC(a[20], a[25]); SQRADDAC(a[21], a[24]); SQRADDAC(a[22], a[23]); SQRADDDB; 
-   COMBA_STORE(b[45]);
-
-   /* output 46 */
-   CARRY_FORWARD;
-   SQRADDSC(a[15], a[31]); SQRADDAC(a[16], a[30]); SQRADDAC(a[17], a[29]); SQRADDAC(a[18], a[28]); SQRADDAC(a[19], a[27]); SQRADDAC(a[20], a[26]); SQRADDAC(a[21], a[25]); SQRADDAC(a[22], a[24]); SQRADDDB; SQRADD(a[23], a[23]); 
-   COMBA_STORE(b[46]);
-
-   /* output 47 */
-   CARRY_FORWARD;
-   SQRADDSC(a[16], a[31]); SQRADDAC(a[17], a[30]); SQRADDAC(a[18], a[29]); SQRADDAC(a[19], a[28]); SQRADDAC(a[20], a[27]); SQRADDAC(a[21], a[26]); SQRADDAC(a[22], a[25]); SQRADDAC(a[23], a[24]); SQRADDDB; 
-   COMBA_STORE(b[47]);
-
-   /* output 48 */
-   CARRY_FORWARD;
-   SQRADDSC(a[17], a[31]); SQRADDAC(a[18], a[30]); SQRADDAC(a[19], a[29]); SQRADDAC(a[20], a[28]); SQRADDAC(a[21], a[27]); SQRADDAC(a[22], a[26]); SQRADDAC(a[23], a[25]); SQRADDDB; SQRADD(a[24], a[24]); 
-   COMBA_STORE(b[48]);
-
-   /* output 49 */
-   CARRY_FORWARD;
-   SQRADDSC(a[18], a[31]); SQRADDAC(a[19], a[30]); SQRADDAC(a[20], a[29]); SQRADDAC(a[21], a[28]); SQRADDAC(a[22], a[27]); SQRADDAC(a[23], a[26]); SQRADDAC(a[24], a[25]); SQRADDDB; 
-   COMBA_STORE(b[49]);
-
-   /* output 50 */
-   CARRY_FORWARD;
-   SQRADDSC(a[19], a[31]); SQRADDAC(a[20], a[30]); SQRADDAC(a[21], a[29]); SQRADDAC(a[22], a[28]); SQRADDAC(a[23], a[27]); SQRADDAC(a[24], a[26]); SQRADDDB; SQRADD(a[25], a[25]); 
-   COMBA_STORE(b[50]);
-
-   /* output 51 */
-   CARRY_FORWARD;
-   SQRADDSC(a[20], a[31]); SQRADDAC(a[21], a[30]); SQRADDAC(a[22], a[29]); SQRADDAC(a[23], a[28]); SQRADDAC(a[24], a[27]); SQRADDAC(a[25], a[26]); SQRADDDB; 
-   COMBA_STORE(b[51]);
-
-   /* output 52 */
-   CARRY_FORWARD;
-   SQRADDSC(a[21], a[31]); SQRADDAC(a[22], a[30]); SQRADDAC(a[23], a[29]); SQRADDAC(a[24], a[28]); SQRADDAC(a[25], a[27]); SQRADDDB; SQRADD(a[26], a[26]); 
-   COMBA_STORE(b[52]);
-
-   /* output 53 */
-   CARRY_FORWARD;
-   SQRADDSC(a[22], a[31]); SQRADDAC(a[23], a[30]); SQRADDAC(a[24], a[29]); SQRADDAC(a[25], a[28]); SQRADDAC(a[26], a[27]); SQRADDDB; 
-   COMBA_STORE(b[53]);
-
-   /* output 54 */
-   CARRY_FORWARD;
-   SQRADDSC(a[23], a[31]); SQRADDAC(a[24], a[30]); SQRADDAC(a[25], a[29]); SQRADDAC(a[26], a[28]); SQRADDDB; SQRADD(a[27], a[27]); 
-   COMBA_STORE(b[54]);
-
-   /* output 55 */
-   CARRY_FORWARD;
-   SQRADDSC(a[24], a[31]); SQRADDAC(a[25], a[30]); SQRADDAC(a[26], a[29]); SQRADDAC(a[27], a[28]); SQRADDDB; 
-   COMBA_STORE(b[55]);
-
-   /* output 56 */
-   CARRY_FORWARD;
-   SQRADDSC(a[25], a[31]); SQRADDAC(a[26], a[30]); SQRADDAC(a[27], a[29]); SQRADDDB; SQRADD(a[28], a[28]); 
-   COMBA_STORE(b[56]);
-
-   /* output 57 */
-   CARRY_FORWARD;
-   SQRADDSC(a[26], a[31]); SQRADDAC(a[27], a[30]); SQRADDAC(a[28], a[29]); SQRADDDB; 
-   COMBA_STORE(b[57]);
-
-   /* output 58 */
-   CARRY_FORWARD;
-   SQRADD2(a[27], a[31]); SQRADD2(a[28], a[30]); SQRADD(a[29], a[29]); 
-   COMBA_STORE(b[58]);
-
-   /* output 59 */
-   CARRY_FORWARD;
-   SQRADD2(a[28], a[31]); SQRADD2(a[29], a[30]); 
-   COMBA_STORE(b[59]);
-
-   /* output 60 */
-   CARRY_FORWARD;
-   SQRADD2(a[29], a[31]); SQRADD(a[30], a[30]); 
-   COMBA_STORE(b[60]);
-
-   /* output 61 */
-   CARRY_FORWARD;
-   SQRADD2(a[30], a[31]); 
-   COMBA_STORE(b[61]);
-
-   /* output 62 */
-   CARRY_FORWARD;
-   SQRADD(a[31], a[31]); 
-   COMBA_STORE(b[62]);
-   COMBA_STORE2(b[63]);
-   COMBA_FINI;
-
-   B->used = 64;
-   B->sign = FP_ZPOS;
-   memcpy(B->dp, b, 64 * sizeof(fp_digit));
-   fp_clamp(B);
-}
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_4.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_4.i
deleted file mode 100755
index bb09dc8..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_4.i
+++ /dev/null
@@ -1,80 +0,0 @@
-/* fp_sqr_comba_4.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SQR4
-void fp_sqr_comba4(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[8], c0, c1, c2;
-#ifdef TFM_ISO
-   fp_word tt;
-#endif
-
-   a = A->dp;
-   COMBA_START; 
-
-   /* clear carries */
-   CLEAR_CARRY;
-
-   /* output 0 */
-   SQRADD(a[0],a[0]);
-   COMBA_STORE(b[0]);
-
-   /* output 1 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[1]); 
-   COMBA_STORE(b[1]);
-
-   /* output 2 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
-   COMBA_STORE(b[2]);
-
-   /* output 3 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
-   COMBA_STORE(b[3]);
-
-   /* output 4 */
-   CARRY_FORWARD;
-   SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
-   COMBA_STORE(b[4]);
-
-   /* output 5 */
-   CARRY_FORWARD;
-   SQRADD2(a[2], a[3]); 
-   COMBA_STORE(b[5]);
-
-   /* output 6 */
-   CARRY_FORWARD;
-   SQRADD(a[3], a[3]); 
-   COMBA_STORE(b[6]);
-   COMBA_STORE2(b[7]);
-   COMBA_FINI;
-
-   B->used = 8;
-   B->sign = FP_ZPOS;
-   memcpy(B->dp, b, 8 * sizeof(fp_digit));
-   fp_clamp(B);
-}
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_48.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_48.i
deleted file mode 100755
index cbaac02..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_48.i
+++ /dev/null
@@ -1,520 +0,0 @@
-/* fp_sqr_comba_48.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SQR48
-void fp_sqr_comba48(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[96], c0, c1, c2, sc0, sc1, sc2;
-#ifdef TFM_ISO
-   fp_word   tt;   
-#endif   
-
-   a = A->dp;
-   COMBA_START; 
-
-   /* clear carries */
-   CLEAR_CARRY;
-
-   /* output 0 */
-   SQRADD(a[0],a[0]);
-   COMBA_STORE(b[0]);
-
-   /* output 1 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[1]); 
-   COMBA_STORE(b[1]);
-
-   /* output 2 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
-   COMBA_STORE(b[2]);
-
-   /* output 3 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
-   COMBA_STORE(b[3]);
-
-   /* output 4 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
-   COMBA_STORE(b[4]);
-
-   /* output 5 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-   COMBA_STORE(b[5]);
-
-   /* output 6 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-   COMBA_STORE(b[6]);
-
-   /* output 7 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-   COMBA_STORE(b[7]);
-
-   /* output 8 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-   COMBA_STORE(b[8]);
-
-   /* output 9 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-   COMBA_STORE(b[9]);
-
-   /* output 10 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-   COMBA_STORE(b[10]);
-
-   /* output 11 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-   COMBA_STORE(b[11]);
-
-   /* output 12 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-   COMBA_STORE(b[12]);
-
-   /* output 13 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-   COMBA_STORE(b[13]);
-
-   /* output 14 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); 
-   COMBA_STORE(b[14]);
-
-   /* output 15 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; 
-   COMBA_STORE(b[15]);
-
-   /* output 16 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); 
-   COMBA_STORE(b[16]);
-
-   /* output 17 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[17]); SQRADDAC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; 
-   COMBA_STORE(b[17]);
-
-   /* output 18 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[18]); SQRADDAC(a[1], a[17]); SQRADDAC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); 
-   COMBA_STORE(b[18]);
-
-   /* output 19 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[19]); SQRADDAC(a[1], a[18]); SQRADDAC(a[2], a[17]); SQRADDAC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; 
-   COMBA_STORE(b[19]);
-
-   /* output 20 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[20]); SQRADDAC(a[1], a[19]); SQRADDAC(a[2], a[18]); SQRADDAC(a[3], a[17]); SQRADDAC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); 
-   COMBA_STORE(b[20]);
-
-   /* output 21 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[21]); SQRADDAC(a[1], a[20]); SQRADDAC(a[2], a[19]); SQRADDAC(a[3], a[18]); SQRADDAC(a[4], a[17]); SQRADDAC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; 
-   COMBA_STORE(b[21]);
-
-   /* output 22 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[22]); SQRADDAC(a[1], a[21]); SQRADDAC(a[2], a[20]); SQRADDAC(a[3], a[19]); SQRADDAC(a[4], a[18]); SQRADDAC(a[5], a[17]); SQRADDAC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); 
-   COMBA_STORE(b[22]);
-
-   /* output 23 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[23]); SQRADDAC(a[1], a[22]); SQRADDAC(a[2], a[21]); SQRADDAC(a[3], a[20]); SQRADDAC(a[4], a[19]); SQRADDAC(a[5], a[18]); SQRADDAC(a[6], a[17]); SQRADDAC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; 
-   COMBA_STORE(b[23]);
-
-   /* output 24 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[24]); SQRADDAC(a[1], a[23]); SQRADDAC(a[2], a[22]); SQRADDAC(a[3], a[21]); SQRADDAC(a[4], a[20]); SQRADDAC(a[5], a[19]); SQRADDAC(a[6], a[18]); SQRADDAC(a[7], a[17]); SQRADDAC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); 
-   COMBA_STORE(b[24]);
-
-   /* output 25 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[25]); SQRADDAC(a[1], a[24]); SQRADDAC(a[2], a[23]); SQRADDAC(a[3], a[22]); SQRADDAC(a[4], a[21]); SQRADDAC(a[5], a[20]); SQRADDAC(a[6], a[19]); SQRADDAC(a[7], a[18]); SQRADDAC(a[8], a[17]); SQRADDAC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; 
-   COMBA_STORE(b[25]);
-
-   /* output 26 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[26]); SQRADDAC(a[1], a[25]); SQRADDAC(a[2], a[24]); SQRADDAC(a[3], a[23]); SQRADDAC(a[4], a[22]); SQRADDAC(a[5], a[21]); SQRADDAC(a[6], a[20]); SQRADDAC(a[7], a[19]); SQRADDAC(a[8], a[18]); SQRADDAC(a[9], a[17]); SQRADDAC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); 
-   COMBA_STORE(b[26]);
-
-   /* output 27 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[27]); SQRADDAC(a[1], a[26]); SQRADDAC(a[2], a[25]); SQRADDAC(a[3], a[24]); SQRADDAC(a[4], a[23]); SQRADDAC(a[5], a[22]); SQRADDAC(a[6], a[21]); SQRADDAC(a[7], a[20]); SQRADDAC(a[8], a[19]); SQRADDAC(a[9], a[18]); SQRADDAC(a[10], a[17]); SQRADDAC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; 
-   COMBA_STORE(b[27]);
-
-   /* output 28 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[28]); SQRADDAC(a[1], a[27]); SQRADDAC(a[2], a[26]); SQRADDAC(a[3], a[25]); SQRADDAC(a[4], a[24]); SQRADDAC(a[5], a[23]); SQRADDAC(a[6], a[22]); SQRADDAC(a[7], a[21]); SQRADDAC(a[8], a[20]); SQRADDAC(a[9], a[19]); SQRADDAC(a[10], a[18]); SQRADDAC(a[11], a[17]); SQRADDAC(a[12], a[16]); SQRADDAC(a[13], a[15]); SQRADDDB; SQRADD(a[14], a[14]); 
-   COMBA_STORE(b[28]);
-
-   /* output 29 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[29]); SQRADDAC(a[1], a[28]); SQRADDAC(a[2], a[27]); SQRADDAC(a[3], a[26]); SQRADDAC(a[4], a[25]); SQRADDAC(a[5], a[24]); SQRADDAC(a[6], a[23]); SQRADDAC(a[7], a[22]); SQRADDAC(a[8], a[21]); SQRADDAC(a[9], a[20]); SQRADDAC(a[10], a[19]); SQRADDAC(a[11], a[18]); SQRADDAC(a[12], a[17]); SQRADDAC(a[13], a[16]); SQRADDAC(a[14], a[15]); SQRADDDB; 
-   COMBA_STORE(b[29]);
-
-   /* output 30 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[30]); SQRADDAC(a[1], a[29]); SQRADDAC(a[2], a[28]); SQRADDAC(a[3], a[27]); SQRADDAC(a[4], a[26]); SQRADDAC(a[5], a[25]); SQRADDAC(a[6], a[24]); SQRADDAC(a[7], a[23]); SQRADDAC(a[8], a[22]); SQRADDAC(a[9], a[21]); SQRADDAC(a[10], a[20]); SQRADDAC(a[11], a[19]); SQRADDAC(a[12], a[18]); SQRADDAC(a[13], a[17]); SQRADDAC(a[14], a[16]); SQRADDDB; SQRADD(a[15], a[15]); 
-   COMBA_STORE(b[30]);
-
-   /* output 31 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[31]); SQRADDAC(a[1], a[30]); SQRADDAC(a[2], a[29]); SQRADDAC(a[3], a[28]); SQRADDAC(a[4], a[27]); SQRADDAC(a[5], a[26]); SQRADDAC(a[6], a[25]); SQRADDAC(a[7], a[24]); SQRADDAC(a[8], a[23]); SQRADDAC(a[9], a[22]); SQRADDAC(a[10], a[21]); SQRADDAC(a[11], a[20]); SQRADDAC(a[12], a[19]); SQRADDAC(a[13], a[18]); SQRADDAC(a[14], a[17]); SQRADDAC(a[15], a[16]); SQRADDDB; 
-   COMBA_STORE(b[31]);
-
-   /* output 32 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[32]); SQRADDAC(a[1], a[31]); SQRADDAC(a[2], a[30]); SQRADDAC(a[3], a[29]); SQRADDAC(a[4], a[28]); SQRADDAC(a[5], a[27]); SQRADDAC(a[6], a[26]); SQRADDAC(a[7], a[25]); SQRADDAC(a[8], a[24]); SQRADDAC(a[9], a[23]); SQRADDAC(a[10], a[22]); SQRADDAC(a[11], a[21]); SQRADDAC(a[12], a[20]); SQRADDAC(a[13], a[19]); SQRADDAC(a[14], a[18]); SQRADDAC(a[15], a[17]); SQRADDDB; SQRADD(a[16], a[16]); 
-   COMBA_STORE(b[32]);
-
-   /* output 33 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[33]); SQRADDAC(a[1], a[32]); SQRADDAC(a[2], a[31]); SQRADDAC(a[3], a[30]); SQRADDAC(a[4], a[29]); SQRADDAC(a[5], a[28]); SQRADDAC(a[6], a[27]); SQRADDAC(a[7], a[26]); SQRADDAC(a[8], a[25]); SQRADDAC(a[9], a[24]); SQRADDAC(a[10], a[23]); SQRADDAC(a[11], a[22]); SQRADDAC(a[12], a[21]); SQRADDAC(a[13], a[20]); SQRADDAC(a[14], a[19]); SQRADDAC(a[15], a[18]); SQRADDAC(a[16], a[17]); SQRADDDB; 
-   COMBA_STORE(b[33]);
-
-   /* output 34 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[34]); SQRADDAC(a[1], a[33]); SQRADDAC(a[2], a[32]); SQRADDAC(a[3], a[31]); SQRADDAC(a[4], a[30]); SQRADDAC(a[5], a[29]); SQRADDAC(a[6], a[28]); SQRADDAC(a[7], a[27]); SQRADDAC(a[8], a[26]); SQRADDAC(a[9], a[25]); SQRADDAC(a[10], a[24]); SQRADDAC(a[11], a[23]); SQRADDAC(a[12], a[22]); SQRADDAC(a[13], a[21]); SQRADDAC(a[14], a[20]); SQRADDAC(a[15], a[19]); SQRADDAC(a[16], a[18]); SQRADDDB; SQRADD(a[17], a[17]); 
-   COMBA_STORE(b[34]);
-
-   /* output 35 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[35]); SQRADDAC(a[1], a[34]); SQRADDAC(a[2], a[33]); SQRADDAC(a[3], a[32]); SQRADDAC(a[4], a[31]); SQRADDAC(a[5], a[30]); SQRADDAC(a[6], a[29]); SQRADDAC(a[7], a[28]); SQRADDAC(a[8], a[27]); SQRADDAC(a[9], a[26]); SQRADDAC(a[10], a[25]); SQRADDAC(a[11], a[24]); SQRADDAC(a[12], a[23]); SQRADDAC(a[13], a[22]); SQRADDAC(a[14], a[21]); SQRADDAC(a[15], a[20]); SQRADDAC(a[16], a[19]); SQRADDAC(a[17], a[18]); SQRADDDB; 
-   COMBA_STORE(b[35]);
-
-   /* output 36 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[36]); SQRADDAC(a[1], a[35]); SQRADDAC(a[2], a[34]); SQRADDAC(a[3], a[33]); SQRADDAC(a[4], a[32]); SQRADDAC(a[5], a[31]); SQRADDAC(a[6], a[30]); SQRADDAC(a[7], a[29]); SQRADDAC(a[8], a[28]); SQRADDAC(a[9], a[27]); SQRADDAC(a[10], a[26]); SQRADDAC(a[11], a[25]); SQRADDAC(a[12], a[24]); SQRADDAC(a[13], a[23]); SQRADDAC(a[14], a[22]); SQRADDAC(a[15], a[21]); SQRADDAC(a[16], a[20]); SQRADDAC(a[17], a[19]); SQRADDDB; SQRADD(a[18], a[18]); 
-   COMBA_STORE(b[36]);
-
-   /* output 37 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[37]); SQRADDAC(a[1], a[36]); SQRADDAC(a[2], a[35]); SQRADDAC(a[3], a[34]); SQRADDAC(a[4], a[33]); SQRADDAC(a[5], a[32]); SQRADDAC(a[6], a[31]); SQRADDAC(a[7], a[30]); SQRADDAC(a[8], a[29]); SQRADDAC(a[9], a[28]); SQRADDAC(a[10], a[27]); SQRADDAC(a[11], a[26]); SQRADDAC(a[12], a[25]); SQRADDAC(a[13], a[24]); SQRADDAC(a[14], a[23]); SQRADDAC(a[15], a[22]); SQRADDAC(a[16], a[21]); SQRADDAC(a[17], a[20]); SQRADDAC(a[18], a[19]); SQRADDDB; 
-   COMBA_STORE(b[37]);
-
-   /* output 38 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[38]); SQRADDAC(a[1], a[37]); SQRADDAC(a[2], a[36]); SQRADDAC(a[3], a[35]); SQRADDAC(a[4], a[34]); SQRADDAC(a[5], a[33]); SQRADDAC(a[6], a[32]); SQRADDAC(a[7], a[31]); SQRADDAC(a[8], a[30]); SQRADDAC(a[9], a[29]); SQRADDAC(a[10], a[28]); SQRADDAC(a[11], a[27]); SQRADDAC(a[12], a[26]); SQRADDAC(a[13], a[25]); SQRADDAC(a[14], a[24]); SQRADDAC(a[15], a[23]); SQRADDAC(a[16], a[22]); SQRADDAC(a[17], a[21]); SQRADDAC(a[18], a[20]); SQRADDDB; SQRADD(a[19], a[19]); 
-   COMBA_STORE(b[38]);
-
-   /* output 39 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[39]); SQRADDAC(a[1], a[38]); SQRADDAC(a[2], a[37]); SQRADDAC(a[3], a[36]); SQRADDAC(a[4], a[35]); SQRADDAC(a[5], a[34]); SQRADDAC(a[6], a[33]); SQRADDAC(a[7], a[32]); SQRADDAC(a[8], a[31]); SQRADDAC(a[9], a[30]); SQRADDAC(a[10], a[29]); SQRADDAC(a[11], a[28]); SQRADDAC(a[12], a[27]); SQRADDAC(a[13], a[26]); SQRADDAC(a[14], a[25]); SQRADDAC(a[15], a[24]); SQRADDAC(a[16], a[23]); SQRADDAC(a[17], a[22]); SQRADDAC(a[18], a[21]); SQRADDAC(a[19], a[20]); SQRADDDB; 
-   COMBA_STORE(b[39]);
-
-   /* output 40 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[40]); SQRADDAC(a[1], a[39]); SQRADDAC(a[2], a[38]); SQRADDAC(a[3], a[37]); SQRADDAC(a[4], a[36]); SQRADDAC(a[5], a[35]); SQRADDAC(a[6], a[34]); SQRADDAC(a[7], a[33]); SQRADDAC(a[8], a[32]); SQRADDAC(a[9], a[31]); SQRADDAC(a[10], a[30]); SQRADDAC(a[11], a[29]); SQRADDAC(a[12], a[28]); SQRADDAC(a[13], a[27]); SQRADDAC(a[14], a[26]); SQRADDAC(a[15], a[25]); SQRADDAC(a[16], a[24]); SQRADDAC(a[17], a[23]); SQRADDAC(a[18], a[22]); SQRADDAC(a[19], a[21]); SQRADDDB; SQRADD(a[20], a[20]); 
-   COMBA_STORE(b[40]);
-
-   /* output 41 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[41]); SQRADDAC(a[1], a[40]); SQRADDAC(a[2], a[39]); SQRADDAC(a[3], a[38]); SQRADDAC(a[4], a[37]); SQRADDAC(a[5], a[36]); SQRADDAC(a[6], a[35]); SQRADDAC(a[7], a[34]); SQRADDAC(a[8], a[33]); SQRADDAC(a[9], a[32]); SQRADDAC(a[10], a[31]); SQRADDAC(a[11], a[30]); SQRADDAC(a[12], a[29]); SQRADDAC(a[13], a[28]); SQRADDAC(a[14], a[27]); SQRADDAC(a[15], a[26]); SQRADDAC(a[16], a[25]); SQRADDAC(a[17], a[24]); SQRADDAC(a[18], a[23]); SQRADDAC(a[19], a[22]); SQRADDAC(a[20], a[21]); SQRADDDB; 
-   COMBA_STORE(b[41]);
-
-   /* output 42 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[42]); SQRADDAC(a[1], a[41]); SQRADDAC(a[2], a[40]); SQRADDAC(a[3], a[39]); SQRADDAC(a[4], a[38]); SQRADDAC(a[5], a[37]); SQRADDAC(a[6], a[36]); SQRADDAC(a[7], a[35]); SQRADDAC(a[8], a[34]); SQRADDAC(a[9], a[33]); SQRADDAC(a[10], a[32]); SQRADDAC(a[11], a[31]); SQRADDAC(a[12], a[30]); SQRADDAC(a[13], a[29]); SQRADDAC(a[14], a[28]); SQRADDAC(a[15], a[27]); SQRADDAC(a[16], a[26]); SQRADDAC(a[17], a[25]); SQRADDAC(a[18], a[24]); SQRADDAC(a[19], a[23]); SQRADDAC(a[20], a[22]); SQRADDDB; SQRADD(a[21], a[21]); 
-   COMBA_STORE(b[42]);
-
-   /* output 43 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[43]); SQRADDAC(a[1], a[42]); SQRADDAC(a[2], a[41]); SQRADDAC(a[3], a[40]); SQRADDAC(a[4], a[39]); SQRADDAC(a[5], a[38]); SQRADDAC(a[6], a[37]); SQRADDAC(a[7], a[36]); SQRADDAC(a[8], a[35]); SQRADDAC(a[9], a[34]); SQRADDAC(a[10], a[33]); SQRADDAC(a[11], a[32]); SQRADDAC(a[12], a[31]); SQRADDAC(a[13], a[30]); SQRADDAC(a[14], a[29]); SQRADDAC(a[15], a[28]); SQRADDAC(a[16], a[27]); SQRADDAC(a[17], a[26]); SQRADDAC(a[18], a[25]); SQRADDAC(a[19], a[24]); SQRADDAC(a[20], a[23]); SQRADDAC(a[21], a[22]); SQRADDDB; 
-   COMBA_STORE(b[43]);
-
-   /* output 44 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[44]); SQRADDAC(a[1], a[43]); SQRADDAC(a[2], a[42]); SQRADDAC(a[3], a[41]); SQRADDAC(a[4], a[40]); SQRADDAC(a[5], a[39]); SQRADDAC(a[6], a[38]); SQRADDAC(a[7], a[37]); SQRADDAC(a[8], a[36]); SQRADDAC(a[9], a[35]); SQRADDAC(a[10], a[34]); SQRADDAC(a[11], a[33]); SQRADDAC(a[12], a[32]); SQRADDAC(a[13], a[31]); SQRADDAC(a[14], a[30]); SQRADDAC(a[15], a[29]); SQRADDAC(a[16], a[28]); SQRADDAC(a[17], a[27]); SQRADDAC(a[18], a[26]); SQRADDAC(a[19], a[25]); SQRADDAC(a[20], a[24]); SQRADDAC(a[21], a[23]); SQRADDDB; SQRADD(a[22], a[22]); 
-   COMBA_STORE(b[44]);
-
-   /* output 45 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[45]); SQRADDAC(a[1], a[44]); SQRADDAC(a[2], a[43]); SQRADDAC(a[3], a[42]); SQRADDAC(a[4], a[41]); SQRADDAC(a[5], a[40]); SQRADDAC(a[6], a[39]); SQRADDAC(a[7], a[38]); SQRADDAC(a[8], a[37]); SQRADDAC(a[9], a[36]); SQRADDAC(a[10], a[35]); SQRADDAC(a[11], a[34]); SQRADDAC(a[12], a[33]); SQRADDAC(a[13], a[32]); SQRADDAC(a[14], a[31]); SQRADDAC(a[15], a[30]); SQRADDAC(a[16], a[29]); SQRADDAC(a[17], a[28]); SQRADDAC(a[18], a[27]); SQRADDAC(a[19], a[26]); SQRADDAC(a[20], a[25]); SQRADDAC(a[21], a[24]); SQRADDAC(a[22], a[23]); SQRADDDB; 
-   COMBA_STORE(b[45]);
-
-   /* output 46 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[46]); SQRADDAC(a[1], a[45]); SQRADDAC(a[2], a[44]); SQRADDAC(a[3], a[43]); SQRADDAC(a[4], a[42]); SQRADDAC(a[5], a[41]); SQRADDAC(a[6], a[40]); SQRADDAC(a[7], a[39]); SQRADDAC(a[8], a[38]); SQRADDAC(a[9], a[37]); SQRADDAC(a[10], a[36]); SQRADDAC(a[11], a[35]); SQRADDAC(a[12], a[34]); SQRADDAC(a[13], a[33]); SQRADDAC(a[14], a[32]); SQRADDAC(a[15], a[31]); SQRADDAC(a[16], a[30]); SQRADDAC(a[17], a[29]); SQRADDAC(a[18], a[28]); SQRADDAC(a[19], a[27]); SQRADDAC(a[20], a[26]); SQRADDAC(a[21], a[25]); SQRADDAC(a[22], a[24]); SQRADDDB; SQRADD(a[23], a[23]); 
-   COMBA_STORE(b[46]);
-
-   /* output 47 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[47]); SQRADDAC(a[1], a[46]); SQRADDAC(a[2], a[45]); SQRADDAC(a[3], a[44]); SQRADDAC(a[4], a[43]); SQRADDAC(a[5], a[42]); SQRADDAC(a[6], a[41]); SQRADDAC(a[7], a[40]); SQRADDAC(a[8], a[39]); SQRADDAC(a[9], a[38]); SQRADDAC(a[10], a[37]); SQRADDAC(a[11], a[36]); SQRADDAC(a[12], a[35]); SQRADDAC(a[13], a[34]); SQRADDAC(a[14], a[33]); SQRADDAC(a[15], a[32]); SQRADDAC(a[16], a[31]); SQRADDAC(a[17], a[30]); SQRADDAC(a[18], a[29]); SQRADDAC(a[19], a[28]); SQRADDAC(a[20], a[27]); SQRADDAC(a[21], a[26]); SQRADDAC(a[22], a[25]); SQRADDAC(a[23], a[24]); SQRADDDB; 
-   COMBA_STORE(b[47]);
-
-   /* output 48 */
-   CARRY_FORWARD;
-   SQRADDSC(a[1], a[47]); SQRADDAC(a[2], a[46]); SQRADDAC(a[3], a[45]); SQRADDAC(a[4], a[44]); SQRADDAC(a[5], a[43]); SQRADDAC(a[6], a[42]); SQRADDAC(a[7], a[41]); SQRADDAC(a[8], a[40]); SQRADDAC(a[9], a[39]); SQRADDAC(a[10], a[38]); SQRADDAC(a[11], a[37]); SQRADDAC(a[12], a[36]); SQRADDAC(a[13], a[35]); SQRADDAC(a[14], a[34]); SQRADDAC(a[15], a[33]); SQRADDAC(a[16], a[32]); SQRADDAC(a[17], a[31]); SQRADDAC(a[18], a[30]); SQRADDAC(a[19], a[29]); SQRADDAC(a[20], a[28]); SQRADDAC(a[21], a[27]); SQRADDAC(a[22], a[26]); SQRADDAC(a[23], a[25]); SQRADDDB; SQRADD(a[24], a[24]); 
-   COMBA_STORE(b[48]);
-
-   /* output 49 */
-   CARRY_FORWARD;
-   SQRADDSC(a[2], a[47]); SQRADDAC(a[3], a[46]); SQRADDAC(a[4], a[45]); SQRADDAC(a[5], a[44]); SQRADDAC(a[6], a[43]); SQRADDAC(a[7], a[42]); SQRADDAC(a[8], a[41]); SQRADDAC(a[9], a[40]); SQRADDAC(a[10], a[39]); SQRADDAC(a[11], a[38]); SQRADDAC(a[12], a[37]); SQRADDAC(a[13], a[36]); SQRADDAC(a[14], a[35]); SQRADDAC(a[15], a[34]); SQRADDAC(a[16], a[33]); SQRADDAC(a[17], a[32]); SQRADDAC(a[18], a[31]); SQRADDAC(a[19], a[30]); SQRADDAC(a[20], a[29]); SQRADDAC(a[21], a[28]); SQRADDAC(a[22], a[27]); SQRADDAC(a[23], a[26]); SQRADDAC(a[24], a[25]); SQRADDDB; 
-   COMBA_STORE(b[49]);
-
-   /* output 50 */
-   CARRY_FORWARD;
-   SQRADDSC(a[3], a[47]); SQRADDAC(a[4], a[46]); SQRADDAC(a[5], a[45]); SQRADDAC(a[6], a[44]); SQRADDAC(a[7], a[43]); SQRADDAC(a[8], a[42]); SQRADDAC(a[9], a[41]); SQRADDAC(a[10], a[40]); SQRADDAC(a[11], a[39]); SQRADDAC(a[12], a[38]); SQRADDAC(a[13], a[37]); SQRADDAC(a[14], a[36]); SQRADDAC(a[15], a[35]); SQRADDAC(a[16], a[34]); SQRADDAC(a[17], a[33]); SQRADDAC(a[18], a[32]); SQRADDAC(a[19], a[31]); SQRADDAC(a[20], a[30]); SQRADDAC(a[21], a[29]); SQRADDAC(a[22], a[28]); SQRADDAC(a[23], a[27]); SQRADDAC(a[24], a[26]); SQRADDDB; SQRADD(a[25], a[25]); 
-   COMBA_STORE(b[50]);
-
-   /* output 51 */
-   CARRY_FORWARD;
-   SQRADDSC(a[4], a[47]); SQRADDAC(a[5], a[46]); SQRADDAC(a[6], a[45]); SQRADDAC(a[7], a[44]); SQRADDAC(a[8], a[43]); SQRADDAC(a[9], a[42]); SQRADDAC(a[10], a[41]); SQRADDAC(a[11], a[40]); SQRADDAC(a[12], a[39]); SQRADDAC(a[13], a[38]); SQRADDAC(a[14], a[37]); SQRADDAC(a[15], a[36]); SQRADDAC(a[16], a[35]); SQRADDAC(a[17], a[34]); SQRADDAC(a[18], a[33]); SQRADDAC(a[19], a[32]); SQRADDAC(a[20], a[31]); SQRADDAC(a[21], a[30]); SQRADDAC(a[22], a[29]); SQRADDAC(a[23], a[28]); SQRADDAC(a[24], a[27]); SQRADDAC(a[25], a[26]); SQRADDDB; 
-   COMBA_STORE(b[51]);
-
-   /* output 52 */
-   CARRY_FORWARD;
-   SQRADDSC(a[5], a[47]); SQRADDAC(a[6], a[46]); SQRADDAC(a[7], a[45]); SQRADDAC(a[8], a[44]); SQRADDAC(a[9], a[43]); SQRADDAC(a[10], a[42]); SQRADDAC(a[11], a[41]); SQRADDAC(a[12], a[40]); SQRADDAC(a[13], a[39]); SQRADDAC(a[14], a[38]); SQRADDAC(a[15], a[37]); SQRADDAC(a[16], a[36]); SQRADDAC(a[17], a[35]); SQRADDAC(a[18], a[34]); SQRADDAC(a[19], a[33]); SQRADDAC(a[20], a[32]); SQRADDAC(a[21], a[31]); SQRADDAC(a[22], a[30]); SQRADDAC(a[23], a[29]); SQRADDAC(a[24], a[28]); SQRADDAC(a[25], a[27]); SQRADDDB; SQRADD(a[26], a[26]); 
-   COMBA_STORE(b[52]);
-
-   /* output 53 */
-   CARRY_FORWARD;
-   SQRADDSC(a[6], a[47]); SQRADDAC(a[7], a[46]); SQRADDAC(a[8], a[45]); SQRADDAC(a[9], a[44]); SQRADDAC(a[10], a[43]); SQRADDAC(a[11], a[42]); SQRADDAC(a[12], a[41]); SQRADDAC(a[13], a[40]); SQRADDAC(a[14], a[39]); SQRADDAC(a[15], a[38]); SQRADDAC(a[16], a[37]); SQRADDAC(a[17], a[36]); SQRADDAC(a[18], a[35]); SQRADDAC(a[19], a[34]); SQRADDAC(a[20], a[33]); SQRADDAC(a[21], a[32]); SQRADDAC(a[22], a[31]); SQRADDAC(a[23], a[30]); SQRADDAC(a[24], a[29]); SQRADDAC(a[25], a[28]); SQRADDAC(a[26], a[27]); SQRADDDB; 
-   COMBA_STORE(b[53]);
-
-   /* output 54 */
-   CARRY_FORWARD;
-   SQRADDSC(a[7], a[47]); SQRADDAC(a[8], a[46]); SQRADDAC(a[9], a[45]); SQRADDAC(a[10], a[44]); SQRADDAC(a[11], a[43]); SQRADDAC(a[12], a[42]); SQRADDAC(a[13], a[41]); SQRADDAC(a[14], a[40]); SQRADDAC(a[15], a[39]); SQRADDAC(a[16], a[38]); SQRADDAC(a[17], a[37]); SQRADDAC(a[18], a[36]); SQRADDAC(a[19], a[35]); SQRADDAC(a[20], a[34]); SQRADDAC(a[21], a[33]); SQRADDAC(a[22], a[32]); SQRADDAC(a[23], a[31]); SQRADDAC(a[24], a[30]); SQRADDAC(a[25], a[29]); SQRADDAC(a[26], a[28]); SQRADDDB; SQRADD(a[27], a[27]); 
-   COMBA_STORE(b[54]);
-
-   /* output 55 */
-   CARRY_FORWARD;
-   SQRADDSC(a[8], a[47]); SQRADDAC(a[9], a[46]); SQRADDAC(a[10], a[45]); SQRADDAC(a[11], a[44]); SQRADDAC(a[12], a[43]); SQRADDAC(a[13], a[42]); SQRADDAC(a[14], a[41]); SQRADDAC(a[15], a[40]); SQRADDAC(a[16], a[39]); SQRADDAC(a[17], a[38]); SQRADDAC(a[18], a[37]); SQRADDAC(a[19], a[36]); SQRADDAC(a[20], a[35]); SQRADDAC(a[21], a[34]); SQRADDAC(a[22], a[33]); SQRADDAC(a[23], a[32]); SQRADDAC(a[24], a[31]); SQRADDAC(a[25], a[30]); SQRADDAC(a[26], a[29]); SQRADDAC(a[27], a[28]); SQRADDDB; 
-   COMBA_STORE(b[55]);
-
-   /* output 56 */
-   CARRY_FORWARD;
-   SQRADDSC(a[9], a[47]); SQRADDAC(a[10], a[46]); SQRADDAC(a[11], a[45]); SQRADDAC(a[12], a[44]); SQRADDAC(a[13], a[43]); SQRADDAC(a[14], a[42]); SQRADDAC(a[15], a[41]); SQRADDAC(a[16], a[40]); SQRADDAC(a[17], a[39]); SQRADDAC(a[18], a[38]); SQRADDAC(a[19], a[37]); SQRADDAC(a[20], a[36]); SQRADDAC(a[21], a[35]); SQRADDAC(a[22], a[34]); SQRADDAC(a[23], a[33]); SQRADDAC(a[24], a[32]); SQRADDAC(a[25], a[31]); SQRADDAC(a[26], a[30]); SQRADDAC(a[27], a[29]); SQRADDDB; SQRADD(a[28], a[28]); 
-   COMBA_STORE(b[56]);
-
-   /* output 57 */
-   CARRY_FORWARD;
-   SQRADDSC(a[10], a[47]); SQRADDAC(a[11], a[46]); SQRADDAC(a[12], a[45]); SQRADDAC(a[13], a[44]); SQRADDAC(a[14], a[43]); SQRADDAC(a[15], a[42]); SQRADDAC(a[16], a[41]); SQRADDAC(a[17], a[40]); SQRADDAC(a[18], a[39]); SQRADDAC(a[19], a[38]); SQRADDAC(a[20], a[37]); SQRADDAC(a[21], a[36]); SQRADDAC(a[22], a[35]); SQRADDAC(a[23], a[34]); SQRADDAC(a[24], a[33]); SQRADDAC(a[25], a[32]); SQRADDAC(a[26], a[31]); SQRADDAC(a[27], a[30]); SQRADDAC(a[28], a[29]); SQRADDDB; 
-   COMBA_STORE(b[57]);
-
-   /* output 58 */
-   CARRY_FORWARD;
-   SQRADDSC(a[11], a[47]); SQRADDAC(a[12], a[46]); SQRADDAC(a[13], a[45]); SQRADDAC(a[14], a[44]); SQRADDAC(a[15], a[43]); SQRADDAC(a[16], a[42]); SQRADDAC(a[17], a[41]); SQRADDAC(a[18], a[40]); SQRADDAC(a[19], a[39]); SQRADDAC(a[20], a[38]); SQRADDAC(a[21], a[37]); SQRADDAC(a[22], a[36]); SQRADDAC(a[23], a[35]); SQRADDAC(a[24], a[34]); SQRADDAC(a[25], a[33]); SQRADDAC(a[26], a[32]); SQRADDAC(a[27], a[31]); SQRADDAC(a[28], a[30]); SQRADDDB; SQRADD(a[29], a[29]); 
-   COMBA_STORE(b[58]);
-
-   /* output 59 */
-   CARRY_FORWARD;
-   SQRADDSC(a[12], a[47]); SQRADDAC(a[13], a[46]); SQRADDAC(a[14], a[45]); SQRADDAC(a[15], a[44]); SQRADDAC(a[16], a[43]); SQRADDAC(a[17], a[42]); SQRADDAC(a[18], a[41]); SQRADDAC(a[19], a[40]); SQRADDAC(a[20], a[39]); SQRADDAC(a[21], a[38]); SQRADDAC(a[22], a[37]); SQRADDAC(a[23], a[36]); SQRADDAC(a[24], a[35]); SQRADDAC(a[25], a[34]); SQRADDAC(a[26], a[33]); SQRADDAC(a[27], a[32]); SQRADDAC(a[28], a[31]); SQRADDAC(a[29], a[30]); SQRADDDB; 
-   COMBA_STORE(b[59]);
-
-   /* output 60 */
-   CARRY_FORWARD;
-   SQRADDSC(a[13], a[47]); SQRADDAC(a[14], a[46]); SQRADDAC(a[15], a[45]); SQRADDAC(a[16], a[44]); SQRADDAC(a[17], a[43]); SQRADDAC(a[18], a[42]); SQRADDAC(a[19], a[41]); SQRADDAC(a[20], a[40]); SQRADDAC(a[21], a[39]); SQRADDAC(a[22], a[38]); SQRADDAC(a[23], a[37]); SQRADDAC(a[24], a[36]); SQRADDAC(a[25], a[35]); SQRADDAC(a[26], a[34]); SQRADDAC(a[27], a[33]); SQRADDAC(a[28], a[32]); SQRADDAC(a[29], a[31]); SQRADDDB; SQRADD(a[30], a[30]); 
-   COMBA_STORE(b[60]);
-
-   /* output 61 */
-   CARRY_FORWARD;
-   SQRADDSC(a[14], a[47]); SQRADDAC(a[15], a[46]); SQRADDAC(a[16], a[45]); SQRADDAC(a[17], a[44]); SQRADDAC(a[18], a[43]); SQRADDAC(a[19], a[42]); SQRADDAC(a[20], a[41]); SQRADDAC(a[21], a[40]); SQRADDAC(a[22], a[39]); SQRADDAC(a[23], a[38]); SQRADDAC(a[24], a[37]); SQRADDAC(a[25], a[36]); SQRADDAC(a[26], a[35]); SQRADDAC(a[27], a[34]); SQRADDAC(a[28], a[33]); SQRADDAC(a[29], a[32]); SQRADDAC(a[30], a[31]); SQRADDDB; 
-   COMBA_STORE(b[61]);
-
-   /* output 62 */
-   CARRY_FORWARD;
-   SQRADDSC(a[15], a[47]); SQRADDAC(a[16], a[46]); SQRADDAC(a[17], a[45]); SQRADDAC(a[18], a[44]); SQRADDAC(a[19], a[43]); SQRADDAC(a[20], a[42]); SQRADDAC(a[21], a[41]); SQRADDAC(a[22], a[40]); SQRADDAC(a[23], a[39]); SQRADDAC(a[24], a[38]); SQRADDAC(a[25], a[37]); SQRADDAC(a[26], a[36]); SQRADDAC(a[27], a[35]); SQRADDAC(a[28], a[34]); SQRADDAC(a[29], a[33]); SQRADDAC(a[30], a[32]); SQRADDDB; SQRADD(a[31], a[31]); 
-   COMBA_STORE(b[62]);
-
-   /* output 63 */
-   CARRY_FORWARD;
-   SQRADDSC(a[16], a[47]); SQRADDAC(a[17], a[46]); SQRADDAC(a[18], a[45]); SQRADDAC(a[19], a[44]); SQRADDAC(a[20], a[43]); SQRADDAC(a[21], a[42]); SQRADDAC(a[22], a[41]); SQRADDAC(a[23], a[40]); SQRADDAC(a[24], a[39]); SQRADDAC(a[25], a[38]); SQRADDAC(a[26], a[37]); SQRADDAC(a[27], a[36]); SQRADDAC(a[28], a[35]); SQRADDAC(a[29], a[34]); SQRADDAC(a[30], a[33]); SQRADDAC(a[31], a[32]); SQRADDDB; 
-   COMBA_STORE(b[63]);
-
-   /* output 64 */
-   CARRY_FORWARD;
-   SQRADDSC(a[17], a[47]); SQRADDAC(a[18], a[46]); SQRADDAC(a[19], a[45]); SQRADDAC(a[20], a[44]); SQRADDAC(a[21], a[43]); SQRADDAC(a[22], a[42]); SQRADDAC(a[23], a[41]); SQRADDAC(a[24], a[40]); SQRADDAC(a[25], a[39]); SQRADDAC(a[26], a[38]); SQRADDAC(a[27], a[37]); SQRADDAC(a[28], a[36]); SQRADDAC(a[29], a[35]); SQRADDAC(a[30], a[34]); SQRADDAC(a[31], a[33]); SQRADDDB; SQRADD(a[32], a[32]); 
-   COMBA_STORE(b[64]);
-
-   /* output 65 */
-   CARRY_FORWARD;
-   SQRADDSC(a[18], a[47]); SQRADDAC(a[19], a[46]); SQRADDAC(a[20], a[45]); SQRADDAC(a[21], a[44]); SQRADDAC(a[22], a[43]); SQRADDAC(a[23], a[42]); SQRADDAC(a[24], a[41]); SQRADDAC(a[25], a[40]); SQRADDAC(a[26], a[39]); SQRADDAC(a[27], a[38]); SQRADDAC(a[28], a[37]); SQRADDAC(a[29], a[36]); SQRADDAC(a[30], a[35]); SQRADDAC(a[31], a[34]); SQRADDAC(a[32], a[33]); SQRADDDB; 
-   COMBA_STORE(b[65]);
-
-   /* output 66 */
-   CARRY_FORWARD;
-   SQRADDSC(a[19], a[47]); SQRADDAC(a[20], a[46]); SQRADDAC(a[21], a[45]); SQRADDAC(a[22], a[44]); SQRADDAC(a[23], a[43]); SQRADDAC(a[24], a[42]); SQRADDAC(a[25], a[41]); SQRADDAC(a[26], a[40]); SQRADDAC(a[27], a[39]); SQRADDAC(a[28], a[38]); SQRADDAC(a[29], a[37]); SQRADDAC(a[30], a[36]); SQRADDAC(a[31], a[35]); SQRADDAC(a[32], a[34]); SQRADDDB; SQRADD(a[33], a[33]); 
-   COMBA_STORE(b[66]);
-
-   /* output 67 */
-   CARRY_FORWARD;
-   SQRADDSC(a[20], a[47]); SQRADDAC(a[21], a[46]); SQRADDAC(a[22], a[45]); SQRADDAC(a[23], a[44]); SQRADDAC(a[24], a[43]); SQRADDAC(a[25], a[42]); SQRADDAC(a[26], a[41]); SQRADDAC(a[27], a[40]); SQRADDAC(a[28], a[39]); SQRADDAC(a[29], a[38]); SQRADDAC(a[30], a[37]); SQRADDAC(a[31], a[36]); SQRADDAC(a[32], a[35]); SQRADDAC(a[33], a[34]); SQRADDDB; 
-   COMBA_STORE(b[67]);
-
-   /* output 68 */
-   CARRY_FORWARD;
-   SQRADDSC(a[21], a[47]); SQRADDAC(a[22], a[46]); SQRADDAC(a[23], a[45]); SQRADDAC(a[24], a[44]); SQRADDAC(a[25], a[43]); SQRADDAC(a[26], a[42]); SQRADDAC(a[27], a[41]); SQRADDAC(a[28], a[40]); SQRADDAC(a[29], a[39]); SQRADDAC(a[30], a[38]); SQRADDAC(a[31], a[37]); SQRADDAC(a[32], a[36]); SQRADDAC(a[33], a[35]); SQRADDDB; SQRADD(a[34], a[34]); 
-   COMBA_STORE(b[68]);
-
-   /* output 69 */
-   CARRY_FORWARD;
-   SQRADDSC(a[22], a[47]); SQRADDAC(a[23], a[46]); SQRADDAC(a[24], a[45]); SQRADDAC(a[25], a[44]); SQRADDAC(a[26], a[43]); SQRADDAC(a[27], a[42]); SQRADDAC(a[28], a[41]); SQRADDAC(a[29], a[40]); SQRADDAC(a[30], a[39]); SQRADDAC(a[31], a[38]); SQRADDAC(a[32], a[37]); SQRADDAC(a[33], a[36]); SQRADDAC(a[34], a[35]); SQRADDDB; 
-   COMBA_STORE(b[69]);
-
-   /* output 70 */
-   CARRY_FORWARD;
-   SQRADDSC(a[23], a[47]); SQRADDAC(a[24], a[46]); SQRADDAC(a[25], a[45]); SQRADDAC(a[26], a[44]); SQRADDAC(a[27], a[43]); SQRADDAC(a[28], a[42]); SQRADDAC(a[29], a[41]); SQRADDAC(a[30], a[40]); SQRADDAC(a[31], a[39]); SQRADDAC(a[32], a[38]); SQRADDAC(a[33], a[37]); SQRADDAC(a[34], a[36]); SQRADDDB; SQRADD(a[35], a[35]); 
-   COMBA_STORE(b[70]);
-
-   /* output 71 */
-   CARRY_FORWARD;
-   SQRADDSC(a[24], a[47]); SQRADDAC(a[25], a[46]); SQRADDAC(a[26], a[45]); SQRADDAC(a[27], a[44]); SQRADDAC(a[28], a[43]); SQRADDAC(a[29], a[42]); SQRADDAC(a[30], a[41]); SQRADDAC(a[31], a[40]); SQRADDAC(a[32], a[39]); SQRADDAC(a[33], a[38]); SQRADDAC(a[34], a[37]); SQRADDAC(a[35], a[36]); SQRADDDB; 
-   COMBA_STORE(b[71]);
-
-   /* output 72 */
-   CARRY_FORWARD;
-   SQRADDSC(a[25], a[47]); SQRADDAC(a[26], a[46]); SQRADDAC(a[27], a[45]); SQRADDAC(a[28], a[44]); SQRADDAC(a[29], a[43]); SQRADDAC(a[30], a[42]); SQRADDAC(a[31], a[41]); SQRADDAC(a[32], a[40]); SQRADDAC(a[33], a[39]); SQRADDAC(a[34], a[38]); SQRADDAC(a[35], a[37]); SQRADDDB; SQRADD(a[36], a[36]); 
-   COMBA_STORE(b[72]);
-
-   /* output 73 */
-   CARRY_FORWARD;
-   SQRADDSC(a[26], a[47]); SQRADDAC(a[27], a[46]); SQRADDAC(a[28], a[45]); SQRADDAC(a[29], a[44]); SQRADDAC(a[30], a[43]); SQRADDAC(a[31], a[42]); SQRADDAC(a[32], a[41]); SQRADDAC(a[33], a[40]); SQRADDAC(a[34], a[39]); SQRADDAC(a[35], a[38]); SQRADDAC(a[36], a[37]); SQRADDDB; 
-   COMBA_STORE(b[73]);
-
-   /* output 74 */
-   CARRY_FORWARD;
-   SQRADDSC(a[27], a[47]); SQRADDAC(a[28], a[46]); SQRADDAC(a[29], a[45]); SQRADDAC(a[30], a[44]); SQRADDAC(a[31], a[43]); SQRADDAC(a[32], a[42]); SQRADDAC(a[33], a[41]); SQRADDAC(a[34], a[40]); SQRADDAC(a[35], a[39]); SQRADDAC(a[36], a[38]); SQRADDDB; SQRADD(a[37], a[37]); 
-   COMBA_STORE(b[74]);
-
-   /* output 75 */
-   CARRY_FORWARD;
-   SQRADDSC(a[28], a[47]); SQRADDAC(a[29], a[46]); SQRADDAC(a[30], a[45]); SQRADDAC(a[31], a[44]); SQRADDAC(a[32], a[43]); SQRADDAC(a[33], a[42]); SQRADDAC(a[34], a[41]); SQRADDAC(a[35], a[40]); SQRADDAC(a[36], a[39]); SQRADDAC(a[37], a[38]); SQRADDDB; 
-   COMBA_STORE(b[75]);
-
-   /* output 76 */
-   CARRY_FORWARD;
-   SQRADDSC(a[29], a[47]); SQRADDAC(a[30], a[46]); SQRADDAC(a[31], a[45]); SQRADDAC(a[32], a[44]); SQRADDAC(a[33], a[43]); SQRADDAC(a[34], a[42]); SQRADDAC(a[35], a[41]); SQRADDAC(a[36], a[40]); SQRADDAC(a[37], a[39]); SQRADDDB; SQRADD(a[38], a[38]); 
-   COMBA_STORE(b[76]);
-
-   /* output 77 */
-   CARRY_FORWARD;
-   SQRADDSC(a[30], a[47]); SQRADDAC(a[31], a[46]); SQRADDAC(a[32], a[45]); SQRADDAC(a[33], a[44]); SQRADDAC(a[34], a[43]); SQRADDAC(a[35], a[42]); SQRADDAC(a[36], a[41]); SQRADDAC(a[37], a[40]); SQRADDAC(a[38], a[39]); SQRADDDB; 
-   COMBA_STORE(b[77]);
-
-   /* output 78 */
-   CARRY_FORWARD;
-   SQRADDSC(a[31], a[47]); SQRADDAC(a[32], a[46]); SQRADDAC(a[33], a[45]); SQRADDAC(a[34], a[44]); SQRADDAC(a[35], a[43]); SQRADDAC(a[36], a[42]); SQRADDAC(a[37], a[41]); SQRADDAC(a[38], a[40]); SQRADDDB; SQRADD(a[39], a[39]); 
-   COMBA_STORE(b[78]);
-
-   /* output 79 */
-   CARRY_FORWARD;
-   SQRADDSC(a[32], a[47]); SQRADDAC(a[33], a[46]); SQRADDAC(a[34], a[45]); SQRADDAC(a[35], a[44]); SQRADDAC(a[36], a[43]); SQRADDAC(a[37], a[42]); SQRADDAC(a[38], a[41]); SQRADDAC(a[39], a[40]); SQRADDDB; 
-   COMBA_STORE(b[79]);
-
-   /* output 80 */
-   CARRY_FORWARD;
-   SQRADDSC(a[33], a[47]); SQRADDAC(a[34], a[46]); SQRADDAC(a[35], a[45]); SQRADDAC(a[36], a[44]); SQRADDAC(a[37], a[43]); SQRADDAC(a[38], a[42]); SQRADDAC(a[39], a[41]); SQRADDDB; SQRADD(a[40], a[40]); 
-   COMBA_STORE(b[80]);
-
-   /* output 81 */
-   CARRY_FORWARD;
-   SQRADDSC(a[34], a[47]); SQRADDAC(a[35], a[46]); SQRADDAC(a[36], a[45]); SQRADDAC(a[37], a[44]); SQRADDAC(a[38], a[43]); SQRADDAC(a[39], a[42]); SQRADDAC(a[40], a[41]); SQRADDDB; 
-   COMBA_STORE(b[81]);
-
-   /* output 82 */
-   CARRY_FORWARD;
-   SQRADDSC(a[35], a[47]); SQRADDAC(a[36], a[46]); SQRADDAC(a[37], a[45]); SQRADDAC(a[38], a[44]); SQRADDAC(a[39], a[43]); SQRADDAC(a[40], a[42]); SQRADDDB; SQRADD(a[41], a[41]); 
-   COMBA_STORE(b[82]);
-
-   /* output 83 */
-   CARRY_FORWARD;
-   SQRADDSC(a[36], a[47]); SQRADDAC(a[37], a[46]); SQRADDAC(a[38], a[45]); SQRADDAC(a[39], a[44]); SQRADDAC(a[40], a[43]); SQRADDAC(a[41], a[42]); SQRADDDB; 
-   COMBA_STORE(b[83]);
-
-   /* output 84 */
-   CARRY_FORWARD;
-   SQRADDSC(a[37], a[47]); SQRADDAC(a[38], a[46]); SQRADDAC(a[39], a[45]); SQRADDAC(a[40], a[44]); SQRADDAC(a[41], a[43]); SQRADDDB; SQRADD(a[42], a[42]); 
-   COMBA_STORE(b[84]);
-
-   /* output 85 */
-   CARRY_FORWARD;
-   SQRADDSC(a[38], a[47]); SQRADDAC(a[39], a[46]); SQRADDAC(a[40], a[45]); SQRADDAC(a[41], a[44]); SQRADDAC(a[42], a[43]); SQRADDDB; 
-   COMBA_STORE(b[85]);
-
-   /* output 86 */
-   CARRY_FORWARD;
-   SQRADDSC(a[39], a[47]); SQRADDAC(a[40], a[46]); SQRADDAC(a[41], a[45]); SQRADDAC(a[42], a[44]); SQRADDDB; SQRADD(a[43], a[43]); 
-   COMBA_STORE(b[86]);
-
-   /* output 87 */
-   CARRY_FORWARD;
-   SQRADDSC(a[40], a[47]); SQRADDAC(a[41], a[46]); SQRADDAC(a[42], a[45]); SQRADDAC(a[43], a[44]); SQRADDDB; 
-   COMBA_STORE(b[87]);
-
-   /* output 88 */
-   CARRY_FORWARD;
-   SQRADDSC(a[41], a[47]); SQRADDAC(a[42], a[46]); SQRADDAC(a[43], a[45]); SQRADDDB; SQRADD(a[44], a[44]); 
-   COMBA_STORE(b[88]);
-
-   /* output 89 */
-   CARRY_FORWARD;
-   SQRADDSC(a[42], a[47]); SQRADDAC(a[43], a[46]); SQRADDAC(a[44], a[45]); SQRADDDB; 
-   COMBA_STORE(b[89]);
-
-   /* output 90 */
-   CARRY_FORWARD;
-   SQRADD2(a[43], a[47]); SQRADD2(a[44], a[46]); SQRADD(a[45], a[45]); 
-   COMBA_STORE(b[90]);
-
-   /* output 91 */
-   CARRY_FORWARD;
-   SQRADD2(a[44], a[47]); SQRADD2(a[45], a[46]); 
-   COMBA_STORE(b[91]);
-
-   /* output 92 */
-   CARRY_FORWARD;
-   SQRADD2(a[45], a[47]); SQRADD(a[46], a[46]); 
-   COMBA_STORE(b[92]);
-
-   /* output 93 */
-   CARRY_FORWARD;
-   SQRADD2(a[46], a[47]); 
-   COMBA_STORE(b[93]);
-
-   /* output 94 */
-   CARRY_FORWARD;
-   SQRADD(a[47], a[47]); 
-   COMBA_STORE(b[94]);
-   COMBA_STORE2(b[95]);
-   COMBA_FINI;
-
-   B->used = 96;
-   B->sign = FP_ZPOS;
-   memcpy(B->dp, b, 96 * sizeof(fp_digit));
-   fp_clamp(B);
-}
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_6.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_6.i
deleted file mode 100755
index bb2fd74..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_6.i
+++ /dev/null
@@ -1,100 +0,0 @@
-/* fp_sqr_comba_6.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SQR6
-void fp_sqr_comba6(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[12], c0, c1, c2, sc0, sc1, sc2;
-#ifdef TFM_ISO
-   fp_word tt;
-#endif
-
-   a = A->dp;
-   COMBA_START; 
-
-   /* clear carries */
-   CLEAR_CARRY;
-
-   /* output 0 */
-   SQRADD(a[0],a[0]);
-   COMBA_STORE(b[0]);
-
-   /* output 1 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[1]); 
-   COMBA_STORE(b[1]);
-
-   /* output 2 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
-   COMBA_STORE(b[2]);
-
-   /* output 3 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
-   COMBA_STORE(b[3]);
-
-   /* output 4 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
-   COMBA_STORE(b[4]);
-
-   /* output 5 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-   COMBA_STORE(b[5]);
-
-   /* output 6 */
-   CARRY_FORWARD;
-   SQRADD2(a[1], a[5]); SQRADD2(a[2], a[4]); SQRADD(a[3], a[3]); 
-   COMBA_STORE(b[6]);
-
-   /* output 7 */
-   CARRY_FORWARD;
-   SQRADD2(a[2], a[5]); SQRADD2(a[3], a[4]); 
-   COMBA_STORE(b[7]);
-
-   /* output 8 */
-   CARRY_FORWARD;
-   SQRADD2(a[3], a[5]); SQRADD(a[4], a[4]); 
-   COMBA_STORE(b[8]);
-
-   /* output 9 */
-   CARRY_FORWARD;
-   SQRADD2(a[4], a[5]); 
-   COMBA_STORE(b[9]);
-
-   /* output 10 */
-   CARRY_FORWARD;
-   SQRADD(a[5], a[5]); 
-   COMBA_STORE(b[10]);
-   COMBA_STORE2(b[11]);
-   COMBA_FINI;
-
-   B->used = 12;
-   B->sign = FP_ZPOS;
-   memcpy(B->dp, b, 12 * sizeof(fp_digit));
-   fp_clamp(B);
-}
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_64.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_64.i
deleted file mode 100755
index b74367a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_64.i
+++ /dev/null
@@ -1,680 +0,0 @@
-/* fp_sqr_comba_64.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SQR64
-void fp_sqr_comba64(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[128], c0, c1, c2, sc0, sc1, sc2;
-#ifdef TFM_ISO
-   fp_word   tt;   
-#endif   
-
-   a = A->dp;
-   COMBA_START; 
-
-   /* clear carries */
-   CLEAR_CARRY;
-
-   /* output 0 */
-   SQRADD(a[0],a[0]);
-   COMBA_STORE(b[0]);
-
-   /* output 1 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[1]); 
-   COMBA_STORE(b[1]);
-
-   /* output 2 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
-   COMBA_STORE(b[2]);
-
-   /* output 3 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
-   COMBA_STORE(b[3]);
-
-   /* output 4 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
-   COMBA_STORE(b[4]);
-
-   /* output 5 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-   COMBA_STORE(b[5]);
-
-   /* output 6 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-   COMBA_STORE(b[6]);
-
-   /* output 7 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-   COMBA_STORE(b[7]);
-
-   /* output 8 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-   COMBA_STORE(b[8]);
-
-   /* output 9 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-   COMBA_STORE(b[9]);
-
-   /* output 10 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-   COMBA_STORE(b[10]);
-
-   /* output 11 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-   COMBA_STORE(b[11]);
-
-   /* output 12 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-   COMBA_STORE(b[12]);
-
-   /* output 13 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-   COMBA_STORE(b[13]);
-
-   /* output 14 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); 
-   COMBA_STORE(b[14]);
-
-   /* output 15 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; 
-   COMBA_STORE(b[15]);
-
-   /* output 16 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); 
-   COMBA_STORE(b[16]);
-
-   /* output 17 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[17]); SQRADDAC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; 
-   COMBA_STORE(b[17]);
-
-   /* output 18 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[18]); SQRADDAC(a[1], a[17]); SQRADDAC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); 
-   COMBA_STORE(b[18]);
-
-   /* output 19 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[19]); SQRADDAC(a[1], a[18]); SQRADDAC(a[2], a[17]); SQRADDAC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; 
-   COMBA_STORE(b[19]);
-
-   /* output 20 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[20]); SQRADDAC(a[1], a[19]); SQRADDAC(a[2], a[18]); SQRADDAC(a[3], a[17]); SQRADDAC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); 
-   COMBA_STORE(b[20]);
-
-   /* output 21 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[21]); SQRADDAC(a[1], a[20]); SQRADDAC(a[2], a[19]); SQRADDAC(a[3], a[18]); SQRADDAC(a[4], a[17]); SQRADDAC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; 
-   COMBA_STORE(b[21]);
-
-   /* output 22 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[22]); SQRADDAC(a[1], a[21]); SQRADDAC(a[2], a[20]); SQRADDAC(a[3], a[19]); SQRADDAC(a[4], a[18]); SQRADDAC(a[5], a[17]); SQRADDAC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); 
-   COMBA_STORE(b[22]);
-
-   /* output 23 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[23]); SQRADDAC(a[1], a[22]); SQRADDAC(a[2], a[21]); SQRADDAC(a[3], a[20]); SQRADDAC(a[4], a[19]); SQRADDAC(a[5], a[18]); SQRADDAC(a[6], a[17]); SQRADDAC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; 
-   COMBA_STORE(b[23]);
-
-   /* output 24 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[24]); SQRADDAC(a[1], a[23]); SQRADDAC(a[2], a[22]); SQRADDAC(a[3], a[21]); SQRADDAC(a[4], a[20]); SQRADDAC(a[5], a[19]); SQRADDAC(a[6], a[18]); SQRADDAC(a[7], a[17]); SQRADDAC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); 
-   COMBA_STORE(b[24]);
-
-   /* output 25 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[25]); SQRADDAC(a[1], a[24]); SQRADDAC(a[2], a[23]); SQRADDAC(a[3], a[22]); SQRADDAC(a[4], a[21]); SQRADDAC(a[5], a[20]); SQRADDAC(a[6], a[19]); SQRADDAC(a[7], a[18]); SQRADDAC(a[8], a[17]); SQRADDAC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; 
-   COMBA_STORE(b[25]);
-
-   /* output 26 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[26]); SQRADDAC(a[1], a[25]); SQRADDAC(a[2], a[24]); SQRADDAC(a[3], a[23]); SQRADDAC(a[4], a[22]); SQRADDAC(a[5], a[21]); SQRADDAC(a[6], a[20]); SQRADDAC(a[7], a[19]); SQRADDAC(a[8], a[18]); SQRADDAC(a[9], a[17]); SQRADDAC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); 
-   COMBA_STORE(b[26]);
-
-   /* output 27 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[27]); SQRADDAC(a[1], a[26]); SQRADDAC(a[2], a[25]); SQRADDAC(a[3], a[24]); SQRADDAC(a[4], a[23]); SQRADDAC(a[5], a[22]); SQRADDAC(a[6], a[21]); SQRADDAC(a[7], a[20]); SQRADDAC(a[8], a[19]); SQRADDAC(a[9], a[18]); SQRADDAC(a[10], a[17]); SQRADDAC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; 
-   COMBA_STORE(b[27]);
-
-   /* output 28 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[28]); SQRADDAC(a[1], a[27]); SQRADDAC(a[2], a[26]); SQRADDAC(a[3], a[25]); SQRADDAC(a[4], a[24]); SQRADDAC(a[5], a[23]); SQRADDAC(a[6], a[22]); SQRADDAC(a[7], a[21]); SQRADDAC(a[8], a[20]); SQRADDAC(a[9], a[19]); SQRADDAC(a[10], a[18]); SQRADDAC(a[11], a[17]); SQRADDAC(a[12], a[16]); SQRADDAC(a[13], a[15]); SQRADDDB; SQRADD(a[14], a[14]); 
-   COMBA_STORE(b[28]);
-
-   /* output 29 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[29]); SQRADDAC(a[1], a[28]); SQRADDAC(a[2], a[27]); SQRADDAC(a[3], a[26]); SQRADDAC(a[4], a[25]); SQRADDAC(a[5], a[24]); SQRADDAC(a[6], a[23]); SQRADDAC(a[7], a[22]); SQRADDAC(a[8], a[21]); SQRADDAC(a[9], a[20]); SQRADDAC(a[10], a[19]); SQRADDAC(a[11], a[18]); SQRADDAC(a[12], a[17]); SQRADDAC(a[13], a[16]); SQRADDAC(a[14], a[15]); SQRADDDB; 
-   COMBA_STORE(b[29]);
-
-   /* output 30 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[30]); SQRADDAC(a[1], a[29]); SQRADDAC(a[2], a[28]); SQRADDAC(a[3], a[27]); SQRADDAC(a[4], a[26]); SQRADDAC(a[5], a[25]); SQRADDAC(a[6], a[24]); SQRADDAC(a[7], a[23]); SQRADDAC(a[8], a[22]); SQRADDAC(a[9], a[21]); SQRADDAC(a[10], a[20]); SQRADDAC(a[11], a[19]); SQRADDAC(a[12], a[18]); SQRADDAC(a[13], a[17]); SQRADDAC(a[14], a[16]); SQRADDDB; SQRADD(a[15], a[15]); 
-   COMBA_STORE(b[30]);
-
-   /* output 31 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[31]); SQRADDAC(a[1], a[30]); SQRADDAC(a[2], a[29]); SQRADDAC(a[3], a[28]); SQRADDAC(a[4], a[27]); SQRADDAC(a[5], a[26]); SQRADDAC(a[6], a[25]); SQRADDAC(a[7], a[24]); SQRADDAC(a[8], a[23]); SQRADDAC(a[9], a[22]); SQRADDAC(a[10], a[21]); SQRADDAC(a[11], a[20]); SQRADDAC(a[12], a[19]); SQRADDAC(a[13], a[18]); SQRADDAC(a[14], a[17]); SQRADDAC(a[15], a[16]); SQRADDDB; 
-   COMBA_STORE(b[31]);
-
-   /* output 32 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[32]); SQRADDAC(a[1], a[31]); SQRADDAC(a[2], a[30]); SQRADDAC(a[3], a[29]); SQRADDAC(a[4], a[28]); SQRADDAC(a[5], a[27]); SQRADDAC(a[6], a[26]); SQRADDAC(a[7], a[25]); SQRADDAC(a[8], a[24]); SQRADDAC(a[9], a[23]); SQRADDAC(a[10], a[22]); SQRADDAC(a[11], a[21]); SQRADDAC(a[12], a[20]); SQRADDAC(a[13], a[19]); SQRADDAC(a[14], a[18]); SQRADDAC(a[15], a[17]); SQRADDDB; SQRADD(a[16], a[16]); 
-   COMBA_STORE(b[32]);
-
-   /* output 33 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[33]); SQRADDAC(a[1], a[32]); SQRADDAC(a[2], a[31]); SQRADDAC(a[3], a[30]); SQRADDAC(a[4], a[29]); SQRADDAC(a[5], a[28]); SQRADDAC(a[6], a[27]); SQRADDAC(a[7], a[26]); SQRADDAC(a[8], a[25]); SQRADDAC(a[9], a[24]); SQRADDAC(a[10], a[23]); SQRADDAC(a[11], a[22]); SQRADDAC(a[12], a[21]); SQRADDAC(a[13], a[20]); SQRADDAC(a[14], a[19]); SQRADDAC(a[15], a[18]); SQRADDAC(a[16], a[17]); SQRADDDB; 
-   COMBA_STORE(b[33]);
-
-   /* output 34 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[34]); SQRADDAC(a[1], a[33]); SQRADDAC(a[2], a[32]); SQRADDAC(a[3], a[31]); SQRADDAC(a[4], a[30]); SQRADDAC(a[5], a[29]); SQRADDAC(a[6], a[28]); SQRADDAC(a[7], a[27]); SQRADDAC(a[8], a[26]); SQRADDAC(a[9], a[25]); SQRADDAC(a[10], a[24]); SQRADDAC(a[11], a[23]); SQRADDAC(a[12], a[22]); SQRADDAC(a[13], a[21]); SQRADDAC(a[14], a[20]); SQRADDAC(a[15], a[19]); SQRADDAC(a[16], a[18]); SQRADDDB; SQRADD(a[17], a[17]); 
-   COMBA_STORE(b[34]);
-
-   /* output 35 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[35]); SQRADDAC(a[1], a[34]); SQRADDAC(a[2], a[33]); SQRADDAC(a[3], a[32]); SQRADDAC(a[4], a[31]); SQRADDAC(a[5], a[30]); SQRADDAC(a[6], a[29]); SQRADDAC(a[7], a[28]); SQRADDAC(a[8], a[27]); SQRADDAC(a[9], a[26]); SQRADDAC(a[10], a[25]); SQRADDAC(a[11], a[24]); SQRADDAC(a[12], a[23]); SQRADDAC(a[13], a[22]); SQRADDAC(a[14], a[21]); SQRADDAC(a[15], a[20]); SQRADDAC(a[16], a[19]); SQRADDAC(a[17], a[18]); SQRADDDB; 
-   COMBA_STORE(b[35]);
-
-   /* output 36 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[36]); SQRADDAC(a[1], a[35]); SQRADDAC(a[2], a[34]); SQRADDAC(a[3], a[33]); SQRADDAC(a[4], a[32]); SQRADDAC(a[5], a[31]); SQRADDAC(a[6], a[30]); SQRADDAC(a[7], a[29]); SQRADDAC(a[8], a[28]); SQRADDAC(a[9], a[27]); SQRADDAC(a[10], a[26]); SQRADDAC(a[11], a[25]); SQRADDAC(a[12], a[24]); SQRADDAC(a[13], a[23]); SQRADDAC(a[14], a[22]); SQRADDAC(a[15], a[21]); SQRADDAC(a[16], a[20]); SQRADDAC(a[17], a[19]); SQRADDDB; SQRADD(a[18], a[18]); 
-   COMBA_STORE(b[36]);
-
-   /* output 37 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[37]); SQRADDAC(a[1], a[36]); SQRADDAC(a[2], a[35]); SQRADDAC(a[3], a[34]); SQRADDAC(a[4], a[33]); SQRADDAC(a[5], a[32]); SQRADDAC(a[6], a[31]); SQRADDAC(a[7], a[30]); SQRADDAC(a[8], a[29]); SQRADDAC(a[9], a[28]); SQRADDAC(a[10], a[27]); SQRADDAC(a[11], a[26]); SQRADDAC(a[12], a[25]); SQRADDAC(a[13], a[24]); SQRADDAC(a[14], a[23]); SQRADDAC(a[15], a[22]); SQRADDAC(a[16], a[21]); SQRADDAC(a[17], a[20]); SQRADDAC(a[18], a[19]); SQRADDDB; 
-   COMBA_STORE(b[37]);
-
-   /* output 38 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[38]); SQRADDAC(a[1], a[37]); SQRADDAC(a[2], a[36]); SQRADDAC(a[3], a[35]); SQRADDAC(a[4], a[34]); SQRADDAC(a[5], a[33]); SQRADDAC(a[6], a[32]); SQRADDAC(a[7], a[31]); SQRADDAC(a[8], a[30]); SQRADDAC(a[9], a[29]); SQRADDAC(a[10], a[28]); SQRADDAC(a[11], a[27]); SQRADDAC(a[12], a[26]); SQRADDAC(a[13], a[25]); SQRADDAC(a[14], a[24]); SQRADDAC(a[15], a[23]); SQRADDAC(a[16], a[22]); SQRADDAC(a[17], a[21]); SQRADDAC(a[18], a[20]); SQRADDDB; SQRADD(a[19], a[19]); 
-   COMBA_STORE(b[38]);
-
-   /* output 39 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[39]); SQRADDAC(a[1], a[38]); SQRADDAC(a[2], a[37]); SQRADDAC(a[3], a[36]); SQRADDAC(a[4], a[35]); SQRADDAC(a[5], a[34]); SQRADDAC(a[6], a[33]); SQRADDAC(a[7], a[32]); SQRADDAC(a[8], a[31]); SQRADDAC(a[9], a[30]); SQRADDAC(a[10], a[29]); SQRADDAC(a[11], a[28]); SQRADDAC(a[12], a[27]); SQRADDAC(a[13], a[26]); SQRADDAC(a[14], a[25]); SQRADDAC(a[15], a[24]); SQRADDAC(a[16], a[23]); SQRADDAC(a[17], a[22]); SQRADDAC(a[18], a[21]); SQRADDAC(a[19], a[20]); SQRADDDB; 
-   COMBA_STORE(b[39]);
-
-   /* output 40 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[40]); SQRADDAC(a[1], a[39]); SQRADDAC(a[2], a[38]); SQRADDAC(a[3], a[37]); SQRADDAC(a[4], a[36]); SQRADDAC(a[5], a[35]); SQRADDAC(a[6], a[34]); SQRADDAC(a[7], a[33]); SQRADDAC(a[8], a[32]); SQRADDAC(a[9], a[31]); SQRADDAC(a[10], a[30]); SQRADDAC(a[11], a[29]); SQRADDAC(a[12], a[28]); SQRADDAC(a[13], a[27]); SQRADDAC(a[14], a[26]); SQRADDAC(a[15], a[25]); SQRADDAC(a[16], a[24]); SQRADDAC(a[17], a[23]); SQRADDAC(a[18], a[22]); SQRADDAC(a[19], a[21]); SQRADDDB; SQRADD(a[20], a[20]); 
-   COMBA_STORE(b[40]);
-
-   /* output 41 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[41]); SQRADDAC(a[1], a[40]); SQRADDAC(a[2], a[39]); SQRADDAC(a[3], a[38]); SQRADDAC(a[4], a[37]); SQRADDAC(a[5], a[36]); SQRADDAC(a[6], a[35]); SQRADDAC(a[7], a[34]); SQRADDAC(a[8], a[33]); SQRADDAC(a[9], a[32]); SQRADDAC(a[10], a[31]); SQRADDAC(a[11], a[30]); SQRADDAC(a[12], a[29]); SQRADDAC(a[13], a[28]); SQRADDAC(a[14], a[27]); SQRADDAC(a[15], a[26]); SQRADDAC(a[16], a[25]); SQRADDAC(a[17], a[24]); SQRADDAC(a[18], a[23]); SQRADDAC(a[19], a[22]); SQRADDAC(a[20], a[21]); SQRADDDB; 
-   COMBA_STORE(b[41]);
-
-   /* output 42 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[42]); SQRADDAC(a[1], a[41]); SQRADDAC(a[2], a[40]); SQRADDAC(a[3], a[39]); SQRADDAC(a[4], a[38]); SQRADDAC(a[5], a[37]); SQRADDAC(a[6], a[36]); SQRADDAC(a[7], a[35]); SQRADDAC(a[8], a[34]); SQRADDAC(a[9], a[33]); SQRADDAC(a[10], a[32]); SQRADDAC(a[11], a[31]); SQRADDAC(a[12], a[30]); SQRADDAC(a[13], a[29]); SQRADDAC(a[14], a[28]); SQRADDAC(a[15], a[27]); SQRADDAC(a[16], a[26]); SQRADDAC(a[17], a[25]); SQRADDAC(a[18], a[24]); SQRADDAC(a[19], a[23]); SQRADDAC(a[20], a[22]); SQRADDDB; SQRADD(a[21], a[21]); 
-   COMBA_STORE(b[42]);
-
-   /* output 43 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[43]); SQRADDAC(a[1], a[42]); SQRADDAC(a[2], a[41]); SQRADDAC(a[3], a[40]); SQRADDAC(a[4], a[39]); SQRADDAC(a[5], a[38]); SQRADDAC(a[6], a[37]); SQRADDAC(a[7], a[36]); SQRADDAC(a[8], a[35]); SQRADDAC(a[9], a[34]); SQRADDAC(a[10], a[33]); SQRADDAC(a[11], a[32]); SQRADDAC(a[12], a[31]); SQRADDAC(a[13], a[30]); SQRADDAC(a[14], a[29]); SQRADDAC(a[15], a[28]); SQRADDAC(a[16], a[27]); SQRADDAC(a[17], a[26]); SQRADDAC(a[18], a[25]); SQRADDAC(a[19], a[24]); SQRADDAC(a[20], a[23]); SQRADDAC(a[21], a[22]); SQRADDDB; 
-   COMBA_STORE(b[43]);
-
-   /* output 44 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[44]); SQRADDAC(a[1], a[43]); SQRADDAC(a[2], a[42]); SQRADDAC(a[3], a[41]); SQRADDAC(a[4], a[40]); SQRADDAC(a[5], a[39]); SQRADDAC(a[6], a[38]); SQRADDAC(a[7], a[37]); SQRADDAC(a[8], a[36]); SQRADDAC(a[9], a[35]); SQRADDAC(a[10], a[34]); SQRADDAC(a[11], a[33]); SQRADDAC(a[12], a[32]); SQRADDAC(a[13], a[31]); SQRADDAC(a[14], a[30]); SQRADDAC(a[15], a[29]); SQRADDAC(a[16], a[28]); SQRADDAC(a[17], a[27]); SQRADDAC(a[18], a[26]); SQRADDAC(a[19], a[25]); SQRADDAC(a[20], a[24]); SQRADDAC(a[21], a[23]); SQRADDDB; SQRADD(a[22], a[22]); 
-   COMBA_STORE(b[44]);
-
-   /* output 45 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[45]); SQRADDAC(a[1], a[44]); SQRADDAC(a[2], a[43]); SQRADDAC(a[3], a[42]); SQRADDAC(a[4], a[41]); SQRADDAC(a[5], a[40]); SQRADDAC(a[6], a[39]); SQRADDAC(a[7], a[38]); SQRADDAC(a[8], a[37]); SQRADDAC(a[9], a[36]); SQRADDAC(a[10], a[35]); SQRADDAC(a[11], a[34]); SQRADDAC(a[12], a[33]); SQRADDAC(a[13], a[32]); SQRADDAC(a[14], a[31]); SQRADDAC(a[15], a[30]); SQRADDAC(a[16], a[29]); SQRADDAC(a[17], a[28]); SQRADDAC(a[18], a[27]); SQRADDAC(a[19], a[26]); SQRADDAC(a[20], a[25]); SQRADDAC(a[21], a[24]); SQRADDAC(a[22], a[23]); SQRADDDB; 
-   COMBA_STORE(b[45]);
-
-   /* output 46 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[46]); SQRADDAC(a[1], a[45]); SQRADDAC(a[2], a[44]); SQRADDAC(a[3], a[43]); SQRADDAC(a[4], a[42]); SQRADDAC(a[5], a[41]); SQRADDAC(a[6], a[40]); SQRADDAC(a[7], a[39]); SQRADDAC(a[8], a[38]); SQRADDAC(a[9], a[37]); SQRADDAC(a[10], a[36]); SQRADDAC(a[11], a[35]); SQRADDAC(a[12], a[34]); SQRADDAC(a[13], a[33]); SQRADDAC(a[14], a[32]); SQRADDAC(a[15], a[31]); SQRADDAC(a[16], a[30]); SQRADDAC(a[17], a[29]); SQRADDAC(a[18], a[28]); SQRADDAC(a[19], a[27]); SQRADDAC(a[20], a[26]); SQRADDAC(a[21], a[25]); SQRADDAC(a[22], a[24]); SQRADDDB; SQRADD(a[23], a[23]); 
-   COMBA_STORE(b[46]);
-
-   /* output 47 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[47]); SQRADDAC(a[1], a[46]); SQRADDAC(a[2], a[45]); SQRADDAC(a[3], a[44]); SQRADDAC(a[4], a[43]); SQRADDAC(a[5], a[42]); SQRADDAC(a[6], a[41]); SQRADDAC(a[7], a[40]); SQRADDAC(a[8], a[39]); SQRADDAC(a[9], a[38]); SQRADDAC(a[10], a[37]); SQRADDAC(a[11], a[36]); SQRADDAC(a[12], a[35]); SQRADDAC(a[13], a[34]); SQRADDAC(a[14], a[33]); SQRADDAC(a[15], a[32]); SQRADDAC(a[16], a[31]); SQRADDAC(a[17], a[30]); SQRADDAC(a[18], a[29]); SQRADDAC(a[19], a[28]); SQRADDAC(a[20], a[27]); SQRADDAC(a[21], a[26]); SQRADDAC(a[22], a[25]); SQRADDAC(a[23], a[24]); SQRADDDB; 
-   COMBA_STORE(b[47]);
-
-   /* output 48 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[48]); SQRADDAC(a[1], a[47]); SQRADDAC(a[2], a[46]); SQRADDAC(a[3], a[45]); SQRADDAC(a[4], a[44]); SQRADDAC(a[5], a[43]); SQRADDAC(a[6], a[42]); SQRADDAC(a[7], a[41]); SQRADDAC(a[8], a[40]); SQRADDAC(a[9], a[39]); SQRADDAC(a[10], a[38]); SQRADDAC(a[11], a[37]); SQRADDAC(a[12], a[36]); SQRADDAC(a[13], a[35]); SQRADDAC(a[14], a[34]); SQRADDAC(a[15], a[33]); SQRADDAC(a[16], a[32]); SQRADDAC(a[17], a[31]); SQRADDAC(a[18], a[30]); SQRADDAC(a[19], a[29]); SQRADDAC(a[20], a[28]); SQRADDAC(a[21], a[27]); SQRADDAC(a[22], a[26]); SQRADDAC(a[23], a[25]); SQRADDDB; SQRADD(a[24], a[24]); 
-   COMBA_STORE(b[48]);
-
-   /* output 49 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[49]); SQRADDAC(a[1], a[48]); SQRADDAC(a[2], a[47]); SQRADDAC(a[3], a[46]); SQRADDAC(a[4], a[45]); SQRADDAC(a[5], a[44]); SQRADDAC(a[6], a[43]); SQRADDAC(a[7], a[42]); SQRADDAC(a[8], a[41]); SQRADDAC(a[9], a[40]); SQRADDAC(a[10], a[39]); SQRADDAC(a[11], a[38]); SQRADDAC(a[12], a[37]); SQRADDAC(a[13], a[36]); SQRADDAC(a[14], a[35]); SQRADDAC(a[15], a[34]); SQRADDAC(a[16], a[33]); SQRADDAC(a[17], a[32]); SQRADDAC(a[18], a[31]); SQRADDAC(a[19], a[30]); SQRADDAC(a[20], a[29]); SQRADDAC(a[21], a[28]); SQRADDAC(a[22], a[27]); SQRADDAC(a[23], a[26]); SQRADDAC(a[24], a[25]); SQRADDDB; 
-   COMBA_STORE(b[49]);
-
-   /* output 50 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[50]); SQRADDAC(a[1], a[49]); SQRADDAC(a[2], a[48]); SQRADDAC(a[3], a[47]); SQRADDAC(a[4], a[46]); SQRADDAC(a[5], a[45]); SQRADDAC(a[6], a[44]); SQRADDAC(a[7], a[43]); SQRADDAC(a[8], a[42]); SQRADDAC(a[9], a[41]); SQRADDAC(a[10], a[40]); SQRADDAC(a[11], a[39]); SQRADDAC(a[12], a[38]); SQRADDAC(a[13], a[37]); SQRADDAC(a[14], a[36]); SQRADDAC(a[15], a[35]); SQRADDAC(a[16], a[34]); SQRADDAC(a[17], a[33]); SQRADDAC(a[18], a[32]); SQRADDAC(a[19], a[31]); SQRADDAC(a[20], a[30]); SQRADDAC(a[21], a[29]); SQRADDAC(a[22], a[28]); SQRADDAC(a[23], a[27]); SQRADDAC(a[24], a[26]); SQRADDDB; SQRADD(a[25], a[25]); 
-   COMBA_STORE(b[50]);
-
-   /* output 51 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[51]); SQRADDAC(a[1], a[50]); SQRADDAC(a[2], a[49]); SQRADDAC(a[3], a[48]); SQRADDAC(a[4], a[47]); SQRADDAC(a[5], a[46]); SQRADDAC(a[6], a[45]); SQRADDAC(a[7], a[44]); SQRADDAC(a[8], a[43]); SQRADDAC(a[9], a[42]); SQRADDAC(a[10], a[41]); SQRADDAC(a[11], a[40]); SQRADDAC(a[12], a[39]); SQRADDAC(a[13], a[38]); SQRADDAC(a[14], a[37]); SQRADDAC(a[15], a[36]); SQRADDAC(a[16], a[35]); SQRADDAC(a[17], a[34]); SQRADDAC(a[18], a[33]); SQRADDAC(a[19], a[32]); SQRADDAC(a[20], a[31]); SQRADDAC(a[21], a[30]); SQRADDAC(a[22], a[29]); SQRADDAC(a[23], a[28]); SQRADDAC(a[24], a[27]); SQRADDAC(a[25], a[26]); SQRADDDB; 
-   COMBA_STORE(b[51]);
-
-   /* output 52 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[52]); SQRADDAC(a[1], a[51]); SQRADDAC(a[2], a[50]); SQRADDAC(a[3], a[49]); SQRADDAC(a[4], a[48]); SQRADDAC(a[5], a[47]); SQRADDAC(a[6], a[46]); SQRADDAC(a[7], a[45]); SQRADDAC(a[8], a[44]); SQRADDAC(a[9], a[43]); SQRADDAC(a[10], a[42]); SQRADDAC(a[11], a[41]); SQRADDAC(a[12], a[40]); SQRADDAC(a[13], a[39]); SQRADDAC(a[14], a[38]); SQRADDAC(a[15], a[37]); SQRADDAC(a[16], a[36]); SQRADDAC(a[17], a[35]); SQRADDAC(a[18], a[34]); SQRADDAC(a[19], a[33]); SQRADDAC(a[20], a[32]); SQRADDAC(a[21], a[31]); SQRADDAC(a[22], a[30]); SQRADDAC(a[23], a[29]); SQRADDAC(a[24], a[28]); SQRADDAC(a[25], a[27]); SQRADDDB; SQRADD(a[26], a[26]); 
-   COMBA_STORE(b[52]);
-
-   /* output 53 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[53]); SQRADDAC(a[1], a[52]); SQRADDAC(a[2], a[51]); SQRADDAC(a[3], a[50]); SQRADDAC(a[4], a[49]); SQRADDAC(a[5], a[48]); SQRADDAC(a[6], a[47]); SQRADDAC(a[7], a[46]); SQRADDAC(a[8], a[45]); SQRADDAC(a[9], a[44]); SQRADDAC(a[10], a[43]); SQRADDAC(a[11], a[42]); SQRADDAC(a[12], a[41]); SQRADDAC(a[13], a[40]); SQRADDAC(a[14], a[39]); SQRADDAC(a[15], a[38]); SQRADDAC(a[16], a[37]); SQRADDAC(a[17], a[36]); SQRADDAC(a[18], a[35]); SQRADDAC(a[19], a[34]); SQRADDAC(a[20], a[33]); SQRADDAC(a[21], a[32]); SQRADDAC(a[22], a[31]); SQRADDAC(a[23], a[30]); SQRADDAC(a[24], a[29]); SQRADDAC(a[25], a[28]); SQRADDAC(a[26], a[27]); SQRADDDB; 
-   COMBA_STORE(b[53]);
-
-   /* output 54 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[54]); SQRADDAC(a[1], a[53]); SQRADDAC(a[2], a[52]); SQRADDAC(a[3], a[51]); SQRADDAC(a[4], a[50]); SQRADDAC(a[5], a[49]); SQRADDAC(a[6], a[48]); SQRADDAC(a[7], a[47]); SQRADDAC(a[8], a[46]); SQRADDAC(a[9], a[45]); SQRADDAC(a[10], a[44]); SQRADDAC(a[11], a[43]); SQRADDAC(a[12], a[42]); SQRADDAC(a[13], a[41]); SQRADDAC(a[14], a[40]); SQRADDAC(a[15], a[39]); SQRADDAC(a[16], a[38]); SQRADDAC(a[17], a[37]); SQRADDAC(a[18], a[36]); SQRADDAC(a[19], a[35]); SQRADDAC(a[20], a[34]); SQRADDAC(a[21], a[33]); SQRADDAC(a[22], a[32]); SQRADDAC(a[23], a[31]); SQRADDAC(a[24], a[30]); SQRADDAC(a[25], a[29]); SQRADDAC(a[26], a[28]); SQRADDDB; SQRADD(a[27], a[27]); 
-   COMBA_STORE(b[54]);
-
-   /* output 55 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[55]); SQRADDAC(a[1], a[54]); SQRADDAC(a[2], a[53]); SQRADDAC(a[3], a[52]); SQRADDAC(a[4], a[51]); SQRADDAC(a[5], a[50]); SQRADDAC(a[6], a[49]); SQRADDAC(a[7], a[48]); SQRADDAC(a[8], a[47]); SQRADDAC(a[9], a[46]); SQRADDAC(a[10], a[45]); SQRADDAC(a[11], a[44]); SQRADDAC(a[12], a[43]); SQRADDAC(a[13], a[42]); SQRADDAC(a[14], a[41]); SQRADDAC(a[15], a[40]); SQRADDAC(a[16], a[39]); SQRADDAC(a[17], a[38]); SQRADDAC(a[18], a[37]); SQRADDAC(a[19], a[36]); SQRADDAC(a[20], a[35]); SQRADDAC(a[21], a[34]); SQRADDAC(a[22], a[33]); SQRADDAC(a[23], a[32]); SQRADDAC(a[24], a[31]); SQRADDAC(a[25], a[30]); SQRADDAC(a[26], a[29]); SQRADDAC(a[27], a[28]); SQRADDDB; 
-   COMBA_STORE(b[55]);
-
-   /* output 56 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[56]); SQRADDAC(a[1], a[55]); SQRADDAC(a[2], a[54]); SQRADDAC(a[3], a[53]); SQRADDAC(a[4], a[52]); SQRADDAC(a[5], a[51]); SQRADDAC(a[6], a[50]); SQRADDAC(a[7], a[49]); SQRADDAC(a[8], a[48]); SQRADDAC(a[9], a[47]); SQRADDAC(a[10], a[46]); SQRADDAC(a[11], a[45]); SQRADDAC(a[12], a[44]); SQRADDAC(a[13], a[43]); SQRADDAC(a[14], a[42]); SQRADDAC(a[15], a[41]); SQRADDAC(a[16], a[40]); SQRADDAC(a[17], a[39]); SQRADDAC(a[18], a[38]); SQRADDAC(a[19], a[37]); SQRADDAC(a[20], a[36]); SQRADDAC(a[21], a[35]); SQRADDAC(a[22], a[34]); SQRADDAC(a[23], a[33]); SQRADDAC(a[24], a[32]); SQRADDAC(a[25], a[31]); SQRADDAC(a[26], a[30]); SQRADDAC(a[27], a[29]); SQRADDDB; SQRADD(a[28], a[28]); 
-   COMBA_STORE(b[56]);
-
-   /* output 57 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[57]); SQRADDAC(a[1], a[56]); SQRADDAC(a[2], a[55]); SQRADDAC(a[3], a[54]); SQRADDAC(a[4], a[53]); SQRADDAC(a[5], a[52]); SQRADDAC(a[6], a[51]); SQRADDAC(a[7], a[50]); SQRADDAC(a[8], a[49]); SQRADDAC(a[9], a[48]); SQRADDAC(a[10], a[47]); SQRADDAC(a[11], a[46]); SQRADDAC(a[12], a[45]); SQRADDAC(a[13], a[44]); SQRADDAC(a[14], a[43]); SQRADDAC(a[15], a[42]); SQRADDAC(a[16], a[41]); SQRADDAC(a[17], a[40]); SQRADDAC(a[18], a[39]); SQRADDAC(a[19], a[38]); SQRADDAC(a[20], a[37]); SQRADDAC(a[21], a[36]); SQRADDAC(a[22], a[35]); SQRADDAC(a[23], a[34]); SQRADDAC(a[24], a[33]); SQRADDAC(a[25], a[32]); SQRADDAC(a[26], a[31]); SQRADDAC(a[27], a[30]); SQRADDAC(a[28], a[29]); SQRADDDB; 
-   COMBA_STORE(b[57]);
-
-   /* output 58 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[58]); SQRADDAC(a[1], a[57]); SQRADDAC(a[2], a[56]); SQRADDAC(a[3], a[55]); SQRADDAC(a[4], a[54]); SQRADDAC(a[5], a[53]); SQRADDAC(a[6], a[52]); SQRADDAC(a[7], a[51]); SQRADDAC(a[8], a[50]); SQRADDAC(a[9], a[49]); SQRADDAC(a[10], a[48]); SQRADDAC(a[11], a[47]); SQRADDAC(a[12], a[46]); SQRADDAC(a[13], a[45]); SQRADDAC(a[14], a[44]); SQRADDAC(a[15], a[43]); SQRADDAC(a[16], a[42]); SQRADDAC(a[17], a[41]); SQRADDAC(a[18], a[40]); SQRADDAC(a[19], a[39]); SQRADDAC(a[20], a[38]); SQRADDAC(a[21], a[37]); SQRADDAC(a[22], a[36]); SQRADDAC(a[23], a[35]); SQRADDAC(a[24], a[34]); SQRADDAC(a[25], a[33]); SQRADDAC(a[26], a[32]); SQRADDAC(a[27], a[31]); SQRADDAC(a[28], a[30]); SQRADDDB; SQRADD(a[29], a[29]); 
-   COMBA_STORE(b[58]);
-
-   /* output 59 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[59]); SQRADDAC(a[1], a[58]); SQRADDAC(a[2], a[57]); SQRADDAC(a[3], a[56]); SQRADDAC(a[4], a[55]); SQRADDAC(a[5], a[54]); SQRADDAC(a[6], a[53]); SQRADDAC(a[7], a[52]); SQRADDAC(a[8], a[51]); SQRADDAC(a[9], a[50]); SQRADDAC(a[10], a[49]); SQRADDAC(a[11], a[48]); SQRADDAC(a[12], a[47]); SQRADDAC(a[13], a[46]); SQRADDAC(a[14], a[45]); SQRADDAC(a[15], a[44]); SQRADDAC(a[16], a[43]); SQRADDAC(a[17], a[42]); SQRADDAC(a[18], a[41]); SQRADDAC(a[19], a[40]); SQRADDAC(a[20], a[39]); SQRADDAC(a[21], a[38]); SQRADDAC(a[22], a[37]); SQRADDAC(a[23], a[36]); SQRADDAC(a[24], a[35]); SQRADDAC(a[25], a[34]); SQRADDAC(a[26], a[33]); SQRADDAC(a[27], a[32]); SQRADDAC(a[28], a[31]); SQRADDAC(a[29], a[30]); SQRADDDB; 
-   COMBA_STORE(b[59]);
-
-   /* output 60 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[60]); SQRADDAC(a[1], a[59]); SQRADDAC(a[2], a[58]); SQRADDAC(a[3], a[57]); SQRADDAC(a[4], a[56]); SQRADDAC(a[5], a[55]); SQRADDAC(a[6], a[54]); SQRADDAC(a[7], a[53]); SQRADDAC(a[8], a[52]); SQRADDAC(a[9], a[51]); SQRADDAC(a[10], a[50]); SQRADDAC(a[11], a[49]); SQRADDAC(a[12], a[48]); SQRADDAC(a[13], a[47]); SQRADDAC(a[14], a[46]); SQRADDAC(a[15], a[45]); SQRADDAC(a[16], a[44]); SQRADDAC(a[17], a[43]); SQRADDAC(a[18], a[42]); SQRADDAC(a[19], a[41]); SQRADDAC(a[20], a[40]); SQRADDAC(a[21], a[39]); SQRADDAC(a[22], a[38]); SQRADDAC(a[23], a[37]); SQRADDAC(a[24], a[36]); SQRADDAC(a[25], a[35]); SQRADDAC(a[26], a[34]); SQRADDAC(a[27], a[33]); SQRADDAC(a[28], a[32]); SQRADDAC(a[29], a[31]); SQRADDDB; SQRADD(a[30], a[30]); 
-   COMBA_STORE(b[60]);
-
-   /* output 61 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[61]); SQRADDAC(a[1], a[60]); SQRADDAC(a[2], a[59]); SQRADDAC(a[3], a[58]); SQRADDAC(a[4], a[57]); SQRADDAC(a[5], a[56]); SQRADDAC(a[6], a[55]); SQRADDAC(a[7], a[54]); SQRADDAC(a[8], a[53]); SQRADDAC(a[9], a[52]); SQRADDAC(a[10], a[51]); SQRADDAC(a[11], a[50]); SQRADDAC(a[12], a[49]); SQRADDAC(a[13], a[48]); SQRADDAC(a[14], a[47]); SQRADDAC(a[15], a[46]); SQRADDAC(a[16], a[45]); SQRADDAC(a[17], a[44]); SQRADDAC(a[18], a[43]); SQRADDAC(a[19], a[42]); SQRADDAC(a[20], a[41]); SQRADDAC(a[21], a[40]); SQRADDAC(a[22], a[39]); SQRADDAC(a[23], a[38]); SQRADDAC(a[24], a[37]); SQRADDAC(a[25], a[36]); SQRADDAC(a[26], a[35]); SQRADDAC(a[27], a[34]); SQRADDAC(a[28], a[33]); SQRADDAC(a[29], a[32]); SQRADDAC(a[30], a[31]); SQRADDDB; 
-   COMBA_STORE(b[61]);
-
-   /* output 62 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[62]); SQRADDAC(a[1], a[61]); SQRADDAC(a[2], a[60]); SQRADDAC(a[3], a[59]); SQRADDAC(a[4], a[58]); SQRADDAC(a[5], a[57]); SQRADDAC(a[6], a[56]); SQRADDAC(a[7], a[55]); SQRADDAC(a[8], a[54]); SQRADDAC(a[9], a[53]); SQRADDAC(a[10], a[52]); SQRADDAC(a[11], a[51]); SQRADDAC(a[12], a[50]); SQRADDAC(a[13], a[49]); SQRADDAC(a[14], a[48]); SQRADDAC(a[15], a[47]); SQRADDAC(a[16], a[46]); SQRADDAC(a[17], a[45]); SQRADDAC(a[18], a[44]); SQRADDAC(a[19], a[43]); SQRADDAC(a[20], a[42]); SQRADDAC(a[21], a[41]); SQRADDAC(a[22], a[40]); SQRADDAC(a[23], a[39]); SQRADDAC(a[24], a[38]); SQRADDAC(a[25], a[37]); SQRADDAC(a[26], a[36]); SQRADDAC(a[27], a[35]); SQRADDAC(a[28], a[34]); SQRADDAC(a[29], a[33]); SQRADDAC(a[30], a[32]); SQRADDDB; SQRADD(a[31], a[31]); 
-   COMBA_STORE(b[62]);
-
-   /* output 63 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[63]); SQRADDAC(a[1], a[62]); SQRADDAC(a[2], a[61]); SQRADDAC(a[3], a[60]); SQRADDAC(a[4], a[59]); SQRADDAC(a[5], a[58]); SQRADDAC(a[6], a[57]); SQRADDAC(a[7], a[56]); SQRADDAC(a[8], a[55]); SQRADDAC(a[9], a[54]); SQRADDAC(a[10], a[53]); SQRADDAC(a[11], a[52]); SQRADDAC(a[12], a[51]); SQRADDAC(a[13], a[50]); SQRADDAC(a[14], a[49]); SQRADDAC(a[15], a[48]); SQRADDAC(a[16], a[47]); SQRADDAC(a[17], a[46]); SQRADDAC(a[18], a[45]); SQRADDAC(a[19], a[44]); SQRADDAC(a[20], a[43]); SQRADDAC(a[21], a[42]); SQRADDAC(a[22], a[41]); SQRADDAC(a[23], a[40]); SQRADDAC(a[24], a[39]); SQRADDAC(a[25], a[38]); SQRADDAC(a[26], a[37]); SQRADDAC(a[27], a[36]); SQRADDAC(a[28], a[35]); SQRADDAC(a[29], a[34]); SQRADDAC(a[30], a[33]); SQRADDAC(a[31], a[32]); SQRADDDB; 
-   COMBA_STORE(b[63]);
-
-   /* output 64 */
-   CARRY_FORWARD;
-   SQRADDSC(a[1], a[63]); SQRADDAC(a[2], a[62]); SQRADDAC(a[3], a[61]); SQRADDAC(a[4], a[60]); SQRADDAC(a[5], a[59]); SQRADDAC(a[6], a[58]); SQRADDAC(a[7], a[57]); SQRADDAC(a[8], a[56]); SQRADDAC(a[9], a[55]); SQRADDAC(a[10], a[54]); SQRADDAC(a[11], a[53]); SQRADDAC(a[12], a[52]); SQRADDAC(a[13], a[51]); SQRADDAC(a[14], a[50]); SQRADDAC(a[15], a[49]); SQRADDAC(a[16], a[48]); SQRADDAC(a[17], a[47]); SQRADDAC(a[18], a[46]); SQRADDAC(a[19], a[45]); SQRADDAC(a[20], a[44]); SQRADDAC(a[21], a[43]); SQRADDAC(a[22], a[42]); SQRADDAC(a[23], a[41]); SQRADDAC(a[24], a[40]); SQRADDAC(a[25], a[39]); SQRADDAC(a[26], a[38]); SQRADDAC(a[27], a[37]); SQRADDAC(a[28], a[36]); SQRADDAC(a[29], a[35]); SQRADDAC(a[30], a[34]); SQRADDAC(a[31], a[33]); SQRADDDB; SQRADD(a[32], a[32]); 
-   COMBA_STORE(b[64]);
-
-   /* output 65 */
-   CARRY_FORWARD;
-   SQRADDSC(a[2], a[63]); SQRADDAC(a[3], a[62]); SQRADDAC(a[4], a[61]); SQRADDAC(a[5], a[60]); SQRADDAC(a[6], a[59]); SQRADDAC(a[7], a[58]); SQRADDAC(a[8], a[57]); SQRADDAC(a[9], a[56]); SQRADDAC(a[10], a[55]); SQRADDAC(a[11], a[54]); SQRADDAC(a[12], a[53]); SQRADDAC(a[13], a[52]); SQRADDAC(a[14], a[51]); SQRADDAC(a[15], a[50]); SQRADDAC(a[16], a[49]); SQRADDAC(a[17], a[48]); SQRADDAC(a[18], a[47]); SQRADDAC(a[19], a[46]); SQRADDAC(a[20], a[45]); SQRADDAC(a[21], a[44]); SQRADDAC(a[22], a[43]); SQRADDAC(a[23], a[42]); SQRADDAC(a[24], a[41]); SQRADDAC(a[25], a[40]); SQRADDAC(a[26], a[39]); SQRADDAC(a[27], a[38]); SQRADDAC(a[28], a[37]); SQRADDAC(a[29], a[36]); SQRADDAC(a[30], a[35]); SQRADDAC(a[31], a[34]); SQRADDAC(a[32], a[33]); SQRADDDB; 
-   COMBA_STORE(b[65]);
-
-   /* output 66 */
-   CARRY_FORWARD;
-   SQRADDSC(a[3], a[63]); SQRADDAC(a[4], a[62]); SQRADDAC(a[5], a[61]); SQRADDAC(a[6], a[60]); SQRADDAC(a[7], a[59]); SQRADDAC(a[8], a[58]); SQRADDAC(a[9], a[57]); SQRADDAC(a[10], a[56]); SQRADDAC(a[11], a[55]); SQRADDAC(a[12], a[54]); SQRADDAC(a[13], a[53]); SQRADDAC(a[14], a[52]); SQRADDAC(a[15], a[51]); SQRADDAC(a[16], a[50]); SQRADDAC(a[17], a[49]); SQRADDAC(a[18], a[48]); SQRADDAC(a[19], a[47]); SQRADDAC(a[20], a[46]); SQRADDAC(a[21], a[45]); SQRADDAC(a[22], a[44]); SQRADDAC(a[23], a[43]); SQRADDAC(a[24], a[42]); SQRADDAC(a[25], a[41]); SQRADDAC(a[26], a[40]); SQRADDAC(a[27], a[39]); SQRADDAC(a[28], a[38]); SQRADDAC(a[29], a[37]); SQRADDAC(a[30], a[36]); SQRADDAC(a[31], a[35]); SQRADDAC(a[32], a[34]); SQRADDDB; SQRADD(a[33], a[33]); 
-   COMBA_STORE(b[66]);
-
-   /* output 67 */
-   CARRY_FORWARD;
-   SQRADDSC(a[4], a[63]); SQRADDAC(a[5], a[62]); SQRADDAC(a[6], a[61]); SQRADDAC(a[7], a[60]); SQRADDAC(a[8], a[59]); SQRADDAC(a[9], a[58]); SQRADDAC(a[10], a[57]); SQRADDAC(a[11], a[56]); SQRADDAC(a[12], a[55]); SQRADDAC(a[13], a[54]); SQRADDAC(a[14], a[53]); SQRADDAC(a[15], a[52]); SQRADDAC(a[16], a[51]); SQRADDAC(a[17], a[50]); SQRADDAC(a[18], a[49]); SQRADDAC(a[19], a[48]); SQRADDAC(a[20], a[47]); SQRADDAC(a[21], a[46]); SQRADDAC(a[22], a[45]); SQRADDAC(a[23], a[44]); SQRADDAC(a[24], a[43]); SQRADDAC(a[25], a[42]); SQRADDAC(a[26], a[41]); SQRADDAC(a[27], a[40]); SQRADDAC(a[28], a[39]); SQRADDAC(a[29], a[38]); SQRADDAC(a[30], a[37]); SQRADDAC(a[31], a[36]); SQRADDAC(a[32], a[35]); SQRADDAC(a[33], a[34]); SQRADDDB; 
-   COMBA_STORE(b[67]);
-
-   /* output 68 */
-   CARRY_FORWARD;
-   SQRADDSC(a[5], a[63]); SQRADDAC(a[6], a[62]); SQRADDAC(a[7], a[61]); SQRADDAC(a[8], a[60]); SQRADDAC(a[9], a[59]); SQRADDAC(a[10], a[58]); SQRADDAC(a[11], a[57]); SQRADDAC(a[12], a[56]); SQRADDAC(a[13], a[55]); SQRADDAC(a[14], a[54]); SQRADDAC(a[15], a[53]); SQRADDAC(a[16], a[52]); SQRADDAC(a[17], a[51]); SQRADDAC(a[18], a[50]); SQRADDAC(a[19], a[49]); SQRADDAC(a[20], a[48]); SQRADDAC(a[21], a[47]); SQRADDAC(a[22], a[46]); SQRADDAC(a[23], a[45]); SQRADDAC(a[24], a[44]); SQRADDAC(a[25], a[43]); SQRADDAC(a[26], a[42]); SQRADDAC(a[27], a[41]); SQRADDAC(a[28], a[40]); SQRADDAC(a[29], a[39]); SQRADDAC(a[30], a[38]); SQRADDAC(a[31], a[37]); SQRADDAC(a[32], a[36]); SQRADDAC(a[33], a[35]); SQRADDDB; SQRADD(a[34], a[34]); 
-   COMBA_STORE(b[68]);
-
-   /* output 69 */
-   CARRY_FORWARD;
-   SQRADDSC(a[6], a[63]); SQRADDAC(a[7], a[62]); SQRADDAC(a[8], a[61]); SQRADDAC(a[9], a[60]); SQRADDAC(a[10], a[59]); SQRADDAC(a[11], a[58]); SQRADDAC(a[12], a[57]); SQRADDAC(a[13], a[56]); SQRADDAC(a[14], a[55]); SQRADDAC(a[15], a[54]); SQRADDAC(a[16], a[53]); SQRADDAC(a[17], a[52]); SQRADDAC(a[18], a[51]); SQRADDAC(a[19], a[50]); SQRADDAC(a[20], a[49]); SQRADDAC(a[21], a[48]); SQRADDAC(a[22], a[47]); SQRADDAC(a[23], a[46]); SQRADDAC(a[24], a[45]); SQRADDAC(a[25], a[44]); SQRADDAC(a[26], a[43]); SQRADDAC(a[27], a[42]); SQRADDAC(a[28], a[41]); SQRADDAC(a[29], a[40]); SQRADDAC(a[30], a[39]); SQRADDAC(a[31], a[38]); SQRADDAC(a[32], a[37]); SQRADDAC(a[33], a[36]); SQRADDAC(a[34], a[35]); SQRADDDB; 
-   COMBA_STORE(b[69]);
-
-   /* output 70 */
-   CARRY_FORWARD;
-   SQRADDSC(a[7], a[63]); SQRADDAC(a[8], a[62]); SQRADDAC(a[9], a[61]); SQRADDAC(a[10], a[60]); SQRADDAC(a[11], a[59]); SQRADDAC(a[12], a[58]); SQRADDAC(a[13], a[57]); SQRADDAC(a[14], a[56]); SQRADDAC(a[15], a[55]); SQRADDAC(a[16], a[54]); SQRADDAC(a[17], a[53]); SQRADDAC(a[18], a[52]); SQRADDAC(a[19], a[51]); SQRADDAC(a[20], a[50]); SQRADDAC(a[21], a[49]); SQRADDAC(a[22], a[48]); SQRADDAC(a[23], a[47]); SQRADDAC(a[24], a[46]); SQRADDAC(a[25], a[45]); SQRADDAC(a[26], a[44]); SQRADDAC(a[27], a[43]); SQRADDAC(a[28], a[42]); SQRADDAC(a[29], a[41]); SQRADDAC(a[30], a[40]); SQRADDAC(a[31], a[39]); SQRADDAC(a[32], a[38]); SQRADDAC(a[33], a[37]); SQRADDAC(a[34], a[36]); SQRADDDB; SQRADD(a[35], a[35]); 
-   COMBA_STORE(b[70]);
-
-   /* output 71 */
-   CARRY_FORWARD;
-   SQRADDSC(a[8], a[63]); SQRADDAC(a[9], a[62]); SQRADDAC(a[10], a[61]); SQRADDAC(a[11], a[60]); SQRADDAC(a[12], a[59]); SQRADDAC(a[13], a[58]); SQRADDAC(a[14], a[57]); SQRADDAC(a[15], a[56]); SQRADDAC(a[16], a[55]); SQRADDAC(a[17], a[54]); SQRADDAC(a[18], a[53]); SQRADDAC(a[19], a[52]); SQRADDAC(a[20], a[51]); SQRADDAC(a[21], a[50]); SQRADDAC(a[22], a[49]); SQRADDAC(a[23], a[48]); SQRADDAC(a[24], a[47]); SQRADDAC(a[25], a[46]); SQRADDAC(a[26], a[45]); SQRADDAC(a[27], a[44]); SQRADDAC(a[28], a[43]); SQRADDAC(a[29], a[42]); SQRADDAC(a[30], a[41]); SQRADDAC(a[31], a[40]); SQRADDAC(a[32], a[39]); SQRADDAC(a[33], a[38]); SQRADDAC(a[34], a[37]); SQRADDAC(a[35], a[36]); SQRADDDB; 
-   COMBA_STORE(b[71]);
-
-   /* output 72 */
-   CARRY_FORWARD;
-   SQRADDSC(a[9], a[63]); SQRADDAC(a[10], a[62]); SQRADDAC(a[11], a[61]); SQRADDAC(a[12], a[60]); SQRADDAC(a[13], a[59]); SQRADDAC(a[14], a[58]); SQRADDAC(a[15], a[57]); SQRADDAC(a[16], a[56]); SQRADDAC(a[17], a[55]); SQRADDAC(a[18], a[54]); SQRADDAC(a[19], a[53]); SQRADDAC(a[20], a[52]); SQRADDAC(a[21], a[51]); SQRADDAC(a[22], a[50]); SQRADDAC(a[23], a[49]); SQRADDAC(a[24], a[48]); SQRADDAC(a[25], a[47]); SQRADDAC(a[26], a[46]); SQRADDAC(a[27], a[45]); SQRADDAC(a[28], a[44]); SQRADDAC(a[29], a[43]); SQRADDAC(a[30], a[42]); SQRADDAC(a[31], a[41]); SQRADDAC(a[32], a[40]); SQRADDAC(a[33], a[39]); SQRADDAC(a[34], a[38]); SQRADDAC(a[35], a[37]); SQRADDDB; SQRADD(a[36], a[36]); 
-   COMBA_STORE(b[72]);
-
-   /* output 73 */
-   CARRY_FORWARD;
-   SQRADDSC(a[10], a[63]); SQRADDAC(a[11], a[62]); SQRADDAC(a[12], a[61]); SQRADDAC(a[13], a[60]); SQRADDAC(a[14], a[59]); SQRADDAC(a[15], a[58]); SQRADDAC(a[16], a[57]); SQRADDAC(a[17], a[56]); SQRADDAC(a[18], a[55]); SQRADDAC(a[19], a[54]); SQRADDAC(a[20], a[53]); SQRADDAC(a[21], a[52]); SQRADDAC(a[22], a[51]); SQRADDAC(a[23], a[50]); SQRADDAC(a[24], a[49]); SQRADDAC(a[25], a[48]); SQRADDAC(a[26], a[47]); SQRADDAC(a[27], a[46]); SQRADDAC(a[28], a[45]); SQRADDAC(a[29], a[44]); SQRADDAC(a[30], a[43]); SQRADDAC(a[31], a[42]); SQRADDAC(a[32], a[41]); SQRADDAC(a[33], a[40]); SQRADDAC(a[34], a[39]); SQRADDAC(a[35], a[38]); SQRADDAC(a[36], a[37]); SQRADDDB; 
-   COMBA_STORE(b[73]);
-
-   /* output 74 */
-   CARRY_FORWARD;
-   SQRADDSC(a[11], a[63]); SQRADDAC(a[12], a[62]); SQRADDAC(a[13], a[61]); SQRADDAC(a[14], a[60]); SQRADDAC(a[15], a[59]); SQRADDAC(a[16], a[58]); SQRADDAC(a[17], a[57]); SQRADDAC(a[18], a[56]); SQRADDAC(a[19], a[55]); SQRADDAC(a[20], a[54]); SQRADDAC(a[21], a[53]); SQRADDAC(a[22], a[52]); SQRADDAC(a[23], a[51]); SQRADDAC(a[24], a[50]); SQRADDAC(a[25], a[49]); SQRADDAC(a[26], a[48]); SQRADDAC(a[27], a[47]); SQRADDAC(a[28], a[46]); SQRADDAC(a[29], a[45]); SQRADDAC(a[30], a[44]); SQRADDAC(a[31], a[43]); SQRADDAC(a[32], a[42]); SQRADDAC(a[33], a[41]); SQRADDAC(a[34], a[40]); SQRADDAC(a[35], a[39]); SQRADDAC(a[36], a[38]); SQRADDDB; SQRADD(a[37], a[37]); 
-   COMBA_STORE(b[74]);
-
-   /* output 75 */
-   CARRY_FORWARD;
-   SQRADDSC(a[12], a[63]); SQRADDAC(a[13], a[62]); SQRADDAC(a[14], a[61]); SQRADDAC(a[15], a[60]); SQRADDAC(a[16], a[59]); SQRADDAC(a[17], a[58]); SQRADDAC(a[18], a[57]); SQRADDAC(a[19], a[56]); SQRADDAC(a[20], a[55]); SQRADDAC(a[21], a[54]); SQRADDAC(a[22], a[53]); SQRADDAC(a[23], a[52]); SQRADDAC(a[24], a[51]); SQRADDAC(a[25], a[50]); SQRADDAC(a[26], a[49]); SQRADDAC(a[27], a[48]); SQRADDAC(a[28], a[47]); SQRADDAC(a[29], a[46]); SQRADDAC(a[30], a[45]); SQRADDAC(a[31], a[44]); SQRADDAC(a[32], a[43]); SQRADDAC(a[33], a[42]); SQRADDAC(a[34], a[41]); SQRADDAC(a[35], a[40]); SQRADDAC(a[36], a[39]); SQRADDAC(a[37], a[38]); SQRADDDB; 
-   COMBA_STORE(b[75]);
-
-   /* output 76 */
-   CARRY_FORWARD;
-   SQRADDSC(a[13], a[63]); SQRADDAC(a[14], a[62]); SQRADDAC(a[15], a[61]); SQRADDAC(a[16], a[60]); SQRADDAC(a[17], a[59]); SQRADDAC(a[18], a[58]); SQRADDAC(a[19], a[57]); SQRADDAC(a[20], a[56]); SQRADDAC(a[21], a[55]); SQRADDAC(a[22], a[54]); SQRADDAC(a[23], a[53]); SQRADDAC(a[24], a[52]); SQRADDAC(a[25], a[51]); SQRADDAC(a[26], a[50]); SQRADDAC(a[27], a[49]); SQRADDAC(a[28], a[48]); SQRADDAC(a[29], a[47]); SQRADDAC(a[30], a[46]); SQRADDAC(a[31], a[45]); SQRADDAC(a[32], a[44]); SQRADDAC(a[33], a[43]); SQRADDAC(a[34], a[42]); SQRADDAC(a[35], a[41]); SQRADDAC(a[36], a[40]); SQRADDAC(a[37], a[39]); SQRADDDB; SQRADD(a[38], a[38]); 
-   COMBA_STORE(b[76]);
-
-   /* output 77 */
-   CARRY_FORWARD;
-   SQRADDSC(a[14], a[63]); SQRADDAC(a[15], a[62]); SQRADDAC(a[16], a[61]); SQRADDAC(a[17], a[60]); SQRADDAC(a[18], a[59]); SQRADDAC(a[19], a[58]); SQRADDAC(a[20], a[57]); SQRADDAC(a[21], a[56]); SQRADDAC(a[22], a[55]); SQRADDAC(a[23], a[54]); SQRADDAC(a[24], a[53]); SQRADDAC(a[25], a[52]); SQRADDAC(a[26], a[51]); SQRADDAC(a[27], a[50]); SQRADDAC(a[28], a[49]); SQRADDAC(a[29], a[48]); SQRADDAC(a[30], a[47]); SQRADDAC(a[31], a[46]); SQRADDAC(a[32], a[45]); SQRADDAC(a[33], a[44]); SQRADDAC(a[34], a[43]); SQRADDAC(a[35], a[42]); SQRADDAC(a[36], a[41]); SQRADDAC(a[37], a[40]); SQRADDAC(a[38], a[39]); SQRADDDB; 
-   COMBA_STORE(b[77]);
-
-   /* output 78 */
-   CARRY_FORWARD;
-   SQRADDSC(a[15], a[63]); SQRADDAC(a[16], a[62]); SQRADDAC(a[17], a[61]); SQRADDAC(a[18], a[60]); SQRADDAC(a[19], a[59]); SQRADDAC(a[20], a[58]); SQRADDAC(a[21], a[57]); SQRADDAC(a[22], a[56]); SQRADDAC(a[23], a[55]); SQRADDAC(a[24], a[54]); SQRADDAC(a[25], a[53]); SQRADDAC(a[26], a[52]); SQRADDAC(a[27], a[51]); SQRADDAC(a[28], a[50]); SQRADDAC(a[29], a[49]); SQRADDAC(a[30], a[48]); SQRADDAC(a[31], a[47]); SQRADDAC(a[32], a[46]); SQRADDAC(a[33], a[45]); SQRADDAC(a[34], a[44]); SQRADDAC(a[35], a[43]); SQRADDAC(a[36], a[42]); SQRADDAC(a[37], a[41]); SQRADDAC(a[38], a[40]); SQRADDDB; SQRADD(a[39], a[39]); 
-   COMBA_STORE(b[78]);
-
-   /* output 79 */
-   CARRY_FORWARD;
-   SQRADDSC(a[16], a[63]); SQRADDAC(a[17], a[62]); SQRADDAC(a[18], a[61]); SQRADDAC(a[19], a[60]); SQRADDAC(a[20], a[59]); SQRADDAC(a[21], a[58]); SQRADDAC(a[22], a[57]); SQRADDAC(a[23], a[56]); SQRADDAC(a[24], a[55]); SQRADDAC(a[25], a[54]); SQRADDAC(a[26], a[53]); SQRADDAC(a[27], a[52]); SQRADDAC(a[28], a[51]); SQRADDAC(a[29], a[50]); SQRADDAC(a[30], a[49]); SQRADDAC(a[31], a[48]); SQRADDAC(a[32], a[47]); SQRADDAC(a[33], a[46]); SQRADDAC(a[34], a[45]); SQRADDAC(a[35], a[44]); SQRADDAC(a[36], a[43]); SQRADDAC(a[37], a[42]); SQRADDAC(a[38], a[41]); SQRADDAC(a[39], a[40]); SQRADDDB; 
-   COMBA_STORE(b[79]);
-
-   /* output 80 */
-   CARRY_FORWARD;
-   SQRADDSC(a[17], a[63]); SQRADDAC(a[18], a[62]); SQRADDAC(a[19], a[61]); SQRADDAC(a[20], a[60]); SQRADDAC(a[21], a[59]); SQRADDAC(a[22], a[58]); SQRADDAC(a[23], a[57]); SQRADDAC(a[24], a[56]); SQRADDAC(a[25], a[55]); SQRADDAC(a[26], a[54]); SQRADDAC(a[27], a[53]); SQRADDAC(a[28], a[52]); SQRADDAC(a[29], a[51]); SQRADDAC(a[30], a[50]); SQRADDAC(a[31], a[49]); SQRADDAC(a[32], a[48]); SQRADDAC(a[33], a[47]); SQRADDAC(a[34], a[46]); SQRADDAC(a[35], a[45]); SQRADDAC(a[36], a[44]); SQRADDAC(a[37], a[43]); SQRADDAC(a[38], a[42]); SQRADDAC(a[39], a[41]); SQRADDDB; SQRADD(a[40], a[40]); 
-   COMBA_STORE(b[80]);
-
-   /* output 81 */
-   CARRY_FORWARD;
-   SQRADDSC(a[18], a[63]); SQRADDAC(a[19], a[62]); SQRADDAC(a[20], a[61]); SQRADDAC(a[21], a[60]); SQRADDAC(a[22], a[59]); SQRADDAC(a[23], a[58]); SQRADDAC(a[24], a[57]); SQRADDAC(a[25], a[56]); SQRADDAC(a[26], a[55]); SQRADDAC(a[27], a[54]); SQRADDAC(a[28], a[53]); SQRADDAC(a[29], a[52]); SQRADDAC(a[30], a[51]); SQRADDAC(a[31], a[50]); SQRADDAC(a[32], a[49]); SQRADDAC(a[33], a[48]); SQRADDAC(a[34], a[47]); SQRADDAC(a[35], a[46]); SQRADDAC(a[36], a[45]); SQRADDAC(a[37], a[44]); SQRADDAC(a[38], a[43]); SQRADDAC(a[39], a[42]); SQRADDAC(a[40], a[41]); SQRADDDB; 
-   COMBA_STORE(b[81]);
-
-   /* output 82 */
-   CARRY_FORWARD;
-   SQRADDSC(a[19], a[63]); SQRADDAC(a[20], a[62]); SQRADDAC(a[21], a[61]); SQRADDAC(a[22], a[60]); SQRADDAC(a[23], a[59]); SQRADDAC(a[24], a[58]); SQRADDAC(a[25], a[57]); SQRADDAC(a[26], a[56]); SQRADDAC(a[27], a[55]); SQRADDAC(a[28], a[54]); SQRADDAC(a[29], a[53]); SQRADDAC(a[30], a[52]); SQRADDAC(a[31], a[51]); SQRADDAC(a[32], a[50]); SQRADDAC(a[33], a[49]); SQRADDAC(a[34], a[48]); SQRADDAC(a[35], a[47]); SQRADDAC(a[36], a[46]); SQRADDAC(a[37], a[45]); SQRADDAC(a[38], a[44]); SQRADDAC(a[39], a[43]); SQRADDAC(a[40], a[42]); SQRADDDB; SQRADD(a[41], a[41]); 
-   COMBA_STORE(b[82]);
-
-   /* output 83 */
-   CARRY_FORWARD;
-   SQRADDSC(a[20], a[63]); SQRADDAC(a[21], a[62]); SQRADDAC(a[22], a[61]); SQRADDAC(a[23], a[60]); SQRADDAC(a[24], a[59]); SQRADDAC(a[25], a[58]); SQRADDAC(a[26], a[57]); SQRADDAC(a[27], a[56]); SQRADDAC(a[28], a[55]); SQRADDAC(a[29], a[54]); SQRADDAC(a[30], a[53]); SQRADDAC(a[31], a[52]); SQRADDAC(a[32], a[51]); SQRADDAC(a[33], a[50]); SQRADDAC(a[34], a[49]); SQRADDAC(a[35], a[48]); SQRADDAC(a[36], a[47]); SQRADDAC(a[37], a[46]); SQRADDAC(a[38], a[45]); SQRADDAC(a[39], a[44]); SQRADDAC(a[40], a[43]); SQRADDAC(a[41], a[42]); SQRADDDB; 
-   COMBA_STORE(b[83]);
-
-   /* output 84 */
-   CARRY_FORWARD;
-   SQRADDSC(a[21], a[63]); SQRADDAC(a[22], a[62]); SQRADDAC(a[23], a[61]); SQRADDAC(a[24], a[60]); SQRADDAC(a[25], a[59]); SQRADDAC(a[26], a[58]); SQRADDAC(a[27], a[57]); SQRADDAC(a[28], a[56]); SQRADDAC(a[29], a[55]); SQRADDAC(a[30], a[54]); SQRADDAC(a[31], a[53]); SQRADDAC(a[32], a[52]); SQRADDAC(a[33], a[51]); SQRADDAC(a[34], a[50]); SQRADDAC(a[35], a[49]); SQRADDAC(a[36], a[48]); SQRADDAC(a[37], a[47]); SQRADDAC(a[38], a[46]); SQRADDAC(a[39], a[45]); SQRADDAC(a[40], a[44]); SQRADDAC(a[41], a[43]); SQRADDDB; SQRADD(a[42], a[42]); 
-   COMBA_STORE(b[84]);
-
-   /* output 85 */
-   CARRY_FORWARD;
-   SQRADDSC(a[22], a[63]); SQRADDAC(a[23], a[62]); SQRADDAC(a[24], a[61]); SQRADDAC(a[25], a[60]); SQRADDAC(a[26], a[59]); SQRADDAC(a[27], a[58]); SQRADDAC(a[28], a[57]); SQRADDAC(a[29], a[56]); SQRADDAC(a[30], a[55]); SQRADDAC(a[31], a[54]); SQRADDAC(a[32], a[53]); SQRADDAC(a[33], a[52]); SQRADDAC(a[34], a[51]); SQRADDAC(a[35], a[50]); SQRADDAC(a[36], a[49]); SQRADDAC(a[37], a[48]); SQRADDAC(a[38], a[47]); SQRADDAC(a[39], a[46]); SQRADDAC(a[40], a[45]); SQRADDAC(a[41], a[44]); SQRADDAC(a[42], a[43]); SQRADDDB; 
-   COMBA_STORE(b[85]);
-
-   /* output 86 */
-   CARRY_FORWARD;
-   SQRADDSC(a[23], a[63]); SQRADDAC(a[24], a[62]); SQRADDAC(a[25], a[61]); SQRADDAC(a[26], a[60]); SQRADDAC(a[27], a[59]); SQRADDAC(a[28], a[58]); SQRADDAC(a[29], a[57]); SQRADDAC(a[30], a[56]); SQRADDAC(a[31], a[55]); SQRADDAC(a[32], a[54]); SQRADDAC(a[33], a[53]); SQRADDAC(a[34], a[52]); SQRADDAC(a[35], a[51]); SQRADDAC(a[36], a[50]); SQRADDAC(a[37], a[49]); SQRADDAC(a[38], a[48]); SQRADDAC(a[39], a[47]); SQRADDAC(a[40], a[46]); SQRADDAC(a[41], a[45]); SQRADDAC(a[42], a[44]); SQRADDDB; SQRADD(a[43], a[43]); 
-   COMBA_STORE(b[86]);
-
-   /* output 87 */
-   CARRY_FORWARD;
-   SQRADDSC(a[24], a[63]); SQRADDAC(a[25], a[62]); SQRADDAC(a[26], a[61]); SQRADDAC(a[27], a[60]); SQRADDAC(a[28], a[59]); SQRADDAC(a[29], a[58]); SQRADDAC(a[30], a[57]); SQRADDAC(a[31], a[56]); SQRADDAC(a[32], a[55]); SQRADDAC(a[33], a[54]); SQRADDAC(a[34], a[53]); SQRADDAC(a[35], a[52]); SQRADDAC(a[36], a[51]); SQRADDAC(a[37], a[50]); SQRADDAC(a[38], a[49]); SQRADDAC(a[39], a[48]); SQRADDAC(a[40], a[47]); SQRADDAC(a[41], a[46]); SQRADDAC(a[42], a[45]); SQRADDAC(a[43], a[44]); SQRADDDB; 
-   COMBA_STORE(b[87]);
-
-   /* output 88 */
-   CARRY_FORWARD;
-   SQRADDSC(a[25], a[63]); SQRADDAC(a[26], a[62]); SQRADDAC(a[27], a[61]); SQRADDAC(a[28], a[60]); SQRADDAC(a[29], a[59]); SQRADDAC(a[30], a[58]); SQRADDAC(a[31], a[57]); SQRADDAC(a[32], a[56]); SQRADDAC(a[33], a[55]); SQRADDAC(a[34], a[54]); SQRADDAC(a[35], a[53]); SQRADDAC(a[36], a[52]); SQRADDAC(a[37], a[51]); SQRADDAC(a[38], a[50]); SQRADDAC(a[39], a[49]); SQRADDAC(a[40], a[48]); SQRADDAC(a[41], a[47]); SQRADDAC(a[42], a[46]); SQRADDAC(a[43], a[45]); SQRADDDB; SQRADD(a[44], a[44]); 
-   COMBA_STORE(b[88]);
-
-   /* output 89 */
-   CARRY_FORWARD;
-   SQRADDSC(a[26], a[63]); SQRADDAC(a[27], a[62]); SQRADDAC(a[28], a[61]); SQRADDAC(a[29], a[60]); SQRADDAC(a[30], a[59]); SQRADDAC(a[31], a[58]); SQRADDAC(a[32], a[57]); SQRADDAC(a[33], a[56]); SQRADDAC(a[34], a[55]); SQRADDAC(a[35], a[54]); SQRADDAC(a[36], a[53]); SQRADDAC(a[37], a[52]); SQRADDAC(a[38], a[51]); SQRADDAC(a[39], a[50]); SQRADDAC(a[40], a[49]); SQRADDAC(a[41], a[48]); SQRADDAC(a[42], a[47]); SQRADDAC(a[43], a[46]); SQRADDAC(a[44], a[45]); SQRADDDB; 
-   COMBA_STORE(b[89]);
-
-   /* output 90 */
-   CARRY_FORWARD;
-   SQRADDSC(a[27], a[63]); SQRADDAC(a[28], a[62]); SQRADDAC(a[29], a[61]); SQRADDAC(a[30], a[60]); SQRADDAC(a[31], a[59]); SQRADDAC(a[32], a[58]); SQRADDAC(a[33], a[57]); SQRADDAC(a[34], a[56]); SQRADDAC(a[35], a[55]); SQRADDAC(a[36], a[54]); SQRADDAC(a[37], a[53]); SQRADDAC(a[38], a[52]); SQRADDAC(a[39], a[51]); SQRADDAC(a[40], a[50]); SQRADDAC(a[41], a[49]); SQRADDAC(a[42], a[48]); SQRADDAC(a[43], a[47]); SQRADDAC(a[44], a[46]); SQRADDDB; SQRADD(a[45], a[45]); 
-   COMBA_STORE(b[90]);
-
-   /* output 91 */
-   CARRY_FORWARD;
-   SQRADDSC(a[28], a[63]); SQRADDAC(a[29], a[62]); SQRADDAC(a[30], a[61]); SQRADDAC(a[31], a[60]); SQRADDAC(a[32], a[59]); SQRADDAC(a[33], a[58]); SQRADDAC(a[34], a[57]); SQRADDAC(a[35], a[56]); SQRADDAC(a[36], a[55]); SQRADDAC(a[37], a[54]); SQRADDAC(a[38], a[53]); SQRADDAC(a[39], a[52]); SQRADDAC(a[40], a[51]); SQRADDAC(a[41], a[50]); SQRADDAC(a[42], a[49]); SQRADDAC(a[43], a[48]); SQRADDAC(a[44], a[47]); SQRADDAC(a[45], a[46]); SQRADDDB; 
-   COMBA_STORE(b[91]);
-
-   /* output 92 */
-   CARRY_FORWARD;
-   SQRADDSC(a[29], a[63]); SQRADDAC(a[30], a[62]); SQRADDAC(a[31], a[61]); SQRADDAC(a[32], a[60]); SQRADDAC(a[33], a[59]); SQRADDAC(a[34], a[58]); SQRADDAC(a[35], a[57]); SQRADDAC(a[36], a[56]); SQRADDAC(a[37], a[55]); SQRADDAC(a[38], a[54]); SQRADDAC(a[39], a[53]); SQRADDAC(a[40], a[52]); SQRADDAC(a[41], a[51]); SQRADDAC(a[42], a[50]); SQRADDAC(a[43], a[49]); SQRADDAC(a[44], a[48]); SQRADDAC(a[45], a[47]); SQRADDDB; SQRADD(a[46], a[46]); 
-   COMBA_STORE(b[92]);
-
-   /* output 93 */
-   CARRY_FORWARD;
-   SQRADDSC(a[30], a[63]); SQRADDAC(a[31], a[62]); SQRADDAC(a[32], a[61]); SQRADDAC(a[33], a[60]); SQRADDAC(a[34], a[59]); SQRADDAC(a[35], a[58]); SQRADDAC(a[36], a[57]); SQRADDAC(a[37], a[56]); SQRADDAC(a[38], a[55]); SQRADDAC(a[39], a[54]); SQRADDAC(a[40], a[53]); SQRADDAC(a[41], a[52]); SQRADDAC(a[42], a[51]); SQRADDAC(a[43], a[50]); SQRADDAC(a[44], a[49]); SQRADDAC(a[45], a[48]); SQRADDAC(a[46], a[47]); SQRADDDB; 
-   COMBA_STORE(b[93]);
-
-   /* output 94 */
-   CARRY_FORWARD;
-   SQRADDSC(a[31], a[63]); SQRADDAC(a[32], a[62]); SQRADDAC(a[33], a[61]); SQRADDAC(a[34], a[60]); SQRADDAC(a[35], a[59]); SQRADDAC(a[36], a[58]); SQRADDAC(a[37], a[57]); SQRADDAC(a[38], a[56]); SQRADDAC(a[39], a[55]); SQRADDAC(a[40], a[54]); SQRADDAC(a[41], a[53]); SQRADDAC(a[42], a[52]); SQRADDAC(a[43], a[51]); SQRADDAC(a[44], a[50]); SQRADDAC(a[45], a[49]); SQRADDAC(a[46], a[48]); SQRADDDB; SQRADD(a[47], a[47]); 
-   COMBA_STORE(b[94]);
-
-   /* output 95 */
-   CARRY_FORWARD;
-   SQRADDSC(a[32], a[63]); SQRADDAC(a[33], a[62]); SQRADDAC(a[34], a[61]); SQRADDAC(a[35], a[60]); SQRADDAC(a[36], a[59]); SQRADDAC(a[37], a[58]); SQRADDAC(a[38], a[57]); SQRADDAC(a[39], a[56]); SQRADDAC(a[40], a[55]); SQRADDAC(a[41], a[54]); SQRADDAC(a[42], a[53]); SQRADDAC(a[43], a[52]); SQRADDAC(a[44], a[51]); SQRADDAC(a[45], a[50]); SQRADDAC(a[46], a[49]); SQRADDAC(a[47], a[48]); SQRADDDB; 
-   COMBA_STORE(b[95]);
-
-   /* output 96 */
-   CARRY_FORWARD;
-   SQRADDSC(a[33], a[63]); SQRADDAC(a[34], a[62]); SQRADDAC(a[35], a[61]); SQRADDAC(a[36], a[60]); SQRADDAC(a[37], a[59]); SQRADDAC(a[38], a[58]); SQRADDAC(a[39], a[57]); SQRADDAC(a[40], a[56]); SQRADDAC(a[41], a[55]); SQRADDAC(a[42], a[54]); SQRADDAC(a[43], a[53]); SQRADDAC(a[44], a[52]); SQRADDAC(a[45], a[51]); SQRADDAC(a[46], a[50]); SQRADDAC(a[47], a[49]); SQRADDDB; SQRADD(a[48], a[48]); 
-   COMBA_STORE(b[96]);
-
-   /* output 97 */
-   CARRY_FORWARD;
-   SQRADDSC(a[34], a[63]); SQRADDAC(a[35], a[62]); SQRADDAC(a[36], a[61]); SQRADDAC(a[37], a[60]); SQRADDAC(a[38], a[59]); SQRADDAC(a[39], a[58]); SQRADDAC(a[40], a[57]); SQRADDAC(a[41], a[56]); SQRADDAC(a[42], a[55]); SQRADDAC(a[43], a[54]); SQRADDAC(a[44], a[53]); SQRADDAC(a[45], a[52]); SQRADDAC(a[46], a[51]); SQRADDAC(a[47], a[50]); SQRADDAC(a[48], a[49]); SQRADDDB; 
-   COMBA_STORE(b[97]);
-
-   /* output 98 */
-   CARRY_FORWARD;
-   SQRADDSC(a[35], a[63]); SQRADDAC(a[36], a[62]); SQRADDAC(a[37], a[61]); SQRADDAC(a[38], a[60]); SQRADDAC(a[39], a[59]); SQRADDAC(a[40], a[58]); SQRADDAC(a[41], a[57]); SQRADDAC(a[42], a[56]); SQRADDAC(a[43], a[55]); SQRADDAC(a[44], a[54]); SQRADDAC(a[45], a[53]); SQRADDAC(a[46], a[52]); SQRADDAC(a[47], a[51]); SQRADDAC(a[48], a[50]); SQRADDDB; SQRADD(a[49], a[49]); 
-   COMBA_STORE(b[98]);
-
-   /* output 99 */
-   CARRY_FORWARD;
-   SQRADDSC(a[36], a[63]); SQRADDAC(a[37], a[62]); SQRADDAC(a[38], a[61]); SQRADDAC(a[39], a[60]); SQRADDAC(a[40], a[59]); SQRADDAC(a[41], a[58]); SQRADDAC(a[42], a[57]); SQRADDAC(a[43], a[56]); SQRADDAC(a[44], a[55]); SQRADDAC(a[45], a[54]); SQRADDAC(a[46], a[53]); SQRADDAC(a[47], a[52]); SQRADDAC(a[48], a[51]); SQRADDAC(a[49], a[50]); SQRADDDB; 
-   COMBA_STORE(b[99]);
-
-   /* output 100 */
-   CARRY_FORWARD;
-   SQRADDSC(a[37], a[63]); SQRADDAC(a[38], a[62]); SQRADDAC(a[39], a[61]); SQRADDAC(a[40], a[60]); SQRADDAC(a[41], a[59]); SQRADDAC(a[42], a[58]); SQRADDAC(a[43], a[57]); SQRADDAC(a[44], a[56]); SQRADDAC(a[45], a[55]); SQRADDAC(a[46], a[54]); SQRADDAC(a[47], a[53]); SQRADDAC(a[48], a[52]); SQRADDAC(a[49], a[51]); SQRADDDB; SQRADD(a[50], a[50]); 
-   COMBA_STORE(b[100]);
-
-   /* output 101 */
-   CARRY_FORWARD;
-   SQRADDSC(a[38], a[63]); SQRADDAC(a[39], a[62]); SQRADDAC(a[40], a[61]); SQRADDAC(a[41], a[60]); SQRADDAC(a[42], a[59]); SQRADDAC(a[43], a[58]); SQRADDAC(a[44], a[57]); SQRADDAC(a[45], a[56]); SQRADDAC(a[46], a[55]); SQRADDAC(a[47], a[54]); SQRADDAC(a[48], a[53]); SQRADDAC(a[49], a[52]); SQRADDAC(a[50], a[51]); SQRADDDB; 
-   COMBA_STORE(b[101]);
-
-   /* output 102 */
-   CARRY_FORWARD;
-   SQRADDSC(a[39], a[63]); SQRADDAC(a[40], a[62]); SQRADDAC(a[41], a[61]); SQRADDAC(a[42], a[60]); SQRADDAC(a[43], a[59]); SQRADDAC(a[44], a[58]); SQRADDAC(a[45], a[57]); SQRADDAC(a[46], a[56]); SQRADDAC(a[47], a[55]); SQRADDAC(a[48], a[54]); SQRADDAC(a[49], a[53]); SQRADDAC(a[50], a[52]); SQRADDDB; SQRADD(a[51], a[51]); 
-   COMBA_STORE(b[102]);
-
-   /* output 103 */
-   CARRY_FORWARD;
-   SQRADDSC(a[40], a[63]); SQRADDAC(a[41], a[62]); SQRADDAC(a[42], a[61]); SQRADDAC(a[43], a[60]); SQRADDAC(a[44], a[59]); SQRADDAC(a[45], a[58]); SQRADDAC(a[46], a[57]); SQRADDAC(a[47], a[56]); SQRADDAC(a[48], a[55]); SQRADDAC(a[49], a[54]); SQRADDAC(a[50], a[53]); SQRADDAC(a[51], a[52]); SQRADDDB; 
-   COMBA_STORE(b[103]);
-
-   /* output 104 */
-   CARRY_FORWARD;
-   SQRADDSC(a[41], a[63]); SQRADDAC(a[42], a[62]); SQRADDAC(a[43], a[61]); SQRADDAC(a[44], a[60]); SQRADDAC(a[45], a[59]); SQRADDAC(a[46], a[58]); SQRADDAC(a[47], a[57]); SQRADDAC(a[48], a[56]); SQRADDAC(a[49], a[55]); SQRADDAC(a[50], a[54]); SQRADDAC(a[51], a[53]); SQRADDDB; SQRADD(a[52], a[52]); 
-   COMBA_STORE(b[104]);
-
-   /* output 105 */
-   CARRY_FORWARD;
-   SQRADDSC(a[42], a[63]); SQRADDAC(a[43], a[62]); SQRADDAC(a[44], a[61]); SQRADDAC(a[45], a[60]); SQRADDAC(a[46], a[59]); SQRADDAC(a[47], a[58]); SQRADDAC(a[48], a[57]); SQRADDAC(a[49], a[56]); SQRADDAC(a[50], a[55]); SQRADDAC(a[51], a[54]); SQRADDAC(a[52], a[53]); SQRADDDB; 
-   COMBA_STORE(b[105]);
-
-   /* output 106 */
-   CARRY_FORWARD;
-   SQRADDSC(a[43], a[63]); SQRADDAC(a[44], a[62]); SQRADDAC(a[45], a[61]); SQRADDAC(a[46], a[60]); SQRADDAC(a[47], a[59]); SQRADDAC(a[48], a[58]); SQRADDAC(a[49], a[57]); SQRADDAC(a[50], a[56]); SQRADDAC(a[51], a[55]); SQRADDAC(a[52], a[54]); SQRADDDB; SQRADD(a[53], a[53]); 
-   COMBA_STORE(b[106]);
-
-   /* output 107 */
-   CARRY_FORWARD;
-   SQRADDSC(a[44], a[63]); SQRADDAC(a[45], a[62]); SQRADDAC(a[46], a[61]); SQRADDAC(a[47], a[60]); SQRADDAC(a[48], a[59]); SQRADDAC(a[49], a[58]); SQRADDAC(a[50], a[57]); SQRADDAC(a[51], a[56]); SQRADDAC(a[52], a[55]); SQRADDAC(a[53], a[54]); SQRADDDB; 
-   COMBA_STORE(b[107]);
-
-   /* output 108 */
-   CARRY_FORWARD;
-   SQRADDSC(a[45], a[63]); SQRADDAC(a[46], a[62]); SQRADDAC(a[47], a[61]); SQRADDAC(a[48], a[60]); SQRADDAC(a[49], a[59]); SQRADDAC(a[50], a[58]); SQRADDAC(a[51], a[57]); SQRADDAC(a[52], a[56]); SQRADDAC(a[53], a[55]); SQRADDDB; SQRADD(a[54], a[54]); 
-   COMBA_STORE(b[108]);
-
-   /* output 109 */
-   CARRY_FORWARD;
-   SQRADDSC(a[46], a[63]); SQRADDAC(a[47], a[62]); SQRADDAC(a[48], a[61]); SQRADDAC(a[49], a[60]); SQRADDAC(a[50], a[59]); SQRADDAC(a[51], a[58]); SQRADDAC(a[52], a[57]); SQRADDAC(a[53], a[56]); SQRADDAC(a[54], a[55]); SQRADDDB; 
-   COMBA_STORE(b[109]);
-
-   /* output 110 */
-   CARRY_FORWARD;
-   SQRADDSC(a[47], a[63]); SQRADDAC(a[48], a[62]); SQRADDAC(a[49], a[61]); SQRADDAC(a[50], a[60]); SQRADDAC(a[51], a[59]); SQRADDAC(a[52], a[58]); SQRADDAC(a[53], a[57]); SQRADDAC(a[54], a[56]); SQRADDDB; SQRADD(a[55], a[55]); 
-   COMBA_STORE(b[110]);
-
-   /* output 111 */
-   CARRY_FORWARD;
-   SQRADDSC(a[48], a[63]); SQRADDAC(a[49], a[62]); SQRADDAC(a[50], a[61]); SQRADDAC(a[51], a[60]); SQRADDAC(a[52], a[59]); SQRADDAC(a[53], a[58]); SQRADDAC(a[54], a[57]); SQRADDAC(a[55], a[56]); SQRADDDB; 
-   COMBA_STORE(b[111]);
-
-   /* output 112 */
-   CARRY_FORWARD;
-   SQRADDSC(a[49], a[63]); SQRADDAC(a[50], a[62]); SQRADDAC(a[51], a[61]); SQRADDAC(a[52], a[60]); SQRADDAC(a[53], a[59]); SQRADDAC(a[54], a[58]); SQRADDAC(a[55], a[57]); SQRADDDB; SQRADD(a[56], a[56]); 
-   COMBA_STORE(b[112]);
-
-   /* output 113 */
-   CARRY_FORWARD;
-   SQRADDSC(a[50], a[63]); SQRADDAC(a[51], a[62]); SQRADDAC(a[52], a[61]); SQRADDAC(a[53], a[60]); SQRADDAC(a[54], a[59]); SQRADDAC(a[55], a[58]); SQRADDAC(a[56], a[57]); SQRADDDB; 
-   COMBA_STORE(b[113]);
-
-   /* output 114 */
-   CARRY_FORWARD;
-   SQRADDSC(a[51], a[63]); SQRADDAC(a[52], a[62]); SQRADDAC(a[53], a[61]); SQRADDAC(a[54], a[60]); SQRADDAC(a[55], a[59]); SQRADDAC(a[56], a[58]); SQRADDDB; SQRADD(a[57], a[57]); 
-   COMBA_STORE(b[114]);
-
-   /* output 115 */
-   CARRY_FORWARD;
-   SQRADDSC(a[52], a[63]); SQRADDAC(a[53], a[62]); SQRADDAC(a[54], a[61]); SQRADDAC(a[55], a[60]); SQRADDAC(a[56], a[59]); SQRADDAC(a[57], a[58]); SQRADDDB; 
-   COMBA_STORE(b[115]);
-
-   /* output 116 */
-   CARRY_FORWARD;
-   SQRADDSC(a[53], a[63]); SQRADDAC(a[54], a[62]); SQRADDAC(a[55], a[61]); SQRADDAC(a[56], a[60]); SQRADDAC(a[57], a[59]); SQRADDDB; SQRADD(a[58], a[58]); 
-   COMBA_STORE(b[116]);
-
-   /* output 117 */
-   CARRY_FORWARD;
-   SQRADDSC(a[54], a[63]); SQRADDAC(a[55], a[62]); SQRADDAC(a[56], a[61]); SQRADDAC(a[57], a[60]); SQRADDAC(a[58], a[59]); SQRADDDB; 
-   COMBA_STORE(b[117]);
-
-   /* output 118 */
-   CARRY_FORWARD;
-   SQRADDSC(a[55], a[63]); SQRADDAC(a[56], a[62]); SQRADDAC(a[57], a[61]); SQRADDAC(a[58], a[60]); SQRADDDB; SQRADD(a[59], a[59]); 
-   COMBA_STORE(b[118]);
-
-   /* output 119 */
-   CARRY_FORWARD;
-   SQRADDSC(a[56], a[63]); SQRADDAC(a[57], a[62]); SQRADDAC(a[58], a[61]); SQRADDAC(a[59], a[60]); SQRADDDB; 
-   COMBA_STORE(b[119]);
-
-   /* output 120 */
-   CARRY_FORWARD;
-   SQRADDSC(a[57], a[63]); SQRADDAC(a[58], a[62]); SQRADDAC(a[59], a[61]); SQRADDDB; SQRADD(a[60], a[60]); 
-   COMBA_STORE(b[120]);
-
-   /* output 121 */
-   CARRY_FORWARD;
-   SQRADDSC(a[58], a[63]); SQRADDAC(a[59], a[62]); SQRADDAC(a[60], a[61]); SQRADDDB; 
-   COMBA_STORE(b[121]);
-
-   /* output 122 */
-   CARRY_FORWARD;
-   SQRADD2(a[59], a[63]); SQRADD2(a[60], a[62]); SQRADD(a[61], a[61]); 
-   COMBA_STORE(b[122]);
-
-   /* output 123 */
-   CARRY_FORWARD;
-   SQRADD2(a[60], a[63]); SQRADD2(a[61], a[62]); 
-   COMBA_STORE(b[123]);
-
-   /* output 124 */
-   CARRY_FORWARD;
-   SQRADD2(a[61], a[63]); SQRADD(a[62], a[62]); 
-   COMBA_STORE(b[124]);
-
-   /* output 125 */
-   CARRY_FORWARD;
-   SQRADD2(a[62], a[63]); 
-   COMBA_STORE(b[125]);
-
-   /* output 126 */
-   CARRY_FORWARD;
-   SQRADD(a[63], a[63]); 
-   COMBA_STORE(b[126]);
-   COMBA_STORE2(b[127]);
-   COMBA_FINI;
-
-   B->used = 128;
-   B->sign = FP_ZPOS;
-   memcpy(B->dp, b, 128 * sizeof(fp_digit));
-   fp_clamp(B);
-}
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_7.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_7.i
deleted file mode 100755
index 8ddef1a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_7.i
+++ /dev/null
@@ -1,110 +0,0 @@
-/* fp_sqr_comba_7.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SQR7
-void fp_sqr_comba7(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[14], c0, c1, c2, sc0, sc1, sc2;
-#ifdef TFM_ISO
-   fp_word tt;
-#endif
-
-   a = A->dp;
-   COMBA_START; 
-
-   /* clear carries */
-   CLEAR_CARRY;
-
-   /* output 0 */
-   SQRADD(a[0],a[0]);
-   COMBA_STORE(b[0]);
-
-   /* output 1 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[1]); 
-   COMBA_STORE(b[1]);
-
-   /* output 2 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
-   COMBA_STORE(b[2]);
-
-   /* output 3 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
-   COMBA_STORE(b[3]);
-
-   /* output 4 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
-   COMBA_STORE(b[4]);
-
-   /* output 5 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-   COMBA_STORE(b[5]);
-
-   /* output 6 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-   COMBA_STORE(b[6]);
-
-   /* output 7 */
-   CARRY_FORWARD;
-   SQRADDSC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-   COMBA_STORE(b[7]);
-
-   /* output 8 */
-   CARRY_FORWARD;
-   SQRADD2(a[2], a[6]); SQRADD2(a[3], a[5]); SQRADD(a[4], a[4]); 
-   COMBA_STORE(b[8]);
-
-   /* output 9 */
-   CARRY_FORWARD;
-   SQRADD2(a[3], a[6]); SQRADD2(a[4], a[5]); 
-   COMBA_STORE(b[9]);
-
-   /* output 10 */
-   CARRY_FORWARD;
-   SQRADD2(a[4], a[6]); SQRADD(a[5], a[5]); 
-   COMBA_STORE(b[10]);
-
-   /* output 11 */
-   CARRY_FORWARD;
-   SQRADD2(a[5], a[6]); 
-   COMBA_STORE(b[11]);
-
-   /* output 12 */
-   CARRY_FORWARD;
-   SQRADD(a[6], a[6]); 
-   COMBA_STORE(b[12]);
-   COMBA_STORE2(b[13]);
-   COMBA_FINI;
-
-   B->used = 14;
-   B->sign = FP_ZPOS;
-   memcpy(B->dp, b, 14 * sizeof(fp_digit));
-   fp_clamp(B);
-}
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_8.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_8.i
deleted file mode 100755
index f9a72bc..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_8.i
+++ /dev/null
@@ -1,120 +0,0 @@
-/* fp_sqr_comba_8.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SQR8
-void fp_sqr_comba8(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[16], c0, c1, c2, sc0, sc1, sc2;
-#ifdef TFM_ISO
-   fp_word   tt;   
-#endif   
-
-   a = A->dp;
-   COMBA_START; 
-
-   /* clear carries */
-   CLEAR_CARRY;
-
-   /* output 0 */
-   SQRADD(a[0],a[0]);
-   COMBA_STORE(b[0]);
-
-   /* output 1 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[1]); 
-   COMBA_STORE(b[1]);
-
-   /* output 2 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
-   COMBA_STORE(b[2]);
-
-   /* output 3 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
-   COMBA_STORE(b[3]);
-
-   /* output 4 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
-   COMBA_STORE(b[4]);
-
-   /* output 5 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-   COMBA_STORE(b[5]);
-
-   /* output 6 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-   COMBA_STORE(b[6]);
-
-   /* output 7 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-   COMBA_STORE(b[7]);
-
-   /* output 8 */
-   CARRY_FORWARD;
-   SQRADDSC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-   COMBA_STORE(b[8]);
-
-   /* output 9 */
-   CARRY_FORWARD;
-   SQRADDSC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-   COMBA_STORE(b[9]);
-
-   /* output 10 */
-   CARRY_FORWARD;
-   SQRADD2(a[3], a[7]); SQRADD2(a[4], a[6]); SQRADD(a[5], a[5]); 
-   COMBA_STORE(b[10]);
-
-   /* output 11 */
-   CARRY_FORWARD;
-   SQRADD2(a[4], a[7]); SQRADD2(a[5], a[6]); 
-   COMBA_STORE(b[11]);
-
-   /* output 12 */
-   CARRY_FORWARD;
-   SQRADD2(a[5], a[7]); SQRADD(a[6], a[6]); 
-   COMBA_STORE(b[12]);
-
-   /* output 13 */
-   CARRY_FORWARD;
-   SQRADD2(a[6], a[7]); 
-   COMBA_STORE(b[13]);
-
-   /* output 14 */
-   CARRY_FORWARD;
-   SQRADD(a[7], a[7]); 
-   COMBA_STORE(b[14]);
-   COMBA_STORE2(b[15]);
-   COMBA_FINI;
-
-   B->used = 16;
-   B->sign = FP_ZPOS;
-   memcpy(B->dp, b, 16 * sizeof(fp_digit));
-   fp_clamp(B);
-}
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_9.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_9.i
deleted file mode 100755
index 94a5d2e..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_9.i
+++ /dev/null
@@ -1,130 +0,0 @@
-/* fp_sqr_comba_9.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef TFM_SQR9
-void fp_sqr_comba9(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[18], c0, c1, c2, sc0, sc1, sc2;
-#ifdef TFM_ISO
-   fp_word tt;
-#endif
-
-   a = A->dp;
-   COMBA_START; 
-
-   /* clear carries */
-   CLEAR_CARRY;
-
-   /* output 0 */
-   SQRADD(a[0],a[0]);
-   COMBA_STORE(b[0]);
-
-   /* output 1 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[1]); 
-   COMBA_STORE(b[1]);
-
-   /* output 2 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
-   COMBA_STORE(b[2]);
-
-   /* output 3 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
-   COMBA_STORE(b[3]);
-
-   /* output 4 */
-   CARRY_FORWARD;
-   SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
-   COMBA_STORE(b[4]);
-
-   /* output 5 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-   COMBA_STORE(b[5]);
-
-   /* output 6 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-   COMBA_STORE(b[6]);
-
-   /* output 7 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-   COMBA_STORE(b[7]);
-
-   /* output 8 */
-   CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-   COMBA_STORE(b[8]);
-
-   /* output 9 */
-   CARRY_FORWARD;
-   SQRADDSC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-   COMBA_STORE(b[9]);
-
-   /* output 10 */
-   CARRY_FORWARD;
-   SQRADDSC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-   COMBA_STORE(b[10]);
-
-   /* output 11 */
-   CARRY_FORWARD;
-   SQRADDSC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-   COMBA_STORE(b[11]);
-
-   /* output 12 */
-   CARRY_FORWARD;
-   SQRADD2(a[4], a[8]); SQRADD2(a[5], a[7]); SQRADD(a[6], a[6]); 
-   COMBA_STORE(b[12]);
-
-   /* output 13 */
-   CARRY_FORWARD;
-   SQRADD2(a[5], a[8]); SQRADD2(a[6], a[7]); 
-   COMBA_STORE(b[13]);
-
-   /* output 14 */
-   CARRY_FORWARD;
-   SQRADD2(a[6], a[8]); SQRADD(a[7], a[7]); 
-   COMBA_STORE(b[14]);
-
-   /* output 15 */
-   CARRY_FORWARD;
-   SQRADD2(a[7], a[8]); 
-   COMBA_STORE(b[15]);
-
-   /* output 16 */
-   CARRY_FORWARD;
-   SQRADD(a[8], a[8]); 
-   COMBA_STORE(b[16]);
-   COMBA_STORE2(b[17]);
-   COMBA_FINI;
-
-   B->used = 18;
-   B->sign = FP_ZPOS;
-   memcpy(B->dp, b, 18 * sizeof(fp_digit));
-   fp_clamp(B);
-}
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_small_set.i b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_small_set.i
deleted file mode 100755
index 9918b2e..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/fp_sqr_comba_small_set.i
+++ /dev/null
@@ -1,1540 +0,0 @@
-/* fp_sqr_comba_small_set.i
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#if defined(TFM_SMALL_SET)
-void fp_sqr_comba_small(fp_int *A, fp_int *B)
-{
-   fp_digit *a, b[32], c0, c1, c2, sc0, sc1, sc2;
-#ifdef TFM_ISO
-   fp_word   tt;   
-#endif   
-   switch (A->used) { 
-   case 1:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-      COMBA_STORE2(b[1]);
-      COMBA_FINI;
-
-      B->used = 2;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 2 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 2:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-      COMBA_STORE2(b[3]);
-      COMBA_FINI;
-
-      B->used = 4;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 4 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 3:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[2]);    SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-
-      /* output 3 */
-      CARRY_FORWARD;
-      SQRADD2(a[1], a[2]); 
-      COMBA_STORE(b[3]);
-
-      /* output 4 */
-      CARRY_FORWARD;
-      SQRADD(a[2], a[2]); 
-      COMBA_STORE(b[4]);
-      COMBA_STORE2(b[5]);
-      COMBA_FINI;
-
-      B->used = 6;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 6 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 4:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[2]);    SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-
-      /* output 3 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[3]);    SQRADD2(a[1], a[2]); 
-      COMBA_STORE(b[3]);
-
-      /* output 4 */
-      CARRY_FORWARD;
-      SQRADD2(a[1], a[3]);    SQRADD(a[2], a[2]); 
-      COMBA_STORE(b[4]);
-
-      /* output 5 */
-      CARRY_FORWARD;
-      SQRADD2(a[2], a[3]); 
-      COMBA_STORE(b[5]);
-
-      /* output 6 */
-      CARRY_FORWARD;
-      SQRADD(a[3], a[3]); 
-      COMBA_STORE(b[6]);
-      COMBA_STORE2(b[7]);
-      COMBA_FINI;
-
-      B->used = 8;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 8 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 5:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[2]);    SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-
-      /* output 3 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[3]);    SQRADD2(a[1], a[2]); 
-      COMBA_STORE(b[3]);
-
-      /* output 4 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[4]);    SQRADD2(a[1], a[3]);    SQRADD(a[2], a[2]); 
-      COMBA_STORE(b[4]);
-
-      /* output 5 */
-      CARRY_FORWARD;
-      SQRADD2(a[1], a[4]);    SQRADD2(a[2], a[3]); 
-      COMBA_STORE(b[5]);
-
-      /* output 6 */
-      CARRY_FORWARD;
-      SQRADD2(a[2], a[4]);    SQRADD(a[3], a[3]); 
-      COMBA_STORE(b[6]);
-
-      /* output 7 */
-      CARRY_FORWARD;
-      SQRADD2(a[3], a[4]); 
-      COMBA_STORE(b[7]);
-
-      /* output 8 */
-      CARRY_FORWARD;
-      SQRADD(a[4], a[4]); 
-      COMBA_STORE(b[8]);
-      COMBA_STORE2(b[9]);
-      COMBA_FINI;
-
-      B->used = 10;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 10 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 6:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[2]);    SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-
-      /* output 3 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[3]);    SQRADD2(a[1], a[2]); 
-      COMBA_STORE(b[3]);
-
-      /* output 4 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[4]);    SQRADD2(a[1], a[3]);    SQRADD(a[2], a[2]); 
-      COMBA_STORE(b[4]);
-
-      /* output 5 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-      COMBA_STORE(b[5]);
-
-      /* output 6 */
-      CARRY_FORWARD;
-      SQRADD2(a[1], a[5]);    SQRADD2(a[2], a[4]);    SQRADD(a[3], a[3]); 
-      COMBA_STORE(b[6]);
-
-      /* output 7 */
-      CARRY_FORWARD;
-      SQRADD2(a[2], a[5]);    SQRADD2(a[3], a[4]); 
-      COMBA_STORE(b[7]);
-
-      /* output 8 */
-      CARRY_FORWARD;
-      SQRADD2(a[3], a[5]);    SQRADD(a[4], a[4]); 
-      COMBA_STORE(b[8]);
-
-      /* output 9 */
-      CARRY_FORWARD;
-      SQRADD2(a[4], a[5]); 
-      COMBA_STORE(b[9]);
-
-      /* output 10 */
-      CARRY_FORWARD;
-      SQRADD(a[5], a[5]); 
-      COMBA_STORE(b[10]);
-      COMBA_STORE2(b[11]);
-      COMBA_FINI;
-
-      B->used = 12;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 12 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 7:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[2]);    SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-
-      /* output 3 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[3]);    SQRADD2(a[1], a[2]); 
-      COMBA_STORE(b[3]);
-
-      /* output 4 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[4]);    SQRADD2(a[1], a[3]);    SQRADD(a[2], a[2]); 
-      COMBA_STORE(b[4]);
-
-      /* output 5 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-      COMBA_STORE(b[5]);
-
-      /* output 6 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-      COMBA_STORE(b[6]);
-
-      /* output 7 */
-      CARRY_FORWARD;
-   SQRADDSC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-      COMBA_STORE(b[7]);
-
-      /* output 8 */
-      CARRY_FORWARD;
-      SQRADD2(a[2], a[6]);    SQRADD2(a[3], a[5]);    SQRADD(a[4], a[4]); 
-      COMBA_STORE(b[8]);
-
-      /* output 9 */
-      CARRY_FORWARD;
-      SQRADD2(a[3], a[6]);    SQRADD2(a[4], a[5]); 
-      COMBA_STORE(b[9]);
-
-      /* output 10 */
-      CARRY_FORWARD;
-      SQRADD2(a[4], a[6]);    SQRADD(a[5], a[5]); 
-      COMBA_STORE(b[10]);
-
-      /* output 11 */
-      CARRY_FORWARD;
-      SQRADD2(a[5], a[6]); 
-      COMBA_STORE(b[11]);
-
-      /* output 12 */
-      CARRY_FORWARD;
-      SQRADD(a[6], a[6]); 
-      COMBA_STORE(b[12]);
-      COMBA_STORE2(b[13]);
-      COMBA_FINI;
-
-      B->used = 14;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 14 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 8:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[2]);    SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-
-      /* output 3 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[3]);    SQRADD2(a[1], a[2]); 
-      COMBA_STORE(b[3]);
-
-      /* output 4 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[4]);    SQRADD2(a[1], a[3]);    SQRADD(a[2], a[2]); 
-      COMBA_STORE(b[4]);
-
-      /* output 5 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-      COMBA_STORE(b[5]);
-
-      /* output 6 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-      COMBA_STORE(b[6]);
-
-      /* output 7 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-      COMBA_STORE(b[7]);
-
-      /* output 8 */
-      CARRY_FORWARD;
-   SQRADDSC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-      COMBA_STORE(b[8]);
-
-      /* output 9 */
-      CARRY_FORWARD;
-   SQRADDSC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-      COMBA_STORE(b[9]);
-
-      /* output 10 */
-      CARRY_FORWARD;
-      SQRADD2(a[3], a[7]);    SQRADD2(a[4], a[6]);    SQRADD(a[5], a[5]); 
-      COMBA_STORE(b[10]);
-
-      /* output 11 */
-      CARRY_FORWARD;
-      SQRADD2(a[4], a[7]);    SQRADD2(a[5], a[6]); 
-      COMBA_STORE(b[11]);
-
-      /* output 12 */
-      CARRY_FORWARD;
-      SQRADD2(a[5], a[7]);    SQRADD(a[6], a[6]); 
-      COMBA_STORE(b[12]);
-
-      /* output 13 */
-      CARRY_FORWARD;
-      SQRADD2(a[6], a[7]); 
-      COMBA_STORE(b[13]);
-
-      /* output 14 */
-      CARRY_FORWARD;
-      SQRADD(a[7], a[7]); 
-      COMBA_STORE(b[14]);
-      COMBA_STORE2(b[15]);
-      COMBA_FINI;
-
-      B->used = 16;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 16 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 9:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[2]);    SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-
-      /* output 3 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[3]);    SQRADD2(a[1], a[2]); 
-      COMBA_STORE(b[3]);
-
-      /* output 4 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[4]);    SQRADD2(a[1], a[3]);    SQRADD(a[2], a[2]); 
-      COMBA_STORE(b[4]);
-
-      /* output 5 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-      COMBA_STORE(b[5]);
-
-      /* output 6 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-      COMBA_STORE(b[6]);
-
-      /* output 7 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-      COMBA_STORE(b[7]);
-
-      /* output 8 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-      COMBA_STORE(b[8]);
-
-      /* output 9 */
-      CARRY_FORWARD;
-   SQRADDSC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-      COMBA_STORE(b[9]);
-
-      /* output 10 */
-      CARRY_FORWARD;
-   SQRADDSC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-      COMBA_STORE(b[10]);
-
-      /* output 11 */
-      CARRY_FORWARD;
-   SQRADDSC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-      COMBA_STORE(b[11]);
-
-      /* output 12 */
-      CARRY_FORWARD;
-      SQRADD2(a[4], a[8]);    SQRADD2(a[5], a[7]);    SQRADD(a[6], a[6]); 
-      COMBA_STORE(b[12]);
-
-      /* output 13 */
-      CARRY_FORWARD;
-      SQRADD2(a[5], a[8]);    SQRADD2(a[6], a[7]); 
-      COMBA_STORE(b[13]);
-
-      /* output 14 */
-      CARRY_FORWARD;
-      SQRADD2(a[6], a[8]);    SQRADD(a[7], a[7]); 
-      COMBA_STORE(b[14]);
-
-      /* output 15 */
-      CARRY_FORWARD;
-      SQRADD2(a[7], a[8]); 
-      COMBA_STORE(b[15]);
-
-      /* output 16 */
-      CARRY_FORWARD;
-      SQRADD(a[8], a[8]); 
-      COMBA_STORE(b[16]);
-      COMBA_STORE2(b[17]);
-      COMBA_FINI;
-
-      B->used = 18;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 18 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 10:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[2]);    SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-
-      /* output 3 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[3]);    SQRADD2(a[1], a[2]); 
-      COMBA_STORE(b[3]);
-
-      /* output 4 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[4]);    SQRADD2(a[1], a[3]);    SQRADD(a[2], a[2]); 
-      COMBA_STORE(b[4]);
-
-      /* output 5 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-      COMBA_STORE(b[5]);
-
-      /* output 6 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-      COMBA_STORE(b[6]);
-
-      /* output 7 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-      COMBA_STORE(b[7]);
-
-      /* output 8 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-      COMBA_STORE(b[8]);
-
-      /* output 9 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-      COMBA_STORE(b[9]);
-
-      /* output 10 */
-      CARRY_FORWARD;
-   SQRADDSC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-      COMBA_STORE(b[10]);
-
-      /* output 11 */
-      CARRY_FORWARD;
-   SQRADDSC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-      COMBA_STORE(b[11]);
-
-      /* output 12 */
-      CARRY_FORWARD;
-   SQRADDSC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-      COMBA_STORE(b[12]);
-
-      /* output 13 */
-      CARRY_FORWARD;
-   SQRADDSC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-      COMBA_STORE(b[13]);
-
-      /* output 14 */
-      CARRY_FORWARD;
-      SQRADD2(a[5], a[9]);    SQRADD2(a[6], a[8]);    SQRADD(a[7], a[7]); 
-      COMBA_STORE(b[14]);
-
-      /* output 15 */
-      CARRY_FORWARD;
-      SQRADD2(a[6], a[9]);    SQRADD2(a[7], a[8]); 
-      COMBA_STORE(b[15]);
-
-      /* output 16 */
-      CARRY_FORWARD;
-      SQRADD2(a[7], a[9]);    SQRADD(a[8], a[8]); 
-      COMBA_STORE(b[16]);
-
-      /* output 17 */
-      CARRY_FORWARD;
-      SQRADD2(a[8], a[9]); 
-      COMBA_STORE(b[17]);
-
-      /* output 18 */
-      CARRY_FORWARD;
-      SQRADD(a[9], a[9]); 
-      COMBA_STORE(b[18]);
-      COMBA_STORE2(b[19]);
-      COMBA_FINI;
-
-      B->used = 20;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 20 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 11:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[2]);    SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-
-      /* output 3 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[3]);    SQRADD2(a[1], a[2]); 
-      COMBA_STORE(b[3]);
-
-      /* output 4 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[4]);    SQRADD2(a[1], a[3]);    SQRADD(a[2], a[2]); 
-      COMBA_STORE(b[4]);
-
-      /* output 5 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-      COMBA_STORE(b[5]);
-
-      /* output 6 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-      COMBA_STORE(b[6]);
-
-      /* output 7 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-      COMBA_STORE(b[7]);
-
-      /* output 8 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-      COMBA_STORE(b[8]);
-
-      /* output 9 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-      COMBA_STORE(b[9]);
-
-      /* output 10 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-      COMBA_STORE(b[10]);
-
-      /* output 11 */
-      CARRY_FORWARD;
-   SQRADDSC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-      COMBA_STORE(b[11]);
-
-      /* output 12 */
-      CARRY_FORWARD;
-   SQRADDSC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-      COMBA_STORE(b[12]);
-
-      /* output 13 */
-      CARRY_FORWARD;
-   SQRADDSC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-      COMBA_STORE(b[13]);
-
-      /* output 14 */
-      CARRY_FORWARD;
-   SQRADDSC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); 
-      COMBA_STORE(b[14]);
-
-      /* output 15 */
-      CARRY_FORWARD;
-   SQRADDSC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; 
-      COMBA_STORE(b[15]);
-
-      /* output 16 */
-      CARRY_FORWARD;
-      SQRADD2(a[6], a[10]);    SQRADD2(a[7], a[9]);    SQRADD(a[8], a[8]); 
-      COMBA_STORE(b[16]);
-
-      /* output 17 */
-      CARRY_FORWARD;
-      SQRADD2(a[7], a[10]);    SQRADD2(a[8], a[9]); 
-      COMBA_STORE(b[17]);
-
-      /* output 18 */
-      CARRY_FORWARD;
-      SQRADD2(a[8], a[10]);    SQRADD(a[9], a[9]); 
-      COMBA_STORE(b[18]);
-
-      /* output 19 */
-      CARRY_FORWARD;
-      SQRADD2(a[9], a[10]); 
-      COMBA_STORE(b[19]);
-
-      /* output 20 */
-      CARRY_FORWARD;
-      SQRADD(a[10], a[10]); 
-      COMBA_STORE(b[20]);
-      COMBA_STORE2(b[21]);
-      COMBA_FINI;
-
-      B->used = 22;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 22 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 12:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[2]);    SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-
-      /* output 3 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[3]);    SQRADD2(a[1], a[2]); 
-      COMBA_STORE(b[3]);
-
-      /* output 4 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[4]);    SQRADD2(a[1], a[3]);    SQRADD(a[2], a[2]); 
-      COMBA_STORE(b[4]);
-
-      /* output 5 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-      COMBA_STORE(b[5]);
-
-      /* output 6 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-      COMBA_STORE(b[6]);
-
-      /* output 7 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-      COMBA_STORE(b[7]);
-
-      /* output 8 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-      COMBA_STORE(b[8]);
-
-      /* output 9 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-      COMBA_STORE(b[9]);
-
-      /* output 10 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-      COMBA_STORE(b[10]);
-
-      /* output 11 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-      COMBA_STORE(b[11]);
-
-      /* output 12 */
-      CARRY_FORWARD;
-   SQRADDSC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-      COMBA_STORE(b[12]);
-
-      /* output 13 */
-      CARRY_FORWARD;
-   SQRADDSC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-      COMBA_STORE(b[13]);
-
-      /* output 14 */
-      CARRY_FORWARD;
-   SQRADDSC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); 
-      COMBA_STORE(b[14]);
-
-      /* output 15 */
-      CARRY_FORWARD;
-   SQRADDSC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; 
-      COMBA_STORE(b[15]);
-
-      /* output 16 */
-      CARRY_FORWARD;
-   SQRADDSC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); 
-      COMBA_STORE(b[16]);
-
-      /* output 17 */
-      CARRY_FORWARD;
-   SQRADDSC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; 
-      COMBA_STORE(b[17]);
-
-      /* output 18 */
-      CARRY_FORWARD;
-      SQRADD2(a[7], a[11]);    SQRADD2(a[8], a[10]);    SQRADD(a[9], a[9]); 
-      COMBA_STORE(b[18]);
-
-      /* output 19 */
-      CARRY_FORWARD;
-      SQRADD2(a[8], a[11]);    SQRADD2(a[9], a[10]); 
-      COMBA_STORE(b[19]);
-
-      /* output 20 */
-      CARRY_FORWARD;
-      SQRADD2(a[9], a[11]);    SQRADD(a[10], a[10]); 
-      COMBA_STORE(b[20]);
-
-      /* output 21 */
-      CARRY_FORWARD;
-      SQRADD2(a[10], a[11]); 
-      COMBA_STORE(b[21]);
-
-      /* output 22 */
-      CARRY_FORWARD;
-      SQRADD(a[11], a[11]); 
-      COMBA_STORE(b[22]);
-      COMBA_STORE2(b[23]);
-      COMBA_FINI;
-
-      B->used = 24;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 24 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 13:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[2]);    SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-
-      /* output 3 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[3]);    SQRADD2(a[1], a[2]); 
-      COMBA_STORE(b[3]);
-
-      /* output 4 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[4]);    SQRADD2(a[1], a[3]);    SQRADD(a[2], a[2]); 
-      COMBA_STORE(b[4]);
-
-      /* output 5 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-      COMBA_STORE(b[5]);
-
-      /* output 6 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-      COMBA_STORE(b[6]);
-
-      /* output 7 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-      COMBA_STORE(b[7]);
-
-      /* output 8 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-      COMBA_STORE(b[8]);
-
-      /* output 9 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-      COMBA_STORE(b[9]);
-
-      /* output 10 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-      COMBA_STORE(b[10]);
-
-      /* output 11 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-      COMBA_STORE(b[11]);
-
-      /* output 12 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-      COMBA_STORE(b[12]);
-
-      /* output 13 */
-      CARRY_FORWARD;
-   SQRADDSC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-      COMBA_STORE(b[13]);
-
-      /* output 14 */
-      CARRY_FORWARD;
-   SQRADDSC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); 
-      COMBA_STORE(b[14]);
-
-      /* output 15 */
-      CARRY_FORWARD;
-   SQRADDSC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; 
-      COMBA_STORE(b[15]);
-
-      /* output 16 */
-      CARRY_FORWARD;
-   SQRADDSC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); 
-      COMBA_STORE(b[16]);
-
-      /* output 17 */
-      CARRY_FORWARD;
-   SQRADDSC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; 
-      COMBA_STORE(b[17]);
-
-      /* output 18 */
-      CARRY_FORWARD;
-   SQRADDSC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); 
-      COMBA_STORE(b[18]);
-
-      /* output 19 */
-      CARRY_FORWARD;
-   SQRADDSC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; 
-      COMBA_STORE(b[19]);
-
-      /* output 20 */
-      CARRY_FORWARD;
-      SQRADD2(a[8], a[12]);    SQRADD2(a[9], a[11]);    SQRADD(a[10], a[10]); 
-      COMBA_STORE(b[20]);
-
-      /* output 21 */
-      CARRY_FORWARD;
-      SQRADD2(a[9], a[12]);    SQRADD2(a[10], a[11]); 
-      COMBA_STORE(b[21]);
-
-      /* output 22 */
-      CARRY_FORWARD;
-      SQRADD2(a[10], a[12]);    SQRADD(a[11], a[11]); 
-      COMBA_STORE(b[22]);
-
-      /* output 23 */
-      CARRY_FORWARD;
-      SQRADD2(a[11], a[12]); 
-      COMBA_STORE(b[23]);
-
-      /* output 24 */
-      CARRY_FORWARD;
-      SQRADD(a[12], a[12]); 
-      COMBA_STORE(b[24]);
-      COMBA_STORE2(b[25]);
-      COMBA_FINI;
-
-      B->used = 26;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 26 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 14:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[2]);    SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-
-      /* output 3 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[3]);    SQRADD2(a[1], a[2]); 
-      COMBA_STORE(b[3]);
-
-      /* output 4 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[4]);    SQRADD2(a[1], a[3]);    SQRADD(a[2], a[2]); 
-      COMBA_STORE(b[4]);
-
-      /* output 5 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-      COMBA_STORE(b[5]);
-
-      /* output 6 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-      COMBA_STORE(b[6]);
-
-      /* output 7 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-      COMBA_STORE(b[7]);
-
-      /* output 8 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-      COMBA_STORE(b[8]);
-
-      /* output 9 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-      COMBA_STORE(b[9]);
-
-      /* output 10 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-      COMBA_STORE(b[10]);
-
-      /* output 11 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-      COMBA_STORE(b[11]);
-
-      /* output 12 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-      COMBA_STORE(b[12]);
-
-      /* output 13 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-      COMBA_STORE(b[13]);
-
-      /* output 14 */
-      CARRY_FORWARD;
-   SQRADDSC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); 
-      COMBA_STORE(b[14]);
-
-      /* output 15 */
-      CARRY_FORWARD;
-   SQRADDSC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; 
-      COMBA_STORE(b[15]);
-
-      /* output 16 */
-      CARRY_FORWARD;
-   SQRADDSC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); 
-      COMBA_STORE(b[16]);
-
-      /* output 17 */
-      CARRY_FORWARD;
-   SQRADDSC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; 
-      COMBA_STORE(b[17]);
-
-      /* output 18 */
-      CARRY_FORWARD;
-   SQRADDSC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); 
-      COMBA_STORE(b[18]);
-
-      /* output 19 */
-      CARRY_FORWARD;
-   SQRADDSC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; 
-      COMBA_STORE(b[19]);
-
-      /* output 20 */
-      CARRY_FORWARD;
-   SQRADDSC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); 
-      COMBA_STORE(b[20]);
-
-      /* output 21 */
-      CARRY_FORWARD;
-   SQRADDSC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; 
-      COMBA_STORE(b[21]);
-
-      /* output 22 */
-      CARRY_FORWARD;
-      SQRADD2(a[9], a[13]);    SQRADD2(a[10], a[12]);    SQRADD(a[11], a[11]); 
-      COMBA_STORE(b[22]);
-
-      /* output 23 */
-      CARRY_FORWARD;
-      SQRADD2(a[10], a[13]);    SQRADD2(a[11], a[12]); 
-      COMBA_STORE(b[23]);
-
-      /* output 24 */
-      CARRY_FORWARD;
-      SQRADD2(a[11], a[13]);    SQRADD(a[12], a[12]); 
-      COMBA_STORE(b[24]);
-
-      /* output 25 */
-      CARRY_FORWARD;
-      SQRADD2(a[12], a[13]); 
-      COMBA_STORE(b[25]);
-
-      /* output 26 */
-      CARRY_FORWARD;
-      SQRADD(a[13], a[13]); 
-      COMBA_STORE(b[26]);
-      COMBA_STORE2(b[27]);
-      COMBA_FINI;
-
-      B->used = 28;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 28 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 15:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[2]);    SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-
-      /* output 3 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[3]);    SQRADD2(a[1], a[2]); 
-      COMBA_STORE(b[3]);
-
-      /* output 4 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[4]);    SQRADD2(a[1], a[3]);    SQRADD(a[2], a[2]); 
-      COMBA_STORE(b[4]);
-
-      /* output 5 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-      COMBA_STORE(b[5]);
-
-      /* output 6 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-      COMBA_STORE(b[6]);
-
-      /* output 7 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-      COMBA_STORE(b[7]);
-
-      /* output 8 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-      COMBA_STORE(b[8]);
-
-      /* output 9 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-      COMBA_STORE(b[9]);
-
-      /* output 10 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-      COMBA_STORE(b[10]);
-
-      /* output 11 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-      COMBA_STORE(b[11]);
-
-      /* output 12 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-      COMBA_STORE(b[12]);
-
-      /* output 13 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-      COMBA_STORE(b[13]);
-
-      /* output 14 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); 
-      COMBA_STORE(b[14]);
-
-      /* output 15 */
-      CARRY_FORWARD;
-   SQRADDSC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; 
-      COMBA_STORE(b[15]);
-
-      /* output 16 */
-      CARRY_FORWARD;
-   SQRADDSC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); 
-      COMBA_STORE(b[16]);
-
-      /* output 17 */
-      CARRY_FORWARD;
-   SQRADDSC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; 
-      COMBA_STORE(b[17]);
-
-      /* output 18 */
-      CARRY_FORWARD;
-   SQRADDSC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); 
-      COMBA_STORE(b[18]);
-
-      /* output 19 */
-      CARRY_FORWARD;
-   SQRADDSC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; 
-      COMBA_STORE(b[19]);
-
-      /* output 20 */
-      CARRY_FORWARD;
-   SQRADDSC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); 
-      COMBA_STORE(b[20]);
-
-      /* output 21 */
-      CARRY_FORWARD;
-   SQRADDSC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; 
-      COMBA_STORE(b[21]);
-
-      /* output 22 */
-      CARRY_FORWARD;
-   SQRADDSC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); 
-      COMBA_STORE(b[22]);
-
-      /* output 23 */
-      CARRY_FORWARD;
-   SQRADDSC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; 
-      COMBA_STORE(b[23]);
-
-      /* output 24 */
-      CARRY_FORWARD;
-      SQRADD2(a[10], a[14]);    SQRADD2(a[11], a[13]);    SQRADD(a[12], a[12]); 
-      COMBA_STORE(b[24]);
-
-      /* output 25 */
-      CARRY_FORWARD;
-      SQRADD2(a[11], a[14]);    SQRADD2(a[12], a[13]); 
-      COMBA_STORE(b[25]);
-
-      /* output 26 */
-      CARRY_FORWARD;
-      SQRADD2(a[12], a[14]);    SQRADD(a[13], a[13]); 
-      COMBA_STORE(b[26]);
-
-      /* output 27 */
-      CARRY_FORWARD;
-      SQRADD2(a[13], a[14]); 
-      COMBA_STORE(b[27]);
-
-      /* output 28 */
-      CARRY_FORWARD;
-      SQRADD(a[14], a[14]); 
-      COMBA_STORE(b[28]);
-      COMBA_STORE2(b[29]);
-      COMBA_FINI;
-
-      B->used = 30;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 30 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   case 16:
-      a = A->dp;
-      COMBA_START; 
-
-      /* clear carries */
-      CLEAR_CARRY;
-
-      /* output 0 */
-      SQRADD(a[0],a[0]);
-      COMBA_STORE(b[0]);
-
-      /* output 1 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[1]); 
-      COMBA_STORE(b[1]);
-
-      /* output 2 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[2]);    SQRADD(a[1], a[1]); 
-      COMBA_STORE(b[2]);
-
-      /* output 3 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[3]);    SQRADD2(a[1], a[2]); 
-      COMBA_STORE(b[3]);
-
-      /* output 4 */
-      CARRY_FORWARD;
-      SQRADD2(a[0], a[4]);    SQRADD2(a[1], a[3]);    SQRADD(a[2], a[2]); 
-      COMBA_STORE(b[4]);
-
-      /* output 5 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
-      COMBA_STORE(b[5]);
-
-      /* output 6 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
-      COMBA_STORE(b[6]);
-
-      /* output 7 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
-      COMBA_STORE(b[7]);
-
-      /* output 8 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); 
-      COMBA_STORE(b[8]);
-
-      /* output 9 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; 
-      COMBA_STORE(b[9]);
-
-      /* output 10 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); 
-      COMBA_STORE(b[10]);
-
-      /* output 11 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; 
-      COMBA_STORE(b[11]);
-
-      /* output 12 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); 
-      COMBA_STORE(b[12]);
-
-      /* output 13 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; 
-      COMBA_STORE(b[13]);
-
-      /* output 14 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); 
-      COMBA_STORE(b[14]);
-
-      /* output 15 */
-      CARRY_FORWARD;
-   SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; 
-      COMBA_STORE(b[15]);
-
-      /* output 16 */
-      CARRY_FORWARD;
-   SQRADDSC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); 
-      COMBA_STORE(b[16]);
-
-      /* output 17 */
-      CARRY_FORWARD;
-   SQRADDSC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; 
-      COMBA_STORE(b[17]);
-
-      /* output 18 */
-      CARRY_FORWARD;
-   SQRADDSC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); 
-      COMBA_STORE(b[18]);
-
-      /* output 19 */
-      CARRY_FORWARD;
-   SQRADDSC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; 
-      COMBA_STORE(b[19]);
-
-      /* output 20 */
-      CARRY_FORWARD;
-   SQRADDSC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); 
-      COMBA_STORE(b[20]);
-
-      /* output 21 */
-      CARRY_FORWARD;
-   SQRADDSC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; 
-      COMBA_STORE(b[21]);
-
-      /* output 22 */
-      CARRY_FORWARD;
-   SQRADDSC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); 
-      COMBA_STORE(b[22]);
-
-      /* output 23 */
-      CARRY_FORWARD;
-   SQRADDSC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; 
-      COMBA_STORE(b[23]);
-
-      /* output 24 */
-      CARRY_FORWARD;
-   SQRADDSC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); 
-      COMBA_STORE(b[24]);
-
-      /* output 25 */
-      CARRY_FORWARD;
-   SQRADDSC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; 
-      COMBA_STORE(b[25]);
-
-      /* output 26 */
-      CARRY_FORWARD;
-      SQRADD2(a[11], a[15]);    SQRADD2(a[12], a[14]);    SQRADD(a[13], a[13]); 
-      COMBA_STORE(b[26]);
-
-      /* output 27 */
-      CARRY_FORWARD;
-      SQRADD2(a[12], a[15]);    SQRADD2(a[13], a[14]); 
-      COMBA_STORE(b[27]);
-
-      /* output 28 */
-      CARRY_FORWARD;
-      SQRADD2(a[13], a[15]);    SQRADD(a[14], a[14]); 
-      COMBA_STORE(b[28]);
-
-      /* output 29 */
-      CARRY_FORWARD;
-      SQRADD2(a[14], a[15]); 
-      COMBA_STORE(b[29]);
-
-      /* output 30 */
-      CARRY_FORWARD;
-      SQRADD(a[15], a[15]); 
-      COMBA_STORE(b[30]);
-      COMBA_STORE2(b[31]);
-      COMBA_FINI;
-
-      B->used = 32;
-      B->sign = FP_ZPOS;
-      memcpy(B->dp, b, 32 * sizeof(fp_digit));
-      fp_clamp(B);
-      break;
-
-   default:
-      break;
-}
-}
-
-#endif /* TFM_SMALL_SET */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ge_low_mem.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ge_low_mem.c
deleted file mode 100755
index 43c533c..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ge_low_mem.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/* ge_low_mem.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
- /* Based from Daniel Beer's public domain work. */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef HAVE_ED25519
-
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-void ed25519_smult(ge_p3 *r, const ge_p3 *a, const byte *e);
-void ed25519_add(ge_p3 *r, const ge_p3 *a, const ge_p3 *b);
-void ed25519_double(ge_p3 *r, const ge_p3 *a);
-
-
-static const byte ed25519_order[F25519_SIZE] = {
-	0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58,
-	0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10
-};
-
-/*Arithmetic modulo the group order m = 2^252 +
- 27742317777372353535851937790883648493 =
- 7237005577332262213973186563042994240857116359379907606001950938285454250989 */
-
-static const word32 m[32] = {
-    0xED,0xD3,0xF5,0x5C,0x1A,0x63,0x12,0x58,0xD6,0x9C,0xF7,0xA2,0xDE,0xF9,
-    0xDE,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-    0x00,0x00,0x00,0x10
-};
-
-static const word32 mu[33] = {
-    0x1B,0x13,0x2C,0x0A,0xA3,0xE5,0x9C,0xED,0xA7,0x29,0x63,0x08,0x5D,0x21,
-    0x06,0x21,0xEB,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
-    0xFF,0xFF,0xFF,0xFF,0x0F
-};
-
-
-int ge_compress_key(byte* out, const byte* xIn, const byte* yIn,
-                        word32 keySz)
-{
-	byte tmp[F25519_SIZE];
-	byte parity;
-    int     i;
-
-	fe_copy(tmp, xIn);
-	parity = (tmp[0] & 1) << 7;
-
-    byte pt[32];
-	fe_copy(pt, yIn);
-	pt[31] |= parity;
-
-    for(i = 0; i < 32; i++) {
-        out[32-i-1] = pt[i];
-    }
-    (void)keySz;
-    return 0;
-}
-
-
-static word32 lt(word32 a,word32 b) /* 16-bit inputs */
-{
-  unsigned int x = a;
-  x -= (unsigned int) b; /* 0..65535: no; 4294901761..4294967295: yes */
-  x >>= 31; /* 0: no; 1: yes */
-  return x;
-}
-
-
-/* Reduce coefficients of r before calling reduce_add_sub */
-static void reduce_add_sub(word32 *r)
-{
-  word32 pb = 0;
-  word32 b;
-  word32 mask;
-  int i;
-  unsigned char t[32];
-
-  for(i=0;i<32;i++)
-  {
-    pb += m[i];
-    b = lt(r[i],pb);
-    t[i] = r[i]-pb+(b<<8);
-    pb = b;
-  }
-  mask = b - 1;
-  for(i=0;i<32;i++)
-    r[i] ^= mask & (r[i] ^ t[i]);
-}
-
-
-/* Reduce coefficients of x before calling barrett_reduce */
-static void barrett_reduce(word32* r, word32 x[64])
-{
-  /* See HAC, Alg. 14.42 */
-  int i,j;
-  word32 q2[66];
-  word32 *q3 = q2 + 33;
-  word32 r1[33];
-  word32 r2[33];
-  word32 carry;
-  word32 pb = 0;
-  word32 b;
-
-  for (i = 0;i < 66;++i) q2[i] = 0;
-  for (i = 0;i < 33;++i) r2[i] = 0;
-
-  for(i=0;i<33;i++)
-    for(j=0;j<33;j++)
-      if(i+j >= 31) q2[i+j] += mu[i]*x[j+31];
-  carry = q2[31] >> 8;
-  q2[32] += carry;
-  carry = q2[32] >> 8;
-  q2[33] += carry;
-
-  for(i=0;i<33;i++)r1[i] = x[i];
-  for(i=0;i<32;i++)
-    for(j=0;j<33;j++)
-      if(i+j < 33) r2[i+j] += m[i]*q3[j];
-
-  for(i=0;i<32;i++)
-  {
-    carry = r2[i] >> 8;
-    r2[i+1] += carry;
-    r2[i] &= 0xff;
-  }
-
-  for(i=0;i<32;i++)
-  {
-    pb += r2[i];
-    b = lt(r1[i],pb);
-    r[i] = r1[i]-pb+(b<<8);
-    pb = b;
-  }
-
-  /* XXX: Can it really happen that r<0?, See HAC, Alg 14.42, Step 3
-   * r is an unsigned type.
-   * If so: Handle  it here!
-   */
-
-  reduce_add_sub(r);
-  reduce_add_sub(r);
-}
-
-
-void sc_reduce(unsigned char x[64])
-{
-  int i;
-  word32 t[64];
-  word32 r[32];
-  for(i=0;i<64;i++) t[i] = x[i];
-  barrett_reduce(r, t);
-  for(i=0;i<32;i++) x[i] = (r[i] & 0xFF);
-}
-
-
-void sc_muladd(byte* out, const byte* a, const byte* b, const byte* c)
-{
-
-	byte s[32];
-    byte e[64];
-
-    XMEMSET(e, 0, sizeof(e));
-    XMEMCPY(e, b, 32);
-
-	/* Obtain e */
-	sc_reduce(e);
-
-	/* Compute s = ze + k */
-	fprime_mul(s, a, e, ed25519_order);
-	fprime_add(s, c, ed25519_order);
-
-	XMEMCPY(out, s, 32);
-}
-
-
-/* Base point is (numbers wrapped):
- *
- *     x = 151122213495354007725011514095885315114
- *         54012693041857206046113283949847762202
- *     y = 463168356949264781694283940034751631413
- *         07993866256225615783033603165251855960
- *
- * y is derived by transforming the original Montgomery base (u=9). x
- * is the corresponding positive coordinate for the new curve equation.
- * t is x*y.
- */
-const ge_p3 ed25519_base = {
-	.X = {
-		0x1a, 0xd5, 0x25, 0x8f, 0x60, 0x2d, 0x56, 0xc9,
-		0xb2, 0xa7, 0x25, 0x95, 0x60, 0xc7, 0x2c, 0x69,
-		0x5c, 0xdc, 0xd6, 0xfd, 0x31, 0xe2, 0xa4, 0xc0,
-		0xfe, 0x53, 0x6e, 0xcd, 0xd3, 0x36, 0x69, 0x21
-	},
-	.Y = {
-		0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
-		0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
-		0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
-		0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66
-	},
-	.T = {
-		0xa3, 0xdd, 0xb7, 0xa5, 0xb3, 0x8a, 0xde, 0x6d,
-		0xf5, 0x52, 0x51, 0x77, 0x80, 0x9f, 0xf0, 0x20,
-		0x7d, 0xe3, 0xab, 0x64, 0x8e, 0x4e, 0xea, 0x66,
-		0x65, 0x76, 0x8b, 0xd7, 0x0f, 0x5f, 0x87, 0x67
-	},
-	.Z = {1, 0}
-};
-
-
-const ge_p3 ed25519_neutral = {
-	.X = {0},
-	.Y = {1, 0},
-	.T = {0},
-	.Z = {1, 0}
-};
-
-
-static const byte ed25519_d[F25519_SIZE] = {
-	0xa3, 0x78, 0x59, 0x13, 0xca, 0x4d, 0xeb, 0x75,
-	0xab, 0xd8, 0x41, 0x41, 0x4d, 0x0a, 0x70, 0x00,
-	0x98, 0xe8, 0x79, 0x77, 0x79, 0x40, 0xc7, 0x8c,
-	0x73, 0xfe, 0x6f, 0x2b, 0xee, 0x6c, 0x03, 0x52
-};
-
-
-/* k = 2d */
-static const byte ed25519_k[F25519_SIZE] = {
-	0x59, 0xf1, 0xb2, 0x26, 0x94, 0x9b, 0xd6, 0xeb,
-	0x56, 0xb1, 0x83, 0x82, 0x9a, 0x14, 0xe0, 0x00,
-	0x30, 0xd1, 0xf3, 0xee, 0xf2, 0x80, 0x8e, 0x19,
-	0xe7, 0xfc, 0xdf, 0x56, 0xdc, 0xd9, 0x06, 0x24
-};
-
-
-void ed25519_add(ge_p3 *r,
-		 const ge_p3 *p1, const ge_p3 *p2)
-{
-	/* Explicit formulas database: add-2008-hwcd-3
-	 *
-	 * source 2008 Hisil--Wong--Carter--Dawson,
-	 *     http://eprint.iacr.org/2008/522, Section 3.1
-	 * appliesto extended-1
-	 * parameter k
-	 * assume k = 2 d
-	 * compute A = (Y1-X1)(Y2-X2)
-	 * compute B = (Y1+X1)(Y2+X2)
-	 * compute C = T1 k T2
-	 * compute D = Z1 2 Z2
-	 * compute E = B - A
-	 * compute F = D - C
-	 * compute G = D + C
-	 * compute H = B + A
-	 * compute X3 = E F
-	 * compute Y3 = G H
-	 * compute T3 = E H
-	 * compute Z3 = F G
-	 */
-	byte a[F25519_SIZE];
-	byte b[F25519_SIZE];
-	byte c[F25519_SIZE];
-	byte d[F25519_SIZE];
-	byte e[F25519_SIZE];
-	byte f[F25519_SIZE];
-	byte g[F25519_SIZE];
-	byte h[F25519_SIZE];
-
-	/* A = (Y1-X1)(Y2-X2) */
-	fe_sub(c, p1->Y, p1->X);
-	fe_sub(d, p2->Y, p2->X);
-	fe_mul__distinct(a, c, d);
-
-	/* B = (Y1+X1)(Y2+X2) */
-	fe_add(c, p1->Y, p1->X);
-	fe_add(d, p2->Y, p2->X);
-	fe_mul__distinct(b, c, d);
-
-	/* C = T1 k T2 */
-	fe_mul__distinct(d, p1->T, p2->T);
-	fe_mul__distinct(c, d, ed25519_k);
-
-	/* D = Z1 2 Z2 */
-	fe_mul__distinct(d, p1->Z, p2->Z);
-	fe_add(d, d, d);
-
-	/* E = B - A */
-	fe_sub(e, b, a);
-
-	/* F = D - C */
-	fe_sub(f, d, c);
-
-	/* G = D + C */
-	fe_add(g, d, c);
-
-	/* H = B + A */
-	fe_add(h, b, a);
-
-	/* X3 = E F */
-	fe_mul__distinct(r->X, e, f);
-
-	/* Y3 = G H */
-	fe_mul__distinct(r->Y, g, h);
-
-	/* T3 = E H */
-	fe_mul__distinct(r->T, e, h);
-
-	/* Z3 = F G */
-	fe_mul__distinct(r->Z, f, g);
-}
-
-
-void ed25519_double(ge_p3 *r, const ge_p3 *p)
-{
-	/* Explicit formulas database: dbl-2008-hwcd
-	 *
-	 * source 2008 Hisil--Wong--Carter--Dawson,
-	 *     http://eprint.iacr.org/2008/522, Section 3.3
-	 * compute A = X1^2
-	 * compute B = Y1^2
-	 * compute C = 2 Z1^2
-	 * compute D = a A
-	 * compute E = (X1+Y1)^2-A-B
-	 * compute G = D + B
-	 * compute F = G - C
-	 * compute H = D - B
-	 * compute X3 = E F
-	 * compute Y3 = G H
-	 * compute T3 = E H
-	 * compute Z3 = F G
-	 */
-	byte a[F25519_SIZE];
-	byte b[F25519_SIZE];
-	byte c[F25519_SIZE];
-	byte e[F25519_SIZE];
-	byte f[F25519_SIZE];
-	byte g[F25519_SIZE];
-	byte h[F25519_SIZE];
-
-	/* A = X1^2 */
-	fe_mul__distinct(a, p->X, p->X);
-
-	/* B = Y1^2 */
-	fe_mul__distinct(b, p->Y, p->Y);
-
-	/* C = 2 Z1^2 */
-	fe_mul__distinct(c, p->Z, p->Z);
-	fe_add(c, c, c);
-
-	/* D = a A (alter sign) */
-	/* E = (X1+Y1)^2-A-B */
-	fe_add(f, p->X, p->Y);
-	fe_mul__distinct(e, f, f);
-	fe_sub(e, e, a);
-	fe_sub(e, e, b);
-
-	/* G = D + B */
-	fe_sub(g, b, a);
-
-	/* F = G - C */
-	fe_sub(f, g, c);
-
-	/* H = D - B */
-	fe_neg(h, b);
-	fe_sub(h, h, a);
-
-	/* X3 = E F */
-	fe_mul__distinct(r->X, e, f);
-
-	/* Y3 = G H */
-	fe_mul__distinct(r->Y, g, h);
-
-	/* T3 = E H */
-	fe_mul__distinct(r->T, e, h);
-
-	/* Z3 = F G */
-	fe_mul__distinct(r->Z, f, g);
-}
-
-
-void ed25519_smult(ge_p3 *r_out, const ge_p3 *p, const byte *e)
-{
-	ge_p3 r;
-	int   i;
-
-    XMEMCPY(&r, &ed25519_neutral, sizeof(r));
-
-	for (i = 255; i >= 0; i--) {
-		const byte bit = (e[i >> 3] >> (i & 7)) & 1;
-		ge_p3 s;
-
-		ed25519_double(&r, &r);
-		ed25519_add(&s, &r, p);
-
-		fe_select(r.X, r.X, s.X, bit);
-		fe_select(r.Y, r.Y, s.Y, bit);
-		fe_select(r.Z, r.Z, s.Z, bit);
-		fe_select(r.T, r.T, s.T, bit);
-	}
-    XMEMCPY(r_out, &r, sizeof(r));
-}
-
-
-void ge_scalarmult_base(ge_p3 *R,const unsigned char *nonce)
-{
-	ed25519_smult(R, &ed25519_base, nonce);
-}
-
-
-/* pack the point h into array s */
-void ge_p3_tobytes(unsigned char *s,const ge_p3 *h)
-{
-	byte x[F25519_SIZE];
-	byte y[F25519_SIZE];
-	byte z1[F25519_SIZE];
-	byte parity;
-
-	fe_inv__distinct(z1, h->Z);
-	fe_mul__distinct(x, h->X, z1);
-	fe_mul__distinct(y, h->Y, z1);
-
-	fe_normalize(x);
-	fe_normalize(y);
-
-	parity = (x[0] & 1) << 7;
-	fe_copy(s, y);
-	fe_normalize(s);
-	s[31] |= parity;
-}
-
-
-/* pack the point h into array s */
-void ge_tobytes(unsigned char *s,const ge_p2 *h)
-{
-	byte x[F25519_SIZE];
-	byte y[F25519_SIZE];
-	byte z1[F25519_SIZE];
-	byte parity;
-
-	fe_inv__distinct(z1, h->Z);
-	fe_mul__distinct(x, h->X, z1);
-	fe_mul__distinct(y, h->Y, z1);
-
-	fe_normalize(x);
-	fe_normalize(y);
-
-	parity = (x[0] & 1) << 7;
-	fe_copy(s, y);
-	fe_normalize(s);
-	s[31] |= parity;
-}
-
-
-/*
-   Test if the public key can be uncommpressed and negate it (-X,Y,Z,-T)
-   return 0 on success
- */
-int ge_frombytes_negate_vartime(ge_p3 *p,const unsigned char *s)
-{
-
-	byte parity;
-    byte x[F25519_SIZE];
-	byte y[F25519_SIZE];
-	byte a[F25519_SIZE];
-	byte b[F25519_SIZE];
-	byte c[F25519_SIZE];
-    int ret = 0;
-
-    /* unpack the key s */
-    parity = s[31] >> 7;
-    fe_copy(y, s);
-	y[31] &= 127;
-
-	fe_mul__distinct(c, y, y);
-    fe_mul__distinct(b, c, ed25519_d);
-	fe_add(a, b, f25519_one);
-	fe_inv__distinct(b, a);
-	fe_sub(a, c, f25519_one);
-	fe_mul__distinct(c, a, b);
-	fe_sqrt(a, c);
-	fe_neg(b, a);
-	fe_select(x, a, b, (a[0] ^ parity) & 1);
-
-    /* test that x^2 is equal to c */
-    fe_mul__distinct(a, x, x);
-	fe_normalize(a);
-	fe_normalize(c);
-	ret |= ConstantCompare(a, c, F25519_SIZE);
-
-    /* project the key s onto p */
-	fe_copy(p->X, x);
-	fe_copy(p->Y, y);
-	fe_load(p->Z, 1);
-	fe_mul__distinct(p->T, x, y);
-
-    /* negate, the point becomes (-X,Y,Z,-T) */
-    fe_neg(p->X,p->X);
-    fe_neg(p->T,p->T);
-
-    return ret;
-}
-
-
-int ge_double_scalarmult_vartime(ge_p2* R, const unsigned char *h,
-                                 const ge_p3 *inA,const unsigned char *sig)
-{
-    ge_p3 p, A;
-    int ret = 0;
-
-    XMEMCPY(&A, inA, sizeof(ge_p3));
-
-    /* find SB */
-    ed25519_smult(&p, &ed25519_base, sig);
-
-    /* find H(R,A,M) * -A */
-	ed25519_smult(&A, &A, h);
-
-    /* SB + -H(R,A,M)A */
-	ed25519_add(&A, &p, &A);
-
-    fe_copy(R->X, A.X);
-    fe_copy(R->Y, A.Y);
-    fe_copy(R->Z, A.Z);
-
-    return ret;
-}
-
-#endif /* HAVE_ED25519 */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ge_operations.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ge_operations.c
deleted file mode 100755
index 665cfe8..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ge_operations.c
+++ /dev/null
@@ -1,2603 +0,0 @@
-/* ge_operations.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
- /* Based On Daniel J Bernstein's ed25519 Public Domain ref10 work. */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef HAVE_ED25519
-
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-/*
-ge means group element.
-
-Here the group is the set of pairs (x,y) of field elements (see fe.h)
-satisfying -x^2 + y^2 = 1 + d x^2y^2
-where d = -121665/121666.
-
-Representations:
-  ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z
-  ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT
-  ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T
-  ge_precomp (Duif): (y+x,y-x,2dxy)
-*/
-
-
-/*
-Input:
-  s[0]+256*s[1]+...+256^63*s[63] = s
-
-Output:
-  s[0]+256*s[1]+...+256^31*s[31] = s mod l
-  where l = 2^252 + 27742317777372353535851937790883648493.
-  Overwrites s in place.
-*/
-void sc_reduce(byte* s)
-{
-  int64_t s0 = 2097151 & load_3(s);
-  int64_t s1 = 2097151 & (load_4(s + 2) >> 5);
-  int64_t s2 = 2097151 & (load_3(s + 5) >> 2);
-  int64_t s3 = 2097151 & (load_4(s + 7) >> 7);
-  int64_t s4 = 2097151 & (load_4(s + 10) >> 4);
-  int64_t s5 = 2097151 & (load_3(s + 13) >> 1);
-  int64_t s6 = 2097151 & (load_4(s + 15) >> 6);
-  int64_t s7 = 2097151 & (load_3(s + 18) >> 3);
-  int64_t s8 = 2097151 & load_3(s + 21);
-  int64_t s9 = 2097151 & (load_4(s + 23) >> 5);
-  int64_t s10 = 2097151 & (load_3(s + 26) >> 2);
-  int64_t s11 = 2097151 & (load_4(s + 28) >> 7);
-  int64_t s12 = 2097151 & (load_4(s + 31) >> 4);
-  int64_t s13 = 2097151 & (load_3(s + 34) >> 1);
-  int64_t s14 = 2097151 & (load_4(s + 36) >> 6);
-  int64_t s15 = 2097151 & (load_3(s + 39) >> 3);
-  int64_t s16 = 2097151 & load_3(s + 42);
-  int64_t s17 = 2097151 & (load_4(s + 44) >> 5);
-  int64_t s18 = 2097151 & (load_3(s + 47) >> 2);
-  int64_t s19 = 2097151 & (load_4(s + 49) >> 7);
-  int64_t s20 = 2097151 & (load_4(s + 52) >> 4);
-  int64_t s21 = 2097151 & (load_3(s + 55) >> 1);
-  int64_t s22 = 2097151 & (load_4(s + 57) >> 6);
-  int64_t s23 = (load_4(s + 60) >> 3);
-  int64_t carry0;
-  int64_t carry1;
-  int64_t carry2;
-  int64_t carry3;
-  int64_t carry4;
-  int64_t carry5;
-  int64_t carry6;
-  int64_t carry7;
-  int64_t carry8;
-  int64_t carry9;
-  int64_t carry10;
-  int64_t carry11;
-  int64_t carry12;
-  int64_t carry13;
-  int64_t carry14;
-  int64_t carry15;
-  int64_t carry16;
-
-  s11 += s23 * 666643;
-  s12 += s23 * 470296;
-  s13 += s23 * 654183;
-  s14 -= s23 * 997805;
-  s15 += s23 * 136657;
-  s16 -= s23 * 683901;
-  s23 = 0;
-
-  s10 += s22 * 666643;
-  s11 += s22 * 470296;
-  s12 += s22 * 654183;
-  s13 -= s22 * 997805;
-  s14 += s22 * 136657;
-  s15 -= s22 * 683901;
-  s22 = 0;
-
-  s9 += s21 * 666643;
-  s10 += s21 * 470296;
-  s11 += s21 * 654183;
-  s12 -= s21 * 997805;
-  s13 += s21 * 136657;
-  s14 -= s21 * 683901;
-  s21 = 0;
-
-  s8 += s20 * 666643;
-  s9 += s20 * 470296;
-  s10 += s20 * 654183;
-  s11 -= s20 * 997805;
-  s12 += s20 * 136657;
-  s13 -= s20 * 683901;
-  s20 = 0;
-
-  s7 += s19 * 666643;
-  s8 += s19 * 470296;
-  s9 += s19 * 654183;
-  s10 -= s19 * 997805;
-  s11 += s19 * 136657;
-  s12 -= s19 * 683901;
-  s19 = 0;
-
-  s6 += s18 * 666643;
-  s7 += s18 * 470296;
-  s8 += s18 * 654183;
-  s9 -= s18 * 997805;
-  s10 += s18 * 136657;
-  s11 -= s18 * 683901;
-  s18 = 0;
-
-  carry6 = (s6 + (1<<20)) >> 21; s7 += carry6; s6 -= carry6 << 21;
-  carry8 = (s8 + (1<<20)) >> 21; s9 += carry8; s8 -= carry8 << 21;
-  carry10 = (s10 + (1<<20)) >> 21; s11 += carry10; s10 -= carry10 << 21;
-  carry12 = (s12 + (1<<20)) >> 21; s13 += carry12; s12 -= carry12 << 21;
-  carry14 = (s14 + (1<<20)) >> 21; s15 += carry14; s14 -= carry14 << 21;
-  carry16 = (s16 + (1<<20)) >> 21; s17 += carry16; s16 -= carry16 << 21;
-
-  carry7 = (s7 + (1<<20)) >> 21; s8 += carry7; s7 -= carry7 << 21;
-  carry9 = (s9 + (1<<20)) >> 21; s10 += carry9; s9 -= carry9 << 21;
-  carry11 = (s11 + (1<<20)) >> 21; s12 += carry11; s11 -= carry11 << 21;
-  carry13 = (s13 + (1<<20)) >> 21; s14 += carry13; s13 -= carry13 << 21;
-  carry15 = (s15 + (1<<20)) >> 21; s16 += carry15; s15 -= carry15 << 21;
-
-  s5 += s17 * 666643;
-  s6 += s17 * 470296;
-  s7 += s17 * 654183;
-  s8 -= s17 * 997805;
-  s9 += s17 * 136657;
-  s10 -= s17 * 683901;
-  s17 = 0;
-
-  s4 += s16 * 666643;
-  s5 += s16 * 470296;
-  s6 += s16 * 654183;
-  s7 -= s16 * 997805;
-  s8 += s16 * 136657;
-  s9 -= s16 * 683901;
-  s16 = 0;
-
-  s3 += s15 * 666643;
-  s4 += s15 * 470296;
-  s5 += s15 * 654183;
-  s6 -= s15 * 997805;
-  s7 += s15 * 136657;
-  s8 -= s15 * 683901;
-  s15 = 0;
-
-  s2 += s14 * 666643;
-  s3 += s14 * 470296;
-  s4 += s14 * 654183;
-  s5 -= s14 * 997805;
-  s6 += s14 * 136657;
-  s7 -= s14 * 683901;
-  s14 = 0;
-
-  s1 += s13 * 666643;
-  s2 += s13 * 470296;
-  s3 += s13 * 654183;
-  s4 -= s13 * 997805;
-  s5 += s13 * 136657;
-  s6 -= s13 * 683901;
-  s13 = 0;
-
-  s0 += s12 * 666643;
-  s1 += s12 * 470296;
-  s2 += s12 * 654183;
-  s3 -= s12 * 997805;
-  s4 += s12 * 136657;
-  s5 -= s12 * 683901;
-  s12 = 0;
-
-  carry0 = (s0 + (1<<20)) >> 21; s1 += carry0; s0 -= carry0 << 21;
-  carry2 = (s2 + (1<<20)) >> 21; s3 += carry2; s2 -= carry2 << 21;
-  carry4 = (s4 + (1<<20)) >> 21; s5 += carry4; s4 -= carry4 << 21;
-  carry6 = (s6 + (1<<20)) >> 21; s7 += carry6; s6 -= carry6 << 21;
-  carry8 = (s8 + (1<<20)) >> 21; s9 += carry8; s8 -= carry8 << 21;
-  carry10 = (s10 + (1<<20)) >> 21; s11 += carry10; s10 -= carry10 << 21;
-
-  carry1 = (s1 + (1<<20)) >> 21; s2 += carry1; s1 -= carry1 << 21;
-  carry3 = (s3 + (1<<20)) >> 21; s4 += carry3; s3 -= carry3 << 21;
-  carry5 = (s5 + (1<<20)) >> 21; s6 += carry5; s5 -= carry5 << 21;
-  carry7 = (s7 + (1<<20)) >> 21; s8 += carry7; s7 -= carry7 << 21;
-  carry9 = (s9 + (1<<20)) >> 21; s10 += carry9; s9 -= carry9 << 21;
-  carry11 = (s11 + (1<<20)) >> 21; s12 += carry11; s11 -= carry11 << 21;
-
-  s0 += s12 * 666643;
-  s1 += s12 * 470296;
-  s2 += s12 * 654183;
-  s3 -= s12 * 997805;
-  s4 += s12 * 136657;
-  s5 -= s12 * 683901;
-  s12 = 0;
-
-  carry0 = s0 >> 21; s1 += carry0; s0 -= carry0 << 21;
-  carry1 = s1 >> 21; s2 += carry1; s1 -= carry1 << 21;
-  carry2 = s2 >> 21; s3 += carry2; s2 -= carry2 << 21;
-  carry3 = s3 >> 21; s4 += carry3; s3 -= carry3 << 21;
-  carry4 = s4 >> 21; s5 += carry4; s4 -= carry4 << 21;
-  carry5 = s5 >> 21; s6 += carry5; s5 -= carry5 << 21;
-  carry6 = s6 >> 21; s7 += carry6; s6 -= carry6 << 21;
-  carry7 = s7 >> 21; s8 += carry7; s7 -= carry7 << 21;
-  carry8 = s8 >> 21; s9 += carry8; s8 -= carry8 << 21;
-  carry9 = s9 >> 21; s10 += carry9; s9 -= carry9 << 21;
-  carry10 = s10 >> 21; s11 += carry10; s10 -= carry10 << 21;
-  carry11 = s11 >> 21; s12 += carry11; s11 -= carry11 << 21;
-
-  s0 += s12 * 666643;
-  s1 += s12 * 470296;
-  s2 += s12 * 654183;
-  s3 -= s12 * 997805;
-  s4 += s12 * 136657;
-  s5 -= s12 * 683901;
-  s12 = 0;
-
-  carry0 = s0 >> 21; s1 += carry0; s0 -= carry0 << 21;
-  carry1 = s1 >> 21; s2 += carry1; s1 -= carry1 << 21;
-  carry2 = s2 >> 21; s3 += carry2; s2 -= carry2 << 21;
-  carry3 = s3 >> 21; s4 += carry3; s3 -= carry3 << 21;
-  carry4 = s4 >> 21; s5 += carry4; s4 -= carry4 << 21;
-  carry5 = s5 >> 21; s6 += carry5; s5 -= carry5 << 21;
-  carry6 = s6 >> 21; s7 += carry6; s6 -= carry6 << 21;
-  carry7 = s7 >> 21; s8 += carry7; s7 -= carry7 << 21;
-  carry8 = s8 >> 21; s9 += carry8; s8 -= carry8 << 21;
-  carry9 = s9 >> 21; s10 += carry9; s9 -= carry9 << 21;
-  carry10 = s10 >> 21; s11 += carry10; s10 -= carry10 << 21;
-
-  s[0] = s0 >> 0;
-  s[1] = s0 >> 8;
-  s[2] = (s0 >> 16) | (s1 << 5);
-  s[3] = s1 >> 3;
-  s[4] = s1 >> 11;
-  s[5] = (s1 >> 19) | (s2 << 2);
-  s[6] = s2 >> 6;
-  s[7] = (s2 >> 14) | (s3 << 7);
-  s[8] = s3 >> 1;
-  s[9] = s3 >> 9;
-  s[10] = (s3 >> 17) | (s4 << 4);
-  s[11] = s4 >> 4;
-  s[12] = s4 >> 12;
-  s[13] = (s4 >> 20) | (s5 << 1);
-  s[14] = s5 >> 7;
-  s[15] = (s5 >> 15) | (s6 << 6);
-  s[16] = s6 >> 2;
-  s[17] = s6 >> 10;
-  s[18] = (s6 >> 18) | (s7 << 3);
-  s[19] = s7 >> 5;
-  s[20] = s7 >> 13;
-  s[21] = s8 >> 0;
-  s[22] = s8 >> 8;
-  s[23] = (s8 >> 16) | (s9 << 5);
-  s[24] = s9 >> 3;
-  s[25] = s9 >> 11;
-  s[26] = (s9 >> 19) | (s10 << 2);
-  s[27] = s10 >> 6;
-  s[28] = (s10 >> 14) | (s11 << 7);
-  s[29] = s11 >> 1;
-  s[30] = s11 >> 9;
-  s[31] = s11 >> 17;
-
-  /* hush warnings after setting values to 0 */
-  (void)s12;
-  (void)s13;
-  (void)s14;
-  (void)s15;
-  (void)s16;
-  (void)s17;
-  (void)s18;
-  (void)s19;
-  (void)s20;
-  (void)s21;
-  (void)s22;
-  (void)s23;
-}
-
-
-/*
-Input:
-  a[0]+256*a[1]+...+256^31*a[31] = a
-  b[0]+256*b[1]+...+256^31*b[31] = b
-  c[0]+256*c[1]+...+256^31*c[31] = c
-
-Output:
-  s[0]+256*s[1]+...+256^31*s[31] = (ab+c) mod l
-  where l = 2^252 + 27742317777372353535851937790883648493.
-*/
-void sc_muladd(byte* s, const byte* a, const byte* b, const byte* c)
-{
-  int64_t a0 = 2097151 & load_3(a);
-  int64_t a1 = 2097151 & (load_4(a + 2) >> 5);
-  int64_t a2 = 2097151 & (load_3(a + 5) >> 2);
-  int64_t a3 = 2097151 & (load_4(a + 7) >> 7);
-  int64_t a4 = 2097151 & (load_4(a + 10) >> 4);
-  int64_t a5 = 2097151 & (load_3(a + 13) >> 1);
-  int64_t a6 = 2097151 & (load_4(a + 15) >> 6);
-  int64_t a7 = 2097151 & (load_3(a + 18) >> 3);
-  int64_t a8 = 2097151 & load_3(a + 21);
-  int64_t a9 = 2097151 & (load_4(a + 23) >> 5);
-  int64_t a10 = 2097151 & (load_3(a + 26) >> 2);
-  int64_t a11 = (load_4(a + 28) >> 7);
-  int64_t b0 = 2097151 & load_3(b);
-  int64_t b1 = 2097151 & (load_4(b + 2) >> 5);
-  int64_t b2 = 2097151 & (load_3(b + 5) >> 2);
-  int64_t b3 = 2097151 & (load_4(b + 7) >> 7);
-  int64_t b4 = 2097151 & (load_4(b + 10) >> 4);
-  int64_t b5 = 2097151 & (load_3(b + 13) >> 1);
-  int64_t b6 = 2097151 & (load_4(b + 15) >> 6);
-  int64_t b7 = 2097151 & (load_3(b + 18) >> 3);
-  int64_t b8 = 2097151 & load_3(b + 21);
-  int64_t b9 = 2097151 & (load_4(b + 23) >> 5);
-  int64_t b10 = 2097151 & (load_3(b + 26) >> 2);
-  int64_t b11 = (load_4(b + 28) >> 7);
-  int64_t c0 = 2097151 & load_3(c);
-  int64_t c1 = 2097151 & (load_4(c + 2) >> 5);
-  int64_t c2 = 2097151 & (load_3(c + 5) >> 2);
-  int64_t c3 = 2097151 & (load_4(c + 7) >> 7);
-  int64_t c4 = 2097151 & (load_4(c + 10) >> 4);
-  int64_t c5 = 2097151 & (load_3(c + 13) >> 1);
-  int64_t c6 = 2097151 & (load_4(c + 15) >> 6);
-  int64_t c7 = 2097151 & (load_3(c + 18) >> 3);
-  int64_t c8 = 2097151 & load_3(c + 21);
-  int64_t c9 = 2097151 & (load_4(c + 23) >> 5);
-  int64_t c10 = 2097151 & (load_3(c + 26) >> 2);
-  int64_t c11 = (load_4(c + 28) >> 7);
-  int64_t s0;
-  int64_t s1;
-  int64_t s2;
-  int64_t s3;
-  int64_t s4;
-  int64_t s5;
-  int64_t s6;
-  int64_t s7;
-  int64_t s8;
-  int64_t s9;
-  int64_t s10;
-  int64_t s11;
-  int64_t s12;
-  int64_t s13;
-  int64_t s14;
-  int64_t s15;
-  int64_t s16;
-  int64_t s17;
-  int64_t s18;
-  int64_t s19;
-  int64_t s20;
-  int64_t s21;
-  int64_t s22;
-  int64_t s23;
-  int64_t carry0;
-  int64_t carry1;
-  int64_t carry2;
-  int64_t carry3;
-  int64_t carry4;
-  int64_t carry5;
-  int64_t carry6;
-  int64_t carry7;
-  int64_t carry8;
-  int64_t carry9;
-  int64_t carry10;
-  int64_t carry11;
-  int64_t carry12;
-  int64_t carry13;
-  int64_t carry14;
-  int64_t carry15;
-  int64_t carry16;
-  int64_t carry17;
-  int64_t carry18;
-  int64_t carry19;
-  int64_t carry20;
-  int64_t carry21;
-  int64_t carry22;
-
-  s0 = c0 + a0*b0;
-  s1 = c1 + a0*b1 + a1*b0;
-  s2 = c2 + a0*b2 + a1*b1 + a2*b0;
-  s3 = c3 + a0*b3 + a1*b2 + a2*b1 + a3*b0;
-  s4 = c4 + a0*b4 + a1*b3 + a2*b2 + a3*b1 + a4*b0;
-  s5 = c5 + a0*b5 + a1*b4 + a2*b3 + a3*b2 + a4*b1 + a5*b0;
-  s6 = c6 + a0*b6 + a1*b5 + a2*b4 + a3*b3 + a4*b2 + a5*b1 + a6*b0;
-  s7 = c7 + a0*b7 + a1*b6 + a2*b5 + a3*b4 + a4*b3 + a5*b2 + a6*b1 + a7*b0;
-  s8 = c8 + a0*b8 + a1*b7 + a2*b6 + a3*b5 + a4*b4 + a5*b3 + a6*b2 + a7*b1
-          + a8*b0;
-  s9 = c9 + a0*b9 + a1*b8 + a2*b7 + a3*b6 + a4*b5 + a5*b4 + a6*b3 + a7*b2
-          + a8*b1 + a9*b0;
-  s10 = c10 + a0*b10 + a1*b9 + a2*b8 + a3*b7 + a4*b6 + a5*b5 + a6*b4 + a7*b3
-            + a8*b2 + a9*b1 + a10*b0;
-  s11 = c11 + a0*b11 + a1*b10 + a2*b9 + a3*b8 + a4*b7 + a5*b6 + a6*b5 + a7*b4
-            + a8*b3 + a9*b2 + a10*b1 + a11*b0;
-  s12 = a1*b11 + a2*b10 + a3*b9 + a4*b8 + a5*b7 + a6*b6 + a7*b5 + a8*b4 + a9*b3
-               + a10*b2 + a11*b1;
-  s13 = a2*b11 + a3*b10 + a4*b9 + a5*b8 + a6*b7 + a7*b6 + a8*b5 + a9*b4 + a10*b3
-               + a11*b2;
-  s14 = a3*b11 + a4*b10 + a5*b9 + a6*b8 + a7*b7 + a8*b6 + a9*b5 + a10*b4
-               + a11*b3;
-  s15 = a4*b11 + a5*b10 + a6*b9 + a7*b8 + a8*b7 + a9*b6 + a10*b5 + a11*b4;
-  s16 = a5*b11 + a6*b10 + a7*b9 + a8*b8 + a9*b7 + a10*b6 + a11*b5;
-  s17 = a6*b11 + a7*b10 + a8*b9 + a9*b8 + a10*b7 + a11*b6;
-  s18 = a7*b11 + a8*b10 + a9*b9 + a10*b8 + a11*b7;
-  s19 = a8*b11 + a9*b10 + a10*b9 + a11*b8;
-  s20 = a9*b11 + a10*b10 + a11*b9;
-  s21 = a10*b11 + a11*b10;
-  s22 = a11*b11;
-  s23 = 0;
-
-  carry0 = (s0 + (1<<20)) >> 21; s1 += carry0; s0 -= carry0 << 21;
-  carry2 = (s2 + (1<<20)) >> 21; s3 += carry2; s2 -= carry2 << 21;
-  carry4 = (s4 + (1<<20)) >> 21; s5 += carry4; s4 -= carry4 << 21;
-  carry6 = (s6 + (1<<20)) >> 21; s7 += carry6; s6 -= carry6 << 21;
-  carry8 = (s8 + (1<<20)) >> 21; s9 += carry8; s8 -= carry8 << 21;
-  carry10 = (s10 + (1<<20)) >> 21; s11 += carry10; s10 -= carry10 << 21;
-  carry12 = (s12 + (1<<20)) >> 21; s13 += carry12; s12 -= carry12 << 21;
-  carry14 = (s14 + (1<<20)) >> 21; s15 += carry14; s14 -= carry14 << 21;
-  carry16 = (s16 + (1<<20)) >> 21; s17 += carry16; s16 -= carry16 << 21;
-  carry18 = (s18 + (1<<20)) >> 21; s19 += carry18; s18 -= carry18 << 21;
-  carry20 = (s20 + (1<<20)) >> 21; s21 += carry20; s20 -= carry20 << 21;
-  carry22 = (s22 + (1<<20)) >> 21; s23 += carry22; s22 -= carry22 << 21;
-
-  carry1 = (s1 + (1<<20)) >> 21; s2 += carry1; s1 -= carry1 << 21;
-  carry3 = (s3 + (1<<20)) >> 21; s4 += carry3; s3 -= carry3 << 21;
-  carry5 = (s5 + (1<<20)) >> 21; s6 += carry5; s5 -= carry5 << 21;
-  carry7 = (s7 + (1<<20)) >> 21; s8 += carry7; s7 -= carry7 << 21;
-  carry9 = (s9 + (1<<20)) >> 21; s10 += carry9; s9 -= carry9 << 21;
-  carry11 = (s11 + (1<<20)) >> 21; s12 += carry11; s11 -= carry11 << 21;
-  carry13 = (s13 + (1<<20)) >> 21; s14 += carry13; s13 -= carry13 << 21;
-  carry15 = (s15 + (1<<20)) >> 21; s16 += carry15; s15 -= carry15 << 21;
-  carry17 = (s17 + (1<<20)) >> 21; s18 += carry17; s17 -= carry17 << 21;
-  carry19 = (s19 + (1<<20)) >> 21; s20 += carry19; s19 -= carry19 << 21;
-  carry21 = (s21 + (1<<20)) >> 21; s22 += carry21; s21 -= carry21 << 21;
-
-  s11 += s23 * 666643;
-  s12 += s23 * 470296;
-  s13 += s23 * 654183;
-  s14 -= s23 * 997805;
-  s15 += s23 * 136657;
-  s16 -= s23 * 683901;
-  s23 = 0;
-
-  s10 += s22 * 666643;
-  s11 += s22 * 470296;
-  s12 += s22 * 654183;
-  s13 -= s22 * 997805;
-  s14 += s22 * 136657;
-  s15 -= s22 * 683901;
-  s22 = 0;
-
-  s9 += s21 * 666643;
-  s10 += s21 * 470296;
-  s11 += s21 * 654183;
-  s12 -= s21 * 997805;
-  s13 += s21 * 136657;
-  s14 -= s21 * 683901;
-  s21 = 0;
-
-  s8 += s20 * 666643;
-  s9 += s20 * 470296;
-  s10 += s20 * 654183;
-  s11 -= s20 * 997805;
-  s12 += s20 * 136657;
-  s13 -= s20 * 683901;
-  s20 = 0;
-
-  s7 += s19 * 666643;
-  s8 += s19 * 470296;
-  s9 += s19 * 654183;
-  s10 -= s19 * 997805;
-  s11 += s19 * 136657;
-  s12 -= s19 * 683901;
-  s19 = 0;
-
-  s6 += s18 * 666643;
-  s7 += s18 * 470296;
-  s8 += s18 * 654183;
-  s9 -= s18 * 997805;
-  s10 += s18 * 136657;
-  s11 -= s18 * 683901;
-  s18 = 0;
-
-  carry6 = (s6 + (1<<20)) >> 21; s7 += carry6; s6 -= carry6 << 21;
-  carry8 = (s8 + (1<<20)) >> 21; s9 += carry8; s8 -= carry8 << 21;
-  carry10 = (s10 + (1<<20)) >> 21; s11 += carry10; s10 -= carry10 << 21;
-  carry12 = (s12 + (1<<20)) >> 21; s13 += carry12; s12 -= carry12 << 21;
-  carry14 = (s14 + (1<<20)) >> 21; s15 += carry14; s14 -= carry14 << 21;
-  carry16 = (s16 + (1<<20)) >> 21; s17 += carry16; s16 -= carry16 << 21;
-
-  carry7 = (s7 + (1<<20)) >> 21; s8 += carry7; s7 -= carry7 << 21;
-  carry9 = (s9 + (1<<20)) >> 21; s10 += carry9; s9 -= carry9 << 21;
-  carry11 = (s11 + (1<<20)) >> 21; s12 += carry11; s11 -= carry11 << 21;
-  carry13 = (s13 + (1<<20)) >> 21; s14 += carry13; s13 -= carry13 << 21;
-  carry15 = (s15 + (1<<20)) >> 21; s16 += carry15; s15 -= carry15 << 21;
-
-  s5 += s17 * 666643;
-  s6 += s17 * 470296;
-  s7 += s17 * 654183;
-  s8 -= s17 * 997805;
-  s9 += s17 * 136657;
-  s10 -= s17 * 683901;
-  s17 = 0;
-
-  s4 += s16 * 666643;
-  s5 += s16 * 470296;
-  s6 += s16 * 654183;
-  s7 -= s16 * 997805;
-  s8 += s16 * 136657;
-  s9 -= s16 * 683901;
-  s16 = 0;
-
-  s3 += s15 * 666643;
-  s4 += s15 * 470296;
-  s5 += s15 * 654183;
-  s6 -= s15 * 997805;
-  s7 += s15 * 136657;
-  s8 -= s15 * 683901;
-  s15 = 0;
-
-  s2 += s14 * 666643;
-  s3 += s14 * 470296;
-  s4 += s14 * 654183;
-  s5 -= s14 * 997805;
-  s6 += s14 * 136657;
-  s7 -= s14 * 683901;
-  s14 = 0;
-
-  s1 += s13 * 666643;
-  s2 += s13 * 470296;
-  s3 += s13 * 654183;
-  s4 -= s13 * 997805;
-  s5 += s13 * 136657;
-  s6 -= s13 * 683901;
-  s13 = 0;
-
-  s0 += s12 * 666643;
-  s1 += s12 * 470296;
-  s2 += s12 * 654183;
-  s3 -= s12 * 997805;
-  s4 += s12 * 136657;
-  s5 -= s12 * 683901;
-  s12 = 0;
-
-  carry0 = (s0 + (1<<20)) >> 21; s1 += carry0; s0 -= carry0 << 21;
-  carry2 = (s2 + (1<<20)) >> 21; s3 += carry2; s2 -= carry2 << 21;
-  carry4 = (s4 + (1<<20)) >> 21; s5 += carry4; s4 -= carry4 << 21;
-  carry6 = (s6 + (1<<20)) >> 21; s7 += carry6; s6 -= carry6 << 21;
-  carry8 = (s8 + (1<<20)) >> 21; s9 += carry8; s8 -= carry8 << 21;
-  carry10 = (s10 + (1<<20)) >> 21; s11 += carry10; s10 -= carry10 << 21;
-
-  carry1 = (s1 + (1<<20)) >> 21; s2 += carry1; s1 -= carry1 << 21;
-  carry3 = (s3 + (1<<20)) >> 21; s4 += carry3; s3 -= carry3 << 21;
-  carry5 = (s5 + (1<<20)) >> 21; s6 += carry5; s5 -= carry5 << 21;
-  carry7 = (s7 + (1<<20)) >> 21; s8 += carry7; s7 -= carry7 << 21;
-  carry9 = (s9 + (1<<20)) >> 21; s10 += carry9; s9 -= carry9 << 21;
-  carry11 = (s11 + (1<<20)) >> 21; s12 += carry11; s11 -= carry11 << 21;
-
-  s0 += s12 * 666643;
-  s1 += s12 * 470296;
-  s2 += s12 * 654183;
-  s3 -= s12 * 997805;
-  s4 += s12 * 136657;
-  s5 -= s12 * 683901;
-  s12 = 0;
-
-  carry0 = s0 >> 21; s1 += carry0; s0 -= carry0 << 21;
-  carry1 = s1 >> 21; s2 += carry1; s1 -= carry1 << 21;
-  carry2 = s2 >> 21; s3 += carry2; s2 -= carry2 << 21;
-  carry3 = s3 >> 21; s4 += carry3; s3 -= carry3 << 21;
-  carry4 = s4 >> 21; s5 += carry4; s4 -= carry4 << 21;
-  carry5 = s5 >> 21; s6 += carry5; s5 -= carry5 << 21;
-  carry6 = s6 >> 21; s7 += carry6; s6 -= carry6 << 21;
-  carry7 = s7 >> 21; s8 += carry7; s7 -= carry7 << 21;
-  carry8 = s8 >> 21; s9 += carry8; s8 -= carry8 << 21;
-  carry9 = s9 >> 21; s10 += carry9; s9 -= carry9 << 21;
-  carry10 = s10 >> 21; s11 += carry10; s10 -= carry10 << 21;
-  carry11 = s11 >> 21; s12 += carry11; s11 -= carry11 << 21;
-
-  s0 += s12 * 666643;
-  s1 += s12 * 470296;
-  s2 += s12 * 654183;
-  s3 -= s12 * 997805;
-  s4 += s12 * 136657;
-  s5 -= s12 * 683901;
-  s12 = 0;
-
-  carry0 = s0 >> 21; s1 += carry0; s0 -= carry0 << 21;
-  carry1 = s1 >> 21; s2 += carry1; s1 -= carry1 << 21;
-  carry2 = s2 >> 21; s3 += carry2; s2 -= carry2 << 21;
-  carry3 = s3 >> 21; s4 += carry3; s3 -= carry3 << 21;
-  carry4 = s4 >> 21; s5 += carry4; s4 -= carry4 << 21;
-  carry5 = s5 >> 21; s6 += carry5; s5 -= carry5 << 21;
-  carry6 = s6 >> 21; s7 += carry6; s6 -= carry6 << 21;
-  carry7 = s7 >> 21; s8 += carry7; s7 -= carry7 << 21;
-  carry8 = s8 >> 21; s9 += carry8; s8 -= carry8 << 21;
-  carry9 = s9 >> 21; s10 += carry9; s9 -= carry9 << 21;
-  carry10 = s10 >> 21; s11 += carry10; s10 -= carry10 << 21;
-
-  s[0] = s0 >> 0;
-  s[1] = s0 >> 8;
-  s[2] = (s0 >> 16) | (s1 << 5);
-  s[3] = s1 >> 3;
-  s[4] = s1 >> 11;
-  s[5] = (s1 >> 19) | (s2 << 2);
-  s[6] = s2 >> 6;
-  s[7] = (s2 >> 14) | (s3 << 7);
-  s[8] = s3 >> 1;
-  s[9] = s3 >> 9;
-  s[10] = (s3 >> 17) | (s4 << 4);
-  s[11] = s4 >> 4;
-  s[12] = s4 >> 12;
-  s[13] = (s4 >> 20) | (s5 << 1);
-  s[14] = s5 >> 7;
-  s[15] = (s5 >> 15) | (s6 << 6);
-  s[16] = s6 >> 2;
-  s[17] = s6 >> 10;
-  s[18] = (s6 >> 18) | (s7 << 3);
-  s[19] = s7 >> 5;
-  s[20] = s7 >> 13;
-  s[21] = s8 >> 0;
-  s[22] = s8 >> 8;
-  s[23] = (s8 >> 16) | (s9 << 5);
-  s[24] = s9 >> 3;
-  s[25] = s9 >> 11;
-  s[26] = (s9 >> 19) | (s10 << 2);
-  s[27] = s10 >> 6;
-  s[28] = (s10 >> 14) | (s11 << 7);
-  s[29] = s11 >> 1;
-  s[30] = s11 >> 9;
-  s[31] = s11 >> 17;
-
-  /* hush warnings after setting values to 0 */
-  (void)s12;
-  (void)s13;
-  (void)s14;
-  (void)s15;
-  (void)s16;
-  (void)s17;
-  (void)s18;
-  (void)s19;
-  (void)s20;
-  (void)s21;
-  (void)s22;
-  (void)s23;
-}
-
-
-int ge_compress_key(byte* out, const byte* xIn, const byte* yIn, word32 keySz)
-{
-    fe     x,y,z;
-    ge_p3  g;
-    byte   bArray[keySz];
-    word32 i;
-
-    fe_0(x);
-    fe_0(y);
-    fe_1(z);
-    fe_frombytes(x, xIn);
-    fe_frombytes(y, yIn);
-
-    fe_copy(g.X, x);
-    fe_copy(g.Y, y);
-    fe_copy(g.Z, z);
-
-    ge_p3_tobytes(bArray, &g);
-
-    for (i = 0; i < keySz; i++) {
-        out[keySz - 1 - i] = bArray[i];
-    }
-
-    return 0;
-}
-
-
-/*
-r = p + q
-*/
-void ge_add(ge_p1p1 *r,const ge_p3 *p,const ge_cached *q)
-{
-	fe t0;
-	fe_add(r->X,p->Y,p->X);
-	fe_sub(r->Y,p->Y,p->X);
-	fe_mul(r->Z,r->X,q->YplusX);
-	fe_mul(r->Y,r->Y,q->YminusX);
-	fe_mul(r->T,q->T2d,p->T);
-	fe_mul(r->X,p->Z,q->Z);
-	fe_add(t0,r->X,r->X);
-	fe_sub(r->X,r->Z,r->Y);
-	fe_add(r->Y,r->Z,r->Y);
-	fe_add(r->Z,t0,r->T);
-	fe_sub(r->T,t0,r->T);
-}
-
-
-/* ge_scalar mult base */
-static unsigned char equal(signed char b,signed char c)
-{
-  unsigned char ub = b;
-  unsigned char uc = c;
-  unsigned char x = ub ^ uc; /* 0: yes; 1..255: no */
-  uint32_t y = x; /* 0: yes; 1..255: no */
-  y -= 1; /* 4294967295: yes; 0..254: no */
-  y >>= 31; /* 1: yes; 0: no */
-  return y;
-}
-
-
-static unsigned char negative(signed char b)
-{
-  unsigned long long x = b; /* 18446744073709551361..18446744073709551615:
-                               yes; 0..255: no */
-  x >>= 63; /* 1: yes; 0: no */
-  return x;
-}
-
-
-static void cmov(ge_precomp *t,ge_precomp *u,unsigned char b)
-{
-  fe_cmov(t->yplusx,u->yplusx,b);
-  fe_cmov(t->yminusx,u->yminusx,b);
-  fe_cmov(t->xy2d,u->xy2d,b);
-}
-
-
-/* base[i][j] = (j+1)*256^i*B */
-static ge_precomp base[32][8] = {
-{
- {
-  { 25967493,-14356035,29566456,3660896,-12694345,4014787,27544626,-11754271,-6079156,2047605 },
-  { -12545711,934262,-2722910,3049990,-727428,9406986,12720692,5043384,19500929,-15469378 },
-  { -8738181,4489570,9688441,-14785194,10184609,-12363380,29287919,11864899,-24514362,-4438546 },
- },
- {
-  { -12815894,-12976347,-21581243,11784320,-25355658,-2750717,-11717903,-3814571,-358445,-10211303 },
-  { -21703237,6903825,27185491,6451973,-29577724,-9554005,-15616551,11189268,-26829678,-5319081 },
-  { 26966642,11152617,32442495,15396054,14353839,-12752335,-3128826,-9541118,-15472047,-4166697 },
- },
- {
-  { 15636291,-9688557,24204773,-7912398,616977,-16685262,27787600,-14772189,28944400,-1550024 },
-  { 16568933,4717097,-11556148,-1102322,15682896,-11807043,16354577,-11775962,7689662,11199574 },
-  { 30464156,-5976125,-11779434,-15670865,23220365,15915852,7512774,10017326,-17749093,-9920357 },
- },
- {
-  { -17036878,13921892,10945806,-6033431,27105052,-16084379,-28926210,15006023,3284568,-6276540 },
-  { 23599295,-8306047,-11193664,-7687416,13236774,10506355,7464579,9656445,13059162,10374397 },
-  { 7798556,16710257,3033922,2874086,28997861,2835604,32406664,-3839045,-641708,-101325 },
- },
- {
-  { 10861363,11473154,27284546,1981175,-30064349,12577861,32867885,14515107,-15438304,10819380 },
-  { 4708026,6336745,20377586,9066809,-11272109,6594696,-25653668,12483688,-12668491,5581306 },
-  { 19563160,16186464,-29386857,4097519,10237984,-4348115,28542350,13850243,-23678021,-15815942 },
- },
- {
-  { -15371964,-12862754,32573250,4720197,-26436522,5875511,-19188627,-15224819,-9818940,-12085777 },
-  { -8549212,109983,15149363,2178705,22900618,4543417,3044240,-15689887,1762328,14866737 },
-  { -18199695,-15951423,-10473290,1707278,-17185920,3916101,-28236412,3959421,27914454,4383652 },
- },
- {
-  { 5153746,9909285,1723747,-2777874,30523605,5516873,19480852,5230134,-23952439,-15175766 },
-  { -30269007,-3463509,7665486,10083793,28475525,1649722,20654025,16520125,30598449,7715701 },
-  { 28881845,14381568,9657904,3680757,-20181635,7843316,-31400660,1370708,29794553,-1409300 },
- },
- {
-  { 14499471,-2729599,-33191113,-4254652,28494862,14271267,30290735,10876454,-33154098,2381726 },
-  { -7195431,-2655363,-14730155,462251,-27724326,3941372,-6236617,3696005,-32300832,15351955 },
-  { 27431194,8222322,16448760,-3907995,-18707002,11938355,-32961401,-2970515,29551813,10109425 },
- },
-},
-{
- {
-  { -13657040,-13155431,-31283750,11777098,21447386,6519384,-2378284,-1627556,10092783,-4764171 },
-  { 27939166,14210322,4677035,16277044,-22964462,-12398139,-32508754,12005538,-17810127,12803510 },
-  { 17228999,-15661624,-1233527,300140,-1224870,-11714777,30364213,-9038194,18016357,4397660 },
- },
- {
-  { -10958843,-7690207,4776341,-14954238,27850028,-15602212,-26619106,14544525,-17477504,982639 },
-  { 29253598,15796703,-2863982,-9908884,10057023,3163536,7332899,-4120128,-21047696,9934963 },
-  { 5793303,16271923,-24131614,-10116404,29188560,1206517,-14747930,4559895,-30123922,-10897950 },
- },
- {
-  { -27643952,-11493006,16282657,-11036493,28414021,-15012264,24191034,4541697,-13338309,5500568 },
-  { 12650548,-1497113,9052871,11355358,-17680037,-8400164,-17430592,12264343,10874051,13524335 },
-  { 25556948,-3045990,714651,2510400,23394682,-10415330,33119038,5080568,-22528059,5376628 },
- },
- {
-  { -26088264,-4011052,-17013699,-3537628,-6726793,1920897,-22321305,-9447443,4535768,1569007 },
-  { -2255422,14606630,-21692440,-8039818,28430649,8775819,-30494562,3044290,31848280,12543772 },
-  { -22028579,2943893,-31857513,6777306,13784462,-4292203,-27377195,-2062731,7718482,14474653 },
- },
- {
-  { 2385315,2454213,-22631320,46603,-4437935,-15680415,656965,-7236665,24316168,-5253567 },
-  { 13741529,10911568,-33233417,-8603737,-20177830,-1033297,33040651,-13424532,-20729456,8321686 },
-  { 21060490,-2212744,15712757,-4336099,1639040,10656336,23845965,-11874838,-9984458,608372 },
- },
- {
-  { -13672732,-15087586,-10889693,-7557059,-6036909,11305547,1123968,-6780577,27229399,23887 },
-  { -23244140,-294205,-11744728,14712571,-29465699,-2029617,12797024,-6440308,-1633405,16678954 },
-  { -29500620,4770662,-16054387,14001338,7830047,9564805,-1508144,-4795045,-17169265,4904953 },
- },
- {
-  { 24059557,14617003,19037157,-15039908,19766093,-14906429,5169211,16191880,2128236,-4326833 },
-  { -16981152,4124966,-8540610,-10653797,30336522,-14105247,-29806336,916033,-6882542,-2986532 },
-  { -22630907,12419372,-7134229,-7473371,-16478904,16739175,285431,2763829,15736322,4143876 },
- },
- {
-  { 2379352,11839345,-4110402,-5988665,11274298,794957,212801,-14594663,23527084,-16458268 },
-  { 33431127,-11130478,-17838966,-15626900,8909499,8376530,-32625340,4087881,-15188911,-14416214 },
-  { 1767683,7197987,-13205226,-2022635,-13091350,448826,5799055,4357868,-4774191,-16323038 },
- },
-},
-{
- {
-  { 6721966,13833823,-23523388,-1551314,26354293,-11863321,23365147,-3949732,7390890,2759800 },
-  { 4409041,2052381,23373853,10530217,7676779,-12885954,21302353,-4264057,1244380,-12919645 },
-  { -4421239,7169619,4982368,-2957590,30256825,-2777540,14086413,9208236,15886429,16489664 },
- },
- {
-  { 1996075,10375649,14346367,13311202,-6874135,-16438411,-13693198,398369,-30606455,-712933 },
-  { -25307465,9795880,-2777414,14878809,-33531835,14780363,13348553,12076947,-30836462,5113182 },
-  { -17770784,11797796,31950843,13929123,-25888302,12288344,-30341101,-7336386,13847711,5387222 },
- },
- {
-  { -18582163,-3416217,17824843,-2340966,22744343,-10442611,8763061,3617786,-19600662,10370991 },
-  { 20246567,-14369378,22358229,-543712,18507283,-10413996,14554437,-8746092,32232924,16763880 },
-  { 9648505,10094563,26416693,14745928,-30374318,-6472621,11094161,15689506,3140038,-16510092 },
- },
- {
-  { -16160072,5472695,31895588,4744994,8823515,10365685,-27224800,9448613,-28774454,366295 },
-  { 19153450,11523972,-11096490,-6503142,-24647631,5420647,28344573,8041113,719605,11671788 },
-  { 8678025,2694440,-6808014,2517372,4964326,11152271,-15432916,-15266516,27000813,-10195553 },
- },
- {
-  { -15157904,7134312,8639287,-2814877,-7235688,10421742,564065,5336097,6750977,-14521026 },
-  { 11836410,-3979488,26297894,16080799,23455045,15735944,1695823,-8819122,8169720,16220347 },
-  { -18115838,8653647,17578566,-6092619,-8025777,-16012763,-11144307,-2627664,-5990708,-14166033 },
- },
- {
-  { -23308498,-10968312,15213228,-10081214,-30853605,-11050004,27884329,2847284,2655861,1738395 },
-  { -27537433,-14253021,-25336301,-8002780,-9370762,8129821,21651608,-3239336,-19087449,-11005278 },
-  { 1533110,3437855,23735889,459276,29970501,11335377,26030092,5821408,10478196,8544890 },
- },
- {
-  { 32173121,-16129311,24896207,3921497,22579056,-3410854,19270449,12217473,17789017,-3395995 },
-  { -30552961,-2228401,-15578829,-10147201,13243889,517024,15479401,-3853233,30460520,1052596 },
-  { -11614875,13323618,32618793,8175907,-15230173,12596687,27491595,-4612359,3179268,-9478891 },
- },
- {
-  { 31947069,-14366651,-4640583,-15339921,-15125977,-6039709,-14756777,-16411740,19072640,-9511060 },
-  { 11685058,11822410,3158003,-13952594,33402194,-4165066,5977896,-5215017,473099,5040608 },
-  { -20290863,8198642,-27410132,11602123,1290375,-2799760,28326862,1721092,-19558642,-3131606 },
- },
-},
-{
- {
-  { 7881532,10687937,7578723,7738378,-18951012,-2553952,21820786,8076149,-27868496,11538389 },
-  { -19935666,3899861,18283497,-6801568,-15728660,-11249211,8754525,7446702,-5676054,5797016 },
-  { -11295600,-3793569,-15782110,-7964573,12708869,-8456199,2014099,-9050574,-2369172,-5877341 },
- },
- {
-  { -22472376,-11568741,-27682020,1146375,18956691,16640559,1192730,-3714199,15123619,10811505 },
-  { 14352098,-3419715,-18942044,10822655,32750596,4699007,-70363,15776356,-28886779,-11974553 },
-  { -28241164,-8072475,-4978962,-5315317,29416931,1847569,-20654173,-16484855,4714547,-9600655 },
- },
- {
-  { 15200332,8368572,19679101,15970074,-31872674,1959451,24611599,-4543832,-11745876,12340220 },
-  { 12876937,-10480056,33134381,6590940,-6307776,14872440,9613953,8241152,15370987,9608631 },
-  { -4143277,-12014408,8446281,-391603,4407738,13629032,-7724868,15866074,-28210621,-8814099 },
- },
- {
-  { 26660628,-15677655,8393734,358047,-7401291,992988,-23904233,858697,20571223,8420556 },
-  { 14620715,13067227,-15447274,8264467,14106269,15080814,33531827,12516406,-21574435,-12476749 },
-  { 236881,10476226,57258,-14677024,6472998,2466984,17258519,7256740,8791136,15069930 },
- },
- {
-  { 1276410,-9371918,22949635,-16322807,-23493039,-5702186,14711875,4874229,-30663140,-2331391 },
-  { 5855666,4990204,-13711848,7294284,-7804282,1924647,-1423175,-7912378,-33069337,9234253 },
-  { 20590503,-9018988,31529744,-7352666,-2706834,10650548,31559055,-11609587,18979186,13396066 },
- },
- {
-  { 24474287,4968103,22267082,4407354,24063882,-8325180,-18816887,13594782,33514650,7021958 },
-  { -11566906,-6565505,-21365085,15928892,-26158305,4315421,-25948728,-3916677,-21480480,12868082 },
-  { -28635013,13504661,19988037,-2132761,21078225,6443208,-21446107,2244500,-12455797,-8089383 },
- },
- {
-  { -30595528,13793479,-5852820,319136,-25723172,-6263899,33086546,8957937,-15233648,5540521 },
-  { -11630176,-11503902,-8119500,-7643073,2620056,1022908,-23710744,-1568984,-16128528,-14962807 },
-  { 23152971,775386,27395463,14006635,-9701118,4649512,1689819,892185,-11513277,-15205948 },
- },
- {
-  { 9770129,9586738,26496094,4324120,1556511,-3550024,27453819,4763127,-19179614,5867134 },
-  { -32765025,1927590,31726409,-4753295,23962434,-16019500,27846559,5931263,-29749703,-16108455 },
-  { 27461885,-2977536,22380810,1815854,-23033753,-3031938,7283490,-15148073,-19526700,7734629 },
- },
-},
-{
- {
-  { -8010264,-9590817,-11120403,6196038,29344158,-13430885,7585295,-3176626,18549497,15302069 },
-  { -32658337,-6171222,-7672793,-11051681,6258878,13504381,10458790,-6418461,-8872242,8424746 },
-  { 24687205,8613276,-30667046,-3233545,1863892,-1830544,19206234,7134917,-11284482,-828919 },
- },
- {
-  { 11334899,-9218022,8025293,12707519,17523892,-10476071,10243738,-14685461,-5066034,16498837 },
-  { 8911542,6887158,-9584260,-6958590,11145641,-9543680,17303925,-14124238,6536641,10543906 },
-  { -28946384,15479763,-17466835,568876,-1497683,11223454,-2669190,-16625574,-27235709,8876771 },
- },
- {
-  { -25742899,-12566864,-15649966,-846607,-33026686,-796288,-33481822,15824474,-604426,-9039817 },
-  { 10330056,70051,7957388,-9002667,9764902,15609756,27698697,-4890037,1657394,3084098 },
-  { 10477963,-7470260,12119566,-13250805,29016247,-5365589,31280319,14396151,-30233575,15272409 },
- },
- {
-  { -12288309,3169463,28813183,16658753,25116432,-5630466,-25173957,-12636138,-25014757,1950504 },
-  { -26180358,9489187,11053416,-14746161,-31053720,5825630,-8384306,-8767532,15341279,8373727 },
-  { 28685821,7759505,-14378516,-12002860,-31971820,4079242,298136,-10232602,-2878207,15190420 },
- },
- {
-  { -32932876,13806336,-14337485,-15794431,-24004620,10940928,8669718,2742393,-26033313,-6875003 },
-  { -1580388,-11729417,-25979658,-11445023,-17411874,-10912854,9291594,-16247779,-12154742,6048605 },
-  { -30305315,14843444,1539301,11864366,20201677,1900163,13934231,5128323,11213262,9168384 },
- },
- {
-  { -26280513,11007847,19408960,-940758,-18592965,-4328580,-5088060,-11105150,20470157,-16398701 },
-  { -23136053,9282192,14855179,-15390078,-7362815,-14408560,-22783952,14461608,14042978,5230683 },
-  { 29969567,-2741594,-16711867,-8552442,9175486,-2468974,21556951,3506042,-5933891,-12449708 },
- },
- {
-  { -3144746,8744661,19704003,4581278,-20430686,6830683,-21284170,8971513,-28539189,15326563 },
-  { -19464629,10110288,-17262528,-3503892,-23500387,1355669,-15523050,15300988,-20514118,9168260 },
-  { -5353335,4488613,-23803248,16314347,7780487,-15638939,-28948358,9601605,33087103,-9011387 },
- },
- {
-  { -19443170,-15512900,-20797467,-12445323,-29824447,10229461,-27444329,-15000531,-5996870,15664672 },
-  { 23294591,-16632613,-22650781,-8470978,27844204,11461195,13099750,-2460356,18151676,13417686 },
-  { -24722913,-4176517,-31150679,5988919,-26858785,6685065,1661597,-12551441,15271676,-15452665 },
- },
-},
-{
- {
-  { 11433042,-13228665,8239631,-5279517,-1985436,-725718,-18698764,2167544,-6921301,-13440182 },
-  { -31436171,15575146,30436815,12192228,-22463353,9395379,-9917708,-8638997,12215110,12028277 },
-  { 14098400,6555944,23007258,5757252,-15427832,-12950502,30123440,4617780,-16900089,-655628 },
- },
- {
-  { -4026201,-15240835,11893168,13718664,-14809462,1847385,-15819999,10154009,23973261,-12684474 },
-  { -26531820,-3695990,-1908898,2534301,-31870557,-16550355,18341390,-11419951,32013174,-10103539 },
-  { -25479301,10876443,-11771086,-14625140,-12369567,1838104,21911214,6354752,4425632,-837822 },
- },
- {
-  { -10433389,-14612966,22229858,-3091047,-13191166,776729,-17415375,-12020462,4725005,14044970 },
-  { 19268650,-7304421,1555349,8692754,-21474059,-9910664,6347390,-1411784,-19522291,-16109756 },
-  { -24864089,12986008,-10898878,-5558584,-11312371,-148526,19541418,8180106,9282262,10282508 },
- },
- {
-  { -26205082,4428547,-8661196,-13194263,4098402,-14165257,15522535,8372215,5542595,-10702683 },
-  { -10562541,14895633,26814552,-16673850,-17480754,-2489360,-2781891,6993761,-18093885,10114655 },
-  { -20107055,-929418,31422704,10427861,-7110749,6150669,-29091755,-11529146,25953725,-106158 },
- },
- {
-  { -4234397,-8039292,-9119125,3046000,2101609,-12607294,19390020,6094296,-3315279,12831125 },
-  { -15998678,7578152,5310217,14408357,-33548620,-224739,31575954,6326196,7381791,-2421839 },
-  { -20902779,3296811,24736065,-16328389,18374254,7318640,6295303,8082724,-15362489,12339664 },
- },
- {
-  { 27724736,2291157,6088201,-14184798,1792727,5857634,13848414,15768922,25091167,14856294 },
-  { -18866652,8331043,24373479,8541013,-701998,-9269457,12927300,-12695493,-22182473,-9012899 },
-  { -11423429,-5421590,11632845,3405020,30536730,-11674039,-27260765,13866390,30146206,9142070 },
- },
- {
-  { 3924129,-15307516,-13817122,-10054960,12291820,-668366,-27702774,9326384,-8237858,4171294 },
-  { -15921940,16037937,6713787,16606682,-21612135,2790944,26396185,3731949,345228,-5462949 },
-  { -21327538,13448259,25284571,1143661,20614966,-8849387,2031539,-12391231,-16253183,-13582083 },
- },
- {
-  { 31016211,-16722429,26371392,-14451233,-5027349,14854137,17477601,3842657,28012650,-16405420 },
-  { -5075835,9368966,-8562079,-4600902,-15249953,6970560,-9189873,16292057,-8867157,3507940 },
-  { 29439664,3537914,23333589,6997794,-17555561,-11018068,-15209202,-15051267,-9164929,6580396 },
- },
-},
-{
- {
-  { -12185861,-7679788,16438269,10826160,-8696817,-6235611,17860444,-9273846,-2095802,9304567 },
-  { 20714564,-4336911,29088195,7406487,11426967,-5095705,14792667,-14608617,5289421,-477127 },
-  { -16665533,-10650790,-6160345,-13305760,9192020,-1802462,17271490,12349094,26939669,-3752294 },
- },
- {
-  { -12889898,9373458,31595848,16374215,21471720,13221525,-27283495,-12348559,-3698806,117887 },
-  { 22263325,-6560050,3984570,-11174646,-15114008,-566785,28311253,5358056,-23319780,541964 },
-  { 16259219,3261970,2309254,-15534474,-16885711,-4581916,24134070,-16705829,-13337066,-13552195 },
- },
- {
-  { 9378160,-13140186,-22845982,-12745264,28198281,-7244098,-2399684,-717351,690426,14876244 },
-  { 24977353,-314384,-8223969,-13465086,28432343,-1176353,-13068804,-12297348,-22380984,6618999 },
-  { -1538174,11685646,12944378,13682314,-24389511,-14413193,8044829,-13817328,32239829,-5652762 },
- },
- {
-  { -18603066,4762990,-926250,8885304,-28412480,-3187315,9781647,-10350059,32779359,5095274 },
-  { -33008130,-5214506,-32264887,-3685216,9460461,-9327423,-24601656,14506724,21639561,-2630236 },
-  { -16400943,-13112215,25239338,15531969,3987758,-4499318,-1289502,-6863535,17874574,558605 },
- },
- {
-  { -13600129,10240081,9171883,16131053,-20869254,9599700,33499487,5080151,2085892,5119761 },
-  { -22205145,-2519528,-16381601,414691,-25019550,2170430,30634760,-8363614,-31999993,-5759884 },
-  { -6845704,15791202,8550074,-1312654,29928809,-12092256,27534430,-7192145,-22351378,12961482 },
- },
- {
-  { -24492060,-9570771,10368194,11582341,-23397293,-2245287,16533930,8206996,-30194652,-5159638 },
-  { -11121496,-3382234,2307366,6362031,-135455,8868177,-16835630,7031275,7589640,8945490 },
-  { -32152748,8917967,6661220,-11677616,-1192060,-15793393,7251489,-11182180,24099109,-14456170 },
- },
- {
-  { 5019558,-7907470,4244127,-14714356,-26933272,6453165,-19118182,-13289025,-6231896,-10280736 },
-  { 10853594,10721687,26480089,5861829,-22995819,1972175,-1866647,-10557898,-3363451,-6441124 },
-  { -17002408,5906790,221599,-6563147,7828208,-13248918,24362661,-2008168,-13866408,7421392 },
- },
- {
-  { 8139927,-6546497,32257646,-5890546,30375719,1886181,-21175108,15441252,28826358,-4123029 },
-  { 6267086,9695052,7709135,-16603597,-32869068,-1886135,14795160,-7840124,13746021,-1742048 },
-  { 28584902,7787108,-6732942,-15050729,22846041,-7571236,-3181936,-363524,4771362,-8419958 },
- },
-},
-{
- {
-  { 24949256,6376279,-27466481,-8174608,-18646154,-9930606,33543569,-12141695,3569627,11342593 },
-  { 26514989,4740088,27912651,3697550,19331575,-11472339,6809886,4608608,7325975,-14801071 },
-  { -11618399,-14554430,-24321212,7655128,-1369274,5214312,-27400540,10258390,-17646694,-8186692 },
- },
- {
-  { 11431204,15823007,26570245,14329124,18029990,4796082,-31446179,15580664,9280358,-3973687 },
-  { -160783,-10326257,-22855316,-4304997,-20861367,-13621002,-32810901,-11181622,-15545091,4387441 },
-  { -20799378,12194512,3937617,-5805892,-27154820,9340370,-24513992,8548137,20617071,-7482001 },
- },
- {
-  { -938825,-3930586,-8714311,16124718,24603125,-6225393,-13775352,-11875822,24345683,10325460 },
-  { -19855277,-1568885,-22202708,8714034,14007766,6928528,16318175,-1010689,4766743,3552007 },
-  { -21751364,-16730916,1351763,-803421,-4009670,3950935,3217514,14481909,10988822,-3994762 },
- },
- {
-  { 15564307,-14311570,3101243,5684148,30446780,-8051356,12677127,-6505343,-8295852,13296005 },
-  { -9442290,6624296,-30298964,-11913677,-4670981,-2057379,31521204,9614054,-30000824,12074674 },
-  { 4771191,-135239,14290749,-13089852,27992298,14998318,-1413936,-1556716,29832613,-16391035 },
- },
- {
-  { 7064884,-7541174,-19161962,-5067537,-18891269,-2912736,25825242,5293297,-27122660,13101590 },
-  { -2298563,2439670,-7466610,1719965,-27267541,-16328445,32512469,-5317593,-30356070,-4190957 },
-  { -30006540,10162316,-33180176,3981723,-16482138,-13070044,14413974,9515896,19568978,9628812 },
- },
- {
-  { 33053803,199357,15894591,1583059,27380243,-4580435,-17838894,-6106839,-6291786,3437740 },
-  { -18978877,3884493,19469877,12726490,15913552,13614290,-22961733,70104,7463304,4176122 },
-  { -27124001,10659917,11482427,-16070381,12771467,-6635117,-32719404,-5322751,24216882,5944158 },
- },
- {
-  { 8894125,7450974,-2664149,-9765752,-28080517,-12389115,19345746,14680796,11632993,5847885 },
-  { 26942781,-2315317,9129564,-4906607,26024105,11769399,-11518837,6367194,-9727230,4782140 },
-  { 19916461,-4828410,-22910704,-11414391,25606324,-5972441,33253853,8220911,6358847,-1873857 },
- },
- {
-  { 801428,-2081702,16569428,11065167,29875704,96627,7908388,-4480480,-13538503,1387155 },
-  { 19646058,5720633,-11416706,12814209,11607948,12749789,14147075,15156355,-21866831,11835260 },
-  { 19299512,1155910,28703737,14890794,2925026,7269399,26121523,15467869,-26560550,5052483 },
- },
-},
-{
- {
-  { -3017432,10058206,1980837,3964243,22160966,12322533,-6431123,-12618185,12228557,-7003677 },
-  { 32944382,14922211,-22844894,5188528,21913450,-8719943,4001465,13238564,-6114803,8653815 },
-  { 22865569,-4652735,27603668,-12545395,14348958,8234005,24808405,5719875,28483275,2841751 },
- },
- {
-  { -16420968,-1113305,-327719,-12107856,21886282,-15552774,-1887966,-315658,19932058,-12739203 },
-  { -11656086,10087521,-8864888,-5536143,-19278573,-3055912,3999228,13239134,-4777469,-13910208 },
-  { 1382174,-11694719,17266790,9194690,-13324356,9720081,20403944,11284705,-14013818,3093230 },
- },
- {
-  { 16650921,-11037932,-1064178,1570629,-8329746,7352753,-302424,16271225,-24049421,-6691850 },
-  { -21911077,-5927941,-4611316,-5560156,-31744103,-10785293,24123614,15193618,-21652117,-16739389 },
-  { -9935934,-4289447,-25279823,4372842,2087473,10399484,31870908,14690798,17361620,11864968 },
- },
- {
-  { -11307610,6210372,13206574,5806320,-29017692,-13967200,-12331205,-7486601,-25578460,-16240689 },
-  { 14668462,-12270235,26039039,15305210,25515617,4542480,10453892,6577524,9145645,-6443880 },
-  { 5974874,3053895,-9433049,-10385191,-31865124,3225009,-7972642,3936128,-5652273,-3050304 },
- },
- {
-  { 30625386,-4729400,-25555961,-12792866,-20484575,7695099,17097188,-16303496,-27999779,1803632 },
-  { -3553091,9865099,-5228566,4272701,-5673832,-16689700,14911344,12196514,-21405489,7047412 },
-  { 20093277,9920966,-11138194,-5343857,13161587,12044805,-32856851,4124601,-32343828,-10257566 },
- },
- {
-  { -20788824,14084654,-13531713,7842147,19119038,-13822605,4752377,-8714640,-21679658,2288038 },
-  { -26819236,-3283715,29965059,3039786,-14473765,2540457,29457502,14625692,-24819617,12570232 },
-  { -1063558,-11551823,16920318,12494842,1278292,-5869109,-21159943,-3498680,-11974704,4724943 },
- },
- {
-  { 17960970,-11775534,-4140968,-9702530,-8876562,-1410617,-12907383,-8659932,-29576300,1903856 },
-  { 23134274,-14279132,-10681997,-1611936,20684485,15770816,-12989750,3190296,26955097,14109738 },
-  { 15308788,5320727,-30113809,-14318877,22902008,7767164,29425325,-11277562,31960942,11934971 },
- },
- {
-  { -27395711,8435796,4109644,12222639,-24627868,14818669,20638173,4875028,10491392,1379718 },
-  { -13159415,9197841,3875503,-8936108,-1383712,-5879801,33518459,16176658,21432314,12180697 },
-  { -11787308,11500838,13787581,-13832590,-22430679,10140205,1465425,12689540,-10301319,-13872883 },
- },
-},
-{
- {
-  { 5414091,-15386041,-21007664,9643570,12834970,1186149,-2622916,-1342231,26128231,6032912 },
-  { -26337395,-13766162,32496025,-13653919,17847801,-12669156,3604025,8316894,-25875034,-10437358 },
-  { 3296484,6223048,24680646,-12246460,-23052020,5903205,-8862297,-4639164,12376617,3188849 },
- },
- {
-  { 29190488,-14659046,27549113,-1183516,3520066,-10697301,32049515,-7309113,-16109234,-9852307 },
-  { -14744486,-9309156,735818,-598978,-20407687,-5057904,25246078,-15795669,18640741,-960977 },
-  { -6928835,-16430795,10361374,5642961,4910474,12345252,-31638386,-494430,10530747,1053335 },
- },
- {
-  { -29265967,-14186805,-13538216,-12117373,-19457059,-10655384,-31462369,-2948985,24018831,15026644 },
-  { -22592535,-3145277,-2289276,5953843,-13440189,9425631,25310643,13003497,-2314791,-15145616 },
-  { -27419985,-603321,-8043984,-1669117,-26092265,13987819,-27297622,187899,-23166419,-2531735 },
- },
- {
-  { -21744398,-13810475,1844840,5021428,-10434399,-15911473,9716667,16266922,-5070217,726099 },
-  { 29370922,-6053998,7334071,-15342259,9385287,2247707,-13661962,-4839461,30007388,-15823341 },
-  { -936379,16086691,23751945,-543318,-1167538,-5189036,9137109,730663,9835848,4555336 },
- },
- {
-  { -23376435,1410446,-22253753,-12899614,30867635,15826977,17693930,544696,-11985298,12422646 },
-  { 31117226,-12215734,-13502838,6561947,-9876867,-12757670,-5118685,-4096706,29120153,13924425 },
-  { -17400879,-14233209,19675799,-2734756,-11006962,-5858820,-9383939,-11317700,7240931,-237388 },
- },
- {
-  { -31361739,-11346780,-15007447,-5856218,-22453340,-12152771,1222336,4389483,3293637,-15551743 },
-  { -16684801,-14444245,11038544,11054958,-13801175,-3338533,-24319580,7733547,12796905,-6335822 },
-  { -8759414,-10817836,-25418864,10783769,-30615557,-9746811,-28253339,3647836,3222231,-11160462 },
- },
- {
-  { 18606113,1693100,-25448386,-15170272,4112353,10045021,23603893,-2048234,-7550776,2484985 },
-  { 9255317,-3131197,-12156162,-1004256,13098013,-9214866,16377220,-2102812,-19802075,-3034702 },
-  { -22729289,7496160,-5742199,11329249,19991973,-3347502,-31718148,9936966,-30097688,-10618797 },
- },
- {
-  { 21878590,-5001297,4338336,13643897,-3036865,13160960,19708896,5415497,-7360503,-4109293 },
-  { 27736861,10103576,12500508,8502413,-3413016,-9633558,10436918,-1550276,-23659143,-8132100 },
-  { 19492550,-12104365,-29681976,-852630,-3208171,12403437,30066266,8367329,13243957,8709688 },
- },
-},
-{
- {
-  { 12015105,2801261,28198131,10151021,24818120,-4743133,-11194191,-5645734,5150968,7274186 },
-  { 2831366,-12492146,1478975,6122054,23825128,-12733586,31097299,6083058,31021603,-9793610 },
-  { -2529932,-2229646,445613,10720828,-13849527,-11505937,-23507731,16354465,15067285,-14147707 },
- },
- {
-  { 7840942,14037873,-33364863,15934016,-728213,-3642706,21403988,1057586,-19379462,-12403220 },
-  { 915865,-16469274,15608285,-8789130,-24357026,6060030,-17371319,8410997,-7220461,16527025 },
-  { 32922597,-556987,20336074,-16184568,10903705,-5384487,16957574,52992,23834301,6588044 },
- },
- {
-  { 32752030,11232950,3381995,-8714866,22652988,-10744103,17159699,16689107,-20314580,-1305992 },
-  { -4689649,9166776,-25710296,-10847306,11576752,12733943,7924251,-2752281,1976123,-7249027 },
-  { 21251222,16309901,-2983015,-6783122,30810597,12967303,156041,-3371252,12331345,-8237197 },
- },
- {
-  { 8651614,-4477032,-16085636,-4996994,13002507,2950805,29054427,-5106970,10008136,-4667901 },
-  { 31486080,15114593,-14261250,12951354,14369431,-7387845,16347321,-13662089,8684155,-10532952 },
-  { 19443825,11385320,24468943,-9659068,-23919258,2187569,-26263207,-6086921,31316348,14219878 },
- },
- {
-  { -28594490,1193785,32245219,11392485,31092169,15722801,27146014,6992409,29126555,9207390 },
-  { 32382935,1110093,18477781,11028262,-27411763,-7548111,-4980517,10843782,-7957600,-14435730 },
-  { 2814918,7836403,27519878,-7868156,-20894015,-11553689,-21494559,8550130,28346258,1994730 },
- },
- {
-  { -19578299,8085545,-14000519,-3948622,2785838,-16231307,-19516951,7174894,22628102,8115180 },
-  { -30405132,955511,-11133838,-15078069,-32447087,-13278079,-25651578,3317160,-9943017,930272 },
-  { -15303681,-6833769,28856490,1357446,23421993,1057177,24091212,-1388970,-22765376,-10650715 },
- },
- {
-  { -22751231,-5303997,-12907607,-12768866,-15811511,-7797053,-14839018,-16554220,-1867018,8398970 },
-  { -31969310,2106403,-4736360,1362501,12813763,16200670,22981545,-6291273,18009408,-15772772 },
-  { -17220923,-9545221,-27784654,14166835,29815394,7444469,29551787,-3727419,19288549,1325865 },
- },
- {
-  { 15100157,-15835752,-23923978,-1005098,-26450192,15509408,12376730,-3479146,33166107,-8042750 },
-  { 20909231,13023121,-9209752,16251778,-5778415,-8094914,12412151,10018715,2213263,-13878373 },
-  { 32529814,-11074689,30361439,-16689753,-9135940,1513226,22922121,6382134,-5766928,8371348 },
- },
-},
-{
- {
-  { 9923462,11271500,12616794,3544722,-29998368,-1721626,12891687,-8193132,-26442943,10486144 },
-  { -22597207,-7012665,8587003,-8257861,4084309,-12970062,361726,2610596,-23921530,-11455195 },
-  { 5408411,-1136691,-4969122,10561668,24145918,14240566,31319731,-4235541,19985175,-3436086 },
- },
- {
-  { -13994457,16616821,14549246,3341099,32155958,13648976,-17577068,8849297,65030,8370684 },
-  { -8320926,-12049626,31204563,5839400,-20627288,-1057277,-19442942,6922164,12743482,-9800518 },
-  { -2361371,12678785,28815050,4759974,-23893047,4884717,23783145,11038569,18800704,255233 },
- },
- {
-  { -5269658,-1773886,13957886,7990715,23132995,728773,13393847,9066957,19258688,-14753793 },
-  { -2936654,-10827535,-10432089,14516793,-3640786,4372541,-31934921,2209390,-1524053,2055794 },
-  { 580882,16705327,5468415,-2683018,-30926419,-14696000,-7203346,-8994389,-30021019,7394435 },
- },
- {
-  { 23838809,1822728,-15738443,15242727,8318092,-3733104,-21672180,-3492205,-4821741,14799921 },
-  { 13345610,9759151,3371034,-16137791,16353039,8577942,31129804,13496856,-9056018,7402518 },
-  { 2286874,-4435931,-20042458,-2008336,-13696227,5038122,11006906,-15760352,8205061,1607563 },
- },
- {
-  { 14414086,-8002132,3331830,-3208217,22249151,-5594188,18364661,-2906958,30019587,-9029278 },
-  { -27688051,1585953,-10775053,931069,-29120221,-11002319,-14410829,12029093,9944378,8024 },
-  { 4368715,-3709630,29874200,-15022983,-20230386,-11410704,-16114594,-999085,-8142388,5640030 },
- },
- {
-  { 10299610,13746483,11661824,16234854,7630238,5998374,9809887,-16694564,15219798,-14327783 },
-  { 27425505,-5719081,3055006,10660664,23458024,595578,-15398605,-1173195,-18342183,9742717 },
-  { 6744077,2427284,26042789,2720740,-847906,1118974,32324614,7406442,12420155,1994844 },
- },
- {
-  { 14012521,-5024720,-18384453,-9578469,-26485342,-3936439,-13033478,-10909803,24319929,-6446333 },
-  { 16412690,-4507367,10772641,15929391,-17068788,-4658621,10555945,-10484049,-30102368,-4739048 },
-  { 22397382,-7767684,-9293161,-12792868,17166287,-9755136,-27333065,6199366,21880021,-12250760 },
- },
- {
-  { -4283307,5368523,-31117018,8163389,-30323063,3209128,16557151,8890729,8840445,4957760 },
-  { -15447727,709327,-6919446,-10870178,-29777922,6522332,-21720181,12130072,-14796503,5005757 },
-  { -2114751,-14308128,23019042,15765735,-25269683,6002752,10183197,-13239326,-16395286,-2176112 },
- },
-},
-{
- {
-  { -19025756,1632005,13466291,-7995100,-23640451,16573537,-32013908,-3057104,22208662,2000468 },
-  { 3065073,-1412761,-25598674,-361432,-17683065,-5703415,-8164212,11248527,-3691214,-7414184 },
-  { 10379208,-6045554,8877319,1473647,-29291284,-12507580,16690915,2553332,-3132688,16400289 },
- },
- {
-  { 15716668,1254266,-18472690,7446274,-8448918,6344164,-22097271,-7285580,26894937,9132066 },
-  { 24158887,12938817,11085297,-8177598,-28063478,-4457083,-30576463,64452,-6817084,-2692882 },
-  { 13488534,7794716,22236231,5989356,25426474,-12578208,2350710,-3418511,-4688006,2364226 },
- },
- {
-  { 16335052,9132434,25640582,6678888,1725628,8517937,-11807024,-11697457,15445875,-7798101 },
-  { 29004207,-7867081,28661402,-640412,-12794003,-7943086,31863255,-4135540,-278050,-15759279 },
-  { -6122061,-14866665,-28614905,14569919,-10857999,-3591829,10343412,-6976290,-29828287,-10815811 },
- },
- {
-  { 27081650,3463984,14099042,-4517604,1616303,-6205604,29542636,15372179,17293797,960709 },
-  { 20263915,11434237,-5765435,11236810,13505955,-10857102,-16111345,6493122,-19384511,7639714 },
-  { -2830798,-14839232,25403038,-8215196,-8317012,-16173699,18006287,-16043750,29994677,-15808121 },
- },
- {
-  { 9769828,5202651,-24157398,-13631392,-28051003,-11561624,-24613141,-13860782,-31184575,709464 },
-  { 12286395,13076066,-21775189,-1176622,-25003198,4057652,-32018128,-8890874,16102007,13205847 },
-  { 13733362,5599946,10557076,3195751,-5557991,8536970,-25540170,8525972,10151379,10394400 },
- },
- {
-  { 4024660,-16137551,22436262,12276534,-9099015,-2686099,19698229,11743039,-33302334,8934414 },
-  { -15879800,-4525240,-8580747,-2934061,14634845,-698278,-9449077,3137094,-11536886,11721158 },
-  { 17555939,-5013938,8268606,2331751,-22738815,9761013,9319229,8835153,-9205489,-1280045 },
- },
- {
-  { -461409,-7830014,20614118,16688288,-7514766,-4807119,22300304,505429,6108462,-6183415 },
-  { -5070281,12367917,-30663534,3234473,32617080,-8422642,29880583,-13483331,-26898490,-7867459 },
-  { -31975283,5726539,26934134,10237677,-3173717,-605053,24199304,3795095,7592688,-14992079 },
- },
- {
-  { 21594432,-14964228,17466408,-4077222,32537084,2739898,6407723,12018833,-28256052,4298412 },
-  { -20650503,-11961496,-27236275,570498,3767144,-1717540,13891942,-1569194,13717174,10805743 },
-  { -14676630,-15644296,15287174,11927123,24177847,-8175568,-796431,14860609,-26938930,-5863836 },
- },
-},
-{
- {
-  { 12962541,5311799,-10060768,11658280,18855286,-7954201,13286263,-12808704,-4381056,9882022 },
-  { 18512079,11319350,-20123124,15090309,18818594,5271736,-22727904,3666879,-23967430,-3299429 },
-  { -6789020,-3146043,16192429,13241070,15898607,-14206114,-10084880,-6661110,-2403099,5276065 },
- },
- {
-  { 30169808,-5317648,26306206,-11750859,27814964,7069267,7152851,3684982,1449224,13082861 },
-  { 10342826,3098505,2119311,193222,25702612,12233820,23697382,15056736,-21016438,-8202000 },
-  { -33150110,3261608,22745853,7948688,19370557,-15177665,-26171976,6482814,-10300080,-11060101 },
- },
- {
-  { 32869458,-5408545,25609743,15678670,-10687769,-15471071,26112421,2521008,-22664288,6904815 },
-  { 29506923,4457497,3377935,-9796444,-30510046,12935080,1561737,3841096,-29003639,-6657642 },
-  { 10340844,-6630377,-18656632,-2278430,12621151,-13339055,30878497,-11824370,-25584551,5181966 },
- },
- {
-  { 25940115,-12658025,17324188,-10307374,-8671468,15029094,24396252,-16450922,-2322852,-12388574 },
-  { -21765684,9916823,-1300409,4079498,-1028346,11909559,1782390,12641087,20603771,-6561742 },
-  { -18882287,-11673380,24849422,11501709,13161720,-4768874,1925523,11914390,4662781,7820689 },
- },
- {
-  { 12241050,-425982,8132691,9393934,32846760,-1599620,29749456,12172924,16136752,15264020 },
-  { -10349955,-14680563,-8211979,2330220,-17662549,-14545780,10658213,6671822,19012087,3772772 },
-  { 3753511,-3421066,10617074,2028709,14841030,-6721664,28718732,-15762884,20527771,12988982 },
- },
- {
-  { -14822485,-5797269,-3707987,12689773,-898983,-10914866,-24183046,-10564943,3299665,-12424953 },
-  { -16777703,-15253301,-9642417,4978983,3308785,8755439,6943197,6461331,-25583147,8991218 },
-  { -17226263,1816362,-1673288,-6086439,31783888,-8175991,-32948145,7417950,-30242287,1507265 },
- },
- {
-  { 29692663,6829891,-10498800,4334896,20945975,-11906496,-28887608,8209391,14606362,-10647073 },
-  { -3481570,8707081,32188102,5672294,22096700,1711240,-33020695,9761487,4170404,-2085325 },
-  { -11587470,14855945,-4127778,-1531857,-26649089,15084046,22186522,16002000,-14276837,-8400798 },
- },
- {
-  { -4811456,13761029,-31703877,-2483919,-3312471,7869047,-7113572,-9620092,13240845,10965870 },
-  { -7742563,-8256762,-14768334,-13656260,-23232383,12387166,4498947,14147411,29514390,4302863 },
-  { -13413405,-12407859,20757302,-13801832,14785143,8976368,-5061276,-2144373,17846988,-13971927 },
- },
-},
-{
- {
-  { -2244452,-754728,-4597030,-1066309,-6247172,1455299,-21647728,-9214789,-5222701,12650267 },
-  { -9906797,-16070310,21134160,12198166,-27064575,708126,387813,13770293,-19134326,10958663 },
-  { 22470984,12369526,23446014,-5441109,-21520802,-9698723,-11772496,-11574455,-25083830,4271862 },
- },
- {
-  { -25169565,-10053642,-19909332,15361595,-5984358,2159192,75375,-4278529,-32526221,8469673 },
-  { 15854970,4148314,-8893890,7259002,11666551,13824734,-30531198,2697372,24154791,-9460943 },
-  { 15446137,-15806644,29759747,14019369,30811221,-9610191,-31582008,12840104,24913809,9815020 },
- },
- {
-  { -4709286,-5614269,-31841498,-12288893,-14443537,10799414,-9103676,13438769,18735128,9466238 },
-  { 11933045,9281483,5081055,-5183824,-2628162,-4905629,-7727821,-10896103,-22728655,16199064 },
-  { 14576810,379472,-26786533,-8317236,-29426508,-10812974,-102766,1876699,30801119,2164795 },
- },
- {
-  { 15995086,3199873,13672555,13712240,-19378835,-4647646,-13081610,-15496269,-13492807,1268052 },
-  { -10290614,-3659039,-3286592,10948818,23037027,3794475,-3470338,-12600221,-17055369,3565904 },
-  { 29210088,-9419337,-5919792,-4952785,10834811,-13327726,-16512102,-10820713,-27162222,-14030531 },
- },
- {
-  { -13161890,15508588,16663704,-8156150,-28349942,9019123,-29183421,-3769423,2244111,-14001979 },
-  { -5152875,-3800936,-9306475,-6071583,16243069,14684434,-25673088,-16180800,13491506,4641841 },
-  { 10813417,643330,-19188515,-728916,30292062,-16600078,27548447,-7721242,14476989,-12767431 },
- },
- {
-  { 10292079,9984945,6481436,8279905,-7251514,7032743,27282937,-1644259,-27912810,12651324 },
-  { -31185513,-813383,22271204,11835308,10201545,15351028,17099662,3988035,21721536,-3148940 },
-  { 10202177,-6545839,-31373232,-9574638,-32150642,-8119683,-12906320,3852694,13216206,14842320 },
- },
- {
-  { -15815640,-10601066,-6538952,-7258995,-6984659,-6581778,-31500847,13765824,-27434397,9900184 },
-  { 14465505,-13833331,-32133984,-14738873,-27443187,12990492,33046193,15796406,-7051866,-8040114 },
-  { 30924417,-8279620,6359016,-12816335,16508377,9071735,-25488601,15413635,9524356,-7018878 },
- },
- {
-  { 12274201,-13175547,32627641,-1785326,6736625,13267305,5237659,-5109483,15663516,4035784 },
-  { -2951309,8903985,17349946,601635,-16432815,-4612556,-13732739,-15889334,-22258478,4659091 },
-  { -16916263,-4952973,-30393711,-15158821,20774812,15897498,5736189,15026997,-2178256,-13455585 },
- },
-},
-{
- {
-  { -8858980,-2219056,28571666,-10155518,-474467,-10105698,-3801496,278095,23440562,-290208 },
-  { 10226241,-5928702,15139956,120818,-14867693,5218603,32937275,11551483,-16571960,-7442864 },
-  { 17932739,-12437276,-24039557,10749060,11316803,7535897,22503767,5561594,-3646624,3898661 },
- },
- {
-  { 7749907,-969567,-16339731,-16464,-25018111,15122143,-1573531,7152530,21831162,1245233 },
-  { 26958459,-14658026,4314586,8346991,-5677764,11960072,-32589295,-620035,-30402091,-16716212 },
-  { -12165896,9166947,33491384,13673479,29787085,13096535,6280834,14587357,-22338025,13987525 },
- },
- {
-  { -24349909,7778775,21116000,15572597,-4833266,-5357778,-4300898,-5124639,-7469781,-2858068 },
-  { 9681908,-6737123,-31951644,13591838,-6883821,386950,31622781,6439245,-14581012,4091397 },
-  { -8426427,1470727,-28109679,-1596990,3978627,-5123623,-19622683,12092163,29077877,-14741988 },
- },
- {
-  { 5269168,-6859726,-13230211,-8020715,25932563,1763552,-5606110,-5505881,-20017847,2357889 },
-  { 32264008,-15407652,-5387735,-1160093,-2091322,-3946900,23104804,-12869908,5727338,189038 },
-  { 14609123,-8954470,-6000566,-16622781,-14577387,-7743898,-26745169,10942115,-25888931,-14884697 },
- },
- {
-  { 20513500,5557931,-15604613,7829531,26413943,-2019404,-21378968,7471781,13913677,-5137875 },
-  { -25574376,11967826,29233242,12948236,-6754465,4713227,-8940970,14059180,12878652,8511905 },
-  { -25656801,3393631,-2955415,-7075526,-2250709,9366908,-30223418,6812974,5568676,-3127656 },
- },
- {
-  { 11630004,12144454,2116339,13606037,27378885,15676917,-17408753,-13504373,-14395196,8070818 },
-  { 27117696,-10007378,-31282771,-5570088,1127282,12772488,-29845906,10483306,-11552749,-1028714 },
-  { 10637467,-5688064,5674781,1072708,-26343588,-6982302,-1683975,9177853,-27493162,15431203 },
- },
- {
-  { 20525145,10892566,-12742472,12779443,-29493034,16150075,-28240519,14943142,-15056790,-7935931 },
-  { -30024462,5626926,-551567,-9981087,753598,11981191,25244767,-3239766,-3356550,9594024 },
-  { -23752644,2636870,-5163910,-10103818,585134,7877383,11345683,-6492290,13352335,-10977084 },
- },
- {
-  { -1931799,-5407458,3304649,-12884869,17015806,-4877091,-29783850,-7752482,-13215537,-319204 },
-  { 20239939,6607058,6203985,3483793,-18386976,-779229,-20723742,15077870,-22750759,14523817 },
-  { 27406042,-6041657,27423596,-4497394,4996214,10002360,-28842031,-4545494,-30172742,-4805667 },
- },
-},
-{
- {
-  { 11374242,12660715,17861383,-12540833,10935568,1099227,-13886076,-9091740,-27727044,11358504 },
-  { -12730809,10311867,1510375,10778093,-2119455,-9145702,32676003,11149336,-26123651,4985768 },
-  { -19096303,341147,-6197485,-239033,15756973,-8796662,-983043,13794114,-19414307,-15621255 },
- },
- {
-  { 6490081,11940286,25495923,-7726360,8668373,-8751316,3367603,6970005,-1691065,-9004790 },
-  { 1656497,13457317,15370807,6364910,13605745,8362338,-19174622,-5475723,-16796596,-5031438 },
-  { -22273315,-13524424,-64685,-4334223,-18605636,-10921968,-20571065,-7007978,-99853,-10237333 },
- },
- {
-  { 17747465,10039260,19368299,-4050591,-20630635,-16041286,31992683,-15857976,-29260363,-5511971 },
-  { 31932027,-4986141,-19612382,16366580,22023614,88450,11371999,-3744247,4882242,-10626905 },
-  { 29796507,37186,19818052,10115756,-11829032,3352736,18551198,3272828,-5190932,-4162409 },
- },
- {
-  { 12501286,4044383,-8612957,-13392385,-32430052,5136599,-19230378,-3529697,330070,-3659409 },
-  { 6384877,2899513,17807477,7663917,-2358888,12363165,25366522,-8573892,-271295,12071499 },
-  { -8365515,-4042521,25133448,-4517355,-6211027,2265927,-32769618,1936675,-5159697,3829363 },
- },
- {
-  { 28425966,-5835433,-577090,-4697198,-14217555,6870930,7921550,-6567787,26333140,14267664 },
-  { -11067219,11871231,27385719,-10559544,-4585914,-11189312,10004786,-8709488,-21761224,8930324 },
-  { -21197785,-16396035,25654216,-1725397,12282012,11008919,1541940,4757911,-26491501,-16408940 },
- },
- {
-  { 13537262,-7759490,-20604840,10961927,-5922820,-13218065,-13156584,6217254,-15943699,13814990 },
-  { -17422573,15157790,18705543,29619,24409717,-260476,27361681,9257833,-1956526,-1776914 },
-  { -25045300,-10191966,15366585,15166509,-13105086,8423556,-29171540,12361135,-18685978,4578290 },
- },
- {
-  { 24579768,3711570,1342322,-11180126,-27005135,14124956,-22544529,14074919,21964432,8235257 },
-  { -6528613,-2411497,9442966,-5925588,12025640,-1487420,-2981514,-1669206,13006806,2355433 },
-  { -16304899,-13605259,-6632427,-5142349,16974359,-10911083,27202044,1719366,1141648,-12796236 },
- },
- {
-  { -12863944,-13219986,-8318266,-11018091,-6810145,-4843894,13475066,-3133972,32674895,13715045 },
-  { 11423335,-5468059,32344216,8962751,24989809,9241752,-13265253,16086212,-28740881,-15642093 },
-  { -1409668,12530728,-6368726,10847387,19531186,-14132160,-11709148,7791794,-27245943,4383347 },
- },
-},
-{
- {
-  { -28970898,5271447,-1266009,-9736989,-12455236,16732599,-4862407,-4906449,27193557,6245191 },
-  { -15193956,5362278,-1783893,2695834,4960227,12840725,23061898,3260492,22510453,8577507 },
-  { -12632451,11257346,-32692994,13548177,-721004,10879011,31168030,13952092,-29571492,-3635906 },
- },
- {
-  { 3877321,-9572739,32416692,5405324,-11004407,-13656635,3759769,11935320,5611860,8164018 },
-  { -16275802,14667797,15906460,12155291,-22111149,-9039718,32003002,-8832289,5773085,-8422109 },
-  { -23788118,-8254300,1950875,8937633,18686727,16459170,-905725,12376320,31632953,190926 },
- },
- {
-  { -24593607,-16138885,-8423991,13378746,14162407,6901328,-8288749,4508564,-25341555,-3627528 },
-  { 8884438,-5884009,6023974,10104341,-6881569,-4941533,18722941,-14786005,-1672488,827625 },
-  { -32720583,-16289296,-32503547,7101210,13354605,2659080,-1800575,-14108036,-24878478,1541286 },
- },
- {
-  { 2901347,-1117687,3880376,-10059388,-17620940,-3612781,-21802117,-3567481,20456845,-1885033 },
-  { 27019610,12299467,-13658288,-1603234,-12861660,-4861471,-19540150,-5016058,29439641,15138866 },
-  { 21536104,-6626420,-32447818,-10690208,-22408077,5175814,-5420040,-16361163,7779328,109896 },
- },
- {
-  { 30279744,14648750,-8044871,6425558,13639621,-743509,28698390,12180118,23177719,-554075 },
-  { 26572847,3405927,-31701700,12890905,-19265668,5335866,-6493768,2378492,4439158,-13279347 },
-  { -22716706,3489070,-9225266,-332753,18875722,-1140095,14819434,-12731527,-17717757,-5461437 },
- },
- {
-  { -5056483,16566551,15953661,3767752,-10436499,15627060,-820954,2177225,8550082,-15114165 },
-  { -18473302,16596775,-381660,15663611,22860960,15585581,-27844109,-3582739,-23260460,-8428588 },
-  { -32480551,15707275,-8205912,-5652081,29464558,2713815,-22725137,15860482,-21902570,1494193 },
- },
- {
-  { -19562091,-14087393,-25583872,-9299552,13127842,759709,21923482,16529112,8742704,12967017 },
-  { -28464899,1553205,32536856,-10473729,-24691605,-406174,-8914625,-2933896,-29903758,15553883 },
-  { 21877909,3230008,9881174,10539357,-4797115,2841332,11543572,14513274,19375923,-12647961 },
- },
- {
-  { 8832269,-14495485,13253511,5137575,5037871,4078777,24880818,-6222716,2862653,9455043 },
-  { 29306751,5123106,20245049,-14149889,9592566,8447059,-2077124,-2990080,15511449,4789663 },
-  { -20679756,7004547,8824831,-9434977,-4045704,-3750736,-5754762,108893,23513200,16652362 },
- },
-},
-{
- {
-  { -33256173,4144782,-4476029,-6579123,10770039,-7155542,-6650416,-12936300,-18319198,10212860 },
-  { 2756081,8598110,7383731,-6859892,22312759,-1105012,21179801,2600940,-9988298,-12506466 },
-  { -24645692,13317462,-30449259,-15653928,21365574,-10869657,11344424,864440,-2499677,-16710063 },
- },
- {
-  { -26432803,6148329,-17184412,-14474154,18782929,-275997,-22561534,211300,2719757,4940997 },
-  { -1323882,3911313,-6948744,14759765,-30027150,7851207,21690126,8518463,26699843,5276295 },
-  { -13149873,-6429067,9396249,365013,24703301,-10488939,1321586,149635,-15452774,7159369 },
- },
- {
-  { 9987780,-3404759,17507962,9505530,9731535,-2165514,22356009,8312176,22477218,-8403385 },
-  { 18155857,-16504990,19744716,9006923,15154154,-10538976,24256460,-4864995,-22548173,9334109 },
-  { 2986088,-4911893,10776628,-3473844,10620590,-7083203,-21413845,14253545,-22587149,536906 },
- },
- {
-  { 4377756,8115836,24567078,15495314,11625074,13064599,7390551,10589625,10838060,-15420424 },
-  { -19342404,867880,9277171,-3218459,-14431572,-1986443,19295826,-15796950,6378260,699185 },
-  { 7895026,4057113,-7081772,-13077756,-17886831,-323126,-716039,15693155,-5045064,-13373962 },
- },
- {
-  { -7737563,-5869402,-14566319,-7406919,11385654,13201616,31730678,-10962840,-3918636,-9669325 },
-  { 10188286,-15770834,-7336361,13427543,22223443,14896287,30743455,7116568,-21786507,5427593 },
-  { 696102,13206899,27047647,-10632082,15285305,-9853179,10798490,-4578720,19236243,12477404 },
- },
- {
-  { -11229439,11243796,-17054270,-8040865,-788228,-8167967,-3897669,11180504,-23169516,7733644 },
-  { 17800790,-14036179,-27000429,-11766671,23887827,3149671,23466177,-10538171,10322027,15313801 },
-  { 26246234,11968874,32263343,-5468728,6830755,-13323031,-15794704,-101982,-24449242,10890804 },
- },
- {
-  { -31365647,10271363,-12660625,-6267268,16690207,-13062544,-14982212,16484931,25180797,-5334884 },
-  { -586574,10376444,-32586414,-11286356,19801893,10997610,2276632,9482883,316878,13820577 },
-  { -9882808,-4510367,-2115506,16457136,-11100081,11674996,30756178,-7515054,30696930,-3712849 },
- },
- {
-  { 32988917,-9603412,12499366,7910787,-10617257,-11931514,-7342816,-9985397,-32349517,7392473 },
-  { -8855661,15927861,9866406,-3649411,-2396914,-16655781,-30409476,-9134995,25112947,-2926644 },
-  { -2504044,-436966,25621774,-5678772,15085042,-5479877,-24884878,-13526194,5537438,-13914319 },
- },
-},
-{
- {
-  { -11225584,2320285,-9584280,10149187,-33444663,5808648,-14876251,-1729667,31234590,6090599 },
-  { -9633316,116426,26083934,2897444,-6364437,-2688086,609721,15878753,-6970405,-9034768 },
-  { -27757857,247744,-15194774,-9002551,23288161,-10011936,-23869595,6503646,20650474,1804084 },
- },
- {
-  { -27589786,15456424,8972517,8469608,15640622,4439847,3121995,-10329713,27842616,-202328 },
-  { -15306973,2839644,22530074,10026331,4602058,5048462,28248656,5031932,-11375082,12714369 },
-  { 20807691,-7270825,29286141,11421711,-27876523,-13868230,-21227475,1035546,-19733229,12796920 },
- },
- {
-  { 12076899,-14301286,-8785001,-11848922,-25012791,16400684,-17591495,-12899438,3480665,-15182815 },
-  { -32361549,5457597,28548107,7833186,7303070,-11953545,-24363064,-15921875,-33374054,2771025 },
-  { -21389266,421932,26597266,6860826,22486084,-6737172,-17137485,-4210226,-24552282,15673397 },
- },
- {
-  { -20184622,2338216,19788685,-9620956,-4001265,-8740893,-20271184,4733254,3727144,-12934448 },
-  { 6120119,814863,-11794402,-622716,6812205,-15747771,2019594,7975683,31123697,-10958981 },
-  { 30069250,-11435332,30434654,2958439,18399564,-976289,12296869,9204260,-16432438,9648165 },
- },
- {
-  { 32705432,-1550977,30705658,7451065,-11805606,9631813,3305266,5248604,-26008332,-11377501 },
-  { 17219865,2375039,-31570947,-5575615,-19459679,9219903,294711,15298639,2662509,-16297073 },
-  { -1172927,-7558695,-4366770,-4287744,-21346413,-8434326,32087529,-1222777,32247248,-14389861 },
- },
- {
-  { 14312628,1221556,17395390,-8700143,-4945741,-8684635,-28197744,-9637817,-16027623,-13378845 },
-  { -1428825,-9678990,-9235681,6549687,-7383069,-468664,23046502,9803137,17597934,2346211 },
-  { 18510800,15337574,26171504,981392,-22241552,7827556,-23491134,-11323352,3059833,-11782870 },
- },
- {
-  { 10141598,6082907,17829293,-1947643,9830092,13613136,-25556636,-5544586,-33502212,3592096 },
-  { 33114168,-15889352,-26525686,-13343397,33076705,8716171,1151462,1521897,-982665,-6837803 },
-  { -32939165,-4255815,23947181,-324178,-33072974,-12305637,-16637686,3891704,26353178,693168 },
- },
- {
-  { 30374239,1595580,-16884039,13186931,4600344,406904,9585294,-400668,31375464,14369965 },
-  { -14370654,-7772529,1510301,6434173,-18784789,-6262728,32732230,-13108839,17901441,16011505 },
-  { 18171223,-11934626,-12500402,15197122,-11038147,-15230035,-19172240,-16046376,8764035,12309598 },
- },
-},
-{
- {
-  { 5975908,-5243188,-19459362,-9681747,-11541277,14015782,-23665757,1228319,17544096,-10593782 },
-  { 5811932,-1715293,3442887,-2269310,-18367348,-8359541,-18044043,-15410127,-5565381,12348900 },
-  { -31399660,11407555,25755363,6891399,-3256938,14872274,-24849353,8141295,-10632534,-585479 },
- },
- {
-  { -12675304,694026,-5076145,13300344,14015258,-14451394,-9698672,-11329050,30944593,1130208 },
-  { 8247766,-6710942,-26562381,-7709309,-14401939,-14648910,4652152,2488540,23550156,-271232 },
-  { 17294316,-3788438,7026748,15626851,22990044,113481,2267737,-5908146,-408818,-137719 },
- },
- {
-  { 16091085,-16253926,18599252,7340678,2137637,-1221657,-3364161,14550936,3260525,-7166271 },
-  { -4910104,-13332887,18550887,10864893,-16459325,-7291596,-23028869,-13204905,-12748722,2701326 },
-  { -8574695,16099415,4629974,-16340524,-20786213,-6005432,-10018363,9276971,11329923,1862132 },
- },
- {
-  { 14763076,-15903608,-30918270,3689867,3511892,10313526,-21951088,12219231,-9037963,-940300 },
-  { 8894987,-3446094,6150753,3013931,301220,15693451,-31981216,-2909717,-15438168,11595570 },
-  { 15214962,3537601,-26238722,-14058872,4418657,-15230761,13947276,10730794,-13489462,-4363670 },
- },
- {
-  { -2538306,7682793,32759013,263109,-29984731,-7955452,-22332124,-10188635,977108,699994 },
-  { -12466472,4195084,-9211532,550904,-15565337,12917920,19118110,-439841,-30534533,-14337913 },
-  { 31788461,-14507657,4799989,7372237,8808585,-14747943,9408237,-10051775,12493932,-5409317 },
- },
- {
-  { -25680606,5260744,-19235809,-6284470,-3695942,16566087,27218280,2607121,29375955,6024730 },
-  { 842132,-2794693,-4763381,-8722815,26332018,-12405641,11831880,6985184,-9940361,2854096 },
-  { -4847262,-7969331,2516242,-5847713,9695691,-7221186,16512645,960770,12121869,16648078 },
- },
- {
-  { -15218652,14667096,-13336229,2013717,30598287,-464137,-31504922,-7882064,20237806,2838411 },
-  { -19288047,4453152,15298546,-16178388,22115043,-15972604,12544294,-13470457,1068881,-12499905 },
-  { -9558883,-16518835,33238498,13506958,30505848,-1114596,-8486907,-2630053,12521378,4845654 },
- },
- {
-  { -28198521,10744108,-2958380,10199664,7759311,-13088600,3409348,-873400,-6482306,-12885870 },
-  { -23561822,6230156,-20382013,10655314,-24040585,-11621172,10477734,-1240216,-3113227,13974498 },
-  { 12966261,15550616,-32038948,-1615346,21025980,-629444,5642325,7188737,18895762,12629579 },
- },
-},
-{
- {
-  { 14741879,-14946887,22177208,-11721237,1279741,8058600,11758140,789443,32195181,3895677 },
-  { 10758205,15755439,-4509950,9243698,-4879422,6879879,-2204575,-3566119,-8982069,4429647 },
-  { -2453894,15725973,-20436342,-10410672,-5803908,-11040220,-7135870,-11642895,18047436,-15281743 },
- },
- {
-  { -25173001,-11307165,29759956,11776784,-22262383,-15820455,10993114,-12850837,-17620701,-9408468 },
-  { 21987233,700364,-24505048,14972008,-7774265,-5718395,32155026,2581431,-29958985,8773375 },
-  { -25568350,454463,-13211935,16126715,25240068,8594567,20656846,12017935,-7874389,-13920155 },
- },
- {
-  { 6028182,6263078,-31011806,-11301710,-818919,2461772,-31841174,-5468042,-1721788,-2776725 },
-  { -12278994,16624277,987579,-5922598,32908203,1248608,7719845,-4166698,28408820,6816612 },
-  { -10358094,-8237829,19549651,-12169222,22082623,16147817,20613181,13982702,-10339570,5067943 },
- },
- {
-  { -30505967,-3821767,12074681,13582412,-19877972,2443951,-19719286,12746132,5331210,-10105944 },
-  { 30528811,3601899,-1957090,4619785,-27361822,-15436388,24180793,-12570394,27679908,-1648928 },
-  { 9402404,-13957065,32834043,10838634,-26580150,-13237195,26653274,-8685565,22611444,-12715406 },
- },
- {
-  { 22190590,1118029,22736441,15130463,-30460692,-5991321,19189625,-4648942,4854859,6622139 },
-  { -8310738,-2953450,-8262579,-3388049,-10401731,-271929,13424426,-3567227,26404409,13001963 },
-  { -31241838,-15415700,-2994250,8939346,11562230,-12840670,-26064365,-11621720,-15405155,11020693 },
- },
- {
-  { 1866042,-7949489,-7898649,-10301010,12483315,13477547,3175636,-12424163,28761762,1406734 },
-  { -448555,-1777666,13018551,3194501,-9580420,-11161737,24760585,-4347088,25577411,-13378680 },
-  { -24290378,4759345,-690653,-1852816,2066747,10693769,-29595790,9884936,-9368926,4745410 },
- },
- {
-  { -9141284,6049714,-19531061,-4341411,-31260798,9944276,-15462008,-11311852,10931924,-11931931 },
-  { -16561513,14112680,-8012645,4817318,-8040464,-11414606,-22853429,10856641,-20470770,13434654 },
-  { 22759489,-10073434,-16766264,-1871422,13637442,-10168091,1765144,-12654326,28445307,-5364710 },
- },
- {
-  { 29875063,12493613,2795536,-3786330,1710620,15181182,-10195717,-8788675,9074234,1167180 },
-  { -26205683,11014233,-9842651,-2635485,-26908120,7532294,-18716888,-9535498,3843903,9367684 },
-  { -10969595,-6403711,9591134,9582310,11349256,108879,16235123,8601684,-139197,4242895 },
- },
-},
-{
- {
-  { 22092954,-13191123,-2042793,-11968512,32186753,-11517388,-6574341,2470660,-27417366,16625501 },
-  { -11057722,3042016,13770083,-9257922,584236,-544855,-7770857,2602725,-27351616,14247413 },
-  { 6314175,-10264892,-32772502,15957557,-10157730,168750,-8618807,14290061,27108877,-1180880 },
- },
- {
-  { -8586597,-7170966,13241782,10960156,-32991015,-13794596,33547976,-11058889,-27148451,981874 },
-  { 22833440,9293594,-32649448,-13618667,-9136966,14756819,-22928859,-13970780,-10479804,-16197962 },
-  { -7768587,3326786,-28111797,10783824,19178761,14905060,22680049,13906969,-15933690,3797899 },
- },
- {
-  { 21721356,-4212746,-12206123,9310182,-3882239,-13653110,23740224,-2709232,20491983,-8042152 },
-  { 9209270,-15135055,-13256557,-6167798,-731016,15289673,25947805,15286587,30997318,-6703063 },
-  { 7392032,16618386,23946583,-8039892,-13265164,-1533858,-14197445,-2321576,17649998,-250080 },
- },
- {
-  { -9301088,-14193827,30609526,-3049543,-25175069,-1283752,-15241566,-9525724,-2233253,7662146 },
-  { -17558673,1763594,-33114336,15908610,-30040870,-12174295,7335080,-8472199,-3174674,3440183 },
-  { -19889700,-5977008,-24111293,-9688870,10799743,-16571957,40450,-4431835,4862400,1133 },
- },
- {
-  { -32856209,-7873957,-5422389,14860950,-16319031,7956142,7258061,311861,-30594991,-7379421 },
-  { -3773428,-1565936,28985340,7499440,24445838,9325937,29727763,16527196,18278453,15405622 },
-  { -4381906,8508652,-19898366,-3674424,-5984453,15149970,-13313598,843523,-21875062,13626197 },
- },
- {
-  { 2281448,-13487055,-10915418,-2609910,1879358,16164207,-10783882,3953792,13340839,15928663 },
-  { 31727126,-7179855,-18437503,-8283652,2875793,-16390330,-25269894,-7014826,-23452306,5964753 },
-  { 4100420,-5959452,-17179337,6017714,-18705837,12227141,-26684835,11344144,2538215,-7570755 },
- },
- {
-  { -9433605,6123113,11159803,-2156608,30016280,14966241,-20474983,1485421,-629256,-15958862 },
-  { -26804558,4260919,11851389,9658551,-32017107,16367492,-20205425,-13191288,11659922,-11115118 },
-  { 26180396,10015009,-30844224,-8581293,5418197,9480663,2231568,-10170080,33100372,-1306171 },
- },
- {
-  { 15121113,-5201871,-10389905,15427821,-27509937,-15992507,21670947,4486675,-5931810,-14466380 },
-  { 16166486,-9483733,-11104130,6023908,-31926798,-1364923,2340060,-16254968,-10735770,-10039824 },
-  { 28042865,-3557089,-12126526,12259706,-3717498,-6945899,6766453,-8689599,18036436,5803270 },
- },
-},
-{
- {
-  { -817581,6763912,11803561,1585585,10958447,-2671165,23855391,4598332,-6159431,-14117438 },
-  { -31031306,-14256194,17332029,-2383520,31312682,-5967183,696309,50292,-20095739,11763584 },
-  { -594563,-2514283,-32234153,12643980,12650761,14811489,665117,-12613632,-19773211,-10713562 },
- },
- {
-  { 30464590,-11262872,-4127476,-12734478,19835327,-7105613,-24396175,2075773,-17020157,992471 },
-  { 18357185,-6994433,7766382,16342475,-29324918,411174,14578841,8080033,-11574335,-10601610 },
-  { 19598397,10334610,12555054,2555664,18821899,-10339780,21873263,16014234,26224780,16452269 },
- },
- {
-  { -30223925,5145196,5944548,16385966,3976735,2009897,-11377804,-7618186,-20533829,3698650 },
-  { 14187449,3448569,-10636236,-10810935,-22663880,-3433596,7268410,-10890444,27394301,12015369 },
-  { 19695761,16087646,28032085,12999827,6817792,11427614,20244189,-1312777,-13259127,-3402461 },
- },
- {
-  { 30860103,12735208,-1888245,-4699734,-16974906,2256940,-8166013,12298312,-8550524,-10393462 },
-  { -5719826,-11245325,-1910649,15569035,26642876,-7587760,-5789354,-15118654,-4976164,12651793 },
-  { -2848395,9953421,11531313,-5282879,26895123,-12697089,-13118820,-16517902,9768698,-2533218 },
- },
- {
-  { -24719459,1894651,-287698,-4704085,15348719,-8156530,32767513,12765450,4940095,10678226 },
-  { 18860224,15980149,-18987240,-1562570,-26233012,-11071856,-7843882,13944024,-24372348,16582019 },
-  { -15504260,4970268,-29893044,4175593,-20993212,-2199756,-11704054,15444560,-11003761,7989037 },
- },
- {
-  { 31490452,5568061,-2412803,2182383,-32336847,4531686,-32078269,6200206,-19686113,-14800171 },
-  { -17308668,-15879940,-31522777,-2831,-32887382,16375549,8680158,-16371713,28550068,-6857132 },
-  { -28126887,-5688091,16837845,-1820458,-6850681,12700016,-30039981,4364038,1155602,5988841 },
- },
- {
-  { 21890435,-13272907,-12624011,12154349,-7831873,15300496,23148983,-4470481,24618407,8283181 },
-  { -33136107,-10512751,9975416,6841041,-31559793,16356536,3070187,-7025928,1466169,10740210 },
-  { -1509399,-15488185,-13503385,-10655916,32799044,909394,-13938903,-5779719,-32164649,-15327040 },
- },
- {
-  { 3960823,-14267803,-28026090,-15918051,-19404858,13146868,15567327,951507,-3260321,-573935 },
-  { 24740841,5052253,-30094131,8961361,25877428,6165135,-24368180,14397372,-7380369,-6144105 },
-  { -28888365,3510803,-28103278,-1158478,-11238128,-10631454,-15441463,-14453128,-1625486,-6494814 },
- },
-},
-{
- {
-  { 793299,-9230478,8836302,-6235707,-27360908,-2369593,33152843,-4885251,-9906200,-621852 },
-  { 5666233,525582,20782575,-8038419,-24538499,14657740,16099374,1468826,-6171428,-15186581 },
-  { -4859255,-3779343,-2917758,-6748019,7778750,11688288,-30404353,-9871238,-1558923,-9863646 },
- },
- {
-  { 10896332,-7719704,824275,472601,-19460308,3009587,25248958,14783338,-30581476,-15757844 },
-  { 10566929,12612572,-31944212,11118703,-12633376,12362879,21752402,8822496,24003793,14264025 },
-  { 27713862,-7355973,-11008240,9227530,27050101,2504721,23886875,-13117525,13958495,-5732453 },
- },
- {
-  { -23481610,4867226,-27247128,3900521,29838369,-8212291,-31889399,-10041781,7340521,-15410068 },
-  { 4646514,-8011124,-22766023,-11532654,23184553,8566613,31366726,-1381061,-15066784,-10375192 },
-  { -17270517,12723032,-16993061,14878794,21619651,-6197576,27584817,3093888,-8843694,3849921 },
- },
- {
-  { -9064912,2103172,25561640,-15125738,-5239824,9582958,32477045,-9017955,5002294,-15550259 },
-  { -12057553,-11177906,21115585,-13365155,8808712,-12030708,16489530,13378448,-25845716,12741426 },
-  { -5946367,10645103,-30911586,15390284,-3286982,-7118677,24306472,15852464,28834118,-7646072 },
- },
- {
-  { -17335748,-9107057,-24531279,9434953,-8472084,-583362,-13090771,455841,20461858,5491305 },
-  { 13669248,-16095482,-12481974,-10203039,-14569770,-11893198,-24995986,11293807,-28588204,-9421832 },
-  { 28497928,6272777,-33022994,14470570,8906179,-1225630,18504674,-14165166,29867745,-8795943 },
- },
- {
-  { -16207023,13517196,-27799630,-13697798,24009064,-6373891,-6367600,-13175392,22853429,-4012011 },
-  { 24191378,16712145,-13931797,15217831,14542237,1646131,18603514,-11037887,12876623,-2112447 },
-  { 17902668,4518229,-411702,-2829247,26878217,5258055,-12860753,608397,16031844,3723494 },
- },
- {
-  { -28632773,12763728,-20446446,7577504,33001348,-13017745,17558842,-7872890,23896954,-4314245 },
-  { -20005381,-12011952,31520464,605201,2543521,5991821,-2945064,7229064,-9919646,-8826859 },
-  { 28816045,298879,-28165016,-15920938,19000928,-1665890,-12680833,-2949325,-18051778,-2082915 },
- },
- {
-  { 16000882,-344896,3493092,-11447198,-29504595,-13159789,12577740,16041268,-19715240,7847707 },
-  { 10151868,10572098,27312476,7922682,14825339,4723128,-32855931,-6519018,-10020567,3852848 },
-  { -11430470,15697596,-21121557,-4420647,5386314,15063598,16514493,-15932110,29330899,-15076224 },
- },
-},
-{
- {
-  { -25499735,-4378794,-15222908,-6901211,16615731,2051784,3303702,15490,-27548796,12314391 },
-  { 15683520,-6003043,18109120,-9980648,15337968,-5997823,-16717435,15921866,16103996,-3731215 },
-  { -23169824,-10781249,13588192,-1628807,-3798557,-1074929,-19273607,5402699,-29815713,-9841101 },
- },
- {
-  { 23190676,2384583,-32714340,3462154,-29903655,-1529132,-11266856,8911517,-25205859,2739713 },
-  { 21374101,-3554250,-33524649,9874411,15377179,11831242,-33529904,6134907,4931255,11987849 },
-  { -7732,-2978858,-16223486,7277597,105524,-322051,-31480539,13861388,-30076310,10117930 },
- },
- {
-  { -29501170,-10744872,-26163768,13051539,-25625564,5089643,-6325503,6704079,12890019,15728940 },
-  { -21972360,-11771379,-951059,-4418840,14704840,2695116,903376,-10428139,12885167,8311031 },
-  { -17516482,5352194,10384213,-13811658,7506451,13453191,26423267,4384730,1888765,-5435404 },
- },
- {
-  { -25817338,-3107312,-13494599,-3182506,30896459,-13921729,-32251644,-12707869,-19464434,-3340243 },
-  { -23607977,-2665774,-526091,4651136,5765089,4618330,6092245,14845197,17151279,-9854116 },
-  { -24830458,-12733720,-15165978,10367250,-29530908,-265356,22825805,-7087279,-16866484,16176525 },
- },
- {
-  { -23583256,6564961,20063689,3798228,-4740178,7359225,2006182,-10363426,-28746253,-10197509 },
-  { -10626600,-4486402,-13320562,-5125317,3432136,-6393229,23632037,-1940610,32808310,1099883 },
-  { 15030977,5768825,-27451236,-2887299,-6427378,-15361371,-15277896,-6809350,2051441,-15225865 },
- },
- {
-  { -3362323,-7239372,7517890,9824992,23555850,295369,5148398,-14154188,-22686354,16633660 },
-  { 4577086,-16752288,13249841,-15304328,19958763,-14537274,18559670,-10759549,8402478,-9864273 },
-  { -28406330,-1051581,-26790155,-907698,-17212414,-11030789,9453451,-14980072,17983010,9967138 },
- },
- {
-  { -25762494,6524722,26585488,9969270,24709298,1220360,-1677990,7806337,17507396,3651560 },
-  { -10420457,-4118111,14584639,15971087,-15768321,8861010,26556809,-5574557,-18553322,-11357135 },
-  { 2839101,14284142,4029895,3472686,14402957,12689363,-26642121,8459447,-5605463,-7621941 },
- },
- {
-  { -4839289,-3535444,9744961,2871048,25113978,3187018,-25110813,-849066,17258084,-7977739 },
-  { 18164541,-10595176,-17154882,-1542417,19237078,-9745295,23357533,-15217008,26908270,12150756 },
-  { -30264870,-7647865,5112249,-7036672,-1499807,-6974257,43168,-5537701,-32302074,16215819 },
- },
-},
-{
- {
-  { -6898905,9824394,-12304779,-4401089,-31397141,-6276835,32574489,12532905,-7503072,-8675347 },
-  { -27343522,-16515468,-27151524,-10722951,946346,16291093,254968,7168080,21676107,-1943028 },
-  { 21260961,-8424752,-16831886,-11920822,-23677961,3968121,-3651949,-6215466,-3556191,-7913075 },
- },
- {
-  { 16544754,13250366,-16804428,15546242,-4583003,12757258,-2462308,-8680336,-18907032,-9662799 },
-  { -2415239,-15577728,18312303,4964443,-15272530,-12653564,26820651,16690659,25459437,-4564609 },
-  { -25144690,11425020,28423002,-11020557,-6144921,-15826224,9142795,-2391602,-6432418,-1644817 },
- },
- {
-  { -23104652,6253476,16964147,-3768872,-25113972,-12296437,-27457225,-16344658,6335692,7249989 },
-  { -30333227,13979675,7503222,-12368314,-11956721,-4621693,-30272269,2682242,25993170,-12478523 },
-  { 4364628,5930691,32304656,-10044554,-8054781,15091131,22857016,-10598955,31820368,15075278 },
- },
- {
-  { 31879134,-8918693,17258761,90626,-8041836,-4917709,24162788,-9650886,-17970238,12833045 },
-  { 19073683,14851414,-24403169,-11860168,7625278,11091125,-19619190,2074449,-9413939,14905377 },
-  { 24483667,-11935567,-2518866,-11547418,-1553130,15355506,-25282080,9253129,27628530,-7555480 },
- },
- {
-  { 17597607,8340603,19355617,552187,26198470,-3176583,4593324,-9157582,-14110875,15297016 },
-  { 510886,14337390,-31785257,16638632,6328095,2713355,-20217417,-11864220,8683221,2921426 },
-  { 18606791,11874196,27155355,-5281482,-24031742,6265446,-25178240,-1278924,4674690,13890525 },
- },
- {
-  { 13609624,13069022,-27372361,-13055908,24360586,9592974,14977157,9835105,4389687,288396 },
-  { 9922506,-519394,13613107,5883594,-18758345,-434263,-12304062,8317628,23388070,16052080 },
-  { 12720016,11937594,-31970060,-5028689,26900120,8561328,-20155687,-11632979,-14754271,-10812892 },
- },
- {
-  { 15961858,14150409,26716931,-665832,-22794328,13603569,11829573,7467844,-28822128,929275 },
-  { 11038231,-11582396,-27310482,-7316562,-10498527,-16307831,-23479533,-9371869,-21393143,2465074 },
-  { 20017163,-4323226,27915242,1529148,12396362,15675764,13817261,-9658066,2463391,-4622140 },
- },
- {
-  { -16358878,-12663911,-12065183,4996454,-1256422,1073572,9583558,12851107,4003896,12673717 },
-  { -1731589,-15155870,-3262930,16143082,19294135,13385325,14741514,-9103726,7903886,2348101 },
-  { 24536016,-16515207,12715592,-3862155,1511293,10047386,-3842346,-7129159,-28377538,10048127 },
- },
-},
-{
- {
-  { -12622226,-6204820,30718825,2591312,-10617028,12192840,18873298,-7297090,-32297756,15221632 },
-  { -26478122,-11103864,11546244,-1852483,9180880,7656409,-21343950,2095755,29769758,6593415 },
-  { -31994208,-2907461,4176912,3264766,12538965,-868111,26312345,-6118678,30958054,8292160 },
- },
- {
-  { 31429822,-13959116,29173532,15632448,12174511,-2760094,32808831,3977186,26143136,-3148876 },
-  { 22648901,1402143,-22799984,13746059,7936347,365344,-8668633,-1674433,-3758243,-2304625 },
-  { -15491917,8012313,-2514730,-12702462,-23965846,-10254029,-1612713,-1535569,-16664475,8194478 },
- },
- {
-  { 27338066,-7507420,-7414224,10140405,-19026427,-6589889,27277191,8855376,28572286,3005164 },
-  { 26287124,4821776,25476601,-4145903,-3764513,-15788984,-18008582,1182479,-26094821,-13079595 },
-  { -7171154,3178080,23970071,6201893,-17195577,-4489192,-21876275,-13982627,32208683,-1198248 },
- },
- {
-  { -16657702,2817643,-10286362,14811298,6024667,13349505,-27315504,-10497842,-27672585,-11539858 },
-  { 15941029,-9405932,-21367050,8062055,31876073,-238629,-15278393,-1444429,15397331,-4130193 },
-  { 8934485,-13485467,-23286397,-13423241,-32446090,14047986,31170398,-1441021,-27505566,15087184 },
- },
- {
-  { -18357243,-2156491,24524913,-16677868,15520427,-6360776,-15502406,11461896,16788528,-5868942 },
-  { -1947386,16013773,21750665,3714552,-17401782,-16055433,-3770287,-10323320,31322514,-11615635 },
-  { 21426655,-5650218,-13648287,-5347537,-28812189,-4920970,-18275391,-14621414,13040862,-12112948 },
- },
- {
-  { 11293895,12478086,-27136401,15083750,-29307421,14748872,14555558,-13417103,1613711,4896935 },
-  { -25894883,15323294,-8489791,-8057900,25967126,-13425460,2825960,-4897045,-23971776,-11267415 },
-  { -15924766,-5229880,-17443532,6410664,3622847,10243618,20615400,12405433,-23753030,-8436416 },
- },
- {
-  { -7091295,12556208,-20191352,9025187,-17072479,4333801,4378436,2432030,23097949,-566018 },
-  { 4565804,-16025654,20084412,-7842817,1724999,189254,24767264,10103221,-18512313,2424778 },
-  { 366633,-11976806,8173090,-6890119,30788634,5745705,-7168678,1344109,-3642553,12412659 },
- },
- {
-  { -24001791,7690286,14929416,-168257,-32210835,-13412986,24162697,-15326504,-3141501,11179385 },
-  { 18289522,-14724954,8056945,16430056,-21729724,7842514,-6001441,-1486897,-18684645,-11443503 },
-  { 476239,6601091,-6152790,-9723375,17503545,-4863900,27672959,13403813,11052904,5219329 },
- },
-},
-{
- {
-  { 20678546,-8375738,-32671898,8849123,-5009758,14574752,31186971,-3973730,9014762,-8579056 },
-  { -13644050,-10350239,-15962508,5075808,-1514661,-11534600,-33102500,9160280,8473550,-3256838 },
-  { 24900749,14435722,17209120,-15292541,-22592275,9878983,-7689309,-16335821,-24568481,11788948 },
- },
- {
-  { -3118155,-11395194,-13802089,14797441,9652448,-6845904,-20037437,10410733,-24568470,-1458691 },
-  { -15659161,16736706,-22467150,10215878,-9097177,7563911,11871841,-12505194,-18513325,8464118 },
-  { -23400612,8348507,-14585951,-861714,-3950205,-6373419,14325289,8628612,33313881,-8370517 },
- },
- {
-  { -20186973,-4967935,22367356,5271547,-1097117,-4788838,-24805667,-10236854,-8940735,-5818269 },
-  { -6948785,-1795212,-32625683,-16021179,32635414,-7374245,15989197,-12838188,28358192,-4253904 },
-  { -23561781,-2799059,-32351682,-1661963,-9147719,10429267,-16637684,4072016,-5351664,5596589 },
- },
- {
-  { -28236598,-3390048,12312896,6213178,3117142,16078565,29266239,2557221,1768301,15373193 },
-  { -7243358,-3246960,-4593467,-7553353,-127927,-912245,-1090902,-4504991,-24660491,3442910 },
-  { -30210571,5124043,14181784,8197961,18964734,-11939093,22597931,7176455,-18585478,13365930 },
- },
- {
-  { -7877390,-1499958,8324673,4690079,6261860,890446,24538107,-8570186,-9689599,-3031667 },
-  { 25008904,-10771599,-4305031,-9638010,16265036,15721635,683793,-11823784,15723479,-15163481 },
-  { -9660625,12374379,-27006999,-7026148,-7724114,-12314514,11879682,5400171,519526,-1235876 },
- },
- {
-  { 22258397,-16332233,-7869817,14613016,-22520255,-2950923,-20353881,7315967,16648397,7605640 },
-  { -8081308,-8464597,-8223311,9719710,19259459,-15348212,23994942,-5281555,-9468848,4763278 },
-  { -21699244,9220969,-15730624,1084137,-25476107,-2852390,31088447,-7764523,-11356529,728112 },
- },
- {
-  { 26047220,-11751471,-6900323,-16521798,24092068,9158119,-4273545,-12555558,-29365436,-5498272 },
-  { 17510331,-322857,5854289,8403524,17133918,-3112612,-28111007,12327945,10750447,10014012 },
-  { -10312768,3936952,9156313,-8897683,16498692,-994647,-27481051,-666732,3424691,7540221 },
- },
- {
-  { 30322361,-6964110,11361005,-4143317,7433304,4989748,-7071422,-16317219,-9244265,15258046 },
-  { 13054562,-2779497,19155474,469045,-12482797,4566042,5631406,2711395,1062915,-5136345 },
-  { -19240248,-11254599,-29509029,-7499965,-5835763,13005411,-6066489,12194497,32960380,1459310 },
- },
-},
-{
- {
-  { 19852034,7027924,23669353,10020366,8586503,-6657907,394197,-6101885,18638003,-11174937 },
-  { 31395534,15098109,26581030,8030562,-16527914,-5007134,9012486,-7584354,-6643087,-5442636 },
-  { -9192165,-2347377,-1997099,4529534,25766844,607986,-13222,9677543,-32294889,-6456008 },
- },
- {
-  { -2444496,-149937,29348902,8186665,1873760,12489863,-30934579,-7839692,-7852844,-8138429 },
-  { -15236356,-15433509,7766470,746860,26346930,-10221762,-27333451,10754588,-9431476,5203576 },
-  { 31834314,14135496,-770007,5159118,20917671,-16768096,-7467973,-7337524,31809243,7347066 },
- },
- {
-  { -9606723,-11874240,20414459,13033986,13716524,-11691881,19797970,-12211255,15192876,-2087490 },
-  { -12663563,-2181719,1168162,-3804809,26747877,-14138091,10609330,12694420,33473243,-13382104 },
-  { 33184999,11180355,15832085,-11385430,-1633671,225884,15089336,-11023903,-6135662,14480053 },
- },
- {
-  { 31308717,-5619998,31030840,-1897099,15674547,-6582883,5496208,13685227,27595050,8737275 },
-  { -20318852,-15150239,10933843,-16178022,8335352,-7546022,-31008351,-12610604,26498114,66511 },
-  { 22644454,-8761729,-16671776,4884562,-3105614,-13559366,30540766,-4286747,-13327787,-7515095 },
- },
- {
-  { -28017847,9834845,18617207,-2681312,-3401956,-13307506,8205540,13585437,-17127465,15115439 },
-  { 23711543,-672915,31206561,-8362711,6164647,-9709987,-33535882,-1426096,8236921,16492939 },
-  { -23910559,-13515526,-26299483,-4503841,25005590,-7687270,19574902,10071562,6708380,-6222424 },
- },
- {
-  { 2101391,-4930054,19702731,2367575,-15427167,1047675,5301017,9328700,29955601,-11678310 },
-  { 3096359,9271816,-21620864,-15521844,-14847996,-7592937,-25892142,-12635595,-9917575,6216608 },
-  { -32615849,338663,-25195611,2510422,-29213566,-13820213,24822830,-6146567,-26767480,7525079 },
- },
- {
-  { -23066649,-13985623,16133487,-7896178,-3389565,778788,-910336,-2782495,-19386633,11994101 },
-  { 21691500,-13624626,-641331,-14367021,3285881,-3483596,-25064666,9718258,-7477437,13381418 },
-  { 18445390,-4202236,14979846,11622458,-1727110,-3582980,23111648,-6375247,28535282,15779576 },
- },
- {
-  { 30098053,3089662,-9234387,16662135,-21306940,11308411,-14068454,12021730,9955285,-16303356 },
-  { 9734894,-14576830,-7473633,-9138735,2060392,11313496,-18426029,9924399,20194861,13380996 },
-  { -26378102,-7965207,-22167821,15789297,-18055342,-6168792,-1984914,15707771,26342023,10146099 },
- },
-},
-{
- {
-  { -26016874,-219943,21339191,-41388,19745256,-2878700,-29637280,2227040,21612326,-545728 },
-  { -13077387,1184228,23562814,-5970442,-20351244,-6348714,25764461,12243797,-20856566,11649658 },
-  { -10031494,11262626,27384172,2271902,26947504,-15997771,39944,6114064,33514190,2333242 },
- },
- {
-  { -21433588,-12421821,8119782,7219913,-21830522,-9016134,-6679750,-12670638,24350578,-13450001 },
-  { -4116307,-11271533,-23886186,4843615,-30088339,690623,-31536088,-10406836,8317860,12352766 },
-  { 18200138,-14475911,-33087759,-2696619,-23702521,-9102511,-23552096,-2287550,20712163,6719373 },
- },
- {
-  { 26656208,6075253,-7858556,1886072,-28344043,4262326,11117530,-3763210,26224235,-3297458 },
-  { -17168938,-14854097,-3395676,-16369877,-19954045,14050420,21728352,9493610,18620611,-16428628 },
-  { -13323321,13325349,11432106,5964811,18609221,6062965,-5269471,-9725556,-30701573,-16479657 },
- },
- {
-  { -23860538,-11233159,26961357,1640861,-32413112,-16737940,12248509,-5240639,13735342,1934062 },
-  { 25089769,6742589,17081145,-13406266,21909293,-16067981,-15136294,-3765346,-21277997,5473616 },
-  { 31883677,-7961101,1083432,-11572403,22828471,13290673,-7125085,12469656,29111212,-5451014 },
- },
- {
-  { 24244947,-15050407,-26262976,2791540,-14997599,16666678,24367466,6388839,-10295587,452383 },
-  { -25640782,-3417841,5217916,16224624,19987036,-4082269,-24236251,-5915248,15766062,8407814 },
-  { -20406999,13990231,15495425,16395525,5377168,15166495,-8917023,-4388953,-8067909,2276718 },
- },
- {
-  { 30157918,12924066,-17712050,9245753,19895028,3368142,-23827587,5096219,22740376,-7303417 },
-  { 2041139,-14256350,7783687,13876377,-25946985,-13352459,24051124,13742383,-15637599,13295222 },
-  { 33338237,-8505733,12532113,7977527,9106186,-1715251,-17720195,-4612972,-4451357,-14669444 },
- },
- {
-  { -20045281,5454097,-14346548,6447146,28862071,1883651,-2469266,-4141880,7770569,9620597 },
-  { 23208068,7979712,33071466,8149229,1758231,-10834995,30945528,-1694323,-33502340,-14767970 },
-  { 1439958,-16270480,-1079989,-793782,4625402,10647766,-5043801,1220118,30494170,-11440799 },
- },
- {
-  { -5037580,-13028295,-2970559,-3061767,15640974,-6701666,-26739026,926050,-1684339,-13333647 },
-  { 13908495,-3549272,30919928,-6273825,-21521863,7989039,9021034,9078865,3353509,4033511 },
-  { -29663431,-15113610,32259991,-344482,24295849,-12912123,23161163,8839127,27485041,7356032 },
- },
-},
-{
- {
-  { 9661027,705443,11980065,-5370154,-1628543,14661173,-6346142,2625015,28431036,-16771834 },
-  { -23839233,-8311415,-25945511,7480958,-17681669,-8354183,-22545972,14150565,15970762,4099461 },
-  { 29262576,16756590,26350592,-8793563,8529671,-11208050,13617293,-9937143,11465739,8317062 },
- },
- {
-  { -25493081,-6962928,32500200,-9419051,-23038724,-2302222,14898637,3848455,20969334,-5157516 },
-  { -20384450,-14347713,-18336405,13884722,-33039454,2842114,-21610826,-3649888,11177095,14989547 },
-  { -24496721,-11716016,16959896,2278463,12066309,10137771,13515641,2581286,-28487508,9930240 },
- },
- {
-  { -17751622,-2097826,16544300,-13009300,-15914807,-14949081,18345767,-13403753,16291481,-5314038 },
-  { -33229194,2553288,32678213,9875984,8534129,6889387,-9676774,6957617,4368891,9788741 },
-  { 16660756,7281060,-10830758,12911820,20108584,-8101676,-21722536,-8613148,16250552,-11111103 },
- },
- {
-  { -19765507,2390526,-16551031,14161980,1905286,6414907,4689584,10604807,-30190403,4782747 },
-  { -1354539,14736941,-7367442,-13292886,7710542,-14155590,-9981571,4383045,22546403,437323 },
-  { 31665577,-12180464,-16186830,1491339,-18368625,3294682,27343084,2786261,-30633590,-14097016 },
- },
- {
-  { -14467279,-683715,-33374107,7448552,19294360,14334329,-19690631,2355319,-19284671,-6114373 },
-  { 15121312,-15796162,6377020,-6031361,-10798111,-12957845,18952177,15496498,-29380133,11754228 },
-  { -2637277,-13483075,8488727,-14303896,12728761,-1622493,7141596,11724556,22761615,-10134141 },
- },
- {
-  { 16918416,11729663,-18083579,3022987,-31015732,-13339659,-28741185,-12227393,32851222,11717399 },
-  { 11166634,7338049,-6722523,4531520,-29468672,-7302055,31474879,3483633,-1193175,-4030831 },
-  { -185635,9921305,31456609,-13536438,-12013818,13348923,33142652,6546660,-19985279,-3948376 },
- },
- {
-  { -32460596,11266712,-11197107,-7899103,31703694,3855903,-8537131,-12833048,-30772034,-15486313 },
-  { -18006477,12709068,3991746,-6479188,-21491523,-10550425,-31135347,-16049879,10928917,3011958 },
-  { -6957757,-15594337,31696059,334240,29576716,14796075,-30831056,-12805180,18008031,10258577 },
- },
- {
-  { -22448644,15655569,7018479,-4410003,-30314266,-1201591,-1853465,1367120,25127874,6671743 },
-  { 29701166,-14373934,-10878120,9279288,-17568,13127210,21382910,11042292,25838796,4642684 },
-  { -20430234,14955537,-24126347,8124619,-5369288,-5990470,30468147,-13900640,18423289,4177476 },
- },
-},
-} ;
-
-
-static void ge_select(ge_precomp *t,int pos,signed char b)
-{
-  ge_precomp minust;
-  unsigned char bnegative = negative(b);
-  unsigned char babs = b - (((-bnegative) & b) << 1);
-
-  ge_precomp_0(t);
-  cmov(t,&base[pos][0],equal(babs,1));
-  cmov(t,&base[pos][1],equal(babs,2));
-  cmov(t,&base[pos][2],equal(babs,3));
-  cmov(t,&base[pos][3],equal(babs,4));
-  cmov(t,&base[pos][4],equal(babs,5));
-  cmov(t,&base[pos][5],equal(babs,6));
-  cmov(t,&base[pos][6],equal(babs,7));
-  cmov(t,&base[pos][7],equal(babs,8));
-  fe_copy(minust.yplusx,t->yminusx);
-  fe_copy(minust.yminusx,t->yplusx);
-  fe_neg(minust.xy2d,t->xy2d);
-  cmov(t,&minust,bnegative);
-}
-
-
-/*
-h = a * B
-where a = a[0]+256*a[1]+...+256^31 a[31]
-B is the Ed25519 base point (x,4/5) with x positive.
-
-Preconditions:
-  a[31] <= 127
-*/
-void ge_scalarmult_base(ge_p3 *h,const unsigned char *a)
-{
-  signed char e[64];
-  signed char carry;
-  ge_p1p1 r;
-  ge_p2 s;
-  ge_precomp t;
-  int i;
-
-  for (i = 0;i < 32;++i) {
-    e[2 * i + 0] = (a[i] >> 0) & 15;
-    e[2 * i + 1] = (a[i] >> 4) & 15;
-  }
-  /* each e[i] is between 0 and 15 */
-  /* e[63] is between 0 and 7 */
-
-  carry = 0;
-  for (i = 0;i < 63;++i) {
-    e[i] += carry;
-    carry = e[i] + 8;
-    carry >>= 4;
-    e[i] -= carry << 4;
-  }
-  e[63] += carry;
-  /* each e[i] is between -8 and 8 */
-
-  ge_p3_0(h);
-  for (i = 1;i < 64;i += 2) {
-    ge_select(&t,i / 2,e[i]);
-    ge_madd(&r,h,&t); ge_p1p1_to_p3(h,&r);
-  }
-
-  ge_p3_dbl(&r,h);  ge_p1p1_to_p2(&s,&r);
-  ge_p2_dbl(&r,&s); ge_p1p1_to_p2(&s,&r);
-  ge_p2_dbl(&r,&s); ge_p1p1_to_p2(&s,&r);
-  ge_p2_dbl(&r,&s); ge_p1p1_to_p3(h,&r);
-
-  for (i = 0;i < 64;i += 2) {
-    ge_select(&t,i / 2,e[i]);
-    ge_madd(&r,h,&t); ge_p1p1_to_p3(h,&r);
-  }
-}
-
-
-/* ge double scalar mult */
-static void slide(signed char *r,const unsigned char *a)
-{
-  int i;
-  int b;
-  int k;
-
-  for (i = 0;i < 256;++i)
-    r[i] = 1 & (a[i >> 3] >> (i & 7));
-
-  for (i = 0;i < 256;++i)
-    if (r[i]) {
-      for (b = 1;b <= 6 && i + b < 256;++b) {
-        if (r[i + b]) {
-          if (r[i] + (r[i + b] << b) <= 15) {
-            r[i] += r[i + b] << b; r[i + b] = 0;
-          } else if (r[i] - (r[i + b] << b) >= -15) {
-            r[i] -= r[i + b] << b;
-            for (k = i + b;k < 256;++k) {
-              if (!r[k]) {
-                r[k] = 1;
-                break;
-              }
-              r[k] = 0;
-            }
-          } else
-            break;
-        }
-      }
-    }
-}
-
-
-static ge_precomp Bi[8] = {
- {
-  { 25967493,-14356035,29566456,3660896,-12694345,4014787,27544626,-11754271,-6079156,2047605 },
-  { -12545711,934262,-2722910,3049990,-727428,9406986,12720692,5043384,19500929,-15469378 },
-  { -8738181,4489570,9688441,-14785194,10184609,-12363380,29287919,11864899,-24514362,-4438546 },
- },
- {
-  { 15636291,-9688557,24204773,-7912398,616977,-16685262,27787600,-14772189,28944400,-1550024 },
-  { 16568933,4717097,-11556148,-1102322,15682896,-11807043,16354577,-11775962,7689662,11199574 },
-  { 30464156,-5976125,-11779434,-15670865,23220365,15915852,7512774,10017326,-17749093,-9920357 },
- },
- {
-  { 10861363,11473154,27284546,1981175,-30064349,12577861,32867885,14515107,-15438304,10819380 },
-  { 4708026,6336745,20377586,9066809,-11272109,6594696,-25653668,12483688,-12668491,5581306 },
-  { 19563160,16186464,-29386857,4097519,10237984,-4348115,28542350,13850243,-23678021,-15815942 },
- },
- {
-  { 5153746,9909285,1723747,-2777874,30523605,5516873,19480852,5230134,-23952439,-15175766 },
-  { -30269007,-3463509,7665486,10083793,28475525,1649722,20654025,16520125,30598449,7715701 },
-  { 28881845,14381568,9657904,3680757,-20181635,7843316,-31400660,1370708,29794553,-1409300 },
- },
- {
-  { -22518993,-6692182,14201702,-8745502,-23510406,8844726,18474211,-1361450,-13062696,13821877 },
-  { -6455177,-7839871,3374702,-4740862,-27098617,-10571707,31655028,-7212327,18853322,-14220951 },
-  { 4566830,-12963868,-28974889,-12240689,-7602672,-2830569,-8514358,-10431137,2207753,-3209784 },
- },
- {
-  { -25154831,-4185821,29681144,7868801,-6854661,-9423865,-12437364,-663000,-31111463,-16132436 },
-  { 25576264,-2703214,7349804,-11814844,16472782,9300885,3844789,15725684,171356,6466918 },
-  { 23103977,13316479,9739013,-16149481,817875,-15038942,8965339,-14088058,-30714912,16193877 },
- },
- {
-  { -33521811,3180713,-2394130,14003687,-16903474,-16270840,17238398,4729455,-18074513,9256800 },
-  { -25182317,-4174131,32336398,5036987,-21236817,11360617,22616405,9761698,-19827198,630305 },
-  { -13720693,2639453,-24237460,-7406481,9494427,-5774029,-6554551,-15960994,-2449256,-14291300 },
- },
- {
-  { -3151181,-5046075,9282714,6866145,-31907062,-863023,-18940575,15033784,25105118,-7894876 },
-  { -24326370,15950226,-31801215,-14592823,-11662737,-5090925,1573892,-2625887,2198790,-15804619 },
-  { -3099351,10324967,-2241613,7453183,-5446979,-2735503,-13812022,-16236442,-32461234,-12290683 },
- },
-} ;
-
-
-/*
-r = a * A + b * B
-where a = a[0]+256*a[1]+...+256^31 a[31].
-and b = b[0]+256*b[1]+...+256^31 b[31].
-B is the Ed25519 base point (x,4/5) with x positive.
-*/
-int ge_double_scalarmult_vartime(ge_p2 *r, const unsigned char *a, 
-                                 const ge_p3 *A, const unsigned char *b)
-{
-  signed char aslide[256];
-  signed char bslide[256];
-  ge_cached Ai[8]; /* A,3A,5A,7A,9A,11A,13A,15A */
-  ge_p1p1 t;
-  ge_p3 u;
-  ge_p3 A2;
-  int i;
-
-  slide(aslide,a);
-  slide(bslide,b);
-
-  ge_p3_to_cached(&Ai[0],A);
-  ge_p3_dbl(&t,A); ge_p1p1_to_p3(&A2,&t);
-  ge_add(&t,&A2,&Ai[0]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[1],&u);
-  ge_add(&t,&A2,&Ai[1]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[2],&u);
-  ge_add(&t,&A2,&Ai[2]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[3],&u);
-  ge_add(&t,&A2,&Ai[3]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[4],&u);
-  ge_add(&t,&A2,&Ai[4]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[5],&u);
-  ge_add(&t,&A2,&Ai[5]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[6],&u);
-  ge_add(&t,&A2,&Ai[6]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[7],&u);
-
-  ge_p2_0(r);
-
-  for (i = 255;i >= 0;--i) {
-    if (aslide[i] || bslide[i]) break;
-  }
-
-  for (;i >= 0;--i) {
-    ge_p2_dbl(&t,r);
-
-    if (aslide[i] > 0) {
-      ge_p1p1_to_p3(&u,&t);
-      ge_add(&t,&u,&Ai[aslide[i]/2]);
-    } else if (aslide[i] < 0) {
-      ge_p1p1_to_p3(&u,&t);
-      ge_sub(&t,&u,&Ai[(-aslide[i])/2]);
-    }
-
-    if (bslide[i] > 0) {
-      ge_p1p1_to_p3(&u,&t);
-      ge_madd(&t,&u,&Bi[bslide[i]/2]);
-    } else if (bslide[i] < 0) {
-      ge_p1p1_to_p3(&u,&t);
-      ge_msub(&t,&u,&Bi[(-bslide[i])/2]);
-    }
-
-    ge_p1p1_to_p2(r,&t);
-  }
-
-  return 0;
-}
-
-
-static const fe d = {
--10913610,13857413,-15372611,6949391,114729,
--8787816,-6275908,-3247719,-18696448,-12055116
-} ;
-
-
-static const fe sqrtm1 = {
--32595792,-7943725,9377950,3500415,12389472,
--272473,-25146209,-2005654,326686,11406482
-} ;
-
-
-int ge_frombytes_negate_vartime(ge_p3 *h,const unsigned char *s)
-{
-  fe u;
-  fe v;
-  fe v3;
-  fe vxx;
-  fe check;
-
-  fe_frombytes(h->Y,s);
-  fe_1(h->Z);
-  fe_sq(u,h->Y);
-  fe_mul(v,u,d);
-  fe_sub(u,u,h->Z);       /* u = y^2-1 */
-  fe_add(v,v,h->Z);       /* v = dy^2+1 */
-
-
-  fe_sq(v3,v);
-  fe_mul(v3,v3,v);        /* v3 = v^3 */
-  fe_sq(h->X,v3);
-  fe_mul(h->X,h->X,v);
-  fe_mul(h->X,h->X,u);    /* x = uv^7 */
-
-  fe_pow22523(h->X,h->X); /* x = (uv^7)^((q-5)/8) */
-  fe_mul(h->X,h->X,v3);
-  fe_mul(h->X,h->X,u);    /* x = uv^3(uv^7)^((q-5)/8) */
-
-  fe_sq(vxx,h->X);
-  fe_mul(vxx,vxx,v);
-  fe_sub(check,vxx,u);    /* vx^2-u */
-  if (fe_isnonzero(check)) {
-    fe_add(check,vxx,u);  /* vx^2+u */
-    if (fe_isnonzero(check)) return -1;
-    fe_mul(h->X,h->X,sqrtm1);
-  }
-
-  if (fe_isnegative(h->X) == (s[31] >> 7))
-    fe_neg(h->X,h->X);
-
-  fe_mul(h->T,h->X,h->Y);
-  return 0;
-}
-
-
-/* ge madd */
-/*
-r = p + q
-*/
-
-void ge_madd(ge_p1p1 *r,const ge_p3 *p,const ge_precomp *q)
-{
-	fe t0;
-	fe_add(r->X,p->Y,p->X);
-	fe_sub(r->Y,p->Y,p->X);
-	fe_mul(r->Z,r->X,q->yplusx);
-	fe_mul(r->Y,r->Y,q->yminusx);
-	fe_mul(r->T,q->xy2d,p->T);
-	fe_add(t0,p->Z,p->Z);
-	fe_sub(r->X,r->Z,r->Y);
-	fe_add(r->Y,r->Z,r->Y);
-	fe_add(r->Z,t0,r->T);
-	fe_sub(r->T,t0,r->T);
-}
-
-
-/* ge msub */
-
-/*
-r = p - q
-*/
-
-void ge_msub(ge_p1p1 *r,const ge_p3 *p,const ge_precomp *q)
-{
-	fe t0;
-	fe_add(r->X,p->Y,p->X);
-	fe_sub(r->Y,p->Y,p->X);
-	fe_mul(r->Z,r->X,q->yminusx);
-	fe_mul(r->Y,r->Y,q->yplusx);
-	fe_mul(r->T,q->xy2d,p->T);
-	fe_add(t0,p->Z,p->Z);
-	fe_sub(r->X,r->Z,r->Y);
-	fe_add(r->Y,r->Z,r->Y);
-	fe_sub(r->Z,t0,r->T);
-	fe_add(r->T,t0,r->T);
-}
-
-
-/* ge p1p1 to p2 */
-/*
-r = p
-*/
-
-extern void ge_p1p1_to_p2(ge_p2 *r,const ge_p1p1 *p)
-{
-  fe_mul(r->X,p->X,p->T);
-  fe_mul(r->Y,p->Y,p->Z);
-  fe_mul(r->Z,p->Z,p->T);
-}
-
-
-/* ge p1p1 to p3 */
-
-/*
-r = p
-*/
-
-extern void ge_p1p1_to_p3(ge_p3 *r,const ge_p1p1 *p)
-{
-  fe_mul(r->X,p->X,p->T);
-  fe_mul(r->Y,p->Y,p->Z);
-  fe_mul(r->Z,p->Z,p->T);
-  fe_mul(r->T,p->X,p->Y);
-}
-
-
-/* ge p2 0 */
-
-void ge_p2_0(ge_p2 *h)
-{
-  fe_0(h->X);
-  fe_1(h->Y);
-  fe_1(h->Z);
-}
-
-
-/* ge p2 dbl */
-
-/*
-r = 2 * p
-*/
-
-void ge_p2_dbl(ge_p1p1 *r,const ge_p2 *p)
-{
-	fe t0;
-	fe_sq(r->X,p->X);
-	fe_sq(r->Z,p->Y);
-	fe_sq2(r->T,p->Z);
-	fe_add(r->Y,p->X,p->Y);
-	fe_sq(t0,r->Y);
-	fe_add(r->Y,r->Z,r->X);
-	fe_sub(r->Z,r->Z,r->X);
-	fe_sub(r->X,t0,r->Y);
-	fe_sub(r->T,r->T,r->Z);
-}
-
-
-/* ge p3 0 */
-
-void ge_p3_0(ge_p3 *h)
-{
-  fe_0(h->X);
-  fe_1(h->Y);
-  fe_1(h->Z);
-  fe_0(h->T);
-}
-
-
-/* ge p3 dble */
-
-/*
-r = 2 * p
-*/
-
-void ge_p3_dbl(ge_p1p1 *r,const ge_p3 *p)
-{
-  ge_p2 q;
-  ge_p3_to_p2(&q,p);
-  ge_p2_dbl(r,&q);
-}
-
-
-/* ge p3 to cached */
-
-/*
-r = p
-*/
-
-static const fe d2 = {
--21827239,-5839606,-30745221,13898782,229458,
-15978800,-12551817,-6495438,29715968,9444199
-} ;
-
-
-extern void ge_p3_to_cached(ge_cached *r,const ge_p3 *p)
-{
-  fe_add(r->YplusX,p->Y,p->X);
-  fe_sub(r->YminusX,p->Y,p->X);
-  fe_copy(r->Z,p->Z);
-  fe_mul(r->T2d,p->T,d2);
-}
-
-
-/* ge p3 to p2 */
-/*
-r = p
-*/
-
-extern void ge_p3_to_p2(ge_p2 *r,const ge_p3 *p)
-{
-  fe_copy(r->X,p->X);
-  fe_copy(r->Y,p->Y);
-  fe_copy(r->Z,p->Z);
-}
-
-
-/* ge p3 tobytes */
-void ge_p3_tobytes(unsigned char *s,const ge_p3 *h)
-{
-  fe recip;
-  fe x;
-  fe y;
-
-  fe_invert(recip,h->Z);
-  fe_mul(x,h->X,recip);
-  fe_mul(y,h->Y,recip);
-  fe_tobytes(s,y);
-  s[31] ^= fe_isnegative(x) << 7;
-}
-
-
-/* ge_precomp_0 */
-void ge_precomp_0(ge_precomp *h)
-{
-  fe_1(h->yplusx);
-  fe_1(h->yminusx);
-  fe_0(h->xy2d);
-}
-
-
-/* ge_sub */
-/*
-r = p - q
-*/
-
-void ge_sub(ge_p1p1 *r,const ge_p3 *p,const ge_cached *q)
-{
-	fe t0;
-	fe_add(r->X,p->Y,p->X);
-	fe_sub(r->Y,p->Y,p->X);
-	fe_mul(r->Z,r->X,q->YminusX);
-	fe_mul(r->Y,r->Y,q->YplusX);
-	fe_mul(r->T,q->T2d,p->T);
-	fe_mul(r->X,p->Z,q->Z);
-	fe_add(t0,r->X,r->X);
-	fe_sub(r->X,r->Z,r->Y);
-	fe_add(r->Y,r->Z,r->Y);
-	fe_sub(r->Z,t0,r->T);
-	fe_add(r->T,t0,r->T);
-}
-
-
-/* ge tobytes */
-void ge_tobytes(unsigned char *s,const ge_p2 *h)
-{
-  fe recip;
-  fe x;
-  fe y;
-
-  fe_invert(recip,h->Z);
-  fe_mul(x,h->X,recip);
-  fe_mul(y,h->Y,recip);
-  fe_tobytes(s,y);
-  s[31] ^= fe_isnegative(x) << 7;
-}
-#endif /* HAVE_ED25519 */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/hash.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/hash.c
deleted file mode 100755
index 55a1f6a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/hash.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* hash.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#if !defined(WOLFSSL_TI_HASH)
-
-#include 
-
-#if !defined(NO_MD5)
-void wc_Md5GetHash(Md5* md5, byte* hash)
-{
-    Md5 save = *md5 ;
-    wc_Md5Final(md5, hash) ;
-    *md5 = save ;
-}
-
-WOLFSSL_API void wc_Md5RestorePos(Md5* m1, Md5* m2) {
-    *m1 = *m2 ;
-}
-#endif
-
-#if !defined(NO_SHA)
-int wc_ShaGetHash(Sha* sha, byte* hash)
-{
-    int ret ;
-    Sha save = *sha ;
-    ret = wc_ShaFinal(sha, hash) ;
-    *sha = save ;
-    return ret ;
-}
-
-WOLFSSL_API void wc_ShaRestorePos(Sha* s1, Sha* s2) {
-    *s1 = *s2 ;
-}
-#endif
-
-#if !defined(NO_SHA256)
-int wc_Sha256GetHash(Sha256* sha256, byte* hash)
-{
-    int ret ;
-    Sha256 save = *sha256 ;
-    ret = wc_Sha256Final(sha256, hash) ;
-    *sha256 = save ;
-    return ret ;
-}
-
-WOLFSSL_API void wc_Sha256RestorePos(Sha256* s1, Sha256* s2) {
-    *s1 = *s2 ;
-}
-#endif
-
-#endif
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/hc128.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/hc128.c
deleted file mode 100755
index bcfa148..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/hc128.c
+++ /dev/null
@@ -1,399 +0,0 @@
-/* hc128.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef HAVE_HC128
-
-#include 
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-		#include 
-#else
-    #include 
-#endif
-
-
-#ifdef BIG_ENDIAN_ORDER
-    #define LITTLE32(x) ByteReverseWord32(x)
-#else
-    #define LITTLE32(x) (x)
-#endif
-
-
-/*h1 function*/
-#define h1(ctx, x, y) {                         \
-     byte a,c;                                  \
-     a = (byte) (x);                            \
-     c = (byte) ((x) >> 16);                    \
-     y = (ctx->T[512+a])+(ctx->T[512+256+c]);   \
-}
-
-/*h2 function*/
-#define h2(ctx, x, y) {                         \
-     byte a,c;                                  \
-     a = (byte) (x);                            \
-     c = (byte) ((x) >> 16);                    \
-     y = (ctx->T[a])+(ctx->T[256+c]);           \
-}
-
-/*one step of HC-128, update P and generate 32 bits keystream*/
-#define step_P(ctx,u,v,a,b,c,d,n){              \
-     word32 tem0,tem1,tem2,tem3;                \
-     h1((ctx),(ctx->X[(d)]),tem3);              \
-     tem0 = rotrFixed((ctx->T[(v)]),23);        \
-     tem1 = rotrFixed((ctx->X[(c)]),10);        \
-     tem2 = rotrFixed((ctx->X[(b)]),8);         \
-     (ctx->T[(u)]) += tem2+(tem0 ^ tem1);       \
-     (ctx->X[(a)]) = (ctx->T[(u)]);             \
-     (n) = tem3 ^ (ctx->T[(u)]) ;               \
-}       
-
-/*one step of HC-128, update Q and generate 32 bits keystream*/
-#define step_Q(ctx,u,v,a,b,c,d,n){              \
-     word32 tem0,tem1,tem2,tem3;                \
-     h2((ctx),(ctx->Y[(d)]),tem3);              \
-     tem0 = rotrFixed((ctx->T[(v)]),(32-23));   \
-     tem1 = rotrFixed((ctx->Y[(c)]),(32-10));   \
-     tem2 = rotrFixed((ctx->Y[(b)]),(32-8));    \
-     (ctx->T[(u)]) += tem2 + (tem0 ^ tem1);     \
-     (ctx->Y[(a)]) = (ctx->T[(u)]);             \
-     (n) = tem3 ^ (ctx->T[(u)]) ;               \
-}   
-
-/*16 steps of HC-128, generate 512 bits keystream*/
-static void generate_keystream(HC128* ctx, word32* keystream)  
-{
-   word32 cc,dd;
-   cc = ctx->counter1024 & 0x1ff;
-   dd = (cc+16)&0x1ff;
-
-   if (ctx->counter1024 < 512)	
-   {   		
-      ctx->counter1024 = (ctx->counter1024 + 16) & 0x3ff;
-      step_P(ctx, cc+0, cc+1, 0, 6, 13,4, keystream[0]);
-      step_P(ctx, cc+1, cc+2, 1, 7, 14,5, keystream[1]);
-      step_P(ctx, cc+2, cc+3, 2, 8, 15,6, keystream[2]);
-      step_P(ctx, cc+3, cc+4, 3, 9, 0, 7, keystream[3]);
-      step_P(ctx, cc+4, cc+5, 4, 10,1, 8, keystream[4]);
-      step_P(ctx, cc+5, cc+6, 5, 11,2, 9, keystream[5]);
-      step_P(ctx, cc+6, cc+7, 6, 12,3, 10,keystream[6]);
-      step_P(ctx, cc+7, cc+8, 7, 13,4, 11,keystream[7]);
-      step_P(ctx, cc+8, cc+9, 8, 14,5, 12,keystream[8]);
-      step_P(ctx, cc+9, cc+10,9, 15,6, 13,keystream[9]);
-      step_P(ctx, cc+10,cc+11,10,0, 7, 14,keystream[10]);
-      step_P(ctx, cc+11,cc+12,11,1, 8, 15,keystream[11]);
-      step_P(ctx, cc+12,cc+13,12,2, 9, 0, keystream[12]);
-      step_P(ctx, cc+13,cc+14,13,3, 10,1, keystream[13]);
-      step_P(ctx, cc+14,cc+15,14,4, 11,2, keystream[14]);
-      step_P(ctx, cc+15,dd+0, 15,5, 12,3, keystream[15]);
-   }
-   else				    
-   {
-	  ctx->counter1024 = (ctx->counter1024 + 16) & 0x3ff;
-      step_Q(ctx, 512+cc+0, 512+cc+1, 0, 6, 13,4, keystream[0]);
-      step_Q(ctx, 512+cc+1, 512+cc+2, 1, 7, 14,5, keystream[1]);
-      step_Q(ctx, 512+cc+2, 512+cc+3, 2, 8, 15,6, keystream[2]);
-      step_Q(ctx, 512+cc+3, 512+cc+4, 3, 9, 0, 7, keystream[3]);
-      step_Q(ctx, 512+cc+4, 512+cc+5, 4, 10,1, 8, keystream[4]);
-      step_Q(ctx, 512+cc+5, 512+cc+6, 5, 11,2, 9, keystream[5]);
-      step_Q(ctx, 512+cc+6, 512+cc+7, 6, 12,3, 10,keystream[6]);
-      step_Q(ctx, 512+cc+7, 512+cc+8, 7, 13,4, 11,keystream[7]);
-      step_Q(ctx, 512+cc+8, 512+cc+9, 8, 14,5, 12,keystream[8]);
-      step_Q(ctx, 512+cc+9, 512+cc+10,9, 15,6, 13,keystream[9]);
-      step_Q(ctx, 512+cc+10,512+cc+11,10,0, 7, 14,keystream[10]);
-      step_Q(ctx, 512+cc+11,512+cc+12,11,1, 8, 15,keystream[11]);
-      step_Q(ctx, 512+cc+12,512+cc+13,12,2, 9, 0, keystream[12]);
-      step_Q(ctx, 512+cc+13,512+cc+14,13,3, 10,1, keystream[13]);
-      step_Q(ctx, 512+cc+14,512+cc+15,14,4, 11,2, keystream[14]);
-      step_Q(ctx, 512+cc+15,512+dd+0, 15,5, 12,3, keystream[15]);
-   }
-}
-
-
-/* The following defines the initialization functions */
-#define f1(x)  (rotrFixed((x),7)  ^ rotrFixed((x),18) ^ ((x) >> 3))
-#define f2(x)  (rotrFixed((x),17) ^ rotrFixed((x),19) ^ ((x) >> 10))
-
-/*update table P*/
-#define update_P(ctx,u,v,a,b,c,d){                  \
-     word32 tem0,tem1,tem2,tem3;                    \
-     tem0 = rotrFixed((ctx->T[(v)]),23);            \
-     tem1 = rotrFixed((ctx->X[(c)]),10);            \
-     tem2 = rotrFixed((ctx->X[(b)]),8);             \
-     h1((ctx),(ctx->X[(d)]),tem3);                  \
-     (ctx->T[(u)]) = ((ctx->T[(u)]) + tem2+(tem0^tem1)) ^ tem3;     \
-     (ctx->X[(a)]) = (ctx->T[(u)]);                 \
-}  
-
-/*update table Q*/
-#define update_Q(ctx,u,v,a,b,c,d){                  \
-     word32 tem0,tem1,tem2,tem3;                    \
-     tem0 = rotrFixed((ctx->T[(v)]),(32-23));       \
-     tem1 = rotrFixed((ctx->Y[(c)]),(32-10));       \
-     tem2 = rotrFixed((ctx->Y[(b)]),(32-8));        \
-     h2((ctx),(ctx->Y[(d)]),tem3);                  \
-     (ctx->T[(u)]) = ((ctx->T[(u)]) + tem2+(tem0^tem1)) ^ tem3;     \
-     (ctx->Y[(a)]) = (ctx->T[(u)]);                 \
-}     
-
-/*16 steps of HC-128, without generating keystream, */
-/*but use the outputs to update P and Q*/
-static void setup_update(HC128* ctx)  /*each time 16 steps*/
-{
-   word32 cc,dd;
-   cc = ctx->counter1024 & 0x1ff;
-   dd = (cc+16)&0x1ff;
-
-   if (ctx->counter1024 < 512)	
-   {   		
-      ctx->counter1024 = (ctx->counter1024 + 16) & 0x3ff;
-      update_P(ctx, cc+0, cc+1, 0, 6, 13, 4);
-      update_P(ctx, cc+1, cc+2, 1, 7, 14, 5);
-      update_P(ctx, cc+2, cc+3, 2, 8, 15, 6);
-      update_P(ctx, cc+3, cc+4, 3, 9, 0,  7);
-      update_P(ctx, cc+4, cc+5, 4, 10,1,  8);
-      update_P(ctx, cc+5, cc+6, 5, 11,2,  9);
-      update_P(ctx, cc+6, cc+7, 6, 12,3,  10);
-      update_P(ctx, cc+7, cc+8, 7, 13,4,  11);
-      update_P(ctx, cc+8, cc+9, 8, 14,5,  12);
-      update_P(ctx, cc+9, cc+10,9, 15,6,  13);
-      update_P(ctx, cc+10,cc+11,10,0, 7,  14);
-      update_P(ctx, cc+11,cc+12,11,1, 8,  15);
-      update_P(ctx, cc+12,cc+13,12,2, 9,  0);
-      update_P(ctx, cc+13,cc+14,13,3, 10, 1);
-      update_P(ctx, cc+14,cc+15,14,4, 11, 2);
-      update_P(ctx, cc+15,dd+0, 15,5, 12, 3);   
-   }
-   else				    
-   {
-      ctx->counter1024 = (ctx->counter1024 + 16) & 0x3ff;
-      update_Q(ctx, 512+cc+0, 512+cc+1, 0, 6, 13, 4);
-      update_Q(ctx, 512+cc+1, 512+cc+2, 1, 7, 14, 5);
-      update_Q(ctx, 512+cc+2, 512+cc+3, 2, 8, 15, 6);
-      update_Q(ctx, 512+cc+3, 512+cc+4, 3, 9, 0,  7);
-      update_Q(ctx, 512+cc+4, 512+cc+5, 4, 10,1,  8);
-      update_Q(ctx, 512+cc+5, 512+cc+6, 5, 11,2,  9);
-      update_Q(ctx, 512+cc+6, 512+cc+7, 6, 12,3,  10);
-      update_Q(ctx, 512+cc+7, 512+cc+8, 7, 13,4,  11);
-      update_Q(ctx, 512+cc+8, 512+cc+9, 8, 14,5,  12);
-      update_Q(ctx, 512+cc+9, 512+cc+10,9, 15,6,  13);
-      update_Q(ctx, 512+cc+10,512+cc+11,10,0, 7,  14);
-      update_Q(ctx, 512+cc+11,512+cc+12,11,1, 8,  15);
-      update_Q(ctx, 512+cc+12,512+cc+13,12,2, 9,  0);
-      update_Q(ctx, 512+cc+13,512+cc+14,13,3, 10, 1);
-      update_Q(ctx, 512+cc+14,512+cc+15,14,4, 11, 2);
-      update_Q(ctx, 512+cc+15,512+dd+0, 15,5, 12, 3); 
-   }       
-}
-
-
-/* for the 128-bit key:  key[0]...key[15]
-*  key[0] is the least significant byte of ctx->key[0] (K_0);
-*  key[3] is the most significant byte of ctx->key[0]  (K_0);
-*  ...
-*  key[12] is the least significant byte of ctx->key[3] (K_3)
-*  key[15] is the most significant byte of ctx->key[3]  (K_3)
-*
-*  for the 128-bit iv:  iv[0]...iv[15]
-*  iv[0] is the least significant byte of ctx->iv[0] (IV_0);
-*  iv[3] is the most significant byte of ctx->iv[0]  (IV_0);
-*  ...
-*  iv[12] is the least significant byte of ctx->iv[3] (IV_3)
-*  iv[15] is the most significant byte of ctx->iv[3]  (IV_3)
-*/
-
-
-
-static void Hc128_SetIV(HC128* ctx, const byte* inIv)
-{ 
-    word32 i;
-    word32 iv[4];
-
-    if (inIv)
-        XMEMCPY(iv, inIv, sizeof(iv));
-    else
-        XMEMSET(iv,    0, sizeof(iv));
-    
-	for (i = 0; i < (128 >> 5); i++)
-        ctx->iv[i] = LITTLE32(iv[i]);
-	
-    for (; i < 8; i++) ctx->iv[i] = ctx->iv[i-4];
-  
-    /* expand the key and IV into the table T */ 
-    /* (expand the key and IV into the table P and Q) */ 
-	
-	for (i = 0; i < 8;  i++)   ctx->T[i] = ctx->key[i];
-	for (i = 8; i < 16; i++)   ctx->T[i] = ctx->iv[i-8];
-
-    for (i = 16; i < (256+16); i++) 
-		ctx->T[i] = f2(ctx->T[i-2]) + ctx->T[i-7] + f1(ctx->T[i-15]) +
-                                                       ctx->T[i-16]+i;
-    
-	for (i = 0; i < 16;  i++)  ctx->T[i] = ctx->T[256+i];
-
-	for (i = 16; i < 1024; i++) 
-		ctx->T[i] = f2(ctx->T[i-2]) + ctx->T[i-7] + f1(ctx->T[i-15]) +
-                                                       ctx->T[i-16]+256+i;
-    
-    /* initialize counter1024, X and Y */
-	ctx->counter1024 = 0;
-	for (i = 0; i < 16; i++) ctx->X[i] = ctx->T[512-16+i];
-    for (i = 0; i < 16; i++) ctx->Y[i] = ctx->T[512+512-16+i];
-    
-    /* run the cipher 1024 steps before generating the output */
-	for (i = 0; i < 64; i++)  setup_update(ctx);  
-}
-
-
-static INLINE int DoKey(HC128* ctx, const byte* key, const byte* iv)
-{ 
-  word32 i;  
-
-  /* Key size in bits 128 */ 
-  for (i = 0; i < (128 >> 5); i++)
-      ctx->key[i] = LITTLE32(((word32*)key)[i]);
- 
-  for ( ; i < 8 ; i++) ctx->key[i] = ctx->key[i-4];
-
-  Hc128_SetIV(ctx, iv);
-
-  return 0;
-}
-
-
-/* Key setup */
-int wc_Hc128_SetKey(HC128* ctx, const byte* key, const byte* iv)
-{
-#ifdef XSTREAM_ALIGN
-    if ((wolfssl_word)key % 4) {
-        int alignKey[4];
-
-        /* iv gets aligned in SetIV */
-        WOLFSSL_MSG("Hc128SetKey unaligned key");
-
-        XMEMCPY(alignKey, key, sizeof(alignKey));
-
-        return DoKey(ctx, (const byte*)alignKey, iv);
-    }
-#endif /* XSTREAM_ALIGN */
-
-    return DoKey(ctx, key, iv);
-}
-
-
-
-/* The following defines the encryption of data stream */
-static INLINE int DoProcess(HC128* ctx, byte* output, const byte* input,
-                            word32 msglen)
-{
-  word32 i, keystream[16];
-
-  for ( ; msglen >= 64; msglen -= 64, input += 64, output += 64)
-  {
-	  generate_keystream(ctx, keystream);
-
-      /* unroll loop */
-	  ((word32*)output)[0]  = ((word32*)input)[0]  ^ LITTLE32(keystream[0]);
-	  ((word32*)output)[1]  = ((word32*)input)[1]  ^ LITTLE32(keystream[1]);
-	  ((word32*)output)[2]  = ((word32*)input)[2]  ^ LITTLE32(keystream[2]);
-	  ((word32*)output)[3]  = ((word32*)input)[3]  ^ LITTLE32(keystream[3]);
-	  ((word32*)output)[4]  = ((word32*)input)[4]  ^ LITTLE32(keystream[4]);
-	  ((word32*)output)[5]  = ((word32*)input)[5]  ^ LITTLE32(keystream[5]);
-	  ((word32*)output)[6]  = ((word32*)input)[6]  ^ LITTLE32(keystream[6]);
-	  ((word32*)output)[7]  = ((word32*)input)[7]  ^ LITTLE32(keystream[7]);
-	  ((word32*)output)[8]  = ((word32*)input)[8]  ^ LITTLE32(keystream[8]);
-	  ((word32*)output)[9]  = ((word32*)input)[9]  ^ LITTLE32(keystream[9]);
-	  ((word32*)output)[10] = ((word32*)input)[10] ^ LITTLE32(keystream[10]);
-	  ((word32*)output)[11] = ((word32*)input)[11] ^ LITTLE32(keystream[11]);
-	  ((word32*)output)[12] = ((word32*)input)[12] ^ LITTLE32(keystream[12]);
-	  ((word32*)output)[13] = ((word32*)input)[13] ^ LITTLE32(keystream[13]);
-	  ((word32*)output)[14] = ((word32*)input)[14] ^ LITTLE32(keystream[14]);
-	  ((word32*)output)[15] = ((word32*)input)[15] ^ LITTLE32(keystream[15]);
-  }
-
-  if (msglen > 0)
-  {
-      XMEMSET(keystream, 0, sizeof(keystream)); /* hush the static analysis */
-      generate_keystream(ctx, keystream);
-
-#ifdef BIG_ENDIAN_ORDER
-      {
-          word32 wordsLeft = msglen / sizeof(word32);
-          if (msglen % sizeof(word32)) wordsLeft++;
-          
-          ByteReverseWords(keystream, keystream, wordsLeft * sizeof(word32));
-      }
-#endif
-
-      for (i = 0; i < msglen; i++)
-	      output[i] = input[i] ^ ((byte*)keystream)[i];
-  }
-
-  return 0;
-}
-
-
-/* Encrypt/decrypt a message of any size */
-int wc_Hc128_Process(HC128* ctx, byte* output, const byte* input, word32 msglen)
-{
-#ifdef XSTREAM_ALIGN
-    if ((wolfssl_word)input % 4 || (wolfssl_word)output % 4) {
-        #ifndef NO_WOLFSSL_ALLOC_ALIGN
-            byte* tmp;
-            WOLFSSL_MSG("Hc128Process unaligned");
-
-            tmp = (byte*)XMALLOC(msglen, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            if (tmp == NULL) return MEMORY_E;
-
-            XMEMCPY(tmp, input, msglen);
-            DoProcess(ctx, tmp, tmp, msglen);
-            XMEMCPY(output, tmp, msglen);
-
-            XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-            return 0;
-        #else
-            return BAD_ALIGN_E;
-        #endif
-    }
-#endif /* XSTREAM_ALIGN */
-
-    return DoProcess(ctx, output, input, msglen);
-}
-
-
-#else  /* HAVE_HC128 */
-
-
-#ifdef _MSC_VER
-    /* 4206 warning for blank file */
-    #pragma warning(disable: 4206)
-#endif
-
-
-#endif /* HAVE_HC128 */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/hmac.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/hmac.c
deleted file mode 100755
index 242adfa..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/hmac.c
+++ /dev/null
@@ -1,879 +0,0 @@
-/* hmac.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef NO_HMAC
-
-#include 
-
-#ifdef HAVE_FIPS
-/* does init */
-int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 keySz)
-{
-    return HmacSetKey_fips(hmac, type, key, keySz);
-}
-
-
-int wc_HmacUpdate(Hmac* hmac, const byte* in, word32 sz)
-{
-    return HmacUpdate_fips(hmac, in, sz);
-}
-
-
-int wc_HmacFinal(Hmac* hmac, byte* out)
-{
-    return HmacFinal_fips(hmac, out);
-}
-
-
-#ifdef HAVE_CAVIUM
-    int  wc_HmacInitCavium(Hmac* hmac, int i)
-    {
-        return HmacInitCavium(hmac, i);
-    }
-
-
-    void wc_HmacFreeCavium(Hmac* hmac)
-    {
-        HmacFreeCavium(hmac);
-    }
-#endif
-
-int wolfSSL_GetHmacMaxSize(void)
-{
-    return CyaSSL_GetHmacMaxSize();
-}
-
-#ifdef HAVE_HKDF
-
-int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
-                    const byte* salt, word32 saltSz,
-                    const byte* info, word32 infoSz,
-                    byte* out, word32 outSz)
-{
-    return HKDF(type, inKey, inKeySz, salt, saltSz, info, infoSz, out, outSz);
-}
-
-
-#endif /* HAVE_HKDF */
-#else /* else build without fips */
-#ifdef WOLFSSL_PIC32MZ_HASH
-
-#define wc_InitMd5   wc_InitMd5_sw
-#define wc_Md5Update wc_Md5Update_sw
-#define wc_Md5Final  wc_Md5Final_sw
-
-#define wc_InitSha   wc_InitSha_sw
-#define wc_ShaUpdate wc_ShaUpdate_sw
-#define wc_ShaFinal  wc_ShaFinal_sw
-
-#define wc_InitSha256   wc_InitSha256_sw
-#define wc_Sha256Update wc_Sha256Update_sw
-#define wc_Sha256Final  wc_Sha256Final_sw
-
-#endif
-
-#ifdef HAVE_FIPS
-    /* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */
-    #define FIPS_NO_WRAPPERS
-#endif
-
-#include 
-
-
-#ifdef HAVE_CAVIUM
-    static void HmacCaviumFinal(Hmac* hmac, byte* hash);
-    static void HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length);
-    static void HmacCaviumSetKey(Hmac* hmac, int type, const byte* key,
-                                 word32 length);
-#endif
-
-static int InitHmac(Hmac* hmac, int type)
-{
-    int ret = 0;
-
-    hmac->innerHashKeyed = 0;
-    hmac->macType = (byte)type;
-
-    if (!(type == MD5 || type == SHA    || type == SHA256 || type == SHA384
-                      || type == SHA512 || type == BLAKE2B_ID))
-        return BAD_FUNC_ARG;
-
-    switch (type) {
-        #ifndef NO_MD5
-        case MD5:
-            wc_InitMd5(&hmac->hash.md5);
-        break;
-        #endif
-
-        #ifndef NO_SHA
-        case SHA:
-            ret = wc_InitSha(&hmac->hash.sha);
-        break;
-        #endif
-        
-        #ifndef NO_SHA256
-        case SHA256:
-            ret = wc_InitSha256(&hmac->hash.sha256);
-        break;
-        #endif
-        
-        #ifdef WOLFSSL_SHA384
-        case SHA384:
-            ret = wc_InitSha384(&hmac->hash.sha384);
-        break;
-        #endif
-        
-        #ifdef WOLFSSL_SHA512
-        case SHA512:
-            ret = wc_InitSha512(&hmac->hash.sha512);
-        break;
-        #endif
-        
-        #ifdef HAVE_BLAKE2 
-        case BLAKE2B_ID:
-            ret = wc_InitBlake2b(&hmac->hash.blake2b, BLAKE2B_256);
-        break;
-        #endif
-        
-        default:
-            return BAD_FUNC_ARG;
-    }
-
-    return ret;
-}
-
-
-int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
-{
-    byte*  ip = (byte*) hmac->ipad;
-    byte*  op = (byte*) hmac->opad;
-    word32 i, hmac_block_size = 0;
-    int    ret;
-
-#ifdef HAVE_CAVIUM
-    if (hmac->magic == WOLFSSL_HMAC_CAVIUM_MAGIC)
-        return HmacCaviumSetKey(hmac, type, key, length);
-#endif
-
-    ret = InitHmac(hmac, type);
-    if (ret != 0)
-        return ret;
-
-#ifdef HAVE_FIPS
-    if (length < HMAC_FIPS_MIN_KEY)
-        return HMAC_MIN_KEYLEN_E;
-#endif
-
-    switch (hmac->macType) {
-        #ifndef NO_MD5
-        case MD5:
-        {
-            hmac_block_size = MD5_BLOCK_SIZE;
-            if (length <= MD5_BLOCK_SIZE) {
-                XMEMCPY(ip, key, length);
-            }
-            else {
-                wc_Md5Update(&hmac->hash.md5, key, length);
-                wc_Md5Final(&hmac->hash.md5, ip);
-                length = MD5_DIGEST_SIZE;
-            }
-        }
-        break;
-        #endif
-
-        #ifndef NO_SHA
-        case SHA:
-        {
-            hmac_block_size = SHA_BLOCK_SIZE;
-            if (length <= SHA_BLOCK_SIZE) {
-                XMEMCPY(ip, key, length);
-            }
-            else {
-                wc_ShaUpdate(&hmac->hash.sha, key, length);
-                wc_ShaFinal(&hmac->hash.sha, ip);
-                length = SHA_DIGEST_SIZE;
-            }
-        }
-        break;
-        #endif
-
-        #ifndef NO_SHA256
-        case SHA256:
-        {
-    		hmac_block_size = SHA256_BLOCK_SIZE;
-            if (length <= SHA256_BLOCK_SIZE) {
-                XMEMCPY(ip, key, length);
-            }
-            else {
-                ret = wc_Sha256Update(&hmac->hash.sha256, key, length);
-                if (ret != 0)
-                    return ret;
-
-                ret = wc_Sha256Final(&hmac->hash.sha256, ip);
-                if (ret != 0)
-                    return ret;
-
-                length = SHA256_DIGEST_SIZE;
-            }
-        }
-        break;
-        #endif
-
-        #ifdef WOLFSSL_SHA384
-        case SHA384:
-        {
-            hmac_block_size = SHA384_BLOCK_SIZE;
-            if (length <= SHA384_BLOCK_SIZE) {
-                XMEMCPY(ip, key, length);
-            }
-            else {
-                ret = wc_Sha384Update(&hmac->hash.sha384, key, length);
-                if (ret != 0)
-                    return ret;
-
-                ret = wc_Sha384Final(&hmac->hash.sha384, ip);
-                if (ret != 0)
-                    return ret;
-
-                length = SHA384_DIGEST_SIZE;
-            }
-        }
-        break;
-        #endif
-
-        #ifdef WOLFSSL_SHA512
-        case SHA512:
-        {
-            hmac_block_size = SHA512_BLOCK_SIZE;
-            if (length <= SHA512_BLOCK_SIZE) {
-                XMEMCPY(ip, key, length);
-            }
-            else {
-                ret = wc_Sha512Update(&hmac->hash.sha512, key, length);
-                if (ret != 0)
-                    return ret;
-
-                ret = wc_Sha512Final(&hmac->hash.sha512, ip);
-                if (ret != 0)
-                    return ret;
-
-                length = SHA512_DIGEST_SIZE;
-            }
-        }
-        break;
-        #endif
-
-        #ifdef HAVE_BLAKE2 
-        case BLAKE2B_ID:
-        {
-            hmac_block_size = BLAKE2B_BLOCKBYTES;
-            if (length <= BLAKE2B_BLOCKBYTES) {
-                XMEMCPY(ip, key, length);
-            }
-            else {
-                ret = wc_Blake2bUpdate(&hmac->hash.blake2b, key, length);
-                if (ret != 0)
-                    return ret;
-
-                ret = wc_Blake2bFinal(&hmac->hash.blake2b, ip, BLAKE2B_256);
-                if (ret != 0)
-                    return ret;
-
-                length = BLAKE2B_256;
-            }
-        }
-        break;
-        #endif
-
-        default:
-            return BAD_FUNC_ARG;
-    }
-    if (length < hmac_block_size)
-        XMEMSET(ip + length, 0, hmac_block_size - length);
-
-    for(i = 0; i < hmac_block_size; i++) {
-        op[i] = ip[i] ^ OPAD;
-        ip[i] ^= IPAD;
-    }
-    return 0;
-}
-
-
-static int HmacKeyInnerHash(Hmac* hmac)
-{
-    int ret = 0;
-
-    switch (hmac->macType) {
-        #ifndef NO_MD5
-        case MD5:
-            wc_Md5Update(&hmac->hash.md5, (byte*) hmac->ipad, MD5_BLOCK_SIZE);
-        break;
-        #endif
-
-        #ifndef NO_SHA
-        case SHA:
-            wc_ShaUpdate(&hmac->hash.sha, (byte*) hmac->ipad, SHA_BLOCK_SIZE);
-        break;
-        #endif
-
-        #ifndef NO_SHA256
-        case SHA256:
-            ret = wc_Sha256Update(&hmac->hash.sha256,
-                                         (byte*) hmac->ipad, SHA256_BLOCK_SIZE);
-            if (ret != 0)
-                return ret;
-        break;
-        #endif
-
-        #ifdef WOLFSSL_SHA384
-        case SHA384:
-            ret = wc_Sha384Update(&hmac->hash.sha384,
-                                         (byte*) hmac->ipad, SHA384_BLOCK_SIZE);
-            if (ret != 0)
-                return ret;
-        break;
-        #endif
-
-        #ifdef WOLFSSL_SHA512
-        case SHA512:
-            ret = wc_Sha512Update(&hmac->hash.sha512,
-                                         (byte*) hmac->ipad, SHA512_BLOCK_SIZE);
-            if (ret != 0)
-                return ret;
-        break;
-        #endif
-
-        #ifdef HAVE_BLAKE2 
-        case BLAKE2B_ID:
-            ret = wc_Blake2bUpdate(&hmac->hash.blake2b,
-                                         (byte*) hmac->ipad,BLAKE2B_BLOCKBYTES);
-            if (ret != 0)
-                return ret;
-        break;
-        #endif
-
-        default:
-        break;
-    }
-
-    hmac->innerHashKeyed = 1;
-
-    return ret;
-}
-
-
-int wc_HmacUpdate(Hmac* hmac, const byte* msg, word32 length)
-{
-    int ret;
-
-#ifdef HAVE_CAVIUM
-    if (hmac->magic == WOLFSSL_HMAC_CAVIUM_MAGIC)
-        return HmacCaviumUpdate(hmac, msg, length);
-#endif
-
-    if (!hmac->innerHashKeyed) {
-        ret = HmacKeyInnerHash(hmac);
-        if (ret != 0)
-            return ret;
-    }
-
-    switch (hmac->macType) {
-        #ifndef NO_MD5
-        case MD5:
-            wc_Md5Update(&hmac->hash.md5, msg, length);
-        break;
-        #endif
-
-        #ifndef NO_SHA
-        case SHA:
-            wc_ShaUpdate(&hmac->hash.sha, msg, length);
-        break;
-        #endif
-
-        #ifndef NO_SHA256
-        case SHA256:
-            ret = wc_Sha256Update(&hmac->hash.sha256, msg, length);
-            if (ret != 0)
-                return ret;
-        break;
-        #endif
-
-        #ifdef WOLFSSL_SHA384
-        case SHA384:
-            ret = wc_Sha384Update(&hmac->hash.sha384, msg, length);
-            if (ret != 0)
-                return ret;
-        break;
-        #endif
-
-        #ifdef WOLFSSL_SHA512
-        case SHA512:
-            ret = wc_Sha512Update(&hmac->hash.sha512, msg, length);
-            if (ret != 0)
-                return ret;
-        break;
-        #endif
-
-        #ifdef HAVE_BLAKE2 
-        case BLAKE2B_ID:
-            ret = wc_Blake2bUpdate(&hmac->hash.blake2b, msg, length);
-            if (ret != 0)
-                return ret;
-        break;
-        #endif
-
-        default:
-        break;
-    }
-
-    return 0;
-}
-
-
-int wc_HmacFinal(Hmac* hmac, byte* hash)
-{
-    int ret;
-
-#ifdef HAVE_CAVIUM
-    if (hmac->magic == WOLFSSL_HMAC_CAVIUM_MAGIC)
-        return HmacCaviumFinal(hmac, hash);
-#endif
-
-    if (!hmac->innerHashKeyed) {
-        ret = HmacKeyInnerHash(hmac);
-        if (ret != 0)
-            return ret;
-    }
-
-    switch (hmac->macType) {
-        #ifndef NO_MD5
-        case MD5:
-        {
-            wc_Md5Final(&hmac->hash.md5, (byte*) hmac->innerHash);
-
-            wc_Md5Update(&hmac->hash.md5, (byte*) hmac->opad, MD5_BLOCK_SIZE);
-            wc_Md5Update(&hmac->hash.md5,
-                                     (byte*) hmac->innerHash, MD5_DIGEST_SIZE);
-
-            wc_Md5Final(&hmac->hash.md5, hash);
-        }
-        break;
-        #endif
-
-        #ifndef NO_SHA
-        case SHA:
-        {
-            wc_ShaFinal(&hmac->hash.sha, (byte*) hmac->innerHash);
-
-            wc_ShaUpdate(&hmac->hash.sha, (byte*) hmac->opad, SHA_BLOCK_SIZE);
-            wc_ShaUpdate(&hmac->hash.sha,
-                                     (byte*) hmac->innerHash, SHA_DIGEST_SIZE);
-
-            wc_ShaFinal(&hmac->hash.sha, hash);
-        }
-        break;
-        #endif
-
-        #ifndef NO_SHA256
-        case SHA256:
-        {
-            ret = wc_Sha256Final(&hmac->hash.sha256, (byte*) hmac->innerHash);
-            if (ret != 0)
-                return ret;
-
-            ret = wc_Sha256Update(&hmac->hash.sha256,
-                                (byte*) hmac->opad, SHA256_BLOCK_SIZE);
-            if (ret != 0)
-                return ret;
-
-            ret = wc_Sha256Update(&hmac->hash.sha256,
-                                (byte*) hmac->innerHash, SHA256_DIGEST_SIZE);
-            if (ret != 0)
-                return ret;
-
-            ret = wc_Sha256Final(&hmac->hash.sha256, hash);
-            if (ret != 0)
-                return ret;
-        }
-        break;
-        #endif
-
-        #ifdef WOLFSSL_SHA384
-        case SHA384:
-        {
-            ret = wc_Sha384Final(&hmac->hash.sha384, (byte*) hmac->innerHash);
-            if (ret != 0)
-                return ret;
-
-            ret = wc_Sha384Update(&hmac->hash.sha384,
-                                 (byte*) hmac->opad, SHA384_BLOCK_SIZE);
-            if (ret != 0)
-                return ret;
-
-            ret = wc_Sha384Update(&hmac->hash.sha384,
-                                 (byte*) hmac->innerHash, SHA384_DIGEST_SIZE);
-            if (ret != 0)
-                return ret;
-
-            ret = wc_Sha384Final(&hmac->hash.sha384, hash);
-            if (ret != 0)
-                return ret;
-        }
-        break;
-        #endif
-
-        #ifdef WOLFSSL_SHA512
-        case SHA512:
-        {
-            ret = wc_Sha512Final(&hmac->hash.sha512, (byte*) hmac->innerHash);
-            if (ret != 0)
-                return ret;
-
-            ret = wc_Sha512Update(&hmac->hash.sha512,
-                                 (byte*) hmac->opad, SHA512_BLOCK_SIZE);
-            if (ret != 0)
-                return ret;
-
-            ret = wc_Sha512Update(&hmac->hash.sha512,
-                                 (byte*) hmac->innerHash, SHA512_DIGEST_SIZE);
-            if (ret != 0)
-                return ret;
-
-            ret = wc_Sha512Final(&hmac->hash.sha512, hash);
-            if (ret != 0)
-                return ret;
-        }
-        break;
-        #endif
-
-        #ifdef HAVE_BLAKE2 
-        case BLAKE2B_ID:
-        {
-            ret = wc_Blake2bFinal(&hmac->hash.blake2b, (byte*) hmac->innerHash,
-                         BLAKE2B_256);
-            if (ret != 0)
-                return ret;
-
-            ret = wc_Blake2bUpdate(&hmac->hash.blake2b,
-                                 (byte*) hmac->opad, BLAKE2B_BLOCKBYTES);
-            if (ret != 0)
-                return ret;
-
-            ret = wc_Blake2bUpdate(&hmac->hash.blake2b,
-                                 (byte*) hmac->innerHash, BLAKE2B_256);
-            if (ret != 0)
-                return ret;
-
-            ret = wc_Blake2bFinal(&hmac->hash.blake2b, hash, BLAKE2B_256);
-            if (ret != 0)
-                return ret;
-        }
-        break;
-        #endif
-
-        default:
-        break;
-    }
-
-    hmac->innerHashKeyed = 0;
-
-    return 0;
-}
-
-
-#ifdef HAVE_CAVIUM
-
-/* Initiliaze Hmac for use with Nitrox device */
-int wc_HmacInitCavium(Hmac* hmac, int devId)
-{
-    if (hmac == NULL)
-        return -1;
-
-    if (CspAllocContext(CONTEXT_SSL, &hmac->contextHandle, devId) != 0)
-        return -1;
-
-    hmac->keyLen  = 0;
-    hmac->dataLen = 0;
-    hmac->type    = 0;
-    hmac->devId   = devId;
-    hmac->magic   = WOLFSSL_HMAC_CAVIUM_MAGIC;
-    hmac->data    = NULL;        /* buffered input data */
-   
-    hmac->innerHashKeyed = 0;
-
-    return 0;
-}
-
-
-/* Free Hmac from use with Nitrox device */
-void wc_HmacFreeCavium(Hmac* hmac)
-{
-    if (hmac == NULL)
-        return;
-
-    CspFreeContext(CONTEXT_SSL, hmac->contextHandle, hmac->devId);
-    hmac->magic = 0;
-    XFREE(hmac->data, NULL, DYNAMIC_TYPE_CAVIUM_TMP);
-    hmac->data = NULL;
-}
-
-
-static void HmacCaviumFinal(Hmac* hmac, byte* hash)
-{
-    word32 requestId;
-
-    if (CspHmac(CAVIUM_BLOCKING, hmac->type, NULL, hmac->keyLen,
-                (byte*)hmac->ipad, hmac->dataLen, hmac->data, hash, &requestId,
-                hmac->devId) != 0) {
-        WOLFSSL_MSG("Cavium Hmac failed");
-    } 
-    hmac->innerHashKeyed = 0;  /* tell update to start over if used again */
-}
-
-
-static void HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length)
-{
-    word16 add = (word16)length;
-    word32 total;
-    byte*  tmp;
-
-    if (length > WOLFSSL_MAX_16BIT) {
-        WOLFSSL_MSG("Too big msg for cavium hmac");
-        return;
-    }
-
-    if (hmac->innerHashKeyed == 0) {  /* starting new */
-        hmac->dataLen        = 0;
-        hmac->innerHashKeyed = 1;
-    }
-
-    total = add + hmac->dataLen;
-    if (total > WOLFSSL_MAX_16BIT) {
-        WOLFSSL_MSG("Too big msg for cavium hmac");
-        return;
-    }
-
-    tmp = XMALLOC(hmac->dataLen + add, NULL,DYNAMIC_TYPE_CAVIUM_TMP);
-    if (tmp == NULL) {
-        WOLFSSL_MSG("Out of memory for cavium update");
-        return;
-    }
-    if (hmac->dataLen)
-        XMEMCPY(tmp, hmac->data,  hmac->dataLen);
-    XMEMCPY(tmp + hmac->dataLen, msg, add);
-        
-    hmac->dataLen += add;
-    XFREE(hmac->data, NULL, DYNAMIC_TYPE_CAVIUM_TMP);
-    hmac->data = tmp;
-}
-
-
-static void HmacCaviumSetKey(Hmac* hmac, int type, const byte* key,
-                             word32 length)
-{
-    hmac->macType = (byte)type;
-    if (type == MD5)
-        hmac->type = MD5_TYPE;
-    else if (type == SHA)
-        hmac->type = SHA1_TYPE;
-    else if (type == SHA256)
-        hmac->type = SHA256_TYPE;
-    else  {
-        WOLFSSL_MSG("unsupported cavium hmac type");
-    }
-
-    hmac->innerHashKeyed = 0;  /* should we key Startup flag */
-
-    hmac->keyLen = (word16)length;
-    /* store key in ipad */
-    XMEMCPY(hmac->ipad, key, length);
-}
-
-#endif /* HAVE_CAVIUM */
-
-int wolfSSL_GetHmacMaxSize(void)
-{
-    return MAX_DIGEST_SIZE;
-}
-
-#ifdef HAVE_HKDF
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-
-static INLINE int GetHashSizeByType(int type)
-{
-    if (!(type == MD5 || type == SHA    || type == SHA256 || type == SHA384
-                      || type == SHA512 || type == BLAKE2B_ID))
-        return BAD_FUNC_ARG;
-
-    switch (type) {
-        #ifndef NO_MD5
-        case MD5:
-            return MD5_DIGEST_SIZE;
-        break;
-        #endif
-
-        #ifndef NO_SHA
-        case SHA:
-            return SHA_DIGEST_SIZE;
-        break;
-        #endif
-        
-        #ifndef NO_SHA256
-        case SHA256:
-            return SHA256_DIGEST_SIZE;
-        break;
-        #endif
-        
-        #ifdef WOLFSSL_SHA384
-        case SHA384:
-            return SHA384_DIGEST_SIZE;
-        break;
-        #endif
-        
-        #ifdef WOLFSSL_SHA512
-        case SHA512:
-            return SHA512_DIGEST_SIZE;
-        break;
-        #endif
-        
-        #ifdef HAVE_BLAKE2 
-        case BLAKE2B_ID:
-            return BLAKE2B_OUTBYTES;
-        break;
-        #endif
-        
-        default:
-            return BAD_FUNC_ARG;
-        break;
-    }
-}
-
-
-/* HMAC-KDF with hash type, optional salt and info, return 0 on success */
-int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
-                   const byte* salt,  word32 saltSz,
-                   const byte* info,  word32 infoSz,
-                   byte* out,         word32 outSz)
-{
-    Hmac   myHmac;
-#ifdef WOLFSSL_SMALL_STACK
-    byte* tmp;
-    byte* prk;
-#else
-    byte   tmp[MAX_DIGEST_SIZE]; /* localSalt helper and T */
-    byte   prk[MAX_DIGEST_SIZE];
-#endif
-    const  byte* localSalt;  /* either points to user input or tmp */
-    int    hashSz = GetHashSizeByType(type);
-    word32 outIdx = 0;
-    byte   n = 0x1;
-    int    ret;
-
-    if (hashSz < 0)
-        return BAD_FUNC_ARG;
-
-#ifdef WOLFSSL_SMALL_STACK
-    tmp = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (tmp == NULL)
-        return MEMORY_E;
-
-    prk = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (prk == NULL) {
-        XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#endif
-
-    localSalt = salt;
-    if (localSalt == NULL) {
-        XMEMSET(tmp, 0, hashSz);
-        localSalt = tmp;
-        saltSz    = hashSz;
-    }
-    
-    do {
-    ret = wc_HmacSetKey(&myHmac, type, localSalt, saltSz);
-    if (ret != 0)
-        break;
-    ret = wc_HmacUpdate(&myHmac, inKey, inKeySz);
-    if (ret != 0)
-        break;
-    ret = wc_HmacFinal(&myHmac,  prk);
-    } while (0);
-
-    if (ret == 0) {
-        while (outIdx < outSz) {
-            int    tmpSz = (n == 1) ? 0 : hashSz;
-            word32 left = outSz - outIdx;
-
-            ret = wc_HmacSetKey(&myHmac, type, prk, hashSz);
-            if (ret != 0)
-                break;
-            ret = wc_HmacUpdate(&myHmac, tmp, tmpSz);
-            if (ret != 0)
-                break;
-            ret = wc_HmacUpdate(&myHmac, info, infoSz);
-            if (ret != 0)
-                break;
-            ret = wc_HmacUpdate(&myHmac, &n, 1);
-            if (ret != 0)
-                break;
-            ret = wc_HmacFinal(&myHmac, tmp);
-            if (ret != 0)
-                break;
-
-            left = min(left, (word32)hashSz);
-            XMEMCPY(out+outIdx, tmp, left);
-
-            outIdx += hashSz;
-            n++;
-        }
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(prk, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-#endif /* HAVE_HKDF */
-
-#endif /* HAVE_FIPS */
-#endif /* NO_HMAC */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/include.am b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/include.am
deleted file mode 100755
index 2999215..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/include.am
+++ /dev/null
@@ -1,48 +0,0 @@
-# vim:ft=automake
-# All paths should be given relative to the root
-
-EXTRA_DIST += wolfcrypt/src/misc.c
-EXTRA_DIST += wolfcrypt/src/asm.c
-EXTRA_DIST += wolfcrypt/src/aes_asm.asm
-
-EXTRA_DIST += \
-              wolfcrypt/src/ecc_fp.c \
-              wolfcrypt/src/fp_mont_small.i \
-              wolfcrypt/src/fp_mul_comba_12.i \
-              wolfcrypt/src/fp_mul_comba_17.i \
-              wolfcrypt/src/fp_mul_comba_20.i \
-              wolfcrypt/src/fp_mul_comba_24.i \
-              wolfcrypt/src/fp_mul_comba_28.i \
-              wolfcrypt/src/fp_mul_comba_32.i \
-              wolfcrypt/src/fp_mul_comba_3.i \
-              wolfcrypt/src/fp_mul_comba_48.i \
-              wolfcrypt/src/fp_mul_comba_4.i \
-              wolfcrypt/src/fp_mul_comba_64.i \
-              wolfcrypt/src/fp_mul_comba_6.i \
-              wolfcrypt/src/fp_mul_comba_7.i \
-              wolfcrypt/src/fp_mul_comba_8.i \
-              wolfcrypt/src/fp_mul_comba_9.i \
-              wolfcrypt/src/fp_mul_comba_small_set.i \
-              wolfcrypt/src/fp_sqr_comba_12.i \
-              wolfcrypt/src/fp_sqr_comba_17.i \
-              wolfcrypt/src/fp_sqr_comba_20.i \
-              wolfcrypt/src/fp_sqr_comba_24.i \
-              wolfcrypt/src/fp_sqr_comba_28.i \
-              wolfcrypt/src/fp_sqr_comba_32.i \
-              wolfcrypt/src/fp_sqr_comba_3.i \
-              wolfcrypt/src/fp_sqr_comba_48.i \
-              wolfcrypt/src/fp_sqr_comba_4.i \
-              wolfcrypt/src/fp_sqr_comba_64.i \
-              wolfcrypt/src/fp_sqr_comba_6.i \
-              wolfcrypt/src/fp_sqr_comba_7.i \
-              wolfcrypt/src/fp_sqr_comba_8.i \
-              wolfcrypt/src/fp_sqr_comba_9.i \
-              wolfcrypt/src/fp_sqr_comba_small_set.i
-
-EXTRA_DIST += wolfcrypt/src/port/ti/ti-aes.c \
-              wolfcrypt/src/port/ti/ti-des3.c \
-              wolfcrypt/src/port/ti/ti-hash.c \
-              wolfcrypt/src/port/ti/ti-ccm.c \
-              wolfcrypt/src/port/pic32/pic32mz-hash.c
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/integer.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/integer.c
deleted file mode 100755
index b3ce420..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/integer.c
+++ /dev/null
@@ -1,4522 +0,0 @@
-/* integer.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-/*
- * Based on public domain LibTomMath 0.38 by Tom St Denis, tomstdenis@iahu.ca,
- * http://math.libtomcrypt.com
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-/* in case user set USE_FAST_MATH there */
-#include 
-
-#ifndef NO_BIG_INT
-
-#ifndef USE_FAST_MATH
-
-#include 
-
-#ifndef NO_WOLFSSL_SMALL_STACK
-    #ifndef WOLFSSL_SMALL_STACK
-        #define WOLFSSL_SMALL_STACK
-    #endif
-#endif
-
-static void bn_reverse (unsigned char *s, int len);
-
-/* math settings check */
-word32 CheckRunTimeSettings(void)
-{
-    return CTC_SETTINGS;
-}
-
-
-/* handle up to 6 inits */
-int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e,
-                  mp_int* f)
-{
-    int res = MP_OKAY;
-
-    if (a && ((res = mp_init(a)) != MP_OKAY))
-        return res;
-
-    if (b && ((res = mp_init(b)) != MP_OKAY)) {
-        mp_clear(a);
-        return res;
-    }
-
-    if (c && ((res = mp_init(c)) != MP_OKAY)) {
-        mp_clear(a); mp_clear(b);
-        return res;
-    }
-
-    if (d && ((res = mp_init(d)) != MP_OKAY)) {
-        mp_clear(a); mp_clear(b); mp_clear(c);
-        return res;
-    }
-
-    if (e && ((res = mp_init(e)) != MP_OKAY)) {
-        mp_clear(a); mp_clear(b); mp_clear(c); mp_clear(d);
-        return res;
-    }
-
-    if (f && ((res = mp_init(f)) != MP_OKAY)) {
-        mp_clear(a); mp_clear(b); mp_clear(c); mp_clear(d); mp_clear(e);
-        return res;
-    }
-
-    return res;
-}
-
-
-/* init a new mp_int */
-int mp_init (mp_int * a)
-{
-  int i;
-
-  /* allocate memory required and clear it */
-  a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * MP_PREC, 0,
-                                      DYNAMIC_TYPE_BIGINT);
-  if (a->dp == NULL) {
-    return MP_MEM;
-  }
-
-  /* set the digits to zero */
-  for (i = 0; i < MP_PREC; i++) {
-      a->dp[i] = 0;
-  }
-
-  /* set the used to zero, allocated digits to the default precision
-   * and sign to positive */
-  a->used  = 0;
-  a->alloc = MP_PREC;
-  a->sign  = MP_ZPOS;
-
-  return MP_OKAY;
-}
-
-
-/* clear one (frees)  */
-void
-mp_clear (mp_int * a)
-{
-  int i;
-
-  if (a == NULL)
-      return;
-
-  /* only do anything if a hasn't been freed previously */
-  if (a->dp != NULL) {
-    /* first zero the digits */
-    for (i = 0; i < a->used; i++) {
-        a->dp[i] = 0;
-    }
-
-    /* free ram */
-    XFREE(a->dp, 0, DYNAMIC_TYPE_BIGINT);
-
-    /* reset members to make debugging easier */
-    a->dp    = NULL;
-    a->alloc = a->used = 0;
-    a->sign  = MP_ZPOS;
-  }
-}
-
-
-/* get the size for an unsigned equivalent */
-int mp_unsigned_bin_size (mp_int * a)
-{
-  int     size = mp_count_bits (a);
-  return (size / 8 + ((size & 7) != 0 ? 1 : 0));
-}
-
-
-/* returns the number of bits in an int */
-int
-mp_count_bits (mp_int * a)
-{
-  int     r;
-  mp_digit q;
-
-  /* shortcut */
-  if (a->used == 0) {
-    return 0;
-  }
-
-  /* get number of digits and add that */
-  r = (a->used - 1) * DIGIT_BIT;
-
-  /* take the last digit and count the bits in it */
-  q = a->dp[a->used - 1];
-  while (q > ((mp_digit) 0)) {
-    ++r;
-    q >>= ((mp_digit) 1);
-  }
-  return r;
-}
-
-
-int mp_leading_bit (mp_int * a)
-{
-    int bit = 0;
-    mp_int t;
-
-    if (mp_init_copy(&t, a) != MP_OKAY)
-        return 0;
-
-    while (mp_iszero(&t) == 0) {
-#ifndef MP_8BIT
-        bit = (t.dp[0] & 0x80) != 0;
-#else
-        bit = (t.dp[0] | ((t.dp[1] & 0x01) << 7)) & 0x80 != 0;
-#endif
-        if (mp_div_2d (&t, 8, &t, NULL) != MP_OKAY)
-            break;
-    }
-    mp_clear(&t);
-    return bit;
-}
-
-
-/* store in unsigned [big endian] format */
-int mp_to_unsigned_bin (mp_int * a, unsigned char *b)
-{
-  int     x, res;
-  mp_int  t;
-
-  if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
-    return res;
-  }
-
-  x = 0;
-  while (mp_iszero (&t) == 0) {
-#ifndef MP_8BIT
-      b[x++] = (unsigned char) (t.dp[0] & 255);
-#else
-      b[x++] = (unsigned char) (t.dp[0] | ((t.dp[1] & 0x01) << 7));
-#endif
-    if ((res = mp_div_2d (&t, 8, &t, NULL)) != MP_OKAY) {
-      mp_clear (&t);
-      return res;
-    }
-  }
-  bn_reverse (b, x);
-  mp_clear (&t);
-  return MP_OKAY;
-}
-
-
-/* creates "a" then copies b into it */
-int mp_init_copy (mp_int * a, mp_int * b)
-{
-  int     res;
-
-  if ((res = mp_init (a)) != MP_OKAY) {
-    return res;
-  }
-  return mp_copy (b, a);
-}
-
-
-/* copy, b = a */
-int
-mp_copy (mp_int * a, mp_int * b)
-{
-  int     res, n;
-
-  /* if dst == src do nothing */
-  if (a == b) {
-    return MP_OKAY;
-  }
-
-  /* grow dest */
-  if (b->alloc < a->used) {
-     if ((res = mp_grow (b, a->used)) != MP_OKAY) {
-        return res;
-     }
-  }
-
-  /* zero b and copy the parameters over */
-  {
-    register mp_digit *tmpa, *tmpb;
-
-    /* pointer aliases */
-
-    /* source */
-    tmpa = a->dp;
-
-    /* destination */
-    tmpb = b->dp;
-
-    /* copy all the digits */
-    for (n = 0; n < a->used; n++) {
-      *tmpb++ = *tmpa++;
-    }
-
-    /* clear high digits */
-    for (; n < b->used; n++) {
-      *tmpb++ = 0;
-    }
-  }
-
-  /* copy used count and sign */
-  b->used = a->used;
-  b->sign = a->sign;
-  return MP_OKAY;
-}
-
-
-/* grow as required */
-int mp_grow (mp_int * a, int size)
-{
-  int     i;
-  mp_digit *tmp;
-
-  /* if the alloc size is smaller alloc more ram */
-  if (a->alloc < size) {
-    /* ensure there are always at least MP_PREC digits extra on top */
-    size += (MP_PREC * 2) - (size % MP_PREC);
-
-    /* reallocate the array a->dp
-     *
-     * We store the return in a temporary variable
-     * in case the operation failed we don't want
-     * to overwrite the dp member of a.
-     */
-    tmp = OPT_CAST(mp_digit) XREALLOC (a->dp, sizeof (mp_digit) * size, 0,
-                                       DYNAMIC_TYPE_BIGINT);
-    if (tmp == NULL) {
-      /* reallocation failed but "a" is still valid [can be freed] */
-      return MP_MEM;
-    }
-
-    /* reallocation succeeded so set a->dp */
-    a->dp = tmp;
-
-    /* zero excess digits */
-    i        = a->alloc;
-    a->alloc = size;
-    for (; i < a->alloc; i++) {
-      a->dp[i] = 0;
-    }
-  }
-  return MP_OKAY;
-}
-
-
-/* reverse an array, used for radix code */
-void
-bn_reverse (unsigned char *s, int len)
-{
-  int     ix, iy;
-  unsigned char t;
-
-  ix = 0;
-  iy = len - 1;
-  while (ix < iy) {
-    t     = s[ix];
-    s[ix] = s[iy];
-    s[iy] = t;
-    ++ix;
-    --iy;
-  }
-}
-
-
-/* shift right by a certain bit count (store quotient in c, optional
-   remainder in d) */
-int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d)
-{
-  int     D, res;
-  mp_int  t;
-
-
-  /* if the shift count is <= 0 then we do no work */
-  if (b <= 0) {
-    res = mp_copy (a, c);
-    if (d != NULL) {
-      mp_zero (d);
-    }
-    return res;
-  }
-
-  if ((res = mp_init (&t)) != MP_OKAY) {
-    return res;
-  }
-
-  /* get the remainder */
-  if (d != NULL) {
-    if ((res = mp_mod_2d (a, b, &t)) != MP_OKAY) {
-      mp_clear (&t);
-      return res;
-    }
-  }
-
-  /* copy */
-  if ((res = mp_copy (a, c)) != MP_OKAY) {
-    mp_clear (&t);
-    return res;
-  }
-
-  /* shift by as many digits in the bit count */
-  if (b >= (int)DIGIT_BIT) {
-    mp_rshd (c, b / DIGIT_BIT);
-  }
-
-  /* shift any bit count < DIGIT_BIT */
-  D = (b % DIGIT_BIT);
-  if (D != 0) {
-    mp_rshb(c, D);
-  }
-  mp_clamp (c);
-  if (d != NULL) {
-    mp_exch (&t, d);
-  }
-  mp_clear (&t);
-  return MP_OKAY;
-}
-
-
-/* set to zero */
-void mp_zero (mp_int * a)
-{
-  int       n;
-  mp_digit *tmp;
-
-  a->sign = MP_ZPOS;
-  a->used = 0;
-
-  tmp = a->dp;
-  for (n = 0; n < a->alloc; n++) {
-     *tmp++ = 0;
-  }
-}
-
-
-/* trim unused digits
- *
- * This is used to ensure that leading zero digits are
- * trimed and the leading "used" digit will be non-zero
- * Typically very fast.  Also fixes the sign if there
- * are no more leading digits
- */
-void
-mp_clamp (mp_int * a)
-{
-  /* decrease used while the most significant digit is
-   * zero.
-   */
-  while (a->used > 0 && a->dp[a->used - 1] == 0) {
-    --(a->used);
-  }
-
-  /* reset the sign flag if used == 0 */
-  if (a->used == 0) {
-    a->sign = MP_ZPOS;
-  }
-}
-
-
-/* swap the elements of two integers, for cases where you can't simply swap the
- * mp_int pointers around
- */
-void
-mp_exch (mp_int * a, mp_int * b)
-{
-  mp_int  t;
-
-  t  = *a;
-  *a = *b;
-  *b = t;
-}
-
-
-/* shift right a certain number of bits */
-void mp_rshb (mp_int *c, int x)
-{
-    register mp_digit *tmpc, mask, shift;
-    mp_digit r, rr;
-    mp_digit D = x;
-
-    /* mask */
-    mask = (((mp_digit)1) << D) - 1;
-
-    /* shift for lsb */
-    shift = DIGIT_BIT - D;
-
-    /* alias */
-    tmpc = c->dp + (c->used - 1);
-
-    /* carry */
-    r = 0;
-    for (x = c->used - 1; x >= 0; x--) {
-      /* get the lower  bits of this word in a temp */
-      rr = *tmpc & mask;
-
-      /* shift the current word and mix in the carry bits from previous word */
-      *tmpc = (*tmpc >> D) | (r << shift);
-      --tmpc;
-
-      /* set the carry to the carry bits of the current word found above */
-      r = rr;
-    }
-}
-
-
-/* shift right a certain amount of digits */
-void mp_rshd (mp_int * a, int b)
-{
-  int     x;
-
-  /* if b <= 0 then ignore it */
-  if (b <= 0) {
-    return;
-  }
-
-  /* if b > used then simply zero it and return */
-  if (a->used <= b) {
-    mp_zero (a);
-    return;
-  }
-
-  {
-    register mp_digit *bottom, *top;
-
-    /* shift the digits down */
-
-    /* bottom */
-    bottom = a->dp;
-
-    /* top [offset into digits] */
-    top = a->dp + b;
-
-    /* this is implemented as a sliding window where
-     * the window is b-digits long and digits from
-     * the top of the window are copied to the bottom
-     *
-     * e.g.
-
-     b-2 | b-1 | b0 | b1 | b2 | ... | bb |   ---->
-                 /\                   |      ---->
-                  \-------------------/      ---->
-     */
-    for (x = 0; x < (a->used - b); x++) {
-      *bottom++ = *top++;
-    }
-
-    /* zero the top digits */
-    for (; x < a->used; x++) {
-      *bottom++ = 0;
-    }
-  }
-
-  /* remove excess digits */
-  a->used -= b;
-}
-
-
-/* calc a value mod 2**b */
-int
-mp_mod_2d (mp_int * a, int b, mp_int * c)
-{
-  int     x, res;
-
-  /* if b is <= 0 then zero the int */
-  if (b <= 0) {
-    mp_zero (c);
-    return MP_OKAY;
-  }
-
-  /* if the modulus is larger than the value than return */
-  if (b >= (int) (a->used * DIGIT_BIT)) {
-    res = mp_copy (a, c);
-    return res;
-  }
-
-  /* copy */
-  if ((res = mp_copy (a, c)) != MP_OKAY) {
-    return res;
-  }
-
-  /* zero digits above the last digit of the modulus */
-  for (x = (b / DIGIT_BIT) + ((b % DIGIT_BIT) == 0 ? 0 : 1); x < c->used; x++) {
-    c->dp[x] = 0;
-  }
-  /* clear the digit that is not completely outside/inside the modulus */
-  c->dp[b / DIGIT_BIT] &= (mp_digit) ((((mp_digit) 1) <<
-              (((mp_digit) b) % DIGIT_BIT)) - ((mp_digit) 1));
-  mp_clamp (c);
-  return MP_OKAY;
-}
-
-
-/* reads a unsigned char array, assumes the msb is stored first [big endian] */
-int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c)
-{
-  int     res;
-
-  /* make sure there are at least two digits */
-  if (a->alloc < 2) {
-     if ((res = mp_grow(a, 2)) != MP_OKAY) {
-        return res;
-     }
-  }
-
-  /* zero the int */
-  mp_zero (a);
-
-  /* read the bytes in */
-  while (c-- > 0) {
-    if ((res = mp_mul_2d (a, 8, a)) != MP_OKAY) {
-      return res;
-    }
-
-#ifndef MP_8BIT
-      a->dp[0] |= *b++;
-      a->used += 1;
-#else
-      a->dp[0] = (*b & MP_MASK);
-      a->dp[1] |= ((*b++ >> 7U) & 1);
-      a->used += 2;
-#endif
-  }
-  mp_clamp (a);
-  return MP_OKAY;
-}
-
-
-/* shift left by a certain bit count */
-int mp_mul_2d (mp_int * a, int b, mp_int * c)
-{
-  mp_digit d;
-  int      res;
-
-  /* copy */
-  if (a != c) {
-     if ((res = mp_copy (a, c)) != MP_OKAY) {
-       return res;
-     }
-  }
-
-  if (c->alloc < (int)(c->used + b/DIGIT_BIT + 1)) {
-     if ((res = mp_grow (c, c->used + b / DIGIT_BIT + 1)) != MP_OKAY) {
-       return res;
-     }
-  }
-
-  /* shift by as many digits in the bit count */
-  if (b >= (int)DIGIT_BIT) {
-    if ((res = mp_lshd (c, b / DIGIT_BIT)) != MP_OKAY) {
-      return res;
-    }
-  }
-
-  /* shift any bit count < DIGIT_BIT */
-  d = (mp_digit) (b % DIGIT_BIT);
-  if (d != 0) {
-    register mp_digit *tmpc, shift, mask, r, rr;
-    register int x;
-
-    /* bitmask for carries */
-    mask = (((mp_digit)1) << d) - 1;
-
-    /* shift for msbs */
-    shift = DIGIT_BIT - d;
-
-    /* alias */
-    tmpc = c->dp;
-
-    /* carry */
-    r    = 0;
-    for (x = 0; x < c->used; x++) {
-      /* get the higher bits of the current word */
-      rr = (*tmpc >> shift) & mask;
-
-      /* shift the current word and OR in the carry */
-      *tmpc = ((*tmpc << d) | r) & MP_MASK;
-      ++tmpc;
-
-      /* set the carry to the carry bits of the current word */
-      r = rr;
-    }
-
-    /* set final carry */
-    if (r != 0) {
-       c->dp[(c->used)++] = r;
-    }
-  }
-  mp_clamp (c);
-  return MP_OKAY;
-}
-
-
-/* shift left a certain amount of digits */
-int mp_lshd (mp_int * a, int b)
-{
-  int     x, res;
-
-  /* if its less than zero return */
-  if (b <= 0) {
-    return MP_OKAY;
-  }
-
-  /* grow to fit the new digits */
-  if (a->alloc < a->used + b) {
-     if ((res = mp_grow (a, a->used + b)) != MP_OKAY) {
-       return res;
-     }
-  }
-
-  {
-    register mp_digit *top, *bottom;
-
-    /* increment the used by the shift amount then copy upwards */
-    a->used += b;
-
-    /* top */
-    top = a->dp + a->used - 1;
-
-    /* base */
-    bottom = a->dp + a->used - 1 - b;
-
-    /* much like mp_rshd this is implemented using a sliding window
-     * except the window goes the otherway around.  Copying from
-     * the bottom to the top.  see bn_mp_rshd.c for more info.
-     */
-    for (x = a->used - 1; x >= b; x--) {
-      *top-- = *bottom--;
-    }
-
-    /* zero the lower digits */
-    top = a->dp;
-    for (x = 0; x < b; x++) {
-      *top++ = 0;
-    }
-  }
-  return MP_OKAY;
-}
-
-
-/* this is a shell function that calls either the normal or Montgomery
- * exptmod functions.  Originally the call to the montgomery code was
- * embedded in the normal function but that wasted alot of stack space
- * for nothing (since 99% of the time the Montgomery code would be called)
- */
-int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y)
-{
-  int dr;
-
-  /* modulus P must be positive */
-  if (P->sign == MP_NEG) {
-     return MP_VAL;
-  }
-
-  /* if exponent X is negative we have to recurse */
-  if (X->sign == MP_NEG) {
-#ifdef BN_MP_INVMOD_C
-     mp_int tmpG, tmpX;
-     int err;
-
-     /* first compute 1/G mod P */
-     if ((err = mp_init(&tmpG)) != MP_OKAY) {
-        return err;
-     }
-     if ((err = mp_invmod(G, P, &tmpG)) != MP_OKAY) {
-        mp_clear(&tmpG);
-        return err;
-     }
-
-     /* now get |X| */
-     if ((err = mp_init(&tmpX)) != MP_OKAY) {
-        mp_clear(&tmpG);
-        return err;
-     }
-     if ((err = mp_abs(X, &tmpX)) != MP_OKAY) {
-        mp_clear(&tmpG);
-        mp_clear(&tmpX);
-        return err;
-     }
-
-     /* and now compute (1/G)**|X| instead of G**X [X < 0] */
-     err = mp_exptmod(&tmpG, &tmpX, P, Y);
-     mp_clear(&tmpG);
-     mp_clear(&tmpX);
-     return err;
-#else
-     /* no invmod */
-     return MP_VAL;
-#endif
-  }
-
-/* modified diminished radix reduction */
-#if defined(BN_MP_REDUCE_IS_2K_L_C) && defined(BN_MP_REDUCE_2K_L_C) && \
-  defined(BN_S_MP_EXPTMOD_C)
-  if (mp_reduce_is_2k_l(P) == MP_YES) {
-     return s_mp_exptmod(G, X, P, Y, 1);
-  }
-#endif
-
-#ifdef BN_MP_DR_IS_MODULUS_C
-  /* is it a DR modulus? */
-  dr = mp_dr_is_modulus(P);
-#else
-  /* default to no */
-  dr = 0;
-#endif
-
-#ifdef BN_MP_REDUCE_IS_2K_C
-  /* if not, is it a unrestricted DR modulus? */
-  if (dr == 0) {
-     dr = mp_reduce_is_2k(P) << 1;
-  }
-#endif
-
-  /* if the modulus is odd or dr != 0 use the montgomery method */
-#ifdef BN_MP_EXPTMOD_FAST_C
-  if (mp_isodd (P) == 1 || dr !=  0) {
-    return mp_exptmod_fast (G, X, P, Y, dr);
-  } else {
-#endif
-#ifdef BN_S_MP_EXPTMOD_C
-    /* otherwise use the generic Barrett reduction technique */
-    return s_mp_exptmod (G, X, P, Y, 0);
-#else
-    /* no exptmod for evens */
-    return MP_VAL;
-#endif
-#ifdef BN_MP_EXPTMOD_FAST_C
-  }
-#endif
-}
-
-
-/* b = |a|
- *
- * Simple function copies the input and fixes the sign to positive
- */
-int
-mp_abs (mp_int * a, mp_int * b)
-{
-  int     res;
-
-  /* copy a to b */
-  if (a != b) {
-     if ((res = mp_copy (a, b)) != MP_OKAY) {
-       return res;
-     }
-  }
-
-  /* force the sign of b to positive */
-  b->sign = MP_ZPOS;
-
-  return MP_OKAY;
-}
-
-
-/* hac 14.61, pp608 */
-int mp_invmod (mp_int * a, mp_int * b, mp_int * c)
-{
-  /* b cannot be negative */
-  if (b->sign == MP_NEG || mp_iszero(b) == 1) {
-    return MP_VAL;
-  }
-
-#ifdef BN_FAST_MP_INVMOD_C
-  /* if the modulus is odd we can use a faster routine instead */
-  if (mp_isodd (b) == 1) {
-    return fast_mp_invmod (a, b, c);
-  }
-#endif
-
-#ifdef BN_MP_INVMOD_SLOW_C
-  return mp_invmod_slow(a, b, c);
-#endif
-}
-
-
-/* computes the modular inverse via binary extended euclidean algorithm,
- * that is c = 1/a mod b
- *
- * Based on slow invmod except this is optimized for the case where b is
- * odd as per HAC Note 14.64 on pp. 610
- */
-int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c)
-{
-  mp_int  x, y, u, v, B, D;
-  int     res, neg, loop_check = 0;
-
-  /* 2. [modified] b must be odd   */
-  if (mp_iseven (b) == 1) {
-    return MP_VAL;
-  }
-
-  /* init all our temps */
-  if ((res = mp_init_multi(&x, &y, &u, &v, &B, &D)) != MP_OKAY) {
-     return res;
-  }
-
-  /* x == modulus, y == value to invert */
-  if ((res = mp_copy (b, &x)) != MP_OKAY) {
-    goto LBL_ERR;
-  }
-
-  /* we need y = |a| */
-  if ((res = mp_mod (a, b, &y)) != MP_OKAY) {
-    goto LBL_ERR;
-  }
-
-  /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */
-  if ((res = mp_copy (&x, &u)) != MP_OKAY) {
-    goto LBL_ERR;
-  }
-  if ((res = mp_copy (&y, &v)) != MP_OKAY) {
-    goto LBL_ERR;
-  }
-  mp_set (&D, 1);
-
-top:
-  /* 4.  while u is even do */
-  while (mp_iseven (&u) == 1) {
-    /* 4.1 u = u/2 */
-    if ((res = mp_div_2 (&u, &u)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-    /* 4.2 if B is odd then */
-    if (mp_isodd (&B) == 1) {
-      if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) {
-        goto LBL_ERR;
-      }
-    }
-    /* B = B/2 */
-    if ((res = mp_div_2 (&B, &B)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-  }
-
-  /* 5.  while v is even do */
-  while (mp_iseven (&v) == 1) {
-    /* 5.1 v = v/2 */
-    if ((res = mp_div_2 (&v, &v)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-    /* 5.2 if D is odd then */
-    if (mp_isodd (&D) == 1) {
-      /* D = (D-x)/2 */
-      if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) {
-        goto LBL_ERR;
-      }
-    }
-    /* D = D/2 */
-    if ((res = mp_div_2 (&D, &D)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-  }
-
-  /* 6.  if u >= v then */
-  if (mp_cmp (&u, &v) != MP_LT) {
-    /* u = u - v, B = B - D */
-    if ((res = mp_sub (&u, &v, &u)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-
-    if ((res = mp_sub (&B, &D, &B)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-  } else {
-    /* v - v - u, D = D - B */
-    if ((res = mp_sub (&v, &u, &v)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-
-    if ((res = mp_sub (&D, &B, &D)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-  }
-
-  /* if not zero goto step 4 */
-  if (mp_iszero (&u) == 0) {
-    if (++loop_check > 1024) {
-        res = MP_VAL;
-        goto LBL_ERR;
-    }
-    goto top;
-  }
-
-  /* now a = C, b = D, gcd == g*v */
-
-  /* if v != 1 then there is no inverse */
-  if (mp_cmp_d (&v, 1) != MP_EQ) {
-    res = MP_VAL;
-    goto LBL_ERR;
-  }
-
-  /* b is now the inverse */
-  neg = a->sign;
-  while (D.sign == MP_NEG) {
-    if ((res = mp_add (&D, b, &D)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-  }
-  mp_exch (&D, c);
-  c->sign = neg;
-  res = MP_OKAY;
-
-LBL_ERR:mp_clear(&x);
-        mp_clear(&y);
-        mp_clear(&u);
-        mp_clear(&v);
-        mp_clear(&B);
-        mp_clear(&D);
-  return res;
-}
-
-
-/* hac 14.61, pp608 */
-int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c)
-{
-  mp_int  x, y, u, v, A, B, C, D;
-  int     res;
-
-  /* b cannot be negative */
-  if (b->sign == MP_NEG || mp_iszero(b) == 1) {
-    return MP_VAL;
-  }
-
-  /* init temps */
-  if ((res = mp_init_multi(&x, &y, &u, &v,
-                           &A, &B)) != MP_OKAY) {
-     return res;
-  }
-
-  /* init rest of tmps temps */
-  if ((res = mp_init_multi(&C, &D, 0, 0, 0, 0)) != MP_OKAY) {
-     return res;
-  }
-
-  /* x = a, y = b */
-  if ((res = mp_mod(a, b, &x)) != MP_OKAY) {
-      goto LBL_ERR;
-  }
-  if ((res = mp_copy (b, &y)) != MP_OKAY) {
-    goto LBL_ERR;
-  }
-
-  /* 2. [modified] if x,y are both even then return an error! */
-  if (mp_iseven (&x) == 1 && mp_iseven (&y) == 1) {
-    res = MP_VAL;
-    goto LBL_ERR;
-  }
-
-  /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */
-  if ((res = mp_copy (&x, &u)) != MP_OKAY) {
-    goto LBL_ERR;
-  }
-  if ((res = mp_copy (&y, &v)) != MP_OKAY) {
-    goto LBL_ERR;
-  }
-  mp_set (&A, 1);
-  mp_set (&D, 1);
-
-top:
-  /* 4.  while u is even do */
-  while (mp_iseven (&u) == 1) {
-    /* 4.1 u = u/2 */
-    if ((res = mp_div_2 (&u, &u)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-    /* 4.2 if A or B is odd then */
-    if (mp_isodd (&A) == 1 || mp_isodd (&B) == 1) {
-      /* A = (A+y)/2, B = (B-x)/2 */
-      if ((res = mp_add (&A, &y, &A)) != MP_OKAY) {
-         goto LBL_ERR;
-      }
-      if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) {
-         goto LBL_ERR;
-      }
-    }
-    /* A = A/2, B = B/2 */
-    if ((res = mp_div_2 (&A, &A)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-    if ((res = mp_div_2 (&B, &B)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-  }
-
-  /* 5.  while v is even do */
-  while (mp_iseven (&v) == 1) {
-    /* 5.1 v = v/2 */
-    if ((res = mp_div_2 (&v, &v)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-    /* 5.2 if C or D is odd then */
-    if (mp_isodd (&C) == 1 || mp_isodd (&D) == 1) {
-      /* C = (C+y)/2, D = (D-x)/2 */
-      if ((res = mp_add (&C, &y, &C)) != MP_OKAY) {
-         goto LBL_ERR;
-      }
-      if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) {
-         goto LBL_ERR;
-      }
-    }
-    /* C = C/2, D = D/2 */
-    if ((res = mp_div_2 (&C, &C)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-    if ((res = mp_div_2 (&D, &D)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-  }
-
-  /* 6.  if u >= v then */
-  if (mp_cmp (&u, &v) != MP_LT) {
-    /* u = u - v, A = A - C, B = B - D */
-    if ((res = mp_sub (&u, &v, &u)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-
-    if ((res = mp_sub (&A, &C, &A)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-
-    if ((res = mp_sub (&B, &D, &B)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-  } else {
-    /* v - v - u, C = C - A, D = D - B */
-    if ((res = mp_sub (&v, &u, &v)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-
-    if ((res = mp_sub (&C, &A, &C)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-
-    if ((res = mp_sub (&D, &B, &D)) != MP_OKAY) {
-      goto LBL_ERR;
-    }
-  }
-
-  /* if not zero goto step 4 */
-  if (mp_iszero (&u) == 0)
-    goto top;
-
-  /* now a = C, b = D, gcd == g*v */
-
-  /* if v != 1 then there is no inverse */
-  if (mp_cmp_d (&v, 1) != MP_EQ) {
-    res = MP_VAL;
-    goto LBL_ERR;
-  }
-
-  /* if its too low */
-  while (mp_cmp_d(&C, 0) == MP_LT) {
-      if ((res = mp_add(&C, b, &C)) != MP_OKAY) {
-         goto LBL_ERR;
-      }
-  }
-
-  /* too big */
-  while (mp_cmp_mag(&C, b) != MP_LT) {
-      if ((res = mp_sub(&C, b, &C)) != MP_OKAY) {
-         goto LBL_ERR;
-      }
-  }
-
-  /* C is now the inverse */
-  mp_exch (&C, c);
-  res = MP_OKAY;
-LBL_ERR:mp_clear(&x);
-        mp_clear(&y);
-        mp_clear(&u);
-        mp_clear(&v);
-        mp_clear(&A);
-        mp_clear(&B);
-        mp_clear(&C);
-        mp_clear(&D);
-  return res;
-}
-
-
-/* compare maginitude of two ints (unsigned) */
-int mp_cmp_mag (mp_int * a, mp_int * b)
-{
-  int     n;
-  mp_digit *tmpa, *tmpb;
-
-  /* compare based on # of non-zero digits */
-  if (a->used > b->used) {
-    return MP_GT;
-  }
-
-  if (a->used < b->used) {
-    return MP_LT;
-  }
-
-  /* alias for a */
-  tmpa = a->dp + (a->used - 1);
-
-  /* alias for b */
-  tmpb = b->dp + (a->used - 1);
-
-  /* compare based on digits  */
-  for (n = 0; n < a->used; ++n, --tmpa, --tmpb) {
-    if (*tmpa > *tmpb) {
-      return MP_GT;
-    }
-
-    if (*tmpa < *tmpb) {
-      return MP_LT;
-    }
-  }
-  return MP_EQ;
-}
-
-
-/* compare two ints (signed)*/
-int
-mp_cmp (mp_int * a, mp_int * b)
-{
-  /* compare based on sign */
-  if (a->sign != b->sign) {
-     if (a->sign == MP_NEG) {
-        return MP_LT;
-     } else {
-        return MP_GT;
-     }
-  }
-
-  /* compare digits */
-  if (a->sign == MP_NEG) {
-     /* if negative compare opposite direction */
-     return mp_cmp_mag(b, a);
-  } else {
-     return mp_cmp_mag(a, b);
-  }
-}
-
-
-/* compare a digit */
-int mp_cmp_d(mp_int * a, mp_digit b)
-{
-  /* compare based on sign */
-  if (a->sign == MP_NEG) {
-    return MP_LT;
-  }
-
-  /* compare based on magnitude */
-  if (a->used > 1) {
-    return MP_GT;
-  }
-
-  /* compare the only digit of a to b */
-  if (a->dp[0] > b) {
-    return MP_GT;
-  } else if (a->dp[0] < b) {
-    return MP_LT;
-  } else {
-    return MP_EQ;
-  }
-}
-
-
-/* set to a digit */
-void mp_set (mp_int * a, mp_digit b)
-{
-  mp_zero (a);
-  a->dp[0] = b & MP_MASK;
-  a->used  = (a->dp[0] != 0) ? 1 : 0;
-}
-
-
-/* c = a mod b, 0 <= c < b */
-int
-mp_mod (mp_int * a, mp_int * b, mp_int * c)
-{
-  mp_int  t;
-  int     res;
-
-  if ((res = mp_init (&t)) != MP_OKAY) {
-    return res;
-  }
-
-  if ((res = mp_div (a, b, NULL, &t)) != MP_OKAY) {
-    mp_clear (&t);
-    return res;
-  }
-
-  if (t.sign != b->sign) {
-    res = mp_add (b, &t, c);
-  } else {
-    res = MP_OKAY;
-    mp_exch (&t, c);
-  }
-
-  mp_clear (&t);
-  return res;
-}
-
-
-/* slower bit-bang division... also smaller */
-int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d)
-{
-   mp_int ta, tb, tq, q;
-   int    res, n, n2;
-
-  /* is divisor zero ? */
-  if (mp_iszero (b) == 1) {
-    return MP_VAL;
-  }
-
-  /* if a < b then q=0, r = a */
-  if (mp_cmp_mag (a, b) == MP_LT) {
-    if (d != NULL) {
-      res = mp_copy (a, d);
-    } else {
-      res = MP_OKAY;
-    }
-    if (c != NULL) {
-      mp_zero (c);
-    }
-    return res;
-  }
-
-  /* init our temps */
-  if ((res = mp_init_multi(&ta, &tb, &tq, &q, 0, 0)) != MP_OKAY) {
-     return res;
-  }
-
-
-  mp_set(&tq, 1);
-  n = mp_count_bits(a) - mp_count_bits(b);
-  if (((res = mp_abs(a, &ta)) != MP_OKAY) ||
-      ((res = mp_abs(b, &tb)) != MP_OKAY) ||
-      ((res = mp_mul_2d(&tb, n, &tb)) != MP_OKAY) ||
-      ((res = mp_mul_2d(&tq, n, &tq)) != MP_OKAY)) {
-      goto LBL_ERR;
-  }
-
-  while (n-- >= 0) {
-     if (mp_cmp(&tb, &ta) != MP_GT) {
-        if (((res = mp_sub(&ta, &tb, &ta)) != MP_OKAY) ||
-            ((res = mp_add(&q, &tq, &q)) != MP_OKAY)) {
-           goto LBL_ERR;
-        }
-     }
-     if (((res = mp_div_2d(&tb, 1, &tb, NULL)) != MP_OKAY) ||
-         ((res = mp_div_2d(&tq, 1, &tq, NULL)) != MP_OKAY)) {
-           goto LBL_ERR;
-     }
-  }
-
-  /* now q == quotient and ta == remainder */
-  n  = a->sign;
-  n2 = (a->sign == b->sign ? MP_ZPOS : MP_NEG);
-  if (c != NULL) {
-     mp_exch(c, &q);
-     c->sign  = (mp_iszero(c) == MP_YES) ? MP_ZPOS : n2;
-  }
-  if (d != NULL) {
-     mp_exch(d, &ta);
-     d->sign = (mp_iszero(d) == MP_YES) ? MP_ZPOS : n;
-  }
-LBL_ERR:
-   mp_clear(&ta);
-   mp_clear(&tb);
-   mp_clear(&tq);
-   mp_clear(&q);
-   return res;
-}
-
-
-/* b = a/2 */
-int mp_div_2(mp_int * a, mp_int * b)
-{
-  int     x, res, oldused;
-
-  /* copy */
-  if (b->alloc < a->used) {
-    if ((res = mp_grow (b, a->used)) != MP_OKAY) {
-      return res;
-    }
-  }
-
-  oldused = b->used;
-  b->used = a->used;
-  {
-    register mp_digit r, rr, *tmpa, *tmpb;
-
-    /* source alias */
-    tmpa = a->dp + b->used - 1;
-
-    /* dest alias */
-    tmpb = b->dp + b->used - 1;
-
-    /* carry */
-    r = 0;
-    for (x = b->used - 1; x >= 0; x--) {
-      /* get the carry for the next iteration */
-      rr = *tmpa & 1;
-
-      /* shift the current digit, add in carry and store */
-      *tmpb-- = (*tmpa-- >> 1) | (r << (DIGIT_BIT - 1));
-
-      /* forward carry to next iteration */
-      r = rr;
-    }
-
-    /* zero excess digits */
-    tmpb = b->dp + b->used;
-    for (x = b->used; x < oldused; x++) {
-      *tmpb++ = 0;
-    }
-  }
-  b->sign = a->sign;
-  mp_clamp (b);
-  return MP_OKAY;
-}
-
-
-/* high level addition (handles signs) */
-int mp_add (mp_int * a, mp_int * b, mp_int * c)
-{
-  int     sa, sb, res;
-
-  /* get sign of both inputs */
-  sa = a->sign;
-  sb = b->sign;
-
-  /* handle two cases, not four */
-  if (sa == sb) {
-    /* both positive or both negative */
-    /* add their magnitudes, copy the sign */
-    c->sign = sa;
-    res = s_mp_add (a, b, c);
-  } else {
-    /* one positive, the other negative */
-    /* subtract the one with the greater magnitude from */
-    /* the one of the lesser magnitude.  The result gets */
-    /* the sign of the one with the greater magnitude. */
-    if (mp_cmp_mag (a, b) == MP_LT) {
-      c->sign = sb;
-      res = s_mp_sub (b, a, c);
-    } else {
-      c->sign = sa;
-      res = s_mp_sub (a, b, c);
-    }
-  }
-  return res;
-}
-
-
-/* low level addition, based on HAC pp.594, Algorithm 14.7 */
-int
-s_mp_add (mp_int * a, mp_int * b, mp_int * c)
-{
-  mp_int *x;
-  int     olduse, res, min, max;
-
-  /* find sizes, we let |a| <= |b| which means we have to sort
-   * them.  "x" will point to the input with the most digits
-   */
-  if (a->used > b->used) {
-    min = b->used;
-    max = a->used;
-    x = a;
-  } else {
-    min = a->used;
-    max = b->used;
-    x = b;
-  }
-
-  /* init result */
-  if (c->alloc < max + 1) {
-    if ((res = mp_grow (c, max + 1)) != MP_OKAY) {
-      return res;
-    }
-  }
-
-  /* get old used digit count and set new one */
-  olduse = c->used;
-  c->used = max + 1;
-
-  {
-    register mp_digit u, *tmpa, *tmpb, *tmpc;
-    register int i;
-
-    /* alias for digit pointers */
-
-    /* first input */
-    tmpa = a->dp;
-
-    /* second input */
-    tmpb = b->dp;
-
-    /* destination */
-    tmpc = c->dp;
-
-    /* zero the carry */
-    u = 0;
-    for (i = 0; i < min; i++) {
-      /* Compute the sum at one digit, T[i] = A[i] + B[i] + U */
-      *tmpc = *tmpa++ + *tmpb++ + u;
-
-      /* U = carry bit of T[i] */
-      u = *tmpc >> ((mp_digit)DIGIT_BIT);
-
-      /* take away carry bit from T[i] */
-      *tmpc++ &= MP_MASK;
-    }
-
-    /* now copy higher words if any, that is in A+B
-     * if A or B has more digits add those in
-     */
-    if (min != max) {
-      for (; i < max; i++) {
-        /* T[i] = X[i] + U */
-        *tmpc = x->dp[i] + u;
-
-        /* U = carry bit of T[i] */
-        u = *tmpc >> ((mp_digit)DIGIT_BIT);
-
-        /* take away carry bit from T[i] */
-        *tmpc++ &= MP_MASK;
-      }
-    }
-
-    /* add carry */
-    *tmpc++ = u;
-
-    /* clear digits above oldused */
-    for (i = c->used; i < olduse; i++) {
-      *tmpc++ = 0;
-    }
-  }
-
-  mp_clamp (c);
-  return MP_OKAY;
-}
-
-
-/* low level subtraction (assumes |a| > |b|), HAC pp.595 Algorithm 14.9 */
-int
-s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
-{
-  int     olduse, res, min, max;
-
-  /* find sizes */
-  min = b->used;
-  max = a->used;
-
-  /* init result */
-  if (c->alloc < max) {
-    if ((res = mp_grow (c, max)) != MP_OKAY) {
-      return res;
-    }
-  }
-  olduse = c->used;
-  c->used = max;
-
-  {
-    register mp_digit u, *tmpa, *tmpb, *tmpc;
-    register int i;
-
-    /* alias for digit pointers */
-    tmpa = a->dp;
-    tmpb = b->dp;
-    tmpc = c->dp;
-
-    /* set carry to zero */
-    u = 0;
-    for (i = 0; i < min; i++) {
-      /* T[i] = A[i] - B[i] - U */
-      *tmpc = *tmpa++ - *tmpb++ - u;
-
-      /* U = carry bit of T[i]
-       * Note this saves performing an AND operation since
-       * if a carry does occur it will propagate all the way to the
-       * MSB.  As a result a single shift is enough to get the carry
-       */
-      u = *tmpc >> ((mp_digit)(CHAR_BIT * sizeof (mp_digit) - 1));
-
-      /* Clear carry from T[i] */
-      *tmpc++ &= MP_MASK;
-    }
-
-    /* now copy higher words if any, e.g. if A has more digits than B  */
-    for (; i < max; i++) {
-      /* T[i] = A[i] - U */
-      *tmpc = *tmpa++ - u;
-
-      /* U = carry bit of T[i] */
-      u = *tmpc >> ((mp_digit)(CHAR_BIT * sizeof (mp_digit) - 1));
-
-      /* Clear carry from T[i] */
-      *tmpc++ &= MP_MASK;
-    }
-
-    /* clear digits above used (since we may not have grown result above) */
-    for (i = c->used; i < olduse; i++) {
-      *tmpc++ = 0;
-    }
-  }
-
-  mp_clamp (c);
-  return MP_OKAY;
-}
-
-
-/* high level subtraction (handles signs) */
-int
-mp_sub (mp_int * a, mp_int * b, mp_int * c)
-{
-  int     sa, sb, res;
-
-  sa = a->sign;
-  sb = b->sign;
-
-  if (sa != sb) {
-    /* subtract a negative from a positive, OR */
-    /* subtract a positive from a negative. */
-    /* In either case, ADD their magnitudes, */
-    /* and use the sign of the first number. */
-    c->sign = sa;
-    res = s_mp_add (a, b, c);
-  } else {
-    /* subtract a positive from a positive, OR */
-    /* subtract a negative from a negative. */
-    /* First, take the difference between their */
-    /* magnitudes, then... */
-    if (mp_cmp_mag (a, b) != MP_LT) {
-      /* Copy the sign from the first */
-      c->sign = sa;
-      /* The first has a larger or equal magnitude */
-      res = s_mp_sub (a, b, c);
-    } else {
-      /* The result has the *opposite* sign from */
-      /* the first number. */
-      c->sign = (sa == MP_ZPOS) ? MP_NEG : MP_ZPOS;
-      /* The second has a larger magnitude */
-      res = s_mp_sub (b, a, c);
-    }
-  }
-  return res;
-}
-
-
-/* determines if reduce_2k_l can be used */
-int mp_reduce_is_2k_l(mp_int *a)
-{
-   int ix, iy;
-
-   if (a->used == 0) {
-      return MP_NO;
-   } else if (a->used == 1) {
-      return MP_YES;
-   } else if (a->used > 1) {
-      /* if more than half of the digits are -1 we're sold */
-      for (iy = ix = 0; ix < a->used; ix++) {
-          if (a->dp[ix] == MP_MASK) {
-              ++iy;
-          }
-      }
-      return (iy >= (a->used/2)) ? MP_YES : MP_NO;
-
-   }
-   return MP_NO;
-}
-
-
-/* determines if mp_reduce_2k can be used */
-int mp_reduce_is_2k(mp_int *a)
-{
-   int ix, iy, iw;
-   mp_digit iz;
-
-   if (a->used == 0) {
-      return MP_NO;
-   } else if (a->used == 1) {
-      return MP_YES;
-   } else if (a->used > 1) {
-      iy = mp_count_bits(a);
-      iz = 1;
-      iw = 1;
-
-      /* Test every bit from the second digit up, must be 1 */
-      for (ix = DIGIT_BIT; ix < iy; ix++) {
-          if ((a->dp[iw] & iz) == 0) {
-             return MP_NO;
-          }
-          iz <<= 1;
-          if (iz > (mp_digit)MP_MASK) {
-             ++iw;
-             iz = 1;
-          }
-      }
-   }
-   return MP_YES;
-}
-
-
-/* determines if a number is a valid DR modulus */
-int mp_dr_is_modulus(mp_int *a)
-{
-   int ix;
-
-   /* must be at least two digits */
-   if (a->used < 2) {
-      return 0;
-   }
-
-   /* must be of the form b**k - a [a <= b] so all
-    * but the first digit must be equal to -1 (mod b).
-    */
-   for (ix = 1; ix < a->used; ix++) {
-       if (a->dp[ix] != MP_MASK) {
-          return 0;
-       }
-   }
-   return 1;
-}
-
-
-/* computes Y == G**X mod P, HAC pp.616, Algorithm 14.85
- *
- * Uses a left-to-right k-ary sliding window to compute the modular
- * exponentiation.
- * The value of k changes based on the size of the exponent.
- *
- * Uses Montgomery or Diminished Radix reduction [whichever appropriate]
- */
-
-#ifdef MP_LOW_MEM
-   #define TAB_SIZE 32
-#else
-   #define TAB_SIZE 256
-#endif
-
-int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y,
-                     int redmode)
-{
-  mp_int res;
-  mp_digit buf, mp;
-  int     err, bitbuf, bitcpy, bitcnt, mode, digidx, x, y, winsize;
-#ifdef WOLFSSL_SMALL_STACK
-  mp_int* M = NULL;
-#else
-  mp_int M[TAB_SIZE];
-#endif
-  /* use a pointer to the reduction algorithm.  This allows us to use
-   * one of many reduction algorithms without modding the guts of
-   * the code with if statements everywhere.
-   */
-  int     (*redux)(mp_int*,mp_int*,mp_digit);
-
-#ifdef WOLFSSL_SMALL_STACK
-  M = (mp_int*) XMALLOC(sizeof(mp_int) * TAB_SIZE, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-  if (M == NULL)
-    return MP_MEM;
-#endif
-
-  /* find window size */
-  x = mp_count_bits (X);
-  if (x <= 7) {
-    winsize = 2;
-  } else if (x <= 36) {
-    winsize = 3;
-  } else if (x <= 140) {
-    winsize = 4;
-  } else if (x <= 450) {
-    winsize = 5;
-  } else if (x <= 1303) {
-    winsize = 6;
-  } else if (x <= 3529) {
-    winsize = 7;
-  } else {
-    winsize = 8;
-  }
-
-#ifdef MP_LOW_MEM
-  if (winsize > 5) {
-     winsize = 5;
-  }
-#endif
-
-  /* init M array */
-  /* init first cell */
-  if ((err = mp_init(&M[1])) != MP_OKAY) {
-#ifdef WOLFSSL_SMALL_STACK
-  XFREE(M, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-     return err;
-  }
-
-  /* now init the second half of the array */
-  for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
-    if ((err = mp_init(&M[x])) != MP_OKAY) {
-      for (y = 1<<(winsize-1); y < x; y++) {
-        mp_clear (&M[y]);
-      }
-      mp_clear(&M[1]);
-
-#ifdef WOLFSSL_SMALL_STACK
-      XFREE(M, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-      return err;
-    }
-  }
-
-  /* determine and setup reduction code */
-  if (redmode == 0) {
-#ifdef BN_MP_MONTGOMERY_SETUP_C
-     /* now setup montgomery  */
-     if ((err = mp_montgomery_setup (P, &mp)) != MP_OKAY) {
-        goto LBL_M;
-     }
-#else
-     err = MP_VAL;
-     goto LBL_M;
-#endif
-
-     /* automatically pick the comba one if available (saves quite a few
-        calls/ifs) */
-#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C
-     if (((P->used * 2 + 1) < MP_WARRAY) &&
-          P->used < (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
-        redux = fast_mp_montgomery_reduce;
-     } else
-#endif
-     {
-#ifdef BN_MP_MONTGOMERY_REDUCE_C
-        /* use slower baseline Montgomery method */
-        redux = mp_montgomery_reduce;
-#else
-        err = MP_VAL;
-        goto LBL_M;
-#endif
-     }
-  } else if (redmode == 1) {
-#if defined(BN_MP_DR_SETUP_C) && defined(BN_MP_DR_REDUCE_C)
-     /* setup DR reduction for moduli of the form B**k - b */
-     mp_dr_setup(P, &mp);
-     redux = mp_dr_reduce;
-#else
-     err = MP_VAL;
-     goto LBL_M;
-#endif
-  } else {
-#if defined(BN_MP_REDUCE_2K_SETUP_C) && defined(BN_MP_REDUCE_2K_C)
-     /* setup DR reduction for moduli of the form 2**k - b */
-     if ((err = mp_reduce_2k_setup(P, &mp)) != MP_OKAY) {
-        goto LBL_M;
-     }
-     redux = mp_reduce_2k;
-#else
-     err = MP_VAL;
-     goto LBL_M;
-#endif
-  }
-
-  /* setup result */
-  if ((err = mp_init (&res)) != MP_OKAY) {
-    goto LBL_M;
-  }
-
-  /* create M table
-   *
-
-   *
-   * The first half of the table is not computed though accept for M[0] and M[1]
-   */
-
-  if (redmode == 0) {
-#ifdef BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
-     /* now we need R mod m */
-     if ((err = mp_montgomery_calc_normalization (&res, P)) != MP_OKAY) {
-       goto LBL_RES;
-     }
-#else
-     err = MP_VAL;
-     goto LBL_RES;
-#endif
-
-     /* now set M[1] to G * R mod m */
-     if ((err = mp_mulmod (G, &res, P, &M[1])) != MP_OKAY) {
-       goto LBL_RES;
-     }
-  } else {
-     mp_set(&res, 1);
-     if ((err = mp_mod(G, P, &M[1])) != MP_OKAY) {
-        goto LBL_RES;
-     }
-  }
-
-  /* compute the value at M[1<<(winsize-1)] by squaring M[1] (winsize-1) times*/
-  if ((err = mp_copy (&M[1], &M[(mp_digit)(1 << (winsize - 1))])) != MP_OKAY) {
-    goto LBL_RES;
-  }
-
-  for (x = 0; x < (winsize - 1); x++) {
-    if ((err = mp_sqr (&M[(mp_digit)(1 << (winsize - 1))], &M[(mp_digit)(1 << (winsize - 1))])) != MP_OKAY) {
-      goto LBL_RES;
-    }
-    if ((err = redux (&M[(mp_digit)(1 << (winsize - 1))], P, mp)) != MP_OKAY) {
-      goto LBL_RES;
-    }
-  }
-
-  /* create upper table */
-  for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) {
-    if ((err = mp_mul (&M[x - 1], &M[1], &M[x])) != MP_OKAY) {
-      goto LBL_RES;
-    }
-    if ((err = redux (&M[x], P, mp)) != MP_OKAY) {
-      goto LBL_RES;
-    }
-  }
-
-  /* set initial mode and bit cnt */
-  mode   = 0;
-  bitcnt = 1;
-  buf    = 0;
-  digidx = X->used - 1;
-  bitcpy = 0;
-  bitbuf = 0;
-
-  for (;;) {
-    /* grab next digit as required */
-    if (--bitcnt == 0) {
-      /* if digidx == -1 we are out of digits so break */
-      if (digidx == -1) {
-        break;
-      }
-      /* read next digit and reset bitcnt */
-      buf    = X->dp[digidx--];
-      bitcnt = (int)DIGIT_BIT;
-    }
-
-    /* grab the next msb from the exponent */
-    y     = (int)(buf >> (DIGIT_BIT - 1)) & 1;
-    buf <<= (mp_digit)1;
-
-    /* if the bit is zero and mode == 0 then we ignore it
-     * These represent the leading zero bits before the first 1 bit
-     * in the exponent.  Technically this opt is not required but it
-     * does lower the # of trivial squaring/reductions used
-     */
-    if (mode == 0 && y == 0) {
-      continue;
-    }
-
-    /* if the bit is zero and mode == 1 then we square */
-    if (mode == 1 && y == 0) {
-      if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
-        goto LBL_RES;
-      }
-      if ((err = redux (&res, P, mp)) != MP_OKAY) {
-        goto LBL_RES;
-      }
-      continue;
-    }
-
-    /* else we add it to the window */
-    bitbuf |= (y << (winsize - ++bitcpy));
-    mode    = 2;
-
-    if (bitcpy == winsize) {
-      /* ok window is filled so square as required and multiply  */
-      /* square first */
-      for (x = 0; x < winsize; x++) {
-        if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
-          goto LBL_RES;
-        }
-        if ((err = redux (&res, P, mp)) != MP_OKAY) {
-          goto LBL_RES;
-        }
-      }
-
-      /* then multiply */
-      if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) {
-        goto LBL_RES;
-      }
-      if ((err = redux (&res, P, mp)) != MP_OKAY) {
-        goto LBL_RES;
-      }
-
-      /* empty window and reset */
-      bitcpy = 0;
-      bitbuf = 0;
-      mode   = 1;
-    }
-  }
-
-  /* if bits remain then square/multiply */
-  if (mode == 2 && bitcpy > 0) {
-    /* square then multiply if the bit is set */
-    for (x = 0; x < bitcpy; x++) {
-      if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
-        goto LBL_RES;
-      }
-      if ((err = redux (&res, P, mp)) != MP_OKAY) {
-        goto LBL_RES;
-      }
-
-      /* get next bit of the window */
-      bitbuf <<= 1;
-      if ((bitbuf & (1 << winsize)) != 0) {
-        /* then multiply */
-        if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) {
-          goto LBL_RES;
-        }
-        if ((err = redux (&res, P, mp)) != MP_OKAY) {
-          goto LBL_RES;
-        }
-      }
-    }
-  }
-
-  if (redmode == 0) {
-     /* fixup result if Montgomery reduction is used
-      * recall that any value in a Montgomery system is
-      * actually multiplied by R mod n.  So we have
-      * to reduce one more time to cancel out the factor
-      * of R.
-      */
-     if ((err = redux(&res, P, mp)) != MP_OKAY) {
-       goto LBL_RES;
-     }
-  }
-
-  /* swap res with Y */
-  mp_exch (&res, Y);
-  err = MP_OKAY;
-LBL_RES:mp_clear (&res);
-LBL_M:
-  mp_clear(&M[1]);
-  for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
-    mp_clear (&M[x]);
-  }
-
-#ifdef WOLFSSL_SMALL_STACK
-  XFREE(M, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-  return err;
-}
-
-
-/* setups the montgomery reduction stuff */
-int
-mp_montgomery_setup (mp_int * n, mp_digit * rho)
-{
-  mp_digit x, b;
-
-/* fast inversion mod 2**k
- *
- * Based on the fact that
- *
- * XA = 1 (mod 2**n)  =>  (X(2-XA)) A = 1 (mod 2**2n)
- *                    =>  2*X*A - X*X*A*A = 1
- *                    =>  2*(1) - (1)     = 1
- */
-  b = n->dp[0];
-
-  if ((b & 1) == 0) {
-    return MP_VAL;
-  }
-
-  x = (((b + 2) & 4) << 1) + b; /* here x*a==1 mod 2**4 */
-  x *= 2 - b * x;               /* here x*a==1 mod 2**8 */
-#if !defined(MP_8BIT)
-  x *= 2 - b * x;               /* here x*a==1 mod 2**16 */
-#endif
-#if defined(MP_64BIT) || !(defined(MP_8BIT) || defined(MP_16BIT))
-  x *= 2 - b * x;               /* here x*a==1 mod 2**32 */
-#endif
-#ifdef MP_64BIT
-  x *= 2 - b * x;               /* here x*a==1 mod 2**64 */
-#endif
-
-  /* rho = -1/m mod b */
-  /* TAO, switched mp_word casts to mp_digit to shut up compiler */
-  *rho = (((mp_digit)1 << ((mp_digit) DIGIT_BIT)) - x) & MP_MASK;
-
-  return MP_OKAY;
-}
-
-
-/* computes xR**-1 == x (mod N) via Montgomery Reduction
- *
- * This is an optimized implementation of montgomery_reduce
- * which uses the comba method to quickly calculate the columns of the
- * reduction.
- *
- * Based on Algorithm 14.32 on pp.601 of HAC.
-*/
-int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
-{
-  int     ix, res, olduse;
-#ifdef WOLFSSL_SMALL_STACK
-  mp_word* W;    /* uses dynamic memory and slower */
-#else
-  mp_word W[MP_WARRAY];
-#endif
-
-  /* get old used count */
-  olduse = x->used;
-
-  /* grow a as required */
-  if (x->alloc < n->used + 1) {
-    if ((res = mp_grow (x, n->used + 1)) != MP_OKAY) {
-      return res;
-    }
-  }
-
-#ifdef WOLFSSL_SMALL_STACK
-  W = (mp_word*)XMALLOC(sizeof(mp_word) * MP_WARRAY, 0, DYNAMIC_TYPE_BIGINT);
-  if (W == NULL)
-    return MP_MEM;
-#endif
-
-  /* first we have to get the digits of the input into
-   * an array of double precision words W[...]
-   */
-  {
-    register mp_word *_W;
-    register mp_digit *tmpx;
-
-    /* alias for the W[] array */
-    _W   = W;
-
-    /* alias for the digits of  x*/
-    tmpx = x->dp;
-
-    /* copy the digits of a into W[0..a->used-1] */
-    for (ix = 0; ix < x->used; ix++) {
-      *_W++ = *tmpx++;
-    }
-
-    /* zero the high words of W[a->used..m->used*2] */
-    for (; ix < n->used * 2 + 1; ix++) {
-      *_W++ = 0;
-    }
-  }
-
-  /* now we proceed to zero successive digits
-   * from the least significant upwards
-   */
-  for (ix = 0; ix < n->used; ix++) {
-    /* mu = ai * m' mod b
-     *
-     * We avoid a double precision multiplication (which isn't required)
-     * by casting the value down to a mp_digit.  Note this requires
-     * that W[ix-1] have  the carry cleared (see after the inner loop)
-     */
-    register mp_digit mu;
-    mu = (mp_digit) (((W[ix] & MP_MASK) * rho) & MP_MASK);
-
-    /* a = a + mu * m * b**i
-     *
-     * This is computed in place and on the fly.  The multiplication
-     * by b**i is handled by offseting which columns the results
-     * are added to.
-     *
-     * Note the comba method normally doesn't handle carries in the
-     * inner loop In this case we fix the carry from the previous
-     * column since the Montgomery reduction requires digits of the
-     * result (so far) [see above] to work.  This is
-     * handled by fixing up one carry after the inner loop.  The
-     * carry fixups are done in order so after these loops the
-     * first m->used words of W[] have the carries fixed
-     */
-    {
-      register int iy;
-      register mp_digit *tmpn;
-      register mp_word *_W;
-
-      /* alias for the digits of the modulus */
-      tmpn = n->dp;
-
-      /* Alias for the columns set by an offset of ix */
-      _W = W + ix;
-
-      /* inner loop */
-      for (iy = 0; iy < n->used; iy++) {
-          *_W++ += ((mp_word)mu) * ((mp_word)*tmpn++);
-      }
-    }
-
-    /* now fix carry for next digit, W[ix+1] */
-    W[ix + 1] += W[ix] >> ((mp_word) DIGIT_BIT);
-  }
-
-  /* now we have to propagate the carries and
-   * shift the words downward [all those least
-   * significant digits we zeroed].
-   */
-  {
-    register mp_digit *tmpx;
-    register mp_word *_W, *_W1;
-
-    /* nox fix rest of carries */
-
-    /* alias for current word */
-    _W1 = W + ix;
-
-    /* alias for next word, where the carry goes */
-    _W = W + ++ix;
-
-    for (; ix <= n->used * 2 + 1; ix++) {
-      *_W++ += *_W1++ >> ((mp_word) DIGIT_BIT);
-    }
-
-    /* copy out, A = A/b**n
-     *
-     * The result is A/b**n but instead of converting from an
-     * array of mp_word to mp_digit than calling mp_rshd
-     * we just copy them in the right order
-     */
-
-    /* alias for destination word */
-    tmpx = x->dp;
-
-    /* alias for shifted double precision result */
-    _W = W + n->used;
-
-    for (ix = 0; ix < n->used + 1; ix++) {
-      *tmpx++ = (mp_digit)(*_W++ & ((mp_word) MP_MASK));
-    }
-
-    /* zero oldused digits, if the input a was larger than
-     * m->used+1 we'll have to clear the digits
-     */
-    for (; ix < olduse; ix++) {
-      *tmpx++ = 0;
-    }
-  }
-
-  /* set the max used and clamp */
-  x->used = n->used + 1;
-  mp_clamp (x);
-
-#ifdef WOLFSSL_SMALL_STACK
-  XFREE(W, 0, DYNAMIC_TYPE_BIGINT);
-#endif
-
-  /* if A >= m then A = A - m */
-  if (mp_cmp_mag (x, n) != MP_LT) {
-    return s_mp_sub (x, n, x);
-  }
-  return MP_OKAY;
-}
-
-
-/* computes xR**-1 == x (mod N) via Montgomery Reduction */
-int
-mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
-{
-  int     ix, res, digs;
-  mp_digit mu;
-
-  /* can the fast reduction [comba] method be used?
-   *
-   * Note that unlike in mul you're safely allowed *less*
-   * than the available columns [255 per default] since carries
-   * are fixed up in the inner loop.
-   */
-  digs = n->used * 2 + 1;
-  if ((digs < MP_WARRAY) &&
-      n->used <
-      (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
-    return fast_mp_montgomery_reduce (x, n, rho);
-  }
-
-  /* grow the input as required */
-  if (x->alloc < digs) {
-    if ((res = mp_grow (x, digs)) != MP_OKAY) {
-      return res;
-    }
-  }
-  x->used = digs;
-
-  for (ix = 0; ix < n->used; ix++) {
-    /* mu = ai * rho mod b
-     *
-     * The value of rho must be precalculated via
-     * montgomery_setup() such that
-     * it equals -1/n0 mod b this allows the
-     * following inner loop to reduce the
-     * input one digit at a time
-     */
-    mu = (mp_digit) (((mp_word)x->dp[ix]) * ((mp_word)rho) & MP_MASK);
-
-    /* a = a + mu * m * b**i */
-    {
-      register int iy;
-      register mp_digit *tmpn, *tmpx, u;
-      register mp_word r;
-
-      /* alias for digits of the modulus */
-      tmpn = n->dp;
-
-      /* alias for the digits of x [the input] */
-      tmpx = x->dp + ix;
-
-      /* set the carry to zero */
-      u = 0;
-
-      /* Multiply and add in place */
-      for (iy = 0; iy < n->used; iy++) {
-        /* compute product and sum */
-        r       = ((mp_word)mu) * ((mp_word)*tmpn++) +
-                  ((mp_word) u) + ((mp_word) * tmpx);
-
-        /* get carry */
-        u       = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
-
-        /* fix digit */
-        *tmpx++ = (mp_digit)(r & ((mp_word) MP_MASK));
-      }
-      /* At this point the ix'th digit of x should be zero */
-
-
-      /* propagate carries upwards as required*/
-      while (u) {
-        *tmpx   += u;
-        u        = *tmpx >> DIGIT_BIT;
-        *tmpx++ &= MP_MASK;
-      }
-    }
-  }
-
-  /* at this point the n.used'th least
-   * significant digits of x are all zero
-   * which means we can shift x to the
-   * right by n.used digits and the
-   * residue is unchanged.
-   */
-
-  /* x = x/b**n.used */
-  mp_clamp(x);
-  mp_rshd (x, n->used);
-
-  /* if x >= n then x = x - n */
-  if (mp_cmp_mag (x, n) != MP_LT) {
-    return s_mp_sub (x, n, x);
-  }
-
-  return MP_OKAY;
-}
-
-
-/* determines the setup value */
-void mp_dr_setup(mp_int *a, mp_digit *d)
-{
-   /* the casts are required if DIGIT_BIT is one less than
-    * the number of bits in a mp_digit [e.g. DIGIT_BIT==31]
-    */
-   *d = (mp_digit)((((mp_word)1) << ((mp_word)DIGIT_BIT)) -
-        ((mp_word)a->dp[0]));
-}
-
-
-/* reduce "x" in place modulo "n" using the Diminished Radix algorithm.
- *
- * Based on algorithm from the paper
- *
- * "Generating Efficient Primes for Discrete Log Cryptosystems"
- *                 Chae Hoon Lim, Pil Joong Lee,
- *          POSTECH Information Research Laboratories
- *
- * The modulus must be of a special format [see manual]
- *
- * Has been modified to use algorithm 7.10 from the LTM book instead
- *
- * Input x must be in the range 0 <= x <= (n-1)**2
- */
-int
-mp_dr_reduce (mp_int * x, mp_int * n, mp_digit k)
-{
-  int      err, i, m;
-  mp_word  r;
-  mp_digit mu, *tmpx1, *tmpx2;
-
-  /* m = digits in modulus */
-  m = n->used;
-
-  /* ensure that "x" has at least 2m digits */
-  if (x->alloc < m + m) {
-    if ((err = mp_grow (x, m + m)) != MP_OKAY) {
-      return err;
-    }
-  }
-
-/* top of loop, this is where the code resumes if
- * another reduction pass is required.
- */
-top:
-  /* aliases for digits */
-  /* alias for lower half of x */
-  tmpx1 = x->dp;
-
-  /* alias for upper half of x, or x/B**m */
-  tmpx2 = x->dp + m;
-
-  /* set carry to zero */
-  mu = 0;
-
-  /* compute (x mod B**m) + k * [x/B**m] inline and inplace */
-  for (i = 0; i < m; i++) {
-      r         = ((mp_word)*tmpx2++) * ((mp_word)k) + *tmpx1 + mu;
-      *tmpx1++  = (mp_digit)(r & MP_MASK);
-      mu        = (mp_digit)(r >> ((mp_word)DIGIT_BIT));
-  }
-
-  /* set final carry */
-  *tmpx1++ = mu;
-
-  /* zero words above m */
-  for (i = m + 1; i < x->used; i++) {
-      *tmpx1++ = 0;
-  }
-
-  /* clamp, sub and return */
-  mp_clamp (x);
-
-  /* if x >= n then subtract and reduce again
-   * Each successive "recursion" makes the input smaller and smaller.
-   */
-  if (mp_cmp_mag (x, n) != MP_LT) {
-    s_mp_sub(x, n, x);
-    goto top;
-  }
-  return MP_OKAY;
-}
-
-
-/* reduces a modulo n where n is of the form 2**p - d */
-int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d)
-{
-   mp_int q;
-   int    p, res;
-
-   if ((res = mp_init(&q)) != MP_OKAY) {
-      return res;
-   }
-
-   p = mp_count_bits(n);
-top:
-   /* q = a/2**p, a = a mod 2**p */
-   if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
-      goto ERR;
-   }
-
-   if (d != 1) {
-      /* q = q * d */
-      if ((res = mp_mul_d(&q, d, &q)) != MP_OKAY) {
-         goto ERR;
-      }
-   }
-
-   /* a = a + q */
-   if ((res = s_mp_add(a, &q, a)) != MP_OKAY) {
-      goto ERR;
-   }
-
-   if (mp_cmp_mag(a, n) != MP_LT) {
-      s_mp_sub(a, n, a);
-      goto top;
-   }
-
-ERR:
-   mp_clear(&q);
-   return res;
-}
-
-
-/* determines the setup value */
-int mp_reduce_2k_setup(mp_int *a, mp_digit *d)
-{
-   int res, p;
-   mp_int tmp;
-
-   if ((res = mp_init(&tmp)) != MP_OKAY) {
-      return res;
-   }
-
-   p = mp_count_bits(a);
-   if ((res = mp_2expt(&tmp, p)) != MP_OKAY) {
-      mp_clear(&tmp);
-      return res;
-   }
-
-   if ((res = s_mp_sub(&tmp, a, &tmp)) != MP_OKAY) {
-      mp_clear(&tmp);
-      return res;
-   }
-
-   *d = tmp.dp[0];
-   mp_clear(&tmp);
-   return MP_OKAY;
-}
-
-
-/* computes a = 2**b
- *
- * Simple algorithm which zeroes the int, grows it then just sets one bit
- * as required.
- */
-int
-mp_2expt (mp_int * a, int b)
-{
-  int     res;
-
-  /* zero a as per default */
-  mp_zero (a);
-
-  /* grow a to accomodate the single bit */
-  if ((res = mp_grow (a, b / DIGIT_BIT + 1)) != MP_OKAY) {
-    return res;
-  }
-
-  /* set the used count of where the bit will go */
-  a->used = b / DIGIT_BIT + 1;
-
-  /* put the single bit in its place */
-  a->dp[b / DIGIT_BIT] = ((mp_digit)1) << (b % DIGIT_BIT);
-
-  return MP_OKAY;
-}
-
-
-/* multiply by a digit */
-int
-mp_mul_d (mp_int * a, mp_digit b, mp_int * c)
-{
-  mp_digit u, *tmpa, *tmpc;
-  mp_word  r;
-  int      ix, res, olduse;
-
-  /* make sure c is big enough to hold a*b */
-  if (c->alloc < a->used + 1) {
-    if ((res = mp_grow (c, a->used + 1)) != MP_OKAY) {
-      return res;
-    }
-  }
-
-  /* get the original destinations used count */
-  olduse = c->used;
-
-  /* set the sign */
-  c->sign = a->sign;
-
-  /* alias for a->dp [source] */
-  tmpa = a->dp;
-
-  /* alias for c->dp [dest] */
-  tmpc = c->dp;
-
-  /* zero carry */
-  u = 0;
-
-  /* compute columns */
-  for (ix = 0; ix < a->used; ix++) {
-    /* compute product and carry sum for this term */
-    r       = ((mp_word) u) + ((mp_word)*tmpa++) * ((mp_word)b);
-
-    /* mask off higher bits to get a single digit */
-    *tmpc++ = (mp_digit) (r & ((mp_word) MP_MASK));
-
-    /* send carry into next iteration */
-    u       = (mp_digit) (r >> ((mp_word) DIGIT_BIT));
-  }
-
-  /* store final carry [if any] and increment ix offset  */
-  *tmpc++ = u;
-  ++ix;
-
-  /* now zero digits above the top */
-  while (ix++ < olduse) {
-     *tmpc++ = 0;
-  }
-
-  /* set used count */
-  c->used = a->used + 1;
-  mp_clamp(c);
-
-  return MP_OKAY;
-}
-
-
-/* d = a * b (mod c) */
-int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
-{
-  int     res;
-  mp_int  t;
-
-  if ((res = mp_init (&t)) != MP_OKAY) {
-    return res;
-  }
-
-  if ((res = mp_mul (a, b, &t)) != MP_OKAY) {
-    mp_clear (&t);
-    return res;
-  }
-  res = mp_mod (&t, c, d);
-  mp_clear (&t);
-  return res;
-}
-
-
-/* computes b = a*a */
-int
-mp_sqr (mp_int * a, mp_int * b)
-{
-  int     res;
-
-  {
-#ifdef BN_FAST_S_MP_SQR_C
-    /* can we use the fast comba multiplier? */
-    if ((a->used * 2 + 1) < MP_WARRAY &&
-         a->used <
-         (1 << (sizeof(mp_word) * CHAR_BIT - 2*DIGIT_BIT - 1))) {
-      res = fast_s_mp_sqr (a, b);
-    } else
-#endif
-#ifdef BN_S_MP_SQR_C
-      res = s_mp_sqr (a, b);
-#else
-      res = MP_VAL;
-#endif
-  }
-  b->sign = MP_ZPOS;
-  return res;
-}
-
-
-/* high level multiplication (handles sign) */
-int mp_mul (mp_int * a, mp_int * b, mp_int * c)
-{
-  int     res, neg;
-  neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG;
-
-  {
-    /* can we use the fast multiplier?
-     *
-     * The fast multiplier can be used if the output will
-     * have less than MP_WARRAY digits and the number of
-     * digits won't affect carry propagation
-     */
-    int     digs = a->used + b->used + 1;
-
-#ifdef BN_FAST_S_MP_MUL_DIGS_C
-    if ((digs < MP_WARRAY) &&
-        MIN(a->used, b->used) <=
-        (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
-      res = fast_s_mp_mul_digs (a, b, c, digs);
-    } else
-#endif
-#ifdef BN_S_MP_MUL_DIGS_C
-      res = s_mp_mul (a, b, c); /* uses s_mp_mul_digs */
-#else
-      res = MP_VAL;
-#endif
-
-  }
-  c->sign = (c->used > 0) ? neg : MP_ZPOS;
-  return res;
-}
-
-
-/* b = a*2 */
-int mp_mul_2(mp_int * a, mp_int * b)
-{
-  int     x, res, oldused;
-
-  /* grow to accomodate result */
-  if (b->alloc < a->used + 1) {
-    if ((res = mp_grow (b, a->used + 1)) != MP_OKAY) {
-      return res;
-    }
-  }
-
-  oldused = b->used;
-  b->used = a->used;
-
-  {
-    register mp_digit r, rr, *tmpa, *tmpb;
-
-    /* alias for source */
-    tmpa = a->dp;
-
-    /* alias for dest */
-    tmpb = b->dp;
-
-    /* carry */
-    r = 0;
-    for (x = 0; x < a->used; x++) {
-
-      /* get what will be the *next* carry bit from the
-       * MSB of the current digit
-       */
-      rr = *tmpa >> ((mp_digit)(DIGIT_BIT - 1));
-
-      /* now shift up this digit, add in the carry [from the previous] */
-      *tmpb++ = ((*tmpa++ << ((mp_digit)1)) | r) & MP_MASK;
-
-      /* copy the carry that would be from the source
-       * digit into the next iteration
-       */
-      r = rr;
-    }
-
-    /* new leading digit? */
-    if (r != 0) {
-      /* add a MSB which is always 1 at this point */
-      *tmpb = 1;
-      ++(b->used);
-    }
-
-    /* now zero any excess digits on the destination
-     * that we didn't write to
-     */
-    tmpb = b->dp + b->used;
-    for (x = b->used; x < oldused; x++) {
-      *tmpb++ = 0;
-    }
-  }
-  b->sign = a->sign;
-  return MP_OKAY;
-}
-
-
-/* divide by three (based on routine from MPI and the GMP manual) */
-int
-mp_div_3 (mp_int * a, mp_int *c, mp_digit * d)
-{
-  mp_int   q;
-  mp_word  w, t;
-  mp_digit b;
-  int      res, ix;
-
-  /* b = 2**DIGIT_BIT / 3 */
-  b = (mp_digit) ( (((mp_word)1) << ((mp_word)DIGIT_BIT)) / ((mp_word)3) );
-
-  if ((res = mp_init_size(&q, a->used)) != MP_OKAY) {
-     return res;
-  }
-
-  q.used = a->used;
-  q.sign = a->sign;
-  w = 0;
-  for (ix = a->used - 1; ix >= 0; ix--) {
-     w = (w << ((mp_word)DIGIT_BIT)) | ((mp_word)a->dp[ix]);
-
-     if (w >= 3) {
-        /* multiply w by [1/3] */
-        t = (w * ((mp_word)b)) >> ((mp_word)DIGIT_BIT);
-
-        /* now subtract 3 * [w/3] from w, to get the remainder */
-        w -= t+t+t;
-
-        /* fixup the remainder as required since
-         * the optimization is not exact.
-         */
-        while (w >= 3) {
-           t += 1;
-           w -= 3;
-        }
-      } else {
-        t = 0;
-      }
-      q.dp[ix] = (mp_digit)t;
-  }
-
-  /* [optional] store the remainder */
-  if (d != NULL) {
-     *d = (mp_digit)w;
-  }
-
-  /* [optional] store the quotient */
-  if (c != NULL) {
-     mp_clamp(&q);
-     mp_exch(&q, c);
-  }
-  mp_clear(&q);
-
-  return res;
-}
-
-
-/* init an mp_init for a given size */
-int mp_init_size (mp_int * a, int size)
-{
-  int x;
-
-  /* pad size so there are always extra digits */
-  size += (MP_PREC * 2) - (size % MP_PREC);
-
-  /* alloc mem */
-  a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * size, 0,
-                                      DYNAMIC_TYPE_BIGINT);
-  if (a->dp == NULL) {
-    return MP_MEM;
-  }
-
-  /* set the members */
-  a->used  = 0;
-  a->alloc = size;
-  a->sign  = MP_ZPOS;
-
-  /* zero the digits */
-  for (x = 0; x < size; x++) {
-      a->dp[x] = 0;
-  }
-
-  return MP_OKAY;
-}
-
-
-/* the jist of squaring...
- * you do like mult except the offset of the tmpx [one that
- * starts closer to zero] can't equal the offset of tmpy.
- * So basically you set up iy like before then you min it with
- * (ty-tx) so that it never happens.  You double all those
- * you add in the inner loop
-
-After that loop you do the squares and add them in.
-*/
-
-int fast_s_mp_sqr (mp_int * a, mp_int * b)
-{
-  int       olduse, res, pa, ix, iz;
-#ifdef WOLFSSL_SMALL_STACK
-  mp_digit* W;    /* uses dynamic memory and slower */
-#else
-  mp_digit W[MP_WARRAY];
-#endif
-  mp_digit  *tmpx;
-  mp_word   W1;
-
-  /* grow the destination as required */
-  pa = a->used + a->used;
-  if (b->alloc < pa) {
-    if ((res = mp_grow (b, pa)) != MP_OKAY) {
-      return res;
-    }
-  }
-
-  if (pa > MP_WARRAY)
-    return MP_RANGE;  /* TAO range check */
-
-#ifdef WOLFSSL_SMALL_STACK
-  W = (mp_digit*)XMALLOC(sizeof(mp_digit) * MP_WARRAY, 0, DYNAMIC_TYPE_BIGINT);
-  if (W == NULL)
-    return MP_MEM;
-#endif
-
-  /* number of output digits to produce */
-  W1 = 0;
-  for (ix = 0; ix < pa; ix++) {
-      int      tx, ty, iy;
-      mp_word  _W;
-      mp_digit *tmpy;
-
-      /* clear counter */
-      _W = 0;
-
-      /* get offsets into the two bignums */
-      ty = MIN(a->used-1, ix);
-      tx = ix - ty;
-
-      /* setup temp aliases */
-      tmpx = a->dp + tx;
-      tmpy = a->dp + ty;
-
-      /* this is the number of times the loop will iterrate, essentially
-         while (tx++ < a->used && ty-- >= 0) { ... }
-       */
-      iy = MIN(a->used-tx, ty+1);
-
-      /* now for squaring tx can never equal ty
-       * we halve the distance since they approach at a rate of 2x
-       * and we have to round because odd cases need to be executed
-       */
-      iy = MIN(iy, (ty-tx+1)>>1);
-
-      /* execute loop */
-      for (iz = 0; iz < iy; iz++) {
-         _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--);
-      }
-
-      /* double the inner product and add carry */
-      _W = _W + _W + W1;
-
-      /* even columns have the square term in them */
-      if ((ix&1) == 0) {
-         _W += ((mp_word)a->dp[ix>>1])*((mp_word)a->dp[ix>>1]);
-      }
-
-      /* store it */
-      W[ix] = (mp_digit)(_W & MP_MASK);
-
-      /* make next carry */
-      W1 = _W >> ((mp_word)DIGIT_BIT);
-  }
-
-  /* setup dest */
-  olduse  = b->used;
-  b->used = a->used+a->used;
-
-  {
-    mp_digit *tmpb;
-    tmpb = b->dp;
-    for (ix = 0; ix < pa; ix++) {
-      *tmpb++ = W[ix] & MP_MASK;
-    }
-
-    /* clear unused digits [that existed in the old copy of c] */
-    for (; ix < olduse; ix++) {
-      *tmpb++ = 0;
-    }
-  }
-  mp_clamp (b);
-
-#ifdef WOLFSSL_SMALL_STACK
-  XFREE(W, 0, DYNAMIC_TYPE_BIGINT);
-#endif
-
-  return MP_OKAY;
-}
-
-
-/* Fast (comba) multiplier
- *
- * This is the fast column-array [comba] multiplier.  It is
- * designed to compute the columns of the product first
- * then handle the carries afterwards.  This has the effect
- * of making the nested loops that compute the columns very
- * simple and schedulable on super-scalar processors.
- *
- * This has been modified to produce a variable number of
- * digits of output so if say only a half-product is required
- * you don't have to compute the upper half (a feature
- * required for fast Barrett reduction).
- *
- * Based on Algorithm 14.12 on pp.595 of HAC.
- *
- */
-int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
-{
-  int     olduse, res, pa, ix, iz;
-#ifdef WOLFSSL_SMALL_STACK
-  mp_digit* W;    /* uses dynamic memory and slower */
-#else
-  mp_digit W[MP_WARRAY];
-#endif
-  register mp_word  _W;
-
-  /* grow the destination as required */
-  if (c->alloc < digs) {
-    if ((res = mp_grow (c, digs)) != MP_OKAY) {
-      return res;
-    }
-  }
-
-  /* number of output digits to produce */
-  pa = MIN(digs, a->used + b->used);
-  if (pa > MP_WARRAY)
-    return MP_RANGE;  /* TAO range check */
-
-#ifdef WOLFSSL_SMALL_STACK
-  W = (mp_digit*)XMALLOC(sizeof(mp_digit) * MP_WARRAY, 0, DYNAMIC_TYPE_BIGINT);
-  if (W == NULL)
-    return MP_MEM;
-#endif
-
-  /* clear the carry */
-  _W = 0;
-  for (ix = 0; ix < pa; ix++) {
-      int      tx, ty;
-      int      iy;
-      mp_digit *tmpx, *tmpy;
-
-      /* get offsets into the two bignums */
-      ty = MIN(b->used-1, ix);
-      tx = ix - ty;
-
-      /* setup temp aliases */
-      tmpx = a->dp + tx;
-      tmpy = b->dp + ty;
-
-      /* this is the number of times the loop will iterrate, essentially
-         while (tx++ < a->used && ty-- >= 0) { ... }
-       */
-      iy = MIN(a->used-tx, ty+1);
-
-      /* execute loop */
-      for (iz = 0; iz < iy; ++iz) {
-         _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--);
-
-      }
-
-      /* store term */
-      W[ix] = ((mp_digit)_W) & MP_MASK;
-
-      /* make next carry */
-      _W = _W >> ((mp_word)DIGIT_BIT);
- }
-
-  /* setup dest */
-  olduse  = c->used;
-  c->used = pa;
-
-  {
-    register mp_digit *tmpc;
-    tmpc = c->dp;
-    for (ix = 0; ix < pa+1; ix++) {
-      /* now extract the previous digit [below the carry] */
-      *tmpc++ = W[ix];
-    }
-
-    /* clear unused digits [that existed in the old copy of c] */
-    for (; ix < olduse; ix++) {
-      *tmpc++ = 0;
-    }
-  }
-  mp_clamp (c);
-
-#ifdef WOLFSSL_SMALL_STACK
-  XFREE(W, 0, DYNAMIC_TYPE_BIGINT);
-#endif
-
-  return MP_OKAY;
-}
-
-
-/* low level squaring, b = a*a, HAC pp.596-597, Algorithm 14.16 */
-int s_mp_sqr (mp_int * a, mp_int * b)
-{
-  mp_int  t;
-  int     res, ix, iy, pa;
-  mp_word r;
-  mp_digit u, tmpx, *tmpt;
-
-  pa = a->used;
-  if ((res = mp_init_size (&t, 2*pa + 1)) != MP_OKAY) {
-    return res;
-  }
-
-  /* default used is maximum possible size */
-  t.used = 2*pa + 1;
-
-  for (ix = 0; ix < pa; ix++) {
-    /* first calculate the digit at 2*ix */
-    /* calculate double precision result */
-    r = ((mp_word) t.dp[2*ix]) +
-        ((mp_word)a->dp[ix])*((mp_word)a->dp[ix]);
-
-    /* store lower part in result */
-    t.dp[ix+ix] = (mp_digit) (r & ((mp_word) MP_MASK));
-
-    /* get the carry */
-    u           = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
-
-    /* left hand side of A[ix] * A[iy] */
-    tmpx        = a->dp[ix];
-
-    /* alias for where to store the results */
-    tmpt        = t.dp + (2*ix + 1);
-
-    for (iy = ix + 1; iy < pa; iy++) {
-      /* first calculate the product */
-      r       = ((mp_word)tmpx) * ((mp_word)a->dp[iy]);
-
-      /* now calculate the double precision result, note we use
-       * addition instead of *2 since it's easier to optimize
-       */
-      r       = ((mp_word) *tmpt) + r + r + ((mp_word) u);
-
-      /* store lower part */
-      *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
-
-      /* get carry */
-      u       = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
-    }
-    /* propagate upwards */
-    while (u != ((mp_digit) 0)) {
-      r       = ((mp_word) *tmpt) + ((mp_word) u);
-      *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
-      u       = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
-    }
-  }
-
-  mp_clamp (&t);
-  mp_exch (&t, b);
-  mp_clear (&t);
-  return MP_OKAY;
-}
-
-
-/* multiplies |a| * |b| and only computes upto digs digits of result
- * HAC pp. 595, Algorithm 14.12  Modified so you can control how
- * many digits of output are created.
- */
-int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
-{
-  mp_int  t;
-  int     res, pa, pb, ix, iy;
-  mp_digit u;
-  mp_word r;
-  mp_digit tmpx, *tmpt, *tmpy;
-
-  /* can we use the fast multiplier? */
-  if (((digs) < MP_WARRAY) &&
-      MIN (a->used, b->used) <
-          (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
-    return fast_s_mp_mul_digs (a, b, c, digs);
-  }
-
-  if ((res = mp_init_size (&t, digs)) != MP_OKAY) {
-    return res;
-  }
-  t.used = digs;
-
-  /* compute the digits of the product directly */
-  pa = a->used;
-  for (ix = 0; ix < pa; ix++) {
-    /* set the carry to zero */
-    u = 0;
-
-    /* limit ourselves to making digs digits of output */
-    pb = MIN (b->used, digs - ix);
-
-    /* setup some aliases */
-    /* copy of the digit from a used within the nested loop */
-    tmpx = a->dp[ix];
-
-    /* an alias for the destination shifted ix places */
-    tmpt = t.dp + ix;
-
-    /* an alias for the digits of b */
-    tmpy = b->dp;
-
-    /* compute the columns of the output and propagate the carry */
-    for (iy = 0; iy < pb; iy++) {
-      /* compute the column as a mp_word */
-      r       = ((mp_word)*tmpt) +
-                ((mp_word)tmpx) * ((mp_word)*tmpy++) +
-                ((mp_word) u);
-
-      /* the new column is the lower part of the result */
-      *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
-
-      /* get the carry word from the result */
-      u       = (mp_digit) (r >> ((mp_word) DIGIT_BIT));
-    }
-    /* set carry if it is placed below digs */
-    if (ix + iy < digs) {
-      *tmpt = u;
-    }
-  }
-
-  mp_clamp (&t);
-  mp_exch (&t, c);
-
-  mp_clear (&t);
-  return MP_OKAY;
-}
-
-
-/*
- * shifts with subtractions when the result is greater than b.
- *
- * The method is slightly modified to shift B unconditionally upto just under
- * the leading bit of b.  This saves alot of multiple precision shifting.
- */
-int mp_montgomery_calc_normalization (mp_int * a, mp_int * b)
-{
-  int     x, bits, res;
-
-  /* how many bits of last digit does b use */
-  bits = mp_count_bits (b) % DIGIT_BIT;
-
-  if (b->used > 1) {
-     if ((res = mp_2expt (a, (b->used - 1) * DIGIT_BIT + bits - 1)) != MP_OKAY) {
-        return res;
-     }
-  } else {
-     mp_set(a, 1);
-     bits = 1;
-  }
-
-
-  /* now compute C = A * B mod b */
-  for (x = bits - 1; x < (int)DIGIT_BIT; x++) {
-    if ((res = mp_mul_2 (a, a)) != MP_OKAY) {
-      return res;
-    }
-    if (mp_cmp_mag (a, b) != MP_LT) {
-      if ((res = s_mp_sub (a, b, a)) != MP_OKAY) {
-        return res;
-      }
-    }
-  }
-
-  return MP_OKAY;
-}
-
-
-#ifdef MP_LOW_MEM
-   #define TAB_SIZE 32
-#else
-   #define TAB_SIZE 256
-#endif
-
-int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
-{
-  mp_int  M[TAB_SIZE], res, mu;
-  mp_digit buf;
-  int     err, bitbuf, bitcpy, bitcnt, mode, digidx, x, y, winsize;
-  int (*redux)(mp_int*,mp_int*,mp_int*);
-
-  /* find window size */
-  x = mp_count_bits (X);
-  if (x <= 7) {
-    winsize = 2;
-  } else if (x <= 36) {
-    winsize = 3;
-  } else if (x <= 140) {
-    winsize = 4;
-  } else if (x <= 450) {
-    winsize = 5;
-  } else if (x <= 1303) {
-    winsize = 6;
-  } else if (x <= 3529) {
-    winsize = 7;
-  } else {
-    winsize = 8;
-  }
-
-#ifdef MP_LOW_MEM
-    if (winsize > 5) {
-       winsize = 5;
-    }
-#endif
-
-  /* init M array */
-  /* init first cell */
-  if ((err = mp_init(&M[1])) != MP_OKAY) {
-     return err;
-  }
-
-  /* now init the second half of the array */
-  for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
-    if ((err = mp_init(&M[x])) != MP_OKAY) {
-      for (y = 1<<(winsize-1); y < x; y++) {
-        mp_clear (&M[y]);
-      }
-      mp_clear(&M[1]);
-      return err;
-    }
-  }
-
-  /* create mu, used for Barrett reduction */
-  if ((err = mp_init (&mu)) != MP_OKAY) {
-    goto LBL_M;
-  }
-
-  if (redmode == 0) {
-     if ((err = mp_reduce_setup (&mu, P)) != MP_OKAY) {
-        goto LBL_MU;
-     }
-     redux = mp_reduce;
-  } else {
-     if ((err = mp_reduce_2k_setup_l (P, &mu)) != MP_OKAY) {
-        goto LBL_MU;
-     }
-     redux = mp_reduce_2k_l;
-  }
-
-  /* create M table
-   *
-   * The M table contains powers of the base,
-   * e.g. M[x] = G**x mod P
-   *
-   * The first half of the table is not
-   * computed though accept for M[0] and M[1]
-   */
-  if ((err = mp_mod (G, P, &M[1])) != MP_OKAY) {
-    goto LBL_MU;
-  }
-
-  /* compute the value at M[1<<(winsize-1)] by squaring
-   * M[1] (winsize-1) times
-   */
-  if ((err = mp_copy (&M[1], &M[(mp_digit)(1 << (winsize - 1))])) != MP_OKAY) {
-    goto LBL_MU;
-  }
-
-  for (x = 0; x < (winsize - 1); x++) {
-    /* square it */
-    if ((err = mp_sqr (&M[(mp_digit)(1 << (winsize - 1))],
-                       &M[(mp_digit)(1 << (winsize - 1))])) != MP_OKAY) {
-      goto LBL_MU;
-    }
-
-    /* reduce modulo P */
-    if ((err = redux (&M[(mp_digit)(1 << (winsize - 1))], P, &mu)) != MP_OKAY) {
-      goto LBL_MU;
-    }
-  }
-
-  /* create upper table, that is M[x] = M[x-1] * M[1] (mod P)
-   * for x = (2**(winsize - 1) + 1) to (2**winsize - 1)
-   */
-  for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) {
-    if ((err = mp_mul (&M[x - 1], &M[1], &M[x])) != MP_OKAY) {
-      goto LBL_MU;
-    }
-    if ((err = redux (&M[x], P, &mu)) != MP_OKAY) {
-      goto LBL_MU;
-    }
-  }
-
-  /* setup result */
-  if ((err = mp_init (&res)) != MP_OKAY) {
-    goto LBL_MU;
-  }
-  mp_set (&res, 1);
-
-  /* set initial mode and bit cnt */
-  mode   = 0;
-  bitcnt = 1;
-  buf    = 0;
-  digidx = X->used - 1;
-  bitcpy = 0;
-  bitbuf = 0;
-
-  for (;;) {
-    /* grab next digit as required */
-    if (--bitcnt == 0) {
-      /* if digidx == -1 we are out of digits */
-      if (digidx == -1) {
-        break;
-      }
-      /* read next digit and reset the bitcnt */
-      buf    = X->dp[digidx--];
-      bitcnt = (int) DIGIT_BIT;
-    }
-
-    /* grab the next msb from the exponent */
-    y     = (int)(buf >> (mp_digit)(DIGIT_BIT - 1)) & 1;
-    buf <<= (mp_digit)1;
-
-    /* if the bit is zero and mode == 0 then we ignore it
-     * These represent the leading zero bits before the first 1 bit
-     * in the exponent.  Technically this opt is not required but it
-     * does lower the # of trivial squaring/reductions used
-     */
-    if (mode == 0 && y == 0) {
-      continue;
-    }
-
-    /* if the bit is zero and mode == 1 then we square */
-    if (mode == 1 && y == 0) {
-      if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
-        goto LBL_RES;
-      }
-      if ((err = redux (&res, P, &mu)) != MP_OKAY) {
-        goto LBL_RES;
-      }
-      continue;
-    }
-
-    /* else we add it to the window */
-    bitbuf |= (y << (winsize - ++bitcpy));
-    mode    = 2;
-
-    if (bitcpy == winsize) {
-      /* ok window is filled so square as required and multiply  */
-      /* square first */
-      for (x = 0; x < winsize; x++) {
-        if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
-          goto LBL_RES;
-        }
-        if ((err = redux (&res, P, &mu)) != MP_OKAY) {
-          goto LBL_RES;
-        }
-      }
-
-      /* then multiply */
-      if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) {
-        goto LBL_RES;
-      }
-      if ((err = redux (&res, P, &mu)) != MP_OKAY) {
-        goto LBL_RES;
-      }
-
-      /* empty window and reset */
-      bitcpy = 0;
-      bitbuf = 0;
-      mode   = 1;
-    }
-  }
-
-  /* if bits remain then square/multiply */
-  if (mode == 2 && bitcpy > 0) {
-    /* square then multiply if the bit is set */
-    for (x = 0; x < bitcpy; x++) {
-      if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
-        goto LBL_RES;
-      }
-      if ((err = redux (&res, P, &mu)) != MP_OKAY) {
-        goto LBL_RES;
-      }
-
-      bitbuf <<= 1;
-      if ((bitbuf & (1 << winsize)) != 0) {
-        /* then multiply */
-        if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) {
-          goto LBL_RES;
-        }
-        if ((err = redux (&res, P, &mu)) != MP_OKAY) {
-          goto LBL_RES;
-        }
-      }
-    }
-  }
-
-  mp_exch (&res, Y);
-  err = MP_OKAY;
-LBL_RES:mp_clear (&res);
-LBL_MU:mp_clear (&mu);
-LBL_M:
-  mp_clear(&M[1]);
-  for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
-    mp_clear (&M[x]);
-  }
-  return err;
-}
-
-
-/* pre-calculate the value required for Barrett reduction
- * For a given modulus "b" it calulates the value required in "a"
- */
-int mp_reduce_setup (mp_int * a, mp_int * b)
-{
-  int     res;
-
-  if ((res = mp_2expt (a, b->used * 2 * DIGIT_BIT)) != MP_OKAY) {
-    return res;
-  }
-  return mp_div (a, b, a, NULL);
-}
-
-
-/* reduces x mod m, assumes 0 < x < m**2, mu is
- * precomputed via mp_reduce_setup.
- * From HAC pp.604 Algorithm 14.42
- */
-int mp_reduce (mp_int * x, mp_int * m, mp_int * mu)
-{
-  mp_int  q;
-  int     res, um = m->used;
-
-  /* q = x */
-  if ((res = mp_init_copy (&q, x)) != MP_OKAY) {
-    return res;
-  }
-
-  /* q1 = x / b**(k-1)  */
-  mp_rshd (&q, um - 1);
-
-  /* according to HAC this optimization is ok */
-  if (((mp_word) um) > (((mp_digit)1) << (DIGIT_BIT - 1))) {
-    if ((res = mp_mul (&q, mu, &q)) != MP_OKAY) {
-      goto CLEANUP;
-    }
-  } else {
-#ifdef BN_S_MP_MUL_HIGH_DIGS_C
-    if ((res = s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) {
-      goto CLEANUP;
-    }
-#elif defined(BN_FAST_S_MP_MUL_HIGH_DIGS_C)
-    if ((res = fast_s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) {
-      goto CLEANUP;
-    }
-#else
-    {
-      res = MP_VAL;
-      goto CLEANUP;
-    }
-#endif
-  }
-
-  /* q3 = q2 / b**(k+1) */
-  mp_rshd (&q, um + 1);
-
-  /* x = x mod b**(k+1), quick (no division) */
-  if ((res = mp_mod_2d (x, DIGIT_BIT * (um + 1), x)) != MP_OKAY) {
-    goto CLEANUP;
-  }
-
-  /* q = q * m mod b**(k+1), quick (no division) */
-  if ((res = s_mp_mul_digs (&q, m, &q, um + 1)) != MP_OKAY) {
-    goto CLEANUP;
-  }
-
-  /* x = x - q */
-  if ((res = mp_sub (x, &q, x)) != MP_OKAY) {
-    goto CLEANUP;
-  }
-
-  /* If x < 0, add b**(k+1) to it */
-  if (mp_cmp_d (x, 0) == MP_LT) {
-    mp_set (&q, 1);
-    if ((res = mp_lshd (&q, um + 1)) != MP_OKAY)
-      goto CLEANUP;
-    if ((res = mp_add (x, &q, x)) != MP_OKAY)
-      goto CLEANUP;
-  }
-
-  /* Back off if it's too big */
-  while (mp_cmp (x, m) != MP_LT) {
-    if ((res = s_mp_sub (x, m, x)) != MP_OKAY) {
-      goto CLEANUP;
-    }
-  }
-
-CLEANUP:
-  mp_clear (&q);
-
-  return res;
-}
-
-
-/* reduces a modulo n where n is of the form 2**p - d
-   This differs from reduce_2k since "d" can be larger
-   than a single digit.
-*/
-int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d)
-{
-   mp_int q;
-   int    p, res;
-
-   if ((res = mp_init(&q)) != MP_OKAY) {
-      return res;
-   }
-
-   p = mp_count_bits(n);
-top:
-   /* q = a/2**p, a = a mod 2**p */
-   if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
-      goto ERR;
-   }
-
-   /* q = q * d */
-   if ((res = mp_mul(&q, d, &q)) != MP_OKAY) {
-      goto ERR;
-   }
-
-   /* a = a + q */
-   if ((res = s_mp_add(a, &q, a)) != MP_OKAY) {
-      goto ERR;
-   }
-
-   if (mp_cmp_mag(a, n) != MP_LT) {
-      s_mp_sub(a, n, a);
-      goto top;
-   }
-
-ERR:
-   mp_clear(&q);
-   return res;
-}
-
-
-/* determines the setup value */
-int mp_reduce_2k_setup_l(mp_int *a, mp_int *d)
-{
-   int    res;
-   mp_int tmp;
-
-   if ((res = mp_init(&tmp)) != MP_OKAY) {
-      return res;
-   }
-
-   if ((res = mp_2expt(&tmp, mp_count_bits(a))) != MP_OKAY) {
-      goto ERR;
-   }
-
-   if ((res = s_mp_sub(&tmp, a, d)) != MP_OKAY) {
-      goto ERR;
-   }
-
-ERR:
-   mp_clear(&tmp);
-   return res;
-}
-
-
-/* multiplies |a| * |b| and does not compute the lower digs digits
- * [meant to get the higher part of the product]
- */
-int
-s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
-{
-  mp_int  t;
-  int     res, pa, pb, ix, iy;
-  mp_digit u;
-  mp_word r;
-  mp_digit tmpx, *tmpt, *tmpy;
-
-  /* can we use the fast multiplier? */
-#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C
-  if (((a->used + b->used + 1) < MP_WARRAY)
-      && MIN (a->used, b->used) < (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
-    return fast_s_mp_mul_high_digs (a, b, c, digs);
-  }
-#endif
-
-  if ((res = mp_init_size (&t, a->used + b->used + 1)) != MP_OKAY) {
-    return res;
-  }
-  t.used = a->used + b->used + 1;
-
-  pa = a->used;
-  pb = b->used;
-  for (ix = 0; ix < pa; ix++) {
-    /* clear the carry */
-    u = 0;
-
-    /* left hand side of A[ix] * B[iy] */
-    tmpx = a->dp[ix];
-
-    /* alias to the address of where the digits will be stored */
-    tmpt = &(t.dp[digs]);
-
-    /* alias for where to read the right hand side from */
-    tmpy = b->dp + (digs - ix);
-
-    for (iy = digs - ix; iy < pb; iy++) {
-      /* calculate the double precision result */
-      r       = ((mp_word)*tmpt) +
-                ((mp_word)tmpx) * ((mp_word)*tmpy++) +
-                ((mp_word) u);
-
-      /* get the lower part */
-      *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
-
-      /* carry the carry */
-      u       = (mp_digit) (r >> ((mp_word) DIGIT_BIT));
-    }
-    *tmpt = u;
-  }
-  mp_clamp (&t);
-  mp_exch (&t, c);
-  mp_clear (&t);
-  return MP_OKAY;
-}
-
-
-/* this is a modified version of fast_s_mul_digs that only produces
- * output digits *above* digs.  See the comments for fast_s_mul_digs
- * to see how it works.
- *
- * This is used in the Barrett reduction since for one of the multiplications
- * only the higher digits were needed.  This essentially halves the work.
- *
- * Based on Algorithm 14.12 on pp.595 of HAC.
- */
-int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
-{
-  int     olduse, res, pa, ix, iz;
-#ifdef WOLFSSL_SMALL_STACK
-  mp_digit* W;    /* uses dynamic memory and slower */
-#else
-  mp_digit W[MP_WARRAY];
-#endif
-  mp_word  _W;
-
-  /* grow the destination as required */
-  pa = a->used + b->used;
-  if (c->alloc < pa) {
-    if ((res = mp_grow (c, pa)) != MP_OKAY) {
-      return res;
-    }
-  }
-
-  if (pa > MP_WARRAY)
-    return MP_RANGE;  /* TAO range check */
-
-#ifdef WOLFSSL_SMALL_STACK
-  W = (mp_digit*)XMALLOC(sizeof(mp_digit) * MP_WARRAY, 0, DYNAMIC_TYPE_BIGINT);
-  if (W == NULL)
-    return MP_MEM;
-#endif
-
-  /* number of output digits to produce */
-  pa = a->used + b->used;
-  _W = 0;
-  for (ix = digs; ix < pa; ix++) {
-      int      tx, ty, iy;
-      mp_digit *tmpx, *tmpy;
-
-      /* get offsets into the two bignums */
-      ty = MIN(b->used-1, ix);
-      tx = ix - ty;
-
-      /* setup temp aliases */
-      tmpx = a->dp + tx;
-      tmpy = b->dp + ty;
-
-      /* this is the number of times the loop will iterrate, essentially its
-         while (tx++ < a->used && ty-- >= 0) { ... }
-       */
-      iy = MIN(a->used-tx, ty+1);
-
-      /* execute loop */
-      for (iz = 0; iz < iy; iz++) {
-         _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--);
-      }
-
-      /* store term */
-      W[ix] = ((mp_digit)_W) & MP_MASK;
-
-      /* make next carry */
-      _W = _W >> ((mp_word)DIGIT_BIT);
-  }
-
-  /* setup dest */
-  olduse  = c->used;
-  c->used = pa;
-
-  {
-    register mp_digit *tmpc;
-
-    tmpc = c->dp + digs;
-    for (ix = digs; ix <= pa; ix++) {
-      /* now extract the previous digit [below the carry] */
-      *tmpc++ = W[ix];
-    }
-
-    /* clear unused digits [that existed in the old copy of c] */
-    for (; ix < olduse; ix++) {
-      *tmpc++ = 0;
-    }
-  }
-  mp_clamp (c);
-
-#ifdef WOLFSSL_SMALL_STACK
-  XFREE(W, 0, DYNAMIC_TYPE_BIGINT);
-#endif
-
-  return MP_OKAY;
-}
-
-
-/* set a 32-bit const */
-int mp_set_int (mp_int * a, unsigned long b)
-{
-  int     x, res;
-
-  mp_zero (a);
-
-  /* set four bits at a time */
-  for (x = 0; x < 8; x++) {
-    /* shift the number up four bits */
-    if ((res = mp_mul_2d (a, 4, a)) != MP_OKAY) {
-      return res;
-    }
-
-    /* OR in the top four bits of the source */
-    a->dp[0] |= (b >> 28) & 15;
-
-    /* shift the source up to the next four bits */
-    b <<= 4;
-
-    /* ensure that digits are not clamped off */
-    a->used += 1;
-  }
-  mp_clamp (a);
-  return MP_OKAY;
-}
-
-
-#if defined(WOLFSSL_KEY_GEN) || defined(HAVE_ECC)
-
-/* c = a * a (mod b) */
-int mp_sqrmod (mp_int * a, mp_int * b, mp_int * c)
-{
-  int     res;
-  mp_int  t;
-
-  if ((res = mp_init (&t)) != MP_OKAY) {
-    return res;
-  }
-
-  if ((res = mp_sqr (a, &t)) != MP_OKAY) {
-    mp_clear (&t);
-    return res;
-  }
-  res = mp_mod (&t, b, c);
-  mp_clear (&t);
-  return res;
-}
-
-#endif
-
-
-#if defined(HAVE_ECC) || !defined(NO_PWDBASED) || defined(WOLFSSL_SNIFFER) || defined(WOLFSSL_HAVE_WOLFSCEP) || defined(WOLFSSL_KEY_GEN)
-
-/* single digit addition */
-int mp_add_d (mp_int* a, mp_digit b, mp_int* c)
-{
-  int     res, ix, oldused;
-  mp_digit *tmpa, *tmpc, mu;
-
-  /* grow c as required */
-  if (c->alloc < a->used + 1) {
-     if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) {
-        return res;
-     }
-  }
-
-  /* if a is negative and |a| >= b, call c = |a| - b */
-  if (a->sign == MP_NEG && (a->used > 1 || a->dp[0] >= b)) {
-     /* temporarily fix sign of a */
-     a->sign = MP_ZPOS;
-
-     /* c = |a| - b */
-     res = mp_sub_d(a, b, c);
-
-     /* fix sign  */
-     a->sign = c->sign = MP_NEG;
-
-     /* clamp */
-     mp_clamp(c);
-
-     return res;
-  }
-
-  /* old number of used digits in c */
-  oldused = c->used;
-
-  /* sign always positive */
-  c->sign = MP_ZPOS;
-
-  /* source alias */
-  tmpa    = a->dp;
-
-  /* destination alias */
-  tmpc    = c->dp;
-
-  /* if a is positive */
-  if (a->sign == MP_ZPOS) {
-     /* add digit, after this we're propagating
-      * the carry.
-      */
-     *tmpc   = *tmpa++ + b;
-     mu      = *tmpc >> DIGIT_BIT;
-     *tmpc++ &= MP_MASK;
-
-     /* now handle rest of the digits */
-     for (ix = 1; ix < a->used; ix++) {
-        *tmpc   = *tmpa++ + mu;
-        mu      = *tmpc >> DIGIT_BIT;
-        *tmpc++ &= MP_MASK;
-     }
-     /* set final carry */
-     if (mu != 0 && ix < c->alloc) {
-        ix++;
-        *tmpc++  = mu;
-     }
-
-     /* setup size */
-     c->used = a->used + 1;
-  } else {
-     /* a was negative and |a| < b */
-     c->used  = 1;
-
-     /* the result is a single digit */
-     if (a->used == 1) {
-        *tmpc++  =  b - a->dp[0];
-     } else {
-        *tmpc++  =  b;
-     }
-
-     /* setup count so the clearing of oldused
-      * can fall through correctly
-      */
-     ix       = 1;
-  }
-
-  /* now zero to oldused */
-  while (ix++ < oldused) {
-     *tmpc++ = 0;
-  }
-  mp_clamp(c);
-
-  return MP_OKAY;
-}
-
-
-/* single digit subtraction */
-int mp_sub_d (mp_int * a, mp_digit b, mp_int * c)
-{
-  mp_digit *tmpa, *tmpc, mu;
-  int       res, ix, oldused;
-
-  /* grow c as required */
-  if (c->alloc < a->used + 1) {
-     if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) {
-        return res;
-     }
-  }
-
-  /* if a is negative just do an unsigned
-   * addition [with fudged signs]
-   */
-  if (a->sign == MP_NEG) {
-     a->sign = MP_ZPOS;
-     res     = mp_add_d(a, b, c);
-     a->sign = c->sign = MP_NEG;
-
-     /* clamp */
-     mp_clamp(c);
-
-     return res;
-  }
-
-  /* setup regs */
-  oldused = c->used;
-  tmpa    = a->dp;
-  tmpc    = c->dp;
-
-  /* if a <= b simply fix the single digit */
-  if ((a->used == 1 && a->dp[0] <= b) || a->used == 0) {
-     if (a->used == 1) {
-        *tmpc++ = b - *tmpa;
-     } else {
-        *tmpc++ = b;
-     }
-     ix      = 1;
-
-     /* negative/1digit */
-     c->sign = MP_NEG;
-     c->used = 1;
-  } else {
-     /* positive/size */
-     c->sign = MP_ZPOS;
-     c->used = a->used;
-
-     /* subtract first digit */
-     *tmpc    = *tmpa++ - b;
-     mu       = *tmpc >> (sizeof(mp_digit) * CHAR_BIT - 1);
-     *tmpc++ &= MP_MASK;
-
-     /* handle rest of the digits */
-     for (ix = 1; ix < a->used; ix++) {
-        *tmpc    = *tmpa++ - mu;
-        mu       = *tmpc >> (sizeof(mp_digit) * CHAR_BIT - 1);
-        *tmpc++ &= MP_MASK;
-     }
-  }
-
-  /* zero excess digits */
-  while (ix++ < oldused) {
-     *tmpc++ = 0;
-  }
-  mp_clamp(c);
-  return MP_OKAY;
-}
-
-#endif /* defined(HAVE_ECC) || !defined(NO_PWDBASED) */
-
-
-#if defined(WOLFSSL_KEY_GEN) || defined(HAVE_COMP_KEY)
-
-static const int lnz[16] = {
-   4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
-};
-
-/* Counts the number of lsbs which are zero before the first zero bit */
-int mp_cnt_lsb(mp_int *a)
-{
-    int x;
-    mp_digit q, qq;
-
-    /* easy out */
-    if (mp_iszero(a) == 1) {
-        return 0;
-    }
-
-    /* scan lower digits until non-zero */
-    for (x = 0; x < a->used && a->dp[x] == 0; x++);
-    q = a->dp[x];
-    x *= DIGIT_BIT;
-
-    /* now scan this digit until a 1 is found */
-    if ((q & 1) == 0) {
-        do {
-            qq  = q & 15;
-            x  += lnz[qq];
-            q >>= 4;
-        } while (qq == 0);
-    }
-    return x;
-}
-
-
-
-
-static int s_is_power_of_two(mp_digit b, int *p)
-{
-   int x;
-
-   /* fast return if no power of two */
-   if ((b==0) || (b & (b-1))) {
-      return 0;
-   }
-
-   for (x = 0; x < DIGIT_BIT; x++) {
-      if (b == (((mp_digit)1)<dp[0] & ((((mp_digit)1)<used)) != MP_OKAY) {
-     return res;
-  }
-
-  q.used = a->used;
-  q.sign = a->sign;
-  w = 0;
-  for (ix = a->used - 1; ix >= 0; ix--) {
-     w = (w << ((mp_word)DIGIT_BIT)) | ((mp_word)a->dp[ix]);
-
-     if (w >= b) {
-        t = (mp_digit)(w / b);
-        w -= ((mp_word)t) * ((mp_word)b);
-      } else {
-        t = 0;
-      }
-      q.dp[ix] = (mp_digit)t;
-  }
-
-  if (d != NULL) {
-     *d = (mp_digit)w;
-  }
-
-  if (c != NULL) {
-     mp_clamp(&q);
-     mp_exch(&q, c);
-  }
-  mp_clear(&q);
-
-  return res;
-}
-
-
-int mp_mod_d (mp_int * a, mp_digit b, mp_digit * c)
-{
-  return mp_div_d(a, b, NULL, c);
-}
-
-#endif /* defined(WOLFSSL_KEY_GEN) || defined(HAVE_COMP_KEY) */
-
-#ifdef WOLFSSL_KEY_GEN
-
-const mp_digit ltm_prime_tab[] = {
-  0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013,
-  0x0017, 0x001D, 0x001F, 0x0025, 0x0029, 0x002B, 0x002F, 0x0035,
-  0x003B, 0x003D, 0x0043, 0x0047, 0x0049, 0x004F, 0x0053, 0x0059,
-  0x0061, 0x0065, 0x0067, 0x006B, 0x006D, 0x0071, 0x007F,
-#ifndef MP_8BIT
-  0x0083,
-  0x0089, 0x008B, 0x0095, 0x0097, 0x009D, 0x00A3, 0x00A7, 0x00AD,
-  0x00B3, 0x00B5, 0x00BF, 0x00C1, 0x00C5, 0x00C7, 0x00D3, 0x00DF,
-  0x00E3, 0x00E5, 0x00E9, 0x00EF, 0x00F1, 0x00FB, 0x0101, 0x0107,
-  0x010D, 0x010F, 0x0115, 0x0119, 0x011B, 0x0125, 0x0133, 0x0137,
-
-  0x0139, 0x013D, 0x014B, 0x0151, 0x015B, 0x015D, 0x0161, 0x0167,
-  0x016F, 0x0175, 0x017B, 0x017F, 0x0185, 0x018D, 0x0191, 0x0199,
-  0x01A3, 0x01A5, 0x01AF, 0x01B1, 0x01B7, 0x01BB, 0x01C1, 0x01C9,
-  0x01CD, 0x01CF, 0x01D3, 0x01DF, 0x01E7, 0x01EB, 0x01F3, 0x01F7,
-  0x01FD, 0x0209, 0x020B, 0x021D, 0x0223, 0x022D, 0x0233, 0x0239,
-  0x023B, 0x0241, 0x024B, 0x0251, 0x0257, 0x0259, 0x025F, 0x0265,
-  0x0269, 0x026B, 0x0277, 0x0281, 0x0283, 0x0287, 0x028D, 0x0293,
-  0x0295, 0x02A1, 0x02A5, 0x02AB, 0x02B3, 0x02BD, 0x02C5, 0x02CF,
-
-  0x02D7, 0x02DD, 0x02E3, 0x02E7, 0x02EF, 0x02F5, 0x02F9, 0x0301,
-  0x0305, 0x0313, 0x031D, 0x0329, 0x032B, 0x0335, 0x0337, 0x033B,
-  0x033D, 0x0347, 0x0355, 0x0359, 0x035B, 0x035F, 0x036D, 0x0371,
-  0x0373, 0x0377, 0x038B, 0x038F, 0x0397, 0x03A1, 0x03A9, 0x03AD,
-  0x03B3, 0x03B9, 0x03C7, 0x03CB, 0x03D1, 0x03D7, 0x03DF, 0x03E5,
-  0x03F1, 0x03F5, 0x03FB, 0x03FD, 0x0407, 0x0409, 0x040F, 0x0419,
-  0x041B, 0x0425, 0x0427, 0x042D, 0x043F, 0x0443, 0x0445, 0x0449,
-  0x044F, 0x0455, 0x045D, 0x0463, 0x0469, 0x047F, 0x0481, 0x048B,
-
-  0x0493, 0x049D, 0x04A3, 0x04A9, 0x04B1, 0x04BD, 0x04C1, 0x04C7,
-  0x04CD, 0x04CF, 0x04D5, 0x04E1, 0x04EB, 0x04FD, 0x04FF, 0x0503,
-  0x0509, 0x050B, 0x0511, 0x0515, 0x0517, 0x051B, 0x0527, 0x0529,
-  0x052F, 0x0551, 0x0557, 0x055D, 0x0565, 0x0577, 0x0581, 0x058F,
-  0x0593, 0x0595, 0x0599, 0x059F, 0x05A7, 0x05AB, 0x05AD, 0x05B3,
-  0x05BF, 0x05C9, 0x05CB, 0x05CF, 0x05D1, 0x05D5, 0x05DB, 0x05E7,
-  0x05F3, 0x05FB, 0x0607, 0x060D, 0x0611, 0x0617, 0x061F, 0x0623,
-  0x062B, 0x062F, 0x063D, 0x0641, 0x0647, 0x0649, 0x064D, 0x0653
-#endif
-};
-
-
-/* Miller-Rabin test of "a" to the base of "b" as described in
- * HAC pp. 139 Algorithm 4.24
- *
- * Sets result to 0 if definitely composite or 1 if probably prime.
- * Randomly the chance of error is no more than 1/4 and often
- * very much lower.
- */
-static int mp_prime_miller_rabin (mp_int * a, mp_int * b, int *result)
-{
-  mp_int  n1, y, r;
-  int     s, j, err;
-
-  /* default */
-  *result = MP_NO;
-
-  /* ensure b > 1 */
-  if (mp_cmp_d(b, 1) != MP_GT) {
-     return MP_VAL;
-  }
-
-  /* get n1 = a - 1 */
-  if ((err = mp_init_copy (&n1, a)) != MP_OKAY) {
-    return err;
-  }
-  if ((err = mp_sub_d (&n1, 1, &n1)) != MP_OKAY) {
-    goto LBL_N1;
-  }
-
-  /* set 2**s * r = n1 */
-  if ((err = mp_init_copy (&r, &n1)) != MP_OKAY) {
-    goto LBL_N1;
-  }
-
-  /* count the number of least significant bits
-   * which are zero
-   */
-  s = mp_cnt_lsb(&r);
-
-  /* now divide n - 1 by 2**s */
-  if ((err = mp_div_2d (&r, s, &r, NULL)) != MP_OKAY) {
-    goto LBL_R;
-  }
-
-  /* compute y = b**r mod a */
-  if ((err = mp_init (&y)) != MP_OKAY) {
-    goto LBL_R;
-  }
-  if ((err = mp_exptmod (b, &r, a, &y)) != MP_OKAY) {
-    goto LBL_Y;
-  }
-
-  /* if y != 1 and y != n1 do */
-  if (mp_cmp_d (&y, 1) != MP_EQ && mp_cmp (&y, &n1) != MP_EQ) {
-    j = 1;
-    /* while j <= s-1 and y != n1 */
-    while ((j <= (s - 1)) && mp_cmp (&y, &n1) != MP_EQ) {
-      if ((err = mp_sqrmod (&y, a, &y)) != MP_OKAY) {
-         goto LBL_Y;
-      }
-
-      /* if y == 1 then composite */
-      if (mp_cmp_d (&y, 1) == MP_EQ) {
-         goto LBL_Y;
-      }
-
-      ++j;
-    }
-
-    /* if y != n1 then composite */
-    if (mp_cmp (&y, &n1) != MP_EQ) {
-      goto LBL_Y;
-    }
-  }
-
-  /* probably prime now */
-  *result = MP_YES;
-LBL_Y:mp_clear (&y);
-LBL_R:mp_clear (&r);
-LBL_N1:mp_clear (&n1);
-  return err;
-}
-
-
-/* determines if an integers is divisible by one
- * of the first PRIME_SIZE primes or not
- *
- * sets result to 0 if not, 1 if yes
- */
-static int mp_prime_is_divisible (mp_int * a, int *result)
-{
-  int     err, ix;
-  mp_digit res;
-
-  /* default to not */
-  *result = MP_NO;
-
-  for (ix = 0; ix < PRIME_SIZE; ix++) {
-    /* what is a mod LBL_prime_tab[ix] */
-    if ((err = mp_mod_d (a, ltm_prime_tab[ix], &res)) != MP_OKAY) {
-      return err;
-    }
-
-    /* is the residue zero? */
-    if (res == 0) {
-      *result = MP_YES;
-      return MP_OKAY;
-    }
-  }
-
-  return MP_OKAY;
-}
-
-
-/*
- * Sets result to 1 if probably prime, 0 otherwise
- */
-int mp_prime_is_prime (mp_int * a, int t, int *result)
-{
-  mp_int  b;
-  int     ix, err, res;
-
-  /* default to no */
-  *result = MP_NO;
-
-  /* valid value of t? */
-  if (t <= 0 || t > PRIME_SIZE) {
-    return MP_VAL;
-  }
-
-  /* is the input equal to one of the primes in the table? */
-  for (ix = 0; ix < PRIME_SIZE; ix++) {
-      if (mp_cmp_d(a, ltm_prime_tab[ix]) == MP_EQ) {
-         *result = 1;
-         return MP_OKAY;
-      }
-  }
-
-  /* first perform trial division */
-  if ((err = mp_prime_is_divisible (a, &res)) != MP_OKAY) {
-    return err;
-  }
-
-  /* return if it was trivially divisible */
-  if (res == MP_YES) {
-    return MP_OKAY;
-  }
-
-  /* now perform the miller-rabin rounds */
-  if ((err = mp_init (&b)) != MP_OKAY) {
-    return err;
-  }
-
-  for (ix = 0; ix < t; ix++) {
-    /* set the prime */
-    mp_set (&b, ltm_prime_tab[ix]);
-
-    if ((err = mp_prime_miller_rabin (a, &b, &res)) != MP_OKAY) {
-      goto LBL_B;
-    }
-
-    if (res == MP_NO) {
-      goto LBL_B;
-    }
-  }
-
-  /* passed the test */
-  *result = MP_YES;
-LBL_B:mp_clear (&b);
-  return err;
-}
-
-
-/* computes least common multiple as |a*b|/(a, b) */
-int mp_lcm (mp_int * a, mp_int * b, mp_int * c)
-{
-  int     res;
-  mp_int  t1, t2;
-
-
-  if ((res = mp_init_multi (&t1, &t2, NULL, NULL, NULL, NULL)) != MP_OKAY) {
-    return res;
-  }
-
-  /* t1 = get the GCD of the two inputs */
-  if ((res = mp_gcd (a, b, &t1)) != MP_OKAY) {
-    goto LBL_T;
-  }
-
-  /* divide the smallest by the GCD */
-  if (mp_cmp_mag(a, b) == MP_LT) {
-     /* store quotient in t2 such that t2 * b is the LCM */
-     if ((res = mp_div(a, &t1, &t2, NULL)) != MP_OKAY) {
-        goto LBL_T;
-     }
-     res = mp_mul(b, &t2, c);
-  } else {
-     /* store quotient in t2 such that t2 * a is the LCM */
-     if ((res = mp_div(b, &t1, &t2, NULL)) != MP_OKAY) {
-        goto LBL_T;
-     }
-     res = mp_mul(a, &t2, c);
-  }
-
-  /* fix the sign to positive */
-  c->sign = MP_ZPOS;
-
-LBL_T:
-  mp_clear(&t1);
-  mp_clear(&t2);
-  return res;
-}
-
-
-
-/* Greatest Common Divisor using the binary method */
-int mp_gcd (mp_int * a, mp_int * b, mp_int * c)
-{
-    mp_int  u, v;
-    int     k, u_lsb, v_lsb, res;
-
-    /* either zero than gcd is the largest */
-    if (mp_iszero (a) == MP_YES) {
-        return mp_abs (b, c);
-    }
-    if (mp_iszero (b) == MP_YES) {
-        return mp_abs (a, c);
-    }
-
-    /* get copies of a and b we can modify */
-    if ((res = mp_init_copy (&u, a)) != MP_OKAY) {
-        return res;
-    }
-
-    if ((res = mp_init_copy (&v, b)) != MP_OKAY) {
-        goto LBL_U;
-    }
-
-    /* must be positive for the remainder of the algorithm */
-    u.sign = v.sign = MP_ZPOS;
-
-    /* B1.  Find the common power of two for u and v */
-    u_lsb = mp_cnt_lsb(&u);
-    v_lsb = mp_cnt_lsb(&v);
-    k     = MIN(u_lsb, v_lsb);
-
-    if (k > 0) {
-        /* divide the power of two out */
-        if ((res = mp_div_2d(&u, k, &u, NULL)) != MP_OKAY) {
-            goto LBL_V;
-        }
-
-        if ((res = mp_div_2d(&v, k, &v, NULL)) != MP_OKAY) {
-            goto LBL_V;
-        }
-    }
-
-    /* divide any remaining factors of two out */
-    if (u_lsb != k) {
-        if ((res = mp_div_2d(&u, u_lsb - k, &u, NULL)) != MP_OKAY) {
-            goto LBL_V;
-        }
-    }
-
-    if (v_lsb != k) {
-        if ((res = mp_div_2d(&v, v_lsb - k, &v, NULL)) != MP_OKAY) {
-            goto LBL_V;
-        }
-    }
-
-    while (mp_iszero(&v) == 0) {
-        /* make sure v is the largest */
-        if (mp_cmp_mag(&u, &v) == MP_GT) {
-            /* swap u and v to make sure v is >= u */
-            mp_exch(&u, &v);
-        }
-
-        /* subtract smallest from largest */
-        if ((res = s_mp_sub(&v, &u, &v)) != MP_OKAY) {
-            goto LBL_V;
-        }
-
-        /* Divide out all factors of two */
-        if ((res = mp_div_2d(&v, mp_cnt_lsb(&v), &v, NULL)) != MP_OKAY) {
-            goto LBL_V;
-        }
-    }
-
-    /* multiply by 2**k which we divided out at the beginning */
-    if ((res = mp_mul_2d (&u, k, c)) != MP_OKAY) {
-        goto LBL_V;
-    }
-    c->sign = MP_ZPOS;
-    res = MP_OKAY;
-LBL_V:mp_clear (&u);
-LBL_U:mp_clear (&v);
-    return res;
-}
-
-
-
-#endif /* WOLFSSL_KEY_GEN */
-
-
-#ifdef HAVE_ECC
-
-/* chars used in radix conversions */
-const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
-
-/* read a string [ASCII] in a given radix */
-int mp_read_radix (mp_int * a, const char *str, int radix)
-{
-  int     y, res, neg;
-  char    ch;
-
-  /* zero the digit bignum */
-  mp_zero(a);
-
-  /* make sure the radix is ok */
-  if (radix < 2 || radix > 64) {
-    return MP_VAL;
-  }
-
-  /* if the leading digit is a
-   * minus set the sign to negative.
-   */
-  if (*str == '-') {
-    ++str;
-    neg = MP_NEG;
-  } else {
-    neg = MP_ZPOS;
-  }
-
-  /* set the integer to the default of zero */
-  mp_zero (a);
-
-  /* process each digit of the string */
-  while (*str) {
-    /* if the radix < 36 the conversion is case insensitive
-     * this allows numbers like 1AB and 1ab to represent the same  value
-     * [e.g. in hex]
-     */
-    ch = (char) ((radix < 36) ? XTOUPPER((unsigned char)*str) : *str);
-    for (y = 0; y < 64; y++) {
-      if (ch == mp_s_rmap[y]) {
-         break;
-      }
-    }
-
-    /* if the char was found in the map
-     * and is less than the given radix add it
-     * to the number, otherwise exit the loop.
-     */
-    if (y < radix) {
-      if ((res = mp_mul_d (a, (mp_digit) radix, a)) != MP_OKAY) {
-         return res;
-      }
-      if ((res = mp_add_d (a, (mp_digit) y, a)) != MP_OKAY) {
-         return res;
-      }
-    } else {
-      break;
-    }
-    ++str;
-  }
-
-  /* set the sign only if a != 0 */
-  if (mp_iszero(a) != 1) {
-     a->sign = neg;
-  }
-  return MP_OKAY;
-}
-
-#endif /* HAVE_ECC */
-
-#endif /* USE_FAST_MATH */
-
-#endif /* NO_BIG_INT */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/logging.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/logging.c
deleted file mode 100755
index 3215306..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/logging.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/* logging.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-/* submitted by eof */
-
-#include 
-#include 
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-    WOLFSSL_API int  wolfSSL_Debugging_ON(void);
-    WOLFSSL_API void wolfSSL_Debugging_OFF(void);
-#ifdef __cplusplus
-    } 
-#endif
-
-
-#ifdef DEBUG_WOLFSSL
-
-/* Set these to default values initially. */
-static wolfSSL_Logging_cb log_function = 0;
-static int loggingEnabled = 0;
-
-#endif /* DEBUG_WOLFSSL */
-
-
-int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb f)
-{
-#ifdef DEBUG_WOLFSSL
-    int res = 0;
-
-    if (f)
-        log_function = f;
-    else
-        res = BAD_FUNC_ARG;
-
-    return res;
-#else
-    (void)f;
-    return NOT_COMPILED_IN;
-#endif
-}
-
-
-int wolfSSL_Debugging_ON(void)
-{
-#ifdef DEBUG_WOLFSSL
-    loggingEnabled = 1;
-    return 0;
-#else
-    return NOT_COMPILED_IN;
-#endif
-}
-
-
-void wolfSSL_Debugging_OFF(void)
-{
-#ifdef DEBUG_WOLFSSL
-    loggingEnabled = 0;
-#endif
-}
-
-
-#ifdef DEBUG_WOLFSSL
-
-#ifdef FREESCALE_MQX
-    #include 
-#else
-    #include    /* for default printf stuff */
-#endif
-
-#ifdef THREADX
-    int dc_log_printf(char*, ...);
-#endif
-
-static void wolfssl_log(const int logLevel, const char *const logMessage)
-{
-    if (log_function)
-        log_function(logLevel, logMessage);
-    else {
-        if (loggingEnabled) {
-#ifdef THREADX
-            dc_log_printf("%s\n", logMessage);
-#elif defined(MICRIUM)
-        #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
-            NetSecure_TraceOut((CPU_CHAR *)logMessage);
-        #endif
-#elif defined(WOLFSSL_MDK_ARM)
-            fflush(stdout) ;
-            printf("%s\n", logMessage);
-            fflush(stdout) ;
-#else
-            fprintf(stderr, "%s\n", logMessage);
-#endif
-        }
-    }
-}
-
-
-void WOLFSSL_MSG(const char* msg)
-{
-    if (loggingEnabled)
-        wolfssl_log(INFO_LOG , msg);
-}
-
-
-void WOLFSSL_ENTER(const char* msg)
-{
-    if (loggingEnabled) {
-        char buffer[80];
-        sprintf(buffer, "wolfSSL Entering %s", msg);
-        wolfssl_log(ENTER_LOG , buffer);
-    }
-}
-
-
-void WOLFSSL_LEAVE(const char* msg, int ret)
-{
-    if (loggingEnabled) {
-        char buffer[80];
-        sprintf(buffer, "wolfSSL Leaving %s, return %d", msg, ret);
-        wolfssl_log(LEAVE_LOG , buffer);
-    }
-}
-
-
-void WOLFSSL_ERROR(int error)
-{
-    if (loggingEnabled) {
-        char buffer[80];
-        sprintf(buffer, "wolfSSL error occured, error = %d", error);
-        wolfssl_log(ERROR_LOG , buffer);
-    }
-}
-
-#endif  /* DEBUG_WOLFSSL */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/md2.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/md2.c
deleted file mode 100755
index ce4e424..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/md2.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/* md2.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef WOLFSSL_MD2
-
-#include 
-#include 
-
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-
-void wc_InitMd2(Md2* md2)
-{
-    XMEMSET(md2->X, 0, MD2_X_SIZE);
-    XMEMSET(md2->C, 0, MD2_BLOCK_SIZE);
-    XMEMSET(md2->buffer, 0, MD2_BLOCK_SIZE);
-    md2->count = 0;
-}
-
-
-void wc_Md2Update(Md2* md2, const byte* data, word32 len)
-{
-    static const byte S[256] = 
-    {
-        41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6,
-        19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188,
-        76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24,
-        138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251,
-        245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63,
-        148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50,
-        39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165,
-        181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210,
-        150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157,
-        112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27,
-        96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15,
-        85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197,
-        234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65,
-        129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123,
-        8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233,
-        203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228,
-        166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237,
-        31, 26, 219, 153, 141, 51, 159, 17, 131, 20
-    };
-
-    while (len) {
-        word32 L = (MD2_PAD_SIZE - md2->count) < len ?
-                   (MD2_PAD_SIZE - md2->count) : len;
-        XMEMCPY(md2->buffer + md2->count, data, L);
-        md2->count += L;
-        data += L;
-        len  -= L;
-
-        if (md2->count == MD2_PAD_SIZE) {
-            int  i;
-            byte t;
-
-            md2->count = 0;
-            XMEMCPY(md2->X + MD2_PAD_SIZE, md2->buffer, MD2_PAD_SIZE);
-            t = md2->C[15];
-
-            for(i = 0; i < MD2_PAD_SIZE; i++) {
-                md2->X[32 + i] = md2->X[MD2_PAD_SIZE + i] ^ md2->X[i];
-                t = md2->C[i] ^= S[md2->buffer[i] ^ t];
-            }
-
-            t=0;
-            for(i = 0; i < 18; i++) {
-                int j;
-                for(j = 0; j < MD2_X_SIZE; j += 8) {
-                    t = md2->X[j+0] ^= S[t];
-                    t = md2->X[j+1] ^= S[t];
-                    t = md2->X[j+2] ^= S[t];
-                    t = md2->X[j+3] ^= S[t];
-                    t = md2->X[j+4] ^= S[t];
-                    t = md2->X[j+5] ^= S[t];
-                    t = md2->X[j+6] ^= S[t];
-                    t = md2->X[j+7] ^= S[t];
-                }
-                t = (t + i) & 0xFF;
-            }
-        }
-    }
-}
-
-
-void wc_Md2Final(Md2* md2, byte* hash)
-{
-    byte   padding[MD2_BLOCK_SIZE];
-    word32 padLen = MD2_PAD_SIZE - md2->count;
-    word32 i;
-
-    for (i = 0; i < padLen; i++)
-        padding[i] = (byte)padLen;
-
-    wc_Md2Update(md2, padding, padLen);
-    wc_Md2Update(md2, md2->C, MD2_BLOCK_SIZE);
-
-    XMEMCPY(hash, md2->X, MD2_DIGEST_SIZE);
-
-    wc_InitMd2(md2);
-}
-
-
-int wc_Md2Hash(const byte* data, word32 len, byte* hash)
-{
-#ifdef WOLFSSL_SMALL_STACK
-    Md2* md2;
-#else
-    Md2 md2[1];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    md2 = (Md2*)XMALLOC(sizeof(Md2), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (md2 == NULL)
-        return MEMORY_E;
-#endif
-
-    wc_InitMd2(md2);
-    wc_Md2Update(md2, data, len);
-    wc_Md2Final(md2, hash);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(md2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return 0;
-}
-
-
-#endif /* WOLFSSL_MD2 */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/md4.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/md4.c
deleted file mode 100755
index c428610..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/md4.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/* md4.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef NO_MD4
-
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-
-void wc_InitMd4(Md4* md4)
-{
-    md4->digest[0] = 0x67452301L;
-    md4->digest[1] = 0xefcdab89L;
-    md4->digest[2] = 0x98badcfeL;
-    md4->digest[3] = 0x10325476L;
-
-    md4->buffLen = 0;
-    md4->loLen   = 0;
-    md4->hiLen   = 0;
-}
-
-
-static void Transform(Md4* md4)
-{
-#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
-#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-
-    /* Copy context->state[] to working vars  */
-    word32 A = md4->digest[0];
-    word32 B = md4->digest[1];
-    word32 C = md4->digest[2];
-    word32 D = md4->digest[3];
-
-#define function(a,b,c,d,k,s) a=rotlFixed(a+F(b,c,d)+md4->buffer[k],s);
-    function(A,B,C,D, 0, 3);
-    function(D,A,B,C, 1, 7);
-    function(C,D,A,B, 2,11);
-    function(B,C,D,A, 3,19);
-    function(A,B,C,D, 4, 3);
-    function(D,A,B,C, 5, 7);
-    function(C,D,A,B, 6,11);
-    function(B,C,D,A, 7,19);
-    function(A,B,C,D, 8, 3);
-    function(D,A,B,C, 9, 7);
-    function(C,D,A,B,10,11);
-    function(B,C,D,A,11,19);
-    function(A,B,C,D,12, 3);
-    function(D,A,B,C,13, 7);
-    function(C,D,A,B,14,11);
-    function(B,C,D,A,15,19);
-
-#undef function	  
-#define function(a,b,c,d,k,s) \
-    a=rotlFixed(a+G(b,c,d)+md4->buffer[k]+0x5a827999,s);
-
-    function(A,B,C,D, 0, 3);
-    function(D,A,B,C, 4, 5);
-    function(C,D,A,B, 8, 9);
-    function(B,C,D,A,12,13);
-    function(A,B,C,D, 1, 3);
-    function(D,A,B,C, 5, 5);
-    function(C,D,A,B, 9, 9);
-    function(B,C,D,A,13,13);
-    function(A,B,C,D, 2, 3);
-    function(D,A,B,C, 6, 5);
-    function(C,D,A,B,10, 9);
-    function(B,C,D,A,14,13);
-    function(A,B,C,D, 3, 3);
-    function(D,A,B,C, 7, 5);
-    function(C,D,A,B,11, 9);
-    function(B,C,D,A,15,13);
-
-#undef function	 
-#define function(a,b,c,d,k,s) \
-    a=rotlFixed(a+H(b,c,d)+md4->buffer[k]+0x6ed9eba1,s);
-
-    function(A,B,C,D, 0, 3);
-    function(D,A,B,C, 8, 9);
-    function(C,D,A,B, 4,11);
-    function(B,C,D,A,12,15);
-    function(A,B,C,D, 2, 3);
-    function(D,A,B,C,10, 9);
-    function(C,D,A,B, 6,11);
-    function(B,C,D,A,14,15);
-    function(A,B,C,D, 1, 3);
-    function(D,A,B,C, 9, 9);
-    function(C,D,A,B, 5,11);
-    function(B,C,D,A,13,15);
-    function(A,B,C,D, 3, 3);
-    function(D,A,B,C,11, 9);
-    function(C,D,A,B, 7,11);
-    function(B,C,D,A,15,15);
-    
-    /* Add the working vars back into digest state[]  */
-    md4->digest[0] += A;
-    md4->digest[1] += B;
-    md4->digest[2] += C;
-    md4->digest[3] += D;
-}
-
-
-static INLINE void AddLength(Md4* md4, word32 len)
-{
-    word32 tmp = md4->loLen;
-    if ( (md4->loLen += len) < tmp)
-        md4->hiLen++;                       /* carry low to high */
-}
-
-
-void wc_Md4Update(Md4* md4, const byte* data, word32 len)
-{
-    /* do block size increments */
-    byte* local = (byte*)md4->buffer;
-
-    while (len) {
-        word32 add = min(len, MD4_BLOCK_SIZE - md4->buffLen);
-        XMEMCPY(&local[md4->buffLen], data, add);
-
-        md4->buffLen += add;
-        data         += add;
-        len          -= add;
-
-        if (md4->buffLen == MD4_BLOCK_SIZE) {
-            #ifdef BIG_ENDIAN_ORDER
-                ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
-            #endif
-            Transform(md4);
-            AddLength(md4, MD4_BLOCK_SIZE);
-            md4->buffLen = 0;
-        }
-    }
-}
-
-
-void wc_Md4Final(Md4* md4, byte* hash)
-{
-    byte* local = (byte*)md4->buffer;
-
-    AddLength(md4, md4->buffLen);               /* before adding pads */
-
-    local[md4->buffLen++] = 0x80;  /* add 1 */
-
-    /* pad with zeros */
-    if (md4->buffLen > MD4_PAD_SIZE) {
-        XMEMSET(&local[md4->buffLen], 0, MD4_BLOCK_SIZE - md4->buffLen);
-        md4->buffLen += MD4_BLOCK_SIZE - md4->buffLen;
-
-        #ifdef BIG_ENDIAN_ORDER
-            ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
-        #endif
-        Transform(md4);
-        md4->buffLen = 0;
-    }
-    XMEMSET(&local[md4->buffLen], 0, MD4_PAD_SIZE - md4->buffLen);
-   
-    /* put lengths in bits */
-    md4->hiLen = (md4->loLen >> (8*sizeof(md4->loLen) - 3)) + 
-                 (md4->hiLen << 3);
-    md4->loLen = md4->loLen << 3;
-
-    /* store lengths */
-    #ifdef BIG_ENDIAN_ORDER
-        ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
-    #endif
-    /* ! length ordering dependent on digest endian type ! */
-    XMEMCPY(&local[MD4_PAD_SIZE], &md4->loLen, sizeof(word32));
-    XMEMCPY(&local[MD4_PAD_SIZE + sizeof(word32)], &md4->hiLen, sizeof(word32));
-
-    Transform(md4);
-    #ifdef BIG_ENDIAN_ORDER
-        ByteReverseWords(md4->digest, md4->digest, MD4_DIGEST_SIZE);
-    #endif
-    XMEMCPY(hash, md4->digest, MD4_DIGEST_SIZE);
-
-    wc_InitMd4(md4);  /* reset state */
-}
-
-
-#endif /* NO_MD4 */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/md5.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/md5.c
deleted file mode 100755
index fbf732a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/md5.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/* md5.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#if !defined(NO_MD5)
-
-#if defined(WOLFSSL_TI_HASH)
-    /* #include  included by wc_port.c */
-#else
-
-#ifdef WOLFSSL_PIC32MZ_HASH
-#define wc_InitMd5   wc_InitMd5_sw
-#define wc_Md5Update wc_Md5Update_sw
-#define wc_Md5Final  wc_Md5Final_sw
-#endif
-
-#include 
-#include 
-
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-#ifdef FREESCALE_MMCAU
-    #include "cau_api.h"
-    #define XTRANSFORM(S,B)  cau_md5_hash_n((B), 1, (unsigned char*)(S)->digest)
-#else
-    #define XTRANSFORM(S,B)  Transform((S))
-#endif
-
-
-#ifdef STM32F2_HASH
-    /*
-     * STM32F2 hardware MD5 support through the STM32F2 standard peripheral
-     * library. Documentation located in STM32F2xx Standard Peripheral Library
-     * document (See note in README).
-     */
-    #include "stm32f2xx.h"
-
-    void wc_InitMd5(Md5* md5)
-    {
-        /* STM32F2 struct notes:
-         * md5->buffer  = first 4 bytes used to hold partial block if needed 
-         * md5->buffLen = num bytes currently stored in md5->buffer
-         * md5->loLen   = num bytes that have been written to STM32 FIFO
-         */
-        XMEMSET(md5->buffer, 0, MD5_REG_SIZE);
-			
-        md5->buffLen = 0;
-        md5->loLen = 0;
-
-        /* initialize HASH peripheral */
-        HASH_DeInit();
-
-        /* configure algo used, algo mode, datatype */
-        HASH->CR &= ~ (HASH_CR_ALGO | HASH_CR_DATATYPE | HASH_CR_MODE);
-        HASH->CR |= (HASH_AlgoSelection_MD5 | HASH_AlgoMode_HASH 
-                 | HASH_DataType_8b);
-
-        /* reset HASH processor */
-        HASH->CR |= HASH_CR_INIT;
-    }
-
-    void wc_Md5Update(Md5* md5, const byte* data, word32 len)
-    {
-        word32 i = 0;
-        word32 fill = 0;
-        word32 diff = 0;
-
-        /* if saved partial block is available */
-        if (md5->buffLen > 0) {
-            fill = 4 - md5->buffLen;
-
-            /* if enough data to fill, fill and push to FIFO */
-            if (fill <= len) {
-                XMEMCPY((byte*)md5->buffer + md5->buffLen, data, fill);
-                HASH_DataIn(*(uint32_t*)md5->buffer);
-
-                data += fill;
-                len -= fill;
-                md5->loLen += 4;
-                md5->buffLen = 0;
-            } else {
-                /* append partial to existing stored block */
-                XMEMCPY((byte*)md5->buffer + md5->buffLen, data, len);
-                md5->buffLen += len;
-                return;
-            }
-        }
-
-        /* write input block in the IN FIFO */
-        for (i = 0; i < len; i += 4)
-        {
-            diff = len - i;
-            if (diff < 4) {
-                /* store incomplete last block, not yet in FIFO */
-                XMEMSET(md5->buffer, 0, MD5_REG_SIZE);
-                XMEMCPY((byte*)md5->buffer, data, diff);
-                md5->buffLen = diff;
-            } else {
-                HASH_DataIn(*(uint32_t*)data);
-                data+=4;
-            }
-        }
-
-        /* keep track of total data length thus far */
-        md5->loLen += (len - md5->buffLen);
-    }
-
-    void wc_Md5Final(Md5* md5, byte* hash)
-    {
-        __IO uint16_t nbvalidbitsdata = 0;
-
-        /* finish reading any trailing bytes into FIFO */
-        if (md5->buffLen > 0) {
-            HASH_DataIn(*(uint32_t*)md5->buffer);
-            md5->loLen += md5->buffLen;
-        }
-
-        /* calculate number of valid bits in last word of input data */
-        nbvalidbitsdata = 8 * (md5->loLen % MD5_REG_SIZE);
-
-        /* configure number of valid bits in last word of the data */
-        HASH_SetLastWordValidBitsNbr(nbvalidbitsdata);
-
-        /* start HASH processor */
-        HASH_StartDigest();
-
-        /* wait until Busy flag == RESET */
-        while (HASH_GetFlagStatus(HASH_FLAG_BUSY) != RESET) {}
-        
-        /* read message digest */
-        md5->digest[0] = HASH->HR[0];
-        md5->digest[1] = HASH->HR[1];
-        md5->digest[2] = HASH->HR[2];
-        md5->digest[3] = HASH->HR[3];
-
-        ByteReverseWords(md5->digest, md5->digest, MD5_DIGEST_SIZE);
-
-        XMEMCPY(hash, md5->digest, MD5_DIGEST_SIZE);
-
-        wc_InitMd5(md5);  /* reset state */
-    }
-
-#else /* CTaoCrypt software implementation */
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-void wc_InitMd5(Md5* md5)
-{
-    md5->digest[0] = 0x67452301L;
-    md5->digest[1] = 0xefcdab89L;
-    md5->digest[2] = 0x98badcfeL;
-    md5->digest[3] = 0x10325476L;
-
-    md5->buffLen = 0;
-    md5->loLen   = 0;
-    md5->hiLen   = 0;
-}
-
-#ifndef FREESCALE_MMCAU
-
-static void Transform(Md5* md5)
-{
-#define F1(x, y, z) (z ^ (x & (y ^ z)))
-#define F2(x, y, z) F1(z, x, y)
-#define F3(x, y, z) (x ^ y ^ z)
-#define F4(x, y, z) (y ^ (x | ~z))
-
-#define MD5STEP(f, w, x, y, z, data, s) \
-    w = rotlFixed(w + f(x, y, z) + data, s) + x
-
-    /* Copy context->state[] to working vars  */
-    word32 a = md5->digest[0];
-    word32 b = md5->digest[1];
-    word32 c = md5->digest[2];
-    word32 d = md5->digest[3];
-
-    MD5STEP(F1, a, b, c, d, md5->buffer[0]  + 0xd76aa478,  7);
-    MD5STEP(F1, d, a, b, c, md5->buffer[1]  + 0xe8c7b756, 12);
-    MD5STEP(F1, c, d, a, b, md5->buffer[2]  + 0x242070db, 17);
-    MD5STEP(F1, b, c, d, a, md5->buffer[3]  + 0xc1bdceee, 22);
-    MD5STEP(F1, a, b, c, d, md5->buffer[4]  + 0xf57c0faf,  7);
-    MD5STEP(F1, d, a, b, c, md5->buffer[5]  + 0x4787c62a, 12);
-    MD5STEP(F1, c, d, a, b, md5->buffer[6]  + 0xa8304613, 17);
-    MD5STEP(F1, b, c, d, a, md5->buffer[7]  + 0xfd469501, 22);
-    MD5STEP(F1, a, b, c, d, md5->buffer[8]  + 0x698098d8,  7);
-    MD5STEP(F1, d, a, b, c, md5->buffer[9]  + 0x8b44f7af, 12);
-    MD5STEP(F1, c, d, a, b, md5->buffer[10] + 0xffff5bb1, 17);
-    MD5STEP(F1, b, c, d, a, md5->buffer[11] + 0x895cd7be, 22);
-    MD5STEP(F1, a, b, c, d, md5->buffer[12] + 0x6b901122,  7);
-    MD5STEP(F1, d, a, b, c, md5->buffer[13] + 0xfd987193, 12);
-    MD5STEP(F1, c, d, a, b, md5->buffer[14] + 0xa679438e, 17);
-    MD5STEP(F1, b, c, d, a, md5->buffer[15] + 0x49b40821, 22);
-
-    MD5STEP(F2, a, b, c, d, md5->buffer[1]  + 0xf61e2562,  5);
-    MD5STEP(F2, d, a, b, c, md5->buffer[6]  + 0xc040b340,  9);
-    MD5STEP(F2, c, d, a, b, md5->buffer[11] + 0x265e5a51, 14);
-    MD5STEP(F2, b, c, d, a, md5->buffer[0]  + 0xe9b6c7aa, 20);
-    MD5STEP(F2, a, b, c, d, md5->buffer[5]  + 0xd62f105d,  5);
-    MD5STEP(F2, d, a, b, c, md5->buffer[10] + 0x02441453,  9);
-    MD5STEP(F2, c, d, a, b, md5->buffer[15] + 0xd8a1e681, 14);
-    MD5STEP(F2, b, c, d, a, md5->buffer[4]  + 0xe7d3fbc8, 20);
-    MD5STEP(F2, a, b, c, d, md5->buffer[9]  + 0x21e1cde6,  5);
-    MD5STEP(F2, d, a, b, c, md5->buffer[14] + 0xc33707d6,  9);
-    MD5STEP(F2, c, d, a, b, md5->buffer[3]  + 0xf4d50d87, 14);
-    MD5STEP(F2, b, c, d, a, md5->buffer[8]  + 0x455a14ed, 20);
-    MD5STEP(F2, a, b, c, d, md5->buffer[13] + 0xa9e3e905,  5);
-    MD5STEP(F2, d, a, b, c, md5->buffer[2]  + 0xfcefa3f8,  9);
-    MD5STEP(F2, c, d, a, b, md5->buffer[7]  + 0x676f02d9, 14);
-    MD5STEP(F2, b, c, d, a, md5->buffer[12] + 0x8d2a4c8a, 20);
-
-    MD5STEP(F3, a, b, c, d, md5->buffer[5]  + 0xfffa3942,  4);
-    MD5STEP(F3, d, a, b, c, md5->buffer[8]  + 0x8771f681, 11);
-    MD5STEP(F3, c, d, a, b, md5->buffer[11] + 0x6d9d6122, 16);
-    MD5STEP(F3, b, c, d, a, md5->buffer[14] + 0xfde5380c, 23);
-    MD5STEP(F3, a, b, c, d, md5->buffer[1]  + 0xa4beea44,  4);
-    MD5STEP(F3, d, a, b, c, md5->buffer[4]  + 0x4bdecfa9, 11);
-    MD5STEP(F3, c, d, a, b, md5->buffer[7]  + 0xf6bb4b60, 16);
-    MD5STEP(F3, b, c, d, a, md5->buffer[10] + 0xbebfbc70, 23);
-    MD5STEP(F3, a, b, c, d, md5->buffer[13] + 0x289b7ec6,  4);
-    MD5STEP(F3, d, a, b, c, md5->buffer[0]  + 0xeaa127fa, 11);
-    MD5STEP(F3, c, d, a, b, md5->buffer[3]  + 0xd4ef3085, 16);
-    MD5STEP(F3, b, c, d, a, md5->buffer[6]  + 0x04881d05, 23);
-    MD5STEP(F3, a, b, c, d, md5->buffer[9]  + 0xd9d4d039,  4);
-    MD5STEP(F3, d, a, b, c, md5->buffer[12] + 0xe6db99e5, 11);
-    MD5STEP(F3, c, d, a, b, md5->buffer[15] + 0x1fa27cf8, 16);
-    MD5STEP(F3, b, c, d, a, md5->buffer[2]  + 0xc4ac5665, 23);
-
-    MD5STEP(F4, a, b, c, d, md5->buffer[0]  + 0xf4292244,  6);
-    MD5STEP(F4, d, a, b, c, md5->buffer[7]  + 0x432aff97, 10);
-    MD5STEP(F4, c, d, a, b, md5->buffer[14] + 0xab9423a7, 15);
-    MD5STEP(F4, b, c, d, a, md5->buffer[5]  + 0xfc93a039, 21);
-    MD5STEP(F4, a, b, c, d, md5->buffer[12] + 0x655b59c3,  6);
-    MD5STEP(F4, d, a, b, c, md5->buffer[3]  + 0x8f0ccc92, 10);
-    MD5STEP(F4, c, d, a, b, md5->buffer[10] + 0xffeff47d, 15);
-    MD5STEP(F4, b, c, d, a, md5->buffer[1]  + 0x85845dd1, 21);
-    MD5STEP(F4, a, b, c, d, md5->buffer[8]  + 0x6fa87e4f,  6);
-    MD5STEP(F4, d, a, b, c, md5->buffer[15] + 0xfe2ce6e0, 10);
-    MD5STEP(F4, c, d, a, b, md5->buffer[6]  + 0xa3014314, 15);
-    MD5STEP(F4, b, c, d, a, md5->buffer[13] + 0x4e0811a1, 21);
-    MD5STEP(F4, a, b, c, d, md5->buffer[4]  + 0xf7537e82,  6);
-    MD5STEP(F4, d, a, b, c, md5->buffer[11] + 0xbd3af235, 10);
-    MD5STEP(F4, c, d, a, b, md5->buffer[2]  + 0x2ad7d2bb, 15);
-    MD5STEP(F4, b, c, d, a, md5->buffer[9]  + 0xeb86d391, 21);
-    
-    /* Add the working vars back into digest state[]  */
-    md5->digest[0] += a;
-    md5->digest[1] += b;
-    md5->digest[2] += c;
-    md5->digest[3] += d;
-}
-
-#endif /* FREESCALE_MMCAU */
-
-
-static INLINE void AddLength(Md5* md5, word32 len)
-{
-    word32 tmp = md5->loLen;
-    if ( (md5->loLen += len) < tmp)
-        md5->hiLen++;                       /* carry low to high */
-}
-
-
-void wc_Md5Update(Md5* md5, const byte* data, word32 len)
-{
-    /* do block size increments */
-    byte* local = (byte*)md5->buffer;
-
-    while (len) {
-        word32 add = min(len, MD5_BLOCK_SIZE - md5->buffLen);
-        XMEMCPY(&local[md5->buffLen], data, add);
-
-        md5->buffLen += add;
-        data         += add;
-        len          -= add;
-
-        if (md5->buffLen == MD5_BLOCK_SIZE) {
-            #if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
-                ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
-            #endif
-            XTRANSFORM(md5, local);
-            AddLength(md5, MD5_BLOCK_SIZE);
-            md5->buffLen = 0;
-        }
-    }
-}
-
-
-void wc_Md5Final(Md5* md5, byte* hash)
-{
-    byte* local = (byte*)md5->buffer;
-
-    AddLength(md5, md5->buffLen);  /* before adding pads */
-
-    local[md5->buffLen++] = 0x80;  /* add 1 */
-
-    /* pad with zeros */
-    if (md5->buffLen > MD5_PAD_SIZE) {
-        XMEMSET(&local[md5->buffLen], 0, MD5_BLOCK_SIZE - md5->buffLen);
-        md5->buffLen += MD5_BLOCK_SIZE - md5->buffLen;
-
-        #if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
-            ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
-        #endif
-        XTRANSFORM(md5, local);
-        md5->buffLen = 0;
-    }
-    XMEMSET(&local[md5->buffLen], 0, MD5_PAD_SIZE - md5->buffLen);
-   
-    /* put lengths in bits */
-    md5->hiLen = (md5->loLen >> (8*sizeof(md5->loLen) - 3)) + 
-                 (md5->hiLen << 3);
-    md5->loLen = md5->loLen << 3;
-
-    /* store lengths */
-    #if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
-        ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
-    #endif
-    /* ! length ordering dependent on digest endian type ! */
-    XMEMCPY(&local[MD5_PAD_SIZE], &md5->loLen, sizeof(word32));
-    XMEMCPY(&local[MD5_PAD_SIZE + sizeof(word32)], &md5->hiLen, sizeof(word32));
-
-    XTRANSFORM(md5, local);
-    #ifdef BIG_ENDIAN_ORDER
-        ByteReverseWords(md5->digest, md5->digest, MD5_DIGEST_SIZE);
-    #endif
-    XMEMCPY(hash, md5->digest, MD5_DIGEST_SIZE);
-
-    wc_InitMd5(md5);  /* reset state */
-}
-
-#endif /* STM32F2_HASH */
-
-
-int wc_Md5Hash(const byte* data, word32 len, byte* hash)
-{
-#ifdef WOLFSSL_SMALL_STACK
-    Md5* md5;
-#else
-    Md5 md5[1];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (md5 == NULL)
-        return MEMORY_E;
-#endif
-
-    wc_InitMd5(md5);
-    wc_Md5Update(md5, data, len);
-    wc_Md5Final(md5, hash);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return 0;
-}
-
-#endif /* WOLFSSL_TI_HASH */
-
-#endif /* NO_MD5 */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/memory.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/memory.c
deleted file mode 100755
index dd92819..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/memory.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/* memory.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-/* check old macros @wc_fips */
-#if defined(USE_CYASSL_MEMORY) && !defined(USE_WOLFSSL_MEMORY)
-    #define USE_WOLFSSL_MEMORY
-#endif
-#if defined(CYASSL_MALLOC_CHECK) && !defined(WOLFSSL_MALLOC_CHECK)
-    #define WOLFSSL_MALLOC_CHECK
-#endif
-
-#ifdef USE_WOLFSSL_MEMORY
-
-#include 
-#include 
-
-#ifdef WOLFSSL_MALLOC_CHECK
-    #include 
-#endif
-
-/* Set these to default values initially. */
-static wolfSSL_Malloc_cb  malloc_function = 0;
-static wolfSSL_Free_cb    free_function = 0;
-static wolfSSL_Realloc_cb realloc_function = 0;
-
-int wolfSSL_SetAllocators(wolfSSL_Malloc_cb  mf,
-                          wolfSSL_Free_cb    ff,
-                          wolfSSL_Realloc_cb rf)
-{
-    int res = 0;
-
-    if (mf)
-        malloc_function = mf;
-    else
-        res = BAD_FUNC_ARG;
-
-    if (ff)
-        free_function = ff;
-    else
-        res = BAD_FUNC_ARG;
-
-    if (rf)
-        realloc_function = rf;
-    else
-        res = BAD_FUNC_ARG;
-
-    return res;
-}
-
-
-void* wolfSSL_Malloc(size_t size)
-{
-    void* res = 0;
-
-    if (malloc_function)
-        res = malloc_function(size);
-    else
-        res = malloc(size);
-
-    #ifdef WOLFSSL_MALLOC_CHECK
-        if (res == NULL)
-            puts("wolfSSL_malloc failed");
-    #endif
-                
-    return res;
-}
-
-void wolfSSL_Free(void *ptr)
-{
-    if (free_function)
-        free_function(ptr);
-    else
-        free(ptr);
-}
-
-void* wolfSSL_Realloc(void *ptr, size_t size)
-{
-    void* res = 0;
-
-    if (realloc_function)
-        res = realloc_function(ptr, size);
-    else
-        res = realloc(ptr, size);
-
-    return res;
-}
-
-#endif /* USE_WOLFSSL_MEMORY */
-
-
-#ifdef HAVE_IO_POOL
-
-/* Example for user io pool, shared build may need definitions in lib proper */
-
-#include 
-#include 
-
-#ifndef HAVE_THREAD_LS
-    #error "Oops, simple I/O pool example needs thread local storage"
-#endif
-
-
-/* allow simple per thread in and out pools */
-/* use 17k size sense max record size is 16k plus overhead */
-static THREAD_LS_T byte pool_in[17*1024];
-static THREAD_LS_T byte pool_out[17*1024];
-
-
-void* XMALLOC(size_t n, void* heap, int type)
-{
-    (void)heap;
-
-    if (type == DYNAMIC_TYPE_IN_BUFFER) {
-        if (n < sizeof(pool_in))
-            return pool_in;
-        else
-            return NULL;
-    }
-
-    if (type == DYNAMIC_TYPE_OUT_BUFFER) {
-        if (n < sizeof(pool_out))
-            return pool_out;
-        else
-            return NULL;
-    }
-
-    return malloc(n);
-}
-
-void* XREALLOC(void *p, size_t n, void* heap, int type)
-{
-    (void)heap;
-
-    if (type == DYNAMIC_TYPE_IN_BUFFER) {
-        if (n < sizeof(pool_in))
-            return pool_in;
-        else
-            return NULL;
-    }
-
-    if (type == DYNAMIC_TYPE_OUT_BUFFER) {
-        if (n < sizeof(pool_out))
-            return pool_out;
-        else
-            return NULL;
-    }
-
-    return realloc(p, n);
-}
-
-
-/* unit api calls, let's make sure visible with WOLFSSL_API */
-WOLFSSL_API void XFREE(void *p, void* heap, int type)
-{
-    (void)heap;
-
-    if (type == DYNAMIC_TYPE_IN_BUFFER)
-        return;  /* do nothing, static pool */
-
-    if (type == DYNAMIC_TYPE_OUT_BUFFER)
-        return;  /* do nothing, static pool */
-
-    free(p);
-}
-
-#endif /* HAVE_IO_POOL */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/misc.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/misc.c
deleted file mode 100755
index 8a79a4c..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/misc.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/* misc.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef WOLF_CRYPT_MISC_C
-#define WOLF_CRYPT_MISC_C
-
-#include 
-
-/* inlining these functions is a huge speed increase and a small size decrease, 
-   because the functions are smaller than function call setup/cleanup, e.g.,
-   md5 benchmark is twice as fast with inline.  If you don't want it, then
-   define NO_INLINE and compile this file into wolfssl, otherwise it's used as
-   a source header
- */
-
-#ifdef NO_INLINE
-    #define STATIC
-#else
-    #define STATIC static
-#endif
-
-
-#ifdef INTEL_INTRINSICS
-
-    #include       /* get intrinsic definitions */
-
-    /* for non visual studio probably need no long version, 32 bit only
-     * i.e., _rotl and _rotr */
-    #pragma intrinsic(_lrotl, _lrotr)
-
-    STATIC INLINE word32 rotlFixed(word32 x, word32 y)
-    {
-        return y ? _lrotl(x, y) : x;
-    }
-
-    STATIC INLINE word32 rotrFixed(word32 x, word32 y)
-    {
-        return y ? _lrotr(x, y) : x;
-    }
-
-#else /* generic */
-
-    STATIC INLINE word32 rotlFixed(word32 x, word32 y)
-    {
-        return (x << y) | (x >> (sizeof(y) * 8 - y));
-    }   
-
-
-    STATIC INLINE word32 rotrFixed(word32 x, word32 y)
-    {
-        return (x >> y) | (x << (sizeof(y) * 8 - y));
-    }
-
-#endif
-
-
-STATIC INLINE word32 ByteReverseWord32(word32 value)
-{
-#ifdef PPC_INTRINSICS
-    /* PPC: load reverse indexed instruction */
-    return (word32)__lwbrx(&value,0);
-#elif defined(KEIL_INTRINSICS)
-    return (word32)__rev(value);
-#elif defined(FAST_ROTATE)
-    /* 5 instructions with rotate instruction, 9 without */
-    return (rotrFixed(value, 8U) & 0xff00ff00) |
-           (rotlFixed(value, 8U) & 0x00ff00ff);
-#else
-    /* 6 instructions with rotate instruction, 8 without */
-    value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8);
-    return rotlFixed(value, 16U);
-#endif
-}
-
-
-STATIC INLINE void ByteReverseWords(word32* out, const word32* in,
-                                    word32 byteCount)
-{
-    word32 count = byteCount/(word32)sizeof(word32), i;
-
-    for (i = 0; i < count; i++)
-        out[i] = ByteReverseWord32(in[i]);
-
-}
-
-
-#ifdef WORD64_AVAILABLE
-
-
-STATIC INLINE word64 rotlFixed64(word64 x, word64 y)
-{
-    return (x << y) | (x >> (sizeof(y) * 8 - y));
-}  
-
-
-STATIC INLINE word64 rotrFixed64(word64 x, word64 y)
-{
-    return (x >> y) | (x << (sizeof(y) * 8 - y));
-}
-
-
-STATIC INLINE word64 ByteReverseWord64(word64 value)
-{
-#ifdef WOLFCRYPT_SLOW_WORD64
-	return (word64)(ByteReverseWord32((word32)value)) << 32 | 
-                    ByteReverseWord32((word32)(value>>32));
-#else
-	value = ((value & W64LIT(0xFF00FF00FF00FF00)) >> 8) |
-            ((value & W64LIT(0x00FF00FF00FF00FF)) << 8);
-	value = ((value & W64LIT(0xFFFF0000FFFF0000)) >> 16) |
-            ((value & W64LIT(0x0000FFFF0000FFFF)) << 16);
-	return rotlFixed64(value, 32U);
-#endif
-}
-
-
-STATIC INLINE void ByteReverseWords64(word64* out, const word64* in,
-                                      word32 byteCount)
-{
-    word32 count = byteCount/(word32)sizeof(word64), i;
-
-    for (i = 0; i < count; i++)
-        out[i] = ByteReverseWord64(in[i]);
-
-}
-
-#endif /* WORD64_AVAILABLE */
-
-
-STATIC INLINE void XorWords(wolfssl_word* r, const wolfssl_word* a, word32 n)
-{
-    word32 i;
-
-    for (i = 0; i < n; i++) r[i] ^= a[i];
-}
-
-
-STATIC INLINE void xorbuf(void* buf, const void* mask, word32 count)
-{
-    if (((wolfssl_word)buf | (wolfssl_word)mask | count) % WOLFSSL_WORD_SIZE == 0)
-        XorWords( (wolfssl_word*)buf,
-                  (const wolfssl_word*)mask, count / WOLFSSL_WORD_SIZE);
-    else {
-        word32 i;
-        byte*       b = (byte*)buf;
-        const byte* m = (const byte*)mask;
-
-        for (i = 0; i < count; i++) b[i] ^= m[i];
-    }
-}
-
-
-/* Make sure compiler doesn't skip */
-STATIC INLINE void ForceZero(const void* mem, word32 len)
-{
-    volatile byte* z = (volatile byte*)mem;
-
-    while (len--) *z++ = 0;
-}
-
-
-/* check all length bytes for equality, return 0 on success */
-STATIC INLINE int ConstantCompare(const byte* a, const byte* b, int length)
-{
-    int i;
-    int compareSum = 0;
-
-    for (i = 0; i < length; i++) {
-        compareSum |= a[i] ^ b[i];
-    }
-
-    return compareSum;
-}
-
-#undef STATIC
-
-#endif /* WOLF_CRYPT_MISC_C */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/pkcs7.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/pkcs7.c
deleted file mode 100755
index 2f66ea2..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/pkcs7.c
+++ /dev/null
@@ -1,1858 +0,0 @@
-/* pkcs7.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef HAVE_PKCS7
-
-#include 
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-
-/* placed ASN.1 contentType OID into *output, return idx on success,
- * 0 upon failure */
-WOLFSSL_LOCAL int wc_SetContentType(int pkcs7TypeOID, byte* output)
-{
-    /* PKCS#7 content types, RFC 2315, section 14 */
-    static const byte pkcs7[]              = { 0x2A, 0x86, 0x48, 0x86, 0xF7,
-                                               0x0D, 0x01, 0x07 };
-    static const byte data[]               = { 0x2A, 0x86, 0x48, 0x86, 0xF7,
-                                               0x0D, 0x01, 0x07, 0x01 };
-    static const byte signedData[]         = { 0x2A, 0x86, 0x48, 0x86, 0xF7,
-                                               0x0D, 0x01, 0x07, 0x02};
-    static const byte envelopedData[]      = { 0x2A, 0x86, 0x48, 0x86, 0xF7,
-                                               0x0D, 0x01, 0x07, 0x03 };
-    static const byte signedAndEnveloped[] = { 0x2A, 0x86, 0x48, 0x86, 0xF7,
-                                               0x0D, 0x01, 0x07, 0x04 };
-    static const byte digestedData[]       = { 0x2A, 0x86, 0x48, 0x86, 0xF7,
-                                               0x0D, 0x01, 0x07, 0x05 };
-    static const byte encryptedData[]      = { 0x2A, 0x86, 0x48, 0x86, 0xF7,
-                                               0x0D, 0x01, 0x07, 0x06 };
-
-    int idSz;
-    int typeSz = 0, idx = 0;
-    const byte* typeName = 0;
-    byte ID_Length[MAX_LENGTH_SZ];
-
-    switch (pkcs7TypeOID) {
-        case PKCS7_MSG:
-            typeSz = sizeof(pkcs7);
-            typeName = pkcs7;
-            break;
-
-        case DATA:
-            typeSz = sizeof(data);
-            typeName = data;
-            break;
-
-        case SIGNED_DATA:
-            typeSz = sizeof(signedData);
-            typeName = signedData;
-            break;
-        
-        case ENVELOPED_DATA:
-            typeSz = sizeof(envelopedData);
-            typeName = envelopedData;
-            break;
-
-        case SIGNED_AND_ENVELOPED_DATA:
-            typeSz = sizeof(signedAndEnveloped);
-            typeName = signedAndEnveloped;
-            break;
-
-        case DIGESTED_DATA:
-            typeSz = sizeof(digestedData);
-            typeName = digestedData;
-            break;
-
-        case ENCRYPTED_DATA:
-            typeSz = sizeof(encryptedData);
-            typeName = encryptedData;
-            break;
-
-        default:
-            WOLFSSL_MSG("Unknown PKCS#7 Type");
-            return 0;
-    };
-
-    idSz  = SetLength(typeSz, ID_Length);
-    output[idx++] = ASN_OBJECT_ID;
-    XMEMCPY(output + idx, ID_Length, idSz);
-    idx += idSz;
-    XMEMCPY(output + idx, typeName, typeSz);
-    idx += typeSz;
-
-    return idx;
-
-}
-
-
-/* get ASN.1 contentType OID sum, return 0 on success, <0 on failure */
-int wc_GetContentType(const byte* input, word32* inOutIdx, word32* oid,
-                   word32 maxIdx)
-{
-    int length;
-    word32 i = *inOutIdx;
-    byte b;
-    *oid = 0;
-
-    WOLFSSL_ENTER("wc_GetContentType");
-
-    b = input[i++];
-    if (b != ASN_OBJECT_ID)
-        return ASN_OBJECT_ID_E;
-
-    if (GetLength(input, &i, &length, maxIdx) < 0)
-        return ASN_PARSE_E;
-
-    while(length--) {
-        *oid += input[i];
-        i++;
-    }
-
-    *inOutIdx = i;
-
-    return 0;
-}
-
-
-/* init PKCS7 struct with recipient cert, decode into DecodedCert */
-int wc_PKCS7_InitWithCert(PKCS7* pkcs7, byte* cert, word32 certSz)
-{
-    int ret = 0;
-
-    XMEMSET(pkcs7, 0, sizeof(PKCS7));
-    if (cert != NULL && certSz > 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        DecodedCert* dCert;
-
-        dCert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-        if (dCert == NULL)
-            return MEMORY_E;
-#else
-        DecodedCert stack_dCert;
-        DecodedCert* dCert = &stack_dCert;
-#endif
-
-        pkcs7->singleCert = cert;
-        pkcs7->singleCertSz = certSz;
-        InitDecodedCert(dCert, cert, certSz, 0);
-
-        ret = ParseCert(dCert, CA_TYPE, NO_VERIFY, 0);
-        if (ret < 0) {
-            FreeDecodedCert(dCert);
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(dCert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ret;
-        }
-
-        XMEMCPY(pkcs7->publicKey, dCert->publicKey, dCert->pubKeySize);
-        pkcs7->publicKeySz = dCert->pubKeySize;
-        XMEMCPY(pkcs7->issuerHash, dCert->issuerHash, KEYID_SIZE);
-        pkcs7->issuer = dCert->issuerRaw;
-        pkcs7->issuerSz = dCert->issuerRawLen;
-        XMEMCPY(pkcs7->issuerSn, dCert->serial, dCert->serialSz);
-        pkcs7->issuerSnSz = dCert->serialSz;
-        FreeDecodedCert(dCert);
-
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(dCert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-    }
-
-    return ret;
-}
-
-
-/* releases any memory allocated by a PKCS7 initializer */
-void wc_PKCS7_Free(PKCS7* pkcs7)
-{
-    (void)pkcs7;
-}
-
-
-/* build PKCS#7 data content type */
-int wc_PKCS7_EncodeData(PKCS7* pkcs7, byte* output, word32 outputSz)
-{
-    static const byte oid[] =
-        { ASN_OBJECT_ID, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01,
-                         0x07, 0x01 };
-    byte seq[MAX_SEQ_SZ];
-    byte octetStr[MAX_OCTET_STR_SZ];
-    word32 seqSz;
-    word32 octetStrSz;
-    word32 oidSz = (word32)sizeof(oid);
-    int idx = 0;
-
-    octetStrSz = SetOctetString(pkcs7->contentSz, octetStr);
-    seqSz = SetSequence(pkcs7->contentSz + octetStrSz + oidSz, seq);
-
-    if (outputSz < pkcs7->contentSz + octetStrSz + oidSz + seqSz)
-        return BUFFER_E;
-
-    XMEMCPY(output, seq, seqSz);
-    idx += seqSz;
-    XMEMCPY(output + idx, oid, oidSz);
-    idx += oidSz;
-    XMEMCPY(output + idx, octetStr, octetStrSz);
-    idx += octetStrSz;
-    XMEMCPY(output + idx, pkcs7->content, pkcs7->contentSz);
-    idx += pkcs7->contentSz;
-
-    return idx;
-}
-
-
-typedef struct EncodedAttrib {
-    byte valueSeq[MAX_SEQ_SZ];
-        const byte* oid;
-        byte valueSet[MAX_SET_SZ];
-        const byte* value;
-    word32 valueSeqSz, oidSz, idSz, valueSetSz, valueSz, totalSz;
-} EncodedAttrib;
-
-
-typedef struct ESD {
-    Sha sha;
-    byte contentDigest[SHA_DIGEST_SIZE + 2]; /* content only + ASN.1 heading */
-    byte contentAttribsDigest[SHA_DIGEST_SIZE];
-    byte encContentDigest[512];
-
-    byte outerSeq[MAX_SEQ_SZ];
-        byte outerContent[MAX_EXP_SZ];
-            byte innerSeq[MAX_SEQ_SZ];
-                byte version[MAX_VERSION_SZ];
-                byte digAlgoIdSet[MAX_SET_SZ];
-                    byte singleDigAlgoId[MAX_ALGO_SZ];
-
-                byte contentInfoSeq[MAX_SEQ_SZ];
-                    byte innerContSeq[MAX_EXP_SZ];
-                        byte innerOctets[MAX_OCTET_STR_SZ];
-
-                byte certsSet[MAX_SET_SZ];
-
-                byte signerInfoSet[MAX_SET_SZ];
-                    byte signerInfoSeq[MAX_SEQ_SZ];
-                        byte signerVersion[MAX_VERSION_SZ];
-                        byte issuerSnSeq[MAX_SEQ_SZ];
-                            byte issuerName[MAX_SEQ_SZ];
-                            byte issuerSn[MAX_SN_SZ];
-                        byte signerDigAlgoId[MAX_ALGO_SZ];
-                        byte digEncAlgoId[MAX_ALGO_SZ];
-                        byte signedAttribSet[MAX_SET_SZ];
-                            EncodedAttrib signedAttribs[6];
-                        byte signerDigest[MAX_OCTET_STR_SZ];
-    word32 innerOctetsSz, innerContSeqSz, contentInfoSeqSz;
-    word32 outerSeqSz, outerContentSz, innerSeqSz, versionSz, digAlgoIdSetSz,
-           singleDigAlgoIdSz, certsSetSz;
-    word32 signerInfoSetSz, signerInfoSeqSz, signerVersionSz,
-           issuerSnSeqSz, issuerNameSz, issuerSnSz,
-           signerDigAlgoIdSz, digEncAlgoIdSz, signerDigestSz;
-    word32 encContentDigestSz, signedAttribsSz, signedAttribsCount,
-           signedAttribSetSz;
-} ESD;
-
-
-static int EncodeAttributes(EncodedAttrib* ea, int eaSz,
-                                            PKCS7Attrib* attribs, int attribsSz)
-{
-    int i;
-    int maxSz = min(eaSz, attribsSz);
-    int allAttribsSz = 0;
-
-    for (i = 0; i < maxSz; i++)
-    {
-        int attribSz = 0;
-
-        ea[i].value = attribs[i].value;
-        ea[i].valueSz = attribs[i].valueSz;
-        attribSz += ea[i].valueSz;
-        ea[i].valueSetSz = SetSet(attribSz, ea[i].valueSet);
-        attribSz += ea[i].valueSetSz;
-        ea[i].oid = attribs[i].oid;
-        ea[i].oidSz = attribs[i].oidSz;
-        attribSz += ea[i].oidSz;
-        ea[i].valueSeqSz = SetSequence(attribSz, ea[i].valueSeq);
-        attribSz += ea[i].valueSeqSz;
-        ea[i].totalSz = attribSz;
-
-        allAttribsSz += attribSz;
-    }
-    return allAttribsSz;
-}
-
-
-static int FlattenAttributes(byte* output, EncodedAttrib* ea, int eaSz)
-{
-    int i, idx;
-
-    idx = 0;
-    for (i = 0; i < eaSz; i++) {
-        XMEMCPY(output + idx, ea[i].valueSeq, ea[i].valueSeqSz);
-        idx += ea[i].valueSeqSz;
-        XMEMCPY(output + idx, ea[i].oid, ea[i].oidSz);
-        idx += ea[i].oidSz;
-        XMEMCPY(output + idx, ea[i].valueSet, ea[i].valueSetSz);
-        idx += ea[i].valueSetSz;
-        XMEMCPY(output + idx, ea[i].value, ea[i].valueSz);
-        idx += ea[i].valueSz;
-    }
-    return 0;
-}
-
-
-/* build PKCS#7 signedData content type */
-int wc_PKCS7_EncodeSignedData(PKCS7* pkcs7, byte* output, word32 outputSz)
-{
-    static const byte outerOid[] =
-        { ASN_OBJECT_ID, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01,
-                         0x07, 0x02 };
-    static const byte innerOid[] =
-        { ASN_OBJECT_ID, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01,
-                         0x07, 0x01 };
-
-#ifdef WOLFSSL_SMALL_STACK
-    ESD* esd = NULL;
-#else
-    ESD stack_esd;
-    ESD* esd = &stack_esd;
-#endif
-
-    word32 signerInfoSz = 0;
-    word32 totalSz = 0;
-    int idx = 0, ret = 0;
-    byte* flatSignedAttribs = NULL;
-    word32 flatSignedAttribsSz = 0;
-    word32 innerOidSz = sizeof(innerOid);
-    word32 outerOidSz = sizeof(outerOid);
-
-    if (pkcs7 == NULL || pkcs7->content == NULL || pkcs7->contentSz == 0 ||
-        pkcs7->encryptOID == 0 || pkcs7->hashOID == 0 || pkcs7->rng == 0 ||
-        pkcs7->singleCert == NULL || pkcs7->singleCertSz == 0 ||
-        pkcs7->privateKey == NULL || pkcs7->privateKeySz == 0 ||
-        output == NULL || outputSz == 0)
-        return BAD_FUNC_ARG;
-
-#ifdef WOLFSSL_SMALL_STACK
-    esd = (ESD*)XMALLOC(sizeof(ESD), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (esd == NULL)
-        return MEMORY_E;
-#endif
-
-    XMEMSET(esd, 0, sizeof(ESD));
-    ret = wc_InitSha(&esd->sha);
-    if (ret != 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(esd, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ret;
-    }
-
-    if (pkcs7->contentSz != 0)
-    {
-        wc_ShaUpdate(&esd->sha, pkcs7->content, pkcs7->contentSz);
-        esd->contentDigest[0] = ASN_OCTET_STRING;
-        esd->contentDigest[1] = SHA_DIGEST_SIZE;
-        wc_ShaFinal(&esd->sha, &esd->contentDigest[2]);
-    }
-
-    esd->innerOctetsSz = SetOctetString(pkcs7->contentSz, esd->innerOctets);
-    esd->innerContSeqSz = SetExplicit(0, esd->innerOctetsSz + pkcs7->contentSz,
-                                esd->innerContSeq);
-    esd->contentInfoSeqSz = SetSequence(pkcs7->contentSz + esd->innerOctetsSz +
-                                    innerOidSz + esd->innerContSeqSz,
-                                    esd->contentInfoSeq);
-
-    esd->issuerSnSz = SetSerialNumber(pkcs7->issuerSn, pkcs7->issuerSnSz,
-                                     esd->issuerSn);
-    signerInfoSz += esd->issuerSnSz;
-    esd->issuerNameSz = SetSequence(pkcs7->issuerSz, esd->issuerName);
-    signerInfoSz += esd->issuerNameSz + pkcs7->issuerSz;
-    esd->issuerSnSeqSz = SetSequence(signerInfoSz, esd->issuerSnSeq);
-    signerInfoSz += esd->issuerSnSeqSz;
-    esd->signerVersionSz = SetMyVersion(1, esd->signerVersion, 0);
-    signerInfoSz += esd->signerVersionSz;
-    esd->signerDigAlgoIdSz = SetAlgoID(pkcs7->hashOID, esd->signerDigAlgoId,
-                                      hashType, 0);
-    signerInfoSz += esd->signerDigAlgoIdSz;
-    esd->digEncAlgoIdSz = SetAlgoID(pkcs7->encryptOID, esd->digEncAlgoId,
-                                   keyType, 0);
-    signerInfoSz += esd->digEncAlgoIdSz;
-
-    if (pkcs7->signedAttribsSz != 0) {
-        byte contentTypeOid[] =
-                { ASN_OBJECT_ID, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xF7, 0x0d, 0x01,
-                                 0x09, 0x03 };
-        byte contentType[] =
-                { ASN_OBJECT_ID, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
-                                 0x07, 0x01 };
-        byte messageDigestOid[] =
-                { ASN_OBJECT_ID, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
-                                 0x09, 0x04 };
-
-        PKCS7Attrib cannedAttribs[2] =
-        {
-            { contentTypeOid, sizeof(contentTypeOid),
-                             contentType, sizeof(contentType) },
-            { messageDigestOid, sizeof(messageDigestOid),
-                             esd->contentDigest, sizeof(esd->contentDigest) }
-        };
-        word32 cannedAttribsCount = sizeof(cannedAttribs)/sizeof(PKCS7Attrib);
-
-        esd->signedAttribsCount += cannedAttribsCount;
-        esd->signedAttribsSz += EncodeAttributes(&esd->signedAttribs[0], 2,
-                                             cannedAttribs, cannedAttribsCount);
-
-        esd->signedAttribsCount += pkcs7->signedAttribsSz;
-        esd->signedAttribsSz += EncodeAttributes(&esd->signedAttribs[2], 4,
-                                  pkcs7->signedAttribs, pkcs7->signedAttribsSz);
-
-        flatSignedAttribs = (byte*)XMALLOC(esd->signedAttribsSz, 0, NULL);
-        flatSignedAttribsSz = esd->signedAttribsSz;
-        if (flatSignedAttribs == NULL) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(esd, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif   
-            return MEMORY_E;
-        }
-        FlattenAttributes(flatSignedAttribs,
-                                   esd->signedAttribs, esd->signedAttribsCount);
-        esd->signedAttribSetSz = SetImplicit(ASN_SET, 0, esd->signedAttribsSz,
-                                                          esd->signedAttribSet);
-    }
-    /* Calculate the final hash and encrypt it. */
-    {
-        int result;
-        word32 scratch = 0;
-
-#ifdef WOLFSSL_SMALL_STACK
-        byte* digestInfo;
-        RsaKey* privKey;
-#else
-        RsaKey stack_privKey;
-        RsaKey* privKey = &stack_privKey;
-        byte digestInfo[MAX_SEQ_SZ + MAX_ALGO_SZ +
-                        MAX_OCTET_STR_SZ + SHA_DIGEST_SIZE];
-#endif
-        byte digestInfoSeq[MAX_SEQ_SZ];
-        byte digestStr[MAX_OCTET_STR_SZ];
-        word32 digestInfoSeqSz, digestStrSz;
-        int digIdx = 0;
-
-        if (pkcs7->signedAttribsSz != 0) {
-            byte attribSet[MAX_SET_SZ];
-            word32 attribSetSz;
-
-            attribSetSz = SetSet(flatSignedAttribsSz, attribSet);
-
-            ret = wc_InitSha(&esd->sha);
-            if (ret < 0) {
-                XFREE(flatSignedAttribs, 0, NULL);
-#ifdef WOLFSSL_SMALL_STACK
-                XFREE(esd, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-                return ret;
-            }
-            wc_ShaUpdate(&esd->sha, attribSet, attribSetSz);
-            wc_ShaUpdate(&esd->sha, flatSignedAttribs, flatSignedAttribsSz);
-        }
-        wc_ShaFinal(&esd->sha, esd->contentAttribsDigest);
-
-        digestStrSz = SetOctetString(SHA_DIGEST_SIZE, digestStr);
-        digestInfoSeqSz = SetSequence(esd->signerDigAlgoIdSz +
-                                      digestStrSz + SHA_DIGEST_SIZE,
-                                      digestInfoSeq);
-
-#ifdef WOLFSSL_SMALL_STACK
-        digestInfo = (byte*)XMALLOC(MAX_SEQ_SZ + MAX_ALGO_SZ +
-                                    MAX_OCTET_STR_SZ + SHA_DIGEST_SIZE,
-                                    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (digestInfo == NULL) {
-            if (pkcs7->signedAttribsSz != 0)
-                XFREE(flatSignedAttribs, 0, NULL);
-            XFREE(esd, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            return MEMORY_E;
-        }
-#endif
-
-        XMEMCPY(digestInfo + digIdx, digestInfoSeq, digestInfoSeqSz);
-        digIdx += digestInfoSeqSz;
-        XMEMCPY(digestInfo + digIdx,
-                                  esd->signerDigAlgoId, esd->signerDigAlgoIdSz);
-        digIdx += esd->signerDigAlgoIdSz;
-        XMEMCPY(digestInfo + digIdx, digestStr, digestStrSz);
-        digIdx += digestStrSz;
-        XMEMCPY(digestInfo + digIdx, esd->contentAttribsDigest,
-                                                               SHA_DIGEST_SIZE);
-        digIdx += SHA_DIGEST_SIZE;
-
-#ifdef WOLFSSL_SMALL_STACK
-        privKey = (RsaKey*)XMALLOC(sizeof(RsaKey), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-        if (privKey == NULL) {
-            if (pkcs7->signedAttribsSz != 0)
-                XFREE(flatSignedAttribs, 0, NULL);
-            XFREE(digestInfo, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(esd,        NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            return MEMORY_E;
-        }
-#endif
-
-        result = wc_InitRsaKey(privKey, NULL);
-        if (result == 0)
-            result = wc_RsaPrivateKeyDecode(pkcs7->privateKey, &scratch, privKey,
-                                         pkcs7->privateKeySz);
-        if (result < 0) {
-            if (pkcs7->signedAttribsSz != 0)
-                XFREE(flatSignedAttribs, 0, NULL);
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(privKey,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(digestInfo, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(esd,        NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return PUBLIC_KEY_E;
-        }
-
-        result = wc_RsaSSL_Sign(digestInfo, digIdx,
-                             esd->encContentDigest,
-                             sizeof(esd->encContentDigest),
-                             privKey, pkcs7->rng);
-
-        wc_FreeRsaKey(privKey);
-
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(privKey,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(digestInfo, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-        if (result < 0) {
-            if (pkcs7->signedAttribsSz != 0)
-                XFREE(flatSignedAttribs, 0, NULL);
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(esd, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return result;
-        }
-        esd->encContentDigestSz = (word32)result;
-    }
-    signerInfoSz += flatSignedAttribsSz + esd->signedAttribSetSz;
-
-    esd->signerDigestSz = SetOctetString(esd->encContentDigestSz,
-                                                             esd->signerDigest);
-    signerInfoSz += esd->signerDigestSz + esd->encContentDigestSz;
-
-    esd->signerInfoSeqSz = SetSequence(signerInfoSz, esd->signerInfoSeq);
-    signerInfoSz += esd->signerInfoSeqSz;
-    esd->signerInfoSetSz = SetSet(signerInfoSz, esd->signerInfoSet);
-    signerInfoSz += esd->signerInfoSetSz;
-
-    esd->certsSetSz = SetImplicit(ASN_SET, 0, pkcs7->singleCertSz,
-                                                                 esd->certsSet);
-
-    esd->singleDigAlgoIdSz = SetAlgoID(pkcs7->hashOID, esd->singleDigAlgoId,
-                                      hashType, 0);
-    esd->digAlgoIdSetSz = SetSet(esd->singleDigAlgoIdSz, esd->digAlgoIdSet);
-
-
-    esd->versionSz = SetMyVersion(1, esd->version, 0);
-
-    totalSz = esd->versionSz + esd->singleDigAlgoIdSz + esd->digAlgoIdSetSz +
-              esd->contentInfoSeqSz + esd->certsSetSz + pkcs7->singleCertSz +
-              esd->innerOctetsSz + esd->innerContSeqSz +
-              innerOidSz + pkcs7->contentSz +
-              signerInfoSz;
-    esd->innerSeqSz = SetSequence(totalSz, esd->innerSeq);
-    totalSz += esd->innerSeqSz;
-    esd->outerContentSz = SetExplicit(0, totalSz, esd->outerContent);
-    totalSz += esd->outerContentSz + outerOidSz;
-    esd->outerSeqSz = SetSequence(totalSz, esd->outerSeq);
-    totalSz += esd->outerSeqSz;
-
-    if (outputSz < totalSz) {
-        if (pkcs7->signedAttribsSz != 0)
-            XFREE(flatSignedAttribs, 0, NULL);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(esd, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return BUFFER_E;
-    }
-
-    idx = 0;
-    XMEMCPY(output + idx, esd->outerSeq, esd->outerSeqSz);
-    idx += esd->outerSeqSz;
-    XMEMCPY(output + idx, outerOid, outerOidSz);
-    idx += outerOidSz;
-    XMEMCPY(output + idx, esd->outerContent, esd->outerContentSz);
-    idx += esd->outerContentSz;
-    XMEMCPY(output + idx, esd->innerSeq, esd->innerSeqSz);
-    idx += esd->innerSeqSz;
-    XMEMCPY(output + idx, esd->version, esd->versionSz);
-    idx += esd->versionSz;
-    XMEMCPY(output + idx, esd->digAlgoIdSet, esd->digAlgoIdSetSz);
-    idx += esd->digAlgoIdSetSz;
-    XMEMCPY(output + idx, esd->singleDigAlgoId, esd->singleDigAlgoIdSz);
-    idx += esd->singleDigAlgoIdSz;
-    XMEMCPY(output + idx, esd->contentInfoSeq, esd->contentInfoSeqSz);
-    idx += esd->contentInfoSeqSz;
-    XMEMCPY(output + idx, innerOid, innerOidSz);
-    idx += innerOidSz;
-    XMEMCPY(output + idx, esd->innerContSeq, esd->innerContSeqSz);
-    idx += esd->innerContSeqSz;
-    XMEMCPY(output + idx, esd->innerOctets, esd->innerOctetsSz);
-    idx += esd->innerOctetsSz;
-    XMEMCPY(output + idx, pkcs7->content, pkcs7->contentSz);
-    idx += pkcs7->contentSz;
-    XMEMCPY(output + idx, esd->certsSet, esd->certsSetSz);
-    idx += esd->certsSetSz;
-    XMEMCPY(output + idx, pkcs7->singleCert, pkcs7->singleCertSz);
-    idx += pkcs7->singleCertSz;
-    XMEMCPY(output + idx, esd->signerInfoSet, esd->signerInfoSetSz);
-    idx += esd->signerInfoSetSz;
-    XMEMCPY(output + idx, esd->signerInfoSeq, esd->signerInfoSeqSz);
-    idx += esd->signerInfoSeqSz;
-    XMEMCPY(output + idx, esd->signerVersion, esd->signerVersionSz);
-    idx += esd->signerVersionSz;
-    XMEMCPY(output + idx, esd->issuerSnSeq, esd->issuerSnSeqSz);
-    idx += esd->issuerSnSeqSz;
-    XMEMCPY(output + idx, esd->issuerName, esd->issuerNameSz);
-    idx += esd->issuerNameSz;
-    XMEMCPY(output + idx, pkcs7->issuer, pkcs7->issuerSz);
-    idx += pkcs7->issuerSz;
-    XMEMCPY(output + idx, esd->issuerSn, esd->issuerSnSz);
-    idx += esd->issuerSnSz;
-    XMEMCPY(output + idx, esd->signerDigAlgoId, esd->signerDigAlgoIdSz);
-    idx += esd->signerDigAlgoIdSz;
-
-    /* SignerInfo:Attributes */
-    if (pkcs7->signedAttribsSz != 0) {
-        XMEMCPY(output + idx, esd->signedAttribSet, esd->signedAttribSetSz);
-        idx += esd->signedAttribSetSz;
-        XMEMCPY(output + idx, flatSignedAttribs, flatSignedAttribsSz);
-        idx += flatSignedAttribsSz;
-        XFREE(flatSignedAttribs, 0, NULL);
-    }
-
-    XMEMCPY(output + idx, esd->digEncAlgoId, esd->digEncAlgoIdSz);
-    idx += esd->digEncAlgoIdSz;
-    XMEMCPY(output + idx, esd->signerDigest, esd->signerDigestSz);
-    idx += esd->signerDigestSz;
-    XMEMCPY(output + idx, esd->encContentDigest, esd->encContentDigestSz);
-    idx += esd->encContentDigestSz;
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(esd, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return idx;
-}
-
-
-/* Finds the certificates in the message and saves it. */
-int wc_PKCS7_VerifySignedData(PKCS7* pkcs7, byte* pkiMsg, word32 pkiMsgSz)
-{
-    word32 idx, contentType;
-    int length, version, ret;
-    byte* content = NULL;
-    byte* sig = NULL;
-    byte* cert = NULL;
-    int contentSz = 0, sigSz = 0, certSz = 0;
-
-    if (pkcs7 == NULL || pkiMsg == NULL || pkiMsgSz == 0)
-        return BAD_FUNC_ARG;
-
-    idx = 0;
-
-    /* Get the contentInfo sequence */
-    if (GetSequence(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-
-    /* Get the contentInfo contentType */
-    if (wc_GetContentType(pkiMsg, &idx, &contentType, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-
-    if (contentType != SIGNED_DATA) {
-        WOLFSSL_MSG("PKCS#7 input not of type SignedData");
-        return PKCS7_OID_E;
-    }
-
-    /* get the ContentInfo content */
-    if (pkiMsg[idx++] != (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 0))
-        return ASN_PARSE_E;
-
-    if (GetLength(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-
-    /* Get the signedData sequence */
-    if (GetSequence(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-
-    /* Get the version */
-    if (GetMyVersion(pkiMsg, &idx, &version) < 0)
-        return ASN_PARSE_E;
-
-    if (version != 1) {
-        WOLFSSL_MSG("PKCS#7 signedData needs to be of version 1");
-        return ASN_VERSION_E;
-    }
-
-    /* Get the set of DigestAlgorithmIdentifiers */
-    if (GetSet(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-
-    /* Skip the set. */
-    idx += length;
-
-    /* Get the inner ContentInfo sequence */
-    if (GetSequence(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-
-    /* Get the inner ContentInfo contentType */
-    if (wc_GetContentType(pkiMsg, &idx, &contentType, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-
-    if (contentType != DATA) {
-        WOLFSSL_MSG("PKCS#7 inner input not of type Data");
-        return PKCS7_OID_E;
-    }
-
-    if (pkiMsg[idx++] != (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 0))
-        return ASN_PARSE_E;
-
-    if (GetLength(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-
-    if (pkiMsg[idx++] != ASN_OCTET_STRING)
-        return ASN_PARSE_E;
-
-    if (GetLength(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-
-    /* Save the inner data as the content. */
-    if (length > 0) {
-        /* Local pointer for calculating hashes later */
-        pkcs7->content = content = &pkiMsg[idx];
-        pkcs7->contentSz = contentSz = length;
-        idx += length;
-    }
-
-    /* Get the implicit[0] set of certificates */
-    if (pkiMsg[idx] == (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 0)) {
-        idx++;
-        if (GetLength(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-            return ASN_PARSE_E;
-
-        if (length > 0) {
-            /* At this point, idx is at the first certificate in
-             * a set of certificates. There may be more than one,
-             * or none, or they may be a PKCS 6 extended
-             * certificate. We want to save the first cert if it
-             * is X.509. */
-
-            word32 certIdx = idx;
-
-            if (pkiMsg[certIdx++] == (ASN_CONSTRUCTED | ASN_SEQUENCE)) {
-                if (GetLength(pkiMsg, &certIdx, &certSz, pkiMsgSz) < 0)
-                    return ASN_PARSE_E;
-
-                cert = &pkiMsg[idx];
-                certSz += (certIdx - idx);
-            }
-            wc_PKCS7_InitWithCert(pkcs7, cert, certSz);
-        }
-        idx += length;
-    }
-
-    /* Get the implicit[1] set of crls */
-    if (pkiMsg[idx] == (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 1)) {
-        idx++;
-        if (GetLength(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-            return ASN_PARSE_E;
-
-        /* Skip the set */
-        idx += length;
-    }
-
-    /* Get the set of signerInfos */
-    if (GetSet(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-
-    if (length > 0) {
-        /* Get the sequence of the first signerInfo */
-        if (GetSequence(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-            return ASN_PARSE_E;
-
-        /* Get the version */
-        if (GetMyVersion(pkiMsg, &idx, &version) < 0)
-            return ASN_PARSE_E;
-
-        if (version != 1) {
-            WOLFSSL_MSG("PKCS#7 signerInfo needs to be of version 1");
-            return ASN_VERSION_E;
-        }
-
-        /* Get the sequence of IssuerAndSerialNumber */
-        if (GetSequence(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-            return ASN_PARSE_E;
-
-        /* Skip it */
-        idx += length;
-
-        /* Get the sequence of digestAlgorithm */
-        if (GetSequence(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-            return ASN_PARSE_E;
-
-        /* Skip it */
-        idx += length;
-
-        /* Get the IMPLICIT[0] SET OF signedAttributes */
-        if (pkiMsg[idx] == (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 0)) {
-            idx++;
-
-            if (GetLength(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-                return ASN_PARSE_E;
-
-            idx += length;
-        }
-
-        /* Get the sequence of digestEncryptionAlgorithm */
-        if (GetSequence(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-            return ASN_PARSE_E;
-
-        /* Skip it */
-        idx += length;
-
-        /* Get the signature */
-        if (pkiMsg[idx] == ASN_OCTET_STRING) {
-            idx++;
-
-            if (GetLength(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-                return ASN_PARSE_E;
-
-            /* save pointer and length */
-            sig = &pkiMsg[idx];
-            sigSz = length;
-
-            idx += length;
-        }
-
-        pkcs7->content = content;
-        pkcs7->contentSz = contentSz;
-
-        {
-            word32 scratch = 0;
-            int plainSz = 0;
-            int digestSz = MAX_SEQ_SZ + MAX_ALGO_SZ +
-                           MAX_OCTET_STR_SZ + SHA_DIGEST_SIZE;
-
-#ifdef WOLFSSL_SMALL_STACK
-            byte* digest;
-            RsaKey* key;
-
-            digest = (byte*)XMALLOC(digestSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-            if (digest == NULL)
-                return MEMORY_E;
-
-            key = (RsaKey*)XMALLOC(sizeof(RsaKey), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-            if (key == NULL) {
-                XFREE(digest, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                return MEMORY_E;
-            }
-#else
-            byte digest[digestSz];
-            RsaKey stack_key;
-            RsaKey* key = &stack_key;
-#endif
-
-            XMEMSET(digest, 0, digestSz);
-
-            ret = wc_InitRsaKey(key, NULL);
-            if (ret != 0) {
-#ifdef WOLFSSL_SMALL_STACK
-                XFREE(digest, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                XFREE(key,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-                return ret;
-            }
-            if (wc_RsaPublicKeyDecode(pkcs7->publicKey, &scratch, key,
-                                   pkcs7->publicKeySz) < 0) {
-                WOLFSSL_MSG("ASN RSA key decode error");
-#ifdef WOLFSSL_SMALL_STACK
-                XFREE(digest, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-                XFREE(key,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-                return PUBLIC_KEY_E;
-            }
-
-            plainSz = wc_RsaSSL_Verify(sig, sigSz, digest, digestSz, key);
-            wc_FreeRsaKey(key);
-
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(digest, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(key,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-            if (plainSz < 0)
-                return plainSz;
-        }
-    }
-
-    return 0;
-}
-
-
-/* create ASN.1 fomatted RecipientInfo structure, returns sequence size */
-WOLFSSL_LOCAL int wc_CreateRecipientInfo(const byte* cert, word32 certSz,
-                                     int keyEncAlgo, int blockKeySz,
-                                     RNG* rng, byte* contentKeyPlain,
-                                     byte* contentKeyEnc,
-                                     int* keyEncSz, byte* out, word32 outSz)
-{
-    word32 idx = 0;
-    int ret = 0, totalSz = 0;
-    int verSz, issuerSz, snSz, keyEncAlgSz;
-    int issuerSeqSz, recipSeqSz, issuerSerialSeqSz;
-    int encKeyOctetStrSz;
-
-    byte ver[MAX_VERSION_SZ];
-    byte issuerSerialSeq[MAX_SEQ_SZ];
-    byte recipSeq[MAX_SEQ_SZ];
-    byte issuerSeq[MAX_SEQ_SZ];
-    byte encKeyOctetStr[MAX_OCTET_STR_SZ];
-
-#ifdef WOLFSSL_SMALL_STACK
-    byte *serial;
-    byte *keyAlgArray;
-    
-    RsaKey* pubKey;
-    DecodedCert* decoded;
-
-    serial = (byte*)XMALLOC(MAX_SN_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    keyAlgArray = (byte*)XMALLOC(MAX_SN_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    decoded = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-
-    if (decoded == NULL || serial == NULL || keyAlgArray == NULL) {
-        if (serial)      XFREE(serial,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (keyAlgArray) XFREE(keyAlgArray, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (decoded)     XFREE(decoded,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-    
-#else
-    byte serial[MAX_SN_SZ];
-    byte keyAlgArray[MAX_ALGO_SZ];
-    
-    RsaKey stack_pubKey;
-    RsaKey* pubKey = &stack_pubKey;
-    DecodedCert stack_decoded;
-    DecodedCert* decoded = &stack_decoded;
-#endif
-
-    InitDecodedCert(decoded, (byte*)cert, certSz, 0);
-    ret = ParseCert(decoded, CA_TYPE, NO_VERIFY, 0);
-    if (ret < 0) {
-        FreeDecodedCert(decoded);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(serial,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(keyAlgArray, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(decoded,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ret;
-    }
-
-    /* version */
-    verSz = SetMyVersion(0, ver, 0);
-
-    /* IssuerAndSerialNumber */
-    if (decoded->issuerRaw == NULL || decoded->issuerRawLen == 0) {
-        WOLFSSL_MSG("DecodedCert lacks raw issuer pointer and length");
-        FreeDecodedCert(decoded);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(serial,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(keyAlgArray, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(decoded,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return -1;
-    }
-    issuerSz    = decoded->issuerRawLen;
-    issuerSeqSz = SetSequence(issuerSz, issuerSeq);
-
-    if (decoded->serialSz == 0) {
-        WOLFSSL_MSG("DecodedCert missing serial number");
-        FreeDecodedCert(decoded);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(serial,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(keyAlgArray, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(decoded,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return -1;
-    }
-    snSz = SetSerialNumber(decoded->serial, decoded->serialSz, serial);
-
-    issuerSerialSeqSz = SetSequence(issuerSeqSz + issuerSz + snSz,
-                                    issuerSerialSeq);
-
-    /* KeyEncryptionAlgorithmIdentifier, only support RSA now */
-    if (keyEncAlgo != RSAk) {
-        FreeDecodedCert(decoded);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(serial,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(keyAlgArray, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(decoded,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ALGO_ID_E;
-    }
-
-    keyEncAlgSz = SetAlgoID(keyEncAlgo, keyAlgArray, keyType, 0);
-    if (keyEncAlgSz == 0) {
-        FreeDecodedCert(decoded);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(serial,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(keyAlgArray, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(decoded,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return BAD_FUNC_ARG;
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    pubKey = (RsaKey*)XMALLOC(sizeof(RsaKey), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (pubKey == NULL) {
-        FreeDecodedCert(decoded);
-        XFREE(serial,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(keyAlgArray, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(decoded,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#endif
-
-    /* EncryptedKey */
-    ret = wc_InitRsaKey(pubKey, 0);
-    if (ret != 0) {
-        FreeDecodedCert(decoded);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(pubKey,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(serial,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(keyAlgArray, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(decoded,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ret;
-    }
-
-    if (wc_RsaPublicKeyDecode(decoded->publicKey, &idx, pubKey,
-                           decoded->pubKeySize) < 0) {
-        WOLFSSL_MSG("ASN RSA key decode error");
-        wc_FreeRsaKey(pubKey);
-        FreeDecodedCert(decoded);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(pubKey,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(serial,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(keyAlgArray, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(decoded,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return PUBLIC_KEY_E;
-    }
-
-    *keyEncSz = wc_RsaPublicEncrypt(contentKeyPlain, blockKeySz, contentKeyEnc,
-                                 MAX_ENCRYPTED_KEY_SZ, pubKey, rng);
-    wc_FreeRsaKey(pubKey);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(pubKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    if (*keyEncSz < 0) {
-        WOLFSSL_MSG("RSA Public Encrypt failed");
-        FreeDecodedCert(decoded);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(serial,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(keyAlgArray, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(decoded,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return *keyEncSz;
-    }
-
-    encKeyOctetStrSz = SetOctetString(*keyEncSz, encKeyOctetStr);
-
-    /* RecipientInfo */
-    recipSeqSz = SetSequence(verSz + issuerSerialSeqSz + issuerSeqSz +
-                             issuerSz + snSz + keyEncAlgSz + encKeyOctetStrSz +
-                             *keyEncSz, recipSeq);
-
-    if (recipSeqSz + verSz + issuerSerialSeqSz + issuerSeqSz + snSz +
-        keyEncAlgSz + encKeyOctetStrSz + *keyEncSz > (int)outSz) {
-        WOLFSSL_MSG("RecipientInfo output buffer too small");
-        FreeDecodedCert(decoded);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(serial,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(keyAlgArray, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(decoded,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return BUFFER_E;
-    }
-
-    XMEMCPY(out + totalSz, recipSeq, recipSeqSz);
-    totalSz += recipSeqSz;
-    XMEMCPY(out + totalSz, ver, verSz);
-    totalSz += verSz;
-    XMEMCPY(out + totalSz, issuerSerialSeq, issuerSerialSeqSz);
-    totalSz += issuerSerialSeqSz;
-    XMEMCPY(out + totalSz, issuerSeq, issuerSeqSz);
-    totalSz += issuerSeqSz;
-    XMEMCPY(out + totalSz, decoded->issuerRaw, issuerSz);
-    totalSz += issuerSz;
-    XMEMCPY(out + totalSz, serial, snSz);
-    totalSz += snSz;
-    XMEMCPY(out + totalSz, keyAlgArray, keyEncAlgSz);
-    totalSz += keyEncAlgSz;
-    XMEMCPY(out + totalSz, encKeyOctetStr, encKeyOctetStrSz);
-    totalSz += encKeyOctetStrSz;
-    XMEMCPY(out + totalSz, contentKeyEnc, *keyEncSz);
-    totalSz += *keyEncSz;
-
-    FreeDecodedCert(decoded);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(serial,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(keyAlgArray, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(decoded,     NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return totalSz;
-}
-
-
-/* build PKCS#7 envelopedData content type, return enveloped size */
-int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7, byte* output, word32 outputSz)
-{
-    int i, ret = 0, idx = 0;
-    int totalSz = 0, padSz = 0, desOutSz = 0;
-
-    int contentInfoSeqSz, outerContentTypeSz, outerContentSz;
-    byte contentInfoSeq[MAX_SEQ_SZ];
-    byte outerContentType[MAX_ALGO_SZ];
-    byte outerContent[MAX_SEQ_SZ];
-
-    int envDataSeqSz, verSz;
-    byte envDataSeq[MAX_SEQ_SZ];
-    byte ver[MAX_VERSION_SZ];
-
-    RNG rng;
-    int contentKeyEncSz, blockKeySz;
-    int dynamicFlag = 0;
-    byte contentKeyPlain[MAX_CONTENT_KEY_LEN];
-#ifdef WOLFSSL_SMALL_STACK
-    byte* contentKeyEnc;
-#else
-    byte contentKeyEnc[MAX_ENCRYPTED_KEY_SZ];
-#endif
-    byte* plain;
-    byte* encryptedContent;
-
-    int recipSz, recipSetSz;
-#ifdef WOLFSSL_SMALL_STACK
-    byte* recip;
-#else
-    byte recip[MAX_RECIP_SZ];
-#endif
-    byte recipSet[MAX_SET_SZ];
-
-    int encContentOctetSz, encContentSeqSz, contentTypeSz;
-    int contentEncAlgoSz, ivOctetStringSz;
-    byte encContentSeq[MAX_SEQ_SZ];
-    byte contentType[MAX_ALGO_SZ];
-    byte contentEncAlgo[MAX_ALGO_SZ];
-    byte tmpIv[DES_BLOCK_SIZE];
-    byte ivOctetString[MAX_OCTET_STR_SZ];
-    byte encContentOctet[MAX_OCTET_STR_SZ];
-
-    if (pkcs7 == NULL || pkcs7->content == NULL || pkcs7->contentSz == 0 ||
-        pkcs7->encryptOID == 0 || pkcs7->singleCert == NULL)
-        return BAD_FUNC_ARG;
-
-    if (output == NULL || outputSz == 0)
-        return BAD_FUNC_ARG;
-
-    /* PKCS#7 only supports DES, 3DES for now */
-    switch (pkcs7->encryptOID) {
-        case DESb:
-            blockKeySz = DES_KEYLEN;
-            break;
-
-        case DES3b:
-            blockKeySz = DES3_KEYLEN;
-            break;
-
-        default:
-            WOLFSSL_MSG("Unsupported content cipher type");
-            return ALGO_ID_E;
-    };
-
-    /* outer content type */
-    outerContentTypeSz = wc_SetContentType(ENVELOPED_DATA, outerContentType);
-
-    /* version, defined as 0 in RFC 2315 */
-    verSz = SetMyVersion(0, ver, 0);
-
-    /* generate random content encryption key */
-    ret = wc_InitRng(&rng);
-    if (ret != 0)
-        return ret;
-
-    ret = wc_RNG_GenerateBlock(&rng, contentKeyPlain, blockKeySz);
-    if (ret != 0) {
-        wc_FreeRng(&rng);
-        return ret;
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    recip         = (byte*)XMALLOC(MAX_RECIP_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    contentKeyEnc = (byte*)XMALLOC(MAX_ENCRYPTED_KEY_SZ, NULL, 
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (contentKeyEnc == NULL || recip == NULL) {
-        if (recip)         XFREE(recip,         NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (contentKeyEnc) XFREE(contentKeyEnc, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        wc_FreeRng(&rng);
-        return MEMORY_E;
-    }
-    
-#endif
-
-    /* build RecipientInfo, only handle 1 for now */
-    recipSz = wc_CreateRecipientInfo(pkcs7->singleCert, pkcs7->singleCertSz, RSAk,
-                                  blockKeySz, &rng, contentKeyPlain,
-                                  contentKeyEnc, &contentKeyEncSz, recip,
-                                  MAX_RECIP_SZ);
-                                                                      
-    ForceZero(contentKeyEnc, MAX_ENCRYPTED_KEY_SZ);
-    
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(contentKeyEnc, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    if (recipSz < 0) {
-        WOLFSSL_MSG("Failed to create RecipientInfo");
-        wc_FreeRng(&rng);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(recip, NULL, DYNAMMIC_TYPE_TMP_BUFFER);
-#endif
-        return recipSz;
-    }
-    recipSetSz = SetSet(recipSz, recipSet);
-
-    /* generate IV for block cipher */
-    ret = wc_RNG_GenerateBlock(&rng, tmpIv, DES_BLOCK_SIZE);
-    wc_FreeRng(&rng);
-    if (ret != 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(recip, NULL, DYNAMMIC_TYPE_TMP_BUFFER);
-#endif
-        return ret;
-    }
-
-    /* EncryptedContentInfo */
-    contentTypeSz = wc_SetContentType(pkcs7->contentOID, contentType);
-    if (contentTypeSz == 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(recip, NULL, DYNAMMIC_TYPE_TMP_BUFFER);
-#endif
-        return BAD_FUNC_ARG;
-    }
-
-    /* allocate encrypted content buffer, pad if necessary, PKCS#7 padding */
-    padSz = DES_BLOCK_SIZE - (pkcs7->contentSz % DES_BLOCK_SIZE);
-    desOutSz = pkcs7->contentSz + padSz;
-
-    if (padSz != 0) {
-        plain = (byte*)XMALLOC(desOutSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (plain == NULL) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(recip, NULL, DYNAMMIC_TYPE_TMP_BUFFER);
-#endif
-            return MEMORY_E;
-        }
-        XMEMCPY(plain, pkcs7->content, pkcs7->contentSz);
-        dynamicFlag = 1;
-
-        for (i = 0; i < padSz; i++) {
-            plain[pkcs7->contentSz + i] = padSz;
-        }
-
-    } else {
-        plain = pkcs7->content;
-        desOutSz = pkcs7->contentSz;
-    }
-
-    encryptedContent = (byte*)XMALLOC(desOutSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (encryptedContent == NULL) {
-        if (dynamicFlag)
-            XFREE(plain, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(recip, NULL, DYNAMMIC_TYPE_TMP_BUFFER);
-#endif
-        return MEMORY_E;
-    }
-
-    /* put together IV OCTET STRING */
-    ivOctetStringSz = SetOctetString(DES_BLOCK_SIZE, ivOctetString);
-
-    /* build up our ContentEncryptionAlgorithmIdentifier sequence,
-     * adding (ivOctetStringSz + DES_BLOCK_SIZE) for IV OCTET STRING */
-    contentEncAlgoSz = SetAlgoID(pkcs7->encryptOID, contentEncAlgo,
-                                 blkType, ivOctetStringSz + DES_BLOCK_SIZE);
-
-    if (contentEncAlgoSz == 0) {
-        XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (dynamicFlag)
-            XFREE(plain, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(recip, NULL, DYNAMMIC_TYPE_TMP_BUFFER);
-#endif
-        return BAD_FUNC_ARG;
-    }
-
-    /* encrypt content */
-    if (pkcs7->encryptOID == DESb) {
-        Des des;
-
-        ret = wc_Des_SetKey(&des, contentKeyPlain, tmpIv, DES_ENCRYPTION);
-
-        if (ret == 0)
-            wc_Des_CbcEncrypt(&des, encryptedContent, plain, desOutSz);
-
-        if (ret != 0) {
-            XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            if (dynamicFlag)
-                XFREE(plain, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(recip, NULL, DYNAMMIC_TYPE_TMP_BUFFER);
-#endif
-            return ret;
-        }
-    }
-    else if (pkcs7->encryptOID == DES3b) {
-        Des3 des3;
-
-        ret = wc_Des3_SetKey(&des3, contentKeyPlain, tmpIv, DES_ENCRYPTION);
-
-        if (ret == 0)
-            ret = wc_Des3_CbcEncrypt(&des3, encryptedContent, plain, desOutSz);
-
-        if (ret != 0) {
-            XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            if (dynamicFlag)
-                XFREE(plain, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(recip, NULL, DYNAMMIC_TYPE_TMP_BUFFER);
-#endif
-            return ret;
-        }
-    }
-
-    encContentOctetSz = SetImplicit(ASN_OCTET_STRING, 0,
-                                    desOutSz, encContentOctet);
-
-    encContentSeqSz = SetSequence(contentTypeSz + contentEncAlgoSz +
-                                  ivOctetStringSz + DES_BLOCK_SIZE +
-                                  encContentOctetSz + desOutSz, encContentSeq);
-
-    /* keep track of sizes for outer wrapper layering */
-    totalSz = verSz + recipSetSz + recipSz + encContentSeqSz + contentTypeSz +
-              contentEncAlgoSz + ivOctetStringSz + DES_BLOCK_SIZE +
-              encContentOctetSz + desOutSz;
-
-    /* EnvelopedData */
-    envDataSeqSz = SetSequence(totalSz, envDataSeq);
-    totalSz += envDataSeqSz;
-
-    /* outer content */
-    outerContentSz = SetExplicit(0, totalSz, outerContent);
-    totalSz += outerContentTypeSz;
-    totalSz += outerContentSz;
-
-    /* ContentInfo */
-    contentInfoSeqSz = SetSequence(totalSz, contentInfoSeq);
-    totalSz += contentInfoSeqSz;
-
-    if (totalSz > (int)outputSz) {
-        WOLFSSL_MSG("Pkcs7_encrypt output buffer too small");
-        XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (dynamicFlag)
-            XFREE(plain, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(recip, NULL, DYNAMMIC_TYPE_TMP_BUFFER);
-#endif
-        return BUFFER_E;
-    }
-
-    XMEMCPY(output + idx, contentInfoSeq, contentInfoSeqSz);
-    idx += contentInfoSeqSz;
-    XMEMCPY(output + idx, outerContentType, outerContentTypeSz);
-    idx += outerContentTypeSz;
-    XMEMCPY(output + idx, outerContent, outerContentSz);
-    idx += outerContentSz;
-    XMEMCPY(output + idx, envDataSeq, envDataSeqSz);
-    idx += envDataSeqSz;
-    XMEMCPY(output + idx, ver, verSz);
-    idx += verSz;
-    XMEMCPY(output + idx, recipSet, recipSetSz);
-    idx += recipSetSz;
-    XMEMCPY(output + idx, recip, recipSz);
-    idx += recipSz;
-    XMEMCPY(output + idx, encContentSeq, encContentSeqSz);
-    idx += encContentSeqSz;
-    XMEMCPY(output + idx, contentType, contentTypeSz);
-    idx += contentTypeSz;
-    XMEMCPY(output + idx, contentEncAlgo, contentEncAlgoSz);
-    idx += contentEncAlgoSz;
-    XMEMCPY(output + idx, ivOctetString, ivOctetStringSz);
-    idx += ivOctetStringSz;
-    XMEMCPY(output + idx, tmpIv, DES_BLOCK_SIZE);
-    idx += DES_BLOCK_SIZE;
-    XMEMCPY(output + idx, encContentOctet, encContentOctetSz);
-    idx += encContentOctetSz;
-    XMEMCPY(output + idx, encryptedContent, desOutSz);
-    idx += desOutSz;
-
-    ForceZero(contentKeyPlain, MAX_CONTENT_KEY_LEN);
-
-    if (dynamicFlag)
-        XFREE(plain, NULL, DYNAMMIC_TYPE_TMP_BUFFER);
-    XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(recip, NULL, DYNAMMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return idx;
-}
-
-/* unwrap and decrypt PKCS#7 envelopedData object, return decoded size */
-WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* pkiMsg,
-                                         word32 pkiMsgSz, byte* output,
-                                         word32 outputSz)
-{
-    int recipFound = 0;
-    int ret, version, length;
-    word32 savedIdx = 0, idx = 0;
-    word32 contentType, encOID;
-    byte   issuerHash[SHA_DIGEST_SIZE];
-
-    int encryptedKeySz, keySz;
-    byte tmpIv[DES_BLOCK_SIZE];
-    byte* decryptedKey = NULL;
-
-#ifdef WOLFSSL_SMALL_STACK
-    mp_int* serialNum;
-    byte* encryptedKey;
-    RsaKey* privKey;
-#else
-    mp_int stack_serialNum;
-    mp_int* serialNum = &stack_serialNum;
-    byte encryptedKey[MAX_ENCRYPTED_KEY_SZ];
-    
-    RsaKey stack_privKey;
-    RsaKey* privKey = &stack_privKey;
-#endif
-    int encryptedContentSz;
-    byte padLen;
-    byte* encryptedContent = NULL;
-
-    if (pkcs7 == NULL || pkcs7->singleCert == NULL ||
-        pkcs7->singleCertSz == 0 || pkcs7->privateKey == NULL ||
-        pkcs7->privateKeySz == 0)
-        return BAD_FUNC_ARG;
-
-    if (pkiMsg == NULL || pkiMsgSz == 0 ||
-        output == NULL || outputSz == 0)
-        return BAD_FUNC_ARG;
-
-    /* read past ContentInfo, verify type is envelopedData */
-    if (GetSequence(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-
-    if (wc_GetContentType(pkiMsg, &idx, &contentType, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-
-    if (contentType != ENVELOPED_DATA) {
-        WOLFSSL_MSG("PKCS#7 input not of type EnvelopedData");
-        return PKCS7_OID_E;
-    }
-
-    if (pkiMsg[idx++] != (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 0))
-        return ASN_PARSE_E;
-
-    if (GetLength(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-
-    /* remove EnvelopedData and version */
-    if (GetSequence(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-
-    if (GetMyVersion(pkiMsg, &idx, &version) < 0)
-        return ASN_PARSE_E;
-
-    if (version != 0) {
-        WOLFSSL_MSG("PKCS#7 envelopedData needs to be of version 0");
-        return ASN_VERSION_E;
-    }
-
-    /* walk through RecipientInfo set, find correct recipient */
-    if (GetSet(pkiMsg, &idx, &length, pkiMsgSz) < 0)
-        return ASN_PARSE_E;
-    
-#ifdef WOLFSSL_SMALL_STACK
-    encryptedKey = (byte*)XMALLOC(MAX_ENCRYPTED_KEY_SZ, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (encryptedKey == NULL)
-        return MEMORY_E;
-#endif
-    
-    savedIdx = idx;
-    recipFound = 0;
-
-    /* when looking for next recipient, use first sequence and version to
-     * indicate there is another, if not, move on */
-    while(recipFound == 0) {
-
-        /* remove RecipientInfo, if we don't have a SEQUENCE, back up idx to
-         * last good saved one */
-        if (GetSequence(pkiMsg, &idx, &length, pkiMsgSz) < 0) {
-            idx = savedIdx;
-            break;
-        }
-
-        if (GetMyVersion(pkiMsg, &idx, &version) < 0) {
-            idx = savedIdx;
-            break;
-        }
-
-        if (version != 0) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ASN_VERSION_E;
-        }
-        
-        /* remove IssuerAndSerialNumber */
-        if (GetSequence(pkiMsg, &idx, &length, pkiMsgSz) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ASN_PARSE_E;
-        }
-        
-        if (GetNameHash(pkiMsg, &idx, issuerHash, pkiMsgSz) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ASN_PARSE_E;
-        }
-        
-        /* if we found correct recipient, issuer hashes will match */
-        if (XMEMCMP(issuerHash, pkcs7->issuerHash, SHA_DIGEST_SIZE) == 0) {
-            recipFound = 1;
-        }
-        
-#ifdef WOLFSSL_SMALL_STACK
-        serialNum = (mp_int*)XMALLOC(sizeof(mp_int), NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-        if (serialNum == NULL) {
-            XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            return MEMORY_E;
-        }
-#endif
-        
-        if (GetInt(serialNum, pkiMsg, &idx, pkiMsgSz) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(serialNum,    NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ASN_PARSE_E;
-        }
-        
-        mp_clear(serialNum);
-        
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(serialNum, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        
-        if (GetAlgoId(pkiMsg, &idx, &encOID, pkiMsgSz) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ASN_PARSE_E;
-        }
-        
-        /* key encryption algorithm must be RSA for now */
-        if (encOID != RSAk) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ALGO_ID_E;
-        }
-        
-        /* read encryptedKey */
-        if (pkiMsg[idx++] != ASN_OCTET_STRING) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ASN_PARSE_E;
-        }
-        
-        if (GetLength(pkiMsg, &idx, &encryptedKeySz, pkiMsgSz) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ASN_PARSE_E;
-        }
-          
-        if (recipFound == 1)
-            XMEMCPY(encryptedKey, &pkiMsg[idx], encryptedKeySz);
-        idx += encryptedKeySz;
-
-        /* update good idx */
-        savedIdx = idx;
-    }
-
-    if (recipFound == 0) {
-        WOLFSSL_MSG("No recipient found in envelopedData that matches input");
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return PKCS7_RECIP_E;
-    }
-
-    /* remove EncryptedContentInfo */
-    if (GetSequence(pkiMsg, &idx, &length, pkiMsgSz) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ASN_PARSE_E;
-    }
-    
-    if (wc_GetContentType(pkiMsg, &idx, &contentType, pkiMsgSz) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ASN_PARSE_E;
-    }
-
-    if (GetAlgoId(pkiMsg, &idx, &encOID, pkiMsgSz) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ASN_PARSE_E;
-    }
-    
-    /* get block cipher IV, stored in OPTIONAL parameter of AlgoID */
-    if (pkiMsg[idx++] != ASN_OCTET_STRING) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ASN_PARSE_E;
-    }
-    
-    if (GetLength(pkiMsg, &idx, &length, pkiMsgSz) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ASN_PARSE_E;
-    }
-    
-    if (length != DES_BLOCK_SIZE) {
-        WOLFSSL_MSG("Incorrect IV length, must be of DES_BLOCK_SIZE");
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ASN_PARSE_E;
-    }
-
-    XMEMCPY(tmpIv, &pkiMsg[idx], length);
-    idx += length;
-
-    /* read encryptedContent, cont[0] */
-    if (pkiMsg[idx++] != (ASN_CONTEXT_SPECIFIC | 0)) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ASN_PARSE_E;
-    }
-
-    if (GetLength(pkiMsg, &idx, &encryptedContentSz, pkiMsgSz) < 0) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ASN_PARSE_E;
-    }
-    
-    encryptedContent = (byte*)XMALLOC(encryptedContentSz, NULL,
-                                                       DYNAMIC_TYPE_TMP_BUFFER);
-    if (encryptedContent == NULL) {
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return MEMORY_E;
-    }
-
-    XMEMCPY(encryptedContent, &pkiMsg[idx], encryptedContentSz);
-
-    /* load private key */
-#ifdef WOLFSSL_SMALL_STACK
-    privKey = (RsaKey*)XMALLOC(sizeof(RsaKey), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (privKey == NULL) {
-        XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(encryptedKey,     NULL, DYNAMIC_TYPE_TMP_BUFFER);        return MEMORY_E;
-    }
-#endif
-
-    ret = wc_InitRsaKey(privKey, 0);
-    if (ret != 0) {
-        XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(privKey,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ret;
-    }
-
-    idx = 0;
-
-    ret = wc_RsaPrivateKeyDecode(pkcs7->privateKey, &idx, privKey,
-                              pkcs7->privateKeySz);
-    if (ret != 0) {
-        WOLFSSL_MSG("Failed to decode RSA private key");
-        XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(privKey,      NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ret;
-    }
-
-    /* decrypt encryptedKey */
-    keySz = wc_RsaPrivateDecryptInline(encryptedKey, encryptedKeySz,
-                                    &decryptedKey, privKey);
-    wc_FreeRsaKey(privKey);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(privKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    if (keySz <= 0) {
-        XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return keySz;
-    }
-
-    /* decrypt encryptedContent */
-    if (encOID == DESb) {
-        Des des;
-        ret = wc_Des_SetKey(&des, decryptedKey, tmpIv, DES_DECRYPTION);
-
-        if (ret == 0)
-            wc_Des_CbcDecrypt(&des, encryptedContent, encryptedContent,
-                                 encryptedContentSz);
-
-        if (ret != 0) {
-            XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ret;
-        }
-    }
-    else if (encOID == DES3b) {
-        Des3 des;
-        ret = wc_Des3_SetKey(&des, decryptedKey, tmpIv, DES_DECRYPTION);
-        if (ret == 0)
-            ret = wc_Des3_CbcDecrypt(&des, encryptedContent, encryptedContent,
-                                  encryptedContentSz);
-
-        if (ret != 0) {
-            XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return ret;
-        }
-    } else {
-        WOLFSSL_MSG("Unsupported content encryption OID type");
-        XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#ifdef WOLFSSL_SMALL_STACK
-        XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-        return ALGO_ID_E;
-    }
-
-    padLen = encryptedContent[encryptedContentSz-1];
-
-    /* copy plaintext to output */
-    XMEMCPY(output, encryptedContent, encryptedContentSz - padLen);
-
-    /* free memory, zero out keys */
-    ForceZero(encryptedKey, MAX_ENCRYPTED_KEY_SZ);
-    ForceZero(encryptedContent, encryptedContentSz);
-    XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(encryptedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-    
-    return encryptedContentSz - padLen;
-}
-
-
-#else  /* HAVE_PKCS7 */
-
-
-#ifdef _MSC_VER
-    /* 4206 warning for blank file */
-    #pragma warning(disable: 4206)
-#endif
-
-
-#endif /* HAVE_PKCS7 */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/poly1305.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/poly1305.c
deleted file mode 100755
index 3cc86e1..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/poly1305.c
+++ /dev/null
@@ -1,554 +0,0 @@
-/* poly1305.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- *
- * Based off the public domain implementations by Andrew Moon 
- * and Daniel J. Bernstein
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef HAVE_POLY1305
-#include 
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-#ifdef CHACHA_AEAD_TEST
-    #include 
-#endif
-
-#ifdef _MSC_VER
-    /* 4127 warning constant while(1)  */
-    #pragma warning(disable: 4127)
-#endif
-
-#if defined(POLY130564)
-	
-	#if defined(_MSC_VER)
-		#define POLY1305_NOINLINE __declspec(noinline)
-	#elif defined(__GNUC__)
-		#define POLY1305_NOINLINE __attribute__((noinline))
-	#else
-		#define POLY1305_NOINLINE
-	#endif
-	
-	#if defined(_MSC_VER)
-	    #include 
-		
-	    typedef struct word128 {
-			word64 lo;
-			word64 hi;
-		} word128;
-	
-		#define MUL(out, x, y) out.lo = _umul128((x), (y), &out.hi)
-		#define ADD(out, in) { word64 t = out.lo; out.lo += in.lo;
-	                           out.hi += (out.lo < t) + in.hi; }
-		#define ADDLO(out, in) { word64 t = out.lo; out.lo += in;
-	                             out.hi += (out.lo < t); }
-		#define SHR(in, shift) (__shiftright128(in.lo, in.hi, (shift)))
-		#define LO(in) (in.lo)
-	
-	#elif defined(__GNUC__)
-		#if defined(__SIZEOF_INT128__)
-			typedef unsigned __int128 word128;
-		#else
-			typedef unsigned word128 __attribute__((mode(TI)));
-		#endif
-	
-		#define MUL(out, x, y) out = ((word128)x * y)
-		#define ADD(out, in) out += in
-		#define ADDLO(out, in) out += in
-		#define SHR(in, shift) (word64)(in >> (shift))
-		#define LO(in) (word64)(in)
-	#endif
-	
-	static word64 U8TO64(const byte* p) {
-		return
-			(((word64)(p[0] & 0xff)      ) |
-		     ((word64)(p[1] & 0xff) <<  8) |
-	         ((word64)(p[2] & 0xff) << 16) |
-	         ((word64)(p[3] & 0xff) << 24) |
-			 ((word64)(p[4] & 0xff) << 32) |
-			 ((word64)(p[5] & 0xff) << 40) |
-			 ((word64)(p[6] & 0xff) << 48) |
-			 ((word64)(p[7] & 0xff) << 56));
-	}
-	
-	static void U64TO8(byte* p, word64 v) {
-		p[0] = (v      ) & 0xff;
-		p[1] = (v >>  8) & 0xff;
-		p[2] = (v >> 16) & 0xff;
-		p[3] = (v >> 24) & 0xff;
-		p[4] = (v >> 32) & 0xff;
-		p[5] = (v >> 40) & 0xff;
-		p[6] = (v >> 48) & 0xff;
-		p[7] = (v >> 56) & 0xff;
-	}
-
-#else /* if not 64 bit then use 32 bit */
-	
-	static word32 U8TO32(const byte *p) {
-		return
-			(((word32)(p[0] & 0xff)      ) |
-		     ((word32)(p[1] & 0xff) <<  8) |
-	         ((word32)(p[2] & 0xff) << 16) |
-	         ((word32)(p[3] & 0xff) << 24));
-	}
-	
-	static void U32TO8(byte *p, word32 v) {
-		p[0] = (v      ) & 0xff;
-		p[1] = (v >>  8) & 0xff;
-		p[2] = (v >> 16) & 0xff;
-		p[3] = (v >> 24) & 0xff;
-	}
-#endif
-
-static void poly1305_blocks(Poly1305* ctx, const unsigned char *m,
-                            size_t bytes) {
-
-#ifdef POLY130564
-
-	const word64 hibit = (ctx->final) ? 0 : ((word64)1 << 40); /* 1 << 128 */
-	word64 r0,r1,r2;
-	word64 s1,s2;
-	word64 h0,h1,h2;
-	word64 c;
-	word128 d0,d1,d2,d;
-
-#else
-
-    const word32 hibit = (ctx->final) ? 0 : (1 << 24); /* 1 << 128 */
-	word32 r0,r1,r2,r3,r4;
-	word32 s1,s2,s3,s4;
-	word32 h0,h1,h2,h3,h4;
-	word64 d0,d1,d2,d3,d4;
-	word32 c;
-
-#endif
-
-#ifdef POLY130564
-
-    r0 = ctx->r[0];
-	r1 = ctx->r[1];
-	r2 = ctx->r[2];
-
-	h0 = ctx->h[0];
-	h1 = ctx->h[1];
-	h2 = ctx->h[2];
-
-	s1 = r1 * (5 << 2);
-	s2 = r2 * (5 << 2);
-
-	while (bytes >= POLY1305_BLOCK_SIZE) {
-		word64 t0,t1;
-
-		/* h += m[i] */
-		t0 = U8TO64(&m[0]);
-		t1 = U8TO64(&m[8]);
-
-		h0 += (( t0                    ) & 0xfffffffffff);
-		h1 += (((t0 >> 44) | (t1 << 20)) & 0xfffffffffff);
-		h2 += (((t1 >> 24)             ) & 0x3ffffffffff) | hibit;
-
-		/* h *= r */
-		MUL(d0, h0, r0); MUL(d, h1, s2); ADD(d0, d); MUL(d, h2, s1); ADD(d0, d);
-		MUL(d1, h0, r1); MUL(d, h1, r0); ADD(d1, d); MUL(d, h2, s2); ADD(d1, d);
-		MUL(d2, h0, r2); MUL(d, h1, r1); ADD(d2, d); MUL(d, h2, r0); ADD(d2, d);
-
-		/* (partial) h %= p */
-		              c = SHR(d0, 44); h0 = LO(d0) & 0xfffffffffff;
-		ADDLO(d1, c); c = SHR(d1, 44); h1 = LO(d1) & 0xfffffffffff;
-		ADDLO(d2, c); c = SHR(d2, 42); h2 = LO(d2) & 0x3ffffffffff;
-		h0  += c * 5; c = (h0 >> 44);  h0 =    h0  & 0xfffffffffff;
-		h1  += c;
-
-		m += POLY1305_BLOCK_SIZE;
-		bytes -= POLY1305_BLOCK_SIZE;
-	}
-
-	ctx->h[0] = h0;
-	ctx->h[1] = h1;
-	ctx->h[2] = h2;
-
-#else /* if not 64 bit then use 32 bit */
-   
-	r0 = ctx->r[0];
-	r1 = ctx->r[1];
-	r2 = ctx->r[2];
-	r3 = ctx->r[3];
-	r4 = ctx->r[4];
-
-	s1 = r1 * 5;
-	s2 = r2 * 5;
-	s3 = r3 * 5;
-	s4 = r4 * 5;
-
-	h0 = ctx->h[0];
-	h1 = ctx->h[1];
-	h2 = ctx->h[2];
-	h3 = ctx->h[3];
-	h4 = ctx->h[4];
-
-	while (bytes >= POLY1305_BLOCK_SIZE) {
-		/* h += m[i] */
-		h0 += (U8TO32(m+ 0)     ) & 0x3ffffff;
-		h1 += (U8TO32(m+ 3) >> 2) & 0x3ffffff;
-		h2 += (U8TO32(m+ 6) >> 4) & 0x3ffffff;
-		h3 += (U8TO32(m+ 9) >> 6) & 0x3ffffff;
-		h4 += (U8TO32(m+12) >> 8) | hibit;
-
-		/* h *= r */
-		d0 = ((word64)h0 * r0) + ((word64)h1 * s4) + ((word64)h2 * s3) +
-             ((word64)h3 * s2) + ((word64)h4 * s1);
-		d1 = ((word64)h0 * r1) + ((word64)h1 * r0) + ((word64)h2 * s4) +
-             ((word64)h3 * s3) + ((word64)h4 * s2);
-		d2 = ((word64)h0 * r2) + ((word64)h1 * r1) + ((word64)h2 * r0) +
-             ((word64)h3 * s4) + ((word64)h4 * s3);
-		d3 = ((word64)h0 * r3) + ((word64)h1 * r2) + ((word64)h2 * r1) +
-             ((word64)h3 * r0) + ((word64)h4 * s4);
-		d4 = ((word64)h0 * r4) + ((word64)h1 * r3) + ((word64)h2 * r2) +
-             ((word64)h3 * r1) + ((word64)h4 * r0);
-
-		/* (partial) h %= p */
-		              c = (word32)(d0 >> 26); h0 = (word32)d0 & 0x3ffffff;
-		d1 += c;      c = (word32)(d1 >> 26); h1 = (word32)d1 & 0x3ffffff;
-		d2 += c;      c = (word32)(d2 >> 26); h2 = (word32)d2 & 0x3ffffff;
-		d3 += c;      c = (word32)(d3 >> 26); h3 = (word32)d3 & 0x3ffffff;
-		d4 += c;      c = (word32)(d4 >> 26); h4 = (word32)d4 & 0x3ffffff;
-		h0 += c * 5;  c =  (h0 >> 26); h0 =                h0 & 0x3ffffff;
-		h1 += c;
-
-		m += POLY1305_BLOCK_SIZE;
-		bytes -= POLY1305_BLOCK_SIZE;
-	}
-
-	ctx->h[0] = h0;
-	ctx->h[1] = h1;
-	ctx->h[2] = h2;
-	ctx->h[3] = h3;
-	ctx->h[4] = h4;
-
-#endif /* end of 64 bit cpu blocks or 32 bit cpu */
-}
-
-
-int wc_Poly1305SetKey(Poly1305* ctx, const byte* key, word32 keySz) {
-
-#if defined(POLY130564)
-    word64 t0,t1;
-#endif
-
-#ifdef CHACHA_AEAD_TEST
-    word32 k;
-    printf("Poly key used:\n");
-    for (k = 0; k < keySz; k++) {
-        printf("%02x", key[k]);
-        if ((k+1) % 8 == 0)
-            printf("\n");
-    }
-	printf("\n");
-#endif
-
-    if (keySz != 32 || ctx == NULL)
-        return BAD_FUNC_ARG;
-
-#if defined(POLY130564)
-
-	/* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
-	t0 = U8TO64(key + 0);
-	t1 = U8TO64(key + 8);
-
-	ctx->r[0] = ( t0                    ) & 0xffc0fffffff;
-	ctx->r[1] = ((t0 >> 44) | (t1 << 20)) & 0xfffffc0ffff;
-	ctx->r[2] = ((t1 >> 24)             ) & 0x00ffffffc0f;
-
-	/* h (accumulator) = 0 */
-	ctx->h[0] = 0;
-	ctx->h[1] = 0;
-	ctx->h[2] = 0;
-
-	/* save pad for later */
-	ctx->pad[0] = U8TO64(key + 16);
-	ctx->pad[1] = U8TO64(key + 24);
-
-#else /* if not 64 bit then use 32 bit */
-	
-    /* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
-	ctx->r[0] = (U8TO32(key +  0)     ) & 0x3ffffff;
-	ctx->r[1] = (U8TO32(key +  3) >> 2) & 0x3ffff03;
-	ctx->r[2] = (U8TO32(key +  6) >> 4) & 0x3ffc0ff;
-	ctx->r[3] = (U8TO32(key +  9) >> 6) & 0x3f03fff;
-	ctx->r[4] = (U8TO32(key + 12) >> 8) & 0x00fffff;
-
-	/* h = 0 */
-	ctx->h[0] = 0;
-	ctx->h[1] = 0;
-	ctx->h[2] = 0;
-	ctx->h[3] = 0;
-	ctx->h[4] = 0;
-
-	/* save pad for later */
-	ctx->pad[0] = U8TO32(key + 16);
-	ctx->pad[1] = U8TO32(key + 20);
-	ctx->pad[2] = U8TO32(key + 24);
-	ctx->pad[3] = U8TO32(key + 28);
-
-#endif
-
-	ctx->leftover = 0;
-	ctx->final = 0;
-
-    return 0;
-}
-
-
-int wc_Poly1305Final(Poly1305* ctx, byte* mac) {
-
-#if defined(POLY130564)
-
-    word64 h0,h1,h2,c;
-	word64 g0,g1,g2;
-	word64 t0,t1;
-
-#else
-
-    word32 h0,h1,h2,h3,h4,c;
-	word32 g0,g1,g2,g3,g4;
-	word64 f;
-	word32 mask;
-
-#endif
-
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-#if defined(POLY130564)
-
-	/* process the remaining block */
-	if (ctx->leftover) {
-		size_t i = ctx->leftover;
-		ctx->buffer[i] = 1;
-		for (i = i + 1; i < POLY1305_BLOCK_SIZE; i++)
-			ctx->buffer[i] = 0;
-		ctx->final = 1;
-		poly1305_blocks(ctx, ctx->buffer, POLY1305_BLOCK_SIZE);
-	}
-
-	/* fully carry h */
-	h0 = ctx->h[0];
-	h1 = ctx->h[1];
-	h2 = ctx->h[2];
-
-	             c = (h1 >> 44); h1 &= 0xfffffffffff;
-	h2 += c;     c = (h2 >> 42); h2 &= 0x3ffffffffff;
-	h0 += c * 5; c = (h0 >> 44); h0 &= 0xfffffffffff;
-	h1 += c;	 c = (h1 >> 44); h1 &= 0xfffffffffff;
-	h2 += c;     c = (h2 >> 42); h2 &= 0x3ffffffffff;
-	h0 += c * 5; c = (h0 >> 44); h0 &= 0xfffffffffff;
-	h1 += c;
-
-	/* compute h + -p */
-	g0 = h0 + 5; c = (g0 >> 44); g0 &= 0xfffffffffff;
-	g1 = h1 + c; c = (g1 >> 44); g1 &= 0xfffffffffff;
-	g2 = h2 + c - ((word64)1 << 42);
-
-	/* select h if h < p, or h + -p if h >= p */
-	c = (g2 >> ((sizeof(word64) * 8) - 1)) - 1;
-	g0 &= c;
-	g1 &= c;
-	g2 &= c;
-	c = ~c;
-	h0 = (h0 & c) | g0;
-	h1 = (h1 & c) | g1;
-	h2 = (h2 & c) | g2;
-
-	/* h = (h + pad) */
-	t0 = ctx->pad[0];
-	t1 = ctx->pad[1];
-
-	h0 += (( t0                    ) & 0xfffffffffff)    ;
-    c = (h0 >> 44); h0 &= 0xfffffffffff;
-	h1 += (((t0 >> 44) | (t1 << 20)) & 0xfffffffffff) + c;
-    c = (h1 >> 44); h1 &= 0xfffffffffff;
-	h2 += (((t1 >> 24)             ) & 0x3ffffffffff) + c;
-    h2 &= 0x3ffffffffff;
-
-	/* mac = h % (2^128) */
-	h0 = ((h0      ) | (h1 << 44));
-	h1 = ((h1 >> 20) | (h2 << 24));
-
-	U64TO8(mac + 0, h0);
-	U64TO8(mac + 8, h1);
-
-	/* zero out the state */
-	ctx->h[0] = 0;
-	ctx->h[1] = 0;
-	ctx->h[2] = 0;
-	ctx->r[0] = 0;
-	ctx->r[1] = 0;
-	ctx->r[2] = 0;
-	ctx->pad[0] = 0;
-	ctx->pad[1] = 0;
-
-#else /* if not 64 bit then use 32 bit */
-    
-	/* process the remaining block */
-	if (ctx->leftover) {
-		size_t i = ctx->leftover;
-		ctx->buffer[i++] = 1;
-		for (; i < POLY1305_BLOCK_SIZE; i++)
-			ctx->buffer[i] = 0;
-		ctx->final = 1;
-		poly1305_blocks(ctx, ctx->buffer, POLY1305_BLOCK_SIZE);
-	}
-
-	/* fully carry h */
-	h0 = ctx->h[0];
-	h1 = ctx->h[1];
-	h2 = ctx->h[2];
-	h3 = ctx->h[3];
-	h4 = ctx->h[4];
-
-	             c = h1 >> 26; h1 = h1 & 0x3ffffff;
-	h2 +=     c; c = h2 >> 26; h2 = h2 & 0x3ffffff;
-	h3 +=     c; c = h3 >> 26; h3 = h3 & 0x3ffffff;
-	h4 +=     c; c = h4 >> 26; h4 = h4 & 0x3ffffff;
-	h0 += c * 5; c = h0 >> 26; h0 = h0 & 0x3ffffff;
-	h1 +=     c;
-
-	/* compute h + -p */
-	g0 = h0 + 5; c = g0 >> 26; g0 &= 0x3ffffff;
-	g1 = h1 + c; c = g1 >> 26; g1 &= 0x3ffffff;
-	g2 = h2 + c; c = g2 >> 26; g2 &= 0x3ffffff;
-	g3 = h3 + c; c = g3 >> 26; g3 &= 0x3ffffff;
-	g4 = h4 + c - (1 << 26);
-
-	/* select h if h < p, or h + -p if h >= p */
-	mask = (g4 >> ((sizeof(word32) * 8) - 1)) - 1;
-	g0 &= mask;
-	g1 &= mask;
-	g2 &= mask;
-	g3 &= mask;
-	g4 &= mask;
-	mask = ~mask;
-	h0 = (h0 & mask) | g0;
-	h1 = (h1 & mask) | g1;
-	h2 = (h2 & mask) | g2;
-	h3 = (h3 & mask) | g3;
-	h4 = (h4 & mask) | g4;
-
-	/* h = h % (2^128) */
-	h0 = ((h0      ) | (h1 << 26)) & 0xffffffff;
-	h1 = ((h1 >>  6) | (h2 << 20)) & 0xffffffff;
-	h2 = ((h2 >> 12) | (h3 << 14)) & 0xffffffff;
-	h3 = ((h3 >> 18) | (h4 <<  8)) & 0xffffffff;
-
-	/* mac = (h + pad) % (2^128) */
-	f = (word64)h0 + ctx->pad[0]            ; h0 = (word32)f;
-	f = (word64)h1 + ctx->pad[1] + (f >> 32); h1 = (word32)f;
-	f = (word64)h2 + ctx->pad[2] + (f >> 32); h2 = (word32)f;
-	f = (word64)h3 + ctx->pad[3] + (f >> 32); h3 = (word32)f;
-
-	U32TO8(mac + 0, h0);
-	U32TO8(mac + 4, h1);
-	U32TO8(mac + 8, h2);
-	U32TO8(mac + 12, h3);
-
-	/* zero out the state */
-	ctx->h[0] = 0;
-	ctx->h[1] = 0;
-	ctx->h[2] = 0;
-	ctx->h[3] = 0;
-	ctx->h[4] = 0;
-	ctx->r[0] = 0;
-	ctx->r[1] = 0;
-	ctx->r[2] = 0;
-	ctx->r[3] = 0;
-	ctx->r[4] = 0;
-	ctx->pad[0] = 0;
-	ctx->pad[1] = 0;
-	ctx->pad[2] = 0;
-	ctx->pad[3] = 0;
-
-#endif
-
-    return 0;
-}
-
-
-int wc_Poly1305Update(Poly1305* ctx, const byte* m, word32 bytes) {
-
-	size_t i;
-
-#ifdef CHACHA_AEAD_TEST
-    word32 k;
-    printf("Raw input to poly:\n");
-    for (k = 0; k < bytes; k++) {
-        printf("%02x", m[k]);
-        if ((k+1) % 16 == 0)
-            printf("\n");
-    }
-	printf("\n");
-#endif
-    
-    if (ctx == NULL)
-        return BAD_FUNC_ARG;
-
-	/* handle leftover */
-	if (ctx->leftover) {
-		size_t want = (POLY1305_BLOCK_SIZE - ctx->leftover);
-		if (want > bytes)
-			want = bytes;
-		for (i = 0; i < want; i++)
-			ctx->buffer[ctx->leftover + i] = m[i];
-		bytes -= want;
-		m += want;
-		ctx->leftover += want;
-		if (ctx->leftover < POLY1305_BLOCK_SIZE)
-			return 0;
-		poly1305_blocks(ctx, ctx->buffer, POLY1305_BLOCK_SIZE);
-		ctx->leftover = 0;
-	}
-
-	/* process full blocks */
-	if (bytes >= POLY1305_BLOCK_SIZE) {
-		size_t want = (bytes & ~(POLY1305_BLOCK_SIZE - 1));
-		poly1305_blocks(ctx, m, want);
-		m += want;
-		bytes -= want;
-	}
-
-	/* store leftover */
-	if (bytes) {
-		for (i = 0; i < bytes; i++)
-			ctx->buffer[ctx->leftover + i] = m[i];
-		ctx->leftover += bytes;
-	}
-    return 0;
-}
-#endif /* HAVE_POLY1305 */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/port/pic32/pic32mz-hash.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/port/pic32/pic32mz-hash.c
deleted file mode 100755
index c293afa..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/port/pic32/pic32mz-hash.c
+++ /dev/null
@@ -1,371 +0,0 @@
-/* pic32mz-hash.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef WOLFSSL_PIC32MZ_HASH
-
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-#if !defined(NO_MD5) && !defined(NO_SHA) && !defined(NO_SHA256)
-
-static uint8_t dataBuffer[PIC32MZ_MAX_BD][PIC32_BLOCK_SIZE] __attribute__((aligned (4), coherent));
-
-static void reset_engine(pic32mz_desc *desc, int algo)
-{
-    int i;
-    pic32mz_desc* uc_desc = KVA0_TO_KVA1(desc);
-
-    CECON = 1 << 6;
-    while (CECON);
-
-    /* Make sure everything is clear first before we make settings. */
-    XMEMSET((void *)&uc_desc->sa, 0, sizeof(uc_desc->sa));
-
-    /* Set up the security association */
-    uc_desc->sa.SA_CTRL.ALGO = algo ;
-    uc_desc->sa.SA_CTRL.LNC = 1;
-    uc_desc->sa.SA_CTRL.FB = 1;
-    uc_desc->sa.SA_CTRL.ENCTYPE = 1;
-    uc_desc->sa.SA_CTRL.LOADIV = 1;
-
-    /* Set up the buffer descriptor */
-    uc_desc->err = 0 ;
-    for (i = 0; i < PIC32MZ_MAX_BD; i++)
-    {
-        XMEMSET((void *)&uc_desc->bd[i], 0, sizeof(uc_desc->bd[i]));
-        uc_desc->bd[i].BD_CTRL.LAST_BD = 1;
-        uc_desc->bd[i].BD_CTRL.LIFM = 1;
-        uc_desc->bd[i].BD_CTRL.PKT_INT_EN = 1;
-        uc_desc->bd[i].SA_ADDR = KVA_TO_PA(&uc_desc->sa);
-        uc_desc->bd[i].SRCADDR = KVA_TO_PA(&dataBuffer[i]);
-        if (PIC32MZ_MAX_BD > i+1)
-            uc_desc->bd[i].NXTPTR = KVA_TO_PA(&uc_desc->bd[i+1]);
-        else
-            uc_desc->bd[i].NXTPTR = KVA_TO_PA(&uc_desc->bd[0]);
-        XMEMSET((void *)&dataBuffer[i], 0, PIC32_BLOCK_SIZE);
-    }
-    uc_desc->bd[0].BD_CTRL.SA_FETCH_EN = 1; // Fetch the security association on the first BD
-    desc->dbPtr = 0;
-    desc->currBd = 0;
-    desc->msgSize = 0;
-    desc->processed = 0;
-    CEBDPADDR = KVA_TO_PA(&(desc->bd[0]));
-
-    CEPOLLCON = 10;
-
-    CECON = 0x27;
-}
-
-#define PIC32MZ_IF_RAM(addr) (KVA_TO_PA(addr) < 0x80000)
-
-static void update_data_size(pic32mz_desc *desc, word32 msgSize)
-{
-    desc->msgSize = msgSize;
-}
-
-static void update_engine(pic32mz_desc *desc, const char *input, word32 len,
-                    word32 *hash)
-{
-   int total ;
-    pic32mz_desc    *uc_desc = KVA0_TO_KVA1(desc);
-
-    uc_desc->bd[desc->currBd].UPDPTR = KVA_TO_PA(hash);
-    // Add the data to the current buffer. If the buffer fills, start processing it
-    // and fill the next one.
-    while (len)
-    {
-        // If the engine is processing the current BD, spin.
-//        if (uc_desc->bd[desc->currBd].BD_CTRL.DESC_EN)
-//            continue;
-        if (desc->msgSize)
-        {
-            // If we've been given the message size, we can process along the
-            // way.
-            // Enable the current buffer descriptor if it is full.
-            if (desc->dbPtr >= PIC32_BLOCK_SIZE)
-            {
-                // Wrap up the buffer descriptor and enable it so the engine can process
-                uc_desc->bd[desc->currBd].MSGLEN = desc->msgSize;
-                uc_desc->bd[desc->currBd].BD_CTRL.BUFLEN = desc->dbPtr;
-                uc_desc->bd[desc->currBd].BD_CTRL.LAST_BD = 0;
-                uc_desc->bd[desc->currBd].BD_CTRL.LIFM = 0;
-                //SYS_DEVCON_DataCacheClean((word32)desc, sizeof(pic32mz_desc));
-                uc_desc->bd[desc->currBd].BD_CTRL.DESC_EN = 1;
-                // Move to the next buffer descriptor, or wrap around.
-                desc->currBd++;
-                if (desc->currBd >= PIC32MZ_MAX_BD)
-                    desc->currBd = 0;
-                // Wait until the engine has processed the new BD.
-                while (uc_desc->bd[desc->currBd].BD_CTRL.DESC_EN);
-                uc_desc->bd[desc->currBd].UPDPTR = KVA_TO_PA(hash);
-                desc->dbPtr = 0;
-            }
-            if (!PIC32MZ_IF_RAM(input)) // If we're inputting from flash, let the BD have the address and max the buffer size
-            {
-                uc_desc->bd[desc->currBd].SRCADDR = KVA_TO_PA(input);
-                total = (len > PIC32MZ_MAX_BLOCK ? PIC32MZ_MAX_BLOCK : len);
-                desc->dbPtr = total;
-                len -= total;
-                input += total;
-            }
-            else
-            {
-                if (len > PIC32_BLOCK_SIZE - desc->dbPtr)
-                {
-                    // We have more data than can be put in the buffer. Fill what we can.
-                    total = PIC32_BLOCK_SIZE - desc->dbPtr;
-                    XMEMCPY(&dataBuffer[desc->currBd][desc->dbPtr], input, total);
-                    len -= total;
-                    desc->dbPtr = PIC32_BLOCK_SIZE;
-                    input += total;
-                }
-                else
-                {
-                    // Fill up what we have, but don't turn on the engine.
-                    XMEMCPY(&dataBuffer[desc->currBd][desc->dbPtr], input, len);
-                    desc->dbPtr += len;
-                    len = 0;
-                }
-            }
-        }
-        else
-        {
-            // We have to buffer everything and keep track of how much has been
-            // added in order to get a total size. If the buffer fills, we move
-            // to the next one. If we try to add more when the last buffer is
-            // full, we error out.
-            if (desc->dbPtr == PIC32_BLOCK_SIZE)
-            {
-                // We filled the last BD buffer, so move on to the next one
-                uc_desc->bd[desc->currBd].BD_CTRL.LAST_BD = 0;
-                uc_desc->bd[desc->currBd].BD_CTRL.LIFM = 0;
-                uc_desc->bd[desc->currBd].BD_CTRL.BUFLEN = PIC32_BLOCK_SIZE;
-                desc->currBd++;
-                uc_desc->bd[desc->currBd].UPDPTR = KVA_TO_PA(hash);
-                desc->dbPtr = 0;
-                if (desc->currBd >= PIC32MZ_MAX_BD)
-                {
-                    desc->err = 1;
-                }
-            }
-            if (len > PIC32_BLOCK_SIZE - desc->dbPtr)
-            {
-                // We have more data than can be put in the buffer. Fill what we can.
-                total = PIC32_BLOCK_SIZE - desc->dbPtr;
-                XMEMCPY(&dataBuffer[desc->currBd][desc->dbPtr], input, total);
-                len -= total;
-                desc->processed += total;
-                desc->dbPtr = PIC32_BLOCK_SIZE;
-                input += total;
-            }
-            else
-            {
-                // Fill up what we have
-                XMEMCPY(&dataBuffer[desc->currBd][desc->dbPtr], input, len);
-                desc->dbPtr += len;
-                desc->processed += len;
-                len = 0;
-            }
-        }
-    }
-}
-
-static void start_engine(pic32mz_desc *desc) {
-    // Wrap up the last buffer descriptor and enable it
-    int i ;
-    int bufferLen ;
-    pic32mz_desc *uc_desc = KVA0_TO_KVA1(desc);
-
-    bufferLen = desc->dbPtr;
-    if (bufferLen % 4)
-        bufferLen = (bufferLen + 4) - (bufferLen % 4);
-    uc_desc->bd[desc->currBd].BD_CTRL.BUFLEN = bufferLen;
-    uc_desc->bd[desc->currBd].BD_CTRL.LAST_BD = 1;
-    uc_desc->bd[desc->currBd].BD_CTRL.LIFM = 1;
-    if (desc->msgSize == 0)
-    {
-        // We were not given the size, so now we have to go through every BD
-        // and give it what will be processed, and enable them.
-        for (i = desc->currBd; i >= 0; i--)
-        {
-            uc_desc->bd[i].MSGLEN = desc->processed;
-            uc_desc->bd[i].BD_CTRL.DESC_EN = 1;
-        }
-    }
-    else
-    {
-        uc_desc->bd[desc->currBd].BD_CTRL.DESC_EN = 1;
-    }
-}
-
-void wait_engine(pic32mz_desc *desc, char *hash, int hash_sz) {
-    unsigned int i;
-    unsigned int *intptr;
-    pic32mz_desc *uc_desc = KVA0_TO_KVA1(desc);
-    enum {true = 1, false = 0} engineRunning = true;
-
-    while (engineRunning)
-    {
-        engineRunning = false;
-        for (i = 0; i < PIC32MZ_MAX_BD; i++)
-            engineRunning = engineRunning || uc_desc->bd[i].BD_CTRL.DESC_EN;
-    }
-    XMEMCPY(hash, KVA0_TO_KVA1(hash), hash_sz) ;
-
-    #ifdef DEBUG_CYASSL
-    print_mem(KVA0_TO_KVA1(hash), hash_sz) ;
-    print_mem(             hash , hash_sz) ;
-    #endif
-    for (i = 0, intptr = (unsigned int *)hash; i < hash_sz/sizeof(unsigned int);
-                                                                  i++, intptr++)
-    {
-        *intptr = ntohl(*intptr);
-    }
-}
-
-static int fillBuff(char *buff, int *bufflen, const char *data, int len, int blocksz)
-{
-    int room, copysz ;
-
-    room = blocksz - *bufflen ;
-    copysz = (len <= room) ? len : room ;
-    XMEMCPY(buff, data, copysz) ;
-    *bufflen += copysz ;
-    return (*bufflen == blocksz) ? 1 : 0 ;
-}
-
-#endif
-
-#ifndef NO_MD5
-void wc_InitMd5(Md5* md5)
-{
-    WOLFSSL_ENTER("InitMd5\n") ;
-    XMEMSET((void *)md5, 0xcc, sizeof(Md5)) ;
-    XMEMSET((void *)KVA0_TO_KVA1(md5), 0xcc, sizeof(Md5)) ;
-    reset_engine(&(md5->desc), PIC32_ALGO_MD5) ;
-
-}
-
-void wc_Md5Update(Md5* md5, const byte* data, word32 len)
-{
-     WOLFSSL_ENTER("Md5Update\n") ;
-     update_engine(&(md5->desc), data, len, md5->digest) ;
-}
-
-void wc_Md5Final(Md5* md5, byte* hash)
-{
-     WOLFSSL_ENTER("Md5Final\n") ;
-    start_engine(&(md5->desc)) ;
-    wait_engine(&(md5->desc), (char *)md5->digest, MD5_HASH_SIZE) ;
-    XMEMCPY(hash, md5->digest, MD5_HASH_SIZE) ;
-    wc_InitMd5(md5);  /* reset state */
-}
-
-void Md5SizeSet(Md5* md5, word32 len)
-{
-    WOLFSSL_ENTER("Md5SizeSet\n");
-    md5->desc.msgSize = len;
-}
-#endif
-
-#ifndef NO_SHA
-int wc_InitSha(Sha* sha)
-{
-    WOLFSSL_ENTER("InitSha\n") ;
-    XMEMSET((void *)sha, 0xcc, sizeof(Sha)) ;
-    XMEMSET((void *)KVA0_TO_KVA1(sha), 0xcc, sizeof(Sha)) ;
-    reset_engine(&(sha->desc), PIC32_ALGO_SHA1) ;
-    return 0;
-}
-
-int wc_ShaUpdate(Sha* sha, const byte* data, word32 len)
-{
-    WOLFSSL_ENTER("ShaUpdate\n") ;
-    update_engine(&(sha->desc), data, len, sha->digest) ;
-    return 0;
-}
-
-int wc_ShaFinal(Sha* sha, byte* hash)
-{
-    WOLFSSL_ENTER("ShaFinal\n") ;
-    start_engine(&(sha->desc)) ;
-    wait_engine(&(sha->desc), (char *)sha->digest, SHA1_HASH_SIZE) ;
-    XMEMCPY(hash, sha->digest, SHA1_HASH_SIZE) ;
-
-    wc_InitSha(sha);  /* reset state */
-    return 0;
-}
-
-void ShaSizeSet(Sha* sha, word32 len)
-{
-    sha->desc.msgSize = len;
-}
-#endif /* NO_SHA */
-
-#ifndef NO_SHA256
-int wc_InitSha256(Sha256* sha256)
-{
-    WOLFSSL_ENTER("InitSha256\n") ;
-    XMEMSET((void *)sha256, 0xcc, sizeof(Sha256)) ;
-    XMEMSET((void *)KVA0_TO_KVA1(sha256), 0xcc, sizeof(Sha256)) ;
-    reset_engine(&(sha256->desc), PIC32_ALGO_SHA256) ;
-    return 0;
-}
-
-int wc_Sha256Update(Sha256* sha256, const byte* data, word32 len)
-{
-    WOLFSSL_ENTER("Sha256Update\n") ;
-    update_engine(&(sha256->desc), data, len, sha256->digest) ;
-
-    return 0;
-}
-
-int wc_Sha256Final(Sha256* sha256, byte* hash)
-{
-    WOLFSSL_ENTER("Sha256Final\n") ;
-    start_engine(&(sha256->desc)) ;
-    wait_engine(&(sha256->desc), (char *)sha256->digest, SHA256_HASH_SIZE) ;
-    XMEMCPY(hash, sha256->digest, SHA256_HASH_SIZE) ;
-    wc_InitSha256(sha256);  /* reset state */
-
-    return 0;
-}
-
-void Sha256SizeSet(Sha256* sha256, word32 len)
-{
-    WOLFSSL_ENTER("Sha256SizeSet\n");
-    sha256->desc.msgSize = len;
-}
-
-#endif /* NO_SHA256 */
-
-#endif
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/port/ti/ti-aes.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/port/ti/ti-aes.c
deleted file mode 100755
index d38e7a3..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/port/ti/ti-aes.c
+++ /dev/null
@@ -1,548 +0,0 @@
-/* port/ti/ti-aes.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
- 
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef NO_AES
-
-
-#if defined(WOLFSSL_TI_CRYPT)
-#include 
-#include 
-
-#include 
-#include 
-#include 
-
-#include "inc/hw_aes.h"
-#include "inc/hw_memmap.h"
-#include "inc/hw_ints.h"
-#include "driverlib/aes.h"
-#include "driverlib/sysctl.h"
-#include "driverlib/rom_map.h"
-#include "driverlib/rom.h"
-
-static int  AesSetIV(Aes* aes, const byte* iv)
-{
-    if (aes == NULL)
-        return BAD_FUNC_ARG;
-
-    if (iv)
-        XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE);
-    else
-        XMEMSET(aes->reg,  0, AES_BLOCK_SIZE);
-
-    return 0;
-}
-
-WOLFSSL_API int  wc_AesSetKey(Aes* aes, const byte* key, word32 len, const byte* iv,
-                          int dir)
-{
-    if(!wolfSSL_TI_CCMInit())return 1 ;
-    if ((aes == NULL) || (key == NULL) || (iv == NULL))
-        return BAD_FUNC_ARG;
-    if(!((dir == AES_ENCRYPTION) || (dir == AES_DECRYPTION)))
-        return BAD_FUNC_ARG;
-    
-    switch(len) {
-    case 16: aes->keylen = AES_CFG_KEY_SIZE_128BIT ; break ;
-    case 24: aes->keylen = AES_CFG_KEY_SIZE_192BIT ; break ;
-    case 32: aes->keylen = AES_CFG_KEY_SIZE_256BIT ; break ;
-    default: return BAD_FUNC_ARG;      
-    }
-    
-    XMEMCPY(aes->key, key, len) ;
-    #ifdef WOLFSSL_AES_COUNTER
-    aes->left = 0;
-    #endif /* WOLFSSL_AES_COUNTER */
-    return AesSetIV(aes, iv);
-}
-
-#define AES_CFG_MODE_CTR_NOCTR AES_CFG_MODE_CTR+100
-#define IS_ALIGN16(p) (((unsigned int)(p)&0xf) == 0)
-
-static int  AesAlign16(Aes* aes, byte* out, const byte* in, word32 sz, word32 dir, word32 mode)
-{   
-    wolfSSL_TI_lockCCM() ;
-    ROM_AESReset(AES_BASE);
-    ROM_AESConfigSet(AES_BASE, (aes->keylen | dir | 
-                     (mode==AES_CFG_MODE_CTR_NOCTR ? AES_CFG_MODE_CTR : mode)));
-    ROM_AESIVSet(AES_BASE, aes->reg);
-    ROM_AESKey1Set(AES_BASE, aes->key, aes->keylen);
-    if((dir == AES_CFG_DIR_DECRYPT)&& (mode == AES_CFG_MODE_CBC))
-        /* if input and output same will overwrite input iv */
-        XMEMCPY(aes->tmp, in + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
-    ROM_AESDataProcess(AES_BASE, (uint32_t *)in, (uint32_t *)out, sz);
-    wolfSSL_TI_unlockCCM() ;
-    
-    /* store iv for next call */
-    if(mode == AES_CFG_MODE_CBC){
-        if(dir == AES_CFG_DIR_ENCRYPT)
-            XMEMCPY(aes->reg, out + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
-        else
-            XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE);
-    }
-
-    if(mode == AES_CFG_MODE_CTR) {
-        do {  
-            int i ;
-            for (i = AES_BLOCK_SIZE - 1; i >= 0; i--) {
-                 if (++((byte *)aes->reg)[i])
-                     break ;
-            }
-            sz -= AES_BLOCK_SIZE ;
-        } while((int)sz > 0) ;
-    }
-
-    return 0 ;
-}
-
-static int  AesProcess(Aes* aes, byte* out, const byte* in, word32 sz, word32 dir, word32 mode)
-{   
-    const byte * in_p ; byte * out_p ; 
-    word32 size ;
-    #define TI_BUFFSIZE 1024
-    byte buff[TI_BUFFSIZE] ;
-    
-    if ((aes == NULL) || (in == NULL) || (out == NULL))
-        return BAD_FUNC_ARG;
-    if(sz % AES_BLOCK_SIZE)
-        return BAD_FUNC_ARG;
-
-    while(sz > 0) {
-        size = sz ; in_p = in ; out_p = out ;
-        if(!IS_ALIGN16(in)){
-            size = sz>TI_BUFFSIZE ? TI_BUFFSIZE : sz ;
-            XMEMCPY(buff, in, size) ; 
-            in_p = (const byte *)buff ;
-        }
-        if(!IS_ALIGN16(out)){
-            size = sz>TI_BUFFSIZE ? TI_BUFFSIZE : sz ;
-            out_p = buff ;
-        }
-   
-        AesAlign16(aes, out_p, in_p, size, dir, mode) ;
- 
-        if(!IS_ALIGN16(out)){
-            XMEMCPY(out, buff, size) ;
-        }
-        sz -= size ; in += size ; out += size ;
-    }
-
-    return 0 ;
-}
-
-WOLFSSL_API int  wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-{   
-    return AesProcess(aes, out, in, sz, AES_CFG_DIR_ENCRYPT, AES_CFG_MODE_CBC) ;
-}
-
-WOLFSSL_API int  wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-{   
-    return AesProcess(aes, out, in, sz, AES_CFG_DIR_DECRYPT, AES_CFG_MODE_CBC) ;
-}
-
-#ifdef WOLFSSL_AES_COUNTER
-WOLFSSL_API void wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
-{ 
-            char out_block[AES_BLOCK_SIZE] ;
-            int odd ;
-            int even ;
-            char *tmp ; /* (char *)aes->tmp, for short */
-
-            tmp = (char *)aes->tmp ;
-            if(aes->left) {
-                if((aes->left + sz) >= AES_BLOCK_SIZE){
-                    odd = AES_BLOCK_SIZE - aes->left ;
-                } else {
-                    odd = sz ;
-                }
-                XMEMCPY(tmp+aes->left, in, odd) ;
-                if((odd+aes->left) == AES_BLOCK_SIZE){
-                    AesProcess(aes, (byte *)out_block, (byte const *)tmp, AES_BLOCK_SIZE, 
-                             AES_CFG_DIR_ENCRYPT, AES_CFG_MODE_CTR) ;
-                    XMEMCPY(out, out_block+aes->left, odd) ;
-                    aes->left = 0 ;
-                    XMEMSET(tmp, 0x0, AES_BLOCK_SIZE) ;
-                }
-                in += odd ;
-                out+= odd ;
-                sz -= odd ;
-            }
-            odd = sz % AES_BLOCK_SIZE ;  /* if there is tail flagment */
-            if(sz / AES_BLOCK_SIZE) {
-                even = (sz/AES_BLOCK_SIZE)*AES_BLOCK_SIZE ;
-                AesProcess(aes, out, in, even, AES_CFG_DIR_ENCRYPT, AES_CFG_MODE_CTR);
-                out += even ;
-                in  += even ;
-            }
-            if(odd) {
-                XMEMSET(tmp+aes->left, 0x0, AES_BLOCK_SIZE - aes->left) ;
-                XMEMCPY(tmp+aes->left, in, odd) ;
-                AesProcess(aes, (byte *)out_block, (byte const *)tmp, AES_BLOCK_SIZE, 
-                           AES_CFG_DIR_ENCRYPT, 
-                           AES_CFG_MODE_CTR_NOCTR /* Counter mode without counting IV */
-                           );
-                XMEMCPY(out, out_block+aes->left,odd) ;
-                aes->left += odd ;
-            }
-}
-#endif
-
-/* AES-DIRECT */
-#if defined(WOLFSSL_AES_DIRECT)
-WOLFSSL_API void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
-{
-    AesProcess(aes, out, in, AES_BLOCK_SIZE, AES_CFG_DIR_ENCRYPT, AES_CFG_MODE_CBC) ;
-}
-WOLFSSL_API void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in)
-{
-    AesProcess(aes, out, in, AES_BLOCK_SIZE, AES_CFG_DIR_DECRYPT, AES_CFG_MODE_CBC) ;
-}
-WOLFSSL_API int wc_AesSetKeyDirect(Aes* aes, const byte* key, word32 len,
-                                     const byte* iv, int dir)
-{
-     return(wc_AesSetKey(aes, key, len, iv, dir)) ;
-}
-#endif
-
-
-#if defined(HAVE_AESGCM) || defined(HAVE_AESCCM)
-
-static int  AesAuthSetKey(Aes* aes, const byte* key, word32 keySz)
-{
-    byte nonce[AES_BLOCK_SIZE];
-
-    if ((aes == NULL) || (key == NULL))
-        return BAD_FUNC_ARG ;
-    if (!((keySz == 16) || (keySz == 24) || (keySz == 32)))
-        return BAD_FUNC_ARG ;
-
-    XMEMSET(nonce, 0, sizeof(nonce));
-    return wc_AesSetKey(aes, key, keySz, nonce, AES_ENCRYPTION);
-}
-
-
-static int AesAuthArgCheck(Aes* aes, byte* out, const byte* in, word32 inSz,
-                              const byte* nonce, word32 nonceSz,
-                              const byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz, word32 *M,  word32 *L)
-{
-    if((aes == NULL)||(nonce == NULL)||(authTag== NULL)||(authIn == NULL))
-        return BAD_FUNC_ARG;
-    if((inSz != 0) && ((out == NULL)||(in == NULL)))
-        return BAD_FUNC_ARG;
-    
-    switch(authTagSz){
-    case  4:
-        *M = AES_CFG_CCM_M_4; break ;
-    case 6:
-        *M = AES_CFG_CCM_M_6; break ;
-    case 8:
-        *M = AES_CFG_CCM_M_8; break ;
-    case 10:
-        *M = AES_CFG_CCM_M_10; break ;
-    case 12:
-        *M = AES_CFG_CCM_M_12; break ;
-    case 14:
-        *M = AES_CFG_CCM_M_14; break ;
-    case 16:
-        *M = AES_CFG_CCM_M_16; break ;
-    default:
-        return 1 ;
-    }
-
-    switch(nonceSz){
-    case 7:
-        *L = AES_CFG_CCM_L_8; break ;
-    case 8:
-        *L = AES_CFG_CCM_L_7; break ;
-    case 9:
-        *L = AES_CFG_CCM_L_6; break ;
-    case  10:
-        *L = AES_CFG_CCM_L_5; break ;
-    case 11:
-        *L = AES_CFG_CCM_L_4; break ;
-    case 12:
-        *L = AES_CFG_CCM_L_3; break ;
-    case 13:
-        *L = AES_CFG_CCM_L_2; break ;
-    case 14:
-        *L = AES_CFG_CCM_L_1; break ;
-    default:
-        return 1;
-    }
-    return 0 ;
-}
-
-static void AesAuthSetIv(Aes *aes, const byte *nonce, word32 len, word32 L, int mode) {
-
-  if(mode == AES_CFG_MODE_CCM){
-    XMEMSET(aes->reg, 0, 16) ;
-    switch(L){
-    case AES_CFG_CCM_L_8: 
-      aes->reg[0] = 0x7; break ;
-    case AES_CFG_CCM_L_7: 
-      aes->reg[0] = 0x6; break ;
-    case AES_CFG_CCM_L_6: 
-      aes->reg[0] = 0x5; break ;
-    case AES_CFG_CCM_L_5: 
-      aes->reg[0] = 0x4; break ;
-    case AES_CFG_CCM_L_4: 
-      aes->reg[0] = 0x3; break ;
-    case AES_CFG_CCM_L_3: 
-      aes->reg[0] = 0x2; break ;
-    case AES_CFG_CCM_L_2: 
-      aes->reg[0] = 0x1; break ;
-    case AES_CFG_CCM_L_1: 
-      aes->reg[0] = 0x0; break ;
-    }
-    XMEMCPY(((byte *)aes->reg)+1, nonce, len) ; 
-  } else {
-    byte *b = (byte *)aes->reg ;
-    XMEMSET(aes->reg, 0, AES_BLOCK_SIZE);
-    XMEMCPY(aes->reg, nonce, len);
-    b[AES_BLOCK_SIZE-4] = 0 ;
-    b[AES_BLOCK_SIZE-3] = 0 ;
-    b[AES_BLOCK_SIZE-2] = 0 ;
-    b[AES_BLOCK_SIZE-1] = 1 ;
-  }
-}
-
-#define RoundUp16(n) ((n+15)&0xfffffff0)
-#define FREE_ALL \
-    if(in_save)    XFREE(in_save, NULL, DYNAMIC_TYPE_TMP_BUFFER);\
-    if(out_save)   XFREE(out_save, NULL, DYNAMIC_TYPE_TMP_BUFFER);\
-    if(authIn_save)XFREE(authIn_save, NULL, DYNAMIC_TYPE_TMP_BUFFER);\
-    if(nonce_save) XFREE(nonce_save, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-
-static int AesAuthEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
-                              const byte* nonce, word32 nonceSz,
-                              byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz, int mode)
-{ 
-    word32 M, L ;
-    byte *in_a,     *in_save ;
-    byte *out_a,    *out_save ;
-    byte *authIn_a, *authIn_save ;
-    byte *nonce_a,    *nonce_save ;
-    word32 tmpTag[4] ;
-    int ret ;
-
-    if(AesAuthArgCheck(aes, out, in, inSz, nonce, nonceSz, authTag, authTagSz, authIn, authInSz, &M, &L)
-       == BAD_FUNC_ARG)return BAD_FUNC_ARG ;
-    
-    /* 16 byte padding */
-    in_save = NULL ; out_save = NULL ; authIn_save = NULL ; nonce_save = NULL ;
-    if((inSz%16)==0){
-        in_save = NULL ; in_a = (byte *)in ;
-        out_save = NULL ; out_a = out ;
-    } else {
-      if((in_save = XMALLOC(RoundUp16(inSz), NULL, DYNAMIC_TYPE_TMP_BUFFER)) == NULL){ 
-          FREE_ALL; return MEMORY_E ; }
-      in_a = in_save ; XMEMSET(in_a, 0, RoundUp16(inSz)) ; XMEMCPY(in_a, in, inSz) ;
-      
-      if((out_save = XMALLOC(RoundUp16(inSz), NULL, DYNAMIC_TYPE_TMP_BUFFER)) == NULL){ 
-          FREE_ALL; return MEMORY_E ; } 
-      out_a = out_save ; 
-    }
-    
-    if((authInSz%16)==0){
-        authIn_save = NULL ; authIn_a = (byte *)authIn ;
-    } else {
-      if((authIn_save = XMALLOC(RoundUp16(authInSz), NULL, DYNAMIC_TYPE_TMP_BUFFER)) == NULL){ 
-          FREE_ALL; return MEMORY_E ; }
-      authIn_a = authIn_save ; XMEMSET(authIn_a, 0, RoundUp16(authInSz)) ; XMEMCPY(authIn_a, authIn, authInSz) ;
-    }
-
-    if((nonceSz%16)==0){
-        nonce_save = NULL ; nonce_a = (byte *)nonce ;
-    } else {
-      if((nonce_save = XMALLOC(RoundUp16(nonceSz), NULL, DYNAMIC_TYPE_TMP_BUFFER)) == NULL){ 
-          FREE_ALL; return MEMORY_E; }
-      nonce_a = nonce_save ; XMEMSET(nonce_a, 0, RoundUp16(nonceSz)) ; XMEMCPY(nonce_a, nonce, nonceSz) ;
-    }
-
-    /* do aes-ccm */
-    AesAuthSetIv(aes, nonce, nonceSz, L, mode) ;
-    ROM_AESReset(AES_BASE);
-    ROM_AESConfigSet(AES_BASE, (aes->keylen | AES_CFG_DIR_ENCRYPT |
-                                AES_CFG_CTR_WIDTH_128 |
-                                mode | ((mode== AES_CFG_MODE_CCM) ? (L | M) : 0 ))) ;
-    ROM_AESIVSet(AES_BASE, aes->reg);
-    ROM_AESKey1Set(AES_BASE, aes->key, aes->keylen);
-    ret = ROM_AESDataProcessAuth(AES_BASE, (unsigned int*)in_a, (unsigned int *)out_a, inSz,
-                           (unsigned int*)authIn_a, authInSz, (unsigned int *)tmpTag);
-    if(ret == false){
-        XMEMSET(out, 0, inSz) ;
-        XMEMSET(authTag, 0, authTagSz) ;
-    } else {
-        XMEMCPY(out, out_a, inSz) ;
-        XMEMCPY(authTag, tmpTag, authTagSz) ;
-    }
-
-    FREE_ALL; 
-    return 0 ;
-}
-
-static int AesAuthDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
-                              const byte* nonce, word32 nonceSz,
-                              const byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz, int mode)
-{ 
-    word32 M, L ;
-    byte *in_a,     *in_save ;
-    byte *out_a,    *out_save ;
-    byte *authIn_a, *authIn_save ;
-    byte *nonce_a,    *nonce_save ;
-    word32 tmpTag[4] ;
-    bool ret ;
-
-    if(AesAuthArgCheck(aes, out, in, inSz, nonce, nonceSz, authTag, authTagSz, authIn, authInSz, &M, &L)
-       == BAD_FUNC_ARG)return  BAD_FUNC_ARG ;
-    
-    /* 16 byte padding */
-    in_save = NULL ; out_save = NULL ; authIn_save = NULL ; nonce_save = NULL ;
-    if((inSz%16)==0){
-        in_save = NULL ; in_a = (byte *)in ;
-        out_save = NULL ; out_a = out ;
-    } else {
-      if((in_save = XMALLOC(RoundUp16(inSz), NULL, DYNAMIC_TYPE_TMP_BUFFER)) == NULL){ 
-          FREE_ALL; return MEMORY_E;}
-      in_a = in_save ; XMEMSET(in_a, 0, RoundUp16(inSz)) ; XMEMCPY(in_a, in, inSz) ;
-      
-      if((out_save = XMALLOC(RoundUp16(inSz), NULL, DYNAMIC_TYPE_TMP_BUFFER)) == NULL){ 
-          FREE_ALL; return MEMORY_E;}
-      out_a = out_save ; 
-    }
-    
-    if((authInSz%16)==0){
-        authIn_save = NULL ; authIn_a = (byte *)authIn ;
-    } else {
-      if((authIn_save = XMALLOC(RoundUp16(authInSz), NULL, DYNAMIC_TYPE_TMP_BUFFER)) == NULL){ 
-          FREE_ALL; return MEMORY_E; }
-      authIn_a = authIn_save ; XMEMSET(authIn_a, 0, RoundUp16(authInSz)) ; XMEMCPY(authIn_a, authIn, authInSz) ;
-    }
-
-    if((nonceSz%16)==0){
-        nonce_save = NULL ; nonce_a = (byte *)nonce ;
-    } else {
-      if((nonce_save = XMALLOC(RoundUp16(nonceSz), NULL, DYNAMIC_TYPE_TMP_BUFFER)) == NULL){ 
-          FREE_ALL; return MEMORY_E; }
-      nonce_a = nonce_save ; XMEMSET(nonce_a, 0, RoundUp16(nonceSz)) ; XMEMCPY(nonce_a, nonce, nonceSz) ;
-    }
-
-    /* do aes-ccm */
-    AesAuthSetIv(aes, nonce, nonceSz, L, mode) ;
-    ROM_AESReset(AES_BASE);
-    ROM_AESConfigSet(AES_BASE, (aes->keylen | AES_CFG_DIR_DECRYPT |
-                                AES_CFG_CTR_WIDTH_128 |
-                                  mode | ((mode== AES_CFG_MODE_CCM) ? (L | M) : 0 ))) ;
-    ROM_AESIVSet(AES_BASE, aes->reg);
-    ROM_AESKey1Set(AES_BASE, aes->key, aes->keylen);
-    ret = ROM_AESDataProcessAuth(AES_BASE, (unsigned int*)in_a, (unsigned int *)out_a, inSz,
-                           (unsigned int*)authIn_a, authInSz, (unsigned int *)tmpTag);
-    if((ret == false) || (XMEMCMP(authTag, tmpTag, authTagSz) != 0)){
-        XMEMSET(out, 0, inSz) ;
-        ret = false ;
-    } else {
-        XMEMCPY(out, out_a, inSz) ;  
-    }
-
-    FREE_ALL ;
-    return ret==true ? 0 : 1 ;
-}
-#endif
-
-
-#ifdef HAVE_AESGCM
-WOLFSSL_API int  wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
-{
-    return AesAuthSetKey(aes, key, len) ;
-}
-
-WOLFSSL_API int  wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
-                              const byte* iv, word32 ivSz,
-                              byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz)
-{
-    return AesAuthEncrypt(aes, out, in, sz, iv, ivSz, authTag, authTagSz,
-                              authIn, authInSz, AES_CFG_MODE_GCM_HY0CALC) ;
-}
-WOLFSSL_API int  wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
-                              const byte* iv, word32 ivSz,
-                              const byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz)
-{ 
-    return AesAuthDecrypt(aes, out, in, sz, iv, ivSz, authTag, authTagSz,
-                              authIn, authInSz, AES_CFG_MODE_GCM_HY0CALC) ;
-}
-
-WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len)
-{
-      return AesAuthSetKey(&gmac->aes, key, len) ;
-}
-
-WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
-                              const byte* authIn, word32 authInSz,
-                              byte* authTag, word32 authTagSz)
-{
-    return AesAuthEncrypt(&gmac->aes, NULL, NULL, 0, iv, ivSz, authTag, authTagSz,
-                              authIn, authInSz, AES_CFG_MODE_GCM_HY0CALC) ;
-}
-
-#endif /* HAVE_AESGCM */
-
-#ifdef HAVE_AESCCM
-WOLFSSL_API void wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz)
-{
-    AesAuthSetKey(aes, key, keySz) ;
-}
-
-WOLFSSL_API void wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
-                              const byte* nonce, word32 nonceSz,
-                              byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz)
-{ 
-    AesAuthEncrypt(aes, out, in, inSz, nonce, nonceSz, authTag, authTagSz,
-                              authIn, authInSz, AES_CFG_MODE_CCM) ;
-}
-
-WOLFSSL_API int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
-                              const byte* nonce, word32 nonceSz,
-                              const byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz)
-{ 
-    return AesAuthDecrypt(aes, out, in, inSz, nonce, nonceSz, authTag, authTagSz,
-                              authIn, authInSz, AES_CFG_MODE_CCM) ;
-}
-#endif /* HAVE_AESCCM */
-
-#endif /* WOLFSSL_TI_CRYPT */
-
-#endif /* NO_AES */
-
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/port/ti/ti-ccm.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/port/ti/ti-ccm.c
deleted file mode 100755
index 09705cf..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/port/ti/ti-ccm.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* port/ti/ti_ccm.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#if defined(WOLFSSL_TI_CRYPT) ||  defined(WOLFSSL_TI_HASH)
-
-
-#include 
-#include 
-
-#include "driverlib/sysctl.h"
-#include "driverlib/rom_map.h"
-#include "driverlib/rom.h"
-
-#ifndef SINGLE_THREADED
-#include 
-    static wolfSSL_Mutex TI_CCM_Mutex ;
-#endif
-
-#define TIMEOUT  500000
-#define WAIT(stat) { volatile int i ; for(i=0; i
-#endif
-
-#include 
-
-#ifndef NO_DES
-
-#if defined(WOLFSSL_TI_CRYPT)
-#include 
-#include 
-
-#include 
-#include 
-#include 
-
-#include "inc/hw_des.h"
-#include "inc/hw_memmap.h"
-#include "inc/hw_ints.h"
-#include "driverlib/des.h"
-#include "driverlib/sysctl.h"
-#include "driverlib/rom_map.h"
-#include "driverlib/rom.h"
-
-static int  DesSetIV(Des* des, const byte* iv, int tri)
-{
-    if (des == NULL)
-        return BAD_FUNC_ARG;
-
-    if (iv)
-        XMEMCPY(des->reg, iv, tri == DES_CFG_TRIPLE ? DES3_IVLEN : DES_IVLEN);
-    else
-        XMEMSET(des->reg,  0, tri == DES_CFG_TRIPLE ? DES3_IVLEN : DES_IVLEN);
-
-    return 0;
-}
-
-static int  DesSetKey(Des* des, const byte* key, const byte* iv,int dir, int tri)
-{
-    if(!wolfSSL_TI_CCMInit())return 1 ;
-    if ((des == NULL) || (key == NULL) || (iv == NULL))
-        return BAD_FUNC_ARG;
-    if(!((dir == DES_ENCRYPTION) || (dir == DES_DECRYPTION)))
-        return BAD_FUNC_ARG;
-    
-    XMEMCPY(des->key, key, tri == DES_CFG_SINGLE ? DES_KEYLEN : DES3_KEYLEN) ;
-    return DesSetIV(des, iv, tri);
-}
-
-static int  DesCbcAlign16(Des* des, byte* out, const byte* in, word32 sz, word32 dir, word32 tri)
-{   
-
-    wolfSSL_TI_lockCCM() ;
-    ROM_DESReset(DES_BASE);
-    ROM_DESConfigSet(DES_BASE, (dir | DES_CFG_MODE_CBC | tri));
-    ROM_DESIVSet(DES_BASE, des->reg);
-    ROM_DESKeySet(DES_BASE, des->key);
-    if(dir == DES_CFG_DIR_DECRYPT)
-        /* if input and output same will overwrite input iv */
-        XMEMCPY(des->tmp, in + sz - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
-    ROM_DESDataProcess(DES_BASE, (uint32_t *)in, (uint32_t *)out, sz);
-    wolfSSL_TI_unlockCCM() ;
-    
-    /* store iv for next call */
-    if(dir == DES_CFG_DIR_ENCRYPT)
-        XMEMCPY(des->reg, out + sz - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
-    else
-        XMEMCPY(des->reg, des->tmp, DES_BLOCK_SIZE);
-    
-    return 0 ;
-}
-
-#define IS_ALIGN16(p) (((unsigned int)(p)&0xf) == 0)
-
-static int  DesCbc(Des* des, byte* out, const byte* in, word32 sz, word32 dir, word32 tri)
-{   
-    const byte * in_p ; byte * out_p ; 
-    word32 size ;
-    #define TI_BUFFSIZE 1024
-    byte buff[TI_BUFFSIZE] ;
-    if ((des == NULL) || (in == NULL) || (out == NULL))
-        return BAD_FUNC_ARG;
-    if(sz % DES_BLOCK_SIZE)
-        return BAD_FUNC_ARG;
-    
-    while(sz > 0) {
-        size = sz ; in_p = in ; out_p = out ;
-        if(!IS_ALIGN16(in)){
-            size = sz>TI_BUFFSIZE ? TI_BUFFSIZE : sz ;
-            XMEMCPY(buff, in, size) ; 
-            in_p = (const byte *)buff ;
-        }
-        if(!IS_ALIGN16(out)){
-            size = sz>TI_BUFFSIZE ? TI_BUFFSIZE : sz ;
-            out_p = (byte *)buff ;
-        }
-    
-        DesCbcAlign16(des, out_p, in_p, size, dir, tri) ;
-        
-        if(!IS_ALIGN16(out)){
-            XMEMCPY(out, buff, size) ;
-        }
-        sz -= size ; in += size ; out += size ;
-    }
-    return 0 ;
-}
-
-WOLFSSL_API int  wc_Des_SetKey(Des* des, const byte* key, const byte* iv,int dir)
-{
-    return DesSetKey(des, key, iv, dir, DES_CFG_SINGLE) ;
-}
-
-WOLFSSL_API void  wc_Des_SetIV(Des* des, const byte* iv)
-{
-    DesSetIV(des, iv, DES_CFG_SINGLE) ;
-}
-
-WOLFSSL_API int  wc_Des3_SetKey(Des3* des, const byte* key, const byte* iv,int dir)
-{
-    return DesSetKey((Des *)des, key, iv, dir, DES_CFG_TRIPLE) ;
-}
-
-WOLFSSL_API int  wc_Des3_SetIV(Des3* des, const byte* iv)
-{
-    return DesSetIV((Des *)des, iv, DES_CFG_TRIPLE) ;
-}
-
-
-WOLFSSL_API int  wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
-{   
-    return DesCbc(des, out, in, sz, DES_CFG_DIR_ENCRYPT, DES_CFG_SINGLE) ;
-}
-
-WOLFSSL_API int  wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
-{   
-    return DesCbc(des, out, in, sz, DES_CFG_DIR_DECRYPT, DES_CFG_SINGLE) ;
-}
-
-WOLFSSL_API int  wc_Des_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
-                                          const byte* key, const byte* iv)
-{ return 0 ;}
-
-WOLFSSL_API int  wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
-{   
-    return DesCbc((Des *)des, out, in, sz, DES_CFG_DIR_ENCRYPT, DES_CFG_TRIPLE) ;
-}
-
-WOLFSSL_API int  wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz)
-{   
-    return DesCbc((Des *)des, out, in, sz, DES_CFG_DIR_DECRYPT, DES_CFG_TRIPLE) ;
-}
-
-WOLFSSL_API int  wc_Des3_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
-                                               const byte* key, const byte* iv)
-{ return 0 ; }
-
-
-#endif /* WOLFSSL_TI_CRYPT */
-
-#endif /* NO_DES */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/port/ti/ti-hash.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/port/ti/ti-hash.c
deleted file mode 100755
index c60f864..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/port/ti/ti-hash.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/* port/ti/ti-hash.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#include 
-
-#if defined(WOLFSSL_TI_HASH)
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-#include 
-#include 
-
-#include 
-#include       
-#include       
-#include       
-#include 
-#include 
-#include 
-
-#ifndef TI_DUMMY_BUILD
-#include "inc/hw_memmap.h"
-#include "inc/hw_shamd5.h"
-#include "inc/hw_ints.h"
-#include "driverlib/shamd5.h"
-#include "driverlib/sysctl.h"
-#include "driverlib/rom_map.h"
-#include "driverlib/rom.h"
-#else
-#define SHAMD5_ALGO_MD5 1
-#define SHAMD5_ALGO_SHA1 2
-#define SHAMD5_ALGO_SHA256 3
-bool wolfSSL_TI_CCMInit(void) { return true ; }
-#endif
-
-static int hashInit(wolfssl_TI_Hash *hash) {
-    hash->used = 0 ;
-    hash->msg  = 0 ;
-    hash->len  = 0 ;
-    return 0 ;
-}
-
-static int hashUpdate(wolfssl_TI_Hash *hash, const byte* data, word32 len)
-{
-    void *p ;
-
-    if((hash== NULL) || (data == NULL))return BAD_FUNC_ARG;
-
-    if(hash->len < hash->used+len) {
-        if(hash->msg == NULL) {
-            p = XMALLOC(hash->used+len, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        } else {
-            p = XREALLOC(hash->msg, hash->used+len, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        }
-        if(p == 0)return 1 ;
-        hash->msg = p ;     
-        hash->len = hash->used+len ;
-    } 
-    XMEMCPY(hash->msg+hash->used, data, len) ;
-    hash->used += len ;
-    return 0 ;
-}
-
-static int hashGetHash(wolfssl_TI_Hash *hash, byte* result, word32 algo, word32 hsize)
-{   
-    uint32_t h[16] ;
-#ifndef TI_DUMMY_BUILD
-    wolfSSL_TI_lockCCM() ;
-    ROM_SHAMD5Reset(SHAMD5_BASE);
-    ROM_SHAMD5ConfigSet(SHAMD5_BASE, algo);
-    ROM_SHAMD5DataProcess(SHAMD5_BASE, 
-                   (uint32_t *)hash->msg, hash->used, h);
-    wolfSSL_TI_unlockCCM() ;
-#else
-    (void) hash ;
-    (void) algo ;
-#endif
-    XMEMCPY(result, h, hsize) ;
-
-    return 0 ;
-}
-
-static void hashRestorePos(wolfssl_TI_Hash *h1, wolfssl_TI_Hash *h2) {
-	h1->used = h2->used ;
-}
-
-static int hashFinal(wolfssl_TI_Hash *hash, byte* result, word32 algo, word32 hsize)
-{   
-    hashGetHash(hash, result, algo, hsize) ;
-    XFREE(hash->msg, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    hashInit(hash) ;
-    return 0 ;
-}
-
-static int hashHash(const byte* data, word32 len, byte* hash, word32 algo, word32 hsize)
-{
-    int ret = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    wolfssl_TI_Hash* hash_desc;
-#else
-    wolfssl_TI_Hash  hash_desc[1];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    hash_desc = (wolfssl_TI_Hash*)XMALLOC(sizeof(wolfssl_TI_Hash), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (hash_desc == NULL)
-        return MEMORY_E;
-#endif
-
-    if ((ret = hashInit(hash_desc)) != 0) {
-        WOLFSSL_MSG("Hash Init failed");
-    }
-    else {
-        hashUpdate(hash_desc, data, len);
-        hashFinal(hash_desc, hash, algo, hsize);
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(hash, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-#if !defined(NO_MD5)
-WOLFSSL_API void wc_InitMd5(Md5* md5)
-{
-    if (md5 == NULL)
-        return ;
-    if(!wolfSSL_TI_CCMInit())return  ;
-    hashInit((wolfssl_TI_Hash *)md5) ;
-}
-
-WOLFSSL_API void wc_Md5Update(Md5* md5, const byte* data, word32 len)
-{
-    hashUpdate((wolfssl_TI_Hash *)md5, data, len) ;
-}
-
-WOLFSSL_API void wc_Md5Final(Md5* md5, byte* hash)
-{
-    hashFinal((wolfssl_TI_Hash *)md5, hash, SHAMD5_ALGO_MD5, MD5_DIGEST_SIZE) ;
-}
-
-WOLFSSL_API void wc_Md5GetHash(Md5* md5, byte* hash)
-{
-    hashGetHash((wolfssl_TI_Hash *)md5, hash, SHAMD5_ALGO_MD5, MD5_DIGEST_SIZE) ;
-}
-
-WOLFSSL_API void wc_Md5RestorePos(Md5* m1, Md5* m2) {
-	hashRestorePos((wolfssl_TI_Hash *)m1, (wolfssl_TI_Hash *)m2) ;
-}
-
-WOLFSSL_API int wc_Md5Hash(const byte*data, word32 len, byte*hash)
-{ 
-    return hashHash(data, len, hash, SHAMD5_ALGO_MD5, MD5_DIGEST_SIZE) ;
-}
-
-#endif /* NO_MD5 */
-
-#if !defined(NO_SHA)
-WOLFSSL_API int wc_InitSha(Sha* sha)
-{
-    if (sha == NULL)
-        return 1 ;
-    if(!wolfSSL_TI_CCMInit())return 1 ;
-    return hashInit((wolfssl_TI_Hash *)sha) ;
-}
-
-WOLFSSL_API int wc_ShaUpdate(Sha* sha, const byte* data, word32 len)
-{
-    return hashUpdate((wolfssl_TI_Hash *)sha, data, len) ;
-}
-
-WOLFSSL_API int wc_ShaFinal(Sha* sha, byte* hash)
-{
-    return hashFinal((wolfssl_TI_Hash *)sha, hash, SHAMD5_ALGO_SHA1, SHA_DIGEST_SIZE) ;
-}
-
-WOLFSSL_API int wc_ShaGetHash(Sha* sha, byte* hash)
-{
-    return hashGetHash(sha, hash, SHAMD5_ALGO_SHA1, SHA_DIGEST_SIZE) ;
-}
-
-WOLFSSL_API void wc_ShaRestorePos(Sha* s1, Sha* s2) {
-	hashRestorePos((wolfssl_TI_Hash *)s1, (wolfssl_TI_Hash *)s2) ;
-}
-
-WOLFSSL_API int wc_ShaHash(const byte*data, word32 len, byte*hash)
-{ 
-    return hashHash(data, len, hash, SHAMD5_ALGO_SHA1, SHA_DIGEST_SIZE) ;
-}
-
-#endif /* NO_SHA */
-
-#if defined(HAVE_SHA224)
-WOLFSSL_API int wc_InitSha224(Sha224* sha224)
-{
-    if (sha224 == NULL)
-        return 1 ;
-    if(!wolfSSL_TI_CCMInit())return 1 ;
-    return hashInit((wolfssl_TI_Hash *)sha224) ;
-}
-
-WOLFSSL_API int wc_Sha224Update(Sha224* sha224, const byte* data, word32 len)
-{
-    return hashUpdate((wolfssl_TI_Hash *)sha224, data, len) ;
-}
-
-WOLFSSL_API int wc_Sha224Final(Sha224* sha224, byte* hash)
-{
-    return hashFinal((wolfssl_TI_Hash *)sha224, hash, SHAMD5_ALGO_SHA224, SHA224_DIGEST_SIZE) ;
-}
-
-WOLFSSL_API int wc_Sha224GetHash(Sha224* sha224, byte* hash)
-{
-    return hashGetHash(sha224, hash, SHAMD5_ALGO_SHA224, SHA224_DIGEST_SIZE) ;
-}
-
-WOLFSSL_API void wc_Sha224RestorePos(Sha224* s1, Sha224* s2) {
-	hashRestorePos((wolfssl_TI_Hash *)s1, (wolfssl_TI_Hash *)s2) ;
-}
-
-WOLFSSL_API int wc_Sha224Hash(const byte* data, word32 len, byte*hash)
-{ 
-    return hashHash(data, len, hash, SHAMD5_ALGO_SHA224, SHA224_DIGEST_SIZE) ;
-}
-
-#endif /* HAVE_SHA224 */
-
-#if !defined(NO_SHA256)
-WOLFSSL_API int wc_InitSha256(Sha256* sha256)
-{
-    if (sha256 == NULL)
-        return 1 ;
-    if(!wolfSSL_TI_CCMInit())return 1 ;
-    return hashInit((wolfssl_TI_Hash *)sha256) ;
-}
-
-WOLFSSL_API int wc_Sha256Update(Sha256* sha256, const byte* data, word32 len)
-{
-    return hashUpdate((wolfssl_TI_Hash *)sha256, data, len) ;
-}
-
-WOLFSSL_API int wc_Sha256Final(Sha256* sha256, byte* hash)
-{
-    return hashFinal((wolfssl_TI_Hash *)sha256, hash, SHAMD5_ALGO_SHA256, SHA256_DIGEST_SIZE) ;
-}
-
-WOLFSSL_API int wc_Sha256GetHash(Sha256* sha256, byte* hash)
-{
-    return hashGetHash(sha256, hash, SHAMD5_ALGO_SHA256, SHA256_DIGEST_SIZE) ;
-}
-
-WOLFSSL_API void wc_Sha256RestorePos(Sha256* s1, Sha256* s2) {
-	hashRestorePos((wolfssl_TI_Hash *)s1, (wolfssl_TI_Hash *)s2) ;
-}
-
-WOLFSSL_API int wc_Sha256Hash(const byte* data, word32 len, byte*hash)
-{
-    return hashHash(data, len, hash, SHAMD5_ALGO_SHA256, SHA256_DIGEST_SIZE) ;
-}
-#endif
-
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/pwdbased.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/pwdbased.c
deleted file mode 100755
index b9764d8..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/pwdbased.c
+++ /dev/null
@@ -1,562 +0,0 @@
-/* pwdbased.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef NO_PWDBASED
-
-#ifdef WOLFSSL_PIC32MZ_HASH
-    #ifndef NO_MD5
-        #define wc_InitMd5   wc_InitMd5_sw
-        #define wc_Md5Update wc_Md5Update_sw
-        #define wc_Md5Final  wc_Md5Final_sw
-    #endif /* NO_MD5 */
-
-    #define wc_InitSha   wc_InitSha_sw
-    #define wc_ShaUpdate wc_ShaUpdate_sw
-    #define wc_ShaFinal  wc_ShaFinal_sw
-
-    #define wc_InitSha256   wc_InitSha256_sw
-    #define wc_Sha256Update wc_Sha256Update_sw
-    #define wc_Sha256Final  wc_Sha256Final_sw
-#endif
-
-#include 
-#include 
-#include 
-#include 
-#if defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384)
-    #include 
-#endif
-
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-
-#ifndef NO_SHA
-/* PBKDF1 needs at least SHA available */
-int wc_PBKDF1(byte* output, const byte* passwd, int pLen, const byte* salt,
-           int sLen, int iterations, int kLen, int hashType)
-{
-    Sha  sha;
-#ifndef NO_MD5
-    Md5  md5;
-#endif
-    int  hLen = (int)SHA_DIGEST_SIZE;
-    int  i, ret = 0;
-    byte buffer[SHA_DIGEST_SIZE];  /* max size */
-
-    if (hashType != MD5 && hashType != SHA)
-        return BAD_FUNC_ARG;
-
-#ifndef NO_MD5
-    if (hashType == MD5)
-        hLen = (int)MD5_DIGEST_SIZE;
-#endif
-
-    if (kLen > hLen)
-        return BAD_FUNC_ARG;
-
-    if (iterations < 1)
-        return BAD_FUNC_ARG;
-
-    switch (hashType) {
-#ifndef NO_MD5
-        case MD5:
-            wc_InitMd5(&md5);
-            wc_Md5Update(&md5, passwd, pLen);
-            wc_Md5Update(&md5, salt,   sLen);
-            wc_Md5Final(&md5,  buffer);
-            break;
-#endif /* NO_MD5 */
-        case SHA:
-        default:
-            ret = wc_InitSha(&sha);
-            if (ret != 0)
-                return ret;
-            wc_ShaUpdate(&sha, passwd, pLen);
-            wc_ShaUpdate(&sha, salt,   sLen);
-            wc_ShaFinal(&sha,  buffer);
-            break;
-    }
-
-    for (i = 1; i < iterations; i++) {
-        if (hashType == SHA) {
-            wc_ShaUpdate(&sha, buffer, hLen);
-            wc_ShaFinal(&sha,  buffer);
-        }
-#ifndef NO_MD5
-        else {
-            wc_Md5Update(&md5, buffer, hLen);
-            wc_Md5Final(&md5,  buffer);
-        }
-#endif
-    }
-    XMEMCPY(output, buffer, kLen);
-
-    return 0;
-}
-#endif /* NO_SHA */
-
-
-int GetDigestSize(int hashType)
-{
-    int hLen;
-
-    switch (hashType) {
-#ifndef NO_MD5
-        case MD5:
-            hLen = MD5_DIGEST_SIZE;
-            break;
-#endif
-#ifndef NO_SHA
-        case SHA:
-            hLen = SHA_DIGEST_SIZE;
-            break;
-#endif
-#ifndef NO_SHA256
-        case SHA256:
-            hLen = SHA256_DIGEST_SIZE;
-            break;
-#endif
-#ifdef WOLFSSL_SHA512
-        case SHA512:
-            hLen = SHA512_DIGEST_SIZE;
-            break;
-#endif
-        default:
-            return BAD_FUNC_ARG;
-    }
-
-    return hLen;
-}
-
-
-int wc_PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt,
-           int sLen, int iterations, int kLen, int hashType)
-{
-    word32 i = 1;
-    int    hLen;
-    int    j, ret;
-    Hmac   hmac;
-#ifdef WOLFSSL_SMALL_STACK
-    byte*  buffer;
-#else
-    byte   buffer[MAX_DIGEST_SIZE];
-#endif
-
-    hLen = GetDigestSize(hashType);
-    if (hLen < 0)
-        return BAD_FUNC_ARG;
-
-#ifdef WOLFSSL_SMALL_STACK
-    buffer = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (buffer == NULL)
-        return MEMORY_E;
-#endif
-
-    ret = wc_HmacSetKey(&hmac, hashType, passwd, pLen);
-
-    if (ret == 0) {
-        while (kLen) {
-            int currentLen;
-
-            ret = wc_HmacUpdate(&hmac, salt, sLen);
-            if (ret != 0)
-                break;
-
-            /* encode i */
-            for (j = 0; j < 4; j++) {
-                byte b = (byte)(i >> ((3-j) * 8));
-
-                ret = wc_HmacUpdate(&hmac, &b, 1);
-                if (ret != 0)
-                    break;
-            }
-
-            /* check ret from inside for loop */
-            if (ret != 0)
-                break;
-
-            ret = wc_HmacFinal(&hmac, buffer);
-            if (ret != 0)
-                break;
-
-            currentLen = min(kLen, hLen);
-            XMEMCPY(output, buffer, currentLen);
-
-            for (j = 1; j < iterations; j++) {
-                ret = wc_HmacUpdate(&hmac, buffer, hLen);
-                if (ret != 0)
-                    break;
-                ret = wc_HmacFinal(&hmac, buffer);
-                if (ret != 0)
-                    break;
-                xorbuf(output, buffer, currentLen);
-            }
-
-            /* check ret from inside for loop */
-            if (ret != 0)
-                break;
-
-            output += currentLen;
-            kLen   -= currentLen;
-            i++;
-        }
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-#ifdef WOLFSSL_SHA512
-    #define PBKDF_DIGEST_SIZE SHA512_BLOCK_SIZE
-#elif !defined(NO_SHA256)
-    #define PBKDF_DIGEST_SIZE SHA256_BLOCK_SIZE
-#else
-    #define PBKDF_DIGEST_SIZE SHA_DIGEST_SIZE
-#endif
-
-/* helper for wc_PKCS12_PBKDF(), sets block and digest sizes */
-int GetPKCS12HashSizes(int hashType, word32* v, word32* u)
-{
-    if (!v || !u)
-        return BAD_FUNC_ARG;
-
-    switch (hashType) {
-#ifndef NO_MD5
-        case MD5:
-            *v = MD5_BLOCK_SIZE;
-            *u = MD5_DIGEST_SIZE;
-            break;
-#endif
-#ifndef NO_SHA
-        case SHA:
-            *v = SHA_BLOCK_SIZE;
-            *u = SHA_DIGEST_SIZE;
-            break;
-#endif
-#ifndef NO_SHA256
-        case SHA256:
-            *v = SHA256_BLOCK_SIZE;
-            *u = SHA256_DIGEST_SIZE;
-            break;
-#endif
-#ifdef WOLFSSL_SHA512
-        case SHA512:
-            *v = SHA512_BLOCK_SIZE;
-            *u = SHA512_DIGEST_SIZE;
-            break;
-#endif
-        default:
-            return BAD_FUNC_ARG;
-    }
-
-    return 0;
-}
-
-/* helper for PKCS12_PBKDF(), does hash operation */
-int DoPKCS12Hash(int hashType, byte* buffer, word32 totalLen,
-                 byte* Ai, word32 u, int iterations)
-{
-    int i;
-    int ret = 0;
-
-    if (buffer == NULL || Ai == NULL)
-        return BAD_FUNC_ARG;
-
-    switch (hashType) {
-#ifndef NO_MD5
-        case MD5:
-            {
-                Md5 md5;
-                wc_InitMd5(&md5);
-                wc_Md5Update(&md5, buffer, totalLen);
-                wc_Md5Final(&md5, Ai);
-
-                for (i = 1; i < iterations; i++) {
-                    wc_Md5Update(&md5, Ai, u);
-                    wc_Md5Final(&md5, Ai);
-                }
-            }
-            break;
-#endif /* NO_MD5 */
-#ifndef NO_SHA
-        case SHA:
-            {
-                Sha sha;
-                ret = wc_InitSha(&sha);
-                if (ret != 0)
-                    break;
-                wc_ShaUpdate(&sha, buffer, totalLen);
-                wc_ShaFinal(&sha, Ai);
-
-                for (i = 1; i < iterations; i++) {
-                    wc_ShaUpdate(&sha, Ai, u);
-                    wc_ShaFinal(&sha, Ai);
-                }
-            }
-            break;
-#endif /* NO_SHA */
-#ifndef NO_SHA256
-        case SHA256:
-            {
-                Sha256 sha256;
-                ret = wc_InitSha256(&sha256);
-                if (ret != 0)
-                    break;
-
-                ret = wc_Sha256Update(&sha256, buffer, totalLen);
-                if (ret != 0)
-                    break;
-
-                ret = wc_Sha256Final(&sha256, Ai);
-                if (ret != 0)
-                    break;
-
-                for (i = 1; i < iterations; i++) {
-                    ret = wc_Sha256Update(&sha256, Ai, u);
-                    if (ret != 0)
-                        break;
-
-                    ret = wc_Sha256Final(&sha256, Ai);
-                    if (ret != 0)
-                        break;
-                }
-            }
-            break;
-#endif /* NO_SHA256 */
-#ifdef WOLFSSL_SHA512
-        case SHA512:
-            {
-                Sha512 sha512;
-                ret = wc_InitSha512(&sha512);
-                if (ret != 0)
-                    break;
-
-                ret = wc_Sha512Update(&sha512, buffer, totalLen);
-                if (ret != 0)
-                    break;
-
-                ret = wc_Sha512Final(&sha512, Ai);
-                if (ret != 0)
-                    break;
-
-                for (i = 1; i < iterations; i++) {
-                    ret = wc_Sha512Update(&sha512, Ai, u);
-                    if (ret != 0)
-                        break;
-
-                    ret = wc_Sha512Final(&sha512, Ai);
-                    if (ret != 0)
-                        break;
-                }
-            }
-            break;
-#endif /* WOLFSSL_SHA512 */
-
-        default:
-            ret = BAD_FUNC_ARG;
-            break;
-    }
-
-    return ret;
-}
-
-int wc_PKCS12_PBKDF(byte* output, const byte* passwd, int passLen,const byte* salt,
-                 int saltLen, int iterations, int kLen, int hashType, int id)
-{
-    /* all in bytes instead of bits */
-    word32 u, v, dLen, pLen, iLen, sLen, totalLen;
-    int    dynamic = 0;
-    int    ret = 0;
-    int    i;
-    byte   *D, *S, *P, *I;
-#ifdef WOLFSSL_SMALL_STACK
-    byte   staticBuffer[1]; /* force dynamic usage */
-#else
-    byte   staticBuffer[1024];
-#endif
-    byte*  buffer = staticBuffer;
-
-#ifdef WOLFSSL_SMALL_STACK
-    byte*  Ai;
-    byte*  B;
-#else
-    byte   Ai[PBKDF_DIGEST_SIZE];
-    byte   B[PBKDF_DIGEST_SIZE];
-#endif
-
-    if (!iterations)
-        iterations = 1;
-
-    ret = GetPKCS12HashSizes(hashType, &v, &u);
-    if (ret < 0)
-        return BAD_FUNC_ARG;
-
-#ifdef WOLFSSL_SMALL_STACK
-    Ai = (byte*)XMALLOC(PBKDF_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (Ai == NULL)
-        return MEMORY_E;
-
-    B = (byte*)XMALLOC(PBKDF_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (B == NULL) {
-        XFREE(Ai, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#endif
-
-    XMEMSET(Ai, 0, PBKDF_DIGEST_SIZE);
-    XMEMSET(B,  0, PBKDF_DIGEST_SIZE);
-
-    dLen = v;
-    sLen =  v * ((saltLen + v - 1) / v);
-    if (passLen)
-        pLen = v * ((passLen + v - 1) / v);
-    else
-        pLen = 0;
-    iLen = sLen + pLen;
-
-    totalLen = dLen + sLen + pLen;
-
-    if (totalLen > sizeof(staticBuffer)) {
-        buffer = (byte*)XMALLOC(totalLen, 0, DYNAMIC_TYPE_KEY);
-        if (buffer == NULL) {
-#ifdef WOLFSSL_SMALL_STACK
-            XFREE(Ai, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-            XFREE(B,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-            return MEMORY_E;
-        }
-        dynamic = 1;
-    }
-
-    D = buffer;
-    S = D + dLen;
-    P = S + sLen;
-    I = S;
-
-    XMEMSET(D, id, dLen);
-
-    for (i = 0; i < (int)sLen; i++)
-        S[i] = salt[i % saltLen];
-    for (i = 0; i < (int)pLen; i++)
-        P[i] = passwd[i % passLen];
-
-    while (kLen > 0) {
-        word32 currentLen;
-        mp_int B1;
-
-        ret = DoPKCS12Hash(hashType, buffer, totalLen, Ai, u, iterations);
-        if (ret < 0)
-            break;
-
-        for (i = 0; i < (int)v; i++)
-            B[i] = Ai[i % u];
-
-        if (mp_init(&B1) != MP_OKAY)
-            ret = MP_INIT_E;
-        else if (mp_read_unsigned_bin(&B1, B, v) != MP_OKAY)
-            ret = MP_READ_E;
-        else if (mp_add_d(&B1, (mp_digit)1, &B1) != MP_OKAY)
-            ret = MP_ADD_E;
-
-        if (ret != 0) {
-            mp_clear(&B1);
-            break;
-        }
-
-        for (i = 0; i < (int)iLen; i += v) {
-            int    outSz;
-            mp_int i1;
-            mp_int res;
-
-            if (mp_init_multi(&i1, &res, NULL, NULL, NULL, NULL) != MP_OKAY) {
-                ret = MP_INIT_E;
-                break;
-            }
-            if (mp_read_unsigned_bin(&i1, I + i, v) != MP_OKAY)
-                ret = MP_READ_E;
-            else if (mp_add(&i1, &B1, &res) != MP_OKAY)
-                ret = MP_ADD_E;
-            else if ( (outSz = mp_unsigned_bin_size(&res)) < 0)
-                ret = MP_TO_E;
-            else {
-                if (outSz > (int)v) {
-                    /* take off MSB */
-                    byte  tmp[129];
-                    ret = mp_to_unsigned_bin(&res, tmp);
-                    XMEMCPY(I + i, tmp + 1, v);
-                }
-                else if (outSz < (int)v) {
-                    XMEMSET(I + i, 0, v - outSz);
-                    ret = mp_to_unsigned_bin(&res, I + i + v - outSz);
-                }
-                else
-                    ret = mp_to_unsigned_bin(&res, I + i);
-            }
-
-            mp_clear(&i1);
-            mp_clear(&res);
-            if (ret < 0) break;
-        }
-
-        currentLen = min(kLen, (int)u);
-        XMEMCPY(output, Ai, currentLen);
-        output += currentLen;
-        kLen   -= currentLen;
-        mp_clear(&B1);
-    }
-
-    if (dynamic) XFREE(buffer, 0, DYNAMIC_TYPE_KEY);
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(Ai, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(B,  NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-#undef PBKDF_DIGEST_SIZE
-
-#endif /* NO_PWDBASED */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/rabbit.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/rabbit.c
deleted file mode 100755
index fc78611..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/rabbit.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/* rabbit.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef NO_RABBIT
-
-#include 
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-
-#ifdef BIG_ENDIAN_ORDER
-    #define LITTLE32(x) ByteReverseWord32(x)
-#else
-    #define LITTLE32(x) (x)
-#endif
-
-#define U32V(x) ((word32)(x) & 0xFFFFFFFFU)
-
-
-/* Square a 32-bit unsigned integer to obtain the 64-bit result and return */
-/* the upper 32 bits XOR the lower 32 bits */
-static word32 RABBIT_g_func(word32 x)
-{
-    /* Temporary variables */
-    word32 a, b, h, l;
-
-    /* Construct high and low argument for squaring */
-    a = x&0xFFFF;
-    b = x>>16;
-
-    /* Calculate high and low result of squaring */
-    h = (((U32V(a*a)>>17) + U32V(a*b))>>15) + b*b;
-    l = x*x;
-
-    /* Return high XOR low */
-    return U32V(h^l);
-}
-
-
-/* Calculate the next internal state */
-static void RABBIT_next_state(RabbitCtx* ctx)
-{
-    /* Temporary variables */
-    word32 g[8], c_old[8], i;
-
-    /* Save old counter values */
-    for (i=0; i<8; i++)
-        c_old[i] = ctx->c[i];
-
-    /* Calculate new counter values */
-    ctx->c[0] = U32V(ctx->c[0] + 0x4D34D34D + ctx->carry);
-    ctx->c[1] = U32V(ctx->c[1] + 0xD34D34D3 + (ctx->c[0] < c_old[0]));
-    ctx->c[2] = U32V(ctx->c[2] + 0x34D34D34 + (ctx->c[1] < c_old[1]));
-    ctx->c[3] = U32V(ctx->c[3] + 0x4D34D34D + (ctx->c[2] < c_old[2]));
-    ctx->c[4] = U32V(ctx->c[4] + 0xD34D34D3 + (ctx->c[3] < c_old[3]));
-    ctx->c[5] = U32V(ctx->c[5] + 0x34D34D34 + (ctx->c[4] < c_old[4]));
-    ctx->c[6] = U32V(ctx->c[6] + 0x4D34D34D + (ctx->c[5] < c_old[5]));
-    ctx->c[7] = U32V(ctx->c[7] + 0xD34D34D3 + (ctx->c[6] < c_old[6]));
-    ctx->carry = (ctx->c[7] < c_old[7]);
-   
-    /* Calculate the g-values */
-    for (i=0;i<8;i++)
-        g[i] = RABBIT_g_func(U32V(ctx->x[i] + ctx->c[i]));
-
-    /* Calculate new state values */
-    ctx->x[0] = U32V(g[0] + rotlFixed(g[7],16) + rotlFixed(g[6], 16));
-    ctx->x[1] = U32V(g[1] + rotlFixed(g[0], 8) + g[7]);
-    ctx->x[2] = U32V(g[2] + rotlFixed(g[1],16) + rotlFixed(g[0], 16));
-    ctx->x[3] = U32V(g[3] + rotlFixed(g[2], 8) + g[1]);
-    ctx->x[4] = U32V(g[4] + rotlFixed(g[3],16) + rotlFixed(g[2], 16));
-    ctx->x[5] = U32V(g[5] + rotlFixed(g[4], 8) + g[3]);
-    ctx->x[6] = U32V(g[6] + rotlFixed(g[5],16) + rotlFixed(g[4], 16));
-    ctx->x[7] = U32V(g[7] + rotlFixed(g[6], 8) + g[5]);
-}
-
-
-/* IV setup */
-static void wc_RabbitSetIV(Rabbit* ctx, const byte* inIv)
-{
-    /* Temporary variables */
-    word32 i0, i1, i2, i3, i;
-    word32 iv[2];
-
-    if (inIv)
-        XMEMCPY(iv, inIv, sizeof(iv));
-    else
-        XMEMSET(iv,    0, sizeof(iv));
-      
-    /* Generate four subvectors */
-    i0 = LITTLE32(iv[0]);
-    i2 = LITTLE32(iv[1]);
-    i1 = (i0>>16) | (i2&0xFFFF0000);
-    i3 = (i2<<16) | (i0&0x0000FFFF);
-
-    /* Modify counter values */
-    ctx->workCtx.c[0] = ctx->masterCtx.c[0] ^ i0;
-    ctx->workCtx.c[1] = ctx->masterCtx.c[1] ^ i1;
-    ctx->workCtx.c[2] = ctx->masterCtx.c[2] ^ i2;
-    ctx->workCtx.c[3] = ctx->masterCtx.c[3] ^ i3;
-    ctx->workCtx.c[4] = ctx->masterCtx.c[4] ^ i0;
-    ctx->workCtx.c[5] = ctx->masterCtx.c[5] ^ i1;
-    ctx->workCtx.c[6] = ctx->masterCtx.c[6] ^ i2;
-    ctx->workCtx.c[7] = ctx->masterCtx.c[7] ^ i3;
-
-    /* Copy state variables */
-    for (i=0; i<8; i++)
-        ctx->workCtx.x[i] = ctx->masterCtx.x[i];
-    ctx->workCtx.carry = ctx->masterCtx.carry;
-
-    /* Iterate the system four times */
-    for (i=0; i<4; i++)
-        RABBIT_next_state(&(ctx->workCtx));
-}
-
-
-/* Key setup */
-static INLINE int DoKey(Rabbit* ctx, const byte* key, const byte* iv)
-{
-    /* Temporary variables */
-    word32 k0, k1, k2, k3, i;
-
-    /* Generate four subkeys */
-    k0 = LITTLE32(*(word32*)(key+ 0));
-    k1 = LITTLE32(*(word32*)(key+ 4));
-    k2 = LITTLE32(*(word32*)(key+ 8));
-    k3 = LITTLE32(*(word32*)(key+12));
-
-    /* Generate initial state variables */
-    ctx->masterCtx.x[0] = k0;
-    ctx->masterCtx.x[2] = k1;
-    ctx->masterCtx.x[4] = k2;
-    ctx->masterCtx.x[6] = k3;
-    ctx->masterCtx.x[1] = U32V(k3<<16) | (k2>>16);
-    ctx->masterCtx.x[3] = U32V(k0<<16) | (k3>>16);
-    ctx->masterCtx.x[5] = U32V(k1<<16) | (k0>>16);
-    ctx->masterCtx.x[7] = U32V(k2<<16) | (k1>>16);
-
-    /* Generate initial counter values */
-    ctx->masterCtx.c[0] = rotlFixed(k2, 16);
-    ctx->masterCtx.c[2] = rotlFixed(k3, 16);
-    ctx->masterCtx.c[4] = rotlFixed(k0, 16);
-    ctx->masterCtx.c[6] = rotlFixed(k1, 16);
-    ctx->masterCtx.c[1] = (k0&0xFFFF0000) | (k1&0xFFFF);
-    ctx->masterCtx.c[3] = (k1&0xFFFF0000) | (k2&0xFFFF);
-    ctx->masterCtx.c[5] = (k2&0xFFFF0000) | (k3&0xFFFF);
-    ctx->masterCtx.c[7] = (k3&0xFFFF0000) | (k0&0xFFFF);
-
-    /* Clear carry bit */
-    ctx->masterCtx.carry = 0;
-
-    /* Iterate the system four times */
-    for (i=0; i<4; i++)
-        RABBIT_next_state(&(ctx->masterCtx));
-
-    /* Modify the counters */
-    for (i=0; i<8; i++)
-        ctx->masterCtx.c[i] ^= ctx->masterCtx.x[(i+4)&0x7];
-
-    /* Copy master instance to work instance */
-    for (i=0; i<8; i++) {
-        ctx->workCtx.x[i] = ctx->masterCtx.x[i];
-        ctx->workCtx.c[i] = ctx->masterCtx.c[i];
-    }
-    ctx->workCtx.carry = ctx->masterCtx.carry;
-
-    wc_RabbitSetIV(ctx, iv);
-
-    return 0;
-}
-
-
-/* Key setup */
-int wc_RabbitSetKey(Rabbit* ctx, const byte* key, const byte* iv)
-{
-#ifdef XSTREAM_ALIGN
-    if ((wolfssl_word)key % 4) {
-        int alignKey[4];
-
-        /* iv aligned in SetIV */
-        WOLFSSL_MSG("wc_RabbitSetKey unaligned key");
-
-        XMEMCPY(alignKey, key, sizeof(alignKey));
-
-        return DoKey(ctx, (const byte*)alignKey, iv);
-    }
-#endif /* XSTREAM_ALIGN */
-
-    return DoKey(ctx, key, iv);
-}
-
-
-/* Encrypt/decrypt a message of any size */
-static INLINE int DoProcess(Rabbit* ctx, byte* output, const byte* input,
-                            word32 msglen)
-{
-    /* Encrypt/decrypt all full blocks */
-    while (msglen >= 16) {
-        /* Iterate the system */
-        RABBIT_next_state(&(ctx->workCtx));
-
-        /* Encrypt/decrypt 16 bytes of data */
-        *(word32*)(output+ 0) = *(word32*)(input+ 0) ^
-                   LITTLE32(ctx->workCtx.x[0] ^ (ctx->workCtx.x[5]>>16) ^
-                   U32V(ctx->workCtx.x[3]<<16));
-        *(word32*)(output+ 4) = *(word32*)(input+ 4) ^
-                   LITTLE32(ctx->workCtx.x[2] ^ (ctx->workCtx.x[7]>>16) ^
-                   U32V(ctx->workCtx.x[5]<<16));
-        *(word32*)(output+ 8) = *(word32*)(input+ 8) ^
-                   LITTLE32(ctx->workCtx.x[4] ^ (ctx->workCtx.x[1]>>16) ^
-                   U32V(ctx->workCtx.x[7]<<16));
-        *(word32*)(output+12) = *(word32*)(input+12) ^
-                   LITTLE32(ctx->workCtx.x[6] ^ (ctx->workCtx.x[3]>>16) ^
-                   U32V(ctx->workCtx.x[1]<<16));
-
-        /* Increment pointers and decrement length */
-        input  += 16;
-        output += 16;
-        msglen -= 16;
-    }
-
-    /* Encrypt/decrypt remaining data */
-    if (msglen) {
-
-        word32 i;
-        word32 tmp[4];
-        byte*  buffer = (byte*)tmp;
-
-        XMEMSET(tmp, 0, sizeof(tmp));   /* help static analysis */
-
-        /* Iterate the system */
-        RABBIT_next_state(&(ctx->workCtx));
-
-        /* Generate 16 bytes of pseudo-random data */
-        tmp[0] = LITTLE32(ctx->workCtx.x[0] ^
-                  (ctx->workCtx.x[5]>>16) ^ U32V(ctx->workCtx.x[3]<<16));
-        tmp[1] = LITTLE32(ctx->workCtx.x[2] ^ 
-                  (ctx->workCtx.x[7]>>16) ^ U32V(ctx->workCtx.x[5]<<16));
-        tmp[2] = LITTLE32(ctx->workCtx.x[4] ^ 
-                  (ctx->workCtx.x[1]>>16) ^ U32V(ctx->workCtx.x[7]<<16));
-        tmp[3] = LITTLE32(ctx->workCtx.x[6] ^ 
-                  (ctx->workCtx.x[3]>>16) ^ U32V(ctx->workCtx.x[1]<<16));
-
-        /* Encrypt/decrypt the data */
-        for (i=0; i
-#endif
- 
-#include 
-
-/* on HPUX 11 you may need to install /dev/random see
-   http://h20293.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=KRNG11I
-
-*/
-
-#include 
-
-#ifdef HAVE_FIPS
-int wc_GenerateSeed(OS_Seed* os, byte* seed, word32 sz)
-{
-    return GenerateSeed(os, seed, sz);
-}
-
-#ifdef HAVE_CAVIUM
-    int  wc_InitRngCavium(RNG* rng, int i)
-    {
-        return InitRngCavium(rng, i);
-    }
-#endif
-
-
-int  wc_InitRng(RNG* rng)
-{
-    return InitRng_fips(rng);
-}
-
-
-int  wc_RNG_GenerateBlock(RNG* rng, byte* b, word32 sz)
-{
-    return RNG_GenerateBlock_fips(rng, b, sz);
-}
-
-
-int  wc_RNG_GenerateByte(RNG* rng, byte* b)
-{
-    return RNG_GenerateByte(rng, b);
-}
-
-#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
-
-    int wc_FreeRng(RNG* rng)
-    {
-        return FreeRng_fips(rng);
-    }
-
-
-    int wc_RNG_HealthTest(int reseed,
-                                        const byte* entropyA, word32 entropyASz,
-                                        const byte* entropyB, word32 entropyBSz,
-                                        byte* output, word32 outputSz)
-    {
-        return RNG_HealthTest_fips(reseed, entropyA, entropyASz,
-                              entropyB, entropyBSz, output, outputSz);
-    }
-#endif /* HAVE_HASHDRBG || NO_RC4 */
-#else /* else build without fips */
-#include 
-
-#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
-
-    #include 
-
-    #ifdef NO_INLINE
-        #include 
-    #else
-        #include 
-    #endif
-#endif /* HAVE_HASHDRBG || NO_RC4 */
-
-#if defined(USE_WINDOWS_API)
-    #ifndef _WIN32_WINNT
-        #define _WIN32_WINNT 0x0400
-    #endif
-    #include 
-    #include 
-#else
-    #if !defined(NO_DEV_RANDOM) && !defined(CUSTOM_RAND_GENERATE) && \
-                          !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_IAR_ARM)
-            #include 
-        #ifndef EBSNET
-            #include 
-        #endif
-    #else
-        /* include headers that may be needed to get good seed */
-    #endif
-#endif /* USE_WINDOWS_API */
-    
-#ifdef HAVE_INTEL_RDGEN
-    static int wc_InitRng_IntelRD(void) ;
-    #if defined(HAVE_HASHDRBG) || defined(NO_RC4)
-	static int wc_GenerateSeed_IntelRD(OS_Seed* os, byte* output, word32 sz) ;
-    #else
-    static int wc_GenerateRand_IntelRD(OS_Seed* os, byte* output, word32 sz) ;
-    #endif
-    static word32 cpuid_check = 0 ;
-    static word32 cpuid_flags = 0 ;
-    #define CPUID_RDRAND 0x4
-    #define CPUID_RDSEED 0x8
-    #define IS_INTEL_RDRAND     (cpuid_flags&CPUID_RDRAND)
-    #define IS_INTEL_RDSEED     (cpuid_flags&CPUID_RDSEED)
-#endif
-
-#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
-
-/* Start NIST DRBG code */
-
-#define OUTPUT_BLOCK_LEN  (SHA256_DIGEST_SIZE)
-#define MAX_REQUEST_LEN   (0x10000)
-#define RESEED_INTERVAL   (1000000)
-#define SECURITY_STRENGTH (256)
-#define ENTROPY_SZ        (SECURITY_STRENGTH/8)
-#define NONCE_SZ          (ENTROPY_SZ/2)
-#define ENTROPY_NONCE_SZ  (ENTROPY_SZ+NONCE_SZ)
-
-/* Internal return codes */
-#define DRBG_SUCCESS      0
-#define DRBG_ERROR        1
-#define DRBG_FAILURE      2
-#define DRBG_NEED_RESEED  3
-#define DRBG_CONT_FAILURE 4
-
-/* RNG health states */
-#define DRBG_NOT_INIT     0
-#define DRBG_OK           1
-#define DRBG_FAILED       2
-#define DRBG_CONT_FAILED  3
-
-
-enum {
-    drbgInitC     = 0,
-    drbgReseed    = 1,
-    drbgGenerateW = 2,
-    drbgGenerateH = 3,
-    drbgInitV
-};
-
-
-typedef struct DRBG {
-    word32 reseedCtr;
-    word32 lastBlock;
-    byte V[DRBG_SEED_LEN];
-    byte C[DRBG_SEED_LEN];
-    byte   matchCount;
-} DRBG;
-
-
-static int wc_RNG_HealthTestLocal(int reseed);
-
-/* Hash Derivation Function */
-/* Returns: DRBG_SUCCESS or DRBG_FAILURE */
-static int Hash_df(DRBG* drbg, byte* out, word32 outSz, byte type,
-                                                  const byte* inA, word32 inASz,
-                                                  const byte* inB, word32 inBSz)
-{
-    byte ctr;
-    int i;
-    int len;
-    word32 bits = (outSz * 8); /* reverse byte order */
-    Sha256 sha;
-    byte digest[SHA256_DIGEST_SIZE];
-
-    (void)drbg;
-    #ifdef LITTLE_ENDIAN_ORDER
-        bits = ByteReverseWord32(bits);
-    #endif
-    len = (outSz / OUTPUT_BLOCK_LEN)
-        + ((outSz % OUTPUT_BLOCK_LEN) ? 1 : 0);
-
-    for (i = 0, ctr = 1; i < len; i++, ctr++)
-    {
-        if (wc_InitSha256(&sha) != 0)
-            return DRBG_FAILURE;
-
-        if (wc_Sha256Update(&sha, &ctr, sizeof(ctr)) != 0)
-            return DRBG_FAILURE;
-
-        if (wc_Sha256Update(&sha, (byte*)&bits, sizeof(bits)) != 0)
-            return DRBG_FAILURE;
-
-        /* churning V is the only string that doesn't have the type added */
-        if (type != drbgInitV)
-            if (wc_Sha256Update(&sha, &type, sizeof(type)) != 0)
-                return DRBG_FAILURE;
-
-        if (wc_Sha256Update(&sha, inA, inASz) != 0)
-            return DRBG_FAILURE;
-
-        if (inB != NULL && inBSz > 0)
-            if (wc_Sha256Update(&sha, inB, inBSz) != 0)
-                return DRBG_FAILURE;
-
-        if (wc_Sha256Final(&sha, digest) != 0)
-            return DRBG_FAILURE;
-
-        if (outSz > OUTPUT_BLOCK_LEN) {
-            XMEMCPY(out, digest, OUTPUT_BLOCK_LEN);
-            outSz -= OUTPUT_BLOCK_LEN;
-            out += OUTPUT_BLOCK_LEN;
-        }
-        else {
-            XMEMCPY(out, digest, outSz);
-        }
-    }
-    ForceZero(digest, sizeof(digest));
-
-    return DRBG_SUCCESS;
-}
-
-
-/* Returns: DRBG_SUCCESS or DRBG_FAILURE */
-static int Hash_DRBG_Reseed(DRBG* drbg, const byte* entropy, word32 entropySz)
-{
-    byte seed[DRBG_SEED_LEN];
-
-    if (Hash_df(drbg, seed, sizeof(seed), drbgReseed, drbg->V, sizeof(drbg->V),
-                                          entropy, entropySz) != DRBG_SUCCESS) {
-        return DRBG_FAILURE;
-    }
-
-    XMEMCPY(drbg->V, seed, sizeof(drbg->V));
-    ForceZero(seed, sizeof(seed));
-
-    if (Hash_df(drbg, drbg->C, sizeof(drbg->C), drbgInitC, drbg->V,
-                                    sizeof(drbg->V), NULL, 0) != DRBG_SUCCESS) {
-        return DRBG_FAILURE;
-    }
-
-    drbg->reseedCtr = 1;
-    drbg->lastBlock = 0;
-    drbg->matchCount = 0;
-    return DRBG_SUCCESS;
-}
-
-static INLINE void array_add_one(byte* data, word32 dataSz)
-{
-    int i;
-
-    for (i = dataSz - 1; i >= 0; i--)
-    {
-        data[i]++;
-        if (data[i] != 0) break;
-    }
-}
-
-
-/* Returns: DRBG_SUCCESS or DRBG_FAILURE */
-static int Hash_gen(DRBG* drbg, byte* out, word32 outSz, const byte* V)
-{
-    byte data[DRBG_SEED_LEN];
-    int i;
-    int len;
-    word32 checkBlock;
-    Sha256 sha;
-    byte digest[SHA256_DIGEST_SIZE];
-
-    /* Special case: outSz is 0 and out is NULL. wc_Generate a block to save for
-     * the continuous test. */
-
-    if (outSz == 0) outSz = 1;
-
-    len = (outSz / OUTPUT_BLOCK_LEN) + ((outSz % OUTPUT_BLOCK_LEN) ? 1 : 0);
-
-    XMEMCPY(data, V, sizeof(data));
-    for (i = 0; i < len; i++) {
-        if (wc_InitSha256(&sha) != 0 ||
-            wc_Sha256Update(&sha, data, sizeof(data)) != 0 ||
-            wc_Sha256Final(&sha, digest) != 0) {
-
-            return DRBG_FAILURE;
-        }
-
-        XMEMCPY(&checkBlock, digest, sizeof(word32));
-        if (drbg->reseedCtr > 1 && checkBlock == drbg->lastBlock) {
-            if (drbg->matchCount == 1) {
-                return DRBG_CONT_FAILURE;
-            }
-            else {
-                if (i == len) {
-                    len++;
-                }
-                drbg->matchCount = 1;
-            }
-        }
-        else {
-            drbg->matchCount = 0;
-            drbg->lastBlock = checkBlock;
-        }
-
-        if (outSz >= OUTPUT_BLOCK_LEN) {
-            XMEMCPY(out, digest, OUTPUT_BLOCK_LEN);
-            outSz -= OUTPUT_BLOCK_LEN;
-            out += OUTPUT_BLOCK_LEN;
-            array_add_one(data, DRBG_SEED_LEN);
-        }
-        else if (out != NULL && outSz != 0) {
-            XMEMCPY(out, digest, outSz);
-            outSz = 0;
-        }
-    }
-    ForceZero(data, sizeof(data));
-
-    return DRBG_SUCCESS;
-}
-
-
-static INLINE void array_add(byte* d, word32 dLen, const byte* s, word32 sLen)
-{
-    word16 carry = 0;
-
-    if (dLen > 0 && sLen > 0 && dLen >= sLen) {
-        int sIdx, dIdx;
-
-        for (sIdx = sLen - 1, dIdx = dLen - 1; sIdx >= 0; dIdx--, sIdx--)
-        {
-            carry += d[dIdx] + s[sIdx];
-            d[dIdx] = (byte)carry;
-            carry >>= 8;
-        }
-
-        for (; carry != 0 && dIdx >= 0; dIdx--) {
-            carry += d[dIdx];
-            d[dIdx] = (byte)carry;
-            carry >>= 8;
-        }
-    }
-}
-
-
-/* Returns: DRBG_SUCCESS, DRBG_NEED_RESEED, or DRBG_FAILURE */
-static int Hash_DRBG_Generate(DRBG* drbg, byte* out, word32 outSz)
-{
-    int ret = DRBG_NEED_RESEED;
-    Sha256 sha;
-    byte digest[SHA256_DIGEST_SIZE];
-
-    if (drbg->reseedCtr != RESEED_INTERVAL) {
-        byte type = drbgGenerateH;
-        word32 reseedCtr = drbg->reseedCtr;
-
-        ret = Hash_gen(drbg, out, outSz, drbg->V);
-        if (ret == DRBG_SUCCESS) {
-            if (wc_InitSha256(&sha) != 0 ||
-                wc_Sha256Update(&sha, &type, sizeof(type)) != 0 ||
-                wc_Sha256Update(&sha, drbg->V, sizeof(drbg->V)) != 0 ||
-                wc_Sha256Final(&sha, digest) != 0) {
-
-                ret = DRBG_FAILURE;
-            }
-            else {
-                array_add(drbg->V, sizeof(drbg->V), digest, sizeof(digest));
-                array_add(drbg->V, sizeof(drbg->V), drbg->C, sizeof(drbg->C));
-                #ifdef LITTLE_ENDIAN_ORDER
-                    reseedCtr = ByteReverseWord32(reseedCtr);
-                #endif
-                array_add(drbg->V, sizeof(drbg->V),
-                                          (byte*)&reseedCtr, sizeof(reseedCtr));
-                ret = DRBG_SUCCESS;
-            }
-            drbg->reseedCtr++;
-        }
-    }
-    ForceZero(digest, sizeof(digest));
-
-    return ret;
-}
-
-
-/* Returns: DRBG_SUCCESS or DRBG_FAILURE */
-static int Hash_DRBG_Instantiate(DRBG* drbg, const byte* seed, word32 seedSz,
-                                             const byte* nonce, word32 nonceSz)
-{
-    int ret = DRBG_FAILURE;
-
-    XMEMSET(drbg, 0, sizeof(DRBG));
-
-    if (Hash_df(drbg, drbg->V, sizeof(drbg->V), drbgInitV, seed, seedSz,
-                                              nonce, nonceSz) == DRBG_SUCCESS &&
-        Hash_df(drbg, drbg->C, sizeof(drbg->C), drbgInitC, drbg->V,
-                                    sizeof(drbg->V), NULL, 0) == DRBG_SUCCESS) {
-
-        drbg->reseedCtr = 1;
-        drbg->lastBlock = 0;
-        drbg->matchCount = 0;
-        ret = DRBG_SUCCESS;
-    }
-
-    return ret;
-}
-
-
-/* Returns: DRBG_SUCCESS or DRBG_FAILURE */
-static int Hash_DRBG_Uninstantiate(DRBG* drbg)
-{
-    word32 i;
-    int    compareSum = 0;
-    byte*  compareDrbg = (byte*)drbg;
-
-    ForceZero(drbg, sizeof(DRBG));
-
-    for (i = 0; i < sizeof(DRBG); i++)
-        compareSum |= compareDrbg[i] ^ 0;
-
-    return (compareSum == 0) ? DRBG_SUCCESS : DRBG_FAILURE;
-}
-
-/* End NIST DRBG Code */
-
-
-/* Get seed and key cipher */
-int wc_InitRng(RNG* rng)
-{
-    int ret = BAD_FUNC_ARG;
-
-    if (rng != NULL) {
-        if (wc_RNG_HealthTestLocal(0) == 0) {
-            byte entropy[ENTROPY_NONCE_SZ];
-
-            rng->drbg =
-                    (struct DRBG*)XMALLOC(sizeof(DRBG), NULL, DYNAMIC_TYPE_RNG);
-            if (rng->drbg == NULL) {
-                ret = MEMORY_E;
-            }
-            /* This doesn't use a separate nonce. The entropy input will be
-             * the default size plus the size of the nonce making the seed
-             * size. */
-            else if (wc_GenerateSeed(&rng->seed,
-                                              entropy, ENTROPY_NONCE_SZ) == 0 &&
-                     Hash_DRBG_Instantiate(rng->drbg,
-                          entropy, ENTROPY_NONCE_SZ, NULL, 0) == DRBG_SUCCESS) {
-
-                ret = Hash_DRBG_Generate(rng->drbg, NULL, 0);
-            }
-            else
-                ret = DRBG_FAILURE;
-
-            ForceZero(entropy, ENTROPY_NONCE_SZ);
-        }
-        else
-            ret = DRBG_CONT_FAILURE;
-
-        if (ret == DRBG_SUCCESS) {
-            rng->status = DRBG_OK;
-            ret = 0;
-        }
-        else if (ret == DRBG_CONT_FAILURE) {
-            rng->status = DRBG_CONT_FAILED;
-            ret = DRBG_CONT_FIPS_E;
-        }
-        else if (ret == DRBG_FAILURE) {
-            rng->status = DRBG_FAILED;
-            ret = RNG_FAILURE_E;
-        }
-        else {
-            rng->status = DRBG_FAILED;
-        }
-    }
-
-    return ret;
-}
-
-
-/* place a generated block in output */
-int wc_RNG_GenerateBlock(RNG* rng, byte* output, word32 sz)
-{
-    int ret;
-
-    if (rng == NULL || output == NULL || sz > MAX_REQUEST_LEN)
-        return BAD_FUNC_ARG;
-
-    if (rng->status != DRBG_OK)
-        return RNG_FAILURE_E;
-
-    ret = Hash_DRBG_Generate(rng->drbg, output, sz);
-
-    if (ret == DRBG_NEED_RESEED) {
-        if (wc_RNG_HealthTestLocal(1) == 0) {
-            byte entropy[ENTROPY_SZ];
-
-            if (wc_GenerateSeed(&rng->seed, entropy, ENTROPY_SZ) == 0 &&
-                Hash_DRBG_Reseed(rng->drbg, entropy, ENTROPY_SZ)
-                                                              == DRBG_SUCCESS) {
-
-                ret = Hash_DRBG_Generate(rng->drbg, NULL, 0);
-                if (ret == DRBG_SUCCESS)
-                    ret = Hash_DRBG_Generate(rng->drbg, output, sz);
-            }
-            else
-                ret = DRBG_FAILURE;
-
-            ForceZero(entropy, ENTROPY_SZ);
-        }
-        else
-            ret = DRBG_CONT_FAILURE;
-    }
-
-    if (ret == DRBG_SUCCESS) {
-        ret = 0;
-    }
-    else if (ret == DRBG_CONT_FAILURE) {
-        ret = DRBG_CONT_FIPS_E;
-        rng->status = DRBG_CONT_FAILED;
-    }
-    else {
-        ret = RNG_FAILURE_E;
-        rng->status = DRBG_FAILED;
-    }
-
-    return ret;
-}
-
-
-int wc_RNG_GenerateByte(RNG* rng, byte* b)
-{
-    return wc_RNG_GenerateBlock(rng, b, 1);
-}
-
-
-int wc_FreeRng(RNG* rng)
-{
-    int ret = BAD_FUNC_ARG;
-
-    if (rng != NULL) {
-        if (rng->drbg != NULL) {
-            if (Hash_DRBG_Uninstantiate(rng->drbg) == DRBG_SUCCESS)
-                ret = 0;
-            else
-                ret = RNG_FAILURE_E;
-
-            XFREE(rng->drbg, NULL, DYNAMIC_TYPE_RNG);
-            rng->drbg = NULL;
-        }
-
-        rng->status = DRBG_NOT_INIT;
-    }
-
-    return ret;
-}
-
-
-int wc_RNG_HealthTest(int reseed, const byte* entropyA, word32 entropyASz,
-                                  const byte* entropyB, word32 entropyBSz,
-                                  byte* output, word32 outputSz)
-{
-    DRBG drbg;
-
-    if (entropyA == NULL || output == NULL)
-        return BAD_FUNC_ARG;
-
-    if (reseed != 0 && entropyB == NULL)
-        return BAD_FUNC_ARG;
-
-    if (outputSz != (SHA256_DIGEST_SIZE * 4))
-        return -1;
-
-    if (Hash_DRBG_Instantiate(&drbg, entropyA, entropyASz, NULL, 0) != 0)
-        return -1;
-
-    if (reseed) {
-        if (Hash_DRBG_Reseed(&drbg, entropyB, entropyBSz) != 0) {
-            Hash_DRBG_Uninstantiate(&drbg);
-            return -1;
-        }
-    }
-
-    if (Hash_DRBG_Generate(&drbg, output, outputSz) != 0) {
-        Hash_DRBG_Uninstantiate(&drbg);
-        return -1;
-    }
-
-    if (Hash_DRBG_Generate(&drbg, output, outputSz) != 0) {
-        Hash_DRBG_Uninstantiate(&drbg);
-        return -1;
-    }
-
-    if (Hash_DRBG_Uninstantiate(&drbg) != 0) {
-        return -1;
-    }
-
-    return 0;
-}
-
-
-const byte entropyA[] = {
-    0x63, 0x36, 0x33, 0x77, 0xe4, 0x1e, 0x86, 0x46, 0x8d, 0xeb, 0x0a, 0xb4,
-    0xa8, 0xed, 0x68, 0x3f, 0x6a, 0x13, 0x4e, 0x47, 0xe0, 0x14, 0xc7, 0x00,
-    0x45, 0x4e, 0x81, 0xe9, 0x53, 0x58, 0xa5, 0x69, 0x80, 0x8a, 0xa3, 0x8f,
-    0x2a, 0x72, 0xa6, 0x23, 0x59, 0x91, 0x5a, 0x9f, 0x8a, 0x04, 0xca, 0x68
-};
-
-const byte reseedEntropyA[] = {
-    0xe6, 0x2b, 0x8a, 0x8e, 0xe8, 0xf1, 0x41, 0xb6, 0x98, 0x05, 0x66, 0xe3,
-    0xbf, 0xe3, 0xc0, 0x49, 0x03, 0xda, 0xd4, 0xac, 0x2c, 0xdf, 0x9f, 0x22,
-    0x80, 0x01, 0x0a, 0x67, 0x39, 0xbc, 0x83, 0xd3
-};
-
-const byte outputA[] = {
-    0x04, 0xee, 0xc6, 0x3b, 0xb2, 0x31, 0xdf, 0x2c, 0x63, 0x0a, 0x1a, 0xfb,
-    0xe7, 0x24, 0x94, 0x9d, 0x00, 0x5a, 0x58, 0x78, 0x51, 0xe1, 0xaa, 0x79,
-    0x5e, 0x47, 0x73, 0x47, 0xc8, 0xb0, 0x56, 0x62, 0x1c, 0x18, 0xbd, 0xdc,
-    0xdd, 0x8d, 0x99, 0xfc, 0x5f, 0xc2, 0xb9, 0x20, 0x53, 0xd8, 0xcf, 0xac,
-    0xfb, 0x0b, 0xb8, 0x83, 0x12, 0x05, 0xfa, 0xd1, 0xdd, 0xd6, 0xc0, 0x71,
-    0x31, 0x8a, 0x60, 0x18, 0xf0, 0x3b, 0x73, 0xf5, 0xed, 0xe4, 0xd4, 0xd0,
-    0x71, 0xf9, 0xde, 0x03, 0xfd, 0x7a, 0xea, 0x10, 0x5d, 0x92, 0x99, 0xb8,
-    0xaf, 0x99, 0xaa, 0x07, 0x5b, 0xdb, 0x4d, 0xb9, 0xaa, 0x28, 0xc1, 0x8d,
-    0x17, 0x4b, 0x56, 0xee, 0x2a, 0x01, 0x4d, 0x09, 0x88, 0x96, 0xff, 0x22,
-    0x82, 0xc9, 0x55, 0xa8, 0x19, 0x69, 0xe0, 0x69, 0xfa, 0x8c, 0xe0, 0x07,
-    0xa1, 0x80, 0x18, 0x3a, 0x07, 0xdf, 0xae, 0x17
-};
-
-const byte entropyB[] = {
-    0xa6, 0x5a, 0xd0, 0xf3, 0x45, 0xdb, 0x4e, 0x0e, 0xff, 0xe8, 0x75, 0xc3,
-    0xa2, 0xe7, 0x1f, 0x42, 0xc7, 0x12, 0x9d, 0x62, 0x0f, 0xf5, 0xc1, 0x19,
-    0xa9, 0xef, 0x55, 0xf0, 0x51, 0x85, 0xe0, 0xfb, 0x85, 0x81, 0xf9, 0x31,
-    0x75, 0x17, 0x27, 0x6e, 0x06, 0xe9, 0x60, 0x7d, 0xdb, 0xcb, 0xcc, 0x2e
-};
-
-const byte outputB[] = {
-    0xd3, 0xe1, 0x60, 0xc3, 0x5b, 0x99, 0xf3, 0x40, 0xb2, 0x62, 0x82, 0x64,
-    0xd1, 0x75, 0x10, 0x60, 0xe0, 0x04, 0x5d, 0xa3, 0x83, 0xff, 0x57, 0xa5,
-    0x7d, 0x73, 0xa6, 0x73, 0xd2, 0xb8, 0xd8, 0x0d, 0xaa, 0xf6, 0xa6, 0xc3,
-    0x5a, 0x91, 0xbb, 0x45, 0x79, 0xd7, 0x3f, 0xd0, 0xc8, 0xfe, 0xd1, 0x11,
-    0xb0, 0x39, 0x13, 0x06, 0x82, 0x8a, 0xdf, 0xed, 0x52, 0x8f, 0x01, 0x81,
-    0x21, 0xb3, 0xfe, 0xbd, 0xc3, 0x43, 0xe7, 0x97, 0xb8, 0x7d, 0xbb, 0x63,
-    0xdb, 0x13, 0x33, 0xde, 0xd9, 0xd1, 0xec, 0xe1, 0x77, 0xcf, 0xa6, 0xb7,
-    0x1f, 0xe8, 0xab, 0x1d, 0xa4, 0x66, 0x24, 0xed, 0x64, 0x15, 0xe5, 0x1c,
-    0xcd, 0xe2, 0xc7, 0xca, 0x86, 0xe2, 0x83, 0x99, 0x0e, 0xea, 0xeb, 0x91,
-    0x12, 0x04, 0x15, 0x52, 0x8b, 0x22, 0x95, 0x91, 0x02, 0x81, 0xb0, 0x2d,
-    0xd4, 0x31, 0xf4, 0xc9, 0xf7, 0x04, 0x27, 0xdf
-};
-
-
-static int wc_RNG_HealthTestLocal(int reseed)
-{
-    int ret = 0;
-    byte check[SHA256_DIGEST_SIZE * 4];
-
-    if (reseed) {
-        ret = wc_RNG_HealthTest(1, entropyA, sizeof(entropyA),
-                                reseedEntropyA, sizeof(reseedEntropyA),
-                                check, sizeof(check));
-        if (ret == 0) {
-            if (ConstantCompare(check, outputA, sizeof(check)) != 0)
-                ret = -1;
-        }
-    }
-    else {
-        ret = wc_RNG_HealthTest(0, entropyB, sizeof(entropyB),
-                                NULL, 0,
-                                check, sizeof(check));
-        if (ret == 0) {
-            if (ConstantCompare(check, outputB, sizeof(check)) != 0)
-                ret = -1;
-        }
-    }
-
-    return ret;
-}
-
-
-#else /* HAVE_HASHDRBG || NO_RC4 */
-
-/* Get seed and key cipher */
-int wc_InitRng(RNG* rng)
-{
-    int  ret;
-#ifdef WOLFSSL_SMALL_STACK
-    byte* key;
-    byte* junk;
-#else
-    byte key[32];
-    byte junk[256];
-#endif
-
-#ifdef HAVE_INTEL_RDGEN
-    wc_InitRng_IntelRD() ;
-    if(IS_INTEL_RDRAND)return 0 ;
-#endif
-#ifdef HAVE_CAVIUM
-    if (rng->magic == WOLFSSL_RNG_CAVIUM_MAGIC)
-        return 0;
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    key = (byte*)XMALLOC(32, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (key == NULL)
-        return MEMORY_E;
-
-    junk = (byte*)XMALLOC(256, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (junk == NULL) {
-        XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        return MEMORY_E;
-    }
-#endif
-
-    ret = wc_GenerateSeed(&rng->seed, key, 32);
-
-    if (ret == 0) {
-        wc_Arc4SetKey(&rng->cipher, key, sizeof(key));
-
-        ret = wc_RNG_GenerateBlock(rng, junk, 256); /*rid initial state*/
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    XFREE(junk, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-#ifdef HAVE_CAVIUM
-    static void CaviumRNG_GenerateBlock(RNG* rng, byte* output, word32 sz);
-#endif
-
-/* place a generated block in output */
-int wc_RNG_GenerateBlock(RNG* rng, byte* output, word32 sz)
-{
-#ifdef HAVE_INTEL_RDGEN
-    if(IS_INTEL_RDRAND)
-        return wc_GenerateRand_IntelRD(NULL, output, sz) ;
-#endif
-#ifdef HAVE_CAVIUM
-    if (rng->magic == WOLFSSL_RNG_CAVIUM_MAGIC)
-        return CaviumRNG_GenerateBlock(rng, output, sz);
-#endif
-    XMEMSET(output, 0, sz);
-    wc_Arc4Process(&rng->cipher, output, output, sz);
-
-    return 0;
-}
-
-
-int wc_RNG_GenerateByte(RNG* rng, byte* b)
-{
-    return wc_RNG_GenerateBlock(rng, b, 1);
-}
-
-
-int wc_FreeRng(RNG* rng)
-{
-    (void)rng;
-    return 0;
-}
-
-
-#ifdef HAVE_CAVIUM
-
-#include 
-#include "cavium_common.h"
-
-/* Initiliaze RNG for use with Nitrox device */
-int wc_InitRngCavium(RNG* rng, int devId)
-{
-    if (rng == NULL)
-        return -1;
-
-    rng->devId = devId;
-    rng->magic = WOLFSSL_RNG_CAVIUM_MAGIC;
-
-    return 0;
-}
-
-
-static void CaviumRNG_GenerateBlock(RNG* rng, byte* output, word32 sz)
-{
-    wolfssl_word offset = 0;
-    word32      requestId;
-
-    while (sz > WOLFSSL_MAX_16BIT) {
-        word16 slen = (word16)WOLFSSL_MAX_16BIT;
-        if (CspRandom(CAVIUM_BLOCKING, slen, output + offset, &requestId,
-                      rng->devId) != 0) {
-            WOLFSSL_MSG("Cavium RNG failed");
-        }
-        sz     -= WOLFSSL_MAX_16BIT;
-        offset += WOLFSSL_MAX_16BIT;
-    }
-    if (sz) {
-        word16 slen = (word16)sz;
-        if (CspRandom(CAVIUM_BLOCKING, slen, output + offset, &requestId,
-                      rng->devId) != 0) {
-            WOLFSSL_MSG("Cavium RNG failed");
-        }
-    }
-}
-
-#endif /* HAVE_CAVIUM */
-
-#endif /* HAVE_HASHDRBG || NO_RC4 */
-
-
-#if defined(HAVE_INTEL_RDGEN)
-
-#ifndef _MSC_VER
-    #define cpuid(reg, leaf, sub)\
-            __asm__ __volatile__ ("cpuid":\
-             "=a" (reg[0]), "=b" (reg[1]), "=c" (reg[2]), "=d" (reg[3]) :\
-             "a" (leaf), "c"(sub));
-
-    #define XASM_LINK(f) asm(f)
-#else
-
-    #include 
-    #define cpuid(a,b) __cpuid((int*)a,b)
-
-    #define XASM_LINK(f)
-
-#endif /* _MSC_VER */
-
-#define EAX 0
-#define EBX 1
-#define ECX 2 
-#define EDX 3
-
-static word32 cpuid_flag(word32 leaf, word32 sub, word32 num, word32 bit) {
-    int got_intel_cpu=0;
-    unsigned int reg[5]; 
-    
-    reg[4] = '\0' ;
-    cpuid(reg, 0, 0);  
-    if(memcmp((char *)&(reg[EBX]), "Genu", 4) == 0 &&  
-                memcmp((char *)&(reg[EDX]), "ineI", 4) == 0 &&  
-                memcmp((char *)&(reg[ECX]), "ntel", 4) == 0) {  
-        got_intel_cpu = 1;  
-    }    
-    if (got_intel_cpu) {
-        cpuid(reg, leaf, sub);
-        return((reg[num]>>bit)&0x1) ;
-    }
-    return 0 ;
-}
-
-static int wc_InitRng_IntelRD()
-{
-    if(cpuid_check==0) {
-        if(cpuid_flag(1, 0, ECX, 30)){ cpuid_flags |= CPUID_RDRAND ;} 
-        if(cpuid_flag(7, 0, EBX, 18)){ cpuid_flags |= CPUID_RDSEED ;}
-        cpuid_check = 1 ;
-    }
-    return 1 ;
-}
-
-#define INTELRD_RETRY 10
-
-#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
-
-/* return 0 on success */
-static inline int IntelRDseed32(unsigned int *seed)  
-{  
-    int rdseed;  unsigned char ok ;
-
-    __asm__ volatile("rdseed %0; setc %1":"=r"(rdseed), "=qm"(ok));  
-    if(ok){
-        *seed = rdseed ;
-        return 0 ;
-    } else
-        return 1;
-}
-
-/* return 0 on success */
-static inline int IntelRDseed32_r(unsigned int *rnd)  
-{  
-    int i ;
-    for(i=0; i 0; sz-=4, output+=4) {
-        if(IS_INTEL_RDSEED)ret = IntelRDseed32_r((word32 *)output) ;
-        else return 1 ;
-        if(ret)
-             return 1 ;
-    }
-    if(sz == 0)return 0 ;
-
-    if(IS_INTEL_RDSEED)ret = IntelRDseed32_r(&rndTmp) ;
-    else return 1 ;
-    if(ret)
-         return 1 ;
-    XMEMCPY(output, &rndTmp, sz) ;
-    return 0;
-}
-
-#else
-
-/* return 0 on success */
-static inline int IntelRDrand32(unsigned int *rnd)  
-{  
-    int rdrand; unsigned char ok ;  
-    __asm__ volatile("rdrand %0; setc %1":"=r"(rdrand), "=qm"(ok));  
-    if(ok){
-        *rnd = rdrand;
-        return 0 ;
-    } else
-        return 1;
-}
-
-/* return 0 on success */
-static inline int IntelRDrand32_r(unsigned int *rnd)  
-{  
-    int i ;
-    for(i=0; i 0; sz-=4, output+=4) {
-        if(IS_INTEL_RDRAND)ret = IntelRDrand32_r((word32 *)output);
-        else return 1 ;
-        if(ret)
-             return 1 ;
-    }
-    if(sz == 0)return 0 ;
-
-    if(IS_INTEL_RDRAND)ret = IntelRDrand32_r(&rndTmp);
-    else return 1 ;
-    if(ret)
-         return 1 ;
-    XMEMCPY(output, &rndTmp, sz) ;
-    return 0;
-}
-#endif /* defined(HAVE_HASHDRBG) || defined(NO_RC4) */
-
-#endif /* HAVE_INTEL_RDGEN */
-
-
-#if defined(USE_WINDOWS_API)
-
-
-int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-{
-    if(!CryptAcquireContext(&os->handle, 0, 0, PROV_RSA_FULL,
-                            CRYPT_VERIFYCONTEXT))
-        return WINCRYPT_E;
-
-    if (!CryptGenRandom(os->handle, sz, output))
-        return CRYPTGEN_E;
-
-    CryptReleaseContext(os->handle, 0);
-
-    return 0;
-}
-
-
-#elif defined(HAVE_RTP_SYS) || defined(EBSNET)
-
-#include "rtprand.h"   /* rtp_rand () */
-#include "rtptime.h"   /* rtp_get_system_msec() */
-
-
-int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-{
-    int i;
-    rtp_srand(rtp_get_system_msec());
-
-    for (i = 0; i < sz; i++ ) {
-        output[i] = rtp_rand() % 256;
-        if ( (i % 8) == 7)
-            rtp_srand(rtp_get_system_msec());
-    }
-
-    return 0;
-}
-
-
-#elif defined(MICRIUM)
-
-int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-{
-    #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
-        NetSecure_InitSeed(output, sz);
-    #endif
-    return 0;
-}
-
-#elif defined(MBED)
-
-/* write a real one !!!, just for testing board */
-int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-{
-    int i;
-    for (i = 0; i < sz; i++ )
-        output[i] = i;
-
-    return 0;
-}
-
-#elif defined(MICROCHIP_PIC32)
-
-#ifdef MICROCHIP_MPLAB_HARMONY
-    #define PIC32_SEED_COUNT _CP0_GET_COUNT
-#else
-    #if !defined(WOLFSSL_MICROCHIP_PIC32MZ)
-        #include 
-    #endif
-    #define PIC32_SEED_COUNT ReadCoreTimer
-#endif
-    #ifdef WOLFSSL_MIC32MZ_RNG
-        #include "xc.h"
-        int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-        {
-            int i ;
-            byte rnd[8] ;
-            word32 *rnd32 = (word32 *)rnd ;
-            word32 size = sz ;
-            byte* op = output ;
-
-            /* This part has to be replaced with better random seed */
-            RNGNUMGEN1 = ReadCoreTimer();
-            RNGPOLY1 = ReadCoreTimer();
-            RNGPOLY2 = ReadCoreTimer();
-            RNGNUMGEN2 = ReadCoreTimer();
-#ifdef DEBUG_WOLFSSL
-            printf("GenerateSeed::Seed=%08x, %08x\n", RNGNUMGEN1, RNGNUMGEN2) ;
-#endif
-            RNGCONbits.PLEN = 0x40;
-            RNGCONbits.PRNGEN = 1;
-            for(i=0; i<5; i++) { /* wait for RNGNUMGEN ready */
-                volatile int x ;
-                x = RNGNUMGEN1 ;
-                x = RNGNUMGEN2 ;
-            }
-            do {
-                rnd32[0] = RNGNUMGEN1;
-                rnd32[1] = RNGNUMGEN2;
-
-                for(i=0; i<8; i++, op++) {
-                    *op = rnd[i] ;
-                    size -- ;
-                    if(size==0)break ;
-                }
-            } while(size) ;
-            return 0;
-        }
-    #else  /* WOLFSSL_MIC32MZ_RNG */
-        /* uses the core timer, in nanoseconds to seed srand */
-        int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-        {
-            int i;
-            srand(PIC32_SEED_COUNT() * 25);
-
-            for (i = 0; i < sz; i++ ) {
-                output[i] = rand() % 256;
-                if ( (i % 8) == 7)
-                    srand(PIC32_SEED_COUNT() * 25);
-            }
-            return 0;
-        }
-    #endif /* WOLFSSL_MIC32MZ_RNG */
-
-#elif defined(FREESCALE_MQX)
-
-    #ifdef FREESCALE_K70_RNGA
-        /*
-         * wc_Generates a RNG seed using the Random Number Generator Accelerator
-         * on the Kinetis K70. Documentation located in Chapter 37 of
-         * K70 Sub-Family Reference Manual (see Note 3 in the README for link).
-         */
-        int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-        {
-            int i;
-
-            /* turn on RNGA module */
-            SIM_SCGC3 |= SIM_SCGC3_RNGA_MASK;
-
-            /* set SLP bit to 0 - "RNGA is not in sleep mode" */
-            RNG_CR &= ~RNG_CR_SLP_MASK;
-
-            /* set HA bit to 1 - "security violations masked" */
-            RNG_CR |= RNG_CR_HA_MASK;
-
-            /* set GO bit to 1 - "output register loaded with data" */
-            RNG_CR |= RNG_CR_GO_MASK;
-
-            for (i = 0; i < sz; i++) {
-
-                /* wait for RNG FIFO to be full */
-                while((RNG_SR & RNG_SR_OREG_LVL(0xF)) == 0) {}
-
-                /* get value */
-                output[i] = RNG_OR;
-            }
-
-            return 0;
-        }
-
-    #elif defined(FREESCALE_K53_RNGB)
-        /*
-         * wc_Generates a RNG seed using the Random Number Generator (RNGB)
-         * on the Kinetis K53. Documentation located in Chapter 33 of
-         * K53 Sub-Family Reference Manual (see note in the README for link).
-         */
-        int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-        {
-            int i;
-
-            /* turn on RNGB module */
-            SIM_SCGC3 |= SIM_SCGC3_RNGB_MASK;
-
-            /* reset RNGB */
-            RNG_CMD |= RNG_CMD_SR_MASK;
-
-            /* FIFO generate interrupt, return all zeros on underflow,
-             * set auto reseed */
-            RNG_CR |= (RNG_CR_FUFMOD_MASK | RNG_CR_AR_MASK);
-
-            /* gen seed, clear interrupts, clear errors */
-            RNG_CMD |= (RNG_CMD_GS_MASK | RNG_CMD_CI_MASK | RNG_CMD_CE_MASK);
-
-            /* wait for seeding to complete */
-            while ((RNG_SR & RNG_SR_SDN_MASK) == 0) {}
-
-            for (i = 0; i < sz; i++) {
-
-                /* wait for a word to be available from FIFO */
-                while((RNG_SR & RNG_SR_FIFO_LVL_MASK) == 0) {}
-
-                /* get value */
-                output[i] = RNG_OUT;
-            }
-
-            return 0;
-        }
-
-    #else
-        #warning "write a real random seed!!!!, just for testing now"
-
-        int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-        {
-            int i;
-            for (i = 0; i < sz; i++ )
-                output[i] = i;
-
-            return 0;
-        }
-    #endif /* FREESCALE_K70_RNGA */
-
-#elif defined(WOLFSSL_SAFERTOS) || defined(WOLFSSL_LEANPSK) \
-   || defined(WOLFSSL_IAR_ARM)  || defined(WOLFSSL_MDK_ARM) \
-   || defined(WOLFSSL_uITRON4)  || defined(WOLFSSL_uTKERNEL2)
-
-#warning "write a real random seed!!!!, just for testing now"
-
-int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-{
-    word32 i;
-    for (i = 0; i < sz; i++ )
-        output[i] = i;
-
-    (void)os;
-
-    return 0;
-}
-
-#elif defined(STM32F2_RNG)
-    #undef RNG
-    #include "stm32f2xx_rng.h"
-    #include "stm32f2xx_rcc.h"
-    /*
-     * wc_Generate a RNG seed using the hardware random number generator
-     * on the STM32F2. Documentation located in STM32F2xx Standard Peripheral
-     * Library document (See note in README).
-     */
-    int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-    {
-        int i;
-
-        /* enable RNG clock source */
-        RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_RNG, ENABLE);
-
-        /* enable RNG peripheral */
-        RNG_Cmd(ENABLE);
-
-        for (i = 0; i < sz; i++) {
-            /* wait until RNG number is ready */
-            while(RNG_GetFlagStatus(RNG_FLAG_DRDY)== RESET) { }
-
-            /* get value */
-            output[i] = RNG_GetRandomNumber();
-        }
-
-        return 0;
-    }
-#elif defined(WOLFSSL_LPC43xx) || defined(WOLFSSL_STM32F2xx)
-
-    #warning "write a real random seed!!!!, just for testing now"
-
-    int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-    {
-        int i;
-
-        for (i = 0; i < sz; i++ )
-            output[i] = i;
-
-        return 0;
-    }
-
-#elif defined(WOLFSSL_TIRTOS)
-
-    #include 
-    #include 
-    int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-    {
-        int i;
-        srand(xdc_runtime_Timestamp_get32());
-
-        for (i = 0; i < sz; i++ ) {
-            output[i] = rand() % 256;
-            if ((i % 8) == 7) {
-                srand(xdc_runtime_Timestamp_get32());
-            }
-        }
-
-        return 0;
-    }
-
-#elif defined(CUSTOM_RAND_GENERATE)
-
-   /* Implement your own random generation function
-    * word32 rand_gen(void);
-    * #define CUSTOM_RAND_GENERATE  rand_gen  */
-
-    int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-    {
-        word32 i;
-
-        (void)os;
-
-        for (i = 0; i < sz; i++ )
-            output[i] = CUSTOM_RAND_GENERATE();
-
-        return 0;
-    }
-
-#elif defined(NO_DEV_RANDOM)
-
-#error "you need to write an os specific wc_GenerateSeed() here"
-
-/*
-int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-{
-    return 0;
-}
-*/
-
-
-#else /* !USE_WINDOWS_API && !HAVE_RPT_SYS && !MICRIUM && !NO_DEV_RANDOM */
-
-/* may block */
-int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
-{
-    int ret = 0;
-
-
-#if defined(HAVE_INTEL_RDGEN) && (defined(HAVE_HASHDRBG) || defined(NO_RC4))
-    wc_InitRng_IntelRD() ; /* set cpuid_flags if not yet */
-    if(IS_INTEL_RDSEED)
-         return wc_GenerateSeed_IntelRD(NULL, output, sz) ;
-#endif
-
-    os->fd = open("/dev/urandom",O_RDONLY);
-    if (os->fd == -1) {
-        /* may still have /dev/random */
-        os->fd = open("/dev/random",O_RDONLY);
-        if (os->fd == -1)
-            return OPEN_RAN_E;
-    }
-
-    while (sz) {
-        int len = (int)read(os->fd, output, sz);
-        if (len == -1) {
-            ret = READ_RAN_E;
-            break;
-        }
-
-        sz     -= len;
-        output += len;
-
-        if (sz) {
-#ifdef BLOCKING
-            sleep(0);             /* context switch */
-#else
-            ret = RAN_BLOCK_E;
-            break;
-#endif
-        }
-    }
-    close(os->fd);
-
-    return ret;
-}
-
-#endif /* USE_WINDOWS_API */
-#endif /* HAVE_FIPS */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ripemd.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ripemd.c
deleted file mode 100755
index 639a42d..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/ripemd.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/* ripemd.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef WOLFSSL_RIPEMD
-
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-void wc_InitRipeMd(RipeMd* ripemd)
-{
-    ripemd->digest[0] = 0x67452301L;
-    ripemd->digest[1] = 0xEFCDAB89L;
-    ripemd->digest[2] = 0x98BADCFEL;
-    ripemd->digest[3] = 0x10325476L;
-    ripemd->digest[4] = 0xC3D2E1F0L;
-
-    ripemd->buffLen = 0;
-    ripemd->loLen   = 0;
-    ripemd->hiLen   = 0;
-}
-
-
-/* for all */
-#define F(x, y, z)    (x ^ y ^ z) 
-#define G(x, y, z)    (z ^ (x & (y^z)))
-#define H(x, y, z)    (z ^ (x | ~y))
-#define I(x, y, z)    (y ^ (z & (x^y)))
-#define J(x, y, z)    (x ^ (y | ~z))
-
-#define k0 0
-#define k1 0x5a827999
-#define k2 0x6ed9eba1
-#define k3 0x8f1bbcdc
-#define k4 0xa953fd4e
-#define k5 0x50a28be6
-#define k6 0x5c4dd124
-#define k7 0x6d703ef3
-#define k8 0x7a6d76e9
-#define k9 0
-
-/* for 160 and 320 */
-#define Subround(f, a, b, c, d, e, x, s, k) \
-    a += f(b, c, d) + x + k;\
-    a = rotlFixed((word32)a, s) + e;\
-    c = rotlFixed((word32)c, 10U)
-
-static void Transform(RipeMd* ripemd)
-{
-    word32 a1, b1, c1, d1, e1, a2, b2, c2, d2, e2;
-    a1 = a2 = ripemd->digest[0];
-    b1 = b2 = ripemd->digest[1];
-    c1 = c2 = ripemd->digest[2];
-    d1 = d2 = ripemd->digest[3];
-    e1 = e2 = ripemd->digest[4];
-
-    Subround(F, a1, b1, c1, d1, e1, ripemd->buffer[ 0], 11, k0);
-    Subround(F, e1, a1, b1, c1, d1, ripemd->buffer[ 1], 14, k0);
-    Subround(F, d1, e1, a1, b1, c1, ripemd->buffer[ 2], 15, k0);
-    Subround(F, c1, d1, e1, a1, b1, ripemd->buffer[ 3], 12, k0);
-    Subround(F, b1, c1, d1, e1, a1, ripemd->buffer[ 4],  5, k0);
-    Subround(F, a1, b1, c1, d1, e1, ripemd->buffer[ 5],  8, k0);
-    Subround(F, e1, a1, b1, c1, d1, ripemd->buffer[ 6],  7, k0);
-    Subround(F, d1, e1, a1, b1, c1, ripemd->buffer[ 7],  9, k0);
-    Subround(F, c1, d1, e1, a1, b1, ripemd->buffer[ 8], 11, k0);
-    Subround(F, b1, c1, d1, e1, a1, ripemd->buffer[ 9], 13, k0);
-    Subround(F, a1, b1, c1, d1, e1, ripemd->buffer[10], 14, k0);
-    Subround(F, e1, a1, b1, c1, d1, ripemd->buffer[11], 15, k0);
-    Subround(F, d1, e1, a1, b1, c1, ripemd->buffer[12],  6, k0);
-    Subround(F, c1, d1, e1, a1, b1, ripemd->buffer[13],  7, k0);
-    Subround(F, b1, c1, d1, e1, a1, ripemd->buffer[14],  9, k0);
-    Subround(F, a1, b1, c1, d1, e1, ripemd->buffer[15],  8, k0);
-
-    Subround(G, e1, a1, b1, c1, d1, ripemd->buffer[ 7],  7, k1);
-    Subround(G, d1, e1, a1, b1, c1, ripemd->buffer[ 4],  6, k1);
-    Subround(G, c1, d1, e1, a1, b1, ripemd->buffer[13],  8, k1);
-    Subround(G, b1, c1, d1, e1, a1, ripemd->buffer[ 1], 13, k1);
-    Subround(G, a1, b1, c1, d1, e1, ripemd->buffer[10], 11, k1);
-    Subround(G, e1, a1, b1, c1, d1, ripemd->buffer[ 6],  9, k1);
-    Subround(G, d1, e1, a1, b1, c1, ripemd->buffer[15],  7, k1);
-    Subround(G, c1, d1, e1, a1, b1, ripemd->buffer[ 3], 15, k1);
-    Subround(G, b1, c1, d1, e1, a1, ripemd->buffer[12],  7, k1);
-    Subround(G, a1, b1, c1, d1, e1, ripemd->buffer[ 0], 12, k1);
-    Subround(G, e1, a1, b1, c1, d1, ripemd->buffer[ 9], 15, k1);
-    Subround(G, d1, e1, a1, b1, c1, ripemd->buffer[ 5],  9, k1);
-    Subround(G, c1, d1, e1, a1, b1, ripemd->buffer[ 2], 11, k1);
-    Subround(G, b1, c1, d1, e1, a1, ripemd->buffer[14],  7, k1);
-    Subround(G, a1, b1, c1, d1, e1, ripemd->buffer[11], 13, k1);
-    Subround(G, e1, a1, b1, c1, d1, ripemd->buffer[ 8], 12, k1);
-
-    Subround(H, d1, e1, a1, b1, c1, ripemd->buffer[ 3], 11, k2);
-    Subround(H, c1, d1, e1, a1, b1, ripemd->buffer[10], 13, k2);
-    Subround(H, b1, c1, d1, e1, a1, ripemd->buffer[14],  6, k2);
-    Subround(H, a1, b1, c1, d1, e1, ripemd->buffer[ 4],  7, k2);
-    Subround(H, e1, a1, b1, c1, d1, ripemd->buffer[ 9], 14, k2);
-    Subround(H, d1, e1, a1, b1, c1, ripemd->buffer[15],  9, k2);
-    Subround(H, c1, d1, e1, a1, b1, ripemd->buffer[ 8], 13, k2);
-    Subround(H, b1, c1, d1, e1, a1, ripemd->buffer[ 1], 15, k2);
-    Subround(H, a1, b1, c1, d1, e1, ripemd->buffer[ 2], 14, k2);
-    Subround(H, e1, a1, b1, c1, d1, ripemd->buffer[ 7],  8, k2);
-    Subround(H, d1, e1, a1, b1, c1, ripemd->buffer[ 0], 13, k2);
-    Subround(H, c1, d1, e1, a1, b1, ripemd->buffer[ 6],  6, k2);
-    Subround(H, b1, c1, d1, e1, a1, ripemd->buffer[13],  5, k2);
-    Subround(H, a1, b1, c1, d1, e1, ripemd->buffer[11], 12, k2);
-    Subround(H, e1, a1, b1, c1, d1, ripemd->buffer[ 5],  7, k2);
-    Subround(H, d1, e1, a1, b1, c1, ripemd->buffer[12],  5, k2);
-
-    Subround(I, c1, d1, e1, a1, b1, ripemd->buffer[ 1], 11, k3);
-    Subround(I, b1, c1, d1, e1, a1, ripemd->buffer[ 9], 12, k3);
-    Subround(I, a1, b1, c1, d1, e1, ripemd->buffer[11], 14, k3);
-    Subround(I, e1, a1, b1, c1, d1, ripemd->buffer[10], 15, k3);
-    Subround(I, d1, e1, a1, b1, c1, ripemd->buffer[ 0], 14, k3);
-    Subround(I, c1, d1, e1, a1, b1, ripemd->buffer[ 8], 15, k3);
-    Subround(I, b1, c1, d1, e1, a1, ripemd->buffer[12],  9, k3);
-    Subround(I, a1, b1, c1, d1, e1, ripemd->buffer[ 4],  8, k3);
-    Subround(I, e1, a1, b1, c1, d1, ripemd->buffer[13],  9, k3);
-    Subround(I, d1, e1, a1, b1, c1, ripemd->buffer[ 3], 14, k3);
-    Subround(I, c1, d1, e1, a1, b1, ripemd->buffer[ 7],  5, k3);
-    Subround(I, b1, c1, d1, e1, a1, ripemd->buffer[15],  6, k3);
-    Subround(I, a1, b1, c1, d1, e1, ripemd->buffer[14],  8, k3);
-    Subround(I, e1, a1, b1, c1, d1, ripemd->buffer[ 5],  6, k3);
-    Subround(I, d1, e1, a1, b1, c1, ripemd->buffer[ 6],  5, k3);
-    Subround(I, c1, d1, e1, a1, b1, ripemd->buffer[ 2], 12, k3);
-
-    Subround(J, b1, c1, d1, e1, a1, ripemd->buffer[ 4],  9, k4);
-    Subround(J, a1, b1, c1, d1, e1, ripemd->buffer[ 0], 15, k4);
-    Subround(J, e1, a1, b1, c1, d1, ripemd->buffer[ 5],  5, k4);
-    Subround(J, d1, e1, a1, b1, c1, ripemd->buffer[ 9], 11, k4);
-    Subround(J, c1, d1, e1, a1, b1, ripemd->buffer[ 7],  6, k4);
-    Subround(J, b1, c1, d1, e1, a1, ripemd->buffer[12],  8, k4);
-    Subround(J, a1, b1, c1, d1, e1, ripemd->buffer[ 2], 13, k4);
-    Subround(J, e1, a1, b1, c1, d1, ripemd->buffer[10], 12, k4);
-    Subround(J, d1, e1, a1, b1, c1, ripemd->buffer[14],  5, k4);
-    Subround(J, c1, d1, e1, a1, b1, ripemd->buffer[ 1], 12, k4);
-    Subround(J, b1, c1, d1, e1, a1, ripemd->buffer[ 3], 13, k4);
-    Subround(J, a1, b1, c1, d1, e1, ripemd->buffer[ 8], 14, k4);
-    Subround(J, e1, a1, b1, c1, d1, ripemd->buffer[11], 11, k4);
-    Subround(J, d1, e1, a1, b1, c1, ripemd->buffer[ 6],  8, k4);
-    Subround(J, c1, d1, e1, a1, b1, ripemd->buffer[15],  5, k4);
-    Subround(J, b1, c1, d1, e1, a1, ripemd->buffer[13],  6, k4);
-
-    Subround(J, a2, b2, c2, d2, e2, ripemd->buffer[ 5],  8, k5);
-    Subround(J, e2, a2, b2, c2, d2, ripemd->buffer[14],  9, k5);
-    Subround(J, d2, e2, a2, b2, c2, ripemd->buffer[ 7],  9, k5);
-    Subround(J, c2, d2, e2, a2, b2, ripemd->buffer[ 0], 11, k5);
-    Subround(J, b2, c2, d2, e2, a2, ripemd->buffer[ 9], 13, k5);
-    Subround(J, a2, b2, c2, d2, e2, ripemd->buffer[ 2], 15, k5);
-    Subround(J, e2, a2, b2, c2, d2, ripemd->buffer[11], 15, k5);
-    Subround(J, d2, e2, a2, b2, c2, ripemd->buffer[ 4],  5, k5);
-    Subround(J, c2, d2, e2, a2, b2, ripemd->buffer[13],  7, k5);
-    Subround(J, b2, c2, d2, e2, a2, ripemd->buffer[ 6],  7, k5);
-    Subround(J, a2, b2, c2, d2, e2, ripemd->buffer[15],  8, k5);
-    Subround(J, e2, a2, b2, c2, d2, ripemd->buffer[ 8], 11, k5);
-    Subround(J, d2, e2, a2, b2, c2, ripemd->buffer[ 1], 14, k5);
-    Subround(J, c2, d2, e2, a2, b2, ripemd->buffer[10], 14, k5);
-    Subround(J, b2, c2, d2, e2, a2, ripemd->buffer[ 3], 12, k5);
-    Subround(J, a2, b2, c2, d2, e2, ripemd->buffer[12],  6, k5);
-
-    Subround(I, e2, a2, b2, c2, d2, ripemd->buffer[ 6],  9, k6); 
-    Subround(I, d2, e2, a2, b2, c2, ripemd->buffer[11], 13, k6);
-    Subround(I, c2, d2, e2, a2, b2, ripemd->buffer[ 3], 15, k6);
-    Subround(I, b2, c2, d2, e2, a2, ripemd->buffer[ 7],  7, k6);
-    Subround(I, a2, b2, c2, d2, e2, ripemd->buffer[ 0], 12, k6);
-    Subround(I, e2, a2, b2, c2, d2, ripemd->buffer[13],  8, k6);
-    Subround(I, d2, e2, a2, b2, c2, ripemd->buffer[ 5],  9, k6);
-    Subround(I, c2, d2, e2, a2, b2, ripemd->buffer[10], 11, k6);
-    Subround(I, b2, c2, d2, e2, a2, ripemd->buffer[14],  7, k6);
-    Subround(I, a2, b2, c2, d2, e2, ripemd->buffer[15],  7, k6);
-    Subround(I, e2, a2, b2, c2, d2, ripemd->buffer[ 8], 12, k6);
-    Subround(I, d2, e2, a2, b2, c2, ripemd->buffer[12],  7, k6);
-    Subround(I, c2, d2, e2, a2, b2, ripemd->buffer[ 4],  6, k6);
-    Subround(I, b2, c2, d2, e2, a2, ripemd->buffer[ 9], 15, k6);
-    Subround(I, a2, b2, c2, d2, e2, ripemd->buffer[ 1], 13, k6);
-    Subround(I, e2, a2, b2, c2, d2, ripemd->buffer[ 2], 11, k6);
-
-    Subround(H, d2, e2, a2, b2, c2, ripemd->buffer[15],  9, k7);
-    Subround(H, c2, d2, e2, a2, b2, ripemd->buffer[ 5],  7, k7);
-    Subround(H, b2, c2, d2, e2, a2, ripemd->buffer[ 1], 15, k7);
-    Subround(H, a2, b2, c2, d2, e2, ripemd->buffer[ 3], 11, k7);
-    Subround(H, e2, a2, b2, c2, d2, ripemd->buffer[ 7],  8, k7);
-    Subround(H, d2, e2, a2, b2, c2, ripemd->buffer[14],  6, k7);
-    Subround(H, c2, d2, e2, a2, b2, ripemd->buffer[ 6],  6, k7);
-    Subround(H, b2, c2, d2, e2, a2, ripemd->buffer[ 9], 14, k7);
-    Subround(H, a2, b2, c2, d2, e2, ripemd->buffer[11], 12, k7);
-    Subround(H, e2, a2, b2, c2, d2, ripemd->buffer[ 8], 13, k7);
-    Subround(H, d2, e2, a2, b2, c2, ripemd->buffer[12],  5, k7);
-    Subround(H, c2, d2, e2, a2, b2, ripemd->buffer[ 2], 14, k7);
-    Subround(H, b2, c2, d2, e2, a2, ripemd->buffer[10], 13, k7);
-    Subround(H, a2, b2, c2, d2, e2, ripemd->buffer[ 0], 13, k7);
-    Subround(H, e2, a2, b2, c2, d2, ripemd->buffer[ 4],  7, k7);
-    Subround(H, d2, e2, a2, b2, c2, ripemd->buffer[13],  5, k7);
-
-    Subround(G, c2, d2, e2, a2, b2, ripemd->buffer[ 8], 15, k8);
-    Subround(G, b2, c2, d2, e2, a2, ripemd->buffer[ 6],  5, k8);
-    Subround(G, a2, b2, c2, d2, e2, ripemd->buffer[ 4],  8, k8);
-    Subround(G, e2, a2, b2, c2, d2, ripemd->buffer[ 1], 11, k8);
-    Subround(G, d2, e2, a2, b2, c2, ripemd->buffer[ 3], 14, k8);
-    Subround(G, c2, d2, e2, a2, b2, ripemd->buffer[11], 14, k8);
-    Subround(G, b2, c2, d2, e2, a2, ripemd->buffer[15],  6, k8);
-    Subround(G, a2, b2, c2, d2, e2, ripemd->buffer[ 0], 14, k8);
-    Subround(G, e2, a2, b2, c2, d2, ripemd->buffer[ 5],  6, k8);
-    Subround(G, d2, e2, a2, b2, c2, ripemd->buffer[12],  9, k8);
-    Subround(G, c2, d2, e2, a2, b2, ripemd->buffer[ 2], 12, k8);
-    Subround(G, b2, c2, d2, e2, a2, ripemd->buffer[13],  9, k8);
-    Subround(G, a2, b2, c2, d2, e2, ripemd->buffer[ 9], 12, k8);
-    Subround(G, e2, a2, b2, c2, d2, ripemd->buffer[ 7],  5, k8);
-    Subround(G, d2, e2, a2, b2, c2, ripemd->buffer[10], 15, k8);
-    Subround(G, c2, d2, e2, a2, b2, ripemd->buffer[14],  8, k8);
-
-    Subround(F, b2, c2, d2, e2, a2, ripemd->buffer[12],  8, k9);
-    Subround(F, a2, b2, c2, d2, e2, ripemd->buffer[15],  5, k9);
-    Subround(F, e2, a2, b2, c2, d2, ripemd->buffer[10], 12, k9);
-    Subround(F, d2, e2, a2, b2, c2, ripemd->buffer[ 4],  9, k9);
-    Subround(F, c2, d2, e2, a2, b2, ripemd->buffer[ 1], 12, k9);
-    Subround(F, b2, c2, d2, e2, a2, ripemd->buffer[ 5],  5, k9);
-    Subround(F, a2, b2, c2, d2, e2, ripemd->buffer[ 8], 14, k9);
-    Subround(F, e2, a2, b2, c2, d2, ripemd->buffer[ 7],  6, k9);
-    Subround(F, d2, e2, a2, b2, c2, ripemd->buffer[ 6],  8, k9);
-    Subround(F, c2, d2, e2, a2, b2, ripemd->buffer[ 2], 13, k9);
-    Subround(F, b2, c2, d2, e2, a2, ripemd->buffer[13],  6, k9);
-    Subround(F, a2, b2, c2, d2, e2, ripemd->buffer[14],  5, k9);
-    Subround(F, e2, a2, b2, c2, d2, ripemd->buffer[ 0], 15, k9);
-    Subround(F, d2, e2, a2, b2, c2, ripemd->buffer[ 3], 13, k9);
-    Subround(F, c2, d2, e2, a2, b2, ripemd->buffer[ 9], 11, k9);
-    Subround(F, b2, c2, d2, e2, a2, ripemd->buffer[11], 11, k9);
-
-    c1                = ripemd->digest[1] + c1 + d2;
-    ripemd->digest[1] = ripemd->digest[2] + d1 + e2;
-    ripemd->digest[2] = ripemd->digest[3] + e1 + a2;
-    ripemd->digest[3] = ripemd->digest[4] + a1 + b2;
-    ripemd->digest[4] = ripemd->digest[0] + b1 + c2;
-    ripemd->digest[0] = c1;
-}
-
-
-static INLINE void AddLength(RipeMd* ripemd, word32 len)
-{
-    word32 tmp = ripemd->loLen;
-    if ( (ripemd->loLen += len) < tmp)
-        ripemd->hiLen++;                       /* carry low to high */
-}
-
-
-void wc_RipeMdUpdate(RipeMd* ripemd, const byte* data, word32 len)
-{
-    /* do block size increments */
-    byte* local = (byte*)ripemd->buffer;
-
-    while (len) {
-        word32 add = min(len, RIPEMD_BLOCK_SIZE - ripemd->buffLen);
-        XMEMCPY(&local[ripemd->buffLen], data, add);
-
-        ripemd->buffLen += add;
-        data         += add;
-        len          -= add;
-
-        if (ripemd->buffLen == RIPEMD_BLOCK_SIZE) {
-            #ifdef BIG_ENDIAN_ORDER
-                ByteReverseWords(ripemd->buffer, ripemd->buffer,
-                                 RIPEMD_BLOCK_SIZE);
-            #endif
-            Transform(ripemd);
-            AddLength(ripemd, RIPEMD_BLOCK_SIZE);
-            ripemd->buffLen = 0;
-        }
-    }
-}
-
-
-void wc_RipeMdFinal(RipeMd* ripemd, byte* hash)
-{
-    byte* local = (byte*)ripemd->buffer;
-
-    AddLength(ripemd, ripemd->buffLen);               /* before adding pads */
-
-    local[ripemd->buffLen++] = 0x80;  /* add 1 */
-
-    /* pad with zeros */
-    if (ripemd->buffLen > RIPEMD_PAD_SIZE) {
-        XMEMSET(&local[ripemd->buffLen], 0, RIPEMD_BLOCK_SIZE - ripemd->buffLen);
-        ripemd->buffLen += RIPEMD_BLOCK_SIZE - ripemd->buffLen;
-
-        #ifdef BIG_ENDIAN_ORDER
-            ByteReverseWords(ripemd->buffer, ripemd->buffer, RIPEMD_BLOCK_SIZE);
-        #endif
-        Transform(ripemd);
-        ripemd->buffLen = 0;
-    }
-    XMEMSET(&local[ripemd->buffLen], 0, RIPEMD_PAD_SIZE - ripemd->buffLen);
-   
-    /* put lengths in bits */
-    ripemd->loLen = ripemd->loLen << 3;
-    ripemd->hiLen = (ripemd->loLen >> (8*sizeof(ripemd->loLen) - 3)) + 
-                 (ripemd->hiLen << 3);
-
-    /* store lengths */
-    #ifdef BIG_ENDIAN_ORDER
-        ByteReverseWords(ripemd->buffer, ripemd->buffer, RIPEMD_BLOCK_SIZE);
-    #endif
-    /* ! length ordering dependent on digest endian type ! */
-    XMEMCPY(&local[RIPEMD_PAD_SIZE], &ripemd->loLen, sizeof(word32));
-    XMEMCPY(&local[RIPEMD_PAD_SIZE + sizeof(word32)], &ripemd->hiLen, 
-           sizeof(word32));
-
-    Transform(ripemd);
-    #ifdef BIG_ENDIAN_ORDER
-        ByteReverseWords(ripemd->digest, ripemd->digest, RIPEMD_DIGEST_SIZE);
-    #endif
-    XMEMCPY(hash, ripemd->digest, RIPEMD_DIGEST_SIZE);
-
-    wc_InitRipeMd(ripemd);  /* reset state */
-}
-
-
-#endif /* WOLFSSL_RIPEMD */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/rsa.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/rsa.c
deleted file mode 100755
index 1a50217..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/rsa.c
+++ /dev/null
@@ -1,972 +0,0 @@
-/* rsa.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifndef NO_RSA
-
-#include 
-
-#ifdef HAVE_FIPS
-int  wc_InitRsaKey(RsaKey* key, void* ptr)
-{
-    return InitRsaKey_fips(key, ptr);
-}
-
-
-int  wc_FreeRsaKey(RsaKey* key)
-{
-    return FreeRsaKey_fips(key);
-}
-
-
-int  wc_RsaPublicEncrypt(const byte* in, word32 inLen, byte* out,
-                                 word32 outLen, RsaKey* key, RNG* rng)
-{
-    return RsaPublicEncrypt_fips(in, inLen, out, outLen, key, rng);
-}
-
-
-int  wc_RsaPrivateDecryptInline(byte* in, word32 inLen, byte** out,
-                                        RsaKey* key)
-{
-    return RsaPrivateDecryptInline_fips(in, inLen, out, key);
-}
-
-
-int  wc_RsaPrivateDecrypt(const byte* in, word32 inLen, byte* out,
-                                  word32 outLen, RsaKey* key)
-{
-    return RsaPrivateDecrypt_fips(in, inLen, out, outLen, key);
-}
-
-
-int  wc_RsaSSL_Sign(const byte* in, word32 inLen, byte* out,
-                            word32 outLen, RsaKey* key, RNG* rng)
-{
-    return RsaSSL_Sign_fips(in, inLen, out, outLen, key, rng);
-}
-
-
-int  wc_RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out, RsaKey* key)
-{
-    return RsaSSL_VerifyInline_fips(in, inLen, out, key);
-}
-
-
-int  wc_RsaSSL_Verify(const byte* in, word32 inLen, byte* out,
-                              word32 outLen, RsaKey* key)
-{
-    return RsaSSL_Verify_fips(in, inLen, out, outLen, key);
-}
-
-
-int  wc_RsaEncryptSize(RsaKey* key)
-{
-    return RsaEncryptSize_fips(key);
-}
-
-
-int wc_RsaFlattenPublicKey(RsaKey* key, byte* a, word32* aSz, byte* b,
-                           word32* bSz)
-{
-    /* not specified as fips so not needing _fips */
-    return RsaFlattenPublicKey(key, a, aSz, b, bSz);
-}
-#ifdef WOLFSSL_KEY_GEN
-    int wc_MakeRsaKey(RsaKey* key, int size, long e, RNG* rng)
-    {
-        return MakeRsaKey(key, size, e, rng);
-    }
-#endif
-
-
-#ifdef HAVE_CAVIUM
-    int  wc_RsaInitCavium(RsaKey* key, int i)
-    {
-        return RsaInitCavium(key, i);
-    }
-
-
-    void wc_RsaFreeCavium(RsaKey* key)
-    {
-        RsaFreeCavium(key);
-    }
-#endif
-
-/* these are functions in asn and are routed to wolfssl/wolfcrypt/asn.c
-* wc_RsaPrivateKeyDecode
-* wc_RsaPublicKeyDecode
-*/
-
-#else /* else build without fips */
-#include 
-#include 
-#include 
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-#ifdef SHOW_GEN
-    #ifdef FREESCALE_MQX
-        #include 
-    #else
-        #include 
-    #endif
-#endif
-
-#ifdef HAVE_CAVIUM
-    static int  InitCaviumRsaKey(RsaKey* key, void* heap);
-    static int  FreeCaviumRsaKey(RsaKey* key);
-    static int  CaviumRsaPublicEncrypt(const byte* in, word32 inLen, byte* out,
-                                       word32 outLen, RsaKey* key);
-    static int  CaviumRsaPrivateDecrypt(const byte* in, word32 inLen, byte* out,
-                                        word32 outLen, RsaKey* key);
-    static int  CaviumRsaSSL_Sign(const byte* in, word32 inLen, byte* out,
-                                  word32 outLen, RsaKey* key);
-    static int  CaviumRsaSSL_Verify(const byte* in, word32 inLen, byte* out,
-                                    word32 outLen, RsaKey* key);
-#endif
-
-enum {
-    RSA_PUBLIC_ENCRYPT  = 0,
-    RSA_PUBLIC_DECRYPT  = 1,
-    RSA_PRIVATE_ENCRYPT = 2,
-    RSA_PRIVATE_DECRYPT = 3,
-
-    RSA_BLOCK_TYPE_1 = 1,
-    RSA_BLOCK_TYPE_2 = 2,
-
-    RSA_MIN_SIZE = 512,
-    RSA_MAX_SIZE = 4096,
-
-    RSA_MIN_PAD_SZ   = 11      /* seperator + 0 + pad value + 8 pads */
-};
-
-
-int wc_InitRsaKey(RsaKey* key, void* heap)
-{
-#ifdef HAVE_CAVIUM
-    if (key->magic == WOLFSSL_RSA_CAVIUM_MAGIC)
-        return InitCaviumRsaKey(key, heap);
-#endif
-
-    key->type = -1;  /* haven't decided yet */
-    key->heap = heap;
-
-/* TomsFastMath doesn't use memory allocation */
-#ifndef USE_FAST_MATH
-    key->n.dp = key->e.dp = 0;  /* public  alloc parts */
-
-    key->d.dp = key->p.dp  = 0;  /* private alloc parts */
-    key->q.dp = key->dP.dp = 0;  
-    key->u.dp = key->dQ.dp = 0;
-#else
-    mp_init(&key->n);
-    mp_init(&key->e);
-    mp_init(&key->d);
-    mp_init(&key->p);
-    mp_init(&key->q);
-    mp_init(&key->dP);
-    mp_init(&key->dQ);
-    mp_init(&key->u);
-#endif
-
-    return 0;
-}
-
-
-int wc_FreeRsaKey(RsaKey* key)
-{
-    (void)key;
-
-#ifdef HAVE_CAVIUM
-    if (key->magic == WOLFSSL_RSA_CAVIUM_MAGIC)
-        return FreeCaviumRsaKey(key);
-#endif
-
-/* TomsFastMath doesn't use memory allocation */
-#ifndef USE_FAST_MATH
-    if (key->type == RSA_PRIVATE) {
-        mp_clear(&key->u);
-        mp_clear(&key->dQ);
-        mp_clear(&key->dP);
-        mp_clear(&key->q);
-        mp_clear(&key->p);
-        mp_clear(&key->d);
-    }
-    mp_clear(&key->e);
-    mp_clear(&key->n);
-#endif
-
-    return 0;
-}
-
-static int wc_RsaPad(const byte* input, word32 inputLen, byte* pkcsBlock,
-                   word32 pkcsBlockLen, byte padValue, RNG* rng)
-{
-    if (inputLen == 0)
-        return 0;
-
-    pkcsBlock[0] = 0x0;       /* set first byte to zero and advance */
-    pkcsBlock++; pkcsBlockLen--;
-    pkcsBlock[0] = padValue;  /* insert padValue */
-
-    if (padValue == RSA_BLOCK_TYPE_1)
-        /* pad with 0xff bytes */
-        XMEMSET(&pkcsBlock[1], 0xFF, pkcsBlockLen - inputLen - 2);
-    else {
-        /* pad with non-zero random bytes */
-        word32 padLen = pkcsBlockLen - inputLen - 1, i;
-        int    ret    = wc_RNG_GenerateBlock(rng, &pkcsBlock[1], padLen);
-
-        if (ret != 0)
-            return ret;
-
-        /* remove zeros */
-        for (i = 1; i < padLen; i++)
-            if (pkcsBlock[i] == 0) pkcsBlock[i] = 0x01;
-    }
-
-    pkcsBlock[pkcsBlockLen-inputLen-1] = 0;     /* separator */
-    XMEMCPY(pkcsBlock+pkcsBlockLen-inputLen, input, inputLen);
-
-    return 0;
-}
-
-
-/* UnPad plaintext, set start to *output, return length of plaintext,
- * < 0 on error */
-static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
-                       byte **output, byte padValue)
-{
-    word32 maxOutputLen = (pkcsBlockLen > 10) ? (pkcsBlockLen - 10) : 0,
-           invalid = 0,
-           i = 1,
-           outputLen;
-
-    if (pkcsBlock[0] != 0x0) /* skip past zero */
-        invalid = 1;
-    pkcsBlock++; pkcsBlockLen--;
-
-    /* Require block type padValue */
-    invalid = (pkcsBlock[0] != padValue) || invalid;
-
-    /* verify the padding until we find the separator */
-    if (padValue == RSA_BLOCK_TYPE_1) {
-        while (i maxOutputLen) || invalid;
-
-    if (invalid) {
-        WOLFSSL_MSG("RsaUnPad error, bad formatting");
-        return RSA_PAD_E;
-    }
-
-    *output = (byte *)(pkcsBlock + i);
-    return outputLen;
-}
-
-
-static int wc_RsaFunction(const byte* in, word32 inLen, byte* out,
-                          word32* outLen, int type, RsaKey* key)
-{
-    #define ERROR_OUT(x) { ret = (x); goto done;}
-
-    mp_int tmp;
-    int    ret = 0;
-    word32 keyLen, len;
-
-    if (mp_init(&tmp) != MP_OKAY)
-        return MP_INIT_E;
-
-    if (mp_read_unsigned_bin(&tmp, (byte*)in, inLen) != MP_OKAY)
-        ERROR_OUT(MP_READ_E);
-
-    if (type == RSA_PRIVATE_DECRYPT || type == RSA_PRIVATE_ENCRYPT) {
-        #ifdef RSA_LOW_MEM      /* half as much memory but twice as slow */
-            if (mp_exptmod(&tmp, &key->d, &key->n, &tmp) != MP_OKAY)
-                ERROR_OUT(MP_EXPTMOD_E);
-        #else
-            #define INNER_ERROR_OUT(x) { ret = (x); goto inner_done; }
-
-            mp_int tmpa, tmpb;
-
-            if (mp_init(&tmpa) != MP_OKAY)
-                ERROR_OUT(MP_INIT_E);
-
-            if (mp_init(&tmpb) != MP_OKAY) {
-                mp_clear(&tmpa);
-                ERROR_OUT(MP_INIT_E);
-            }
-
-            /* tmpa = tmp^dP mod p */
-            if (mp_exptmod(&tmp, &key->dP, &key->p, &tmpa) != MP_OKAY)
-                INNER_ERROR_OUT(MP_EXPTMOD_E);
-
-            /* tmpb = tmp^dQ mod q */
-            if (mp_exptmod(&tmp, &key->dQ, &key->q, &tmpb) != MP_OKAY)
-                INNER_ERROR_OUT(MP_EXPTMOD_E);
-
-            /* tmp = (tmpa - tmpb) * qInv (mod p) */
-            if (mp_sub(&tmpa, &tmpb, &tmp) != MP_OKAY)
-                INNER_ERROR_OUT(MP_SUB_E);
-
-            if (mp_mulmod(&tmp, &key->u, &key->p, &tmp) != MP_OKAY)
-                INNER_ERROR_OUT(MP_MULMOD_E);
-
-            /* tmp = tmpb + q * tmp */
-            if (mp_mul(&tmp, &key->q, &tmp) != MP_OKAY)
-                INNER_ERROR_OUT(MP_MUL_E);
-
-            if (mp_add(&tmp, &tmpb, &tmp) != MP_OKAY)
-                INNER_ERROR_OUT(MP_ADD_E);
-
-        inner_done:
-            mp_clear(&tmpa);
-            mp_clear(&tmpb);
-
-            if (ret != 0) return ret;
-
-        #endif   /* RSA_LOW_MEM */
-    }
-    else if (type == RSA_PUBLIC_ENCRYPT || type == RSA_PUBLIC_DECRYPT) {
-        if (mp_exptmod(&tmp, &key->e, &key->n, &tmp) != MP_OKAY)
-            ERROR_OUT(MP_EXPTMOD_E);
-    }
-    else
-        ERROR_OUT(RSA_WRONG_TYPE_E);
-
-    keyLen = mp_unsigned_bin_size(&key->n);
-    if (keyLen > *outLen)
-        ERROR_OUT(RSA_BUFFER_E);
-
-    len = mp_unsigned_bin_size(&tmp);
-
-    /* pad front w/ zeros to match key length */
-    while (len < keyLen) {
-        *out++ = 0x00;
-        len++;
-    }
-
-    *outLen = keyLen;
-
-    /* convert */
-    if (mp_to_unsigned_bin(&tmp, out) != MP_OKAY)
-        ERROR_OUT(MP_TO_E);
-
-done:
-    mp_clear(&tmp);
-    if (ret == MP_EXPTMOD_E) {
-        WOLFSSL_MSG("RSA_FUNCTION MP_EXPTMOD_E: memory/config problem");
-    }
-    return ret;
-}
-
-
-int wc_RsaPublicEncrypt(const byte* in, word32 inLen, byte* out, word32 outLen,
-                     RsaKey* key, RNG* rng)
-{
-    int sz, ret;
-
-#ifdef HAVE_CAVIUM
-    if (key->magic == WOLFSSL_RSA_CAVIUM_MAGIC)
-        return CaviumRsaPublicEncrypt(in, inLen, out, outLen, key);
-#endif
-
-    sz = mp_unsigned_bin_size(&key->n);
-    if (sz > (int)outLen)
-        return RSA_BUFFER_E;
-
-    if (inLen > (word32)(sz - RSA_MIN_PAD_SZ))
-        return RSA_BUFFER_E;
-
-    ret = wc_RsaPad(in, inLen, out, sz, RSA_BLOCK_TYPE_2, rng);
-    if (ret != 0)
-        return ret;
-
-    if ((ret = wc_RsaFunction(out, sz, out, &outLen,
-                              RSA_PUBLIC_ENCRYPT, key)) < 0)
-        sz = ret;
-
-    return sz;
-}
-
-
-int wc_RsaPrivateDecryptInline(byte* in, word32 inLen, byte** out, RsaKey* key)
-{
-    int ret;
-
-#ifdef HAVE_CAVIUM
-    if (key->magic == WOLFSSL_RSA_CAVIUM_MAGIC) {
-        ret = CaviumRsaPrivateDecrypt(in, inLen, in, inLen, key);
-        if (ret > 0)
-            *out = in;
-        return ret;
-    }
-#endif
-
-    if ((ret = wc_RsaFunction(in, inLen, in, &inLen, RSA_PRIVATE_DECRYPT, key))
-            < 0) {
-        return ret;
-    }
- 
-    return RsaUnPad(in, inLen, out, RSA_BLOCK_TYPE_2);
-}
-
-
-int wc_RsaPrivateDecrypt(const byte* in, word32 inLen, byte* out, word32 outLen,
-                     RsaKey* key)
-{
-    int plainLen;
-    byte*  tmp;
-    byte*  pad = 0;
-
-#ifdef HAVE_CAVIUM
-    if (key->magic == WOLFSSL_RSA_CAVIUM_MAGIC)
-        return CaviumRsaPrivateDecrypt(in, inLen, out, outLen, key);
-#endif
-
-    tmp = (byte*)XMALLOC(inLen, key->heap, DYNAMIC_TYPE_RSA);
-    if (tmp == NULL) {
-        return MEMORY_E;
-    }
-
-    XMEMCPY(tmp, in, inLen);
-
-    if ( (plainLen = wc_RsaPrivateDecryptInline(tmp, inLen, &pad, key) ) < 0) {
-        XFREE(tmp, key->heap, DYNAMIC_TYPE_RSA);
-        return plainLen;
-    }
-    if (plainLen > (int)outLen)
-        plainLen = BAD_FUNC_ARG;
-    else
-        XMEMCPY(out, pad, plainLen);
-
-    ForceZero(tmp, inLen);
-    XFREE(tmp, key->heap, DYNAMIC_TYPE_RSA);
-
-    return plainLen;
-}
-
-
-/* for Rsa Verify */
-int wc_RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out, RsaKey* key)
-{
-    int ret;
-
-#ifdef HAVE_CAVIUM
-    if (key->magic == WOLFSSL_RSA_CAVIUM_MAGIC) {
-        ret = CaviumRsaSSL_Verify(in, inLen, in, inLen, key);
-        if (ret > 0)
-            *out = in;
-        return ret;
-    }
-#endif
-
-    if ((ret = wc_RsaFunction(in, inLen, in, &inLen, RSA_PUBLIC_DECRYPT, key))
-            < 0) {
-        return ret;
-    }
-  
-    return RsaUnPad(in, inLen, out, RSA_BLOCK_TYPE_1);
-}
-
-
-int wc_RsaSSL_Verify(const byte* in, word32 inLen, byte* out, word32 outLen,
-                     RsaKey* key)
-{
-    int plainLen;
-    byte*  tmp;
-    byte*  pad = 0;
-
-#ifdef HAVE_CAVIUM
-    if (key->magic == WOLFSSL_RSA_CAVIUM_MAGIC)
-        return CaviumRsaSSL_Verify(in, inLen, out, outLen, key);
-#endif
-
-    tmp = (byte*)XMALLOC(inLen, key->heap, DYNAMIC_TYPE_RSA);
-    if (tmp == NULL) {
-        return MEMORY_E;
-    }
-
-    XMEMCPY(tmp, in, inLen);
-
-    if ( (plainLen = wc_RsaSSL_VerifyInline(tmp, inLen, &pad, key) ) < 0) {
-        XFREE(tmp, key->heap, DYNAMIC_TYPE_RSA);
-        return plainLen;
-    }
-
-    if (plainLen > (int)outLen)
-        plainLen = BAD_FUNC_ARG;
-    else
-        XMEMCPY(out, pad, plainLen);
-
-    ForceZero(tmp, inLen);
-    XFREE(tmp, key->heap, DYNAMIC_TYPE_RSA);
-
-    return plainLen;
-}
-
-
-/* for Rsa Sign */
-int wc_RsaSSL_Sign(const byte* in, word32 inLen, byte* out, word32 outLen,
-                      RsaKey* key, RNG* rng)
-{
-    int sz, ret;
-
-#ifdef HAVE_CAVIUM
-    if (key->magic == WOLFSSL_RSA_CAVIUM_MAGIC)
-        return CaviumRsaSSL_Sign(in, inLen, out, outLen, key);
-#endif
-
-    sz = mp_unsigned_bin_size(&key->n);
-    if (sz > (int)outLen)
-        return RSA_BUFFER_E;
-
-    if (inLen > (word32)(sz - RSA_MIN_PAD_SZ))
-        return RSA_BUFFER_E;
-
-    ret = wc_RsaPad(in, inLen, out, sz, RSA_BLOCK_TYPE_1, rng);
-    if (ret != 0)
-        return ret;
-
-    if ((ret = wc_RsaFunction(out, sz, out, &outLen,
-                              RSA_PRIVATE_ENCRYPT,key)) < 0)
-        sz = ret;
-    
-    return sz;
-}
-
-
-int wc_RsaEncryptSize(RsaKey* key)
-{
-#ifdef HAVE_CAVIUM
-    if (key->magic == WOLFSSL_RSA_CAVIUM_MAGIC)
-        return key->c_nSz;
-#endif
-    return mp_unsigned_bin_size(&key->n);
-}
-
-/* flatten RsaKey structure into individual elements (e, n) */
-int wc_RsaFlattenPublicKey(RsaKey* key, byte* e, word32* eSz, byte* n,
-                           word32* nSz)
-{
-    int sz, ret;
-
-    if (key == NULL || e == NULL || eSz == NULL || n == NULL || nSz == NULL)
-       return BAD_FUNC_ARG;
-
-    sz = mp_unsigned_bin_size(&key->e);
-    if ((word32)sz > *nSz)
-        return RSA_BUFFER_E;
-    ret = mp_to_unsigned_bin(&key->e, e);
-    if (ret != MP_OKAY)
-        return ret;
-    *eSz = (word32)sz;
-
-    sz = mp_unsigned_bin_size(&key->n);
-    if ((word32)sz > *nSz)
-        return RSA_BUFFER_E;
-    ret = mp_to_unsigned_bin(&key->n, n);
-    if (ret != MP_OKAY)
-        return ret;
-    *nSz = (word32)sz;
-
-    return 0;
-}
-
-
-#ifdef WOLFSSL_KEY_GEN
-
-static const int USE_BBS = 1;
-
-static int rand_prime(mp_int* N, int len, RNG* rng, void* heap)
-{
-    int   err, res, type;
-    byte* buf;
-
-    (void)heap;
-    if (N == NULL || rng == NULL)
-       return BAD_FUNC_ARG; 
-
-    /* get type */
-    if (len < 0) {
-        type = USE_BBS;
-        len = -len;
-    } else {
-        type = 0;
-    }
-
-    /* allow sizes between 2 and 512 bytes for a prime size */
-    if (len < 2 || len > 512) { 
-        return BAD_FUNC_ARG;
-    }
-   
-    /* allocate buffer to work with */
-    buf = (byte*)XMALLOC(len, heap, DYNAMIC_TYPE_RSA);
-    if (buf == NULL) {
-        return MEMORY_E;
-    }
-    XMEMSET(buf, 0, len);
-
-    do {
-#ifdef SHOW_GEN
-        printf(".");
-        fflush(stdout);
-#endif
-        /* generate value */
-        err = wc_RNG_GenerateBlock(rng, buf, len);
-        if (err != 0) {
-            XFREE(buf, heap, DYNAMIC_TYPE_RSA);
-            return err;
-        }
-
-        /* munge bits */
-        buf[0]     |= 0x80 | 0x40;
-        buf[len-1] |= 0x01 | ((type & USE_BBS) ? 0x02 : 0x00);
- 
-        /* load value */
-        if ((err = mp_read_unsigned_bin(N, buf, len)) != MP_OKAY) {
-            XFREE(buf, heap, DYNAMIC_TYPE_RSA);
-            return err;
-        }
-
-        /* test */
-        if ((err = mp_prime_is_prime(N, 8, &res)) != MP_OKAY) {
-            XFREE(buf, heap, DYNAMIC_TYPE_RSA);
-            return err;
-        }
-    } while (res == MP_NO);
-
-    ForceZero(buf, len);
-    XFREE(buf, heap, DYNAMIC_TYPE_RSA);
-
-    return 0;
-}
-
-
-/* Make an RSA key for size bits, with e specified, 65537 is a good e */
-int wc_MakeRsaKey(RsaKey* key, int size, long e, RNG* rng)
-{
-    mp_int p, q, tmp1, tmp2, tmp3;
-    int    err;
-
-    if (key == NULL || rng == NULL)
-        return BAD_FUNC_ARG;
-
-    if (size < RSA_MIN_SIZE || size > RSA_MAX_SIZE)
-        return BAD_FUNC_ARG;
-
-    if (e < 3 || (e & 1) == 0)
-        return BAD_FUNC_ARG;
-
-    if ((err = mp_init_multi(&p, &q, &tmp1, &tmp2, &tmp3, NULL)) != MP_OKAY)
-        return err;
-
-    err = mp_set_int(&tmp3, e);
-
-    /* make p */
-    if (err == MP_OKAY) {
-        do {
-            err = rand_prime(&p, size/16, rng, key->heap); /* size in bytes/2 */
-
-            if (err == MP_OKAY)
-                err = mp_sub_d(&p, 1, &tmp1);  /* tmp1 = p-1 */
-
-            if (err == MP_OKAY)
-                err = mp_gcd(&tmp1, &tmp3, &tmp2);  /* tmp2 = gcd(p-1, e) */
-        } while (err == MP_OKAY && mp_cmp_d(&tmp2, 1) != 0);  /* e divdes p-1 */
-    }
-
-    /* make q */
-    if (err == MP_OKAY) {
-        do {
-            err = rand_prime(&q, size/16, rng, key->heap); /* size in bytes/2 */
-
-            if (err == MP_OKAY)
-                err = mp_sub_d(&q, 1, &tmp1);  /* tmp1 = q-1 */
-
-            if (err == MP_OKAY)
-                err = mp_gcd(&tmp1, &tmp3, &tmp2);  /* tmp2 = gcd(q-1, e) */
-        } while (err == MP_OKAY && mp_cmp_d(&tmp2, 1) != 0);  /* e divdes q-1 */
-    }
-
-    if (err == MP_OKAY)
-        err = mp_init_multi(&key->n, &key->e, &key->d, &key->p, &key->q, NULL);
-
-    if (err == MP_OKAY)
-        err = mp_init_multi(&key->dP, &key->dQ, &key->u, NULL, NULL, NULL);
-
-    if (err == MP_OKAY)
-        err = mp_sub_d(&p, 1, &tmp2);  /* tmp2 = p-1 */
-
-    if (err == MP_OKAY)
-        err = mp_lcm(&tmp1, &tmp2, &tmp1);  /* tmp1 = lcm(p-1, q-1),last loop */
-
-    /* make key */
-    if (err == MP_OKAY)
-        err = mp_set_int(&key->e, e);  /* key->e = e */
-
-    if (err == MP_OKAY)                /* key->d = 1/e mod lcm(p-1, q-1) */
-        err = mp_invmod(&key->e, &tmp1, &key->d);
-
-    if (err == MP_OKAY)
-        err = mp_mul(&p, &q, &key->n);  /* key->n = pq */
-
-    if (err == MP_OKAY)
-        err = mp_sub_d(&p, 1, &tmp1);
-
-    if (err == MP_OKAY)
-        err = mp_sub_d(&q, 1, &tmp2);
-
-    if (err == MP_OKAY)
-        err = mp_mod(&key->d, &tmp1, &key->dP);
-
-    if (err == MP_OKAY)
-        err = mp_mod(&key->d, &tmp2, &key->dQ);
-
-    if (err == MP_OKAY)
-        err = mp_invmod(&q, &p, &key->u);
-
-    if (err == MP_OKAY)
-        err = mp_copy(&p, &key->p);
-
-    if (err == MP_OKAY)
-        err = mp_copy(&q, &key->q);
-
-    if (err == MP_OKAY)
-        key->type = RSA_PRIVATE; 
-
-    mp_clear(&tmp3); 
-    mp_clear(&tmp2); 
-    mp_clear(&tmp1); 
-    mp_clear(&q); 
-    mp_clear(&p);
-
-    if (err != MP_OKAY) {
-        wc_FreeRsaKey(key);        
-        return err;
-    }
-
-    return 0;
-}
-
-
-#endif /* WOLFSSL_KEY_GEN */
-
-
-#ifdef HAVE_CAVIUM
-
-#include 
-#include "cavium_common.h"
-
-/* Initiliaze RSA for use with Nitrox device */
-int RsaInitCavium(RsaKey* rsa, int devId)
-{
-    if (rsa == NULL)
-        return -1;
-
-    if (CspAllocContext(CONTEXT_SSL, &rsa->contextHandle, devId) != 0)
-        return -1;
-
-    rsa->devId = devId;
-    rsa->magic = WOLFSSL_RSA_CAVIUM_MAGIC;
-   
-    return 0;
-}
-
-
-/* Free RSA from use with Nitrox device */
-void wc_RsaFreeCavium(RsaKey* rsa)
-{
-    if (rsa == NULL)
-        return;
-
-    CspFreeContext(CONTEXT_SSL, rsa->contextHandle, rsa->devId);
-    rsa->magic = 0;
-}
-
-
-/* Initialize cavium RSA key */
-static int InitCaviumRsaKey(RsaKey* key, void* heap)
-{
-    if (key == NULL)
-        return BAD_FUNC_ARG;
-
-    key->heap = heap;
-    key->type = -1;   /* don't know yet */
-
-    key->c_n  = NULL;
-    key->c_e  = NULL;
-    key->c_d  = NULL;
-    key->c_p  = NULL;
-    key->c_q  = NULL;
-    key->c_dP = NULL;
-    key->c_dQ = NULL;
-    key->c_u  = NULL;
-
-    key->c_nSz   = 0;
-    key->c_eSz   = 0;
-    key->c_dSz   = 0;
-    key->c_pSz   = 0;
-    key->c_qSz   = 0;
-    key->c_dP_Sz = 0;
-    key->c_dQ_Sz = 0;
-    key->c_uSz   = 0;
-    
-    return 0;
-}
-
-
-/* Free cavium RSA key */
-static int FreeCaviumRsaKey(RsaKey* key)
-{
-    if (key == NULL)
-        return BAD_FUNC_ARG;
-
-    XFREE(key->c_n,  key->heap, DYNAMIC_TYPE_CAVIUM_TMP);
-    XFREE(key->c_e,  key->heap, DYNAMIC_TYPE_CAVIUM_TMP);
-    XFREE(key->c_d,  key->heap, DYNAMIC_TYPE_CAVIUM_TMP);
-    XFREE(key->c_p,  key->heap, DYNAMIC_TYPE_CAVIUM_TMP);
-    XFREE(key->c_q,  key->heap, DYNAMIC_TYPE_CAVIUM_TMP);
-    XFREE(key->c_dP, key->heap, DYNAMIC_TYPE_CAVIUM_TMP);
-    XFREE(key->c_dQ, key->heap, DYNAMIC_TYPE_CAVIUM_TMP);
-    XFREE(key->c_u,  key->heap, DYNAMIC_TYPE_CAVIUM_TMP);
-
-    return InitCaviumRsaKey(key, key->heap);  /* reset pointers */
-}
-
-
-static int CaviumRsaPublicEncrypt(const byte* in, word32 inLen, byte* out,
-                                   word32 outLen, RsaKey* key)
-{
-    word32 requestId;
-    word32 ret;
-
-    if (key == NULL || in == NULL || out == NULL || outLen < (word32)key->c_nSz)
-        return -1;
-
-    ret = CspPkcs1v15Enc(CAVIUM_BLOCKING, BT2, key->c_nSz, key->c_eSz,
-                         (word16)inLen, key->c_n, key->c_e, (byte*)in, out,
-                         &requestId, key->devId);
-    if (ret != 0) {
-        WOLFSSL_MSG("Cavium Enc BT2 failed");
-        return -1;
-    }
-    return key->c_nSz;
-}
-
-
-static INLINE void ato16(const byte* c, word16* u16)
-{
-    *u16 = (c[0] << 8) | (c[1]);
-}
-
-
-static int CaviumRsaPrivateDecrypt(const byte* in, word32 inLen, byte* out,
-                                    word32 outLen, RsaKey* key)
-{
-    word32 requestId;
-    word32 ret;
-    word16 outSz = (word16)outLen;
-
-    if (key == NULL || in == NULL || out == NULL || inLen != (word32)key->c_nSz)
-        return -1;
-
-    ret = CspPkcs1v15CrtDec(CAVIUM_BLOCKING, BT2, key->c_nSz, key->c_q,
-                            key->c_dQ, key->c_p, key->c_dP, key->c_u,
-                            (byte*)in, &outSz, out, &requestId, key->devId);
-    if (ret != 0) {
-        WOLFSSL_MSG("Cavium CRT Dec BT2 failed");
-        return -1;
-    }
-    ato16((const byte*)&outSz, &outSz); 
-
-    return outSz;
-}
-
-
-static int CaviumRsaSSL_Sign(const byte* in, word32 inLen, byte* out,
-                             word32 outLen, RsaKey* key)
-{
-    word32 requestId;
-    word32 ret;
-
-    if (key == NULL || in == NULL || out == NULL || inLen == 0 || outLen <
-                                                             (word32)key->c_nSz)
-        return -1;
-
-    ret = CspPkcs1v15CrtEnc(CAVIUM_BLOCKING, BT1, key->c_nSz, (word16)inLen,
-                            key->c_q, key->c_dQ, key->c_p, key->c_dP, key->c_u,
-                            (byte*)in, out, &requestId, key->devId);
-    if (ret != 0) {
-        WOLFSSL_MSG("Cavium CRT Enc BT1 failed");
-        return -1;
-    }
-    return key->c_nSz;
-}
-
-
-static int CaviumRsaSSL_Verify(const byte* in, word32 inLen, byte* out,
-                               word32 outLen, RsaKey* key)
-{
-    word32 requestId;
-    word32 ret;
-    word16 outSz = (word16)outLen;
-
-    if (key == NULL || in == NULL || out == NULL || inLen != (word32)key->c_nSz)
-        return -1;
-
-    ret = CspPkcs1v15Dec(CAVIUM_BLOCKING, BT1, key->c_nSz, key->c_eSz,
-                         key->c_n, key->c_e, (byte*)in, &outSz, out,
-                         &requestId, key->devId);
-    if (ret != 0) {
-        WOLFSSL_MSG("Cavium Dec BT1 failed");
-        return -1;
-    }
-    outSz = ntohs(outSz);
-
-    return outSz;
-}
-
-
-#endif /* HAVE_CAVIUM */
-
-#endif /* HAVE_FIPS */
-#endif /* NO_RSA */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/sha.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/sha.c
deleted file mode 100755
index be8cf17..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/sha.c
+++ /dev/null
@@ -1,458 +0,0 @@
-/* sha.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#if !defined(NO_SHA)
-
-#include 
-#include 
-#include 
-
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-/* fips wrapper calls, user can call direct */
-#ifdef HAVE_FIPS
-	int wc_InitSha(Sha* sha)
-	{
-	    return InitSha_fips(sha);
-	}
-
-
-	int wc_ShaUpdate(Sha* sha, const byte* data, word32 len)
-	{
-	    return ShaUpdate_fips(sha, data, len);
-	}
-
-
-	int wc_ShaFinal(Sha* sha, byte* out)
-	{
-	    return ShaFinal_fips(sha,out);
-    }
-
-    int wc_ShaHash(const byte* data, word32 sz, byte* out)
-    {
-        return ShaHash(data, sz, out);
-    }
-
-#else /* else build without fips */
-
-#if defined(WOLFSSL_TI_HASH)
-    /* #include  included by wc_port.c */
-#else
-
-#ifdef WOLFSSL_PIC32MZ_HASH
-#define wc_InitSha   wc_InitSha_sw
-#define wc_ShaUpdate wc_ShaUpdate_sw
-#define wc_ShaFinal  wc_ShaFinal_sw
-#endif
-
-
-#ifdef FREESCALE_MMCAU
-    #include "cau_api.h"
-    #define XTRANSFORM(S,B)  cau_sha1_hash_n((B), 1, ((S))->digest)
-#else
-    #define XTRANSFORM(S,B)  Transform((S))
-#endif
-
-#ifdef STM32F2_HASH
-/*
- * STM32F2 hardware SHA1 support through the STM32F2 standard peripheral
- * library. Documentation located in STM32F2xx Standard Peripheral Library
- * document (See note in README).
- */
-#include "stm32f2xx.h"
-#include "stm32f2xx_hash.h"
-
-int wc_InitSha(Sha* sha)
-{
-    /* STM32F2 struct notes:
-     * sha->buffer  = first 4 bytes used to hold partial block if needed
-     * sha->buffLen = num bytes currently stored in sha->buffer
-     * sha->loLen   = num bytes that have been written to STM32 FIFO
-     */
-    XMEMSET(sha->buffer, 0, SHA_REG_SIZE);
-    sha->buffLen = 0;
-    sha->loLen = 0;
-
-    /* initialize HASH peripheral */
-    HASH_DeInit();
-
-    /* configure algo used, algo mode, datatype */
-    HASH->CR &= ~ (HASH_CR_ALGO | HASH_CR_DATATYPE | HASH_CR_MODE);
-    HASH->CR |= (HASH_AlgoSelection_SHA1 | HASH_AlgoMode_HASH
-                 | HASH_DataType_8b);
-
-    /* reset HASH processor */
-    HASH->CR |= HASH_CR_INIT;
-
-    return 0;
-}
-
-int wc_ShaUpdate(Sha* sha, const byte* data, word32 len)
-{
-    word32 i = 0;
-    word32 fill = 0;
-    word32 diff = 0;
-
-    /* if saved partial block is available */
-    if (sha->buffLen) {
-        fill = 4 - sha->buffLen;
-
-        /* if enough data to fill, fill and push to FIFO */
-        if (fill <= len) {
-            XMEMCPY((byte*)sha->buffer + sha->buffLen, data, fill);
-            HASH_DataIn(*(uint32_t*)sha->buffer);
-
-            data += fill;
-            len -= fill;
-            sha->loLen += 4;
-            sha->buffLen = 0;
-        } else {
-            /* append partial to existing stored block */
-            XMEMCPY((byte*)sha->buffer + sha->buffLen, data, len);
-            sha->buffLen += len;
-            return;
-        }
-    }
-
-    /* write input block in the IN FIFO */
-    for(i = 0; i < len; i += 4)
-    {
-        diff = len - i;
-        if ( diff < 4) {
-            /* store incomplete last block, not yet in FIFO */
-            XMEMSET(sha->buffer, 0, SHA_REG_SIZE);
-            XMEMCPY((byte*)sha->buffer, data, diff);
-            sha->buffLen = diff;
-        } else {
-            HASH_DataIn(*(uint32_t*)data);
-            data+=4;
-        }
-    }
-
-    /* keep track of total data length thus far */
-    sha->loLen += (len - sha->buffLen);
-
-    return 0;
-}
-
-int wc_ShaFinal(Sha* sha, byte* hash)
-{
-    __IO uint16_t nbvalidbitsdata = 0;
-
-    /* finish reading any trailing bytes into FIFO */
-    if (sha->buffLen) {
-        HASH_DataIn(*(uint32_t*)sha->buffer);
-        sha->loLen += sha->buffLen;
-    }
-
-    /* calculate number of valid bits in last word of input data */
-    nbvalidbitsdata = 8 * (sha->loLen % SHA_REG_SIZE);
-
-    /* configure number of valid bits in last word of the data */
-    HASH_SetLastWordValidBitsNbr(nbvalidbitsdata);
-
-    /* start HASH processor */
-    HASH_StartDigest();
-
-    /* wait until Busy flag == RESET */
-    while (HASH_GetFlagStatus(HASH_FLAG_BUSY) != RESET) {}
-
-    /* read message digest */
-    sha->digest[0] = HASH->HR[0];
-    sha->digest[1] = HASH->HR[1];
-    sha->digest[2] = HASH->HR[2];
-    sha->digest[3] = HASH->HR[3];
-    sha->digest[4] = HASH->HR[4];
-
-    ByteReverseWords(sha->digest, sha->digest, SHA_DIGEST_SIZE);
-
-    XMEMCPY(hash, sha->digest, SHA_DIGEST_SIZE);
-
-    return wc_InitSha(sha);  /* reset state */
-}
-
-#else /* wc_ software implementation */
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-
-int wc_InitSha(Sha* sha)
-{
-#ifdef FREESCALE_MMCAU
-    cau_sha1_initialize_output(sha->digest);
-#else
-    sha->digest[0] = 0x67452301L;
-    sha->digest[1] = 0xEFCDAB89L;
-    sha->digest[2] = 0x98BADCFEL;
-    sha->digest[3] = 0x10325476L;
-    sha->digest[4] = 0xC3D2E1F0L;
-#endif
-
-    sha->buffLen = 0;
-    sha->loLen   = 0;
-    sha->hiLen   = 0;
-
-    return 0;
-}
-
-#ifndef FREESCALE_MMCAU
-
-#define blk0(i) (W[i] = sha->buffer[i])
-#define blk1(i) (W[(i)&15] = \
-rotlFixed(W[((i)+13)&15]^W[((i)+8)&15]^W[((i)+2)&15]^W[(i)&15],1))
-
-#define f1(x,y,z) ((z)^((x) &((y)^(z))))
-#define f2(x,y,z) ((x)^(y)^(z))
-#define f3(x,y,z) (((x)&(y))|((z)&((x)|(y))))
-#define f4(x,y,z) ((x)^(y)^(z))
-
-/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
-#define R0(v,w,x,y,z,i) (z)+= f1((w),(x),(y)) + blk0((i)) + 0x5A827999+ \
-rotlFixed((v),5); (w) = rotlFixed((w),30);
-#define R1(v,w,x,y,z,i) (z)+= f1((w),(x),(y)) + blk1((i)) + 0x5A827999+ \
-rotlFixed((v),5); (w) = rotlFixed((w),30);
-#define R2(v,w,x,y,z,i) (z)+= f2((w),(x),(y)) + blk1((i)) + 0x6ED9EBA1+ \
-rotlFixed((v),5); (w) = rotlFixed((w),30);
-#define R3(v,w,x,y,z,i) (z)+= f3((w),(x),(y)) + blk1((i)) + 0x8F1BBCDC+ \
-rotlFixed((v),5); (w) = rotlFixed((w),30);
-#define R4(v,w,x,y,z,i) (z)+= f4((w),(x),(y)) + blk1((i)) + 0xCA62C1D6+ \
-rotlFixed((v),5); (w) = rotlFixed((w),30);
-
-static void Transform(Sha* sha)
-{
-    word32 W[SHA_BLOCK_SIZE / sizeof(word32)];
-
-    /* Copy context->state[] to working vars */
-    word32 a = sha->digest[0];
-    word32 b = sha->digest[1];
-    word32 c = sha->digest[2];
-    word32 d = sha->digest[3];
-    word32 e = sha->digest[4];
-
-#ifdef USE_SLOW_SHA
-    word32 t, i;
-
-    for (i = 0; i < 16; i++) {
-        R0(a, b, c, d, e, i);
-        t = e; e = d; d = c; c = b; b = a; a = t;
-    }
-
-    for (; i < 20; i++) {
-        R1(a, b, c, d, e, i);
-        t = e; e = d; d = c; c = b; b = a; a = t;
-    }
-
-    for (; i < 40; i++) {
-        R2(a, b, c, d, e, i);
-        t = e; e = d; d = c; c = b; b = a; a = t;
-    }
-
-    for (; i < 60; i++) {
-        R3(a, b, c, d, e, i);
-        t = e; e = d; d = c; c = b; b = a; a = t;
-    }
-
-    for (; i < 80; i++) {
-        R4(a, b, c, d, e, i);
-        t = e; e = d; d = c; c = b; b = a; a = t;
-    }
-#else
-    /* nearly 1 K bigger in code size but 25% faster  */
-    /* 4 rounds of 20 operations each. Loop unrolled. */
-    R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
-    R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
-    R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
-    R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
-
-    R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
-
-    R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
-    R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
-    R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
-    R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
-    R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
-
-    R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
-    R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
-    R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
-    R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
-    R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
-
-    R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
-    R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
-    R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
-    R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
-    R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
-#endif
-
-    /* Add the working vars back into digest state[] */
-    sha->digest[0] += a;
-    sha->digest[1] += b;
-    sha->digest[2] += c;
-    sha->digest[3] += d;
-    sha->digest[4] += e;
-}
-
-#endif /* FREESCALE_MMCAU */
-
-
-static INLINE void AddLength(Sha* sha, word32 len)
-{
-    word32 tmp = sha->loLen;
-    if ( (sha->loLen += len) < tmp)
-        sha->hiLen++;                       /* carry low to high */
-}
-
-
-int wc_ShaUpdate(Sha* sha, const byte* data, word32 len)
-{
-    /* do block size increments */
-    byte* local = (byte*)sha->buffer;
-
-    while (len) {
-        word32 add = min(len, SHA_BLOCK_SIZE - sha->buffLen);
-        XMEMCPY(&local[sha->buffLen], data, add);
-
-        sha->buffLen += add;
-        data         += add;
-        len          -= add;
-
-        if (sha->buffLen == SHA_BLOCK_SIZE) {
-#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
-            ByteReverseWords(sha->buffer, sha->buffer, SHA_BLOCK_SIZE);
-#endif
-            XTRANSFORM(sha, local);
-            AddLength(sha, SHA_BLOCK_SIZE);
-            sha->buffLen = 0;
-        }
-    }
-
-    return 0;
-}
-
-
-int wc_ShaFinal(Sha* sha, byte* hash)
-{
-    byte* local = (byte*)sha->buffer;
-
-    AddLength(sha, sha->buffLen);  /* before adding pads */
-
-    local[sha->buffLen++] = 0x80;  /* add 1 */
-
-    /* pad with zeros */
-    if (sha->buffLen > SHA_PAD_SIZE) {
-        XMEMSET(&local[sha->buffLen], 0, SHA_BLOCK_SIZE - sha->buffLen);
-        sha->buffLen += SHA_BLOCK_SIZE - sha->buffLen;
-
-#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
-        ByteReverseWords(sha->buffer, sha->buffer, SHA_BLOCK_SIZE);
-#endif
-        XTRANSFORM(sha, local);
-        sha->buffLen = 0;
-    }
-    XMEMSET(&local[sha->buffLen], 0, SHA_PAD_SIZE - sha->buffLen);
-
-    /* put lengths in bits */
-    sha->hiLen = (sha->loLen >> (8*sizeof(sha->loLen) - 3)) +
-    (sha->hiLen << 3);
-    sha->loLen = sha->loLen << 3;
-
-    /* store lengths */
-#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
-    ByteReverseWords(sha->buffer, sha->buffer, SHA_BLOCK_SIZE);
-#endif
-    /* ! length ordering dependent on digest endian type ! */
-    XMEMCPY(&local[SHA_PAD_SIZE], &sha->hiLen, sizeof(word32));
-    XMEMCPY(&local[SHA_PAD_SIZE + sizeof(word32)], &sha->loLen, sizeof(word32));
-
-#ifdef FREESCALE_MMCAU
-    /* Kinetis requires only these bytes reversed */
-    ByteReverseWords(&sha->buffer[SHA_PAD_SIZE/sizeof(word32)],
-                     &sha->buffer[SHA_PAD_SIZE/sizeof(word32)],
-                     2 * sizeof(word32));
-#endif
-
-    XTRANSFORM(sha, local);
-#ifdef LITTLE_ENDIAN_ORDER
-    ByteReverseWords(sha->digest, sha->digest, SHA_DIGEST_SIZE);
-#endif
-    XMEMCPY(hash, sha->digest, SHA_DIGEST_SIZE);
-
-    return wc_InitSha(sha);  /* reset state */
-}
-
-#endif /* STM32F2_HASH */
-
-
-int wc_ShaHash(const byte* data, word32 len, byte* hash)
-{
-    int ret = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    Sha* sha;
-#else
-    Sha sha[1];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    sha = (Sha*)XMALLOC(sizeof(Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (sha == NULL)
-        return MEMORY_E;
-#endif
-
-    if ((ret = wc_InitSha(sha)) != 0) {
-        WOLFSSL_MSG("wc_InitSha failed");
-    }
-    else {
-        wc_ShaUpdate(sha, data, len);
-        wc_ShaFinal(sha, hash);
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-
-}
-
-#endif /* HAVE_FIPS */
-#endif /* WOLFSSL_TI_HASH */
-#endif /* NO_SHA */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/sha256.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/sha256.c
deleted file mode 100755
index f9f02b0..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/sha256.c
+++ /dev/null
@@ -1,1766 +0,0 @@
-/* sha256.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/* code submitted by raphael.huck@efixo.com */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-#include 
-
-#if !defined(NO_SHA256)
-#ifdef HAVE_FIPS
-
-int wc_InitSha256(Sha256* sha)
-{
-    return InitSha256_fips(sha);
-}
-
-
-int wc_Sha256Update(Sha256* sha, const byte* data, word32 len)
-{
-    return Sha256Update_fips(sha, data, len);
-}
-
-
-int wc_Sha256Final(Sha256* sha, byte* out)
-{
-    return Sha256Final_fips(sha, out);
-}
-
-
-int wc_Sha256Hash(const byte* data, word32 len, byte* out)
-{
-    return Sha256Hash(data, len, out);
-}
-
-#else /* else build without fips */
-
-#if !defined(NO_SHA256) && defined(WOLFSSL_TI_HASH)
-    /* #include  included by wc_port.c */
-#else
-
-#if !defined (ALIGN32)
-    #if defined (__GNUC__)
-        #define ALIGN32 __attribute__ ( (aligned (32)))
-    #elif defined(_MSC_VER)
-        /* disable align warning, we want alignment ! */
-        #pragma warning(disable: 4324)
-        #define ALIGN32 __declspec (align (32))
-    #else
-        #define ALIGN32
-    #endif
-#endif
-
-#ifdef WOLFSSL_PIC32MZ_HASH
-#define wc_InitSha256   wc_InitSha256_sw
-#define wc_Sha256Update wc_Sha256Update_sw
-#define wc_Sha256Final  wc_Sha256Final_sw
-#endif
-
-#ifdef HAVE_FIPS
-    /* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */
-    #define FIPS_NO_WRAPPERS
-#endif
-
-#if defined(USE_INTEL_SPEEDUP)
-#define HAVE_INTEL_AVX1
-#define HAVE_INTEL_AVX2
-
-#if defined(DEBUG_XMM)
-#include "stdio.h"
-#endif
-
-#endif
-
-#if defined(HAVE_INTEL_AVX2)
-#define HAVE_INTEL_RORX
-#endif
- 
-
-/*****
-Intel AVX1/AVX2 Macro Control Structure
-
-#define HAVE_INTEL_AVX1
-#define HAVE_INTEL_AVX2
-
-#define HAVE_INTEL_RORX
-
-
-int InitSha256(Sha256* sha256) { 
-     Save/Recover XMM, YMM
-     ...
-}
-
-#if defined(HAVE_INTEL_AVX1)|| defined(HAVE_INTEL_AVX2)
-  Transform() ; Function prototype 
-#else
-  Transform() {   }
-  int Sha256Final() { 
-     Save/Recover XMM, YMM
-     ...
-  }
-#endif
-
-#if defined(HAVE_INTEL_AVX1)|| defined(HAVE_INTEL_AVX2)
-    #if defined(HAVE_INTEL_RORX
-         #define RND with rorx instuction
-    #else
-        #define RND
-    #endif
-#endif
-
-#if defined(HAVE_INTEL_AVX1)
-   
-   #define XMM Instructions/inline asm
-   
-   int Transform() {
-       Stitched Message Sched/Round
-    } 
-   
-#elif defined(HAVE_INTEL_AVX2)
-  
-  #define YMM Instructions/inline asm
-  
-  int Transform() {
-      More granural Stitched Message Sched/Round
-  }
-  
-*/
-
-
-#if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-
-/* Each platform needs to query info type 1 from cpuid to see if aesni is
- * supported. Also, let's setup a macro for proper linkage w/o ABI conflicts
- */
-
-#ifndef _MSC_VER
-    #define cpuid(reg, leaf, sub)\
-            __asm__ __volatile__ ("cpuid":\
-             "=a" (reg[0]), "=b" (reg[1]), "=c" (reg[2]), "=d" (reg[3]) :\
-             "a" (leaf), "c"(sub));
-
-    #define XASM_LINK(f) asm(f)
-#else
-
-    #include 
-    #define cpuid(a,b) __cpuid((int*)a,b)
-
-    #define XASM_LINK(f)
-
-#endif /* _MSC_VER */
-
-#define EAX 0
-#define EBX 1
-#define ECX 2 
-#define EDX 3
-    
-#define CPUID_AVX1   0x1
-#define CPUID_AVX2   0x2
-#define CPUID_RDRAND 0x4
-#define CPUID_RDSEED 0x8
-#define CPUID_BMI2   0x10   /* MULX, RORX */
-
-#define IS_INTEL_AVX1       (cpuid_flags&CPUID_AVX1)
-#define IS_INTEL_AVX2       (cpuid_flags&CPUID_AVX2)
-#define IS_INTEL_BMI2       (cpuid_flags&CPUID_BMI2)
-#define IS_INTEL_RDRAND     (cpuid_flags&CPUID_RDRAND)
-#define IS_INTEL_RDSEED     (cpuid_flags&CPUID_RDSEED)
-
-static word32 cpuid_check = 0 ;
-static word32 cpuid_flags = 0 ;
-
-static word32 cpuid_flag(word32 leaf, word32 sub, word32 num, word32 bit) {
-    int got_intel_cpu=0;
-    unsigned int reg[5]; 
-    
-    reg[4] = '\0' ;
-    cpuid(reg, 0, 0);  
-    if(memcmp((char *)&(reg[EBX]), "Genu", 4) == 0 &&  
-                memcmp((char *)&(reg[EDX]), "ineI", 4) == 0 &&  
-                memcmp((char *)&(reg[ECX]), "ntel", 4) == 0) {  
-        got_intel_cpu = 1;  
-    }    
-    if (got_intel_cpu) {
-        cpuid(reg, leaf, sub);
-        return((reg[num]>>bit)&0x1) ;
-    }
-    return 0 ;
-}
-
-static int set_cpuid_flags(void) {  
-    if(cpuid_check==0) {
-        if(cpuid_flag(1, 0, ECX, 28)){ cpuid_flags |= CPUID_AVX1 ;}
-        if(cpuid_flag(7, 0, EBX, 5)){  cpuid_flags |= CPUID_AVX2 ; }
-        if(cpuid_flag(7, 0, EBX, 8)) { cpuid_flags |= CPUID_BMI2 ; }
-        if(cpuid_flag(1, 0, ECX, 30)){ cpuid_flags |= CPUID_RDRAND ;  } 
-        if(cpuid_flag(7, 0, EBX, 18)){ cpuid_flags |= CPUID_RDSEED ;  }
-        cpuid_check = 1 ;
-        return 0 ;
-    }
-    return 1 ;
-}
-
-
-/* #if defined(HAVE_INTEL_AVX1/2) at the tail of sha512 */
-static int Transform(Sha256* sha256);
-
-#if defined(HAVE_INTEL_AVX1)
-static int Transform_AVX1(Sha256 *sha256) ;
-#endif
-#if defined(HAVE_INTEL_AVX2)
-static int Transform_AVX2(Sha256 *sha256) ; 
-static int Transform_AVX1_RORX(Sha256 *sha256) ; 
-#endif
-
-static int (*Transform_p)(Sha256* sha256) /* = _Transform */;
-
-#define XTRANSFORM(sha256, B)  (*Transform_p)(sha256)
-
-static void set_Transform(void) {
-     if(set_cpuid_flags())return ;
-
-#if defined(HAVE_INTEL_AVX2)
-     if(IS_INTEL_AVX2 && IS_INTEL_BMI2){ 
-         Transform_p = Transform_AVX1_RORX; return ; 
-         Transform_p = Transform_AVX2      ; 
-                  /* for avoiding warning,"not used" */
-     }
-#endif
-#if defined(HAVE_INTEL_AVX1)
-     Transform_p = ((IS_INTEL_AVX1) ? Transform_AVX1 : Transform) ; return ;
-#endif
-     Transform_p = Transform ; return ;
-}
-
-#else
-   #if defined(FREESCALE_MMCAU)
-      #define XTRANSFORM(sha256, B) Transform(sha256, B)
-   #else
-      #define XTRANSFORM(sha256, B) Transform(sha256)
-   #endif
-#endif
-
-/* Dummy for saving MM_REGs on behalf of Transform */
-#if defined(HAVE_INTEL_AVX2)&& !defined(HAVE_INTEL_AVX1)
-#define  SAVE_XMM_YMM   __asm__ volatile("or %%r8d, %%r8d":::\
-  "%ymm4","%ymm5","%ymm6","%ymm7","%ymm8","%ymm9","%ymm10","%ymm11","%ymm12","%ymm13","%ymm14","%ymm15")
-#elif defined(HAVE_INTEL_AVX1)
-#define  SAVE_XMM_YMM   __asm__ volatile("or %%r8d, %%r8d":::\
-    "xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7","xmm8","xmm9","xmm10",\
-    "xmm11","xmm12","xmm13","xmm14","xmm15")
-#else
-#define  SAVE_XMM_YMM
-#endif
-
-#ifdef WOLFSSL_PIC32MZ_HASH
-#define InitSha256   InitSha256_sw
-#define Sha256Update Sha256Update_sw
-#define Sha256Final  Sha256Final_sw
-#endif
-
-#include 
-#include 
-
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-#ifdef FREESCALE_MMCAU
-    #include "cau_api.h"
-#endif
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-
-int wc_InitSha256(Sha256* sha256)
-{
-    #ifdef FREESCALE_MMCAU
-        cau_sha256_initialize_output(sha256->digest);
-    #else
-        sha256->digest[0] = 0x6A09E667L;
-        sha256->digest[1] = 0xBB67AE85L;
-        sha256->digest[2] = 0x3C6EF372L;
-        sha256->digest[3] = 0xA54FF53AL;
-        sha256->digest[4] = 0x510E527FL;
-        sha256->digest[5] = 0x9B05688CL;
-        sha256->digest[6] = 0x1F83D9ABL;
-        sha256->digest[7] = 0x5BE0CD19L;
-    #endif
-
-    sha256->buffLen = 0;
-    sha256->loLen   = 0;
-    sha256->hiLen   = 0;
-    
-#if defined(HAVE_INTEL_AVX1)|| defined(HAVE_INTEL_AVX2)
-    set_Transform() ; /* choose best Transform function under this runtime environment */
-#endif
-
-    return 0;
-}
-
-
-#if !defined(FREESCALE_MMCAU)
-static const ALIGN32 word32 K[64] = {
-    0x428A2F98L, 0x71374491L, 0xB5C0FBCFL, 0xE9B5DBA5L, 0x3956C25BL,
-    0x59F111F1L, 0x923F82A4L, 0xAB1C5ED5L, 0xD807AA98L, 0x12835B01L,
-    0x243185BEL, 0x550C7DC3L, 0x72BE5D74L, 0x80DEB1FEL, 0x9BDC06A7L,
-    0xC19BF174L, 0xE49B69C1L, 0xEFBE4786L, 0x0FC19DC6L, 0x240CA1CCL,
-    0x2DE92C6FL, 0x4A7484AAL, 0x5CB0A9DCL, 0x76F988DAL, 0x983E5152L,
-    0xA831C66DL, 0xB00327C8L, 0xBF597FC7L, 0xC6E00BF3L, 0xD5A79147L,
-    0x06CA6351L, 0x14292967L, 0x27B70A85L, 0x2E1B2138L, 0x4D2C6DFCL,
-    0x53380D13L, 0x650A7354L, 0x766A0ABBL, 0x81C2C92EL, 0x92722C85L,
-    0xA2BFE8A1L, 0xA81A664BL, 0xC24B8B70L, 0xC76C51A3L, 0xD192E819L,
-    0xD6990624L, 0xF40E3585L, 0x106AA070L, 0x19A4C116L, 0x1E376C08L,
-    0x2748774CL, 0x34B0BCB5L, 0x391C0CB3L, 0x4ED8AA4AL, 0x5B9CCA4FL,
-    0x682E6FF3L, 0x748F82EEL, 0x78A5636FL, 0x84C87814L, 0x8CC70208L,
-    0x90BEFFFAL, 0xA4506CEBL, 0xBEF9A3F7L, 0xC67178F2L
-};
-
-#endif
-
-#if defined(FREESCALE_MMCAU)
-
-static int Transform(Sha256* sha256, byte* buf)
-{
-    cau_sha256_hash_n(buf, 1, sha256->digest);
-
-    return 0;
-}
-
-#endif /* FREESCALE_MMCAU */
-
-#define Ch(x,y,z)       ((z) ^ ((x) & ((y) ^ (z))))
-#define Maj(x,y,z)      ((((x) | (y)) & (z)) | ((x) & (y)))
-#define R(x, n)         (((x)&0xFFFFFFFFU)>>(n))
-
-#define S(x, n)         rotrFixed(x, n)
-#define Sigma0(x)       (S(x, 2) ^ S(x, 13) ^ S(x, 22))
-#define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
-#define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
-#define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
-
-#define RND(a,b,c,d,e,f,g,h,i) \
-     t0 = (h) + Sigma1((e)) + Ch((e), (f), (g)) + K[(i)] + W[(i)]; \
-     t1 = Sigma0((a)) + Maj((a), (b), (c)); \
-     (d) += t0; \
-     (h)  = t0 + t1;
-
-#if !defined(FREESCALE_MMCAU)
-static int Transform(Sha256* sha256)
-{
-    word32 S[8], t0, t1;
-    int i;
-
-#ifdef WOLFSSL_SMALL_STACK
-    word32* W;
-
-    W = (word32*) XMALLOC(sizeof(word32) * 64, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (W == NULL)
-        return MEMORY_E;
-#else
-    word32 W[64];
-#endif
-
-    /* Copy context->state[] to working vars */
-    for (i = 0; i < 8; i++)
-        S[i] = sha256->digest[i];
-
-    for (i = 0; i < 16; i++)
-        W[i] = sha256->buffer[i];
-
-    for (i = 16; i < 64; i++)
-        W[i] = Gamma1(W[i-2]) + W[i-7] + Gamma0(W[i-15]) + W[i-16];
-
-    for (i = 0; i < 64; i += 8) {
-        RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i+0);
-        RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],i+1);
-        RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],i+2);
-        RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],i+3);
-        RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],i+4);
-        RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],i+5);
-        RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],i+6);
-        RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7);
-    }
-
-    /* Add the working vars back into digest state[] */
-    for (i = 0; i < 8; i++) {
-        sha256->digest[i] += S[i];
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(W, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return 0;
-}
-
-#endif /* #if !defined(FREESCALE_MMCAU) */
-
-static INLINE void AddLength(Sha256* sha256, word32 len)
-{
-    word32 tmp = sha256->loLen;
-    if ( (sha256->loLen += len) < tmp)
-        sha256->hiLen++;                       /* carry low to high */
-}
-
-int wc_Sha256Update(Sha256* sha256, const byte* data, word32 len)
-{
-
-    /* do block size increments */
-    byte* local = (byte*)sha256->buffer;
-
-    SAVE_XMM_YMM ; /* for Intel AVX */
-
-    while (len) {
-        word32 add = min(len, SHA256_BLOCK_SIZE - sha256->buffLen);
-        XMEMCPY(&local[sha256->buffLen], data, add);
-
-        sha256->buffLen += add;
-        data            += add;
-        len             -= add;
-
-        if (sha256->buffLen == SHA256_BLOCK_SIZE) {
-            int ret;
-
-            #if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
-                #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-                if(!IS_INTEL_AVX1 && !IS_INTEL_AVX2)
-                #endif
-                ByteReverseWords(sha256->buffer, sha256->buffer,
-                                 SHA256_BLOCK_SIZE);
-            #endif
-            ret = XTRANSFORM(sha256, local);
-            if (ret != 0)
-                return ret;
-
-            AddLength(sha256, SHA256_BLOCK_SIZE);
-            sha256->buffLen = 0;
-        }
-    }
-
-    return 0;
-}
-
-int wc_Sha256Final(Sha256* sha256, byte* hash)
-{
-    byte* local = (byte*)sha256->buffer;
-    int ret;
-    
-    SAVE_XMM_YMM ; /* for Intel AVX */
-
-    AddLength(sha256, sha256->buffLen);  /* before adding pads */
-
-    local[sha256->buffLen++] = 0x80;     /* add 1 */
-
-    /* pad with zeros */
-    if (sha256->buffLen > SHA256_PAD_SIZE) {
-        XMEMSET(&local[sha256->buffLen], 0, SHA256_BLOCK_SIZE - sha256->buffLen);
-        sha256->buffLen += SHA256_BLOCK_SIZE - sha256->buffLen;
-
-        #if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
-            #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-            if(!IS_INTEL_AVX1 && !IS_INTEL_AVX2)
-            #endif
-            ByteReverseWords(sha256->buffer, sha256->buffer, SHA256_BLOCK_SIZE);
-        #endif
-
-        ret = XTRANSFORM(sha256, local);
-        if (ret != 0)
-            return ret;
-
-        sha256->buffLen = 0;
-    }
-    XMEMSET(&local[sha256->buffLen], 0, SHA256_PAD_SIZE - sha256->buffLen);
-
-    /* put lengths in bits */
-    sha256->hiLen = (sha256->loLen >> (8*sizeof(sha256->loLen) - 3)) +
-                 (sha256->hiLen << 3);
-    sha256->loLen = sha256->loLen << 3;
-
-    /* store lengths */
-    #if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
-        #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-        if(!IS_INTEL_AVX1 && !IS_INTEL_AVX2)
-        #endif
-            ByteReverseWords(sha256->buffer, sha256->buffer, SHA256_BLOCK_SIZE);
-    #endif
-    /* ! length ordering dependent on digest endian type ! */
-    XMEMCPY(&local[SHA256_PAD_SIZE], &sha256->hiLen, sizeof(word32));
-    XMEMCPY(&local[SHA256_PAD_SIZE + sizeof(word32)], &sha256->loLen,
-            sizeof(word32));
-
-    #if defined(FREESCALE_MMCAU) || defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-        /* Kinetis requires only these bytes reversed */
-        #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-        if(IS_INTEL_AVX1 || IS_INTEL_AVX2)
-        #endif
-        ByteReverseWords(&sha256->buffer[SHA256_PAD_SIZE/sizeof(word32)],
-                         &sha256->buffer[SHA256_PAD_SIZE/sizeof(word32)],
-                         2 * sizeof(word32));
-    #endif
-
-    ret = XTRANSFORM(sha256, local);
-    if (ret != 0)
-        return ret;
-
-    #if defined(LITTLE_ENDIAN_ORDER)
-        ByteReverseWords(sha256->digest, sha256->digest, SHA256_DIGEST_SIZE);
-    #endif
-    XMEMCPY(hash, sha256->digest, SHA256_DIGEST_SIZE);
-
-    return wc_InitSha256(sha256);  /* reset state */
-}
-
-
-
-int wc_Sha256Hash(const byte* data, word32 len, byte* hash)
-{
-    int ret = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    Sha256* sha256;
-#else
-    Sha256 sha256[1];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    sha256 = (Sha256*)XMALLOC(sizeof(Sha256), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (sha256 == NULL)
-        return MEMORY_E;
-#endif
-
-    if ((ret = wc_InitSha256(sha256)) != 0) {
-        WOLFSSL_MSG("InitSha256 failed");
-    }
-    else if ((ret = wc_Sha256Update(sha256, data, len)) != 0) {
-        WOLFSSL_MSG("Sha256Update failed");
-    }
-    else if ((ret = wc_Sha256Final(sha256, hash)) != 0) {
-        WOLFSSL_MSG("Sha256Final failed");
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(sha256, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-#if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-
-#define _DigestToReg(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )\
-    { word32 d ;\
-    d = sha256->digest[0]; __asm__ volatile("movl %0, %"#S_0::"r"(d):SSE_REGs) ;\
-    d = sha256->digest[1]; __asm__ volatile("movl %0, %"#S_1::"r"(d):SSE_REGs) ;\
-    d = sha256->digest[2]; __asm__ volatile("movl %0, %"#S_2::"r"(d):SSE_REGs) ;\
-    d = sha256->digest[3]; __asm__ volatile("movl %0, %"#S_3::"r"(d):SSE_REGs) ;\
-    d = sha256->digest[4]; __asm__ volatile("movl %0, %"#S_4::"r"(d):SSE_REGs) ;\
-    d = sha256->digest[5]; __asm__ volatile("movl %0, %"#S_5::"r"(d):SSE_REGs) ;\
-    d = sha256->digest[6]; __asm__ volatile("movl %0, %"#S_6::"r"(d):SSE_REGs) ;\
-    d = sha256->digest[7]; __asm__ volatile("movl %0, %"#S_7::"r"(d):SSE_REGs) ;\
-}
-
-#define _RegToDigest(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )\
-    { word32 d ; \
-    __asm__ volatile("movl %"#S_0", %0":"=r"(d)::SSE_REGs) ; sha256->digest[0] += d;\
-    __asm__ volatile("movl %"#S_1", %0":"=r"(d)::SSE_REGs) ; sha256->digest[1] += d;\
-    __asm__ volatile("movl %"#S_2", %0":"=r"(d)::SSE_REGs) ; sha256->digest[2] += d;\
-    __asm__ volatile("movl %"#S_3", %0":"=r"(d)::SSE_REGs) ; sha256->digest[3] += d;\
-    __asm__ volatile("movl %"#S_4", %0":"=r"(d)::SSE_REGs) ; sha256->digest[4] += d;\
-    __asm__ volatile("movl %"#S_5", %0":"=r"(d)::SSE_REGs) ; sha256->digest[5] += d;\
-    __asm__ volatile("movl %"#S_6", %0":"=r"(d)::SSE_REGs) ; sha256->digest[6] += d;\
-    __asm__ volatile("movl %"#S_7", %0":"=r"(d)::SSE_REGs) ; sha256->digest[7] += d;\
-}
-
-
-#define DigestToReg(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )\
-    _DigestToReg(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )
-
-#define RegToDigest(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )\
-    _RegToDigest(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )
-
-
-
-
-#define S_0 %r15d 
-#define S_1 %r10d
-#define S_2 %r11d       
-#define S_3 %r12d
-#define S_4 %r13d
-#define S_5 %r14d
-#define S_6 %ebx
-#define S_7 %r9d
-
-#define SSE_REGs "%edi", "%ecx", "%esi", "%edx", "%ebx","%r8","%r9","%r10","%r11","%r12","%r13","%r14","%r15"
-
-#if defined(HAVE_INTEL_RORX)
-#define RND_STEP_RORX_1(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("rorx  $6, %"#e", %%edx\n\t":::"%edx",SSE_REGs);  /* edx = e>>6 */\
-
-#define RND_STEP_RORX_2(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("rorx  $11, %"#e",%%edi\n\t":::"%edi",SSE_REGs); /* edi = e>>11  */\
-__asm__ volatile("xorl  %%edx, %%edi\n\t":::"%edx","%edi",SSE_REGs); /* edi = (e>>11) ^ (e>>6)  */\
-__asm__ volatile("rorx  $25, %"#e", %%edx\n\t":::"%edx",SSE_REGs);   /* edx = e>>25             */\
-
-#define RND_STEP_RORX_3(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("movl  %"#f", %%esi\n\t":::"%esi",SSE_REGs);  /* esi = f   */\
-__asm__ volatile("xorl  %"#g", %%esi\n\t":::"%esi",SSE_REGs);  /* esi = f ^ g  */\
-__asm__ volatile("xorl  %%edi, %%edx\n\t":::"%edi","%edx",SSE_REGs);  /* edx = Sigma1(e)  */\
-__asm__ volatile("andl  %"#e", %%esi\n\t":::"%esi",SSE_REGs);  /* esi = (f ^ g) & e       */\
-__asm__ volatile("xorl  %"#g", %%esi\n\t":::"%esi",SSE_REGs);  /* esi = Ch(e,f,g)         */\
-
-#define RND_STEP_RORX_4(a,b,c,d,e,f,g,h,i)\
-/*__asm__ volatile("movl    %0, %%edx\n\t"::"m"(w_k):"%edx");*/\
-__asm__ volatile("addl  %0, %"#h"\n\t"::"r"(W_K[i]):SSE_REGs);    /* h += w_k  */\
-__asm__ volatile("addl  %%edx, %"#h"\n\t":::"%edx",SSE_REGs);     /* h = h + w_k + Sigma1(e) */\
-__asm__ volatile("rorx  $2, %"#a", %%r8d\n\t":::"%r8",SSE_REGs);  /* r8d = a>>2   */\
-__asm__ volatile("rorx  $13, %"#a", %%edi\n\t":::"%edi",SSE_REGs);/* edi = a>>13  */\
-
-#define RND_STEP_RORX_5(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("rorx  $22, %"#a", %%edx\n\t":::"%edx",SSE_REGs); /* edx = a>>22 */\
-__asm__ volatile("xorl  %%r8d, %%edi\n\t":::"%edi","%r8",SSE_REGs);/* edi = (a>>2) ^ (a>>13)  */\
-__asm__ volatile("xorl  %%edi, %%edx\n\t":::"%edi","%edx",SSE_REGs);  /* edx = Sigma0(a)      */\
- 
-#define RND_STEP_RORX_6(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("movl  %"#b", %%edi\n\t":::"%edi",SSE_REGs);  /* edi = b          */\
-__asm__ volatile("orl   %"#a", %%edi\n\t":::"%edi",SSE_REGs);  /* edi = a | b      */\
-__asm__ volatile("andl  %"#c", %%edi\n\t":::"%edi",SSE_REGs);  /* edi = (a | b) & c*/\
-__asm__ volatile("movl  %"#b", %%r8d\n\t":::"%r8",SSE_REGs);  /* r8d = b           */\
-
-#define RND_STEP_RORX_7(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("addl  %%esi, %"#h"\n\t":::"%esi",SSE_REGs);  /* h += Ch(e,f,g)   */\
-__asm__ volatile("andl  %"#a", %%r8d\n\t":::"%r8",SSE_REGs);  /* r8d = b & a       */\
-__asm__ volatile("orl   %%edi, %%r8d\n\t":::"%edi","%r8",SSE_REGs); /* r8d = Maj(a,b,c) */\
-
-#define RND_STEP_RORX_8(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("addl  "#h", "#d"\n\t");  /* d += h + w_k + Sigma1(e) + Ch(e,f,g) */\
-__asm__ volatile("addl  %"#h", %%r8d\n\t":::"%r8",SSE_REGs); \
-__asm__ volatile("addl  %%edx, %%r8d\n\t":::"%edx","%r8",SSE_REGs); \
-__asm__ volatile("movl  %r8d, "#h"\n\t");   
-
-#endif
-
-#define RND_STEP_1(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("movl  %"#e", %%edx\n\t":::"%edx",SSE_REGs);\
-__asm__ volatile("roll  $26, %%edx\n\t":::"%edx",SSE_REGs);  /* edx = e>>6     */\
-__asm__ volatile("movl  %"#e", %%edi\n\t":::"%edi",SSE_REGs);\
-
-#define RND_STEP_2(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("roll  $21, %%edi\n\t":::"%edi",SSE_REGs);         /* edi = e>>11 */\
-__asm__ volatile("xorl  %%edx, %%edi\n\t":::"%edx","%edi",SSE_REGs); /* edi = (e>>11) ^ (e>>6)  */\
-__asm__ volatile("movl  %"#e", %%edx\n\t":::"%edx",SSE_REGs);   /* edx = e      */\
-__asm__ volatile("roll  $7, %%edx\n\t":::"%edx",SSE_REGs);      /* edx = e>>25  */\
-
-#define RND_STEP_3(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("movl  %"#f", %%esi\n\t":::"%esi",SSE_REGs);  /* esi = f       */\
-__asm__ volatile("xorl  %"#g", %%esi\n\t":::"%esi",SSE_REGs);  /* esi = f ^ g   */\
-__asm__ volatile("xorl  %%edi, %%edx\n\t":::"%edi","%edx",SSE_REGs); /* edx = Sigma1(e) */\
-__asm__ volatile("andl  %"#e", %%esi\n\t":::"%esi",SSE_REGs);  /* esi = (f ^ g) & e  */\
-__asm__ volatile("xorl  %"#g", %%esi\n\t":::"%esi",SSE_REGs);  /* esi = Ch(e,f,g)    */\
-
-#define RND_STEP_4(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("addl  %0, %"#h"\n\t"::"r"(W_K[i]):SSE_REGs); /* h += w_k  */\
-__asm__ volatile("addl  %%edx, %"#h"\n\t":::"%edx",SSE_REGs); /* h = h + w_k + Sigma1(e) */\
-__asm__ volatile("movl  %"#a", %%r8d\n\t":::"%r8",SSE_REGs);  /* r8d = a    */\
-__asm__ volatile("roll  $30, %%r8d\n\t":::"%r8",SSE_REGs);    /* r8d = a>>2 */\
-__asm__ volatile("movl  %"#a", %%edi\n\t":::"%edi",SSE_REGs);  /* edi = a   */\
-__asm__ volatile("roll  $19, %%edi\n\t":::"%edi",SSE_REGs);    /* edi = a>>13 */\
-__asm__ volatile("movl  %"#a", %%edx\n\t":::"%edx",SSE_REGs);  /* edx = a     */\
-
-#define RND_STEP_5(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("roll  $10, %%edx\n\t":::"%edx",SSE_REGs);    /* edx = a>>22 */\
-__asm__ volatile("xorl  %%r8d, %%edi\n\t":::"%edi","%r8",SSE_REGs); /* edi = (a>>2) ^ (a>>13)  */\
-__asm__ volatile("xorl  %%edi, %%edx\n\t":::"%edi","%edx",SSE_REGs);/* edx = Sigma0(a)         */\
-
-#define RND_STEP_6(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("movl  %"#b", %%edi\n\t":::"%edi",SSE_REGs);  /* edi = b      */\
-__asm__ volatile("orl   %"#a", %%edi\n\t":::"%edi",SSE_REGs);  /* edi = a | b  */\
-__asm__ volatile("andl  %"#c", %%edi\n\t":::"%edi",SSE_REGs);  /* edi = (a | b) & c */\
-__asm__ volatile("movl  %"#b", %%r8d\n\t":::"%r8",SSE_REGs);  /* r8d = b       */\
-
-#define RND_STEP_7(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("addl  %%esi, %"#h"\n\t":::"%esi",SSE_REGs);  /* h += Ch(e,f,g)        */\
-__asm__ volatile("andl  %"#a", %%r8d\n\t":::"%r8",SSE_REGs);  /* r8d = b & a            */\
-__asm__ volatile("orl   %%edi, %%r8d\n\t":::"%edi","%r8",SSE_REGs); /* r8d = Maj(a,b,c) */\
-
-#define RND_STEP_8(a,b,c,d,e,f,g,h,i)\
-__asm__ volatile("addl  "#h", "#d"\n\t");  /* d += h + w_k + Sigma1(e) + Ch(e,f,g) */\
-__asm__ volatile("addl  %"#h", %%r8d\n\t":::"%r8",SSE_REGs); \
-                 /* r8b = h + w_k + Sigma1(e) + Ch(e,f,g) + Maj(a,b,c) */\
-__asm__ volatile("addl  %%edx, %%r8d\n\t":::"%edx","%r8",SSE_REGs);\
-                 /* r8b = h + w_k + Sigma1(e) Sigma0(a) + Ch(e,f,g) + Maj(a,b,c)     */\
-__asm__ volatile("movl  %%r8d, %"#h"\n\t":::"%r8", SSE_REGs); \
-                 /* h = h + w_k + Sigma1(e) + Sigma0(a) + Ch(e,f,g) + Maj(a,b,c) */ \
-
-#define RND_X(a,b,c,d,e,f,g,h,i) \
-       RND_STEP_1(a,b,c,d,e,f,g,h,i); \
-       RND_STEP_2(a,b,c,d,e,f,g,h,i); \
-       RND_STEP_3(a,b,c,d,e,f,g,h,i); \
-       RND_STEP_4(a,b,c,d,e,f,g,h,i); \
-       RND_STEP_5(a,b,c,d,e,f,g,h,i); \
-       RND_STEP_6(a,b,c,d,e,f,g,h,i); \
-       RND_STEP_7(a,b,c,d,e,f,g,h,i); \
-       RND_STEP_8(a,b,c,d,e,f,g,h,i); 
-
-#define RND_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i);
-#define RND_7(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_7,S_0,S_1,S_2,S_3,S_4,S_5,S_6,_i);
-#define RND_6(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_6,S_7,S_0,S_1,S_2,S_3,S_4,S_5,_i);
-#define RND_5(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_5,S_6,S_7,S_0,S_1,S_2,S_3,S_4,_i);
-#define RND_4(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,_i);
-#define RND_3(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_3,S_4,S_5,S_6,S_7,S_0,S_1,S_2,_i);
-#define RND_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_2,S_3,S_4,S_5,S_6,S_7,S_0,S_1,_i);
-#define RND_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_1,S_2,S_3,S_4,S_5,S_6,S_7,S_0,_i);
-
-
-#define RND_1_3(a,b,c,d,e,f,g,h,i) {\
-       RND_STEP_1(a,b,c,d,e,f,g,h,i); \
-       RND_STEP_2(a,b,c,d,e,f,g,h,i); \
-       RND_STEP_3(a,b,c,d,e,f,g,h,i); \
-}
-
-#define RND_4_6(a,b,c,d,e,f,g,h,i) {\
-       RND_STEP_4(a,b,c,d,e,f,g,h,i); \
-       RND_STEP_5(a,b,c,d,e,f,g,h,i); \
-       RND_STEP_6(a,b,c,d,e,f,g,h,i); \
-}
-
-#define RND_7_8(a,b,c,d,e,f,g,h,i) {\
-       RND_STEP_7(a,b,c,d,e,f,g,h,i); \
-       RND_STEP_8(a,b,c,d,e,f,g,h,i); \
-}
-
-#define RND_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i);
-#define RND_7(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_7,S_0,S_1,S_2,S_3,S_4,S_5,S_6,_i);
-#define RND_6(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_6,S_7,S_0,S_1,S_2,S_3,S_4,S_5,_i);
-#define RND_5(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_5,S_6,S_7,S_0,S_1,S_2,S_3,S_4,_i);
-#define RND_4(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,_i);
-#define RND_3(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_3,S_4,S_5,S_6,S_7,S_0,S_1,S_2,_i);
-#define RND_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_2,S_3,S_4,S_5,S_6,S_7,S_0,S_1,_i);
-#define RND_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_X(S_1,S_2,S_3,S_4,S_5,S_6,S_7,S_0,_i);
-
-
-#define RND_0_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_1_3(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i);
-#define RND_7_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_1_3(S_7,S_0,S_1,S_2,S_3,S_4,S_5,S_6,_i);
-#define RND_6_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_1_3(S_6,S_7,S_0,S_1,S_2,S_3,S_4,S_5,_i);
-#define RND_5_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_1_3(S_5,S_6,S_7,S_0,S_1,S_2,S_3,S_4,_i);
-#define RND_4_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_1_3(S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,_i);
-#define RND_3_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_1_3(S_3,S_4,S_5,S_6,S_7,S_0,S_1,S_2,_i);
-#define RND_2_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_1_3(S_2,S_3,S_4,S_5,S_6,S_7,S_0,S_1,_i);
-#define RND_1_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_1_3(S_1,S_2,S_3,S_4,S_5,S_6,S_7,S_0,_i);
-
-#define RND_0_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_4_6(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i);
-#define RND_7_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_4_6(S_7,S_0,S_1,S_2,S_3,S_4,S_5,S_6,_i);
-#define RND_6_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_4_6(S_6,S_7,S_0,S_1,S_2,S_3,S_4,S_5,_i);
-#define RND_5_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_4_6(S_5,S_6,S_7,S_0,S_1,S_2,S_3,S_4,_i);
-#define RND_4_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_4_6(S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,_i);
-#define RND_3_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_4_6(S_3,S_4,S_5,S_6,S_7,S_0,S_1,S_2,_i);
-#define RND_2_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_4_6(S_2,S_3,S_4,S_5,S_6,S_7,S_0,S_1,_i);
-#define RND_1_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_4_6(S_1,S_2,S_3,S_4,S_5,S_6,S_7,S_0,_i);
-
-#define RND_0_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_7_8(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i);
-#define RND_7_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_7_8(S_7,S_0,S_1,S_2,S_3,S_4,S_5,S_6,_i);
-#define RND_6_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_7_8(S_6,S_7,S_0,S_1,S_2,S_3,S_4,S_5,_i);
-#define RND_5_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_7_8(S_5,S_6,S_7,S_0,S_1,S_2,S_3,S_4,_i);
-#define RND_4_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_7_8(S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,_i);
-#define RND_3_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_7_8(S_3,S_4,S_5,S_6,S_7,S_0,S_1,S_2,_i);
-#define RND_2_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_7_8(S_2,S_3,S_4,S_5,S_6,S_7,S_0,S_1,_i);
-#define RND_1_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,_i) RND_7_8(S_1,S_2,S_3,S_4,S_5,S_6,S_7,S_0,_i);
-
-#define FOR(cnt, init, max, inc, loop)  \
-    __asm__ volatile("movl $"#init", %0\n\t"#loop":"::"m"(cnt):) 
-#define END(cnt, init, max, inc, loop)  \
-    __asm__ volatile("addl $"#inc", %0\n\tcmpl $"#max", %0\n\tjle "#loop"\n\t":"=m"(cnt)::) ;
-
-#endif  /* defined(HAVE_INTEL_AVX1) ||  defined(HAVE_INTEL_AVX2) */
-
-#if defined(HAVE_INTEL_AVX1) /* inline Assember for Intel AVX1 instructions */
-
-#define VPALIGNR(op1,op2,op3,op4) __asm__ volatile("vpalignr $"#op4", %"#op3", %"#op2", %"#op1:::XMM_REGs) 
-#define VPADDD(op1,op2,op3)       __asm__ volatile("vpaddd %"#op3", %"#op2", %"#op1:::XMM_REGs)
-#define VPSRLD(op1,op2,op3)       __asm__ volatile("vpsrld $"#op3", %"#op2", %"#op1:::XMM_REGs)
-#define VPSRLQ(op1,op2,op3)       __asm__ volatile("vpsrlq $"#op3", %"#op2", %"#op1:::XMM_REGs)
-#define VPSLLD(op1,op2,op3)       __asm__ volatile("vpslld $"#op3", %"#op2", %"#op1:::XMM_REGs)
-#define VPOR(op1,op2,op3)         __asm__ volatile("vpor   %"#op3", %"#op2", %"#op1:::XMM_REGs)
-#define VPXOR(op1,op2,op3)        __asm__ volatile("vpxor  %"#op3", %"#op2", %"#op1:::XMM_REGs)
-#define VPSHUFD(op1,op2,op3)      __asm__ volatile("vpshufd $"#op3", %"#op2", %"#op1:::XMM_REGs)
-#define VPSHUFB(op1,op2,op3)      __asm__ volatile("vpshufb %"#op3", %"#op2", %"#op1:::XMM_REGs)
-
-#define MessageSched(X0, X1, X2, X3, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, XFER, SHUF_00BA, SHUF_DC00,\
-     a,b,c,d,e,f,g,h,_i)\
-            RND_STEP_1(a,b,c,d,e,f,g,h,_i);\
-    VPALIGNR (XTMP0, X3, X2, 4) ;\
-            RND_STEP_2(a,b,c,d,e,f,g,h,_i);\
-    VPADDD   (XTMP0, XTMP0, X0) ;\
-            RND_STEP_3(a,b,c,d,e,f,g,h,_i);\
-    VPALIGNR (XTMP1, X1, X0, 4) ;   /* XTMP1 = W[-15] */\
-            RND_STEP_4(a,b,c,d,e,f,g,h,_i);\
-    VPSRLD   (XTMP2, XTMP1, 7) ;\
-            RND_STEP_5(a,b,c,d,e,f,g,h,_i);\
-    VPSLLD   (XTMP3, XTMP1, 25) ; /* VPSLLD   (XTMP3, XTMP1, (32-7)) */\
-            RND_STEP_6(a,b,c,d,e,f,g,h,_i);\
-    VPOR     (XTMP3, XTMP3, XTMP2)  ;  /* XTMP1 = W[-15] MY_ROR 7 */\
-            RND_STEP_7(a,b,c,d,e,f,g,h,_i);\
-    VPSRLD   (XTMP2, XTMP1,18) ;\
-            RND_STEP_8(a,b,c,d,e,f,g,h,_i);\
-\
-            RND_STEP_1(h,a,b,c,d,e,f,g,_i+1);\
-    VPSRLD   (XTMP4, XTMP1, 3)      ;  /* XTMP4 = W[-15] >> 3 */\
-            RND_STEP_2(h,a,b,c,d,e,f,g,_i+1);\
-    VPSLLD   (XTMP1, XTMP1, 14) ; /* VPSLLD   (XTMP1, XTMP1, (32-18)) */\
-            RND_STEP_3(h,a,b,c,d,e,f,g,_i+1);\
-    VPXOR    (XTMP3, XTMP3, XTMP1)  ;\
-            RND_STEP_4(h,a,b,c,d,e,f,g,_i+1);\
-    VPXOR    (XTMP3, XTMP3, XTMP2)  ;  /* XTMP1 = W[-15] MY_ROR 7 ^ W[-15] MY_ROR 18 */\
-            RND_STEP_5(h,a,b,c,d,e,f,g,_i+1);\
-    VPXOR    (XTMP1, XTMP3, XTMP4)  ;  /* XTMP1 = s0 */\
-            RND_STEP_6(h,a,b,c,d,e,f,g,_i+1);\
-    VPSHUFD(XTMP2, X3, 0b11111010)  ;  /* XTMP2 = W[-2] {BBAA}*/\
-            RND_STEP_7(h,a,b,c,d,e,f,g,_i+1);\
-    VPADDD   (XTMP0, XTMP0, XTMP1)  ;  /* XTMP0 = W[-16] + W[-7] + s0 */\
-            RND_STEP_8(h,a,b,c,d,e,f,g,_i+1);\
-\
-            RND_STEP_1(g,h,a,b,c,d,e,f,_i+2);\
-    VPSRLD   (XTMP4, XTMP2, 10) ;      /* XTMP4 = W[-2] >> 10 {BBAA} */\
-            RND_STEP_2(g,h,a,b,c,d,e,f,_i+2);\
-    VPSRLQ   (XTMP3, XTMP2, 19) ;      /* XTMP3 = W[-2] MY_ROR 19 {xBxA} */\
-            RND_STEP_3(g,h,a,b,c,d,e,f,_i+2);\
-    VPSRLQ   (XTMP2, XTMP2, 17) ;      /* XTMP2 = W[-2] MY_ROR 17 {xBxA} */\
-            RND_STEP_4(g,h,a,b,c,d,e,f,_i+2);\
-    VPXOR    (XTMP2, XTMP2, XTMP3) ;\
-            RND_STEP_5(g,h,a,b,c,d,e,f,_i+2);\
-    VPXOR    (XTMP4, XTMP4, XTMP2) ;   /* XTMP4 = s1 {xBxA} */\
-            RND_STEP_6(g,h,a,b,c,d,e,f,_i+2);\
-    VPSHUFB  (XTMP4, XTMP4, SHUF_00BA)  ;  /* XTMP4 = s1 {00BA} */\
-            RND_STEP_7(g,h,a,b,c,d,e,f,_i+2);\
-    VPADDD   (XTMP0, XTMP0, XTMP4)  ;  /* XTMP0 = {..., ..., W[1], W[0]} */\
-            RND_STEP_8(g,h,a,b,c,d,e,f,_i+2);\
-\
-            RND_STEP_1(f,g,h,a,b,c,d,e,_i+3);\
-    VPSHUFD  (XTMP2, XTMP0, 0b01010000) ; /* XTMP2 = W[-2] {DDCC} */\
-            RND_STEP_2(f,g,h,a,b,c,d,e,_i+3);\
-    VPSRLD   (XTMP5, XTMP2, 10);       /* XTMP5 = W[-2] >> 10 {DDCC} */\
-            RND_STEP_3(f,g,h,a,b,c,d,e,_i+3);\
-    VPSRLQ   (XTMP3, XTMP2, 19);       /* XTMP3 = W[-2] MY_ROR 19 {xDxC} */\
-            RND_STEP_4(f,g,h,a,b,c,d,e,_i+3);\
-    VPSRLQ   (XTMP2, XTMP2, 17) ;      /* XTMP2 = W[-2] MY_ROR 17 {xDxC} */\
-            RND_STEP_5(f,g,h,a,b,c,d,e,_i+3);\
-    VPXOR    (XTMP2, XTMP2, XTMP3) ;\
-            RND_STEP_6(f,g,h,a,b,c,d,e,_i+3);\
-    VPXOR    (XTMP5, XTMP5, XTMP2) ;   /* XTMP5 = s1 {xDxC} */\
-            RND_STEP_7(f,g,h,a,b,c,d,e,_i+3);\
-    VPSHUFB  (XTMP5, XTMP5, SHUF_DC00) ; /* XTMP5 = s1 {DC00} */\
-            RND_STEP_8(f,g,h,a,b,c,d,e,_i+3);\
-    VPADDD   (X0, XTMP5, XTMP0) ;      /* X0 = {W[3], W[2], W[1], W[0]} */\
-
-#if defined(HAVE_INTEL_RORX)
-
-#define MessageSched_RORX(X0, X1, X2, X3, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, \
-                          XFER, SHUF_00BA, SHUF_DC00,a,b,c,d,e,f,g,h,_i)\
-            RND_STEP_RORX_1(a,b,c,d,e,f,g,h,_i);\
-    VPALIGNR (XTMP0, X3, X2, 4) ;\
-            RND_STEP_RORX_2(a,b,c,d,e,f,g,h,_i);\
-    VPADDD   (XTMP0, XTMP0, X0) ;\
-            RND_STEP_RORX_3(a,b,c,d,e,f,g,h,_i);\
-    VPALIGNR (XTMP1, X1, X0, 4) ;   /* XTMP1 = W[-15] */\
-            RND_STEP_RORX_4(a,b,c,d,e,f,g,h,_i);\
-    VPSRLD   (XTMP2, XTMP1, 7) ;\
-            RND_STEP_RORX_5(a,b,c,d,e,f,g,h,_i);\
-    VPSLLD   (XTMP3, XTMP1, 25) ; /* VPSLLD   (XTMP3, XTMP1, (32-7)) */\
-            RND_STEP_RORX_6(a,b,c,d,e,f,g,h,_i);\
-    VPOR     (XTMP3, XTMP3, XTMP2)  ;  /* XTMP1 = W[-15] MY_ROR 7 */\
-            RND_STEP_RORX_7(a,b,c,d,e,f,g,h,_i);\
-    VPSRLD   (XTMP2, XTMP1,18) ;\
-            RND_STEP_RORX_8(a,b,c,d,e,f,g,h,_i);\
-\
-            RND_STEP_RORX_1(h,a,b,c,d,e,f,g,_i+1);\
-    VPSRLD   (XTMP4, XTMP1, 3)      ;  /* XTMP4 = W[-15] >> 3 */\
-            RND_STEP_RORX_2(h,a,b,c,d,e,f,g,_i+1);\
-    VPSLLD   (XTMP1, XTMP1, 14) ; /* VPSLLD   (XTMP1, XTMP1, (32-18)) */\
-            RND_STEP_RORX_3(h,a,b,c,d,e,f,g,_i+1);\
-    VPXOR    (XTMP3, XTMP3, XTMP1)  ;\
-            RND_STEP_RORX_4(h,a,b,c,d,e,f,g,_i+1);\
-    VPXOR    (XTMP3, XTMP3, XTMP2)  ;  /* XTMP1 = W[-15] MY_ROR 7 ^ W[-15] MY_ROR 18 */\
-            RND_STEP_RORX_5(h,a,b,c,d,e,f,g,_i+1);\
-    VPXOR    (XTMP1, XTMP3, XTMP4)  ;  /* XTMP1 = s0 */\
-            RND_STEP_RORX_6(h,a,b,c,d,e,f,g,_i+1);\
-    VPSHUFD(XTMP2, X3, 0b11111010)  ;  /* XTMP2 = W[-2] {BBAA}*/\
-            RND_STEP_RORX_7(h,a,b,c,d,e,f,g,_i+1);\
-    VPADDD   (XTMP0, XTMP0, XTMP1)  ;  /* XTMP0 = W[-16] + W[-7] + s0 */\
-            RND_STEP_RORX_8(h,a,b,c,d,e,f,g,_i+1);\
-\
-            RND_STEP_RORX_1(g,h,a,b,c,d,e,f,_i+2);\
-    VPSRLD   (XTMP4, XTMP2, 10) ;      /* XTMP4 = W[-2] >> 10 {BBAA} */\
-            RND_STEP_RORX_2(g,h,a,b,c,d,e,f,_i+2);\
-    VPSRLQ   (XTMP3, XTMP2, 19) ;      /* XTMP3 = W[-2] MY_ROR 19 {xBxA} */\
-            RND_STEP_RORX_3(g,h,a,b,c,d,e,f,_i+2);\
-    VPSRLQ   (XTMP2, XTMP2, 17) ;      /* XTMP2 = W[-2] MY_ROR 17 {xBxA} */\
-            RND_STEP_RORX_4(g,h,a,b,c,d,e,f,_i+2);\
-    VPXOR    (XTMP2, XTMP2, XTMP3) ;\
-            RND_STEP_RORX_5(g,h,a,b,c,d,e,f,_i+2);\
-    VPXOR    (XTMP4, XTMP4, XTMP2) ;   /* XTMP4 = s1 {xBxA} */\
-            RND_STEP_RORX_6(g,h,a,b,c,d,e,f,_i+2);\
-    VPSHUFB  (XTMP4, XTMP4, SHUF_00BA)  ;  /* XTMP4 = s1 {00BA} */\
-            RND_STEP_RORX_7(g,h,a,b,c,d,e,f,_i+2);\
-    VPADDD   (XTMP0, XTMP0, XTMP4)  ;  /* XTMP0 = {..., ..., W[1], W[0]} */\
-            RND_STEP_RORX_8(g,h,a,b,c,d,e,f,_i+2);\
-\
-            RND_STEP_RORX_1(f,g,h,a,b,c,d,e,_i+3);\
-    VPSHUFD  (XTMP2, XTMP0, 0b01010000) ; /* XTMP2 = W[-2] {DDCC} */\
-            RND_STEP_RORX_2(f,g,h,a,b,c,d,e,_i+3);\
-    VPSRLD   (XTMP5, XTMP2, 10);       /* XTMP5 = W[-2] >> 10 {DDCC} */\
-            RND_STEP_RORX_3(f,g,h,a,b,c,d,e,_i+3);\
-    VPSRLQ   (XTMP3, XTMP2, 19);       /* XTMP3 = W[-2] MY_ROR 19 {xDxC} */\
-            RND_STEP_RORX_4(f,g,h,a,b,c,d,e,_i+3);\
-    VPSRLQ   (XTMP2, XTMP2, 17) ;      /* XTMP2 = W[-2] MY_ROR 17 {xDxC} */\
-            RND_STEP_RORX_5(f,g,h,a,b,c,d,e,_i+3);\
-    VPXOR    (XTMP2, XTMP2, XTMP3) ;\
-            RND_STEP_RORX_6(f,g,h,a,b,c,d,e,_i+3);\
-    VPXOR    (XTMP5, XTMP5, XTMP2) ;   /* XTMP5 = s1 {xDxC} */\
-            RND_STEP_RORX_7(f,g,h,a,b,c,d,e,_i+3);\
-    VPSHUFB  (XTMP5, XTMP5, SHUF_DC00) ; /* XTMP5 = s1 {DC00} */\
-            RND_STEP_RORX_8(f,g,h,a,b,c,d,e,_i+3);\
-    VPADDD   (X0, XTMP5, XTMP0) ;      /* X0 = {W[3], W[2], W[1], W[0]} */\
-
-#endif
-
-
-#define W_K_from_buff\
-         __asm__ volatile("vmovdqu %0, %%xmm4\n\t"\
-                          "vpshufb %%xmm13, %%xmm4, %%xmm4\n\t"\
-                          :: "m"(sha256->buffer[0]):"%xmm4") ;\
-         __asm__ volatile("vmovdqu %0, %%xmm5\n\t"\
-                          "vpshufb %%xmm13, %%xmm5, %%xmm5\n\t"\
-                          ::"m"(sha256->buffer[4]):"%xmm5") ;\
-         __asm__ volatile("vmovdqu %0, %%xmm6\n\t"\
-                          "vpshufb %%xmm13, %%xmm6, %%xmm6\n\t"\
-                          ::"m"(sha256->buffer[8]):"%xmm6") ;\
-         __asm__ volatile("vmovdqu %0, %%xmm7\n\t"\
-                          "vpshufb %%xmm13, %%xmm7, %%xmm7\n\t"\
-                          ::"m"(sha256->buffer[12]):"%xmm7") ;\
-
-#define _SET_W_K_XFER(reg, i)\
-    __asm__ volatile("vpaddd %0, %"#reg", %%xmm9"::"m"(K[i]):XMM_REGs) ;\
-    __asm__ volatile("vmovdqa %%xmm9, %0":"=m"(W_K[i])::XMM_REGs) ;
-
-#define SET_W_K_XFER(reg, i) _SET_W_K_XFER(reg, i)
-
-static const ALIGN32 word64 mSHUF_00BA[] = { 0x0b0a090803020100, 0xFFFFFFFFFFFFFFFF } ; /* shuffle xBxA -> 00BA */
-static const ALIGN32 word64 mSHUF_DC00[] = { 0xFFFFFFFFFFFFFFFF, 0x0b0a090803020100 } ; /* shuffle xDxC -> DC00 */
-static const ALIGN32 word64 mBYTE_FLIP_MASK[] =  { 0x0405060700010203, 0x0c0d0e0f08090a0b } ;
-
-
-#define _Init_Masks(mask1, mask2, mask3)\
-__asm__ volatile("vmovdqu %0, %"#mask1 ::"m"(mBYTE_FLIP_MASK[0])) ;\
-__asm__ volatile("vmovdqu %0, %"#mask2 ::"m"(mSHUF_00BA[0])) ;\
-__asm__ volatile("vmovdqu %0, %"#mask3 ::"m"(mSHUF_DC00[0])) ;
-
-#define Init_Masks(BYTE_FLIP_MASK, SHUF_00BA, SHUF_DC00)\
-    _Init_Masks(BYTE_FLIP_MASK, SHUF_00BA, SHUF_DC00)
-
-#define X0 %xmm4
-#define X1 %xmm5
-#define X2 %xmm6
-#define X3 %xmm7
-#define X_ X0
-
-#define XTMP0 %xmm0
-#define XTMP1 %xmm1
-#define XTMP2 %xmm2
-#define XTMP3 %xmm3
-#define XTMP4 %xmm8
-#define XTMP5 %xmm9
-#define XFER  %xmm10
-
-#define SHUF_00BA   %xmm11 /* shuffle xBxA -> 00BA */
-#define SHUF_DC00   %xmm12 /* shuffle xDxC -> DC00 */
-#define BYTE_FLIP_MASK  %xmm13
-
-#define XMM_REGs   /* Registers are saved in Sha256Update/Finel */
-                   /*"xmm4","xmm5","xmm6","xmm7","xmm8","xmm9","xmm10","xmm11","xmm12","xmm13" */
-
-static int Transform_AVX1(Sha256* sha256)
-{
-
-    word32 W_K[64] ;  /* temp for W+K */
-
-    #if defined(DEBUG_XMM)
-    int i, j ;
-    word32 xmm[29][4*15] ;
-    #endif
-
-    Init_Masks(BYTE_FLIP_MASK, SHUF_00BA, SHUF_DC00) ;
-    W_K_from_buff ; /* X0, X1, X2, X3 = W[0..15] ; */
-
-    DigestToReg(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7) ;
-  
-    SET_W_K_XFER(X0, 0) ;
-    MessageSched(X0, X1, X2, X3, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, XFER, 
-            SHUF_00BA, SHUF_DC00, S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,0) ;
-    SET_W_K_XFER(X1, 4) ;
-    MessageSched(X1, X2, X3, X0, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, XFER,
-            SHUF_00BA, SHUF_DC00, S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,4) ;
-    SET_W_K_XFER(X2, 8) ;
-    MessageSched(X2, X3, X0, X1, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, XFER, 
-            SHUF_00BA, SHUF_DC00, S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,8) ;
-    SET_W_K_XFER(X3, 12) ;
-    MessageSched(X3, X0, X1, X2, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, XFER, 
-            SHUF_00BA, SHUF_DC00, S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,12) ;
-    SET_W_K_XFER(X0, 16) ;
-    MessageSched(X0, X1, X2, X3, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, XFER, 
-            SHUF_00BA, SHUF_DC00, S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,16) ;
-    SET_W_K_XFER(X1, 20) ;
-    MessageSched(X1, X2, X3, X0, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, XFER, 
-            SHUF_00BA, SHUF_DC00, S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,20) ;
-    SET_W_K_XFER(X2, 24) ;
-    MessageSched(X2, X3, X0, X1, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, XFER, 
-            SHUF_00BA, SHUF_DC00, S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,24) ;
-    SET_W_K_XFER(X3, 28) ;
-    MessageSched(X3, X0, X1, X2, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, XFER, 
-            SHUF_00BA, SHUF_DC00, S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,28) ;
-    SET_W_K_XFER(X0, 32) ;
-    MessageSched(X0, X1, X2, X3, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, XFER, 
-            SHUF_00BA, SHUF_DC00, S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,32) ;
-    SET_W_K_XFER(X1, 36) ;
-    MessageSched(X1, X2, X3, X0, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, XFER, 
-            SHUF_00BA, SHUF_DC00, S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,36) ;
-    SET_W_K_XFER(X2, 40) ;
-    MessageSched(X2, X3, X0, X1, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, XFER, 
-            SHUF_00BA, SHUF_DC00, S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,40) ;
-    SET_W_K_XFER(X3, 44) ;
-    MessageSched(X3, X0, X1, X2, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, XFER, 
-            SHUF_00BA, SHUF_DC00, S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,44) ;
-
-    SET_W_K_XFER(X0, 48) ;
-    SET_W_K_XFER(X1, 52) ;
-    SET_W_K_XFER(X2, 56) ;
-    SET_W_K_XFER(X3, 60) ;
-    
-    RND_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,48) ;
-    RND_7(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,49) ;
-    RND_6(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,50) ;
-    RND_5(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,51) ;
-
-    RND_4(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,52) ;
-    RND_3(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,53) ;
-    RND_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,54) ;
-    RND_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,55) ;
-
-    RND_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,56) ;     
-    RND_7(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,57) ;
-    RND_6(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,58) ;
-    RND_5(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,59) ;
-
-    RND_4(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,60) ;
-    RND_3(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,61) ;
-    RND_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,62) ;
-    RND_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,63) ;
-        
-    RegToDigest(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7) ;  
-        
-    #if defined(DEBUG_XMM)
-    for(i=0; i<29; i++) {
-        for(j=0; j<4*14; j+=4)
-            printf("xmm%d[%d]=%08x,%08x,%08x,%08x\n", j/4, i, 
-                   xmm[i][j],xmm[i][j+1],xmm[i][j+2],xmm[i][j+3]) ;
-        printf("\n") ;
-    }
-        
-    for(i=0; i<64; i++)printf("W_K[%d]%08x\n", i, W_K[i]) ;
-    #endif
-
-    return 0;
-}
-
-#if defined(HAVE_INTEL_RORX)
-static int Transform_AVX1_RORX(Sha256* sha256)
-{
-
-    word32 W_K[64] ;  /* temp for W+K */
-
-    #if defined(DEBUG_XMM)
-    int i, j ;
-    word32 xmm[29][4*15] ;
-    #endif
-
-    Init_Masks(BYTE_FLIP_MASK, SHUF_00BA, SHUF_DC00) ;
-    W_K_from_buff ; /* X0, X1, X2, X3 = W[0..15] ; */
-
-    DigestToReg(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7) ;
-    SET_W_K_XFER(X0, 0) ;
-    MessageSched_RORX(X0, X1, X2, X3, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, 
-            XFER, SHUF_00BA, SHUF_DC00, S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,0) ;
-    SET_W_K_XFER(X1, 4) ;
-    MessageSched_RORX(X1, X2, X3, X0, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, 
-            XFER, SHUF_00BA, SHUF_DC00, S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,4) ;
-    SET_W_K_XFER(X2, 8) ;
-    MessageSched_RORX(X2, X3, X0, X1, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, 
-            XFER, SHUF_00BA, SHUF_DC00, S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,8) ;
-    SET_W_K_XFER(X3, 12) ;
-    MessageSched_RORX(X3, X0, X1, X2, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, 
-            XFER, SHUF_00BA, SHUF_DC00, S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,12) ;
-    SET_W_K_XFER(X0, 16) ;
-    MessageSched_RORX(X0, X1, X2, X3, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, 
-            XFER, SHUF_00BA, SHUF_DC00, S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,16) ;
-    SET_W_K_XFER(X1, 20) ;
-    MessageSched_RORX(X1, X2, X3, X0, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, 
-            XFER, SHUF_00BA, SHUF_DC00, S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,20) ;
-    SET_W_K_XFER(X2, 24) ;
-    MessageSched_RORX(X2, X3, X0, X1, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, 
-            XFER, SHUF_00BA, SHUF_DC00, S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,24) ;
-    SET_W_K_XFER(X3, 28) ;
-    MessageSched_RORX(X3, X0, X1, X2, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, 
-            XFER, SHUF_00BA, SHUF_DC00, S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,28) ;
-    SET_W_K_XFER(X0, 32) ;
-    MessageSched_RORX(X0, X1, X2, X3, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, 
-            XFER, SHUF_00BA, SHUF_DC00, S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,32) ;
-    SET_W_K_XFER(X1, 36) ;
-    MessageSched_RORX(X1, X2, X3, X0, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5, 
-            XFER, SHUF_00BA, SHUF_DC00, S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,36) ;
-    SET_W_K_XFER(X2, 40) ;
-    MessageSched_RORX(X2, X3, X0, X1, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5,
-            XFER, SHUF_00BA, SHUF_DC00, S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,40) ;
-    SET_W_K_XFER(X3, 44) ;
-    MessageSched_RORX(X3, X0, X1, X2, XTMP0, XTMP1, XTMP2, XTMP3, XTMP4, XTMP5,
-            XFER, SHUF_00BA, SHUF_DC00, S_4,S_5,S_6,S_7,S_0,S_1,S_2,S_3,44) ;
-
-    SET_W_K_XFER(X0, 48) ;
-    SET_W_K_XFER(X1, 52) ;
-    SET_W_K_XFER(X2, 56) ;
-    SET_W_K_XFER(X3, 60) ;
-    
-    RND_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,48) ;
-    RND_7(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,49) ;
-    RND_6(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,50) ;
-    RND_5(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,51) ;
-
-    RND_4(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,52) ;
-    RND_3(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,53) ;
-    RND_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,54) ;
-    RND_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,55) ;
-
-    RND_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,56) ;     
-    RND_7(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,57) ;
-    RND_6(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,58) ;
-    RND_5(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,59) ;
-
-    RND_4(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,60) ;
-    RND_3(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,61) ;
-    RND_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,62) ;
-    RND_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,63) ;
-        
-    RegToDigest(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7) ;  
-        
-    #if defined(DEBUG_XMM)
-    for(i=0; i<29; i++) {
-        for(j=0; j<4*14; j+=4)
-            printf("xmm%d[%d]=%08x,%08x,%08x,%08x\n", j/4, i, 
-                    xmm[i][j],xmm[i][j+1],xmm[i][j+2],xmm[i][j+3]) ;
-        printf("\n") ;
-    }
-        
-    for(i=0; i<64; i++)printf("W_K[%d]%08x\n", i, W_K[i]) ;
-    #endif
-
-    return 0;
-}
-#endif  /* HAVE_INTEL_RORX */
-
-#endif  /* HAVE_INTEL_AVX1 */
-
-
-#if defined(HAVE_INTEL_AVX2)
-
-#define _MOVE_to_REG(ymm, mem)       __asm__ volatile("vmovdqu %0, %%"#ymm" ":: "m"(mem):YMM_REGs) ;
-#define _MOVE_to_MEM(mem, ymm)       __asm__ volatile("vmovdqu %%"#ymm", %0" : "=m"(mem)::YMM_REGs) ;
-#define _BYTE_SWAP(ymm, map)              __asm__ volatile("vpshufb %0, %%"#ymm", %%"#ymm"\n\t"\
-                                                       :: "m"(map):YMM_REGs) ;
-#define _MOVE_128(ymm0, ymm1, ymm2, map)   __asm__ volatile("vperm2i128  $"#map", %%"\
-                                  #ymm2", %%"#ymm1", %%"#ymm0" ":::YMM_REGs) ;
-#define _MOVE_BYTE(ymm0, ymm1, map)  __asm__ volatile("vpshufb %0, %%"#ymm1", %%"\
-                                  #ymm0"\n\t":: "m"(map):YMM_REGs) ;
-#define _S_TEMP(dest, src, bits, temp)    __asm__ volatile("vpsrld  $"#bits", %%"\
-         #src", %%"#dest"\n\tvpslld  $32-"#bits", %%"#src", %%"#temp"\n\tvpor %%"\
-         #temp",%%"#dest", %%"#dest" ":::YMM_REGs) ;
-#define _AVX2_R(dest, src, bits)          __asm__ volatile("vpsrld  $"#bits", %%"\
-                                  #src", %%"#dest" ":::YMM_REGs) ;
-#define _XOR(dest, src1, src2)       __asm__ volatile("vpxor   %%"#src1", %%"\
-         #src2", %%"#dest" ":::YMM_REGs) ;
-#define _OR(dest, src1, src2)       __asm__ volatile("vpor    %%"#src1", %%"\
-         #src2", %%"#dest" ":::YMM_REGs) ;
-#define _ADD(dest, src1, src2)       __asm__ volatile("vpaddd   %%"#src1", %%"\
-         #src2", %%"#dest" ":::YMM_REGs) ;
-#define _ADD_MEM(dest, src1, mem)    __asm__ volatile("vpaddd   %0, %%"#src1", %%"\
-         #dest" "::"m"(mem):YMM_REGs) ;
-#define _BLEND(map, dest, src1, src2)    __asm__ volatile("vpblendd    $"#map", %%"\
-         #src1",   %%"#src2", %%"#dest" ":::YMM_REGs) ;
-
-#define    _EXTRACT_XMM_0(xmm, mem)  __asm__ volatile("vpextrd $0, %%"#xmm", %0 ":"=r"(mem)::YMM_REGs) ;
-#define    _EXTRACT_XMM_1(xmm, mem)  __asm__ volatile("vpextrd $1, %%"#xmm", %0 ":"=r"(mem)::YMM_REGs) ;
-#define    _EXTRACT_XMM_2(xmm, mem)  __asm__ volatile("vpextrd $2, %%"#xmm", %0 ":"=r"(mem)::YMM_REGs) ;
-#define    _EXTRACT_XMM_3(xmm, mem)  __asm__ volatile("vpextrd $3, %%"#xmm", %0 ":"=r"(mem)::YMM_REGs) ;
-#define    _EXTRACT_XMM_4(ymm, xmm, mem)\
-      __asm__ volatile("vperm2i128 $0x1, %%"#ymm", %%"#ymm", %%"#ymm" ":::YMM_REGs) ;\
-      __asm__ volatile("vpextrd $0, %%"#xmm", %0 ":"=r"(mem)::YMM_REGs) ;
-#define    _EXTRACT_XMM_5(xmm, mem)  __asm__ volatile("vpextrd $1, %%"#xmm", %0 ":"=r"(mem)::YMM_REGs) ;
-#define    _EXTRACT_XMM_6(xmm, mem)  __asm__ volatile("vpextrd $2, %%"#xmm", %0 ":"=r"(mem)::YMM_REGs) ;
-#define    _EXTRACT_XMM_7(xmm, mem)  __asm__ volatile("vpextrd $3, %%"#xmm", %0 ":"=r"(mem)::YMM_REGs) ;
-
-#define    _SWAP_YMM_HL(ymm)   __asm__ volatile("vperm2i128 $0x1, %%"#ymm", %%"#ymm", %%"#ymm" ":::YMM_REGs) ;
-#define     SWAP_YMM_HL(ymm)   _SWAP_YMM_HL(ymm) 
-
-#define MOVE_to_REG(ymm, mem)      _MOVE_to_REG(ymm, mem)
-#define MOVE_to_MEM(mem, ymm)      _MOVE_to_MEM(mem, ymm)
-#define BYTE_SWAP(ymm, map)        _BYTE_SWAP(ymm, map)
-#define MOVE_128(ymm0, ymm1, ymm2, map) _MOVE_128(ymm0, ymm1, ymm2, map) 
-#define MOVE_BYTE(ymm0, ymm1, map) _MOVE_BYTE(ymm0, ymm1, map)
-#define XOR(dest, src1, src2)      _XOR(dest, src1, src2)
-#define OR(dest, src1, src2)       _OR(dest, src1, src2)
-#define ADD(dest, src1, src2)      _ADD(dest, src1, src2)
-#define ADD_MEM(dest, src1, mem)  _ADD_MEM(dest, src1, mem)
-#define BLEND(map, dest, src1, src2) _BLEND(map, dest, src1, src2)
-
-#define S_TMP(dest, src, bits, temp) _S_TEMP(dest, src, bits, temp); 
-#define AVX2_S(dest, src, bits)      S_TMP(dest, src, bits, S_TEMP)
-#define AVX2_R(dest, src, bits)      _AVX2_R(dest, src, bits)
-
-#define GAMMA0(dest, src)      AVX2_S(dest, src, 7);  AVX2_S(G_TEMP, src, 18); \
-    XOR(dest, G_TEMP, dest) ; AVX2_R(G_TEMP, src, 3);  XOR(dest, G_TEMP, dest) ;
-#define GAMMA0_1(dest, src)    AVX2_S(dest, src, 7);  AVX2_S(G_TEMP, src, 18); 
-#define GAMMA0_2(dest, src)    XOR(dest, G_TEMP, dest) ; AVX2_R(G_TEMP, src, 3);  \
-    XOR(dest, G_TEMP, dest) ;
-
-#define GAMMA1(dest, src)      AVX2_S(dest, src, 17); AVX2_S(G_TEMP, src, 19); \
-    XOR(dest, G_TEMP, dest) ; AVX2_R(G_TEMP, src, 10); XOR(dest, G_TEMP, dest) ;
-#define GAMMA1_1(dest, src)    AVX2_S(dest, src, 17); AVX2_S(G_TEMP, src, 19); 
-#define GAMMA1_2(dest, src)    XOR(dest, G_TEMP, dest) ; AVX2_R(G_TEMP, src, 10); \
-    XOR(dest, G_TEMP, dest) ;
-
-#define    FEEDBACK1_to_W_I_2    MOVE_BYTE(YMM_TEMP0, W_I, mMAP1toW_I_2[0]) ; \
-    BLEND(0x0c, W_I_2, YMM_TEMP0, W_I_2) ;
-#define    FEEDBACK2_to_W_I_2    MOVE_128(YMM_TEMP0, W_I, W_I, 0x08) ;  \
-    MOVE_BYTE(YMM_TEMP0, YMM_TEMP0, mMAP2toW_I_2[0]) ; BLEND(0x30, W_I_2, YMM_TEMP0, W_I_2) ; 
-#define    FEEDBACK3_to_W_I_2    MOVE_BYTE(YMM_TEMP0, W_I, mMAP3toW_I_2[0]) ; \
-    BLEND(0xc0, W_I_2, YMM_TEMP0, W_I_2) ; 
-
-#define    FEEDBACK_to_W_I_7     MOVE_128(YMM_TEMP0, W_I, W_I, 0x08) ;\
-    MOVE_BYTE(YMM_TEMP0, YMM_TEMP0, mMAPtoW_I_7[0]) ; BLEND(0x80, W_I_7, YMM_TEMP0, W_I_7) ;
-
-#undef voitle
-
-#define W_I_16  ymm8
-#define W_I_15  ymm9
-#define W_I_7  ymm10
-#define W_I_2  ymm11
-#define W_I    ymm12
-#define G_TEMP     ymm13
-#define S_TEMP     ymm14
-#define YMM_TEMP0  ymm15
-#define YMM_TEMP0x xmm15
-#define W_I_TEMP   ymm7
-#define W_K_TEMP   ymm15
-#define W_K_TEMPx  xmm15
-
-#define YMM_REGs /* Registers are saved in Sha256Update/Finel */
- /* "%ymm7","%ymm8","%ymm9","%ymm10","%ymm11","%ymm12","%ymm13","%ymm14","%ymm15"*/
-
-
-#define MOVE_15_to_16(w_i_16, w_i_15, w_i_7)\
-    __asm__ volatile("vperm2i128  $0x01, %%"#w_i_15", %%"#w_i_15", %%"#w_i_15" ":::YMM_REGs) ;\
-    __asm__ volatile("vpblendd    $0x08, %%"#w_i_15", %%"#w_i_7", %%"#w_i_16" ":::YMM_REGs) ;\
-    __asm__ volatile("vperm2i128 $0x01,  %%"#w_i_7",  %%"#w_i_7", %%"#w_i_15" ":::YMM_REGs) ;\
-    __asm__ volatile("vpblendd    $0x80, %%"#w_i_15", %%"#w_i_16", %%"#w_i_16" ":::YMM_REGs) ;\
-    __asm__ volatile("vpshufd    $0x93,  %%"#w_i_16", %%"#w_i_16" ":::YMM_REGs) ;\
-
-#define MOVE_7_to_15(w_i_15, w_i_7)\
-    __asm__ volatile("vmovdqu                 %%"#w_i_7",  %%"#w_i_15" ":::YMM_REGs) ;\
-
-#define MOVE_I_to_7(w_i_7, w_i)\
-    __asm__ volatile("vperm2i128 $0x01,       %%"#w_i",   %%"#w_i",   %%"#w_i_7" ":::YMM_REGs) ;\
-    __asm__ volatile("vpblendd    $0x01,       %%"#w_i_7",   %%"#w_i", %%"#w_i_7" ":::YMM_REGs) ;\
-    __asm__ volatile("vpshufd    $0x39, %%"#w_i_7", %%"#w_i_7" ":::YMM_REGs) ;\
-
-#define MOVE_I_to_2(w_i_2, w_i)\
-    __asm__ volatile("vperm2i128 $0x01,       %%"#w_i", %%"#w_i", %%"#w_i_2" ":::YMM_REGs) ;\
-    __asm__ volatile("vpshufd    $0x0e, %%"#w_i_2", %%"#w_i_2" ":::YMM_REGs) ;\
-
-#define ROTATE_W(w_i_16, w_i_15, w_i_7, w_i_2, w_i)\
-    MOVE_15_to_16(w_i_16, w_i_15, w_i_7) ; \
-    MOVE_7_to_15(w_i_15, w_i_7) ; \
-    MOVE_I_to_7(w_i_7, w_i) ; \
-    MOVE_I_to_2(w_i_2, w_i) ;\
-
-#define _RegToDigest(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )\
-    { word32 d ;\
-    __asm__ volatile("movl %"#S_0", %0":"=r"(d)::SSE_REGs) ;\
-    sha256->digest[0] += d;\
-    __asm__ volatile("movl %"#S_1", %0":"=r"(d)::SSE_REGs) ;\
-    sha256->digest[1] += d;\
-    __asm__ volatile("movl %"#S_2", %0":"=r"(d)::SSE_REGs) ;\
-    sha256->digest[2] += d;\
-    __asm__ volatile("movl %"#S_3", %0":"=r"(d)::SSE_REGs) ;\
-    sha256->digest[3] += d;\
-    __asm__ volatile("movl %"#S_4", %0":"=r"(d)::SSE_REGs) ;\
-    sha256->digest[4] += d;\
-    __asm__ volatile("movl %"#S_5", %0":"=r"(d)::SSE_REGs) ;\
-    sha256->digest[5] += d;\
-    __asm__ volatile("movl %"#S_6", %0":"=r"(d)::SSE_REGs) ;\
-    sha256->digest[6] += d;\
-    __asm__ volatile("movl %"#S_7", %0":"=r"(d)::SSE_REGs) ;\
-    sha256->digest[7] += d;\
-}
-
-#define _DumpS(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )\
-  { word32 d[8] ;\
-    __asm__ volatile("movl %"#S_0", %0":"=r"(d[0])::SSE_REGs) ;\
-    __asm__ volatile("movl %"#S_1", %0":"=r"(d[1])::SSE_REGs) ;\
-    __asm__ volatile("movl %"#S_2", %0":"=r"(d[2])::SSE_REGs) ;\
-    __asm__ volatile("movl %"#S_3", %0":"=r"(d[3])::SSE_REGs) ;\
-    __asm__ volatile("movl %"#S_4", %0":"=r"(d[4])::SSE_REGs) ;\
-    __asm__ volatile("movl %"#S_5", %0":"=r"(d[5])::SSE_REGs) ;\
-    __asm__ volatile("movl %"#S_6", %0":"=r"(d[6])::SSE_REGs) ;\
-    __asm__ volatile("movl %"#S_7", %0":"=r"(d[7])::SSE_REGs) ;\
-        printf("S[0..7]=%08x,%08x,%08x,%08x,%08x,%08x,%08x,%08x\n", d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7]);\
-    __asm__ volatile("movl %0, %"#S_0::"r"(d[0]):SSE_REGs) ;\
-    __asm__ volatile("movl %0, %"#S_1::"r"(d[1]):SSE_REGs) ;\
-    __asm__ volatile("movl %0, %"#S_2::"r"(d[2]):SSE_REGs) ;\
-    __asm__ volatile("movl %0, %"#S_3::"r"(d[3]):SSE_REGs) ;\
-    __asm__ volatile("movl %0, %"#S_4::"r"(d[4]):SSE_REGs) ;\
-    __asm__ volatile("movl %0, %"#S_5::"r"(d[5]):SSE_REGs) ;\
-    __asm__ volatile("movl %0, %"#S_6::"r"(d[6]):SSE_REGs) ;\
-    __asm__ volatile("movl %0, %"#S_7::"r"(d[7]):SSE_REGs) ;\
-}
-
-
-#define DigestToReg(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )\
-    _DigestToReg(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )
-
-#define RegToDigest(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )\
-    _RegToDigest(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )
-
-#define DumS(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )\
-    _DumpS(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )
-
-        
-    /* Byte swap Masks to ensure that rest of the words are filled with zero's. */
-    static const unsigned long mBYTE_FLIP_MASK_16[] =  
-        { 0x0405060700010203, 0x0c0d0e0f08090a0b, 0x0405060700010203, 0x0c0d0e0f08090a0b } ;
-    static const unsigned long mBYTE_FLIP_MASK_15[] =  
-        { 0x0405060700010203, 0x0c0d0e0f08090a0b, 0x0405060700010203, 0x0c0d0e0f08090a0b } ;
-    static const unsigned long mBYTE_FLIP_MASK_7 [] =  
-        { 0x0405060700010203, 0x0c0d0e0f08090a0b, 0x0405060700010203, 0x8080808008090a0b } ;
-    static const unsigned long mBYTE_FLIP_MASK_2 [] =  
-        { 0x0405060700010203, 0x8080808080808080, 0x8080808080808080, 0x8080808080808080 } ;
-
-    static const unsigned long mMAPtoW_I_7[] =  
-        { 0x8080808080808080, 0x8080808080808080, 0x8080808080808080, 0x0302010080808080 } ;
-    static const unsigned long mMAP1toW_I_2[] = 
-        { 0x8080808080808080, 0x0706050403020100, 0x8080808080808080, 0x8080808080808080 } ;
-    static const unsigned long mMAP2toW_I_2[] = 
-        { 0x8080808080808080, 0x8080808080808080, 0x0f0e0d0c0b0a0908, 0x8080808080808080 } ;
-    static const unsigned long mMAP3toW_I_2[] = 
-        { 0x8080808080808080, 0x8080808080808080, 0x8080808080808080, 0x0706050403020100 } ;
- 
-static int Transform_AVX2(Sha256* sha256)
-{
-
-    #ifdef WOLFSSL_SMALL_STACK
-        word32* W_K;
-        W_K = (word32*) XMALLOC(sizeof(word32) * 64, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-        if (W_K == NULL)
-            return MEMORY_E;
-    #else
-        word32 W_K[64]  ;
-    #endif
-
-    MOVE_to_REG(W_I_16, sha256->buffer[0]);     BYTE_SWAP(W_I_16, mBYTE_FLIP_MASK_16[0]) ;
-    MOVE_to_REG(W_I_15, sha256->buffer[1]);     BYTE_SWAP(W_I_15, mBYTE_FLIP_MASK_15[0]) ;
-    MOVE_to_REG(W_I,    sha256->buffer[8]) ;    BYTE_SWAP(W_I,    mBYTE_FLIP_MASK_16[0]) ;
-    MOVE_to_REG(W_I_7,  sha256->buffer[16-7]) ; BYTE_SWAP(W_I_7,  mBYTE_FLIP_MASK_7[0])  ;
-    MOVE_to_REG(W_I_2,  sha256->buffer[16-2]) ; BYTE_SWAP(W_I_2,  mBYTE_FLIP_MASK_2[0])  ;
-
-    DigestToReg(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7) ;
-
-    ADD_MEM(W_K_TEMP, W_I_16, K[0]) ;
-    MOVE_to_MEM(W_K[0], W_K_TEMP) ; 
-
-    RND_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,0) ;
-    RND_7(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,1) ;
-    RND_6(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,2) ;
-    RND_5(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,3) ;  
-    RND_4(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,4) ;
-    RND_3(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,5) ;
-    RND_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,6) ;
-    RND_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,7) ;
-
-    ADD_MEM(YMM_TEMP0, W_I, K[8]) ;
-    MOVE_to_MEM(W_K[8], YMM_TEMP0) ; 
-
-        /* W[i] = Gamma1(W[i-2]) + W[i-7] + Gamma0(W[i-15] + W[i-16]) */
-                RND_0_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,8) ;
-        GAMMA0_1(W_I_TEMP, W_I_15) ;
-                RND_0_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,8) ;
-        GAMMA0_2(W_I_TEMP, W_I_15) ;
-                RND_0_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,8) ;
-        ADD(W_I_TEMP, W_I_16, W_I_TEMP) ;/* for saving W_I before adding incomplete W_I_7 */
-                RND_7_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,9) ;
-        ADD(W_I, W_I_7, W_I_TEMP);
-                RND_7_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,9) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ; 
-                RND_7_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,9) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ; 
-                RND_6_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,10) ;
-        ADD(W_I, W_I, YMM_TEMP0) ;/* now W[16..17] are completed */
-                RND_6_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,10) ;
-        FEEDBACK1_to_W_I_2 ;
-                RND_6_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,10) ;
-        FEEDBACK_to_W_I_7 ; 
-                RND_5_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,11) ;
-        ADD(W_I_TEMP, W_I_7, W_I_TEMP);
-                RND_5_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,11) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ; 
-                RND_5_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,11) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ; 
-                RND_4_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,12) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ;/* now W[16..19] are completed */
-                RND_4_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,12) ;
-        FEEDBACK2_to_W_I_2 ;
-                RND_4_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,12) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ;
-                RND_3_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,13) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ; 
-                RND_3_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,13) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ; /* now W[16..21] are completed */
-                RND_3_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,13) ;
-        FEEDBACK3_to_W_I_2 ;
-                RND_2_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,14) ;
-        GAMMA1(YMM_TEMP0, W_I_2) ;
-                RND_2_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,14) ;
-                RND_2_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,14) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ; /* now W[16..23] are completed */
-                RND_1_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,15) ;
-
-        MOVE_to_REG(YMM_TEMP0, K[16]) ;    
-                RND_1_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,15) ;
-        ROTATE_W(W_I_16, W_I_15, W_I_7, W_I_2, W_I) ;
-                RND_1_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,15) ;
-        ADD(YMM_TEMP0, YMM_TEMP0, W_I) ;
-        MOVE_to_MEM(W_K[16], YMM_TEMP0) ;
-
-        /* W[i] = Gamma1(W[i-2]) + W[i-7] + Gamma0(W[i-15] + W[i-16]) */
-                RND_0_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,16) ;
-        GAMMA0_1(W_I_TEMP, W_I_15) ;
-                RND_0_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,16) ;
-        GAMMA0_2(W_I_TEMP, W_I_15) ;
-                RND_0_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,16) ;
-        ADD(W_I_TEMP, W_I_16, W_I_TEMP) ;/* for saving W_I before adding incomplete W_I_7 */
-                RND_7_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,17) ;
-        ADD(W_I, W_I_7, W_I_TEMP);
-                RND_7_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,17) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ; 
-                RND_7_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,17) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ; 
-                RND_6_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,18) ;
-        ADD(W_I, W_I, YMM_TEMP0) ;/* now W[16..17] are completed */
-                RND_6_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,18) ;
-        FEEDBACK1_to_W_I_2 ;
-                RND_6_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,18) ;
-        FEEDBACK_to_W_I_7 ; 
-                RND_5_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,19) ;
-        ADD(W_I_TEMP, W_I_7, W_I_TEMP);
-                RND_5_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,19) ;
-        GAMMA1(YMM_TEMP0, W_I_2) ; 
-                RND_5_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,19) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ; 
-                RND_4_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,20) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ;/* now W[16..19] are completed */
-                RND_4_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,20) ;
-        FEEDBACK2_to_W_I_2 ;
-                RND_4_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,20) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ;
-                RND_3_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,21) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ; 
-                RND_3_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,21) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ; /* now W[16..21] are completed */
-                RND_3_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,21) ;
-        FEEDBACK3_to_W_I_2 ;
-                RND_2_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,22) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ;
-                RND_2_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,22) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ; 
-                RND_2_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,22) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ; /* now W[16..23] are completed */
-                RND_1_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,23) ;
-
-        MOVE_to_REG(YMM_TEMP0, K[24]) ;    
-                RND_1_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,23) ;
-        ROTATE_W(W_I_16, W_I_15, W_I_7, W_I_2, W_I) ;
-                RND_1_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,23) ;
-        ADD(YMM_TEMP0, YMM_TEMP0, W_I) ;
-        MOVE_to_MEM(W_K[24], YMM_TEMP0) ;
-
-                /* W[i] = Gamma1(W[i-2]) + W[i-7] + Gamma0(W[i-15] + W[i-16]) */
-                RND_0_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,24) ;
-        GAMMA0_1(W_I_TEMP, W_I_15) ;
-                RND_0_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,24) ;
-        GAMMA0_2(W_I_TEMP, W_I_15) ;
-                RND_0_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,24) ;
-        ADD(W_I_TEMP, W_I_16, W_I_TEMP) ;/* for saving W_I before adding incomplete W_I_7 */
-                RND_7_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,25) ;
-        ADD(W_I, W_I_7, W_I_TEMP);
-                RND_7_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,25) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ; 
-                RND_7_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,25) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ; 
-                RND_6_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,26) ;
-        ADD(W_I, W_I, YMM_TEMP0) ;/* now W[16..17] are completed */
-                RND_6_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,26) ;
-        FEEDBACK1_to_W_I_2 ;
-                RND_6_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,26) ;
-        FEEDBACK_to_W_I_7 ; 
-                RND_5_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,27) ;
-        ADD(W_I_TEMP, W_I_7, W_I_TEMP);
-                RND_5_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,27) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ; 
-                RND_5_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,27) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ; 
-                RND_4_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,28) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ;/* now W[16..19] are completed */
-                RND_4_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,28) ;
-        FEEDBACK2_to_W_I_2 ;
-                RND_4_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,28) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ;
-                RND_3_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,29) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ; 
-                RND_3_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,29) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ; /* now W[16..21] are completed */
-                RND_3_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,29) ;
-        FEEDBACK3_to_W_I_2 ;
-                RND_2_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,30) ;
-        GAMMA1(YMM_TEMP0, W_I_2) ;
-                RND_2_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,30) ;
-                RND_2_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,30) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ; /* now W[16..23] are completed */
-                RND_1_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,31) ;
-
-        MOVE_to_REG(YMM_TEMP0, K[32]) ;    
-                RND_1_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,31) ;
-        ROTATE_W(W_I_16, W_I_15, W_I_7, W_I_2, W_I) ;
-                RND_1_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,31) ;
-        ADD(YMM_TEMP0, YMM_TEMP0, W_I) ;
-        MOVE_to_MEM(W_K[32], YMM_TEMP0) ;
-
-        
-                /* W[i] = Gamma1(W[i-2]) + W[i-7] + Gamma0(W[i-15] + W[i-16]) */
-                RND_0_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,32) ;
-        GAMMA0_1(W_I_TEMP, W_I_15) ;
-                RND_0_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,32) ;
-        GAMMA0_2(W_I_TEMP, W_I_15) ;
-                RND_0_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,32) ;
-        ADD(W_I_TEMP, W_I_16, W_I_TEMP) ;/* for saving W_I before adding incomplete W_I_7 */
-                RND_7_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,33) ;
-        ADD(W_I, W_I_7, W_I_TEMP);
-                RND_7_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,33) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ;
-                RND_7_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,33) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ; 
-                RND_6_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,34) ;
-        ADD(W_I, W_I, YMM_TEMP0) ;/* now W[16..17] are completed */
-                RND_6_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,34) ;
-        FEEDBACK1_to_W_I_2 ;
-                RND_6_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,34) ;
-        FEEDBACK_to_W_I_7 ; 
-                RND_5_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,35) ;
-        ADD(W_I_TEMP, W_I_7, W_I_TEMP);
-                RND_5_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,35) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ;
-                RND_5_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,35) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ;
-                RND_4_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,36) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ;/* now W[16..19] are completed */
-                RND_4_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,36) ;
-        FEEDBACK2_to_W_I_2 ;
-                RND_4_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,36) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ;
-                RND_3_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,37) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ;
-                RND_3_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,37) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ; /* now W[16..21] are completed */
-                RND_3_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,37) ;
-        FEEDBACK3_to_W_I_2 ;
-                RND_2_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,38) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ;
-                RND_2_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,38) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ;
-                RND_2_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,38) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ; /* now W[16..23] are completed */
-                RND_1_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,39) ;
-
-        MOVE_to_REG(YMM_TEMP0, K[40]) ;    
-                RND_1_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,39) ;
-        ROTATE_W(W_I_16, W_I_15, W_I_7, W_I_2, W_I) ;
-                RND_1_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,39) ;
-        ADD(YMM_TEMP0, YMM_TEMP0, W_I) ;
-        MOVE_to_MEM(W_K[40], YMM_TEMP0) ;
-
-                /* W[i] = Gamma1(W[i-2]) + W[i-7] + Gamma0(W[i-15] + W[i-16]) */
-                RND_0_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,40) ;
-        GAMMA0_1(W_I_TEMP, W_I_15) ;
-                RND_0_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,40) ;
-        GAMMA0_2(W_I_TEMP, W_I_15) ;
-                RND_0_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,40) ;
-        ADD(W_I_TEMP, W_I_16, W_I_TEMP) ;/* for saving W_I before adding incomplete W_I_7 */
-                RND_7_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,41) ;
-        ADD(W_I, W_I_7, W_I_TEMP);
-                RND_7_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,41) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ;
-                RND_7_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,41) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ;
-                RND_6_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,42) ;
-        ADD(W_I, W_I, YMM_TEMP0) ;/* now W[16..17] are completed */
-                RND_6_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,42) ;
-        FEEDBACK1_to_W_I_2 ;
-                RND_6_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,42) ;
-        FEEDBACK_to_W_I_7 ; 
-                RND_5_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,43) ;
-        ADD(W_I_TEMP, W_I_7, W_I_TEMP);
-                RND_5_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,43) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ; 
-                RND_5_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,43) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ;
-                RND_4_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,44) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ;/* now W[16..19] are completed */
-                RND_4_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,44) ;
-        FEEDBACK2_to_W_I_2 ;
-                RND_4_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,44) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ;
-                RND_3_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,45) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ;
-                RND_3_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,45) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ; /* now W[16..21] are completed */
-                RND_3_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,45) ;
-        FEEDBACK3_to_W_I_2 ;
-                RND_2_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,46) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ;
-                RND_2_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,46) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ;
-                RND_2_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,46) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ; /* now W[16..23] are completed */
-                RND_1_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,47) ;
-
-        MOVE_to_REG(YMM_TEMP0, K[48]) ;    
-                RND_1_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,47) ;
-        ROTATE_W(W_I_16, W_I_15, W_I_7, W_I_2, W_I) ;
-                RND_1_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,47) ;
-        ADD(YMM_TEMP0, YMM_TEMP0, W_I) ;
-        MOVE_to_MEM(W_K[48], YMM_TEMP0) ;
-        
-                /* W[i] = Gamma1(W[i-2]) + W[i-7] + Gamma0(W[i-15] + W[i-16]) */
-                RND_0_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,48) ;
-        GAMMA0_1(W_I_TEMP, W_I_15) ;
-                RND_0_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,48) ;
-        GAMMA0_2(W_I_TEMP, W_I_15) ;
-                RND_0_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,48) ;
-        ADD(W_I_TEMP, W_I_16, W_I_TEMP) ;/* for saving W_I before adding incomplete W_I_7 */
-                RND_7_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,49) ;
-        ADD(W_I, W_I_7, W_I_TEMP);
-                RND_7_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,49) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ; 
-                RND_7_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,49) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ;
-                RND_6_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,50) ;
-        ADD(W_I, W_I, YMM_TEMP0) ;/* now W[16..17] are completed */
-                RND_6_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,50) ;
-        FEEDBACK1_to_W_I_2 ;
-                RND_6_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,50) ;
-        FEEDBACK_to_W_I_7 ; 
-                RND_5_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,51) ;
-        ADD(W_I_TEMP, W_I_7, W_I_TEMP);
-                RND_5_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,51) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ;
-                RND_5_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,51) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ;
-                RND_4_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,52) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ;/* now W[16..19] are completed */
-                RND_4_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,52) ;
-        FEEDBACK2_to_W_I_2 ;
-                RND_4_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,52) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ;
-                RND_3_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,53) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ;
-                RND_3_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,53) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ; /* now W[16..21] are completed */
-                RND_3_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,53) ;
-        FEEDBACK3_to_W_I_2 ;
-                RND_2_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,54) ;
-        GAMMA1_1(YMM_TEMP0, W_I_2) ;
-                RND_2_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,54) ;
-        GAMMA1_2(YMM_TEMP0, W_I_2) ;
-                RND_2_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,54) ;
-        ADD(W_I, W_I_TEMP, YMM_TEMP0) ; /* now W[16..23] are completed */
-                RND_1_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,55) ;
-
-        MOVE_to_REG(YMM_TEMP0, K[56]) ;    
-                RND_1_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,55) ;
-        ROTATE_W(W_I_16, W_I_15, W_I_7, W_I_2, W_I) ;
-                RND_1_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,55) ;
-        ADD(YMM_TEMP0, YMM_TEMP0, W_I) ;
-        MOVE_to_MEM(W_K[56], YMM_TEMP0) ;        
-        
-        RND_0(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,56) ;
-        RND_7(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,57) ;
-        RND_6(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,58) ;
-        RND_5(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,59) ;
-
-        RND_4(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,60) ;
-        RND_3(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,61) ;
-        RND_2(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,62) ;
-        RND_1(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7,63) ;
-
-    RegToDigest(S_0,S_1,S_2,S_3,S_4,S_5,S_6,S_7) ;  
-
-    #ifdef WOLFSSL_SMALL_STACK
-        XFREE(W, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    #endif
-    
-    return 0;
-}
-
-#endif   /* HAVE_INTEL_AVX2 */
-
-#endif   /* HAVE_FIPS */
-
-#endif   /* WOLFSSL_TI_HAHS */
-
-#endif /* NO_SHA256 */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/sha512.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/sha512.c
deleted file mode 100755
index 8e52da9..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/sha512.c
+++ /dev/null
@@ -1,1805 +0,0 @@
-/* sha512.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-#include 
-
-#ifdef WOLFSSL_SHA512
-
-#ifdef HAVE_FIPS
-int wc_InitSha512(Sha512* sha)
-{
-    return InitSha512_fips(sha);
-}
-
-
-int wc_Sha512Update(Sha512* sha, const byte* data, word32 len)
-{
-    return Sha512Update_fips(sha, data, len);
-}
-
-
-int wc_Sha512Final(Sha512* sha, byte* out)
-{
-    return Sha512Final_fips(sha, out);
-}
-
-
-int wc_Sha512Hash(const byte* data, word32 len, byte* out)
-{
-    return Sha512Hash(data, len, out);
-}
-
-#if defined(WOLFSSL_SHA384) || defined(HAVE_AESGCM)
-
-int wc_InitSha384(Sha384* sha)
-{
-    return InitSha384_fips(sha);
-}
-
-
-int wc_Sha384Update(Sha384* sha, const byte* data, word32 len)
-{
-    return Sha384Update_fips(sha, data, len);
-}
-
-
-int wc_Sha384Final(Sha384* sha, byte* out)
-{
-    return Sha384Final_fips(sha, out);
-}
-
-
-int wc_Sha384Hash(const byte* data, word32 len, byte* out)
-{
-    return Sha384Hash(data, len, out);
-}
-#endif /* WOLFSSL_SHA384 */
-#else /* else build without using fips */
-#include 
-#include 
-
-#ifdef NO_INLINE
-    #include 
-#else
-    #include 
-#endif
-
-
-#ifndef WOLFSSL_HAVE_MIN
-#define WOLFSSL_HAVE_MIN
-
-    static INLINE word32 min(word32 a, word32 b)
-    {
-        return a > b ? b : a;
-    }
-
-#endif /* WOLFSSL_HAVE_MIN */
-
-#if defined(USE_INTEL_SPEEDUP)
-  #define HAVE_INTEL_AVX1
-  #define HAVE_INTEL_AVX2
-#endif
-
-#if defined(HAVE_INTEL_AVX1)
-/* #define DEBUG_XMM  */
-#endif
-
-#if defined(HAVE_INTEL_AVX2)
-#define HAVE_INTEL_RORX
-/* #define DEBUG_YMM  */
-#endif
-
-/*****
-Intel AVX1/AVX2 Macro Control Structure
-
-#if defined(HAVE_INteL_SPEEDUP)
-    #define HAVE_INTEL_AVX1
-    #define HAVE_INTEL_AVX2
-#endif
-
-int InitSha512(Sha512* sha512) { 
-     Save/Recover XMM, YMM
-     ...
-
-     Check Intel AVX cpuid flags
-}
-
-#if defined(HAVE_INTEL_AVX1)|| defined(HAVE_INTEL_AVX2)
-  Transform_AVX1() ; # Function prototype 
-  Transform_AVX2() ; #
-#endif
-
-  _Transform() {     # Native Transform Function body
-  
-  }
-  
-  int Sha512Update() { 
-     Save/Recover XMM, YMM
-     ...
-  }
-  
-  int Sha512Final() { 
-     Save/Recover XMM, YMM
-     ...
-  }
-
-
-#if defined(HAVE_INTEL_AVX1)
-   
-   XMM Instructions/inline asm Definitions
-
-#endif
-
-#if defined(HAVE_INTEL_AVX2)
-
-   YMM Instructions/inline asm Definitions
-
-#endif
-
-#if defnied(HAVE_INTEL_AVX1)
-  
-  int Transform_AVX1() {
-      Stitched Message Sched/Round
-  }
-
-#endif
-
-#if defnied(HAVE_INTEL_AVX2)
-  
-  int Transform_AVX2() {
-      Stitched Message Sched/Round
-  }
-#endif
-
-
-*/
-
-#if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-
-
-/* Each platform needs to query info type 1 from cpuid to see if aesni is
- * supported. Also, let's setup a macro for proper linkage w/o ABI conflicts
- */
-
-#ifndef _MSC_VER
-    #define cpuid(reg, leaf, sub)\
-            __asm__ __volatile__ ("cpuid":\
-             "=a" (reg[0]), "=b" (reg[1]), "=c" (reg[2]), "=d" (reg[3]) :\
-             "a" (leaf), "c"(sub));
-
-    #define XASM_LINK(f) asm(f)
-#else
-
-    #include 
-    #define cpuid(a,b) __cpuid((int*)a,b)
-
-    #define XASM_LINK(f)
-
-#endif /* _MSC_VER */
-
-#define EAX 0
-#define EBX 1
-#define ECX 2 
-#define EDX 3
-    
-#define CPUID_AVX1   0x1
-#define CPUID_AVX2   0x2
-#define CPUID_RDRAND 0x4
-#define CPUID_RDSEED 0x8
-#define CPUID_BMI2   0x10   /* MULX, RORX */
-
-#define IS_INTEL_AVX1       (cpuid_flags&CPUID_AVX1)
-#define IS_INTEL_AVX2       (cpuid_flags&CPUID_AVX2)
-#define IS_INTEL_BMI2       (cpuid_flags&CPUID_BMI2)
-#define IS_INTEL_RDRAND     (cpuid_flags&CPUID_RDRAND)
-#define IS_INTEL_RDSEED     (cpuid_flags&CPUID_RDSEED)
-
-static word32 cpuid_check = 0 ;
-static word32 cpuid_flags = 0 ;
-
-static word32 cpuid_flag(word32 leaf, word32 sub, word32 num, word32 bit) {
-    int got_intel_cpu=0;
-    unsigned int reg[5]; 
-    
-    reg[4] = '\0' ;
-    cpuid(reg, 0, 0);  
-    if(memcmp((char *)&(reg[EBX]), "Genu", 4) == 0 &&  
-                memcmp((char *)&(reg[EDX]), "ineI", 4) == 0 &&  
-                memcmp((char *)&(reg[ECX]), "ntel", 4) == 0) {  
-        got_intel_cpu = 1;  
-    }    
-    if (got_intel_cpu) {
-        cpuid(reg, leaf, sub);
-        return((reg[num]>>bit)&0x1) ;
-    }
-    return 0 ;
-}
-
-#define CHECK_SHA512 0x1
-#define CHECK_SHA384 0x2
-
-static int set_cpuid_flags(int sha) {  
-    if((cpuid_check & sha) ==0) {
-        if(cpuid_flag(1, 0, ECX, 28)){ cpuid_flags |= CPUID_AVX1 ;}
-        if(cpuid_flag(7, 0, EBX, 5)){  cpuid_flags |= CPUID_AVX2 ; }
-        if(cpuid_flag(7, 0, EBX, 8)) { cpuid_flags |= CPUID_BMI2 ; }
-        if(cpuid_flag(1, 0, ECX, 30)){ cpuid_flags |= CPUID_RDRAND ;  } 
-        if(cpuid_flag(7, 0, EBX, 18)){ cpuid_flags |= CPUID_RDSEED ;  }
-		cpuid_check |= sha ;
-		return 0 ;
-    }
-    return 1 ;
-}
-
-
-/* #if defined(HAVE_INTEL_AVX1/2) at the tail of sha512 */
-
-#if defined(HAVE_INTEL_AVX1)
-static int Transform_AVX1(Sha512 *sha512) ;
-#endif
-
-#if defined(HAVE_INTEL_AVX2)
-static int Transform_AVX2(Sha512 *sha512) ; 
-
-#if defined(HAVE_INTEL_AVX1) && defined(HAVE_INTEL_AVX2) && defined(HAVE_INTEL_RORX)
-static int Transform_AVX1_RORX(Sha512 *sha512) ;
-#endif
-
-#endif
-
-static int _Transform(Sha512 *sha512) ; 
-    
-static int (*Transform_p)(Sha512* sha512) = _Transform ;
-
-#define Transform(sha512) (*Transform_p)(sha512)
-
-static void set_Transform(void) {
-     if(set_cpuid_flags(CHECK_SHA512)) return ;
-
-#if defined(HAVE_INTEL_AVX2)
-     if(IS_INTEL_AVX2 && IS_INTEL_BMI2){ 
-         Transform_p = Transform_AVX1_RORX; return ; 
-         Transform_p = Transform_AVX2      ; 
-                  /* for avoiding warning,"not used" */
-     }
-#endif
-#if defined(HAVE_INTEL_AVX1)
-     Transform_p = ((IS_INTEL_AVX1) ? Transform_AVX1 : _Transform) ; return ;
-#endif
-     Transform_p = _Transform ; return ;
-}
-
-#else
-   #define Transform(sha512) _Transform(sha512)
-#endif
-
-/* Dummy for saving MM_REGs on behalf of Transform */
-/* #if defined(HAVE_INTEL_AVX2)
- #define  SAVE_XMM_YMM   __asm__ volatile("orq %%r8, %%r8":::\
-   "%ymm0","%ymm1","%ymm2","%ymm3","%ymm4","%ymm5","%ymm6","%ymm7","%ymm8","%ymm9","%ymm10","%ymm11",\
-   "%ymm12","%ymm13","%ymm14","%ymm15")
-*/
-#if defined(HAVE_INTEL_AVX1)
-   #define  SAVE_XMM_YMM   __asm__ volatile("orq %%r8, %%r8":::\
-    "xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7","xmm8","xmm9","xmm10","xmm11","xmm12","xmm13","xmm14","xmm15")
-#else
-#define  SAVE_XMM_YMM
-#endif
-
-#if defined(HAVE_INTEL_AVX1)|| defined(HAVE_INTEL_AVX2)
-
-#include 
-
-#endif /* defined(HAVE_INTEL_AVX1)|| defined(HAVE_INTEL_AVX2) */
-
-
-#if defined(HAVE_INTEL_RORX)
-#define ROTR(func, bits, x) \
-word64 func(word64 x) {  word64 ret ;\
-    __asm__ ("rorx $"#bits", %1, %0\n\t":"=r"(ret):"r"(x):) ;\
-    return ret ;\
-}
-
-static INLINE ROTR(rotrFixed64_28, 28, x)
-static INLINE ROTR(rotrFixed64_34, 34, x)
-static INLINE ROTR(rotrFixed64_39, 39, x)
-static INLINE ROTR(rotrFixed64_14, 14, x)
-static INLINE ROTR(rotrFixed64_18, 18, x)
-static INLINE ROTR(rotrFixed64_41, 41, x)
-
-#define S0_RORX(x) (rotrFixed64_28(x)^rotrFixed64_34(x)^rotrFixed64_39(x))
-#define S1_RORX(x) (rotrFixed64_14(x)^rotrFixed64_18(x)^rotrFixed64_41(x))
-#endif
-
-#if defined(HAVE_BYTEREVERSE64) && !defined(HAVE_INTEL_AVX1) && !defined(HAVE_INTEL_AVX2)
-#define ByteReverseWords64(out, in, size) ByteReverseWords64_1(out, size)
-#define ByteReverseWords64_1(buf, size)\
- { unsigned int i ;\
-   for(i=0; i< size/sizeof(word64); i++){\
-       __asm__ volatile("bswapq %0":"+r"(buf[i])::) ;\
-   }\
-}
-#endif
-
-
-int wc_InitSha512(Sha512* sha512)
-{
-    sha512->digest[0] = W64LIT(0x6a09e667f3bcc908);
-    sha512->digest[1] = W64LIT(0xbb67ae8584caa73b);
-    sha512->digest[2] = W64LIT(0x3c6ef372fe94f82b);
-    sha512->digest[3] = W64LIT(0xa54ff53a5f1d36f1);
-    sha512->digest[4] = W64LIT(0x510e527fade682d1);
-    sha512->digest[5] = W64LIT(0x9b05688c2b3e6c1f);
-    sha512->digest[6] = W64LIT(0x1f83d9abfb41bd6b);
-    sha512->digest[7] = W64LIT(0x5be0cd19137e2179);
-
-    sha512->buffLen = 0;
-    sha512->loLen   = 0;
-    sha512->hiLen   = 0;
-    
-#if defined(HAVE_INTEL_AVX1)|| defined(HAVE_INTEL_AVX2)
-    set_Transform() ; /* choose best Transform function under this runtime environment */
-#endif
-    
-    return 0 ;
-}
-
-
-static const word64 K512[80] = {
-	W64LIT(0x428a2f98d728ae22), W64LIT(0x7137449123ef65cd),
-	W64LIT(0xb5c0fbcfec4d3b2f), W64LIT(0xe9b5dba58189dbbc),
-	W64LIT(0x3956c25bf348b538), W64LIT(0x59f111f1b605d019),
-	W64LIT(0x923f82a4af194f9b), W64LIT(0xab1c5ed5da6d8118),
-	W64LIT(0xd807aa98a3030242), W64LIT(0x12835b0145706fbe),
-	W64LIT(0x243185be4ee4b28c), W64LIT(0x550c7dc3d5ffb4e2),
-	W64LIT(0x72be5d74f27b896f), W64LIT(0x80deb1fe3b1696b1),
-	W64LIT(0x9bdc06a725c71235), W64LIT(0xc19bf174cf692694),
-	W64LIT(0xe49b69c19ef14ad2), W64LIT(0xefbe4786384f25e3),
-	W64LIT(0x0fc19dc68b8cd5b5), W64LIT(0x240ca1cc77ac9c65),
-	W64LIT(0x2de92c6f592b0275), W64LIT(0x4a7484aa6ea6e483),
-	W64LIT(0x5cb0a9dcbd41fbd4), W64LIT(0x76f988da831153b5),
-	W64LIT(0x983e5152ee66dfab), W64LIT(0xa831c66d2db43210),
-	W64LIT(0xb00327c898fb213f), W64LIT(0xbf597fc7beef0ee4),
-	W64LIT(0xc6e00bf33da88fc2), W64LIT(0xd5a79147930aa725),
-	W64LIT(0x06ca6351e003826f), W64LIT(0x142929670a0e6e70),
-	W64LIT(0x27b70a8546d22ffc), W64LIT(0x2e1b21385c26c926),
-	W64LIT(0x4d2c6dfc5ac42aed), W64LIT(0x53380d139d95b3df),
-	W64LIT(0x650a73548baf63de), W64LIT(0x766a0abb3c77b2a8),
-	W64LIT(0x81c2c92e47edaee6), W64LIT(0x92722c851482353b),
-	W64LIT(0xa2bfe8a14cf10364), W64LIT(0xa81a664bbc423001),
-	W64LIT(0xc24b8b70d0f89791), W64LIT(0xc76c51a30654be30),
-	W64LIT(0xd192e819d6ef5218), W64LIT(0xd69906245565a910),
-	W64LIT(0xf40e35855771202a), W64LIT(0x106aa07032bbd1b8),
-	W64LIT(0x19a4c116b8d2d0c8), W64LIT(0x1e376c085141ab53),
-	W64LIT(0x2748774cdf8eeb99), W64LIT(0x34b0bcb5e19b48a8),
-	W64LIT(0x391c0cb3c5c95a63), W64LIT(0x4ed8aa4ae3418acb),
-	W64LIT(0x5b9cca4f7763e373), W64LIT(0x682e6ff3d6b2b8a3),
-	W64LIT(0x748f82ee5defb2fc), W64LIT(0x78a5636f43172f60),
-	W64LIT(0x84c87814a1f0ab72), W64LIT(0x8cc702081a6439ec),
-	W64LIT(0x90befffa23631e28), W64LIT(0xa4506cebde82bde9),
-	W64LIT(0xbef9a3f7b2c67915), W64LIT(0xc67178f2e372532b),
-	W64LIT(0xca273eceea26619c), W64LIT(0xd186b8c721c0c207),
-	W64LIT(0xeada7dd6cde0eb1e), W64LIT(0xf57d4f7fee6ed178),
-	W64LIT(0x06f067aa72176fba), W64LIT(0x0a637dc5a2c898a6),
-	W64LIT(0x113f9804bef90dae), W64LIT(0x1b710b35131c471b),
-	W64LIT(0x28db77f523047d84), W64LIT(0x32caab7b40c72493),
-	W64LIT(0x3c9ebe0a15c9bebc), W64LIT(0x431d67c49c100d4c),
-	W64LIT(0x4cc5d4becb3e42b6), W64LIT(0x597f299cfc657e2a),
-	W64LIT(0x5fcb6fab3ad6faec), W64LIT(0x6c44198c4a475817)
-};
-
-
-
-#define blk0(i) (W[i] = sha512->buffer[i])
-
-#define blk2(i) (W[i&15]+=s1(W[(i-2)&15])+W[(i-7)&15]+s0(W[(i-15)&15]))
-
-#define Ch(x,y,z) (z^(x&(y^z)))
-#define Maj(x,y,z) ((x&y)|(z&(x|y)))
-
-#define a(i) T[(0-i)&7]
-#define b(i) T[(1-i)&7]
-#define c(i) T[(2-i)&7]
-#define d(i) T[(3-i)&7]
-#define e(i) T[(4-i)&7]
-#define f(i) T[(5-i)&7]
-#define g(i) T[(6-i)&7]
-#define h(i) T[(7-i)&7]
-
-#define S0(x) (rotrFixed64(x,28)^rotrFixed64(x,34)^rotrFixed64(x,39))
-#define S1(x) (rotrFixed64(x,14)^rotrFixed64(x,18)^rotrFixed64(x,41))
-#define s0(x) (rotrFixed64(x,1)^rotrFixed64(x,8)^(x>>7))
-#define s1(x) (rotrFixed64(x,19)^rotrFixed64(x,61)^(x>>6))
-
-#define R(i) h(i)+=S1(e(i))+Ch(e(i),f(i),g(i))+K[i+j]+(j?blk2(i):blk0(i));\
-    d(i)+=h(i);h(i)+=S0(a(i))+Maj(a(i),b(i),c(i))
-
-#define blk384(i) (W[i] = sha384->buffer[i])
-
-#define R2(i) h(i)+=S1(e(i))+Ch(e(i),f(i),g(i))+K[i+j]+(j?blk2(i):blk384(i));\
-    d(i)+=h(i);h(i)+=S0(a(i))+Maj(a(i),b(i),c(i))
-
-static int _Transform(Sha512* sha512)
-{
-    const word64* K = K512;
-
-    word32 j;
-    word64 T[8];
-
-
-#ifdef WOLFSSL_SMALL_STACK
-    word64* W;
-    W = (word64*) XMALLOC(sizeof(word64) * 16, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (W == NULL)
-        return MEMORY_E;
-#else
-    word64 W[16];
-#endif
-
-    /* Copy digest to working vars */
-    XMEMCPY(T, sha512->digest, sizeof(T));
-
-#ifdef USE_SLOW_SHA2
-    /* over twice as small, but 50% slower */
-    /* 80 operations, not unrolled */
-    for (j = 0; j < 80; j += 16) {
-        int m; 
-        for (m = 0; m < 16; m++) { /* braces needed here for macros {} */
-            R(m);
-        }
-    }
-#else
-    /* 80 operations, partially loop unrolled */
-    for (j = 0; j < 80; j += 16) {
-        R( 0); R( 1); R( 2); R( 3);
-        R( 4); R( 5); R( 6); R( 7);
-        R( 8); R( 9); R(10); R(11);
-        R(12); R(13); R(14); R(15);
-    }
-#endif /* USE_SLOW_SHA2 */
-
-    /* Add the working vars back into digest */
-
-    sha512->digest[0] += a(0);
-    sha512->digest[1] += b(0);
-    sha512->digest[2] += c(0);
-    sha512->digest[3] += d(0);
-    sha512->digest[4] += e(0);
-    sha512->digest[5] += f(0);
-    sha512->digest[6] += g(0);
-    sha512->digest[7] += h(0);
-
-    /* Wipe variables */
-    ForceZero(W, sizeof(word64) * 16);
-    ForceZero(T, sizeof(T));
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(W, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return 0;
-}
-
-
-static INLINE void AddLength(Sha512* sha512, word32 len)
-{
-    word32 tmp = sha512->loLen;
-    if ( (sha512->loLen += len) < tmp)
-        sha512->hiLen++;                       /* carry low to high */
-}
-
-int wc_Sha512Update(Sha512* sha512, const byte* data, word32 len)
-{
-    /* do block size increments */
-    byte* local = (byte*)sha512->buffer;
-    SAVE_XMM_YMM ; /* for Intel AVX */
-
-    while (len) {
-        word32 add = min(len, SHA512_BLOCK_SIZE - sha512->buffLen);
-        XMEMCPY(&local[sha512->buffLen], data, add);
-
-        sha512->buffLen += add;
-        data         += add;
-        len          -= add;
-
-        if (sha512->buffLen == SHA512_BLOCK_SIZE) {
-            int ret;
-            #if defined(LITTLE_ENDIAN_ORDER)
-                #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-                if(!IS_INTEL_AVX1 && !IS_INTEL_AVX2) 
-                #endif
-                    ByteReverseWords64(sha512->buffer, sha512->buffer,
-                                   SHA512_BLOCK_SIZE);
-            #endif
-            ret = Transform(sha512);
-            if (ret != 0)
-                return ret;
-
-            AddLength(sha512, SHA512_BLOCK_SIZE);
-            sha512->buffLen = 0;
-        }
-    }
-    return 0;
-}
-
-
-int wc_Sha512Final(Sha512* sha512, byte* hash)
-{
-    byte* local = (byte*)sha512->buffer;
-    int ret;
-
-    SAVE_XMM_YMM ; /* for Intel AVX */
-    AddLength(sha512, sha512->buffLen);               /* before adding pads */
-
-    local[sha512->buffLen++] = 0x80;  /* add 1 */
-
-    /* pad with zeros */
-    if (sha512->buffLen > SHA512_PAD_SIZE) {
-        XMEMSET(&local[sha512->buffLen], 0, SHA512_BLOCK_SIZE -sha512->buffLen);
-        sha512->buffLen += SHA512_BLOCK_SIZE - sha512->buffLen;
-        #if defined(LITTLE_ENDIAN_ORDER) 
-            #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-            if(!IS_INTEL_AVX1 && !IS_INTEL_AVX2)
-            #endif
-            ByteReverseWords64(sha512->buffer,sha512->buffer,SHA512_BLOCK_SIZE);
-        #endif
-        ret = Transform(sha512);
-        if (ret != 0)
-            return ret;
-
-        sha512->buffLen = 0;
-    }
-    XMEMSET(&local[sha512->buffLen], 0, SHA512_PAD_SIZE - sha512->buffLen);
-   
-    /* put lengths in bits */
-    sha512->hiLen = (sha512->loLen >> (8*sizeof(sha512->loLen) - 3)) + 
-                 (sha512->hiLen << 3);
-    sha512->loLen = sha512->loLen << 3;
-
-    /* store lengths */
-    #if defined(LITTLE_ENDIAN_ORDER)
-        #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-        if(!IS_INTEL_AVX1 && !IS_INTEL_AVX2)
-        #endif
-        ByteReverseWords64(sha512->buffer, sha512->buffer, SHA512_PAD_SIZE);
-    #endif
-    /* ! length ordering dependent on digest endian type ! */
-
-    sha512->buffer[SHA512_BLOCK_SIZE / sizeof(word64) - 2] = sha512->hiLen;
-    sha512->buffer[SHA512_BLOCK_SIZE / sizeof(word64) - 1] = sha512->loLen;
-    #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-    if(IS_INTEL_AVX1 || IS_INTEL_AVX2)
-        ByteReverseWords64(&(sha512->buffer[SHA512_BLOCK_SIZE / sizeof(word64) - 2]),
-                           &(sha512->buffer[SHA512_BLOCK_SIZE / sizeof(word64) - 2]),
-                           SHA512_BLOCK_SIZE - SHA512_PAD_SIZE);
-    #endif
-    ret = Transform(sha512);
-    if (ret != 0)
-        return ret;
-
-    #ifdef LITTLE_ENDIAN_ORDER
-        ByteReverseWords64(sha512->digest, sha512->digest, SHA512_DIGEST_SIZE);
-    #endif
-    XMEMCPY(hash, sha512->digest, SHA512_DIGEST_SIZE);
-
-    return wc_InitSha512(sha512);  /* reset state */
-}
-
-
-int wc_Sha512Hash(const byte* data, word32 len, byte* hash)
-{
-    int ret = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    Sha512* sha512;
-#else
-    Sha512 sha512[1];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    sha512 = (Sha512*)XMALLOC(sizeof(Sha512), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (sha512 == NULL)
-        return MEMORY_E;
-#endif
-    
-    if ((ret = wc_InitSha512(sha512)) != 0) {
-        WOLFSSL_MSG("InitSha512 failed");
-    }
-    else if ((ret = wc_Sha512Update(sha512, data, len)) != 0) {
-        WOLFSSL_MSG("Sha512Update failed");
-    }
-    else if ((ret = wc_Sha512Final(sha512, hash)) != 0) {
-        WOLFSSL_MSG("Sha512Final failed");
-    }
-    
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(sha512, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-    
-    return ret;
-}
-
-#if defined(HAVE_INTEL_AVX1)
-
-#define Rx_1(i) h(i)+=S1(e(i))+Ch(e(i),f(i),g(i))+K[i+j] + W_X[i] ;
-#define Rx_2(i) d(i)+=h(i);
-#define Rx_3(i) h(i)+=S0(a(i))+Maj(a(i),b(i),c(i));
-
-#if defined(HAVE_INTEL_RORX)
-#define Rx_RORX_1(i) h(i)+=S1_RORX(e(i))+Ch(e(i),f(i),g(i))+K[i+j] + W_X[i] ;
-#define Rx_RORX_2(i) d(i)+=h(i);
-#define Rx_RORX_3(i) h(i)+=S0_RORX(a(i))+Maj(a(i),b(i),c(i));
-#endif
-
-#endif
-
-#if defined(HAVE_INTEL_AVX2) 
-#define Ry_1(i, w) h(i)+=S1(e(i))+Ch(e(i),f(i),g(i))+K[i+j] + w ; 
-#define Ry_2(i, w) d(i)+=h(i);
-#define Ry_3(i, w) h(i)+=S0(a(i))+Maj(a(i),b(i),c(i));
-#endif
-
-#if defined(HAVE_INTEL_AVX1) /* inline Assember for Intel AVX1 instructions */
-#if defined(DEBUG_XMM)
-
-#define SAVE_REG(i)     __asm__ volatile("vmovdqu %%xmm"#i", %0 \n\t":"=m"(reg[i][0])::XMM_REGs);
-#define RECV_REG(i)     __asm__ volatile("vmovdqu %0, %%xmm"#i" \n\t"::"m"(reg[i][0]):XMM_REGs);
-
-#define _DUMP_REG(REG, name)\
-    { word64 buf[16] ;word64 reg[16][2];int k ;\
-      SAVE_REG(0); SAVE_REG(1); SAVE_REG(2);  SAVE_REG(3);  SAVE_REG(4);  \
-      SAVE_REG(5);   SAVE_REG(6); SAVE_REG(7);SAVE_REG(8); SAVE_REG(9); SAVE_REG(10);\
-       SAVE_REG(11); SAVE_REG(12); SAVE_REG(13); SAVE_REG(14); SAVE_REG(15); \
-      __asm__ volatile("vmovdqu %%"#REG", %0 \n\t":"=m"(buf[0])::XMM_REGs);\
-      printf(" "#name":\t") ; for(k=0; k<2; k++) printf("%016lx.", (word64)(buf[k])); printf("\n") ; \
-      RECV_REG(0); RECV_REG(1); RECV_REG(2);  RECV_REG(3);  RECV_REG(4);\
-      RECV_REG(5);   RECV_REG(6); RECV_REG(7); RECV_REG(8); RECV_REG(9);\
-      RECV_REG(10); RECV_REG(11); RECV_REG(12); RECV_REG(13); RECV_REG(14); RECV_REG(15);\
-    }
-
-#define DUMP_REG(REG) _DUMP_REG(REG, #REG) 
-#define PRINTF(fmt, ...) 
-
-#else
-
-#define DUMP_REG(REG) 
-#define PRINTF(fmt, ...) 
-
-#endif
-
-#define _MOVE_to_REG(xymm, mem)       __asm__ volatile("vmovdqu %0, %%"#xymm" "\
-        :: "m"(mem):XMM_REGs) ;
-#define _MOVE_to_MEM(mem,i, xymm)     __asm__ volatile("vmovdqu %%"#xymm", %0" :\
-         "=m"(mem[i]),"=m"(mem[i+1]),"=m"(mem[i+2]),"=m"(mem[i+3])::XMM_REGs) ;
-#define _MOVE(dest, src)              __asm__ volatile("vmovdqu %%"#src",  %%"\
-        #dest" ":::XMM_REGs) ;
-
-#define _S_TEMP(dest, src, bits, temp)  __asm__ volatile("vpsrlq  $"#bits", %%"\
-        #src", %%"#dest"\n\tvpsllq  $64-"#bits", %%"#src", %%"#temp"\n\tvpor %%"\
-        #temp",%%"#dest", %%"#dest" ":::XMM_REGs) ;
-#define _AVX1_R(dest, src, bits)      __asm__ volatile("vpsrlq  $"#bits", %%"\
-        #src", %%"#dest" ":::XMM_REGs) ;
-#define _XOR(dest, src1, src2)        __asm__ volatile("vpxor   %%"#src1", %%"\
-        #src2", %%"#dest" ":::XMM_REGs) ;
-#define _OR(dest, src1, src2)         __asm__ volatile("vpor    %%"#src1", %%"\
-        #src2", %%"#dest" ":::XMM_REGs) ;
-#define _ADD(dest, src1, src2)        __asm__ volatile("vpaddq   %%"#src1", %%"\
-        #src2", %%"#dest" ":::XMM_REGs) ;
-#define _ADD_MEM(dest, src1, mem)     __asm__ volatile("vpaddq   %0, %%"#src1", %%"\
-        #dest" "::"m"(mem):XMM_REGs) ;
-
-#define MOVE_to_REG(xymm, mem)      _MOVE_to_REG(xymm, mem)
-#define MOVE_to_MEM(mem, i, xymm)   _MOVE_to_MEM(mem, i, xymm)
-#define MOVE(dest, src)             _MOVE(dest, src)  
-
-#define XOR(dest, src1, src2)      _XOR(dest, src1, src2)
-#define OR(dest, src1, src2)       _OR(dest, src1, src2)
-#define ADD(dest, src1, src2)      _ADD(dest, src1, src2)
-
-#define S_TMP(dest, src, bits, temp) _S_TEMP(dest, src, bits, temp);
-#define AVX1_S(dest, src, bits)      S_TMP(dest, src, bits, S_TEMP)
-#define AVX1_R(dest, src, bits)      _AVX1_R(dest, src, bits)
-
-#define Init_Mask(mask) \
-     __asm__ volatile("vmovdqu %0, %%xmm1\n\t"::"m"(mask):"%xmm1") ;
-     
-#define _W_from_buff1(w, buff, xmm) \
-    /* X0..3(xmm4..7), W[0..15] = sha512->buffer[0.15];  */\
-     __asm__ volatile("vmovdqu %1, %%"#xmm"\n\t"\
-                      "vpshufb %%xmm1, %%"#xmm", %%"#xmm"\n\t"\
-                      "vmovdqu %%"#xmm", %0"\
-                      :"=m"(w): "m"(buff):"%xmm0") ;
-
-#define W_from_buff1(w, buff, xmm) _W_from_buff1(w, buff, xmm) 
-
-#define W_from_buff(w, buff)\
-     Init_Mask(mBYTE_FLIP_MASK[0]) ;\
-     W_from_buff1(w[0], buff[0], W_0);\
-     W_from_buff1(w[2], buff[2], W_2);\
-     W_from_buff1(w[4], buff[4], W_4);\
-     W_from_buff1(w[6], buff[6], W_6);\
-     W_from_buff1(w[8], buff[8], W_8);\
-     W_from_buff1(w[10],buff[10],W_10);\
-     W_from_buff1(w[12],buff[12],W_12);\
-     W_from_buff1(w[14],buff[14],W_14);
-                          
-static word64 mBYTE_FLIP_MASK[] =  { 0x0001020304050607, 0x08090a0b0c0d0e0f } ;
-
-#define W_I_15  xmm14
-#define W_I_7   xmm11
-#define W_I_2   xmm13
-#define W_I     xmm12
-#define G_TEMP  xmm0
-#define S_TEMP  xmm1
-#define XMM_TEMP0  xmm2
-
-#define W_0     xmm12
-#define W_2     xmm3
-#define W_4     xmm4
-#define W_6     xmm5
-#define W_8     xmm6
-#define W_10    xmm7
-#define W_12    xmm8
-#define W_14    xmm9
-
-#define XMM_REGs
-
-#define s0_1(dest, src)      AVX1_S(dest, src, 1); 
-#define s0_2(dest, src)      AVX1_S(G_TEMP, src, 8); XOR(dest, G_TEMP, dest) ; 
-#define s0_3(dest, src)      AVX1_R(G_TEMP, src, 7);  XOR(dest, G_TEMP, dest) ;
-
-#define s1_1(dest, src)      AVX1_S(dest, src, 19);
-#define s1_2(dest, src)      AVX1_S(G_TEMP, src, 61); XOR(dest, G_TEMP, dest) ; 
-#define s1_3(dest, src)      AVX1_R(G_TEMP, src, 6); XOR(dest, G_TEMP, dest) ;
-
-#define s0_(dest, src)       s0_1(dest, src) ; s0_2(dest, src) ; s0_3(dest, src)
-#define s1_(dest, src)       s1_1(dest, src) ; s1_2(dest, src) ; s1_3(dest, src)
-        
-#define Block_xx_1(i) \
-    MOVE_to_REG(W_I_15, W_X[(i-15)&15]) ;\
-    MOVE_to_REG(W_I_7,  W_X[(i- 7)&15]) ;\
-        
-#define Block_xx_2(i) \
-    MOVE_to_REG(W_I_2,  W_X[(i- 2)&15]) ;\
-    MOVE_to_REG(W_I,    W_X[(i)]) ;\
-        
-#define Block_xx_3(i) \
-    s0_ (XMM_TEMP0, W_I_15) ;\
-        
-#define Block_xx_4(i) \
-    ADD(W_I, W_I, XMM_TEMP0) ;\
-    ADD(W_I, W_I, W_I_7) ;\
-        
-#define Block_xx_5(i) \
-    s1_ (XMM_TEMP0, W_I_2) ;\
-    
-#define Block_xx_6(i) \
-    ADD(W_I, W_I, XMM_TEMP0) ;\
-    MOVE_to_MEM(W_X,i, W_I) ;\
-    if(i==0)\
-        MOVE_to_MEM(W_X,16, W_I) ;\
-
-#define Block_xx_7(i) \
-    MOVE_to_REG(W_I_15, W_X[(i-15)&15]) ;\
-    MOVE_to_REG(W_I_7,  W_X[(i- 7)&15]) ;\
-            
-#define Block_xx_8(i) \
-    MOVE_to_REG(W_I_2,  W_X[(i- 2)&15]) ;\
-    MOVE_to_REG(W_I,    W_X[(i)]) ;\
-
-#define Block_xx_9(i) \
-    s0_ (XMM_TEMP0, W_I_15) ;\
-
-#define Block_xx_10(i) \
-    ADD(W_I, W_I, XMM_TEMP0) ;\
-    ADD(W_I, W_I, W_I_7) ;\
-
-#define Block_xx_11(i) \
-    s1_ (XMM_TEMP0, W_I_2) ;\
-
-#define Block_xx_12(i) \
-    ADD(W_I, W_I, XMM_TEMP0) ;\
-    MOVE_to_MEM(W_X,i, W_I) ;\
-    if((i)==0)\
-        MOVE_to_MEM(W_X,16, W_I) ;\
-
-static inline void Block_0_1(word64 *W_X) { Block_xx_1(0) ; }
-static inline void Block_0_2(word64 *W_X) { Block_xx_2(0) ; }
-static inline void Block_0_3(void) { Block_xx_3(0) ; }
-static inline void Block_0_4(void) { Block_xx_4(0) ; }
-static inline void Block_0_5(void) { Block_xx_5(0) ; }
-static inline void Block_0_6(word64 *W_X) { Block_xx_6(0) ; }
-static inline void Block_0_7(word64 *W_X) { Block_xx_7(2) ; }
-static inline void Block_0_8(word64 *W_X) { Block_xx_8(2) ; }
-static inline void Block_0_9(void) { Block_xx_9(2) ; }
-static inline void Block_0_10(void){ Block_xx_10(2) ; }
-static inline void Block_0_11(void){ Block_xx_11(2) ; }
-static inline void Block_0_12(word64 *W_X){ Block_xx_12(2) ; }
-
-static inline void Block_4_1(word64 *W_X) { Block_xx_1(4) ; }
-static inline void Block_4_2(word64 *W_X) { Block_xx_2(4) ; }
-static inline void Block_4_3(void) { Block_xx_3(4) ; }
-static inline void Block_4_4(void) { Block_xx_4(4) ; }
-static inline void Block_4_5(void) { Block_xx_5(4) ; }
-static inline void Block_4_6(word64 *W_X) { Block_xx_6(4) ; }
-static inline void Block_4_7(word64 *W_X) { Block_xx_7(6) ; }
-static inline void Block_4_8(word64 *W_X) { Block_xx_8(6) ; }
-static inline void Block_4_9(void) { Block_xx_9(6) ; }
-static inline void Block_4_10(void){ Block_xx_10(6) ; }
-static inline void Block_4_11(void){ Block_xx_11(6) ; }
-static inline void Block_4_12(word64 *W_X){ Block_xx_12(6) ; }
-
-static inline void Block_8_1(word64 *W_X) { Block_xx_1(8) ; }
-static inline void Block_8_2(word64 *W_X) { Block_xx_2(8) ; }
-static inline void Block_8_3(void) { Block_xx_3(8) ; }
-static inline void Block_8_4(void) { Block_xx_4(8) ; }
-static inline void Block_8_5(void) { Block_xx_5(8) ; }
-static inline void Block_8_6(word64 *W_X) { Block_xx_6(8) ; }
-static inline void Block_8_7(word64 *W_X) { Block_xx_7(10) ; }
-static inline void Block_8_8(word64 *W_X) { Block_xx_8(10) ; }
-static inline void Block_8_9(void) { Block_xx_9(10) ; }
-static inline void Block_8_10(void){ Block_xx_10(10) ; }
-static inline void Block_8_11(void){ Block_xx_11(10) ; }
-static inline void Block_8_12(word64 *W_X){ Block_xx_12(10) ; }
-
-static inline void Block_12_1(word64 *W_X) { Block_xx_1(12) ; }
-static inline void Block_12_2(word64 *W_X) { Block_xx_2(12) ; }
-static inline void Block_12_3(void) { Block_xx_3(12) ; }
-static inline void Block_12_4(void) { Block_xx_4(12) ; }
-static inline void Block_12_5(void) { Block_xx_5(12) ; }
-static inline void Block_12_6(word64 *W_X) { Block_xx_6(12) ; }
-static inline void Block_12_7(word64 *W_X) { Block_xx_7(14) ; }
-static inline void Block_12_8(word64 *W_X) { Block_xx_8(14) ; }
-static inline void Block_12_9(void) { Block_xx_9(14) ; }
-static inline void Block_12_10(void){ Block_xx_10(14) ; }
-static inline void Block_12_11(void){ Block_xx_11(14) ; }
-static inline void Block_12_12(word64 *W_X){ Block_xx_12(14) ; }
-
-#endif
-
-#if defined(HAVE_INTEL_AVX2)
-static const unsigned long mBYTE_FLIP_MASK_Y[] =
-   { 0x0001020304050607, 0x08090a0b0c0d0e0f, 0x0001020304050607, 0x08090a0b0c0d0e0f } ;
-
-#define W_from_buff_Y(buff)\
-    { /* X0..3(ymm9..12), W_X[0..15] = sha512->buffer[0.15];  */\
-     __asm__ volatile("vmovdqu %0, %%ymm8\n\t"::"m"(mBYTE_FLIP_MASK_Y[0]):YMM_REGs) ;\
-     __asm__ volatile("vmovdqu %0, %%ymm12\n\t"\
-                      "vmovdqu %1, %%ymm4\n\t"\
-                      "vpshufb %%ymm8, %%ymm12, %%ymm12\n\t"\
-                      "vpshufb %%ymm8, %%ymm4, %%ymm4\n\t"\
-                      :: "m"(buff[0]),  "m"(buff[4]):YMM_REGs) ;\
-     __asm__ volatile("vmovdqu %0, %%ymm5\n\t"\
-                      "vmovdqu %1, %%ymm6\n\t"\
-                      "vpshufb %%ymm8, %%ymm5, %%ymm5\n\t"\
-                      "vpshufb %%ymm8, %%ymm6, %%ymm6\n\t"\
-                      :: "m"(buff[8]),  "m"(buff[12]):YMM_REGs) ;\
-    }
-
-#if defined(DEBUG_YMM)
-
-#define SAVE_REG_Y(i) __asm__ volatile("vmovdqu %%ymm"#i", %0 \n\t":"=m"(reg[i-4][0])::YMM_REGs);
-#define RECV_REG_Y(i) __asm__ volatile("vmovdqu %0, %%ymm"#i" \n\t"::"m"(reg[i-4][0]):YMM_REGs);
-
-#define _DUMP_REG_Y(REG, name)\
-    { word64 buf[16] ;word64 reg[16][2];int k ;\
-      SAVE_REG_Y(4);  SAVE_REG_Y(5);   SAVE_REG_Y(6); SAVE_REG_Y(7); \
-      SAVE_REG_Y(8); SAVE_REG_Y(9); SAVE_REG_Y(10); SAVE_REG_Y(11); SAVE_REG_Y(12);\
-      SAVE_REG_Y(13); SAVE_REG_Y(14); SAVE_REG_Y(15); \
-      __asm__ volatile("vmovdqu %%"#REG", %0 \n\t":"=m"(buf[0])::YMM_REGs);\
-      printf(" "#name":\t") ; for(k=0; k<4; k++) printf("%016lx.", (word64)buf[k]) ; printf("\n") ; \
-      RECV_REG_Y(4);  RECV_REG_Y(5);   RECV_REG_Y(6); RECV_REG_Y(7); \
-      RECV_REG_Y(8); RECV_REG_Y(9); RECV_REG_Y(10); RECV_REG_Y(11); RECV_REG_Y(12); \
-      RECV_REG_Y(13); RECV_REG_Y(14); RECV_REG_Y(15);\
-    }
-
-#define DUMP_REG_Y(REG) _DUMP_REG_Y(REG, #REG) 
-#define DUMP_REG2_Y(REG) _DUMP_REG_Y(REG, #REG) 
-#define PRINTF_Y(fmt, ...) 
-
-#else
-
-#define DUMP_REG_Y(REG) 
-#define DUMP_REG2_Y(REG)
-#define PRINTF_Y(fmt, ...) 
-
-#endif
-
-#define _MOVE_to_REGy(ymm, mem)         __asm__ volatile("vmovdqu %0, %%"#ymm" "\
-                                        :: "m"(mem):YMM_REGs) ;
-#define _MOVE_to_MEMy(mem,i, ymm)       __asm__ volatile("vmovdqu %%"#ymm", %0" \
-        : "=m"(mem[i]),"=m"(mem[i+1]),"=m"(mem[i+2]),"=m"(mem[i+3])::YMM_REGs) ;
-#define _MOVE_128y(ymm0, ymm1, ymm2, map)  __asm__ volatile("vperm2i128  $"\
-        #map", %%"#ymm2", %%"#ymm1", %%"#ymm0" ":::YMM_REGs) ;
-#define _S_TEMPy(dest, src, bits, temp) \
-         __asm__ volatile("vpsrlq  $"#bits", %%"#src", %%"#dest"\n\tvpsllq  $64-"#bits\
-        ", %%"#src", %%"#temp"\n\tvpor %%"#temp",%%"#dest", %%"#dest" ":::YMM_REGs) ;
-#define _AVX2_R(dest, src, bits)        __asm__ volatile("vpsrlq  $"#bits", %%"\
-         #src", %%"#dest" ":::YMM_REGs) ;
-#define _XORy(dest, src1, src2)         __asm__ volatile("vpxor   %%"#src1", %%"\
-         #src2", %%"#dest" ":::YMM_REGs) ;
-#define _ADDy(dest, src1, src2)         __asm__ volatile("vpaddq   %%"#src1", %%"\
-         #src2", %%"#dest" ":::YMM_REGs) ;
-#define _BLENDy(map, dest, src1, src2)  __asm__ volatile("vpblendd    $"#map", %%"\
-         #src1",   %%"#src2", %%"#dest" ":::YMM_REGs) ;
-#define _BLENDQy(map, dest, src1, src2) __asm__ volatile("vblendpd   $"#map", %%"\
-         #src1",   %%"#src2", %%"#dest" ":::YMM_REGs) ;
-#define _PERMQy(map, dest, src)         __asm__ volatile("vpermq  $"#map", %%"\
-         #src", %%"#dest" ":::YMM_REGs) ;
-
-#define MOVE_to_REGy(ymm, mem)      _MOVE_to_REGy(ymm, mem)
-#define MOVE_to_MEMy(mem, i, ymm)   _MOVE_to_MEMy(mem, i, ymm)
-
-#define MOVE_128y(ymm0, ymm1, ymm2, map) _MOVE_128y(ymm0, ymm1, ymm2, map) 
-#define XORy(dest, src1, src2)      _XORy(dest, src1, src2)
-#define ADDy(dest, src1, src2)      _ADDy(dest, src1, src2)
-#define BLENDy(map, dest, src1, src2) _BLENDy(map, dest, src1, src2)
-#define BLENDQy(map, dest, src1, src2) _BLENDQy(map, dest, src1, src2)
-#define PERMQy(map, dest, src)      _PERMQy(map, dest, src)
-
-
-#define S_TMPy(dest, src, bits, temp) _S_TEMPy(dest, src, bits, temp);
-#define AVX2_S(dest, src, bits)      S_TMPy(dest, src, bits, S_TEMPy)
-#define AVX2_R(dest, src, bits)      _AVX2_R(dest, src, bits)
-
-
-#define    FEEDBACK1_to_W_I_2(w_i_2, w_i)    MOVE_128y(YMM_TEMP0, w_i, w_i, 0x08) ;\
-                                       BLENDy(0xf0, w_i_2, YMM_TEMP0, w_i_2) ; 
-
-#define    MOVE_W_to_W_I_15(w_i_15, w_0, w_4)  BLENDQy(0x1, w_i_15, w_4, w_0) ;\
-                                       PERMQy(0x39, w_i_15, w_i_15) ;
-#define    MOVE_W_to_W_I_7(w_i_7,  w_8, w_12)  BLENDQy(0x1, w_i_7, w_12, w_8) ;\
-                                       PERMQy(0x39, w_i_7, w_i_7) ; 
-#define    MOVE_W_to_W_I_2(w_i_2,  w_12)       BLENDQy(0xc, w_i_2, w_12, w_i_2) ;\
-                                       PERMQy(0x0e, w_i_2, w_i_2) ;
-
-
-#define W_I_16y  ymm8
-#define W_I_15y  ymm9
-#define W_I_7y  ymm10
-#define W_I_2y  ymm11
-#define W_Iy    ymm12
-#define G_TEMPy     ymm13
-#define S_TEMPy     ymm14
-#define YMM_TEMP0  ymm15
-#define YMM_TEMP0x xmm15
-#define W_I_TEMPy   ymm7
-#define W_K_TEMPy   ymm15
-#define W_K_TEMPx  xmm15
-#define W_0y     ymm12
-#define W_4y     ymm4
-#define W_8y     ymm5
-#define W_12y    ymm6
-
-#define YMM_REGs
-/* Registers are saved in Sha512Update/Final */
-                 /* "%ymm7","%ymm8","%ymm9","%ymm10","%ymm11","%ymm12","%ymm13","%ymm14","%ymm15"*/
-
-#define MOVE_15_to_16(w_i_16, w_i_15, w_i_7)\
-    __asm__ volatile("vperm2i128  $0x01, %%"#w_i_15", %%"#w_i_15", %%"#w_i_15" ":::YMM_REGs) ;\
-    __asm__ volatile("vpblendd    $0x08, %%"#w_i_15", %%"#w_i_7", %%"#w_i_16" ":::YMM_REGs) ;\
-    __asm__ volatile("vperm2i128 $0x01,  %%"#w_i_7",  %%"#w_i_7", %%"#w_i_15" ":::YMM_REGs) ;\
-    __asm__ volatile("vpblendd    $0x80, %%"#w_i_15", %%"#w_i_16", %%"#w_i_16" ":::YMM_REGs) ;\
-    __asm__ volatile("vpshufd    $0x93,  %%"#w_i_16", %%"#w_i_16" ":::YMM_REGs) ;\
-
-#define MOVE_7_to_15(w_i_15, w_i_7)\
-    __asm__ volatile("vmovdqu                 %%"#w_i_7",  %%"#w_i_15" ":::YMM_REGs) ;\
-
-#define MOVE_I_to_7(w_i_7, w_i)\
-    __asm__ volatile("vperm2i128 $0x01,       %%"#w_i",   %%"#w_i",   %%"#w_i_7" ":::YMM_REGs) ;\
-    __asm__ volatile("vpblendd    $0x01,       %%"#w_i_7",   %%"#w_i", %%"#w_i_7" ":::YMM_REGs) ;\
-    __asm__ volatile("vpshufd    $0x39, %%"#w_i_7", %%"#w_i_7" ":::YMM_REGs) ;\
-
-#define MOVE_I_to_2(w_i_2, w_i)\
-    __asm__ volatile("vperm2i128 $0x01,       %%"#w_i", %%"#w_i", %%"#w_i_2" ":::YMM_REGs) ;\
-    __asm__ volatile("vpshufd    $0x0e, %%"#w_i_2", %%"#w_i_2" ":::YMM_REGs) ;\
-
-#endif
-
-
-/***  Transform Body ***/
-#if defined(HAVE_INTEL_AVX1)
-
-static int Transform_AVX1(Sha512* sha512)
-{
-    const word64* K = K512;
-    word64 W_X[16+4];
-    word32 j;
-    word64 T[8];
-    /* Copy digest to working vars */
-    XMEMCPY(T, sha512->digest, sizeof(T));
-
-    W_from_buff(W_X, sha512->buffer) ;
-    for (j = 0; j < 80; j += 16) {
-        Rx_1( 0); Block_0_1(W_X); Rx_2( 0); Block_0_2(W_X); Rx_3( 0); Block_0_3(); 
-        Rx_1( 1); Block_0_4(); Rx_2( 1); Block_0_5(); Rx_3( 1); Block_0_6(W_X); 
-        Rx_1( 2); Block_0_7(W_X); Rx_2( 2); Block_0_8(W_X); Rx_3( 2); Block_0_9();
-        Rx_1( 3); Block_0_10();Rx_2( 3); Block_0_11();Rx_3( 3); Block_0_12(W_X);   
-        
-        Rx_1( 4); Block_4_1(W_X); Rx_2( 4); Block_4_2(W_X); Rx_3( 4); Block_4_3(); 
-        Rx_1( 5); Block_4_4(); Rx_2( 5); Block_4_5(); Rx_3( 5); Block_4_6(W_X); 
-        Rx_1( 6); Block_4_7(W_X); Rx_2( 6); Block_4_8(W_X); Rx_3( 6); Block_4_9();
-        Rx_1( 7); Block_4_10();Rx_2( 7); Block_4_11();Rx_3( 7); Block_4_12(W_X);   
-        
-        Rx_1( 8); Block_8_1(W_X); Rx_2( 8); Block_8_2(W_X); Rx_3( 8); Block_8_3(); 
-        Rx_1( 9); Block_8_4(); Rx_2( 9); Block_8_5(); Rx_3( 9); Block_8_6(W_X); 
-        Rx_1(10); Block_8_7(W_X); Rx_2(10); Block_8_8(W_X); Rx_3(10); Block_8_9();
-        Rx_1(11); Block_8_10();Rx_2(11); Block_8_11();Rx_3(11); Block_8_12(W_X);   
-        
-        Rx_1(12); Block_12_1(W_X); Rx_2(12); Block_12_2(W_X); Rx_3(12); Block_12_3(); 
-        Rx_1(13); Block_12_4(); Rx_2(13); Block_12_5(); Rx_3(13); Block_12_6(W_X); 
-        Rx_1(14); Block_12_7(W_X); Rx_2(14); Block_12_8(W_X); Rx_3(14); Block_12_9();
-        Rx_1(15); Block_12_10();Rx_2(15); Block_12_11();Rx_3(15); Block_12_12(W_X);     
-    }
-
-    /* Add the working vars back into digest */
-
-    sha512->digest[0] += a(0);
-    sha512->digest[1] += b(0);
-    sha512->digest[2] += c(0);
-    sha512->digest[3] += d(0);
-    sha512->digest[4] += e(0);
-    sha512->digest[5] += f(0);
-    sha512->digest[6] += g(0);
-    sha512->digest[7] += h(0);
-
-    /* Wipe variables */
-    #if !defined(HAVE_INTEL_AVX1)&&!defined(HAVE_INTEL_AVX2)
-    XMEMSET(W_X, 0, sizeof(word64) * 16);
-    #endif
-    XMEMSET(T, 0, sizeof(T));
-
-    return 0;
-}
-
-#endif
-
-#if defined(HAVE_INTEL_AVX2) && defined(HAVE_INTEL_AVX1) && defined(HAVE_INTEL_RORX)
-
-static int Transform_AVX1_RORX(Sha512* sha512)
-{
-    const word64* K = K512;
-    word64 W_X[16+4];
-    word32 j;
-    word64 T[8];
-    /* Copy digest to working vars */
-    XMEMCPY(T, sha512->digest, sizeof(T));
-
-    W_from_buff(W_X, sha512->buffer) ;
-    for (j = 0; j < 80; j += 16) {
-        Rx_RORX_1( 0); Block_0_1(W_X); Rx_RORX_2( 0); Block_0_2(W_X); 
-                                    Rx_RORX_3( 0); Block_0_3(); 
-        Rx_RORX_1( 1); Block_0_4(); Rx_RORX_2( 1); Block_0_5(); 
-                                    Rx_RORX_3( 1); Block_0_6(W_X); 
-        Rx_RORX_1( 2); Block_0_7(W_X); Rx_RORX_2( 2); Block_0_8(W_X); 
-                                    Rx_RORX_3( 2); Block_0_9();
-        Rx_RORX_1( 3); Block_0_10();Rx_RORX_2( 3); Block_0_11();
-                                    Rx_RORX_3( 3); Block_0_12(W_X);   
-        
-        Rx_RORX_1( 4); Block_4_1(W_X); Rx_RORX_2( 4); Block_4_2(W_X); 
-                                    Rx_RORX_3( 4); Block_4_3(); 
-        Rx_RORX_1( 5); Block_4_4(); Rx_RORX_2( 5); Block_4_5(); 
-                                    Rx_RORX_3( 5); Block_4_6(W_X); 
-        Rx_RORX_1( 6); Block_4_7(W_X); Rx_RORX_2( 6); Block_4_8(W_X); 
-                                    Rx_RORX_3( 6); Block_4_9();
-        Rx_RORX_1( 7); Block_4_10();Rx_RORX_2( 7); Block_4_11();
-                                    Rx_RORX_3( 7); Block_4_12(W_X);   
-        
-        Rx_RORX_1( 8); Block_8_1(W_X); Rx_RORX_2( 8); Block_8_2(W_X); 
-                                    Rx_RORX_3( 8); Block_8_3(); 
-        Rx_RORX_1( 9); Block_8_4(); Rx_RORX_2( 9); Block_8_5(); 
-                                    Rx_RORX_3( 9); Block_8_6(W_X); 
-        Rx_RORX_1(10); Block_8_7(W_X); Rx_RORX_2(10); Block_8_8(W_X); 
-                                    Rx_RORX_3(10); Block_8_9();
-        Rx_RORX_1(11); Block_8_10();Rx_RORX_2(11); Block_8_11();
-                                    Rx_RORX_3(11); Block_8_12(W_X);   
-        
-        Rx_RORX_1(12); Block_12_1(W_X); Rx_RORX_2(12); Block_12_2(W_X); 
-                                     Rx_RORX_3(12); Block_12_3(); 
-        Rx_RORX_1(13); Block_12_4(); Rx_RORX_2(13); Block_12_5(); 
-                                     Rx_RORX_3(13); Block_12_6(W_X); 
-        Rx_RORX_1(14); Block_12_7(W_X); Rx_RORX_2(14); Block_12_8(W_X); 
-                                     Rx_RORX_3(14); Block_12_9();
-        Rx_RORX_1(15); Block_12_10();Rx_RORX_2(15); Block_12_11();
-                                     Rx_RORX_3(15); Block_12_12(W_X);     
-    }
-    /* Add the working vars back into digest */
-
-    sha512->digest[0] += a(0);
-    sha512->digest[1] += b(0);
-    sha512->digest[2] += c(0);
-    sha512->digest[3] += d(0);
-    sha512->digest[4] += e(0);
-    sha512->digest[5] += f(0);
-    sha512->digest[6] += g(0);
-    sha512->digest[7] += h(0);
-
-    /* Wipe variables */
-    #if !defined(HAVE_INTEL_AVX1)&&!defined(HAVE_INTEL_AVX2)
-    XMEMSET(W_X, 0, sizeof(word64) * 16);
-    #endif
-    XMEMSET(T, 0, sizeof(T));
-
-    return 0;
-}
-#endif
-
-#if defined(HAVE_INTEL_AVX2)
-
-#define s0_1y(dest, src)      AVX2_S(dest, src, 1); 
-#define s0_2y(dest, src)      AVX2_S(G_TEMPy, src, 8); XORy(dest, G_TEMPy, dest) ; 
-#define s0_3y(dest, src)      AVX2_R(G_TEMPy, src, 7);  XORy(dest, G_TEMPy, dest) ;
-
-#define s1_1y(dest, src)      AVX2_S(dest, src, 19);
-#define s1_2y(dest, src)      AVX2_S(G_TEMPy, src, 61); XORy(dest, G_TEMPy, dest) ; 
-#define s1_3y(dest, src)      AVX2_R(G_TEMPy, src, 6); XORy(dest, G_TEMPy, dest) ;
-
-#define s0_y(dest, src)       s0_1y(dest, src) ; s0_2y(dest, src) ; s0_3y(dest, src)
-#define s1_y(dest, src)       s1_1y(dest, src) ; s1_2y(dest, src) ; s1_3y(dest, src)
-
-#define blk384(i) (W[i] = sha384->buffer[i])
-
-
-#define Block_Y_xx_1(i, w_0, w_4, w_8, w_12)\
-    MOVE_W_to_W_I_15(W_I_15y, w_0, w_4) ;\
-    MOVE_W_to_W_I_7 (W_I_7y,  w_8, w_12) ;\
-    MOVE_W_to_W_I_2 (W_I_2y,  w_12) ;\
-
-#define Block_Y_xx_2(i, w_0, w_4, w_8, w_12)\
-    s0_1y (YMM_TEMP0, W_I_15y) ;\
-
-#define Block_Y_xx_3(i, w_0, w_4, w_8, w_12)\
-    s0_2y (YMM_TEMP0, W_I_15y) ;\
-
-#define Block_Y_xx_4(i, w_0, w_4, w_8, w_12)\
-    s0_3y (YMM_TEMP0, W_I_15y) ;\
-
-#define Block_Y_xx_5(i, w_0, w_4, w_8, w_12)\
-    ADDy(W_I_TEMPy, w_0, YMM_TEMP0) ;\
-
-#define Block_Y_xx_6(i, w_0, w_4, w_8, w_12)\
-    ADDy(W_I_TEMPy, W_I_TEMPy, W_I_7y) ;\
-    s1_1y (YMM_TEMP0, W_I_2y) ;\
-
-#define Block_Y_xx_7(i, w_0, w_4, w_8, w_12)\
-    s1_2y (YMM_TEMP0, W_I_2y) ;\
-
-#define Block_Y_xx_8(i, w_0, w_4, w_8, w_12)\
-    s1_3y (YMM_TEMP0, W_I_2y) ;\
-    ADDy(w_0, W_I_TEMPy, YMM_TEMP0) ;\
-
-#define Block_Y_xx_9(i, w_0, w_4, w_8, w_12)\
-    FEEDBACK1_to_W_I_2(W_I_2y, w_0) ;\
-
-#define Block_Y_xx_10(i, w_0, w_4, w_8, w_12) \
-    s1_1y (YMM_TEMP0, W_I_2y) ;\
-
-#define Block_Y_xx_11(i, w_0, w_4, w_8, w_12) \
-    s1_2y (YMM_TEMP0, W_I_2y) ;\
-
-#define Block_Y_xx_12(i, w_0, w_4, w_8, w_12)\
-    s1_3y (YMM_TEMP0, W_I_2y) ;\
-    ADDy(w_0, W_I_TEMPy, YMM_TEMP0) ;\
-    MOVE_to_MEMy(w,0, w_4) ;\
-
-
-static inline void Block_Y_0_1(void) { Block_Y_xx_1(0, W_0y, W_4y, W_8y, W_12y) ; }
-static inline void Block_Y_0_2(void) { Block_Y_xx_2(0, W_0y, W_4y, W_8y, W_12y) ; }
-static inline void Block_Y_0_3(void) { Block_Y_xx_3(0, W_0y, W_4y, W_8y, W_12y) ; }
-static inline void Block_Y_0_4(void) { Block_Y_xx_4(0, W_0y, W_4y, W_8y, W_12y) ; }
-static inline void Block_Y_0_5(void) { Block_Y_xx_5(0, W_0y, W_4y, W_8y, W_12y) ; }
-static inline void Block_Y_0_6(void) { Block_Y_xx_6(0, W_0y, W_4y, W_8y, W_12y) ; }
-static inline void Block_Y_0_7(void) { Block_Y_xx_7(0, W_0y, W_4y, W_8y, W_12y) ; }
-static inline void Block_Y_0_8(void) { Block_Y_xx_8(0, W_0y, W_4y, W_8y, W_12y) ; }
-static inline void Block_Y_0_9(void) { Block_Y_xx_9(0, W_0y, W_4y, W_8y, W_12y) ; }
-static inline void Block_Y_0_10(void){ Block_Y_xx_10(0, W_0y, W_4y, W_8y, W_12y) ; }
-static inline void Block_Y_0_11(void){ Block_Y_xx_11(0, W_0y, W_4y, W_8y, W_12y) ; }
-static inline void Block_Y_0_12(word64 *w){ Block_Y_xx_12(0, W_0y, W_4y, W_8y, W_12y) ; }
-
-static inline void Block_Y_4_1(void) { Block_Y_xx_1(4, W_4y, W_8y, W_12y, W_0y) ; }
-static inline void Block_Y_4_2(void) { Block_Y_xx_2(4, W_4y, W_8y, W_12y, W_0y) ; }
-static inline void Block_Y_4_3(void) { Block_Y_xx_3(4, W_4y, W_8y, W_12y, W_0y) ; }
-static inline void Block_Y_4_4(void) { Block_Y_xx_4(4, W_4y, W_8y, W_12y, W_0y) ; }
-static inline void Block_Y_4_5(void) { Block_Y_xx_5(4, W_4y, W_8y, W_12y, W_0y) ; }
-static inline void Block_Y_4_6(void) { Block_Y_xx_6(4, W_4y, W_8y, W_12y, W_0y) ; }
-static inline void Block_Y_4_7(void) { Block_Y_xx_7(4, W_4y, W_8y, W_12y, W_0y) ; }
-static inline void Block_Y_4_8(void) { Block_Y_xx_8(4, W_4y, W_8y, W_12y, W_0y) ; }
-static inline void Block_Y_4_9(void) { Block_Y_xx_9(4, W_4y, W_8y, W_12y, W_0y) ; }
-static inline void Block_Y_4_10(void) { Block_Y_xx_10(4, W_4y, W_8y, W_12y, W_0y) ; }
-static inline void Block_Y_4_11(void) { Block_Y_xx_11(4, W_4y, W_8y, W_12y, W_0y) ; }
-static inline void Block_Y_4_12(word64 *w) { Block_Y_xx_12(4, W_4y, W_8y, W_12y, W_0y) ; }
-
-static inline void Block_Y_8_1(void) { Block_Y_xx_1(8, W_8y, W_12y, W_0y, W_4y) ; }
-static inline void Block_Y_8_2(void) { Block_Y_xx_2(8, W_8y, W_12y, W_0y, W_4y) ; }
-static inline void Block_Y_8_3(void) { Block_Y_xx_3(8, W_8y, W_12y, W_0y, W_4y) ; }
-static inline void Block_Y_8_4(void) { Block_Y_xx_4(8, W_8y, W_12y, W_0y, W_4y) ; }
-static inline void Block_Y_8_5(void) { Block_Y_xx_5(8, W_8y, W_12y, W_0y, W_4y) ; }
-static inline void Block_Y_8_6(void) { Block_Y_xx_6(8, W_8y, W_12y, W_0y, W_4y) ; }
-static inline void Block_Y_8_7(void) { Block_Y_xx_7(8, W_8y, W_12y, W_0y, W_4y) ; }
-static inline void Block_Y_8_8(void) { Block_Y_xx_8(8, W_8y, W_12y, W_0y, W_4y) ; }
-static inline void Block_Y_8_9(void) { Block_Y_xx_9(8, W_8y, W_12y, W_0y, W_4y) ; }
-static inline void Block_Y_8_10(void) { Block_Y_xx_10(8, W_8y, W_12y, W_0y, W_4y) ; }
-static inline void Block_Y_8_11(void) { Block_Y_xx_11(8, W_8y, W_12y, W_0y, W_4y) ; }
-static inline void Block_Y_8_12(word64 *w) { Block_Y_xx_12(8, W_8y, W_12y, W_0y, W_4y) ; }
-
-static inline void Block_Y_12_1(void) { Block_Y_xx_1(12, W_12y, W_0y, W_4y, W_8y) ; }
-static inline void Block_Y_12_2(void) { Block_Y_xx_2(12, W_12y, W_0y, W_4y, W_8y) ; }
-static inline void Block_Y_12_3(void) { Block_Y_xx_3(12, W_12y, W_0y, W_4y, W_8y) ; }
-static inline void Block_Y_12_4(void) { Block_Y_xx_4(12, W_12y, W_0y, W_4y, W_8y) ; }
-static inline void Block_Y_12_5(void) { Block_Y_xx_5(12, W_12y, W_0y, W_4y, W_8y) ; }
-static inline void Block_Y_12_6(void) { Block_Y_xx_6(12, W_12y, W_0y, W_4y, W_8y) ; }
-static inline void Block_Y_12_7(void) { Block_Y_xx_7(12, W_12y, W_0y, W_4y, W_8y) ; }
-static inline void Block_Y_12_8(void) { Block_Y_xx_8(12, W_12y, W_0y, W_4y, W_8y) ; }
-static inline void Block_Y_12_9(void) { Block_Y_xx_9(12, W_12y, W_0y, W_4y, W_8y) ; }
-static inline void Block_Y_12_10(void) { Block_Y_xx_10(12, W_12y, W_0y, W_4y, W_8y) ; }
-static inline void Block_Y_12_11(void) { Block_Y_xx_11(12, W_12y, W_0y, W_4y, W_8y) ; }
-static inline void Block_Y_12_12(word64 *w) { Block_Y_xx_12(12, W_12y, W_0y, W_4y, W_8y) ; }
-
-
-static int Transform_AVX2(Sha512* sha512)
-{
-    const word64* K = K512;
-    word64 w[4] ;
-    word32 j /*, k*/;
-    word64 T[8];
-    /* Copy digest to working vars */
-    XMEMCPY(T, sha512->digest, sizeof(T));
-
-    W_from_buff_Y(sha512->buffer) ;
-    MOVE_to_MEMy(w,0, W_0y) ; 
-    for (j = 0; j < 80; j += 16) {
-        Ry_1( 0, w[0]); Block_Y_0_1(); Ry_2( 0, w[0]); Block_Y_0_2(); 
-                                       Ry_3( 0, w[0]); Block_Y_0_3(); 
-        Ry_1( 1, w[1]); Block_Y_0_4(); Ry_2( 1, w[1]); Block_Y_0_5(); 
-                                       Ry_3( 1, w[1]); Block_Y_0_6();  
-        Ry_1( 2, w[2]); Block_Y_0_7(); Ry_2( 2, w[2]); Block_Y_0_8(); 
-                                       Ry_3( 2, w[2]); Block_Y_0_9();
-        Ry_1( 3, w[3]); Block_Y_0_10();Ry_2( 3, w[3]); Block_Y_0_11();
-                                       Ry_3( 3, w[3]); Block_Y_0_12(w);
-        
-        Ry_1( 4, w[0]); Block_Y_4_1(); Ry_2( 4, w[0]); Block_Y_4_2(); 
-                                       Ry_3( 4, w[0]); Block_Y_4_3(); 
-        Ry_1( 5, w[1]); Block_Y_4_4(); Ry_2( 5, w[1]); Block_Y_4_5(); 
-                                       Ry_3( 5, w[1]); Block_Y_4_6();
-        Ry_1( 6, w[2]); Block_Y_4_7(); Ry_2( 6, w[2]); Block_Y_4_8(); 
-                                       Ry_3( 6, w[2]); Block_Y_4_9();
-        Ry_1( 7, w[3]); Block_Y_4_10(); Ry_2( 7, w[3]);Block_Y_4_11(); 
-                                        Ry_3( 7, w[3]);Block_Y_4_12(w);  
-        
-        Ry_1( 8, w[0]); Block_Y_8_1(); Ry_2( 8, w[0]); Block_Y_8_2(); 
-                                       Ry_3( 8, w[0]); Block_Y_8_3();
-        Ry_1( 9, w[1]); Block_Y_8_4(); Ry_2( 9, w[1]); Block_Y_8_5(); 
-                                       Ry_3( 9, w[1]); Block_Y_8_6();
-        Ry_1(10, w[2]); Block_Y_8_7(); Ry_2(10, w[2]); Block_Y_8_8(); 
-                                       Ry_3(10, w[2]); Block_Y_8_9(); 
-        Ry_1(11, w[3]); Block_Y_8_10();Ry_2(11, w[3]); Block_Y_8_11();
-                                       Ry_3(11, w[3]); Block_Y_8_12(w);
-                 
-        Ry_1(12, w[0]); Block_Y_12_1(); Ry_2(12, w[0]); Block_Y_12_2(); 
-                                        Ry_3(12, w[0]); Block_Y_12_3();
-        Ry_1(13, w[1]); Block_Y_12_4(); Ry_2(13, w[1]); Block_Y_12_5(); 
-                                        Ry_3(13, w[1]); Block_Y_12_6(); 
-        Ry_1(14, w[2]); Block_Y_12_7(); Ry_2(14, w[2]); Block_Y_12_8(); 
-                                        Ry_3(14, w[2]); Block_Y_12_9();
-        Ry_1(15, w[3]); Block_Y_12_10();Ry_2(15, w[3]); Block_Y_12_11();
-                                        Ry_3(15, w[3]);Block_Y_12_12(w);
-    }
- 
-    /* Add the working vars back into digest */
-
-    sha512->digest[0] += a(0);
-    sha512->digest[1] += b(0);
-    sha512->digest[2] += c(0);
-    sha512->digest[3] += d(0);
-    sha512->digest[4] += e(0);
-    sha512->digest[5] += f(0);
-    sha512->digest[6] += g(0);
-    sha512->digest[7] += h(0);
-
-    /* Wipe variables */
-    #if !defined(HAVE_INTEL_AVX1)&&!defined(HAVE_INTEL_AVX2)
-    XMEMSET(W, 0, sizeof(word64) * 16);
-    #endif
-    XMEMSET(T, 0, sizeof(T));
-
-    return 0;
-}
-
-#endif
-
-
-#ifdef WOLFSSL_SHA384
-
-#if defined(HAVE_INTEL_AVX1) ||  defined(HAVE_INTEL_AVX2) 
-
-#if defined(HAVE_INTEL_AVX1)
-static int Transform384_AVX1(Sha384 *sha384) ;
-#endif
-#if defined(HAVE_INTEL_AVX2)
-static int Transform384_AVX2(Sha384 *sha384) ; 
-#endif
-
-#if defined(HAVE_INTEL_AVX1) &&  defined(HAVE_INTEL_AVX2) &&defined(HAVE_INTEL_RORX)
-static int Transform384_AVX1_RORX(Sha384 *sha384) ; 
-#endif
-
-static int _Transform384(Sha384 *sha384) ; 
-static int (*Transform384_p)(Sha384* sha384) = _Transform384 ;
-
-#define Transform384(sha384) (*Transform384_p)(sha384)
-static void set_Transform384(void) {
-     if(set_cpuid_flags(CHECK_SHA384))return ;
-
-#if defined(HAVE_INTEL_AVX1) && !defined(HAVE_INTEL_AVX2)
-     Transform384_p = ((IS_INTEL_AVX1) ? Transform384_AVX1 : _Transform384) ;
-#elif defined(HAVE_INTEL_AVX2)
-     #if defined(HAVE_INTEL_AVX1) && defined(HAVE_INTEL_RORX)
-     if(IS_INTEL_AVX2 && IS_INTEL_BMI2) { Transform384_p = Transform384_AVX1_RORX ; return ; }
-     #endif
-     if(IS_INTEL_AVX2) { Transform384_p = Transform384_AVX2 ; return ; }
-     #if defined(HAVE_INTEL_AVX1)
-     Transform384_p = ((IS_INTEL_AVX1) ? Transform384_AVX1 : _Transform384) ;
-     #endif
-#else
-     Transform384_p = ((IS_INTEL_AVX1) ? Transform384_AVX1 : _Transform384) ;
-#endif
-}
-
-#else
-   #define Transform384(sha512) _Transform384(sha512)
-#endif
-
-int wc_InitSha384(Sha384* sha384)
-{
-    sha384->digest[0] = W64LIT(0xcbbb9d5dc1059ed8);
-    sha384->digest[1] = W64LIT(0x629a292a367cd507);
-    sha384->digest[2] = W64LIT(0x9159015a3070dd17);
-    sha384->digest[3] = W64LIT(0x152fecd8f70e5939);
-    sha384->digest[4] = W64LIT(0x67332667ffc00b31);
-    sha384->digest[5] = W64LIT(0x8eb44a8768581511);
-    sha384->digest[6] = W64LIT(0xdb0c2e0d64f98fa7);
-    sha384->digest[7] = W64LIT(0x47b5481dbefa4fa4);
-
-    sha384->buffLen = 0;
-    sha384->loLen   = 0;
-    sha384->hiLen   = 0;
-
-#if defined(HAVE_INTEL_AVX1)|| defined(HAVE_INTEL_AVX2)
-    set_Transform384() ;
-#endif
-    
-    return 0;
-}
-
-static int _Transform384(Sha384* sha384)
-{
-    const word64* K = K512;
-
-    word32 j;
-    word64 T[8];
-
-#ifdef WOLFSSL_SMALL_STACK
-    word64* W;
-
-    W = (word64*) XMALLOC(sizeof(word64) * 16, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (W == NULL)
-        return MEMORY_E;
-#else
-    word64 W[16];
-#endif
-
-    /* Copy digest to working vars */
-    XMEMCPY(T, sha384->digest, sizeof(T));
-
-#ifdef USE_SLOW_SHA2
-    /* over twice as small, but 50% slower */
-    /* 80 operations, not unrolled */
-    for (j = 0; j < 80; j += 16) {
-        int m;
-        for (m = 0; m < 16; m++) {  /* braces needed for macros {} */
-            R2(m);
-        }
-    }
-#else
-    /* 80 operations, partially loop unrolled */
-    for (j = 0; j < 80; j += 16) {
-        R2( 0); R2( 1); R2( 2); R2( 3);
-        R2( 4); R2( 5); R2( 6); R2( 7);
-        R2( 8); R2( 9); R2(10); R2(11);
-        R2(12); R2(13); R2(14); R2(15);
-    }
-#endif /* USE_SLOW_SHA2 */
-
-    /* Add the working vars back into digest */
-
-    sha384->digest[0] += a(0);
-    sha384->digest[1] += b(0);
-    sha384->digest[2] += c(0);
-    sha384->digest[3] += d(0);
-    sha384->digest[4] += e(0);
-    sha384->digest[5] += f(0);
-    sha384->digest[6] += g(0);
-    sha384->digest[7] += h(0);
-
-    /* Wipe variables */
-    XMEMSET(W, 0, sizeof(word64) * 16);
-    XMEMSET(T, 0, sizeof(T));
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(W, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return 0;
-}
-
-static INLINE void AddLength384(Sha384* sha384, word32 len)
-{
-    word32 tmp = sha384->loLen;
-    if ( (sha384->loLen += len) < tmp)
-        sha384->hiLen++;                       /* carry low to high */
-}
-
-int wc_Sha384Update(Sha384* sha384, const byte* data, word32 len)
-{
-    /* do block size increments */
-    byte* local = (byte*)sha384->buffer;
-	
-    SAVE_XMM_YMM ; /* for Intel AVX */
-    
-    while (len) {
-        word32 add = min(len, SHA384_BLOCK_SIZE - sha384->buffLen);
-        XMEMCPY(&local[sha384->buffLen], data, add);
-
-        sha384->buffLen += add;
-        data         += add;
-        len          -= add;
-
-        if (sha384->buffLen == SHA384_BLOCK_SIZE) {
-            int ret;
-
-            #if defined(LITTLE_ENDIAN_ORDER)
-                #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-                if(!IS_INTEL_AVX1 && !IS_INTEL_AVX2) 
-                #endif
-                    ByteReverseWords64(sha384->buffer, sha384->buffer,
-                                   SHA384_BLOCK_SIZE);
-            #endif
-            ret = Transform384(sha384);
-            if (ret != 0)
-                return ret;
-
-            AddLength384(sha384, SHA384_BLOCK_SIZE);
-            sha384->buffLen = 0;
-        }
-    }
-    return 0;
-}
-
-
-int wc_Sha384Final(Sha384* sha384, byte* hash)
-{
-    byte* local = (byte*)sha384->buffer;
-    int ret;
-
-    SAVE_XMM_YMM ; /* for Intel AVX */
-    AddLength384(sha384, sha384->buffLen);              /* before adding pads */
-
-    local[sha384->buffLen++] = 0x80;  /* add 1 */
-
-    /* pad with zeros */
-    if (sha384->buffLen > SHA384_PAD_SIZE) {
-        XMEMSET(&local[sha384->buffLen], 0, SHA384_BLOCK_SIZE -sha384->buffLen);
-        sha384->buffLen += SHA384_BLOCK_SIZE - sha384->buffLen;
-
-        #if defined(LITTLE_ENDIAN_ORDER)
-            #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-            if(!IS_INTEL_AVX1 && !IS_INTEL_AVX2) 
-            #endif
-                 ByteReverseWords64(sha384->buffer, sha384->buffer,
-                               SHA384_BLOCK_SIZE);
-        #endif
-        ret = Transform384(sha384);
-        if (ret !=  0)
-            return ret;
-
-        sha384->buffLen = 0;
-    }
-    XMEMSET(&local[sha384->buffLen], 0, SHA384_PAD_SIZE - sha384->buffLen);
-   
-    /* put lengths in bits */
-    sha384->hiLen = (sha384->loLen >> (8*sizeof(sha384->loLen) - 3)) + 
-                 (sha384->hiLen << 3);
-    sha384->loLen = sha384->loLen << 3;
-
-    /* store lengths */
-    #if defined(LITTLE_ENDIAN_ORDER)
-        #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-        if(!IS_INTEL_AVX1 && !IS_INTEL_AVX2) 
-        #endif
-             ByteReverseWords64(sha384->buffer, sha384->buffer,
-                           SHA384_BLOCK_SIZE);
-    #endif
-    /* ! length ordering dependent on digest endian type ! */
-    sha384->buffer[SHA384_BLOCK_SIZE / sizeof(word64) - 2] = sha384->hiLen;
-    sha384->buffer[SHA384_BLOCK_SIZE / sizeof(word64) - 1] = sha384->loLen;
-    #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
-    if(IS_INTEL_AVX1 || IS_INTEL_AVX2)
-        ByteReverseWords64(&(sha384->buffer[SHA384_BLOCK_SIZE / sizeof(word64) - 2]),
-                           &(sha384->buffer[SHA384_BLOCK_SIZE / sizeof(word64) - 2]),
-                           SHA384_BLOCK_SIZE - SHA384_PAD_SIZE);
-    #endif
-    ret = Transform384(sha384);
-    if (ret != 0)
-        return ret;
-
-    #ifdef LITTLE_ENDIAN_ORDER
-        ByteReverseWords64(sha384->digest, sha384->digest, SHA384_DIGEST_SIZE);
-    #endif
-    XMEMCPY(hash, sha384->digest, SHA384_DIGEST_SIZE);
-
-    return wc_InitSha384(sha384);  /* reset state */
-}
-
-
-int wc_Sha384Hash(const byte* data, word32 len, byte* hash)
-{
-    int ret = 0;
-#ifdef WOLFSSL_SMALL_STACK
-    Sha384* sha384;
-#else
-    Sha384 sha384[1];
-#endif
-
-#ifdef WOLFSSL_SMALL_STACK
-    sha384 = (Sha384*)XMALLOC(sizeof(Sha384), NULL, DYNAMIC_TYPE_TMP_BUFFER);
-    if (sha384 == NULL)
-        return MEMORY_E;
-#endif
-
-    if ((ret = wc_InitSha384(sha384)) != 0) {
-        WOLFSSL_MSG("InitSha384 failed");
-    }
-    else if ((ret = wc_Sha384Update(sha384, data, len)) != 0) {
-        WOLFSSL_MSG("Sha384Update failed");
-    }
-    else if ((ret = wc_Sha384Final(sha384, hash)) != 0) {
-        WOLFSSL_MSG("Sha384Final failed");
-    }
-
-#ifdef WOLFSSL_SMALL_STACK
-    XFREE(sha384, NULL, DYNAMIC_TYPE_TMP_BUFFER);
-#endif
-
-    return ret;
-}
-
-#if defined(HAVE_INTEL_AVX1)
- 
-static int Transform384_AVX1(Sha384* sha384)
-{
-    const word64* K = K512;
-    word64 W_X[16+4];
-    word32 j;
-    word64 T[8];
-
-    /* Copy digest to working vars */
-    XMEMCPY(T, sha384->digest, sizeof(T));
-    W_from_buff(W_X, sha384->buffer) ;
-    for (j = 0; j < 80; j += 16) {
-        Rx_1( 0); Block_0_1(W_X); Rx_2( 0); Block_0_2(W_X); Rx_3( 0); Block_0_3(); 
-        Rx_1( 1); Block_0_4(); Rx_2( 1); Block_0_5(); Rx_3( 1); Block_0_6(W_X); 
-        Rx_1( 2); Block_0_7(W_X); Rx_2( 2); Block_0_8(W_X); Rx_3( 2); Block_0_9();
-        Rx_1( 3); Block_0_10();Rx_2( 3); Block_0_11();Rx_3( 3); Block_0_12(W_X);   
-        
-        Rx_1( 4); Block_4_1(W_X); Rx_2( 4); Block_4_2(W_X); Rx_3( 4); Block_4_3(); 
-        Rx_1( 5); Block_4_4(); Rx_2( 5); Block_4_5(); Rx_3( 5); Block_4_6(W_X); 
-        Rx_1( 6); Block_4_7(W_X); Rx_2( 6); Block_4_8(W_X); Rx_3( 6); Block_4_9();
-        Rx_1( 7); Block_4_10();Rx_2( 7); Block_4_11();Rx_3( 7); Block_4_12(W_X);   
-        
-        Rx_1( 8); Block_8_1(W_X); Rx_2( 8); Block_8_2(W_X); Rx_3( 8); Block_8_3(); 
-        Rx_1( 9); Block_8_4(); Rx_2( 9); Block_8_5(); Rx_3( 9); Block_8_6(W_X); 
-        Rx_1(10); Block_8_7(W_X); Rx_2(10); Block_8_8(W_X); Rx_3(10); Block_8_9();
-        Rx_1(11); Block_8_10();Rx_2(11); Block_8_11();Rx_3(11); Block_8_12(W_X);   
-        
-        Rx_1(12); Block_12_1(W_X); Rx_2(12); Block_12_2(W_X); Rx_3(12); Block_12_3(); 
-        Rx_1(13); Block_12_4(); Rx_2(13); Block_12_5(); Rx_3(13); Block_12_6(W_X); 
-        Rx_1(14); Block_12_7(W_X); Rx_2(14); Block_12_8(W_X); Rx_3(14); Block_12_9();
-        Rx_1(15); Block_12_10();Rx_2(15); Block_12_11();Rx_3(15); Block_12_12(W_X);     
-    }
-
-    /* Add the working vars back into digest */
-
-    sha384->digest[0] += a(0);
-    sha384->digest[1] += b(0);
-    sha384->digest[2] += c(0);
-    sha384->digest[3] += d(0);
-    sha384->digest[4] += e(0);
-    sha384->digest[5] += f(0);
-    sha384->digest[6] += g(0);
-    sha384->digest[7] += h(0);
-
-    /* Wipe variables */
-    #if !defined(HAVE_INTEL_AVX1)&&!defined(HAVE_INTEL_AVX2)
-    XMEMSET(W, 0, sizeof(word64) * 16);
-    #endif
-    XMEMSET(T, 0, sizeof(T));
-
-    return 0;
-}
-
-#endif
-
-#if defined(HAVE_INTEL_AVX1) && defined(HAVE_INTEL_AVX2) && defined(HAVE_INTEL_RORX)
-static int Transform384_AVX1_RORX(Sha384* sha384)
-{
-    const word64* K = K512;
-    word64 W_X[16+4];
-    word32 j;
-    word64 T[8];
-
-    /* Copy digest to working vars */
-    XMEMCPY(T, sha384->digest, sizeof(T));
-
-    W_from_buff(W_X, sha384->buffer) ;
-    for (j = 0; j < 80; j += 16) {
-        Rx_RORX_1( 0); Block_0_1(W_X); Rx_RORX_2( 0); 
-            Block_0_2(W_X); Rx_RORX_3( 0); Block_0_3(); 
-        Rx_RORX_1( 1); Block_0_4(); Rx_RORX_2( 1); 
-            Block_0_5(); Rx_RORX_3( 1); Block_0_6(W_X); 
-        Rx_RORX_1( 2); Block_0_7(W_X); Rx_RORX_2( 2); 
-            Block_0_8(W_X); Rx_RORX_3( 2); Block_0_9();
-        Rx_RORX_1( 3); Block_0_10();Rx_RORX_2( 3); 
-            Block_0_11();Rx_RORX_3( 3); Block_0_12(W_X);   
-        
-        Rx_RORX_1( 4); Block_4_1(W_X); Rx_RORX_2( 4); 
-            Block_4_2(W_X); Rx_RORX_3( 4); Block_4_3(); 
-        Rx_RORX_1( 5); Block_4_4(); Rx_RORX_2( 5); 
-            Block_4_5(); Rx_RORX_3( 5); Block_4_6(W_X); 
-        Rx_RORX_1( 6); Block_4_7(W_X); Rx_RORX_2( 6); 
-            Block_4_8(W_X); Rx_RORX_3( 6); Block_4_9();
-        Rx_RORX_1( 7); Block_4_10();Rx_RORX_2( 7); 
-            Block_4_11();Rx_RORX_3( 7); Block_4_12(W_X);   
-        
-        Rx_RORX_1( 8); Block_8_1(W_X); Rx_RORX_2( 8); 
-            Block_8_2(W_X); Rx_RORX_3( 8); Block_8_3(); 
-        Rx_RORX_1( 9); Block_8_4(); Rx_RORX_2( 9); 
-            Block_8_5(); Rx_RORX_3( 9); Block_8_6(W_X); 
-        Rx_RORX_1(10); Block_8_7(W_X); Rx_RORX_2(10); 
-            Block_8_8(W_X); Rx_RORX_3(10); Block_8_9();
-        Rx_RORX_1(11); Block_8_10();Rx_RORX_2(11); 
-            Block_8_11();Rx_RORX_3(11); Block_8_12(W_X);   
-        
-        Rx_RORX_1(12); Block_12_1(W_X); Rx_RORX_2(12);
-            Block_12_2(W_X); Rx_RORX_3(12); Block_12_3(); 
-        Rx_RORX_1(13); Block_12_4(); Rx_RORX_2(13); 
-            Block_12_5(); Rx_RORX_3(13); Block_12_6(W_X); 
-        Rx_RORX_1(14); Block_12_7(W_X); Rx_RORX_2(14); 
-            Block_12_8(W_X); Rx_RORX_3(14); Block_12_9();
-        Rx_RORX_1(15); Block_12_10();Rx_RORX_2(15); 
-            Block_12_11();Rx_RORX_3(15); Block_12_12(W_X);     
-    }
-
-    /* Add the working vars back into digest */
-
-    sha384->digest[0] += a(0);
-    sha384->digest[1] += b(0);
-    sha384->digest[2] += c(0);
-    sha384->digest[3] += d(0);
-    sha384->digest[4] += e(0);
-    sha384->digest[5] += f(0);
-    sha384->digest[6] += g(0);
-    sha384->digest[7] += h(0);
-
-    /* Wipe variables */
-    #if !defined(HAVE_INTEL_AVX1)&&!defined(HAVE_INTEL_AVX2)
-    XMEMSET(W, 0, sizeof(word64) * 16);
-    #endif
-    XMEMSET(T, 0, sizeof(T));
-
-    return 0;
-}
-#endif
-
-#if defined(HAVE_INTEL_AVX2)
-
-static int Transform384_AVX2(Sha384* sha384)
-{
-    const word64* K = K512;
-    word64 w[4] ;
-    word32 j;
-    word64 T[8];
-
-    /* Copy digest to working vars */
-    XMEMCPY(T, sha384->digest, sizeof(T));
-
-    /* over twice as small, but 50% slower */
-    /* 80 operations, not unrolled */
-
-    W_from_buff_Y(sha384->buffer) ;
-
-    MOVE_to_MEMy(w,0, W_0y) ;
-    for (j = 0; j < 80; j += 16) {
-        Ry_1( 0, w[0]); Block_Y_0_1(); Ry_2( 0, w[0]); 
-            Block_Y_0_2(); Ry_3( 0, w[0]); Block_Y_0_3(); 
-        Ry_1( 1, w[1]); Block_Y_0_4(); Ry_2( 1, w[1]); 
-            Block_Y_0_5(); Ry_3( 1, w[1]); Block_Y_0_6();  
-        Ry_1( 2, w[2]); Block_Y_0_7(); Ry_2( 2, w[2]); 
-            Block_Y_0_8(); Ry_3( 2, w[2]); Block_Y_0_9();
-        Ry_1( 3, w[3]); Block_Y_0_10();Ry_2( 3, w[3]); 
-            Block_Y_0_11();Ry_3( 3, w[3]); Block_Y_0_12(w);
-        
-        Ry_1( 4, w[0]); Block_Y_4_1(); Ry_2( 4, w[0]); 
-            Block_Y_4_2(); Ry_3( 4, w[0]); Block_Y_4_3(); 
-        Ry_1( 5, w[1]); Block_Y_4_4(); Ry_2( 5, w[1]);   
-            Block_Y_4_5(); Ry_3( 5, w[1]); Block_Y_4_6();
-        Ry_1( 6, w[2]); Block_Y_4_7(); Ry_2( 6, w[2]); 
-            Block_Y_4_8(); Ry_3( 6, w[2]); Block_Y_4_9();
-        Ry_1( 7, w[3]); Block_Y_4_10(); Ry_2( 7, w[3]);
-            Block_Y_4_11(); Ry_3( 7, w[3]);Block_Y_4_12(w);  
-        
-        Ry_1( 8, w[0]); Block_Y_8_1(); Ry_2( 8, w[0]); 
-            Block_Y_8_2(); Ry_3( 8, w[0]); Block_Y_8_3();
-        Ry_1( 9, w[1]); Block_Y_8_4(); Ry_2( 9, w[1]);
-            Block_Y_8_5(); Ry_3( 9, w[1]); Block_Y_8_6();
-        Ry_1(10, w[2]); Block_Y_8_7(); Ry_2(10, w[2]); 
-            Block_Y_8_8(); Ry_3(10, w[2]); Block_Y_8_9(); 
-        Ry_1(11, w[3]); Block_Y_8_10();Ry_2(11, w[3]); 
-           Block_Y_8_11();Ry_3(11, w[3]); Block_Y_8_12(w);
-                 
-        Ry_1(12, w[0]); Block_Y_12_1(); Ry_2(12, w[0]); 
-            Block_Y_12_2(); Ry_3(12, w[0]); Block_Y_12_3();
-        Ry_1(13, w[1]); Block_Y_12_4(); Ry_2(13, w[1]); 
-            Block_Y_12_5(); Ry_3(13, w[1]); Block_Y_12_6(); 
-        Ry_1(14, w[2]); Block_Y_12_7(); Ry_2(14, w[2]); 
-            Block_Y_12_8(); Ry_3(14, w[2]); Block_Y_12_9();
-        Ry_1(15, w[3]); Block_Y_12_10();Ry_2(15, w[3]); 
-            Block_Y_12_11();Ry_3(15, w[3]); Block_Y_12_12(w);
-    }
-
-    /* Add the working vars back into digest */
-
-    sha384->digest[0] += a(0);
-    sha384->digest[1] += b(0);
-    sha384->digest[2] += c(0);
-    sha384->digest[3] += d(0);
-    sha384->digest[4] += e(0);
-    sha384->digest[5] += f(0);
-    sha384->digest[6] += g(0);
-    sha384->digest[7] += h(0);
-
-    /* Wipe variables */
-    XMEMSET(T, 0, sizeof(T));
-
-    return 0;
-}
-
-#endif
-
-#endif /* WOLFSSL_SHA384 */
-
-#endif /* HAVE_FIPS */
-
-#endif /* WOLFSSL_SHA512 */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/tfm.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/tfm.c
deleted file mode 100755
index 2c1e86c..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/tfm.c
+++ /dev/null
@@ -1,2701 +0,0 @@
-/* tfm.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-/*
- * Based on public domain TomsFastMath 0.10 by Tom St Denis, tomstdenis@iahu.ca,
- * http://math.libtomcrypt.com
- */
-
-/**
- *  Edited by Moisés Guimarães (moisesguimaraesm@gmail.com)
- *  to fit CyaSSL's needs.
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-/* in case user set USE_FAST_MATH there */
-#include 
-
-#ifdef USE_FAST_MATH
-
-#include 
-#include   /* will define asm MACROS or C ones */
-
-
-/* math settings check */
-word32 CheckRunTimeSettings(void)
-{
-    return CTC_SETTINGS;
-}
-
-
-/* math settings size check */
-word32 CheckRunTimeFastMath(void)
-{
-    return FP_SIZE;
-}
-
-
-/* Functions */
-
-void fp_add(fp_int *a, fp_int *b, fp_int *c)
-{
-  int     sa, sb;
-
-  /* get sign of both inputs */
-  sa = a->sign;
-  sb = b->sign;
-
-  /* handle two cases, not four */
-  if (sa == sb) {
-    /* both positive or both negative */
-    /* add their magnitudes, copy the sign */
-    c->sign = sa;
-    s_fp_add (a, b, c);
-  } else {
-    /* one positive, the other negative */
-    /* subtract the one with the greater magnitude from */
-    /* the one of the lesser magnitude.  The result gets */
-    /* the sign of the one with the greater magnitude. */
-    if (fp_cmp_mag (a, b) == FP_LT) {
-      c->sign = sb;
-      s_fp_sub (b, a, c);
-    } else {
-      c->sign = sa;
-      s_fp_sub (a, b, c);
-    }
-  }
-}
-
-/* unsigned addition */
-void s_fp_add(fp_int *a, fp_int *b, fp_int *c)
-{
-  int      x, y, oldused;
-  register fp_word  t;
-
-  y       = MAX(a->used, b->used);
-  oldused = MIN(c->used, FP_SIZE);   /* help static analysis w/ largest size */
-  c->used = y;
- 
-  t = 0;
-  for (x = 0; x < y; x++) {
-      t         += ((fp_word)a->dp[x]) + ((fp_word)b->dp[x]);
-      c->dp[x]   = (fp_digit)t;
-      t        >>= DIGIT_BIT;
-  }
-  if (t != 0 && x < FP_SIZE) {
-     c->dp[c->used++] = (fp_digit)t;
-     ++x;
-  }
-
-  c->used = x;
-  for (; x < oldused; x++) {
-     c->dp[x] = 0;
-  }
-  fp_clamp(c);
-}
-
-/* c = a - b */
-void fp_sub(fp_int *a, fp_int *b, fp_int *c)
-{
-  int     sa, sb;
-
-  sa = a->sign;
-  sb = b->sign;
-
-  if (sa != sb) {
-    /* subtract a negative from a positive, OR */
-    /* subtract a positive from a negative. */
-    /* In either case, ADD their magnitudes, */
-    /* and use the sign of the first number. */
-    c->sign = sa;
-    s_fp_add (a, b, c);
-  } else {
-    /* subtract a positive from a positive, OR */
-    /* subtract a negative from a negative. */
-    /* First, take the difference between their */
-    /* magnitudes, then... */
-    if (fp_cmp_mag (a, b) != FP_LT) {
-      /* Copy the sign from the first */
-      c->sign = sa;
-      /* The first has a larger or equal magnitude */
-      s_fp_sub (a, b, c);
-    } else {
-      /* The result has the *opposite* sign from */
-      /* the first number. */
-      c->sign = (sa == FP_ZPOS) ? FP_NEG : FP_ZPOS;
-      /* The second has a larger magnitude */
-      s_fp_sub (b, a, c);
-    }
-  }
-}
-
-/* unsigned subtraction ||a|| >= ||b|| ALWAYS! */
-void s_fp_sub(fp_int *a, fp_int *b, fp_int *c)
-{
-  int      x, oldbused, oldused;
-  fp_word  t;
-
-  oldused  = c->used;
-  oldbused = b->used;
-  c->used  = a->used;
-  t       = 0;
-  for (x = 0; x < oldbused; x++) {
-     t         = ((fp_word)a->dp[x]) - (((fp_word)b->dp[x]) + t);
-     c->dp[x]  = (fp_digit)t;
-     t         = (t >> DIGIT_BIT)&1;
-  }
-  for (; x < a->used; x++) {
-     t         = ((fp_word)a->dp[x]) - t;
-     c->dp[x]  = (fp_digit)t;
-     t         = (t >> DIGIT_BIT)&1;
-   }
-  for (; x < oldused; x++) {
-     c->dp[x] = 0;
-  }
-  fp_clamp(c);
-}
-
-/* c = a * b */
-void fp_mul(fp_int *A, fp_int *B, fp_int *C)
-{
-    int   y, yy;
-
-    y  = MAX(A->used, B->used);
-    yy = MIN(A->used, B->used);
-
-    /* call generic if we're out of range */
-    if (y + yy > FP_SIZE) {
-       fp_mul_comba(A, B, C);
-       return ;
-    }
-
-    /* pick a comba (unrolled 4/8/16/32 x or rolled) based on the size
-       of the largest input.  We also want to avoid doing excess mults if the 
-       inputs are not close to the next power of two.  That is, for example,
-       if say y=17 then we would do (32-17)^2 = 225 unneeded multiplications 
-    */
-
-#ifdef TFM_MUL3
-        if (y <= 3) {
-           fp_mul_comba3(A,B,C);
-           return;
-        }
-#endif
-#ifdef TFM_MUL4
-        if (y == 4) {
-           fp_mul_comba4(A,B,C);
-           return;
-        }
-#endif
-#ifdef TFM_MUL6
-        if (y <= 6) {
-           fp_mul_comba6(A,B,C);
-           return;
-        }
-#endif
-#ifdef TFM_MUL7
-        if (y == 7) {
-           fp_mul_comba7(A,B,C);
-           return;
-        }
-#endif
-#ifdef TFM_MUL8
-        if (y == 8) {
-           fp_mul_comba8(A,B,C);
-           return;
-        }
-#endif
-#ifdef TFM_MUL9
-        if (y == 9) {
-           fp_mul_comba9(A,B,C);
-           return;
-        }
-#endif
-#ifdef TFM_MUL12
-        if (y <= 12) {
-           fp_mul_comba12(A,B,C);
-           return;
-        }
-#endif
-#ifdef TFM_MUL17
-        if (y <= 17) {
-           fp_mul_comba17(A,B,C);
-           return;
-        }
-#endif
-
-#ifdef TFM_SMALL_SET
-        if (y <= 16) {
-           fp_mul_comba_small(A,B,C);
-           return;
-        }
-#endif        
-#if defined(TFM_MUL20)
-        if (y <= 20) {
-           fp_mul_comba20(A,B,C);
-           return;
-        }
-#endif
-#if defined(TFM_MUL24)
-        if (yy >= 16 && y <= 24) {
-           fp_mul_comba24(A,B,C);
-           return;
-        }
-#endif
-#if defined(TFM_MUL28)
-        if (yy >= 20 && y <= 28) {
-           fp_mul_comba28(A,B,C);
-           return;
-        }
-#endif
-#if defined(TFM_MUL32)
-        if (yy >= 24 && y <= 32) {
-           fp_mul_comba32(A,B,C);
-           return;
-        }
-#endif
-#if defined(TFM_MUL48)
-        if (yy >= 40 && y <= 48) {
-           fp_mul_comba48(A,B,C);
-           return;
-        }
-#endif        
-#if defined(TFM_MUL64)
-        if (yy >= 56 && y <= 64) {
-           fp_mul_comba64(A,B,C);
-           return;
-        }
-#endif
-        fp_mul_comba(A,B,C);
-}
-
-void fp_mul_2(fp_int * a, fp_int * b)
-{
-  int     x, oldused;
-   
-  oldused = b->used;
-  b->used = a->used;
-
-  {
-    register fp_digit r, rr, *tmpa, *tmpb;
-
-    /* alias for source */
-    tmpa = a->dp;
-    
-    /* alias for dest */
-    tmpb = b->dp;
-
-    /* carry */
-    r = 0;
-    for (x = 0; x < a->used; x++) {
-    
-      /* get what will be the *next* carry bit from the 
-       * MSB of the current digit 
-       */
-      rr = *tmpa >> ((fp_digit)(DIGIT_BIT - 1));
-      
-      /* now shift up this digit, add in the carry [from the previous] */
-      *tmpb++ = ((*tmpa++ << ((fp_digit)1)) | r);
-      
-      /* copy the carry that would be from the source 
-       * digit into the next iteration 
-       */
-      r = rr;
-    }
-
-    /* new leading digit? */
-    if (r != 0 && b->used != (FP_SIZE-1)) {
-      /* add a MSB which is always 1 at this point */
-      *tmpb = 1;
-      ++(b->used);
-    }
-
-    /* now zero any excess digits on the destination 
-     * that we didn't write to 
-     */
-    tmpb = b->dp + b->used;
-    for (x = b->used; x < oldused; x++) {
-      *tmpb++ = 0;
-    }
-  }
-  b->sign = a->sign;
-}
-
-/* c = a * b */
-void fp_mul_d(fp_int *a, fp_digit b, fp_int *c)
-{
-   fp_word  w;
-   int      x, oldused;
-
-   oldused = c->used;
-   c->used = a->used;
-   c->sign = a->sign;
-   w       = 0;
-   for (x = 0; x < a->used; x++) {
-       w         = ((fp_word)a->dp[x]) * ((fp_word)b) + w;
-       c->dp[x]  = (fp_digit)w;
-       w         = w >> DIGIT_BIT;
-   }
-   if (w != 0 && (a->used != FP_SIZE)) {
-      c->dp[c->used++] = (fp_digit) w;
-      ++x;
-   }
-   for (; x < oldused; x++) {
-      c->dp[x] = 0;
-   }
-   fp_clamp(c);
-}
-
-/* c = a * 2**d */
-void fp_mul_2d(fp_int *a, int b, fp_int *c)
-{
-   fp_digit carry, carrytmp, shift;
-   int x;
-
-   /* copy it */
-   fp_copy(a, c);
-
-   /* handle whole digits */
-   if (b >= DIGIT_BIT) {
-      fp_lshd(c, b/DIGIT_BIT);
-   }
-   b %= DIGIT_BIT;
-
-   /* shift the digits */
-   if (b != 0) {
-      carry = 0;   
-      shift = DIGIT_BIT - b;
-      for (x = 0; x < c->used; x++) {
-          carrytmp = c->dp[x] >> shift;
-          c->dp[x] = (c->dp[x] << b) + carry;
-          carry = carrytmp;
-      }
-      /* store last carry if room */
-      if (carry && x < FP_SIZE) {
-         c->dp[c->used++] = carry;
-      }
-   }
-   fp_clamp(c);
-}
-
-/* generic PxQ multiplier */
-#if defined(HAVE_INTEL_MULX)
-
-INLINE static void fp_mul_comba_mulx(fp_int *A, fp_int *B, fp_int *C)
-
-{     
-   int       ix, iy, iz, pa;
-   fp_int    tmp, *dst;
-
-   /* get size of output and trim */
-   pa = A->used + B->used;
-   if (pa >= FP_SIZE) {
-      pa = FP_SIZE-1;
-   }
- 
-   if (A == C || B == C) {
-      fp_init(&tmp);
-      dst = &tmp;
-   } else {
-      fp_zero(C);
-      dst = C;
-   }
-
-   TFM_INTEL_MUL_COMBA(A, B, dst) ;
-
-  dst->used = pa;
-  dst->sign = A->sign ^ B->sign;
-  fp_clamp(dst);
-  fp_copy(dst, C);  
-}
-#endif
-
-void fp_mul_comba(fp_int *A, fp_int *B, fp_int *C)
-{
-   int       ix, iy, iz, tx, ty, pa;
-   fp_digit  c0, c1, c2, *tmpx, *tmpy;
-   fp_int    tmp, *dst;
-
-   IF_HAVE_INTEL_MULX(fp_mul_comba_mulx(A, B, C), return) ;
-
-   COMBA_START;
-   COMBA_CLEAR;
-   
-   /* get size of output and trim */
-   pa = A->used + B->used;
-   if (pa >= FP_SIZE) {
-      pa = FP_SIZE-1;
-   }
-
-   if (A == C || B == C) {
-      fp_init(&tmp);
-      dst = &tmp;
-   } else {
-      fp_zero(C);
-      dst = C;
-   }
-
-   for (ix = 0; ix < pa; ix++) {
-      /* get offsets into the two bignums */
-      ty = MIN(ix, B->used-1);
-      tx = ix - ty;
-
-      /* setup temp aliases */
-      tmpx = A->dp + tx;
-      tmpy = B->dp + ty;
-
-      /* this is the number of times the loop will iterrate, essentially its 
-         while (tx++ < a->used && ty-- >= 0) { ... }
-       */
-      iy = MIN(A->used-tx, ty+1);
-
-      /* execute loop */
-      COMBA_FORWARD;
-      for (iz = 0; iz < iy; ++iz) {
-          /* TAO change COMBA_ADD back to MULADD */
-          MULADD(*tmpx++, *tmpy--);
-      }
-
-      /* store term */
-      COMBA_STORE(dst->dp[ix]);
-  }
-  COMBA_FINI;
-
-  dst->used = pa;
-  dst->sign = A->sign ^ B->sign;
-  fp_clamp(dst);
-  fp_copy(dst, C);
-}
-
-/* a/b => cb + d == a */
-int fp_div(fp_int *a, fp_int *b, fp_int *c, fp_int *d)
-{
-  fp_int  q, x, y, t1, t2;
-  int     n, t, i, norm, neg;
-
-  /* is divisor zero ? */
-  if (fp_iszero (b) == 1) {
-    return FP_VAL;
-  }
-
-  /* if a < b then q=0, r = a */
-  if (fp_cmp_mag (a, b) == FP_LT) {
-    if (d != NULL) {
-      fp_copy (a, d);
-    } 
-    if (c != NULL) {
-      fp_zero (c);
-    }
-    return FP_OKAY;
-  }
-
-  fp_init(&q);
-  q.used = a->used + 2;
-
-  fp_init(&t1);
-  fp_init(&t2);
-  fp_init_copy(&x, a);
-  fp_init_copy(&y, b);
-
-  /* fix the sign */
-  neg = (a->sign == b->sign) ? FP_ZPOS : FP_NEG;
-  x.sign = y.sign = FP_ZPOS;
-
-  /* normalize both x and y, ensure that y >= b/2, [b == 2**DIGIT_BIT] */
-  norm = fp_count_bits(&y) % DIGIT_BIT;
-  if (norm < (int)(DIGIT_BIT-1)) {
-     norm = (DIGIT_BIT-1) - norm;
-     fp_mul_2d (&x, norm, &x);
-     fp_mul_2d (&y, norm, &y);
-  } else {
-     norm = 0;
-  }
-
-  /* note hac does 0 based, so if used==5 then its 0,1,2,3,4, e.g. use 4 */
-  n = x.used - 1;
-  t = y.used - 1;
-
-  /* while (x >= y*b**n-t) do { q[n-t] += 1; x -= y*b**{n-t} } */
-  fp_lshd (&y, n - t);                                             /* y = y*b**{n-t} */
-
-  while (fp_cmp (&x, &y) != FP_LT) {
-    ++(q.dp[n - t]);
-    fp_sub (&x, &y, &x);
-  }
-
-  /* reset y by shifting it back down */
-  fp_rshd (&y, n - t);
-
-  /* step 3. for i from n down to (t + 1) */
-  for (i = n; i >= (t + 1); i--) {
-    if (i > x.used) {
-      continue;
-    }
-
-    /* step 3.1 if xi == yt then set q{i-t-1} to b-1, 
-     * otherwise set q{i-t-1} to (xi*b + x{i-1})/yt */
-    if (x.dp[i] == y.dp[t]) {
-      q.dp[i - t - 1] = (fp_digit) ((((fp_word)1) << DIGIT_BIT) - 1);
-    } else {
-      fp_word tmp;
-      tmp = ((fp_word) x.dp[i]) << ((fp_word) DIGIT_BIT);
-      tmp |= ((fp_word) x.dp[i - 1]);
-      tmp /= ((fp_word)y.dp[t]);
-      q.dp[i - t - 1] = (fp_digit) (tmp);
-    }
-
-    /* while (q{i-t-1} * (yt * b + y{t-1})) > 
-             xi * b**2 + xi-1 * b + xi-2 
-     
-       do q{i-t-1} -= 1; 
-    */
-    q.dp[i - t - 1] = (q.dp[i - t - 1] + 1);
-    do {
-      q.dp[i - t - 1] = (q.dp[i - t - 1] - 1);
-
-      /* find left hand */
-      fp_zero (&t1);
-      t1.dp[0] = (t - 1 < 0) ? 0 : y.dp[t - 1];
-      t1.dp[1] = y.dp[t];
-      t1.used = 2;
-      fp_mul_d (&t1, q.dp[i - t - 1], &t1);
-
-      /* find right hand */
-      t2.dp[0] = (i - 2 < 0) ? 0 : x.dp[i - 2];
-      t2.dp[1] = (i - 1 < 0) ? 0 : x.dp[i - 1];
-      t2.dp[2] = x.dp[i];
-      t2.used = 3;
-    } while (fp_cmp_mag(&t1, &t2) == FP_GT);
-
-    /* step 3.3 x = x - q{i-t-1} * y * b**{i-t-1} */
-    fp_mul_d (&y, q.dp[i - t - 1], &t1);
-    fp_lshd  (&t1, i - t - 1);
-    fp_sub   (&x, &t1, &x);
-
-    /* if x < 0 then { x = x + y*b**{i-t-1}; q{i-t-1} -= 1; } */
-    if (x.sign == FP_NEG) {
-      fp_copy (&y, &t1);
-      fp_lshd (&t1, i - t - 1);
-      fp_add (&x, &t1, &x);
-      q.dp[i - t - 1] = q.dp[i - t - 1] - 1;
-    }
-  }
-
-  /* now q is the quotient and x is the remainder 
-   * [which we have to normalize] 
-   */
-  
-  /* get sign before writing to c */
-  x.sign = x.used == 0 ? FP_ZPOS : a->sign;
-
-  if (c != NULL) {
-    fp_clamp (&q);
-    fp_copy (&q, c);
-    c->sign = neg;
-  }
-
-  if (d != NULL) {
-    fp_div_2d (&x, norm, &x, NULL);
-
-/* the following is a kludge, essentially we were seeing the right remainder but 
-   with excess digits that should have been zero
- */
-    for (i = b->used; i < x.used; i++) {
-        x.dp[i] = 0;
-    }
-    fp_clamp(&x);
-    fp_copy (&x, d);
-  }
-
-  return FP_OKAY;
-}
-
-/* b = a/2 */
-void fp_div_2(fp_int * a, fp_int * b)
-{
-  int     x, oldused;
-
-  oldused = b->used;
-  b->used = a->used;
-  {
-    register fp_digit r, rr, *tmpa, *tmpb;
-
-    /* source alias */
-    tmpa = a->dp + b->used - 1;
-
-    /* dest alias */
-    tmpb = b->dp + b->used - 1;
-
-    /* carry */
-    r = 0;
-    for (x = b->used - 1; x >= 0; x--) {
-      /* get the carry for the next iteration */
-      rr = *tmpa & 1;
-
-      /* shift the current digit, add in carry and store */
-      *tmpb-- = (*tmpa-- >> 1) | (r << (DIGIT_BIT - 1));
-
-      /* forward carry to next iteration */
-      r = rr;
-    }
-
-    /* zero excess digits */
-    tmpb = b->dp + b->used;
-    for (x = b->used; x < oldused; x++) {
-      *tmpb++ = 0;
-    }
-  }
-  b->sign = a->sign;
-  fp_clamp (b);
-}
-
-/* c = a / 2**b */
-void fp_div_2d(fp_int *a, int b, fp_int *c, fp_int *d)
-{
-  int      D;
-  fp_int   t;
-
-  /* if the shift count is <= 0 then we do no work */
-  if (b <= 0) {
-    fp_copy (a, c);
-    if (d != NULL) {
-      fp_zero (d);
-    }
-    return;
-  }
-
-  fp_init(&t);
-
-  /* get the remainder */
-  if (d != NULL) {
-    fp_mod_2d (a, b, &t);
-  }
-
-  /* copy */
-  fp_copy(a, c);
-
-  /* shift by as many digits in the bit count */
-  if (b >= (int)DIGIT_BIT) {
-    fp_rshd (c, b / DIGIT_BIT);
-  }
-
-  /* shift any bit count < DIGIT_BIT */
-  D = (b % DIGIT_BIT);
-  if (D != 0) {
-    fp_rshb(c, D);
-  }
-  fp_clamp (c);
-  if (d != NULL) {
-    fp_copy (&t, d);
-  }
-}
-
-/* c = a mod b, 0 <= c < b  */
-int fp_mod(fp_int *a, fp_int *b, fp_int *c)
-{
-   fp_int t;
-   int    err;
-
-   fp_init(&t);
-   if ((err = fp_div(a, b, NULL, &t)) != FP_OKAY) {
-      return err;
-   }
-   if (t.sign != b->sign) {
-      fp_add(&t, b, c);
-   } else {
-      fp_copy(&t, c);
-  }
-  return FP_OKAY;
-}
-
-/* c = a mod 2**d */
-void fp_mod_2d(fp_int *a, int b, fp_int *c)
-{
-   int x;
-
-   /* zero if count less than or equal to zero */
-   if (b <= 0) {
-      fp_zero(c);
-      return;
-   }
-
-   /* get copy of input */
-   fp_copy(a, c);
- 
-   /* if 2**d is larger than we just return */
-   if (b >= (DIGIT_BIT * a->used)) {
-      return;
-   }
-
-  /* zero digits above the last digit of the modulus */
-  for (x = (b / DIGIT_BIT) + ((b % DIGIT_BIT) == 0 ? 0 : 1); x < c->used; x++) {
-    c->dp[x] = 0;
-  }
-  /* clear the digit that is not completely outside/inside the modulus */
-  c->dp[b / DIGIT_BIT] &= ~((fp_digit)0) >> (DIGIT_BIT - b);
-  fp_clamp (c);
-}
-
-static int fp_invmod_slow (fp_int * a, fp_int * b, fp_int * c)
-{
-  fp_int  x, y, u, v, A, B, C, D;
-  int     res;
-
-  /* b cannot be negative */
-  if (b->sign == FP_NEG || fp_iszero(b) == 1) {
-    return FP_VAL;
-  }
-
-  /* init temps */
-  fp_init(&x);    fp_init(&y);
-  fp_init(&u);    fp_init(&v);
-  fp_init(&A);    fp_init(&B);
-  fp_init(&C);    fp_init(&D);
-
-  /* x = a, y = b */
-  if ((res = fp_mod(a, b, &x)) != FP_OKAY) {
-      return res;
-  }
-  fp_copy(b, &y);
-
-  /* 2. [modified] if x,y are both even then return an error! */
-  if (fp_iseven (&x) == 1 && fp_iseven (&y) == 1) {
-    return FP_VAL;
-  }
-
-  /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */
-  fp_copy (&x, &u);
-  fp_copy (&y, &v);
-  fp_set (&A, 1);
-  fp_set (&D, 1);
-
-top:
-  /* 4.  while u is even do */
-  while (fp_iseven (&u) == 1) {
-    /* 4.1 u = u/2 */
-    fp_div_2 (&u, &u);
-
-    /* 4.2 if A or B is odd then */
-    if (fp_isodd (&A) == 1 || fp_isodd (&B) == 1) {
-      /* A = (A+y)/2, B = (B-x)/2 */
-      fp_add (&A, &y, &A);
-      fp_sub (&B, &x, &B);
-    }
-    /* A = A/2, B = B/2 */
-    fp_div_2 (&A, &A);
-    fp_div_2 (&B, &B);
-  }
-
-  /* 5.  while v is even do */
-  while (fp_iseven (&v) == 1) {
-    /* 5.1 v = v/2 */
-    fp_div_2 (&v, &v);
-
-    /* 5.2 if C or D is odd then */
-    if (fp_isodd (&C) == 1 || fp_isodd (&D) == 1) {
-      /* C = (C+y)/2, D = (D-x)/2 */
-      fp_add (&C, &y, &C);
-      fp_sub (&D, &x, &D);
-    }
-    /* C = C/2, D = D/2 */
-    fp_div_2 (&C, &C);
-    fp_div_2 (&D, &D);
-  }
-
-  /* 6.  if u >= v then */
-  if (fp_cmp (&u, &v) != FP_LT) {
-    /* u = u - v, A = A - C, B = B - D */
-    fp_sub (&u, &v, &u);
-    fp_sub (&A, &C, &A);
-    fp_sub (&B, &D, &B);
-  } else {
-    /* v - v - u, C = C - A, D = D - B */
-    fp_sub (&v, &u, &v);
-    fp_sub (&C, &A, &C);
-    fp_sub (&D, &B, &D);
-  }
-
-  /* if not zero goto step 4 */
-  if (fp_iszero (&u) == 0)
-    goto top;
-
-  /* now a = C, b = D, gcd == g*v */
-
-  /* if v != 1 then there is no inverse */
-  if (fp_cmp_d (&v, 1) != FP_EQ) {
-    return FP_VAL;
-  }
-
-  /* if its too low */
-  while (fp_cmp_d(&C, 0) == FP_LT) {
-      fp_add(&C, b, &C);
-  }
-  
-  /* too big */
-  while (fp_cmp_mag(&C, b) != FP_LT) {
-      fp_sub(&C, b, &C);
-  }
-  
-  /* C is now the inverse */
-  fp_copy(&C, c);
-  return FP_OKAY;
-}
-
-
-/* c = 1/a (mod b) for odd b only */
-int fp_invmod(fp_int *a, fp_int *b, fp_int *c)
-{
-  fp_int  x, y, u, v, B, D;
-  int     neg, loop_check = 0;
-
-  /* 2. [modified] b must be odd   */
-  if (fp_iseven (b) == FP_YES) {
-    return fp_invmod_slow(a,b,c);
-  }
-
-  /* init all our temps */
-  fp_init(&x);  fp_init(&y);
-  fp_init(&u);  fp_init(&v);
-  fp_init(&B);  fp_init(&D);
-
-  /* x == modulus, y == value to invert */
-  fp_copy(b, &x);
-
-  /* we need y = |a| */
-  fp_abs(a, &y);
-
-  /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */
-  fp_copy(&x, &u);
-  fp_copy(&y, &v);
-  fp_set (&D, 1);
-
-top:
-  /* 4.  while u is even do */
-  while (fp_iseven (&u) == FP_YES) {
-    /* 4.1 u = u/2 */
-    fp_div_2 (&u, &u);
-
-    /* 4.2 if B is odd then */
-    if (fp_isodd (&B) == FP_YES) {
-      fp_sub (&B, &x, &B);
-    }
-    /* B = B/2 */
-    fp_div_2 (&B, &B);
-  }
-
-  /* 5.  while v is even do */
-  while (fp_iseven (&v) == FP_YES) {
-    /* 5.1 v = v/2 */
-    fp_div_2 (&v, &v);
-
-    /* 5.2 if D is odd then */
-    if (fp_isodd (&D) == FP_YES) {
-      /* D = (D-x)/2 */
-      fp_sub (&D, &x, &D);
-    }
-    /* D = D/2 */
-    fp_div_2 (&D, &D);
-  }
-
-  /* 6.  if u >= v then */
-  if (fp_cmp (&u, &v) != FP_LT) {
-    /* u = u - v, B = B - D */
-    fp_sub (&u, &v, &u);
-    fp_sub (&B, &D, &B);
-  } else {
-    /* v - v - u, D = D - B */
-    fp_sub (&v, &u, &v);
-    fp_sub (&D, &B, &D);
-  }
-
-  /* if not zero goto step 4 */
-  if (fp_iszero (&u) == FP_NO) {
-    if (++loop_check > 1024) /* bad input */
-      return FP_VAL;
-    goto top;
-  }
-
-  /* now a = C, b = D, gcd == g*v */
-
-  /* if v != 1 then there is no inverse */
-  if (fp_cmp_d (&v, 1) != FP_EQ) {
-    return FP_VAL;
-  }
-
-  /* b is now the inverse */
-  neg = a->sign;
-  while (D.sign == FP_NEG) {
-    fp_add (&D, b, &D);
-  }
-  fp_copy (&D, c);
-  c->sign = neg;
-  return FP_OKAY;
-}
-
-/* d = a * b (mod c) */
-int fp_mulmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d)
-{
-  fp_int tmp;
-  fp_init(&tmp);
-  fp_mul(a, b, &tmp);
-  return fp_mod(&tmp, c, d);
-}
-
-#ifdef TFM_TIMING_RESISTANT
-
-/* timing resistant montgomery ladder based exptmod 
-
-   Based on work by Marc Joye, Sung-Ming Yen, "The Montgomery Powering Ladder", Cryptographic Hardware and Embedded Systems, CHES 2002
-*/
-static int _fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y)
-{
-  fp_int   R[2];
-  fp_digit buf, mp;
-  int      err, bitcnt, digidx, y;
-
-  /* now setup montgomery  */
-  if ((err = fp_montgomery_setup (P, &mp)) != FP_OKAY) {
-     return err;
-  }
-
-  fp_init(&R[0]);   
-  fp_init(&R[1]);   
-   
-  /* now we need R mod m */
-  fp_montgomery_calc_normalization (&R[0], P);
-
-  /* now set R[0][1] to G * R mod m */
-  if (fp_cmp_mag(P, G) != FP_GT) {
-     /* G > P so we reduce it first */
-     fp_mod(G, P, &R[1]);
-  } else {
-     fp_copy(G, &R[1]);
-  }
-  fp_mulmod (&R[1], &R[0], P, &R[1]);
-
-  /* for j = t-1 downto 0 do
-        r_!k = R0*R1; r_k = r_k^2
-  */
-  
-  /* set initial mode and bit cnt */
-  bitcnt = 1;
-  buf    = 0;
-  digidx = X->used - 1;
-
-  for (;;) {
-    /* grab next digit as required */
-    if (--bitcnt == 0) {
-      /* if digidx == -1 we are out of digits so break */
-      if (digidx == -1) {
-        break;
-      }
-      /* read next digit and reset bitcnt */
-      buf    = X->dp[digidx--];
-      bitcnt = (int)DIGIT_BIT;
-    }
-
-    /* grab the next msb from the exponent */
-    y     = (int)(buf >> (DIGIT_BIT - 1)) & 1;
-    buf <<= (fp_digit)1;
-
-    /* do ops */
-    fp_mul(&R[0], &R[1], &R[y^1]); fp_montgomery_reduce(&R[y^1], P, mp);
-    fp_sqr(&R[y], &R[y]);          fp_montgomery_reduce(&R[y], P, mp);
-  }
-
-   fp_montgomery_reduce(&R[0], P, mp);
-   fp_copy(&R[0], Y);
-   return FP_OKAY;
-}   
-
-#else
-
-/* y = g**x (mod b) 
- * Some restrictions... x must be positive and < b
- */
-static int _fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y)
-{
-  fp_int   M[64], res;
-  fp_digit buf, mp;
-  int      err, bitbuf, bitcpy, bitcnt, mode, digidx, x, y, winsize;
-
-  /* find window size */
-  x = fp_count_bits (X);
-  if (x <= 21) {
-    winsize = 1;
-  } else if (x <= 36) {
-    winsize = 3;
-  } else if (x <= 140) {
-    winsize = 4;
-  } else if (x <= 450) {
-    winsize = 5;
-  } else {
-    winsize = 6;
-  } 
-
-  /* init M array */
-  XMEMSET(M, 0, sizeof(M)); 
-
-  /* now setup montgomery  */
-  if ((err = fp_montgomery_setup (P, &mp)) != FP_OKAY) {
-     return err;
-  }
-
-  /* setup result */
-  fp_init(&res);
-
-  /* create M table
-   *
-   * The M table contains powers of the input base, e.g. M[x] = G^x mod P
-   *
-   * The first half of the table is not computed though accept for M[0] and M[1]
-   */
-
-   /* now we need R mod m */
-   fp_montgomery_calc_normalization (&res, P);
-
-   /* now set M[1] to G * R mod m */
-   if (fp_cmp_mag(P, G) != FP_GT) {
-      /* G > P so we reduce it first */
-      fp_mod(G, P, &M[1]);
-   } else {
-      fp_copy(G, &M[1]);
-   }
-   fp_mulmod (&M[1], &res, P, &M[1]);
-
-  /* compute the value at M[1<<(winsize-1)] by squaring M[1] (winsize-1) times */
-  fp_copy (&M[1], &M[1 << (winsize - 1)]);
-  for (x = 0; x < (winsize - 1); x++) {
-    fp_sqr (&M[1 << (winsize - 1)], &M[1 << (winsize - 1)]);
-    fp_montgomery_reduce (&M[1 << (winsize - 1)], P, mp);
-  }
-
-  /* create upper table */
-  for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) {
-    fp_mul(&M[x - 1], &M[1], &M[x]);
-    fp_montgomery_reduce(&M[x], P, mp);
-  }
-
-  /* set initial mode and bit cnt */
-  mode   = 0;
-  bitcnt = 1;
-  buf    = 0;
-  digidx = X->used - 1;
-  bitcpy = 0;
-  bitbuf = 0;
-
-  for (;;) {
-    /* grab next digit as required */
-    if (--bitcnt == 0) {
-      /* if digidx == -1 we are out of digits so break */
-      if (digidx == -1) {
-        break;
-      }
-      /* read next digit and reset bitcnt */
-      buf    = X->dp[digidx--];
-      bitcnt = (int)DIGIT_BIT;
-    }
-
-    /* grab the next msb from the exponent */
-    y     = (int)(buf >> (DIGIT_BIT - 1)) & 1;
-    buf <<= (fp_digit)1;
-
-    /* if the bit is zero and mode == 0 then we ignore it
-     * These represent the leading zero bits before the first 1 bit
-     * in the exponent.  Technically this opt is not required but it
-     * does lower the # of trivial squaring/reductions used
-     */
-    if (mode == 0 && y == 0) {
-      continue;
-    }
-
-    /* if the bit is zero and mode == 1 then we square */
-    if (mode == 1 && y == 0) {
-      fp_sqr(&res, &res);
-      fp_montgomery_reduce(&res, P, mp);
-      continue;
-    }
-
-    /* else we add it to the window */
-    bitbuf |= (y << (winsize - ++bitcpy));
-    mode    = 2;
-
-    if (bitcpy == winsize) {
-      /* ok window is filled so square as required and multiply  */
-      /* square first */
-      for (x = 0; x < winsize; x++) {
-        fp_sqr(&res, &res);
-        fp_montgomery_reduce(&res, P, mp);
-      }
-
-      /* then multiply */
-      fp_mul(&res, &M[bitbuf], &res);
-      fp_montgomery_reduce(&res, P, mp);
-
-      /* empty window and reset */
-      bitcpy = 0;
-      bitbuf = 0;
-      mode   = 1;
-    }
-  }
-
-  /* if bits remain then square/multiply */
-  if (mode == 2 && bitcpy > 0) {
-    /* square then multiply if the bit is set */
-    for (x = 0; x < bitcpy; x++) {
-      fp_sqr(&res, &res);
-      fp_montgomery_reduce(&res, P, mp);
-
-      /* get next bit of the window */
-      bitbuf <<= 1;
-      if ((bitbuf & (1 << winsize)) != 0) {
-        /* then multiply */
-        fp_mul(&res, &M[1], &res);
-        fp_montgomery_reduce(&res, P, mp);
-      }
-    }
-  }
-
-  /* fixup result if Montgomery reduction is used
-   * recall that any value in a Montgomery system is
-   * actually multiplied by R mod n.  So we have
-   * to reduce one more time to cancel out the factor
-   * of R.
-   */
-  fp_montgomery_reduce(&res, P, mp);
-
-  /* swap res with Y */
-  fp_copy (&res, Y);
-  return FP_OKAY;
-}
-
-#endif
-
-int fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y)
-{
-   /* prevent overflows */
-   if (P->used > (FP_SIZE/2)) {
-      return FP_VAL;
-   }
-
-   if (X->sign == FP_NEG) {
-#ifndef POSITIVE_EXP_ONLY  /* reduce stack if assume no negatives */
-      int    err;
-      fp_int tmp;
-
-      /* yes, copy G and invmod it */
-      fp_copy(G, &tmp);
-      if ((err = fp_invmod(&tmp, P, &tmp)) != FP_OKAY) {
-         return err;
-      }
-      X->sign = FP_ZPOS;
-      err =  _fp_exptmod(&tmp, X, P, Y);
-      if (X != Y) {
-         X->sign = FP_NEG;
-      }
-      return err;
-#else
-      return FP_VAL;
-#endif 
-   }
-   else {
-      /* Positive exponent so just exptmod */
-      return _fp_exptmod(G, X, P, Y);
-   }
-}
-
-/* computes a = 2**b */
-void fp_2expt(fp_int *a, int b)
-{
-   int     z;
-
-   /* zero a as per default */
-   fp_zero (a);
-
-   if (b < 0) { 
-      return;
-   }
-
-   z = b / DIGIT_BIT;
-   if (z >= FP_SIZE) {
-      return; 
-   }
-
-  /* set the used count of where the bit will go */
-  a->used = z + 1;
-
-  /* put the single bit in its place */
-  a->dp[z] = ((fp_digit)1) << (b % DIGIT_BIT);
-}
-
-/* b = a*a  */
-void fp_sqr(fp_int *A, fp_int *B)
-{
-    int y = A->used;
-
-    /* call generic if we're out of range */
-    if (y + y > FP_SIZE) {
-       fp_sqr_comba(A, B);
-       return ;
-    }
-
-#if defined(TFM_SQR3)
-        if (y <= 3) {
-           fp_sqr_comba3(A,B);
-           return;
-        }
-#endif
-#if defined(TFM_SQR4)
-        if (y == 4) {
-           fp_sqr_comba4(A,B);
-           return;
-        }
-#endif
-#if defined(TFM_SQR6)
-        if (y <= 6) {
-           fp_sqr_comba6(A,B);
-           return;
-        }
-#endif
-#if defined(TFM_SQR7)
-        if (y == 7) {
-           fp_sqr_comba7(A,B);
-           return;
-        }
-#endif
-#if defined(TFM_SQR8)
-        if (y == 8) {
-           fp_sqr_comba8(A,B);
-           return;
-        }
-#endif
-#if defined(TFM_SQR9)
-        if (y == 9) {
-           fp_sqr_comba9(A,B);
-           return;
-        }
-#endif
-#if defined(TFM_SQR12)
-        if (y <= 12) {
-           fp_sqr_comba12(A,B);
-           return;
-        }
-#endif
-#if defined(TFM_SQR17)
-        if (y <= 17) {
-           fp_sqr_comba17(A,B);
-           return;
-        }
-#endif
-#if defined(TFM_SMALL_SET)
-        if (y <= 16) {
-           fp_sqr_comba_small(A,B);
-           return;
-        }
-#endif
-#if defined(TFM_SQR20)
-        if (y <= 20) {
-           fp_sqr_comba20(A,B);
-           return;
-        }
-#endif
-#if defined(TFM_SQR24)
-        if (y <= 24) {
-           fp_sqr_comba24(A,B);
-           return;
-        }
-#endif
-#if defined(TFM_SQR28)
-        if (y <= 28) {
-           fp_sqr_comba28(A,B);
-           return;
-        }
-#endif
-#if defined(TFM_SQR32)
-        if (y <= 32) {
-           fp_sqr_comba32(A,B);
-           return;
-        }
-#endif
-#if defined(TFM_SQR48)
-        if (y <= 48) {
-           fp_sqr_comba48(A,B);
-           return;
-        }
-#endif
-#if defined(TFM_SQR64)
-        if (y <= 64) {
-           fp_sqr_comba64(A,B);
-           return;
-        }
-#endif
-       fp_sqr_comba(A, B);
-}
-
-/* generic comba squarer */
-void fp_sqr_comba(fp_int *A, fp_int *B)
-{
-  int       pa, ix, iz;
-  fp_digit  c0, c1, c2;
-  fp_int    tmp, *dst;
-#ifdef TFM_ISO
-  fp_word   tt;
-#endif    
-
-  /* get size of output and trim */
-  pa = A->used + A->used;
-  if (pa >= FP_SIZE) {
-     pa = FP_SIZE-1;
-  }
-
-  /* number of output digits to produce */
-  COMBA_START;
-  COMBA_CLEAR;
-
-  if (A == B) {
-     fp_init(&tmp);
-     dst = &tmp;
-  } else {
-     fp_zero(B);
-     dst = B;
-  }
-
-  for (ix = 0; ix < pa; ix++) { 
-      int      tx, ty, iy;
-      fp_digit *tmpy, *tmpx;
-
-      /* get offsets into the two bignums */
-      ty = MIN(A->used-1, ix);
-      tx = ix - ty;
-
-      /* setup temp aliases */
-      tmpx = A->dp + tx;
-      tmpy = A->dp + ty;
-
-      /* this is the number of times the loop will iterrate,
-         while (tx++ < a->used && ty-- >= 0) { ... }
-       */
-      iy = MIN(A->used-tx, ty+1);
-
-      /* now for squaring tx can never equal ty 
-       * we halve the distance since they approach 
-       * at a rate of 2x and we have to round because 
-       * odd cases need to be executed
-       */
-      iy = MIN(iy, (ty-tx+1)>>1);
-
-      /* forward carries */
-      COMBA_FORWARD;
-
-      /* execute loop */
-      for (iz = 0; iz < iy; iz++) {
-          SQRADD2(*tmpx++, *tmpy--);
-      }
-
-      /* even columns have the square term in them */
-      if ((ix&1) == 0) {
-          /* TAO change COMBA_ADD back to SQRADD */
-          SQRADD(A->dp[ix>>1], A->dp[ix>>1]);
-      }
-
-      /* store it */
-      COMBA_STORE(dst->dp[ix]);
-  }
-
-  COMBA_FINI;
-
-  /* setup dest */
-  dst->used = pa;
-  fp_clamp (dst);
-  if (dst != B) {
-     fp_copy(dst, B);
-  }
-}
-
-int fp_cmp(fp_int *a, fp_int *b)
-{
-   if (a->sign == FP_NEG && b->sign == FP_ZPOS) {
-      return FP_LT;
-   } else if (a->sign == FP_ZPOS && b->sign == FP_NEG) {
-      return FP_GT;
-   } else {
-      /* compare digits */
-      if (a->sign == FP_NEG) {
-         /* if negative compare opposite direction */
-         return fp_cmp_mag(b, a);
-      } else {
-         return fp_cmp_mag(a, b);
-      }
-   }
-}
-
-/* compare against a single digit */
-int fp_cmp_d(fp_int *a, fp_digit b)
-{
-  /* compare based on sign */
-  if ((b && a->used == 0) || a->sign == FP_NEG) {
-    return FP_LT;
-  }
-
-  /* compare based on magnitude */
-  if (a->used > 1) {
-    return FP_GT;
-  }
-
-  /* compare the only digit of a to b */
-  if (a->dp[0] > b) {
-    return FP_GT;
-  } else if (a->dp[0] < b) {
-    return FP_LT;
-  } else {
-    return FP_EQ;
-  }
-
-}
-
-int fp_cmp_mag(fp_int *a, fp_int *b)
-{
-   int x;
-
-   if (a->used > b->used) {
-      return FP_GT;
-   } else if (a->used < b->used) {
-      return FP_LT;
-   } else {
-      for (x = a->used - 1; x >= 0; x--) {
-          if (a->dp[x] > b->dp[x]) {
-             return FP_GT;
-          } else if (a->dp[x] < b->dp[x]) {
-             return FP_LT;
-          }
-      }
-   }
-   return FP_EQ;
-}
-
-/* setups the montgomery reduction */
-int fp_montgomery_setup(fp_int *a, fp_digit *rho)
-{
-  fp_digit x, b;
-
-/* fast inversion mod 2**k
- *
- * Based on the fact that
- *
- * XA = 1 (mod 2**n)  =>  (X(2-XA)) A = 1 (mod 2**2n)
- *                    =>  2*X*A - X*X*A*A = 1
- *                    =>  2*(1) - (1)     = 1
- */
-  b = a->dp[0];
-
-  if ((b & 1) == 0) {
-    return FP_VAL;
-  }
-
-  x = (((b + 2) & 4) << 1) + b; /* here x*a==1 mod 2**4 */
-  x *= 2 - b * x;               /* here x*a==1 mod 2**8 */
-  x *= 2 - b * x;               /* here x*a==1 mod 2**16 */
-  x *= 2 - b * x;               /* here x*a==1 mod 2**32 */
-#ifdef FP_64BIT
-  x *= 2 - b * x;               /* here x*a==1 mod 2**64 */
-#endif
-
-  /* rho = -1/m mod b */
-  *rho = (fp_digit) (((fp_word) 1 << ((fp_word) DIGIT_BIT)) - ((fp_word)x));
-
-  return FP_OKAY;
-}
-
-/* computes a = B**n mod b without division or multiplication useful for
- * normalizing numbers in a Montgomery system.
- */
-void fp_montgomery_calc_normalization(fp_int *a, fp_int *b)
-{
-  int     x, bits;
-
-  /* how many bits of last digit does b use */
-  bits = fp_count_bits (b) % DIGIT_BIT;
-  if (!bits) bits = DIGIT_BIT;
-
-  /* compute A = B^(n-1) * 2^(bits-1) */
-  if (b->used > 1) {
-     fp_2expt (a, (b->used - 1) * DIGIT_BIT + bits - 1);
-  } else {
-     fp_set(a, 1);
-     bits = 1;
-  }
-
-  /* now compute C = A * B mod b */
-  for (x = bits - 1; x < (int)DIGIT_BIT; x++) {
-    fp_mul_2 (a, a);
-    if (fp_cmp_mag (a, b) != FP_LT) {
-      s_fp_sub (a, b, a);
-    }
-  }
-}
-
-
-#ifdef TFM_SMALL_MONT_SET
-    #include "fp_mont_small.i"
-#endif
-
-#ifdef HAVE_INTEL_MULX
-static inline void innermul8_mulx(fp_digit *c_mulx, fp_digit *cy_mulx, fp_digit *tmpm, fp_digit mu) 
-{
-    fp_digit _c0, _c1, _c2, _c3, _c4, _c5, _c6, _c7, cy ;
-
-    cy = *cy_mulx ;
-    _c0=c_mulx[0]; _c1=c_mulx[1]; _c2=c_mulx[2]; _c3=c_mulx[3]; _c4=c_mulx[4]; _c5=c_mulx[5]; _c6=c_mulx[6]; _c7=c_mulx[7];    
-    INNERMUL8_MULX ;
-    c_mulx[0]=_c0; c_mulx[1]=_c1; c_mulx[2]=_c2; c_mulx[3]=_c3; c_mulx[4]=_c4; c_mulx[5]=_c5; c_mulx[6]=_c6; c_mulx[7]=_c7; 
-    *cy_mulx = cy ;
-}
-
-/* computes x/R == x (mod N) via Montgomery Reduction */
-static void fp_montgomery_reduce_mulx(fp_int *a, fp_int *m, fp_digit mp)
-{
-   fp_digit c[FP_SIZE], *_c, *tmpm, mu = 0;
-   int      oldused, x, y, pa;
-
-   /* bail if too large */
-   if (m->used > (FP_SIZE/2)) {
-      (void)mu;                     /* shut up compiler */
-      return;
-   }
-
-#ifdef TFM_SMALL_MONT_SET
-   if (m->used <= 16) {
-      fp_montgomery_reduce_small(a, m, mp);
-      return;
-   }
-#endif
-
-
-   /* now zero the buff */
-   XMEMSET(c, 0, sizeof c);
-   pa = m->used;
-
-   /* copy the input */
-   oldused = a->used;
-   for (x = 0; x < oldused; x++) {
-       c[x] = a->dp[x];
-   }
-   MONT_START;
-
-   for (x = 0; x < pa; x++) {
-       fp_digit cy = 0;
-       /* get Mu for this round */
-       LOOP_START;
-       _c   = c + x;
-       tmpm = m->dp;
-       y = 0;
-        for (; y < (pa & ~7); y += 8) {
-              innermul8_mulx(_c, &cy, tmpm, mu) ;
-              _c   += 8;
-              tmpm += 8;
-           }
-       for (; y < pa; y++) {
-          INNERMUL;
-          ++_c;
-       }
-       LOOP_END;
-       while (cy) {
-           PROPCARRY;
-           ++_c;
-       }
-  }         
-
-  /* now copy out */
-  _c   = c + pa;
-  tmpm = a->dp;
-  for (x = 0; x < pa+1; x++) {
-     *tmpm++ = *_c++;
-  }
-
-  for (; x < oldused; x++)   {
-     *tmpm++ = 0;
-  }
-
-  MONT_FINI;
-
-  a->used = pa+1;
-  fp_clamp(a);
-  
-  /* if A >= m then A = A - m */
-  if (fp_cmp_mag (a, m) != FP_LT) {
-    s_fp_sub (a, m, a);
-  }
-}
-#endif
-
-/* computes x/R == x (mod N) via Montgomery Reduction */
-void fp_montgomery_reduce(fp_int *a, fp_int *m, fp_digit mp)
-{
-   fp_digit c[FP_SIZE], *_c, *tmpm, mu = 0;
-   int      oldused, x, y, pa;
-
-   IF_HAVE_INTEL_MULX(fp_montgomery_reduce_mulx(a, m, mp), return) ;
-
-   /* bail if too large */
-   if (m->used > (FP_SIZE/2)) {
-      (void)mu;                     /* shut up compiler */
-      return;
-   }
-
-#ifdef TFM_SMALL_MONT_SET
-   if (m->used <= 16) {
-      fp_montgomery_reduce_small(a, m, mp);
-      return;
-   }
-#endif
-
-
-   /* now zero the buff */
-   XMEMSET(c, 0, sizeof c);
-   pa = m->used;
-
-   /* copy the input */
-   oldused = a->used;
-   for (x = 0; x < oldused; x++) {
-       c[x] = a->dp[x];
-   }
-   MONT_START;
-
-   for (x = 0; x < pa; x++) {
-       fp_digit cy = 0;
-       /* get Mu for this round */
-       LOOP_START;
-       _c   = c + x;
-       tmpm = m->dp;
-       y = 0;
-       #if (defined(TFM_SSE2) || defined(TFM_X86_64))
-        for (; y < (pa & ~7); y += 8) {
-              INNERMUL8 ;
-              _c   += 8;
-              tmpm += 8;
-           }
-       #endif
-       for (; y < pa; y++) {
-          INNERMUL;
-          ++_c;
-       }
-       LOOP_END;
-       while (cy) {
-           PROPCARRY;
-           ++_c;
-       }
-  }         
-
-  /* now copy out */
-  _c   = c + pa;
-  tmpm = a->dp;
-  for (x = 0; x < pa+1; x++) {
-     *tmpm++ = *_c++;
-  }
-
-  for (; x < oldused; x++)   {
-     *tmpm++ = 0;
-  }
-
-  MONT_FINI;
-
-  a->used = pa+1;
-  fp_clamp(a);
-  
-  /* if A >= m then A = A - m */
-  if (fp_cmp_mag (a, m) != FP_LT) {
-    s_fp_sub (a, m, a);
-  }
-}
-
-void fp_read_unsigned_bin(fp_int *a, unsigned char *b, int c)
-{
-  /* zero the int */
-  fp_zero (a);
-
-  /* If we know the endianness of this architecture, and we're using
-     32-bit fp_digits, we can optimize this */
-#if (defined(LITTLE_ENDIAN_ORDER) || defined(BIG_ENDIAN_ORDER)) && defined(FP_32BIT)
-  /* But not for both simultaneously */
-#if defined(LITTLE_ENDIAN_ORDER) && defined(BIG_ENDIAN_ORDER)
-#error Both LITTLE_ENDIAN_ORDER and BIG_ENDIAN_ORDER defined.
-#endif
-  {
-     unsigned char *pd = (unsigned char *)a->dp;
-
-     if ((unsigned)c > (FP_SIZE * sizeof(fp_digit))) {
-        int excess = c - (FP_SIZE * sizeof(fp_digit));
-        c -= excess;
-        b += excess;
-     }
-     a->used = (c + sizeof(fp_digit) - 1)/sizeof(fp_digit);
-     /* read the bytes in */
-#ifdef BIG_ENDIAN_ORDER
-     {
-       /* Use Duff's device to unroll the loop. */
-       int idx = (c - 1) & ~3;
-       switch (c % 4) {
-       case 0:	do { pd[idx+0] = *b++;
-       case 3:	     pd[idx+1] = *b++;
-       case 2:	     pd[idx+2] = *b++;
-       case 1:	     pd[idx+3] = *b++;
-                     idx -= 4;
-	 	        } while ((c -= 4) > 0);
-       }
-     }
-#else
-     for (c -= 1; c >= 0; c -= 1) {
-       pd[c] = *b++;
-     }
-#endif
-  }
-#else
-  /* read the bytes in */
-  for (; c > 0; c--) {
-     fp_mul_2d (a, 8, a);
-     a->dp[0] |= *b++;
-     a->used += 1;
-  }
-#endif
-  fp_clamp (a);
-}
-
-void fp_to_unsigned_bin(fp_int *a, unsigned char *b)
-{
-  int     x;
-  fp_int  t;
-
-  fp_init_copy(&t, a);
-
-  x = 0;
-  while (fp_iszero (&t) == FP_NO) {
-      b[x++] = (unsigned char) (t.dp[0] & 255);
-      fp_div_2d (&t, 8, &t, NULL);
-  }
-  fp_reverse (b, x);
-}
-
-int fp_unsigned_bin_size(fp_int *a)
-{
-  int     size = fp_count_bits (a);
-  return (size / 8 + ((size & 7) != 0 ? 1 : 0));
-}
-
-void fp_set(fp_int *a, fp_digit b)
-{
-   fp_zero(a);
-   a->dp[0] = b;
-   a->used  = a->dp[0] ? 1 : 0;
-}
-
-int fp_count_bits (fp_int * a)
-{
-  int     r;
-  fp_digit q;
-
-  /* shortcut */
-  if (a->used == 0) {
-    return 0;
-  }
-
-  /* get number of digits and add that */
-  r = (a->used - 1) * DIGIT_BIT;
-
-  /* take the last digit and count the bits in it */
-  q = a->dp[a->used - 1];
-  while (q > ((fp_digit) 0)) {
-    ++r;
-    q >>= ((fp_digit) 1);
-  }
-  return r;
-}
-
-int fp_leading_bit(fp_int *a)
-{
-    int bit = 0;
-
-    if (a->used != 0) {
-        fp_digit q = a->dp[a->used - 1];
-        int qSz = sizeof(fp_digit);
-
-        while (qSz > 0) {
-            if ((unsigned char)q != 0)
-                bit = (q & 0x80) != 0;
-            q >>= 8;
-            qSz--;
-        }
-    }
-
-    return bit;
-}
-
-void fp_lshd(fp_int *a, int x)
-{
-   int y;
-
-   /* move up and truncate as required */
-   y = MIN(a->used + x - 1, (int)(FP_SIZE-1));
-
-   /* store new size */
-   a->used = y + 1;
-
-   /* move digits */
-   for (; y >= x; y--) {
-       a->dp[y] = a->dp[y-x];
-   }
- 
-   /* zero lower digits */
-   for (; y >= 0; y--) {
-       a->dp[y] = 0;
-   }
-
-   /* clamp digits */
-   fp_clamp(a);
-}
-
-
-/* right shift by bit count */
-void fp_rshb(fp_int *c, int x)
-{
-    register fp_digit *tmpc, mask, shift;
-    fp_digit r, rr;
-    fp_digit D = x;
-
-    /* mask */
-    mask = (((fp_digit)1) << D) - 1;
-
-    /* shift for lsb */
-    shift = DIGIT_BIT - D;
-
-    /* alias */
-    tmpc = c->dp + (c->used - 1);
-
-    /* carry */
-    r = 0;
-    for (x = c->used - 1; x >= 0; x--) {
-      /* get the lower  bits of this word in a temp */
-      rr = *tmpc & mask;
-
-      /* shift the current word and mix in the carry bits from previous word */
-      *tmpc = (*tmpc >> D) | (r << shift);
-      --tmpc;
-
-      /* set the carry to the carry bits of the current word found above */
-      r = rr;
-    }
-}
-
-
-void fp_rshd(fp_int *a, int x)
-{
-  int y;
-
-  /* too many digits just zero and return */
-  if (x >= a->used) {
-     fp_zero(a);
-     return;
-  }
-
-   /* shift */
-   for (y = 0; y < a->used - x; y++) {
-      a->dp[y] = a->dp[y+x];
-   }
-
-   /* zero rest */
-   for (; y < a->used; y++) {
-      a->dp[y] = 0;
-   }
-   
-   /* decrement count */
-   a->used -= x;
-   fp_clamp(a);
-}
-
-/* reverse an array, used for radix code */
-void fp_reverse (unsigned char *s, int len)
-{
-  int     ix, iy;
-  unsigned char t;
-
-  ix = 0;
-  iy = len - 1;
-  while (ix < iy) {
-    t     = s[ix];
-    s[ix] = s[iy];
-    s[iy] = t;
-    ++ix;
-    --iy;
-  }
-}
-
-
-/* c = a - b */
-void fp_sub_d(fp_int *a, fp_digit b, fp_int *c)
-{
-   fp_int tmp;
-   fp_init(&tmp);
-   fp_set(&tmp, b);
-   fp_sub(a, &tmp, c);
-}
-
-
-/* CyaSSL callers from normal lib */
-
-/* init a new mp_int */
-int mp_init (mp_int * a)
-{
-  if (a)
-    fp_init(a);
-  return MP_OKAY;
-}
-
-#ifdef ALT_ECC_SIZE
-void fp_init(fp_int *a)
-{
-    a->size = FP_SIZE;
-    fp_zero(a);
-}
-
-void fp_zero(fp_int *a)
-{
-    a->used = 0;
-    a->sign = FP_ZPOS;
-    XMEMSET(a->dp, 0, a->size * sizeof(fp_digit));
-}
-#endif
-
-
-/* clear one (frees)  */
-void mp_clear (mp_int * a)
-{
-  fp_zero(a);
-}
-
-/* handle up to 6 inits */
-int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e, mp_int* f)
-{
-    if (a)
-        fp_init(a);
-    if (b)
-        fp_init(b);
-    if (c)
-        fp_init(c);
-    if (d)
-        fp_init(d);
-    if (e)
-        fp_init(e);
-    if (f)
-        fp_init(f);
-
-    return MP_OKAY;
-}
-
-/* high level addition (handles signs) */
-int mp_add (mp_int * a, mp_int * b, mp_int * c)
-{
-  fp_add(a, b, c);
-  return MP_OKAY;
-}
-
-/* high level subtraction (handles signs) */
-int mp_sub (mp_int * a, mp_int * b, mp_int * c)
-{
-  fp_sub(a, b, c);
-  return MP_OKAY;
-}
-
-/* high level multiplication (handles sign) */
-int mp_mul (mp_int * a, mp_int * b, mp_int * c)
-{
-  fp_mul(a, b, c);
-  return MP_OKAY;
-}
-
-/* d = a * b (mod c) */
-int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
-{
-  return fp_mulmod(a, b, c, d);
-}
-
-/* c = a mod b, 0 <= c < b */
-int mp_mod (mp_int * a, mp_int * b, mp_int * c)
-{
-  return fp_mod (a, b, c);
-}
-
-/* hac 14.61, pp608 */
-int mp_invmod (mp_int * a, mp_int * b, mp_int * c)
-{
-  return fp_invmod(a, b, c);
-}
-
-/* this is a shell function that calls either the normal or Montgomery
- * exptmod functions.  Originally the call to the montgomery code was
- * embedded in the normal function but that wasted alot of stack space
- * for nothing (since 99% of the time the Montgomery code would be called)
- */
-int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y)
-{
-  return fp_exptmod(G, X, P, Y);
-}
-
-/* compare two ints (signed)*/
-int mp_cmp (mp_int * a, mp_int * b)
-{
-  return fp_cmp(a, b);
-}
-
-/* compare a digit */
-int mp_cmp_d(mp_int * a, mp_digit b)
-{
-  return fp_cmp_d(a, b);
-}
-
-/* get the size for an unsigned equivalent */
-int mp_unsigned_bin_size (mp_int * a)
-{
-  return fp_unsigned_bin_size(a);
-}
-
-/* store in unsigned [big endian] format */
-int mp_to_unsigned_bin (mp_int * a, unsigned char *b)
-{
-  fp_to_unsigned_bin(a,b);
-  return MP_OKAY;
-}
-
-/* reads a unsigned char array, assumes the msb is stored first [big endian] */
-int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c)
-{
-  fp_read_unsigned_bin(a, (unsigned char *)b, c);
-  return MP_OKAY;
-}
-
-
-int mp_sub_d(fp_int *a, fp_digit b, fp_int *c)
-{
-    fp_sub_d(a, b, c);
-    return MP_OKAY;
-}
-
-
-#ifdef ALT_ECC_SIZE
-void fp_copy(fp_int *a, fp_int* b)
-{
-    if (a != b) {
-        b->used = a->used;
-        b->sign = a->sign;
-        XMEMCPY(b->dp, a->dp, a->used * sizeof(fp_digit));
-    }
-}
-
-void fp_init_copy(fp_int *a, fp_int* b)
-{
-    if (a != b) {
-        fp_init(a);
-        fp_copy(b, a);
-    }
-}
-#endif
-
-/* fast math conversion */
-int mp_copy(fp_int* a, fp_int* b)
-{
-    fp_copy(a, b);
-    return MP_OKAY;
-}
-
-
-/* fast math conversion */
-int mp_isodd(mp_int* a)
-{
-    return fp_isodd(a);
-}
-
-
-/* fast math conversion */
-int mp_iszero(mp_int* a)
-{
-    return fp_iszero(a);
-}
-
-
-/* fast math conversion */
-int mp_count_bits (mp_int* a)
-{
-    return fp_count_bits(a);
-}
-
-
-int mp_leading_bit (mp_int* a)
-{
-    return fp_leading_bit(a);
-}
-
-
-/* fast math conversion */
-void mp_rshb (mp_int* a, int x)
-{
-    fp_rshb(a, x);
-}
-
-
-/* fast math wrappers */
-int mp_set_int(fp_int *a, fp_digit b)
-{
-    fp_set(a, b);
-    return MP_OKAY;
-}
-
-
-#if defined(WOLFSSL_KEY_GEN) || defined (HAVE_ECC)
-
-/* c = a * a (mod b) */
-int fp_sqrmod(fp_int *a, fp_int *b, fp_int *c)
-{
-  fp_int tmp;
-  fp_init(&tmp);
-  fp_sqr(a, &tmp);
-  return fp_mod(&tmp, b, c);
-}
-
-/* fast math conversion */
-int mp_sqrmod(mp_int *a, mp_int *b, mp_int *c)
-{
-    return fp_sqrmod(a, b, c);
-}
-
-/* fast math conversion */
-int mp_montgomery_calc_normalization(mp_int *a, mp_int *b)
-{
-    fp_montgomery_calc_normalization(a, b);
-    return MP_OKAY;
-}
-
-#endif /* WOLFSSL_KEYGEN || HAVE_ECC */
-
-
-#if defined(WOLFSSL_KEY_GEN) || defined(HAVE_COMP_KEY)
-
-static const int lnz[16] = {
-   4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
-};
-
-/* Counts the number of lsbs which are zero before the first zero bit */
-int fp_cnt_lsb(fp_int *a)
-{
-   int x;
-   fp_digit q, qq;
-
-   /* easy out */
-   if (fp_iszero(a) == 1) {
-      return 0;
-   }
-
-   /* scan lower digits until non-zero */
-   for (x = 0; x < a->used && a->dp[x] == 0; x++);
-   q = a->dp[x];
-   x *= DIGIT_BIT;
-
-   /* now scan this digit until a 1 is found */
-   if ((q & 1) == 0) {
-      do {
-         qq  = q & 15;
-         x  += lnz[qq];
-         q >>= 4;
-      } while (qq == 0);
-   }
-   return x;
-}
-
-
-
-
-static int s_is_power_of_two(fp_digit b, int *p)
-{
-   int x;
-
-   /* fast return if no power of two */
-   if ((b==0) || (b & (b-1))) {
-      return 0;
-   }
-
-   for (x = 0; x < DIGIT_BIT; x++) {
-      if (b == (((fp_digit)1)< cb + d == a */
-static int fp_div_d(fp_int *a, fp_digit b, fp_int *c, fp_digit *d)
-{
-  fp_int   q;
-  fp_word  w;
-  fp_digit t;
-  int      ix;
-
-  /* cannot divide by zero */
-  if (b == 0) {
-     return FP_VAL;
-  }
-
-  /* quick outs */
-  if (b == 1 || fp_iszero(a) == 1) {
-     if (d != NULL) {
-        *d = 0;
-     }
-     if (c != NULL) {
-        fp_copy(a, c);
-     }
-     return FP_OKAY;
-  }
-
-  /* power of two ? */
-  if (s_is_power_of_two(b, &ix) == 1) {
-     if (d != NULL) {
-        *d = a->dp[0] & ((((fp_digit)1)<used;
-  q.sign = a->sign;
-  w = 0;
-  for (ix = a->used - 1; ix >= 0; ix--) {
-     w = (w << ((fp_word)DIGIT_BIT)) | ((fp_word)a->dp[ix]);
-     
-     if (w >= b) {
-        t = (fp_digit)(w / b);
-        w -= ((fp_word)t) * ((fp_word)b);
-      } else {
-        t = 0;
-      }
-      q.dp[ix] = (fp_digit)t;
-  }
-  
-  if (d != NULL) {
-     *d = (fp_digit)w;
-  }
-  
-  if (c != NULL) {
-     fp_clamp(&q);
-     fp_copy(&q, c);
-  }
- 
-  return FP_OKAY;
-}
-
-
-/* c = a mod b, 0 <= c < b  */
-static int fp_mod_d(fp_int *a, fp_digit b, fp_digit *c)
-{
-   return fp_div_d(a, b, NULL, c);
-}
-
-int mp_mod_d(fp_int *a, fp_digit b, fp_digit *c)
-{
-   return fp_mod_d(a, b, c);
-}
-
-#endif /* defined(WOLFSSL_KEY_GEN) || defined(HAVE_COMP_KEY) */
-
-#ifdef WOLFSSL_KEY_GEN
-
-void fp_gcd(fp_int *a, fp_int *b, fp_int *c);
-void fp_lcm(fp_int *a, fp_int *b, fp_int *c);
-int  fp_isprime(fp_int *a);
-
-int mp_gcd(fp_int *a, fp_int *b, fp_int *c)
-{
-    fp_gcd(a, b, c);
-    return MP_OKAY;
-}
-
-
-int mp_lcm(fp_int *a, fp_int *b, fp_int *c)
-{
-    fp_lcm(a, b, c);
-    return MP_OKAY;
-}
-
-
-int mp_prime_is_prime(mp_int* a, int t, int* result)
-{
-    (void)t;
-    *result = fp_isprime(a);
-    return MP_OKAY;
-}
-
-/* Miller-Rabin test of "a" to the base of "b" as described in 
- * HAC pp. 139 Algorithm 4.24
- *
- * Sets result to 0 if definitely composite or 1 if probably prime.
- * Randomly the chance of error is no more than 1/4 and often 
- * very much lower.
- */
-static void fp_prime_miller_rabin (fp_int * a, fp_int * b, int *result)
-{
-  fp_int  n1, y, r;
-  int     s, j;
-
-  /* default */
-  *result = FP_NO;
-
-  /* ensure b > 1 */
-  if (fp_cmp_d(b, 1) != FP_GT) {
-     return;
-  }     
-
-  /* get n1 = a - 1 */
-  fp_init_copy(&n1, a);
-  fp_sub_d(&n1, 1, &n1);
-
-  /* set 2**s * r = n1 */
-  fp_init_copy(&r, &n1);
-
-  /* count the number of least significant bits
-   * which are zero
-   */
-  s = fp_cnt_lsb(&r);
-
-  /* now divide n - 1 by 2**s */
-  fp_div_2d (&r, s, &r, NULL);
-
-  /* compute y = b**r mod a */
-  fp_init(&y);
-  fp_exptmod(b, &r, a, &y);
-
-  /* if y != 1 and y != n1 do */
-  if (fp_cmp_d (&y, 1) != FP_EQ && fp_cmp (&y, &n1) != FP_EQ) {
-    j = 1;
-    /* while j <= s-1 and y != n1 */
-    while ((j <= (s - 1)) && fp_cmp (&y, &n1) != FP_EQ) {
-      fp_sqrmod (&y, a, &y);
-
-      /* if y == 1 then composite */
-      if (fp_cmp_d (&y, 1) == FP_EQ) {
-         return;
-      }
-      ++j;
-    }
-
-    /* if y != n1 then composite */
-    if (fp_cmp (&y, &n1) != FP_EQ) {
-       return;
-    }
-  }
-
-  /* probably prime now */
-  *result = FP_YES;
-}
-
-
-/* a few primes */
-static const fp_digit primes[256] = {
-  0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013,
-  0x0017, 0x001D, 0x001F, 0x0025, 0x0029, 0x002B, 0x002F, 0x0035,
-  0x003B, 0x003D, 0x0043, 0x0047, 0x0049, 0x004F, 0x0053, 0x0059,
-  0x0061, 0x0065, 0x0067, 0x006B, 0x006D, 0x0071, 0x007F, 0x0083,
-  0x0089, 0x008B, 0x0095, 0x0097, 0x009D, 0x00A3, 0x00A7, 0x00AD,
-  0x00B3, 0x00B5, 0x00BF, 0x00C1, 0x00C5, 0x00C7, 0x00D3, 0x00DF,
-  0x00E3, 0x00E5, 0x00E9, 0x00EF, 0x00F1, 0x00FB, 0x0101, 0x0107,
-  0x010D, 0x010F, 0x0115, 0x0119, 0x011B, 0x0125, 0x0133, 0x0137,
-
-  0x0139, 0x013D, 0x014B, 0x0151, 0x015B, 0x015D, 0x0161, 0x0167,
-  0x016F, 0x0175, 0x017B, 0x017F, 0x0185, 0x018D, 0x0191, 0x0199,
-  0x01A3, 0x01A5, 0x01AF, 0x01B1, 0x01B7, 0x01BB, 0x01C1, 0x01C9,
-  0x01CD, 0x01CF, 0x01D3, 0x01DF, 0x01E7, 0x01EB, 0x01F3, 0x01F7,
-  0x01FD, 0x0209, 0x020B, 0x021D, 0x0223, 0x022D, 0x0233, 0x0239,
-  0x023B, 0x0241, 0x024B, 0x0251, 0x0257, 0x0259, 0x025F, 0x0265,
-  0x0269, 0x026B, 0x0277, 0x0281, 0x0283, 0x0287, 0x028D, 0x0293,
-  0x0295, 0x02A1, 0x02A5, 0x02AB, 0x02B3, 0x02BD, 0x02C5, 0x02CF,
-
-  0x02D7, 0x02DD, 0x02E3, 0x02E7, 0x02EF, 0x02F5, 0x02F9, 0x0301,
-  0x0305, 0x0313, 0x031D, 0x0329, 0x032B, 0x0335, 0x0337, 0x033B,
-  0x033D, 0x0347, 0x0355, 0x0359, 0x035B, 0x035F, 0x036D, 0x0371,
-  0x0373, 0x0377, 0x038B, 0x038F, 0x0397, 0x03A1, 0x03A9, 0x03AD,
-  0x03B3, 0x03B9, 0x03C7, 0x03CB, 0x03D1, 0x03D7, 0x03DF, 0x03E5,
-  0x03F1, 0x03F5, 0x03FB, 0x03FD, 0x0407, 0x0409, 0x040F, 0x0419,
-  0x041B, 0x0425, 0x0427, 0x042D, 0x043F, 0x0443, 0x0445, 0x0449,
-  0x044F, 0x0455, 0x045D, 0x0463, 0x0469, 0x047F, 0x0481, 0x048B,
-
-  0x0493, 0x049D, 0x04A3, 0x04A9, 0x04B1, 0x04BD, 0x04C1, 0x04C7,
-  0x04CD, 0x04CF, 0x04D5, 0x04E1, 0x04EB, 0x04FD, 0x04FF, 0x0503,
-  0x0509, 0x050B, 0x0511, 0x0515, 0x0517, 0x051B, 0x0527, 0x0529,
-  0x052F, 0x0551, 0x0557, 0x055D, 0x0565, 0x0577, 0x0581, 0x058F,
-  0x0593, 0x0595, 0x0599, 0x059F, 0x05A7, 0x05AB, 0x05AD, 0x05B3,
-  0x05BF, 0x05C9, 0x05CB, 0x05CF, 0x05D1, 0x05D5, 0x05DB, 0x05E7,
-  0x05F3, 0x05FB, 0x0607, 0x060D, 0x0611, 0x0617, 0x061F, 0x0623,
-  0x062B, 0x062F, 0x063D, 0x0641, 0x0647, 0x0649, 0x064D, 0x0653
-};
-
-int fp_isprime(fp_int *a)
-{
-   fp_int   b;
-   fp_digit d = 0;
-   int      r, res;
-
-   /* do trial division */
-   for (r = 0; r < 256; r++) {
-       fp_mod_d(a, primes[r], &d);
-       if (d == 0) {
-          return FP_NO;
-       }
-   }
-
-   /* now do 8 miller rabins */
-   fp_init(&b);
-   for (r = 0; r < 8; r++) {
-       fp_set(&b, primes[r]);
-       fp_prime_miller_rabin(a, &b, &res);
-       if (res == FP_NO) {
-          return FP_NO;
-       }
-   }
-   return FP_YES;
-}
-
-
-/* c = [a, b] */
-void fp_lcm(fp_int *a, fp_int *b, fp_int *c)
-{
-   fp_int  t1, t2;
-
-   fp_init(&t1);
-   fp_init(&t2);
-   fp_gcd(a, b, &t1);
-   if (fp_cmp_mag(a, b) == FP_GT) {
-      fp_div(a, &t1, &t2, NULL);
-      fp_mul(b, &t2, c);
-   } else {
-      fp_div(b, &t1, &t2, NULL);
-      fp_mul(a, &t2, c);
-   }   
-}
-
-
-
-/* c = (a, b) */
-void fp_gcd(fp_int *a, fp_int *b, fp_int *c)
-{
-   fp_int u, v, r;
-
-   /* either zero than gcd is the largest */
-   if (fp_iszero (a) == 1 && fp_iszero (b) == 0) {
-     fp_abs (b, c);
-     return;
-   }
-   if (fp_iszero (a) == 0 && fp_iszero (b) == 1) {
-     fp_abs (a, c);
-     return;
-   }
-
-   /* optimized.  At this point if a == 0 then
-    * b must equal zero too
-    */
-   if (fp_iszero (a) == 1) {
-     fp_zero(c);
-     return;
-   }
-
-   /* sort inputs */
-   if (fp_cmp_mag(a, b) != FP_LT) {
-      fp_init_copy(&u, a);
-      fp_init_copy(&v, b);
-   } else {
-      fp_init_copy(&u, b);
-      fp_init_copy(&v, a);
-   }
- 
-   fp_init(&r);
-   while (fp_iszero(&v) == FP_NO) {
-      fp_mod(&u, &v, &r);
-      fp_copy(&v, &u);
-      fp_copy(&r, &v);
-   }
-   fp_copy(&u, c);
-}
-
-#endif /* WOLFSSL_KEY_GEN */
-
-
-#if defined(HAVE_ECC) || !defined(NO_PWDBASED)
-/* c = a + b */
-void fp_add_d(fp_int *a, fp_digit b, fp_int *c)
-{
-   fp_int tmp;
-   fp_init(&tmp);
-   fp_set(&tmp, b);
-   fp_add(a,&tmp,c);
-}
-
-/* external compatibility */
-int mp_add_d(fp_int *a, fp_digit b, fp_int *c)
-{
-    fp_add_d(a, b, c);
-    return MP_OKAY;
-}
-
-#endif  /* HAVE_ECC || !NO_PWDBASED */
-
-
-#ifdef HAVE_ECC
-
-/* chars used in radix conversions */
-static const char *fp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
-
-static int fp_read_radix(fp_int *a, const char *str, int radix)
-{
-  int     y, neg;
-  char    ch;
-
-  /* make sure the radix is ok */
-  if (radix < 2 || radix > 64) {
-    return FP_VAL;
-  }
-
-  /* if the leading digit is a
-   * minus set the sign to negative.
-   */
-  if (*str == '-') {
-    ++str;
-    neg = FP_NEG;
-  } else {
-    neg = FP_ZPOS;
-  }
-
-  /* set the integer to the default of zero */
-  fp_zero (a);
-
-  /* process each digit of the string */
-  while (*str) {
-    /* if the radix < 36 the conversion is case insensitive
-     * this allows numbers like 1AB and 1ab to represent the same  value
-     * [e.g. in hex]
-     */
-    ch = (char) ((radix < 36) ? XTOUPPER((unsigned char)*str) : *str);
-    for (y = 0; y < 64; y++) {
-      if (ch == fp_s_rmap[y]) {
-         break;
-      }
-    }
-
-    /* if the char was found in the map
-     * and is less than the given radix add it
-     * to the number, otherwise exit the loop.
-     */
-    if (y < radix) {
-      fp_mul_d (a, (fp_digit) radix, a);
-      fp_add_d (a, (fp_digit) y, a);
-    } else {
-      break;
-    }
-    ++str;
-  }
-
-  /* set the sign only if a != 0 */
-  if (fp_iszero(a) != FP_YES) {
-     a->sign = neg;
-  }
-  return FP_OKAY;
-}
-
-/* fast math conversion */
-int mp_read_radix(mp_int *a, const char *str, int radix)
-{
-    return fp_read_radix(a, str, radix);
-}
-
-/* fast math conversion */
-void mp_set(fp_int *a, fp_digit b)
-{
-    fp_set(a,b);
-}
-
-/* fast math conversion */
-int mp_sqr(fp_int *A, fp_int *B)
-{
-    fp_sqr(A, B);
-    return MP_OKAY;
-}
-  
-/* fast math conversion */
-int mp_montgomery_reduce(fp_int *a, fp_int *m, fp_digit mp)
-{
-    fp_montgomery_reduce(a, m, mp);
-    return MP_OKAY;
-}
-
-
-/* fast math conversion */
-int mp_montgomery_setup(fp_int *a, fp_digit *rho)
-{
-    return fp_montgomery_setup(a, rho);
-}
-
-int mp_div_2(fp_int * a, fp_int * b)
-{
-    fp_div_2(a, b);
-    return MP_OKAY;
-}
-
-
-int mp_init_copy(fp_int * a, fp_int * b)
-{
-    fp_init_copy(a, b);
-    return MP_OKAY;
-}
-
-
-#ifdef HAVE_COMP_KEY
-
-int mp_cnt_lsb(fp_int* a)
-{
-    fp_cnt_lsb(a);
-    return MP_OKAY;
-}
-
-int mp_div_2d(fp_int* a, int b, fp_int* c, fp_int* d)
-{
-    fp_div_2d(a, b, c, d);
-    return MP_OKAY;
-}
-
-#endif /* HAVE_COMP_KEY */
-
-
-#endif /* HAVE_ECC */
-
-#endif /* USE_FAST_MATH */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/wc_port.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/wc_port.c
deleted file mode 100755
index 4190337..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/src/wc_port.c
+++ /dev/null
@@ -1,656 +0,0 @@
-/* port.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-#include 
-#include 
-
-
-#ifdef _MSC_VER
-    /* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
-    #pragma warning(disable: 4996)
-#endif
-
-
-
-#ifdef SINGLE_THREADED
-
-int InitMutex(wolfSSL_Mutex* m)
-{
-    (void)m;
-    return 0;
-}
-
-
-int FreeMutex(wolfSSL_Mutex *m)
-{
-    (void)m;
-    return 0;
-}
-
-
-int LockMutex(wolfSSL_Mutex *m)
-{
-    (void)m;
-    return 0;
-}
-
-
-int UnLockMutex(wolfSSL_Mutex *m)
-{
-    (void)m;
-    return 0;
-}
-
-#else /* MULTI_THREAD */
-
-    #if defined(FREERTOS)
-
-        int InitMutex(wolfSSL_Mutex* m)
-        {
-            int iReturn;
-
-            *m = ( wolfSSL_Mutex ) xSemaphoreCreateMutex();
-            if( *m != NULL )
-                iReturn = 0;
-            else
-                iReturn = BAD_MUTEX_E;
-
-            return iReturn;
-        }
-
-        int FreeMutex(wolfSSL_Mutex* m)
-        {
-            vSemaphoreDelete( *m );
-            return 0;
-        }
-
-        int LockMutex(wolfSSL_Mutex* m)
-        {
-            /* Assume an infinite block, or should there be zero block? */
-            xSemaphoreTake( *m, portMAX_DELAY );
-            return 0;
-        }
-
-        int UnLockMutex(wolfSSL_Mutex* m)
-        {
-            xSemaphoreGive( *m );
-            return 0;
-        }
-
-    #elif defined(WOLFSSL_SAFERTOS)
-
-        int InitMutex(wolfSSL_Mutex* m)
-        {
-            vSemaphoreCreateBinary(m->mutexBuffer, m->mutex);
-            if (m->mutex == NULL)
-                return BAD_MUTEX_E;
-
-            return 0;
-        }
-
-        int FreeMutex(wolfSSL_Mutex* m)
-        {
-            (void)m;
-            return 0;
-        }
-
-        int LockMutex(wolfSSL_Mutex* m)
-        {
-            /* Assume an infinite block */
-            xSemaphoreTake(m->mutex, portMAX_DELAY);
-            return 0;
-        }
-
-        int UnLockMutex(wolfSSL_Mutex* m)
-        {
-            xSemaphoreGive(m->mutex);
-            return 0;
-        }
-
-
-    #elif defined(USE_WINDOWS_API)
-
-        int InitMutex(wolfSSL_Mutex* m)
-        {
-            InitializeCriticalSection(m);
-            return 0;
-        }
-
-
-        int FreeMutex(wolfSSL_Mutex* m)
-        {
-            DeleteCriticalSection(m);
-            return 0;
-        }
-
-
-        int LockMutex(wolfSSL_Mutex* m)
-        {
-            EnterCriticalSection(m);
-            return 0;
-        }
-
-
-        int UnLockMutex(wolfSSL_Mutex* m)
-        {
-            LeaveCriticalSection(m);
-            return 0;
-        }
-
-    #elif defined(WOLFSSL_PTHREADS)
-
-        int InitMutex(wolfSSL_Mutex* m)
-        {
-            if (pthread_mutex_init(m, 0) == 0)
-                return 0;
-            else
-                return BAD_MUTEX_E;
-        }
-
-
-        int FreeMutex(wolfSSL_Mutex* m)
-        {
-            if (pthread_mutex_destroy(m) == 0)
-                return 0;
-            else
-                return BAD_MUTEX_E;
-        }
-
-
-        int LockMutex(wolfSSL_Mutex* m)
-        {
-            if (pthread_mutex_lock(m) == 0)
-                return 0;
-            else
-                return BAD_MUTEX_E;
-        }
-
-
-        int UnLockMutex(wolfSSL_Mutex* m)
-        {
-            if (pthread_mutex_unlock(m) == 0)
-                return 0;
-            else
-                return BAD_MUTEX_E;
-        }
-
-    #elif defined(THREADX)
-
-        int InitMutex(wolfSSL_Mutex* m)
-        {
-            if (tx_mutex_create(m, "wolfSSL Mutex", TX_NO_INHERIT) == 0)
-                return 0;
-            else
-                return BAD_MUTEX_E;
-        }
-
-
-        int FreeMutex(wolfSSL_Mutex* m)
-        {
-            if (tx_mutex_delete(m) == 0)
-                return 0;
-            else
-                return BAD_MUTEX_E;
-        }
-
-
-        int LockMutex(wolfSSL_Mutex* m)
-        {
-            if (tx_mutex_get(m, TX_WAIT_FOREVER) == 0)
-                return 0;
-            else
-                return BAD_MUTEX_E;
-        }
-
-
-        int UnLockMutex(wolfSSL_Mutex* m)
-        {
-            if (tx_mutex_put(m) == 0)
-                return 0;
-            else
-                return BAD_MUTEX_E;
-        }
-
-    #elif defined(MICRIUM)
-
-        int InitMutex(wolfSSL_Mutex* m)
-        {
-            #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
-                if (NetSecure_OS_MutexCreate(m) == 0)
-                    return 0;
-                else
-                    return BAD_MUTEX_E;
-            #else
-                return 0;
-            #endif
-        }
-
-
-        int FreeMutex(wolfSSL_Mutex* m)
-        {
-            #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
-                if (NetSecure_OS_FreeMutex(m) == 0)
-                    return 0;
-                else
-                    return BAD_MUTEX_E;
-            #else
-                return 0;
-            #endif
-        }
-
-
-        int LockMutex(wolfSSL_Mutex* m)
-        {
-            #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
-                if (NetSecure_OS_LockMutex(m) == 0)
-                    return 0;
-                else
-                    return BAD_MUTEX_E;
-            #else
-                return 0;
-            #endif
-        }
-
-
-        int UnLockMutex(wolfSSL_Mutex* m)
-        {
-            #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
-                if (NetSecure_OS_UnLockMutex(m) == 0)
-                    return 0;
-                else
-                    return BAD_MUTEX_E;
-            #else
-                return 0;
-            #endif
-
-        }
-
-    #elif defined(EBSNET)
-
-        int InitMutex(wolfSSL_Mutex* m)
-        {
-            if (rtp_sig_mutex_alloc(m, "wolfSSL Mutex") == -1)
-                return BAD_MUTEX_E;
-            else
-                return 0;
-        }
-
-        int FreeMutex(wolfSSL_Mutex* m)
-        {
-            rtp_sig_mutex_free(*m);
-            return 0;
-        }
-
-        int LockMutex(wolfSSL_Mutex* m)
-        {
-            if (rtp_sig_mutex_claim_timed(*m, RTIP_INF) == 0)
-                return 0;
-            else
-                return BAD_MUTEX_E;
-        }
-
-        int UnLockMutex(wolfSSL_Mutex* m)
-        {
-            rtp_sig_mutex_release(*m);
-            return 0;
-        }
-
-    #elif defined(FREESCALE_MQX)
-
-        int InitMutex(wolfSSL_Mutex* m)
-        {
-            if (_mutex_init(m, NULL) == MQX_EOK)
-                return 0;
-            else
-                return BAD_MUTEX_E;
-        }
-
-        int FreeMutex(wolfSSL_Mutex* m)
-        {
-            if (_mutex_destroy(m) == MQX_EOK)
-                return 0;
-            else
-                return BAD_MUTEX_E;
-        }
-
-        int LockMutex(wolfSSL_Mutex* m)
-        {
-            if (_mutex_lock(m) == MQX_EOK)
-                return 0;
-            else
-                return BAD_MUTEX_E;
-        }
-
-        int UnLockMutex(wolfSSL_Mutex* m)
-        {
-            if (_mutex_unlock(m) == MQX_EOK)
-                return 0;
-            else
-                return BAD_MUTEX_E;
-        }
-
-    #elif defined (WOLFSSL_TIRTOS)
-
-        int InitMutex(wolfSSL_Mutex* m)
-        {
-           Semaphore_Params params;
-
-           Semaphore_Params_init(¶ms);
-           params.mode = Semaphore_Mode_BINARY;
-
-           *m = Semaphore_create(1, ¶ms, NULL);
-
-           return 0;
-        }
-
-        int FreeMutex(wolfSSL_Mutex* m)
-        {
-            Semaphore_delete(m);
-
-            return 0;
-        }
-
-        int LockMutex(wolfSSL_Mutex* m)
-        {
-            Semaphore_pend(*m, BIOS_WAIT_FOREVER);
-
-            return 0;
-        }
-
-        int UnLockMutex(wolfSSL_Mutex* m)
-        {
-            Semaphore_post(*m);
-
-            return 0;
-        }
-
-    #elif defined(WOLFSSL_uITRON4)
-        #include "kernel.h"
-        int InitMutex(wolfSSL_Mutex* m)
-        {
-            int iReturn;
-            m->sem.sematr  = TA_TFIFO ;
-            m->sem.isemcnt = 1 ;
-            m->sem.maxsem  = 1 ;
-            m->sem.name    = NULL ;
-
-            m->id = acre_sem(&m->sem);
-            if( m->id != NULL )
-                iReturn = 0;
-            else
-                iReturn = BAD_MUTEX_E;
-
-            return iReturn;
-        }
-
-        int FreeMutex(wolfSSL_Mutex* m)
-        {
-            del_sem( m->id );
-            return 0;
-        }
-
-        int LockMutex(wolfSSL_Mutex* m)
-        {
-            wai_sem(m->id);
-            return 0;
-        }
-
-        int UnLockMutex(wolfSSL_Mutex* m)
-        {
-            sig_sem(m->id);
-            return 0;
-        }
-
-        /****  uITRON malloc/free ***/
-        static ID ID_wolfssl_MPOOL = 0 ;
-        static T_CMPL wolfssl_MPOOL = {TA_TFIFO, 0, NULL, "wolfSSL_MPOOL"};
-
-        int uITRON4_minit(size_t poolsz) {
-            ER ercd;
-            wolfssl_MPOOL.mplsz = poolsz ;
-            ercd = acre_mpl(&wolfssl_MPOOL);
-            if (ercd > 0) {
-                ID_wolfssl_MPOOL = ercd;
-                return 0;
-            } else {
-                return -1;
-            }
-        }
-
-        void *uITRON4_malloc(size_t sz) {
-            ER ercd;
-            void *p ;
-            ercd = get_mpl(ID_wolfssl_MPOOL, sz, (VP)&p);
-            if (ercd == E_OK) {
-                return p;
-            } else {
-                return 0 ;
-            }
-        }
-
-        void *uITRON4_realloc(void *p, size_t sz) {
-          ER ercd;
-          void *newp ;
-          if(p) {
-              ercd = get_mpl(ID_wolfssl_MPOOL, sz, (VP)&newp);
-              if (ercd == E_OK) {
-                  memcpy(newp, p, sz) ;
-                  ercd = rel_mpl(ID_wolfssl_MPOOL, (VP)p);
-                  if (ercd == E_OK) {
-                      return newp;
-                  }
-              }
-          }
-          return 0 ;
-        }
-
-        void uITRON4_free(void *p) {
-            ER ercd;
-            ercd = rel_mpl(ID_wolfssl_MPOOL, (VP)p);
-            if (ercd == E_OK) {
-                return ;
-            } else {
-                return ;
-            }
-        }
-
-#elif defined(WOLFSSL_uTKERNEL2)
-        #include "tk/tkernel.h"
-        int InitMutex(wolfSSL_Mutex* m)
-        {
-            int iReturn;
-            m->sem.sematr  = TA_TFIFO ;
-            m->sem.isemcnt = 1 ;
-            m->sem.maxsem  = 1 ;
-
-            m->id = tk_cre_sem(&m->sem);
-            if( m->id != NULL )
-                iReturn = 0;
-            else
-                iReturn = BAD_MUTEX_E;
-
-            return iReturn;
-        }
-
-        int FreeMutex(wolfSSL_Mutex* m)
-        {
-            tk_del_sem( m->id );
-            return 0;
-        }
-
-        int LockMutex(wolfSSL_Mutex* m)
-        {
-            tk_wai_sem(m->id, 1, TMO_FEVR);
-            return 0;
-        }
-
-        int UnLockMutex(wolfSSL_Mutex* m)
-        {
-            tk_sig_sem(m->id, 1);
-            return 0;
-        }
-
-        /****  uT-Kernel malloc/free ***/
-        static ID ID_wolfssl_MPOOL = 0 ;
-        static T_CMPL wolfssl_MPOOL =
-                     {(void *)NULL,
-        TA_TFIFO , 0,   "wolfSSL_MPOOL"};
-
-        int uTKernel_init_mpool(unsigned int sz) {
-            ER ercd;
-            wolfssl_MPOOL.mplsz = sz ;
-            ercd = tk_cre_mpl(&wolfssl_MPOOL);
-            if (ercd > 0) {
-                ID_wolfssl_MPOOL = ercd;
-                return 0;
-            } else {
-                return -1;
-            }
-        }
-
-        void *uTKernel_malloc(unsigned int sz) {
-            ER ercd;
-            void *p ;
-            ercd = tk_get_mpl(ID_wolfssl_MPOOL, sz, (VP)&p, TMO_FEVR);
-            if (ercd == E_OK) {
-                return p;
-            } else {
-                return 0 ;
-            }
-        }
-
-        void *uTKernel_realloc(void *p, unsigned int sz) {
-          ER ercd;
-          void *newp ;
-          if(p) {
-              ercd = tk_get_mpl(ID_wolfssl_MPOOL, sz, (VP)&newp, TMO_FEVR);
-              if (ercd == E_OK) {
-                  memcpy(newp, p, sz) ;
-                  ercd = tk_rel_mpl(ID_wolfssl_MPOOL, (VP)p);
-                  if (ercd == E_OK) {
-                      return newp;
-                  }
-              }
-          }
-          return 0 ;
-        }
-
-        void uTKernel_free(void *p) {
-            ER ercd;
-            ercd = tk_rel_mpl(ID_wolfssl_MPOOL, (VP)p);
-            if (ercd == E_OK) {
-                return ;
-            } else {
-                return ;
-            }
-        }
-
-    #elif defined(WOLFSSL_MDK_ARM)|| defined(WOLFSSL_CMSIS_RTOS)
-    
-        #if defined(WOLFSSL_CMSIS_RTOS)
-            #include "cmsis_os.h"
-            #define CMSIS_NMUTEX 10
-            osMutexDef(wolfSSL_mt0) ;  osMutexDef(wolfSSL_mt1) ;  osMutexDef(wolfSSL_mt2) ;
-            osMutexDef(wolfSSL_mt3) ;  osMutexDef(wolfSSL_mt4) ;  osMutexDef(wolfSSL_mt5) ;  
-            osMutexDef(wolfSSL_mt6) ;  osMutexDef(wolfSSL_mt7) ;  osMutexDef(wolfSSL_mt8) ;  
-            osMutexDef(wolfSSL_mt9) ;  
-            
-            static const osMutexDef_t *CMSIS_mutex[] = { osMutex(wolfSSL_mt0),   
-                osMutex(wolfSSL_mt1),    osMutex(wolfSSL_mt2),   osMutex(wolfSSL_mt3),    
-                osMutex(wolfSSL_mt4),    osMutex(wolfSSL_mt5),   osMutex(wolfSSL_mt6),
-                osMutex(wolfSSL_mt7),    osMutex(wolfSSL_mt8),    osMutex(wolfSSL_mt9) } ;                 
-            
-            static osMutexId CMSIS_mutexID[CMSIS_NMUTEX] = {0} ;
-
-            int InitMutex(wolfSSL_Mutex* m)
-            {
-                int i ;
-                for (i=0; i  /* initialize and Mutex for TI Crypt Engine */
-    #include  /* md5, sha1, sha224, sha256 */
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/include.am b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/include.am
deleted file mode 100755
index 950d7c6..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/include.am
+++ /dev/null
@@ -1,11 +0,0 @@
-# vim:ft=automake
-# All paths should be given relative to the root
-
-noinst_PROGRAMS+= wolfcrypt/test/testwolfcrypt
-wolfcrypt_test_testwolfcrypt_SOURCES      = wolfcrypt/test/test.c
-wolfcrypt_test_testwolfcrypt_LDADD        = src/libwolfssl.la
-wolfcrypt_test_testwolfcrypt_DEPENDENCIES = src/libwolfssl.la
-noinst_HEADERS += wolfcrypt/test/test.h
-EXTRA_DIST += wolfcrypt/test/test.sln
-EXTRA_DIST += wolfcrypt/test/test.vcproj
-DISTCLEANFILES+= wolfcrypt/test/.libs/testwolfcrypt
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/test.c b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/test.c
deleted file mode 100755
index cf5dbe5..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/test.c
+++ /dev/null
@@ -1,6239 +0,0 @@
-/* test.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#ifdef XMALLOC_USER
-    #include   /* we're using malloc / free direct here */
-#endif
-
-#ifndef NO_CRYPT_TEST
-
-#ifdef WOLFSSL_TEST_CERT
-    #include 
-#else
-    #include 
-#endif
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#ifdef HAVE_ECC
-    #include 
-#endif
-#ifdef HAVE_CURVE25519
-    #include 
-#endif
-#ifdef HAVE_ED25519
-    #include 
-#endif
-#ifdef HAVE_BLAKE2
-    #include 
-#endif
-#ifdef HAVE_LIBZ
-    #include 
-#endif
-#ifdef HAVE_PKCS7
-    #include 
-#endif
-#ifdef HAVE_FIPS
-    #include 
-#endif
-
-#ifdef _MSC_VER
-    /* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
-    #pragma warning(disable: 4996)
-#endif
-
-#ifdef OPENSSL_EXTRA
-    #include 
-    #include 
-    #include 
-    #include 
-#endif
-
-
-#if defined(USE_CERT_BUFFERS_1024) || defined(USE_CERT_BUFFERS_2048) \
-                                   || !defined(NO_DH)
-    /* include test cert and key buffers for use with NO_FILESYSTEM */
-    #if defined(WOLFSSL_MDK_ARM)
-        #include "cert_data.h"
-                        /* use certs_test.c for initial data, so other
-                                               commands can share the data. */
-    #else
-        #include 
-    #endif
-#endif
-
-#if defined(WOLFSSL_MDK_ARM)
-        #include 
-        #include 
-    extern FILE * wolfSSL_fopen(const char *fname, const char *mode) ;
-    #define fopen wolfSSL_fopen
-#endif
-
-#ifdef HAVE_NTRU
-    #include "ntru_crypto.h"
-#endif
-#ifdef HAVE_CAVIUM
-    #include "cavium_sysdep.h"
-    #include "cavium_common.h"
-    #include "cavium_ioctl.h"
-#endif
-
-#ifdef FREESCALE_MQX
-    #include 
-    #include 
-    #include 
-#else
-    #include 
-#endif
-
-
-#ifdef THREADX
-    /* since just testing, use THREADX log printf instead */
-    int dc_log_printf(char*, ...);
-        #undef printf
-        #define printf dc_log_printf
-#endif
-
-#include "wolfcrypt/test/test.h"
-
-
-typedef struct testVector {
-    const char*  input;
-    const char*  output;
-    size_t inLen;
-    size_t outLen;
-} testVector;
-
-int  md2_test(void);
-int  md5_test(void);
-int  md4_test(void);
-int  sha_test(void);
-int  sha256_test(void);
-int  sha512_test(void);
-int  sha384_test(void);
-int  hmac_md5_test(void);
-int  hmac_sha_test(void);
-int  hmac_sha256_test(void);
-int  hmac_sha384_test(void);
-int  hmac_sha512_test(void);
-int  hmac_blake2b_test(void);
-int  hkdf_test(void);
-int  arc4_test(void);
-int  hc128_test(void);
-int  rabbit_test(void);
-int  chacha_test(void);
-int  chacha20_poly1305_aead_test(void);
-int  des_test(void);
-int  des3_test(void);
-int  aes_test(void);
-int  poly1305_test(void);
-int  aesgcm_test(void);
-int  gmac_test(void);
-int  aesccm_test(void);
-int  camellia_test(void);
-int  rsa_test(void);
-int  dh_test(void);
-int  dsa_test(void);
-int  random_test(void);
-int  pwdbased_test(void);
-int  ripemd_test(void);
-int  openssl_test(void);   /* test mini api */
-int pbkdf1_test(void);
-int pkcs12_test(void);
-int pbkdf2_test(void);
-#ifdef HAVE_ECC
-    int  ecc_test(void);
-    #ifdef HAVE_ECC_ENCRYPT
-        int  ecc_encrypt_test(void);
-    #endif
-#endif
-#ifdef HAVE_CURVE25519
-    int  curve25519_test(void);
-#endif
-#ifdef HAVE_ED25519
-    int  ed25519_test(void);
-#endif
-#ifdef HAVE_BLAKE2
-    int  blake2b_test(void);
-#endif
-#ifdef HAVE_LIBZ
-    int compress_test(void);
-#endif
-#ifdef HAVE_PKCS7
-    int pkcs7enveloped_test(void);
-    int pkcs7signed_test(void);
-#endif
-
-
-/* General big buffer size for many tests. */ 
-#define FOURK_BUF 4096
-
-
-static int err_sys(const char* msg, int es)
-
-{
-    printf("%s error = %d\n", msg, es);
-    return -1; /* error state */
-}
-
-/* func_args from test.h, so don't have to pull in other junk */
-typedef struct func_args {
-    int    argc;
-    char** argv;
-    int    return_code;
-} func_args;
-
-
-#ifdef HAVE_FIPS
-
-static void myFipsCb(int ok, int err, const char* hash)
-{
-    printf("in my Fips callback, ok = %d, err = %d\n", ok, err);
-    printf("message = %s\n", wc_GetErrorString(err));
-    printf("hash = %s\n", hash);
-
-    if (err == IN_CORE_FIPS_E) {
-        printf("In core integrity hash check failure, copy above hash\n");
-        printf("into verifyCore[] in fips_test.c and rebuild\n");
-    }
-}
-
-#endif /* HAVE_FIPS */
-
-
-int wolfcrypt_test(void* args)
-{
-    int ret = 0;
-
-    ((func_args*)args)->return_code = -1; /* error state */
-
-#ifdef HAVE_FIPS
-    wolfCrypt_SetCb_fips(myFipsCb);
-#endif
-
-#if !defined(NO_BIG_INT)
-    if (CheckCtcSettings() != 1)
-        return err_sys("Build vs runtime math mismatch\n", -1234);
-
-#ifdef USE_FAST_MATH
-    if (CheckFastMathSettings() != 1)
-        return err_sys("Build vs runtime fastmath FP_MAX_BITS mismatch\n",
-                       -1235);
-#endif /* USE_FAST_MATH */
-#endif /* !NO_BIG_INT */
-
-
-#ifndef NO_MD5
-    if ( (ret = md5_test()) != 0)
-        return err_sys("MD5      test failed!\n", ret);
-    else
-        printf( "MD5      test passed!\n");
-#endif
-
-#ifdef WOLFSSL_MD2
-    if ( (ret = md2_test()) != 0)
-        return err_sys("MD2      test failed!\n", ret);
-    else
-        printf( "MD2      test passed!\n");
-#endif
-
-#ifndef NO_MD4
-    if ( (ret = md4_test()) != 0)
-        return err_sys("MD4      test failed!\n", ret);
-    else
-        printf( "MD4      test passed!\n");
-#endif
-
-#ifndef NO_SHA
-    if ( (ret = sha_test()) != 0)
-        return err_sys("SHA      test failed!\n", ret);
-    else
-        printf( "SHA      test passed!\n");
-#endif
-
-#ifndef NO_SHA256
-    if ( (ret = sha256_test()) != 0)
-        return err_sys("SHA-256  test failed!\n", ret);
-    else
-        printf( "SHA-256  test passed!\n");
-#endif
-
-#ifdef WOLFSSL_SHA384
-    if ( (ret = sha384_test()) != 0)
-        return err_sys("SHA-384  test failed!\n", ret);
-    else
-        printf( "SHA-384  test passed!\n");
-#endif
-
-#ifdef WOLFSSL_SHA512
-    if ( (ret = sha512_test()) != 0)
-        return err_sys("SHA-512  test failed!\n", ret);
-    else
-        printf( "SHA-512  test passed!\n");
-#endif
-
-#ifdef WOLFSSL_RIPEMD
-    if ( (ret = ripemd_test()) != 0)
-        return err_sys("RIPEMD   test failed!\n", ret);
-    else
-        printf( "RIPEMD   test passed!\n");
-#endif
-
-#ifdef HAVE_BLAKE2
-    if ( (ret = blake2b_test()) != 0)
-        return err_sys("BLAKE2b  test failed!\n", ret);
-    else
-        printf( "BLAKE2b  test passed!\n");
-#endif
-
-#ifndef NO_HMAC
-    #ifndef NO_MD5
-        if ( (ret = hmac_md5_test()) != 0)
-            return err_sys("HMAC-MD5 test failed!\n", ret);
-        else
-            printf( "HMAC-MD5 test passed!\n");
-    #endif
-
-    #ifndef NO_SHA
-    if ( (ret = hmac_sha_test()) != 0)
-        return err_sys("HMAC-SHA test failed!\n", ret);
-    else
-        printf( "HMAC-SHA test passed!\n");
-    #endif
-
-    #ifndef NO_SHA256
-        if ( (ret = hmac_sha256_test()) != 0)
-            return err_sys("HMAC-SHA256 test failed!\n", ret);
-        else
-            printf( "HMAC-SHA256 test passed!\n");
-    #endif
-
-    #ifdef WOLFSSL_SHA384
-        if ( (ret = hmac_sha384_test()) != 0)
-            return err_sys("HMAC-SHA384 test failed!\n", ret);
-        else
-            printf( "HMAC-SHA384 test passed!\n");
-    #endif
-
-    #ifdef WOLFSSL_SHA512
-        if ( (ret = hmac_sha512_test()) != 0)
-            return err_sys("HMAC-SHA512 test failed!\n", ret);
-        else
-            printf( "HMAC-SHA512 test passed!\n");
-    #endif
-
-    #ifdef HAVE_BLAKE2
-        if ( (ret = hmac_blake2b_test()) != 0)
-            return err_sys("HMAC-BLAKE2 test failed!\n", ret);
-        else
-            printf( "HMAC-BLAKE2 test passed!\n");
-    #endif
-
-    #ifdef HAVE_HKDF
-        if ( (ret = hkdf_test()) != 0)
-            return err_sys("HMAC-KDF    test failed!\n", ret);
-        else
-            printf( "HMAC-KDF    test passed!\n");
-    #endif
-
-#endif
-
-#ifdef HAVE_AESGCM
-    if ( (ret = gmac_test()) != 0)
-        return err_sys("GMAC     test passed!\n", ret);
-    else
-        printf( "GMAC     test passed!\n");
-#endif
-
-#ifndef NO_RC4
-    if ( (ret = arc4_test()) != 0)
-        return err_sys("ARC4     test failed!\n", ret);
-    else
-        printf( "ARC4     test passed!\n");
-#endif
-
-#ifndef NO_HC128
-    if ( (ret = hc128_test()) != 0)
-        return err_sys("HC-128   test failed!\n", ret);
-    else
-        printf( "HC-128   test passed!\n");
-#endif
-
-#ifndef NO_RABBIT
-    if ( (ret = rabbit_test()) != 0)
-        return err_sys("Rabbit   test failed!\n", ret);
-    else
-        printf( "Rabbit   test passed!\n");
-#endif
-
-#ifdef HAVE_CHACHA
-    if ( (ret = chacha_test()) != 0)
-        return err_sys("Chacha   test failed!\n", ret);
-    else
-        printf( "Chacha   test passed!\n");
-#endif
-
-#ifdef HAVE_POLY1305
-    if ( (ret = poly1305_test()) != 0)
-        return err_sys("POLY1305 test failed!\n", ret);
-    else
-        printf( "POLY1305 test passed!\n");
-#endif
-
-#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
-    if ( (ret = chacha20_poly1305_aead_test()) != 0)
-        return err_sys("ChaCha20-Poly1305 AEAD test failed!\n", ret);
-    else
-        printf( "ChaCha20-Poly1305 AEAD test passed!\n");
-#endif
-
-#ifndef NO_DES3
-    if ( (ret = des_test()) != 0)
-        return err_sys("DES      test failed!\n", ret);
-    else
-        printf( "DES      test passed!\n");
-#endif
-
-#ifndef NO_DES3
-    if ( (ret = des3_test()) != 0)
-        return err_sys("DES3     test failed!\n", ret);
-    else
-        printf( "DES3     test passed!\n");
-#endif
-
-#ifndef NO_AES
-    if ( (ret = aes_test()) != 0)
-        return err_sys("AES      test failed!\n", ret);
-    else
-        printf( "AES      test passed!\n");
-
-#ifdef HAVE_AESGCM
-    if ( (ret = aesgcm_test()) != 0)
-        return err_sys("AES-GCM  test failed!\n", ret);
-    else
-        printf( "AES-GCM  test passed!\n");
-#endif
-
-#ifdef HAVE_AESCCM
-    if ( (ret = aesccm_test()) != 0)
-        return err_sys("AES-CCM  test failed!\n", ret);
-    else
-        printf( "AES-CCM  test passed!\n");
-#endif
-#endif
-
-#ifdef HAVE_CAMELLIA
-    if ( (ret = camellia_test()) != 0)
-        return err_sys("CAMELLIA test failed!\n", ret);
-    else
-        printf( "CAMELLIA test passed!\n");
-#endif
-
-    if ( (ret = random_test()) != 0)
-        return err_sys("RANDOM   test failed!\n", ret);
-    else
-        printf( "RANDOM   test passed!\n");
-
-#ifndef NO_RSA
-    if ( (ret = rsa_test()) != 0)
-        return err_sys("RSA      test failed!\n", ret);
-    else
-        printf( "RSA      test passed!\n");
-#endif
-
-#ifndef NO_DH
-    if ( (ret = dh_test()) != 0)
-        return err_sys("DH       test failed!\n", ret);
-    else
-        printf( "DH       test passed!\n");
-#endif
-
-#ifndef NO_DSA
-    if ( (ret = dsa_test()) != 0)
-        return err_sys("DSA      test failed!\n", ret);
-    else
-        printf( "DSA      test passed!\n");
-#endif
-
-#ifndef NO_PWDBASED
-    if ( (ret = pwdbased_test()) != 0)
-        return err_sys("PWDBASED test failed!\n", ret);
-    else
-        printf( "PWDBASED test passed!\n");
-#endif
-
-#ifdef OPENSSL_EXTRA
-    if ( (ret = openssl_test()) != 0)
-        return err_sys("OPENSSL  test failed!\n", ret);
-    else
-        printf( "OPENSSL  test passed!\n");
-#endif
-
-#ifdef HAVE_ECC
-    if ( (ret = ecc_test()) != 0)
-        return err_sys("ECC      test failed!\n", ret);
-    else
-        printf( "ECC      test passed!\n");
-    #ifdef HAVE_ECC_ENCRYPT
-        if ( (ret = ecc_encrypt_test()) != 0)
-            return err_sys("ECC Enc  test failed!\n", ret);
-        else
-            printf( "ECC Enc  test passed!\n");
-    #endif
-#endif
-
-#ifdef HAVE_CURVE25519
-    if ( (ret = curve25519_test()) != 0)
-        return err_sys("CURVE25519 test failed!\n", ret);
-    else
-        printf( "CURVE25519 test passed!\n");
-#endif
-
-#ifdef HAVE_ED25519
-    if ( (ret = ed25519_test()) != 0)
-        return err_sys("ED25519  test failed!\n", ret);
-    else
-        printf( "ED25519  test passed!\n");
-#endif
-
-#ifdef HAVE_LIBZ
-    if ( (ret = compress_test()) != 0)
-        return err_sys("COMPRESS test failed!\n", ret);
-    else
-        printf( "COMPRESS test passed!\n");
-#endif
-
-#ifdef HAVE_PKCS7
-    if ( (ret = pkcs7enveloped_test()) != 0)
-        return err_sys("PKCS7enveloped test failed!\n", ret);
-    else
-        printf( "PKCS7enveloped test passed!\n");
-
-    if ( (ret = pkcs7signed_test()) != 0)
-        return err_sys("PKCS7signed    test failed!\n", ret);
-    else
-        printf( "PKCS7signed    test passed!\n");
-#endif
-
-    ((func_args*)args)->return_code = ret;
-
-    return ret;
-}
-
-
-#ifndef NO_MAIN_DRIVER
-
-#ifdef HAVE_CAVIUM
-
-static int OpenNitroxDevice(int dma_mode,int dev_id)
-{
-   Csp1CoreAssignment core_assign;
-   Uint32             device;
-
-   if (CspInitialize(CAVIUM_DIRECT,CAVIUM_DEV_ID))
-      return -1;
-   if (Csp1GetDevType(&device))
-      return -1;
-   if (device != NPX_DEVICE) {
-      if (ioctl(gpkpdev_hdlr[CAVIUM_DEV_ID], IOCTL_CSP1_GET_CORE_ASSIGNMENT,
-                (Uint32 *)&core_assign)!= 0)
-         return -1;
-   }
-   CspShutdown(CAVIUM_DEV_ID);
-
-   return CspInitialize(dma_mode, dev_id);
-}
-
-#endif /* HAVE_CAVIUM */
-
-    /* so overall tests can pull in test function */
-
-    int main(int argc, char** argv)
-    {
-
-        func_args args;
-
-
-#ifdef HAVE_CAVIUM
-        int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID);
-        if (ret != 0) {
-            err_sys("Cavium OpenNitroxDevice failed", -1236);
-            return -1236;
-        }
-#endif /* HAVE_CAVIUM */
-
-        args.argc = argc;
-        args.argv = argv;
-
-        wolfcrypt_test(&args);
-
-#ifdef HAVE_CAVIUM
-        CspShutdown(CAVIUM_DEV_ID);
-#endif
-
-        return args.return_code;
-    }
-
-#endif /* NO_MAIN_DRIVER */
-
-
-#ifdef WOLFSSL_MD2
-int md2_test()
-{
-    Md2  md2;
-    byte hash[MD2_DIGEST_SIZE];
-
-    testVector a, b, c, d, e, f, g;
-    testVector test_md2[7];
-    int times = sizeof(test_md2) / sizeof(testVector), i;
-
-    a.input  = "";
-    a.output = "\x83\x50\xe5\xa3\xe2\x4c\x15\x3d\xf2\x27\x5c\x9f\x80\x69"
-               "\x27\x73";
-    a.inLen  = strlen(a.input);
-    a.outLen = MD2_DIGEST_SIZE;
-
-    b.input  = "a";
-    b.output = "\x32\xec\x01\xec\x4a\x6d\xac\x72\xc0\xab\x96\xfb\x34\xc0"
-               "\xb5\xd1";
-    b.inLen  = strlen(b.input);
-    b.outLen = MD2_DIGEST_SIZE;
-
-    c.input  = "abc";
-    c.output = "\xda\x85\x3b\x0d\x3f\x88\xd9\x9b\x30\x28\x3a\x69\xe6\xde"
-               "\xd6\xbb";
-    c.inLen  = strlen(c.input);
-    c.outLen = MD2_DIGEST_SIZE;
-
-    d.input  = "message digest";
-    d.output = "\xab\x4f\x49\x6b\xfb\x2a\x53\x0b\x21\x9f\xf3\x30\x31\xfe"
-               "\x06\xb0";
-    d.inLen  = strlen(d.input);
-    d.outLen = MD2_DIGEST_SIZE;
-
-    e.input  = "abcdefghijklmnopqrstuvwxyz";
-    e.output = "\x4e\x8d\xdf\xf3\x65\x02\x92\xab\x5a\x41\x08\xc3\xaa\x47"
-               "\x94\x0b";
-    e.inLen  = strlen(e.input);
-    e.outLen = MD2_DIGEST_SIZE;
-
-    f.input  = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345"
-               "6789";
-    f.output = "\xda\x33\xde\xf2\xa4\x2d\xf1\x39\x75\x35\x28\x46\xc3\x03"
-               "\x38\xcd";
-    f.inLen  = strlen(f.input);
-    f.outLen = MD2_DIGEST_SIZE;
-
-    g.input  = "1234567890123456789012345678901234567890123456789012345678"
-               "9012345678901234567890";
-    g.output = "\xd5\x97\x6f\x79\xd8\x3d\x3a\x0d\xc9\x80\x6c\x3c\x66\xf3"
-               "\xef\xd8";
-    g.inLen  = strlen(g.input);
-    g.outLen = MD2_DIGEST_SIZE;
-
-    test_md2[0] = a;
-    test_md2[1] = b;
-    test_md2[2] = c;
-    test_md2[3] = d;
-    test_md2[4] = e;
-    test_md2[5] = f;
-    test_md2[6] = g;
-
-    wc_InitMd2(&md2);
-
-    for (i = 0; i < times; ++i) {
-        wc_Md2Update(&md2, (byte*)test_md2[i].input, (word32)test_md2[i].inLen);
-        wc_Md2Final(&md2, hash);
-
-        if (memcmp(hash, test_md2[i].output, MD2_DIGEST_SIZE) != 0)
-            return -155 - i;
-    }
-
-    return 0;
-}
-#endif
-
-#ifndef NO_MD5
-int md5_test(void)
-{
-    Md5  md5;
-    byte hash[MD5_DIGEST_SIZE];
-
-    testVector a, b, c, d, e;
-    testVector test_md5[5];
-    int times = sizeof(test_md5) / sizeof(testVector), i;
-
-    a.input  = "abc";
-    a.output = "\x90\x01\x50\x98\x3c\xd2\x4f\xb0\xd6\x96\x3f\x7d\x28\xe1\x7f"
-               "\x72";
-    a.inLen  = strlen(a.input);
-    a.outLen = MD5_DIGEST_SIZE;
-
-    b.input  = "message digest";
-    b.output = "\xf9\x6b\x69\x7d\x7c\xb7\x93\x8d\x52\x5a\x2f\x31\xaa\xf1\x61"
-               "\xd0";
-    b.inLen  = strlen(b.input);
-    b.outLen = MD5_DIGEST_SIZE;
-
-    c.input  = "abcdefghijklmnopqrstuvwxyz";
-    c.output = "\xc3\xfc\xd3\xd7\x61\x92\xe4\x00\x7d\xfb\x49\x6c\xca\x67\xe1"
-               "\x3b";
-    c.inLen  = strlen(c.input);
-    c.outLen = MD5_DIGEST_SIZE;
-
-    d.input  = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345"
-               "6789";
-    d.output = "\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d"
-               "\x9f";
-    d.inLen  = strlen(d.input);
-    d.outLen = MD5_DIGEST_SIZE;
-
-    e.input  = "1234567890123456789012345678901234567890123456789012345678"
-               "9012345678901234567890";
-    e.output = "\x57\xed\xf4\xa2\x2b\xe3\xc9\x55\xac\x49\xda\x2e\x21\x07\xb6"
-               "\x7a";
-    e.inLen  = strlen(e.input);
-    e.outLen = MD5_DIGEST_SIZE;
-
-    test_md5[0] = a;
-    test_md5[1] = b;
-    test_md5[2] = c;
-    test_md5[3] = d;
-    test_md5[4] = e;
-
-    wc_InitMd5(&md5);
-
-    for (i = 0; i < times; ++i) {
-        wc_Md5Update(&md5, (byte*)test_md5[i].input, (word32)test_md5[i].inLen);
-        wc_Md5Final(&md5, hash);
-
-        if (memcmp(hash, test_md5[i].output, MD5_DIGEST_SIZE) != 0)
-            return -5 - i;
-    }
-
-    return 0;
-}
-#endif /* NO_MD5 */
-
-
-#ifndef NO_MD4
-
-int md4_test(void)
-{
-    Md4  md4;
-    byte hash[MD4_DIGEST_SIZE];
-
-    testVector a, b, c, d, e, f, g;
-    testVector test_md4[7];
-    int times = sizeof(test_md4) / sizeof(testVector), i;
-
-    a.input  = "";
-    a.output = "\x31\xd6\xcf\xe0\xd1\x6a\xe9\x31\xb7\x3c\x59\xd7\xe0\xc0\x89"
-               "\xc0";
-    a.inLen  = strlen(a.input);
-    a.outLen = MD4_DIGEST_SIZE;
-
-    b.input  = "a";
-    b.output = "\xbd\xe5\x2c\xb3\x1d\xe3\x3e\x46\x24\x5e\x05\xfb\xdb\xd6\xfb"
-               "\x24";
-    b.inLen  = strlen(b.input);
-    b.outLen = MD4_DIGEST_SIZE;
-
-    c.input  = "abc";
-    c.output = "\xa4\x48\x01\x7a\xaf\x21\xd8\x52\x5f\xc1\x0a\xe8\x7a\xa6\x72"
-               "\x9d";
-    c.inLen  = strlen(c.input);
-    c.outLen = MD4_DIGEST_SIZE;
-
-    d.input  = "message digest";
-    d.output = "\xd9\x13\x0a\x81\x64\x54\x9f\xe8\x18\x87\x48\x06\xe1\xc7\x01"
-               "\x4b";
-    d.inLen  = strlen(d.input);
-    d.outLen = MD4_DIGEST_SIZE;
-
-    e.input  = "abcdefghijklmnopqrstuvwxyz";
-    e.output = "\xd7\x9e\x1c\x30\x8a\xa5\xbb\xcd\xee\xa8\xed\x63\xdf\x41\x2d"
-               "\xa9";
-    e.inLen  = strlen(e.input);
-    e.outLen = MD4_DIGEST_SIZE;
-
-    f.input  = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345"
-               "6789";
-    f.output = "\x04\x3f\x85\x82\xf2\x41\xdb\x35\x1c\xe6\x27\xe1\x53\xe7\xf0"
-               "\xe4";
-    f.inLen  = strlen(f.input);
-    f.outLen = MD4_DIGEST_SIZE;
-
-    g.input  = "1234567890123456789012345678901234567890123456789012345678"
-               "9012345678901234567890";
-    g.output = "\xe3\x3b\x4d\xdc\x9c\x38\xf2\x19\x9c\x3e\x7b\x16\x4f\xcc\x05"
-               "\x36";
-    g.inLen  = strlen(g.input);
-    g.outLen = MD4_DIGEST_SIZE;
-
-    test_md4[0] = a;
-    test_md4[1] = b;
-    test_md4[2] = c;
-    test_md4[3] = d;
-    test_md4[4] = e;
-    test_md4[5] = f;
-    test_md4[6] = g;
-
-    wc_InitMd4(&md4);
-
-    for (i = 0; i < times; ++i) {
-        wc_Md4Update(&md4, (byte*)test_md4[i].input, (word32)test_md4[i].inLen);
-        wc_Md4Final(&md4, hash);
-
-        if (memcmp(hash, test_md4[i].output, MD4_DIGEST_SIZE) != 0)
-            return -205 - i;
-    }
-
-    return 0;
-}
-
-#endif /* NO_MD4 */
-
-#ifndef NO_SHA
-
-int sha_test(void)
-{
-    Sha  sha;
-    byte hash[SHA_DIGEST_SIZE];
-
-    testVector a, b, c, d;
-    testVector test_sha[4];
-    int ret;
-    int times = sizeof(test_sha) / sizeof(struct testVector), i;
-
-    a.input  = "abc";
-    a.output = "\xA9\x99\x3E\x36\x47\x06\x81\x6A\xBA\x3E\x25\x71\x78\x50\xC2"
-               "\x6C\x9C\xD0\xD8\x9D";
-    a.inLen  = strlen(a.input);
-    a.outLen = SHA_DIGEST_SIZE;
-
-    b.input  = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
-    b.output = "\x84\x98\x3E\x44\x1C\x3B\xD2\x6E\xBA\xAE\x4A\xA1\xF9\x51\x29"
-               "\xE5\xE5\x46\x70\xF1";
-    b.inLen  = strlen(b.input);
-    b.outLen = SHA_DIGEST_SIZE;
-
-    c.input  = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-               "aaaaaa";
-    c.output = "\x00\x98\xBA\x82\x4B\x5C\x16\x42\x7B\xD7\xA1\x12\x2A\x5A\x44"
-               "\x2A\x25\xEC\x64\x4D";
-    c.inLen  = strlen(c.input);
-    c.outLen = SHA_DIGEST_SIZE;
-
-    d.input  = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-               "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-               "aaaaaaaaaa";
-    d.output = "\xAD\x5B\x3F\xDB\xCB\x52\x67\x78\xC2\x83\x9D\x2F\x15\x1E\xA7"
-               "\x53\x99\x5E\x26\xA0";
-    d.inLen  = strlen(d.input);
-    d.outLen = SHA_DIGEST_SIZE;
-
-    test_sha[0] = a;
-    test_sha[1] = b;
-    test_sha[2] = c;
-    test_sha[3] = d;
-
-    ret = wc_InitSha(&sha);
-    if (ret != 0)
-        return -4001;
-
-    for (i = 0; i < times; ++i) {
-        wc_ShaUpdate(&sha, (byte*)test_sha[i].input, (word32)test_sha[i].inLen);
-        wc_ShaFinal(&sha, hash);
-
-        if (memcmp(hash, test_sha[i].output, SHA_DIGEST_SIZE) != 0)
-            return -10 - i;
-    }
-
-    return 0;
-}
-
-#endif /* NO_SHA */
-
-#ifdef WOLFSSL_RIPEMD
-int ripemd_test(void)
-{
-    RipeMd  ripemd;
-    byte hash[RIPEMD_DIGEST_SIZE];
-
-    testVector a, b, c, d;
-    testVector test_ripemd[4];
-    int times = sizeof(test_ripemd) / sizeof(struct testVector), i;
-
-    a.input  = "abc";
-    a.output = "\x8e\xb2\x08\xf7\xe0\x5d\x98\x7a\x9b\x04\x4a\x8e\x98\xc6"
-               "\xb0\x87\xf1\x5a\x0b\xfc";
-    a.inLen  = strlen(a.input);
-    a.outLen = RIPEMD_DIGEST_SIZE;
-
-    b.input  = "message digest";
-    b.output = "\x5d\x06\x89\xef\x49\xd2\xfa\xe5\x72\xb8\x81\xb1\x23\xa8"
-               "\x5f\xfa\x21\x59\x5f\x36";
-    b.inLen  = strlen(b.input);
-    b.outLen = RIPEMD_DIGEST_SIZE;
-
-    c.input  = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
-    c.output = "\x12\xa0\x53\x38\x4a\x9c\x0c\x88\xe4\x05\xa0\x6c\x27\xdc"
-               "\xf4\x9a\xda\x62\xeb\x2b";
-    c.inLen  = strlen(c.input);
-    c.outLen = RIPEMD_DIGEST_SIZE;
-
-    d.input  = "12345678901234567890123456789012345678901234567890123456"
-               "789012345678901234567890";
-    d.output = "\x9b\x75\x2e\x45\x57\x3d\x4b\x39\xf4\xdb\xd3\x32\x3c\xab"
-               "\x82\xbf\x63\x32\x6b\xfb";
-    d.inLen  = strlen(d.input);
-    d.outLen = RIPEMD_DIGEST_SIZE;
-
-    test_ripemd[0] = a;
-    test_ripemd[1] = b;
-    test_ripemd[2] = c;
-    test_ripemd[3] = d;
-
-    wc_InitRipeMd(&ripemd);
-
-    for (i = 0; i < times; ++i) {
-        wc_RipeMdUpdate(&ripemd, (byte*)test_ripemd[i].input,
-                     (word32)test_ripemd[i].inLen);
-        wc_RipeMdFinal(&ripemd, hash);
-
-        if (memcmp(hash, test_ripemd[i].output, RIPEMD_DIGEST_SIZE) != 0)
-            return -10 - i;
-    }
-
-    return 0;
-}
-#endif /* WOLFSSL_RIPEMD */
-
-
-#ifdef HAVE_BLAKE2
-
-
-#define BLAKE2_TESTS 3
-
-static const byte blake2b_vec[BLAKE2_TESTS][BLAKE2B_OUTBYTES] =
-{
-  {
-    0x78, 0x6A, 0x02, 0xF7, 0x42, 0x01, 0x59, 0x03,
-    0xC6, 0xC6, 0xFD, 0x85, 0x25, 0x52, 0xD2, 0x72,
-    0x91, 0x2F, 0x47, 0x40, 0xE1, 0x58, 0x47, 0x61,
-    0x8A, 0x86, 0xE2, 0x17, 0xF7, 0x1F, 0x54, 0x19,
-    0xD2, 0x5E, 0x10, 0x31, 0xAF, 0xEE, 0x58, 0x53,
-    0x13, 0x89, 0x64, 0x44, 0x93, 0x4E, 0xB0, 0x4B,
-    0x90, 0x3A, 0x68, 0x5B, 0x14, 0x48, 0xB7, 0x55,
-    0xD5, 0x6F, 0x70, 0x1A, 0xFE, 0x9B, 0xE2, 0xCE
-  },
-  {
-    0x2F, 0xA3, 0xF6, 0x86, 0xDF, 0x87, 0x69, 0x95,
-    0x16, 0x7E, 0x7C, 0x2E, 0x5D, 0x74, 0xC4, 0xC7,
-    0xB6, 0xE4, 0x8F, 0x80, 0x68, 0xFE, 0x0E, 0x44,
-    0x20, 0x83, 0x44, 0xD4, 0x80, 0xF7, 0x90, 0x4C,
-    0x36, 0x96, 0x3E, 0x44, 0x11, 0x5F, 0xE3, 0xEB,
-    0x2A, 0x3A, 0xC8, 0x69, 0x4C, 0x28, 0xBC, 0xB4,
-    0xF5, 0xA0, 0xF3, 0x27, 0x6F, 0x2E, 0x79, 0x48,
-    0x7D, 0x82, 0x19, 0x05, 0x7A, 0x50, 0x6E, 0x4B
-  },
-  {
-    0x1C, 0x08, 0x79, 0x8D, 0xC6, 0x41, 0xAB, 0xA9,
-    0xDE, 0xE4, 0x35, 0xE2, 0x25, 0x19, 0xA4, 0x72,
-    0x9A, 0x09, 0xB2, 0xBF, 0xE0, 0xFF, 0x00, 0xEF,
-    0x2D, 0xCD, 0x8E, 0xD6, 0xF8, 0xA0, 0x7D, 0x15,
-    0xEA, 0xF4, 0xAE, 0xE5, 0x2B, 0xBF, 0x18, 0xAB,
-    0x56, 0x08, 0xA6, 0x19, 0x0F, 0x70, 0xB9, 0x04,
-    0x86, 0xC8, 0xA7, 0xD4, 0x87, 0x37, 0x10, 0xB1,
-    0x11, 0x5D, 0x3D, 0xEB, 0xBB, 0x43, 0x27, 0xB5
-  }
-};
-
-
-
-int blake2b_test(void)
-{
-    Blake2b b2b;
-    byte    digest[64];
-    byte    input[64];
-    int     i, ret;
-
-    for (i = 0; i < (int)sizeof(input); i++)
-        input[i] = (byte)i;
-
-    for (i = 0; i < BLAKE2_TESTS; i++) {
-        ret = wc_InitBlake2b(&b2b, 64);
-        if (ret != 0)
-            return -4002;
-
-        ret = wc_Blake2bUpdate(&b2b, input, i);
-        if (ret != 0)
-            return -4003;
-
-        ret = wc_Blake2bFinal(&b2b, digest, 64);
-        if (ret != 0)
-            return -4004;
-
-        if (memcmp(digest, blake2b_vec[i], 64) != 0) {
-            return -300 - i;
-        }
-    }
-
-    return 0;
-}
-#endif /* HAVE_BLAKE2 */
-
-
-#ifndef NO_SHA256
-int sha256_test(void)
-{
-    Sha256 sha;
-    byte   hash[SHA256_DIGEST_SIZE];
-
-    testVector a, b;
-    testVector test_sha[2];
-    int ret;
-    int times = sizeof(test_sha) / sizeof(struct testVector), i;
-
-    a.input  = "abc";
-    a.output = "\xBA\x78\x16\xBF\x8F\x01\xCF\xEA\x41\x41\x40\xDE\x5D\xAE\x22"
-               "\x23\xB0\x03\x61\xA3\x96\x17\x7A\x9C\xB4\x10\xFF\x61\xF2\x00"
-               "\x15\xAD";
-    a.inLen  = strlen(a.input);
-    a.outLen = SHA256_DIGEST_SIZE;
-
-    b.input  = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
-    b.output = "\x24\x8D\x6A\x61\xD2\x06\x38\xB8\xE5\xC0\x26\x93\x0C\x3E\x60"
-               "\x39\xA3\x3C\xE4\x59\x64\xFF\x21\x67\xF6\xEC\xED\xD4\x19\xDB"
-               "\x06\xC1";
-    b.inLen  = strlen(b.input);
-    b.outLen = SHA256_DIGEST_SIZE;
-
-    test_sha[0] = a;
-    test_sha[1] = b;
-
-    ret = wc_InitSha256(&sha);
-    if (ret != 0)
-        return -4005;
-
-    for (i = 0; i < times; ++i) {
-        ret = wc_Sha256Update(&sha, (byte*)test_sha[i].input,(word32)test_sha[i].inLen);
-        if (ret != 0)
-            return -4006;
-        ret = wc_Sha256Final(&sha, hash);
-        if (ret != 0)
-            return -4007;
-
-        if (memcmp(hash, test_sha[i].output, SHA256_DIGEST_SIZE) != 0)
-            return -10 - i;
-    }
-
-    return 0;
-}
-#endif
-
-
-#ifdef WOLFSSL_SHA512
-int sha512_test(void)
-{
-    Sha512 sha;
-    byte   hash[SHA512_DIGEST_SIZE];
-    int    ret;
-
-    testVector a, b;
-    testVector test_sha[2];
-    int times = sizeof(test_sha) / sizeof(struct testVector), i;
-
-    a.input  = "abc";
-    a.output = "\xdd\xaf\x35\xa1\x93\x61\x7a\xba\xcc\x41\x73\x49\xae\x20\x41"
-               "\x31\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2\x0a\x9e\xee\xe6\x4b\x55"
-               "\xd3\x9a\x21\x92\x99\x2a\x27\x4f\xc1\xa8\x36\xba\x3c\x23\xa3"
-               "\xfe\xeb\xbd\x45\x4d\x44\x23\x64\x3c\xe8\x0e\x2a\x9a\xc9\x4f"
-               "\xa5\x4c\xa4\x9f";
-    a.inLen  = strlen(a.input);
-    a.outLen = SHA512_DIGEST_SIZE;
-
-    b.input  = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi"
-               "jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
-    b.output = "\x8e\x95\x9b\x75\xda\xe3\x13\xda\x8c\xf4\xf7\x28\x14\xfc\x14"
-               "\x3f\x8f\x77\x79\xc6\xeb\x9f\x7f\xa1\x72\x99\xae\xad\xb6\x88"
-               "\x90\x18\x50\x1d\x28\x9e\x49\x00\xf7\xe4\x33\x1b\x99\xde\xc4"
-               "\xb5\x43\x3a\xc7\xd3\x29\xee\xb6\xdd\x26\x54\x5e\x96\xe5\x5b"
-               "\x87\x4b\xe9\x09";
-    b.inLen  = strlen(b.input);
-    b.outLen = SHA512_DIGEST_SIZE;
-
-    test_sha[0] = a;
-    test_sha[1] = b;
-
-    ret = wc_InitSha512(&sha);
-    if (ret != 0)
-        return -4009;
-
-    for (i = 0; i < times; ++i) {
-        ret = wc_Sha512Update(&sha, (byte*)test_sha[i].input,(word32)test_sha[i].inLen);
-        if (ret != 0)
-            return -4010;
-
-        ret = wc_Sha512Final(&sha, hash);
-        if (ret != 0)
-            return -4011;
-
-        if (memcmp(hash, test_sha[i].output, SHA512_DIGEST_SIZE) != 0)
-            return -10 - i;
-    }
-
-    return 0;
-}
-#endif
-
-
-#ifdef WOLFSSL_SHA384
-int sha384_test(void)
-{
-    Sha384 sha;
-    byte   hash[SHA384_DIGEST_SIZE];
-    int    ret;
-
-    testVector a, b;
-    testVector test_sha[2];
-    int times = sizeof(test_sha) / sizeof(struct testVector), i;
-
-    a.input  = "abc";
-    a.output = "\xcb\x00\x75\x3f\x45\xa3\x5e\x8b\xb5\xa0\x3d\x69\x9a\xc6\x50"
-               "\x07\x27\x2c\x32\xab\x0e\xde\xd1\x63\x1a\x8b\x60\x5a\x43\xff"
-               "\x5b\xed\x80\x86\x07\x2b\xa1\xe7\xcc\x23\x58\xba\xec\xa1\x34"
-               "\xc8\x25\xa7";
-    a.inLen  = strlen(a.input);
-    a.outLen = SHA384_DIGEST_SIZE;
-
-    b.input  = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi"
-               "jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
-    b.output = "\x09\x33\x0c\x33\xf7\x11\x47\xe8\x3d\x19\x2f\xc7\x82\xcd\x1b"
-               "\x47\x53\x11\x1b\x17\x3b\x3b\x05\xd2\x2f\xa0\x80\x86\xe3\xb0"
-               "\xf7\x12\xfc\xc7\xc7\x1a\x55\x7e\x2d\xb9\x66\xc3\xe9\xfa\x91"
-               "\x74\x60\x39";
-    b.inLen  = strlen(b.input);
-    b.outLen = SHA384_DIGEST_SIZE;
-
-    test_sha[0] = a;
-    test_sha[1] = b;
-
-    ret = wc_InitSha384(&sha);
-    if (ret != 0)
-        return -4012;
-
-    for (i = 0; i < times; ++i) {
-        ret = wc_Sha384Update(&sha, (byte*)test_sha[i].input,(word32)test_sha[i].inLen);
-        if (ret != 0)
-            return -4013;
-
-        ret = wc_Sha384Final(&sha, hash);
-        if (ret != 0)
-            return -4014;
-
-        if (memcmp(hash, test_sha[i].output, SHA384_DIGEST_SIZE) != 0)
-            return -10 - i;
-    }
-
-    return 0;
-}
-#endif /* WOLFSSL_SHA384 */
-
-
-#if !defined(NO_HMAC) && !defined(NO_MD5)
-int hmac_md5_test(void)
-{
-    Hmac hmac;
-    byte hash[MD5_DIGEST_SIZE];
-
-    const char* keys[]=
-    {
-        "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
-        "Jefe",
-        "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
-    };
-
-    testVector a, b, c;
-    testVector test_hmac[3];
-
-    int ret;
-    int times = sizeof(test_hmac) / sizeof(testVector), i;
-
-    a.input  = "Hi There";
-    a.output = "\x92\x94\x72\x7a\x36\x38\xbb\x1c\x13\xf4\x8e\xf8\x15\x8b\xfc"
-               "\x9d";
-    a.inLen  = strlen(a.input);
-    a.outLen = MD5_DIGEST_SIZE;
-
-    b.input  = "what do ya want for nothing?";
-    b.output = "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7"
-               "\x38";
-    b.inLen  = strlen(b.input);
-    b.outLen = MD5_DIGEST_SIZE;
-
-    c.input  = "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD";
-    c.output = "\x56\xbe\x34\x52\x1d\x14\x4c\x88\xdb\xb8\xc7\x33\xf0\xe8\xb3"
-               "\xf6";
-    c.inLen  = strlen(c.input);
-    c.outLen = MD5_DIGEST_SIZE;
-
-    test_hmac[0] = a;
-    test_hmac[1] = b;
-    test_hmac[2] = c;
-
-    for (i = 0; i < times; ++i) {
-#if defined(HAVE_FIPS) || defined(HAVE_CAVIUM)
-        if (i == 1)
-            continue; /* cavium can't handle short keys, fips not allowed */
-#endif
-#ifdef HAVE_CAVIUM
-        if (wc_HmacInitCavium(&hmac, CAVIUM_DEV_ID) != 0)
-            return -20009;
-#endif
-        ret = wc_HmacSetKey(&hmac, MD5, (byte*)keys[i], (word32)strlen(keys[i]));
-        if (ret != 0)
-            return -4015;
-        ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
-                   (word32)test_hmac[i].inLen);
-        if (ret != 0)
-            return -4016;
-        ret = wc_HmacFinal(&hmac, hash);
-        if (ret != 0)
-            return -4017;
-
-        if (memcmp(hash, test_hmac[i].output, MD5_DIGEST_SIZE) != 0)
-            return -20 - i;
-#ifdef HAVE_CAVIUM
-        wc_HmacFreeCavium(&hmac);
-#endif
-    }
-
-    return 0;
-}
-#endif /* NO_HMAC && NO_MD5 */
-
-#if !defined(NO_HMAC) && !defined(NO_SHA)
-int hmac_sha_test(void)
-{
-    Hmac hmac;
-    byte hash[SHA_DIGEST_SIZE];
-
-    const char* keys[]=
-    {
-        "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
-                                                                "\x0b\x0b\x0b",
-        "Jefe",
-        "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
-                                                                "\xAA\xAA\xAA"
-    };
-
-    testVector a, b, c;
-    testVector test_hmac[3];
-
-    int ret;
-    int times = sizeof(test_hmac) / sizeof(testVector), i;
-
-    a.input  = "Hi There";
-    a.output = "\xb6\x17\x31\x86\x55\x05\x72\x64\xe2\x8b\xc0\xb6\xfb\x37\x8c"
-               "\x8e\xf1\x46\xbe\x00";
-    a.inLen  = strlen(a.input);
-    a.outLen = SHA_DIGEST_SIZE;
-
-    b.input  = "what do ya want for nothing?";
-    b.output = "\xef\xfc\xdf\x6a\xe5\xeb\x2f\xa2\xd2\x74\x16\xd5\xf1\x84\xdf"
-               "\x9c\x25\x9a\x7c\x79";
-    b.inLen  = strlen(b.input);
-    b.outLen = SHA_DIGEST_SIZE;
-
-    c.input  = "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD";
-    c.output = "\x12\x5d\x73\x42\xb9\xac\x11\xcd\x91\xa3\x9a\xf4\x8a\xa1\x7b"
-               "\x4f\x63\xf1\x75\xd3";
-    c.inLen  = strlen(c.input);
-    c.outLen = SHA_DIGEST_SIZE;
-
-    test_hmac[0] = a;
-    test_hmac[1] = b;
-    test_hmac[2] = c;
-
-    for (i = 0; i < times; ++i) {
-#if defined(HAVE_FIPS) || defined(HAVE_CAVIUM)
-        if (i == 1)
-            continue; /* cavium can't handle short keys, fips not allowed */
-#endif
-#ifdef HAVE_CAVIUM
-        if (wc_HmacInitCavium(&hmac, CAVIUM_DEV_ID) != 0)
-            return -20010;
-#endif
-        ret = wc_HmacSetKey(&hmac, SHA, (byte*)keys[i], (word32)strlen(keys[i]));
-        if (ret != 0)
-            return -4018;
-        ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
-                   (word32)test_hmac[i].inLen);
-        if (ret != 0)
-            return -4019;
-        ret = wc_HmacFinal(&hmac, hash);
-        if (ret != 0)
-            return -4020;
-
-        if (memcmp(hash, test_hmac[i].output, SHA_DIGEST_SIZE) != 0)
-            return -20 - i;
-#ifdef HAVE_CAVIUM
-        wc_HmacFreeCavium(&hmac);
-#endif
-    }
-
-    return 0;
-}
-#endif
-
-
-#if !defined(NO_HMAC) && !defined(NO_SHA256)
-int hmac_sha256_test(void)
-{
-    Hmac hmac;
-    byte hash[SHA256_DIGEST_SIZE];
-
-    const char* keys[]=
-    {
-        "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
-                                                                "\x0b\x0b\x0b",
-        "Jefe",
-        "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
-                                                                "\xAA\xAA\xAA"
-    };
-
-    testVector a, b, c;
-    testVector test_hmac[3];
-
-    int ret;
-    int times = sizeof(test_hmac) / sizeof(testVector), i;
-
-    a.input  = "Hi There";
-    a.output = "\xb0\x34\x4c\x61\xd8\xdb\x38\x53\x5c\xa8\xaf\xce\xaf\x0b\xf1"
-               "\x2b\x88\x1d\xc2\x00\xc9\x83\x3d\xa7\x26\xe9\x37\x6c\x2e\x32"
-               "\xcf\xf7";
-    a.inLen  = strlen(a.input);
-    a.outLen = SHA256_DIGEST_SIZE;
-
-    b.input  = "what do ya want for nothing?";
-    b.output = "\x5b\xdc\xc1\x46\xbf\x60\x75\x4e\x6a\x04\x24\x26\x08\x95\x75"
-               "\xc7\x5a\x00\x3f\x08\x9d\x27\x39\x83\x9d\xec\x58\xb9\x64\xec"
-               "\x38\x43";
-    b.inLen  = strlen(b.input);
-    b.outLen = SHA256_DIGEST_SIZE;
-
-    c.input  = "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD";
-    c.output = "\x77\x3e\xa9\x1e\x36\x80\x0e\x46\x85\x4d\xb8\xeb\xd0\x91\x81"
-               "\xa7\x29\x59\x09\x8b\x3e\xf8\xc1\x22\xd9\x63\x55\x14\xce\xd5"
-               "\x65\xfe";
-    c.inLen  = strlen(c.input);
-    c.outLen = SHA256_DIGEST_SIZE;
-
-    test_hmac[0] = a;
-    test_hmac[1] = b;
-    test_hmac[2] = c;
-
-    for (i = 0; i < times; ++i) {
-#if defined(HAVE_FIPS) || defined(HAVE_CAVIUM)
-        if (i == 1)
-            continue; /* cavium can't handle short keys, fips not allowed */
-#endif
-#ifdef HAVE_CAVIUM
-        if (wc_HmacInitCavium(&hmac, CAVIUM_DEV_ID) != 0)
-            return -20011;
-#endif
-        ret = wc_HmacSetKey(&hmac, SHA256, (byte*)keys[i],(word32)strlen(keys[i]));
-        if (ret != 0)
-            return -4021;
-        ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
-                   (word32)test_hmac[i].inLen);
-        if (ret != 0)
-            return -4022;
-        ret = wc_HmacFinal(&hmac, hash);
-        if (ret != 0)
-            return -4023;
-
-        if (memcmp(hash, test_hmac[i].output, SHA256_DIGEST_SIZE) != 0)
-            return -20 - i;
-#ifdef HAVE_CAVIUM
-        wc_HmacFreeCavium(&hmac);
-#endif
-    }
-
-    return 0;
-}
-#endif
-
-
-#if !defined(NO_HMAC) && defined(HAVE_BLAKE2)
-int hmac_blake2b_test(void)
-{
-    Hmac hmac;
-    byte hash[BLAKE2B_256];
-
-    const char* keys[]=
-    {
-        "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
-                                                                "\x0b\x0b\x0b",
-        "Jefe",
-        "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
-                                                                "\xAA\xAA\xAA"
-    };
-
-    testVector a, b, c;
-    testVector test_hmac[3];
-
-    int ret;
-    int times = sizeof(test_hmac) / sizeof(testVector), i;
-
-    a.input  = "Hi There";
-    a.output = "\x72\x93\x0d\xdd\xf5\xf7\xe1\x78\x38\x07\x44\x18\x0b\x3f\x51"
-               "\x37\x25\xb5\x82\xc2\x08\x83\x2f\x1c\x99\xfd\x03\xa0\x16\x75"
-               "\xac\xfd";
-    a.inLen  = strlen(a.input);
-    a.outLen = BLAKE2B_256;
-
-    b.input  = "what do ya want for nothing?";
-    b.output = "\x3d\x20\x50\x71\x05\xc0\x8c\x0c\x38\x44\x1e\xf7\xf9\xd1\x67"
-               "\x21\xff\x64\xf5\x94\x00\xcf\xf9\x75\x41\xda\x88\x61\x9d\x7c"
-               "\xda\x2b";
-    b.inLen  = strlen(b.input);
-    b.outLen = BLAKE2B_256;
-
-    c.input  = "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD";
-    c.output = "\xda\xfe\x2a\x24\xfc\xe7\xea\x36\x34\xbe\x41\x92\xc7\x11\xa7"
-               "\x00\xae\x53\x9c\x11\x9c\x80\x74\x55\x22\x25\x4a\xb9\x55\xd3"
-               "\x0f\x87";
-    c.inLen  = strlen(c.input);
-    c.outLen = BLAKE2B_256;
-
-    test_hmac[0] = a;
-    test_hmac[1] = b;
-    test_hmac[2] = c;
-
-    for (i = 0; i < times; ++i) {
-#if defined(HAVE_FIPS) || defined(HAVE_CAVIUM)
-        if (i == 1)
-            continue; /* cavium can't handle short keys, fips not allowed */
-#endif
-#ifdef HAVE_CAVIUM
-        if (wc_HmacInitCavium(&hmac, CAVIUM_DEV_ID) != 0)
-            return -20011;
-#endif
-        ret = wc_HmacSetKey(&hmac, BLAKE2B_ID, (byte*)keys[i],
-                         (word32)strlen(keys[i]));
-        if (ret != 0)
-            return -4024;
-        ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
-                   (word32)test_hmac[i].inLen);
-        if (ret != 0)
-            return -4025;
-        ret = wc_HmacFinal(&hmac, hash);
-        if (ret != 0)
-            return -4026;
-
-        if (memcmp(hash, test_hmac[i].output, BLAKE2B_256) != 0)
-            return -20 - i;
-#ifdef HAVE_CAVIUM
-        wc_HmacFreeCavium(&hmac);
-#endif
-    }
-
-    return 0;
-}
-#endif
-
-
-#if !defined(NO_HMAC) && defined(WOLFSSL_SHA384)
-int hmac_sha384_test(void)
-{
-    Hmac hmac;
-    byte hash[SHA384_DIGEST_SIZE];
-
-    const char* keys[]=
-    {
-        "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
-                                                                "\x0b\x0b\x0b",
-        "Jefe",
-        "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
-                                                                "\xAA\xAA\xAA"
-    };
-
-    testVector a, b, c;
-    testVector test_hmac[3];
-
-    int ret;
-    int times = sizeof(test_hmac) / sizeof(testVector), i;
-
-    a.input  = "Hi There";
-    a.output = "\xaf\xd0\x39\x44\xd8\x48\x95\x62\x6b\x08\x25\xf4\xab\x46\x90"
-               "\x7f\x15\xf9\xda\xdb\xe4\x10\x1e\xc6\x82\xaa\x03\x4c\x7c\xeb"
-               "\xc5\x9c\xfa\xea\x9e\xa9\x07\x6e\xde\x7f\x4a\xf1\x52\xe8\xb2"
-               "\xfa\x9c\xb6";
-    a.inLen  = strlen(a.input);
-    a.outLen = SHA384_DIGEST_SIZE;
-
-    b.input  = "what do ya want for nothing?";
-    b.output = "\xaf\x45\xd2\xe3\x76\x48\x40\x31\x61\x7f\x78\xd2\xb5\x8a\x6b"
-               "\x1b\x9c\x7e\xf4\x64\xf5\xa0\x1b\x47\xe4\x2e\xc3\x73\x63\x22"
-               "\x44\x5e\x8e\x22\x40\xca\x5e\x69\xe2\xc7\x8b\x32\x39\xec\xfa"
-               "\xb2\x16\x49";
-    b.inLen  = strlen(b.input);
-    b.outLen = SHA384_DIGEST_SIZE;
-
-    c.input  = "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD";
-    c.output = "\x88\x06\x26\x08\xd3\xe6\xad\x8a\x0a\xa2\xac\xe0\x14\xc8\xa8"
-               "\x6f\x0a\xa6\x35\xd9\x47\xac\x9f\xeb\xe8\x3e\xf4\xe5\x59\x66"
-               "\x14\x4b\x2a\x5a\xb3\x9d\xc1\x38\x14\xb9\x4e\x3a\xb6\xe1\x01"
-               "\xa3\x4f\x27";
-    c.inLen  = strlen(c.input);
-    c.outLen = SHA384_DIGEST_SIZE;
-
-    test_hmac[0] = a;
-    test_hmac[1] = b;
-    test_hmac[2] = c;
-
-    for (i = 0; i < times; ++i) {
-#if defined(HAVE_FIPS)
-        if (i == 1)
-            continue; /* fips not allowed */
-#endif
-        ret = wc_HmacSetKey(&hmac, SHA384, (byte*)keys[i],(word32)strlen(keys[i]));
-        if (ret != 0)
-            return -4027;
-        ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
-                   (word32)test_hmac[i].inLen);
-        if (ret != 0)
-            return -4028;
-        ret = wc_HmacFinal(&hmac, hash);
-        if (ret != 0)
-            return -4029;
-
-        if (memcmp(hash, test_hmac[i].output, SHA384_DIGEST_SIZE) != 0)
-            return -20 - i;
-    }
-
-    return 0;
-}
-#endif
-
-
-#if !defined(NO_HMAC) && defined(WOLFSSL_SHA512)
-int hmac_sha512_test(void)
-{
-    Hmac hmac;
-    byte hash[SHA512_DIGEST_SIZE];
-
-    const char* keys[]=
-    {
-        "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
-                                                                "\x0b\x0b\x0b",
-        "Jefe",
-        "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
-                                                                "\xAA\xAA\xAA"
-    };
-
-    testVector a, b, c;
-    testVector test_hmac[3];
-
-    int ret;
-    int times = sizeof(test_hmac) / sizeof(testVector), i;
-
-    a.input  = "Hi There";
-    a.output = "\x87\xaa\x7c\xde\xa5\xef\x61\x9d\x4f\xf0\xb4\x24\x1a\x1d\x6c"
-               "\xb0\x23\x79\xf4\xe2\xce\x4e\xc2\x78\x7a\xd0\xb3\x05\x45\xe1"
-               "\x7c\xde\xda\xa8\x33\xb7\xd6\xb8\xa7\x02\x03\x8b\x27\x4e\xae"
-               "\xa3\xf4\xe4\xbe\x9d\x91\x4e\xeb\x61\xf1\x70\x2e\x69\x6c\x20"
-               "\x3a\x12\x68\x54";
-    a.inLen  = strlen(a.input);
-    a.outLen = SHA512_DIGEST_SIZE;
-
-    b.input  = "what do ya want for nothing?";
-    b.output = "\x16\x4b\x7a\x7b\xfc\xf8\x19\xe2\xe3\x95\xfb\xe7\x3b\x56\xe0"
-               "\xa3\x87\xbd\x64\x22\x2e\x83\x1f\xd6\x10\x27\x0c\xd7\xea\x25"
-               "\x05\x54\x97\x58\xbf\x75\xc0\x5a\x99\x4a\x6d\x03\x4f\x65\xf8"
-               "\xf0\xe6\xfd\xca\xea\xb1\xa3\x4d\x4a\x6b\x4b\x63\x6e\x07\x0a"
-               "\x38\xbc\xe7\x37";
-    b.inLen  = strlen(b.input);
-    b.outLen = SHA512_DIGEST_SIZE;
-
-    c.input  = "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
-               "\xDD\xDD\xDD\xDD\xDD\xDD";
-    c.output = "\xfa\x73\xb0\x08\x9d\x56\xa2\x84\xef\xb0\xf0\x75\x6c\x89\x0b"
-               "\xe9\xb1\xb5\xdb\xdd\x8e\xe8\x1a\x36\x55\xf8\x3e\x33\xb2\x27"
-               "\x9d\x39\xbf\x3e\x84\x82\x79\xa7\x22\xc8\x06\xb4\x85\xa4\x7e"
-               "\x67\xc8\x07\xb9\x46\xa3\x37\xbe\xe8\x94\x26\x74\x27\x88\x59"
-               "\xe1\x32\x92\xfb";
-    c.inLen  = strlen(c.input);
-    c.outLen = SHA512_DIGEST_SIZE;
-
-    test_hmac[0] = a;
-    test_hmac[1] = b;
-    test_hmac[2] = c;
-
-    for (i = 0; i < times; ++i) {
-#if defined(HAVE_FIPS)
-        if (i == 1)
-            continue; /* fips not allowed */
-#endif
-        ret = wc_HmacSetKey(&hmac, SHA512, (byte*)keys[i],(word32)strlen(keys[i]));
-        if (ret != 0)
-            return -4030;
-        ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
-                   (word32)test_hmac[i].inLen);
-        if (ret != 0)
-            return -4031;
-        ret = wc_HmacFinal(&hmac, hash);
-        if (ret != 0)
-            return -4032;
-
-        if (memcmp(hash, test_hmac[i].output, SHA512_DIGEST_SIZE) != 0)
-            return -20 - i;
-    }
-
-    return 0;
-}
-#endif
-
-
-#ifndef NO_RC4
-int arc4_test(void)
-{
-    byte cipher[16];
-    byte plain[16];
-
-    const char* keys[] =
-    {
-        "\x01\x23\x45\x67\x89\xab\xcd\xef",
-        "\x01\x23\x45\x67\x89\xab\xcd\xef",
-        "\x00\x00\x00\x00\x00\x00\x00\x00",
-        "\xef\x01\x23\x45"
-    };
-
-    testVector a, b, c, d;
-    testVector test_arc4[4];
-
-    int times = sizeof(test_arc4) / sizeof(testVector), i;
-
-    a.input  = "\x01\x23\x45\x67\x89\xab\xcd\xef";
-    a.output = "\x75\xb7\x87\x80\x99\xe0\xc5\x96";
-    a.inLen  = 8;
-    a.outLen = 8;
-
-    b.input  = "\x00\x00\x00\x00\x00\x00\x00\x00";
-    b.output = "\x74\x94\xc2\xe7\x10\x4b\x08\x79";
-    b.inLen  = 8;
-    b.outLen = 8;
-
-    c.input  = "\x00\x00\x00\x00\x00\x00\x00\x00";
-    c.output = "\xde\x18\x89\x41\xa3\x37\x5d\x3a";
-    c.inLen  = 8;
-    c.outLen = 8;
-
-    d.input  = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
-    d.output = "\xd6\xa1\x41\xa7\xec\x3c\x38\xdf\xbd\x61";
-    d.inLen  = 10;
-    d.outLen = 10;
-
-    test_arc4[0] = a;
-    test_arc4[1] = b;
-    test_arc4[2] = c;
-    test_arc4[3] = d;
-
-    for (i = 0; i < times; ++i) {
-        Arc4 enc;
-        Arc4 dec;
-        int  keylen = 8;  /* strlen with key 0x00 not good */
-        if (i == 3)
-            keylen = 4;
-
-#ifdef HAVE_CAVIUM
-        if (wc_Arc4InitCavium(&enc, CAVIUM_DEV_ID) != 0)
-            return -20001;
-        if (wc_Arc4InitCavium(&dec, CAVIUM_DEV_ID) != 0)
-            return -20002;
-#endif
-
-        wc_Arc4SetKey(&enc, (byte*)keys[i], keylen);
-        wc_Arc4SetKey(&dec, (byte*)keys[i], keylen);
-
-        wc_Arc4Process(&enc, cipher, (byte*)test_arc4[i].input,
-                    (word32)test_arc4[i].outLen);
-        wc_Arc4Process(&dec, plain,  cipher, (word32)test_arc4[i].outLen);
-
-        if (memcmp(plain, test_arc4[i].input, test_arc4[i].outLen))
-            return -20 - i;
-
-        if (memcmp(cipher, test_arc4[i].output, test_arc4[i].outLen))
-            return -20 - 5 - i;
-
-#ifdef HAVE_CAVIUM
-        wc_Arc4FreeCavium(&enc);
-        wc_Arc4FreeCavium(&dec);
-#endif
-    }
-
-    return 0;
-}
-#endif
-
-
-int hc128_test(void)
-{
-#ifdef HAVE_HC128
-    byte cipher[16];
-    byte plain[16];
-
-    const char* keys[] =
-    {
-        "\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
-        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
-        "\x00\x53\xA6\xF9\x4C\x9F\xF2\x45\x98\xEB\x3E\x91\xE4\x37\x8A\xDD",
-        "\x0F\x62\xB5\x08\x5B\xAE\x01\x54\xA7\xFA\x4D\xA0\xF3\x46\x99\xEC"
-    };
-
-    const char* ivs[] =
-    {
-        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
-        "\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
-        "\x0D\x74\xDB\x42\xA9\x10\x77\xDE\x45\xAC\x13\x7A\xE1\x48\xAF\x16",
-        "\x28\x8F\xF6\x5D\xC4\x2B\x92\xF9\x60\xC7\x2E\x95\xFC\x63\xCA\x31"
-    };
-
-
-    testVector a, b, c, d;
-    testVector test_hc128[4];
-
-    int times = sizeof(test_hc128) / sizeof(testVector), i;
-
-    a.input  = "\x00\x00\x00\x00\x00\x00\x00\x00";
-    a.output = "\x37\x86\x02\xB9\x8F\x32\xA7\x48";
-    a.inLen  = 8;
-    a.outLen = 8;
-
-    b.input  = "\x00\x00\x00\x00\x00\x00\x00\x00";
-    b.output = "\x33\x7F\x86\x11\xC6\xED\x61\x5F";
-    b.inLen  = 8;
-    b.outLen = 8;
-
-    c.input  = "\x00\x00\x00\x00\x00\x00\x00\x00";
-    c.output = "\x2E\x1E\xD1\x2A\x85\x51\xC0\x5A";
-    c.inLen  = 8;
-    c.outLen = 8;
-
-    d.input  = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
-    d.output = "\x1C\xD8\xAE\xDD\xFE\x52\xE2\x17\xE8\x35\xD0\xB7\xE8\x4E\x29";
-    d.inLen  = 15;
-    d.outLen = 15;
-
-    test_hc128[0] = a;
-    test_hc128[1] = b;
-    test_hc128[2] = c;
-    test_hc128[3] = d;
-
-    for (i = 0; i < times; ++i) {
-        HC128 enc;
-        HC128 dec;
-
-        /* align keys/ivs in plain/cipher buffers */
-        memcpy(plain,  keys[i], 16);
-        memcpy(cipher, ivs[i],  16);
-
-        wc_Hc128_SetKey(&enc, plain, cipher);
-        wc_Hc128_SetKey(&dec, plain, cipher);
-
-        /* align input */
-        memcpy(plain, test_hc128[i].input, test_hc128[i].outLen);
-        wc_Hc128_Process(&enc, cipher, plain,  (word32)test_hc128[i].outLen);
-        wc_Hc128_Process(&dec, plain,  cipher, (word32)test_hc128[i].outLen);
-
-        if (memcmp(plain, test_hc128[i].input, test_hc128[i].outLen))
-            return -120 - i;
-
-        if (memcmp(cipher, test_hc128[i].output, test_hc128[i].outLen))
-            return -120 - 5 - i;
-    }
-
-#endif /* HAVE_HC128 */
-    return 0;
-}
-
-
-#ifndef NO_RABBIT
-int rabbit_test(void)
-{
-    byte cipher[16];
-    byte plain[16];
-
-    const char* keys[] =
-    {
-        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
-        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
-        "\xAC\xC3\x51\xDC\xF1\x62\xFC\x3B\xFE\x36\x3D\x2E\x29\x13\x28\x91"
-    };
-
-    const char* ivs[] =
-    {
-        "\x00\x00\x00\x00\x00\x00\x00\x00",
-        "\x59\x7E\x26\xC1\x75\xF5\x73\xC3",
-        0
-    };
-
-    testVector a, b, c;
-    testVector test_rabbit[3];
-
-    int times = sizeof(test_rabbit) / sizeof(testVector), i;
-
-    a.input  = "\x00\x00\x00\x00\x00\x00\x00\x00";
-    a.output = "\xED\xB7\x05\x67\x37\x5D\xCD\x7C";
-    a.inLen  = 8;
-    a.outLen = 8;
-
-    b.input  = "\x00\x00\x00\x00\x00\x00\x00\x00";
-    b.output = "\x6D\x7D\x01\x22\x92\xCC\xDC\xE0";
-    b.inLen  = 8;
-    b.outLen = 8;
-
-    c.input  = "\x00\x00\x00\x00\x00\x00\x00\x00";
-    c.output = "\x04\xCE\xCA\x7A\x1A\x86\x6E\x77";
-    c.inLen  = 8;
-    c.outLen = 8;
-
-    test_rabbit[0] = a;
-    test_rabbit[1] = b;
-    test_rabbit[2] = c;
-
-    for (i = 0; i < times; ++i) {
-        Rabbit enc;
-        Rabbit dec;
-        byte*  iv;
-
-        /* align keys/ivs in plain/cipher buffers */
-        memcpy(plain,  keys[i], 16);
-        if (ivs[i]) {
-            memcpy(cipher, ivs[i],   8);
-            iv = cipher;
-        } else
-            iv = NULL;
-        wc_RabbitSetKey(&enc, plain, iv);
-        wc_RabbitSetKey(&dec, plain, iv);
-
-        /* align input */
-        memcpy(plain, test_rabbit[i].input, test_rabbit[i].outLen);
-        wc_RabbitProcess(&enc, cipher, plain,  (word32)test_rabbit[i].outLen);
-        wc_RabbitProcess(&dec, plain,  cipher, (word32)test_rabbit[i].outLen);
-
-        if (memcmp(plain, test_rabbit[i].input, test_rabbit[i].outLen))
-            return -130 - i;
-
-        if (memcmp(cipher, test_rabbit[i].output, test_rabbit[i].outLen))
-            return -130 - 5 - i;
-    }
-
-    return 0;
-}
-#endif /* NO_RABBIT */
-
-
-#ifdef HAVE_CHACHA
-int chacha_test(void)
-{
-    ChaCha enc;
-    ChaCha dec;
-    byte   cipher[32];
-    byte   plain[32];
-    byte   input[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-    word32 keySz;
-    int    i;
-    int    times = 4;
-
-    static const byte key1[] =
-    {
-         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
-    };
-
-    static const byte key2[] =
-    {
-         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01
-    };
-
-    static const byte key3[] =
-    {
-         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
-    };
-
-    /* 128 bit key */
-    static const byte key4[] =
-    {
-         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
-    };
-
-
-    const byte* keys[] = {key1, key2, key3, key4};
-
-    static const byte ivs1[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-    static const byte ivs2[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-    static const byte ivs3[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01};
-    static const byte ivs4[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-
-
-    const byte* ivs[] = {ivs1, ivs2, ivs3, ivs4};
-
-
-    byte a[] = {0x76,0xb8,0xe0,0xad,0xa0,0xf1,0x3d,0x90};
-    byte b[] = {0x45,0x40,0xf0,0x5a,0x9f,0x1f,0xb2,0x96};
-    byte c[] = {0xde,0x9c,0xba,0x7b,0xf3,0xd6,0x9e,0xf5};
-    byte d[] = {0x89,0x67,0x09,0x52,0x60,0x83,0x64,0xfd};
-
-    byte* test_chacha[4];
-
-    test_chacha[0] = a;
-    test_chacha[1] = b;
-    test_chacha[2] = c;
-    test_chacha[3] = d;
-
-    for (i = 0; i < times; ++i) {
-        if (i < 3) {
-            keySz = 32;
-        }
-        else {
-            keySz = 16;
-        }
-
-        XMEMCPY(plain, keys[i], keySz);
-        XMEMSET(cipher, 0, 32);
-        XMEMCPY(cipher + 4, ivs[i], 8);
-
-        wc_Chacha_SetKey(&enc, keys[i], keySz);
-        wc_Chacha_SetKey(&dec, keys[i], keySz);
-
-        wc_Chacha_SetIV(&enc, cipher, 0);
-        wc_Chacha_SetIV(&dec, cipher, 0);
-        XMEMCPY(plain, input, 8);
-
-        wc_Chacha_Process(&enc, cipher, plain,  (word32)8);
-        wc_Chacha_Process(&dec, plain,  cipher, (word32)8);
-
-        if (memcmp(test_chacha[i], cipher, 8))
-            return -130 - 5 - i;
-
-        if (memcmp(plain, input, 8))
-            return -130 - i;
-    }
-
-    return 0;
-}
-#endif /* HAVE_CHACHA */
-
-
-#ifdef HAVE_POLY1305
-int poly1305_test(void)
-{
-    int      ret = 0;
-    int      i;
-    byte     tag[16];
-    Poly1305 enc;
-
-    const byte msg[] =
-    {
-        0x43,0x72,0x79,0x70,0x74,0x6f,0x67,0x72,
-        0x61,0x70,0x68,0x69,0x63,0x20,0x46,0x6f,
-        0x72,0x75,0x6d,0x20,0x52,0x65,0x73,0x65,
-        0x61,0x72,0x63,0x68,0x20,0x47,0x72,0x6f,
-        0x75,0x70
-    };
-
-    const byte msg2[] =
-    {
-        0x48,0x65,0x6c,0x6c,0x6f,0x20,0x77,0x6f,0x72,
-        0x6c,0x64,0x21
-    };
-
-    const byte msg3[] =
-    {
-        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
-    };
-
-    const byte correct[] =
-    {
-        0xa8,0x06,0x1d,0xc1,0x30,0x51,0x36,0xc6,
-        0xc2,0x2b,0x8b,0xaf,0x0c,0x01,0x27,0xa9
-
-    };
-
-    const byte correct2[] =
-    {
-        0xa6,0xf7,0x45,0x00,0x8f,0x81,0xc9,0x16,
-        0xa2,0x0d,0xcc,0x74,0xee,0xf2,0xb2,0xf0
-    };
-
-    const byte correct3[] =
-    {
-        0x49,0xec,0x78,0x09,0x0e,0x48,0x1e,0xc6,
-        0xc2,0x6b,0x33,0xb9,0x1c,0xcc,0x03,0x07
-    };
-
-    const byte key[] = {
-        0x85,0xd6,0xbe,0x78,0x57,0x55,0x6d,0x33,
-        0x7f,0x44,0x52,0xfe,0x42,0xd5,0x06,0xa8,
-        0x01,0x03,0x80,0x8a,0xfb,0x0d,0xb2,0xfd,
-        0x4a,0xbf,0xf6,0xaf,0x41,0x49,0xf5,0x1b
-    };
-
-    const byte key2[] = {
-        0x74,0x68,0x69,0x73,0x20,0x69,0x73,0x20,
-        0x33,0x32,0x2d,0x62,0x79,0x74,0x65,0x20,
-        0x6b,0x65,0x79,0x20,0x66,0x6f,0x72,0x20,
-        0x50,0x6f,0x6c,0x79,0x31,0x33,0x30,0x35
-    };
-
-    const byte* msgs[]  = {msg, msg2, msg3};
-    word32      szm[]   = {sizeof(msg),sizeof(msg2),sizeof(msg3)};
-    const byte* keys[]  = {key, key2, key2};
-    const byte* tests[] = {correct, correct2, correct3};
-
-    for (i = 0; i < 3; i++) {
-        ret = wc_Poly1305SetKey(&enc, keys[i], 32);
-        if (ret != 0)
-            return -1001;
-
-        ret = wc_Poly1305Update(&enc, msgs[i], szm[i]);
-        if (ret != 0)
-            return -1005;
-
-        ret = wc_Poly1305Final(&enc, tag);
-        if (ret != 0)
-            return -60;
-
-        if (memcmp(tag, tests[i], sizeof(tag)))
-            return -61;
-    }
-
-    return 0;
-}
-#endif /* HAVE_POLY1305 */
-
-
-#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
-int chacha20_poly1305_aead_test(void)
-{
-    /* Test #1 from Section 2.8.2 of draft-irtf-cfrg-chacha20-poly1305-10 */
-    /* https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-10  */
-
-    const byte key1[] = {
-        0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
-        0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
-        0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
-        0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f
-    };
-
-    const byte plaintext1[] = {
-        0x4c, 0x61, 0x64, 0x69, 0x65, 0x73, 0x20, 0x61,
-        0x6e, 0x64, 0x20, 0x47, 0x65, 0x6e, 0x74, 0x6c,
-        0x65, 0x6d, 0x65, 0x6e, 0x20, 0x6f, 0x66, 0x20,
-        0x74, 0x68, 0x65, 0x20, 0x63, 0x6c, 0x61, 0x73,
-        0x73, 0x20, 0x6f, 0x66, 0x20, 0x27, 0x39, 0x39,
-        0x3a, 0x20, 0x49, 0x66, 0x20, 0x49, 0x20, 0x63,
-        0x6f, 0x75, 0x6c, 0x64, 0x20, 0x6f, 0x66, 0x66,
-        0x65, 0x72, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x6f,
-        0x6e, 0x6c, 0x79, 0x20, 0x6f, 0x6e, 0x65, 0x20,
-        0x74, 0x69, 0x70, 0x20, 0x66, 0x6f, 0x72, 0x20,
-        0x74, 0x68, 0x65, 0x20, 0x66, 0x75, 0x74, 0x75,
-        0x72, 0x65, 0x2c, 0x20, 0x73, 0x75, 0x6e, 0x73,
-        0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x77, 0x6f,
-        0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x69,
-        0x74, 0x2e
-    };
-
-    const byte iv1[] = {
-        0x07, 0x00, 0x00, 0x00, 0x40, 0x41, 0x42, 0x43,
-        0x44, 0x45, 0x46, 0x47
-    };
-
-    const byte aad1[] = { /* additional data */
-        0x50, 0x51, 0x52, 0x53, 0xc0, 0xc1, 0xc2, 0xc3,
-        0xc4, 0xc5, 0xc6, 0xc7
-    };
-
-    const byte cipher1[] = { /* expected output from operation */
-        0xd3, 0x1a, 0x8d, 0x34, 0x64, 0x8e, 0x60, 0xdb,
-        0x7b, 0x86, 0xaf, 0xbc, 0x53, 0xef, 0x7e, 0xc2,
-        0xa4, 0xad, 0xed, 0x51, 0x29, 0x6e, 0x08, 0xfe,
-        0xa9, 0xe2, 0xb5, 0xa7, 0x36, 0xee, 0x62, 0xd6,
-        0x3d, 0xbe, 0xa4, 0x5e, 0x8c, 0xa9, 0x67, 0x12,
-        0x82, 0xfa, 0xfb, 0x69, 0xda, 0x92, 0x72, 0x8b,
-        0x1a, 0x71, 0xde, 0x0a, 0x9e, 0x06, 0x0b, 0x29,
-        0x05, 0xd6, 0xa5, 0xb6, 0x7e, 0xcd, 0x3b, 0x36,
-        0x92, 0xdd, 0xbd, 0x7f, 0x2d, 0x77, 0x8b, 0x8c,
-        0x98, 0x03, 0xae, 0xe3, 0x28, 0x09, 0x1b, 0x58,
-        0xfa, 0xb3, 0x24, 0xe4, 0xfa, 0xd6, 0x75, 0x94,
-        0x55, 0x85, 0x80, 0x8b, 0x48, 0x31, 0xd7, 0xbc,
-        0x3f, 0xf4, 0xde, 0xf0, 0x8e, 0x4b, 0x7a, 0x9d,
-        0xe5, 0x76, 0xd2, 0x65, 0x86, 0xce, 0xc6, 0x4b,
-        0x61, 0x16
-    };
-
-    const byte authTag1[] = { /* expected output from operation */
-        0x1a, 0xe1, 0x0b, 0x59, 0x4f, 0x09, 0xe2, 0x6a,
-        0x7e, 0x90, 0x2e, 0xcb, 0xd0, 0x60, 0x06, 0x91
-    };
-
-    /* Test #2 from Appendix A.2 in draft-irtf-cfrg-chacha20-poly1305-10 */
-    /* https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-10  */
-
-    const byte key2[] = {
-        0x1c, 0x92, 0x40, 0xa5, 0xeb, 0x55, 0xd3, 0x8a,
-        0xf3, 0x33, 0x88, 0x86, 0x04, 0xf6, 0xb5, 0xf0,
-        0x47, 0x39, 0x17, 0xc1, 0x40, 0x2b, 0x80, 0x09,
-        0x9d, 0xca, 0x5c, 0xbc, 0x20, 0x70, 0x75, 0xc0
-    };
-
-    const byte plaintext2[] = {
-        0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74,
-        0x2d, 0x44, 0x72, 0x61, 0x66, 0x74, 0x73, 0x20,
-        0x61, 0x72, 0x65, 0x20, 0x64, 0x72, 0x61, 0x66,
-        0x74, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65,
-        0x6e, 0x74, 0x73, 0x20, 0x76, 0x61, 0x6c, 0x69,
-        0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x61, 0x20,
-        0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x20,
-        0x6f, 0x66, 0x20, 0x73, 0x69, 0x78, 0x20, 0x6d,
-        0x6f, 0x6e, 0x74, 0x68, 0x73, 0x20, 0x61, 0x6e,
-        0x64, 0x20, 0x6d, 0x61, 0x79, 0x20, 0x62, 0x65,
-        0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64,
-        0x2c, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63,
-        0x65, 0x64, 0x2c, 0x20, 0x6f, 0x72, 0x20, 0x6f,
-        0x62, 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, 0x64,
-        0x20, 0x62, 0x79, 0x20, 0x6f, 0x74, 0x68, 0x65,
-        0x72, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65,
-        0x6e, 0x74, 0x73, 0x20, 0x61, 0x74, 0x20, 0x61,
-        0x6e, 0x79, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x2e,
-        0x20, 0x49, 0x74, 0x20, 0x69, 0x73, 0x20, 0x69,
-        0x6e, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x70, 0x72,
-        0x69, 0x61, 0x74, 0x65, 0x20, 0x74, 0x6f, 0x20,
-        0x75, 0x73, 0x65, 0x20, 0x49, 0x6e, 0x74, 0x65,
-        0x72, 0x6e, 0x65, 0x74, 0x2d, 0x44, 0x72, 0x61,
-        0x66, 0x74, 0x73, 0x20, 0x61, 0x73, 0x20, 0x72,
-        0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65,
-        0x20, 0x6d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61,
-        0x6c, 0x20, 0x6f, 0x72, 0x20, 0x74, 0x6f, 0x20,
-        0x63, 0x69, 0x74, 0x65, 0x20, 0x74, 0x68, 0x65,
-        0x6d, 0x20, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x20,
-        0x74, 0x68, 0x61, 0x6e, 0x20, 0x61, 0x73, 0x20,
-        0x2f, 0xe2, 0x80, 0x9c, 0x77, 0x6f, 0x72, 0x6b,
-        0x20, 0x69, 0x6e, 0x20, 0x70, 0x72, 0x6f, 0x67,
-        0x72, 0x65, 0x73, 0x73, 0x2e, 0x2f, 0xe2, 0x80,
-        0x9d
-    };
-
-    const byte iv2[] = {
-        0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04,
-        0x05, 0x06, 0x07, 0x08
-    };
-
-    const byte aad2[] = { /* additional data */
-        0xf3, 0x33, 0x88, 0x86, 0x00, 0x00, 0x00, 0x00,
-        0x00, 0x00, 0x4e, 0x91
-    };
-
-    const byte cipher2[] = { /* expected output from operation */
-        0x64, 0xa0, 0x86, 0x15, 0x75, 0x86, 0x1a, 0xf4,
-        0x60, 0xf0, 0x62, 0xc7, 0x9b, 0xe6, 0x43, 0xbd,
-        0x5e, 0x80, 0x5c, 0xfd, 0x34, 0x5c, 0xf3, 0x89,
-        0xf1, 0x08, 0x67, 0x0a, 0xc7, 0x6c, 0x8c, 0xb2,
-        0x4c, 0x6c, 0xfc, 0x18, 0x75, 0x5d, 0x43, 0xee,
-        0xa0, 0x9e, 0xe9, 0x4e, 0x38, 0x2d, 0x26, 0xb0,
-        0xbd, 0xb7, 0xb7, 0x3c, 0x32, 0x1b, 0x01, 0x00,
-        0xd4, 0xf0, 0x3b, 0x7f, 0x35, 0x58, 0x94, 0xcf,
-        0x33, 0x2f, 0x83, 0x0e, 0x71, 0x0b, 0x97, 0xce,
-        0x98, 0xc8, 0xa8, 0x4a, 0xbd, 0x0b, 0x94, 0x81,
-        0x14, 0xad, 0x17, 0x6e, 0x00, 0x8d, 0x33, 0xbd,
-        0x60, 0xf9, 0x82, 0xb1, 0xff, 0x37, 0xc8, 0x55,
-        0x97, 0x97, 0xa0, 0x6e, 0xf4, 0xf0, 0xef, 0x61,
-        0xc1, 0x86, 0x32, 0x4e, 0x2b, 0x35, 0x06, 0x38,
-        0x36, 0x06, 0x90, 0x7b, 0x6a, 0x7c, 0x02, 0xb0,
-        0xf9, 0xf6, 0x15, 0x7b, 0x53, 0xc8, 0x67, 0xe4,
-        0xb9, 0x16, 0x6c, 0x76, 0x7b, 0x80, 0x4d, 0x46,
-        0xa5, 0x9b, 0x52, 0x16, 0xcd, 0xe7, 0xa4, 0xe9,
-        0x90, 0x40, 0xc5, 0xa4, 0x04, 0x33, 0x22, 0x5e,
-        0xe2, 0x82, 0xa1, 0xb0, 0xa0, 0x6c, 0x52, 0x3e,
-        0xaf, 0x45, 0x34, 0xd7, 0xf8, 0x3f, 0xa1, 0x15,
-        0x5b, 0x00, 0x47, 0x71, 0x8c, 0xbc, 0x54, 0x6a,
-        0x0d, 0x07, 0x2b, 0x04, 0xb3, 0x56, 0x4e, 0xea,
-        0x1b, 0x42, 0x22, 0x73, 0xf5, 0x48, 0x27, 0x1a,
-        0x0b, 0xb2, 0x31, 0x60, 0x53, 0xfa, 0x76, 0x99,
-        0x19, 0x55, 0xeb, 0xd6, 0x31, 0x59, 0x43, 0x4e,
-        0xce, 0xbb, 0x4e, 0x46, 0x6d, 0xae, 0x5a, 0x10,
-        0x73, 0xa6, 0x72, 0x76, 0x27, 0x09, 0x7a, 0x10,
-        0x49, 0xe6, 0x17, 0xd9, 0x1d, 0x36, 0x10, 0x94,
-        0xfa, 0x68, 0xf0, 0xff, 0x77, 0x98, 0x71, 0x30,
-        0x30, 0x5b, 0xea, 0xba, 0x2e, 0xda, 0x04, 0xdf,
-        0x99, 0x7b, 0x71, 0x4d, 0x6c, 0x6f, 0x2c, 0x29,
-        0xa6, 0xad, 0x5c, 0xb4, 0x02, 0x2b, 0x02, 0x70,
-        0x9b
-    };
-
-    const byte authTag2[] = { /* expected output from operation */
-        0xee, 0xad, 0x9d, 0x67, 0x89, 0x0c, 0xbb, 0x22,
-        0x39, 0x23, 0x36, 0xfe, 0xa1, 0x85, 0x1f, 0x38
-    };
-
-    byte generatedCiphertext[272];
-    byte generatedPlaintext[272];
-    byte generatedAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE];
-    int err;
-
-    XMEMSET(generatedCiphertext, 0, sizeof(generatedCiphertext));
-    XMEMSET(generatedAuthTag, 0, sizeof(generatedAuthTag));
-    XMEMSET(generatedPlaintext, 0, sizeof(generatedPlaintext));
-
-    /* Test #1 */
-
-    err = wc_ChaCha20Poly1305_Encrypt(key1, iv1,
-                                       aad1, sizeof(aad1),
-                                       plaintext1, sizeof(plaintext1),
-                                       generatedCiphertext, generatedAuthTag);
-    if (err)
-    {
-        return err;
-    }
-
-    /* -- Check the ciphertext and authtag */
-
-    if (XMEMCMP(generatedCiphertext, cipher1, sizeof(cipher1)))
-    {
-        return -1064;
-    }
-
-    if (XMEMCMP(generatedAuthTag, authTag1, sizeof(authTag1)))
-    {
-        return -1065;
-    }
-
-    /* -- Verify decryption works */
-
-    err = wc_ChaCha20Poly1305_Decrypt(key1, iv1,
-                                       aad1, sizeof(aad1),
-                                       cipher1, sizeof(cipher1),
-                                       authTag1, generatedPlaintext);
-    if (err)
-    {
-        return err;
-    }
-
-    if (XMEMCMP(generatedPlaintext, plaintext1, sizeof( plaintext1)))
-    {
-        return -1066;
-    }
-
-    XMEMSET(generatedCiphertext, 0, sizeof(generatedCiphertext));
-    XMEMSET(generatedAuthTag, 0, sizeof(generatedAuthTag));
-    XMEMSET(generatedPlaintext, 0, sizeof(generatedPlaintext));
-
-    /* Test #2 */
-
-    err = wc_ChaCha20Poly1305_Encrypt(key2, iv2,
-                                       aad2, sizeof(aad2),
-                                       plaintext2, sizeof(plaintext2),
-                                       generatedCiphertext, generatedAuthTag);
-    if (err)
-    {
-        return err;
-    }
-
-    /* -- Check the ciphertext and authtag */
-
-    if (XMEMCMP(generatedCiphertext, cipher2, sizeof(cipher2)))
-    {
-        return -1067;
-    }
-
-    if (XMEMCMP(generatedAuthTag, authTag2, sizeof(authTag2)))
-    {
-        return -1068;
-    }
-
-    /* -- Verify decryption works */
-
-    err = wc_ChaCha20Poly1305_Decrypt(key2, iv2,
-                                      aad2, sizeof(aad2),
-                                      cipher2, sizeof(cipher2),
-                                      authTag2, generatedPlaintext);
-    if (err)
-    {
-        return err;
-    }
-
-    if (XMEMCMP(generatedPlaintext, plaintext2, sizeof(plaintext2)))
-    {
-        return -1069;
-    }
-
-    return err;
-}
-#endif /* HAVE_CHACHA && HAVE_POLY1305 */
-
-
-#ifndef NO_DES3
-int des_test(void)
-{
-    const byte vector[] = { /* "now is the time for all " w/o trailing 0 */
-        0x6e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74,
-        0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20,
-        0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20
-    };
-
-    byte plain[24];
-    byte cipher[24];
-
-    Des enc;
-    Des dec;
-
-    const byte key[] =
-    {
-        0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef
-    };
-
-    const byte iv[] =
-    {
-        0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef
-    };
-
-    const byte verify[] =
-    {
-        0x8b,0x7c,0x52,0xb0,0x01,0x2b,0x6c,0xb8,
-        0x4f,0x0f,0xeb,0xf3,0xfb,0x5f,0x86,0x73,
-        0x15,0x85,0xb3,0x22,0x4b,0x86,0x2b,0x4b
-    };
-
-    int ret;
-
-    ret = wc_Des_SetKey(&enc, key, iv, DES_ENCRYPTION);
-    if (ret != 0)
-        return -31;
-
-    wc_Des_CbcEncrypt(&enc, cipher, vector, sizeof(vector));
-    ret = wc_Des_SetKey(&dec, key, iv, DES_DECRYPTION);
-    if (ret != 0)
-        return -32;
-    wc_Des_CbcDecrypt(&dec, plain, cipher, sizeof(cipher));
-
-    if (memcmp(plain, vector, sizeof(plain)))
-        return -33;
-
-    if (memcmp(cipher, verify, sizeof(cipher)))
-        return -34;
-
-    return 0;
-}
-#endif /* NO_DES3 */
-
-
-#ifndef NO_DES3
-int des3_test(void)
-{
-    const byte vector[] = { /* "Now is the time for all " w/o trailing 0 */
-        0x4e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74,
-        0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20,
-        0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20
-    };
-
-    byte plain[24];
-    byte cipher[24];
-
-    Des3 enc;
-    Des3 dec;
-
-    const byte key3[] =
-    {
-        0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
-        0xfe,0xde,0xba,0x98,0x76,0x54,0x32,0x10,
-        0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67
-    };
-    const byte iv3[] =
-    {
-        0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef,
-        0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
-        0x11,0x21,0x31,0x41,0x51,0x61,0x71,0x81
-
-    };
-
-    const byte verify3[] =
-    {
-        0x43,0xa0,0x29,0x7e,0xd1,0x84,0xf8,0x0e,
-        0x89,0x64,0x84,0x32,0x12,0xd5,0x08,0x98,
-        0x18,0x94,0x15,0x74,0x87,0x12,0x7d,0xb0
-    };
-
-    int ret;
-
-
-#ifdef HAVE_CAVIUM
-    if (wc_Des3_InitCavium(&enc, CAVIUM_DEV_ID) != 0)
-        return -20005;
-    if (wc_Des3_InitCavium(&dec, CAVIUM_DEV_ID) != 0)
-        return -20006;
-#endif
-    ret = wc_Des3_SetKey(&enc, key3, iv3, DES_ENCRYPTION);
-    if (ret != 0)
-        return -31;
-    ret = wc_Des3_SetKey(&dec, key3, iv3, DES_DECRYPTION);
-    if (ret != 0)
-        return -32;
-    ret = wc_Des3_CbcEncrypt(&enc, cipher, vector, sizeof(vector));
-    if (ret != 0)
-        return -33;
-    ret = wc_Des3_CbcDecrypt(&dec, plain, cipher, sizeof(cipher));
-    if (ret != 0)
-        return -34;
-
-    if (memcmp(plain, vector, sizeof(plain)))
-        return -35;
-
-    if (memcmp(cipher, verify3, sizeof(cipher)))
-        return -36;
-
-#ifdef HAVE_CAVIUM
-    wc_Des3_FreeCavium(&enc);
-    wc_Des3_FreeCavium(&dec);
-#endif
-    return 0;
-}
-#endif /* NO_DES */
-
-
-#ifndef NO_AES
-int aes_test(void)
-{
-    Aes enc;
-    Aes dec;
-
-    const byte msg[] = { /* "Now is the time for all " w/o trailing 0 */
-        0x6e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74,
-        0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20,
-        0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20
-    };
-
-    const byte verify[] =
-    {
-        0x95,0x94,0x92,0x57,0x5f,0x42,0x81,0x53,
-        0x2c,0xcc,0x9d,0x46,0x77,0xa2,0x33,0xcb
-    };
-
-    byte key[] = "0123456789abcdef   ";  /* align */
-    byte iv[]  = "1234567890abcdef   ";  /* align */
-
-    byte cipher[AES_BLOCK_SIZE * 4];
-    byte plain [AES_BLOCK_SIZE * 4];
-    int  ret;
-
-#ifdef HAVE_CAVIUM
-        if (wc_AesInitCavium(&enc, CAVIUM_DEV_ID) != 0)
-            return -20003;
-        if (wc_AesInitCavium(&dec, CAVIUM_DEV_ID) != 0)
-            return -20004;
-#endif
-    ret = wc_AesSetKey(&enc, key, AES_BLOCK_SIZE, iv, AES_ENCRYPTION);
-    if (ret != 0)
-        return -1001;
-    ret = wc_AesSetKey(&dec, key, AES_BLOCK_SIZE, iv, AES_DECRYPTION);
-    if (ret != 0)
-        return -1002;
-
-    ret = wc_AesCbcEncrypt(&enc, cipher, msg,   AES_BLOCK_SIZE);
-    if (ret != 0)
-        return -1005;
-    ret = wc_AesCbcDecrypt(&dec, plain, cipher, AES_BLOCK_SIZE);
-    if (ret != 0)
-        return -1006;
-
-    if (memcmp(plain, msg, AES_BLOCK_SIZE))
-        return -60;
-
-    if (memcmp(cipher, verify, AES_BLOCK_SIZE))
-        return -61;
-
-#ifdef HAVE_CAVIUM
-        wc_AesFreeCavium(&enc);
-        wc_AesFreeCavium(&dec);
-#endif
-#ifdef WOLFSSL_AES_COUNTER
-    {
-        const byte ctrKey[] =
-        {
-            0x2b,0x7e,0x15,0x16,0x28,0xae,0xd2,0xa6,
-            0xab,0xf7,0x15,0x88,0x09,0xcf,0x4f,0x3c
-        };
-
-        const byte ctrIv[] =
-        {
-            0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,
-            0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff
-        };
-
-
-        const byte ctrPlain[] =
-        {
-            0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,
-            0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a,
-            0xae,0x2d,0x8a,0x57,0x1e,0x03,0xac,0x9c,
-            0x9e,0xb7,0x6f,0xac,0x45,0xaf,0x8e,0x51,
-            0x30,0xc8,0x1c,0x46,0xa3,0x5c,0xe4,0x11,
-            0xe5,0xfb,0xc1,0x19,0x1a,0x0a,0x52,0xef,
-            0xf6,0x9f,0x24,0x45,0xdf,0x4f,0x9b,0x17,
-            0xad,0x2b,0x41,0x7b,0xe6,0x6c,0x37,0x10
-        };
-
-        const byte ctrCipher[] =
-        {
-            0x87,0x4d,0x61,0x91,0xb6,0x20,0xe3,0x26,
-            0x1b,0xef,0x68,0x64,0x99,0x0d,0xb6,0xce,
-            0x98,0x06,0xf6,0x6b,0x79,0x70,0xfd,0xff,
-            0x86,0x17,0x18,0x7b,0xb9,0xff,0xfd,0xff,
-            0x5a,0xe4,0xdf,0x3e,0xdb,0xd5,0xd3,0x5e,
-            0x5b,0x4f,0x09,0x02,0x0d,0xb0,0x3e,0xab,
-            0x1e,0x03,0x1d,0xda,0x2f,0xbe,0x03,0xd1,
-            0x79,0x21,0x70,0xa0,0xf3,0x00,0x9c,0xee
-        };
-
-        const byte oddCipher[] =
-        {
-            0xb9,0xd7,0xcb,0x08,0xb0,0xe1,0x7b,0xa0,
-            0xc2
-        };
-
-        wc_AesSetKeyDirect(&enc, ctrKey, AES_BLOCK_SIZE, ctrIv, AES_ENCRYPTION);
-        /* Ctr only uses encrypt, even on key setup */
-        wc_AesSetKeyDirect(&dec, ctrKey, AES_BLOCK_SIZE, ctrIv, AES_ENCRYPTION);
-
-        wc_AesCtrEncrypt(&enc, cipher, ctrPlain, AES_BLOCK_SIZE*4);
-        wc_AesCtrEncrypt(&dec, plain, cipher, AES_BLOCK_SIZE*4);
-
-        if (memcmp(plain, ctrPlain, AES_BLOCK_SIZE*4))
-            return -66;
-
-        if (memcmp(cipher, ctrCipher, AES_BLOCK_SIZE*4))
-            return -67;
-
-        /* let's try with just 9 bytes, non block size test */
-        wc_AesSetKeyDirect(&enc, ctrKey, AES_BLOCK_SIZE, ctrIv, AES_ENCRYPTION);
-        /* Ctr only uses encrypt, even on key setup */
-        wc_AesSetKeyDirect(&dec, ctrKey, AES_BLOCK_SIZE, ctrIv, AES_ENCRYPTION);
-
-        wc_AesCtrEncrypt(&enc, cipher, ctrPlain, 9);
-        wc_AesCtrEncrypt(&dec, plain, cipher, 9);
-
-        if (memcmp(plain, ctrPlain, 9))
-            return -68;
-
-        if (memcmp(cipher, ctrCipher, 9))
-            return -69;
-
-        /* and an additional 9 bytes to reuse tmp left buffer */
-        wc_AesCtrEncrypt(&enc, cipher, ctrPlain, 9);
-        wc_AesCtrEncrypt(&dec, plain, cipher, 9);
-
-        if (memcmp(plain, ctrPlain, 9))
-            return -70;
-
-        if (memcmp(cipher, oddCipher, 9))
-            return -71;
-    }
-#endif /* WOLFSSL_AES_COUNTER */
-
-#if defined(WOLFSSL_AESNI) && defined(WOLFSSL_AES_DIRECT)
-    {
-        const byte niPlain[] =
-        {
-            0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,
-            0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a
-        };
-
-        const byte niCipher[] =
-        {
-            0xf3,0xee,0xd1,0xbd,0xb5,0xd2,0xa0,0x3c,
-            0x06,0x4b,0x5a,0x7e,0x3d,0xb1,0x81,0xf8
-        };
-
-        const byte niKey[] =
-        {
-            0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,
-            0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,
-            0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,
-            0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4
-        };
-
-        XMEMSET(cipher, 0, AES_BLOCK_SIZE);
-        ret = wc_AesSetKey(&enc, niKey, sizeof(niKey), cipher, AES_ENCRYPTION);
-        if (ret != 0)
-            return -1003;
-        wc_AesEncryptDirect(&enc, cipher, niPlain);
-        if (XMEMCMP(cipher, niCipher, AES_BLOCK_SIZE) != 0)
-            return -20006;
-
-        XMEMSET(plain, 0, AES_BLOCK_SIZE);
-        ret = wc_AesSetKey(&dec, niKey, sizeof(niKey), plain, AES_DECRYPTION);
-        if (ret != 0)
-            return -1004;
-        wc_AesDecryptDirect(&dec, plain, niCipher);
-        if (XMEMCMP(plain, niPlain, AES_BLOCK_SIZE) != 0)
-            return -20007;
-    }
-#endif /* WOLFSSL_AESNI && WOLFSSL_AES_DIRECT */
-
-    return 0;
-}
-
-#ifdef HAVE_AESGCM
-int aesgcm_test(void)
-{
-    Aes enc;
-
-    /*
-     * This is Test Case 16 from the document Galois/
-     * Counter Mode of Operation (GCM) by McGrew and
-     * Viega.
-     */
-    const byte k[] =
-    {
-        0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
-        0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
-        0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
-        0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
-    };
-
-    const byte iv[] =
-    {
-        0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
-        0xde, 0xca, 0xf8, 0x88
-    };
-
-    const byte p[] =
-    {
-        0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
-        0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
-        0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
-        0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
-        0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
-        0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
-        0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
-        0xba, 0x63, 0x7b, 0x39
-    };
-
-    const byte a[] =
-    {
-        0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
-        0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
-        0xab, 0xad, 0xda, 0xd2
-    };
-
-    const byte c[] =
-    {
-        0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07,
-        0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d,
-        0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9,
-        0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa,
-        0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
-        0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38,
-        0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a,
-        0xbc, 0xc9, 0xf6, 0x62
-    };
-
-    const byte t[] =
-    {
-        0x76, 0xfc, 0x6e, 0xce, 0x0f, 0x4e, 0x17, 0x68,
-        0xcd, 0xdf, 0x88, 0x53, 0xbb, 0x2d, 0x55, 0x1b
-    };
-
-    byte t2[sizeof(t)];
-    byte p2[sizeof(c)];
-    byte c2[sizeof(p)];
-
-    int result;
-
-    memset(t2, 0, sizeof(t2));
-    memset(c2, 0, sizeof(c2));
-    memset(p2, 0, sizeof(p2));
-
-    wc_AesGcmSetKey(&enc, k, sizeof(k));
-    /* AES-GCM encrypt and decrypt both use AES encrypt internally */
-    wc_AesGcmEncrypt(&enc, c2, p, sizeof(c2), iv, sizeof(iv),
-                                                 t2, sizeof(t2), a, sizeof(a));
-    if (memcmp(c, c2, sizeof(c2)))
-        return -68;
-    if (memcmp(t, t2, sizeof(t2)))
-        return -69;
-
-    result = wc_AesGcmDecrypt(&enc, p2, c2, sizeof(p2), iv, sizeof(iv),
-                                                 t2, sizeof(t2), a, sizeof(a));
-    if (result != 0)
-        return -70;
-    if (memcmp(p, p2, sizeof(p2)))
-        return -71;
-
-    return 0;
-}
-
-int gmac_test(void)
-{
-    Gmac gmac;
-
-    const byte k1[] =
-    {
-        0x89, 0xc9, 0x49, 0xe9, 0xc8, 0x04, 0xaf, 0x01,
-        0x4d, 0x56, 0x04, 0xb3, 0x94, 0x59, 0xf2, 0xc8
-    };
-    const byte iv1[] =
-    {
-        0xd1, 0xb1, 0x04, 0xc8, 0x15, 0xbf, 0x1e, 0x94,
-        0xe2, 0x8c, 0x8f, 0x16
-    };
-    const byte a1[] =
-    {
-       0x82, 0xad, 0xcd, 0x63, 0x8d, 0x3f, 0xa9, 0xd9,
-       0xf3, 0xe8, 0x41, 0x00, 0xd6, 0x1e, 0x07, 0x77
-    };
-    const byte t1[] =
-    {
-        0x88, 0xdb, 0x9d, 0x62, 0x17, 0x2e, 0xd0, 0x43,
-        0xaa, 0x10, 0xf1, 0x6d, 0x22, 0x7d, 0xc4, 0x1b
-    };
-
-    const byte k2[] =
-    {
-        0x40, 0xf7, 0xec, 0xb2, 0x52, 0x6d, 0xaa, 0xd4,
-        0x74, 0x25, 0x1d, 0xf4, 0x88, 0x9e, 0xf6, 0x5b
-    };
-    const byte iv2[] =
-    {
-        0xee, 0x9c, 0x6e, 0x06, 0x15, 0x45, 0x45, 0x03,
-        0x1a, 0x60, 0x24, 0xa7
-    };
-    const byte a2[] =
-    {
-        0x94, 0x81, 0x2c, 0x87, 0x07, 0x4e, 0x15, 0x18,
-        0x34, 0xb8, 0x35, 0xaf, 0x1c, 0xa5, 0x7e, 0x56
-    };
-    const byte t2[] =
-    {
-        0xc6, 0x81, 0x79, 0x8e, 0x3d, 0xda, 0xb0, 0x9f,
-        0x8d, 0x83, 0xb0, 0xbb, 0x14, 0xb6, 0x91
-    };
-
-    const byte k3[] =
-    {
-        0xb8, 0xe4, 0x9a, 0x5e, 0x37, 0xf9, 0x98, 0x2b,
-        0xb9, 0x6d, 0xd0, 0xc9, 0xb6, 0xab, 0x26, 0xac
-    };
-    const byte iv3[] =
-    {
-        0xe4, 0x4a, 0x42, 0x18, 0x8c, 0xae, 0x94, 0x92,
-        0x6a, 0x9c, 0x26, 0xb0
-    };
-    const byte a3[] =
-    {
-        0x9d, 0xb9, 0x61, 0x68, 0xa6, 0x76, 0x7a, 0x31,
-        0xf8, 0x29, 0xe4, 0x72, 0x61, 0x68, 0x3f, 0x8a
-    };
-    const byte t3[] =
-    {
-        0x23, 0xe2, 0x9f, 0x66, 0xe4, 0xc6, 0x52, 0x48
-    };
-
-    byte tag[16];
-
-    memset(tag, 0, sizeof(tag));
-    wc_GmacSetKey(&gmac, k1, sizeof(k1));
-    wc_GmacUpdate(&gmac, iv1, sizeof(iv1), a1, sizeof(a1), tag, sizeof(t1));
-    if (memcmp(t1, tag, sizeof(t1)) != 0)
-        return -126;
-
-    memset(tag, 0, sizeof(tag));
-    wc_GmacSetKey(&gmac, k2, sizeof(k2));
-    wc_GmacUpdate(&gmac, iv2, sizeof(iv2), a2, sizeof(a2), tag, sizeof(t2));
-    if (memcmp(t2, tag, sizeof(t2)) != 0)
-        return -127;
-
-    memset(tag, 0, sizeof(tag));
-    wc_GmacSetKey(&gmac, k3, sizeof(k3));
-    wc_GmacUpdate(&gmac, iv3, sizeof(iv3), a3, sizeof(a3), tag, sizeof(t3));
-    if (memcmp(t3, tag, sizeof(t3)) != 0)
-        return -128;
-
-    return 0;
-}
-#endif /* HAVE_AESGCM */
-
-#ifdef HAVE_AESCCM
-int aesccm_test(void)
-{
-    Aes enc;
-
-    /* key */
-    const byte k[] =
-    {
-        0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
-        0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf
-    };
-
-    /* nonce */
-    const byte iv[] =
-    {
-        0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0,
-        0xa1, 0xa2, 0xa3, 0xa4, 0xa5
-    };
-
-    /* plaintext */
-    const byte p[] =
-    {
-        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
-        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
-        0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e
-    };
-
-    const byte a[] =
-    {
-        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
-    };
-
-    const byte c[] =
-    {
-        0x58, 0x8c, 0x97, 0x9a, 0x61, 0xc6, 0x63, 0xd2,
-        0xf0, 0x66, 0xd0, 0xc2, 0xc0, 0xf9, 0x89, 0x80,
-        0x6d, 0x5f, 0x6b, 0x61, 0xda, 0xc3, 0x84
-    };
-
-    const byte t[] =
-    {
-        0x17, 0xe8, 0xd1, 0x2c, 0xfd, 0xf9, 0x26, 0xe0
-    };
-
-    byte t2[sizeof(t)];
-    byte p2[sizeof(p)];
-    byte c2[sizeof(c)];
-
-    int result;
-
-    memset(t2, 0, sizeof(t2));
-    memset(c2, 0, sizeof(c2));
-    memset(p2, 0, sizeof(p2));
-
-    wc_AesCcmSetKey(&enc, k, sizeof(k));
-    /* AES-CCM encrypt and decrypt both use AES encrypt internally */
-    wc_AesCcmEncrypt(&enc, c2, p, sizeof(c2), iv, sizeof(iv),
-                                                 t2, sizeof(t2), a, sizeof(a));
-    if (memcmp(c, c2, sizeof(c2)))
-        return -107;
-    if (memcmp(t, t2, sizeof(t2)))
-        return -108;
-
-    result = wc_AesCcmDecrypt(&enc, p2, c2, sizeof(p2), iv, sizeof(iv),
-                                                 t2, sizeof(t2), a, sizeof(a));
-    if (result != 0)
-        return -109;
-    if (memcmp(p, p2, sizeof(p2)))
-        return -110;
-
-    /* Test the authentication failure */
-    t2[0]++; /* Corrupt the authentication tag. */
-    result = wc_AesCcmDecrypt(&enc, p2, c, sizeof(p2), iv, sizeof(iv),
-                                                 t2, sizeof(t2), a, sizeof(a));
-    if (result == 0)
-        return -111;
-
-    /* Clear c2 to compare against p2. p2 should be set to zero in case of
-     * authentication fail. */
-    memset(c2, 0, sizeof(c2));
-    if (memcmp(p2, c2, sizeof(p2)))
-        return -112;
-
-    return 0;
-}
-#endif /* HAVE_AESCCM */
-
-
-#endif /* NO_AES */
-
-
-#ifdef HAVE_CAMELLIA
-
-enum {
-    CAM_ECB_ENC, CAM_ECB_DEC, CAM_CBC_ENC, CAM_CBC_DEC
-};
-
-typedef struct {
-    int type;
-    const byte* plaintext;
-    const byte* iv;
-    const byte* ciphertext;
-    const byte* key;
-    word32 keySz;
-    int errorCode;
-} test_vector_t;
-
-int camellia_test(void)
-{
-    /* Camellia ECB Test Plaintext */
-    static const byte pte[] =
-    {
-        0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
-        0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10
-    };
-
-    /* Camellia ECB Test Initialization Vector */
-    static const byte ive[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-
-    /* Test 1: Camellia ECB 128-bit key */
-    static const byte k1[] =
-    {
-        0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
-        0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10
-    };
-    static const byte c1[] =
-    {
-        0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73,
-        0x08, 0x57, 0x06, 0x56, 0x48, 0xea, 0xbe, 0x43
-    };
-
-    /* Test 2: Camellia ECB 192-bit key */
-    static const byte k2[] =
-    {
-        0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
-        0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
-        0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
-    };
-    static const byte c2[] =
-    {
-        0xb4, 0x99, 0x34, 0x01, 0xb3, 0xe9, 0x96, 0xf8,
-        0x4e, 0xe5, 0xce, 0xe7, 0xd7, 0x9b, 0x09, 0xb9
-    };
-
-    /* Test 3: Camellia ECB 256-bit key */
-    static const byte k3[] =
-    {
-        0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
-        0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
-        0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
-        0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
-    };
-    static const byte c3[] =
-    {
-        0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c,
-        0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09
-    };
-
-    /* Camellia CBC Test Plaintext */
-    static const byte ptc[] =
-    {
-        0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96,
-        0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A
-    };
-
-    /* Camellia CBC Test Initialization Vector */
-    static const byte ivc[] =
-    {
-        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-        0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
-    };
-
-    /* Test 4: Camellia-CBC 128-bit key */
-    static const byte k4[] =
-    {
-        0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
-        0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
-    };
-    static const byte c4[] =
-    {
-        0x16, 0x07, 0xCF, 0x49, 0x4B, 0x36, 0xBB, 0xF0,
-        0x0D, 0xAE, 0xB0, 0xB5, 0x03, 0xC8, 0x31, 0xAB
-    };
-
-    /* Test 5: Camellia-CBC 192-bit key */
-    static const byte k5[] =
-    {
-        0x8E, 0x73, 0xB0, 0xF7, 0xDA, 0x0E, 0x64, 0x52,
-        0xC8, 0x10, 0xF3, 0x2B, 0x80, 0x90, 0x79, 0xE5,
-        0x62, 0xF8, 0xEA, 0xD2, 0x52, 0x2C, 0x6B, 0x7B
-    };
-    static const byte c5[] =
-    {
-        0x2A, 0x48, 0x30, 0xAB, 0x5A, 0xC4, 0xA1, 0xA2,
-        0x40, 0x59, 0x55, 0xFD, 0x21, 0x95, 0xCF, 0x93
-    };
-
-    /* Test 6: CBC 256-bit key */
-    static const byte k6[] =
-    {
-        0x60, 0x3D, 0xEB, 0x10, 0x15, 0xCA, 0x71, 0xBE,
-        0x2B, 0x73, 0xAE, 0xF0, 0x85, 0x7D, 0x77, 0x81,
-        0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7,
-        0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4
-    };
-    static const byte c6[] =
-    {
-        0xE6, 0xCF, 0xA3, 0x5F, 0xC0, 0x2B, 0x13, 0x4A,
-        0x4D, 0x2C, 0x0B, 0x67, 0x37, 0xAC, 0x3E, 0xDA
-    };
-
-    byte out[CAMELLIA_BLOCK_SIZE];
-    Camellia cam;
-    int i, testsSz;
-    const test_vector_t testVectors[] =
-    {
-        {CAM_ECB_ENC, pte, ive, c1, k1, sizeof(k1), -114},
-        {CAM_ECB_ENC, pte, ive, c2, k2, sizeof(k2), -115},
-        {CAM_ECB_ENC, pte, ive, c3, k3, sizeof(k3), -116},
-        {CAM_ECB_DEC, pte, ive, c1, k1, sizeof(k1), -117},
-        {CAM_ECB_DEC, pte, ive, c2, k2, sizeof(k2), -118},
-        {CAM_ECB_DEC, pte, ive, c3, k3, sizeof(k3), -119},
-        {CAM_CBC_ENC, ptc, ivc, c4, k4, sizeof(k4), -120},
-        {CAM_CBC_ENC, ptc, ivc, c5, k5, sizeof(k5), -121},
-        {CAM_CBC_ENC, ptc, ivc, c6, k6, sizeof(k6), -122},
-        {CAM_CBC_DEC, ptc, ivc, c4, k4, sizeof(k4), -123},
-        {CAM_CBC_DEC, ptc, ivc, c5, k5, sizeof(k5), -124},
-        {CAM_CBC_DEC, ptc, ivc, c6, k6, sizeof(k6), -125}
-    };
-
-    testsSz = sizeof(testVectors)/sizeof(test_vector_t);
-    for (i = 0; i < testsSz; i++) {
-        if (wc_CamelliaSetKey(&cam, testVectors[i].key, testVectors[i].keySz,
-                                                        testVectors[i].iv) != 0)
-            return testVectors[i].errorCode;
-
-        switch (testVectors[i].type) {
-            case CAM_ECB_ENC:
-                wc_CamelliaEncryptDirect(&cam, out, testVectors[i].plaintext);
-                if (memcmp(out, testVectors[i].ciphertext, CAMELLIA_BLOCK_SIZE))
-                    return testVectors[i].errorCode;
-                break;
-            case CAM_ECB_DEC:
-                wc_CamelliaDecryptDirect(&cam, out, testVectors[i].ciphertext);
-                if (memcmp(out, testVectors[i].plaintext, CAMELLIA_BLOCK_SIZE))
-                    return testVectors[i].errorCode;
-                break;
-            case CAM_CBC_ENC:
-                wc_CamelliaCbcEncrypt(&cam, out, testVectors[i].plaintext,
-                                                           CAMELLIA_BLOCK_SIZE);
-                if (memcmp(out, testVectors[i].ciphertext, CAMELLIA_BLOCK_SIZE))
-                    return testVectors[i].errorCode;
-                break;
-            case CAM_CBC_DEC:
-                wc_CamelliaCbcDecrypt(&cam, out, testVectors[i].ciphertext,
-                                                           CAMELLIA_BLOCK_SIZE);
-                if (memcmp(out, testVectors[i].plaintext, CAMELLIA_BLOCK_SIZE))
-                    return testVectors[i].errorCode;
-                break;
-            default:
-                break;
-        }
-    }
-
-    /* Setting the IV and checking it was actually set. */
-    wc_CamelliaSetIV(&cam, ivc);
-    if (XMEMCMP(cam.reg, ivc, CAMELLIA_BLOCK_SIZE))
-        return -1;
-
-    /* Setting the IV to NULL should be same as all zeros IV */
-    if (wc_CamelliaSetIV(&cam, NULL) != 0 ||
-                                    XMEMCMP(cam.reg, ive, CAMELLIA_BLOCK_SIZE))
-        return -1;
-
-    /* First parameter should never be null */
-    if (wc_CamelliaSetIV(NULL, NULL) == 0)
-        return -1;
-
-    /* First parameter should never be null, check it fails */
-    if (wc_CamelliaSetKey(NULL, k1, sizeof(k1), NULL) == 0)
-        return -1;
-
-    /* Key should have a size of 16, 24, or 32 */
-    if (wc_CamelliaSetKey(&cam, k1, 0, NULL) == 0)
-        return -1;
-
-    return 0;
-}
-#endif /* HAVE_CAMELLIA */
-
-
-#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
-
-int random_test(void)
-{
-    const byte test1Entropy[] =
-    {
-        0xa6, 0x5a, 0xd0, 0xf3, 0x45, 0xdb, 0x4e, 0x0e, 0xff, 0xe8, 0x75, 0xc3,
-        0xa2, 0xe7, 0x1f, 0x42, 0xc7, 0x12, 0x9d, 0x62, 0x0f, 0xf5, 0xc1, 0x19,
-        0xa9, 0xef, 0x55, 0xf0, 0x51, 0x85, 0xe0, 0xfb, 0x85, 0x81, 0xf9, 0x31,
-        0x75, 0x17, 0x27, 0x6e, 0x06, 0xe9, 0x60, 0x7d, 0xdb, 0xcb, 0xcc, 0x2e
-    };
-    const byte test1Output[] =
-    {
-        0xd3, 0xe1, 0x60, 0xc3, 0x5b, 0x99, 0xf3, 0x40, 0xb2, 0x62, 0x82, 0x64,
-        0xd1, 0x75, 0x10, 0x60, 0xe0, 0x04, 0x5d, 0xa3, 0x83, 0xff, 0x57, 0xa5,
-        0x7d, 0x73, 0xa6, 0x73, 0xd2, 0xb8, 0xd8, 0x0d, 0xaa, 0xf6, 0xa6, 0xc3,
-        0x5a, 0x91, 0xbb, 0x45, 0x79, 0xd7, 0x3f, 0xd0, 0xc8, 0xfe, 0xd1, 0x11,
-        0xb0, 0x39, 0x13, 0x06, 0x82, 0x8a, 0xdf, 0xed, 0x52, 0x8f, 0x01, 0x81,
-        0x21, 0xb3, 0xfe, 0xbd, 0xc3, 0x43, 0xe7, 0x97, 0xb8, 0x7d, 0xbb, 0x63,
-        0xdb, 0x13, 0x33, 0xde, 0xd9, 0xd1, 0xec, 0xe1, 0x77, 0xcf, 0xa6, 0xb7,
-        0x1f, 0xe8, 0xab, 0x1d, 0xa4, 0x66, 0x24, 0xed, 0x64, 0x15, 0xe5, 0x1c,
-        0xcd, 0xe2, 0xc7, 0xca, 0x86, 0xe2, 0x83, 0x99, 0x0e, 0xea, 0xeb, 0x91,
-        0x12, 0x04, 0x15, 0x52, 0x8b, 0x22, 0x95, 0x91, 0x02, 0x81, 0xb0, 0x2d,
-        0xd4, 0x31, 0xf4, 0xc9, 0xf7, 0x04, 0x27, 0xdf
-    };
-    const byte test2EntropyA[] =
-    {
-        0x63, 0x36, 0x33, 0x77, 0xe4, 0x1e, 0x86, 0x46, 0x8d, 0xeb, 0x0a, 0xb4,
-        0xa8, 0xed, 0x68, 0x3f, 0x6a, 0x13, 0x4e, 0x47, 0xe0, 0x14, 0xc7, 0x00,
-        0x45, 0x4e, 0x81, 0xe9, 0x53, 0x58, 0xa5, 0x69, 0x80, 0x8a, 0xa3, 0x8f,
-        0x2a, 0x72, 0xa6, 0x23, 0x59, 0x91, 0x5a, 0x9f, 0x8a, 0x04, 0xca, 0x68
-    };
-    const byte test2EntropyB[] =
-    {
-        0xe6, 0x2b, 0x8a, 0x8e, 0xe8, 0xf1, 0x41, 0xb6, 0x98, 0x05, 0x66, 0xe3,
-        0xbf, 0xe3, 0xc0, 0x49, 0x03, 0xda, 0xd4, 0xac, 0x2c, 0xdf, 0x9f, 0x22,
-        0x80, 0x01, 0x0a, 0x67, 0x39, 0xbc, 0x83, 0xd3
-    };
-    const byte test2Output[] =
-    {
-        0x04, 0xee, 0xc6, 0x3b, 0xb2, 0x31, 0xdf, 0x2c, 0x63, 0x0a, 0x1a, 0xfb,
-        0xe7, 0x24, 0x94, 0x9d, 0x00, 0x5a, 0x58, 0x78, 0x51, 0xe1, 0xaa, 0x79,
-        0x5e, 0x47, 0x73, 0x47, 0xc8, 0xb0, 0x56, 0x62, 0x1c, 0x18, 0xbd, 0xdc,
-        0xdd, 0x8d, 0x99, 0xfc, 0x5f, 0xc2, 0xb9, 0x20, 0x53, 0xd8, 0xcf, 0xac,
-        0xfb, 0x0b, 0xb8, 0x83, 0x12, 0x05, 0xfa, 0xd1, 0xdd, 0xd6, 0xc0, 0x71,
-        0x31, 0x8a, 0x60, 0x18, 0xf0, 0x3b, 0x73, 0xf5, 0xed, 0xe4, 0xd4, 0xd0,
-        0x71, 0xf9, 0xde, 0x03, 0xfd, 0x7a, 0xea, 0x10, 0x5d, 0x92, 0x99, 0xb8,
-        0xaf, 0x99, 0xaa, 0x07, 0x5b, 0xdb, 0x4d, 0xb9, 0xaa, 0x28, 0xc1, 0x8d,
-        0x17, 0x4b, 0x56, 0xee, 0x2a, 0x01, 0x4d, 0x09, 0x88, 0x96, 0xff, 0x22,
-        0x82, 0xc9, 0x55, 0xa8, 0x19, 0x69, 0xe0, 0x69, 0xfa, 0x8c, 0xe0, 0x07,
-        0xa1, 0x80, 0x18, 0x3a, 0x07, 0xdf, 0xae, 0x17
-    };
-
-    byte output[SHA256_DIGEST_SIZE * 4];
-    int ret;
-
-    ret = wc_RNG_HealthTest(0, test1Entropy, sizeof(test1Entropy), NULL, 0,
-                            output, sizeof(output));
-    if (ret != 0)
-        return -39;
-
-    if (XMEMCMP(test1Output, output, sizeof(output)) != 0)
-        return -40;
-
-    ret = wc_RNG_HealthTest(1, test2EntropyA, sizeof(test2EntropyA),
-                            test2EntropyB, sizeof(test2EntropyB),
-                            output, sizeof(output));
-    if (ret != 0)
-        return -41;
-
-    if (XMEMCMP(test2Output, output, sizeof(output)) != 0)
-        return -42;
-
-    return 0;
-}
-
-#else /* HAVE_HASHDRBG || NO_RC4 */
-
-int random_test(void)
-{
-    RNG  rng;
-    byte block[32];
-    int ret;
-
-#ifdef HAVE_CAVIUM
-    ret = wc_InitRngCavium(&rng, CAVIUM_DEV_ID);
-    if (ret != 0) return -2007;
-#endif
-    ret = wc_InitRng(&rng);
-    if (ret != 0) return -39;
-
-    ret = wc_RNG_GenerateBlock(&rng, block, sizeof(block));
-    if (ret != 0) return -40;
-
-    wc_FreeRng(&rng);
-
-    return 0;
-}
-
-#endif /* HAVE_HASHDRBG || NO_RC4 */
-
-
-#ifdef HAVE_NTRU
-
-byte GetEntropy(ENTROPY_CMD cmd, byte* out);
-
-byte GetEntropy(ENTROPY_CMD cmd, byte* out)
-{
-    static RNG rng;
-
-    if (cmd == INIT)
-        return (wc_InitRng(&rng) == 0) ? 1 : 0;
-
-    if (out == NULL)
-        return 0;
-
-    if (cmd == GET_BYTE_OF_ENTROPY)
-        return (wc_RNG_GenerateBlock(&rng, out, 1) == 0) ? 1 : 0;
-
-    if (cmd == GET_NUM_BYTES_PER_BYTE_OF_ENTROPY) {
-        *out = 1;
-        return 1;
-    }
-
-    return 0;
-}
-
-#endif /* HAVE_NTRU */
-
-#ifndef NO_RSA
-
-#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
-    #ifdef FREESCALE_MQX
-        static const char* clientKey  = "a:\\certs\\client-key.der";
-        static const char* clientCert = "a:\\certs\\client-cert.der";
-        #ifdef WOLFSSL_CERT_GEN
-            static const char* caKeyFile  = "a:\\certs\\ca-key.der";
-            static const char* caCertFile = "a:\\certs\\ca-cert.pem";
-            #ifdef HAVE_ECC
-                static const char* eccCaKeyFile  = "a:\\certs\\ecc-key.der";
-                static const char* eccCaCertFile = "a:\\certs\\server-ecc.pem";
-            #endif
-        #endif
-    #elif defined(WOLFSSL_MKD_SHELL)
-        static char* clientKey = "certs/client-key.der";
-        static char* clientCert = "certs/client-cert.der";
-        void set_clientKey(char *key) {  clientKey = key ; }
-        void set_clientCert(char *cert) {  clientCert = cert ; }
-        #ifdef WOLFSSL_CERT_GEN
-            static char* caKeyFile  = "certs/ca-key.der";
-            static char* caCertFile = "certs/ca-cert.pem";
-            void set_caKeyFile (char * key)  { caKeyFile   = key ; }
-            void set_caCertFile(char * cert) { caCertFile = cert ; }
-            #ifdef HAVE_ECC
-                static const char* eccCaKeyFile  = "certs/ecc-key.der";
-                static const char* eccCaCertFile = "certs/server-ecc.pem";
-                void set_eccCaKeyFile (char * key)  { eccCaKeyFile  = key ; }
-                void set_eccCaCertFile(char * cert) { eccCaCertFile = cert ; }
-            #endif
-        #endif
-    #else
-        static const char* clientKey  = "./certs/client-key.der";
-        static const char* clientCert = "./certs/client-cert.der";
-        #ifdef WOLFSSL_CERT_GEN
-            static const char* caKeyFile  = "./certs/ca-key.der";
-            static const char* caCertFile = "./certs/ca-cert.pem";
-            #ifdef HAVE_ECC
-                static const char* eccCaKeyFile  = "./certs/ecc-key.der";
-                static const char* eccCaCertFile = "./certs/server-ecc.pem";
-            #endif
-        #endif
-    #endif
-#endif
-
-
-int rsa_test(void)
-{
-    byte*   tmp;
-    size_t bytes;
-    RsaKey key;
-    RNG    rng;
-    word32 idx = 0;
-    int    ret;
-    byte   in[] = "Everyone gets Friday off.";
-    word32 inLen = (word32)strlen((char*)in);
-    byte   out[256];
-    byte   plain[256];
-#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
-    FILE*  file, * file2;
-#endif
-#ifdef WOLFSSL_TEST_CERT
-    DecodedCert cert;
-#endif
-
-    tmp = (byte*)malloc(FOURK_BUF);
-    if (tmp == NULL)
-        return -40;
-
-#ifdef USE_CERT_BUFFERS_1024
-    XMEMCPY(tmp, client_key_der_1024, sizeof_client_key_der_1024);
-    bytes = sizeof_client_key_der_1024;
-#elif defined(USE_CERT_BUFFERS_2048)
-    XMEMCPY(tmp, client_key_der_2048, sizeof_client_key_der_2048);
-    bytes = sizeof_client_key_der_2048;
-#else
-    file = fopen(clientKey, "rb");
-
-    if (!file) {
-        err_sys("can't open ./certs/client-key.der, "
-                "Please run from wolfSSL home dir", -40);
-        free(tmp);
-        return -40;
-    }
-
-    bytes = fread(tmp, 1, FOURK_BUF, file);
-    fclose(file);
-#endif /* USE_CERT_BUFFERS */
-
-#ifdef HAVE_CAVIUM
-    wc_RsaInitCavium(&key, CAVIUM_DEV_ID);
-#endif
-    ret = wc_InitRsaKey(&key, 0);
-    if (ret != 0) {
-        free(tmp);
-        return -39;
-    }
-    ret = wc_RsaPrivateKeyDecode(tmp, &idx, &key, (word32)bytes);
-    if (ret != 0) {
-        free(tmp);
-        return -41;
-    }
-    ret = wc_InitRng(&rng);
-    if (ret != 0) {
-        free(tmp);
-        return -42;
-    }
-    ret = wc_RsaPublicEncrypt(in, inLen, out, sizeof(out), &key, &rng);
-    if (ret < 0) {
-        free(tmp);
-        return -43;
-    }
-    ret = wc_RsaPrivateDecrypt(out, ret, plain, sizeof(plain), &key);
-    if (ret < 0) {
-        free(tmp);
-        return -44;
-    }
-    if (memcmp(plain, in, inLen)) {
-        free(tmp);
-        return -45;
-    }
-    ret = wc_RsaSSL_Sign(in, inLen, out, sizeof(out), &key, &rng);
-    if (ret < 0) {
-        free(tmp);
-        return -46;
-    }
-    memset(plain, 0, sizeof(plain));
-    ret = wc_RsaSSL_Verify(out, ret, plain, sizeof(plain), &key);
-    if (ret < 0) {
-        free(tmp);
-        return -47;
-    }
-    if (memcmp(plain, in, ret)) {
-        free(tmp);
-        return -48;
-    }
-#if defined(WOLFSSL_MDK_ARM)
-    #define sizeof(s) strlen((char *)(s))
-#endif
-
-#ifdef USE_CERT_BUFFERS_1024
-    XMEMCPY(tmp, client_cert_der_1024, sizeof_client_cert_der_1024);
-    bytes = sizeof_client_cert_der_1024;
-#elif defined(USE_CERT_BUFFERS_2048)
-    XMEMCPY(tmp, client_cert_der_2048, sizeof_client_cert_der_2048);
-    bytes = sizeof_client_cert_der_2048;
-#else
-    file2 = fopen(clientCert, "rb");
-    if (!file2) {
-        free(tmp);
-        return -49;
-    }
-
-    bytes = fread(tmp, 1, FOURK_BUF, file2);
-    fclose(file2);
-#endif
-
-#ifdef sizeof
-		#undef sizeof
-#endif
-
-#ifdef WOLFSSL_TEST_CERT
-    InitDecodedCert(&cert, tmp, (word32)bytes, 0);
-
-    ret = ParseCert(&cert, CERT_TYPE, NO_VERIFY, 0);
-    if (ret != 0) return -491;
-
-    FreeDecodedCert(&cert);
-#else
-    (void)bytes;
-#endif
-
-
-#ifdef WOLFSSL_KEY_GEN
-    {
-        byte*  der;
-        byte*  pem;
-        int    derSz = 0;
-        int    pemSz = 0;
-        RsaKey derIn;
-        RsaKey genKey;
-        FILE*  keyFile;
-        FILE*  pemFile;
-
-        ret = wc_InitRsaKey(&genKey, 0);
-        if (ret != 0)
-            return -300;
-        ret = wc_MakeRsaKey(&genKey, 1024, 65537, &rng);
-        if (ret != 0)
-            return -301;
-
-        der = (byte*)malloc(FOURK_BUF);
-        if (der == NULL) {
-            wc_FreeRsaKey(&genKey);
-            return -307;
-        }
-        pem = (byte*)malloc(FOURK_BUF);
-        if (pem == NULL) {
-            free(der);
-            wc_FreeRsaKey(&genKey);
-            return -308;
-        }
-
-        derSz = wc_RsaKeyToDer(&genKey, der, FOURK_BUF);
-        if (derSz < 0) {
-            free(der);
-            free(pem);
-            return -302;
-        }
-
-#ifdef FREESCALE_MQX
-        keyFile = fopen("a:\\certs\\key.der", "wb");
-#else
-        keyFile = fopen("./key.der", "wb");
-#endif
-        if (!keyFile) {
-            free(der);
-            free(pem);
-            wc_FreeRsaKey(&genKey);
-            return -303;
-        }
-        ret = (int)fwrite(der, 1, derSz, keyFile);
-        fclose(keyFile);
-        if (ret != derSz) {
-            free(der);
-            free(pem);
-            wc_FreeRsaKey(&genKey);
-            return -313;
-        }
-
-        pemSz = wc_DerToPem(der, derSz, pem, FOURK_BUF, PRIVATEKEY_TYPE);
-        if (pemSz < 0) {
-            free(der);
-            free(pem);
-            wc_FreeRsaKey(&genKey);
-            return -304;
-        }
-
-#ifdef FREESCALE_MQX
-        pemFile = fopen("a:\\certs\\key.pem", "wb");
-#else
-        pemFile = fopen("./key.pem", "wb");
-#endif
-        if (!pemFile) {
-            free(der);
-            free(pem);
-            wc_FreeRsaKey(&genKey);
-            return -305;
-        }
-        ret = (int)fwrite(pem, 1, pemSz, pemFile);
-        fclose(pemFile);
-        if (ret != pemSz) {
-            free(der);
-            free(pem);
-            wc_FreeRsaKey(&genKey);
-            return -314;
-        }
-
-        ret = wc_InitRsaKey(&derIn, 0);
-        if (ret != 0) {
-            free(der);
-            free(pem);
-            wc_FreeRsaKey(&genKey);
-            return -3060;
-        }
-        idx = 0;
-        ret = wc_RsaPrivateKeyDecode(der, &idx, &derIn, derSz);
-        if (ret != 0) {
-            free(der);
-            free(pem);
-            wc_FreeRsaKey(&derIn);
-            wc_FreeRsaKey(&genKey);
-            return -306;
-        }
-
-        wc_FreeRsaKey(&derIn);
-        wc_FreeRsaKey(&genKey);
-        free(pem);
-        free(der);
-    }
-#endif /* WOLFSSL_KEY_GEN */
-
-
-#ifdef WOLFSSL_CERT_GEN
-    /* self signed */
-    {
-        Cert        myCert;
-        byte*       derCert;
-        byte*       pem;
-        FILE*       derFile;
-        FILE*       pemFile;
-        int         certSz;
-        int         pemSz;
-#ifdef WOLFSSL_TEST_CERT
-        DecodedCert decode;
-#endif
-
-        derCert = (byte*)malloc(FOURK_BUF);
-        if (derCert == NULL)
-            return -309;
-        pem = (byte*)malloc(FOURK_BUF);
-        if (pem == NULL) {
-            free(derCert);
-            return -310;
-        }
-
-        wc_InitCert(&myCert);
-
-        strncpy(myCert.subject.country, "US", CTC_NAME_SIZE);
-        strncpy(myCert.subject.state, "OR", CTC_NAME_SIZE);
-        strncpy(myCert.subject.locality, "Portland", CTC_NAME_SIZE);
-        strncpy(myCert.subject.org, "yaSSL", CTC_NAME_SIZE);
-        strncpy(myCert.subject.unit, "Development", CTC_NAME_SIZE);
-        strncpy(myCert.subject.commonName, "www.yassl.com", CTC_NAME_SIZE);
-        strncpy(myCert.subject.email, "info@yassl.com", CTC_NAME_SIZE);
-        myCert.isCA    = 1;
-        myCert.sigType = CTC_SHA256wRSA;
-
-        certSz = wc_MakeSelfCert(&myCert, derCert, FOURK_BUF, &key, &rng);
-        if (certSz < 0) {
-            free(derCert);
-            free(pem);
-            return -401;
-        }
-
-#ifdef WOLFSSL_TEST_CERT
-        InitDecodedCert(&decode, derCert, certSz, 0);
-        ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0);
-        if (ret != 0) {
-            free(derCert);
-            free(pem);
-            return -402;
-        }
-        FreeDecodedCert(&decode);
-#endif
-
-#ifdef FREESCALE_MQX
-        derFile = fopen("a:\\certs\\cert.der", "wb");
-#else
-        derFile = fopen("./cert.der", "wb");
-#endif
-        if (!derFile) {
-            free(derCert);
-            free(pem);
-            return -403;
-        }
-        ret = (int)fwrite(derCert, 1, certSz, derFile);
-        fclose(derFile);
-        if (ret != certSz) {
-            free(derCert);
-            free(pem);
-            return -414;
-        }
-
-        pemSz = wc_DerToPem(derCert, certSz, pem, FOURK_BUF, CERT_TYPE);
-        if (pemSz < 0) {
-            free(derCert);
-            free(pem);
-            return -404;
-        }
-
-#ifdef FREESCALE_MQX
-        pemFile = fopen("a:\\certs\\cert.pem", "wb");
-#else
-        pemFile = fopen("./cert.pem", "wb");
-#endif
-        if (!pemFile) {
-            free(derCert);
-            free(pem);
-            return -405;
-        }
-        ret = (int)fwrite(pem, 1, pemSz, pemFile);
-        fclose(pemFile);
-        if (ret != pemSz) {
-            free(derCert);
-            free(pem);
-            return -406;
-        }
-        free(pem);
-        free(derCert);
-    }
-    /* CA style */
-    {
-        RsaKey      caKey;
-        Cert        myCert;
-        byte*       derCert;
-        byte*       pem;
-        FILE*       derFile;
-        FILE*       pemFile;
-        int         certSz;
-        int         pemSz;
-        size_t      bytes3;
-        word32      idx3 = 0;
-        FILE*       file3 ;
-#ifdef WOLFSSL_TEST_CERT
-        DecodedCert decode;
-#endif
-
-        derCert = (byte*)malloc(FOURK_BUF);
-        if (derCert == NULL)
-            return -311;
-        pem = (byte*)malloc(FOURK_BUF);
-        if (pem == NULL) {
-            free(derCert);
-            return -312;
-        }
-
-        file3 = fopen(caKeyFile, "rb");
-
-        if (!file3) {
-            free(derCert);
-            free(pem);
-            return -412;
-        }
-
-        bytes3 = fread(tmp, 1, FOURK_BUF, file3);
-        fclose(file3);
-
-        ret = wc_InitRsaKey(&caKey, 0);
-        if (ret != 0) {
-            free(derCert);
-            free(pem);
-            return -411;
-        }
-        ret = wc_RsaPrivateKeyDecode(tmp, &idx3, &caKey, (word32)bytes3);
-        if (ret != 0) {
-            free(derCert);
-            free(pem);
-            wc_FreeRsaKey(&caKey);
-            return -413;
-        }
-
-        wc_InitCert(&myCert);
-
-        strncpy(myCert.subject.country, "US", CTC_NAME_SIZE);
-        strncpy(myCert.subject.state, "OR", CTC_NAME_SIZE);
-        strncpy(myCert.subject.locality, "Portland", CTC_NAME_SIZE);
-        strncpy(myCert.subject.org, "yaSSL", CTC_NAME_SIZE);
-        strncpy(myCert.subject.unit, "Development", CTC_NAME_SIZE);
-        strncpy(myCert.subject.commonName, "www.yassl.com", CTC_NAME_SIZE);
-        strncpy(myCert.subject.email, "info@yassl.com", CTC_NAME_SIZE);
-
-        ret = wc_SetIssuer(&myCert, caCertFile);
-        if (ret < 0) {
-            free(derCert);
-            free(pem);
-            wc_FreeRsaKey(&caKey);
-            return -405;
-        }
-
-        certSz = wc_MakeCert(&myCert, derCert, FOURK_BUF, &key, NULL, &rng);
-        if (certSz < 0) {
-            free(derCert);
-            free(pem);
-            wc_FreeRsaKey(&caKey);
-            return -407;
-        }
-
-        certSz = wc_SignCert(myCert.bodySz, myCert.sigType, derCert, FOURK_BUF,
-                          &caKey, NULL, &rng);
-        if (certSz < 0) {
-            free(derCert);
-            free(pem);
-            wc_FreeRsaKey(&caKey);
-            return -408;
-        }
-
-
-#ifdef WOLFSSL_TEST_CERT
-        InitDecodedCert(&decode, derCert, certSz, 0);
-        ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0);
-        if (ret != 0) {
-            free(derCert);
-            free(pem);
-            wc_FreeRsaKey(&caKey);
-            return -409;
-        }
-        FreeDecodedCert(&decode);
-#endif
-
-#ifdef FREESCALE_MQX
-        derFile = fopen("a:\\certs\\othercert.der", "wb");
-#else
-        derFile = fopen("./othercert.der", "wb");
-#endif
-        if (!derFile) {
-            free(derCert);
-            free(pem);
-            wc_FreeRsaKey(&caKey);
-            return -410;
-        }
-        ret = (int)fwrite(derCert, 1, certSz, derFile);
-        fclose(derFile);
-        if (ret != certSz) {
-            free(derCert);
-            free(pem);
-            wc_FreeRsaKey(&caKey);
-            return -416;
-        }
-
-        pemSz = wc_DerToPem(derCert, certSz, pem, FOURK_BUF, CERT_TYPE);
-        if (pemSz < 0) {
-            free(derCert);
-            free(pem);
-            wc_FreeRsaKey(&caKey);
-            return -411;
-        }
-
-#ifdef FREESCALE_MQX
-        pemFile = fopen("a:\\certs\\othercert.pem", "wb");
-#else
-        pemFile = fopen("./othercert.pem", "wb");
-#endif
-        if (!pemFile) {
-            free(derCert);
-            free(pem);
-            wc_FreeRsaKey(&caKey);
-            return -412;
-        }
-        ret = (int)fwrite(pem, 1, pemSz, pemFile);
-        if (ret != pemSz) {
-            free(derCert);
-            free(pem);
-            wc_FreeRsaKey(&caKey);
-            return -415;
-        }
-        fclose(pemFile);
-        free(pem);
-        free(derCert);
-        wc_FreeRsaKey(&caKey);
-    }
-#ifdef HAVE_ECC
-    /* ECC CA style */
-    {
-        ecc_key     caKey;
-        Cert        myCert;
-        byte*       derCert;
-        byte*       pem;
-        FILE*       derFile;
-        FILE*       pemFile;
-        int         certSz;
-        int         pemSz;
-        size_t      bytes3;
-        word32      idx3 = 0;
-        FILE*       file3;
-#ifdef WOLFSSL_TEST_CERT
-        DecodedCert decode;
-#endif
-
-        derCert = (byte*)malloc(FOURK_BUF);
-        if (derCert == NULL)
-            return -5311;
-        pem = (byte*)malloc(FOURK_BUF);
-        if (pem == NULL) {
-            free(derCert);
-            return -5312;
-        }
-
-        file3 = fopen(eccCaKeyFile, "rb");
-
-        if (!file3) {
-            free(derCert);
-            free(pem);
-            return -5412;
-        }
-
-        bytes3 = fread(tmp, 1, FOURK_BUF, file3);
-        fclose(file3);
-
-        wc_ecc_init(&caKey);
-        ret = wc_EccPrivateKeyDecode(tmp, &idx3, &caKey, (word32)bytes3);
-        if (ret != 0) {
-            free(derCert);
-            free(pem);
-            return -5413;
-        }
-
-        wc_InitCert(&myCert);
-        myCert.sigType = CTC_SHA256wECDSA;
-
-        strncpy(myCert.subject.country, "US", CTC_NAME_SIZE);
-        strncpy(myCert.subject.state, "OR", CTC_NAME_SIZE);
-        strncpy(myCert.subject.locality, "Portland", CTC_NAME_SIZE);
-        strncpy(myCert.subject.org, "wolfSSL", CTC_NAME_SIZE);
-        strncpy(myCert.subject.unit, "Development", CTC_NAME_SIZE);
-        strncpy(myCert.subject.commonName, "www.wolfssl.com", CTC_NAME_SIZE);
-        strncpy(myCert.subject.email, "info@wolfssl.com", CTC_NAME_SIZE);
-
-        ret = wc_SetIssuer(&myCert, eccCaCertFile);
-        if (ret < 0) {
-            free(pem);
-            free(derCert);
-            wc_ecc_free(&caKey);
-            return -5405;
-        }
-
-        certSz = wc_MakeCert(&myCert, derCert, FOURK_BUF, NULL, &caKey, &rng);
-        if (certSz < 0) {
-            free(pem);
-            free(derCert);
-            wc_ecc_free(&caKey);
-            return -5407;
-        }
-
-        certSz = wc_SignCert(myCert.bodySz, myCert.sigType, derCert, FOURK_BUF,
-                          NULL, &caKey, &rng);
-        if (certSz < 0) {
-            free(pem);
-            free(derCert);
-            wc_ecc_free(&caKey);
-            return -5408;
-        }
-
-#ifdef WOLFSSL_TEST_CERT
-        InitDecodedCert(&decode, derCert, certSz, 0);
-        ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0);
-        if (ret != 0) {
-            free(pem);
-            free(derCert);
-            wc_ecc_free(&caKey);
-            return -5409;
-        }
-        FreeDecodedCert(&decode);
-#endif
-
-#ifdef FREESCALE_MQX
-        derFile = fopen("a:\\certs\\certecc.der", "wb");
-#else
-        derFile = fopen("./certecc.der", "wb");
-#endif
-        if (!derFile) {
-            free(pem);
-            free(derCert);
-            wc_ecc_free(&caKey);
-            return -5410;
-        }
-        ret = (int)fwrite(derCert, 1, certSz, derFile);
-        fclose(derFile);
-        if (ret != certSz) {
-            free(pem);
-            free(derCert);
-            wc_ecc_free(&caKey);
-            return -5414;
-        }
-
-        pemSz = wc_DerToPem(derCert, certSz, pem, FOURK_BUF, CERT_TYPE);
-        if (pemSz < 0) {
-            free(pem);
-            free(derCert);
-            wc_ecc_free(&caKey);
-            return -5411;
-        }
-
-#ifdef FREESCALE_MQX
-        pemFile = fopen("a:\\certs\\certecc.pem", "wb");
-#else
-        pemFile = fopen("./certecc.pem", "wb");
-#endif
-        if (!pemFile) {
-            free(pem);
-            free(derCert);
-            wc_ecc_free(&caKey);
-            return -5412;
-        }
-        ret = (int)fwrite(pem, 1, pemSz, pemFile);
-        if (ret != pemSz) {
-            free(pem);
-            free(derCert);
-            wc_ecc_free(&caKey);
-            return -5415;
-        }
-        fclose(pemFile);
-        free(pem);
-        free(derCert);
-        wc_ecc_free(&caKey);
-    }
-#endif /* HAVE_ECC */
-#ifdef HAVE_NTRU
-    {
-        RsaKey      caKey;
-        Cert        myCert;
-        byte*       derCert;
-        byte*       pem;
-        FILE*       derFile;
-        FILE*       pemFile;
-        FILE*       caFile;
-        FILE*       ntruPrivFile;
-        int         certSz;
-        int         pemSz;
-        word32      idx3;
-#ifdef WOLFSSL_TEST_CERT
-        DecodedCert decode;
-#endif
-        derCert = (byte*)malloc(FOURK_BUF);
-        if (derCert == NULL)
-            return -311;
-        pem = (byte*)malloc(FOURK_BUF);
-        if (pem == NULL) {
-            free(derCert);
-            return -312;
-        }
-
-        byte   public_key[557];          /* sized for EES401EP2 */
-        word16 public_key_len;           /* no. of octets in public key */
-        byte   private_key[607];         /* sized for EES401EP2 */
-        word16 private_key_len;          /* no. of octets in private key */
-        DRBG_HANDLE drbg;
-        static uint8_t const pers_str[] = {
-                'C', 'y', 'a', 'S', 'S', 'L', ' ', 't', 'e', 's', 't'
-        };
-        word32 rc = ntru_crypto_drbg_instantiate(112, pers_str,
-                          sizeof(pers_str), GetEntropy, &drbg);
-        if (rc != DRBG_OK) {
-            free(derCert);
-            free(pem);
-            return -448;
-        }
-
-        rc = ntru_crypto_ntru_encrypt_keygen(drbg, NTRU_EES401EP2,
-                                             &public_key_len, NULL,
-                                             &private_key_len, NULL);
-        if (rc != NTRU_OK) {
-            free(derCert);
-            free(pem);
-            return -449;
-        }
-
-        rc = ntru_crypto_ntru_encrypt_keygen(drbg, NTRU_EES401EP2,
-                                             &public_key_len, public_key,
-                                             &private_key_len, private_key);
-        if (rc != NTRU_OK) {
-            free(derCert);
-            free(pem);
-            return -450;
-        }
-
-        rc = ntru_crypto_drbg_uninstantiate(drbg);
-
-        if (rc != NTRU_OK) {
-            free(derCert);
-            free(pem);
-            return -451;
-        }
-
-        caFile = fopen(caKeyFile, "rb");
-
-        if (!caFile) {
-            free(derCert);
-            free(pem);
-            return -452;
-        }
-
-        bytes = fread(tmp, 1, FOURK_BUF, caFile);
-        fclose(caFile);
-
-        ret = wc_InitRsaKey(&caKey, 0);
-        if (ret != 0) {
-            free(derCert);
-            free(pem);
-            return -453;
-        }
-        ret = wc_RsaPrivateKeyDecode(tmp, &idx3, &caKey, (word32)bytes);
-        if (ret != 0) {
-            free(derCert);
-            free(pem);
-            return -454;
-        }
-
-        wc_InitCert(&myCert);
-
-        strncpy(myCert.subject.country, "US", CTC_NAME_SIZE);
-        strncpy(myCert.subject.state, "OR", CTC_NAME_SIZE);
-        strncpy(myCert.subject.locality, "Portland", CTC_NAME_SIZE);
-        strncpy(myCert.subject.org, "yaSSL", CTC_NAME_SIZE);
-        strncpy(myCert.subject.unit, "Development", CTC_NAME_SIZE);
-        strncpy(myCert.subject.commonName, "www.yassl.com", CTC_NAME_SIZE);
-        strncpy(myCert.subject.email, "info@yassl.com", CTC_NAME_SIZE);
-
-        ret = wc_SetIssuer(&myCert, caCertFile);
-        if (ret < 0) {
-            free(derCert);
-            free(pem);
-            wc_FreeRsaKey(&caKey);
-            return -455;
-        }
-
-        certSz = wc_MakeNtruCert(&myCert, derCert, FOURK_BUF, public_key,
-                              public_key_len, &rng);
-        if (certSz < 0) {
-            free(derCert);
-            free(pem);
-            wc_FreeRsaKey(&caKey);
-            return -456;
-        }
-
-        certSz = wc_SignCert(myCert.bodySz, myCert.sigType, derCert, FOURK_BUF,
-                          &caKey, NULL, &rng);
-        wc_FreeRsaKey(&caKey);
-        if (certSz < 0) {
-            free(derCert);
-            free(pem);
-            return -457;
-        }
-
-
-#ifdef WOLFSSL_TEST_CERT
-        InitDecodedCert(&decode, derCert, certSz, 0);
-        ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0);
-        if (ret != 0) {
-            free(derCert);
-            free(pem);
-            return -458;
-        }
-        FreeDecodedCert(&decode);
-#endif
-        derFile = fopen("./ntru-cert.der", "wb");
-        if (!derFile) {
-            free(derCert);
-            free(pem);
-            return -459;
-        }
-        ret = (int)fwrite(derCert, 1, certSz, derFile);
-        fclose(derFile);
-        if (ret != certSz) {
-            free(derCert);
-            free(pem);
-            return -473;
-        }
-
-        pemSz = wc_DerToPem(derCert, certSz, pem, FOURK_BUF, CERT_TYPE);
-        if (pemSz < 0) {
-            free(derCert);
-            free(pem);
-            return -460;
-        }
-
-        pemFile = fopen("./ntru-cert.pem", "wb");
-        if (!pemFile) {
-            free(derCert);
-            free(pem);
-            return -461;
-        }
-        ret = (int)fwrite(pem, 1, pemSz, pemFile);
-        fclose(pemFile);
-        if (ret != pemSz) {
-            free(derCert);
-            free(pem);
-            return -474;
-        }
-
-        ntruPrivFile = fopen("./ntru-key.raw", "wb");
-        if (!ntruPrivFile) {
-            free(derCert);
-            free(pem);
-            return -462;
-        }
-        ret = (int)fwrite(private_key, 1, private_key_len, ntruPrivFile);
-        fclose(ntruPrivFile);
-        if (ret != private_key_len) {
-            free(pem);
-            free(derCert);
-            return -475;
-        }
-        free(pem);
-        free(derCert);
-    }
-#endif /* HAVE_NTRU */
-#ifdef WOLFSSL_CERT_REQ
-    {
-        Cert        req;
-        byte*       der;
-        byte*       pem;
-        int         derSz;
-        int         pemSz;
-        FILE*       reqFile;
-
-        der = (byte*)malloc(FOURK_BUF);
-        if (der == NULL)
-            return -463;
-        pem = (byte*)malloc(FOURK_BUF);
-        if (pem == NULL) {
-            free(der);
-            return -464;
-        }
-
-        wc_InitCert(&req);
-
-        req.version = 0;
-        req.isCA    = 1;
-        strncpy(req.challengePw, "yassl123", CTC_NAME_SIZE);
-        strncpy(req.subject.country, "US", CTC_NAME_SIZE);
-        strncpy(req.subject.state, "OR", CTC_NAME_SIZE);
-        strncpy(req.subject.locality, "Portland", CTC_NAME_SIZE);
-        strncpy(req.subject.org, "yaSSL", CTC_NAME_SIZE);
-        strncpy(req.subject.unit, "Development", CTC_NAME_SIZE);
-        strncpy(req.subject.commonName, "www.yassl.com", CTC_NAME_SIZE);
-        strncpy(req.subject.email, "info@yassl.com", CTC_NAME_SIZE);
-        req.sigType = CTC_SHA256wRSA;
-
-        derSz = wc_MakeCertReq(&req, der, FOURK_BUF, &key, NULL);
-        if (derSz < 0) {
-            free(pem);
-            free(der);
-            return -465;
-        }
-
-        derSz = wc_SignCert(req.bodySz, req.sigType, der, FOURK_BUF,
-                          &key, NULL, &rng);
-        if (derSz < 0) {
-            free(pem);
-            free(der);
-            return -466;
-        }
-
-        pemSz = wc_DerToPem(der, derSz, pem, FOURK_BUF, CERTREQ_TYPE);
-        if (pemSz < 0) {
-            free(pem);
-            free(der);
-            return -467;
-        }
-
-#ifdef FREESCALE_MQX
-        reqFile = fopen("a:\\certs\\certreq.der", "wb");
-#else
-        reqFile = fopen("./certreq.der", "wb");
-#endif
-        if (!reqFile) {
-            free(pem);
-            free(der);
-            return -468;
-        }
-
-        ret = (int)fwrite(der, 1, derSz, reqFile);
-        fclose(reqFile);
-        if (ret != derSz) {
-            free(pem);
-            free(der);
-            return -471;
-        }
-
-#ifdef FREESCALE_MQX
-        reqFile = fopen("a:\\certs\\certreq.pem", "wb");
-#else
-        reqFile = fopen("./certreq.pem", "wb");
-#endif
-        if (!reqFile) {
-            free(pem);
-            free(der);
-            return -469;
-        }
-        ret = (int)fwrite(pem, 1, pemSz, reqFile);
-        fclose(reqFile);
-        if (ret != pemSz) {
-            free(pem);
-            free(der);
-            return -470;
-        }
-
-        free(pem);
-        free(der);
-    }
-#endif /* WOLFSSL_CERT_REQ */
-#endif /* WOLFSSL_CERT_GEN */
-
-    wc_FreeRsaKey(&key);
-#ifdef HAVE_CAVIUM
-    wc_RsaFreeCavium(&key);
-#endif
-    free(tmp);
-    wc_FreeRng(&rng);
-
-    return 0;
-}
-
-#endif
-
-
-#ifndef NO_DH
-
-#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
-    #ifdef FREESCALE_MQX
-        static const char* dhKey = "a:\\certs\\dh2048.der";
-    #elif defined(NO_ASN)
-        /* don't use file, no DER parsing */
-    #else
-        static const char* dhKey = "./certs/dh2048.der";
-    #endif
-#endif
-
-int dh_test(void)
-{
-    int    ret;
-    word32 bytes;
-    word32 idx = 0, privSz, pubSz, privSz2, pubSz2, agreeSz, agreeSz2;
-    byte   tmp[1024];
-    byte   priv[256];
-    byte   pub[256];
-    byte   priv2[256];
-    byte   pub2[256];
-    byte   agree[256];
-    byte   agree2[256];
-    DhKey  key;
-    DhKey  key2;
-    RNG    rng;
-
-#ifdef USE_CERT_BUFFERS_1024
-    XMEMCPY(tmp, dh_key_der_1024, sizeof_dh_key_der_1024);
-    bytes = sizeof_dh_key_der_1024;
-#elif defined(USE_CERT_BUFFERS_2048)
-    XMEMCPY(tmp, dh_key_der_2048, sizeof_dh_key_der_2048);
-    bytes = sizeof_dh_key_der_2048;
-#elif defined(NO_ASN)
-    /* don't use file, no DER parsing */
-#else
-    FILE*  file = fopen(dhKey, "rb");
-
-    if (!file)
-        return -50;
-
-    bytes = (word32) fread(tmp, 1, sizeof(tmp), file);
-    fclose(file);
-#endif /* USE_CERT_BUFFERS */
-
-    (void)idx;
-    (void)tmp;
-    (void)bytes;
-
-    wc_InitDhKey(&key);
-    wc_InitDhKey(&key2);
-#ifdef NO_ASN
-    ret = wc_DhSetKey(&key, dh_p, sizeof(dh_p), dh_g, sizeof(dh_g));
-    if (ret != 0)
-        return -51;
-
-    ret = wc_DhSetKey(&key2, dh_p, sizeof(dh_p), dh_g, sizeof(dh_g));
-    if (ret != 0)
-        return -51;
-#else
-    ret = wc_DhKeyDecode(tmp, &idx, &key, bytes);
-    if (ret != 0)
-        return -51;
-
-    idx = 0;
-    ret = wc_DhKeyDecode(tmp, &idx, &key2, bytes);
-    if (ret != 0)
-        return -52;
-#endif
-
-    ret = wc_InitRng(&rng);
-    if (ret != 0)
-        return -53;
-
-    ret =  wc_DhGenerateKeyPair(&key, &rng, priv, &privSz, pub, &pubSz);
-    ret += wc_DhGenerateKeyPair(&key2, &rng, priv2, &privSz2, pub2, &pubSz2);
-    if (ret != 0)
-        return -54;
-
-    ret =  wc_DhAgree(&key, agree, &agreeSz, priv, privSz, pub2, pubSz2);
-    ret += wc_DhAgree(&key2, agree2, &agreeSz2, priv2, privSz2, pub, pubSz);
-    if (ret != 0)
-        return -55;
-
-    if (memcmp(agree, agree2, agreeSz))
-        return -56;
-
-    wc_FreeDhKey(&key);
-    wc_FreeDhKey(&key2);
-    wc_FreeRng(&rng);
-
-    return 0;
-}
-
-#endif /* NO_DH */
-
-
-#ifndef NO_DSA
-
-#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
-    #ifdef FREESCALE_MQX
-        static const char* dsaKey = "a:\\certs\\dsa2048.der";
-    #else
-        static const char* dsaKey = "./certs/dsa2048.der";
-    #endif
-#endif
-
-int dsa_test(void)
-{
-    int    ret, answer;
-    word32 bytes;
-    word32 idx = 0;
-    byte   tmp[1024];
-    DsaKey key;
-    RNG    rng;
-    Sha    sha;
-    byte   hash[SHA_DIGEST_SIZE];
-    byte   signature[40];
-
-
-#ifdef USE_CERT_BUFFERS_1024
-    XMEMCPY(tmp, dsa_key_der_1024, sizeof_dsa_key_der_1024);
-    bytes = sizeof_dsa_key_der_1024;
-#elif defined(USE_CERT_BUFFERS_2048)
-    XMEMCPY(tmp, dsa_key_der_2048, sizeof_dsa_key_der_2048);
-    bytes = sizeof_dsa_key_der_2048;
-#else
-    FILE*  file = fopen(dsaKey, "rb");
-
-    if (!file)
-        return -60;
-
-    bytes = (word32) fread(tmp, 1, sizeof(tmp), file);
-    fclose(file);
-#endif /* USE_CERT_BUFFERS */
-
-    ret = wc_InitSha(&sha);
-    if (ret != 0)
-        return -4002;
-    wc_ShaUpdate(&sha, tmp, bytes);
-    wc_ShaFinal(&sha, hash);
-
-    wc_InitDsaKey(&key);
-    ret = wc_DsaPrivateKeyDecode(tmp, &idx, &key, bytes);
-    if (ret != 0) return -61;
-
-    ret = wc_InitRng(&rng);
-    if (ret != 0) return -62;
-
-    ret = wc_DsaSign(hash, signature, &key, &rng);
-    if (ret != 0) return -63;
-
-    ret = wc_DsaVerify(hash, signature, &key, &answer);
-    if (ret != 0) return -64;
-    if (answer != 1) return -65;
-
-    wc_FreeDsaKey(&key);
-    wc_FreeRng(&rng);
-
-    return 0;
-}
-
-#endif /* NO_DSA */
-
-
-#ifdef OPENSSL_EXTRA
-
-int openssl_test(void)
-{
-    EVP_MD_CTX md_ctx;
-    testVector a, b, c, d, e, f;
-    byte       hash[SHA256_DIGEST_SIZE*2];  /* max size */
-
-    (void)a;
-    (void)b;
-    (void)c;
-    (void)e;
-    (void)f;
-
-#ifndef NO_MD5
-
-    a.input  = "1234567890123456789012345678901234567890123456789012345678"
-               "9012345678901234567890";
-    a.output = "\x57\xed\xf4\xa2\x2b\xe3\xc9\x55\xac\x49\xda\x2e\x21\x07\xb6"
-               "\x7a";
-    a.inLen  = strlen(a.input);
-    a.outLen = MD5_DIGEST_SIZE;
-
-    EVP_MD_CTX_init(&md_ctx);
-    EVP_DigestInit(&md_ctx, EVP_md5());
-
-    EVP_DigestUpdate(&md_ctx, a.input, (unsigned long)a.inLen);
-    EVP_DigestFinal(&md_ctx, hash, 0);
-
-    if (memcmp(hash, a.output, MD5_DIGEST_SIZE) != 0)
-        return -71;
-
-#endif /* NO_MD5 */
-
-#ifndef NO_SHA
-
-    b.input  = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-               "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-               "aaaaaaaaaa";
-    b.output = "\xAD\x5B\x3F\xDB\xCB\x52\x67\x78\xC2\x83\x9D\x2F\x15\x1E\xA7"
-               "\x53\x99\x5E\x26\xA0";
-    b.inLen  = strlen(b.input);
-    b.outLen = SHA_DIGEST_SIZE;
-
-    EVP_MD_CTX_init(&md_ctx);
-    EVP_DigestInit(&md_ctx, EVP_sha1());
-
-    EVP_DigestUpdate(&md_ctx, b.input, (unsigned long)b.inLen);
-    EVP_DigestFinal(&md_ctx, hash, 0);
-
-    if (memcmp(hash, b.output, SHA_DIGEST_SIZE) != 0)
-        return -72;
-
-#endif /* NO_SHA */
-
-
-    d.input  = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
-    d.output = "\x24\x8D\x6A\x61\xD2\x06\x38\xB8\xE5\xC0\x26\x93\x0C\x3E\x60"
-               "\x39\xA3\x3C\xE4\x59\x64\xFF\x21\x67\xF6\xEC\xED\xD4\x19\xDB"
-               "\x06\xC1";
-    d.inLen  = strlen(d.input);
-    d.outLen = SHA256_DIGEST_SIZE;
-
-    EVP_MD_CTX_init(&md_ctx);
-    EVP_DigestInit(&md_ctx, EVP_sha256());
-
-    EVP_DigestUpdate(&md_ctx, d.input, (unsigned long)d.inLen);
-    EVP_DigestFinal(&md_ctx, hash, 0);
-
-    if (memcmp(hash, d.output, SHA256_DIGEST_SIZE) != 0)
-        return -78;
-
-#ifdef WOLFSSL_SHA384
-
-    e.input  = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi"
-               "jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
-    e.output = "\x09\x33\x0c\x33\xf7\x11\x47\xe8\x3d\x19\x2f\xc7\x82\xcd\x1b"
-               "\x47\x53\x11\x1b\x17\x3b\x3b\x05\xd2\x2f\xa0\x80\x86\xe3\xb0"
-               "\xf7\x12\xfc\xc7\xc7\x1a\x55\x7e\x2d\xb9\x66\xc3\xe9\xfa\x91"
-               "\x74\x60\x39";
-    e.inLen  = strlen(e.input);
-    e.outLen = SHA384_DIGEST_SIZE;
-
-    EVP_MD_CTX_init(&md_ctx);
-    EVP_DigestInit(&md_ctx, EVP_sha384());
-
-    EVP_DigestUpdate(&md_ctx, e.input, (unsigned long)e.inLen);
-    EVP_DigestFinal(&md_ctx, hash, 0);
-
-    if (memcmp(hash, e.output, SHA384_DIGEST_SIZE) != 0)
-        return -79;
-
-#endif /* WOLFSSL_SHA384 */
-
-
-#ifdef WOLFSSL_SHA512
-
-    f.input  = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi"
-               "jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
-    f.output = "\x8e\x95\x9b\x75\xda\xe3\x13\xda\x8c\xf4\xf7\x28\x14\xfc\x14"
-               "\x3f\x8f\x77\x79\xc6\xeb\x9f\x7f\xa1\x72\x99\xae\xad\xb6\x88"
-               "\x90\x18\x50\x1d\x28\x9e\x49\x00\xf7\xe4\x33\x1b\x99\xde\xc4"
-               "\xb5\x43\x3a\xc7\xd3\x29\xee\xb6\xdd\x26\x54\x5e\x96\xe5\x5b"
-               "\x87\x4b\xe9\x09";
-    f.inLen  = strlen(f.input);
-    f.outLen = SHA512_DIGEST_SIZE;
-
-    EVP_MD_CTX_init(&md_ctx);
-    EVP_DigestInit(&md_ctx, EVP_sha512());
-
-    EVP_DigestUpdate(&md_ctx, f.input, (unsigned long)f.inLen);
-    EVP_DigestFinal(&md_ctx, hash, 0);
-
-    if (memcmp(hash, f.output, SHA512_DIGEST_SIZE) != 0)
-        return -80;
-
-#endif /* WOLFSSL_SHA512 */
-
-
-#ifndef NO_MD5
-    if (RAND_bytes(hash, sizeof(hash)) != 1)
-        return -73;
-
-    c.input  = "what do ya want for nothing?";
-    c.output = "\x55\x78\xe8\x48\x4b\xcc\x93\x80\x93\xec\x53\xaf\x22\xd6\x14"
-               "\x76";
-    c.inLen  = strlen(c.input);
-    c.outLen = MD5_DIGEST_SIZE;
-
-    HMAC(EVP_md5(),
-                 "JefeJefeJefeJefe", 16, (byte*)c.input, (int)c.inLen, hash, 0);
-
-    if (memcmp(hash, c.output, MD5_DIGEST_SIZE) != 0)
-        return -74;
-
-#endif /* NO_MD5 */
-
-#ifndef NO_DES3
-    { /* des test */
-    const byte vector[] = { /* "now is the time for all " w/o trailing 0 */
-        0x6e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74,
-        0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20,
-        0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20
-    };
-
-    byte plain[24];
-    byte cipher[24];
-
-    const_DES_cblock key =
-    {
-        0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef
-    };
-
-    DES_cblock iv =
-    {
-        0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef
-    };
-
-    DES_key_schedule sched;
-
-    const byte verify[] =
-    {
-        0x8b,0x7c,0x52,0xb0,0x01,0x2b,0x6c,0xb8,
-        0x4f,0x0f,0xeb,0xf3,0xfb,0x5f,0x86,0x73,
-        0x15,0x85,0xb3,0x22,0x4b,0x86,0x2b,0x4b
-    };
-
-    DES_key_sched(&key, &sched);
-
-    DES_cbc_encrypt(vector, cipher, sizeof(vector), &sched, &iv, DES_ENCRYPT);
-    DES_cbc_encrypt(cipher, plain, sizeof(vector), &sched, &iv, DES_DECRYPT);
-
-    if (memcmp(plain, vector, sizeof(vector)) != 0)
-        return -75;
-
-    if (memcmp(cipher, verify, sizeof(verify)) != 0)
-        return -76;
-
-        /* test changing iv */
-    DES_ncbc_encrypt(vector, cipher, 8, &sched, &iv, DES_ENCRYPT);
-    DES_ncbc_encrypt(vector + 8, cipher + 8, 16, &sched, &iv, DES_ENCRYPT);
-
-    if (memcmp(cipher, verify, sizeof(verify)) != 0)
-        return -77;
-
-    }  /* end des test */
-
-#endif /* NO_DES3 */
-
-#ifndef NO_AES
-
-    {  /* evp_cipher test */
-        EVP_CIPHER_CTX ctx;
-
-
-        const byte msg[] = { /* "Now is the time for all " w/o trailing 0 */
-            0x6e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74,
-            0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20,
-            0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20
-        };
-
-        const byte verify[] =
-        {
-            0x95,0x94,0x92,0x57,0x5f,0x42,0x81,0x53,
-            0x2c,0xcc,0x9d,0x46,0x77,0xa2,0x33,0xcb
-        };
-
-        byte key[] = "0123456789abcdef   ";  /* align */
-        byte iv[]  = "1234567890abcdef   ";  /* align */
-
-        byte cipher[AES_BLOCK_SIZE * 4];
-        byte plain [AES_BLOCK_SIZE * 4];
-
-        EVP_CIPHER_CTX_init(&ctx);
-        if (EVP_CipherInit(&ctx, EVP_aes_128_cbc(), key, iv, 1) == 0)
-            return -81;
-
-        if (EVP_Cipher(&ctx, cipher, (byte*)msg, 16) == 0)
-            return -82;
-
-        if (memcmp(cipher, verify, AES_BLOCK_SIZE))
-            return -83;
-
-        EVP_CIPHER_CTX_init(&ctx);
-        if (EVP_CipherInit(&ctx, EVP_aes_128_cbc(), key, iv, 0) == 0)
-            return -84;
-
-        if (EVP_Cipher(&ctx, plain, cipher, 16) == 0)
-            return -85;
-
-        if (memcmp(plain, msg, AES_BLOCK_SIZE))
-            return -86;
-
-
-    }  /* end evp_cipher test */
-
-#endif /* NO_AES */
-
-    return 0;
-}
-
-#endif /* OPENSSL_EXTRA */
-
-
-#ifndef NO_PWDBASED
-
-int pkcs12_test(void)
-{
-    const byte passwd[] = { 0x00, 0x73, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x67,
-                            0x00, 0x00 };
-    const byte salt[] =   { 0x0a, 0x58, 0xCF, 0x64, 0x53, 0x0d, 0x82, 0x3f };
-
-    const byte passwd2[] = { 0x00, 0x71, 0x00, 0x75, 0x00, 0x65, 0x00, 0x65,
-                             0x00, 0x67, 0x00, 0x00 };
-    const byte salt2[] =   { 0x16, 0x82, 0xC0, 0xfC, 0x5b, 0x3f, 0x7e, 0xc5 };
-    byte  derived[64];
-
-    const byte verify[] = {
-        0x27, 0xE9, 0x0D, 0x7E, 0xD5, 0xA1, 0xC4, 0x11,
-        0xBA, 0x87, 0x8B, 0xC0, 0x90, 0xF5, 0xCE, 0xBE,
-        0x5E, 0x9D, 0x5F, 0xE3, 0xD6, 0x2B, 0x73, 0xAA
-    };
-
-    const byte verify2[] = {
-        0x90, 0x1B, 0x49, 0x70, 0xF0, 0x94, 0xF0, 0xF8,
-        0x45, 0xC0, 0xF3, 0xF3, 0x13, 0x59, 0x18, 0x6A,
-        0x35, 0xE3, 0x67, 0xFE, 0xD3, 0x21, 0xFD, 0x7C
-    };
-
-    int id         =  1;
-    int kLen       = 24;
-    int iterations =  1;
-    int ret = wc_PKCS12_PBKDF(derived, passwd, sizeof(passwd), salt, 8,
-                                                  iterations, kLen, SHA256, id);
-
-    if (ret < 0)
-        return -103;
-
-    if ( (ret = memcmp(derived, verify, kLen)) != 0)
-        return -104;
-
-    iterations = 1000;
-    ret = wc_PKCS12_PBKDF(derived, passwd2, sizeof(passwd2), salt2, 8,
-                                                  iterations, kLen, SHA256, id);
-    if (ret < 0)
-        return -105;
-
-    if ( (ret = memcmp(derived, verify2, 24)) != 0)
-        return -106;
-
-    return 0;
-}
-
-
-int pbkdf2_test(void)
-{
-    char passwd[] = "passwordpassword";
-    const byte salt[] = { 0x78, 0x57, 0x8E, 0x5a, 0x5d, 0x63, 0xcb, 0x06 };
-    int   iterations = 2048;
-    int   kLen = 24;
-    byte  derived[64];
-
-    const byte verify[] = {
-        0x43, 0x6d, 0xb5, 0xe8, 0xd0, 0xfb, 0x3f, 0x35, 0x42, 0x48, 0x39, 0xbc,
-        0x2d, 0xd4, 0xf9, 0x37, 0xd4, 0x95, 0x16, 0xa7, 0x2a, 0x9a, 0x21, 0xd1
-    };
-
-    int ret = wc_PBKDF2(derived, (byte*)passwd, (int)strlen(passwd), salt, 8,
-                                                      iterations, kLen, SHA256);
-    if (ret != 0)
-        return ret;
-
-    if (memcmp(derived, verify, sizeof(verify)) != 0)
-        return -102;
-
-    return 0;
-}
-
-
-#ifndef NO_SHA
-int pbkdf1_test(void)
-{
-    char passwd[] = "password";
-    const byte salt[] = { 0x78, 0x57, 0x8E, 0x5a, 0x5d, 0x63, 0xcb, 0x06 };
-    int   iterations = 1000;
-    int   kLen = 16;
-    byte  derived[16];
-
-    const byte verify[] = {
-        0xDC, 0x19, 0x84, 0x7E, 0x05, 0xC6, 0x4D, 0x2F, 0xAF, 0x10, 0xEB, 0xFB,
-        0x4A, 0x3D, 0x2A, 0x20
-    };
-
-    wc_PBKDF1(derived, (byte*)passwd, (int)strlen(passwd), salt, 8, iterations,
-           kLen, SHA);
-
-    if (memcmp(derived, verify, sizeof(verify)) != 0)
-        return -101;
-
-    return 0;
-}
-#endif
-
-
-int pwdbased_test(void)
-{
-   int ret = 0;
-#ifndef NO_SHA
-   ret += pbkdf1_test();
-#endif
-   ret += pbkdf2_test();
-
-   return ret + pkcs12_test();
-}
-
-#endif /* NO_PWDBASED */
-
-#if defined(HAVE_HKDF) && (!defined(NO_SHA) || !defined(NO_SHA256))
-
-int hkdf_test(void)
-{
-    int ret;
-    int L = 42;
-    byte okm1[42];
-    byte ikm1[22] = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
-                      0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
-                      0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b };
-    byte salt1[13] ={ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-                      0x08, 0x09, 0x0a, 0x0b, 0x0c };
-    byte info1[10] ={ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
-                      0xf8, 0xf9 };
-    byte res1[42] = { 0x0a, 0xc1, 0xaf, 0x70, 0x02, 0xb3, 0xd7, 0x61,
-                      0xd1, 0xe5, 0x52, 0x98, 0xda, 0x9d, 0x05, 0x06,
-                      0xb9, 0xae, 0x52, 0x05, 0x72, 0x20, 0xa3, 0x06,
-                      0xe0, 0x7b, 0x6b, 0x87, 0xe8, 0xdf, 0x21, 0xd0,
-                      0xea, 0x00, 0x03, 0x3d, 0xe0, 0x39, 0x84, 0xd3,
-                      0x49, 0x18 };
-    byte res2[42] = { 0x08, 0x5a, 0x01, 0xea, 0x1b, 0x10, 0xf3, 0x69,
-                      0x33, 0x06, 0x8b, 0x56, 0xef, 0xa5, 0xad, 0x81,
-                      0xa4, 0xf1, 0x4b, 0x82, 0x2f, 0x5b, 0x09, 0x15,
-                      0x68, 0xa9, 0xcd, 0xd4, 0xf1, 0x55, 0xfd, 0xa2,
-                      0xc2, 0x2e, 0x42, 0x24, 0x78, 0xd3, 0x05, 0xf3,
-                      0xf8, 0x96 };
-    byte res3[42] = { 0x8d, 0xa4, 0xe7, 0x75, 0xa5, 0x63, 0xc1, 0x8f,
-                      0x71, 0x5f, 0x80, 0x2a, 0x06, 0x3c, 0x5a, 0x31,
-                      0xb8, 0xa1, 0x1f, 0x5c, 0x5e, 0xe1, 0x87, 0x9e,
-                      0xc3, 0x45, 0x4e, 0x5f, 0x3c, 0x73, 0x8d, 0x2d,
-                      0x9d, 0x20, 0x13, 0x95, 0xfa, 0xa4, 0xb6, 0x1a,
-                      0x96, 0xc8 };
-    byte res4[42] = { 0x3c, 0xb2, 0x5f, 0x25, 0xfa, 0xac, 0xd5, 0x7a,
-                      0x90, 0x43, 0x4f, 0x64, 0xd0, 0x36, 0x2f, 0x2a,
-                      0x2d, 0x2d, 0x0a, 0x90, 0xcf, 0x1a, 0x5a, 0x4c,
-                      0x5d, 0xb0, 0x2d, 0x56, 0xec, 0xc4, 0xc5, 0xbf,
-                      0x34, 0x00, 0x72, 0x08, 0xd5, 0xb8, 0x87, 0x18,
-                      0x58, 0x65 };
-
-    (void)res1;
-    (void)res2;
-    (void)res3;
-    (void)res4;
-    (void)salt1;
-    (void)info1;
-
-#ifndef NO_SHA
-    ret = wc_HKDF(SHA, ikm1, 22, NULL, 0, NULL, 0, okm1, L);
-    if (ret != 0)
-        return -2001;
-
-    if (memcmp(okm1, res1, L) != 0)
-        return -2002;
-
-#ifndef HAVE_FIPS
-    /* fips can't have key size under 14 bytes, salt is key too */
-    ret = wc_HKDF(SHA, ikm1, 11, salt1, 13, info1, 10, okm1, L);
-    if (ret != 0)
-        return -2003;
-
-    if (memcmp(okm1, res2, L) != 0)
-        return -2004;
-#endif /* HAVE_FIPS */
-#endif /* NO_SHA */
-
-#ifndef NO_SHA256
-    ret = wc_HKDF(SHA256, ikm1, 22, NULL, 0, NULL, 0, okm1, L);
-    if (ret != 0)
-        return -2005;
-
-    if (memcmp(okm1, res3, L) != 0)
-        return -2006;
-
-#ifndef HAVE_FIPS
-    /* fips can't have key size under 14 bytes, salt is key too */
-    ret = wc_HKDF(SHA256, ikm1, 22, salt1, 13, info1, 10, okm1, L);
-    if (ret != 0)
-        return -2007;
-
-    if (memcmp(okm1, res4, L) != 0)
-        return -2007;
-#endif /* HAVE_FIPS */
-#endif /* NO_SHA256 */
-
-    return 0;
-}
-
-#endif /* HAVE_HKDF */
-
-
-#ifdef HAVE_ECC
-
-typedef struct rawEccVector {
-    const char* msg;
-    const char* Qx;
-    const char* Qy;
-    const char* d;
-    const char* R;
-    const char* S;
-    const char* curveName;
-    size_t msgLen;
-} rawEccVector;
-
-int ecc_test(void)
-{
-    RNG     rng;
-    byte    sharedA[1024];
-    byte    sharedB[1024];
-    byte    sig[1024];
-    byte    digest[20];
-    byte    exportBuf[1024];
-    word32  x, y;
-    int     i, verify, ret;
-    ecc_key userA, userB, pubKey;
-
-    ret = wc_InitRng(&rng);
-    if (ret != 0)
-        return -1001;
-
-    wc_ecc_init(&userA);
-    wc_ecc_init(&userB);
-    wc_ecc_init(&pubKey);
-
-    ret = wc_ecc_make_key(&rng, 32, &userA);
-
-    if (ret != 0)
-        return -1014;
-
-    ret = wc_ecc_check_key(&userA);
-    if (ret != 0)
-        return -1024;
-
-    ret = wc_ecc_make_key(&rng, 32, &userB);
-
-    if (ret != 0)
-        return -1002;
-
-    x = sizeof(sharedA);
-    ret = wc_ecc_shared_secret(&userA, &userB, sharedA, &x);
-
-    if (ret != 0)
-        return -1015;
-
-    y = sizeof(sharedB);
-    ret = wc_ecc_shared_secret(&userB, &userA, sharedB, &y);
-
-    if (ret != 0)
-        return -1003;
-
-    if (y != x)
-        return -1004;
-
-    if (memcmp(sharedA, sharedB, x))
-        return -1005;
-
-    x = sizeof(exportBuf);
-    ret = wc_ecc_export_x963(&userA, exportBuf, &x);
-    if (ret != 0)
-        return -1006;
-
-    ret = wc_ecc_import_x963(exportBuf, x, &pubKey);
-
-    if (ret != 0)
-        return -1007;
-
-    y = sizeof(sharedB);
-    ret = wc_ecc_shared_secret(&userB, &pubKey, sharedB, &y);
-
-    if (ret != 0)
-        return -1008;
-
-    if (memcmp(sharedA, sharedB, y))
-        return -1009;
-
-#ifdef HAVE_COMP_KEY
-    /* try compressed export / import too */
-    x = sizeof(exportBuf);
-    ret = wc_ecc_export_x963_ex(&userA, exportBuf, &x, 1);
-    if (ret != 0)
-        return -1010;
-
-    wc_ecc_free(&pubKey);
-    wc_ecc_init(&pubKey);
-    ret = wc_ecc_import_x963(exportBuf, x, &pubKey);
-
-    if (ret != 0)
-        return -1011;
-#endif
-
-    y = sizeof(sharedB);
-    ret = wc_ecc_shared_secret(&userB, &pubKey, sharedB, &y);
-
-    if (ret != 0)
-        return -1012;
-
-    if (memcmp(sharedA, sharedB, y))
-        return -1013;
-
-    /* test DSA sign hash */
-    for (i = 0; i < (int)sizeof(digest); i++)
-        digest[i] = (byte)i;
-
-    x = sizeof(sig);
-    ret = wc_ecc_sign_hash(digest, sizeof(digest), sig, &x, &rng, &userA);
-
-    if (ret != 0)
-        return -1014;
-
-    verify = 0;
-    ret = wc_ecc_verify_hash(sig, x, digest, sizeof(digest), &verify, &userA);
-
-    if (ret != 0)
-        return -1015;
-
-    if (verify != 1)
-        return -1016;
-
-    x = sizeof(exportBuf);
-    ret = wc_ecc_export_private_only(&userA, exportBuf, &x);
-    if (ret != 0)
-        return -1017;
-
-#if !defined(NO_SHA) && \
-    ((defined(HAVE_ECC192) && defined(HAVE_ECC224)) || defined(HAVE_ALL_CURVES))
-    {
-        /* test raw ECC key import */
-        Sha sha;
-        byte hash[SHA_DIGEST_SIZE];
-        rawEccVector a, b;
-        rawEccVector test_ecc[2];
-        int times = sizeof(test_ecc) / sizeof(rawEccVector);
-
-        /* first [P-192,SHA-1] vector from FIPS 186-3 NIST vectors */
-        a.msg = "\xeb\xf7\x48\xd7\x48\xeb\xbc\xa7\xd2\x9f\xb4\x73\x69\x8a"
-                "\x6e\x6b\x4f\xb1\x0c\x86\x5d\x4a\xf0\x24\xcc\x39\xae\x3d"
-                "\xf3\x46\x4b\xa4\xf1\xd6\xd4\x0f\x32\xbf\x96\x18\xa9\x1b"
-                "\xb5\x98\x6f\xa1\xa2\xaf\x04\x8a\x0e\x14\xdc\x51\xe5\x26"
-                "\x7e\xb0\x5e\x12\x7d\x68\x9d\x0a\xc6\xf1\xa7\xf1\x56\xce"
-                "\x06\x63\x16\xb9\x71\xcc\x7a\x11\xd0\xfd\x7a\x20\x93\xe2"
-                "\x7c\xf2\xd0\x87\x27\xa4\xe6\x74\x8c\xc3\x2f\xd5\x9c\x78"
-                "\x10\xc5\xb9\x01\x9d\xf2\x1c\xdc\xc0\xbc\xa4\x32\xc0\xa3"
-                "\xee\xd0\x78\x53\x87\x50\x88\x77\x11\x43\x59\xce\xe4\xa0"
-                "\x71\xcf";
-        a.msgLen = 128;
-        a.Qx = "07008ea40b08dbe76432096e80a2494c94982d2d5bcf98e6";
-        a.Qy = "76fab681d00b414ea636ba215de26d98c41bd7f2e4d65477";
-        a.d  = "e14f37b3d1374ff8b03f41b9b3fdd2f0ebccf275d660d7f3";
-        a.R  = "6994d962bdd0d793ffddf855ec5bf2f91a9698b46258a63e";
-        a.S  = "02ba6465a234903744ab02bc8521405b73cf5fc00e1a9f41";
-        a.curveName = "ECC-192";
-
-        /* first [P-224,SHA-1] vector from FIPS 186-3 NIST vectors */
-        b.msg = "\x36\xc8\xb2\x29\x86\x48\x7f\x67\x7c\x18\xd0\x97\x2a\x9e"
-                "\x20\x47\xb3\xaf\xa5\x9e\xc1\x62\x76\x4e\xc3\x0b\x5b\x69"
-                "\xe0\x63\x0f\x99\x0d\x4e\x05\xc2\x73\xb0\xe5\xa9\xd4\x28"
-                "\x27\xb6\x95\xfc\x2d\x64\xd9\x13\x8b\x1c\xf4\xc1\x21\x55"
-                "\x89\x4c\x42\x13\x21\xa7\xbb\x97\x0b\xdc\xe0\xfb\xf0\xd2"
-                "\xae\x85\x61\xaa\xd8\x71\x7f\x2e\x46\xdf\xe3\xff\x8d\xea"
-                "\xb4\xd7\x93\x23\x56\x03\x2c\x15\x13\x0d\x59\x9e\x26\xc1"
-                "\x0f\x2f\xec\x96\x30\x31\xac\x69\x38\xa1\x8d\x66\x45\x38"
-                "\xb9\x4d\xac\x55\x34\xef\x7b\x59\x94\x24\xd6\x9b\xe1\xf7"
-                "\x1c\x20";
-        b.msgLen = 128;
-        b.Qx = "8a4dca35136c4b70e588e23554637ae251077d1365a6ba5db9585de7";
-        b.Qy = "ad3dee06de0be8279d4af435d7245f14f3b4f82eb578e519ee0057b1";
-        b.d  = "97c4b796e1639dd1035b708fc00dc7ba1682cec44a1002a1a820619f";
-        b.R  = "147b33758321e722a0360a4719738af848449e2c1d08defebc1671a7";
-        b.S  = "24fc7ed7f1352ca3872aa0916191289e2e04d454935d50fe6af3ad5b";
-        b.curveName = "ECC-224";
-
-        test_ecc[0] = a;
-        test_ecc[1] = b;
-
-        for (i = 0; i < times; i++) {
-
-            wc_ecc_free(&userA);
-            wc_ecc_init(&userA);
-
-            memset(sig, 0, sizeof(sig));
-            x = sizeof(sig);
-
-            /* calculate SHA-1 hash of message */
-            ret = wc_InitSha(&sha);
-            if (ret != 0)
-                return -1015 - i;
-
-            wc_ShaUpdate(&sha, (byte*)test_ecc[i].msg, (word32)test_ecc[i].msgLen);
-            wc_ShaFinal(&sha, hash);
-
-            ret = wc_ecc_import_raw(&userA, test_ecc[i].Qx, test_ecc[i].Qy,
-                                 test_ecc[i].d, test_ecc[i].curveName);
-            if (ret != 0)
-                return -1017 - i;
-
-            ret = wc_ecc_rs_to_sig(test_ecc[i].R, test_ecc[i].S, sig, &x);
-            if (ret != 0)
-                return -1019 - i;
-
-            ret = wc_ecc_verify_hash(sig, x, hash, sizeof(hash), &verify, &userA);
-            if (ret != 0)
-                return -1021 - i;
-
-            if (verify != 1)
-                return -1023 - i;
-        }
-    }
-#endif /* defined(HAVE_ECC192) && defined(HAVE_ECC256) */
-
-
-#ifdef WOLFSSL_KEY_GEN
-    {
-        int   derSz, pemSz;
-        byte  der[FOURK_BUF];
-        byte  pem[FOURK_BUF];
-        FILE* keyFile;
-        FILE* pemFile;
-
-        derSz = wc_EccKeyToDer(&userB, der, FOURK_BUF);
-        if (derSz < 0) {
-            return -1024;
-        }
-
-        keyFile = fopen("./ecc-key.der", "wb");
-        if (!keyFile) {
-            return -1025;
-        }
-        ret = (int)fwrite(der, 1, derSz, keyFile);
-        fclose(keyFile);
-        if (ret != derSz) {
-            return -1026;
-        }
-
-        pemSz = wc_DerToPem(der, derSz, pem, FOURK_BUF, ECC_PRIVATEKEY_TYPE);
-        if (pemSz < 0) {
-            return -1027;
-        }
-
-        pemFile = fopen("./ecc-key.pem", "wb");
-        if (!pemFile) {
-            return -1028;
-        }
-        ret = (int)fwrite(pem, 1, pemSz, pemFile);
-        fclose(pemFile);
-        if (ret != pemSz) {
-            return -1029;
-        }
-    }
-#endif /* WOLFSSL_KEY_GEN */
-
-    wc_ecc_free(&pubKey);
-    wc_ecc_free(&userB);
-    wc_ecc_free(&userA);
-    wc_FreeRng(&rng);
-
-    return 0;
-}
-
-#ifdef HAVE_ECC_ENCRYPT
-
-int ecc_encrypt_test(void)
-{
-    RNG     rng;
-    int     ret;
-    ecc_key userA, userB;
-    byte    msg[48];
-    byte    plain[48];
-    byte    out[80];
-    word32  outSz   = sizeof(out);
-    word32  plainSz = sizeof(plain);
-    int     i;
-
-    ret = wc_InitRng(&rng);
-    if (ret != 0)
-        return -3001;
-
-    wc_ecc_init(&userA);
-    wc_ecc_init(&userB);
-
-    ret  = wc_ecc_make_key(&rng, 32, &userA);
-    ret += wc_ecc_make_key(&rng, 32, &userB);
-
-    if (ret != 0)
-        return -3002;
-
-    for (i = 0; i < 48; i++)
-        msg[i] = i;
-
-    /* encrypt msg to B */
-    ret = wc_ecc_encrypt(&userA, &userB, msg, sizeof(msg), out, &outSz, NULL);
-    if (ret != 0)
-        return -3003;
-
-    /* decrypt msg from A */
-    ret = wc_ecc_decrypt(&userB, &userA, out, outSz, plain, &plainSz, NULL);
-    if (ret != 0)
-        return -3004;
-
-    if (memcmp(plain, msg, sizeof(msg)) != 0)
-        return -3005;
-
-
-    {  /* let's verify message exchange works, A is client, B is server */
-        ecEncCtx* cliCtx = wc_ecc_ctx_new(REQ_RESP_CLIENT, &rng);
-        ecEncCtx* srvCtx = wc_ecc_ctx_new(REQ_RESP_SERVER, &rng);
-
-        byte cliSalt[EXCHANGE_SALT_SZ];
-        byte srvSalt[EXCHANGE_SALT_SZ];
-        const byte* tmpSalt;
-
-        if (cliCtx == NULL || srvCtx == NULL)
-            return -3006;
-
-        /* get salt to send to peer */
-        tmpSalt = wc_ecc_ctx_get_own_salt(cliCtx);
-        if (tmpSalt == NULL)
-            return -3007;
-        memcpy(cliSalt, tmpSalt, EXCHANGE_SALT_SZ);
-
-        tmpSalt = wc_ecc_ctx_get_own_salt(srvCtx);
-        if (tmpSalt == NULL)
-            return -3007;
-        memcpy(srvSalt, tmpSalt, EXCHANGE_SALT_SZ);
-
-        /* in actual use, we'd get the peer's salt over the transport */
-        ret  = wc_ecc_ctx_set_peer_salt(cliCtx, srvSalt);
-        ret += wc_ecc_ctx_set_peer_salt(srvCtx, cliSalt);
-
-        ret += wc_ecc_ctx_set_info(cliCtx, (byte*)"wolfSSL MSGE", 11);
-        ret += wc_ecc_ctx_set_info(srvCtx, (byte*)"wolfSSL MSGE", 11);
-
-        if (ret != 0)
-            return -3008;
-
-        /* get encrypted msg (request) to send to B */
-        outSz  = sizeof(out);
-        ret = wc_ecc_encrypt(&userA, &userB, msg, sizeof(msg), out, &outSz,cliCtx);
-        if (ret != 0)
-            return -3009;
-
-        /* B decrypts msg (request) from A */
-        plainSz = sizeof(plain);
-        ret = wc_ecc_decrypt(&userB, &userA, out, outSz, plain, &plainSz, srvCtx);
-        if (ret != 0)
-            return -3010;
-
-        if (memcmp(plain, msg, sizeof(msg)) != 0)
-            return -3011;
-
-        {
-            /* msg2 (response) from B to A */
-            byte    msg2[48];
-            byte    plain2[48];
-            byte    out2[80];
-            word32  outSz2   = sizeof(out2);
-            word32  plainSz2 = sizeof(plain2);
-
-            for (i = 0; i < 48; i++)
-                msg2[i] = i+48;
-
-            /* get encrypted msg (response) to send to B */
-            ret = wc_ecc_encrypt(&userB, &userA, msg2, sizeof(msg2), out2,
-                              &outSz2, srvCtx);
-            if (ret != 0)
-                return -3012;
-
-            /* A decrypts msg (response) from B */
-            ret = wc_ecc_decrypt(&userA, &userB, out2, outSz2, plain2, &plainSz2,
-                             cliCtx);
-            if (ret != 0)
-                return -3013;
-
-            if (memcmp(plain2, msg2, sizeof(msg2)) != 0)
-                return -3014;
-        }
-
-        /* cleanup */
-        wc_ecc_ctx_free(srvCtx);
-        wc_ecc_ctx_free(cliCtx);
-    }
-
-    /* cleanup */
-    wc_ecc_free(&userB);
-    wc_ecc_free(&userA);
-    wc_FreeRng(&rng);
-
-    return 0;
-}
-
-#endif /* HAVE_ECC_ENCRYPT */
-#endif /* HAVE_ECC */
-
-
-#ifdef HAVE_CURVE25519
-
-int curve25519_test(void)
-{
-    RNG     rng;
-    byte    sharedA[32];
-    byte    sharedB[32];
-    byte    exportBuf[32];
-    word32  x, y;
-    curve25519_key userA, userB, pubKey;
-
-    /* test vectors from
-       https://tools.ietf.org/html/draft-josefsson-tls-curve25519-03
-     */
-
-    /* secret key for party a */
-    byte sa[] = {
-        0x5A,0xC9,0x9F,0x33,0x63,0x2E,0x5A,0x76,
-        0x8D,0xE7,0xE8,0x1B,0xF8,0x54,0xC2,0x7C,
-        0x46,0xE3,0xFB,0xF2,0xAB,0xBA,0xCD,0x29,
-        0xEC,0x4A,0xFF,0x51,0x73,0x69,0xC6,0x60
-    };
-
-    /* public key for party a */
-    byte pa[] = {
-        0x05,0x7E,0x23,0xEA,0x9F,0x1C,0xBE,0x8A,
-        0x27,0x16,0x8F,0x6E,0x69,0x6A,0x79,0x1D,
-        0xE6,0x1D,0xD3,0xAF,0x7A,0xCD,0x4E,0xEA,
-        0xCC,0x6E,0x7B,0xA5,0x14,0xFD,0xA8,0x63
-    };
-
-    /* secret key for party b */
-    byte sb[] = {
-        0x47,0xDC,0x3D,0x21,0x41,0x74,0x82,0x0E,
-        0x11,0x54,0xB4,0x9B,0xC6,0xCD,0xB2,0xAB,
-        0xD4,0x5E,0xE9,0x58,0x17,0x05,0x5D,0x25,
-        0x5A,0xA3,0x58,0x31,0xB7,0x0D,0x32,0x60
-    };
-
-    /* public key for party b */
-    byte pb[] = {
-        0x6E,0xB8,0x9D,0xA9,0x19,0x89,0xAE,0x37,
-        0xC7,0xEA,0xC7,0x61,0x8D,0x9E,0x5C,0x49,
-        0x51,0xDB,0xA1,0xD7,0x3C,0x28,0x5A,0xE1,
-        0xCD,0x26,0xA8,0x55,0x02,0x0E,0xEF,0x04
-    };
-
-    /* expected shared key */
-    byte ss[] = {
-        0x61,0x45,0x0C,0xD9,0x8E,0x36,0x01,0x6B,
-        0x58,0x77,0x6A,0x89,0x7A,0x9F,0x0A,0xEF,
-        0x73,0x8B,0x99,0xF0,0x94,0x68,0xB8,0xD6,
-        0xB8,0x51,0x11,0x84,0xD5,0x34,0x94,0xAB
-    };
-
-    if (wc_InitRng(&rng) != 0)
-        return -1001;
-
-    wc_curve25519_init(&userA);
-    wc_curve25519_init(&userB);
-    wc_curve25519_init(&pubKey);
-
-    /* make curve25519 keys */
-    if (wc_curve25519_make_key(&rng, 32, &userA) != 0)
-        return -1002;
-
-    if (wc_curve25519_make_key(&rng, 32, &userB) != 0)
-        return -1003;
-
-    /* find shared secret key */
-    if (wc_curve25519_shared_secret(&userA, &userB, sharedA, &x) != 0)
-        return -1004;
-
-    if (wc_curve25519_shared_secret(&userB, &userA, sharedB, &y) != 0)
-        return -1005;
-
-    /* compare shared secret keys to test they are the same */
-    if (y != x)
-        return -1006;
-
-    if (XMEMCMP(sharedA, sharedB, x))
-        return -1007;
-
-    /* export a public key and import it for another user */
-    if (wc_curve25519_export_public(&userA, exportBuf, &x) != 0)
-        return -1008;
-
-    if (wc_curve25519_import_public(exportBuf, x, &pubKey) != 0)
-        return -1009;
-
-    /* test shared key after importing a public key */
-    XMEMSET(sharedB, 0, sizeof(sharedB));
-    if (wc_curve25519_shared_secret(&userB, &pubKey, sharedB, &y) != 0)
-        return -1010;
-
-    if (XMEMCMP(sharedA, sharedB, y))
-        return -1011;
-
-    /* import RFC test vectors and compare shared key */
-    if (wc_curve25519_import_private_raw(sa, sizeof(sa), pa, sizeof(pa), &userA)
-            != 0)
-        return -1012;
-
-    if (wc_curve25519_import_private_raw(sb, sizeof(sb), pb, sizeof(pb), &userB)
-            != 0)
-        return -1013;
-
-    /* test against known test vector */
-    XMEMSET(sharedB, 0, sizeof(sharedB));
-    if (wc_curve25519_shared_secret(&userA, &userB, sharedB, &y) != 0)
-        return -1014;
-
-    if (XMEMCMP(ss, sharedB, y))
-        return -1015;
-
-    /* test swaping roles of keys and generating same shared key */
-    XMEMSET(sharedB, 0, sizeof(sharedB));
-    if (wc_curve25519_shared_secret(&userB, &userA, sharedB, &y) != 0)
-        return -1016;
-
-    if (XMEMCMP(ss, sharedB, y))
-        return -1017;
-
-    /* clean up keys when done */
-    wc_curve25519_free(&pubKey);
-    wc_curve25519_free(&userB);
-    wc_curve25519_free(&userA);
-
-    wc_FreeRng(&rng);
-
-    return 0;
-}
-#endif /* HAVE_CURVE25519 */
-
-
-#ifdef HAVE_ED25519
-int ed25519_test(void)
-{
-    RNG    rng;
-    byte   out[ED25519_SIG_SIZE];
-    byte   exportPKey[ED25519_KEY_SIZE];
-    byte   exportSKey[ED25519_KEY_SIZE];
-    word32 outlen;
-    word32 exportPSz;
-    word32 exportSSz;
-    word32 keySz, sigSz;
-    int    i, verify;
-    ed25519_key key;
-    ed25519_key key2;
-
-    /* test vectors from
-       https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-02
-     */
-
-    const byte sKey1[] = {
-		0x9d,0x61,0xb1,0x9d,0xef,0xfd,0x5a,0x60,
-		0xba,0x84,0x4a,0xf4,0x92,0xec,0x2c,0xc4,
-		0x44,0x49,0xc5,0x69,0x7b,0x32,0x69,0x19,
-		0x70,0x3b,0xac,0x03,0x1c,0xae,0x7f,0x60
-    };
-
-    const byte sKey2[] = {
-		0x4c,0xcd,0x08,0x9b,0x28,0xff,0x96,0xda,
-		0x9d,0xb6,0xc3,0x46,0xec,0x11,0x4e,0x0f,
-		0x5b,0x8a,0x31,0x9f,0x35,0xab,0xa6,0x24,
-		0xda,0x8c,0xf6,0xed,0x4f,0xb8,0xa6,0xfb
-    };
-
-    const byte sKey3[] = {
-		0xc5,0xaa,0x8d,0xf4,0x3f,0x9f,0x83,0x7b,
-		0xed,0xb7,0x44,0x2f,0x31,0xdc,0xb7,0xb1,
-		0x66,0xd3,0x85,0x35,0x07,0x6f,0x09,0x4b,
-		0x85,0xce,0x3a,0x2e,0x0b,0x44,0x58,0xf7
-    };
-
-    /* uncompressed test */
-    const byte sKey4[] = {
-		0x9d,0x61,0xb1,0x9d,0xef,0xfd,0x5a,0x60,
-		0xba,0x84,0x4a,0xf4,0x92,0xec,0x2c,0xc4,
-		0x44,0x49,0xc5,0x69,0x7b,0x32,0x69,0x19,
-		0x70,0x3b,0xac,0x03,0x1c,0xae,0x7f,0x60
-    };
-
-    /* compressed prefix test */
-    const byte sKey5[] = {
-		0x9d,0x61,0xb1,0x9d,0xef,0xfd,0x5a,0x60,
-		0xba,0x84,0x4a,0xf4,0x92,0xec,0x2c,0xc4,
-		0x44,0x49,0xc5,0x69,0x7b,0x32,0x69,0x19,
-		0x70,0x3b,0xac,0x03,0x1c,0xae,0x7f,0x60
-    };
-
-    const byte sKey6[] = {
-		0xf5,0xe5,0x76,0x7c,0xf1,0x53,0x31,0x95,
-		0x17,0x63,0x0f,0x22,0x68,0x76,0xb8,0x6c,
-		0x81,0x60,0xcc,0x58,0x3b,0xc0,0x13,0x74,
-		0x4c,0x6b,0xf2,0x55,0xf5,0xcc,0x0e,0xe5
-    };
-
-    const byte* sKeys[] = {sKey1, sKey2, sKey3, sKey4, sKey5, sKey6};
-
-    const byte pKey1[] = {
-		0xd7,0x5a,0x98,0x01,0x82,0xb1,0x0a,0xb7,
-		0xd5,0x4b,0xfe,0xd3,0xc9,0x64,0x07,0x3a,
-		0x0e,0xe1,0x72,0xf3,0xda,0xa6,0x23,0x25,
-		0xaf,0x02,0x1a,0x68,0xf7,0x07,0x51,0x1a
-    };
-
-    const byte pKey2[] = {
-		0x3d,0x40,0x17,0xc3,0xe8,0x43,0x89,0x5a,
-		0x92,0xb7,0x0a,0xa7,0x4d,0x1b,0x7e,0xbc,
-        0x9c,0x98,0x2c,0xcf,0x2e,0xc4,0x96,0x8c,
-		0xc0,0xcd,0x55,0xf1,0x2a,0xf4,0x66,0x0c
-    };
-
-    const byte pKey3[] = {
-		0xfc,0x51,0xcd,0x8e,0x62,0x18,0xa1,0xa3,
-		0x8d,0xa4,0x7e,0xd0,0x02,0x30,0xf0,0x58,
-		0x08,0x16,0xed,0x13,0xba,0x33,0x03,0xac,
-		0x5d,0xeb,0x91,0x15,0x48,0x90,0x80,0x25
-    };
-
-    /* uncompressed test */
-    const byte pKey4[] = {
-		0x04,0x55,0xd0,0xe0,0x9a,0x2b,0x9d,0x34,
-		0x29,0x22,0x97,0xe0,0x8d,0x60,0xd0,0xf6,
-		0x20,0xc5,0x13,0xd4,0x72,0x53,0x18,0x7c,
-		0x24,0xb1,0x27,0x86,0xbd,0x77,0x76,0x45,
-		0xce,0x1a,0x51,0x07,0xf7,0x68,0x1a,0x02,
-		0xaf,0x25,0x23,0xa6,0xda,0xf3,0x72,0xe1,
-		0x0e,0x3a,0x07,0x64,0xc9,0xd3,0xfe,0x4b,
-		0xd5,0xb7,0x0a,0xb1,0x82,0x01,0x98,0x5a,
-		0xd7
-    };
-
-    /* compressed prefix */
-    const byte pKey5[] = {
-		0x40,0xd7,0x5a,0x98,0x01,0x82,0xb1,0x0a,0xb7,
-		0xd5,0x4b,0xfe,0xd3,0xc9,0x64,0x07,0x3a,
-		0x0e,0xe1,0x72,0xf3,0xda,0xa6,0x23,0x25,
-		0xaf,0x02,0x1a,0x68,0xf7,0x07,0x51,0x1a
-    };
-
-    const byte pKey6[] = {
-		0x27,0x81,0x17,0xfc,0x14,0x4c,0x72,0x34,
-		0x0f,0x67,0xd0,0xf2,0x31,0x6e,0x83,0x86,
-		0xce,0xff,0xbf,0x2b,0x24,0x28,0xc9,0xc5,
-		0x1f,0xef,0x7c,0x59,0x7f,0x1d,0x42,0x6e
-    };
-
-    const byte* pKeys[] = {pKey1, pKey2, pKey3, pKey4, pKey5, pKey6};
-    const byte  pKeySz[] = {sizeof(pKey1), sizeof(pKey2), sizeof(pKey3),
-                            sizeof(pKey4), sizeof(pKey5), sizeof(pKey6)};
-
-    const byte sig1[] = {
-		0xe5,0x56,0x43,0x00,0xc3,0x60,0xac,0x72,
-		0x90,0x86,0xe2,0xcc,0x80,0x6e,0x82,0x8a,
-		0x84,0x87,0x7f,0x1e,0xb8,0xe5,0xd9,0x74,
-		0xd8,0x73,0xe0,0x65,0x22,0x49,0x01,0x55,
-		0x5f,0xb8,0x82,0x15,0x90,0xa3,0x3b,0xac,
-		0xc6,0x1e,0x39,0x70,0x1c,0xf9,0xb4,0x6b,
-		0xd2,0x5b,0xf5,0xf0,0x59,0x5b,0xbe,0x24,
-		0x65,0x51,0x41,0x43,0x8e,0x7a,0x10,0x0b
-    };
-
-    const byte sig2[] = {
-		0x92,0xa0,0x09,0xa9,0xf0,0xd4,0xca,0xb8,
-		0x72,0x0e,0x82,0x0b,0x5f,0x64,0x25,0x40,
-		0xa2,0xb2,0x7b,0x54,0x16,0x50,0x3f,0x8f,
-		0xb3,0x76,0x22,0x23,0xeb,0xdb,0x69,0xda,
-		0x08,0x5a,0xc1,0xe4,0x3e,0x15,0x99,0x6e,
-		0x45,0x8f,0x36,0x13,0xd0,0xf1,0x1d,0x8c,
-		0x38,0x7b,0x2e,0xae,0xb4,0x30,0x2a,0xee,
-		0xb0,0x0d,0x29,0x16,0x12,0xbb,0x0c,0x00
-    };
-
-    const byte sig3[] = {
-		0x62,0x91,0xd6,0x57,0xde,0xec,0x24,0x02,
-		0x48,0x27,0xe6,0x9c,0x3a,0xbe,0x01,0xa3,
-		0x0c,0xe5,0x48,0xa2,0x84,0x74,0x3a,0x44,
-		0x5e,0x36,0x80,0xd7,0xdb,0x5a,0xc3,0xac,
-		0x18,0xff,0x9b,0x53,0x8d,0x16,0xf2,0x90,
-		0xae,0x67,0xf7,0x60,0x98,0x4d,0xc6,0x59,
-		0x4a,0x7c,0x15,0xe9,0x71,0x6e,0xd2,0x8d,
-		0xc0,0x27,0xbe,0xce,0xea,0x1e,0xc4,0x0a
-    };
-
-    /* uncompressed test */
-    const byte sig4[] = {
-		0xe5,0x56,0x43,0x00,0xc3,0x60,0xac,0x72,
-		0x90,0x86,0xe2,0xcc,0x80,0x6e,0x82,0x8a,
-		0x84,0x87,0x7f,0x1e,0xb8,0xe5,0xd9,0x74,
-		0xd8,0x73,0xe0,0x65,0x22,0x49,0x01,0x55,
-		0x5f,0xb8,0x82,0x15,0x90,0xa3,0x3b,0xac,
-		0xc6,0x1e,0x39,0x70,0x1c,0xf9,0xb4,0x6b,
-		0xd2,0x5b,0xf5,0xf0,0x59,0x5b,0xbe,0x24,
-		0x65,0x51,0x41,0x43,0x8e,0x7a,0x10,0x0b
-    };
-
-    /* compressed prefix */
-    const byte sig5[] = {
-		0xe5,0x56,0x43,0x00,0xc3,0x60,0xac,0x72,
-		0x90,0x86,0xe2,0xcc,0x80,0x6e,0x82,0x8a,
-		0x84,0x87,0x7f,0x1e,0xb8,0xe5,0xd9,0x74,
-		0xd8,0x73,0xe0,0x65,0x22,0x49,0x01,0x55,
-		0x5f,0xb8,0x82,0x15,0x90,0xa3,0x3b,0xac,
-		0xc6,0x1e,0x39,0x70,0x1c,0xf9,0xb4,0x6b,
-		0xd2,0x5b,0xf5,0xf0,0x59,0x5b,0xbe,0x24,
-		0x65,0x51,0x41,0x43,0x8e,0x7a,0x10,0x0b
-    };
-
-    const byte sig6[] = {
-		0x0a,0xab,0x4c,0x90,0x05,0x01,0xb3,0xe2,
-		0x4d,0x7c,0xdf,0x46,0x63,0x32,0x6a,0x3a,
-		0x87,0xdf,0x5e,0x48,0x43,0xb2,0xcb,0xdb,
-		0x67,0xcb,0xf6,0xe4,0x60,0xfe,0xc3,0x50,
-		0xaa,0x53,0x71,0xb1,0x50,0x8f,0x9f,0x45,
-		0x28,0xec,0xea,0x23,0xc4,0x36,0xd9,0x4b,
-		0x5e,0x8f,0xcd,0x4f,0x68,0x1e,0x30,0xa6,
-		0xac,0x00,0xa9,0x70,0x4a,0x18,0x8a,0x03
-    };
-
-    const byte* sigs[] = {sig1, sig2, sig3, sig4, sig5, sig6};
-
-    const byte msg1[]  = {};
-    const byte msg2[]  = {0x72};
-    const byte msg3[]  = {0xAF,0x82};
-
-    /* test of a 1024 byte long message */
-    const byte msg4[]  = {
-		0x08,0xb8,0xb2,0xb7,0x33,0x42,0x42,0x43,
-		0x76,0x0f,0xe4,0x26,0xa4,0xb5,0x49,0x08,
-		0x63,0x21,0x10,0xa6,0x6c,0x2f,0x65,0x91,
-		0xea,0xbd,0x33,0x45,0xe3,0xe4,0xeb,0x98,
-		0xfa,0x6e,0x26,0x4b,0xf0,0x9e,0xfe,0x12,
-		0xee,0x50,0xf8,0xf5,0x4e,0x9f,0x77,0xb1,
-		0xe3,0x55,0xf6,0xc5,0x05,0x44,0xe2,0x3f,
-		0xb1,0x43,0x3d,0xdf,0x73,0xbe,0x84,0xd8,
-		0x79,0xde,0x7c,0x00,0x46,0xdc,0x49,0x96,
-		0xd9,0xe7,0x73,0xf4,0xbc,0x9e,0xfe,0x57,
-		0x38,0x82,0x9a,0xdb,0x26,0xc8,0x1b,0x37,
-		0xc9,0x3a,0x1b,0x27,0x0b,0x20,0x32,0x9d,
-		0x65,0x86,0x75,0xfc,0x6e,0xa5,0x34,0xe0,
-		0x81,0x0a,0x44,0x32,0x82,0x6b,0xf5,0x8c,
-		0x94,0x1e,0xfb,0x65,0xd5,0x7a,0x33,0x8b,
-		0xbd,0x2e,0x26,0x64,0x0f,0x89,0xff,0xbc,
-		0x1a,0x85,0x8e,0xfc,0xb8,0x55,0x0e,0xe3,
-		0xa5,0xe1,0x99,0x8b,0xd1,0x77,0xe9,0x3a,
-		0x73,0x63,0xc3,0x44,0xfe,0x6b,0x19,0x9e,
-		0xe5,0xd0,0x2e,0x82,0xd5,0x22,0xc4,0xfe,
-		0xba,0x15,0x45,0x2f,0x80,0x28,0x8a,0x82,
-		0x1a,0x57,0x91,0x16,0xec,0x6d,0xad,0x2b,
-		0x3b,0x31,0x0d,0xa9,0x03,0x40,0x1a,0xa6,
-		0x21,0x00,0xab,0x5d,0x1a,0x36,0x55,0x3e,
-		0x06,0x20,0x3b,0x33,0x89,0x0c,0xc9,0xb8,
-		0x32,0xf7,0x9e,0xf8,0x05,0x60,0xcc,0xb9,
-		0xa3,0x9c,0xe7,0x67,0x96,0x7e,0xd6,0x28,
-		0xc6,0xad,0x57,0x3c,0xb1,0x16,0xdb,0xef,
-		0xef,0xd7,0x54,0x99,0xda,0x96,0xbd,0x68,
-		0xa8,0xa9,0x7b,0x92,0x8a,0x8b,0xbc,0x10,
-		0x3b,0x66,0x21,0xfc,0xde,0x2b,0xec,0xa1,
-		0x23,0x1d,0x20,0x6b,0xe6,0xcd,0x9e,0xc7,
-		0xaf,0xf6,0xf6,0xc9,0x4f,0xcd,0x72,0x04,
-		0xed,0x34,0x55,0xc6,0x8c,0x83,0xf4,0xa4,
-		0x1d,0xa4,0xaf,0x2b,0x74,0xef,0x5c,0x53,
-		0xf1,0xd8,0xac,0x70,0xbd,0xcb,0x7e,0xd1,
-		0x85,0xce,0x81,0xbd,0x84,0x35,0x9d,0x44,
-		0x25,0x4d,0x95,0x62,0x9e,0x98,0x55,0xa9,
-		0x4a,0x7c,0x19,0x58,0xd1,0xf8,0xad,0xa5,
-		0xd0,0x53,0x2e,0xd8,0xa5,0xaa,0x3f,0xb2,
-		0xd1,0x7b,0xa7,0x0e,0xb6,0x24,0x8e,0x59,
-		0x4e,0x1a,0x22,0x97,0xac,0xbb,0xb3,0x9d,
-		0x50,0x2f,0x1a,0x8c,0x6e,0xb6,0xf1,0xce,
-		0x22,0xb3,0xde,0x1a,0x1f,0x40,0xcc,0x24,
-		0x55,0x41,0x19,0xa8,0x31,0xa9,0xaa,0xd6,
-		0x07,0x9c,0xad,0x88,0x42,0x5d,0xe6,0xbd,
-		0xe1,0xa9,0x18,0x7e,0xbb,0x60,0x92,0xcf,
-		0x67,0xbf,0x2b,0x13,0xfd,0x65,0xf2,0x70,
-		0x88,0xd7,0x8b,0x7e,0x88,0x3c,0x87,0x59,
-		0xd2,0xc4,0xf5,0xc6,0x5a,0xdb,0x75,0x53,
-		0x87,0x8a,0xd5,0x75,0xf9,0xfa,0xd8,0x78,
-		0xe8,0x0a,0x0c,0x9b,0xa6,0x3b,0xcb,0xcc,
-		0x27,0x32,0xe6,0x94,0x85,0xbb,0xc9,0xc9,
-		0x0b,0xfb,0xd6,0x24,0x81,0xd9,0x08,0x9b,
-		0xec,0xcf,0x80,0xcf,0xe2,0xdf,0x16,0xa2,
-		0xcf,0x65,0xbd,0x92,0xdd,0x59,0x7b,0x07,
-		0x07,0xe0,0x91,0x7a,0xf4,0x8b,0xbb,0x75,
-		0xfe,0xd4,0x13,0xd2,0x38,0xf5,0x55,0x5a,
-		0x7a,0x56,0x9d,0x80,0xc3,0x41,0x4a,0x8d,
-		0x08,0x59,0xdc,0x65,0xa4,0x61,0x28,0xba,
-		0xb2,0x7a,0xf8,0x7a,0x71,0x31,0x4f,0x31,
-		0x8c,0x78,0x2b,0x23,0xeb,0xfe,0x80,0x8b,
-		0x82,0xb0,0xce,0x26,0x40,0x1d,0x2e,0x22,
-		0xf0,0x4d,0x83,0xd1,0x25,0x5d,0xc5,0x1a,
-		0xdd,0xd3,0xb7,0x5a,0x2b,0x1a,0xe0,0x78,
-		0x45,0x04,0xdf,0x54,0x3a,0xf8,0x96,0x9b,
-		0xe3,0xea,0x70,0x82,0xff,0x7f,0xc9,0x88,
-		0x8c,0x14,0x4d,0xa2,0xaf,0x58,0x42,0x9e,
-		0xc9,0x60,0x31,0xdb,0xca,0xd3,0xda,0xd9,
-		0xaf,0x0d,0xcb,0xaa,0xaf,0x26,0x8c,0xb8,
-		0xfc,0xff,0xea,0xd9,0x4f,0x3c,0x7c,0xa4,
-		0x95,0xe0,0x56,0xa9,0xb4,0x7a,0xcd,0xb7,
-		0x51,0xfb,0x73,0xe6,0x66,0xc6,0xc6,0x55,
-		0xad,0xe8,0x29,0x72,0x97,0xd0,0x7a,0xd1,
-		0xba,0x5e,0x43,0xf1,0xbc,0xa3,0x23,0x01,
-		0x65,0x13,0x39,0xe2,0x29,0x04,0xcc,0x8c,
-		0x42,0xf5,0x8c,0x30,0xc0,0x4a,0xaf,0xdb,
-		0x03,0x8d,0xda,0x08,0x47,0xdd,0x98,0x8d,
-		0xcd,0xa6,0xf3,0xbf,0xd1,0x5c,0x4b,0x4c,
-		0x45,0x25,0x00,0x4a,0xa0,0x6e,0xef,0xf8,
-		0xca,0x61,0x78,0x3a,0xac,0xec,0x57,0xfb,
-		0x3d,0x1f,0x92,0xb0,0xfe,0x2f,0xd1,0xa8,
-		0x5f,0x67,0x24,0x51,0x7b,0x65,0xe6,0x14,
-		0xad,0x68,0x08,0xd6,0xf6,0xee,0x34,0xdf,
-		0xf7,0x31,0x0f,0xdc,0x82,0xae,0xbf,0xd9,
-		0x04,0xb0,0x1e,0x1d,0xc5,0x4b,0x29,0x27,
-		0x09,0x4b,0x2d,0xb6,0x8d,0x6f,0x90,0x3b,
-		0x68,0x40,0x1a,0xde,0xbf,0x5a,0x7e,0x08,
-		0xd7,0x8f,0xf4,0xef,0x5d,0x63,0x65,0x3a,
-		0x65,0x04,0x0c,0xf9,0xbf,0xd4,0xac,0xa7,
-		0x98,0x4a,0x74,0xd3,0x71,0x45,0x98,0x67,
-		0x80,0xfc,0x0b,0x16,0xac,0x45,0x16,0x49,
-		0xde,0x61,0x88,0xa7,0xdb,0xdf,0x19,0x1f,
-		0x64,0xb5,0xfc,0x5e,0x2a,0xb4,0x7b,0x57,
-		0xf7,0xf7,0x27,0x6c,0xd4,0x19,0xc1,0x7a,
-		0x3c,0xa8,0xe1,0xb9,0x39,0xae,0x49,0xe4,
-		0x88,0xac,0xba,0x6b,0x96,0x56,0x10,0xb5,
-		0x48,0x01,0x09,0xc8,0xb1,0x7b,0x80,0xe1,
-		0xb7,0xb7,0x50,0xdf,0xc7,0x59,0x8d,0x5d,
-		0x50,0x11,0xfd,0x2d,0xcc,0x56,0x00,0xa3,
-		0x2e,0xf5,0xb5,0x2a,0x1e,0xcc,0x82,0x0e,
-		0x30,0x8a,0xa3,0x42,0x72,0x1a,0xac,0x09,
-		0x43,0xbf,0x66,0x86,0xb6,0x4b,0x25,0x79,
-		0x37,0x65,0x04,0xcc,0xc4,0x93,0xd9,0x7e,
-		0x6a,0xed,0x3f,0xb0,0xf9,0xcd,0x71,0xa4,
-		0x3d,0xd4,0x97,0xf0,0x1f,0x17,0xc0,0xe2,
-		0xcb,0x37,0x97,0xaa,0x2a,0x2f,0x25,0x66,
-		0x56,0x16,0x8e,0x6c,0x49,0x6a,0xfc,0x5f,
-		0xb9,0x32,0x46,0xf6,0xb1,0x11,0x63,0x98,
-		0xa3,0x46,0xf1,0xa6,0x41,0xf3,0xb0,0x41,
-		0xe9,0x89,0xf7,0x91,0x4f,0x90,0xcc,0x2c,
-		0x7f,0xff,0x35,0x78,0x76,0xe5,0x06,0xb5,
-		0x0d,0x33,0x4b,0xa7,0x7c,0x22,0x5b,0xc3,
-		0x07,0xba,0x53,0x71,0x52,0xf3,0xf1,0x61,
-		0x0e,0x4e,0xaf,0xe5,0x95,0xf6,0xd9,0xd9,
-		0x0d,0x11,0xfa,0xa9,0x33,0xa1,0x5e,0xf1,
-		0x36,0x95,0x46,0x86,0x8a,0x7f,0x3a,0x45,
-		0xa9,0x67,0x68,0xd4,0x0f,0xd9,0xd0,0x34,
-		0x12,0xc0,0x91,0xc6,0x31,0x5c,0xf4,0xfd,
-		0xe7,0xcb,0x68,0x60,0x69,0x37,0x38,0x0d,
-		0xb2,0xea,0xaa,0x70,0x7b,0x4c,0x41,0x85,
-		0xc3,0x2e,0xdd,0xcd,0xd3,0x06,0x70,0x5e,
-		0x4d,0xc1,0xff,0xc8,0x72,0xee,0xee,0x47,
-		0x5a,0x64,0xdf,0xac,0x86,0xab,0xa4,0x1c,
-		0x06,0x18,0x98,0x3f,0x87,0x41,0xc5,0xef,
-		0x68,0xd3,0xa1,0x01,0xe8,0xa3,0xb8,0xca,
-		0xc6,0x0c,0x90,0x5c,0x15,0xfc,0x91,0x08,
-		0x40,0xb9,0x4c,0x00,0xa0,0xb9,0xd0
-    };
-
-    const byte* msgs[] = {msg1, msg2, msg3, msg1, msg1, msg4};
-    const word16 msgSz[] = {sizeof(msg1), sizeof(msg2), sizeof(msg3),
-                            sizeof(msg1), sizeof(msg1), sizeof(msg4)};
-
-    /* create ed25519 keys */
-    wc_InitRng(&rng);
-    wc_ed25519_init(&key);
-    wc_ed25519_init(&key2);
-    wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key);
-    wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key2);
-
-    /* helper functions for signature and key size */
-    keySz = wc_ed25519_size(&key);
-    sigSz = wc_ed25519_sig_size(&key);
-
-    for (i = 0; i < 6; i++) {
-        outlen = sizeof(out);
-        XMEMSET(out, 0, sizeof(out));
-
-        if (wc_ed25519_import_private_key(sKeys[i], ED25519_KEY_SIZE, pKeys[i],
-                pKeySz[i], &key) != 0)
-            return -1021 - i;
-
-        if (wc_ed25519_sign_msg(msgs[i], msgSz[i], out, &outlen, &key)
-                != 0)
-            return -1027 - i;
-
-        if (XMEMCMP(out, sigs[i], 64))
-            return -1033 - i;
-
-        /* test verify on good msg */
-        if (wc_ed25519_verify_msg(out, outlen, msgs[i], msgSz[i], &verify,
-                    &key) != 0 || verify != 1)
-            return -1039 - i;
-
-        /* test verify on bad msg */
-        out[outlen-1] = out[outlen-1] + 1;
-        if (wc_ed25519_verify_msg(out, outlen, msgs[i], msgSz[i], &verify,
-                    &key) == 0 || verify == 1)
-            return -1045 - i;
-
-        /* test api for import/exporting keys */
-        exportPSz = sizeof(exportPKey);
-        exportSSz = sizeof(exportSKey);
-        if (wc_ed25519_export_public(&key, exportPKey, &exportPSz) != 0)
-            return -1051 - i;
-
-        if (wc_ed25519_import_public(exportPKey, exportPSz, &key2) != 0)
-            return -1057 - i;
-
-        if (wc_ed25519_export_private_only(&key, exportSKey, &exportSSz) != 0)
-            return -1063 - i;
-
-        if (wc_ed25519_import_private_key(exportSKey, exportSSz,
-                                          exportPKey, exportPSz, &key2) != 0)
-            return -1069 - i;
-
-        /* clear "out" buffer and test sign with imported keys */
-        outlen = sizeof(out);
-        XMEMSET(out, 0, sizeof(out));
-        if (wc_ed25519_sign_msg(msgs[i], msgSz[i], out, &outlen, &key2) != 0)
-            return -1075 - i;
-
-        if (wc_ed25519_verify_msg(out, outlen, msgs[i], msgSz[i], &verify,
-                                  &key2) != 0 || verify != 1)
-            return -1081 - i;
-
-        if (XMEMCMP(out, sigs[i], 64))
-            return -1087 - i;
-    }
-
-    /* clean up keys when done */
-    wc_ed25519_free(&key);
-    wc_ed25519_free(&key2);
-
-#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
-    wc_FreeRng(&rng);
-#endif
-
-    /* hush warrnings of unused keySz and sigSz */
-    (void)keySz;
-    (void)sigSz;
-
-    return 0;
-}
-#endif /* HAVE_ED25519 */
-
-
-#ifdef HAVE_LIBZ
-
-const byte sample_text[] =
-    "Biodiesel cupidatat marfa, cliche aute put a bird on it incididunt elit\n"
-    "polaroid. Sunt tattooed bespoke reprehenderit. Sint twee organic id\n"
-    "marfa. Commodo veniam ad esse gastropub. 3 wolf moon sartorial vero,\n"
-    "plaid delectus biodiesel squid +1 vice. Post-ironic keffiyeh leggings\n"
-    "selfies cray fap hoodie, forage anim. Carles cupidatat shoreditch, VHS\n"
-    "small batch meggings kogi dolore food truck bespoke gastropub.\n"
-    "\n"
-    "Terry richardson adipisicing actually typewriter tumblr, twee whatever\n"
-    "four loko you probably haven't heard of them high life. Messenger bag\n"
-    "whatever tattooed deep v mlkshk. Brooklyn pinterest assumenda chillwave\n"
-    "et, banksy ullamco messenger bag umami pariatur direct trade forage.\n"
-    "Typewriter culpa try-hard, pariatur sint brooklyn meggings. Gentrify\n"
-    "food truck next level, tousled irony non semiotics PBR ethical anim cred\n"
-    "readymade. Mumblecore brunch lomo odd future, portland organic terry\n"
-    "richardson elit leggings adipisicing ennui raw denim banjo hella. Godard\n"
-    "mixtape polaroid, pork belly readymade organic cray typewriter helvetica\n"
-    "four loko whatever street art yr farm-to-table.\n"
-    "\n"
-    "Vinyl keytar vice tofu. Locavore you probably haven't heard of them pug\n"
-    "pickled, hella tonx labore truffaut DIY mlkshk elit cosby sweater sint\n"
-    "et mumblecore. Elit swag semiotics, reprehenderit DIY sartorial nisi ugh\n"
-    "nesciunt pug pork belly wayfarers selfies delectus. Ethical hoodie\n"
-    "seitan fingerstache kale chips. Terry richardson artisan williamsburg,\n"
-    "eiusmod fanny pack irony tonx ennui lo-fi incididunt tofu YOLO\n"
-    "readymade. 8-bit sed ethnic beard officia. Pour-over iphone DIY butcher,\n"
-    "ethnic art party qui letterpress nisi proident jean shorts mlkshk\n"
-    "locavore.\n"
-    "\n"
-    "Narwhal flexitarian letterpress, do gluten-free voluptate next level\n"
-    "banh mi tonx incididunt carles DIY. Odd future nulla 8-bit beard ut\n"
-    "cillum pickled velit, YOLO officia you probably haven't heard of them\n"
-    "trust fund gastropub. Nisi adipisicing tattooed, Austin mlkshk 90's\n"
-    "small batch american apparel. Put a bird on it cosby sweater before they\n"
-    "sold out pork belly kogi hella. Street art mollit sustainable polaroid,\n"
-    "DIY ethnic ea pug beard dreamcatcher cosby sweater magna scenester nisi.\n"
-    "Sed pork belly skateboard mollit, labore proident eiusmod. Sriracha\n"
-    "excepteur cosby sweater, anim deserunt laborum eu aliquip ethical et\n"
-    "neutra PBR selvage.\n"
-    "\n"
-    "Raw denim pork belly truffaut, irony plaid sustainable put a bird on it\n"
-    "next level jean shorts exercitation. Hashtag keytar whatever, nihil\n"
-    "authentic aliquip disrupt laborum. Tattooed selfies deserunt trust fund\n"
-    "wayfarers. 3 wolf moon synth church-key sartorial, gastropub leggings\n"
-    "tattooed. Labore high life commodo, meggings raw denim fingerstache pug\n"
-    "trust fund leggings seitan forage. Nostrud ullamco duis, reprehenderit\n"
-    "incididunt flannel sustainable helvetica pork belly pug banksy you\n"
-    "probably haven't heard of them nesciunt farm-to-table. Disrupt nostrud\n"
-    "mollit magna, sriracha sartorial helvetica.\n"
-    "\n"
-    "Nulla kogi reprehenderit, skateboard sustainable duis adipisicing viral\n"
-    "ad fanny pack salvia. Fanny pack trust fund you probably haven't heard\n"
-    "of them YOLO vice nihil. Keffiyeh cray lo-fi pinterest cardigan aliqua,\n"
-    "reprehenderit aute. Culpa tousled williamsburg, marfa lomo actually anim\n"
-    "skateboard. Iphone aliqua ugh, semiotics pariatur vero readymade\n"
-    "organic. Marfa squid nulla, in laborum disrupt laboris irure gastropub.\n"
-    "Veniam sunt food truck leggings, sint vinyl fap.\n"
-    "\n"
-    "Hella dolore pork belly, truffaut carles you probably haven't heard of\n"
-    "them PBR helvetica in sapiente. Fashion axe ugh bushwick american\n"
-    "apparel. Fingerstache sed iphone, jean shorts blue bottle nisi bushwick\n"
-    "flexitarian officia veniam plaid bespoke fap YOLO lo-fi. Blog\n"
-    "letterpress mumblecore, food truck id cray brooklyn cillum ad sed.\n"
-    "Assumenda chambray wayfarers vinyl mixtape sustainable. VHS vinyl\n"
-    "delectus, culpa williamsburg polaroid cliche swag church-key synth kogi\n"
-    "magna pop-up literally. Swag thundercats ennui shoreditch vegan\n"
-    "pitchfork neutra truffaut etsy, sed single-origin coffee craft beer.\n"
-    "\n"
-    "Odio letterpress brooklyn elit. Nulla single-origin coffee in occaecat\n"
-    "meggings. Irony meggings 8-bit, chillwave lo-fi adipisicing cred\n"
-    "dreamcatcher veniam. Put a bird on it irony umami, trust fund bushwick\n"
-    "locavore kale chips. Sriracha swag thundercats, chillwave disrupt\n"
-    "tousled beard mollit mustache leggings portland next level. Nihil esse\n"
-    "est, skateboard art party etsy thundercats sed dreamcatcher ut iphone\n"
-    "swag consectetur et. Irure skateboard banjo, nulla deserunt messenger\n"
-    "bag dolor terry richardson sapiente.\n";
-
-
-int compress_test(void)
-{
-    int ret = 0;
-    word32 dSz = sizeof(sample_text);
-    word32 cSz = (dSz + (word32)(dSz * 0.001) + 12);
-    byte *c = NULL;
-    byte *d = NULL;
-
-    c = calloc(cSz, sizeof(byte));
-    d = calloc(dSz, sizeof(byte));
-
-    if (c == NULL || d == NULL)
-        ret = -300;
-
-    if (ret == 0 && (ret = wc_Compress(c, cSz, sample_text, dSz, 0)) < 0)
-        ret = -301;
-
-    if (ret > 0) {
-        cSz = (word32)ret;
-        ret = 0;
-    }
-
-    if (ret == 0 && wc_DeCompress(d, dSz, c, cSz) != (int)dSz)
-        ret = -302;
-
-    if (ret == 0 && memcmp(d, sample_text, dSz))
-        ret = -303;
-
-    if (c) free(c);
-    if (d) free(d);
-
-    return ret;
-}
-
-#endif /* HAVE_LIBZ */
-
-#ifdef HAVE_PKCS7
-
-int pkcs7enveloped_test(void)
-{
-    int ret = 0;
-
-    int cipher = DES3b;
-    int envelopedSz, decodedSz;
-    PKCS7 pkcs7;
-    byte* cert;
-    byte* privKey;
-    byte  enveloped[2048];
-    byte  decoded[2048];
-
-    size_t certSz;
-    size_t privKeySz;
-    FILE*  certFile;
-    FILE*  keyFile;
-    FILE*  pkcs7File;
-    const char* pkcs7OutFile = "pkcs7envelopedData.der";
-
-    const byte data[] = { /* Hello World */
-        0x48,0x65,0x6c,0x6c,0x6f,0x20,0x57,0x6f,
-        0x72,0x6c,0x64
-    };
-
-    /* read client cert and key in DER format */
-    cert = (byte*)malloc(FOURK_BUF);
-    if (cert == NULL)
-        return -201;
-
-    privKey = (byte*)malloc(FOURK_BUF);
-    if (privKey == NULL) {
-        free(cert);
-        return -202;
-    }
-
-    certFile = fopen(clientCert, "rb");
-    if (!certFile) {
-        free(cert);
-        free(privKey);
-        err_sys("can't open ./certs/client-cert.der, "
-                "Please run from wolfSSL home dir", -42);
-        return -42;
-    }
-
-    certSz = fread(cert, 1, FOURK_BUF, certFile);
-    fclose(certFile);
-
-    keyFile = fopen(clientKey, "rb");
-    if (!keyFile) {
-        free(cert);
-        free(privKey);
-        err_sys("can't open ./certs/client-key.der, "
-                "Please run from wolfSSL home dir", -43);
-        return -43;
-    }
-
-    privKeySz = fread(privKey, 1, FOURK_BUF, keyFile);
-    fclose(keyFile);
-
-    wc_PKCS7_InitWithCert(&pkcs7, cert, (word32)certSz);
-    pkcs7.content     = (byte*)data;
-    pkcs7.contentSz   = (word32)sizeof(data);
-    pkcs7.contentOID  = DATA;
-    pkcs7.encryptOID  = cipher;
-    pkcs7.privateKey  = privKey;
-    pkcs7.privateKeySz = (word32)privKeySz;
-
-    /* encode envelopedData */
-    envelopedSz = wc_PKCS7_EncodeEnvelopedData(&pkcs7, enveloped,
-                                            sizeof(enveloped));
-    if (envelopedSz <= 0) {
-        free(cert);
-        free(privKey);
-        return -203;
-    }
-
-    /* decode envelopedData */
-    decodedSz = wc_PKCS7_DecodeEnvelopedData(&pkcs7, enveloped, envelopedSz,
-                                          decoded, sizeof(decoded));
-    if (decodedSz <= 0) {
-        free(cert);
-        free(privKey);
-        return -204;
-    }
-
-    /* test decode result */
-    if (memcmp(decoded, data, sizeof(data)) != 0) {
-        free(cert);
-        free(privKey);
-        return -205;
-    }
-
-    /* output pkcs7 envelopedData for external testing */
-    pkcs7File = fopen(pkcs7OutFile, "wb");
-    if (!pkcs7File) {
-        free(cert);
-        free(privKey);
-        return -206;
-    }
-
-    ret = (int)fwrite(enveloped, envelopedSz, 1, pkcs7File);
-    fclose(pkcs7File);
-
-    free(cert);
-    free(privKey);
-    wc_PKCS7_Free(&pkcs7);
-
-    if (ret > 0)
-        return 0;
-
-    return ret;
-}
-
-int pkcs7signed_test(void)
-{
-    int ret = 0;
-
-    FILE* file;
-    byte* certDer;
-    byte* keyDer;
-    byte* out;
-    char data[] = "Hello World";
-    word32 dataSz, outSz, certDerSz, keyDerSz;
-    PKCS7 msg;
-    RNG rng;
-
-    byte transIdOid[] =
-               { 0x06, 0x0a, 0x60, 0x86, 0x48, 0x01, 0x86, 0xF8, 0x45, 0x01,
-                 0x09, 0x07 };
-    byte messageTypeOid[] =
-               { 0x06, 0x0a, 0x60, 0x86, 0x48, 0x01, 0x86, 0xF8, 0x45, 0x01,
-                 0x09, 0x02 };
-    byte senderNonceOid[] =
-               { 0x06, 0x0a, 0x60, 0x86, 0x48, 0x01, 0x86, 0xF8, 0x45, 0x01,
-                 0x09, 0x05 };
-    byte transId[(SHA_DIGEST_SIZE + 1) * 2 + 1];
-    byte messageType[] = { 0x13, 2, '1', '9' };
-    byte senderNonce[PKCS7_NONCE_SZ + 2];
-
-    PKCS7Attrib attribs[] =
-    {
-        { transIdOid, sizeof(transIdOid),
-                     transId, sizeof(transId) - 1 }, /* take off the null */
-        { messageTypeOid, sizeof(messageTypeOid),
-                     messageType, sizeof(messageType) },
-        { senderNonceOid, sizeof(senderNonceOid),
-                     senderNonce, sizeof(senderNonce) }
-    };
-
-    dataSz = (word32) strlen(data);
-    outSz = FOURK_BUF;
-
-    certDer = (byte*)malloc(FOURK_BUF);
-    if (certDer == NULL)
-        return -207;
-    keyDer = (byte*)malloc(FOURK_BUF);
-    if (keyDer == NULL) {
-        free(certDer);
-        return -208;
-    }
-    out = (byte*)malloc(FOURK_BUF);
-    if (out == NULL) {
-        free(certDer);
-        free(keyDer);
-        return -209;
-    }
-
-    /* read in DER cert of recipient, into cert of size certSz */
-    file = fopen(clientCert, "rb");
-    if (!file) {
-        free(certDer);
-        free(keyDer);
-        free(out);
-        err_sys("can't open ./certs/client-cert.der, "
-                "Please run from wolfSSL home dir", -44);
-        return -44;
-    }
-    certDerSz = (word32)fread(certDer, 1, FOURK_BUF, file);
-    fclose(file);
-
-    file = fopen(clientKey, "rb");
-    if (!file) {
-        free(certDer);
-        free(keyDer);
-        free(out);
-        err_sys("can't open ./certs/client-key.der, "
-                "Please run from wolfSSL home dir", -45);
-        return -45;
-    }
-    keyDerSz = (word32)fread(keyDer, 1, FOURK_BUF, file);
-    fclose(file);
-
-    ret = wc_InitRng(&rng);
-    if (ret != 0) {
-        free(certDer);
-        free(keyDer);
-        free(out);
-        return -210;
-    }
-
-    senderNonce[0] = 0x04;
-    senderNonce[1] = PKCS7_NONCE_SZ;
-
-    ret = wc_RNG_GenerateBlock(&rng, &senderNonce[2], PKCS7_NONCE_SZ);
-    if (ret != 0) {
-        free(certDer);
-        free(keyDer);
-        free(out);
-        return -211;
-    }
-
-    wc_PKCS7_InitWithCert(&msg, certDer, certDerSz);
-    msg.privateKey = keyDer;
-    msg.privateKeySz = keyDerSz;
-    msg.content = (byte*)data;
-    msg.contentSz = dataSz;
-    msg.hashOID = SHAh;
-    msg.encryptOID = RSAk;
-    msg.signedAttribs = attribs;
-    msg.signedAttribsSz = sizeof(attribs)/sizeof(PKCS7Attrib);
-    msg.rng = &rng;
-    {
-        Sha sha;
-        byte digest[SHA_DIGEST_SIZE];
-        int i,j;
-
-        transId[0] = 0x13;
-        transId[1] = SHA_DIGEST_SIZE * 2;
-
-        ret = wc_InitSha(&sha);
-        if (ret != 0) {
-            free(certDer);
-            free(keyDer);
-            free(out);
-            return -4003;
-        }
-        wc_ShaUpdate(&sha, msg.publicKey, msg.publicKeySz);
-        wc_ShaFinal(&sha, digest);
-
-        for (i = 0, j = 2; i < SHA_DIGEST_SIZE; i++, j += 2) {
-            snprintf((char*)&transId[j], 3, "%02x", digest[i]);
-        }
-    }
-    ret = wc_PKCS7_EncodeSignedData(&msg, out, outSz);
-    if (ret < 0) {
-        free(certDer);
-        free(keyDer);
-        free(out);
-        wc_PKCS7_Free(&msg);
-        return -212;
-    }
-    else
-        outSz = ret;
-
-    /* write PKCS#7 to output file for more testing */
-    file = fopen("./pkcs7signedData.der", "wb");
-    if (!file) {
-        free(certDer);
-        free(keyDer);
-        free(out);
-        wc_PKCS7_Free(&msg);
-        return -213;
-    }
-    ret = (int)fwrite(out, 1, outSz, file);
-    fclose(file);
-    if (ret != (int)outSz) {
-        free(certDer);
-        free(keyDer);
-        free(out);
-        wc_PKCS7_Free(&msg);
-        return -218;
-    }
-
-    wc_PKCS7_Free(&msg);
-    wc_PKCS7_InitWithCert(&msg, NULL, 0);
-
-    ret = wc_PKCS7_VerifySignedData(&msg, out, outSz);
-    if (ret < 0) {
-        free(certDer);
-        free(keyDer);
-        free(out);
-        wc_PKCS7_Free(&msg);
-        return -214;
-    }
-
-    if (msg.singleCert == NULL || msg.singleCertSz == 0) {
-        free(certDer);
-        free(keyDer);
-        free(out);
-        wc_PKCS7_Free(&msg);
-        return -215;
-    }
-
-    file = fopen("./pkcs7cert.der", "wb");
-    if (!file) {
-        free(certDer);
-        free(keyDer);
-        free(out);
-        wc_PKCS7_Free(&msg);
-        return -216;
-    }
-    ret = (int)fwrite(msg.singleCert, 1, msg.singleCertSz, file);
-    fclose(file);
-
-    free(certDer);
-    free(keyDer);
-    free(out);
-    wc_PKCS7_Free(&msg);
-
-    wc_FreeRng(&rng);
-
-    if (ret > 0)
-        return 0;
-
-    return ret;
-}
-
-#endif /* HAVE_PKCS7 */
-
-#endif /* NO_CRYPT_TEST */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/test.h b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/test.h
deleted file mode 100755
index dbe6e25..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/test.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* ctaocrypt/test/test.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#pragma once
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-int wolfcrypt_test(void* args);
-
-#ifdef __cplusplus
-    }  /* extern "C" */
-#endif
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/test.sln b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/test.sln
deleted file mode 100755
index 97b2e8d..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/test.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual C++ Express 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcproj", "{D04BDF66-664A-4D59-BEAC-8AB2D5809C21}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{D04BDF66-664A-4D59-BEAC-8AB2D5809C21}.Debug|Win32.ActiveCfg = Debug|Win32
-		{D04BDF66-664A-4D59-BEAC-8AB2D5809C21}.Debug|Win32.Build.0 = Debug|Win32
-		{D04BDF66-664A-4D59-BEAC-8AB2D5809C21}.Release|Win32.ActiveCfg = Release|Win32
-		{D04BDF66-664A-4D59-BEAC-8AB2D5809C21}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/test.vcproj b/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/test.vcproj
deleted file mode 100755
index 38c5c6b..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfcrypt/test/test.vcproj
+++ /dev/null
@@ -1,195 +0,0 @@
-
-
-	
-		
-	
-	
-	
-	
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-		
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-			
-		
-	
-	
-	
-	
-		
-		
-		
-		
-		
-			
-			
-		
-	
-	
-	
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/callbacks.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/callbacks.h
deleted file mode 100755
index 8794e9e..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/callbacks.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* callbacks.h
- *
- * Copyright (C) 2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLFSSL_CALLBACKS_H
-#define WOLFSSL_CALLBACKS_H
-
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-enum { /* CALLBACK CONTSTANTS */
-    MAX_PACKETNAME_SZ     =  24,
-    MAX_CIPHERNAME_SZ     =  24,
-    MAX_TIMEOUT_NAME_SZ   =  24,       
-    MAX_PACKETS_HANDSHAKE =  14,       /* 12 for client auth plus 2 alerts */
-    MAX_VALUE_SZ          = 128,       /* all handshake packets but Cert should
-                                          fit here  */
-};
-
-
-typedef struct handShakeInfo_st {
-    char   cipherName[MAX_CIPHERNAME_SZ + 1];    /* negotiated cipher */
-    char   packetNames[MAX_PACKETS_HANDSHAKE][MAX_PACKETNAME_SZ + 1];
-                                                 /* SSL packet names  */ 
-    int    numberPackets;                        /* actual # of packets */
-    int    negotiationError;                     /* cipher/parameter err */
-} HandShakeInfo;
-
-
-typedef struct timeval Timeval;
-
-
-typedef struct packetInfo_st {
-    char           packetName[MAX_PACKETNAME_SZ + 1]; /* SSL packet name */
-    Timeval        timestamp;                       /* when it occured    */
-    unsigned char  value[MAX_VALUE_SZ];             /* if fits, it's here */ 
-    unsigned char* bufferValue;                     /* otherwise here (non 0) */
-    int            valueSz;                         /* sz of value or buffer */
-} PacketInfo;
-
-
-typedef struct timeoutInfo_st {
-    char       timeoutName[MAX_TIMEOUT_NAME_SZ + 1]; /* timeout Name */
-    int        flags;                              /* for future use */
-    int        numberPackets;                      /* actual # of packets */
-    PacketInfo packets[MAX_PACKETS_HANDSHAKE];     /* list of all packets  */
-    Timeval    timeoutValue;                       /* timer that caused it */
-} TimeoutInfo;
-
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */
-#endif
-
-
-#endif /* WOLFSSL_CALLBACKS_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/certs_test.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/certs_test.h
deleted file mode 100755
index 3ce4915..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/certs_test.h
+++ /dev/null
@@ -1,1226 +0,0 @@
-/* certs_test.h */
-
-#ifndef WOLFSSL_CERTS_TEST_H
-#define WOLFSSL_CERTS_TEST_H
-
-#ifdef USE_CERT_BUFFERS_1024
-
-/* ./certs/1024/client-key.der, 1024-bit */
-static const unsigned char client_key_der_1024[] =
-{
-	0x30, 0x82, 0x02, 0x5C, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 
-	0x00, 0xBC, 0x73, 0x0E, 0xA8, 0x49, 0xF3, 0x74, 0xA2, 0xA9, 
-	0xEF, 0x18, 0xA5, 0xDA, 0x55, 0x99, 0x21, 0xF9, 0xC8, 0xEC, 
-	0xB3, 0x6D, 0x48, 0xE5, 0x35, 0x35, 0x75, 0x77, 0x37, 0xEC, 
-	0xD1, 0x61, 0x90, 0x5F, 0x3E, 0xD9, 0xE4, 0xD5, 0xDF, 0x94, 
-	0xCA, 0xC1, 0xA9, 0xD7, 0x19, 0xDA, 0x86, 0xC9, 0xE8, 0x4D, 
-	0xC4, 0x61, 0x36, 0x82, 0xFE, 0xAB, 0xAD, 0x7E, 0x77, 0x25, 
-	0xBB, 0x8D, 0x11, 0xA5, 0xBC, 0x62, 0x3A, 0xA8, 0x38, 0xCC, 
-	0x39, 0xA2, 0x04, 0x66, 0xB4, 0xF7, 0xF7, 0xF3, 0xAA, 0xDA, 
-	0x4D, 0x02, 0x0E, 0xBB, 0x5E, 0x8D, 0x69, 0x48, 0xDC, 0x77, 
-	0xC9, 0x28, 0x0E, 0x22, 0xE9, 0x6B, 0xA4, 0x26, 0xBA, 0x4C, 
-	0xE8, 0xC1, 0xFD, 0x4A, 0x6F, 0x2B, 0x1F, 0xEF, 0x8A, 0xAE, 
-	0xF6, 0x90, 0x62, 0xE5, 0x64, 0x1E, 0xEB, 0x2B, 0x3C, 0x67, 
-	0xC8, 0xDC, 0x27, 0x00, 0xF6, 0x91, 0x68, 0x65, 0xA9, 0x02, 
-	0x03, 0x01, 0x00, 0x01, 0x02, 0x81, 0x80, 0x13, 0x97, 0xEA, 
-	0xE8, 0x38, 0x78, 0x25, 0xA2, 0x5C, 0x04, 0xCE, 0x0D, 0x40, 
-	0x7C, 0x31, 0xE5, 0xC4, 0x70, 0xCD, 0x9B, 0x82, 0x3B, 0x58, 
-	0x09, 0x86, 0x3B, 0x66, 0x5F, 0xDC, 0x31, 0x90, 0xF1, 0x4F, 
-	0xD5, 0xDB, 0x15, 0xDD, 0xDE, 0xD7, 0x3B, 0x95, 0x93, 0x31, 
-	0x18, 0x31, 0x0E, 0x5E, 0xA3, 0xD6, 0xA2, 0x1A, 0x71, 0x6E, 
-	0x81, 0x48, 0x1C, 0x4B, 0xCF, 0xDB, 0x8E, 0x7A, 0x86, 0x61, 
-	0x32, 0xDC, 0xFB, 0x55, 0xC1, 0x16, 0x6D, 0x27, 0x92, 0x24, 
-	0x45, 0x8B, 0xF1, 0xB8, 0x48, 0xB1, 0x4B, 0x1D, 0xAC, 0xDE, 
-	0xDA, 0xDD, 0x8E, 0x2F, 0xC2, 0x91, 0xFB, 0xA5, 0xA9, 0x6E, 
-	0xF8, 0x3A, 0x6A, 0xF1, 0xFD, 0x50, 0x18, 0xEF, 0x9F, 0xE7, 
-	0xC3, 0xCA, 0x78, 0xEA, 0x56, 0xD3, 0xD3, 0x72, 0x5B, 0x96, 
-	0xDD, 0x4E, 0x06, 0x4E, 0x3A, 0xC3, 0xD9, 0xBE, 0x72, 0xB6, 
-	0x65, 0x07, 0x07, 0x4C, 0x01, 0x02, 0x41, 0x00, 0xFA, 0x47, 
-	0xD4, 0x7A, 0x7C, 0x92, 0x3C, 0x55, 0xEF, 0x81, 0xF0, 0x41, 
-	0x30, 0x2D, 0xA3, 0xCF, 0x8F, 0x1C, 0xE6, 0x87, 0x27, 0x05, 
-	0x70, 0x0D, 0xDF, 0x98, 0x35, 0xD6, 0xF1, 0x8B, 0x38, 0x2F, 
-	0x24, 0xB5, 0xD0, 0x84, 0xB6, 0x79, 0x4F, 0x71, 0x29, 0x94, 
-	0x5A, 0xF0, 0x64, 0x6A, 0xAC, 0xE7, 0x72, 0xC6, 0xED, 0x4D, 
-	0x59, 0x98, 0x3E, 0x67, 0x3A, 0xF3, 0x74, 0x2C, 0xF9, 0x61, 
-	0x17, 0x69, 0x02, 0x41, 0x00, 0xC0, 0xC1, 0x82, 0x0D, 0x0C, 
-	0xEB, 0xC6, 0x2F, 0xDC, 0x92, 0xF9, 0x9D, 0x82, 0x1A, 0x31, 
-	0xE9, 0xE9, 0xF7, 0x4B, 0xF2, 0x82, 0x87, 0x1C, 0xEE, 0x16, 
-	0x6A, 0xD1, 0x1D, 0x18, 0x82, 0x70, 0xF3, 0xC0, 0xB6, 0x2F, 
-	0xF6, 0xF3, 0xF7, 0x1D, 0xF1, 0x86, 0x23, 0xC8, 0x4E, 0xEB, 
-	0x8F, 0x56, 0x8E, 0x8F, 0xF5, 0xBF, 0xF1, 0xF7, 0x2B, 0xB5, 
-	0xCC, 0x3D, 0xC6, 0x57, 0x39, 0x0C, 0x1B, 0x54, 0x41, 0x02, 
-	0x41, 0x00, 0x9D, 0x7E, 0x05, 0xDE, 0xED, 0xF4, 0xB7, 0xB2, 
-	0xFB, 0xFC, 0x30, 0x4B, 0x55, 0x1D, 0xE3, 0x2F, 0x01, 0x47, 
-	0x96, 0x69, 0x05, 0xCD, 0x0E, 0x2E, 0x2C, 0xBD, 0x83, 0x63, 
-	0xB6, 0xAB, 0x7C, 0xB7, 0x6D, 0xCA, 0x5B, 0x64, 0xA7, 0xCE, 
-	0xBE, 0x86, 0xDF, 0x3B, 0x53, 0xDE, 0x61, 0xD2, 0x1E, 0xEB, 
-	0xA5, 0xF6, 0x37, 0xED, 0xAC, 0xAB, 0x78, 0xD9, 0x4C, 0xE7, 
-	0x55, 0xFB, 0xD7, 0x11, 0x99, 0xC1, 0x02, 0x40, 0x18, 0x98, 
-	0x18, 0x29, 0xE6, 0x1E, 0x27, 0x39, 0x70, 0x21, 0x68, 0xAC, 
-	0x0A, 0x2F, 0xA1, 0x72, 0xC1, 0x21, 0x86, 0x95, 0x38, 0xC6, 
-	0x58, 0x90, 0xA0, 0x57, 0x9C, 0xBA, 0xE3, 0xA7, 0xB1, 0x15, 
-	0xC8, 0xDE, 0xF6, 0x1B, 0xC2, 0x61, 0x23, 0x76, 0xEF, 0xB0, 
-	0x9D, 0x1C, 0x44, 0xBE, 0x13, 0x43, 0x39, 0x67, 0x17, 0xC8, 
-	0x9D, 0xCA, 0xFB, 0xF5, 0x45, 0x64, 0x8B, 0x38, 0x82, 0x2C, 
-	0xF2, 0x81, 0x02, 0x40, 0x39, 0x89, 0xE5, 0x9C, 0x19, 0x55, 
-	0x30, 0xBA, 0xB7, 0x48, 0x8C, 0x48, 0x14, 0x0E, 0xF4, 0x9F, 
-	0x7E, 0x77, 0x97, 0x43, 0xE1, 0xB4, 0x19, 0x35, 0x31, 0x23, 
-	0x75, 0x9C, 0x3B, 0x44, 0xAD, 0x69, 0x12, 0x56, 0xEE, 0x00, 
-	0x61, 0x64, 0x16, 0x66, 0xD3, 0x7C, 0x74, 0x2B, 0x15, 0xB4, 
-	0xA2, 0xFE, 0xBF, 0x08, 0x6B, 0x1A, 0x5D, 0x3F, 0x90, 0x12, 
-	0xB1, 0x05, 0x86, 0x31, 0x29, 0xDB, 0xD9, 0xE2
-};
-static const int sizeof_client_key_der_1024 = sizeof(client_key_der_1024);
-
-/* ./certs/1024/client-cert.der, 1024-bit */
-static const unsigned char client_cert_der_1024[] =
-{
-	0x30, 0x82, 0x03, 0xC5, 0x30, 0x82, 0x03, 0x2E, 0xA0, 0x03, 
-	0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xE3, 0xD7, 0xA0, 0xFA, 
-	0x76, 0xDF, 0x2A, 0xFA, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 
-	0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x30, 
-	0x81, 0x9E, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 
-	0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x10, 0x30, 0x0E, 0x06, 
-	0x03, 0x55, 0x04, 0x08, 0x0C, 0x07, 0x4D, 0x6F, 0x6E, 0x74, 
-	0x61, 0x6E, 0x61, 0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 
-	0x04, 0x07, 0x0C, 0x07, 0x42, 0x6F, 0x7A, 0x65, 0x6D, 0x61, 
-	0x6E, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0A, 
-	0x0C, 0x0C, 0x77, 0x6F, 0x6C, 0x66, 0x53, 0x53, 0x4C, 0x5F, 
-	0x31, 0x30, 0x32, 0x34, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 
-	0x55, 0x04, 0x0B, 0x0C, 0x10, 0x50, 0x72, 0x6F, 0x67, 0x72, 
-	0x61, 0x6D, 0x6D, 0x69, 0x6E, 0x67, 0x2D, 0x31, 0x30, 0x32, 
-	0x34, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 
-	0x0C, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x6F, 0x6C, 0x66, 
-	0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x31, 0x1F, 0x30, 
-	0x1D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 
-	0x09, 0x01, 0x16, 0x10, 0x69, 0x6E, 0x66, 0x6F, 0x40, 0x77, 
-	0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 
-	0x30, 0x1E, 0x17, 0x0D, 0x31, 0x35, 0x30, 0x35, 0x30, 0x37, 
-	0x31, 0x38, 0x32, 0x31, 0x30, 0x31, 0x5A, 0x17, 0x0D, 0x31, 
-	0x38, 0x30, 0x31, 0x33, 0x31, 0x31, 0x38, 0x32, 0x31, 0x30, 
-	0x31, 0x5A, 0x30, 0x81, 0x9E, 0x31, 0x0B, 0x30, 0x09, 0x06, 
-	0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x10, 
-	0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0C, 0x07, 0x4D, 
-	0x6F, 0x6E, 0x74, 0x61, 0x6E, 0x61, 0x31, 0x10, 0x30, 0x0E, 
-	0x06, 0x03, 0x55, 0x04, 0x07, 0x0C, 0x07, 0x42, 0x6F, 0x7A, 
-	0x65, 0x6D, 0x61, 0x6E, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 
-	0x55, 0x04, 0x0A, 0x0C, 0x0C, 0x77, 0x6F, 0x6C, 0x66, 0x53, 
-	0x53, 0x4C, 0x5F, 0x31, 0x30, 0x32, 0x34, 0x31, 0x19, 0x30, 
-	0x17, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x0C, 0x10, 0x50, 0x72, 
-	0x6F, 0x67, 0x72, 0x61, 0x6D, 0x6D, 0x69, 0x6E, 0x67, 0x2D, 
-	0x31, 0x30, 0x32, 0x34, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 
-	0x55, 0x04, 0x03, 0x0C, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x77, 
-	0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 
-	0x31, 0x1F, 0x30, 0x1D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 
-	0xF7, 0x0D, 0x01, 0x09, 0x01, 0x16, 0x10, 0x69, 0x6E, 0x66, 
-	0x6F, 0x40, 0x77, 0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 
-	0x63, 0x6F, 0x6D, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 
-	0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 
-	0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 
-	0x81, 0x00, 0xBC, 0x73, 0x0E, 0xA8, 0x49, 0xF3, 0x74, 0xA2, 
-	0xA9, 0xEF, 0x18, 0xA5, 0xDA, 0x55, 0x99, 0x21, 0xF9, 0xC8, 
-	0xEC, 0xB3, 0x6D, 0x48, 0xE5, 0x35, 0x35, 0x75, 0x77, 0x37, 
-	0xEC, 0xD1, 0x61, 0x90, 0x5F, 0x3E, 0xD9, 0xE4, 0xD5, 0xDF, 
-	0x94, 0xCA, 0xC1, 0xA9, 0xD7, 0x19, 0xDA, 0x86, 0xC9, 0xE8, 
-	0x4D, 0xC4, 0x61, 0x36, 0x82, 0xFE, 0xAB, 0xAD, 0x7E, 0x77, 
-	0x25, 0xBB, 0x8D, 0x11, 0xA5, 0xBC, 0x62, 0x3A, 0xA8, 0x38, 
-	0xCC, 0x39, 0xA2, 0x04, 0x66, 0xB4, 0xF7, 0xF7, 0xF3, 0xAA, 
-	0xDA, 0x4D, 0x02, 0x0E, 0xBB, 0x5E, 0x8D, 0x69, 0x48, 0xDC, 
-	0x77, 0xC9, 0x28, 0x0E, 0x22, 0xE9, 0x6B, 0xA4, 0x26, 0xBA, 
-	0x4C, 0xE8, 0xC1, 0xFD, 0x4A, 0x6F, 0x2B, 0x1F, 0xEF, 0x8A, 
-	0xAE, 0xF6, 0x90, 0x62, 0xE5, 0x64, 0x1E, 0xEB, 0x2B, 0x3C, 
-	0x67, 0xC8, 0xDC, 0x27, 0x00, 0xF6, 0x91, 0x68, 0x65, 0xA9, 
-	0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x82, 0x01, 0x07, 0x30, 
-	0x82, 0x01, 0x03, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 
-	0x04, 0x16, 0x04, 0x14, 0x81, 0x69, 0x0F, 0xF8, 0xDF, 0xDD, 
-	0xCF, 0x34, 0x29, 0xD5, 0x67, 0x75, 0x71, 0x85, 0xC7, 0x75, 
-	0x10, 0x69, 0x59, 0xEC, 0x30, 0x81, 0xD3, 0x06, 0x03, 0x55, 
-	0x1D, 0x23, 0x04, 0x81, 0xCB, 0x30, 0x81, 0xC8, 0x80, 0x14, 
-	0x81, 0x69, 0x0F, 0xF8, 0xDF, 0xDD, 0xCF, 0x34, 0x29, 0xD5, 
-	0x67, 0x75, 0x71, 0x85, 0xC7, 0x75, 0x10, 0x69, 0x59, 0xEC, 
-	0xA1, 0x81, 0xA4, 0xA4, 0x81, 0xA1, 0x30, 0x81, 0x9E, 0x31, 
-	0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 
-	0x55, 0x53, 0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 
-	0x08, 0x0C, 0x07, 0x4D, 0x6F, 0x6E, 0x74, 0x61, 0x6E, 0x61, 
-	0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0C, 
-	0x07, 0x42, 0x6F, 0x7A, 0x65, 0x6D, 0x61, 0x6E, 0x31, 0x15, 
-	0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x0C, 0x77, 
-	0x6F, 0x6C, 0x66, 0x53, 0x53, 0x4C, 0x5F, 0x31, 0x30, 0x32, 
-	0x34, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x0B, 
-	0x0C, 0x10, 0x50, 0x72, 0x6F, 0x67, 0x72, 0x61, 0x6D, 0x6D, 
-	0x69, 0x6E, 0x67, 0x2D, 0x31, 0x30, 0x32, 0x34, 0x31, 0x18, 
-	0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x0F, 0x77, 
-	0x77, 0x77, 0x2E, 0x77, 0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 
-	0x2E, 0x63, 0x6F, 0x6D, 0x31, 0x1F, 0x30, 0x1D, 0x06, 0x09, 
-	0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01, 0x16, 
-	0x10, 0x69, 0x6E, 0x66, 0x6F, 0x40, 0x77, 0x6F, 0x6C, 0x66, 
-	0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x09, 0x00, 
-	0xE3, 0xD7, 0xA0, 0xFA, 0x76, 0xDF, 0x2A, 0xFA, 0x30, 0x0C, 
-	0x06, 0x03, 0x55, 0x1D, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 
-	0x01, 0xFF, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 
-	0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x03, 0x81, 0x81, 
-	0x00, 0x1D, 0xB7, 0xD5, 0x7C, 0xE1, 0xB1, 0xD8, 0xC0, 0x67, 
-	0x5D, 0xB5, 0xD3, 0x88, 0xE7, 0x50, 0x29, 0x71, 0x63, 0x8F, 
-	0xCC, 0x26, 0x1F, 0x33, 0x09, 0x55, 0x43, 0x9B, 0xAB, 0xC6, 
-	0x1B, 0xBC, 0xC7, 0x01, 0x95, 0x1A, 0xFA, 0x65, 0xE0, 0xFD, 
-	0x9C, 0xEB, 0x6F, 0x0A, 0x0F, 0x14, 0xEC, 0xB5, 0x2F, 0xDC, 
-	0x1C, 0x30, 0xDD, 0x52, 0x97, 0xD4, 0x1C, 0x09, 0x00, 0x33, 
-	0x38, 0x5F, 0xCB, 0xA8, 0x16, 0x8F, 0x11, 0xB7, 0xB8, 0xD0, 
-	0x66, 0xE1, 0x54, 0x28, 0xF3, 0x3F, 0xBF, 0x6A, 0x6F, 0x76, 
-	0x48, 0x2A, 0x5E, 0x56, 0xA7, 0xCE, 0x1C, 0xF0, 0x04, 0xDD, 
-	0x17, 0xBD, 0x06, 0x78, 0x21, 0x6D, 0xD6, 0xB1, 0x9B, 0x75, 
-	0x31, 0x92, 0xC1, 0xFE, 0xD4, 0x8D, 0xD4, 0x67, 0x2F, 0x03, 
-	0x1B, 0x27, 0x8D, 0xAB, 0xFF, 0x30, 0x3B, 0xC3, 0x7F, 0x23, 
-	0xE4, 0xAB, 0x5B, 0x91, 0xE1, 0x1B, 0x66, 0xE6, 0xED
-};
-static const int sizeof_client_cert_der_1024 = sizeof(client_cert_der_1024);
-
-/* ./certs/1024/dh1024.der, 1024-bit */
-static const unsigned char dh_key_der_1024[] =
-{
-	0x30, 0x81, 0x87, 0x02, 0x81, 0x81, 0x00, 0xA4, 0xD2, 0xB8, 
-	0x6E, 0x78, 0xF5, 0xD9, 0xED, 0x2D, 0x7C, 0xDD, 0xB6, 0x16, 
-	0x86, 0x5A, 0x4B, 0x05, 0x76, 0x90, 0xDD, 0x66, 0x61, 0xB9, 
-	0x6D, 0x52, 0xA7, 0x1C, 0xAF, 0x62, 0xC6, 0x69, 0x47, 0x7B, 
-	0x39, 0xF2, 0xFB, 0x94, 0xEC, 0xBC, 0x79, 0xFF, 0x24, 0x5E, 
-	0xEF, 0x79, 0xBB, 0x59, 0xB2, 0xFC, 0xCA, 0x07, 0xD6, 0xF4, 
-	0xE9, 0x34, 0xF7, 0xE8, 0x38, 0xE7, 0xD7, 0x33, 0x44, 0x1D, 
-	0xA3, 0x64, 0x76, 0x1A, 0x84, 0x97, 0x54, 0x74, 0x40, 0x84, 
-	0x1F, 0x15, 0xFE, 0x7C, 0x25, 0x2A, 0x2B, 0x25, 0xFD, 0x9E, 
-	0xC1, 0x89, 0x33, 0x8C, 0x39, 0x25, 0x2B, 0x40, 0xE6, 0xCD, 
-	0xF8, 0xA8, 0xA1, 0x8A, 0x53, 0xC6, 0x47, 0xB2, 0xA0, 0xD7, 
-	0x8F, 0xEB, 0x2E, 0x60, 0x0A, 0x0D, 0x4B, 0xF8, 0xB4, 0x94, 
-	0x8C, 0x63, 0x0A, 0xAD, 0xC7, 0x10, 0xEA, 0xC7, 0xA1, 0xB9, 
-	0x9D, 0xF2, 0xA8, 0x37, 0x73, 0x02, 0x01, 0x02
-};
-static const int sizeof_dh_key_der_1024 = sizeof(dh_key_der_1024);
-
-/* ./certs/1024/dsa1024.der, 1024-bit */
-static const unsigned char dsa_key_der_1024[] =
-{
-	0x30, 0x82, 0x01, 0xBC, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 
-	0x00, 0xF7, 0x4B, 0xF9, 0xBB, 0x15, 0x98, 0xEB, 0xDD, 0xDE, 
-	0x1E, 0x4E, 0x71, 0x88, 0x85, 0xF2, 0xB7, 0xBA, 0xE2, 0x4A, 
-	0xDA, 0x76, 0x40, 0xCD, 0x69, 0x48, 0x9E, 0x83, 0x7C, 0x11, 
-	0xF7, 0x65, 0x31, 0x78, 0xF5, 0x25, 0x2D, 0xF7, 0xB7, 0xF8, 
-	0x52, 0x3F, 0xBE, 0xD8, 0xB6, 0xC5, 0xFE, 0x18, 0x15, 0x5B, 
-	0xB9, 0xD5, 0x92, 0x86, 0xBC, 0xB2, 0x17, 0x7C, 0xD8, 0xB0, 
-	0xBE, 0xA0, 0x7C, 0xF2, 0xD5, 0x73, 0x7A, 0x58, 0x8F, 0x8D, 
-	0xE5, 0x4A, 0x00, 0x99, 0x83, 0x4A, 0xC0, 0x9E, 0x16, 0x09, 
-	0xA1, 0x10, 0x34, 0xD5, 0x19, 0xBB, 0x63, 0xE3, 0xDD, 0x83, 
-	0x74, 0x7F, 0x10, 0xCA, 0x73, 0x75, 0xEE, 0x31, 0x4A, 0xDD, 
-	0x9F, 0xE0, 0x02, 0x6A, 0x9D, 0xEE, 0xB2, 0x4B, 0xA7, 0x6B, 
-	0x2A, 0x6C, 0xC7, 0x86, 0x77, 0xE8, 0x04, 0x15, 0xDC, 0x92, 
-	0xB4, 0x7A, 0x29, 0x1F, 0x4E, 0x83, 0x63, 0x85, 0x55, 0x02, 
-	0x15, 0x00, 0xD2, 0x05, 0xE4, 0x73, 0xFB, 0xC1, 0x99, 0xC5, 
-	0xDC, 0x68, 0xA4, 0x8D, 0x92, 0x27, 0x3D, 0xE2, 0x52, 0x5F, 
-	0x89, 0x8B, 0x02, 0x81, 0x81, 0x00, 0xAA, 0x21, 0x02, 0x09, 
-	0x43, 0x6E, 0xFB, 0xA2, 0x54, 0x14, 0x85, 0x0A, 0xF4, 0x28, 
-	0x7C, 0xCB, 0xCC, 0xDB, 0xF5, 0x1E, 0xA2, 0x18, 0xA9, 0x21, 
-	0xDE, 0x88, 0x88, 0x33, 0x8C, 0x2E, 0xEB, 0x8D, 0xA3, 0xF0, 
-	0x1D, 0xC8, 0x8F, 0xF6, 0x7E, 0xF8, 0xCF, 0x12, 0xF5, 0xB4, 
-	0xA1, 0x11, 0x6F, 0x0C, 0xD4, 0xF0, 0x06, 0xAD, 0xC4, 0xFC, 
-	0x14, 0x45, 0xC7, 0x94, 0x15, 0xBC, 0x19, 0x4B, 0xAE, 0xEF, 
-	0x93, 0x6A, 0x4F, 0xCC, 0x14, 0xD8, 0x47, 0x8B, 0x39, 0x66, 
-	0x87, 0x02, 0xD4, 0x28, 0x0A, 0xB8, 0xEE, 0x09, 0x37, 0xF4, 
-	0x00, 0xA0, 0x04, 0xA7, 0x79, 0xA7, 0xD2, 0x3C, 0xF7, 0x34, 
-	0x43, 0x56, 0x8E, 0xD0, 0x7C, 0xC2, 0xD8, 0x4D, 0x0F, 0x89, 
-	0xED, 0x14, 0xC1, 0x2C, 0x9C, 0x4C, 0x19, 0x9B, 0x9E, 0xDC, 
-	0x53, 0x09, 0x9F, 0xDF, 0x2D, 0xF0, 0x0C, 0x27, 0x54, 0x3A, 
-	0x77, 0x14, 0x2D, 0xDE, 0x02, 0x81, 0x81, 0x00, 0xE8, 0x1F, 
-	0x7C, 0xB7, 0xC0, 0x54, 0x51, 0xA7, 0x28, 0x2D, 0x58, 0x7C, 
-	0xDE, 0xD4, 0x5C, 0xDD, 0xD5, 0x76, 0x84, 0x3C, 0x36, 0x20, 
-	0xC0, 0xC3, 0x25, 0xD7, 0x3A, 0x38, 0xE1, 0x54, 0xC8, 0xFD, 
-	0x40, 0x68, 0x1A, 0x21, 0x54, 0x26, 0x39, 0x14, 0xBF, 0xF6, 
-	0xA3, 0x9C, 0x5E, 0xD9, 0x2B, 0xF7, 0xC9, 0x25, 0xBA, 0x00, 
-	0x09, 0xCB, 0x7F, 0x0C, 0x4A, 0x24, 0xFD, 0x15, 0x16, 0x15, 
-	0x48, 0xCD, 0x0B, 0x52, 0x44, 0x40, 0x7B, 0x90, 0x63, 0x2B, 
-	0x90, 0x22, 0xC5, 0x18, 0x05, 0x80, 0x53, 0xAF, 0x83, 0x1F, 
-	0x54, 0xE2, 0xB0, 0xA2, 0x0B, 0x5A, 0x92, 0x24, 0xE1, 0x62, 
-	0x28, 0x3F, 0xB7, 0xCA, 0xB9, 0x89, 0xD6, 0xA0, 0xB7, 0xAD, 
-	0xAE, 0x05, 0xE1, 0xC1, 0x59, 0x40, 0xED, 0x4A, 0x1B, 0x68, 
-	0xA7, 0x7B, 0xFB, 0xC3, 0x20, 0x81, 0xEF, 0x4B, 0xF3, 0x69, 
-	0x91, 0xB0, 0xCE, 0x3A, 0xB0, 0x38, 0x02, 0x14, 0x25, 0x38, 
-	0x3B, 0xA1, 0x19, 0x75, 0xDF, 0x9B, 0xF5, 0x72, 0x53, 0x4F, 
-	0x39, 0xE1, 0x1C, 0xEC, 0x13, 0x84, 0x82, 0x18
-};
-static const int sizeof_dsa_key_der_1024 = sizeof(dsa_key_der_1024);
-
-/* ./certs/1024/rsa1024.der, 1024-bit */
-static const unsigned char rsa_key_der_1024[] =
-{
-	0x30, 0x82, 0x02, 0x5D, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 
-	0x00, 0xBE, 0x70, 0x70, 0xB8, 0x04, 0x18, 0xE5, 0x28, 0xFE, 
-	0x66, 0xD8, 0x90, 0x88, 0xE0, 0xF1, 0xB7, 0xC3, 0xD0, 0xD2, 
-	0x3E, 0xE6, 0x4B, 0x94, 0x74, 0xB0, 0xFF, 0xB0, 0xF7, 0x63, 
-	0xA5, 0xAB, 0x7E, 0xAF, 0xB6, 0x2B, 0xB7, 0x38, 0x16, 0x1A, 
-	0x50, 0xBF, 0xF1, 0xCA, 0x87, 0x3A, 0xD5, 0xB0, 0xDA, 0xF8, 
-	0x43, 0x7A, 0x15, 0xB9, 0x7E, 0xEA, 0x2A, 0x80, 0xD2, 0x51, 
-	0xB0, 0x35, 0xAF, 0x07, 0xF3, 0xF2, 0x5D, 0x24, 0x3A, 0x4B, 
-	0x87, 0x56, 0x48, 0x1B, 0x3C, 0x24, 0x9A, 0xDA, 0x70, 0x80, 
-	0xBD, 0x3C, 0x8B, 0x03, 0x4A, 0x0C, 0x83, 0x71, 0xDE, 0xE3, 
-	0x03, 0x70, 0xA2, 0xB7, 0x60, 0x09, 0x1B, 0x5E, 0xC7, 0x3D, 
-	0xA0, 0x64, 0x60, 0xE3, 0xA9, 0x06, 0x8D, 0xD3, 0xFF, 0x42, 
-	0xBB, 0x0A, 0x94, 0x27, 0x2D, 0x57, 0x42, 0x0D, 0xB0, 0x2D, 
-	0xE0, 0xBA, 0x18, 0x25, 0x60, 0x92, 0x11, 0x92, 0xF3, 0x02, 
-	0x03, 0x01, 0x00, 0x01, 0x02, 0x81, 0x80, 0x0E, 0xEE, 0x1D, 
-	0xC8, 0x2F, 0x7A, 0x0C, 0x2D, 0x44, 0x94, 0xA7, 0x91, 0xDD, 
-	0x49, 0x55, 0x6A, 0x04, 0xCE, 0x10, 0x4D, 0xA2, 0x1C, 0x76, 
-	0xCD, 0x17, 0x3B, 0x54, 0x92, 0x70, 0x9B, 0x82, 0x70, 0x72, 
-	0x32, 0x24, 0x07, 0x3F, 0x3C, 0x6C, 0x5F, 0xBC, 0x4C, 0xA6, 
-	0x86, 0x27, 0x94, 0xAD, 0x42, 0xDD, 0x87, 0xDC, 0xC0, 0x6B, 
-	0x44, 0x89, 0xF3, 0x3F, 0x1A, 0x3E, 0x11, 0x44, 0x84, 0x2E, 
-	0x69, 0x4C, 0xBB, 0x4A, 0x71, 0x1A, 0xBB, 0x9A, 0x52, 0x3C, 
-	0x6B, 0xDE, 0xBC, 0xB2, 0x7C, 0x51, 0xEF, 0x4F, 0x8F, 0x3A, 
-	0xDC, 0x50, 0x04, 0x4E, 0xB6, 0x31, 0x66, 0xA8, 0x8E, 0x06, 
-	0x3B, 0x51, 0xA9, 0xC1, 0x8A, 0xCB, 0xC4, 0x81, 0xCA, 0x2D, 
-	0x69, 0xEC, 0x88, 0xFC, 0x33, 0x88, 0xD1, 0xD4, 0x29, 0x47, 
-	0x87, 0x37, 0xF9, 0x6A, 0x22, 0x69, 0xB9, 0xC9, 0xFE, 0xEB, 
-	0x8C, 0xC5, 0x21, 0x41, 0x71, 0x02, 0x41, 0x00, 0xFD, 0x17, 
-	0x98, 0x42, 0x54, 0x1C, 0x23, 0xF8, 0xD7, 0x5D, 0xEF, 0x49, 
-	0x4F, 0xAF, 0xD9, 0x35, 0x6F, 0x08, 0xC6, 0xC7, 0x40, 0x5C, 
-	0x7E, 0x58, 0x86, 0xC2, 0xB2, 0x16, 0x39, 0x24, 0xC5, 0x06, 
-	0xB0, 0x3D, 0xAF, 0x02, 0xD2, 0x87, 0x77, 0xD2, 0x76, 0xBA, 
-	0xE3, 0x59, 0x60, 0x42, 0xF1, 0x16, 0xEF, 0x33, 0x0B, 0xF2, 
-	0x0B, 0xBA, 0x99, 0xCC, 0xB6, 0x4C, 0x46, 0x3F, 0x33, 0xE4, 
-	0xD4, 0x67, 0x02, 0x41, 0x00, 0xC0, 0xA0, 0x91, 0x6D, 0xFE, 
-	0x28, 0xE0, 0x81, 0x5A, 0x15, 0xA7, 0xC9, 0xA8, 0x98, 0xC6, 
-	0x0A, 0xAB, 0x00, 0xC5, 0x40, 0xC9, 0x21, 0xBB, 0xB2, 0x33, 
-	0x5A, 0xA7, 0xCB, 0x6E, 0xB8, 0x08, 0x56, 0x4A, 0x76, 0x28, 
-	0xE8, 0x6D, 0xBD, 0xF5, 0x26, 0x7B, 0xBF, 0xC5, 0x46, 0x45, 
-	0x0D, 0xEC, 0x7D, 0xEE, 0x82, 0xD6, 0xCA, 0x5F, 0x3D, 0x6E, 
-	0xCC, 0x94, 0x73, 0xCD, 0xCE, 0x86, 0x6E, 0x95, 0x95, 0x02, 
-	0x40, 0x38, 0xFD, 0x28, 0x1E, 0xBF, 0x5B, 0xBA, 0xC9, 0xDC, 
-	0x8C, 0xDD, 0x45, 0xAF, 0xB8, 0xD3, 0xFB, 0x11, 0x2E, 0x73, 
-	0xBC, 0x08, 0x05, 0x0B, 0xBA, 0x19, 0x56, 0x1B, 0xCD, 0x9F, 
-	0x3E, 0x65, 0x53, 0x15, 0x3A, 0x3E, 0x7F, 0x2F, 0x32, 0xAB, 
-	0xCB, 0x6B, 0x4A, 0xB7, 0xC8, 0xB7, 0x41, 0x3B, 0x92, 0x43, 
-	0x78, 0x46, 0x17, 0x51, 0x86, 0xC9, 0xFC, 0xEB, 0x8B, 0x8F, 
-	0x41, 0xCA, 0x08, 0x9B, 0xBF, 0x02, 0x41, 0x00, 0xAD, 0x9B, 
-	0x89, 0xB6, 0xF2, 0x8C, 0x70, 0xDA, 0xE4, 0x10, 0x04, 0x6B, 
-	0x11, 0x92, 0xAF, 0x5A, 0xCA, 0x08, 0x25, 0xBF, 0x60, 0x07, 
-	0x11, 0x1D, 0x68, 0x7F, 0x5A, 0x1F, 0x55, 0x28, 0x74, 0x0B, 
-	0x21, 0x8D, 0x21, 0x0D, 0x6A, 0x6A, 0xFB, 0xD9, 0xB5, 0x4A, 
-	0x7F, 0x47, 0xF7, 0xD0, 0xB6, 0xC6, 0x41, 0x02, 0x97, 0x07, 
-	0x49, 0x93, 0x1A, 0x9B, 0x33, 0x68, 0xB3, 0xA2, 0x61, 0x32, 
-	0xA5, 0x89, 0x02, 0x41, 0x00, 0x8F, 0xEF, 0xAD, 0xB5, 0xB0, 
-	0xB0, 0x7E, 0x86, 0x03, 0x43, 0x93, 0x6E, 0xDD, 0x3C, 0x2D, 
-	0x9B, 0x6A, 0x55, 0xFF, 0x6F, 0x3E, 0x70, 0x2A, 0xD4, 0xBF, 
-	0x1F, 0x8C, 0x93, 0x60, 0x9E, 0x6D, 0x2F, 0x18, 0x6C, 0x11, 
-	0x36, 0x98, 0x3F, 0x10, 0x78, 0xE8, 0x3E, 0x8F, 0xFE, 0x55, 
-	0xB9, 0x9E, 0xD5, 0x5B, 0x2E, 0x87, 0x1C, 0x58, 0xD0, 0x37, 
-	0x89, 0x96, 0xEC, 0x48, 0x54, 0xF5, 0x9F, 0x0F, 0xB3
-};
-static const int sizeof_rsa_key_der_1024 = sizeof(rsa_key_der_1024);
-
-#elif defined(USE_CERT_BUFFERS_2048)
-
-/* ./certs/client-key.der, 2048-bit */
-static const unsigned char client_key_der_2048[] =
-{
-	0x30, 0x82, 0x04, 0xA4, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 
-	0x01, 0x00, 0xC3, 0x03, 0xD1, 0x2B, 0xFE, 0x39, 0xA4, 0x32, 
-	0x45, 0x3B, 0x53, 0xC8, 0x84, 0x2B, 0x2A, 0x7C, 0x74, 0x9A, 
-	0xBD, 0xAA, 0x2A, 0x52, 0x07, 0x47, 0xD6, 0xA6, 0x36, 0xB2, 
-	0x07, 0x32, 0x8E, 0xD0, 0xBA, 0x69, 0x7B, 0xC6, 0xC3, 0x44, 
-	0x9E, 0xD4, 0x81, 0x48, 0xFD, 0x2D, 0x68, 0xA2, 0x8B, 0x67, 
-	0xBB, 0xA1, 0x75, 0xC8, 0x36, 0x2C, 0x4A, 0xD2, 0x1B, 0xF7, 
-	0x8B, 0xBA, 0xCF, 0x0D, 0xF9, 0xEF, 0xEC, 0xF1, 0x81, 0x1E, 
-	0x7B, 0x9B, 0x03, 0x47, 0x9A, 0xBF, 0x65, 0xCC, 0x7F, 0x65, 
-	0x24, 0x69, 0xA6, 0xE8, 0x14, 0x89, 0x5B, 0xE4, 0x34, 0xF7, 
-	0xC5, 0xB0, 0x14, 0x93, 0xF5, 0x67, 0x7B, 0x3A, 0x7A, 0x78, 
-	0xE1, 0x01, 0x56, 0x56, 0x91, 0xA6, 0x13, 0x42, 0x8D, 0xD2, 
-	0x3C, 0x40, 0x9C, 0x4C, 0xEF, 0xD1, 0x86, 0xDF, 0x37, 0x51, 
-	0x1B, 0x0C, 0xA1, 0x3B, 0xF5, 0xF1, 0xA3, 0x4A, 0x35, 0xE4, 
-	0xE1, 0xCE, 0x96, 0xDF, 0x1B, 0x7E, 0xBF, 0x4E, 0x97, 0xD0, 
-	0x10, 0xE8, 0xA8, 0x08, 0x30, 0x81, 0xAF, 0x20, 0x0B, 0x43, 
-	0x14, 0xC5, 0x74, 0x67, 0xB4, 0x32, 0x82, 0x6F, 0x8D, 0x86, 
-	0xC2, 0x88, 0x40, 0x99, 0x36, 0x83, 0xBA, 0x1E, 0x40, 0x72, 
-	0x22, 0x17, 0xD7, 0x52, 0x65, 0x24, 0x73, 0xB0, 0xCE, 0xEF, 
-	0x19, 0xCD, 0xAE, 0xFF, 0x78, 0x6C, 0x7B, 0xC0, 0x12, 0x03, 
-	0xD4, 0x4E, 0x72, 0x0D, 0x50, 0x6D, 0x3B, 0xA3, 0x3B, 0xA3, 
-	0x99, 0x5E, 0x9D, 0xC8, 0xD9, 0x0C, 0x85, 0xB3, 0xD9, 0x8A, 
-	0xD9, 0x54, 0x26, 0xDB, 0x6D, 0xFA, 0xAC, 0xBB, 0xFF, 0x25, 
-	0x4C, 0xC4, 0xD1, 0x79, 0xF4, 0x71, 0xD3, 0x86, 0x40, 0x18, 
-	0x13, 0xB0, 0x63, 0xB5, 0x72, 0x4E, 0x30, 0xC4, 0x97, 0x84, 
-	0x86, 0x2D, 0x56, 0x2F, 0xD7, 0x15, 0xF7, 0x7F, 0xC0, 0xAE, 
-	0xF5, 0xFC, 0x5B, 0xE5, 0xFB, 0xA1, 0xBA, 0xD3, 0x02, 0x03, 
-	0x01, 0x00, 0x01, 0x02, 0x82, 0x01, 0x01, 0x00, 0xA2, 0xE6, 
-	0xD8, 0x5F, 0x10, 0x71, 0x64, 0x08, 0x9E, 0x2E, 0x6D, 0xD1, 
-	0x6D, 0x1E, 0x85, 0xD2, 0x0A, 0xB1, 0x8C, 0x47, 0xCE, 0x2C, 
-	0x51, 0x6A, 0xA0, 0x12, 0x9E, 0x53, 0xDE, 0x91, 0x4C, 0x1D, 
-	0x6D, 0xEA, 0x59, 0x7B, 0xF2, 0x77, 0xAA, 0xD9, 0xC6, 0xD9, 
-	0x8A, 0xAB, 0xD8, 0xE1, 0x16, 0xE4, 0x63, 0x26, 0xFF, 0xB5, 
-	0x6C, 0x13, 0x59, 0xB8, 0xE3, 0xA5, 0xC8, 0x72, 0x17, 0x2E, 
-	0x0C, 0x9F, 0x6F, 0xE5, 0x59, 0x3F, 0x76, 0x6F, 0x49, 0xB1, 
-	0x11, 0xC2, 0x5A, 0x2E, 0x16, 0x29, 0x0D, 0xDE, 0xB7, 0x8E, 
-	0xDC, 0x40, 0xD5, 0xA2, 0xEE, 0xE0, 0x1E, 0xA1, 0xF4, 0xBE, 
-	0x97, 0xDB, 0x86, 0x63, 0x96, 0x14, 0xCD, 0x98, 0x09, 0x60, 
-	0x2D, 0x30, 0x76, 0x9C, 0x3C, 0xCD, 0xE6, 0x88, 0xEE, 0x47, 
-	0x92, 0x79, 0x0B, 0x5A, 0x00, 0xE2, 0x5E, 0x5F, 0x11, 0x7C, 
-	0x7D, 0xF9, 0x08, 0xB7, 0x20, 0x06, 0x89, 0x2A, 0x5D, 0xFD, 
-	0x00, 0xAB, 0x22, 0xE1, 0xF0, 0xB3, 0xBC, 0x24, 0xA9, 0x5E, 
-	0x26, 0x0E, 0x1F, 0x00, 0x2D, 0xFE, 0x21, 0x9A, 0x53, 0x5B, 
-	0x6D, 0xD3, 0x2B, 0xAB, 0x94, 0x82, 0x68, 0x43, 0x36, 0xD8, 
-	0xF6, 0x2F, 0xC6, 0x22, 0xFC, 0xB5, 0x41, 0x5D, 0x0D, 0x33, 
-	0x60, 0xEA, 0xA4, 0x7D, 0x7E, 0xE8, 0x4B, 0x55, 0x91, 0x56, 
-	0xD3, 0x5C, 0x57, 0x8F, 0x1F, 0x94, 0x17, 0x2F, 0xAA, 0xDE, 
-	0xE9, 0x9E, 0xA8, 0xF4, 0xCF, 0x8A, 0x4C, 0x8E, 0xA0, 0xE4, 
-	0x56, 0x73, 0xB2, 0xCF, 0x4F, 0x86, 0xC5, 0x69, 0x3C, 0xF3, 
-	0x24, 0x20, 0x8B, 0x5C, 0x96, 0x0C, 0xFA, 0x6B, 0x12, 0x3B, 
-	0x9A, 0x67, 0xC1, 0xDF, 0xC6, 0x96, 0xB2, 0xA5, 0xD5, 0x92, 
-	0x0D, 0x9B, 0x09, 0x42, 0x68, 0x24, 0x10, 0x45, 0xD4, 0x50, 
-	0xE4, 0x17, 0x39, 0x48, 0xD0, 0x35, 0x8B, 0x94, 0x6D, 0x11, 
-	0xDE, 0x8F, 0xCA, 0x59, 0x02, 0x81, 0x81, 0x00, 0xEA, 0x24, 
-	0xA7, 0xF9, 0x69, 0x33, 0xE9, 0x71, 0xDC, 0x52, 0x7D, 0x88, 
-	0x21, 0x28, 0x2F, 0x49, 0xDE, 0xBA, 0x72, 0x16, 0xE9, 0xCC, 
-	0x47, 0x7A, 0x88, 0x0D, 0x94, 0x57, 0x84, 0x58, 0x16, 0x3A, 
-	0x81, 0xB0, 0x3F, 0xA2, 0xCF, 0xA6, 0x6C, 0x1E, 0xB0, 0x06, 
-	0x29, 0x00, 0x8F, 0xE7, 0x77, 0x76, 0xAC, 0xDB, 0xCA, 0xC7, 
-	0xD9, 0x5E, 0x9B, 0x3F, 0x26, 0x90, 0x52, 0xAE, 0xFC, 0x38, 
-	0x90, 0x00, 0x14, 0xBB, 0xB4, 0x0F, 0x58, 0x94, 0xE7, 0x2F, 
-	0x6A, 0x7E, 0x1C, 0x4F, 0x41, 0x21, 0xD4, 0x31, 0x59, 0x1F, 
-	0x4E, 0x8A, 0x1A, 0x8D, 0xA7, 0x57, 0x6C, 0x22, 0xD8, 0xE5, 
-	0xF4, 0x7E, 0x32, 0xA6, 0x10, 0xCB, 0x64, 0xA5, 0x55, 0x03, 
-	0x87, 0xA6, 0x27, 0x05, 0x8C, 0xC3, 0xD7, 0xB6, 0x27, 0xB2, 
-	0x4D, 0xBA, 0x30, 0xDA, 0x47, 0x8F, 0x54, 0xD3, 0x3D, 0x8B, 
-	0x84, 0x8D, 0x94, 0x98, 0x58, 0xA5, 0x02, 0x81, 0x81, 0x00, 
-	0xD5, 0x38, 0x1B, 0xC3, 0x8F, 0xC5, 0x93, 0x0C, 0x47, 0x0B, 
-	0x6F, 0x35, 0x92, 0xC5, 0xB0, 0x8D, 0x46, 0xC8, 0x92, 0x18, 
-	0x8F, 0xF5, 0x80, 0x0A, 0xF7, 0xEF, 0xA1, 0xFE, 0x80, 0xB9, 
-	0xB5, 0x2A, 0xBA, 0xCA, 0x18, 0xB0, 0x5D, 0xA5, 0x07, 0xD0, 
-	0x93, 0x8D, 0xD8, 0x9C, 0x04, 0x1C, 0xD4, 0x62, 0x8E, 0xA6, 
-	0x26, 0x81, 0x01, 0xFF, 0xCE, 0x8A, 0x2A, 0x63, 0x34, 0x35, 
-	0x40, 0xAA, 0x6D, 0x80, 0xDE, 0x89, 0x23, 0x6A, 0x57, 0x4D, 
-	0x9E, 0x6E, 0xAD, 0x93, 0x4E, 0x56, 0x90, 0x0B, 0x6D, 0x9D, 
-	0x73, 0x8B, 0x0C, 0xAE, 0x27, 0x3D, 0xDE, 0x4E, 0xF0, 0xAA, 
-	0xC5, 0x6C, 0x78, 0x67, 0x6C, 0x94, 0x52, 0x9C, 0x37, 0x67, 
-	0x6C, 0x2D, 0xEF, 0xBB, 0xAF, 0xDF, 0xA6, 0x90, 0x3C, 0xC4, 
-	0x47, 0xCF, 0x8D, 0x96, 0x9E, 0x98, 0xA9, 0xB4, 0x9F, 0xC5, 
-	0xA6, 0x50, 0xDC, 0xB3, 0xF0, 0xFB, 0x74, 0x17, 0x02, 0x81, 
-	0x80, 0x5E, 0x83, 0x09, 0x62, 0xBD, 0xBA, 0x7C, 0xA2, 0xBF, 
-	0x42, 0x74, 0xF5, 0x7C, 0x1C, 0xD2, 0x69, 0xC9, 0x04, 0x0D, 
-	0x85, 0x7E, 0x3E, 0x3D, 0x24, 0x12, 0xC3, 0x18, 0x7B, 0xF3, 
-	0x29, 0xF3, 0x5F, 0x0E, 0x76, 0x6C, 0x59, 0x75, 0xE4, 0x41, 
-	0x84, 0x69, 0x9D, 0x32, 0xF3, 0xCD, 0x22, 0xAB, 0xB0, 0x35, 
-	0xBA, 0x4A, 0xB2, 0x3C, 0xE5, 0xD9, 0x58, 0xB6, 0x62, 0x4F, 
-	0x5D, 0xDE, 0xE5, 0x9E, 0x0A, 0xCA, 0x53, 0xB2, 0x2C, 0xF7, 
-	0x9E, 0xB3, 0x6B, 0x0A, 0x5B, 0x79, 0x65, 0xEC, 0x6E, 0x91, 
-	0x4E, 0x92, 0x20, 0xF6, 0xFC, 0xFC, 0x16, 0xED, 0xD3, 0x76, 
-	0x0C, 0xE2, 0xEC, 0x7F, 0xB2, 0x69, 0x13, 0x6B, 0x78, 0x0E, 
-	0x5A, 0x46, 0x64, 0xB4, 0x5E, 0xB7, 0x25, 0xA0, 0x5A, 0x75, 
-	0x3A, 0x4B, 0xEF, 0xC7, 0x3C, 0x3E, 0xF7, 0xFD, 0x26, 0xB8, 
-	0x20, 0xC4, 0x99, 0x0A, 0x9A, 0x73, 0xBE, 0xC3, 0x19, 0x02, 
-	0x81, 0x81, 0x00, 0xBA, 0x44, 0x93, 0x14, 0xAC, 0x34, 0x19, 
-	0x3B, 0x5F, 0x91, 0x60, 0xAC, 0xF7, 0xB4, 0xD6, 0x81, 0x05, 
-	0x36, 0x51, 0x53, 0x3D, 0xE8, 0x65, 0xDC, 0xAF, 0x2E, 0xDC, 
-	0x61, 0x3E, 0xC9, 0x7D, 0xB8, 0x7F, 0x87, 0xF0, 0x3B, 0x9B, 
-	0x03, 0x82, 0x29, 0x37, 0xCE, 0x72, 0x4E, 0x11, 0xD5, 0xB1, 
-	0xC1, 0x0C, 0x07, 0xA0, 0x99, 0x91, 0x4A, 0x8D, 0x7F, 0xEC, 
-	0x79, 0xCF, 0xF1, 0x39, 0xB5, 0xE9, 0x85, 0xEC, 0x62, 0xF7, 
-	0xDA, 0x7D, 0xBC, 0x64, 0x4D, 0x22, 0x3C, 0x0E, 0xF2, 0xD6, 
-	0x51, 0xF5, 0x87, 0xD8, 0x99, 0xC0, 0x11, 0x20, 0x5D, 0x0F, 
-	0x29, 0xFD, 0x5B, 0xE2, 0xAE, 0xD9, 0x1C, 0xD9, 0x21, 0x56, 
-	0x6D, 0xFC, 0x84, 0xD0, 0x5F, 0xED, 0x10, 0x15, 0x1C, 0x18, 
-	0x21, 0xE7, 0xC4, 0x3D, 0x4B, 0xD7, 0xD0, 0x9E, 0x6A, 0x95, 
-	0xCF, 0x22, 0xC9, 0x03, 0x7B, 0x9E, 0xE3, 0x60, 0x01, 0xFC, 
-	0x2F, 0x02, 0x81, 0x80, 0x11, 0xD0, 0x4B, 0xCF, 0x1B, 0x67, 
-	0xB9, 0x9F, 0x10, 0x75, 0x47, 0x86, 0x65, 0xAE, 0x31, 0xC2, 
-	0xC6, 0x30, 0xAC, 0x59, 0x06, 0x50, 0xD9, 0x0F, 0xB5, 0x70, 
-	0x06, 0xF7, 0xF0, 0xD3, 0xC8, 0x62, 0x7C, 0xA8, 0xDA, 0x6E, 
-	0xF6, 0x21, 0x3F, 0xD3, 0x7F, 0x5F, 0xEA, 0x8A, 0xAB, 0x3F, 
-	0xD9, 0x2A, 0x5E, 0xF3, 0x51, 0xD2, 0xC2, 0x30, 0x37, 0xE3, 
-	0x2D, 0xA3, 0x75, 0x0D, 0x1E, 0x4D, 0x21, 0x34, 0xD5, 0x57, 
-	0x70, 0x5C, 0x89, 0xBF, 0x72, 0xEC, 0x4A, 0x6E, 0x68, 0xD5, 
-	0xCD, 0x18, 0x74, 0x33, 0x4E, 0x8C, 0x3A, 0x45, 0x8F, 0xE6, 
-	0x96, 0x40, 0xEB, 0x63, 0xF9, 0x19, 0x86, 0x3A, 0x51, 0xDD, 
-	0x89, 0x4B, 0xB0, 0xF3, 0xF9, 0x9F, 0x5D, 0x28, 0x95, 0x38, 
-	0xBE, 0x35, 0xAB, 0xCA, 0x5C, 0xE7, 0x93, 0x53, 0x34, 0xA1, 
-	0x45, 0x5D, 0x13, 0x39, 0x65, 0x42, 0x46, 0xA1, 0x9F, 0xCD, 
-	0xF5, 0xBF
-};
-static const int sizeof_client_key_der_2048 = sizeof(client_key_der_2048);
-
-/* ./certs/client-cert.der, 2048-bit */
-static const unsigned char client_cert_der_2048[] =
-{
-	0x30, 0x82, 0x04, 0xCA, 0x30, 0x82, 0x03, 0xB2, 0xA0, 0x03, 
-	0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xAA, 0x27, 0xB3, 0xC5, 
-	0xA9, 0x72, 0x6E, 0x0D, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 
-	0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x30, 
-	0x81, 0x9E, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 
-	0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x10, 0x30, 0x0E, 0x06, 
-	0x03, 0x55, 0x04, 0x08, 0x0C, 0x07, 0x4D, 0x6F, 0x6E, 0x74, 
-	0x61, 0x6E, 0x61, 0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 
-	0x04, 0x07, 0x0C, 0x07, 0x42, 0x6F, 0x7A, 0x65, 0x6D, 0x61, 
-	0x6E, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0A, 
-	0x0C, 0x0C, 0x77, 0x6F, 0x6C, 0x66, 0x53, 0x53, 0x4C, 0x5F, 
-	0x32, 0x30, 0x34, 0x38, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 
-	0x55, 0x04, 0x0B, 0x0C, 0x10, 0x50, 0x72, 0x6F, 0x67, 0x72, 
-	0x61, 0x6D, 0x6D, 0x69, 0x6E, 0x67, 0x2D, 0x32, 0x30, 0x34, 
-	0x38, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 
-	0x0C, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x6F, 0x6C, 0x66, 
-	0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x31, 0x1F, 0x30, 
-	0x1D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 
-	0x09, 0x01, 0x16, 0x10, 0x69, 0x6E, 0x66, 0x6F, 0x40, 0x77, 
-	0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 
-	0x30, 0x1E, 0x17, 0x0D, 0x31, 0x35, 0x30, 0x35, 0x30, 0x37, 
-	0x31, 0x38, 0x32, 0x31, 0x30, 0x31, 0x5A, 0x17, 0x0D, 0x31, 
-	0x38, 0x30, 0x31, 0x33, 0x31, 0x31, 0x38, 0x32, 0x31, 0x30, 
-	0x31, 0x5A, 0x30, 0x81, 0x9E, 0x31, 0x0B, 0x30, 0x09, 0x06, 
-	0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x10, 
-	0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0C, 0x07, 0x4D, 
-	0x6F, 0x6E, 0x74, 0x61, 0x6E, 0x61, 0x31, 0x10, 0x30, 0x0E, 
-	0x06, 0x03, 0x55, 0x04, 0x07, 0x0C, 0x07, 0x42, 0x6F, 0x7A, 
-	0x65, 0x6D, 0x61, 0x6E, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 
-	0x55, 0x04, 0x0A, 0x0C, 0x0C, 0x77, 0x6F, 0x6C, 0x66, 0x53, 
-	0x53, 0x4C, 0x5F, 0x32, 0x30, 0x34, 0x38, 0x31, 0x19, 0x30, 
-	0x17, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x0C, 0x10, 0x50, 0x72, 
-	0x6F, 0x67, 0x72, 0x61, 0x6D, 0x6D, 0x69, 0x6E, 0x67, 0x2D, 
-	0x32, 0x30, 0x34, 0x38, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 
-	0x55, 0x04, 0x03, 0x0C, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x77, 
-	0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 
-	0x31, 0x1F, 0x30, 0x1D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 
-	0xF7, 0x0D, 0x01, 0x09, 0x01, 0x16, 0x10, 0x69, 0x6E, 0x66, 
-	0x6F, 0x40, 0x77, 0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 
-	0x63, 0x6F, 0x6D, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0D, 0x06, 
-	0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 
-	0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00, 0x30, 0x82, 0x01, 
-	0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xC3, 0x03, 0xD1, 0x2B, 
-	0xFE, 0x39, 0xA4, 0x32, 0x45, 0x3B, 0x53, 0xC8, 0x84, 0x2B, 
-	0x2A, 0x7C, 0x74, 0x9A, 0xBD, 0xAA, 0x2A, 0x52, 0x07, 0x47, 
-	0xD6, 0xA6, 0x36, 0xB2, 0x07, 0x32, 0x8E, 0xD0, 0xBA, 0x69, 
-	0x7B, 0xC6, 0xC3, 0x44, 0x9E, 0xD4, 0x81, 0x48, 0xFD, 0x2D, 
-	0x68, 0xA2, 0x8B, 0x67, 0xBB, 0xA1, 0x75, 0xC8, 0x36, 0x2C, 
-	0x4A, 0xD2, 0x1B, 0xF7, 0x8B, 0xBA, 0xCF, 0x0D, 0xF9, 0xEF, 
-	0xEC, 0xF1, 0x81, 0x1E, 0x7B, 0x9B, 0x03, 0x47, 0x9A, 0xBF, 
-	0x65, 0xCC, 0x7F, 0x65, 0x24, 0x69, 0xA6, 0xE8, 0x14, 0x89, 
-	0x5B, 0xE4, 0x34, 0xF7, 0xC5, 0xB0, 0x14, 0x93, 0xF5, 0x67, 
-	0x7B, 0x3A, 0x7A, 0x78, 0xE1, 0x01, 0x56, 0x56, 0x91, 0xA6, 
-	0x13, 0x42, 0x8D, 0xD2, 0x3C, 0x40, 0x9C, 0x4C, 0xEF, 0xD1, 
-	0x86, 0xDF, 0x37, 0x51, 0x1B, 0x0C, 0xA1, 0x3B, 0xF5, 0xF1, 
-	0xA3, 0x4A, 0x35, 0xE4, 0xE1, 0xCE, 0x96, 0xDF, 0x1B, 0x7E, 
-	0xBF, 0x4E, 0x97, 0xD0, 0x10, 0xE8, 0xA8, 0x08, 0x30, 0x81, 
-	0xAF, 0x20, 0x0B, 0x43, 0x14, 0xC5, 0x74, 0x67, 0xB4, 0x32, 
-	0x82, 0x6F, 0x8D, 0x86, 0xC2, 0x88, 0x40, 0x99, 0x36, 0x83, 
-	0xBA, 0x1E, 0x40, 0x72, 0x22, 0x17, 0xD7, 0x52, 0x65, 0x24, 
-	0x73, 0xB0, 0xCE, 0xEF, 0x19, 0xCD, 0xAE, 0xFF, 0x78, 0x6C, 
-	0x7B, 0xC0, 0x12, 0x03, 0xD4, 0x4E, 0x72, 0x0D, 0x50, 0x6D, 
-	0x3B, 0xA3, 0x3B, 0xA3, 0x99, 0x5E, 0x9D, 0xC8, 0xD9, 0x0C, 
-	0x85, 0xB3, 0xD9, 0x8A, 0xD9, 0x54, 0x26, 0xDB, 0x6D, 0xFA, 
-	0xAC, 0xBB, 0xFF, 0x25, 0x4C, 0xC4, 0xD1, 0x79, 0xF4, 0x71, 
-	0xD3, 0x86, 0x40, 0x18, 0x13, 0xB0, 0x63, 0xB5, 0x72, 0x4E, 
-	0x30, 0xC4, 0x97, 0x84, 0x86, 0x2D, 0x56, 0x2F, 0xD7, 0x15, 
-	0xF7, 0x7F, 0xC0, 0xAE, 0xF5, 0xFC, 0x5B, 0xE5, 0xFB, 0xA1, 
-	0xBA, 0xD3, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x82, 0x01, 
-	0x07, 0x30, 0x82, 0x01, 0x03, 0x30, 0x1D, 0x06, 0x03, 0x55, 
-	0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14, 0x33, 0xD8, 0x45, 0x66, 
-	0xD7, 0x68, 0x87, 0x18, 0x7E, 0x54, 0x0D, 0x70, 0x27, 0x91, 
-	0xC7, 0x26, 0xD7, 0x85, 0x65, 0xC0, 0x30, 0x81, 0xD3, 0x06, 
-	0x03, 0x55, 0x1D, 0x23, 0x04, 0x81, 0xCB, 0x30, 0x81, 0xC8, 
-	0x80, 0x14, 0x33, 0xD8, 0x45, 0x66, 0xD7, 0x68, 0x87, 0x18, 
-	0x7E, 0x54, 0x0D, 0x70, 0x27, 0x91, 0xC7, 0x26, 0xD7, 0x85, 
-	0x65, 0xC0, 0xA1, 0x81, 0xA4, 0xA4, 0x81, 0xA1, 0x30, 0x81, 
-	0x9E, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 
-	0x13, 0x02, 0x55, 0x53, 0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 
-	0x55, 0x04, 0x08, 0x0C, 0x07, 0x4D, 0x6F, 0x6E, 0x74, 0x61, 
-	0x6E, 0x61, 0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 
-	0x07, 0x0C, 0x07, 0x42, 0x6F, 0x7A, 0x65, 0x6D, 0x61, 0x6E, 
-	0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 
-	0x0C, 0x77, 0x6F, 0x6C, 0x66, 0x53, 0x53, 0x4C, 0x5F, 0x32, 
-	0x30, 0x34, 0x38, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 
-	0x04, 0x0B, 0x0C, 0x10, 0x50, 0x72, 0x6F, 0x67, 0x72, 0x61, 
-	0x6D, 0x6D, 0x69, 0x6E, 0x67, 0x2D, 0x32, 0x30, 0x34, 0x38, 
-	0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 
-	0x0F, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x6F, 0x6C, 0x66, 0x73, 
-	0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x31, 0x1F, 0x30, 0x1D, 
-	0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 
-	0x01, 0x16, 0x10, 0x69, 0x6E, 0x66, 0x6F, 0x40, 0x77, 0x6F, 
-	0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 
-	0x09, 0x00, 0xAA, 0x27, 0xB3, 0xC5, 0xA9, 0x72, 0x6E, 0x0D, 
-	0x30, 0x0C, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x04, 0x05, 0x30, 
-	0x03, 0x01, 0x01, 0xFF, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 
-	0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x03, 
-	0x82, 0x01, 0x01, 0x00, 0x51, 0x96, 0xA7, 0x1C, 0x26, 0x5D, 
-	0x1C, 0x90, 0xC6, 0x32, 0x9F, 0x96, 0x15, 0xF2, 0x1D, 0xE7, 
-	0x93, 0x9C, 0xAC, 0x75, 0x56, 0x95, 0xFD, 0x20, 0x70, 0xAB, 
-	0x45, 0x6A, 0x09, 0xB0, 0xF3, 0xF2, 0x03, 0xA8, 0xDB, 0xDC, 
-	0x2F, 0xBC, 0x1F, 0x87, 0x7A, 0xA3, 0xD4, 0x8F, 0xD5, 0x49, 
-	0x97, 0x7E, 0x3C, 0x54, 0xAC, 0xB1, 0xE3, 0xF0, 0x39, 0x0D, 
-	0xFE, 0x09, 0x9A, 0x23, 0xF6, 0x32, 0xA6, 0x41, 0x59, 0xBD, 
-	0x60, 0xE8, 0xBD, 0xDE, 0x00, 0x36, 0x6F, 0x3E, 0xE9, 0x41, 
-	0x6F, 0xA9, 0x63, 0xC7, 0xAA, 0xD5, 0x7B, 0xF3, 0xE4, 0x39, 
-	0x48, 0x9E, 0xF6, 0x60, 0xC6, 0xC6, 0x86, 0xD5, 0x72, 0x86, 
-	0x23, 0xCD, 0xF5, 0x6A, 0x63, 0x53, 0xA4, 0xF8, 0xFC, 0x51, 
-	0x6A, 0xCD, 0x60, 0x74, 0x8E, 0xA3, 0x86, 0x61, 0x01, 0x34, 
-	0x78, 0xF7, 0x29, 0x97, 0xB3, 0xA7, 0x34, 0xB6, 0x0A, 0xDE, 
-	0xB5, 0x71, 0x7A, 0x09, 0xA6, 0x3E, 0xD6, 0x82, 0x58, 0x89, 
-	0x67, 0x9C, 0xC5, 0x68, 0x62, 0xBA, 0x06, 0xD6, 0x39, 0xBB, 
-	0xCB, 0x3A, 0xC0, 0xE0, 0x63, 0x1F, 0xC7, 0x0C, 0x9C, 0x12, 
-	0x86, 0xEC, 0xF7, 0x39, 0x6A, 0x61, 0x93, 0xD0, 0x33, 0x14, 
-	0xC6, 0x55, 0x3B, 0xB6, 0xCF, 0x80, 0x5B, 0x8C, 0x43, 0xEF, 
-	0x43, 0x44, 0x0B, 0x3C, 0x93, 0x39, 0xA3, 0x4E, 0x15, 0xD1, 
-	0x0B, 0x5F, 0x84, 0x98, 0x1D, 0xCD, 0x9F, 0xA9, 0x47, 0xEB, 
-	0x3B, 0x56, 0x30, 0xB6, 0x76, 0x92, 0xC1, 0x48, 0x5F, 0xBC, 
-	0x95, 0xB0, 0x50, 0x1A, 0x55, 0xC8, 0x4E, 0x62, 0x47, 0x87, 
-	0x54, 0x64, 0x0C, 0x9B, 0x91, 0xFA, 0x43, 0xB3, 0x29, 0x48, 
-	0xBE, 0xE6, 0x12, 0xEB, 0xE3, 0x44, 0xC6, 0x52, 0xE4, 0x40, 
-	0xC6, 0x83, 0x95, 0x1B, 0xA7, 0x65, 0x27, 0x69, 0x73, 0x2F, 
-	0xC8, 0xA0, 0x4D, 0x7F, 0xBE, 0xEA, 0x9B, 0x67, 0xB2, 0x7B
-
-};
-static const int sizeof_client_cert_der_2048 = sizeof(client_cert_der_2048);
-
-/* ./certs/dh2048.der, 2048-bit */
-static const unsigned char dh_key_der_2048[] =
-{
-	0x30, 0x82, 0x01, 0x08, 0x02, 0x82, 0x01, 0x01, 0x00, 0xB0, 
-	0xA1, 0x08, 0x06, 0x9C, 0x08, 0x13, 0xBA, 0x59, 0x06, 0x3C, 
-	0xBC, 0x30, 0xD5, 0xF5, 0x00, 0xC1, 0x4F, 0x44, 0xA7, 0xD6, 
-	0xEF, 0x4A, 0xC6, 0x25, 0x27, 0x1C, 0xE8, 0xD2, 0x96, 0x53, 
-	0x0A, 0x5C, 0x91, 0xDD, 0xA2, 0xC2, 0x94, 0x84, 0xBF, 0x7D, 
-	0xB2, 0x44, 0x9F, 0x9B, 0xD2, 0xC1, 0x8A, 0xC5, 0xBE, 0x72, 
-	0x5C, 0xA7, 0xE7, 0x91, 0xE6, 0xD4, 0x9F, 0x73, 0x07, 0x85, 
-	0x5B, 0x66, 0x48, 0xC7, 0x70, 0xFA, 0xB4, 0xEE, 0x02, 0xC9, 
-	0x3D, 0x9A, 0x4A, 0xDA, 0x3D, 0xC1, 0x46, 0x3E, 0x19, 0x69, 
-	0xD1, 0x17, 0x46, 0x07, 0xA3, 0x4D, 0x9F, 0x2B, 0x96, 0x17, 
-	0x39, 0x6D, 0x30, 0x8D, 0x2A, 0xF3, 0x94, 0xD3, 0x75, 0xCF, 
-	0xA0, 0x75, 0xE6, 0xF2, 0x92, 0x1F, 0x1A, 0x70, 0x05, 0xAA, 
-	0x04, 0x83, 0x57, 0x30, 0xFB, 0xDA, 0x76, 0x93, 0x38, 0x50, 
-	0xE8, 0x27, 0xFD, 0x63, 0xEE, 0x3C, 0xE5, 0xB7, 0xC8, 0x09, 
-	0xAE, 0x6F, 0x50, 0x35, 0x8E, 0x84, 0xCE, 0x4A, 0x00, 0xE9, 
-	0x12, 0x7E, 0x5A, 0x31, 0xD7, 0x33, 0xFC, 0x21, 0x13, 0x76, 
-	0xCC, 0x16, 0x30, 0xDB, 0x0C, 0xFC, 0xC5, 0x62, 0xA7, 0x35, 
-	0xB8, 0xEF, 0xB7, 0xB0, 0xAC, 0xC0, 0x36, 0xF6, 0xD9, 0xC9, 
-	0x46, 0x48, 0xF9, 0x40, 0x90, 0x00, 0x2B, 0x1B, 0xAA, 0x6C, 
-	0xE3, 0x1A, 0xC3, 0x0B, 0x03, 0x9E, 0x1B, 0xC2, 0x46, 0xE4, 
-	0x48, 0x4E, 0x22, 0x73, 0x6F, 0xC3, 0x5F, 0xD4, 0x9A, 0xD6, 
-	0x30, 0x07, 0x48, 0xD6, 0x8C, 0x90, 0xAB, 0xD4, 0xF6, 0xF1, 
-	0xE3, 0x48, 0xD3, 0x58, 0x4B, 0xA6, 0xB9, 0xCD, 0x29, 0xBF, 
-	0x68, 0x1F, 0x08, 0x4B, 0x63, 0x86, 0x2F, 0x5C, 0x6B, 0xD6, 
-	0xB6, 0x06, 0x65, 0xF7, 0xA6, 0xDC, 0x00, 0x67, 0x6B, 0xBB, 
-	0xC3, 0xA9, 0x41, 0x83, 0xFB, 0xC7, 0xFA, 0xC8, 0xE2, 0x1E, 
-	0x7E, 0xAF, 0x00, 0x3F, 0x93, 0x02, 0x01, 0x02
-};
-static const int sizeof_dh_key_der_2048 = sizeof(dh_key_der_2048);
-
-/* ./certs/dsa2048.der, 2048-bit */
-static const unsigned char dsa_key_der_2048[] =
-{
-	0x30, 0x82, 0x03, 0x3F, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 
-	0x01, 0x00, 0xCC, 0x8E, 0xC9, 0xA0, 0xD5, 0x9A, 0x27, 0x1C, 
-	0xDA, 0x52, 0xDF, 0xC7, 0xC0, 0xE6, 0x06, 0xA4, 0x3E, 0x8A, 
-	0x66, 0x49, 0xD0, 0x59, 0x33, 0x51, 0x69, 0xC4, 0x9C, 0x5E, 
-	0x64, 0x85, 0xC7, 0xF1, 0xAB, 0xD5, 0xD9, 0x62, 0xAC, 0xFD, 
-	0xA1, 0xE0, 0x1B, 0x57, 0xFF, 0x96, 0xEF, 0x0C, 0x9F, 0xC8, 
-	0x44, 0x87, 0xEB, 0x5C, 0x91, 0xD0, 0x46, 0x42, 0x09, 0x50, 
-	0x6A, 0x23, 0xCB, 0x89, 0x6F, 0x55, 0xE9, 0x6A, 0x11, 0xA9, 
-	0xA8, 0x32, 0xAB, 0x33, 0x0D, 0x51, 0xB5, 0x79, 0x51, 0xB4, 
-	0xAB, 0xA2, 0x25, 0x11, 0x8D, 0xE5, 0x24, 0xBE, 0xD8, 0xF1, 
-	0x9D, 0x4E, 0x12, 0x6F, 0xAC, 0x44, 0x54, 0x80, 0xA9, 0xB4, 
-	0x81, 0x68, 0x4E, 0x44, 0x0E, 0xB8, 0x39, 0xF3, 0xBE, 0x83, 
-	0x08, 0x74, 0xA2, 0xC6, 0x7A, 0xD7, 0x6A, 0x7D, 0x0A, 0x88, 
-	0x57, 0x83, 0x48, 0xDC, 0xCF, 0x5E, 0x6F, 0xEE, 0x68, 0x0C, 
-	0xF7, 0xFF, 0x03, 0x04, 0x90, 0xAA, 0xF7, 0x07, 0x98, 0xF8, 
-	0x67, 0x5A, 0x83, 0x23, 0x66, 0x47, 0x60, 0xC3, 0x43, 0x6E, 
-	0x03, 0x91, 0xAC, 0x28, 0x66, 0xCB, 0xF0, 0xD3, 0x05, 0xC8, 
-	0x09, 0x97, 0xB5, 0xAE, 0x01, 0x5E, 0x80, 0x3B, 0x9D, 0x4F, 
-	0xDE, 0x3E, 0x94, 0xFE, 0xCB, 0x82, 0xB0, 0xB1, 0xFC, 0x91, 
-	0x8B, 0x1D, 0x8A, 0xEE, 0xC6, 0x06, 0x1F, 0x37, 0x91, 0x48, 
-	0xD2, 0xF8, 0x6C, 0x5D, 0x60, 0x13, 0x83, 0xA7, 0x81, 0xAC, 
-	0xCA, 0x8D, 0xD0, 0x6A, 0x04, 0x0A, 0xEA, 0x3E, 0x22, 0x4E, 
-	0x13, 0xF1, 0x0D, 0xBB, 0x60, 0x6B, 0xCD, 0xBC, 0x5C, 0x87, 
-	0xA3, 0x67, 0x2B, 0x42, 0xA1, 0x9F, 0xCD, 0x39, 0x58, 0xBE, 
-	0x55, 0xB1, 0x93, 0x84, 0xCE, 0xB2, 0x10, 0x4E, 0xE4, 0xC3, 
-	0x9F, 0xB2, 0x53, 0x61, 0x01, 0x29, 0xAA, 0x96, 0xCB, 0x20, 
-	0x60, 0x42, 0x1D, 0xBA, 0x75, 0x4B, 0x63, 0xC1, 0x02, 0x15, 
-	0x00, 0xE7, 0xA5, 0x39, 0xD4, 0x6A, 0x37, 0x5E, 0x95, 0x06, 
-	0x39, 0x07, 0x77, 0x0A, 0xEB, 0xA0, 0x03, 0xEB, 0x78, 0x82, 
-	0x9B, 0x02, 0x82, 0x01, 0x01, 0x00, 0x9A, 0xD4, 0x4C, 0x71, 
-	0x2F, 0xEC, 0xFA, 0x32, 0xB2, 0x80, 0x7E, 0x61, 0x4A, 0x6B, 
-	0x5F, 0x18, 0x76, 0x43, 0xC3, 0x69, 0xBA, 0x41, 0xC7, 0xA7, 
-	0x1D, 0x79, 0x01, 0xEC, 0xAF, 0x34, 0x87, 0x67, 0x4F, 0x29, 
-	0x80, 0xA8, 0x3B, 0x87, 0xF6, 0xE8, 0xA1, 0xE8, 0xCD, 0x1B, 
-	0x1C, 0x86, 0x38, 0xF6, 0xD1, 0x0C, 0x46, 0x2E, 0xC8, 0xE0, 
-	0xC9, 0x30, 0x26, 0xD5, 0x2C, 0x7F, 0xC1, 0x08, 0xBF, 0xCC, 
-	0x5A, 0x82, 0x8E, 0xD4, 0xD4, 0x49, 0xAA, 0xA2, 0xFA, 0xE6, 
-	0xC1, 0x9D, 0xF0, 0xD9, 0x96, 0xB0, 0xFF, 0x0C, 0x5B, 0x33, 
-	0x8E, 0x06, 0xDD, 0x9D, 0x28, 0xA9, 0xE9, 0x80, 0x41, 0x3B, 
-	0xD8, 0x7A, 0x94, 0x21, 0x8F, 0x56, 0xF1, 0xA2, 0xB4, 0x2B, 
-	0x89, 0x1C, 0x74, 0xFF, 0x7E, 0x91, 0xDC, 0x1F, 0x91, 0x13, 
-	0x98, 0xAF, 0xC7, 0x06, 0xD2, 0x4C, 0x90, 0xA2, 0xBD, 0xDA, 
-	0x16, 0xBA, 0x65, 0xB0, 0x2D, 0x68, 0x87, 0x3C, 0x6E, 0x25, 
-	0x8D, 0x90, 0xC7, 0xBC, 0x0D, 0xA9, 0x43, 0x03, 0xC9, 0xBE, 
-	0xCF, 0x85, 0x6F, 0xDB, 0x07, 0x7B, 0x8C, 0xF8, 0xB1, 0xC2, 
-	0x49, 0x10, 0x69, 0x63, 0x56, 0x37, 0xC5, 0x30, 0xD2, 0xFB, 
-	0x71, 0x9A, 0xE8, 0x82, 0x07, 0x2E, 0x3E, 0x95, 0x50, 0xF3, 
-	0x73, 0xCF, 0x34, 0x5B, 0xD5, 0xAB, 0x02, 0x15, 0xF2, 0xCC, 
-	0xD7, 0x52, 0xC5, 0x28, 0xD8, 0x41, 0x19, 0x55, 0x6F, 0xB8, 
-	0x5F, 0xF1, 0x99, 0xB3, 0xC7, 0xD9, 0xB3, 0x71, 0xF4, 0x2D, 
-	0xDF, 0x22, 0x59, 0x35, 0x86, 0xDB, 0x39, 0xCA, 0x1B, 0x4D, 
-	0x35, 0x90, 0x19, 0x6B, 0x31, 0xE3, 0xC8, 0xC6, 0x09, 0xBF, 
-	0x7C, 0xED, 0x01, 0xB4, 0xB2, 0xF5, 0x6E, 0xDA, 0x63, 0x41, 
-	0x3C, 0xE6, 0x3A, 0x72, 0x2D, 0x65, 0x48, 0xF6, 0x07, 0xCD, 
-	0x92, 0x84, 0x8B, 0x1D, 0xA7, 0x31, 0x6B, 0xD6, 0xF0, 0xFB, 
-	0xD9, 0xF4, 0x02, 0x82, 0x01, 0x00, 0x66, 0x4B, 0xBB, 0xB7, 
-	0xC9, 0x48, 0x95, 0x0D, 0x5A, 0xA6, 0x2D, 0xA1, 0x7F, 0xDF, 
-	0x1F, 0x67, 0x6D, 0xED, 0x52, 0x4B, 0x16, 0x6C, 0x17, 0xC6, 
-	0xAE, 0xF8, 0x6A, 0xC4, 0x57, 0xED, 0x2F, 0xB3, 0xF0, 0x2A, 
-	0x55, 0xAB, 0xBA, 0xCA, 0xEA, 0x17, 0xE8, 0x35, 0x7C, 0xE5, 
-	0x31, 0x0D, 0x4A, 0x95, 0xFC, 0x43, 0x6F, 0x97, 0x3C, 0x5C, 
-	0x67, 0xAC, 0xBE, 0x67, 0x7F, 0xE9, 0x4E, 0xAA, 0x48, 0xB3, 
-	0x92, 0xA1, 0x76, 0x75, 0xEA, 0x04, 0x34, 0x7F, 0x87, 0x33, 
-	0x2D, 0x24, 0xB6, 0x29, 0x97, 0xE3, 0x04, 0x77, 0x93, 0x89, 
-	0x13, 0xDB, 0x1B, 0x93, 0xB8, 0x2C, 0x90, 0x1A, 0x09, 0x3B, 
-	0x26, 0xD9, 0x59, 0xF3, 0x2A, 0x09, 0x58, 0xDC, 0xAC, 0x25, 
-	0xB4, 0xA9, 0x45, 0x3B, 0xA2, 0x3A, 0x6C, 0x61, 0x84, 0xBF, 
-	0x68, 0xD4, 0xEA, 0x9B, 0xC5, 0x29, 0x48, 0x60, 0x15, 0x10, 
-	0x35, 0x2C, 0x44, 0x1D, 0xB5, 0x9A, 0xEE, 0xAC, 0xC1, 0x68, 
-	0xE8, 0x47, 0xB7, 0x41, 0x34, 0x39, 0x9A, 0xF8, 0xA5, 0x20, 
-	0xE9, 0x24, 0xC4, 0x2C, 0x58, 0x3F, 0x4C, 0x41, 0x30, 0x3A, 
-	0x14, 0x6E, 0x8D, 0xEA, 0xAD, 0xBA, 0x9B, 0x43, 0xD3, 0x98, 
-	0x2F, 0x83, 0xD8, 0x14, 0x67, 0xE8, 0xF8, 0xD5, 0x4F, 0xAC, 
-	0xE0, 0x3B, 0xBF, 0xA7, 0x54, 0x16, 0x5E, 0x49, 0x64, 0x26, 
-	0x54, 0xA4, 0x6B, 0x69, 0x7C, 0xBA, 0x8A, 0x83, 0xD9, 0x2E, 
-	0x65, 0x0A, 0xA2, 0x27, 0xEF, 0x99, 0x99, 0x08, 0xD7, 0xB5, 
-	0x9F, 0xA0, 0x01, 0xEF, 0x7E, 0x17, 0xBF, 0x83, 0x6B, 0x2E, 
-	0xDD, 0xC0, 0x39, 0x38, 0x23, 0x68, 0xB4, 0x76, 0x6B, 0xE5, 
-	0xCA, 0xF7, 0x7C, 0xEE, 0xC0, 0x52, 0xE2, 0xDD, 0xAD, 0x59, 
-	0x3A, 0x42, 0x06, 0x45, 0xB0, 0xC7, 0xC1, 0x77, 0x05, 0xB2, 
-	0x0C, 0x32, 0x40, 0x46, 0xAA, 0xDA, 0x79, 0x77, 0x04, 0x71, 
-	0xDF, 0x7A, 0x02, 0x15, 0x00, 0x98, 0xEE, 0xB9, 0x51, 0x37, 
-	0x3E, 0x75, 0x13, 0x13, 0x06, 0x8F, 0x94, 0xD3, 0xE6, 0xE9, 
-	0x00, 0xCB, 0x62, 0x6D, 0x9A
-};
-static const int sizeof_dsa_key_der_2048 = sizeof(dsa_key_der_2048);
-
-/* ./certs/rsa2048.der, 2048-bit */
-static const unsigned char rsa_key_der_2048[] =
-{
-	0x30, 0x82, 0x04, 0xA3, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 
-	0x01, 0x00, 0xE9, 0x8A, 0x5D, 0x15, 0xA4, 0xD4, 0x34, 0xB9, 
-	0x59, 0xA2, 0xDA, 0xAF, 0x74, 0xC8, 0xC9, 0x03, 0x26, 0x38, 
-	0xFA, 0x48, 0xFC, 0x4D, 0x30, 0x6E, 0xEA, 0x76, 0x89, 0xCE, 
-	0x4F, 0xF6, 0x87, 0xDE, 0x32, 0x3A, 0x46, 0x6E, 0x38, 0x12, 
-	0x58, 0x37, 0x22, 0x0D, 0x80, 0xAC, 0x2D, 0xAF, 0x2F, 0x12, 
-	0x3E, 0x62, 0x73, 0x60, 0x66, 0x68, 0x90, 0xB2, 0x6F, 0x47, 
-	0x17, 0x04, 0x2B, 0xCA, 0xB7, 0x26, 0xB7, 0x10, 0xC2, 0x13, 
-	0xF9, 0x7A, 0x62, 0x0A, 0x93, 0x32, 0x90, 0x42, 0x0D, 0x16, 
-	0x2E, 0xFA, 0xD7, 0x29, 0xD7, 0x9F, 0x54, 0xE4, 0xFC, 0x65, 
-	0x74, 0xF8, 0xF6, 0x43, 0x6B, 0x4E, 0x9E, 0x34, 0x7F, 0xCB, 
-	0x6B, 0x1C, 0x1A, 0xDE, 0x82, 0x81, 0xBF, 0x08, 0x5D, 0x3F, 
-	0xC0, 0xB6, 0xB1, 0xA8, 0xA5, 0x9C, 0x81, 0x70, 0xA7, 0x4E, 
-	0x32, 0x87, 0x15, 0x1C, 0x78, 0x0E, 0xF0, 0x18, 0xFE, 0xEB, 
-	0x4B, 0x37, 0x2B, 0xE9, 0xE1, 0xF7, 0xFA, 0x51, 0xC6, 0x58, 
-	0xB9, 0xD8, 0x06, 0x03, 0xED, 0xC0, 0x03, 0x18, 0x55, 0x8B, 
-	0x98, 0xFE, 0xB1, 0xF6, 0xD0, 0x3D, 0xFA, 0x63, 0xC0, 0x38, 
-	0x19, 0xC7, 0x00, 0xEF, 0x4D, 0x99, 0x60, 0xB4, 0xBA, 0xCE, 
-	0xE3, 0xCE, 0xD9, 0x6B, 0x2D, 0x76, 0x94, 0xFF, 0xFB, 0x77, 
-	0x18, 0x4A, 0xFE, 0x65, 0xF0, 0x0A, 0x91, 0x5C, 0x3B, 0x22, 
-	0x94, 0x85, 0xD0, 0x20, 0x18, 0x59, 0x2E, 0xA5, 0x33, 0x03, 
-	0xAC, 0x1B, 0x5F, 0x78, 0x32, 0x11, 0x25, 0xEE, 0x7F, 0x96, 
-	0x21, 0xA9, 0xD6, 0x76, 0x97, 0x8D, 0x66, 0x7E, 0xB2, 0x91, 
-	0xD0, 0x36, 0x2E, 0xA3, 0x1D, 0xBF, 0xF1, 0x85, 0xED, 0xC0, 
-	0x3E, 0x60, 0xB8, 0x5A, 0x9F, 0xAB, 0x80, 0xE0, 0xEA, 0x5D, 
-	0x5F, 0x75, 0x56, 0xC7, 0x4D, 0x51, 0x8E, 0xD4, 0x1F, 0x34, 
-	0xA6, 0x36, 0xF1, 0x30, 0x1F, 0x51, 0x99, 0x2F, 0x02, 0x03, 
-	0x01, 0x00, 0x01, 0x02, 0x82, 0x01, 0x00, 0x52, 0x11, 0x33, 
-	0x40, 0xC5, 0xD9, 0x64, 0x65, 0xB5, 0xE0, 0x0A, 0xA5, 0x19, 
-	0x8E, 0xED, 0x44, 0x54, 0x0C, 0x35, 0xB7, 0xAC, 0x21, 0x9B, 
-	0xE1, 0x7E, 0x37, 0x05, 0x9A, 0x20, 0x73, 0x6B, 0xAF, 0x63, 
-	0x4B, 0x23, 0x30, 0xDC, 0x37, 0x66, 0x14, 0x89, 0xBC, 0xE0, 
-	0xF8, 0xA0, 0x5D, 0x2D, 0x57, 0x65, 0xE0, 0xC6, 0xD6, 0x9B, 
-	0x66, 0x27, 0x62, 0xEC, 0xC3, 0xB8, 0x8C, 0xD8, 0xAE, 0xB5, 
-	0xC9, 0xBF, 0x0E, 0xFE, 0x84, 0x72, 0x68, 0xD5, 0x47, 0x0E, 
-	0x0E, 0xF8, 0xAE, 0x9D, 0x56, 0xAC, 0x4F, 0xAD, 0x88, 0xA0, 
-	0xA2, 0xF6, 0xFC, 0x38, 0xCD, 0x96, 0x5B, 0x5E, 0x7E, 0xB6, 
-	0x98, 0xBB, 0xF3, 0x8A, 0xEC, 0xFA, 0xC8, 0xB7, 0x90, 0x75, 
-	0xA0, 0x0E, 0x77, 0x6B, 0xFD, 0x59, 0x45, 0x5A, 0x0C, 0xFF, 
-	0x95, 0x8D, 0xCE, 0xFE, 0x9B, 0xF6, 0x19, 0x8E, 0x0B, 0xA1, 
-	0x0C, 0xEE, 0xC6, 0x79, 0xDD, 0x9D, 0x61, 0x85, 0x5C, 0x19, 
-	0x6C, 0x47, 0xCC, 0x08, 0xFF, 0xA5, 0x62, 0xDB, 0xE4, 0x2D, 
-	0x2D, 0xDD, 0x14, 0x67, 0xD6, 0x4A, 0x64, 0x2A, 0x66, 0x49, 
-	0x54, 0x9C, 0xE3, 0x85, 0x18, 0xE7, 0x31, 0x42, 0xE2, 0xD0, 
-	0x2C, 0x20, 0xA0, 0x74, 0x0F, 0x1F, 0x20, 0x89, 0xBA, 0xAB, 
-	0x80, 0xD8, 0x38, 0xD9, 0x46, 0x69, 0xBB, 0xEF, 0xCC, 0x8B, 
-	0xA1, 0x73, 0xA7, 0xF2, 0xE4, 0x38, 0x5D, 0xD6, 0x75, 0x9F, 
-	0x88, 0x0E, 0x56, 0xCD, 0xD8, 0x84, 0x59, 0x29, 0x73, 0xF5, 
-	0xA1, 0x79, 0xDA, 0x7A, 0x1F, 0xBF, 0x73, 0x83, 0xC0, 0x6D, 
-	0x9F, 0x8B, 0x34, 0x15, 0xC0, 0x6D, 0x69, 0x6A, 0x20, 0xE6, 
-	0x51, 0xCF, 0x45, 0x6E, 0xCC, 0x05, 0xC4, 0x3A, 0xC0, 0x9E, 
-	0xAA, 0xC1, 0x06, 0x2F, 0xAB, 0x99, 0x30, 0xE1, 0x6E, 0x9D, 
-	0x45, 0x7A, 0xFF, 0xA9, 0xCE, 0x70, 0xB8, 0x16, 0x1A, 0x0E, 
-	0x20, 0xFA, 0xC1, 0x02, 0x81, 0x81, 0x00, 0xFF, 0x30, 0x11, 
-	0xC2, 0x3C, 0x6B, 0xB4, 0xD6, 0x9E, 0x6B, 0xC1, 0x93, 0xD1, 
-	0x48, 0xCE, 0x80, 0x2D, 0xBE, 0xAF, 0xF7, 0xBA, 0xB2, 0xD7, 
-	0xC3, 0xC4, 0x53, 0x6E, 0x15, 0x02, 0xAA, 0x61, 0xB9, 0xEA, 
-	0x05, 0x9B, 0x79, 0x67, 0x0B, 0xCE, 0xD9, 0xFB, 0x98, 0x8C, 
-	0x1D, 0x6B, 0xF4, 0x5A, 0xA7, 0xA0, 0x5E, 0x54, 0x18, 0xE9, 
-	0x31, 0x44, 0x7C, 0xC7, 0x52, 0xD8, 0x6D, 0xA0, 0x3E, 0xD6, 
-	0x14, 0x2D, 0x7B, 0x15, 0x9D, 0x1E, 0x39, 0x87, 0x96, 0xDD, 
-	0xA8, 0x33, 0x55, 0x2A, 0x8E, 0x32, 0xC0, 0xC4, 0xE5, 0xB8, 
-	0xCB, 0xCD, 0x32, 0x8D, 0xAD, 0x7B, 0xE5, 0xC6, 0x7E, 0x4D, 
-	0x6F, 0xF3, 0xA4, 0xC5, 0xA6, 0x40, 0xBE, 0x90, 0x3A, 0x33, 
-	0x6A, 0x24, 0xB2, 0x80, 0x81, 0x12, 0xAC, 0xE3, 0x7B, 0x26, 
-	0x63, 0xCF, 0x88, 0xB9, 0xFF, 0x74, 0x23, 0x37, 0x52, 0xF0, 
-	0xC4, 0x27, 0x5D, 0x45, 0x1F, 0x02, 0x81, 0x81, 0x00, 0xEA, 
-	0x48, 0xA7, 0xDD, 0x73, 0x41, 0x56, 0x21, 0x15, 0xF7, 0x42, 
-	0x45, 0x4D, 0xA9, 0xE1, 0x66, 0x5B, 0xBD, 0x25, 0x7D, 0xF7, 
-	0xA8, 0x65, 0x13, 0xAE, 0x2D, 0x38, 0x11, 0xCD, 0x93, 0xFC, 
-	0x30, 0xA3, 0x2C, 0x44, 0xBB, 0xCF, 0xD0, 0x21, 0x8F, 0xFB, 
-	0xC1, 0xF9, 0xAD, 0x1D, 0xEE, 0x96, 0xCF, 0x97, 0x49, 0x60, 
-	0x53, 0x80, 0xA5, 0xA2, 0xF8, 0xEE, 0xB9, 0xD5, 0x77, 0x44, 
-	0xDD, 0xFD, 0x19, 0x2A, 0xF1, 0x81, 0xF4, 0xD9, 0x3C, 0xEC, 
-	0x73, 0xD0, 0x2A, 0xD8, 0x3C, 0x27, 0x87, 0x79, 0x12, 0x86, 
-	0xE7, 0x57, 0x0C, 0x59, 0xD1, 0x44, 0x55, 0xAE, 0xC3, 0x4D, 
-	0x42, 0xAD, 0xA9, 0xB3, 0x28, 0x61, 0xB4, 0x9C, 0xA6, 0x63, 
-	0xD3, 0x96, 0xB1, 0x75, 0x9F, 0x2A, 0x78, 0x99, 0xE3, 0x1E, 
-	0x71, 0x47, 0x39, 0xF4, 0x52, 0xE3, 0x66, 0xF1, 0xEB, 0x7F, 
-	0xEF, 0xC6, 0x81, 0x93, 0x4C, 0x99, 0xF1, 0x02, 0x81, 0x81, 
-	0x00, 0xC5, 0xB6, 0x20, 0x8C, 0x34, 0xF3, 0xDD, 0xF0, 0x4A, 
-	0x5D, 0x82, 0x65, 0x5C, 0x48, 0xE4, 0x75, 0x3A, 0xFB, 0xFA, 
-	0xAA, 0x1C, 0xE4, 0x63, 0x77, 0x31, 0xAC, 0xD2, 0x25, 0x45, 
-	0x23, 0x6D, 0x03, 0xF5, 0xE4, 0xD2, 0x48, 0x85, 0x26, 0x08, 
-	0xE5, 0xAA, 0xA0, 0xCE, 0x2E, 0x1D, 0x6D, 0xFC, 0xAE, 0xD2, 
-	0xF9, 0x42, 0x7E, 0xEA, 0x6D, 0x59, 0x7A, 0xB3, 0x93, 0xE4, 
-	0x4B, 0x4B, 0x54, 0x63, 0xD8, 0xCE, 0x44, 0x06, 0xC2, 0xEC, 
-	0x9F, 0xF6, 0x05, 0x55, 0x46, 0xF4, 0x3E, 0x8F, 0xF2, 0x0C, 
-	0x30, 0x7E, 0x5C, 0xDD, 0x88, 0x49, 0x3B, 0x59, 0xB9, 0x87, 
-	0xBC, 0xC6, 0xC5, 0x24, 0x8A, 0x10, 0x63, 0x21, 0x1F, 0x66, 
-	0x1A, 0x3E, 0xF4, 0x58, 0xD1, 0x6C, 0x0D, 0x40, 0xB2, 0xC0, 
-	0x1D, 0x63, 0x42, 0x0E, 0xC4, 0x56, 0x0E, 0xC0, 0xCC, 0xC2, 
-	0xD6, 0x66, 0x0E, 0xC4, 0xAB, 0xB5, 0x33, 0xF6, 0x51, 0x02, 
-	0x81, 0x80, 0x19, 0x7E, 0xE6, 0xA5, 0xB6, 0xD1, 0x39, 0x6A, 
-	0x48, 0x55, 0xAC, 0x24, 0x96, 0x9B, 0x12, 0x28, 0x6D, 0x7B, 
-	0x5C, 0x05, 0x25, 0x5A, 0x72, 0x05, 0x7E, 0x42, 0xF5, 0x83, 
-	0x1A, 0x78, 0x2C, 0x4D, 0xAE, 0xB4, 0x36, 0x96, 0xA9, 0xBA, 
-	0xE0, 0xAC, 0x26, 0x9D, 0xA9, 0x6A, 0x29, 0x83, 0xB9, 0x6D, 
-	0xC5, 0xEC, 0xFA, 0x4A, 0x9C, 0x09, 0x6A, 0x7E, 0xE4, 0x9B, 
-	0xDC, 0x9B, 0x2A, 0x27, 0x6E, 0x4F, 0xBA, 0xD8, 0xA5, 0x67, 
-	0xDB, 0xEC, 0x41, 0x5F, 0x29, 0x1C, 0x40, 0x83, 0xEB, 0x59, 
-	0x56, 0xD7, 0xA9, 0x4E, 0xAB, 0xAE, 0x70, 0x67, 0xD1, 0xA3, 
-	0xF1, 0x6C, 0xD7, 0x8F, 0x96, 0x0E, 0x8D, 0xAC, 0xAB, 0x55, 
-	0x58, 0x66, 0xD3, 0x1E, 0x47, 0x9B, 0xF0, 0x4C, 0xED, 0xF6, 
-	0x49, 0xE8, 0xE9, 0x7B, 0x32, 0x61, 0x20, 0x31, 0x95, 0x05, 
-	0xB2, 0xF6, 0x09, 0xEA, 0x32, 0x14, 0x0F, 0xCF, 0x9A, 0x41, 
-	0x02, 0x81, 0x80, 0x77, 0x3F, 0xB6, 0x14, 0x8D, 0xC5, 0x13, 
-	0x08, 0x7E, 0xC9, 0xC4, 0xEA, 0xD4, 0xBA, 0x0D, 0xA4, 0x9E, 
-	0xB3, 0x6E, 0xDE, 0x1A, 0x7A, 0xF8, 0x89, 0x88, 0xEF, 0x36, 
-	0x3C, 0x11, 0xBC, 0x83, 0xE8, 0x30, 0x6C, 0x81, 0x7C, 0x47, 
-	0xF3, 0x4D, 0xCA, 0xEA, 0x56, 0x01, 0x62, 0x55, 0x2E, 0x4B, 
-	0x89, 0xA9, 0xBD, 0x6F, 0x01, 0xF6, 0x74, 0x02, 0xAA, 0xE3, 
-	0x84, 0x66, 0x06, 0x95, 0x34, 0xA1, 0xE2, 0xCA, 0x65, 0xFE, 
-	0xA3, 0x2D, 0x43, 0x97, 0x95, 0x6C, 0x6F, 0xD5, 0xB4, 0x38, 
-	0xF6, 0xF9, 0x95, 0x30, 0xFA, 0xF8, 0x9C, 0x25, 0x2B, 0xB6, 
-	0x14, 0x51, 0xCC, 0x2E, 0xB3, 0x5B, 0xD6, 0xDC, 0x1A, 0xEC, 
-	0x2D, 0x09, 0x5B, 0x3F, 0x3A, 0xD0, 0xB8, 0x4E, 0x27, 0x1F, 
-	0xDC, 0x2A, 0xEE, 0xAC, 0xA9, 0x59, 0x5D, 0x07, 0x63, 0x11, 
-	0x83, 0x0B, 0xD4, 0x74, 0x80, 0xB6, 0x7D, 0x62, 0x45, 0xBF, 
-	0x56
-};
-static const int sizeof_rsa_key_der_2048 = sizeof(rsa_key_der_2048);
-
-/* ./certs/ca-cert.der, 2048-bit */
-static const unsigned char ca_cert_der_2048[] =
-{
-	0x30, 0x82, 0x04, 0xAA, 0x30, 0x82, 0x03, 0x92, 0xA0, 0x03, 
-	0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xD9, 0x80, 0x3A, 0xC3, 
-	0xD2, 0xF4, 0xDA, 0x37, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 
-	0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x30, 
-	0x81, 0x94, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 
-	0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x10, 0x30, 0x0E, 0x06, 
-	0x03, 0x55, 0x04, 0x08, 0x0C, 0x07, 0x4D, 0x6F, 0x6E, 0x74, 
-	0x61, 0x6E, 0x61, 0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 
-	0x04, 0x07, 0x0C, 0x07, 0x42, 0x6F, 0x7A, 0x65, 0x6D, 0x61, 
-	0x6E, 0x31, 0x11, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x04, 0x0A, 
-	0x0C, 0x08, 0x53, 0x61, 0x77, 0x74, 0x6F, 0x6F, 0x74, 0x68, 
-	0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x0C, 
-	0x0A, 0x43, 0x6F, 0x6E, 0x73, 0x75, 0x6C, 0x74, 0x69, 0x6E, 
-	0x67, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 
-	0x0C, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x6F, 0x6C, 0x66, 
-	0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x31, 0x1F, 0x30, 
-	0x1D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 
-	0x09, 0x01, 0x16, 0x10, 0x69, 0x6E, 0x66, 0x6F, 0x40, 0x77, 
-	0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 
-	0x30, 0x1E, 0x17, 0x0D, 0x31, 0x35, 0x30, 0x35, 0x30, 0x37, 
-	0x31, 0x38, 0x32, 0x31, 0x30, 0x31, 0x5A, 0x17, 0x0D, 0x31, 
-	0x38, 0x30, 0x31, 0x33, 0x31, 0x31, 0x38, 0x32, 0x31, 0x30, 
-	0x31, 0x5A, 0x30, 0x81, 0x94, 0x31, 0x0B, 0x30, 0x09, 0x06, 
-	0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x10, 
-	0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0C, 0x07, 0x4D, 
-	0x6F, 0x6E, 0x74, 0x61, 0x6E, 0x61, 0x31, 0x10, 0x30, 0x0E, 
-	0x06, 0x03, 0x55, 0x04, 0x07, 0x0C, 0x07, 0x42, 0x6F, 0x7A, 
-	0x65, 0x6D, 0x61, 0x6E, 0x31, 0x11, 0x30, 0x0F, 0x06, 0x03, 
-	0x55, 0x04, 0x0A, 0x0C, 0x08, 0x53, 0x61, 0x77, 0x74, 0x6F, 
-	0x6F, 0x74, 0x68, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 
-	0x04, 0x0B, 0x0C, 0x0A, 0x43, 0x6F, 0x6E, 0x73, 0x75, 0x6C, 
-	0x74, 0x69, 0x6E, 0x67, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 
-	0x55, 0x04, 0x03, 0x0C, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x77, 
-	0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 
-	0x31, 0x1F, 0x30, 0x1D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 
-	0xF7, 0x0D, 0x01, 0x09, 0x01, 0x16, 0x10, 0x69, 0x6E, 0x66, 
-	0x6F, 0x40, 0x77, 0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 
-	0x63, 0x6F, 0x6D, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0D, 0x06, 
-	0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 
-	0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00, 0x30, 0x82, 0x01, 
-	0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xBF, 0x0C, 0xCA, 0x2D, 
-	0x14, 0xB2, 0x1E, 0x84, 0x42, 0x5B, 0xCD, 0x38, 0x1F, 0x4A, 
-	0xF2, 0x4D, 0x75, 0x10, 0xF1, 0xB6, 0x35, 0x9F, 0xDF, 0xCA, 
-	0x7D, 0x03, 0x98, 0xD3, 0xAC, 0xDE, 0x03, 0x66, 0xEE, 0x2A, 
-	0xF1, 0xD8, 0xB0, 0x7D, 0x6E, 0x07, 0x54, 0x0B, 0x10, 0x98, 
-	0x21, 0x4D, 0x80, 0xCB, 0x12, 0x20, 0xE7, 0xCC, 0x4F, 0xDE, 
-	0x45, 0x7D, 0xC9, 0x72, 0x77, 0x32, 0xEA, 0xCA, 0x90, 0xBB, 
-	0x69, 0x52, 0x10, 0x03, 0x2F, 0xA8, 0xF3, 0x95, 0xC5, 0xF1, 
-	0x8B, 0x62, 0x56, 0x1B, 0xEF, 0x67, 0x6F, 0xA4, 0x10, 0x41, 
-	0x95, 0xAD, 0x0A, 0x9B, 0xE3, 0xA5, 0xC0, 0xB0, 0xD2, 0x70, 
-	0x76, 0x50, 0x30, 0x5B, 0xA8, 0xE8, 0x08, 0x2C, 0x7C, 0xED, 
-	0xA7, 0xA2, 0x7A, 0x8D, 0x38, 0x29, 0x1C, 0xAC, 0xC7, 0xED, 
-	0xF2, 0x7C, 0x95, 0xB0, 0x95, 0x82, 0x7D, 0x49, 0x5C, 0x38, 
-	0xCD, 0x77, 0x25, 0xEF, 0xBD, 0x80, 0x75, 0x53, 0x94, 0x3C, 
-	0x3D, 0xCA, 0x63, 0x5B, 0x9F, 0x15, 0xB5, 0xD3, 0x1D, 0x13, 
-	0x2F, 0x19, 0xD1, 0x3C, 0xDB, 0x76, 0x3A, 0xCC, 0xB8, 0x7D, 
-	0xC9, 0xE5, 0xC2, 0xD7, 0xDA, 0x40, 0x6F, 0xD8, 0x21, 0xDC, 
-	0x73, 0x1B, 0x42, 0x2D, 0x53, 0x9C, 0xFE, 0x1A, 0xFC, 0x7D, 
-	0xAB, 0x7A, 0x36, 0x3F, 0x98, 0xDE, 0x84, 0x7C, 0x05, 0x67, 
-	0xCE, 0x6A, 0x14, 0x38, 0x87, 0xA9, 0xF1, 0x8C, 0xB5, 0x68, 
-	0xCB, 0x68, 0x7F, 0x71, 0x20, 0x2B, 0xF5, 0xA0, 0x63, 0xF5, 
-	0x56, 0x2F, 0xA3, 0x26, 0xD2, 0xB7, 0x6F, 0xB1, 0x5A, 0x17, 
-	0xD7, 0x38, 0x99, 0x08, 0xFE, 0x93, 0x58, 0x6F, 0xFE, 0xC3, 
-	0x13, 0x49, 0x08, 0x16, 0x0B, 0xA7, 0x4D, 0x67, 0x00, 0x52, 
-	0x31, 0x67, 0x23, 0x4E, 0x98, 0xED, 0x51, 0x45, 0x1D, 0xB9, 
-	0x04, 0xD9, 0x0B, 0xEC, 0xD8, 0x28, 0xB3, 0x4B, 0xBD, 0xED, 
-	0x36, 0x79, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x81, 0xFC, 
-	0x30, 0x81, 0xF9, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 
-	0x04, 0x16, 0x04, 0x14, 0x27, 0x8E, 0x67, 0x11, 0x74, 0xC3, 
-	0x26, 0x1D, 0x3F, 0xED, 0x33, 0x63, 0xB3, 0xA4, 0xD8, 0x1D, 
-	0x30, 0xE5, 0xE8, 0xD5, 0x30, 0x81, 0xC9, 0x06, 0x03, 0x55, 
-	0x1D, 0x23, 0x04, 0x81, 0xC1, 0x30, 0x81, 0xBE, 0x80, 0x14, 
-	0x27, 0x8E, 0x67, 0x11, 0x74, 0xC3, 0x26, 0x1D, 0x3F, 0xED, 
-	0x33, 0x63, 0xB3, 0xA4, 0xD8, 0x1D, 0x30, 0xE5, 0xE8, 0xD5, 
-	0xA1, 0x81, 0x9A, 0xA4, 0x81, 0x97, 0x30, 0x81, 0x94, 0x31, 
-	0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 
-	0x55, 0x53, 0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 
-	0x08, 0x0C, 0x07, 0x4D, 0x6F, 0x6E, 0x74, 0x61, 0x6E, 0x61, 
-	0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0C, 
-	0x07, 0x42, 0x6F, 0x7A, 0x65, 0x6D, 0x61, 0x6E, 0x31, 0x11, 
-	0x30, 0x0F, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x08, 0x53, 
-	0x61, 0x77, 0x74, 0x6F, 0x6F, 0x74, 0x68, 0x31, 0x13, 0x30, 
-	0x11, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x0C, 0x0A, 0x43, 0x6F, 
-	0x6E, 0x73, 0x75, 0x6C, 0x74, 0x69, 0x6E, 0x67, 0x31, 0x18, 
-	0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x0F, 0x77, 
-	0x77, 0x77, 0x2E, 0x77, 0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 
-	0x2E, 0x63, 0x6F, 0x6D, 0x31, 0x1F, 0x30, 0x1D, 0x06, 0x09, 
-	0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01, 0x16, 
-	0x10, 0x69, 0x6E, 0x66, 0x6F, 0x40, 0x77, 0x6F, 0x6C, 0x66, 
-	0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x09, 0x00, 
-	0xD9, 0x80, 0x3A, 0xC3, 0xD2, 0xF4, 0xDA, 0x37, 0x30, 0x0C, 
-	0x06, 0x03, 0x55, 0x1D, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 
-	0x01, 0xFF, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 
-	0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x03, 0x82, 0x01, 
-	0x01, 0x00, 0x7A, 0xAF, 0x44, 0x3B, 0xAA, 0x6F, 0x53, 0x42, 
-	0xB2, 0x33, 0xAA, 0x43, 0x5F, 0x56, 0x30, 0xD3, 0xB9, 0x96, 
-	0x0B, 0x9A, 0x55, 0x5A, 0x39, 0x2A, 0x0B, 0x4E, 0xE4, 0x2E, 
-	0xF1, 0x95, 0x66, 0xC9, 0x86, 0x36, 0x82, 0x8D, 0x63, 0x7C, 
-	0x4D, 0xA2, 0xEE, 0x48, 0xBA, 0x03, 0xC7, 0x90, 0xD7, 0xA7, 
-	0xC6, 0x74, 0x60, 0x48, 0x5F, 0x31, 0xA2, 0xF9, 0x5E, 0x3E, 
-	0xC3, 0x82, 0xE1, 0xE5, 0x2F, 0x41, 0x81, 0x83, 0x29, 0x25, 
-	0x79, 0xD1, 0x53, 0x00, 0x69, 0x3C, 0xED, 0x0A, 0x30, 0x3B, 
-	0x41, 0x1D, 0x92, 0xA1, 0x2C, 0xA8, 0x9D, 0x2C, 0xE3, 0x23, 
-	0x87, 0x79, 0xE0, 0x55, 0x6E, 0x91, 0xA8, 0x50, 0xDA, 0x46, 
-	0x2F, 0xC2, 0x20, 0x50, 0x3E, 0x2B, 0x47, 0x97, 0x14, 0xB0, 
-	0x7D, 0x04, 0xBA, 0x45, 0x51, 0xD0, 0x6E, 0xE1, 0x5A, 0xA2, 
-	0x4B, 0x84, 0x9C, 0x4D, 0xCD, 0x85, 0x04, 0xF9, 0x28, 0x31, 
-	0x82, 0x93, 0xBC, 0xC7, 0x59, 0x49, 0x91, 0x03, 0xE8, 0xDF, 
-	0x6A, 0xE4, 0x56, 0xAD, 0x6A, 0xCB, 0x1F, 0x0D, 0x37, 0xE4, 
-	0x5E, 0xBD, 0xE7, 0x9F, 0xD5, 0xEC, 0x9D, 0x3C, 0x18, 0x25, 
-	0x9B, 0xF1, 0x2F, 0x50, 0x7D, 0xEB, 0x31, 0xCB, 0xF1, 0x63, 
-	0x22, 0x9D, 0x57, 0xFC, 0xF3, 0x84, 0x20, 0x1A, 0xC6, 0x07, 
-	0x87, 0x92, 0x26, 0x9E, 0x15, 0x18, 0x59, 0x33, 0x06, 0xDC, 
-	0xFB, 0xB0, 0xB6, 0x76, 0x5D, 0xF1, 0xC1, 0x2F, 0xC8, 0x2F, 
-	0x62, 0x9C, 0xC0, 0xD6, 0xDE, 0xEB, 0x65, 0x77, 0xF3, 0x5C, 
-	0xA6, 0xC3, 0x88, 0x27, 0x96, 0x75, 0xB4, 0xF4, 0x54, 0xCD, 
-	0xFF, 0x2D, 0x21, 0x2E, 0x96, 0xF0, 0x07, 0x73, 0x4B, 0xE9, 
-	0x93, 0x92, 0x90, 0xDE, 0x62, 0xD9, 0xA3, 0x3B, 0xAC, 0x6E, 
-	0x24, 0x5F, 0x27, 0x4A, 0xB3, 0x94, 0x70, 0xFF, 0x30, 0x17, 
-	0xE7, 0x7E, 0x32, 0x8F, 0x65, 0xB7, 0x75, 0x58
-};
-static const int sizeof_ca_cert_der_2048 = sizeof(ca_cert_der_2048);
-
-/* ./certs/server-key.der, 2048-bit */
-static const unsigned char server_key_der_2048[] =
-{
-	0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 
-	0x01, 0x00, 0xC0, 0x95, 0x08, 0xE1, 0x57, 0x41, 0xF2, 0x71, 
-	0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, 0x01, 0x65, 0xC6, 0x45, 
-	0xAE, 0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE, 0x2F, 0x4E, 
-	0xD6, 0xF6, 0x1C, 0x88, 0xBC, 0x7C, 0x9F, 0xFB, 0xA8, 0x67, 
-	0x7F, 0xFE, 0x5C, 0x9C, 0x51, 0x75, 0xF7, 0x8A, 0xCA, 0x07, 
-	0xE7, 0x35, 0x2F, 0x8F, 0xE1, 0xBD, 0x7B, 0xC0, 0x2F, 0x7C, 
-	0xAB, 0x64, 0xA8, 0x17, 0xFC, 0xCA, 0x5D, 0x7B, 0xBA, 0xE0, 
-	0x21, 0xE5, 0x72, 0x2E, 0x6F, 0x2E, 0x86, 0xD8, 0x95, 0x73, 
-	0xDA, 0xAC, 0x1B, 0x53, 0xB9, 0x5F, 0x3F, 0xD7, 0x19, 0x0D, 
-	0x25, 0x4F, 0xE1, 0x63, 0x63, 0x51, 0x8B, 0x0B, 0x64, 0x3F, 
-	0xAD, 0x43, 0xB8, 0xA5, 0x1C, 0x5C, 0x34, 0xB3, 0xAE, 0x00, 
-	0xA0, 0x63, 0xC5, 0xF6, 0x7F, 0x0B, 0x59, 0x68, 0x78, 0x73, 
-	0xA6, 0x8C, 0x18, 0xA9, 0x02, 0x6D, 0xAF, 0xC3, 0x19, 0x01, 
-	0x2E, 0xB8, 0x10, 0xE3, 0xC6, 0xCC, 0x40, 0xB4, 0x69, 0xA3, 
-	0x46, 0x33, 0x69, 0x87, 0x6E, 0xC4, 0xBB, 0x17, 0xA6, 0xF3, 
-	0xE8, 0xDD, 0xAD, 0x73, 0xBC, 0x7B, 0x2F, 0x21, 0xB5, 0xFD, 
-	0x66, 0x51, 0x0C, 0xBD, 0x54, 0xB3, 0xE1, 0x6D, 0x5F, 0x1C, 
-	0xBC, 0x23, 0x73, 0xD1, 0x09, 0x03, 0x89, 0x14, 0xD2, 0x10, 
-	0xB9, 0x64, 0xC3, 0x2A, 0xD0, 0xA1, 0x96, 0x4A, 0xBC, 0xE1, 
-	0xD4, 0x1A, 0x5B, 0xC7, 0xA0, 0xC0, 0xC1, 0x63, 0x78, 0x0F, 
-	0x44, 0x37, 0x30, 0x32, 0x96, 0x80, 0x32, 0x23, 0x95, 0xA1, 
-	0x77, 0xBA, 0x13, 0xD2, 0x97, 0x73, 0xE2, 0x5D, 0x25, 0xC9, 
-	0x6A, 0x0D, 0xC3, 0x39, 0x60, 0xA4, 0xB4, 0xB0, 0x69, 0x42, 
-	0x42, 0x09, 0xE9, 0xD8, 0x08, 0xBC, 0x33, 0x20, 0xB3, 0x58, 
-	0x22, 0xA7, 0xAA, 0xEB, 0xC4, 0xE1, 0xE6, 0x61, 0x83, 0xC5, 
-	0xD2, 0x96, 0xDF, 0xD9, 0xD0, 0x4F, 0xAD, 0xD7, 0x02, 0x03, 
-	0x01, 0x00, 0x01, 0x02, 0x82, 0x01, 0x01, 0x00, 0x9A, 0xD0, 
-	0x34, 0x0F, 0x52, 0x62, 0x05, 0x50, 0x01, 0xEF, 0x9F, 0xED, 
-	0x64, 0x6E, 0xC2, 0xC4, 0xDA, 0x1A, 0xF2, 0x84, 0xD7, 0x92, 
-	0x10, 0x48, 0x92, 0xC4, 0xE9, 0x6A, 0xEB, 0x8B, 0x75, 0x6C, 
-	0xC6, 0x79, 0x38, 0xF2, 0xC9, 0x72, 0x4A, 0x86, 0x64, 0x54, 
-	0x95, 0x77, 0xCB, 0xC3, 0x9A, 0x9D, 0xB7, 0xD4, 0x1D, 0xA4, 
-	0x00, 0xC8, 0x9E, 0x4E, 0xE4, 0xDD, 0xC7, 0xBA, 0x67, 0x16, 
-	0xC1, 0x74, 0xBC, 0xA9, 0xD6, 0x94, 0x8F, 0x2B, 0x30, 0x1A, 
-	0xFB, 0xED, 0xDF, 0x21, 0x05, 0x23, 0xD9, 0x4A, 0x39, 0xBD, 
-	0x98, 0x6B, 0x65, 0x9A, 0xB8, 0xDC, 0xC4, 0x7D, 0xEE, 0xA6, 
-	0x43, 0x15, 0x2E, 0x3D, 0xBE, 0x1D, 0x22, 0x60, 0x2A, 0x73, 
-	0x30, 0xD5, 0x3E, 0xD8, 0xA2, 0xAC, 0x86, 0x43, 0x2E, 0xC4, 
-	0xF5, 0x64, 0x5E, 0x3F, 0x89, 0x75, 0x0F, 0x11, 0xD8, 0x51, 
-	0x25, 0x4E, 0x9F, 0xD8, 0xAA, 0xA3, 0xCE, 0x60, 0xB3, 0xE2, 
-	0x8A, 0xD9, 0x7E, 0x1B, 0xF0, 0x64, 0xCA, 0x9A, 0x5B, 0x05, 
-	0x0B, 0x5B, 0xAA, 0xCB, 0xE5, 0xE3, 0x3F, 0x6E, 0x32, 0x22, 
-	0x05, 0xF3, 0xD0, 0xFA, 0xEF, 0x74, 0x52, 0x81, 0xE2, 0x5F, 
-	0x74, 0xD3, 0xBD, 0xFF, 0x31, 0x83, 0x45, 0x75, 0xFA, 0x63, 
-	0x7A, 0x97, 0x2E, 0xD6, 0xB6, 0x19, 0xC6, 0x92, 0x26, 0xE4, 
-	0x28, 0x06, 0x50, 0x50, 0x0E, 0x78, 0x2E, 0xA9, 0x78, 0x0D, 
-	0x14, 0x97, 0xB4, 0x12, 0xD8, 0x31, 0x40, 0xAB, 0xA1, 0x01, 
-	0x41, 0xC2, 0x30, 0xF8, 0x07, 0x5F, 0x16, 0xE4, 0x61, 0x77, 
-	0xD2, 0x60, 0xF2, 0x9F, 0x8D, 0xE8, 0xF4, 0xBA, 0xEB, 0x63, 
-	0xDE, 0x2A, 0x97, 0x81, 0xEF, 0x4C, 0x6C, 0xE6, 0x55, 0x34, 
-	0x51, 0x2B, 0x28, 0x34, 0xF4, 0x53, 0x1C, 0xC4, 0x58, 0x0A, 
-	0x3F, 0xBB, 0xAF, 0xB5, 0xF7, 0x4A, 0x85, 0x43, 0x2D, 0x3C, 
-	0xF1, 0x58, 0x58, 0x81, 0x02, 0x81, 0x81, 0x00, 0xF2, 0x2C, 
-	0x54, 0x76, 0x39, 0x23, 0x63, 0xC9, 0x10, 0x32, 0xB7, 0x93, 
-	0xAD, 0xAF, 0xBE, 0x19, 0x75, 0x96, 0x81, 0x64, 0xE6, 0xB5, 
-	0xB8, 0x89, 0x42, 0x41, 0xD1, 0x6D, 0xD0, 0x1C, 0x1B, 0xF8, 
-	0x1B, 0xAC, 0x69, 0xCB, 0x36, 0x3C, 0x64, 0x7D, 0xDC, 0xF4, 
-	0x19, 0xB8, 0xC3, 0x60, 0xB1, 0x57, 0x48, 0x5F, 0x52, 0x4F, 
-	0x59, 0x3A, 0x55, 0x7F, 0x32, 0xC0, 0x19, 0x43, 0x50, 0x3F, 
-	0xAE, 0xCE, 0x6F, 0x17, 0xF3, 0x0E, 0x9F, 0x40, 0xCA, 0x4E, 
-	0xAD, 0x15, 0x3B, 0xC9, 0x79, 0xE9, 0xC0, 0x59, 0x38, 0x73, 
-	0x70, 0x9C, 0x0A, 0x7C, 0xC9, 0x3A, 0x48, 0x32, 0xA7, 0xD8, 
-	0x49, 0x75, 0x0A, 0x85, 0xC2, 0xC2, 0xFD, 0x15, 0x73, 0xDA, 
-	0x99, 0x09, 0x2A, 0x69, 0x9A, 0x9F, 0x0A, 0x71, 0xBF, 0xB0, 
-	0x04, 0xA6, 0x8C, 0x7A, 0x5A, 0x6F, 0x48, 0x5A, 0x54, 0x3B, 
-	0xC6, 0xB1, 0x53, 0x17, 0xDF, 0xE7, 0x02, 0x81, 0x81, 0x00, 
-	0xCB, 0x93, 0xDE, 0x77, 0x15, 0x5D, 0xB7, 0x5C, 0x5C, 0x7C, 
-	0xD8, 0x90, 0xA9, 0x98, 0x2D, 0xD6, 0x69, 0x0E, 0x63, 0xB3, 
-	0xA3, 0xDC, 0xA6, 0xCC, 0x8B, 0x6A, 0xA4, 0xA2, 0x12, 0x8C, 
-	0x8E, 0x7B, 0x48, 0x2C, 0xB2, 0x4B, 0x37, 0xDC, 0x06, 0x18, 
-	0x7D, 0xEA, 0xFE, 0x76, 0xA1, 0xD4, 0xA1, 0xE9, 0x3F, 0x0D, 
-	0xCD, 0x1B, 0x5F, 0xAF, 0x5F, 0x9E, 0x96, 0x5B, 0x5B, 0x0F, 
-	0xA1, 0x7C, 0xAF, 0xB3, 0x9B, 0x90, 0xDB, 0x57, 0x73, 0x3A, 
-	0xED, 0xB0, 0x23, 0x44, 0xAE, 0x41, 0x4F, 0x1F, 0x07, 0x42, 
-	0x13, 0x23, 0x4C, 0xCB, 0xFA, 0xF4, 0x14, 0xA4, 0xD5, 0xF7, 
-	0x9E, 0x36, 0x7C, 0x5B, 0x9F, 0xA8, 0x3C, 0xC1, 0x85, 0x5F, 
-	0x74, 0xD2, 0x39, 0x2D, 0xFF, 0xD0, 0x84, 0xDF, 0xFB, 0xB3, 
-	0x20, 0x7A, 0x2E, 0x9B, 0x17, 0xAE, 0xE6, 0xBA, 0x0B, 0xAE, 
-	0x5F, 0x53, 0xA4, 0x52, 0xED, 0x1B, 0xC4, 0x91, 0x02, 0x81, 
-	0x81, 0x00, 0xEC, 0x98, 0xDA, 0xBB, 0xD5, 0xFE, 0xF9, 0x52, 
-	0x4A, 0x7D, 0x02, 0x55, 0x49, 0x6F, 0x55, 0x6E, 0x52, 0x2F, 
-	0x84, 0xA3, 0x2B, 0xB3, 0x86, 0x62, 0xB3, 0x54, 0xD2, 0x63, 
-	0x52, 0xDA, 0xE3, 0x88, 0x76, 0xA0, 0xEF, 0x8B, 0x15, 0xA5, 
-	0xD3, 0x18, 0x14, 0x72, 0x77, 0x5E, 0xC7, 0xA3, 0x04, 0x1F, 
-	0x9E, 0x19, 0x62, 0xB5, 0x1B, 0x1B, 0x9E, 0xC3, 0xF2, 0xB5, 
-	0x32, 0xF9, 0x4C, 0xC1, 0xAA, 0xEB, 0x0C, 0x26, 0x7D, 0xD4, 
-	0x5F, 0x4A, 0x51, 0x5C, 0xA4, 0x45, 0x06, 0x70, 0x44, 0xA7, 
-	0x56, 0xC0, 0xD4, 0x22, 0x14, 0x76, 0x9E, 0xD8, 0x63, 0x50, 
-	0x89, 0x90, 0xD3, 0xE2, 0xBF, 0x81, 0x95, 0x92, 0x31, 0x41, 
-	0x87, 0x39, 0x1A, 0x43, 0x0B, 0x18, 0xA5, 0x53, 0x1F, 0x39, 
-	0x1A, 0x5F, 0x1F, 0x43, 0xBC, 0x87, 0x6A, 0xDF, 0x6E, 0xD3, 
-	0x22, 0x00, 0xFE, 0x22, 0x98, 0x70, 0x4E, 0x1A, 0x19, 0x29, 
-	0x02, 0x81, 0x81, 0x00, 0x8A, 0x41, 0x56, 0x28, 0x51, 0x9E, 
-	0x5F, 0xD4, 0x9E, 0x0B, 0x3B, 0x98, 0xA3, 0x54, 0xF2, 0x6C, 
-	0x56, 0xD4, 0xAA, 0xE9, 0x69, 0x33, 0x85, 0x24, 0x0C, 0xDA, 
-	0xD4, 0x0C, 0x2D, 0xC4, 0xBF, 0x4F, 0x02, 0x69, 0x38, 0x7C, 
-	0xD4, 0xE6, 0xDC, 0x4C, 0xED, 0xD7, 0x16, 0x11, 0xC3, 0x3E, 
-	0x00, 0xE7, 0xC3, 0x26, 0xC0, 0x51, 0x02, 0xDE, 0xBB, 0x75, 
-	0x9C, 0x6F, 0x56, 0x9C, 0x7A, 0xF3, 0x8E, 0xEF, 0xCF, 0x8A, 
-	0xC5, 0x2B, 0xD2, 0xDA, 0x06, 0x6A, 0x44, 0xC9, 0x73, 0xFE, 
-	0x6E, 0x99, 0x87, 0xF8, 0x5B, 0xBE, 0xF1, 0x7C, 0xE6, 0x65, 
-	0xB5, 0x4F, 0x6C, 0xF0, 0xC9, 0xC5, 0xFF, 0x16, 0xCA, 0x8B, 
-	0x1B, 0x17, 0xE2, 0x58, 0x3D, 0xA2, 0x37, 0xAB, 0x01, 0xBC, 
-	0xBF, 0x40, 0xCE, 0x53, 0x8C, 0x8E, 0xED, 0xEF, 0xEE, 0x59, 
-	0x9D, 0xE0, 0x63, 0xE6, 0x7C, 0x5E, 0xF5, 0x8E, 0x4B, 0xF1, 
-	0x3B, 0xC1, 0x02, 0x81, 0x80, 0x4D, 0x45, 0xF9, 0x40, 0x8C, 
-	0xC5, 0x5B, 0xF4, 0x2A, 0x1A, 0x8A, 0xB4, 0xF2, 0x1C, 0xAC, 
-	0x6B, 0xE9, 0x0C, 0x56, 0x36, 0xB7, 0x4E, 0x72, 0x96, 0xD5, 
-	0xE5, 0x8A, 0xD2, 0xE2, 0xFF, 0xF1, 0xF1, 0x18, 0x13, 0x3D, 
-	0x86, 0x09, 0xB8, 0xD8, 0x76, 0xA7, 0xC9, 0x1C, 0x71, 0x52, 
-	0x94, 0x30, 0x43, 0xE0, 0xF1, 0x78, 0x74, 0xFD, 0x61, 0x1B, 
-	0x4C, 0x09, 0xCC, 0xE6, 0x68, 0x2A, 0x71, 0xAD, 0x1C, 0xDF, 
-	0x43, 0xBC, 0x56, 0xDB, 0xA5, 0xA4, 0xBE, 0x35, 0x70, 0xA4, 
-	0x5E, 0xCF, 0x4F, 0xFC, 0x00, 0x55, 0x99, 0x3A, 0x3D, 0x23, 
-	0xCF, 0x67, 0x5A, 0xF5, 0x22, 0xF8, 0xB5, 0x29, 0xD0, 0x44, 
-	0x11, 0xEB, 0x35, 0x2E, 0x46, 0xBE, 0xFD, 0x8E, 0x18, 0xB2, 
-	0x5F, 0xA8, 0xBF, 0x19, 0x32, 0xA1, 0xF5, 0xDC, 0x03, 0xE6, 
-	0x7C, 0x9A, 0x1F, 0x0C, 0x7C, 0xA9, 0xB0, 0x0E, 0x21, 0x37, 
-	0x3B, 0xF1, 0xB0
-};
-static const int sizeof_server_key_der_2048 = sizeof(server_key_der_2048);
-
-/* ./certs/server-cert.der, 2048-bit */
-static const unsigned char server_cert_der_2048[] =
-{
-	0x30, 0x82, 0x04, 0x9E, 0x30, 0x82, 0x03, 0x86, 0xA0, 0x03, 
-	0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x30, 0x0D, 0x06, 0x09, 
-	0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 
-	0x00, 0x30, 0x81, 0x94, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 
-	0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x10, 0x30, 
-	0x0E, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0C, 0x07, 0x4D, 0x6F, 
-	0x6E, 0x74, 0x61, 0x6E, 0x61, 0x31, 0x10, 0x30, 0x0E, 0x06, 
-	0x03, 0x55, 0x04, 0x07, 0x0C, 0x07, 0x42, 0x6F, 0x7A, 0x65, 
-	0x6D, 0x61, 0x6E, 0x31, 0x11, 0x30, 0x0F, 0x06, 0x03, 0x55, 
-	0x04, 0x0A, 0x0C, 0x08, 0x53, 0x61, 0x77, 0x74, 0x6F, 0x6F, 
-	0x74, 0x68, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 
-	0x0B, 0x0C, 0x0A, 0x43, 0x6F, 0x6E, 0x73, 0x75, 0x6C, 0x74, 
-	0x69, 0x6E, 0x67, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 
-	0x04, 0x03, 0x0C, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x6F, 
-	0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x31, 
-	0x1F, 0x30, 0x1D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 
-	0x0D, 0x01, 0x09, 0x01, 0x16, 0x10, 0x69, 0x6E, 0x66, 0x6F, 
-	0x40, 0x77, 0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 
-	0x6F, 0x6D, 0x30, 0x1E, 0x17, 0x0D, 0x31, 0x35, 0x30, 0x35, 
-	0x30, 0x37, 0x31, 0x38, 0x32, 0x31, 0x30, 0x31, 0x5A, 0x17, 
-	0x0D, 0x31, 0x38, 0x30, 0x31, 0x33, 0x31, 0x31, 0x38, 0x32, 
-	0x31, 0x30, 0x31, 0x5A, 0x30, 0x81, 0x90, 0x31, 0x0B, 0x30, 
-	0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 
-	0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0C, 
-	0x07, 0x4D, 0x6F, 0x6E, 0x74, 0x61, 0x6E, 0x61, 0x31, 0x10, 
-	0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0C, 0x07, 0x42, 
-	0x6F, 0x7A, 0x65, 0x6D, 0x61, 0x6E, 0x31, 0x10, 0x30, 0x0E, 
-	0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x07, 0x77, 0x6F, 0x6C, 
-	0x66, 0x53, 0x53, 0x4C, 0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 
-	0x55, 0x04, 0x0B, 0x0C, 0x07, 0x53, 0x75, 0x70, 0x70, 0x6F, 
-	0x72, 0x74, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 
-	0x03, 0x0C, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x6F, 0x6C, 
-	0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x31, 0x1F, 
-	0x30, 0x1D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 
-	0x01, 0x09, 0x01, 0x16, 0x10, 0x69, 0x6E, 0x66, 0x6F, 0x40, 
-	0x77, 0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 
-	0x6D, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 
-	0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 
-	0x03, 0x82, 0x01, 0x0F, 0x00, 0x30, 0x82, 0x01, 0x0A, 0x02, 
-	0x82, 0x01, 0x01, 0x00, 0xC0, 0x95, 0x08, 0xE1, 0x57, 0x41, 
-	0xF2, 0x71, 0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, 0x01, 0x65, 
-	0xC6, 0x45, 0xAE, 0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE, 
-	0x2F, 0x4E, 0xD6, 0xF6, 0x1C, 0x88, 0xBC, 0x7C, 0x9F, 0xFB, 
-	0xA8, 0x67, 0x7F, 0xFE, 0x5C, 0x9C, 0x51, 0x75, 0xF7, 0x8A, 
-	0xCA, 0x07, 0xE7, 0x35, 0x2F, 0x8F, 0xE1, 0xBD, 0x7B, 0xC0, 
-	0x2F, 0x7C, 0xAB, 0x64, 0xA8, 0x17, 0xFC, 0xCA, 0x5D, 0x7B, 
-	0xBA, 0xE0, 0x21, 0xE5, 0x72, 0x2E, 0x6F, 0x2E, 0x86, 0xD8, 
-	0x95, 0x73, 0xDA, 0xAC, 0x1B, 0x53, 0xB9, 0x5F, 0x3F, 0xD7, 
-	0x19, 0x0D, 0x25, 0x4F, 0xE1, 0x63, 0x63, 0x51, 0x8B, 0x0B, 
-	0x64, 0x3F, 0xAD, 0x43, 0xB8, 0xA5, 0x1C, 0x5C, 0x34, 0xB3, 
-	0xAE, 0x00, 0xA0, 0x63, 0xC5, 0xF6, 0x7F, 0x0B, 0x59, 0x68, 
-	0x78, 0x73, 0xA6, 0x8C, 0x18, 0xA9, 0x02, 0x6D, 0xAF, 0xC3, 
-	0x19, 0x01, 0x2E, 0xB8, 0x10, 0xE3, 0xC6, 0xCC, 0x40, 0xB4, 
-	0x69, 0xA3, 0x46, 0x33, 0x69, 0x87, 0x6E, 0xC4, 0xBB, 0x17, 
-	0xA6, 0xF3, 0xE8, 0xDD, 0xAD, 0x73, 0xBC, 0x7B, 0x2F, 0x21, 
-	0xB5, 0xFD, 0x66, 0x51, 0x0C, 0xBD, 0x54, 0xB3, 0xE1, 0x6D, 
-	0x5F, 0x1C, 0xBC, 0x23, 0x73, 0xD1, 0x09, 0x03, 0x89, 0x14, 
-	0xD2, 0x10, 0xB9, 0x64, 0xC3, 0x2A, 0xD0, 0xA1, 0x96, 0x4A, 
-	0xBC, 0xE1, 0xD4, 0x1A, 0x5B, 0xC7, 0xA0, 0xC0, 0xC1, 0x63, 
-	0x78, 0x0F, 0x44, 0x37, 0x30, 0x32, 0x96, 0x80, 0x32, 0x23, 
-	0x95, 0xA1, 0x77, 0xBA, 0x13, 0xD2, 0x97, 0x73, 0xE2, 0x5D, 
-	0x25, 0xC9, 0x6A, 0x0D, 0xC3, 0x39, 0x60, 0xA4, 0xB4, 0xB0, 
-	0x69, 0x42, 0x42, 0x09, 0xE9, 0xD8, 0x08, 0xBC, 0x33, 0x20, 
-	0xB3, 0x58, 0x22, 0xA7, 0xAA, 0xEB, 0xC4, 0xE1, 0xE6, 0x61, 
-	0x83, 0xC5, 0xD2, 0x96, 0xDF, 0xD9, 0xD0, 0x4F, 0xAD, 0xD7, 
-	0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x81, 0xFC, 0x30, 0x81, 
-	0xF9, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16, 
-	0x04, 0x14, 0xB3, 0x11, 0x32, 0xC9, 0x92, 0x98, 0x84, 0xE2, 
-	0xC9, 0xF8, 0xD0, 0x3B, 0x6E, 0x03, 0x42, 0xCA, 0x1F, 0x0E, 
-	0x8E, 0x3C, 0x30, 0x81, 0xC9, 0x06, 0x03, 0x55, 0x1D, 0x23, 
-	0x04, 0x81, 0xC1, 0x30, 0x81, 0xBE, 0x80, 0x14, 0x27, 0x8E, 
-	0x67, 0x11, 0x74, 0xC3, 0x26, 0x1D, 0x3F, 0xED, 0x33, 0x63, 
-	0xB3, 0xA4, 0xD8, 0x1D, 0x30, 0xE5, 0xE8, 0xD5, 0xA1, 0x81, 
-	0x9A, 0xA4, 0x81, 0x97, 0x30, 0x81, 0x94, 0x31, 0x0B, 0x30, 
-	0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 
-	0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0C, 
-	0x07, 0x4D, 0x6F, 0x6E, 0x74, 0x61, 0x6E, 0x61, 0x31, 0x10, 
-	0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0C, 0x07, 0x42, 
-	0x6F, 0x7A, 0x65, 0x6D, 0x61, 0x6E, 0x31, 0x11, 0x30, 0x0F, 
-	0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x08, 0x53, 0x61, 0x77, 
-	0x74, 0x6F, 0x6F, 0x74, 0x68, 0x31, 0x13, 0x30, 0x11, 0x06, 
-	0x03, 0x55, 0x04, 0x0B, 0x0C, 0x0A, 0x43, 0x6F, 0x6E, 0x73, 
-	0x75, 0x6C, 0x74, 0x69, 0x6E, 0x67, 0x31, 0x18, 0x30, 0x16, 
-	0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x0F, 0x77, 0x77, 0x77, 
-	0x2E, 0x77, 0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 
-	0x6F, 0x6D, 0x31, 0x1F, 0x30, 0x1D, 0x06, 0x09, 0x2A, 0x86, 
-	0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01, 0x16, 0x10, 0x69, 
-	0x6E, 0x66, 0x6F, 0x40, 0x77, 0x6F, 0x6C, 0x66, 0x73, 0x73, 
-	0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x09, 0x00, 0xD9, 0x80, 
-	0x3A, 0xC3, 0xD2, 0xF4, 0xDA, 0x37, 0x30, 0x0C, 0x06, 0x03, 
-	0x55, 0x1D, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xFF, 
-	0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 
-	0x01, 0x01, 0x0B, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 
-	0x67, 0xC0, 0x2C, 0xA9, 0x43, 0x47, 0xE7, 0x11, 0x14, 0x77, 
-	0xAE, 0xCC, 0xD8, 0xE0, 0x6B, 0x23, 0x82, 0x91, 0x63, 0xE8, 
-	0xA8, 0x0D, 0x21, 0xC5, 0xC8, 0x47, 0x97, 0x2F, 0xD5, 0xF3, 
-	0x86, 0xFB, 0x6C, 0xCE, 0x25, 0xF9, 0x7C, 0x78, 0xC8, 0x3A, 
-	0x22, 0x68, 0xF2, 0x16, 0x1E, 0xD2, 0xD2, 0x3F, 0x24, 0x04, 
-	0x87, 0xF2, 0xB7, 0xC1, 0x62, 0x63, 0xBA, 0xC5, 0xFA, 0xAE, 
-	0xD2, 0x20, 0x81, 0x1A, 0xD2, 0x0C, 0xAE, 0x26, 0x6B, 0x1B, 
-	0x2B, 0x10, 0xD3, 0xE1, 0x9A, 0x4E, 0x64, 0x6C, 0x97, 0xDB, 
-	0x36, 0xA8, 0x8F, 0xF8, 0x05, 0x63, 0xBF, 0xBA, 0x0D, 0x88, 
-	0x0B, 0x87, 0x46, 0xC9, 0xE4, 0x64, 0xE3, 0xD7, 0xBD, 0xB8, 
-	0x2D, 0xD5, 0xC1, 0xC3, 0xC4, 0xDB, 0x55, 0x68, 0xDC, 0xA3, 
-	0x7A, 0x40, 0xB9, 0xA9, 0xF6, 0x04, 0x4A, 0x22, 0xCF, 0x98, 
-	0x76, 0x1C, 0xE4, 0xA3, 0xFF, 0x79, 0x19, 0x96, 0x57, 0x63, 
-	0x07, 0x6F, 0xF6, 0x32, 0x77, 0x16, 0x50, 0x9B, 0xE3, 0x34, 
-	0x18, 0xD4, 0xEB, 0xBE, 0xFD, 0xB6, 0x6F, 0xE3, 0xC7, 0xF6, 
-	0x85, 0xBF, 0xAC, 0x32, 0xAD, 0x98, 0x57, 0xBE, 0x13, 0x92, 
-	0x44, 0x10, 0xA5, 0xF3, 0xAE, 0xE2, 0x66, 0xDA, 0x44, 0xA9, 
-	0x94, 0x71, 0x3F, 0xD0, 0x2F, 0x20, 0x59, 0x87, 0xE4, 0x5A, 
-	0x40, 0xEE, 0xD2, 0xE4, 0x0C, 0xCE, 0x25, 0x94, 0xDC, 0x0F, 
-	0xFE, 0x38, 0xE0, 0x41, 0x52, 0x34, 0x5C, 0xBB, 0xC3, 0xDB, 
-	0xC1, 0x5F, 0x76, 0xC3, 0x5D, 0x0E, 0x32, 0x69, 0x2B, 0x9D, 
-	0x01, 0xED, 0x50, 0x1B, 0x4F, 0x77, 0xA9, 0xA9, 0xD8, 0x71, 
-	0x30, 0xCB, 0x2E, 0x2C, 0x70, 0x00, 0xAB, 0x78, 0x4B, 0xD7, 
-	0x15, 0xD9, 0x17, 0xF8, 0x64, 0xB2, 0xF7, 0x3A, 0xDA, 0xE1, 
-	0x0B, 0x8B, 0x0A, 0xE1, 0x4E, 0xB1, 0x03, 0x46, 0x14, 0xCA, 
-	0x94, 0xE3, 0x44, 0x77, 0xD7, 0x59
-};
-static const int sizeof_server_cert_der_2048 = sizeof(server_cert_der_2048);
-
-#endif /* USE_CERT_BUFFERS_1024 */
-
-/* dh1024 p */
-static const unsigned char dh_p[] =
-{
-    0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3,
-    0xBD, 0xD4, 0x79, 0x8E, 0x91, 0xB7, 0x81, 0x82, 0x51, 0xBB, 0x05, 0x5E,
-    0x2A, 0x20, 0x64, 0x90, 0x4A, 0x79, 0xA7, 0x70, 0xFA, 0x15, 0xA2, 0x59,
-    0xCB, 0xD5, 0x23, 0xA6, 0xA6, 0xEF, 0x09, 0xC4, 0x30, 0x48, 0xD5, 0xA2,
-    0x2F, 0x97, 0x1F, 0x3C, 0x20, 0x12, 0x9B, 0x48, 0x00, 0x0E, 0x6E, 0xDD,
-    0x06, 0x1C, 0xBC, 0x05, 0x3E, 0x37, 0x1D, 0x79, 0x4E, 0x53, 0x27, 0xDF,
-    0x61, 0x1E, 0xBB, 0xBE, 0x1B, 0xAC, 0x9B, 0x5C, 0x60, 0x44, 0xCF, 0x02,
-    0x3D, 0x76, 0xE0, 0x5E, 0xEA, 0x9B, 0xAD, 0x99, 0x1B, 0x13, 0xA6, 0x3C,
-    0x97, 0x4E, 0x9E, 0xF1, 0x83, 0x9E, 0xB5, 0xDB, 0x12, 0x51, 0x36, 0xF7,
-    0x26, 0x2E, 0x56, 0xA8, 0x87, 0x15, 0x38, 0xDF, 0xD8, 0x23, 0xC6, 0x50,
-    0x50, 0x85, 0xE2, 0x1F, 0x0D, 0xD5, 0xC8, 0x6B,
-};
-
-/* dh1024 g */
-static const unsigned char dh_g[] =
-{
-  0x02,
-};
-
-
-#endif /* WOLFSSL_CERTS_TEST_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/crl.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/crl.h
deleted file mode 100755
index 05c039a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/crl.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* crl.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLFSSL_CRL_H
-#define WOLFSSL_CRL_H
-
-
-#ifdef HAVE_CRL
-
-#include 
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-typedef struct WOLFSSL_CRL WOLFSSL_CRL;
-
-WOLFSSL_LOCAL int  InitCRL(WOLFSSL_CRL*, WOLFSSL_CERT_MANAGER*);
-WOLFSSL_LOCAL void FreeCRL(WOLFSSL_CRL*, int dynamic);
-
-WOLFSSL_LOCAL int  LoadCRL(WOLFSSL_CRL* crl, const char* path, int type, int mon);
-WOLFSSL_LOCAL int  BufferLoadCRL(WOLFSSL_CRL*, const byte*, long, int);
-WOLFSSL_LOCAL int  CheckCertCRL(WOLFSSL_CRL*, DecodedCert*);
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */
-#endif
-
-#endif /* HAVE_CRL */
-#endif /* WOLFSSL_CRL_H */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/error-ssl.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/error-ssl.h
deleted file mode 100755
index f151c3f..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/error-ssl.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/* error-ssl.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLFSSL_ERROR_H
-#define WOLFSSL_ERROR_H
-
-#include    /* pull in wolfCrypt errors */
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-enum wolfSSL_ErrorCodes {
-    INPUT_CASE_ERROR        = -301,        /* process input state error */
-    PREFIX_ERROR            = -302,        /* bad index to key rounds  */
-    MEMORY_ERROR            = -303,        /* out of memory            */
-    VERIFY_FINISHED_ERROR   = -304,        /* verify problem on finished */
-    VERIFY_MAC_ERROR        = -305,        /* verify mac problem       */
-    PARSE_ERROR             = -306,        /* parse error on header    */
-    UNKNOWN_HANDSHAKE_TYPE  = -307,        /* weird handshake type     */
-    SOCKET_ERROR_E          = -308,        /* error state on socket    */
-    SOCKET_NODATA           = -309,        /* expected data, not there */
-    INCOMPLETE_DATA         = -310,        /* don't have enough data to
-                                              complete task            */
-    UNKNOWN_RECORD_TYPE     = -311,        /* unknown type in record hdr */
-    DECRYPT_ERROR           = -312,        /* error during decryption  */
-    FATAL_ERROR             = -313,        /* recvd alert fatal error  */
-    ENCRYPT_ERROR           = -314,        /* error during encryption  */
-    FREAD_ERROR             = -315,        /* fread problem            */
-    NO_PEER_KEY             = -316,        /* need peer's key          */
-    NO_PRIVATE_KEY          = -317,        /* need the private key     */
-    RSA_PRIVATE_ERROR       = -318,        /* error during rsa priv op */
-    NO_DH_PARAMS            = -319,        /* server missing DH params */
-    BUILD_MSG_ERROR         = -320,        /* build message failure    */
-
-    BAD_HELLO               = -321,        /* client hello malformed   */
-    DOMAIN_NAME_MISMATCH    = -322,        /* peer subject name mismatch */
-    WANT_READ               = -323,        /* want read, call again    */
-    NOT_READY_ERROR         = -324,        /* handshake layer not ready */
-    PMS_VERSION_ERROR       = -325,        /* pre m secret version error */
-    VERSION_ERROR           = -326,        /* record layer version error */
-    WANT_WRITE              = -327,        /* want write, call again   */
-    BUFFER_ERROR            = -328,        /* malformed buffer input   */
-    VERIFY_CERT_ERROR       = -329,        /* verify cert error        */
-    VERIFY_SIGN_ERROR       = -330,        /* verify sign error        */
-    CLIENT_ID_ERROR         = -331,        /* psk client identity error  */
-    SERVER_HINT_ERROR       = -332,        /* psk server hint error  */
-    PSK_KEY_ERROR           = -333,        /* psk key error  */
-    ZLIB_INIT_ERROR         = -334,        /* zlib init error  */
-    ZLIB_COMPRESS_ERROR     = -335,        /* zlib compression error  */
-    ZLIB_DECOMPRESS_ERROR   = -336,        /* zlib decompression error  */
-
-    GETTIME_ERROR           = -337,        /* gettimeofday failed ??? */
-    GETITIMER_ERROR         = -338,        /* getitimer failed ??? */
-    SIGACT_ERROR            = -339,        /* sigaction failed ??? */
-    SETITIMER_ERROR         = -340,        /* setitimer failed ??? */
-    LENGTH_ERROR            = -341,        /* record layer length error */
-    PEER_KEY_ERROR          = -342,        /* can't decode peer key */
-    ZERO_RETURN             = -343,        /* peer sent close notify */
-    SIDE_ERROR              = -344,        /* wrong client/server type */
-    NO_PEER_CERT            = -345,        /* peer didn't send key */
-    NTRU_KEY_ERROR          = -346,        /* NTRU key error  */
-    NTRU_DRBG_ERROR         = -347,        /* NTRU drbg error  */
-    NTRU_ENCRYPT_ERROR      = -348,        /* NTRU encrypt error  */
-    NTRU_DECRYPT_ERROR      = -349,        /* NTRU decrypt error  */
-    ECC_CURVETYPE_ERROR     = -350,        /* Bad ECC Curve Type */
-    ECC_CURVE_ERROR         = -351,        /* Bad ECC Curve */
-    ECC_PEERKEY_ERROR       = -352,        /* Bad Peer ECC Key */
-    ECC_MAKEKEY_ERROR       = -353,        /* Bad Make ECC Key */
-    ECC_EXPORT_ERROR        = -354,        /* Bad ECC Export Key */
-    ECC_SHARED_ERROR        = -355,        /* Bad ECC Shared Secret */
-    NOT_CA_ERROR            = -357,        /* Not a CA cert error */
-    BAD_PATH_ERROR          = -358,        /* Bad path for opendir */
-    BAD_CERT_MANAGER_ERROR  = -359,        /* Bad Cert Manager */
-    OCSP_CERT_REVOKED       = -360,        /* OCSP Certificate revoked */
-    CRL_CERT_REVOKED        = -361,        /* CRL Certificate revoked */
-    CRL_MISSING             = -362,        /* CRL Not loaded */
-    MONITOR_RUNNING_E       = -363,        /* CRL Monitor already running */
-    THREAD_CREATE_E         = -364,        /* Thread Create Error */
-    OCSP_NEED_URL           = -365,        /* OCSP need an URL for lookup */
-    OCSP_CERT_UNKNOWN       = -366,        /* OCSP responder doesn't know */
-    OCSP_LOOKUP_FAIL        = -367,        /* OCSP lookup not successful */
-    MAX_CHAIN_ERROR         = -368,        /* max chain depth exceeded */
-    COOKIE_ERROR            = -369,        /* dtls cookie error */
-    SEQUENCE_ERROR          = -370,        /* dtls sequence error */
-    SUITES_ERROR            = -371,        /* suites pointer error */
-    SSL_NO_PEM_HEADER       = -372,        /* no PEM header found */
-    OUT_OF_ORDER_E          = -373,        /* out of order message */
-    BAD_KEA_TYPE_E          = -374,        /* bad KEA type found */
-    SANITY_CIPHER_E         = -375,        /* sanity check on cipher error */
-    RECV_OVERFLOW_E         = -376,        /* RXCB returned more than rqed */
-    GEN_COOKIE_E            = -377,        /* Generate Cookie Error */
-    NO_PEER_VERIFY          = -378,        /* Need peer cert verify Error */
-    FWRITE_ERROR            = -379,        /* fwrite problem */
-    CACHE_MATCH_ERROR       = -380,        /* chache hdr match error */
-    UNKNOWN_SNI_HOST_NAME_E = -381,        /* Unrecognized host name Error */
-    UNKNOWN_MAX_FRAG_LEN_E  = -382,        /* Unrecognized max frag len Error */
-    KEYUSE_SIGNATURE_E      = -383,        /* KeyUse digSignature error */
-    KEYUSE_ENCIPHER_E       = -385,        /* KeyUse keyEncipher error */
-    EXTKEYUSE_AUTH_E        = -386,        /* ExtKeyUse server|client_auth */
-    SEND_OOB_READ_E         = -387,        /* Send Cb out of bounds read */
-    SECURE_RENEGOTIATION_E  = -388,        /* Invalid Renegotiation Info */
-    SESSION_TICKET_LEN_E    = -389,        /* Session Ticket too large */
-    SESSION_TICKET_EXPECT_E = -390,        /* Session Ticket missing   */
-    SCR_DIFFERENT_CERT_E    = -391,        /* SCR Different cert error  */
-    SESSION_SECRET_CB_E     = -392,        /* Session secret Cb fcn failure */
-    NO_CHANGE_CIPHER_E      = -393,        /* Finished before change cipher */
-    SANITY_MSG_E            = -394,        /* Sanity check on msg order error */
-    DUPLICATE_MSG_E         = -395,        /* Duplicate message error */
-    SNI_UNSUPPORTED         = -396,        /* SSL 3.0 does not support SNI */
-    SOCKET_PEER_CLOSED_E    = -397,        /* Underlying transport closed */
-
-    BAD_TICKET_KEY_CB_SZ    = -398,        /* Bad session ticket key cb size */
-    BAD_TICKET_MSG_SZ       = -399,        /* Bad session ticket msg size    */
-    BAD_TICKET_ENCRYPT      = -400,        /* Bad user ticket encrypt        */
-
-    DH_KEY_SIZE_E           = -401,        /* DH Key too small */
-
-    /* add strings to SetErrorString !!!!! */
-
-    /* begin negotiation parameter errors */
-    UNSUPPORTED_SUITE       = -500,        /* unsupported cipher suite */
-    MATCH_SUITE_ERROR       = -501         /* can't match cipher suite */
-    /* end negotiation parameter errors only 10 for now */
-    /* add strings to SetErrorString !!!!! */
-
-    /* no error stings go down here, add above negotiation errors !!!! */
-};
-
-
-#ifdef WOLFSSL_CALLBACKS
-    enum {
-        MIN_PARAM_ERR = UNSUPPORTED_SUITE,
-        MAX_PARAM_ERR = MIN_PARAM_ERR - 10
-    };
-#endif
-
-
-WOLFSSL_LOCAL
-void SetErrorString(int err, char* buff);
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */
-#endif
-
-
-#endif /* wolfSSL_ERROR_H */
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/include.am b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/include.am
deleted file mode 100755
index a02488f..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/include.am
+++ /dev/null
@@ -1,25 +0,0 @@
-# vim:ft=automake
-# All paths should be given relative to the root
-#
-
-include wolfssl/wolfcrypt/include.am
-include wolfssl/openssl/include.am
-
-EXTRA_DIST+= wolfssl/sniffer_error.rc
-
-nobase_include_HEADERS+= \
-                         wolfssl/error-ssl.h \
-                         wolfssl/ssl.h \
-                         wolfssl/sniffer_error.h \
-                         wolfssl/sniffer.h \
-                         wolfssl/callbacks.h \
-                         wolfssl/certs_test.h \
-                         wolfssl/test.h \
-                         wolfssl/version.h \
-                         wolfssl/options.h \
-                         wolfssl/ocsp.h \
-                         wolfssl/crl.h
-
-noinst_HEADERS+= \
-                         wolfssl/internal.h
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/internal.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/internal.h
deleted file mode 100755
index 99d3e9a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/internal.h
+++ /dev/null
@@ -1,2513 +0,0 @@
-/* internal.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as 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-1301, USA
- */
-
-
-#ifndef WOLFSSL_INT_H
-#define WOLFSSL_INT_H
-
-
-#include 
-#include 
-#ifdef HAVE_CRL
-    #include 
-#endif
-#include 
-#ifndef NO_DES3
-    #include 
-#endif
-#ifndef NO_HC128
-    #include 
-#endif
-#ifndef NO_RABBIT
-    #include 
-#endif
-#ifdef HAVE_CHACHA
-    #include 
-#endif
-#ifndef NO_ASN
-    #include 
-#endif
-#ifndef NO_MD5
-    #include 
-#endif
-#ifndef NO_SHA
-    #include 
-#endif
-#ifndef NO_AES
-    #include 
-#endif
-#ifdef HAVE_POLY1305
-    #include 
-#endif
-#ifdef HAVE_CAMELLIA
-    #include 
-#endif
-#include 
-#ifndef NO_HMAC
-    #include 
-#endif
-#ifndef NO_RC4
-    #include 
-#endif
-#ifdef HAVE_ECC
-    #include 
-#endif
-#ifndef NO_SHA256
-    #include 
-#endif
-#ifdef HAVE_OCSP
-    #include 
-#endif
-#ifdef WOLFSSL_SHA512
-    #include 
-#endif
-
-#ifdef HAVE_AESGCM
-    #include 
-#endif
-
-#ifdef WOLFSSL_RIPEMD
-    #include 
-#endif
-
-#include 
-
-#ifdef WOLFSSL_CALLBACKS
-    #include 
-    #include 
-#endif
-
-#ifdef USE_WINDOWS_API
-    #ifdef WOLFSSL_GAME_BUILD
-        #include "system/xtl.h"
-    #else
-        #if defined(_WIN32_WCE) || defined(WIN32_LEAN_AND_MEAN)
-            /* On WinCE winsock2.h must be included before windows.h */
-            #include 
-        #endif
-        #include 
-    #endif
-#elif defined(THREADX)
-    #ifndef SINGLE_THREADED
-        #include "tx_api.h"
-    #endif
-#elif defined(MICRIUM)
-    /* do nothing, just don't pick Unix */
-#elif defined(FREERTOS) || defined(WOLFSSL_SAFERTOS)
-    /* do nothing */
-#elif defined(EBSNET)
-    /* do nothing */
-#elif defined(FREESCALE_MQX)
-    /* do nothing */
-#elif defined(WOLFSSL_MDK_ARM)
-    #if defined(WOLFSSL_MDK5)
-         #include "cmsis_os.h"
-    #else
-        #include 
-    #endif
-#elif defined(MBED)
-#elif defined(WOLFSSL_TIRTOS)
-    /* do nothing */
-#else
-    #ifndef SINGLE_THREADED
-        #define WOLFSSL_PTHREADS
-        #include 
-    #endif
-    #if defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS)
-        #include       /* for close of BIO */
-    #endif
-#endif
-
-
-#ifdef HAVE_LIBZ
-    #include "zlib.h"
-#endif
-
-#ifdef _MSC_VER
-    /* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
-    #pragma warning(disable: 4996)
-#endif
-
-#ifdef NO_AES
-    #if !defined (ALIGN16)
-        #define ALIGN16
-    #endif
-#endif
-
-#ifdef NO_SHA
-    #define SHA_DIGEST_SIZE 20
-#endif
-
-#ifdef NO_SHA256
-    #define SHA256_DIGEST_SIZE 32
-#endif
-
-#ifdef NO_MD5
-    #define MD5_DIGEST_SIZE 16
-#endif
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-#ifdef USE_WINDOWS_API
-    typedef unsigned int SOCKET_T;
-#else
-    typedef int SOCKET_T;
-#endif
-
-
-typedef byte word24[3];
-
-/* Define or comment out the cipher suites you'd like to be compiled in
-   make sure to use at least one BUILD_SSL_xxx or BUILD_TLS_xxx is defined
-
-   When adding cipher suites, add name to cipher_names, idx to cipher_name_idx
-
-   Now that there is a maximum strength crypto build, the following BUILD_XXX
-   flags need to be divided into two groups selected by WOLFSSL_MAX_STRENGTH.
-   Those that do not use Perfect Forward Security and do not use AEAD ciphers
-   need to be switched off. Allowed suites use (EC)DHE, AES-GCM|CCM, or
-   CHACHA-POLY.
-*/
-
-/* Check that if WOLFSSL_MAX_STRENGTH is set that all the required options are
- * not turned off. */
-#if defined(WOLFSSL_MAX_STRENGTH) && \
-    ((!defined(HAVE_ECC) && (defined(NO_DH) || defined(NO_RSA))) || \
-     (!defined(HAVE_AESGCM) && !defined(HAVE_AESCCM) && \
-      (!defined(HAVE_POLY1305) || !defined(HAVE_CHACHA))) || \
-     (defined(NO_SHA256) && !defined(WOLFSSL_SHA384)) || \
-     !defined(NO_OLD_TLS))
-
-    #error "You are trying to build max strength with requirements disabled."
-#endif
-
-#ifndef WOLFSSL_MAX_STRENGTH
-
-    #if !defined(NO_RSA) && !defined(NO_RC4)
-        #if !defined(NO_SHA)
-            #define BUILD_SSL_RSA_WITH_RC4_128_SHA
-        #endif
-        #if !defined(NO_MD5)
-            #define BUILD_SSL_RSA_WITH_RC4_128_MD5
-        #endif
-        #if !defined(NO_TLS) && defined(HAVE_NTRU) && !defined(NO_SHA)
-            #define BUILD_TLS_NTRU_RSA_WITH_RC4_128_SHA
-        #endif
-    #endif
-
-    #if !defined(NO_RSA) && !defined(NO_DES3)
-        #if !defined(NO_SHA)
-            #define BUILD_SSL_RSA_WITH_3DES_EDE_CBC_SHA
-            #if !defined(NO_TLS) && defined(HAVE_NTRU)
-                    #define BUILD_TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA
-            #endif
-        #endif
-    #endif
-
-    #if !defined(NO_RSA) && !defined(NO_AES) && !defined(NO_TLS)
-        #if !defined(NO_SHA)
-            #define BUILD_TLS_RSA_WITH_AES_128_CBC_SHA
-            #define BUILD_TLS_RSA_WITH_AES_256_CBC_SHA
-            #if defined(HAVE_NTRU)
-                    #define BUILD_TLS_NTRU_RSA_WITH_AES_128_CBC_SHA
-                    #define BUILD_TLS_NTRU_RSA_WITH_AES_256_CBC_SHA
-            #endif
-        #endif
-        #if !defined (NO_SHA256)
-            #define BUILD_TLS_RSA_WITH_AES_128_CBC_SHA256
-            #define BUILD_TLS_RSA_WITH_AES_256_CBC_SHA256
-        #endif
-        #if defined (HAVE_AESGCM)
-            #define BUILD_TLS_RSA_WITH_AES_128_GCM_SHA256
-            #if defined (WOLFSSL_SHA384)
-                #define BUILD_TLS_RSA_WITH_AES_256_GCM_SHA384
-            #endif
-        #endif
-        #if defined (HAVE_AESCCM)
-            #define BUILD_TLS_RSA_WITH_AES_128_CCM_8
-            #define BUILD_TLS_RSA_WITH_AES_256_CCM_8
-        #endif
-        #if defined(HAVE_BLAKE2)
-            #define BUILD_TLS_RSA_WITH_AES_128_CBC_B2B256
-            #define BUILD_TLS_RSA_WITH_AES_256_CBC_B2B256
-        #endif
-    #endif
-
-    #if defined(HAVE_CAMELLIA) && !defined(NO_TLS)
-        #ifndef NO_RSA
-          #if !defined(NO_SHA)
-            #define BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA
-            #define BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA
-          #endif
-            #ifndef NO_SHA256
-                #define BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256
-                #define BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256
-            #endif
-            #if !defined(NO_DH)
-              #if !defined(NO_SHA)
-                #define BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
-                #define BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
-              #endif
-                #ifndef NO_SHA256
-                    #define BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
-                    #define BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256
-                #endif
-            #endif
-        #endif
-    #endif
-
-    #if !defined(NO_PSK) && !defined(NO_AES) && !defined(NO_TLS)
-        #if !defined(NO_SHA)
-            #define BUILD_TLS_PSK_WITH_AES_128_CBC_SHA
-            #define BUILD_TLS_PSK_WITH_AES_256_CBC_SHA
-        #endif
-        #ifndef NO_SHA256
-            #define BUILD_TLS_PSK_WITH_AES_128_CBC_SHA256
-            #ifdef HAVE_AESGCM
-                #define BUILD_TLS_PSK_WITH_AES_128_GCM_SHA256
-            #endif
-            #ifdef HAVE_AESCCM
-                #define BUILD_TLS_PSK_WITH_AES_128_CCM_8
-                #define BUILD_TLS_PSK_WITH_AES_256_CCM_8
-                #define BUILD_TLS_PSK_WITH_AES_128_CCM
-                #define BUILD_TLS_PSK_WITH_AES_256_CCM
-            #endif
-        #endif
-        #ifdef WOLFSSL_SHA384
-            #define BUILD_TLS_PSK_WITH_AES_256_CBC_SHA384
-            #ifdef HAVE_AESGCM
-                #define BUILD_TLS_PSK_WITH_AES_256_GCM_SHA384
-            #endif
-        #endif
-    #endif
-
-    #if !defined(NO_TLS) && defined(HAVE_NULL_CIPHER)
-        #if !defined(NO_RSA)
-            #if !defined(NO_SHA)
-                #define BUILD_TLS_RSA_WITH_NULL_SHA
-            #endif
-            #ifndef NO_SHA256
-                #define BUILD_TLS_RSA_WITH_NULL_SHA256
-            #endif
-        #endif
-        #if !defined(NO_PSK)
-            #if !defined(NO_SHA)
-                #define BUILD_TLS_PSK_WITH_NULL_SHA
-            #endif
-            #ifndef NO_SHA256
-                #define BUILD_TLS_PSK_WITH_NULL_SHA256
-            #endif
-            #ifdef WOLFSSL_SHA384
-                #define BUILD_TLS_PSK_WITH_NULL_SHA384
-            #endif
-        #endif
-    #endif
-
-    #if !defined(NO_HC128) && !defined(NO_RSA) && !defined(NO_TLS)
-        #define BUILD_TLS_RSA_WITH_HC_128_MD5
-        #if !defined(NO_SHA)
-            #define BUILD_TLS_RSA_WITH_HC_128_SHA
-        #endif
-        #if defined(HAVE_BLAKE2)
-            #define BUILD_TLS_RSA_WITH_HC_128_B2B256
-        #endif
-    #endif
-
-    #if !defined(NO_RABBIT) && !defined(NO_TLS) && !defined(NO_RSA)
-        #if !defined(NO_SHA)
-            #define BUILD_TLS_RSA_WITH_RABBIT_SHA
-        #endif
-    #endif
-
-    #if !defined(NO_DH) && !defined(NO_AES) && !defined(NO_TLS) && \
-        !defined(NO_RSA)
-
-        #if !defined(NO_SHA)
-            #define BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA
-            #define BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA
-        #endif
-        #if !defined(NO_SHA256)
-            #define BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
-            #define BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
-        #endif
-    #endif
-
-    #if defined(HAVE_ANON) && !defined(NO_TLS) && !defined(NO_DH) && \
-        !defined(NO_AES) && !defined(NO_SHA)
-        #define BUILD_TLS_DH_anon_WITH_AES_128_CBC_SHA
-    #endif
-
-    #if !defined(NO_DH) && !defined(NO_PSK) && !defined(NO_TLS)
-        #ifndef NO_SHA256
-            #define BUILD_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256
-            #ifdef HAVE_NULL_CIPHER
-                #define BUILD_TLS_DHE_PSK_WITH_NULL_SHA256
-            #endif
-        #endif
-        #ifdef WOLFSSL_SHA384
-            #define BUILD_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384
-            #ifdef HAVE_NULL_CIPHER
-                #define BUILD_TLS_DHE_PSK_WITH_NULL_SHA384
-            #endif
-        #endif
-    #endif
-
-    #if defined(HAVE_ECC) && !defined(NO_TLS)
-        #if !defined(NO_AES)
-            #if !defined(NO_SHA)
-                #if !defined(NO_RSA)
-                    #define BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
-                    #define BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
-                    #define BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
-                    #define BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
-                #endif
-
-                #define BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
-                #define BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
-
-                #define BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
-                #define BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
-            #endif /* NO_SHA */
-            #ifndef NO_SHA256
-                #if !defined(NO_RSA)
-                    #define BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
-                    #define BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
-                #endif
-                #define BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
-                #define BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
-            #endif
-
-            #ifdef WOLFSSL_SHA384
-                #if !defined(NO_RSA)
-                    #define BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
-                    #define BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
-                #endif
-                #define BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
-                #define BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
-            #endif
-
-            #if defined (HAVE_AESGCM)
-                #if !defined(NO_RSA)
-                    #define BUILD_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
-                    #if defined(WOLFSSL_SHA384)
-                        #define BUILD_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
-                    #endif
-                #endif
-
-                #define BUILD_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
-
-                #if defined(WOLFSSL_SHA384)
-                    #define BUILD_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
-                #endif
-            #endif
-        #endif /* NO_AES */
-        #if !defined(NO_RC4)
-            #if !defined(NO_SHA)
-                #if !defined(NO_RSA)
-                    #define BUILD_TLS_ECDHE_RSA_WITH_RC4_128_SHA
-                    #define BUILD_TLS_ECDH_RSA_WITH_RC4_128_SHA
-                #endif
-
-                #define BUILD_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
-                #define BUILD_TLS_ECDH_ECDSA_WITH_RC4_128_SHA
-            #endif
-        #endif
-        #if !defined(NO_DES3)
-            #ifndef NO_SHA
-                #if !defined(NO_RSA)
-                    #define BUILD_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
-                    #define BUILD_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
-                #endif
-
-                #define BUILD_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
-                #define BUILD_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
-            #endif /* NO_SHA */
-        #endif
-    #endif
-
-#endif /* !WOLFSSL_MAX_STRENGTH */
-
-#if !defined(NO_DH) && !defined(NO_AES) && !defined(NO_TLS) && \
-    !defined(NO_RSA) && defined(HAVE_AESGCM)
-
-    #ifndef NO_SHA256
-        #define BUILD_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
-    #endif
-
-    #ifdef WOLFSSL_SHA384
-        #define BUILD_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
-    #endif
-#endif
-
-#if !defined(NO_DH) && !defined(NO_PSK) && !defined(NO_TLS)
-    #ifndef NO_SHA256
-        #ifdef HAVE_AESGCM
-            #define BUILD_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256
-        #endif
-        #ifdef HAVE_AESCCM
-            #define BUILD_TLS_DHE_PSK_WITH_AES_128_CCM
-            #define BUILD_TLS_DHE_PSK_WITH_AES_256_CCM
-        #endif
-    #endif
-    #if defined(WOLFSSL_SHA384) && defined(HAVE_AESGCM)
-        #define BUILD_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384
-    #endif
-#endif
-
-#if defined(HAVE_ECC) && !defined(NO_TLS) && !defined(NO_AES)
-    #ifdef HAVE_AESGCM
-        #ifndef NO_SHA256
-            #define BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
-            #ifndef NO_RSA
-                #define BUILD_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
-            #endif
-        #endif
-        #ifdef WOLFSSL_SHA384
-            #define BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
-            #ifndef NO_RSA
-                #define BUILD_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
-            #endif
-        #endif
-    #endif
-    #if defined(HAVE_AESCCM) && !defined(NO_SHA256)
-        #define BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
-        #define BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8
-    #endif
-#endif
-
-#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305) && !defined(NO_SHA256)
-    #ifdef HAVE_ECC
-        #define BUILD_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
-        #ifndef NO_RSA
-            #define BUILD_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
-        #endif
-    #endif
-    #if !defined(NO_DH) && !defined(NO_RSA)
-        #define BUILD_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256
-    #endif
-#endif
-
-
-#if defined(BUILD_SSL_RSA_WITH_RC4_128_SHA) || \
-    defined(BUILD_SSL_RSA_WITH_RC4_128_MD5)
-    #define BUILD_ARC4
-#endif
-
-#if defined(BUILD_SSL_RSA_WITH_3DES_EDE_CBC_SHA)
-    #define BUILD_DES3
-#endif
-
-#if defined(BUILD_TLS_RSA_WITH_AES_128_CBC_SHA) || \
-    defined(BUILD_TLS_RSA_WITH_AES_256_CBC_SHA) || \
-    defined(BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256)
-    #undef  BUILD_AES
-    #define BUILD_AES
-#endif
-
-#if defined(BUILD_TLS_RSA_WITH_AES_128_GCM_SHA256) || \
-    defined(BUILD_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256) || \
-    defined(BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256) || \
-    defined(BUILD_TLS_PSK_WITH_AES_128_GCM_SHA256)
-    #define BUILD_AESGCM
-#endif
-
-#if defined(BUILD_TLS_RSA_WITH_HC_128_SHA) || \
-    defined(BUILD_TLS_RSA_WITH_HC_128_MD5) || \
-    defined(BUILD_TLS_RSA_WITH_HC_128_B2B256)
-    #define BUILD_HC128
-#endif
-
-#if defined(BUILD_TLS_RSA_WITH_RABBIT_SHA)
-    #define BUILD_RABBIT
-#endif
-
-#ifdef NO_DES3
-    #define DES_BLOCK_SIZE 8
-#else
-    #undef  BUILD_DES3
-    #define BUILD_DES3
-#endif
-
-#ifdef NO_AES
-    #define AES_BLOCK_SIZE 16
-#else
-    #undef  BUILD_AES
-    #define BUILD_AES
-#endif
-
-#ifndef NO_RC4
-    #undef  BUILD_ARC4
-    #define BUILD_ARC4
-#endif
-
-#ifdef HAVE_CHACHA
-    #define CHACHA20_BLOCK_SIZE 16
-#endif
-
-#if defined(WOLFSSL_MAX_STRENGTH) || \
-    defined(HAVE_AESGCM) || defined(HAVE_AESCCM) || \
-    (defined(HAVE_CHACHA) && defined(HAVE_POLY1305))
-
-    #define HAVE_AEAD
-#endif
-
-#if defined(WOLFSSL_MAX_STRENGTH) || \
-    defined(HAVE_ECC) || !defined(NO_DH)
-
-    #define HAVE_PFS
-#endif
-
-
-/* actual cipher values, 2nd byte */
-enum {
-    TLS_DHE_RSA_WITH_AES_256_CBC_SHA  = 0x39,
-    TLS_DHE_RSA_WITH_AES_128_CBC_SHA  = 0x33,
-    TLS_DH_anon_WITH_AES_128_CBC_SHA  = 0x34,
-    TLS_RSA_WITH_AES_256_CBC_SHA      = 0x35,
-    TLS_RSA_WITH_AES_128_CBC_SHA      = 0x2F,
-    TLS_RSA_WITH_NULL_SHA             = 0x02,
-    TLS_PSK_WITH_AES_256_CBC_SHA      = 0x8d,
-    TLS_PSK_WITH_AES_128_CBC_SHA256   = 0xae,
-    TLS_PSK_WITH_AES_256_CBC_SHA384   = 0xaf,
-    TLS_PSK_WITH_AES_128_CBC_SHA      = 0x8c,
-    TLS_PSK_WITH_NULL_SHA256          = 0xb0,
-    TLS_PSK_WITH_NULL_SHA384          = 0xb1,
-    TLS_PSK_WITH_NULL_SHA             = 0x2c,
-    SSL_RSA_WITH_RC4_128_SHA          = 0x05,
-    SSL_RSA_WITH_RC4_128_MD5          = 0x04,
-    SSL_RSA_WITH_3DES_EDE_CBC_SHA     = 0x0A,
-
-    /* ECC suites, first byte is 0xC0 (ECC_BYTE) */
-    TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA    = 0x14,
-    TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA    = 0x13,
-    TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA  = 0x0A,
-    TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA  = 0x09,
-    TLS_ECDHE_RSA_WITH_RC4_128_SHA        = 0x11,
-    TLS_ECDHE_ECDSA_WITH_RC4_128_SHA      = 0x07,
-    TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA   = 0x12,
-    TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA = 0x08,
-    TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256   = 0x27,
-    TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 = 0x23,
-    TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384   = 0x28,
-    TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 = 0x24,
-
-    /* static ECDH, first byte is 0xC0 (ECC_BYTE) */
-    TLS_ECDH_RSA_WITH_AES_256_CBC_SHA    = 0x0F,
-    TLS_ECDH_RSA_WITH_AES_128_CBC_SHA    = 0x0E,
-    TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA  = 0x05,
-    TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA  = 0x04,
-    TLS_ECDH_RSA_WITH_RC4_128_SHA        = 0x0C,
-    TLS_ECDH_ECDSA_WITH_RC4_128_SHA      = 0x02,
-    TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA   = 0x0D,
-    TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA = 0x03,
-    TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256   = 0x29,
-    TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 = 0x25,
-    TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384   = 0x2A,
-    TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 = 0x26,
-
-    /* wolfSSL extension - eSTREAM */
-    TLS_RSA_WITH_HC_128_MD5       = 0xFB,
-    TLS_RSA_WITH_HC_128_SHA       = 0xFC,
-    TLS_RSA_WITH_RABBIT_SHA       = 0xFD,
-
-    /* wolfSSL extension - Blake2b 256 */
-    TLS_RSA_WITH_AES_128_CBC_B2B256   = 0xF8,
-    TLS_RSA_WITH_AES_256_CBC_B2B256   = 0xF9,
-    TLS_RSA_WITH_HC_128_B2B256        = 0xFA,   /* eSTREAM too */
-
-    /* wolfSSL extension - NTRU */
-    TLS_NTRU_RSA_WITH_RC4_128_SHA      = 0xe5,
-    TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA = 0xe6,
-    TLS_NTRU_RSA_WITH_AES_128_CBC_SHA  = 0xe7,  /* clashes w/official SHA-256 */
-    TLS_NTRU_RSA_WITH_AES_256_CBC_SHA  = 0xe8,
-
-    /* SHA256 */
-    TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 = 0x6b,
-    TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 = 0x67,
-    TLS_RSA_WITH_AES_256_CBC_SHA256     = 0x3d,
-    TLS_RSA_WITH_AES_128_CBC_SHA256     = 0x3c,
-    TLS_RSA_WITH_NULL_SHA256            = 0x3b,
-    TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 = 0xb2,
-    TLS_DHE_PSK_WITH_NULL_SHA256        = 0xb4,
-
-    /* SHA384 */
-    TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 = 0xb3,
-    TLS_DHE_PSK_WITH_NULL_SHA384        = 0xb5,
-
-    /* AES-GCM */
-    TLS_RSA_WITH_AES_128_GCM_SHA256          = 0x9c,
-    TLS_RSA_WITH_AES_256_GCM_SHA384          = 0x9d,
-    TLS_DHE_RSA_WITH_AES_128_GCM_SHA256      = 0x9e,
-    TLS_DHE_RSA_WITH_AES_256_GCM_SHA384      = 0x9f,
-    TLS_PSK_WITH_AES_128_GCM_SHA256          = 0xa8,
-    TLS_PSK_WITH_AES_256_GCM_SHA384          = 0xa9,
-    TLS_DHE_PSK_WITH_AES_128_GCM_SHA256      = 0xaa,
-    TLS_DHE_PSK_WITH_AES_256_GCM_SHA384      = 0xab,
-
-    /* ECC AES-GCM, first byte is 0xC0 (ECC_BYTE) */
-    TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256  = 0x2b,
-    TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384  = 0x2c,
-    TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256   = 0x2d,
-    TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384   = 0x2e,
-    TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256    = 0x2f,
-    TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384    = 0x30,
-    TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256     = 0x31,
-    TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384     = 0x32,
-
-    /* AES-CCM, first byte is 0xC0 but isn't ECC,
-     * also, in some of the other AES-CCM suites
-     * there will be second byte number conflicts
-     * with non-ECC AES-GCM */
-    TLS_RSA_WITH_AES_128_CCM_8         = 0xa0,
-    TLS_RSA_WITH_AES_256_CCM_8         = 0xa1,
-    TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 = 0xae,
-    TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 = 0xaf,
-    TLS_PSK_WITH_AES_128_CCM           = 0xa4,
-    TLS_PSK_WITH_AES_256_CCM           = 0xa5,
-    TLS_PSK_WITH_AES_128_CCM_8         = 0xa8,
-    TLS_PSK_WITH_AES_256_CCM_8         = 0xa9,
-    TLS_DHE_PSK_WITH_AES_128_CCM       = 0xa6,
-    TLS_DHE_PSK_WITH_AES_256_CCM       = 0xa7,
-
-    /* Camellia */
-    TLS_RSA_WITH_CAMELLIA_128_CBC_SHA        = 0x41,
-    TLS_RSA_WITH_CAMELLIA_256_CBC_SHA        = 0x84,
-    TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256     = 0xba,
-    TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256     = 0xc0,
-    TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA    = 0x45,
-    TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA    = 0x88,
-    TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xbe,
-    TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 = 0xc4,
-
-    TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256   = 0x13,
-    TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 = 0x14,
-    TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256     = 0x15,
-
-    /* Renegotiation Indication Extension Special Suite */
-    TLS_EMPTY_RENEGOTIATION_INFO_SCSV        = 0xff
-};
-
-
-#ifndef WOLFSSL_SESSION_TIMEOUT
-    #define WOLFSSL_SESSION_TIMEOUT 500
-    /* default session resumption cache timeout in seconds */
-#endif
-
-
-enum Misc {
-    ECC_BYTE    =  0xC0,           /* ECC first cipher suite byte */
-    CHACHA_BYTE = 0xCC,            /* ChaCha first cipher suite */
-
-    SEND_CERT       = 1,
-    SEND_BLANK_CERT = 2,
-
-    DTLS_MAJOR      = 0xfe,     /* DTLS major version number */
-    DTLS_MINOR      = 0xff,     /* DTLS minor version number */
-    DTLSv1_2_MINOR  = 0xfd,     /* DTLS minor version number */
-    SSLv3_MAJOR     = 3,        /* SSLv3 and TLSv1+  major version number */
-    SSLv3_MINOR     = 0,        /* TLSv1   minor version number */
-    TLSv1_MINOR     = 1,        /* TLSv1   minor version number */
-    TLSv1_1_MINOR   = 2,        /* TLSv1_1 minor version number */
-    TLSv1_2_MINOR   = 3,        /* TLSv1_2 minor version number */
-    OLD_HELLO_ID    = 0x01,     /* SSLv2 Client Hello Indicator */
-    INVALID_BYTE    = 0xff,     /* Used to initialize cipher specs values */
-    NO_COMPRESSION  =  0,
-    ZLIB_COMPRESSION = 221,     /* wolfSSL zlib compression */
-    HELLO_EXT_SIG_ALGO = 13,    /* ID for the sig_algo hello extension */
-    SECRET_LEN      = 48,       /* pre RSA and all master */
-    ENCRYPT_LEN     = 512,      /* allow 4096 bit static buffer */
-    SIZEOF_SENDER   =  4,       /* clnt or srvr           */
-    FINISHED_SZ     = 36,       /* MD5_DIGEST_SIZE + SHA_DIGEST_SIZE */
-    MAX_RECORD_SIZE = 16384,    /* 2^14, max size by standard */
-    MAX_MSG_EXTRA   = 38 + MAX_DIGEST_SIZE,
-                                /* max added to msg, mac + pad  from */
-                                /* RECORD_HEADER_SZ + BLOCK_SZ (pad) + Max
-                                   digest sz + BLOC_SZ (iv) + pad byte (1) */
-    MAX_COMP_EXTRA  = 1024,     /* max compression extra */
-    MAX_MTU         = 1500,     /* max expected MTU */
-    MAX_UDP_SIZE    = 8192 - 100, /* was MAX_MTU - 100 */
-    MAX_DH_SZ       = 1036,     /* 4096 p, pub, g + 2 byte size for each */
-    MAX_STR_VERSION = 8,        /* string rep of protocol version */
-
-    PAD_MD5        = 48,       /* pad length for finished */
-    PAD_SHA        = 40,       /* pad length for finished */
-    MAX_PAD_SIZE   = 256,      /* maximum length of padding */
-    COMPRESS_DUMMY_SIZE = 64,  /* compression dummy round size */
-    COMPRESS_CONSTANT   = 13,  /* compression calc constant */
-    COMPRESS_UPPER      = 55,  /* compression calc numerator */
-    COMPRESS_LOWER      = 64,  /* compression calc denominator */
-
-    PEM_LINE_LEN   = 80,       /* PEM line max + fudge */
-    LENGTH_SZ      =  2,       /* length field for HMAC, data only */
-    VERSION_SZ     =  2,       /* length of proctocol version */
-    SEQ_SZ         =  8,       /* 64 bit sequence number  */
-    BYTE3_LEN      =  3,       /* up to 24 bit byte lengths */
-    ALERT_SIZE     =  2,       /* level + description     */
-    VERIFY_HEADER  =  2,       /* always use 2 bytes      */
-    EXT_ID_SZ      =  2,       /* always use 2 bytes      */
-    MAX_DH_SIZE    = 513,      /* 4096 bit plus possible leading 0 */
-    SESSION_HINT_SZ = 4,       /* session timeout hint */
-
-    MAX_SUITE_SZ = 200,        /* 100 suites for now! */
-    RAN_LEN      = 32,         /* random length           */
-    SEED_LEN     = RAN_LEN * 2, /* tls prf seed length    */
-    ID_LEN       = 32,         /* session id length       */
-    MAX_COOKIE_LEN = 32,       /* max dtls cookie size    */
-    COOKIE_SZ    = 20,         /* use a 20 byte cookie    */
-    SUITE_LEN    =  2,         /* cipher suite sz length  */
-    ENUM_LEN     =  1,         /* always a byte           */
-    OPAQUE8_LEN  =  1,         /* 1 byte                  */
-    OPAQUE16_LEN =  2,         /* 2 bytes                 */
-    OPAQUE24_LEN =  3,         /* 3 bytes                 */
-    OPAQUE32_LEN =  4,         /* 4 bytes                 */
-    COMP_LEN     =  1,         /* compression length      */
-    CURVE_LEN    =  2,         /* ecc named curve length  */
-    SERVER_ID_LEN = 20,        /* server session id length  */
-    
-    HANDSHAKE_HEADER_SZ   = 4,  /* type + length(3)        */
-    RECORD_HEADER_SZ      = 5,  /* type + version + len(2) */
-    CERT_HEADER_SZ        = 3,  /* always 3 bytes          */
-    REQ_HEADER_SZ         = 2,  /* cert request header sz  */
-    HINT_LEN_SZ           = 2,  /* length of hint size field */
-    TRUNCATED_HMAC_SZ     = 10, /* length of hmac w/ truncated hmac extension */
-    HELLO_EXT_TYPE_SZ     = 2,  /* length of a hello extension type */
-    HELLO_EXT_SZ          = 8,  /* total length of the lazy hello extensions */
-    HELLO_EXT_LEN         = 6,  /* length of the lazy hello extensions */
-    HELLO_EXT_SIGALGO_SZ  = 2,  /* length of signature algo extension  */
-    HELLO_EXT_SIGALGO_MAX = 32, /* number of items in the signature algo list */
-
-    DTLS_HANDSHAKE_HEADER_SZ = 12, /* normal + seq(2) + offset(3) + length(3) */
-    DTLS_RECORD_HEADER_SZ    = 13, /* normal + epoch(2) + seq_num(6) */
-    DTLS_HANDSHAKE_EXTRA     = 8,  /* diff from normal */
-    DTLS_RECORD_EXTRA        = 8,  /* diff from normal */
-    DTLS_HANDSHAKE_SEQ_SZ    = 2,  /* handshake header sequence number */
-    DTLS_HANDSHAKE_FRAG_SZ   = 3,  /* fragment offset and length are 24 bit */
-    DTLS_POOL_SZ             = 5,  /* buffers to hold in the retry pool */
-
-    FINISHED_LABEL_SZ   = 15,  /* TLS finished label size */
-    TLS_FINISHED_SZ     = 12,  /* TLS has a shorter size  */
-    MASTER_LABEL_SZ     = 13,  /* TLS master secret label sz */
-    KEY_LABEL_SZ        = 13,  /* TLS key block expansion sz */
-    MAX_PRF_HALF        = 256, /* Maximum half secret len */
-    MAX_PRF_LABSEED     = 128, /* Maximum label + seed len */
-    MAX_PRF_DIG         = 224, /* Maximum digest len      */
-    MAX_REQUEST_SZ      = 256, /* Maximum cert req len (no auth yet */
-    SESSION_FLUSH_COUNT = 256, /* Flush session cache unless user turns off */ 
-
-    RC4_KEY_SIZE        = 16,  /* always 128bit           */
-    DES_KEY_SIZE        =  8,  /* des                     */
-    DES3_KEY_SIZE       = 24,  /* 3 des ede               */
-    DES_IV_SIZE         = DES_BLOCK_SIZE,
-    AES_256_KEY_SIZE    = 32,  /* for 256 bit             */
-    AES_192_KEY_SIZE    = 24,  /* for 192 bit             */
-    AES_IV_SIZE         = 16,  /* always block size       */
-    AES_128_KEY_SIZE    = 16,  /* for 128 bit             */
-
-    AEAD_SEQ_OFFSET     = 4,        /* Auth Data: Sequence number */
-    AEAD_TYPE_OFFSET    = 8,        /* Auth Data: Type            */
-    AEAD_VMAJ_OFFSET    = 9,        /* Auth Data: Major Version   */
-    AEAD_VMIN_OFFSET    = 10,       /* Auth Data: Minor Version   */
-    AEAD_LEN_OFFSET     = 11,       /* Auth Data: Length          */
-    AEAD_AUTH_DATA_SZ   = 13,       /* Size of the data to authenticate */
-    AEAD_IMP_IV_SZ      = 4,        /* Size of the implicit IV     */
-    AEAD_EXP_IV_SZ      = 8,        /* Size of the explicit IV     */
-    AEAD_NONCE_SZ       = AEAD_EXP_IV_SZ + AEAD_IMP_IV_SZ,
-
-    AES_GCM_AUTH_SZ     = 16, /* AES-GCM Auth Tag length    */
-    AES_CCM_16_AUTH_SZ  = 16, /* AES-CCM-16 Auth Tag length */
-    AES_CCM_8_AUTH_SZ   = 8,  /* AES-CCM-8 Auth Tag Length  */
-
-    CAMELLIA_128_KEY_SIZE = 16, /* for 128 bit */
-    CAMELLIA_192_KEY_SIZE = 24, /* for 192 bit */
-    CAMELLIA_256_KEY_SIZE = 32, /* for 256 bit */
-    CAMELLIA_IV_SIZE      = 16, /* always block size */
-
-    CHACHA20_256_KEY_SIZE = 32,  /* for 256 bit             */
-    CHACHA20_128_KEY_SIZE = 16,  /* for 128 bit             */
-    CHACHA20_IV_SIZE      =  8,  /* 64 bits for iv          */
-
-    POLY1305_AUTH_SZ    = 16,  /* 128 bits                */
-
-    HC_128_KEY_SIZE     = 16,  /* 128 bits                */
-    HC_128_IV_SIZE      = 16,  /* also 128 bits           */
-
-    RABBIT_KEY_SIZE     = 16,  /* 128 bits                */
-    RABBIT_IV_SIZE      =  8,  /* 64 bits for iv          */
-
-    EVP_SALT_SIZE       =  8,  /* evp salt size 64 bits   */
-
-    ECDHE_SIZE          = 32,  /* ECHDE server size defaults to 256 bit */
-    MAX_EXPORT_ECC_SZ   = 256, /* Export ANS X9.62 max future size */
-
-    MAX_HELLO_SZ       = 128,  /* max client or server hello */
-    MAX_CERT_VERIFY_SZ = 1024, /* max   */
-    CLIENT_HELLO_FIRST =  35,  /* Protocol + RAN_LEN + sizeof(id_len) */
-    MAX_SUITE_NAME     =  48,  /* maximum length of cipher suite string */
-
-    DTLS_TIMEOUT_INIT       =  1, /* default timeout init for DTLS receive  */
-    DTLS_TIMEOUT_MAX        = 64, /* default max timeout for DTLS receive */
-    DTLS_TIMEOUT_MULTIPLIER =  2, /* default timeout multiplier for DTLS recv */
-
-    MAX_PSK_ID_LEN     = 128,  /* max psk identity/hint supported */
-    MAX_PSK_KEY_LEN    =  64,  /* max psk key supported */
-
-    MAX_WOLFSSL_FILE_SIZE = 1024 * 1024 * 4,  /* 4 mb file size alloc limit */
-
-#ifdef FORTRESS
-    MAX_EX_DATA        =   3,  /* allow for three items of ex_data */
-#endif
-
-    MAX_X509_SIZE      = 2048, /* max static x509 buffer size */
-    CERT_MIN_SIZE      =  256, /* min PEM cert size with header/footer */
-    MAX_FILENAME_SZ    =  256, /* max file name length */
-    FILE_BUFFER_SIZE   = 1024, /* default static file buffer size for input,
-                                  will use dynamic buffer if not big enough */
-
-    MAX_NTRU_PUB_KEY_SZ = 1027, /* NTRU max for now */
-    MAX_NTRU_ENCRYPT_SZ = 1027, /* NTRU max for now */
-    MAX_NTRU_BITS       =  256, /* max symmetric bit strength */
-    NO_SNIFF           =   0,  /* not sniffing */
-    SNIFF              =   1,  /* currently sniffing */
-
-    HASH_SIG_SIZE      =   2,  /* default SHA1 RSA */
-
-    NO_CAVIUM_DEVICE   =  -2,  /* invalid cavium device id */
-
-    NO_COPY            =   0,  /* should we copy static buffer for write */
-    COPY               =   1   /* should we copy static buffer for write */
-};
-
-
-#ifndef WOLFSSL_MIN_DHKEY_BITS
-    #ifdef WOLFSSL_MAX_STRENGTH
-        #define WOLFSSL_MIN_DHKEY_BITS 2048
-    #else
-        #define WOLFSSL_MIN_DHKEY_BITS 1024
-    #endif
-#endif
-#if (WOLFSSL_MIN_DHKEY_BITS % 8)
-    #error DH minimum bit size must be multiple of 8
-#endif
-#if (WOLFSSL_MIN_DHKEY_BITS > 16000)
-    #error DH minimum bit size must not be greater than 16000
-#endif
-#define MIN_DHKEY_SZ (WOLFSSL_MIN_DHKEY_BITS / 8)
-
-
-#ifdef SESSION_INDEX
-/* Shift values for making a session index */
-#define SESSIDX_ROW_SHIFT 4
-#define SESSIDX_IDX_MASK  0x0F
-#endif
-
-
-/* max cert chain peer depth */
-#ifndef MAX_CHAIN_DEPTH
-    #define MAX_CHAIN_DEPTH 9
-#endif
-
-#ifndef SESSION_TICKET_LEN
-    #define SESSION_TICKET_LEN 256
-#endif
-
-#ifndef SESSION_TICKET_HINT_DEFAULT
-    #define SESSION_TICKET_HINT_DEFAULT 300
-#endif
-
-
-/* don't use extra 3/4k stack space unless need to */
-#ifdef HAVE_NTRU
-    #define MAX_ENCRYPT_SZ MAX_NTRU_ENCRYPT_SZ
-#else
-    #define MAX_ENCRYPT_SZ ENCRYPT_LEN
-#endif
-
-
-/* states */
-enum states {
-    NULL_STATE = 0,
-
-    SERVER_HELLOVERIFYREQUEST_COMPLETE,
-    SERVER_HELLO_COMPLETE,
-    SERVER_CERT_COMPLETE,
-    SERVER_KEYEXCHANGE_COMPLETE,
-    SERVER_HELLODONE_COMPLETE,
-    SERVER_FINISHED_COMPLETE,
-
-    CLIENT_HELLO_COMPLETE,
-    CLIENT_KEYEXCHANGE_COMPLETE,
-    CLIENT_FINISHED_COMPLETE,
-
-    HANDSHAKE_DONE
-};
-
-
-#if defined(__GNUC__)
-    #define WOLFSSL_PACK __attribute__ ((packed))
-#else
-    #define WOLFSSL_PACK
-#endif
-
-/* SSL Version */
-typedef struct ProtocolVersion {
-    byte major;
-    byte minor;
-} WOLFSSL_PACK ProtocolVersion;
-
-
-WOLFSSL_LOCAL ProtocolVersion MakeSSLv3(void);
-WOLFSSL_LOCAL ProtocolVersion MakeTLSv1(void);
-WOLFSSL_LOCAL ProtocolVersion MakeTLSv1_1(void);
-WOLFSSL_LOCAL ProtocolVersion MakeTLSv1_2(void);
-
-#ifdef WOLFSSL_DTLS
-    WOLFSSL_LOCAL ProtocolVersion MakeDTLSv1(void);
-    WOLFSSL_LOCAL ProtocolVersion MakeDTLSv1_2(void);
-#endif
-
-
-enum BIO_TYPE {
-    BIO_BUFFER = 1,
-    BIO_SOCKET = 2,
-    BIO_SSL    = 3,
-    BIO_MEMORY = 4
-};
-
-
-/* wolfSSL BIO_METHOD type */
-struct WOLFSSL_BIO_METHOD {
-    byte type;               /* method type */
-};
-
-
-/* wolfSSL BIO type */
-struct WOLFSSL_BIO {
-    byte        type;          /* method type */
-    byte        close;         /* close flag */
-    byte        eof;           /* eof flag */
-    WOLFSSL*     ssl;           /* possible associated ssl */
-    byte*       mem;           /* memory buffer */
-    int         memLen;        /* memory buffer length */
-    int         fd;            /* possible file descriptor */
-    WOLFSSL_BIO* prev;          /* previous in chain */
-    WOLFSSL_BIO* next;          /* next in chain */
-};
-
-
-/* wolfSSL method type */
-struct WOLFSSL_METHOD {
-    ProtocolVersion version;
-    byte            side;         /* connection side, server or client */
-    byte            downgrade;    /* whether to downgrade version, default no */
-};
-
-
-/* defautls to client */
-WOLFSSL_LOCAL void InitSSL_Method(WOLFSSL_METHOD*, ProtocolVersion);
-
-/* for sniffer */
-WOLFSSL_LOCAL int DoFinished(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
-                            word32 size, word32 totalSz, int sniff);
-WOLFSSL_LOCAL int DoApplicationData(WOLFSSL* ssl, byte* input, word32* inOutIdx);
-
-
-/* wolfSSL buffer type */
-typedef struct buffer {
-    byte*  buffer;
-    word32 length;
-} buffer;
-
-
-enum {
-    FORCED_FREE = 1,
-    NO_FORCED_FREE = 0
-};
-
-
-/* only use compression extra if using compression */
-#ifdef HAVE_LIBZ
-    #define COMP_EXTRA MAX_COMP_EXTRA
-#else
-    #define COMP_EXTRA 0
-#endif
-
-/* only the sniffer needs space in the buffer for extra MTU record(s) */
-#ifdef WOLFSSL_SNIFFER
-    #define MTU_EXTRA MAX_MTU * 3 
-#else
-    #define MTU_EXTRA 0
-#endif
-
-
-/* embedded callbacks require large static buffers, make sure on */
-#ifdef WOLFSSL_CALLBACKS
-    #undef  LARGE_STATIC_BUFFERS
-    #define LARGE_STATIC_BUFFERS
-#endif
-
-
-/* give user option to use 16K static buffers */
-#if defined(LARGE_STATIC_BUFFERS)
-    #define RECORD_SIZE MAX_RECORD_SIZE
-#else
-    #ifdef WOLFSSL_DTLS
-        #define RECORD_SIZE MAX_MTU 
-    #else
-        #define RECORD_SIZE 128 
-    #endif
-#endif
-
-
-/* user option to turn off 16K output option */
-/* if using small static buffers (default) and SSL_write tries to write data
-   larger than the record we have, dynamically get it, unless user says only
-   write in static buffer chuncks  */
-#ifndef STATIC_CHUNKS_ONLY
-    #define OUTPUT_RECORD_SIZE MAX_RECORD_SIZE
-#else
-    #define OUTPUT_RECORD_SIZE RECORD_SIZE
-#endif
-
-/* wolfSSL input buffer
-
-   RFC 2246:
-
-   length
-       The length (in bytes) of the following TLSPlaintext.fragment.
-       The length should not exceed 2^14.
-*/
-#if defined(LARGE_STATIC_BUFFERS)
-    #define STATIC_BUFFER_LEN RECORD_HEADER_SZ + RECORD_SIZE + COMP_EXTRA + \
-             MTU_EXTRA + MAX_MSG_EXTRA
-#else
-    /* don't fragment memory from the record header */
-    #define STATIC_BUFFER_LEN RECORD_HEADER_SZ
-#endif
-
-typedef struct {
-    ALIGN16 byte staticBuffer[STATIC_BUFFER_LEN];
-    byte*  buffer;       /* place holder for static or dynamic buffer */
-    word32 length;       /* total buffer length used */
-    word32 idx;          /* idx to part of length already consumed */
-    word32 bufferSize;   /* current buffer size */
-    byte   dynamicFlag;  /* dynamic memory currently in use */
-    byte   offset;       /* alignment offset attempt */
-} bufferStatic;
-
-/* Cipher Suites holder */
-typedef struct Suites {
-    word16 suiteSz;                 /* suite length in bytes        */
-    word16 hashSigAlgoSz;           /* SigAlgo extension length in bytes */
-    byte   suites[MAX_SUITE_SZ];
-    byte   hashSigAlgo[HELLO_EXT_SIGALGO_MAX]; /* sig/algo to offer */
-    byte   setSuites;               /* user set suites from default */
-    byte   hashAlgo;                /* selected hash algorithm */
-    byte   sigAlgo;                 /* selected sig algorithm */
-} Suites;
-
-
-WOLFSSL_LOCAL
-void InitSuites(Suites*, ProtocolVersion, word16, word16, word16, word16,
-                word16, word16, int);
-WOLFSSL_LOCAL
-int  SetCipherList(Suites*, const char* list);
-
-#ifndef PSK_TYPES_DEFINED
-    typedef unsigned int (*psk_client_callback)(WOLFSSL*, const char*, char*,
-                          unsigned int, unsigned char*, unsigned int);
-    typedef unsigned int (*psk_server_callback)(WOLFSSL*, const char*,
-                          unsigned char*, unsigned int);
-#endif /* PSK_TYPES_DEFINED */
-
-
-#ifdef HAVE_NETX
-    WOLFSSL_LOCAL int NetX_Receive(WOLFSSL *ssl, char *buf, int sz, void *ctx);
-    WOLFSSL_LOCAL int NetX_Send(WOLFSSL *ssl, char *buf, int sz, void *ctx);
-#endif /* HAVE_NETX */
-
-
-/* wolfSSL Cipher type just points back to SSL */
-struct WOLFSSL_CIPHER {
-    WOLFSSL* ssl;
-};
-
-
-typedef struct OCSP_Entry OCSP_Entry;
-
-#ifdef NO_SHA
-    #define OCSP_DIGEST_SIZE SHA256_DIGEST_SIZE
-#else
-    #define OCSP_DIGEST_SIZE SHA_DIGEST_SIZE
-#endif
-
-#ifdef NO_ASN 
-    /* no_asn won't have */
-    typedef struct CertStatus CertStatus;
-#endif
-
-struct OCSP_Entry {
-    OCSP_Entry* next;                        /* next entry             */
-    byte    issuerHash[OCSP_DIGEST_SIZE];    /* issuer hash            */ 
-    byte    issuerKeyHash[OCSP_DIGEST_SIZE]; /* issuer public key hash */
-    CertStatus* status;                      /* OCSP response list     */
-    int         totalStatus;                 /* number on list         */
-};
-
-
-#ifndef HAVE_OCSP
-    typedef struct WOLFSSL_OCSP WOLFSSL_OCSP;
-#endif
-
-/* wolfSSL OCSP controller */
-struct WOLFSSL_OCSP {
-    WOLFSSL_CERT_MANAGER* cm;            /* pointer back to cert manager */
-    OCSP_Entry*          ocspList;      /* OCSP response list */
-    wolfSSL_Mutex         ocspLock;      /* OCSP list lock */
-};
-
-#ifndef MAX_DATE_SIZE
-#define MAX_DATE_SIZE 32
-#endif
-
-typedef struct CRL_Entry CRL_Entry;
-
-#ifdef NO_SHA
-    #define CRL_DIGEST_SIZE SHA256_DIGEST_SIZE
-#else
-    #define CRL_DIGEST_SIZE SHA_DIGEST_SIZE
-#endif
-
-#ifdef NO_ASN 
-    typedef struct RevokedCert RevokedCert;
-#endif
-
-/* Complete CRL */
-struct CRL_Entry {
-    CRL_Entry* next;                      /* next entry */
-    byte    issuerHash[CRL_DIGEST_SIZE];  /* issuer hash                 */ 
-    /* byte    crlHash[CRL_DIGEST_SIZE];      raw crl data hash           */ 
-    /* restore the hash here if needed for optimized comparisons */
-    byte    lastDate[MAX_DATE_SIZE]; /* last date updated  */
-    byte    nextDate[MAX_DATE_SIZE]; /* next update date   */
-    byte    lastDateFormat;          /* last date format */
-    byte    nextDateFormat;          /* next date format */
-    RevokedCert* certs;              /* revoked cert list  */
-    int          totalCerts;         /* number on list     */
-};
-
-
-typedef struct CRL_Monitor CRL_Monitor;
-
-/* CRL directory monitor */
-struct CRL_Monitor {
-    char* path;      /* full dir path, if valid pointer we're using */
-    int   type;      /* PEM or ASN1 type */
-};
-
-
-#ifndef HAVE_CRL
-    typedef struct WOLFSSL_CRL WOLFSSL_CRL;
-#endif
-
-/* wolfSSL CRL controller */
-struct WOLFSSL_CRL {
-    WOLFSSL_CERT_MANAGER* cm;            /* pointer back to cert manager */
-    CRL_Entry*           crlList;       /* our CRL list */
-    wolfSSL_Mutex         crlLock;       /* CRL list lock */
-    CRL_Monitor          monitors[2];   /* PEM and DER possible */
-#ifdef HAVE_CRL_MONITOR
-    pthread_t            tid;           /* monitoring thread */
-    int                  mfd;           /* monitor fd, -1 if no init yet */
-#endif
-};
-
-
-#ifdef NO_ASN 
-    typedef struct Signer Signer;
-#endif
-
-
-#ifndef CA_TABLE_SIZE
-    #define CA_TABLE_SIZE 11
-#endif
-
-/* wolfSSL Certificate Manager */
-struct WOLFSSL_CERT_MANAGER {
-    Signer*         caTable[CA_TABLE_SIZE]; /* the CA signer table */
-    void*           heap;               /* heap helper */
-    WOLFSSL_CRL*    crl;                /* CRL checker */
-    WOLFSSL_OCSP*   ocsp;               /* OCSP checker */
-    char*           ocspOverrideURL;    /* use this responder */
-    void*           ocspIOCtx;          /* I/O callback CTX */
-    CallbackCACache caCacheCallback;    /* CA cache addition callback */
-    CbMissingCRL    cbMissingCRL;       /* notify through cb of missing crl */
-    CbOCSPIO        ocspIOCb;           /* I/O callback for OCSP lookup */
-    CbOCSPRespFree  ocspRespFreeCb;     /* Frees OCSP Response from IO Cb */
-    wolfSSL_Mutex   caLock;             /* CA list lock */
-    byte            crlEnabled;         /* is CRL on ? */
-    byte            crlCheckAll;        /* always leaf, but all ? */
-    byte            ocspEnabled;        /* is OCSP on ? */
-    byte            ocspCheckAll;       /* always leaf, but all ? */
-    byte            ocspSendNonce;      /* send the OCSP nonce ? */
-    byte            ocspUseOverrideURL; /* ignore cert's responder, override */
-};
-
-WOLFSSL_LOCAL int CM_SaveCertCache(WOLFSSL_CERT_MANAGER*, const char*);
-WOLFSSL_LOCAL int CM_RestoreCertCache(WOLFSSL_CERT_MANAGER*, const char*);
-WOLFSSL_LOCAL int CM_MemSaveCertCache(WOLFSSL_CERT_MANAGER*, void*, int, int*);
-WOLFSSL_LOCAL int CM_MemRestoreCertCache(WOLFSSL_CERT_MANAGER*, const void*, int);
-WOLFSSL_LOCAL int CM_GetCertCacheMemSize(WOLFSSL_CERT_MANAGER*);
-
-/* wolfSSL Sock Addr */
-struct WOLFSSL_SOCKADDR {
-    unsigned int sz; /* sockaddr size */
-    void*        sa; /* pointer to the sockaddr_in or sockaddr_in6 */
-};
-
-typedef struct WOLFSSL_DTLS_CTX {
-    WOLFSSL_SOCKADDR peer;
-    int fd;
-} WOLFSSL_DTLS_CTX;
-
-
-#ifdef WOLFSSL_DTLS
-
-    #ifdef WORD64_AVAILABLE
-        typedef word64 DtlsSeq;
-    #else
-        typedef word32 DtlsSeq;
-    #endif
-    #define DTLS_SEQ_BITS (sizeof(DtlsSeq) * CHAR_BIT)
-
-    typedef struct DtlsState {
-        DtlsSeq window;     /* Sliding window for current epoch    */
-        word16 nextEpoch;   /* Expected epoch in next record       */
-        word32 nextSeq;     /* Expected sequence in next record    */
-
-        word16 curEpoch;    /* Received epoch in current record    */
-        word32 curSeq;      /* Received sequence in current record */
-
-        DtlsSeq prevWindow; /* Sliding window for old epoch        */
-        word32 prevSeq;     /* Next sequence in allowed old epoch  */
-    } DtlsState;
-
-#endif /* WOLFSSL_DTLS */
-
-
-/* keys and secrets */
-typedef struct Keys {
-    byte client_write_MAC_secret[MAX_DIGEST_SIZE];   /* max sizes */
-    byte server_write_MAC_secret[MAX_DIGEST_SIZE];
-    byte client_write_key[AES_256_KEY_SIZE];         /* max sizes */
-    byte server_write_key[AES_256_KEY_SIZE];
-    byte client_write_IV[AES_IV_SIZE];               /* max sizes */
-    byte server_write_IV[AES_IV_SIZE];
-#ifdef HAVE_AEAD
-    byte aead_exp_IV[AEAD_EXP_IV_SZ];
-    byte aead_enc_imp_IV[AEAD_IMP_IV_SZ];
-    byte aead_dec_imp_IV[AEAD_IMP_IV_SZ];
-#endif
-
-    word32 peer_sequence_number;
-    word32 sequence_number;
-
-#ifdef WOLFSSL_DTLS
-    DtlsState dtls_state;                       /* Peer's state */
-    word16 dtls_peer_handshake_number;
-    word16 dtls_expected_peer_handshake_number;
-
-    word16 dtls_epoch;                          /* Current tx epoch    */
-    word32 dtls_sequence_number;                /* Current tx sequence */
-    word16 dtls_handshake_number;               /* Current tx handshake seq */
-#endif
-
-    word32 encryptSz;             /* last size of encrypted data   */
-    word32 padSz;                 /* how much to advance after decrypt part */
-    byte   encryptionOn;          /* true after change cipher spec */
-    byte   decryptedCur;          /* only decrypt current record once */
-} Keys;
-
-
-
-/* RFC 6066 TLS Extensions */
-#ifdef HAVE_TLS_EXTENSIONS
-
-typedef enum {
-    SERVER_NAME_INDICATION = 0x0000,
-    MAX_FRAGMENT_LENGTH    = 0x0001,
-    TRUNCATED_HMAC         = 0x0004,
-    ELLIPTIC_CURVES        = 0x000a,
-    SESSION_TICKET         = 0x0023,
-    SECURE_RENEGOTIATION   = 0xff01
-} TLSX_Type;
-
-typedef struct TLSX {
-    TLSX_Type    type; /* Extension Type  */
-    void*        data; /* Extension Data  */
-    byte         resp; /* IsResponse Flag */
-    struct TLSX* next; /* List Behavior   */
-} TLSX;
-
-WOLFSSL_LOCAL TLSX*  TLSX_Find(TLSX* list, TLSX_Type type);
-WOLFSSL_LOCAL void   TLSX_FreeAll(TLSX* list);
-WOLFSSL_LOCAL int    TLSX_SupportExtensions(WOLFSSL* ssl);
-
-#ifndef NO_WOLFSSL_CLIENT
-WOLFSSL_LOCAL word16 TLSX_GetRequestSize(WOLFSSL* ssl);
-WOLFSSL_LOCAL word16 TLSX_WriteRequest(WOLFSSL* ssl, byte* output);
-#endif
-
-#ifndef NO_WOLFSSL_SERVER
-WOLFSSL_LOCAL word16 TLSX_GetResponseSize(WOLFSSL* ssl);
-WOLFSSL_LOCAL word16 TLSX_WriteResponse(WOLFSSL* ssl, byte* output);
-#endif
-
-WOLFSSL_LOCAL int    TLSX_Parse(WOLFSSL* ssl, byte* input, word16 length,
-                                                byte isRequest, Suites *suites);
-                                                
-#elif defined(HAVE_SNI)                  \
-   || defined(HAVE_MAX_FRAGMENT)         \
-   || defined(HAVE_TRUNCATED_HMAC)       \
-   || defined(HAVE_SUPPORTED_CURVES)     \
-   || defined(HAVE_SECURE_RENEGOTIATION) \
-   || defined(HAVE_SESSION_TICKET)
-
-#error Using TLS extensions requires HAVE_TLS_EXTENSIONS to be defined.
-
-#endif /* HAVE_TLS_EXTENSIONS */
-
-/* Server Name Indication */
-#ifdef HAVE_SNI
-
-typedef struct SNI {
-    byte                       type;    /* SNI Type          */
-    union { char* host_name; } data;    /* SNI Data          */
-    struct SNI*                next;    /* List Behavior     */
-#ifndef NO_WOLFSSL_SERVER
-    byte                       options; /* Behaviour options */
-    byte                       status;  /* Matching result   */
-#endif
-} SNI;
-
-WOLFSSL_LOCAL int TLSX_UseSNI(TLSX** extensions, byte type, const void* data,
-                                                                   word16 size);
-
-#ifndef NO_WOLFSSL_SERVER
-WOLFSSL_LOCAL void   TLSX_SNI_SetOptions(TLSX* extensions, byte type,
-                                                                  byte options);
-WOLFSSL_LOCAL byte   TLSX_SNI_Status(TLSX* extensions, byte type);
-WOLFSSL_LOCAL word16 TLSX_SNI_GetRequest(TLSX* extensions, byte type,
-                                                                   void** data);
-WOLFSSL_LOCAL int    TLSX_SNI_GetFromBuffer(const byte* buffer, word32 bufferSz,
-                                         byte type, byte* sni, word32* inOutSz);
-#endif
-
-#endif /* HAVE_SNI */
-
-/* Maximum Fragment Length */
-#ifdef HAVE_MAX_FRAGMENT
-
-WOLFSSL_LOCAL int TLSX_UseMaxFragment(TLSX** extensions, byte mfl);
-
-#endif /* HAVE_MAX_FRAGMENT */
-
-#ifdef HAVE_TRUNCATED_HMAC
-
-WOLFSSL_LOCAL int TLSX_UseTruncatedHMAC(TLSX** extensions);
-
-#endif /* HAVE_TRUNCATED_HMAC */
-
-#ifdef HAVE_SUPPORTED_CURVES
-
-typedef struct EllipticCurve {
-    word16                name; /* CurveNames    */
-    struct EllipticCurve* next; /* List Behavior */
-} EllipticCurve;
-
-WOLFSSL_LOCAL int TLSX_UseSupportedCurve(TLSX** extensions, word16 name);
-
-#ifndef NO_WOLFSSL_SERVER
-WOLFSSL_LOCAL int TLSX_ValidateEllipticCurves(WOLFSSL* ssl, byte first,
-                                                                   byte second);
-#endif
-
-#endif /* HAVE_SUPPORTED_CURVES */
-
-#ifdef HAVE_SECURE_RENEGOTIATION
-
-enum key_cache_state {
-    SCR_CACHE_NULL   = 0,       /* empty / begin state */
-    SCR_CACHE_NEEDED,           /* need to cache keys */
-    SCR_CACHE_COPY,             /* we have a cached copy */
-    SCR_CACHE_PARTIAL,          /* partial restore to real keys */
-    SCR_CACHE_COMPLETE          /* complete restore to real keys */
-};
-
-
-/* Additional Conection State according to rfc5746 section 3.1 */
-typedef struct SecureRenegotiation {
-   byte                 enabled;  /* secure_renegotiation flag in rfc */
-   byte                 startScr; /* server requested client to start scr */
-   enum key_cache_state cache_status;  /* track key cache state */
-   byte                 client_verify_data[TLS_FINISHED_SZ];  /* cached */
-   byte                 server_verify_data[TLS_FINISHED_SZ];  /* cached */
-   byte                 subject_hash[SHA_DIGEST_SIZE];  /* peer cert hash */
-   Keys                 tmp_keys;  /* can't overwrite real keys yet */
-} SecureRenegotiation;
-
-WOLFSSL_LOCAL int TLSX_UseSecureRenegotiation(TLSX** extensions);
-
-#endif /* HAVE_SECURE_RENEGOTIATION */
-
-#ifdef HAVE_SESSION_TICKET
-
-typedef struct SessionTicket {
-    word32 lifetime;
-    byte*  data;
-    word16 size;
-} SessionTicket;
-
-WOLFSSL_LOCAL int  TLSX_UseSessionTicket(TLSX** extensions, 
-                                                         SessionTicket* ticket);
-WOLFSSL_LOCAL SessionTicket* TLSX_SessionTicket_Create(word32 lifetime,
-                                                       byte* data, word16 size);
-WOLFSSL_LOCAL void TLSX_SessionTicket_Free(SessionTicket* ticket);
-#endif /* HAVE_SESSION_TICKET */
-
-/* wolfSSL context type */
-struct WOLFSSL_CTX {
-    WOLFSSL_METHOD* method;
-    wolfSSL_Mutex   countMutex;    /* reference count mutex */
-    int         refCount;         /* reference count */
-#ifndef NO_DH
-    buffer      serverDH_P;
-    buffer      serverDH_G;
-#endif
-#ifndef NO_CERTS
-    buffer      certificate;
-    buffer      certChain;
-                 /* chain after self, in DER, with leading size for each cert */
-    buffer      privateKey;
-    WOLFSSL_CERT_MANAGER* cm;      /* our cert manager, ctx owns SSL will use */
-#endif
-    Suites*     suites;           /* make dynamic, user may not need/set */
-    void*       heap;             /* for user memory overrides */
-    byte        verifyPeer;
-    byte        verifyNone;
-    byte        failNoCert;
-    byte        sessionCacheOff;
-    byte        sessionCacheFlushOff;
-    byte        sendVerify;       /* for client side */
-    byte        haveRSA;          /* RSA available */
-    byte        haveDH;           /* server DH parms set by user */
-    byte        haveNTRU;         /* server private NTRU  key loaded */
-    byte        haveECDSAsig;     /* server cert signed w/ ECDSA */
-    byte        haveStaticECC;    /* static server ECC private key */
-    byte        partialWrite;     /* only one msg per write call */
-    byte        quietShutdown;    /* don't send close notify */
-    byte        groupMessages;    /* group handshake messages before sending */
-    byte        minDowngrade;     /* minimum downgrade version */
-#ifndef NO_DH
-    word16      minDhKeySz;       /* minimum DH key size */
-#endif
-    CallbackIORecv CBIORecv;
-    CallbackIOSend CBIOSend;
-#ifdef WOLFSSL_DTLS
-    CallbackGenCookie CBIOCookie;       /* gen cookie callback */
-#endif
-    VerifyCallback  verifyCallback;     /* cert verification callback */
-    word32          timeout;            /* session timeout */
-#ifdef HAVE_ECC
-    word16          eccTempKeySz;       /* in octets 20 - 66 */
-    word32          pkCurveOID;         /* curve Ecc_Sum */
-#endif
-#ifndef NO_PSK
-    byte        havePSK;                /* psk key set by user */
-    psk_client_callback client_psk_cb;  /* client callback */
-    psk_server_callback server_psk_cb;  /* server callback */
-    char        server_hint[MAX_PSK_ID_LEN];
-#endif /* NO_PSK */
-#ifdef HAVE_ANON
-    byte        haveAnon;               /* User wants to allow Anon suites */
-#endif /* HAVE_ANON */
-#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
-    pem_password_cb passwd_cb;
-    void*            userdata;
-#endif /* OPENSSL_EXTRA */
-#ifdef HAVE_OCSP
-    WOLFSSL_OCSP      ocsp;
-#endif
-#ifdef HAVE_CAVIUM
-    int              devId;            /* cavium device id to use */
-#endif
-#ifdef HAVE_TLS_EXTENSIONS
-    TLSX* extensions;                  /* RFC 6066 TLS Extensions data */
-    #if defined(HAVE_SESSION_TICKET) && !defined(NO_WOLFSSL_SEVER)
-        SessionTicketEncCb ticketEncCb;   /* enc/dec session ticket Cb */
-        void*              ticketEncCtx;  /* session encrypt context */
-        int                ticketHint;    /* ticket hint in seconds */
-    #endif
-#endif
-#ifdef ATOMIC_USER
-    CallbackMacEncrypt    MacEncryptCb;    /* Atomic User Mac/Encrypt Cb */
-    CallbackDecryptVerify DecryptVerifyCb; /* Atomic User Decrypt/Verify Cb */
-#endif
-#ifdef HAVE_PK_CALLBACKS
-    #ifdef HAVE_ECC
-        CallbackEccSign   EccSignCb;    /* User EccSign   Callback handler */
-        CallbackEccVerify EccVerifyCb;  /* User EccVerify Callback handler */
-    #endif /* HAVE_ECC */
-    #ifndef NO_RSA 
-        CallbackRsaSign   RsaSignCb;    /* User RsaSign   Callback handler */
-        CallbackRsaVerify RsaVerifyCb;  /* User RsaVerify Callback handler */
-        CallbackRsaEnc    RsaEncCb;     /* User Rsa Public Encrypt  handler */
-        CallbackRsaDec    RsaDecCb;     /* User Rsa Private Decrypt handler */
-    #endif /* NO_RSA */
-#endif /* HAVE_PK_CALLBACKS */
-};
-
-
-WOLFSSL_LOCAL
-int InitSSL_Ctx(WOLFSSL_CTX*, WOLFSSL_METHOD*);
-WOLFSSL_LOCAL
-void FreeSSL_Ctx(WOLFSSL_CTX*);
-WOLFSSL_LOCAL
-void SSL_CtxResourceFree(WOLFSSL_CTX*);
-
-WOLFSSL_LOCAL
-int DeriveTlsKeys(WOLFSSL* ssl);
-WOLFSSL_LOCAL
-int ProcessOldClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
-                          word32 inSz, word16 sz);
-#ifndef NO_CERTS
-    WOLFSSL_LOCAL
-    int AddCA(WOLFSSL_CERT_MANAGER* ctx, buffer der, int type, int verify);
-    WOLFSSL_LOCAL
-    int AlreadySigner(WOLFSSL_CERT_MANAGER* cm, byte* hash);
-#endif
-
-/* All cipher suite related info */
-typedef struct CipherSpecs {
-    word16 key_size;
-    word16 iv_size;
-    word16 block_size;
-    word16 aead_mac_size;
-    byte bulk_cipher_algorithm;
-    byte cipher_type;               /* block, stream, or aead */
-    byte mac_algorithm;
-    byte kea;                       /* key exchange algo */
-    byte sig_algo;
-    byte hash_size;
-    byte pad_size;
-    byte static_ecdh;
-} CipherSpecs;
-
-
-void InitCipherSpecs(CipherSpecs* cs);
-
-
-/* Supported Message Authentication Codes from page 43 */
-enum MACAlgorithm { 
-    no_mac,
-    md5_mac,
-    sha_mac,
-    sha224_mac,
-    sha256_mac,     /* needs to match external KDF_MacAlgorithm */
-    sha384_mac,
-    sha512_mac,
-    rmd_mac,
-    blake2b_mac
-};
-
-
-/* Supported Key Exchange Protocols */
-enum KeyExchangeAlgorithm { 
-    no_kea,
-    rsa_kea, 
-    diffie_hellman_kea, 
-    fortezza_kea,
-    psk_kea,
-    dhe_psk_kea,
-    ntru_kea,
-    ecc_diffie_hellman_kea,
-    ecc_static_diffie_hellman_kea       /* for verify suite only */
-};
-
-
-/* Supported Authentication Schemes */
-enum SignatureAlgorithm {
-    anonymous_sa_algo,
-    rsa_sa_algo,
-    dsa_sa_algo,
-    ecc_dsa_sa_algo
-};
-
-
-/* Supprted ECC Curve Types */
-enum EccCurves {
-    named_curve = 3
-};
-
-
-/* Valid client certificate request types from page 27 */
-enum ClientCertificateType {    
-    rsa_sign            = 1, 
-    dss_sign            = 2,
-    rsa_fixed_dh        = 3,
-    dss_fixed_dh        = 4,
-    rsa_ephemeral_dh    = 5,
-    dss_ephemeral_dh    = 6,
-    fortezza_kea_cert   = 20,
-    ecdsa_sign          = 64,
-    rsa_fixed_ecdh      = 65,
-    ecdsa_fixed_ecdh    = 66
-};
-
-
-enum CipherType { stream, block, aead };
-
-
-
-
-
-
-/* cipher for now */
-typedef struct Ciphers {
-#ifdef BUILD_ARC4
-    Arc4*   arc4;
-#endif
-#ifdef BUILD_DES3
-    Des3*   des3;
-#endif
-#if defined(BUILD_AES) || defined(BUILD_AESGCM)
-    Aes*    aes;
-#endif
-#ifdef HAVE_CAMELLIA
-    Camellia* cam;
-#endif
-#ifdef HAVE_CHACHA
-    ChaCha*   chacha;
-#endif
-#ifdef HAVE_HC128
-    HC128*  hc128;
-#endif
-#ifdef BUILD_RABBIT
-    Rabbit* rabbit;
-#endif
-    byte    setup;       /* have we set it up flag for detection */
-} Ciphers;
-
-
-#ifdef HAVE_ONE_TIME_AUTH
-/* Ciphers for one time authentication such as poly1305 */
-typedef struct OneTimeAuth {
-#ifdef HAVE_POLY1305
-    Poly1305* poly1305;
-#endif
-    byte    setup;      /* flag for if a cipher has been set */
-
-} OneTimeAuth;
-#endif
-
-
-WOLFSSL_LOCAL void InitCiphers(WOLFSSL* ssl);
-WOLFSSL_LOCAL void FreeCiphers(WOLFSSL* ssl);
-
-
-/* hashes type */
-typedef struct Hashes {
-    #ifndef NO_OLD_TLS
-        byte md5[MD5_DIGEST_SIZE];
-    #endif
-    byte sha[SHA_DIGEST_SIZE];
-    #ifndef NO_SHA256
-        byte sha256[SHA256_DIGEST_SIZE];
-    #endif
-    #ifdef WOLFSSL_SHA384
-        byte sha384[SHA384_DIGEST_SIZE];
-    #endif
-    #ifdef WOLFSSL_SHA512
-        byte sha512[SHA512_DIGEST_SIZE];
-    #endif
-} Hashes;
-
-
-/* Static x509 buffer */
-typedef struct x509_buffer {
-    int  length;                  /* actual size */
-    byte buffer[MAX_X509_SIZE];   /* max static cert size */
-} x509_buffer;
-
-
-/* wolfSSL X509_CHAIN, for no dynamic memory SESSION_CACHE */
-struct WOLFSSL_X509_CHAIN {
-    int         count;                    /* total number in chain */
-    x509_buffer certs[MAX_CHAIN_DEPTH];   /* only allow max depth 4 for now */
-};
-
-
-/* wolfSSL session type */
-struct WOLFSSL_SESSION {
-    word32       bornOn;                        /* create time in seconds   */
-    word32       timeout;                       /* timeout in seconds       */
-    byte         sessionID[ID_LEN];             /* id for protocol */
-    byte         sessionIDSz;
-    byte         masterSecret[SECRET_LEN];      /* stored secret */
-#ifdef SESSION_CERTS
-    WOLFSSL_X509_CHAIN chain;                    /* peer cert chain, static  */
-    ProtocolVersion version;                    /* which version was used */
-    byte            cipherSuite0;               /* first byte, normally 0 */
-    byte            cipherSuite;                /* 2nd byte, actual suite */
-#endif
-#ifndef NO_CLIENT_CACHE
-    word16       idLen;                         /* serverID length */
-    byte         serverID[SERVER_ID_LEN];       /* for easier client lookup */
-#endif
-#ifdef HAVE_SESSION_TICKET
-    word16       ticketLen;
-    byte         ticket[SESSION_TICKET_LEN];
-#endif
-};
-
-
-WOLFSSL_LOCAL
-WOLFSSL_SESSION* GetSession(WOLFSSL*, byte*);
-WOLFSSL_LOCAL
-int          SetSession(WOLFSSL*, WOLFSSL_SESSION*);
-
-typedef int (*hmacfp) (WOLFSSL*, byte*, const byte*, word32, int, int);
-
-#ifndef NO_CLIENT_CACHE
-    WOLFSSL_SESSION* GetSessionClient(WOLFSSL*, const byte*, int);
-#endif
-
-/* client connect state for nonblocking restart */
-enum ConnectState {
-    CONNECT_BEGIN = 0,
-    CLIENT_HELLO_SENT,
-    HELLO_AGAIN,               /* HELLO_AGAIN s for DTLS case */
-    HELLO_AGAIN_REPLY,
-    FIRST_REPLY_DONE,
-    FIRST_REPLY_FIRST,
-    FIRST_REPLY_SECOND,
-    FIRST_REPLY_THIRD,
-    FIRST_REPLY_FOURTH,
-    FINISHED_DONE,
-    SECOND_REPLY_DONE
-};
-
-
-/* server accept state for nonblocking restart */
-enum AcceptState {
-    ACCEPT_BEGIN = 0,
-    ACCEPT_CLIENT_HELLO_DONE,
-    HELLO_VERIFY_SENT,
-    ACCEPT_FIRST_REPLY_DONE,
-    SERVER_HELLO_SENT,
-    CERT_SENT,
-    KEY_EXCHANGE_SENT,
-    CERT_REQ_SENT,
-    SERVER_HELLO_DONE,
-    ACCEPT_SECOND_REPLY_DONE,
-    TICKET_SENT,
-    CHANGE_CIPHER_SENT,
-    ACCEPT_FINISHED_DONE,
-    ACCEPT_THIRD_REPLY_DONE
-};
-
-
-typedef struct Buffers {
-    bufferStatic    inputBuffer;
-    bufferStatic    outputBuffer;
-    buffer          domainName;             /* for client check */
-    buffer          clearOutputBuffer;
-    int             prevSent;              /* previous plain text bytes sent
-                                              when got WANT_WRITE            */
-    int             plainSz;               /* plain text bytes in buffer to send
-                                              when got WANT_WRITE            */
-    byte            weOwnCert;             /* SSL own cert flag */
-    byte            weOwnCertChain;        /* SSL own cert chain flag */
-    byte            weOwnKey;              /* SSL own key  flag */
-    byte            weOwnDH;               /* SSL own dh (p,g)  flag */
-#ifndef NO_DH
-    buffer          serverDH_P;            /* WOLFSSL_CTX owns, unless we own */
-    buffer          serverDH_G;            /* WOLFSSL_CTX owns, unless we own */
-    buffer          serverDH_Pub;
-    buffer          serverDH_Priv;
-#endif
-#ifndef NO_CERTS
-    buffer          certificate;           /* WOLFSSL_CTX owns, unless we own */
-    buffer          key;                   /* WOLFSSL_CTX owns, unless we own */
-    buffer          certChain;             /* WOLFSSL_CTX owns, unless we own */
-                 /* chain after self, in DER, with leading size for each cert */
-#endif
-#ifdef WOLFSSL_DTLS
-    WOLFSSL_DTLS_CTX dtlsCtx;               /* DTLS connection context */
-#endif
-#ifdef HAVE_PK_CALLBACKS
-    #ifdef HAVE_ECC
-        buffer peerEccDsaKey;              /* we own for Ecc Verify Callbacks */
-    #endif /* HAVE_ECC */
-    #ifndef NO_RSA
-        buffer peerRsaKey;                 /* we own for Rsa Verify Callbacks */
-    #endif /* NO_RSA */
-#endif /* HAVE_PK_CALLBACKS */
-} Buffers;
-
-typedef struct Options {
-#ifndef NO_PSK
-    psk_client_callback client_psk_cb;
-    psk_server_callback server_psk_cb;
-    word16            havePSK:1;            /* psk key set by user */
-#endif /* NO_PSK */
-
-    /* on/off or small bit flags, optimize layout */
-    word16            sendVerify:2;     /* false = 0, true = 1, sendBlank = 2 */
-    word16            sessionCacheOff:1;
-    word16            sessionCacheFlushOff:1;
-    word16            side:1;             /* client or server end */
-    word16            verifyPeer:1;
-    word16            verifyNone:1;
-    word16            failNoCert:1;
-    word16            downgrade:1;        /* allow downgrade of versions */
-    word16            resuming:1;
-    word16            haveSessionId:1;    /* server may not send */
-    word16            tls:1;              /* using TLS ? */
-    word16            tls1_1:1;           /* using TLSv1.1+ ? */
-    word16            dtls:1;             /* using datagrams ? */
-    word16            connReset:1;        /* has the peer reset */
-    word16            isClosed:1;         /* if we consider conn closed */
-    word16            closeNotify:1;      /* we've recieved a close notify */
-    word16            sentNotify:1;       /* we've sent a close notify */
-    word16            usingCompression:1; /* are we using compression */
-    word16            haveRSA:1;          /* RSA available */
-    word16            haveDH:1;           /* server DH parms set by user */
-    word16            haveNTRU:1;         /* server NTRU  private key loaded */
-    word16            haveECDSAsig:1;     /* server ECDSA signed cert */
-    word16            haveStaticECC:1;    /* static server ECC private key */
-    word16            havePeerCert:1;     /* do we have peer's cert */
-    word16            havePeerVerify:1;   /* and peer's cert verify */
-    word16            usingPSK_cipher:1;  /* are using psk as cipher */
-    word16            usingAnon_cipher:1; /* are we using an anon cipher */
-    word16            sendAlertState:1;   /* nonblocking resume */
-    word16            partialWrite:1;     /* only one msg per write call */
-    word16            quietShutdown:1;    /* don't send close notify */
-    word16            certOnly:1;         /* stop once we get cert */
-    word16            groupMessages:1;    /* group handshake messages */
-    word16            usingNonblock:1;    /* are we using nonblocking socket */
-    word16            saveArrays:1;       /* save array Memory for user get keys
-                                           or psk */
-#ifdef HAVE_POLY1305
-    word16            oldPoly:1;        /* set when to use old rfc way of poly*/
-#endif
-#ifdef HAVE_ANON
-    word16            haveAnon:1;       /* User wants to allow Anon suites */
-#endif
-#ifdef HAVE_SESSION_TICKET
-    word16            createTicket:1;     /* Server to create new Ticket */
-    word16            useTicket:1;        /* Use Ticket not session cache */
-#endif
-
-    /* need full byte values for this section */
-    byte            processReply;           /* nonblocking resume */
-    byte            cipherSuite0;           /* first byte, normally 0 */
-    byte            cipherSuite;            /* second byte, actual suite */
-    byte            serverState;
-    byte            clientState;
-    byte            handShakeState;
-    byte            handShakeDone;      /* at least one handshake complete */
-    byte            minDowngrade;       /* minimum downgrade version */
-    byte            connectState;       /* nonblocking resume */
-    byte            acceptState;        /* nonblocking resume */
-#ifndef NO_DH
-    word16          minDhKeySz;         /* minimum DH key size */
-    word16          dhKeySz;            /* actual DH key size */
-#endif
-
-} Options;
-
-typedef struct Arrays {
-    word32          preMasterSz;        /* differs for DH, actual size */
-#ifndef NO_PSK
-    word32          psk_keySz;          /* acutal size */
-    char            client_identity[MAX_PSK_ID_LEN];
-    char            server_hint[MAX_PSK_ID_LEN];
-    byte            psk_key[MAX_PSK_KEY_LEN];
-#endif
-    byte            clientRandom[RAN_LEN];
-    byte            serverRandom[RAN_LEN];
-    byte            sessionID[ID_LEN];
-    byte            sessionIDSz;
-    byte            preMasterSecret[ENCRYPT_LEN];
-    byte            masterSecret[SECRET_LEN];
-#ifdef WOLFSSL_DTLS
-    byte            cookie[MAX_COOKIE_LEN];
-    byte            cookieSz;
-#endif
-} Arrays;
-
-#ifndef ASN_NAME_MAX
-#define ASN_NAME_MAX 256
-#endif
-
-#ifndef MAX_DATE_SZ
-#define MAX_DATE_SZ 32
-#endif
-
-struct WOLFSSL_X509_NAME {
-    char  *name;
-    char  staticName[ASN_NAME_MAX];
-    int   dynamicName;
-    int   sz;
-#ifdef OPENSSL_EXTRA
-    DecodedName fullName;
-#endif /* OPENSSL_EXTRA */
-};
-
-#ifndef EXTERNAL_SERIAL_SIZE
-    #define EXTERNAL_SERIAL_SIZE 32
-#endif
-
-#ifdef NO_ASN 
-    typedef struct DNS_entry DNS_entry;
-#endif
-
-struct WOLFSSL_X509 {
-    int              version;
-    WOLFSSL_X509_NAME issuer;
-    WOLFSSL_X509_NAME subject;
-    int              serialSz;
-    byte             serial[EXTERNAL_SERIAL_SIZE];
-    char             subjectCN[ASN_NAME_MAX];        /* common name short cut */
-#ifdef WOLFSSL_SEP
-    int              deviceTypeSz;
-    byte             deviceType[EXTERNAL_SERIAL_SIZE];
-    int              hwTypeSz;
-    byte             hwType[EXTERNAL_SERIAL_SIZE];
-    int              hwSerialNumSz;
-    byte             hwSerialNum[EXTERNAL_SERIAL_SIZE];
-    #ifdef OPENSSL_EXTRA
-        byte             certPolicySet;
-        byte             certPolicyCrit;
-    #endif /* OPENSSL_EXTRA */
-#endif
-    int              notBeforeSz;
-    byte             notBefore[MAX_DATE_SZ];
-    int              notAfterSz;
-    byte             notAfter[MAX_DATE_SZ];
-    int              sigOID;
-    buffer           sig;
-    int              pubKeyOID;
-    buffer           pubKey;
-    #ifdef HAVE_ECC
-        word32       pkCurveOID;
-    #endif /* HAVE_ECC */
-    buffer           derCert;                        /* may need  */
-    DNS_entry*       altNames;                       /* alt names list */
-    DNS_entry*       altNamesNext;                   /* hint for retrieval */
-    byte             dynamicMemory;                  /* dynamic memory flag */
-    byte             isCa;
-#ifdef OPENSSL_EXTRA
-    word32           pathLength;
-    word16           keyUsage;
-    byte             basicConstSet;
-    byte             basicConstCrit;
-    byte             basicConstPlSet;
-    byte             subjAltNameSet;
-    byte             subjAltNameCrit;
-    byte             authKeyIdSet;
-    byte             authKeyIdCrit;
-    byte*            authKeyId;
-    word32           authKeyIdSz;
-    byte             subjKeyIdSet;
-    byte             subjKeyIdCrit;
-    byte*            subjKeyId;
-    word32           subjKeyIdSz;
-    byte             keyUsageSet;
-    byte             keyUsageCrit;
-#endif /* OPENSSL_EXTRA */
-};
-
-
-/* record layer header for PlainText, Compressed, and CipherText */
-typedef struct RecordLayerHeader {
-    byte            type;
-    byte            pvMajor;
-    byte            pvMinor;
-    byte            length[2];
-} RecordLayerHeader;
-
-
-/* record layer header for DTLS PlainText, Compressed, and CipherText */
-typedef struct DtlsRecordLayerHeader {
-    byte            type;
-    byte            pvMajor;
-    byte            pvMinor;
-    byte            epoch[2];             /* increment on cipher state change */
-    byte            sequence_number[6];   /* per record */
-    byte            length[2];
-} DtlsRecordLayerHeader;
-
-
-typedef struct DtlsPool {
-    buffer          buf[DTLS_POOL_SZ];
-    int             used;
-} DtlsPool;
-
-typedef struct DtlsMsg {
-    struct DtlsMsg* next;
-    word32          seq;       /* Handshake sequence number    */
-    word32          sz;        /* Length of whole mesage       */
-    word32          fragSz;    /* Length of fragments received */
-    byte            type;
-    byte*           buf;
-    byte*           msg;
-} DtlsMsg;
-
-
-#ifdef HAVE_NETX
-
-    /* NETX I/O Callback default */
-    typedef struct NetX_Ctx {
-        NX_TCP_SOCKET* nxSocket;    /* send/recv socket handle */
-        NX_PACKET*     nxPacket;    /* incoming packet handle for short reads */
-        ULONG          nxOffset;    /* offset already read from nxPacket */
-        ULONG          nxWait;      /* wait option flag */
-    } NetX_Ctx;
-
-#endif
-
-
-/* Handshake messages recevied from peer (plus change cipher */
-typedef struct MsgsReceived {
-    word16 got_hello_request:1;
-    word16 got_client_hello:1;
-    word16 got_server_hello:1;
-    word16 got_hello_verify_request:1;
-    word16 got_session_ticket:1;
-    word16 got_certificate:1;
-    word16 got_server_key_exchange:1;
-    word16 got_certificate_request:1;
-    word16 got_server_hello_done:1;
-    word16 got_certificate_verify:1;
-    word16 got_client_key_exchange:1;
-    word16 got_finished:1;
-    word16 got_change_cipher:1;
-} MsgsReceived;
-
-
-/* Handshake hashes */
-typedef struct HS_Hashes {
-    Hashes          verifyHashes;
-    Hashes          certHashes;         /* for cert verify */
-#ifndef NO_OLD_TLS
-#ifndef NO_SHA
-    Sha             hashSha;            /* sha hash of handshake msgs */
-#endif
-#ifndef NO_MD5
-    Md5             hashMd5;            /* md5 hash of handshake msgs */
-#endif
-#endif /* NO_OLD_TLS */
-#ifndef NO_SHA256
-    Sha256          hashSha256;         /* sha256 hash of handshake msgs */
-#endif
-#ifdef WOLFSSL_SHA384
-    Sha384          hashSha384;         /* sha384 hash of handshake msgs */
-#endif
-#ifdef WOLFSSL_SHA512
-    Sha512          hashSha512;         /* sha512 hash of handshake msgs */
-#endif
-} HS_Hashes;
-
-
-/* wolfSSL ssl type */
-struct WOLFSSL {
-    WOLFSSL_CTX*    ctx;
-    Suites*         suites;             /* only need during handshake */
-    Arrays*         arrays;
-    HS_Hashes*      hsHashes;
-    void*           IOCB_ReadCtx;
-    void*           IOCB_WriteCtx;
-    RNG*            rng;
-    void*           verifyCbCtx;        /* cert verify callback user ctx*/
-    VerifyCallback  verifyCallback;     /* cert verification callback */
-    void*           heap;               /* for user overrides */
-#ifndef NO_HANDSHAKE_DONE_CB
-    HandShakeDoneCb hsDoneCb;          /*  notify user handshake done */
-    void*           hsDoneCtx;         /*  user handshake cb context  */
-#endif
-    WOLFSSL_CIPHER  cipher;
-    hmacfp          hmac;
-    Ciphers         encrypt;
-    Ciphers         decrypt;
-    Buffers         buffers;
-    WOLFSSL_SESSION session;
-    WOLFSSL_ALERT_HISTORY alert_history;
-    int             error;
-    int             rfd;                /* read  file descriptor */
-    int             wfd;                /* write file descriptor */
-    int             rflags;             /* user read  flags */
-    int             wflags;             /* user write flags */
-    word32          timeout;            /* session timeout */
-    word16          curSize;
-    RecordLayerHeader curRL;
-    MsgsReceived    msgsReceived;       /* peer messages received */
-    ProtocolVersion version;            /* negotiated version */
-    ProtocolVersion chVersion;          /* client hello version */
-    CipherSpecs     specs;
-    Keys            keys;
-    Options         options;
-#ifdef OPENSSL_EXTRA
-    WOLFSSL_BIO*     biord;              /* socket bio read  to free/close */
-    WOLFSSL_BIO*     biowr;              /* socket bio write to free/close */
-#endif
-#ifndef NO_RSA
-    RsaKey*         peerRsaKey;
-    byte            peerRsaKeyPresent;
-#endif
-#ifdef HAVE_NTRU
-    word16          peerNtruKeyLen;
-    byte            peerNtruKey[MAX_NTRU_PUB_KEY_SZ];
-    byte            peerNtruKeyPresent;
-#endif
-#ifdef HAVE_ECC
-    ecc_key*        peerEccKey;              /* peer's  ECDHE key */
-    ecc_key*        peerEccDsaKey;           /* peer's  ECDSA key */
-    ecc_key*        eccTempKey;              /* private ECDHE key */
-    word32          pkCurveOID;              /* curve Ecc_Sum     */
-    word16          eccTempKeySz;            /* in octets 20 - 66 */
-    byte            peerEccKeyPresent;
-    byte            peerEccDsaKeyPresent;
-    byte            eccTempKeyPresent;
-#endif
-#ifdef HAVE_LIBZ
-    z_stream        c_stream;           /* compression   stream */
-    z_stream        d_stream;           /* decompression stream */
-    byte            didStreamInit;      /* for stream init and end */
-#endif
-#ifdef WOLFSSL_DTLS
-    int             dtls_timeout_init;  /* starting timeout vaule */
-    int             dtls_timeout_max;   /* maximum timeout value */
-    int             dtls_timeout;       /* current timeout value, changes */
-    DtlsPool*       dtls_pool;
-    DtlsMsg*        dtls_msg_list;
-    void*           IOCB_CookieCtx;     /* gen cookie ctx */
-    word32          dtls_expected_rx;
-#endif
-#ifdef WOLFSSL_CALLBACKS
-    HandShakeInfo   handShakeInfo;      /* info saved during handshake */
-    TimeoutInfo     timeoutInfo;        /* info saved during handshake */
-    byte            hsInfoOn;           /* track handshake info        */
-    byte            toInfoOn;           /* track timeout   info        */
-#endif
-#ifdef HAVE_FUZZER
-    CallbackFuzzer  fuzzerCb;           /* for testing with using fuzzer */
-    void*           fuzzerCtx;          /* user defined pointer */
-#endif
-#ifdef KEEP_PEER_CERT
-    WOLFSSL_X509     peerCert;           /* X509 peer cert */
-#endif
-#ifdef FORTRESS
-    void*           ex_data[MAX_EX_DATA]; /* external data, for Fortress */
-#endif
-#ifdef HAVE_CAVIUM
-    int              devId;            /* cavium device id to use */
-#endif
-#ifdef HAVE_ONE_TIME_AUTH
-    OneTimeAuth     auth;
-#endif
-#ifdef HAVE_TLS_EXTENSIONS
-    TLSX* extensions;                  /* RFC 6066 TLS Extensions data */
-    #ifdef HAVE_MAX_FRAGMENT
-        word16 max_fragment;
-    #endif
-    #ifdef HAVE_TRUNCATED_HMAC
-        byte truncated_hmac;
-    #endif
-    #ifdef HAVE_SECURE_RENEGOTIATION
-        SecureRenegotiation* secure_renegotiation; /* valid pointer indicates */
-    #endif                                         /* user turned on */
-    #if !defined(NO_WOLFSSL_CLIENT) && defined(HAVE_SESSION_TICKET)
-        CallbackSessionTicket session_ticket_cb;
-        void*                 session_ticket_ctx;
-        byte                  expect_session_ticket;
-    #endif
-#endif /* HAVE_TLS_EXTENSIONS */
-#ifdef HAVE_NETX
-    NetX_Ctx        nxCtx;             /* NetX IO Context */
-#endif
-#ifdef SESSION_INDEX
-    int sessionIndex;                  /* Session's location in the cache. */
-#endif
-#ifdef ATOMIC_USER
-    void*    MacEncryptCtx;    /* Atomic User Mac/Encrypt Callback Context */
-    void*    DecryptVerifyCtx; /* Atomic User Decrypt/Verify Callback Context */
-#endif
-#ifdef HAVE_PK_CALLBACKS
-    #ifdef HAVE_ECC
-        void* EccSignCtx;     /* Ecc Sign   Callback Context */
-        void* EccVerifyCtx;   /* Ecc Verify Callback Context */
-    #endif /* HAVE_ECC */
-    #ifndef NO_RSA
-        void* RsaSignCtx;     /* Rsa Sign   Callback Context */
-        void* RsaVerifyCtx;   /* Rsa Verify Callback Context */
-        void* RsaEncCtx;      /* Rsa Public  Encrypt   Callback Context */
-        void* RsaDecCtx;      /* Rsa Private Decrypt   Callback Context */
-    #endif /* NO_RSA */
-#endif /* HAVE_PK_CALLBACKS */
-#ifdef HAVE_SECRET_CALLBACK
-        SessionSecretCb sessionSecretCb;
-        void*           sessionSecretCtx;
-#endif /* HAVE_SECRET_CALLBACK */
-};
-
-
-WOLFSSL_LOCAL
-int  InitSSL(WOLFSSL*, WOLFSSL_CTX*);
-WOLFSSL_LOCAL
-void FreeSSL(WOLFSSL*);
-WOLFSSL_API void SSL_ResourceFree(WOLFSSL*);   /* Micrium uses */
-
-
-enum {
-    IV_SZ   = 32,          /* max iv sz */
-    NAME_SZ = 80          /* max one line */
-};
-
-
-typedef struct EncryptedInfo {
-    char     name[NAME_SZ];    /* encryption name */
-    byte     iv[IV_SZ];        /* encrypted IV */
-    word32   ivSz;             /* encrypted IV size */
-    long     consumed;         /* tracks PEM bytes consumed */
-    byte     set;              /* if encryption set */
-    WOLFSSL_CTX* ctx;              /* CTX owner */
-} EncryptedInfo;
-
-
-#ifndef NO_CERTS
-    WOLFSSL_LOCAL int PemToDer(const unsigned char* buff, long sz, int type,
-                              buffer* der, void* heap, EncryptedInfo* info,
-                              int* eccKey);
-
-    WOLFSSL_LOCAL int ProcessFile(WOLFSSL_CTX* ctx, const char* fname, int format,
-                                 int type, WOLFSSL* ssl, int userChain,
-                                WOLFSSL_CRL* crl);
-#endif
-
-
-#ifdef WOLFSSL_CALLBACKS
-    WOLFSSL_LOCAL
-    void InitHandShakeInfo(HandShakeInfo*);
-    WOLFSSL_LOCAL 
-    void FinishHandShakeInfo(HandShakeInfo*, const WOLFSSL*);
-    WOLFSSL_LOCAL 
-    void AddPacketName(const char*, HandShakeInfo*);
-
-    WOLFSSL_LOCAL
-    void InitTimeoutInfo(TimeoutInfo*);
-    WOLFSSL_LOCAL 
-    void FreeTimeoutInfo(TimeoutInfo*, void*);
-    WOLFSSL_LOCAL 
-    void AddPacketInfo(const char*, TimeoutInfo*, const byte*, int, void*);
-    WOLFSSL_LOCAL 
-    void AddLateName(const char*, TimeoutInfo*);
-    WOLFSSL_LOCAL 
-    void AddLateRecordHeader(const RecordLayerHeader* rl, TimeoutInfo* info);
-#endif
-
-
-/* Record Layer Header identifier from page 12 */
-enum ContentType {
-    no_type            = 0,
-    change_cipher_spec = 20, 
-    alert              = 21, 
-    handshake          = 22, 
-    application_data   = 23 
-};
-
-
-/* handshake header, same for each message type, pgs 20/21 */
-typedef struct HandShakeHeader {
-    byte            type;
-    word24          length;
-} HandShakeHeader;
-
-
-/* DTLS handshake header, same for each message type */
-typedef struct DtlsHandShakeHeader {
-    byte            type;
-    word24          length;
-    byte            message_seq[2];    /* start at 0, restransmit gets same # */
-    word24          fragment_offset;   /* bytes in previous fragments */
-    word24          fragment_length;   /* length of this fragment */
-} DtlsHandShakeHeader;
-
-
-enum HandShakeType {
-    no_shake            = -1,
-    hello_request       = 0, 
-    client_hello        = 1, 
-    server_hello        = 2,
-    hello_verify_request = 3,       /* DTLS addition */
-    session_ticket      =  4,
-    certificate         = 11, 
-    server_key_exchange = 12,
-    certificate_request = 13, 
-    server_hello_done   = 14,
-    certificate_verify  = 15, 
-    client_key_exchange = 16,
-    finished            = 20,
-    certificate_status  = 22,
-    change_cipher_hs    = 55      /* simulate unique handshake type for sanity
-                                     checks.  record layer change_cipher
-                                     conflicts with handshake finished */
-};
-
-
-static const byte client[SIZEOF_SENDER] = { 0x43, 0x4C, 0x4E, 0x54 };
-static const byte server[SIZEOF_SENDER] = { 0x53, 0x52, 0x56, 0x52 };
-
-static const byte tls_client[FINISHED_LABEL_SZ + 1] = "client finished";
-static const byte tls_server[FINISHED_LABEL_SZ + 1] = "server finished";
-
-
-/* internal functions */
-WOLFSSL_LOCAL int SendChangeCipher(WOLFSSL*);
-WOLFSSL_LOCAL int SendTicket(WOLFSSL*);
-WOLFSSL_LOCAL int DoClientTicket(WOLFSSL*, const byte*, word32);
-WOLFSSL_LOCAL int SendData(WOLFSSL*, const void*, int);
-WOLFSSL_LOCAL int SendCertificate(WOLFSSL*);
-WOLFSSL_LOCAL int SendCertificateRequest(WOLFSSL*);
-WOLFSSL_LOCAL int SendServerKeyExchange(WOLFSSL*);
-WOLFSSL_LOCAL int SendBuffered(WOLFSSL*);
-WOLFSSL_LOCAL int ReceiveData(WOLFSSL*, byte*, int, int);
-WOLFSSL_LOCAL int SendFinished(WOLFSSL*);
-WOLFSSL_LOCAL int SendAlert(WOLFSSL*, int, int);
-WOLFSSL_LOCAL int ProcessReply(WOLFSSL*);
-
-WOLFSSL_LOCAL int SetCipherSpecs(WOLFSSL*);
-WOLFSSL_LOCAL int MakeMasterSecret(WOLFSSL*);
-
-WOLFSSL_LOCAL int  AddSession(WOLFSSL*);
-WOLFSSL_LOCAL int  DeriveKeys(WOLFSSL* ssl);
-WOLFSSL_LOCAL int  StoreKeys(WOLFSSL* ssl, const byte* keyData);
-
-WOLFSSL_LOCAL int IsTLS(const WOLFSSL* ssl);
-WOLFSSL_LOCAL int IsAtLeastTLSv1_2(const WOLFSSL* ssl);
-
-WOLFSSL_LOCAL void FreeHandshakeResources(WOLFSSL* ssl);
-WOLFSSL_LOCAL void ShrinkInputBuffer(WOLFSSL* ssl, int forcedFree);
-WOLFSSL_LOCAL void ShrinkOutputBuffer(WOLFSSL* ssl);
-
-WOLFSSL_LOCAL int VerifyClientSuite(WOLFSSL* ssl);
-#ifndef NO_CERTS
-    WOLFSSL_LOCAL Signer* GetCA(void* cm, byte* hash);
-    #ifndef NO_SKID
-        WOLFSSL_LOCAL Signer* GetCAByName(void* cm, byte* hash);
-    #endif
-#endif
-WOLFSSL_LOCAL int  BuildTlsFinished(WOLFSSL* ssl, Hashes* hashes,
-                                   const byte* sender);
-WOLFSSL_LOCAL void FreeArrays(WOLFSSL* ssl, int keep);
-WOLFSSL_LOCAL  int CheckAvailableSize(WOLFSSL *ssl, int size);
-WOLFSSL_LOCAL  int GrowInputBuffer(WOLFSSL* ssl, int size, int usedLength);
-
-#ifndef NO_TLS
-    WOLFSSL_LOCAL int  MakeTlsMasterSecret(WOLFSSL*);
-    WOLFSSL_LOCAL int  TLS_hmac(WOLFSSL* ssl, byte* digest, const byte* in,
-                               word32 sz, int content, int verify);
-#endif
-
-#ifndef NO_WOLFSSL_CLIENT
-    WOLFSSL_LOCAL int SendClientHello(WOLFSSL*);
-    WOLFSSL_LOCAL int SendClientKeyExchange(WOLFSSL*);
-    WOLFSSL_LOCAL int SendCertificateVerify(WOLFSSL*);
-#endif /* NO_WOLFSSL_CLIENT */
-
-#ifndef NO_WOLFSSL_SERVER
-    WOLFSSL_LOCAL int SendServerHello(WOLFSSL*);
-    WOLFSSL_LOCAL int SendServerHelloDone(WOLFSSL*);
-    #ifdef WOLFSSL_DTLS
-        WOLFSSL_LOCAL int SendHelloVerifyRequest(WOLFSSL*);
-    #endif
-#endif /* NO_WOLFSSL_SERVER */
-
-#ifdef WOLFSSL_DTLS
-    WOLFSSL_LOCAL int  DtlsPoolInit(WOLFSSL*);
-    WOLFSSL_LOCAL int  DtlsPoolSave(WOLFSSL*, const byte*, int);
-    WOLFSSL_LOCAL int  DtlsPoolTimeout(WOLFSSL*);
-    WOLFSSL_LOCAL int  DtlsPoolSend(WOLFSSL*);
-    WOLFSSL_LOCAL void DtlsPoolReset(WOLFSSL*);
-
-    WOLFSSL_LOCAL DtlsMsg* DtlsMsgNew(word32, void*);
-    WOLFSSL_LOCAL void DtlsMsgDelete(DtlsMsg*, void*);
-    WOLFSSL_LOCAL void DtlsMsgListDelete(DtlsMsg*, void*);
-    WOLFSSL_LOCAL void DtlsMsgSet(DtlsMsg*, word32, const byte*, byte,
-                                                             word32, word32);
-    WOLFSSL_LOCAL DtlsMsg* DtlsMsgFind(DtlsMsg*, word32);
-    WOLFSSL_LOCAL DtlsMsg* DtlsMsgStore(DtlsMsg*, word32, const byte*, word32,
-                                                byte, word32, word32, void*);
-    WOLFSSL_LOCAL DtlsMsg* DtlsMsgInsert(DtlsMsg*, DtlsMsg*);
-#endif /* WOLFSSL_DTLS */
-
-#ifndef NO_TLS
-    
-
-#endif /* NO_TLS */
-
-
-WOLFSSL_LOCAL word32  LowResTimer(void);
-
-WOLFSSL_LOCAL void InitX509Name(WOLFSSL_X509_NAME*, int);
-WOLFSSL_LOCAL void FreeX509Name(WOLFSSL_X509_NAME* name);
-WOLFSSL_LOCAL void InitX509(WOLFSSL_X509*, int);
-WOLFSSL_LOCAL void FreeX509(WOLFSSL_X509*);
-#ifndef NO_CERTS
-    WOLFSSL_LOCAL int  CopyDecodedToX509(WOLFSSL_X509*, DecodedCert*);
-#endif
-
-/* used by ssl.c and wolfssl_int.c */
-WOLFSSL_LOCAL void c32to24(word32 in, word24 out);
-
-WOLFSSL_LOCAL const char* const* GetCipherNames(void);
-WOLFSSL_LOCAL int GetCipherNamesSize(void);
-
-
-enum encrypt_side {
-    ENCRYPT_SIDE_ONLY = 1,
-    DECRYPT_SIDE_ONLY,
-    ENCRYPT_AND_DECRYPT_SIDE
-};
-
-WOLFSSL_LOCAL int SetKeysSide(WOLFSSL*, enum encrypt_side);
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */
-#endif
-
-#endif /* wolfSSL_INT_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/ocsp.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/ocsp.h
deleted file mode 100755
index 77a4157..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/ocsp.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* ocsp.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-/* wolfSSL OCSP API */
-
-#ifndef WOLFSSL_OCSP_H
-#define WOLFSSL_OCSP_H
-
-#ifdef HAVE_OCSP
-
-#include 
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-typedef struct WOLFSSL_OCSP WOLFSSL_OCSP;
-
-WOLFSSL_LOCAL int  InitOCSP(WOLFSSL_OCSP*, WOLFSSL_CERT_MANAGER*);
-WOLFSSL_LOCAL void FreeOCSP(WOLFSSL_OCSP*, int dynamic);
-
-WOLFSSL_LOCAL int  CheckCertOCSP(WOLFSSL_OCSP*, DecodedCert*);
-
-#ifdef __cplusplus
-    }  /* extern "C" */
-#endif
-
-
-#endif /* HAVE_OCSP */
-#endif /* WOLFSSL_OCSP_H */
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/asn1.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/asn1.h
deleted file mode 100755
index 3f34d7d..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/asn1.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* asn1.h for openssl */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/bio.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/bio.h
deleted file mode 100755
index 5f1d421..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/bio.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* bio.h for openssl */
-
-
-#ifndef WOLFSSL_BIO_H_
-#define WOLFSSL_BIO_H_
-
-#include 
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */ 
-#endif
-
-
-#endif /* WOLFSSL_BIO_H_ */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/bn.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/bn.h
deleted file mode 100755
index 4d81eb1..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/bn.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* bn.h for openssl */
-
-
-#ifndef WOLFSSL_BN_H_
-#define WOLFSSL_BN_H_
-
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-typedef struct WOLFSSL_BIGNUM {
-    int   neg;              /* openssh deference */
-    void* internal;         /* our big num */
-} WOLFSSL_BIGNUM;
-
-
-typedef struct WOLFSSL_BN_CTX WOLFSSL_BN_CTX;
-
-
-WOLFSSL_API WOLFSSL_BN_CTX* wolfSSL_BN_CTX_new(void);
-WOLFSSL_API void           wolfSSL_BN_CTX_init(WOLFSSL_BN_CTX*);
-WOLFSSL_API void           wolfSSL_BN_CTX_free(WOLFSSL_BN_CTX*);
-
-WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_new(void);
-WOLFSSL_API void           wolfSSL_BN_free(WOLFSSL_BIGNUM*);
-WOLFSSL_API void           wolfSSL_BN_clear_free(WOLFSSL_BIGNUM*);
-
-
-WOLFSSL_API int wolfSSL_BN_sub(WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*,
-	                         const WOLFSSL_BIGNUM*);
-WOLFSSL_API int wolfSSL_BN_mod(WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*,
-	                         const WOLFSSL_BIGNUM*, const WOLFSSL_BN_CTX*);
-
-WOLFSSL_API const WOLFSSL_BIGNUM* wolfSSL_BN_value_one(void);
-
-
-WOLFSSL_API int wolfSSL_BN_num_bytes(const WOLFSSL_BIGNUM*);
-WOLFSSL_API int wolfSSL_BN_num_bits(const WOLFSSL_BIGNUM*);
-
-WOLFSSL_API int wolfSSL_BN_is_zero(const WOLFSSL_BIGNUM*);
-WOLFSSL_API int wolfSSL_BN_is_one(const WOLFSSL_BIGNUM*);
-WOLFSSL_API int wolfSSL_BN_is_odd(const WOLFSSL_BIGNUM*);
-
-WOLFSSL_API int wolfSSL_BN_cmp(const WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*);
-
-WOLFSSL_API int wolfSSL_BN_bn2bin(const WOLFSSL_BIGNUM*, unsigned char*);
-WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_bin2bn(const unsigned char*, int len,
-	                            WOLFSSL_BIGNUM* ret);
-
-WOLFSSL_API int wolfSSL_mask_bits(WOLFSSL_BIGNUM*, int n);
-
-WOLFSSL_API int wolfSSL_BN_rand(WOLFSSL_BIGNUM*, int bits, int top, int bottom);
-WOLFSSL_API int wolfSSL_BN_is_bit_set(const WOLFSSL_BIGNUM*, int n);
-WOLFSSL_API int wolfSSL_BN_hex2bn(WOLFSSL_BIGNUM**, const char* str);
-
-WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_dup(const WOLFSSL_BIGNUM*);
-WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_copy(WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*);
-
-WOLFSSL_API int wolfSSL_BN_set_word(WOLFSSL_BIGNUM*, unsigned long w);
-
-WOLFSSL_API int   wolfSSL_BN_dec2bn(WOLFSSL_BIGNUM**, const char* str);
-WOLFSSL_API char* wolfSSL_BN_bn2dec(const WOLFSSL_BIGNUM*);
-
-
-typedef WOLFSSL_BIGNUM BIGNUM;
-typedef WOLFSSL_BN_CTX BN_CTX;
-
-#define BN_CTX_new        wolfSSL_BN_CTX_new
-#define BN_CTX_init       wolfSSL_BN_CTX_init
-#define BN_CTX_free       wolfSSL_BN_CTX_free
-
-#define BN_new        wolfSSL_BN_new
-#define BN_free       wolfSSL_BN_free
-#define BN_clear_free wolfSSL_BN_clear_free
-
-#define BN_num_bytes wolfSSL_BN_num_bytes
-#define BN_num_bits  wolfSSL_BN_num_bits
-
-#define BN_is_zero  wolfSSL_BN_is_zero
-#define BN_is_one   wolfSSL_BN_is_one
-#define BN_is_odd   wolfSSL_BN_is_odd
-
-#define BN_cmp    wolfSSL_BN_cmp
-
-#define BN_bn2bin  wolfSSL_BN_bn2bin
-#define BN_bin2bn  wolfSSL_BN_bin2bn
-
-#define BN_mod       wolfSSL_BN_mod
-#define BN_sub       wolfSSL_BN_sub
-#define BN_value_one wolfSSL_BN_value_one
-
-#define BN_mask_bits wolfSSL_mask_bits
-
-#define BN_rand       wolfSSL_BN_rand
-#define BN_is_bit_set wolfSSL_BN_is_bit_set
-#define BN_hex2bn     wolfSSL_BN_hex2bn
-
-#define BN_dup  wolfSSL_BN_dup
-#define BN_copy wolfSSL_BN_copy
-
-#define BN_set_word wolfSSL_BN_set_word
-
-#define BN_dec2bn wolfSSL_BN_dec2bn
-#define BN_bn2dec wolfSSL_BN_bn2dec
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */ 
-#endif
-
-
-#endif /* WOLFSSL__H_ */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/conf.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/conf.h
deleted file mode 100755
index 1e328cf..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/conf.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* conf.h for openssl */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/crypto.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/crypto.h
deleted file mode 100755
index 8f7c6f4..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/crypto.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* crypto.h for openSSL */
-
-#ifndef WOLFSSL_CRYPTO_H_
-#define WOLFSSL_CRYPTO_H_
-
-
-#include 
-
-#ifdef WOLFSSL_PREFIX
-#include "prefix_crypto.h"
-#endif
-
-
-WOLFSSL_API const char*   wolfSSLeay_version(int type);
-WOLFSSL_API unsigned long wolfSSLeay(void);
-
-#define SSLeay_version wolfSSLeay_version
-#define SSLeay wolfSSLeay
-
-
-#define SSLEAY_VERSION 0x0090600fL
-#define SSLEAY_VERSION_NUMBER SSLEAY_VERSION
-
-
-#endif /* header */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/des.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/des.h
deleted file mode 100755
index f5b4f2a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/des.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* des.h
- *
- * Copyright (C) 2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as 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-1301, USA
- */
-
-
-/*  des.h defines mini des openssl compatibility layer 
- *
- */
-
-
-#ifndef WOLFSSL_DES_H_
-#define WOLFSSL_DES_H_
-
-#include 
-
-#ifndef NO_DES3
-
-#ifdef WOLFSSL_PREFIX
-#include "prefix_des.h"
-#endif
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-typedef unsigned char WOLFSSL_DES_cblock[8];
-typedef /* const */ WOLFSSL_DES_cblock WOLFSSL_const_DES_cblock;
-typedef WOLFSSL_DES_cblock WOLFSSL_DES_key_schedule;
-
-
-enum {
-    DES_ENCRYPT = 1,
-    DES_DECRYPT = 0
-};
-
-
-WOLFSSL_API void wolfSSL_DES_set_key_unchecked(WOLFSSL_const_DES_cblock*,
-                                             WOLFSSL_DES_key_schedule*);
-WOLFSSL_API int  wolfSSL_DES_key_sched(WOLFSSL_const_DES_cblock* key,
-                                     WOLFSSL_DES_key_schedule* schedule);
-WOLFSSL_API void wolfSSL_DES_cbc_encrypt(const unsigned char* input,
-                     unsigned char* output, long length,
-                     WOLFSSL_DES_key_schedule* schedule, WOLFSSL_DES_cblock* ivec,
-                     int enc);
-WOLFSSL_API void wolfSSL_DES_ncbc_encrypt(const unsigned char* input,
-                      unsigned char* output, long length,
-                      WOLFSSL_DES_key_schedule* schedule,
-                      WOLFSSL_DES_cblock* ivec, int enc);
-
-WOLFSSL_API void wolfSSL_DES_set_odd_parity(WOLFSSL_DES_cblock*);
-WOLFSSL_API void wolfSSL_DES_ecb_encrypt(WOLFSSL_DES_cblock*, WOLFSSL_DES_cblock*,
-                                       WOLFSSL_DES_key_schedule*, int);
-
-
-typedef WOLFSSL_DES_cblock DES_cblock;
-typedef WOLFSSL_const_DES_cblock const_DES_cblock;
-typedef WOLFSSL_DES_key_schedule DES_key_schedule;
-
-#define DES_set_key_unchecked wolfSSL_DES_set_key_unchecked
-#define DES_key_sched wolfSSL_DES_key_sched
-#define DES_cbc_encrypt wolfSSL_DES_cbc_encrypt
-#define DES_ncbc_encrypt wolfSSL_DES_ncbc_encrypt
-#define DES_set_odd_parity wolfSSL_DES_set_odd_parity
-#define DES_ecb_encrypt wolfSSL_DES_ecb_encrypt
-#define DES_ede3_cbc_encrypt(input, output, sz, ks1, ks2, ks3, ivec, enc) \
-do {                                                         \
-    Des3 des;                                                \
-    byte key[24];/* EDE uses 24 size key */                  \
-    memcpy(key, (ks1), DES_BLOCK_SIZE);                      \
-    memcpy(&key[DES_BLOCK_SIZE], (ks2), DES_BLOCK_SIZE);     \
-    memcpy(&key[DES_BLOCK_SIZE * 2], (ks3), DES_BLOCK_SIZE); \
-    if (enc) {                                               \
-        wc_Des3_SetKey(&des, key, (const byte*)(ivec), DES_ENCRYPTION);    \
-        wc_Des3_CbcEncrypt(&des, (output), (input), (sz));    \
-    }                                                         \
-    else {                                                    \
-        wc_Des3_SetKey(&des, key, (const byte*)(ivec), DES_ENCRYPTION);    \
-        wc_Des3_CbcDecrypt(&des, (output), (input), (sz));    \
-    }                                                         \
-} while(0)
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* NO_DES3 */
-
-#endif /* WOLFSSL_DES_H_ */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/dh.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/dh.h
deleted file mode 100755
index 071abf7..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/dh.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* dh.h for openSSL */
-
-
-#ifndef WOLFSSL_DH_H_
-#define WOLFSSL_DH_H_
-
-
-#include 
-#include 
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-
-
-typedef struct WOLFSSL_DH {
-	WOLFSSL_BIGNUM* p;
-	WOLFSSL_BIGNUM* g;
-    WOLFSSL_BIGNUM* pub_key;      /* openssh deference g^x */
-    WOLFSSL_BIGNUM* priv_key;     /* openssh deference x   */
-    void*          internal;     /* our DH */
-    char           inSet;        /* internal set from external ? */
-    char           exSet;        /* external set from internal ? */
-} WOLFSSL_DH;
-
-
-WOLFSSL_API WOLFSSL_DH* wolfSSL_DH_new(void);
-WOLFSSL_API void       wolfSSL_DH_free(WOLFSSL_DH*);
-
-WOLFSSL_API int wolfSSL_DH_size(WOLFSSL_DH*);
-WOLFSSL_API int wolfSSL_DH_generate_key(WOLFSSL_DH*);
-WOLFSSL_API int wolfSSL_DH_compute_key(unsigned char* key, WOLFSSL_BIGNUM* pub,
-                                     WOLFSSL_DH*);
-
-typedef WOLFSSL_DH DH;
-
-#define DH_new  wolfSSL_DH_new 
-#define DH_free wolfSSL_DH_free
-
-#define DH_size         wolfSSL_DH_size
-#define DH_generate_key wolfSSL_DH_generate_key
-#define DH_compute_key  wolfSSL_DH_compute_key
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */ 
-#endif
-
-#endif /* header */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/dsa.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/dsa.h
deleted file mode 100755
index 7255670..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/dsa.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* dsa.h for openSSL */
-
-
-#ifndef WOLFSSL_DSA_H_
-#define WOLFSSL_DSA_H_
-
-
-#include 
-#include 
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-
-struct WOLFSSL_DSA {
-	WOLFSSL_BIGNUM* p;
-	WOLFSSL_BIGNUM* q;
-	WOLFSSL_BIGNUM* g;
-	WOLFSSL_BIGNUM* pub_key;      /* our y */
-	WOLFSSL_BIGNUM* priv_key;     /* our x */
-    void*          internal;     /* our Dsa Key */
-    char           inSet;        /* internal set from external ? */
-    char           exSet;        /* external set from internal ? */
-};
-
-
-WOLFSSL_API WOLFSSL_DSA* wolfSSL_DSA_new(void);
-WOLFSSL_API void        wolfSSL_DSA_free(WOLFSSL_DSA*);
-
-WOLFSSL_API int wolfSSL_DSA_generate_key(WOLFSSL_DSA*);
-WOLFSSL_API int wolfSSL_DSA_generate_parameters_ex(WOLFSSL_DSA*, int bits,
-                   unsigned char* seed, int seedLen, int* counterRet,
-                   unsigned long* hRet, void* cb);
-
-WOLFSSL_API int wolfSSL_DSA_LoadDer(WOLFSSL_DSA*, const unsigned char*, int sz);
-WOLFSSL_API int wolfSSL_DSA_do_sign(const unsigned char* d, unsigned char* sigRet,
-                                  WOLFSSL_DSA* dsa);
-
-#define DSA_new wolfSSL_DSA_new
-#define DSA_free wolfSSL_DSA_free
-
-#define DSA_generate_key           wolfSSL_DSA_generate_key
-#define DSA_generate_parameters_ex wolfSSL_DSA_generate_parameters_ex
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */ 
-#endif
-
-#endif /* header */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ec.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ec.h
deleted file mode 100755
index 5ffdaf6..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ec.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* ec.h for openssl */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ecdsa.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ecdsa.h
deleted file mode 100755
index f3cf0de..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ecdsa.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* ecdsa.h for openssl */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/engine.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/engine.h
deleted file mode 100755
index 39952fc..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/engine.h
+++ /dev/null
@@ -1,5 +0,0 @@
-/* engine.h for libcurl */
-
-#undef HAVE_OPENSSL_ENGINE_H
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/err.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/err.h
deleted file mode 100755
index 7e7f1eb..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/err.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* err.h for openssl */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/evp.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/evp.h
deleted file mode 100755
index ded0b2f..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/evp.h
+++ /dev/null
@@ -1,257 +0,0 @@
-/* evp.h
- *
- * Copyright (C) 2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-/*  evp.h defines mini evp openssl compatibility layer 
- *
- */
-
-
-#ifndef WOLFSSL_EVP_H_
-#define WOLFSSL_EVP_H_
-
-#include 
-
-#ifdef WOLFSSL_PREFIX
-#include "prefix_evp.h"
-#endif
-
-#ifndef NO_MD5
-    #include 
-#endif
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-typedef char WOLFSSL_EVP_MD;
-typedef char WOLFSSL_EVP_CIPHER;
-
-#ifndef NO_MD5
-    WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_md5(void);
-#endif
-WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha1(void);
-WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha256(void);
-WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha384(void);
-WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha512(void);
-WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_ripemd160(void);
-
-WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_cbc(void);
-WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_cbc(void);
-WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_cbc(void);
-WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_ctr(void);
-WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_ctr(void);
-WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_ctr(void);
-WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_cbc(void);
-WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_ede3_cbc(void);
-WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_rc4(void);
-WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_enc_null(void);
-
-
-typedef union {
-    #ifndef NO_MD5
-        WOLFSSL_MD5_CTX    md5;
-    #endif
-    WOLFSSL_SHA_CTX    sha;
-    WOLFSSL_SHA256_CTX sha256;
-    #ifdef WOLFSSL_SHA384
-        WOLFSSL_SHA384_CTX sha384;
-    #endif
-    #ifdef WOLFSSL_SHA512
-        WOLFSSL_SHA512_CTX sha512;
-    #endif
-    #ifdef WOLFSSL_RIPEMD
-        WOLFSSL_RIPEMD_CTX ripemd;
-    #endif
-} WOLFSSL_Hasher;
-
-
-typedef struct WOLFSSL_EVP_MD_CTX {
-    unsigned char macType;
-    WOLFSSL_Hasher hash;
-} WOLFSSL_EVP_MD_CTX;
-
-
-typedef union {
-#ifndef NO_AES
-    Aes  aes;
-#endif
-#ifndef NO_DES3
-    Des  des;
-    Des3 des3;
-#endif
-    Arc4 arc4;
-} WOLFSSL_Cipher;
-
-
-enum {
-    AES_128_CBC_TYPE  = 1,
-    AES_192_CBC_TYPE  = 2,
-    AES_256_CBC_TYPE  = 3,
-    AES_128_CTR_TYPE  = 4,
-    AES_192_CTR_TYPE  = 5,
-    AES_256_CTR_TYPE  = 6,
-    DES_CBC_TYPE      = 7,
-    DES_EDE3_CBC_TYPE = 8,
-    ARC4_TYPE         = 9,
-    NULL_CIPHER_TYPE  = 10,
-    EVP_PKEY_RSA      = 11,
-    EVP_PKEY_DSA      = 12,
-    NID_sha1          = 64,
-    NID_md5           =  4
-};
-
-
-typedef struct WOLFSSL_EVP_CIPHER_CTX {
-    int            keyLen;         /* user may set for variable */
-    unsigned char  enc;            /* if encrypt side, then true */
-    unsigned char  cipherType;
-#ifndef NO_AES
-    unsigned char  iv[AES_BLOCK_SIZE];    /* working iv pointer into cipher */
-#elif !defined(NO_DES3)
-    unsigned char  iv[DES_BLOCK_SIZE];    /* working iv pointer into cipher */
-#endif
-    WOLFSSL_Cipher  cipher;
-} WOLFSSL_EVP_CIPHER_CTX;
-
-
-WOLFSSL_API int  wolfSSL_EVP_MD_size(const WOLFSSL_EVP_MD* md);
-WOLFSSL_API void wolfSSL_EVP_MD_CTX_init(WOLFSSL_EVP_MD_CTX* ctx);
-WOLFSSL_API int  wolfSSL_EVP_MD_CTX_cleanup(WOLFSSL_EVP_MD_CTX* ctx);
-
-WOLFSSL_API int wolfSSL_EVP_DigestInit(WOLFSSL_EVP_MD_CTX* ctx,
-                                     const WOLFSSL_EVP_MD* type);
-WOLFSSL_API int wolfSSL_EVP_DigestUpdate(WOLFSSL_EVP_MD_CTX* ctx, const void* data,
-                                       unsigned long sz);
-WOLFSSL_API int wolfSSL_EVP_DigestFinal(WOLFSSL_EVP_MD_CTX* ctx, unsigned char* md,
-                                      unsigned int* s);
-WOLFSSL_API int wolfSSL_EVP_DigestFinal_ex(WOLFSSL_EVP_MD_CTX* ctx,
-                                            unsigned char* md, unsigned int* s);
-#ifndef NO_MD5
-WOLFSSL_API int wolfSSL_EVP_BytesToKey(const WOLFSSL_EVP_CIPHER*,
-                              const WOLFSSL_EVP_MD*, const unsigned char*,
-                              const unsigned char*, int, int, unsigned char*,
-                              unsigned char*);
-#endif
-
-WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_init(WOLFSSL_EVP_CIPHER_CTX* ctx);
-WOLFSSL_API int  wolfSSL_EVP_CIPHER_CTX_cleanup(WOLFSSL_EVP_CIPHER_CTX* ctx);
-
-WOLFSSL_API int  wolfSSL_EVP_CIPHER_CTX_iv_length(const WOLFSSL_EVP_CIPHER_CTX*);
-
-
-WOLFSSL_API int  wolfSSL_EVP_CipherInit(WOLFSSL_EVP_CIPHER_CTX* ctx,
-                                    const WOLFSSL_EVP_CIPHER* type,
-                                    unsigned char* key, unsigned char* iv,
-                                    int enc);
-WOLFSSL_API int  wolfSSL_EVP_CIPHER_CTX_key_length(WOLFSSL_EVP_CIPHER_CTX* ctx);
-WOLFSSL_API int  wolfSSL_EVP_CIPHER_CTX_set_key_length(WOLFSSL_EVP_CIPHER_CTX* ctx,
-                                                     int keylen);
-WOLFSSL_API int  wolfSSL_EVP_Cipher(WOLFSSL_EVP_CIPHER_CTX* ctx,
-                          unsigned char* dst, unsigned char* src,
-                          unsigned int len);
-
-WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_get_digestbynid(int);
-
-WOLFSSL_API WOLFSSL_RSA* wolfSSL_EVP_PKEY_get1_RSA(WOLFSSL_EVP_PKEY*);
-WOLFSSL_API WOLFSSL_DSA* wolfSSL_EVP_PKEY_get1_DSA(WOLFSSL_EVP_PKEY*);
-
-/* these next ones don't need real OpenSSL type, for OpenSSH compat only */
-WOLFSSL_API void* wolfSSL_EVP_X_STATE(const WOLFSSL_EVP_CIPHER_CTX* ctx);
-WOLFSSL_API int   wolfSSL_EVP_X_STATE_LEN(const WOLFSSL_EVP_CIPHER_CTX* ctx);
-
-WOLFSSL_API void  wolfSSL_3des_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset,
-                                unsigned char* iv, int len);
-WOLFSSL_API void  wolfSSL_aes_ctr_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset,
-                                unsigned char* iv, int len);
-
-WOLFSSL_API int  wolfSSL_StoreExternalIV(WOLFSSL_EVP_CIPHER_CTX* ctx);
-WOLFSSL_API int  wolfSSL_SetInternalIV(WOLFSSL_EVP_CIPHER_CTX* ctx);
-
-
-/* end OpenSSH compat */
-
-typedef WOLFSSL_EVP_MD         EVP_MD;
-typedef WOLFSSL_EVP_CIPHER     EVP_CIPHER;
-typedef WOLFSSL_EVP_MD_CTX     EVP_MD_CTX;
-typedef WOLFSSL_EVP_CIPHER_CTX EVP_CIPHER_CTX;
-
-#ifndef NO_MD5
-    #define EVP_md5       wolfSSL_EVP_md5
-#endif
-#define EVP_sha1      wolfSSL_EVP_sha1
-#define EVP_sha256    wolfSSL_EVP_sha256
-#define EVP_sha384    wolfSSL_EVP_sha384
-#define EVP_sha512    wolfSSL_EVP_sha512
-#define EVP_ripemd160 wolfSSL_EVP_ripemd160
-
-#define EVP_aes_128_cbc  wolfSSL_EVP_aes_128_cbc
-#define EVP_aes_192_cbc  wolfSSL_EVP_aes_192_cbc
-#define EVP_aes_256_cbc  wolfSSL_EVP_aes_256_cbc
-#define EVP_aes_128_ctr  wolfSSL_EVP_aes_128_ctr
-#define EVP_aes_192_ctr  wolfSSL_EVP_aes_192_ctr
-#define EVP_aes_256_ctr  wolfSSL_EVP_aes_256_ctr
-#define EVP_des_cbc      wolfSSL_EVP_des_cbc
-#define EVP_des_ede3_cbc wolfSSL_EVP_des_ede3_cbc
-#define EVP_rc4          wolfSSL_EVP_rc4
-#define EVP_enc_null     wolfSSL_EVP_enc_null
-
-#define EVP_MD_size        wolfSSL_EVP_MD_size
-#define EVP_MD_CTX_init    wolfSSL_EVP_MD_CTX_init
-#define EVP_MD_CTX_cleanup wolfSSL_EVP_MD_CTX_cleanup
-#define EVP_DigestInit     wolfSSL_EVP_DigestInit
-#define EVP_DigestUpdate   wolfSSL_EVP_DigestUpdate
-#define EVP_DigestFinal    wolfSSL_EVP_DigestFinal
-#define EVP_DigestFinal_ex wolfSSL_EVP_DigestFinal_ex
-#define EVP_BytesToKey     wolfSSL_EVP_BytesToKey
-
-#define EVP_CIPHER_CTX_init           wolfSSL_EVP_CIPHER_CTX_init
-#define EVP_CIPHER_CTX_cleanup        wolfSSL_EVP_CIPHER_CTX_cleanup
-#define EVP_CIPHER_CTX_iv_length      wolfSSL_EVP_CIPHER_CTX_iv_length
-#define EVP_CIPHER_CTX_key_length     wolfSSL_EVP_CIPHER_CTX_key_length
-#define EVP_CIPHER_CTX_set_key_length wolfSSL_EVP_CIPHER_CTX_set_key_length
-#define EVP_CipherInit                wolfSSL_EVP_CipherInit
-#define EVP_Cipher                    wolfSSL_EVP_Cipher
-
-#define EVP_get_digestbynid           wolfSSL_EVP_get_digestbynid
-
-#define EVP_PKEY_get1_RSA   wolfSSL_EVP_PKEY_get1_RSA
-#define EVP_PKEY_get1_DSA   wolfSSL_EVP_PKEY_get1_DSA
-
-#ifndef EVP_MAX_MD_SIZE
-    #define EVP_MAX_MD_SIZE   64     /* sha512 */
-#endif
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-
-#endif /* WOLFSSL_EVP_H_ */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/hmac.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/hmac.h
deleted file mode 100755
index 0dca8cb..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/hmac.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* hmac.h
- *
- * Copyright (C) 2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-/*  hmac.h defines mini hamc openssl compatibility layer 
- *
- */
-
-
-#ifndef WOLFSSL_HMAC_H_
-#define WOLFSSL_HMAC_H_
-
-#include 
-
-#ifdef WOLFSSL_PREFIX
-#include "prefix_hmac.h"
-#endif
-
-#include 
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-WOLFSSL_API unsigned char* wolfSSL_HMAC(const WOLFSSL_EVP_MD* evp_md,
-                               const void* key, int key_len,
-                               const unsigned char* d, int n, unsigned char* md,
-                               unsigned int* md_len);
-
-
-typedef struct WOLFSSL_HMAC_CTX {
-    Hmac hmac;
-    int  type;
-} WOLFSSL_HMAC_CTX;
-
-
-WOLFSSL_API void wolfSSL_HMAC_Init(WOLFSSL_HMAC_CTX* ctx, const void* key,
-                                 int keylen, const EVP_MD* type);
-WOLFSSL_API void wolfSSL_HMAC_Update(WOLFSSL_HMAC_CTX* ctx,
-                                   const unsigned char* data, int len);
-WOLFSSL_API void wolfSSL_HMAC_Final(WOLFSSL_HMAC_CTX* ctx, unsigned char* hash,
-                                  unsigned int* len);
-WOLFSSL_API void wolfSSL_HMAC_cleanup(WOLFSSL_HMAC_CTX* ctx);
-
-
-typedef struct WOLFSSL_HMAC_CTX HMAC_CTX;
-
-#define HMAC(a,b,c,d,e,f,g) wolfSSL_HMAC((a),(b),(c),(d),(e),(f),(g))
-
-#define HMAC_Init    wolfSSL_HMAC_Init
-#define HMAC_Update  wolfSSL_HMAC_Update
-#define HMAC_Final   wolfSSL_HMAC_Final
-#define HMAC_cleanup wolfSSL_HMAC_cleanup
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-
-#endif /* WOLFSSL_HMAC_H_ */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/include.am b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/include.am
deleted file mode 100755
index 05b509b..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/include.am
+++ /dev/null
@@ -1,36 +0,0 @@
-# vim:ft=automake
-# All paths should be given relative to the root
-
-nobase_include_HEADERS+= \
-                         wolfssl/openssl/asn1.h \
-                         wolfssl/openssl/bio.h \
-                         wolfssl/openssl/bn.h \
-                         wolfssl/openssl/conf.h \
-                         wolfssl/openssl/crypto.h \
-                         wolfssl/openssl/des.h \
-                         wolfssl/openssl/dh.h \
-                         wolfssl/openssl/dsa.h \
-                         wolfssl/openssl/ecdsa.h \
-                         wolfssl/openssl/ec.h \
-                         wolfssl/openssl/engine.h \
-                         wolfssl/openssl/err.h \
-                         wolfssl/openssl/evp.h \
-                         wolfssl/openssl/hmac.h \
-                         wolfssl/openssl/lhash.h \
-                         wolfssl/openssl/md4.h \
-                         wolfssl/openssl/md5.h \
-                         wolfssl/openssl/ripemd.h \
-                         wolfssl/openssl/ocsp.h \
-                         wolfssl/openssl/opensslconf.h \
-                         wolfssl/openssl/opensslv.h \
-                         wolfssl/openssl/ossl_typ.h \
-                         wolfssl/openssl/pem.h \
-                         wolfssl/openssl/pkcs12.h \
-                         wolfssl/openssl/rand.h \
-                         wolfssl/openssl/rsa.h \
-                         wolfssl/openssl/sha.h \
-                         wolfssl/openssl/ssl.h \
-                         wolfssl/openssl/stack.h \
-                         wolfssl/openssl/ui.h \
-                         wolfssl/openssl/x509.h \
-                         wolfssl/openssl/x509v3.h
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/lhash.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/lhash.h
deleted file mode 100755
index 01f8535..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/lhash.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* lhash.h for openSSL */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/md4.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/md4.h
deleted file mode 100755
index 2e99f97..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/md4.h
+++ /dev/null
@@ -1 +0,0 @@
-/* md4.h for libcurl */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/md5.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/md5.h
deleted file mode 100755
index bdcda5b..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/md5.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* md5.h for openssl */
-
-
-#ifndef WOLFSSL_MD5_H_
-#define WOLFSSL_MD5_H_
-
-#include 
-
-#ifndef NO_MD5
-
-#ifdef WOLFSSL_PREFIX
-#include "prefix_md5.h"
-#endif
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-typedef struct WOLFSSL_MD5_CTX {
-    int holder[24];   /* big enough to hold wolfcrypt md5, but check on init */
-} WOLFSSL_MD5_CTX;
-
-WOLFSSL_API void wolfSSL_MD5_Init(WOLFSSL_MD5_CTX*);
-WOLFSSL_API void wolfSSL_MD5_Update(WOLFSSL_MD5_CTX*, const void*, unsigned long);
-WOLFSSL_API void wolfSSL_MD5_Final(unsigned char*, WOLFSSL_MD5_CTX*);
-
-
-typedef WOLFSSL_MD5_CTX MD5_CTX;
-
-#define MD5_Init wolfSSL_MD5_Init
-#define MD5_Update wolfSSL_MD5_Update
-#define MD5_Final wolfSSL_MD5_Final
-
-#ifdef __cplusplus
-    }  /* extern "C" */ 
-#endif
-
-#endif /* NO_MD5 */
-
-#endif /* WOLFSSL_MD5_H_ */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ocsp.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ocsp.h
deleted file mode 100755
index 7463eec..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ocsp.h
+++ /dev/null
@@ -1 +0,0 @@
-/* ocsp.h for libcurl */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/opensslconf.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/opensslconf.h
deleted file mode 100755
index ac6b55b..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/opensslconf.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* opensslconf.h for openSSL */
-
-
-#ifndef OPENSSL_THREADS
-    #define OPENSSL_THREADS
-#endif
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/opensslv.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/opensslv.h
deleted file mode 100755
index e13e992..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/opensslv.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* opensslv.h compatibility */
-
-#ifndef WOLFSSL_OPENSSLV_H_
-#define WOLFSSL_OPENSSLV_H_
-
-
-/* api version compatibility */
-#define OPENSSL_VERSION_NUMBER 0x0090410fL
-
-
-#endif /* header */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ossl_typ.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ossl_typ.h
deleted file mode 100755
index 65b00c7..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ossl_typ.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* ossl_typ.h for openssl */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/pem.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/pem.h
deleted file mode 100755
index 926e43f..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/pem.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* pem.h for openssl */
-
-
-#ifndef WOLFSSL_PEM_H_
-#define WOLFSSL_PEM_H_
-
-#include 
-#include 
-#include 
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-WOLFSSL_API int wolfSSL_PEM_write_bio_RSAPrivateKey(WOLFSSL_BIO* bio, RSA* rsa,
-	                                  const EVP_CIPHER* cipher,
-	                                  unsigned char* passwd, int len,
-	                                  pem_password_cb cb, void* arg);
-
-WOLFSSL_API int wolfSSL_PEM_write_bio_DSAPrivateKey(WOLFSSL_BIO* bio, DSA* rsa,
-	                                  const EVP_CIPHER* cipher,
-	                                  unsigned char* passwd, int len,
-	                                  pem_password_cb cb, void* arg);
-
-WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_PEM_read_bio_PrivateKey(WOLFSSL_BIO* bio,
-                        WOLFSSL_EVP_PKEY**, pem_password_cb cb, void* arg); 
-
-#define PEM_write_bio_RSAPrivateKey wolfSSL_PEM_write_bio_RSAPrivateKey
-#define PEM_write_bio_DSAPrivateKey wolfSSL_PEM_write_bio_DSAPrivateKey
-#define PEM_read_bio_PrivateKey     wolfSSL_PEM_read_bio_PrivateKey
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */ 
-#endif
-
-
-#endif /* WOLFSSL_PEM_H_ */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/pkcs12.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/pkcs12.h
deleted file mode 100755
index 544b6f0..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/pkcs12.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* pkcs12.h for openssl */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/rand.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/rand.h
deleted file mode 100755
index c1fa62e..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/rand.h
+++ /dev/null
@@ -1,4 +0,0 @@
-/* rand.h for openSSL */
-
-#include 
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ripemd.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ripemd.h
deleted file mode 100755
index ef1578e..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ripemd.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ripemd.h for openssl */
-
-
-#ifndef WOLFSSL_RIPEMD_H_
-#define WOLFSSL_RIPEMD_H_
-
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-typedef struct WOLFSSL_RIPEMD_CTX {
-    int holder[32];   /* big enough to hold wolfcrypt, but check on init */
-} WOLFSSL_RIPEMD_CTX;
-
-WOLFSSL_API void wolfSSL_RIPEMD_Init(WOLFSSL_RIPEMD_CTX*);
-WOLFSSL_API void wolfSSL_RIPEMD_Update(WOLFSSL_RIPEMD_CTX*, const void*,
-                                     unsigned long);
-WOLFSSL_API void wolfSSL_RIPEMD_Final(unsigned char*, WOLFSSL_RIPEMD_CTX*);
-
-
-typedef WOLFSSL_RIPEMD_CTX RIPEMD_CTX;
-
-#define RIPEMD_Init   wolfSSL_RIPEMD_Init
-#define RIPEMD_Update wolfSSL_RIPEMD_Update
-#define RIPEMD_Final  wolfSSL_RIPEMD_Final
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */ 
-#endif
-
-
-#endif /* WOLFSSL_MD5_H_ */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/rsa.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/rsa.h
deleted file mode 100755
index 2db993b..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/rsa.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* rsa.h for openSSL */
-
-
-#ifndef WOLFSSL_RSA_H_
-#define WOLFSSL_RSA_H_
-
-#include 
-#include 
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-enum  { 
-	RSA_PKCS1_PADDING = 1
- };
-
-struct WOLFSSL_RSA {
-	WOLFSSL_BIGNUM* n;
-	WOLFSSL_BIGNUM* e;
-	WOLFSSL_BIGNUM* d;
-	WOLFSSL_BIGNUM* p;
-	WOLFSSL_BIGNUM* q;
-	WOLFSSL_BIGNUM* dmp1;      /* dP */
-	WOLFSSL_BIGNUM* dmq1;      /* dQ */
-	WOLFSSL_BIGNUM* iqmp;      /* u */
-    void*          internal;  /* our RSA */
-    char           inSet;     /* internal set from external ? */
-    char           exSet;     /* external set from internal ? */
-};
-
-
-WOLFSSL_API WOLFSSL_RSA* wolfSSL_RSA_new(void);
-WOLFSSL_API void        wolfSSL_RSA_free(WOLFSSL_RSA*);
-
-WOLFSSL_API int wolfSSL_RSA_generate_key_ex(WOLFSSL_RSA*, int bits, WOLFSSL_BIGNUM*,
-                                          void* cb);
-
-WOLFSSL_API int wolfSSL_RSA_blinding_on(WOLFSSL_RSA*, WOLFSSL_BN_CTX*);
-WOLFSSL_API int wolfSSL_RSA_public_encrypt(int len, unsigned char* fr,
-	                               unsigned char* to, WOLFSSL_RSA*, int padding);
-WOLFSSL_API int wolfSSL_RSA_private_decrypt(int len, unsigned char* fr,
-	                               unsigned char* to, WOLFSSL_RSA*, int padding);
-
-WOLFSSL_API int wolfSSL_RSA_size(const WOLFSSL_RSA*);
-WOLFSSL_API int wolfSSL_RSA_sign(int type, const unsigned char* m,
-                               unsigned int mLen, unsigned char* sigRet,
-                               unsigned int* sigLen, WOLFSSL_RSA*);
-WOLFSSL_API int wolfSSL_RSA_public_decrypt(int flen, unsigned char* from,
-                                  unsigned char* to, WOLFSSL_RSA*, int padding);
-WOLFSSL_API int wolfSSL_RSA_GenAdd(WOLFSSL_RSA*);
-WOLFSSL_API int wolfSSL_RSA_LoadDer(WOLFSSL_RSA*, const unsigned char*, int sz);
-
-
-#define RSA_new  wolfSSL_RSA_new
-#define RSA_free wolfSSL_RSA_free
-
-#define RSA_generate_key_ex wolfSSL_RSA_generate_key_ex
-
-#define RSA_blinding_on     wolfSSL_RSA_blinding_on
-#define RSA_public_encrypt  wolfSSL_RSA_public_encrypt
-#define RSA_private_decrypt wolfSSL_RSA_private_decrypt
-
-#define RSA_size           wolfSSL_RSA_size
-#define RSA_sign           wolfSSL_RSA_sign
-#define RSA_public_decrypt wolfSSL_RSA_public_decrypt
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */ 
-#endif
-
-#endif /* header */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/sha.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/sha.h
deleted file mode 100755
index 7f8b0eb..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/sha.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* sha.h for openssl */
-
-
-#ifndef WOLFSSL_SHA_H_
-#define WOLFSSL_SHA_H_
-
-#include 
-
-#ifdef WOLFSSL_PREFIX
-#include "prefix_sha.h"
-#endif
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-typedef struct WOLFSSL_SHA_CTX {
-    int holder[24];   /* big enough to hold wolfcrypt sha, but check on init */
-} WOLFSSL_SHA_CTX;
-
-WOLFSSL_API void wolfSSL_SHA_Init(WOLFSSL_SHA_CTX*);
-WOLFSSL_API void wolfSSL_SHA_Update(WOLFSSL_SHA_CTX*, const void*, unsigned long);
-WOLFSSL_API void wolfSSL_SHA_Final(unsigned char*, WOLFSSL_SHA_CTX*);
-
-/* SHA1 points to above, shouldn't use SHA0 ever */
-WOLFSSL_API void wolfSSL_SHA1_Init(WOLFSSL_SHA_CTX*);
-WOLFSSL_API void wolfSSL_SHA1_Update(WOLFSSL_SHA_CTX*, const void*, unsigned long);
-WOLFSSL_API void wolfSSL_SHA1_Final(unsigned char*, WOLFSSL_SHA_CTX*);
-
-enum {
-    SHA_DIGEST_LENGTH = 20
-};
-
-
-typedef WOLFSSL_SHA_CTX SHA_CTX;
-
-#define SHA_Init wolfSSL_SHA_Init
-#define SHA_Update wolfSSL_SHA_Update
-#define SHA_Final wolfSSL_SHA_Final
-
-#define SHA1_Init wolfSSL_SHA1_Init
-#define SHA1_Update wolfSSL_SHA1_Update
-#define SHA1_Final wolfSSL_SHA1_Final
-
-
-typedef struct WOLFSSL_SHA256_CTX {
-    int holder[28];   /* big enough to hold wolfcrypt sha, but check on init */
-} WOLFSSL_SHA256_CTX;
-
-WOLFSSL_API void wolfSSL_SHA256_Init(WOLFSSL_SHA256_CTX*);
-WOLFSSL_API void wolfSSL_SHA256_Update(WOLFSSL_SHA256_CTX*, const void*,
-	                                 unsigned long);
-WOLFSSL_API void wolfSSL_SHA256_Final(unsigned char*, WOLFSSL_SHA256_CTX*);
-
-enum {
-    SHA256_DIGEST_LENGTH = 32 
-};
-
-
-typedef WOLFSSL_SHA256_CTX SHA256_CTX;
-
-#define SHA256_Init   wolfSSL_SHA256_Init
-#define SHA256_Update wolfSSL_SHA256_Update
-#define SHA256_Final  wolfSSL_SHA256_Final
-
-
-#ifdef WOLFSSL_SHA384
-
-typedef struct WOLFSSL_SHA384_CTX {
-    long long holder[32];   /* big enough, but check on init */
-} WOLFSSL_SHA384_CTX;
-
-WOLFSSL_API void wolfSSL_SHA384_Init(WOLFSSL_SHA384_CTX*);
-WOLFSSL_API void wolfSSL_SHA384_Update(WOLFSSL_SHA384_CTX*, const void*,
-	                                 unsigned long);
-WOLFSSL_API void wolfSSL_SHA384_Final(unsigned char*, WOLFSSL_SHA384_CTX*);
-
-enum {
-    SHA384_DIGEST_LENGTH = 48 
-};
-
-
-typedef WOLFSSL_SHA384_CTX SHA384_CTX;
-
-#define SHA384_Init   wolfSSL_SHA384_Init
-#define SHA384_Update wolfSSL_SHA384_Update
-#define SHA384_Final  wolfSSL_SHA384_Final
-
-#endif /* WOLFSSL_SHA384 */
-
-#ifdef WOLFSSL_SHA512
-
-typedef struct WOLFSSL_SHA512_CTX {
-    long long holder[36];   /* big enough, but check on init */
-} WOLFSSL_SHA512_CTX;
-
-WOLFSSL_API void wolfSSL_SHA512_Init(WOLFSSL_SHA512_CTX*);
-WOLFSSL_API void wolfSSL_SHA512_Update(WOLFSSL_SHA512_CTX*, const void*,
-	                                 unsigned long);
-WOLFSSL_API void wolfSSL_SHA512_Final(unsigned char*, WOLFSSL_SHA512_CTX*);
-
-enum {
-    SHA512_DIGEST_LENGTH = 64 
-};
-
-
-typedef WOLFSSL_SHA512_CTX SHA512_CTX;
-
-#define SHA512_Init   wolfSSL_SHA512_Init
-#define SHA512_Update wolfSSL_SHA512_Update
-#define SHA512_Final  wolfSSL_SHA512_Final
-
-#endif /* WOLFSSL_SHA512 */
-
-
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */ 
-#endif
-
-
-#endif /* WOLFSSL_SHA_H_ */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ssl.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ssl.h
deleted file mode 100755
index 34d7948..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ssl.h
+++ /dev/null
@@ -1,406 +0,0 @@
-/* ssl.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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
- * a with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-
-/*  ssl.h defines wolfssl_openssl compatibility layer 
- *
- */
-
-
-#ifndef WOLFSSL_OPENSSL_H_
-#define WOLFSSL_OPENSSL_H_
-
-/* wolfssl_openssl compatibility layer */
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-#ifdef _WIN32
-    /* wincrypt.h clashes */
-    #undef X509_NAME
-#endif
-
-
-typedef WOLFSSL          SSL;
-typedef WOLFSSL_SESSION  SSL_SESSION;
-typedef WOLFSSL_METHOD   SSL_METHOD;
-typedef WOLFSSL_CTX      SSL_CTX;
-
-typedef WOLFSSL_X509       X509;
-typedef WOLFSSL_X509_NAME  X509_NAME;
-typedef WOLFSSL_X509_CHAIN X509_CHAIN;
-
-
-/* redeclare guard */
-#define WOLFSSL_TYPES_DEFINED
-
-
-typedef WOLFSSL_EVP_PKEY       EVP_PKEY;
-typedef WOLFSSL_RSA            RSA;
-typedef WOLFSSL_DSA            DSA;
-typedef WOLFSSL_BIO            BIO;
-typedef WOLFSSL_BIO_METHOD     BIO_METHOD;
-typedef WOLFSSL_CIPHER         SSL_CIPHER;
-typedef WOLFSSL_X509_LOOKUP    X509_LOOKUP;
-typedef WOLFSSL_X509_LOOKUP_METHOD X509_LOOKUP_METHOD;
-typedef WOLFSSL_X509_CRL       X509_CRL;
-typedef WOLFSSL_X509_EXTENSION X509_EXTENSION;
-typedef WOLFSSL_ASN1_TIME      ASN1_TIME;
-typedef WOLFSSL_ASN1_INTEGER   ASN1_INTEGER;
-typedef WOLFSSL_ASN1_OBJECT    ASN1_OBJECT;
-typedef WOLFSSL_ASN1_STRING    ASN1_STRING;
-typedef WOLFSSL_dynlock_value  CRYPTO_dynlock_value;
-
-#define ASN1_UTCTIME WOLFSSL_ASN1_TIME
-
-typedef WOLFSSL_MD4_CTX        MD4_CTX;
-typedef WOLFSSL_COMP_METHOD    COMP_METHOD;
-typedef WOLFSSL_X509_STORE     X509_STORE;
-typedef WOLFSSL_X509_REVOKED   X509_REVOKED;
-typedef WOLFSSL_X509_OBJECT    X509_OBJECT;
-typedef WOLFSSL_X509_STORE_CTX X509_STORE_CTX;
-
-#define SSL_get_cipher_list(ctx,i)          wolfSSL_get_cipher_list((i))
-#define SSL_get_cipher_name(ctx)            wolfSSL_get_cipher((ctx))
-#define SSL_get_shared_ciphers(ctx,buf,len) \
-                                strncpy(buf, "Not Implemented, SSLv2 only", len)
-
-/* @TODO */
-#define ERR_print_errors_fp(file)
-
-/* at the moment only returns ok */
-#define SSL_get_verify_result(ctx)    X509_V_OK
-#define SSL_get_verify_mode           wolfSSL_SSL_get_mode
-#define SSL_get_verify_depth          wolfSSL_get_verify_depth
-#define SSL_CTX_get_verify_mode       wolfSSL_CTX_get_mode
-#define SSL_CTX_get_verify_depth      wolfSSL_CTX_get_verify_depth
-#define SSL_get_certificate(ctx)      0 /* used to pass to get_privatekey */
-
-#define SSLv3_server_method wolfSSLv3_server_method
-#define SSLv3_client_method wolfSSLv3_client_method
-#define TLSv1_server_method wolfTLSv1_server_method
-#define TLSv1_client_method wolfTLSv1_client_method
-#define TLSv1_1_server_method wolfTLSv1_1_server_method
-#define TLSv1_1_client_method wolfTLSv1_1_client_method
-#define TLSv1_2_server_method wolfTLSv1_2_server_method
-#define TLSv1_2_client_method wolfTLSv1_2_client_method
-
-#ifdef WOLFSSL_DTLS
-    #define DTLSv1_client_method wolfDTLSv1_client_method
-    #define DTLSv1_server_method wolfDTLSv1_server_method
-    #define DTLSv1_2_client_method wolfDTLSv1_2_client_method
-    #define DTLSv1_2_server_method wolfDTLSv1_2_server_method
-#endif
-
-
-#ifndef NO_FILESYSTEM
-    #define SSL_CTX_use_certificate_file wolfSSL_CTX_use_certificate_file
-    #define SSL_CTX_use_PrivateKey_file wolfSSL_CTX_use_PrivateKey_file
-    #define SSL_CTX_load_verify_locations wolfSSL_CTX_load_verify_locations
-    #define SSL_CTX_use_certificate_chain_file wolfSSL_CTX_use_certificate_chain_file
-    #define SSL_CTX_use_RSAPrivateKey_file wolfSSL_CTX_use_RSAPrivateKey_file
-    
-    #define SSL_use_certificate_file wolfSSL_use_certificate_file
-    #define SSL_use_PrivateKey_file wolfSSL_use_PrivateKey_file
-    #define SSL_use_certificate_chain_file wolfSSL_use_certificate_chain_file
-    #define SSL_use_RSAPrivateKey_file wolfSSL_use_RSAPrivateKey_file
-#endif
-
-#define SSL_CTX_new wolfSSL_CTX_new
-#define SSL_new     wolfSSL_new
-#define SSL_set_fd  wolfSSL_set_fd
-#define SSL_get_fd  wolfSSL_get_fd
-#define SSL_connect wolfSSL_connect
-#define SSL_clear   wolfSSL_clear
-
-#define SSL_write    wolfSSL_write
-#define SSL_read     wolfSSL_read
-#define SSL_peek     wolfSSL_peek
-#define SSL_accept   wolfSSL_accept
-#define SSL_CTX_free wolfSSL_CTX_free
-#define SSL_free     wolfSSL_free
-#define SSL_shutdown wolfSSL_shutdown
-
-#define SSL_CTX_set_quiet_shutdown wolfSSL_CTX_set_quiet_shutdown
-#define SSL_set_quiet_shutdown wolfSSL_set_quiet_shutdown
-#define SSL_get_error wolfSSL_get_error
-#define SSL_set_session wolfSSL_set_session
-#define SSL_get_session wolfSSL_get_session
-#define SSL_flush_sessions wolfSSL_flush_sessions
-/* assume unlimited temporarly */
-#define SSL_CTX_get_session_cache_mode(ctx) 0
-
-#define SSL_CTX_set_verify wolfSSL_CTX_set_verify
-#define SSL_set_verify wolfSSL_set_verify
-#define SSL_pending wolfSSL_pending
-#define SSL_load_error_strings wolfSSL_load_error_strings
-#define SSL_library_init wolfSSL_library_init
-#define SSL_CTX_set_session_cache_mode wolfSSL_CTX_set_session_cache_mode
-#define SSL_CTX_set_cipher_list wolfSSL_CTX_set_cipher_list
-#define SSL_set_cipher_list     wolfSSL_set_cipher_list
-
-#define ERR_error_string wolfSSL_ERR_error_string
-#define ERR_error_string_n wolfSSL_ERR_error_string_n
-#define ERR_reason_error_string wolfSSL_ERR_reason_error_string
-
-#define SSL_set_ex_data wolfSSL_set_ex_data
-#define SSL_get_shutdown wolfSSL_get_shutdown
-#define SSL_set_rfd wolfSSL_set_rfd
-#define SSL_set_wfd wolfSSL_set_wfd
-#define SSL_set_shutdown wolfSSL_set_shutdown
-#define SSL_set_session_id_context wolfSSL_set_session_id_context
-#define SSL_set_connect_state wolfSSL_set_connect_state
-#define SSL_set_accept_state wolfSSL_set_accept_state
-#define SSL_session_reused wolfSSL_session_reused
-#define SSL_SESSION_free wolfSSL_SESSION_free
-#define SSL_is_init_finished wolfSSL_is_init_finished
-
-#define SSL_get_version wolfSSL_get_version
-#define SSL_get_current_cipher wolfSSL_get_current_cipher
-#define SSL_get_cipher wolfSSL_get_cipher
-#define SSL_CIPHER_description wolfSSL_CIPHER_description
-#define SSL_CIPHER_get_name wolfSSL_CIPHER_get_name
-#define SSL_get1_session wolfSSL_get1_session
-
-#define SSL_get_keyblock_size wolfSSL_get_keyblock_size
-#define SSL_get_keys          wolfSSL_get_keys
-
-#define X509_free wolfSSL_X509_free
-#define OPENSSL_free wolfSSL_OPENSSL_free
-
-#define OCSP_parse_url wolfSSL_OCSP_parse_url
-#define SSLv23_client_method wolfSSLv23_client_method
-#define SSLv2_client_method wolfSSLv2_client_method
-#define SSLv2_server_method wolfSSLv2_server_method
-
-#define MD4_Init wolfSSL_MD4_Init
-#define MD4_Update  wolfSSL_MD4_Update
-#define MD4_Final wolfSSL_MD4_Final
-
-#define BIO_new      wolfSSL_BIO_new
-#define BIO_free     wolfSSL_BIO_free
-#define BIO_free_all wolfSSL_BIO_free_all
-#define BIO_read     wolfSSL_BIO_read
-#define BIO_write    wolfSSL_BIO_write
-#define BIO_push     wolfSSL_BIO_push
-#define BIO_pop      wolfSSL_BIO_pop
-#define BIO_flush    wolfSSL_BIO_flush
-#define BIO_pending  wolfSSL_BIO_pending
-
-#define BIO_get_mem_data wolfSSL_BIO_get_mem_data
-#define BIO_new_mem_buf  wolfSSL_BIO_new_mem_buf
-
-#define BIO_f_buffer              wolfSSL_BIO_f_buffer
-#define BIO_set_write_buffer_size wolfSSL_BIO_set_write_buffer_size
-#define BIO_f_ssl                 wolfSSL_BIO_f_ssl
-#define BIO_new_socket            wolfSSL_BIO_new_socket
-#define SSL_set_bio               wolfSSL_set_bio
-#define BIO_eof                   wolfSSL_BIO_eof
-#define BIO_set_ss                wolfSSL_BIO_set_ss
-
-#define BIO_s_mem     wolfSSL_BIO_s_mem
-#define BIO_f_base64  wolfSSL_BIO_f_base64
-#define BIO_set_flags wolfSSL_BIO_set_flags
-
-#define OpenSSL_add_all_algorithms wolfSSL_add_all_algorithms
-#define SSLeay_add_ssl_algorithms  wolfSSL_add_all_algorithms
-#define SSLeay_add_all_algorithms wolfSSL_add_all_algorithms
-
-#define RAND_screen     wolfSSL_RAND_screen
-#define RAND_file_name  wolfSSL_RAND_file_name
-#define RAND_write_file wolfSSL_RAND_write_file
-#define RAND_load_file  wolfSSL_RAND_load_file
-#define RAND_egd        wolfSSL_RAND_egd
-#define RAND_seed       wolfSSL_RAND_seed
-#define RAND_add        wolfSSL_RAND_add
-
-#define COMP_zlib                       wolfSSL_COMP_zlib
-#define COMP_rle                        wolfSSL_COMP_rle
-#define SSL_COMP_add_compression_method wolfSSL_COMP_add_compression_method
-
-#define SSL_get_ex_new_index wolfSSL_get_ex_new_index
-
-#define CRYPTO_set_id_callback wolfSSL_set_id_callback
-#define CRYPTO_set_locking_callback wolfSSL_set_locking_callback
-#define CRYPTO_set_dynlock_create_callback wolfSSL_set_dynlock_create_callback
-#define CRYPTO_set_dynlock_lock_callback wolfSSL_set_dynlock_lock_callback
-#define CRYPTO_set_dynlock_destroy_callback wolfSSL_set_dynlock_destroy_callback
-#define CRYPTO_num_locks wolfSSL_num_locks
-
-#define X509_STORE_CTX_get_current_cert wolfSSL_X509_STORE_CTX_get_current_cert
-#define X509_STORE_CTX_get_error wolfSSL_X509_STORE_CTX_get_error
-#define X509_STORE_CTX_get_error_depth wolfSSL_X509_STORE_CTX_get_error_depth
-
-#define X509_NAME_oneline             wolfSSL_X509_NAME_oneline
-#define X509_get_issuer_name          wolfSSL_X509_get_issuer_name
-#define X509_get_subject_name         wolfSSL_X509_get_subject_name
-#define X509_verify_cert_error_string wolfSSL_X509_verify_cert_error_string
-
-#define X509_LOOKUP_add_dir wolfSSL_X509_LOOKUP_add_dir
-#define X509_LOOKUP_load_file wolfSSL_X509_LOOKUP_load_file
-#define X509_LOOKUP_hash_dir wolfSSL_X509_LOOKUP_hash_dir
-#define X509_LOOKUP_file wolfSSL_X509_LOOKUP_file
-
-#define X509_STORE_add_lookup wolfSSL_X509_STORE_add_lookup
-#define X509_STORE_new wolfSSL_X509_STORE_new
-#define X509_STORE_get_by_subject wolfSSL_X509_STORE_get_by_subject
-#define X509_STORE_CTX_init wolfSSL_X509_STORE_CTX_init
-#define X509_STORE_CTX_cleanup wolfSSL_X509_STORE_CTX_cleanup
-
-#define X509_CRL_get_lastUpdate wolfSSL_X509_CRL_get_lastUpdate
-#define X509_CRL_get_nextUpdate wolfSSL_X509_CRL_get_nextUpdate
-
-#define X509_get_pubkey           wolfSSL_X509_get_pubkey
-#define X509_CRL_verify           wolfSSL_X509_CRL_verify
-#define X509_STORE_CTX_set_error  wolfSSL_X509_STORE_CTX_set_error
-#define X509_OBJECT_free_contents wolfSSL_X509_OBJECT_free_contents
-#define EVP_PKEY_free             wolfSSL_EVP_PKEY_free
-#define X509_cmp_current_time     wolfSSL_X509_cmp_current_time
-#define sk_X509_REVOKED_num       wolfSSL_sk_X509_REVOKED_num
-#define X509_CRL_get_REVOKED      wolfSSL_X509_CRL_get_REVOKED
-#define sk_X509_REVOKED_value     wolfSSL_sk_X509_REVOKED_value
-#define X509_get_notBefore(cert)  (ASN1_TIME*)wolfSSL_X509_notBefore((cert))
-#define X509_get_notAfter(cert)   (ASN1_TIME*)wolfSSL_X509_notAfter((cert))
-
-
-#define X509_get_serialNumber wolfSSL_X509_get_serialNumber
-
-#define ASN1_TIME_pr wolfSSL_ASN1_TIME_pr
-
-#define ASN1_INTEGER_cmp wolfSSL_ASN1_INTEGER_cmp
-#define ASN1_INTEGER_get wolfSSL_ASN1_INTEGER_get
-
-#define SSL_load_client_CA_file wolfSSL_load_client_CA_file
-
-#define SSL_CTX_set_client_CA_list         wolfSSL_CTX_set_client_CA_list
-#define X509_STORE_CTX_get_ex_data         wolfSSL_X509_STORE_CTX_get_ex_data
-#define SSL_get_ex_data_X509_STORE_CTX_idx wolfSSL_get_ex_data_X509_STORE_CTX_idx
-#define SSL_get_ex_data wolfSSL_get_ex_data
-
-#define SSL_CTX_set_default_passwd_cb_userdata wolfSSL_CTX_set_default_passwd_cb_userdata
-#define SSL_CTX_set_default_passwd_cb wolfSSL_CTX_set_default_passwd_cb
-
-#define SSL_CTX_set_timeout wolfSSL_CTX_set_timeout
-#define SSL_CTX_set_info_callback wolfSSL_CTX_set_info_callback
-
-#define ERR_peek_error wolfSSL_ERR_peek_error
-#define ERR_GET_REASON wolfSSL_ERR_GET_REASON
-
-#define SSL_alert_type_string wolfSSL_alert_type_string
-#define SSL_alert_desc_string wolfSSL_alert_desc_string
-#define SSL_state_string wolfSSL_state_string
-
-#define RSA_free wolfSSL_RSA_free
-#define RSA_generate_key wolfSSL_RSA_generate_key
-#define SSL_CTX_set_tmp_rsa_callback wolfSSL_CTX_set_tmp_rsa_callback
-
-#define PEM_def_callback wolfSSL_PEM_def_callback
-
-#define SSL_CTX_sess_accept wolfSSL_CTX_sess_accept
-#define SSL_CTX_sess_connect wolfSSL_CTX_sess_connect
-#define SSL_CTX_sess_accept_good wolfSSL_CTX_sess_accept_good
-#define SSL_CTX_sess_connect_good wolfSSL_CTX_sess_connect_good
-#define SSL_CTX_sess_accept_renegotiate wolfSSL_CTX_sess_accept_renegotiate
-#define SSL_CTX_sess_connect_renegotiate wolfSSL_CTX_sess_connect_renegotiate
-#define SSL_CTX_sess_hits wolfSSL_CTX_sess_hits
-#define SSL_CTX_sess_cb_hits wolfSSL_CTX_sess_cb_hits
-#define SSL_CTX_sess_cache_full wolfSSL_CTX_sess_cache_full
-#define SSL_CTX_sess_misses wolfSSL_CTX_sess_misses
-#define SSL_CTX_sess_timeouts wolfSSL_CTX_sess_timeouts
-#define SSL_CTX_sess_number wolfSSL_CTX_sess_number
-#define SSL_CTX_sess_get_cache_size wolfSSL_CTX_sess_get_cache_size
-
-
-#define SSL_DEFAULT_CIPHER_LIST WOLFSSL_DEFAULT_CIPHER_LIST
-#define RSA_F4 WOLFSSL_RSA_F4
-
-#define SSL_CTX_set_psk_client_callback wolfSSL_CTX_set_psk_client_callback
-#define SSL_set_psk_client_callback wolfSSL_set_psk_client_callback
-
-#define SSL_get_psk_identity_hint wolfSSL_get_psk_identity_hint
-#define SSL_get_psk_identity wolfSSL_get_psk_identity
-
-#define SSL_CTX_use_psk_identity_hint wolfSSL_CTX_use_psk_identity_hint
-#define SSL_use_psk_identity_hint wolfSSL_use_psk_identity_hint
-
-#define SSL_CTX_set_psk_server_callback wolfSSL_CTX_set_psk_server_callback
-#define SSL_set_psk_server_callback wolfSSL_set_psk_server_callback
-
-#define ERR_get_error_line_data wolfSSL_ERR_get_error_line_data
-
-#define ERR_get_error wolfSSL_ERR_get_error
-#define ERR_clear_error wolfSSL_ERR_clear_error
-
-#define RAND_status wolfSSL_RAND_status
-#define RAND_bytes wolfSSL_RAND_bytes
-#define SSLv23_server_method wolfSSLv23_server_method
-#define SSL_CTX_set_options wolfSSL_CTX_set_options 
-#define SSL_CTX_check_private_key wolfSSL_CTX_check_private_key
-
-#define ERR_free_strings wolfSSL_ERR_free_strings
-#define ERR_remove_state wolfSSL_ERR_remove_state
-#define EVP_cleanup wolfSSL_EVP_cleanup
-
-#define CRYPTO_cleanup_all_ex_data wolfSSL_cleanup_all_ex_data
-#define SSL_CTX_set_mode wolfSSL_CTX_set_mode
-#define SSL_CTX_get_mode wolfSSL_CTX_get_mode
-#define SSL_CTX_set_default_read_ahead wolfSSL_CTX_set_default_read_ahead
-
-#define SSL_CTX_sess_set_cache_size wolfSSL_CTX_sess_set_cache_size
-#define SSL_CTX_set_default_verify_paths wolfSSL_CTX_set_default_verify_paths
-
-#define SSL_CTX_set_session_id_context wolfSSL_CTX_set_session_id_context
-#define SSL_get_peer_certificate wolfSSL_get_peer_certificate
-
-#define SSL_want_read wolfSSL_want_read
-#define SSL_want_write wolfSSL_want_write
-
-#define BIO_prf wolfSSL_BIO_prf
-#define ASN1_UTCTIME_pr wolfSSL_ASN1_UTCTIME_pr
-
-#define sk_num wolfSSL_sk_num
-#define sk_value wolfSSL_sk_value
-
-#define SSL_CTX_get_ex_data wolfSSL_CTX_get_ex_data
-#define SSL_CTX_set_ex_data wolfSSL_CTX_set_ex_data
-#define SSL_CTX_sess_set_get_cb wolfSSL_CTX_sess_set_get_cb
-#define SSL_CTX_sess_set_new_cb wolfSSL_CTX_sess_set_new_cb
-#define SSL_CTX_sess_set_remove_cb wolfSSL_CTX_sess_set_remove_cb
-
-#define i2d_SSL_SESSION wolfSSL_i2d_SSL_SESSION
-#define d2i_SSL_SESSION wolfSSL_d2i_SSL_SESSION
-#define SSL_SESSION_set_timeout wolfSSL_SSL_SESSION_set_timeout
-#define SSL_SESSION_get_timeout wolfSSL_SESSION_get_timeout
-#define SSL_SESSION_get_time wolfSSL_SESSION_get_time
-#define SSL_CTX_get_ex_new_index wolfSSL_CTX_get_ex_new_index
-
-/* yassl had set the default to be 500 */
-#define SSL_get_default_timeout(ctx) 500
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-
-#endif /* wolfSSL_openssl_h__ */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/stack.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/stack.h
deleted file mode 100755
index 374c1fc..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/stack.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* stack.h for openssl */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ui.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ui.h
deleted file mode 100755
index a253930..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/ui.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* ui.h for openssl */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/x509.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/x509.h
deleted file mode 100755
index 9d13002..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/x509.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/* x509.h for openssl */
-
-#include 
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/x509v3.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/x509v3.h
deleted file mode 100755
index 77828a3..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/openssl/x509v3.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* x509v3.h for openssl */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/options.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/options.h
deleted file mode 100755
index d1e362c..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/options.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* options.h.in
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/* default blank options for autoconf */
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/options.h.in b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/options.h.in
deleted file mode 100755
index d1e362c..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/options.h.in
+++ /dev/null
@@ -1,34 +0,0 @@
-/* options.h.in
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/* default blank options for autoconf */
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/sniffer.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/sniffer.h
deleted file mode 100755
index a14f883..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/sniffer.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* sniffer.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLFSSL_SNIFFER_H
-#define WOLFSSL_SNIFFER_H
-
-#include 
-
-#ifdef _WIN32
-    #ifdef SSL_SNIFFER_EXPORTS
-        #define SSL_SNIFFER_API __declspec(dllexport)
-    #else
-        #define SSL_SNIFFER_API __declspec(dllimport)
-    #endif
-#else
-    #define SSL_SNIFFER_API
-#endif /* _WIN32 */
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-/* @param typeK: (formerly keyType) was shadowing a global declaration in 
- *                wolfssl/wolfcrypt/asn.h line 175
- */
-WOLFSSL_API 
-SSL_SNIFFER_API int ssl_SetPrivateKey(const char* address, int port,
-                                      const char* keyFile, int typeK,
-                                      const char* password, char* error);
-
-WOLFSSL_API
-SSL_SNIFFER_API int ssl_SetNamedPrivateKey(const char* name,
-                                           const char* address, int port,
-                                           const char* keyFile, int typeK,
-                                           const char* password, char* error);
-
-WOLFSSL_API 
-SSL_SNIFFER_API int ssl_DecodePacket(const unsigned char* packet, int length,
-                                     unsigned char* data, char* error);
-
-WOLFSSL_API 
-SSL_SNIFFER_API int ssl_Trace(const char* traceFile, char* error);
-        
-        
-WOLFSSL_API void ssl_InitSniffer(void);
-        
-WOLFSSL_API void ssl_FreeSniffer(void);
-
-        
-/* ssl_SetPrivateKey typeKs */
-enum {
-    FILETYPE_PEM = 1,
-    FILETYPE_DER = 2,
-};
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */
-#endif
-
-#endif /* wolfSSL_SNIFFER_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/sniffer_error.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/sniffer_error.h
deleted file mode 100755
index ad89a50..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/sniffer_error.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* sniffer_error.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLFSSL_SNIFFER_ERROR_H
-#define WOLFSSL_SNIFFER_ERROR_H
-
-/* need to have errors as #defines since .rc files can't handle enums */
-/* need to start at 1 and go in order for same reason */
-
-#define MEMORY_STR 1
-#define NEW_SERVER_STR 2
-#define IP_CHECK_STR 3
-#define SERVER_NOT_REG_STR 4
-#define TCP_CHECK_STR 5
-#define SERVER_PORT_NOT_REG_STR 6
-#define RSA_DECRYPT_STR 7
-#define RSA_DECODE_STR 8
-#define BAD_CIPHER_SPEC_STR 9
-#define SERVER_HELLO_INPUT_STR 10
-
-#define BAD_SESSION_RESUME_STR 11
-#define SERVER_DID_RESUMPTION_STR 12
-#define CLIENT_HELLO_INPUT_STR 13
-#define CLIENT_RESUME_TRY_STR 14
-#define HANDSHAKE_INPUT_STR 15
-#define GOT_HELLO_VERIFY_STR 16
-#define GOT_SERVER_HELLO_STR 17
-#define GOT_CERT_REQ_STR 18
-#define GOT_SERVER_KEY_EX_STR 19
-#define GOT_CERT_STR 20
-
-#define GOT_SERVER_HELLO_DONE_STR 21
-#define GOT_FINISHED_STR 22
-#define GOT_CLIENT_HELLO_STR 23
-#define GOT_CLIENT_KEY_EX_STR 24
-#define GOT_CERT_VER_STR 25
-#define GOT_UNKNOWN_HANDSHAKE_STR 26
-#define NEW_SESSION_STR 27
-#define BAD_NEW_SSL_STR 28
-#define GOT_PACKET_STR 29
-#define NO_DATA_STR 30
-
-#define BAD_SESSION_STR 31
-#define GOT_OLD_CLIENT_HELLO_STR 32
-#define OLD_CLIENT_INPUT_STR 33
-#define OLD_CLIENT_OK_STR 34
-#define BAD_OLD_CLIENT_STR 35
-#define BAD_RECORD_HDR_STR 36
-#define RECORD_INPUT_STR 37
-#define GOT_HANDSHAKE_STR 38
-#define BAD_HANDSHAKE_STR 39
-#define GOT_CHANGE_CIPHER_STR 40
-
-#define GOT_APP_DATA_STR 41
-#define BAD_APP_DATA_STR 42
-#define GOT_ALERT_STR 43
-#define ANOTHER_MSG_STR 44
-#define REMOVE_SESSION_STR 45
-#define KEY_FILE_STR 46
-#define BAD_IPVER_STR 47
-#define BAD_PROTO_STR 48
-#define PACKET_HDR_SHORT_STR 49
-#define GOT_UNKNOWN_RECORD_STR 50
-
-#define BAD_TRACE_FILE_STR 51
-#define FATAL_ERROR_STR 52
-#define PARTIAL_INPUT_STR 53
-#define BUFFER_ERROR_STR 54
-#define PARTIAL_ADD_STR 55
-#define DUPLICATE_STR 56
-#define OUT_OF_ORDER_STR 57
-#define OVERLAP_DUPLICATE_STR 58
-#define OVERLAP_REASSEMBLY_BEGIN_STR 59
-#define OVERLAP_REASSEMBLY_END_STR 60
-
-#define MISSED_CLIENT_HELLO_STR 61
-#define GOT_HELLO_REQUEST_STR 62
-#define GOT_SESSION_TICKET_STR 63
-#define BAD_INPUT_STR 64
-#define BAD_DECRYPT_TYPE 65
-#define BAD_FINISHED_MSG 66
-#define BAD_COMPRESSION_STR 67
-#define BAD_DERIVE_STR 68
-#define ACK_MISSED_STR 69
-#define BAD_DECRYPT    70 
-
-#define DECRYPT_KEYS_NOT_SETUP 71
-#define CLIENT_HELLO_LATE_KEY_STR 72
-#define GOT_CERT_STATUS_STR 73
-#define RSA_KEY_MISSING_STR 74
-/* !!!! also add to msgTable in sniffer.c and .rc file !!!! */
-
-
-#endif /* wolfSSL_SNIFFER_ERROR_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/sniffer_error.rc b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/sniffer_error.rc
deleted file mode 100755
index 8bcd692..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/sniffer_error.rc
+++ /dev/null
@@ -1,93 +0,0 @@
-
-STRINGTABLE 
-{
-    1, "Out of Memory"
-    2, "New SSL Sniffer Server Registered"
-    3, "Checking IP Header"
-    4, "SSL Sniffer Server Not Registered"
-    5, "Checking TCP Header"
-
-    6, "SSL Sniffer Server Port Not Registered"
-    7, "RSA Private Decrypt Error"
-    8, "RSA Private Decode Error"
-    9, "Set Cipher Spec Error"
-    10, "Server Hello Input Malformed"
-
-    11, "Couldn't Resume Session Error"
-    12, "Server Did Resumption"
-    13, "Client Hello Input Malformed"
-    14, "Client Trying to Resume"
-    15, "Handshake Input Malformed"
-
-    16, "Got Hello Verify msg"
-    17, "Got Server Hello msg"
-    18, "Got Cert Request msg"
-    19, "Got Server Key Exchange msg"
-    20, "Got Cert msg"
-
-    21, "Got Server Hello Done msg"
-    22, "Got Finished msg"
-    23, "Got Client Hello msg"
-    24, "Got Client Key Exchange msg"
-    25, "Got Cert Verify msg"
-
-    26, "Got Unknown Handshake msg"
-    27, "New SSL Sniffer Session created"
-    28, "Couldn't create new SSL"
-    29, "Got a Packet to decode"
-    30, "No data present"
-
-    31, "Session Not Found"
-    32, "Got an Old Client Hello msg"
-    33, "Old Client Hello Input Malformed"
-    34, "Old Client Hello OK"
-    35, "Bad Old Client Hello"
-
-    36, "Bad Record Header"
-    37, "Record Header Input Malformed"
-    38, "Got a HandShake msg"
-    39, "Bad HandShake msg"
-    40, "Got a Change Cipher Spec msg"
-
-    41, "Got Application Data msg"
-    42, "Bad Application Data"
-    43, "Got an Alert msg"
-    44, "Another msg to Process"
-    45, "Removing Session From Table"
-
-    46, "Bad Key File"
-    47, "Wrong IP Version"
-    48, "Wrong Protocol type"
-    49, "Packet Short for header processing"
-    50, "Got Unknown Record Type"
-    
-    51, "Can't Open Trace File"
-    52, "Session in Fatal Error State"
-    53, "Partial SSL record received"
-    54, "Buffer Error, malformed input"
-    55, "Added to Partial Input"
-
-    56, "Received a Duplicate Packet"
-    57, "Received an Out of Order Packet"
-    58, "Received an Overlap Duplicate Packet"
-    59, "Received an Overlap Reassembly Begin Duplicate Packet"
-    60, "Received an Overlap Reassembly End Duplicate Packet"
-    
-    61, "Missed the Client Hello Entirely"
-    62, "Got Hello Request msg"
-    63, "Got Session Ticket msg"
-    64, "Bad Input"
-    65, "Bad Decrypt Type"
-
-    66, "Bad Finished Message Processing"
-    67, "Bad Compression Type"
-    68, "Bad DeriveKeys Error"
-    69, "Saw ACK for Missing Packet Error"
-    70, "Bad Decrypt Operation"
-
-    71, "Decrypt Keys Not Set Up"
-    72, "Late Key Load Error"
-    73, "Got Certificate Status msg"
-    74, "RSA Key Missing Error"
-}
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/ssl.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/ssl.h
deleted file mode 100755
index 9c3ac84..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/ssl.h
+++ /dev/null
@@ -1,1464 +0,0 @@
-/* ssl.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-/* wolfSSL API */
-
-#ifndef WOLFSSL_SSL_H
-#define WOLFSSL_SSL_H
-
-
-/* for users not using preprocessor flags*/
-#include 
-#include 
-
-#ifndef NO_FILESYSTEM
-    #ifdef FREESCALE_MQX
-        #include 
-    #else
-        #include    /* ERR_printf */
-    #endif
-#endif
-
-#ifdef WOLFSSL_PREFIX
-    #include "prefix_ssl.h"
-#endif
-
-#ifdef LIBWOLFSSL_VERSION_STRING
-    #define WOLFSSL_VERSION LIBWOLFSSL_VERSION_STRING
-#endif
-
-#ifdef _WIN32
-    /* wincrypt.h clashes */
-    #undef OCSP_REQUEST
-    #undef OCSP_RESPONSE
-#endif
-
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-typedef struct WOLFSSL          WOLFSSL;
-typedef struct WOLFSSL_SESSION  WOLFSSL_SESSION;
-typedef struct WOLFSSL_METHOD   WOLFSSL_METHOD;
-typedef struct WOLFSSL_CTX      WOLFSSL_CTX;
-
-typedef struct WOLFSSL_X509       WOLFSSL_X509;
-typedef struct WOLFSSL_X509_NAME  WOLFSSL_X509_NAME;
-typedef struct WOLFSSL_X509_CHAIN WOLFSSL_X509_CHAIN;
-
-typedef struct WOLFSSL_CERT_MANAGER WOLFSSL_CERT_MANAGER;
-typedef struct WOLFSSL_SOCKADDR     WOLFSSL_SOCKADDR;
-
-/* redeclare guard */
-#define WOLFSSL_TYPES_DEFINED
-
-
-typedef struct WOLFSSL_RSA            WOLFSSL_RSA;
-typedef struct WOLFSSL_DSA            WOLFSSL_DSA;
-typedef struct WOLFSSL_CIPHER         WOLFSSL_CIPHER;
-typedef struct WOLFSSL_X509_LOOKUP    WOLFSSL_X509_LOOKUP;
-typedef struct WOLFSSL_X509_LOOKUP_METHOD WOLFSSL_X509_LOOKUP_METHOD;
-typedef struct WOLFSSL_X509_CRL       WOLFSSL_X509_CRL;
-typedef struct WOLFSSL_BIO            WOLFSSL_BIO;
-typedef struct WOLFSSL_BIO_METHOD     WOLFSSL_BIO_METHOD;
-typedef struct WOLFSSL_X509_EXTENSION WOLFSSL_X509_EXTENSION;
-typedef struct WOLFSSL_ASN1_TIME      WOLFSSL_ASN1_TIME;
-typedef struct WOLFSSL_ASN1_INTEGER   WOLFSSL_ASN1_INTEGER;
-typedef struct WOLFSSL_ASN1_OBJECT    WOLFSSL_ASN1_OBJECT;
-typedef struct WOLFSSL_ASN1_STRING    WOLFSSL_ASN1_STRING;
-typedef struct WOLFSSL_dynlock_value  WOLFSSL_dynlock_value;
-
-#define WOLFSSL_ASN1_UTCTIME WOLFSSL_ASN1_TIME
-
-typedef struct WOLFSSL_EVP_PKEY {
-    int type;         /* openssh dereference */
-    int save_type;    /* openssh dereference */
-    int pkey_sz;
-    union {
-        char* ptr;
-    } pkey;
-    #ifdef HAVE_ECC
-        int pkey_curve;
-    #endif
-} WOLFSSL_EVP_PKEY;
-
-typedef struct WOLFSSL_MD4_CTX {
-    int buffer[32];      /* big enough to hold, check size in Init */
-} WOLFSSL_MD4_CTX;
-
-
-typedef struct WOLFSSL_COMP_METHOD {
-    int type;            /* stunnel dereference */
-} WOLFSSL_COMP_METHOD;
-
-
-typedef struct WOLFSSL_X509_STORE {
-    int                  cache;          /* stunnel dereference */
-    WOLFSSL_CERT_MANAGER* cm;
-} WOLFSSL_X509_STORE;
-
-typedef struct WOLFSSL_ALERT {
-    int code;
-    int level;
-} WOLFSSL_ALERT;
-
-typedef struct WOLFSSL_ALERT_HISTORY {
-    WOLFSSL_ALERT last_rx;
-    WOLFSSL_ALERT last_tx;
-} WOLFSSL_ALERT_HISTORY;
-
-typedef struct WOLFSSL_X509_REVOKED {
-    WOLFSSL_ASN1_INTEGER* serialNumber;          /* stunnel dereference */
-} WOLFSSL_X509_REVOKED;
-
-
-typedef struct WOLFSSL_X509_OBJECT {
-    union {
-        char* ptr;
-        WOLFSSL_X509_CRL* crl;           /* stunnel dereference */
-    } data;
-} WOLFSSL_X509_OBJECT;
-
-
-typedef struct WOLFSSL_X509_STORE_CTX {
-    WOLFSSL_X509_STORE* store;    /* Store full of a CA cert chain */
-    WOLFSSL_X509* current_cert;   /* stunnel dereference */
-    char* domain;                /* subject CN domain name */
-    void* ex_data;               /* external data, for fortress build */
-    void* userCtx;               /* user ctx */
-    int   error;                 /* current error */
-    int   error_depth;           /* cert depth for this error */
-    int   discardSessionCerts;   /* so verify callback can flag for discard */
-} WOLFSSL_X509_STORE_CTX;
-
-
-/* Valid Alert types from page 16/17 */
-enum AlertDescription {
-    close_notify            = 0,
-    unexpected_message      = 10,
-    bad_record_mac          = 20,
-    record_overflow         = 22,
-    decompression_failure   = 30,
-    handshake_failure       = 40,
-    no_certificate          = 41,
-    bad_certificate         = 42,
-    unsupported_certificate = 43,
-    certificate_revoked     = 44,
-    certificate_expired     = 45,
-    certificate_unknown     = 46,
-    illegal_parameter       = 47,
-    decrypt_error           = 51,
-    #ifdef WOLFSSL_MYSQL_COMPATIBLE
-    /* catch name conflict for enum protocol with MYSQL build */
-    wc_protocol_version     = 70,
-    #else
-    protocol_version        = 70,
-    #endif
-    no_renegotiation        = 100,
-    unrecognized_name       = 112
-};
-
-
-enum AlertLevel {
-    alert_warning = 1,
-    alert_fatal = 2
-};
-
-
-WOLFSSL_API WOLFSSL_METHOD *wolfSSLv3_server_method(void);
-WOLFSSL_API WOLFSSL_METHOD *wolfSSLv3_client_method(void);
-WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_server_method(void);
-WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_client_method(void);
-WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_1_server_method(void);
-WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_1_client_method(void);
-WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_2_server_method(void);
-WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_2_client_method(void);
-
-#ifdef WOLFSSL_DTLS
-    WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_client_method(void);
-    WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_server_method(void);
-    WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_2_client_method(void);
-    WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_2_server_method(void);
-#endif
-
-#ifdef HAVE_POLY1305
-    WOLFSSL_API int wolfSSL_use_old_poly(WOLFSSL*, int);
-#endif
-
-#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
-
-WOLFSSL_API int wolfSSL_CTX_use_certificate_file(WOLFSSL_CTX*, const char*, int);
-WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_file(WOLFSSL_CTX*, const char*, int);
-WOLFSSL_API int wolfSSL_CTX_load_verify_locations(WOLFSSL_CTX*, const char*,
-                                                const char*);
-WOLFSSL_API int wolfSSL_CTX_use_certificate_chain_file(WOLFSSL_CTX *,
-                                                     const char *file);
-WOLFSSL_API int wolfSSL_CTX_use_RSAPrivateKey_file(WOLFSSL_CTX*, const char*, int);
-
-WOLFSSL_API long wolfSSL_get_verify_depth(WOLFSSL* ssl);
-WOLFSSL_API long wolfSSL_CTX_get_verify_depth(WOLFSSL_CTX* ctx);
-WOLFSSL_API int wolfSSL_use_certificate_file(WOLFSSL*, const char*, int);
-WOLFSSL_API int wolfSSL_use_PrivateKey_file(WOLFSSL*, const char*, int);
-WOLFSSL_API int wolfSSL_use_certificate_chain_file(WOLFSSL*, const char *file);
-WOLFSSL_API int wolfSSL_use_RSAPrivateKey_file(WOLFSSL*, const char*, int);
-
-#ifdef WOLFSSL_DER_LOAD
-    WOLFSSL_API int wolfSSL_CTX_der_load_verify_locations(WOLFSSL_CTX*,
-                                                    const char*, int);
-#endif
-
-#ifdef HAVE_NTRU
-    WOLFSSL_API int wolfSSL_CTX_use_NTRUPrivateKey_file(WOLFSSL_CTX*, const char*);
-    /* load NTRU private key blob */
-#endif
-
-#ifndef WOLFSSL_PEMCERT_TODER_DEFINED
-    WOLFSSL_API int wolfSSL_PemCertToDer(const char*, unsigned char*, int);
-    #define WOLFSSL_PEMCERT_TODER_DEFINED
-#endif
-
-#endif /* !NO_FILESYSTEM && !NO_CERTS */
-
-WOLFSSL_API WOLFSSL_CTX* wolfSSL_CTX_new(WOLFSSL_METHOD*);
-WOLFSSL_API WOLFSSL* wolfSSL_new(WOLFSSL_CTX*);
-WOLFSSL_API int  wolfSSL_set_fd (WOLFSSL*, int);
-WOLFSSL_API char* wolfSSL_get_cipher_list(int priority);
-WOLFSSL_API int  wolfSSL_get_ciphers(char*, int);
-WOLFSSL_API int  wolfSSL_get_fd(const WOLFSSL*);
-WOLFSSL_API void wolfSSL_set_using_nonblock(WOLFSSL*, int);
-WOLFSSL_API int  wolfSSL_get_using_nonblock(WOLFSSL*);
-WOLFSSL_API int  wolfSSL_connect(WOLFSSL*);     /* please see note at top of README
-                                             if you get an error from connect */
-WOLFSSL_API int  wolfSSL_write(WOLFSSL*, const void*, int);
-WOLFSSL_API int  wolfSSL_read(WOLFSSL*, void*, int);
-WOLFSSL_API int  wolfSSL_peek(WOLFSSL*, void*, int);
-WOLFSSL_API int  wolfSSL_accept(WOLFSSL*);
-WOLFSSL_API void wolfSSL_CTX_free(WOLFSSL_CTX*);
-WOLFSSL_API void wolfSSL_free(WOLFSSL*);
-WOLFSSL_API int  wolfSSL_shutdown(WOLFSSL*);
-WOLFSSL_API int  wolfSSL_send(WOLFSSL*, const void*, int sz, int flags);
-WOLFSSL_API int  wolfSSL_recv(WOLFSSL*, void*, int sz, int flags);
-
-WOLFSSL_API void wolfSSL_CTX_set_quiet_shutdown(WOLFSSL_CTX*, int);
-WOLFSSL_API void wolfSSL_set_quiet_shutdown(WOLFSSL*, int);
-
-WOLFSSL_API int  wolfSSL_get_error(WOLFSSL*, int);
-WOLFSSL_API int  wolfSSL_get_alert_history(WOLFSSL*, WOLFSSL_ALERT_HISTORY *);
-
-WOLFSSL_API int        wolfSSL_set_session(WOLFSSL* ssl,WOLFSSL_SESSION* session);
-WOLFSSL_API long       wolfSSL_SSL_SESSION_set_timeout(WOLFSSL_SESSION* session, long t);
-WOLFSSL_API WOLFSSL_SESSION* wolfSSL_get_session(WOLFSSL* ssl);
-WOLFSSL_API void       wolfSSL_flush_sessions(WOLFSSL_CTX *ctx, long tm);
-WOLFSSL_API int        wolfSSL_SetServerID(WOLFSSL* ssl, const unsigned char*,
-                                         int, int);
-
-#ifdef SESSION_INDEX
-WOLFSSL_API int wolfSSL_GetSessionIndex(WOLFSSL* ssl);
-WOLFSSL_API int wolfSSL_GetSessionAtIndex(int index, WOLFSSL_SESSION* session);
-#endif /* SESSION_INDEX */
-
-#if defined(SESSION_INDEX) && defined(SESSION_CERTS)
-WOLFSSL_API
-    WOLFSSL_X509_CHAIN* wolfSSL_SESSION_get_peer_chain(WOLFSSL_SESSION* session);
-#endif /* SESSION_INDEX && SESSION_CERTS */
-
-typedef int (*VerifyCallback)(int, WOLFSSL_X509_STORE_CTX*);
-typedef int (*pem_password_cb)(char*, int, int, void*);
-
-WOLFSSL_API void wolfSSL_CTX_set_verify(WOLFSSL_CTX*, int,
-                                      VerifyCallback verify_callback);
-WOLFSSL_API void wolfSSL_set_verify(WOLFSSL*, int, VerifyCallback verify_callback);
-WOLFSSL_API void wolfSSL_SetCertCbCtx(WOLFSSL*, void*);
-
-WOLFSSL_API int  wolfSSL_pending(WOLFSSL*);
-
-WOLFSSL_API void wolfSSL_load_error_strings(void);
-WOLFSSL_API int  wolfSSL_library_init(void);
-WOLFSSL_API long wolfSSL_CTX_set_session_cache_mode(WOLFSSL_CTX*, long);
-
-#ifdef HAVE_SECRET_CALLBACK
-typedef int (*SessionSecretCb)(WOLFSSL* ssl,
-                                        void* secret, int* secretSz, void* ctx);
-WOLFSSL_API int  wolfSSL_set_session_secret_cb(WOLFSSL*, SessionSecretCb, void*);
-#endif /* HAVE_SECRET_CALLBACK */
-
-/* session cache persistence */
-WOLFSSL_API int  wolfSSL_save_session_cache(const char*);
-WOLFSSL_API int  wolfSSL_restore_session_cache(const char*);
-WOLFSSL_API int  wolfSSL_memsave_session_cache(void*, int);
-WOLFSSL_API int  wolfSSL_memrestore_session_cache(const void*, int);
-WOLFSSL_API int  wolfSSL_get_session_cache_memsize(void);
-
-/* certificate cache persistence, uses ctx since certs are per ctx */
-WOLFSSL_API int  wolfSSL_CTX_save_cert_cache(WOLFSSL_CTX*, const char*);
-WOLFSSL_API int  wolfSSL_CTX_restore_cert_cache(WOLFSSL_CTX*, const char*);
-WOLFSSL_API int  wolfSSL_CTX_memsave_cert_cache(WOLFSSL_CTX*, void*, int, int*);
-WOLFSSL_API int  wolfSSL_CTX_memrestore_cert_cache(WOLFSSL_CTX*, const void*, int);
-WOLFSSL_API int  wolfSSL_CTX_get_cert_cache_memsize(WOLFSSL_CTX*);
-
-/* only supports full name from cipher_name[] delimited by : */
-WOLFSSL_API int  wolfSSL_CTX_set_cipher_list(WOLFSSL_CTX*, const char*);
-WOLFSSL_API int  wolfSSL_set_cipher_list(WOLFSSL*, const char*);
-
-/* Nonblocking DTLS helper functions */
-WOLFSSL_API int  wolfSSL_dtls_get_current_timeout(WOLFSSL* ssl);
-WOLFSSL_API int  wolfSSL_dtls_set_timeout_init(WOLFSSL* ssl, int);
-WOLFSSL_API int  wolfSSL_dtls_set_timeout_max(WOLFSSL* ssl, int);
-WOLFSSL_API int  wolfSSL_dtls_got_timeout(WOLFSSL* ssl);
-WOLFSSL_API int  wolfSSL_dtls(WOLFSSL* ssl);
-
-WOLFSSL_API int  wolfSSL_dtls_set_peer(WOLFSSL*, void*, unsigned int);
-WOLFSSL_API int  wolfSSL_dtls_get_peer(WOLFSSL*, void*, unsigned int*);
-
-WOLFSSL_API int   wolfSSL_ERR_GET_REASON(int err);
-WOLFSSL_API char* wolfSSL_ERR_error_string(unsigned long,char*);
-WOLFSSL_API void  wolfSSL_ERR_error_string_n(unsigned long e, char* buf,
-                                           unsigned long sz);
-WOLFSSL_API const char* wolfSSL_ERR_reason_error_string(unsigned long);
-
-/* extras */
-
-#define STACK_OF(x) x
-
-WOLFSSL_API int  wolfSSL_set_ex_data(WOLFSSL*, int, void*);
-WOLFSSL_API int  wolfSSL_get_shutdown(const WOLFSSL*);
-WOLFSSL_API int  wolfSSL_set_rfd(WOLFSSL*, int);
-WOLFSSL_API int  wolfSSL_set_wfd(WOLFSSL*, int);
-WOLFSSL_API void wolfSSL_set_shutdown(WOLFSSL*, int);
-WOLFSSL_API int  wolfSSL_set_session_id_context(WOLFSSL*, const unsigned char*,
-                                           unsigned int);
-WOLFSSL_API void wolfSSL_set_connect_state(WOLFSSL*);
-WOLFSSL_API void wolfSSL_set_accept_state(WOLFSSL*);
-WOLFSSL_API int  wolfSSL_session_reused(WOLFSSL*);
-WOLFSSL_API void wolfSSL_SESSION_free(WOLFSSL_SESSION* session);
-WOLFSSL_API int  wolfSSL_is_init_finished(WOLFSSL*);
-
-WOLFSSL_API const char*  wolfSSL_get_version(WOLFSSL*);
-WOLFSSL_API int  wolfSSL_get_current_cipher_suite(WOLFSSL* ssl);
-WOLFSSL_API WOLFSSL_CIPHER*  wolfSSL_get_current_cipher(WOLFSSL*);
-WOLFSSL_API char*        wolfSSL_CIPHER_description(WOLFSSL_CIPHER*, char*, int);
-WOLFSSL_API const char*  wolfSSL_CIPHER_get_name(const WOLFSSL_CIPHER* cipher);
-WOLFSSL_API const char*  wolfSSL_get_cipher(WOLFSSL*);
-WOLFSSL_API WOLFSSL_SESSION* wolfSSL_get1_session(WOLFSSL* ssl);
-                           /* what's ref count */
-
-WOLFSSL_API void wolfSSL_X509_free(WOLFSSL_X509*);
-WOLFSSL_API void wolfSSL_OPENSSL_free(void*);
-
-WOLFSSL_API int wolfSSL_OCSP_parse_url(char* url, char** host, char** port,
-                                     char** path, int* ssl);
-
-WOLFSSL_API WOLFSSL_METHOD* wolfSSLv23_client_method(void);
-WOLFSSL_API WOLFSSL_METHOD* wolfSSLv2_client_method(void);
-WOLFSSL_API WOLFSSL_METHOD* wolfSSLv2_server_method(void);
-
-WOLFSSL_API void wolfSSL_MD4_Init(WOLFSSL_MD4_CTX*);
-WOLFSSL_API void wolfSSL_MD4_Update(WOLFSSL_MD4_CTX*, const void*, unsigned long);
-WOLFSSL_API void wolfSSL_MD4_Final(unsigned char*, WOLFSSL_MD4_CTX*);
-
-
-WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_new(WOLFSSL_BIO_METHOD*);
-WOLFSSL_API int  wolfSSL_BIO_free(WOLFSSL_BIO*);
-WOLFSSL_API int  wolfSSL_BIO_free_all(WOLFSSL_BIO*);
-WOLFSSL_API int  wolfSSL_BIO_read(WOLFSSL_BIO*, void*, int);
-WOLFSSL_API int  wolfSSL_BIO_write(WOLFSSL_BIO*, const void*, int);
-WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_push(WOLFSSL_BIO*, WOLFSSL_BIO* append);
-WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_pop(WOLFSSL_BIO*);
-WOLFSSL_API int  wolfSSL_BIO_flush(WOLFSSL_BIO*);
-WOLFSSL_API int  wolfSSL_BIO_pending(WOLFSSL_BIO*);
-
-WOLFSSL_API WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_buffer(void);
-WOLFSSL_API long wolfSSL_BIO_set_write_buffer_size(WOLFSSL_BIO*, long size);
-WOLFSSL_API WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_ssl(void);
-WOLFSSL_API WOLFSSL_BIO*        wolfSSL_BIO_new_socket(int sfd, int flag);
-WOLFSSL_API int         wolfSSL_BIO_eof(WOLFSSL_BIO*);
-
-WOLFSSL_API WOLFSSL_BIO_METHOD* wolfSSL_BIO_s_mem(void);
-WOLFSSL_API WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_base64(void);
-WOLFSSL_API void wolfSSL_BIO_set_flags(WOLFSSL_BIO*, int);
-
-WOLFSSL_API int wolfSSL_BIO_get_mem_data(WOLFSSL_BIO* bio,const unsigned char** p);
-WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_new_mem_buf(void* buf, int len);
-
-
-WOLFSSL_API long        wolfSSL_BIO_set_ssl(WOLFSSL_BIO*, WOLFSSL*, int flag);
-WOLFSSL_API void        wolfSSL_set_bio(WOLFSSL*, WOLFSSL_BIO* rd, WOLFSSL_BIO* wr);
-
-WOLFSSL_API int  wolfSSL_add_all_algorithms(void);
-
-WOLFSSL_API void        wolfSSL_RAND_screen(void);
-WOLFSSL_API const char* wolfSSL_RAND_file_name(char*, unsigned long);
-WOLFSSL_API int         wolfSSL_RAND_write_file(const char*);
-WOLFSSL_API int         wolfSSL_RAND_load_file(const char*, long);
-WOLFSSL_API int         wolfSSL_RAND_egd(const char*);
-WOLFSSL_API int         wolfSSL_RAND_seed(const void*, int);
-WOLFSSL_API void        wolfSSL_RAND_add(const void*, int, double);
-
-WOLFSSL_API WOLFSSL_COMP_METHOD* wolfSSL_COMP_zlib(void);
-WOLFSSL_API WOLFSSL_COMP_METHOD* wolfSSL_COMP_rle(void);
-WOLFSSL_API int wolfSSL_COMP_add_compression_method(int, void*);
-
-WOLFSSL_API int wolfSSL_get_ex_new_index(long, void*, void*, void*, void*);
-
-WOLFSSL_API void wolfSSL_set_id_callback(unsigned long (*f)(void));
-WOLFSSL_API void wolfSSL_set_locking_callback(void (*f)(int, int, const char*,
-                                                      int));
-WOLFSSL_API void wolfSSL_set_dynlock_create_callback(WOLFSSL_dynlock_value* (*f)
-                                                   (const char*, int));
-WOLFSSL_API void wolfSSL_set_dynlock_lock_callback(void (*f)(int,
-                                      WOLFSSL_dynlock_value*, const char*, int));
-WOLFSSL_API void wolfSSL_set_dynlock_destroy_callback(void (*f)
-                                     (WOLFSSL_dynlock_value*, const char*, int));
-WOLFSSL_API int  wolfSSL_num_locks(void);
-
-WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_STORE_CTX_get_current_cert(
-                                                        WOLFSSL_X509_STORE_CTX*);
-WOLFSSL_API int   wolfSSL_X509_STORE_CTX_get_error(WOLFSSL_X509_STORE_CTX*);
-WOLFSSL_API int   wolfSSL_X509_STORE_CTX_get_error_depth(WOLFSSL_X509_STORE_CTX*);
-
-WOLFSSL_API char*       wolfSSL_X509_NAME_oneline(WOLFSSL_X509_NAME*, char*, int);
-WOLFSSL_API WOLFSSL_X509_NAME*  wolfSSL_X509_get_issuer_name(WOLFSSL_X509*);
-WOLFSSL_API WOLFSSL_X509_NAME*  wolfSSL_X509_get_subject_name(WOLFSSL_X509*);
-WOLFSSL_API int  wolfSSL_X509_ext_isSet_by_NID(WOLFSSL_X509*, int);
-WOLFSSL_API int  wolfSSL_X509_ext_get_critical_by_NID(WOLFSSL_X509*, int);
-WOLFSSL_API int  wolfSSL_X509_get_isCA(WOLFSSL_X509*);
-WOLFSSL_API int  wolfSSL_X509_get_isSet_pathLength(WOLFSSL_X509*);
-WOLFSSL_API unsigned int wolfSSL_X509_get_pathLength(WOLFSSL_X509*);
-WOLFSSL_API unsigned int wolfSSL_X509_get_keyUsage(WOLFSSL_X509*);
-WOLFSSL_API unsigned char* wolfSSL_X509_get_authorityKeyID(
-                                            WOLFSSL_X509*, unsigned char*, int*);
-WOLFSSL_API unsigned char* wolfSSL_X509_get_subjectKeyID(
-                                            WOLFSSL_X509*, unsigned char*, int*);
-WOLFSSL_API int wolfSSL_X509_NAME_entry_count(WOLFSSL_X509_NAME*);
-WOLFSSL_API int wolfSSL_X509_NAME_get_text_by_NID(
-                                            WOLFSSL_X509_NAME*, int, char*, int);
-WOLFSSL_API int         wolfSSL_X509_verify_cert(WOLFSSL_X509_STORE_CTX*);
-WOLFSSL_API const char* wolfSSL_X509_verify_cert_error_string(long);
-WOLFSSL_API int wolfSSL_X509_get_signature_type(WOLFSSL_X509*);
-WOLFSSL_API int wolfSSL_X509_get_signature(WOLFSSL_X509*, unsigned char*, int*);
-
-WOLFSSL_API int wolfSSL_X509_LOOKUP_add_dir(WOLFSSL_X509_LOOKUP*,const char*,long);
-WOLFSSL_API int wolfSSL_X509_LOOKUP_load_file(WOLFSSL_X509_LOOKUP*, const char*,
-                                            long);
-WOLFSSL_API WOLFSSL_X509_LOOKUP_METHOD* wolfSSL_X509_LOOKUP_hash_dir(void);
-WOLFSSL_API WOLFSSL_X509_LOOKUP_METHOD* wolfSSL_X509_LOOKUP_file(void);
-
-WOLFSSL_API WOLFSSL_X509_LOOKUP* wolfSSL_X509_STORE_add_lookup(WOLFSSL_X509_STORE*,
-                                                    WOLFSSL_X509_LOOKUP_METHOD*);
-WOLFSSL_API WOLFSSL_X509_STORE*  wolfSSL_X509_STORE_new(void);
-WOLFSSL_API void         wolfSSL_X509_STORE_free(WOLFSSL_X509_STORE*);
-WOLFSSL_API int          wolfSSL_X509_STORE_add_cert(
-                                              WOLFSSL_X509_STORE*, WOLFSSL_X509*);
-WOLFSSL_API int          wolfSSL_X509_STORE_set_default_paths(WOLFSSL_X509_STORE*);
-WOLFSSL_API int          wolfSSL_X509_STORE_get_by_subject(WOLFSSL_X509_STORE_CTX*,
-                                   int, WOLFSSL_X509_NAME*, WOLFSSL_X509_OBJECT*);
-WOLFSSL_API WOLFSSL_X509_STORE_CTX* wolfSSL_X509_STORE_CTX_new(void);
-WOLFSSL_API int  wolfSSL_X509_STORE_CTX_init(WOLFSSL_X509_STORE_CTX*,
-                      WOLFSSL_X509_STORE*, WOLFSSL_X509*, STACK_OF(WOLFSSL_X509)*);
-WOLFSSL_API void wolfSSL_X509_STORE_CTX_free(WOLFSSL_X509_STORE_CTX*);
-WOLFSSL_API void wolfSSL_X509_STORE_CTX_cleanup(WOLFSSL_X509_STORE_CTX*);
-
-WOLFSSL_API WOLFSSL_ASN1_TIME* wolfSSL_X509_CRL_get_lastUpdate(WOLFSSL_X509_CRL*);
-WOLFSSL_API WOLFSSL_ASN1_TIME* wolfSSL_X509_CRL_get_nextUpdate(WOLFSSL_X509_CRL*);
-
-WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_X509_get_pubkey(WOLFSSL_X509*);
-WOLFSSL_API int       wolfSSL_X509_CRL_verify(WOLFSSL_X509_CRL*, WOLFSSL_EVP_PKEY*);
-WOLFSSL_API void      wolfSSL_X509_STORE_CTX_set_error(WOLFSSL_X509_STORE_CTX*,
-                                                     int);
-WOLFSSL_API void      wolfSSL_X509_OBJECT_free_contents(WOLFSSL_X509_OBJECT*);
-WOLFSSL_API void      wolfSSL_EVP_PKEY_free(WOLFSSL_EVP_PKEY*);
-WOLFSSL_API int       wolfSSL_X509_cmp_current_time(const WOLFSSL_ASN1_TIME*);
-WOLFSSL_API int       wolfSSL_sk_X509_REVOKED_num(WOLFSSL_X509_REVOKED*);
-
-WOLFSSL_API WOLFSSL_X509_REVOKED* wolfSSL_X509_CRL_get_REVOKED(WOLFSSL_X509_CRL*);
-WOLFSSL_API WOLFSSL_X509_REVOKED* wolfSSL_sk_X509_REVOKED_value(
-                                                      WOLFSSL_X509_REVOKED*,int);
-WOLFSSL_API WOLFSSL_ASN1_INTEGER* wolfSSL_X509_get_serialNumber(WOLFSSL_X509*);
-
-WOLFSSL_API int wolfSSL_ASN1_TIME_print(WOLFSSL_BIO*, const WOLFSSL_ASN1_TIME*);
-
-WOLFSSL_API int  wolfSSL_ASN1_INTEGER_cmp(const WOLFSSL_ASN1_INTEGER*,
-                                       const WOLFSSL_ASN1_INTEGER*);
-WOLFSSL_API long wolfSSL_ASN1_INTEGER_get(const WOLFSSL_ASN1_INTEGER*);
-
-WOLFSSL_API STACK_OF(WOLFSSL_X509_NAME)* wolfSSL_load_client_CA_file(const char*);
-
-WOLFSSL_API void  wolfSSL_CTX_set_client_CA_list(WOLFSSL_CTX*,
-                                               STACK_OF(WOLFSSL_X509_NAME)*);
-WOLFSSL_API void* wolfSSL_X509_STORE_CTX_get_ex_data(WOLFSSL_X509_STORE_CTX*, int);
-WOLFSSL_API int   wolfSSL_get_ex_data_X509_STORE_CTX_idx(void);
-WOLFSSL_API void* wolfSSL_get_ex_data(const WOLFSSL*, int);
-
-WOLFSSL_API void wolfSSL_CTX_set_default_passwd_cb_userdata(WOLFSSL_CTX*,
-                                                          void* userdata);
-WOLFSSL_API void wolfSSL_CTX_set_default_passwd_cb(WOLFSSL_CTX*, pem_password_cb);
-
-
-WOLFSSL_API void wolfSSL_CTX_set_info_callback(WOLFSSL_CTX*, void (*)(void));
-
-WOLFSSL_API unsigned long wolfSSL_ERR_peek_error(void);
-WOLFSSL_API int           wolfSSL_GET_REASON(int);
-
-WOLFSSL_API char* wolfSSL_alert_type_string_long(int);
-WOLFSSL_API char* wolfSSL_alert_desc_string_long(int);
-WOLFSSL_API char* wolfSSL_state_string_long(WOLFSSL*);
-
-WOLFSSL_API WOLFSSL_RSA* wolfSSL_RSA_generate_key(int, unsigned long,
-                                               void(*)(int, int, void*), void*);
-WOLFSSL_API void wolfSSL_CTX_set_tmp_rsa_callback(WOLFSSL_CTX*,
-                                             WOLFSSL_RSA*(*)(WOLFSSL*, int, int));
-
-WOLFSSL_API int wolfSSL_PEM_def_callback(char*, int num, int w, void* key);
-
-WOLFSSL_API long wolfSSL_CTX_sess_accept(WOLFSSL_CTX*);
-WOLFSSL_API long wolfSSL_CTX_sess_connect(WOLFSSL_CTX*);
-WOLFSSL_API long wolfSSL_CTX_sess_accept_good(WOLFSSL_CTX*);
-WOLFSSL_API long wolfSSL_CTX_sess_connect_good(WOLFSSL_CTX*);
-WOLFSSL_API long wolfSSL_CTX_sess_accept_renegotiate(WOLFSSL_CTX*);
-WOLFSSL_API long wolfSSL_CTX_sess_connect_renegotiate(WOLFSSL_CTX*);
-WOLFSSL_API long wolfSSL_CTX_sess_hits(WOLFSSL_CTX*);
-WOLFSSL_API long wolfSSL_CTX_sess_cb_hits(WOLFSSL_CTX*);
-WOLFSSL_API long wolfSSL_CTX_sess_cache_full(WOLFSSL_CTX*);
-WOLFSSL_API long wolfSSL_CTX_sess_misses(WOLFSSL_CTX*);
-WOLFSSL_API long wolfSSL_CTX_sess_timeouts(WOLFSSL_CTX*);
-WOLFSSL_API long wolfSSL_CTX_sess_number(WOLFSSL_CTX*);
-WOLFSSL_API long wolfSSL_CTX_sess_get_cache_size(WOLFSSL_CTX*);
-
-#define WOLFSSL_DEFAULT_CIPHER_LIST ""   /* default all */
-#define WOLFSSL_RSA_F4 0x10001L
-
-enum {
-    OCSP_NOCERTS     = 1,
-    OCSP_NOINTERN    = 2,
-    OCSP_NOSIGS      = 4,
-    OCSP_NOCHAIN     = 8,
-    OCSP_NOVERIFY    = 16,
-    OCSP_NOEXPLICIT  = 32,
-    OCSP_NOCASIGN    = 64,
-    OCSP_NODELEGATED = 128,
-    OCSP_NOCHECKS    = 256,
-    OCSP_TRUSTOTHER  = 512,
-    OCSP_RESPID_KEY  = 1024,
-    OCSP_NOTIME      = 2048,
-
-    OCSP_CERTID   = 2,
-    OCSP_REQUEST  = 4,
-    OCSP_RESPONSE = 8,
-    OCSP_BASICRESP = 16,
-
-    WOLFSSL_OCSP_URL_OVERRIDE = 1,
-    WOLFSSL_OCSP_NO_NONCE     = 2,
-    WOLFSSL_OCSP_CHECKALL     = 4,
-
-    WOLFSSL_CRL_CHECKALL = 1,
-
-    ASN1_GENERALIZEDTIME = 4,
-
-    SSL_OP_MICROSOFT_SESS_ID_BUG = 1,
-    SSL_OP_NETSCAPE_CHALLENGE_BUG = 2,
-    SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG = 3,
-    SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG = 4,
-    SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER = 5,
-    SSL_OP_MSIE_SSLV2_RSA_PADDING = 6,
-    SSL_OP_SSLEAY_080_CLIENT_DH_BUG = 7,
-    SSL_OP_TLS_D5_BUG = 8,
-    SSL_OP_TLS_BLOCK_PADDING_BUG = 9,
-    SSL_OP_TLS_ROLLBACK_BUG = 10,
-    SSL_OP_ALL = 11,
-    SSL_OP_EPHEMERAL_RSA = 12,
-    SSL_OP_NO_SSLv3 = 13,
-    SSL_OP_NO_TLSv1 = 14,
-    SSL_OP_PKCS1_CHECK_1 = 15,
-    SSL_OP_PKCS1_CHECK_2 = 16,
-    SSL_OP_NETSCAPE_CA_DN_BUG = 17,
-    SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG = 18,
-    SSL_OP_SINGLE_DH_USE = 19,
-    SSL_OP_NO_TICKET = 20,
-    SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS = 21,
-    SSL_OP_NO_QUERY_MTU = 22,
-    SSL_OP_COOKIE_EXCHANGE = 23,
-    SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION = 24,
-    SSL_OP_SINGLE_ECDH_USE = 25,
-    SSL_OP_CIPHER_SERVER_PREFERENCE = 26,
-
-    SSL_MAX_SSL_SESSION_ID_LENGTH = 32,
-
-    EVP_R_BAD_DECRYPT = 2,
-
-    SSL_CB_LOOP = 4,
-    SSL_ST_CONNECT = 5,
-    SSL_ST_ACCEPT  = 6,
-    SSL_CB_ALERT   = 7,
-    SSL_CB_READ    = 8,
-    SSL_CB_HANDSHAKE_DONE = 9,
-
-    SSL_MODE_ENABLE_PARTIAL_WRITE = 2,
-
-    BIO_FLAGS_BASE64_NO_NL = 1,
-    BIO_CLOSE   = 1,
-    BIO_NOCLOSE = 0,
-
-    NID_undef = 0,
-
-    X509_FILETYPE_PEM = 8,
-    X509_LU_X509      = 9,
-    X509_LU_CRL       = 12,
-
-    X509_V_ERR_CRL_SIGNATURE_FAILURE = 13,
-    X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = 14,
-    X509_V_ERR_CRL_HAS_EXPIRED                = 15,
-    X509_V_ERR_CERT_REVOKED                   = 16,
-    X509_V_ERR_CERT_CHAIN_TOO_LONG            = 17,
-    X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT      = 18,
-    X509_V_ERR_CERT_NOT_YET_VALID             = 19,
-    X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = 20,
-    X509_V_ERR_CERT_HAS_EXPIRED               = 21,
-    X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD  = 22,
-
-    X509_V_OK = 0,
-
-    CRYPTO_LOCK = 1,
-    CRYPTO_NUM_LOCKS = 10
-};
-
-/* extras end */
-
-#if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
-/* wolfSSL extension, provide last error from SSL_get_error
-   since not using thread storage error queue */
-WOLFSSL_API void  wolfSSL_ERR_print_errors_fp(FILE*, int err);
-#endif
-
-enum { /* ssl Constants */
-    SSL_ERROR_NONE      =  0,   /* for most functions */
-    SSL_FAILURE         =  0,   /* for some functions */
-    SSL_SUCCESS         =  1,
-    SSL_SHUTDOWN_NOT_DONE =  2,  /* call wolfSSL_shutdown again to complete */
-
-    SSL_BAD_CERTTYPE    = -8,
-    SSL_BAD_STAT        = -7,
-    SSL_BAD_PATH        = -6,
-    SSL_BAD_FILETYPE    = -5,
-    SSL_BAD_FILE        = -4,
-    SSL_NOT_IMPLEMENTED = -3,
-    SSL_UNKNOWN         = -2,
-    SSL_FATAL_ERROR     = -1,
-
-    SSL_FILETYPE_ASN1    = 2,
-    SSL_FILETYPE_PEM     = 1,
-    SSL_FILETYPE_DEFAULT = 2, /* ASN1 */
-    SSL_FILETYPE_RAW     = 3, /* NTRU raw key blob */
-
-    SSL_VERIFY_NONE                 = 0,
-    SSL_VERIFY_PEER                 = 1,
-    SSL_VERIFY_FAIL_IF_NO_PEER_CERT = 2,
-    SSL_VERIFY_CLIENT_ONCE          = 4,
-
-    SSL_SESS_CACHE_OFF                = 30,
-    SSL_SESS_CACHE_CLIENT             = 31,
-    SSL_SESS_CACHE_SERVER             = 32,
-    SSL_SESS_CACHE_BOTH               = 33,
-    SSL_SESS_CACHE_NO_AUTO_CLEAR      = 34,
-    SSL_SESS_CACHE_NO_INTERNAL_LOOKUP = 35,
-
-    SSL_ERROR_WANT_READ        =  2,
-    SSL_ERROR_WANT_WRITE       =  3,
-    SSL_ERROR_WANT_CONNECT     =  7,
-    SSL_ERROR_WANT_ACCEPT      =  8,
-    SSL_ERROR_SYSCALL          =  5,
-    SSL_ERROR_WANT_X509_LOOKUP = 83,
-    SSL_ERROR_ZERO_RETURN      =  6,
-    SSL_ERROR_SSL              = 85,
-
-    SSL_SENT_SHUTDOWN     = 1,
-    SSL_RECEIVED_SHUTDOWN = 2,
-    SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER = 4,
-    SSL_OP_NO_SSLv2       = 8,
-
-    SSL_R_SSL_HANDSHAKE_FAILURE           = 101,
-    SSL_R_TLSV1_ALERT_UNKNOWN_CA          = 102,
-    SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN = 103,
-    SSL_R_SSLV3_ALERT_BAD_CERTIFICATE     = 104,
-
-    PEM_BUFSIZE = 1024
-};
-
-
-#ifndef NO_PSK
-    typedef unsigned int (*psk_client_callback)(WOLFSSL*, const char*, char*,
-                                    unsigned int, unsigned char*, unsigned int);
-    WOLFSSL_API void wolfSSL_CTX_set_psk_client_callback(WOLFSSL_CTX*,
-                                                    psk_client_callback);
-    WOLFSSL_API void wolfSSL_set_psk_client_callback(WOLFSSL*,psk_client_callback);
-
-    WOLFSSL_API const char* wolfSSL_get_psk_identity_hint(const WOLFSSL*);
-    WOLFSSL_API const char* wolfSSL_get_psk_identity(const WOLFSSL*);
-
-    WOLFSSL_API int wolfSSL_CTX_use_psk_identity_hint(WOLFSSL_CTX*, const char*);
-    WOLFSSL_API int wolfSSL_use_psk_identity_hint(WOLFSSL*, const char*);
-
-    typedef unsigned int (*psk_server_callback)(WOLFSSL*, const char*,
-                          unsigned char*, unsigned int);
-    WOLFSSL_API void wolfSSL_CTX_set_psk_server_callback(WOLFSSL_CTX*,
-                                                    psk_server_callback);
-    WOLFSSL_API void wolfSSL_set_psk_server_callback(WOLFSSL*,psk_server_callback);
-
-    #define PSK_TYPES_DEFINED
-#endif /* NO_PSK */
-
-
-#ifdef HAVE_ANON
-    WOLFSSL_API int wolfSSL_CTX_allow_anon_cipher(WOLFSSL_CTX*);
-#endif /* HAVE_ANON */
-
-
-/* extra begins */
-
-enum {  /* ERR Constants */
-    ERR_TXT_STRING = 1
-};
-
-WOLFSSL_API unsigned long wolfSSL_ERR_get_error_line_data(const char**, int*,
-                                                 const char**, int *);
-
-WOLFSSL_API unsigned long wolfSSL_ERR_get_error(void);
-WOLFSSL_API void          wolfSSL_ERR_clear_error(void);
-
-
-WOLFSSL_API int  wolfSSL_RAND_status(void);
-WOLFSSL_API int  wolfSSL_RAND_bytes(unsigned char* buf, int num);
-WOLFSSL_API WOLFSSL_METHOD *wolfSSLv23_server_method(void);
-WOLFSSL_API long wolfSSL_CTX_set_options(WOLFSSL_CTX*, long);
-#ifndef NO_CERTS
-  WOLFSSL_API int  wolfSSL_CTX_check_private_key(WOLFSSL_CTX*);
-#endif /* !NO_CERTS */
-
-WOLFSSL_API void wolfSSL_ERR_free_strings(void);
-WOLFSSL_API void wolfSSL_ERR_remove_state(unsigned long);
-WOLFSSL_API void wolfSSL_EVP_cleanup(void);
-WOLFSSL_API int  wolfSSL_clear(WOLFSSL* ssl);
-
-WOLFSSL_API void wolfSSL_cleanup_all_ex_data(void);
-WOLFSSL_API long wolfSSL_CTX_set_mode(WOLFSSL_CTX* ctx, long mode);
-WOLFSSL_API long wolfSSL_CTX_get_mode(WOLFSSL_CTX* ctx);
-WOLFSSL_API void wolfSSL_CTX_set_default_read_ahead(WOLFSSL_CTX* ctx, int m);
-WOLFSSL_API long wolfSSL_SSL_get_mode(WOLFSSL* ssl);
-
-WOLFSSL_API long wolfSSL_CTX_sess_set_cache_size(WOLFSSL_CTX*, long);
-
-WOLFSSL_API int  wolfSSL_CTX_set_default_verify_paths(WOLFSSL_CTX*);
-WOLFSSL_API int  wolfSSL_CTX_set_session_id_context(WOLFSSL_CTX*,
-                                            const unsigned char*, unsigned int);
-WOLFSSL_API WOLFSSL_X509* wolfSSL_get_peer_certificate(WOLFSSL* ssl);
-
-WOLFSSL_API int wolfSSL_want_read(WOLFSSL*);
-WOLFSSL_API int wolfSSL_want_write(WOLFSSL*);
-
-WOLFSSL_API int wolfSSL_BIO_printf(WOLFSSL_BIO*, const char*, ...);
-WOLFSSL_API int wolfSSL_ASN1_UTCTIME_print(WOLFSSL_BIO*,
-                                         const WOLFSSL_ASN1_UTCTIME*);
-WOLFSSL_API int   wolfSSL_sk_num(WOLFSSL_X509_REVOKED*);
-WOLFSSL_API void* wolfSSL_sk_value(WOLFSSL_X509_REVOKED*, int);
-
-/* stunnel 4.28 needs */
-WOLFSSL_API void* wolfSSL_CTX_get_ex_data(const WOLFSSL_CTX*, int);
-WOLFSSL_API int   wolfSSL_CTX_set_ex_data(WOLFSSL_CTX*, int, void*);
-WOLFSSL_API void  wolfSSL_CTX_sess_set_get_cb(WOLFSSL_CTX*,
-                       WOLFSSL_SESSION*(*f)(WOLFSSL*, unsigned char*, int, int*));
-WOLFSSL_API void  wolfSSL_CTX_sess_set_new_cb(WOLFSSL_CTX*,
-                                            int (*f)(WOLFSSL*, WOLFSSL_SESSION*));
-WOLFSSL_API void  wolfSSL_CTX_sess_set_remove_cb(WOLFSSL_CTX*,
-                                       void (*f)(WOLFSSL_CTX*, WOLFSSL_SESSION*));
-
-WOLFSSL_API int          wolfSSL_i2d_SSL_SESSION(WOLFSSL_SESSION*,unsigned char**);
-WOLFSSL_API WOLFSSL_SESSION* wolfSSL_d2i_SSL_SESSION(WOLFSSL_SESSION**,
-                                                   const unsigned char**, long);
-
-WOLFSSL_API long wolfSSL_SESSION_get_timeout(const WOLFSSL_SESSION*);
-WOLFSSL_API long wolfSSL_SESSION_get_time(const WOLFSSL_SESSION*);
-WOLFSSL_API int  wolfSSL_CTX_get_ex_new_index(long, void*, void*, void*, void*);
-
-/* extra ends */
-
-
-/* wolfSSL extensions */
-
-/* call before SSL_connect, if verifying will add name check to
-   date check and signature check */
-WOLFSSL_API int wolfSSL_check_domain_name(WOLFSSL* ssl, const char* dn);
-
-/* need to call once to load library (session cache) */
-WOLFSSL_API int wolfSSL_Init(void);
-/* call when done to cleanup/free session cache mutex / resources  */
-WOLFSSL_API int wolfSSL_Cleanup(void);
-
-/* which library version do we have */
-WOLFSSL_API const char* wolfSSL_lib_version(void);
-/* which library version do we have in hex */
-WOLFSSL_API unsigned int wolfSSL_lib_version_hex(void);
-
-/* turn logging on, only if compiled in */
-WOLFSSL_API int  wolfSSL_Debugging_ON(void);
-/* turn logging off */
-WOLFSSL_API void wolfSSL_Debugging_OFF(void);
-
-/* do accept or connect depedning on side */
-WOLFSSL_API int wolfSSL_negotiate(WOLFSSL* ssl);
-/* turn on wolfSSL data compression */
-WOLFSSL_API int wolfSSL_set_compression(WOLFSSL* ssl);
-
-WOLFSSL_API int wolfSSL_set_timeout(WOLFSSL*, unsigned int);
-WOLFSSL_API int wolfSSL_CTX_set_timeout(WOLFSSL_CTX*, unsigned int);
-
-/* get wolfSSL peer X509_CHAIN */
-WOLFSSL_API WOLFSSL_X509_CHAIN* wolfSSL_get_peer_chain(WOLFSSL* ssl);
-/* peer chain count */
-WOLFSSL_API int  wolfSSL_get_chain_count(WOLFSSL_X509_CHAIN* chain);
-/* index cert length */
-WOLFSSL_API int  wolfSSL_get_chain_length(WOLFSSL_X509_CHAIN*, int idx);
-/* index cert */
-WOLFSSL_API unsigned char* wolfSSL_get_chain_cert(WOLFSSL_X509_CHAIN*, int idx);
-/* index cert in X509 */
-WOLFSSL_API WOLFSSL_X509* wolfSSL_get_chain_X509(WOLFSSL_X509_CHAIN*, int idx);
-/* free X509 */
-WOLFSSL_API void wolfSSL_FreeX509(WOLFSSL_X509*);
-/* get index cert in PEM */
-WOLFSSL_API int  wolfSSL_get_chain_cert_pem(WOLFSSL_X509_CHAIN*, int idx,
-                                unsigned char* buffer, int inLen, int* outLen);
-WOLFSSL_API const unsigned char* wolfSSL_get_sessionID(const WOLFSSL_SESSION* s);
-WOLFSSL_API int  wolfSSL_X509_get_serial_number(WOLFSSL_X509*,unsigned char*,int*);
-WOLFSSL_API char*  wolfSSL_X509_get_subjectCN(WOLFSSL_X509*);
-WOLFSSL_API const unsigned char* wolfSSL_X509_get_der(WOLFSSL_X509*, int*);
-WOLFSSL_API const unsigned char* wolfSSL_X509_notBefore(WOLFSSL_X509*);
-WOLFSSL_API const unsigned char* wolfSSL_X509_notAfter(WOLFSSL_X509*);
-WOLFSSL_API int wolfSSL_X509_version(WOLFSSL_X509*);
-
-WOLFSSL_API int wolfSSL_cmp_peer_cert_to_file(WOLFSSL*, const char*);
-
-WOLFSSL_API char* wolfSSL_X509_get_next_altname(WOLFSSL_X509*);
-
-WOLFSSL_API WOLFSSL_X509*
-    wolfSSL_X509_d2i(WOLFSSL_X509** x509, const unsigned char* in, int len);
-#ifndef NO_FILESYSTEM
-    #ifndef NO_STDIO_FILESYSTEM
-    WOLFSSL_API WOLFSSL_X509*
-        wolfSSL_X509_d2i_fp(WOLFSSL_X509** x509, FILE* file);
-    #endif
-WOLFSSL_API WOLFSSL_X509*
-    wolfSSL_X509_load_certificate_file(const char* fname, int format);
-#endif
-
-#ifdef WOLFSSL_SEP
-    WOLFSSL_API unsigned char*
-           wolfSSL_X509_get_device_type(WOLFSSL_X509*, unsigned char*, int*);
-    WOLFSSL_API unsigned char*
-           wolfSSL_X509_get_hw_type(WOLFSSL_X509*, unsigned char*, int*);
-    WOLFSSL_API unsigned char*
-           wolfSSL_X509_get_hw_serial_number(WOLFSSL_X509*, unsigned char*, int*);
-#endif
-
-/* connect enough to get peer cert */
-WOLFSSL_API int  wolfSSL_connect_cert(WOLFSSL* ssl);
-
-#ifndef NO_DH
-/* server Diffie-Hellman parameters */
-WOLFSSL_API int  wolfSSL_SetTmpDH(WOLFSSL*, const unsigned char* p, int pSz,
-                                const unsigned char* g, int gSz);
-WOLFSSL_API int  wolfSSL_SetTmpDH_buffer(WOLFSSL*, const unsigned char* b, long sz,
-                                       int format);
-#ifndef NO_FILESYSTEM
-    WOLFSSL_API int  wolfSSL_SetTmpDH_file(WOLFSSL*, const char* f, int format);
-#endif
-
-/* server ctx Diffie-Hellman parameters */
-WOLFSSL_API int  wolfSSL_CTX_SetTmpDH(WOLFSSL_CTX*, const unsigned char* p,
-                                    int pSz, const unsigned char* g, int gSz);
-WOLFSSL_API int  wolfSSL_CTX_SetTmpDH_buffer(WOLFSSL_CTX*, const unsigned char* b,
-                                           long sz, int format);
-
-#ifndef NO_FILESYSTEM
-    WOLFSSL_API int  wolfSSL_CTX_SetTmpDH_file(WOLFSSL_CTX*, const char* f,
-                                             int format);
-#endif
-
-WOLFSSL_API int wolfSSL_CTX_SetMinDhKey_Sz(WOLFSSL_CTX*, unsigned short);
-WOLFSSL_API int wolfSSL_SetMinDhKey_Sz(WOLFSSL*, unsigned short);
-WOLFSSL_API int wolfSSL_GetDhKey_Sz(WOLFSSL*);
-#endif /* NO_DH */
-
-WOLFSSL_API int  wolfSSL_SetTmpEC_DHE_Sz(WOLFSSL*, unsigned short);
-WOLFSSL_API int  wolfSSL_CTX_SetTmpEC_DHE_Sz(WOLFSSL_CTX*, unsigned short);
-
-/* keyblock size in bytes or -1 */
-/* need to call wolfSSL_KeepArrays before handshake to save keys */
-WOLFSSL_API int wolfSSL_get_keyblock_size(WOLFSSL*);
-WOLFSSL_API int wolfSSL_get_keys(WOLFSSL*,unsigned char** ms, unsigned int* msLen,
-                                       unsigned char** sr, unsigned int* srLen,
-                                       unsigned char** cr, unsigned int* crLen);
-
-/* Computes EAP-TLS and EAP-TTLS keying material from the master_secret. */
-WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL*, void* key, unsigned int len,
-                                                             const char* label);
-
-
-#ifndef _WIN32
-    #ifndef NO_WRITEV
-        #ifdef __PPU
-            #include 
-            #include 
-        #elif !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_IAR_ARM) && !defined(WOLFSSL_PICOTCP)
-            #include 
-        #endif
-        /* allow writev style writing */
-        WOLFSSL_API int wolfSSL_writev(WOLFSSL* ssl, const struct iovec* iov,
-                                     int iovcnt);
-    #endif
-#endif
-
-
-#ifndef NO_CERTS
-    /* SSL_CTX versions */
-    WOLFSSL_API int wolfSSL_CTX_UnloadCAs(WOLFSSL_CTX*);
-    WOLFSSL_API int wolfSSL_CTX_load_verify_buffer(WOLFSSL_CTX*,
-                                               const unsigned char*, long, int);
-    WOLFSSL_API int wolfSSL_CTX_use_certificate_buffer(WOLFSSL_CTX*,
-                                               const unsigned char*, long, int);
-    WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_buffer(WOLFSSL_CTX*,
-                                               const unsigned char*, long, int);
-    WOLFSSL_API int wolfSSL_CTX_use_certificate_chain_buffer(WOLFSSL_CTX*,
-                                                    const unsigned char*, long);
-
-    /* SSL versions */
-    WOLFSSL_API int wolfSSL_use_certificate_buffer(WOLFSSL*, const unsigned char*,
-                                               long, int);
-    WOLFSSL_API int wolfSSL_use_PrivateKey_buffer(WOLFSSL*, const unsigned char*,
-                                               long, int);
-    WOLFSSL_API int wolfSSL_use_certificate_chain_buffer(WOLFSSL*,
-                                               const unsigned char*, long);
-    WOLFSSL_API int wolfSSL_UnloadCertsKeys(WOLFSSL*);
-#endif
-
-WOLFSSL_API int wolfSSL_CTX_set_group_messages(WOLFSSL_CTX*);
-WOLFSSL_API int wolfSSL_set_group_messages(WOLFSSL*);
-
-/* I/O callbacks */
-typedef int (*CallbackIORecv)(WOLFSSL *ssl, char *buf, int sz, void *ctx);
-typedef int (*CallbackIOSend)(WOLFSSL *ssl, char *buf, int sz, void *ctx);
-
-#ifdef HAVE_FUZZER
-enum fuzzer_type {
-    FUZZ_HMAC      = 0,
-    FUZZ_ENCRYPT   = 1,
-    FUZZ_SIGNATURE = 2,
-    FUZZ_HASH      = 3,
-    FUZZ_HEAD      = 4
-};
-
-typedef int (*CallbackFuzzer)(WOLFSSL* ssl, const unsigned char* buf, int sz,
-        int type, void* fuzzCtx);
-
-WOLFSSL_API void wolfSSL_SetFuzzerCb(WOLFSSL* ssl, CallbackFuzzer cbf, void* fCtx);
-#endif
-
-WOLFSSL_API void wolfSSL_SetIORecv(WOLFSSL_CTX*, CallbackIORecv);
-WOLFSSL_API void wolfSSL_SetIOSend(WOLFSSL_CTX*, CallbackIOSend);
-
-WOLFSSL_API void wolfSSL_SetIOReadCtx( WOLFSSL* ssl, void *ctx);
-WOLFSSL_API void wolfSSL_SetIOWriteCtx(WOLFSSL* ssl, void *ctx);
-
-WOLFSSL_API void* wolfSSL_GetIOReadCtx( WOLFSSL* ssl);
-WOLFSSL_API void* wolfSSL_GetIOWriteCtx(WOLFSSL* ssl);
-
-WOLFSSL_API void wolfSSL_SetIOReadFlags( WOLFSSL* ssl, int flags);
-WOLFSSL_API void wolfSSL_SetIOWriteFlags(WOLFSSL* ssl, int flags);
-
-
-#ifndef WOLFSSL_USER_IO
-    /* default IO callbacks */
-    WOLFSSL_API int EmbedReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx);
-    WOLFSSL_API int EmbedSend(WOLFSSL* ssl, char* buf, int sz, void* ctx);
-
-    #ifdef HAVE_OCSP
-        WOLFSSL_API int EmbedOcspLookup(void*, const char*, int, unsigned char*,
-                                       int, unsigned char**);
-        WOLFSSL_API void EmbedOcspRespFree(void*, unsigned char*);
-    #endif
-
-    #ifdef WOLFSSL_DTLS
-        WOLFSSL_API int EmbedReceiveFrom(WOLFSSL* ssl, char* buf, int sz, void*);
-        WOLFSSL_API int EmbedSendTo(WOLFSSL* ssl, char* buf, int sz, void* ctx);
-        WOLFSSL_API int EmbedGenerateCookie(WOLFSSL* ssl, unsigned char* buf,
-                                           int sz, void*);
-    #endif /* WOLFSSL_DTLS */
-#endif /* WOLFSSL_USER_IO */
-
-
-#ifdef HAVE_NETX
-    WOLFSSL_API void wolfSSL_SetIO_NetX(WOLFSSL* ssl, NX_TCP_SOCKET* nxsocket,
-                                      ULONG waitoption);
-#endif
-
-typedef int (*CallbackGenCookie)(WOLFSSL* ssl, unsigned char* buf, int sz,
-                                 void* ctx);
-WOLFSSL_API void  wolfSSL_CTX_SetGenCookie(WOLFSSL_CTX*, CallbackGenCookie);
-WOLFSSL_API void  wolfSSL_SetCookieCtx(WOLFSSL* ssl, void *ctx);
-WOLFSSL_API void* wolfSSL_GetCookieCtx(WOLFSSL* ssl);
-
-
-/* I/O Callback default errors */
-enum IOerrors {
-    WOLFSSL_CBIO_ERR_GENERAL    = -1,     /* general unexpected err */
-    WOLFSSL_CBIO_ERR_WANT_READ  = -2,     /* need to call read  again */
-    WOLFSSL_CBIO_ERR_WANT_WRITE = -2,     /* need to call write again */
-    WOLFSSL_CBIO_ERR_CONN_RST   = -3,     /* connection reset */
-    WOLFSSL_CBIO_ERR_ISR        = -4,     /* interrupt */
-    WOLFSSL_CBIO_ERR_CONN_CLOSE = -5,     /* connection closed or epipe */
-    WOLFSSL_CBIO_ERR_TIMEOUT    = -6      /* socket timeout */
-};
-
-
-/* CA cache callbacks */
-enum {
-    WOLFSSL_SSLV3    = 0,
-    WOLFSSL_TLSV1    = 1,
-    WOLFSSL_TLSV1_1  = 2,
-    WOLFSSL_TLSV1_2  = 3,
-    WOLFSSL_USER_CA  = 1,          /* user added as trusted */
-    WOLFSSL_CHAIN_CA = 2           /* added to cache from trusted chain */
-};
-
-WOLFSSL_API int wolfSSL_CTX_SetMinVersion(WOLFSSL_CTX* ctx, int version);
-WOLFSSL_API int wolfSSL_SetMinVersion(WOLFSSL* ssl, int version);
-WOLFSSL_API int wolfSSL_GetObjectSize(void);  /* object size based on build */
-WOLFSSL_API int wolfSSL_SetVersion(WOLFSSL* ssl, int version);
-WOLFSSL_API int wolfSSL_KeyPemToDer(const unsigned char*, int sz, unsigned char*,
-                                  int, const char*);
-WOLFSSL_API int wolfSSL_CertPemToDer(const unsigned char*, int sz, unsigned char*,
-                                   int, int);
-
-typedef void (*CallbackCACache)(unsigned char* der, int sz, int type);
-typedef void (*CbMissingCRL)(const char* url);
-typedef int  (*CbOCSPIO)(void*, const char*, int,
-                                         unsigned char*, int, unsigned char**);
-typedef void (*CbOCSPRespFree)(void*,unsigned char*);
-
-/* User Atomic Record Layer CallBacks */
-typedef int (*CallbackMacEncrypt)(WOLFSSL* ssl, unsigned char* macOut,
-       const unsigned char* macIn, unsigned int macInSz, int macContent,
-       int macVerify, unsigned char* encOut, const unsigned char* encIn,
-       unsigned int encSz, void* ctx);
-WOLFSSL_API void  wolfSSL_CTX_SetMacEncryptCb(WOLFSSL_CTX*, CallbackMacEncrypt);
-WOLFSSL_API void  wolfSSL_SetMacEncryptCtx(WOLFSSL* ssl, void *ctx);
-WOLFSSL_API void* wolfSSL_GetMacEncryptCtx(WOLFSSL* ssl);
-
-typedef int (*CallbackDecryptVerify)(WOLFSSL* ssl,
-       unsigned char* decOut, const unsigned char* decIn,
-       unsigned int decSz, int content, int verify, unsigned int* padSz,
-       void* ctx);
-WOLFSSL_API void  wolfSSL_CTX_SetDecryptVerifyCb(WOLFSSL_CTX*,
-                                               CallbackDecryptVerify);
-WOLFSSL_API void  wolfSSL_SetDecryptVerifyCtx(WOLFSSL* ssl, void *ctx);
-WOLFSSL_API void* wolfSSL_GetDecryptVerifyCtx(WOLFSSL* ssl);
-
-WOLFSSL_API const unsigned char* wolfSSL_GetMacSecret(WOLFSSL*, int);
-WOLFSSL_API const unsigned char* wolfSSL_GetClientWriteKey(WOLFSSL*);
-WOLFSSL_API const unsigned char* wolfSSL_GetClientWriteIV(WOLFSSL*);
-WOLFSSL_API const unsigned char* wolfSSL_GetServerWriteKey(WOLFSSL*);
-WOLFSSL_API const unsigned char* wolfSSL_GetServerWriteIV(WOLFSSL*);
-WOLFSSL_API int                  wolfSSL_GetKeySize(WOLFSSL*);
-WOLFSSL_API int                  wolfSSL_GetIVSize(WOLFSSL*);
-WOLFSSL_API int                  wolfSSL_GetSide(WOLFSSL*);
-WOLFSSL_API int                  wolfSSL_IsTLSv1_1(WOLFSSL*);
-WOLFSSL_API int                  wolfSSL_GetBulkCipher(WOLFSSL*);
-WOLFSSL_API int                  wolfSSL_GetCipherBlockSize(WOLFSSL*);
-WOLFSSL_API int                  wolfSSL_GetAeadMacSize(WOLFSSL*);
-WOLFSSL_API int                  wolfSSL_GetHmacSize(WOLFSSL*);
-WOLFSSL_API int                  wolfSSL_GetHmacType(WOLFSSL*);
-WOLFSSL_API int                  wolfSSL_GetCipherType(WOLFSSL*);
-WOLFSSL_API int                  wolfSSL_SetTlsHmacInner(WOLFSSL*, unsigned char*,
-                                                       unsigned int, int, int);
-
-/* Atomic User Needs */
-enum {
-    WOLFSSL_SERVER_END = 0,
-    WOLFSSL_CLIENT_END = 1,
-    WOLFSSL_BLOCK_TYPE = 2,
-    WOLFSSL_STREAM_TYPE = 3,
-    WOLFSSL_AEAD_TYPE = 4,
-    WOLFSSL_TLS_HMAC_INNER_SZ = 13      /* SEQ_SZ + ENUM + VERSION_SZ + LEN_SZ */
-};
-
-/* for GetBulkCipher and internal use */
-enum BulkCipherAlgorithm {
-    wolfssl_cipher_null,
-    wolfssl_rc4,
-    wolfssl_rc2,
-    wolfssl_des,
-    wolfssl_triple_des,             /* leading 3 (3des) not valid identifier */
-    wolfssl_des40,
-    wolfssl_idea,
-    wolfssl_aes,
-    wolfssl_aes_gcm,
-    wolfssl_aes_ccm,
-    wolfssl_chacha,
-    wolfssl_camellia,
-    wolfssl_hc128,                  /* wolfSSL extensions */
-    wolfssl_rabbit
-};
-
-
-/* for KDF TLS 1.2 mac types */
-enum KDF_MacAlgorithm {
-    wolfssl_sha256 = 4,     /* needs to match internal MACAlgorithm */
-    wolfssl_sha384,
-    wolfssl_sha512
-};
-
-
-/* Public Key Callback support */
-typedef int (*CallbackEccSign)(WOLFSSL* ssl,
-       const unsigned char* in, unsigned int inSz,
-       unsigned char* out, unsigned int* outSz,
-       const unsigned char* keyDer, unsigned int keySz,
-       void* ctx);
-WOLFSSL_API void  wolfSSL_CTX_SetEccSignCb(WOLFSSL_CTX*, CallbackEccSign);
-WOLFSSL_API void  wolfSSL_SetEccSignCtx(WOLFSSL* ssl, void *ctx);
-WOLFSSL_API void* wolfSSL_GetEccSignCtx(WOLFSSL* ssl);
-
-typedef int (*CallbackEccVerify)(WOLFSSL* ssl,
-       const unsigned char* sig, unsigned int sigSz,
-       const unsigned char* hash, unsigned int hashSz,
-       const unsigned char* keyDer, unsigned int keySz,
-       int* result, void* ctx);
-WOLFSSL_API void  wolfSSL_CTX_SetEccVerifyCb(WOLFSSL_CTX*, CallbackEccVerify);
-WOLFSSL_API void  wolfSSL_SetEccVerifyCtx(WOLFSSL* ssl, void *ctx);
-WOLFSSL_API void* wolfSSL_GetEccVerifyCtx(WOLFSSL* ssl);
-
-typedef int (*CallbackRsaSign)(WOLFSSL* ssl,
-       const unsigned char* in, unsigned int inSz,
-       unsigned char* out, unsigned int* outSz,
-       const unsigned char* keyDer, unsigned int keySz,
-       void* ctx);
-WOLFSSL_API void  wolfSSL_CTX_SetRsaSignCb(WOLFSSL_CTX*, CallbackRsaSign);
-WOLFSSL_API void  wolfSSL_SetRsaSignCtx(WOLFSSL* ssl, void *ctx);
-WOLFSSL_API void* wolfSSL_GetRsaSignCtx(WOLFSSL* ssl);
-
-typedef int (*CallbackRsaVerify)(WOLFSSL* ssl,
-       unsigned char* sig, unsigned int sigSz,
-       unsigned char** out,
-       const unsigned char* keyDer, unsigned int keySz,
-       void* ctx);
-WOLFSSL_API void  wolfSSL_CTX_SetRsaVerifyCb(WOLFSSL_CTX*, CallbackRsaVerify);
-WOLFSSL_API void  wolfSSL_SetRsaVerifyCtx(WOLFSSL* ssl, void *ctx);
-WOLFSSL_API void* wolfSSL_GetRsaVerifyCtx(WOLFSSL* ssl);
-
-/* RSA Public Encrypt cb */
-typedef int (*CallbackRsaEnc)(WOLFSSL* ssl,
-       const unsigned char* in, unsigned int inSz,
-       unsigned char* out, unsigned int* outSz,
-       const unsigned char* keyDer, unsigned int keySz,
-       void* ctx);
-WOLFSSL_API void  wolfSSL_CTX_SetRsaEncCb(WOLFSSL_CTX*, CallbackRsaEnc);
-WOLFSSL_API void  wolfSSL_SetRsaEncCtx(WOLFSSL* ssl, void *ctx);
-WOLFSSL_API void* wolfSSL_GetRsaEncCtx(WOLFSSL* ssl);
-
-/* RSA Private Decrypt cb */
-typedef int (*CallbackRsaDec)(WOLFSSL* ssl,
-       unsigned char* in, unsigned int inSz,
-       unsigned char** out,
-       const unsigned char* keyDer, unsigned int keySz,
-       void* ctx);
-WOLFSSL_API void  wolfSSL_CTX_SetRsaDecCb(WOLFSSL_CTX*, CallbackRsaDec);
-WOLFSSL_API void  wolfSSL_SetRsaDecCtx(WOLFSSL* ssl, void *ctx);
-WOLFSSL_API void* wolfSSL_GetRsaDecCtx(WOLFSSL* ssl);
-
-
-#ifndef NO_CERTS
-	WOLFSSL_API void wolfSSL_CTX_SetCACb(WOLFSSL_CTX*, CallbackCACache);
-
-    WOLFSSL_API WOLFSSL_CERT_MANAGER* wolfSSL_CertManagerNew(void);
-    WOLFSSL_API void wolfSSL_CertManagerFree(WOLFSSL_CERT_MANAGER*);
-
-    WOLFSSL_API int wolfSSL_CertManagerLoadCA(WOLFSSL_CERT_MANAGER*, const char* f,
-                                                                 const char* d);
-    WOLFSSL_API int wolfSSL_CertManagerUnloadCAs(WOLFSSL_CERT_MANAGER* cm);
-    WOLFSSL_API int wolfSSL_CertManagerVerify(WOLFSSL_CERT_MANAGER*, const char* f,
-                                                                    int format);
-    WOLFSSL_API int wolfSSL_CertManagerVerifyBuffer(WOLFSSL_CERT_MANAGER* cm,
-                                const unsigned char* buff, long sz, int format);
-    WOLFSSL_API int wolfSSL_CertManagerCheckCRL(WOLFSSL_CERT_MANAGER*,
-                                                        unsigned char*, int sz);
-    WOLFSSL_API int wolfSSL_CertManagerEnableCRL(WOLFSSL_CERT_MANAGER*,
-                                                                   int options);
-    WOLFSSL_API int wolfSSL_CertManagerDisableCRL(WOLFSSL_CERT_MANAGER*);
-    WOLFSSL_API int wolfSSL_CertManagerLoadCRL(WOLFSSL_CERT_MANAGER*, const char*,
-                                                                      int, int);
-    WOLFSSL_API int wolfSSL_CertManagerSetCRL_Cb(WOLFSSL_CERT_MANAGER*,
-                                                                  CbMissingCRL);
-    WOLFSSL_API int wolfSSL_CertManagerCheckOCSP(WOLFSSL_CERT_MANAGER*,
-                                                        unsigned char*, int sz);
-    WOLFSSL_API int wolfSSL_CertManagerEnableOCSP(WOLFSSL_CERT_MANAGER*,
-                                                                   int options);
-    WOLFSSL_API int wolfSSL_CertManagerDisableOCSP(WOLFSSL_CERT_MANAGER*);
-    WOLFSSL_API int wolfSSL_CertManagerSetOCSPOverrideURL(WOLFSSL_CERT_MANAGER*,
-                                                                   const char*);
-    WOLFSSL_API int wolfSSL_CertManagerSetOCSP_Cb(WOLFSSL_CERT_MANAGER*,
-                                               CbOCSPIO, CbOCSPRespFree, void*);
-
-    WOLFSSL_API int wolfSSL_EnableCRL(WOLFSSL* ssl, int options);
-    WOLFSSL_API int wolfSSL_DisableCRL(WOLFSSL* ssl);
-    WOLFSSL_API int wolfSSL_LoadCRL(WOLFSSL*, const char*, int, int);
-    WOLFSSL_API int wolfSSL_SetCRL_Cb(WOLFSSL*, CbMissingCRL);
-    WOLFSSL_API int wolfSSL_EnableOCSP(WOLFSSL*, int options);
-    WOLFSSL_API int wolfSSL_DisableOCSP(WOLFSSL*);
-    WOLFSSL_API int wolfSSL_SetOCSP_OverrideURL(WOLFSSL*, const char*);
-    WOLFSSL_API int wolfSSL_SetOCSP_Cb(WOLFSSL*, CbOCSPIO, CbOCSPRespFree, void*);
-
-    WOLFSSL_API int wolfSSL_CTX_EnableCRL(WOLFSSL_CTX* ctx, int options);
-    WOLFSSL_API int wolfSSL_CTX_DisableCRL(WOLFSSL_CTX* ctx);
-    WOLFSSL_API int wolfSSL_CTX_LoadCRL(WOLFSSL_CTX*, const char*, int, int);
-    WOLFSSL_API int wolfSSL_CTX_SetCRL_Cb(WOLFSSL_CTX*, CbMissingCRL);
-    WOLFSSL_API int wolfSSL_CTX_EnableOCSP(WOLFSSL_CTX*, int options);
-    WOLFSSL_API int wolfSSL_CTX_DisableOCSP(WOLFSSL_CTX*);
-    WOLFSSL_API int wolfSSL_CTX_SetOCSP_OverrideURL(WOLFSSL_CTX*, const char*);
-    WOLFSSL_API int wolfSSL_CTX_SetOCSP_Cb(WOLFSSL_CTX*,
-                                               CbOCSPIO, CbOCSPRespFree, void*);
-#endif /* !NO_CERTS */
-
-/* end of handshake frees temporary arrays, if user needs for get_keys or
-   psk hints, call KeepArrays before handshake and then FreeArrays when done
-   if don't want to wait for object free */
-WOLFSSL_API void wolfSSL_KeepArrays(WOLFSSL*);
-WOLFSSL_API void wolfSSL_FreeArrays(WOLFSSL*);
-
-
-/* cavium additions */
-WOLFSSL_API int wolfSSL_UseCavium(WOLFSSL*, int devId);
-WOLFSSL_API int wolfSSL_CTX_UseCavium(WOLFSSL_CTX*, int devId);
-
-/* TLS Extensions */
-
-/* Server Name Indication */
-#ifdef HAVE_SNI
-
-/* SNI types */
-enum {
-    WOLFSSL_SNI_HOST_NAME = 0
-};
-
-WOLFSSL_API int wolfSSL_UseSNI(WOLFSSL* ssl, unsigned char type, const void* data,
-                                                           unsigned short size);
-WOLFSSL_API int wolfSSL_CTX_UseSNI(WOLFSSL_CTX* ctx, unsigned char type,
-                                         const void* data, unsigned short size);
-
-#ifndef NO_WOLFSSL_SERVER
-
-/* SNI options */
-enum {
-    WOLFSSL_SNI_CONTINUE_ON_MISMATCH = 0x01, /* do not abort on mismatch flag */
-    WOLFSSL_SNI_ANSWER_ON_MISMATCH   = 0x02  /* fake match on mismatch flag */
-};
-
-WOLFSSL_API void wolfSSL_SNI_SetOptions(WOLFSSL* ssl, unsigned char type,
-                                                         unsigned char options);
-WOLFSSL_API void wolfSSL_CTX_SNI_SetOptions(WOLFSSL_CTX* ctx, unsigned char type,
-                                                         unsigned char options);
-
-/* SNI status */
-enum {
-    WOLFSSL_SNI_NO_MATCH   = 0,
-    WOLFSSL_SNI_FAKE_MATCH = 1, /* if WOLFSSL_SNI_ANSWER_ON_MISMATCH is enabled */
-    WOLFSSL_SNI_REAL_MATCH = 2
-};
-
-WOLFSSL_API unsigned char wolfSSL_SNI_Status(WOLFSSL* ssl, unsigned char type);
-
-WOLFSSL_API unsigned short wolfSSL_SNI_GetRequest(WOLFSSL *ssl, unsigned char type,
-                                                                   void** data);
-WOLFSSL_API int wolfSSL_SNI_GetFromBuffer(
-                 const unsigned char* clientHello, unsigned int helloSz,
-                 unsigned char type, unsigned char* sni, unsigned int* inOutSz);
-
-#endif
-#endif
-
-/* Maximum Fragment Length */
-#ifdef HAVE_MAX_FRAGMENT
-
-/* Fragment lengths */
-enum {
-    WOLFSSL_MFL_2_9  = 1, /*  512 bytes */
-    WOLFSSL_MFL_2_10 = 2, /* 1024 bytes */
-    WOLFSSL_MFL_2_11 = 3, /* 2048 bytes */
-    WOLFSSL_MFL_2_12 = 4, /* 4096 bytes */
-    WOLFSSL_MFL_2_13 = 5  /* 8192 bytes *//* wolfSSL ONLY!!! */
-};
-
-#ifndef NO_WOLFSSL_CLIENT
-
-WOLFSSL_API int wolfSSL_UseMaxFragment(WOLFSSL* ssl, unsigned char mfl);
-WOLFSSL_API int wolfSSL_CTX_UseMaxFragment(WOLFSSL_CTX* ctx, unsigned char mfl);
-
-#endif
-#endif
-
-/* Truncated HMAC */
-#ifdef HAVE_TRUNCATED_HMAC
-#ifndef NO_WOLFSSL_CLIENT
-
-WOLFSSL_API int wolfSSL_UseTruncatedHMAC(WOLFSSL* ssl);
-WOLFSSL_API int wolfSSL_CTX_UseTruncatedHMAC(WOLFSSL_CTX* ctx);
-
-#endif
-#endif
-
-/* Elliptic Curves */
-enum {
-    WOLFSSL_ECC_SECP160R1 = 0x10,
-    WOLFSSL_ECC_SECP192R1 = 0x13,
-    WOLFSSL_ECC_SECP224R1 = 0x15,
-    WOLFSSL_ECC_SECP256R1 = 0x17,
-    WOLFSSL_ECC_SECP384R1 = 0x18,
-    WOLFSSL_ECC_SECP521R1 = 0x19
-};
-
-#ifdef HAVE_SUPPORTED_CURVES
-#ifndef NO_WOLFSSL_CLIENT
-
-WOLFSSL_API int wolfSSL_UseSupportedCurve(WOLFSSL* ssl, unsigned short name);
-WOLFSSL_API int wolfSSL_CTX_UseSupportedCurve(WOLFSSL_CTX* ctx,
-                                                           unsigned short name);
-
-#endif
-#endif
-
-/* Secure Renegotiation */
-#ifdef HAVE_SECURE_RENEGOTIATION
-
-WOLFSSL_API int wolfSSL_UseSecureRenegotiation(WOLFSSL* ssl);
-WOLFSSL_API int wolfSSL_Rehandshake(WOLFSSL* ssl);
-
-#endif
-
-/* Session Ticket */
-#ifdef HAVE_SESSION_TICKET
-
-#ifndef NO_WOLFSSL_CLIENT
-WOLFSSL_API int wolfSSL_UseSessionTicket(WOLFSSL* ssl);
-WOLFSSL_API int wolfSSL_CTX_UseSessionTicket(WOLFSSL_CTX* ctx);
-WOLFSSL_API int wolfSSL_get_SessionTicket(WOLFSSL*, unsigned char*, unsigned int*);
-WOLFSSL_API int wolfSSL_set_SessionTicket(WOLFSSL*, unsigned char*, unsigned int);
-typedef int (*CallbackSessionTicket)(WOLFSSL*, const unsigned char*, int, void*);
-WOLFSSL_API int wolfSSL_set_SessionTicket_cb(WOLFSSL*,
-                                                  CallbackSessionTicket, void*);
-#endif /* NO_WOLFSSL_CLIENT */
-
-#ifndef NO_WOLFSSL_SERVER
-
-#define WOLFSSL_TICKET_NAME_SZ 16
-#define WOLFSSL_TICKET_IV_SZ   16
-#define WOLFSSL_TICKET_MAC_SZ  32
-
-enum TicketEncRet {
-    WOLFSSL_TICKET_RET_FATAL  = -1,  /* fatal error, don't use ticket */
-    WOLFSSL_TICKET_RET_OK     =  0,  /* ok, use ticket */
-    WOLFSSL_TICKET_RET_REJECT,       /* don't use ticket, but not fatal */
-    WOLFSSL_TICKET_RET_CREATE        /* existing ticket ok and create new one */
-};
-
-typedef int (*SessionTicketEncCb)(WOLFSSL*,
-                                 unsigned char key_name[WOLFSSL_TICKET_NAME_SZ],
-                                 unsigned char iv[WOLFSSL_TICKET_IV_SZ],
-                                 unsigned char mac[WOLFSSL_TICKET_MAC_SZ],
-                                 int enc, unsigned char*, int, int*, void*);
-WOLFSSL_API int wolfSSL_CTX_set_TicketEncCb(WOLFSSL_CTX* ctx,
-                                            SessionTicketEncCb);
-WOLFSSL_API int wolfSSL_CTX_set_TicketHint(WOLFSSL_CTX* ctx, int);
-WOLFSSL_API int wolfSSL_CTX_set_TicketEncCtx(WOLFSSL_CTX* ctx, void*);
-
-#endif /* NO_WOLFSSL_SERVER */
-
-#endif /* HAVE_SESSION_TICKET */
-
-#define WOLFSSL_CRL_MONITOR   0x01   /* monitor this dir flag */
-#define WOLFSSL_CRL_START_MON 0x02   /* start monitoring flag */
-
-
-/* notify user the hanshake is done */
-typedef int (*HandShakeDoneCb)(WOLFSSL*, void*);
-WOLFSSL_API int wolfSSL_SetHsDoneCb(WOLFSSL*, HandShakeDoneCb, void*);
-
-
-WOLFSSL_API int wolfSSL_PrintSessionStats(void);
-WOLFSSL_API int wolfSSL_get_session_stats(unsigned int* active,
-                                          unsigned int* total,
-                                          unsigned int* peak,
-                                          unsigned int* maxSessions);
-/* External facing KDF */
-WOLFSSL_API
-int wolfSSL_MakeTlsMasterSecret(unsigned char* ms, unsigned int msLen,
-                               const unsigned char* pms, unsigned int pmsLen,
-                               const unsigned char* cr, const unsigned char* sr,
-                               int tls1_2, int hash_type);
-
-WOLFSSL_API
-int wolfSSL_DeriveTlsKeys(unsigned char* key_data, unsigned int keyLen,
-                               const unsigned char* ms, unsigned int msLen,
-                               const unsigned char* sr, const unsigned char* cr,
-                               int tls1_2, int hash_type);
-
-#ifdef WOLFSSL_CALLBACKS
-
-/* used internally by wolfSSL while OpenSSL types aren't */
-#include 
-
-typedef int (*HandShakeCallBack)(HandShakeInfo*);
-typedef int (*TimeoutCallBack)(TimeoutInfo*);
-
-/* wolfSSL connect extension allowing HandShakeCallBack and/or TimeoutCallBack
-   for diagnostics */
-WOLFSSL_API int wolfSSL_connect_ex(WOLFSSL*, HandShakeCallBack, TimeoutCallBack,
-                                 Timeval);
-WOLFSSL_API int wolfSSL_accept_ex(WOLFSSL*, HandShakeCallBack, TimeoutCallBack,
-                                Timeval);
-
-#endif /* WOLFSSL_CALLBACKS */
-
-
-#ifdef WOLFSSL_HAVE_WOLFSCEP
-    WOLFSSL_API void wolfSSL_wolfSCEP(void);
-#endif /* WOLFSSL_HAVE_WOLFSCEP */
-
-#ifdef WOLFSSL_HAVE_CERT_SERVICE
-    WOLFSSL_API void wolfSSL_cert_service(void);
-#endif
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */
-#endif
-
-
-#endif /* WOLFSSL_SSL_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/test.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/test.h
deleted file mode 100755
index 4c95d72..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/test.h
+++ /dev/null
@@ -1,1952 +0,0 @@
-/* test.h */
-
-#ifndef wolfSSL_TEST_H
-#define wolfSSL_TEST_H
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#ifdef ATOMIC_USER
-    #include 
-    #include 
-    #include 
-#endif
-#ifdef HAVE_PK_CALLBACKS
-    #include 
-    #ifdef HAVE_ECC
-        #include 
-    #endif /* HAVE_ECC */
-#endif /*HAVE_PK_CALLBACKS */
-
-#ifdef USE_WINDOWS_API 
-    #include 
-    #include 
-    #ifdef TEST_IPV6            /* don't require newer SDK for IPV4 */
-        #include 
-        #include 
-    #endif
-    #define SOCKET_T SOCKET
-    #define SNPRINTF _snprintf
-#elif defined(WOLFSSL_MDK_ARM)
-    #include 
-#elif defined(WOLFSSL_TIRTOS)
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    struct hostent {
-    	char *h_name; /* official name of host */
-    	char **h_aliases; /* alias list */
-    	int h_addrtype; /* host address type */
-    	int h_length; /* length of address */
-    	char **h_addr_list; /* list of addresses from name server */
-    };
-    #define SOCKET_T int
-#else
-    #include 
-    #include 
-#ifndef WOLFSSL_LEANPSK
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #include 
-    #ifdef TEST_IPV6
-        #include 
-    #endif
-#endif
-    #define SOCKET_T int
-    #ifndef SO_NOSIGPIPE
-        #include   /* ignore SIGPIPE */
-    #endif
-    #define SNPRINTF snprintf
-#endif /* USE_WINDOWS_API */
-
-#ifdef HAVE_CAVIUM
-    #include "cavium_sysdep.h"
-    #include "cavium_common.h"
-    #include "cavium_ioctl.h"
-#endif
-
-#ifdef _MSC_VER
-    /* disable conversion warning */
-    /* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
-    #pragma warning(disable:4244 4996)
-#endif
-
-
-#if defined(__MACH__) || defined(USE_WINDOWS_API)
-    #ifndef _SOCKLEN_T
-        typedef int socklen_t;
-    #endif
-#endif
-
-
-/* HPUX doesn't use socklent_t for third parameter to accept, unless
-   _XOPEN_SOURCE_EXTENDED is defined */
-#if !defined(__hpux__) && !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_IAR_ARM)
-    typedef socklen_t* ACCEPT_THIRD_T;
-#else
-    #if defined _XOPEN_SOURCE_EXTENDED
-        typedef socklen_t* ACCEPT_THIRD_T;
-    #else
-        typedef int*       ACCEPT_THIRD_T;
-    #endif
-#endif
-
-
-#ifdef USE_WINDOWS_API 
-    #define CloseSocket(s) closesocket(s)
-    #define StartTCP() { WSADATA wsd; WSAStartup(0x0002, &wsd); }
-#elif defined(WOLFSSL_MDK_ARM)
-    #define CloseSocket(s) closesocket(s)
-    #define StartTCP() 
-#else
-    #define CloseSocket(s) close(s)
-    #define StartTCP() 
-#endif
-
-
-#ifdef SINGLE_THREADED
-    typedef unsigned int  THREAD_RETURN;
-    typedef void*         THREAD_TYPE;
-    #define WOLFSSL_THREAD
-#else
-    #if defined(_POSIX_THREADS) && !defined(__MINGW32__)
-        typedef void*         THREAD_RETURN;
-        typedef pthread_t     THREAD_TYPE;
-        #define WOLFSSL_THREAD
-        #define INFINITE -1
-        #define WAIT_OBJECT_0 0L
-    #elif defined(WOLFSSL_MDK_ARM)
-        typedef unsigned int  THREAD_RETURN;
-        typedef int           THREAD_TYPE;
-        #define WOLFSSL_THREAD
-    #elif defined(WOLFSSL_TIRTOS)
-        typedef void          THREAD_RETURN;
-        typedef Task_Handle   THREAD_TYPE;
-        #define WOLFSSL_THREAD
-    #else
-        typedef unsigned int  THREAD_RETURN;
-        typedef intptr_t      THREAD_TYPE;
-        #define WOLFSSL_THREAD __stdcall
-    #endif
-#endif
-
-
-#ifdef TEST_IPV6
-    typedef struct sockaddr_in6 SOCKADDR_IN_T;
-    #define AF_INET_V    AF_INET6
-#else
-    typedef struct sockaddr_in  SOCKADDR_IN_T;
-    #define AF_INET_V    AF_INET
-#endif
-   
-
-#define SERVER_DEFAULT_VERSION 3
-#define SERVER_DTLS_DEFAULT_VERSION (-2)
-#define SERVER_INVALID_VERSION (-99)
-#define CLIENT_DEFAULT_VERSION 3
-#define CLIENT_DTLS_DEFAULT_VERSION (-2)
-#define CLIENT_INVALID_VERSION (-99)
-#if !defined(NO_FILESYSTEM) && defined(WOLFSSL_MAX_STRENGTH)
-    #define DEFAULT_MIN_DHKEY_BITS 2048
-#else
-    #define DEFAULT_MIN_DHKEY_BITS 1024
-#endif
-
-/* all certs relative to wolfSSL home directory now */
-#define caCert     "./certs/ca-cert.pem"
-#define eccCert    "./certs/server-ecc.pem"
-#define eccKey     "./certs/ecc-key.pem"
-#define svrCert    "./certs/server-cert.pem"
-#define svrKey     "./certs/server-key.pem"
-#define cliCert    "./certs/client-cert.pem"
-#define cliKey     "./certs/client-key.pem"
-#define ntruCert   "./certs/ntru-cert.pem"
-#define ntruKey    "./certs/ntru-key.raw"
-#define dhParam    "./certs/dh2048.pem"
-#define cliEccKey  "./certs/ecc-client-key.pem"
-#define cliEccCert "./certs/client-ecc-cert.pem"
-#define crlPemDir  "./certs/crl"
-
-typedef struct tcp_ready {
-    word16 ready;              /* predicate */
-    word16 port;
-#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
-    pthread_mutex_t mutex;
-    pthread_cond_t  cond;
-#endif
-} tcp_ready;    
-
-
-void InitTcpReady(tcp_ready*);
-void FreeTcpReady(tcp_ready*);
-
-typedef WOLFSSL_METHOD* (*method_provider)(void);
-typedef void (*ctx_callback)(WOLFSSL_CTX* ctx);
-typedef void (*ssl_callback)(WOLFSSL* ssl);
-
-typedef struct callback_functions {
-    method_provider method;
-    ctx_callback ctx_ready;
-    ssl_callback ssl_ready;
-    ssl_callback on_result;
-} callback_functions;
-
-typedef struct func_args {
-    int    argc;
-    char** argv;
-    int    return_code;
-    tcp_ready* signal;
-    callback_functions *callbacks;
-} func_args;
-
-void wait_tcp_ready(func_args*);
-
-typedef THREAD_RETURN WOLFSSL_THREAD THREAD_FUNC(void*);
-
-void start_thread(THREAD_FUNC, func_args*, THREAD_TYPE*);
-void join_thread(THREAD_TYPE);
-
-/* wolfSSL */
-#ifndef TEST_IPV6
-    static const char* const wolfSSLIP   = "127.0.0.1";
-#else
-    static const char* const wolfSSLIP   = "::1";
-#endif
-static const word16      wolfSSLPort = 11111;
-
-static INLINE void err_sys(const char* msg)
-{
-    printf("wolfSSL error: %s\n", msg);
-    if (msg)
-        exit(EXIT_FAILURE);
-}
-
-
-#define MY_EX_USAGE 2
-
-extern int   myoptind;
-extern char* myoptarg;
-
-static INLINE int mygetopt(int argc, char** argv, const char* optstring)
-{
-    static char* next = NULL;
-
-    char  c;
-    char* cp;
-
-    if (myoptind == 0)
-        next = NULL;   /* we're starting new/over */
-
-    if (next == NULL || *next == '\0') {
-        if (myoptind == 0)
-            myoptind++;
-
-        if (myoptind >= argc || argv[myoptind][0] != '-' ||
-                                argv[myoptind][1] == '\0') {
-            myoptarg = NULL;
-            if (myoptind < argc)
-                myoptarg = argv[myoptind];
-
-            return -1;
-        }
-
-        if (strcmp(argv[myoptind], "--") == 0) {
-            myoptind++;
-            myoptarg = NULL;
-
-            if (myoptind < argc)
-                myoptarg = argv[myoptind];
-
-            return -1;
-        }
-
-        next = argv[myoptind];
-        next++;                  /* skip - */
-        myoptind++;
-    }
-
-    c  = *next++;
-    /* The C++ strchr can return a different value */
-    cp = (char*)strchr(optstring, c);
-
-    if (cp == NULL || c == ':') 
-        return '?';
-
-    cp++;
-
-    if (*cp == ':') {
-        if (*next != '\0') {
-            myoptarg = next;
-            next     = NULL;
-        }
-        else if (myoptind < argc) {
-            myoptarg = argv[myoptind];
-            myoptind++;
-        }
-        else 
-            return '?';
-    }
-
-    return c;
-}
-
-
-#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
-
-static INLINE int PasswordCallBack(char* passwd, int sz, int rw, void* userdata)
-{
-    (void)rw;
-    (void)userdata;
-    strncpy(passwd, "yassl123", sz);
-    return 8;
-}
-
-#endif
-
-
-#if defined(KEEP_PEER_CERT) || defined(SESSION_CERTS)
-
-static INLINE void ShowX509(WOLFSSL_X509* x509, const char* hdr)
-{
-    char* altName;
-    char* issuer  = wolfSSL_X509_NAME_oneline(
-                                       wolfSSL_X509_get_issuer_name(x509), 0, 0);
-    char* subject = wolfSSL_X509_NAME_oneline(
-                                      wolfSSL_X509_get_subject_name(x509), 0, 0);
-    byte  serial[32];
-    int   ret;
-    int   sz = sizeof(serial);
-        
-    printf("%s\n issuer : %s\n subject: %s\n", hdr, issuer, subject);
-
-    while ( (altName = wolfSSL_X509_get_next_altname(x509)) != NULL)
-        printf(" altname = %s\n", altName);
-
-    ret = wolfSSL_X509_get_serial_number(x509, serial, &sz);
-    if (ret == SSL_SUCCESS) {
-        int  i;
-        int  strLen;
-        char serialMsg[80];
-
-        /* testsuite has multiple threads writing to stdout, get output
-           message ready to write once */
-        strLen = sprintf(serialMsg, " serial number");
-        for (i = 0; i < sz; i++)
-            sprintf(serialMsg + strLen + (i*3), ":%02x ", serial[i]);
-        printf("%s\n", serialMsg);
-    }
-
-    XFREE(subject, 0, DYNAMIC_TYPE_OPENSSL);
-    XFREE(issuer,  0, DYNAMIC_TYPE_OPENSSL);
-}
-
-#endif /* KEEP_PEER_CERT || SESSION_CERTS */
-
-
-static INLINE void showPeer(WOLFSSL* ssl)
-{
-
-    WOLFSSL_CIPHER* cipher;
-#ifdef KEEP_PEER_CERT
-    WOLFSSL_X509* peer = wolfSSL_get_peer_certificate(ssl);
-    if (peer)
-        ShowX509(peer, "peer's cert info:");
-    else
-        printf("peer has no cert!\n");
-#endif
-    printf("SSL version is %s\n", wolfSSL_get_version(ssl));
-
-    cipher = wolfSSL_get_current_cipher(ssl);
-    printf("SSL cipher suite is %s\n", wolfSSL_CIPHER_get_name(cipher));
-
-#if defined(SESSION_CERTS) && defined(SHOW_CERTS)
-    {
-        WOLFSSL_X509_CHAIN* chain = wolfSSL_get_peer_chain(ssl);
-        int                count = wolfSSL_get_chain_count(chain);
-        int i;
-
-        for (i = 0; i < count; i++) {
-            int length;
-            unsigned char buffer[3072];
-            WOLFSSL_X509* chainX509;
-
-            wolfSSL_get_chain_cert_pem(chain,i,buffer, sizeof(buffer), &length);
-            buffer[length] = 0;
-            printf("cert %d has length %d data = \n%s\n", i, length, buffer);
-
-            chainX509 = wolfSSL_get_chain_X509(chain, i);
-            if (chainX509)
-                ShowX509(chainX509, "session cert info:");
-            else
-                printf("get_chain_X509 failed\n");
-            wolfSSL_FreeX509(chainX509);
-        }
-    }
-#endif
-  (void)ssl;
-}
-
-
-static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
-                              word16 port, int udp)
-{
-    int useLookup = 0;
-    (void)useLookup;
-    (void)udp;
-
-    memset(addr, 0, sizeof(SOCKADDR_IN_T));
-
-#ifndef TEST_IPV6
-    /* peer could be in human readable form */
-    if ( (peer != INADDR_ANY) && isalpha((int)peer[0])) {
-        #ifdef WOLFSSL_MDK_ARM
-            int err;
-            struct hostent* entry = gethostbyname(peer, &err);
-        #elif defined(WOLFSSL_TIRTOS)
-            struct hostent* entry = DNSGetHostByName(peer);
-        #else
-            struct hostent* entry = gethostbyname(peer);
-        #endif
-
-        if (entry) {
-            memcpy(&addr->sin_addr.s_addr, entry->h_addr_list[0],
-                   entry->h_length);
-            useLookup = 1;
-        }
-        else
-            err_sys("no entry for host");
-    }
-#endif
-
-
-#ifndef TEST_IPV6
-    #if defined(WOLFSSL_MDK_ARM)
-        addr->sin_family = PF_INET;
-    #else
-        addr->sin_family = AF_INET_V;
-    #endif
-    addr->sin_port = htons(port);
-    if (peer == INADDR_ANY)
-        addr->sin_addr.s_addr = INADDR_ANY;
-    else {
-        if (!useLookup)
-            addr->sin_addr.s_addr = inet_addr(peer);
-    }
-#else
-    addr->sin6_family = AF_INET_V;
-    addr->sin6_port = htons(port);
-    if (peer == INADDR_ANY)
-        addr->sin6_addr = in6addr_any;
-    else {
-        #ifdef HAVE_GETADDRINFO
-            struct addrinfo  hints;
-            struct addrinfo* answer = NULL;
-            int    ret;
-            char   strPort[80];
-
-            memset(&hints, 0, sizeof(hints));
-
-            hints.ai_family   = AF_INET_V;
-            hints.ai_socktype = udp ? SOCK_DGRAM : SOCK_STREAM;
-            hints.ai_protocol = udp ? IPPROTO_UDP : IPPROTO_TCP;
-
-            SNPRINTF(strPort, sizeof(strPort), "%d", port);
-            strPort[79] = '\0';
-
-            ret = getaddrinfo(peer, strPort, &hints, &answer);
-            if (ret < 0 || answer == NULL)
-                err_sys("getaddrinfo failed");
-
-            memcpy(addr, answer->ai_addr, answer->ai_addrlen);
-            freeaddrinfo(answer);
-        #else
-            printf("no ipv6 getaddrinfo, loopback only tests/examples\n");
-            addr->sin6_addr = in6addr_loopback;
-        #endif
-    }
-#endif
-}
-
-
-static INLINE void tcp_socket(SOCKET_T* sockfd, int udp)
-{
-    if (udp)
-        *sockfd = socket(AF_INET_V, SOCK_DGRAM, 0);
-    else
-        *sockfd = socket(AF_INET_V, SOCK_STREAM, 0);
-
-#ifdef USE_WINDOWS_API
-    if (*sockfd == INVALID_SOCKET)
-        err_sys("socket failed\n");
-#elif defined(WOLFSSL_TIRTOS)
-    if (*sockfd == -1)
-        err_sys("socket failed\n");
-#else
-    if (*sockfd < 0)
-        err_sys("socket failed\n");
-#endif
-
-#ifndef USE_WINDOWS_API 
-#ifdef SO_NOSIGPIPE
-    {
-        int       on = 1;
-        socklen_t len = sizeof(on);
-        int       res = setsockopt(*sockfd, SOL_SOCKET, SO_NOSIGPIPE, &on, len);
-        if (res < 0)
-            err_sys("setsockopt SO_NOSIGPIPE failed\n");
-    }
-#elif defined(WOLFSSL_MDK_ARM) || defined (WOLFSSL_TIRTOS)
-    /* nothing to define */
-#else  /* no S_NOSIGPIPE */
-    signal(SIGPIPE, SIG_IGN);
-#endif /* S_NOSIGPIPE */
-
-#if defined(TCP_NODELAY)
-    if (!udp)
-    {
-        int       on = 1;
-        socklen_t len = sizeof(on);
-        int       res = setsockopt(*sockfd, IPPROTO_TCP, TCP_NODELAY, &on, len);
-        if (res < 0)
-            err_sys("setsockopt TCP_NODELAY failed\n");
-    }
-#endif
-#endif  /* USE_WINDOWS_API */
-}
-
-static INLINE void tcp_connect(SOCKET_T* sockfd, const char* ip, word16 port,
-                               int udp)
-{
-    SOCKADDR_IN_T addr;
-    build_addr(&addr, ip, port, udp);
-    tcp_socket(sockfd, udp);
-
-    if (!udp) {
-        if (connect(*sockfd, (const struct sockaddr*)&addr, sizeof(addr)) != 0)
-            err_sys("tcp connect failed");
-    }
-}
-
-
-static INLINE void udp_connect(SOCKET_T* sockfd, void* addr, int addrSz)
-{
-    if (connect(*sockfd, (const struct sockaddr*)addr, addrSz) != 0)
-        err_sys("tcp connect failed");
-}
-
-
-enum {
-    TEST_SELECT_FAIL,
-    TEST_TIMEOUT,
-    TEST_RECV_READY,
-    TEST_ERROR_READY
-};
-
-
-#if !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_TIRTOS)
-static INLINE int tcp_select(SOCKET_T socketfd, int to_sec)
-{
-    fd_set recvfds, errfds;
-    SOCKET_T nfds = socketfd + 1;
-    struct timeval timeout = { (to_sec > 0) ? to_sec : 0, 0};
-    int result;
-
-    FD_ZERO(&recvfds);
-    FD_SET(socketfd, &recvfds);
-    FD_ZERO(&errfds);
-    FD_SET(socketfd, &errfds);
-
-    result = select(nfds, &recvfds, NULL, &errfds, &timeout);
-
-    if (result == 0)
-        return TEST_TIMEOUT;
-    else if (result > 0) {
-        if (FD_ISSET(socketfd, &recvfds))
-            return TEST_RECV_READY;
-        else if(FD_ISSET(socketfd, &errfds))
-            return TEST_ERROR_READY;
-    }
-
-    return TEST_SELECT_FAIL;
-}
-#elif defined(WOLFSSL_TIRTOS)
-static INLINE int tcp_select(SOCKET_T socketfd, int to_sec)
-{
-    return TEST_RECV_READY;
-}
-#endif /* !WOLFSSL_MDK_ARM */
-
-
-static INLINE void tcp_listen(SOCKET_T* sockfd, word16* port, int useAnyAddr,
-                              int udp)
-{
-    SOCKADDR_IN_T addr;
-
-    /* don't use INADDR_ANY by default, firewall may block, make user switch
-       on */
-    build_addr(&addr, (useAnyAddr ? INADDR_ANY : wolfSSLIP), *port, udp);
-    tcp_socket(sockfd, udp);
-
-#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_MDK_ARM)
-    {
-        int       res, on  = 1;
-        socklen_t len = sizeof(on);
-        res = setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR, &on, len);
-        if (res < 0)
-            err_sys("setsockopt SO_REUSEADDR failed\n");
-    }
-#endif
-
-    if (bind(*sockfd, (const struct sockaddr*)&addr, sizeof(addr)) != 0)
-        err_sys("tcp bind failed");
-    if (!udp) {
-        if (listen(*sockfd, 5) != 0)
-            err_sys("tcp listen failed");
-    }
-    #if (defined(NO_MAIN_DRIVER) && !defined(USE_WINDOWS_API)) && !defined(WOLFSSL_TIRTOS)
-        if (*port == 0) {
-            socklen_t len = sizeof(addr);
-            if (getsockname(*sockfd, (struct sockaddr*)&addr, &len) == 0) {
-                #ifndef TEST_IPV6
-                    *port = ntohs(addr.sin_port);
-                #else
-                    *port = ntohs(addr.sin6_port);
-                #endif
-            }
-        }
-    #endif
-}
-
-
-static INLINE int udp_read_connect(SOCKET_T sockfd)
-{
-    SOCKADDR_IN_T cliaddr;
-    byte          b[1500];
-    int           n;
-    socklen_t     len = sizeof(cliaddr);
-
-    n = (int)recvfrom(sockfd, (char*)b, sizeof(b), MSG_PEEK,
-                      (struct sockaddr*)&cliaddr, &len);
-    if (n > 0) {
-        if (connect(sockfd, (const struct sockaddr*)&cliaddr,
-                    sizeof(cliaddr)) != 0)
-            err_sys("udp connect failed");
-    }
-    else
-        err_sys("recvfrom failed");
-
-    return sockfd;
-}
-
-static INLINE void udp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
-                              int useAnyAddr, word16 port, func_args* args)
-{
-    SOCKADDR_IN_T addr;
-
-    (void)args;
-    build_addr(&addr, (useAnyAddr ? INADDR_ANY : wolfSSLIP), port, 1);
-    tcp_socket(sockfd, 1);
-
-
-#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_MDK_ARM)
-    {
-        int       res, on  = 1;
-        socklen_t len = sizeof(on);
-        res = setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR, &on, len);
-        if (res < 0)
-            err_sys("setsockopt SO_REUSEADDR failed\n");
-    }
-#endif
-
-    if (bind(*sockfd, (const struct sockaddr*)&addr, sizeof(addr)) != 0)
-        err_sys("tcp bind failed");
-
-    #if (defined(NO_MAIN_DRIVER) && !defined(USE_WINDOWS_API)) && !defined(WOLFSSL_TIRTOS)
-        if (port == 0) {
-            socklen_t len = sizeof(addr);
-            if (getsockname(*sockfd, (struct sockaddr*)&addr, &len) == 0) {
-                #ifndef TEST_IPV6
-                    port = ntohs(addr.sin_port);
-                #else
-                    port = ntohs(addr.sin6_port);
-                #endif
-            }
-        }
-    #endif
-
-#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) && !defined(__MINGW32__)
-    /* signal ready to accept data */
-    {
-    tcp_ready* ready = args->signal;
-    pthread_mutex_lock(&ready->mutex);
-    ready->ready = 1;
-    ready->port = port;
-    pthread_cond_signal(&ready->cond);
-    pthread_mutex_unlock(&ready->mutex);
-    }
-#elif defined (WOLFSSL_TIRTOS)
-    /* Need mutex? */
-    tcp_ready* ready = args->signal;
-    ready->ready = 1;
-    ready->port = port;
-#endif
-
-    *clientfd = udp_read_connect(*sockfd);
-}
-
-static INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
-                              func_args* args, word16 port, int useAnyAddr,
-                              int udp, int ready_file)
-{
-    SOCKADDR_IN_T client;
-    socklen_t client_len = sizeof(client);
-
-    if (udp) {
-        udp_accept(sockfd, clientfd, useAnyAddr, port, args);
-        return;
-    }
-
-    tcp_listen(sockfd, &port, useAnyAddr, udp);
-
-#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) && !defined(__MINGW32__)
-    /* signal ready to tcp_accept */
-    {
-    tcp_ready* ready = args->signal;
-    pthread_mutex_lock(&ready->mutex);
-    ready->ready = 1;
-    ready->port = port;
-    pthread_cond_signal(&ready->cond);
-    pthread_mutex_unlock(&ready->mutex);
-    }
-#elif defined (WOLFSSL_TIRTOS)
-    /* Need mutex? */
-    tcp_ready* ready = args->signal;
-    ready->ready = 1;
-    ready->port = port;
-#endif
-
-    if (ready_file) {
-#ifndef NO_FILESYSTEM
-    #ifndef USE_WINDOWS_API
-        FILE* srf = fopen("/tmp/wolfssl_server_ready", "w");
-    #else
-        FILE* srf = fopen("wolfssl_server_ready", "w");
-    #endif
-
-        if (srf) {
-            fputs("ready", srf);
-            fclose(srf);
-        }
-#endif
-    }
-
-    *clientfd = accept(*sockfd, (struct sockaddr*)&client,
-                      (ACCEPT_THIRD_T)&client_len);
-#ifdef USE_WINDOWS_API
-    if (*clientfd == INVALID_SOCKET)
-        err_sys("tcp accept failed");
-#else
-    if (*clientfd == -1)
-        err_sys("tcp accept failed");
-#endif
-}
-
-
-static INLINE void tcp_set_nonblocking(SOCKET_T* sockfd)
-{
-    #ifdef USE_WINDOWS_API 
-        unsigned long blocking = 1;
-        int ret = ioctlsocket(*sockfd, FIONBIO, &blocking);
-        if (ret == SOCKET_ERROR)
-            err_sys("ioctlsocket failed");
-    #elif defined(WOLFSSL_MDK_ARM) || defined (WOLFSSL_TIRTOS)
-         /* non blocking not suppported, for now */ 
-    #else
-        int flags = fcntl(*sockfd, F_GETFL, 0);
-        if (flags < 0)
-            err_sys("fcntl get failed");
-        flags = fcntl(*sockfd, F_SETFL, flags | O_NONBLOCK);
-        if (flags < 0)
-            err_sys("fcntl set failed");
-    #endif
-}
-
-
-#ifndef NO_PSK
-
-static INLINE unsigned int my_psk_client_cb(WOLFSSL* ssl, const char* hint,
-        char* identity, unsigned int id_max_len, unsigned char* key,
-        unsigned int key_max_len)
-{
-    (void)ssl;
-    (void)hint;
-    (void)key_max_len;
-
-    /* identity is OpenSSL testing default for openssl s_client, keep same */
-    strncpy(identity, "Client_identity", id_max_len);
-
-
-    /* test key in hex is 0x1a2b3c4d , in decimal 439,041,101 , we're using
-       unsigned binary */
-    key[0] = 26;
-    key[1] = 43;
-    key[2] = 60;
-    key[3] = 77;
-
-    return 4;   /* length of key in octets or 0 for error */
-}
-
-
-static INLINE unsigned int my_psk_server_cb(WOLFSSL* ssl, const char* identity,
-        unsigned char* key, unsigned int key_max_len)
-{
-    (void)ssl;
-    (void)key_max_len;
-
-    /* identity is OpenSSL testing default for openssl s_client, keep same */
-    if (strncmp(identity, "Client_identity", 15) != 0)
-        return 0;
-
-    /* test key in hex is 0x1a2b3c4d , in decimal 439,041,101 , we're using
-       unsigned binary */
-    key[0] = 26;
-    key[1] = 43;
-    key[2] = 60;
-    key[3] = 77;
-
-    return 4;   /* length of key in octets or 0 for error */
-}
-
-#endif /* NO_PSK */
-
-
-#ifdef USE_WINDOWS_API 
-
-    #define WIN32_LEAN_AND_MEAN
-    #include 
-
-    static INLINE double current_time()
-    {
-        static int init = 0;
-        static LARGE_INTEGER freq;
-    
-        LARGE_INTEGER count;
-
-        if (!init) {
-            QueryPerformanceFrequency(&freq);
-            init = 1;
-        }
-
-        QueryPerformanceCounter(&count);
-
-        return (double)count.QuadPart / freq.QuadPart;
-    }
-
-#elif defined(WOLFSSL_TIRTOS)
-    extern double current_time();
-#else
-
-#if !defined(WOLFSSL_MDK_ARM)
-    #include 
-
-    static INLINE double current_time(void)
-    {
-        struct timeval tv;
-        gettimeofday(&tv, 0);
-
-        return (double)tv.tv_sec + (double)tv.tv_usec / 1000000;
-    }
-        
-#endif
-#endif /* USE_WINDOWS_API */
-
-
-#if defined(NO_FILESYSTEM) && !defined(NO_CERTS)
-
-    enum {
-        WOLFSSL_CA   = 1,
-        WOLFSSL_CERT = 2,
-        WOLFSSL_KEY  = 3
-    };
-
-    static INLINE void load_buffer(WOLFSSL_CTX* ctx, const char* fname, int type)
-    {
-        /* test buffer load */
-        long  sz = 0;
-        byte  buff[10000];
-        FILE* file = fopen(fname, "rb");
-
-        if (!file)
-            err_sys("can't open file for buffer load "
-                    "Please run from wolfSSL home directory if not");
-        fseek(file, 0, SEEK_END);
-        sz = ftell(file);
-        rewind(file);
-        fread(buff, sizeof(buff), 1, file);
-  
-        if (type == WOLFSSL_CA) {
-            if (wolfSSL_CTX_load_verify_buffer(ctx, buff, sz, SSL_FILETYPE_PEM)
-                                              != SSL_SUCCESS)
-                err_sys("can't load buffer ca file");
-        }
-        else if (type == WOLFSSL_CERT) {
-            if (wolfSSL_CTX_use_certificate_buffer(ctx, buff, sz,
-                        SSL_FILETYPE_PEM) != SSL_SUCCESS)
-                err_sys("can't load buffer cert file");
-        }
-        else if (type == WOLFSSL_KEY) {
-            if (wolfSSL_CTX_use_PrivateKey_buffer(ctx, buff, sz,
-                        SSL_FILETYPE_PEM) != SSL_SUCCESS)
-                err_sys("can't load buffer key file");
-        }
-    }
-
-#endif /* NO_FILESYSTEM */
-
-#ifdef VERIFY_CALLBACK
-
-static INLINE int myVerify(int preverify, WOLFSSL_X509_STORE_CTX* store)
-{
-    (void)preverify;
-    char buffer[WOLFSSL_MAX_ERROR_SZ];
-
-#ifdef OPENSSL_EXTRA
-    WOLFSSL_X509* peer;
-#endif
-
-    printf("In verification callback, error = %d, %s\n", store->error,
-                                 wolfSSL_ERR_error_string(store->error, buffer));
-#ifdef OPENSSL_EXTRA
-    peer = store->current_cert;
-    if (peer) {
-        char* issuer  = wolfSSL_X509_NAME_oneline(
-                                       wolfSSL_X509_get_issuer_name(peer), 0, 0);
-        char* subject = wolfSSL_X509_NAME_oneline(
-                                      wolfSSL_X509_get_subject_name(peer), 0, 0);
-        printf("peer's cert info:\n issuer : %s\n subject: %s\n", issuer,
-                                                                  subject);
-        XFREE(subject, 0, DYNAMIC_TYPE_OPENSSL);
-        XFREE(issuer,  0, DYNAMIC_TYPE_OPENSSL);
-    }
-    else
-        printf("peer has no cert!\n");
-#endif
-    printf("Subject's domain name is %s\n", store->domain);
-
-    printf("Allowing to continue anyway (shouldn't do this, EVER!!!)\n");
-    return 1;
-}
-
-#endif /* VERIFY_CALLBACK */
-
-
-static INLINE int myDateCb(int preverify, WOLFSSL_X509_STORE_CTX* store)
-{
-    char buffer[WOLFSSL_MAX_ERROR_SZ];
-    (void)preverify;
-
-    printf("In verification callback, error = %d, %s\n", store->error,
-                                 wolfSSL_ERR_error_string(store->error, buffer));
-    printf("Subject's domain name is %s\n", store->domain);
-
-    if (store->error == ASN_BEFORE_DATE_E || store->error == ASN_AFTER_DATE_E) {
-        printf("Overriding cert date error as example for bad clock testing\n");
-        return 1;
-    }
-    printf("Cert error is not date error, not overriding\n");
-
-    return 0;
-}
-
-
-#ifdef HAVE_CRL
-
-static INLINE void CRL_CallBack(const char* url)
-{
-    printf("CRL callback url = %s\n", url);
-}
-
-#endif
-
-#ifndef NO_DH
-static INLINE void SetDH(WOLFSSL* ssl)
-{
-    /* dh1024 p */
-    static unsigned char p[] =
-    {
-        0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3,
-        0xBD, 0xD4, 0x79, 0x8E, 0x91, 0xB7, 0x81, 0x82, 0x51, 0xBB, 0x05, 0x5E,
-        0x2A, 0x20, 0x64, 0x90, 0x4A, 0x79, 0xA7, 0x70, 0xFA, 0x15, 0xA2, 0x59,
-        0xCB, 0xD5, 0x23, 0xA6, 0xA6, 0xEF, 0x09, 0xC4, 0x30, 0x48, 0xD5, 0xA2,
-        0x2F, 0x97, 0x1F, 0x3C, 0x20, 0x12, 0x9B, 0x48, 0x00, 0x0E, 0x6E, 0xDD,
-        0x06, 0x1C, 0xBC, 0x05, 0x3E, 0x37, 0x1D, 0x79, 0x4E, 0x53, 0x27, 0xDF,
-        0x61, 0x1E, 0xBB, 0xBE, 0x1B, 0xAC, 0x9B, 0x5C, 0x60, 0x44, 0xCF, 0x02,
-        0x3D, 0x76, 0xE0, 0x5E, 0xEA, 0x9B, 0xAD, 0x99, 0x1B, 0x13, 0xA6, 0x3C,
-        0x97, 0x4E, 0x9E, 0xF1, 0x83, 0x9E, 0xB5, 0xDB, 0x12, 0x51, 0x36, 0xF7,
-        0x26, 0x2E, 0x56, 0xA8, 0x87, 0x15, 0x38, 0xDF, 0xD8, 0x23, 0xC6, 0x50,
-        0x50, 0x85, 0xE2, 0x1F, 0x0D, 0xD5, 0xC8, 0x6B,
-    };
-
-    /* dh1024 g */
-    static unsigned char g[] =
-    {
-      0x02,
-    };
-
-    wolfSSL_SetTmpDH(ssl, p, sizeof(p), g, sizeof(g));
-}
-
-static INLINE void SetDHCtx(WOLFSSL_CTX* ctx)
-{
-    /* dh1024 p */
-    static unsigned char p[] =
-    {
-        0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3,
-        0xBD, 0xD4, 0x79, 0x8E, 0x91, 0xB7, 0x81, 0x82, 0x51, 0xBB, 0x05, 0x5E,
-        0x2A, 0x20, 0x64, 0x90, 0x4A, 0x79, 0xA7, 0x70, 0xFA, 0x15, 0xA2, 0x59,
-        0xCB, 0xD5, 0x23, 0xA6, 0xA6, 0xEF, 0x09, 0xC4, 0x30, 0x48, 0xD5, 0xA2,
-        0x2F, 0x97, 0x1F, 0x3C, 0x20, 0x12, 0x9B, 0x48, 0x00, 0x0E, 0x6E, 0xDD,
-        0x06, 0x1C, 0xBC, 0x05, 0x3E, 0x37, 0x1D, 0x79, 0x4E, 0x53, 0x27, 0xDF,
-        0x61, 0x1E, 0xBB, 0xBE, 0x1B, 0xAC, 0x9B, 0x5C, 0x60, 0x44, 0xCF, 0x02,
-        0x3D, 0x76, 0xE0, 0x5E, 0xEA, 0x9B, 0xAD, 0x99, 0x1B, 0x13, 0xA6, 0x3C,
-        0x97, 0x4E, 0x9E, 0xF1, 0x83, 0x9E, 0xB5, 0xDB, 0x12, 0x51, 0x36, 0xF7,
-        0x26, 0x2E, 0x56, 0xA8, 0x87, 0x15, 0x38, 0xDF, 0xD8, 0x23, 0xC6, 0x50,
-        0x50, 0x85, 0xE2, 0x1F, 0x0D, 0xD5, 0xC8, 0x6B,
-    };
-
-    /* dh1024 g */
-    static unsigned char g[] =
-    {
-      0x02,
-    };
-
-    wolfSSL_CTX_SetTmpDH(ctx, p, sizeof(p), g, sizeof(g));
-}
-#endif /* NO_DH */
-
-#ifndef NO_CERTS
-
-static INLINE void CaCb(unsigned char* der, int sz, int type)
-{
-    (void)der;
-    printf("Got CA cache add callback, derSz = %d, type = %d\n", sz, type);
-}
-
-#endif /* !NO_CERTS */
-
-#ifdef HAVE_CAVIUM
-
-static INLINE int OpenNitroxDevice(int dma_mode,int dev_id)
-{
-   Csp1CoreAssignment core_assign;
-   Uint32             device;
-
-   if (CspInitialize(CAVIUM_DIRECT,CAVIUM_DEV_ID))
-      return -1;
-   if (Csp1GetDevType(&device))
-      return -1;
-   if (device != NPX_DEVICE) {
-      if (ioctl(gpkpdev_hdlr[CAVIUM_DEV_ID], IOCTL_CSP1_GET_CORE_ASSIGNMENT,
-                (Uint32 *)&core_assign)!= 0)
-         return -1;
-   }
-   CspShutdown(CAVIUM_DEV_ID);
-
-   return CspInitialize(dma_mode, dev_id);
-}
-
-#endif /* HAVE_CAVIUM */
-
-
-#ifdef USE_WINDOWS_API 
-
-/* do back x number of directories */
-static INLINE void ChangeDirBack(int x)
-{
-    char path[MAX_PATH];
-
-    if (x == 1)
-        strncpy(path, "..\\", MAX_PATH);
-    else if (x == 2)
-        strncpy(path, "..\\..\\", MAX_PATH);
-    else if (x == 3)
-        strncpy(path, "..\\..\\..\\", MAX_PATH);
-    else if (x == 4)
-        strncpy(path, "..\\..\\..\\..\\", MAX_PATH);
-    else
-        strncpy(path, ".\\", MAX_PATH);
-    
-    SetCurrentDirectoryA(path);
-}
-
-/* does current dir contain str */
-static INLINE int CurrentDir(const char* str)
-{
-    char  path[MAX_PATH];
-    char* baseName;
-
-    GetCurrentDirectoryA(sizeof(path), path);
-
-    baseName = strrchr(path, '\\');
-    if (baseName)
-        baseName++;
-    else
-        baseName = path;
-
-    if (strstr(baseName, str))
-        return 1;
-
-    return 0;
-}
-
-#elif defined(WOLFSSL_MDK_ARM)
-    /* KEIL-RL File System does not support relative directry */
-#elif defined(WOLFSSL_TIRTOS)
-#else
-
-#ifndef MAX_PATH
-    #define MAX_PATH 256
-#endif
-
-/* do back x number of directories */
-static INLINE void ChangeDirBack(int x)
-{
-    char path[MAX_PATH];
-
-    if (x == 1)
-        strncpy(path, "../", MAX_PATH);
-    else if (x == 2)
-        strncpy(path, "../../", MAX_PATH);
-    else if (x == 3)
-        strncpy(path, "../../../", MAX_PATH);
-    else if (x == 4)
-        strncpy(path, "../../../../", MAX_PATH);
-    else
-        strncpy(path, "./", MAX_PATH);
-    
-    if (chdir(path) < 0)
-        printf("chdir to %s failed\n", path);
-}
-
-/* does current dir contain str */
-static INLINE int CurrentDir(const char* str)
-{
-    char  path[MAX_PATH];
-    char* baseName;
-
-    if (getcwd(path, sizeof(path)) == NULL) {
-        printf("no current dir?\n");
-        return 0;
-    }
-
-    baseName = strrchr(path, '/');
-    if (baseName)
-        baseName++;
-    else
-        baseName = path;
-
-    if (strstr(baseName, str))
-        return 1;
-
-    return 0;
-}
-
-#endif /* USE_WINDOWS_API */
-
-
-#ifdef USE_WOLFSSL_MEMORY
-
-    typedef struct memoryStats {
-        size_t totalAllocs;     /* number of allocations */
-        size_t totalBytes;      /* total number of bytes allocated */
-        size_t peakBytes;       /* concurrent max bytes */
-        size_t currentBytes;    /* total current bytes in use */
-    } memoryStats;
-
-    typedef struct memHint {
-        size_t thisSize;      /* size of this memory */
-        void*  thisMemory;    /* actual memory for user */
-    } memHint;
-
-    typedef struct memoryTrack {
-        union {
-            memHint hint;
-            byte    alignit[16];   /* make sure we have strong alignment */
-        } u;
-    } memoryTrack;
-
-    #if defined(WOLFSSL_TRACK_MEMORY)
-        #define DO_MEM_STATS
-        static memoryStats ourMemStats;
-    #endif
-
-    static INLINE void* TrackMalloc(size_t sz)
-    {
-        memoryTrack* mt;
-
-        if (sz == 0)
-            return NULL;
-
-        mt = (memoryTrack*)malloc(sizeof(memoryTrack) + sz);
-        if (mt == NULL)
-            return NULL;
-
-        mt->u.hint.thisSize   = sz;
-        mt->u.hint.thisMemory = (byte*)mt + sizeof(memoryTrack);
-
-#ifdef DO_MEM_STATS
-        ourMemStats.totalAllocs++;
-        ourMemStats.totalBytes   += sz;
-        ourMemStats.currentBytes += sz;
-        if (ourMemStats.currentBytes > ourMemStats.peakBytes)
-            ourMemStats.peakBytes = ourMemStats.currentBytes;
-#endif
-
-        return mt->u.hint.thisMemory;
-    }
-
-
-    static INLINE void TrackFree(void* ptr)
-    {
-        memoryTrack* mt;
-
-        if (ptr == NULL)
-            return;
-
-        mt = (memoryTrack*)ptr;
-        --mt;   /* same as minus sizeof(memoryTrack), removes header */
-
-#ifdef DO_MEM_STATS 
-        ourMemStats.currentBytes -= mt->u.hint.thisSize; 
-#endif
-
-        free(mt);
-    }
-
-
-    static INLINE void* TrackRealloc(void* ptr, size_t sz)
-    {
-        void* ret = TrackMalloc(sz);
-
-        if (ptr) {
-            /* if realloc is bigger, don't overread old ptr */
-            memoryTrack* mt = (memoryTrack*)ptr;
-            --mt;  /* same as minus sizeof(memoryTrack), removes header */
-
-            if (mt->u.hint.thisSize < sz)
-                sz = mt->u.hint.thisSize;
-        }
-
-        if (ret && ptr)
-            memcpy(ret, ptr, sz);
-
-        if (ret)
-            TrackFree(ptr);
-
-        return ret;
-    }
-
-    static INLINE void InitMemoryTracker(void) 
-    {
-        if (wolfSSL_SetAllocators(TrackMalloc, TrackFree, TrackRealloc) != 0)
-            err_sys("wolfSSL SetAllocators failed for track memory");
-
-    #ifdef DO_MEM_STATS
-        ourMemStats.totalAllocs  = 0;
-        ourMemStats.totalBytes   = 0;
-        ourMemStats.peakBytes    = 0;
-        ourMemStats.currentBytes = 0;
-    #endif
-    }
-
-    static INLINE void ShowMemoryTracker(void) 
-    {
-    #ifdef DO_MEM_STATS 
-        printf("total   Allocs = %9lu\n",
-                                       (unsigned long)ourMemStats.totalAllocs);
-        printf("total   Bytes  = %9lu\n",
-                                       (unsigned long)ourMemStats.totalBytes);
-        printf("peak    Bytes  = %9lu\n",
-                                       (unsigned long)ourMemStats.peakBytes);
-        printf("current Bytes  = %9lu\n",
-                                       (unsigned long)ourMemStats.currentBytes);
-    #endif
-    }
-
-#endif /* USE_WOLFSSL_MEMORY */
-
-
-#ifdef HAVE_STACK_SIZE
-
-typedef THREAD_RETURN WOLFSSL_THREAD (*thread_func)(void* args);
-
-
-static INLINE void StackSizeCheck(func_args* args, thread_func tf)
-{
-    int            ret, i, used;
-    unsigned char* myStack;
-    int            stackSize = 1024*128;
-    pthread_attr_t myAttr;
-    pthread_t      threadId;
-
-#ifdef PTHREAD_STACK_MIN
-    if (stackSize < PTHREAD_STACK_MIN)
-        stackSize = PTHREAD_STACK_MIN;
-#endif
-
-    ret = posix_memalign((void**)&myStack, sysconf(_SC_PAGESIZE), stackSize);
-    if (ret != 0) 
-        err_sys("posix_memalign failed\n");        
-
-    memset(myStack, 0x01, stackSize);
-
-    ret = pthread_attr_init(&myAttr);
-    if (ret != 0)
-        err_sys("attr_init failed");
-
-    ret = pthread_attr_setstack(&myAttr, myStack, stackSize);
-    if (ret != 0)
-        err_sys("attr_setstackaddr failed");
-
-    ret = pthread_create(&threadId, &myAttr, tf, args);
-    if (ret != 0) {
-        perror("pthread_create failed");
-        exit(EXIT_FAILURE);
-    }
-
-    ret = pthread_join(threadId, NULL);
-    if (ret != 0)
-        err_sys("pthread_join failed");
-
-    for (i = 0; i < stackSize; i++) {
-        if (myStack[i] != 0x01) {
-            break;
-        }
-    }
-
-    used = stackSize - i;
-    printf("stack used = %d\n", used);
-}
-
-
-#endif /* HAVE_STACK_SIZE */
-
-
-#ifdef STACK_TRAP
-
-/* good settings
-   --enable-debug --disable-shared C_EXTRA_FLAGS="-DUSER_TIME -DTFM_TIMING_RESISTANT -DPOSITIVE_EXP_ONLY -DSTACK_TRAP"
-
-*/
-
-#ifdef HAVE_STACK_SIZE
-    /* client only for now, setrlimit will fail if pthread_create() called */
-    /* STACK_SIZE does pthread_create() on client */
-    #error "can't use STACK_TRAP with STACK_SIZE, setrlimit will fail"
-#endif /* HAVE_STACK_SIZE */
-
-static INLINE void StackTrap(void)
-{
-    struct rlimit  rl;
-    if (getrlimit(RLIMIT_STACK, &rl) != 0)
-        err_sys("getrlimit failed");
-    printf("rlim_cur = %llu\n", rl.rlim_cur);
-    rl.rlim_cur = 1024*21;  /* adjust trap size here */
-    if (setrlimit(RLIMIT_STACK, &rl) != 0) {
-        perror("setrlimit");
-        err_sys("setrlimit failed");
-    }
-}
-
-#else /* STACK_TRAP */
-
-static INLINE void StackTrap(void)
-{
-}
-
-#endif /* STACK_TRAP */
-
-
-#ifdef ATOMIC_USER
-
-/* Atomic Encrypt Context example */
-typedef struct AtomicEncCtx {
-    int  keySetup;           /* have we done key setup yet */
-    Aes  aes;                /* for aes example */
-} AtomicEncCtx;
-
-
-/* Atomic Decrypt Context example */
-typedef struct AtomicDecCtx {
-    int  keySetup;           /* have we done key setup yet */
-    Aes  aes;                /* for aes example */
-} AtomicDecCtx;
-
-
-static INLINE int myMacEncryptCb(WOLFSSL* ssl, unsigned char* macOut, 
-       const unsigned char* macIn, unsigned int macInSz, int macContent, 
-       int macVerify, unsigned char* encOut, const unsigned char* encIn,
-       unsigned int encSz, void* ctx)
-{
-    int  ret;
-    Hmac hmac;
-    byte myInner[WOLFSSL_TLS_HMAC_INNER_SZ];
-    AtomicEncCtx* encCtx = (AtomicEncCtx*)ctx;
-    const char* tlsStr = "TLS";
-
-    /* example supports (d)tls aes */
-    if (wolfSSL_GetBulkCipher(ssl) != wolfssl_aes) {
-        printf("myMacEncryptCb not using AES\n");
-        return -1;
-    }
-
-    if (strstr(wolfSSL_get_version(ssl), tlsStr) == NULL) {
-        printf("myMacEncryptCb not using (D)TLS\n");
-        return -1;
-    }
-
-    /* hmac, not needed if aead mode */
-    wolfSSL_SetTlsHmacInner(ssl, myInner, macInSz, macContent, macVerify);
-
-    ret = wc_HmacSetKey(&hmac, wolfSSL_GetHmacType(ssl),
-               wolfSSL_GetMacSecret(ssl, macVerify), wolfSSL_GetHmacSize(ssl));
-    if (ret != 0)
-        return ret;
-    ret = wc_HmacUpdate(&hmac, myInner, sizeof(myInner));
-    if (ret != 0)
-        return ret;
-    ret = wc_HmacUpdate(&hmac, macIn, macInSz);
-    if (ret != 0)
-        return ret;
-    ret = wc_HmacFinal(&hmac, macOut);
-    if (ret != 0)
-        return ret;
-
-
-    /* encrypt setup on first time */
-    if (encCtx->keySetup == 0) {
-        int   keyLen = wolfSSL_GetKeySize(ssl);
-        const byte* key;
-        const byte* iv;
-
-        if (wolfSSL_GetSide(ssl) == WOLFSSL_CLIENT_END) {
-            key = wolfSSL_GetClientWriteKey(ssl);
-            iv  = wolfSSL_GetClientWriteIV(ssl);
-        }
-        else {
-            key = wolfSSL_GetServerWriteKey(ssl);
-            iv  = wolfSSL_GetServerWriteIV(ssl);
-        }
-
-        ret = wc_AesSetKey(&encCtx->aes, key, keyLen, iv, AES_ENCRYPTION);
-        if (ret != 0) {
-            printf("AesSetKey failed in myMacEncryptCb\n");
-            return ret;
-        }
-        encCtx->keySetup = 1;
-    }
-
-    /* encrypt */
-    return wc_AesCbcEncrypt(&encCtx->aes, encOut, encIn, encSz);
-}
-
-
-static INLINE int myDecryptVerifyCb(WOLFSSL* ssl, 
-       unsigned char* decOut, const unsigned char* decIn,
-       unsigned int decSz, int macContent, int macVerify,
-       unsigned int* padSz, void* ctx)
-{
-    AtomicDecCtx* decCtx = (AtomicDecCtx*)ctx;
-    int ret      = 0;
-    int macInSz  = 0;
-    int ivExtra  = 0;
-    int digestSz = wolfSSL_GetHmacSize(ssl);
-    unsigned int pad     = 0;
-    unsigned int padByte = 0;
-    Hmac hmac;
-    byte myInner[WOLFSSL_TLS_HMAC_INNER_SZ];
-    byte verify[MAX_DIGEST_SIZE];
-    const char* tlsStr = "TLS";
-
-    /* example supports (d)tls aes */
-    if (wolfSSL_GetBulkCipher(ssl) != wolfssl_aes) {
-        printf("myMacEncryptCb not using AES\n");
-        return -1;
-    }
-
-    if (strstr(wolfSSL_get_version(ssl), tlsStr) == NULL) {
-        printf("myMacEncryptCb not using (D)TLS\n");
-        return -1;
-    }
-
-    /*decrypt */
-    if (decCtx->keySetup == 0) {
-        int   keyLen = wolfSSL_GetKeySize(ssl);
-        const byte* key;
-        const byte* iv;
-
-        /* decrypt is from other side (peer) */
-        if (wolfSSL_GetSide(ssl) == WOLFSSL_SERVER_END) {
-            key = wolfSSL_GetClientWriteKey(ssl);
-            iv  = wolfSSL_GetClientWriteIV(ssl);
-        }
-        else {
-            key = wolfSSL_GetServerWriteKey(ssl);
-            iv  = wolfSSL_GetServerWriteIV(ssl);
-        }
-
-        ret = wc_AesSetKey(&decCtx->aes, key, keyLen, iv, AES_DECRYPTION);
-        if (ret != 0) {
-            printf("AesSetKey failed in myDecryptVerifyCb\n");
-            return ret;
-        }
-        decCtx->keySetup = 1;
-    }
-
-    /* decrypt */
-    ret = wc_AesCbcDecrypt(&decCtx->aes, decOut, decIn, decSz);
-
-    if (wolfSSL_GetCipherType(ssl) == WOLFSSL_AEAD_TYPE) {
-        *padSz = wolfSSL_GetAeadMacSize(ssl);
-        return 0; /* hmac, not needed if aead mode */
-    }
-
-    if (wolfSSL_GetCipherType(ssl) == WOLFSSL_BLOCK_TYPE) {
-        pad     = *(decOut + decSz - 1);
-        padByte = 1;
-        if (wolfSSL_IsTLSv1_1(ssl))
-            ivExtra = wolfSSL_GetCipherBlockSize(ssl);
-    }
-
-    *padSz  = wolfSSL_GetHmacSize(ssl) + pad + padByte;
-    macInSz = decSz - ivExtra - digestSz - pad - padByte;
-
-    wolfSSL_SetTlsHmacInner(ssl, myInner, macInSz, macContent, macVerify);
-
-    ret = wc_HmacSetKey(&hmac, wolfSSL_GetHmacType(ssl),
-               wolfSSL_GetMacSecret(ssl, macVerify), digestSz);
-    if (ret != 0)
-        return ret;
-    ret = wc_HmacUpdate(&hmac, myInner, sizeof(myInner));
-    if (ret != 0)
-        return ret;
-    ret = wc_HmacUpdate(&hmac, decOut + ivExtra, macInSz);
-    if (ret != 0)
-        return ret;
-    ret = wc_HmacFinal(&hmac, verify);
-    if (ret != 0)
-        return ret;
-
-    if (memcmp(verify, decOut + decSz - digestSz - pad - padByte,
-               digestSz) != 0) {
-        printf("myDecryptVerify verify failed\n");
-        return -1;
-    }
-
-    return ret;
-}
-
-
-static INLINE void SetupAtomicUser(WOLFSSL_CTX* ctx, WOLFSSL* ssl)
-{
-    AtomicEncCtx* encCtx;
-    AtomicDecCtx* decCtx;
-
-    encCtx = (AtomicEncCtx*)malloc(sizeof(AtomicEncCtx));
-    if (encCtx == NULL)
-        err_sys("AtomicEncCtx malloc failed");
-    memset(encCtx, 0, sizeof(AtomicEncCtx));
-
-    decCtx = (AtomicDecCtx*)malloc(sizeof(AtomicDecCtx));
-    if (decCtx == NULL) {
-        free(encCtx);
-        err_sys("AtomicDecCtx malloc failed");
-    }
-    memset(decCtx, 0, sizeof(AtomicDecCtx));
-
-    wolfSSL_CTX_SetMacEncryptCb(ctx, myMacEncryptCb);
-    wolfSSL_SetMacEncryptCtx(ssl, encCtx);
-
-    wolfSSL_CTX_SetDecryptVerifyCb(ctx, myDecryptVerifyCb);
-    wolfSSL_SetDecryptVerifyCtx(ssl, decCtx);
-}
-
-
-static INLINE void FreeAtomicUser(WOLFSSL* ssl)
-{
-    AtomicEncCtx* encCtx = (AtomicEncCtx*)wolfSSL_GetMacEncryptCtx(ssl);
-    AtomicDecCtx* decCtx = (AtomicDecCtx*)wolfSSL_GetDecryptVerifyCtx(ssl);
-
-    free(decCtx);
-    free(encCtx);
-}
-
-#endif /* ATOMIC_USER */
-
-
-#ifdef HAVE_PK_CALLBACKS
-
-#ifdef HAVE_ECC
-
-static INLINE int myEccSign(WOLFSSL* ssl, const byte* in, word32 inSz,
-        byte* out, word32* outSz, const byte* key, word32 keySz, void* ctx)
-{
-    RNG     rng;
-    int     ret;
-    word32  idx = 0;
-    ecc_key myKey;
-
-    (void)ssl;
-    (void)ctx;
-
-    ret = wc_InitRng(&rng);
-    if (ret != 0)
-        return ret;
-
-    wc_ecc_init(&myKey);
-    
-    ret = wc_EccPrivateKeyDecode(key, &idx, &myKey, keySz);    
-    if (ret == 0)
-        ret = wc_ecc_sign_hash(in, inSz, out, outSz, &rng, &myKey);
-    wc_ecc_free(&myKey);
-    wc_FreeRng(&rng);
-
-    return ret;
-}
-
-
-static INLINE int myEccVerify(WOLFSSL* ssl, const byte* sig, word32 sigSz,
-        const byte* hash, word32 hashSz, const byte* key, word32 keySz,
-        int* result, void* ctx)
-{
-    int     ret;
-    ecc_key myKey;
-
-    (void)ssl;
-    (void)ctx;
-
-    wc_ecc_init(&myKey);
-    
-    ret = wc_ecc_import_x963(key, keySz, &myKey);
-    if (ret == 0)
-        ret = wc_ecc_verify_hash(sig, sigSz, hash, hashSz, result, &myKey);
-    wc_ecc_free(&myKey);
-
-    return ret;
-}
-
-#endif /* HAVE_ECC */
-
-#ifndef NO_RSA
-
-static INLINE int myRsaSign(WOLFSSL* ssl, const byte* in, word32 inSz,
-        byte* out, word32* outSz, const byte* key, word32 keySz, void* ctx)
-{
-    RNG     rng;
-    int     ret;
-    word32  idx = 0;
-    RsaKey  myKey;
-
-    (void)ssl;
-    (void)ctx;
-
-    ret = wc_InitRng(&rng);
-    if (ret != 0)
-        return ret;
-
-    wc_InitRsaKey(&myKey, NULL);
-    
-    ret = wc_RsaPrivateKeyDecode(key, &idx, &myKey, keySz);    
-    if (ret == 0)
-        ret = wc_RsaSSL_Sign(in, inSz, out, *outSz, &myKey, &rng);
-    if (ret > 0) {  /* save and convert to 0 success */
-        *outSz = ret;
-        ret = 0;
-    }
-    wc_FreeRsaKey(&myKey);
-    wc_FreeRng(&rng);
-
-    return ret;
-}
-
-
-static INLINE int myRsaVerify(WOLFSSL* ssl, byte* sig, word32 sigSz,
-        byte** out,
-        const byte* key, word32 keySz,
-        void* ctx)
-{
-    int     ret;
-    word32  idx = 0;
-    RsaKey  myKey;
-
-    (void)ssl;
-    (void)ctx;
-
-    wc_InitRsaKey(&myKey, NULL);
-
-    ret = wc_RsaPublicKeyDecode(key, &idx, &myKey, keySz);
-    if (ret == 0)
-        ret = wc_RsaSSL_VerifyInline(sig, sigSz, out, &myKey);
-    wc_FreeRsaKey(&myKey);
-
-    return ret;
-}
-
-
-static INLINE int myRsaEnc(WOLFSSL* ssl, const byte* in, word32 inSz,
-                           byte* out, word32* outSz, const byte* key,
-                           word32 keySz, void* ctx)
-{
-    int     ret;
-    word32  idx = 0;
-    RsaKey  myKey;
-    RNG     rng;
-
-    (void)ssl;
-    (void)ctx;
-
-    ret = wc_InitRng(&rng);
-    if (ret != 0)
-        return ret;
-
-    wc_InitRsaKey(&myKey, NULL);
-    
-    ret = wc_RsaPublicKeyDecode(key, &idx, &myKey, keySz);
-    if (ret == 0) {
-        ret = wc_RsaPublicEncrypt(in, inSz, out, *outSz, &myKey, &rng);
-        if (ret > 0) {
-            *outSz = ret;
-            ret = 0;  /* reset to success */
-        }
-    }
-    wc_FreeRsaKey(&myKey);
-    wc_FreeRng(&rng);
-
-    return ret;
-}
-
-static INLINE int myRsaDec(WOLFSSL* ssl, byte* in, word32 inSz,
-                           byte** out,
-                           const byte* key, word32 keySz, void* ctx)
-{
-    int     ret;
-    word32  idx = 0;
-    RsaKey  myKey;
-
-    (void)ssl;
-    (void)ctx;
-
-    wc_InitRsaKey(&myKey, NULL);
-
-    ret = wc_RsaPrivateKeyDecode(key, &idx, &myKey, keySz);
-    if (ret == 0) {
-        ret = wc_RsaPrivateDecryptInline(in, inSz, out, &myKey);
-    }
-    wc_FreeRsaKey(&myKey);
-
-    return ret;
-}
-
-#endif /* NO_RSA */
-
-static INLINE void SetupPkCallbacks(WOLFSSL_CTX* ctx, WOLFSSL* ssl)
-{
-    (void)ctx;
-    (void)ssl;
-
-    #ifdef HAVE_ECC
-        wolfSSL_CTX_SetEccSignCb(ctx, myEccSign);
-        wolfSSL_CTX_SetEccVerifyCb(ctx, myEccVerify);
-    #endif /* HAVE_ECC */
-    #ifndef NO_RSA 
-        wolfSSL_CTX_SetRsaSignCb(ctx, myRsaSign);
-        wolfSSL_CTX_SetRsaVerifyCb(ctx, myRsaVerify);
-        wolfSSL_CTX_SetRsaEncCb(ctx, myRsaEnc);
-        wolfSSL_CTX_SetRsaDecCb(ctx, myRsaDec);
-    #endif /* NO_RSA */
-}
-
-#endif /* HAVE_PK_CALLBACKS */
-
-
-
-
-
-#if defined(__hpux__) || defined(__MINGW32__) || defined (WOLFSSL_TIRTOS) \
-                      || defined(_MSC_VER)
-
-/* HP/UX doesn't have strsep, needed by test/suites.c */
-static INLINE char* strsep(char **stringp, const char *delim)
-{
-    char* start;
-    char* end;
-
-    start = *stringp;
-    if (start == NULL)
-        return NULL;
-
-    if ((end = strpbrk(start, delim))) {
-        *end++ = '\0';
-        *stringp = end;
-    } else {
-        *stringp = NULL;
-    }
-
-    return start;
-}
-
-#endif /* __hpux__ and others */
-
-/* Create unique filename, len is length of tempfn name, assuming
-   len does not include null terminating character,
-   num is number of characters in tempfn name to randomize */
-static INLINE const char* mymktemp(char *tempfn, int len, int num)
-{
-    int x, size;
-    static const char alphanum[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                                   "abcdefghijklmnopqrstuvwxyz";
-    RNG rng;
-    byte out;
-
-    if (tempfn == NULL || len < 1 || num < 1 || len <= num) {
-        printf("Bad input\n");
-        return NULL;
-    }
-
-    size = len - 1;
-
-    if (wc_InitRng(&rng) != 0) {
-        printf("InitRng failed\n");
-        return NULL;
-    }
-
-    for (x = size; x > size - num; x--) {
-        if (wc_RNG_GenerateBlock(&rng,(byte*)&out, sizeof(out)) != 0) {
-            printf("RNG_GenerateBlock failed\n");
-            return NULL;
-        }
-        tempfn[x] = alphanum[out % (sizeof(alphanum) - 1)];
-    }
-    tempfn[len] = '\0';
-
-    wc_FreeRng(&rng);
-
-    return tempfn;
-}
-
-
-
-#if defined(HAVE_SESSION_TICKET) && defined(HAVE_CHACHA) && \
-                                    defined(HAVE_POLY1305)
-
-    #include 
-
-    typedef struct key_ctx {
-        byte name[WOLFSSL_TICKET_NAME_SZ];     /* name for this context */
-        byte key[16];                          /* cipher key */
-    } key_ctx;
-
-    static key_ctx myKey_ctx;
-    static RNG rng;
-
-    static INLINE int TicketInit(void)
-    {
-        int ret = wc_InitRng(&rng);
-        if (ret != 0) return ret;
-
-        ret = wc_RNG_GenerateBlock(&rng, myKey_ctx.key, sizeof(myKey_ctx.key));
-        if (ret != 0) return ret;
-
-        ret = wc_RNG_GenerateBlock(&rng, myKey_ctx.name,sizeof(myKey_ctx.name));
-        if (ret != 0) return ret;
-
-        return 0;
-    }
-
-    static INLINE void TicketCleanup(void)
-    {
-        wc_FreeRng(&rng);
-    }
-
-    static INLINE int myTicketEncCb(WOLFSSL* ssl,
-                             byte key_name[WOLFSSL_TICKET_NAME_SZ],
-                             byte iv[WOLFSSL_TICKET_IV_SZ],
-                             byte mac[WOLFSSL_TICKET_MAC_SZ],
-                             int enc, byte* ticket, int inLen, int* outLen,
-                             void* userCtx)
-    {
-        (void)ssl;
-        (void)userCtx;
-
-        int ret;
-        word16 sLen = htons(inLen);
-        byte aad[WOLFSSL_TICKET_NAME_SZ + WOLFSSL_TICKET_IV_SZ + 2];
-        int  aadSz = WOLFSSL_TICKET_NAME_SZ + WOLFSSL_TICKET_IV_SZ + 2;
-        byte* tmp = aad;
-
-        if (enc) {
-            XMEMCPY(key_name, myKey_ctx.name, WOLFSSL_TICKET_NAME_SZ);
-
-            ret = wc_RNG_GenerateBlock(&rng, iv, WOLFSSL_TICKET_IV_SZ);
-            if (ret != 0) return WOLFSSL_TICKET_RET_REJECT;
-
-            /* build aad from key name, iv, and length */
-            XMEMCPY(tmp, key_name, WOLFSSL_TICKET_NAME_SZ);
-            tmp += WOLFSSL_TICKET_NAME_SZ;
-            XMEMCPY(tmp, iv, WOLFSSL_TICKET_IV_SZ);
-            tmp += WOLFSSL_TICKET_IV_SZ;
-            XMEMCPY(tmp, &sLen, 2);
-
-            ret = wc_ChaCha20Poly1305_Encrypt(myKey_ctx.key, iv,
-                                              aad, aadSz,
-                                              ticket, inLen,
-                                              ticket,
-                                              mac);
-            if (ret != 0) return WOLFSSL_TICKET_RET_REJECT;
-            *outLen = inLen;  /* no padding in this mode */
-        } else {
-            /* decrypt */
-
-            /* see if we know this key */
-            if (XMEMCMP(key_name, myKey_ctx.name, WOLFSSL_TICKET_NAME_SZ) != 0){
-                printf("client presented unknown ticket key name ");
-                return WOLFSSL_TICKET_RET_FATAL;
-            }
-
-            /* build aad from key name, iv, and length */
-            XMEMCPY(tmp, key_name, WOLFSSL_TICKET_NAME_SZ);
-            tmp += WOLFSSL_TICKET_NAME_SZ;
-            XMEMCPY(tmp, iv, WOLFSSL_TICKET_IV_SZ);
-            tmp += WOLFSSL_TICKET_IV_SZ;
-            XMEMCPY(tmp, &sLen, 2);
-
-            ret = wc_ChaCha20Poly1305_Decrypt(myKey_ctx.key, iv,
-                                              aad, aadSz,
-                                              ticket, inLen,
-                                              mac,
-                                              ticket);
-            if (ret != 0) return WOLFSSL_TICKET_RET_REJECT;
-            *outLen = inLen;  /* no padding in this mode */
-        }
-
-        return WOLFSSL_TICKET_RET_OK;
-    }
-
-#endif  /* HAVE_SESSION_TICKET && CHACHA20 && POLY1305 */
-
-#endif /* wolfSSL_TEST_H */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/version.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/version.h
deleted file mode 100755
index b163a0a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/version.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* wolfssl_version.h.in
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define LIBWOLFSSL_VERSION_STRING "3.6.0"
-#define LIBWOLFSSL_VERSION_HEX 0x03006000
-
-#ifdef __cplusplus
-}
-#endif
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/version.h.in b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/version.h.in
deleted file mode 100755
index 966ff5a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/version.h.in
+++ /dev/null
@@ -1,35 +0,0 @@
-/* wolfssl_version.h.in
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define LIBWOLFSSL_VERSION_STRING "@VERSION@"
-#define LIBWOLFSSL_VERSION_HEX @HEX_VERSION@
-
-#ifdef __cplusplus
-}
-#endif
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/aes.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/aes.h
deleted file mode 100755
index a94ad08..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/aes.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/* aes.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_AES_H
-#define WOLF_CRYPT_AES_H
-
-#include 
-
-#ifndef NO_AES
-
-/* included for fips @wc_fips */
-#ifdef HAVE_FIPS
-#include 
-#if defined(CYASSL_AES_COUNTER) && !defined(WOLFSSL_AES_COUNTER)
-    #define WOLFSSL_AES_COUNTER
-#endif
-#if !defined(WOLFSSL_AES_DIRECT) && defined(CYASSL_AES_DIRECT)
-    #define WOLFSSL_AES_DIRECT
-#endif
-#endif
-
-#ifndef HAVE_FIPS /* to avoid redefinition of macros */
-#ifdef HAVE_CAVIUM
-    #include 
-    #include "cavium_common.h"
-#endif
-
-#ifdef WOLFSSL_AESNI
-
-#include 
-
-#if !defined (ALIGN16)
-    #if defined (__GNUC__)
-        #define ALIGN16 __attribute__ ( (aligned (16)))
-    #elif defined(_MSC_VER)
-        /* disable align warning, we want alignment ! */
-        #pragma warning(disable: 4324)
-        #define ALIGN16 __declspec (align (16))
-    #else
-        #define ALIGN16
-    #endif
-#endif
-
-#endif /* WOLFSSL_AESNI */
-
-#if !defined (ALIGN16)
-    #define ALIGN16
-#endif
-#endif /* HAVE_FIPS */
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-#ifndef HAVE_FIPS /* to avoid redefinition of structures */
-#define WOLFSSL_AES_CAVIUM_MAGIC 0xBEEF0002
-
-enum {
-    AES_ENC_TYPE   = 1,   /* cipher unique type */
-    AES_ENCRYPTION = 0,
-    AES_DECRYPTION = 1,
-    AES_BLOCK_SIZE = 16
-};
-
-
-typedef struct Aes {
-    /* AESNI needs key first, rounds 2nd, not sure why yet */
-    ALIGN16 word32 key[60];
-    word32  rounds;
-
-    ALIGN16 word32 reg[AES_BLOCK_SIZE / sizeof(word32)];      /* for CBC mode */
-    ALIGN16 word32 tmp[AES_BLOCK_SIZE / sizeof(word32)];      /* same         */
-
-#ifdef HAVE_AESGCM
-    ALIGN16 byte H[AES_BLOCK_SIZE];
-#ifdef GCM_TABLE
-    /* key-based fast multiplication table. */
-    ALIGN16 byte M0[256][AES_BLOCK_SIZE];
-#endif /* GCM_TABLE */
-#endif /* HAVE_AESGCM */
-#ifdef WOLFSSL_AESNI
-    byte use_aesni;
-#endif /* WOLFSSL_AESNI */
-#ifdef HAVE_CAVIUM
-    AesType type;            /* aes key type */
-    int     devId;           /* nitrox device id */
-    word32  magic;           /* using cavium magic */
-    word64  contextHandle;   /* nitrox context memory handle */
-#endif
-#ifdef WOLFSSL_AES_COUNTER
-    word32  left;            /* unsued bytes left from last call */
-#endif
-#ifdef WOLFSSL_PIC32MZ_CRYPT
-    word32 key_ce[AES_BLOCK_SIZE*2/sizeof(word32)] ;
-    word32 iv_ce [AES_BLOCK_SIZE  /sizeof(word32)] ;
-    int    keylen ;
-#endif
-#ifdef WOLFSSL_TI_CRYPT
-    int    keylen ;
-#endif
-} Aes;
-
-
-#ifdef HAVE_AESGCM
-typedef struct Gmac {
-    Aes aes;
-} Gmac;
-#endif /* HAVE_AESGCM */
-#endif /* HAVE_FIPS */
-
- WOLFSSL_API int  wc_AesSetKey(Aes* aes, const byte* key, word32 len, const byte* iv,
-                          int dir);
- WOLFSSL_API int  wc_AesSetIV(Aes* aes, const byte* iv);
- WOLFSSL_API int  wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
- WOLFSSL_API int  wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz);
- WOLFSSL_API int  wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
-                                 const byte* key, word32 keySz, const byte* iv);
-
-/* AES-CTR */
-#ifdef WOLFSSL_AES_COUNTER
- WOLFSSL_API void wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
-#endif
-/* AES-DIRECT */
-#if defined(WOLFSSL_AES_DIRECT)
- WOLFSSL_API void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in);
- WOLFSSL_API void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in);
- WOLFSSL_API int  wc_AesSetKeyDirect(Aes* aes, const byte* key, word32 len,
-                                const byte* iv, int dir);
-#endif
-#ifdef HAVE_AESGCM
- WOLFSSL_API int  wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len);
- WOLFSSL_API int  wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
-                              const byte* iv, word32 ivSz,
-                              byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz);
- WOLFSSL_API int  wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
-                              const byte* iv, word32 ivSz,
-                              const byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz);
-
- WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len);
- WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
-                              const byte* authIn, word32 authInSz,
-                              byte* authTag, word32 authTagSz);
-#endif /* HAVE_AESGCM */
-#ifdef HAVE_AESCCM
- WOLFSSL_API void wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz);
- WOLFSSL_API void wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
-                              const byte* nonce, word32 nonceSz,
-                              byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz);
- WOLFSSL_API int  wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
-                              const byte* nonce, word32 nonceSz,
-                              const byte* authTag, word32 authTagSz,
-                              const byte* authIn, word32 authInSz);
-#endif /* HAVE_AESCCM */
-
-#ifdef HAVE_CAVIUM
-     WOLFSSL_API int  wc_AesInitCavium(Aes*, int);
-     WOLFSSL_API void wc_AesFreeCavium(Aes*);
-#endif
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-
-#endif /* NO_AES */
-#endif /* WOLF_CRYPT_AES_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/arc4.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/arc4.h
deleted file mode 100755
index 727b627..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/arc4.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* arc4.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLF_CRYPT_ARC4_H
-#define WOLF_CRYPT_ARC4_H
-
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-#define WOLFSSL_ARC4_CAVIUM_MAGIC 0xBEEF0001
-
-enum {
-	ARC4_ENC_TYPE   = 4,    /* cipher unique type */
-    ARC4_STATE_SIZE = 256
-};
-
-/* ARC4 encryption and decryption */
-typedef struct Arc4 {
-    byte x;
-    byte y;
-    byte state[ARC4_STATE_SIZE];
-#ifdef HAVE_CAVIUM
-    int    devId;           /* nitrox device id */
-    word32 magic;           /* using cavium magic */
-    word64 contextHandle;   /* nitrox context memory handle */
-#endif
-} Arc4;
-
-WOLFSSL_API void wc_Arc4Process(Arc4*, byte*, const byte*, word32);
-WOLFSSL_API void wc_Arc4SetKey(Arc4*, const byte*, word32);
-
-#ifdef HAVE_CAVIUM
-    WOLFSSL_API int  wc_Arc4InitCavium(Arc4*, int);
-    WOLFSSL_API void wc_Arc4FreeCavium(Arc4*);
-#endif
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-
-#endif /* WOLF_CRYPT_ARC4_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/asn.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/asn.h
deleted file mode 100755
index 10d0943..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/asn.h
+++ /dev/null
@@ -1,742 +0,0 @@
-/* asn.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_ASN_H
-#define WOLF_CRYPT_ASN_H
-
-#include 
-
-#ifndef NO_ASN
-
-#include 
-#ifndef NO_RSA
-    #include 
-#endif
-
-/* fips declare of RsaPrivateKeyDecode @wc_fips */
-#if defined(HAVE_FIPS) && !defined(NO_RSA)
-    #include 
-#endif
-
-#ifndef NO_DH
-    #include 
-#endif
-#ifndef NO_DSA
-    #include 
-#endif
-#ifndef NO_SHA
-    #include 
-#endif
-#ifndef NO_MD5
-    #include 
-#endif
-#include 
-#include    /* public interface */
-#ifdef HAVE_ECC
-    #include 
-#endif
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-enum {
-    ISSUER  = 0,
-    SUBJECT = 1,
-
-    EXTERNAL_SERIAL_SIZE = 32,
-
-    BEFORE  = 0,
-    AFTER   = 1
-};
-
-/* ASN Tags   */
-enum ASN_Tags {
-    ASN_BOOLEAN           = 0x01,
-    ASN_INTEGER           = 0x02,
-    ASN_BIT_STRING        = 0x03,
-    ASN_OCTET_STRING      = 0x04,
-    ASN_TAG_NULL          = 0x05,
-    ASN_OBJECT_ID         = 0x06,
-    ASN_ENUMERATED        = 0x0a,
-    ASN_UTF8STRING        = 0x0c,
-    ASN_SEQUENCE          = 0x10,
-    ASN_SET               = 0x11,
-    ASN_UTC_TIME          = 0x17,
-    ASN_OTHER_TYPE        = 0x00,
-    ASN_RFC822_TYPE       = 0x01,
-    ASN_DNS_TYPE          = 0x02,
-    ASN_DIR_TYPE          = 0x04,
-    ASN_GENERALIZED_TIME  = 0x18,
-    CRL_EXTENSIONS        = 0xa0,
-    ASN_EXTENSIONS        = 0xa3,
-    ASN_LONG_LENGTH       = 0x80
-};
-
-enum  ASN_Flags{
-    ASN_CONSTRUCTED       = 0x20,
-    ASN_CONTEXT_SPECIFIC  = 0x80
-};
-
-enum DN_Tags {
-    ASN_COMMON_NAME   = 0x03,   /* CN */
-    ASN_SUR_NAME      = 0x04,   /* SN */
-    ASN_SERIAL_NUMBER = 0x05,   /* serialNumber */
-    ASN_COUNTRY_NAME  = 0x06,   /* C  */
-    ASN_LOCALITY_NAME = 0x07,   /* L  */
-    ASN_STATE_NAME    = 0x08,   /* ST */
-    ASN_ORG_NAME      = 0x0a,   /* O  */
-    ASN_ORGUNIT_NAME  = 0x0b    /* OU */
-};
-
-enum PBES {
-    PBE_MD5_DES      = 0,
-    PBE_SHA1_DES     = 1,
-    PBE_SHA1_DES3    = 2,
-    PBE_SHA1_RC4_128 = 3,
-    PBES2            = 13       /* algo ID */
-};
-
-enum ENCRYPTION_TYPES {
-    DES_TYPE  = 0,
-    DES3_TYPE = 1,
-    RC4_TYPE  = 2
-};
-
-enum ECC_TYPES {
-    ECC_PREFIX_0 = 160,
-    ECC_PREFIX_1 = 161
-};
-
-enum Misc_ASN {
-    ASN_NAME_MAX        = 256,
-    MAX_SALT_SIZE       =  64,     /* MAX PKCS Salt length */
-    MAX_IV_SIZE         =  64,     /* MAX PKCS Iv length */
-    MAX_KEY_SIZE        =  64,     /* MAX PKCS Key  length */
-    PKCS5               =   5,     /* PKCS oid tag */
-    PKCS5v2             =   6,     /* PKCS #5 v2.0 */
-    PKCS12              =  12,     /* PKCS #12 */
-    MAX_UNICODE_SZ      = 256,
-    ASN_BOOL_SIZE       =   2,     /* including type */
-    ASN_ECC_HEADER_SZ   =   2,     /* String type + 1 byte len */
-    ASN_ECC_CONTEXT_SZ  =   2,     /* Content specific type + 1 byte len */
-#ifdef NO_SHA
-    KEYID_SIZE          = SHA256_DIGEST_SIZE,
-#else
-    KEYID_SIZE          = SHA_DIGEST_SIZE,
-#endif
-    RSA_INTS            =   8,     /* RSA ints in private key */
-    MIN_DATE_SIZE       =  13,
-    MAX_DATE_SIZE       =  32,
-    ASN_GEN_TIME_SZ     =  15,     /* 7 numbers * 2 + Zulu tag */
-    MAX_ENCODED_SIG_SZ  = 512,
-    MAX_SIG_SZ          = 256,
-    MAX_ALGO_SZ         =  20,
-    MAX_SEQ_SZ          =   5,     /* enum(seq | con) + length(4) */
-    MAX_SET_SZ          =   5,     /* enum(set | con) + length(4) */
-    MAX_OCTET_STR_SZ    =   5,     /* enum(set | con) + length(4) */
-    MAX_EXP_SZ          =   5,     /* enum(contextspec|con|exp) + length(4) */
-    MAX_PRSTR_SZ        =   5,     /* enum(prstr) + length(4) */
-    MAX_VERSION_SZ      =   5,     /* enum + id + version(byte) + (header(2))*/
-    MAX_ENCODED_DIG_SZ  =  73,     /* sha512 + enum(bit or octet) + legnth(4) */
-    MAX_RSA_INT_SZ      = 517,     /* RSA raw sz 4096 for bits + tag + len(4) */
-    MAX_NTRU_KEY_SZ     = 610,     /* NTRU 112 bit public key */
-    MAX_NTRU_ENC_SZ     = 628,     /* NTRU 112 bit DER public encoding */
-    MAX_LENGTH_SZ       =   4,     /* Max length size for DER encoding */
-    MAX_RSA_E_SZ        =  16,     /* Max RSA public e size */
-    MAX_CA_SZ           =  32,     /* Max encoded CA basic constraint length */
-    MAX_SN_SZ           =  35,     /* Max encoded serial number (INT) length */
-#ifdef WOLFSSL_CERT_GEN
-    #ifdef WOLFSSL_CERT_REQ
-                          /* Max encoded cert req attributes length */
-        MAX_ATTRIB_SZ   = MAX_SEQ_SZ * 3 + (11 + MAX_SEQ_SZ) * 2 +
-                          MAX_PRSTR_SZ + CTC_NAME_SIZE, /* 11 is the OID size */
-    #endif
-    #ifdef WOLFSSL_ALT_NAMES
-        MAX_EXTENSIONS_SZ   = 1 + MAX_LENGTH_SZ + CTC_MAX_ALT_SIZE,
-    #else
-        MAX_EXTENSIONS_SZ   = 1 + MAX_LENGTH_SZ + MAX_CA_SZ,
-    #endif
-                                   /* Max total extensions, id + len + others */
-#endif
-    MAX_OCSP_EXT_SZ     = 58,      /* Max OCSP Extension length */
-    MAX_OCSP_NONCE_SZ   = 18,      /* OCSP Nonce size           */
-    EIGHTK_BUF          = 8192,    /* Tmp buffer size           */
-    MAX_PUBLIC_KEY_SZ   = MAX_NTRU_ENC_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ * 2
-                                   /* use bigger NTRU size */
-};
-
-
-enum Oid_Types {
-    hashType  = 0,
-    sigType   = 1,
-    keyType   = 2,
-    curveType = 3,
-    blkType   = 4
-};
-
-
-enum Hash_Sum  {
-    MD2h    = 646,
-    MD5h    = 649,
-    SHAh    =  88,
-    SHA256h = 414,
-    SHA384h = 415,
-    SHA512h = 416
-};
-
-
-enum Block_Sum {
-    DESb  = 69,
-    DES3b = 652
-};
-
-
-enum Key_Sum {
-    DSAk   = 515,
-    RSAk   = 645,
-    NTRUk  = 274,
-    ECDSAk = 518
-};
-
-
-enum Ecc_Sum {
-    ECC_256R1 = 526,
-    ECC_384R1 = 210,
-    ECC_521R1 = 211,
-    ECC_160R1 = 184,
-    ECC_192R1 = 520,
-    ECC_224R1 = 209
-};
-
-
-enum KDF_Sum {
-    PBKDF2_OID = 660
-};
-
-
-enum Extensions_Sum {
-    BASIC_CA_OID    = 133,
-    ALT_NAMES_OID   = 131,
-    CRL_DIST_OID    = 145,
-    AUTH_INFO_OID   = 69,
-    CA_ISSUER_OID   = 117,
-    AUTH_KEY_OID    = 149,
-    SUBJ_KEY_OID    = 128,
-    CERT_POLICY_OID = 146,
-    KEY_USAGE_OID   = 129,  /* 2.5.29.15 */
-    INHIBIT_ANY_OID = 168,  /* 2.5.29.54 */
-    EXT_KEY_USAGE_OID = 151, /* 2.5.29.37 */
-    NAME_CONS_OID   = 144   /* 2.5.29.30 */
-};
-
-enum CertificatePolicy_Sum {
-    CP_ANY_OID      = 146  /* id-ce 32 0 */
-};
-
-enum SepHardwareName_Sum {
-    HW_NAME_OID     = 79   /* 1.3.6.1.5.5.7.8.4 from RFC 4108*/
-};
-
-enum AuthInfo_Sum {
-    AIA_OCSP_OID      = 116, /* 1.3.6.1.5.5.7.48.1 */
-    AIA_CA_ISSUER_OID = 117  /* 1.3.6.1.5.5.7.48.2 */
-};
-
-enum ExtKeyUsage_Sum { /* From RFC 5280 */
-    EKU_ANY_OID         = 151, /* 2.5.29.37.0, anyExtendedKeyUsage         */
-    EKU_SERVER_AUTH_OID = 71,  /* 1.3.6.1.5.5.7.3.1, id-kp-serverAuth      */
-    EKU_CLIENT_AUTH_OID = 72,  /* 1.3.6.1.5.5.7.3.2, id-kp-clientAuth      */
-    EKU_OCSP_SIGN_OID   = 79   /* 1.3.6.1.5.5.7.3.9, OCSPSigning           */
-};
-
-
-enum VerifyType {
-    NO_VERIFY = 0,
-    VERIFY    = 1
-};
-
-
-/* Key usage extension bits */
-#define KEYUSE_DIGITAL_SIG    0x0100
-#define KEYUSE_CONTENT_COMMIT 0x0080
-#define KEYUSE_KEY_ENCIPHER   0x0040
-#define KEYUSE_DATA_ENCIPHER  0x0020
-#define KEYUSE_KEY_AGREE      0x0010
-#define KEYUSE_KEY_CERT_SIGN  0x0008
-#define KEYUSE_CRL_SIGN       0x0004
-#define KEYUSE_ENCIPHER_ONLY  0x0002
-#define KEYUSE_DECIPHER_ONLY  0x0001
-
-#define EXTKEYUSE_ANY         0x08
-#define EXTKEYUSE_OCSP_SIGN   0x04
-#define EXTKEYUSE_CLIENT_AUTH 0x02
-#define EXTKEYUSE_SERVER_AUTH 0x01
-
-typedef struct DNS_entry   DNS_entry;
-
-struct DNS_entry {
-    DNS_entry* next;   /* next on DNS list */
-    char*      name;   /* actual DNS name */
-};
-
-
-typedef struct Base_entry  Base_entry;
-
-struct Base_entry {
-    Base_entry* next;   /* next on name base list */
-    char*       name;   /* actual name base */
-    int         nameSz; /* name length */
-    byte        type;   /* Name base type (DNS or RFC822) */
-};
-
-
-struct DecodedName {
-    char*   fullName;
-    int     fullNameLen;
-    int     entryCount;
-    int     cnIdx;
-    int     cnLen;
-    int     snIdx;
-    int     snLen;
-    int     cIdx;
-    int     cLen;
-    int     lIdx;
-    int     lLen;
-    int     stIdx;
-    int     stLen;
-    int     oIdx;
-    int     oLen;
-    int     ouIdx;
-    int     ouLen;
-    int     emailIdx;
-    int     emailLen;
-    int     uidIdx;
-    int     uidLen;
-    int     serialIdx;
-    int     serialLen;
-};
-
-
-typedef struct DecodedCert DecodedCert;
-typedef struct DecodedName DecodedName;
-typedef struct Signer      Signer;
-
-
-struct DecodedCert {
-    byte*   publicKey;
-    word32  pubKeySize;
-    int     pubKeyStored;
-    word32  certBegin;               /* offset to start of cert          */
-    word32  sigIndex;                /* offset to start of signature     */
-    word32  sigLength;               /* length of signature              */
-    word32  signatureOID;            /* sum of algorithm object id       */
-    word32  keyOID;                  /* sum of key algo  object id       */
-    int     version;                 /* cert version, 1 or 3             */
-    DNS_entry* altNames;             /* alt names list of dns entries    */
-#ifndef IGNORE_NAME_CONSTRAINTS
-    DNS_entry* altEmailNames;        /* alt names list of RFC822 entries */
-    Base_entry* permittedNames;      /* Permitted name bases             */
-    Base_entry* excludedNames;       /* Excluded name bases              */
-#endif /* IGNORE_NAME_CONSTRAINTS */
-    byte    subjectHash[KEYID_SIZE]; /* hash of all Names                */
-    byte    issuerHash[KEYID_SIZE];  /* hash of all Names                */
-#ifdef HAVE_OCSP
-    byte    issuerKeyHash[KEYID_SIZE]; /* hash of the public Key         */
-#endif /* HAVE_OCSP */
-    byte*   signature;               /* not owned, points into raw cert  */
-    char*   subjectCN;               /* CommonName                       */
-    int     subjectCNLen;            /* CommonName Length                */
-    char    subjectCNEnc;            /* CommonName Encoding              */
-    int     subjectCNStored;         /* have we saved a copy we own      */
-    char    issuer[ASN_NAME_MAX];    /* full name including common name  */
-    char    subject[ASN_NAME_MAX];   /* full name including common name  */
-    int     verify;                  /* Default to yes, but could be off */
-    byte*   source;                  /* byte buffer holder cert, NOT owner */
-    word32  srcIdx;                  /* current offset into buffer       */
-    word32  maxIdx;                  /* max offset based on init size    */
-    void*   heap;                    /* for user memory overrides        */
-    byte    serial[EXTERNAL_SERIAL_SIZE];  /* raw serial number          */
-    int     serialSz;                /* raw serial bytes stored */
-    byte*   extensions;              /* not owned, points into raw cert  */
-    int     extensionsSz;            /* length of cert extensions */
-    word32  extensionsIdx;           /* if want to go back and parse later */
-    byte*   extAuthInfo;             /* Authority Information Access URI */
-    int     extAuthInfoSz;           /* length of the URI                */
-    byte*   extCrlInfo;              /* CRL Distribution Points          */
-    int     extCrlInfoSz;            /* length of the URI                */
-    byte    extSubjKeyId[KEYID_SIZE]; /* Subject Key ID                  */
-    byte    extSubjKeyIdSet;         /* Set when the SKID was read from cert */
-    byte    extAuthKeyId[KEYID_SIZE]; /* Authority Key ID                */
-    byte    extAuthKeyIdSet;         /* Set when the AKID was read from cert */
-#ifndef IGNORE_NAME_CONSTRAINTS
-    byte    extNameConstraintSet;
-#endif /* IGNORE_NAME_CONSTRAINTS */
-    byte    isCA;                    /* CA basic constraint true         */
-    byte    weOwnAltNames;           /* altNames haven't been given to copy */
-    byte    extKeyUsageSet;
-    word16  extKeyUsage;             /* Key usage bitfield               */
-    byte    extExtKeyUsageSet;       /* Extended Key Usage               */
-    byte    extExtKeyUsage;          /* Extended Key usage bitfield      */
-#ifdef OPENSSL_EXTRA
-    byte    extBasicConstSet;
-    byte    extBasicConstCrit;
-    byte    extBasicConstPlSet;
-    word32  pathLength;              /* CA basic constraint path length, opt */
-    byte    extSubjAltNameSet;
-    byte    extSubjAltNameCrit;
-    byte    extAuthKeyIdCrit;
-#ifndef IGNORE_NAME_CONSTRAINTS
-    byte    extNameConstraintCrit;
-#endif /* IGNORE_NAME_CONSTRAINTS */
-    byte    extSubjKeyIdCrit;
-    byte    extKeyUsageCrit;
-    byte    extExtKeyUsageCrit;
-    byte*   extExtKeyUsageSrc;
-    word32  extExtKeyUsageSz;
-    word32  extExtKeyUsageCount;
-    byte*   extAuthKeyIdSrc;
-    word32  extAuthKeyIdSz;
-    byte*   extSubjKeyIdSrc;
-    word32  extSubjKeyIdSz;
-#endif
-#ifdef HAVE_ECC
-    word32  pkCurveOID;           /* Public Key's curve OID */
-#endif /* HAVE_ECC */
-    byte*   beforeDate;
-    int     beforeDateLen;
-    byte*   afterDate;
-    int     afterDateLen;
-#ifdef HAVE_PKCS7
-    byte*   issuerRaw;               /* pointer to issuer inside source */
-    int     issuerRawLen;
-#endif
-#ifndef IGNORE_NAME_CONSTRAINT
-    byte*   subjectRaw;               /* pointer to subject inside source */
-    int     subjectRawLen;
-#endif
-#if defined(WOLFSSL_CERT_GEN)
-    /* easy access to subject info for other sign */
-    char*   subjectSN;
-    int     subjectSNLen;
-    char    subjectSNEnc;
-    char*   subjectC;
-    int     subjectCLen;
-    char    subjectCEnc;
-    char*   subjectL;
-    int     subjectLLen;
-    char    subjectLEnc;
-    char*   subjectST;
-    int     subjectSTLen;
-    char    subjectSTEnc;
-    char*   subjectO;
-    int     subjectOLen;
-    char    subjectOEnc;
-    char*   subjectOU;
-    int     subjectOULen;
-    char    subjectOUEnc;
-    char*   subjectEmail;
-    int     subjectEmailLen;
-#endif /* WOLFSSL_CERT_GEN */
-#ifdef OPENSSL_EXTRA
-    DecodedName issuerName;
-    DecodedName subjectName;
-#endif /* OPENSSL_EXTRA */
-#ifdef WOLFSSL_SEP
-    int     deviceTypeSz;
-    byte*   deviceType;
-    int     hwTypeSz;
-    byte*   hwType;
-    int     hwSerialNumSz;
-    byte*   hwSerialNum;
-    #ifdef OPENSSL_EXTRA
-        byte    extCertPolicySet;
-        byte    extCertPolicyCrit;
-    #endif /* OPENSSL_EXTRA */
-#endif /* WOLFSSL_SEP */
-};
-
-
-#ifdef NO_SHA
-    #define SIGNER_DIGEST_SIZE SHA256_DIGEST_SIZE
-#else
-    #define SIGNER_DIGEST_SIZE SHA_DIGEST_SIZE
-#endif
-
-/* CA Signers */
-/* if change layout change PERSIST_CERT_CACHE functions too */
-struct Signer {
-    word32  pubKeySize;
-    word32  keyOID;                  /* key type */
-    word16  keyUsage;
-    byte*   publicKey;
-    int     nameLen;
-    char*   name;                    /* common name */
-#ifndef IGNORE_NAME_CONSTRAINTS
-        Base_entry* permittedNames;
-        Base_entry* excludedNames;
-#endif /* IGNORE_NAME_CONSTRAINTS */
-    byte    subjectNameHash[SIGNER_DIGEST_SIZE];
-                                     /* sha hash of names in certificate */
-    #ifndef NO_SKID
-        byte    subjectKeyIdHash[SIGNER_DIGEST_SIZE];
-                                     /* sha hash of names in certificate */
-    #endif
-    Signer* next;
-};
-
-
-/* not for public consumption but may use for testing sometimes */
-#ifdef WOLFSSL_TEST_CERT
-    #define WOLFSSL_TEST_API WOLFSSL_API
-#else
-    #define WOLFSSL_TEST_API WOLFSSL_LOCAL
-#endif
-
-WOLFSSL_TEST_API void FreeAltNames(DNS_entry*, void*);
-#ifndef IGNORE_NAME_CONSTRAINTS
-    WOLFSSL_TEST_API void FreeNameSubtrees(Base_entry*, void*);
-#endif /* IGNORE_NAME_CONSTRAINTS */
-WOLFSSL_TEST_API void InitDecodedCert(DecodedCert*, byte*, word32, void*);
-WOLFSSL_TEST_API void FreeDecodedCert(DecodedCert*);
-WOLFSSL_TEST_API int  ParseCert(DecodedCert*, int type, int verify, void* cm);
-
-WOLFSSL_LOCAL int ParseCertRelative(DecodedCert*, int type, int verify,void* cm);
-WOLFSSL_LOCAL int DecodeToKey(DecodedCert*, int verify);
-
-WOLFSSL_LOCAL Signer* MakeSigner(void*);
-WOLFSSL_LOCAL void    FreeSigner(Signer*, void*);
-WOLFSSL_LOCAL void    FreeSignerTable(Signer**, int, void*);
-
-
-WOLFSSL_LOCAL int ToTraditional(byte* buffer, word32 length);
-WOLFSSL_LOCAL int ToTraditionalEnc(byte* buffer, word32 length,const char*, int);
-
-WOLFSSL_LOCAL int ValidateDate(const byte* date, byte format, int dateType);
-
-/* ASN.1 helper functions */
-WOLFSSL_LOCAL int GetLength(const byte* input, word32* inOutIdx, int* len,
-                           word32 maxIdx);
-WOLFSSL_LOCAL int GetSequence(const byte* input, word32* inOutIdx, int* len,
-                             word32 maxIdx);
-WOLFSSL_LOCAL int GetSet(const byte* input, word32* inOutIdx, int* len,
-                        word32 maxIdx);
-WOLFSSL_LOCAL int GetMyVersion(const byte* input, word32* inOutIdx,
-                              int* version);
-WOLFSSL_LOCAL int GetInt(mp_int* mpi, const byte* input, word32* inOutIdx,
-                        word32 maxIdx);
-WOLFSSL_LOCAL int GetAlgoId(const byte* input, word32* inOutIdx, word32* oid,
-                           word32 maxIdx);
-WOLFSSL_LOCAL word32 SetLength(word32 length, byte* output);
-WOLFSSL_LOCAL word32 SetSequence(word32 len, byte* output);
-WOLFSSL_LOCAL word32 SetOctetString(word32 len, byte* output);
-WOLFSSL_LOCAL word32 SetImplicit(byte tag, byte number, word32 len,byte* output);
-WOLFSSL_LOCAL word32 SetExplicit(byte number, word32 len, byte* output);
-WOLFSSL_LOCAL word32 SetSet(word32 len, byte* output);
-WOLFSSL_LOCAL word32 SetAlgoID(int algoOID, byte* output, int type, int curveSz);
-WOLFSSL_LOCAL int SetMyVersion(word32 version, byte* output, int header);
-WOLFSSL_LOCAL int SetSerialNumber(const byte* sn, word32 snSz, byte* output);
-WOLFSSL_LOCAL int GetNameHash(const byte* source, word32* idx, byte* hash,
-                             int maxIdx);
-
-#ifdef HAVE_ECC
-    /* ASN sig helpers */
-    WOLFSSL_LOCAL int StoreECC_DSA_Sig(byte* out, word32* outLen, mp_int* r,
-                                      mp_int* s);
-    WOLFSSL_LOCAL int DecodeECC_DSA_Sig(const byte* sig, word32 sigLen,
-                                       mp_int* r, mp_int* s);
-#endif
-
-#ifdef WOLFSSL_CERT_GEN
-
-enum cert_enums {
-    NAME_ENTRIES    =  8,
-    JOINT_LEN       =  2,
-    EMAIL_JOINT_LEN =  9,
-    RSA_KEY         = 10,
-    NTRU_KEY        = 11,
-    ECC_KEY         = 12
-};
-
-#ifndef WOLFSSL_PEMCERT_TODER_DEFINED
-#ifndef NO_FILESYSTEM
-/* forward from wolfSSL */
-WOLFSSL_API
-int wolfSSL_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz);
-#define WOLFSSL_PEMCERT_TODER_DEFINED
-#endif
-#endif
-
-#endif /* WOLFSSL_CERT_GEN */
-
-
-
-/* for pointer use */
-typedef struct CertStatus CertStatus;
-
-#ifdef HAVE_OCSP
-
-enum Ocsp_Response_Status {
-    OCSP_SUCCESSFUL        = 0, /* Response has valid confirmations */
-    OCSP_MALFORMED_REQUEST = 1, /* Illegal confirmation request */
-    OCSP_INTERNAL_ERROR    = 2, /* Internal error in issuer */
-    OCSP_TRY_LATER         = 3, /* Try again later */
-    OCSP_SIG_REQUIRED      = 5, /* Must sign the request (4 is skipped) */
-    OCSP_UNAUTHROIZED      = 6  /* Request unauthorized */
-};
-
-
-enum Ocsp_Cert_Status {
-    CERT_GOOD    = 0,
-    CERT_REVOKED = 1,
-    CERT_UNKNOWN = 2
-};
-
-
-enum Ocsp_Sums {
-    OCSP_BASIC_OID = 117,
-    OCSP_NONCE_OID = 118
-};
-
-
-typedef struct OcspRequest  OcspRequest;
-typedef struct OcspResponse OcspResponse;
-
-
-struct CertStatus {
-    CertStatus* next;
-
-    byte serial[EXTERNAL_SERIAL_SIZE];
-    int serialSz;
-
-    int status;
-
-    byte thisDate[MAX_DATE_SIZE];
-    byte nextDate[MAX_DATE_SIZE];
-    byte thisDateFormat;
-    byte nextDateFormat;
-};
-
-
-struct OcspResponse {
-    int     responseStatus;  /* return code from Responder */
-
-    byte*   response;        /* Pointer to beginning of OCSP Response */
-    word32  responseSz;      /* length of the OCSP Response */
-
-    byte    producedDate[MAX_DATE_SIZE];
-							 /* Date at which this response was signed */
-    byte    producedDateFormat; /* format of the producedDate */
-    byte*   issuerHash;
-    byte*   issuerKeyHash;
-
-    byte*   cert;
-    word32  certSz;
-
-    byte*   sig;             /* Pointer to sig in source */
-    word32  sigSz;           /* Length in octets for the sig */
-    word32  sigOID;          /* OID for hash used for sig */
-
-    CertStatus* status;      /* certificate status to fill out */
-
-    byte*   nonce;           /* pointer to nonce inside ASN.1 response */
-    int     nonceSz;         /* length of the nonce string */
-
-    byte*   source;          /* pointer to source buffer, not owned */
-    word32  maxIdx;          /* max offset based on init size */
-};
-
-
-struct OcspRequest {
-    DecodedCert* cert;
-
-    byte    useNonce;
-    byte    nonce[MAX_OCSP_NONCE_SZ];
-    int     nonceSz;
-
-    byte*   issuerHash;      /* pointer to issuerHash in source cert */
-    byte*   issuerKeyHash;   /* pointer to issuerKeyHash in source cert */
-    byte*   serial;          /* pointer to serial number in source cert */
-    int     serialSz;        /* length of the serial number */
-
-    byte*   dest;            /* pointer to the destination ASN.1 buffer */
-    word32  destSz;          /* length of the destination buffer */
-};
-
-
-WOLFSSL_LOCAL void InitOcspResponse(OcspResponse*, CertStatus*, byte*, word32);
-WOLFSSL_LOCAL int  OcspResponseDecode(OcspResponse*);
-
-WOLFSSL_LOCAL void InitOcspRequest(OcspRequest*, DecodedCert*,
-                                                          byte, byte*, word32);
-WOLFSSL_LOCAL int  EncodeOcspRequest(OcspRequest*);
-
-WOLFSSL_LOCAL int  CompareOcspReqResp(OcspRequest*, OcspResponse*);
-
-
-#endif /* HAVE_OCSP */
-
-
-/* for pointer use */
-typedef struct RevokedCert RevokedCert;
-
-#ifdef HAVE_CRL
-
-struct RevokedCert {
-    byte         serialNumber[EXTERNAL_SERIAL_SIZE];
-    int          serialSz;
-    RevokedCert* next;
-};
-
-typedef struct DecodedCRL DecodedCRL;
-
-struct DecodedCRL {
-    word32  certBegin;               /* offset to start of cert          */
-    word32  sigIndex;                /* offset to start of signature     */
-    word32  sigLength;               /* length of signature              */
-    word32  signatureOID;            /* sum of algorithm object id       */
-    byte*   signature;               /* pointer into raw source, not owned */
-    byte    issuerHash[SIGNER_DIGEST_SIZE]; /* issuer hash               */
-    byte    crlHash[SIGNER_DIGEST_SIZE]; /* raw crl data hash            */
-    byte    lastDate[MAX_DATE_SIZE]; /* last date updated  */
-    byte    nextDate[MAX_DATE_SIZE]; /* next update date   */
-    byte    lastDateFormat;          /* format of last date */
-    byte    nextDateFormat;          /* format of next date */
-    RevokedCert* certs;              /* revoked cert list  */
-    int          totalCerts;         /* number on list     */
-};
-
-WOLFSSL_LOCAL void InitDecodedCRL(DecodedCRL*);
-WOLFSSL_LOCAL int  ParseCRL(DecodedCRL*, const byte* buff, word32 sz, void* cm);
-WOLFSSL_LOCAL void FreeDecodedCRL(DecodedCRL*);
-
-
-#endif /* HAVE_CRL */
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* !NO_ASN */
-#endif /* WOLF_CRYPT_ASN_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/asn_public.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/asn_public.h
deleted file mode 100755
index 8708708..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/asn_public.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/* asn_public.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLF_CRYPT_ASN_PUBLIC_H
-#define WOLF_CRYPT_ASN_PUBLIC_H
-
-#include 
-#ifdef HAVE_ECC
-    #include 
-#endif
-#if defined(WOLFSSL_CERT_GEN) && !defined(NO_RSA)
-    #include 
-#endif
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-/* Certificate file Type */
-enum CertType {
-    CERT_TYPE       = 0,
-    PRIVATEKEY_TYPE,
-    DH_PARAM_TYPE,
-    CRL_TYPE,
-    CA_TYPE,
-    ECC_PRIVATEKEY_TYPE,
-    CERTREQ_TYPE
-};
-
-
-/* Signature type, by OID sum */
-enum Ctc_SigType {
-    CTC_SHAwDSA      = 517,
-    CTC_MD2wRSA      = 646,
-    CTC_MD5wRSA      = 648,
-    CTC_SHAwRSA      = 649,
-    CTC_SHAwECDSA    = 520,
-    CTC_SHA256wRSA   = 655,
-    CTC_SHA256wECDSA = 524,
-    CTC_SHA384wRSA   = 656,
-    CTC_SHA384wECDSA = 525,
-    CTC_SHA512wRSA   = 657,
-    CTC_SHA512wECDSA = 526
-};
-
-enum Ctc_Encoding {
-    CTC_UTF8       = 0x0c, /* utf8      */
-    CTC_PRINTABLE  = 0x13  /* printable */
-};
-
-
-#ifdef WOLFSSL_CERT_GEN
-
-#ifndef HAVE_ECC
-    typedef struct ecc_key ecc_key;
-#endif
-
-enum Ctc_Misc {
-    CTC_NAME_SIZE    =    64,
-    CTC_DATE_SIZE    =    32,
-    CTC_MAX_ALT_SIZE = 16384,   /* may be huge */
-    CTC_SERIAL_SIZE  =     8
-};
-
-typedef struct CertName {
-    char country[CTC_NAME_SIZE];
-    char countryEnc;
-    char state[CTC_NAME_SIZE];
-    char stateEnc;
-    char locality[CTC_NAME_SIZE];
-    char localityEnc;
-    char sur[CTC_NAME_SIZE];
-    char surEnc;
-    char org[CTC_NAME_SIZE];
-    char orgEnc;
-    char unit[CTC_NAME_SIZE];
-    char unitEnc;
-    char commonName[CTC_NAME_SIZE];
-    char commonNameEnc;
-    char email[CTC_NAME_SIZE];  /* !!!! email has to be last !!!! */
-} CertName;
-
-
-/* for user to fill for certificate generation */
-typedef struct Cert {
-    int      version;                   /* x509 version  */
-    byte     serial[CTC_SERIAL_SIZE];   /* serial number */
-    int      sigType;                   /* signature algo type */
-    CertName issuer;                    /* issuer info */
-    int      daysValid;                 /* validity days */
-    int      selfSigned;                /* self signed flag */
-    CertName subject;                   /* subject info */
-    int      isCA;                      /* is this going to be a CA */
-    /* internal use only */
-    int      bodySz;                    /* pre sign total size */
-    int      keyType;                   /* public key type of subject */
-#ifdef WOLFSSL_ALT_NAMES
-    byte     altNames[CTC_MAX_ALT_SIZE]; /* altNames copy */
-    int      altNamesSz;                 /* altNames size in bytes */
-    byte     beforeDate[CTC_DATE_SIZE];  /* before date copy */
-    int      beforeDateSz;               /* size of copy */
-    byte     afterDate[CTC_DATE_SIZE];   /* after date copy */
-    int      afterDateSz;                /* size of copy */
-#endif
-#ifdef WOLFSSL_CERT_REQ
-    char     challengePw[CTC_NAME_SIZE];
-#endif
-} Cert;
-#endif /* WOLFSSL_CERT_GEN */
-
-
-#ifdef WOLFSSL_CERT_GEN
-
-
-
-/* Initialize and Set Certficate defaults:
-   version    = 3 (0x2)
-   serial     = 0 (Will be randomly generated)
-   sigType    = SHA_WITH_RSA
-   issuer     = blank
-   daysValid  = 500
-   selfSigned = 1 (true) use subject as issuer
-   subject    = blank
-   isCA       = 0 (false)
-   keyType    = RSA_KEY (default)
-*/
-WOLFSSL_API void wc_InitCert(Cert*);
-WOLFSSL_API int  wc_MakeCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*,
-                         ecc_key*, RNG*);
-#ifdef WOLFSSL_CERT_REQ
-    WOLFSSL_API int  wc_MakeCertReq(Cert*, byte* derBuffer, word32 derSz, RsaKey*,
-                                ecc_key*);
-#endif
-WOLFSSL_API int  wc_SignCert(int requestSz, int sigType, byte* derBuffer,
-                         word32 derSz, RsaKey*, ecc_key*, RNG*);
-WOLFSSL_API int  wc_MakeSelfCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*,
-                             RNG*);
-WOLFSSL_API int  wc_SetIssuer(Cert*, const char*);
-WOLFSSL_API int  wc_SetSubject(Cert*, const char*);
-#ifdef WOLFSSL_ALT_NAMES
-    WOLFSSL_API int  wc_SetAltNames(Cert*, const char*);
-#endif
-WOLFSSL_API int  wc_SetIssuerBuffer(Cert*, const byte*, int);
-WOLFSSL_API int  wc_SetSubjectBuffer(Cert*, const byte*, int);
-WOLFSSL_API int  wc_SetAltNamesBuffer(Cert*, const byte*, int);
-WOLFSSL_API int  wc_SetDatesBuffer(Cert*, const byte*, int);
-
-    #ifdef HAVE_NTRU
-        WOLFSSL_API int  wc_MakeNtruCert(Cert*, byte* derBuffer, word32 derSz,
-                                     const byte* ntruKey, word16 keySz, RNG*);
-    #endif
-
-#endif /* WOLFSSL_CERT_GEN */
-
-
-#if defined(WOLFSSL_KEY_GEN) || defined(WOLFSSL_CERT_GEN)
-    WOLFSSL_API int wc_DerToPem(const byte* der, word32 derSz, byte* output,
-                            word32 outputSz, int type);
-#endif
-
-#ifdef HAVE_ECC
-    /* private key helpers */
-    WOLFSSL_API int wc_EccPrivateKeyDecode(const byte* input,word32* inOutIdx,
-                                         ecc_key*,word32);
-    WOLFSSL_API int wc_EccKeyToDer(ecc_key*, byte* output, word32 inLen);
-#endif
-
-/* DER encode signature */
-WOLFSSL_API word32 wc_EncodeSignature(byte* out, const byte* digest, word32 digSz,
-                                  int hashOID);
-WOLFSSL_API int wc_GetCTC_HashOID(int type);
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* WOLF_CRYPT_ASN_PUBLIC_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/blake2-impl.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/blake2-impl.h
deleted file mode 100755
index e1882f2..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/blake2-impl.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
-   BLAKE2 reference source code package - reference C implementations
-
-   Written in 2012 by Samuel Neves 
-
-   To the extent possible under law, the author(s) have dedicated all copyright
-   and related and neighboring rights to this software to the public domain
-   worldwide. This software is distributed without any warranty.
-
-   You should have received a copy of the CC0 Public Domain Dedication along with
-   this software. If not, see .
-*/
-/* blake2-impl.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLFCRYPT_BLAKE2_IMPL_H
-#define WOLFCRYPT_BLAKE2_IMPL_H
-
-#include 
-
-static inline word32 load32( const void *src )
-{
-#if defined(LITTLE_ENDIAN_ORDER)
-  return *( word32 * )( src );
-#else
-  const byte *p = ( byte * )src;
-  word32 w = *p++;
-  w |= ( word32 )( *p++ ) <<  8;
-  w |= ( word32 )( *p++ ) << 16;
-  w |= ( word32 )( *p++ ) << 24;
-  return w;
-#endif
-}
-
-static inline word64 load64( const void *src )
-{
-#if defined(LITTLE_ENDIAN_ORDER)
-  return *( word64 * )( src );
-#else
-  const byte *p = ( byte * )src;
-  word64 w = *p++;
-  w |= ( word64 )( *p++ ) <<  8;
-  w |= ( word64 )( *p++ ) << 16;
-  w |= ( word64 )( *p++ ) << 24;
-  w |= ( word64 )( *p++ ) << 32;
-  w |= ( word64 )( *p++ ) << 40;
-  w |= ( word64 )( *p++ ) << 48;
-  w |= ( word64 )( *p++ ) << 56;
-  return w;
-#endif
-}
-
-static inline void store32( void *dst, word32 w )
-{
-#if defined(LITTLE_ENDIAN_ORDER)
-  *( word32 * )( dst ) = w;
-#else
-  byte *p = ( byte * )dst;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w;
-#endif
-}
-
-static inline void store64( void *dst, word64 w )
-{
-#if defined(LITTLE_ENDIAN_ORDER)
-  *( word64 * )( dst ) = w;
-#else
-  byte *p = ( byte * )dst;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w;
-#endif
-}
-
-static inline word64 load48( const void *src )
-{
-  const byte *p = ( const byte * )src;
-  word64 w = *p++;
-  w |= ( word64 )( *p++ ) <<  8;
-  w |= ( word64 )( *p++ ) << 16;
-  w |= ( word64 )( *p++ ) << 24;
-  w |= ( word64 )( *p++ ) << 32;
-  w |= ( word64 )( *p++ ) << 40;
-  return w;
-}
-
-static inline void store48( void *dst, word64 w )
-{
-  byte *p = ( byte * )dst;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w; w >>= 8;
-  *p++ = ( byte )w;
-}
-
-static inline word32 rotl32( const word32 w, const unsigned c )
-{
-  return ( w << c ) | ( w >> ( 32 - c ) );
-}
-
-static inline word64 rotl64( const word64 w, const unsigned c )
-{
-  return ( w << c ) | ( w >> ( 64 - c ) );
-}
-
-static inline word32 rotr32( const word32 w, const unsigned c )
-{
-  return ( w >> c ) | ( w << ( 32 - c ) );
-}
-
-static inline word64 rotr64( const word64 w, const unsigned c )
-{
-  return ( w >> c ) | ( w << ( 64 - c ) );
-}
-
-/* prevents compiler optimizing out memset() */
-static inline void secure_zero_memory( void *v, word64 n )
-{
-  volatile byte *p = ( volatile byte * )v;
-
-  while( n-- ) *p++ = 0;
-}
-
-#endif  /* WOLFCRYPT_BLAKE2_IMPL_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/blake2-int.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/blake2-int.h
deleted file mode 100755
index 05fd027..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/blake2-int.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
-   BLAKE2 reference source code package - reference C implementations
-
-   Written in 2012 by Samuel Neves 
-
-   To the extent possible under law, the author(s) have dedicated all copyright
-   and related and neighboring rights to this software to the public domain
-   worldwide. This software is distributed without any warranty.
-
-   You should have received a copy of the CC0 Public Domain Dedication along with
-   this software. If not, see .
-*/
-/* blake2-int.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-
-#ifndef WOLFCRYPT_BLAKE2_INT_H
-#define WOLFCRYPT_BLAKE2_INT_H
-
-#include 
-
-
-#if defined(_MSC_VER)
-    #define ALIGN(x) __declspec(align(x))
-#elif defined(__GNUC__)
-    #define ALIGN(x) __attribute__((aligned(x)))
-#else
-    #define ALIGN(x)
-#endif
-
-
-#if defined(__cplusplus)
-    extern "C" {
-#endif
-
-  enum blake2s_constant
-  {
-    BLAKE2S_BLOCKBYTES = 64,
-    BLAKE2S_OUTBYTES   = 32,
-    BLAKE2S_KEYBYTES   = 32,
-    BLAKE2S_SALTBYTES  = 8,
-    BLAKE2S_PERSONALBYTES = 8
-  };
-
-  enum blake2b_constant
-  {
-    BLAKE2B_BLOCKBYTES = 128,
-    BLAKE2B_OUTBYTES   = 64,
-    BLAKE2B_KEYBYTES   = 64,
-    BLAKE2B_SALTBYTES  = 16,
-    BLAKE2B_PERSONALBYTES = 16
-  };
-
-#pragma pack(push, 1)
-  typedef struct __blake2s_param
-  {
-    byte  digest_length; /* 1 */
-    byte  key_length;    /* 2 */
-    byte  fanout;        /* 3 */
-    byte  depth;         /* 4 */
-    word32 leaf_length;   /* 8 */
-    byte  node_offset[6];/* 14 */
-    byte  node_depth;    /* 15 */
-    byte  inner_length;  /* 16 */
-    /* byte  reserved[0]; */
-    byte  salt[BLAKE2B_SALTBYTES]; /* 24 */
-    byte  personal[BLAKE2S_PERSONALBYTES];  /* 32 */
-  } blake2s_param;
-
-  ALIGN( 64 ) typedef struct __blake2s_state
-  {
-    word32 h[8];
-    word32 t[2];
-    word32 f[2];
-    byte  buf[2 * BLAKE2S_BLOCKBYTES];
-    word64 buflen;
-    byte  last_node;
-  } blake2s_state ;
-
-  typedef struct __blake2b_param
-  {
-    byte  digest_length; /* 1 */
-    byte  key_length;    /* 2 */
-    byte  fanout;        /* 3 */
-    byte  depth;         /* 4 */
-    word32 leaf_length;   /* 8 */
-    word64 node_offset;   /* 16 */
-    byte  node_depth;    /* 17 */
-    byte  inner_length;  /* 18 */
-    byte  reserved[14];  /* 32 */
-    byte  salt[BLAKE2B_SALTBYTES]; /* 48 */
-    byte  personal[BLAKE2B_PERSONALBYTES];  /* 64 */
-  } blake2b_param;
-
-  ALIGN( 64 ) typedef struct __blake2b_state
-  {
-    word64 h[8];
-    word64 t[2];
-    word64 f[2];
-    byte  buf[2 * BLAKE2B_BLOCKBYTES];
-    word64 buflen;
-    byte  last_node;
-  } blake2b_state;
-
-  typedef struct __blake2sp_state
-  {
-    blake2s_state S[8][1];
-    blake2s_state R[1];
-    byte buf[8 * BLAKE2S_BLOCKBYTES];
-    word64 buflen;
-  } blake2sp_state;
-
-  typedef struct __blake2bp_state
-  {
-    blake2b_state S[4][1];
-    blake2b_state R[1];
-    byte buf[4 * BLAKE2B_BLOCKBYTES];
-    word64 buflen;
-  } blake2bp_state;
-#pragma pack(pop)
-
-  /* Streaming API */
-  int blake2s_init( blake2s_state *S, const byte outlen );
-  int blake2s_init_key( blake2s_state *S, const byte outlen, const void *key, const byte keylen );
-  int blake2s_init_param( blake2s_state *S, const blake2s_param *P );
-  int blake2s_update( blake2s_state *S, const byte *in, word64 inlen );
-  int blake2s_final( blake2s_state *S, byte *out, byte outlen );
-
-  int blake2b_init( blake2b_state *S, const byte outlen );
-  int blake2b_init_key( blake2b_state *S, const byte outlen, const void *key, const byte keylen );
-  int blake2b_init_param( blake2b_state *S, const blake2b_param *P );
-  int blake2b_update( blake2b_state *S, const byte *in, word64 inlen );
-  int blake2b_final( blake2b_state *S, byte *out, byte outlen );
-
-  int blake2sp_init( blake2sp_state *S, const byte outlen );
-  int blake2sp_init_key( blake2sp_state *S, const byte outlen, const void *key, const byte keylen );
-  int blake2sp_update( blake2sp_state *S, const byte *in, word64 inlen );
-  int blake2sp_final( blake2sp_state *S, byte *out, byte outlen );
-
-  int blake2bp_init( blake2bp_state *S, const byte outlen );
-  int blake2bp_init_key( blake2bp_state *S, const byte outlen, const void *key, const byte keylen );
-  int blake2bp_update( blake2bp_state *S, const byte *in, word64 inlen );
-  int blake2bp_final( blake2bp_state *S, byte *out, byte outlen );
-
-  /* Simple API */
-  int blake2s( byte *out, const void *in, const void *key, const byte outlen, const word64 inlen, byte keylen );
-  int blake2b( byte *out, const void *in, const void *key, const byte outlen, const word64 inlen, byte keylen );
-
-  int blake2sp( byte *out, const void *in, const void *key, const byte outlen, const word64 inlen, byte keylen );
-  int blake2bp( byte *out, const void *in, const void *key, const byte outlen, const word64 inlen, byte keylen );
-
-  static inline int blake2( byte *out, const void *in, const void *key, const byte outlen, const word64 inlen, byte keylen )
-  {
-    return blake2b( out, in, key, outlen, inlen, keylen );
-  }
-
-
-
-#if defined(__cplusplus)
-    }
-#endif
-
-#endif  /* WOLFCRYPT_BLAKE2_INT_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/blake2.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/blake2.h
deleted file mode 100755
index 5186663..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/blake2.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* blake2.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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
- * a with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-
-
-#ifndef WOLF_CRYPT_BLAKE2_H
-#define WOLF_CRYPT_BLAKE2_H
-
-#include 
-
-#ifdef HAVE_BLAKE2
-
-#include 
-
-/* call old functions if using fips for the sake of hmac @wc_fips */
-#ifdef HAVE_FIPS
-    /* Since hmac can call blake functions provide original calls */
-    #define wc_InitBlake2b   InitBlake2b
-    #define wc_Blake2bUpdate Blake2bUpdate
-    #define wc_Blake2bFinal  Blake2bFinal
-#endif
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-/* in bytes, variable digest size up to 512 bits (64 bytes) */
-enum {
-    BLAKE2B_ID  = 7,   /* hash type unique */
-    BLAKE2B_256 = 32   /* 256 bit type, SSL default */
-};
-
-
-/* BLAKE2b digest */
-typedef struct Blake2b {
-    blake2b_state S[1];         /* our state */
-    word32        digestSz;     /* digest size used on init */
-} Blake2b;
-
-
-WOLFSSL_API int wc_InitBlake2b(Blake2b*, word32);
-WOLFSSL_API int wc_Blake2bUpdate(Blake2b*, const byte*, word32);
-WOLFSSL_API int wc_Blake2bFinal(Blake2b*, byte*, word32);
-
-
-
-#ifdef __cplusplus
-    }
-#endif
-
-#endif  /* HAVE_BLAKE2 */
-#endif  /* WOLF_CRYPT_BLAKE2_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/camellia.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/camellia.h
deleted file mode 100755
index 4b7b92a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/camellia.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* camellia.h ver 1.2.0
- *
- * Copyright (c) 2006,2007
- * NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer as
- *   the first lines of this file unmodified.
- * 2. Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY NTT ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL NTT BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* camellia.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_CAMELLIA_H
-#define WOLF_CRYPT_CAMELLIA_H
-
-#include 
-
-#ifdef HAVE_CAMELLIA
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-enum {
-    CAMELLIA_BLOCK_SIZE = 16
-};
-
-#define CAMELLIA_TABLE_BYTE_LEN 272
-#define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / sizeof(word32))
-
-typedef word32 KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
-
-typedef struct Camellia {
-    word32 keySz;
-    KEY_TABLE_TYPE key;
-    word32 reg[CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
-    word32 tmp[CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
-} Camellia;
-
-
-WOLFSSL_API int  wc_CamelliaSetKey(Camellia* cam,
-                                   const byte* key, word32 len, const byte* iv);
-WOLFSSL_API int  wc_CamelliaSetIV(Camellia* cam, const byte* iv);
-WOLFSSL_API void wc_CamelliaEncryptDirect(Camellia* cam, byte* out,
-                                                                const byte* in);
-WOLFSSL_API void wc_CamelliaDecryptDirect(Camellia* cam, byte* out,
-                                                                const byte* in);
-WOLFSSL_API void wc_CamelliaCbcEncrypt(Camellia* cam,
-                                          byte* out, const byte* in, word32 sz);
-WOLFSSL_API void wc_CamelliaCbcDecrypt(Camellia* cam,
-                                          byte* out, const byte* in, word32 sz);
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* HAVE_CAMELLIA */
-#endif /* WOLF_CRYPT_CAMELLIA_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/chacha.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/chacha.h
deleted file mode 100755
index da938c9..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/chacha.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* chacha.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_CHACHA_H
-#define WOLF_CRYPT_CHACHA_H
-
-#include 
-
-#ifdef HAVE_CHACHA
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-enum {
-	CHACHA_ENC_TYPE = 7     /* cipher unique type */
-};
-
-typedef struct ChaCha {
-    word32 X[16];           /* state of cipher */
-} ChaCha;
-
-/**
-  * IV(nonce) changes with each record
-  * counter is for what value the block counter should start ... usually 0
-  */
-WOLFSSL_API int wc_Chacha_SetIV(ChaCha* ctx, const byte* inIv, word32 counter);
-
-WOLFSSL_API int wc_Chacha_Process(ChaCha* ctx, byte* cipher, const byte* plain,
-                              word32 msglen);
-WOLFSSL_API int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz);
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* HAVE_CHACHA */
-#endif /* WOLF_CRYPT_CHACHA_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/chacha20_poly1305.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/chacha20_poly1305.h
deleted file mode 100755
index e65842b..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/chacha20_poly1305.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* chacha20_poly1305.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/* This implementation of the ChaCha20-Poly1305 AEAD is based on "ChaCha20
- * and Poly1305 for IETF protocols" (draft-irtf-cfrg-chacha20-poly1305-10):
- * https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-10
- */
-
-#ifndef WOLF_CRYPT_CHACHA20_POLY1305_H
-#define WOLF_CRYPT_CHACHA20_POLY1305_H
-
-#include 
-
-#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-#define CHACHA20_POLY1305_AEAD_KEYSIZE      32
-#define CHACHA20_POLY1305_AEAD_IV_SIZE      12
-#define CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE 16
-
-enum {
-    CHACHA20_POLY_1305_ENC_TYPE = 8    /* cipher unique type */
-};
-
-    /*
-     * The IV for this implementation is 96 bits to give the most flexibility.
-     *
-     * Some protocols may have unique per-invocation inputs that are not
-     * 96-bit in length. For example, IPsec may specify a 64-bit nonce. In
-     * such a case, it is up to the protocol document to define how to
-     * transform the protocol nonce into a 96-bit nonce, for example by
-     * concatenating a constant value.
-     */
-
-WOLFSSL_API
-int wc_ChaCha20Poly1305_Encrypt(
-                const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
-                const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
-                const byte* inAAD, const word32 inAADLen,
-                const byte* inPlaintext, const word32 inPlaintextLen,
-                byte* outCiphertext,
-                byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE]);
-
-WOLFSSL_API
-int wc_ChaCha20Poly1305_Decrypt(
-                const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
-                const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
-                const byte* inAAD, const word32 inAADLen,
-                const byte* inCiphertext, const word32 inCiphertextLen,
-                const byte inAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE],
-                byte* outPlaintext);
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* HAVE_CHACHA && HAVE_POLY1305 */
-#endif /* WOLF_CRYPT_CHACHA20_POLY1305_H */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/coding.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/coding.h
deleted file mode 100755
index 296bc3c..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/coding.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* coding.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLF_CRYPT_CODING_H
-#define WOLF_CRYPT_CODING_H
-
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-WOLFSSL_API int Base64_Decode(const byte* in, word32 inLen, byte* out,
-                               word32* outLen);
-
-#if defined(OPENSSL_EXTRA) || defined(SESSION_CERTS) || defined(WOLFSSL_KEY_GEN)                         || defined(WOLFSSL_CERT_GEN) || defined(HAVE_WEBSERVER)
-    #ifndef WOLFSSL_BASE64_ENCODE
-        #define WOLFSSL_BASE64_ENCODE
-    #endif
-#endif
-
-
-#ifdef WOLFSSL_BASE64_ENCODE
-    /* encode isn't */
-    WOLFSSL_API
-    int Base64_Encode(const byte* in, word32 inLen, byte* out,
-                                  word32* outLen);
-    WOLFSSL_API
-    int Base64_EncodeEsc(const byte* in, word32 inLen, byte* out,
-                                  word32* outLen);
-#endif
-
-#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) || defined(HAVE_FIPS)
-    WOLFSSL_API
-    int Base16_Decode(const byte* in, word32 inLen, byte* out, word32* outLen);
-#endif
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* WOLF_CRYPT_CODING_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/compress.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/compress.h
deleted file mode 100755
index dc012b8..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/compress.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* compress.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_COMPRESS_H
-#define WOLF_CRYPT_COMPRESS_H
-
-#include 
-
-#ifdef HAVE_LIBZ
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-#define COMPRESS_FIXED 1
-
-
-WOLFSSL_API int wc_Compress(byte*, word32, const byte*, word32, word32);
-WOLFSSL_API int wc_DeCompress(byte*, word32, const byte*, word32);
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-
-#endif /* HAVE_LIBZ */
-#endif /* WOLF_CRYPT_COMPRESS_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/curve25519.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/curve25519.h
deleted file mode 100755
index 1171577..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/curve25519.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* curve25519.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_CURVE25519_H
-#define WOLF_CRYPT_CURVE25519_H
-
-#include 
-
-#ifdef HAVE_CURVE25519
-
-#include 
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-#define CURVE25519_KEYSIZE 32
-
-/* curve25519 set type */
-typedef struct {
-    int size;       /* The size of the curve in octets */
-    const char* name;     /* name of this curve */
-} curve25519_set_type;
-
-
-/* ECC point */
-typedef struct {
-    byte point[CURVE25519_KEYSIZE];
-}ECPoint;
-
-/* A CURVE25519 Key */
-typedef struct {
-    int idx;            /* Index into the ecc_sets[] for the parameters of
-                           this curve if -1, this key is using user supplied
-                           curve in dp */
-    const curve25519_set_type* dp;   /* domain parameters, either points to
-                                   curves (idx >= 0) or user supplied */
-    ECPoint   p;        /* public key  */
-    ECPoint   k;        /* private key */
-} curve25519_key;
-
-WOLFSSL_API
-int wc_curve25519_make_key(RNG* rng, int keysize, curve25519_key* key);
-
-WOLFSSL_API
-int wc_curve25519_shared_secret(curve25519_key* private_key,
-                                curve25519_key* public_key,
-                                byte* out, word32* outlen);
-
-WOLFSSL_API
-int wc_curve25519_init(curve25519_key* key);
-
-WOLFSSL_API
-void wc_curve25519_free(curve25519_key* key);
-
-
-/* raw key helpers */
-WOLFSSL_API
-int wc_curve25519_import_private_raw(const byte* priv, word32 privSz,
-                            const byte* pub, word32 pubSz, curve25519_key* key);
-WOLFSSL_API
-int wc_curve25519_export_private_raw(curve25519_key* key, byte* out,
-                                     word32* outLen);
-
-WOLFSSL_API
-int wc_curve25519_import_public(const byte* in, word32 inLen,
-                                curve25519_key* key);
-
-WOLFSSL_API
-int wc_curve25519_export_public(curve25519_key* key, byte* out, word32* outLen);
-
-
-/* size helper */
-WOLFSSL_API
-int wc_curve25519_size(curve25519_key* key);
-
-#ifdef __cplusplus
-    }    /* extern "C" */
-#endif
-
-#endif /* HAVE_CURVE25519 */
-#endif /* WOLF_CRYPT_CURVE25519_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/des3.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/des3.h
deleted file mode 100755
index c178849..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/des3.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/* des3.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_DES3_H
-#define WOLF_CRYPT_DES3_H
-
-#include 
-
-#ifndef NO_DES3
-
-#ifdef HAVE_FIPS
-/* included for fips @wc_fips */
-#include 
-#endif
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-#ifndef HAVE_FIPS /* to avoid redifinition of macros */
-#define WOLFSSL_3DES_CAVIUM_MAGIC 0xBEEF0003
-
-enum {
-    DES_ENC_TYPE    = 2,     /* cipher unique type */
-    DES3_ENC_TYPE   = 3,     /* cipher unique type */
-    DES_BLOCK_SIZE  = 8,
-    DES_KS_SIZE     = 32,
-
-    DES_ENCRYPTION  = 0,
-    DES_DECRYPTION  = 1
-};
-
-#define DES_IVLEN 8
-#define DES_KEYLEN 8
-#define DES3_IVLEN 8
-#define DES3_KEYLEN 24
-
-
-#ifdef STM32F2_CRYPTO
-enum {
-    DES_CBC = 0,
-    DES_ECB = 1
-};
-#endif
-
-
-/* DES encryption and decryption */
-typedef struct Des {
-    word32 reg[DES_BLOCK_SIZE / sizeof(word32)];      /* for CBC mode */
-    word32 tmp[DES_BLOCK_SIZE / sizeof(word32)];      /* same         */
-    word32 key[DES_KS_SIZE];
-} Des;
-
-
-/* DES3 encryption and decryption */
-typedef struct Des3 {
-    word32 key[3][DES_KS_SIZE];
-    word32 reg[DES_BLOCK_SIZE / sizeof(word32)];      /* for CBC mode */
-    word32 tmp[DES_BLOCK_SIZE / sizeof(word32)];      /* same         */
-#ifdef HAVE_CAVIUM
-    int     devId;           /* nitrox device id */
-    word32  magic;           /* using cavium magic */
-    word64  contextHandle;   /* nitrox context memory handle */
-#endif
-} Des3;
-#endif /* HAVE_FIPS */
-
-WOLFSSL_API int  wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir);
-WOLFSSL_API void wc_Des_SetIV(Des* des, const byte* iv);
-WOLFSSL_API int  wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz);
-WOLFSSL_API int  wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz);
-WOLFSSL_API int  wc_Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz);
-WOLFSSL_API int  wc_Des_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
-                                               const byte* key, const byte* iv);
-
-WOLFSSL_API int  wc_Des3_SetKey(Des3* des, const byte* key, const byte* iv,int dir);
-WOLFSSL_API int  wc_Des3_SetIV(Des3* des, const byte* iv);
-WOLFSSL_API int  wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in,word32 sz);
-WOLFSSL_API int  wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in,word32 sz);
-WOLFSSL_API int  wc_Des3_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
-                                               const byte* key, const byte* iv);
-
-
-#ifdef HAVE_CAVIUM
-    WOLFSSL_API int  wc_Des3_InitCavium(Des3*, int);
-    WOLFSSL_API void wc_Des3_FreeCavium(Des3*);
-#endif
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* NO_DES3 */
-#endif /* WOLF_CRYPT_DES3_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/dh.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/dh.h
deleted file mode 100755
index 7cee7dc..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/dh.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* dh.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_DH_H
-#define WOLF_CRYPT_DH_H
-
-#include 
-
-#ifndef NO_DH
-
-#include 
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-/* Diffie-Hellman Key */
-typedef struct DhKey {
-    mp_int p, g;                            /* group parameters  */
-} DhKey;
-
-
-WOLFSSL_API void wc_InitDhKey(DhKey* key);
-WOLFSSL_API void wc_FreeDhKey(DhKey* key);
-
-WOLFSSL_API int wc_DhGenerateKeyPair(DhKey* key, RNG* rng, byte* priv,
-                                 word32* privSz, byte* pub, word32* pubSz);
-WOLFSSL_API int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz,
-                       const byte* priv, word32 privSz, const byte* otherPub,
-                       word32 pubSz);
-
-WOLFSSL_API int wc_DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key,
-                           word32);
-WOLFSSL_API int wc_DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
-                        word32 gSz);
-WOLFSSL_API int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p,
-                            word32* pInOutSz, byte* g, word32* gInOutSz);
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* NO_DH */
-#endif /* WOLF_CRYPT_DH_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/dsa.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/dsa.h
deleted file mode 100755
index 960bd75..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/dsa.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* dsa.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_DSA_H
-#define WOLF_CRYPT_DSA_H
-
-#include 
-
-#ifndef NO_DSA
-
-#include 
-#include 
-
-/* for DSA reverse compatibility */
-#define InitDsaKey wc_InitDsaKey
-#define FreeDsaKey wc_FreeDsaKey
-#define DsaSign wc_DsaSign
-#define DsaVerify wc_DsaVerify
-#define DsaPublicKeyDecode wc_DsaPublicKeyDecode
-#define DsaPrivateKeyDecode wc_DsaPrivateKeyDecode
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-enum {
-    DSA_PUBLIC   = 0,
-    DSA_PRIVATE  = 1
-};
-
-/* DSA */
-typedef struct DsaKey {
-    mp_int p, q, g, y, x;
-    int type;                               /* public or private */
-} DsaKey;
-
-
-WOLFSSL_API void wc_InitDsaKey(DsaKey* key);
-WOLFSSL_API void wc_FreeDsaKey(DsaKey* key);
-
-WOLFSSL_API int wc_DsaSign(const byte* digest, byte* out, DsaKey* key, RNG* rng);
-WOLFSSL_API int wc_DsaVerify(const byte* digest, const byte* sig, DsaKey* key,
-                         int* answer);
-
-WOLFSSL_API int wc_DsaPublicKeyDecode(const byte* input, word32* inOutIdx, DsaKey*,
-                                  word32);
-WOLFSSL_API int wc_DsaPrivateKeyDecode(const byte* input, word32* inOutIdx, DsaKey*,
-                                   word32);
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* NO_DSA */
-#endif /* WOLF_CRYPT_DSA_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/ecc.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/ecc.h
deleted file mode 100755
index 447e8d3..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/ecc.h
+++ /dev/null
@@ -1,245 +0,0 @@
-/* ecc.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_ECC_H
-#define WOLF_CRYPT_ECC_H
-
-#include 
-
-#ifdef HAVE_ECC
-
-#include 
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-enum {
-    ECC_PUBLICKEY  = 1,
-    ECC_PRIVATEKEY = 2,
-    ECC_MAXNAME    = 16,     /* MAX CURVE NAME LENGTH */
-    SIG_HEADER_SZ  =  6,     /* ECC signature header size */
-    ECC_BUFSIZE    = 256,    /* for exported keys temp buffer */
-    ECC_MINSIZE    = 20,     /* MIN Private Key size */
-    ECC_MAXSIZE    = 66      /* MAX Private Key size */
-};
-
-
-/* ECC set type defined a NIST GF(p) curve */
-typedef struct {
-    int size;       /* The size of the curve in octets */
-    const char* name;     /* name of this curve */
-    const char* prime;    /* prime that defines the field, curve is in (hex) */
-    const char* Af;       /* fields A param (hex) */
-    const char* Bf;       /* fields B param (hex) */
-    const char* order;    /* order of the curve (hex) */
-    const char* Gx;       /* x coordinate of the base point on curve (hex) */
-    const char* Gy;       /* y coordinate of the base point on curve (hex) */
-} ecc_set_type;
-
-
-#ifdef ALT_ECC_SIZE
-
-/* Note on ALT_ECC_SIZE:
- * The fast math code uses an array of a fixed size to store the big integers.
- * By default, the array is big enough for RSA keys. There is a size,
- * FP_MAX_BITS which can be used to make the array smaller when one wants ECC
- * but not RSA. Some people want fast math sized for both RSA and ECC, where
- * ECC won't use as much as RSA. The flag ALT_ECC_SIZE switches in an alternate
- * ecc_point structure that uses an alternate fp_int that has a shorter array
- * of fp_digits.
- *
- * Now, without ALT_ECC_SIZE, the ecc_point has three single item arrays of
- * mp_ints for the components of the point. With ALT_ECC_SIZE, the components
- * of the point are pointers that are set to each of a three item array of
- * alt_fp_ints. While an mp_int will have 4096 bits of digit inside the
- * structure, the alt_fp_int will only have 512 bits. A size value was added
- * in the ALT case, as well, and is set by mp_init() and alt_fp_init(). The
- * functions fp_zero() and fp_copy() use the size parameter. An int needs to
- * be initialized before using it instead of just fp_zeroing it, the init will
- * call zero. FP_MAX_BITS_ECC defaults to 512, but can be set to change the
- * number of bits used in the alternate FP_INT.
- *
- * Do not enable ALT_ECC_SIZE and disable fast math in the configuration.
- */
-
-#ifndef FP_MAX_BITS_ECC
-    #define FP_MAX_BITS_ECC           512
-#endif
-#define FP_MAX_SIZE_ECC           (FP_MAX_BITS_ECC+(8*DIGIT_BIT))
-#if FP_MAX_BITS_ECC % CHAR_BIT
-   #error FP_MAX_BITS_ECC must be a multiple of CHAR_BIT
-#endif
-#define FP_SIZE_ECC    (FP_MAX_SIZE_ECC/DIGIT_BIT)
-
-/* This needs to match the size of the fp_int struct, except the
- * fp_digit array will be shorter. */
-typedef struct alt_fp_int {
-    int used, sign, size;
-    fp_digit dp[FP_SIZE_ECC];
-} alt_fp_int;
-#endif
-
-/* A point on an ECC curve, stored in Jacbobian format such that (x,y,z) =>
-   (x/z^2, y/z^3, 1) when interpreted as affine */
-typedef struct {
-#ifndef ALT_ECC_SIZE
-    mp_int x[1];        /* The x coordinate */
-    mp_int y[1];        /* The y coordinate */
-    mp_int z[1];        /* The z coordinate */
-#else
-    mp_int* x;        /* The x coordinate */
-    mp_int* y;        /* The y coordinate */
-    mp_int* z;        /* The z coordinate */
-    alt_fp_int xyz[3];
-#endif
-} ecc_point;
-
-
-/* An ECC Key */
-typedef struct {
-    int type;           /* Public or Private */
-    int idx;            /* Index into the ecc_sets[] for the parameters of
-                           this curve if -1, this key is using user supplied
-                           curve in dp */
-    const ecc_set_type* dp;     /* domain parameters, either points to NIST
-                                   curves (idx >= 0) or user supplied */
-    ecc_point pubkey;   /* public key */
-    mp_int    k;        /* private key */
-} ecc_key;
-
-
-/* ECC predefined curve sets  */
-extern const ecc_set_type ecc_sets[];
-
-
-WOLFSSL_API
-int wc_ecc_make_key(RNG* rng, int keysize, ecc_key* key);
-WOLFSSL_API
-int wc_ecc_check_key(ecc_key* key);
-WOLFSSL_API
-int wc_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte* out,
-                      word32* outlen);
-WOLFSSL_API
-int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen, 
-                  RNG* rng, ecc_key* key);
-WOLFSSL_API
-int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
-                    word32 hashlen, int* stat, ecc_key* key);
-WOLFSSL_API
-int wc_ecc_init(ecc_key* key);
-WOLFSSL_API
-void wc_ecc_free(ecc_key* key);
-WOLFSSL_API
-void wc_ecc_fp_free(void);
-
-
-/* ASN key helpers */
-WOLFSSL_API
-int wc_ecc_export_x963(ecc_key*, byte* out, word32* outLen);
-WOLFSSL_API
-int wc_ecc_export_x963_ex(ecc_key*, byte* out, word32* outLen, int compressed);
-    /* extended functionality with compressed option */
-WOLFSSL_API
-int wc_ecc_import_x963(const byte* in, word32 inLen, ecc_key* key);
-WOLFSSL_API
-int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub,
-                           word32 pubSz, ecc_key* key);
-WOLFSSL_API
-int wc_ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* outlen);
-WOLFSSL_API
-int wc_ecc_import_raw(ecc_key* key, const char* qx, const char* qy,
-                   const char* d, const char* curveName);
-
-WOLFSSL_API
-int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen);
-
-/* size helper */
-WOLFSSL_API
-int wc_ecc_size(ecc_key* key);
-WOLFSSL_API
-int wc_ecc_sig_size(ecc_key* key);
-
-
-#ifdef HAVE_ECC_ENCRYPT
-/* ecc encrypt */
-
-enum ecEncAlgo {
-    ecAES_128_CBC = 1,  /* default */
-    ecAES_256_CBC = 2
-};
-
-enum ecKdfAlgo {
-    ecHKDF_SHA256 = 1,  /* default */
-    ecHKDF_SHA1   = 2
-};
-
-enum ecMacAlgo {
-    ecHMAC_SHA256 = 1,  /* default */
-    ecHMAC_SHA1   = 2
-};
-
-enum {
-    KEY_SIZE_128     = 16,
-    KEY_SIZE_256     = 32,
-    IV_SIZE_64       =  8,
-    EXCHANGE_SALT_SZ = 16,
-    EXCHANGE_INFO_SZ = 23
-};
-
-enum ecFlags {
-    REQ_RESP_CLIENT = 1,
-    REQ_RESP_SERVER = 2
-};
-
-
-typedef struct ecEncCtx ecEncCtx;
-
-WOLFSSL_API
-ecEncCtx* wc_ecc_ctx_new(int flags, RNG* rng);
-WOLFSSL_API
-void wc_ecc_ctx_free(ecEncCtx*);
-WOLFSSL_API
-int wc_ecc_ctx_reset(ecEncCtx*, RNG*);   /* reset for use again w/o alloc/free */
-
-WOLFSSL_API
-const byte* wc_ecc_ctx_get_own_salt(ecEncCtx*);
-WOLFSSL_API
-int wc_ecc_ctx_set_peer_salt(ecEncCtx*, const byte* salt);
-WOLFSSL_API
-int wc_ecc_ctx_set_info(ecEncCtx*, const byte* info, int sz);
-
-WOLFSSL_API
-int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
-                word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx);
-WOLFSSL_API
-int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
-                word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx);
-
-#endif /* HAVE_ECC_ENCRYPT */
-
-#ifdef __cplusplus
-    }    /* extern "C" */
-#endif
-
-#endif /* HAVE_ECC */
-#endif /* WOLF_CRYPT_ECC_H */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/ed25519.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/ed25519.h
deleted file mode 100755
index 6f9a199..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/ed25519.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ed25519.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_ED25519_H
-#define WOLF_CRYPT_ED25519_H
-
-#include 
-
-#ifdef HAVE_ED25519
-
-#include 
-#include 
-#include 
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-/* info about EdDSA curve specifically ed25519, defined as an elliptic curve
-   over GF(p) */
-/*
-    32,                key size
-    "ED25519",         curve name
-    "2^255-19",        prime number
-    "SHA512",          hash function
-    "-121665/121666",  value of d
-*/
-
-#define ED25519_KEY_SIZE 32
-#define ED25519_SIG_SIZE 64
-
-
-/* An ED25519 Key */
-typedef struct {
-    byte    p[32];        /* compressed public key */
-    byte    k[64];        /* private key : 32 secret -- 32 public */
-} ed25519_key;
-
-
-WOLFSSL_API
-int wc_ed25519_make_key(RNG* rng, int keysize, ed25519_key* key);
-WOLFSSL_API
-int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out,
-                        word32 *outlen, ed25519_key* key);
-WOLFSSL_API
-int wc_ed25519_verify_msg(byte* sig, word32 siglen, const byte* msg,
-                          word32 msglen, int* stat, ed25519_key* key);
-WOLFSSL_API
-int wc_ed25519_init(ed25519_key* key);
-WOLFSSL_API
-void wc_ed25519_free(ed25519_key* key);
-WOLFSSL_API
-int wc_ed25519_import_public(const byte* in, word32 inLen, ed25519_key* key);
-WOLFSSL_API
-int wc_ed25519_import_private_key(const byte* priv, word32 privSz,
-                               const byte* pub, word32 pubSz, ed25519_key* key);
-WOLFSSL_API
-int wc_ed25519_export_public(ed25519_key*, byte* out, word32* outLen);
-WOLFSSL_API
-int wc_ed25519_export_private_only(ed25519_key* key, byte* out, word32* outLen);
-
-/* size helper */
-WOLFSSL_API
-int wc_ed25519_size(ed25519_key* key);
-WOLFSSL_API
-int wc_ed25519_sig_size(ed25519_key* key);
-
-#ifdef __cplusplus
-    }    /* extern "C" */
-#endif
-
-#endif /* HAVE_ED25519 */
-#endif /* WOLF_CRYPT_ED25519_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/error-crypt.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/error-crypt.h
deleted file mode 100755
index 79991fd..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/error-crypt.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/* error-crypt.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLF_CRYPT_ERROR_H
-#define WOLF_CRYPT_ERROR_H
-
-#include 
-
-#ifdef HAVE_FIPS
-	#include 
-	#define wc_ErrorString    CTaoCryptErrorString
-	#define wc_GetErrorString CTaoCryptGetErrorString
-#endif /* HAVE_FIPS */
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-/* error codes */
-enum {
-    MAX_CODE_E         = -100,  /* errors -101 - -299 */
-    OPEN_RAN_E         = -101,  /* opening random device error */
-    READ_RAN_E         = -102,  /* reading random device error */
-    WINCRYPT_E         = -103,  /* windows crypt init error */
-    CRYPTGEN_E         = -104,  /* windows crypt generation error */
-    RAN_BLOCK_E        = -105,  /* reading random device would block */
-    BAD_MUTEX_E        = -106,  /* Bad mutex operation */
-
-    MP_INIT_E          = -110,  /* mp_init error state */
-    MP_READ_E          = -111,  /* mp_read error state */
-    MP_EXPTMOD_E       = -112,  /* mp_exptmod error state */
-    MP_TO_E            = -113,  /* mp_to_xxx error state, can't convert */
-    MP_SUB_E           = -114,  /* mp_sub error state, can't subtract */
-    MP_ADD_E           = -115,  /* mp_add error state, can't add */
-    MP_MUL_E           = -116,  /* mp_mul error state, can't multiply */
-    MP_MULMOD_E        = -117,  /* mp_mulmod error state, can't multiply mod */
-    MP_MOD_E           = -118,  /* mp_mod error state, can't mod */
-    MP_INVMOD_E        = -119,  /* mp_invmod error state, can't inv mod */
-    MP_CMP_E           = -120,  /* mp_cmp error state */
-    MP_ZERO_E          = -121,  /* got a mp zero result, not expected */
-
-    MEMORY_E           = -125,  /* out of memory error */
-
-    RSA_WRONG_TYPE_E   = -130,  /* RSA wrong block type for RSA function */
-    RSA_BUFFER_E       = -131,  /* RSA buffer error, output too small or
-                                   input too large */
-    BUFFER_E           = -132,  /* output buffer too small or input too large */
-    ALGO_ID_E          = -133,  /* setting algo id error */
-    PUBLIC_KEY_E       = -134,  /* setting public key error */
-    DATE_E             = -135,  /* setting date validity error */
-    SUBJECT_E          = -136,  /* setting subject name error */
-    ISSUER_E           = -137,  /* setting issuer  name error */
-    CA_TRUE_E          = -138,  /* setting CA basic constraint true error */
-    EXTENSIONS_E       = -139,  /* setting extensions error */
-
-    ASN_PARSE_E        = -140,  /* ASN parsing error, invalid input */
-    ASN_VERSION_E      = -141,  /* ASN version error, invalid number */
-    ASN_GETINT_E       = -142,  /* ASN get big int error, invalid data */
-    ASN_RSA_KEY_E      = -143,  /* ASN key init error, invalid input */
-    ASN_OBJECT_ID_E    = -144,  /* ASN object id error, invalid id */
-    ASN_TAG_NULL_E     = -145,  /* ASN tag error, not null */
-    ASN_EXPECT_0_E     = -146,  /* ASN expect error, not zero */
-    ASN_BITSTR_E       = -147,  /* ASN bit string error, wrong id */
-    ASN_UNKNOWN_OID_E  = -148,  /* ASN oid error, unknown sum id */
-    ASN_DATE_SZ_E      = -149,  /* ASN date error, bad size */
-    ASN_BEFORE_DATE_E  = -150,  /* ASN date error, current date before */
-    ASN_AFTER_DATE_E   = -151,  /* ASN date error, current date after */
-    ASN_SIG_OID_E      = -152,  /* ASN signature error, mismatched oid */
-    ASN_TIME_E         = -153,  /* ASN time error, unknown time type */
-    ASN_INPUT_E        = -154,  /* ASN input error, not enough data */
-    ASN_SIG_CONFIRM_E  = -155,  /* ASN sig error, confirm failure */
-    ASN_SIG_HASH_E     = -156,  /* ASN sig error, unsupported hash type */
-    ASN_SIG_KEY_E      = -157,  /* ASN sig error, unsupported key type */
-    ASN_DH_KEY_E       = -158,  /* ASN key init error, invalid input */
-    ASN_NTRU_KEY_E     = -159,  /* ASN ntru key decode error, invalid input */
-    ASN_CRIT_EXT_E     = -160,  /* ASN unsupported critical extension */
-
-    ECC_BAD_ARG_E      = -170,  /* ECC input argument of wrong type */
-    ASN_ECC_KEY_E      = -171,  /* ASN ECC bad input */
-    ECC_CURVE_OID_E    = -172,  /* Unsupported ECC OID curve type */
-    BAD_FUNC_ARG       = -173,  /* Bad function argument provided */
-    NOT_COMPILED_IN    = -174,  /* Feature not compiled in */
-    UNICODE_SIZE_E     = -175,  /* Unicode password too big */
-    NO_PASSWORD        = -176,  /* no password provided by user */
-    ALT_NAME_E         = -177,  /* alt name size problem, too big */
-
-    AES_GCM_AUTH_E     = -180,  /* AES-GCM Authentication check failure */
-    AES_CCM_AUTH_E     = -181,  /* AES-CCM Authentication check failure */
-
-    CAVIUM_INIT_E      = -182,  /* Cavium Init type error */
-
-    COMPRESS_INIT_E    = -183,  /* Compress init error */
-    COMPRESS_E         = -184,  /* Compress error */
-    DECOMPRESS_INIT_E  = -185,  /* DeCompress init error */
-    DECOMPRESS_E       = -186,  /* DeCompress error */
-
-    BAD_ALIGN_E         = -187,  /* Bad alignment for operation, no alloc */
-    ASN_NO_SIGNER_E     = -188,  /* ASN no signer to confirm failure */
-    ASN_CRL_CONFIRM_E   = -189,  /* ASN CRL signature confirm failure */
-    ASN_CRL_NO_SIGNER_E = -190,  /* ASN CRL no signer to confirm failure */
-    ASN_OCSP_CONFIRM_E  = -191,  /* ASN OCSP signature confirm failure */
-
-    BAD_ENC_STATE_E     = -192,  /* Bad ecc enc state operation */
-    BAD_PADDING_E       = -193,  /* Bad padding, msg not correct length  */
-
-    REQ_ATTRIBUTE_E     = -194,  /* setting cert request attributes error */
-
-    PKCS7_OID_E         = -195,  /* PKCS#7, mismatched OID error */
-    PKCS7_RECIP_E       = -196,  /* PKCS#7, recipient error */
-    FIPS_NOT_ALLOWED_E  = -197,  /* FIPS not allowed error */
-    ASN_NAME_INVALID_E  = -198,  /* ASN name constraint error */
-
-    RNG_FAILURE_E       = -199,  /* RNG Failed, Reinitialize */
-    HMAC_MIN_KEYLEN_E   = -200,  /* FIPS Mode HMAC Minimum Key Length error */
-    RSA_PAD_E           = -201,  /* RSA Padding Error */
-    LENGTH_ONLY_E       = -202,  /* Returning output length only */
-
-    IN_CORE_FIPS_E      = -203,  /* In Core Integrity check failure */
-    AES_KAT_FIPS_E      = -204,  /* AES KAT failure */
-    DES3_KAT_FIPS_E     = -205,  /* DES3 KAT failure */
-    HMAC_KAT_FIPS_E     = -206,  /* HMAC KAT failure */
-    RSA_KAT_FIPS_E      = -207,  /* RSA KAT failure */
-    DRBG_KAT_FIPS_E     = -208,  /* HASH DRBG KAT failure */
-    DRBG_CONT_FIPS_E    = -209,  /* HASH DRBG Continious test failure */
-    AESGCM_KAT_FIPS_E   = -210,  /* AESGCM KAT failure */
-    THREAD_STORE_KEY_E  = -211,  /* Thread local storage key create failure */
-    THREAD_STORE_SET_E  = -212,  /* Thread local storage key set failure */
-
-    MAC_CMP_FAILED_E    = -213,  /* MAC comparison failed */
-    IS_POINT_E          = -214,  /* ECC is point on curve failed */
-    ECC_INF_E           = -215,  /* ECC point infinity error */
-    ECC_PRIV_KEY_E      = -216,  /* ECC private key not valid error */
-
-    MIN_CODE_E          = -300   /* errors -101 - -299 */
-};
-
-
-WOLFSSL_API void wc_ErrorString(int err, char* buff);
-WOLFSSL_API const char* wc_GetErrorString(int error);
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-#endif /* WOLF_CRYPT_ERROR_H */
-
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/fe_operations.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/fe_operations.h
deleted file mode 100755
index a779f2b..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/fe_operations.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* fe_operations.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_FE_OPERATIONS_H
-#define WOLF_CRYPT_FE_OPERATIONS_H
-
-#include 
-
-#if defined(HAVE_CURVE25519) || defined(HAVE_ED25519)
-
-#ifndef CURVED25519_SMALL
-    #include 
-#endif
-#include 
-
-/*
-fe means field element.
-Here the field is \Z/(2^255-19).
-An element t, entries t[0]...t[9], represents the integer
-t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9].
-Bounds on each t[i] vary depending on context.
-*/
-
-#ifdef CURVED25519_SMALL
-    #define F25519_SIZE	32
-    typedef byte     fe[32];
-#else
-    typedef int32_t  fe[10];
-#endif
-
-WOLFSSL_LOCAL int  curve25519(byte * q, byte * n, byte * p);
-WOLFSSL_LOCAL void fe_copy(fe, const fe);
-WOLFSSL_LOCAL void fe_add(fe, const fe, const fe);
-WOLFSSL_LOCAL void fe_neg(fe,const fe);
-WOLFSSL_LOCAL void fe_sub(fe, const fe, const fe);
-WOLFSSL_LOCAL void fe_invert(fe, const fe);
-WOLFSSL_LOCAL void fe_mul(fe,const fe,const fe);
-
-/* default to be faster but take more memory */
-#ifndef CURVED25519_SMALL
-
-/* Based On Daniel J Bernstein's curve25519 and ed25519 Public Domain ref10
-   work. */
-
-WOLFSSL_LOCAL void fe_0(fe);
-WOLFSSL_LOCAL void fe_1(fe);
-WOLFSSL_LOCAL int  fe_isnonzero(const fe);
-WOLFSSL_LOCAL int  fe_isnegative(const fe);
-WOLFSSL_LOCAL void fe_tobytes(unsigned char *, const fe);
-WOLFSSL_LOCAL void fe_sq(fe, const fe);
-WOLFSSL_LOCAL void fe_sq2(fe,const fe);
-WOLFSSL_LOCAL void fe_frombytes(fe,const unsigned char *);
-WOLFSSL_LOCAL void fe_cswap(fe,fe,unsigned int);
-WOLFSSL_LOCAL void fe_mul121666(fe,fe);
-WOLFSSL_LOCAL void fe_cmov(fe,const fe,unsigned int);
-WOLFSSL_LOCAL void fe_pow22523(fe,const fe);
-
-/* 64 type needed for SHA512 */
-WOLFSSL_LOCAL uint64_t load_3(const unsigned char *in);
-WOLFSSL_LOCAL uint64_t load_4(const unsigned char *in);
-#endif /* not defined CURVED25519_SMALL */
-
-/* Use less memory and only 32bit types or less, but is slower
-   Based on Daniel Beer's public domain work. */
-#ifdef CURVED25519_SMALL
-static const byte c25519_base_x[F25519_SIZE] = {9};
-static const byte f25519_zero[F25519_SIZE]   = {0};
-static const byte f25519_one[F25519_SIZE]    = {1};
-static const byte fprime_zero[F25519_SIZE]   = {0};
-static const byte fprime_one[F25519_SIZE]    = {1};
-
-WOLFSSL_LOCAL void fe_load(byte *x, word32 c);
-WOLFSSL_LOCAL void fe_normalize(byte *x);
-WOLFSSL_LOCAL void fe_inv__distinct(byte *r, const byte *x);
-
-/* Conditional copy. If condition == 0, then zero is copied to dst. If
- * condition == 1, then one is copied to dst. Any other value results in
- * undefined behaviour.
- */
-WOLFSSL_LOCAL void fe_select(byte *dst, const byte *zero, const byte *one,
-		   byte condition);
-
-/* Multiply a point by a small constant. The two pointers are not
- * required to be distinct.
- *
- * The constant must be less than 2^24.
- */
-WOLFSSL_LOCAL void fe_mul_c(byte *r, const byte *a, word32 b);
-WOLFSSL_LOCAL void fe_mul__distinct(byte *r, const byte *a, const byte *b);
-
-/* Compute one of the square roots of the field element, if the element
- * is square. The other square is -r.
- *
- * If the input is not square, the returned value is a valid field
- * element, but not the correct answer. If you don't already know that
- * your element is square, you should square the return value and test.
- */
-WOLFSSL_LOCAL void fe_sqrt(byte *r, const byte *x);
-
-/* Conditional copy. If condition == 0, then zero is copied to dst. If
- * condition == 1, then one is copied to dst. Any other value results in
- * undefined behaviour.
- */
-WOLFSSL_LOCAL void fprime_select(byte *dst, const byte *zero, const byte *one,
-		                         byte condition);
-WOLFSSL_LOCAL void fprime_add(byte *r, const byte *a, const byte *modulus);
-WOLFSSL_LOCAL void fprime_sub(byte *r, const byte *a, const byte *modulus);
-WOLFSSL_LOCAL void fprime_mul(byte *r, const byte *a, const byte *b,
-		                      const byte *modulus);
-WOLFSSL_LOCAL void fprime_copy(byte *x, const byte *a);
-#endif /* CURVED25519_SMALL */
-#endif /* HAVE_CURVE25519 or HAVE_ED25519 */
-#endif /* WOLF_CRYPT_FE_OPERATIONS_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/fips_test.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/fips_test.h
deleted file mode 100755
index 6ef0678..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/fips_test.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* fips_test.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLF_CRYPT_FIPS_TEST_H
-#define WOLF_CRYPT_FIPS_TEST_H
-
-#include 
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-/* Known Answer Test string inputs are hex, internal */
-CYASSL_LOCAL int DoKnownAnswerTests(char*, int);
-
-
-/* FIPS failure callback */
-typedef void(*wolfCrypt_fips_cb)(int ok, int err, const char* hash);
-
-/* Public set function */
-CYASSL_API int wolfCrypt_SetCb_fips(wolfCrypt_fips_cb cbf);
-
-/* Public get status functions */
-CYASSL_API int wolfCrypt_GetStatus_fips(void);
-CYASSL_API const char* wolfCrypt_GetCoreHash_fips(void);
-
-#ifdef HAVE_FORCE_FIPS_FAILURE
-    /* Public function to force failure mode for operational testing */
-    CYASSL_API int wolfCrypt_SetStatus_fips(int);
-#endif
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* WOLF_CRYPT_FIPS_TEST_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/ge_operations.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/ge_operations.h
deleted file mode 100755
index 00d1b3e..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/ge_operations.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ge_operations.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
- /* Based On Daniel J Bernstein's ed25519 Public Domain ref10 work. */
-
-#ifndef WOLF_CRYPT_GE_OPERATIONS_H
-#define WOLF_CRYPT_GE_OPERATIONS_H
-
-#include 
-
-#ifdef HAVE_ED25519
-
-#ifndef CURVED25519_SMALL
-    #include 
-#endif
-#include 
-
-/*
-ge means group element.
-
-Here the group is the set of pairs (x,y) of field elements (see fe.h)
-satisfying -x^2 + y^2 = 1 + d x^2y^2
-where d = -121665/121666.
-
-Representations:
-  ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z
-  ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT
-  ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T
-  ge_precomp (Duif): (y+x,y-x,2dxy)
-*/
-
-
-typedef struct {
-  fe X;
-  fe Y;
-  fe Z;
-} ge_p2;
-
-typedef struct {
-  fe X;
-  fe Y;
-  fe Z;
-  fe T;
-} ge_p3;
-
-WOLFSSL_LOCAL int  ge_compress_key(byte* out, const byte* xIn, const byte* yIn,
-                                                                word32 keySz);
-WOLFSSL_LOCAL int  ge_frombytes_negate_vartime(ge_p3 *,const unsigned char *);
-
-WOLFSSL_LOCAL int  ge_double_scalarmult_vartime(ge_p2 *,const unsigned char *,
-                                         const ge_p3 *,const unsigned char *);
-WOLFSSL_LOCAL void ge_scalarmult_base(ge_p3 *,const unsigned char *);
-WOLFSSL_LOCAL void sc_reduce(byte* s);
-WOLFSSL_LOCAL void sc_muladd(byte* s, const byte* a, const byte* b,
-                             const byte* c);
-WOLFSSL_LOCAL void ge_tobytes(unsigned char *,const ge_p2 *);
-WOLFSSL_LOCAL void ge_p3_tobytes(unsigned char *,const ge_p3 *);
-
-#ifndef CURVED25519_SMALL
-typedef struct {
-  fe X;
-  fe Y;
-  fe Z;
-  fe T;
-} ge_p1p1;
-
-typedef struct {
-  fe yplusx;
-  fe yminusx;
-  fe xy2d;
-} ge_precomp;
-
-typedef struct {
-  fe YplusX;
-  fe YminusX;
-  fe Z;
-  fe T2d;
-} ge_cached;
-
-WOLFSSL_LOCAL void ge_p2_0(ge_p2 *);
-WOLFSSL_LOCAL void ge_p3_0(ge_p3 *);
-WOLFSSL_LOCAL void ge_precomp_0(ge_precomp *);
-WOLFSSL_LOCAL void ge_p3_to_p2(ge_p2 *,const ge_p3 *);
-WOLFSSL_LOCAL void ge_p3_to_cached(ge_cached *,const ge_p3 *);
-WOLFSSL_LOCAL void ge_p1p1_to_p2(ge_p2 *,const ge_p1p1 *);
-WOLFSSL_LOCAL void ge_p1p1_to_p3(ge_p3 *,const ge_p1p1 *);
-WOLFSSL_LOCAL void ge_p2_dbl(ge_p1p1 *,const ge_p2 *);
-WOLFSSL_LOCAL void ge_p3_dbl(ge_p1p1 *,const ge_p3 *);
-
-WOLFSSL_LOCAL void ge_madd(ge_p1p1 *,const ge_p3 *,const ge_precomp *);
-WOLFSSL_LOCAL void ge_msub(ge_p1p1 *,const ge_p3 *,const ge_precomp *);
-WOLFSSL_LOCAL void ge_add(ge_p1p1 *,const ge_p3 *,const ge_cached *);
-WOLFSSL_LOCAL void ge_sub(ge_p1p1 *,const ge_p3 *,const ge_cached *);
-#endif /* no CURVED25519_SMALL */
-#endif /* HAVE_ED25519 */
-#endif /* WOLF_CRYPT_GE_OPERATIONS_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/hash.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/hash.h
deleted file mode 100755
index ad10628..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/hash.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* hash.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_HASH_H
-#define WOLF_CRYPT_HASH_H
-
-#ifndef NO_MD5
-#include 
-WOLFSSL_API void wc_Md5GetHash(Md5*, byte*);
-WOLFSSL_API void wc_Md5RestorePos(Md5*, Md5*) ;
-#endif
-#ifndef NO_SHA
-#include 
-WOLFSSL_API int wc_ShaGetHash(Sha*, byte*);
-WOLFSSL_API void wc_ShaRestorePos(Sha*, Sha*) ;
-#endif
-#ifndef NO_SHA256
-#include 
-WOLFSSL_API int wc_Sha256GetHash(Sha256*, byte*);
-WOLFSSL_API void wc_Sha256RestorePos(Sha256*, Sha256*) ;
-#endif
-
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/hc128.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/hc128.h
deleted file mode 100755
index ba53dd3..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/hc128.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* hc128.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_HC128_H
-#define WOLF_CRYPT_HC128_H
-
-#include 
-
-#ifndef NO_HC128
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-enum {
-	HC128_ENC_TYPE    =  6    /* cipher unique type */
-};
-
-/* HC-128 stream cipher */
-typedef struct HC128 {
-    word32 T[1024];             /* P[i] = T[i];  Q[i] = T[1024 + i ]; */
-    word32 X[16];
-    word32 Y[16];
-    word32 counter1024;         /* counter1024 = i mod 1024 at the ith step */
-    word32 key[8];
-    word32 iv[8];
-} HC128;
-
-
-WOLFSSL_API int wc_Hc128_Process(HC128*, byte*, const byte*, word32);
-WOLFSSL_API int wc_Hc128_SetKey(HC128*, const byte* key, const byte* iv);
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* HAVE_HC128 */
-#endif /* WOLF_CRYPT_HC128_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/hmac.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/hmac.h
deleted file mode 100755
index 2be5afc..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/hmac.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/* hmac.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef NO_HMAC
-
-#ifndef WOLF_CRYPT_HMAC_H
-#define WOLF_CRYPT_HMAC_H
-
-#include 
-
-#ifndef NO_MD5
-    #include 
-#endif
-
-#ifndef NO_SHA
-    #include 
-#endif
-
-#ifndef NO_SHA256
-    #include 
-#endif
-
-#ifdef WOLFSSL_SHA512
-    #include 
-#endif
-
-#ifdef HAVE_BLAKE2
-    #include 
-#endif
-
-#ifdef HAVE_FIPS
-/* for fips */
-    #include 
-#endif
-
-#ifdef HAVE_CAVIUM
-    #include 
-    #include "cavium_common.h"
-#endif
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-#ifndef HAVE_FIPS
-#define WOLFSSL_HMAC_CAVIUM_MAGIC 0xBEEF0005
-
-enum {
-    HMAC_FIPS_MIN_KEY = 14,   /* 112 bit key length minimum */
-
-    IPAD    = 0x36,
-    OPAD    = 0x5C,
-
-/* If any hash is not enabled, add the ID here. */
-#ifdef NO_MD5
-    MD5     = 0,
-#endif
-#ifdef NO_SHA
-    SHA     = 1,
-#endif
-#ifdef NO_SHA256
-    SHA256  = 2,
-#endif
-#ifndef WOLFSSL_SHA512
-    SHA512  = 4,
-#endif
-#ifndef WOLFSSL_SHA384
-    SHA384  = 5,
-#endif
-#ifndef HAVE_BLAKE2
-    BLAKE2B_ID = 7,
-#endif
-
-/* Select the largest available hash for the buffer size. */
-#if defined(WOLFSSL_SHA512)
-    MAX_DIGEST_SIZE = SHA512_DIGEST_SIZE,
-    HMAC_BLOCK_SIZE = SHA512_BLOCK_SIZE
-#elif defined(HAVE_BLAKE2)
-    MAX_DIGEST_SIZE = BLAKE2B_OUTBYTES,
-    HMAC_BLOCK_SIZE = BLAKE2B_BLOCKBYTES,
-#elif defined(WOLFSSL_SHA384)
-    MAX_DIGEST_SIZE = SHA384_DIGEST_SIZE,
-    HMAC_BLOCK_SIZE = SHA384_BLOCK_SIZE
-#elif !defined(NO_SHA256)
-    MAX_DIGEST_SIZE = SHA256_DIGEST_SIZE,
-    HMAC_BLOCK_SIZE = SHA256_BLOCK_SIZE
-#elif !defined(NO_SHA)
-    MAX_DIGEST_SIZE = SHA_DIGEST_SIZE,
-    HMAC_BLOCK_SIZE = SHA_BLOCK_SIZE
-#elif !defined(NO_MD5)
-    MAX_DIGEST_SIZE = MD5_DIGEST_SIZE,
-    HMAC_BLOCK_SIZE = MD5_BLOCK_SIZE
-#else
-    #error "You have to have some kind of hash if you want to use HMAC."
-#endif
-};
-
-
-/* hash union */
-typedef union {
-    #ifndef NO_MD5
-        Md5 md5;
-    #endif
-    #ifndef NO_SHA
-        Sha sha;
-    #endif
-    #ifndef NO_SHA256
-        Sha256 sha256;
-    #endif
-    #ifdef WOLFSSL_SHA384
-        Sha384 sha384;
-    #endif
-    #ifdef WOLFSSL_SHA512
-        Sha512 sha512;
-    #endif
-    #ifdef HAVE_BLAKE2
-        Blake2b blake2b;
-    #endif
-} Hash;
-
-/* Hmac digest */
-typedef struct Hmac {
-    Hash    hash;
-    word32  ipad[HMAC_BLOCK_SIZE  / sizeof(word32)];  /* same block size all*/
-    word32  opad[HMAC_BLOCK_SIZE  / sizeof(word32)];
-    word32  innerHash[MAX_DIGEST_SIZE / sizeof(word32)];
-    byte    macType;                                     /* md5 sha or sha256 */
-    byte    innerHashKeyed;                              /* keyed flag */
-#ifdef HAVE_CAVIUM
-    word16   keyLen;          /* hmac key length */
-    word16   dataLen;
-    HashType type;            /* hmac key type */
-    int      devId;           /* nitrox device id */
-    word32   magic;           /* using cavium magic */
-    word64   contextHandle;   /* nitrox context memory handle */
-    byte*    data;            /* buffered input data for one call */
-#endif
-} Hmac;
-
-#endif /* HAVE_FIPS */
-
-/* does init */
-WOLFSSL_API int wc_HmacSetKey(Hmac*, int type, const byte* key, word32 keySz);
-WOLFSSL_API int wc_HmacUpdate(Hmac*, const byte*, word32);
-WOLFSSL_API int wc_HmacFinal(Hmac*, byte*);
-
-#ifdef HAVE_CAVIUM
-    WOLFSSL_API int  wc_HmacInitCavium(Hmac*, int);
-    WOLFSSL_API void wc_HmacFreeCavium(Hmac*);
-#endif
-
-WOLFSSL_API int wolfSSL_GetHmacMaxSize(void);
-
-
-#ifdef HAVE_HKDF
-
-WOLFSSL_API int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
-                    const byte* salt, word32 saltSz,
-                    const byte* info, word32 infoSz,
-                    byte* out, word32 outSz);
-
-#endif /* HAVE_HKDF */
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* WOLF_CRYPT_HMAC_H */
-
-#endif /* NO_HMAC */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/include.am b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/include.am
deleted file mode 100755
index 1f3a726..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/include.am
+++ /dev/null
@@ -1,59 +0,0 @@
-# vim:ft=automake
-# All paths should be given relative to the root
-
-nobase_include_HEADERS+= \
-                         wolfssl/wolfcrypt/aes.h \
-                         wolfssl/wolfcrypt/arc4.h \
-                         wolfssl/wolfcrypt/asn.h \
-                         wolfssl/wolfcrypt/asn_public.h \
-                         wolfssl/wolfcrypt/poly1305.h \
-                         wolfssl/wolfcrypt/camellia.h \
-                         wolfssl/wolfcrypt/coding.h \
-                         wolfssl/wolfcrypt/compress.h \
-                         wolfssl/wolfcrypt/des3.h \
-                         wolfssl/wolfcrypt/dh.h \
-                         wolfssl/wolfcrypt/dsa.h \
-                         wolfssl/wolfcrypt/ecc.h \
-                         wolfssl/wolfcrypt/curve25519.h \
-                         wolfssl/wolfcrypt/ed25519.h \
-                         wolfssl/wolfcrypt/fe_operations.h \
-                         wolfssl/wolfcrypt/ge_operations.h \
-                         wolfssl/wolfcrypt/error-crypt.h \
-                         wolfssl/wolfcrypt/fips_test.h \
-                         wolfssl/wolfcrypt/hash.h \
-                         wolfssl/wolfcrypt/hc128.h \
-                         wolfssl/wolfcrypt/hmac.h \
-                         wolfssl/wolfcrypt/integer.h \
-                         wolfssl/wolfcrypt/md2.h \
-                         wolfssl/wolfcrypt/md4.h \
-                         wolfssl/wolfcrypt/md5.h \
-                         wolfssl/wolfcrypt/misc.h \
-                         wolfssl/wolfcrypt/pkcs7.h \
-                         wolfssl/wolfcrypt/wc_port.h \
-                         wolfssl/wolfcrypt/pwdbased.h \
-                         wolfssl/wolfcrypt/rabbit.h \
-                         wolfssl/wolfcrypt/chacha.h \
-                         wolfssl/wolfcrypt/chacha20_poly1305.h \
-                         wolfssl/wolfcrypt/random.h \
-                         wolfssl/wolfcrypt/ripemd.h \
-                         wolfssl/wolfcrypt/rsa.h \
-                         wolfssl/wolfcrypt/settings.h \
-                         wolfssl/wolfcrypt/sha256.h \
-                         wolfssl/wolfcrypt/sha512.h \
-                         wolfssl/wolfcrypt/sha.h \
-                         wolfssl/wolfcrypt/blake2.h \
-                         wolfssl/wolfcrypt/blake2-int.h \
-                         wolfssl/wolfcrypt/blake2-impl.h \
-                         wolfssl/wolfcrypt/tfm.h \
-                         wolfssl/wolfcrypt/types.h \
-                         wolfssl/wolfcrypt/visibility.h \
-                         wolfssl/wolfcrypt/logging.h \
-                         wolfssl/wolfcrypt/memory.h \
-                         wolfssl/wolfcrypt/mpi_class.h \
-                         wolfssl/wolfcrypt/mpi_superclass.h
-
-noinst_HEADERS+= \
-                         wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h \
-                         wolfssl/wolfcrypt/port/ti/ti-hash.h \
-                         wolfssl/wolfcrypt/port/ti/ti-ccm.h
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/integer.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/integer.h
deleted file mode 100755
index b623298..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/integer.h
+++ /dev/null
@@ -1,324 +0,0 @@
-/* integer.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/*
- * Based on public domain LibTomMath 0.38 by Tom St Denis, tomstdenis@iahu.ca,
- * http://math.libtomcrypt.com
- */
-
-
-#ifndef WOLF_CRYPT_INTEGER_H
-#define WOLF_CRYPT_INTEGER_H
-
-/* may optionally use fast math instead, not yet supported on all platforms and
-   may not be faster on all
-*/
-#include        /* will set MP_xxBIT if not default */
-#ifdef USE_FAST_MATH
-    #include 
-#else
-
-#ifndef CHAR_BIT
-    #include 
-#endif
-
-#include 
-
-#ifndef MIN
-   #define MIN(x,y) ((x)<(y)?(x):(y))
-#endif
-
-#ifndef MAX
-   #define MAX(x,y) ((x)>(y)?(x):(y))
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-
-/* C++ compilers don't like assigning void * to mp_digit * */
-#define  OPT_CAST(x)  (x *)
-
-#else
-
-/* C on the other hand doesn't care */
-#define  OPT_CAST(x)
-
-#endif
-
-
-/* detect 64-bit mode if possible */
-#if defined(__x86_64__)
-   #if !(defined(MP_64BIT) && defined(MP_16BIT) && defined(MP_8BIT))
-      #define MP_64BIT
-   #endif
-#endif
-/* if intel compiler doesn't provide 128 bit type don't turn on 64bit */
-#if defined(MP_64BIT) && defined(__INTEL_COMPILER) && !defined(HAVE___UINT128_T)
-    #undef MP_64BIT
-#endif
-
-/* some default configurations.
- *
- * A "mp_digit" must be able to hold DIGIT_BIT + 1 bits
- * A "mp_word" must be able to hold 2*DIGIT_BIT + 1 bits
- *
- * At the very least a mp_digit must be able to hold 7 bits
- * [any size beyond that is ok provided it doesn't overflow the data type]
- */
-#ifdef MP_8BIT
-   typedef unsigned char      mp_digit;
-   typedef unsigned short     mp_word;
-#elif defined(MP_16BIT) || defined(NO_64BIT)
-   typedef unsigned short     mp_digit;
-   typedef unsigned int       mp_word;
-#elif defined(MP_64BIT)
-   /* for GCC only on supported platforms */
-   typedef unsigned long long mp_digit;  /* 64 bit type, 128 uses mode(TI) */
-   typedef unsigned long      mp_word __attribute__ ((mode(TI)));
-
-   #define DIGIT_BIT          60
-#else
-   /* this is the default case, 28-bit digits */
-
-   #if defined(_MSC_VER) || defined(__BORLANDC__)
-      typedef unsigned __int64   ulong64;
-   #else
-      typedef unsigned long long ulong64;
-   #endif
-
-   typedef unsigned int       mp_digit;  /* long could be 64 now, changed TAO */
-   typedef ulong64            mp_word;
-
-#ifdef MP_31BIT
-   /* this is an extension that uses 31-bit digits */
-   #define DIGIT_BIT          31
-#else
-   /* default case is 28-bit digits, defines MP_28BIT as a handy test macro */
-   #define DIGIT_BIT          28
-   #define MP_28BIT
-#endif
-#endif
-
-
-/* otherwise the bits per digit is calculated automatically from the size of
-   a mp_digit */
-#ifndef DIGIT_BIT
-   #define DIGIT_BIT ((int)((CHAR_BIT * sizeof(mp_digit) - 1)))
-      /* bits per digit */
-#endif
-
-#define MP_DIGIT_BIT     DIGIT_BIT
-#define MP_MASK          ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1))
-#define MP_DIGIT_MAX     MP_MASK
-
-/* equalities */
-#define MP_LT        -1   /* less than */
-#define MP_EQ         0   /* equal to */
-#define MP_GT         1   /* greater than */
-
-#define MP_ZPOS       0   /* positive integer */
-#define MP_NEG        1   /* negative */
-
-#define MP_OKAY       0   /* ok result */
-#define MP_MEM        -2  /* out of mem */
-#define MP_VAL        -3  /* invalid input */
-#define MP_RANGE      MP_VAL
-
-#define MP_YES        1   /* yes response */
-#define MP_NO         0   /* no response */
-
-/* Primality generation flags */
-#define LTM_PRIME_BBS      0x0001 /* BBS style prime */
-#define LTM_PRIME_SAFE     0x0002 /* Safe prime (p-1)/2 == prime */
-#define LTM_PRIME_2MSB_ON  0x0008 /* force 2nd MSB to 1 */
-
-typedef int           mp_err;
-
-/* define this to use lower memory usage routines (exptmods mostly) */
-#define MP_LOW_MEM
-
-/* default precision */
-#ifndef MP_PREC
-   #ifndef MP_LOW_MEM
-      #define MP_PREC                 32     /* default digits of precision */
-   #else
-      #define MP_PREC                 1      /* default digits of precision */
-   #endif
-#endif
-
-/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD -
-   BITS_PER_DIGIT*2) */
-#define MP_WARRAY  (1 << (sizeof(mp_word) * CHAR_BIT - 2 * DIGIT_BIT + 1))
-
-/* the infamous mp_int structure */
-typedef struct  {
-    int used, alloc, sign;
-    mp_digit *dp;
-} mp_int;
-
-/* callback for mp_prime_random, should fill dst with random bytes and return
-   how many read [upto len] */
-typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat);
-
-
-#define USED(m)    ((m)->used)
-#define DIGIT(m,k) ((m)->dp[(k)])
-#define SIGN(m)    ((m)->sign)
-
-
-/* ---> Basic Manipulations <--- */
-#define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
-#define mp_iseven(a) \
-    (((a)->used > 0 && (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO)
-#define mp_isodd(a) \
-    (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO)
-
-
-/* number of primes */
-#ifdef MP_8BIT
-   #define PRIME_SIZE      31
-#else
-   #define PRIME_SIZE      256
-#endif
-
-#define mp_prime_random(a, t, size, bbs, cb, dat) \
-   mp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?LTM_PRIME_BBS:0, cb, dat)
-
-#define mp_read_raw(mp, str, len) mp_read_signed_bin((mp), (str), (len))
-#define mp_raw_size(mp)           mp_signed_bin_size(mp)
-#define mp_toraw(mp, str)         mp_to_signed_bin((mp), (str))
-#define mp_read_mag(mp, str, len) mp_read_unsigned_bin((mp), (str), (len))
-#define mp_mag_size(mp)           mp_unsigned_bin_size(mp)
-#define mp_tomag(mp, str)         mp_to_unsigned_bin((mp), (str))
-
-#define mp_tobinary(M, S)  mp_toradix((M), (S), 2)
-#define mp_tooctal(M, S)   mp_toradix((M), (S), 8)
-#define mp_todecimal(M, S) mp_toradix((M), (S), 10)
-#define mp_tohex(M, S)     mp_toradix((M), (S), 16)
-
-#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
-
-extern const char *mp_s_rmap;
-
-/* 6 functions needed by Rsa */
-int  mp_init (mp_int * a);
-void mp_clear (mp_int * a);
-int  mp_unsigned_bin_size(mp_int * a);
-int  mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c);
-int  mp_to_unsigned_bin (mp_int * a, unsigned char *b);
-int  mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y);
-/* end functions needed by Rsa */
-
-/* functions added to support above needed, removed TOOM and KARATSUBA */
-int  mp_count_bits (mp_int * a);
-int  mp_leading_bit (mp_int * a);
-int  mp_init_copy (mp_int * a, mp_int * b);
-int  mp_copy (mp_int * a, mp_int * b);
-int  mp_grow (mp_int * a, int size);
-int  mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d);
-void mp_zero (mp_int * a);
-void mp_clamp (mp_int * a);
-void mp_exch (mp_int * a, mp_int * b);
-void mp_rshd (mp_int * a, int b);
-void mp_rshb (mp_int * a, int b);
-int  mp_mod_2d (mp_int * a, int b, mp_int * c);
-int  mp_mul_2d (mp_int * a, int b, mp_int * c);
-int  mp_lshd (mp_int * a, int b);
-int  mp_abs (mp_int * a, mp_int * b);
-int  mp_invmod (mp_int * a, mp_int * b, mp_int * c);
-int  fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c);
-int  mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c);
-int  mp_cmp_mag (mp_int * a, mp_int * b);
-int  mp_cmp (mp_int * a, mp_int * b);
-int  mp_cmp_d(mp_int * a, mp_digit b);
-void mp_set (mp_int * a, mp_digit b);
-int  mp_mod (mp_int * a, mp_int * b, mp_int * c);
-int  mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d);
-int  mp_div_2(mp_int * a, mp_int * b);
-int  mp_add (mp_int * a, mp_int * b, mp_int * c);
-int  s_mp_add (mp_int * a, mp_int * b, mp_int * c);
-int  s_mp_sub (mp_int * a, mp_int * b, mp_int * c);
-int  mp_sub (mp_int * a, mp_int * b, mp_int * c);
-int  mp_reduce_is_2k_l(mp_int *a);
-int  mp_reduce_is_2k(mp_int *a);
-int  mp_dr_is_modulus(mp_int *a);
-int  mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int);
-int  mp_montgomery_setup (mp_int * n, mp_digit * rho);
-int  fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho);
-int  mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho);
-void mp_dr_setup(mp_int *a, mp_digit *d);
-int  mp_dr_reduce (mp_int * x, mp_int * n, mp_digit k);
-int  mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d);
-int  fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
-int  s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
-int  mp_reduce_2k_setup_l(mp_int *a, mp_int *d);
-int  mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d);
-int  mp_reduce (mp_int * x, mp_int * m, mp_int * mu);
-int  mp_reduce_setup (mp_int * a, mp_int * b);
-int  s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode);
-int  mp_montgomery_calc_normalization (mp_int * a, mp_int * b);
-int  s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
-int  s_mp_sqr (mp_int * a, mp_int * b);
-int  fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
-int  fast_s_mp_sqr (mp_int * a, mp_int * b);
-int  mp_init_size (mp_int * a, int size);
-int  mp_div_3 (mp_int * a, mp_int *c, mp_digit * d);
-int  mp_mul_2(mp_int * a, mp_int * b);
-int  mp_mul (mp_int * a, mp_int * b, mp_int * c);
-int  mp_sqr (mp_int * a, mp_int * b);
-int  mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d);
-int  mp_mul_d (mp_int * a, mp_digit b, mp_int * c);
-int  mp_2expt (mp_int * a, int b);
-int  mp_reduce_2k_setup(mp_int *a, mp_digit *d);
-int  mp_add_d (mp_int* a, mp_digit b, mp_int* c);
-int mp_set_int (mp_int * a, unsigned long b);
-int mp_sub_d (mp_int * a, mp_digit b, mp_int * c);
-/* end support added functions */
-
-/* added */
-int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e,
-                  mp_int* f);
-
-#if defined(HAVE_ECC) || defined(WOLFSSL_KEY_GEN)
-    int mp_sqrmod(mp_int* a, mp_int* b, mp_int* c);
-#endif
-#ifdef HAVE_ECC
-    int mp_read_radix(mp_int* a, const char* str, int radix);
-#endif
-
-#ifdef WOLFSSL_KEY_GEN
-    int mp_prime_is_prime (mp_int * a, int t, int *result);
-    int mp_gcd (mp_int * a, mp_int * b, mp_int * c);
-    int mp_lcm (mp_int * a, mp_int * b, mp_int * c);
-#endif
-
-int mp_cnt_lsb(mp_int *a);
-int mp_mod_d(mp_int* a, mp_digit b, mp_digit* c);
-
-#ifdef __cplusplus
-   }
-#endif
-
-
-#endif /* USE_FAST_MATH */
-
-#endif  /* WOLF_CRYPT_INTEGER_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/logging.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/logging.h
deleted file mode 100755
index 0b12483..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/logging.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* logging.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/* submitted by eof */
-
-
-#ifndef WOLFSSL_LOGGING_H
-#define WOLFSSL_LOGGING_H
-
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-enum  CYA_Log_Levels {
-    ERROR_LOG = 0,
-    INFO_LOG,
-    ENTER_LOG,
-    LEAVE_LOG,
-    OTHER_LOG
-};
-
-typedef void (*wolfSSL_Logging_cb)(const int logLevel,
-                                  const char *const logMessage);
-
-WOLFSSL_API int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb log_function);
-
-#ifdef DEBUG_WOLFSSL
-
-    void WOLFSSL_ENTER(const char* msg);
-    void WOLFSSL_LEAVE(const char* msg, int ret);
-
-    void WOLFSSL_ERROR(int);
-    void WOLFSSL_MSG(const char* msg);
-
-#else /* DEBUG_WOLFSSL   */
-
-    #define WOLFSSL_ENTER(m)
-    #define WOLFSSL_LEAVE(m, r)
-
-    #define WOLFSSL_ERROR(e)
-    #define WOLFSSL_MSG(m)
-
-#endif /* DEBUG_WOLFSSL  */
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* WOLFSSL_LOGGING_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/md2.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/md2.h
deleted file mode 100755
index d494078..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/md2.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* md2.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_MD2_H
-#define WOLF_CRYPT_MD2_H
-
-#include 
-
-#ifdef WOLFSSL_MD2
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-/* in bytes */
-enum {
-    MD2             =  6,    /* hash type unique */
-    MD2_BLOCK_SIZE  = 16,
-    MD2_DIGEST_SIZE = 16,
-    MD2_PAD_SIZE    = 16,
-    MD2_X_SIZE      = 48
-};
-
-
-/* Md2 digest */
-typedef struct Md2 {
-    word32  count;   /* bytes % PAD_SIZE  */
-    byte    X[MD2_X_SIZE];
-    byte    C[MD2_BLOCK_SIZE];
-    byte    buffer[MD2_BLOCK_SIZE];
-} Md2;
-
-
-WOLFSSL_API void wc_InitMd2(Md2*);
-WOLFSSL_API void wc_Md2Update(Md2*, const byte*, word32);
-WOLFSSL_API void wc_Md2Final(Md2*, byte*);
-WOLFSSL_API int  wc_Md2Hash(const byte*, word32, byte*);
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* WOLFSSL_MD2 */
-#endif /* WOLF_CRYPT_MD2_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/md4.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/md4.h
deleted file mode 100755
index 369e15b..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/md4.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* md4.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_MD4_H
-#define WOLF_CRYPT_MD4_H
-
-#include 
-
-#ifndef NO_MD4
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-/* in bytes */
-enum {
-    MD4_BLOCK_SIZE  = 64,
-    MD4_DIGEST_SIZE = 16,
-    MD4_PAD_SIZE    = 56
-};
-
-
-/* MD4 digest */
-typedef struct Md4 {
-    word32  buffLen;   /* in bytes          */
-    word32  loLen;     /* length in bytes   */
-    word32  hiLen;     /* length in bytes   */
-    word32  digest[MD4_DIGEST_SIZE / sizeof(word32)];
-    word32  buffer[MD4_BLOCK_SIZE  / sizeof(word32)];
-} Md4;
-
-
-WOLFSSL_API void wc_InitMd4(Md4*);
-WOLFSSL_API void wc_Md4Update(Md4*, const byte*, word32);
-WOLFSSL_API void wc_Md4Final(Md4*, byte*);
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* NO_MD4 */
-#endif /* WOLF_CRYPT_MD4_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/md5.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/md5.h
deleted file mode 100755
index d0b134b..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/md5.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* md5.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_MD5_H
-#define WOLF_CRYPT_MD5_H
-
-#include 
-
-#ifndef NO_MD5
-
-#ifdef HAVE_FIPS
-    #define wc_InitMd5   InitMd5
-    #define wc_Md5Update Md5Update
-    #define wc_Md5Final  Md5Final
-    #define wc_Md5Hash   Md5Hash
-#endif
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-/* in bytes */
-enum {
-#ifdef STM32F2_HASH
-    MD5_REG_SIZE    =  4,      /* STM32 register size, bytes */
-#endif
-    MD5             =  0,      /* hash type unique */
-    MD5_BLOCK_SIZE  = 64,
-    MD5_DIGEST_SIZE = 16,
-    MD5_PAD_SIZE    = 56
-};
-
-#if defined(WOLFSSL_PIC32MZ_HASH)
-#include "port/pic32/pic32mz-crypt.h"
-#endif
-
-#ifndef WOLFSSL_TI_HASH
-
-/* MD5 digest */
-typedef struct Md5 {
-    word32  buffLen;   /* in bytes          */
-    word32  loLen;     /* length in bytes   */
-    word32  hiLen;     /* length in bytes   */
-    word32  buffer[MD5_BLOCK_SIZE  / sizeof(word32)];
-    #if !defined(WOLFSSL_PIC32MZ_HASH)
-    word32  digest[MD5_DIGEST_SIZE / sizeof(word32)];
-    #else
-    word32  digest[PIC32_HASH_SIZE / sizeof(word32)];
-    pic32mz_desc desc ; /* Crypt Engine descripter */
-    #endif
-} Md5;
-
-#else /* WOLFSSL_TI_HASH */
-    #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
-#endif
-
-WOLFSSL_API void wc_InitMd5(Md5*);
-WOLFSSL_API void wc_Md5Update(Md5*, const byte*, word32);
-WOLFSSL_API void wc_Md5Final(Md5*, byte*);
-WOLFSSL_API int  wc_Md5Hash(const byte*, word32, byte*);
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* NO_MD5 */
-#endif /* WOLF_CRYPT_MD5_H */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/memory.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/memory.h
deleted file mode 100755
index 3968b35..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/memory.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* memory.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/* submitted by eof */
-
-
-#ifndef WOLFSSL_MEMORY_H
-#define WOLFSSL_MEMORY_H
-
-#include 
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-typedef void *(*wolfSSL_Malloc_cb)(size_t size);
-typedef void (*wolfSSL_Free_cb)(void *ptr);
-typedef void *(*wolfSSL_Realloc_cb)(void *ptr, size_t size);
-
-
-/* Public set function */
-WOLFSSL_API int wolfSSL_SetAllocators(wolfSSL_Malloc_cb  malloc_function,
-                                    wolfSSL_Free_cb    free_function,
-                                    wolfSSL_Realloc_cb realloc_function);
-
-/* Public in case user app wants to use XMALLOC/XFREE */
-WOLFSSL_API void* wolfSSL_Malloc(size_t size);
-WOLFSSL_API void  wolfSSL_Free(void *ptr);
-WOLFSSL_API void* wolfSSL_Realloc(void *ptr, size_t size);
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */
-#endif
-
-#endif /* WOLFSSL_MEMORY_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/misc.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/misc.h
deleted file mode 100755
index 78c7fbd..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/misc.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* misc.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLF_CRYPT_MISC_H
-#define WOLF_CRYPT_MISC_H
-
-
-#include 
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-#ifdef NO_INLINE
-WOLFSSL_LOCAL
-word32 rotlFixed(word32, word32);
-WOLFSSL_LOCAL
-word32 rotrFixed(word32, word32);
-
-WOLFSSL_LOCAL
-word32 ByteReverseWord32(word32);
-WOLFSSL_LOCAL
-void   ByteReverseWords(word32*, const word32*, word32);
-
-WOLFSSL_LOCAL
-void XorWords(wolfssl_word*, const wolfssl_word*, word32);
-WOLFSSL_LOCAL
-void xorbuf(void*, const void*, word32);
-
-WOLFSSL_LOCAL
-void ForceZero(const void*, word32);
-
-WOLFSSL_LOCAL
-int ConstantCompare(const byte*, const byte*, int);
-
-#ifdef WORD64_AVAILABLE
-WOLFSSL_LOCAL
-word64 rotlFixed64(word64, word64);
-WOLFSSL_LOCAL
-word64 rotrFixed64(word64, word64);
-
-WOLFSSL_LOCAL
-word64 ByteReverseWord64(word64);
-WOLFSSL_LOCAL
-void   ByteReverseWords64(word64*, const word64*, word32);
-#endif /* WORD64_AVAILABLE */
-
-#endif /* NO_INLINE */
-
-
-#ifdef __cplusplus
-    }   /* extern "C" */
-#endif
-
-
-#endif /* WOLF_CRYPT_MISC_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/mpi_class.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/mpi_class.h
deleted file mode 100755
index 334a7a4..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/mpi_class.h
+++ /dev/null
@@ -1,1018 +0,0 @@
-/* mpi_class.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#if !(defined(LTM1) && defined(LTM2) && defined(LTM3))
-#if defined(LTM2)
-#define LTM3
-#endif
-#if defined(LTM1)
-#define LTM2
-#endif
-#define LTM1
-
-#if defined(LTM_ALL)
-#define BN_ERROR_C
-#define BN_FAST_MP_INVMOD_C
-#define BN_FAST_MP_MONTGOMERY_REDUCE_C
-#define BN_FAST_S_MP_MUL_DIGS_C
-#define BN_FAST_S_MP_MUL_HIGH_DIGS_C
-#define BN_FAST_S_MP_SQR_C
-#define BN_MP_2EXPT_C
-#define BN_MP_ABS_C
-#define BN_MP_ADD_C
-#define BN_MP_ADD_D_C
-#define BN_MP_ADDMOD_C
-#define BN_MP_AND_C
-#define BN_MP_CLAMP_C
-#define BN_MP_CLEAR_C
-#define BN_MP_CLEAR_MULTI_C
-#define BN_MP_CMP_C
-#define BN_MP_CMP_D_C
-#define BN_MP_CMP_MAG_C
-#define BN_MP_CNT_LSB_C
-#define BN_MP_COPY_C
-#define BN_MP_COUNT_BITS_C
-#define BN_MP_DIV_C
-#define BN_MP_DIV_2_C
-#define BN_MP_DIV_2D_C
-#define BN_MP_DIV_3_C
-#define BN_MP_DIV_D_C
-#define BN_MP_DR_IS_MODULUS_C
-#define BN_MP_DR_REDUCE_C
-#define BN_MP_DR_SETUP_C
-#define BN_MP_EXCH_C
-#define BN_MP_EXPT_D_C
-#define BN_MP_EXPTMOD_C
-#define BN_MP_EXPTMOD_FAST_C
-#define BN_MP_EXTEUCLID_C
-#define BN_MP_FREAD_C
-#define BN_MP_FWRITE_C
-#define BN_MP_GCD_C
-#define BN_MP_GET_INT_C
-#define BN_MP_GROW_C
-#define BN_MP_INIT_C
-#define BN_MP_INIT_COPY_C
-#define BN_MP_INIT_MULTI_C
-#define BN_MP_INIT_SET_C
-#define BN_MP_INIT_SET_INT_C
-#define BN_MP_INIT_SIZE_C
-#define BN_MP_INVMOD_C
-#define BN_MP_INVMOD_SLOW_C
-#define BN_MP_IS_SQUARE_C
-#define BN_MP_JACOBI_C
-#define BN_MP_KARATSUBA_MUL_C
-#define BN_MP_KARATSUBA_SQR_C
-#define BN_MP_LCM_C
-#define BN_MP_LSHD_C
-#define BN_MP_MOD_C
-#define BN_MP_MOD_2D_C
-#define BN_MP_MOD_D_C
-#define BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
-#define BN_MP_MONTGOMERY_REDUCE_C
-#define BN_MP_MONTGOMERY_SETUP_C
-#define BN_MP_MUL_C
-#define BN_MP_MUL_2_C
-#define BN_MP_MUL_2D_C
-#define BN_MP_MUL_D_C
-#define BN_MP_MULMOD_C
-#define BN_MP_N_ROOT_C
-#define BN_MP_NEG_C
-#define BN_MP_OR_C
-#define BN_MP_PRIME_FERMAT_C
-#define BN_MP_PRIME_IS_DIVISIBLE_C
-#define BN_MP_PRIME_IS_PRIME_C
-#define BN_MP_PRIME_MILLER_RABIN_C
-#define BN_MP_PRIME_NEXT_PRIME_C
-#define BN_MP_PRIME_RABIN_MILLER_TRIALS_C
-#define BN_MP_PRIME_RANDOM_EX_C
-#define BN_MP_RADIX_SIZE_C
-#define BN_MP_RADIX_SMAP_C
-#define BN_MP_RAND_C
-#define BN_MP_READ_RADIX_C
-#define BN_MP_READ_SIGNED_BIN_C
-#define BN_MP_READ_UNSIGNED_BIN_C
-#define BN_MP_REDUCE_C
-#define BN_MP_REDUCE_2K_C
-#define BN_MP_REDUCE_2K_L_C
-#define BN_MP_REDUCE_2K_SETUP_C
-#define BN_MP_REDUCE_2K_SETUP_L_C
-#define BN_MP_REDUCE_IS_2K_C
-#define BN_MP_REDUCE_IS_2K_L_C
-#define BN_MP_REDUCE_SETUP_C
-#define BN_MP_RSHD_C
-#define BN_MP_SET_C
-#define BN_MP_SET_INT_C
-#define BN_MP_SHRINK_C
-#define BN_MP_SIGNED_BIN_SIZE_C
-#define BN_MP_SQR_C
-#define BN_MP_SQRMOD_C
-#define BN_MP_SQRT_C
-#define BN_MP_SUB_C
-#define BN_MP_SUB_D_C
-#define BN_MP_SUBMOD_C
-#define BN_MP_TO_SIGNED_BIN_C
-#define BN_MP_TO_SIGNED_BIN_N_C
-#define BN_MP_TO_UNSIGNED_BIN_C
-#define BN_MP_TO_UNSIGNED_BIN_N_C
-#define BN_MP_TOOM_MUL_C
-#define BN_MP_TOOM_SQR_C
-#define BN_MP_TORADIX_C
-#define BN_MP_TORADIX_N_C
-#define BN_MP_UNSIGNED_BIN_SIZE_C
-#define BN_MP_XOR_C
-#define BN_MP_ZERO_C
-#define BN_PRIME_TAB_C
-#define BN_REVERSE_C
-#define BN_S_MP_ADD_C
-#define BN_S_MP_EXPTMOD_C
-#define BN_S_MP_MUL_DIGS_C
-#define BN_S_MP_MUL_HIGH_DIGS_C
-#define BN_S_MP_SQR_C
-#define BN_S_MP_SUB_C
-#define BNCORE_C
-#endif
-
-#if defined(BN_ERROR_C)
-   #define BN_MP_ERROR_TO_STRING_C
-#endif
-
-#if defined(BN_FAST_MP_INVMOD_C)
-   #define BN_MP_ISEVEN_C
-   #define BN_MP_INIT_MULTI_C
-   #define BN_MP_COPY_C
-   #define BN_MP_MOD_C
-   #define BN_MP_SET_C
-   #define BN_MP_DIV_2_C
-   #define BN_MP_ISODD_C
-   #define BN_MP_SUB_C
-   #define BN_MP_CMP_C
-   #define BN_MP_ISZERO_C
-   #define BN_MP_CMP_D_C
-   #define BN_MP_ADD_C
-   #define BN_MP_EXCH_C
-   #define BN_MP_CLEAR_MULTI_C
-#endif
-
-#if defined(BN_FAST_MP_MONTGOMERY_REDUCE_C)
-   #define BN_MP_GROW_C
-   #define BN_MP_RSHD_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_CMP_MAG_C
-   #define BN_S_MP_SUB_C
-#endif
-
-#if defined(BN_FAST_S_MP_MUL_DIGS_C)
-   #define BN_MP_GROW_C
-   #define BN_MP_CLAMP_C
-#endif
-
-#if defined(BN_FAST_S_MP_MUL_HIGH_DIGS_C)
-   #define BN_MP_GROW_C
-   #define BN_MP_CLAMP_C
-#endif
-
-#if defined(BN_FAST_S_MP_SQR_C)
-   #define BN_MP_GROW_C
-   #define BN_MP_CLAMP_C
-#endif
-
-#if defined(BN_MP_2EXPT_C)
-   #define BN_MP_ZERO_C
-   #define BN_MP_GROW_C
-#endif
-
-#if defined(BN_MP_ABS_C)
-   #define BN_MP_COPY_C
-#endif
-
-#if defined(BN_MP_ADD_C)
-   #define BN_S_MP_ADD_C
-   #define BN_MP_CMP_MAG_C
-   #define BN_S_MP_SUB_C
-#endif
-
-#if defined(BN_MP_ADD_D_C)
-   #define BN_MP_GROW_C
-   #define BN_MP_SUB_D_C
-   #define BN_MP_CLAMP_C
-#endif
-
-#if defined(BN_MP_ADDMOD_C)
-   #define BN_MP_INIT_C
-   #define BN_MP_ADD_C
-   #define BN_MP_CLEAR_C
-   #define BN_MP_MOD_C
-#endif
-
-#if defined(BN_MP_AND_C)
-   #define BN_MP_INIT_COPY_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_EXCH_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_CLAMP_C)
-#endif
-
-#if defined(BN_MP_CLEAR_C)
-#endif
-
-#if defined(BN_MP_CLEAR_MULTI_C)
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_CMP_C)
-   #define BN_MP_CMP_MAG_C
-#endif
-
-#if defined(BN_MP_CMP_D_C)
-#endif
-
-#if defined(BN_MP_CMP_MAG_C)
-#endif
-
-#if defined(BN_MP_CNT_LSB_C)
-   #define BN_MP_ISZERO_C
-#endif
-
-#if defined(BN_MP_COPY_C)
-   #define BN_MP_GROW_C
-#endif
-
-#if defined(BN_MP_COUNT_BITS_C)
-#endif
-
-#if defined(BN_MP_DIV_C)
-   #define BN_MP_ISZERO_C
-   #define BN_MP_CMP_MAG_C
-   #define BN_MP_COPY_C
-   #define BN_MP_ZERO_C
-   #define BN_MP_INIT_MULTI_C
-   #define BN_MP_SET_C
-   #define BN_MP_COUNT_BITS_C
-   #define BN_MP_ABS_C
-   #define BN_MP_MUL_2D_C
-   #define BN_MP_CMP_C
-   #define BN_MP_SUB_C
-   #define BN_MP_ADD_C
-   #define BN_MP_DIV_2D_C
-   #define BN_MP_EXCH_C
-   #define BN_MP_CLEAR_MULTI_C
-   #define BN_MP_INIT_SIZE_C
-   #define BN_MP_INIT_C
-   #define BN_MP_INIT_COPY_C
-   #define BN_MP_LSHD_C
-   #define BN_MP_RSHD_C
-   #define BN_MP_MUL_D_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_DIV_2_C)
-   #define BN_MP_GROW_C
-   #define BN_MP_CLAMP_C
-#endif
-
-#if defined(BN_MP_DIV_2D_C)
-   #define BN_MP_COPY_C
-   #define BN_MP_ZERO_C
-   #define BN_MP_INIT_C
-   #define BN_MP_MOD_2D_C
-   #define BN_MP_CLEAR_C
-   #define BN_MP_RSHD_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_EXCH_C
-#endif
-
-#if defined(BN_MP_DIV_3_C)
-   #define BN_MP_INIT_SIZE_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_EXCH_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_DIV_D_C)
-   #define BN_MP_ISZERO_C
-   #define BN_MP_COPY_C
-   #define BN_MP_DIV_2D_C
-   #define BN_MP_DIV_3_C
-   #define BN_MP_INIT_SIZE_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_EXCH_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_DR_IS_MODULUS_C)
-#endif
-
-#if defined(BN_MP_DR_REDUCE_C)
-   #define BN_MP_GROW_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_CMP_MAG_C
-   #define BN_S_MP_SUB_C
-#endif
-
-#if defined(BN_MP_DR_SETUP_C)
-#endif
-
-#if defined(BN_MP_EXCH_C)
-#endif
-
-#if defined(BN_MP_EXPT_D_C)
-   #define BN_MP_INIT_COPY_C
-   #define BN_MP_SET_C
-   #define BN_MP_SQR_C
-   #define BN_MP_CLEAR_C
-   #define BN_MP_MUL_C
-#endif
-
-#if defined(BN_MP_EXPTMOD_C)
-   #define BN_MP_INIT_C
-   #define BN_MP_INVMOD_C
-   #define BN_MP_CLEAR_C
-   #define BN_MP_ABS_C
-   #define BN_MP_CLEAR_MULTI_C
-   #define BN_MP_REDUCE_IS_2K_L_C
-   #define BN_S_MP_EXPTMOD_C
-   #define BN_MP_DR_IS_MODULUS_C
-   #define BN_MP_REDUCE_IS_2K_C
-   #define BN_MP_ISODD_C
-   #define BN_MP_EXPTMOD_FAST_C
-#endif
-
-#if defined(BN_MP_EXPTMOD_FAST_C)
-   #define BN_MP_COUNT_BITS_C
-   #define BN_MP_INIT_C
-   #define BN_MP_CLEAR_C
-   #define BN_MP_MONTGOMERY_SETUP_C
-   #define BN_FAST_MP_MONTGOMERY_REDUCE_C
-   #define BN_MP_MONTGOMERY_REDUCE_C
-   #define BN_MP_DR_SETUP_C
-   #define BN_MP_DR_REDUCE_C
-   #define BN_MP_REDUCE_2K_SETUP_C
-   #define BN_MP_REDUCE_2K_C
-   #define BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
-   #define BN_MP_MULMOD_C
-   #define BN_MP_SET_C
-   #define BN_MP_MOD_C
-   #define BN_MP_COPY_C
-   #define BN_MP_SQR_C
-   #define BN_MP_MUL_C
-   #define BN_MP_EXCH_C
-#endif
-
-#if defined(BN_MP_EXTEUCLID_C)
-   #define BN_MP_INIT_MULTI_C
-   #define BN_MP_SET_C
-   #define BN_MP_COPY_C
-   #define BN_MP_ISZERO_C
-   #define BN_MP_DIV_C
-   #define BN_MP_MUL_C
-   #define BN_MP_SUB_C
-   #define BN_MP_NEG_C
-   #define BN_MP_EXCH_C
-   #define BN_MP_CLEAR_MULTI_C
-#endif
-
-#if defined(BN_MP_FREAD_C)
-   #define BN_MP_ZERO_C
-   #define BN_MP_S_RMAP_C
-   #define BN_MP_MUL_D_C
-   #define BN_MP_ADD_D_C
-   #define BN_MP_CMP_D_C
-#endif
-
-#if defined(BN_MP_FWRITE_C)
-   #define BN_MP_RADIX_SIZE_C
-   #define BN_MP_TORADIX_C
-#endif
-
-#if defined(BN_MP_GCD_C)
-   #define BN_MP_ISZERO_C
-   #define BN_MP_ABS_C
-   #define BN_MP_ZERO_C
-   #define BN_MP_INIT_COPY_C
-   #define BN_MP_CNT_LSB_C
-   #define BN_MP_DIV_2D_C
-   #define BN_MP_CMP_MAG_C
-   #define BN_MP_EXCH_C
-   #define BN_S_MP_SUB_C
-   #define BN_MP_MUL_2D_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_GET_INT_C)
-#endif
-
-#if defined(BN_MP_GROW_C)
-#endif
-
-#if defined(BN_MP_INIT_C)
-#endif
-
-#if defined(BN_MP_INIT_COPY_C)
-   #define BN_MP_COPY_C
-#endif
-
-#if defined(BN_MP_INIT_MULTI_C)
-   #define BN_MP_ERR_C
-   #define BN_MP_INIT_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_INIT_SET_C)
-   #define BN_MP_INIT_C
-   #define BN_MP_SET_C
-#endif
-
-#if defined(BN_MP_INIT_SET_INT_C)
-   #define BN_MP_INIT_C
-   #define BN_MP_SET_INT_C
-#endif
-
-#if defined(BN_MP_INIT_SIZE_C)
-   #define BN_MP_INIT_C
-#endif
-
-#if defined(BN_MP_INVMOD_C)
-   #define BN_MP_ISZERO_C
-   #define BN_MP_ISODD_C
-   #define BN_FAST_MP_INVMOD_C
-   #define BN_MP_INVMOD_SLOW_C
-#endif
-
-#if defined(BN_MP_INVMOD_SLOW_C)
-   #define BN_MP_ISZERO_C
-   #define BN_MP_INIT_MULTI_C
-   #define BN_MP_MOD_C
-   #define BN_MP_COPY_C
-   #define BN_MP_ISEVEN_C
-   #define BN_MP_SET_C
-   #define BN_MP_DIV_2_C
-   #define BN_MP_ISODD_C
-   #define BN_MP_ADD_C
-   #define BN_MP_SUB_C
-   #define BN_MP_CMP_C
-   #define BN_MP_CMP_D_C
-   #define BN_MP_CMP_MAG_C
-   #define BN_MP_EXCH_C
-   #define BN_MP_CLEAR_MULTI_C
-#endif
-
-#if defined(BN_MP_IS_SQUARE_C)
-   #define BN_MP_MOD_D_C
-   #define BN_MP_INIT_SET_INT_C
-   #define BN_MP_MOD_C
-   #define BN_MP_GET_INT_C
-   #define BN_MP_SQRT_C
-   #define BN_MP_SQR_C
-   #define BN_MP_CMP_MAG_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_JACOBI_C)
-   #define BN_MP_CMP_D_C
-   #define BN_MP_ISZERO_C
-   #define BN_MP_INIT_COPY_C
-   #define BN_MP_CNT_LSB_C
-   #define BN_MP_DIV_2D_C
-   #define BN_MP_MOD_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_KARATSUBA_MUL_C)
-   #define BN_MP_MUL_C
-   #define BN_MP_INIT_SIZE_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_SUB_C
-   #define BN_MP_ADD_C
-   #define BN_MP_LSHD_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_KARATSUBA_SQR_C)
-   #define BN_MP_INIT_SIZE_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_SQR_C
-   #define BN_MP_SUB_C
-   #define BN_S_MP_ADD_C
-   #define BN_MP_LSHD_C
-   #define BN_MP_ADD_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_LCM_C)
-   #define BN_MP_INIT_MULTI_C
-   #define BN_MP_GCD_C
-   #define BN_MP_CMP_MAG_C
-   #define BN_MP_DIV_C
-   #define BN_MP_MUL_C
-   #define BN_MP_CLEAR_MULTI_C
-#endif
-
-#if defined(BN_MP_LSHD_C)
-   #define BN_MP_GROW_C
-   #define BN_MP_RSHD_C
-#endif
-
-#if defined(BN_MP_MOD_C)
-   #define BN_MP_INIT_C
-   #define BN_MP_DIV_C
-   #define BN_MP_CLEAR_C
-   #define BN_MP_ADD_C
-   #define BN_MP_EXCH_C
-#endif
-
-#if defined(BN_MP_MOD_2D_C)
-   #define BN_MP_ZERO_C
-   #define BN_MP_COPY_C
-   #define BN_MP_CLAMP_C
-#endif
-
-#if defined(BN_MP_MOD_D_C)
-   #define BN_MP_DIV_D_C
-#endif
-
-#if defined(BN_MP_MONTGOMERY_CALC_NORMALIZATION_C)
-   #define BN_MP_COUNT_BITS_C
-   #define BN_MP_2EXPT_C
-   #define BN_MP_SET_C
-   #define BN_MP_MUL_2_C
-   #define BN_MP_CMP_MAG_C
-   #define BN_S_MP_SUB_C
-#endif
-
-#if defined(BN_MP_MONTGOMERY_REDUCE_C)
-   #define BN_FAST_MP_MONTGOMERY_REDUCE_C
-   #define BN_MP_GROW_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_RSHD_C
-   #define BN_MP_CMP_MAG_C
-   #define BN_S_MP_SUB_C
-#endif
-
-#if defined(BN_MP_MONTGOMERY_SETUP_C)
-#endif
-
-#if defined(BN_MP_MUL_C)
-   #define BN_MP_TOOM_MUL_C
-   #define BN_MP_KARATSUBA_MUL_C
-   #define BN_FAST_S_MP_MUL_DIGS_C
-   #define BN_S_MP_MUL_C
-   #define BN_S_MP_MUL_DIGS_C
-#endif
-
-#if defined(BN_MP_MUL_2_C)
-   #define BN_MP_GROW_C
-#endif
-
-#if defined(BN_MP_MUL_2D_C)
-   #define BN_MP_COPY_C
-   #define BN_MP_GROW_C
-   #define BN_MP_LSHD_C
-   #define BN_MP_CLAMP_C
-#endif
-
-#if defined(BN_MP_MUL_D_C)
-   #define BN_MP_GROW_C
-   #define BN_MP_CLAMP_C
-#endif
-
-#if defined(BN_MP_MULMOD_C)
-   #define BN_MP_INIT_C
-   #define BN_MP_MUL_C
-   #define BN_MP_CLEAR_C
-   #define BN_MP_MOD_C
-#endif
-
-#if defined(BN_MP_N_ROOT_C)
-   #define BN_MP_INIT_C
-   #define BN_MP_SET_C
-   #define BN_MP_COPY_C
-   #define BN_MP_EXPT_D_C
-   #define BN_MP_MUL_C
-   #define BN_MP_SUB_C
-   #define BN_MP_MUL_D_C
-   #define BN_MP_DIV_C
-   #define BN_MP_CMP_C
-   #define BN_MP_SUB_D_C
-   #define BN_MP_EXCH_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_NEG_C)
-   #define BN_MP_COPY_C
-   #define BN_MP_ISZERO_C
-#endif
-
-#if defined(BN_MP_OR_C)
-   #define BN_MP_INIT_COPY_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_EXCH_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_PRIME_FERMAT_C)
-   #define BN_MP_CMP_D_C
-   #define BN_MP_INIT_C
-   #define BN_MP_EXPTMOD_C
-   #define BN_MP_CMP_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_PRIME_IS_DIVISIBLE_C)
-   #define BN_MP_MOD_D_C
-#endif
-
-#if defined(BN_MP_PRIME_IS_PRIME_C)
-   #define BN_MP_CMP_D_C
-   #define BN_MP_PRIME_IS_DIVISIBLE_C
-   #define BN_MP_INIT_C
-   #define BN_MP_SET_C
-   #define BN_MP_PRIME_MILLER_RABIN_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_PRIME_MILLER_RABIN_C)
-   #define BN_MP_CMP_D_C
-   #define BN_MP_INIT_COPY_C
-   #define BN_MP_SUB_D_C
-   #define BN_MP_CNT_LSB_C
-   #define BN_MP_DIV_2D_C
-   #define BN_MP_EXPTMOD_C
-   #define BN_MP_CMP_C
-   #define BN_MP_SQRMOD_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_PRIME_NEXT_PRIME_C)
-   #define BN_MP_CMP_D_C
-   #define BN_MP_SET_C
-   #define BN_MP_SUB_D_C
-   #define BN_MP_ISEVEN_C
-   #define BN_MP_MOD_D_C
-   #define BN_MP_INIT_C
-   #define BN_MP_ADD_D_C
-   #define BN_MP_PRIME_MILLER_RABIN_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_PRIME_RABIN_MILLER_TRIALS_C)
-#endif
-
-#if defined(BN_MP_PRIME_RANDOM_EX_C)
-   #define BN_MP_READ_UNSIGNED_BIN_C
-   #define BN_MP_PRIME_IS_PRIME_C
-   #define BN_MP_SUB_D_C
-   #define BN_MP_DIV_2_C
-   #define BN_MP_MUL_2_C
-   #define BN_MP_ADD_D_C
-#endif
-
-#if defined(BN_MP_RADIX_SIZE_C)
-   #define BN_MP_COUNT_BITS_C
-   #define BN_MP_INIT_COPY_C
-   #define BN_MP_ISZERO_C
-   #define BN_MP_DIV_D_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_RADIX_SMAP_C)
-   #define BN_MP_S_RMAP_C
-#endif
-
-#if defined(BN_MP_RAND_C)
-   #define BN_MP_ZERO_C
-   #define BN_MP_ADD_D_C
-   #define BN_MP_LSHD_C
-#endif
-
-#if defined(BN_MP_READ_RADIX_C)
-   #define BN_MP_ZERO_C
-   #define BN_MP_S_RMAP_C
-   #define BN_MP_RADIX_SMAP_C
-   #define BN_MP_MUL_D_C
-   #define BN_MP_ADD_D_C
-   #define BN_MP_ISZERO_C
-#endif
-
-#if defined(BN_MP_READ_SIGNED_BIN_C)
-   #define BN_MP_READ_UNSIGNED_BIN_C
-#endif
-
-#if defined(BN_MP_READ_UNSIGNED_BIN_C)
-   #define BN_MP_GROW_C
-   #define BN_MP_ZERO_C
-   #define BN_MP_MUL_2D_C
-   #define BN_MP_CLAMP_C
-#endif
-
-#if defined(BN_MP_REDUCE_C)
-   #define BN_MP_REDUCE_SETUP_C
-   #define BN_MP_INIT_COPY_C
-   #define BN_MP_RSHD_C
-   #define BN_MP_MUL_C
-   #define BN_S_MP_MUL_HIGH_DIGS_C
-   #define BN_FAST_S_MP_MUL_HIGH_DIGS_C
-   #define BN_MP_MOD_2D_C
-   #define BN_S_MP_MUL_DIGS_C
-   #define BN_MP_SUB_C
-   #define BN_MP_CMP_D_C
-   #define BN_MP_SET_C
-   #define BN_MP_LSHD_C
-   #define BN_MP_ADD_C
-   #define BN_MP_CMP_C
-   #define BN_S_MP_SUB_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_REDUCE_2K_C)
-   #define BN_MP_INIT_C
-   #define BN_MP_COUNT_BITS_C
-   #define BN_MP_DIV_2D_C
-   #define BN_MP_MUL_D_C
-   #define BN_S_MP_ADD_C
-   #define BN_MP_CMP_MAG_C
-   #define BN_S_MP_SUB_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_REDUCE_2K_L_C)
-   #define BN_MP_INIT_C
-   #define BN_MP_COUNT_BITS_C
-   #define BN_MP_DIV_2D_C
-   #define BN_MP_MUL_C
-   #define BN_S_MP_ADD_C
-   #define BN_MP_CMP_MAG_C
-   #define BN_S_MP_SUB_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_REDUCE_2K_SETUP_C)
-   #define BN_MP_INIT_C
-   #define BN_MP_COUNT_BITS_C
-   #define BN_MP_2EXPT_C
-   #define BN_MP_CLEAR_C
-   #define BN_S_MP_SUB_C
-#endif
-
-#if defined(BN_MP_REDUCE_2K_SETUP_L_C)
-   #define BN_MP_INIT_C
-   #define BN_MP_2EXPT_C
-   #define BN_MP_COUNT_BITS_C
-   #define BN_S_MP_SUB_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_REDUCE_IS_2K_C)
-   #define BN_MP_REDUCE_2K_C
-   #define BN_MP_COUNT_BITS_C
-#endif
-
-#if defined(BN_MP_REDUCE_IS_2K_L_C)
-#endif
-
-#if defined(BN_MP_REDUCE_SETUP_C)
-   #define BN_MP_2EXPT_C
-   #define BN_MP_DIV_C
-#endif
-
-#if defined(BN_MP_RSHD_C)
-   #define BN_MP_ZERO_C
-#endif
-
-#if defined(BN_MP_SET_C)
-   #define BN_MP_ZERO_C
-#endif
-
-#if defined(BN_MP_SET_INT_C)
-   #define BN_MP_ZERO_C
-   #define BN_MP_MUL_2D_C
-   #define BN_MP_CLAMP_C
-#endif
-
-#if defined(BN_MP_SHRINK_C)
-#endif
-
-#if defined(BN_MP_SIGNED_BIN_SIZE_C)
-   #define BN_MP_UNSIGNED_BIN_SIZE_C
-#endif
-
-#if defined(BN_MP_SQR_C)
-   #define BN_MP_TOOM_SQR_C
-   #define BN_MP_KARATSUBA_SQR_C
-   #define BN_FAST_S_MP_SQR_C
-   #define BN_S_MP_SQR_C
-#endif
-
-#if defined(BN_MP_SQRMOD_C)
-   #define BN_MP_INIT_C
-   #define BN_MP_SQR_C
-   #define BN_MP_CLEAR_C
-   #define BN_MP_MOD_C
-#endif
-
-#if defined(BN_MP_SQRT_C)
-   #define BN_MP_N_ROOT_C
-   #define BN_MP_ISZERO_C
-   #define BN_MP_ZERO_C
-   #define BN_MP_INIT_COPY_C
-   #define BN_MP_RSHD_C
-   #define BN_MP_DIV_C
-   #define BN_MP_ADD_C
-   #define BN_MP_DIV_2_C
-   #define BN_MP_CMP_MAG_C
-   #define BN_MP_EXCH_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_SUB_C)
-   #define BN_S_MP_ADD_C
-   #define BN_MP_CMP_MAG_C
-   #define BN_S_MP_SUB_C
-#endif
-
-#if defined(BN_MP_SUB_D_C)
-   #define BN_MP_GROW_C
-   #define BN_MP_ADD_D_C
-   #define BN_MP_CLAMP_C
-#endif
-
-#if defined(BN_MP_SUBMOD_C)
-   #define BN_MP_INIT_C
-   #define BN_MP_SUB_C
-   #define BN_MP_CLEAR_C
-   #define BN_MP_MOD_C
-#endif
-
-#if defined(BN_MP_TO_SIGNED_BIN_C)
-   #define BN_MP_TO_UNSIGNED_BIN_C
-#endif
-
-#if defined(BN_MP_TO_SIGNED_BIN_N_C)
-   #define BN_MP_SIGNED_BIN_SIZE_C
-   #define BN_MP_TO_SIGNED_BIN_C
-#endif
-
-#if defined(BN_MP_TO_UNSIGNED_BIN_C)
-   #define BN_MP_INIT_COPY_C
-   #define BN_MP_ISZERO_C
-   #define BN_MP_DIV_2D_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_TO_UNSIGNED_BIN_N_C)
-   #define BN_MP_UNSIGNED_BIN_SIZE_C
-   #define BN_MP_TO_UNSIGNED_BIN_C
-#endif
-
-#if defined(BN_MP_TOOM_MUL_C)
-   #define BN_MP_INIT_MULTI_C
-   #define BN_MP_MOD_2D_C
-   #define BN_MP_COPY_C
-   #define BN_MP_RSHD_C
-   #define BN_MP_MUL_C
-   #define BN_MP_MUL_2_C
-   #define BN_MP_ADD_C
-   #define BN_MP_SUB_C
-   #define BN_MP_DIV_2_C
-   #define BN_MP_MUL_2D_C
-   #define BN_MP_MUL_D_C
-   #define BN_MP_DIV_3_C
-   #define BN_MP_LSHD_C
-   #define BN_MP_CLEAR_MULTI_C
-#endif
-
-#if defined(BN_MP_TOOM_SQR_C)
-   #define BN_MP_INIT_MULTI_C
-   #define BN_MP_MOD_2D_C
-   #define BN_MP_COPY_C
-   #define BN_MP_RSHD_C
-   #define BN_MP_SQR_C
-   #define BN_MP_MUL_2_C
-   #define BN_MP_ADD_C
-   #define BN_MP_SUB_C
-   #define BN_MP_DIV_2_C
-   #define BN_MP_MUL_2D_C
-   #define BN_MP_MUL_D_C
-   #define BN_MP_DIV_3_C
-   #define BN_MP_LSHD_C
-   #define BN_MP_CLEAR_MULTI_C
-#endif
-
-#if defined(BN_MP_TORADIX_C)
-   #define BN_MP_ISZERO_C
-   #define BN_MP_INIT_COPY_C
-   #define BN_MP_DIV_D_C
-   #define BN_MP_CLEAR_C
-   #define BN_MP_S_RMAP_C
-#endif
-
-#if defined(BN_MP_TORADIX_N_C)
-   #define BN_MP_ISZERO_C
-   #define BN_MP_INIT_COPY_C
-   #define BN_MP_DIV_D_C
-   #define BN_MP_CLEAR_C
-   #define BN_MP_S_RMAP_C
-#endif
-
-#if defined(BN_MP_UNSIGNED_BIN_SIZE_C)
-   #define BN_MP_COUNT_BITS_C
-#endif
-
-#if defined(BN_MP_XOR_C)
-   #define BN_MP_INIT_COPY_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_EXCH_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_MP_ZERO_C)
-#endif
-
-#if defined(BN_PRIME_TAB_C)
-#endif
-
-#if defined(BN_REVERSE_C)
-#endif
-
-#if defined(BN_S_MP_ADD_C)
-   #define BN_MP_GROW_C
-   #define BN_MP_CLAMP_C
-#endif
-
-#if defined(BN_S_MP_EXPTMOD_C)
-   #define BN_MP_COUNT_BITS_C
-   #define BN_MP_INIT_C
-   #define BN_MP_CLEAR_C
-   #define BN_MP_REDUCE_SETUP_C
-   #define BN_MP_REDUCE_C
-   #define BN_MP_REDUCE_2K_SETUP_L_C
-   #define BN_MP_REDUCE_2K_L_C
-   #define BN_MP_MOD_C
-   #define BN_MP_COPY_C
-   #define BN_MP_SQR_C
-   #define BN_MP_MUL_C
-   #define BN_MP_SET_C
-   #define BN_MP_EXCH_C
-#endif
-
-#if defined(BN_S_MP_MUL_DIGS_C)
-   #define BN_FAST_S_MP_MUL_DIGS_C
-   #define BN_MP_INIT_SIZE_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_EXCH_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_S_MP_MUL_HIGH_DIGS_C)
-   #define BN_FAST_S_MP_MUL_HIGH_DIGS_C
-   #define BN_MP_INIT_SIZE_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_EXCH_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_S_MP_SQR_C)
-   #define BN_MP_INIT_SIZE_C
-   #define BN_MP_CLAMP_C
-   #define BN_MP_EXCH_C
-   #define BN_MP_CLEAR_C
-#endif
-
-#if defined(BN_S_MP_SUB_C)
-   #define BN_MP_GROW_C
-   #define BN_MP_CLAMP_C
-#endif
-
-#if defined(BNCORE_C)
-#endif
-
-#ifdef LTM3
-#define LTM_LAST
-#endif
-#include "mpi_superclass.h"
-#include "mpi_class.h"
-#else
-#define LTM_LAST
-#endif
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/mpi_superclass.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/mpi_superclass.h
deleted file mode 100755
index f4c95ab..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/mpi_superclass.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* mpi_superclass.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-/* super class file for PK algos */
-
-/* default ... include all MPI */
-#define LTM_ALL
-
-/* RSA only (does not support DH/DSA/ECC) */
-/* #define SC_RSA_1 */
-
-/* For reference.... On an Athlon64 optimizing for speed...
-
-   LTM's mpi.o with all functions [striped] is 142KiB in size.
-
-*/
-
-/* Works for RSA only, mpi.o is 68KiB */
-#ifdef SC_RSA_1
-   #define BN_MP_SHRINK_C
-   #define BN_MP_LCM_C
-   #define BN_MP_PRIME_RANDOM_EX_C
-   #define BN_MP_INVMOD_C
-   #define BN_MP_GCD_C
-   #define BN_MP_MOD_C
-   #define BN_MP_MULMOD_C
-   #define BN_MP_ADDMOD_C
-   #define BN_MP_EXPTMOD_C
-   #define BN_MP_SET_INT_C
-   #define BN_MP_INIT_MULTI_C
-   #define BN_MP_CLEAR_MULTI_C
-   #define BN_MP_UNSIGNED_BIN_SIZE_C
-   #define BN_MP_TO_UNSIGNED_BIN_C
-   #define BN_MP_MOD_D_C
-   #define BN_MP_PRIME_RABIN_MILLER_TRIALS_C
-   #define BN_REVERSE_C
-   #define BN_PRIME_TAB_C
-
-   /* other modifiers */
-   #define BN_MP_DIV_SMALL                    /* Slower division, not critical */
-
-   /* here we are on the last pass so we turn things off.  The functions classes are still there
-    * but we remove them specifically from the build.  This also invokes tweaks in functions
-    * like removing support for even moduli, etc...
-    */
-#ifdef LTM_LAST
-   #undef  BN_MP_TOOM_MUL_C
-   #undef  BN_MP_TOOM_SQR_C
-   #undef  BN_MP_KARATSUBA_MUL_C
-   #undef  BN_MP_KARATSUBA_SQR_C
-   #undef  BN_MP_REDUCE_C
-   #undef  BN_MP_REDUCE_SETUP_C
-   #undef  BN_MP_DR_IS_MODULUS_C
-   #undef  BN_MP_DR_SETUP_C
-   #undef  BN_MP_DR_REDUCE_C
-   #undef  BN_MP_REDUCE_IS_2K_C
-   #undef  BN_MP_REDUCE_2K_SETUP_C
-   #undef  BN_MP_REDUCE_2K_C
-   #undef  BN_S_MP_EXPTMOD_C
-   #undef  BN_MP_DIV_3_C
-   #undef  BN_S_MP_MUL_HIGH_DIGS_C
-   #undef  BN_FAST_S_MP_MUL_HIGH_DIGS_C
-   #undef  BN_FAST_MP_INVMOD_C
-
-   /* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold
-    * which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines] 
-    * which means roughly speaking you can handle upto 2536-bit RSA keys with these defined without
-    * trouble.  
-    */
-   #undef  BN_S_MP_MUL_DIGS_C
-   #undef  BN_S_MP_SQR_C
-   #undef  BN_MP_MONTGOMERY_REDUCE_C
-#endif
-
-#endif
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/pkcs7.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/pkcs7.h
deleted file mode 100755
index e39a12b..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/pkcs7.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* pkcs7.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_PKCS7_H
-#define WOLF_CRYPT_PKCS7_H
-
-#include 
-
-#ifdef HAVE_PKCS7
-
-#ifndef NO_ASN
-    #include 
-#endif
-#include 
-#include 
-#ifndef NO_DES3
-    #include 
-#endif
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-/* PKCS#7 content types, ref RFC 2315 (Section 14) */
-enum PKCS7_TYPES {
-    PKCS7_MSG                 = 650,   /* 1.2.840.113549.1.7   */
-    DATA                      = 651,   /* 1.2.840.113549.1.7.1 */
-    SIGNED_DATA               = 652,   /* 1.2.840.113549.1.7.2 */
-    ENVELOPED_DATA            = 653,   /* 1.2.840.113549.1.7.3 */
-    SIGNED_AND_ENVELOPED_DATA = 654,   /* 1.2.840.113549.1.7.4 */
-    DIGESTED_DATA             = 655,   /* 1.2.840.113549.1.7.5 */
-    ENCRYPTED_DATA            = 656    /* 1.2.840.113549.1.7.6 */
-};
-
-enum Pkcs7_Misc {
-    PKCS7_NONCE_SZ       = 16,
-    MAX_ENCRYPTED_KEY_SZ = 512,           /* max enc. key size, RSA <= 4096 */
-    MAX_CONTENT_KEY_LEN  = DES3_KEYLEN,   /* highest current cipher is 3DES */
-    MAX_RECIP_SZ         = MAX_VERSION_SZ +
-                           MAX_SEQ_SZ + ASN_NAME_MAX + MAX_SN_SZ +
-                           MAX_SEQ_SZ + MAX_ALGO_SZ + 1 + MAX_ENCRYPTED_KEY_SZ
-};
-
-
-typedef struct PKCS7Attrib {
-    byte* oid;
-    word32 oidSz;
-    byte* value;
-    word32 valueSz;
-} PKCS7Attrib;
-
-
-typedef struct PKCS7 {
-    byte* content;                /* inner content, not owner             */
-    word32 contentSz;             /* content size                         */
-    int contentOID;               /* PKCS#7 content type OID sum          */
-
-    RNG* rng;
-
-    int hashOID;
-    int encryptOID;               /* key encryption algorithm OID         */
-
-    byte*  singleCert;            /* recipient cert, DER, not owner       */
-    word32 singleCertSz;          /* size of recipient cert buffer, bytes */
-    byte issuerHash[KEYID_SIZE];  /* hash of all alt Names                */
-    byte*  issuer;                /* issuer name of singleCert            */
-    word32 issuerSz;              /* length of issuer name                */
-    byte issuerSn[MAX_SN_SZ];     /* singleCert's serial number           */
-    word32 issuerSnSz;            /* length of serial number              */
-    byte publicKey[512];
-    word32 publicKeySz;
-    byte*  privateKey;            /* private key, DER, not owner          */
-    word32 privateKeySz;          /* size of private key buffer, bytes    */
-
-    PKCS7Attrib* signedAttribs;
-    word32 signedAttribsSz;
-} PKCS7;
-
-
-WOLFSSL_LOCAL int wc_SetContentType(int pkcs7TypeOID, byte* output);
-WOLFSSL_LOCAL int wc_GetContentType(const byte* input, word32* inOutIdx,
-                                word32* oid, word32 maxIdx);
-WOLFSSL_LOCAL int wc_CreateRecipientInfo(const byte* cert, word32 certSz,
-                                     int keyEncAlgo, int blockKeySz,
-                                     RNG* rng, byte* contentKeyPlain,
-                                     byte* contentKeyEnc,
-                                     int* keyEncSz, byte* out, word32 outSz);
-
-WOLFSSL_API int  wc_PKCS7_InitWithCert(PKCS7* pkcs7, byte* cert, word32 certSz);
-WOLFSSL_API void wc_PKCS7_Free(PKCS7* pkcs7);
-WOLFSSL_API int  wc_PKCS7_EncodeData(PKCS7* pkcs7, byte* output, word32 outputSz);
-WOLFSSL_API int  wc_PKCS7_EncodeSignedData(PKCS7* pkcs7,
-                                       byte* output, word32 outputSz);
-WOLFSSL_API int  wc_PKCS7_VerifySignedData(PKCS7* pkcs7,
-                                       byte* pkiMsg, word32 pkiMsgSz);
-WOLFSSL_API int  wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7,
-                                          byte* output, word32 outputSz);
-WOLFSSL_API int  wc_PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* pkiMsg,
-                                          word32 pkiMsgSz, byte* output,
-                                          word32 outputSz);
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* HAVE_PKCS7 */
-#endif /* WOLF_CRYPT_PKCS7_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/poly1305.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/poly1305.h
deleted file mode 100755
index 0e76d06..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/poly1305.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* poly1305.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_POLY1305_H
-#define WOLF_CRYPT_POLY1305_H
-
-#include 
-
-#ifdef HAVE_POLY1305
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-/* auto detect between 32bit / 64bit */
-#define HAS_SIZEOF_INT128_64BIT (defined(__SIZEOF_INT128__) && defined(__LP64__))
-#define HAS_MSVC_64BIT (defined(_MSC_VER) && defined(_M_X64))
-#define HAS_GCC_4_4_64BIT (defined(__GNUC__) && defined(__LP64__) && \
-        ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))))
-
-#if (HAS_SIZEOF_INT128_64BIT || HAS_MSVC_64BIT || HAS_GCC_4_4_64BIT)
-#define POLY130564
-#else
-#define POLY130532
-#endif
-
-enum {
-    POLY1305 = 7,
-    POLY1305_BLOCK_SIZE = 16,
-    POLY1305_DIGEST_SIZE = 16,
-    POLY1305_PAD_SIZE = 56
-};
-
-/* Poly1305 state */
-typedef struct Poly1305 {
-#if defined(POLY130564)
-	word64 r[3];
-	word64 h[3];
-	word64 pad[2];
-#else
-	word32 r[5];
-	word32 h[5];
-	word32 pad[4];
-#endif
-	size_t leftover;
-	unsigned char buffer[POLY1305_BLOCK_SIZE];
-	unsigned char final;
-} Poly1305;
-
-
-/* does init */
-
-WOLFSSL_API int wc_Poly1305SetKey(Poly1305* poly1305, const byte* key, word32 kySz);
-WOLFSSL_API int wc_Poly1305Update(Poly1305* poly1305, const byte*, word32);
-WOLFSSL_API int wc_Poly1305Final(Poly1305* poly1305, byte* tag);
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* HAVE_POLY1305 */
-#endif /* WOLF_CRYPT_POLY1305_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h
deleted file mode 100755
index 44c54d7..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* pic32mz-crypt.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef PIC32MZ_CRYPT_H
-#define PIC32MZ_CRYPT_H
-
-#ifdef  WOLFSSL_MICROCHIP_PIC32MZ
-
-#define MICROCHIP_PIC32
-#include 
-#include 
-#include 
-
-typedef struct saCtrl {
-    unsigned int CRYPTOALGO : 4;
-    unsigned int MULTITASK : 3;
-    unsigned int KEYSIZE : 2;
-    unsigned int ENCTYPE : 1;
-    unsigned int ALGO : 7;
-    unsigned int : 3;
-    unsigned int FLAGS : 1;
-    unsigned int FB : 1;
-    unsigned int LOADIV : 1;
-    unsigned int LNC : 1;
-    unsigned int IRFLAG : 1;
-    unsigned int ICVONLY : 1;
-    unsigned int OR_EN : 1;
-    unsigned int NO_RX : 1;
-    unsigned int : 1;
-    unsigned int VERIFY : 1;
-    unsigned int : 2;
-} saCtrl;
-
-typedef struct securityAssociation {
-    saCtrl SA_CTRL;
-    unsigned int SA_AUTHKEY[8];
-    unsigned int SA_ENCKEY[8];
-    unsigned int SA_AUTHIV[8];
-    unsigned int SA_ENCIV[4];
-} securityAssociation;
-
-typedef struct bdCtrl {
-    unsigned int BUFLEN : 16;
-    unsigned int CBD_INT_EN : 1;
-    unsigned int PKT_INT_EN : 1;
-    unsigned int LIFM : 1;
-    unsigned int LAST_BD: 1;
-    unsigned int : 2;
-    unsigned int SA_FETCH_EN : 1;
-    unsigned int : 8;
-    unsigned int DESC_EN : 1;
-} bdCtrl;
-
-typedef struct bufferDescriptor {
-    bdCtrl BD_CTRL;
-    unsigned int SA_ADDR;
-    unsigned int SRCADDR;
-    unsigned int DSTADDR;
-    unsigned int NXTPTR;
-    unsigned int UPDPTR;
-    unsigned int MSGLEN;
-    unsigned int ENCOFF;
-} bufferDescriptor;
-
-
-#define PIC32_ENCRYPTION      0b1
-#define PIC32_DECRYPTION      0b0
-
-#define PIC32_ALGO_HMAC1     0b01000000
-#define PIC32_ALGO_SHA256    0b00100000
-#define PIC32_ALGO_SHA1      0b00010000
-#define PIC32_ALGO_MD5       0b00001000
-#define PIC32_ALGO_AES       0b00000100
-#define PIC32_ALGO_TDES      0b00000010
-#define PIC32_ALGO_DES       0b00000001
-
-#define PIC32_CRYPTOALGO_AES_GCM 0b1110
-#define PIC32_CRYPTOALGO_RCTR    0b1101
-#define PIC32_CRYPTOALGO_RCBC    0b1001
-#define PIC32_CRYPTOALGO_REBC    0b1000
-#define PIC32_CRYPTOALGO_TCBC    0b0101
-#define PIC32_CRYPTOALGO_CBC     0b0001
-
-#define PIC32_AES_KEYSIZE_256     0b10
-#define PIC32_AES_KEYSIZE_192     0b01
-#define PIC32_AES_KEYSIZE_128     0b00
-
-#define PIC32_AES_BLOCK_SIZE 16
-#define MD5_HASH_SIZE 16
-#define SHA1_HASH_SIZE 20
-#define SHA256_HASH_SIZE 32
-#define PIC32_HASH_SIZE 32
-
-#define PIC32MZ_MAX_BD   2
-typedef struct {      /* Crypt Engine descripter */
-    int bdCount ;
-    int err   ;
-    volatile bufferDescriptor 
-        bd[PIC32MZ_MAX_BD] __attribute__((aligned (8), coherent));
-    securityAssociation 
-        sa                 __attribute__((aligned (8), coherent));
-} pic32mz_desc ;
-
-#define PIC32MZ_IF_RAM(addr) (KVA_TO_PA(addr) < 0x80000)
-
-#define WAIT_ENGINE \
-    { volatile int v ; while (CESTATbits.ACTIVE) ; for(v=0; v<100; v++) ; }
-
-#ifdef DEBUG_CYASSL
-static void print_mem(const unsigned char *p, int size) {
-    for(; size>0; size--, p++) {
-        if(size%4 == 0)printf(" ") ;
-            printf("%02x", (int)*p) ;
-    }
-    puts("") ;
-}
-#endif
-
-#endif
-#endif /* PIC32MZ_CRYPT_H */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/port/ti/ti-ccm.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/port/ti/ti-ccm.h
deleted file mode 100755
index 4eec7f7..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/port/ti/ti-ccm.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* port/ti/ti_ccm.c
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-    #include 
-#endif
-
-#include 
-
-#if defined(WOLFSSL_TI_CRYPT) ||  defined(WOLFSSL_TI_HASH)
-
-bool wolfSSL_TI_CCMInit(void) ;
-
-#ifndef SINGLE_THREADED
-void wolfSSL_TI_lockCCM() ;
-void wolfSSL_TI_unlockCCM() ;
-#else 
-#define wolfSSL_TI_lockCCM()
-#define wolfSSL_TI_unlockCCM()
-#endif
-
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/port/ti/ti-hash.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/port/ti/ti-hash.h
deleted file mode 100755
index 505ccc4..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/port/ti/ti-hash.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* port/ti/ti-hash.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
- 
-#ifndef WOLF_CRYPT_TI_HASH_H
-#define WOLF_CRYPT_TI_HASH_H
-
-#include 
-
-#ifndef WOLFSSL_TI_INITBUFF
-#define WOLFSSL_TI_INITBUFF 64
-#endif
-
-#define WOLFSSL_MAX_HASH_SIZE  64
-
-typedef struct {
-    byte   *msg ;
-    word32 used ;
-    word32 len ;
-    byte hash[WOLFSSL_MAX_HASH_SIZE] ;
-} wolfssl_TI_Hash ;
-
-
-#ifndef TI_HASH_TEST
-#if !defined(NO_MD5)
-typedef wolfssl_TI_Hash Md5 ;
-
-#endif
-#if !defined(NO_SHA)
-typedef wolfssl_TI_Hash Sha ;
-#endif
-#if !defined(NO_SHA256)
-typedef wolfssl_TI_Hash Sha256 ;
-#endif
-
-#if defined(HAVE_SHA224)
-typedef wolfssl_TI_Hash Sha224 ;
-#define SHA224_DIGEST_SIZE  28
-
-WOLFSSL_API int wc_InitSha224(Sha224* sha224) ;
-WOLFSSL_API int wc_Sha224Update(Sha224* sha224, const byte* data, word32 len) ;
-WOLFSSL_API int wc_Sha224Final(Sha224* sha224, byte* hash) ;
-WOLFSSL_API int wc_Sha224Hash(const byte* data, word32 len, byte*hash) ;
-
-#endif
-#endif
-#endif /* WOLF_CRYPT_TI_HASH_H  */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/pwdbased.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/pwdbased.h
deleted file mode 100755
index 0173bee..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/pwdbased.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* pwdbased.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_PWDBASED_H
-#define WOLF_CRYPT_PWDBASED_H
-
-#include 
-
-#ifndef NO_PWDBASED
-
-#ifndef NO_MD5
-    #include        /* for hash type */
-#endif
-
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-/*
- * hashType renamed to typeH to avoid shadowing global declation here:
- * wolfssl/wolfcrypt/asn.h line 173 in enum Oid_Types
- */
-WOLFSSL_API int wc_PBKDF1(byte* output, const byte* passwd, int pLen,
-                      const byte* salt, int sLen, int iterations, int kLen,
-                      int typeH);
-WOLFSSL_API int wc_PBKDF2(byte* output, const byte* passwd, int pLen,
-                      const byte* salt, int sLen, int iterations, int kLen,
-                      int typeH);
-WOLFSSL_API int wc_PKCS12_PBKDF(byte* output, const byte* passwd, int pLen,
-                            const byte* salt, int sLen, int iterations,
-                            int kLen, int typeH, int purpose);
-
-/* helper functions */
-WOLFSSL_LOCAL int GetDigestSize(int hashType);
-WOLFSSL_LOCAL int GetPKCS12HashSizes(int hashType, word32* v, word32* u);
-WOLFSSL_LOCAL int DoPKCS12Hash(int hashType, byte* buffer, word32 totalLen,
-                               byte* Ai, word32 u, int iterations);
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* NO_PWDBASED */
-#endif /* WOLF_CRYPT_PWDBASED_H */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/rabbit.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/rabbit.h
deleted file mode 100755
index ea5ae73..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/rabbit.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* rabbit.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_RABBIT_H
-#define WOLF_CRYPT_RABBIT_H
-
-#include 
-
-#ifndef NO_RABBIT
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-enum {
-	RABBIT_ENC_TYPE  = 5     /* cipher unique type */
-};
-
-
-/* Rabbit Context */
-typedef struct RabbitCtx {
-    word32 x[8];
-    word32 c[8];
-    word32 carry;
-} RabbitCtx;
-
-
-/* Rabbit stream cipher */
-typedef struct Rabbit {
-    RabbitCtx masterCtx;
-    RabbitCtx workCtx;
-} Rabbit;
-
-
-WOLFSSL_API int wc_RabbitProcess(Rabbit*, byte*, const byte*, word32);
-WOLFSSL_API int wc_RabbitSetKey(Rabbit*, const byte* key, const byte* iv);
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* NO_RABBIT */
-#endif /* WOLF_CRYPT_RABBIT_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/random.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/random.h
deleted file mode 100755
index 1921443..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/random.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/* random.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLF_CRYPT_RANDOM_H
-#define WOLF_CRYPT_RANDOM_H
-
-#include 
-
-#ifdef HAVE_FIPS
-/* for fips @wc_fips */
-#include 
-#endif
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-#ifndef HAVE_FIPS /* avoid redefining structs and macros */
-#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
-    #ifdef NO_SHA256
-        #error "Hash DRBG requires SHA-256."
-    #endif /* NO_SHA256 */
-
-    #include 
-#else /* HAVE_HASHDRBG || NO_RC4 */
-    #include 
-#endif /* HAVE_HASHDRBG || NO_RC4 */
-
-#if defined(USE_WINDOWS_API)
-    #if defined(_WIN64)
-        typedef unsigned __int64 ProviderHandle;
-        /* type HCRYPTPROV, avoid #include  */
-    #else
-        typedef unsigned long ProviderHandle;
-    #endif
-#endif
-
-
-/* OS specific seeder */
-typedef struct OS_Seed {
-    #if defined(USE_WINDOWS_API)
-        ProviderHandle handle;
-    #else
-        int fd;
-    #endif
-} OS_Seed;
-
-
-#if defined(WOLFSSL_MDK_ARM)
-#undef RNG
-#define RNG wolfSSL_RNG   /* for avoiding name conflict in "stm32f2xx.h" */
-#endif
-
-
-#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
-
-
-#define DRBG_SEED_LEN (440/8)
-
-
-struct DRBG; /* Private DRBG state */
-
-
-/* Hash-based Deterministic Random Bit Generator */
-typedef struct RNG {
-    struct DRBG* drbg;
-    OS_Seed seed;
-    byte status;
-} RNG;
-
-
-#else /* HAVE_HASHDRBG || NO_RC4 */
-
-
-#define WOLFSSL_RNG_CAVIUM_MAGIC 0xBEEF0004
-
-/* secure Random Number Generator */
-
-
-typedef struct RNG {
-    OS_Seed seed;
-    Arc4    cipher;
-#ifdef HAVE_CAVIUM
-    int    devId;           /* nitrox device id */
-    word32 magic;           /* using cavium magic */
-#endif
-} RNG;
-
-
-#endif /* HAVE_HASH_DRBG || NO_RC4 */
-
-#endif /* HAVE_FIPS */
-
-WOLFSSL_LOCAL
-int wc_GenerateSeed(OS_Seed* os, byte* seed, word32 sz);
-
-#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
-
-#ifdef HAVE_CAVIUM
-    WOLFSSL_API int  wc_InitRngCavium(RNG*, int);
-#endif
-
-#endif /* HAVE_HASH_DRBG || NO_RC4 */
-
-
-WOLFSSL_API int  wc_InitRng(RNG*);
-WOLFSSL_API int  wc_RNG_GenerateBlock(RNG*, byte*, word32 sz);
-WOLFSSL_API int  wc_RNG_GenerateByte(RNG*, byte*);
-WOLFSSL_API int  wc_FreeRng(RNG*);
-
-
-#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
-    WOLFSSL_API int wc_RNG_HealthTest(int reseed,
-                                        const byte* entropyA, word32 entropyASz,
-                                        const byte* entropyB, word32 entropyBSz,
-                                        byte* output, word32 outputSz);
-#endif /* HAVE_HASHDRBG || NO_RC4 */
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* WOLF_CRYPT_RANDOM_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/ripemd.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/ripemd.h
deleted file mode 100755
index a76b64d..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/ripemd.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* ripemd.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_RIPEMD_H
-#define WOLF_CRYPT_RIPEMD_H
-
-#include 
-
-#ifdef WOLFSSL_RIPEMD
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-/* in bytes */
-enum {
-    RIPEMD             =  3,    /* hash type unique */
-    RIPEMD_BLOCK_SIZE  = 64,
-    RIPEMD_DIGEST_SIZE = 20,
-    RIPEMD_PAD_SIZE    = 56
-};
-
-
-/* RipeMd 160 digest */
-typedef struct RipeMd {
-    word32  buffLen;   /* in bytes          */
-    word32  loLen;     /* length in bytes   */
-    word32  hiLen;     /* length in bytes   */
-    word32  digest[RIPEMD_DIGEST_SIZE / sizeof(word32)];
-    word32  buffer[RIPEMD_BLOCK_SIZE  / sizeof(word32)];
-} RipeMd;
-
-
-WOLFSSL_API void wc_InitRipeMd(RipeMd*);
-WOLFSSL_API void wc_RipeMdUpdate(RipeMd*, const byte*, word32);
-WOLFSSL_API void wc_RipeMdFinal(RipeMd*, byte*);
-
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* WOLFSSL_RIPEMD */
-#endif /* WOLF_CRYPT_RIPEMD_H */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/rsa.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/rsa.h
deleted file mode 100755
index 5441535..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/rsa.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/* rsa.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_RSA_H
-#define WOLF_CRYPT_RSA_H
-
-#include 
-
-#ifndef NO_RSA
-
-#ifdef HAVE_FIPS
-/* for fips @wc_fips */
-#include 
-#if defined(CYASSL_KEY_GEN) && !defined(WOLFSSL_KEY_GEN)
-    #define WOLFSSL_KEY_GEN
-#endif
-#else
-    #include 
-    #include 
-#endif /* HAVE_FIPS */
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-#ifndef HAVE_FIPS /* avoid redefinition of structs */
-#define WOLFSSL_RSA_CAVIUM_MAGIC 0xBEEF0006
-
-enum {
-    RSA_PUBLIC   = 0,
-    RSA_PRIVATE  = 1
-};
-
-/* RSA */
-typedef struct RsaKey {
-    mp_int n, e, d, p, q, dP, dQ, u;
-    int   type;                               /* public or private */
-    void* heap;                               /* for user memory overrides */
-#ifdef HAVE_CAVIUM
-    int    devId;           /* nitrox device id */
-    word32 magic;           /* using cavium magic */
-    word64 contextHandle;   /* nitrox context memory handle */
-    byte*  c_n;             /* cavium byte buffers for key parts */
-    byte*  c_e;
-    byte*  c_d;
-    byte*  c_p;
-    byte*  c_q;
-    byte*  c_dP;
-    byte*  c_dQ;
-    byte*  c_u;             /* sizes in bytes */
-    word16 c_nSz, c_eSz, c_dSz, c_pSz, c_qSz, c_dP_Sz, c_dQ_Sz, c_uSz;
-#endif
-} RsaKey;
-#endif /*HAVE_FIPS */
-
-
-WOLFSSL_API int  wc_InitRsaKey(RsaKey* key, void*);
-WOLFSSL_API int  wc_FreeRsaKey(RsaKey* key);
-
-WOLFSSL_API int  wc_RsaPublicEncrypt(const byte* in, word32 inLen, byte* out,
-                                 word32 outLen, RsaKey* key, RNG* rng);
-WOLFSSL_API int  wc_RsaPrivateDecryptInline(byte* in, word32 inLen, byte** out,
-                                        RsaKey* key);
-WOLFSSL_API int  wc_RsaPrivateDecrypt(const byte* in, word32 inLen, byte* out,
-                                  word32 outLen, RsaKey* key);
-WOLFSSL_API int  wc_RsaSSL_Sign(const byte* in, word32 inLen, byte* out,
-                            word32 outLen, RsaKey* key, RNG* rng);
-WOLFSSL_API int  wc_RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out,
-                                    RsaKey* key);
-WOLFSSL_API int  wc_RsaSSL_Verify(const byte* in, word32 inLen, byte* out,
-                              word32 outLen, RsaKey* key);
-WOLFSSL_API int  wc_RsaEncryptSize(RsaKey* key);
-
-#ifndef HAVE_FIPS /* to avoid asn duplicate symbols @wc_fips */
-WOLFSSL_API int  wc_RsaPrivateKeyDecode(const byte* input, word32* inOutIdx,
-                                                               RsaKey*, word32);
-WOLFSSL_API int  wc_RsaPublicKeyDecode(const byte* input, word32* inOutIdx,
-                                                               RsaKey*, word32);
-WOLFSSL_API int  wc_RsaPublicKeyDecodeRaw(const byte* n, word32 nSz,
-                                        const byte* e, word32 eSz, RsaKey* key);
-#ifdef WOLFSSL_KEY_GEN
-    WOLFSSL_API int wc_RsaKeyToDer(RsaKey*, byte* output, word32 inLen);
-#endif
-#endif /* HAVE_FIPS*/
-WOLFSSL_API int  wc_RsaFlattenPublicKey(RsaKey*, byte*, word32*, byte*,
-                                                                       word32*);
-
-#ifdef WOLFSSL_KEY_GEN
-    WOLFSSL_API int wc_MakeRsaKey(RsaKey* key, int size, long e, RNG* rng);
-#endif
-
-#ifdef HAVE_CAVIUM
-    WOLFSSL_API int  wc_RsaInitCavium(RsaKey*, int);
-    WOLFSSL_API void wc_RsaFreeCavium(RsaKey*);
-#endif
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* NO_RSA */
-#endif /* WOLF_CRYPT_RSA_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/settings.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/settings.h
deleted file mode 100755
index 57c404a..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/settings.h
+++ /dev/null
@@ -1,800 +0,0 @@
-/* settings.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/* Place OS specific preprocessor flags, defines, includes here, will be
-   included into every file because types.h includes it */
-
-
-#ifndef WOLF_CRYPT_SETTINGS_H
-#define WOLF_CRYPT_SETTINGS_H
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-/* Uncomment next line if using IPHONE */
-/* #define IPHONE */
-
-/* Uncomment next line if using ThreadX */
-/* #define THREADX */
-
-/* Uncomment next line if using Micrium ucOS */
-/* #define MICRIUM */
-
-/* Uncomment next line if using Mbed */
-/* #define MBED */
-
-/* Uncomment next line if using Microchip PIC32 ethernet starter kit */
-/* #define MICROCHIP_PIC32 */
-
-/* Uncomment next line if using Microchip TCP/IP stack, version 5 */
-/* #define MICROCHIP_TCPIP_V5 */
-
-/* Uncomment next line if using Microchip TCP/IP stack, version 6 or later */
-/* #define MICROCHIP_TCPIP */
-
-/* Uncomment next line if using PIC32MZ Crypto Engine */
-/* #define WOLFSSL_MICROCHIP_PIC32MZ */
-
-/* Uncomment next line if using FreeRTOS */
-/* #define FREERTOS */
-
-/* Uncomment next line if using FreeRTOS Windows Simulator */
-/* #define FREERTOS_WINSIM */
-
-/* Uncomment next line if using RTIP */
-/* #define EBSNET */
-
-/* Uncomment next line if using lwip */
-/* #define WOLFSSL_LWIP */
-
-/* Uncomment next line if building wolfSSL for a game console */
-/* #define WOLFSSL_GAME_BUILD */
-
-/* Uncomment next line if building wolfSSL for LSR */
-/* #define WOLFSSL_LSR */
-
-/* Uncomment next line if building wolfSSL for Freescale MQX/RTCS/MFS */
-/* #define FREESCALE_MQX */
-
-/* Uncomment next line if using STM32F2 */
-/* #define WOLFSSL_STM32F2 */
-
-/* Uncomment next line if using Comverge settings */
-/* #define COMVERGE */
-
-/* Uncomment next line if using QL SEP settings */
-/* #define WOLFSSL_QL */
-
-/* Uncomment next line if building for EROAD */
-/* #define WOLFSSL_EROAD */
-
-/* Uncomment next line if building for IAR EWARM */
-/* #define WOLFSSL_IAR_ARM */
-
-/* Uncomment next line if using TI-RTOS settings */
-/* #define WOLFSSL_TIRTOS */
-
-/* Uncomment next line if building with PicoTCP */
-/* #define WOLFSSL_PICOTCP */
-
-/* Uncomment next line if building for PicoTCP demo bundle */
-/* #define WOLFSSL_PICOTCP_DEMO */
-
-/* Uncomment next line if building for uITRON4  */
-/* #define WOLFSSL_uITRON4 */
-
-/* Uncomment next line if building for uT-Kernel */
-/* #define WOLFSSL_uTKERNEL2 */
-
-/* Uncomment next line if using Max Strength build */
-/* #define WOLFSSL_MAX_STRENGTH */
-
-/* Uncomment next line if building for VxWorks */
-/* #define WOLFSSL_VXWORKS */
-
-#include 
-
-#ifdef WOLFSSL_USER_SETTINGS
-    #include 
-#endif
-
-
-#ifdef IPHONE
-    #define SIZEOF_LONG_LONG 8
-#endif
-
-
-#ifdef COMVERGE
-    #define THREADX
-    #define HAVE_NETX
-    #define WOLFSSL_USER_IO
-    #define NO_WRITEV
-    #define NO_DEV_RANDOM
-    #define NO_FILESYSTEM
-    #define NO_SHA512
-    #define NO_DH
-    #define NO_DSA
-    #define NO_HC128
-    #define NO_RSA
-    #define NO_SESSION_CACHE
-    #define HAVE_ECC
-#endif
-
-
-#ifdef THREADX
-    #define SIZEOF_LONG_LONG 8
-#endif
-
-#ifdef HAVE_NETX
-    #include "nx_api.h"
-#endif
-
-#if defined(HAVE_LWIP_NATIVE) /* using LwIP native TCP socket */
-    #define WOLFSSL_LWIP
-    #define NO_WRITEV
-    #define SINGLE_THREADED
-    #define WOLFSSL_USER_IO
-    #define NO_FILESYSTEM
-#endif
-
-#if defined(WOLFSSL_IAR_ARM)
-    #define NO_MAIN_DRIVER
-    #define SINGLE_THREADED
-    #define USE_CERT_BUFFERS_1024
-    #define BENCH_EMBEDDED
-    #define NO_FILESYSTEM
-    #define NO_WRITEV
-    #define WOLFSSL_USER_IO
-    #define  BENCH_EMBEDDED
-#endif
-
-#ifdef MICROCHIP_PIC32
-    /* #define WOLFSSL_MICROCHIP_PIC32MZ */
-    #define SIZEOF_LONG_LONG 8
-    #define SINGLE_THREADED
-    #define WOLFSSL_USER_IO
-    #define NO_WRITEV
-    #define NO_DEV_RANDOM
-    #define NO_FILESYSTEM
-    #define USE_FAST_MATH
-    #define TFM_TIMING_RESISTANT
-    #define NEED_AES_TABLES
-#endif
-
-#ifdef WOLFSSL_MICROCHIP_PIC32MZ
-    #define WOLFSSL_PIC32MZ_CE
-    #define WOLFSSL_PIC32MZ_CRYPT
-    #define HAVE_AES_ENGINE
-    #define WOLFSSL_PIC32MZ_RNG
-    /* #define WOLFSSL_PIC32MZ_HASH */
-    #define WOLFSSL_AES_COUNTER
-    #define HAVE_AESGCM
-    #define NO_BIG_INT
-#endif
-
-#ifdef MICROCHIP_TCPIP_V5
-    /* include timer functions */
-    #include "TCPIP Stack/TCPIP.h"
-#endif
-
-#ifdef MICROCHIP_TCPIP
-    /* include timer, NTP functions */
-    #ifdef MICROCHIP_MPLAB_HARMONY
-        #include "tcpip/tcpip.h"
-    #else
-        #include "system/system_services.h"
-        #include "tcpip/sntp.h"
-    #endif
-#endif
-
-#ifdef MBED
-    #define WOLFSSL_USER_IO
-    #define NO_FILESYSTEM
-    #define NO_CERT
-    #define USE_CERT_BUFFERS_1024
-    #define NO_WRITEV
-    #define NO_DEV_RANDOM
-    #define NO_SHA512
-    #define NO_DH
-    #define NO_DSA
-    #define NO_HC128
-    #define HAVE_ECC
-    #define NO_SESSION_CACHE
-    #define WOLFSSL_CMSIS_RTOS
-#endif
-
-
-#ifdef WOLFSSL_EROAD
-    #define FREESCALE_MQX
-    #define FREESCALE_MMCAU
-    #define SINGLE_THREADED
-    #define NO_STDIO_FILESYSTEM
-    #define WOLFSSL_LEANPSK
-    #define HAVE_NULL_CIPHER
-    #define NO_OLD_TLS
-    #define NO_ASN
-    #define NO_BIG_INT
-    #define NO_RSA
-    #define NO_DSA
-    #define NO_DH
-    #define NO_CERTS
-    #define NO_PWDBASED
-    #define NO_DES3
-    #define NO_MD4
-    #define NO_RC4
-    #define NO_MD5
-    #define NO_SESSION_CACHE
-    #define NO_MAIN_DRIVER
-#endif
-
-#ifdef WOLFSSL_PICOTCP
-    #ifndef errno
-        #define errno pico_err
-    #endif
-    #include "pico_defines.h"
-    #include "pico_stack.h"
-    #include "pico_constants.h"
-    #include "pico_protocol.h"
-    #define CUSTOM_RAND_GENERATE pico_rand
-#endif
-
-#ifdef WOLFSSL_PICOTCP_DEMO
-    #define WOLFSSL_STM32
-    #define USE_FAST_MATH
-    #define TFM_TIMING_RESISTANT
-    #define XMALLOC(s, h, type)  PICO_ZALLOC((s))
-    #define XFREE(p, h, type)    PICO_FREE((p))
-    #define SINGLE_THREADED
-    #define NO_WRITEV
-    #define WOLFSSL_USER_IO
-    #define NO_DEV_RANDOM
-    #define NO_FILESYSTEM
-#endif
-
-#ifdef FREERTOS_WINSIM
-    #define FREERTOS
-    #define USE_WINDOWS_API
-#endif
-
-
-#ifdef WOLFSSL_VXWORKS
-    #define NO_DEV_RANDOM
-    #define NO_WRITEV
-#endif
-
-
-/* Micrium will use Visual Studio for compilation but not the Win32 API */
-#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) \
-        && !defined(EBSNET) && !defined(WOLFSSL_EROAD)
-    #define USE_WINDOWS_API
-#endif
-
-
-#if defined(WOLFSSL_LEANPSK) && !defined(XMALLOC_USER)
-    #include 
-    #define XMALLOC(s, h, type)  malloc((s))
-    #define XFREE(p, h, type)    free((p))
-    #define XREALLOC(p, n, h, t) realloc((p), (n))
-#endif
-
-#if defined(XMALLOC_USER) && defined(SSN_BUILDING_LIBYASSL)
-    #undef  XMALLOC
-    #define XMALLOC     yaXMALLOC
-    #undef  XFREE
-    #define XFREE       yaXFREE
-    #undef  XREALLOC
-    #define XREALLOC    yaXREALLOC
-#endif
-
-
-#ifdef FREERTOS
-    #ifndef NO_WRITEV
-        #define NO_WRITEV
-    #endif
-    #ifndef HAVE_SHA512
-        #ifndef NO_SHA512
-            #define NO_SHA512
-        #endif
-    #endif
-    #ifndef HAVE_DH
-        #ifndef NO_DH
-            #define NO_DH
-        #endif
-    #endif
-    #ifndef NO_DSA
-        #define NO_DSA
-    #endif
-    #ifndef NO_HC128
-        #define NO_HC128
-    #endif
-
-    #ifndef SINGLE_THREADED
-        #include "FreeRTOS.h"
-        #include "semphr.h"
-    #endif
-#endif
-
-#ifdef WOLFSSL_TIRTOS
-    #define SIZEOF_LONG_LONG 8
-    #define NO_WRITEV
-    #define NO_WOLFSSL_DIR
-    #define USE_FAST_MATH
-    #define TFM_TIMING_RESISTANT
-    #define NO_DEV_RANDOM
-    #define NO_FILESYSTEM
-    #define USE_CERT_BUFFERS_2048
-    #define NO_ERROR_STRINGS
-    #define USER_TIME
-
-    #ifdef __IAR_SYSTEMS_ICC__
-        #pragma diag_suppress=Pa089
-    #elif !defined(__GNUC__)
-        /* Suppress the sslpro warning */
-        #pragma diag_suppress=11
-    #endif
-
-    #include 
-#endif
-
-#ifdef EBSNET
-    #include "rtip.h"
-
-    /* #define DEBUG_WOLFSSL */
-    #define NO_WOLFSSL_DIR  /* tbd */
-
-    #if (POLLOS)
-        #define SINGLE_THREADED
-    #endif
-
-    #if (RTPLATFORM)
-        #if (!RTP_LITTLE_ENDIAN)
-            #define BIG_ENDIAN_ORDER
-        #endif
-    #else
-        #if (!KS_LITTLE_ENDIAN)
-            #define BIG_ENDIAN_ORDER
-        #endif
-    #endif
-
-    #if (WINMSP3)
-        #undef SIZEOF_LONG
-        #define SIZEOF_LONG_LONG 8
-    #else
-        #sslpro: settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG
-    #endif
-
-    #define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC))
-    #define XFREE(p, h, type) (rtp_free(p))
-    #define XREALLOC(p, n, h, t) realloc((p), (n))
-
-#endif /* EBSNET */
-
-#ifdef WOLFSSL_GAME_BUILD
-    #define SIZEOF_LONG_LONG 8
-    #if defined(__PPU) || defined(__XENON)
-        #define BIG_ENDIAN_ORDER
-    #endif
-#endif
-
-#ifdef WOLFSSL_LSR
-    #define HAVE_WEBSERVER
-    #define SIZEOF_LONG_LONG 8
-    #define WOLFSSL_LOW_MEMORY
-    #define NO_WRITEV
-    #define NO_SHA512
-    #define NO_DH
-    #define NO_DSA
-    #define NO_HC128
-    #define NO_DEV_RANDOM
-    #define NO_WOLFSSL_DIR
-    #define NO_RABBIT
-    #ifndef NO_FILESYSTEM
-        #define LSR_FS
-        #include "inc/hw_types.h"
-        #include "fs.h"
-    #endif
-    #define WOLFSSL_LWIP
-    #include   /* for tcp errno */
-    #define WOLFSSL_SAFERTOS
-    #if defined(__IAR_SYSTEMS_ICC__)
-        /* enum uses enum */
-        #pragma diag_suppress=Pa089
-    #endif
-#endif
-
-#ifdef WOLFSSL_SAFERTOS
-    #ifndef SINGLE_THREADED
-        #include "SafeRTOS/semphr.h"
-    #endif
-
-    #include "SafeRTOS/heap.h"
-    #define XMALLOC(s, h, type)  pvPortMalloc((s))
-    #define XFREE(p, h, type)    vPortFree((p))
-    #define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
-#endif
-
-#ifdef WOLFSSL_LOW_MEMORY
-    #undef  RSA_LOW_MEM
-    #define RSA_LOW_MEM
-    #undef  WOLFSSL_SMALL_STACK
-    #define WOLFSSL_SMALL_STACK
-    #undef  TFM_TIMING_RESISTANT
-    #define TFM_TIMING_RESISTANT
-#endif
-
-#ifdef FREESCALE_MQX
-    #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
-    #define FREESCALE_K70_RNGA
-    /* #define FREESCALE_K53_RNGB */
-    #include "mqx.h"
-    #ifndef NO_FILESYSTEM
-        #include "mfs.h"
-        #include "fio.h"
-    #endif
-    #ifndef SINGLE_THREADED
-        #include "mutex.h"
-    #endif
-
-    #define XMALLOC(s, h, t)    (void *)_mem_alloc_system((s))
-    #define XFREE(p, h, t)      {void* xp = (p); if ((xp)) _mem_free((xp));}
-    /* Note: MQX has no realloc, using fastmath above */
-#endif
-
-#ifdef WOLFSSL_STM32F2
-    #define SIZEOF_LONG_LONG 8
-    #define NO_DEV_RANDOM
-    #define NO_WOLFSSL_DIR
-    #define NO_RABBIT
-    #define STM32F2_RNG
-    #define STM32F2_CRYPTO
-    #define KEIL_INTRINSICS
-#endif
-
-#ifdef MICRIUM
-
-    #include "stdlib.h"
-    #include "net_cfg.h"
-    #include "ssl_cfg.h"
-    #include "net_secure_os.h"
-
-    #define WOLFSSL_TYPES
-
-    typedef CPU_INT08U byte;
-    typedef CPU_INT16U word16;
-    typedef CPU_INT32U word32;
-
-    #if (NET_SECURE_MGR_CFG_WORD_SIZE == CPU_WORD_SIZE_32)
-        #define SIZEOF_LONG        4
-        #undef  SIZEOF_LONG_LONG
-    #else
-        #undef  SIZEOF_LONG
-        #define SIZEOF_LONG_LONG   8
-    #endif
-
-    #define STRING_USER
-
-    #define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr)))
-    #define XSTRNCPY(pstr_dest, pstr_src, len_max) \
-                    ((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \
-                     (CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max)))
-    #define XSTRNCMP(pstr_1, pstr_2, len_max) \
-                    ((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \
-                     (CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))
-    #define XSTRSTR(pstr, pstr_srch) \
-                    ((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \
-                     (CPU_CHAR *)(pstr_srch)))
-    #define XMEMSET(pmem, data_val, size) \
-                    ((void)Mem_Set((void *)(pmem), (CPU_INT08U) (data_val), \
-                    (CPU_SIZE_T)(size)))
-    #define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \
-                     (void *)(psrc), (CPU_SIZE_T)(size)))
-    #define XMEMCMP(pmem_1, pmem_2, size) \
-                   (((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), (void *)(pmem_2), \
-                     (CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES)
-    #define XMEMMOVE XMEMCPY
-
-#if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
-    #define MICRIUM_MALLOC
-    #define XMALLOC(s, h, type) ((void *)NetSecure_BlkGet((CPU_INT08U)(type), \
-                                 (CPU_SIZE_T)(s), (void *)0))
-    #define XFREE(p, h, type)   (NetSecure_BlkFree((CPU_INT08U)(type), \
-                                 (p), (void *)0))
-    #define XREALLOC(p, n, h, t) realloc((p), (n))
-#endif
-
-    #if (NET_SECURE_MGR_CFG_FS_EN == DEF_ENABLED)
-        #undef  NO_FILESYSTEM
-    #else
-        #define NO_FILESYSTEM
-    #endif
-
-    #if (SSL_CFG_TRACE_LEVEL == WOLFSSL_TRACE_LEVEL_DBG)
-        #define DEBUG_WOLFSSL
-    #else
-        #undef  DEBUG_WOLFSSL
-    #endif
-
-    #if (SSL_CFG_OPENSSL_EN == DEF_ENABLED)
-        #define OPENSSL_EXTRA
-    #else
-        #undef  OPENSSL_EXTRA
-    #endif
-
-    #if (SSL_CFG_MULTI_THREAD_EN == DEF_ENABLED)
-        #undef  SINGLE_THREADED
-    #else
-        #define SINGLE_THREADED
-    #endif
-
-    #if (SSL_CFG_DH_EN == DEF_ENABLED)
-        #undef  NO_DH
-    #else
-        #define NO_DH
-    #endif
-
-    #if (SSL_CFG_DSA_EN == DEF_ENABLED)
-        #undef  NO_DSA
-    #else
-        #define NO_DSA
-    #endif
-
-    #if (SSL_CFG_PSK_EN == DEF_ENABLED)
-        #undef  NO_PSK
-    #else
-        #define NO_PSK
-    #endif
-
-    #if (SSL_CFG_3DES_EN == DEF_ENABLED)
-        #undef  NO_DES
-    #else
-        #define NO_DES
-    #endif
-
-    #if (SSL_CFG_AES_EN == DEF_ENABLED)
-        #undef  NO_AES
-    #else
-        #define NO_AES
-    #endif
-
-    #if (SSL_CFG_RC4_EN == DEF_ENABLED)
-        #undef  NO_RC4
-    #else
-        #define NO_RC4
-    #endif
-
-    #if (SSL_CFG_RABBIT_EN == DEF_ENABLED)
-        #undef  NO_RABBIT
-    #else
-        #define NO_RABBIT
-    #endif
-
-    #if (SSL_CFG_HC128_EN == DEF_ENABLED)
-        #undef  NO_HC128
-    #else
-        #define NO_HC128
-    #endif
-
-    #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
-        #define BIG_ENDIAN_ORDER
-    #else
-        #undef  BIG_ENDIAN_ORDER
-        #define LITTLE_ENDIAN_ORDER
-    #endif
-
-    #if (SSL_CFG_MD4_EN == DEF_ENABLED)
-        #undef  NO_MD4
-    #else
-        #define NO_MD4
-    #endif
-
-    #if (SSL_CFG_WRITEV_EN == DEF_ENABLED)
-        #undef  NO_WRITEV
-    #else
-        #define NO_WRITEV
-    #endif
-
-    #if (SSL_CFG_USER_RNG_SEED_EN == DEF_ENABLED)
-        #define NO_DEV_RANDOM
-    #else
-        #undef  NO_DEV_RANDOM
-    #endif
-
-    #if (SSL_CFG_USER_IO_EN == DEF_ENABLED)
-        #define WOLFSSL_USER_IO
-    #else
-        #undef  WOLFSSL_USER_IO
-    #endif
-
-    #if (SSL_CFG_DYNAMIC_BUFFERS_EN == DEF_ENABLED)
-        #undef  LARGE_STATIC_BUFFERS
-        #undef  STATIC_CHUNKS_ONLY
-    #else
-        #define LARGE_STATIC_BUFFERS
-        #define STATIC_CHUNKS_ONLY
-    #endif
-
-    #if (SSL_CFG_DER_LOAD_EN == DEF_ENABLED)
-        #define  WOLFSSL_DER_LOAD
-    #else
-        #undef   WOLFSSL_DER_LOAD
-    #endif
-
-    #if (SSL_CFG_DTLS_EN == DEF_ENABLED)
-        #define  WOLFSSL_DTLS
-    #else
-        #undef   WOLFSSL_DTLS
-    #endif
-
-    #if (SSL_CFG_CALLBACKS_EN == DEF_ENABLED)
-         #define WOLFSSL_CALLBACKS
-    #else
-         #undef  WOLFSSL_CALLBACKS
-    #endif
-
-    #if (SSL_CFG_FAST_MATH_EN == DEF_ENABLED)
-         #define USE_FAST_MATH
-    #else
-         #undef  USE_FAST_MATH
-    #endif
-
-    #if (SSL_CFG_TFM_TIMING_RESISTANT_EN == DEF_ENABLED)
-         #define TFM_TIMING_RESISTANT
-    #else
-         #undef  TFM_TIMING_RESISTANT
-    #endif
-
-#endif /* MICRIUM */
-
-
-#ifdef WOLFSSL_QL
-    #ifndef WOLFSSL_SEP
-        #define WOLFSSL_SEP
-    #endif
-    #ifndef OPENSSL_EXTRA
-        #define OPENSSL_EXTRA
-    #endif
-    #ifndef SESSION_CERTS
-        #define SESSION_CERTS
-    #endif
-    #ifndef HAVE_AESCCM
-        #define HAVE_AESCCM
-    #endif
-    #ifndef ATOMIC_USER
-        #define ATOMIC_USER
-    #endif
-    #ifndef WOLFSSL_DER_LOAD
-        #define WOLFSSL_DER_LOAD
-    #endif
-    #ifndef KEEP_PEER_CERT
-        #define KEEP_PEER_CERT
-    #endif
-    #ifndef HAVE_ECC
-        #define HAVE_ECC
-    #endif
-    #ifndef SESSION_INDEX
-        #define SESSION_INDEX
-    #endif
-#endif /* WOLFSSL_QL */
-
-
-#if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \
-    !defined(WOLFSSL_LEANPSK) && !defined(NO_WOLFSSL_MEMORY)
-    #define USE_WOLFSSL_MEMORY
-#endif
-
-
-#if defined(OPENSSL_EXTRA) && !defined(NO_CERTS)
-    #undef  KEEP_PEER_CERT
-    #define KEEP_PEER_CERT
-#endif
-
-
-/* stream ciphers except arc4 need 32bit alignment, intel ok without */
-#ifndef XSTREAM_ALIGN
-    #if defined(__x86_64__) || defined(__ia64__) || defined(__i386__)
-        #define NO_XSTREAM_ALIGN
-    #else
-        #define XSTREAM_ALIGN
-    #endif
-#endif
-
-
-/* FreeScale MMCAU hardware crypto has 4 byte alignment */
-#ifdef FREESCALE_MMCAU
-    #define WOLFSSL_MMCAU_ALIGNMENT 4
-#endif
-
-/* if using hardware crypto and have alignment requirements, specify the
-   requirement here.  The record header of SSL/TLS will prvent easy alignment.
-   This hint tries to help as much as possible.  */
-#ifndef WOLFSSL_GENERAL_ALIGNMENT
-    #ifdef WOLFSSL_AESNI
-        #define WOLFSSL_GENERAL_ALIGNMENT 16
-    #elif defined(XSTREAM_ALIGN)
-        #define WOLFSSL_GENERAL_ALIGNMENT  4
-    #elif defined(FREESCALE_MMCAU)
-        #define WOLFSSL_GENERAL_ALIGNMENT  WOLFSSL_MMCAU_ALIGNMENT
-    #else
-        #define WOLFSSL_GENERAL_ALIGNMENT  0
-    #endif
-#endif
-
-#if defined(WOLFSSL_GENERAL_ALIGNMENT) && (WOLFSSL_GENERAL_ALIGNMENT > 0)
-    #if defined(_MSC_VER)
-        #define XGEN_ALIGN __declspec(align(WOLFSSL_GENERAL_ALIGNMENT))
-    #elif defined(__GNUC__)
-        #define XGEN_ALIGN __attribute__((aligned(WOLFSSL_GENERAL_ALIGNMENT)))
-    #else
-        #define XGEN_ALIGN
-    #endif
-#else
-    #define XGEN_ALIGN
-#endif
-
-#ifdef HAVE_CRL
-    /* not widely supported yet */
-    #undef NO_SKID
-    #define NO_SKID
-#endif
-
-
-#ifdef __INTEL_COMPILER
-    #pragma warning(disable:2259) /* explicit casts to smaller sizes, disable */
-#endif
-
-/* user can specify what curves they want with ECC_USER_CURVES otherwise
- * all curves are on by default for now */
-#ifndef ECC_USER_CURVES
-    #ifndef HAVE_ALL_CURVES
-        #define HAVE_ALL_CURVES
-    #endif
-#endif
-
-/* if desktop type system and fastmath increase default max bits */
-#ifdef WOLFSSL_X86_64_BUILD
-    #ifdef USE_FAST_MATH
-        #ifndef FP_MAX_BITS
-            #define FP_MAX_BITS 8192
-        #endif
-    #endif
-#endif
-
-/* If using the max strength build, ensure OLD TLS is disabled. */
-#ifdef WOLFSSL_MAX_STRENGTH
-    #undef NO_OLD_TLS
-    #define NO_OLD_TLS
-#endif
-
-/* Place any other flags or defines here */
-
-
-#ifdef __cplusplus
-    }   /* extern "C" */
-#endif
-
-#endif
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha.h
deleted file mode 100755
index 80a2c98..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* sha.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_SHA_H
-#define WOLF_CRYPT_SHA_H
-
-#include 
-
-#ifndef NO_SHA
-
-#ifdef HAVE_FIPS
-/* for fips @wc_fips */
-#include 
-#endif
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-#ifndef HAVE_FIPS /* avoid redefining structs */
-/* in bytes */
-enum {
-#ifdef STM32F2_HASH
-    SHA_REG_SIZE     =  4,    /* STM32 register size, bytes */
-#endif
-    SHA              =  1,    /* hash type unique */
-    SHA_BLOCK_SIZE   = 64,
-    SHA_DIGEST_SIZE  = 20,
-    SHA_PAD_SIZE     = 56
-};
-
-#ifdef WOLFSSL_PIC32MZ_HASH
-#include "port/pic32/pic32mz-crypt.h"
-#endif
-
-#ifndef WOLFSSL_TI_HASH
-      
-/* Sha digest */
-typedef struct Sha {
-    word32  buffLen;   /* in bytes          */
-    word32  loLen;     /* length in bytes   */
-    word32  hiLen;     /* length in bytes   */
-    word32  buffer[SHA_BLOCK_SIZE  / sizeof(word32)];
-    #ifndef WOLFSSL_PIC32MZ_HASH
-        word32  digest[SHA_DIGEST_SIZE / sizeof(word32)];
-    #else
-        word32  digest[PIC32_HASH_SIZE / sizeof(word32)];
-        pic32mz_desc desc; /* Crypt Engine descripter */
-    #endif
-} Sha;
-
-#else /* WOLFSSL_TI_HASH */
-    #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
-#endif
-
-#endif /* HAVE_FIPS */
-
-WOLFSSL_API int wc_InitSha(Sha*);
-WOLFSSL_API int wc_ShaUpdate(Sha*, const byte*, word32);
-WOLFSSL_API int wc_ShaFinal(Sha*, byte*);
-WOLFSSL_API int wc_ShaHash(const byte*, word32, byte*);
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* NO_SHA */
-#endif /* WOLF_CRYPT_SHA_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha256.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha256.h
deleted file mode 100755
index 7cf6d86..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha256.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* sha256.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/* code submitted by raphael.huck@efixo.com */
-
-#ifndef WOLF_CRYPT_SHA256_H
-#define WOLF_CRYPT_SHA256_H
-
-#include 
-
-#ifndef NO_SHA256
-
-#ifdef HAVE_FIPS
-    /* for fips @wc_fips */
-    #include 
-#endif
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-#ifndef HAVE_FIPS /* avoid redefinition of structs */
-#ifdef WOLFSSL_PIC32MZ_HASH
-    #include "port/pic32/pic32mz-crypt.h"
-#endif
-
-/* in bytes */
-enum {
-    SHA256              =  2,   /* hash type unique */
-    SHA256_BLOCK_SIZE   = 64,
-    SHA256_DIGEST_SIZE  = 32,
-    SHA256_PAD_SIZE     = 56
-};
-
-#ifndef WOLFSSL_TI_HASH
-
-/* Sha256 digest */
-typedef struct Sha256 {
-    word32  buffLen;   /* in bytes          */
-    word32  loLen;     /* length in bytes   */
-    word32  hiLen;     /* length in bytes   */
-    word32  digest[SHA256_DIGEST_SIZE / sizeof(word32)];
-    word32  buffer[SHA256_BLOCK_SIZE  / sizeof(word32)];
-    #ifdef WOLFSSL_PIC32MZ_HASH
-        pic32mz_desc desc ; /* Crypt Engine descripter */
-    #endif
-} Sha256;
-
-#else /* WOLFSSL_TI_HASH */
-    #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
-#endif
-
-#endif /* HAVE_FIPS */
-
-WOLFSSL_API int wc_InitSha256(Sha256*);
-WOLFSSL_API int wc_Sha256Update(Sha256*, const byte*, word32);
-WOLFSSL_API int wc_Sha256Final(Sha256*, byte*);
-WOLFSSL_API int wc_Sha256Hash(const byte*, word32, byte*);
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* NO_SHA256 */
-#endif /* WOLF_CRYPT_SHA256_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha512.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha512.h
deleted file mode 100755
index 83f07c7..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha512.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* sha512.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-#ifndef WOLF_CRYPT_SHA512_H
-#define WOLF_CRYPT_SHA512_H
-
-#include 
-
-#ifdef WOLFSSL_SHA512
-
-/* for fips @wc_fips */
-#ifdef HAVE_FIPS
-    #define CYASSL_SHA512
-    #if defined(WOLFSSL_SHA384)
-        #define CYASSL_SHA384
-    #endif
-    #include 
-#endif
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-#ifndef HAVE_FIPS /* avoid redefinition of structs */
-
-/* in bytes */
-enum {
-    SHA512              =   4,   /* hash type unique */
-    SHA512_BLOCK_SIZE   = 128,
-    SHA512_DIGEST_SIZE  =  64,
-    SHA512_PAD_SIZE     = 112
-};
-
-
-/* Sha512 digest */
-typedef struct Sha512 {
-    word32  buffLen;   /* in bytes          */
-    word32  loLen;     /* length in bytes   */
-    word32  hiLen;     /* length in bytes   */
-    word64  digest[SHA512_DIGEST_SIZE / sizeof(word64)];
-    word64  buffer[SHA512_BLOCK_SIZE  / sizeof(word64)];
-} Sha512;
-
-#endif /* HAVE_FIPS */
-
-WOLFSSL_API int wc_InitSha512(Sha512*);
-WOLFSSL_API int wc_Sha512Update(Sha512*, const byte*, word32);
-WOLFSSL_API int wc_Sha512Final(Sha512*, byte*);
-WOLFSSL_API int wc_Sha512Hash(const byte*, word32, byte*);
-
-#if defined(WOLFSSL_SHA384)
-
-#ifndef HAVE_FIPS /* avoid redefinition of structs */
-/* in bytes */
-enum {
-    SHA384              =   5,   /* hash type unique */
-    SHA384_BLOCK_SIZE   = 128,
-    SHA384_DIGEST_SIZE  =  48,
-    SHA384_PAD_SIZE     = 112
-};
-
-
-/* Sha384 digest */
-typedef struct Sha384 {
-    word32  buffLen;   /* in bytes          */
-    word32  loLen;     /* length in bytes   */
-    word32  hiLen;     /* length in bytes   */
-    word64  digest[SHA512_DIGEST_SIZE / sizeof(word64)]; /* for transform 512 */
-    word64  buffer[SHA384_BLOCK_SIZE  / sizeof(word64)];
-} Sha384;
-#endif /* HAVE_FIPS */
-
-WOLFSSL_API int wc_InitSha384(Sha384*);
-WOLFSSL_API int wc_Sha384Update(Sha384*, const byte*, word32);
-WOLFSSL_API int wc_Sha384Final(Sha384*, byte*);
-WOLFSSL_API int wc_Sha384Hash(const byte*, word32, byte*);
-
-#endif /* WOLFSSL_SHA384 */
-
-#ifdef __cplusplus
-    } /* extern "C" */
-#endif
-
-#endif /* WOLFSSL_SHA512 */
-#endif /* WOLF_CRYPT_SHA512_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/tfm.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/tfm.h
deleted file mode 100755
index 1b0bbea..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/tfm.h
+++ /dev/null
@@ -1,720 +0,0 @@
-/* tfm.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-/*
- * Based on public domain TomsFastMath 0.10 by Tom St Denis, tomstdenis@iahu.ca,
- * http://math.libtomcrypt.com
- */
-
-
-/**
- *  Edited by Moisés Guimarães (moises.guimaraes@phoebus.com.br)
- *  to fit CyaSSL's needs.
- */
-
-
-#ifndef WOLF_CRYPT_TFM_H
-#define WOLF_CRYPT_TFM_H
-
-#include 
-#ifndef CHAR_BIT
-    #include 
-#endif
-
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-#ifndef MIN
-   #define MIN(x,y) ((x)<(y)?(x):(y))
-#endif
-
-#ifndef MAX
-   #define MAX(x,y) ((x)>(y)?(x):(y))
-#endif
-
-
-#ifndef NO_64BIT
-/* autodetect x86-64 and make sure we are using 64-bit digits with x86-64 asm */
-#if defined(__x86_64__)
-   #if defined(TFM_X86) || defined(TFM_SSE2) || defined(TFM_ARM)
-       #error x86-64 detected, x86-32/SSE2/ARM optimizations are not valid!
-   #endif
-   #if !defined(TFM_X86_64) && !defined(TFM_NO_ASM)
-      #define TFM_X86_64
-   #endif
-#endif
-#if defined(TFM_X86_64)
-    #if !defined(FP_64BIT)
-       #define FP_64BIT
-    #endif
-#endif
-/* use 64-bit digit even if not using asm on x86_64 */
-#if defined(__x86_64__) && !defined(FP_64BIT)
-    #define FP_64BIT
-#endif
-/* if intel compiler doesn't provide 128 bit type don't turn on 64bit */
-#if defined(FP_64BIT) && defined(__INTEL_COMPILER) && !defined(HAVE___UINT128_T)
-    #undef FP_64BIT
-    #undef TFM_X86_64
-#endif
-#endif /* NO_64BIT */
-
-/* try to detect x86-32 */
-#if defined(__i386__) && !defined(TFM_SSE2)
-   #if defined(TFM_X86_64) || defined(TFM_ARM)
-       #error x86-32 detected, x86-64/ARM optimizations are not valid!
-   #endif
-   #if !defined(TFM_X86) && !defined(TFM_NO_ASM)
-      #define TFM_X86
-   #endif
-#endif
-
-/* make sure we're 32-bit for x86-32/sse/arm/ppc32 */
-#if (defined(TFM_X86) || defined(TFM_SSE2) || defined(TFM_ARM) || defined(TFM_PPC32)) && defined(FP_64BIT)
-   #warning x86-32, SSE2 and ARM, PPC32 optimizations require 32-bit digits (undefining)
-   #undef FP_64BIT
-#endif
-
-/* multi asms? */
-#ifdef TFM_X86
-   #define TFM_ASM
-#endif
-#ifdef TFM_X86_64
-   #ifdef TFM_ASM
-      #error TFM_ASM already defined!
-   #endif
-   #define TFM_ASM
-#endif
-#ifdef TFM_SSE2
-   #ifdef TFM_ASM
-      #error TFM_ASM already defined!
-   #endif
-   #define TFM_ASM
-#endif
-#ifdef TFM_ARM
-   #ifdef TFM_ASM
-      #error TFM_ASM already defined!
-   #endif
-   #define TFM_ASM
-#endif
-#ifdef TFM_PPC32
-   #ifdef TFM_ASM
-      #error TFM_ASM already defined!
-   #endif
-   #define TFM_ASM
-#endif
-#ifdef TFM_PPC64
-   #ifdef TFM_ASM
-      #error TFM_ASM already defined!
-   #endif
-   #define TFM_ASM
-#endif
-#ifdef TFM_AVR32
-   #ifdef TFM_ASM
-      #error TFM_ASM already defined!
-   #endif
-   #define TFM_ASM
-#endif
-
-/* we want no asm? */
-#ifdef TFM_NO_ASM
-   #undef TFM_X86
-   #undef TFM_X86_64
-   #undef TFM_SSE2
-   #undef TFM_ARM
-   #undef TFM_PPC32
-   #undef TFM_PPC64
-   #undef TFM_AVR32
-   #undef TFM_ASM
-#endif
-
-/* ECC helpers */
-#ifdef TFM_ECC192
-   #ifdef FP_64BIT
-       #define TFM_MUL3
-       #define TFM_SQR3
-   #else
-       #define TFM_MUL6
-       #define TFM_SQR6
-   #endif
-#endif
-
-#ifdef TFM_ECC224
-   #ifdef FP_64BIT
-       #define TFM_MUL4
-       #define TFM_SQR4
-   #else
-       #define TFM_MUL7
-       #define TFM_SQR7
-   #endif
-#endif
-
-#ifdef TFM_ECC256
-   #ifdef FP_64BIT
-       #define TFM_MUL4
-       #define TFM_SQR4
-   #else
-       #define TFM_MUL8
-       #define TFM_SQR8
-   #endif
-#endif
-
-#ifdef TFM_ECC384
-   #ifdef FP_64BIT
-       #define TFM_MUL6
-       #define TFM_SQR6
-   #else
-       #define TFM_MUL12
-       #define TFM_SQR12
-   #endif
-#endif
-
-#ifdef TFM_ECC521
-   #ifdef FP_64BIT
-       #define TFM_MUL9
-       #define TFM_SQR9
-   #else
-       #define TFM_MUL17
-       #define TFM_SQR17
-   #endif
-#endif
-
-
-/* some default configurations.
- */
-#if defined(FP_64BIT)
-   /* for GCC only on supported platforms */
-   typedef unsigned long long fp_digit;   /* 64bit, 128 uses mode(TI) below */
-   typedef unsigned long      fp_word __attribute__ ((mode(TI)));
-#else
-   #if defined(_MSC_VER) || defined(__BORLANDC__)
-      typedef unsigned __int64   ulong64;
-   #else
-      typedef unsigned long long ulong64;
-   #endif
-
-   #ifndef NO_64BIT
-      typedef unsigned int       fp_digit;
-      typedef ulong64            fp_word;
-      #define FP_32BIT
-   #else
-      /* some procs like coldfire prefer not to place multiply into 64bit type
-         even though it exists */
-      typedef unsigned short     fp_digit;
-      typedef unsigned int       fp_word;
-   #endif
-#endif
-
-/* # of digits this is */
-#define DIGIT_BIT  (int)((CHAR_BIT) * sizeof(fp_digit))
-
-/* Max size of any number in bits.  Basically the largest size you will be
- * multiplying should be half [or smaller] of FP_MAX_SIZE-four_digit
- *
- * It defaults to 4096-bits [allowing multiplications upto 2048x2048 bits ]
- */
-#ifndef FP_MAX_BITS
-    #define FP_MAX_BITS           4096
-#endif
-#define FP_MAX_SIZE           (FP_MAX_BITS+(8*DIGIT_BIT))
-
-/* will this lib work? */
-#if (CHAR_BIT & 7)
-   #error CHAR_BIT must be a multiple of eight.
-#endif
-#if FP_MAX_BITS % CHAR_BIT
-   #error FP_MAX_BITS must be a multiple of CHAR_BIT
-#endif
-
-#define FP_MASK    (fp_digit)(-1)
-#define FP_SIZE    (FP_MAX_SIZE/DIGIT_BIT)
-
-/* signs */
-#define FP_ZPOS     0
-#define FP_NEG      1
-
-/* return codes */
-#define FP_OKAY     0
-#define FP_VAL      1
-#define FP_MEM      2
-
-/* equalities */
-#define FP_LT        -1   /* less than */
-#define FP_EQ         0   /* equal to */
-#define FP_GT         1   /* greater than */
-
-/* replies */
-#define FP_YES        1   /* yes response */
-#define FP_NO         0   /* no response */
-
-/* a FP type */
-typedef struct {
-    int      used,
-             sign;
-#ifdef ALT_ECC_SIZE
-    int      size;
-#endif
-    fp_digit dp[FP_SIZE];
-} fp_int;
-
-/* externally define this symbol to ignore the default settings, useful for changing the build from the make process */
-#ifndef TFM_ALREADY_SET
-
-/* do we want the large set of small multiplications ?
-   Enable these if you are going to be doing a lot of small (<= 16 digit) multiplications say in ECC
-   Or if you're on a 64-bit machine doing RSA as a 1024-bit integer == 16 digits ;-)
- */
-/* need to refactor the function */
-/*#define TFM_SMALL_SET */
-
-/* do we want huge code
-   Enable these if you are doing 20, 24, 28, 32, 48, 64 digit multiplications (useful for RSA)
-   Less important on 64-bit machines as 32 digits == 2048 bits
- */
-#if 0
-#define TFM_MUL3
-#define TFM_MUL4
-#define TFM_MUL6
-#define TFM_MUL7
-#define TFM_MUL8
-#define TFM_MUL9
-#define TFM_MUL12
-#define TFM_MUL17
-#endif
-#ifdef TFM_HUGE_SET
-#define TFM_MUL20
-#define TFM_MUL24
-#define TFM_MUL28
-#define TFM_MUL32
-#if (FP_MAX_BITS >= 6144) && defined(FP_64BIT)
-    #define TFM_MUL48
-#endif
-#if (FP_MAX_BITS >= 8192) && defined(FP_64BIT)
-    #define TFM_MUL64
-#endif
-#endif
-
-#if 0
-#define TFM_SQR3
-#define TFM_SQR4
-#define TFM_SQR6
-#define TFM_SQR7
-#define TFM_SQR8
-#define TFM_SQR9
-#define TFM_SQR12
-#define TFM_SQR17
-#endif
-#ifdef TFM_HUGE_SET
-#define TFM_SQR20
-#define TFM_SQR24
-#define TFM_SQR28
-#define TFM_SQR32
-#define TFM_SQR48
-#define TFM_SQR64
-#endif
-
-/* do we want some overflow checks
-   Not required if you make sure your numbers are within range (e.g. by default a modulus for fp_exptmod() can only be upto 2048 bits long)
- */
-/* #define TFM_CHECK */
-
-/* Is the target a P4 Prescott
- */
-/* #define TFM_PRESCOTT */
-
-/* Do we want timing resistant fp_exptmod() ?
- * This makes it slower but also timing invariant with respect to the exponent 
- */
-/* #define TFM_TIMING_RESISTANT */
-
-#endif /* TFM_ALREADY_SET */
-
-/* functions */
-
-/* returns a TFM ident string useful for debugging... */
-/*const char *fp_ident(void);*/
-
-/* initialize [or zero] an fp int */
-#ifdef ALT_ECC_SIZE
-    void fp_init(fp_int *a);
-    void fp_zero(fp_int *a);
-#else
-    #define fp_init(a)  (void)XMEMSET((a), 0, sizeof(fp_int))
-    #define fp_zero(a)  fp_init(a)
-#endif
-
-/* zero/even/odd ? */
-#define fp_iszero(a) (((a)->used == 0) ? FP_YES : FP_NO)
-#define fp_iseven(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 0)) ? FP_YES : FP_NO)
-#define fp_isodd(a)  (((a)->used > 0  && (((a)->dp[0] & 1) == 1)) ? FP_YES : FP_NO)
-
-/* set to a small digit */
-void fp_set(fp_int *a, fp_digit b);
-
-/* copy from a to b */
-#ifndef ALT_ECC_SIZE
-    #define fp_copy(a, b)  (void)(((a) != (b)) ? ((void)XMEMCPY((b), (a), sizeof(fp_int))) : (void)0)
-    #define fp_init_copy(a, b) fp_copy(b, a)
-#else
-    void fp_copy(fp_int *a, fp_int *b);
-    void fp_init_copy(fp_int *a, fp_int *b);
-#endif
-
-/* clamp digits */
-#define fp_clamp(a)   { while ((a)->used && (a)->dp[(a)->used-1] == 0) --((a)->used); (a)->sign = (a)->used ? (a)->sign : FP_ZPOS; }
-
-/* negate and absolute */
-#define fp_neg(a, b)  { fp_copy(a, b); (b)->sign ^= 1; fp_clamp(b); }
-#define fp_abs(a, b)  { fp_copy(a, b); (b)->sign  = 0; }
-
-/* right shift x digits */
-void fp_rshd(fp_int *a, int x);
-
-/* right shift x bits */
-void fp_rshb(fp_int *a, int x);
-
-/* left shift x digits */
-void fp_lshd(fp_int *a, int x);
-
-/* signed comparison */
-int fp_cmp(fp_int *a, fp_int *b);
-
-/* unsigned comparison */
-int fp_cmp_mag(fp_int *a, fp_int *b);
-
-/* power of 2 operations */
-void fp_div_2d(fp_int *a, int b, fp_int *c, fp_int *d);
-void fp_mod_2d(fp_int *a, int b, fp_int *c);
-void fp_mul_2d(fp_int *a, int b, fp_int *c);
-void fp_2expt (fp_int *a, int b);
-void fp_mul_2(fp_int *a, fp_int *c);
-void fp_div_2(fp_int *a, fp_int *c);
-
-/* Counts the number of lsbs which are zero before the first zero bit */
-int fp_cnt_lsb(fp_int *a);
-
-/* c = a + b */
-void fp_add(fp_int *a, fp_int *b, fp_int *c);
-
-/* c = a - b */
-void fp_sub(fp_int *a, fp_int *b, fp_int *c);
-
-/* c = a * b */
-void fp_mul(fp_int *a, fp_int *b, fp_int *c);
-
-/* b = a*a  */
-void fp_sqr(fp_int *a, fp_int *b);
-
-/* a/b => cb + d == a */
-int fp_div(fp_int *a, fp_int *b, fp_int *c, fp_int *d);
-
-/* c = a mod b, 0 <= c < b  */
-int fp_mod(fp_int *a, fp_int *b, fp_int *c);
-
-/* compare against a single digit */
-int fp_cmp_d(fp_int *a, fp_digit b);
-
-/* c = a + b */
-void fp_add_d(fp_int *a, fp_digit b, fp_int *c);
-
-/* c = a - b */
-void fp_sub_d(fp_int *a, fp_digit b, fp_int *c);
-
-/* c = a * b */
-void fp_mul_d(fp_int *a, fp_digit b, fp_int *c);
-
-/* a/b => cb + d == a */
-/*int fp_div_d(fp_int *a, fp_digit b, fp_int *c, fp_digit *d);*/
-
-/* c = a mod b, 0 <= c < b  */
-/*int fp_mod_d(fp_int *a, fp_digit b, fp_digit *c);*/
-
-/* ---> number theory <--- */
-/* d = a + b (mod c) */
-/*int fp_addmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d);*/
-
-/* d = a - b (mod c) */
-/*int fp_submod(fp_int *a, fp_int *b, fp_int *c, fp_int *d);*/
-
-/* d = a * b (mod c) */
-int fp_mulmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d);
-
-/* c = a * a (mod b) */
-int fp_sqrmod(fp_int *a, fp_int *b, fp_int *c);
-
-/* c = 1/a (mod b) */
-int fp_invmod(fp_int *a, fp_int *b, fp_int *c);
-
-/* c = (a, b) */
-/*void fp_gcd(fp_int *a, fp_int *b, fp_int *c);*/
-
-/* c = [a, b] */
-/*void fp_lcm(fp_int *a, fp_int *b, fp_int *c);*/
-
-/* setups the montgomery reduction */
-int fp_montgomery_setup(fp_int *a, fp_digit *mp);
-
-/* computes a = B**n mod b without division or multiplication useful for
- * normalizing numbers in a Montgomery system.
- */
-void fp_montgomery_calc_normalization(fp_int *a, fp_int *b);
-
-/* computes x/R == x (mod N) via Montgomery Reduction */
-void fp_montgomery_reduce(fp_int *a, fp_int *m, fp_digit mp);
-
-/* d = a**b (mod c) */
-int fp_exptmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d);
-
-/* primality stuff */
-
-/* perform a Miller-Rabin test of a to the base b and store result in "result" */
-/*void fp_prime_miller_rabin (fp_int * a, fp_int * b, int *result);*/
-
-/* 256 trial divisions + 8 Miller-Rabins, returns FP_YES if probable prime  */
-/*int fp_isprime(fp_int *a);*/
-
-/* Primality generation flags */
-/*#define TFM_PRIME_BBS      0x0001 */ /* BBS style prime */
-/*#define TFM_PRIME_SAFE     0x0002 */ /* Safe prime (p-1)/2 == prime */
-/*#define TFM_PRIME_2MSB_OFF 0x0004 */ /* force 2nd MSB to 0 */
-/*#define TFM_PRIME_2MSB_ON  0x0008 */ /* force 2nd MSB to 1 */
-
-/* callback for fp_prime_random, should fill dst with random bytes and return how many read [upto len] */
-/*typedef int tfm_prime_callback(unsigned char *dst, int len, void *dat);*/
-
-/*#define fp_prime_random(a, t, size, bbs, cb, dat) fp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?TFM_PRIME_BBS:0, cb, dat)*/
-
-/*int fp_prime_random_ex(fp_int *a, int t, int size, int flags, tfm_prime_callback cb, void *dat);*/
-
-/* radix conersions */
-int fp_count_bits(fp_int *a);
-int fp_leading_bit(fp_int *a);
-
-int fp_unsigned_bin_size(fp_int *a);
-void fp_read_unsigned_bin(fp_int *a, unsigned char *b, int c);
-void fp_to_unsigned_bin(fp_int *a, unsigned char *b);
-
-/*int fp_signed_bin_size(fp_int *a);*/
-/*void fp_read_signed_bin(fp_int *a, unsigned char *b, int c);*/
-/*void fp_to_signed_bin(fp_int *a, unsigned char *b);*/
-
-/*int fp_read_radix(fp_int *a, char *str, int radix);*/
-/*int fp_toradix(fp_int *a, char *str, int radix);*/
-/*int fp_toradix_n(fp_int * a, char *str, int radix, int maxlen);*/
-
-
-/* VARIOUS LOW LEVEL STUFFS */
-void s_fp_add(fp_int *a, fp_int *b, fp_int *c);
-void s_fp_sub(fp_int *a, fp_int *b, fp_int *c);
-void fp_reverse(unsigned char *s, int len);
-
-void fp_mul_comba(fp_int *a, fp_int *b, fp_int *c);
-
-#ifdef TFM_SMALL_SET
-void fp_mul_comba_small(fp_int *a, fp_int *b, fp_int *c);
-#endif
-
-#ifdef TFM_MUL3
-void fp_mul_comba3(fp_int *a, fp_int *b, fp_int *c);
-#endif
-#ifdef TFM_MUL4
-void fp_mul_comba4(fp_int *a, fp_int *b, fp_int *c);
-#endif
-#ifdef TFM_MUL6
-void fp_mul_comba6(fp_int *a, fp_int *b, fp_int *c);
-#endif
-#ifdef TFM_MUL7
-void fp_mul_comba7(fp_int *a, fp_int *b, fp_int *c);
-#endif
-#ifdef TFM_MUL8
-void fp_mul_comba8(fp_int *a, fp_int *b, fp_int *c);
-#endif
-#ifdef TFM_MUL9
-void fp_mul_comba9(fp_int *a, fp_int *b, fp_int *c);
-#endif
-#ifdef TFM_MUL12
-void fp_mul_comba12(fp_int *a, fp_int *b, fp_int *c);
-#endif
-#ifdef TFM_MUL17
-void fp_mul_comba17(fp_int *a, fp_int *b, fp_int *c);
-#endif
-
-#ifdef TFM_MUL20
-void fp_mul_comba20(fp_int *a, fp_int *b, fp_int *c);
-#endif
-#ifdef TFM_MUL24
-void fp_mul_comba24(fp_int *a, fp_int *b, fp_int *c);
-#endif
-#ifdef TFM_MUL28
-void fp_mul_comba28(fp_int *a, fp_int *b, fp_int *c);
-#endif
-#ifdef TFM_MUL32
-void fp_mul_comba32(fp_int *a, fp_int *b, fp_int *c);
-#endif
-#ifdef TFM_MUL48
-void fp_mul_comba48(fp_int *a, fp_int *b, fp_int *c);
-#endif
-#ifdef TFM_MUL64
-void fp_mul_comba64(fp_int *a, fp_int *b, fp_int *c);
-#endif
-
-void fp_sqr_comba(fp_int *a, fp_int *b);
-
-#ifdef TFM_SMALL_SET
-void fp_sqr_comba_small(fp_int *a, fp_int *b);
-#endif
-
-#ifdef TFM_SQR3
-void fp_sqr_comba3(fp_int *a, fp_int *b);
-#endif
-#ifdef TFM_SQR4
-void fp_sqr_comba4(fp_int *a, fp_int *b);
-#endif
-#ifdef TFM_SQR6
-void fp_sqr_comba6(fp_int *a, fp_int *b);
-#endif
-#ifdef TFM_SQR7
-void fp_sqr_comba7(fp_int *a, fp_int *b);
-#endif
-#ifdef TFM_SQR8
-void fp_sqr_comba8(fp_int *a, fp_int *b);
-#endif
-#ifdef TFM_SQR9
-void fp_sqr_comba9(fp_int *a, fp_int *b);
-#endif
-#ifdef TFM_SQR12
-void fp_sqr_comba12(fp_int *a, fp_int *b);
-#endif
-#ifdef TFM_SQR17
-void fp_sqr_comba17(fp_int *a, fp_int *b);
-#endif
-
-#ifdef TFM_SQR20
-void fp_sqr_comba20(fp_int *a, fp_int *b);
-#endif
-#ifdef TFM_SQR24
-void fp_sqr_comba24(fp_int *a, fp_int *b);
-#endif
-#ifdef TFM_SQR28
-void fp_sqr_comba28(fp_int *a, fp_int *b);
-#endif
-#ifdef TFM_SQR32
-void fp_sqr_comba32(fp_int *a, fp_int *b);
-#endif
-#ifdef TFM_SQR48
-void fp_sqr_comba48(fp_int *a, fp_int *b);
-#endif
-#ifdef TFM_SQR64
-void fp_sqr_comba64(fp_int *a, fp_int *b);
-#endif
-/*extern const char *fp_s_rmap;*/
-
-
-/**
- * Used by wolfSSL
- */
-
-/* Types */
-    typedef fp_digit mp_digit;
-    typedef fp_word  mp_word;
-    typedef fp_int mp_int;
-
-/* Constants */
-    #define MP_LT   FP_LT   /* less than    */
-    #define MP_EQ   FP_EQ   /* equal to     */
-    #define MP_GT   FP_GT   /* greater than */
-    #define MP_VAL  FP_VAL  /* invalid */
-    #define MP_OKAY FP_OKAY /* ok result    */
-    #define MP_NO   FP_NO   /* yes/no result */
-    #define MP_YES  FP_YES  /* yes/no result */
-
-/* Prototypes */
-#define mp_zero(a)  fp_zero(a)
-#define mp_iseven(a)  fp_iseven(a)
-int  mp_init (mp_int * a);
-void mp_clear (mp_int * a);
-int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e, mp_int* f);
-
-int  mp_add (mp_int * a, mp_int * b, mp_int * c);
-int  mp_sub (mp_int * a, mp_int * b, mp_int * c);
-int  mp_add_d (mp_int * a, mp_digit b, mp_int * c);
-
-int  mp_mul (mp_int * a, mp_int * b, mp_int * c);
-int  mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d);
-int  mp_mod(mp_int *a, mp_int *b, mp_int *c);
-int  mp_invmod(mp_int *a, mp_int *b, mp_int *c);
-int  mp_exptmod (mp_int * g, mp_int * x, mp_int * p, mp_int * y);
-
-int  mp_cmp(mp_int *a, mp_int *b);
-int  mp_cmp_d(mp_int *a, mp_digit b);
-
-int  mp_unsigned_bin_size(mp_int * a);
-int  mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c);
-int  mp_to_unsigned_bin (mp_int * a, unsigned char *b);
-
-int  mp_sub_d(fp_int *a, fp_digit b, fp_int *c);
-int  mp_copy(fp_int* a, fp_int* b);
-int  mp_isodd(mp_int* a);
-int  mp_iszero(mp_int* a);
-int  mp_count_bits(mp_int *a);
-int  mp_leading_bit(mp_int *a);
-int  mp_set_int(fp_int *a, fp_digit b);
-void mp_rshb(mp_int *a, int x);
-
-#ifdef HAVE_ECC
-    int mp_read_radix(mp_int* a, const char* str, int radix);
-    void mp_set(fp_int *a, fp_digit b);
-    int mp_sqr(fp_int *a, fp_int *b);
-    int mp_montgomery_reduce(fp_int *a, fp_int *m, fp_digit mp);
-    int mp_montgomery_setup(fp_int *a, fp_digit *rho);
-    int mp_div_2(fp_int * a, fp_int * b);
-    int mp_init_copy(fp_int * a, fp_int * b);
-#endif
-
-#if defined(HAVE_ECC) || defined(WOLFSSL_KEY_GEN)
-    int mp_sqrmod(mp_int* a, mp_int* b, mp_int* c);
-    int mp_montgomery_calc_normalization(mp_int *a, mp_int *b);
-#endif
-
-#ifdef WOLFSSL_KEY_GEN
-int  mp_gcd(fp_int *a, fp_int *b, fp_int *c);
-int  mp_lcm(fp_int *a, fp_int *b, fp_int *c);
-int  mp_prime_is_prime(mp_int* a, int t, int* result);
-#endif /* WOLFSSL_KEY_GEN */
-
-int  mp_cnt_lsb(fp_int *a);
-int  mp_div_2d(fp_int *a, int b, fp_int *c, fp_int *d);
-int  mp_mod_d(fp_int* a, fp_digit b, fp_digit* c);
-
-WOLFSSL_API word32 CheckRunTimeFastMath(void);
-
-/* If user uses RSA, DH, DSA, or ECC math lib directly then fast math FP_SIZE
-   must match, return 1 if a match otherwise 0 */
-#define CheckFastMathSettings() (FP_SIZE == CheckRunTimeFastMath())
-#ifdef __cplusplus
-   }
-#endif
-
-#endif  /* WOLF_CRYPT_TFM_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/types.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/types.h
deleted file mode 100755
index a5ff1d3..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/types.h
+++ /dev/null
@@ -1,322 +0,0 @@
-/* types.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLF_CRYPT_TYPES_H
-#define WOLF_CRYPT_TYPES_H
-
-	#include 
-	#include 
-
-	#ifdef __cplusplus
-	    extern "C" {
-	#endif
-
-
-	#if defined(WORDS_BIGENDIAN)
-	    #define BIG_ENDIAN_ORDER
-	#endif
-
-	#ifndef BIG_ENDIAN_ORDER
-	    #define LITTLE_ENDIAN_ORDER
-	#endif
-
-	#ifndef WOLFSSL_TYPES
-	    #ifndef byte
-	        typedef unsigned char  byte;
-	    #endif
-	    typedef unsigned short word16;
-	    typedef unsigned int   word32;
-	#endif
-
-
-	/* try to set SIZEOF_LONG or LONG_LONG if user didn't */
-	#if !defined(_MSC_VER) && !defined(__BCPLUSPLUS__)
-	    #if !defined(SIZEOF_LONG_LONG) && !defined(SIZEOF_LONG)
-	        #if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) \
-	                || defined(__mips64)  || defined(__x86_64__))
-	            /* long should be 64bit */
-	            #define SIZEOF_LONG 8
-	        #elif defined(__i386__) || defined(__CORTEX_M3__)
-	            /* long long should be 64bit */
-	            #define SIZEOF_LONG_LONG 8
-	        #endif
-	    #endif
-	#endif
-
-
-	#if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
-	    #define WORD64_AVAILABLE
-	    #define W64LIT(x) x##ui64
-	    typedef unsigned __int64 word64;
-	#elif defined(SIZEOF_LONG) && SIZEOF_LONG == 8
-	    #define WORD64_AVAILABLE
-	    #define W64LIT(x) x##LL
-	    typedef unsigned long word64;
-	#elif defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG == 8
-	    #define WORD64_AVAILABLE
-	    #define W64LIT(x) x##LL
-	    typedef unsigned long long word64;
-	#elif defined(__SIZEOF_LONG_LONG__) && __SIZEOF_LONG_LONG__ == 8
-	    #define WORD64_AVAILABLE
-	    #define W64LIT(x) x##LL
-	    typedef unsigned long long word64;
-	#else
-	    #define MP_16BIT  /* for mp_int, mp_word needs to be twice as big as
-	                         mp_digit, no 64 bit type so make mp_digit 16 bit */
-	#endif
-
-
-	/* These platforms have 64-bit CPU registers.  */
-	#if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \
-	     defined(__mips64)  || defined(__x86_64__) || defined(_M_X64))
-	    typedef word64 wolfssl_word;
-	#else
-	    typedef word32 wolfssl_word;
-	    #ifdef WORD64_AVAILABLE
-	        #define WOLFCRYPT_SLOW_WORD64
-	    #endif
-	#endif
-
-
-	enum {
-	    WOLFSSL_WORD_SIZE  = sizeof(wolfssl_word),
-	    WOLFSSL_BIT_SIZE   = 8,
-	    WOLFSSL_WORD_BITS  = WOLFSSL_WORD_SIZE * WOLFSSL_BIT_SIZE
-	};
-
-	#define WOLFSSL_MAX_16BIT 0xffffU
-
-	/* use inlining if compiler allows */
-	#ifndef INLINE
-	#ifndef NO_INLINE
-	    #ifdef _MSC_VER
-	        #define INLINE __inline
-	    #elif defined(__GNUC__)
-	        #define INLINE inline
-	    #elif defined(__IAR_SYSTEMS_ICC__)
-	        #define INLINE inline
-	    #elif defined(THREADX)
-	        #define INLINE _Inline
-	    #else
-	        #define INLINE
-	    #endif
-	#else
-	    #define INLINE
-	#endif
-	#endif
-
-
-	/* set up rotate style */
-	#if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
-	    #define INTEL_INTRINSICS
-	    #define FAST_ROTATE
-	#elif defined(__MWERKS__) && TARGET_CPU_PPC
-	    #define PPC_INTRINSICS
-	    #define FAST_ROTATE
-	#elif defined(__GNUC__) && defined(__i386__)
-	        /* GCC does peephole optimizations which should result in using rotate
-	           instructions  */
-	    #define FAST_ROTATE
-	#endif
-
-
-	/* set up thread local storage if available */
-	#ifdef HAVE_THREAD_LS
-	    #if defined(_MSC_VER)
-	        #define THREAD_LS_T __declspec(thread)
-	    #else
-	        #define THREAD_LS_T __thread
-	    #endif
-	#else
-	    #define THREAD_LS_T
-	#endif
-
-
-	/* Micrium will use Visual Studio for compilation but not the Win32 API */
-	#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) \
-	        && !defined(EBSNET)
-	    #define USE_WINDOWS_API
-	#endif
-
-
-	/* idea to add global alloc override by Moisés Guimarães  */
-	/* default to libc stuff */
-	/* XREALLOC is used once in normal math lib, not in fast math lib */
-	/* XFREE on some embeded systems doesn't like free(0) so test  */
-	#if defined(XMALLOC_USER)
-	    /* prototypes for user heap override functions */
-	    #include   /* for size_t */
-	    extern void *XMALLOC(size_t n, void* heap, int type);
-	    extern void *XREALLOC(void *p, size_t n, void* heap, int type);
-	    extern void XFREE(void *p, void* heap, int type);
-	#elif defined(NO_WOLFSSL_MEMORY)
-	    /* just use plain C stdlib stuff if desired */
-	    #include 
-	    #define XMALLOC(s, h, t)     ((void)h, (void)t, malloc((s)))
-	    #define XFREE(p, h, t)       {void* xp = (p); if((xp)) free((xp));}
-	    #define XREALLOC(p, n, h, t) realloc((p), (n))
-	#elif !defined(MICRIUM_MALLOC) && !defined(EBSNET) \
-	        && !defined(WOLFSSL_SAFERTOS) && !defined(FREESCALE_MQX) \
-	        && !defined(WOLFSSL_LEANPSK)
-	    /* default C runtime, can install different routines at runtime via cbs */
-	    #include 
-	    #define XMALLOC(s, h, t)     ((void)h, (void)t, wolfSSL_Malloc((s)))
-	    #define XFREE(p, h, t)       {void* xp = (p); if((xp)) wolfSSL_Free((xp));}
-	    #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n))
-	#endif
-
-	#ifndef STRING_USER
-	    #include 
-	    char* mystrnstr(const char* s1, const char* s2, unsigned int n);
-
-	    #define XMEMCPY(d,s,l)    memcpy((d),(s),(l))
-	    #define XMEMSET(b,c,l)    memset((b),(c),(l))
-	    #define XMEMCMP(s1,s2,n)  memcmp((s1),(s2),(n))
-	    #define XMEMMOVE(d,s,l)   memmove((d),(s),(l))
-
-	    #define XSTRLEN(s1)       strlen((s1))
-	    #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
-	    /* strstr, strncmp, and strncat only used by wolfSSL proper, not required for
-	       CTaoCrypt only */
-	    #define XSTRSTR(s1,s2)    strstr((s1),(s2))
-	    #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
-	    #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
-	    #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
-	    #ifndef USE_WINDOWS_API
-	        #define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
-	        #define XSNPRINTF snprintf
-	    #else
-	        #define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
-	        #define XSNPRINTF _snprintf
-	    #endif
-	#endif
-
-	#ifndef CTYPE_USER
-	    #include 
-	    #if defined(HAVE_ECC) || defined(HAVE_OCSP)
-	        #define XTOUPPER(c)     toupper((c))
-	        #define XISALPHA(c)     isalpha((c))
-	    #endif
-	    /* needed by wolfSSL_check_domain_name() */
-	    #define XTOLOWER(c)      tolower((c))
-	#endif
-
-
-	/* memory allocation types for user hints */
-	enum {
-	    DYNAMIC_TYPE_CA           = 1,
-	    DYNAMIC_TYPE_CERT         = 2,
-	    DYNAMIC_TYPE_KEY          = 3,
-	    DYNAMIC_TYPE_FILE         = 4,
-	    DYNAMIC_TYPE_SUBJECT_CN   = 5,
-	    DYNAMIC_TYPE_PUBLIC_KEY   = 6,
-	    DYNAMIC_TYPE_SIGNER       = 7,
-	    DYNAMIC_TYPE_NONE         = 8,
-	    DYNAMIC_TYPE_BIGINT       = 9,
-	    DYNAMIC_TYPE_RSA          = 10,
-	    DYNAMIC_TYPE_METHOD       = 11,
-	    DYNAMIC_TYPE_OUT_BUFFER   = 12,
-	    DYNAMIC_TYPE_IN_BUFFER    = 13,
-	    DYNAMIC_TYPE_INFO         = 14,
-	    DYNAMIC_TYPE_DH           = 15,
-	    DYNAMIC_TYPE_DOMAIN       = 16,
-	    DYNAMIC_TYPE_SSL          = 17,
-	    DYNAMIC_TYPE_CTX          = 18,
-	    DYNAMIC_TYPE_WRITEV       = 19,
-	    DYNAMIC_TYPE_OPENSSL      = 20,
-	    DYNAMIC_TYPE_DSA          = 21,
-	    DYNAMIC_TYPE_CRL          = 22,
-	    DYNAMIC_TYPE_REVOKED      = 23,
-	    DYNAMIC_TYPE_CRL_ENTRY    = 24,
-	    DYNAMIC_TYPE_CERT_MANAGER = 25,
-	    DYNAMIC_TYPE_CRL_MONITOR  = 26,
-	    DYNAMIC_TYPE_OCSP_STATUS  = 27,
-	    DYNAMIC_TYPE_OCSP_ENTRY   = 28,
-	    DYNAMIC_TYPE_ALTNAME      = 29,
-	    DYNAMIC_TYPE_SUITES       = 30,
-	    DYNAMIC_TYPE_CIPHER       = 31,
-	    DYNAMIC_TYPE_RNG          = 32,
-	    DYNAMIC_TYPE_ARRAYS       = 33,
-	    DYNAMIC_TYPE_DTLS_POOL    = 34,
-	    DYNAMIC_TYPE_SOCKADDR     = 35,
-	    DYNAMIC_TYPE_LIBZ         = 36,
-	    DYNAMIC_TYPE_ECC          = 37,
-	    DYNAMIC_TYPE_TMP_BUFFER   = 38,
-	    DYNAMIC_TYPE_DTLS_MSG     = 39,
-	    DYNAMIC_TYPE_CAVIUM_TMP   = 40,
-	    DYNAMIC_TYPE_CAVIUM_RSA   = 41,
-	    DYNAMIC_TYPE_X509         = 42,
-	    DYNAMIC_TYPE_TLSX         = 43,
-	    DYNAMIC_TYPE_OCSP         = 44,
-	    DYNAMIC_TYPE_SIGNATURE    = 45,
-	    DYNAMIC_TYPE_HASHES       = 46
-	};
-
-	/* max error buffer string size */
-	enum {
-	    WOLFSSL_MAX_ERROR_SZ = 80
-	};
-
-	/* stack protection */
-	enum {
-	    MIN_STACK_BUFFER = 8
-	};
-
-
-
-	/* settings detection for compile vs runtime math incombatibilities */
-	enum {
-	#if !defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
-	    CTC_SETTINGS = 0x0
-	#elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
-	    CTC_SETTINGS = 0x1
-	#elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
-	    CTC_SETTINGS = 0x2
-	#elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4)
-	    CTC_SETTINGS = 0x4
-	#elif defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
-	    CTC_SETTINGS = 0x8
-	#elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
-	    CTC_SETTINGS = 0x10
-	#elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
-	    CTC_SETTINGS = 0x20
-	#elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4)
-	    CTC_SETTINGS = 0x40
-	#else
-	    #error "bad math long / long long settings"
-	#endif
-	};
-
-
-	WOLFSSL_API word32 CheckRunTimeSettings(void);
-
-	/* If user uses RSA, DH, DSA, or ECC math lib directly then fast math and long
-	   types need to match at compile time and run time, CheckCtcSettings will
-	   return 1 if a match otherwise 0 */
-	#define CheckCtcSettings() (CTC_SETTINGS == CheckRunTimeSettings())
-
-
-	#ifdef __cplusplus
-	    }   /* extern "C" */
-	#endif
-
-#endif /* WOLF_CRYPT_TYPES_H */
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/visibility.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/visibility.h
deleted file mode 100755
index 6e41d23..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/visibility.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* visibility.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-/* Visibility control macros */
-
-#ifndef WOLF_CRYPT_VISIBILITY_H
-#define WOLF_CRYPT_VISIBILITY_H
-
-
-/* for compatibility and so that fips is using same name of macro @wc_fips */
-#ifdef HAVE_FIPS
-    #include 
-    #define WOLFSSL_API   CYASSL_API
-	#define WOLFSSL_LOCAL CYASSL_LOCAL
-#else
-
-/* WOLFSSL_API is used for the public API symbols.
-        It either imports or exports (or does nothing for static builds)
-
-   WOLFSSL_LOCAL is used for non-API symbols (private).
-*/
-
-#if defined(BUILDING_WOLFSSL)
-    #if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
-        #define WOLFSSL_API   __attribute__ ((visibility("default")))
-        #define WOLFSSL_LOCAL __attribute__ ((visibility("hidden")))
-    #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
-        #define WOLFSSL_API   __global
-        #define WOLFSSL_LOCAL __hidden
-    #elif defined(_MSC_VER)
-        #ifdef WOLFSSL_DLL
-            #define WOLFSSL_API __declspec(dllexport)
-        #else
-            #define WOLFSSL_API
-        #endif
-        #define WOLFSSL_LOCAL
-    #else
-        #define WOLFSSL_API
-        #define WOLFSSL_LOCAL
-    #endif /* HAVE_VISIBILITY */
-#else /* BUILDING_WOLFSSL */
-    #if defined(_MSC_VER)
-        #ifdef WOLFSSL_DLL
-            #define WOLFSSL_API __declspec(dllimport)
-        #else
-            #define WOLFSSL_API
-        #endif
-        #define WOLFSSL_LOCAL
-    #else
-        #define WOLFSSL_API
-        #define WOLFSSL_LOCAL
-    #endif
-#endif /* BUILDING_WOLFSSL */
-
-#endif /* HAVE_FIPS */
-#endif /* WOLF_CRYPT_VISIBILITY_H */
-
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/wc_port.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/wc_port.h
deleted file mode 100755
index c13f394..0000000
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/wc_port.h
+++ /dev/null
@@ -1,207 +0,0 @@
-/* wc_port.h
- *
- * Copyright (C) 2006-2015 wolfSSL Inc.
- *
- * This file is part of wolfSSL. (formerly known as CyaSSL)
- *
- * 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-1301, USA
- */
-
-
-#ifndef WOLF_CRYPT_PORT_H
-#define WOLF_CRYPT_PORT_H
-
-#include 
-
-#ifdef __cplusplus
-    extern "C" {
-#endif
-
-
-#ifdef USE_WINDOWS_API
-    #ifdef WOLFSSL_GAME_BUILD
-        #include "system/xtl.h"
-    #else
-        #ifndef WIN32_LEAN_AND_MEAN
-            #define WIN32_LEAN_AND_MEAN
-        #endif
-        #if defined(_WIN32_WCE) || defined(WIN32_LEAN_AND_MEAN)
-            /* On WinCE winsock2.h must be included before windows.h */
-            #include 
-        #endif
-        #include 
-    #endif
-#elif defined(THREADX)
-    #ifndef SINGLE_THREADED
-        #include "tx_api.h"
-    #endif
-#elif defined(MICRIUM)
-    /* do nothing, just don't pick Unix */
-#elif defined(FREERTOS) || defined(WOLFSSL_SAFERTOS)
-    /* do nothing */
-#elif defined(EBSNET)
-    /* do nothing */
-#elif defined(FREESCALE_MQX)
-    /* do nothing */
-#elif defined(WOLFSSL_MDK_ARM)
-    #if defined(WOLFSSL_MDK5)
-         #include "cmsis_os.h"
-    #else
-        #include 
-    #endif
-#elif defined(WOLFSSL_CMSIS_RTOS)
-    #include "cmsis_os.h"
-#elif defined(WOLFSSL_TIRTOS)
-    #include 
-    #include 
-#else
-    #ifndef SINGLE_THREADED
-        #define WOLFSSL_PTHREADS
-        #include 
-    #endif
-    #if defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS)
-        #include       /* for close of BIO */
-    #endif
-#endif
-
-
-#ifdef SINGLE_THREADED
-    typedef int wolfSSL_Mutex;
-#else /* MULTI_THREADED */
-    /* FREERTOS comes first to enable use of FreeRTOS Windows simulator only */
-    #ifdef FREERTOS
-        typedef xSemaphoreHandle wolfSSL_Mutex;
-    #elif defined(WOLFSSL_SAFERTOS)
-        typedef struct wolfSSL_Mutex {
-            signed char mutexBuffer[portQUEUE_OVERHEAD_BYTES];
-            xSemaphoreHandle mutex;
-        } wolfSSL_Mutex;
-    #elif defined(USE_WINDOWS_API)
-        typedef CRITICAL_SECTION wolfSSL_Mutex;
-    #elif defined(WOLFSSL_PTHREADS)
-        typedef pthread_mutex_t wolfSSL_Mutex;
-    #elif defined(THREADX)
-        typedef TX_MUTEX wolfSSL_Mutex;
-    #elif defined(MICRIUM)
-        typedef OS_MUTEX wolfSSL_Mutex;
-    #elif defined(EBSNET)
-        typedef RTP_MUTEX wolfSSL_Mutex;
-    #elif defined(FREESCALE_MQX)
-        typedef MUTEX_STRUCT wolfSSL_Mutex;
-    #elif defined(WOLFSSL_MDK_ARM)
-        #if defined(WOLFSSL_CMSIS_RTOS)
-            typedef osMutexId wolfSSL_Mutex;
-        #else
-            typedef OS_MUT wolfSSL_Mutex;
-        #endif
-    #elif defined(WOLFSSL_CMSIS_RTOS)
-        typedef osMutexId wolfSSL_Mutex;
-    #elif defined(WOLFSSL_TIRTOS)
-        typedef ti_sysbios_knl_Semaphore_Handle wolfSSL_Mutex;
-    #else
-        #error Need a mutex type in multithreaded mode
-    #endif /* USE_WINDOWS_API */
-#endif /* SINGLE_THREADED */
-
-WOLFSSL_LOCAL int InitMutex(wolfSSL_Mutex*);
-WOLFSSL_LOCAL int FreeMutex(wolfSSL_Mutex*);
-WOLFSSL_LOCAL int LockMutex(wolfSSL_Mutex*);
-WOLFSSL_LOCAL int UnLockMutex(wolfSSL_Mutex*);
-
-
-/* filesystem abstraction layer, used by ssl.c */
-#ifndef NO_FILESYSTEM
-
-#if defined(EBSNET)
-    #define XFILE                    int
-    #define XFOPEN(NAME, MODE)       vf_open((const char *)NAME, VO_RDONLY, 0);
-    #define XFSEEK                   vf_lseek
-    #define XFTELL                   vf_tell
-    #define XREWIND                  vf_rewind
-    #define XFREAD(BUF, SZ, AMT, FD) vf_read(FD, BUF, SZ*AMT)
-    #define XFWRITE(BUF, SZ, AMT, FD) vf_write(FD, BUF, SZ*AMT)
-    #define XFCLOSE                  vf_close
-    #define XSEEK_END                VSEEK_END
-    #define XBADFILE                 -1
-#elif defined(LSR_FS)
-    #include 
-    #define XFILE                   struct fs_file*
-    #define XFOPEN(NAME, MODE)      fs_open((char*)NAME);
-    #define XFSEEK(F, O, W)         (void)F
-    #define XFTELL(F)               (F)->len
-    #define XREWIND(F)              (void)F
-    #define XFREAD(BUF, SZ, AMT, F) fs_read(F, (char*)BUF, SZ*AMT)
-    #define XFWRITE(BUF, SZ, AMT, F) fs_write(F, (char*)BUF, SZ*AMT)
-    #define XFCLOSE                 fs_close
-    #define XSEEK_END               0
-    #define XBADFILE                NULL
-#elif defined(FREESCALE_MQX)
-    #define XFILE                   MQX_FILE_PTR
-    #define XFOPEN                  fopen
-    #define XFSEEK                  fseek
-    #define XFTELL                  ftell
-    #define XREWIND(F)              fseek(F, 0, IO_SEEK_SET)
-    #define XFREAD                  fread
-    #define XFWRITE                 fwrite
-    #define XFCLOSE                 fclose
-    #define XSEEK_END               IO_SEEK_END
-    #define XBADFILE                NULL
-#elif defined(MICRIUM)
-    #include 
-    #define XFILE      FS_FILE*
-    #define XFOPEN     fs_fopen
-    #define XFSEEK     fs_fseek
-    #define XFTELL     fs_ftell
-    #define XREWIND    fs_rewind
-    #define XFREAD     fs_fread
-    #define XFWRITE    fs_fwrite
-    #define XFCLOSE    fs_fclose
-    #define XSEEK_END  FS_SEEK_END
-    #define XBADFILE   NULL
-#else
-    /* stdio, default case */
-    #define XFILE      FILE*
-    #if defined(WOLFSSL_MDK_ARM)
-        #include 
-        extern FILE * wolfSSL_fopen(const char *name, const char *mode) ;
-        #define XFOPEN     wolfSSL_fopen
-    #else
-        #define XFOPEN     fopen
-    #endif
-    #define XFSEEK     fseek
-    #define XFTELL     ftell
-    #define XREWIND    rewind
-    #define XFREAD     fread
-    #define XFWRITE    fwrite
-    #define XFCLOSE    fclose
-    #define XSEEK_END  SEEK_END
-    #define XBADFILE   NULL
-#endif
-
-#endif /* NO_FILESYSTEM */
-
-
-/* Windows API defines its own min() macro. */
-#if defined(USE_WINDOWS_API) && defined(min)
-    #define WOLFSSL_HAVE_MIN
-#endif
-
-
-#ifdef __cplusplus
-    }  /* extern "C" */
-#endif
-
-#endif /* WOLF_CRYPT_PORT_H */
-
diff --git a/FreeRTOS-Plus/readme.txt b/FreeRTOS-Plus/readme.txt
deleted file mode 100755
index 4b5881e..0000000
--- a/FreeRTOS-Plus/readme.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-Directories:
-
-+ The FreeRTOS-Plus/Source directory contains source code for some of the
-  FreeRTOS+ components.  These subdirectories contain further readme files and
-  links to documentation.
-
-+ The FreeRTOS-Plus/Demo directory contains a demo application for every most of
-  the FreeRTOS+ components.  Lots of the demo applications use the FreeRTOS
-  Windows simulator for easy evaluation.  Be aware that FreeRTOS is much slower
-  and not deterministic when executed in a simulated environment.
-
-+ See http://www.freertos.org/plus
-
diff --git a/FreeRTOS/Source/croutine.c b/FreeRTOS/Source/croutine.c
deleted file mode 100755
index be17174..0000000
--- a/FreeRTOS/Source/croutine.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * FreeRTOS Kernel V10.1.1
- * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * http://www.FreeRTOS.org
- * http://aws.amazon.com/freertos
- *
- * 1 tab == 4 spaces!
- */
-
-#include "FreeRTOS.h"
-#include "task.h"
-#include "croutine.h"
-
-/* Remove the whole file is co-routines are not being used. */
-#if( configUSE_CO_ROUTINES != 0 )
-
-/*
- * Some kernel aware debuggers require data to be viewed to be global, rather
- * than file scope.
- */
-#ifdef portREMOVE_STATIC_QUALIFIER
-	#define static
-#endif
-
-
-/* Lists for ready and blocked co-routines. --------------------*/
-static List_t pxReadyCoRoutineLists[ configMAX_CO_ROUTINE_PRIORITIES ];	/*< Prioritised ready co-routines. */
-static List_t xDelayedCoRoutineList1;									/*< Delayed co-routines. */
-static List_t xDelayedCoRoutineList2;									/*< Delayed co-routines (two lists are used - one for delays that have overflowed the current tick count. */
-static List_t * pxDelayedCoRoutineList;									/*< Points to the delayed co-routine list currently being used. */
-static List_t * pxOverflowDelayedCoRoutineList;							/*< Points to the delayed co-routine list currently being used to hold co-routines that have overflowed the current tick count. */
-static List_t xPendingReadyCoRoutineList;								/*< Holds co-routines that have been readied by an external event.  They cannot be added directly to the ready lists as the ready lists cannot be accessed by interrupts. */
-
-/* Other file private variables. --------------------------------*/
-CRCB_t * pxCurrentCoRoutine = NULL;
-static UBaseType_t uxTopCoRoutineReadyPriority = 0;
-static TickType_t xCoRoutineTickCount = 0, xLastTickCount = 0, xPassedTicks = 0;
-
-/* The initial state of the co-routine when it is created. */
-#define corINITIAL_STATE	( 0 )
-
-/*
- * Place the co-routine represented by pxCRCB into the appropriate ready queue
- * for the priority.  It is inserted at the end of the list.
- *
- * This macro accesses the co-routine ready lists and therefore must not be
- * used from within an ISR.
- */
-#define prvAddCoRoutineToReadyQueue( pxCRCB )																		\
-{																													\
-	if( pxCRCB->uxPriority > uxTopCoRoutineReadyPriority )															\
-	{																												\
-		uxTopCoRoutineReadyPriority = pxCRCB->uxPriority;															\
-	}																												\
-	vListInsertEnd( ( List_t * ) &( pxReadyCoRoutineLists[ pxCRCB->uxPriority ] ), &( pxCRCB->xGenericListItem ) );	\
-}
-
-/*
- * Utility to ready all the lists used by the scheduler.  This is called
- * automatically upon the creation of the first co-routine.
- */
-static void prvInitialiseCoRoutineLists( void );
-
-/*
- * Co-routines that are readied by an interrupt cannot be placed directly into
- * the ready lists (there is no mutual exclusion).  Instead they are placed in
- * in the pending ready list in order that they can later be moved to the ready
- * list by the co-routine scheduler.
- */
-static void prvCheckPendingReadyList( void );
-
-/*
- * Macro that looks at the list of co-routines that are currently delayed to
- * see if any require waking.
- *
- * Co-routines are stored in the queue in the order of their wake time -
- * meaning once one co-routine has been found whose timer has not expired
- * we need not look any further down the list.
- */
-static void prvCheckDelayedList( void );
-
-/*-----------------------------------------------------------*/
-
-BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex )
-{
-BaseType_t xReturn;
-CRCB_t *pxCoRoutine;
-
-	/* Allocate the memory that will store the co-routine control block. */
-	pxCoRoutine = ( CRCB_t * ) pvPortMalloc( sizeof( CRCB_t ) );
-	if( pxCoRoutine )
-	{
-		/* If pxCurrentCoRoutine is NULL then this is the first co-routine to
-		be created and the co-routine data structures need initialising. */
-		if( pxCurrentCoRoutine == NULL )
-		{
-			pxCurrentCoRoutine = pxCoRoutine;
-			prvInitialiseCoRoutineLists();
-		}
-
-		/* Check the priority is within limits. */
-		if( uxPriority >= configMAX_CO_ROUTINE_PRIORITIES )
-		{
-			uxPriority = configMAX_CO_ROUTINE_PRIORITIES - 1;
-		}
-
-		/* Fill out the co-routine control block from the function parameters. */
-		pxCoRoutine->uxState = corINITIAL_STATE;
-		pxCoRoutine->uxPriority = uxPriority;
-		pxCoRoutine->uxIndex = uxIndex;
-		pxCoRoutine->pxCoRoutineFunction = pxCoRoutineCode;
-
-		/* Initialise all the other co-routine control block parameters. */
-		vListInitialiseItem( &( pxCoRoutine->xGenericListItem ) );
-		vListInitialiseItem( &( pxCoRoutine->xEventListItem ) );
-
-		/* Set the co-routine control block as a link back from the ListItem_t.
-		This is so we can get back to the containing CRCB from a generic item
-		in a list. */
-		listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xGenericListItem ), pxCoRoutine );
-		listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xEventListItem ), pxCoRoutine );
-
-		/* Event lists are always in priority order. */
-		listSET_LIST_ITEM_VALUE( &( pxCoRoutine->xEventListItem ), ( ( TickType_t ) configMAX_CO_ROUTINE_PRIORITIES - ( TickType_t ) uxPriority ) );
-
-		/* Now the co-routine has been initialised it can be added to the ready
-		list at the correct priority. */
-		prvAddCoRoutineToReadyQueue( pxCoRoutine );
-
-		xReturn = pdPASS;
-	}
-	else
-	{
-		xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;
-	}
-
-	return xReturn;
-}
-/*-----------------------------------------------------------*/
-
-void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList )
-{
-TickType_t xTimeToWake;
-
-	/* Calculate the time to wake - this may overflow but this is
-	not a problem. */
-	xTimeToWake = xCoRoutineTickCount + xTicksToDelay;
-
-	/* We must remove ourselves from the ready list before adding
-	ourselves to the blocked list as the same list item is used for
-	both lists. */
-	( void ) uxListRemove( ( ListItem_t * ) &( pxCurrentCoRoutine->xGenericListItem ) );
-
-	/* The list item will be inserted in wake time order. */
-	listSET_LIST_ITEM_VALUE( &( pxCurrentCoRoutine->xGenericListItem ), xTimeToWake );
-
-	if( xTimeToWake < xCoRoutineTickCount )
-	{
-		/* Wake time has overflowed.  Place this item in the
-		overflow list. */
-		vListInsert( ( List_t * ) pxOverflowDelayedCoRoutineList, ( ListItem_t * ) &( pxCurrentCoRoutine->xGenericListItem ) );
-	}
-	else
-	{
-		/* The wake time has not overflowed, so we can use the
-		current block list. */
-		vListInsert( ( List_t * ) pxDelayedCoRoutineList, ( ListItem_t * ) &( pxCurrentCoRoutine->xGenericListItem ) );
-	}
-
-	if( pxEventList )
-	{
-		/* Also add the co-routine to an event list.  If this is done then the
-		function must be called with interrupts disabled. */
-		vListInsert( pxEventList, &( pxCurrentCoRoutine->xEventListItem ) );
-	}
-}
-/*-----------------------------------------------------------*/
-
-static void prvCheckPendingReadyList( void )
-{
-	/* Are there any co-routines waiting to get moved to the ready list?  These
-	are co-routines that have been readied by an ISR.  The ISR cannot access
-	the	ready lists itself. */
-	while( listLIST_IS_EMPTY( &xPendingReadyCoRoutineList ) == pdFALSE )
-	{
-		CRCB_t *pxUnblockedCRCB;
-
-		/* The pending ready list can be accessed by an ISR. */
-		portDISABLE_INTERRUPTS();
-		{
-			pxUnblockedCRCB = ( CRCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( (&xPendingReadyCoRoutineList) );
-			( void ) uxListRemove( &( pxUnblockedCRCB->xEventListItem ) );
-		}
-		portENABLE_INTERRUPTS();
-
-		( void ) uxListRemove( &( pxUnblockedCRCB->xGenericListItem ) );
-		prvAddCoRoutineToReadyQueue( pxUnblockedCRCB );
-	}
-}
-/*-----------------------------------------------------------*/
-
-static void prvCheckDelayedList( void )
-{
-CRCB_t *pxCRCB;
-
-	xPassedTicks = xTaskGetTickCount() - xLastTickCount;
-	while( xPassedTicks )
-	{
-		xCoRoutineTickCount++;
-		xPassedTicks--;
-
-		/* If the tick count has overflowed we need to swap the ready lists. */
-		if( xCoRoutineTickCount == 0 )
-		{
-			List_t * pxTemp;
-
-			/* Tick count has overflowed so we need to swap the delay lists.  If there are
-			any items in pxDelayedCoRoutineList here then there is an error! */
-			pxTemp = pxDelayedCoRoutineList;
-			pxDelayedCoRoutineList = pxOverflowDelayedCoRoutineList;
-			pxOverflowDelayedCoRoutineList = pxTemp;
-		}
-
-		/* See if this tick has made a timeout expire. */
-		while( listLIST_IS_EMPTY( pxDelayedCoRoutineList ) == pdFALSE )
-		{
-			pxCRCB = ( CRCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedCoRoutineList );
-
-			if( xCoRoutineTickCount < listGET_LIST_ITEM_VALUE( &( pxCRCB->xGenericListItem ) ) )
-			{
-				/* Timeout not yet expired. */
-				break;
-			}
-
-			portDISABLE_INTERRUPTS();
-			{
-				/* The event could have occurred just before this critical
-				section.  If this is the case then the generic list item will
-				have been moved to the pending ready list and the following
-				line is still valid.  Also the pvContainer parameter will have
-				been set to NULL so the following lines are also valid. */
-				( void ) uxListRemove( &( pxCRCB->xGenericListItem ) );
-
-				/* Is the co-routine waiting on an event also? */
-				if( pxCRCB->xEventListItem.pxContainer )
-				{
-					( void ) uxListRemove( &( pxCRCB->xEventListItem ) );
-				}
-			}
-			portENABLE_INTERRUPTS();
-
-			prvAddCoRoutineToReadyQueue( pxCRCB );
-		}
-	}
-
-	xLastTickCount = xCoRoutineTickCount;
-}
-/*-----------------------------------------------------------*/
-
-void vCoRoutineSchedule( void )
-{
-	/* See if any co-routines readied by events need moving to the ready lists. */
-	prvCheckPendingReadyList();
-
-	/* See if any delayed co-routines have timed out. */
-	prvCheckDelayedList();
-
-	/* Find the highest priority queue that contains ready co-routines. */
-	while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) )
-	{
-		if( uxTopCoRoutineReadyPriority == 0 )
-		{
-			/* No more co-routines to check. */
-			return;
-		}
-		--uxTopCoRoutineReadyPriority;
-	}
-
-	/* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the co-routines
-	 of the	same priority get an equal share of the processor time. */
-	listGET_OWNER_OF_NEXT_ENTRY( pxCurrentCoRoutine, &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) );
-
-	/* Call the co-routine. */
-	( pxCurrentCoRoutine->pxCoRoutineFunction )( pxCurrentCoRoutine, pxCurrentCoRoutine->uxIndex );
-
-	return;
-}
-/*-----------------------------------------------------------*/
-
-static void prvInitialiseCoRoutineLists( void )
-{
-UBaseType_t uxPriority;
-
-	for( uxPriority = 0; uxPriority < configMAX_CO_ROUTINE_PRIORITIES; uxPriority++ )
-	{
-		vListInitialise( ( List_t * ) &( pxReadyCoRoutineLists[ uxPriority ] ) );
-	}
-
-	vListInitialise( ( List_t * ) &xDelayedCoRoutineList1 );
-	vListInitialise( ( List_t * ) &xDelayedCoRoutineList2 );
-	vListInitialise( ( List_t * ) &xPendingReadyCoRoutineList );
-
-	/* Start with pxDelayedCoRoutineList using list1 and the
-	pxOverflowDelayedCoRoutineList using list2. */
-	pxDelayedCoRoutineList = &xDelayedCoRoutineList1;
-	pxOverflowDelayedCoRoutineList = &xDelayedCoRoutineList2;
-}
-/*-----------------------------------------------------------*/
-
-BaseType_t xCoRoutineRemoveFromEventList( const List_t *pxEventList )
-{
-CRCB_t *pxUnblockedCRCB;
-BaseType_t xReturn;
-
-	/* This function is called from within an interrupt.  It can only access
-	event lists and the pending ready list.  This function assumes that a
-	check has already been made to ensure pxEventList is not empty. */
-	pxUnblockedCRCB = ( CRCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );
-	( void ) uxListRemove( &( pxUnblockedCRCB->xEventListItem ) );
-	vListInsertEnd( ( List_t * ) &( xPendingReadyCoRoutineList ), &( pxUnblockedCRCB->xEventListItem ) );
-
-	if( pxUnblockedCRCB->uxPriority >= pxCurrentCoRoutine->uxPriority )
-	{
-		xReturn = pdTRUE;
-	}
-	else
-	{
-		xReturn = pdFALSE;
-	}
-
-	return xReturn;
-}
-
-#endif /* configUSE_CO_ROUTINES == 0 */
-
diff --git a/FreeRTOS/Source/event_groups.c b/FreeRTOS/Source/event_groups.c
index f28016c..65a5ff2 100755
--- a/FreeRTOS/Source/event_groups.c
+++ b/FreeRTOS/Source/event_groups.c
@@ -1,6 +1,6 @@
 /*
- * FreeRTOS Kernel V10.1.1
- * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
+ * FreeRTOS Kernel V10.2.1
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy of
  * this software and associated documentation files (the "Software"), to deal in
diff --git a/FreeRTOS/Source/include/FreeRTOS.h b/FreeRTOS/Source/include/FreeRTOS.h
index 35d2a71..c68d5ac 100755
--- a/FreeRTOS/Source/include/FreeRTOS.h
+++ b/FreeRTOS/Source/include/FreeRTOS.h
@@ -1,6 +1,6 @@
 /*
- * FreeRTOS Kernel V10.1.1
- * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
+ * FreeRTOS Kernel V10.2.1
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy of
  * this software and associated documentation files (the "Software"), to deal in
@@ -241,6 +241,22 @@ extern "C" {
 	#define configASSERT_DEFINED 1
 #endif
 
+/* configPRECONDITION should be resolve to configASSERT.
+   The CBMC proofs need a way to track assumptions and assertions.
+   A configPRECONDITION statement should express an implicit invariant or assumption made.
+   A configASSERT statement should express an invariant that must hold explicit before calling
+   the code. */
+#ifndef configPRECONDITION
+	#define configPRECONDITION( X ) configASSERT(X)
+	#define configPRECONDITION_DEFINED 0
+#else
+	#define configPRECONDITION_DEFINED 1
+#endif
+
+#ifndef portMEMORY_BARRIER
+	#define portMEMORY_BARRIER()
+#endif
+
 /* The timers module relies on xTaskGetSchedulerState(). */
 #if configUSE_TIMERS == 1
 
@@ -762,8 +778,12 @@ extern "C" {
 	#define portTASK_USES_FLOATING_POINT()
 #endif
 
-#ifndef portTASK_CALLS_SECURE_FUNCTIONS
-	#define portTASK_CALLS_SECURE_FUNCTIONS()
+#ifndef portALLOCATE_SECURE_CONTEXT
+	#define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize )
+#endif
+
+#ifndef portDONT_DISCARD
+	#define portDONT_DISCARD
 #endif
 
 #ifndef configUSE_TIME_SLICING
@@ -954,6 +974,75 @@ point support. */
 	#define configUSE_TASK_FPU_SUPPORT 1
 #endif
 
+/* Set configENABLE_MPU to 1 to enable MPU support and 0 to disable it. This is
+currently used in ARMv8M ports. */
+#ifndef configENABLE_MPU
+	#define configENABLE_MPU 0
+#endif
+
+/* Set configENABLE_FPU to 1 to enable FPU support and 0 to disable it. This is
+currently used in ARMv8M ports. */
+#ifndef configENABLE_FPU
+	#define configENABLE_FPU 1
+#endif
+
+/* Set configENABLE_TRUSTZONE to 1 enable TrustZone support and 0 to disable it.
+This is currently used in ARMv8M ports. */
+#ifndef configENABLE_TRUSTZONE
+	#define configENABLE_TRUSTZONE 1
+#endif
+
+/* Set configRUN_FREERTOS_SECURE_ONLY to 1 to run the FreeRTOS ARMv8M port on
+the Secure Side only. */
+#ifndef configRUN_FREERTOS_SECURE_ONLY
+	#define configRUN_FREERTOS_SECURE_ONLY 0
+#endif
+
+/* Sometimes the FreeRTOSConfig.h settings only allow a task to be created using
+ * dynamically allocated RAM, in which case when any task is deleted it is known
+ * that both the task's stack and TCB need to be freed.  Sometimes the
+ * FreeRTOSConfig.h settings only allow a task to be created using statically
+ * allocated RAM, in which case when any task is deleted it is known that neither
+ * the task's stack or TCB should be freed.  Sometimes the FreeRTOSConfig.h
+ * settings allow a task to be created using either statically or dynamically
+ * allocated RAM, in which case a member of the TCB is used to record whether the
+ * stack and/or TCB were allocated statically or dynamically, so when a task is
+ * deleted the RAM that was allocated dynamically is freed again and no attempt is
+ * made to free the RAM that was allocated statically.
+ * tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE is only true if it is possible for a
+ * task to be created using either statically or dynamically allocated RAM.  Note
+ * that if portUSING_MPU_WRAPPERS is 1 then a protected task can be created with
+ * a statically allocated stack and a dynamically allocated TCB.
+ *
+ * The following table lists various combinations of portUSING_MPU_WRAPPERS,
+ * configSUPPORT_DYNAMIC_ALLOCATION and configSUPPORT_STATIC_ALLOCATION and
+ * when it is possible to have both static and dynamic allocation:
+ *  +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+
+ * | MPU | Dynamic | Static |     Available Functions     |       Possible Allocations        | Both Dynamic and | Need Free |
+ * |     |         |        |                             |                                   | Static Possible  |           |
+ * +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+
+ * | 0   | 0       | 1      | xTaskCreateStatic           | TCB - Static, Stack - Static      | No               | No        |
+ * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
+ * | 0   | 1       | 0      | xTaskCreate                 | TCB - Dynamic, Stack - Dynamic    | No               | Yes       |
+ * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
+ * | 0   | 1       | 1      | xTaskCreate,                | 1. TCB - Dynamic, Stack - Dynamic | Yes              | Yes       |
+ * |     |         |        | xTaskCreateStatic           | 2. TCB - Static, Stack - Static   |                  |           |
+ * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
+ * | 1   | 0       | 1      | xTaskCreateStatic,          | TCB - Static, Stack - Static      | No               | No        |
+ * |     |         |        | xTaskCreateRestrictedStatic |                                   |                  |           |
+ * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
+ * | 1   | 1       | 0      | xTaskCreate,                | 1. TCB - Dynamic, Stack - Dynamic | Yes              | Yes       |
+ * |     |         |        | xTaskCreateRestricted       | 2. TCB - Dynamic, Stack - Static  |                  |           |
+ * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
+ * | 1   | 1       | 1      | xTaskCreate,                | 1. TCB - Dynamic, Stack - Dynamic | Yes              | Yes       |
+ * |     |         |        | xTaskCreateStatic,          | 2. TCB - Dynamic, Stack - Static  |                  |           |
+ * |     |         |        | xTaskCreateRestricted,      | 3. TCB - Static, Stack - Static   |                  |           |
+ * |     |         |        | xTaskCreateRestrictedStatic |                                   |                  |           |
+ * +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+
+ */
+#define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE	( ( ( portUSING_MPU_WRAPPERS == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) || \
+													  ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) )
+
 /*
  * In line with software engineering best practice, FreeRTOS implements a strict
  * data hiding policy, so the real structures used by FreeRTOS to maintain the
@@ -966,25 +1055,40 @@ point support. */
  */
 struct xSTATIC_LIST_ITEM
 {
-	TickType_t xDummy1;
-	void *pvDummy2[ 4 ];
+	#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
+		TickType_t xDummy1;
+	#endif
+	TickType_t xDummy2;
+	void *pvDummy3[ 4 ];
+	#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
+		TickType_t xDummy4;
+	#endif
 };
 typedef struct xSTATIC_LIST_ITEM StaticListItem_t;
 
 /* See the comments above the struct xSTATIC_LIST_ITEM definition. */
 struct xSTATIC_MINI_LIST_ITEM
 {
-	TickType_t xDummy1;
-	void *pvDummy2[ 2 ];
+	#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
+		TickType_t xDummy1;
+	#endif
+	TickType_t xDummy2;
+	void *pvDummy3[ 2 ];
 };
 typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t;
 
 /* See the comments above the struct xSTATIC_LIST_ITEM definition. */
 typedef struct xSTATIC_LIST
 {
-	UBaseType_t uxDummy1;
-	void *pvDummy2;
-	StaticMiniListItem_t xDummy3;
+	#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
+		TickType_t xDummy1;
+	#endif
+	UBaseType_t uxDummy2;
+	void *pvDummy3;
+	StaticMiniListItem_t xDummy4;
+	#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
+		TickType_t xDummy5;
+	#endif
 } StaticList_t;
 
 /*
@@ -1038,7 +1142,7 @@ typedef struct xSTATIC_TCB
 		uint32_t 		ulDummy18;
 		uint8_t 		ucDummy19;
 	#endif
-	#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
+	#if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 )
 		uint8_t			uxDummy20;
 	#endif
 
diff --git a/FreeRTOS/Source/include/StackMacros.h b/FreeRTOS/Source/include/StackMacros.h
deleted file mode 100755
index b6eaec3..0000000
--- a/FreeRTOS/Source/include/StackMacros.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * FreeRTOS Kernel V10.1.1
- * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * http://www.FreeRTOS.org
- * http://aws.amazon.com/freertos
- *
- * 1 tab == 4 spaces!
- */
-
-#ifndef STACK_MACROS_H
-#define STACK_MACROS_H
-
-#ifndef _MSC_VER /* Visual Studio doesn't support #warning. */
-	#warning The name of this file has changed to stack_macros.h.  Please update your code accordingly.  This source file (which has the original name) will be removed in future released.
-#endif
-
-/*
- * Call the stack overflow hook function if the stack of the task being swapped
- * out is currently overflowed, or looks like it might have overflowed in the
- * past.
- *
- * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check
- * the current stack state only - comparing the current top of stack value to
- * the stack limit.  Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1
- * will also cause the last few stack bytes to be checked to ensure the value
- * to which the bytes were set when the task was created have not been
- * overwritten.  Note this second test does not guarantee that an overflowed
- * stack will always be recognised.
- */
-
-/*-----------------------------------------------------------*/
-
-#if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) )
-
-	/* Only the current stack state is to be checked. */
-	#define taskCHECK_FOR_STACK_OVERFLOW()																\
-	{																									\
-		/* Is the currently saved stack pointer within the stack limit? */								\
-		if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack )										\
-		{																								\
-			vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName );	\
-		}																								\
-	}
-
-#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
-/*-----------------------------------------------------------*/
-
-#if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) )
-
-	/* Only the current stack state is to be checked. */
-	#define taskCHECK_FOR_STACK_OVERFLOW()																\
-	{																									\
-																										\
-		/* Is the currently saved stack pointer within the stack limit? */								\
-		if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack )									\
-		{																								\
-			vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName );	\
-		}																								\
-	}
-
-#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
-/*-----------------------------------------------------------*/
-
-#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) )
-
-	#define taskCHECK_FOR_STACK_OVERFLOW()																\
-	{																									\
-		const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack;							\
-		const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5;											\
-																										\
-		if( ( pulStack[ 0 ] != ulCheckValue ) ||												\
-			( pulStack[ 1 ] != ulCheckValue ) ||												\
-			( pulStack[ 2 ] != ulCheckValue ) ||												\
-			( pulStack[ 3 ] != ulCheckValue ) )												\
-		{																								\
-			vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName );	\
-		}																								\
-	}
-
-#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
-/*-----------------------------------------------------------*/
-
-#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) )
-
-	#define taskCHECK_FOR_STACK_OVERFLOW()																								\
-	{																																	\
-	int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack;																		\
-	static const uint8_t ucExpectedStackBytes[] = {	tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE,		\
-													tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE,		\
-													tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE,		\
-													tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE,		\
-													tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE };	\
-																																		\
-																																		\
-		pcEndOfStack -= sizeof( ucExpectedStackBytes );																					\
-																																		\
-		/* Has the extremity of the task stack ever been written over? */																\
-		if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 )					\
-		{																																\
-			vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName );									\
-		}																																\
-	}
-
-#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
-/*-----------------------------------------------------------*/
-
-/* Remove stack overflow macro if not being used. */
-#ifndef taskCHECK_FOR_STACK_OVERFLOW
-	#define taskCHECK_FOR_STACK_OVERFLOW()
-#endif
-
-
-
-#endif /* STACK_MACROS_H */
-
diff --git a/FreeRTOS/Source/include/atomic.h b/FreeRTOS/Source/include/atomic.h
new file mode 100755
index 0000000..3d23ca4
--- /dev/null
+++ b/FreeRTOS/Source/include/atomic.h
@@ -0,0 +1,547 @@
+/*
+ * FreeRTOS Kernel V10.2.1
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+
+/**
+ * @file atomic.h
+ * @brief FreeRTOS atomic operation support.
+ *
+ * Two implementations of atomic are given in this header file:
+ * 1. Disabling interrupt globally.
+ * 2. ISA native atomic support.
+ * The former is available to all ports (compiler-architecture combination),
+ * while the latter is only available to ports compiling with GCC (version at
+ * least 4.7.0), which also have ISA atomic support.
+ *
+ * User can select which implementation to use by:
+ * setting/clearing configUSE_ATOMIC_INSTRUCTION in FreeRTOSConfig.h.
+ * Define AND set configUSE_ATOMIC_INSTRUCTION to 1 for ISA native atomic support.
+ * Undefine OR clear configUSE_ATOMIC_INSTRUCTION for disabling global interrupt
+ * implementation.
+ *
+ * @see GCC Built-in Functions for Memory Model Aware Atomic Operations
+ *      https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
+ */
+
+#ifndef ATOMIC_H
+#define ATOMIC_H
+
+#ifndef INC_FREERTOS_H
+    #error "include FreeRTOS.h must appear in source files before include atomic.h"
+#endif
+
+/* Standard includes. */
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+
+    /* Needed for __atomic_compare_exchange() weak=false. */
+    #include 
+
+    /* This branch is for GCC compiler and GCC compiler only. */
+    #ifndef portFORCE_INLINE
+        #define portFORCE_INLINE  inline __attribute__((always_inline))
+    #endif
+
+#else
+
+    /* Port specific definitions -- entering/exiting critical section.
+     * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
+     *
+     * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
+     * ATOMIC_ENTER_CRITICAL().
+     */
+    #if defined( portSET_INTERRUPT_MASK_FROM_ISR )
+
+        /* Nested interrupt scheme is supported in this port. */
+        #define ATOMIC_ENTER_CRITICAL()     \
+            UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
+
+        #define ATOMIC_EXIT_CRITICAL()      \
+            portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType )
+
+    #else
+
+        /* Nested interrupt scheme is NOT supported in this port. */
+        #define ATOMIC_ENTER_CRITICAL()     portENTER_CRITICAL()
+        #define ATOMIC_EXIT_CRITICAL()      portEXIT_CRITICAL()
+
+    #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
+
+    /* Port specific definition -- "always inline". 
+     * Inline is compiler specific, and may not always get inlined depending on your optimization level. 
+     * Also, inline is considerred as performance optimization for atomic. 
+     * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error,
+     * simply define it. 
+     */
+    #ifndef portFORCE_INLINE
+        #define portFORCE_INLINE 
+    #endif
+
+#endif /* configUSE_GCC_BUILTIN_ATOMICS */
+
+#define ATOMIC_COMPARE_AND_SWAP_SUCCESS     0x1U        /**< Compare and swap succeeded, swapped. */
+#define ATOMIC_COMPARE_AND_SWAP_FAILURE     0x0U        /**< Compare and swap failed, did not swap. */
+
+/*----------------------------- Swap && CAS ------------------------------*/
+
+/**
+ * Atomic compare-and-swap
+ *
+ * @brief Performs an atomic compare-and-swap operation on the specified values.
+ *
+ * @param[in, out] pDestination  Pointer to memory location from where value is
+ *                               to be loaded and checked.
+ * @param[in] ulExchange         If condition meets, write this value to memory.
+ * @param[in] ulComparand        Swap condition.
+ *
+ * @return Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped.
+ *
+ * @note This function only swaps *pDestination with ulExchange, if previous
+ *       *pDestination value equals ulComparand.
+ */
+static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32(
+        uint32_t volatile * pDestination,
+        uint32_t ulExchange,
+        uint32_t ulComparand )
+{
+
+    uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
+
+#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+
+    if ( __atomic_compare_exchange( pDestination,
+                                    &ulComparand,
+                                    &ulExchange,
+                                    false,
+                                    __ATOMIC_SEQ_CST,
+                                    __ATOMIC_SEQ_CST ) )
+    {
+        ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+    }
+
+#else
+
+    ATOMIC_ENTER_CRITICAL();
+
+    if ( *pDestination == ulComparand )
+    {
+        *pDestination = ulExchange;
+        ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+    }
+
+    ATOMIC_EXIT_CRITICAL();
+
+#endif
+
+    return ulReturnValue;
+
+}
+
+/**
+ * Atomic swap (pointers)
+ *
+ * @brief Atomically sets the address pointed to by *ppDestination to the value
+ *        of *pExchange.
+ *
+ * @param[in, out] ppDestination  Pointer to memory location from where a pointer
+ *                                value is to be loaded and written back to.
+ * @param[in] pExchange           Pointer value to be written to *ppDestination.
+ *
+ * @return The initial value of *ppDestination.
+ */
+static portFORCE_INLINE void * Atomic_SwapPointers_p32(
+        void * volatile * ppDestination,
+        void * pExchange )
+{
+    void * pReturnValue;
+
+#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+
+    __atomic_exchange( ppDestination, &pExchange, &pReturnValue, __ATOMIC_SEQ_CST );
+
+#else
+
+    ATOMIC_ENTER_CRITICAL();
+
+    pReturnValue = *ppDestination;
+
+    *ppDestination = pExchange;
+
+    ATOMIC_EXIT_CRITICAL();
+
+#endif
+
+    return pReturnValue;
+}
+
+/**
+ * Atomic compare-and-swap (pointers)
+ *
+ * @brief Performs an atomic compare-and-swap operation on the specified pointer
+ *        values.
+ *
+ * @param[in, out] ppDestination  Pointer to memory location from where a pointer
+ *                                value is to be loaded and checked.
+ * @param[in] pExchange           If condition meets, write this value to memory.
+ * @param[in] pComparand          Swap condition.
+ *
+ * @return Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped.
+ *
+ * @note This function only swaps *ppDestination with pExchange, if previous
+ *       *ppDestination value equals pComparand.
+ */
+static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32(
+        void * volatile * ppDestination,
+        void * pExchange, void * pComparand )
+{
+    uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
+
+#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+    if ( __atomic_compare_exchange( ppDestination,
+                                    &pComparand,
+                                    &pExchange,
+                                    false,
+                                    __ATOMIC_SEQ_CST,
+                                    __ATOMIC_SEQ_CST ) )
+    {
+        ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+    }
+
+#else
+
+    ATOMIC_ENTER_CRITICAL();
+
+    if ( *ppDestination == pComparand )
+    {
+        *ppDestination = pExchange;
+        ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+    }
+
+    ATOMIC_EXIT_CRITICAL();
+
+#endif
+
+    return ulReturnValue;
+}
+
+
+/*----------------------------- Arithmetic ------------------------------*/
+
+/**
+ * Atomic add
+ *
+ * @brief Atomically adds count to the value of the specified pointer points to.
+ *
+ * @param[in,out] pAddend  Pointer to memory location from where value is to be
+ *                         loaded and written back to.
+ * @param[in] ulCount      Value to be added to *pAddend.
+ *
+ * @return previous *pAddend value.
+ */
+static portFORCE_INLINE uint32_t Atomic_Add_u32(
+        uint32_t volatile * pAddend,
+        uint32_t ulCount )
+{
+#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+
+    return __atomic_fetch_add(pAddend, ulCount, __ATOMIC_SEQ_CST);
+
+#else
+
+    uint32_t ulCurrent;
+
+    ATOMIC_ENTER_CRITICAL();
+
+    ulCurrent = *pAddend;
+
+    *pAddend += ulCount;
+
+    ATOMIC_EXIT_CRITICAL();
+
+    return ulCurrent;
+
+#endif
+}
+
+/**
+ * Atomic subtract
+ *
+ * @brief Atomically subtracts count from the value of the specified pointer
+ *        pointers to.
+ *
+ * @param[in,out] pAddend  Pointer to memory location from where value is to be
+ *                         loaded and written back to.
+ * @param[in] ulCount      Value to be subtract from *pAddend.
+ *
+ * @return previous *pAddend value.
+ */
+static portFORCE_INLINE uint32_t Atomic_Subtract_u32(
+        uint32_t volatile * pAddend,
+        uint32_t ulCount )
+{
+#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+
+    return __atomic_fetch_sub(pAddend, ulCount, __ATOMIC_SEQ_CST);
+
+#else
+
+    uint32_t ulCurrent;
+
+    ATOMIC_ENTER_CRITICAL();
+
+    ulCurrent = *pAddend;
+
+    *pAddend -= ulCount;
+
+    ATOMIC_EXIT_CRITICAL();
+
+    return ulCurrent;
+
+#endif
+}
+
+/**
+ * Atomic increment
+ *
+ * @brief Atomically increments the value of the specified pointer points to.
+ *
+ * @param[in,out] pAddend  Pointer to memory location from where value is to be
+ *                         loaded and written back to.
+ *
+ * @return *pAddend value before increment.
+ */
+static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend )
+{
+#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+
+    return __atomic_fetch_add(pAddend, 1, __ATOMIC_SEQ_CST);
+
+#else
+
+    uint32_t ulCurrent;
+
+    ATOMIC_ENTER_CRITICAL();
+
+    ulCurrent = *pAddend;
+
+    *pAddend += 1;
+
+    ATOMIC_EXIT_CRITICAL();
+
+    return ulCurrent;
+
+#endif
+}
+
+/**
+ * Atomic decrement
+ *
+ * @brief Atomically decrements the value of the specified pointer points to
+ *
+ * @param[in,out] pAddend  Pointer to memory location from where value is to be
+ *                         loaded and written back to.
+ *
+ * @return *pAddend value before decrement.
+ */
+static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend )
+{
+#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+
+    return __atomic_fetch_sub(pAddend, 1, __ATOMIC_SEQ_CST);
+
+#else
+
+    uint32_t ulCurrent;
+
+    ATOMIC_ENTER_CRITICAL();
+
+    ulCurrent = *pAddend;
+
+    *pAddend -= 1;
+
+    ATOMIC_EXIT_CRITICAL();
+
+    return ulCurrent;
+
+#endif
+}
+
+/*----------------------------- Bitwise Logical ------------------------------*/
+
+/**
+ * Atomic OR
+ *
+ * @brief Performs an atomic OR operation on the specified values.
+ *
+ * @param [in, out] pDestination  Pointer to memory location from where value is
+ *                                to be loaded and written back to.
+ * @param [in] ulValue            Value to be ORed with *pDestination.
+ *
+ * @return The original value of *pDestination.
+ */
+static portFORCE_INLINE uint32_t Atomic_OR_u32(
+        uint32_t volatile * pDestination,
+        uint32_t ulValue )
+{
+#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+
+    return __atomic_fetch_or(pDestination, ulValue, __ATOMIC_SEQ_CST);
+
+#else
+
+    uint32_t ulCurrent;
+
+    ATOMIC_ENTER_CRITICAL();
+
+    ulCurrent = *pDestination;
+
+    *pDestination |= ulValue;
+
+    ATOMIC_EXIT_CRITICAL();
+
+    return ulCurrent;
+
+#endif
+}
+
+/**
+ * Atomic AND
+ *
+ * @brief Performs an atomic AND operation on the specified values.
+ *
+ * @param [in, out] pDestination  Pointer to memory location from where value is
+ *                                to be loaded and written back to.
+ * @param [in] ulValue            Value to be ANDed with *pDestination.
+ *
+ * @return The original value of *pDestination.
+ */
+static portFORCE_INLINE uint32_t Atomic_AND_u32(
+        uint32_t volatile * pDestination,
+        uint32_t ulValue )
+{
+#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+
+    return __atomic_fetch_and(pDestination, ulValue, __ATOMIC_SEQ_CST);
+
+#else
+
+    uint32_t ulCurrent;
+
+    ATOMIC_ENTER_CRITICAL();
+
+    ulCurrent = *pDestination;
+
+    *pDestination &= ulValue;
+
+    ATOMIC_EXIT_CRITICAL();
+
+    return ulCurrent;
+
+#endif
+}
+
+/**
+ * Atomic NAND
+ *
+ * @brief Performs an atomic NAND operation on the specified values.
+ *
+ * @param [in, out] pDestination  Pointer to memory location from where value is
+ *                                to be loaded and written back to.
+ * @param [in] ulValue            Value to be NANDed with *pDestination.
+ *
+ * @return The original value of *pDestination.
+ */
+static portFORCE_INLINE uint32_t Atomic_NAND_u32(
+        uint32_t volatile * pDestination,
+        uint32_t ulValue )
+{
+#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+
+    return __atomic_fetch_nand(pDestination, ulValue, __ATOMIC_SEQ_CST);
+
+#else
+
+    uint32_t ulCurrent;
+
+    ATOMIC_ENTER_CRITICAL();
+
+    ulCurrent = *pDestination;
+
+    *pDestination = ~(ulCurrent & ulValue);
+
+    ATOMIC_EXIT_CRITICAL();
+
+    return ulCurrent;
+
+#endif
+}
+
+/**
+ * Atomic XOR
+ *
+ * @brief Performs an atomic XOR operation on the specified values.
+ *
+ * @param [in, out] pDestination  Pointer to memory location from where value is
+ *                                to be loaded and written back to.
+ * @param [in] ulValue            Value to be XORed with *pDestination.
+ *
+ * @return The original value of *pDestination.
+ */
+static portFORCE_INLINE uint32_t Atomic_XOR_u32(
+        uint32_t volatile * pDestination,
+        uint32_t ulValue )
+{
+#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+
+    return __atomic_fetch_xor(pDestination, ulValue, __ATOMIC_SEQ_CST);
+
+#else
+
+    uint32_t ulCurrent;
+
+    ATOMIC_ENTER_CRITICAL();
+
+    ulCurrent = *pDestination;
+
+    *pDestination ^= ulValue;
+
+    ATOMIC_EXIT_CRITICAL();
+
+    return ulCurrent;
+
+#endif
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ATOMIC_H */
diff --git a/FreeRTOS/Source/include/croutine.h b/FreeRTOS/Source/include/croutine.h
deleted file mode 100755
index 6f66fdc..0000000
--- a/FreeRTOS/Source/include/croutine.h
+++ /dev/null
@@ -1,720 +0,0 @@
-/*
- * FreeRTOS Kernel V10.1.1
- * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * http://www.FreeRTOS.org
- * http://aws.amazon.com/freertos
- *
- * 1 tab == 4 spaces!
- */
-
-#ifndef CO_ROUTINE_H
-#define CO_ROUTINE_H
-
-#ifndef INC_FREERTOS_H
-	#error "include FreeRTOS.h must appear in source files before include croutine.h"
-#endif
-
-#include "list.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Used to hide the implementation of the co-routine control block.  The
-control block structure however has to be included in the header due to
-the macro implementation of the co-routine functionality. */
-typedef void * CoRoutineHandle_t;
-
-/* Defines the prototype to which co-routine functions must conform. */
-typedef void (*crCOROUTINE_CODE)( CoRoutineHandle_t, UBaseType_t );
-
-typedef struct corCoRoutineControlBlock
-{
-	crCOROUTINE_CODE 	pxCoRoutineFunction;
-	ListItem_t			xGenericListItem;	/*< List item used to place the CRCB in ready and blocked queues. */
-	ListItem_t			xEventListItem;		/*< List item used to place the CRCB in event lists. */
-	UBaseType_t 		uxPriority;			/*< The priority of the co-routine in relation to other co-routines. */
-	UBaseType_t 		uxIndex;			/*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */
-	uint16_t 			uxState;			/*< Used internally by the co-routine implementation. */
-} CRCB_t; /* Co-routine control block.  Note must be identical in size down to uxPriority with TCB_t. */
-
-/**
- * croutine. h
- *
- BaseType_t xCoRoutineCreate(
-                                 crCOROUTINE_CODE pxCoRoutineCode,
-                                 UBaseType_t uxPriority,
-                                 UBaseType_t uxIndex
-                               );
- * - * Create a new co-routine and add it to the list of co-routines that are - * ready to run. - * - * @param pxCoRoutineCode Pointer to the co-routine function. Co-routine - * functions require special syntax - see the co-routine section of the WEB - * documentation for more information. - * - * @param uxPriority The priority with respect to other co-routines at which - * the co-routine will run. - * - * @param uxIndex Used to distinguish between different co-routines that - * execute the same function. See the example below and the co-routine section - * of the WEB documentation for further information. - * - * @return pdPASS if the co-routine was successfully created and added to a ready - * list, otherwise an error code defined with ProjDefs.h. - * - * Example usage: -
- // Co-routine to be created.
- void vFlashCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- // This may not be necessary for const variables.
- static const char cLedToFlash[ 2 ] = { 5, 6 };
- static const TickType_t uxFlashRates[ 2 ] = { 200, 400 };
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // This co-routine just delays for a fixed period, then toggles
-         // an LED.  Two co-routines are created using this function, so
-         // the uxIndex parameter is used to tell the co-routine which
-         // LED to flash and how int32_t to delay.  This assumes xQueue has
-         // already been created.
-         vParTestToggleLED( cLedToFlash[ uxIndex ] );
-         crDELAY( xHandle, uxFlashRates[ uxIndex ] );
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
-
- // Function that creates two co-routines.
- void vOtherFunction( void )
- {
- uint8_t ucParameterToPass;
- TaskHandle_t xHandle;
-
-     // Create two co-routines at priority 0.  The first is given index 0
-     // so (from the code above) toggles LED 5 every 200 ticks.  The second
-     // is given index 1 so toggles LED 6 every 400 ticks.
-     for( uxIndex = 0; uxIndex < 2; uxIndex++ )
-     {
-         xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex );
-     }
- }
-   
- * \defgroup xCoRoutineCreate xCoRoutineCreate - * \ingroup Tasks - */ -BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex ); - - -/** - * croutine. h - *
- void vCoRoutineSchedule( void );
- * - * Run a co-routine. - * - * vCoRoutineSchedule() executes the highest priority co-routine that is able - * to run. The co-routine will execute until it either blocks, yields or is - * preempted by a task. Co-routines execute cooperatively so one - * co-routine cannot be preempted by another, but can be preempted by a task. - * - * If an application comprises of both tasks and co-routines then - * vCoRoutineSchedule should be called from the idle task (in an idle task - * hook). - * - * Example usage: -
- // This idle task hook will schedule a co-routine each time it is called.
- // The rest of the idle task will execute between co-routine calls.
- void vApplicationIdleHook( void )
- {
-	vCoRoutineSchedule();
- }
-
- // Alternatively, if you do not require any other part of the idle task to
- // execute, the idle task hook can call vCoRoutineScheduler() within an
- // infinite loop.
- void vApplicationIdleHook( void )
- {
-    for( ;; )
-    {
-        vCoRoutineSchedule();
-    }
- }
- 
- * \defgroup vCoRoutineSchedule vCoRoutineSchedule - * \ingroup Tasks - */ -void vCoRoutineSchedule( void ); - -/** - * croutine. h - *
- crSTART( CoRoutineHandle_t xHandle );
- * - * This macro MUST always be called at the start of a co-routine function. - * - * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static int32_t ulAVariable;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-          // Co-routine functionality goes here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
- * \defgroup crSTART crSTART - * \ingroup Tasks - */ -#define crSTART( pxCRCB ) switch( ( ( CRCB_t * )( pxCRCB ) )->uxState ) { case 0: - -/** - * croutine. h - *
- crEND();
- * - * This macro MUST always be called at the end of a co-routine function. - * - * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static int32_t ulAVariable;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-          // Co-routine functionality goes here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
- * \defgroup crSTART crSTART - * \ingroup Tasks - */ -#define crEND() } - -/* - * These macros are intended for internal use by the co-routine implementation - * only. The macros should not be used directly by application writers. - */ -#define crSET_STATE0( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2): -#define crSET_STATE1( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1): - -/** - * croutine. h - *
- crDELAY( CoRoutineHandle_t xHandle, TickType_t xTicksToDelay );
- * - * Delay a co-routine for a fixed period of time. - * - * crDELAY can only be called from the co-routine function itself - not - * from within a function called by the co-routine function. This is because - * co-routines do not maintain their own stack. - * - * @param xHandle The handle of the co-routine to delay. This is the xHandle - * parameter of the co-routine function. - * - * @param xTickToDelay The number of ticks that the co-routine should delay - * for. The actual amount of time this equates to is defined by - * configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant portTICK_PERIOD_MS - * can be used to convert ticks to milliseconds. - * - * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- // This may not be necessary for const variables.
- // We are to delay for 200ms.
- static const xTickType xDelayTime = 200 / portTICK_PERIOD_MS;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-        // Delay for 200ms.
-        crDELAY( xHandle, xDelayTime );
-
-        // Do something here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
- * \defgroup crDELAY crDELAY - * \ingroup Tasks - */ -#define crDELAY( xHandle, xTicksToDelay ) \ - if( ( xTicksToDelay ) > 0 ) \ - { \ - vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \ - } \ - crSET_STATE0( ( xHandle ) ); - -/** - *
- crQUEUE_SEND(
-                  CoRoutineHandle_t xHandle,
-                  QueueHandle_t pxQueue,
-                  void *pvItemToQueue,
-                  TickType_t xTicksToWait,
-                  BaseType_t *pxResult
-             )
- * - * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine - * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. - * - * crQUEUE_SEND and crQUEUE_RECEIVE can only be used from a co-routine whereas - * xQueueSend() and xQueueReceive() can only be used from tasks. - * - * crQUEUE_SEND can only be called from the co-routine function itself - not - * from within a function called by the co-routine function. This is because - * co-routines do not maintain their own stack. - * - * See the co-routine section of the WEB documentation for information on - * passing data between tasks and co-routines and between ISR's and - * co-routines. - * - * @param xHandle The handle of the calling co-routine. This is the xHandle - * parameter of the co-routine function. - * - * @param pxQueue The handle of the queue on which the data will be posted. - * The handle is obtained as the return value when the queue is created using - * the xQueueCreate() API function. - * - * @param pvItemToQueue A pointer to the data being posted onto the queue. - * The number of bytes of each queued item is specified when the queue is - * created. This number of bytes is copied from pvItemToQueue into the queue - * itself. - * - * @param xTickToDelay The number of ticks that the co-routine should block - * to wait for space to become available on the queue, should space not be - * available immediately. The actual amount of time this equates to is defined - * by configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant - * portTICK_PERIOD_MS can be used to convert ticks to milliseconds (see example - * below). - * - * @param pxResult The variable pointed to by pxResult will be set to pdPASS if - * data was successfully posted onto the queue, otherwise it will be set to an - * error defined within ProjDefs.h. - * - * Example usage: -
- // Co-routine function that blocks for a fixed period then posts a number onto
- // a queue.
- static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static BaseType_t xNumberToPost = 0;
- static BaseType_t xResult;
-
-    // Co-routines must begin with a call to crSTART().
-    crSTART( xHandle );
-
-    for( ;; )
-    {
-        // This assumes the queue has already been created.
-        crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult );
-
-        if( xResult != pdPASS )
-        {
-            // The message was not posted!
-        }
-
-        // Increment the number to be posted onto the queue.
-        xNumberToPost++;
-
-        // Delay for 100 ticks.
-        crDELAY( xHandle, 100 );
-    }
-
-    // Co-routines must end with a call to crEND().
-    crEND();
- }
- * \defgroup crQUEUE_SEND crQUEUE_SEND - * \ingroup Tasks - */ -#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \ -{ \ - *( pxResult ) = xQueueCRSend( ( pxQueue) , ( pvItemToQueue) , ( xTicksToWait ) ); \ - if( *( pxResult ) == errQUEUE_BLOCKED ) \ - { \ - crSET_STATE0( ( xHandle ) ); \ - *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \ - } \ - if( *pxResult == errQUEUE_YIELD ) \ - { \ - crSET_STATE1( ( xHandle ) ); \ - *pxResult = pdPASS; \ - } \ -} - -/** - * croutine. h - *
-  crQUEUE_RECEIVE(
-                     CoRoutineHandle_t xHandle,
-                     QueueHandle_t pxQueue,
-                     void *pvBuffer,
-                     TickType_t xTicksToWait,
-                     BaseType_t *pxResult
-                 )
- * - * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine - * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. - * - * crQUEUE_SEND and crQUEUE_RECEIVE can only be used from a co-routine whereas - * xQueueSend() and xQueueReceive() can only be used from tasks. - * - * crQUEUE_RECEIVE can only be called from the co-routine function itself - not - * from within a function called by the co-routine function. This is because - * co-routines do not maintain their own stack. - * - * See the co-routine section of the WEB documentation for information on - * passing data between tasks and co-routines and between ISR's and - * co-routines. - * - * @param xHandle The handle of the calling co-routine. This is the xHandle - * parameter of the co-routine function. - * - * @param pxQueue The handle of the queue from which the data will be received. - * The handle is obtained as the return value when the queue is created using - * the xQueueCreate() API function. - * - * @param pvBuffer The buffer into which the received item is to be copied. - * The number of bytes of each queued item is specified when the queue is - * created. This number of bytes is copied into pvBuffer. - * - * @param xTickToDelay The number of ticks that the co-routine should block - * to wait for data to become available from the queue, should data not be - * available immediately. The actual amount of time this equates to is defined - * by configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant - * portTICK_PERIOD_MS can be used to convert ticks to milliseconds (see the - * crQUEUE_SEND example). - * - * @param pxResult The variable pointed to by pxResult will be set to pdPASS if - * data was successfully retrieved from the queue, otherwise it will be set to - * an error code as defined within ProjDefs.h. - * - * Example usage: -
- // A co-routine receives the number of an LED to flash from a queue.  It
- // blocks on the queue until the number is received.
- static void prvCoRoutineFlashWorkTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static BaseType_t xResult;
- static UBaseType_t uxLEDToFlash;
-
-    // All co-routines must start with a call to crSTART().
-    crSTART( xHandle );
-
-    for( ;; )
-    {
-        // Wait for data to become available on the queue.
-        crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
-
-        if( xResult == pdPASS )
-        {
-            // We received the LED to flash - flash it!
-            vParTestToggleLED( uxLEDToFlash );
-        }
-    }
-
-    crEND();
- }
- * \defgroup crQUEUE_RECEIVE crQUEUE_RECEIVE - * \ingroup Tasks - */ -#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \ -{ \ - *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), ( xTicksToWait ) ); \ - if( *( pxResult ) == errQUEUE_BLOCKED ) \ - { \ - crSET_STATE0( ( xHandle ) ); \ - *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), 0 ); \ - } \ - if( *( pxResult ) == errQUEUE_YIELD ) \ - { \ - crSET_STATE1( ( xHandle ) ); \ - *( pxResult ) = pdPASS; \ - } \ -} - -/** - * croutine. h - *
-  crQUEUE_SEND_FROM_ISR(
-                            QueueHandle_t pxQueue,
-                            void *pvItemToQueue,
-                            BaseType_t xCoRoutinePreviouslyWoken
-                       )
- * - * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the - * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() - * functions used by tasks. - * - * crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() can only be used to - * pass data between a co-routine and and ISR, whereas xQueueSendFromISR() and - * xQueueReceiveFromISR() can only be used to pass data between a task and and - * ISR. - * - * crQUEUE_SEND_FROM_ISR can only be called from an ISR to send data to a queue - * that is being used from within a co-routine. - * - * See the co-routine section of the WEB documentation for information on - * passing data between tasks and co-routines and between ISR's and - * co-routines. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param xCoRoutinePreviouslyWoken This is included so an ISR can post onto - * the same queue multiple times from a single interrupt. The first call - * should always pass in pdFALSE. Subsequent calls should pass in - * the value returned from the previous call. - * - * @return pdTRUE if a co-routine was woken by posting onto the queue. This is - * used by the ISR to determine if a context switch may be required following - * the ISR. - * - * Example usage: -
- // A co-routine that blocks on a queue waiting for characters to be received.
- static void vReceivingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- char cRxedChar;
- BaseType_t xResult;
-
-     // All co-routines must start with a call to crSTART().
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // Wait for data to become available on the queue.  This assumes the
-         // queue xCommsRxQueue has already been created!
-         crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
-
-         // Was a character received?
-         if( xResult == pdPASS )
-         {
-             // Process the character here.
-         }
-     }
-
-     // All co-routines must end with a call to crEND().
-     crEND();
- }
-
- // An ISR that uses a queue to send characters received on a serial port to
- // a co-routine.
- void vUART_ISR( void )
- {
- char cRxedChar;
- BaseType_t xCRWokenByPost = pdFALSE;
-
-     // We loop around reading characters until there are none left in the UART.
-     while( UART_RX_REG_NOT_EMPTY() )
-     {
-         // Obtain the character from the UART.
-         cRxedChar = UART_RX_REG;
-
-         // Post the character onto a queue.  xCRWokenByPost will be pdFALSE
-         // the first time around the loop.  If the post causes a co-routine
-         // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE.
-         // In this manner we can ensure that if more than one co-routine is
-         // blocked on the queue only one is woken by this ISR no matter how
-         // many characters are posted to the queue.
-         xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost );
-     }
- }
- * \defgroup crQUEUE_SEND_FROM_ISR crQUEUE_SEND_FROM_ISR - * \ingroup Tasks - */ -#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) ) - - -/** - * croutine. h - *
-  crQUEUE_SEND_FROM_ISR(
-                            QueueHandle_t pxQueue,
-                            void *pvBuffer,
-                            BaseType_t * pxCoRoutineWoken
-                       )
- * - * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the - * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() - * functions used by tasks. - * - * crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() can only be used to - * pass data between a co-routine and and ISR, whereas xQueueSendFromISR() and - * xQueueReceiveFromISR() can only be used to pass data between a task and and - * ISR. - * - * crQUEUE_RECEIVE_FROM_ISR can only be called from an ISR to receive data - * from a queue that is being used from within a co-routine (a co-routine - * posted to the queue). - * - * See the co-routine section of the WEB documentation for information on - * passing data between tasks and co-routines and between ISR's and - * co-routines. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvBuffer A pointer to a buffer into which the received item will be - * placed. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from the queue into - * pvBuffer. - * - * @param pxCoRoutineWoken A co-routine may be blocked waiting for space to become - * available on the queue. If crQUEUE_RECEIVE_FROM_ISR causes such a - * co-routine to unblock *pxCoRoutineWoken will get set to pdTRUE, otherwise - * *pxCoRoutineWoken will remain unchanged. - * - * @return pdTRUE an item was successfully received from the queue, otherwise - * pdFALSE. - * - * Example usage: -
- // A co-routine that posts a character to a queue then blocks for a fixed
- // period.  The character is incremented each time.
- static void vSendingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // cChar holds its value while this co-routine is blocked and must therefore
- // be declared static.
- static char cCharToTx = 'a';
- BaseType_t xResult;
-
-     // All co-routines must start with a call to crSTART().
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // Send the next character to the queue.
-         crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult );
-
-         if( xResult == pdPASS )
-         {
-             // The character was successfully posted to the queue.
-         }
-		 else
-		 {
-			// Could not post the character to the queue.
-		 }
-
-         // Enable the UART Tx interrupt to cause an interrupt in this
-		 // hypothetical UART.  The interrupt will obtain the character
-		 // from the queue and send it.
-		 ENABLE_RX_INTERRUPT();
-
-		 // Increment to the next character then block for a fixed period.
-		 // cCharToTx will maintain its value across the delay as it is
-		 // declared static.
-		 cCharToTx++;
-		 if( cCharToTx > 'x' )
-		 {
-			cCharToTx = 'a';
-		 }
-		 crDELAY( 100 );
-     }
-
-     // All co-routines must end with a call to crEND().
-     crEND();
- }
-
- // An ISR that uses a queue to receive characters to send on a UART.
- void vUART_ISR( void )
- {
- char cCharToTx;
- BaseType_t xCRWokenByPost = pdFALSE;
-
-     while( UART_TX_REG_EMPTY() )
-     {
-         // Are there any characters in the queue waiting to be sent?
-		 // xCRWokenByPost will automatically be set to pdTRUE if a co-routine
-		 // is woken by the post - ensuring that only a single co-routine is
-		 // woken no matter how many times we go around this loop.
-         if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) )
-		 {
-			 SEND_CHARACTER( cCharToTx );
-		 }
-     }
- }
- * \defgroup crQUEUE_RECEIVE_FROM_ISR crQUEUE_RECEIVE_FROM_ISR - * \ingroup Tasks - */ -#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) ) - -/* - * This function is intended for internal use by the co-routine macros only. - * The macro nature of the co-routine implementation requires that the - * prototype appears here. The function should not be used by application - * writers. - * - * Removes the current co-routine from its ready list and places it in the - * appropriate delayed list. - */ -void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList ); - -/* - * This function is intended for internal use by the queue implementation only. - * The function should not be used by application writers. - * - * Removes the highest priority co-routine from the event list and places it in - * the pending ready list. - */ -BaseType_t xCoRoutineRemoveFromEventList( const List_t *pxEventList ); - -#ifdef __cplusplus -} -#endif - -#endif /* CO_ROUTINE_H */ diff --git a/FreeRTOS/Source/include/deprecated_definitions.h b/FreeRTOS/Source/include/deprecated_definitions.h index c747847..9cece98 100755 --- a/FreeRTOS/Source/include/deprecated_definitions.h +++ b/FreeRTOS/Source/include/deprecated_definitions.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/include/event_groups.h b/FreeRTOS/Source/include/event_groups.h index e40c544..1f38bdb 100755 --- a/FreeRTOS/Source/include/event_groups.h +++ b/FreeRTOS/Source/include/event_groups.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/include/list.h b/FreeRTOS/Source/include/list.h index 43e0fff..2fb6775 100755 --- a/FreeRTOS/Source/include/list.h +++ b/FreeRTOS/Source/include/list.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/include/message_buffer.h b/FreeRTOS/Source/include/message_buffer.h index e62e42d..cfa08cb 100755 --- a/FreeRTOS/Source/include/message_buffer.h +++ b/FreeRTOS/Source/include/message_buffer.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -692,6 +692,7 @@ size_t xMessageBufferSpaceAvailable( MessageBufferHandle_t xMessageBuffer ) ); * \ingroup MessageBufferManagement */ #define xMessageBufferSpaceAvailable( xMessageBuffer ) xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) +#define xMessageBufferSpacesAvailable( xMessageBuffer ) xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) /* Corrects typo in original macro name. */ /** * message_buffer.h diff --git a/FreeRTOS/Source/include/mpu_prototypes.h b/FreeRTOS/Source/include/mpu_prototypes.h index 850e430..5d74907 100755 --- a/FreeRTOS/Source/include/mpu_prototypes.h +++ b/FreeRTOS/Source/include/mpu_prototypes.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -38,119 +38,118 @@ #define MPU_PROTOTYPES_H /* MPU versions of tasks.h API functions. */ -BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask ); -TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode, const char * const pcName, const uint32_t ulStackDepth, void * const pvParameters, UBaseType_t uxPriority, StackType_t * const puxStackBuffer, StaticTask_t * const pxTaskBuffer ); -BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ); -BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ); -void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ); -void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ); -void MPU_vTaskDelay( const TickType_t xTicksToDelay ); -void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ); -BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ); -UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t xTask ); -eTaskState MPU_eTaskGetState( TaskHandle_t xTask ); -void MPU_vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ); -void MPU_vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ); -void MPU_vTaskSuspend( TaskHandle_t xTaskToSuspend ); -void MPU_vTaskResume( TaskHandle_t xTaskToResume ); -void MPU_vTaskStartScheduler( void ); -void MPU_vTaskSuspendAll( void ); -BaseType_t MPU_xTaskResumeAll( void ); -TickType_t MPU_xTaskGetTickCount( void ); -UBaseType_t MPU_uxTaskGetNumberOfTasks( void ); -char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ); -TaskHandle_t MPU_xTaskGetHandle( const char *pcNameToQuery ); -UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ); -configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ); -void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ); -TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ); -TaskHookFunction_t MPU_xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ); -void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ); -void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ); -BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ); -TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ); -UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ); -void MPU_vTaskList( char * pcWriteBuffer ); -void MPU_vTaskGetRunTimeStats( char *pcWriteBuffer ); -BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ); -BaseType_t MPU_xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ); -uint32_t MPU_ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ); -BaseType_t MPU_xTaskNotifyStateClear( TaskHandle_t xTask ); -BaseType_t MPU_xTaskIncrementTick( void ); -TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ); -void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ); -BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ); -void MPU_vTaskMissedYield( void ); -BaseType_t MPU_xTaskGetSchedulerState( void ); +BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode, const char * const pcName, const uint32_t ulStackDepth, void * const pvParameters, UBaseType_t uxPriority, StackType_t * const puxStackBuffer, StaticTask_t * const pxTaskBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskDelay( const TickType_t xTicksToDelay ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +eTaskState MPU_eTaskGetState( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSuspend( TaskHandle_t xTaskToSuspend ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskResume( TaskHandle_t xTaskToResume ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskStartScheduler( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSuspendAll( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskResumeAll( void ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTaskGetTickCount( void ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) FREERTOS_SYSTEM_CALL; +char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetHandle( const char *pcNameToQuery ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ) FREERTOS_SYSTEM_CALL; +TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) FREERTOS_SYSTEM_CALL; +void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTaskGetIdleRunTimeCounter( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskList( char * pcWriteBuffer ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskGetRunTimeStats( char *pcWriteBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +uint32_t MPU_ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskNotifyStateClear( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskIncrementTick( void ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskMissedYield( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGetSchedulerState( void ) FREERTOS_SYSTEM_CALL; /* MPU versions of queue.h API functions. */ -BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ); -BaseType_t MPU_xQueueReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ); -BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ); -BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ); -UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t xQueue ); -UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ); -void MPU_vQueueDelete( QueueHandle_t xQueue ); -QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ); -QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ); -QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ); -QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ); -TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ); -BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ); -BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t pxMutex ); -void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ); -void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ); -const char * MPU_pcQueueGetName( QueueHandle_t xQueue ); -QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ); -QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ); -QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ); -BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ); -BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ); -QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ); -BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ); -void MPU_vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ); -UBaseType_t MPU_uxQueueGetQueueNumber( QueueHandle_t xQueue ); -uint8_t MPU_ucQueueGetQueueType( QueueHandle_t xQueue ); +BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueDelete( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +const char * MPU_pcQueueGetName( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL; +QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueGetQueueNumber( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +uint8_t MPU_ucQueueGetQueueType( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; /* MPU versions of timers.h API functions. */ -TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ); -TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxTimerBuffer ); -void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ); -void MPU_vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ); -BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ); -TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ); -BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ); -const char * MPU_pcTimerGetName( TimerHandle_t xTimer ); -TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ); -TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ); -BaseType_t MPU_xTimerCreateTimerTask( void ); -BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ); +TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) FREERTOS_SYSTEM_CALL; +TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxTimerBuffer ) FREERTOS_SYSTEM_CALL; +void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +void MPU_vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +void MPU_vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerCreateTimerTask( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; /* MPU versions of event_group.h API functions. */ -EventGroupHandle_t MPU_xEventGroupCreate( void ); -EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer ); -EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ); -EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ); -EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ); -EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ); -void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ); -UBaseType_t MPU_uxEventGroupGetNumber( void* xEventGroup ); +EventGroupHandle_t MPU_xEventGroupCreate( void ) FREERTOS_SYSTEM_CALL; +EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxEventGroupGetNumber( void* xEventGroup ) FREERTOS_SYSTEM_CALL; /* MPU versions of message/stream_buffer.h API functions. */ -size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait ); -size_t MPU_xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, BaseType_t * const pxHigherPriorityTaskWoken ); -size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait ); -size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ); -size_t MPU_xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, BaseType_t * const pxHigherPriorityTaskWoken ); -void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ); -BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ); -BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ); -BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ); -size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ); -size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ); -BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ); -StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer ); -StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer, uint8_t * const pucStreamBufferStorageArea, StaticStreamBuffer_t * const pxStaticStreamBuffer ); +size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ) FREERTOS_SYSTEM_CALL; +StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer ) FREERTOS_SYSTEM_CALL; +StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer, uint8_t * const pucStreamBufferStorageArea, StaticStreamBuffer_t * const pxStaticStreamBuffer ) FREERTOS_SYSTEM_CALL; diff --git a/FreeRTOS/Source/include/mpu_wrappers.h b/FreeRTOS/Source/include/mpu_wrappers.h index 37f6f4e..711393f 100755 --- a/FreeRTOS/Source/include/mpu_wrappers.h +++ b/FreeRTOS/Source/include/mpu_wrappers.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -70,7 +70,6 @@ only for ports that are using the MPU. */ #define uxTaskGetStackHighWaterMark2 MPU_uxTaskGetStackHighWaterMark2 #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag - #define xTaskGetApplicationTaskTagFromISR MPU_xTaskGetApplicationTaskTagFromISR #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook @@ -78,6 +77,7 @@ only for ports that are using the MPU. */ #define uxTaskGetSystemState MPU_uxTaskGetSystemState #define vTaskList MPU_vTaskList #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats + #define xTaskGetIdleRunTimeCounter MPU_xTaskGetIdleRunTimeCounter #define xTaskGenericNotify MPU_xTaskGenericNotify #define xTaskNotifyWait MPU_xTaskNotifyWait #define ulTaskNotifyTake MPU_ulTaskNotifyTake @@ -126,6 +126,7 @@ only for ports that are using the MPU. */ #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall #define pcTimerGetName MPU_pcTimerGetName + #define vTimerSetReloadMode MPU_vTimerSetReloadMode #define xTimerGetPeriod MPU_xTimerGetPeriod #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime #define xTimerGenericCommand MPU_xTimerGenericCommand @@ -142,10 +143,8 @@ only for ports that are using the MPU. */ /* Map standard message/stream_buffer.h API functions to the MPU equivalents. */ #define xStreamBufferSend MPU_xStreamBufferSend - #define xStreamBufferSendFromISR MPU_xStreamBufferSendFromISR #define xStreamBufferReceive MPU_xStreamBufferReceive #define xStreamBufferNextMessageLengthBytes MPU_xStreamBufferNextMessageLengthBytes - #define xStreamBufferReceiveFromISR MPU_xStreamBufferReceiveFromISR #define vStreamBufferDelete MPU_vStreamBufferDelete #define xStreamBufferIsFull MPU_xStreamBufferIsFull #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty @@ -162,12 +161,14 @@ only for ports that are using the MPU. */ (useful when using statically allocated objects). */ #define PRIVILEGED_FUNCTION #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) + #define FREERTOS_SYSTEM_CALL #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ /* Ensure API functions go in the privileged execution section. */ #define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions"))) #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) + #define FREERTOS_SYSTEM_CALL __attribute__((section( "freertos_system_calls"))) #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ @@ -175,6 +176,7 @@ only for ports that are using the MPU. */ #define PRIVILEGED_FUNCTION #define PRIVILEGED_DATA + #define FREERTOS_SYSTEM_CALL #define portUSING_MPU_WRAPPERS 0 #endif /* portUSING_MPU_WRAPPERS */ diff --git a/FreeRTOS/Source/include/portable.h b/FreeRTOS/Source/include/portable.h index 15f0e65..59e8169 100755 --- a/FreeRTOS/Source/include/portable.h +++ b/FreeRTOS/Source/include/portable.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -84,6 +84,14 @@ must be set in the compiler's include path. */ #define portNUM_CONFIGURABLE_REGIONS 1 #endif +#ifndef portHAS_STACK_OVERFLOW_CHECKING + #define portHAS_STACK_OVERFLOW_CHECKING 0 +#endif + +#ifndef portARCH_NAME + #define portARCH_NAME NULL +#endif + #ifdef __cplusplus extern "C" { #endif @@ -97,9 +105,17 @@ extern "C" { * */ #if( portUSING_MPU_WRAPPERS == 1 ) - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; + #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; + #else + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; + #endif #else - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; + #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; + #else + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; + #endif #endif /* Used by heap_5.c. */ diff --git a/FreeRTOS/Source/include/projdefs.h b/FreeRTOS/Source/include/projdefs.h index c862173..e045861 100755 --- a/FreeRTOS/Source/include/projdefs.h +++ b/FreeRTOS/Source/include/projdefs.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/include/queue.h b/FreeRTOS/Source/include/queue.h index 1967cca..3b9da93 100755 --- a/FreeRTOS/Source/include/queue.h +++ b/FreeRTOS/Source/include/queue.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/include/semphr.h b/FreeRTOS/Source/include/semphr.h index 53b158a..2c106ea 100755 --- a/FreeRTOS/Source/include/semphr.h +++ b/FreeRTOS/Source/include/semphr.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/include/stack_macros.h b/FreeRTOS/Source/include/stack_macros.h index 673ef6d..18406bb 100755 --- a/FreeRTOS/Source/include/stack_macros.h +++ b/FreeRTOS/Source/include/stack_macros.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/include/stdint.readme b/FreeRTOS/Source/include/stdint.readme deleted file mode 100755 index 4414c29..0000000 --- a/FreeRTOS/Source/include/stdint.readme +++ /dev/null @@ -1,27 +0,0 @@ - -#ifndef FREERTOS_STDINT -#define FREERTOS_STDINT - -/******************************************************************************* - * THIS IS NOT A FULL stdint.h IMPLEMENTATION - It only contains the definitions - * necessary to build the FreeRTOS code. It is provided to allow FreeRTOS to be - * built using compilers that do not provide their own stdint.h definition. - * - * To use this file: - * - * 1) Copy this file into the directory that contains your FreeRTOSConfig.h - * header file, as that directory will already be in the compilers include - * path. - * - * 2) Rename the copied file stdint.h. - * - */ - -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef short int16_t; -typedef unsigned short uint16_t; -typedef long int32_t; -typedef unsigned long uint32_t; - -#endif /* FREERTOS_STDINT */ diff --git a/FreeRTOS/Source/include/stream_buffer.h b/FreeRTOS/Source/include/stream_buffer.h index 6619fe0..0f00119 100755 --- a/FreeRTOS/Source/include/stream_buffer.h +++ b/FreeRTOS/Source/include/stream_buffer.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/include/task.h b/FreeRTOS/Source/include/task.h index 22fad55..4174cbb 100755 --- a/FreeRTOS/Source/include/task.h +++ b/FreeRTOS/Source/include/task.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -43,11 +43,19 @@ extern "C" { * MACROS AND DEFINITIONS *----------------------------------------------------------*/ -#define tskKERNEL_VERSION_NUMBER "V10.1.1" +#define tskKERNEL_VERSION_NUMBER "V10.2.1" #define tskKERNEL_VERSION_MAJOR 10 -#define tskKERNEL_VERSION_MINOR 1 +#define tskKERNEL_VERSION_MINOR 2 #define tskKERNEL_VERSION_BUILD 1 +/* MPU region parameters passed in ulParameters + * of MemoryRegion_t struct. */ +#define tskMPU_REGION_READ_ONLY ( 1UL << 0UL ) +#define tskMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define tskMPU_REGION_EXECUTE_NEVER ( 1UL << 2UL ) +#define tskMPU_REGION_NORMAL_MEMORY ( 1UL << 3UL ) +#define tskMPU_REGION_DEVICE_MEMORY ( 1UL << 4UL ) + /** * task. h * @@ -114,7 +122,7 @@ typedef struct xTASK_PARAMETERS { TaskFunction_t pvTaskCode; const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - uint16_t usStackDepth; + configSTACK_DEPTH_TYPE usStackDepth; void *pvParameters; UBaseType_t uxPriority; StackType_t *puxStackBuffer; @@ -376,9 +384,9 @@ is used in assert() statements. */ * memory to be allocated dynamically. * * @return If neither pxStackBuffer or pxTaskBuffer are NULL, then the task will - * be created and pdPASS is returned. If either pxStackBuffer or pxTaskBuffer - * are NULL then the task will not be created and - * errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY is returned. + * be created and a handle to the created task is returned. If either + * pxStackBuffer or pxTaskBuffer are NULL then the task will not be created and + * NULL is returned. * * Example usage:
@@ -1342,20 +1350,6 @@ BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION;
  */
 TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;
 
-/**
- * task. h
- * 
TickType_t xTaskGetIdleTickCount( void );
- * - * Idle ticks are defined as ticks in which no other task than the idle task was - * executed. - * - * @return The count of idle ticks since vTaskStartScheduler was called. - * - * \defgroup xTaskGetIdleTickCount xTaskGetIdleTickCount - * \ingroup TaskUtils - */ -TickType_t xTaskGetIdleTickCount( void ) PRIVILEGED_FUNCTION; - /** * task. h *
TickType_t xTaskGetTickCountFromISR( void );
@@ -1742,6 +1736,36 @@ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unquali */ void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +/** +* task. h +*
TickType_t xTaskGetIdleRunTimeCounter( void );
+* +* configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS +* must both be defined as 1 for this function to be available. The application +* must also then provide definitions for +* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE() +* to configure a peripheral timer/counter and return the timers current count +* value respectively. The counter should be at least 10 times the frequency of +* the tick count. +* +* Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total +* accumulated execution time being stored for each task. The resolution +* of the accumulated time value depends on the frequency of the timer +* configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro. +* While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total +* execution time of each task into a buffer, xTaskGetIdleRunTimeCounter() +* returns the total execution time of just the idle task. +* +* @return The total run time of the idle task. This is the amount of time the +* idle task has actually been executing. The unit of time is dependent on the +* frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and +* portGET_RUN_TIME_COUNTER_VALUE() macros. +* +* \defgroup xTaskGetIdleRunTimeCounter xTaskGetIdleRunTimeCounter +* \ingroup TaskUtils +*/ +TickType_t xTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; + /** * task. h *
BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );
@@ -2280,7 +2304,7 @@ void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const Tick * Sets the pointer to the current TCB to the TCB of the highest priority task * that is ready to run. */ -void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION; +portDONT_DISCARD void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION; /* * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY @@ -2360,7 +2384,7 @@ void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVIL void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION; /* - * Only avilable when configUSE_TICKLESS_IDLE is set to 1. + * Only available when configUSE_TICKLESS_IDLE is set to 1. * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port * specific sleep function to determine if it is ok to proceed with the sleep, * and if it is ok to proceed, if it is ok to sleep indefinitely. diff --git a/FreeRTOS/Source/include/timers.h b/FreeRTOS/Source/include/timers.h index ae8bc71..cb72179 100755 --- a/FreeRTOS/Source/include/timers.h +++ b/FreeRTOS/Source/include/timers.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -1231,6 +1231,23 @@ BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvPar */ const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +/** + * void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ); + * + * Updates a timer to be either an autoreload timer, in which case the timer + * automatically resets itself each time it expires, or a one shot timer, in + * which case the timer will only expire once unless it is manually restarted. + * + * @param xTimer The handle of the timer being updated. + * + * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will + * expire repeatedly with a frequency set by the timer's period (see the + * xTimerPeriodInTicks parameter of the xTimerCreate() API function). If + * uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and + * enter the dormant state after it expires. + */ +void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION; + /** * TickType_t xTimerGetPeriod( TimerHandle_t xTimer ); * diff --git a/FreeRTOS/Source/list.c b/FreeRTOS/Source/list.c index 83e1a3f..21dabde 100755 --- a/FreeRTOS/Source/list.c +++ b/FreeRTOS/Source/list.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/ARMv8M/ReadMe.txt b/FreeRTOS/Source/portable/ARMv8M/ReadMe.txt new file mode 100755 index 0000000..9b12e54 --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/ReadMe.txt @@ -0,0 +1,10 @@ +This directory tree contains the master copy of the FreeeRTOS Cortex-M33 port. +Do not use the files located here! These file are copied into separate +FreeRTOS/Source/portable/[compiler]/ARM_CM33_NNN directories prior to each +FreeRTOS release. + +If your Cortex-M33 application uses TrustZone then use the files from the +FreeRTOS/Source/portable/[compiler]/ARM_CM33 directories. + +If your Cortex-M33 application does not use TrustZone then use the files from +the FreeRTOS/Source/portable/[compiler]/ARM_CM33_NTZ directories. diff --git a/FreeRTOS/Source/portable/ARMv8M/copy_files.py b/FreeRTOS/Source/portable/ARMv8M/copy_files.py new file mode 100755 index 0000000..88fce0b --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/copy_files.py @@ -0,0 +1,103 @@ +#/* +# * FreeRTOS Kernel V10.2.1 +# * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# * +# * Permission is hereby granted, free of charge, to any person obtaining a copy of +# * this software and associated documentation files (the "Software"), to deal in +# * the Software without restriction, including without limitation the rights to +# * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +# * the Software, and to permit persons to whom the Software is furnished to do so, +# * subject to the following conditions: +# * +# * The above copyright notice and this permission notice shall be included in all +# * copies or substantial portions of the Software. +# * +# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +# * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# * +# * http://www.FreeRTOS.org +# * http://aws.amazon.com/freertos +# * +# * 1 tab == 4 spaces! +# */ + +import os +import shutil + +_THIS_FILE_DIRECTORY_ = os.path.dirname(os.path.realpath(__file__)) +_FREERTOS_PORTABLE_DIRECTORY_ = os.path.dirname(_THIS_FILE_DIRECTORY_) + +_COMPILERS_ = ['GCC', 'IAR'] +_ARCH_NS_ = ['ARM_CM33', 'ARM_CM33_NTZ', 'ARM_CM23', 'ARM_CM23_NTZ'] +_ARCH_S_ = ['ARM_CM33', 'ARM_CM23'] + +_SUPPORTED_CONFIGS_ = { + 'GCC' : ['ARM_CM33', 'ARM_CM33_NTZ', 'ARM_CM23', 'ARM_CM23_NTZ'], + 'IAR' : ['ARM_CM33', 'ARM_CM33_NTZ', 'ARM_CM23', 'ARM_CM23_NTZ'] + } + +# Files to be complied in the Secure Project +_SECURE_FILE_PATHS_ = [ + os.path.join('secure', 'context'), + os.path.join('secure', 'context', 'portable', '_COMPILER_ARCH_'), + os.path.join('secure', 'heap'), + os.path.join('secure', 'init'), + os.path.join('secure', 'macros') +] + +# Files to be complied in the Non-Secure Project +_NONSECURE_FILE_PATHS_ = [ + 'non_secure', + os.path.join('non_secure', 'portable', '_COMPILER_ARCH_') +] + + +def is_supported_config(compiler, arch): + return arch in _SUPPORTED_CONFIGS_[compiler] + + +def copy_files_in_dir(src_abs_path, dst_abs_path): + for src_file in os.listdir(src_abs_path): + src_file_abs_path = os.path.join(src_abs_path, src_file) + if os.path.isfile(src_file_abs_path) and src_file != 'ReadMe.txt': + if not os.path.exists(dst_abs_path): + os.makedirs(dst_abs_path) + print('Copying {}...'.format(os.path.basename(src_file_abs_path))) + shutil.copy2(src_file_abs_path, dst_abs_path) + + +def copy_files_for_compiler_and_arch(compiler, arch, src_paths, dst_path): + _COMPILER_ARCH_ = os.path.join(compiler, arch) + for src_path in src_paths: + src_path_sanitized = src_path.replace('_COMPILER_ARCH_', _COMPILER_ARCH_ ) + + src_abs_path = os.path.join(_THIS_FILE_DIRECTORY_, src_path_sanitized) + dst_abs_path = os.path.join(_FREERTOS_PORTABLE_DIRECTORY_, _COMPILER_ARCH_, dst_path) + + copy_files_in_dir(src_abs_path, dst_abs_path) + + +def copy_files(): + # Copy Secure Files + for compiler in _COMPILERS_: + for arch in _ARCH_S_: + if is_supported_config(compiler, arch): + copy_files_for_compiler_and_arch(compiler, arch, _SECURE_FILE_PATHS_, 'secure') + + # Copy Non-Secure Files + for compiler in _COMPILERS_: + for arch in _ARCH_NS_: + if is_supported_config(compiler, arch): + copy_files_for_compiler_and_arch(compiler, arch, _NONSECURE_FILE_PATHS_, 'non_secure') + + +def main(): + copy_files() + + +if __name__ == '__main__': + main() diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/ReadMe.txt b/FreeRTOS/Source/portable/ARMv8M/non_secure/ReadMe.txt new file mode 100755 index 0000000..c74a534 --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/ReadMe.txt @@ -0,0 +1,11 @@ +This directory tree contains the master copy of the FreeeRTOS Cortex-M33 port. +Do not use the files located here! These file are copied into separate +FreeRTOS/Source/portable/[compiler]/ARM_CM33_NNN directories prior to each +FreeRTOS release. + +If your Cortex-M33 application uses TrustZone then use the files from the +FreeRTOS/Source/portable/[compiler]/ARM_CM33 directories. + +If your Cortex-M33 application does not use TrustZone then use the files from +the FreeRTOS/Source/portable/[compiler]/ARM_CM33_NTZ directories. + diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/port.c b/FreeRTOS/Source/portable/ARMv8M/non_secure/port.c new file mode 100755 index 0000000..bd85a6f --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/port.c @@ -0,0 +1,899 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/* Portasm includes. */ +#include "portasm.h" + +#if( configENABLE_TRUSTZONE == 1 ) + /* Secure components includes. */ + #include "secure_context.h" + #include "secure_init.h" +#endif /* configENABLE_TRUSTZONE */ + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/** + * The FreeRTOS Cortex M33 port can be configured to run on the Secure Side only + * i.e. the processor boots as secure and never jumps to the non-secure side. + * The Trust Zone support in the port must be disabled in order to run FreeRTOS + * on the secure side. The following are the valid configuration seetings: + * + * 1. Run FreeRTOS on the Secure Side: + * configRUN_FREERTOS_SECURE_ONLY = 1 and configENABLE_TRUSTZONE = 0 + * + * 2. Run FreeRTOS on the Non-Secure Side with Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 1 + * + * 3. Run FreeRTOS on the Non-Secure Side only i.e. no Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 0 + */ +#if( ( configRUN_FREERTOS_SECURE_ONLY == 1 ) && ( configENABLE_TRUSTZONE == 1 ) ) + #error TrustZone needs to be disabled in order to run FreeRTOS on the Secure Side. +#endif +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the NVIC. + */ +#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t * ) 0xe000e010 ) +#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t * ) 0xe000e014 ) +#define portNVIC_SYSTICK_CURRENT_VALUE ( ( volatile uint32_t * ) 0xe000e018 ) +#define portNVIC_INT_CTRL ( ( volatile uint32_t * ) 0xe000ed04 ) +#define portNVIC_SYSPRI2 ( ( volatile uint32_t * ) 0xe000ed20 ) +#define portNVIC_SYSTICK_CLK ( 0x00000004 ) +#define portNVIC_SYSTICK_INT ( 0x00000002 ) +#define portNVIC_SYSTICK_ENABLE ( 0x00000001 ) +#define portNVIC_PENDSVSET ( 0x10000000 ) +#define portMIN_INTERRUPT_PRIORITY ( 255UL ) +#define portNVIC_PENDSV_PRI ( portMIN_INTERRUPT_PRIORITY << 16UL ) +#define portNVIC_SYSTICK_PRI ( portMIN_INTERRUPT_PRIORITY << 24UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the SCB. + */ +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( * ( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_MEM_FAULT_ENABLE ( 1UL << 16UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the FPU. + */ +#define portCPACR ( ( volatile uint32_t * ) 0xe000ed88 ) /* Coprocessor Access Control Register. */ +#define portCPACR_CP10_VALUE ( 3UL ) +#define portCPACR_CP11_VALUE portCPACR_CP10_VALUE +#define portCPACR_CP10_POS ( 20UL ) +#define portCPACR_CP11_POS ( 22UL ) + +#define portFPCCR ( ( volatile uint32_t * ) 0xe000ef34 ) /* Floating Point Context Control Register. */ +#define portFPCCR_ASPEN_POS ( 31UL ) +#define portFPCCR_ASPEN_MASK ( 1UL << portFPCCR_ASPEN_POS ) +#define portFPCCR_LSPEN_POS ( 30UL ) +#define portFPCCR_LSPEN_MASK ( 1UL << portFPCCR_LSPEN_POS ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the MPU. + */ +#define portMPU_TYPE_REG ( * ( ( volatile uint32_t * ) 0xe000ed90 ) ) +#define portMPU_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed94 ) ) +#define portMPU_RNR_REG ( * ( ( volatile uint32_t * ) 0xe000ed98 ) ) + +#define portMPU_RBAR_REG ( * ( ( volatile uint32_t * ) 0xe000ed9c ) ) +#define portMPU_RLAR_REG ( * ( ( volatile uint32_t * ) 0xe000eda0 ) ) + +#define portMPU_RBAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda4 ) ) +#define portMPU_RLAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda8 ) ) + +#define portMPU_RBAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edac ) ) +#define portMPU_RLAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edb0 ) ) + +#define portMPU_RBAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb4 ) ) +#define portMPU_RLAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb8 ) ) + +#define portMPU_MAIR0_REG ( * ( ( volatile uint32_t * ) 0xe000edc0 ) ) +#define portMPU_MAIR1_REG ( * ( ( volatile uint32_t * ) 0xe000edc4 ) ) + +#define portMPU_RBAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ +#define portMPU_RLAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ + +#define portMPU_MAIR_ATTR0_POS ( 0UL ) +#define portMPU_MAIR_ATTR0_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR1_POS ( 8UL ) +#define portMPU_MAIR_ATTR1_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR2_POS ( 16UL ) +#define portMPU_MAIR_ATTR2_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR3_POS ( 24UL ) +#define portMPU_MAIR_ATTR3_MASK ( 0xff000000 ) + +#define portMPU_MAIR_ATTR4_POS ( 0UL ) +#define portMPU_MAIR_ATTR4_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR5_POS ( 8UL ) +#define portMPU_MAIR_ATTR5_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR6_POS ( 16UL ) +#define portMPU_MAIR_ATTR6_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR7_POS ( 24UL ) +#define portMPU_MAIR_ATTR7_MASK ( 0xff000000 ) + +#define portMPU_RLAR_ATTR_INDEX0 ( 0UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX1 ( 1UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX2 ( 2UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX3 ( 3UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX4 ( 4UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX5 ( 5UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX6 ( 6UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX7 ( 7UL << 1UL ) + +#define portMPU_RLAR_REGION_ENABLE ( 1UL ) + +/* Enable privileged access to unmapped region. */ +#define portMPU_PRIV_BACKGROUND_ENABLE ( 1UL << 2UL ) + +/* Enable MPU. */ +#define portMPU_ENABLE ( 1UL << 0UL ) + +/* Expected value of the portMPU_TYPE register. */ +#define portEXPECTED_MPU_TYPE_VALUE ( 8UL << 8UL ) /* 8 regions, unified. */ +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to set up the initial stack. + */ +#define portINITIAL_XPSR ( 0x01000000 ) + +#if( configRUN_FREERTOS_SECURE_ONLY == 1 ) + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF FD + * 1111 1111 1111 1111 1111 1111 1111 1101 + * + * Bit[6] - 1 --> The exception was taken from the Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 1 --> The exception was taken to the Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xfffffffd ) +#else + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF BC + * 1111 1111 1111 1111 1111 1111 1011 1100 + * + * Bit[6] - 0 --> The exception was taken from the Non-Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 0 --> The exception was taken to the Non-Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xffffffbc ) +#endif /* configRUN_FREERTOS_SECURE_ONLY */ + +/** + * @brief CONTROL register privileged bit mask. + * + * Bit[0] in CONTROL register tells the privilege: + * Bit[0] = 0 ==> The task is privileged. + * Bit[0] = 1 ==> The task is not privileged. + */ +#define portCONTROL_PRIVILEGED_MASK ( 1UL << 0UL ) + +/** + * @brief Initial CONTROL register values. + */ +#define portINITIAL_CONTROL_UNPRIVILEGED ( 0x3 ) +#define portINITIAL_CONTROL_PRIVILEGED ( 0x2 ) + +/** + * @brief Let the user override the pre-loading of the initial LR with the + * address of prvTaskExitError() in case it messes up unwinding of the stack + * in the debugger. + */ +#ifdef configTASK_RETURN_ADDRESS + #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS +#else + #define portTASK_RETURN_ADDRESS prvTaskExitError +#endif + +/** + * @brief If portPRELOAD_REGISTERS then registers will be given an initial value + * when a task is created. This helps in debugging at the cost of code size. + */ +#define portPRELOAD_REGISTERS 1 + +/** + * @brief A task is created without a secure context, and must call + * portALLOCATE_SECURE_CONTEXT() to give itself a secure context before it makes + * any secure calls. + */ +#define portNO_SECURE_CONTEXT 0 +/*-----------------------------------------------------------*/ + +/** + * @brief Setup the timer to generate the tick interrupts. + */ +static void prvSetupTimerInterrupt( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Used to catch tasks that attempt to return from their implementing + * function. + */ +static void prvTaskExitError( void ); + +#if( configENABLE_MPU == 1 ) + /** + * @brief Setup the Memory Protection Unit (MPU). + */ + static void prvSetupMPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_MPU */ + +#if( configENABLE_FPU == 1 ) + /** + * @brief Setup the Floating Point Unit (FPU). + */ + static void prvSetupFPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_FPU */ + +/** + * @brief Yield the processor. + */ +void vPortYield( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Enter critical section. + */ +void vPortEnterCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Exit from critical section. + */ +void vPortExitCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief SysTick handler. + */ +void SysTick_Handler( void ) PRIVILEGED_FUNCTION; + +/** + * @brief C part of SVC handler. + */ +portDONT_DISCARD void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) PRIVILEGED_FUNCTION; +/*-----------------------------------------------------------*/ + +/** + * @brief Each task maintains its own interrupt status in the critical nesting + * variable. + */ +static volatile uint32_t ulCriticalNesting = 0xaaaaaaaaUL; + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Saved as part of the task context to indicate which context the + * task is using on the secure side. + */ + portDONT_DISCARD volatile SecureContextHandle_t xSecureContext = portNO_SECURE_CONTEXT; +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +static void prvSetupTimerInterrupt( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Stop and reset the SysTick. */ + *( portNVIC_SYSTICK_CTRL ) = 0UL; + *( portNVIC_SYSTICK_CURRENT_VALUE ) = 0UL; + + /* Configure SysTick to interrupt at the requested rate. */ + *( portNVIC_SYSTICK_LOAD ) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; + *( portNVIC_SYSTICK_CTRL ) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE; +} +/*-----------------------------------------------------------*/ + +static void prvTaskExitError( void ) +{ +volatile uint32_t ulDummy = 0UL; + + /* A function that implements a task must not exit or attempt to return to + * its caller as there is nothing to return to. If a task wants to exit it + * should instead call vTaskDelete( NULL ). Artificially force an assert() + * to be triggered if configASSERT() is defined, then stop here so + * application writers can catch the error. */ + configASSERT( ulCriticalNesting == ~0UL ); + portDISABLE_INTERRUPTS(); + + while( ulDummy == 0 ) + { + /* This file calls prvTaskExitError() after the scheduler has been + * started to remove a compiler warning about the function being + * defined but never called. ulDummy is used purely to quieten other + * warnings about code appearing after this function is called - making + * ulDummy volatile makes the compiler think the function could return + * and therefore not output an 'unreachable code' warning for code that + * appears after it. */ + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + static void prvSetupMPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __privileged_functions_start__; + extern uint32_t * __privileged_functions_end__; + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + extern uint32_t * __unprivileged_flash_start__; + extern uint32_t * __unprivileged_flash_end__; + extern uint32_t * __privileged_sram_start__; + extern uint32_t * __privileged_sram_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __privileged_functions_start__[]; + extern uint32_t __privileged_functions_end__[]; + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + extern uint32_t __unprivileged_flash_start__[]; + extern uint32_t __unprivileged_flash_end__[]; + extern uint32_t __privileged_sram_start__[]; + extern uint32_t __privileged_sram_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ + + /* Check that the MPU is present. */ + if( portMPU_TYPE_REG == portEXPECTED_MPU_TYPE_VALUE ) + { + /* MAIR0 - Index 0. */ + portMPU_MAIR0_REG |= ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + /* MAIR0 - Index 1. */ + portMPU_MAIR0_REG |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* Setup privileged flash as Read Only so that privileged tasks can + * read it but not modify. */ + portMPU_RNR_REG = portPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_functions_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_functions_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged flash as Read Only by both privileged and + * unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __unprivileged_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __unprivileged_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged syscalls flash as Read Only by both privileged + * and unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_SYSCALLS_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __syscalls_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __syscalls_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup RAM containing kernel data for privileged access only. */ + portMPU_RNR_REG = portPRIVILEGED_RAM_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_sram_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_sram_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Enable mem fault. */ + portSCB_SYS_HANDLER_CTRL_STATE_REG |= portSCB_MEM_FAULT_ENABLE; + + /* Enable MPU with privileged background access i.e. unmapped + * regions have privileged access. */ + portMPU_CTRL_REG |= ( portMPU_PRIV_BACKGROUND_ENABLE | portMPU_ENABLE ); + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_FPU == 1 ) + static void prvSetupFPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* Enable non-secure access to the FPU. */ + SecureInit_EnableNSFPUAccess(); + } + #endif /* configENABLE_TRUSTZONE */ + + /* CP10 = 11 ==> Full access to FPU i.e. both privileged and + * unprivileged code should be able to access FPU. CP11 should be + * programmed to the same value as CP10. */ + *( portCPACR ) |= ( ( portCPACR_CP10_VALUE << portCPACR_CP10_POS ) | + ( portCPACR_CP11_VALUE << portCPACR_CP11_POS ) + ); + + /* ASPEN = 1 ==> Hardware should automatically preserve floating point + * context on exception entry and restore on exception return. + * LSPEN = 1 ==> Enable lazy context save of FP state. */ + *( portFPCCR ) |= ( portFPCCR_ASPEN_MASK | portFPCCR_LSPEN_MASK ); + } +#endif /* configENABLE_FPU */ +/*-----------------------------------------------------------*/ + +void vPortYield( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Set a PendSV to request a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + portDISABLE_INTERRUPTS(); + ulCriticalNesting++; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + configASSERT( ulCriticalNesting ); + ulCriticalNesting--; + + if( ulCriticalNesting == 0 ) + { + portENABLE_INTERRUPTS(); + } +} +/*-----------------------------------------------------------*/ + +void SysTick_Handler( void ) /* PRIVILEGED_FUNCTION */ +{ +uint32_t ulPreviousMask; + + ulPreviousMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* Increment the RTOS tick. */ + if( xTaskIncrementTick() != pdFALSE ) + { + /* Pend a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulPreviousMask ); +} +/*-----------------------------------------------------------*/ + +void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) /* PRIVILEGED_FUNCTION portDONT_DISCARD */ +{ +#if( configENABLE_MPU == 1 ) + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ +#endif /* configENABLE_MPU */ + +uint32_t ulPC; + +#if( configENABLE_TRUSTZONE == 1 ) + uint32_t ulR0; + #if( configENABLE_MPU == 1 ) + uint32_t ulControl, ulIsTaskPrivileged; + #endif /* configENABLE_MPU */ +#endif /* configENABLE_TRUSTZONE */ +uint8_t ucSVCNumber; + + /* Register are stored on the stack in the following order - R0, R1, R2, R3, + * R12, LR, PC, xPSR. */ + ulPC = pulCallerStackAddress[ 6 ]; + ucSVCNumber = ( ( uint8_t *) ulPC )[ -2 ]; + + switch( ucSVCNumber ) + { + #if( configENABLE_TRUSTZONE == 1 ) + case portSVC_ALLOCATE_SECURE_CONTEXT: + { + /* R0 contains the stack size passed as parameter to the + * vPortAllocateSecureContext function. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + #if( configENABLE_MPU == 1 ) + { + /* Read the CONTROL register value. */ + __asm volatile ( "mrs %0, control" : "=r" ( ulControl ) ); + + /* The task that raised the SVC is privileged if Bit[0] + * in the CONTROL register is 0. */ + ulIsTaskPrivileged = ( ( ulControl & portCONTROL_PRIVILEGED_MASK ) == 0 ); + + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0, ulIsTaskPrivileged ); + } + #else + { + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0 ); + } + #endif /* configENABLE_MPU */ + + configASSERT( xSecureContext != NULL ); + SecureContext_LoadContext( xSecureContext ); + } + break; + + case portSVC_FREE_SECURE_CONTEXT: + { + /* R0 contains the secure context handle to be freed. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + /* Free the secure context. */ + SecureContext_FreeContext( ( SecureContextHandle_t ) ulR0 ); + } + break; + #endif /* configENABLE_TRUSTZONE */ + + case portSVC_START_SCHEDULER: + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* De-prioritize the non-secure exceptions so that the + * non-secure pendSV runs at the lowest priority. */ + SecureInit_DePrioritizeNSExceptions(); + + /* Initialize the secure context management system. */ + SecureContext_Init(); + } + #endif /* configENABLE_TRUSTZONE */ + + #if( configENABLE_FPU == 1 ) + { + /* Setup the Floating Point Unit (FPU). */ + prvSetupFPU(); + } + #endif /* configENABLE_FPU */ + + /* Setup the context of the first task so that the first task starts + * executing. */ + vRestoreContextOfFirstTask(); + } + break; + + #if( configENABLE_MPU == 1 ) + case portSVC_RAISE_PRIVILEGE: + { + /* Only raise the privilege, if the svc was raised from any of + * the system calls. */ + if( ulPC >= ( uint32_t ) __syscalls_flash_start__ && + ulPC <= ( uint32_t ) __syscalls_flash_end__ ) + { + vRaisePrivilege(); + } + } + break; + #endif /* configENABLE_MPU */ + + default: + { + /* Incorrect SVC call. */ + configASSERT( pdFALSE ); + } + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) /* PRIVILEGED_FUNCTION */ +#else + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) /* PRIVILEGED_FUNCTION */ +#endif /* configENABLE_MPU */ +{ + /* Simulate the stack frame as it would be created by a context switch + * interrupt. */ + #if( portPRELOAD_REGISTERS == 0 ) + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack -= 9; /* R11..R4, EXC_RETURN. */ + *pxTopOfStack = portINITIAL_EXC_RETURN; + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #else /* portPRELOAD_REGISTERS */ + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x12121212UL; /* R12 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x03030303UL; /* R3 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x02020202UL; /* R2 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x01010101UL; /* R1 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x11111111UL; /* R11 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x10101010UL; /* R10 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x09090909UL; /* R09 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x08080808UL; /* R08 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x07070707UL; /* R07 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x06060606UL; /* R06 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x05050505UL; /* R05 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x04040404UL; /* R04 */ + pxTopOfStack--; + *pxTopOfStack = portINITIAL_EXC_RETURN; /* EXC_RETURN */ + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #endif /* portPRELOAD_REGISTERS */ + + return pxTopOfStack; +} +/*-----------------------------------------------------------*/ + +BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + *( portNVIC_SYSPRI2 ) |= portNVIC_PENDSV_PRI; + *( portNVIC_SYSPRI2 ) |= portNVIC_SYSTICK_PRI; + + #if( configENABLE_MPU == 1 ) + { + /* Setup the Memory Protection Unit (MPU). */ + prvSetupMPU(); + } + #endif /* configENABLE_MPU */ + + /* Start the timer that generates the tick ISR. Interrupts are disabled + * here already. */ + prvSetupTimerInterrupt(); + + /* Initialize the critical nesting count ready for the first task. */ + ulCriticalNesting = 0; + + /* Start the first task. */ + vStartFirstTask(); + + /* Should never get here as the tasks will now be executing. Call the task + * exit error function to prevent compiler warnings about a static function + * not being called in the case that the application writer overrides this + * functionality by defining configTASK_RETURN_ADDRESS. Call + * vTaskSwitchContext() so link time optimization does not remove the + * symbol. */ + vTaskSwitchContext(); + prvTaskExitError(); + + /* Should not get here. */ + return 0; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Not implemented in ports where there is nothing to return to. + * Artificially force an assert. */ + configASSERT( ulCriticalNesting == 1000UL ); +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) + { + uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber; + int32_t lIndex = 0; + + /* Setup MAIR0. */ + xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + xMPUSettings->ulMAIR0 |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* This function is called automatically when the task is created - in + * which case the stack region parameters will be valid. At all other + * times the stack parameters will not be valid and it is assumed that + * the stack region has already been configured. */ + if( ulStackDepth > 0 ) + { + /* Define the region that allows access to the stack. */ + ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + + xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + } + + /* User supplied configurable regions. */ + for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ ) + { + /* If xRegions is NULL i.e. the task has not specified any MPU + * region, the else part ensures that all the configurable MPU + * regions are invalidated. */ + if( ( xRegions != NULL ) && ( xRegions[ lIndex ].ulLengthInBytes > 0UL ) ) + { + /* Translate the generic region definition contained in xRegions + * into the ARMv8 specific MPU settings that are then stored in + * xMPUSettings. */ + ulRegionStartAddress = ( ( uint32_t ) xRegions[ lIndex ].pvBaseAddress ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) xRegions[ lIndex ].pvBaseAddress + xRegions[ lIndex ].ulLengthInBytes - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + /* Start address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ); + + /* RO/RW. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_READ_ONLY ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_ONLY ); + } + else + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_WRITE ); + } + + /* XN. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_EXECUTE_NEVER ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_EXECUTE_NEVER ); + } + + /* End Address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Normal memory/ Device memory. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_DEVICE_MEMORY ) != 0 ) + { + /* Attr1 in MAIR0 is configured as device memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX1; + } + else + { + /* Attr1 in MAIR0 is configured as normal memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX0; + } + } + else + { + /* Invalidate the region. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = 0UL; + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = 0UL; + } + + lIndex++; + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM23/portasm.c b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM23/portasm.c new file mode 100755 index 0000000..c8345c7 --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM23/portasm.c @@ -0,0 +1,468 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE ensures that PRIVILEGED_FUNCTION + * is defined correctly and privileged functions are placed in correct sections. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Portasm includes. */ +#include "portasm.h" + +/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE is needed to be defined only for the + * header files. */ +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#if( configENABLE_FPU == 1 ) + #error Cortex-M23 does not have a Floating Point Unit (FPU) and therefore configENABLE_FPU must be set to 0. +#endif + +void vRestoreContextOfFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " \n" + " ldr r2, pxCurrentTCBConst2 \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r3, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r0, [r3] \n" /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r5, #1 \n" /* r5 = 1. */ + " bics r4, r5 \n" /* r4 = r4 & ~r5 i.e. Clear the bit 0 in r4. */ + " str r4, [r2] \n" /* Disable MPU. */ + " \n" + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + " ldr r4, [r3] \n" /* r4 = *r3 i.e. r4 = MAIR0. */ + " ldr r2, xMAIR0Const2 \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r4, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst2 \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + " movs r5, #4 \n" /* r5 = 4. */ + " str r5, [r2] \n" /* Program RNR = 4. */ + " ldmia r3!, {r6,r7} \n" /* Read first set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst2 \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write first set of RBAR/RLAR registers. */ + " movs r5, #5 \n" /* r5 = 5. */ + " str r5, [r2] \n" /* Program RNR = 5. */ + " ldmia r3!, {r6,r7} \n" /* Read second set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst2 \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write second set of RBAR/RLAR registers. */ + " movs r5, #6 \n" /* r5 = 6. */ + " str r5, [r2] \n" /* Program RNR = 6. */ + " ldmia r3!, {r6,r7} \n" /* Read third set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst2 \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write third set of RBAR/RLAR registers. */ + " movs r5, #7 \n" /* r5 = 7. */ + " str r5, [r2] \n" /* Program RNR = 7. */ + " ldmia r3!, {r6,r7} \n" /* Read fourth set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst2 \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write fourth set of RBAR/RLAR registers. */ + " \n" + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r5, #1 \n" /* r5 = 1. */ + " orrs r4, r5 \n" /* r4 = r4 | r5 i.e. Set the bit 0 in r4. */ + " str r4, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " ldm r0!, {r1-r4} \n" /* Read from stack - r1 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = EXC_RETURN. */ + " ldr r5, xSecureContextConst2 \n" + " str r1, [r5] \n" /* Set xSecureContext to this task's value for the same. */ + " msr psplim, r2 \n" /* Set this task's PSPLIM value. */ + " msr control, r3 \n" /* Set this task's CONTROL value. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r4 \n" /* Finally, branch to EXC_RETURN. */ + #else /* configENABLE_MPU */ + " ldm r0!, {r1-r3} \n" /* Read from stack - r1 = xSecureContext, r2 = PSPLIM and r3 = EXC_RETURN. */ + " ldr r4, xSecureContextConst2 \n" + " str r1, [r4] \n" /* Set xSecureContext to this task's value for the same. */ + " msr psplim, r2 \n" /* Set this task's PSPLIM value. */ + " movs r1, #2 \n" /* r1 = 2. */ + " msr CONTROL, r1 \n" /* Switch to use PSP in the thread mode. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r3 \n" /* Finally, branch to EXC_RETURN. */ + #endif /* configENABLE_MPU */ + " \n" + " .align 4 \n" + "pxCurrentTCBConst2: .word pxCurrentTCB \n" + "xSecureContextConst2: .word xSecureContext \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst2: .word 0xe000ed94 \n" + "xMAIR0Const2: .word 0xe000edc0 \n" + "xRNRConst2: .word 0xe000ed98 \n" + "xRBARConst2: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " movs r1, #1 \n" /* r1 = 1. */ + " tst r0, r1 \n" /* Perform r0 & r1 (bitwise AND) and update the conditions flag. */ + " beq running_privileged \n" /* If the result of previous AND operation was 0, branch. */ + " movs r0, #0 \n" /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + " bx lr \n" /* Return. */ + " running_privileged: \n" + " movs r0, #1 \n" /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + " bx lr \n" /* Return. */ + " \n" + " .align 4 \n" + ::: "r0", "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vRaisePrivilege( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, control \n" /* Read the CONTROL register. */ + " movs r1, #1 \n" /* r1 = 1. */ + " bics r0, r1 \n" /* Clear the bit 0. */ + " msr control, r0 \n" /* Write back the new CONTROL value. */ + " bx lr \n" /* Return to the caller. */ + ::: "r0", "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vResetPrivilege( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " movs r1, #1 \n" /* r1 = 1. */ + " orrs r0, r1 \n" /* r0 = r0 | r1. */ + " msr control, r0 \n" /* CONTROL = r0. */ + " bx lr \n" /* Return to the caller. */ + :::"r0", "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vStartFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " ldr r0, xVTORConst \n" /* Use the NVIC offset register to locate the stack. */ + " ldr r0, [r0] \n" /* Read the VTOR register which gives the address of vector table. */ + " ldr r0, [r0] \n" /* The first entry in vector table is stack pointer. */ + " msr msp, r0 \n" /* Set the MSP back to the start of the stack. */ + " cpsie i \n" /* Globally enable interrupts. */ + " dsb \n" + " isb \n" + " svc %0 \n" /* System call to start the first task. */ + " nop \n" + " \n" + " .align 4 \n" + "xVTORConst: .word 0xe000ed08 \n" + :: "i" ( portSVC_START_SCHEDULER ) : "memory" + ); +} +/*-----------------------------------------------------------*/ + +uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, PRIMASK \n" + " cpsid i \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* To avoid compiler warnings. The return statement will never be reached, + * but some compilers warn if it is not included, while others won't compile + * if it is. */ + return 0; +#endif +} +/*-----------------------------------------------------------*/ + +void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " msr PRIMASK, r0 \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* Just to avoid compiler warning. ulMask is used from the asm code but + * the compiler can't see that. Some compilers generate warnings without + * the following line, while others generate warnings if the line is + * included. */ + ( void ) ulMask; +#endif +} +/*-----------------------------------------------------------*/ + +void PendSV_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " .extern SecureContext_SaveContext \n" + " .extern SecureContext_LoadContext \n" + " \n" + " mrs r1, psp \n" /* Read PSP in r1. */ + " ldr r2, xSecureContextConst \n" /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + " ldr r0, [r2] \n" /* Read xSecureContext - Value of xSecureContext must be in r0 as it is used as a parameter later. */ + " \n" + " cbz r0, save_ns_context \n" /* No secure context to save. */ + " push {r0-r2, r14} \n" + " bl SecureContext_SaveContext \n" + " pop {r0-r3} \n" /* LR is now in r3. */ + " mov lr, r3 \n" /* LR = r3. */ + " lsls r2, r3, #25 \n" /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + " bpl save_ns_context \n" /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + " ldr r3, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r2, [r3] \n" /* Read pxCurrentTCB. */ + #if( configENABLE_MPU == 1 ) + " subs r1, r1, #16 \n" /* Make space for xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mrs r3, control \n" /* r3 = CONTROL. */ + " mov r4, lr \n" /* r4 = LR/EXC_RETURN. */ + " stmia r1!, {r0, r2-r4} \n" /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + #else /* configENABLE_MPU */ + " subs r1, r1, #12 \n" /* Make space for xSecureContext, PSPLIM and LR on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " stmia r1!, {r0, r2-r3} \n" /* Store xSecureContext, PSPLIM and LR on the stack. */ + #endif /* configENABLE_MPU */ + " b select_next_task \n" + " \n" + " save_ns_context: \n" + " ldr r3, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r2, [r3] \n" /* Read pxCurrentTCB. */ + #if( configENABLE_MPU == 1 ) + " subs r1, r1, #48 \n" /* Make space for xSecureContext, PSPLIM, CONTROL, LR and the remaining registers on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " adds r1, r1, #16 \n" /* r1 = r1 + 16. */ + " stmia r1!, {r4-r7} \n" /* Store the low registers that are not saved automatically. */ + " mov r4, r8 \n" /* r4 = r8. */ + " mov r5, r9 \n" /* r5 = r9. */ + " mov r6, r10 \n" /* r6 = r10. */ + " mov r7, r11 \n" /* r7 = r11. */ + " stmia r1!, {r4-r7} \n" /* Store the high registers that are not saved automatically. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mrs r3, control \n" /* r3 = CONTROL. */ + " mov r4, lr \n" /* r4 = LR/EXC_RETURN. */ + " subs r1, r1, #48 \n" /* r1 = r1 - 48. */ + " stmia r1!, {r0, r2-r4} \n" /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + #else /* configENABLE_MPU */ + " subs r1, r1, #44 \n" /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " stmia r1!, {r0, r2-r7} \n" /* Store xSecureContext, PSPLIM, LR and the low registers that are not saved automatically. */ + " mov r4, r8 \n" /* r4 = r8. */ + " mov r5, r9 \n" /* r5 = r9. */ + " mov r6, r10 \n" /* r6 = r10. */ + " mov r7, r11 \n" /* r7 = r11. */ + " stmia r1!, {r4-r7} \n" /* Store the high registers that are not saved automatically. */ + #endif /* configENABLE_MPU */ + " \n" + " select_next_task: \n" + " cpsid i \n" + " bl vTaskSwitchContext \n" + " cpsie i \n" + " \n" + " ldr r2, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r3, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r1, [r3] \n" /* The first item in pxCurrentTCB is the task top of stack. r1 now points to the top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r5, #1 \n" /* r5 = 1. */ + " bics r4, r5 \n" /* r4 = r4 & ~r5 i.e. Clear the bit 0 in r4. */ + " str r4, [r2] \n" /* Disable MPU. */ + " \n" + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + " ldr r4, [r3] \n" /* r4 = *r3 i.e. r4 = MAIR0. */ + " ldr r2, xMAIR0Const \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r4, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + " movs r5, #4 \n" /* r5 = 4. */ + " str r5, [r2] \n" /* Program RNR = 4. */ + " ldmia r3!, {r6,r7} \n" /* Read first set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write first set of RBAR/RLAR registers. */ + " movs r5, #5 \n" /* r5 = 5. */ + " str r5, [r2] \n" /* Program RNR = 5. */ + " ldmia r3!, {r6,r7} \n" /* Read second set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write second set of RBAR/RLAR registers. */ + " movs r5, #6 \n" /* r5 = 6. */ + " str r5, [r2] \n" /* Program RNR = 6. */ + " ldmia r3!, {r6,r7} \n" /* Read third set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write third set of RBAR/RLAR registers. */ + " movs r5, #7 \n" /* r5 = 7. */ + " str r5, [r2] \n" /* Program RNR = 7. */ + " ldmia r3!, {r6,r7} \n" /* Read fourth set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write fourth set of RBAR/RLAR registers. */ + " \n" + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r5, #1 \n" /* r5 = 1. */ + " orrs r4, r5 \n" /* r4 = r4 | r5 i.e. Set the bit 0 in r4. */ + " str r4, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " ldmia r1!, {r0, r2-r4} \n" /* Read from stack - r0 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = LR. */ + " msr psplim, r2 \n" /* Restore the PSPLIM register value for the task. */ + " msr control, r3 \n" /* Restore the CONTROL register value for the task. */ + " mov lr, r4 \n" /* LR = r4. */ + " ldr r2, xSecureContextConst \n" /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + " str r0, [r2] \n" /* Restore the task's xSecureContext. */ + " cbz r0, restore_ns_context \n" /* If there is no secure context for the task, restore the non-secure context. */ + " push {r1,r4} \n" + " bl SecureContext_LoadContext \n" /* Restore the secure context. */ + " pop {r1,r4} \n" + " mov lr, r4 \n" /* LR = r4. */ + " lsls r2, r4, #25 \n" /* r2 = r4 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + " bpl restore_ns_context \n" /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + " msr psp, r1 \n" /* Remember the new top of stack for the task. */ + " bx lr \n" + #else /* configENABLE_MPU */ + " ldmia r1!, {r0, r2-r3} \n" /* Read from stack - r0 = xSecureContext, r2 = PSPLIM and r3 = LR. */ + " msr psplim, r2 \n" /* Restore the PSPLIM register value for the task. */ + " mov lr, r3 \n" /* LR = r3. */ + " ldr r2, xSecureContextConst \n" /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + " str r0, [r2] \n" /* Restore the task's xSecureContext. */ + " cbz r0, restore_ns_context \n" /* If there is no secure context for the task, restore the non-secure context. */ + " push {r1,r3} \n" + " bl SecureContext_LoadContext \n" /* Restore the secure context. */ + " pop {r1,r3} \n" + " mov lr, r3 \n" /* LR = r3. */ + " lsls r2, r3, #25 \n" /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + " bpl restore_ns_context \n" /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + " msr psp, r1 \n" /* Remember the new top of stack for the task. */ + " bx lr \n" + #endif /* configENABLE_MPU */ + " \n" + " restore_ns_context: \n" + " adds r1, r1, #16 \n" /* Move to the high registers. */ + " ldmia r1!, {r4-r7} \n" /* Restore the high registers that are not automatically restored. */ + " mov r8, r4 \n" /* r8 = r4. */ + " mov r9, r5 \n" /* r9 = r5. */ + " mov r10, r6 \n" /* r10 = r6. */ + " mov r11, r7 \n" /* r11 = r7. */ + " msr psp, r1 \n" /* Remember the new top of stack for the task. */ + " subs r1, r1, #32 \n" /* Go back to the low registers. */ + " ldmia r1!, {r4-r7} \n" /* Restore the low registers that are not automatically restored. */ + " bx lr \n" + " \n" + " .align 4 \n" + "pxCurrentTCBConst: .word pxCurrentTCB \n" + "xSecureContextConst: .word xSecureContext \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst: .word 0xe000ed94 \n" + "xMAIR0Const: .word 0xe000edc0 \n" + "xRNRConst: .word 0xe000ed98 \n" + "xRBARConst: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +void SVC_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " movs r0, #4 \n" + " mov r1, lr \n" + " tst r0, r1 \n" + " beq stacking_used_msp \n" + " mrs r0, psp \n" + " ldr r2, svchandler_address_const \n" + " bx r2 \n" + " stacking_used_msp: \n" + " mrs r0, msp \n" + " ldr r2, svchandler_address_const \n" + " bx r2 \n" + " \n" + " .align 4 \n" + "svchandler_address_const: .word vPortSVCHandler_C \n" + ); +} +/*-----------------------------------------------------------*/ + +void vPortAllocateSecureContext( uint32_t ulSecureStackSize ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " svc %0 \n" /* Secure context is allocated in the supervisor call. */ + " bx lr \n" /* Return. */ + :: "i" ( portSVC_ALLOCATE_SECURE_CONTEXT ) : "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " ldr r1, [r0] \n" /* The first item in the TCB is the top of the stack. */ + " ldr r0, [r1] \n" /* The first item on the stack is the task's xSecureContext. */ + " cmp r0, #0 \n" /* Raise svc if task's xSecureContext is not NULL. */ + " beq free_secure_context \n" + " bx lr \n" /* There is no secure context (xSecureContext is NULL). */ + " free_secure_context: \n" + " svc %0 \n" /* Secure context is freed in the supervisor call. */ + " bx lr \n" /* Return. */ + :: "i" ( portSVC_FREE_SECURE_CONTEXT ) : "memory" + ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM23/portmacro.h b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM23/portmacro.h new file mode 100755 index 0000000..bbab1b7 --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM23/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M23" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __attribute__(( used )) +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM23_NTZ/portasm.c b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM23_NTZ/portasm.c new file mode 100755 index 0000000..5b8e604 --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM23_NTZ/portasm.c @@ -0,0 +1,381 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE ensures that PRIVILEGED_FUNCTION + * is defined correctly and privileged functions are placed in correct sections. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Portasm includes. */ +#include "portasm.h" + +/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE is needed to be defined only for the + * header files. */ +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#if( configENABLE_FPU == 1 ) + #error Cortex-M23 does not have a Floating Point Unit (FPU) and therefore configENABLE_FPU must be set to 0. +#endif + +void vRestoreContextOfFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " \n" + " ldr r2, pxCurrentTCBConst2 \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r1, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r0, [r1] \n" /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r3, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r4, #1 \n" /* r4 = 1. */ + " bics r3, r4 \n" /* r3 = r3 & ~r4 i.e. Clear the bit 0 in r3. */ + " str r3, [r2] \n" /* Disable MPU. */ + " \n" + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + " ldr r4, [r1] \n" /* r4 = *r1 i.e. r4 = MAIR0. */ + " ldr r2, xMAIR0Const2 \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r4, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst2 \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + " movs r4, #4 \n" /* r4 = 4. */ + " str r4, [r2] \n" /* Program RNR = 4. */ + " ldmia r1!, {r5,r6} \n" /* Read first set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst2 \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write first set of RBAR/RLAR registers. */ + " movs r4, #5 \n" /* r4 = 5. */ + " str r4, [r2] \n" /* Program RNR = 5. */ + " ldmia r1!, {r5,r6} \n" /* Read second set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst2 \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write second set of RBAR/RLAR registers. */ + " movs r4, #6 \n" /* r4 = 6. */ + " str r4, [r2] \n" /* Program RNR = 6. */ + " ldmia r1!, {r5,r6} \n" /* Read third set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst2 \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write third set of RBAR/RLAR registers. */ + " movs r4, #7 \n" /* r4 = 7. */ + " str r4, [r2] \n" /* Program RNR = 7. */ + " ldmia r1!, {r5,r6} \n" /* Read fourth set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst2 \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write fourth set of RBAR/RLAR registers. */ + " \n" + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r3, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r4, #1 \n" /* r4 = 1. */ + " orrs r3, r4 \n" /* r3 = r3 | r4 i.e. Set the bit 0 in r3. */ + " str r3, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " ldm r0!, {r1-r3} \n" /* Read from stack - r1 = PSPLIM, r2 = CONTROL and r3 = EXC_RETURN. */ + " msr psplim, r1 \n" /* Set this task's PSPLIM value. */ + " msr control, r2 \n" /* Set this task's CONTROL value. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r3 \n" /* Finally, branch to EXC_RETURN. */ + #else /* configENABLE_MPU */ + " ldm r0!, {r1-r2} \n" /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ + " msr psplim, r1 \n" /* Set this task's PSPLIM value. */ + " movs r1, #2 \n" /* r1 = 2. */ + " msr CONTROL, r1 \n" /* Switch to use PSP in the thread mode. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r2 \n" /* Finally, branch to EXC_RETURN. */ + #endif /* configENABLE_MPU */ + " \n" + " .align 4 \n" + "pxCurrentTCBConst2: .word pxCurrentTCB \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst2: .word 0xe000ed94 \n" + "xMAIR0Const2: .word 0xe000edc0 \n" + "xRNRConst2: .word 0xe000ed98 \n" + "xRBARConst2: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " movs r1, #1 \n" /* r1 = 1. */ + " tst r0, r1 \n" /* Perform r0 & r1 (bitwise AND) and update the conditions flag. */ + " beq running_privileged \n" /* If the result of previous AND operation was 0, branch. */ + " movs r0, #0 \n" /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + " bx lr \n" /* Return. */ + " running_privileged: \n" + " movs r0, #1 \n" /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + " bx lr \n" /* Return. */ + " \n" + " .align 4 \n" + ::: "r0", "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vRaisePrivilege( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, control \n" /* Read the CONTROL register. */ + " movs r1, #1 \n" /* r1 = 1. */ + " bics r0, r1 \n" /* Clear the bit 0. */ + " msr control, r0 \n" /* Write back the new CONTROL value. */ + " bx lr \n" /* Return to the caller. */ + ::: "r0", "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vResetPrivilege( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " movs r1, #1 \n" /* r1 = 1. */ + " orrs r0, r1 \n" /* r0 = r0 | r1. */ + " msr control, r0 \n" /* CONTROL = r0. */ + " bx lr \n" /* Return to the caller. */ + :::"r0", "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vStartFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " ldr r0, xVTORConst \n" /* Use the NVIC offset register to locate the stack. */ + " ldr r0, [r0] \n" /* Read the VTOR register which gives the address of vector table. */ + " ldr r0, [r0] \n" /* The first entry in vector table is stack pointer. */ + " msr msp, r0 \n" /* Set the MSP back to the start of the stack. */ + " cpsie i \n" /* Globally enable interrupts. */ + " dsb \n" + " isb \n" + " svc %0 \n" /* System call to start the first task. */ + " nop \n" + " \n" + " .align 4 \n" + "xVTORConst: .word 0xe000ed08 \n" + :: "i" ( portSVC_START_SCHEDULER ) : "memory" + ); +} +/*-----------------------------------------------------------*/ + +uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, PRIMASK \n" + " cpsid i \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* To avoid compiler warnings. The return statement will never be reached, + * but some compilers warn if it is not included, while others won't compile + * if it is. */ + return 0; +#endif +} +/*-----------------------------------------------------------*/ + +void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " msr PRIMASK, r0 \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* Just to avoid compiler warning. ulMask is used from the asm code but + * the compiler can't see that. Some compilers generate warnings without + * the following line, while others generate warnings if the line is + * included. */ + ( void ) ulMask; +#endif +} +/*-----------------------------------------------------------*/ + +void PendSV_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " \n" + " mrs r0, psp \n" /* Read PSP in r0. */ + " ldr r2, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r1, [r2] \n" /* Read pxCurrentTCB. */ + #if( configENABLE_MPU == 1 ) + " subs r0, r0, #44 \n" /* Make space for PSPLIM, CONTROL, LR and the remaining registers on the stack. */ + " str r0, [r1] \n" /* Save the new top of stack in TCB. */ + " mrs r1, psplim \n" /* r1 = PSPLIM. */ + " mrs r2, control \n" /* r2 = CONTROL. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " stmia r0!, {r1-r7} \n" /* Store on the stack - PSPLIM, CONTROL, LR and low registers that are not automatically saved. */ + " mov r4, r8 \n" /* r4 = r8. */ + " mov r5, r9 \n" /* r5 = r9. */ + " mov r6, r10 \n" /* r6 = r10. */ + " mov r7, r11 \n" /* r7 = r11. */ + " stmia r0!, {r4-r7} \n" /* Store the high registers that are not saved automatically. */ + #else /* configENABLE_MPU */ + " subs r0, r0, #40 \n" /* Make space for PSPLIM, LR and the remaining registers on the stack. */ + " str r0, [r1] \n" /* Save the new top of stack in TCB. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " stmia r0!, {r2-r7} \n" /* Store on the stack - PSPLIM, LR and low registers that are not automatically saved. */ + " mov r4, r8 \n" /* r4 = r8. */ + " mov r5, r9 \n" /* r5 = r9. */ + " mov r6, r10 \n" /* r6 = r10. */ + " mov r7, r11 \n" /* r7 = r11. */ + " stmia r0!, {r4-r7} \n" /* Store the high registers that are not saved automatically. */ + #endif /* configENABLE_MPU */ + " \n" + " cpsid i \n" + " bl vTaskSwitchContext \n" + " cpsie i \n" + " \n" + " ldr r2, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r1, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. r0 now points to the top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r3, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r4, #1 \n" /* r4 = 1. */ + " bics r3, r4 \n" /* r3 = r3 & ~r4 i.e. Clear the bit 0 in r3. */ + " str r3, [r2] \n" /* Disable MPU. */ + " \n" + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + " ldr r4, [r1] \n" /* r4 = *r1 i.e. r4 = MAIR0. */ + " ldr r2, xMAIR0Const \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r4, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + " movs r4, #4 \n" /* r4 = 4. */ + " str r4, [r2] \n" /* Program RNR = 4. */ + " ldmia r1!, {r5,r6} \n" /* Read first set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write first set of RBAR/RLAR registers. */ + " movs r4, #5 \n" /* r4 = 5. */ + " str r4, [r2] \n" /* Program RNR = 5. */ + " ldmia r1!, {r5,r6} \n" /* Read second set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write second set of RBAR/RLAR registers. */ + " movs r4, #6 \n" /* r4 = 6. */ + " str r4, [r2] \n" /* Program RNR = 6. */ + " ldmia r1!, {r5,r6} \n" /* Read third set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write third set of RBAR/RLAR registers. */ + " movs r4, #7 \n" /* r4 = 7. */ + " str r4, [r2] \n" /* Program RNR = 7. */ + " ldmia r1!, {r5,r6} \n" /* Read fourth set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write fourth set of RBAR/RLAR registers. */ + " \n" + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r3, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r4, #1 \n" /* r4 = 1. */ + " orrs r3, r4 \n" /* r3 = r3 | r4 i.e. Set the bit 0 in r3. */ + " str r3, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " adds r0, r0, #28 \n" /* Move to the high registers. */ + " ldmia r0!, {r4-r7} \n" /* Restore the high registers that are not automatically restored. */ + " mov r8, r4 \n" /* r8 = r4. */ + " mov r9, r5 \n" /* r9 = r5. */ + " mov r10, r6 \n" /* r10 = r6. */ + " mov r11, r7 \n" /* r11 = r7. */ + " msr psp, r0 \n" /* Remember the new top of stack for the task. */ + " subs r0, r0, #44 \n" /* Move to the starting of the saved context. */ + " ldmia r0!, {r1-r7} \n" /* Read from stack - r1 = PSPLIM, r2 = CONTROL, r3 = LR and r4-r7 restored. */ + " msr psplim, r1 \n" /* Restore the PSPLIM register value for the task. */ + " msr control, r2 \n" /* Restore the CONTROL register value for the task. */ + " bx r3 \n" + #else /* configENABLE_MPU */ + " adds r0, r0, #24 \n" /* Move to the high registers. */ + " ldmia r0!, {r4-r7} \n" /* Restore the high registers that are not automatically restored. */ + " mov r8, r4 \n" /* r8 = r4. */ + " mov r9, r5 \n" /* r9 = r5. */ + " mov r10, r6 \n" /* r10 = r6. */ + " mov r11, r7 \n" /* r11 = r7. */ + " msr psp, r0 \n" /* Remember the new top of stack for the task. */ + " subs r0, r0, #40 \n" /* Move to the starting of the saved context. */ + " ldmia r0!, {r2-r7} \n" /* Read from stack - r2 = PSPLIM, r3 = LR and r4-r7 restored. */ + " msr psplim, r2 \n" /* Restore the PSPLIM register value for the task. */ + " bx r3 \n" + #endif /* configENABLE_MPU */ + " \n" + " .align 4 \n" + "pxCurrentTCBConst: .word pxCurrentTCB \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst: .word 0xe000ed94 \n" + "xMAIR0Const: .word 0xe000edc0 \n" + "xRNRConst: .word 0xe000ed98 \n" + "xRBARConst: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +void SVC_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " movs r0, #4 \n" + " mov r1, lr \n" + " tst r0, r1 \n" + " beq stacking_used_msp \n" + " mrs r0, psp \n" + " ldr r2, svchandler_address_const \n" + " bx r2 \n" + " stacking_used_msp: \n" + " mrs r0, msp \n" + " ldr r2, svchandler_address_const \n" + " bx r2 \n" + " \n" + " .align 4 \n" + "svchandler_address_const: .word vPortSVCHandler_C \n" + ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM23_NTZ/portmacro.h b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM23_NTZ/portmacro.h new file mode 100755 index 0000000..bbab1b7 --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM23_NTZ/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M23" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __attribute__(( used )) +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM33/portasm.c b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM33/portasm.c new file mode 100755 index 0000000..3a24f3a --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM33/portasm.c @@ -0,0 +1,415 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE ensures that PRIVILEGED_FUNCTION + * is defined correctly and privileged functions are placed in correct sections. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Portasm includes. */ +#include "portasm.h" + +/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE is needed to be defined only for the + * header files. */ +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +void vRestoreContextOfFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " \n" + " ldr r2, pxCurrentTCBConst2 \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r3, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r0, [r3] \n" /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " bic r4, #1 \n" /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + " str r4, [r2] \n" /* Disable MPU. */ + " \n" + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + " ldr r4, [r3] \n" /* r4 = *r3 i.e. r4 = MAIR0. */ + " ldr r2, xMAIR0Const2 \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r4, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst2 \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " movs r4, #4 \n" /* r4 = 4. */ + " str r4, [r2] \n" /* Program RNR = 4. */ + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + " ldr r2, xRBARConst2 \n" /* r2 = 0xe000ed9c [Location of RBAR]. */ + " ldmia r3!, {r4-r11} \n" /* Read 4 set of RBAR/RLAR registers from TCB. */ + " stmia r2!, {r4-r11} \n" /* Write 4 set of RBAR/RLAR registers using alias registers. */ + " \n" + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " orr r4, #1 \n" /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + " str r4, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " ldm r0!, {r1-r4} \n" /* Read from stack - r1 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = EXC_RETURN. */ + " ldr r5, xSecureContextConst2 \n" + " str r1, [r5] \n" /* Set xSecureContext to this task's value for the same. */ + " msr psplim, r2 \n" /* Set this task's PSPLIM value. */ + " msr control, r3 \n" /* Set this task's CONTROL value. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r4 \n" /* Finally, branch to EXC_RETURN. */ + #else /* configENABLE_MPU */ + " ldm r0!, {r1-r3} \n" /* Read from stack - r1 = xSecureContext, r2 = PSPLIM and r3 = EXC_RETURN. */ + " ldr r4, xSecureContextConst2 \n" + " str r1, [r4] \n" /* Set xSecureContext to this task's value for the same. */ + " msr psplim, r2 \n" /* Set this task's PSPLIM value. */ + " movs r1, #2 \n" /* r1 = 2. */ + " msr CONTROL, r1 \n" /* Switch to use PSP in the thread mode. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r3 \n" /* Finally, branch to EXC_RETURN. */ + #endif /* configENABLE_MPU */ + " \n" + " .align 4 \n" + "pxCurrentTCBConst2: .word pxCurrentTCB \n" + "xSecureContextConst2: .word xSecureContext \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst2: .word 0xe000ed94 \n" + "xMAIR0Const2: .word 0xe000edc0 \n" + "xRNRConst2: .word 0xe000ed98 \n" + "xRBARConst2: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " tst r0, #1 \n" /* Perform r0 & 1 (bitwise AND) and update the conditions flag. */ + " ite ne \n" + " movne r0, #0 \n" /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + " moveq r0, #1 \n" /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + " bx lr \n" /* Return. */ + " \n" + " .align 4 \n" + ::: "r0", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vRaisePrivilege( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, control \n" /* Read the CONTROL register. */ + " bic r0, #1 \n" /* Clear the bit 0. */ + " msr control, r0 \n" /* Write back the new CONTROL value. */ + " bx lr \n" /* Return to the caller. */ + ::: "r0", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vResetPrivilege( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " orr r0, #1 \n" /* r0 = r0 | 1. */ + " msr control, r0 \n" /* CONTROL = r0. */ + " bx lr \n" /* Return to the caller. */ + :::"r0", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vStartFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " ldr r0, xVTORConst \n" /* Use the NVIC offset register to locate the stack. */ + " ldr r0, [r0] \n" /* Read the VTOR register which gives the address of vector table. */ + " ldr r0, [r0] \n" /* The first entry in vector table is stack pointer. */ + " msr msp, r0 \n" /* Set the MSP back to the start of the stack. */ + " cpsie i \n" /* Globally enable interrupts. */ + " cpsie f \n" + " dsb \n" + " isb \n" + " svc %0 \n" /* System call to start the first task. */ + " nop \n" + " \n" + " .align 4 \n" + "xVTORConst: .word 0xe000ed08 \n" + :: "i" ( portSVC_START_SCHEDULER ) : "memory" + ); +} +/*-----------------------------------------------------------*/ + +uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, PRIMASK \n" + " cpsid i \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* To avoid compiler warnings. The return statement will never be reached, + * but some compilers warn if it is not included, while others won't compile + * if it is. */ + return 0; +#endif +} +/*-----------------------------------------------------------*/ + +void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " msr PRIMASK, r0 \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* Just to avoid compiler warning. ulMask is used from the asm code but + * the compiler can't see that. Some compilers generate warnings without + * the following line, while others generate warnings if the line is + * included. */ + ( void ) ulMask; +#endif +} +/*-----------------------------------------------------------*/ + +void PendSV_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " .extern SecureContext_SaveContext \n" + " .extern SecureContext_LoadContext \n" + " \n" + " mrs r1, psp \n" /* Read PSP in r1. */ + " ldr r2, xSecureContextConst \n" /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + " ldr r0, [r2] \n" /* Read xSecureContext - Value of xSecureContext must be in r0 as it is used as a parameter later. */ + " \n" + " cbz r0, save_ns_context \n" /* No secure context to save. */ + " push {r0-r2, r14} \n" + " bl SecureContext_SaveContext \n" + " pop {r0-r3} \n" /* LR is now in r3. */ + " mov lr, r3 \n" /* LR = r3. */ + " lsls r2, r3, #25 \n" /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + " bpl save_ns_context \n" /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + " ldr r3, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r2, [r3] \n" /* Read pxCurrentTCB. */ + #if( configENABLE_MPU == 1 ) + " subs r1, r1, #16 \n" /* Make space for xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mrs r3, control \n" /* r3 = CONTROL. */ + " mov r4, lr \n" /* r4 = LR/EXC_RETURN. */ + " stmia r1!, {r0, r2-r4} \n" /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + #else /* configENABLE_MPU */ + " subs r1, r1, #12 \n" /* Make space for xSecureContext, PSPLIM and LR on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " stmia r1!, {r0, r2-r3} \n" /* Store xSecureContext, PSPLIM and LR on the stack. */ + #endif /* configENABLE_MPU */ + " b select_next_task \n" + " \n" + " save_ns_context: \n" + " ldr r3, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r2, [r3] \n" /* Read pxCurrentTCB. */ + #if( configENABLE_FPU == 1 ) + " tst lr, #0x10 \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + " it eq \n" + " vstmdbeq r1!, {s16-s31} \n" /* Store the FPU registers which are not saved automatically. */ + #endif /* configENABLE_FPU */ + #if( configENABLE_MPU == 1 ) + " subs r1, r1, #48 \n" /* Make space for xSecureContext, PSPLIM, CONTROL, LR and the remaining registers on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " adds r1, r1, #16 \n" /* r1 = r1 + 16. */ + " stm r1, {r4-r11} \n" /* Store the registers that are not saved automatically. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mrs r3, control \n" /* r3 = CONTROL. */ + " mov r4, lr \n" /* r4 = LR/EXC_RETURN. */ + " subs r1, r1, #16 \n" /* r1 = r1 - 16. */ + " stm r1, {r0, r2-r4} \n" /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + #else /* configENABLE_MPU */ + " subs r1, r1, #44 \n" /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " adds r1, r1, #12 \n" /* r1 = r1 + 12. */ + " stm r1, {r4-r11} \n" /* Store the registers that are not saved automatically. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " subs r1, r1, #12 \n" /* r1 = r1 - 12. */ + " stmia r1!, {r0, r2-r3} \n" /* Store xSecureContext, PSPLIM and LR on the stack. */ + #endif /* configENABLE_MPU */ + " \n" + " select_next_task: \n" + " cpsid i \n" + " bl vTaskSwitchContext \n" + " cpsie i \n" + " \n" + " ldr r2, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r3, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r1, [r3] \n" /* The first item in pxCurrentTCB is the task top of stack. r1 now points to the top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " bic r4, #1 \n" /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + " str r4, [r2] \n" /* Disable MPU. */ + " \n" + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + " ldr r4, [r3] \n" /* r4 = *r3 i.e. r4 = MAIR0. */ + " ldr r2, xMAIR0Const \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r4, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " movs r4, #4 \n" /* r4 = 4. */ + " str r4, [r2] \n" /* Program RNR = 4. */ + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + " ldr r2, xRBARConst \n" /* r2 = 0xe000ed9c [Location of RBAR]. */ + " ldmia r3!, {r4-r11} \n" /* Read 4 sets of RBAR/RLAR registers from TCB. */ + " stmia r2!, {r4-r11} \n" /* Write 4 set of RBAR/RLAR registers using alias registers. */ + " \n" + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " orr r4, #1 \n" /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + " str r4, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " ldmia r1!, {r0, r2-r4} \n" /* Read from stack - r0 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = LR. */ + " msr psplim, r2 \n" /* Restore the PSPLIM register value for the task. */ + " msr control, r3 \n" /* Restore the CONTROL register value for the task. */ + " mov lr, r4 \n" /* LR = r4. */ + " ldr r2, xSecureContextConst \n" /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + " str r0, [r2] \n" /* Restore the task's xSecureContext. */ + " cbz r0, restore_ns_context \n" /* If there is no secure context for the task, restore the non-secure context. */ + " push {r1,r4} \n" + " bl SecureContext_LoadContext \n" /* Restore the secure context. */ + " pop {r1,r4} \n" + " mov lr, r4 \n" /* LR = r4. */ + " lsls r2, r4, #25 \n" /* r2 = r4 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + " bpl restore_ns_context \n" /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + " msr psp, r1 \n" /* Remember the new top of stack for the task. */ + " bx lr \n" + #else /* configENABLE_MPU */ + " ldmia r1!, {r0, r2-r3} \n" /* Read from stack - r0 = xSecureContext, r2 = PSPLIM and r3 = LR. */ + " msr psplim, r2 \n" /* Restore the PSPLIM register value for the task. */ + " mov lr, r3 \n" /* LR = r3. */ + " ldr r2, xSecureContextConst \n" /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + " str r0, [r2] \n" /* Restore the task's xSecureContext. */ + " cbz r0, restore_ns_context \n" /* If there is no secure context for the task, restore the non-secure context. */ + " push {r1,r3} \n" + " bl SecureContext_LoadContext \n" /* Restore the secure context. */ + " pop {r1,r3} \n" + " mov lr, r3 \n" /* LR = r3. */ + " lsls r2, r3, #25 \n" /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + " bpl restore_ns_context \n" /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + " msr psp, r1 \n" /* Remember the new top of stack for the task. */ + " bx lr \n" + #endif /* configENABLE_MPU */ + " \n" + " restore_ns_context: \n" + " ldmia r1!, {r4-r11} \n" /* Restore the registers that are not automatically restored. */ + #if( configENABLE_FPU == 1 ) + " tst lr, #0x10 \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + " it eq \n" + " vldmiaeq r1!, {s16-s31} \n" /* Restore the FPU registers which are not restored automatically. */ + #endif /* configENABLE_FPU */ + " msr psp, r1 \n" /* Remember the new top of stack for the task. */ + " bx lr \n" + " \n" + " .align 4 \n" + "pxCurrentTCBConst: .word pxCurrentTCB \n" + "xSecureContextConst: .word xSecureContext \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst: .word 0xe000ed94 \n" + "xMAIR0Const: .word 0xe000edc0 \n" + "xRNRConst: .word 0xe000ed98 \n" + "xRBARConst: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +void SVC_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " tst lr, #4 \n" + " ite eq \n" + " mrseq r0, msp \n" + " mrsne r0, psp \n" + " ldr r1, svchandler_address_const \n" + " bx r1 \n" + " \n" + " .align 4 \n" + "svchandler_address_const: .word vPortSVCHandler_C \n" + ); +} +/*-----------------------------------------------------------*/ + +void vPortAllocateSecureContext( uint32_t ulSecureStackSize ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " svc %0 \n" /* Secure context is allocated in the supervisor call. */ + " bx lr \n" /* Return. */ + :: "i" ( portSVC_ALLOCATE_SECURE_CONTEXT ) : "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " ldr r1, [r0] \n" /* The first item in the TCB is the top of the stack. */ + " ldr r0, [r1] \n" /* The first item on the stack is the task's xSecureContext. */ + " cmp r0, #0 \n" /* Raise svc if task's xSecureContext is not NULL. */ + " it ne \n" + " svcne %0 \n" /* Secure context is freed in the supervisor call. */ + " bx lr \n" /* Return. */ + :: "i" ( portSVC_FREE_SECURE_CONTEXT ) : "memory" + ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM33/portmacro.h b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM33/portmacro.h new file mode 100755 index 0000000..d051ddc --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM33/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M33" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __attribute__(( used )) +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM33_NTZ/portasm.c b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM33_NTZ/portasm.c new file mode 100755 index 0000000..ba4a69c --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM33_NTZ/portasm.c @@ -0,0 +1,321 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE ensures that PRIVILEGED_FUNCTION + * is defined correctly and privileged functions are placed in correct sections. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Portasm includes. */ +#include "portasm.h" + +/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE is needed to be defined only for the + * header files. */ +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +void vRestoreContextOfFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " \n" + " ldr r2, pxCurrentTCBConst2 \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r1, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r0, [r1] \n" /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " bic r4, #1 \n" /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + " str r4, [r2] \n" /* Disable MPU. */ + " \n" + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + " ldr r3, [r1] \n" /* r3 = *r1 i.e. r3 = MAIR0. */ + " ldr r2, xMAIR0Const2 \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r3, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst2 \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " movs r3, #4 \n" /* r3 = 4. */ + " str r3, [r2] \n" /* Program RNR = 4. */ + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + " ldr r2, xRBARConst2 \n" /* r2 = 0xe000ed9c [Location of RBAR]. */ + " ldmia r1!, {r4-r11} \n" /* Read 4 set of RBAR/RLAR registers from TCB. */ + " stmia r2!, {r4-r11} \n" /* Write 4 set of RBAR/RLAR registers using alias registers. */ + " \n" + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " orr r4, #1 \n" /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + " str r4, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " ldm r0!, {r1-r3} \n" /* Read from stack - r1 = PSPLIM, r2 = CONTROL and r3 = EXC_RETURN. */ + " msr psplim, r1 \n" /* Set this task's PSPLIM value. */ + " msr control, r2 \n" /* Set this task's CONTROL value. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r3 \n" /* Finally, branch to EXC_RETURN. */ + #else /* configENABLE_MPU */ + " ldm r0!, {r1-r2} \n" /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ + " msr psplim, r1 \n" /* Set this task's PSPLIM value. */ + " movs r1, #2 \n" /* r1 = 2. */ + " msr CONTROL, r1 \n" /* Switch to use PSP in the thread mode. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r2 \n" /* Finally, branch to EXC_RETURN. */ + #endif /* configENABLE_MPU */ + " \n" + " .align 4 \n" + "pxCurrentTCBConst2: .word pxCurrentTCB \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst2: .word 0xe000ed94 \n" + "xMAIR0Const2: .word 0xe000edc0 \n" + "xRNRConst2: .word 0xe000ed98 \n" + "xRBARConst2: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " tst r0, #1 \n" /* Perform r0 & 1 (bitwise AND) and update the conditions flag. */ + " ite ne \n" + " movne r0, #0 \n" /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + " moveq r0, #1 \n" /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + " bx lr \n" /* Return. */ + " \n" + " .align 4 \n" + ::: "r0", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vRaisePrivilege( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, control \n" /* Read the CONTROL register. */ + " bic r0, #1 \n" /* Clear the bit 0. */ + " msr control, r0 \n" /* Write back the new CONTROL value. */ + " bx lr \n" /* Return to the caller. */ + ::: "r0", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vResetPrivilege( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " orr r0, #1 \n" /* r0 = r0 | 1. */ + " msr control, r0 \n" /* CONTROL = r0. */ + " bx lr \n" /* Return to the caller. */ + :::"r0", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vStartFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " ldr r0, xVTORConst \n" /* Use the NVIC offset register to locate the stack. */ + " ldr r0, [r0] \n" /* Read the VTOR register which gives the address of vector table. */ + " ldr r0, [r0] \n" /* The first entry in vector table is stack pointer. */ + " msr msp, r0 \n" /* Set the MSP back to the start of the stack. */ + " cpsie i \n" /* Globally enable interrupts. */ + " cpsie f \n" + " dsb \n" + " isb \n" + " svc %0 \n" /* System call to start the first task. */ + " nop \n" + " \n" + " .align 4 \n" + "xVTORConst: .word 0xe000ed08 \n" + :: "i" ( portSVC_START_SCHEDULER ) : "memory" + ); +} +/*-----------------------------------------------------------*/ + +uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, PRIMASK \n" + " cpsid i \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* To avoid compiler warnings. The return statement will never be reached, + * but some compilers warn if it is not included, while others won't compile + * if it is. */ + return 0; +#endif +} +/*-----------------------------------------------------------*/ + +void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " msr PRIMASK, r0 \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* Just to avoid compiler warning. ulMask is used from the asm code but + * the compiler can't see that. Some compilers generate warnings without + * the following line, while others generate warnings if the line is + * included. */ + ( void ) ulMask; +#endif +} +/*-----------------------------------------------------------*/ + +void PendSV_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " \n" + " mrs r0, psp \n" /* Read PSP in r0. */ + #if( configENABLE_FPU == 1 ) + " tst lr, #0x10 \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + " it eq \n" + " vstmdbeq r0!, {s16-s31} \n" /* Store the FPU registers which are not saved automatically. */ + #endif /* configENABLE_FPU */ + #if( configENABLE_MPU == 1 ) + " mrs r1, psplim \n" /* r1 = PSPLIM. */ + " mrs r2, control \n" /* r2 = CONTROL. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " stmdb r0!, {r1-r11} \n" /* Store on the stack - PSPLIM, CONTROL, LR and registers that are not automatically saved. */ + #else /* configENABLE_MPU */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " stmdb r0!, {r2-r11} \n" /* Store on the stack - PSPLIM, LR and registers that are not automatically saved. */ + #endif /* configENABLE_MPU */ + " \n" + " ldr r2, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r1, [r2] \n" /* Read pxCurrentTCB. */ + " str r0, [r1] \n" /* Save the new top of stack in TCB. */ + " \n" + " cpsid i \n" + " bl vTaskSwitchContext \n" + " cpsie i \n" + " \n" + " ldr r2, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r1, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. r0 now points to the top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " bic r4, #1 \n" /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + " str r4, [r2] \n" /* Disable MPU. */ + " \n" + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + " ldr r3, [r1] \n" /* r3 = *r1 i.e. r3 = MAIR0. */ + " ldr r2, xMAIR0Const \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r3, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " movs r3, #4 \n" /* r3 = 4. */ + " str r3, [r2] \n" /* Program RNR = 4. */ + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + " ldr r2, xRBARConst \n" /* r2 = 0xe000ed9c [Location of RBAR]. */ + " ldmia r1!, {r4-r11} \n" /* Read 4 sets of RBAR/RLAR registers from TCB. */ + " stmia r2!, {r4-r11} \n" /* Write 4 set of RBAR/RLAR registers using alias registers. */ + " \n" + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " orr r4, #1 \n" /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + " str r4, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " ldmia r0!, {r1-r11} \n" /* Read from stack - r1 = PSPLIM, r2 = CONTROL, r3 = LR and r4-r11 restored. */ + #else /* configENABLE_MPU */ + " ldmia r0!, {r2-r11} \n" /* Read from stack - r2 = PSPLIM, r3 = LR and r4-r11 restored. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_FPU == 1 ) + " tst r3, #0x10 \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + " it eq \n" + " vldmiaeq r0!, {s16-s31} \n" /* Restore the FPU registers which are not restored automatically. */ + #endif /* configENABLE_FPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " msr psplim, r1 \n" /* Restore the PSPLIM register value for the task. */ + " msr control, r2 \n" /* Restore the CONTROL register value for the task. */ + #else /* configENABLE_MPU */ + " msr psplim, r2 \n" /* Restore the PSPLIM register value for the task. */ + #endif /* configENABLE_MPU */ + " msr psp, r0 \n" /* Remember the new top of stack for the task. */ + " bx r3 \n" + " \n" + " .align 4 \n" + "pxCurrentTCBConst: .word pxCurrentTCB \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst: .word 0xe000ed94 \n" + "xMAIR0Const: .word 0xe000edc0 \n" + "xRNRConst: .word 0xe000ed98 \n" + "xRBARConst: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +void SVC_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " tst lr, #4 \n" + " ite eq \n" + " mrseq r0, msp \n" + " mrsne r0, psp \n" + " ldr r1, svchandler_address_const \n" + " bx r1 \n" + " \n" + " .align 4 \n" + "svchandler_address_const: .word vPortSVCHandler_C \n" + ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM33_NTZ/portmacro.h b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM33_NTZ/portmacro.h new file mode 100755 index 0000000..d051ddc --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/GCC/ARM_CM33_NTZ/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M33" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __attribute__(( used )) +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM23/portasm.s b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM23/portasm.s new file mode 100755 index 0000000..b1a543a --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM23/portasm.s @@ -0,0 +1,377 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + EXTERN pxCurrentTCB + EXTERN xSecureContext + EXTERN vTaskSwitchContext + EXTERN vPortSVCHandler_C + EXTERN SecureContext_SaveContext + EXTERN SecureContext_LoadContext + + PUBLIC xIsPrivileged + PUBLIC vResetPrivilege + PUBLIC vPortAllocateSecureContext + PUBLIC vRestoreContextOfFirstTask + PUBLIC vRaisePrivilege + PUBLIC vStartFirstTask + PUBLIC ulSetInterruptMaskFromISR + PUBLIC vClearInterruptMaskFromISR + PUBLIC PendSV_Handler + PUBLIC SVC_Handler + PUBLIC vPortFreeSecureContext + +#if ( configENABLE_FPU == 1 ) + #error Cortex-M23 does not have a Floating Point Unit (FPU) and therefore configENABLE_FPU must be set to 0. +#endif +/*-----------------------------------------------------------*/ + +/*---------------- Unprivileged Functions -------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION .text:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +xIsPrivileged: + mrs r0, control /* r0 = CONTROL. */ + movs r1, #1 /* r1 = 1. */ + tst r0, r1 /* Perform r0 & r1 (bitwise AND) and update the conditions flag. */ + beq running_privileged /* If the result of previous AND operation was 0, branch. */ + movs r0, #0 /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + bx lr /* Return. */ + running_privileged: + movs r0, #1 /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ + +vResetPrivilege: + mrs r0, control /* r0 = CONTROL. */ + movs r1, #1 /* r1 = 1. */ + orrs r0, r1 /* r0 = r0 | r1. */ + msr control, r0 /* CONTROL = r0. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +vPortAllocateSecureContext: + svc 0 /* Secure context is allocated in the supervisor call. portSVC_ALLOCATE_SECURE_CONTEXT = 0. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ + +/*----------------- Privileged Functions --------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION privileged_functions:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +vRestoreContextOfFirstTask: + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r3, [r2] /* Read pxCurrentTCB. */ + ldr r0, [r3] /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + +#if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + movs r5, #1 /* r5 = 1. */ + bics r4, r5 /* r4 = r4 & ~r5 i.e. Clear the bit 0 in r4. */ + str r4, [r2] /* Disable MPU. */ + + adds r3, #4 /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + ldr r4, [r3] /* r4 = *r3 i.e. r4 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r4, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + adds r3, #4 /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + movs r5, #4 /* r5 = 4. */ + str r5, [r2] /* Program RNR = 4. */ + ldmia r3!, {r6,r7} /* Read first set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write first set of RBAR/RLAR registers. */ + movs r5, #5 /* r5 = 5. */ + str r5, [r2] /* Program RNR = 5. */ + ldmia r3!, {r6,r7} /* Read second set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write second set of RBAR/RLAR registers. */ + movs r5, #6 /* r5 = 6. */ + str r5, [r2] /* Program RNR = 6. */ + ldmia r3!, {r6,r7} /* Read third set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write third set of RBAR/RLAR registers. */ + movs r5, #7 /* r5 = 7. */ + str r5, [r2] /* Program RNR = 7. */ + ldmia r3!, {r6,r7} /* Read fourth set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write fourth set of RBAR/RLAR registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + movs r5, #1 /* r5 = 1. */ + orrs r4, r5 /* r4 = r4 | r5 i.e. Set the bit 0 in r4. */ + str r4, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ +#endif /* configENABLE_MPU */ + +#if ( configENABLE_MPU == 1 ) + ldm r0!, {r1-r4} /* Read from stack - r1 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = EXC_RETURN. */ + ldr r5, =xSecureContext + str r1, [r5] /* Set xSecureContext to this task's value for the same. */ + msr psplim, r2 /* Set this task's PSPLIM value. */ + msr control, r3 /* Set this task's CONTROL value. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r4 /* Finally, branch to EXC_RETURN. */ +#else /* configENABLE_MPU */ + ldm r0!, {r1-r3} /* Read from stack - r1 = xSecureContext, r2 = PSPLIM and r3 = EXC_RETURN. */ + ldr r4, =xSecureContext + str r1, [r4] /* Set xSecureContext to this task's value for the same. */ + msr psplim, r2 /* Set this task's PSPLIM value. */ + movs r1, #2 /* r1 = 2. */ + msr CONTROL, r1 /* Switch to use PSP in the thread mode. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r3 /* Finally, branch to EXC_RETURN. */ +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +vRaisePrivilege: + mrs r0, control /* Read the CONTROL register. */ + movs r1, #1 /* r1 = 1. */ + bics r0, r1 /* Clear the bit 0. */ + msr control, r0 /* Write back the new CONTROL value. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +vStartFirstTask: + ldr r0, =0xe000ed08 /* Use the NVIC offset register to locate the stack. */ + ldr r0, [r0] /* Read the VTOR register which gives the address of vector table. */ + ldr r0, [r0] /* The first entry in vector table is stack pointer. */ + msr msp, r0 /* Set the MSP back to the start of the stack. */ + cpsie i /* Globally enable interrupts. */ + dsb + isb + svc 2 /* System call to start the first task. portSVC_START_SCHEDULER = 2. */ +/*-----------------------------------------------------------*/ + +ulSetInterruptMaskFromISR: + mrs r0, PRIMASK + cpsid i + bx lr +/*-----------------------------------------------------------*/ + +vClearInterruptMaskFromISR: + msr PRIMASK, r0 + bx lr +/*-----------------------------------------------------------*/ + +PendSV_Handler: + mrs r1, psp /* Read PSP in r1. */ + ldr r2, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + ldr r0, [r2] /* Read xSecureContext - Value of xSecureContext must be in r0 as it is used as a parameter later. */ + + cbz r0, save_ns_context /* No secure context to save. */ + push {r0-r2, r14} + bl SecureContext_SaveContext + pop {r0-r3} /* LR is now in r3. */ + mov lr, r3 /* LR = r3. */ + lsls r2, r3, #25 /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + bpl save_ns_context /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r2, [r3] /* Read pxCurrentTCB. */ +#if ( configENABLE_MPU == 1 ) + subs r1, r1, #16 /* Make space for xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mrs r3, control /* r3 = CONTROL. */ + mov r4, lr /* r4 = LR/EXC_RETURN. */ + stmia r1!, {r0, r2-r4} /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ +#else /* configENABLE_MPU */ + subs r1, r1, #12 /* Make space for xSecureContext, PSPLIM and LR on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + stmia r1!, {r0, r2-r3} /* Store xSecureContext, PSPLIM and LR on the stack. */ +#endif /* configENABLE_MPU */ + b select_next_task + + save_ns_context: + ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r2, [r3] /* Read pxCurrentTCB. */ + #if ( configENABLE_MPU == 1 ) + subs r1, r1, #48 /* Make space for xSecureContext, PSPLIM, CONTROL, LR and the remaining registers on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + adds r1, r1, #16 /* r1 = r1 + 16. */ + stmia r1!, {r4-r7} /* Store the low registers that are not saved automatically. */ + mov r4, r8 /* r4 = r8. */ + mov r5, r9 /* r5 = r9. */ + mov r6, r10 /* r6 = r10. */ + mov r7, r11 /* r7 = r11. */ + stmia r1!, {r4-r7} /* Store the high registers that are not saved automatically. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mrs r3, control /* r3 = CONTROL. */ + mov r4, lr /* r4 = LR/EXC_RETURN. */ + subs r1, r1, #48 /* r1 = r1 - 48. */ + stmia r1!, {r0, r2-r4} /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + #else /* configENABLE_MPU */ + subs r1, r1, #44 /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + stmia r1!, {r0, r2-r7} /* Store xSecureContext, PSPLIM, LR and the low registers that are not saved automatically. */ + mov r4, r8 /* r4 = r8. */ + mov r5, r9 /* r5 = r9. */ + mov r6, r10 /* r6 = r10. */ + mov r7, r11 /* r7 = r11. */ + stmia r1!, {r4-r7} /* Store the high registers that are not saved automatically. */ + #endif /* configENABLE_MPU */ + + select_next_task: + cpsid i + bl vTaskSwitchContext + cpsie i + + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r3, [r2] /* Read pxCurrentTCB. */ + ldr r1, [r3] /* The first item in pxCurrentTCB is the task top of stack. r1 now points to the top of stack. */ + + #if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + movs r5, #1 /* r5 = 1. */ + bics r4, r5 /* r4 = r4 & ~r5 i.e. Clear the bit 0 in r4. */ + str r4, [r2] /* Disable MPU. */ + + adds r3, #4 /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + ldr r4, [r3] /* r4 = *r3 i.e. r4 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r4, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + adds r3, #4 /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + movs r5, #4 /* r5 = 4. */ + str r5, [r2] /* Program RNR = 4. */ + ldmia r3!, {r6,r7} /* Read first set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write first set of RBAR/RLAR registers. */ + movs r5, #5 /* r5 = 5. */ + str r5, [r2] /* Program RNR = 5. */ + ldmia r3!, {r6,r7} /* Read second set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write second set of RBAR/RLAR registers. */ + movs r5, #6 /* r5 = 6. */ + str r5, [r2] /* Program RNR = 6. */ + ldmia r3!, {r6,r7} /* Read third set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write third set of RBAR/RLAR registers. */ + movs r5, #7 /* r5 = 7. */ + str r5, [r2] /* Program RNR = 7. */ + ldmia r3!, {r6,r7} /* Read fourth set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write fourth set of RBAR/RLAR registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + movs r5, #1 /* r5 = 1. */ + orrs r4, r5 /* r4 = r4 | r5 i.e. Set the bit 0 in r4. */ + str r4, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + + #if ( configENABLE_MPU == 1 ) + ldmia r1!, {r0, r2-r4} /* Read from stack - r0 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = LR. */ + msr psplim, r2 /* Restore the PSPLIM register value for the task. */ + msr control, r3 /* Restore the CONTROL register value for the task. */ + mov lr, r4 /* LR = r4. */ + ldr r2, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + str r0, [r2] /* Restore the task's xSecureContext. */ + cbz r0, restore_ns_context /* If there is no secure context for the task, restore the non-secure context. */ + push {r1,r4} + bl SecureContext_LoadContext /* Restore the secure context. */ + pop {r1,r4} + mov lr, r4 /* LR = r4. */ + lsls r2, r4, #25 /* r2 = r4 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + bpl restore_ns_context /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + msr psp, r1 /* Remember the new top of stack for the task. */ + bx lr + #else /* configENABLE_MPU */ + ldmia r1!, {r0, r2-r3} /* Read from stack - r0 = xSecureContext, r2 = PSPLIM and r3 = LR. */ + msr psplim, r2 /* Restore the PSPLIM register value for the task. */ + mov lr, r3 /* LR = r3. */ + ldr r2, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + str r0, [r2] /* Restore the task's xSecureContext. */ + cbz r0, restore_ns_context /* If there is no secure context for the task, restore the non-secure context. */ + push {r1,r3} + bl SecureContext_LoadContext /* Restore the secure context. */ + pop {r1,r3} + mov lr, r3 /* LR = r3. */ + lsls r2, r3, #25 /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + bpl restore_ns_context /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + msr psp, r1 /* Remember the new top of stack for the task. */ + bx lr + #endif /* configENABLE_MPU */ + + restore_ns_context: + adds r1, r1, #16 /* Move to the high registers. */ + ldmia r1!, {r4-r7} /* Restore the high registers that are not automatically restored. */ + mov r8, r4 /* r8 = r4. */ + mov r9, r5 /* r9 = r5. */ + mov r10, r6 /* r10 = r6. */ + mov r11, r7 /* r11 = r7. */ + msr psp, r1 /* Remember the new top of stack for the task. */ + subs r1, r1, #32 /* Go back to the low registers. */ + ldmia r1!, {r4-r7} /* Restore the low registers that are not automatically restored. */ + bx lr +/*-----------------------------------------------------------*/ + +SVC_Handler: + movs r0, #4 + mov r1, lr + tst r0, r1 + beq stacking_used_msp + mrs r0, psp + b vPortSVCHandler_C + stacking_used_msp: + mrs r0, msp + b vPortSVCHandler_C +/*-----------------------------------------------------------*/ + +vPortFreeSecureContext: + ldr r1, [r0] /* The first item in the TCB is the top of the stack. */ + ldr r0, [r1] /* The first item on the stack is the task's xSecureContext. */ + cmp r0, #0 /* Raise svc if task's xSecureContext is not NULL. */ + beq free_secure_context + bx lr /* There is no secure context (xSecureContext is NULL). */ + free_secure_context: + svc 1 /* Secure context is freed in the supervisor call. portSVC_FREE_SECURE_CONTEXT = 1. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ + + END diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM23/portmacro.h b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM23/portmacro.h new file mode 100755 index 0000000..48b0e0b --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM23/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M23" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __root +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM23_NTZ/portasm.s b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM23_NTZ/portasm.s new file mode 100755 index 0000000..3121df6 --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM23_NTZ/portasm.s @@ -0,0 +1,303 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + EXTERN pxCurrentTCB + EXTERN vTaskSwitchContext + EXTERN vPortSVCHandler_C + + PUBLIC xIsPrivileged + PUBLIC vResetPrivilege + PUBLIC vRestoreContextOfFirstTask + PUBLIC vRaisePrivilege + PUBLIC vStartFirstTask + PUBLIC ulSetInterruptMaskFromISR + PUBLIC vClearInterruptMaskFromISR + PUBLIC PendSV_Handler + PUBLIC SVC_Handler + +#if ( configENABLE_FPU == 1 ) + #error Cortex-M23 does not have a Floating Point Unit (FPU) and therefore configENABLE_FPU must be set to 0. +#endif +/*-----------------------------------------------------------*/ + +/*---------------- Unprivileged Functions -------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION .text:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +xIsPrivileged: + mrs r0, control /* r0 = CONTROL. */ + movs r1, #1 /* r1 = 1. */ + tst r0, r1 /* Perform r0 & r1 (bitwise AND) and update the conditions flag. */ + beq running_privileged /* If the result of previous AND operation was 0, branch. */ + movs r0, #0 /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + bx lr /* Return. */ + running_privileged: + movs r0, #1 /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + bx lr /* Return. */ + +/*-----------------------------------------------------------*/ + +vResetPrivilege: + mrs r0, control /* r0 = CONTROL. */ + movs r1, #1 /* r1 = 1. */ + orrs r0, r1 /* r0 = r0 | r1. */ + msr control, r0 /* CONTROL = r0. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +/*----------------- Privileged Functions --------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION privileged_functions:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +vRestoreContextOfFirstTask: + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r1, [r2] /* Read pxCurrentTCB. */ + ldr r0, [r1] /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + +#if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r3, [r2] /* Read the value of MPU_CTRL. */ + movs r4, #1 /* r4 = 1. */ + bics r3, r4 /* r3 = r3 & ~r4 i.e. Clear the bit 0 in r3. */ + str r3, [r2] /* Disable MPU. */ + + adds r1, #4 /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + ldr r4, [r1] /* r4 = *r1 i.e. r4 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r4, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + adds r1, #4 /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + movs r4, #4 /* r4 = 4. */ + str r4, [r2] /* Program RNR = 4. */ + ldmia r1!, {r5,r6} /* Read first set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write first set of RBAR/RLAR registers. */ + movs r4, #5 /* r4 = 5. */ + str r4, [r2] /* Program RNR = 5. */ + ldmia r1!, {r5,r6} /* Read second set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write second set of RBAR/RLAR registers. */ + movs r4, #6 /* r4 = 6. */ + str r4, [r2] /* Program RNR = 6. */ + ldmia r1!, {r5,r6} /* Read third set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write third set of RBAR/RLAR registers. */ + movs r4, #7 /* r4 = 7. */ + str r4, [r2] /* Program RNR = 7. */ + ldmia r1!, {r5,r6} /* Read fourth set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write fourth set of RBAR/RLAR registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r3, [r2] /* Read the value of MPU_CTRL. */ + movs r4, #1 /* r4 = 1. */ + orrs r3, r4 /* r3 = r3 | r4 i.e. Set the bit 0 in r3. */ + str r3, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ +#endif /* configENABLE_MPU */ + +#if ( configENABLE_MPU == 1 ) + ldm r0!, {r1-r3} /* Read from stack - r1 = PSPLIM, r2 = CONTROL and r3 = EXC_RETURN. */ + msr psplim, r1 /* Set this task's PSPLIM value. */ + msr control, r2 /* Set this task's CONTROL value. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r3 /* Finally, branch to EXC_RETURN. */ +#else /* configENABLE_MPU */ + ldm r0!, {r1-r2} /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ + msr psplim, r1 /* Set this task's PSPLIM value. */ + movs r1, #2 /* r1 = 2. */ + msr CONTROL, r1 /* Switch to use PSP in the thread mode. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r2 /* Finally, branch to EXC_RETURN. */ +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +vRaisePrivilege: + mrs r0, control /* Read the CONTROL register. */ + movs r1, #1 /* r1 = 1. */ + bics r0, r1 /* Clear the bit 0. */ + msr control, r0 /* Write back the new CONTROL value. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +vStartFirstTask: + ldr r0, =0xe000ed08 /* Use the NVIC offset register to locate the stack. */ + ldr r0, [r0] /* Read the VTOR register which gives the address of vector table. */ + ldr r0, [r0] /* The first entry in vector table is stack pointer. */ + msr msp, r0 /* Set the MSP back to the start of the stack. */ + cpsie i /* Globally enable interrupts. */ + dsb + isb + svc 2 /* System call to start the first task. portSVC_START_SCHEDULER = 2. */ + nop +/*-----------------------------------------------------------*/ + +ulSetInterruptMaskFromISR: + mrs r0, PRIMASK + cpsid i + bx lr +/*-----------------------------------------------------------*/ + +vClearInterruptMaskFromISR: + msr PRIMASK, r0 + bx lr +/*-----------------------------------------------------------*/ + +PendSV_Handler: + mrs r0, psp /* Read PSP in r0. */ + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r1, [r2] /* Read pxCurrentTCB. */ +#if ( configENABLE_MPU == 1 ) + subs r0, r0, #44 /* Make space for PSPLIM, CONTROL, LR and the remaining registers on the stack. */ + str r0, [r1] /* Save the new top of stack in TCB. */ + mrs r1, psplim /* r1 = PSPLIM. */ + mrs r2, control /* r2 = CONTROL. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + stmia r0!, {r1-r7} /* Store on the stack - PSPLIM, CONTROL, LR and low registers that are not automatically saved. */ + mov r4, r8 /* r4 = r8. */ + mov r5, r9 /* r5 = r9. */ + mov r6, r10 /* r6 = r10. */ + mov r7, r11 /* r7 = r11. */ + stmia r0!, {r4-r7} /* Store the high registers that are not saved automatically. */ +#else /* configENABLE_MPU */ + subs r0, r0, #40 /* Make space for PSPLIM, LR and the remaining registers on the stack. */ + str r0, [r1] /* Save the new top of stack in TCB. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + stmia r0!, {r2-r7} /* Store on the stack - PSPLIM, LR and low registers that are not automatically saved. */ + mov r4, r8 /* r4 = r8. */ + mov r5, r9 /* r5 = r9. */ + mov r6, r10 /* r6 = r10. */ + mov r7, r11 /* r7 = r11. */ + stmia r0!, {r4-r7} /* Store the high registers that are not saved automatically. */ +#endif /* configENABLE_MPU */ + + cpsid i + bl vTaskSwitchContext + cpsie i + + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r1, [r2] /* Read pxCurrentTCB. */ + ldr r0, [r1] /* The first item in pxCurrentTCB is the task top of stack. r0 now points to the top of stack. */ + +#if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r3, [r2] /* Read the value of MPU_CTRL. */ + movs r4, #1 /* r4 = 1. */ + bics r3, r4 /* r3 = r3 & ~r4 i.e. Clear the bit 0 in r3. */ + str r3, [r2] /* Disable MPU. */ + + adds r1, #4 /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + ldr r4, [r1] /* r4 = *r1 i.e. r4 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r4, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + adds r1, #4 /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + movs r4, #4 /* r4 = 4. */ + str r4, [r2] /* Program RNR = 4. */ + ldmia r1!, {r5,r6} /* Read first set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write first set of RBAR/RLAR registers. */ + movs r4, #5 /* r4 = 5. */ + str r4, [r2] /* Program RNR = 5. */ + ldmia r1!, {r5,r6} /* Read second set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write second set of RBAR/RLAR registers. */ + movs r4, #6 /* r4 = 6. */ + str r4, [r2] /* Program RNR = 6. */ + ldmia r1!, {r5,r6} /* Read third set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write third set of RBAR/RLAR registers. */ + movs r4, #7 /* r4 = 7. */ + str r4, [r2] /* Program RNR = 7. */ + ldmia r1!, {r5,r6} /* Read fourth set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write fourth set of RBAR/RLAR registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r3, [r2] /* Read the value of MPU_CTRL. */ + movs r4, #1 /* r4 = 1. */ + orrs r3, r4 /* r3 = r3 | r4 i.e. Set the bit 0 in r3. */ + str r3, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ +#endif /* configENABLE_MPU */ + +#if ( configENABLE_MPU == 1 ) + adds r0, r0, #28 /* Move to the high registers. */ + ldmia r0!, {r4-r7} /* Restore the high registers that are not automatically restored. */ + mov r8, r4 /* r8 = r4. */ + mov r9, r5 /* r9 = r5. */ + mov r10, r6 /* r10 = r6. */ + mov r11, r7 /* r11 = r7. */ + msr psp, r0 /* Remember the new top of stack for the task. */ + subs r0, r0, #44 /* Move to the starting of the saved context. */ + ldmia r0!, {r1-r7} /* Read from stack - r1 = PSPLIM, r2 = CONTROL, r3 = LR and r4-r7 restored. */ + msr psplim, r1 /* Restore the PSPLIM register value for the task. */ + msr control, r2 /* Restore the CONTROL register value for the task. */ + bx r3 +#else /* configENABLE_MPU */ + adds r0, r0, #24 /* Move to the high registers. */ + ldmia r0!, {r4-r7} /* Restore the high registers that are not automatically restored. */ + mov r8, r4 /* r8 = r4. */ + mov r9, r5 /* r9 = r5. */ + mov r10, r6 /* r10 = r6. */ + mov r11, r7 /* r11 = r7. */ + msr psp, r0 /* Remember the new top of stack for the task. */ + subs r0, r0, #40 /* Move to the starting of the saved context. */ + ldmia r0!, {r2-r7} /* Read from stack - r2 = PSPLIM, r3 = LR and r4-r7 restored. */ + msr psplim, r2 /* Restore the PSPLIM register value for the task. */ + bx r3 +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +SVC_Handler: + movs r0, #4 + mov r1, lr + tst r0, r1 + beq stacking_used_msp + mrs r0, psp + b vPortSVCHandler_C + stacking_used_msp: + mrs r0, msp + b vPortSVCHandler_C +/*-----------------------------------------------------------*/ + + END diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM23_NTZ/portmacro.h b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM23_NTZ/portmacro.h new file mode 100755 index 0000000..48b0e0b --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM23_NTZ/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M23" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __root +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM33/portasm.s b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM33/portasm.s new file mode 100755 index 0000000..e38104c --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM33/portasm.s @@ -0,0 +1,326 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + EXTERN pxCurrentTCB + EXTERN xSecureContext + EXTERN vTaskSwitchContext + EXTERN vPortSVCHandler_C + EXTERN SecureContext_SaveContext + EXTERN SecureContext_LoadContext + + PUBLIC xIsPrivileged + PUBLIC vResetPrivilege + PUBLIC vPortAllocateSecureContext + PUBLIC vRestoreContextOfFirstTask + PUBLIC vRaisePrivilege + PUBLIC vStartFirstTask + PUBLIC ulSetInterruptMaskFromISR + PUBLIC vClearInterruptMaskFromISR + PUBLIC PendSV_Handler + PUBLIC SVC_Handler + PUBLIC vPortFreeSecureContext +/*-----------------------------------------------------------*/ + +/*---------------- Unprivileged Functions -------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION .text:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +xIsPrivileged: + mrs r0, control /* r0 = CONTROL. */ + tst r0, #1 /* Perform r0 & 1 (bitwise AND) and update the conditions flag. */ + ite ne + movne r0, #0 /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + moveq r0, #1 /* CONTROL[0]==0. Return true to indicate that the processor is not privileged. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ + +vResetPrivilege: + mrs r0, control /* r0 = CONTROL. */ + orr r0, r0, #1 /* r0 = r0 | 1. */ + msr control, r0 /* CONTROL = r0. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +vPortAllocateSecureContext: + svc 0 /* Secure context is allocated in the supervisor call. portSVC_ALLOCATE_SECURE_CONTEXT = 0. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ + +/*----------------- Privileged Functions --------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION privileged_functions:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +vRestoreContextOfFirstTask: + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r3, [r2] /* Read pxCurrentTCB. */ + ldr r0, [r3] /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + +#if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + bic r4, r4, #1 /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + str r4, [r2] /* Disable MPU. */ + + adds r3, #4 /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + ldr r4, [r3] /* r4 = *r3 i.e. r4 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r4, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + movs r4, #4 /* r4 = 4. */ + str r4, [r2] /* Program RNR = 4. */ + adds r3, #4 /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + ldr r2, =0xe000ed9c /* r2 = 0xe000ed9c [Location of RBAR]. */ + ldmia r3!, {r4-r11} /* Read 4 set of RBAR/RLAR registers from TCB. */ + stmia r2!, {r4-r11} /* Write 4 set of RBAR/RLAR registers using alias registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + orr r4, r4, #1 /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + str r4, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ +#endif /* configENABLE_MPU */ + +#if ( configENABLE_MPU == 1 ) + ldm r0!, {r1-r4} /* Read from stack - r1 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = EXC_RETURN. */ + ldr r5, =xSecureContext + str r1, [r5] /* Set xSecureContext to this task's value for the same. */ + msr psplim, r2 /* Set this task's PSPLIM value. */ + msr control, r3 /* Set this task's CONTROL value. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r4 /* Finally, branch to EXC_RETURN. */ +#else /* configENABLE_MPU */ + ldm r0!, {r1-r3} /* Read from stack - r1 = xSecureContext, r2 = PSPLIM and r3 = EXC_RETURN. */ + ldr r4, =xSecureContext + str r1, [r4] /* Set xSecureContext to this task's value for the same. */ + msr psplim, r2 /* Set this task's PSPLIM value. */ + movs r1, #2 /* r1 = 2. */ + msr CONTROL, r1 /* Switch to use PSP in the thread mode. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r3 /* Finally, branch to EXC_RETURN. */ +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +vRaisePrivilege: + mrs r0, control /* Read the CONTROL register. */ + bic r0, r0, #1 /* Clear the bit 0. */ + msr control, r0 /* Write back the new CONTROL value. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +vStartFirstTask: + ldr r0, =0xe000ed08 /* Use the NVIC offset register to locate the stack. */ + ldr r0, [r0] /* Read the VTOR register which gives the address of vector table. */ + ldr r0, [r0] /* The first entry in vector table is stack pointer. */ + msr msp, r0 /* Set the MSP back to the start of the stack. */ + cpsie i /* Globally enable interrupts. */ + cpsie f + dsb + isb + svc 2 /* System call to start the first task. portSVC_START_SCHEDULER = 2. */ +/*-----------------------------------------------------------*/ + +ulSetInterruptMaskFromISR: + mrs r0, PRIMASK + cpsid i + bx lr +/*-----------------------------------------------------------*/ + +vClearInterruptMaskFromISR: + msr PRIMASK, r0 + bx lr +/*-----------------------------------------------------------*/ + +PendSV_Handler: + mrs r1, psp /* Read PSP in r1. */ + ldr r2, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + ldr r0, [r2] /* Read xSecureContext - Value of xSecureContext must be in r0 as it is used as a parameter later. */ + + cbz r0, save_ns_context /* No secure context to save. */ + push {r0-r2, r14} + bl SecureContext_SaveContext + pop {r0-r3} /* LR is now in r3. */ + mov lr, r3 /* LR = r3. */ + lsls r2, r3, #25 /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + bpl save_ns_context /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r2, [r3] /* Read pxCurrentTCB. */ +#if ( configENABLE_MPU == 1 ) + subs r1, r1, #16 /* Make space for xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mrs r3, control /* r3 = CONTROL. */ + mov r4, lr /* r4 = LR/EXC_RETURN. */ + stmia r1!, {r0, r2-r4} /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ +#else /* configENABLE_MPU */ + subs r1, r1, #12 /* Make space for xSecureContext, PSPLIM and LR on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + stmia r1!, {r0, r2-r3} /* Store xSecureContext, PSPLIM and LR on the stack. */ +#endif /* configENABLE_MPU */ + b select_next_task + + save_ns_context: + ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r2, [r3] /* Read pxCurrentTCB. */ + #if ( configENABLE_FPU == 1 ) + tst lr, #0x10 /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + it eq + vstmdbeq r1!, {s16-s31} /* Store the FPU registers which are not saved automatically. */ + #endif /* configENABLE_FPU */ + #if ( configENABLE_MPU == 1 ) + subs r1, r1, #48 /* Make space for xSecureContext, PSPLIM, CONTROL, LR and the remaining registers on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + adds r1, r1, #16 /* r1 = r1 + 16. */ + stm r1, {r4-r11} /* Store the registers that are not saved automatically. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mrs r3, control /* r3 = CONTROL. */ + mov r4, lr /* r4 = LR/EXC_RETURN. */ + subs r1, r1, #16 /* r1 = r1 - 16. */ + stm r1, {r0, r2-r4} /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + #else /* configENABLE_MPU */ + subs r1, r1, #44 /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + adds r1, r1, #12 /* r1 = r1 + 12. */ + stm r1, {r4-r11} /* Store the registers that are not saved automatically. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + subs r1, r1, #12 /* r1 = r1 - 12. */ + stmia r1!, {r0, r2-r3} /* Store xSecureContext, PSPLIM and LR on the stack. */ + #endif /* configENABLE_MPU */ + + select_next_task: + cpsid i + bl vTaskSwitchContext + cpsie i + + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r3, [r2] /* Read pxCurrentTCB. */ + ldr r1, [r3] /* The first item in pxCurrentTCB is the task top of stack. r1 now points to the top of stack. */ + + #if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + bic r4, r4, #1 /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + str r4, [r2] /* Disable MPU. */ + + adds r3, #4 /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + ldr r4, [r3] /* r4 = *r3 i.e. r4 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r4, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + movs r4, #4 /* r4 = 4. */ + str r4, [r2] /* Program RNR = 4. */ + adds r3, #4 /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + ldr r2, =0xe000ed9c /* r2 = 0xe000ed9c [Location of RBAR]. */ + ldmia r3!, {r4-r11} /* Read 4 sets of RBAR/RLAR registers from TCB. */ + stmia r2!, {r4-r11} /* Write 4 set of RBAR/RLAR registers using alias registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + orr r4, r4, #1 /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + str r4, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + + #if ( configENABLE_MPU == 1 ) + ldmia r1!, {r0, r2-r4} /* Read from stack - r0 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = LR. */ + msr psplim, r2 /* Restore the PSPLIM register value for the task. */ + msr control, r3 /* Restore the CONTROL register value for the task. */ + mov lr, r4 /* LR = r4. */ + ldr r2, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + str r0, [r2] /* Restore the task's xSecureContext. */ + cbz r0, restore_ns_context /* If there is no secure context for the task, restore the non-secure context. */ + push {r1,r4} + bl SecureContext_LoadContext /* Restore the secure context. */ + pop {r1,r4} + mov lr, r4 /* LR = r4. */ + lsls r2, r4, #25 /* r2 = r4 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + bpl restore_ns_context /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + msr psp, r1 /* Remember the new top of stack for the task. */ + bx lr + #else /* configENABLE_MPU */ + ldmia r1!, {r0, r2-r3} /* Read from stack - r0 = xSecureContext, r2 = PSPLIM and r3 = LR. */ + msr psplim, r2 /* Restore the PSPLIM register value for the task. */ + mov lr, r3 /* LR = r3. */ + ldr r2, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + str r0, [r2] /* Restore the task's xSecureContext. */ + cbz r0, restore_ns_context /* If there is no secure context for the task, restore the non-secure context. */ + push {r1,r3} + bl SecureContext_LoadContext /* Restore the secure context. */ + pop {r1,r3} + mov lr, r3 /* LR = r3. */ + lsls r2, r3, #25 /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + bpl restore_ns_context /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + msr psp, r1 /* Remember the new top of stack for the task. */ + bx lr + #endif /* configENABLE_MPU */ + + restore_ns_context: + ldmia r1!, {r4-r11} /* Restore the registers that are not automatically restored. */ + #if ( configENABLE_FPU == 1 ) + tst lr, #0x10 /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + it eq + vldmiaeq r1!, {s16-s31} /* Restore the FPU registers which are not restored automatically. */ + #endif /* configENABLE_FPU */ + msr psp, r1 /* Remember the new top of stack for the task. */ + bx lr +/*-----------------------------------------------------------*/ + +SVC_Handler: + tst lr, #4 + ite eq + mrseq r0, msp + mrsne r0, psp + b vPortSVCHandler_C +/*-----------------------------------------------------------*/ + +vPortFreeSecureContext: + /* r0 = uint32_t *pulTCB. */ + ldr r1, [r0] /* The first item in the TCB is the top of the stack. */ + ldr r0, [r1] /* The first item on the stack is the task's xSecureContext. */ + cmp r0, #0 /* Raise svc if task's xSecureContext is not NULL. */ + it ne + svcne 1 /* Secure context is freed in the supervisor call. portSVC_FREE_SECURE_CONTEXT = 1. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ + + END diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM33/portmacro.h b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM33/portmacro.h new file mode 100755 index 0000000..aba3daf --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM33/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M33" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __root +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM33_NTZ/portasm.s b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM33_NTZ/portasm.s new file mode 100755 index 0000000..400755b --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM33_NTZ/portasm.s @@ -0,0 +1,242 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + EXTERN pxCurrentTCB + EXTERN vTaskSwitchContext + EXTERN vPortSVCHandler_C + + PUBLIC xIsPrivileged + PUBLIC vResetPrivilege + PUBLIC vRestoreContextOfFirstTask + PUBLIC vRaisePrivilege + PUBLIC vStartFirstTask + PUBLIC ulSetInterruptMaskFromISR + PUBLIC vClearInterruptMaskFromISR + PUBLIC PendSV_Handler + PUBLIC SVC_Handler +/*-----------------------------------------------------------*/ + +/*---------------- Unprivileged Functions -------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION .text:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +xIsPrivileged: + mrs r0, control /* r0 = CONTROL. */ + tst r0, #1 /* Perform r0 & 1 (bitwise AND) and update the conditions flag. */ + ite ne + movne r0, #0 /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + moveq r0, #1 /* CONTROL[0]==0. Return true to indicate that the processor is not privileged. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ + +vResetPrivilege: + mrs r0, control /* r0 = CONTROL. */ + orr r0, r0, #1 /* r0 = r0 | 1. */ + msr control, r0 /* CONTROL = r0. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +/*----------------- Privileged Functions --------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION privileged_functions:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +vRestoreContextOfFirstTask: + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r1, [r2] /* Read pxCurrentTCB. */ + ldr r0, [r1] /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + +#if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + bic r4, r4, #1 /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + str r4, [r2] /* Disable MPU. */ + + adds r1, #4 /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + ldr r3, [r1] /* r3 = *r1 i.e. r3 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r3, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + movs r3, #4 /* r3 = 4. */ + str r3, [r2] /* Program RNR = 4. */ + adds r1, #4 /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + ldr r2, =0xe000ed9c /* r2 = 0xe000ed9c [Location of RBAR]. */ + ldmia r1!, {r4-r11} /* Read 4 sets of RBAR/RLAR registers from TCB. */ + stmia r2!, {r4-r11} /* Write 4 set of RBAR/RLAR registers using alias registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + orr r4, r4, #1 /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + str r4, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ +#endif /* configENABLE_MPU */ + +#if ( configENABLE_MPU == 1 ) + ldm r0!, {r1-r3} /* Read from stack - r1 = PSPLIM, r2 = CONTROL and r3 = EXC_RETURN. */ + msr psplim, r1 /* Set this task's PSPLIM value. */ + msr control, r2 /* Set this task's CONTROL value. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r3 /* Finally, branch to EXC_RETURN. */ +#else /* configENABLE_MPU */ + ldm r0!, {r1-r2} /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ + msr psplim, r1 /* Set this task's PSPLIM value. */ + movs r1, #2 /* r1 = 2. */ + msr CONTROL, r1 /* Switch to use PSP in the thread mode. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r2 /* Finally, branch to EXC_RETURN. */ +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +vRaisePrivilege: + mrs r0, control /* Read the CONTROL register. */ + bic r0, r0, #1 /* Clear the bit 0. */ + msr control, r0 /* Write back the new CONTROL value. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +vStartFirstTask: + ldr r0, =0xe000ed08 /* Use the NVIC offset register to locate the stack. */ + ldr r0, [r0] /* Read the VTOR register which gives the address of vector table. */ + ldr r0, [r0] /* The first entry in vector table is stack pointer. */ + msr msp, r0 /* Set the MSP back to the start of the stack. */ + cpsie i /* Globally enable interrupts. */ + cpsie f + dsb + isb + svc 2 /* System call to start the first task. portSVC_START_SCHEDULER = 2. */ +/*-----------------------------------------------------------*/ + +ulSetInterruptMaskFromISR: + mrs r0, PRIMASK + cpsid i + bx lr +/*-----------------------------------------------------------*/ + +vClearInterruptMaskFromISR: + msr PRIMASK, r0 + bx lr +/*-----------------------------------------------------------*/ + +PendSV_Handler: + mrs r0, psp /* Read PSP in r0. */ +#if ( configENABLE_FPU == 1 ) + tst lr, #0x10 /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + it eq + vstmdbeq r0!, {s16-s31} /* Store the FPU registers which are not saved automatically. */ +#endif /* configENABLE_FPU */ +#if ( configENABLE_MPU == 1 ) + mrs r1, psplim /* r1 = PSPLIM. */ + mrs r2, control /* r2 = CONTROL. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + stmdb r0!, {r1-r11} /* Store on the stack - PSPLIM, CONTROL, LR and registers that are not automatically saved. */ +#else /* configENABLE_MPU */ + mrs r2, psplim /* r2 = PSPLIM. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + stmdb r0!, {r2-r11} /* Store on the stack - PSPLIM, LR and registers that are not automatically. */ +#endif /* configENABLE_MPU */ + + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r1, [r2] /* Read pxCurrentTCB. */ + str r0, [r1] /* Save the new top of stack in TCB. */ + + cpsid i + bl vTaskSwitchContext + cpsie i + + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r1, [r2] /* Read pxCurrentTCB. */ + ldr r0, [r1] /* The first item in pxCurrentTCB is the task top of stack. r0 now points to the top of stack. */ + +#if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + bic r4, r4, #1 /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + str r4, [r2] /* Disable MPU. */ + + adds r1, #4 /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + ldr r3, [r1] /* r3 = *r1 i.e. r3 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r3, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + movs r3, #4 /* r3 = 4. */ + str r3, [r2] /* Program RNR = 4. */ + adds r1, #4 /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + ldr r2, =0xe000ed9c /* r2 = 0xe000ed9c [Location of RBAR]. */ + ldmia r1!, {r4-r11} /* Read 4 sets of RBAR/RLAR registers from TCB. */ + stmia r2!, {r4-r11} /* Write 4 set of RBAR/RLAR registers using alias registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + orr r4, r4, #1 /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + str r4, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ +#endif /* configENABLE_MPU */ + +#if ( configENABLE_MPU == 1 ) + ldmia r0!, {r1-r11} /* Read from stack - r1 = PSPLIM, r2 = CONTROL, r3 = LR and r4-r11 restored. */ +#else /* configENABLE_MPU */ + ldmia r0!, {r2-r11} /* Read from stack - r2 = PSPLIM, r3 = LR and r4-r11 restored. */ +#endif /* configENABLE_MPU */ + +#if ( configENABLE_FPU == 1 ) + tst r3, #0x10 /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + it eq + vldmiaeq r0!, {s16-s31} /* Restore the FPU registers which are not restored automatically. */ +#endif /* configENABLE_FPU */ + + #if ( configENABLE_MPU == 1 ) + msr psplim, r1 /* Restore the PSPLIM register value for the task. */ + msr control, r2 /* Restore the CONTROL register value for the task. */ +#else /* configENABLE_MPU */ + msr psplim, r2 /* Restore the PSPLIM register value for the task. */ +#endif /* configENABLE_MPU */ + msr psp, r0 /* Remember the new top of stack for the task. */ + bx r3 +/*-----------------------------------------------------------*/ + +SVC_Handler: + tst lr, #4 + ite eq + mrseq r0, msp + mrsne r0, psp + b vPortSVCHandler_C +/*-----------------------------------------------------------*/ + + END diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM33_NTZ/portmacro.h b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM33_NTZ/portmacro.h new file mode 100755 index 0000000..aba3daf --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portable/IAR/ARM_CM33_NTZ/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M33" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __root +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portasm.h b/FreeRTOS/Source/portable/ARMv8M/non_secure/portasm.h new file mode 100755 index 0000000..2ecf04e --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portasm.h @@ -0,0 +1,113 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __PORT_ASM_H__ +#define __PORT_ASM_H__ + +/* Scheduler includes. */ +#include "FreeRTOS.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/** + * @brief Restore the context of the first task so that the first task starts + * executing. + */ +void vRestoreContextOfFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +BaseType_t xIsPrivileged( void ) __attribute__ (( naked )); + +/** + * @brief Raises the privilege level by clearing the bit 0 of the CONTROL + * register. + * + * @note This is a privileged function and should only be called from the kenrel + * code. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vRaisePrivilege( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vResetPrivilege( void ) __attribute__ (( naked )); + +/** + * @brief Starts the first task. + */ +void vStartFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Disables interrupts. + */ +uint32_t ulSetInterruptMaskFromISR( void ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Enables interrupts. + */ +void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief PendSV Exception handler. + */ +void PendSV_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief SVC Handler. + */ +void SVC_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Allocate a Secure context for the calling task. + * + * @param[in] ulSecureStackSize The size of the stack to be allocated on the + * secure side for the calling task. + */ +void vPortAllocateSecureContext( uint32_t ulSecureStackSize ) __attribute__ (( naked )); + +/** + * @brief Free the task's secure context. + * + * @param[in] pulTCB Pointer to the Task Control Block (TCB) of the task. + */ +void vPortFreeSecureContext( uint32_t *pulTCB ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +#endif /* __PORT_ASM_H__ */ diff --git a/FreeRTOS/Source/portable/ARMv8M/non_secure/portmacro.h b/FreeRTOS/Source/portable/ARMv8M/non_secure/portmacro.h new file mode 100755 index 0000000..2d02a1f --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/non_secure/portmacro.h @@ -0,0 +1,295 @@ +/* + * FreeRTOS Kernel V10.2.0 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portPRIVILEGED_RAM_REGION ( 2UL ) +#define portUNPRIVILEGED_DEVICE_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Devices Region. */ +#define portDEVICE_REGION_START_ADDRESS ( 0x50000000 ) +#define portDEVICE_REGION_END_ADDRESS ( 0x5FFFFFFF ) + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/ARMv8M/secure/ReadMe.txt b/FreeRTOS/Source/portable/ARMv8M/secure/ReadMe.txt new file mode 100755 index 0000000..9b12e54 --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/secure/ReadMe.txt @@ -0,0 +1,10 @@ +This directory tree contains the master copy of the FreeeRTOS Cortex-M33 port. +Do not use the files located here! These file are copied into separate +FreeRTOS/Source/portable/[compiler]/ARM_CM33_NNN directories prior to each +FreeRTOS release. + +If your Cortex-M33 application uses TrustZone then use the files from the +FreeRTOS/Source/portable/[compiler]/ARM_CM33 directories. + +If your Cortex-M33 application does not use TrustZone then use the files from +the FreeRTOS/Source/portable/[compiler]/ARM_CM33_NTZ directories. diff --git a/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/GCC/ARM_CM23/secure_context_port.c b/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/GCC/ARM_CM23/secure_context_port.c new file mode 100755 index 0000000..e703498 --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/GCC/ARM_CM23/secure_context_port.c @@ -0,0 +1,91 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Secure context includes. */ +#include "secure_context.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +#if( configENABLE_FPU == 1 ) + #error Cortex-M23 does not have a Floating Point Unit (FPU) and therefore configENABLE_FPU must be set to 0. +#endif + +secureportNON_SECURE_CALLABLE void SecureContext_LoadContext( SecureContextHandle_t xSecureContextHandle ) +{ + /* xSecureContextHandle value is in r0. */ + __asm volatile + ( + " .syntax unified \n" + " \n" + " mrs r1, ipsr \n" /* r1 = IPSR. */ + " cbz r1, load_ctx_therad_mode \n" /* Do nothing if the processor is running in the Thread Mode. */ + " ldmia r0!, {r1, r2} \n" /* r1 = xSecureContextHandle->pucCurrentStackPointer, r2 = xSecureContextHandle->pucStackLimit. */ + #if( configENABLE_MPU == 1 ) + " ldmia r1!, {r3} \n" /* Read CONTROL register value from task's stack. r3 = CONTROL. */ + " msr control, r3 \n" /* CONTROL = r3. */ + #endif /* configENABLE_MPU */ + " msr psplim, r2 \n" /* PSPLIM = r2. */ + " msr psp, r1 \n" /* PSP = r1. */ + " \n" + " load_ctx_therad_mode: \n" + " nop \n" + " \n" + :::"r0", "r1", "r2" + ); +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_SaveContext( SecureContextHandle_t xSecureContextHandle ) +{ + /* xSecureContextHandle value is in r0. */ + __asm volatile + ( + " .syntax unified \n" + " \n" + " mrs r1, ipsr \n" /* r1 = IPSR. */ + " cbz r1, save_ctx_therad_mode \n" /* Do nothing if the processor is running in the Thread Mode. */ + " mrs r1, psp \n" /* r1 = PSP. */ + #if( configENABLE_MPU == 1 ) + " mrs r2, control \n" /* r2 = CONTROL. */ + " subs r1, r1, #4 \n" /* Make space for the CONTROL value on the stack. */ + " str r1, [r0] \n" /* Save the top of stack in context. xSecureContextHandle->pucCurrentStackPointer = r1. */ + " stmia r1!, {r2} \n" /* Store CONTROL value on the stack. */ + #else /* configENABLE_MPU */ + " str r1, [r0] \n" /* Save the top of stack in context. xSecureContextHandle->pucCurrentStackPointer = r1. */ + #endif /* configENABLE_MPU */ + " movs r1, %0 \n" /* r1 = securecontextNO_STACK. */ + " msr psplim, r1 \n" /* PSPLIM = securecontextNO_STACK. */ + " msr psp, r1 \n" /* PSP = securecontextNO_STACK i.e. No stack for thread mode until next task's context is loaded. */ + " \n" + " save_ctx_therad_mode: \n" + " nop \n" + " \n" + :: "i" ( securecontextNO_STACK ) : "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/GCC/ARM_CM33/secure_context_port.c b/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/GCC/ARM_CM33/secure_context_port.c new file mode 100755 index 0000000..7c556f5 --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/GCC/ARM_CM33/secure_context_port.c @@ -0,0 +1,88 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Secure context includes. */ +#include "secure_context.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +secureportNON_SECURE_CALLABLE void SecureContext_LoadContext( SecureContextHandle_t xSecureContextHandle ) +{ + /* xSecureContextHandle value is in r0. */ + __asm volatile + ( + " .syntax unified \n" + " \n" + " mrs r1, ipsr \n" /* r1 = IPSR. */ + " cbz r1, load_ctx_therad_mode \n" /* Do nothing if the processor is running in the Thread Mode. */ + " ldmia r0!, {r1, r2} \n" /* r1 = xSecureContextHandle->pucCurrentStackPointer, r2 = xSecureContextHandle->pucStackLimit. */ + #if( configENABLE_MPU == 1 ) + " ldmia r1!, {r3} \n" /* Read CONTROL register value from task's stack. r3 = CONTROL. */ + " msr control, r3 \n" /* CONTROL = r3. */ + #endif /* configENABLE_MPU */ + " msr psplim, r2 \n" /* PSPLIM = r2. */ + " msr psp, r1 \n" /* PSP = r1. */ + " \n" + " load_ctx_therad_mode: \n" + " nop \n" + " \n" + :::"r0", "r1", "r2" + ); +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_SaveContext( SecureContextHandle_t xSecureContextHandle ) +{ + /* xSecureContextHandle value is in r0. */ + __asm volatile + ( + " .syntax unified \n" + " \n" + " mrs r1, ipsr \n" /* r1 = IPSR. */ + " cbz r1, save_ctx_therad_mode \n" /* Do nothing if the processor is running in the Thread Mode. */ + " mrs r1, psp \n" /* r1 = PSP. */ + #if( configENABLE_FPU == 1 ) + " vstmdb r1!, {s0} \n" /* Trigger the defferred stacking of FPU registers. */ + " vldmia r1!, {s0} \n" /* Nullify the effect of the pervious statement. */ + #endif /* configENABLE_FPU */ + #if( configENABLE_MPU == 1 ) + " mrs r2, control \n" /* r2 = CONTROL. */ + " stmdb r1!, {r2} \n" /* Store CONTROL value on the stack. */ + #endif /* configENABLE_MPU */ + " str r1, [r0] \n" /* Save the top of stack in context. xSecureContextHandle->pucCurrentStackPointer = r1. */ + " movs r1, %0 \n" /* r1 = securecontextNO_STACK. */ + " msr psplim, r1 \n" /* PSPLIM = securecontextNO_STACK. */ + " msr psp, r1 \n" /* PSP = securecontextNO_STACK i.e. No stack for thread mode until next task's context is loaded. */ + " \n" + " save_ctx_therad_mode: \n" + " nop \n" + " \n" + :: "i" ( securecontextNO_STACK ) : "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/IAR/ARM_CM23/secure_context_port.c b/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/IAR/ARM_CM23/secure_context_port.c new file mode 100755 index 0000000..619db1e --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/IAR/ARM_CM23/secure_context_port.c @@ -0,0 +1,48 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Secure context includes. */ +#include "secure_context.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/* Functions implemented in assembler file. */ +extern void SecureContext_LoadContextAsm( SecureContextHandle_t xSecureContextHandle ); +extern void SecureContext_SaveContextAsm( SecureContextHandle_t xSecureContextHandle ); + +secureportNON_SECURE_CALLABLE void SecureContext_LoadContext( SecureContextHandle_t xSecureContextHandle ) +{ + SecureContext_LoadContextAsm( xSecureContextHandle ); +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_SaveContext( SecureContextHandle_t xSecureContextHandle ) +{ + SecureContext_SaveContextAsm( xSecureContextHandle ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/IAR/ARM_CM23/secure_context_port_asm.s b/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/IAR/ARM_CM23/secure_context_port_asm.s new file mode 100755 index 0000000..65cee0c --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/IAR/ARM_CM23/secure_context_port_asm.s @@ -0,0 +1,76 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + SECTION .text:CODE:NOROOT(2) + THUMB + + PUBLIC SecureContext_LoadContextAsm + PUBLIC SecureContext_SaveContextAsm + +#if ( configENABLE_FPU == 1 ) + #error Cortex-M23 does not have a Floating Point Unit (FPU) and therefore configENABLE_FPU must be set to 0. +#endif +/*-----------------------------------------------------------*/ + +SecureContext_LoadContextAsm: + /* xSecureContextHandle value is in r0. */ + mrs r1, ipsr /* r1 = IPSR. */ + cbz r1, load_ctx_therad_mode /* Do nothing if the processor is running in the Thread Mode. */ + ldmia r0!, {r1, r2} /* r1 = xSecureContextHandle->pucCurrentStackPointer, r2 = xSecureContextHandle->pucStackLimit. */ +#if ( configENABLE_MPU == 1 ) + ldmia r1!, {r3} /* Read CONTROL register value from task's stack. r3 = CONTROL. */ + msr control, r3 /* CONTROL = r3. */ +#endif /* configENABLE_MPU */ + msr psplim, r2 /* PSPLIM = r2. */ + msr psp, r1 /* PSP = r1. */ + + load_ctx_therad_mode: + bx lr +/*-----------------------------------------------------------*/ + +SecureContext_SaveContextAsm: + /* xSecureContextHandle value is in r0. */ + mrs r1, ipsr /* r1 = IPSR. */ + cbz r1, save_ctx_therad_mode /* Do nothing if the processor is running in the Thread Mode. */ + mrs r1, psp /* r1 = PSP. */ +#if ( configENABLE_MPU == 1 ) + mrs r2, control /* r2 = CONTROL. */ + subs r1, r1, #4 /* Make space for the CONTROL value on the stack. */ + str r1, [r0] /* Save the top of stack in context. xSecureContextHandle->pucCurrentStackPointer = r1. */ + stmia r1!, {r2} /* Store CONTROL value on the stack. */ +#else /* configENABLE_MPU */ + str r1, [r0] /* Save the top of stack in context. xSecureContextHandle->pucCurrentStackPointer = r1. */ +#endif /* configENABLE_MPU */ + movs r1, #0 /* r1 = securecontextNO_STACK. */ + msr psplim, r1 /* PSPLIM = securecontextNO_STACK. */ + msr psp, r1 /* PSP = securecontextNO_STACK i.e. No stack for thread mode until next task's context is loaded. */ + + save_ctx_therad_mode: + bx lr +/*-----------------------------------------------------------*/ + + END diff --git a/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/IAR/ARM_CM33/secure_context_port.c b/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/IAR/ARM_CM33/secure_context_port.c new file mode 100755 index 0000000..619db1e --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/IAR/ARM_CM33/secure_context_port.c @@ -0,0 +1,48 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Secure context includes. */ +#include "secure_context.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/* Functions implemented in assembler file. */ +extern void SecureContext_LoadContextAsm( SecureContextHandle_t xSecureContextHandle ); +extern void SecureContext_SaveContextAsm( SecureContextHandle_t xSecureContextHandle ); + +secureportNON_SECURE_CALLABLE void SecureContext_LoadContext( SecureContextHandle_t xSecureContextHandle ) +{ + SecureContext_LoadContextAsm( xSecureContextHandle ); +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_SaveContext( SecureContextHandle_t xSecureContextHandle ) +{ + SecureContext_SaveContextAsm( xSecureContextHandle ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/IAR/ARM_CM33/secure_context_port_asm.s b/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/IAR/ARM_CM33/secure_context_port_asm.s new file mode 100755 index 0000000..0cbfe6e --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/secure/context/portable/IAR/ARM_CM33/secure_context_port_asm.s @@ -0,0 +1,73 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + SECTION .text:CODE:NOROOT(2) + THUMB + + PUBLIC SecureContext_LoadContextAsm + PUBLIC SecureContext_SaveContextAsm +/*-----------------------------------------------------------*/ + +SecureContext_LoadContextAsm: + /* xSecureContextHandle value is in r0. */ + mrs r1, ipsr /* r1 = IPSR. */ + cbz r1, load_ctx_therad_mode /* Do nothing if the processor is running in the Thread Mode. */ + ldmia r0!, {r1, r2} /* r1 = xSecureContextHandle->pucCurrentStackPointer, r2 = xSecureContextHandle->pucStackLimit. */ +#if ( configENABLE_MPU == 1 ) + ldmia r1!, {r3} /* Read CONTROL register value from task's stack. r3 = CONTROL. */ + msr control, r3 /* CONTROL = r3. */ +#endif /* configENABLE_MPU */ + msr psplim, r2 /* PSPLIM = r2. */ + msr psp, r1 /* PSP = r1. */ + + load_ctx_therad_mode: + bx lr +/*-----------------------------------------------------------*/ + +SecureContext_SaveContextAsm: + /* xSecureContextHandle value is in r0. */ + mrs r1, ipsr /* r1 = IPSR. */ + cbz r1, save_ctx_therad_mode /* Do nothing if the processor is running in the Thread Mode. */ + mrs r1, psp /* r1 = PSP. */ +#if ( configENABLE_FPU == 1 ) + vstmdb r1!, {s0} /* Trigger the defferred stacking of FPU registers. */ + vldmia r1!, {s0} /* Nullify the effect of the pervious statement. */ +#endif /* configENABLE_FPU */ +#if ( configENABLE_MPU == 1 ) + mrs r2, control /* r2 = CONTROL. */ + stmdb r1!, {r2} /* Store CONTROL value on the stack. */ +#endif /* configENABLE_MPU */ + str r1, [r0] /* Save the top of stack in context. xSecureContextHandle->pucCurrentStackPointer = r1. */ + movs r1, #0 /* r1 = securecontextNO_STACK. */ + msr psplim, r1 /* PSPLIM = securecontextNO_STACK. */ + msr psp, r1 /* PSP = securecontextNO_STACK i.e. No stack for thread mode until next task's context is loaded. */ + + save_ctx_therad_mode: + bx lr +/*-----------------------------------------------------------*/ + + END diff --git a/FreeRTOS/Source/portable/ARMv8M/secure/context/secure_context.c b/FreeRTOS/Source/portable/ARMv8M/secure/context/secure_context.c new file mode 100755 index 0000000..53535cd --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/secure/context/secure_context.c @@ -0,0 +1,204 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Secure context includes. */ +#include "secure_context.h" + +/* Secure heap includes. */ +#include "secure_heap.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief CONTROL value for privileged tasks. + * + * Bit[0] - 0 --> Thread mode is privileged. + * Bit[1] - 1 --> Thread mode uses PSP. + */ +#define securecontextCONTROL_VALUE_PRIVILEGED 0x02 + +/** + * @brief CONTROL value for un-privileged tasks. + * + * Bit[0] - 1 --> Thread mode is un-privileged. + * Bit[1] - 1 --> Thread mode uses PSP. + */ +#define securecontextCONTROL_VALUE_UNPRIVILEGED 0x03 +/*-----------------------------------------------------------*/ + +/** + * @brief Structure to represent secure context. + * + * @note Since stack grows down, pucStackStart is the highest address while + * pucStackLimit is the first addess of the allocated memory. + */ +typedef struct SecureContext +{ + uint8_t *pucCurrentStackPointer; /**< Current value of stack pointer (PSP). */ + uint8_t *pucStackLimit; /**< Last location of the stack memory (PSPLIM). */ + uint8_t *pucStackStart; /**< First location of the stack memory. */ +} SecureContext_t; +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_Init( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* No stack for thread mode until a task's context is loaded. */ + secureportSET_PSPLIM( securecontextNO_STACK ); + secureportSET_PSP( securecontextNO_STACK ); + + #if( configENABLE_MPU == 1 ) + { + /* Configure thread mode to use PSP and to be unprivileged. */ + secureportSET_CONTROL( securecontextCONTROL_VALUE_UNPRIVILEGED ); + } + #else /* configENABLE_MPU */ + { + /* Configure thread mode to use PSP and to be privileged.. */ + secureportSET_CONTROL( securecontextCONTROL_VALUE_PRIVILEGED ); + } + #endif /* configENABLE_MPU */ + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + secureportNON_SECURE_CALLABLE SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize, uint32_t ulIsTaskPrivileged ) +#else /* configENABLE_MPU */ + secureportNON_SECURE_CALLABLE SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize ) +#endif /* configENABLE_MPU */ +{ + uint8_t *pucStackMemory = NULL; + uint32_t ulIPSR; + SecureContextHandle_t xSecureContextHandle = NULL; + #if( configENABLE_MPU == 1 ) + uint32_t *pulCurrentStackPointer = NULL; + #endif /* configENABLE_MPU */ + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* Allocate the context structure. */ + xSecureContextHandle = ( SecureContextHandle_t ) pvPortMalloc( sizeof( SecureContext_t ) ); + + if( xSecureContextHandle != NULL ) + { + /* Allocate the stack space. */ + pucStackMemory = pvPortMalloc( ulSecureStackSize ); + + if( pucStackMemory != NULL ) + { + /* Since stack grows down, the starting point will be the last + * location. Note that this location is next to the last + * allocated byte because the hardware decrements the stack + * pointer before writing i.e. if stack pointer is 0x2, a push + * operation will decrement the stack pointer to 0x1 and then + * write at 0x1. */ + xSecureContextHandle->pucStackStart = pucStackMemory + ulSecureStackSize; + + /* The stack cannot go beyond this location. This value is + * programmed in the PSPLIM register on context switch.*/ + xSecureContextHandle->pucStackLimit = pucStackMemory; + + #if( configENABLE_MPU == 1 ) + { + /* Store the correct CONTROL value for the task on the stack. + * This value is programmed in the CONTROL register on + * context switch. */ + pulCurrentStackPointer = ( uint32_t * ) xSecureContextHandle->pucStackStart; + pulCurrentStackPointer--; + if( ulIsTaskPrivileged ) + { + *( pulCurrentStackPointer ) = securecontextCONTROL_VALUE_PRIVILEGED; + } + else + { + *( pulCurrentStackPointer ) = securecontextCONTROL_VALUE_UNPRIVILEGED; + } + + /* Store the current stack pointer. This value is programmed in + * the PSP register on context switch. */ + xSecureContextHandle->pucCurrentStackPointer = ( uint8_t * ) pulCurrentStackPointer; + } + #else /* configENABLE_MPU */ + { + /* Current SP is set to the starting of the stack. This + * value programmed in the PSP register on context switch. */ + xSecureContextHandle->pucCurrentStackPointer = xSecureContextHandle->pucStackStart; + + } + #endif /* configENABLE_MPU */ + } + else + { + /* Free the context to avoid memory leak and make sure to return + * NULL to indicate failure. */ + vPortFree( xSecureContextHandle ); + xSecureContextHandle = NULL; + } + } + } + + return xSecureContextHandle; +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_FreeContext( SecureContextHandle_t xSecureContextHandle ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* Ensure that valid parameters are passed. */ + secureportASSERT( xSecureContextHandle != NULL ); + + /* Free the stack space. */ + vPortFree( xSecureContextHandle->pucStackLimit ); + + /* Free the context itself. */ + vPortFree( xSecureContextHandle ); + } +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/ARMv8M/secure/context/secure_context.h b/FreeRTOS/Source/portable/ARMv8M/secure/context/secure_context.h new file mode 100755 index 0000000..e148bff --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/secure/context/secure_context.h @@ -0,0 +1,111 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_CONTEXT_H__ +#define __SECURE_CONTEXT_H__ + +/* Standard includes. */ +#include + +/* FreeRTOS includes. */ +#include "FreeRTOSConfig.h" + +/** + * @brief PSP value when no task's context is loaded. + */ +#define securecontextNO_STACK 0x0 + +/** + * @brief Opaque handle. + */ +struct SecureContext; +typedef struct SecureContext* SecureContextHandle_t; +/*-----------------------------------------------------------*/ + +/** + * @brief Initializes the secure context management system. + * + * PSP is set to NULL and therefore a task must allocate and load a context + * before calling any secure side function in the thread mode. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureContext_Init( void ); + +/** + * @brief Allocates a context on the secure side. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] ulSecureStackSize Size of the stack to allocate on secure side. + * @param[in] ulIsTaskPrivileged 1 if the calling task is privileged, 0 otherwise. + * + * @return Opaque context handle if context is successfully allocated, NULL + * otherwise. + */ +#if( configENABLE_MPU == 1 ) + SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize, uint32_t ulIsTaskPrivileged ); +#else /* configENABLE_MPU */ + SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize ); +#endif /* configENABLE_MPU */ + +/** + * @brief Frees the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the + * context to be freed. + */ +void SecureContext_FreeContext( SecureContextHandle_t xSecureContextHandle ); + +/** + * @brief Loads the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the context + * to be loaded. + */ +void SecureContext_LoadContext( SecureContextHandle_t xSecureContextHandle ); + +/** + * @brief Saves the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the context + * to be saved. + */ +void SecureContext_SaveContext( SecureContextHandle_t xSecureContextHandle ); + +#endif /* __SECURE_CONTEXT_H__ */ diff --git a/FreeRTOS/Source/portable/ARMv8M/secure/heap/secure_heap.c b/FreeRTOS/Source/portable/ARMv8M/secure/heap/secure_heap.c new file mode 100755 index 0000000..60fce5c --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/secure/heap/secure_heap.c @@ -0,0 +1,450 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Secure context heap includes. */ +#include "secure_heap.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief Total heap size. + */ +#define secureconfigTOTAL_HEAP_SIZE ( ( ( size_t ) ( 10 * 1024 ) ) ) + +/* No test marker by default. */ +#ifndef mtCOVERAGE_TEST_MARKER + #define mtCOVERAGE_TEST_MARKER() +#endif + +/* No tracing by default. */ +#ifndef traceMALLOC + #define traceMALLOC( pvReturn, xWantedSize ) +#endif + +/* No tracing by default. */ +#ifndef traceFREE + #define traceFREE( pv, xBlockSize ) +#endif + +/* Block sizes must not get too small. */ +#define secureheapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) ) + +/* Assumes 8bit bytes! */ +#define secureheapBITS_PER_BYTE ( ( size_t ) 8 ) +/*-----------------------------------------------------------*/ + +/* Allocate the memory for the heap. */ +#if( configAPPLICATION_ALLOCATED_HEAP == 1 ) + /* The application writer has already defined the array used for the RTOS + * heap - probably so it can be placed in a special segment or address. */ + extern uint8_t ucHeap[ secureconfigTOTAL_HEAP_SIZE ]; +#else /* configAPPLICATION_ALLOCATED_HEAP */ + static uint8_t ucHeap[ secureconfigTOTAL_HEAP_SIZE ]; +#endif /* configAPPLICATION_ALLOCATED_HEAP */ + +/** + * @brief The linked list structure. + * + * This is used to link free blocks in order of their memory address. + */ +typedef struct A_BLOCK_LINK +{ + struct A_BLOCK_LINK *pxNextFreeBlock; /**< The next free block in the list. */ + size_t xBlockSize; /**< The size of the free block. */ +} BlockLink_t; +/*-----------------------------------------------------------*/ + +/** + * @brief Called automatically to setup the required heap structures the first + * time pvPortMalloc() is called. + */ +static void prvHeapInit( void ); + +/** + * @brief Inserts a block of memory that is being freed into the correct + * position in the list of free memory blocks. + * + * The block being freed will be merged with the block in front it and/or the + * block behind it if the memory blocks are adjacent to each other. + * + * @param[in] pxBlockToInsert The block being freed. + */ +static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ); +/*-----------------------------------------------------------*/ + +/** + * @brief The size of the structure placed at the beginning of each allocated + * memory block must by correctly byte aligned. + */ +static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( secureportBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + +/** + * @brief Create a couple of list links to mark the start and end of the list. + */ +static BlockLink_t xStart, *pxEnd = NULL; + +/** + * @brief Keeps track of the number of free bytes remaining, but says nothing + * about fragmentation. + */ +static size_t xFreeBytesRemaining = 0U; +static size_t xMinimumEverFreeBytesRemaining = 0U; + +/** + * @brief Gets set to the top bit of an size_t type. + * + * When this bit in the xBlockSize member of an BlockLink_t structure is set + * then the block belongs to the application. When the bit is free the block is + * still part of the free heap space. + */ +static size_t xBlockAllocatedBit = 0; +/*-----------------------------------------------------------*/ + +static void prvHeapInit( void ) +{ +BlockLink_t *pxFirstFreeBlock; +uint8_t *pucAlignedHeap; +size_t uxAddress; +size_t xTotalHeapSize = secureconfigTOTAL_HEAP_SIZE; + + /* Ensure the heap starts on a correctly aligned boundary. */ + uxAddress = ( size_t ) ucHeap; + + if( ( uxAddress & secureportBYTE_ALIGNMENT_MASK ) != 0 ) + { + uxAddress += ( secureportBYTE_ALIGNMENT - 1 ); + uxAddress &= ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + xTotalHeapSize -= uxAddress - ( size_t ) ucHeap; + } + + pucAlignedHeap = ( uint8_t * ) uxAddress; + + /* xStart is used to hold a pointer to the first item in the list of free + * blocks. The void cast is used to prevent compiler warnings. */ + xStart.pxNextFreeBlock = ( void * ) pucAlignedHeap; + xStart.xBlockSize = ( size_t ) 0; + + /* pxEnd is used to mark the end of the list of free blocks and is inserted + * at the end of the heap space. */ + uxAddress = ( ( size_t ) pucAlignedHeap ) + xTotalHeapSize; + uxAddress -= xHeapStructSize; + uxAddress &= ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + pxEnd = ( void * ) uxAddress; + pxEnd->xBlockSize = 0; + pxEnd->pxNextFreeBlock = NULL; + + /* To start with there is a single free block that is sized to take up the + * entire heap space, minus the space taken by pxEnd. */ + pxFirstFreeBlock = ( void * ) pucAlignedHeap; + pxFirstFreeBlock->xBlockSize = uxAddress - ( size_t ) pxFirstFreeBlock; + pxFirstFreeBlock->pxNextFreeBlock = pxEnd; + + /* Only one block exists - and it covers the entire usable heap space. */ + xMinimumEverFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; + xFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; + + /* Work out the position of the top bit in a size_t variable. */ + xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * secureheapBITS_PER_BYTE ) - 1 ); +} +/*-----------------------------------------------------------*/ + +static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ) +{ +BlockLink_t *pxIterator; +uint8_t *puc; + + /* Iterate through the list until a block is found that has a higher address + * than the block being inserted. */ + for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) + { + /* Nothing to do here, just iterate to the right position. */ + } + + /* Do the block being inserted, and the block it is being inserted after + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxIterator; + if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) + { + pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; + pxBlockToInsert = pxIterator; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Do the block being inserted, and the block it is being inserted before + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxBlockToInsert; + if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) + { + if( pxIterator->pxNextFreeBlock != pxEnd ) + { + /* Form one big block from the two blocks. */ + pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock; + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxEnd; + } + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; + } + + /* If the block being inserted plugged a gab, so was merged with the block + * before and the block after, then it's pxNextFreeBlock pointer will have + * already been set, and should not be set here as that would make it point + * to itself. */ + if( pxIterator != pxBlockToInsert ) + { + pxIterator->pxNextFreeBlock = pxBlockToInsert; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } +} +/*-----------------------------------------------------------*/ + +void *pvPortMalloc( size_t xWantedSize ) +{ +BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink; +void *pvReturn = NULL; + + /* If this is the first call to malloc then the heap will require + * initialisation to setup the list of free blocks. */ + if( pxEnd == NULL ) + { + prvHeapInit(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Check the requested block size is not so large that the top bit is set. + * The top bit of the block size member of the BlockLink_t structure is used + * to determine who owns the block - the application or the kernel, so it + * must be free. */ + if( ( xWantedSize & xBlockAllocatedBit ) == 0 ) + { + /* The wanted size is increased so it can contain a BlockLink_t + * structure in addition to the requested amount of bytes. */ + if( xWantedSize > 0 ) + { + xWantedSize += xHeapStructSize; + + /* Ensure that blocks are always aligned to the required number of + * bytes. */ + if( ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) != 0x00 ) + { + /* Byte alignment required. */ + xWantedSize += ( secureportBYTE_ALIGNMENT - ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) ); + secureportASSERT( ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) == 0 ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) + { + /* Traverse the list from the start (lowest address) block until + * one of adequate size is found. */ + pxPreviousBlock = &xStart; + pxBlock = xStart.pxNextFreeBlock; + while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) + { + pxPreviousBlock = pxBlock; + pxBlock = pxBlock->pxNextFreeBlock; + } + + /* If the end marker was reached then a block of adequate size was + * not found. */ + if( pxBlock != pxEnd ) + { + /* Return the memory space pointed to - jumping over the + * BlockLink_t structure at its start. */ + pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize ); + + /* This block is being returned for use so must be taken out + * of the list of free blocks. */ + pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; + + /* If the block is larger than required it can be split into + * two. */ + if( ( pxBlock->xBlockSize - xWantedSize ) > secureheapMINIMUM_BLOCK_SIZE ) + { + /* This block is to be split into two. Create a new + * block following the number of bytes requested. The void + * cast is used to prevent byte alignment warnings from the + * compiler. */ + pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize ); + secureportASSERT( ( ( ( size_t ) pxNewBlockLink ) & secureportBYTE_ALIGNMENT_MASK ) == 0 ); + + /* Calculate the sizes of two blocks split from the single + * block. */ + pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; + pxBlock->xBlockSize = xWantedSize; + + /* Insert the new block into the list of free blocks. */ + prvInsertBlockIntoFreeList( pxNewBlockLink ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + xFreeBytesRemaining -= pxBlock->xBlockSize; + + if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) + { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* The block is being returned - it is allocated and owned by + * the application and has no "next" block. */ + pxBlock->xBlockSize |= xBlockAllocatedBit; + pxBlock->pxNextFreeBlock = NULL; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + traceMALLOC( pvReturn, xWantedSize ); + + #if( secureconfigUSE_MALLOC_FAILED_HOOK == 1 ) + { + if( pvReturn == NULL ) + { + extern void vApplicationMallocFailedHook( void ); + vApplicationMallocFailedHook(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif + + secureportASSERT( ( ( ( size_t ) pvReturn ) & ( size_t ) secureportBYTE_ALIGNMENT_MASK ) == 0 ); + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void *pv ) +{ +uint8_t *puc = ( uint8_t * ) pv; +BlockLink_t *pxLink; + + if( pv != NULL ) + { + /* The memory being freed will have an BlockLink_t structure immediately + * before it. */ + puc -= xHeapStructSize; + + /* This casting is to keep the compiler from issuing warnings. */ + pxLink = ( void * ) puc; + + /* Check the block is actually allocated. */ + secureportASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ); + secureportASSERT( pxLink->pxNextFreeBlock == NULL ); + + if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) + { + if( pxLink->pxNextFreeBlock == NULL ) + { + /* The block is being returned to the heap - it is no longer + * allocated. */ + pxLink->xBlockSize &= ~xBlockAllocatedBit; + + secureportDISABLE_NON_SECURE_INTERRUPTS(); + { + /* Add this block to the list of free blocks. */ + xFreeBytesRemaining += pxLink->xBlockSize; + traceFREE( pv, pxLink->xBlockSize ); + prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) ); + } + secureportENABLE_NON_SECURE_INTERRUPTS(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } +} +/*-----------------------------------------------------------*/ + +size_t xPortGetFreeHeapSize( void ) +{ + return xFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +size_t xPortGetMinimumEverFreeHeapSize( void ) +{ + return xMinimumEverFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +void vPortInitialiseBlocks( void ) +{ + /* This just exists to keep the linker quiet. */ +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/NetworkInterface.h b/FreeRTOS/Source/portable/ARMv8M/secure/heap/secure_heap.h similarity index 64% rename from FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/NetworkInterface.h rename to FreeRTOS/Source/portable/ARMv8M/secure/heap/secure_heap.h index f4e1665..69e4f2a 100755 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/NetworkInterface.h +++ b/FreeRTOS/Source/portable/ARMv8M/secure/heap/secure_heap.h @@ -1,6 +1,6 @@ /* - * FreeRTOS+TCP V2.0.7 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -19,26 +19,33 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://aws.amazon.com/freertos * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! */ -#ifndef NETWORK_INTERFACE_H -#define NETWORK_INTERFACE_H +#ifndef __SECURE_HEAP_H__ +#define __SECURE_HEAP_H__ -#ifdef __cplusplus -extern "C" { -#endif +/* Standard includes. */ +#include -/* NOTE PUBLIC API FUNCTIONS. */ -BaseType_t xNetworkInterfaceInitialise( void ); -BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer, BaseType_t xReleaseAfterSend ); -void vNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkBuffers[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ] ); -BaseType_t xGetPhyLinkStatus( void ); +/** + * @brief Allocates memory from heap. + * + * @param[in] xWantedSize The size of the memory to be allocated. + * + * @return Pointer to the memory region if the allocation is successful, NULL + * otherwise. + */ +void *pvPortMalloc( size_t xWantedSize ); -#ifdef __cplusplus -} // extern "C" -#endif - -#endif /* NETWORK_INTERFACE_H */ +/** + * @brief Frees the previously allocated memory. + * + * @param[in] pv Pointer to the memory to be freed. + */ +void vPortFree( void *pv ); +#endif /* __SECURE_HEAP_H__ */ diff --git a/FreeRTOS/Source/portable/ARMv8M/secure/init/secure_init.c b/FreeRTOS/Source/portable/ARMv8M/secure/init/secure_init.c new file mode 100755 index 0000000..c6525f7 --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/secure/init/secure_init.c @@ -0,0 +1,105 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Secure init includes. */ +#include "secure_init.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief Constants required to manipulate the SCB. + */ +#define secureinitSCB_AIRCR ( ( volatile uint32_t * ) 0xe000ed0c ) /* Application Interrupt and Reset Control Register. */ +#define secureinitSCB_AIRCR_VECTKEY_POS ( 16UL ) +#define secureinitSCB_AIRCR_VECTKEY_MASK ( 0xFFFFUL << secureinitSCB_AIRCR_VECTKEY_POS ) +#define secureinitSCB_AIRCR_PRIS_POS ( 14UL ) +#define secureinitSCB_AIRCR_PRIS_MASK ( 1UL << secureinitSCB_AIRCR_PRIS_POS ) + +/** + * @brief Constants required to manipulate the FPU. + */ +#define secureinitFPCCR ( ( volatile uint32_t * ) 0xe000ef34 ) /* Floating Point Context Control Register. */ +#define secureinitFPCCR_LSPENS_POS ( 29UL ) +#define secureinitFPCCR_LSPENS_MASK ( 1UL << secureinitFPCCR_LSPENS_POS ) +#define secureinitFPCCR_TS_POS ( 26UL ) +#define secureinitFPCCR_TS_MASK ( 1UL << secureinitFPCCR_TS_POS ) + +#define secureinitNSACR ( ( volatile uint32_t * ) 0xe000ed8c ) /* Non-secure Access Control Register. */ +#define secureinitNSACR_CP10_POS ( 10UL ) +#define secureinitNSACR_CP10_MASK ( 1UL << secureinitNSACR_CP10_POS ) +#define secureinitNSACR_CP11_POS ( 11UL ) +#define secureinitNSACR_CP11_MASK ( 1UL << secureinitNSACR_CP11_POS ) +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureInit_DePrioritizeNSExceptions( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + *( secureinitSCB_AIRCR ) = ( *( secureinitSCB_AIRCR ) & ~( secureinitSCB_AIRCR_VECTKEY_MASK | secureinitSCB_AIRCR_PRIS_MASK ) ) | + ( ( 0x05FAUL << secureinitSCB_AIRCR_VECTKEY_POS ) & secureinitSCB_AIRCR_VECTKEY_MASK ) | + ( ( 0x1UL << secureinitSCB_AIRCR_PRIS_POS ) & secureinitSCB_AIRCR_PRIS_MASK ); + } +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureInit_EnableNSFPUAccess( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* CP10 = 1 ==> Non-secure access to the Floating Point Unit is + * permitted. CP11 should be programmed to the same value as CP10. */ + *( secureinitNSACR ) |= ( secureinitNSACR_CP10_MASK | secureinitNSACR_CP11_MASK ); + + /* LSPENS = 0 ==> LSPEN is writable fron non-secure state. This ensures + * that we can enable/disable lazy stacking in port.c file. */ + *( secureinitFPCCR ) &= ~ ( secureinitFPCCR_LSPENS_MASK ); + + /* TS = 1 ==> Treat FP registers as secure i.e. callee saved FP + * registers (S16-S31) are also pushed to stack on exception entry and + * restored on exception return. */ + *( secureinitFPCCR ) |= ( secureinitFPCCR_TS_MASK ); + } +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/ARMv8M/secure/init/secure_init.h b/FreeRTOS/Source/portable/ARMv8M/secure/init/secure_init.h new file mode 100755 index 0000000..6c5bc71 --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/secure/init/secure_init.h @@ -0,0 +1,53 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_INIT_H__ +#define __SECURE_INIT_H__ + +/** + * @brief De-prioritizes the non-secure exceptions. + * + * This is needed to ensure that the non-secure PendSV runs at the lowest + * priority. Context switch is done in the non-secure PendSV handler. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureInit_DePrioritizeNSExceptions( void ); + +/** + * @brief Sets up the Floating Point Unit (FPU) for Non-Secure access. + * + * Also sets FPCCR.TS=1 to ensure that the content of the Floating Point + * Registers are not leaked to the non-secure side. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureInit_EnableNSFPUAccess( void ); + +#endif /* __SECURE_INIT_H__ */ diff --git a/FreeRTOS/Source/portable/ARMv8M/secure/macros/secure_port_macros.h b/FreeRTOS/Source/portable/ARMv8M/secure/macros/secure_port_macros.h new file mode 100755 index 0000000..760edab --- /dev/null +++ b/FreeRTOS/Source/portable/ARMv8M/secure/macros/secure_port_macros.h @@ -0,0 +1,133 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_PORT_MACROS_H__ +#define __SECURE_PORT_MACROS_H__ + +/** + * @brief Byte alignment requirements. + */ +#define secureportBYTE_ALIGNMENT 8 +#define secureportBYTE_ALIGNMENT_MASK ( 0x0007 ) + +/** + * @brief Macro to declare a function as non-secure callable. + */ +#if defined( __IAR_SYSTEMS_ICC__ ) + #define secureportNON_SECURE_CALLABLE __cmse_nonsecure_entry __root +#else + #define secureportNON_SECURE_CALLABLE __attribute__((cmse_nonsecure_entry)) __attribute__((used)) +#endif + +/** + * @brief Set the secure PRIMASK value. + */ +#define secureportSET_SECURE_PRIMASK( ulPrimaskValue ) \ + __asm volatile ( "msr primask, %0" : : "r" ( ulPrimaskValue ) : "memory" ) + +/** + * @brief Set the non-secure PRIMASK value. + */ +#define secureportSET_NON_SECURE_PRIMASK( ulPrimaskValue ) \ + __asm volatile ( "msr primask_ns, %0" : : "r" ( ulPrimaskValue ) : "memory" ) + +/** + * @brief Read the PSP value in the given variable. + */ +#define secureportREAD_PSP( pucOutCurrentStackPointer ) \ + __asm volatile ( "mrs %0, psp" : "=r" ( pucOutCurrentStackPointer ) ) + +/** + * @brief Set the PSP to the given value. + */ +#define secureportSET_PSP( pucCurrentStackPointer ) \ + __asm volatile ( "msr psp, %0" : : "r" ( pucCurrentStackPointer ) ) + +/** + * @brief Set the PSPLIM to the given value. + */ +#define secureportSET_PSPLIM( pucStackLimit ) \ + __asm volatile ( "msr psplim, %0" : : "r" ( pucStackLimit ) ) + +/** + * @brief Set the NonSecure MSP to the given value. + */ +#define secureportSET_MSP_NS( pucMainStackPointer ) \ + __asm volatile ( "msr msp_ns, %0" : : "r" ( pucMainStackPointer ) ) + +/** + * @brief Set the CONTROL register to the given value. + */ +#define secureportSET_CONTROL( ulControl ) \ + __asm volatile ( "msr control, %0" : : "r" ( ulControl ) : "memory" ) + +/** + * @brief Read the Interrupt Program Status Register (IPSR) value in the given + * variable. + */ +#define secureportREAD_IPSR( ulIPSR ) \ + __asm volatile ( "mrs %0, ipsr" : "=r" ( ulIPSR ) ) + +/** + * @brief PRIMASK value to enable interrupts. + */ +#define secureportPRIMASK_ENABLE_INTERRUPTS_VAL 0 + +/** + * @brief PRIMASK value to disable interrupts. + */ +#define secureportPRIMASK_DISABLE_INTERRUPTS_VAL 1 + +/** + * @brief Disable secure interrupts. + */ +#define secureportDISABLE_SECURE_INTERRUPTS() secureportSET_SECURE_PRIMASK( secureportPRIMASK_DISABLE_INTERRUPTS_VAL ) + +/** + * @brief Disable non-secure interrupts. + * + * This effectively disables context switches. + */ +#define secureportDISABLE_NON_SECURE_INTERRUPTS() secureportSET_NON_SECURE_PRIMASK( secureportPRIMASK_DISABLE_INTERRUPTS_VAL ) + +/** + * @brief Enable non-secure interrupts. + */ +#define secureportENABLE_NON_SECURE_INTERRUPTS() secureportSET_NON_SECURE_PRIMASK( secureportPRIMASK_ENABLE_INTERRUPTS_VAL ) + +/** + * @brief Assert definition. + */ +#define secureportASSERT( x ) \ + if( ( x ) == 0 ) \ + { \ + secureportDISABLE_SECURE_INTERRUPTS(); \ + secureportDISABLE_NON_SECURE_INTERRUPTS(); \ + for( ;; ); \ + } + +#endif /* __SECURE_PORT_MACROS_H__ */ diff --git a/FreeRTOS/Source/portable/BCC/16BitDOS/Flsh186/port.c b/FreeRTOS/Source/portable/BCC/16BitDOS/Flsh186/port.c index 06a0c3e..9d43e12 100755 --- a/FreeRTOS/Source/portable/BCC/16BitDOS/Flsh186/port.c +++ b/FreeRTOS/Source/portable/BCC/16BitDOS/Flsh186/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/BCC/16BitDOS/Flsh186/prtmacro.h b/FreeRTOS/Source/portable/BCC/16BitDOS/Flsh186/prtmacro.h index 5459ede..e5ad60e 100755 --- a/FreeRTOS/Source/portable/BCC/16BitDOS/Flsh186/prtmacro.h +++ b/FreeRTOS/Source/portable/BCC/16BitDOS/Flsh186/prtmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/BCC/16BitDOS/PC/port.c b/FreeRTOS/Source/portable/BCC/16BitDOS/PC/port.c index bd20a13..bab75b1 100755 --- a/FreeRTOS/Source/portable/BCC/16BitDOS/PC/port.c +++ b/FreeRTOS/Source/portable/BCC/16BitDOS/PC/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/BCC/16BitDOS/PC/prtmacro.h b/FreeRTOS/Source/portable/BCC/16BitDOS/PC/prtmacro.h index 20e926f..678458f 100755 --- a/FreeRTOS/Source/portable/BCC/16BitDOS/PC/prtmacro.h +++ b/FreeRTOS/Source/portable/BCC/16BitDOS/PC/prtmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/BCC/16BitDOS/common/portasm.h b/FreeRTOS/Source/portable/BCC/16BitDOS/common/portasm.h index b0bcdab..c9251ca 100755 --- a/FreeRTOS/Source/portable/BCC/16BitDOS/common/portasm.h +++ b/FreeRTOS/Source/portable/BCC/16BitDOS/common/portasm.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/BCC/16BitDOS/common/portcomn.c b/FreeRTOS/Source/portable/BCC/16BitDOS/common/portcomn.c index b64269d..c45fe05 100755 --- a/FreeRTOS/Source/portable/BCC/16BitDOS/common/portcomn.c +++ b/FreeRTOS/Source/portable/BCC/16BitDOS/common/portcomn.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CCS/ARM_CM3/port.c b/FreeRTOS/Source/portable/CCS/ARM_CM3/port.c index 1a7a006..784b0eb 100755 --- a/FreeRTOS/Source/portable/CCS/ARM_CM3/port.c +++ b/FreeRTOS/Source/portable/CCS/ARM_CM3/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CCS/ARM_CM3/portasm.asm b/FreeRTOS/Source/portable/CCS/ARM_CM3/portasm.asm index 30a2a5f..6d04fc3 100755 --- a/FreeRTOS/Source/portable/CCS/ARM_CM3/portasm.asm +++ b/FreeRTOS/Source/portable/CCS/ARM_CM3/portasm.asm @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CCS/ARM_CM3/portmacro.h b/FreeRTOS/Source/portable/CCS/ARM_CM3/portmacro.h index 4f42973..7d267c3 100755 --- a/FreeRTOS/Source/portable/CCS/ARM_CM3/portmacro.h +++ b/FreeRTOS/Source/portable/CCS/ARM_CM3/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CCS/ARM_CM4F/port.c b/FreeRTOS/Source/portable/CCS/ARM_CM4F/port.c index f55298e..3824b56 100755 --- a/FreeRTOS/Source/portable/CCS/ARM_CM4F/port.c +++ b/FreeRTOS/Source/portable/CCS/ARM_CM4F/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CCS/ARM_CM4F/portasm.asm b/FreeRTOS/Source/portable/CCS/ARM_CM4F/portasm.asm index a7cedde..a2251b7 100755 --- a/FreeRTOS/Source/portable/CCS/ARM_CM4F/portasm.asm +++ b/FreeRTOS/Source/portable/CCS/ARM_CM4F/portasm.asm @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CCS/ARM_CM4F/portmacro.h b/FreeRTOS/Source/portable/CCS/ARM_CM4F/portmacro.h index 41d4a0d..81f7897 100755 --- a/FreeRTOS/Source/portable/CCS/ARM_CM4F/portmacro.h +++ b/FreeRTOS/Source/portable/CCS/ARM_CM4F/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/port.c b/FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/port.c index 0048d94..c01fac2 100755 --- a/FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/port.c +++ b/FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/portASM.asm b/FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/portASM.asm index 854a1ba..cec6166 100755 --- a/FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/portASM.asm +++ b/FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/portASM.asm @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/portmacro.h b/FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/portmacro.h index 0e5858a..414cc23 100755 --- a/FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/portmacro.h +++ b/FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CCS/MSP430X/data_model.h b/FreeRTOS/Source/portable/CCS/MSP430X/data_model.h index 65eafc9..c777098 100755 --- a/FreeRTOS/Source/portable/CCS/MSP430X/data_model.h +++ b/FreeRTOS/Source/portable/CCS/MSP430X/data_model.h @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CCS/MSP430X/port.c b/FreeRTOS/Source/portable/CCS/MSP430X/port.c index 97024b7..2952a59 100755 --- a/FreeRTOS/Source/portable/CCS/MSP430X/port.c +++ b/FreeRTOS/Source/portable/CCS/MSP430X/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CCS/MSP430X/portext.asm b/FreeRTOS/Source/portable/CCS/MSP430X/portext.asm index 305178c..ca3b4de 100755 --- a/FreeRTOS/Source/portable/CCS/MSP430X/portext.asm +++ b/FreeRTOS/Source/portable/CCS/MSP430X/portext.asm @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CCS/MSP430X/portmacro.h b/FreeRTOS/Source/portable/CCS/MSP430X/portmacro.h index 9402b1d..a5f5f7d 100755 --- a/FreeRTOS/Source/portable/CCS/MSP430X/portmacro.h +++ b/FreeRTOS/Source/portable/CCS/MSP430X/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V1/port.c b/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V1/port.c index c3c91fd..565669e 100755 --- a/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V1/port.c +++ b/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V1/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V1/portasm.S b/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V1/portasm.S index f6ed081..eaeba54 100755 --- a/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V1/portasm.S +++ b/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V1/portasm.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V1/portmacro.h b/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V1/portmacro.h index 28c60f5..2c557f3 100755 --- a/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V1/portmacro.h +++ b/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V1/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V2/port.c b/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V2/port.c index dfbb0d8..0681eb3 100755 --- a/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V2/port.c +++ b/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V2/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V2/portasm.S b/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V2/portasm.S index 232ee95..55627c6 100755 --- a/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V2/portasm.S +++ b/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V2/portasm.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V2/portmacro.h b/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V2/portmacro.h index 7474091..9dc4bb8 100755 --- a/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V2/portmacro.h +++ b/FreeRTOS/Source/portable/CodeWarrior/ColdFire_V2/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CodeWarrior/HCS12/port.c b/FreeRTOS/Source/portable/CodeWarrior/HCS12/port.c index 8c8df94..eafd5a0 100755 --- a/FreeRTOS/Source/portable/CodeWarrior/HCS12/port.c +++ b/FreeRTOS/Source/portable/CodeWarrior/HCS12/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/CodeWarrior/HCS12/portmacro.h b/FreeRTOS/Source/portable/CodeWarrior/HCS12/portmacro.h index f828a76..b8832f3 100755 --- a/FreeRTOS/Source/portable/CodeWarrior/HCS12/portmacro.h +++ b/FreeRTOS/Source/portable/CodeWarrior/HCS12/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Common/mpu_wrappers.c b/FreeRTOS/Source/portable/Common/mpu_wrappers.c index 617ba3c..8b3ff27 100755 --- a/FreeRTOS/Source/portable/Common/mpu_wrappers.c +++ b/FreeRTOS/Source/portable/Common/mpu_wrappers.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -46,17 +46,48 @@ task.h is included from an application file. */ #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE -/* - * Checks to see if being called from the context of an unprivileged task, and - * if so raises the privilege level and returns false - otherwise does nothing - * other than return true. +/** + * @brief Calls the port specific code to raise the privilege. + * + * @return pdFALSE if privilege was raised, pdTRUE otherwise. */ -extern BaseType_t xPortRaisePrivilege( void ); +BaseType_t xPortRaisePrivilege( void ) FREERTOS_SYSTEM_CALL; +/** + * @brief If xRunningPrivileged is not pdTRUE, calls the port specific + * code to reset the privilege, otherwise does nothing. + */ +void vPortResetPrivilege( BaseType_t xRunningPrivileged ); +/*-----------------------------------------------------------*/ + +BaseType_t xPortRaisePrivilege( void ) /* FREERTOS_SYSTEM_CALL */ +{ +BaseType_t xRunningPrivileged; + + /* Check whether the processor is already privileged. */ + xRunningPrivileged = portIS_PRIVILEGED(); + + /* If the processor is not already privileged, raise privilege. */ + if( xRunningPrivileged != pdTRUE ) + { + portRAISE_PRIVILEGE(); + } + + return xRunningPrivileged; +} +/*-----------------------------------------------------------*/ + +void vPortResetPrivilege( BaseType_t xRunningPrivileged ) +{ + if( xRunningPrivileged != pdTRUE ) + { + portRESET_PRIVILEGE(); + } +} /*-----------------------------------------------------------*/ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) + BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -69,7 +100,7 @@ extern BaseType_t xPortRaisePrivilege( void ); /*-----------------------------------------------------------*/ #if( configSUPPORT_STATIC_ALLOCATION == 1 ) - BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) + BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -82,7 +113,7 @@ extern BaseType_t xPortRaisePrivilege( void ); /*-----------------------------------------------------------*/ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - BaseType_t MPU_xTaskCreate( TaskFunction_t pvTaskCode, const char * const pcName, uint16_t usStackDepth, void *pvParameters, UBaseType_t uxPriority, TaskHandle_t *pxCreatedTask ) + BaseType_t MPU_xTaskCreate( TaskFunction_t pvTaskCode, const char * const pcName, uint16_t usStackDepth, void *pvParameters, UBaseType_t uxPriority, TaskHandle_t *pxCreatedTask ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -95,7 +126,7 @@ extern BaseType_t xPortRaisePrivilege( void ); /*-----------------------------------------------------------*/ #if( configSUPPORT_STATIC_ALLOCATION == 1 ) - TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode, const char * const pcName, const uint32_t ulStackDepth, void * const pvParameters, UBaseType_t uxPriority, StackType_t * const puxStackBuffer, StaticTask_t * const pxTaskBuffer ) + TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode, const char * const pcName, const uint32_t ulStackDepth, void * const pvParameters, UBaseType_t uxPriority, StackType_t * const puxStackBuffer, StaticTask_t * const pxTaskBuffer ) /* FREERTOS_SYSTEM_CALL */ { TaskHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -107,7 +138,7 @@ extern BaseType_t xPortRaisePrivilege( void ); #endif /* configSUPPORT_STATIC_ALLOCATION */ /*-----------------------------------------------------------*/ -void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const xRegions ) +void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const xRegions ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -117,7 +148,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_vTaskDelete == 1 ) - void MPU_vTaskDelete( TaskHandle_t pxTaskToDelete ) + void MPU_vTaskDelete( TaskHandle_t pxTaskToDelete ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -128,7 +159,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_vTaskDelayUntil == 1 ) - void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, TickType_t xTimeIncrement ) + void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, TickType_t xTimeIncrement ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -139,7 +170,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_xTaskAbortDelay == 1 ) - BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) + BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -152,7 +183,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_vTaskDelay == 1 ) - void MPU_vTaskDelay( TickType_t xTicksToDelay ) + void MPU_vTaskDelay( TickType_t xTicksToDelay ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -163,7 +194,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_uxTaskPriorityGet == 1 ) - UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t pxTask ) + UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t pxTask ) /* FREERTOS_SYSTEM_CALL */ { UBaseType_t uxReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -176,7 +207,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_vTaskPrioritySet == 1 ) - void MPU_vTaskPrioritySet( TaskHandle_t pxTask, UBaseType_t uxNewPriority ) + void MPU_vTaskPrioritySet( TaskHandle_t pxTask, UBaseType_t uxNewPriority ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -187,7 +218,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_eTaskGetState == 1 ) - eTaskState MPU_eTaskGetState( TaskHandle_t pxTask ) + eTaskState MPU_eTaskGetState( TaskHandle_t pxTask ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); eTaskState eReturn; @@ -200,7 +231,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configUSE_TRACE_FACILITY == 1 ) - void MPU_vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) + void MPU_vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -211,7 +242,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) - TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) + TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */ { TaskHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -224,7 +255,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_vTaskSuspend == 1 ) - void MPU_vTaskSuspend( TaskHandle_t pxTaskToSuspend ) + void MPU_vTaskSuspend( TaskHandle_t pxTaskToSuspend ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -235,7 +266,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_vTaskSuspend == 1 ) - void MPU_vTaskResume( TaskHandle_t pxTaskToResume ) + void MPU_vTaskResume( TaskHandle_t pxTaskToResume ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -245,7 +276,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); #endif /*-----------------------------------------------------------*/ -void MPU_vTaskSuspendAll( void ) +void MPU_vTaskSuspendAll( void ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -254,7 +285,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -BaseType_t MPU_xTaskResumeAll( void ) +BaseType_t MPU_xTaskResumeAll( void ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -265,7 +296,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -TickType_t MPU_xTaskGetTickCount( void ) +TickType_t MPU_xTaskGetTickCount( void ) /* FREERTOS_SYSTEM_CALL */ { TickType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -276,7 +307,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) +UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) /* FREERTOS_SYSTEM_CALL */ { UBaseType_t uxReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -287,7 +318,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) +char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) /* FREERTOS_SYSTEM_CALL */ { char *pcReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -299,7 +330,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_xTaskGetHandle == 1 ) - TaskHandle_t MPU_xTaskGetHandle( const char *pcNameToQuery ) + TaskHandle_t MPU_xTaskGetHandle( const char *pcNameToQuery ) /* FREERTOS_SYSTEM_CALL */ { TaskHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -312,7 +343,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) - void MPU_vTaskList( char *pcWriteBuffer ) + void MPU_vTaskList( char *pcWriteBuffer ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -323,7 +354,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) - void MPU_vTaskGetRunTimeStats( char *pcWriteBuffer ) + void MPU_vTaskGetRunTimeStats( char *pcWriteBuffer ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -333,8 +364,21 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); #endif /*-----------------------------------------------------------*/ +#if( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) + TickType_t MPU_xTaskGetIdleRunTimeCounter( void ) /* FREERTOS_SYSTEM_CALL */ + { + TickType_t xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = xTaskGetIdleRunTimeCounter(); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + #if ( configUSE_APPLICATION_TASK_TAG == 1 ) - void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxTagValue ) + void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxTagValue ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -345,7 +389,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( configUSE_APPLICATION_TASK_TAG == 1 ) - TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ) + TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */ { TaskHookFunction_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -357,21 +401,8 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); #endif /*-----------------------------------------------------------*/ -#if ( configUSE_APPLICATION_TASK_TAG == 1 ) - TaskHookFunction_t MPU_xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) - { - TaskHookFunction_t xReturn; - BaseType_t xRunningPrivileged = xPortRaisePrivilege(); - - xReturn = xTaskGetApplicationTaskTagFromISR( xTask ); - vPortResetPrivilege( xRunningPrivileged ); - return xReturn; - } -#endif -/*-----------------------------------------------------------*/ - #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) - void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) + void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -382,7 +413,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) - void *MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) + void *MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) /* FREERTOS_SYSTEM_CALL */ { void *pvReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -395,7 +426,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( configUSE_APPLICATION_TASK_TAG == 1 ) - BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) + BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -408,7 +439,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t *pxTaskStatusArray, UBaseType_t uxArraySize, uint32_t *pulTotalRunTime ) + UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t *pxTaskStatusArray, UBaseType_t uxArraySize, uint32_t *pulTotalRunTime ) /* FREERTOS_SYSTEM_CALL */ { UBaseType_t uxReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -421,7 +452,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) - UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) + UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */ { UBaseType_t uxReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -434,7 +465,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) - configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) + configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */ { configSTACK_DEPTH_TYPE uxReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -447,7 +478,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) - TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) + TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */ { TaskHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -460,7 +491,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if ( INCLUDE_xTaskGetSchedulerState == 1 ) - BaseType_t MPU_xTaskGetSchedulerState( void ) + BaseType_t MPU_xTaskGetSchedulerState( void ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -472,7 +503,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); #endif /*-----------------------------------------------------------*/ -void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) +void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -481,7 +512,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) +BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -493,7 +524,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configUSE_TASK_NOTIFICATIONS == 1 ) - BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) + BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -506,7 +537,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configUSE_TASK_NOTIFICATIONS == 1 ) - BaseType_t MPU_xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) + BaseType_t MPU_xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -519,7 +550,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configUSE_TASK_NOTIFICATIONS == 1 ) - uint32_t MPU_ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) + uint32_t MPU_ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ { uint32_t ulReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -532,7 +563,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configUSE_TASK_NOTIFICATIONS == 1 ) - BaseType_t MPU_xTaskNotifyStateClear( TaskHandle_t xTask ) + BaseType_t MPU_xTaskNotifyStateClear( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -545,7 +576,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - QueueHandle_t MPU_xQueueGenericCreate( UBaseType_t uxQueueLength, UBaseType_t uxItemSize, uint8_t ucQueueType ) + QueueHandle_t MPU_xQueueGenericCreate( UBaseType_t uxQueueLength, UBaseType_t uxItemSize, uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */ { QueueHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -558,7 +589,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configSUPPORT_STATIC_ALLOCATION == 1 ) - QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ) + QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */ { QueueHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -570,7 +601,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); #endif /*-----------------------------------------------------------*/ -BaseType_t MPU_xQueueGenericReset( QueueHandle_t pxQueue, BaseType_t xNewQueue ) +BaseType_t MPU_xQueueGenericReset( QueueHandle_t pxQueue, BaseType_t xNewQueue ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -581,7 +612,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, BaseType_t xCopyPosition ) +BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, BaseType_t xCopyPosition ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -592,7 +623,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t pxQueue ) +UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t pxQueue ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); UBaseType_t uxReturn; @@ -603,7 +634,7 @@ UBaseType_t uxReturn; } /*-----------------------------------------------------------*/ -UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) +UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); UBaseType_t uxReturn; @@ -614,7 +645,7 @@ UBaseType_t uxReturn; } /*-----------------------------------------------------------*/ -BaseType_t MPU_xQueueReceive( QueueHandle_t pxQueue, void * const pvBuffer, TickType_t xTicksToWait ) +BaseType_t MPU_xQueueReceive( QueueHandle_t pxQueue, void * const pvBuffer, TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); BaseType_t xReturn; @@ -625,7 +656,7 @@ BaseType_t xReturn; } /*-----------------------------------------------------------*/ -BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) +BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); BaseType_t xReturn; @@ -636,7 +667,7 @@ BaseType_t xReturn; } /*-----------------------------------------------------------*/ -BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ) +BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); BaseType_t xReturn; @@ -647,30 +678,21 @@ BaseType_t xReturn; } /*-----------------------------------------------------------*/ -BaseType_t MPU_xQueuePeekFromISR( QueueHandle_t pxQueue, void * const pvBuffer ) -{ -BaseType_t xRunningPrivileged = xPortRaisePrivilege(); -BaseType_t xReturn; +#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) + TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) /* FREERTOS_SYSTEM_CALL */ + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + void * xReturn; - xReturn = xQueuePeekFromISR( pxQueue, pvBuffer ); - vPortResetPrivilege( xRunningPrivileged ); - return xReturn; -} -/*-----------------------------------------------------------*/ - -TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) -{ -BaseType_t xRunningPrivileged = xPortRaisePrivilege(); -void * xReturn; - - xReturn = xQueueGetMutexHolder( xSemaphore ); - vPortResetPrivilege( xRunningPrivileged ); - return xReturn; -} + xReturn = xQueueGetMutexHolder( xSemaphore ); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif /*-----------------------------------------------------------*/ #if( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) - QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) + QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */ { QueueHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -683,7 +705,7 @@ void * xReturn; /*-----------------------------------------------------------*/ #if( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) - QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ) + QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ) /* FREERTOS_SYSTEM_CALL */ { QueueHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -696,7 +718,7 @@ void * xReturn; /*-----------------------------------------------------------*/ #if( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) - QueueHandle_t MPU_xQueueCreateCountingSemaphore( UBaseType_t uxCountValue, UBaseType_t uxInitialCount ) + QueueHandle_t MPU_xQueueCreateCountingSemaphore( UBaseType_t uxCountValue, UBaseType_t uxInitialCount ) /* FREERTOS_SYSTEM_CALL */ { QueueHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -710,7 +732,7 @@ void * xReturn; #if( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) - QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) + QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) /* FREERTOS_SYSTEM_CALL */ { QueueHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -723,7 +745,7 @@ void * xReturn; /*-----------------------------------------------------------*/ #if ( configUSE_RECURSIVE_MUTEXES == 1 ) - BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xBlockTime ) + BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xBlockTime ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -736,7 +758,7 @@ void * xReturn; /*-----------------------------------------------------------*/ #if ( configUSE_RECURSIVE_MUTEXES == 1 ) - BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t xMutex ) + BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t xMutex ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -749,7 +771,7 @@ void * xReturn; /*-----------------------------------------------------------*/ #if( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) - QueueSetHandle_t MPU_xQueueCreateSet( UBaseType_t uxEventQueueLength ) + QueueSetHandle_t MPU_xQueueCreateSet( UBaseType_t uxEventQueueLength ) /* FREERTOS_SYSTEM_CALL */ { QueueSetHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -762,7 +784,7 @@ void * xReturn; /*-----------------------------------------------------------*/ #if ( configUSE_QUEUE_SETS == 1 ) - QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, TickType_t xBlockTimeTicks ) + QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, TickType_t xBlockTimeTicks ) /* FREERTOS_SYSTEM_CALL */ { QueueSetMemberHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -775,7 +797,7 @@ void * xReturn; /*-----------------------------------------------------------*/ #if ( configUSE_QUEUE_SETS == 1 ) - BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) + BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -788,7 +810,7 @@ void * xReturn; /*-----------------------------------------------------------*/ #if ( configUSE_QUEUE_SETS == 1 ) - BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) + BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -801,7 +823,7 @@ void * xReturn; /*-----------------------------------------------------------*/ #if configQUEUE_REGISTRY_SIZE > 0 - void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ) + void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -813,7 +835,7 @@ void * xReturn; /*-----------------------------------------------------------*/ #if configQUEUE_REGISTRY_SIZE > 0 - void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ) + void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -825,7 +847,7 @@ void * xReturn; /*-----------------------------------------------------------*/ #if configQUEUE_REGISTRY_SIZE > 0 - const char *MPU_pcQueueGetName( QueueHandle_t xQueue ) + const char *MPU_pcQueueGetName( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); const char *pcReturn; @@ -838,7 +860,7 @@ void * xReturn; #endif /*-----------------------------------------------------------*/ -void MPU_vQueueDelete( QueueHandle_t xQueue ) +void MPU_vQueueDelete( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -849,7 +871,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - void *MPU_pvPortMalloc( size_t xSize ) + void *MPU_pvPortMalloc( size_t xSize ) /* FREERTOS_SYSTEM_CALL */ { void *pvReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -864,7 +886,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - void MPU_vPortFree( void *pv ) + void MPU_vPortFree( void *pv ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -876,7 +898,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - void MPU_vPortInitialiseBlocks( void ) + void MPU_vPortInitialiseBlocks( void ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -888,7 +910,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - size_t MPU_xPortGetFreeHeapSize( void ) + size_t MPU_xPortGetFreeHeapSize( void ) /* FREERTOS_SYSTEM_CALL */ { size_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -903,7 +925,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) ) - TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) + TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) /* FREERTOS_SYSTEM_CALL */ { TimerHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -917,7 +939,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) ) - TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxTimerBuffer ) + TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxTimerBuffer ) /* FREERTOS_SYSTEM_CALL */ { TimerHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -931,7 +953,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configUSE_TIMERS == 1 ) - void *MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ) + void *MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */ { void * pvReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -945,7 +967,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configUSE_TIMERS == 1 ) - void MPU_vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) + void MPU_vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -956,7 +978,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configUSE_TIMERS == 1 ) - BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ) + BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -970,7 +992,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configUSE_TIMERS == 1 ) - TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ) + TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */ { TaskHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -984,7 +1006,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) - BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) + BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -998,7 +1020,18 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configUSE_TIMERS == 1 ) - const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) + void MPU_vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) /* FREERTOS_SYSTEM_CALL */ + { + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + vTimerSetReloadMode( xTimer, uxAutoReload ); + vPortResetPrivilege( xRunningPrivileged ); + } +#endif +/*-----------------------------------------------------------*/ + +#if( configUSE_TIMERS == 1 ) + const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */ { const char * pcReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1012,7 +1045,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configUSE_TIMERS == 1 ) - TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) + TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */ { TickType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1026,7 +1059,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configUSE_TIMERS == 1 ) - TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ) + TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */ { TickType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1040,7 +1073,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configUSE_TIMERS == 1 ) - BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) + BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1054,7 +1087,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - EventGroupHandle_t MPU_xEventGroupCreate( void ) + EventGroupHandle_t MPU_xEventGroupCreate( void ) /* FREERTOS_SYSTEM_CALL */ { EventGroupHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1068,7 +1101,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configSUPPORT_STATIC_ALLOCATION == 1 ) - EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer ) + EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer ) /* FREERTOS_SYSTEM_CALL */ { EventGroupHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1081,7 +1114,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); #endif /*-----------------------------------------------------------*/ -EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ) +EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ { EventBits_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1093,7 +1126,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) +EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) /* FREERTOS_SYSTEM_CALL */ { EventBits_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1105,7 +1138,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) +EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) /* FREERTOS_SYSTEM_CALL */ { EventBits_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1117,7 +1150,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) +EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ { EventBits_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1129,7 +1162,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) +void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1138,7 +1171,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait ) +size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ { size_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1150,19 +1183,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -size_t MPU_xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, BaseType_t * const pxHigherPriorityTaskWoken ) -{ -size_t xReturn; -BaseType_t xRunningPrivileged = xPortRaisePrivilege(); - - xReturn = xStreamBufferSendFromISR( xStreamBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ); - vPortResetPrivilege( xRunningPrivileged ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) +size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ { size_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1174,7 +1195,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait ) +size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ { size_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1186,19 +1207,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -size_t MPU_xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, BaseType_t * const pxHigherPriorityTaskWoken ) -{ -size_t xReturn; -BaseType_t xRunningPrivileged = xPortRaisePrivilege(); - - xReturn = xStreamBufferReceiveFromISR( xStreamBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ); - vPortResetPrivilege( xRunningPrivileged ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) +void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1207,7 +1216,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) +BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1219,7 +1228,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) +BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1231,7 +1240,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) +BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1243,7 +1252,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) +size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ { size_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1255,7 +1264,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) +size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ { size_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1267,7 +1276,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); } /*-----------------------------------------------------------*/ -BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ) +BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ) /* FREERTOS_SYSTEM_CALL */ { BaseType_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1280,7 +1289,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer ) + StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer ) /* FREERTOS_SYSTEM_CALL */ { StreamBufferHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); @@ -1294,7 +1303,7 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); /*-----------------------------------------------------------*/ #if( configSUPPORT_STATIC_ALLOCATION == 1 ) - StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer, uint8_t * const pucStreamBufferStorageArea, StaticStreamBuffer_t * const pxStaticStreamBuffer ) + StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer, uint8_t * const pucStreamBufferStorageArea, StaticStreamBuffer_t * const pxStaticStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ { StreamBufferHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/IAR/pack_struct_end.h b/FreeRTOS/Source/portable/Compiler/Arch/port.c similarity index 58% rename from FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/IAR/pack_struct_end.h rename to FreeRTOS/Source/portable/Compiler/Arch/port.c index 72f0b73..7320ba4 100755 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/IAR/pack_struct_end.h +++ b/FreeRTOS/Source/portable/Compiler/Arch/port.c @@ -1,6 +1,6 @@ /* -FreeRTOS+TCP V2.0.7 -Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +FreeRTOS Kernel V10.2.1 +Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -23,25 +23,37 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. http://www.FreeRTOS.org */ -/***************************************************************************** - * - * See the following URL for an explanation of this file: - * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Compiler_Porting.html - * - *****************************************************************************/ - -; - - - - - - - - - +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" +/* + * See header file for description. + */ +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) +{ + ( void ) pxTopOfStack; + ( void ) pxCode; + ( void ) pvParameters; + /* FIX ME. */ + return ( StackType_t * ) NULL; +} +/*-----------------------------------------------------------*/ +/* + * See header file for description. + */ +BaseType_t xPortStartScheduler( void ) +{ + /* FIX ME. */ + return pdFAIL; +} +/*-----------------------------------------------------------*/ +void vPortEndScheduler( void ) +{ + /* Do not implement. */ +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/Compiler/Arch/portmacro.h b/FreeRTOS/Source/portable/Compiler/Arch/portmacro.h new file mode 100755 index 0000000..3c8b1e3 --- /dev/null +++ b/FreeRTOS/Source/portable/Compiler/Arch/portmacro.h @@ -0,0 +1,106 @@ +/* +FreeRTOS Kernel V10.2.1 +Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + http://aws.amazon.com/freertos + http://www.FreeRTOS.org +*/ + + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Type definitions. */ +#define portSTACK_TYPE uint32_t +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/* Architecture specifics. */ +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 /* FIX ME. */ +/*-----------------------------------------------------------*/ + +/* Scheduler utilities. */ +#define portYIELD() 0 /* FIX ME. */ +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) portYIELD() +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/* Architecture specific optimisations. */ +#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +#endif + +#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 + + /* Store/clear the ready priorities in a bit map. */ + #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) 0 /* FIX ME. */ + #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) 0 /* FIX ME. */ + + /*-----------------------------------------------------------*/ + + #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = 0 /* FIX ME. */ + +#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ +/*-----------------------------------------------------------*/ + +/* Critical section management. */ +#define portSET_INTERRUPT_MASK_FROM_ISR() 0 /* FIX ME. */ +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) 0 /* FIX ME. */ +#define portDISABLE_INTERRUPTS() 0 /* FIX ME. */ +#define portENABLE_INTERRUPTS() 0 /* FIX ME. */ +#define portENTER_CRITICAL() 0 /* FIX ME. */ +#define portEXIT_CRITICAL() 0 /* FIX ME. */ + +/*-----------------------------------------------------------*/ + +/* Task function macros as described on the FreeRTOS.org WEB site. These are +not necessary for to use this port. They are defined so the common demo files +(which build with all the ports) will build. */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ + diff --git a/FreeRTOS/Source/portable/GCC/ARM7_AT91FR40008/port.c b/FreeRTOS/Source/portable/GCC/ARM7_AT91FR40008/port.c index fa4627e..17e74b2 100755 --- a/FreeRTOS/Source/portable/GCC/ARM7_AT91FR40008/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM7_AT91FR40008/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM7_AT91FR40008/portISR.c b/FreeRTOS/Source/portable/GCC/ARM7_AT91FR40008/portISR.c index 0e5fc62..960d9ea 100755 --- a/FreeRTOS/Source/portable/GCC/ARM7_AT91FR40008/portISR.c +++ b/FreeRTOS/Source/portable/GCC/ARM7_AT91FR40008/portISR.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM7_AT91FR40008/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM7_AT91FR40008/portmacro.h index a43efd8..fb11822 100755 --- a/FreeRTOS/Source/portable/GCC/ARM7_AT91FR40008/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ARM7_AT91FR40008/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM7_AT91SAM7S/port.c b/FreeRTOS/Source/portable/GCC/ARM7_AT91SAM7S/port.c index c320328..df7ac2b 100755 --- a/FreeRTOS/Source/portable/GCC/ARM7_AT91SAM7S/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM7_AT91SAM7S/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM7_AT91SAM7S/portISR.c b/FreeRTOS/Source/portable/GCC/ARM7_AT91SAM7S/portISR.c index a8fff6f..e2f0f67 100755 --- a/FreeRTOS/Source/portable/GCC/ARM7_AT91SAM7S/portISR.c +++ b/FreeRTOS/Source/portable/GCC/ARM7_AT91SAM7S/portISR.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h index 6b6a2fe..de8e5d4 100755 --- a/FreeRTOS/Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM7_LPC2000/port.c b/FreeRTOS/Source/portable/GCC/ARM7_LPC2000/port.c index 7a3851f..713df07 100755 --- a/FreeRTOS/Source/portable/GCC/ARM7_LPC2000/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM7_LPC2000/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM7_LPC2000/portISR.c b/FreeRTOS/Source/portable/GCC/ARM7_LPC2000/portISR.c index 95192ab..9912644 100755 --- a/FreeRTOS/Source/portable/GCC/ARM7_LPC2000/portISR.c +++ b/FreeRTOS/Source/portable/GCC/ARM7_LPC2000/portISR.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM7_LPC2000/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM7_LPC2000/portmacro.h index 9a84fa8..f36f5a1 100755 --- a/FreeRTOS/Source/portable/GCC/ARM7_LPC2000/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ARM7_LPC2000/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/port.c b/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/port.c index 4690ca0..2e2a81e 100755 --- a/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portISR.c b/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portISR.c index 913e619..1e25640 100755 --- a/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portISR.c +++ b/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portISR.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portmacro.h index f506028..0ef784c 100755 --- a/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM_CA53_64_BIT/port.c b/FreeRTOS/Source/portable/GCC/ARM_CA53_64_BIT/port.c index 96dbee9..d6e1e64 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CA53_64_BIT/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CA53_64_BIT/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM_CA53_64_BIT/portASM.S b/FreeRTOS/Source/portable/GCC/ARM_CA53_64_BIT/portASM.S index 5cdbaae..5d07851 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CA53_64_BIT/portASM.S +++ b/FreeRTOS/Source/portable/GCC/ARM_CA53_64_BIT/portASM.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM_CA53_64_BIT/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM_CA53_64_BIT/portmacro.h index 09eaeaf..f201cf0 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CA53_64_BIT/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ARM_CA53_64_BIT/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -205,5 +205,7 @@ number of bits implemented by the interrupt controller. */ #define portICCBPR_BINARY_POINT_REGISTER ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCBPR_BINARY_POINT_OFFSET ) ) ) #define portICCRPR_RUNNING_PRIORITY_REGISTER ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCRPR_RUNNING_PRIORITY_OFFSET ) ) ) +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) + #endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CA9/port.c b/FreeRTOS/Source/portable/GCC/ARM_CA9/port.c index b9bc9a5..0f7c96c 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CA9/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CA9/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM_CA9/portASM.S b/FreeRTOS/Source/portable/GCC/ARM_CA9/portASM.S index a2cfc15..f43ce96 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CA9/portASM.S +++ b/FreeRTOS/Source/portable/GCC/ARM_CA9/portASM.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM_CA9/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM_CA9/portmacro.h index 446644c..ca82a7c 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CA9/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ARM_CA9/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -202,5 +202,7 @@ number of bits implemented by the interrupt controller. */ #define portICCBPR_BINARY_POINT_REGISTER ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCBPR_BINARY_POINT_OFFSET ) ) ) #define portICCRPR_RUNNING_PRIORITY_REGISTER ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCRPR_RUNNING_PRIORITY_OFFSET ) ) ) +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) + #endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM0/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM0/port.c index 062b29d..fe846d0 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CM0/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CM0/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -175,7 +175,7 @@ void vPortStartFirstTask( void ) */ BaseType_t xPortStartScheduler( void ) { - /* Make PendSV, CallSV and SysTick the same priroity as the kernel. */ + /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ *(portNVIC_SYSPRI2) |= portNVIC_PENDSV_PRI; *(portNVIC_SYSPRI2) |= portNVIC_SYSTICK_PRI; diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM0/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM_CM0/portmacro.h index db99901..a4fdae0 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CM0/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ARM_CM0/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -107,6 +107,8 @@ extern void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__((naked) #define portNOP() +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) + #ifdef __cplusplus } #endif diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23/non_secure/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM23/non_secure/port.c new file mode 100755 index 0000000..bd85a6f --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23/non_secure/port.c @@ -0,0 +1,899 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/* Portasm includes. */ +#include "portasm.h" + +#if( configENABLE_TRUSTZONE == 1 ) + /* Secure components includes. */ + #include "secure_context.h" + #include "secure_init.h" +#endif /* configENABLE_TRUSTZONE */ + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/** + * The FreeRTOS Cortex M33 port can be configured to run on the Secure Side only + * i.e. the processor boots as secure and never jumps to the non-secure side. + * The Trust Zone support in the port must be disabled in order to run FreeRTOS + * on the secure side. The following are the valid configuration seetings: + * + * 1. Run FreeRTOS on the Secure Side: + * configRUN_FREERTOS_SECURE_ONLY = 1 and configENABLE_TRUSTZONE = 0 + * + * 2. Run FreeRTOS on the Non-Secure Side with Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 1 + * + * 3. Run FreeRTOS on the Non-Secure Side only i.e. no Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 0 + */ +#if( ( configRUN_FREERTOS_SECURE_ONLY == 1 ) && ( configENABLE_TRUSTZONE == 1 ) ) + #error TrustZone needs to be disabled in order to run FreeRTOS on the Secure Side. +#endif +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the NVIC. + */ +#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t * ) 0xe000e010 ) +#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t * ) 0xe000e014 ) +#define portNVIC_SYSTICK_CURRENT_VALUE ( ( volatile uint32_t * ) 0xe000e018 ) +#define portNVIC_INT_CTRL ( ( volatile uint32_t * ) 0xe000ed04 ) +#define portNVIC_SYSPRI2 ( ( volatile uint32_t * ) 0xe000ed20 ) +#define portNVIC_SYSTICK_CLK ( 0x00000004 ) +#define portNVIC_SYSTICK_INT ( 0x00000002 ) +#define portNVIC_SYSTICK_ENABLE ( 0x00000001 ) +#define portNVIC_PENDSVSET ( 0x10000000 ) +#define portMIN_INTERRUPT_PRIORITY ( 255UL ) +#define portNVIC_PENDSV_PRI ( portMIN_INTERRUPT_PRIORITY << 16UL ) +#define portNVIC_SYSTICK_PRI ( portMIN_INTERRUPT_PRIORITY << 24UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the SCB. + */ +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( * ( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_MEM_FAULT_ENABLE ( 1UL << 16UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the FPU. + */ +#define portCPACR ( ( volatile uint32_t * ) 0xe000ed88 ) /* Coprocessor Access Control Register. */ +#define portCPACR_CP10_VALUE ( 3UL ) +#define portCPACR_CP11_VALUE portCPACR_CP10_VALUE +#define portCPACR_CP10_POS ( 20UL ) +#define portCPACR_CP11_POS ( 22UL ) + +#define portFPCCR ( ( volatile uint32_t * ) 0xe000ef34 ) /* Floating Point Context Control Register. */ +#define portFPCCR_ASPEN_POS ( 31UL ) +#define portFPCCR_ASPEN_MASK ( 1UL << portFPCCR_ASPEN_POS ) +#define portFPCCR_LSPEN_POS ( 30UL ) +#define portFPCCR_LSPEN_MASK ( 1UL << portFPCCR_LSPEN_POS ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the MPU. + */ +#define portMPU_TYPE_REG ( * ( ( volatile uint32_t * ) 0xe000ed90 ) ) +#define portMPU_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed94 ) ) +#define portMPU_RNR_REG ( * ( ( volatile uint32_t * ) 0xe000ed98 ) ) + +#define portMPU_RBAR_REG ( * ( ( volatile uint32_t * ) 0xe000ed9c ) ) +#define portMPU_RLAR_REG ( * ( ( volatile uint32_t * ) 0xe000eda0 ) ) + +#define portMPU_RBAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda4 ) ) +#define portMPU_RLAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda8 ) ) + +#define portMPU_RBAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edac ) ) +#define portMPU_RLAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edb0 ) ) + +#define portMPU_RBAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb4 ) ) +#define portMPU_RLAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb8 ) ) + +#define portMPU_MAIR0_REG ( * ( ( volatile uint32_t * ) 0xe000edc0 ) ) +#define portMPU_MAIR1_REG ( * ( ( volatile uint32_t * ) 0xe000edc4 ) ) + +#define portMPU_RBAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ +#define portMPU_RLAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ + +#define portMPU_MAIR_ATTR0_POS ( 0UL ) +#define portMPU_MAIR_ATTR0_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR1_POS ( 8UL ) +#define portMPU_MAIR_ATTR1_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR2_POS ( 16UL ) +#define portMPU_MAIR_ATTR2_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR3_POS ( 24UL ) +#define portMPU_MAIR_ATTR3_MASK ( 0xff000000 ) + +#define portMPU_MAIR_ATTR4_POS ( 0UL ) +#define portMPU_MAIR_ATTR4_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR5_POS ( 8UL ) +#define portMPU_MAIR_ATTR5_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR6_POS ( 16UL ) +#define portMPU_MAIR_ATTR6_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR7_POS ( 24UL ) +#define portMPU_MAIR_ATTR7_MASK ( 0xff000000 ) + +#define portMPU_RLAR_ATTR_INDEX0 ( 0UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX1 ( 1UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX2 ( 2UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX3 ( 3UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX4 ( 4UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX5 ( 5UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX6 ( 6UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX7 ( 7UL << 1UL ) + +#define portMPU_RLAR_REGION_ENABLE ( 1UL ) + +/* Enable privileged access to unmapped region. */ +#define portMPU_PRIV_BACKGROUND_ENABLE ( 1UL << 2UL ) + +/* Enable MPU. */ +#define portMPU_ENABLE ( 1UL << 0UL ) + +/* Expected value of the portMPU_TYPE register. */ +#define portEXPECTED_MPU_TYPE_VALUE ( 8UL << 8UL ) /* 8 regions, unified. */ +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to set up the initial stack. + */ +#define portINITIAL_XPSR ( 0x01000000 ) + +#if( configRUN_FREERTOS_SECURE_ONLY == 1 ) + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF FD + * 1111 1111 1111 1111 1111 1111 1111 1101 + * + * Bit[6] - 1 --> The exception was taken from the Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 1 --> The exception was taken to the Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xfffffffd ) +#else + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF BC + * 1111 1111 1111 1111 1111 1111 1011 1100 + * + * Bit[6] - 0 --> The exception was taken from the Non-Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 0 --> The exception was taken to the Non-Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xffffffbc ) +#endif /* configRUN_FREERTOS_SECURE_ONLY */ + +/** + * @brief CONTROL register privileged bit mask. + * + * Bit[0] in CONTROL register tells the privilege: + * Bit[0] = 0 ==> The task is privileged. + * Bit[0] = 1 ==> The task is not privileged. + */ +#define portCONTROL_PRIVILEGED_MASK ( 1UL << 0UL ) + +/** + * @brief Initial CONTROL register values. + */ +#define portINITIAL_CONTROL_UNPRIVILEGED ( 0x3 ) +#define portINITIAL_CONTROL_PRIVILEGED ( 0x2 ) + +/** + * @brief Let the user override the pre-loading of the initial LR with the + * address of prvTaskExitError() in case it messes up unwinding of the stack + * in the debugger. + */ +#ifdef configTASK_RETURN_ADDRESS + #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS +#else + #define portTASK_RETURN_ADDRESS prvTaskExitError +#endif + +/** + * @brief If portPRELOAD_REGISTERS then registers will be given an initial value + * when a task is created. This helps in debugging at the cost of code size. + */ +#define portPRELOAD_REGISTERS 1 + +/** + * @brief A task is created without a secure context, and must call + * portALLOCATE_SECURE_CONTEXT() to give itself a secure context before it makes + * any secure calls. + */ +#define portNO_SECURE_CONTEXT 0 +/*-----------------------------------------------------------*/ + +/** + * @brief Setup the timer to generate the tick interrupts. + */ +static void prvSetupTimerInterrupt( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Used to catch tasks that attempt to return from their implementing + * function. + */ +static void prvTaskExitError( void ); + +#if( configENABLE_MPU == 1 ) + /** + * @brief Setup the Memory Protection Unit (MPU). + */ + static void prvSetupMPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_MPU */ + +#if( configENABLE_FPU == 1 ) + /** + * @brief Setup the Floating Point Unit (FPU). + */ + static void prvSetupFPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_FPU */ + +/** + * @brief Yield the processor. + */ +void vPortYield( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Enter critical section. + */ +void vPortEnterCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Exit from critical section. + */ +void vPortExitCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief SysTick handler. + */ +void SysTick_Handler( void ) PRIVILEGED_FUNCTION; + +/** + * @brief C part of SVC handler. + */ +portDONT_DISCARD void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) PRIVILEGED_FUNCTION; +/*-----------------------------------------------------------*/ + +/** + * @brief Each task maintains its own interrupt status in the critical nesting + * variable. + */ +static volatile uint32_t ulCriticalNesting = 0xaaaaaaaaUL; + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Saved as part of the task context to indicate which context the + * task is using on the secure side. + */ + portDONT_DISCARD volatile SecureContextHandle_t xSecureContext = portNO_SECURE_CONTEXT; +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +static void prvSetupTimerInterrupt( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Stop and reset the SysTick. */ + *( portNVIC_SYSTICK_CTRL ) = 0UL; + *( portNVIC_SYSTICK_CURRENT_VALUE ) = 0UL; + + /* Configure SysTick to interrupt at the requested rate. */ + *( portNVIC_SYSTICK_LOAD ) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; + *( portNVIC_SYSTICK_CTRL ) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE; +} +/*-----------------------------------------------------------*/ + +static void prvTaskExitError( void ) +{ +volatile uint32_t ulDummy = 0UL; + + /* A function that implements a task must not exit or attempt to return to + * its caller as there is nothing to return to. If a task wants to exit it + * should instead call vTaskDelete( NULL ). Artificially force an assert() + * to be triggered if configASSERT() is defined, then stop here so + * application writers can catch the error. */ + configASSERT( ulCriticalNesting == ~0UL ); + portDISABLE_INTERRUPTS(); + + while( ulDummy == 0 ) + { + /* This file calls prvTaskExitError() after the scheduler has been + * started to remove a compiler warning about the function being + * defined but never called. ulDummy is used purely to quieten other + * warnings about code appearing after this function is called - making + * ulDummy volatile makes the compiler think the function could return + * and therefore not output an 'unreachable code' warning for code that + * appears after it. */ + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + static void prvSetupMPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __privileged_functions_start__; + extern uint32_t * __privileged_functions_end__; + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + extern uint32_t * __unprivileged_flash_start__; + extern uint32_t * __unprivileged_flash_end__; + extern uint32_t * __privileged_sram_start__; + extern uint32_t * __privileged_sram_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __privileged_functions_start__[]; + extern uint32_t __privileged_functions_end__[]; + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + extern uint32_t __unprivileged_flash_start__[]; + extern uint32_t __unprivileged_flash_end__[]; + extern uint32_t __privileged_sram_start__[]; + extern uint32_t __privileged_sram_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ + + /* Check that the MPU is present. */ + if( portMPU_TYPE_REG == portEXPECTED_MPU_TYPE_VALUE ) + { + /* MAIR0 - Index 0. */ + portMPU_MAIR0_REG |= ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + /* MAIR0 - Index 1. */ + portMPU_MAIR0_REG |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* Setup privileged flash as Read Only so that privileged tasks can + * read it but not modify. */ + portMPU_RNR_REG = portPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_functions_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_functions_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged flash as Read Only by both privileged and + * unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __unprivileged_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __unprivileged_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged syscalls flash as Read Only by both privileged + * and unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_SYSCALLS_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __syscalls_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __syscalls_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup RAM containing kernel data for privileged access only. */ + portMPU_RNR_REG = portPRIVILEGED_RAM_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_sram_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_sram_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Enable mem fault. */ + portSCB_SYS_HANDLER_CTRL_STATE_REG |= portSCB_MEM_FAULT_ENABLE; + + /* Enable MPU with privileged background access i.e. unmapped + * regions have privileged access. */ + portMPU_CTRL_REG |= ( portMPU_PRIV_BACKGROUND_ENABLE | portMPU_ENABLE ); + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_FPU == 1 ) + static void prvSetupFPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* Enable non-secure access to the FPU. */ + SecureInit_EnableNSFPUAccess(); + } + #endif /* configENABLE_TRUSTZONE */ + + /* CP10 = 11 ==> Full access to FPU i.e. both privileged and + * unprivileged code should be able to access FPU. CP11 should be + * programmed to the same value as CP10. */ + *( portCPACR ) |= ( ( portCPACR_CP10_VALUE << portCPACR_CP10_POS ) | + ( portCPACR_CP11_VALUE << portCPACR_CP11_POS ) + ); + + /* ASPEN = 1 ==> Hardware should automatically preserve floating point + * context on exception entry and restore on exception return. + * LSPEN = 1 ==> Enable lazy context save of FP state. */ + *( portFPCCR ) |= ( portFPCCR_ASPEN_MASK | portFPCCR_LSPEN_MASK ); + } +#endif /* configENABLE_FPU */ +/*-----------------------------------------------------------*/ + +void vPortYield( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Set a PendSV to request a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + portDISABLE_INTERRUPTS(); + ulCriticalNesting++; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + configASSERT( ulCriticalNesting ); + ulCriticalNesting--; + + if( ulCriticalNesting == 0 ) + { + portENABLE_INTERRUPTS(); + } +} +/*-----------------------------------------------------------*/ + +void SysTick_Handler( void ) /* PRIVILEGED_FUNCTION */ +{ +uint32_t ulPreviousMask; + + ulPreviousMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* Increment the RTOS tick. */ + if( xTaskIncrementTick() != pdFALSE ) + { + /* Pend a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulPreviousMask ); +} +/*-----------------------------------------------------------*/ + +void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) /* PRIVILEGED_FUNCTION portDONT_DISCARD */ +{ +#if( configENABLE_MPU == 1 ) + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ +#endif /* configENABLE_MPU */ + +uint32_t ulPC; + +#if( configENABLE_TRUSTZONE == 1 ) + uint32_t ulR0; + #if( configENABLE_MPU == 1 ) + uint32_t ulControl, ulIsTaskPrivileged; + #endif /* configENABLE_MPU */ +#endif /* configENABLE_TRUSTZONE */ +uint8_t ucSVCNumber; + + /* Register are stored on the stack in the following order - R0, R1, R2, R3, + * R12, LR, PC, xPSR. */ + ulPC = pulCallerStackAddress[ 6 ]; + ucSVCNumber = ( ( uint8_t *) ulPC )[ -2 ]; + + switch( ucSVCNumber ) + { + #if( configENABLE_TRUSTZONE == 1 ) + case portSVC_ALLOCATE_SECURE_CONTEXT: + { + /* R0 contains the stack size passed as parameter to the + * vPortAllocateSecureContext function. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + #if( configENABLE_MPU == 1 ) + { + /* Read the CONTROL register value. */ + __asm volatile ( "mrs %0, control" : "=r" ( ulControl ) ); + + /* The task that raised the SVC is privileged if Bit[0] + * in the CONTROL register is 0. */ + ulIsTaskPrivileged = ( ( ulControl & portCONTROL_PRIVILEGED_MASK ) == 0 ); + + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0, ulIsTaskPrivileged ); + } + #else + { + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0 ); + } + #endif /* configENABLE_MPU */ + + configASSERT( xSecureContext != NULL ); + SecureContext_LoadContext( xSecureContext ); + } + break; + + case portSVC_FREE_SECURE_CONTEXT: + { + /* R0 contains the secure context handle to be freed. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + /* Free the secure context. */ + SecureContext_FreeContext( ( SecureContextHandle_t ) ulR0 ); + } + break; + #endif /* configENABLE_TRUSTZONE */ + + case portSVC_START_SCHEDULER: + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* De-prioritize the non-secure exceptions so that the + * non-secure pendSV runs at the lowest priority. */ + SecureInit_DePrioritizeNSExceptions(); + + /* Initialize the secure context management system. */ + SecureContext_Init(); + } + #endif /* configENABLE_TRUSTZONE */ + + #if( configENABLE_FPU == 1 ) + { + /* Setup the Floating Point Unit (FPU). */ + prvSetupFPU(); + } + #endif /* configENABLE_FPU */ + + /* Setup the context of the first task so that the first task starts + * executing. */ + vRestoreContextOfFirstTask(); + } + break; + + #if( configENABLE_MPU == 1 ) + case portSVC_RAISE_PRIVILEGE: + { + /* Only raise the privilege, if the svc was raised from any of + * the system calls. */ + if( ulPC >= ( uint32_t ) __syscalls_flash_start__ && + ulPC <= ( uint32_t ) __syscalls_flash_end__ ) + { + vRaisePrivilege(); + } + } + break; + #endif /* configENABLE_MPU */ + + default: + { + /* Incorrect SVC call. */ + configASSERT( pdFALSE ); + } + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) /* PRIVILEGED_FUNCTION */ +#else + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) /* PRIVILEGED_FUNCTION */ +#endif /* configENABLE_MPU */ +{ + /* Simulate the stack frame as it would be created by a context switch + * interrupt. */ + #if( portPRELOAD_REGISTERS == 0 ) + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack -= 9; /* R11..R4, EXC_RETURN. */ + *pxTopOfStack = portINITIAL_EXC_RETURN; + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #else /* portPRELOAD_REGISTERS */ + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x12121212UL; /* R12 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x03030303UL; /* R3 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x02020202UL; /* R2 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x01010101UL; /* R1 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x11111111UL; /* R11 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x10101010UL; /* R10 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x09090909UL; /* R09 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x08080808UL; /* R08 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x07070707UL; /* R07 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x06060606UL; /* R06 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x05050505UL; /* R05 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x04040404UL; /* R04 */ + pxTopOfStack--; + *pxTopOfStack = portINITIAL_EXC_RETURN; /* EXC_RETURN */ + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #endif /* portPRELOAD_REGISTERS */ + + return pxTopOfStack; +} +/*-----------------------------------------------------------*/ + +BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + *( portNVIC_SYSPRI2 ) |= portNVIC_PENDSV_PRI; + *( portNVIC_SYSPRI2 ) |= portNVIC_SYSTICK_PRI; + + #if( configENABLE_MPU == 1 ) + { + /* Setup the Memory Protection Unit (MPU). */ + prvSetupMPU(); + } + #endif /* configENABLE_MPU */ + + /* Start the timer that generates the tick ISR. Interrupts are disabled + * here already. */ + prvSetupTimerInterrupt(); + + /* Initialize the critical nesting count ready for the first task. */ + ulCriticalNesting = 0; + + /* Start the first task. */ + vStartFirstTask(); + + /* Should never get here as the tasks will now be executing. Call the task + * exit error function to prevent compiler warnings about a static function + * not being called in the case that the application writer overrides this + * functionality by defining configTASK_RETURN_ADDRESS. Call + * vTaskSwitchContext() so link time optimization does not remove the + * symbol. */ + vTaskSwitchContext(); + prvTaskExitError(); + + /* Should not get here. */ + return 0; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Not implemented in ports where there is nothing to return to. + * Artificially force an assert. */ + configASSERT( ulCriticalNesting == 1000UL ); +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) + { + uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber; + int32_t lIndex = 0; + + /* Setup MAIR0. */ + xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + xMPUSettings->ulMAIR0 |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* This function is called automatically when the task is created - in + * which case the stack region parameters will be valid. At all other + * times the stack parameters will not be valid and it is assumed that + * the stack region has already been configured. */ + if( ulStackDepth > 0 ) + { + /* Define the region that allows access to the stack. */ + ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + + xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + } + + /* User supplied configurable regions. */ + for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ ) + { + /* If xRegions is NULL i.e. the task has not specified any MPU + * region, the else part ensures that all the configurable MPU + * regions are invalidated. */ + if( ( xRegions != NULL ) && ( xRegions[ lIndex ].ulLengthInBytes > 0UL ) ) + { + /* Translate the generic region definition contained in xRegions + * into the ARMv8 specific MPU settings that are then stored in + * xMPUSettings. */ + ulRegionStartAddress = ( ( uint32_t ) xRegions[ lIndex ].pvBaseAddress ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) xRegions[ lIndex ].pvBaseAddress + xRegions[ lIndex ].ulLengthInBytes - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + /* Start address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ); + + /* RO/RW. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_READ_ONLY ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_ONLY ); + } + else + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_WRITE ); + } + + /* XN. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_EXECUTE_NEVER ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_EXECUTE_NEVER ); + } + + /* End Address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Normal memory/ Device memory. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_DEVICE_MEMORY ) != 0 ) + { + /* Attr1 in MAIR0 is configured as device memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX1; + } + else + { + /* Attr1 in MAIR0 is configured as normal memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX0; + } + } + else + { + /* Invalidate the region. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = 0UL; + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = 0UL; + } + + lIndex++; + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23/non_secure/portasm.c b/FreeRTOS/Source/portable/GCC/ARM_CM23/non_secure/portasm.c new file mode 100755 index 0000000..c8345c7 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23/non_secure/portasm.c @@ -0,0 +1,468 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE ensures that PRIVILEGED_FUNCTION + * is defined correctly and privileged functions are placed in correct sections. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Portasm includes. */ +#include "portasm.h" + +/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE is needed to be defined only for the + * header files. */ +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#if( configENABLE_FPU == 1 ) + #error Cortex-M23 does not have a Floating Point Unit (FPU) and therefore configENABLE_FPU must be set to 0. +#endif + +void vRestoreContextOfFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " \n" + " ldr r2, pxCurrentTCBConst2 \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r3, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r0, [r3] \n" /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r5, #1 \n" /* r5 = 1. */ + " bics r4, r5 \n" /* r4 = r4 & ~r5 i.e. Clear the bit 0 in r4. */ + " str r4, [r2] \n" /* Disable MPU. */ + " \n" + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + " ldr r4, [r3] \n" /* r4 = *r3 i.e. r4 = MAIR0. */ + " ldr r2, xMAIR0Const2 \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r4, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst2 \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + " movs r5, #4 \n" /* r5 = 4. */ + " str r5, [r2] \n" /* Program RNR = 4. */ + " ldmia r3!, {r6,r7} \n" /* Read first set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst2 \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write first set of RBAR/RLAR registers. */ + " movs r5, #5 \n" /* r5 = 5. */ + " str r5, [r2] \n" /* Program RNR = 5. */ + " ldmia r3!, {r6,r7} \n" /* Read second set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst2 \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write second set of RBAR/RLAR registers. */ + " movs r5, #6 \n" /* r5 = 6. */ + " str r5, [r2] \n" /* Program RNR = 6. */ + " ldmia r3!, {r6,r7} \n" /* Read third set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst2 \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write third set of RBAR/RLAR registers. */ + " movs r5, #7 \n" /* r5 = 7. */ + " str r5, [r2] \n" /* Program RNR = 7. */ + " ldmia r3!, {r6,r7} \n" /* Read fourth set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst2 \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write fourth set of RBAR/RLAR registers. */ + " \n" + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r5, #1 \n" /* r5 = 1. */ + " orrs r4, r5 \n" /* r4 = r4 | r5 i.e. Set the bit 0 in r4. */ + " str r4, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " ldm r0!, {r1-r4} \n" /* Read from stack - r1 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = EXC_RETURN. */ + " ldr r5, xSecureContextConst2 \n" + " str r1, [r5] \n" /* Set xSecureContext to this task's value for the same. */ + " msr psplim, r2 \n" /* Set this task's PSPLIM value. */ + " msr control, r3 \n" /* Set this task's CONTROL value. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r4 \n" /* Finally, branch to EXC_RETURN. */ + #else /* configENABLE_MPU */ + " ldm r0!, {r1-r3} \n" /* Read from stack - r1 = xSecureContext, r2 = PSPLIM and r3 = EXC_RETURN. */ + " ldr r4, xSecureContextConst2 \n" + " str r1, [r4] \n" /* Set xSecureContext to this task's value for the same. */ + " msr psplim, r2 \n" /* Set this task's PSPLIM value. */ + " movs r1, #2 \n" /* r1 = 2. */ + " msr CONTROL, r1 \n" /* Switch to use PSP in the thread mode. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r3 \n" /* Finally, branch to EXC_RETURN. */ + #endif /* configENABLE_MPU */ + " \n" + " .align 4 \n" + "pxCurrentTCBConst2: .word pxCurrentTCB \n" + "xSecureContextConst2: .word xSecureContext \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst2: .word 0xe000ed94 \n" + "xMAIR0Const2: .word 0xe000edc0 \n" + "xRNRConst2: .word 0xe000ed98 \n" + "xRBARConst2: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " movs r1, #1 \n" /* r1 = 1. */ + " tst r0, r1 \n" /* Perform r0 & r1 (bitwise AND) and update the conditions flag. */ + " beq running_privileged \n" /* If the result of previous AND operation was 0, branch. */ + " movs r0, #0 \n" /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + " bx lr \n" /* Return. */ + " running_privileged: \n" + " movs r0, #1 \n" /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + " bx lr \n" /* Return. */ + " \n" + " .align 4 \n" + ::: "r0", "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vRaisePrivilege( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, control \n" /* Read the CONTROL register. */ + " movs r1, #1 \n" /* r1 = 1. */ + " bics r0, r1 \n" /* Clear the bit 0. */ + " msr control, r0 \n" /* Write back the new CONTROL value. */ + " bx lr \n" /* Return to the caller. */ + ::: "r0", "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vResetPrivilege( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " movs r1, #1 \n" /* r1 = 1. */ + " orrs r0, r1 \n" /* r0 = r0 | r1. */ + " msr control, r0 \n" /* CONTROL = r0. */ + " bx lr \n" /* Return to the caller. */ + :::"r0", "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vStartFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " ldr r0, xVTORConst \n" /* Use the NVIC offset register to locate the stack. */ + " ldr r0, [r0] \n" /* Read the VTOR register which gives the address of vector table. */ + " ldr r0, [r0] \n" /* The first entry in vector table is stack pointer. */ + " msr msp, r0 \n" /* Set the MSP back to the start of the stack. */ + " cpsie i \n" /* Globally enable interrupts. */ + " dsb \n" + " isb \n" + " svc %0 \n" /* System call to start the first task. */ + " nop \n" + " \n" + " .align 4 \n" + "xVTORConst: .word 0xe000ed08 \n" + :: "i" ( portSVC_START_SCHEDULER ) : "memory" + ); +} +/*-----------------------------------------------------------*/ + +uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, PRIMASK \n" + " cpsid i \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* To avoid compiler warnings. The return statement will never be reached, + * but some compilers warn if it is not included, while others won't compile + * if it is. */ + return 0; +#endif +} +/*-----------------------------------------------------------*/ + +void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " msr PRIMASK, r0 \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* Just to avoid compiler warning. ulMask is used from the asm code but + * the compiler can't see that. Some compilers generate warnings without + * the following line, while others generate warnings if the line is + * included. */ + ( void ) ulMask; +#endif +} +/*-----------------------------------------------------------*/ + +void PendSV_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " .extern SecureContext_SaveContext \n" + " .extern SecureContext_LoadContext \n" + " \n" + " mrs r1, psp \n" /* Read PSP in r1. */ + " ldr r2, xSecureContextConst \n" /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + " ldr r0, [r2] \n" /* Read xSecureContext - Value of xSecureContext must be in r0 as it is used as a parameter later. */ + " \n" + " cbz r0, save_ns_context \n" /* No secure context to save. */ + " push {r0-r2, r14} \n" + " bl SecureContext_SaveContext \n" + " pop {r0-r3} \n" /* LR is now in r3. */ + " mov lr, r3 \n" /* LR = r3. */ + " lsls r2, r3, #25 \n" /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + " bpl save_ns_context \n" /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + " ldr r3, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r2, [r3] \n" /* Read pxCurrentTCB. */ + #if( configENABLE_MPU == 1 ) + " subs r1, r1, #16 \n" /* Make space for xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mrs r3, control \n" /* r3 = CONTROL. */ + " mov r4, lr \n" /* r4 = LR/EXC_RETURN. */ + " stmia r1!, {r0, r2-r4} \n" /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + #else /* configENABLE_MPU */ + " subs r1, r1, #12 \n" /* Make space for xSecureContext, PSPLIM and LR on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " stmia r1!, {r0, r2-r3} \n" /* Store xSecureContext, PSPLIM and LR on the stack. */ + #endif /* configENABLE_MPU */ + " b select_next_task \n" + " \n" + " save_ns_context: \n" + " ldr r3, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r2, [r3] \n" /* Read pxCurrentTCB. */ + #if( configENABLE_MPU == 1 ) + " subs r1, r1, #48 \n" /* Make space for xSecureContext, PSPLIM, CONTROL, LR and the remaining registers on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " adds r1, r1, #16 \n" /* r1 = r1 + 16. */ + " stmia r1!, {r4-r7} \n" /* Store the low registers that are not saved automatically. */ + " mov r4, r8 \n" /* r4 = r8. */ + " mov r5, r9 \n" /* r5 = r9. */ + " mov r6, r10 \n" /* r6 = r10. */ + " mov r7, r11 \n" /* r7 = r11. */ + " stmia r1!, {r4-r7} \n" /* Store the high registers that are not saved automatically. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mrs r3, control \n" /* r3 = CONTROL. */ + " mov r4, lr \n" /* r4 = LR/EXC_RETURN. */ + " subs r1, r1, #48 \n" /* r1 = r1 - 48. */ + " stmia r1!, {r0, r2-r4} \n" /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + #else /* configENABLE_MPU */ + " subs r1, r1, #44 \n" /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " stmia r1!, {r0, r2-r7} \n" /* Store xSecureContext, PSPLIM, LR and the low registers that are not saved automatically. */ + " mov r4, r8 \n" /* r4 = r8. */ + " mov r5, r9 \n" /* r5 = r9. */ + " mov r6, r10 \n" /* r6 = r10. */ + " mov r7, r11 \n" /* r7 = r11. */ + " stmia r1!, {r4-r7} \n" /* Store the high registers that are not saved automatically. */ + #endif /* configENABLE_MPU */ + " \n" + " select_next_task: \n" + " cpsid i \n" + " bl vTaskSwitchContext \n" + " cpsie i \n" + " \n" + " ldr r2, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r3, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r1, [r3] \n" /* The first item in pxCurrentTCB is the task top of stack. r1 now points to the top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r5, #1 \n" /* r5 = 1. */ + " bics r4, r5 \n" /* r4 = r4 & ~r5 i.e. Clear the bit 0 in r4. */ + " str r4, [r2] \n" /* Disable MPU. */ + " \n" + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + " ldr r4, [r3] \n" /* r4 = *r3 i.e. r4 = MAIR0. */ + " ldr r2, xMAIR0Const \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r4, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + " movs r5, #4 \n" /* r5 = 4. */ + " str r5, [r2] \n" /* Program RNR = 4. */ + " ldmia r3!, {r6,r7} \n" /* Read first set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write first set of RBAR/RLAR registers. */ + " movs r5, #5 \n" /* r5 = 5. */ + " str r5, [r2] \n" /* Program RNR = 5. */ + " ldmia r3!, {r6,r7} \n" /* Read second set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write second set of RBAR/RLAR registers. */ + " movs r5, #6 \n" /* r5 = 6. */ + " str r5, [r2] \n" /* Program RNR = 6. */ + " ldmia r3!, {r6,r7} \n" /* Read third set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write third set of RBAR/RLAR registers. */ + " movs r5, #7 \n" /* r5 = 7. */ + " str r5, [r2] \n" /* Program RNR = 7. */ + " ldmia r3!, {r6,r7} \n" /* Read fourth set of RBAR/RLAR from TCB. */ + " ldr r4, xRBARConst \n" /* r4 = 0xe000ed9c [Location of RBAR]. */ + " stmia r4!, {r6,r7} \n" /* Write fourth set of RBAR/RLAR registers. */ + " \n" + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r5, #1 \n" /* r5 = 1. */ + " orrs r4, r5 \n" /* r4 = r4 | r5 i.e. Set the bit 0 in r4. */ + " str r4, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " ldmia r1!, {r0, r2-r4} \n" /* Read from stack - r0 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = LR. */ + " msr psplim, r2 \n" /* Restore the PSPLIM register value for the task. */ + " msr control, r3 \n" /* Restore the CONTROL register value for the task. */ + " mov lr, r4 \n" /* LR = r4. */ + " ldr r2, xSecureContextConst \n" /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + " str r0, [r2] \n" /* Restore the task's xSecureContext. */ + " cbz r0, restore_ns_context \n" /* If there is no secure context for the task, restore the non-secure context. */ + " push {r1,r4} \n" + " bl SecureContext_LoadContext \n" /* Restore the secure context. */ + " pop {r1,r4} \n" + " mov lr, r4 \n" /* LR = r4. */ + " lsls r2, r4, #25 \n" /* r2 = r4 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + " bpl restore_ns_context \n" /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + " msr psp, r1 \n" /* Remember the new top of stack for the task. */ + " bx lr \n" + #else /* configENABLE_MPU */ + " ldmia r1!, {r0, r2-r3} \n" /* Read from stack - r0 = xSecureContext, r2 = PSPLIM and r3 = LR. */ + " msr psplim, r2 \n" /* Restore the PSPLIM register value for the task. */ + " mov lr, r3 \n" /* LR = r3. */ + " ldr r2, xSecureContextConst \n" /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + " str r0, [r2] \n" /* Restore the task's xSecureContext. */ + " cbz r0, restore_ns_context \n" /* If there is no secure context for the task, restore the non-secure context. */ + " push {r1,r3} \n" + " bl SecureContext_LoadContext \n" /* Restore the secure context. */ + " pop {r1,r3} \n" + " mov lr, r3 \n" /* LR = r3. */ + " lsls r2, r3, #25 \n" /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + " bpl restore_ns_context \n" /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + " msr psp, r1 \n" /* Remember the new top of stack for the task. */ + " bx lr \n" + #endif /* configENABLE_MPU */ + " \n" + " restore_ns_context: \n" + " adds r1, r1, #16 \n" /* Move to the high registers. */ + " ldmia r1!, {r4-r7} \n" /* Restore the high registers that are not automatically restored. */ + " mov r8, r4 \n" /* r8 = r4. */ + " mov r9, r5 \n" /* r9 = r5. */ + " mov r10, r6 \n" /* r10 = r6. */ + " mov r11, r7 \n" /* r11 = r7. */ + " msr psp, r1 \n" /* Remember the new top of stack for the task. */ + " subs r1, r1, #32 \n" /* Go back to the low registers. */ + " ldmia r1!, {r4-r7} \n" /* Restore the low registers that are not automatically restored. */ + " bx lr \n" + " \n" + " .align 4 \n" + "pxCurrentTCBConst: .word pxCurrentTCB \n" + "xSecureContextConst: .word xSecureContext \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst: .word 0xe000ed94 \n" + "xMAIR0Const: .word 0xe000edc0 \n" + "xRNRConst: .word 0xe000ed98 \n" + "xRBARConst: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +void SVC_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " movs r0, #4 \n" + " mov r1, lr \n" + " tst r0, r1 \n" + " beq stacking_used_msp \n" + " mrs r0, psp \n" + " ldr r2, svchandler_address_const \n" + " bx r2 \n" + " stacking_used_msp: \n" + " mrs r0, msp \n" + " ldr r2, svchandler_address_const \n" + " bx r2 \n" + " \n" + " .align 4 \n" + "svchandler_address_const: .word vPortSVCHandler_C \n" + ); +} +/*-----------------------------------------------------------*/ + +void vPortAllocateSecureContext( uint32_t ulSecureStackSize ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " svc %0 \n" /* Secure context is allocated in the supervisor call. */ + " bx lr \n" /* Return. */ + :: "i" ( portSVC_ALLOCATE_SECURE_CONTEXT ) : "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " ldr r1, [r0] \n" /* The first item in the TCB is the top of the stack. */ + " ldr r0, [r1] \n" /* The first item on the stack is the task's xSecureContext. */ + " cmp r0, #0 \n" /* Raise svc if task's xSecureContext is not NULL. */ + " beq free_secure_context \n" + " bx lr \n" /* There is no secure context (xSecureContext is NULL). */ + " free_secure_context: \n" + " svc %0 \n" /* Secure context is freed in the supervisor call. */ + " bx lr \n" /* Return. */ + :: "i" ( portSVC_FREE_SECURE_CONTEXT ) : "memory" + ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23/non_secure/portasm.h b/FreeRTOS/Source/portable/GCC/ARM_CM23/non_secure/portasm.h new file mode 100755 index 0000000..2ecf04e --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23/non_secure/portasm.h @@ -0,0 +1,113 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __PORT_ASM_H__ +#define __PORT_ASM_H__ + +/* Scheduler includes. */ +#include "FreeRTOS.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/** + * @brief Restore the context of the first task so that the first task starts + * executing. + */ +void vRestoreContextOfFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +BaseType_t xIsPrivileged( void ) __attribute__ (( naked )); + +/** + * @brief Raises the privilege level by clearing the bit 0 of the CONTROL + * register. + * + * @note This is a privileged function and should only be called from the kenrel + * code. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vRaisePrivilege( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vResetPrivilege( void ) __attribute__ (( naked )); + +/** + * @brief Starts the first task. + */ +void vStartFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Disables interrupts. + */ +uint32_t ulSetInterruptMaskFromISR( void ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Enables interrupts. + */ +void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief PendSV Exception handler. + */ +void PendSV_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief SVC Handler. + */ +void SVC_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Allocate a Secure context for the calling task. + * + * @param[in] ulSecureStackSize The size of the stack to be allocated on the + * secure side for the calling task. + */ +void vPortAllocateSecureContext( uint32_t ulSecureStackSize ) __attribute__ (( naked )); + +/** + * @brief Free the task's secure context. + * + * @param[in] pulTCB Pointer to the Task Control Block (TCB) of the task. + */ +void vPortFreeSecureContext( uint32_t *pulTCB ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +#endif /* __PORT_ASM_H__ */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23/non_secure/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM_CM23/non_secure/portmacro.h new file mode 100755 index 0000000..bbab1b7 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23/non_secure/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M23" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __attribute__(( used )) +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_context.c b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_context.c new file mode 100755 index 0000000..53535cd --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_context.c @@ -0,0 +1,204 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Secure context includes. */ +#include "secure_context.h" + +/* Secure heap includes. */ +#include "secure_heap.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief CONTROL value for privileged tasks. + * + * Bit[0] - 0 --> Thread mode is privileged. + * Bit[1] - 1 --> Thread mode uses PSP. + */ +#define securecontextCONTROL_VALUE_PRIVILEGED 0x02 + +/** + * @brief CONTROL value for un-privileged tasks. + * + * Bit[0] - 1 --> Thread mode is un-privileged. + * Bit[1] - 1 --> Thread mode uses PSP. + */ +#define securecontextCONTROL_VALUE_UNPRIVILEGED 0x03 +/*-----------------------------------------------------------*/ + +/** + * @brief Structure to represent secure context. + * + * @note Since stack grows down, pucStackStart is the highest address while + * pucStackLimit is the first addess of the allocated memory. + */ +typedef struct SecureContext +{ + uint8_t *pucCurrentStackPointer; /**< Current value of stack pointer (PSP). */ + uint8_t *pucStackLimit; /**< Last location of the stack memory (PSPLIM). */ + uint8_t *pucStackStart; /**< First location of the stack memory. */ +} SecureContext_t; +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_Init( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* No stack for thread mode until a task's context is loaded. */ + secureportSET_PSPLIM( securecontextNO_STACK ); + secureportSET_PSP( securecontextNO_STACK ); + + #if( configENABLE_MPU == 1 ) + { + /* Configure thread mode to use PSP and to be unprivileged. */ + secureportSET_CONTROL( securecontextCONTROL_VALUE_UNPRIVILEGED ); + } + #else /* configENABLE_MPU */ + { + /* Configure thread mode to use PSP and to be privileged.. */ + secureportSET_CONTROL( securecontextCONTROL_VALUE_PRIVILEGED ); + } + #endif /* configENABLE_MPU */ + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + secureportNON_SECURE_CALLABLE SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize, uint32_t ulIsTaskPrivileged ) +#else /* configENABLE_MPU */ + secureportNON_SECURE_CALLABLE SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize ) +#endif /* configENABLE_MPU */ +{ + uint8_t *pucStackMemory = NULL; + uint32_t ulIPSR; + SecureContextHandle_t xSecureContextHandle = NULL; + #if( configENABLE_MPU == 1 ) + uint32_t *pulCurrentStackPointer = NULL; + #endif /* configENABLE_MPU */ + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* Allocate the context structure. */ + xSecureContextHandle = ( SecureContextHandle_t ) pvPortMalloc( sizeof( SecureContext_t ) ); + + if( xSecureContextHandle != NULL ) + { + /* Allocate the stack space. */ + pucStackMemory = pvPortMalloc( ulSecureStackSize ); + + if( pucStackMemory != NULL ) + { + /* Since stack grows down, the starting point will be the last + * location. Note that this location is next to the last + * allocated byte because the hardware decrements the stack + * pointer before writing i.e. if stack pointer is 0x2, a push + * operation will decrement the stack pointer to 0x1 and then + * write at 0x1. */ + xSecureContextHandle->pucStackStart = pucStackMemory + ulSecureStackSize; + + /* The stack cannot go beyond this location. This value is + * programmed in the PSPLIM register on context switch.*/ + xSecureContextHandle->pucStackLimit = pucStackMemory; + + #if( configENABLE_MPU == 1 ) + { + /* Store the correct CONTROL value for the task on the stack. + * This value is programmed in the CONTROL register on + * context switch. */ + pulCurrentStackPointer = ( uint32_t * ) xSecureContextHandle->pucStackStart; + pulCurrentStackPointer--; + if( ulIsTaskPrivileged ) + { + *( pulCurrentStackPointer ) = securecontextCONTROL_VALUE_PRIVILEGED; + } + else + { + *( pulCurrentStackPointer ) = securecontextCONTROL_VALUE_UNPRIVILEGED; + } + + /* Store the current stack pointer. This value is programmed in + * the PSP register on context switch. */ + xSecureContextHandle->pucCurrentStackPointer = ( uint8_t * ) pulCurrentStackPointer; + } + #else /* configENABLE_MPU */ + { + /* Current SP is set to the starting of the stack. This + * value programmed in the PSP register on context switch. */ + xSecureContextHandle->pucCurrentStackPointer = xSecureContextHandle->pucStackStart; + + } + #endif /* configENABLE_MPU */ + } + else + { + /* Free the context to avoid memory leak and make sure to return + * NULL to indicate failure. */ + vPortFree( xSecureContextHandle ); + xSecureContextHandle = NULL; + } + } + } + + return xSecureContextHandle; +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_FreeContext( SecureContextHandle_t xSecureContextHandle ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* Ensure that valid parameters are passed. */ + secureportASSERT( xSecureContextHandle != NULL ); + + /* Free the stack space. */ + vPortFree( xSecureContextHandle->pucStackLimit ); + + /* Free the context itself. */ + vPortFree( xSecureContextHandle ); + } +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_context.h b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_context.h new file mode 100755 index 0000000..e148bff --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_context.h @@ -0,0 +1,111 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_CONTEXT_H__ +#define __SECURE_CONTEXT_H__ + +/* Standard includes. */ +#include + +/* FreeRTOS includes. */ +#include "FreeRTOSConfig.h" + +/** + * @brief PSP value when no task's context is loaded. + */ +#define securecontextNO_STACK 0x0 + +/** + * @brief Opaque handle. + */ +struct SecureContext; +typedef struct SecureContext* SecureContextHandle_t; +/*-----------------------------------------------------------*/ + +/** + * @brief Initializes the secure context management system. + * + * PSP is set to NULL and therefore a task must allocate and load a context + * before calling any secure side function in the thread mode. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureContext_Init( void ); + +/** + * @brief Allocates a context on the secure side. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] ulSecureStackSize Size of the stack to allocate on secure side. + * @param[in] ulIsTaskPrivileged 1 if the calling task is privileged, 0 otherwise. + * + * @return Opaque context handle if context is successfully allocated, NULL + * otherwise. + */ +#if( configENABLE_MPU == 1 ) + SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize, uint32_t ulIsTaskPrivileged ); +#else /* configENABLE_MPU */ + SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize ); +#endif /* configENABLE_MPU */ + +/** + * @brief Frees the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the + * context to be freed. + */ +void SecureContext_FreeContext( SecureContextHandle_t xSecureContextHandle ); + +/** + * @brief Loads the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the context + * to be loaded. + */ +void SecureContext_LoadContext( SecureContextHandle_t xSecureContextHandle ); + +/** + * @brief Saves the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the context + * to be saved. + */ +void SecureContext_SaveContext( SecureContextHandle_t xSecureContextHandle ); + +#endif /* __SECURE_CONTEXT_H__ */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_context_port.c b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_context_port.c new file mode 100755 index 0000000..e703498 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_context_port.c @@ -0,0 +1,91 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Secure context includes. */ +#include "secure_context.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +#if( configENABLE_FPU == 1 ) + #error Cortex-M23 does not have a Floating Point Unit (FPU) and therefore configENABLE_FPU must be set to 0. +#endif + +secureportNON_SECURE_CALLABLE void SecureContext_LoadContext( SecureContextHandle_t xSecureContextHandle ) +{ + /* xSecureContextHandle value is in r0. */ + __asm volatile + ( + " .syntax unified \n" + " \n" + " mrs r1, ipsr \n" /* r1 = IPSR. */ + " cbz r1, load_ctx_therad_mode \n" /* Do nothing if the processor is running in the Thread Mode. */ + " ldmia r0!, {r1, r2} \n" /* r1 = xSecureContextHandle->pucCurrentStackPointer, r2 = xSecureContextHandle->pucStackLimit. */ + #if( configENABLE_MPU == 1 ) + " ldmia r1!, {r3} \n" /* Read CONTROL register value from task's stack. r3 = CONTROL. */ + " msr control, r3 \n" /* CONTROL = r3. */ + #endif /* configENABLE_MPU */ + " msr psplim, r2 \n" /* PSPLIM = r2. */ + " msr psp, r1 \n" /* PSP = r1. */ + " \n" + " load_ctx_therad_mode: \n" + " nop \n" + " \n" + :::"r0", "r1", "r2" + ); +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_SaveContext( SecureContextHandle_t xSecureContextHandle ) +{ + /* xSecureContextHandle value is in r0. */ + __asm volatile + ( + " .syntax unified \n" + " \n" + " mrs r1, ipsr \n" /* r1 = IPSR. */ + " cbz r1, save_ctx_therad_mode \n" /* Do nothing if the processor is running in the Thread Mode. */ + " mrs r1, psp \n" /* r1 = PSP. */ + #if( configENABLE_MPU == 1 ) + " mrs r2, control \n" /* r2 = CONTROL. */ + " subs r1, r1, #4 \n" /* Make space for the CONTROL value on the stack. */ + " str r1, [r0] \n" /* Save the top of stack in context. xSecureContextHandle->pucCurrentStackPointer = r1. */ + " stmia r1!, {r2} \n" /* Store CONTROL value on the stack. */ + #else /* configENABLE_MPU */ + " str r1, [r0] \n" /* Save the top of stack in context. xSecureContextHandle->pucCurrentStackPointer = r1. */ + #endif /* configENABLE_MPU */ + " movs r1, %0 \n" /* r1 = securecontextNO_STACK. */ + " msr psplim, r1 \n" /* PSPLIM = securecontextNO_STACK. */ + " msr psp, r1 \n" /* PSP = securecontextNO_STACK i.e. No stack for thread mode until next task's context is loaded. */ + " \n" + " save_ctx_therad_mode: \n" + " nop \n" + " \n" + :: "i" ( securecontextNO_STACK ) : "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_heap.c b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_heap.c new file mode 100755 index 0000000..60fce5c --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_heap.c @@ -0,0 +1,450 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Secure context heap includes. */ +#include "secure_heap.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief Total heap size. + */ +#define secureconfigTOTAL_HEAP_SIZE ( ( ( size_t ) ( 10 * 1024 ) ) ) + +/* No test marker by default. */ +#ifndef mtCOVERAGE_TEST_MARKER + #define mtCOVERAGE_TEST_MARKER() +#endif + +/* No tracing by default. */ +#ifndef traceMALLOC + #define traceMALLOC( pvReturn, xWantedSize ) +#endif + +/* No tracing by default. */ +#ifndef traceFREE + #define traceFREE( pv, xBlockSize ) +#endif + +/* Block sizes must not get too small. */ +#define secureheapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) ) + +/* Assumes 8bit bytes! */ +#define secureheapBITS_PER_BYTE ( ( size_t ) 8 ) +/*-----------------------------------------------------------*/ + +/* Allocate the memory for the heap. */ +#if( configAPPLICATION_ALLOCATED_HEAP == 1 ) + /* The application writer has already defined the array used for the RTOS + * heap - probably so it can be placed in a special segment or address. */ + extern uint8_t ucHeap[ secureconfigTOTAL_HEAP_SIZE ]; +#else /* configAPPLICATION_ALLOCATED_HEAP */ + static uint8_t ucHeap[ secureconfigTOTAL_HEAP_SIZE ]; +#endif /* configAPPLICATION_ALLOCATED_HEAP */ + +/** + * @brief The linked list structure. + * + * This is used to link free blocks in order of their memory address. + */ +typedef struct A_BLOCK_LINK +{ + struct A_BLOCK_LINK *pxNextFreeBlock; /**< The next free block in the list. */ + size_t xBlockSize; /**< The size of the free block. */ +} BlockLink_t; +/*-----------------------------------------------------------*/ + +/** + * @brief Called automatically to setup the required heap structures the first + * time pvPortMalloc() is called. + */ +static void prvHeapInit( void ); + +/** + * @brief Inserts a block of memory that is being freed into the correct + * position in the list of free memory blocks. + * + * The block being freed will be merged with the block in front it and/or the + * block behind it if the memory blocks are adjacent to each other. + * + * @param[in] pxBlockToInsert The block being freed. + */ +static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ); +/*-----------------------------------------------------------*/ + +/** + * @brief The size of the structure placed at the beginning of each allocated + * memory block must by correctly byte aligned. + */ +static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( secureportBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + +/** + * @brief Create a couple of list links to mark the start and end of the list. + */ +static BlockLink_t xStart, *pxEnd = NULL; + +/** + * @brief Keeps track of the number of free bytes remaining, but says nothing + * about fragmentation. + */ +static size_t xFreeBytesRemaining = 0U; +static size_t xMinimumEverFreeBytesRemaining = 0U; + +/** + * @brief Gets set to the top bit of an size_t type. + * + * When this bit in the xBlockSize member of an BlockLink_t structure is set + * then the block belongs to the application. When the bit is free the block is + * still part of the free heap space. + */ +static size_t xBlockAllocatedBit = 0; +/*-----------------------------------------------------------*/ + +static void prvHeapInit( void ) +{ +BlockLink_t *pxFirstFreeBlock; +uint8_t *pucAlignedHeap; +size_t uxAddress; +size_t xTotalHeapSize = secureconfigTOTAL_HEAP_SIZE; + + /* Ensure the heap starts on a correctly aligned boundary. */ + uxAddress = ( size_t ) ucHeap; + + if( ( uxAddress & secureportBYTE_ALIGNMENT_MASK ) != 0 ) + { + uxAddress += ( secureportBYTE_ALIGNMENT - 1 ); + uxAddress &= ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + xTotalHeapSize -= uxAddress - ( size_t ) ucHeap; + } + + pucAlignedHeap = ( uint8_t * ) uxAddress; + + /* xStart is used to hold a pointer to the first item in the list of free + * blocks. The void cast is used to prevent compiler warnings. */ + xStart.pxNextFreeBlock = ( void * ) pucAlignedHeap; + xStart.xBlockSize = ( size_t ) 0; + + /* pxEnd is used to mark the end of the list of free blocks and is inserted + * at the end of the heap space. */ + uxAddress = ( ( size_t ) pucAlignedHeap ) + xTotalHeapSize; + uxAddress -= xHeapStructSize; + uxAddress &= ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + pxEnd = ( void * ) uxAddress; + pxEnd->xBlockSize = 0; + pxEnd->pxNextFreeBlock = NULL; + + /* To start with there is a single free block that is sized to take up the + * entire heap space, minus the space taken by pxEnd. */ + pxFirstFreeBlock = ( void * ) pucAlignedHeap; + pxFirstFreeBlock->xBlockSize = uxAddress - ( size_t ) pxFirstFreeBlock; + pxFirstFreeBlock->pxNextFreeBlock = pxEnd; + + /* Only one block exists - and it covers the entire usable heap space. */ + xMinimumEverFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; + xFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; + + /* Work out the position of the top bit in a size_t variable. */ + xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * secureheapBITS_PER_BYTE ) - 1 ); +} +/*-----------------------------------------------------------*/ + +static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ) +{ +BlockLink_t *pxIterator; +uint8_t *puc; + + /* Iterate through the list until a block is found that has a higher address + * than the block being inserted. */ + for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) + { + /* Nothing to do here, just iterate to the right position. */ + } + + /* Do the block being inserted, and the block it is being inserted after + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxIterator; + if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) + { + pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; + pxBlockToInsert = pxIterator; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Do the block being inserted, and the block it is being inserted before + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxBlockToInsert; + if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) + { + if( pxIterator->pxNextFreeBlock != pxEnd ) + { + /* Form one big block from the two blocks. */ + pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock; + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxEnd; + } + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; + } + + /* If the block being inserted plugged a gab, so was merged with the block + * before and the block after, then it's pxNextFreeBlock pointer will have + * already been set, and should not be set here as that would make it point + * to itself. */ + if( pxIterator != pxBlockToInsert ) + { + pxIterator->pxNextFreeBlock = pxBlockToInsert; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } +} +/*-----------------------------------------------------------*/ + +void *pvPortMalloc( size_t xWantedSize ) +{ +BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink; +void *pvReturn = NULL; + + /* If this is the first call to malloc then the heap will require + * initialisation to setup the list of free blocks. */ + if( pxEnd == NULL ) + { + prvHeapInit(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Check the requested block size is not so large that the top bit is set. + * The top bit of the block size member of the BlockLink_t structure is used + * to determine who owns the block - the application or the kernel, so it + * must be free. */ + if( ( xWantedSize & xBlockAllocatedBit ) == 0 ) + { + /* The wanted size is increased so it can contain a BlockLink_t + * structure in addition to the requested amount of bytes. */ + if( xWantedSize > 0 ) + { + xWantedSize += xHeapStructSize; + + /* Ensure that blocks are always aligned to the required number of + * bytes. */ + if( ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) != 0x00 ) + { + /* Byte alignment required. */ + xWantedSize += ( secureportBYTE_ALIGNMENT - ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) ); + secureportASSERT( ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) == 0 ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) + { + /* Traverse the list from the start (lowest address) block until + * one of adequate size is found. */ + pxPreviousBlock = &xStart; + pxBlock = xStart.pxNextFreeBlock; + while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) + { + pxPreviousBlock = pxBlock; + pxBlock = pxBlock->pxNextFreeBlock; + } + + /* If the end marker was reached then a block of adequate size was + * not found. */ + if( pxBlock != pxEnd ) + { + /* Return the memory space pointed to - jumping over the + * BlockLink_t structure at its start. */ + pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize ); + + /* This block is being returned for use so must be taken out + * of the list of free blocks. */ + pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; + + /* If the block is larger than required it can be split into + * two. */ + if( ( pxBlock->xBlockSize - xWantedSize ) > secureheapMINIMUM_BLOCK_SIZE ) + { + /* This block is to be split into two. Create a new + * block following the number of bytes requested. The void + * cast is used to prevent byte alignment warnings from the + * compiler. */ + pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize ); + secureportASSERT( ( ( ( size_t ) pxNewBlockLink ) & secureportBYTE_ALIGNMENT_MASK ) == 0 ); + + /* Calculate the sizes of two blocks split from the single + * block. */ + pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; + pxBlock->xBlockSize = xWantedSize; + + /* Insert the new block into the list of free blocks. */ + prvInsertBlockIntoFreeList( pxNewBlockLink ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + xFreeBytesRemaining -= pxBlock->xBlockSize; + + if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) + { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* The block is being returned - it is allocated and owned by + * the application and has no "next" block. */ + pxBlock->xBlockSize |= xBlockAllocatedBit; + pxBlock->pxNextFreeBlock = NULL; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + traceMALLOC( pvReturn, xWantedSize ); + + #if( secureconfigUSE_MALLOC_FAILED_HOOK == 1 ) + { + if( pvReturn == NULL ) + { + extern void vApplicationMallocFailedHook( void ); + vApplicationMallocFailedHook(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif + + secureportASSERT( ( ( ( size_t ) pvReturn ) & ( size_t ) secureportBYTE_ALIGNMENT_MASK ) == 0 ); + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void *pv ) +{ +uint8_t *puc = ( uint8_t * ) pv; +BlockLink_t *pxLink; + + if( pv != NULL ) + { + /* The memory being freed will have an BlockLink_t structure immediately + * before it. */ + puc -= xHeapStructSize; + + /* This casting is to keep the compiler from issuing warnings. */ + pxLink = ( void * ) puc; + + /* Check the block is actually allocated. */ + secureportASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ); + secureportASSERT( pxLink->pxNextFreeBlock == NULL ); + + if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) + { + if( pxLink->pxNextFreeBlock == NULL ) + { + /* The block is being returned to the heap - it is no longer + * allocated. */ + pxLink->xBlockSize &= ~xBlockAllocatedBit; + + secureportDISABLE_NON_SECURE_INTERRUPTS(); + { + /* Add this block to the list of free blocks. */ + xFreeBytesRemaining += pxLink->xBlockSize; + traceFREE( pv, pxLink->xBlockSize ); + prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) ); + } + secureportENABLE_NON_SECURE_INTERRUPTS(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } +} +/*-----------------------------------------------------------*/ + +size_t xPortGetFreeHeapSize( void ) +{ + return xFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +size_t xPortGetMinimumEverFreeHeapSize( void ) +{ + return xMinimumEverFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +void vPortInitialiseBlocks( void ) +{ + /* This just exists to keep the linker quiet. */ +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_heap.h b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_heap.h new file mode 100755 index 0000000..69e4f2a --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_heap.h @@ -0,0 +1,51 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_HEAP_H__ +#define __SECURE_HEAP_H__ + +/* Standard includes. */ +#include + +/** + * @brief Allocates memory from heap. + * + * @param[in] xWantedSize The size of the memory to be allocated. + * + * @return Pointer to the memory region if the allocation is successful, NULL + * otherwise. + */ +void *pvPortMalloc( size_t xWantedSize ); + +/** + * @brief Frees the previously allocated memory. + * + * @param[in] pv Pointer to the memory to be freed. + */ +void vPortFree( void *pv ); + +#endif /* __SECURE_HEAP_H__ */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_init.c b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_init.c new file mode 100755 index 0000000..c6525f7 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_init.c @@ -0,0 +1,105 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Secure init includes. */ +#include "secure_init.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief Constants required to manipulate the SCB. + */ +#define secureinitSCB_AIRCR ( ( volatile uint32_t * ) 0xe000ed0c ) /* Application Interrupt and Reset Control Register. */ +#define secureinitSCB_AIRCR_VECTKEY_POS ( 16UL ) +#define secureinitSCB_AIRCR_VECTKEY_MASK ( 0xFFFFUL << secureinitSCB_AIRCR_VECTKEY_POS ) +#define secureinitSCB_AIRCR_PRIS_POS ( 14UL ) +#define secureinitSCB_AIRCR_PRIS_MASK ( 1UL << secureinitSCB_AIRCR_PRIS_POS ) + +/** + * @brief Constants required to manipulate the FPU. + */ +#define secureinitFPCCR ( ( volatile uint32_t * ) 0xe000ef34 ) /* Floating Point Context Control Register. */ +#define secureinitFPCCR_LSPENS_POS ( 29UL ) +#define secureinitFPCCR_LSPENS_MASK ( 1UL << secureinitFPCCR_LSPENS_POS ) +#define secureinitFPCCR_TS_POS ( 26UL ) +#define secureinitFPCCR_TS_MASK ( 1UL << secureinitFPCCR_TS_POS ) + +#define secureinitNSACR ( ( volatile uint32_t * ) 0xe000ed8c ) /* Non-secure Access Control Register. */ +#define secureinitNSACR_CP10_POS ( 10UL ) +#define secureinitNSACR_CP10_MASK ( 1UL << secureinitNSACR_CP10_POS ) +#define secureinitNSACR_CP11_POS ( 11UL ) +#define secureinitNSACR_CP11_MASK ( 1UL << secureinitNSACR_CP11_POS ) +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureInit_DePrioritizeNSExceptions( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + *( secureinitSCB_AIRCR ) = ( *( secureinitSCB_AIRCR ) & ~( secureinitSCB_AIRCR_VECTKEY_MASK | secureinitSCB_AIRCR_PRIS_MASK ) ) | + ( ( 0x05FAUL << secureinitSCB_AIRCR_VECTKEY_POS ) & secureinitSCB_AIRCR_VECTKEY_MASK ) | + ( ( 0x1UL << secureinitSCB_AIRCR_PRIS_POS ) & secureinitSCB_AIRCR_PRIS_MASK ); + } +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureInit_EnableNSFPUAccess( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* CP10 = 1 ==> Non-secure access to the Floating Point Unit is + * permitted. CP11 should be programmed to the same value as CP10. */ + *( secureinitNSACR ) |= ( secureinitNSACR_CP10_MASK | secureinitNSACR_CP11_MASK ); + + /* LSPENS = 0 ==> LSPEN is writable fron non-secure state. This ensures + * that we can enable/disable lazy stacking in port.c file. */ + *( secureinitFPCCR ) &= ~ ( secureinitFPCCR_LSPENS_MASK ); + + /* TS = 1 ==> Treat FP registers as secure i.e. callee saved FP + * registers (S16-S31) are also pushed to stack on exception entry and + * restored on exception return. */ + *( secureinitFPCCR ) |= ( secureinitFPCCR_TS_MASK ); + } +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_init.h b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_init.h new file mode 100755 index 0000000..6c5bc71 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_init.h @@ -0,0 +1,53 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_INIT_H__ +#define __SECURE_INIT_H__ + +/** + * @brief De-prioritizes the non-secure exceptions. + * + * This is needed to ensure that the non-secure PendSV runs at the lowest + * priority. Context switch is done in the non-secure PendSV handler. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureInit_DePrioritizeNSExceptions( void ); + +/** + * @brief Sets up the Floating Point Unit (FPU) for Non-Secure access. + * + * Also sets FPCCR.TS=1 to ensure that the content of the Floating Point + * Registers are not leaked to the non-secure side. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureInit_EnableNSFPUAccess( void ); + +#endif /* __SECURE_INIT_H__ */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_port_macros.h b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_port_macros.h new file mode 100755 index 0000000..760edab --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23/secure/secure_port_macros.h @@ -0,0 +1,133 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_PORT_MACROS_H__ +#define __SECURE_PORT_MACROS_H__ + +/** + * @brief Byte alignment requirements. + */ +#define secureportBYTE_ALIGNMENT 8 +#define secureportBYTE_ALIGNMENT_MASK ( 0x0007 ) + +/** + * @brief Macro to declare a function as non-secure callable. + */ +#if defined( __IAR_SYSTEMS_ICC__ ) + #define secureportNON_SECURE_CALLABLE __cmse_nonsecure_entry __root +#else + #define secureportNON_SECURE_CALLABLE __attribute__((cmse_nonsecure_entry)) __attribute__((used)) +#endif + +/** + * @brief Set the secure PRIMASK value. + */ +#define secureportSET_SECURE_PRIMASK( ulPrimaskValue ) \ + __asm volatile ( "msr primask, %0" : : "r" ( ulPrimaskValue ) : "memory" ) + +/** + * @brief Set the non-secure PRIMASK value. + */ +#define secureportSET_NON_SECURE_PRIMASK( ulPrimaskValue ) \ + __asm volatile ( "msr primask_ns, %0" : : "r" ( ulPrimaskValue ) : "memory" ) + +/** + * @brief Read the PSP value in the given variable. + */ +#define secureportREAD_PSP( pucOutCurrentStackPointer ) \ + __asm volatile ( "mrs %0, psp" : "=r" ( pucOutCurrentStackPointer ) ) + +/** + * @brief Set the PSP to the given value. + */ +#define secureportSET_PSP( pucCurrentStackPointer ) \ + __asm volatile ( "msr psp, %0" : : "r" ( pucCurrentStackPointer ) ) + +/** + * @brief Set the PSPLIM to the given value. + */ +#define secureportSET_PSPLIM( pucStackLimit ) \ + __asm volatile ( "msr psplim, %0" : : "r" ( pucStackLimit ) ) + +/** + * @brief Set the NonSecure MSP to the given value. + */ +#define secureportSET_MSP_NS( pucMainStackPointer ) \ + __asm volatile ( "msr msp_ns, %0" : : "r" ( pucMainStackPointer ) ) + +/** + * @brief Set the CONTROL register to the given value. + */ +#define secureportSET_CONTROL( ulControl ) \ + __asm volatile ( "msr control, %0" : : "r" ( ulControl ) : "memory" ) + +/** + * @brief Read the Interrupt Program Status Register (IPSR) value in the given + * variable. + */ +#define secureportREAD_IPSR( ulIPSR ) \ + __asm volatile ( "mrs %0, ipsr" : "=r" ( ulIPSR ) ) + +/** + * @brief PRIMASK value to enable interrupts. + */ +#define secureportPRIMASK_ENABLE_INTERRUPTS_VAL 0 + +/** + * @brief PRIMASK value to disable interrupts. + */ +#define secureportPRIMASK_DISABLE_INTERRUPTS_VAL 1 + +/** + * @brief Disable secure interrupts. + */ +#define secureportDISABLE_SECURE_INTERRUPTS() secureportSET_SECURE_PRIMASK( secureportPRIMASK_DISABLE_INTERRUPTS_VAL ) + +/** + * @brief Disable non-secure interrupts. + * + * This effectively disables context switches. + */ +#define secureportDISABLE_NON_SECURE_INTERRUPTS() secureportSET_NON_SECURE_PRIMASK( secureportPRIMASK_DISABLE_INTERRUPTS_VAL ) + +/** + * @brief Enable non-secure interrupts. + */ +#define secureportENABLE_NON_SECURE_INTERRUPTS() secureportSET_NON_SECURE_PRIMASK( secureportPRIMASK_ENABLE_INTERRUPTS_VAL ) + +/** + * @brief Assert definition. + */ +#define secureportASSERT( x ) \ + if( ( x ) == 0 ) \ + { \ + secureportDISABLE_SECURE_INTERRUPTS(); \ + secureportDISABLE_NON_SECURE_INTERRUPTS(); \ + for( ;; ); \ + } + +#endif /* __SECURE_PORT_MACROS_H__ */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23_NTZ/non_secure/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM23_NTZ/non_secure/port.c new file mode 100755 index 0000000..bd85a6f --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23_NTZ/non_secure/port.c @@ -0,0 +1,899 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/* Portasm includes. */ +#include "portasm.h" + +#if( configENABLE_TRUSTZONE == 1 ) + /* Secure components includes. */ + #include "secure_context.h" + #include "secure_init.h" +#endif /* configENABLE_TRUSTZONE */ + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/** + * The FreeRTOS Cortex M33 port can be configured to run on the Secure Side only + * i.e. the processor boots as secure and never jumps to the non-secure side. + * The Trust Zone support in the port must be disabled in order to run FreeRTOS + * on the secure side. The following are the valid configuration seetings: + * + * 1. Run FreeRTOS on the Secure Side: + * configRUN_FREERTOS_SECURE_ONLY = 1 and configENABLE_TRUSTZONE = 0 + * + * 2. Run FreeRTOS on the Non-Secure Side with Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 1 + * + * 3. Run FreeRTOS on the Non-Secure Side only i.e. no Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 0 + */ +#if( ( configRUN_FREERTOS_SECURE_ONLY == 1 ) && ( configENABLE_TRUSTZONE == 1 ) ) + #error TrustZone needs to be disabled in order to run FreeRTOS on the Secure Side. +#endif +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the NVIC. + */ +#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t * ) 0xe000e010 ) +#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t * ) 0xe000e014 ) +#define portNVIC_SYSTICK_CURRENT_VALUE ( ( volatile uint32_t * ) 0xe000e018 ) +#define portNVIC_INT_CTRL ( ( volatile uint32_t * ) 0xe000ed04 ) +#define portNVIC_SYSPRI2 ( ( volatile uint32_t * ) 0xe000ed20 ) +#define portNVIC_SYSTICK_CLK ( 0x00000004 ) +#define portNVIC_SYSTICK_INT ( 0x00000002 ) +#define portNVIC_SYSTICK_ENABLE ( 0x00000001 ) +#define portNVIC_PENDSVSET ( 0x10000000 ) +#define portMIN_INTERRUPT_PRIORITY ( 255UL ) +#define portNVIC_PENDSV_PRI ( portMIN_INTERRUPT_PRIORITY << 16UL ) +#define portNVIC_SYSTICK_PRI ( portMIN_INTERRUPT_PRIORITY << 24UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the SCB. + */ +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( * ( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_MEM_FAULT_ENABLE ( 1UL << 16UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the FPU. + */ +#define portCPACR ( ( volatile uint32_t * ) 0xe000ed88 ) /* Coprocessor Access Control Register. */ +#define portCPACR_CP10_VALUE ( 3UL ) +#define portCPACR_CP11_VALUE portCPACR_CP10_VALUE +#define portCPACR_CP10_POS ( 20UL ) +#define portCPACR_CP11_POS ( 22UL ) + +#define portFPCCR ( ( volatile uint32_t * ) 0xe000ef34 ) /* Floating Point Context Control Register. */ +#define portFPCCR_ASPEN_POS ( 31UL ) +#define portFPCCR_ASPEN_MASK ( 1UL << portFPCCR_ASPEN_POS ) +#define portFPCCR_LSPEN_POS ( 30UL ) +#define portFPCCR_LSPEN_MASK ( 1UL << portFPCCR_LSPEN_POS ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the MPU. + */ +#define portMPU_TYPE_REG ( * ( ( volatile uint32_t * ) 0xe000ed90 ) ) +#define portMPU_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed94 ) ) +#define portMPU_RNR_REG ( * ( ( volatile uint32_t * ) 0xe000ed98 ) ) + +#define portMPU_RBAR_REG ( * ( ( volatile uint32_t * ) 0xe000ed9c ) ) +#define portMPU_RLAR_REG ( * ( ( volatile uint32_t * ) 0xe000eda0 ) ) + +#define portMPU_RBAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda4 ) ) +#define portMPU_RLAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda8 ) ) + +#define portMPU_RBAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edac ) ) +#define portMPU_RLAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edb0 ) ) + +#define portMPU_RBAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb4 ) ) +#define portMPU_RLAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb8 ) ) + +#define portMPU_MAIR0_REG ( * ( ( volatile uint32_t * ) 0xe000edc0 ) ) +#define portMPU_MAIR1_REG ( * ( ( volatile uint32_t * ) 0xe000edc4 ) ) + +#define portMPU_RBAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ +#define portMPU_RLAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ + +#define portMPU_MAIR_ATTR0_POS ( 0UL ) +#define portMPU_MAIR_ATTR0_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR1_POS ( 8UL ) +#define portMPU_MAIR_ATTR1_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR2_POS ( 16UL ) +#define portMPU_MAIR_ATTR2_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR3_POS ( 24UL ) +#define portMPU_MAIR_ATTR3_MASK ( 0xff000000 ) + +#define portMPU_MAIR_ATTR4_POS ( 0UL ) +#define portMPU_MAIR_ATTR4_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR5_POS ( 8UL ) +#define portMPU_MAIR_ATTR5_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR6_POS ( 16UL ) +#define portMPU_MAIR_ATTR6_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR7_POS ( 24UL ) +#define portMPU_MAIR_ATTR7_MASK ( 0xff000000 ) + +#define portMPU_RLAR_ATTR_INDEX0 ( 0UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX1 ( 1UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX2 ( 2UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX3 ( 3UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX4 ( 4UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX5 ( 5UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX6 ( 6UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX7 ( 7UL << 1UL ) + +#define portMPU_RLAR_REGION_ENABLE ( 1UL ) + +/* Enable privileged access to unmapped region. */ +#define portMPU_PRIV_BACKGROUND_ENABLE ( 1UL << 2UL ) + +/* Enable MPU. */ +#define portMPU_ENABLE ( 1UL << 0UL ) + +/* Expected value of the portMPU_TYPE register. */ +#define portEXPECTED_MPU_TYPE_VALUE ( 8UL << 8UL ) /* 8 regions, unified. */ +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to set up the initial stack. + */ +#define portINITIAL_XPSR ( 0x01000000 ) + +#if( configRUN_FREERTOS_SECURE_ONLY == 1 ) + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF FD + * 1111 1111 1111 1111 1111 1111 1111 1101 + * + * Bit[6] - 1 --> The exception was taken from the Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 1 --> The exception was taken to the Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xfffffffd ) +#else + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF BC + * 1111 1111 1111 1111 1111 1111 1011 1100 + * + * Bit[6] - 0 --> The exception was taken from the Non-Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 0 --> The exception was taken to the Non-Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xffffffbc ) +#endif /* configRUN_FREERTOS_SECURE_ONLY */ + +/** + * @brief CONTROL register privileged bit mask. + * + * Bit[0] in CONTROL register tells the privilege: + * Bit[0] = 0 ==> The task is privileged. + * Bit[0] = 1 ==> The task is not privileged. + */ +#define portCONTROL_PRIVILEGED_MASK ( 1UL << 0UL ) + +/** + * @brief Initial CONTROL register values. + */ +#define portINITIAL_CONTROL_UNPRIVILEGED ( 0x3 ) +#define portINITIAL_CONTROL_PRIVILEGED ( 0x2 ) + +/** + * @brief Let the user override the pre-loading of the initial LR with the + * address of prvTaskExitError() in case it messes up unwinding of the stack + * in the debugger. + */ +#ifdef configTASK_RETURN_ADDRESS + #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS +#else + #define portTASK_RETURN_ADDRESS prvTaskExitError +#endif + +/** + * @brief If portPRELOAD_REGISTERS then registers will be given an initial value + * when a task is created. This helps in debugging at the cost of code size. + */ +#define portPRELOAD_REGISTERS 1 + +/** + * @brief A task is created without a secure context, and must call + * portALLOCATE_SECURE_CONTEXT() to give itself a secure context before it makes + * any secure calls. + */ +#define portNO_SECURE_CONTEXT 0 +/*-----------------------------------------------------------*/ + +/** + * @brief Setup the timer to generate the tick interrupts. + */ +static void prvSetupTimerInterrupt( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Used to catch tasks that attempt to return from their implementing + * function. + */ +static void prvTaskExitError( void ); + +#if( configENABLE_MPU == 1 ) + /** + * @brief Setup the Memory Protection Unit (MPU). + */ + static void prvSetupMPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_MPU */ + +#if( configENABLE_FPU == 1 ) + /** + * @brief Setup the Floating Point Unit (FPU). + */ + static void prvSetupFPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_FPU */ + +/** + * @brief Yield the processor. + */ +void vPortYield( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Enter critical section. + */ +void vPortEnterCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Exit from critical section. + */ +void vPortExitCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief SysTick handler. + */ +void SysTick_Handler( void ) PRIVILEGED_FUNCTION; + +/** + * @brief C part of SVC handler. + */ +portDONT_DISCARD void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) PRIVILEGED_FUNCTION; +/*-----------------------------------------------------------*/ + +/** + * @brief Each task maintains its own interrupt status in the critical nesting + * variable. + */ +static volatile uint32_t ulCriticalNesting = 0xaaaaaaaaUL; + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Saved as part of the task context to indicate which context the + * task is using on the secure side. + */ + portDONT_DISCARD volatile SecureContextHandle_t xSecureContext = portNO_SECURE_CONTEXT; +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +static void prvSetupTimerInterrupt( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Stop and reset the SysTick. */ + *( portNVIC_SYSTICK_CTRL ) = 0UL; + *( portNVIC_SYSTICK_CURRENT_VALUE ) = 0UL; + + /* Configure SysTick to interrupt at the requested rate. */ + *( portNVIC_SYSTICK_LOAD ) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; + *( portNVIC_SYSTICK_CTRL ) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE; +} +/*-----------------------------------------------------------*/ + +static void prvTaskExitError( void ) +{ +volatile uint32_t ulDummy = 0UL; + + /* A function that implements a task must not exit or attempt to return to + * its caller as there is nothing to return to. If a task wants to exit it + * should instead call vTaskDelete( NULL ). Artificially force an assert() + * to be triggered if configASSERT() is defined, then stop here so + * application writers can catch the error. */ + configASSERT( ulCriticalNesting == ~0UL ); + portDISABLE_INTERRUPTS(); + + while( ulDummy == 0 ) + { + /* This file calls prvTaskExitError() after the scheduler has been + * started to remove a compiler warning about the function being + * defined but never called. ulDummy is used purely to quieten other + * warnings about code appearing after this function is called - making + * ulDummy volatile makes the compiler think the function could return + * and therefore not output an 'unreachable code' warning for code that + * appears after it. */ + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + static void prvSetupMPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __privileged_functions_start__; + extern uint32_t * __privileged_functions_end__; + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + extern uint32_t * __unprivileged_flash_start__; + extern uint32_t * __unprivileged_flash_end__; + extern uint32_t * __privileged_sram_start__; + extern uint32_t * __privileged_sram_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __privileged_functions_start__[]; + extern uint32_t __privileged_functions_end__[]; + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + extern uint32_t __unprivileged_flash_start__[]; + extern uint32_t __unprivileged_flash_end__[]; + extern uint32_t __privileged_sram_start__[]; + extern uint32_t __privileged_sram_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ + + /* Check that the MPU is present. */ + if( portMPU_TYPE_REG == portEXPECTED_MPU_TYPE_VALUE ) + { + /* MAIR0 - Index 0. */ + portMPU_MAIR0_REG |= ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + /* MAIR0 - Index 1. */ + portMPU_MAIR0_REG |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* Setup privileged flash as Read Only so that privileged tasks can + * read it but not modify. */ + portMPU_RNR_REG = portPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_functions_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_functions_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged flash as Read Only by both privileged and + * unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __unprivileged_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __unprivileged_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged syscalls flash as Read Only by both privileged + * and unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_SYSCALLS_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __syscalls_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __syscalls_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup RAM containing kernel data for privileged access only. */ + portMPU_RNR_REG = portPRIVILEGED_RAM_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_sram_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_sram_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Enable mem fault. */ + portSCB_SYS_HANDLER_CTRL_STATE_REG |= portSCB_MEM_FAULT_ENABLE; + + /* Enable MPU with privileged background access i.e. unmapped + * regions have privileged access. */ + portMPU_CTRL_REG |= ( portMPU_PRIV_BACKGROUND_ENABLE | portMPU_ENABLE ); + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_FPU == 1 ) + static void prvSetupFPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* Enable non-secure access to the FPU. */ + SecureInit_EnableNSFPUAccess(); + } + #endif /* configENABLE_TRUSTZONE */ + + /* CP10 = 11 ==> Full access to FPU i.e. both privileged and + * unprivileged code should be able to access FPU. CP11 should be + * programmed to the same value as CP10. */ + *( portCPACR ) |= ( ( portCPACR_CP10_VALUE << portCPACR_CP10_POS ) | + ( portCPACR_CP11_VALUE << portCPACR_CP11_POS ) + ); + + /* ASPEN = 1 ==> Hardware should automatically preserve floating point + * context on exception entry and restore on exception return. + * LSPEN = 1 ==> Enable lazy context save of FP state. */ + *( portFPCCR ) |= ( portFPCCR_ASPEN_MASK | portFPCCR_LSPEN_MASK ); + } +#endif /* configENABLE_FPU */ +/*-----------------------------------------------------------*/ + +void vPortYield( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Set a PendSV to request a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + portDISABLE_INTERRUPTS(); + ulCriticalNesting++; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + configASSERT( ulCriticalNesting ); + ulCriticalNesting--; + + if( ulCriticalNesting == 0 ) + { + portENABLE_INTERRUPTS(); + } +} +/*-----------------------------------------------------------*/ + +void SysTick_Handler( void ) /* PRIVILEGED_FUNCTION */ +{ +uint32_t ulPreviousMask; + + ulPreviousMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* Increment the RTOS tick. */ + if( xTaskIncrementTick() != pdFALSE ) + { + /* Pend a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulPreviousMask ); +} +/*-----------------------------------------------------------*/ + +void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) /* PRIVILEGED_FUNCTION portDONT_DISCARD */ +{ +#if( configENABLE_MPU == 1 ) + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ +#endif /* configENABLE_MPU */ + +uint32_t ulPC; + +#if( configENABLE_TRUSTZONE == 1 ) + uint32_t ulR0; + #if( configENABLE_MPU == 1 ) + uint32_t ulControl, ulIsTaskPrivileged; + #endif /* configENABLE_MPU */ +#endif /* configENABLE_TRUSTZONE */ +uint8_t ucSVCNumber; + + /* Register are stored on the stack in the following order - R0, R1, R2, R3, + * R12, LR, PC, xPSR. */ + ulPC = pulCallerStackAddress[ 6 ]; + ucSVCNumber = ( ( uint8_t *) ulPC )[ -2 ]; + + switch( ucSVCNumber ) + { + #if( configENABLE_TRUSTZONE == 1 ) + case portSVC_ALLOCATE_SECURE_CONTEXT: + { + /* R0 contains the stack size passed as parameter to the + * vPortAllocateSecureContext function. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + #if( configENABLE_MPU == 1 ) + { + /* Read the CONTROL register value. */ + __asm volatile ( "mrs %0, control" : "=r" ( ulControl ) ); + + /* The task that raised the SVC is privileged if Bit[0] + * in the CONTROL register is 0. */ + ulIsTaskPrivileged = ( ( ulControl & portCONTROL_PRIVILEGED_MASK ) == 0 ); + + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0, ulIsTaskPrivileged ); + } + #else + { + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0 ); + } + #endif /* configENABLE_MPU */ + + configASSERT( xSecureContext != NULL ); + SecureContext_LoadContext( xSecureContext ); + } + break; + + case portSVC_FREE_SECURE_CONTEXT: + { + /* R0 contains the secure context handle to be freed. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + /* Free the secure context. */ + SecureContext_FreeContext( ( SecureContextHandle_t ) ulR0 ); + } + break; + #endif /* configENABLE_TRUSTZONE */ + + case portSVC_START_SCHEDULER: + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* De-prioritize the non-secure exceptions so that the + * non-secure pendSV runs at the lowest priority. */ + SecureInit_DePrioritizeNSExceptions(); + + /* Initialize the secure context management system. */ + SecureContext_Init(); + } + #endif /* configENABLE_TRUSTZONE */ + + #if( configENABLE_FPU == 1 ) + { + /* Setup the Floating Point Unit (FPU). */ + prvSetupFPU(); + } + #endif /* configENABLE_FPU */ + + /* Setup the context of the first task so that the first task starts + * executing. */ + vRestoreContextOfFirstTask(); + } + break; + + #if( configENABLE_MPU == 1 ) + case portSVC_RAISE_PRIVILEGE: + { + /* Only raise the privilege, if the svc was raised from any of + * the system calls. */ + if( ulPC >= ( uint32_t ) __syscalls_flash_start__ && + ulPC <= ( uint32_t ) __syscalls_flash_end__ ) + { + vRaisePrivilege(); + } + } + break; + #endif /* configENABLE_MPU */ + + default: + { + /* Incorrect SVC call. */ + configASSERT( pdFALSE ); + } + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) /* PRIVILEGED_FUNCTION */ +#else + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) /* PRIVILEGED_FUNCTION */ +#endif /* configENABLE_MPU */ +{ + /* Simulate the stack frame as it would be created by a context switch + * interrupt. */ + #if( portPRELOAD_REGISTERS == 0 ) + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack -= 9; /* R11..R4, EXC_RETURN. */ + *pxTopOfStack = portINITIAL_EXC_RETURN; + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #else /* portPRELOAD_REGISTERS */ + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x12121212UL; /* R12 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x03030303UL; /* R3 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x02020202UL; /* R2 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x01010101UL; /* R1 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x11111111UL; /* R11 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x10101010UL; /* R10 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x09090909UL; /* R09 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x08080808UL; /* R08 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x07070707UL; /* R07 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x06060606UL; /* R06 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x05050505UL; /* R05 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x04040404UL; /* R04 */ + pxTopOfStack--; + *pxTopOfStack = portINITIAL_EXC_RETURN; /* EXC_RETURN */ + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #endif /* portPRELOAD_REGISTERS */ + + return pxTopOfStack; +} +/*-----------------------------------------------------------*/ + +BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + *( portNVIC_SYSPRI2 ) |= portNVIC_PENDSV_PRI; + *( portNVIC_SYSPRI2 ) |= portNVIC_SYSTICK_PRI; + + #if( configENABLE_MPU == 1 ) + { + /* Setup the Memory Protection Unit (MPU). */ + prvSetupMPU(); + } + #endif /* configENABLE_MPU */ + + /* Start the timer that generates the tick ISR. Interrupts are disabled + * here already. */ + prvSetupTimerInterrupt(); + + /* Initialize the critical nesting count ready for the first task. */ + ulCriticalNesting = 0; + + /* Start the first task. */ + vStartFirstTask(); + + /* Should never get here as the tasks will now be executing. Call the task + * exit error function to prevent compiler warnings about a static function + * not being called in the case that the application writer overrides this + * functionality by defining configTASK_RETURN_ADDRESS. Call + * vTaskSwitchContext() so link time optimization does not remove the + * symbol. */ + vTaskSwitchContext(); + prvTaskExitError(); + + /* Should not get here. */ + return 0; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Not implemented in ports where there is nothing to return to. + * Artificially force an assert. */ + configASSERT( ulCriticalNesting == 1000UL ); +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) + { + uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber; + int32_t lIndex = 0; + + /* Setup MAIR0. */ + xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + xMPUSettings->ulMAIR0 |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* This function is called automatically when the task is created - in + * which case the stack region parameters will be valid. At all other + * times the stack parameters will not be valid and it is assumed that + * the stack region has already been configured. */ + if( ulStackDepth > 0 ) + { + /* Define the region that allows access to the stack. */ + ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + + xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + } + + /* User supplied configurable regions. */ + for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ ) + { + /* If xRegions is NULL i.e. the task has not specified any MPU + * region, the else part ensures that all the configurable MPU + * regions are invalidated. */ + if( ( xRegions != NULL ) && ( xRegions[ lIndex ].ulLengthInBytes > 0UL ) ) + { + /* Translate the generic region definition contained in xRegions + * into the ARMv8 specific MPU settings that are then stored in + * xMPUSettings. */ + ulRegionStartAddress = ( ( uint32_t ) xRegions[ lIndex ].pvBaseAddress ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) xRegions[ lIndex ].pvBaseAddress + xRegions[ lIndex ].ulLengthInBytes - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + /* Start address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ); + + /* RO/RW. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_READ_ONLY ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_ONLY ); + } + else + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_WRITE ); + } + + /* XN. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_EXECUTE_NEVER ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_EXECUTE_NEVER ); + } + + /* End Address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Normal memory/ Device memory. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_DEVICE_MEMORY ) != 0 ) + { + /* Attr1 in MAIR0 is configured as device memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX1; + } + else + { + /* Attr1 in MAIR0 is configured as normal memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX0; + } + } + else + { + /* Invalidate the region. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = 0UL; + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = 0UL; + } + + lIndex++; + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.c b/FreeRTOS/Source/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.c new file mode 100755 index 0000000..5b8e604 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.c @@ -0,0 +1,381 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE ensures that PRIVILEGED_FUNCTION + * is defined correctly and privileged functions are placed in correct sections. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Portasm includes. */ +#include "portasm.h" + +/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE is needed to be defined only for the + * header files. */ +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +#if( configENABLE_FPU == 1 ) + #error Cortex-M23 does not have a Floating Point Unit (FPU) and therefore configENABLE_FPU must be set to 0. +#endif + +void vRestoreContextOfFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " \n" + " ldr r2, pxCurrentTCBConst2 \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r1, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r0, [r1] \n" /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r3, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r4, #1 \n" /* r4 = 1. */ + " bics r3, r4 \n" /* r3 = r3 & ~r4 i.e. Clear the bit 0 in r3. */ + " str r3, [r2] \n" /* Disable MPU. */ + " \n" + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + " ldr r4, [r1] \n" /* r4 = *r1 i.e. r4 = MAIR0. */ + " ldr r2, xMAIR0Const2 \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r4, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst2 \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + " movs r4, #4 \n" /* r4 = 4. */ + " str r4, [r2] \n" /* Program RNR = 4. */ + " ldmia r1!, {r5,r6} \n" /* Read first set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst2 \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write first set of RBAR/RLAR registers. */ + " movs r4, #5 \n" /* r4 = 5. */ + " str r4, [r2] \n" /* Program RNR = 5. */ + " ldmia r1!, {r5,r6} \n" /* Read second set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst2 \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write second set of RBAR/RLAR registers. */ + " movs r4, #6 \n" /* r4 = 6. */ + " str r4, [r2] \n" /* Program RNR = 6. */ + " ldmia r1!, {r5,r6} \n" /* Read third set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst2 \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write third set of RBAR/RLAR registers. */ + " movs r4, #7 \n" /* r4 = 7. */ + " str r4, [r2] \n" /* Program RNR = 7. */ + " ldmia r1!, {r5,r6} \n" /* Read fourth set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst2 \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write fourth set of RBAR/RLAR registers. */ + " \n" + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r3, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r4, #1 \n" /* r4 = 1. */ + " orrs r3, r4 \n" /* r3 = r3 | r4 i.e. Set the bit 0 in r3. */ + " str r3, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " ldm r0!, {r1-r3} \n" /* Read from stack - r1 = PSPLIM, r2 = CONTROL and r3 = EXC_RETURN. */ + " msr psplim, r1 \n" /* Set this task's PSPLIM value. */ + " msr control, r2 \n" /* Set this task's CONTROL value. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r3 \n" /* Finally, branch to EXC_RETURN. */ + #else /* configENABLE_MPU */ + " ldm r0!, {r1-r2} \n" /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ + " msr psplim, r1 \n" /* Set this task's PSPLIM value. */ + " movs r1, #2 \n" /* r1 = 2. */ + " msr CONTROL, r1 \n" /* Switch to use PSP in the thread mode. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r2 \n" /* Finally, branch to EXC_RETURN. */ + #endif /* configENABLE_MPU */ + " \n" + " .align 4 \n" + "pxCurrentTCBConst2: .word pxCurrentTCB \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst2: .word 0xe000ed94 \n" + "xMAIR0Const2: .word 0xe000edc0 \n" + "xRNRConst2: .word 0xe000ed98 \n" + "xRBARConst2: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " movs r1, #1 \n" /* r1 = 1. */ + " tst r0, r1 \n" /* Perform r0 & r1 (bitwise AND) and update the conditions flag. */ + " beq running_privileged \n" /* If the result of previous AND operation was 0, branch. */ + " movs r0, #0 \n" /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + " bx lr \n" /* Return. */ + " running_privileged: \n" + " movs r0, #1 \n" /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + " bx lr \n" /* Return. */ + " \n" + " .align 4 \n" + ::: "r0", "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vRaisePrivilege( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, control \n" /* Read the CONTROL register. */ + " movs r1, #1 \n" /* r1 = 1. */ + " bics r0, r1 \n" /* Clear the bit 0. */ + " msr control, r0 \n" /* Write back the new CONTROL value. */ + " bx lr \n" /* Return to the caller. */ + ::: "r0", "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vResetPrivilege( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " movs r1, #1 \n" /* r1 = 1. */ + " orrs r0, r1 \n" /* r0 = r0 | r1. */ + " msr control, r0 \n" /* CONTROL = r0. */ + " bx lr \n" /* Return to the caller. */ + :::"r0", "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vStartFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " ldr r0, xVTORConst \n" /* Use the NVIC offset register to locate the stack. */ + " ldr r0, [r0] \n" /* Read the VTOR register which gives the address of vector table. */ + " ldr r0, [r0] \n" /* The first entry in vector table is stack pointer. */ + " msr msp, r0 \n" /* Set the MSP back to the start of the stack. */ + " cpsie i \n" /* Globally enable interrupts. */ + " dsb \n" + " isb \n" + " svc %0 \n" /* System call to start the first task. */ + " nop \n" + " \n" + " .align 4 \n" + "xVTORConst: .word 0xe000ed08 \n" + :: "i" ( portSVC_START_SCHEDULER ) : "memory" + ); +} +/*-----------------------------------------------------------*/ + +uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, PRIMASK \n" + " cpsid i \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* To avoid compiler warnings. The return statement will never be reached, + * but some compilers warn if it is not included, while others won't compile + * if it is. */ + return 0; +#endif +} +/*-----------------------------------------------------------*/ + +void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " msr PRIMASK, r0 \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* Just to avoid compiler warning. ulMask is used from the asm code but + * the compiler can't see that. Some compilers generate warnings without + * the following line, while others generate warnings if the line is + * included. */ + ( void ) ulMask; +#endif +} +/*-----------------------------------------------------------*/ + +void PendSV_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " \n" + " mrs r0, psp \n" /* Read PSP in r0. */ + " ldr r2, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r1, [r2] \n" /* Read pxCurrentTCB. */ + #if( configENABLE_MPU == 1 ) + " subs r0, r0, #44 \n" /* Make space for PSPLIM, CONTROL, LR and the remaining registers on the stack. */ + " str r0, [r1] \n" /* Save the new top of stack in TCB. */ + " mrs r1, psplim \n" /* r1 = PSPLIM. */ + " mrs r2, control \n" /* r2 = CONTROL. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " stmia r0!, {r1-r7} \n" /* Store on the stack - PSPLIM, CONTROL, LR and low registers that are not automatically saved. */ + " mov r4, r8 \n" /* r4 = r8. */ + " mov r5, r9 \n" /* r5 = r9. */ + " mov r6, r10 \n" /* r6 = r10. */ + " mov r7, r11 \n" /* r7 = r11. */ + " stmia r0!, {r4-r7} \n" /* Store the high registers that are not saved automatically. */ + #else /* configENABLE_MPU */ + " subs r0, r0, #40 \n" /* Make space for PSPLIM, LR and the remaining registers on the stack. */ + " str r0, [r1] \n" /* Save the new top of stack in TCB. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " stmia r0!, {r2-r7} \n" /* Store on the stack - PSPLIM, LR and low registers that are not automatically saved. */ + " mov r4, r8 \n" /* r4 = r8. */ + " mov r5, r9 \n" /* r5 = r9. */ + " mov r6, r10 \n" /* r6 = r10. */ + " mov r7, r11 \n" /* r7 = r11. */ + " stmia r0!, {r4-r7} \n" /* Store the high registers that are not saved automatically. */ + #endif /* configENABLE_MPU */ + " \n" + " cpsid i \n" + " bl vTaskSwitchContext \n" + " cpsie i \n" + " \n" + " ldr r2, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r1, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. r0 now points to the top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r3, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r4, #1 \n" /* r4 = 1. */ + " bics r3, r4 \n" /* r3 = r3 & ~r4 i.e. Clear the bit 0 in r3. */ + " str r3, [r2] \n" /* Disable MPU. */ + " \n" + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + " ldr r4, [r1] \n" /* r4 = *r1 i.e. r4 = MAIR0. */ + " ldr r2, xMAIR0Const \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r4, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + " movs r4, #4 \n" /* r4 = 4. */ + " str r4, [r2] \n" /* Program RNR = 4. */ + " ldmia r1!, {r5,r6} \n" /* Read first set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write first set of RBAR/RLAR registers. */ + " movs r4, #5 \n" /* r4 = 5. */ + " str r4, [r2] \n" /* Program RNR = 5. */ + " ldmia r1!, {r5,r6} \n" /* Read second set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write second set of RBAR/RLAR registers. */ + " movs r4, #6 \n" /* r4 = 6. */ + " str r4, [r2] \n" /* Program RNR = 6. */ + " ldmia r1!, {r5,r6} \n" /* Read third set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write third set of RBAR/RLAR registers. */ + " movs r4, #7 \n" /* r4 = 7. */ + " str r4, [r2] \n" /* Program RNR = 7. */ + " ldmia r1!, {r5,r6} \n" /* Read fourth set of RBAR/RLAR from TCB. */ + " ldr r3, xRBARConst \n" /* r3 = 0xe000ed9c [Location of RBAR]. */ + " stmia r3!, {r5,r6} \n" /* Write fourth set of RBAR/RLAR registers. */ + " \n" + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r3, [r2] \n" /* Read the value of MPU_CTRL. */ + " movs r4, #1 \n" /* r4 = 1. */ + " orrs r3, r4 \n" /* r3 = r3 | r4 i.e. Set the bit 0 in r3. */ + " str r3, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " adds r0, r0, #28 \n" /* Move to the high registers. */ + " ldmia r0!, {r4-r7} \n" /* Restore the high registers that are not automatically restored. */ + " mov r8, r4 \n" /* r8 = r4. */ + " mov r9, r5 \n" /* r9 = r5. */ + " mov r10, r6 \n" /* r10 = r6. */ + " mov r11, r7 \n" /* r11 = r7. */ + " msr psp, r0 \n" /* Remember the new top of stack for the task. */ + " subs r0, r0, #44 \n" /* Move to the starting of the saved context. */ + " ldmia r0!, {r1-r7} \n" /* Read from stack - r1 = PSPLIM, r2 = CONTROL, r3 = LR and r4-r7 restored. */ + " msr psplim, r1 \n" /* Restore the PSPLIM register value for the task. */ + " msr control, r2 \n" /* Restore the CONTROL register value for the task. */ + " bx r3 \n" + #else /* configENABLE_MPU */ + " adds r0, r0, #24 \n" /* Move to the high registers. */ + " ldmia r0!, {r4-r7} \n" /* Restore the high registers that are not automatically restored. */ + " mov r8, r4 \n" /* r8 = r4. */ + " mov r9, r5 \n" /* r9 = r5. */ + " mov r10, r6 \n" /* r10 = r6. */ + " mov r11, r7 \n" /* r11 = r7. */ + " msr psp, r0 \n" /* Remember the new top of stack for the task. */ + " subs r0, r0, #40 \n" /* Move to the starting of the saved context. */ + " ldmia r0!, {r2-r7} \n" /* Read from stack - r2 = PSPLIM, r3 = LR and r4-r7 restored. */ + " msr psplim, r2 \n" /* Restore the PSPLIM register value for the task. */ + " bx r3 \n" + #endif /* configENABLE_MPU */ + " \n" + " .align 4 \n" + "pxCurrentTCBConst: .word pxCurrentTCB \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst: .word 0xe000ed94 \n" + "xMAIR0Const: .word 0xe000edc0 \n" + "xRNRConst: .word 0xe000ed98 \n" + "xRBARConst: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +void SVC_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " movs r0, #4 \n" + " mov r1, lr \n" + " tst r0, r1 \n" + " beq stacking_used_msp \n" + " mrs r0, psp \n" + " ldr r2, svchandler_address_const \n" + " bx r2 \n" + " stacking_used_msp: \n" + " mrs r0, msp \n" + " ldr r2, svchandler_address_const \n" + " bx r2 \n" + " \n" + " .align 4 \n" + "svchandler_address_const: .word vPortSVCHandler_C \n" + ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.h b/FreeRTOS/Source/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.h new file mode 100755 index 0000000..2ecf04e --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.h @@ -0,0 +1,113 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __PORT_ASM_H__ +#define __PORT_ASM_H__ + +/* Scheduler includes. */ +#include "FreeRTOS.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/** + * @brief Restore the context of the first task so that the first task starts + * executing. + */ +void vRestoreContextOfFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +BaseType_t xIsPrivileged( void ) __attribute__ (( naked )); + +/** + * @brief Raises the privilege level by clearing the bit 0 of the CONTROL + * register. + * + * @note This is a privileged function and should only be called from the kenrel + * code. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vRaisePrivilege( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vResetPrivilege( void ) __attribute__ (( naked )); + +/** + * @brief Starts the first task. + */ +void vStartFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Disables interrupts. + */ +uint32_t ulSetInterruptMaskFromISR( void ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Enables interrupts. + */ +void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief PendSV Exception handler. + */ +void PendSV_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief SVC Handler. + */ +void SVC_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Allocate a Secure context for the calling task. + * + * @param[in] ulSecureStackSize The size of the stack to be allocated on the + * secure side for the calling task. + */ +void vPortAllocateSecureContext( uint32_t ulSecureStackSize ) __attribute__ (( naked )); + +/** + * @brief Free the task's secure context. + * + * @param[in] pulTCB Pointer to the Task Control Block (TCB) of the task. + */ +void vPortFreeSecureContext( uint32_t *pulTCB ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +#endif /* __PORT_ASM_H__ */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM23_NTZ/non_secure/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM_CM23_NTZ/non_secure/portmacro.h new file mode 100755 index 0000000..bbab1b7 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM23_NTZ/non_secure/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M23" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __attribute__(( used )) +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c index cdd962b..3c0c8e0 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM3/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM_CM3/portmacro.h index 1f0c43a..f1becb3 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CM3/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ARM_CM3/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -233,6 +233,7 @@ portFORCE_INLINE static void vPortSetBASEPRI( uint32_t ulNewMaskValue ) } /*-----------------------------------------------------------*/ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) #ifdef __cplusplus } diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/port.c new file mode 100755 index 0000000..bd85a6f --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/port.c @@ -0,0 +1,899 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/* Portasm includes. */ +#include "portasm.h" + +#if( configENABLE_TRUSTZONE == 1 ) + /* Secure components includes. */ + #include "secure_context.h" + #include "secure_init.h" +#endif /* configENABLE_TRUSTZONE */ + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/** + * The FreeRTOS Cortex M33 port can be configured to run on the Secure Side only + * i.e. the processor boots as secure and never jumps to the non-secure side. + * The Trust Zone support in the port must be disabled in order to run FreeRTOS + * on the secure side. The following are the valid configuration seetings: + * + * 1. Run FreeRTOS on the Secure Side: + * configRUN_FREERTOS_SECURE_ONLY = 1 and configENABLE_TRUSTZONE = 0 + * + * 2. Run FreeRTOS on the Non-Secure Side with Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 1 + * + * 3. Run FreeRTOS on the Non-Secure Side only i.e. no Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 0 + */ +#if( ( configRUN_FREERTOS_SECURE_ONLY == 1 ) && ( configENABLE_TRUSTZONE == 1 ) ) + #error TrustZone needs to be disabled in order to run FreeRTOS on the Secure Side. +#endif +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the NVIC. + */ +#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t * ) 0xe000e010 ) +#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t * ) 0xe000e014 ) +#define portNVIC_SYSTICK_CURRENT_VALUE ( ( volatile uint32_t * ) 0xe000e018 ) +#define portNVIC_INT_CTRL ( ( volatile uint32_t * ) 0xe000ed04 ) +#define portNVIC_SYSPRI2 ( ( volatile uint32_t * ) 0xe000ed20 ) +#define portNVIC_SYSTICK_CLK ( 0x00000004 ) +#define portNVIC_SYSTICK_INT ( 0x00000002 ) +#define portNVIC_SYSTICK_ENABLE ( 0x00000001 ) +#define portNVIC_PENDSVSET ( 0x10000000 ) +#define portMIN_INTERRUPT_PRIORITY ( 255UL ) +#define portNVIC_PENDSV_PRI ( portMIN_INTERRUPT_PRIORITY << 16UL ) +#define portNVIC_SYSTICK_PRI ( portMIN_INTERRUPT_PRIORITY << 24UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the SCB. + */ +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( * ( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_MEM_FAULT_ENABLE ( 1UL << 16UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the FPU. + */ +#define portCPACR ( ( volatile uint32_t * ) 0xe000ed88 ) /* Coprocessor Access Control Register. */ +#define portCPACR_CP10_VALUE ( 3UL ) +#define portCPACR_CP11_VALUE portCPACR_CP10_VALUE +#define portCPACR_CP10_POS ( 20UL ) +#define portCPACR_CP11_POS ( 22UL ) + +#define portFPCCR ( ( volatile uint32_t * ) 0xe000ef34 ) /* Floating Point Context Control Register. */ +#define portFPCCR_ASPEN_POS ( 31UL ) +#define portFPCCR_ASPEN_MASK ( 1UL << portFPCCR_ASPEN_POS ) +#define portFPCCR_LSPEN_POS ( 30UL ) +#define portFPCCR_LSPEN_MASK ( 1UL << portFPCCR_LSPEN_POS ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the MPU. + */ +#define portMPU_TYPE_REG ( * ( ( volatile uint32_t * ) 0xe000ed90 ) ) +#define portMPU_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed94 ) ) +#define portMPU_RNR_REG ( * ( ( volatile uint32_t * ) 0xe000ed98 ) ) + +#define portMPU_RBAR_REG ( * ( ( volatile uint32_t * ) 0xe000ed9c ) ) +#define portMPU_RLAR_REG ( * ( ( volatile uint32_t * ) 0xe000eda0 ) ) + +#define portMPU_RBAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda4 ) ) +#define portMPU_RLAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda8 ) ) + +#define portMPU_RBAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edac ) ) +#define portMPU_RLAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edb0 ) ) + +#define portMPU_RBAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb4 ) ) +#define portMPU_RLAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb8 ) ) + +#define portMPU_MAIR0_REG ( * ( ( volatile uint32_t * ) 0xe000edc0 ) ) +#define portMPU_MAIR1_REG ( * ( ( volatile uint32_t * ) 0xe000edc4 ) ) + +#define portMPU_RBAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ +#define portMPU_RLAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ + +#define portMPU_MAIR_ATTR0_POS ( 0UL ) +#define portMPU_MAIR_ATTR0_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR1_POS ( 8UL ) +#define portMPU_MAIR_ATTR1_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR2_POS ( 16UL ) +#define portMPU_MAIR_ATTR2_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR3_POS ( 24UL ) +#define portMPU_MAIR_ATTR3_MASK ( 0xff000000 ) + +#define portMPU_MAIR_ATTR4_POS ( 0UL ) +#define portMPU_MAIR_ATTR4_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR5_POS ( 8UL ) +#define portMPU_MAIR_ATTR5_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR6_POS ( 16UL ) +#define portMPU_MAIR_ATTR6_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR7_POS ( 24UL ) +#define portMPU_MAIR_ATTR7_MASK ( 0xff000000 ) + +#define portMPU_RLAR_ATTR_INDEX0 ( 0UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX1 ( 1UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX2 ( 2UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX3 ( 3UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX4 ( 4UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX5 ( 5UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX6 ( 6UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX7 ( 7UL << 1UL ) + +#define portMPU_RLAR_REGION_ENABLE ( 1UL ) + +/* Enable privileged access to unmapped region. */ +#define portMPU_PRIV_BACKGROUND_ENABLE ( 1UL << 2UL ) + +/* Enable MPU. */ +#define portMPU_ENABLE ( 1UL << 0UL ) + +/* Expected value of the portMPU_TYPE register. */ +#define portEXPECTED_MPU_TYPE_VALUE ( 8UL << 8UL ) /* 8 regions, unified. */ +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to set up the initial stack. + */ +#define portINITIAL_XPSR ( 0x01000000 ) + +#if( configRUN_FREERTOS_SECURE_ONLY == 1 ) + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF FD + * 1111 1111 1111 1111 1111 1111 1111 1101 + * + * Bit[6] - 1 --> The exception was taken from the Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 1 --> The exception was taken to the Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xfffffffd ) +#else + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF BC + * 1111 1111 1111 1111 1111 1111 1011 1100 + * + * Bit[6] - 0 --> The exception was taken from the Non-Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 0 --> The exception was taken to the Non-Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xffffffbc ) +#endif /* configRUN_FREERTOS_SECURE_ONLY */ + +/** + * @brief CONTROL register privileged bit mask. + * + * Bit[0] in CONTROL register tells the privilege: + * Bit[0] = 0 ==> The task is privileged. + * Bit[0] = 1 ==> The task is not privileged. + */ +#define portCONTROL_PRIVILEGED_MASK ( 1UL << 0UL ) + +/** + * @brief Initial CONTROL register values. + */ +#define portINITIAL_CONTROL_UNPRIVILEGED ( 0x3 ) +#define portINITIAL_CONTROL_PRIVILEGED ( 0x2 ) + +/** + * @brief Let the user override the pre-loading of the initial LR with the + * address of prvTaskExitError() in case it messes up unwinding of the stack + * in the debugger. + */ +#ifdef configTASK_RETURN_ADDRESS + #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS +#else + #define portTASK_RETURN_ADDRESS prvTaskExitError +#endif + +/** + * @brief If portPRELOAD_REGISTERS then registers will be given an initial value + * when a task is created. This helps in debugging at the cost of code size. + */ +#define portPRELOAD_REGISTERS 1 + +/** + * @brief A task is created without a secure context, and must call + * portALLOCATE_SECURE_CONTEXT() to give itself a secure context before it makes + * any secure calls. + */ +#define portNO_SECURE_CONTEXT 0 +/*-----------------------------------------------------------*/ + +/** + * @brief Setup the timer to generate the tick interrupts. + */ +static void prvSetupTimerInterrupt( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Used to catch tasks that attempt to return from their implementing + * function. + */ +static void prvTaskExitError( void ); + +#if( configENABLE_MPU == 1 ) + /** + * @brief Setup the Memory Protection Unit (MPU). + */ + static void prvSetupMPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_MPU */ + +#if( configENABLE_FPU == 1 ) + /** + * @brief Setup the Floating Point Unit (FPU). + */ + static void prvSetupFPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_FPU */ + +/** + * @brief Yield the processor. + */ +void vPortYield( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Enter critical section. + */ +void vPortEnterCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Exit from critical section. + */ +void vPortExitCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief SysTick handler. + */ +void SysTick_Handler( void ) PRIVILEGED_FUNCTION; + +/** + * @brief C part of SVC handler. + */ +portDONT_DISCARD void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) PRIVILEGED_FUNCTION; +/*-----------------------------------------------------------*/ + +/** + * @brief Each task maintains its own interrupt status in the critical nesting + * variable. + */ +static volatile uint32_t ulCriticalNesting = 0xaaaaaaaaUL; + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Saved as part of the task context to indicate which context the + * task is using on the secure side. + */ + portDONT_DISCARD volatile SecureContextHandle_t xSecureContext = portNO_SECURE_CONTEXT; +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +static void prvSetupTimerInterrupt( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Stop and reset the SysTick. */ + *( portNVIC_SYSTICK_CTRL ) = 0UL; + *( portNVIC_SYSTICK_CURRENT_VALUE ) = 0UL; + + /* Configure SysTick to interrupt at the requested rate. */ + *( portNVIC_SYSTICK_LOAD ) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; + *( portNVIC_SYSTICK_CTRL ) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE; +} +/*-----------------------------------------------------------*/ + +static void prvTaskExitError( void ) +{ +volatile uint32_t ulDummy = 0UL; + + /* A function that implements a task must not exit or attempt to return to + * its caller as there is nothing to return to. If a task wants to exit it + * should instead call vTaskDelete( NULL ). Artificially force an assert() + * to be triggered if configASSERT() is defined, then stop here so + * application writers can catch the error. */ + configASSERT( ulCriticalNesting == ~0UL ); + portDISABLE_INTERRUPTS(); + + while( ulDummy == 0 ) + { + /* This file calls prvTaskExitError() after the scheduler has been + * started to remove a compiler warning about the function being + * defined but never called. ulDummy is used purely to quieten other + * warnings about code appearing after this function is called - making + * ulDummy volatile makes the compiler think the function could return + * and therefore not output an 'unreachable code' warning for code that + * appears after it. */ + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + static void prvSetupMPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __privileged_functions_start__; + extern uint32_t * __privileged_functions_end__; + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + extern uint32_t * __unprivileged_flash_start__; + extern uint32_t * __unprivileged_flash_end__; + extern uint32_t * __privileged_sram_start__; + extern uint32_t * __privileged_sram_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __privileged_functions_start__[]; + extern uint32_t __privileged_functions_end__[]; + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + extern uint32_t __unprivileged_flash_start__[]; + extern uint32_t __unprivileged_flash_end__[]; + extern uint32_t __privileged_sram_start__[]; + extern uint32_t __privileged_sram_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ + + /* Check that the MPU is present. */ + if( portMPU_TYPE_REG == portEXPECTED_MPU_TYPE_VALUE ) + { + /* MAIR0 - Index 0. */ + portMPU_MAIR0_REG |= ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + /* MAIR0 - Index 1. */ + portMPU_MAIR0_REG |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* Setup privileged flash as Read Only so that privileged tasks can + * read it but not modify. */ + portMPU_RNR_REG = portPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_functions_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_functions_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged flash as Read Only by both privileged and + * unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __unprivileged_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __unprivileged_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged syscalls flash as Read Only by both privileged + * and unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_SYSCALLS_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __syscalls_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __syscalls_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup RAM containing kernel data for privileged access only. */ + portMPU_RNR_REG = portPRIVILEGED_RAM_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_sram_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_sram_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Enable mem fault. */ + portSCB_SYS_HANDLER_CTRL_STATE_REG |= portSCB_MEM_FAULT_ENABLE; + + /* Enable MPU with privileged background access i.e. unmapped + * regions have privileged access. */ + portMPU_CTRL_REG |= ( portMPU_PRIV_BACKGROUND_ENABLE | portMPU_ENABLE ); + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_FPU == 1 ) + static void prvSetupFPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* Enable non-secure access to the FPU. */ + SecureInit_EnableNSFPUAccess(); + } + #endif /* configENABLE_TRUSTZONE */ + + /* CP10 = 11 ==> Full access to FPU i.e. both privileged and + * unprivileged code should be able to access FPU. CP11 should be + * programmed to the same value as CP10. */ + *( portCPACR ) |= ( ( portCPACR_CP10_VALUE << portCPACR_CP10_POS ) | + ( portCPACR_CP11_VALUE << portCPACR_CP11_POS ) + ); + + /* ASPEN = 1 ==> Hardware should automatically preserve floating point + * context on exception entry and restore on exception return. + * LSPEN = 1 ==> Enable lazy context save of FP state. */ + *( portFPCCR ) |= ( portFPCCR_ASPEN_MASK | portFPCCR_LSPEN_MASK ); + } +#endif /* configENABLE_FPU */ +/*-----------------------------------------------------------*/ + +void vPortYield( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Set a PendSV to request a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + portDISABLE_INTERRUPTS(); + ulCriticalNesting++; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + configASSERT( ulCriticalNesting ); + ulCriticalNesting--; + + if( ulCriticalNesting == 0 ) + { + portENABLE_INTERRUPTS(); + } +} +/*-----------------------------------------------------------*/ + +void SysTick_Handler( void ) /* PRIVILEGED_FUNCTION */ +{ +uint32_t ulPreviousMask; + + ulPreviousMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* Increment the RTOS tick. */ + if( xTaskIncrementTick() != pdFALSE ) + { + /* Pend a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulPreviousMask ); +} +/*-----------------------------------------------------------*/ + +void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) /* PRIVILEGED_FUNCTION portDONT_DISCARD */ +{ +#if( configENABLE_MPU == 1 ) + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ +#endif /* configENABLE_MPU */ + +uint32_t ulPC; + +#if( configENABLE_TRUSTZONE == 1 ) + uint32_t ulR0; + #if( configENABLE_MPU == 1 ) + uint32_t ulControl, ulIsTaskPrivileged; + #endif /* configENABLE_MPU */ +#endif /* configENABLE_TRUSTZONE */ +uint8_t ucSVCNumber; + + /* Register are stored on the stack in the following order - R0, R1, R2, R3, + * R12, LR, PC, xPSR. */ + ulPC = pulCallerStackAddress[ 6 ]; + ucSVCNumber = ( ( uint8_t *) ulPC )[ -2 ]; + + switch( ucSVCNumber ) + { + #if( configENABLE_TRUSTZONE == 1 ) + case portSVC_ALLOCATE_SECURE_CONTEXT: + { + /* R0 contains the stack size passed as parameter to the + * vPortAllocateSecureContext function. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + #if( configENABLE_MPU == 1 ) + { + /* Read the CONTROL register value. */ + __asm volatile ( "mrs %0, control" : "=r" ( ulControl ) ); + + /* The task that raised the SVC is privileged if Bit[0] + * in the CONTROL register is 0. */ + ulIsTaskPrivileged = ( ( ulControl & portCONTROL_PRIVILEGED_MASK ) == 0 ); + + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0, ulIsTaskPrivileged ); + } + #else + { + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0 ); + } + #endif /* configENABLE_MPU */ + + configASSERT( xSecureContext != NULL ); + SecureContext_LoadContext( xSecureContext ); + } + break; + + case portSVC_FREE_SECURE_CONTEXT: + { + /* R0 contains the secure context handle to be freed. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + /* Free the secure context. */ + SecureContext_FreeContext( ( SecureContextHandle_t ) ulR0 ); + } + break; + #endif /* configENABLE_TRUSTZONE */ + + case portSVC_START_SCHEDULER: + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* De-prioritize the non-secure exceptions so that the + * non-secure pendSV runs at the lowest priority. */ + SecureInit_DePrioritizeNSExceptions(); + + /* Initialize the secure context management system. */ + SecureContext_Init(); + } + #endif /* configENABLE_TRUSTZONE */ + + #if( configENABLE_FPU == 1 ) + { + /* Setup the Floating Point Unit (FPU). */ + prvSetupFPU(); + } + #endif /* configENABLE_FPU */ + + /* Setup the context of the first task so that the first task starts + * executing. */ + vRestoreContextOfFirstTask(); + } + break; + + #if( configENABLE_MPU == 1 ) + case portSVC_RAISE_PRIVILEGE: + { + /* Only raise the privilege, if the svc was raised from any of + * the system calls. */ + if( ulPC >= ( uint32_t ) __syscalls_flash_start__ && + ulPC <= ( uint32_t ) __syscalls_flash_end__ ) + { + vRaisePrivilege(); + } + } + break; + #endif /* configENABLE_MPU */ + + default: + { + /* Incorrect SVC call. */ + configASSERT( pdFALSE ); + } + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) /* PRIVILEGED_FUNCTION */ +#else + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) /* PRIVILEGED_FUNCTION */ +#endif /* configENABLE_MPU */ +{ + /* Simulate the stack frame as it would be created by a context switch + * interrupt. */ + #if( portPRELOAD_REGISTERS == 0 ) + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack -= 9; /* R11..R4, EXC_RETURN. */ + *pxTopOfStack = portINITIAL_EXC_RETURN; + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #else /* portPRELOAD_REGISTERS */ + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x12121212UL; /* R12 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x03030303UL; /* R3 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x02020202UL; /* R2 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x01010101UL; /* R1 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x11111111UL; /* R11 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x10101010UL; /* R10 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x09090909UL; /* R09 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x08080808UL; /* R08 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x07070707UL; /* R07 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x06060606UL; /* R06 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x05050505UL; /* R05 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x04040404UL; /* R04 */ + pxTopOfStack--; + *pxTopOfStack = portINITIAL_EXC_RETURN; /* EXC_RETURN */ + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #endif /* portPRELOAD_REGISTERS */ + + return pxTopOfStack; +} +/*-----------------------------------------------------------*/ + +BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + *( portNVIC_SYSPRI2 ) |= portNVIC_PENDSV_PRI; + *( portNVIC_SYSPRI2 ) |= portNVIC_SYSTICK_PRI; + + #if( configENABLE_MPU == 1 ) + { + /* Setup the Memory Protection Unit (MPU). */ + prvSetupMPU(); + } + #endif /* configENABLE_MPU */ + + /* Start the timer that generates the tick ISR. Interrupts are disabled + * here already. */ + prvSetupTimerInterrupt(); + + /* Initialize the critical nesting count ready for the first task. */ + ulCriticalNesting = 0; + + /* Start the first task. */ + vStartFirstTask(); + + /* Should never get here as the tasks will now be executing. Call the task + * exit error function to prevent compiler warnings about a static function + * not being called in the case that the application writer overrides this + * functionality by defining configTASK_RETURN_ADDRESS. Call + * vTaskSwitchContext() so link time optimization does not remove the + * symbol. */ + vTaskSwitchContext(); + prvTaskExitError(); + + /* Should not get here. */ + return 0; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Not implemented in ports where there is nothing to return to. + * Artificially force an assert. */ + configASSERT( ulCriticalNesting == 1000UL ); +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) + { + uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber; + int32_t lIndex = 0; + + /* Setup MAIR0. */ + xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + xMPUSettings->ulMAIR0 |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* This function is called automatically when the task is created - in + * which case the stack region parameters will be valid. At all other + * times the stack parameters will not be valid and it is assumed that + * the stack region has already been configured. */ + if( ulStackDepth > 0 ) + { + /* Define the region that allows access to the stack. */ + ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + + xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + } + + /* User supplied configurable regions. */ + for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ ) + { + /* If xRegions is NULL i.e. the task has not specified any MPU + * region, the else part ensures that all the configurable MPU + * regions are invalidated. */ + if( ( xRegions != NULL ) && ( xRegions[ lIndex ].ulLengthInBytes > 0UL ) ) + { + /* Translate the generic region definition contained in xRegions + * into the ARMv8 specific MPU settings that are then stored in + * xMPUSettings. */ + ulRegionStartAddress = ( ( uint32_t ) xRegions[ lIndex ].pvBaseAddress ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) xRegions[ lIndex ].pvBaseAddress + xRegions[ lIndex ].ulLengthInBytes - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + /* Start address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ); + + /* RO/RW. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_READ_ONLY ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_ONLY ); + } + else + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_WRITE ); + } + + /* XN. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_EXECUTE_NEVER ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_EXECUTE_NEVER ); + } + + /* End Address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Normal memory/ Device memory. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_DEVICE_MEMORY ) != 0 ) + { + /* Attr1 in MAIR0 is configured as device memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX1; + } + else + { + /* Attr1 in MAIR0 is configured as normal memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX0; + } + } + else + { + /* Invalidate the region. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = 0UL; + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = 0UL; + } + + lIndex++; + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/portasm.c b/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/portasm.c new file mode 100755 index 0000000..3a24f3a --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/portasm.c @@ -0,0 +1,415 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE ensures that PRIVILEGED_FUNCTION + * is defined correctly and privileged functions are placed in correct sections. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Portasm includes. */ +#include "portasm.h" + +/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE is needed to be defined only for the + * header files. */ +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +void vRestoreContextOfFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " \n" + " ldr r2, pxCurrentTCBConst2 \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r3, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r0, [r3] \n" /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " bic r4, #1 \n" /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + " str r4, [r2] \n" /* Disable MPU. */ + " \n" + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + " ldr r4, [r3] \n" /* r4 = *r3 i.e. r4 = MAIR0. */ + " ldr r2, xMAIR0Const2 \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r4, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst2 \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " movs r4, #4 \n" /* r4 = 4. */ + " str r4, [r2] \n" /* Program RNR = 4. */ + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + " ldr r2, xRBARConst2 \n" /* r2 = 0xe000ed9c [Location of RBAR]. */ + " ldmia r3!, {r4-r11} \n" /* Read 4 set of RBAR/RLAR registers from TCB. */ + " stmia r2!, {r4-r11} \n" /* Write 4 set of RBAR/RLAR registers using alias registers. */ + " \n" + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " orr r4, #1 \n" /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + " str r4, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " ldm r0!, {r1-r4} \n" /* Read from stack - r1 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = EXC_RETURN. */ + " ldr r5, xSecureContextConst2 \n" + " str r1, [r5] \n" /* Set xSecureContext to this task's value for the same. */ + " msr psplim, r2 \n" /* Set this task's PSPLIM value. */ + " msr control, r3 \n" /* Set this task's CONTROL value. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r4 \n" /* Finally, branch to EXC_RETURN. */ + #else /* configENABLE_MPU */ + " ldm r0!, {r1-r3} \n" /* Read from stack - r1 = xSecureContext, r2 = PSPLIM and r3 = EXC_RETURN. */ + " ldr r4, xSecureContextConst2 \n" + " str r1, [r4] \n" /* Set xSecureContext to this task's value for the same. */ + " msr psplim, r2 \n" /* Set this task's PSPLIM value. */ + " movs r1, #2 \n" /* r1 = 2. */ + " msr CONTROL, r1 \n" /* Switch to use PSP in the thread mode. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r3 \n" /* Finally, branch to EXC_RETURN. */ + #endif /* configENABLE_MPU */ + " \n" + " .align 4 \n" + "pxCurrentTCBConst2: .word pxCurrentTCB \n" + "xSecureContextConst2: .word xSecureContext \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst2: .word 0xe000ed94 \n" + "xMAIR0Const2: .word 0xe000edc0 \n" + "xRNRConst2: .word 0xe000ed98 \n" + "xRBARConst2: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " tst r0, #1 \n" /* Perform r0 & 1 (bitwise AND) and update the conditions flag. */ + " ite ne \n" + " movne r0, #0 \n" /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + " moveq r0, #1 \n" /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + " bx lr \n" /* Return. */ + " \n" + " .align 4 \n" + ::: "r0", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vRaisePrivilege( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, control \n" /* Read the CONTROL register. */ + " bic r0, #1 \n" /* Clear the bit 0. */ + " msr control, r0 \n" /* Write back the new CONTROL value. */ + " bx lr \n" /* Return to the caller. */ + ::: "r0", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vResetPrivilege( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " orr r0, #1 \n" /* r0 = r0 | 1. */ + " msr control, r0 \n" /* CONTROL = r0. */ + " bx lr \n" /* Return to the caller. */ + :::"r0", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vStartFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " ldr r0, xVTORConst \n" /* Use the NVIC offset register to locate the stack. */ + " ldr r0, [r0] \n" /* Read the VTOR register which gives the address of vector table. */ + " ldr r0, [r0] \n" /* The first entry in vector table is stack pointer. */ + " msr msp, r0 \n" /* Set the MSP back to the start of the stack. */ + " cpsie i \n" /* Globally enable interrupts. */ + " cpsie f \n" + " dsb \n" + " isb \n" + " svc %0 \n" /* System call to start the first task. */ + " nop \n" + " \n" + " .align 4 \n" + "xVTORConst: .word 0xe000ed08 \n" + :: "i" ( portSVC_START_SCHEDULER ) : "memory" + ); +} +/*-----------------------------------------------------------*/ + +uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, PRIMASK \n" + " cpsid i \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* To avoid compiler warnings. The return statement will never be reached, + * but some compilers warn if it is not included, while others won't compile + * if it is. */ + return 0; +#endif +} +/*-----------------------------------------------------------*/ + +void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " msr PRIMASK, r0 \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* Just to avoid compiler warning. ulMask is used from the asm code but + * the compiler can't see that. Some compilers generate warnings without + * the following line, while others generate warnings if the line is + * included. */ + ( void ) ulMask; +#endif +} +/*-----------------------------------------------------------*/ + +void PendSV_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " .extern SecureContext_SaveContext \n" + " .extern SecureContext_LoadContext \n" + " \n" + " mrs r1, psp \n" /* Read PSP in r1. */ + " ldr r2, xSecureContextConst \n" /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + " ldr r0, [r2] \n" /* Read xSecureContext - Value of xSecureContext must be in r0 as it is used as a parameter later. */ + " \n" + " cbz r0, save_ns_context \n" /* No secure context to save. */ + " push {r0-r2, r14} \n" + " bl SecureContext_SaveContext \n" + " pop {r0-r3} \n" /* LR is now in r3. */ + " mov lr, r3 \n" /* LR = r3. */ + " lsls r2, r3, #25 \n" /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + " bpl save_ns_context \n" /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + " ldr r3, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r2, [r3] \n" /* Read pxCurrentTCB. */ + #if( configENABLE_MPU == 1 ) + " subs r1, r1, #16 \n" /* Make space for xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mrs r3, control \n" /* r3 = CONTROL. */ + " mov r4, lr \n" /* r4 = LR/EXC_RETURN. */ + " stmia r1!, {r0, r2-r4} \n" /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + #else /* configENABLE_MPU */ + " subs r1, r1, #12 \n" /* Make space for xSecureContext, PSPLIM and LR on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " stmia r1!, {r0, r2-r3} \n" /* Store xSecureContext, PSPLIM and LR on the stack. */ + #endif /* configENABLE_MPU */ + " b select_next_task \n" + " \n" + " save_ns_context: \n" + " ldr r3, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r2, [r3] \n" /* Read pxCurrentTCB. */ + #if( configENABLE_FPU == 1 ) + " tst lr, #0x10 \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + " it eq \n" + " vstmdbeq r1!, {s16-s31} \n" /* Store the FPU registers which are not saved automatically. */ + #endif /* configENABLE_FPU */ + #if( configENABLE_MPU == 1 ) + " subs r1, r1, #48 \n" /* Make space for xSecureContext, PSPLIM, CONTROL, LR and the remaining registers on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " adds r1, r1, #16 \n" /* r1 = r1 + 16. */ + " stm r1, {r4-r11} \n" /* Store the registers that are not saved automatically. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mrs r3, control \n" /* r3 = CONTROL. */ + " mov r4, lr \n" /* r4 = LR/EXC_RETURN. */ + " subs r1, r1, #16 \n" /* r1 = r1 - 16. */ + " stm r1, {r0, r2-r4} \n" /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + #else /* configENABLE_MPU */ + " subs r1, r1, #44 \n" /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */ + " str r1, [r2] \n" /* Save the new top of stack in TCB. */ + " adds r1, r1, #12 \n" /* r1 = r1 + 12. */ + " stm r1, {r4-r11} \n" /* Store the registers that are not saved automatically. */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " subs r1, r1, #12 \n" /* r1 = r1 - 12. */ + " stmia r1!, {r0, r2-r3} \n" /* Store xSecureContext, PSPLIM and LR on the stack. */ + #endif /* configENABLE_MPU */ + " \n" + " select_next_task: \n" + " cpsid i \n" + " bl vTaskSwitchContext \n" + " cpsie i \n" + " \n" + " ldr r2, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r3, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r1, [r3] \n" /* The first item in pxCurrentTCB is the task top of stack. r1 now points to the top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " bic r4, #1 \n" /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + " str r4, [r2] \n" /* Disable MPU. */ + " \n" + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + " ldr r4, [r3] \n" /* r4 = *r3 i.e. r4 = MAIR0. */ + " ldr r2, xMAIR0Const \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r4, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " movs r4, #4 \n" /* r4 = 4. */ + " str r4, [r2] \n" /* Program RNR = 4. */ + " adds r3, #4 \n" /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + " ldr r2, xRBARConst \n" /* r2 = 0xe000ed9c [Location of RBAR]. */ + " ldmia r3!, {r4-r11} \n" /* Read 4 sets of RBAR/RLAR registers from TCB. */ + " stmia r2!, {r4-r11} \n" /* Write 4 set of RBAR/RLAR registers using alias registers. */ + " \n" + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " orr r4, #1 \n" /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + " str r4, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " ldmia r1!, {r0, r2-r4} \n" /* Read from stack - r0 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = LR. */ + " msr psplim, r2 \n" /* Restore the PSPLIM register value for the task. */ + " msr control, r3 \n" /* Restore the CONTROL register value for the task. */ + " mov lr, r4 \n" /* LR = r4. */ + " ldr r2, xSecureContextConst \n" /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + " str r0, [r2] \n" /* Restore the task's xSecureContext. */ + " cbz r0, restore_ns_context \n" /* If there is no secure context for the task, restore the non-secure context. */ + " push {r1,r4} \n" + " bl SecureContext_LoadContext \n" /* Restore the secure context. */ + " pop {r1,r4} \n" + " mov lr, r4 \n" /* LR = r4. */ + " lsls r2, r4, #25 \n" /* r2 = r4 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + " bpl restore_ns_context \n" /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + " msr psp, r1 \n" /* Remember the new top of stack for the task. */ + " bx lr \n" + #else /* configENABLE_MPU */ + " ldmia r1!, {r0, r2-r3} \n" /* Read from stack - r0 = xSecureContext, r2 = PSPLIM and r3 = LR. */ + " msr psplim, r2 \n" /* Restore the PSPLIM register value for the task. */ + " mov lr, r3 \n" /* LR = r3. */ + " ldr r2, xSecureContextConst \n" /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + " str r0, [r2] \n" /* Restore the task's xSecureContext. */ + " cbz r0, restore_ns_context \n" /* If there is no secure context for the task, restore the non-secure context. */ + " push {r1,r3} \n" + " bl SecureContext_LoadContext \n" /* Restore the secure context. */ + " pop {r1,r3} \n" + " mov lr, r3 \n" /* LR = r3. */ + " lsls r2, r3, #25 \n" /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + " bpl restore_ns_context \n" /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + " msr psp, r1 \n" /* Remember the new top of stack for the task. */ + " bx lr \n" + #endif /* configENABLE_MPU */ + " \n" + " restore_ns_context: \n" + " ldmia r1!, {r4-r11} \n" /* Restore the registers that are not automatically restored. */ + #if( configENABLE_FPU == 1 ) + " tst lr, #0x10 \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + " it eq \n" + " vldmiaeq r1!, {s16-s31} \n" /* Restore the FPU registers which are not restored automatically. */ + #endif /* configENABLE_FPU */ + " msr psp, r1 \n" /* Remember the new top of stack for the task. */ + " bx lr \n" + " \n" + " .align 4 \n" + "pxCurrentTCBConst: .word pxCurrentTCB \n" + "xSecureContextConst: .word xSecureContext \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst: .word 0xe000ed94 \n" + "xMAIR0Const: .word 0xe000edc0 \n" + "xRNRConst: .word 0xe000ed98 \n" + "xRBARConst: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +void SVC_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " tst lr, #4 \n" + " ite eq \n" + " mrseq r0, msp \n" + " mrsne r0, psp \n" + " ldr r1, svchandler_address_const \n" + " bx r1 \n" + " \n" + " .align 4 \n" + "svchandler_address_const: .word vPortSVCHandler_C \n" + ); +} +/*-----------------------------------------------------------*/ + +void vPortAllocateSecureContext( uint32_t ulSecureStackSize ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " svc %0 \n" /* Secure context is allocated in the supervisor call. */ + " bx lr \n" /* Return. */ + :: "i" ( portSVC_ALLOCATE_SECURE_CONTEXT ) : "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " ldr r1, [r0] \n" /* The first item in the TCB is the top of the stack. */ + " ldr r0, [r1] \n" /* The first item on the stack is the task's xSecureContext. */ + " cmp r0, #0 \n" /* Raise svc if task's xSecureContext is not NULL. */ + " it ne \n" + " svcne %0 \n" /* Secure context is freed in the supervisor call. */ + " bx lr \n" /* Return. */ + :: "i" ( portSVC_FREE_SECURE_CONTEXT ) : "memory" + ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/portasm.h b/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/portasm.h new file mode 100755 index 0000000..2ecf04e --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/portasm.h @@ -0,0 +1,113 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __PORT_ASM_H__ +#define __PORT_ASM_H__ + +/* Scheduler includes. */ +#include "FreeRTOS.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/** + * @brief Restore the context of the first task so that the first task starts + * executing. + */ +void vRestoreContextOfFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +BaseType_t xIsPrivileged( void ) __attribute__ (( naked )); + +/** + * @brief Raises the privilege level by clearing the bit 0 of the CONTROL + * register. + * + * @note This is a privileged function and should only be called from the kenrel + * code. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vRaisePrivilege( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vResetPrivilege( void ) __attribute__ (( naked )); + +/** + * @brief Starts the first task. + */ +void vStartFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Disables interrupts. + */ +uint32_t ulSetInterruptMaskFromISR( void ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Enables interrupts. + */ +void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief PendSV Exception handler. + */ +void PendSV_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief SVC Handler. + */ +void SVC_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Allocate a Secure context for the calling task. + * + * @param[in] ulSecureStackSize The size of the stack to be allocated on the + * secure side for the calling task. + */ +void vPortAllocateSecureContext( uint32_t ulSecureStackSize ) __attribute__ (( naked )); + +/** + * @brief Free the task's secure context. + * + * @param[in] pulTCB Pointer to the Task Control Block (TCB) of the task. + */ +void vPortFreeSecureContext( uint32_t *pulTCB ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +#endif /* __PORT_ASM_H__ */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/portmacro.h new file mode 100755 index 0000000..d051ddc --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M33" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __attribute__(( used )) +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_context.c b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_context.c new file mode 100755 index 0000000..53535cd --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_context.c @@ -0,0 +1,204 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Secure context includes. */ +#include "secure_context.h" + +/* Secure heap includes. */ +#include "secure_heap.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief CONTROL value for privileged tasks. + * + * Bit[0] - 0 --> Thread mode is privileged. + * Bit[1] - 1 --> Thread mode uses PSP. + */ +#define securecontextCONTROL_VALUE_PRIVILEGED 0x02 + +/** + * @brief CONTROL value for un-privileged tasks. + * + * Bit[0] - 1 --> Thread mode is un-privileged. + * Bit[1] - 1 --> Thread mode uses PSP. + */ +#define securecontextCONTROL_VALUE_UNPRIVILEGED 0x03 +/*-----------------------------------------------------------*/ + +/** + * @brief Structure to represent secure context. + * + * @note Since stack grows down, pucStackStart is the highest address while + * pucStackLimit is the first addess of the allocated memory. + */ +typedef struct SecureContext +{ + uint8_t *pucCurrentStackPointer; /**< Current value of stack pointer (PSP). */ + uint8_t *pucStackLimit; /**< Last location of the stack memory (PSPLIM). */ + uint8_t *pucStackStart; /**< First location of the stack memory. */ +} SecureContext_t; +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_Init( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* No stack for thread mode until a task's context is loaded. */ + secureportSET_PSPLIM( securecontextNO_STACK ); + secureportSET_PSP( securecontextNO_STACK ); + + #if( configENABLE_MPU == 1 ) + { + /* Configure thread mode to use PSP and to be unprivileged. */ + secureportSET_CONTROL( securecontextCONTROL_VALUE_UNPRIVILEGED ); + } + #else /* configENABLE_MPU */ + { + /* Configure thread mode to use PSP and to be privileged.. */ + secureportSET_CONTROL( securecontextCONTROL_VALUE_PRIVILEGED ); + } + #endif /* configENABLE_MPU */ + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + secureportNON_SECURE_CALLABLE SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize, uint32_t ulIsTaskPrivileged ) +#else /* configENABLE_MPU */ + secureportNON_SECURE_CALLABLE SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize ) +#endif /* configENABLE_MPU */ +{ + uint8_t *pucStackMemory = NULL; + uint32_t ulIPSR; + SecureContextHandle_t xSecureContextHandle = NULL; + #if( configENABLE_MPU == 1 ) + uint32_t *pulCurrentStackPointer = NULL; + #endif /* configENABLE_MPU */ + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* Allocate the context structure. */ + xSecureContextHandle = ( SecureContextHandle_t ) pvPortMalloc( sizeof( SecureContext_t ) ); + + if( xSecureContextHandle != NULL ) + { + /* Allocate the stack space. */ + pucStackMemory = pvPortMalloc( ulSecureStackSize ); + + if( pucStackMemory != NULL ) + { + /* Since stack grows down, the starting point will be the last + * location. Note that this location is next to the last + * allocated byte because the hardware decrements the stack + * pointer before writing i.e. if stack pointer is 0x2, a push + * operation will decrement the stack pointer to 0x1 and then + * write at 0x1. */ + xSecureContextHandle->pucStackStart = pucStackMemory + ulSecureStackSize; + + /* The stack cannot go beyond this location. This value is + * programmed in the PSPLIM register on context switch.*/ + xSecureContextHandle->pucStackLimit = pucStackMemory; + + #if( configENABLE_MPU == 1 ) + { + /* Store the correct CONTROL value for the task on the stack. + * This value is programmed in the CONTROL register on + * context switch. */ + pulCurrentStackPointer = ( uint32_t * ) xSecureContextHandle->pucStackStart; + pulCurrentStackPointer--; + if( ulIsTaskPrivileged ) + { + *( pulCurrentStackPointer ) = securecontextCONTROL_VALUE_PRIVILEGED; + } + else + { + *( pulCurrentStackPointer ) = securecontextCONTROL_VALUE_UNPRIVILEGED; + } + + /* Store the current stack pointer. This value is programmed in + * the PSP register on context switch. */ + xSecureContextHandle->pucCurrentStackPointer = ( uint8_t * ) pulCurrentStackPointer; + } + #else /* configENABLE_MPU */ + { + /* Current SP is set to the starting of the stack. This + * value programmed in the PSP register on context switch. */ + xSecureContextHandle->pucCurrentStackPointer = xSecureContextHandle->pucStackStart; + + } + #endif /* configENABLE_MPU */ + } + else + { + /* Free the context to avoid memory leak and make sure to return + * NULL to indicate failure. */ + vPortFree( xSecureContextHandle ); + xSecureContextHandle = NULL; + } + } + } + + return xSecureContextHandle; +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_FreeContext( SecureContextHandle_t xSecureContextHandle ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* Ensure that valid parameters are passed. */ + secureportASSERT( xSecureContextHandle != NULL ); + + /* Free the stack space. */ + vPortFree( xSecureContextHandle->pucStackLimit ); + + /* Free the context itself. */ + vPortFree( xSecureContextHandle ); + } +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_context.h b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_context.h new file mode 100755 index 0000000..e148bff --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_context.h @@ -0,0 +1,111 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_CONTEXT_H__ +#define __SECURE_CONTEXT_H__ + +/* Standard includes. */ +#include + +/* FreeRTOS includes. */ +#include "FreeRTOSConfig.h" + +/** + * @brief PSP value when no task's context is loaded. + */ +#define securecontextNO_STACK 0x0 + +/** + * @brief Opaque handle. + */ +struct SecureContext; +typedef struct SecureContext* SecureContextHandle_t; +/*-----------------------------------------------------------*/ + +/** + * @brief Initializes the secure context management system. + * + * PSP is set to NULL and therefore a task must allocate and load a context + * before calling any secure side function in the thread mode. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureContext_Init( void ); + +/** + * @brief Allocates a context on the secure side. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] ulSecureStackSize Size of the stack to allocate on secure side. + * @param[in] ulIsTaskPrivileged 1 if the calling task is privileged, 0 otherwise. + * + * @return Opaque context handle if context is successfully allocated, NULL + * otherwise. + */ +#if( configENABLE_MPU == 1 ) + SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize, uint32_t ulIsTaskPrivileged ); +#else /* configENABLE_MPU */ + SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize ); +#endif /* configENABLE_MPU */ + +/** + * @brief Frees the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the + * context to be freed. + */ +void SecureContext_FreeContext( SecureContextHandle_t xSecureContextHandle ); + +/** + * @brief Loads the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the context + * to be loaded. + */ +void SecureContext_LoadContext( SecureContextHandle_t xSecureContextHandle ); + +/** + * @brief Saves the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the context + * to be saved. + */ +void SecureContext_SaveContext( SecureContextHandle_t xSecureContextHandle ); + +#endif /* __SECURE_CONTEXT_H__ */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_context_port.c b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_context_port.c new file mode 100755 index 0000000..7c556f5 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_context_port.c @@ -0,0 +1,88 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Secure context includes. */ +#include "secure_context.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +secureportNON_SECURE_CALLABLE void SecureContext_LoadContext( SecureContextHandle_t xSecureContextHandle ) +{ + /* xSecureContextHandle value is in r0. */ + __asm volatile + ( + " .syntax unified \n" + " \n" + " mrs r1, ipsr \n" /* r1 = IPSR. */ + " cbz r1, load_ctx_therad_mode \n" /* Do nothing if the processor is running in the Thread Mode. */ + " ldmia r0!, {r1, r2} \n" /* r1 = xSecureContextHandle->pucCurrentStackPointer, r2 = xSecureContextHandle->pucStackLimit. */ + #if( configENABLE_MPU == 1 ) + " ldmia r1!, {r3} \n" /* Read CONTROL register value from task's stack. r3 = CONTROL. */ + " msr control, r3 \n" /* CONTROL = r3. */ + #endif /* configENABLE_MPU */ + " msr psplim, r2 \n" /* PSPLIM = r2. */ + " msr psp, r1 \n" /* PSP = r1. */ + " \n" + " load_ctx_therad_mode: \n" + " nop \n" + " \n" + :::"r0", "r1", "r2" + ); +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_SaveContext( SecureContextHandle_t xSecureContextHandle ) +{ + /* xSecureContextHandle value is in r0. */ + __asm volatile + ( + " .syntax unified \n" + " \n" + " mrs r1, ipsr \n" /* r1 = IPSR. */ + " cbz r1, save_ctx_therad_mode \n" /* Do nothing if the processor is running in the Thread Mode. */ + " mrs r1, psp \n" /* r1 = PSP. */ + #if( configENABLE_FPU == 1 ) + " vstmdb r1!, {s0} \n" /* Trigger the defferred stacking of FPU registers. */ + " vldmia r1!, {s0} \n" /* Nullify the effect of the pervious statement. */ + #endif /* configENABLE_FPU */ + #if( configENABLE_MPU == 1 ) + " mrs r2, control \n" /* r2 = CONTROL. */ + " stmdb r1!, {r2} \n" /* Store CONTROL value on the stack. */ + #endif /* configENABLE_MPU */ + " str r1, [r0] \n" /* Save the top of stack in context. xSecureContextHandle->pucCurrentStackPointer = r1. */ + " movs r1, %0 \n" /* r1 = securecontextNO_STACK. */ + " msr psplim, r1 \n" /* PSPLIM = securecontextNO_STACK. */ + " msr psp, r1 \n" /* PSP = securecontextNO_STACK i.e. No stack for thread mode until next task's context is loaded. */ + " \n" + " save_ctx_therad_mode: \n" + " nop \n" + " \n" + :: "i" ( securecontextNO_STACK ) : "r1", "memory" + ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_heap.c b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_heap.c new file mode 100755 index 0000000..60fce5c --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_heap.c @@ -0,0 +1,450 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Secure context heap includes. */ +#include "secure_heap.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief Total heap size. + */ +#define secureconfigTOTAL_HEAP_SIZE ( ( ( size_t ) ( 10 * 1024 ) ) ) + +/* No test marker by default. */ +#ifndef mtCOVERAGE_TEST_MARKER + #define mtCOVERAGE_TEST_MARKER() +#endif + +/* No tracing by default. */ +#ifndef traceMALLOC + #define traceMALLOC( pvReturn, xWantedSize ) +#endif + +/* No tracing by default. */ +#ifndef traceFREE + #define traceFREE( pv, xBlockSize ) +#endif + +/* Block sizes must not get too small. */ +#define secureheapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) ) + +/* Assumes 8bit bytes! */ +#define secureheapBITS_PER_BYTE ( ( size_t ) 8 ) +/*-----------------------------------------------------------*/ + +/* Allocate the memory for the heap. */ +#if( configAPPLICATION_ALLOCATED_HEAP == 1 ) + /* The application writer has already defined the array used for the RTOS + * heap - probably so it can be placed in a special segment or address. */ + extern uint8_t ucHeap[ secureconfigTOTAL_HEAP_SIZE ]; +#else /* configAPPLICATION_ALLOCATED_HEAP */ + static uint8_t ucHeap[ secureconfigTOTAL_HEAP_SIZE ]; +#endif /* configAPPLICATION_ALLOCATED_HEAP */ + +/** + * @brief The linked list structure. + * + * This is used to link free blocks in order of their memory address. + */ +typedef struct A_BLOCK_LINK +{ + struct A_BLOCK_LINK *pxNextFreeBlock; /**< The next free block in the list. */ + size_t xBlockSize; /**< The size of the free block. */ +} BlockLink_t; +/*-----------------------------------------------------------*/ + +/** + * @brief Called automatically to setup the required heap structures the first + * time pvPortMalloc() is called. + */ +static void prvHeapInit( void ); + +/** + * @brief Inserts a block of memory that is being freed into the correct + * position in the list of free memory blocks. + * + * The block being freed will be merged with the block in front it and/or the + * block behind it if the memory blocks are adjacent to each other. + * + * @param[in] pxBlockToInsert The block being freed. + */ +static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ); +/*-----------------------------------------------------------*/ + +/** + * @brief The size of the structure placed at the beginning of each allocated + * memory block must by correctly byte aligned. + */ +static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( secureportBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + +/** + * @brief Create a couple of list links to mark the start and end of the list. + */ +static BlockLink_t xStart, *pxEnd = NULL; + +/** + * @brief Keeps track of the number of free bytes remaining, but says nothing + * about fragmentation. + */ +static size_t xFreeBytesRemaining = 0U; +static size_t xMinimumEverFreeBytesRemaining = 0U; + +/** + * @brief Gets set to the top bit of an size_t type. + * + * When this bit in the xBlockSize member of an BlockLink_t structure is set + * then the block belongs to the application. When the bit is free the block is + * still part of the free heap space. + */ +static size_t xBlockAllocatedBit = 0; +/*-----------------------------------------------------------*/ + +static void prvHeapInit( void ) +{ +BlockLink_t *pxFirstFreeBlock; +uint8_t *pucAlignedHeap; +size_t uxAddress; +size_t xTotalHeapSize = secureconfigTOTAL_HEAP_SIZE; + + /* Ensure the heap starts on a correctly aligned boundary. */ + uxAddress = ( size_t ) ucHeap; + + if( ( uxAddress & secureportBYTE_ALIGNMENT_MASK ) != 0 ) + { + uxAddress += ( secureportBYTE_ALIGNMENT - 1 ); + uxAddress &= ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + xTotalHeapSize -= uxAddress - ( size_t ) ucHeap; + } + + pucAlignedHeap = ( uint8_t * ) uxAddress; + + /* xStart is used to hold a pointer to the first item in the list of free + * blocks. The void cast is used to prevent compiler warnings. */ + xStart.pxNextFreeBlock = ( void * ) pucAlignedHeap; + xStart.xBlockSize = ( size_t ) 0; + + /* pxEnd is used to mark the end of the list of free blocks and is inserted + * at the end of the heap space. */ + uxAddress = ( ( size_t ) pucAlignedHeap ) + xTotalHeapSize; + uxAddress -= xHeapStructSize; + uxAddress &= ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + pxEnd = ( void * ) uxAddress; + pxEnd->xBlockSize = 0; + pxEnd->pxNextFreeBlock = NULL; + + /* To start with there is a single free block that is sized to take up the + * entire heap space, minus the space taken by pxEnd. */ + pxFirstFreeBlock = ( void * ) pucAlignedHeap; + pxFirstFreeBlock->xBlockSize = uxAddress - ( size_t ) pxFirstFreeBlock; + pxFirstFreeBlock->pxNextFreeBlock = pxEnd; + + /* Only one block exists - and it covers the entire usable heap space. */ + xMinimumEverFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; + xFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; + + /* Work out the position of the top bit in a size_t variable. */ + xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * secureheapBITS_PER_BYTE ) - 1 ); +} +/*-----------------------------------------------------------*/ + +static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ) +{ +BlockLink_t *pxIterator; +uint8_t *puc; + + /* Iterate through the list until a block is found that has a higher address + * than the block being inserted. */ + for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) + { + /* Nothing to do here, just iterate to the right position. */ + } + + /* Do the block being inserted, and the block it is being inserted after + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxIterator; + if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) + { + pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; + pxBlockToInsert = pxIterator; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Do the block being inserted, and the block it is being inserted before + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxBlockToInsert; + if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) + { + if( pxIterator->pxNextFreeBlock != pxEnd ) + { + /* Form one big block from the two blocks. */ + pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock; + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxEnd; + } + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; + } + + /* If the block being inserted plugged a gab, so was merged with the block + * before and the block after, then it's pxNextFreeBlock pointer will have + * already been set, and should not be set here as that would make it point + * to itself. */ + if( pxIterator != pxBlockToInsert ) + { + pxIterator->pxNextFreeBlock = pxBlockToInsert; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } +} +/*-----------------------------------------------------------*/ + +void *pvPortMalloc( size_t xWantedSize ) +{ +BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink; +void *pvReturn = NULL; + + /* If this is the first call to malloc then the heap will require + * initialisation to setup the list of free blocks. */ + if( pxEnd == NULL ) + { + prvHeapInit(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Check the requested block size is not so large that the top bit is set. + * The top bit of the block size member of the BlockLink_t structure is used + * to determine who owns the block - the application or the kernel, so it + * must be free. */ + if( ( xWantedSize & xBlockAllocatedBit ) == 0 ) + { + /* The wanted size is increased so it can contain a BlockLink_t + * structure in addition to the requested amount of bytes. */ + if( xWantedSize > 0 ) + { + xWantedSize += xHeapStructSize; + + /* Ensure that blocks are always aligned to the required number of + * bytes. */ + if( ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) != 0x00 ) + { + /* Byte alignment required. */ + xWantedSize += ( secureportBYTE_ALIGNMENT - ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) ); + secureportASSERT( ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) == 0 ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) + { + /* Traverse the list from the start (lowest address) block until + * one of adequate size is found. */ + pxPreviousBlock = &xStart; + pxBlock = xStart.pxNextFreeBlock; + while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) + { + pxPreviousBlock = pxBlock; + pxBlock = pxBlock->pxNextFreeBlock; + } + + /* If the end marker was reached then a block of adequate size was + * not found. */ + if( pxBlock != pxEnd ) + { + /* Return the memory space pointed to - jumping over the + * BlockLink_t structure at its start. */ + pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize ); + + /* This block is being returned for use so must be taken out + * of the list of free blocks. */ + pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; + + /* If the block is larger than required it can be split into + * two. */ + if( ( pxBlock->xBlockSize - xWantedSize ) > secureheapMINIMUM_BLOCK_SIZE ) + { + /* This block is to be split into two. Create a new + * block following the number of bytes requested. The void + * cast is used to prevent byte alignment warnings from the + * compiler. */ + pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize ); + secureportASSERT( ( ( ( size_t ) pxNewBlockLink ) & secureportBYTE_ALIGNMENT_MASK ) == 0 ); + + /* Calculate the sizes of two blocks split from the single + * block. */ + pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; + pxBlock->xBlockSize = xWantedSize; + + /* Insert the new block into the list of free blocks. */ + prvInsertBlockIntoFreeList( pxNewBlockLink ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + xFreeBytesRemaining -= pxBlock->xBlockSize; + + if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) + { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* The block is being returned - it is allocated and owned by + * the application and has no "next" block. */ + pxBlock->xBlockSize |= xBlockAllocatedBit; + pxBlock->pxNextFreeBlock = NULL; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + traceMALLOC( pvReturn, xWantedSize ); + + #if( secureconfigUSE_MALLOC_FAILED_HOOK == 1 ) + { + if( pvReturn == NULL ) + { + extern void vApplicationMallocFailedHook( void ); + vApplicationMallocFailedHook(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif + + secureportASSERT( ( ( ( size_t ) pvReturn ) & ( size_t ) secureportBYTE_ALIGNMENT_MASK ) == 0 ); + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void *pv ) +{ +uint8_t *puc = ( uint8_t * ) pv; +BlockLink_t *pxLink; + + if( pv != NULL ) + { + /* The memory being freed will have an BlockLink_t structure immediately + * before it. */ + puc -= xHeapStructSize; + + /* This casting is to keep the compiler from issuing warnings. */ + pxLink = ( void * ) puc; + + /* Check the block is actually allocated. */ + secureportASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ); + secureportASSERT( pxLink->pxNextFreeBlock == NULL ); + + if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) + { + if( pxLink->pxNextFreeBlock == NULL ) + { + /* The block is being returned to the heap - it is no longer + * allocated. */ + pxLink->xBlockSize &= ~xBlockAllocatedBit; + + secureportDISABLE_NON_SECURE_INTERRUPTS(); + { + /* Add this block to the list of free blocks. */ + xFreeBytesRemaining += pxLink->xBlockSize; + traceFREE( pv, pxLink->xBlockSize ); + prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) ); + } + secureportENABLE_NON_SECURE_INTERRUPTS(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } +} +/*-----------------------------------------------------------*/ + +size_t xPortGetFreeHeapSize( void ) +{ + return xFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +size_t xPortGetMinimumEverFreeHeapSize( void ) +{ + return xMinimumEverFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +void vPortInitialiseBlocks( void ) +{ + /* This just exists to keep the linker quiet. */ +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_heap.h b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_heap.h new file mode 100755 index 0000000..69e4f2a --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_heap.h @@ -0,0 +1,51 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_HEAP_H__ +#define __SECURE_HEAP_H__ + +/* Standard includes. */ +#include + +/** + * @brief Allocates memory from heap. + * + * @param[in] xWantedSize The size of the memory to be allocated. + * + * @return Pointer to the memory region if the allocation is successful, NULL + * otherwise. + */ +void *pvPortMalloc( size_t xWantedSize ); + +/** + * @brief Frees the previously allocated memory. + * + * @param[in] pv Pointer to the memory to be freed. + */ +void vPortFree( void *pv ); + +#endif /* __SECURE_HEAP_H__ */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_init.c b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_init.c new file mode 100755 index 0000000..c6525f7 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_init.c @@ -0,0 +1,105 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Secure init includes. */ +#include "secure_init.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief Constants required to manipulate the SCB. + */ +#define secureinitSCB_AIRCR ( ( volatile uint32_t * ) 0xe000ed0c ) /* Application Interrupt and Reset Control Register. */ +#define secureinitSCB_AIRCR_VECTKEY_POS ( 16UL ) +#define secureinitSCB_AIRCR_VECTKEY_MASK ( 0xFFFFUL << secureinitSCB_AIRCR_VECTKEY_POS ) +#define secureinitSCB_AIRCR_PRIS_POS ( 14UL ) +#define secureinitSCB_AIRCR_PRIS_MASK ( 1UL << secureinitSCB_AIRCR_PRIS_POS ) + +/** + * @brief Constants required to manipulate the FPU. + */ +#define secureinitFPCCR ( ( volatile uint32_t * ) 0xe000ef34 ) /* Floating Point Context Control Register. */ +#define secureinitFPCCR_LSPENS_POS ( 29UL ) +#define secureinitFPCCR_LSPENS_MASK ( 1UL << secureinitFPCCR_LSPENS_POS ) +#define secureinitFPCCR_TS_POS ( 26UL ) +#define secureinitFPCCR_TS_MASK ( 1UL << secureinitFPCCR_TS_POS ) + +#define secureinitNSACR ( ( volatile uint32_t * ) 0xe000ed8c ) /* Non-secure Access Control Register. */ +#define secureinitNSACR_CP10_POS ( 10UL ) +#define secureinitNSACR_CP10_MASK ( 1UL << secureinitNSACR_CP10_POS ) +#define secureinitNSACR_CP11_POS ( 11UL ) +#define secureinitNSACR_CP11_MASK ( 1UL << secureinitNSACR_CP11_POS ) +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureInit_DePrioritizeNSExceptions( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + *( secureinitSCB_AIRCR ) = ( *( secureinitSCB_AIRCR ) & ~( secureinitSCB_AIRCR_VECTKEY_MASK | secureinitSCB_AIRCR_PRIS_MASK ) ) | + ( ( 0x05FAUL << secureinitSCB_AIRCR_VECTKEY_POS ) & secureinitSCB_AIRCR_VECTKEY_MASK ) | + ( ( 0x1UL << secureinitSCB_AIRCR_PRIS_POS ) & secureinitSCB_AIRCR_PRIS_MASK ); + } +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureInit_EnableNSFPUAccess( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* CP10 = 1 ==> Non-secure access to the Floating Point Unit is + * permitted. CP11 should be programmed to the same value as CP10. */ + *( secureinitNSACR ) |= ( secureinitNSACR_CP10_MASK | secureinitNSACR_CP11_MASK ); + + /* LSPENS = 0 ==> LSPEN is writable fron non-secure state. This ensures + * that we can enable/disable lazy stacking in port.c file. */ + *( secureinitFPCCR ) &= ~ ( secureinitFPCCR_LSPENS_MASK ); + + /* TS = 1 ==> Treat FP registers as secure i.e. callee saved FP + * registers (S16-S31) are also pushed to stack on exception entry and + * restored on exception return. */ + *( secureinitFPCCR ) |= ( secureinitFPCCR_TS_MASK ); + } +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_init.h b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_init.h new file mode 100755 index 0000000..6c5bc71 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_init.h @@ -0,0 +1,53 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_INIT_H__ +#define __SECURE_INIT_H__ + +/** + * @brief De-prioritizes the non-secure exceptions. + * + * This is needed to ensure that the non-secure PendSV runs at the lowest + * priority. Context switch is done in the non-secure PendSV handler. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureInit_DePrioritizeNSExceptions( void ); + +/** + * @brief Sets up the Floating Point Unit (FPU) for Non-Secure access. + * + * Also sets FPCCR.TS=1 to ensure that the content of the Floating Point + * Registers are not leaked to the non-secure side. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureInit_EnableNSFPUAccess( void ); + +#endif /* __SECURE_INIT_H__ */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_port_macros.h b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_port_macros.h new file mode 100755 index 0000000..760edab --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/secure_port_macros.h @@ -0,0 +1,133 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_PORT_MACROS_H__ +#define __SECURE_PORT_MACROS_H__ + +/** + * @brief Byte alignment requirements. + */ +#define secureportBYTE_ALIGNMENT 8 +#define secureportBYTE_ALIGNMENT_MASK ( 0x0007 ) + +/** + * @brief Macro to declare a function as non-secure callable. + */ +#if defined( __IAR_SYSTEMS_ICC__ ) + #define secureportNON_SECURE_CALLABLE __cmse_nonsecure_entry __root +#else + #define secureportNON_SECURE_CALLABLE __attribute__((cmse_nonsecure_entry)) __attribute__((used)) +#endif + +/** + * @brief Set the secure PRIMASK value. + */ +#define secureportSET_SECURE_PRIMASK( ulPrimaskValue ) \ + __asm volatile ( "msr primask, %0" : : "r" ( ulPrimaskValue ) : "memory" ) + +/** + * @brief Set the non-secure PRIMASK value. + */ +#define secureportSET_NON_SECURE_PRIMASK( ulPrimaskValue ) \ + __asm volatile ( "msr primask_ns, %0" : : "r" ( ulPrimaskValue ) : "memory" ) + +/** + * @brief Read the PSP value in the given variable. + */ +#define secureportREAD_PSP( pucOutCurrentStackPointer ) \ + __asm volatile ( "mrs %0, psp" : "=r" ( pucOutCurrentStackPointer ) ) + +/** + * @brief Set the PSP to the given value. + */ +#define secureportSET_PSP( pucCurrentStackPointer ) \ + __asm volatile ( "msr psp, %0" : : "r" ( pucCurrentStackPointer ) ) + +/** + * @brief Set the PSPLIM to the given value. + */ +#define secureportSET_PSPLIM( pucStackLimit ) \ + __asm volatile ( "msr psplim, %0" : : "r" ( pucStackLimit ) ) + +/** + * @brief Set the NonSecure MSP to the given value. + */ +#define secureportSET_MSP_NS( pucMainStackPointer ) \ + __asm volatile ( "msr msp_ns, %0" : : "r" ( pucMainStackPointer ) ) + +/** + * @brief Set the CONTROL register to the given value. + */ +#define secureportSET_CONTROL( ulControl ) \ + __asm volatile ( "msr control, %0" : : "r" ( ulControl ) : "memory" ) + +/** + * @brief Read the Interrupt Program Status Register (IPSR) value in the given + * variable. + */ +#define secureportREAD_IPSR( ulIPSR ) \ + __asm volatile ( "mrs %0, ipsr" : "=r" ( ulIPSR ) ) + +/** + * @brief PRIMASK value to enable interrupts. + */ +#define secureportPRIMASK_ENABLE_INTERRUPTS_VAL 0 + +/** + * @brief PRIMASK value to disable interrupts. + */ +#define secureportPRIMASK_DISABLE_INTERRUPTS_VAL 1 + +/** + * @brief Disable secure interrupts. + */ +#define secureportDISABLE_SECURE_INTERRUPTS() secureportSET_SECURE_PRIMASK( secureportPRIMASK_DISABLE_INTERRUPTS_VAL ) + +/** + * @brief Disable non-secure interrupts. + * + * This effectively disables context switches. + */ +#define secureportDISABLE_NON_SECURE_INTERRUPTS() secureportSET_NON_SECURE_PRIMASK( secureportPRIMASK_DISABLE_INTERRUPTS_VAL ) + +/** + * @brief Enable non-secure interrupts. + */ +#define secureportENABLE_NON_SECURE_INTERRUPTS() secureportSET_NON_SECURE_PRIMASK( secureportPRIMASK_ENABLE_INTERRUPTS_VAL ) + +/** + * @brief Assert definition. + */ +#define secureportASSERT( x ) \ + if( ( x ) == 0 ) \ + { \ + secureportDISABLE_SECURE_INTERRUPTS(); \ + secureportDISABLE_NON_SECURE_INTERRUPTS(); \ + for( ;; ); \ + } + +#endif /* __SECURE_PORT_MACROS_H__ */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/port.c new file mode 100755 index 0000000..bd85a6f --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/port.c @@ -0,0 +1,899 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/* Portasm includes. */ +#include "portasm.h" + +#if( configENABLE_TRUSTZONE == 1 ) + /* Secure components includes. */ + #include "secure_context.h" + #include "secure_init.h" +#endif /* configENABLE_TRUSTZONE */ + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/** + * The FreeRTOS Cortex M33 port can be configured to run on the Secure Side only + * i.e. the processor boots as secure and never jumps to the non-secure side. + * The Trust Zone support in the port must be disabled in order to run FreeRTOS + * on the secure side. The following are the valid configuration seetings: + * + * 1. Run FreeRTOS on the Secure Side: + * configRUN_FREERTOS_SECURE_ONLY = 1 and configENABLE_TRUSTZONE = 0 + * + * 2. Run FreeRTOS on the Non-Secure Side with Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 1 + * + * 3. Run FreeRTOS on the Non-Secure Side only i.e. no Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 0 + */ +#if( ( configRUN_FREERTOS_SECURE_ONLY == 1 ) && ( configENABLE_TRUSTZONE == 1 ) ) + #error TrustZone needs to be disabled in order to run FreeRTOS on the Secure Side. +#endif +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the NVIC. + */ +#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t * ) 0xe000e010 ) +#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t * ) 0xe000e014 ) +#define portNVIC_SYSTICK_CURRENT_VALUE ( ( volatile uint32_t * ) 0xe000e018 ) +#define portNVIC_INT_CTRL ( ( volatile uint32_t * ) 0xe000ed04 ) +#define portNVIC_SYSPRI2 ( ( volatile uint32_t * ) 0xe000ed20 ) +#define portNVIC_SYSTICK_CLK ( 0x00000004 ) +#define portNVIC_SYSTICK_INT ( 0x00000002 ) +#define portNVIC_SYSTICK_ENABLE ( 0x00000001 ) +#define portNVIC_PENDSVSET ( 0x10000000 ) +#define portMIN_INTERRUPT_PRIORITY ( 255UL ) +#define portNVIC_PENDSV_PRI ( portMIN_INTERRUPT_PRIORITY << 16UL ) +#define portNVIC_SYSTICK_PRI ( portMIN_INTERRUPT_PRIORITY << 24UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the SCB. + */ +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( * ( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_MEM_FAULT_ENABLE ( 1UL << 16UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the FPU. + */ +#define portCPACR ( ( volatile uint32_t * ) 0xe000ed88 ) /* Coprocessor Access Control Register. */ +#define portCPACR_CP10_VALUE ( 3UL ) +#define portCPACR_CP11_VALUE portCPACR_CP10_VALUE +#define portCPACR_CP10_POS ( 20UL ) +#define portCPACR_CP11_POS ( 22UL ) + +#define portFPCCR ( ( volatile uint32_t * ) 0xe000ef34 ) /* Floating Point Context Control Register. */ +#define portFPCCR_ASPEN_POS ( 31UL ) +#define portFPCCR_ASPEN_MASK ( 1UL << portFPCCR_ASPEN_POS ) +#define portFPCCR_LSPEN_POS ( 30UL ) +#define portFPCCR_LSPEN_MASK ( 1UL << portFPCCR_LSPEN_POS ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the MPU. + */ +#define portMPU_TYPE_REG ( * ( ( volatile uint32_t * ) 0xe000ed90 ) ) +#define portMPU_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed94 ) ) +#define portMPU_RNR_REG ( * ( ( volatile uint32_t * ) 0xe000ed98 ) ) + +#define portMPU_RBAR_REG ( * ( ( volatile uint32_t * ) 0xe000ed9c ) ) +#define portMPU_RLAR_REG ( * ( ( volatile uint32_t * ) 0xe000eda0 ) ) + +#define portMPU_RBAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda4 ) ) +#define portMPU_RLAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda8 ) ) + +#define portMPU_RBAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edac ) ) +#define portMPU_RLAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edb0 ) ) + +#define portMPU_RBAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb4 ) ) +#define portMPU_RLAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb8 ) ) + +#define portMPU_MAIR0_REG ( * ( ( volatile uint32_t * ) 0xe000edc0 ) ) +#define portMPU_MAIR1_REG ( * ( ( volatile uint32_t * ) 0xe000edc4 ) ) + +#define portMPU_RBAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ +#define portMPU_RLAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ + +#define portMPU_MAIR_ATTR0_POS ( 0UL ) +#define portMPU_MAIR_ATTR0_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR1_POS ( 8UL ) +#define portMPU_MAIR_ATTR1_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR2_POS ( 16UL ) +#define portMPU_MAIR_ATTR2_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR3_POS ( 24UL ) +#define portMPU_MAIR_ATTR3_MASK ( 0xff000000 ) + +#define portMPU_MAIR_ATTR4_POS ( 0UL ) +#define portMPU_MAIR_ATTR4_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR5_POS ( 8UL ) +#define portMPU_MAIR_ATTR5_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR6_POS ( 16UL ) +#define portMPU_MAIR_ATTR6_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR7_POS ( 24UL ) +#define portMPU_MAIR_ATTR7_MASK ( 0xff000000 ) + +#define portMPU_RLAR_ATTR_INDEX0 ( 0UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX1 ( 1UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX2 ( 2UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX3 ( 3UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX4 ( 4UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX5 ( 5UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX6 ( 6UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX7 ( 7UL << 1UL ) + +#define portMPU_RLAR_REGION_ENABLE ( 1UL ) + +/* Enable privileged access to unmapped region. */ +#define portMPU_PRIV_BACKGROUND_ENABLE ( 1UL << 2UL ) + +/* Enable MPU. */ +#define portMPU_ENABLE ( 1UL << 0UL ) + +/* Expected value of the portMPU_TYPE register. */ +#define portEXPECTED_MPU_TYPE_VALUE ( 8UL << 8UL ) /* 8 regions, unified. */ +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to set up the initial stack. + */ +#define portINITIAL_XPSR ( 0x01000000 ) + +#if( configRUN_FREERTOS_SECURE_ONLY == 1 ) + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF FD + * 1111 1111 1111 1111 1111 1111 1111 1101 + * + * Bit[6] - 1 --> The exception was taken from the Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 1 --> The exception was taken to the Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xfffffffd ) +#else + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF BC + * 1111 1111 1111 1111 1111 1111 1011 1100 + * + * Bit[6] - 0 --> The exception was taken from the Non-Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 0 --> The exception was taken to the Non-Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xffffffbc ) +#endif /* configRUN_FREERTOS_SECURE_ONLY */ + +/** + * @brief CONTROL register privileged bit mask. + * + * Bit[0] in CONTROL register tells the privilege: + * Bit[0] = 0 ==> The task is privileged. + * Bit[0] = 1 ==> The task is not privileged. + */ +#define portCONTROL_PRIVILEGED_MASK ( 1UL << 0UL ) + +/** + * @brief Initial CONTROL register values. + */ +#define portINITIAL_CONTROL_UNPRIVILEGED ( 0x3 ) +#define portINITIAL_CONTROL_PRIVILEGED ( 0x2 ) + +/** + * @brief Let the user override the pre-loading of the initial LR with the + * address of prvTaskExitError() in case it messes up unwinding of the stack + * in the debugger. + */ +#ifdef configTASK_RETURN_ADDRESS + #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS +#else + #define portTASK_RETURN_ADDRESS prvTaskExitError +#endif + +/** + * @brief If portPRELOAD_REGISTERS then registers will be given an initial value + * when a task is created. This helps in debugging at the cost of code size. + */ +#define portPRELOAD_REGISTERS 1 + +/** + * @brief A task is created without a secure context, and must call + * portALLOCATE_SECURE_CONTEXT() to give itself a secure context before it makes + * any secure calls. + */ +#define portNO_SECURE_CONTEXT 0 +/*-----------------------------------------------------------*/ + +/** + * @brief Setup the timer to generate the tick interrupts. + */ +static void prvSetupTimerInterrupt( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Used to catch tasks that attempt to return from their implementing + * function. + */ +static void prvTaskExitError( void ); + +#if( configENABLE_MPU == 1 ) + /** + * @brief Setup the Memory Protection Unit (MPU). + */ + static void prvSetupMPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_MPU */ + +#if( configENABLE_FPU == 1 ) + /** + * @brief Setup the Floating Point Unit (FPU). + */ + static void prvSetupFPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_FPU */ + +/** + * @brief Yield the processor. + */ +void vPortYield( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Enter critical section. + */ +void vPortEnterCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Exit from critical section. + */ +void vPortExitCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief SysTick handler. + */ +void SysTick_Handler( void ) PRIVILEGED_FUNCTION; + +/** + * @brief C part of SVC handler. + */ +portDONT_DISCARD void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) PRIVILEGED_FUNCTION; +/*-----------------------------------------------------------*/ + +/** + * @brief Each task maintains its own interrupt status in the critical nesting + * variable. + */ +static volatile uint32_t ulCriticalNesting = 0xaaaaaaaaUL; + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Saved as part of the task context to indicate which context the + * task is using on the secure side. + */ + portDONT_DISCARD volatile SecureContextHandle_t xSecureContext = portNO_SECURE_CONTEXT; +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +static void prvSetupTimerInterrupt( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Stop and reset the SysTick. */ + *( portNVIC_SYSTICK_CTRL ) = 0UL; + *( portNVIC_SYSTICK_CURRENT_VALUE ) = 0UL; + + /* Configure SysTick to interrupt at the requested rate. */ + *( portNVIC_SYSTICK_LOAD ) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; + *( portNVIC_SYSTICK_CTRL ) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE; +} +/*-----------------------------------------------------------*/ + +static void prvTaskExitError( void ) +{ +volatile uint32_t ulDummy = 0UL; + + /* A function that implements a task must not exit or attempt to return to + * its caller as there is nothing to return to. If a task wants to exit it + * should instead call vTaskDelete( NULL ). Artificially force an assert() + * to be triggered if configASSERT() is defined, then stop here so + * application writers can catch the error. */ + configASSERT( ulCriticalNesting == ~0UL ); + portDISABLE_INTERRUPTS(); + + while( ulDummy == 0 ) + { + /* This file calls prvTaskExitError() after the scheduler has been + * started to remove a compiler warning about the function being + * defined but never called. ulDummy is used purely to quieten other + * warnings about code appearing after this function is called - making + * ulDummy volatile makes the compiler think the function could return + * and therefore not output an 'unreachable code' warning for code that + * appears after it. */ + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + static void prvSetupMPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __privileged_functions_start__; + extern uint32_t * __privileged_functions_end__; + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + extern uint32_t * __unprivileged_flash_start__; + extern uint32_t * __unprivileged_flash_end__; + extern uint32_t * __privileged_sram_start__; + extern uint32_t * __privileged_sram_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __privileged_functions_start__[]; + extern uint32_t __privileged_functions_end__[]; + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + extern uint32_t __unprivileged_flash_start__[]; + extern uint32_t __unprivileged_flash_end__[]; + extern uint32_t __privileged_sram_start__[]; + extern uint32_t __privileged_sram_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ + + /* Check that the MPU is present. */ + if( portMPU_TYPE_REG == portEXPECTED_MPU_TYPE_VALUE ) + { + /* MAIR0 - Index 0. */ + portMPU_MAIR0_REG |= ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + /* MAIR0 - Index 1. */ + portMPU_MAIR0_REG |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* Setup privileged flash as Read Only so that privileged tasks can + * read it but not modify. */ + portMPU_RNR_REG = portPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_functions_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_functions_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged flash as Read Only by both privileged and + * unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __unprivileged_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __unprivileged_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged syscalls flash as Read Only by both privileged + * and unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_SYSCALLS_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __syscalls_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __syscalls_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup RAM containing kernel data for privileged access only. */ + portMPU_RNR_REG = portPRIVILEGED_RAM_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_sram_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_sram_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Enable mem fault. */ + portSCB_SYS_HANDLER_CTRL_STATE_REG |= portSCB_MEM_FAULT_ENABLE; + + /* Enable MPU with privileged background access i.e. unmapped + * regions have privileged access. */ + portMPU_CTRL_REG |= ( portMPU_PRIV_BACKGROUND_ENABLE | portMPU_ENABLE ); + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_FPU == 1 ) + static void prvSetupFPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* Enable non-secure access to the FPU. */ + SecureInit_EnableNSFPUAccess(); + } + #endif /* configENABLE_TRUSTZONE */ + + /* CP10 = 11 ==> Full access to FPU i.e. both privileged and + * unprivileged code should be able to access FPU. CP11 should be + * programmed to the same value as CP10. */ + *( portCPACR ) |= ( ( portCPACR_CP10_VALUE << portCPACR_CP10_POS ) | + ( portCPACR_CP11_VALUE << portCPACR_CP11_POS ) + ); + + /* ASPEN = 1 ==> Hardware should automatically preserve floating point + * context on exception entry and restore on exception return. + * LSPEN = 1 ==> Enable lazy context save of FP state. */ + *( portFPCCR ) |= ( portFPCCR_ASPEN_MASK | portFPCCR_LSPEN_MASK ); + } +#endif /* configENABLE_FPU */ +/*-----------------------------------------------------------*/ + +void vPortYield( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Set a PendSV to request a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + portDISABLE_INTERRUPTS(); + ulCriticalNesting++; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + configASSERT( ulCriticalNesting ); + ulCriticalNesting--; + + if( ulCriticalNesting == 0 ) + { + portENABLE_INTERRUPTS(); + } +} +/*-----------------------------------------------------------*/ + +void SysTick_Handler( void ) /* PRIVILEGED_FUNCTION */ +{ +uint32_t ulPreviousMask; + + ulPreviousMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* Increment the RTOS tick. */ + if( xTaskIncrementTick() != pdFALSE ) + { + /* Pend a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulPreviousMask ); +} +/*-----------------------------------------------------------*/ + +void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) /* PRIVILEGED_FUNCTION portDONT_DISCARD */ +{ +#if( configENABLE_MPU == 1 ) + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ +#endif /* configENABLE_MPU */ + +uint32_t ulPC; + +#if( configENABLE_TRUSTZONE == 1 ) + uint32_t ulR0; + #if( configENABLE_MPU == 1 ) + uint32_t ulControl, ulIsTaskPrivileged; + #endif /* configENABLE_MPU */ +#endif /* configENABLE_TRUSTZONE */ +uint8_t ucSVCNumber; + + /* Register are stored on the stack in the following order - R0, R1, R2, R3, + * R12, LR, PC, xPSR. */ + ulPC = pulCallerStackAddress[ 6 ]; + ucSVCNumber = ( ( uint8_t *) ulPC )[ -2 ]; + + switch( ucSVCNumber ) + { + #if( configENABLE_TRUSTZONE == 1 ) + case portSVC_ALLOCATE_SECURE_CONTEXT: + { + /* R0 contains the stack size passed as parameter to the + * vPortAllocateSecureContext function. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + #if( configENABLE_MPU == 1 ) + { + /* Read the CONTROL register value. */ + __asm volatile ( "mrs %0, control" : "=r" ( ulControl ) ); + + /* The task that raised the SVC is privileged if Bit[0] + * in the CONTROL register is 0. */ + ulIsTaskPrivileged = ( ( ulControl & portCONTROL_PRIVILEGED_MASK ) == 0 ); + + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0, ulIsTaskPrivileged ); + } + #else + { + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0 ); + } + #endif /* configENABLE_MPU */ + + configASSERT( xSecureContext != NULL ); + SecureContext_LoadContext( xSecureContext ); + } + break; + + case portSVC_FREE_SECURE_CONTEXT: + { + /* R0 contains the secure context handle to be freed. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + /* Free the secure context. */ + SecureContext_FreeContext( ( SecureContextHandle_t ) ulR0 ); + } + break; + #endif /* configENABLE_TRUSTZONE */ + + case portSVC_START_SCHEDULER: + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* De-prioritize the non-secure exceptions so that the + * non-secure pendSV runs at the lowest priority. */ + SecureInit_DePrioritizeNSExceptions(); + + /* Initialize the secure context management system. */ + SecureContext_Init(); + } + #endif /* configENABLE_TRUSTZONE */ + + #if( configENABLE_FPU == 1 ) + { + /* Setup the Floating Point Unit (FPU). */ + prvSetupFPU(); + } + #endif /* configENABLE_FPU */ + + /* Setup the context of the first task so that the first task starts + * executing. */ + vRestoreContextOfFirstTask(); + } + break; + + #if( configENABLE_MPU == 1 ) + case portSVC_RAISE_PRIVILEGE: + { + /* Only raise the privilege, if the svc was raised from any of + * the system calls. */ + if( ulPC >= ( uint32_t ) __syscalls_flash_start__ && + ulPC <= ( uint32_t ) __syscalls_flash_end__ ) + { + vRaisePrivilege(); + } + } + break; + #endif /* configENABLE_MPU */ + + default: + { + /* Incorrect SVC call. */ + configASSERT( pdFALSE ); + } + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) /* PRIVILEGED_FUNCTION */ +#else + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) /* PRIVILEGED_FUNCTION */ +#endif /* configENABLE_MPU */ +{ + /* Simulate the stack frame as it would be created by a context switch + * interrupt. */ + #if( portPRELOAD_REGISTERS == 0 ) + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack -= 9; /* R11..R4, EXC_RETURN. */ + *pxTopOfStack = portINITIAL_EXC_RETURN; + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #else /* portPRELOAD_REGISTERS */ + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x12121212UL; /* R12 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x03030303UL; /* R3 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x02020202UL; /* R2 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x01010101UL; /* R1 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x11111111UL; /* R11 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x10101010UL; /* R10 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x09090909UL; /* R09 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x08080808UL; /* R08 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x07070707UL; /* R07 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x06060606UL; /* R06 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x05050505UL; /* R05 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x04040404UL; /* R04 */ + pxTopOfStack--; + *pxTopOfStack = portINITIAL_EXC_RETURN; /* EXC_RETURN */ + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #endif /* portPRELOAD_REGISTERS */ + + return pxTopOfStack; +} +/*-----------------------------------------------------------*/ + +BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + *( portNVIC_SYSPRI2 ) |= portNVIC_PENDSV_PRI; + *( portNVIC_SYSPRI2 ) |= portNVIC_SYSTICK_PRI; + + #if( configENABLE_MPU == 1 ) + { + /* Setup the Memory Protection Unit (MPU). */ + prvSetupMPU(); + } + #endif /* configENABLE_MPU */ + + /* Start the timer that generates the tick ISR. Interrupts are disabled + * here already. */ + prvSetupTimerInterrupt(); + + /* Initialize the critical nesting count ready for the first task. */ + ulCriticalNesting = 0; + + /* Start the first task. */ + vStartFirstTask(); + + /* Should never get here as the tasks will now be executing. Call the task + * exit error function to prevent compiler warnings about a static function + * not being called in the case that the application writer overrides this + * functionality by defining configTASK_RETURN_ADDRESS. Call + * vTaskSwitchContext() so link time optimization does not remove the + * symbol. */ + vTaskSwitchContext(); + prvTaskExitError(); + + /* Should not get here. */ + return 0; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Not implemented in ports where there is nothing to return to. + * Artificially force an assert. */ + configASSERT( ulCriticalNesting == 1000UL ); +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) + { + uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber; + int32_t lIndex = 0; + + /* Setup MAIR0. */ + xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + xMPUSettings->ulMAIR0 |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* This function is called automatically when the task is created - in + * which case the stack region parameters will be valid. At all other + * times the stack parameters will not be valid and it is assumed that + * the stack region has already been configured. */ + if( ulStackDepth > 0 ) + { + /* Define the region that allows access to the stack. */ + ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + + xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + } + + /* User supplied configurable regions. */ + for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ ) + { + /* If xRegions is NULL i.e. the task has not specified any MPU + * region, the else part ensures that all the configurable MPU + * regions are invalidated. */ + if( ( xRegions != NULL ) && ( xRegions[ lIndex ].ulLengthInBytes > 0UL ) ) + { + /* Translate the generic region definition contained in xRegions + * into the ARMv8 specific MPU settings that are then stored in + * xMPUSettings. */ + ulRegionStartAddress = ( ( uint32_t ) xRegions[ lIndex ].pvBaseAddress ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) xRegions[ lIndex ].pvBaseAddress + xRegions[ lIndex ].ulLengthInBytes - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + /* Start address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ); + + /* RO/RW. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_READ_ONLY ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_ONLY ); + } + else + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_WRITE ); + } + + /* XN. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_EXECUTE_NEVER ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_EXECUTE_NEVER ); + } + + /* End Address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Normal memory/ Device memory. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_DEVICE_MEMORY ) != 0 ) + { + /* Attr1 in MAIR0 is configured as device memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX1; + } + else + { + /* Attr1 in MAIR0 is configured as normal memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX0; + } + } + else + { + /* Invalidate the region. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = 0UL; + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = 0UL; + } + + lIndex++; + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.c b/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.c new file mode 100755 index 0000000..ba4a69c --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.c @@ -0,0 +1,321 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE ensures that PRIVILEGED_FUNCTION + * is defined correctly and privileged functions are placed in correct sections. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Portasm includes. */ +#include "portasm.h" + +/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE is needed to be defined only for the + * header files. */ +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +void vRestoreContextOfFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " \n" + " ldr r2, pxCurrentTCBConst2 \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r1, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r0, [r1] \n" /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " bic r4, #1 \n" /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + " str r4, [r2] \n" /* Disable MPU. */ + " \n" + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + " ldr r3, [r1] \n" /* r3 = *r1 i.e. r3 = MAIR0. */ + " ldr r2, xMAIR0Const2 \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r3, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst2 \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " movs r3, #4 \n" /* r3 = 4. */ + " str r3, [r2] \n" /* Program RNR = 4. */ + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + " ldr r2, xRBARConst2 \n" /* r2 = 0xe000ed9c [Location of RBAR]. */ + " ldmia r1!, {r4-r11} \n" /* Read 4 set of RBAR/RLAR registers from TCB. */ + " stmia r2!, {r4-r11} \n" /* Write 4 set of RBAR/RLAR registers using alias registers. */ + " \n" + " ldr r2, xMPUCTRLConst2 \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " orr r4, #1 \n" /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + " str r4, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " ldm r0!, {r1-r3} \n" /* Read from stack - r1 = PSPLIM, r2 = CONTROL and r3 = EXC_RETURN. */ + " msr psplim, r1 \n" /* Set this task's PSPLIM value. */ + " msr control, r2 \n" /* Set this task's CONTROL value. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r3 \n" /* Finally, branch to EXC_RETURN. */ + #else /* configENABLE_MPU */ + " ldm r0!, {r1-r2} \n" /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ + " msr psplim, r1 \n" /* Set this task's PSPLIM value. */ + " movs r1, #2 \n" /* r1 = 2. */ + " msr CONTROL, r1 \n" /* Switch to use PSP in the thread mode. */ + " adds r0, #32 \n" /* Discard everything up to r0. */ + " msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ + " isb \n" + " bx r2 \n" /* Finally, branch to EXC_RETURN. */ + #endif /* configENABLE_MPU */ + " \n" + " .align 4 \n" + "pxCurrentTCBConst2: .word pxCurrentTCB \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst2: .word 0xe000ed94 \n" + "xMAIR0Const2: .word 0xe000edc0 \n" + "xRNRConst2: .word 0xe000ed98 \n" + "xRBARConst2: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " tst r0, #1 \n" /* Perform r0 & 1 (bitwise AND) and update the conditions flag. */ + " ite ne \n" + " movne r0, #0 \n" /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + " moveq r0, #1 \n" /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + " bx lr \n" /* Return. */ + " \n" + " .align 4 \n" + ::: "r0", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vRaisePrivilege( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, control \n" /* Read the CONTROL register. */ + " bic r0, #1 \n" /* Clear the bit 0. */ + " msr control, r0 \n" /* Write back the new CONTROL value. */ + " bx lr \n" /* Return to the caller. */ + ::: "r0", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vResetPrivilege( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " orr r0, #1 \n" /* r0 = r0 | 1. */ + " msr control, r0 \n" /* CONTROL = r0. */ + " bx lr \n" /* Return to the caller. */ + :::"r0", "memory" + ); +} +/*-----------------------------------------------------------*/ + +void vStartFirstTask( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " ldr r0, xVTORConst \n" /* Use the NVIC offset register to locate the stack. */ + " ldr r0, [r0] \n" /* Read the VTOR register which gives the address of vector table. */ + " ldr r0, [r0] \n" /* The first entry in vector table is stack pointer. */ + " msr msp, r0 \n" /* Set the MSP back to the start of the stack. */ + " cpsie i \n" /* Globally enable interrupts. */ + " cpsie f \n" + " dsb \n" + " isb \n" + " svc %0 \n" /* System call to start the first task. */ + " nop \n" + " \n" + " .align 4 \n" + "xVTORConst: .word 0xe000ed08 \n" + :: "i" ( portSVC_START_SCHEDULER ) : "memory" + ); +} +/*-----------------------------------------------------------*/ + +uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " mrs r0, PRIMASK \n" + " cpsid i \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* To avoid compiler warnings. The return statement will never be reached, + * but some compilers warn if it is not included, while others won't compile + * if it is. */ + return 0; +#endif +} +/*-----------------------------------------------------------*/ + +void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " msr PRIMASK, r0 \n" + " bx lr \n" + ::: "memory" + ); + +#if !defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + /* Just to avoid compiler warning. ulMask is used from the asm code but + * the compiler can't see that. Some compilers generate warnings without + * the following line, while others generate warnings if the line is + * included. */ + ( void ) ulMask; +#endif +} +/*-----------------------------------------------------------*/ + +void PendSV_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " .syntax unified \n" + " \n" + " mrs r0, psp \n" /* Read PSP in r0. */ + #if( configENABLE_FPU == 1 ) + " tst lr, #0x10 \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + " it eq \n" + " vstmdbeq r0!, {s16-s31} \n" /* Store the FPU registers which are not saved automatically. */ + #endif /* configENABLE_FPU */ + #if( configENABLE_MPU == 1 ) + " mrs r1, psplim \n" /* r1 = PSPLIM. */ + " mrs r2, control \n" /* r2 = CONTROL. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " stmdb r0!, {r1-r11} \n" /* Store on the stack - PSPLIM, CONTROL, LR and registers that are not automatically saved. */ + #else /* configENABLE_MPU */ + " mrs r2, psplim \n" /* r2 = PSPLIM. */ + " mov r3, lr \n" /* r3 = LR/EXC_RETURN. */ + " stmdb r0!, {r2-r11} \n" /* Store on the stack - PSPLIM, LR and registers that are not automatically saved. */ + #endif /* configENABLE_MPU */ + " \n" + " ldr r2, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r1, [r2] \n" /* Read pxCurrentTCB. */ + " str r0, [r1] \n" /* Save the new top of stack in TCB. */ + " \n" + " cpsid i \n" + " bl vTaskSwitchContext \n" + " cpsie i \n" + " \n" + " ldr r2, pxCurrentTCBConst \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + " ldr r1, [r2] \n" /* Read pxCurrentTCB. */ + " ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. r0 now points to the top of stack. */ + " \n" + #if( configENABLE_MPU == 1 ) + " dmb \n" /* Complete outstanding transfers before disabling MPU. */ + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " bic r4, #1 \n" /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + " str r4, [r2] \n" /* Disable MPU. */ + " \n" + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + " ldr r3, [r1] \n" /* r3 = *r1 i.e. r3 = MAIR0. */ + " ldr r2, xMAIR0Const \n" /* r2 = 0xe000edc0 [Location of MAIR0]. */ + " str r3, [r2] \n" /* Program MAIR0. */ + " ldr r2, xRNRConst \n" /* r2 = 0xe000ed98 [Location of RNR]. */ + " movs r3, #4 \n" /* r3 = 4. */ + " str r3, [r2] \n" /* Program RNR = 4. */ + " adds r1, #4 \n" /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + " ldr r2, xRBARConst \n" /* r2 = 0xe000ed9c [Location of RBAR]. */ + " ldmia r1!, {r4-r11} \n" /* Read 4 sets of RBAR/RLAR registers from TCB. */ + " stmia r2!, {r4-r11} \n" /* Write 4 set of RBAR/RLAR registers using alias registers. */ + " \n" + " ldr r2, xMPUCTRLConst \n" /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + " ldr r4, [r2] \n" /* Read the value of MPU_CTRL. */ + " orr r4, #1 \n" /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + " str r4, [r2] \n" /* Enable MPU. */ + " dsb \n" /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " ldmia r0!, {r1-r11} \n" /* Read from stack - r1 = PSPLIM, r2 = CONTROL, r3 = LR and r4-r11 restored. */ + #else /* configENABLE_MPU */ + " ldmia r0!, {r2-r11} \n" /* Read from stack - r2 = PSPLIM, r3 = LR and r4-r11 restored. */ + #endif /* configENABLE_MPU */ + " \n" + #if( configENABLE_FPU == 1 ) + " tst r3, #0x10 \n" /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + " it eq \n" + " vldmiaeq r0!, {s16-s31} \n" /* Restore the FPU registers which are not restored automatically. */ + #endif /* configENABLE_FPU */ + " \n" + #if( configENABLE_MPU == 1 ) + " msr psplim, r1 \n" /* Restore the PSPLIM register value for the task. */ + " msr control, r2 \n" /* Restore the CONTROL register value for the task. */ + #else /* configENABLE_MPU */ + " msr psplim, r2 \n" /* Restore the PSPLIM register value for the task. */ + #endif /* configENABLE_MPU */ + " msr psp, r0 \n" /* Remember the new top of stack for the task. */ + " bx r3 \n" + " \n" + " .align 4 \n" + "pxCurrentTCBConst: .word pxCurrentTCB \n" + #if( configENABLE_MPU == 1 ) + "xMPUCTRLConst: .word 0xe000ed94 \n" + "xMAIR0Const: .word 0xe000edc0 \n" + "xRNRConst: .word 0xe000ed98 \n" + "xRBARConst: .word 0xe000ed9c \n" + #endif /* configENABLE_MPU */ + ); +} +/*-----------------------------------------------------------*/ + +void SVC_Handler( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */ +{ + __asm volatile + ( + " tst lr, #4 \n" + " ite eq \n" + " mrseq r0, msp \n" + " mrsne r0, psp \n" + " ldr r1, svchandler_address_const \n" + " bx r1 \n" + " \n" + " .align 4 \n" + "svchandler_address_const: .word vPortSVCHandler_C \n" + ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.h b/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.h new file mode 100755 index 0000000..2ecf04e --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.h @@ -0,0 +1,113 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __PORT_ASM_H__ +#define __PORT_ASM_H__ + +/* Scheduler includes. */ +#include "FreeRTOS.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/** + * @brief Restore the context of the first task so that the first task starts + * executing. + */ +void vRestoreContextOfFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +BaseType_t xIsPrivileged( void ) __attribute__ (( naked )); + +/** + * @brief Raises the privilege level by clearing the bit 0 of the CONTROL + * register. + * + * @note This is a privileged function and should only be called from the kenrel + * code. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vRaisePrivilege( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vResetPrivilege( void ) __attribute__ (( naked )); + +/** + * @brief Starts the first task. + */ +void vStartFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Disables interrupts. + */ +uint32_t ulSetInterruptMaskFromISR( void ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Enables interrupts. + */ +void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief PendSV Exception handler. + */ +void PendSV_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief SVC Handler. + */ +void SVC_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Allocate a Secure context for the calling task. + * + * @param[in] ulSecureStackSize The size of the stack to be allocated on the + * secure side for the calling task. + */ +void vPortAllocateSecureContext( uint32_t ulSecureStackSize ) __attribute__ (( naked )); + +/** + * @brief Free the task's secure context. + * + * @param[in] pulTCB Pointer to the Task Control Block (TCB) of the task. + */ +void vPortFreeSecureContext( uint32_t *pulTCB ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +#endif /* __PORT_ASM_H__ */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/portmacro.h new file mode 100755 index 0000000..d051ddc --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M33" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __attribute__(( used )) +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM3_MPU/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM3_MPU/port.c index 625b187..454f90f 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CM3_MPU/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CM3_MPU/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -114,13 +114,6 @@ static void prvSetupMPU( void ) PRIVILEGED_FUNCTION; */ static uint32_t prvGetMPURegionSizeSetting( uint32_t ulActualSizeInBytes ) PRIVILEGED_FUNCTION; -/* - * Checks to see if being called from the context of an unprivileged task, and - * if so raises the privilege level and returns false - otherwise does nothing - * other than return true. - */ -BaseType_t xPortRaisePrivilege( void ) __attribute__(( naked )); - /* * Setup the timer to generate the tick interrupts. The implementation in this * file is weak to allow application writers to change the timer used to @@ -146,6 +139,35 @@ static void prvRestoreContextOfFirstTask( void ) __attribute__(( naked )) PRIVIL */ static void prvSVCHandler( uint32_t *pulRegisters ) __attribute__(( noinline )) PRIVILEGED_FUNCTION; +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +BaseType_t xIsPrivileged( void ) __attribute__ (( naked )); + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vResetPrivilege( void ) __attribute__ (( naked )); + +/** + * @brief Calls the port specific code to raise the privilege. + * + * @return pdFALSE if privilege was raised, pdTRUE otherwise. + */ +extern BaseType_t xPortRaisePrivilege( void ); + +/** + * @brief If xRunningPrivileged is not pdTRUE, calls the port specific + * code to reset the privilege, otherwise does nothing. + */ +extern void vPortResetPrivilege( BaseType_t xRunningPrivileged ); /*-----------------------------------------------------------*/ /* Each task maintains its own interrupt status in the critical nesting @@ -585,21 +607,33 @@ uint32_t ulRegionSize, ulReturnValue = 4; } /*-----------------------------------------------------------*/ -BaseType_t xPortRaisePrivilege( void ) +BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */ { __asm volatile ( - " mrs r0, control \n" - " tst r0, #1 \n" /* Is the task running privileged? */ - " itte ne \n" - " movne r0, #0 \n" /* CONTROL[0]!=0, return false. */ - " svcne %0 \n" /* Switch to privileged. */ - " moveq r0, #1 \n" /* CONTROL[0]==0, return true. */ - " bx lr \n" - :: "i" (portSVC_RAISE_PRIVILEGE) : "r0", "memory" + " mrs r0, control \n" /* r0 = CONTROL. */ + " tst r0, #1 \n" /* Perform r0 & 1 (bitwise AND) and update the conditions flag. */ + " ite ne \n" + " movne r0, #0 \n" /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + " moveq r0, #1 \n" /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + " bx lr \n" /* Return. */ + " \n" + " .align 4 \n" + ::: "r0", "memory" ); +} +/*-----------------------------------------------------------*/ - return 0; +void vResetPrivilege( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " orr r0, #1 \n" /* r0 = r0 | 1. */ + " msr control, r0 \n" /* CONTROL = r0. */ + " bx lr \n" /* Return to the caller. */ + :::"r0", "memory" + ); } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM3_MPU/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM_CM3_MPU/portmacro.h index 2dfa6f8..3458b0e 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CM3_MPU/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ARM_CM3_MPU/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -200,18 +200,28 @@ not necessary for to use this port. They are defined so the common demo files #ifndef portFORCE_INLINE #define portFORCE_INLINE inline __attribute__(( always_inline)) #endif +/*-----------------------------------------------------------*/ -/* Set the privilege level to user mode if xRunningPrivileged is false. */ -portFORCE_INLINE static void vPortResetPrivilege( BaseType_t xRunningPrivileged ) -{ - if( xRunningPrivileged != pdTRUE ) - { - __asm volatile ( " mrs r0, control \n" \ - " orr r0, #1 \n" \ - " msr control, r0 \n" \ - :::"r0", "memory" ); - } -} +extern BaseType_t xIsPrivileged( void ); +extern void vResetPrivilege( void ); + +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +#define portIS_PRIVILEGED() xIsPrivileged() + +/** + * @brief Raise an SVC request to raise privilege. +*/ +#define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ +#define portRESET_PRIVILEGE() vResetPrivilege() /*-----------------------------------------------------------*/ portFORCE_INLINE static BaseType_t xPortIsInsideInterrupt( void ) @@ -281,6 +291,7 @@ portFORCE_INLINE static void vPortSetBASEPRI( uint32_t ulNewMaskValue ) } /*-----------------------------------------------------------*/ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) #ifdef __cplusplus } diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c index 8d8e2b5..720058f 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h index 2c85e78..fd31d22 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -233,6 +233,7 @@ portFORCE_INLINE static void vPortSetBASEPRI( uint32_t ulNewMaskValue ) } /*-----------------------------------------------------------*/ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) #ifdef __cplusplus } diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM4_MPU/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM4_MPU/port.c index dd2c0e2..9c68178 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CM4_MPU/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CM4_MPU/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -123,13 +123,6 @@ static void prvSetupMPU( void ) PRIVILEGED_FUNCTION; */ static uint32_t prvGetMPURegionSizeSetting( uint32_t ulActualSizeInBytes ) PRIVILEGED_FUNCTION; -/* - * Checks to see if being called from the context of an unprivileged task, and - * if so raises the privilege level and returns false - otherwise does nothing - * other than return true. - */ -BaseType_t xPortRaisePrivilege( void ) __attribute__(( naked )); - /* * Setup the timer to generate the tick interrupts. The implementation in this * file is weak to allow application writers to change the timer used to @@ -160,6 +153,35 @@ static void prvSVCHandler( uint32_t *pulRegisters ) __attribute__(( noinline )) */ static void vPortEnableVFP( void ) __attribute__ (( naked )); +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +BaseType_t xIsPrivileged( void ) __attribute__ (( naked )); + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vResetPrivilege( void ) __attribute__ (( naked )); + +/** + * @brief Calls the port specific code to raise the privilege. + * + * @return pdFALSE if privilege was raised, pdTRUE otherwise. + */ +extern BaseType_t xPortRaisePrivilege( void ); + +/** + * @brief If xRunningPrivileged is not pdTRUE, calls the port specific + * code to reset the privilege, otherwise does nothing. + */ +extern void vPortResetPrivilege( BaseType_t xRunningPrivileged ); /*-----------------------------------------------------------*/ /* Each task maintains its own interrupt status in the critical nesting @@ -573,7 +595,7 @@ extern uint32_t __privileged_data_end__[]; ( prvGetMPURegionSizeSetting( ( uint32_t ) __FLASH_segment_end__ - ( uint32_t ) __FLASH_segment_start__ ) ) | ( portMPU_REGION_ENABLE ); - /* Setup the first 16K for privileged only access (even though less + /* Setup the first nK for privileged only access (even though less than 10K is actually being used). This is where the kernel code is placed. */ portMPU_REGION_BASE_ADDRESS_REG = ( ( uint32_t ) __FLASH_segment_start__ ) | /* Base address. */ @@ -639,21 +661,33 @@ uint32_t ulRegionSize, ulReturnValue = 4; } /*-----------------------------------------------------------*/ -BaseType_t xPortRaisePrivilege( void ) +BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */ { __asm volatile ( - " mrs r0, control \n" - " tst r0, #1 \n" /* Is the task running privileged? */ - " itte ne \n" - " movne r0, #0 \n" /* CONTROL[0]!=0, return false. */ - " svcne %0 \n" /* Switch to privileged. */ - " moveq r0, #1 \n" /* CONTROL[0]==0, return true. */ - " bx lr \n" - :: "i" (portSVC_RAISE_PRIVILEGE) : "r0", "memory" + " mrs r0, control \n" /* r0 = CONTROL. */ + " tst r0, #1 \n" /* Perform r0 & 1 (bitwise AND) and update the conditions flag. */ + " ite ne \n" + " movne r0, #0 \n" /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + " moveq r0, #1 \n" /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + " bx lr \n" /* Return. */ + " \n" + " .align 4 \n" + ::: "r0", "memory" ); +} +/*-----------------------------------------------------------*/ - return 0; +void vResetPrivilege( void ) /* __attribute__ (( naked )) */ +{ + __asm volatile + ( + " mrs r0, control \n" /* r0 = CONTROL. */ + " orr r0, #1 \n" /* r0 = r0 | 1. */ + " msr control, r0 \n" /* CONTROL = r0. */ + " bx lr \n" /* Return to the caller. */ + :::"r0", "memory" + ); } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM4_MPU/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM_CM4_MPU/portmacro.h index 2dfa6f8..3458b0e 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CM4_MPU/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ARM_CM4_MPU/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -200,18 +200,28 @@ not necessary for to use this port. They are defined so the common demo files #ifndef portFORCE_INLINE #define portFORCE_INLINE inline __attribute__(( always_inline)) #endif +/*-----------------------------------------------------------*/ -/* Set the privilege level to user mode if xRunningPrivileged is false. */ -portFORCE_INLINE static void vPortResetPrivilege( BaseType_t xRunningPrivileged ) -{ - if( xRunningPrivileged != pdTRUE ) - { - __asm volatile ( " mrs r0, control \n" \ - " orr r0, #1 \n" \ - " msr control, r0 \n" \ - :::"r0", "memory" ); - } -} +extern BaseType_t xIsPrivileged( void ); +extern void vResetPrivilege( void ); + +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +#define portIS_PRIVILEGED() xIsPrivileged() + +/** + * @brief Raise an SVC request to raise privilege. +*/ +#define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ +#define portRESET_PRIVILEGE() vResetPrivilege() /*-----------------------------------------------------------*/ portFORCE_INLINE static BaseType_t xPortIsInsideInterrupt( void ) @@ -281,6 +291,7 @@ portFORCE_INLINE static void vPortSetBASEPRI( uint32_t ulNewMaskValue ) } /*-----------------------------------------------------------*/ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) #ifdef __cplusplus } diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1/port.c index b23ad9f..7822afb 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1/portmacro.h index 69ee6e9..62543ac 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -237,6 +237,7 @@ portFORCE_INLINE static void vPortSetBASEPRI( uint32_t ulNewMaskValue ) } /*-----------------------------------------------------------*/ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) #ifdef __cplusplus } diff --git a/FreeRTOS/Source/portable/GCC/ARM_CR5/port.c b/FreeRTOS/Source/portable/GCC/ARM_CR5/port.c index 1ccbb4f..1328c45 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CR5/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CR5/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM_CR5/portASM.S b/FreeRTOS/Source/portable/GCC/ARM_CR5/portASM.S index 217c635..cda842e 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CR5/portASM.S +++ b/FreeRTOS/Source/portable/GCC/ARM_CR5/portASM.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM_CR5/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM_CR5/portmacro.h index b57f116..5a4601c 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CR5/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ARM_CR5/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -189,5 +189,7 @@ number of bits implemented by the interrupt controller. */ #define portICCBPR_BINARY_POINT_REGISTER ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCBPR_BINARY_POINT_OFFSET ) ) ) #define portICCRPR_RUNNING_PRIORITY_REGISTER ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCRPR_RUNNING_PRIORITY_OFFSET ) ) ) +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) + #endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/GCC/ARM_CRx_No_GIC/port.c b/FreeRTOS/Source/portable/GCC/ARM_CRx_No_GIC/port.c index 58b620b..96e01f0 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CRx_No_GIC/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CRx_No_GIC/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM_CRx_No_GIC/portASM.S b/FreeRTOS/Source/portable/GCC/ARM_CRx_No_GIC/portASM.S index 1bc0fb9..a1c0077 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CRx_No_GIC/portASM.S +++ b/FreeRTOS/Source/portable/GCC/ARM_CRx_No_GIC/portASM.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ARM_CRx_No_GIC/portmacro.h b/FreeRTOS/Source/portable/GCC/ARM_CRx_No_GIC/portmacro.h index 4ca748c..a4505b0 100755 --- a/FreeRTOS/Source/portable/GCC/ARM_CRx_No_GIC/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ARM_CRx_No_GIC/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -164,6 +164,8 @@ void vPortTaskUsesFPU( void ); #define portNOP() __asm volatile( "NOP" ) #define portINLINE __inline +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) + #ifdef __cplusplus } /* extern C */ #endif diff --git a/FreeRTOS/Source/portable/GCC/ATMega323/port.c b/FreeRTOS/Source/portable/GCC/ATMega323/port.c index 8754e1c..1d968f0 100755 --- a/FreeRTOS/Source/portable/GCC/ATMega323/port.c +++ b/FreeRTOS/Source/portable/GCC/ATMega323/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ATMega323/portmacro.h b/FreeRTOS/Source/portable/GCC/ATMega323/portmacro.h index 580b7f0..998f24c 100755 --- a/FreeRTOS/Source/portable/GCC/ATMega323/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ATMega323/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/AVR32_UC3/port.c b/FreeRTOS/Source/portable/GCC/AVR32_UC3/port.c index cb8e9ee..4f00e4c 100755 --- a/FreeRTOS/Source/portable/GCC/AVR32_UC3/port.c +++ b/FreeRTOS/Source/portable/GCC/AVR32_UC3/port.c @@ -13,8 +13,8 @@ *****************************************************************************/ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/AVR32_UC3/portmacro.h b/FreeRTOS/Source/portable/GCC/AVR32_UC3/portmacro.h index e8e64df..7fb10ed 100755 --- a/FreeRTOS/Source/portable/GCC/AVR32_UC3/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/AVR32_UC3/portmacro.h @@ -13,8 +13,8 @@ *****************************************************************************/ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/CORTUS_APS3/port.c b/FreeRTOS/Source/portable/GCC/CORTUS_APS3/port.c index 98b3bb0..3ac5846 100755 --- a/FreeRTOS/Source/portable/GCC/CORTUS_APS3/port.c +++ b/FreeRTOS/Source/portable/GCC/CORTUS_APS3/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/CORTUS_APS3/portmacro.h b/FreeRTOS/Source/portable/GCC/CORTUS_APS3/portmacro.h index b7478cd..1192e03 100755 --- a/FreeRTOS/Source/portable/GCC/CORTUS_APS3/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/CORTUS_APS3/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ColdFire_V2/port.c b/FreeRTOS/Source/portable/GCC/ColdFire_V2/port.c index e2ebce8..1ee2add 100755 --- a/FreeRTOS/Source/portable/GCC/ColdFire_V2/port.c +++ b/FreeRTOS/Source/portable/GCC/ColdFire_V2/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ColdFire_V2/portasm.S b/FreeRTOS/Source/portable/GCC/ColdFire_V2/portasm.S index 4b80297..4076d4d 100755 --- a/FreeRTOS/Source/portable/GCC/ColdFire_V2/portasm.S +++ b/FreeRTOS/Source/portable/GCC/ColdFire_V2/portasm.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/ColdFire_V2/portmacro.h b/FreeRTOS/Source/portable/GCC/ColdFire_V2/portmacro.h index 63617b4..0fc0526 100755 --- a/FreeRTOS/Source/portable/GCC/ColdFire_V2/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/ColdFire_V2/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/H8S2329/port.c b/FreeRTOS/Source/portable/GCC/H8S2329/port.c index 235c56b..9f39b97 100755 --- a/FreeRTOS/Source/portable/GCC/H8S2329/port.c +++ b/FreeRTOS/Source/portable/GCC/H8S2329/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/H8S2329/portmacro.h b/FreeRTOS/Source/portable/GCC/H8S2329/portmacro.h index 796faab..05ec873 100755 --- a/FreeRTOS/Source/portable/GCC/H8S2329/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/H8S2329/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/HCS12/port.c b/FreeRTOS/Source/portable/GCC/HCS12/port.c index 0801e16..f1673c3 100755 --- a/FreeRTOS/Source/portable/GCC/HCS12/port.c +++ b/FreeRTOS/Source/portable/GCC/HCS12/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/HCS12/portmacro.h b/FreeRTOS/Source/portable/GCC/HCS12/portmacro.h index 813bcdf..2dceeb1 100755 --- a/FreeRTOS/Source/portable/GCC/HCS12/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/HCS12/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/IA32_flat/ISR_Support.h b/FreeRTOS/Source/portable/GCC/IA32_flat/ISR_Support.h index 1fe07e1..62fe635 100755 --- a/FreeRTOS/Source/portable/GCC/IA32_flat/ISR_Support.h +++ b/FreeRTOS/Source/portable/GCC/IA32_flat/ISR_Support.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/IA32_flat/port.c b/FreeRTOS/Source/portable/GCC/IA32_flat/port.c index 052b34d..96f88eb 100755 --- a/FreeRTOS/Source/portable/GCC/IA32_flat/port.c +++ b/FreeRTOS/Source/portable/GCC/IA32_flat/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/IA32_flat/portASM.S b/FreeRTOS/Source/portable/GCC/IA32_flat/portASM.S index 1b6b86c..fd5579b 100755 --- a/FreeRTOS/Source/portable/GCC/IA32_flat/portASM.S +++ b/FreeRTOS/Source/portable/GCC/IA32_flat/portASM.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/IA32_flat/portmacro.h b/FreeRTOS/Source/portable/GCC/IA32_flat/portmacro.h index 8a1b14e..913e73a 100755 --- a/FreeRTOS/Source/portable/GCC/IA32_flat/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/IA32_flat/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/MSP430F449/port.c b/FreeRTOS/Source/portable/GCC/MSP430F449/port.c index e71d83f..4fee812 100755 --- a/FreeRTOS/Source/portable/GCC/MSP430F449/port.c +++ b/FreeRTOS/Source/portable/GCC/MSP430F449/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/MSP430F449/portmacro.h b/FreeRTOS/Source/portable/GCC/MSP430F449/portmacro.h index 3ad31be..7ba66f2 100755 --- a/FreeRTOS/Source/portable/GCC/MSP430F449/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/MSP430F449/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/MicroBlaze/port.c b/FreeRTOS/Source/portable/GCC/MicroBlaze/port.c index 799f7a6..a453ea4 100755 --- a/FreeRTOS/Source/portable/GCC/MicroBlaze/port.c +++ b/FreeRTOS/Source/portable/GCC/MicroBlaze/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/MicroBlaze/portasm.s b/FreeRTOS/Source/portable/GCC/MicroBlaze/portasm.s index 49fc553..26baecf 100755 --- a/FreeRTOS/Source/portable/GCC/MicroBlaze/portasm.s +++ b/FreeRTOS/Source/portable/GCC/MicroBlaze/portasm.s @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/MicroBlaze/portmacro.h b/FreeRTOS/Source/portable/GCC/MicroBlaze/portmacro.h index b7a9d7b..157acf6 100755 --- a/FreeRTOS/Source/portable/GCC/MicroBlaze/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/MicroBlaze/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port.c b/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port.c index 2f31510..59a1564 100755 --- a/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port.c +++ b/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port_exceptions.c b/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port_exceptions.c index f412502..2b1cb28 100755 --- a/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port_exceptions.c +++ b/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port_exceptions.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/MicroBlazeV8/portasm.S b/FreeRTOS/Source/portable/GCC/MicroBlazeV8/portasm.S index 0e9de1a..c603041 100755 --- a/FreeRTOS/Source/portable/GCC/MicroBlazeV8/portasm.S +++ b/FreeRTOS/Source/portable/GCC/MicroBlazeV8/portasm.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/MicroBlazeV8/portmacro.h b/FreeRTOS/Source/portable/GCC/MicroBlazeV8/portmacro.h index 7d0bad3..a00cc89 100755 --- a/FreeRTOS/Source/portable/GCC/MicroBlazeV8/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/MicroBlazeV8/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/MicroBlazeV9/port.c b/FreeRTOS/Source/portable/GCC/MicroBlazeV9/port.c index 072f01e..5d8d7f4 100755 --- a/FreeRTOS/Source/portable/GCC/MicroBlazeV9/port.c +++ b/FreeRTOS/Source/portable/GCC/MicroBlazeV9/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/MicroBlazeV9/port_exceptions.c b/FreeRTOS/Source/portable/GCC/MicroBlazeV9/port_exceptions.c index f412502..2b1cb28 100755 --- a/FreeRTOS/Source/portable/GCC/MicroBlazeV9/port_exceptions.c +++ b/FreeRTOS/Source/portable/GCC/MicroBlazeV9/port_exceptions.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/MicroBlazeV9/portasm.S b/FreeRTOS/Source/portable/GCC/MicroBlazeV9/portasm.S index 0e9de1a..c603041 100755 --- a/FreeRTOS/Source/portable/GCC/MicroBlazeV9/portasm.S +++ b/FreeRTOS/Source/portable/GCC/MicroBlazeV9/portasm.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/MicroBlazeV9/portmacro.h b/FreeRTOS/Source/portable/GCC/MicroBlazeV9/portmacro.h index 7d0bad3..a00cc89 100755 --- a/FreeRTOS/Source/portable/GCC/MicroBlazeV9/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/MicroBlazeV9/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/NiosII/port.c b/FreeRTOS/Source/portable/GCC/NiosII/port.c index 2a8edc0..5aeebe4 100755 --- a/FreeRTOS/Source/portable/GCC/NiosII/port.c +++ b/FreeRTOS/Source/portable/GCC/NiosII/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/NiosII/port_asm.S b/FreeRTOS/Source/portable/GCC/NiosII/port_asm.S index 1ef2288..f34514b 100755 --- a/FreeRTOS/Source/portable/GCC/NiosII/port_asm.S +++ b/FreeRTOS/Source/portable/GCC/NiosII/port_asm.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/NiosII/portmacro.h b/FreeRTOS/Source/portable/GCC/NiosII/portmacro.h index 47cd651..632a92c 100755 --- a/FreeRTOS/Source/portable/GCC/NiosII/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/NiosII/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/FPU_Macros.h b/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/FPU_Macros.h index 5d1c411..4b1ca84 100755 --- a/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/FPU_Macros.h +++ b/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/FPU_Macros.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/port.c b/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/port.c index 1a11beb..e3fc58b 100755 --- a/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/port.c +++ b/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/portasm.S b/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/portasm.S index 3213a25..ebd74e3 100755 --- a/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/portasm.S +++ b/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/portasm.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/portmacro.h b/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/portmacro.h index b68881c..171140e 100755 --- a/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/PPC405_Xilinx/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/FPU_Macros.h b/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/FPU_Macros.h index 5d1c411..4b1ca84 100755 --- a/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/FPU_Macros.h +++ b/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/FPU_Macros.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/port.c b/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/port.c index c4501e6..105bff1 100755 --- a/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/port.c +++ b/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/portasm.S b/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/portasm.S index 3213a25..ebd74e3 100755 --- a/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/portasm.S +++ b/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/portasm.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/portmacro.h b/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/portmacro.h index b68881c..171140e 100755 --- a/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/PPC440_Xilinx/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/RISC-V-RV32/port.c b/FreeRTOS/Source/portable/GCC/RISC-V-RV32/port.c deleted file mode 100755 index 0a9e073..0000000 --- a/FreeRTOS/Source/portable/GCC/RISC-V-RV32/port.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ - -/*----------------------------------------------------------- - * Implementation of functions defined in portable.h for the RISC-V RV32 port. - *----------------------------------------------------------*/ - -/* Scheduler includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "portmacro.h" - -/* - * Setup the timer to generate the tick interrupts. The implementation in this - * file is weak to allow application writers to change the timer used to - * generate the tick interrupt. - */ -void vPortSetupTimerInterrupt( void ) __attribute__(( weak )); - -/* - * Used to catch tasks that attempt to return from their implementing function. - */ -static void prvTaskExitError( void ); - -/*-----------------------------------------------------------*/ - -/* Used to program the machine timer compare register. */ -static uint64_t ullNextTime = 0ULL; -static volatile uint64_t * const pullMachineTimerCompareRegister = ( volatile uint64_t * const ) ( configCTRL_BASE + 0x4000 ); - -/*-----------------------------------------------------------*/ - -void prvTaskExitError( void ) -{ -volatile uint32_t ulx = 0; - - /* A function that implements a task must not exit or attempt to return to - its caller as there is nothing to return to. If a task wants to exit it - should instead call vTaskDelete( NULL ). - - Artificially force an assert() to be triggered if configASSERT() is - defined, then stop here so application writers can catch the error. */ - configASSERT( ulx == ~0UL ); - portDISABLE_INTERRUPTS(); - for( ;; ); -} -/*-----------------------------------------------------------*/ - -/* - * See header file for description. - */ -StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) -{ - /* - X1 to X31 integer registers for the 'I' profile, X1 to X15 for the 'E' profile. - - Register ABI Name Description Saver - x0 zero Hard-wired zero - - x1 ra Return address Caller - x2 sp Stack pointer Callee - x3 gp Global pointer - - x4 tp Thread pointer - - x5-7 t0-2 Temporaries Caller - x8 s0/fp Saved register/Frame pointer Callee - x9 s1 Saved register Callee - x10-11 a0-1 Function Arguments/return values Caller - x12-17 a2-7 Function arguments Caller - x18-27 s2-11 Saved registers Callee - x28-31 t3-6 Temporaries Caller - */ - - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 31; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 30; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 29; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 28; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 27; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 26; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 25; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 24; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 23; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 22; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 21; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 20; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 19; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 18; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 17; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 16; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 15; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 14; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 13; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 12; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 11; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) pvParameters; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 9; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 8; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 7; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 6; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 5; - pxTopOfStack--; -// *pxTopOfStack = ( StackType_t ) 4; /* Thread pointer. */ -// pxTopOfStack--; -// *pxTopOfStack = ( StackType_t ) 3; /* Global pointer. */ -// pxTopOfStack--; -// *pxTopOfStack = ( StackType_t ) 2; /* Stack pointer. */ -// pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) prvTaskExitError; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) pxCode; - - return pxTopOfStack; -} -/*-----------------------------------------------------------*/ - -void vPortSetupTimerInterrupt( void ) -{ -uint32_t ulCurrentTimeHigh, ulCurrentTimeLow; -volatile uint32_t * const pulTimeHigh = ( volatile uint32_t * const ) ( configCTRL_BASE + 0xBFF8 ); -volatile uint32_t * const pulTimeLow = ( volatile uint32_t * const ) ( configCTRL_BASE + 0xBFFc ); - - do - { - ulCurrentTimeHigh = *pulTimeHigh; - ulCurrentTimeLow = *pulTimeLow; - } while( ulCurrentTimeHigh != *pulTimeHigh ); - - ullNextTime = ( uint64_t ) ulCurrentTimeHigh; - ullNextTime <<= 32ULL; - ullNextTime |= ( uint64_t ) ulCurrentTimeLow; - ullNextTime += ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ); - *pullMachineTimerCompareRegister = ullNextTime; - - /* Enable timer interrupt */ - __asm volatile( "csrs mie, %0" :: "r"(0x80) ); -} -/*-----------------------------------------------------------*/ - -void Software_IRQHandler( void ) -{ -volatile uint32_t * const ulSoftInterrupt = ( uint32_t * ) configCTRL_BASE; - - vTaskSwitchContext(); - - /* Clear software interrupt. */ - *ulSoftInterrupt = 0UL; -} -/*-----------------------------------------------------------*/ - - diff --git a/FreeRTOS/Source/portable/GCC/RISC-V-RV32/portASM.S b/FreeRTOS/Source/portable/GCC/RISC-V-RV32/portASM.S deleted file mode 100755 index f0bbf01..0000000 --- a/FreeRTOS/Source/portable/GCC/RISC-V-RV32/portASM.S +++ /dev/null @@ -1,176 +0,0 @@ -/* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and t - - o permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ - -#if __riscv_xlen == 64 - #error Not implemented yet - change lw to ld, and sw to sd. - #define WORD_SIZE 8 -#elif __riscv_xlen == 32 - #define WORD_SIZE 4 -#else - #error Assembler has not defined __riscv_xlen -#endif - -#define CONTEXT_SIZE ( 28 * WORD_SIZE ) - -.global xPortStartScheduler -.global vPortTrapHandler -.extern pxCurrentTCB -.extern handle_trap - -/*-----------------------------------------------------------*/ - -.align 8 -xPortStartScheduler: - lw sp, pxCurrentTCB /* Load pxCurrentTCB. */ - lw sp, 0( sp ) /* Read sp from first TCB member. */ - - lw x1, 0( sp ) /* Note for starting the scheduler the exception return address is used as the function return address. */ - lw x5, 2 * WORD_SIZE( sp ) /* t0 */ - lw x6, 3 * WORD_SIZE( sp ) /* t1 */ - lw x7, 4 * WORD_SIZE( sp ) /* t2 */ - lw x8, 5 * WORD_SIZE( sp ) /* s0/fp */ - lw x9, 6 * WORD_SIZE( sp ) /* s1 */ - lw x10, 7 * WORD_SIZE( sp ) /* a0 */ - lw x11, 8 * WORD_SIZE( sp ) /* a1 */ - lw x12, 9 * WORD_SIZE( sp ) /* a2 */ - lw x13, 10 * WORD_SIZE( sp ) /* a3 */ - lw x14, 11 * WORD_SIZE( sp ) /* a4 */ - lw x15, 12 * WORD_SIZE( sp ) /* a5 */ - lw x16, 13 * WORD_SIZE( sp ) /* a6 */ - lw x17, 14 * WORD_SIZE( sp ) /* a7 */ - lw x18, 15 * WORD_SIZE( sp ) /* s2 */ - lw x19, 16 * WORD_SIZE( sp ) /* s3 */ - lw x20, 17 * WORD_SIZE( sp ) /* s4 */ - lw x21, 18 * WORD_SIZE( sp ) /* s5 */ - lw x22, 19 * WORD_SIZE( sp ) /* s6 */ - lw x23, 20 * WORD_SIZE( sp ) /* s7 */ - lw x24, 21 * WORD_SIZE( sp ) /* s8 */ - lw x25, 22 * WORD_SIZE( sp ) /* s9 */ - lw x26, 23 * WORD_SIZE( sp ) /* s10 */ - lw x27, 24 * WORD_SIZE( sp ) /* s11 */ - lw x28, 25 * WORD_SIZE( sp ) /* t3 */ - lw x29, 26 * WORD_SIZE( sp ) /* t4 */ - lw x30, 27 * WORD_SIZE( sp ) /* t5 */ - lw x31, 28 * WORD_SIZE( sp ) /* t6 */ - addi sp, sp, CONTEXT_SIZE - csrs mstatus, 8 /* Enable machine interrupts. */ - csrs mie, 8 /* Enable soft interrupt. */ - ret - -/*-----------------------------------------------------------*/ - -.align 8 -vPortTrapHandler: - addi sp, sp, -CONTEXT_SIZE - sw x1, 1( sp ) - sw x5, 2 * WORD_SIZE( sp ) - sw x6, 3 * WORD_SIZE( sp ) - sw x7, 4 * WORD_SIZE( sp ) - sw x8, 5 * WORD_SIZE( sp ) - sw x9, 6 * WORD_SIZE( sp ) - sw x10, 7 * WORD_SIZE( sp ) - sw x11, 8 * WORD_SIZE( sp ) - sw x12, 9 * WORD_SIZE( sp ) - sw x13, 10 * WORD_SIZE( sp ) - sw x14, 11 * WORD_SIZE( sp ) - sw x15, 12 * WORD_SIZE( sp ) - sw x16, 13 * WORD_SIZE( sp ) - sw x17, 14 * WORD_SIZE( sp ) - sw x18, 15 * WORD_SIZE( sp ) - sw x19, 16 * WORD_SIZE( sp ) - sw x20, 17 * WORD_SIZE( sp ) - sw x21, 18 * WORD_SIZE( sp ) - sw x22, 19 * WORD_SIZE( sp ) - sw x23, 20 * WORD_SIZE( sp ) - sw x24, 21 * WORD_SIZE( sp ) - sw x25, 22 * WORD_SIZE( sp ) - sw x26, 23 * WORD_SIZE( sp ) - sw x27, 24 * WORD_SIZE( sp ) - sw x28, 25 * WORD_SIZE( sp ) - sw x29, 26 * WORD_SIZE( sp ) - sw x30, 27 * WORD_SIZE( sp ) - sw x31, 28 * WORD_SIZE( sp ) - - /* Save exception return address. */ - csrr t0, mepc - sw t0, 0( sp ) - - lw t0, pxCurrentTCB /* Load pxCurrentTCB. */ - sw sp, 0( t0 ) /* Write sp from first TCB member. */ - - csrr a0, mcause - csrr a1, mepc - mv a2, sp - jal handle_trap - csrw mepc, a0 - - # Remain in M-mode after mret - li t0, 0x00001800 /* MSTATUS MPP */ - csrs mstatus, t0 - - lw sp, pxCurrentTCB /* Load pxCurrentTCB. */ - lw sp, 0( sp ) /* Read sp from first TCB member. */ - - /* Load mret with the address of the first task. */ - lw t0, 0( sp ) - csrw mepc, t0 - - lw x1, 1( sp ) - lw x5, 2 * WORD_SIZE( sp ) /* t0 */ - lw x6, 3 * WORD_SIZE( sp ) /* t1 */ - lw x7, 4 * WORD_SIZE( sp ) /* t2 */ - lw x8, 5 * WORD_SIZE( sp ) /* s0/fp */ - lw x9, 6 * WORD_SIZE( sp ) /* s1 */ - lw x10, 7 * WORD_SIZE( sp ) /* a0 */ - lw x11, 8 * WORD_SIZE( sp ) /* a1 */ - lw x12, 9 * WORD_SIZE( sp ) /* a2 */ - lw x13, 10 * WORD_SIZE( sp ) /* a3 */ - lw x14, 11 * WORD_SIZE( sp ) /* a4 */ - lw x15, 12 * WORD_SIZE( sp ) /* a5 */ - lw x16, 13 * WORD_SIZE( sp ) /* a6 */ - lw x17, 14 * WORD_SIZE( sp ) /* a7 */ - lw x18, 15 * WORD_SIZE( sp ) /* s2 */ - lw x19, 16 * WORD_SIZE( sp ) /* s3 */ - lw x20, 17 * WORD_SIZE( sp ) /* s4 */ - lw x21, 18 * WORD_SIZE( sp ) /* s5 */ - lw x22, 19 * WORD_SIZE( sp ) /* s6 */ - lw x23, 20 * WORD_SIZE( sp ) /* s7 */ - lw x24, 21 * WORD_SIZE( sp ) /* s8 */ - lw x25, 22 * WORD_SIZE( sp ) /* s9 */ - lw x26, 23 * WORD_SIZE( sp ) /* s10 */ - lw x27, 24 * WORD_SIZE( sp ) /* s11 */ - lw x28, 25 * WORD_SIZE( sp ) /* t3 */ - lw x29, 26 * WORD_SIZE( sp ) /* t4 */ - lw x30, 27 * WORD_SIZE( sp ) /* t5 */ - lw x31, 28 * WORD_SIZE( sp ) /* t6 */ - addi sp, sp, CONTEXT_SIZE - - mret - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/ReadMe.url b/FreeRTOS/Source/portable/GCC/RISC-V/Documentation.url similarity index 50% rename from FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/ReadMe.url rename to FreeRTOS/Source/portable/GCC/RISC-V/Documentation.url index afc826f..6d32fd8 100755 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/ReadMe.url +++ b/FreeRTOS/Source/portable/GCC/RISC-V/Documentation.url @@ -1,5 +1,5 @@ -[InternetShortcut] -URL=http://www.freertos.org/cli -IDList= [{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 +Prop3=19,11 +[InternetShortcut] +IDList= +URL=https://freertos.org/Using-FreeRTOS-on-RISC-V.html diff --git a/FreeRTOS/Source/portable/GCC/RISC-V/chip_specific_extensions/Pulpino_Vega_RV32M1RM/freertos_risc_v_chip_specific_extensions.h b/FreeRTOS/Source/portable/GCC/RISC-V/chip_specific_extensions/Pulpino_Vega_RV32M1RM/freertos_risc_v_chip_specific_extensions.h new file mode 100755 index 0000000..ef95484 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/RISC-V/chip_specific_extensions/Pulpino_Vega_RV32M1RM/freertos_risc_v_chip_specific_extensions.h @@ -0,0 +1,109 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and t + + o permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* + * The FreeRTOS kernel's RISC-V port is split between the the code that is + * common across all currently supported RISC-V chips (implementations of the + * RISC-V ISA), and code that tailors the port to a specific RISC-V chip: + * + * + FreeRTOS\Source\portable\GCC\RISC-V-RV32\portASM.S contains the code that + * is common to all currently supported RISC-V chips. There is only one + * portASM.S file because the same file is built for all RISC-V target chips. + * + * + Header files called freertos_risc_v_chip_specific_extensions.h contain the + * code that tailors the FreeRTOS kernel's RISC-V port to a specific RISC-V + * chip. There are multiple freertos_risc_v_chip_specific_extensions.h files + * as there are multiple RISC-V chip implementations. + * + * !!!NOTE!!! + * TAKE CARE TO INCLUDE THE CORRECT freertos_risc_v_chip_specific_extensions.h + * HEADER FILE FOR THE CHIP IN USE. This is done using the assembler's (not the + * compiler's!) include path. For example, if the chip in use includes a core + * local interrupter (CLINT) and does not include any chip specific register + * extensions then add the path below to the assembler's include path: + * FreeRTOS\Source\portable\GCC\RISC-V-RV32\chip_specific_extensions\RV32I_CLINT_no_extensions + * + */ + +/* + * This freertos_risc_v_chip_specific_extensions.h is for use with Pulpino Ri5cy + * devices, developed and tested using the Vega board RV32M1RM. + */ + +#ifndef __FREERTOS_RISC_V_EXTENSIONS_H__ +#define __FREERTOS_RISC_V_EXTENSIONS_H__ + +#define portasmHAS_CLINT 0 + +/* Constants to define the additional registers found on the Pulpino RI5KY. */ +#define lpstart0 0x7b0 +#define lpend0 0x7b1 +#define lpcount0 0x7b2 +#define lpstart1 0x7b4 +#define lpend1 0x7b5 +#define lpcount1 0x7b6 + +/* Six additional registers to save and restore, as per the #defines above. */ +#define portasmADDITIONAL_CONTEXT_SIZE 6 /* Must be even number on 32-bit cores. */ + +/* Save additional registers found on the Pulpino. */ +.macro portasmSAVE_ADDITIONAL_REGISTERS + addi sp, sp, -(portasmADDITIONAL_CONTEXT_SIZE * portWORD_SIZE) /* Make room for the additional registers. */ + csrr t0, lpstart0 /* Load additional registers into accessible temporary registers. */ + csrr t1, lpend0 + csrr t2, lpcount0 + csrr t3, lpstart1 + csrr t4, lpend1 + csrr t5, lpcount1 + sw t0, 1 * portWORD_SIZE( sp ) + sw t1, 2 * portWORD_SIZE( sp ) + sw t2, 3 * portWORD_SIZE( sp ) + sw t3, 4 * portWORD_SIZE( sp ) + sw t4, 5 * portWORD_SIZE( sp ) + sw t5, 6 * portWORD_SIZE( sp ) + .endm + +/* Restore the additional registers found on the Pulpino. */ +.macro portasmRESTORE_ADDITIONAL_REGISTERS + lw t0, 1 * portWORD_SIZE( sp ) /* Load additional registers into accessible temporary registers. */ + lw t1, 2 * portWORD_SIZE( sp ) + lw t2, 3 * portWORD_SIZE( sp ) + lw t3, 4 * portWORD_SIZE( sp ) + lw t4, 5 * portWORD_SIZE( sp ) + lw t5, 6 * portWORD_SIZE( sp ) + csrw lpstart0, t0 + csrw lpend0, t1 + csrw lpcount0, t2 + csrw lpstart1, t3 + csrw lpend1, t4 + csrw lpcount1, t5 + addi sp, sp, (portasmADDITIONAL_CONTEXT_SIZE * portWORD_SIZE )/* Remove space added for additional registers. */ + .endm + +#endif /* __FREERTOS_RISC_V_EXTENSIONS_H__ */ diff --git a/FreeRTOS/Source/portable/GCC/RISC-V/chip_specific_extensions/RV32I_CLINT_no_extensions/freertos_risc_v_chip_specific_extensions.h b/FreeRTOS/Source/portable/GCC/RISC-V/chip_specific_extensions/RV32I_CLINT_no_extensions/freertos_risc_v_chip_specific_extensions.h new file mode 100755 index 0000000..b3562ab --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/RISC-V/chip_specific_extensions/RV32I_CLINT_no_extensions/freertos_risc_v_chip_specific_extensions.h @@ -0,0 +1,68 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* + * The FreeRTOS kernel's RISC-V port is split between the the code that is + * common across all currently supported RISC-V chips (implementations of the + * RISC-V ISA), and code that tailors the port to a specific RISC-V chip: + * + * + FreeRTOS\Source\portable\GCC\RISC-V-RV32\portASM.S contains the code that + * is common to all currently supported RISC-V chips. There is only one + * portASM.S file because the same file is built for all RISC-V target chips. + * + * + Header files called freertos_risc_v_chip_specific_extensions.h contain the + * code that tailors the FreeRTOS kernel's RISC-V port to a specific RISC-V + * chip. There are multiple freertos_risc_v_chip_specific_extensions.h files + * as there are multiple RISC-V chip implementations. + * + * !!!NOTE!!! + * TAKE CARE TO INCLUDE THE CORRECT freertos_risc_v_chip_specific_extensions.h + * HEADER FILE FOR THE CHIP IN USE. This is done using the assembler's (not the + * compiler's!) include path. For example, if the chip in use includes a core + * local interrupter (CLINT) and does not include any chip specific register + * extensions then add the path below to the assembler's include path: + * FreeRTOS\Source\portable\GCC\RISC-V-RV32\chip_specific_extensions\RV32I_CLINT_no_extensions + * + */ + + +#ifndef __FREERTOS_RISC_V_EXTENSIONS_H__ +#define __FREERTOS_RISC_V_EXTENSIONS_H__ + +#define portasmHAS_CLINT 1 +#define portasmADDITIONAL_CONTEXT_SIZE 0 /* Must be even number on 32-bit cores. */ + +.macro portasmSAVE_ADDITIONAL_REGISTERS + /* No additional registers to save, so this macro does nothing. */ + .endm + +/* Restore the additional registers found on the Pulpino. */ +.macro portasmRESTORE_ADDITIONAL_REGISTERS + /* No additional registers to restore, so this macro does nothing. */ + .endm + +#endif /* __FREERTOS_RISC_V_EXTENSIONS_H__ */ diff --git a/FreeRTOS/Source/portable/GCC/RISC-V/chip_specific_extensions/readme.txt b/FreeRTOS/Source/portable/GCC/RISC-V/chip_specific_extensions/readme.txt new file mode 100755 index 0000000..b24c0b9 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/RISC-V/chip_specific_extensions/readme.txt @@ -0,0 +1,23 @@ +/* + * The FreeRTOS kernel's RISC-V port is split between the the code that is + * common across all currently supported RISC-V chips (implementations of the + * RISC-V ISA), and code that tailors the port to a specific RISC-V chip: + * + * + FreeRTOS\Source\portable\GCC\RISC-V-RV32\portASM.S contains the code that + * is common to all currently supported RISC-V chips. There is only one + * portASM.S file because the same file is built for all RISC-V target chips. + * + * + Header files called freertos_risc_v_chip_specific_extensions.h contain the + * code that tailors the FreeRTOS kernel's RISC-V port to a specific RISC-V + * chip. There are multiple freertos_risc_v_chip_specific_extensions.h files + * as there are multiple RISC-V chip implementations. + * + * !!!NOTE!!! + * TAKE CARE TO INCLUDE THE CORRECT freertos_risc_v_chip_specific_extensions.h + * HEADER FILE FOR THE CHIP IN USE. This is done using the assembler's (not the + * compiler's!) include path. For example, if the chip in use includes a core + * local interrupter (CLINT) and does not include any chip specific register + * extensions then add the path below to the assembler's include path: + * FreeRTOS\Source\portable\GCC\RISC-V-RV32\chip_specific_extensions\RV32I_CLINT_no_extensions + * + */ diff --git a/FreeRTOS/Source/portable/GCC/RISC-V/port.c b/FreeRTOS/Source/portable/GCC/RISC-V/port.c new file mode 100755 index 0000000..3a35de3 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/RISC-V/port.c @@ -0,0 +1,189 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/*----------------------------------------------------------- + * Implementation of functions defined in portable.h for the RISC-V RV32 port. + *----------------------------------------------------------*/ + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" +#include "portmacro.h" + +#ifndef configCLINT_BASE_ADDRESS + #warning configCLINT_BASE_ADDRESS must be defined in FreeRTOSConfig.h. If the target chip includes a Core Local Interrupter (CLINT) then set configCLINT_BASE_ADDRESS to the CLINT base address. Otherwise set configCLINT_BASE_ADDRESS to 0. +#endif + +/* Let the user override the pre-loading of the initial LR with the address of +prvTaskExitError() in case it messes up unwinding of the stack in the +debugger. */ +#ifdef configTASK_RETURN_ADDRESS + #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS +#else + #define portTASK_RETURN_ADDRESS prvTaskExitError +#endif + +/* The stack used by interrupt service routines. Set configISR_STACK_SIZE_WORDS +to use a statically allocated array as the interrupt stack. Alternative leave +configISR_STACK_SIZE_WORDS undefined and update the linker script so that a +linker variable names __freertos_irq_stack_top has the same value as the top +of the stack used by main. Using the linker script method will repurpose the +stack that was used by main before the scheduler was started for use as the +interrupt stack after the scheduler has started. */ +#ifdef configISR_STACK_SIZE_WORDS + static __attribute__ ((aligned(16))) StackType_t xISRStack[ configISR_STACK_SIZE_WORDS ] = { 0 }; + const StackType_t xISRStackTop = ( StackType_t ) &( xISRStack[ ( configISR_STACK_SIZE_WORDS & ~portBYTE_ALIGNMENT_MASK ) - 1 ] ); +#else + extern const uint32_t __freertos_irq_stack_top[]; + const StackType_t xISRStackTop = ( StackType_t ) __freertos_irq_stack_top; +#endif + +/* + * Setup the timer to generate the tick interrupts. The implementation in this + * file is weak to allow application writers to change the timer used to + * generate the tick interrupt. + */ +void vPortSetupTimerInterrupt( void ) __attribute__(( weak )); + +/*-----------------------------------------------------------*/ + +/* Used to program the machine timer compare register. */ +uint64_t ullNextTime = 0ULL; +const uint64_t *pullNextTime = &ullNextTime; +const size_t uxTimerIncrementsForOneTick = ( size_t ) ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ); /* Assumes increment won't go over 32-bits. */ +volatile uint64_t * const pullMachineTimerCompareRegister = ( volatile uint64_t * const ) ( configCLINT_BASE_ADDRESS + 0x4000 ); + +/* Set configCHECK_FOR_STACK_OVERFLOW to 3 to add ISR stack checking to task +stack checking. A problem in the ISR stack will trigger an assert, not call the +stack overflow hook function (because the stack overflow hook is specific to a +task stack, not the ISR stack). */ +#if( configCHECK_FOR_STACK_OVERFLOW > 2 ) + #warning This path not tested, or even compiled yet. + /* Don't use 0xa5 as the stack fill bytes as that is used by the kernerl for + the task stacks, and so will legitimately appear in many positions within + the ISR stack. */ + #define portISR_STACK_FILL_BYTE 0xee + + static const uint8_t ucExpectedStackBytes[] = { + portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, \ + portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, \ + portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, \ + portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, \ + portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE }; \ + + #define portCHECK_ISR_STACK() configASSERT( ( memcmp( ( void * ) xISRStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) == 0 ) ) +#else + /* Define the function away. */ + #define portCHECK_ISR_STACK() +#endif /* configCHECK_FOR_STACK_OVERFLOW > 2 */ + +/*-----------------------------------------------------------*/ + +#if( configCLINT_BASE_ADDRESS != 0 ) + + void vPortSetupTimerInterrupt( void ) + { + uint32_t ulCurrentTimeHigh, ulCurrentTimeLow; + volatile uint32_t * const pulTimeHigh = ( volatile uint32_t * const ) ( configCLINT_BASE_ADDRESS + 0xBFFC ); + volatile uint32_t * const pulTimeLow = ( volatile uint32_t * const ) ( configCLINT_BASE_ADDRESS + 0xBFF8 ); + + do + { + ulCurrentTimeHigh = *pulTimeHigh; + ulCurrentTimeLow = *pulTimeLow; + } while( ulCurrentTimeHigh != *pulTimeHigh ); + + ullNextTime = ( uint64_t ) ulCurrentTimeHigh; + ullNextTime <<= 32ULL; + ullNextTime |= ( uint64_t ) ulCurrentTimeLow; + ullNextTime += ( uint64_t ) uxTimerIncrementsForOneTick; + *pullMachineTimerCompareRegister = ullNextTime; + + /* Prepare the time to use after the next tick interrupt. */ + ullNextTime += ( uint64_t ) uxTimerIncrementsForOneTick; + } + +#endif /* ( configCLINT_BASE_ADDRESS != 0 ) */ +/*-----------------------------------------------------------*/ + +BaseType_t xPortStartScheduler( void ) +{ +extern void xPortStartFirstTask( void ); + + #if( configASSERT_DEFINED == 1 ) + { + volatile uint32_t mtvec = 0; + + /* Check the least significant two bits of mtvec are 00 - indicating + single vector mode. */ + __asm volatile( "csrr %0, mtvec" : "=r"( mtvec ) ); + configASSERT( ( mtvec & 0x03UL ) == 0 ); + + /* Check alignment of the interrupt stack - which is the same as the + stack that was being used by main() prior to the scheduler being + started. */ + configASSERT( ( xISRStackTop & portBYTE_ALIGNMENT_MASK ) == 0 ); + } + #endif /* configASSERT_DEFINED */ + + /* If there is a CLINT then it is ok to use the default implementation + in this file, otherwise vPortSetupTimerInterrupt() must be implemented to + configure whichever clock is to be used to generate the tick interrupt. */ + vPortSetupTimerInterrupt(); + + #if( configCLINT_BASE_ADDRESS != 0 ) + { + /* Enable mtime and external interrupts. 1<<7 for timer interrupt, 1<<11 + for external interrupt. _RB_ What happens here when mtime is not present as + with pulpino? */ + __asm volatile( "csrs mie, %0" :: "r"(0x880) ); + } + #else + { + /* Enable external interrupts. */ + __asm volatile( "csrs mie, %0" :: "r"(0x800) ); + } + #endif /* configCLINT_BASE_ADDRESS */ + + xPortStartFirstTask(); + + /* Should not get here as after calling xPortStartFirstTask() only tasks + should be executing. */ + return pdFAIL; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) +{ + /* Not implemented. */ + for( ;; ); +} + + + + + diff --git a/FreeRTOS/Source/portable/GCC/RISC-V/portASM.S b/FreeRTOS/Source/portable/GCC/RISC-V/portASM.S new file mode 100755 index 0000000..7974f7e --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/RISC-V/portASM.S @@ -0,0 +1,420 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* + * The FreeRTOS kernel's RISC-V port is split between the the code that is + * common across all currently supported RISC-V chips (implementations of the + * RISC-V ISA), and code which tailors the port to a specific RISC-V chip: + * + * + The code that is common to all RISC-V chips is implemented in + * FreeRTOS\Source\portable\GCC\RISC-V-RV32\portASM.S. There is only one + * portASM.S file because the same file is used no matter which RISC-V chip is + * in use. + * + * + The code that tailors the kernel's RISC-V port to a specific RISC-V + * chip is implemented in freertos_risc_v_chip_specific_extensions.h. There + * is one freertos_risc_v_chip_specific_extensions.h that can be used with any + * RISC-V chip that both includes a standard CLINT and does not add to the + * base set of RISC-V registers. There are additional + * freertos_risc_v_chip_specific_extensions.h files for RISC-V implementations + * that do not include a standard CLINT or do add to the base set of RISC-V + * registers. + * + * CARE MUST BE TAKEN TO INCLDUE THE CORRECT + * freertos_risc_v_chip_specific_extensions.h HEADER FILE FOR THE CHIP + * IN USE. To include the correct freertos_risc_v_chip_specific_extensions.h + * header file ensure the path to the correct header file is in the assembler's + * include path. + * + * This freertos_risc_v_chip_specific_extensions.h is for use on RISC-V chips + * that include a standard CLINT and do not add to the base set of RISC-V + * registers. + * + */ +#if __riscv_xlen == 64 + #define portWORD_SIZE 8 + #define store_x sd + #define load_x ld +#elif __riscv_xlen == 32 + #define store_x sw + #define load_x lw + #define portWORD_SIZE 4 +#else + #error Assembler did not define __riscv_xlen +#endif + +#include "freertos_risc_v_chip_specific_extensions.h" + +/* Check the freertos_risc_v_chip_specific_extensions.h and/or command line +definitions. */ +#ifndef portasmHAS_CLINT + #error freertos_risc_v_chip_specific_extensions.h must define portasmHAS_CLINT to either 1 (CLINT present) or 0 (clint not present). +#endif + +#ifndef portasmHANDLE_INTERRUPT + #error portasmHANDLE_INTERRUPT must be defined to the function to be called to handle external/peripheral interrupts. portasmHANDLE_INTERRUPT can be defined on the assmbler command line or in the appropriate freertos_risc_v_chip_specific_extensions.h header file. +#endif + +/* Only the standard core registers are stored by default. Any additional +registers must be saved by the portasmSAVE_ADDITIONAL_REGISTERS and +portasmRESTORE_ADDITIONAL_REGISTERS macros - which can be defined in a chip +specific version of freertos_risc_v_chip_specific_extensions.h. See the notes +at the top of this file. */ +#define portCONTEXT_SIZE ( 30 * portWORD_SIZE ) + +.global xPortStartFirstTask +.global freertos_risc_v_trap_handler +.global pxPortInitialiseStack +.extern pxCurrentTCB +.extern ulPortTrapHandler +.extern vTaskSwitchContext +.extern Timer_IRQHandler +.extern pullMachineTimerCompareRegister +.extern pullNextTime +.extern uxTimerIncrementsForOneTick /* size_t type so 32-bit on 32-bit core and 64-bits on 64-bit core. */ +.extern xISRStackTop + +/*-----------------------------------------------------------*/ + +.align 8 +.func +freertos_risc_v_trap_handler: + addi sp, sp, -portCONTEXT_SIZE + store_x x1, 1 * portWORD_SIZE( sp ) + store_x x5, 2 * portWORD_SIZE( sp ) + store_x x6, 3 * portWORD_SIZE( sp ) + store_x x7, 4 * portWORD_SIZE( sp ) + store_x x8, 5 * portWORD_SIZE( sp ) + store_x x9, 6 * portWORD_SIZE( sp ) + store_x x10, 7 * portWORD_SIZE( sp ) + store_x x11, 8 * portWORD_SIZE( sp ) + store_x x12, 9 * portWORD_SIZE( sp ) + store_x x13, 10 * portWORD_SIZE( sp ) + store_x x14, 11 * portWORD_SIZE( sp ) + store_x x15, 12 * portWORD_SIZE( sp ) + store_x x16, 13 * portWORD_SIZE( sp ) + store_x x17, 14 * portWORD_SIZE( sp ) + store_x x18, 15 * portWORD_SIZE( sp ) + store_x x19, 16 * portWORD_SIZE( sp ) + store_x x20, 17 * portWORD_SIZE( sp ) + store_x x21, 18 * portWORD_SIZE( sp ) + store_x x22, 19 * portWORD_SIZE( sp ) + store_x x23, 20 * portWORD_SIZE( sp ) + store_x x24, 21 * portWORD_SIZE( sp ) + store_x x25, 22 * portWORD_SIZE( sp ) + store_x x26, 23 * portWORD_SIZE( sp ) + store_x x27, 24 * portWORD_SIZE( sp ) + store_x x28, 25 * portWORD_SIZE( sp ) + store_x x29, 26 * portWORD_SIZE( sp ) + store_x x30, 27 * portWORD_SIZE( sp ) + store_x x31, 28 * portWORD_SIZE( sp ) + + csrr t0, mstatus /* Required for MPIE bit. */ + store_x t0, 29 * portWORD_SIZE( sp ) + + portasmSAVE_ADDITIONAL_REGISTERS /* Defined in freertos_risc_v_chip_specific_extensions.h to save any registers unique to the RISC-V implementation. */ + + load_x t0, pxCurrentTCB /* Load pxCurrentTCB. */ + store_x sp, 0( t0 ) /* Write sp to first TCB member. */ + + csrr a0, mcause + csrr a1, mepc + +test_if_asynchronous: + srli a2, a0, __riscv_xlen - 1 /* MSB of mcause is 1 if handing an asynchronous interrupt - shift to LSB to clear other bits. */ + beq a2, x0, handle_synchronous /* Branch past interrupt handing if not asynchronous. */ + store_x a1, 0( sp ) /* Asynch so save unmodified exception return address. */ + +handle_asynchronous: + +#if( portasmHAS_CLINT != 0 ) + + test_if_mtimer: /* If there is a CLINT then the mtimer is used to generate the tick interrupt. */ + + addi t0, x0, 1 + + slli t0, t0, __riscv_xlen - 1 /* LSB is already set, shift into MSB. Shift 31 on 32-bit or 63 on 64-bit cores. */ + addi t1, t0, 7 /* 0x8000[]0007 == machine timer interrupt. */ + bne a0, t1, test_if_external_interrupt + + load_x t0, pullMachineTimerCompareRegister /* Load address of compare register into t0. */ + load_x t1, pullNextTime /* Load the address of ullNextTime into t1. */ + + #if( __riscv_xlen == 32 ) + + /* Update the 64-bit mtimer compare match value in two 32-bit writes. */ + lw t2, 0(t1) /* Load the low word of ullNextTime into t2. */ + lw t3, 4(t1) /* Load the high word of ullNextTime into t3. */ + sw t2, 0(t0) /* Store low word of ullNextTime into compare register. */ + sw t3, 4(t0) /* Store high word of ullNextTime into compare register. */ + lw t0, uxTimerIncrementsForOneTick /* Load the value of ullTimerIncrementForOneTick into t0 (could this be optimized by storing in an array next to pullNextTime?). */ + add t4, t0, t2 /* Add the low word of ullNextTime to the timer increments for one tick (assumes timer increment for one tick fits in 32-bits). */ + sltu t5, t4, t2 /* See if the sum of low words overflowed (what about the zero case?). */ + add t6, t3, t5 /* Add overflow to high word of ullNextTime. */ + sw t4, 0(t1) /* Store new low word of ullNextTime. */ + sw t6, 4(t1) /* Store new high word of ullNextTime. */ + + #endif /* __riscv_xlen == 32 */ + + #if( __riscv_xlen == 64 ) + + /* Update the 64-bit mtimer compare match value. */ + ld t2, 0(t1) /* Load ullNextTime into t2. */ + sd t2, 0(t0) /* Store ullNextTime into compare register. */ + ld t0, uxTimerIncrementsForOneTick /* Load the value of ullTimerIncrementForOneTick into t0 (could this be optimized by storing in an array next to pullNextTime?). */ + add t4, t0, t2 /* Add ullNextTime to the timer increments for one tick. */ + sd t4, 0(t1) /* Store ullNextTime. */ + + #endif /* __riscv_xlen == 64 */ + + load_x sp, xISRStackTop /* Switch to ISR stack before function call. */ + jal xTaskIncrementTick + beqz a0, processed_source /* Don't switch context if incrementing tick didn't unblock a task. */ + jal vTaskSwitchContext + j processed_source + + test_if_external_interrupt: /* If there is a CLINT and the mtimer interrupt is not pending then check to see if an external interrupt is pending. */ + addi t1, t1, 4 /* 0x80000007 + 4 = 0x8000000b == Machine external interrupt. */ + bne a0, t1, as_yet_unhandled /* Something as yet unhandled. */ + +#endif /* portasmHAS_CLINT */ + + load_x sp, xISRStackTop /* Switch to ISR stack before function call. */ + jal portasmHANDLE_INTERRUPT /* Jump to the interrupt handler if there is no CLINT or if there is a CLINT and it has been determined that an external interrupt is pending. */ + j processed_source + +handle_synchronous: + addi a1, a1, 4 /* Synchronous so updated exception return address to the instruction after the instruction that generated the exeption. */ + store_x a1, 0( sp ) /* Save updated exception return address. */ + +test_if_environment_call: + li t0, 11 /* 11 == environment call. */ + bne a0, t0, is_exception /* Not an M environment call, so some other exception. */ + load_x sp, xISRStackTop /* Switch to ISR stack before function call. */ + jal vTaskSwitchContext + j processed_source + +is_exception: + ebreak + j is_exception + +as_yet_unhandled: + ebreak + j as_yet_unhandled + +processed_source: + load_x t1, pxCurrentTCB /* Load pxCurrentTCB. */ + load_x sp, 0( t1 ) /* Read sp from first TCB member. */ + + /* Load mret with the address of the next instruction in the task to run next. */ + load_x t0, 0( sp ) + csrw mepc, t0 + + portasmRESTORE_ADDITIONAL_REGISTERS /* Defined in freertos_risc_v_chip_specific_extensions.h to restore any registers unique to the RISC-V implementation. */ + + /* Load mstatus with the interrupt enable bits used by the task. */ + load_x t0, 29 * portWORD_SIZE( sp ) + csrw mstatus, t0 /* Required for MPIE bit. */ + + load_x x1, 1 * portWORD_SIZE( sp ) + load_x x5, 2 * portWORD_SIZE( sp ) /* t0 */ + load_x x6, 3 * portWORD_SIZE( sp ) /* t1 */ + load_x x7, 4 * portWORD_SIZE( sp ) /* t2 */ + load_x x8, 5 * portWORD_SIZE( sp ) /* s0/fp */ + load_x x9, 6 * portWORD_SIZE( sp ) /* s1 */ + load_x x10, 7 * portWORD_SIZE( sp ) /* a0 */ + load_x x11, 8 * portWORD_SIZE( sp ) /* a1 */ + load_x x12, 9 * portWORD_SIZE( sp ) /* a2 */ + load_x x13, 10 * portWORD_SIZE( sp ) /* a3 */ + load_x x14, 11 * portWORD_SIZE( sp ) /* a4 */ + load_x x15, 12 * portWORD_SIZE( sp ) /* a5 */ + load_x x16, 13 * portWORD_SIZE( sp ) /* a6 */ + load_x x17, 14 * portWORD_SIZE( sp ) /* a7 */ + load_x x18, 15 * portWORD_SIZE( sp ) /* s2 */ + load_x x19, 16 * portWORD_SIZE( sp ) /* s3 */ + load_x x20, 17 * portWORD_SIZE( sp ) /* s4 */ + load_x x21, 18 * portWORD_SIZE( sp ) /* s5 */ + load_x x22, 19 * portWORD_SIZE( sp ) /* s6 */ + load_x x23, 20 * portWORD_SIZE( sp ) /* s7 */ + load_x x24, 21 * portWORD_SIZE( sp ) /* s8 */ + load_x x25, 22 * portWORD_SIZE( sp ) /* s9 */ + load_x x26, 23 * portWORD_SIZE( sp ) /* s10 */ + load_x x27, 24 * portWORD_SIZE( sp ) /* s11 */ + load_x x28, 25 * portWORD_SIZE( sp ) /* t3 */ + load_x x29, 26 * portWORD_SIZE( sp ) /* t4 */ + load_x x30, 27 * portWORD_SIZE( sp ) /* t5 */ + load_x x31, 28 * portWORD_SIZE( sp ) /* t6 */ + addi sp, sp, portCONTEXT_SIZE + + mret + .endfunc +/*-----------------------------------------------------------*/ + +.align 8 +.func +xPortStartFirstTask: + +#if( portasmHAS_CLINT != 0 ) + /* If there is a clint then interrupts can branch directly to the FreeRTOS + trap handler. Otherwise the interrupt controller will need to be configured + outside of this file. */ + la t0, freertos_risc_v_trap_handler + csrw mtvec, t0 +#endif /* portasmHAS_CLILNT */ + + load_x sp, pxCurrentTCB /* Load pxCurrentTCB. */ + load_x sp, 0( sp ) /* Read sp from first TCB member. */ + + load_x x1, 0( sp ) /* Note for starting the scheduler the exception return address is used as the function return address. */ + + portasmRESTORE_ADDITIONAL_REGISTERS /* Defined in freertos_risc_v_chip_specific_extensions.h to restore any registers unique to the RISC-V implementation. */ + + load_x t0, 29 * portWORD_SIZE( sp ) /* mstatus */ + csrrw x0, mstatus, t0 /* Interrupts enabled from here! */ + + load_x x5, 2 * portWORD_SIZE( sp ) /* t0 */ + load_x x6, 3 * portWORD_SIZE( sp ) /* t1 */ + load_x x7, 4 * portWORD_SIZE( sp ) /* t2 */ + load_x x8, 5 * portWORD_SIZE( sp ) /* s0/fp */ + load_x x9, 6 * portWORD_SIZE( sp ) /* s1 */ + load_x x10, 7 * portWORD_SIZE( sp ) /* a0 */ + load_x x11, 8 * portWORD_SIZE( sp ) /* a1 */ + load_x x12, 9 * portWORD_SIZE( sp ) /* a2 */ + load_x x13, 10 * portWORD_SIZE( sp ) /* a3 */ + load_x x14, 11 * portWORD_SIZE( sp ) /* a4 */ + load_x x15, 12 * portWORD_SIZE( sp ) /* a5 */ + load_x x16, 13 * portWORD_SIZE( sp ) /* a6 */ + load_x x17, 14 * portWORD_SIZE( sp ) /* a7 */ + load_x x18, 15 * portWORD_SIZE( sp ) /* s2 */ + load_x x19, 16 * portWORD_SIZE( sp ) /* s3 */ + load_x x20, 17 * portWORD_SIZE( sp ) /* s4 */ + load_x x21, 18 * portWORD_SIZE( sp ) /* s5 */ + load_x x22, 19 * portWORD_SIZE( sp ) /* s6 */ + load_x x23, 20 * portWORD_SIZE( sp ) /* s7 */ + load_x x24, 21 * portWORD_SIZE( sp ) /* s8 */ + load_x x25, 22 * portWORD_SIZE( sp ) /* s9 */ + load_x x26, 23 * portWORD_SIZE( sp ) /* s10 */ + load_x x27, 24 * portWORD_SIZE( sp ) /* s11 */ + load_x x28, 25 * portWORD_SIZE( sp ) /* t3 */ + load_x x29, 26 * portWORD_SIZE( sp ) /* t4 */ + load_x x30, 27 * portWORD_SIZE( sp ) /* t5 */ + load_x x31, 28 * portWORD_SIZE( sp ) /* t6 */ + addi sp, sp, portCONTEXT_SIZE + ret + .endfunc +/*-----------------------------------------------------------*/ + +/* + * Unlike other ports pxPortInitialiseStack() is written in assembly code as it + * needs access to the portasmADDITIONAL_CONTEXT_SIZE constant. The prototype + * for the function is as per the other ports: + * StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ); + * + * As per the standard RISC-V ABI pxTopcOfStack is passed in in a0, pxCode in + * a1, and pvParameters in a2. The new top of stack is passed out in a0. + * + * RISC-V maps registers to ABI names as follows (X1 to X31 integer registers + * for the 'I' profile, X1 to X15 for the 'E' profile, currently I assumed). + * + * Register ABI Name Description Saver + * x0 zero Hard-wired zero - + * x1 ra Return address Caller + * x2 sp Stack pointer Callee + * x3 gp Global pointer - + * x4 tp Thread pointer - + * x5-7 t0-2 Temporaries Caller + * x8 s0/fp Saved register/Frame pointer Callee + * x9 s1 Saved register Callee + * x10-11 a0-1 Function Arguments/return values Caller + * x12-17 a2-7 Function arguments Caller + * x18-27 s2-11 Saved registers Callee + * x28-31 t3-6 Temporaries Caller + * + * The RISC-V context is saved t FreeRTOS tasks in the following stack frame, + * where the global and thread pointers are currently assumed to be constant so + * are not saved: + * + * mstatus + * x31 + * x30 + * x29 + * x28 + * x27 + * x26 + * x25 + * x24 + * x23 + * x22 + * x21 + * x20 + * x19 + * x18 + * x17 + * x16 + * x15 + * x14 + * x13 + * x12 + * x11 + * pvParameters + * x9 + * x8 + * x7 + * x6 + * x5 + * portTASK_RETURN_ADDRESS + * [chip specific registers go here] + * pxCode + */ +.align 8 +.func +pxPortInitialiseStack: + + csrr t0, mstatus /* Obtain current mstatus value. */ + addi t1, x0, 0x188 /* Generate the value 0x1880, which are the MPIE and MPP bits to set in mstatus. */ + slli t1, t1, 4 + or t0, t0, t1 /* Set MPIE and MPP bits in mstatus value. */ + + addi a0, a0, -portWORD_SIZE + store_x t0, 0(a0) /* mstatus onto the stack. */ + addi a0, a0, -(22 * portWORD_SIZE) /* Space for registers x11-x31. */ + store_x a2, 0(a0) /* Task parameters (pvParameters parameter) goes into register X10/a0 on the stack. */ + addi a0, a0, -(6 * portWORD_SIZE) /* Space for registers x5-x9. */ + store_x x0, 0(a0) /* Return address onto the stack, could be portTASK_RETURN_ADDRESS */ + addi t0, x0, portasmADDITIONAL_CONTEXT_SIZE /* The number of chip specific additional registers. */ +chip_specific_stack_frame: /* First add any chip specific registers to the stack frame being created. */ + beq t0, x0, 1f /* No more chip specific registers to save. */ + addi a0, a0, -portWORD_SIZE /* Make space for chip specific register. */ + store_x x0, 0(a0) /* Give the chip specific register an initial value of zero. */ + addi t0, t0, -1 /* Decrement the count of chip specific registers remaining. */ + j chip_specific_stack_frame /* Until no more chip specific registers. */ +1: + addi a0, a0, -portWORD_SIZE + store_x a1, 0(a0) /* mret value (pxCode parameter) onto the stack. */ + ret + .endfunc +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/GCC/RISC-V/portmacro.h b/FreeRTOS/Source/portable/GCC/RISC-V/portmacro.h new file mode 100755 index 0000000..61ac5c8 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/RISC-V/portmacro.h @@ -0,0 +1,155 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*----------------------------------------------------------- + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the + * given hardware and compiler. + * + * These settings should not be altered. + *----------------------------------------------------------- + */ + +/* Type definitions. */ +#if __riscv_xlen == 64 + #define portSTACK_TYPE uint64_t + #define portBASE_TYPE int64_t + #define portUBASE_TYPE uint64_t + #define portMAX_DELAY ( TickType_t ) 0xffffffffffffffffUL + #define portPOINTER_SIZE_TYPE uint64_t +#elif __riscv_xlen == 32 + #define portSTACK_TYPE uint32_t + #define portBASE_TYPE int32_t + #define portUBASE_TYPE uint32_t + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL +#else + #error Assembler did not define __riscv_xlen +#endif + + +typedef portSTACK_TYPE StackType_t; +typedef portBASE_TYPE BaseType_t; +typedef portUBASE_TYPE UBaseType_t; +typedef portUBASE_TYPE TickType_t; + +/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do +not need to be guarded with a critical section. */ +#define portTICK_TYPE_IS_ATOMIC 1 +/*-----------------------------------------------------------*/ + +/* Architecture specifics. */ +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#ifdef __riscv64 + #error This is the RV32 port that has not yet been adapted for 64. + #define portBYTE_ALIGNMENT 16 +#else + #define portBYTE_ALIGNMENT 8 +#endif +/*-----------------------------------------------------------*/ + + +/* Scheduler utilities. */ +extern void vTaskSwitchContext( void ); +#define portYIELD() __asm volatile( "ecall" ); +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) vTaskSwitchContext() +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + + +/* Critical section management. */ +#define portCRITICAL_NESTING_IN_TCB 1 +extern void vTaskEnterCritical( void ); +extern void vTaskExitCritical( void ); + +#define portSET_INTERRUPT_MASK_FROM_ISR() 0 +#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue +#define portDISABLE_INTERRUPTS() __asm volatile( "csrc mstatus, 8" ) +#define portENABLE_INTERRUPTS() __asm volatile( "csrs mstatus, 8" ) +#define portENTER_CRITICAL() vTaskEnterCritical() +#define portEXIT_CRITICAL() vTaskExitCritical() + +/*-----------------------------------------------------------*/ + +/* Architecture specific optimisations. */ +#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION + #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +#endif + +#if( configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 ) + + /* Check the configuration. */ + #if( configMAX_PRIORITIES > 32 ) + #error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice. + #endif + + /* Store/clear the ready priorities in a bit map. */ + #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) ) + #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) ) + + /*-----------------------------------------------------------*/ + + #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - __builtin_clz( uxReadyPriorities ) ) + +#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ + + +/*-----------------------------------------------------------*/ + +/* Task function macros as described on the FreeRTOS.org WEB site. These are +not necessary for to use this port. They are defined so the common demo files +(which build with all the ports) will build. */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) + +/*-----------------------------------------------------------*/ + +#define portNOP() __asm volatile ( " nop " ) + +#define portINLINE __inline + +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline)) +#endif + +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ + diff --git a/FreeRTOS/Source/portable/GCC/RISC-V/readme.txt b/FreeRTOS/Source/portable/GCC/RISC-V/readme.txt new file mode 100755 index 0000000..b24c0b9 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/RISC-V/readme.txt @@ -0,0 +1,23 @@ +/* + * The FreeRTOS kernel's RISC-V port is split between the the code that is + * common across all currently supported RISC-V chips (implementations of the + * RISC-V ISA), and code that tailors the port to a specific RISC-V chip: + * + * + FreeRTOS\Source\portable\GCC\RISC-V-RV32\portASM.S contains the code that + * is common to all currently supported RISC-V chips. There is only one + * portASM.S file because the same file is built for all RISC-V target chips. + * + * + Header files called freertos_risc_v_chip_specific_extensions.h contain the + * code that tailors the FreeRTOS kernel's RISC-V port to a specific RISC-V + * chip. There are multiple freertos_risc_v_chip_specific_extensions.h files + * as there are multiple RISC-V chip implementations. + * + * !!!NOTE!!! + * TAKE CARE TO INCLUDE THE CORRECT freertos_risc_v_chip_specific_extensions.h + * HEADER FILE FOR THE CHIP IN USE. This is done using the assembler's (not the + * compiler's!) include path. For example, if the chip in use includes a core + * local interrupter (CLINT) and does not include any chip specific register + * extensions then add the path below to the assembler's include path: + * FreeRTOS\Source\portable\GCC\RISC-V-RV32\chip_specific_extensions\RV32I_CLINT_no_extensions + * + */ diff --git a/FreeRTOS/Source/portable/GCC/RL78/isr_support.h b/FreeRTOS/Source/portable/GCC/RL78/isr_support.h index 4185141..1a32cf3 100755 --- a/FreeRTOS/Source/portable/GCC/RL78/isr_support.h +++ b/FreeRTOS/Source/portable/GCC/RL78/isr_support.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/RL78/port.c b/FreeRTOS/Source/portable/GCC/RL78/port.c index 415c56d..906b5da 100755 --- a/FreeRTOS/Source/portable/GCC/RL78/port.c +++ b/FreeRTOS/Source/portable/GCC/RL78/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/RL78/portasm.S b/FreeRTOS/Source/portable/GCC/RL78/portasm.S index f18638a..17c0013 100755 --- a/FreeRTOS/Source/portable/GCC/RL78/portasm.S +++ b/FreeRTOS/Source/portable/GCC/RL78/portasm.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/RL78/portmacro.h b/FreeRTOS/Source/portable/GCC/RL78/portmacro.h index 9b722e9..4e15678 100755 --- a/FreeRTOS/Source/portable/GCC/RL78/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/RL78/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/RX100/port.c b/FreeRTOS/Source/portable/GCC/RX100/port.c index 8d5577d..b5c8d7d 100755 --- a/FreeRTOS/Source/portable/GCC/RX100/port.c +++ b/FreeRTOS/Source/portable/GCC/RX100/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/RX100/portmacro.h b/FreeRTOS/Source/portable/GCC/RX100/portmacro.h index a4666e8..7365139 100755 --- a/FreeRTOS/Source/portable/GCC/RX100/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/RX100/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/RX600/port.c b/FreeRTOS/Source/portable/GCC/RX600/port.c index 322657e..43c098b 100755 --- a/FreeRTOS/Source/portable/GCC/RX600/port.c +++ b/FreeRTOS/Source/portable/GCC/RX600/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/RX600/portmacro.h b/FreeRTOS/Source/portable/GCC/RX600/portmacro.h index 7be29ee..f2cd558 100755 --- a/FreeRTOS/Source/portable/GCC/RX600/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/RX600/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/RX600v2/port.c b/FreeRTOS/Source/portable/GCC/RX600v2/port.c index f9f1e9a..dfd0a69 100755 --- a/FreeRTOS/Source/portable/GCC/RX600v2/port.c +++ b/FreeRTOS/Source/portable/GCC/RX600v2/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/RX600v2/portmacro.h b/FreeRTOS/Source/portable/GCC/RX600v2/portmacro.h index 7be29ee..f2cd558 100755 --- a/FreeRTOS/Source/portable/GCC/RX600v2/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/RX600v2/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/STR75x/port.c b/FreeRTOS/Source/portable/GCC/STR75x/port.c index 0db41e1..f085ace 100755 --- a/FreeRTOS/Source/portable/GCC/STR75x/port.c +++ b/FreeRTOS/Source/portable/GCC/STR75x/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/STR75x/portISR.c b/FreeRTOS/Source/portable/GCC/STR75x/portISR.c index aea6f24..92b6884 100755 --- a/FreeRTOS/Source/portable/GCC/STR75x/portISR.c +++ b/FreeRTOS/Source/portable/GCC/STR75x/portISR.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/STR75x/portmacro.h b/FreeRTOS/Source/portable/GCC/STR75x/portmacro.h index bb6e0c7..26a777a 100755 --- a/FreeRTOS/Source/portable/GCC/STR75x/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/STR75x/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/TriCore_1782/port.c b/FreeRTOS/Source/portable/GCC/TriCore_1782/port.c index ff4b2b5..91661c3 100755 --- a/FreeRTOS/Source/portable/GCC/TriCore_1782/port.c +++ b/FreeRTOS/Source/portable/GCC/TriCore_1782/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/TriCore_1782/portmacro.h b/FreeRTOS/Source/portable/GCC/TriCore_1782/portmacro.h index c4d73ae..6e335e8 100755 --- a/FreeRTOS/Source/portable/GCC/TriCore_1782/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/TriCore_1782/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/TriCore_1782/porttrap.c b/FreeRTOS/Source/portable/GCC/TriCore_1782/porttrap.c index 396e014..530b4f0 100755 --- a/FreeRTOS/Source/portable/GCC/TriCore_1782/porttrap.c +++ b/FreeRTOS/Source/portable/GCC/TriCore_1782/porttrap.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/GCC/nrf52840-dk/port.c b/FreeRTOS/Source/portable/GCC/nrf52840-dk/port.c new file mode 100755 index 0000000..5b5b4f1 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/nrf52840-dk/port.c @@ -0,0 +1,148 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/*----------------------------------------------------------- + * Implementation of functions defined in portable.h for the ARM CM4F port. + *----------------------------------------------------------*/ + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* + * Start first task is a separate function so it can be tested in isolation. + */ +void vPortStartFirstTask( void ) __attribute__ (( naked )); + +/* + * Exception handlers. + */ +void vPortSVCHandler( void ) __attribute__ (( naked )); +void xPortPendSVHandler( void ) __attribute__ (( naked )); + + +/*-----------------------------------------------------------*/ + +void vPortStartFirstTask( void ) +{ + __asm volatile( +#if defined(__SES_ARM) + " ldr r0, =_vectors \n" /* Locate the stack using _vectors table. */ +#else + " ldr r0, =__isr_vector \n" /* Locate the stack using __isr_vector table. */ +#endif + " ldr r0, [r0] \n" + " msr msp, r0 \n" /* Set the msp back to the start of the stack. */ + " cpsie i \n" /* Globally enable interrupts. */ + " cpsie f \n" + " dsb \n" + " isb \n" +#ifdef SOFTDEVICE_PRESENT + /* Block kernel interrupts only (PendSV) before calling SVC */ + " mov r0, %0 \n" + " msr basepri, r0 \n" +#endif + " svc 0 \n" /* System call to start first task. */ + " \n" + " .align 2 \n" +#ifdef SOFTDEVICE_PRESENT + ::"i"(configKERNEL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) +#endif + ); +} + +/*-----------------------------------------------------------*/ + +void vPortSVCHandler( void ) +{ + __asm volatile ( + " ldr r3, =pxCurrentTCB \n" /* Restore the context. */ + " ldr r1, [r3] \n" /* Use pxCurrentTCBConst to get the pxCurrentTCB address. */ + " ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */ + " ldmia r0!, {r4-r11, r14} \n" /* Pop the registers that are not automatically saved on exception entry and the critical nesting count. */ + " msr psp, r0 \n" /* Restore the task stack pointer. */ + " isb \n" + " mov r0, #0 \n" + " msr basepri, r0 \n" + " bx r14 \n" + " \n" + " .align 2 \n" + ); +} + +/*-----------------------------------------------------------*/ + +void xPortPendSVHandler( void ) +{ + /* This is a naked function. */ + + __asm volatile + ( + " mrs r0, psp \n" + " isb \n" + " \n" + " ldr r3, =pxCurrentTCB \n" /* Get the location of the current TCB. */ + " ldr r2, [r3] \n" + " \n" + " tst r14, #0x10 \n" /* Is the task using the FPU context? If so, push high vfp registers. */ + " it eq \n" + " vstmdbeq r0!, {s16-s31} \n" + " \n" + " stmdb r0!, {r4-r11, r14} \n" /* Save the core registers. */ + " \n" + " str r0, [r2] \n" /* Save the new top of stack into the first member of the TCB. */ + " \n" + " stmdb sp!, {r3} \n" + " mov r0, %0 \n" + " msr basepri, r0 \n" + " dsb \n" + " isb \n" + " bl vTaskSwitchContext \n" + " mov r0, #0 \n" + " msr basepri, r0 \n" + " ldmia sp!, {r3} \n" + " \n" + " ldr r1, [r3] \n" /* The first item in pxCurrentTCB is the task top of stack. */ + " ldr r0, [r1] \n" + " \n" + " ldmia r0!, {r4-r11, r14} \n" /* Pop the core registers. */ + " \n" + " tst r14, #0x10 \n" /* Is the task using the FPU context? If so, pop the high vfp registers too. */ + " it eq \n" + " vldmiaeq r0!, {s16-s31} \n" + " \n" + " msr psp, r0 \n" + " isb \n" + " \n" + " \n" + " bx r14 \n" + " \n" + " .align 2 \n" + ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) + ); +} diff --git a/FreeRTOS/Source/portable/GCC/nrf52840-dk/port_cmsis.c b/FreeRTOS/Source/portable/GCC/nrf52840-dk/port_cmsis.c new file mode 100755 index 0000000..2fbec43 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/nrf52840-dk/port_cmsis.c @@ -0,0 +1,357 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/*----------------------------------------------------------- + * Implementation of functions defined in portable.h for the ARM CM4F port. + *----------------------------------------------------------*/ + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" +#ifdef SOFTDEVICE_PRESENT +#include "nrf_soc.h" +#include "app_util.h" +#include "app_util_platform.h" +#endif + +#if !(__FPU_USED) && !(__LINT__) + #error This port can only be used when the project options are configured to enable hardware floating point support. +#endif + +#if configMAX_SYSCALL_INTERRUPT_PRIORITY == 0 + #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html +#endif + +/* Constants used to detect a Cortex-M7 r0p1 core, which should use the ARM_CM7 +r0p1 port. */ +#define portCORTEX_M4_r0p1_ID ( 0x410FC241UL ) + +/* Constants required to check the validity of an interrupt priority. */ +#define portFIRST_USER_INTERRUPT_NUMBER ( 16 ) +#define portMAX_8_BIT_VALUE ( ( uint8_t ) 0xff ) +#define portTOP_BIT_OF_BYTE ( ( uint8_t ) 0x80 ) + +/* Constants required to set up the initial stack. */ +#define portINITIAL_XPSR (((xPSR_Type){.b.T = 1}).w) +#define portINITIAL_EXEC_RETURN ( 0xfffffffd ) + +/* Let the user override the pre-loading of the initial LR with the address of +prvTaskExitError() in case is messes up unwinding of the stack in the +debugger. */ +#ifdef configTASK_RETURN_ADDRESS + #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS +#else + #define portTASK_RETURN_ADDRESS prvTaskExitError +#endif + +/* Each task maintains its own interrupt status in the critical nesting +variable. */ +static UBaseType_t uxCriticalNesting = 0; + +/* + * Setup the timer to generate the tick interrupts. The implementation in this + * file is weak to allow application writers to change the timer used to + * generate the tick interrupt. + */ +extern void vPortSetupTimerInterrupt( void ); + +/* + * Exception handlers. + */ +void xPortSysTickHandler( void ); + +/* + * Start first task is a separate function so it can be tested in isolation. + */ +extern void vPortStartFirstTask( void ); + +/* + * Function to enable the VFP. + */ +static void vPortEnableVFP( void ); + +/* + * Used to catch tasks that attempt to return from their implementing function. + */ +static void prvTaskExitError( void ); + +/*-----------------------------------------------------------*/ + +/* + * Used by the portASSERT_IF_INTERRUPT_PRIORITY_INVALID() macro to ensure + * FreeRTOS API functions are not called from interrupts that have been assigned + * a priority above configMAX_SYSCALL_INTERRUPT_PRIORITY. + */ +#if ( configASSERT_DEFINED == 1 ) + static uint8_t ucMaxSysCallPriority = 0; + static uint32_t ulMaxPRIGROUPValue = 0; +#endif /* configASSERT_DEFINED */ + +/*-----------------------------------------------------------*/ + +/* + * See header file for description. + */ +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) +{ + /* Simulate the stack frame as it would be created by a context switch + interrupt. */ + + /* Offset added to account for the way the MCU uses the stack on entry/exit + of interrupts, and to ensure alignment. */ + pxTopOfStack--; + + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + + /* Save code space by skipping register initialisation. */ + pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + + /* A save method is being used that requires each task to maintain its + own exec return value. */ + pxTopOfStack--; + *pxTopOfStack = portINITIAL_EXEC_RETURN; + + pxTopOfStack -= 8; /* R11, R10, R9, R8, R7, R6, R5 and R4. */ + + return pxTopOfStack; +} +/*-----------------------------------------------------------*/ + +static void prvTaskExitError( void ) +{ + /* A function that implements a task must not exit or attempt to return to + its caller as there is nothing to return to. If a task wants to exit it + should instead call vTaskDelete( NULL ). + + Artificially force an assert() to be triggered if configASSERT() is + defined, then stop here so application writers can catch the error. */ + configASSERT( uxCriticalNesting == ~0UL ); + portDISABLE_INTERRUPTS(); + for ( ;; ); +} + + +/*-----------------------------------------------------------*/ + +/* + * See header file for description. + */ +BaseType_t xPortStartScheduler( void ) +{ + /* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. + See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ + configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY ); + + /* This port is designed for nRF52, this is Cortex-M4 r0p1. */ + configASSERT( SCB->CPUID == portCORTEX_M4_r0p1_ID ); + + #if ( configASSERT_DEFINED == 1 ) + { + volatile uint32_t ulOriginalPriority; + volatile uint8_t * const pucFirstUserPriorityRegister = &NVIC->IP[0]; + volatile uint8_t ucMaxPriorityValue; + + /* Determine the maximum priority from which ISR safe FreeRTOS API + functions can be called. ISR safe functions are those that end in + "FromISR". FreeRTOS maintains separate thread and ISR API functions to + ensure interrupt entry is as fast and simple as possible. + + Save the interrupt priority value that is about to be clobbered. */ + ulOriginalPriority = *pucFirstUserPriorityRegister; + + /* Determine the number of priority bits available. First write to all + possible bits. */ + *pucFirstUserPriorityRegister = portMAX_8_BIT_VALUE; + + /* Read the value back to see how many bits stuck. */ + ucMaxPriorityValue = *pucFirstUserPriorityRegister; + + /* Use the same mask on the maximum system call priority. */ + ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue; + + /* Calculate the maximum acceptable priority group value for the number + of bits read back. */ + ulMaxPRIGROUPValue = SCB_AIRCR_PRIGROUP_Msk >> SCB_AIRCR_PRIGROUP_Pos; + while ( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) + { + ulMaxPRIGROUPValue--; + ucMaxPriorityValue <<= ( uint8_t ) 0x01; + } + + /* Remove any bits that are more than actually existing. */ + ulMaxPRIGROUPValue &= SCB_AIRCR_PRIGROUP_Msk >> SCB_AIRCR_PRIGROUP_Pos; + + /* Restore the clobbered interrupt priority register to its original + value. */ + *pucFirstUserPriorityRegister = ulOriginalPriority; + } + #endif /* conifgASSERT_DEFINED */ + + /* Make PendSV the lowest priority interrupts. */ + NVIC_SetPriority(PendSV_IRQn, configKERNEL_INTERRUPT_PRIORITY); + + /* Start the timer that generates the tick ISR. Interrupts are disabled + here already. */ + vPortSetupTimerInterrupt(); + + /* Initialise the critical nesting count ready for the first task. */ + uxCriticalNesting = 0; + + /* Ensure the VFP is enabled - it should be anyway. */ + vPortEnableVFP(); + + /* Lazy save always. */ + FPU->FPCCR |= FPU_FPCCR_ASPEN_Msk | FPU_FPCCR_LSPEN_Msk; + + /* Finally this port requires SEVONPEND to be active */ + SCB->SCR |= SCB_SCR_SEVONPEND_Msk; + + /* Start the first task. */ + vPortStartFirstTask(); + + /* Should never get here as the tasks will now be executing! Call the task + exit error function to prevent compiler warnings about a static function + not being called in the case that the application writer overrides this + functionality by defining configTASK_RETURN_ADDRESS. */ + prvTaskExitError(); + + /* Should not get here! */ + return 0; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) +{ + /* Not implemented in ports where there is nothing to return to. + Artificially force an assert. */ + configASSERT( uxCriticalNesting == 1000UL ); +} +/*-----------------------------------------------------------*/ + +void vPortEnterCritical( void ) +{ + portDISABLE_INTERRUPTS(); + uxCriticalNesting++; + + /* This is not the interrupt safe version of the enter critical function so + assert() if it is being called from an interrupt context. Only API + functions that end in "FromISR" can be used in an interrupt. Only assert if + the critical nesting count is 1 to protect against recursive calls if the + assert function also uses a critical section. */ + if ( uxCriticalNesting == 1 ) + { + configASSERT( ( SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk ) == 0 ); + } +} +/*-----------------------------------------------------------*/ + +void vPortExitCritical( void ) +{ + configASSERT( uxCriticalNesting ); + uxCriticalNesting--; + if ( uxCriticalNesting == 0 ) + { + portENABLE_INTERRUPTS(); + } +} + +/*-----------------------------------------------------------*/ + +/* This is a naked function. */ +static void vPortEnableVFP( void ) +{ + SCB->CPACR |= 0xf << 20; +} +/*-----------------------------------------------------------*/ + +#if ( configASSERT_DEFINED == 1 ) + + void vPortValidateInterruptPriority( void ) + { + uint32_t ulCurrentInterrupt; + uint8_t ucCurrentPriority; + IPSR_Type ipsr; + + /* Obtain the number of the currently executing interrupt. */ + ipsr.w = __get_IPSR(); + ulCurrentInterrupt = ipsr.b.ISR; + + /* Is the interrupt number a user defined interrupt? */ + if ( ulCurrentInterrupt >= portFIRST_USER_INTERRUPT_NUMBER ) + { + /* Look up the interrupt's priority. */ + ucCurrentPriority = NVIC->IP[ ulCurrentInterrupt - portFIRST_USER_INTERRUPT_NUMBER ]; + + /* The following assertion will fail if a service routine (ISR) for + an interrupt that has been assigned a priority above + configMAX_SYSCALL_INTERRUPT_PRIORITY calls an ISR safe FreeRTOS API + function. ISR safe FreeRTOS API functions must *only* be called + from interrupts that have been assigned a priority at or below + configMAX_SYSCALL_INTERRUPT_PRIORITY. + + Numerically low interrupt priority numbers represent logically high + interrupt priorities, therefore the priority of the interrupt must + be set to a value equal to or numerically *higher* than + configMAX_SYSCALL_INTERRUPT_PRIORITY. + + Interrupts that use the FreeRTOS API must not be left at their + default priority of zero as that is the highest possible priority, + which is guaranteed to be above configMAX_SYSCALL_INTERRUPT_PRIORITY, + and therefore also guaranteed to be invalid. + + FreeRTOS maintains separate thread and ISR API functions to ensure + interrupt entry is as fast and simple as possible. + + The following links provide detailed information: + http://www.freertos.org/RTOS-Cortex-M3-M4.html + http://www.freertos.org/FAQHelp.html */ + configASSERT( ucCurrentPriority >= ucMaxSysCallPriority ); + } + + /* Priority grouping: The interrupt controller (NVIC) allows the bits + that define each interrupt's priority to be split between bits that + define the interrupt's pre-emption priority bits and bits that define + the interrupt's sub-priority. For simplicity all bits must be defined + to be pre-emption priority bits. The following assertion will fail if + this is not the case (if some bits represent a sub-priority). + + If the application only uses CMSIS libraries for interrupt + configuration then the correct setting can be achieved on all Cortex-M + devices by calling NVIC_SetPriorityGrouping( 0 ); before starting the + scheduler. Note however that some vendor specific peripheral libraries + assume a non-zero priority group setting, in which cases using a value + of zero will result in unpredicable behaviour. */ + configASSERT( NVIC_GetPriorityGrouping() <= ulMaxPRIGROUPValue ); + } + +#endif /* configASSERT_DEFINED */ diff --git a/FreeRTOS/Source/portable/GCC/nrf52840-dk/port_cmsis_systick.c b/FreeRTOS/Source/portable/GCC/nrf52840-dk/port_cmsis_systick.c new file mode 100755 index 0000000..aa3ba8c --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/nrf52840-dk/port_cmsis_systick.c @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" +#include "app_util.h" + +#ifdef SOFTDEVICE_PRESENT +#include "nrf_soc.h" +#include "nrf_sdh.h" +#include "app_error.h" +#include "app_util_platform.h" +#endif + +/*----------------------------------------------------------- + * Implementation of functions defined in portable.h for the ARM CM4F port. + * CMSIS compatible layer to menage SysTick ticking source. + *----------------------------------------------------------*/ + +#if configTICK_SOURCE == FREERTOS_USE_SYSTICK + + +#ifndef configSYSTICK_CLOCK_HZ + #define configSYSTICK_CLOCK_HZ configCPU_CLOCK_HZ + /* Ensure the SysTick is clocked at the same frequency as the core. */ + #define portNVIC_SYSTICK_CLK_BIT ( SysTick_CTRL_CLKSOURCE_Msk ) +#else + /* The way the SysTick is clocked is not modified in case it is not the same + as the core. */ + #define portNVIC_SYSTICK_CLK_BIT ( 0 ) +#endif + + +#if configUSE_TICKLESS_IDLE == 1 + #error SysTick port for RF52 does not support tickless idle. Use RTC mode instead. +#endif /* configUSE_TICKLESS_IDLE */ + +/*-----------------------------------------------------------*/ + +void xPortSysTickHandler( void ) +{ + /* The SysTick runs at the lowest interrupt priority, so when this interrupt + executes all interrupts must be unmasked. There is therefore no need to + save and then restore the interrupt mask value as its value is already + known. */ + ( void ) portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* Increment the RTOS tick. */ + if ( xTaskIncrementTick() != pdFALSE ) + { + /* A context switch is required. Context switching is performed in + the PendSV interrupt. Pend the PendSV interrupt. */ + SCB->ICSR = SCB_ICSR_PENDSVSET_Msk; + __SEV(); + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 ); +} + +/*-----------------------------------------------------------*/ + +/* + * Setup the systick timer to generate the tick interrupts at the required + * frequency. + */ +void vPortSetupTimerInterrupt( void ) +{ + /* Set interrupt priority */ + NVIC_SetPriority(SysTick_IRQn, configKERNEL_INTERRUPT_PRIORITY); + /* Configure SysTick to interrupt at the requested rate. */ + SysTick->LOAD = ROUNDED_DIV(configSYSTICK_CLOCK_HZ, configTICK_RATE_HZ) - 1UL; + SysTick->CTRL = ( portNVIC_SYSTICK_CLK_BIT | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk ); +} + +/*-----------------------------------------------------------*/ + +#elif configTICK_SOURCE == FREERTOS_USE_RTC + +#if configUSE_16_BIT_TICKS == 1 +#error This port does not support 16 bit ticks. +#endif + +#include "nrf_rtc.h" +#include "nrf_drv_clock.h" + +/*-----------------------------------------------------------*/ + +void xPortSysTickHandler( void ) +{ +#if configUSE_TICKLESS_IDLE == 1 + nrf_rtc_event_clear(portNRF_RTC_REG, NRF_RTC_EVENT_COMPARE_0); +#endif + + BaseType_t switch_req = pdFALSE; + uint32_t isrstate = portSET_INTERRUPT_MASK_FROM_ISR(); + + uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG); + nrf_rtc_event_clear(portNRF_RTC_REG, NRF_RTC_EVENT_TICK); + + if (configUSE_DISABLE_TICK_AUTO_CORRECTION_DEBUG == 0) + { + /* check FreeRTOSConfig.h file for more details on configUSE_DISABLE_TICK_AUTO_CORRECTION_DEBUG */ + TickType_t diff; + diff = (systick_counter - xTaskGetTickCount()) & portNRF_RTC_MAXTICKS; + + /* At most 1 step if scheduler is suspended - the xTaskIncrementTick + * would return the tick state from the moment when suspend function was called. */ + if ((diff > 1) && (xTaskGetSchedulerState() != taskSCHEDULER_RUNNING)) + { + diff = 1; + } + while ((diff--) > 0) + { + switch_req |= xTaskIncrementTick(); + } + } + else + { + switch_req = xTaskIncrementTick(); + } + + /* Increment the RTOS tick as usual which checks if there is a need for rescheduling */ + if ( switch_req != pdFALSE ) + { + /* A context switch is required. Context switching is performed in + the PendSV interrupt. Pend the PendSV interrupt. */ + SCB->ICSR = SCB_ICSR_PENDSVSET_Msk; + __SEV(); + } + + portCLEAR_INTERRUPT_MASK_FROM_ISR( isrstate ); +} + +/* + * Setup the RTC time to generate the tick interrupts at the required + * frequency. + */ +void vPortSetupTimerInterrupt( void ) +{ + /* Request LF clock */ + nrf_drv_clock_lfclk_request(NULL); + + /* Configure SysTick to interrupt at the requested rate. */ + nrf_rtc_prescaler_set(portNRF_RTC_REG, portNRF_RTC_PRESCALER); + nrf_rtc_int_enable (portNRF_RTC_REG, RTC_INTENSET_TICK_Msk); + nrf_rtc_task_trigger (portNRF_RTC_REG, NRF_RTC_TASK_CLEAR); + nrf_rtc_task_trigger (portNRF_RTC_REG, NRF_RTC_TASK_START); + nrf_rtc_event_enable(portNRF_RTC_REG, RTC_EVTEN_OVRFLW_Msk); + + NVIC_SetPriority(portNRF_RTC_IRQn, configKERNEL_INTERRUPT_PRIORITY); + NVIC_EnableIRQ(portNRF_RTC_IRQn); +} + +#if configUSE_TICKLESS_IDLE == 1 + +void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ) +{ + /* + * Implementation note: + * + * To help debugging the option configUSE_TICKLESS_IDLE_SIMPLE_DEBUG was presented. + * This option would make sure that even if program execution was stopped inside + * this function no more than expected number of ticks would be skipped. + * + * Normally RTC works all the time even if firmware execution was stopped + * and that may lead to skipping too much of ticks. + */ + TickType_t enterTime; + + /* Make sure the SysTick reload value does not overflow the counter. */ + if ( xExpectedIdleTime > portNRF_RTC_MAXTICKS - configEXPECTED_IDLE_TIME_BEFORE_SLEEP ) + { + xExpectedIdleTime = portNRF_RTC_MAXTICKS - configEXPECTED_IDLE_TIME_BEFORE_SLEEP; + } + /* Block all the interrupts globally */ +#ifdef SOFTDEVICE_PRESENT + do{ + uint8_t dummy = 0; + uint32_t err_code = sd_nvic_critical_region_enter(&dummy); + APP_ERROR_CHECK(err_code); + }while (0); +#else + __disable_irq(); +#endif + + enterTime = nrf_rtc_counter_get(portNRF_RTC_REG); + + if ( eTaskConfirmSleepModeStatus() != eAbortSleep ) + { + TickType_t xModifiableIdleTime; + TickType_t wakeupTime = (enterTime + xExpectedIdleTime) & portNRF_RTC_MAXTICKS; + + /* Stop tick events */ + nrf_rtc_int_disable(portNRF_RTC_REG, NRF_RTC_INT_TICK_MASK); + + /* Configure CTC interrupt */ + nrf_rtc_cc_set(portNRF_RTC_REG, 0, wakeupTime); + nrf_rtc_event_clear(portNRF_RTC_REG, NRF_RTC_EVENT_COMPARE_0); + nrf_rtc_int_enable(portNRF_RTC_REG, NRF_RTC_INT_COMPARE0_MASK); + + __DSB(); + + /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can + * set its parameter to 0 to indicate that its implementation contains + * its own wait for interrupt or wait for event instruction, and so wfi + * should not be executed again. However, the original expected idle + * time variable must remain unmodified, so a copy is taken. */ + xModifiableIdleTime = xExpectedIdleTime; + configPRE_SLEEP_PROCESSING( xModifiableIdleTime ); + if ( xModifiableIdleTime > 0 ) + { +#if 0 // With FreeRTOS sd_app_evt_wait increases power consumption with FreeRTOS compared to _WFE (NRFFOSDK-11174) +#ifdef SOFTDEVICE_PRESENT + if (nrf_sdh_is_enabled()) + { + uint32_t err_code = sd_app_evt_wait(); + APP_ERROR_CHECK(err_code); + } + else +#endif +#endif // (NRFFOSDK-11174) + { + /* No SD - we would just block interrupts globally. + * BASEPRI cannot be used for that because it would prevent WFE from wake up. + */ + do{ + __WFE(); + } while (0 == (NVIC->ISPR[0] | NVIC->ISPR[1])); + } + } + configPOST_SLEEP_PROCESSING( xExpectedIdleTime ); + + nrf_rtc_int_disable(portNRF_RTC_REG, NRF_RTC_INT_COMPARE0_MASK); + nrf_rtc_event_clear(portNRF_RTC_REG, NRF_RTC_EVENT_COMPARE_0); + + /* Correct the system ticks */ + { + TickType_t diff; + TickType_t exitTime; + + nrf_rtc_event_clear(portNRF_RTC_REG, NRF_RTC_EVENT_TICK); + nrf_rtc_int_enable (portNRF_RTC_REG, NRF_RTC_INT_TICK_MASK); + + exitTime = nrf_rtc_counter_get(portNRF_RTC_REG); + diff = (exitTime - enterTime) & portNRF_RTC_MAXTICKS; + + /* It is important that we clear pending here so that our corrections are latest and in sync with tick_interrupt handler */ + NVIC_ClearPendingIRQ(portNRF_RTC_IRQn); + + if ((configUSE_TICKLESS_IDLE_SIMPLE_DEBUG) && (diff > xExpectedIdleTime)) + { + diff = xExpectedIdleTime; + } + + if (diff > 0) + { + vTaskStepTick(diff); + } + } + } +#ifdef SOFTDEVICE_PRESENT + uint32_t err_code = sd_nvic_critical_region_exit(0); + APP_ERROR_CHECK(err_code); +#else + __enable_irq(); +#endif +} + +#endif // configUSE_TICKLESS_IDLE + +#else // configTICK_SOURCE + #error Unsupported configTICK_SOURCE value +#endif // configTICK_SOURCE == FREERTOS_USE_SYSTICK diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_UDP_IP.h b/FreeRTOS/Source/portable/GCC/nrf52840-dk/portmacro.h similarity index 74% rename from FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_UDP_IP.h rename to FreeRTOS/Source/portable/GCC/nrf52840-dk/portmacro.h index 6d60226..3458498 100755 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_UDP_IP.h +++ b/FreeRTOS/Source/portable/GCC/nrf52840-dk/portmacro.h @@ -1,5 +1,5 @@ /* - * FreeRTOS+TCP V2.0.7 + * FreeRTOS Kernel V10.0.0 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -10,7 +10,8 @@ * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS @@ -19,38 +20,17 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://aws.amazon.com/freertos * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! */ -#ifndef FREERTOS_UDP_IP_H -#define FREERTOS_UDP_IP_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Application level configuration options. */ -#include "FreeRTOSIPConfig.h" -#include "FreeRTOSIPConfigDefaults.h" -#include "IPTraceMacroDefaults.h" - - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif /* FREERTOS_UDP_IP_H */ - - - - - - - - - +#ifndef PORTMACRO_H +#define PORTMACRO_H +#include "portmacro_cmsis.h" +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/GCC/nrf52840-dk/portmacro_cmsis.h b/FreeRTOS/Source/portable/GCC/nrf52840-dk/portmacro_cmsis.h new file mode 100755 index 0000000..3d2dee5 --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/nrf52840-dk/portmacro_cmsis.h @@ -0,0 +1,187 @@ +/* + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_CMSIS_H +#define PORTMACRO_CMSIS_H +#include "app_util.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*----------------------------------------------------------- + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the + * given hardware and compiler. + * + * These settings should not be altered. + *----------------------------------------------------------- + */ + +/* Type definitions. */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if ( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/* Architecture specifics. */ +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 + +/* RTC register */ +#define portNRF_RTC_REG NRF_RTC1 +/* IRQn used by the selected RTC */ +#define portNRF_RTC_IRQn RTC1_IRQn +/* Constants required to manipulate the NVIC. */ +#define portNRF_RTC_PRESCALER ( (uint32_t) (ROUNDED_DIV(configSYSTICK_CLOCK_HZ, configTICK_RATE_HZ) - 1) ) +/* Maximum RTC ticks */ +#define portNRF_RTC_MAXTICKS ((1U<<24)-1U) +/*-----------------------------------------------------------*/ + +/* Scheduler utilities. */ +#define portYIELD() do \ +{ \ + /* Set a PendSV to request a context switch. */ \ + SCB->ICSR = SCB_ICSR_PENDSVSET_Msk; \ + __SEV(); \ + /* Barriers are normally not required but do ensure the code is completely \ + within the specified behaviour for the architecture. */ \ + __DSB(); \ + __ISB(); \ +}while (0) + +#define portEND_SWITCHING_ISR( xSwitchRequired ) if ( (xSwitchRequired) != pdFALSE ) portYIELD() +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/* Critical section management. */ +extern void vPortEnterCritical( void ); +extern void vPortExitCritical( void ); +#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortRaiseBASEPRI() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortSetBASEPRI(x) +#define portDISABLE_INTERRUPTS() vPortRaiseBASEPRI() +#define portENABLE_INTERRUPTS() vPortSetBASEPRI(0) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() + +/*-----------------------------------------------------------*/ + +/* Task function macros as described on the FreeRTOS.org WEB site. These are +not necessary for to use this port. They are defined so the common demo files +(which build with all the ports) will build. */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +/* Tickless idle/low power functionality. */ +#ifndef portSUPPRESS_TICKS_AND_SLEEP + extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ); + #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime ) +#endif +/*-----------------------------------------------------------*/ + +/* Architecture specific optimisations. */ +#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION + #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +#endif + +#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 + + /* Count leading zeros helper. */ + #define ucPortCountLeadingZeros( bits ) __CLZ( bits ) + + /* Check the configuration. */ + #if ( configMAX_PRIORITIES > 32 ) + #error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice. + #endif + + /* Store/clear the ready priorities in a bit map. */ + #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) ) + #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) ) + + /*-----------------------------------------------------------*/ + + #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - ucPortCountLeadingZeros( ( uxReadyPriorities ) ) ) + +#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ + +/*-----------------------------------------------------------*/ + +#ifdef configASSERT + void vPortValidateInterruptPriority( void ); + #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority() +#endif + +/*-----------------------------------------------------------*/ + +#define vPortSetBASEPRI( ulNewMaskValue ) __set_BASEPRI(ulNewMaskValue) + +/*-----------------------------------------------------------*/ + +#define vPortRaiseBASEPRI( ) vPortSetBASEPRI(configMAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) + +/*-----------------------------------------------------------*/ + +__STATIC_INLINE uint32_t ulPortRaiseBASEPRI( void ) +{ + uint32_t ulOriginalBASEPRI = __get_BASEPRI(); + vPortRaiseBASEPRI(); + return ulOriginalBASEPRI; +} + +/*-----------------------------------------------------------*/ + + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_CMSIS_H */ + diff --git a/FreeRTOS/Source/portable/GCC/stubs/port.c b/FreeRTOS/Source/portable/GCC/stubs/port.c new file mode 100755 index 0000000..58c048a --- /dev/null +++ b/FreeRTOS/Source/portable/GCC/stubs/port.c @@ -0,0 +1,59 @@ +/* + * FreeRTOS Kernel V10.2.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* + * See header file for description. + */ +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) +{ + ( void ) pxTopOfStack; + ( void ) pxCode; + ( void ) pvParameters; + + return ( StackType_t * ) NULL; +} +/*-----------------------------------------------------------*/ + +/* + * See header file for description. + */ +BaseType_t xPortStartScheduler( void ) +{ + return pdFAIL; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) +{ + /* Do not implement. */ +} +/*-----------------------------------------------------------*/ + diff --git a/FreeRTOS/Source/portable/GCC/RISC-V-RV32/portmacro.h b/FreeRTOS/Source/portable/GCC/stubs/portmacro.h similarity index 62% rename from FreeRTOS/Source/portable/GCC/RISC-V-RV32/portmacro.h rename to FreeRTOS/Source/portable/GCC/stubs/portmacro.h index 9b1e890..15274c8 100755 --- a/FreeRTOS/Source/portable/GCC/RISC-V-RV32/portmacro.h +++ b/FreeRTOS/Source/portable/GCC/stubs/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -33,60 +33,44 @@ extern "C" { #endif -/*----------------------------------------------------------- - * Port specific definitions. - * - * The settings in this file configure FreeRTOS correctly for the - * given hardware and compiler. - * - * These settings should not be altered. - *----------------------------------------------------------- - */ - -#ifdef __riscv64 - #error This is the RV32 port that supports 32-bit cores only. -#endif - /* Type definitions. */ #define portSTACK_TYPE uint32_t -#define portBASE_TYPE long - typedef portSTACK_TYPE StackType_t; typedef long BaseType_t; typedef unsigned long UBaseType_t; -typedef uint32_t TickType_t; -#define portMAX_DELAY ( TickType_t ) 0xffffffffUL -/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do -not need to be guarded with a critical section. */ -#define portTICK_TYPE_IS_ATOMIC 1 +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif /*-----------------------------------------------------------*/ /* Architecture specifics. */ #define portSTACK_GROWTH ( -1 ) #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) -#define portBYTE_ALIGNMENT 16 +#define portBYTE_ALIGNMENT Fix Me /*-----------------------------------------------------------*/ - /* Scheduler utilities. */ -#define portYIELD() { volatile uint32_t * const ulSoftInterrupt = ( uint32_t * ) configCTRL_BASE; *ulSoftInterrupt = 1UL; } -#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) vPortYield() +#define portYIELD() Fix Me +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) portYIELD() #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) /*-----------------------------------------------------------*/ - /* Critical section management. */ -#define portCRITICAL_NESTING_IN_TCB 1 -extern int vPortSetInterruptMask( void ); -extern void vPortClearInterruptMask( int ); - -#define portSET_INTERRUPT_MASK_FROM_ISR() 0 -#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) -#define portDISABLE_INTERRUPTS() -#define portENABLE_INTERRUPTS() -#define portENTER_CRITICAL() -#define portEXIT_CRITICAL() +#define portSET_INTERRUPT_MASK_FROM_ISR() Fix Me +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) Fix Me +#define portDISABLE_INTERRUPTS() Fix Me +#define portENABLE_INTERRUPTS() Fix Me +#define portENTER_CRITICAL() Fix Me +#define portEXIT_CRITICAL() Fix me /*-----------------------------------------------------------*/ @@ -95,17 +79,8 @@ not necessary for to use this port. They are defined so the common demo files (which build with all the ports) will build. */ #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) - /*-----------------------------------------------------------*/ -#define portNOP() __asm volatile ( " nop " ) - -#define portINLINE __inline - -#ifndef portFORCE_INLINE - #define portFORCE_INLINE inline __attribute__(( always_inline)) -#endif -portFORCE_INLINE static BaseType_t xPortIsInsideInterrupt( void ) {} #ifdef __cplusplus } diff --git a/FreeRTOS/Source/portable/IAR/78K0R/ISR_Support.h b/FreeRTOS/Source/portable/IAR/78K0R/ISR_Support.h index 2eaf588..791b50e 100755 --- a/FreeRTOS/Source/portable/IAR/78K0R/ISR_Support.h +++ b/FreeRTOS/Source/portable/IAR/78K0R/ISR_Support.h @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/78K0R/port.c b/FreeRTOS/Source/portable/IAR/78K0R/port.c index 463f3b2..30e9631 100755 --- a/FreeRTOS/Source/portable/IAR/78K0R/port.c +++ b/FreeRTOS/Source/portable/IAR/78K0R/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/78K0R/portasm.s26 b/FreeRTOS/Source/portable/IAR/78K0R/portasm.s26 index 4ebbdf1..802a71e 100755 --- a/FreeRTOS/Source/portable/IAR/78K0R/portasm.s26 +++ b/FreeRTOS/Source/portable/IAR/78K0R/portasm.s26 @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/78K0R/portmacro.h b/FreeRTOS/Source/portable/IAR/78K0R/portmacro.h index c5762d0..956d50f 100755 --- a/FreeRTOS/Source/portable/IAR/78K0R/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/78K0R/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/port.c b/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/port.c index 7f97f24..ccb32d3 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/port.c +++ b/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/portASM.h b/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/portASM.h index 6898ae5..e1e55c7 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/portASM.h +++ b/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/portASM.h @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/portASM.s b/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/portASM.s index 9ec0f1a..f213966 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/portASM.s +++ b/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/portASM.s @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/portmacro.h b/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/portmacro.h index b854278..f20e19e 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/ARM_CA5_No_GIC/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CA9/port.c b/FreeRTOS/Source/portable/IAR/ARM_CA9/port.c index 01d4ba8..83c7587 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CA9/port.c +++ b/FreeRTOS/Source/portable/IAR/ARM_CA9/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.h b/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.h index 25e2610..eda42ba 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.h +++ b/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.h @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.s b/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.s index 8b1a190..42f23d8 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.s +++ b/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.s @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CA9/portmacro.h b/FreeRTOS/Source/portable/IAR/ARM_CA9/portmacro.h index 35f7421..dfa8ff2 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CA9/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/ARM_CA9/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM0/port.c b/FreeRTOS/Source/portable/IAR/ARM_CM0/port.c index 680048b..565c687 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM0/port.c +++ b/FreeRTOS/Source/portable/IAR/ARM_CM0/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM0/portasm.s b/FreeRTOS/Source/portable/IAR/ARM_CM0/portasm.s index a6824a7..a2e3ce8 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM0/portasm.s +++ b/FreeRTOS/Source/portable/IAR/ARM_CM0/portasm.s @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM0/portmacro.h b/FreeRTOS/Source/portable/IAR/ARM_CM0/portmacro.h index e3aafb5..44fe318 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM0/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/ARM_CM0/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23/non_secure/port.c b/FreeRTOS/Source/portable/IAR/ARM_CM23/non_secure/port.c new file mode 100755 index 0000000..bd85a6f --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23/non_secure/port.c @@ -0,0 +1,899 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/* Portasm includes. */ +#include "portasm.h" + +#if( configENABLE_TRUSTZONE == 1 ) + /* Secure components includes. */ + #include "secure_context.h" + #include "secure_init.h" +#endif /* configENABLE_TRUSTZONE */ + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/** + * The FreeRTOS Cortex M33 port can be configured to run on the Secure Side only + * i.e. the processor boots as secure and never jumps to the non-secure side. + * The Trust Zone support in the port must be disabled in order to run FreeRTOS + * on the secure side. The following are the valid configuration seetings: + * + * 1. Run FreeRTOS on the Secure Side: + * configRUN_FREERTOS_SECURE_ONLY = 1 and configENABLE_TRUSTZONE = 0 + * + * 2. Run FreeRTOS on the Non-Secure Side with Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 1 + * + * 3. Run FreeRTOS on the Non-Secure Side only i.e. no Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 0 + */ +#if( ( configRUN_FREERTOS_SECURE_ONLY == 1 ) && ( configENABLE_TRUSTZONE == 1 ) ) + #error TrustZone needs to be disabled in order to run FreeRTOS on the Secure Side. +#endif +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the NVIC. + */ +#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t * ) 0xe000e010 ) +#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t * ) 0xe000e014 ) +#define portNVIC_SYSTICK_CURRENT_VALUE ( ( volatile uint32_t * ) 0xe000e018 ) +#define portNVIC_INT_CTRL ( ( volatile uint32_t * ) 0xe000ed04 ) +#define portNVIC_SYSPRI2 ( ( volatile uint32_t * ) 0xe000ed20 ) +#define portNVIC_SYSTICK_CLK ( 0x00000004 ) +#define portNVIC_SYSTICK_INT ( 0x00000002 ) +#define portNVIC_SYSTICK_ENABLE ( 0x00000001 ) +#define portNVIC_PENDSVSET ( 0x10000000 ) +#define portMIN_INTERRUPT_PRIORITY ( 255UL ) +#define portNVIC_PENDSV_PRI ( portMIN_INTERRUPT_PRIORITY << 16UL ) +#define portNVIC_SYSTICK_PRI ( portMIN_INTERRUPT_PRIORITY << 24UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the SCB. + */ +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( * ( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_MEM_FAULT_ENABLE ( 1UL << 16UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the FPU. + */ +#define portCPACR ( ( volatile uint32_t * ) 0xe000ed88 ) /* Coprocessor Access Control Register. */ +#define portCPACR_CP10_VALUE ( 3UL ) +#define portCPACR_CP11_VALUE portCPACR_CP10_VALUE +#define portCPACR_CP10_POS ( 20UL ) +#define portCPACR_CP11_POS ( 22UL ) + +#define portFPCCR ( ( volatile uint32_t * ) 0xe000ef34 ) /* Floating Point Context Control Register. */ +#define portFPCCR_ASPEN_POS ( 31UL ) +#define portFPCCR_ASPEN_MASK ( 1UL << portFPCCR_ASPEN_POS ) +#define portFPCCR_LSPEN_POS ( 30UL ) +#define portFPCCR_LSPEN_MASK ( 1UL << portFPCCR_LSPEN_POS ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the MPU. + */ +#define portMPU_TYPE_REG ( * ( ( volatile uint32_t * ) 0xe000ed90 ) ) +#define portMPU_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed94 ) ) +#define portMPU_RNR_REG ( * ( ( volatile uint32_t * ) 0xe000ed98 ) ) + +#define portMPU_RBAR_REG ( * ( ( volatile uint32_t * ) 0xe000ed9c ) ) +#define portMPU_RLAR_REG ( * ( ( volatile uint32_t * ) 0xe000eda0 ) ) + +#define portMPU_RBAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda4 ) ) +#define portMPU_RLAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda8 ) ) + +#define portMPU_RBAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edac ) ) +#define portMPU_RLAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edb0 ) ) + +#define portMPU_RBAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb4 ) ) +#define portMPU_RLAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb8 ) ) + +#define portMPU_MAIR0_REG ( * ( ( volatile uint32_t * ) 0xe000edc0 ) ) +#define portMPU_MAIR1_REG ( * ( ( volatile uint32_t * ) 0xe000edc4 ) ) + +#define portMPU_RBAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ +#define portMPU_RLAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ + +#define portMPU_MAIR_ATTR0_POS ( 0UL ) +#define portMPU_MAIR_ATTR0_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR1_POS ( 8UL ) +#define portMPU_MAIR_ATTR1_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR2_POS ( 16UL ) +#define portMPU_MAIR_ATTR2_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR3_POS ( 24UL ) +#define portMPU_MAIR_ATTR3_MASK ( 0xff000000 ) + +#define portMPU_MAIR_ATTR4_POS ( 0UL ) +#define portMPU_MAIR_ATTR4_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR5_POS ( 8UL ) +#define portMPU_MAIR_ATTR5_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR6_POS ( 16UL ) +#define portMPU_MAIR_ATTR6_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR7_POS ( 24UL ) +#define portMPU_MAIR_ATTR7_MASK ( 0xff000000 ) + +#define portMPU_RLAR_ATTR_INDEX0 ( 0UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX1 ( 1UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX2 ( 2UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX3 ( 3UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX4 ( 4UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX5 ( 5UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX6 ( 6UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX7 ( 7UL << 1UL ) + +#define portMPU_RLAR_REGION_ENABLE ( 1UL ) + +/* Enable privileged access to unmapped region. */ +#define portMPU_PRIV_BACKGROUND_ENABLE ( 1UL << 2UL ) + +/* Enable MPU. */ +#define portMPU_ENABLE ( 1UL << 0UL ) + +/* Expected value of the portMPU_TYPE register. */ +#define portEXPECTED_MPU_TYPE_VALUE ( 8UL << 8UL ) /* 8 regions, unified. */ +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to set up the initial stack. + */ +#define portINITIAL_XPSR ( 0x01000000 ) + +#if( configRUN_FREERTOS_SECURE_ONLY == 1 ) + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF FD + * 1111 1111 1111 1111 1111 1111 1111 1101 + * + * Bit[6] - 1 --> The exception was taken from the Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 1 --> The exception was taken to the Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xfffffffd ) +#else + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF BC + * 1111 1111 1111 1111 1111 1111 1011 1100 + * + * Bit[6] - 0 --> The exception was taken from the Non-Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 0 --> The exception was taken to the Non-Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xffffffbc ) +#endif /* configRUN_FREERTOS_SECURE_ONLY */ + +/** + * @brief CONTROL register privileged bit mask. + * + * Bit[0] in CONTROL register tells the privilege: + * Bit[0] = 0 ==> The task is privileged. + * Bit[0] = 1 ==> The task is not privileged. + */ +#define portCONTROL_PRIVILEGED_MASK ( 1UL << 0UL ) + +/** + * @brief Initial CONTROL register values. + */ +#define portINITIAL_CONTROL_UNPRIVILEGED ( 0x3 ) +#define portINITIAL_CONTROL_PRIVILEGED ( 0x2 ) + +/** + * @brief Let the user override the pre-loading of the initial LR with the + * address of prvTaskExitError() in case it messes up unwinding of the stack + * in the debugger. + */ +#ifdef configTASK_RETURN_ADDRESS + #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS +#else + #define portTASK_RETURN_ADDRESS prvTaskExitError +#endif + +/** + * @brief If portPRELOAD_REGISTERS then registers will be given an initial value + * when a task is created. This helps in debugging at the cost of code size. + */ +#define portPRELOAD_REGISTERS 1 + +/** + * @brief A task is created without a secure context, and must call + * portALLOCATE_SECURE_CONTEXT() to give itself a secure context before it makes + * any secure calls. + */ +#define portNO_SECURE_CONTEXT 0 +/*-----------------------------------------------------------*/ + +/** + * @brief Setup the timer to generate the tick interrupts. + */ +static void prvSetupTimerInterrupt( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Used to catch tasks that attempt to return from their implementing + * function. + */ +static void prvTaskExitError( void ); + +#if( configENABLE_MPU == 1 ) + /** + * @brief Setup the Memory Protection Unit (MPU). + */ + static void prvSetupMPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_MPU */ + +#if( configENABLE_FPU == 1 ) + /** + * @brief Setup the Floating Point Unit (FPU). + */ + static void prvSetupFPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_FPU */ + +/** + * @brief Yield the processor. + */ +void vPortYield( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Enter critical section. + */ +void vPortEnterCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Exit from critical section. + */ +void vPortExitCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief SysTick handler. + */ +void SysTick_Handler( void ) PRIVILEGED_FUNCTION; + +/** + * @brief C part of SVC handler. + */ +portDONT_DISCARD void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) PRIVILEGED_FUNCTION; +/*-----------------------------------------------------------*/ + +/** + * @brief Each task maintains its own interrupt status in the critical nesting + * variable. + */ +static volatile uint32_t ulCriticalNesting = 0xaaaaaaaaUL; + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Saved as part of the task context to indicate which context the + * task is using on the secure side. + */ + portDONT_DISCARD volatile SecureContextHandle_t xSecureContext = portNO_SECURE_CONTEXT; +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +static void prvSetupTimerInterrupt( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Stop and reset the SysTick. */ + *( portNVIC_SYSTICK_CTRL ) = 0UL; + *( portNVIC_SYSTICK_CURRENT_VALUE ) = 0UL; + + /* Configure SysTick to interrupt at the requested rate. */ + *( portNVIC_SYSTICK_LOAD ) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; + *( portNVIC_SYSTICK_CTRL ) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE; +} +/*-----------------------------------------------------------*/ + +static void prvTaskExitError( void ) +{ +volatile uint32_t ulDummy = 0UL; + + /* A function that implements a task must not exit or attempt to return to + * its caller as there is nothing to return to. If a task wants to exit it + * should instead call vTaskDelete( NULL ). Artificially force an assert() + * to be triggered if configASSERT() is defined, then stop here so + * application writers can catch the error. */ + configASSERT( ulCriticalNesting == ~0UL ); + portDISABLE_INTERRUPTS(); + + while( ulDummy == 0 ) + { + /* This file calls prvTaskExitError() after the scheduler has been + * started to remove a compiler warning about the function being + * defined but never called. ulDummy is used purely to quieten other + * warnings about code appearing after this function is called - making + * ulDummy volatile makes the compiler think the function could return + * and therefore not output an 'unreachable code' warning for code that + * appears after it. */ + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + static void prvSetupMPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __privileged_functions_start__; + extern uint32_t * __privileged_functions_end__; + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + extern uint32_t * __unprivileged_flash_start__; + extern uint32_t * __unprivileged_flash_end__; + extern uint32_t * __privileged_sram_start__; + extern uint32_t * __privileged_sram_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __privileged_functions_start__[]; + extern uint32_t __privileged_functions_end__[]; + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + extern uint32_t __unprivileged_flash_start__[]; + extern uint32_t __unprivileged_flash_end__[]; + extern uint32_t __privileged_sram_start__[]; + extern uint32_t __privileged_sram_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ + + /* Check that the MPU is present. */ + if( portMPU_TYPE_REG == portEXPECTED_MPU_TYPE_VALUE ) + { + /* MAIR0 - Index 0. */ + portMPU_MAIR0_REG |= ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + /* MAIR0 - Index 1. */ + portMPU_MAIR0_REG |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* Setup privileged flash as Read Only so that privileged tasks can + * read it but not modify. */ + portMPU_RNR_REG = portPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_functions_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_functions_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged flash as Read Only by both privileged and + * unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __unprivileged_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __unprivileged_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged syscalls flash as Read Only by both privileged + * and unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_SYSCALLS_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __syscalls_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __syscalls_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup RAM containing kernel data for privileged access only. */ + portMPU_RNR_REG = portPRIVILEGED_RAM_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_sram_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_sram_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Enable mem fault. */ + portSCB_SYS_HANDLER_CTRL_STATE_REG |= portSCB_MEM_FAULT_ENABLE; + + /* Enable MPU with privileged background access i.e. unmapped + * regions have privileged access. */ + portMPU_CTRL_REG |= ( portMPU_PRIV_BACKGROUND_ENABLE | portMPU_ENABLE ); + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_FPU == 1 ) + static void prvSetupFPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* Enable non-secure access to the FPU. */ + SecureInit_EnableNSFPUAccess(); + } + #endif /* configENABLE_TRUSTZONE */ + + /* CP10 = 11 ==> Full access to FPU i.e. both privileged and + * unprivileged code should be able to access FPU. CP11 should be + * programmed to the same value as CP10. */ + *( portCPACR ) |= ( ( portCPACR_CP10_VALUE << portCPACR_CP10_POS ) | + ( portCPACR_CP11_VALUE << portCPACR_CP11_POS ) + ); + + /* ASPEN = 1 ==> Hardware should automatically preserve floating point + * context on exception entry and restore on exception return. + * LSPEN = 1 ==> Enable lazy context save of FP state. */ + *( portFPCCR ) |= ( portFPCCR_ASPEN_MASK | portFPCCR_LSPEN_MASK ); + } +#endif /* configENABLE_FPU */ +/*-----------------------------------------------------------*/ + +void vPortYield( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Set a PendSV to request a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + portDISABLE_INTERRUPTS(); + ulCriticalNesting++; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + configASSERT( ulCriticalNesting ); + ulCriticalNesting--; + + if( ulCriticalNesting == 0 ) + { + portENABLE_INTERRUPTS(); + } +} +/*-----------------------------------------------------------*/ + +void SysTick_Handler( void ) /* PRIVILEGED_FUNCTION */ +{ +uint32_t ulPreviousMask; + + ulPreviousMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* Increment the RTOS tick. */ + if( xTaskIncrementTick() != pdFALSE ) + { + /* Pend a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulPreviousMask ); +} +/*-----------------------------------------------------------*/ + +void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) /* PRIVILEGED_FUNCTION portDONT_DISCARD */ +{ +#if( configENABLE_MPU == 1 ) + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ +#endif /* configENABLE_MPU */ + +uint32_t ulPC; + +#if( configENABLE_TRUSTZONE == 1 ) + uint32_t ulR0; + #if( configENABLE_MPU == 1 ) + uint32_t ulControl, ulIsTaskPrivileged; + #endif /* configENABLE_MPU */ +#endif /* configENABLE_TRUSTZONE */ +uint8_t ucSVCNumber; + + /* Register are stored on the stack in the following order - R0, R1, R2, R3, + * R12, LR, PC, xPSR. */ + ulPC = pulCallerStackAddress[ 6 ]; + ucSVCNumber = ( ( uint8_t *) ulPC )[ -2 ]; + + switch( ucSVCNumber ) + { + #if( configENABLE_TRUSTZONE == 1 ) + case portSVC_ALLOCATE_SECURE_CONTEXT: + { + /* R0 contains the stack size passed as parameter to the + * vPortAllocateSecureContext function. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + #if( configENABLE_MPU == 1 ) + { + /* Read the CONTROL register value. */ + __asm volatile ( "mrs %0, control" : "=r" ( ulControl ) ); + + /* The task that raised the SVC is privileged if Bit[0] + * in the CONTROL register is 0. */ + ulIsTaskPrivileged = ( ( ulControl & portCONTROL_PRIVILEGED_MASK ) == 0 ); + + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0, ulIsTaskPrivileged ); + } + #else + { + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0 ); + } + #endif /* configENABLE_MPU */ + + configASSERT( xSecureContext != NULL ); + SecureContext_LoadContext( xSecureContext ); + } + break; + + case portSVC_FREE_SECURE_CONTEXT: + { + /* R0 contains the secure context handle to be freed. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + /* Free the secure context. */ + SecureContext_FreeContext( ( SecureContextHandle_t ) ulR0 ); + } + break; + #endif /* configENABLE_TRUSTZONE */ + + case portSVC_START_SCHEDULER: + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* De-prioritize the non-secure exceptions so that the + * non-secure pendSV runs at the lowest priority. */ + SecureInit_DePrioritizeNSExceptions(); + + /* Initialize the secure context management system. */ + SecureContext_Init(); + } + #endif /* configENABLE_TRUSTZONE */ + + #if( configENABLE_FPU == 1 ) + { + /* Setup the Floating Point Unit (FPU). */ + prvSetupFPU(); + } + #endif /* configENABLE_FPU */ + + /* Setup the context of the first task so that the first task starts + * executing. */ + vRestoreContextOfFirstTask(); + } + break; + + #if( configENABLE_MPU == 1 ) + case portSVC_RAISE_PRIVILEGE: + { + /* Only raise the privilege, if the svc was raised from any of + * the system calls. */ + if( ulPC >= ( uint32_t ) __syscalls_flash_start__ && + ulPC <= ( uint32_t ) __syscalls_flash_end__ ) + { + vRaisePrivilege(); + } + } + break; + #endif /* configENABLE_MPU */ + + default: + { + /* Incorrect SVC call. */ + configASSERT( pdFALSE ); + } + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) /* PRIVILEGED_FUNCTION */ +#else + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) /* PRIVILEGED_FUNCTION */ +#endif /* configENABLE_MPU */ +{ + /* Simulate the stack frame as it would be created by a context switch + * interrupt. */ + #if( portPRELOAD_REGISTERS == 0 ) + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack -= 9; /* R11..R4, EXC_RETURN. */ + *pxTopOfStack = portINITIAL_EXC_RETURN; + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #else /* portPRELOAD_REGISTERS */ + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x12121212UL; /* R12 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x03030303UL; /* R3 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x02020202UL; /* R2 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x01010101UL; /* R1 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x11111111UL; /* R11 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x10101010UL; /* R10 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x09090909UL; /* R09 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x08080808UL; /* R08 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x07070707UL; /* R07 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x06060606UL; /* R06 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x05050505UL; /* R05 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x04040404UL; /* R04 */ + pxTopOfStack--; + *pxTopOfStack = portINITIAL_EXC_RETURN; /* EXC_RETURN */ + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #endif /* portPRELOAD_REGISTERS */ + + return pxTopOfStack; +} +/*-----------------------------------------------------------*/ + +BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + *( portNVIC_SYSPRI2 ) |= portNVIC_PENDSV_PRI; + *( portNVIC_SYSPRI2 ) |= portNVIC_SYSTICK_PRI; + + #if( configENABLE_MPU == 1 ) + { + /* Setup the Memory Protection Unit (MPU). */ + prvSetupMPU(); + } + #endif /* configENABLE_MPU */ + + /* Start the timer that generates the tick ISR. Interrupts are disabled + * here already. */ + prvSetupTimerInterrupt(); + + /* Initialize the critical nesting count ready for the first task. */ + ulCriticalNesting = 0; + + /* Start the first task. */ + vStartFirstTask(); + + /* Should never get here as the tasks will now be executing. Call the task + * exit error function to prevent compiler warnings about a static function + * not being called in the case that the application writer overrides this + * functionality by defining configTASK_RETURN_ADDRESS. Call + * vTaskSwitchContext() so link time optimization does not remove the + * symbol. */ + vTaskSwitchContext(); + prvTaskExitError(); + + /* Should not get here. */ + return 0; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Not implemented in ports where there is nothing to return to. + * Artificially force an assert. */ + configASSERT( ulCriticalNesting == 1000UL ); +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) + { + uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber; + int32_t lIndex = 0; + + /* Setup MAIR0. */ + xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + xMPUSettings->ulMAIR0 |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* This function is called automatically when the task is created - in + * which case the stack region parameters will be valid. At all other + * times the stack parameters will not be valid and it is assumed that + * the stack region has already been configured. */ + if( ulStackDepth > 0 ) + { + /* Define the region that allows access to the stack. */ + ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + + xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + } + + /* User supplied configurable regions. */ + for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ ) + { + /* If xRegions is NULL i.e. the task has not specified any MPU + * region, the else part ensures that all the configurable MPU + * regions are invalidated. */ + if( ( xRegions != NULL ) && ( xRegions[ lIndex ].ulLengthInBytes > 0UL ) ) + { + /* Translate the generic region definition contained in xRegions + * into the ARMv8 specific MPU settings that are then stored in + * xMPUSettings. */ + ulRegionStartAddress = ( ( uint32_t ) xRegions[ lIndex ].pvBaseAddress ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) xRegions[ lIndex ].pvBaseAddress + xRegions[ lIndex ].ulLengthInBytes - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + /* Start address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ); + + /* RO/RW. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_READ_ONLY ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_ONLY ); + } + else + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_WRITE ); + } + + /* XN. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_EXECUTE_NEVER ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_EXECUTE_NEVER ); + } + + /* End Address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Normal memory/ Device memory. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_DEVICE_MEMORY ) != 0 ) + { + /* Attr1 in MAIR0 is configured as device memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX1; + } + else + { + /* Attr1 in MAIR0 is configured as normal memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX0; + } + } + else + { + /* Invalidate the region. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = 0UL; + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = 0UL; + } + + lIndex++; + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23/non_secure/portasm.h b/FreeRTOS/Source/portable/IAR/ARM_CM23/non_secure/portasm.h new file mode 100755 index 0000000..2ecf04e --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23/non_secure/portasm.h @@ -0,0 +1,113 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __PORT_ASM_H__ +#define __PORT_ASM_H__ + +/* Scheduler includes. */ +#include "FreeRTOS.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/** + * @brief Restore the context of the first task so that the first task starts + * executing. + */ +void vRestoreContextOfFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +BaseType_t xIsPrivileged( void ) __attribute__ (( naked )); + +/** + * @brief Raises the privilege level by clearing the bit 0 of the CONTROL + * register. + * + * @note This is a privileged function and should only be called from the kenrel + * code. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vRaisePrivilege( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vResetPrivilege( void ) __attribute__ (( naked )); + +/** + * @brief Starts the first task. + */ +void vStartFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Disables interrupts. + */ +uint32_t ulSetInterruptMaskFromISR( void ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Enables interrupts. + */ +void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief PendSV Exception handler. + */ +void PendSV_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief SVC Handler. + */ +void SVC_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Allocate a Secure context for the calling task. + * + * @param[in] ulSecureStackSize The size of the stack to be allocated on the + * secure side for the calling task. + */ +void vPortAllocateSecureContext( uint32_t ulSecureStackSize ) __attribute__ (( naked )); + +/** + * @brief Free the task's secure context. + * + * @param[in] pulTCB Pointer to the Task Control Block (TCB) of the task. + */ +void vPortFreeSecureContext( uint32_t *pulTCB ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +#endif /* __PORT_ASM_H__ */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23/non_secure/portasm.s b/FreeRTOS/Source/portable/IAR/ARM_CM23/non_secure/portasm.s new file mode 100755 index 0000000..b1a543a --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23/non_secure/portasm.s @@ -0,0 +1,377 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + EXTERN pxCurrentTCB + EXTERN xSecureContext + EXTERN vTaskSwitchContext + EXTERN vPortSVCHandler_C + EXTERN SecureContext_SaveContext + EXTERN SecureContext_LoadContext + + PUBLIC xIsPrivileged + PUBLIC vResetPrivilege + PUBLIC vPortAllocateSecureContext + PUBLIC vRestoreContextOfFirstTask + PUBLIC vRaisePrivilege + PUBLIC vStartFirstTask + PUBLIC ulSetInterruptMaskFromISR + PUBLIC vClearInterruptMaskFromISR + PUBLIC PendSV_Handler + PUBLIC SVC_Handler + PUBLIC vPortFreeSecureContext + +#if ( configENABLE_FPU == 1 ) + #error Cortex-M23 does not have a Floating Point Unit (FPU) and therefore configENABLE_FPU must be set to 0. +#endif +/*-----------------------------------------------------------*/ + +/*---------------- Unprivileged Functions -------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION .text:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +xIsPrivileged: + mrs r0, control /* r0 = CONTROL. */ + movs r1, #1 /* r1 = 1. */ + tst r0, r1 /* Perform r0 & r1 (bitwise AND) and update the conditions flag. */ + beq running_privileged /* If the result of previous AND operation was 0, branch. */ + movs r0, #0 /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + bx lr /* Return. */ + running_privileged: + movs r0, #1 /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ + +vResetPrivilege: + mrs r0, control /* r0 = CONTROL. */ + movs r1, #1 /* r1 = 1. */ + orrs r0, r1 /* r0 = r0 | r1. */ + msr control, r0 /* CONTROL = r0. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +vPortAllocateSecureContext: + svc 0 /* Secure context is allocated in the supervisor call. portSVC_ALLOCATE_SECURE_CONTEXT = 0. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ + +/*----------------- Privileged Functions --------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION privileged_functions:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +vRestoreContextOfFirstTask: + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r3, [r2] /* Read pxCurrentTCB. */ + ldr r0, [r3] /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + +#if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + movs r5, #1 /* r5 = 1. */ + bics r4, r5 /* r4 = r4 & ~r5 i.e. Clear the bit 0 in r4. */ + str r4, [r2] /* Disable MPU. */ + + adds r3, #4 /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + ldr r4, [r3] /* r4 = *r3 i.e. r4 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r4, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + adds r3, #4 /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + movs r5, #4 /* r5 = 4. */ + str r5, [r2] /* Program RNR = 4. */ + ldmia r3!, {r6,r7} /* Read first set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write first set of RBAR/RLAR registers. */ + movs r5, #5 /* r5 = 5. */ + str r5, [r2] /* Program RNR = 5. */ + ldmia r3!, {r6,r7} /* Read second set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write second set of RBAR/RLAR registers. */ + movs r5, #6 /* r5 = 6. */ + str r5, [r2] /* Program RNR = 6. */ + ldmia r3!, {r6,r7} /* Read third set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write third set of RBAR/RLAR registers. */ + movs r5, #7 /* r5 = 7. */ + str r5, [r2] /* Program RNR = 7. */ + ldmia r3!, {r6,r7} /* Read fourth set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write fourth set of RBAR/RLAR registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + movs r5, #1 /* r5 = 1. */ + orrs r4, r5 /* r4 = r4 | r5 i.e. Set the bit 0 in r4. */ + str r4, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ +#endif /* configENABLE_MPU */ + +#if ( configENABLE_MPU == 1 ) + ldm r0!, {r1-r4} /* Read from stack - r1 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = EXC_RETURN. */ + ldr r5, =xSecureContext + str r1, [r5] /* Set xSecureContext to this task's value for the same. */ + msr psplim, r2 /* Set this task's PSPLIM value. */ + msr control, r3 /* Set this task's CONTROL value. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r4 /* Finally, branch to EXC_RETURN. */ +#else /* configENABLE_MPU */ + ldm r0!, {r1-r3} /* Read from stack - r1 = xSecureContext, r2 = PSPLIM and r3 = EXC_RETURN. */ + ldr r4, =xSecureContext + str r1, [r4] /* Set xSecureContext to this task's value for the same. */ + msr psplim, r2 /* Set this task's PSPLIM value. */ + movs r1, #2 /* r1 = 2. */ + msr CONTROL, r1 /* Switch to use PSP in the thread mode. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r3 /* Finally, branch to EXC_RETURN. */ +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +vRaisePrivilege: + mrs r0, control /* Read the CONTROL register. */ + movs r1, #1 /* r1 = 1. */ + bics r0, r1 /* Clear the bit 0. */ + msr control, r0 /* Write back the new CONTROL value. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +vStartFirstTask: + ldr r0, =0xe000ed08 /* Use the NVIC offset register to locate the stack. */ + ldr r0, [r0] /* Read the VTOR register which gives the address of vector table. */ + ldr r0, [r0] /* The first entry in vector table is stack pointer. */ + msr msp, r0 /* Set the MSP back to the start of the stack. */ + cpsie i /* Globally enable interrupts. */ + dsb + isb + svc 2 /* System call to start the first task. portSVC_START_SCHEDULER = 2. */ +/*-----------------------------------------------------------*/ + +ulSetInterruptMaskFromISR: + mrs r0, PRIMASK + cpsid i + bx lr +/*-----------------------------------------------------------*/ + +vClearInterruptMaskFromISR: + msr PRIMASK, r0 + bx lr +/*-----------------------------------------------------------*/ + +PendSV_Handler: + mrs r1, psp /* Read PSP in r1. */ + ldr r2, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + ldr r0, [r2] /* Read xSecureContext - Value of xSecureContext must be in r0 as it is used as a parameter later. */ + + cbz r0, save_ns_context /* No secure context to save. */ + push {r0-r2, r14} + bl SecureContext_SaveContext + pop {r0-r3} /* LR is now in r3. */ + mov lr, r3 /* LR = r3. */ + lsls r2, r3, #25 /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + bpl save_ns_context /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r2, [r3] /* Read pxCurrentTCB. */ +#if ( configENABLE_MPU == 1 ) + subs r1, r1, #16 /* Make space for xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mrs r3, control /* r3 = CONTROL. */ + mov r4, lr /* r4 = LR/EXC_RETURN. */ + stmia r1!, {r0, r2-r4} /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ +#else /* configENABLE_MPU */ + subs r1, r1, #12 /* Make space for xSecureContext, PSPLIM and LR on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + stmia r1!, {r0, r2-r3} /* Store xSecureContext, PSPLIM and LR on the stack. */ +#endif /* configENABLE_MPU */ + b select_next_task + + save_ns_context: + ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r2, [r3] /* Read pxCurrentTCB. */ + #if ( configENABLE_MPU == 1 ) + subs r1, r1, #48 /* Make space for xSecureContext, PSPLIM, CONTROL, LR and the remaining registers on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + adds r1, r1, #16 /* r1 = r1 + 16. */ + stmia r1!, {r4-r7} /* Store the low registers that are not saved automatically. */ + mov r4, r8 /* r4 = r8. */ + mov r5, r9 /* r5 = r9. */ + mov r6, r10 /* r6 = r10. */ + mov r7, r11 /* r7 = r11. */ + stmia r1!, {r4-r7} /* Store the high registers that are not saved automatically. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mrs r3, control /* r3 = CONTROL. */ + mov r4, lr /* r4 = LR/EXC_RETURN. */ + subs r1, r1, #48 /* r1 = r1 - 48. */ + stmia r1!, {r0, r2-r4} /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + #else /* configENABLE_MPU */ + subs r1, r1, #44 /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + stmia r1!, {r0, r2-r7} /* Store xSecureContext, PSPLIM, LR and the low registers that are not saved automatically. */ + mov r4, r8 /* r4 = r8. */ + mov r5, r9 /* r5 = r9. */ + mov r6, r10 /* r6 = r10. */ + mov r7, r11 /* r7 = r11. */ + stmia r1!, {r4-r7} /* Store the high registers that are not saved automatically. */ + #endif /* configENABLE_MPU */ + + select_next_task: + cpsid i + bl vTaskSwitchContext + cpsie i + + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r3, [r2] /* Read pxCurrentTCB. */ + ldr r1, [r3] /* The first item in pxCurrentTCB is the task top of stack. r1 now points to the top of stack. */ + + #if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + movs r5, #1 /* r5 = 1. */ + bics r4, r5 /* r4 = r4 & ~r5 i.e. Clear the bit 0 in r4. */ + str r4, [r2] /* Disable MPU. */ + + adds r3, #4 /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + ldr r4, [r3] /* r4 = *r3 i.e. r4 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r4, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + adds r3, #4 /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + movs r5, #4 /* r5 = 4. */ + str r5, [r2] /* Program RNR = 4. */ + ldmia r3!, {r6,r7} /* Read first set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write first set of RBAR/RLAR registers. */ + movs r5, #5 /* r5 = 5. */ + str r5, [r2] /* Program RNR = 5. */ + ldmia r3!, {r6,r7} /* Read second set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write second set of RBAR/RLAR registers. */ + movs r5, #6 /* r5 = 6. */ + str r5, [r2] /* Program RNR = 6. */ + ldmia r3!, {r6,r7} /* Read third set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write third set of RBAR/RLAR registers. */ + movs r5, #7 /* r5 = 7. */ + str r5, [r2] /* Program RNR = 7. */ + ldmia r3!, {r6,r7} /* Read fourth set of RBAR/RLAR from TCB. */ + ldr r4, =0xe000ed9c /* r4 = 0xe000ed9c [Location of RBAR]. */ + stmia r4!, {r6,r7} /* Write fourth set of RBAR/RLAR registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + movs r5, #1 /* r5 = 1. */ + orrs r4, r5 /* r4 = r4 | r5 i.e. Set the bit 0 in r4. */ + str r4, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + + #if ( configENABLE_MPU == 1 ) + ldmia r1!, {r0, r2-r4} /* Read from stack - r0 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = LR. */ + msr psplim, r2 /* Restore the PSPLIM register value for the task. */ + msr control, r3 /* Restore the CONTROL register value for the task. */ + mov lr, r4 /* LR = r4. */ + ldr r2, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + str r0, [r2] /* Restore the task's xSecureContext. */ + cbz r0, restore_ns_context /* If there is no secure context for the task, restore the non-secure context. */ + push {r1,r4} + bl SecureContext_LoadContext /* Restore the secure context. */ + pop {r1,r4} + mov lr, r4 /* LR = r4. */ + lsls r2, r4, #25 /* r2 = r4 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + bpl restore_ns_context /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + msr psp, r1 /* Remember the new top of stack for the task. */ + bx lr + #else /* configENABLE_MPU */ + ldmia r1!, {r0, r2-r3} /* Read from stack - r0 = xSecureContext, r2 = PSPLIM and r3 = LR. */ + msr psplim, r2 /* Restore the PSPLIM register value for the task. */ + mov lr, r3 /* LR = r3. */ + ldr r2, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + str r0, [r2] /* Restore the task's xSecureContext. */ + cbz r0, restore_ns_context /* If there is no secure context for the task, restore the non-secure context. */ + push {r1,r3} + bl SecureContext_LoadContext /* Restore the secure context. */ + pop {r1,r3} + mov lr, r3 /* LR = r3. */ + lsls r2, r3, #25 /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + bpl restore_ns_context /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + msr psp, r1 /* Remember the new top of stack for the task. */ + bx lr + #endif /* configENABLE_MPU */ + + restore_ns_context: + adds r1, r1, #16 /* Move to the high registers. */ + ldmia r1!, {r4-r7} /* Restore the high registers that are not automatically restored. */ + mov r8, r4 /* r8 = r4. */ + mov r9, r5 /* r9 = r5. */ + mov r10, r6 /* r10 = r6. */ + mov r11, r7 /* r11 = r7. */ + msr psp, r1 /* Remember the new top of stack for the task. */ + subs r1, r1, #32 /* Go back to the low registers. */ + ldmia r1!, {r4-r7} /* Restore the low registers that are not automatically restored. */ + bx lr +/*-----------------------------------------------------------*/ + +SVC_Handler: + movs r0, #4 + mov r1, lr + tst r0, r1 + beq stacking_used_msp + mrs r0, psp + b vPortSVCHandler_C + stacking_used_msp: + mrs r0, msp + b vPortSVCHandler_C +/*-----------------------------------------------------------*/ + +vPortFreeSecureContext: + ldr r1, [r0] /* The first item in the TCB is the top of the stack. */ + ldr r0, [r1] /* The first item on the stack is the task's xSecureContext. */ + cmp r0, #0 /* Raise svc if task's xSecureContext is not NULL. */ + beq free_secure_context + bx lr /* There is no secure context (xSecureContext is NULL). */ + free_secure_context: + svc 1 /* Secure context is freed in the supervisor call. portSVC_FREE_SECURE_CONTEXT = 1. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ + + END diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23/non_secure/portmacro.h b/FreeRTOS/Source/portable/IAR/ARM_CM23/non_secure/portmacro.h new file mode 100755 index 0000000..48b0e0b --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23/non_secure/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M23" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __root +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_context.c b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_context.c new file mode 100755 index 0000000..53535cd --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_context.c @@ -0,0 +1,204 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Secure context includes. */ +#include "secure_context.h" + +/* Secure heap includes. */ +#include "secure_heap.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief CONTROL value for privileged tasks. + * + * Bit[0] - 0 --> Thread mode is privileged. + * Bit[1] - 1 --> Thread mode uses PSP. + */ +#define securecontextCONTROL_VALUE_PRIVILEGED 0x02 + +/** + * @brief CONTROL value for un-privileged tasks. + * + * Bit[0] - 1 --> Thread mode is un-privileged. + * Bit[1] - 1 --> Thread mode uses PSP. + */ +#define securecontextCONTROL_VALUE_UNPRIVILEGED 0x03 +/*-----------------------------------------------------------*/ + +/** + * @brief Structure to represent secure context. + * + * @note Since stack grows down, pucStackStart is the highest address while + * pucStackLimit is the first addess of the allocated memory. + */ +typedef struct SecureContext +{ + uint8_t *pucCurrentStackPointer; /**< Current value of stack pointer (PSP). */ + uint8_t *pucStackLimit; /**< Last location of the stack memory (PSPLIM). */ + uint8_t *pucStackStart; /**< First location of the stack memory. */ +} SecureContext_t; +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_Init( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* No stack for thread mode until a task's context is loaded. */ + secureportSET_PSPLIM( securecontextNO_STACK ); + secureportSET_PSP( securecontextNO_STACK ); + + #if( configENABLE_MPU == 1 ) + { + /* Configure thread mode to use PSP and to be unprivileged. */ + secureportSET_CONTROL( securecontextCONTROL_VALUE_UNPRIVILEGED ); + } + #else /* configENABLE_MPU */ + { + /* Configure thread mode to use PSP and to be privileged.. */ + secureportSET_CONTROL( securecontextCONTROL_VALUE_PRIVILEGED ); + } + #endif /* configENABLE_MPU */ + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + secureportNON_SECURE_CALLABLE SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize, uint32_t ulIsTaskPrivileged ) +#else /* configENABLE_MPU */ + secureportNON_SECURE_CALLABLE SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize ) +#endif /* configENABLE_MPU */ +{ + uint8_t *pucStackMemory = NULL; + uint32_t ulIPSR; + SecureContextHandle_t xSecureContextHandle = NULL; + #if( configENABLE_MPU == 1 ) + uint32_t *pulCurrentStackPointer = NULL; + #endif /* configENABLE_MPU */ + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* Allocate the context structure. */ + xSecureContextHandle = ( SecureContextHandle_t ) pvPortMalloc( sizeof( SecureContext_t ) ); + + if( xSecureContextHandle != NULL ) + { + /* Allocate the stack space. */ + pucStackMemory = pvPortMalloc( ulSecureStackSize ); + + if( pucStackMemory != NULL ) + { + /* Since stack grows down, the starting point will be the last + * location. Note that this location is next to the last + * allocated byte because the hardware decrements the stack + * pointer before writing i.e. if stack pointer is 0x2, a push + * operation will decrement the stack pointer to 0x1 and then + * write at 0x1. */ + xSecureContextHandle->pucStackStart = pucStackMemory + ulSecureStackSize; + + /* The stack cannot go beyond this location. This value is + * programmed in the PSPLIM register on context switch.*/ + xSecureContextHandle->pucStackLimit = pucStackMemory; + + #if( configENABLE_MPU == 1 ) + { + /* Store the correct CONTROL value for the task on the stack. + * This value is programmed in the CONTROL register on + * context switch. */ + pulCurrentStackPointer = ( uint32_t * ) xSecureContextHandle->pucStackStart; + pulCurrentStackPointer--; + if( ulIsTaskPrivileged ) + { + *( pulCurrentStackPointer ) = securecontextCONTROL_VALUE_PRIVILEGED; + } + else + { + *( pulCurrentStackPointer ) = securecontextCONTROL_VALUE_UNPRIVILEGED; + } + + /* Store the current stack pointer. This value is programmed in + * the PSP register on context switch. */ + xSecureContextHandle->pucCurrentStackPointer = ( uint8_t * ) pulCurrentStackPointer; + } + #else /* configENABLE_MPU */ + { + /* Current SP is set to the starting of the stack. This + * value programmed in the PSP register on context switch. */ + xSecureContextHandle->pucCurrentStackPointer = xSecureContextHandle->pucStackStart; + + } + #endif /* configENABLE_MPU */ + } + else + { + /* Free the context to avoid memory leak and make sure to return + * NULL to indicate failure. */ + vPortFree( xSecureContextHandle ); + xSecureContextHandle = NULL; + } + } + } + + return xSecureContextHandle; +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_FreeContext( SecureContextHandle_t xSecureContextHandle ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* Ensure that valid parameters are passed. */ + secureportASSERT( xSecureContextHandle != NULL ); + + /* Free the stack space. */ + vPortFree( xSecureContextHandle->pucStackLimit ); + + /* Free the context itself. */ + vPortFree( xSecureContextHandle ); + } +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_context.h b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_context.h new file mode 100755 index 0000000..e148bff --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_context.h @@ -0,0 +1,111 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_CONTEXT_H__ +#define __SECURE_CONTEXT_H__ + +/* Standard includes. */ +#include + +/* FreeRTOS includes. */ +#include "FreeRTOSConfig.h" + +/** + * @brief PSP value when no task's context is loaded. + */ +#define securecontextNO_STACK 0x0 + +/** + * @brief Opaque handle. + */ +struct SecureContext; +typedef struct SecureContext* SecureContextHandle_t; +/*-----------------------------------------------------------*/ + +/** + * @brief Initializes the secure context management system. + * + * PSP is set to NULL and therefore a task must allocate and load a context + * before calling any secure side function in the thread mode. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureContext_Init( void ); + +/** + * @brief Allocates a context on the secure side. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] ulSecureStackSize Size of the stack to allocate on secure side. + * @param[in] ulIsTaskPrivileged 1 if the calling task is privileged, 0 otherwise. + * + * @return Opaque context handle if context is successfully allocated, NULL + * otherwise. + */ +#if( configENABLE_MPU == 1 ) + SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize, uint32_t ulIsTaskPrivileged ); +#else /* configENABLE_MPU */ + SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize ); +#endif /* configENABLE_MPU */ + +/** + * @brief Frees the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the + * context to be freed. + */ +void SecureContext_FreeContext( SecureContextHandle_t xSecureContextHandle ); + +/** + * @brief Loads the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the context + * to be loaded. + */ +void SecureContext_LoadContext( SecureContextHandle_t xSecureContextHandle ); + +/** + * @brief Saves the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the context + * to be saved. + */ +void SecureContext_SaveContext( SecureContextHandle_t xSecureContextHandle ); + +#endif /* __SECURE_CONTEXT_H__ */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_context_port.c b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_context_port.c new file mode 100755 index 0000000..619db1e --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_context_port.c @@ -0,0 +1,48 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Secure context includes. */ +#include "secure_context.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/* Functions implemented in assembler file. */ +extern void SecureContext_LoadContextAsm( SecureContextHandle_t xSecureContextHandle ); +extern void SecureContext_SaveContextAsm( SecureContextHandle_t xSecureContextHandle ); + +secureportNON_SECURE_CALLABLE void SecureContext_LoadContext( SecureContextHandle_t xSecureContextHandle ) +{ + SecureContext_LoadContextAsm( xSecureContextHandle ); +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_SaveContext( SecureContextHandle_t xSecureContextHandle ) +{ + SecureContext_SaveContextAsm( xSecureContextHandle ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_context_port_asm.s b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_context_port_asm.s new file mode 100755 index 0000000..65cee0c --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_context_port_asm.s @@ -0,0 +1,76 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + SECTION .text:CODE:NOROOT(2) + THUMB + + PUBLIC SecureContext_LoadContextAsm + PUBLIC SecureContext_SaveContextAsm + +#if ( configENABLE_FPU == 1 ) + #error Cortex-M23 does not have a Floating Point Unit (FPU) and therefore configENABLE_FPU must be set to 0. +#endif +/*-----------------------------------------------------------*/ + +SecureContext_LoadContextAsm: + /* xSecureContextHandle value is in r0. */ + mrs r1, ipsr /* r1 = IPSR. */ + cbz r1, load_ctx_therad_mode /* Do nothing if the processor is running in the Thread Mode. */ + ldmia r0!, {r1, r2} /* r1 = xSecureContextHandle->pucCurrentStackPointer, r2 = xSecureContextHandle->pucStackLimit. */ +#if ( configENABLE_MPU == 1 ) + ldmia r1!, {r3} /* Read CONTROL register value from task's stack. r3 = CONTROL. */ + msr control, r3 /* CONTROL = r3. */ +#endif /* configENABLE_MPU */ + msr psplim, r2 /* PSPLIM = r2. */ + msr psp, r1 /* PSP = r1. */ + + load_ctx_therad_mode: + bx lr +/*-----------------------------------------------------------*/ + +SecureContext_SaveContextAsm: + /* xSecureContextHandle value is in r0. */ + mrs r1, ipsr /* r1 = IPSR. */ + cbz r1, save_ctx_therad_mode /* Do nothing if the processor is running in the Thread Mode. */ + mrs r1, psp /* r1 = PSP. */ +#if ( configENABLE_MPU == 1 ) + mrs r2, control /* r2 = CONTROL. */ + subs r1, r1, #4 /* Make space for the CONTROL value on the stack. */ + str r1, [r0] /* Save the top of stack in context. xSecureContextHandle->pucCurrentStackPointer = r1. */ + stmia r1!, {r2} /* Store CONTROL value on the stack. */ +#else /* configENABLE_MPU */ + str r1, [r0] /* Save the top of stack in context. xSecureContextHandle->pucCurrentStackPointer = r1. */ +#endif /* configENABLE_MPU */ + movs r1, #0 /* r1 = securecontextNO_STACK. */ + msr psplim, r1 /* PSPLIM = securecontextNO_STACK. */ + msr psp, r1 /* PSP = securecontextNO_STACK i.e. No stack for thread mode until next task's context is loaded. */ + + save_ctx_therad_mode: + bx lr +/*-----------------------------------------------------------*/ + + END diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_heap.c b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_heap.c new file mode 100755 index 0000000..60fce5c --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_heap.c @@ -0,0 +1,450 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Secure context heap includes. */ +#include "secure_heap.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief Total heap size. + */ +#define secureconfigTOTAL_HEAP_SIZE ( ( ( size_t ) ( 10 * 1024 ) ) ) + +/* No test marker by default. */ +#ifndef mtCOVERAGE_TEST_MARKER + #define mtCOVERAGE_TEST_MARKER() +#endif + +/* No tracing by default. */ +#ifndef traceMALLOC + #define traceMALLOC( pvReturn, xWantedSize ) +#endif + +/* No tracing by default. */ +#ifndef traceFREE + #define traceFREE( pv, xBlockSize ) +#endif + +/* Block sizes must not get too small. */ +#define secureheapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) ) + +/* Assumes 8bit bytes! */ +#define secureheapBITS_PER_BYTE ( ( size_t ) 8 ) +/*-----------------------------------------------------------*/ + +/* Allocate the memory for the heap. */ +#if( configAPPLICATION_ALLOCATED_HEAP == 1 ) + /* The application writer has already defined the array used for the RTOS + * heap - probably so it can be placed in a special segment or address. */ + extern uint8_t ucHeap[ secureconfigTOTAL_HEAP_SIZE ]; +#else /* configAPPLICATION_ALLOCATED_HEAP */ + static uint8_t ucHeap[ secureconfigTOTAL_HEAP_SIZE ]; +#endif /* configAPPLICATION_ALLOCATED_HEAP */ + +/** + * @brief The linked list structure. + * + * This is used to link free blocks in order of their memory address. + */ +typedef struct A_BLOCK_LINK +{ + struct A_BLOCK_LINK *pxNextFreeBlock; /**< The next free block in the list. */ + size_t xBlockSize; /**< The size of the free block. */ +} BlockLink_t; +/*-----------------------------------------------------------*/ + +/** + * @brief Called automatically to setup the required heap structures the first + * time pvPortMalloc() is called. + */ +static void prvHeapInit( void ); + +/** + * @brief Inserts a block of memory that is being freed into the correct + * position in the list of free memory blocks. + * + * The block being freed will be merged with the block in front it and/or the + * block behind it if the memory blocks are adjacent to each other. + * + * @param[in] pxBlockToInsert The block being freed. + */ +static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ); +/*-----------------------------------------------------------*/ + +/** + * @brief The size of the structure placed at the beginning of each allocated + * memory block must by correctly byte aligned. + */ +static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( secureportBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + +/** + * @brief Create a couple of list links to mark the start and end of the list. + */ +static BlockLink_t xStart, *pxEnd = NULL; + +/** + * @brief Keeps track of the number of free bytes remaining, but says nothing + * about fragmentation. + */ +static size_t xFreeBytesRemaining = 0U; +static size_t xMinimumEverFreeBytesRemaining = 0U; + +/** + * @brief Gets set to the top bit of an size_t type. + * + * When this bit in the xBlockSize member of an BlockLink_t structure is set + * then the block belongs to the application. When the bit is free the block is + * still part of the free heap space. + */ +static size_t xBlockAllocatedBit = 0; +/*-----------------------------------------------------------*/ + +static void prvHeapInit( void ) +{ +BlockLink_t *pxFirstFreeBlock; +uint8_t *pucAlignedHeap; +size_t uxAddress; +size_t xTotalHeapSize = secureconfigTOTAL_HEAP_SIZE; + + /* Ensure the heap starts on a correctly aligned boundary. */ + uxAddress = ( size_t ) ucHeap; + + if( ( uxAddress & secureportBYTE_ALIGNMENT_MASK ) != 0 ) + { + uxAddress += ( secureportBYTE_ALIGNMENT - 1 ); + uxAddress &= ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + xTotalHeapSize -= uxAddress - ( size_t ) ucHeap; + } + + pucAlignedHeap = ( uint8_t * ) uxAddress; + + /* xStart is used to hold a pointer to the first item in the list of free + * blocks. The void cast is used to prevent compiler warnings. */ + xStart.pxNextFreeBlock = ( void * ) pucAlignedHeap; + xStart.xBlockSize = ( size_t ) 0; + + /* pxEnd is used to mark the end of the list of free blocks and is inserted + * at the end of the heap space. */ + uxAddress = ( ( size_t ) pucAlignedHeap ) + xTotalHeapSize; + uxAddress -= xHeapStructSize; + uxAddress &= ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + pxEnd = ( void * ) uxAddress; + pxEnd->xBlockSize = 0; + pxEnd->pxNextFreeBlock = NULL; + + /* To start with there is a single free block that is sized to take up the + * entire heap space, minus the space taken by pxEnd. */ + pxFirstFreeBlock = ( void * ) pucAlignedHeap; + pxFirstFreeBlock->xBlockSize = uxAddress - ( size_t ) pxFirstFreeBlock; + pxFirstFreeBlock->pxNextFreeBlock = pxEnd; + + /* Only one block exists - and it covers the entire usable heap space. */ + xMinimumEverFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; + xFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; + + /* Work out the position of the top bit in a size_t variable. */ + xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * secureheapBITS_PER_BYTE ) - 1 ); +} +/*-----------------------------------------------------------*/ + +static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ) +{ +BlockLink_t *pxIterator; +uint8_t *puc; + + /* Iterate through the list until a block is found that has a higher address + * than the block being inserted. */ + for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) + { + /* Nothing to do here, just iterate to the right position. */ + } + + /* Do the block being inserted, and the block it is being inserted after + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxIterator; + if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) + { + pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; + pxBlockToInsert = pxIterator; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Do the block being inserted, and the block it is being inserted before + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxBlockToInsert; + if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) + { + if( pxIterator->pxNextFreeBlock != pxEnd ) + { + /* Form one big block from the two blocks. */ + pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock; + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxEnd; + } + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; + } + + /* If the block being inserted plugged a gab, so was merged with the block + * before and the block after, then it's pxNextFreeBlock pointer will have + * already been set, and should not be set here as that would make it point + * to itself. */ + if( pxIterator != pxBlockToInsert ) + { + pxIterator->pxNextFreeBlock = pxBlockToInsert; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } +} +/*-----------------------------------------------------------*/ + +void *pvPortMalloc( size_t xWantedSize ) +{ +BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink; +void *pvReturn = NULL; + + /* If this is the first call to malloc then the heap will require + * initialisation to setup the list of free blocks. */ + if( pxEnd == NULL ) + { + prvHeapInit(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Check the requested block size is not so large that the top bit is set. + * The top bit of the block size member of the BlockLink_t structure is used + * to determine who owns the block - the application or the kernel, so it + * must be free. */ + if( ( xWantedSize & xBlockAllocatedBit ) == 0 ) + { + /* The wanted size is increased so it can contain a BlockLink_t + * structure in addition to the requested amount of bytes. */ + if( xWantedSize > 0 ) + { + xWantedSize += xHeapStructSize; + + /* Ensure that blocks are always aligned to the required number of + * bytes. */ + if( ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) != 0x00 ) + { + /* Byte alignment required. */ + xWantedSize += ( secureportBYTE_ALIGNMENT - ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) ); + secureportASSERT( ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) == 0 ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) + { + /* Traverse the list from the start (lowest address) block until + * one of adequate size is found. */ + pxPreviousBlock = &xStart; + pxBlock = xStart.pxNextFreeBlock; + while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) + { + pxPreviousBlock = pxBlock; + pxBlock = pxBlock->pxNextFreeBlock; + } + + /* If the end marker was reached then a block of adequate size was + * not found. */ + if( pxBlock != pxEnd ) + { + /* Return the memory space pointed to - jumping over the + * BlockLink_t structure at its start. */ + pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize ); + + /* This block is being returned for use so must be taken out + * of the list of free blocks. */ + pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; + + /* If the block is larger than required it can be split into + * two. */ + if( ( pxBlock->xBlockSize - xWantedSize ) > secureheapMINIMUM_BLOCK_SIZE ) + { + /* This block is to be split into two. Create a new + * block following the number of bytes requested. The void + * cast is used to prevent byte alignment warnings from the + * compiler. */ + pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize ); + secureportASSERT( ( ( ( size_t ) pxNewBlockLink ) & secureportBYTE_ALIGNMENT_MASK ) == 0 ); + + /* Calculate the sizes of two blocks split from the single + * block. */ + pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; + pxBlock->xBlockSize = xWantedSize; + + /* Insert the new block into the list of free blocks. */ + prvInsertBlockIntoFreeList( pxNewBlockLink ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + xFreeBytesRemaining -= pxBlock->xBlockSize; + + if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) + { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* The block is being returned - it is allocated and owned by + * the application and has no "next" block. */ + pxBlock->xBlockSize |= xBlockAllocatedBit; + pxBlock->pxNextFreeBlock = NULL; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + traceMALLOC( pvReturn, xWantedSize ); + + #if( secureconfigUSE_MALLOC_FAILED_HOOK == 1 ) + { + if( pvReturn == NULL ) + { + extern void vApplicationMallocFailedHook( void ); + vApplicationMallocFailedHook(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif + + secureportASSERT( ( ( ( size_t ) pvReturn ) & ( size_t ) secureportBYTE_ALIGNMENT_MASK ) == 0 ); + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void *pv ) +{ +uint8_t *puc = ( uint8_t * ) pv; +BlockLink_t *pxLink; + + if( pv != NULL ) + { + /* The memory being freed will have an BlockLink_t structure immediately + * before it. */ + puc -= xHeapStructSize; + + /* This casting is to keep the compiler from issuing warnings. */ + pxLink = ( void * ) puc; + + /* Check the block is actually allocated. */ + secureportASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ); + secureportASSERT( pxLink->pxNextFreeBlock == NULL ); + + if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) + { + if( pxLink->pxNextFreeBlock == NULL ) + { + /* The block is being returned to the heap - it is no longer + * allocated. */ + pxLink->xBlockSize &= ~xBlockAllocatedBit; + + secureportDISABLE_NON_SECURE_INTERRUPTS(); + { + /* Add this block to the list of free blocks. */ + xFreeBytesRemaining += pxLink->xBlockSize; + traceFREE( pv, pxLink->xBlockSize ); + prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) ); + } + secureportENABLE_NON_SECURE_INTERRUPTS(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } +} +/*-----------------------------------------------------------*/ + +size_t xPortGetFreeHeapSize( void ) +{ + return xFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +size_t xPortGetMinimumEverFreeHeapSize( void ) +{ + return xMinimumEverFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +void vPortInitialiseBlocks( void ) +{ + /* This just exists to keep the linker quiet. */ +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_heap.h b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_heap.h new file mode 100755 index 0000000..69e4f2a --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_heap.h @@ -0,0 +1,51 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_HEAP_H__ +#define __SECURE_HEAP_H__ + +/* Standard includes. */ +#include + +/** + * @brief Allocates memory from heap. + * + * @param[in] xWantedSize The size of the memory to be allocated. + * + * @return Pointer to the memory region if the allocation is successful, NULL + * otherwise. + */ +void *pvPortMalloc( size_t xWantedSize ); + +/** + * @brief Frees the previously allocated memory. + * + * @param[in] pv Pointer to the memory to be freed. + */ +void vPortFree( void *pv ); + +#endif /* __SECURE_HEAP_H__ */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_init.c b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_init.c new file mode 100755 index 0000000..c6525f7 --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_init.c @@ -0,0 +1,105 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Secure init includes. */ +#include "secure_init.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief Constants required to manipulate the SCB. + */ +#define secureinitSCB_AIRCR ( ( volatile uint32_t * ) 0xe000ed0c ) /* Application Interrupt and Reset Control Register. */ +#define secureinitSCB_AIRCR_VECTKEY_POS ( 16UL ) +#define secureinitSCB_AIRCR_VECTKEY_MASK ( 0xFFFFUL << secureinitSCB_AIRCR_VECTKEY_POS ) +#define secureinitSCB_AIRCR_PRIS_POS ( 14UL ) +#define secureinitSCB_AIRCR_PRIS_MASK ( 1UL << secureinitSCB_AIRCR_PRIS_POS ) + +/** + * @brief Constants required to manipulate the FPU. + */ +#define secureinitFPCCR ( ( volatile uint32_t * ) 0xe000ef34 ) /* Floating Point Context Control Register. */ +#define secureinitFPCCR_LSPENS_POS ( 29UL ) +#define secureinitFPCCR_LSPENS_MASK ( 1UL << secureinitFPCCR_LSPENS_POS ) +#define secureinitFPCCR_TS_POS ( 26UL ) +#define secureinitFPCCR_TS_MASK ( 1UL << secureinitFPCCR_TS_POS ) + +#define secureinitNSACR ( ( volatile uint32_t * ) 0xe000ed8c ) /* Non-secure Access Control Register. */ +#define secureinitNSACR_CP10_POS ( 10UL ) +#define secureinitNSACR_CP10_MASK ( 1UL << secureinitNSACR_CP10_POS ) +#define secureinitNSACR_CP11_POS ( 11UL ) +#define secureinitNSACR_CP11_MASK ( 1UL << secureinitNSACR_CP11_POS ) +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureInit_DePrioritizeNSExceptions( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + *( secureinitSCB_AIRCR ) = ( *( secureinitSCB_AIRCR ) & ~( secureinitSCB_AIRCR_VECTKEY_MASK | secureinitSCB_AIRCR_PRIS_MASK ) ) | + ( ( 0x05FAUL << secureinitSCB_AIRCR_VECTKEY_POS ) & secureinitSCB_AIRCR_VECTKEY_MASK ) | + ( ( 0x1UL << secureinitSCB_AIRCR_PRIS_POS ) & secureinitSCB_AIRCR_PRIS_MASK ); + } +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureInit_EnableNSFPUAccess( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* CP10 = 1 ==> Non-secure access to the Floating Point Unit is + * permitted. CP11 should be programmed to the same value as CP10. */ + *( secureinitNSACR ) |= ( secureinitNSACR_CP10_MASK | secureinitNSACR_CP11_MASK ); + + /* LSPENS = 0 ==> LSPEN is writable fron non-secure state. This ensures + * that we can enable/disable lazy stacking in port.c file. */ + *( secureinitFPCCR ) &= ~ ( secureinitFPCCR_LSPENS_MASK ); + + /* TS = 1 ==> Treat FP registers as secure i.e. callee saved FP + * registers (S16-S31) are also pushed to stack on exception entry and + * restored on exception return. */ + *( secureinitFPCCR ) |= ( secureinitFPCCR_TS_MASK ); + } +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_init.h b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_init.h new file mode 100755 index 0000000..6c5bc71 --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_init.h @@ -0,0 +1,53 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_INIT_H__ +#define __SECURE_INIT_H__ + +/** + * @brief De-prioritizes the non-secure exceptions. + * + * This is needed to ensure that the non-secure PendSV runs at the lowest + * priority. Context switch is done in the non-secure PendSV handler. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureInit_DePrioritizeNSExceptions( void ); + +/** + * @brief Sets up the Floating Point Unit (FPU) for Non-Secure access. + * + * Also sets FPCCR.TS=1 to ensure that the content of the Floating Point + * Registers are not leaked to the non-secure side. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureInit_EnableNSFPUAccess( void ); + +#endif /* __SECURE_INIT_H__ */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_port_macros.h b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_port_macros.h new file mode 100755 index 0000000..760edab --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23/secure/secure_port_macros.h @@ -0,0 +1,133 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_PORT_MACROS_H__ +#define __SECURE_PORT_MACROS_H__ + +/** + * @brief Byte alignment requirements. + */ +#define secureportBYTE_ALIGNMENT 8 +#define secureportBYTE_ALIGNMENT_MASK ( 0x0007 ) + +/** + * @brief Macro to declare a function as non-secure callable. + */ +#if defined( __IAR_SYSTEMS_ICC__ ) + #define secureportNON_SECURE_CALLABLE __cmse_nonsecure_entry __root +#else + #define secureportNON_SECURE_CALLABLE __attribute__((cmse_nonsecure_entry)) __attribute__((used)) +#endif + +/** + * @brief Set the secure PRIMASK value. + */ +#define secureportSET_SECURE_PRIMASK( ulPrimaskValue ) \ + __asm volatile ( "msr primask, %0" : : "r" ( ulPrimaskValue ) : "memory" ) + +/** + * @brief Set the non-secure PRIMASK value. + */ +#define secureportSET_NON_SECURE_PRIMASK( ulPrimaskValue ) \ + __asm volatile ( "msr primask_ns, %0" : : "r" ( ulPrimaskValue ) : "memory" ) + +/** + * @brief Read the PSP value in the given variable. + */ +#define secureportREAD_PSP( pucOutCurrentStackPointer ) \ + __asm volatile ( "mrs %0, psp" : "=r" ( pucOutCurrentStackPointer ) ) + +/** + * @brief Set the PSP to the given value. + */ +#define secureportSET_PSP( pucCurrentStackPointer ) \ + __asm volatile ( "msr psp, %0" : : "r" ( pucCurrentStackPointer ) ) + +/** + * @brief Set the PSPLIM to the given value. + */ +#define secureportSET_PSPLIM( pucStackLimit ) \ + __asm volatile ( "msr psplim, %0" : : "r" ( pucStackLimit ) ) + +/** + * @brief Set the NonSecure MSP to the given value. + */ +#define secureportSET_MSP_NS( pucMainStackPointer ) \ + __asm volatile ( "msr msp_ns, %0" : : "r" ( pucMainStackPointer ) ) + +/** + * @brief Set the CONTROL register to the given value. + */ +#define secureportSET_CONTROL( ulControl ) \ + __asm volatile ( "msr control, %0" : : "r" ( ulControl ) : "memory" ) + +/** + * @brief Read the Interrupt Program Status Register (IPSR) value in the given + * variable. + */ +#define secureportREAD_IPSR( ulIPSR ) \ + __asm volatile ( "mrs %0, ipsr" : "=r" ( ulIPSR ) ) + +/** + * @brief PRIMASK value to enable interrupts. + */ +#define secureportPRIMASK_ENABLE_INTERRUPTS_VAL 0 + +/** + * @brief PRIMASK value to disable interrupts. + */ +#define secureportPRIMASK_DISABLE_INTERRUPTS_VAL 1 + +/** + * @brief Disable secure interrupts. + */ +#define secureportDISABLE_SECURE_INTERRUPTS() secureportSET_SECURE_PRIMASK( secureportPRIMASK_DISABLE_INTERRUPTS_VAL ) + +/** + * @brief Disable non-secure interrupts. + * + * This effectively disables context switches. + */ +#define secureportDISABLE_NON_SECURE_INTERRUPTS() secureportSET_NON_SECURE_PRIMASK( secureportPRIMASK_DISABLE_INTERRUPTS_VAL ) + +/** + * @brief Enable non-secure interrupts. + */ +#define secureportENABLE_NON_SECURE_INTERRUPTS() secureportSET_NON_SECURE_PRIMASK( secureportPRIMASK_ENABLE_INTERRUPTS_VAL ) + +/** + * @brief Assert definition. + */ +#define secureportASSERT( x ) \ + if( ( x ) == 0 ) \ + { \ + secureportDISABLE_SECURE_INTERRUPTS(); \ + secureportDISABLE_NON_SECURE_INTERRUPTS(); \ + for( ;; ); \ + } + +#endif /* __SECURE_PORT_MACROS_H__ */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23_NTZ/non_secure/port.c b/FreeRTOS/Source/portable/IAR/ARM_CM23_NTZ/non_secure/port.c new file mode 100755 index 0000000..bd85a6f --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23_NTZ/non_secure/port.c @@ -0,0 +1,899 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/* Portasm includes. */ +#include "portasm.h" + +#if( configENABLE_TRUSTZONE == 1 ) + /* Secure components includes. */ + #include "secure_context.h" + #include "secure_init.h" +#endif /* configENABLE_TRUSTZONE */ + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/** + * The FreeRTOS Cortex M33 port can be configured to run on the Secure Side only + * i.e. the processor boots as secure and never jumps to the non-secure side. + * The Trust Zone support in the port must be disabled in order to run FreeRTOS + * on the secure side. The following are the valid configuration seetings: + * + * 1. Run FreeRTOS on the Secure Side: + * configRUN_FREERTOS_SECURE_ONLY = 1 and configENABLE_TRUSTZONE = 0 + * + * 2. Run FreeRTOS on the Non-Secure Side with Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 1 + * + * 3. Run FreeRTOS on the Non-Secure Side only i.e. no Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 0 + */ +#if( ( configRUN_FREERTOS_SECURE_ONLY == 1 ) && ( configENABLE_TRUSTZONE == 1 ) ) + #error TrustZone needs to be disabled in order to run FreeRTOS on the Secure Side. +#endif +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the NVIC. + */ +#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t * ) 0xe000e010 ) +#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t * ) 0xe000e014 ) +#define portNVIC_SYSTICK_CURRENT_VALUE ( ( volatile uint32_t * ) 0xe000e018 ) +#define portNVIC_INT_CTRL ( ( volatile uint32_t * ) 0xe000ed04 ) +#define portNVIC_SYSPRI2 ( ( volatile uint32_t * ) 0xe000ed20 ) +#define portNVIC_SYSTICK_CLK ( 0x00000004 ) +#define portNVIC_SYSTICK_INT ( 0x00000002 ) +#define portNVIC_SYSTICK_ENABLE ( 0x00000001 ) +#define portNVIC_PENDSVSET ( 0x10000000 ) +#define portMIN_INTERRUPT_PRIORITY ( 255UL ) +#define portNVIC_PENDSV_PRI ( portMIN_INTERRUPT_PRIORITY << 16UL ) +#define portNVIC_SYSTICK_PRI ( portMIN_INTERRUPT_PRIORITY << 24UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the SCB. + */ +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( * ( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_MEM_FAULT_ENABLE ( 1UL << 16UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the FPU. + */ +#define portCPACR ( ( volatile uint32_t * ) 0xe000ed88 ) /* Coprocessor Access Control Register. */ +#define portCPACR_CP10_VALUE ( 3UL ) +#define portCPACR_CP11_VALUE portCPACR_CP10_VALUE +#define portCPACR_CP10_POS ( 20UL ) +#define portCPACR_CP11_POS ( 22UL ) + +#define portFPCCR ( ( volatile uint32_t * ) 0xe000ef34 ) /* Floating Point Context Control Register. */ +#define portFPCCR_ASPEN_POS ( 31UL ) +#define portFPCCR_ASPEN_MASK ( 1UL << portFPCCR_ASPEN_POS ) +#define portFPCCR_LSPEN_POS ( 30UL ) +#define portFPCCR_LSPEN_MASK ( 1UL << portFPCCR_LSPEN_POS ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the MPU. + */ +#define portMPU_TYPE_REG ( * ( ( volatile uint32_t * ) 0xe000ed90 ) ) +#define portMPU_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed94 ) ) +#define portMPU_RNR_REG ( * ( ( volatile uint32_t * ) 0xe000ed98 ) ) + +#define portMPU_RBAR_REG ( * ( ( volatile uint32_t * ) 0xe000ed9c ) ) +#define portMPU_RLAR_REG ( * ( ( volatile uint32_t * ) 0xe000eda0 ) ) + +#define portMPU_RBAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda4 ) ) +#define portMPU_RLAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda8 ) ) + +#define portMPU_RBAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edac ) ) +#define portMPU_RLAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edb0 ) ) + +#define portMPU_RBAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb4 ) ) +#define portMPU_RLAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb8 ) ) + +#define portMPU_MAIR0_REG ( * ( ( volatile uint32_t * ) 0xe000edc0 ) ) +#define portMPU_MAIR1_REG ( * ( ( volatile uint32_t * ) 0xe000edc4 ) ) + +#define portMPU_RBAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ +#define portMPU_RLAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ + +#define portMPU_MAIR_ATTR0_POS ( 0UL ) +#define portMPU_MAIR_ATTR0_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR1_POS ( 8UL ) +#define portMPU_MAIR_ATTR1_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR2_POS ( 16UL ) +#define portMPU_MAIR_ATTR2_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR3_POS ( 24UL ) +#define portMPU_MAIR_ATTR3_MASK ( 0xff000000 ) + +#define portMPU_MAIR_ATTR4_POS ( 0UL ) +#define portMPU_MAIR_ATTR4_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR5_POS ( 8UL ) +#define portMPU_MAIR_ATTR5_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR6_POS ( 16UL ) +#define portMPU_MAIR_ATTR6_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR7_POS ( 24UL ) +#define portMPU_MAIR_ATTR7_MASK ( 0xff000000 ) + +#define portMPU_RLAR_ATTR_INDEX0 ( 0UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX1 ( 1UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX2 ( 2UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX3 ( 3UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX4 ( 4UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX5 ( 5UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX6 ( 6UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX7 ( 7UL << 1UL ) + +#define portMPU_RLAR_REGION_ENABLE ( 1UL ) + +/* Enable privileged access to unmapped region. */ +#define portMPU_PRIV_BACKGROUND_ENABLE ( 1UL << 2UL ) + +/* Enable MPU. */ +#define portMPU_ENABLE ( 1UL << 0UL ) + +/* Expected value of the portMPU_TYPE register. */ +#define portEXPECTED_MPU_TYPE_VALUE ( 8UL << 8UL ) /* 8 regions, unified. */ +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to set up the initial stack. + */ +#define portINITIAL_XPSR ( 0x01000000 ) + +#if( configRUN_FREERTOS_SECURE_ONLY == 1 ) + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF FD + * 1111 1111 1111 1111 1111 1111 1111 1101 + * + * Bit[6] - 1 --> The exception was taken from the Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 1 --> The exception was taken to the Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xfffffffd ) +#else + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF BC + * 1111 1111 1111 1111 1111 1111 1011 1100 + * + * Bit[6] - 0 --> The exception was taken from the Non-Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 0 --> The exception was taken to the Non-Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xffffffbc ) +#endif /* configRUN_FREERTOS_SECURE_ONLY */ + +/** + * @brief CONTROL register privileged bit mask. + * + * Bit[0] in CONTROL register tells the privilege: + * Bit[0] = 0 ==> The task is privileged. + * Bit[0] = 1 ==> The task is not privileged. + */ +#define portCONTROL_PRIVILEGED_MASK ( 1UL << 0UL ) + +/** + * @brief Initial CONTROL register values. + */ +#define portINITIAL_CONTROL_UNPRIVILEGED ( 0x3 ) +#define portINITIAL_CONTROL_PRIVILEGED ( 0x2 ) + +/** + * @brief Let the user override the pre-loading of the initial LR with the + * address of prvTaskExitError() in case it messes up unwinding of the stack + * in the debugger. + */ +#ifdef configTASK_RETURN_ADDRESS + #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS +#else + #define portTASK_RETURN_ADDRESS prvTaskExitError +#endif + +/** + * @brief If portPRELOAD_REGISTERS then registers will be given an initial value + * when a task is created. This helps in debugging at the cost of code size. + */ +#define portPRELOAD_REGISTERS 1 + +/** + * @brief A task is created without a secure context, and must call + * portALLOCATE_SECURE_CONTEXT() to give itself a secure context before it makes + * any secure calls. + */ +#define portNO_SECURE_CONTEXT 0 +/*-----------------------------------------------------------*/ + +/** + * @brief Setup the timer to generate the tick interrupts. + */ +static void prvSetupTimerInterrupt( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Used to catch tasks that attempt to return from their implementing + * function. + */ +static void prvTaskExitError( void ); + +#if( configENABLE_MPU == 1 ) + /** + * @brief Setup the Memory Protection Unit (MPU). + */ + static void prvSetupMPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_MPU */ + +#if( configENABLE_FPU == 1 ) + /** + * @brief Setup the Floating Point Unit (FPU). + */ + static void prvSetupFPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_FPU */ + +/** + * @brief Yield the processor. + */ +void vPortYield( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Enter critical section. + */ +void vPortEnterCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Exit from critical section. + */ +void vPortExitCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief SysTick handler. + */ +void SysTick_Handler( void ) PRIVILEGED_FUNCTION; + +/** + * @brief C part of SVC handler. + */ +portDONT_DISCARD void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) PRIVILEGED_FUNCTION; +/*-----------------------------------------------------------*/ + +/** + * @brief Each task maintains its own interrupt status in the critical nesting + * variable. + */ +static volatile uint32_t ulCriticalNesting = 0xaaaaaaaaUL; + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Saved as part of the task context to indicate which context the + * task is using on the secure side. + */ + portDONT_DISCARD volatile SecureContextHandle_t xSecureContext = portNO_SECURE_CONTEXT; +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +static void prvSetupTimerInterrupt( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Stop and reset the SysTick. */ + *( portNVIC_SYSTICK_CTRL ) = 0UL; + *( portNVIC_SYSTICK_CURRENT_VALUE ) = 0UL; + + /* Configure SysTick to interrupt at the requested rate. */ + *( portNVIC_SYSTICK_LOAD ) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; + *( portNVIC_SYSTICK_CTRL ) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE; +} +/*-----------------------------------------------------------*/ + +static void prvTaskExitError( void ) +{ +volatile uint32_t ulDummy = 0UL; + + /* A function that implements a task must not exit or attempt to return to + * its caller as there is nothing to return to. If a task wants to exit it + * should instead call vTaskDelete( NULL ). Artificially force an assert() + * to be triggered if configASSERT() is defined, then stop here so + * application writers can catch the error. */ + configASSERT( ulCriticalNesting == ~0UL ); + portDISABLE_INTERRUPTS(); + + while( ulDummy == 0 ) + { + /* This file calls prvTaskExitError() after the scheduler has been + * started to remove a compiler warning about the function being + * defined but never called. ulDummy is used purely to quieten other + * warnings about code appearing after this function is called - making + * ulDummy volatile makes the compiler think the function could return + * and therefore not output an 'unreachable code' warning for code that + * appears after it. */ + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + static void prvSetupMPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __privileged_functions_start__; + extern uint32_t * __privileged_functions_end__; + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + extern uint32_t * __unprivileged_flash_start__; + extern uint32_t * __unprivileged_flash_end__; + extern uint32_t * __privileged_sram_start__; + extern uint32_t * __privileged_sram_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __privileged_functions_start__[]; + extern uint32_t __privileged_functions_end__[]; + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + extern uint32_t __unprivileged_flash_start__[]; + extern uint32_t __unprivileged_flash_end__[]; + extern uint32_t __privileged_sram_start__[]; + extern uint32_t __privileged_sram_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ + + /* Check that the MPU is present. */ + if( portMPU_TYPE_REG == portEXPECTED_MPU_TYPE_VALUE ) + { + /* MAIR0 - Index 0. */ + portMPU_MAIR0_REG |= ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + /* MAIR0 - Index 1. */ + portMPU_MAIR0_REG |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* Setup privileged flash as Read Only so that privileged tasks can + * read it but not modify. */ + portMPU_RNR_REG = portPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_functions_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_functions_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged flash as Read Only by both privileged and + * unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __unprivileged_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __unprivileged_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged syscalls flash as Read Only by both privileged + * and unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_SYSCALLS_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __syscalls_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __syscalls_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup RAM containing kernel data for privileged access only. */ + portMPU_RNR_REG = portPRIVILEGED_RAM_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_sram_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_sram_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Enable mem fault. */ + portSCB_SYS_HANDLER_CTRL_STATE_REG |= portSCB_MEM_FAULT_ENABLE; + + /* Enable MPU with privileged background access i.e. unmapped + * regions have privileged access. */ + portMPU_CTRL_REG |= ( portMPU_PRIV_BACKGROUND_ENABLE | portMPU_ENABLE ); + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_FPU == 1 ) + static void prvSetupFPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* Enable non-secure access to the FPU. */ + SecureInit_EnableNSFPUAccess(); + } + #endif /* configENABLE_TRUSTZONE */ + + /* CP10 = 11 ==> Full access to FPU i.e. both privileged and + * unprivileged code should be able to access FPU. CP11 should be + * programmed to the same value as CP10. */ + *( portCPACR ) |= ( ( portCPACR_CP10_VALUE << portCPACR_CP10_POS ) | + ( portCPACR_CP11_VALUE << portCPACR_CP11_POS ) + ); + + /* ASPEN = 1 ==> Hardware should automatically preserve floating point + * context on exception entry and restore on exception return. + * LSPEN = 1 ==> Enable lazy context save of FP state. */ + *( portFPCCR ) |= ( portFPCCR_ASPEN_MASK | portFPCCR_LSPEN_MASK ); + } +#endif /* configENABLE_FPU */ +/*-----------------------------------------------------------*/ + +void vPortYield( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Set a PendSV to request a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + portDISABLE_INTERRUPTS(); + ulCriticalNesting++; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + configASSERT( ulCriticalNesting ); + ulCriticalNesting--; + + if( ulCriticalNesting == 0 ) + { + portENABLE_INTERRUPTS(); + } +} +/*-----------------------------------------------------------*/ + +void SysTick_Handler( void ) /* PRIVILEGED_FUNCTION */ +{ +uint32_t ulPreviousMask; + + ulPreviousMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* Increment the RTOS tick. */ + if( xTaskIncrementTick() != pdFALSE ) + { + /* Pend a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulPreviousMask ); +} +/*-----------------------------------------------------------*/ + +void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) /* PRIVILEGED_FUNCTION portDONT_DISCARD */ +{ +#if( configENABLE_MPU == 1 ) + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ +#endif /* configENABLE_MPU */ + +uint32_t ulPC; + +#if( configENABLE_TRUSTZONE == 1 ) + uint32_t ulR0; + #if( configENABLE_MPU == 1 ) + uint32_t ulControl, ulIsTaskPrivileged; + #endif /* configENABLE_MPU */ +#endif /* configENABLE_TRUSTZONE */ +uint8_t ucSVCNumber; + + /* Register are stored on the stack in the following order - R0, R1, R2, R3, + * R12, LR, PC, xPSR. */ + ulPC = pulCallerStackAddress[ 6 ]; + ucSVCNumber = ( ( uint8_t *) ulPC )[ -2 ]; + + switch( ucSVCNumber ) + { + #if( configENABLE_TRUSTZONE == 1 ) + case portSVC_ALLOCATE_SECURE_CONTEXT: + { + /* R0 contains the stack size passed as parameter to the + * vPortAllocateSecureContext function. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + #if( configENABLE_MPU == 1 ) + { + /* Read the CONTROL register value. */ + __asm volatile ( "mrs %0, control" : "=r" ( ulControl ) ); + + /* The task that raised the SVC is privileged if Bit[0] + * in the CONTROL register is 0. */ + ulIsTaskPrivileged = ( ( ulControl & portCONTROL_PRIVILEGED_MASK ) == 0 ); + + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0, ulIsTaskPrivileged ); + } + #else + { + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0 ); + } + #endif /* configENABLE_MPU */ + + configASSERT( xSecureContext != NULL ); + SecureContext_LoadContext( xSecureContext ); + } + break; + + case portSVC_FREE_SECURE_CONTEXT: + { + /* R0 contains the secure context handle to be freed. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + /* Free the secure context. */ + SecureContext_FreeContext( ( SecureContextHandle_t ) ulR0 ); + } + break; + #endif /* configENABLE_TRUSTZONE */ + + case portSVC_START_SCHEDULER: + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* De-prioritize the non-secure exceptions so that the + * non-secure pendSV runs at the lowest priority. */ + SecureInit_DePrioritizeNSExceptions(); + + /* Initialize the secure context management system. */ + SecureContext_Init(); + } + #endif /* configENABLE_TRUSTZONE */ + + #if( configENABLE_FPU == 1 ) + { + /* Setup the Floating Point Unit (FPU). */ + prvSetupFPU(); + } + #endif /* configENABLE_FPU */ + + /* Setup the context of the first task so that the first task starts + * executing. */ + vRestoreContextOfFirstTask(); + } + break; + + #if( configENABLE_MPU == 1 ) + case portSVC_RAISE_PRIVILEGE: + { + /* Only raise the privilege, if the svc was raised from any of + * the system calls. */ + if( ulPC >= ( uint32_t ) __syscalls_flash_start__ && + ulPC <= ( uint32_t ) __syscalls_flash_end__ ) + { + vRaisePrivilege(); + } + } + break; + #endif /* configENABLE_MPU */ + + default: + { + /* Incorrect SVC call. */ + configASSERT( pdFALSE ); + } + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) /* PRIVILEGED_FUNCTION */ +#else + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) /* PRIVILEGED_FUNCTION */ +#endif /* configENABLE_MPU */ +{ + /* Simulate the stack frame as it would be created by a context switch + * interrupt. */ + #if( portPRELOAD_REGISTERS == 0 ) + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack -= 9; /* R11..R4, EXC_RETURN. */ + *pxTopOfStack = portINITIAL_EXC_RETURN; + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #else /* portPRELOAD_REGISTERS */ + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x12121212UL; /* R12 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x03030303UL; /* R3 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x02020202UL; /* R2 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x01010101UL; /* R1 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x11111111UL; /* R11 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x10101010UL; /* R10 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x09090909UL; /* R09 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x08080808UL; /* R08 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x07070707UL; /* R07 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x06060606UL; /* R06 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x05050505UL; /* R05 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x04040404UL; /* R04 */ + pxTopOfStack--; + *pxTopOfStack = portINITIAL_EXC_RETURN; /* EXC_RETURN */ + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #endif /* portPRELOAD_REGISTERS */ + + return pxTopOfStack; +} +/*-----------------------------------------------------------*/ + +BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + *( portNVIC_SYSPRI2 ) |= portNVIC_PENDSV_PRI; + *( portNVIC_SYSPRI2 ) |= portNVIC_SYSTICK_PRI; + + #if( configENABLE_MPU == 1 ) + { + /* Setup the Memory Protection Unit (MPU). */ + prvSetupMPU(); + } + #endif /* configENABLE_MPU */ + + /* Start the timer that generates the tick ISR. Interrupts are disabled + * here already. */ + prvSetupTimerInterrupt(); + + /* Initialize the critical nesting count ready for the first task. */ + ulCriticalNesting = 0; + + /* Start the first task. */ + vStartFirstTask(); + + /* Should never get here as the tasks will now be executing. Call the task + * exit error function to prevent compiler warnings about a static function + * not being called in the case that the application writer overrides this + * functionality by defining configTASK_RETURN_ADDRESS. Call + * vTaskSwitchContext() so link time optimization does not remove the + * symbol. */ + vTaskSwitchContext(); + prvTaskExitError(); + + /* Should not get here. */ + return 0; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Not implemented in ports where there is nothing to return to. + * Artificially force an assert. */ + configASSERT( ulCriticalNesting == 1000UL ); +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) + { + uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber; + int32_t lIndex = 0; + + /* Setup MAIR0. */ + xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + xMPUSettings->ulMAIR0 |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* This function is called automatically when the task is created - in + * which case the stack region parameters will be valid. At all other + * times the stack parameters will not be valid and it is assumed that + * the stack region has already been configured. */ + if( ulStackDepth > 0 ) + { + /* Define the region that allows access to the stack. */ + ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + + xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + } + + /* User supplied configurable regions. */ + for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ ) + { + /* If xRegions is NULL i.e. the task has not specified any MPU + * region, the else part ensures that all the configurable MPU + * regions are invalidated. */ + if( ( xRegions != NULL ) && ( xRegions[ lIndex ].ulLengthInBytes > 0UL ) ) + { + /* Translate the generic region definition contained in xRegions + * into the ARMv8 specific MPU settings that are then stored in + * xMPUSettings. */ + ulRegionStartAddress = ( ( uint32_t ) xRegions[ lIndex ].pvBaseAddress ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) xRegions[ lIndex ].pvBaseAddress + xRegions[ lIndex ].ulLengthInBytes - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + /* Start address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ); + + /* RO/RW. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_READ_ONLY ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_ONLY ); + } + else + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_WRITE ); + } + + /* XN. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_EXECUTE_NEVER ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_EXECUTE_NEVER ); + } + + /* End Address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Normal memory/ Device memory. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_DEVICE_MEMORY ) != 0 ) + { + /* Attr1 in MAIR0 is configured as device memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX1; + } + else + { + /* Attr1 in MAIR0 is configured as normal memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX0; + } + } + else + { + /* Invalidate the region. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = 0UL; + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = 0UL; + } + + lIndex++; + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23_NTZ/non_secure/portasm.h b/FreeRTOS/Source/portable/IAR/ARM_CM23_NTZ/non_secure/portasm.h new file mode 100755 index 0000000..2ecf04e --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23_NTZ/non_secure/portasm.h @@ -0,0 +1,113 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __PORT_ASM_H__ +#define __PORT_ASM_H__ + +/* Scheduler includes. */ +#include "FreeRTOS.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/** + * @brief Restore the context of the first task so that the first task starts + * executing. + */ +void vRestoreContextOfFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +BaseType_t xIsPrivileged( void ) __attribute__ (( naked )); + +/** + * @brief Raises the privilege level by clearing the bit 0 of the CONTROL + * register. + * + * @note This is a privileged function and should only be called from the kenrel + * code. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vRaisePrivilege( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vResetPrivilege( void ) __attribute__ (( naked )); + +/** + * @brief Starts the first task. + */ +void vStartFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Disables interrupts. + */ +uint32_t ulSetInterruptMaskFromISR( void ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Enables interrupts. + */ +void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief PendSV Exception handler. + */ +void PendSV_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief SVC Handler. + */ +void SVC_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Allocate a Secure context for the calling task. + * + * @param[in] ulSecureStackSize The size of the stack to be allocated on the + * secure side for the calling task. + */ +void vPortAllocateSecureContext( uint32_t ulSecureStackSize ) __attribute__ (( naked )); + +/** + * @brief Free the task's secure context. + * + * @param[in] pulTCB Pointer to the Task Control Block (TCB) of the task. + */ +void vPortFreeSecureContext( uint32_t *pulTCB ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +#endif /* __PORT_ASM_H__ */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23_NTZ/non_secure/portasm.s b/FreeRTOS/Source/portable/IAR/ARM_CM23_NTZ/non_secure/portasm.s new file mode 100755 index 0000000..3121df6 --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23_NTZ/non_secure/portasm.s @@ -0,0 +1,303 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + EXTERN pxCurrentTCB + EXTERN vTaskSwitchContext + EXTERN vPortSVCHandler_C + + PUBLIC xIsPrivileged + PUBLIC vResetPrivilege + PUBLIC vRestoreContextOfFirstTask + PUBLIC vRaisePrivilege + PUBLIC vStartFirstTask + PUBLIC ulSetInterruptMaskFromISR + PUBLIC vClearInterruptMaskFromISR + PUBLIC PendSV_Handler + PUBLIC SVC_Handler + +#if ( configENABLE_FPU == 1 ) + #error Cortex-M23 does not have a Floating Point Unit (FPU) and therefore configENABLE_FPU must be set to 0. +#endif +/*-----------------------------------------------------------*/ + +/*---------------- Unprivileged Functions -------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION .text:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +xIsPrivileged: + mrs r0, control /* r0 = CONTROL. */ + movs r1, #1 /* r1 = 1. */ + tst r0, r1 /* Perform r0 & r1 (bitwise AND) and update the conditions flag. */ + beq running_privileged /* If the result of previous AND operation was 0, branch. */ + movs r0, #0 /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + bx lr /* Return. */ + running_privileged: + movs r0, #1 /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + bx lr /* Return. */ + +/*-----------------------------------------------------------*/ + +vResetPrivilege: + mrs r0, control /* r0 = CONTROL. */ + movs r1, #1 /* r1 = 1. */ + orrs r0, r1 /* r0 = r0 | r1. */ + msr control, r0 /* CONTROL = r0. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +/*----------------- Privileged Functions --------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION privileged_functions:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +vRestoreContextOfFirstTask: + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r1, [r2] /* Read pxCurrentTCB. */ + ldr r0, [r1] /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + +#if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r3, [r2] /* Read the value of MPU_CTRL. */ + movs r4, #1 /* r4 = 1. */ + bics r3, r4 /* r3 = r3 & ~r4 i.e. Clear the bit 0 in r3. */ + str r3, [r2] /* Disable MPU. */ + + adds r1, #4 /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + ldr r4, [r1] /* r4 = *r1 i.e. r4 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r4, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + adds r1, #4 /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + movs r4, #4 /* r4 = 4. */ + str r4, [r2] /* Program RNR = 4. */ + ldmia r1!, {r5,r6} /* Read first set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write first set of RBAR/RLAR registers. */ + movs r4, #5 /* r4 = 5. */ + str r4, [r2] /* Program RNR = 5. */ + ldmia r1!, {r5,r6} /* Read second set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write second set of RBAR/RLAR registers. */ + movs r4, #6 /* r4 = 6. */ + str r4, [r2] /* Program RNR = 6. */ + ldmia r1!, {r5,r6} /* Read third set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write third set of RBAR/RLAR registers. */ + movs r4, #7 /* r4 = 7. */ + str r4, [r2] /* Program RNR = 7. */ + ldmia r1!, {r5,r6} /* Read fourth set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write fourth set of RBAR/RLAR registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r3, [r2] /* Read the value of MPU_CTRL. */ + movs r4, #1 /* r4 = 1. */ + orrs r3, r4 /* r3 = r3 | r4 i.e. Set the bit 0 in r3. */ + str r3, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ +#endif /* configENABLE_MPU */ + +#if ( configENABLE_MPU == 1 ) + ldm r0!, {r1-r3} /* Read from stack - r1 = PSPLIM, r2 = CONTROL and r3 = EXC_RETURN. */ + msr psplim, r1 /* Set this task's PSPLIM value. */ + msr control, r2 /* Set this task's CONTROL value. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r3 /* Finally, branch to EXC_RETURN. */ +#else /* configENABLE_MPU */ + ldm r0!, {r1-r2} /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ + msr psplim, r1 /* Set this task's PSPLIM value. */ + movs r1, #2 /* r1 = 2. */ + msr CONTROL, r1 /* Switch to use PSP in the thread mode. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r2 /* Finally, branch to EXC_RETURN. */ +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +vRaisePrivilege: + mrs r0, control /* Read the CONTROL register. */ + movs r1, #1 /* r1 = 1. */ + bics r0, r1 /* Clear the bit 0. */ + msr control, r0 /* Write back the new CONTROL value. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +vStartFirstTask: + ldr r0, =0xe000ed08 /* Use the NVIC offset register to locate the stack. */ + ldr r0, [r0] /* Read the VTOR register which gives the address of vector table. */ + ldr r0, [r0] /* The first entry in vector table is stack pointer. */ + msr msp, r0 /* Set the MSP back to the start of the stack. */ + cpsie i /* Globally enable interrupts. */ + dsb + isb + svc 2 /* System call to start the first task. portSVC_START_SCHEDULER = 2. */ + nop +/*-----------------------------------------------------------*/ + +ulSetInterruptMaskFromISR: + mrs r0, PRIMASK + cpsid i + bx lr +/*-----------------------------------------------------------*/ + +vClearInterruptMaskFromISR: + msr PRIMASK, r0 + bx lr +/*-----------------------------------------------------------*/ + +PendSV_Handler: + mrs r0, psp /* Read PSP in r0. */ + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r1, [r2] /* Read pxCurrentTCB. */ +#if ( configENABLE_MPU == 1 ) + subs r0, r0, #44 /* Make space for PSPLIM, CONTROL, LR and the remaining registers on the stack. */ + str r0, [r1] /* Save the new top of stack in TCB. */ + mrs r1, psplim /* r1 = PSPLIM. */ + mrs r2, control /* r2 = CONTROL. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + stmia r0!, {r1-r7} /* Store on the stack - PSPLIM, CONTROL, LR and low registers that are not automatically saved. */ + mov r4, r8 /* r4 = r8. */ + mov r5, r9 /* r5 = r9. */ + mov r6, r10 /* r6 = r10. */ + mov r7, r11 /* r7 = r11. */ + stmia r0!, {r4-r7} /* Store the high registers that are not saved automatically. */ +#else /* configENABLE_MPU */ + subs r0, r0, #40 /* Make space for PSPLIM, LR and the remaining registers on the stack. */ + str r0, [r1] /* Save the new top of stack in TCB. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + stmia r0!, {r2-r7} /* Store on the stack - PSPLIM, LR and low registers that are not automatically saved. */ + mov r4, r8 /* r4 = r8. */ + mov r5, r9 /* r5 = r9. */ + mov r6, r10 /* r6 = r10. */ + mov r7, r11 /* r7 = r11. */ + stmia r0!, {r4-r7} /* Store the high registers that are not saved automatically. */ +#endif /* configENABLE_MPU */ + + cpsid i + bl vTaskSwitchContext + cpsie i + + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r1, [r2] /* Read pxCurrentTCB. */ + ldr r0, [r1] /* The first item in pxCurrentTCB is the task top of stack. r0 now points to the top of stack. */ + +#if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r3, [r2] /* Read the value of MPU_CTRL. */ + movs r4, #1 /* r4 = 1. */ + bics r3, r4 /* r3 = r3 & ~r4 i.e. Clear the bit 0 in r3. */ + str r3, [r2] /* Disable MPU. */ + + adds r1, #4 /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + ldr r4, [r1] /* r4 = *r1 i.e. r4 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r4, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + adds r1, #4 /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + movs r4, #4 /* r4 = 4. */ + str r4, [r2] /* Program RNR = 4. */ + ldmia r1!, {r5,r6} /* Read first set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write first set of RBAR/RLAR registers. */ + movs r4, #5 /* r4 = 5. */ + str r4, [r2] /* Program RNR = 5. */ + ldmia r1!, {r5,r6} /* Read second set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write second set of RBAR/RLAR registers. */ + movs r4, #6 /* r4 = 6. */ + str r4, [r2] /* Program RNR = 6. */ + ldmia r1!, {r5,r6} /* Read third set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write third set of RBAR/RLAR registers. */ + movs r4, #7 /* r4 = 7. */ + str r4, [r2] /* Program RNR = 7. */ + ldmia r1!, {r5,r6} /* Read fourth set of RBAR/RLAR from TCB. */ + ldr r3, =0xe000ed9c /* r3 = 0xe000ed9c [Location of RBAR]. */ + stmia r3!, {r5,r6} /* Write fourth set of RBAR/RLAR registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r3, [r2] /* Read the value of MPU_CTRL. */ + movs r4, #1 /* r4 = 1. */ + orrs r3, r4 /* r3 = r3 | r4 i.e. Set the bit 0 in r3. */ + str r3, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ +#endif /* configENABLE_MPU */ + +#if ( configENABLE_MPU == 1 ) + adds r0, r0, #28 /* Move to the high registers. */ + ldmia r0!, {r4-r7} /* Restore the high registers that are not automatically restored. */ + mov r8, r4 /* r8 = r4. */ + mov r9, r5 /* r9 = r5. */ + mov r10, r6 /* r10 = r6. */ + mov r11, r7 /* r11 = r7. */ + msr psp, r0 /* Remember the new top of stack for the task. */ + subs r0, r0, #44 /* Move to the starting of the saved context. */ + ldmia r0!, {r1-r7} /* Read from stack - r1 = PSPLIM, r2 = CONTROL, r3 = LR and r4-r7 restored. */ + msr psplim, r1 /* Restore the PSPLIM register value for the task. */ + msr control, r2 /* Restore the CONTROL register value for the task. */ + bx r3 +#else /* configENABLE_MPU */ + adds r0, r0, #24 /* Move to the high registers. */ + ldmia r0!, {r4-r7} /* Restore the high registers that are not automatically restored. */ + mov r8, r4 /* r8 = r4. */ + mov r9, r5 /* r9 = r5. */ + mov r10, r6 /* r10 = r6. */ + mov r11, r7 /* r11 = r7. */ + msr psp, r0 /* Remember the new top of stack for the task. */ + subs r0, r0, #40 /* Move to the starting of the saved context. */ + ldmia r0!, {r2-r7} /* Read from stack - r2 = PSPLIM, r3 = LR and r4-r7 restored. */ + msr psplim, r2 /* Restore the PSPLIM register value for the task. */ + bx r3 +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +SVC_Handler: + movs r0, #4 + mov r1, lr + tst r0, r1 + beq stacking_used_msp + mrs r0, psp + b vPortSVCHandler_C + stacking_used_msp: + mrs r0, msp + b vPortSVCHandler_C +/*-----------------------------------------------------------*/ + + END diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM23_NTZ/non_secure/portmacro.h b/FreeRTOS/Source/portable/IAR/ARM_CM23_NTZ/non_secure/portmacro.h new file mode 100755 index 0000000..48b0e0b --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM23_NTZ/non_secure/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M23" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __root +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM3/port.c b/FreeRTOS/Source/portable/IAR/ARM_CM3/port.c index 8272c53..bdbfdb7 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM3/port.c +++ b/FreeRTOS/Source/portable/IAR/ARM_CM3/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM3/portasm.s b/FreeRTOS/Source/portable/IAR/ARM_CM3/portasm.s index 8f8c295..fbc278a 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM3/portasm.s +++ b/FreeRTOS/Source/portable/IAR/ARM_CM3/portasm.s @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM3/portmacro.h b/FreeRTOS/Source/portable/IAR/ARM_CM3/portmacro.h index 7bffe3e..1d69069 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM3/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/ARM_CM3/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33/non_secure/port.c b/FreeRTOS/Source/portable/IAR/ARM_CM33/non_secure/port.c new file mode 100755 index 0000000..bd85a6f --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33/non_secure/port.c @@ -0,0 +1,899 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/* Portasm includes. */ +#include "portasm.h" + +#if( configENABLE_TRUSTZONE == 1 ) + /* Secure components includes. */ + #include "secure_context.h" + #include "secure_init.h" +#endif /* configENABLE_TRUSTZONE */ + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/** + * The FreeRTOS Cortex M33 port can be configured to run on the Secure Side only + * i.e. the processor boots as secure and never jumps to the non-secure side. + * The Trust Zone support in the port must be disabled in order to run FreeRTOS + * on the secure side. The following are the valid configuration seetings: + * + * 1. Run FreeRTOS on the Secure Side: + * configRUN_FREERTOS_SECURE_ONLY = 1 and configENABLE_TRUSTZONE = 0 + * + * 2. Run FreeRTOS on the Non-Secure Side with Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 1 + * + * 3. Run FreeRTOS on the Non-Secure Side only i.e. no Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 0 + */ +#if( ( configRUN_FREERTOS_SECURE_ONLY == 1 ) && ( configENABLE_TRUSTZONE == 1 ) ) + #error TrustZone needs to be disabled in order to run FreeRTOS on the Secure Side. +#endif +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the NVIC. + */ +#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t * ) 0xe000e010 ) +#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t * ) 0xe000e014 ) +#define portNVIC_SYSTICK_CURRENT_VALUE ( ( volatile uint32_t * ) 0xe000e018 ) +#define portNVIC_INT_CTRL ( ( volatile uint32_t * ) 0xe000ed04 ) +#define portNVIC_SYSPRI2 ( ( volatile uint32_t * ) 0xe000ed20 ) +#define portNVIC_SYSTICK_CLK ( 0x00000004 ) +#define portNVIC_SYSTICK_INT ( 0x00000002 ) +#define portNVIC_SYSTICK_ENABLE ( 0x00000001 ) +#define portNVIC_PENDSVSET ( 0x10000000 ) +#define portMIN_INTERRUPT_PRIORITY ( 255UL ) +#define portNVIC_PENDSV_PRI ( portMIN_INTERRUPT_PRIORITY << 16UL ) +#define portNVIC_SYSTICK_PRI ( portMIN_INTERRUPT_PRIORITY << 24UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the SCB. + */ +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( * ( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_MEM_FAULT_ENABLE ( 1UL << 16UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the FPU. + */ +#define portCPACR ( ( volatile uint32_t * ) 0xe000ed88 ) /* Coprocessor Access Control Register. */ +#define portCPACR_CP10_VALUE ( 3UL ) +#define portCPACR_CP11_VALUE portCPACR_CP10_VALUE +#define portCPACR_CP10_POS ( 20UL ) +#define portCPACR_CP11_POS ( 22UL ) + +#define portFPCCR ( ( volatile uint32_t * ) 0xe000ef34 ) /* Floating Point Context Control Register. */ +#define portFPCCR_ASPEN_POS ( 31UL ) +#define portFPCCR_ASPEN_MASK ( 1UL << portFPCCR_ASPEN_POS ) +#define portFPCCR_LSPEN_POS ( 30UL ) +#define portFPCCR_LSPEN_MASK ( 1UL << portFPCCR_LSPEN_POS ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the MPU. + */ +#define portMPU_TYPE_REG ( * ( ( volatile uint32_t * ) 0xe000ed90 ) ) +#define portMPU_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed94 ) ) +#define portMPU_RNR_REG ( * ( ( volatile uint32_t * ) 0xe000ed98 ) ) + +#define portMPU_RBAR_REG ( * ( ( volatile uint32_t * ) 0xe000ed9c ) ) +#define portMPU_RLAR_REG ( * ( ( volatile uint32_t * ) 0xe000eda0 ) ) + +#define portMPU_RBAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda4 ) ) +#define portMPU_RLAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda8 ) ) + +#define portMPU_RBAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edac ) ) +#define portMPU_RLAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edb0 ) ) + +#define portMPU_RBAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb4 ) ) +#define portMPU_RLAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb8 ) ) + +#define portMPU_MAIR0_REG ( * ( ( volatile uint32_t * ) 0xe000edc0 ) ) +#define portMPU_MAIR1_REG ( * ( ( volatile uint32_t * ) 0xe000edc4 ) ) + +#define portMPU_RBAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ +#define portMPU_RLAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ + +#define portMPU_MAIR_ATTR0_POS ( 0UL ) +#define portMPU_MAIR_ATTR0_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR1_POS ( 8UL ) +#define portMPU_MAIR_ATTR1_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR2_POS ( 16UL ) +#define portMPU_MAIR_ATTR2_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR3_POS ( 24UL ) +#define portMPU_MAIR_ATTR3_MASK ( 0xff000000 ) + +#define portMPU_MAIR_ATTR4_POS ( 0UL ) +#define portMPU_MAIR_ATTR4_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR5_POS ( 8UL ) +#define portMPU_MAIR_ATTR5_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR6_POS ( 16UL ) +#define portMPU_MAIR_ATTR6_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR7_POS ( 24UL ) +#define portMPU_MAIR_ATTR7_MASK ( 0xff000000 ) + +#define portMPU_RLAR_ATTR_INDEX0 ( 0UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX1 ( 1UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX2 ( 2UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX3 ( 3UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX4 ( 4UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX5 ( 5UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX6 ( 6UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX7 ( 7UL << 1UL ) + +#define portMPU_RLAR_REGION_ENABLE ( 1UL ) + +/* Enable privileged access to unmapped region. */ +#define portMPU_PRIV_BACKGROUND_ENABLE ( 1UL << 2UL ) + +/* Enable MPU. */ +#define portMPU_ENABLE ( 1UL << 0UL ) + +/* Expected value of the portMPU_TYPE register. */ +#define portEXPECTED_MPU_TYPE_VALUE ( 8UL << 8UL ) /* 8 regions, unified. */ +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to set up the initial stack. + */ +#define portINITIAL_XPSR ( 0x01000000 ) + +#if( configRUN_FREERTOS_SECURE_ONLY == 1 ) + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF FD + * 1111 1111 1111 1111 1111 1111 1111 1101 + * + * Bit[6] - 1 --> The exception was taken from the Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 1 --> The exception was taken to the Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xfffffffd ) +#else + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF BC + * 1111 1111 1111 1111 1111 1111 1011 1100 + * + * Bit[6] - 0 --> The exception was taken from the Non-Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 0 --> The exception was taken to the Non-Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xffffffbc ) +#endif /* configRUN_FREERTOS_SECURE_ONLY */ + +/** + * @brief CONTROL register privileged bit mask. + * + * Bit[0] in CONTROL register tells the privilege: + * Bit[0] = 0 ==> The task is privileged. + * Bit[0] = 1 ==> The task is not privileged. + */ +#define portCONTROL_PRIVILEGED_MASK ( 1UL << 0UL ) + +/** + * @brief Initial CONTROL register values. + */ +#define portINITIAL_CONTROL_UNPRIVILEGED ( 0x3 ) +#define portINITIAL_CONTROL_PRIVILEGED ( 0x2 ) + +/** + * @brief Let the user override the pre-loading of the initial LR with the + * address of prvTaskExitError() in case it messes up unwinding of the stack + * in the debugger. + */ +#ifdef configTASK_RETURN_ADDRESS + #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS +#else + #define portTASK_RETURN_ADDRESS prvTaskExitError +#endif + +/** + * @brief If portPRELOAD_REGISTERS then registers will be given an initial value + * when a task is created. This helps in debugging at the cost of code size. + */ +#define portPRELOAD_REGISTERS 1 + +/** + * @brief A task is created without a secure context, and must call + * portALLOCATE_SECURE_CONTEXT() to give itself a secure context before it makes + * any secure calls. + */ +#define portNO_SECURE_CONTEXT 0 +/*-----------------------------------------------------------*/ + +/** + * @brief Setup the timer to generate the tick interrupts. + */ +static void prvSetupTimerInterrupt( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Used to catch tasks that attempt to return from their implementing + * function. + */ +static void prvTaskExitError( void ); + +#if( configENABLE_MPU == 1 ) + /** + * @brief Setup the Memory Protection Unit (MPU). + */ + static void prvSetupMPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_MPU */ + +#if( configENABLE_FPU == 1 ) + /** + * @brief Setup the Floating Point Unit (FPU). + */ + static void prvSetupFPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_FPU */ + +/** + * @brief Yield the processor. + */ +void vPortYield( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Enter critical section. + */ +void vPortEnterCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Exit from critical section. + */ +void vPortExitCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief SysTick handler. + */ +void SysTick_Handler( void ) PRIVILEGED_FUNCTION; + +/** + * @brief C part of SVC handler. + */ +portDONT_DISCARD void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) PRIVILEGED_FUNCTION; +/*-----------------------------------------------------------*/ + +/** + * @brief Each task maintains its own interrupt status in the critical nesting + * variable. + */ +static volatile uint32_t ulCriticalNesting = 0xaaaaaaaaUL; + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Saved as part of the task context to indicate which context the + * task is using on the secure side. + */ + portDONT_DISCARD volatile SecureContextHandle_t xSecureContext = portNO_SECURE_CONTEXT; +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +static void prvSetupTimerInterrupt( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Stop and reset the SysTick. */ + *( portNVIC_SYSTICK_CTRL ) = 0UL; + *( portNVIC_SYSTICK_CURRENT_VALUE ) = 0UL; + + /* Configure SysTick to interrupt at the requested rate. */ + *( portNVIC_SYSTICK_LOAD ) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; + *( portNVIC_SYSTICK_CTRL ) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE; +} +/*-----------------------------------------------------------*/ + +static void prvTaskExitError( void ) +{ +volatile uint32_t ulDummy = 0UL; + + /* A function that implements a task must not exit or attempt to return to + * its caller as there is nothing to return to. If a task wants to exit it + * should instead call vTaskDelete( NULL ). Artificially force an assert() + * to be triggered if configASSERT() is defined, then stop here so + * application writers can catch the error. */ + configASSERT( ulCriticalNesting == ~0UL ); + portDISABLE_INTERRUPTS(); + + while( ulDummy == 0 ) + { + /* This file calls prvTaskExitError() after the scheduler has been + * started to remove a compiler warning about the function being + * defined but never called. ulDummy is used purely to quieten other + * warnings about code appearing after this function is called - making + * ulDummy volatile makes the compiler think the function could return + * and therefore not output an 'unreachable code' warning for code that + * appears after it. */ + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + static void prvSetupMPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __privileged_functions_start__; + extern uint32_t * __privileged_functions_end__; + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + extern uint32_t * __unprivileged_flash_start__; + extern uint32_t * __unprivileged_flash_end__; + extern uint32_t * __privileged_sram_start__; + extern uint32_t * __privileged_sram_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __privileged_functions_start__[]; + extern uint32_t __privileged_functions_end__[]; + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + extern uint32_t __unprivileged_flash_start__[]; + extern uint32_t __unprivileged_flash_end__[]; + extern uint32_t __privileged_sram_start__[]; + extern uint32_t __privileged_sram_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ + + /* Check that the MPU is present. */ + if( portMPU_TYPE_REG == portEXPECTED_MPU_TYPE_VALUE ) + { + /* MAIR0 - Index 0. */ + portMPU_MAIR0_REG |= ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + /* MAIR0 - Index 1. */ + portMPU_MAIR0_REG |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* Setup privileged flash as Read Only so that privileged tasks can + * read it but not modify. */ + portMPU_RNR_REG = portPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_functions_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_functions_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged flash as Read Only by both privileged and + * unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __unprivileged_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __unprivileged_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged syscalls flash as Read Only by both privileged + * and unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_SYSCALLS_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __syscalls_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __syscalls_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup RAM containing kernel data for privileged access only. */ + portMPU_RNR_REG = portPRIVILEGED_RAM_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_sram_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_sram_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Enable mem fault. */ + portSCB_SYS_HANDLER_CTRL_STATE_REG |= portSCB_MEM_FAULT_ENABLE; + + /* Enable MPU with privileged background access i.e. unmapped + * regions have privileged access. */ + portMPU_CTRL_REG |= ( portMPU_PRIV_BACKGROUND_ENABLE | portMPU_ENABLE ); + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_FPU == 1 ) + static void prvSetupFPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* Enable non-secure access to the FPU. */ + SecureInit_EnableNSFPUAccess(); + } + #endif /* configENABLE_TRUSTZONE */ + + /* CP10 = 11 ==> Full access to FPU i.e. both privileged and + * unprivileged code should be able to access FPU. CP11 should be + * programmed to the same value as CP10. */ + *( portCPACR ) |= ( ( portCPACR_CP10_VALUE << portCPACR_CP10_POS ) | + ( portCPACR_CP11_VALUE << portCPACR_CP11_POS ) + ); + + /* ASPEN = 1 ==> Hardware should automatically preserve floating point + * context on exception entry and restore on exception return. + * LSPEN = 1 ==> Enable lazy context save of FP state. */ + *( portFPCCR ) |= ( portFPCCR_ASPEN_MASK | portFPCCR_LSPEN_MASK ); + } +#endif /* configENABLE_FPU */ +/*-----------------------------------------------------------*/ + +void vPortYield( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Set a PendSV to request a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + portDISABLE_INTERRUPTS(); + ulCriticalNesting++; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + configASSERT( ulCriticalNesting ); + ulCriticalNesting--; + + if( ulCriticalNesting == 0 ) + { + portENABLE_INTERRUPTS(); + } +} +/*-----------------------------------------------------------*/ + +void SysTick_Handler( void ) /* PRIVILEGED_FUNCTION */ +{ +uint32_t ulPreviousMask; + + ulPreviousMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* Increment the RTOS tick. */ + if( xTaskIncrementTick() != pdFALSE ) + { + /* Pend a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulPreviousMask ); +} +/*-----------------------------------------------------------*/ + +void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) /* PRIVILEGED_FUNCTION portDONT_DISCARD */ +{ +#if( configENABLE_MPU == 1 ) + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ +#endif /* configENABLE_MPU */ + +uint32_t ulPC; + +#if( configENABLE_TRUSTZONE == 1 ) + uint32_t ulR0; + #if( configENABLE_MPU == 1 ) + uint32_t ulControl, ulIsTaskPrivileged; + #endif /* configENABLE_MPU */ +#endif /* configENABLE_TRUSTZONE */ +uint8_t ucSVCNumber; + + /* Register are stored on the stack in the following order - R0, R1, R2, R3, + * R12, LR, PC, xPSR. */ + ulPC = pulCallerStackAddress[ 6 ]; + ucSVCNumber = ( ( uint8_t *) ulPC )[ -2 ]; + + switch( ucSVCNumber ) + { + #if( configENABLE_TRUSTZONE == 1 ) + case portSVC_ALLOCATE_SECURE_CONTEXT: + { + /* R0 contains the stack size passed as parameter to the + * vPortAllocateSecureContext function. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + #if( configENABLE_MPU == 1 ) + { + /* Read the CONTROL register value. */ + __asm volatile ( "mrs %0, control" : "=r" ( ulControl ) ); + + /* The task that raised the SVC is privileged if Bit[0] + * in the CONTROL register is 0. */ + ulIsTaskPrivileged = ( ( ulControl & portCONTROL_PRIVILEGED_MASK ) == 0 ); + + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0, ulIsTaskPrivileged ); + } + #else + { + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0 ); + } + #endif /* configENABLE_MPU */ + + configASSERT( xSecureContext != NULL ); + SecureContext_LoadContext( xSecureContext ); + } + break; + + case portSVC_FREE_SECURE_CONTEXT: + { + /* R0 contains the secure context handle to be freed. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + /* Free the secure context. */ + SecureContext_FreeContext( ( SecureContextHandle_t ) ulR0 ); + } + break; + #endif /* configENABLE_TRUSTZONE */ + + case portSVC_START_SCHEDULER: + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* De-prioritize the non-secure exceptions so that the + * non-secure pendSV runs at the lowest priority. */ + SecureInit_DePrioritizeNSExceptions(); + + /* Initialize the secure context management system. */ + SecureContext_Init(); + } + #endif /* configENABLE_TRUSTZONE */ + + #if( configENABLE_FPU == 1 ) + { + /* Setup the Floating Point Unit (FPU). */ + prvSetupFPU(); + } + #endif /* configENABLE_FPU */ + + /* Setup the context of the first task so that the first task starts + * executing. */ + vRestoreContextOfFirstTask(); + } + break; + + #if( configENABLE_MPU == 1 ) + case portSVC_RAISE_PRIVILEGE: + { + /* Only raise the privilege, if the svc was raised from any of + * the system calls. */ + if( ulPC >= ( uint32_t ) __syscalls_flash_start__ && + ulPC <= ( uint32_t ) __syscalls_flash_end__ ) + { + vRaisePrivilege(); + } + } + break; + #endif /* configENABLE_MPU */ + + default: + { + /* Incorrect SVC call. */ + configASSERT( pdFALSE ); + } + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) /* PRIVILEGED_FUNCTION */ +#else + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) /* PRIVILEGED_FUNCTION */ +#endif /* configENABLE_MPU */ +{ + /* Simulate the stack frame as it would be created by a context switch + * interrupt. */ + #if( portPRELOAD_REGISTERS == 0 ) + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack -= 9; /* R11..R4, EXC_RETURN. */ + *pxTopOfStack = portINITIAL_EXC_RETURN; + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #else /* portPRELOAD_REGISTERS */ + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x12121212UL; /* R12 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x03030303UL; /* R3 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x02020202UL; /* R2 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x01010101UL; /* R1 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x11111111UL; /* R11 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x10101010UL; /* R10 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x09090909UL; /* R09 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x08080808UL; /* R08 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x07070707UL; /* R07 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x06060606UL; /* R06 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x05050505UL; /* R05 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x04040404UL; /* R04 */ + pxTopOfStack--; + *pxTopOfStack = portINITIAL_EXC_RETURN; /* EXC_RETURN */ + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #endif /* portPRELOAD_REGISTERS */ + + return pxTopOfStack; +} +/*-----------------------------------------------------------*/ + +BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + *( portNVIC_SYSPRI2 ) |= portNVIC_PENDSV_PRI; + *( portNVIC_SYSPRI2 ) |= portNVIC_SYSTICK_PRI; + + #if( configENABLE_MPU == 1 ) + { + /* Setup the Memory Protection Unit (MPU). */ + prvSetupMPU(); + } + #endif /* configENABLE_MPU */ + + /* Start the timer that generates the tick ISR. Interrupts are disabled + * here already. */ + prvSetupTimerInterrupt(); + + /* Initialize the critical nesting count ready for the first task. */ + ulCriticalNesting = 0; + + /* Start the first task. */ + vStartFirstTask(); + + /* Should never get here as the tasks will now be executing. Call the task + * exit error function to prevent compiler warnings about a static function + * not being called in the case that the application writer overrides this + * functionality by defining configTASK_RETURN_ADDRESS. Call + * vTaskSwitchContext() so link time optimization does not remove the + * symbol. */ + vTaskSwitchContext(); + prvTaskExitError(); + + /* Should not get here. */ + return 0; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Not implemented in ports where there is nothing to return to. + * Artificially force an assert. */ + configASSERT( ulCriticalNesting == 1000UL ); +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) + { + uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber; + int32_t lIndex = 0; + + /* Setup MAIR0. */ + xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + xMPUSettings->ulMAIR0 |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* This function is called automatically when the task is created - in + * which case the stack region parameters will be valid. At all other + * times the stack parameters will not be valid and it is assumed that + * the stack region has already been configured. */ + if( ulStackDepth > 0 ) + { + /* Define the region that allows access to the stack. */ + ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + + xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + } + + /* User supplied configurable regions. */ + for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ ) + { + /* If xRegions is NULL i.e. the task has not specified any MPU + * region, the else part ensures that all the configurable MPU + * regions are invalidated. */ + if( ( xRegions != NULL ) && ( xRegions[ lIndex ].ulLengthInBytes > 0UL ) ) + { + /* Translate the generic region definition contained in xRegions + * into the ARMv8 specific MPU settings that are then stored in + * xMPUSettings. */ + ulRegionStartAddress = ( ( uint32_t ) xRegions[ lIndex ].pvBaseAddress ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) xRegions[ lIndex ].pvBaseAddress + xRegions[ lIndex ].ulLengthInBytes - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + /* Start address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ); + + /* RO/RW. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_READ_ONLY ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_ONLY ); + } + else + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_WRITE ); + } + + /* XN. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_EXECUTE_NEVER ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_EXECUTE_NEVER ); + } + + /* End Address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Normal memory/ Device memory. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_DEVICE_MEMORY ) != 0 ) + { + /* Attr1 in MAIR0 is configured as device memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX1; + } + else + { + /* Attr1 in MAIR0 is configured as normal memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX0; + } + } + else + { + /* Invalidate the region. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = 0UL; + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = 0UL; + } + + lIndex++; + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33/non_secure/portasm.h b/FreeRTOS/Source/portable/IAR/ARM_CM33/non_secure/portasm.h new file mode 100755 index 0000000..2ecf04e --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33/non_secure/portasm.h @@ -0,0 +1,113 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __PORT_ASM_H__ +#define __PORT_ASM_H__ + +/* Scheduler includes. */ +#include "FreeRTOS.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/** + * @brief Restore the context of the first task so that the first task starts + * executing. + */ +void vRestoreContextOfFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +BaseType_t xIsPrivileged( void ) __attribute__ (( naked )); + +/** + * @brief Raises the privilege level by clearing the bit 0 of the CONTROL + * register. + * + * @note This is a privileged function and should only be called from the kenrel + * code. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vRaisePrivilege( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vResetPrivilege( void ) __attribute__ (( naked )); + +/** + * @brief Starts the first task. + */ +void vStartFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Disables interrupts. + */ +uint32_t ulSetInterruptMaskFromISR( void ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Enables interrupts. + */ +void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief PendSV Exception handler. + */ +void PendSV_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief SVC Handler. + */ +void SVC_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Allocate a Secure context for the calling task. + * + * @param[in] ulSecureStackSize The size of the stack to be allocated on the + * secure side for the calling task. + */ +void vPortAllocateSecureContext( uint32_t ulSecureStackSize ) __attribute__ (( naked )); + +/** + * @brief Free the task's secure context. + * + * @param[in] pulTCB Pointer to the Task Control Block (TCB) of the task. + */ +void vPortFreeSecureContext( uint32_t *pulTCB ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +#endif /* __PORT_ASM_H__ */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33/non_secure/portasm.s b/FreeRTOS/Source/portable/IAR/ARM_CM33/non_secure/portasm.s new file mode 100755 index 0000000..e38104c --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33/non_secure/portasm.s @@ -0,0 +1,326 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + EXTERN pxCurrentTCB + EXTERN xSecureContext + EXTERN vTaskSwitchContext + EXTERN vPortSVCHandler_C + EXTERN SecureContext_SaveContext + EXTERN SecureContext_LoadContext + + PUBLIC xIsPrivileged + PUBLIC vResetPrivilege + PUBLIC vPortAllocateSecureContext + PUBLIC vRestoreContextOfFirstTask + PUBLIC vRaisePrivilege + PUBLIC vStartFirstTask + PUBLIC ulSetInterruptMaskFromISR + PUBLIC vClearInterruptMaskFromISR + PUBLIC PendSV_Handler + PUBLIC SVC_Handler + PUBLIC vPortFreeSecureContext +/*-----------------------------------------------------------*/ + +/*---------------- Unprivileged Functions -------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION .text:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +xIsPrivileged: + mrs r0, control /* r0 = CONTROL. */ + tst r0, #1 /* Perform r0 & 1 (bitwise AND) and update the conditions flag. */ + ite ne + movne r0, #0 /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + moveq r0, #1 /* CONTROL[0]==0. Return true to indicate that the processor is not privileged. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ + +vResetPrivilege: + mrs r0, control /* r0 = CONTROL. */ + orr r0, r0, #1 /* r0 = r0 | 1. */ + msr control, r0 /* CONTROL = r0. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +vPortAllocateSecureContext: + svc 0 /* Secure context is allocated in the supervisor call. portSVC_ALLOCATE_SECURE_CONTEXT = 0. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ + +/*----------------- Privileged Functions --------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION privileged_functions:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +vRestoreContextOfFirstTask: + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r3, [r2] /* Read pxCurrentTCB. */ + ldr r0, [r3] /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + +#if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + bic r4, r4, #1 /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + str r4, [r2] /* Disable MPU. */ + + adds r3, #4 /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + ldr r4, [r3] /* r4 = *r3 i.e. r4 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r4, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + movs r4, #4 /* r4 = 4. */ + str r4, [r2] /* Program RNR = 4. */ + adds r3, #4 /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + ldr r2, =0xe000ed9c /* r2 = 0xe000ed9c [Location of RBAR]. */ + ldmia r3!, {r4-r11} /* Read 4 set of RBAR/RLAR registers from TCB. */ + stmia r2!, {r4-r11} /* Write 4 set of RBAR/RLAR registers using alias registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + orr r4, r4, #1 /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + str r4, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ +#endif /* configENABLE_MPU */ + +#if ( configENABLE_MPU == 1 ) + ldm r0!, {r1-r4} /* Read from stack - r1 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = EXC_RETURN. */ + ldr r5, =xSecureContext + str r1, [r5] /* Set xSecureContext to this task's value for the same. */ + msr psplim, r2 /* Set this task's PSPLIM value. */ + msr control, r3 /* Set this task's CONTROL value. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r4 /* Finally, branch to EXC_RETURN. */ +#else /* configENABLE_MPU */ + ldm r0!, {r1-r3} /* Read from stack - r1 = xSecureContext, r2 = PSPLIM and r3 = EXC_RETURN. */ + ldr r4, =xSecureContext + str r1, [r4] /* Set xSecureContext to this task's value for the same. */ + msr psplim, r2 /* Set this task's PSPLIM value. */ + movs r1, #2 /* r1 = 2. */ + msr CONTROL, r1 /* Switch to use PSP in the thread mode. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r3 /* Finally, branch to EXC_RETURN. */ +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +vRaisePrivilege: + mrs r0, control /* Read the CONTROL register. */ + bic r0, r0, #1 /* Clear the bit 0. */ + msr control, r0 /* Write back the new CONTROL value. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +vStartFirstTask: + ldr r0, =0xe000ed08 /* Use the NVIC offset register to locate the stack. */ + ldr r0, [r0] /* Read the VTOR register which gives the address of vector table. */ + ldr r0, [r0] /* The first entry in vector table is stack pointer. */ + msr msp, r0 /* Set the MSP back to the start of the stack. */ + cpsie i /* Globally enable interrupts. */ + cpsie f + dsb + isb + svc 2 /* System call to start the first task. portSVC_START_SCHEDULER = 2. */ +/*-----------------------------------------------------------*/ + +ulSetInterruptMaskFromISR: + mrs r0, PRIMASK + cpsid i + bx lr +/*-----------------------------------------------------------*/ + +vClearInterruptMaskFromISR: + msr PRIMASK, r0 + bx lr +/*-----------------------------------------------------------*/ + +PendSV_Handler: + mrs r1, psp /* Read PSP in r1. */ + ldr r2, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + ldr r0, [r2] /* Read xSecureContext - Value of xSecureContext must be in r0 as it is used as a parameter later. */ + + cbz r0, save_ns_context /* No secure context to save. */ + push {r0-r2, r14} + bl SecureContext_SaveContext + pop {r0-r3} /* LR is now in r3. */ + mov lr, r3 /* LR = r3. */ + lsls r2, r3, #25 /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + bpl save_ns_context /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r2, [r3] /* Read pxCurrentTCB. */ +#if ( configENABLE_MPU == 1 ) + subs r1, r1, #16 /* Make space for xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mrs r3, control /* r3 = CONTROL. */ + mov r4, lr /* r4 = LR/EXC_RETURN. */ + stmia r1!, {r0, r2-r4} /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ +#else /* configENABLE_MPU */ + subs r1, r1, #12 /* Make space for xSecureContext, PSPLIM and LR on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + stmia r1!, {r0, r2-r3} /* Store xSecureContext, PSPLIM and LR on the stack. */ +#endif /* configENABLE_MPU */ + b select_next_task + + save_ns_context: + ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r2, [r3] /* Read pxCurrentTCB. */ + #if ( configENABLE_FPU == 1 ) + tst lr, #0x10 /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + it eq + vstmdbeq r1!, {s16-s31} /* Store the FPU registers which are not saved automatically. */ + #endif /* configENABLE_FPU */ + #if ( configENABLE_MPU == 1 ) + subs r1, r1, #48 /* Make space for xSecureContext, PSPLIM, CONTROL, LR and the remaining registers on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + adds r1, r1, #16 /* r1 = r1 + 16. */ + stm r1, {r4-r11} /* Store the registers that are not saved automatically. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mrs r3, control /* r3 = CONTROL. */ + mov r4, lr /* r4 = LR/EXC_RETURN. */ + subs r1, r1, #16 /* r1 = r1 - 16. */ + stm r1, {r0, r2-r4} /* Store xSecureContext, PSPLIM, CONTROL and LR on the stack. */ + #else /* configENABLE_MPU */ + subs r1, r1, #44 /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */ + str r1, [r2] /* Save the new top of stack in TCB. */ + adds r1, r1, #12 /* r1 = r1 + 12. */ + stm r1, {r4-r11} /* Store the registers that are not saved automatically. */ + mrs r2, psplim /* r2 = PSPLIM. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + subs r1, r1, #12 /* r1 = r1 - 12. */ + stmia r1!, {r0, r2-r3} /* Store xSecureContext, PSPLIM and LR on the stack. */ + #endif /* configENABLE_MPU */ + + select_next_task: + cpsid i + bl vTaskSwitchContext + cpsie i + + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r3, [r2] /* Read pxCurrentTCB. */ + ldr r1, [r3] /* The first item in pxCurrentTCB is the task top of stack. r1 now points to the top of stack. */ + + #if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + bic r4, r4, #1 /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + str r4, [r2] /* Disable MPU. */ + + adds r3, #4 /* r3 = r3 + 4. r3 now points to MAIR0 in TCB. */ + ldr r4, [r3] /* r4 = *r3 i.e. r4 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r4, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + movs r4, #4 /* r4 = 4. */ + str r4, [r2] /* Program RNR = 4. */ + adds r3, #4 /* r3 = r3 + 4. r3 now points to first RBAR in TCB. */ + ldr r2, =0xe000ed9c /* r2 = 0xe000ed9c [Location of RBAR]. */ + ldmia r3!, {r4-r11} /* Read 4 sets of RBAR/RLAR registers from TCB. */ + stmia r2!, {r4-r11} /* Write 4 set of RBAR/RLAR registers using alias registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + orr r4, r4, #1 /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + str r4, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ + #endif /* configENABLE_MPU */ + + #if ( configENABLE_MPU == 1 ) + ldmia r1!, {r0, r2-r4} /* Read from stack - r0 = xSecureContext, r2 = PSPLIM, r3 = CONTROL and r4 = LR. */ + msr psplim, r2 /* Restore the PSPLIM register value for the task. */ + msr control, r3 /* Restore the CONTROL register value for the task. */ + mov lr, r4 /* LR = r4. */ + ldr r2, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + str r0, [r2] /* Restore the task's xSecureContext. */ + cbz r0, restore_ns_context /* If there is no secure context for the task, restore the non-secure context. */ + push {r1,r4} + bl SecureContext_LoadContext /* Restore the secure context. */ + pop {r1,r4} + mov lr, r4 /* LR = r4. */ + lsls r2, r4, #25 /* r2 = r4 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + bpl restore_ns_context /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + msr psp, r1 /* Remember the new top of stack for the task. */ + bx lr + #else /* configENABLE_MPU */ + ldmia r1!, {r0, r2-r3} /* Read from stack - r0 = xSecureContext, r2 = PSPLIM and r3 = LR. */ + msr psplim, r2 /* Restore the PSPLIM register value for the task. */ + mov lr, r3 /* LR = r3. */ + ldr r2, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */ + str r0, [r2] /* Restore the task's xSecureContext. */ + cbz r0, restore_ns_context /* If there is no secure context for the task, restore the non-secure context. */ + push {r1,r3} + bl SecureContext_LoadContext /* Restore the secure context. */ + pop {r1,r3} + mov lr, r3 /* LR = r3. */ + lsls r2, r3, #25 /* r2 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */ + bpl restore_ns_context /* bpl - branch if positive or zero. If r2 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */ + msr psp, r1 /* Remember the new top of stack for the task. */ + bx lr + #endif /* configENABLE_MPU */ + + restore_ns_context: + ldmia r1!, {r4-r11} /* Restore the registers that are not automatically restored. */ + #if ( configENABLE_FPU == 1 ) + tst lr, #0x10 /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + it eq + vldmiaeq r1!, {s16-s31} /* Restore the FPU registers which are not restored automatically. */ + #endif /* configENABLE_FPU */ + msr psp, r1 /* Remember the new top of stack for the task. */ + bx lr +/*-----------------------------------------------------------*/ + +SVC_Handler: + tst lr, #4 + ite eq + mrseq r0, msp + mrsne r0, psp + b vPortSVCHandler_C +/*-----------------------------------------------------------*/ + +vPortFreeSecureContext: + /* r0 = uint32_t *pulTCB. */ + ldr r1, [r0] /* The first item in the TCB is the top of the stack. */ + ldr r0, [r1] /* The first item on the stack is the task's xSecureContext. */ + cmp r0, #0 /* Raise svc if task's xSecureContext is not NULL. */ + it ne + svcne 1 /* Secure context is freed in the supervisor call. portSVC_FREE_SECURE_CONTEXT = 1. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ + + END diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33/non_secure/portmacro.h b/FreeRTOS/Source/portable/IAR/ARM_CM33/non_secure/portmacro.h new file mode 100755 index 0000000..aba3daf --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33/non_secure/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M33" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __root +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_context.c b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_context.c new file mode 100755 index 0000000..53535cd --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_context.c @@ -0,0 +1,204 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Secure context includes. */ +#include "secure_context.h" + +/* Secure heap includes. */ +#include "secure_heap.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief CONTROL value for privileged tasks. + * + * Bit[0] - 0 --> Thread mode is privileged. + * Bit[1] - 1 --> Thread mode uses PSP. + */ +#define securecontextCONTROL_VALUE_PRIVILEGED 0x02 + +/** + * @brief CONTROL value for un-privileged tasks. + * + * Bit[0] - 1 --> Thread mode is un-privileged. + * Bit[1] - 1 --> Thread mode uses PSP. + */ +#define securecontextCONTROL_VALUE_UNPRIVILEGED 0x03 +/*-----------------------------------------------------------*/ + +/** + * @brief Structure to represent secure context. + * + * @note Since stack grows down, pucStackStart is the highest address while + * pucStackLimit is the first addess of the allocated memory. + */ +typedef struct SecureContext +{ + uint8_t *pucCurrentStackPointer; /**< Current value of stack pointer (PSP). */ + uint8_t *pucStackLimit; /**< Last location of the stack memory (PSPLIM). */ + uint8_t *pucStackStart; /**< First location of the stack memory. */ +} SecureContext_t; +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_Init( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* No stack for thread mode until a task's context is loaded. */ + secureportSET_PSPLIM( securecontextNO_STACK ); + secureportSET_PSP( securecontextNO_STACK ); + + #if( configENABLE_MPU == 1 ) + { + /* Configure thread mode to use PSP and to be unprivileged. */ + secureportSET_CONTROL( securecontextCONTROL_VALUE_UNPRIVILEGED ); + } + #else /* configENABLE_MPU */ + { + /* Configure thread mode to use PSP and to be privileged.. */ + secureportSET_CONTROL( securecontextCONTROL_VALUE_PRIVILEGED ); + } + #endif /* configENABLE_MPU */ + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + secureportNON_SECURE_CALLABLE SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize, uint32_t ulIsTaskPrivileged ) +#else /* configENABLE_MPU */ + secureportNON_SECURE_CALLABLE SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize ) +#endif /* configENABLE_MPU */ +{ + uint8_t *pucStackMemory = NULL; + uint32_t ulIPSR; + SecureContextHandle_t xSecureContextHandle = NULL; + #if( configENABLE_MPU == 1 ) + uint32_t *pulCurrentStackPointer = NULL; + #endif /* configENABLE_MPU */ + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* Allocate the context structure. */ + xSecureContextHandle = ( SecureContextHandle_t ) pvPortMalloc( sizeof( SecureContext_t ) ); + + if( xSecureContextHandle != NULL ) + { + /* Allocate the stack space. */ + pucStackMemory = pvPortMalloc( ulSecureStackSize ); + + if( pucStackMemory != NULL ) + { + /* Since stack grows down, the starting point will be the last + * location. Note that this location is next to the last + * allocated byte because the hardware decrements the stack + * pointer before writing i.e. if stack pointer is 0x2, a push + * operation will decrement the stack pointer to 0x1 and then + * write at 0x1. */ + xSecureContextHandle->pucStackStart = pucStackMemory + ulSecureStackSize; + + /* The stack cannot go beyond this location. This value is + * programmed in the PSPLIM register on context switch.*/ + xSecureContextHandle->pucStackLimit = pucStackMemory; + + #if( configENABLE_MPU == 1 ) + { + /* Store the correct CONTROL value for the task on the stack. + * This value is programmed in the CONTROL register on + * context switch. */ + pulCurrentStackPointer = ( uint32_t * ) xSecureContextHandle->pucStackStart; + pulCurrentStackPointer--; + if( ulIsTaskPrivileged ) + { + *( pulCurrentStackPointer ) = securecontextCONTROL_VALUE_PRIVILEGED; + } + else + { + *( pulCurrentStackPointer ) = securecontextCONTROL_VALUE_UNPRIVILEGED; + } + + /* Store the current stack pointer. This value is programmed in + * the PSP register on context switch. */ + xSecureContextHandle->pucCurrentStackPointer = ( uint8_t * ) pulCurrentStackPointer; + } + #else /* configENABLE_MPU */ + { + /* Current SP is set to the starting of the stack. This + * value programmed in the PSP register on context switch. */ + xSecureContextHandle->pucCurrentStackPointer = xSecureContextHandle->pucStackStart; + + } + #endif /* configENABLE_MPU */ + } + else + { + /* Free the context to avoid memory leak and make sure to return + * NULL to indicate failure. */ + vPortFree( xSecureContextHandle ); + xSecureContextHandle = NULL; + } + } + } + + return xSecureContextHandle; +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_FreeContext( SecureContextHandle_t xSecureContextHandle ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* Ensure that valid parameters are passed. */ + secureportASSERT( xSecureContextHandle != NULL ); + + /* Free the stack space. */ + vPortFree( xSecureContextHandle->pucStackLimit ); + + /* Free the context itself. */ + vPortFree( xSecureContextHandle ); + } +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_context.h b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_context.h new file mode 100755 index 0000000..e148bff --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_context.h @@ -0,0 +1,111 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_CONTEXT_H__ +#define __SECURE_CONTEXT_H__ + +/* Standard includes. */ +#include + +/* FreeRTOS includes. */ +#include "FreeRTOSConfig.h" + +/** + * @brief PSP value when no task's context is loaded. + */ +#define securecontextNO_STACK 0x0 + +/** + * @brief Opaque handle. + */ +struct SecureContext; +typedef struct SecureContext* SecureContextHandle_t; +/*-----------------------------------------------------------*/ + +/** + * @brief Initializes the secure context management system. + * + * PSP is set to NULL and therefore a task must allocate and load a context + * before calling any secure side function in the thread mode. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureContext_Init( void ); + +/** + * @brief Allocates a context on the secure side. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] ulSecureStackSize Size of the stack to allocate on secure side. + * @param[in] ulIsTaskPrivileged 1 if the calling task is privileged, 0 otherwise. + * + * @return Opaque context handle if context is successfully allocated, NULL + * otherwise. + */ +#if( configENABLE_MPU == 1 ) + SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize, uint32_t ulIsTaskPrivileged ); +#else /* configENABLE_MPU */ + SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize ); +#endif /* configENABLE_MPU */ + +/** + * @brief Frees the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the + * context to be freed. + */ +void SecureContext_FreeContext( SecureContextHandle_t xSecureContextHandle ); + +/** + * @brief Loads the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the context + * to be loaded. + */ +void SecureContext_LoadContext( SecureContextHandle_t xSecureContextHandle ); + +/** + * @brief Saves the given context. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + * + * @param[in] xSecureContextHandle Context handle corresponding to the context + * to be saved. + */ +void SecureContext_SaveContext( SecureContextHandle_t xSecureContextHandle ); + +#endif /* __SECURE_CONTEXT_H__ */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_context_port.c b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_context_port.c new file mode 100755 index 0000000..619db1e --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_context_port.c @@ -0,0 +1,48 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Secure context includes. */ +#include "secure_context.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/* Functions implemented in assembler file. */ +extern void SecureContext_LoadContextAsm( SecureContextHandle_t xSecureContextHandle ); +extern void SecureContext_SaveContextAsm( SecureContextHandle_t xSecureContextHandle ); + +secureportNON_SECURE_CALLABLE void SecureContext_LoadContext( SecureContextHandle_t xSecureContextHandle ) +{ + SecureContext_LoadContextAsm( xSecureContextHandle ); +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureContext_SaveContext( SecureContextHandle_t xSecureContextHandle ) +{ + SecureContext_SaveContextAsm( xSecureContextHandle ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_context_port_asm.s b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_context_port_asm.s new file mode 100755 index 0000000..0cbfe6e --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_context_port_asm.s @@ -0,0 +1,73 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + SECTION .text:CODE:NOROOT(2) + THUMB + + PUBLIC SecureContext_LoadContextAsm + PUBLIC SecureContext_SaveContextAsm +/*-----------------------------------------------------------*/ + +SecureContext_LoadContextAsm: + /* xSecureContextHandle value is in r0. */ + mrs r1, ipsr /* r1 = IPSR. */ + cbz r1, load_ctx_therad_mode /* Do nothing if the processor is running in the Thread Mode. */ + ldmia r0!, {r1, r2} /* r1 = xSecureContextHandle->pucCurrentStackPointer, r2 = xSecureContextHandle->pucStackLimit. */ +#if ( configENABLE_MPU == 1 ) + ldmia r1!, {r3} /* Read CONTROL register value from task's stack. r3 = CONTROL. */ + msr control, r3 /* CONTROL = r3. */ +#endif /* configENABLE_MPU */ + msr psplim, r2 /* PSPLIM = r2. */ + msr psp, r1 /* PSP = r1. */ + + load_ctx_therad_mode: + bx lr +/*-----------------------------------------------------------*/ + +SecureContext_SaveContextAsm: + /* xSecureContextHandle value is in r0. */ + mrs r1, ipsr /* r1 = IPSR. */ + cbz r1, save_ctx_therad_mode /* Do nothing if the processor is running in the Thread Mode. */ + mrs r1, psp /* r1 = PSP. */ +#if ( configENABLE_FPU == 1 ) + vstmdb r1!, {s0} /* Trigger the defferred stacking of FPU registers. */ + vldmia r1!, {s0} /* Nullify the effect of the pervious statement. */ +#endif /* configENABLE_FPU */ +#if ( configENABLE_MPU == 1 ) + mrs r2, control /* r2 = CONTROL. */ + stmdb r1!, {r2} /* Store CONTROL value on the stack. */ +#endif /* configENABLE_MPU */ + str r1, [r0] /* Save the top of stack in context. xSecureContextHandle->pucCurrentStackPointer = r1. */ + movs r1, #0 /* r1 = securecontextNO_STACK. */ + msr psplim, r1 /* PSPLIM = securecontextNO_STACK. */ + msr psp, r1 /* PSP = securecontextNO_STACK i.e. No stack for thread mode until next task's context is loaded. */ + + save_ctx_therad_mode: + bx lr +/*-----------------------------------------------------------*/ + + END diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_heap.c b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_heap.c new file mode 100755 index 0000000..60fce5c --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_heap.c @@ -0,0 +1,450 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Secure context heap includes. */ +#include "secure_heap.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief Total heap size. + */ +#define secureconfigTOTAL_HEAP_SIZE ( ( ( size_t ) ( 10 * 1024 ) ) ) + +/* No test marker by default. */ +#ifndef mtCOVERAGE_TEST_MARKER + #define mtCOVERAGE_TEST_MARKER() +#endif + +/* No tracing by default. */ +#ifndef traceMALLOC + #define traceMALLOC( pvReturn, xWantedSize ) +#endif + +/* No tracing by default. */ +#ifndef traceFREE + #define traceFREE( pv, xBlockSize ) +#endif + +/* Block sizes must not get too small. */ +#define secureheapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) ) + +/* Assumes 8bit bytes! */ +#define secureheapBITS_PER_BYTE ( ( size_t ) 8 ) +/*-----------------------------------------------------------*/ + +/* Allocate the memory for the heap. */ +#if( configAPPLICATION_ALLOCATED_HEAP == 1 ) + /* The application writer has already defined the array used for the RTOS + * heap - probably so it can be placed in a special segment or address. */ + extern uint8_t ucHeap[ secureconfigTOTAL_HEAP_SIZE ]; +#else /* configAPPLICATION_ALLOCATED_HEAP */ + static uint8_t ucHeap[ secureconfigTOTAL_HEAP_SIZE ]; +#endif /* configAPPLICATION_ALLOCATED_HEAP */ + +/** + * @brief The linked list structure. + * + * This is used to link free blocks in order of their memory address. + */ +typedef struct A_BLOCK_LINK +{ + struct A_BLOCK_LINK *pxNextFreeBlock; /**< The next free block in the list. */ + size_t xBlockSize; /**< The size of the free block. */ +} BlockLink_t; +/*-----------------------------------------------------------*/ + +/** + * @brief Called automatically to setup the required heap structures the first + * time pvPortMalloc() is called. + */ +static void prvHeapInit( void ); + +/** + * @brief Inserts a block of memory that is being freed into the correct + * position in the list of free memory blocks. + * + * The block being freed will be merged with the block in front it and/or the + * block behind it if the memory blocks are adjacent to each other. + * + * @param[in] pxBlockToInsert The block being freed. + */ +static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ); +/*-----------------------------------------------------------*/ + +/** + * @brief The size of the structure placed at the beginning of each allocated + * memory block must by correctly byte aligned. + */ +static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( secureportBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + +/** + * @brief Create a couple of list links to mark the start and end of the list. + */ +static BlockLink_t xStart, *pxEnd = NULL; + +/** + * @brief Keeps track of the number of free bytes remaining, but says nothing + * about fragmentation. + */ +static size_t xFreeBytesRemaining = 0U; +static size_t xMinimumEverFreeBytesRemaining = 0U; + +/** + * @brief Gets set to the top bit of an size_t type. + * + * When this bit in the xBlockSize member of an BlockLink_t structure is set + * then the block belongs to the application. When the bit is free the block is + * still part of the free heap space. + */ +static size_t xBlockAllocatedBit = 0; +/*-----------------------------------------------------------*/ + +static void prvHeapInit( void ) +{ +BlockLink_t *pxFirstFreeBlock; +uint8_t *pucAlignedHeap; +size_t uxAddress; +size_t xTotalHeapSize = secureconfigTOTAL_HEAP_SIZE; + + /* Ensure the heap starts on a correctly aligned boundary. */ + uxAddress = ( size_t ) ucHeap; + + if( ( uxAddress & secureportBYTE_ALIGNMENT_MASK ) != 0 ) + { + uxAddress += ( secureportBYTE_ALIGNMENT - 1 ); + uxAddress &= ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + xTotalHeapSize -= uxAddress - ( size_t ) ucHeap; + } + + pucAlignedHeap = ( uint8_t * ) uxAddress; + + /* xStart is used to hold a pointer to the first item in the list of free + * blocks. The void cast is used to prevent compiler warnings. */ + xStart.pxNextFreeBlock = ( void * ) pucAlignedHeap; + xStart.xBlockSize = ( size_t ) 0; + + /* pxEnd is used to mark the end of the list of free blocks and is inserted + * at the end of the heap space. */ + uxAddress = ( ( size_t ) pucAlignedHeap ) + xTotalHeapSize; + uxAddress -= xHeapStructSize; + uxAddress &= ~( ( size_t ) secureportBYTE_ALIGNMENT_MASK ); + pxEnd = ( void * ) uxAddress; + pxEnd->xBlockSize = 0; + pxEnd->pxNextFreeBlock = NULL; + + /* To start with there is a single free block that is sized to take up the + * entire heap space, minus the space taken by pxEnd. */ + pxFirstFreeBlock = ( void * ) pucAlignedHeap; + pxFirstFreeBlock->xBlockSize = uxAddress - ( size_t ) pxFirstFreeBlock; + pxFirstFreeBlock->pxNextFreeBlock = pxEnd; + + /* Only one block exists - and it covers the entire usable heap space. */ + xMinimumEverFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; + xFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; + + /* Work out the position of the top bit in a size_t variable. */ + xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * secureheapBITS_PER_BYTE ) - 1 ); +} +/*-----------------------------------------------------------*/ + +static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ) +{ +BlockLink_t *pxIterator; +uint8_t *puc; + + /* Iterate through the list until a block is found that has a higher address + * than the block being inserted. */ + for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) + { + /* Nothing to do here, just iterate to the right position. */ + } + + /* Do the block being inserted, and the block it is being inserted after + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxIterator; + if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) + { + pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; + pxBlockToInsert = pxIterator; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Do the block being inserted, and the block it is being inserted before + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxBlockToInsert; + if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) + { + if( pxIterator->pxNextFreeBlock != pxEnd ) + { + /* Form one big block from the two blocks. */ + pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock; + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxEnd; + } + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; + } + + /* If the block being inserted plugged a gab, so was merged with the block + * before and the block after, then it's pxNextFreeBlock pointer will have + * already been set, and should not be set here as that would make it point + * to itself. */ + if( pxIterator != pxBlockToInsert ) + { + pxIterator->pxNextFreeBlock = pxBlockToInsert; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } +} +/*-----------------------------------------------------------*/ + +void *pvPortMalloc( size_t xWantedSize ) +{ +BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink; +void *pvReturn = NULL; + + /* If this is the first call to malloc then the heap will require + * initialisation to setup the list of free blocks. */ + if( pxEnd == NULL ) + { + prvHeapInit(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Check the requested block size is not so large that the top bit is set. + * The top bit of the block size member of the BlockLink_t structure is used + * to determine who owns the block - the application or the kernel, so it + * must be free. */ + if( ( xWantedSize & xBlockAllocatedBit ) == 0 ) + { + /* The wanted size is increased so it can contain a BlockLink_t + * structure in addition to the requested amount of bytes. */ + if( xWantedSize > 0 ) + { + xWantedSize += xHeapStructSize; + + /* Ensure that blocks are always aligned to the required number of + * bytes. */ + if( ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) != 0x00 ) + { + /* Byte alignment required. */ + xWantedSize += ( secureportBYTE_ALIGNMENT - ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) ); + secureportASSERT( ( xWantedSize & secureportBYTE_ALIGNMENT_MASK ) == 0 ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) + { + /* Traverse the list from the start (lowest address) block until + * one of adequate size is found. */ + pxPreviousBlock = &xStart; + pxBlock = xStart.pxNextFreeBlock; + while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) + { + pxPreviousBlock = pxBlock; + pxBlock = pxBlock->pxNextFreeBlock; + } + + /* If the end marker was reached then a block of adequate size was + * not found. */ + if( pxBlock != pxEnd ) + { + /* Return the memory space pointed to - jumping over the + * BlockLink_t structure at its start. */ + pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize ); + + /* This block is being returned for use so must be taken out + * of the list of free blocks. */ + pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; + + /* If the block is larger than required it can be split into + * two. */ + if( ( pxBlock->xBlockSize - xWantedSize ) > secureheapMINIMUM_BLOCK_SIZE ) + { + /* This block is to be split into two. Create a new + * block following the number of bytes requested. The void + * cast is used to prevent byte alignment warnings from the + * compiler. */ + pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize ); + secureportASSERT( ( ( ( size_t ) pxNewBlockLink ) & secureportBYTE_ALIGNMENT_MASK ) == 0 ); + + /* Calculate the sizes of two blocks split from the single + * block. */ + pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; + pxBlock->xBlockSize = xWantedSize; + + /* Insert the new block into the list of free blocks. */ + prvInsertBlockIntoFreeList( pxNewBlockLink ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + xFreeBytesRemaining -= pxBlock->xBlockSize; + + if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) + { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* The block is being returned - it is allocated and owned by + * the application and has no "next" block. */ + pxBlock->xBlockSize |= xBlockAllocatedBit; + pxBlock->pxNextFreeBlock = NULL; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + traceMALLOC( pvReturn, xWantedSize ); + + #if( secureconfigUSE_MALLOC_FAILED_HOOK == 1 ) + { + if( pvReturn == NULL ) + { + extern void vApplicationMallocFailedHook( void ); + vApplicationMallocFailedHook(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + #endif + + secureportASSERT( ( ( ( size_t ) pvReturn ) & ( size_t ) secureportBYTE_ALIGNMENT_MASK ) == 0 ); + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void *pv ) +{ +uint8_t *puc = ( uint8_t * ) pv; +BlockLink_t *pxLink; + + if( pv != NULL ) + { + /* The memory being freed will have an BlockLink_t structure immediately + * before it. */ + puc -= xHeapStructSize; + + /* This casting is to keep the compiler from issuing warnings. */ + pxLink = ( void * ) puc; + + /* Check the block is actually allocated. */ + secureportASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ); + secureportASSERT( pxLink->pxNextFreeBlock == NULL ); + + if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) + { + if( pxLink->pxNextFreeBlock == NULL ) + { + /* The block is being returned to the heap - it is no longer + * allocated. */ + pxLink->xBlockSize &= ~xBlockAllocatedBit; + + secureportDISABLE_NON_SECURE_INTERRUPTS(); + { + /* Add this block to the list of free blocks. */ + xFreeBytesRemaining += pxLink->xBlockSize; + traceFREE( pv, pxLink->xBlockSize ); + prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) ); + } + secureportENABLE_NON_SECURE_INTERRUPTS(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } +} +/*-----------------------------------------------------------*/ + +size_t xPortGetFreeHeapSize( void ) +{ + return xFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +size_t xPortGetMinimumEverFreeHeapSize( void ) +{ + return xMinimumEverFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +void vPortInitialiseBlocks( void ) +{ + /* This just exists to keep the linker quiet. */ +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_heap.h b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_heap.h new file mode 100755 index 0000000..69e4f2a --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_heap.h @@ -0,0 +1,51 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_HEAP_H__ +#define __SECURE_HEAP_H__ + +/* Standard includes. */ +#include + +/** + * @brief Allocates memory from heap. + * + * @param[in] xWantedSize The size of the memory to be allocated. + * + * @return Pointer to the memory region if the allocation is successful, NULL + * otherwise. + */ +void *pvPortMalloc( size_t xWantedSize ); + +/** + * @brief Frees the previously allocated memory. + * + * @param[in] pv Pointer to the memory to be freed. + */ +void vPortFree( void *pv ); + +#endif /* __SECURE_HEAP_H__ */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_init.c b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_init.c new file mode 100755 index 0000000..c6525f7 --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_init.c @@ -0,0 +1,105 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Secure init includes. */ +#include "secure_init.h" + +/* Secure port macros. */ +#include "secure_port_macros.h" + +/** + * @brief Constants required to manipulate the SCB. + */ +#define secureinitSCB_AIRCR ( ( volatile uint32_t * ) 0xe000ed0c ) /* Application Interrupt and Reset Control Register. */ +#define secureinitSCB_AIRCR_VECTKEY_POS ( 16UL ) +#define secureinitSCB_AIRCR_VECTKEY_MASK ( 0xFFFFUL << secureinitSCB_AIRCR_VECTKEY_POS ) +#define secureinitSCB_AIRCR_PRIS_POS ( 14UL ) +#define secureinitSCB_AIRCR_PRIS_MASK ( 1UL << secureinitSCB_AIRCR_PRIS_POS ) + +/** + * @brief Constants required to manipulate the FPU. + */ +#define secureinitFPCCR ( ( volatile uint32_t * ) 0xe000ef34 ) /* Floating Point Context Control Register. */ +#define secureinitFPCCR_LSPENS_POS ( 29UL ) +#define secureinitFPCCR_LSPENS_MASK ( 1UL << secureinitFPCCR_LSPENS_POS ) +#define secureinitFPCCR_TS_POS ( 26UL ) +#define secureinitFPCCR_TS_MASK ( 1UL << secureinitFPCCR_TS_POS ) + +#define secureinitNSACR ( ( volatile uint32_t * ) 0xe000ed8c ) /* Non-secure Access Control Register. */ +#define secureinitNSACR_CP10_POS ( 10UL ) +#define secureinitNSACR_CP10_MASK ( 1UL << secureinitNSACR_CP10_POS ) +#define secureinitNSACR_CP11_POS ( 11UL ) +#define secureinitNSACR_CP11_MASK ( 1UL << secureinitNSACR_CP11_POS ) +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureInit_DePrioritizeNSExceptions( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + *( secureinitSCB_AIRCR ) = ( *( secureinitSCB_AIRCR ) & ~( secureinitSCB_AIRCR_VECTKEY_MASK | secureinitSCB_AIRCR_PRIS_MASK ) ) | + ( ( 0x05FAUL << secureinitSCB_AIRCR_VECTKEY_POS ) & secureinitSCB_AIRCR_VECTKEY_MASK ) | + ( ( 0x1UL << secureinitSCB_AIRCR_PRIS_POS ) & secureinitSCB_AIRCR_PRIS_MASK ); + } +} +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void SecureInit_EnableNSFPUAccess( void ) +{ + uint32_t ulIPSR; + + /* Read the Interrupt Program Status Register (IPSR) value. */ + secureportREAD_IPSR( ulIPSR ); + + /* Do nothing if the processor is running in the Thread Mode. IPSR is zero + * when the processor is running in the Thread Mode. */ + if( ulIPSR != 0 ) + { + /* CP10 = 1 ==> Non-secure access to the Floating Point Unit is + * permitted. CP11 should be programmed to the same value as CP10. */ + *( secureinitNSACR ) |= ( secureinitNSACR_CP10_MASK | secureinitNSACR_CP11_MASK ); + + /* LSPENS = 0 ==> LSPEN is writable fron non-secure state. This ensures + * that we can enable/disable lazy stacking in port.c file. */ + *( secureinitFPCCR ) &= ~ ( secureinitFPCCR_LSPENS_MASK ); + + /* TS = 1 ==> Treat FP registers as secure i.e. callee saved FP + * registers (S16-S31) are also pushed to stack on exception entry and + * restored on exception return. */ + *( secureinitFPCCR ) |= ( secureinitFPCCR_TS_MASK ); + } +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_init.h b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_init.h new file mode 100755 index 0000000..6c5bc71 --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_init.h @@ -0,0 +1,53 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_INIT_H__ +#define __SECURE_INIT_H__ + +/** + * @brief De-prioritizes the non-secure exceptions. + * + * This is needed to ensure that the non-secure PendSV runs at the lowest + * priority. Context switch is done in the non-secure PendSV handler. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureInit_DePrioritizeNSExceptions( void ); + +/** + * @brief Sets up the Floating Point Unit (FPU) for Non-Secure access. + * + * Also sets FPCCR.TS=1 to ensure that the content of the Floating Point + * Registers are not leaked to the non-secure side. + * + * @note This function must be called in the handler mode. It is no-op if called + * in the thread mode. + */ +void SecureInit_EnableNSFPUAccess( void ); + +#endif /* __SECURE_INIT_H__ */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_port_macros.h b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_port_macros.h new file mode 100755 index 0000000..760edab --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33/secure/secure_port_macros.h @@ -0,0 +1,133 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __SECURE_PORT_MACROS_H__ +#define __SECURE_PORT_MACROS_H__ + +/** + * @brief Byte alignment requirements. + */ +#define secureportBYTE_ALIGNMENT 8 +#define secureportBYTE_ALIGNMENT_MASK ( 0x0007 ) + +/** + * @brief Macro to declare a function as non-secure callable. + */ +#if defined( __IAR_SYSTEMS_ICC__ ) + #define secureportNON_SECURE_CALLABLE __cmse_nonsecure_entry __root +#else + #define secureportNON_SECURE_CALLABLE __attribute__((cmse_nonsecure_entry)) __attribute__((used)) +#endif + +/** + * @brief Set the secure PRIMASK value. + */ +#define secureportSET_SECURE_PRIMASK( ulPrimaskValue ) \ + __asm volatile ( "msr primask, %0" : : "r" ( ulPrimaskValue ) : "memory" ) + +/** + * @brief Set the non-secure PRIMASK value. + */ +#define secureportSET_NON_SECURE_PRIMASK( ulPrimaskValue ) \ + __asm volatile ( "msr primask_ns, %0" : : "r" ( ulPrimaskValue ) : "memory" ) + +/** + * @brief Read the PSP value in the given variable. + */ +#define secureportREAD_PSP( pucOutCurrentStackPointer ) \ + __asm volatile ( "mrs %0, psp" : "=r" ( pucOutCurrentStackPointer ) ) + +/** + * @brief Set the PSP to the given value. + */ +#define secureportSET_PSP( pucCurrentStackPointer ) \ + __asm volatile ( "msr psp, %0" : : "r" ( pucCurrentStackPointer ) ) + +/** + * @brief Set the PSPLIM to the given value. + */ +#define secureportSET_PSPLIM( pucStackLimit ) \ + __asm volatile ( "msr psplim, %0" : : "r" ( pucStackLimit ) ) + +/** + * @brief Set the NonSecure MSP to the given value. + */ +#define secureportSET_MSP_NS( pucMainStackPointer ) \ + __asm volatile ( "msr msp_ns, %0" : : "r" ( pucMainStackPointer ) ) + +/** + * @brief Set the CONTROL register to the given value. + */ +#define secureportSET_CONTROL( ulControl ) \ + __asm volatile ( "msr control, %0" : : "r" ( ulControl ) : "memory" ) + +/** + * @brief Read the Interrupt Program Status Register (IPSR) value in the given + * variable. + */ +#define secureportREAD_IPSR( ulIPSR ) \ + __asm volatile ( "mrs %0, ipsr" : "=r" ( ulIPSR ) ) + +/** + * @brief PRIMASK value to enable interrupts. + */ +#define secureportPRIMASK_ENABLE_INTERRUPTS_VAL 0 + +/** + * @brief PRIMASK value to disable interrupts. + */ +#define secureportPRIMASK_DISABLE_INTERRUPTS_VAL 1 + +/** + * @brief Disable secure interrupts. + */ +#define secureportDISABLE_SECURE_INTERRUPTS() secureportSET_SECURE_PRIMASK( secureportPRIMASK_DISABLE_INTERRUPTS_VAL ) + +/** + * @brief Disable non-secure interrupts. + * + * This effectively disables context switches. + */ +#define secureportDISABLE_NON_SECURE_INTERRUPTS() secureportSET_NON_SECURE_PRIMASK( secureportPRIMASK_DISABLE_INTERRUPTS_VAL ) + +/** + * @brief Enable non-secure interrupts. + */ +#define secureportENABLE_NON_SECURE_INTERRUPTS() secureportSET_NON_SECURE_PRIMASK( secureportPRIMASK_ENABLE_INTERRUPTS_VAL ) + +/** + * @brief Assert definition. + */ +#define secureportASSERT( x ) \ + if( ( x ) == 0 ) \ + { \ + secureportDISABLE_SECURE_INTERRUPTS(); \ + secureportDISABLE_NON_SECURE_INTERRUPTS(); \ + for( ;; ); \ + } + +#endif /* __SECURE_PORT_MACROS_H__ */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33_NTZ/non_secure/port.c b/FreeRTOS/Source/portable/IAR/ARM_CM33_NTZ/non_secure/port.c new file mode 100755 index 0000000..bd85a6f --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33_NTZ/non_secure/port.c @@ -0,0 +1,899 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining + * all the API functions to use the MPU wrappers. That should only be done when + * task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/* Portasm includes. */ +#include "portasm.h" + +#if( configENABLE_TRUSTZONE == 1 ) + /* Secure components includes. */ + #include "secure_context.h" + #include "secure_init.h" +#endif /* configENABLE_TRUSTZONE */ + +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/** + * The FreeRTOS Cortex M33 port can be configured to run on the Secure Side only + * i.e. the processor boots as secure and never jumps to the non-secure side. + * The Trust Zone support in the port must be disabled in order to run FreeRTOS + * on the secure side. The following are the valid configuration seetings: + * + * 1. Run FreeRTOS on the Secure Side: + * configRUN_FREERTOS_SECURE_ONLY = 1 and configENABLE_TRUSTZONE = 0 + * + * 2. Run FreeRTOS on the Non-Secure Side with Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 1 + * + * 3. Run FreeRTOS on the Non-Secure Side only i.e. no Secure Side function call support: + * configRUN_FREERTOS_SECURE_ONLY = 0 and configENABLE_TRUSTZONE = 0 + */ +#if( ( configRUN_FREERTOS_SECURE_ONLY == 1 ) && ( configENABLE_TRUSTZONE == 1 ) ) + #error TrustZone needs to be disabled in order to run FreeRTOS on the Secure Side. +#endif +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the NVIC. + */ +#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t * ) 0xe000e010 ) +#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t * ) 0xe000e014 ) +#define portNVIC_SYSTICK_CURRENT_VALUE ( ( volatile uint32_t * ) 0xe000e018 ) +#define portNVIC_INT_CTRL ( ( volatile uint32_t * ) 0xe000ed04 ) +#define portNVIC_SYSPRI2 ( ( volatile uint32_t * ) 0xe000ed20 ) +#define portNVIC_SYSTICK_CLK ( 0x00000004 ) +#define portNVIC_SYSTICK_INT ( 0x00000002 ) +#define portNVIC_SYSTICK_ENABLE ( 0x00000001 ) +#define portNVIC_PENDSVSET ( 0x10000000 ) +#define portMIN_INTERRUPT_PRIORITY ( 255UL ) +#define portNVIC_PENDSV_PRI ( portMIN_INTERRUPT_PRIORITY << 16UL ) +#define portNVIC_SYSTICK_PRI ( portMIN_INTERRUPT_PRIORITY << 24UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the SCB. + */ +#define portSCB_SYS_HANDLER_CTRL_STATE_REG ( * ( volatile uint32_t * ) 0xe000ed24 ) +#define portSCB_MEM_FAULT_ENABLE ( 1UL << 16UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the FPU. + */ +#define portCPACR ( ( volatile uint32_t * ) 0xe000ed88 ) /* Coprocessor Access Control Register. */ +#define portCPACR_CP10_VALUE ( 3UL ) +#define portCPACR_CP11_VALUE portCPACR_CP10_VALUE +#define portCPACR_CP10_POS ( 20UL ) +#define portCPACR_CP11_POS ( 22UL ) + +#define portFPCCR ( ( volatile uint32_t * ) 0xe000ef34 ) /* Floating Point Context Control Register. */ +#define portFPCCR_ASPEN_POS ( 31UL ) +#define portFPCCR_ASPEN_MASK ( 1UL << portFPCCR_ASPEN_POS ) +#define portFPCCR_LSPEN_POS ( 30UL ) +#define portFPCCR_LSPEN_MASK ( 1UL << portFPCCR_LSPEN_POS ) +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to manipulate the MPU. + */ +#define portMPU_TYPE_REG ( * ( ( volatile uint32_t * ) 0xe000ed90 ) ) +#define portMPU_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed94 ) ) +#define portMPU_RNR_REG ( * ( ( volatile uint32_t * ) 0xe000ed98 ) ) + +#define portMPU_RBAR_REG ( * ( ( volatile uint32_t * ) 0xe000ed9c ) ) +#define portMPU_RLAR_REG ( * ( ( volatile uint32_t * ) 0xe000eda0 ) ) + +#define portMPU_RBAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda4 ) ) +#define portMPU_RLAR_A1_REG ( * ( ( volatile uint32_t * ) 0xe000eda8 ) ) + +#define portMPU_RBAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edac ) ) +#define portMPU_RLAR_A2_REG ( * ( ( volatile uint32_t * ) 0xe000edb0 ) ) + +#define portMPU_RBAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb4 ) ) +#define portMPU_RLAR_A3_REG ( * ( ( volatile uint32_t * ) 0xe000edb8 ) ) + +#define portMPU_MAIR0_REG ( * ( ( volatile uint32_t * ) 0xe000edc0 ) ) +#define portMPU_MAIR1_REG ( * ( ( volatile uint32_t * ) 0xe000edc4 ) ) + +#define portMPU_RBAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ +#define portMPU_RLAR_ADDRESS_MASK ( 0xffffffe0 ) /* Must be 32-byte aligned. */ + +#define portMPU_MAIR_ATTR0_POS ( 0UL ) +#define portMPU_MAIR_ATTR0_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR1_POS ( 8UL ) +#define portMPU_MAIR_ATTR1_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR2_POS ( 16UL ) +#define portMPU_MAIR_ATTR2_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR3_POS ( 24UL ) +#define portMPU_MAIR_ATTR3_MASK ( 0xff000000 ) + +#define portMPU_MAIR_ATTR4_POS ( 0UL ) +#define portMPU_MAIR_ATTR4_MASK ( 0x000000ff ) + +#define portMPU_MAIR_ATTR5_POS ( 8UL ) +#define portMPU_MAIR_ATTR5_MASK ( 0x0000ff00 ) + +#define portMPU_MAIR_ATTR6_POS ( 16UL ) +#define portMPU_MAIR_ATTR6_MASK ( 0x00ff0000 ) + +#define portMPU_MAIR_ATTR7_POS ( 24UL ) +#define portMPU_MAIR_ATTR7_MASK ( 0xff000000 ) + +#define portMPU_RLAR_ATTR_INDEX0 ( 0UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX1 ( 1UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX2 ( 2UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX3 ( 3UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX4 ( 4UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX5 ( 5UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX6 ( 6UL << 1UL ) +#define portMPU_RLAR_ATTR_INDEX7 ( 7UL << 1UL ) + +#define portMPU_RLAR_REGION_ENABLE ( 1UL ) + +/* Enable privileged access to unmapped region. */ +#define portMPU_PRIV_BACKGROUND_ENABLE ( 1UL << 2UL ) + +/* Enable MPU. */ +#define portMPU_ENABLE ( 1UL << 0UL ) + +/* Expected value of the portMPU_TYPE register. */ +#define portEXPECTED_MPU_TYPE_VALUE ( 8UL << 8UL ) /* 8 regions, unified. */ +/*-----------------------------------------------------------*/ + +/** + * @brief Constants required to set up the initial stack. + */ +#define portINITIAL_XPSR ( 0x01000000 ) + +#if( configRUN_FREERTOS_SECURE_ONLY == 1 ) + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF FD + * 1111 1111 1111 1111 1111 1111 1111 1101 + * + * Bit[6] - 1 --> The exception was taken from the Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 1 --> The exception was taken to the Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xfffffffd ) +#else + /** + * @brief Initial EXC_RETURN value. + * + * FF FF FF BC + * 1111 1111 1111 1111 1111 1111 1011 1100 + * + * Bit[6] - 0 --> The exception was taken from the Non-Secure state. + * Bit[5] - 1 --> Do not skip stacking of additional state context. + * Bit[4] - 1 --> The PE did not allocate space on the stack for FP context. + * Bit[3] - 1 --> Return to the Thread mode. + * Bit[2] - 1 --> Restore registers from the process stack. + * Bit[1] - 0 --> Reserved, 0. + * Bit[0] - 0 --> The exception was taken to the Non-Secure state. + */ + #define portINITIAL_EXC_RETURN ( 0xffffffbc ) +#endif /* configRUN_FREERTOS_SECURE_ONLY */ + +/** + * @brief CONTROL register privileged bit mask. + * + * Bit[0] in CONTROL register tells the privilege: + * Bit[0] = 0 ==> The task is privileged. + * Bit[0] = 1 ==> The task is not privileged. + */ +#define portCONTROL_PRIVILEGED_MASK ( 1UL << 0UL ) + +/** + * @brief Initial CONTROL register values. + */ +#define portINITIAL_CONTROL_UNPRIVILEGED ( 0x3 ) +#define portINITIAL_CONTROL_PRIVILEGED ( 0x2 ) + +/** + * @brief Let the user override the pre-loading of the initial LR with the + * address of prvTaskExitError() in case it messes up unwinding of the stack + * in the debugger. + */ +#ifdef configTASK_RETURN_ADDRESS + #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS +#else + #define portTASK_RETURN_ADDRESS prvTaskExitError +#endif + +/** + * @brief If portPRELOAD_REGISTERS then registers will be given an initial value + * when a task is created. This helps in debugging at the cost of code size. + */ +#define portPRELOAD_REGISTERS 1 + +/** + * @brief A task is created without a secure context, and must call + * portALLOCATE_SECURE_CONTEXT() to give itself a secure context before it makes + * any secure calls. + */ +#define portNO_SECURE_CONTEXT 0 +/*-----------------------------------------------------------*/ + +/** + * @brief Setup the timer to generate the tick interrupts. + */ +static void prvSetupTimerInterrupt( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Used to catch tasks that attempt to return from their implementing + * function. + */ +static void prvTaskExitError( void ); + +#if( configENABLE_MPU == 1 ) + /** + * @brief Setup the Memory Protection Unit (MPU). + */ + static void prvSetupMPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_MPU */ + +#if( configENABLE_FPU == 1 ) + /** + * @brief Setup the Floating Point Unit (FPU). + */ + static void prvSetupFPU( void ) PRIVILEGED_FUNCTION; +#endif /* configENABLE_FPU */ + +/** + * @brief Yield the processor. + */ +void vPortYield( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Enter critical section. + */ +void vPortEnterCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief Exit from critical section. + */ +void vPortExitCritical( void ) PRIVILEGED_FUNCTION; + +/** + * @brief SysTick handler. + */ +void SysTick_Handler( void ) PRIVILEGED_FUNCTION; + +/** + * @brief C part of SVC handler. + */ +portDONT_DISCARD void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) PRIVILEGED_FUNCTION; +/*-----------------------------------------------------------*/ + +/** + * @brief Each task maintains its own interrupt status in the critical nesting + * variable. + */ +static volatile uint32_t ulCriticalNesting = 0xaaaaaaaaUL; + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Saved as part of the task context to indicate which context the + * task is using on the secure side. + */ + portDONT_DISCARD volatile SecureContextHandle_t xSecureContext = portNO_SECURE_CONTEXT; +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +static void prvSetupTimerInterrupt( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Stop and reset the SysTick. */ + *( portNVIC_SYSTICK_CTRL ) = 0UL; + *( portNVIC_SYSTICK_CURRENT_VALUE ) = 0UL; + + /* Configure SysTick to interrupt at the requested rate. */ + *( portNVIC_SYSTICK_LOAD ) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; + *( portNVIC_SYSTICK_CTRL ) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE; +} +/*-----------------------------------------------------------*/ + +static void prvTaskExitError( void ) +{ +volatile uint32_t ulDummy = 0UL; + + /* A function that implements a task must not exit or attempt to return to + * its caller as there is nothing to return to. If a task wants to exit it + * should instead call vTaskDelete( NULL ). Artificially force an assert() + * to be triggered if configASSERT() is defined, then stop here so + * application writers can catch the error. */ + configASSERT( ulCriticalNesting == ~0UL ); + portDISABLE_INTERRUPTS(); + + while( ulDummy == 0 ) + { + /* This file calls prvTaskExitError() after the scheduler has been + * started to remove a compiler warning about the function being + * defined but never called. ulDummy is used purely to quieten other + * warnings about code appearing after this function is called - making + * ulDummy volatile makes the compiler think the function could return + * and therefore not output an 'unreachable code' warning for code that + * appears after it. */ + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + static void prvSetupMPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __privileged_functions_start__; + extern uint32_t * __privileged_functions_end__; + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + extern uint32_t * __unprivileged_flash_start__; + extern uint32_t * __unprivileged_flash_end__; + extern uint32_t * __privileged_sram_start__; + extern uint32_t * __privileged_sram_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __privileged_functions_start__[]; + extern uint32_t __privileged_functions_end__[]; + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + extern uint32_t __unprivileged_flash_start__[]; + extern uint32_t __unprivileged_flash_end__[]; + extern uint32_t __privileged_sram_start__[]; + extern uint32_t __privileged_sram_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ + + /* Check that the MPU is present. */ + if( portMPU_TYPE_REG == portEXPECTED_MPU_TYPE_VALUE ) + { + /* MAIR0 - Index 0. */ + portMPU_MAIR0_REG |= ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + /* MAIR0 - Index 1. */ + portMPU_MAIR0_REG |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* Setup privileged flash as Read Only so that privileged tasks can + * read it but not modify. */ + portMPU_RNR_REG = portPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_functions_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_functions_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged flash as Read Only by both privileged and + * unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_FLASH_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __unprivileged_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __unprivileged_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup unprivileged syscalls flash as Read Only by both privileged + * and unprivileged tasks. All tasks can read it but no-one can modify. */ + portMPU_RNR_REG = portUNPRIVILEGED_SYSCALLS_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __syscalls_flash_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_ONLY ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __syscalls_flash_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Setup RAM containing kernel data for privileged access only. */ + portMPU_RNR_REG = portPRIVILEGED_RAM_REGION; + portMPU_RBAR_REG = ( ( ( uint32_t ) __privileged_sram_start__ ) & portMPU_RBAR_ADDRESS_MASK ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_PRIVILEGED_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + portMPU_RLAR_REG = ( ( ( uint32_t ) __privileged_sram_end__ ) & portMPU_RLAR_ADDRESS_MASK ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Enable mem fault. */ + portSCB_SYS_HANDLER_CTRL_STATE_REG |= portSCB_MEM_FAULT_ENABLE; + + /* Enable MPU with privileged background access i.e. unmapped + * regions have privileged access. */ + portMPU_CTRL_REG |= ( portMPU_PRIV_BACKGROUND_ENABLE | portMPU_ENABLE ); + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_FPU == 1 ) + static void prvSetupFPU( void ) /* PRIVILEGED_FUNCTION */ + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* Enable non-secure access to the FPU. */ + SecureInit_EnableNSFPUAccess(); + } + #endif /* configENABLE_TRUSTZONE */ + + /* CP10 = 11 ==> Full access to FPU i.e. both privileged and + * unprivileged code should be able to access FPU. CP11 should be + * programmed to the same value as CP10. */ + *( portCPACR ) |= ( ( portCPACR_CP10_VALUE << portCPACR_CP10_POS ) | + ( portCPACR_CP11_VALUE << portCPACR_CP11_POS ) + ); + + /* ASPEN = 1 ==> Hardware should automatically preserve floating point + * context on exception entry and restore on exception return. + * LSPEN = 1 ==> Enable lazy context save of FP state. */ + *( portFPCCR ) |= ( portFPCCR_ASPEN_MASK | portFPCCR_LSPEN_MASK ); + } +#endif /* configENABLE_FPU */ +/*-----------------------------------------------------------*/ + +void vPortYield( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Set a PendSV to request a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + portDISABLE_INTERRUPTS(); + ulCriticalNesting++; + + /* Barriers are normally not required but do ensure the code is + * completely within the specified behaviour for the architecture. */ + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); +} +/*-----------------------------------------------------------*/ + +void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */ +{ + configASSERT( ulCriticalNesting ); + ulCriticalNesting--; + + if( ulCriticalNesting == 0 ) + { + portENABLE_INTERRUPTS(); + } +} +/*-----------------------------------------------------------*/ + +void SysTick_Handler( void ) /* PRIVILEGED_FUNCTION */ +{ +uint32_t ulPreviousMask; + + ulPreviousMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* Increment the RTOS tick. */ + if( xTaskIncrementTick() != pdFALSE ) + { + /* Pend a context switch. */ + *( portNVIC_INT_CTRL ) = portNVIC_PENDSVSET; + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulPreviousMask ); +} +/*-----------------------------------------------------------*/ + +void vPortSVCHandler_C( uint32_t *pulCallerStackAddress ) /* PRIVILEGED_FUNCTION portDONT_DISCARD */ +{ +#if( configENABLE_MPU == 1 ) + #if defined( __ARMCC_VERSION ) + /* Declaration when these variable are defined in code instead of being + * exported from linker scripts. */ + extern uint32_t * __syscalls_flash_start__; + extern uint32_t * __syscalls_flash_end__; + #else + /* Declaration when these variable are exported from linker scripts. */ + extern uint32_t __syscalls_flash_start__[]; + extern uint32_t __syscalls_flash_end__[]; + #endif /* defined( __ARMCC_VERSION ) */ +#endif /* configENABLE_MPU */ + +uint32_t ulPC; + +#if( configENABLE_TRUSTZONE == 1 ) + uint32_t ulR0; + #if( configENABLE_MPU == 1 ) + uint32_t ulControl, ulIsTaskPrivileged; + #endif /* configENABLE_MPU */ +#endif /* configENABLE_TRUSTZONE */ +uint8_t ucSVCNumber; + + /* Register are stored on the stack in the following order - R0, R1, R2, R3, + * R12, LR, PC, xPSR. */ + ulPC = pulCallerStackAddress[ 6 ]; + ucSVCNumber = ( ( uint8_t *) ulPC )[ -2 ]; + + switch( ucSVCNumber ) + { + #if( configENABLE_TRUSTZONE == 1 ) + case portSVC_ALLOCATE_SECURE_CONTEXT: + { + /* R0 contains the stack size passed as parameter to the + * vPortAllocateSecureContext function. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + #if( configENABLE_MPU == 1 ) + { + /* Read the CONTROL register value. */ + __asm volatile ( "mrs %0, control" : "=r" ( ulControl ) ); + + /* The task that raised the SVC is privileged if Bit[0] + * in the CONTROL register is 0. */ + ulIsTaskPrivileged = ( ( ulControl & portCONTROL_PRIVILEGED_MASK ) == 0 ); + + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0, ulIsTaskPrivileged ); + } + #else + { + /* Allocate and load a context for the secure task. */ + xSecureContext = SecureContext_AllocateContext( ulR0 ); + } + #endif /* configENABLE_MPU */ + + configASSERT( xSecureContext != NULL ); + SecureContext_LoadContext( xSecureContext ); + } + break; + + case portSVC_FREE_SECURE_CONTEXT: + { + /* R0 contains the secure context handle to be freed. */ + ulR0 = pulCallerStackAddress[ 0 ]; + + /* Free the secure context. */ + SecureContext_FreeContext( ( SecureContextHandle_t ) ulR0 ); + } + break; + #endif /* configENABLE_TRUSTZONE */ + + case portSVC_START_SCHEDULER: + { + #if( configENABLE_TRUSTZONE == 1 ) + { + /* De-prioritize the non-secure exceptions so that the + * non-secure pendSV runs at the lowest priority. */ + SecureInit_DePrioritizeNSExceptions(); + + /* Initialize the secure context management system. */ + SecureContext_Init(); + } + #endif /* configENABLE_TRUSTZONE */ + + #if( configENABLE_FPU == 1 ) + { + /* Setup the Floating Point Unit (FPU). */ + prvSetupFPU(); + } + #endif /* configENABLE_FPU */ + + /* Setup the context of the first task so that the first task starts + * executing. */ + vRestoreContextOfFirstTask(); + } + break; + + #if( configENABLE_MPU == 1 ) + case portSVC_RAISE_PRIVILEGE: + { + /* Only raise the privilege, if the svc was raised from any of + * the system calls. */ + if( ulPC >= ( uint32_t ) __syscalls_flash_start__ && + ulPC <= ( uint32_t ) __syscalls_flash_end__ ) + { + vRaisePrivilege(); + } + } + break; + #endif /* configENABLE_MPU */ + + default: + { + /* Incorrect SVC call. */ + configASSERT( pdFALSE ); + } + } +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) /* PRIVILEGED_FUNCTION */ +#else + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) /* PRIVILEGED_FUNCTION */ +#endif /* configENABLE_MPU */ +{ + /* Simulate the stack frame as it would be created by a context switch + * interrupt. */ + #if( portPRELOAD_REGISTERS == 0 ) + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack -= 9; /* R11..R4, EXC_RETURN. */ + *pxTopOfStack = portINITIAL_EXC_RETURN; + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #else /* portPRELOAD_REGISTERS */ + { + pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x12121212UL; /* R12 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x03030303UL; /* R3 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x02020202UL; /* R2 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x01010101UL; /* R1 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x11111111UL; /* R11 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x10101010UL; /* R10 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x09090909UL; /* R09 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x08080808UL; /* R08 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x07070707UL; /* R07 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x06060606UL; /* R06 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x05050505UL; /* R05 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x04040404UL; /* R04 */ + pxTopOfStack--; + *pxTopOfStack = portINITIAL_EXC_RETURN; /* EXC_RETURN */ + + #if( configENABLE_MPU == 1 ) + { + pxTopOfStack--; + if( xRunPrivileged == pdTRUE ) + { + *pxTopOfStack = portINITIAL_CONTROL_PRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + else + { + *pxTopOfStack = portINITIAL_CONTROL_UNPRIVILEGED; /* Slot used to hold this task's CONTROL value. */ + } + } + #endif /* configENABLE_MPU */ + + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pxEndOfStack; /* Slot used to hold this task's PSPLIM value. */ + + #if( configENABLE_TRUSTZONE == 1 ) + { + pxTopOfStack--; + *pxTopOfStack = portNO_SECURE_CONTEXT; /* Slot used to hold this task's xSecureContext value. */ + } + #endif /* configENABLE_TRUSTZONE */ + } + #endif /* portPRELOAD_REGISTERS */ + + return pxTopOfStack; +} +/*-----------------------------------------------------------*/ + +BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ + *( portNVIC_SYSPRI2 ) |= portNVIC_PENDSV_PRI; + *( portNVIC_SYSPRI2 ) |= portNVIC_SYSTICK_PRI; + + #if( configENABLE_MPU == 1 ) + { + /* Setup the Memory Protection Unit (MPU). */ + prvSetupMPU(); + } + #endif /* configENABLE_MPU */ + + /* Start the timer that generates the tick ISR. Interrupts are disabled + * here already. */ + prvSetupTimerInterrupt(); + + /* Initialize the critical nesting count ready for the first task. */ + ulCriticalNesting = 0; + + /* Start the first task. */ + vStartFirstTask(); + + /* Should never get here as the tasks will now be executing. Call the task + * exit error function to prevent compiler warnings about a static function + * not being called in the case that the application writer overrides this + * functionality by defining configTASK_RETURN_ADDRESS. Call + * vTaskSwitchContext() so link time optimization does not remove the + * symbol. */ + vTaskSwitchContext(); + prvTaskExitError(); + + /* Should not get here. */ + return 0; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */ +{ + /* Not implemented in ports where there is nothing to return to. + * Artificially force an assert. */ + configASSERT( ulCriticalNesting == 1000UL ); +} +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) + { + uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber; + int32_t lIndex = 0; + + /* Setup MAIR0. */ + xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK ); + xMPUSettings->ulMAIR0 |= ( ( portMPU_DEVICE_MEMORY_nGnRE << portMPU_MAIR_ATTR1_POS ) & portMPU_MAIR_ATTR1_MASK ); + + /* This function is called automatically when the task is created - in + * which case the stack region parameters will be valid. At all other + * times the stack parameters will not be valid and it is assumed that + * the stack region has already been configured. */ + if( ulStackDepth > 0 ) + { + /* Define the region that allows access to the stack. */ + ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ) | + ( portMPU_REGION_READ_WRITE ) | + ( portMPU_REGION_EXECUTE_NEVER ); + + xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_ATTR_INDEX0 ) | + ( portMPU_RLAR_REGION_ENABLE ); + } + + /* User supplied configurable regions. */ + for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ ) + { + /* If xRegions is NULL i.e. the task has not specified any MPU + * region, the else part ensures that all the configurable MPU + * regions are invalidated. */ + if( ( xRegions != NULL ) && ( xRegions[ lIndex ].ulLengthInBytes > 0UL ) ) + { + /* Translate the generic region definition contained in xRegions + * into the ARMv8 specific MPU settings that are then stored in + * xMPUSettings. */ + ulRegionStartAddress = ( ( uint32_t ) xRegions[ lIndex ].pvBaseAddress ) & portMPU_RBAR_ADDRESS_MASK; + ulRegionEndAddress = ( uint32_t ) xRegions[ lIndex ].pvBaseAddress + xRegions[ lIndex ].ulLengthInBytes - 1; + ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK; + + /* Start address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = ( ulRegionStartAddress ) | + ( portMPU_REGION_NON_SHAREABLE ); + + /* RO/RW. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_READ_ONLY ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_ONLY ); + } + else + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_READ_WRITE ); + } + + /* XN. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_EXECUTE_NEVER ) != 0 ) + { + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR |= ( portMPU_REGION_EXECUTE_NEVER ); + } + + /* End Address. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = ( ulRegionEndAddress ) | + ( portMPU_RLAR_REGION_ENABLE ); + + /* Normal memory/ Device memory. */ + if( ( xRegions[ lIndex ].ulParameters & tskMPU_REGION_DEVICE_MEMORY ) != 0 ) + { + /* Attr1 in MAIR0 is configured as device memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX1; + } + else + { + /* Attr1 in MAIR0 is configured as normal memory. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR |= portMPU_RLAR_ATTR_INDEX0; + } + } + else + { + /* Invalidate the region. */ + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRBAR = 0UL; + xMPUSettings->xRegionsSettings[ ulRegionNumber ].ulRLAR = 0UL; + } + + lIndex++; + } + } +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33_NTZ/non_secure/portasm.h b/FreeRTOS/Source/portable/IAR/ARM_CM33_NTZ/non_secure/portasm.h new file mode 100755 index 0000000..2ecf04e --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33_NTZ/non_secure/portasm.h @@ -0,0 +1,113 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef __PORT_ASM_H__ +#define __PORT_ASM_H__ + +/* Scheduler includes. */ +#include "FreeRTOS.h" + +/* MPU wrappers includes. */ +#include "mpu_wrappers.h" + +/** + * @brief Restore the context of the first task so that the first task starts + * executing. + */ +void vRestoreContextOfFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +BaseType_t xIsPrivileged( void ) __attribute__ (( naked )); + +/** + * @brief Raises the privilege level by clearing the bit 0 of the CONTROL + * register. + * + * @note This is a privileged function and should only be called from the kenrel + * code. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vRaisePrivilege( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vResetPrivilege( void ) __attribute__ (( naked )); + +/** + * @brief Starts the first task. + */ +void vStartFirstTask( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Disables interrupts. + */ +uint32_t ulSetInterruptMaskFromISR( void ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Enables interrupts. + */ +void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__(( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief PendSV Exception handler. + */ +void PendSV_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief SVC Handler. + */ +void SVC_Handler( void ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +/** + * @brief Allocate a Secure context for the calling task. + * + * @param[in] ulSecureStackSize The size of the stack to be allocated on the + * secure side for the calling task. + */ +void vPortAllocateSecureContext( uint32_t ulSecureStackSize ) __attribute__ (( naked )); + +/** + * @brief Free the task's secure context. + * + * @param[in] pulTCB Pointer to the Task Control Block (TCB) of the task. + */ +void vPortFreeSecureContext( uint32_t *pulTCB ) __attribute__ (( naked )) PRIVILEGED_FUNCTION; + +#endif /* __PORT_ASM_H__ */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33_NTZ/non_secure/portasm.s b/FreeRTOS/Source/portable/IAR/ARM_CM33_NTZ/non_secure/portasm.s new file mode 100755 index 0000000..400755b --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33_NTZ/non_secure/portasm.s @@ -0,0 +1,242 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + EXTERN pxCurrentTCB + EXTERN vTaskSwitchContext + EXTERN vPortSVCHandler_C + + PUBLIC xIsPrivileged + PUBLIC vResetPrivilege + PUBLIC vRestoreContextOfFirstTask + PUBLIC vRaisePrivilege + PUBLIC vStartFirstTask + PUBLIC ulSetInterruptMaskFromISR + PUBLIC vClearInterruptMaskFromISR + PUBLIC PendSV_Handler + PUBLIC SVC_Handler +/*-----------------------------------------------------------*/ + +/*---------------- Unprivileged Functions -------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION .text:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +xIsPrivileged: + mrs r0, control /* r0 = CONTROL. */ + tst r0, #1 /* Perform r0 & 1 (bitwise AND) and update the conditions flag. */ + ite ne + movne r0, #0 /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + moveq r0, #1 /* CONTROL[0]==0. Return true to indicate that the processor is not privileged. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ + +vResetPrivilege: + mrs r0, control /* r0 = CONTROL. */ + orr r0, r0, #1 /* r0 = r0 | 1. */ + msr control, r0 /* CONTROL = r0. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +/*----------------- Privileged Functions --------------------*/ + +/*-----------------------------------------------------------*/ + + SECTION privileged_functions:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +vRestoreContextOfFirstTask: + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r1, [r2] /* Read pxCurrentTCB. */ + ldr r0, [r1] /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */ + +#if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + bic r4, r4, #1 /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + str r4, [r2] /* Disable MPU. */ + + adds r1, #4 /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + ldr r3, [r1] /* r3 = *r1 i.e. r3 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r3, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + movs r3, #4 /* r3 = 4. */ + str r3, [r2] /* Program RNR = 4. */ + adds r1, #4 /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + ldr r2, =0xe000ed9c /* r2 = 0xe000ed9c [Location of RBAR]. */ + ldmia r1!, {r4-r11} /* Read 4 sets of RBAR/RLAR registers from TCB. */ + stmia r2!, {r4-r11} /* Write 4 set of RBAR/RLAR registers using alias registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + orr r4, r4, #1 /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + str r4, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ +#endif /* configENABLE_MPU */ + +#if ( configENABLE_MPU == 1 ) + ldm r0!, {r1-r3} /* Read from stack - r1 = PSPLIM, r2 = CONTROL and r3 = EXC_RETURN. */ + msr psplim, r1 /* Set this task's PSPLIM value. */ + msr control, r2 /* Set this task's CONTROL value. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r3 /* Finally, branch to EXC_RETURN. */ +#else /* configENABLE_MPU */ + ldm r0!, {r1-r2} /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ + msr psplim, r1 /* Set this task's PSPLIM value. */ + movs r1, #2 /* r1 = 2. */ + msr CONTROL, r1 /* Switch to use PSP in the thread mode. */ + adds r0, #32 /* Discard everything up to r0. */ + msr psp, r0 /* This is now the new top of stack to use in the task. */ + isb + bx r2 /* Finally, branch to EXC_RETURN. */ +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +vRaisePrivilege: + mrs r0, control /* Read the CONTROL register. */ + bic r0, r0, #1 /* Clear the bit 0. */ + msr control, r0 /* Write back the new CONTROL value. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ + +vStartFirstTask: + ldr r0, =0xe000ed08 /* Use the NVIC offset register to locate the stack. */ + ldr r0, [r0] /* Read the VTOR register which gives the address of vector table. */ + ldr r0, [r0] /* The first entry in vector table is stack pointer. */ + msr msp, r0 /* Set the MSP back to the start of the stack. */ + cpsie i /* Globally enable interrupts. */ + cpsie f + dsb + isb + svc 2 /* System call to start the first task. portSVC_START_SCHEDULER = 2. */ +/*-----------------------------------------------------------*/ + +ulSetInterruptMaskFromISR: + mrs r0, PRIMASK + cpsid i + bx lr +/*-----------------------------------------------------------*/ + +vClearInterruptMaskFromISR: + msr PRIMASK, r0 + bx lr +/*-----------------------------------------------------------*/ + +PendSV_Handler: + mrs r0, psp /* Read PSP in r0. */ +#if ( configENABLE_FPU == 1 ) + tst lr, #0x10 /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + it eq + vstmdbeq r0!, {s16-s31} /* Store the FPU registers which are not saved automatically. */ +#endif /* configENABLE_FPU */ +#if ( configENABLE_MPU == 1 ) + mrs r1, psplim /* r1 = PSPLIM. */ + mrs r2, control /* r2 = CONTROL. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + stmdb r0!, {r1-r11} /* Store on the stack - PSPLIM, CONTROL, LR and registers that are not automatically saved. */ +#else /* configENABLE_MPU */ + mrs r2, psplim /* r2 = PSPLIM. */ + mov r3, lr /* r3 = LR/EXC_RETURN. */ + stmdb r0!, {r2-r11} /* Store on the stack - PSPLIM, LR and registers that are not automatically. */ +#endif /* configENABLE_MPU */ + + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r1, [r2] /* Read pxCurrentTCB. */ + str r0, [r1] /* Save the new top of stack in TCB. */ + + cpsid i + bl vTaskSwitchContext + cpsie i + + ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */ + ldr r1, [r2] /* Read pxCurrentTCB. */ + ldr r0, [r1] /* The first item in pxCurrentTCB is the task top of stack. r0 now points to the top of stack. */ + +#if ( configENABLE_MPU == 1 ) + dmb /* Complete outstanding transfers before disabling MPU. */ + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + bic r4, r4, #1 /* r4 = r4 & ~1 i.e. Clear the bit 0 in r4. */ + str r4, [r2] /* Disable MPU. */ + + adds r1, #4 /* r1 = r1 + 4. r1 now points to MAIR0 in TCB. */ + ldr r3, [r1] /* r3 = *r1 i.e. r3 = MAIR0. */ + ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */ + str r3, [r2] /* Program MAIR0. */ + ldr r2, =0xe000ed98 /* r2 = 0xe000ed98 [Location of RNR]. */ + movs r3, #4 /* r3 = 4. */ + str r3, [r2] /* Program RNR = 4. */ + adds r1, #4 /* r1 = r1 + 4. r1 now points to first RBAR in TCB. */ + ldr r2, =0xe000ed9c /* r2 = 0xe000ed9c [Location of RBAR]. */ + ldmia r1!, {r4-r11} /* Read 4 sets of RBAR/RLAR registers from TCB. */ + stmia r2!, {r4-r11} /* Write 4 set of RBAR/RLAR registers using alias registers. */ + + ldr r2, =0xe000ed94 /* r2 = 0xe000ed94 [Location of MPU_CTRL]. */ + ldr r4, [r2] /* Read the value of MPU_CTRL. */ + orr r4, r4, #1 /* r4 = r4 | 1 i.e. Set the bit 0 in r4. */ + str r4, [r2] /* Enable MPU. */ + dsb /* Force memory writes before continuing. */ +#endif /* configENABLE_MPU */ + +#if ( configENABLE_MPU == 1 ) + ldmia r0!, {r1-r11} /* Read from stack - r1 = PSPLIM, r2 = CONTROL, r3 = LR and r4-r11 restored. */ +#else /* configENABLE_MPU */ + ldmia r0!, {r2-r11} /* Read from stack - r2 = PSPLIM, r3 = LR and r4-r11 restored. */ +#endif /* configENABLE_MPU */ + +#if ( configENABLE_FPU == 1 ) + tst r3, #0x10 /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the FPU is in use. */ + it eq + vldmiaeq r0!, {s16-s31} /* Restore the FPU registers which are not restored automatically. */ +#endif /* configENABLE_FPU */ + + #if ( configENABLE_MPU == 1 ) + msr psplim, r1 /* Restore the PSPLIM register value for the task. */ + msr control, r2 /* Restore the CONTROL register value for the task. */ +#else /* configENABLE_MPU */ + msr psplim, r2 /* Restore the PSPLIM register value for the task. */ +#endif /* configENABLE_MPU */ + msr psp, r0 /* Remember the new top of stack for the task. */ + bx r3 +/*-----------------------------------------------------------*/ + +SVC_Handler: + tst lr, #4 + ite eq + mrseq r0, msp + mrsne r0, psp + b vPortSVCHandler_C +/*-----------------------------------------------------------*/ + + END diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM33_NTZ/non_secure/portmacro.h b/FreeRTOS/Source/portable/IAR/ARM_CM33_NTZ/non_secure/portmacro.h new file mode 100755 index 0000000..aba3daf --- /dev/null +++ b/FreeRTOS/Source/portable/IAR/ARM_CM33_NTZ/non_secure/portmacro.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------------ + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *------------------------------------------------------------------------------ + */ + +#ifndef configENABLE_FPU + #error configENABLE_FPU must be defined in FreeRTOSConfig.h. Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU. +#endif /* configENABLE_FPU */ + +#ifndef configENABLE_MPU + #error configENABLE_MPU must be defined in FreeRTOSConfig.h. Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU. +#endif /* configENABLE_MPU */ + +#ifndef configENABLE_TRUSTZONE + #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h. Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone. +#endif /* configENABLE_TRUSTZONE */ + +/*-----------------------------------------------------------*/ + +/** + * @brief Type definitions. + */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do + * not need to be guarded with a critical section. */ + #define portTICK_TYPE_IS_ATOMIC 1 +#endif +/*-----------------------------------------------------------*/ + +/** + * Architecture specifics. + */ +#define portARCH_NAME "Cortex-M33" +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() +#define portINLINE __inline +#ifndef portFORCE_INLINE + #define portFORCE_INLINE inline __attribute__(( always_inline )) +#endif +#define portHAS_STACK_OVERFLOW_CHECKING 1 +#define portDONT_DISCARD __root +/*-----------------------------------------------------------*/ + +/** + * @brief Extern declarations. + */ +extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */; + +extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */; +extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */; + +extern uint32_t ulSetInterruptMaskFromISR( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */; + +#if( configENABLE_TRUSTZONE == 1 ) + extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */ + extern void vPortFreeSecureContext( uint32_t *pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */; +#endif /* configENABLE_TRUSTZONE */ + +#if( configENABLE_MPU == 1 ) + extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */; + extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */; +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief MPU specific constants. + */ +#if( configENABLE_MPU == 1 ) + #define portUSING_MPU_WRAPPERS 1 + #define portPRIVILEGE_BIT ( 0x80000000UL ) +#else + #define portPRIVILEGE_BIT ( 0x0UL ) +#endif /* configENABLE_MPU */ + + +/* MPU regions. */ +#define portPRIVILEGED_FLASH_REGION ( 0UL ) +#define portUNPRIVILEGED_FLASH_REGION ( 1UL ) +#define portUNPRIVILEGED_SYSCALLS_REGION ( 2UL ) +#define portPRIVILEGED_RAM_REGION ( 3UL ) +#define portSTACK_REGION ( 4UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portLAST_CONFIGURABLE_REGION ( 7UL ) +#define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) +#define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ + +/* Device memory attributes used in MPU_MAIR registers. + * + * 8-bit values encoded as follows: + * Bit[7:4] - 0000 - Device Memory + * Bit[3:2] - 00 --> Device-nGnRnE + * 01 --> Device-nGnRE + * 10 --> Device-nGRE + * 11 --> Device-GRE + * Bit[1:0] - 00, Reserved. + */ +#define portMPU_DEVICE_MEMORY_nGnRnE ( 0x00 ) /* 0000 0000 */ +#define portMPU_DEVICE_MEMORY_nGnRE ( 0x04 ) /* 0000 0100 */ +#define portMPU_DEVICE_MEMORY_nGRE ( 0x08 ) /* 0000 1000 */ +#define portMPU_DEVICE_MEMORY_GRE ( 0x0C ) /* 0000 1100 */ + +/* Normal memory attributes used in MPU_MAIR registers. */ +#define portMPU_NORMAL_MEMORY_NON_CACHEABLE ( 0x44 ) /* Non-cacheable. */ +#define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE ( 0xFF ) /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */ + +/* Attributes used in MPU_RBAR registers. */ +#define portMPU_REGION_NON_SHAREABLE ( 0UL << 3UL ) +#define portMPU_REGION_INNER_SHAREABLE ( 1UL << 3UL ) +#define portMPU_REGION_OUTER_SHAREABLE ( 2UL << 3UL ) + +#define portMPU_REGION_PRIVILEGED_READ_WRITE ( 0UL << 1UL ) +#define portMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define portMPU_REGION_PRIVILEGED_READ_ONLY ( 2UL << 1UL ) +#define portMPU_REGION_READ_ONLY ( 3UL << 1UL ) + +#define portMPU_REGION_EXECUTE_NEVER ( 1UL ) +/*-----------------------------------------------------------*/ + +/** + * @brief Settings to define an MPU region. + */ +typedef struct MPURegionSettings +{ + uint32_t ulRBAR; /**< RBAR for the region. */ + uint32_t ulRLAR; /**< RLAR for the region. */ +} MPURegionSettings_t; + +/** + * @brief MPU settings as stored in the TCB. + */ +typedef struct MPU_SETTINGS +{ + uint32_t ulMAIR0; /**< MAIR0 for the task containing attributes for all the 4 per task regions. */ + MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */ +} xMPU_SETTINGS; +/*-----------------------------------------------------------*/ + +/** + * @brief SVC numbers. + */ +#define portSVC_ALLOCATE_SECURE_CONTEXT 0 +#define portSVC_FREE_SECURE_CONTEXT 1 +#define portSVC_START_SCHEDULER 2 +#define portSVC_RAISE_PRIVILEGE 3 +/*-----------------------------------------------------------*/ + +/** + * @brief Scheduler utilities. + */ +#define portYIELD() vPortYield() +#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) +#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +/*-----------------------------------------------------------*/ + +/** + * @brief Critical section management. + */ +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x ) +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() +/*-----------------------------------------------------------*/ + +/** + * @brief Task function macros as described on the FreeRTOS.org WEB site. + */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) +/*-----------------------------------------------------------*/ + +#if( configENABLE_TRUSTZONE == 1 ) + /** + * @brief Allocate a secure context for the task. + * + * Tasks are not created with a secure context. Any task that is going to call + * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a + * secure context before it calls any secure function. + * + * @param[in] ulSecureStackSize The size of the secure stack to be allocated. + */ + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) vPortAllocateSecureContext( ulSecureStackSize ) + + /** + * @brief Called when a task is deleted to delete the task's secure context, + * if it has one. + * + * @param[in] pxTCB The TCB of the task being deleted. + */ + #define portCLEAN_UP_TCB( pxTCB ) vPortFreeSecureContext( ( uint32_t * ) pxTCB ) +#else + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portCLEAN_UP_TCB( pxTCB ) +#endif /* configENABLE_TRUSTZONE */ +/*-----------------------------------------------------------*/ + +#if( configENABLE_MPU == 1 ) + /** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ + #define portIS_PRIVILEGED() xIsPrivileged() + + /** + * @brief Raise an SVC request to raise privilege. + * + * The SVC handler checks that the SVC was raised from a system call and only + * then it raises the privilege. If this is called from any other place, + * the privilege is not raised. + */ + #define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + + /** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ + #define portRESET_PRIVILEGE() vResetPrivilege() +#else + #define portIS_PRIVILEGED() + #define portRAISE_PRIVILEGE() + #define portRESET_PRIVILEGE() +#endif /* configENABLE_MPU */ +/*-----------------------------------------------------------*/ + +/** + * @brief Barriers. + */ +#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/*-----------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM4F/port.c b/FreeRTOS/Source/portable/IAR/ARM_CM4F/port.c index c007033..fd27a15 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM4F/port.c +++ b/FreeRTOS/Source/portable/IAR/ARM_CM4F/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM4F/portasm.s b/FreeRTOS/Source/portable/IAR/ARM_CM4F/portasm.s index 37bcf92..da715ae 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM4F/portasm.s +++ b/FreeRTOS/Source/portable/IAR/ARM_CM4F/portasm.s @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM4F/portmacro.h b/FreeRTOS/Source/portable/IAR/ARM_CM4F/portmacro.h index f723a37..08f5d1c 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM4F/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/ARM_CM4F/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM4F_MPU/port.c b/FreeRTOS/Source/portable/IAR/ARM_CM4F_MPU/port.c index 1db2120..81c5a10 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM4F_MPU/port.c +++ b/FreeRTOS/Source/portable/IAR/ARM_CM4F_MPU/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -153,13 +153,6 @@ static void prvSetupMPU( void ) PRIVILEGED_FUNCTION; */ static uint32_t prvGetMPURegionSizeSetting( uint32_t ulActualSizeInBytes ) PRIVILEGED_FUNCTION; -/* - * Checks to see if being called from the context of an unprivileged task, and - * if so raises the privilege level and returns false - otherwise does nothing - * other than return true. - */ -extern BaseType_t xPortRaisePrivilege( void ); - /* * Setup the timer to generate the tick interrupts. The implementation in this * file is weak to allow application writers to change the timer used to @@ -192,6 +185,18 @@ void vPortSVCHandler_C( uint32_t *pulParam ); */ extern void vPortRestoreContextOfFirstTask( void ) PRIVILEGED_FUNCTION; +/** + * @brief Calls the port specific code to raise the privilege. + * + * @return pdFALSE if privilege was raised, pdTRUE otherwise. + */ +extern BaseType_t xPortRaisePrivilege( void ); + +/** + * @brief If xRunningPrivileged is not pdTRUE, calls the port specific + * code to reset the privilege, otherwise does nothing. + */ +extern void vPortResetPrivilege( BaseType_t xRunningPrivileged ); /*-----------------------------------------------------------*/ /* Each task maintains its own interrupt status in the critical nesting @@ -564,18 +569,6 @@ uint32_t ulRegionSize, ulReturnValue = 4; } /*-----------------------------------------------------------*/ -void vPortResetPrivilege( BaseType_t xRunningPrivileged ) -{ - if( xRunningPrivileged != pdTRUE ) - { - __asm volatile ( " mrs r0, control \n" \ - " orr r0, r0, #1 \n" \ - " msr control, r0 \n" \ - :::"r0", "memory" ); - } -} -/*-----------------------------------------------------------*/ - void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) { extern uint32_t __SRAM_segment_start__[]; diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM4F_MPU/portasm.s b/FreeRTOS/Source/portable/IAR/ARM_CM4F_MPU/portasm.s index 7ca5301..37f1a80 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM4F_MPU/portasm.s +++ b/FreeRTOS/Source/portable/IAR/ARM_CM4F_MPU/portasm.s @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -39,7 +39,8 @@ PUBLIC vPortStartFirstTask PUBLIC vPortEnableVFP PUBLIC vPortRestoreContextOfFirstTask - PUBLIC xPortRaisePrivilege + PUBLIC xIsPrivileged + PUBLIC vResetPrivilege /*-----------------------------------------------------------*/ @@ -114,7 +115,7 @@ vPortSVCHandler: /*-----------------------------------------------------------*/ -vPortStartFirstTask +vPortStartFirstTask: /* Use the NVIC offset register to locate the stack. */ ldr r0, =0xE000ED08 ldr r0, [r0] @@ -136,7 +137,7 @@ vPortStartFirstTask /*-----------------------------------------------------------*/ -vPortRestoreContextOfFirstTask +vPortRestoreContextOfFirstTask: /* Use the NVIC offset register to locate the stack. */ ldr r0, =0xE000ED08 ldr r0, [r0] @@ -167,7 +168,7 @@ vPortRestoreContextOfFirstTask /*-----------------------------------------------------------*/ -vPortEnableVFP +vPortEnableVFP: /* The FPU enable bits are in the CPACR. */ ldr.w r0, =0xE000ED88 ldr r1, [r0] @@ -179,19 +180,20 @@ vPortEnableVFP /*-----------------------------------------------------------*/ -xPortRaisePrivilege - mrs r0, control - /* Is the task running privileged? */ - tst r0, #1 - itte ne - /* CONTROL[0]!=0, return false. */ - movne r0, #0 - /* Switch to privileged. */ - svcne 2 /* 2 == portSVC_RAISE_PRIVILEGE */ - /* CONTROL[0]==0, return true. */ - moveq r0, #1 - bx lr +xIsPrivileged: + mrs r0, control /* r0 = CONTROL. */ + tst r0, #1 /* Perform r0 & 1 (bitwise AND) and update the conditions flag. */ + ite ne + movne r0, #0 /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + moveq r0, #1 /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + bx lr /* Return. */ +/*-----------------------------------------------------------*/ +vResetPrivilege: + mrs r0, control /* r0 = CONTROL. */ + orr r0, r0, #1 /* r0 = r0 | 1. */ + msr control, r0 /* CONTROL = r0. */ + bx lr /* Return to the caller. */ +/*-----------------------------------------------------------*/ END - diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM4F_MPU/portmacro.h b/FreeRTOS/Source/portable/IAR/ARM_CM4F_MPU/portmacro.h index 0455e8b..ecdd0cf 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM4F_MPU/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/ARM_CM4F_MPU/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -190,11 +190,28 @@ not necessary for to use this port. They are defined so the common demo files /* portNOP() is not required by this port. */ #define portNOP() +/*-----------------------------------------------------------*/ +extern BaseType_t xIsPrivileged( void ); +extern void vResetPrivilege( void ); -/* Set the privilege level to user mode if xRunningPrivileged is false. */ -void vPortResetPrivilege( BaseType_t xRunningPrivileged ); +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +#define portIS_PRIVILEGED() xIsPrivileged() +/** + * @brief Raise an SVC request to raise privilege. +*/ +#define portRAISE_PRIVILEGE() __asm volatile ( "svc %0 \n" :: "i" ( portSVC_RAISE_PRIVILEGE ) : "memory" ); + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ +#define portRESET_PRIVILEGE() vResetPrivilege() /*-----------------------------------------------------------*/ /* Suppress warnings that are generated by the IAR tools, but cannot be fixed in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM7/r0p1/port.c b/FreeRTOS/Source/portable/IAR/ARM_CM7/r0p1/port.c index 1aa63cc..3a1f873 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM7/r0p1/port.c +++ b/FreeRTOS/Source/portable/IAR/ARM_CM7/r0p1/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM7/r0p1/portasm.s b/FreeRTOS/Source/portable/IAR/ARM_CM7/r0p1/portasm.s index 3d56ff3..ad8070c 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM7/r0p1/portasm.s +++ b/FreeRTOS/Source/portable/IAR/ARM_CM7/r0p1/portasm.s @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM7/r0p1/portmacro.h b/FreeRTOS/Source/portable/IAR/ARM_CM7/r0p1/portmacro.h index c483686..9f3c261 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CM7/r0p1/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/ARM_CM7/r0p1/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CRx_No_GIC/port.c b/FreeRTOS/Source/portable/IAR/ARM_CRx_No_GIC/port.c index e290161..13c8deb 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CRx_No_GIC/port.c +++ b/FreeRTOS/Source/portable/IAR/ARM_CRx_No_GIC/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CRx_No_GIC/portASM.s b/FreeRTOS/Source/portable/IAR/ARM_CRx_No_GIC/portASM.s index d222b4d..9366775 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CRx_No_GIC/portASM.s +++ b/FreeRTOS/Source/portable/IAR/ARM_CRx_No_GIC/portASM.s @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ARM_CRx_No_GIC/portmacro.h b/FreeRTOS/Source/portable/IAR/ARM_CRx_No_GIC/portmacro.h index 3109206..30c877a 100755 --- a/FreeRTOS/Source/portable/IAR/ARM_CRx_No_GIC/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/ARM_CRx_No_GIC/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ATMega323/port.c b/FreeRTOS/Source/portable/IAR/ATMega323/port.c index 5487305..2bdb430 100755 --- a/FreeRTOS/Source/portable/IAR/ATMega323/port.c +++ b/FreeRTOS/Source/portable/IAR/ATMega323/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ATMega323/portmacro.h b/FreeRTOS/Source/portable/IAR/ATMega323/portmacro.h index cf1a0f4..822995a 100755 --- a/FreeRTOS/Source/portable/IAR/ATMega323/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/ATMega323/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/ATMega323/portmacro.s90 b/FreeRTOS/Source/portable/IAR/ATMega323/portmacro.s90 index ffd6cc7..0ecf983 100755 --- a/FreeRTOS/Source/portable/IAR/ATMega323/portmacro.s90 +++ b/FreeRTOS/Source/portable/IAR/ATMega323/portmacro.s90 @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/AVR32_UC3/port.c b/FreeRTOS/Source/portable/IAR/AVR32_UC3/port.c index 9091e82..983e08f 100755 --- a/FreeRTOS/Source/portable/IAR/AVR32_UC3/port.c +++ b/FreeRTOS/Source/portable/IAR/AVR32_UC3/port.c @@ -13,8 +13,8 @@ *****************************************************************************/ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/AVR32_UC3/portmacro.h b/FreeRTOS/Source/portable/IAR/AVR32_UC3/portmacro.h index 735eca8..e130404 100755 --- a/FreeRTOS/Source/portable/IAR/AVR32_UC3/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/AVR32_UC3/portmacro.h @@ -13,8 +13,8 @@ *****************************************************************************/ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/ISR_Support.h b/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/ISR_Support.h index 246a74c..babc698 100755 --- a/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/ISR_Support.h +++ b/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/ISR_Support.h @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/port.c b/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/port.c index 5b57fb9..8e6152d 100755 --- a/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/port.c +++ b/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/portasm.s79 b/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/portasm.s79 index 205f7e1..9a2ca89 100755 --- a/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/portasm.s79 +++ b/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/portasm.s79 @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/portmacro.h b/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/portmacro.h index 09ceaa7..605c4d6 100755 --- a/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/AtmelSAM7S64/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/AtmelSAM9XE/port.c b/FreeRTOS/Source/portable/IAR/AtmelSAM9XE/port.c index 4941157..68468f9 100755 --- a/FreeRTOS/Source/portable/IAR/AtmelSAM9XE/port.c +++ b/FreeRTOS/Source/portable/IAR/AtmelSAM9XE/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/AtmelSAM9XE/portmacro.h b/FreeRTOS/Source/portable/IAR/AtmelSAM9XE/portmacro.h index 6985dc9..c20ac28 100755 --- a/FreeRTOS/Source/portable/IAR/AtmelSAM9XE/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/AtmelSAM9XE/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/LPC2000/ISR_Support.h b/FreeRTOS/Source/portable/IAR/LPC2000/ISR_Support.h index 246a74c..babc698 100755 --- a/FreeRTOS/Source/portable/IAR/LPC2000/ISR_Support.h +++ b/FreeRTOS/Source/portable/IAR/LPC2000/ISR_Support.h @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/LPC2000/port.c b/FreeRTOS/Source/portable/IAR/LPC2000/port.c index 57e1176..8829f27 100755 --- a/FreeRTOS/Source/portable/IAR/LPC2000/port.c +++ b/FreeRTOS/Source/portable/IAR/LPC2000/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/LPC2000/portasm.s79 b/FreeRTOS/Source/portable/IAR/LPC2000/portasm.s79 index 03d4974..ff8efb6 100755 --- a/FreeRTOS/Source/portable/IAR/LPC2000/portasm.s79 +++ b/FreeRTOS/Source/portable/IAR/LPC2000/portasm.s79 @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/LPC2000/portmacro.h b/FreeRTOS/Source/portable/IAR/LPC2000/portmacro.h index 63d69dc..4ef35a2 100755 --- a/FreeRTOS/Source/portable/IAR/LPC2000/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/LPC2000/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/MSP430/port.c b/FreeRTOS/Source/portable/IAR/MSP430/port.c index 5dd7fdc..6322ba3 100755 --- a/FreeRTOS/Source/portable/IAR/MSP430/port.c +++ b/FreeRTOS/Source/portable/IAR/MSP430/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/MSP430/portasm.h b/FreeRTOS/Source/portable/IAR/MSP430/portasm.h index c633283..0248dd5 100755 --- a/FreeRTOS/Source/portable/IAR/MSP430/portasm.h +++ b/FreeRTOS/Source/portable/IAR/MSP430/portasm.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/MSP430/portext.s43 b/FreeRTOS/Source/portable/IAR/MSP430/portext.s43 index fa15533..6dea51d 100755 --- a/FreeRTOS/Source/portable/IAR/MSP430/portext.s43 +++ b/FreeRTOS/Source/portable/IAR/MSP430/portext.s43 @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/MSP430/portmacro.h b/FreeRTOS/Source/portable/IAR/MSP430/portmacro.h index 8dfcb5a..bb39abb 100755 --- a/FreeRTOS/Source/portable/IAR/MSP430/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/MSP430/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/MSP430X/data_model.h b/FreeRTOS/Source/portable/IAR/MSP430X/data_model.h index 3b92f4e..bd4cb6f 100755 --- a/FreeRTOS/Source/portable/IAR/MSP430X/data_model.h +++ b/FreeRTOS/Source/portable/IAR/MSP430X/data_model.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/MSP430X/port.c b/FreeRTOS/Source/portable/IAR/MSP430X/port.c index 5e0437c..71988bd 100755 --- a/FreeRTOS/Source/portable/IAR/MSP430X/port.c +++ b/FreeRTOS/Source/portable/IAR/MSP430X/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/MSP430X/portext.s43 b/FreeRTOS/Source/portable/IAR/MSP430X/portext.s43 index a98e9c6..e669c45 100755 --- a/FreeRTOS/Source/portable/IAR/MSP430X/portext.s43 +++ b/FreeRTOS/Source/portable/IAR/MSP430X/portext.s43 @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/MSP430X/portmacro.h b/FreeRTOS/Source/portable/IAR/MSP430X/portmacro.h index f7ab5ac..feb8a14 100755 --- a/FreeRTOS/Source/portable/IAR/MSP430X/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/MSP430X/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/RL78/ISR_Support.h b/FreeRTOS/Source/portable/IAR/RL78/ISR_Support.h index 7f757e2..143c9c0 100755 --- a/FreeRTOS/Source/portable/IAR/RL78/ISR_Support.h +++ b/FreeRTOS/Source/portable/IAR/RL78/ISR_Support.h @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/RL78/port.c b/FreeRTOS/Source/portable/IAR/RL78/port.c index e188705..0788d1c 100755 --- a/FreeRTOS/Source/portable/IAR/RL78/port.c +++ b/FreeRTOS/Source/portable/IAR/RL78/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/RL78/portasm.s87 b/FreeRTOS/Source/portable/IAR/RL78/portasm.s87 index 17f47e9..ee6e7f2 100755 --- a/FreeRTOS/Source/portable/IAR/RL78/portasm.s87 +++ b/FreeRTOS/Source/portable/IAR/RL78/portasm.s87 @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/RL78/portmacro.h b/FreeRTOS/Source/portable/IAR/RL78/portmacro.h index 6fd138b..2f66784 100755 --- a/FreeRTOS/Source/portable/IAR/RL78/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/RL78/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/RX100/port.c b/FreeRTOS/Source/portable/IAR/RX100/port.c index 9f33202..df36270 100755 --- a/FreeRTOS/Source/portable/IAR/RX100/port.c +++ b/FreeRTOS/Source/portable/IAR/RX100/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/RX100/port_asm.s b/FreeRTOS/Source/portable/IAR/RX100/port_asm.s index c1a0991..ca2e439 100755 --- a/FreeRTOS/Source/portable/IAR/RX100/port_asm.s +++ b/FreeRTOS/Source/portable/IAR/RX100/port_asm.s @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/RX100/portmacro.h b/FreeRTOS/Source/portable/IAR/RX100/portmacro.h index 065c699..594bc82 100755 --- a/FreeRTOS/Source/portable/IAR/RX100/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/RX100/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/RX600/port.c b/FreeRTOS/Source/portable/IAR/RX600/port.c index 5ec8736..f3922fc 100755 --- a/FreeRTOS/Source/portable/IAR/RX600/port.c +++ b/FreeRTOS/Source/portable/IAR/RX600/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/RX600/port_asm.s b/FreeRTOS/Source/portable/IAR/RX600/port_asm.s index 8f5d9dd..400e1fd 100755 --- a/FreeRTOS/Source/portable/IAR/RX600/port_asm.s +++ b/FreeRTOS/Source/portable/IAR/RX600/port_asm.s @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/RX600/portmacro.h b/FreeRTOS/Source/portable/IAR/RX600/portmacro.h index da42b11..ec974da 100755 --- a/FreeRTOS/Source/portable/IAR/RX600/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/RX600/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/RXv2/port.c b/FreeRTOS/Source/portable/IAR/RXv2/port.c index 395ade2..3f4cc78 100755 --- a/FreeRTOS/Source/portable/IAR/RXv2/port.c +++ b/FreeRTOS/Source/portable/IAR/RXv2/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/RXv2/port_asm.s b/FreeRTOS/Source/portable/IAR/RXv2/port_asm.s index 07105a4..9e94823 100755 --- a/FreeRTOS/Source/portable/IAR/RXv2/port_asm.s +++ b/FreeRTOS/Source/portable/IAR/RXv2/port_asm.s @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/RXv2/portmacro.h b/FreeRTOS/Source/portable/IAR/RXv2/portmacro.h index 1465dbd..ee64729 100755 --- a/FreeRTOS/Source/portable/IAR/RXv2/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/RXv2/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/STR71x/ISR_Support.h b/FreeRTOS/Source/portable/IAR/STR71x/ISR_Support.h index 246a74c..babc698 100755 --- a/FreeRTOS/Source/portable/IAR/STR71x/ISR_Support.h +++ b/FreeRTOS/Source/portable/IAR/STR71x/ISR_Support.h @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/STR71x/port.c b/FreeRTOS/Source/portable/IAR/STR71x/port.c index 59a1712..f7b2f9e 100755 --- a/FreeRTOS/Source/portable/IAR/STR71x/port.c +++ b/FreeRTOS/Source/portable/IAR/STR71x/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/STR71x/portasm.s79 b/FreeRTOS/Source/portable/IAR/STR71x/portasm.s79 index ca2d14e..9067dcc 100755 --- a/FreeRTOS/Source/portable/IAR/STR71x/portasm.s79 +++ b/FreeRTOS/Source/portable/IAR/STR71x/portasm.s79 @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/STR71x/portmacro.h b/FreeRTOS/Source/portable/IAR/STR71x/portmacro.h index c61237b..37d92ee 100755 --- a/FreeRTOS/Source/portable/IAR/STR71x/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/STR71x/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/STR75x/ISR_Support.h b/FreeRTOS/Source/portable/IAR/STR75x/ISR_Support.h index 246a74c..babc698 100755 --- a/FreeRTOS/Source/portable/IAR/STR75x/ISR_Support.h +++ b/FreeRTOS/Source/portable/IAR/STR75x/ISR_Support.h @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/STR75x/port.c b/FreeRTOS/Source/portable/IAR/STR75x/port.c index fbe2306..8d919c9 100755 --- a/FreeRTOS/Source/portable/IAR/STR75x/port.c +++ b/FreeRTOS/Source/portable/IAR/STR75x/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/STR75x/portasm.s79 b/FreeRTOS/Source/portable/IAR/STR75x/portasm.s79 index e1f4631..1d5674a 100755 --- a/FreeRTOS/Source/portable/IAR/STR75x/portasm.s79 +++ b/FreeRTOS/Source/portable/IAR/STR75x/portasm.s79 @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/STR75x/portmacro.h b/FreeRTOS/Source/portable/IAR/STR75x/portmacro.h index 30eb1c3..77ec1b4 100755 --- a/FreeRTOS/Source/portable/IAR/STR75x/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/STR75x/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/STR91x/ISR_Support.h b/FreeRTOS/Source/portable/IAR/STR91x/ISR_Support.h index 2733cfe..740f368 100755 --- a/FreeRTOS/Source/portable/IAR/STR91x/ISR_Support.h +++ b/FreeRTOS/Source/portable/IAR/STR91x/ISR_Support.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/STR91x/port.c b/FreeRTOS/Source/portable/IAR/STR91x/port.c index 729393e..af94429 100755 --- a/FreeRTOS/Source/portable/IAR/STR91x/port.c +++ b/FreeRTOS/Source/portable/IAR/STR91x/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/STR91x/portasm.s79 b/FreeRTOS/Source/portable/IAR/STR91x/portasm.s79 index 7e57207..d112743 100755 --- a/FreeRTOS/Source/portable/IAR/STR91x/portasm.s79 +++ b/FreeRTOS/Source/portable/IAR/STR91x/portasm.s79 @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/STR91x/portmacro.h b/FreeRTOS/Source/portable/IAR/STR91x/portmacro.h index 48dd8e9..e28d905 100755 --- a/FreeRTOS/Source/portable/IAR/STR91x/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/STR91x/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/V850ES/ISR_Support.h b/FreeRTOS/Source/portable/IAR/V850ES/ISR_Support.h index 53be27e..dbe871d 100755 --- a/FreeRTOS/Source/portable/IAR/V850ES/ISR_Support.h +++ b/FreeRTOS/Source/portable/IAR/V850ES/ISR_Support.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/V850ES/port.c b/FreeRTOS/Source/portable/IAR/V850ES/port.c index 9303116..3dd8f8a 100755 --- a/FreeRTOS/Source/portable/IAR/V850ES/port.c +++ b/FreeRTOS/Source/portable/IAR/V850ES/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/V850ES/portasm.s85 b/FreeRTOS/Source/portable/IAR/V850ES/portasm.s85 index 9ba6bd1..31d0c8d 100755 --- a/FreeRTOS/Source/portable/IAR/V850ES/portasm.s85 +++ b/FreeRTOS/Source/portable/IAR/V850ES/portasm.s85 @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/V850ES/portasm_Fx3.s85 b/FreeRTOS/Source/portable/IAR/V850ES/portasm_Fx3.s85 index 3c956e2..89b1f52 100755 --- a/FreeRTOS/Source/portable/IAR/V850ES/portasm_Fx3.s85 +++ b/FreeRTOS/Source/portable/IAR/V850ES/portasm_Fx3.s85 @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/V850ES/portasm_Hx2.s85 b/FreeRTOS/Source/portable/IAR/V850ES/portasm_Hx2.s85 index cdbc91e..35d79f9 100755 --- a/FreeRTOS/Source/portable/IAR/V850ES/portasm_Hx2.s85 +++ b/FreeRTOS/Source/portable/IAR/V850ES/portasm_Hx2.s85 @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/IAR/V850ES/portmacro.h b/FreeRTOS/Source/portable/IAR/V850ES/portmacro.h index a5d320d..4ca1f7d 100755 --- a/FreeRTOS/Source/portable/IAR/V850ES/portmacro.h +++ b/FreeRTOS/Source/portable/IAR/V850ES/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC18F/port.c b/FreeRTOS/Source/portable/MPLAB/PIC18F/port.c index b936ab0..b2870bb 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC18F/port.c +++ b/FreeRTOS/Source/portable/MPLAB/PIC18F/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC18F/portmacro.h b/FreeRTOS/Source/portable/MPLAB/PIC18F/portmacro.h index e36e21a..4061c94 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC18F/portmacro.h +++ b/FreeRTOS/Source/portable/MPLAB/PIC18F/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/port.c b/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/port.c index 121a090..a843ee0 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/port.c +++ b/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portasm_PIC24.S b/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portasm_PIC24.S index 9e897f8..7e90e27 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portasm_PIC24.S +++ b/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portasm_PIC24.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portasm_dsPIC.S b/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portasm_dsPIC.S index 74500f6..ee24ce3 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portasm_dsPIC.S +++ b/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portasm_dsPIC.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portmacro.h b/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portmacro.h index f80c853..233053d 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portmacro.h +++ b/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/ISR_Support.h b/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/ISR_Support.h index 6390177..58d40b8 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/ISR_Support.h +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/ISR_Support.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/port.c b/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/port.c index 522fdd0..b5159fa 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/port.c +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/port_asm.S b/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/port_asm.S index cb0af4a..60d8072 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/port_asm.S +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/port_asm.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/portmacro.h b/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/portmacro.h index 5760877..1595288 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/portmacro.h +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MEC14xx/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MX/ISR_Support.h b/FreeRTOS/Source/portable/MPLAB/PIC32MX/ISR_Support.h index 058174f..c6bc98c 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MX/ISR_Support.h +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MX/ISR_Support.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MX/port.c b/FreeRTOS/Source/portable/MPLAB/PIC32MX/port.c index 8db051e..e4329a9 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MX/port.c +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MX/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MX/port_asm.S b/FreeRTOS/Source/portable/MPLAB/PIC32MX/port_asm.S index 4cd02eb..79a55d7 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MX/port_asm.S +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MX/port_asm.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MX/portmacro.h b/FreeRTOS/Source/portable/MPLAB/PIC32MX/portmacro.h index 281ff7b..5065732 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MX/portmacro.h +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MX/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MZ/ISR_Support.h b/FreeRTOS/Source/portable/MPLAB/PIC32MZ/ISR_Support.h index 13ac077..f078406 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MZ/ISR_Support.h +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MZ/ISR_Support.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MZ/port.c b/FreeRTOS/Source/portable/MPLAB/PIC32MZ/port.c index 39e93c6..b5c0f93 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MZ/port.c +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MZ/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MZ/port_asm.S b/FreeRTOS/Source/portable/MPLAB/PIC32MZ/port_asm.S index fb10d6e..43be67d 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MZ/port_asm.S +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MZ/port_asm.S @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MZ/portmacro.h b/FreeRTOS/Source/portable/MPLAB/PIC32MZ/portmacro.h index 088d1fd..7830488 100755 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MZ/portmacro.h +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MZ/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MSVC-MingW/port.c b/FreeRTOS/Source/portable/MSVC-MingW/port.c index 38a596c..02d432c 100755 --- a/FreeRTOS/Source/portable/MSVC-MingW/port.c +++ b/FreeRTOS/Source/portable/MSVC-MingW/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MSVC-MingW/portmacro.h b/FreeRTOS/Source/portable/MSVC-MingW/portmacro.h index 0aa22b9..24822a6 100755 --- a/FreeRTOS/Source/portable/MSVC-MingW/portmacro.h +++ b/FreeRTOS/Source/portable/MSVC-MingW/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MemMang/heap_1.c b/FreeRTOS/Source/portable/MemMang/heap_1.c index 8df215c..542317d 100755 --- a/FreeRTOS/Source/portable/MemMang/heap_1.c +++ b/FreeRTOS/Source/portable/MemMang/heap_1.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MemMang/heap_2.c b/FreeRTOS/Source/portable/MemMang/heap_2.c index b48b87d..7d06921 100755 --- a/FreeRTOS/Source/portable/MemMang/heap_2.c +++ b/FreeRTOS/Source/portable/MemMang/heap_2.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MemMang/heap_3.c b/FreeRTOS/Source/portable/MemMang/heap_3.c index 0bfd1c0..e6a2990 100755 --- a/FreeRTOS/Source/portable/MemMang/heap_3.c +++ b/FreeRTOS/Source/portable/MemMang/heap_3.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MemMang/heap_4.c b/FreeRTOS/Source/portable/MemMang/heap_4.c index ce7abe3..d7cd8a5 100755 --- a/FreeRTOS/Source/portable/MemMang/heap_4.c +++ b/FreeRTOS/Source/portable/MemMang/heap_4.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MemMang/heap_5.c b/FreeRTOS/Source/portable/MemMang/heap_5.c index d150f91..b52d61c 100755 --- a/FreeRTOS/Source/portable/MemMang/heap_5.c +++ b/FreeRTOS/Source/portable/MemMang/heap_5.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MikroC/ARM_CM4F/port.c b/FreeRTOS/Source/portable/MikroC/ARM_CM4F/port.c index e9ff4d0..58933d0 100755 --- a/FreeRTOS/Source/portable/MikroC/ARM_CM4F/port.c +++ b/FreeRTOS/Source/portable/MikroC/ARM_CM4F/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/MikroC/ARM_CM4F/portmacro.h b/FreeRTOS/Source/portable/MikroC/ARM_CM4F/portmacro.h index c3e90b0..2118257 100755 --- a/FreeRTOS/Source/portable/MikroC/ARM_CM4F/portmacro.h +++ b/FreeRTOS/Source/portable/MikroC/ARM_CM4F/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Paradigm/Tern_EE/large_untested/port.c b/FreeRTOS/Source/portable/Paradigm/Tern_EE/large_untested/port.c index 56ba214..51f44f8 100755 --- a/FreeRTOS/Source/portable/Paradigm/Tern_EE/large_untested/port.c +++ b/FreeRTOS/Source/portable/Paradigm/Tern_EE/large_untested/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Paradigm/Tern_EE/large_untested/portasm.h b/FreeRTOS/Source/portable/Paradigm/Tern_EE/large_untested/portasm.h index acadbdb..6539159 100755 --- a/FreeRTOS/Source/portable/Paradigm/Tern_EE/large_untested/portasm.h +++ b/FreeRTOS/Source/portable/Paradigm/Tern_EE/large_untested/portasm.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Paradigm/Tern_EE/large_untested/portmacro.h b/FreeRTOS/Source/portable/Paradigm/Tern_EE/large_untested/portmacro.h index 386b220..3b0d305 100755 --- a/FreeRTOS/Source/portable/Paradigm/Tern_EE/large_untested/portmacro.h +++ b/FreeRTOS/Source/portable/Paradigm/Tern_EE/large_untested/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Paradigm/Tern_EE/small/port.c b/FreeRTOS/Source/portable/Paradigm/Tern_EE/small/port.c index b2bc456..bfb22f7 100755 --- a/FreeRTOS/Source/portable/Paradigm/Tern_EE/small/port.c +++ b/FreeRTOS/Source/portable/Paradigm/Tern_EE/small/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Paradigm/Tern_EE/small/portasm.h b/FreeRTOS/Source/portable/Paradigm/Tern_EE/small/portasm.h index 825b442..0b6d3b5 100755 --- a/FreeRTOS/Source/portable/Paradigm/Tern_EE/small/portasm.h +++ b/FreeRTOS/Source/portable/Paradigm/Tern_EE/small/portasm.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Paradigm/Tern_EE/small/portmacro.h b/FreeRTOS/Source/portable/Paradigm/Tern_EE/small/portmacro.h index 7fd16bb..7dfb258 100755 --- a/FreeRTOS/Source/portable/Paradigm/Tern_EE/small/portmacro.h +++ b/FreeRTOS/Source/portable/Paradigm/Tern_EE/small/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/port.c b/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/port.c index 59c76af..32803cb 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/port.c +++ b/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/portASM.s b/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/portASM.s index 33cba2a..972ffda 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/portASM.s +++ b/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/portASM.s @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/portmacro.h b/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/portmacro.h index 1f2532b..e8e7b5b 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/portmacro.h +++ b/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/portmacro.inc b/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/portmacro.inc index eb12f74..1d0ee67 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/portmacro.inc +++ b/FreeRTOS/Source/portable/RVDS/ARM7_LPC21xx/portmacro.inc @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CA9/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CA9/port.c index 98c5cb8..48205d1 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM_CA9/port.c +++ b/FreeRTOS/Source/portable/RVDS/ARM_CA9/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CA9/portASM.s b/FreeRTOS/Source/portable/RVDS/ARM_CA9/portASM.s index bcbb631..cc5772e 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM_CA9/portASM.s +++ b/FreeRTOS/Source/portable/RVDS/ARM_CA9/portASM.s @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CA9/portmacro.h b/FreeRTOS/Source/portable/RVDS/ARM_CA9/portmacro.h index 4a5d81b..b7483a1 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM_CA9/portmacro.h +++ b/FreeRTOS/Source/portable/RVDS/ARM_CA9/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CA9/portmacro.inc b/FreeRTOS/Source/portable/RVDS/ARM_CA9/portmacro.inc index bf738f5..c07151d 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM_CA9/portmacro.inc +++ b/FreeRTOS/Source/portable/RVDS/ARM_CA9/portmacro.inc @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c index 19fdeb9..eb1613e 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -157,7 +157,7 @@ __asm void prvPortStartFirstTask( void ) */ BaseType_t xPortStartScheduler( void ) { - /* Make PendSV, CallSV and SysTick the same priroity as the kernel. */ + /* Make PendSV, CallSV and SysTick the same priority as the kernel. */ *(portNVIC_SYSPRI2) |= portNVIC_PENDSV_PRI; *(portNVIC_SYSPRI2) |= portNVIC_SYSTICK_PRI; diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM0/portmacro.h b/FreeRTOS/Source/portable/RVDS/ARM_CM0/portmacro.h index 27067bc..9843778 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM0/portmacro.h +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM0/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c index 215a6a7..bb7f9cc 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM3/portmacro.h b/FreeRTOS/Source/portable/RVDS/ARM_CM3/portmacro.h index ffa6654..65cd27e 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM3/portmacro.h +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM3/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c index ac0826b..484e427 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.h b/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.h index ffa6654..65cd27e 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.h +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM4_MPU/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CM4_MPU/port.c index d602661..79557fe 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM4_MPU/port.c +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM4_MPU/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -129,13 +129,6 @@ static void prvStartFirstTask( void ) PRIVILEGED_FUNCTION; */ static uint32_t prvGetMPURegionSizeSetting( uint32_t ulActualSizeInBytes ) PRIVILEGED_FUNCTION; -/* - * Checks to see if being called from the context of an unprivileged task, and - * if so raises the privilege level and returns false - otherwise does nothing - * other than return true. - */ -BaseType_t xPortRaisePrivilege( void ); - /* * Standard FreeRTOS exception handlers. */ @@ -175,6 +168,35 @@ static uint32_t prvPortGetIPSR( void ); static const volatile uint8_t * const pcInterruptPriorityRegisters = ( const uint8_t * ) portNVIC_IP_REGISTERS_OFFSET_16; #endif /* configASSERT_DEFINED */ +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +BaseType_t xIsPrivileged( void ); + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + * + * Bit 0 of the CONTROL register defines the privilege level of Thread Mode. + * Bit[0] = 0 --> The processor is running privileged + * Bit[0] = 1 --> The processor is running unprivileged. + */ +void vResetPrivilege( void ); + +/** + * @brief Calls the port specific code to raise the privilege. + * + * @return pdFALSE if privilege was raised, pdTRUE otherwise. + */ +extern BaseType_t xPortRaisePrivilege( void ); + +/** + * @brief If xRunningPrivileged is not pdTRUE, calls the port specific + * code to reset the privilege, otherwise does nothing. + */ +extern void vPortResetPrivilege( BaseType_t xRunningPrivileged ); /*-----------------------------------------------------------*/ /* @@ -651,15 +673,27 @@ uint32_t ulRegionSize, ulReturnValue = 4; } /*-----------------------------------------------------------*/ -__asm BaseType_t xPortRaisePrivilege( void ) +__asm BaseType_t xIsPrivileged( void ) { - mrs r0, control - tst r0, #1 /* Is the task running privileged? */ - itte ne - movne r0, #0 /* CONTROL[0]!=0, return false. */ - svcne portSVC_RAISE_PRIVILEGE /* Switch to privileged. */ - moveq r0, #1 /* CONTROL[0]==0, return true. */ - bx lr + PRESERVE8 + + mrs r0, control /* r0 = CONTROL. */ + tst r0, #1 /* Perform r0 & 1 (bitwise AND) and update the conditions flag. */ + ite ne + movne r0, #0 /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */ + moveq r0, #1 /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */ + bx lr /* Return. */ +} +/*-----------------------------------------------------------*/ + +__asm void vResetPrivilege( void ) +{ + PRESERVE8 + + mrs r0, control /* r0 = CONTROL. */ + orrs r0, #1 /* r0 = r0 | 1. */ + msr control, r0 /* CONTROL = r0. */ + bx lr /* Return. */ } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM4_MPU/portmacro.h b/FreeRTOS/Source/portable/RVDS/ARM_CM4_MPU/portmacro.h index 260b54d..9a37600 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM4_MPU/portmacro.h +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM4_MPU/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -85,7 +85,7 @@ typedef unsigned long UBaseType_t; #define portPRIVILEGED_RAM_REGION ( 2UL ) #define portGENERAL_PERIPHERALS_REGION ( 3UL ) #define portSTACK_REGION ( 4UL ) -#define portFIRST_CONFIGURABLE_REGION ( 5UL ) +#define portFIRST_CONFIGURABLE_REGION ( 5UL ) #define portLAST_CONFIGURABLE_REGION ( 7UL ) #define portNUM_CONFIGURABLE_REGIONS ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 ) #define portTOTAL_NUM_REGIONS ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */ @@ -197,7 +197,28 @@ not necessary for to use this port. They are defined so the common demo files #ifndef portFORCE_INLINE #define portFORCE_INLINE __forceinline #endif +/*-----------------------------------------------------------*/ +extern BaseType_t xIsPrivileged( void ); +extern void vResetPrivilege( void ); + +/** + * @brief Checks whether or not the processor is privileged. + * + * @return 1 if the processor is already privileged, 0 otherwise. + */ +#define portIS_PRIVILEGED() xIsPrivileged() + +/** + * @brief Raise an SVC request to raise privilege. + */ +#define portRAISE_PRIVILEGE() __asm { svc portSVC_RAISE_PRIVILEGE } + +/** + * @brief Lowers the privilege level by setting the bit 0 of the CONTROL + * register. + */ +#define portRESET_PRIVILEGE() vResetPrivilege() /*-----------------------------------------------------------*/ static portFORCE_INLINE void vPortSetBASEPRI( uint32_t ulBASEPRI ) @@ -280,24 +301,6 @@ BaseType_t xReturn; } /*-----------------------------------------------------------*/ -/* Set the privilege level to user mode if xRunningPrivileged is false. */ -portFORCE_INLINE static void vPortResetPrivilege( BaseType_t xRunningPrivileged ) -{ -uint32_t ulReg; - - if( xRunningPrivileged != pdTRUE ) - { - __asm - { - mrs ulReg, control - orr ulReg, #1 - msr control, ulReg - } - } -} -/*-----------------------------------------------------------*/ - - #ifdef __cplusplus } #endif diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/port.c index 50fc3df..d5a4557 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/port.c +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/portmacro.h b/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/portmacro.h index 369ba61..7004756 100755 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/portmacro.h +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/RX100/port.c b/FreeRTOS/Source/portable/Renesas/RX100/port.c index b7308e2..edc3efe 100755 --- a/FreeRTOS/Source/portable/Renesas/RX100/port.c +++ b/FreeRTOS/Source/portable/Renesas/RX100/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/RX100/port_asm.src b/FreeRTOS/Source/portable/Renesas/RX100/port_asm.src index d0d571d..badce8b 100755 --- a/FreeRTOS/Source/portable/Renesas/RX100/port_asm.src +++ b/FreeRTOS/Source/portable/Renesas/RX100/port_asm.src @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/RX100/portmacro.h b/FreeRTOS/Source/portable/Renesas/RX100/portmacro.h index 1fd369d..a5aadf8 100755 --- a/FreeRTOS/Source/portable/Renesas/RX100/portmacro.h +++ b/FreeRTOS/Source/portable/Renesas/RX100/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/RX200/port.c b/FreeRTOS/Source/portable/Renesas/RX200/port.c index c2b45ff..0a52a61 100755 --- a/FreeRTOS/Source/portable/Renesas/RX200/port.c +++ b/FreeRTOS/Source/portable/Renesas/RX200/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/RX200/port_asm.src b/FreeRTOS/Source/portable/Renesas/RX200/port_asm.src index d0d571d..badce8b 100755 --- a/FreeRTOS/Source/portable/Renesas/RX200/port_asm.src +++ b/FreeRTOS/Source/portable/Renesas/RX200/port_asm.src @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/RX200/portmacro.h b/FreeRTOS/Source/portable/Renesas/RX200/portmacro.h index 36a8f21..62e9f87 100755 --- a/FreeRTOS/Source/portable/Renesas/RX200/portmacro.h +++ b/FreeRTOS/Source/portable/Renesas/RX200/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/RX600/port.c b/FreeRTOS/Source/portable/Renesas/RX600/port.c index 627d597..8e69801 100755 --- a/FreeRTOS/Source/portable/Renesas/RX600/port.c +++ b/FreeRTOS/Source/portable/Renesas/RX600/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/RX600/port_asm.src b/FreeRTOS/Source/portable/Renesas/RX600/port_asm.src index d0d571d..badce8b 100755 --- a/FreeRTOS/Source/portable/Renesas/RX600/port_asm.src +++ b/FreeRTOS/Source/portable/Renesas/RX600/port_asm.src @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/RX600/portmacro.h b/FreeRTOS/Source/portable/Renesas/RX600/portmacro.h index d536e94..f678450 100755 --- a/FreeRTOS/Source/portable/Renesas/RX600/portmacro.h +++ b/FreeRTOS/Source/portable/Renesas/RX600/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/RX600v2/port.c b/FreeRTOS/Source/portable/Renesas/RX600v2/port.c index 9aeb47f..3f47412 100755 --- a/FreeRTOS/Source/portable/Renesas/RX600v2/port.c +++ b/FreeRTOS/Source/portable/Renesas/RX600v2/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -37,7 +37,11 @@ #include "string.h" /* Hardware specifics. */ -#include "iodefine.h" +#if defined( configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H ) && ( configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H == 1 ) + #include "platform.h" +#else + #include "iodefine.h" +#endif /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/Renesas/RX600v2/port_asm.src b/FreeRTOS/Source/portable/Renesas/RX600v2/port_asm.src index 08357d1..818b7b8 100755 --- a/FreeRTOS/Source/portable/Renesas/RX600v2/port_asm.src +++ b/FreeRTOS/Source/portable/Renesas/RX600v2/port_asm.src @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/RX600v2/portmacro.h b/FreeRTOS/Source/portable/Renesas/RX600v2/portmacro.h index fa6f6ac..76c7921 100755 --- a/FreeRTOS/Source/portable/Renesas/RX600v2/portmacro.h +++ b/FreeRTOS/Source/portable/Renesas/RX600v2/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/SH2A_FPU/ISR_Support.inc b/FreeRTOS/Source/portable/Renesas/SH2A_FPU/ISR_Support.inc index fbe8c64..c4fcd3f 100755 --- a/FreeRTOS/Source/portable/Renesas/SH2A_FPU/ISR_Support.inc +++ b/FreeRTOS/Source/portable/Renesas/SH2A_FPU/ISR_Support.inc @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/SH2A_FPU/port.c b/FreeRTOS/Source/portable/Renesas/SH2A_FPU/port.c index 9e90752..e2e78bd 100755 --- a/FreeRTOS/Source/portable/Renesas/SH2A_FPU/port.c +++ b/FreeRTOS/Source/portable/Renesas/SH2A_FPU/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/SH2A_FPU/portasm.src b/FreeRTOS/Source/portable/Renesas/SH2A_FPU/portasm.src index 3574fb1..d265852 100755 --- a/FreeRTOS/Source/portable/Renesas/SH2A_FPU/portasm.src +++ b/FreeRTOS/Source/portable/Renesas/SH2A_FPU/portasm.src @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Renesas/SH2A_FPU/portmacro.h b/FreeRTOS/Source/portable/Renesas/SH2A_FPU/portmacro.h index b6a98dc..328c67a 100755 --- a/FreeRTOS/Source/portable/Renesas/SH2A_FPU/portmacro.h +++ b/FreeRTOS/Source/portable/Renesas/SH2A_FPU/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Rowley/MSP430F449/port.c b/FreeRTOS/Source/portable/Rowley/MSP430F449/port.c index 7335076..ea01e47 100755 --- a/FreeRTOS/Source/portable/Rowley/MSP430F449/port.c +++ b/FreeRTOS/Source/portable/Rowley/MSP430F449/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Rowley/MSP430F449/portasm.h b/FreeRTOS/Source/portable/Rowley/MSP430F449/portasm.h index e7dfb1a..fe55c65 100755 --- a/FreeRTOS/Source/portable/Rowley/MSP430F449/portasm.h +++ b/FreeRTOS/Source/portable/Rowley/MSP430F449/portasm.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Rowley/MSP430F449/portext.asm b/FreeRTOS/Source/portable/Rowley/MSP430F449/portext.asm index e870120..157754c 100755 --- a/FreeRTOS/Source/portable/Rowley/MSP430F449/portext.asm +++ b/FreeRTOS/Source/portable/Rowley/MSP430F449/portext.asm @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Rowley/MSP430F449/portmacro.h b/FreeRTOS/Source/portable/Rowley/MSP430F449/portmacro.h index 5b7b1a2..df06497 100755 --- a/FreeRTOS/Source/portable/Rowley/MSP430F449/portmacro.h +++ b/FreeRTOS/Source/portable/Rowley/MSP430F449/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/SDCC/Cygnal/port.c b/FreeRTOS/Source/portable/SDCC/Cygnal/port.c index 6061983..21445a0 100755 --- a/FreeRTOS/Source/portable/SDCC/Cygnal/port.c +++ b/FreeRTOS/Source/portable/SDCC/Cygnal/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/SDCC/Cygnal/portmacro.h b/FreeRTOS/Source/portable/SDCC/Cygnal/portmacro.h index 6121b11..1a3eafa 100755 --- a/FreeRTOS/Source/portable/SDCC/Cygnal/portmacro.h +++ b/FreeRTOS/Source/portable/SDCC/Cygnal/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Softune/MB91460/port.c b/FreeRTOS/Source/portable/Softune/MB91460/port.c index 603b5aa..7c79be1 100755 --- a/FreeRTOS/Source/portable/Softune/MB91460/port.c +++ b/FreeRTOS/Source/portable/Softune/MB91460/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Softune/MB91460/portmacro.h b/FreeRTOS/Source/portable/Softune/MB91460/portmacro.h index 1d79211..30501c6 100755 --- a/FreeRTOS/Source/portable/Softune/MB91460/portmacro.h +++ b/FreeRTOS/Source/portable/Softune/MB91460/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Softune/MB96340/port.c b/FreeRTOS/Source/portable/Softune/MB96340/port.c index b3a620d..18a0388 100755 --- a/FreeRTOS/Source/portable/Softune/MB96340/port.c +++ b/FreeRTOS/Source/portable/Softune/MB96340/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Softune/MB96340/portmacro.h b/FreeRTOS/Source/portable/Softune/MB96340/portmacro.h index f1ca4f7..4994b5e 100755 --- a/FreeRTOS/Source/portable/Softune/MB96340/portmacro.h +++ b/FreeRTOS/Source/portable/Softune/MB96340/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Tasking/ARM_CM4F/port.c b/FreeRTOS/Source/portable/Tasking/ARM_CM4F/port.c index 7d49d9f..497a3fd 100755 --- a/FreeRTOS/Source/portable/Tasking/ARM_CM4F/port.c +++ b/FreeRTOS/Source/portable/Tasking/ARM_CM4F/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Tasking/ARM_CM4F/port_asm.asm b/FreeRTOS/Source/portable/Tasking/ARM_CM4F/port_asm.asm index 563bddf..46173b6 100755 --- a/FreeRTOS/Source/portable/Tasking/ARM_CM4F/port_asm.asm +++ b/FreeRTOS/Source/portable/Tasking/ARM_CM4F/port_asm.asm @@ -1,6 +1,6 @@ ;/* -; * FreeRTOS Kernel V10.1.1 -; * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.2.1 +; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/Tasking/ARM_CM4F/portmacro.h b/FreeRTOS/Source/portable/Tasking/ARM_CM4F/portmacro.h index 376091d..fe56903 100755 --- a/FreeRTOS/Source/portable/Tasking/ARM_CM4F/portmacro.h +++ b/FreeRTOS/Source/portable/Tasking/ARM_CM4F/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Wiced_CY/port.c b/FreeRTOS/Source/portable/ThirdParty/GCC/Wiced_CY/port.c new file mode 100755 index 0000000..b604164 --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Wiced_CY/port.c @@ -0,0 +1,324 @@ +/* + * FreeRTOS Kernel V10.2.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 + /* Check the configuration. */ + #if( configMAX_PRIORITIES > 32 ) + #error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice. + #endif +#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ + +#ifndef configSETUP_TICK_INTERRUPT + #error configSETUP_TICK_INTERRUPT() must be defined in FreeRTOSConfig.h to call the function that sets up the tick interrupt. +#endif + +#ifndef configCLEAR_TICK_INTERRUPT + #error configCLEAR_TICK_INTERRUPT must be defined in FreeRTOSConfig.h to clear which ever interrupt was used to generate the tick interrupt. +#endif + +/* A critical section is exited when the critical section nesting count reaches +this value. */ +#define portNO_CRITICAL_NESTING ( ( uint32_t ) 0 ) + +/* Tasks are not created with a floating point context, but can be given a +floating point context after they have been created. A variable is stored as +part of the tasks context that holds portNO_FLOATING_POINT_CONTEXT if the task +does not have an FPU context, or any other value if the task does have an FPU +context. */ +#define portNO_FLOATING_POINT_CONTEXT ( ( StackType_t ) 0 ) + +/* Constants required to setup the initial task context. */ +#define portINITIAL_SPSR ( ( StackType_t ) 0x1f ) /* System mode, ARM mode, IRQ enabled FIQ enabled. */ +#define portTHUMB_MODE_BIT ( ( StackType_t ) 0x20 ) +#define portTHUMB_MODE_ADDRESS ( 0x01UL ) + +/* Masks all bits in the APSR other than the mode bits. */ +#define portAPSR_MODE_BITS_MASK ( 0x1F ) + +/* The value of the mode bits in the APSR when the CPU is executing in user +mode. */ +#define portAPSR_USER_MODE ( 0x10 ) + +/* Let the user override the pre-loading of the initial LR with the address of +prvTaskExitError() in case it messes up unwinding of the stack in the +debugger. */ +#ifdef configTASK_RETURN_ADDRESS + #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS +#else + #define portTASK_RETURN_ADDRESS prvTaskExitError +#endif + +/*-----------------------------------------------------------*/ + +/* + * Starts the first task executing. This function is necessarily written in + * assembly code so is implemented in portASM.s. + */ +extern void vPortRestoreTaskContext( void ); + +/* + * Used to catch tasks that attempt to return from their implementing function. + */ +static void prvTaskExitError( void ); + +/*-----------------------------------------------------------*/ + +/* A variable is used to keep track of the critical section nesting. This +variable has to be stored as part of the task context and must be initialised to +a non zero value to ensure interrupts don't inadvertently become unmasked before +the scheduler starts. As it is stored as part of the task context it will +automatically be set to 0 when the first task is started. */ +volatile uint32_t ulCriticalNesting = 9999UL; + +/* Saved as part of the task context. If ulPortTaskHasFPUContext is non-zero then +a floating point context must be saved and restored for the task. */ +volatile uint32_t ulPortTaskHasFPUContext = pdFALSE; + +/* Set to 1 to pend a context switch from an ISR. */ +volatile uint32_t ulPortYieldRequired = pdFALSE; + +/* Counts the interrupt nesting depth. A context switch is only performed if +if the nesting depth is 0. */ +volatile uint32_t ulPortInterruptNesting = 0UL; + +/* Used in the asm file to clear an interrupt. */ +__attribute__(( used )) const uint32_t ulICCEOIR = configEOI_ADDRESS; + +/*-----------------------------------------------------------*/ + +/* + * See header file for description. + */ +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) +{ + /* Setup the initial stack of the task. The stack is set exactly as + expected by the portRESTORE_CONTEXT() macro. + + The fist real value on the stack is the status register, which is set for + system mode, with interrupts enabled. A few NULLs are added first to ensure + GDB does not try decoding a non-existent return address. */ + *pxTopOfStack = ( StackType_t ) NULL; + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) NULL; + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) NULL; + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) portINITIAL_SPSR; + + if( ( ( uint32_t ) pxCode & portTHUMB_MODE_ADDRESS ) != 0x00UL ) + { + /* The task will start in THUMB mode. */ + *pxTopOfStack |= portTHUMB_MODE_BIT; + } + + pxTopOfStack--; + + /* Next the return address, which in this case is the start of the task. */ + *pxTopOfStack = ( StackType_t ) pxCode; + pxTopOfStack--; + + /* Next all the registers other than the stack pointer. */ + *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* R14 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x12121212; /* R12 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x11111111; /* R11 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x10101010; /* R10 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x09090909; /* R9 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x08080808; /* R8 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x07070707; /* R7 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x06060606; /* R6 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x05050505; /* R5 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x04040404; /* R4 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x03030303; /* R3 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x02020202; /* R2 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x01010101; /* R1 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ + pxTopOfStack--; + + /* The task will start with a critical nesting count of 0 as interrupts are + enabled. */ + *pxTopOfStack = portNO_CRITICAL_NESTING; + pxTopOfStack--; + + /* The task will start without a floating point context. A task that uses + the floating point hardware must call vPortTaskUsesFPU() before executing + any floating point instructions. */ + *pxTopOfStack = portNO_FLOATING_POINT_CONTEXT; + + return pxTopOfStack; +} +/*-----------------------------------------------------------*/ + +static void prvTaskExitError( void ) +{ + /* A function that implements a task must not exit or attempt to return to + its caller as there is nothing to return to. If a task wants to exit it + should instead call vTaskDelete( NULL ). + + Artificially force an assert() to be triggered if configASSERT() is + defined, then stop here so application writers can catch the error. */ + configASSERT( ulPortInterruptNesting == ~0UL ); + portDISABLE_INTERRUPTS(); + for( ;; ); +} +/*-----------------------------------------------------------*/ + +BaseType_t xPortStartScheduler( void ) +{ +uint32_t ulAPSR; + + /* Only continue if the CPU is not in User mode. The CPU must be in a + Privileged mode for the scheduler to start. */ + __asm volatile ( "MRS %0, APSR" : "=r" ( ulAPSR ) ); + ulAPSR &= portAPSR_MODE_BITS_MASK; + configASSERT( ulAPSR != portAPSR_USER_MODE ); + + if( ulAPSR != portAPSR_USER_MODE ) + { + /* Start the timer that generates the tick ISR. */ + portDISABLE_INTERRUPTS(); + configSETUP_TICK_INTERRUPT(); + + /* Start the first task executing. */ + vPortRestoreTaskContext(); + } + + /* Will only get here if vTaskStartScheduler() was called with the CPU in + a non-privileged mode or the binary point register was not set to its lowest + possible value. prvTaskExitError() is referenced to prevent a compiler + warning about it being defined but not referenced in the case that the user + defines their own exit address. */ + ( void ) prvTaskExitError; + return 0; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) +{ + /* Not implemented in ports where there is nothing to return to. + Artificially force an assert. */ + configASSERT( ulCriticalNesting == 1000UL ); +} +/*-----------------------------------------------------------*/ + +void vPortEnterCritical( void ) +{ + portDISABLE_INTERRUPTS(); + + /* Now interrupts are disabled ulCriticalNesting can be accessed + directly. Increment ulCriticalNesting to keep a count of how many times + portENTER_CRITICAL() has been called. */ + ulCriticalNesting++; + + /* This is not the interrupt safe version of the enter critical function so + assert() if it is being called from an interrupt context. Only API + functions that end in "FromISR" can be used in an interrupt. Only assert if + the critical nesting count is 1 to protect against recursive calls if the + assert function also uses a critical section. */ + if( ulCriticalNesting == 1 ) + { + configASSERT( ulPortInterruptNesting == 0 ); + } +} +/*-----------------------------------------------------------*/ + +void vPortExitCritical( void ) +{ + if( ulCriticalNesting > portNO_CRITICAL_NESTING ) + { + /* Decrement the nesting count as the critical section is being + exited. */ + ulCriticalNesting--; + + /* If the nesting level has reached zero then all interrupt + priorities must be re-enabled. */ + if( ulCriticalNesting == portNO_CRITICAL_NESTING ) + { + /* Critical nesting has reached zero so all interrupt priorities + should be unmasked. */ + portENABLE_INTERRUPTS(); + } + } +} +/*-----------------------------------------------------------*/ + +void FreeRTOS_Tick_Handler( void ) +{ +uint32_t ulInterruptStatus; + + ulInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); + + /* Increment the RTOS tick. */ + if( xTaskIncrementTick() != pdFALSE ) + { + ulPortYieldRequired = pdTRUE; + } + + portCLEAR_INTERRUPT_MASK_FROM_ISR( ulInterruptStatus ); + + configCLEAR_TICK_INTERRUPT(); +} +/*-----------------------------------------------------------*/ + +void vPortTaskUsesFPU( void ) +{ +#if configFPU == 1 +uint32_t ulInitialFPSCR = 0; + + /* A task is registering the fact that it needs an FPU context. Set the + FPU flag (which is saved as part of the task context). */ + ulPortTaskHasFPUContext = pdTRUE; + + /* Initialise the floating point status register. */ + __asm volatile ( "FMXR FPSCR, %0" :: "r" (ulInitialFPSCR) ); +#else + /* If FreeRTOS was built without FPU support but a task is using the FPU, we have a problem */ + configASSERT( 0 ); +#endif +} +/*-----------------------------------------------------------*/ + + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Wiced_CY/portASM.S b/FreeRTOS/Source/portable/ThirdParty/GCC/Wiced_CY/portASM.S new file mode 100755 index 0000000..0aa650c --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Wiced_CY/portASM.S @@ -0,0 +1,268 @@ +/* + * FreeRTOS Kernel V10.2.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + + .text + .arm + + .set SYS_MODE, 0x1f + .set SVC_MODE, 0x13 + .set IRQ_MODE, 0x12 + + /* Variables and functions. */ + .extern ulMaxAPIPriorityMask + .extern _freertos_vector_table + .extern pxCurrentTCB + .extern vTaskSwitchContext + .extern vApplicationIRQHandler + .extern ulPortInterruptNesting + .extern ulPortTaskHasFPUContext + .extern ulICCEOIR + .extern ulPortYieldRequired + + .global FreeRTOS_IRQ_Handler + .global FreeRTOS_SVC_Handler + .global vPortRestoreTaskContext + + +.macro portSAVE_CONTEXT + + /* Save the LR and SPSR onto the system mode stack before switching to + system mode to save the remaining system mode registers. */ + SRSDB sp!, #SYS_MODE + CPS #SYS_MODE + PUSH {R0-R12, R14} + + /* Push the critical nesting count. */ + LDR R2, ulCriticalNestingConst + LDR R1, [R2] + PUSH {R1} + + /* Does the task have a floating point context that needs saving? If + ulPortTaskHasFPUContext is 0 then no. */ + LDR R2, ulPortTaskHasFPUContextConst + LDR R3, [R2] + CMP R3, #0 + +#if configFPU == 1 + /* Save the floating point context, if any. */ + FMRXNE R1, FPSCR + VPUSHNE {D0-D15} +#if configFPU_D32 == 1 + VPUSHNE {D16-D31} +#endif /* configFPU_D32 */ + PUSHNE {R1} +#endif + + /* Save ulPortTaskHasFPUContext itself. */ + PUSH {R3} + + /* Save the stack pointer in the TCB. */ + LDR R0, pxCurrentTCBConst + LDR R1, [R0] + STR SP, [R1] + + .endm + +; /**********************************************************************/ + +.macro portRESTORE_CONTEXT + + /* Set the SP to point to the stack of the task being restored. */ + LDR R0, pxCurrentTCBConst + LDR R1, [R0] + LDR SP, [R1] + + /* Is there a floating point context to restore? If the restored + ulPortTaskHasFPUContext is zero then no. */ + LDR R0, ulPortTaskHasFPUContextConst + POP {R1} + STR R1, [R0] + CMP R1, #0 + +#if configFPU == 1 + /* Restore the floating point context, if any. */ + POPNE {R0} +#if configFPU_D32 == 1 + VPOPNE {D16-D31} +#endif /* configFPU_D32 */ + VPOPNE {D0-D15} + VMSRNE FPSCR, R0 +#endif + + /* Restore the critical section nesting depth. */ + LDR R0, ulCriticalNestingConst + POP {R1} + STR R1, [R0] + + /* Restore all system mode registers other than the SP (which is already + being used). */ + POP {R0-R12, R14} + + /* Return to the task code, loading CPSR on the way. */ + RFEIA sp! + + .endm + + + + +/****************************************************************************** + * SVC handler is used to yield. + *****************************************************************************/ +.align 4 +.type FreeRTOS_SVC_Handler, %function +FreeRTOS_SVC_Handler: + /* Save the context of the current task and select a new task to run. */ + portSAVE_CONTEXT + LDR R0, vTaskSwitchContextConst + BLX R0 + portRESTORE_CONTEXT + + +/****************************************************************************** + * vPortRestoreTaskContext is used to start the scheduler. + *****************************************************************************/ +.align 4 +.type vPortRestoreTaskContext, %function +vPortRestoreTaskContext: + /* Switch to system mode. */ + CPS #SYS_MODE + portRESTORE_CONTEXT + +.align 4 +.type FreeRTOS_IRQ_Handler, %function +FreeRTOS_IRQ_Handler: + /* Return to the interrupted instruction. */ + SUB lr, lr, #4 + + /* Push the return address and SPSR. */ + PUSH {lr} + MRS lr, SPSR + PUSH {lr} + + /* Change to supervisor mode to allow reentry. */ + CPS #0x13 + + /* Push used registers. */ + PUSH {r0-r3, r12} + + /* Increment nesting count. r3 holds the address of ulPortInterruptNesting + for future use. r1 holds the original ulPortInterruptNesting value for + future use. */ + LDR r3, ulPortInterruptNestingConst + LDR r1, [r3] + ADD r0, r1, #1 + STR r0, [r3] + + /* Ensure bit 2 of the stack pointer is clear. r2 holds the bit 2 value for + future use. */ + MOV r0, sp + AND r2, r0, #4 + SUB sp, sp, r2 + + /* Call the interrupt handler. */ + PUSH {r0-r3, lr} + LDR r1, vApplicationIRQHandlerConst + BLX r1 + POP {r0-r3, lr} + ADD sp, sp, r2 + + CPSID i + DSB + ISB + + /* Write to the EOI register. */ + LDR r0, ulICCEOIRConst + LDR r2, [r0] + STR r0, [r2] + + /* Restore the old nesting count. */ + STR r1, [r3] + + /* A context switch is never performed if the nesting count is not 0. */ + CMP r1, #0 + BNE exit_without_switch + + /* Did the interrupt request a context switch? r1 holds the address of + ulPortYieldRequired and r0 the value of ulPortYieldRequired for future + use. */ + LDR r1, ulPortYieldRequiredConst + LDR r0, [r1] + CMP r0, #0 + BNE switch_before_exit + +exit_without_switch: + /* No context switch. Restore used registers, LR_irq and SPSR before + returning. */ + POP {r0-r3, r12} + CPS #IRQ_MODE + POP {LR} + MSR SPSR_cxsf, LR + POP {LR} + MOVS PC, LR + +switch_before_exit: + /* A context swtich is to be performed. Clear the context switch pending + flag. */ + MOV r0, #0 + STR r0, [r1] + + /* Restore used registers, LR-irq and SPSR before saving the context + to the task stack. */ + POP {r0-r3, r12} + CPS #IRQ_MODE + POP {LR} + MSR SPSR_cxsf, LR + POP {LR} + portSAVE_CONTEXT + + /* Call the function that selects the new task to execute. + vTaskSwitchContext() if vTaskSwitchContext() uses LDRD or STRD + instructions, or 8 byte aligned stack allocated data. LR does not need + saving as a new LR will be loaded by portRESTORE_CONTEXT anyway. */ + LDR R0, vTaskSwitchContextConst + BLX R0 + + /* Restore the context of, and branch to, the task selected to execute + next. */ + portRESTORE_CONTEXT + +ulICCEOIRConst: .word ulICCEOIR +pxCurrentTCBConst: .word pxCurrentTCB +ulCriticalNestingConst: .word ulCriticalNesting +ulPortTaskHasFPUContextConst: .word ulPortTaskHasFPUContext +vTaskSwitchContextConst: .word vTaskSwitchContext +vApplicationIRQHandlerConst: .word vApplicationIRQHandler +ulPortInterruptNestingConst: .word ulPortInterruptNesting +ulPortYieldRequiredConst: .word ulPortYieldRequired + +.end + + + + + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Wiced_CY/portmacro.h b/FreeRTOS/Source/portable/ThirdParty/GCC/Wiced_CY/portmacro.h new file mode 100755 index 0000000..8c4aee3 --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Wiced_CY/portmacro.h @@ -0,0 +1,179 @@ +/* + * FreeRTOS Kernel V10.2.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus + extern "C" { +#endif + +/*----------------------------------------------------------- + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the given hardware + * and compiler. + * + * These settings should not be altered. + *----------------------------------------------------------- + */ + +/* Type definitions. */ +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +typedef uint32_t TickType_t; +#define portMAX_DELAY ( TickType_t ) 0xffffffffUL + +/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do +not need to be guarded with a critical section. */ +#define portTICK_TYPE_IS_ATOMIC 1 + +/*-----------------------------------------------------------*/ + +/* Hardware specifics. */ +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 + +/*-----------------------------------------------------------*/ + +/* Task utilities. */ + +/* Called at the end of an ISR that can cause a context switch. */ +#define portEND_SWITCHING_ISR( xSwitchRequired )\ +{ \ +extern volatile uint32_t ulPortYieldRequired; \ + \ + if( xSwitchRequired != pdFALSE ) \ + { \ + ulPortYieldRequired = pdTRUE; \ + } \ +} + +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) +#define portYIELD() __asm volatile ( "SWI 0 \n" \ + "ISB " ); + + +/*----------------------------------------------------------- + * Critical section control + *----------------------------------------------------------*/ + +extern void vPortEnterCritical( void ); +extern void vPortExitCritical( void ); +extern uint32_t ulPortSetInterruptMask( void ); +extern void vPortClearInterruptMask( uint32_t ulNewMaskValue ); +extern void vPortInstallFreeRTOSVectorTable( void ); + +/* The I bit within the CPSR. */ +#define portINTERRUPT_ENABLE_BIT ( 1 << 7 ) + +/* In the absence of a priority mask register, these functions and macros +globally enable and disable interrupts. */ +#define portENTER_CRITICAL() vPortEnterCritical(); +#define portEXIT_CRITICAL() vPortExitCritical(); +#define portENABLE_INTERRUPTS() __asm volatile ( "CPSIE i \n" ); +#define portDISABLE_INTERRUPTS() __asm volatile ( "CPSID i \n" \ + "DSB \n" \ + "ISB " ); + +__attribute__( ( always_inline ) ) static __inline uint32_t portINLINE_SET_INTERRUPT_MASK_FROM_ISR( void ) +{ +volatile uint32_t ulCPSR; + + __asm volatile ( "MRS %0, CPSR" : "=r" (ulCPSR) ); + ulCPSR &= portINTERRUPT_ENABLE_BIT; + portDISABLE_INTERRUPTS(); + return ulCPSR; +} + +#define portSET_INTERRUPT_MASK_FROM_ISR() portINLINE_SET_INTERRUPT_MASK_FROM_ISR() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) if( x == 0 ) portENABLE_INTERRUPTS() + +/*-----------------------------------------------------------*/ + +/* Task function macros as described on the FreeRTOS.org WEB site. These are +not required for this port but included in case common demo code that uses these +macros is used. */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) + +/* Tickless idle/low power functionality. */ +#ifndef portSUPPRESS_TICKS_AND_SLEEP + extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ); + #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime ) +#endif + +/* Prototype of the FreeRTOS tick handler. This must be installed as the +handler for whichever peripheral is used to generate the RTOS tick. */ +void FreeRTOS_Tick_Handler( void ); + +/* Any task that uses the floating point unit MUST call vPortTaskUsesFPU() +before any floating point instructions are executed. */ +void vPortTaskUsesFPU( void ); +#define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU() + +#define portLOWEST_INTERRUPT_PRIORITY ( ( ( uint32_t ) configUNIQUE_INTERRUPT_PRIORITIES ) - 1UL ) +#define portLOWEST_USABLE_INTERRUPT_PRIORITY ( portLOWEST_INTERRUPT_PRIORITY - 1UL ) + +/* Architecture specific optimisations. */ +#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION + #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +#endif + +#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 + + /* Store/clear the ready priorities in a bit map. */ + #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) ) + #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) ) + + /*-----------------------------------------------------------*/ + + #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - ( uint32_t ) __builtin_clz( uxReadyPriorities ) ) + +#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ + +#define portNOP() __asm volatile( "NOP" ) +#define portINLINE __inline + +#ifdef __cplusplus + } /* extern C */ +#endif + + +#endif /* PORTMACRO_H */ + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/FreeRTOS-openocd.c b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/FreeRTOS-openocd.c new file mode 100755 index 0000000..2367d82 --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/FreeRTOS-openocd.c @@ -0,0 +1,24 @@ +/* + * Since at least FreeRTOS V7.5.3 uxTopUsedPriority is no longer + * present in the kernel, so it has to be supplied by other means for + * OpenOCD's threads awareness. + * + * Add this file to your project, and, if you're using --gc-sections, + * ``--undefined=uxTopUsedPriority'' (or + * ``-Wl,--undefined=uxTopUsedPriority'' when using gcc for final + * linking) to your LDFLAGS; same with all the other symbols you need. + */ + +#include "FreeRTOS.h" +#include "esp_attr.h" +#include "sdkconfig.h" + +#ifdef __GNUC__ +#define USED __attribute__((used)) +#else +#define USED +#endif + +#ifdef CONFIG_ESP32_DEBUG_OCDAWARE +const int USED DRAM_ATTR uxTopUsedPriority = configMAX_PRIORITIES - 1; +#endif diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/portbenchmark.h b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/portbenchmark.h new file mode 100755 index 0000000..4ce41d3 --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/portbenchmark.h @@ -0,0 +1,46 @@ +/******************************************************************************* +// Copyright (c) 2003-2015 Cadence Design Systems, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------------------- +*/ + +/* + * This utility helps benchmarking interrupt latency and context switches. + * In order to enable it, set configBENCHMARK to 1 in FreeRTOSConfig.h. + * You will also need to download the FreeRTOS_trace patch that contains + * portbenchmark.c and the complete version of portbenchmark.h + */ + +#ifndef PORTBENCHMARK_H +#define PORTBENCHMARK_H + +#if configBENCHMARK + #error "You need to download the FreeRTOS_trace patch that overwrites this file" +#endif + +#define portbenchmarkINTERRUPT_DISABLE() +#define portbenchmarkINTERRUPT_RESTORE(newstate) +#define portbenchmarkIntLatency() +#define portbenchmarkIntWait() +#define portbenchmarkReset() +#define portbenchmarkPrint() + +#endif /* PORTBENCHMARK */ diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/portmacro.h b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/portmacro.h new file mode 100755 index 0000000..d22318c --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/portmacro.h @@ -0,0 +1,462 @@ +/* + FreeRTOS V8.2.0 - Copyright (C) 2015 Real Time Engineers Ltd. + All rights reserved + + VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. + + *************************************************************************** + * * + * FreeRTOS provides completely free yet professionally developed, * + * robust, strictly quality controlled, supported, and cross * + * platform software that has become a de facto standard. * + * * + * Help yourself get started quickly and support the FreeRTOS * + * project by purchasing a FreeRTOS tutorial book, reference * + * manual, or both from: http://www.FreeRTOS.org/Documentation * + * * + * Thank you! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. + + >>! NOTE: The modification to the GPL is included to allow you to !<< + >>! distribute a combined work that includes FreeRTOS without being !<< + >>! obliged to provide the source code for proprietary components !<< + >>! outside of the FreeRTOS kernel. !<< + + FreeRTOS 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. Full license text is available from the following + link: http://www.freertos.org/a00114.html + + 1 tab == 4 spaces! + + *************************************************************************** + * * + * Having a problem? Start by reading the FAQ "My application does * + * not run, what could be wrong?" * + * * + * http://www.FreeRTOS.org/FAQHelp.html * + * * + *************************************************************************** + + http://www.FreeRTOS.org - Documentation, books, training, latest versions, + license and Real Time Engineers Ltd. contact details. + + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, + including FreeRTOS+Trace - an indispensable productivity tool, a DOS + compatible FAT file system, and our tiny thread aware UDP/IP stack. + + http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High + Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS + licenses offer ticketed support, indemnification and middleware. + + http://www.SafeRTOS.com - High Integrity Systems also provide a safety + engineered and independently SIL3 certified version for use in safety and + mission critical applications that require provable dependability. + + 1 tab == 4 spaces! +*/ + +#ifndef PORTMACRO_H +#define PORTMACRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __ASSEMBLER__ + +#include + +#include +#include +#include /* required for XSHAL_CLIB */ +#include +#include "esp_timer.h" /* required for FreeRTOS run time stats */ +#include "esp_system.h" + + +#include +#include "soc/soc_memory_layout.h" + +//#include "xtensa_context.h" + +/*----------------------------------------------------------- + * Port specific definitions. + * + * The settings in this file configure FreeRTOS correctly for the + * given hardware and compiler. + * + * These settings should not be altered. + *----------------------------------------------------------- + */ + +/* Type definitions. */ + +#define portCHAR int8_t +#define portFLOAT float +#define portDOUBLE double +#define portLONG int32_t +#define portSHORT int16_t +#define portSTACK_TYPE uint8_t +#define portBASE_TYPE int + +typedef portSTACK_TYPE StackType_t; +typedef portBASE_TYPE BaseType_t; +typedef unsigned portBASE_TYPE UBaseType_t; + +#if( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL +#endif +/*-----------------------------------------------------------*/ + +// portbenchmark +#include "portbenchmark.h" + +#include "sdkconfig.h" +#include "esp_attr.h" + +/* "mux" data structure (spinlock) */ +typedef struct { + /* owner field values: + * 0 - Uninitialized (invalid) + * portMUX_FREE_VAL - Mux is free, can be locked by either CPU + * CORE_ID_PRO / CORE_ID_APP - Mux is locked to the particular core + * + * Any value other than portMUX_FREE_VAL, CORE_ID_PRO, CORE_ID_APP indicates corruption + */ + uint32_t owner; + /* count field: + * If mux is unlocked, count should be zero. + * If mux is locked, count is non-zero & represents the number of recursive locks on the mux. + */ + uint32_t count; +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG + const char *lastLockedFn; + int lastLockedLine; +#endif +} portMUX_TYPE; + +#define portMUX_FREE_VAL 0xB33FFFFF + +/* Special constants for vPortCPUAcquireMutexTimeout() */ +#define portMUX_NO_TIMEOUT (-1) /* When passed for 'timeout_cycles', spin forever if necessary */ +#define portMUX_TRY_LOCK 0 /* Try to acquire the spinlock a single time only */ + +// Keep this in sync with the portMUX_TYPE struct definition please. +#ifndef CONFIG_FREERTOS_PORTMUX_DEBUG +#define portMUX_INITIALIZER_UNLOCKED { \ + .owner = portMUX_FREE_VAL, \ + .count = 0, \ + } +#else +#define portMUX_INITIALIZER_UNLOCKED { \ + .owner = portMUX_FREE_VAL, \ + .count = 0, \ + .lastLockedFn = "(never locked)", \ + .lastLockedLine = -1 \ + } +#endif + + +#define portASSERT_IF_IN_ISR() vPortAssertIfInISR() +void vPortAssertIfInISR(); + +#define portCRITICAL_NESTING_IN_TCB 1 + +/* +Modifications to portENTER_CRITICAL. + +For an introduction, see "Critical Sections & Disabling Interrupts" in docs/api-guides/freertos-smp.rst + +The original portENTER_CRITICAL only disabled the ISRs. This is enough for single-CPU operation: by +disabling the interrupts, there is no task switch so no other tasks can meddle in the data, and because +interrupts are disabled, ISRs can't corrupt data structures either. + +For multiprocessing, things get a bit more hairy. First of all, disabling the interrupts doesn't stop +the tasks or ISRs on the other processors meddling with our CPU. For tasks, this is solved by adding +a spinlock to the portENTER_CRITICAL macro. A task running on the other CPU accessing the same data will +spinlock in the portENTER_CRITICAL code until the first CPU is done. + +For ISRs, we now also need muxes: while portENTER_CRITICAL disabling interrupts will stop ISRs on the same +CPU from meddling with the data, it does not stop interrupts on the other cores from interfering with the +data. For this, we also use a spinlock in the routines called by the ISR, but these spinlocks +do not disable the interrupts (because they already are). + +This all assumes that interrupts are either entirely disabled or enabled. Interrupt priority levels +will break this scheme. + +Remark: For the ESP32, portENTER_CRITICAL and portENTER_CRITICAL_ISR both alias vTaskEnterCritical, meaning +that either function can be called both from ISR as well as task context. This is not standard FreeRTOS +behaviour; please keep this in mind if you need any compatibility with other FreeRTOS implementations. +*/ +void vPortCPUInitializeMutex(portMUX_TYPE *mux); +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG +#error CONFIG_FREERTOS_PORTMUX_DEBUG not supported in Amazon FreeRTOS +#endif + +void vTaskExitCritical(); +void vTaskEnterCritical(); +static inline void vPortConsumeSpinlockArg(int unused, ...) +{ +} + +/** @brief Acquire a portmux spinlock with a timeout + * + * @param mux Pointer to portmux to acquire. + * @param timeout_cycles Timeout to spin, in CPU cycles. Pass portMUX_NO_TIMEOUT to wait forever, + * portMUX_TRY_LOCK to try a single time to acquire the lock. + * + * @return true if mutex is successfully acquired, false on timeout. + */ +bool vPortCPUAcquireMutexTimeout(portMUX_TYPE *mux, int timeout_cycles); +void vPortCPUReleaseMutex(portMUX_TYPE *mux); + +#define portENTER_CRITICAL(...) do { vTaskEnterCritical(); vPortConsumeSpinlockArg(0, ##__VA_ARGS__); } while(0) +#define portEXIT_CRITICAL(...) do { vTaskExitCritical(); vPortConsumeSpinlockArg(0, ##__VA_ARGS__); } while(0) + + +#define portENTER_CRITICAL_ISR(mux) vPortCPUAcquireMutexTimeout(mux, portMUX_NO_TIMEOUT) +#define portEXIT_CRITICAL_ISR(mux) vPortCPUReleaseMutex(mux) + +#define portENTER_CRITICAL_SAFE(mux) do { \ + if (xPortInIsrContext()) { \ + portENTER_CRITICAL_ISR(mux); \ + } else { \ + portENTER_CRITICAL(mux); \ + } \ + } while(0) + +#define portEXIT_CRITICAL_SAFE(mux) do { \ + if (xPortInIsrContext()) { \ + portEXIT_CRITICAL_ISR(mux); \ + } else { \ + portEXIT_CRITICAL(mux); \ + } \ + } while(0) + + +// Critical section management. NW-TODO: replace XTOS_SET_INTLEVEL with more efficient version, if any? +// These cannot be nested. They should be used with a lot of care and cannot be called from interrupt level. +// +// Only applies to one CPU. See notes above & below for reasons not to use these. +#define portDISABLE_INTERRUPTS() do { XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL); portbenchmarkINTERRUPT_DISABLE(); } while (0) +#define portENABLE_INTERRUPTS() do { portbenchmarkINTERRUPT_RESTORE(0); XTOS_SET_INTLEVEL(0); } while (0) + +// Cleaner solution allows nested interrupts disabling and restoring via local registers or stack. +// They can be called from interrupts too. +// WARNING: Only applies to current CPU. See notes above. +static inline unsigned portENTER_CRITICAL_NESTED() { + unsigned state = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL); + portbenchmarkINTERRUPT_DISABLE(); + return state; +} +#define portEXIT_CRITICAL_NESTED(state) do { portbenchmarkINTERRUPT_RESTORE(state); XTOS_RESTORE_JUST_INTLEVEL(state); } while (0) + +// These FreeRTOS versions are similar to the nested versions above +#define portSET_INTERRUPT_MASK_FROM_ISR() portENTER_CRITICAL_NESTED() +#define portCLEAR_INTERRUPT_MASK_FROM_ISR(state) portEXIT_CRITICAL_NESTED(state) + +//Because the ROM routines don't necessarily handle a stack in external RAM correctly, we force +//the stack memory to always be internal. +#define pvPortMallocTcbMem(size) heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT) +#define pvPortMallocStackMem(size) heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT) + +//xTaskCreateStatic uses these functions to check incoming memory. +#define portVALID_TCB_MEM(ptr) (esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr)) +#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY +#define portVALID_STACK_MEM(ptr) esp_ptr_byte_accessible(ptr) +#else +#define portVALID_STACK_MEM(ptr) (esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr)) +#endif + +/* + * Wrapper for the Xtensa compare-and-set instruction. This subroutine will atomically compare + * *addr to 'compare'. If *addr == compare, *addr is set to *set. *set is updated with the previous + * value of *addr (either 'compare' or some other value.) + * + * Warning: From the ISA docs: in some (unspecified) cases, the s32c1i instruction may return the + * *bitwise inverse* of the old mem if the mem wasn't written. This doesn't seem to happen on the + * ESP32 (portMUX assertions would fail). + */ +static inline void uxPortCompareSet(volatile uint32_t *addr, uint32_t compare, uint32_t *set) { + __asm__ __volatile__ ( + "WSR %2,SCOMPARE1 \n" + "S32C1I %0, %1, 0 \n" + :"=r"(*set) + :"r"(addr), "r"(compare), "0"(*set) + ); +} + +void uxPortCompareSetExtram(volatile uint32_t *addr, uint32_t compare, uint32_t *set); + +/*-----------------------------------------------------------*/ + +/* Architecture specifics. */ +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 4 +#define portNOP() XT_NOP() +/*-----------------------------------------------------------*/ + +/* Fine resolution time */ +#define portGET_RUN_TIME_COUNTER_VALUE() xthal_get_ccount() +//ccount or esp_timer are initialized elsewhere +#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() + +#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER +/* Coarse resolution time (us) */ +#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) x = (uint32_t)esp_timer_get_time() +#endif + + + +/* Kernel utilities. */ +void vPortYield( void ); +void _frxt_setup_switch( void ); +#define portYIELD() vPortYield() +#define portYIELD_FROM_ISR() {traceISR_EXIT_TO_SCHEDULER(); _frxt_setup_switch();} + +static inline uint32_t xPortGetCoreID(); + +/*-----------------------------------------------------------*/ + +/* Task function macros as described on the FreeRTOS.org WEB site. */ +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) + +// When coprocessors are defined, we to maintain a pointer to coprocessors area. +// We currently use a hack: redefine field xMPU_SETTINGS in TCB block as a structure that can hold: +// MPU wrappers, coprocessor area pointer, trace code structure, and more if needed. +// The field is normally used for memory protection. FreeRTOS should create another general purpose field. +typedef struct { + #if XCHAL_CP_NUM > 0 + volatile StackType_t* coproc_area; // Pointer to coprocessor save area; MUST BE FIRST + #endif + + #if portUSING_MPU_WRAPPERS + // Define here mpu_settings, which is port dependent + int mpu_setting; // Just a dummy example here; MPU not ported to Xtensa yet + #endif + + #if configUSE_TRACE_FACILITY_2 + struct { + // Cf. porttraceStamp() + int taskstamp; /* Stamp from inside task to see where we are */ + int taskstampcount; /* A counter usually incremented when we restart the task's loop */ + } porttrace; + #endif +} xMPU_SETTINGS; + +// Main hack to use MPU_wrappers even when no MPU is defined (warning: mpu_setting should not be accessed; otherwise move this above xMPU_SETTINGS) +#if (XCHAL_CP_NUM > 0 || configUSE_TRACE_FACILITY_2) && !portUSING_MPU_WRAPPERS // If MPU wrappers not used, we still need to allocate coproc area + #undef portUSING_MPU_WRAPPERS + #define portUSING_MPU_WRAPPERS 1 // Enable it to allocate coproc area + #define MPU_WRAPPERS_H // Override mpu_wrapper.h to disable unwanted code + #define PRIVILEGED_FUNCTION + #define PRIVILEGED_DATA +#endif + +bool vApplicationSleep( TickType_t xExpectedIdleTime ); + +#define portSUPPRESS_TICKS_AND_SLEEP( idleTime ) vApplicationSleep( idleTime ) + + + +void _xt_coproc_release(volatile void * coproc_sa_base); + + +/* + * Map to the memory management routines required for the port. + * + * Note that libc standard malloc/free are also available for + * non-FreeRTOS-specific code, and behave the same as + * pvPortMalloc()/vPortFree(). + */ +#define pvPortMalloc heap_caps_malloc_default +#define vPortFree heap_caps_free +#define xPortGetFreeHeapSize esp_get_free_heap_size +#define xPortGetMinimumEverFreeHeapSize esp_get_minimum_free_heap_size + +/* + * Send an interrupt to another core in order to make the task running + * on it yield for a higher-priority task. + */ + +void vPortYieldOtherCore( BaseType_t coreid) PRIVILEGED_FUNCTION; + + +/* + Callback to set a watchpoint on the end of the stack. Called every context switch to change the stack + watchpoint around. + */ +void vPortSetStackWatchpoint( void* pxStackStart ); + +/* + * Returns true if the current core is in ISR context; low prio ISR, med prio ISR or timer tick ISR. High prio ISRs + * aren't detected here, but they normally cannot call C code, so that should not be an issue anyway. + */ +BaseType_t xPortInIsrContext(); + +/* + * This function will be called in High prio ISRs. Returns true if the current core was in ISR context + * before calling into high prio ISR context. + */ +BaseType_t xPortInterruptedFromISRContext(); + +/* + * The structures and methods of manipulating the MPU are contained within the + * port layer. + * + * Fills the xMPUSettings structure with the memory region information + * contained in xRegions. + */ +#if( portUSING_MPU_WRAPPERS == 1 ) + struct xMEMORY_REGION; + void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t usStackDepth ) PRIVILEGED_FUNCTION; + void vPortReleaseTaskMPUSettings( xMPU_SETTINGS *xMPUSettings ); +#endif + +/* Multi-core: get current core ID */ +static inline uint32_t IRAM_ATTR xPortGetCoreID() { + int id; + asm ( + "rsr.prid %0\n" + " extui %0,%0,13,1" + :"=r"(id)); + return id; +} + +/* Get tick rate per second */ +uint32_t xPortGetTickRateHz(void); + +// porttrace +#if configUSE_TRACE_FACILITY_2 +#include "porttrace.h" +#endif + +// configASSERT_2 if requested +#if configASSERT_2 +#include +void exit(int); +#define configASSERT( x ) if (!(x)) { porttracePrint(-1); printf("\nAssertion failed in %s:%d\n", __FILE__, __LINE__); exit(-1); } +#endif + +#endif // __ASSEMBLER__ + +#ifdef __cplusplus +} +#endif + +#endif /* PORTMACRO_H */ + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_api.h b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_api.h new file mode 100755 index 0000000..19630ce --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_api.h @@ -0,0 +1,130 @@ +/******************************************************************************* +Copyright (c) 2006-2015 Cadence Design Systems Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + +/****************************************************************************** + Xtensa-specific API for RTOS ports. +******************************************************************************/ + +#ifndef __XTENSA_API_H__ +#define __XTENSA_API_H__ + +#include + +#include "xtensa_context.h" + + +/* Typedef for C-callable interrupt handler function */ +typedef void (*xt_handler)(void *); + +/* Typedef for C-callable exception handler function */ +typedef void (*xt_exc_handler)(XtExcFrame *); + + +/* +------------------------------------------------------------------------------- + Call this function to set a handler for the specified exception. The handler + will be installed on the core that calls this function. + + n - Exception number (type) + f - Handler function address, NULL to uninstall handler. + + The handler will be passed a pointer to the exception frame, which is created + on the stack of the thread that caused the exception. + + If the handler returns, the thread context will be restored and the faulting + instruction will be retried. Any values in the exception frame that are + modified by the handler will be restored as part of the context. For details + of the exception frame structure see xtensa_context.h. +------------------------------------------------------------------------------- +*/ +extern xt_exc_handler xt_set_exception_handler(int n, xt_exc_handler f); + + +/* +------------------------------------------------------------------------------- + Call this function to set a handler for the specified interrupt. The handler + will be installed on the core that calls this function. + + n - Interrupt number. + f - Handler function address, NULL to uninstall handler. + arg - Argument to be passed to handler. +------------------------------------------------------------------------------- +*/ +extern xt_handler xt_set_interrupt_handler(int n, xt_handler f, void * arg); + + +/* +------------------------------------------------------------------------------- + Call this function to enable the specified interrupts on the core that runs + this code. + + mask - Bit mask of interrupts to be enabled. +------------------------------------------------------------------------------- +*/ +extern void xt_ints_on(unsigned int mask); + + +/* +------------------------------------------------------------------------------- + Call this function to disable the specified interrupts on the core that runs + this code. + + mask - Bit mask of interrupts to be disabled. +------------------------------------------------------------------------------- +*/ +extern void xt_ints_off(unsigned int mask); + + +/* +------------------------------------------------------------------------------- + Call this function to set the specified (s/w) interrupt. +------------------------------------------------------------------------------- +*/ +static inline void xt_set_intset(unsigned int arg) +{ + xthal_set_intset(arg); +} + + +/* +------------------------------------------------------------------------------- + Call this function to clear the specified (s/w or edge-triggered) + interrupt. +------------------------------------------------------------------------------- +*/ +static inline void xt_set_intclear(unsigned int arg) +{ + xthal_set_intclear(arg); +} + +/* +------------------------------------------------------------------------------- + Call this function to get handler's argument for the specified interrupt. + + n - Interrupt number. +------------------------------------------------------------------------------- +*/ +extern void * xt_get_interrupt_handler_arg(int n); + +#endif /* __XTENSA_API_H__ */ + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_config.h b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_config.h new file mode 100755 index 0000000..58baee2 --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_config.h @@ -0,0 +1,146 @@ +/******************************************************************************* +// Copyright (c) 2003-2015 Cadence Design Systems, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------------------- + + Configuration-specific information for Xtensa build. This file must be + included in FreeRTOSConfig.h to properly set up the config-dependent + parameters correctly. + + NOTE: To enable thread-safe C library support, XT_USE_THREAD_SAFE_CLIB must + be defined to be > 0 somewhere above or on the command line. + +*******************************************************************************/ + +#ifndef XTENSA_CONFIG_H +#define XTENSA_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include /* required for XSHAL_CLIB */ + +#include "xtensa_context.h" + + +/*----------------------------------------------------------------------------- +* STACK REQUIREMENTS +* +* This section defines the minimum stack size, and the extra space required to +* be allocated for saving coprocessor state and/or C library state information +* (if thread safety is enabled for the C library). The sizes are in bytes. +* +* Stack sizes for individual tasks should be derived from these minima based on +* the maximum call depth of the task and the maximum level of interrupt nesting. +* A minimum stack size is defined by XT_STACK_MIN_SIZE. This minimum is based +* on the requirement for a task that calls nothing else but can be interrupted. +* This assumes that interrupt handlers do not call more than a few levels deep. +* If this is not true, i.e. one or more interrupt handlers make deep calls then +* the minimum must be increased. +* +* If the Xtensa processor configuration includes coprocessors, then space is +* allocated to save the coprocessor state on the stack. +* +* If thread safety is enabled for the C runtime library, (XT_USE_THREAD_SAFE_CLIB +* is defined) then space is allocated to save the C library context in the TCB. +* +* Allocating insufficient stack space is a common source of hard-to-find errors. +* During development, it is best to enable the FreeRTOS stack checking features. +* +* Usage: +* +* XT_USE_THREAD_SAFE_CLIB -- Define this to a nonzero value to enable thread-safe +* use of the C library. This will require extra stack +* space to be allocated for tasks that use the C library +* reentrant functions. See below for more information. +* +* NOTE: The Xtensa toolchain supports multiple C libraries and not all of them +* support thread safety. Check your core configuration to see which C library +* was chosen for your system. +* +* XT_STACK_MIN_SIZE -- The minimum stack size for any task. It is recommended +* that you do not use a stack smaller than this for any +* task. In case you want to use stacks smaller than this +* size, you must verify that the smaller size(s) will work +* under all operating conditions. +* +* XT_STACK_EXTRA -- The amount of extra stack space to allocate for a task +* that does not make C library reentrant calls. Add this +* to the amount of stack space required by the task itself. +* +* XT_STACK_EXTRA_CLIB -- The amount of space to allocate for C library state. +* +-----------------------------------------------------------------------------*/ + +/* Extra space required for interrupt/exception hooks. */ +#ifdef XT_INTEXC_HOOKS + #ifdef __XTENSA_CALL0_ABI__ + #define STK_INTEXC_EXTRA 0x200 + #else + #define STK_INTEXC_EXTRA 0x180 + #endif +#else + #define STK_INTEXC_EXTRA 0 +#endif + +#define XT_CLIB_CONTEXT_AREA_SIZE 0 + +/*------------------------------------------------------------------------------ + Extra size -- interrupt frame plus coprocessor save area plus hook space. + NOTE: Make sure XT_INTEXC_HOOKS is undefined unless you really need the hooks. +------------------------------------------------------------------------------*/ +#ifdef __XTENSA_CALL0_ABI__ + #define XT_XTRA_SIZE (XT_STK_FRMSZ + STK_INTEXC_EXTRA + 0x10 + XT_CP_SIZE) +#else + #define XT_XTRA_SIZE (XT_STK_FRMSZ + STK_INTEXC_EXTRA + 0x20 + XT_CP_SIZE) +#endif + +/*------------------------------------------------------------------------------ + Space allocated for user code -- function calls and local variables. + NOTE: This number can be adjusted to suit your needs. You must verify that the + amount of space you reserve is adequate for the worst-case conditions in your + application. + NOTE: The windowed ABI requires more stack, since space has to be reserved + for spilling register windows. +------------------------------------------------------------------------------*/ +#ifdef __XTENSA_CALL0_ABI__ + #define XT_USER_SIZE 0x200 +#else + #define XT_USER_SIZE 0x400 +#endif + +/* Minimum recommended stack size. */ +#define XT_STACK_MIN_SIZE ((XT_XTRA_SIZE + XT_USER_SIZE) / sizeof(unsigned char)) + +/* OS overhead with and without C library thread context. */ +#define XT_STACK_EXTRA (XT_XTRA_SIZE) +#define XT_STACK_EXTRA_CLIB (XT_XTRA_SIZE + XT_CLIB_CONTEXT_AREA_SIZE) + + +#ifdef __cplusplus +} +#endif + +#endif /* XTENSA_CONFIG_H */ + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_context.h b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_context.h new file mode 100755 index 0000000..9e6fe55 --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_context.h @@ -0,0 +1,378 @@ +/******************************************************************************* +Copyright (c) 2006-2015 Cadence Design Systems Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------------------- + + XTENSA CONTEXT FRAMES AND MACROS FOR RTOS ASSEMBLER SOURCES + +This header contains definitions and macros for use primarily by Xtensa +RTOS assembly coded source files. It includes and uses the Xtensa hardware +abstraction layer (HAL) to deal with config specifics. It may also be +included in C source files. + +!! Supports only Xtensa Exception Architecture 2 (XEA2). XEA1 not supported. !! + +NOTE: The Xtensa architecture requires stack pointer alignment to 16 bytes. + +*******************************************************************************/ + +#ifndef XTENSA_CONTEXT_H +#define XTENSA_CONTEXT_H + +#ifdef __ASSEMBLER__ +#include +#endif + +#include +#include +#include +#include + + +/* Align a value up to nearest n-byte boundary, where n is a power of 2. */ +#define ALIGNUP(n, val) (((val) + (n)-1) & -(n)) + + +/* +------------------------------------------------------------------------------- + Macros that help define structures for both C and assembler. +------------------------------------------------------------------------------- +*/ + +#ifdef STRUCT_BEGIN +#undef STRUCT_BEGIN +#undef STRUCT_FIELD +#undef STRUCT_AFIELD +#undef STRUCT_END +#endif + +#if defined(_ASMLANGUAGE) || defined(__ASSEMBLER__) + +#define STRUCT_BEGIN .pushsection .text; .struct 0 +#define STRUCT_FIELD(ctype,size,asname,name) asname: .space size +#define STRUCT_AFIELD(ctype,size,asname,name,n) asname: .space (size)*(n) +#define STRUCT_END(sname) sname##Size:; .popsection + +#else + +#define STRUCT_BEGIN typedef struct { +#define STRUCT_FIELD(ctype,size,asname,name) ctype name; +#define STRUCT_AFIELD(ctype,size,asname,name,n) ctype name[n]; +#define STRUCT_END(sname) } sname; + +#endif //_ASMLANGUAGE || __ASSEMBLER__ + + +/* +------------------------------------------------------------------------------- + INTERRUPT/EXCEPTION STACK FRAME FOR A THREAD OR NESTED INTERRUPT + + A stack frame of this structure is allocated for any interrupt or exception. + It goes on the current stack. If the RTOS has a system stack for handling + interrupts, every thread stack must allow space for just one interrupt stack + frame, then nested interrupt stack frames go on the system stack. + + The frame includes basic registers (explicit) and "extra" registers introduced + by user TIE or the use of the MAC16 option in the user's Xtensa config. + The frame size is minimized by omitting regs not applicable to user's config. + + For Windowed ABI, this stack frame includes the interruptee's base save area, + another base save area to manage gcc nested functions, and a little temporary + space to help manage the spilling of the register windows. +------------------------------------------------------------------------------- +*/ + +STRUCT_BEGIN +STRUCT_FIELD (long, 4, XT_STK_EXIT, exit) /* exit point for dispatch */ +STRUCT_FIELD (long, 4, XT_STK_PC, pc) /* return PC */ +STRUCT_FIELD (long, 4, XT_STK_PS, ps) /* return PS */ +STRUCT_FIELD (long, 4, XT_STK_A0, a0) +STRUCT_FIELD (long, 4, XT_STK_A1, a1) /* stack pointer before interrupt */ +STRUCT_FIELD (long, 4, XT_STK_A2, a2) +STRUCT_FIELD (long, 4, XT_STK_A3, a3) +STRUCT_FIELD (long, 4, XT_STK_A4, a4) +STRUCT_FIELD (long, 4, XT_STK_A5, a5) +STRUCT_FIELD (long, 4, XT_STK_A6, a6) +STRUCT_FIELD (long, 4, XT_STK_A7, a7) +STRUCT_FIELD (long, 4, XT_STK_A8, a8) +STRUCT_FIELD (long, 4, XT_STK_A9, a9) +STRUCT_FIELD (long, 4, XT_STK_A10, a10) +STRUCT_FIELD (long, 4, XT_STK_A11, a11) +STRUCT_FIELD (long, 4, XT_STK_A12, a12) +STRUCT_FIELD (long, 4, XT_STK_A13, a13) +STRUCT_FIELD (long, 4, XT_STK_A14, a14) +STRUCT_FIELD (long, 4, XT_STK_A15, a15) +STRUCT_FIELD (long, 4, XT_STK_SAR, sar) +STRUCT_FIELD (long, 4, XT_STK_EXCCAUSE, exccause) +STRUCT_FIELD (long, 4, XT_STK_EXCVADDR, excvaddr) +#if XCHAL_HAVE_LOOPS +STRUCT_FIELD (long, 4, XT_STK_LBEG, lbeg) +STRUCT_FIELD (long, 4, XT_STK_LEND, lend) +STRUCT_FIELD (long, 4, XT_STK_LCOUNT, lcount) +#endif +#ifndef __XTENSA_CALL0_ABI__ +/* Temporary space for saving stuff during window spill */ +STRUCT_FIELD (long, 4, XT_STK_TMP0, tmp0) +STRUCT_FIELD (long, 4, XT_STK_TMP1, tmp1) +STRUCT_FIELD (long, 4, XT_STK_TMP2, tmp2) +#endif +#ifdef XT_USE_SWPRI +/* Storage for virtual priority mask */ +STRUCT_FIELD (long, 4, XT_STK_VPRI, vpri) +#endif +#ifdef XT_USE_OVLY +/* Storage for overlay state */ +STRUCT_FIELD (long, 4, XT_STK_OVLY, ovly) +#endif +STRUCT_END(XtExcFrame) + +#if defined(_ASMLANGUAGE) || defined(__ASSEMBLER__) +#define XT_STK_NEXT1 XtExcFrameSize +#else +#define XT_STK_NEXT1 sizeof(XtExcFrame) +#endif + +/* Allocate extra storage if needed */ +#if XCHAL_EXTRA_SA_SIZE != 0 + +#if XCHAL_EXTRA_SA_ALIGN <= 16 +#define XT_STK_EXTRA ALIGNUP(XCHAL_EXTRA_SA_ALIGN, XT_STK_NEXT1) +#else +/* If need more alignment than stack, add space for dynamic alignment */ +#define XT_STK_EXTRA (ALIGNUP(XCHAL_EXTRA_SA_ALIGN, XT_STK_NEXT1) + XCHAL_EXTRA_SA_ALIGN) +#endif +#define XT_STK_NEXT2 (XT_STK_EXTRA + XCHAL_EXTRA_SA_SIZE) + +#else + +#define XT_STK_NEXT2 XT_STK_NEXT1 + +#endif + +/* +------------------------------------------------------------------------------- + This is the frame size. Add space for 4 registers (interruptee's base save + area) and some space for gcc nested functions if any. +------------------------------------------------------------------------------- +*/ +#define XT_STK_FRMSZ (ALIGNUP(0x10, XT_STK_NEXT2) + 0x20) + + +/* +------------------------------------------------------------------------------- + SOLICITED STACK FRAME FOR A THREAD + + A stack frame of this structure is allocated whenever a thread enters the + RTOS kernel intentionally (and synchronously) to submit to thread scheduling. + It goes on the current thread's stack. + + The solicited frame only includes registers that are required to be preserved + by the callee according to the compiler's ABI conventions, some space to save + the return address for returning to the caller, and the caller's PS register. + + For Windowed ABI, this stack frame includes the caller's base save area. + + Note on XT_SOL_EXIT field: + It is necessary to distinguish a solicited from an interrupt stack frame. + This field corresponds to XT_STK_EXIT in the interrupt stack frame and is + always at the same offset (0). It can be written with a code (usually 0) + to distinguish a solicted frame from an interrupt frame. An RTOS port may + opt to ignore this field if it has another way of distinguishing frames. +------------------------------------------------------------------------------- +*/ + +STRUCT_BEGIN +#ifdef __XTENSA_CALL0_ABI__ +STRUCT_FIELD (long, 4, XT_SOL_EXIT, exit) +STRUCT_FIELD (long, 4, XT_SOL_PC, pc) +STRUCT_FIELD (long, 4, XT_SOL_PS, ps) +STRUCT_FIELD (long, 4, XT_SOL_NEXT, next) +STRUCT_FIELD (long, 4, XT_SOL_A12, a12) /* should be on 16-byte alignment */ +STRUCT_FIELD (long, 4, XT_SOL_A13, a13) +STRUCT_FIELD (long, 4, XT_SOL_A14, a14) +STRUCT_FIELD (long, 4, XT_SOL_A15, a15) +#else +STRUCT_FIELD (long, 4, XT_SOL_EXIT, exit) +STRUCT_FIELD (long, 4, XT_SOL_PC, pc) +STRUCT_FIELD (long, 4, XT_SOL_PS, ps) +STRUCT_FIELD (long, 4, XT_SOL_NEXT, next) +STRUCT_FIELD (long, 4, XT_SOL_A0, a0) /* should be on 16-byte alignment */ +STRUCT_FIELD (long, 4, XT_SOL_A1, a1) +STRUCT_FIELD (long, 4, XT_SOL_A2, a2) +STRUCT_FIELD (long, 4, XT_SOL_A3, a3) +#endif +STRUCT_END(XtSolFrame) + +/* Size of solicited stack frame */ +#define XT_SOL_FRMSZ ALIGNUP(0x10, XtSolFrameSize) + + +/* +------------------------------------------------------------------------------- + CO-PROCESSOR STATE SAVE AREA FOR A THREAD + + The RTOS must provide an area per thread to save the state of co-processors + when that thread does not have control. Co-processors are context-switched + lazily (on demand) only when a new thread uses a co-processor instruction, + otherwise a thread retains ownership of the co-processor even when it loses + control of the processor. An Xtensa co-processor exception is triggered when + any co-processor instruction is executed by a thread that is not the owner, + and the context switch of that co-processor is then peformed by the handler. + Ownership represents which thread's state is currently in the co-processor. + + Co-processors may not be used by interrupt or exception handlers. If an + co-processor instruction is executed by an interrupt or exception handler, + the co-processor exception handler will trigger a kernel panic and freeze. + This restriction is introduced to reduce the overhead of saving and restoring + co-processor state (which can be quite large) and in particular remove that + overhead from interrupt handlers. + + The co-processor state save area may be in any convenient per-thread location + such as in the thread control block or above the thread stack area. It need + not be in the interrupt stack frame since interrupts don't use co-processors. + + Along with the save area for each co-processor, two bitmasks with flags per + co-processor (laid out as in the CPENABLE reg) help manage context-switching + co-processors as efficiently as possible: + + XT_CPENABLE + The contents of a non-running thread's CPENABLE register. + It represents the co-processors owned (and whose state is still needed) + by the thread. When a thread is preempted, its CPENABLE is saved here. + When a thread solicits a context-swtich, its CPENABLE is cleared - the + compiler has saved the (caller-saved) co-proc state if it needs to. + When a non-running thread loses ownership of a CP, its bit is cleared. + When a thread runs, it's XT_CPENABLE is loaded into the CPENABLE reg. + Avoids co-processor exceptions when no change of ownership is needed. + + XT_CPSTORED + A bitmask with the same layout as CPENABLE, a bit per co-processor. + Indicates whether the state of each co-processor is saved in the state + save area. When a thread enters the kernel, only the state of co-procs + still enabled in CPENABLE is saved. When the co-processor exception + handler assigns ownership of a co-processor to a thread, it restores + the saved state only if this bit is set, and clears this bit. + + XT_CP_CS_ST + A bitmask with the same layout as CPENABLE, a bit per co-processor. + Indicates whether callee-saved state is saved in the state save area. + Callee-saved state is saved by itself on a solicited context switch, + and restored when needed by the coprocessor exception handler. + Unsolicited switches will cause the entire coprocessor to be saved + when necessary. + + XT_CP_ASA + Pointer to the aligned save area. Allows it to be aligned more than + the overall save area (which might only be stack-aligned or TCB-aligned). + Especially relevant for Xtensa cores configured with a very large data + path that requires alignment greater than 16 bytes (ABI stack alignment). +------------------------------------------------------------------------------- +*/ + +#if XCHAL_CP_NUM > 0 + +/* Offsets of each coprocessor save area within the 'aligned save area': */ +#define XT_CP0_SA 0 +#define XT_CP1_SA ALIGNUP(XCHAL_CP1_SA_ALIGN, XT_CP0_SA + XCHAL_CP0_SA_SIZE) +#define XT_CP2_SA ALIGNUP(XCHAL_CP2_SA_ALIGN, XT_CP1_SA + XCHAL_CP1_SA_SIZE) +#define XT_CP3_SA ALIGNUP(XCHAL_CP3_SA_ALIGN, XT_CP2_SA + XCHAL_CP2_SA_SIZE) +#define XT_CP4_SA ALIGNUP(XCHAL_CP4_SA_ALIGN, XT_CP3_SA + XCHAL_CP3_SA_SIZE) +#define XT_CP5_SA ALIGNUP(XCHAL_CP5_SA_ALIGN, XT_CP4_SA + XCHAL_CP4_SA_SIZE) +#define XT_CP6_SA ALIGNUP(XCHAL_CP6_SA_ALIGN, XT_CP5_SA + XCHAL_CP5_SA_SIZE) +#define XT_CP7_SA ALIGNUP(XCHAL_CP7_SA_ALIGN, XT_CP6_SA + XCHAL_CP6_SA_SIZE) +#define XT_CP_SA_SIZE ALIGNUP(16, XT_CP7_SA + XCHAL_CP7_SA_SIZE) + +/* Offsets within the overall save area: */ +#define XT_CPENABLE 0 /* (2 bytes) coprocessors active for this thread */ +#define XT_CPSTORED 2 /* (2 bytes) coprocessors saved for this thread */ +#define XT_CP_CS_ST 4 /* (2 bytes) coprocessor callee-saved regs stored for this thread */ +#define XT_CP_ASA 8 /* (4 bytes) ptr to aligned save area */ +/* Overall size allows for dynamic alignment: */ +#define XT_CP_SIZE (12 + XT_CP_SA_SIZE + XCHAL_TOTAL_SA_ALIGN) +#else +#define XT_CP_SIZE 0 +#endif + + +/* + Macro to get the current core ID. Only uses the reg given as an argument. + Reading PRID on the ESP32 gives us 0xCDCD on the PRO processor (0) + and 0xABAB on the APP CPU (1). We can distinguish between the two by checking + bit 13: it's 1 on the APP and 0 on the PRO processor. +*/ +#ifdef __ASSEMBLER__ + .macro getcoreid reg + rsr.prid \reg + extui \reg,\reg,13,1 + .endm +#endif + +#define CORE_ID_PRO 0xCDCD +#define CORE_ID_APP 0xABAB + +/* +------------------------------------------------------------------------------- + MACROS TO HANDLE ABI SPECIFICS OF FUNCTION ENTRY AND RETURN + + Convenient where the frame size requirements are the same for both ABIs. + ENTRY(sz), RET(sz) are for framed functions (have locals or make calls). + ENTRY0, RET0 are for frameless functions (no locals, no calls). + + where size = size of stack frame in bytes (must be >0 and aligned to 16). + For framed functions the frame is created and the return address saved at + base of frame (Call0 ABI) or as determined by hardware (Windowed ABI). + For frameless functions, there is no frame and return address remains in a0. + Note: Because CPP macros expand to a single line, macros requiring multi-line + expansions are implemented as assembler macros. +------------------------------------------------------------------------------- +*/ + +#ifdef __ASSEMBLER__ +#ifdef __XTENSA_CALL0_ABI__ + /* Call0 */ + #define ENTRY(sz) entry1 sz + .macro entry1 size=0x10 + addi sp, sp, -\size + s32i a0, sp, 0 + .endm + #define ENTRY0 + #define RET(sz) ret1 sz + .macro ret1 size=0x10 + l32i a0, sp, 0 + addi sp, sp, \size + ret + .endm + #define RET0 ret +#else + /* Windowed */ + #define ENTRY(sz) entry sp, sz + #define ENTRY0 entry sp, 0x10 + #define RET(sz) retw + #define RET0 retw +#endif +#endif + + + + + +#endif /* XTENSA_CONTEXT_H */ + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_rtos.h b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_rtos.h new file mode 100755 index 0000000..25d42da --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_rtos.h @@ -0,0 +1,232 @@ +/******************************************************************************* +// Copyright (c) 2003-2015 Cadence Design Systems, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------------------- + + RTOS-SPECIFIC INFORMATION FOR XTENSA RTOS ASSEMBLER SOURCES + (FreeRTOS Port) + +This header is the primary glue between generic Xtensa RTOS support +sources and a specific RTOS port for Xtensa. It contains definitions +and macros for use primarily by Xtensa assembly coded source files. + +Macros in this header map callouts from generic Xtensa files to specific +RTOS functions. It may also be included in C source files. + +Xtensa RTOS ports support all RTOS-compatible configurations of the Xtensa +architecture, using the Xtensa hardware abstraction layer (HAL) to deal +with configuration specifics. + +Should be included by all Xtensa generic and RTOS port-specific sources. + +*******************************************************************************/ + +#ifndef XTENSA_RTOS_H +#define XTENSA_RTOS_H + +#ifdef __ASSEMBLER__ +#include +#else +#include +#endif + +#include +#include + +/* +Include any RTOS specific definitions that are needed by this header. +*/ +#include "FreeRTOSConfig.h" + +/* +Convert FreeRTOSConfig definitions to XTENSA definitions. +However these can still be overridden from the command line. +*/ + +#ifndef XT_SIMULATOR + #if configXT_SIMULATOR + #define XT_SIMULATOR 1 /* Simulator mode */ + #endif +#endif + +#ifndef XT_BOARD + #if configXT_BOARD + #define XT_BOARD 1 /* Board mode */ + #endif +#endif + +#ifndef XT_TIMER_INDEX + #if defined configXT_TIMER_INDEX + #define XT_TIMER_INDEX configXT_TIMER_INDEX /* Index of hardware timer to be used */ + #endif +#endif + +#ifndef XT_INTEXC_HOOKS + #if configXT_INTEXC_HOOKS + #define XT_INTEXC_HOOKS 1 /* Enables exception hooks */ + #endif +#endif + +#if !defined(XT_SIMULATOR) && !defined(XT_BOARD) + #error Either XT_SIMULATOR or XT_BOARD must be defined. +#endif + + +/* +Name of RTOS (for messages). +*/ +#define XT_RTOS_NAME FreeRTOS + +/* +Check some Xtensa configuration requirements and report error if not met. +Error messages can be customize to the RTOS port. +*/ + +#if !XCHAL_HAVE_XEA2 +#error "FreeRTOS/Xtensa requires XEA2 (exception architecture 2)." +#endif + + +/******************************************************************************* + +RTOS CALLOUT MACROS MAPPED TO RTOS PORT-SPECIFIC FUNCTIONS. + +Define callout macros used in generic Xtensa code to interact with the RTOS. +The macros are simply the function names for use in calls from assembler code. +Some of these functions may call back to generic functions in xtensa_context.h . + +*******************************************************************************/ + +/* +Inform RTOS of entry into an interrupt handler that will affect it. +Allows RTOS to manage switch to any system stack and count nesting level. +Called after minimal context has been saved, with interrupts disabled. +RTOS port can call0 _xt_context_save to save the rest of the context. +May only be called from assembly code by the 'call0' instruction. +*/ +// void XT_RTOS_INT_ENTER(void) +#define XT_RTOS_INT_ENTER _frxt_int_enter + +/* +Inform RTOS of completion of an interrupt handler, and give control to +RTOS to perform thread/task scheduling, switch back from any system stack +and restore the context, and return to the exit dispatcher saved in the +stack frame at XT_STK_EXIT. RTOS port can call0 _xt_context_restore +to save the context saved in XT_RTOS_INT_ENTER via _xt_context_save, +leaving only a minimal part of the context to be restored by the exit +dispatcher. This function does not return to the place it was called from. +May only be called from assembly code by the 'call0' instruction. +*/ +// void XT_RTOS_INT_EXIT(void) +#define XT_RTOS_INT_EXIT _frxt_int_exit + +/* +Inform RTOS of the occurrence of a tick timer interrupt. +If RTOS has no tick timer, leave XT_RTOS_TIMER_INT undefined. +May be coded in or called from C or assembly, per ABI conventions. +RTOS may optionally define XT_TICK_PER_SEC in its own way (eg. macro). +*/ +// void XT_RTOS_TIMER_INT(void) +#define XT_RTOS_TIMER_INT _frxt_timer_int +#define XT_TICK_PER_SEC configTICK_RATE_HZ + +/* +Return in a15 the base address of the co-processor state save area for the +thread that triggered a co-processor exception, or 0 if no thread was running. +The state save area is structured as defined in xtensa_context.h and has size +XT_CP_SIZE. Co-processor instructions should only be used in thread code, never +in interrupt handlers or the RTOS kernel. May only be called from assembly code +and by the 'call0' instruction. A result of 0 indicates an unrecoverable error. +The implementation may use only a2-4, a15 (all other regs must be preserved). +*/ +// void* XT_RTOS_CP_STATE(void) +#define XT_RTOS_CP_STATE _frxt_task_coproc_state + + +/******************************************************************************* + +HOOKS TO DYNAMICALLY INSTALL INTERRUPT AND EXCEPTION HANDLERS PER LEVEL. + +This Xtensa RTOS port provides hooks for dynamically installing exception +and interrupt handlers to facilitate automated testing where each test +case can install its own handler for user exceptions and each interrupt +priority (level). This consists of an array of function pointers indexed +by interrupt priority, with index 0 being the user exception handler hook. +Each entry in the array is initially 0, and may be replaced by a function +pointer of type XT_INTEXC_HOOK. A handler may be uninstalled by installing 0. + +The handler for low and medium priority obeys ABI conventions so may be coded +in C. For the exception handler, the cause is the contents of the EXCCAUSE +reg, and the result is -1 if handled, else the cause (still needs handling). +For interrupt handlers, the cause is a mask of pending enabled interrupts at +that level, and the result is the same mask with the bits for the handled +interrupts cleared (those not cleared still need handling). This allows a test +case to either pre-handle or override the default handling for the exception +or interrupt level (see xtensa_vectors.S). + +High priority handlers (including NMI) must be coded in assembly, are always +called by 'call0' regardless of ABI, must preserve all registers except a0, +and must not use or modify the interrupted stack. The hook argument 'cause' +is not passed and the result is ignored, so as not to burden the caller with +saving and restoring a2 (it assumes only one interrupt per level - see the +discussion in high priority interrupts in xtensa_vectors.S). The handler +therefore should be coded to prototype 'void h(void)' even though it plugs +into an array of handlers of prototype 'unsigned h(unsigned)'. + +To enable interrupt/exception hooks, compile the RTOS with '-DXT_INTEXC_HOOKS'. + +*******************************************************************************/ + +#define XT_INTEXC_HOOK_NUM (1 + XCHAL_NUM_INTLEVELS + XCHAL_HAVE_NMI) + +#ifndef __ASSEMBLER__ +typedef unsigned (*XT_INTEXC_HOOK)(unsigned cause); +extern volatile XT_INTEXC_HOOK _xt_intexc_hooks[XT_INTEXC_HOOK_NUM]; +#endif + + +/******************************************************************************* + +CONVENIENCE INCLUSIONS. + +Ensures RTOS specific files need only include this one Xtensa-generic header. +These headers are included last so they can use the RTOS definitions above. + +*******************************************************************************/ + +#include "xtensa_context.h" + +#ifdef XT_RTOS_TIMER_INT +#include "xtensa_timer.h" +#endif + + +/******************************************************************************* + +Xtensa Port Version. + +*******************************************************************************/ + +#define XTENSA_PORT_VERSION 1.4.2 +#define XTENSA_PORT_VERSION_STRING "1.4.2" + +#endif /* XTENSA_RTOS_H */ + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_timer.h b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_timer.h new file mode 100755 index 0000000..fa4f960 --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/include/xtensa_timer.h @@ -0,0 +1,159 @@ +/******************************************************************************* +// Copyright (c) 2003-2015 Cadence Design Systems, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------------------- + + XTENSA INFORMATION FOR RTOS TICK TIMER AND CLOCK FREQUENCY + +This header contains definitions and macros for use primarily by Xtensa +RTOS assembly coded source files. It includes and uses the Xtensa hardware +abstraction layer (HAL) to deal with config specifics. It may also be +included in C source files. + +User may edit to modify timer selection and to specify clock frequency and +tick duration to match timer interrupt to the real-time tick duration. + +If the RTOS has no timer interrupt, then there is no tick timer and the +clock frequency is irrelevant, so all of these macros are left undefined +and the Xtensa core configuration need not have a timer. + +*******************************************************************************/ + +#ifndef XTENSA_TIMER_H +#define XTENSA_TIMER_H + +#ifdef __ASSEMBLER__ +#include +#endif + +#include +#include + +#include "xtensa_rtos.h" /* in case this wasn't included directly */ + +#include "FreeRTOSConfig.h" + +/* +Select timer to use for periodic tick, and determine its interrupt number +and priority. User may specify a timer by defining XT_TIMER_INDEX with -D, +in which case its validity is checked (it must exist in this core and must +not be on a high priority interrupt - an error will be reported in invalid). +Otherwise select the first low or medium priority interrupt timer available. +*/ +#if XCHAL_NUM_TIMERS == 0 + + #error "This Xtensa configuration is unsupported, it has no timers." + +#else + +#ifndef XT_TIMER_INDEX + #if XCHAL_TIMER3_INTERRUPT != XTHAL_TIMER_UNCONFIGURED + #if XCHAL_INT_LEVEL(XCHAL_TIMER3_INTERRUPT) <= XCHAL_EXCM_LEVEL + #undef XT_TIMER_INDEX + #define XT_TIMER_INDEX 3 + #endif + #endif + #if XCHAL_TIMER2_INTERRUPT != XTHAL_TIMER_UNCONFIGURED + #if XCHAL_INT_LEVEL(XCHAL_TIMER2_INTERRUPT) <= XCHAL_EXCM_LEVEL + #undef XT_TIMER_INDEX + #define XT_TIMER_INDEX 2 + #endif + #endif + #if XCHAL_TIMER1_INTERRUPT != XTHAL_TIMER_UNCONFIGURED + #if XCHAL_INT_LEVEL(XCHAL_TIMER1_INTERRUPT) <= XCHAL_EXCM_LEVEL + #undef XT_TIMER_INDEX + #define XT_TIMER_INDEX 1 + #endif + #endif + #if XCHAL_TIMER0_INTERRUPT != XTHAL_TIMER_UNCONFIGURED + #if XCHAL_INT_LEVEL(XCHAL_TIMER0_INTERRUPT) <= XCHAL_EXCM_LEVEL + #undef XT_TIMER_INDEX + #define XT_TIMER_INDEX 0 + #endif + #endif +#endif +#ifndef XT_TIMER_INDEX + #error "There is no suitable timer in this Xtensa configuration." +#endif + +#define XT_CCOMPARE (CCOMPARE + XT_TIMER_INDEX) +#define XT_TIMER_INTNUM XCHAL_TIMER_INTERRUPT(XT_TIMER_INDEX) +#define XT_TIMER_INTPRI XCHAL_INT_LEVEL(XT_TIMER_INTNUM) +#define XT_TIMER_INTEN (1 << XT_TIMER_INTNUM) + +#if XT_TIMER_INTNUM == XTHAL_TIMER_UNCONFIGURED + #error "The timer selected by XT_TIMER_INDEX does not exist in this core." +#elif XT_TIMER_INTPRI > XCHAL_EXCM_LEVEL + #error "The timer interrupt cannot be high priority (use medium or low)." +#endif + +#endif /* XCHAL_NUM_TIMERS */ + +/* +Set processor clock frequency, used to determine clock divisor for timer tick. +User should BE SURE TO ADJUST THIS for the Xtensa platform being used. +If using a supported board via the board-independent API defined in xtbsp.h, +this may be left undefined and frequency and tick divisor will be computed +and cached during run-time initialization. + +NOTE ON SIMULATOR: +Under the Xtensa instruction set simulator, the frequency can only be estimated +because it depends on the speed of the host and the version of the simulator. +Also because it runs much slower than hardware, it is not possible to achieve +real-time performance for most applications under the simulator. A frequency +too low does not allow enough time between timer interrupts, starving threads. +To obtain a more convenient but non-real-time tick duration on the simulator, +compile with xt-xcc option "-DXT_SIMULATOR". +Adjust this frequency to taste (it's not real-time anyway!). +*/ +#if defined(XT_SIMULATOR) && !defined(XT_CLOCK_FREQ) +#define XT_CLOCK_FREQ configCPU_CLOCK_HZ +#endif + +#if !defined(XT_CLOCK_FREQ) && !defined(XT_BOARD) + #error "XT_CLOCK_FREQ must be defined for the target platform." +#endif + +/* +Default number of timer "ticks" per second (default 100 for 10ms tick). +RTOS may define this in its own way (if applicable) in xtensa_rtos.h. +User may redefine this to an optimal value for the application, either by +editing this here or in xtensa_rtos.h, or compiling with xt-xcc option +"-DXT_TICK_PER_SEC=" where is a suitable number. +*/ +#ifndef XT_TICK_PER_SEC +#define XT_TICK_PER_SEC configTICK_RATE_HZ /* 10 ms tick = 100 ticks per second */ +#endif + +/* +Derivation of clock divisor for timer tick and interrupt (one per tick). +*/ +#ifdef XT_CLOCK_FREQ +#define XT_TICK_DIVISOR (XT_CLOCK_FREQ / XT_TICK_PER_SEC) +#endif + +#ifndef __ASSEMBLER__ +extern unsigned _xt_tick_divisor; +extern void _xt_tick_divisor_init(void); +#endif + +#endif /* XTENSA_TIMER_H */ + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/port.c b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/port.c new file mode 100755 index 0000000..bdf74d3 --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/port.c @@ -0,0 +1,428 @@ +/* + FreeRTOS V8.2.0 - Copyright (C) 2015 Real Time Engineers Ltd. + All rights reserved + + VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. + + *************************************************************************** + >>! NOTE: The modification to the GPL is included to allow you to !<< + >>! distribute a combined work that includes FreeRTOS without being !<< + >>! obliged to provide the source code for proprietary components !<< + >>! outside of the FreeRTOS kernel. !<< + *************************************************************************** + + FreeRTOS 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. Full license text is available on the following + link: http://www.freertos.org/a00114.html + + *************************************************************************** + * * + * FreeRTOS provides completely free yet professionally developed, * + * robust, strictly quality controlled, supported, and cross * + * platform software that is more than just the market leader, it * + * is the industry's de facto standard. * + * * + * Help yourself get started quickly while simultaneously helping * + * to support the FreeRTOS project by purchasing a FreeRTOS * + * tutorial book, reference manual, or both: * + * http://www.FreeRTOS.org/Documentation * + * * + *************************************************************************** + + http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading + the FAQ page "My application does not run, what could be wrong?". Have you + defined configASSERT()? + + http://www.FreeRTOS.org/support - In return for receiving this top quality + embedded software for free we request you assist our global community by + participating in the support forum. + + http://www.FreeRTOS.org/training - Investing in training allows your team to + be as productive as possible as early as possible. Now you can receive + FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers + Ltd, and the world's leading authority on the world's leading RTOS. + + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, + including FreeRTOS+Trace - an indispensable productivity tool, a DOS + compatible FAT file system, and our tiny thread aware UDP/IP stack. + + http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. + Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. + + http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High + Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS + licenses offer ticketed support, indemnification and commercial middleware. + + http://www.SafeRTOS.com - High Integrity Systems also provide a safety + engineered and independently SIL3 certified version for use in safety and + mission critical applications that require provable dependability. + + 1 tab == 4 spaces! +*/ + +/******************************************************************************* +// Copyright (c) 2003-2015 Cadence Design Systems, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------------------- +*/ + +#include +#include + +#include "xtensa_rtos.h" + +#include "rom/ets_sys.h" +#include "soc/cpu.h" + +#include "FreeRTOS.h" +#include "task.h" + +#include "esp_panic.h" +#include "esp_heap_caps.h" +#include "esp_crosscore_int.h" + +#include "esp_intr_alloc.h" + +/* Defined in portasm.h */ +extern void _frxt_tick_timer_init(void); + +/* Defined in xtensa_context.S */ +extern void _xt_coproc_init(void); + + +#if CONFIG_FREERTOS_CORETIMER_0 + #define SYSTICK_INTR_ID (ETS_INTERNAL_TIMER0_INTR_SOURCE+ETS_INTERNAL_INTR_SOURCE_OFF) +#endif +#if CONFIG_FREERTOS_CORETIMER_1 + #define SYSTICK_INTR_ID (ETS_INTERNAL_TIMER1_INTR_SOURCE+ETS_INTERNAL_INTR_SOURCE_OFF) +#endif + +/*-----------------------------------------------------------*/ + +unsigned port_xSchedulerRunning[portNUM_PROCESSORS] = {0}; // Duplicate of inaccessible xSchedulerRunning; needed at startup to avoid counting nesting +unsigned port_interruptNesting[portNUM_PROCESSORS] = {0}; // Interrupt nesting level. Increased/decreased in portasm.c, _frxt_int_enter/_frxt_int_exit + +/*-----------------------------------------------------------*/ + +// User exception dispatcher when exiting +void _xt_user_exit(void); + +/* + * Stack initialization + */ +#if portUSING_MPU_WRAPPERS +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) +#else +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) +#endif +{ + StackType_t *sp, *tp; + XtExcFrame *frame; + #if XCHAL_CP_NUM > 0 + uint32_t *p; + #endif + + /* Create interrupt stack frame aligned to 16 byte boundary */ + sp = (StackType_t *) (((UBaseType_t)(pxTopOfStack + 1) - XT_CP_SIZE - XT_STK_FRMSZ) & ~0xf); + + /* Clear the entire frame (do not use memset() because we don't depend on C library) */ + for (tp = sp; tp <= pxTopOfStack; ++tp) + *tp = 0; + + frame = (XtExcFrame *) sp; + + /* Explicitly initialize certain saved registers */ + frame->pc = (UBaseType_t) pxCode; /* task entrypoint */ + frame->a0 = 0; /* to terminate GDB backtrace */ + frame->a1 = (UBaseType_t) sp + XT_STK_FRMSZ; /* physical top of stack frame */ + frame->exit = (UBaseType_t) _xt_user_exit; /* user exception exit dispatcher */ + + /* Set initial PS to int level 0, EXCM disabled ('rfe' will enable), user mode. */ + /* Also set entry point argument parameter. */ + #ifdef __XTENSA_CALL0_ABI__ + frame->a2 = (UBaseType_t) pvParameters; + frame->ps = PS_UM | PS_EXCM; + #else + /* + for windowed ABI also set WOE and CALLINC (pretend task was 'call4'd). */ + frame->a6 = (UBaseType_t) pvParameters; + frame->ps = PS_UM | PS_EXCM | PS_WOE | PS_CALLINC(1); + #endif + + #ifdef XT_USE_SWPRI + /* Set the initial virtual priority mask value to all 1's. */ + frame->vpri = 0xFFFFFFFF; + #endif + + #if XCHAL_CP_NUM > 0 + /* Init the coprocessor save area (see xtensa_context.h) */ + /* No access to TCB here, so derive indirectly. Stack growth is top to bottom. + * //p = (uint32_t *) xMPUSettings->coproc_area; + */ + p = (uint32_t *)(((uint32_t) pxTopOfStack - XT_CP_SIZE) & ~0xf); + p[0] = 0; + p[1] = 0; + p[2] = (((uint32_t) p) + 12 + XCHAL_TOTAL_SA_ALIGN - 1) & -XCHAL_TOTAL_SA_ALIGN; + #endif + + return sp; +} + +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) +{ + /* It is unlikely that the Xtensa port will get stopped. If required simply + disable the tick interrupt here. */ +} + +/*-----------------------------------------------------------*/ + +BaseType_t xPortStartScheduler( void ) +{ + // Interrupts are disabled at this point and stack contains PS with enabled interrupts when task context is restored + + #if XCHAL_CP_NUM > 0 + /* Initialize co-processor management for tasks. Leave CPENABLE alone. */ + _xt_coproc_init(); + #endif + + /* Init the tick divisor value */ + _xt_tick_divisor_init(); + + /* Setup the hardware to generate the tick. */ + _frxt_tick_timer_init(); + + port_xSchedulerRunning[xPortGetCoreID()] = 1; + + // Cannot be directly called from C; never returns + __asm__ volatile ("call0 _frxt_dispatch\n"); + + /* Should not get here. */ + return pdTRUE; +} +/*-----------------------------------------------------------*/ + +BaseType_t xPortSysTickHandler( void ) +{ + BaseType_t ret; + unsigned interruptMask; + + portbenchmarkIntLatency(); + traceISR_ENTER(SYSTICK_INTR_ID); + + /* Interrupts upto configMAX_SYSCALL_INTERRUPT_PRIORITY must be + * disabled before calling xTaskIncrementTick as it access the + * kernel lists. */ + interruptMask = portSET_INTERRUPT_MASK_FROM_ISR(); + { + ret = xTaskIncrementTick(); + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( interruptMask ); + + if( ret != pdFALSE ) + { + portYIELD_FROM_ISR(); + } else { + traceISR_EXIT(); + } + return ret; +} + + +void vPortYieldOtherCore( BaseType_t coreid ) { + esp_crosscore_int_send_yield( coreid ); +} + +/*-----------------------------------------------------------*/ + +/* + * Used to set coprocessor area in stack. Current hack is to reuse MPU pointer for coprocessor area. + */ +#if portUSING_MPU_WRAPPERS +void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t usStackDepth ) +{ + #if XCHAL_CP_NUM > 0 + xMPUSettings->coproc_area = (StackType_t*)((((uint32_t)(pxBottomOfStack + usStackDepth - 1)) - XT_CP_SIZE ) & ~0xf); + + + /* NOTE: we cannot initialize the coprocessor save area here because FreeRTOS is going to + * clear the stack area after we return. This is done in pxPortInitialiseStack(). + */ + #endif +} + +void vPortReleaseTaskMPUSettings( xMPU_SETTINGS *xMPUSettings ) +{ + /* If task has live floating point registers somewhere, release them */ + _xt_coproc_release( xMPUSettings->coproc_area ); +} + +#endif + +/* + * Returns true if the current core is in ISR context; low prio ISR, med prio ISR or timer tick ISR. High prio ISRs + * aren't detected here, but they normally cannot call C code, so that should not be an issue anyway. + */ +BaseType_t xPortInIsrContext() +{ + unsigned int irqStatus; + BaseType_t ret; + irqStatus=portENTER_CRITICAL_NESTED(); + ret=(port_interruptNesting[xPortGetCoreID()] != 0); + portEXIT_CRITICAL_NESTED(irqStatus); + return ret; +} + +/* + * This function will be called in High prio ISRs. Returns true if the current core was in ISR context + * before calling into high prio ISR context. + */ +BaseType_t IRAM_ATTR xPortInterruptedFromISRContext() +{ + return (port_interruptNesting[xPortGetCoreID()] != 0); +} + +void vPortAssertIfInISR() +{ + if (xPortInIsrContext()) { + ets_printf("core=%d port_interruptNesting=%d\n\n", xPortGetCoreID(), port_interruptNesting[xPortGetCoreID()]); + } + configASSERT(!xPortInIsrContext()); +} + +/* + * For kernel use: Initialize a per-CPU mux. Mux will be initialized unlocked. + */ +void vPortCPUInitializeMutex(portMUX_TYPE *mux) { + +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG + ets_printf("Initializing mux %p\n", mux); + mux->lastLockedFn="(never locked)"; + mux->lastLockedLine=-1; +#endif + mux->owner=portMUX_FREE_VAL; + mux->count=0; +} + +#include "portmux_impl.h" + +/* + * For kernel use: Acquire a per-CPU mux. Spinlocks, so don't hold on to these muxes for too long. + */ +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG +void vPortCPUAcquireMutex(portMUX_TYPE *mux, const char *fnName, int line) { + unsigned int irqStatus = portENTER_CRITICAL_NESTED(); + vPortCPUAcquireMutexIntsDisabled(mux, portMUX_NO_TIMEOUT, fnName, line); + portEXIT_CRITICAL_NESTED(irqStatus); +} + +bool vPortCPUAcquireMutexTimeout(portMUX_TYPE *mux, int timeout_cycles, const char *fnName, int line) { + unsigned int irqStatus = portENTER_CRITICAL_NESTED(); + bool result = vPortCPUAcquireMutexIntsDisabled(mux, timeout_cycles, fnName, line); + portEXIT_CRITICAL_NESTED(irqStatus); + return result; +} + +#else +void vPortCPUAcquireMutex(portMUX_TYPE *mux) { + unsigned int irqStatus = portENTER_CRITICAL_NESTED(); + vPortCPUAcquireMutexIntsDisabled(mux, portMUX_NO_TIMEOUT); + portEXIT_CRITICAL_NESTED(irqStatus); +} + +bool vPortCPUAcquireMutexTimeout(portMUX_TYPE *mux, int timeout_cycles) { + unsigned int irqStatus = portENTER_CRITICAL_NESTED(); + bool result = vPortCPUAcquireMutexIntsDisabled(mux, timeout_cycles); + portEXIT_CRITICAL_NESTED(irqStatus); + return result; +} +#endif + + +/* + * For kernel use: Release a per-CPU mux + * + * Mux must be already locked by this core + */ +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG +void vPortCPUReleaseMutex(portMUX_TYPE *mux, const char *fnName, int line) { + unsigned int irqStatus = portENTER_CRITICAL_NESTED(); + vPortCPUReleaseMutexIntsDisabled(mux, fnName, line); + portEXIT_CRITICAL_NESTED(irqStatus); +} +#else +void vPortCPUReleaseMutex(portMUX_TYPE *mux) { + unsigned int irqStatus = portENTER_CRITICAL_NESTED(); + vPortCPUReleaseMutexIntsDisabled(mux); + portEXIT_CRITICAL_NESTED(irqStatus); +} +#endif + +void vPortSetStackWatchpoint( void* pxStackStart ) { + //Set watchpoint 1 to watch the last 32 bytes of the stack. + //Unfortunately, the Xtensa watchpoints can't set a watchpoint on a random [base - base+n] region because + //the size works by masking off the lowest address bits. For that reason, we futz a bit and watch the lowest 32 + //bytes of the stack we can actually watch. In general, this can cause the watchpoint to be triggered at most + //28 bytes early. The value 32 is chosen because it's larger than the stack canary, which in FreeRTOS is 20 bytes. + //This way, we make sure we trigger before/when the stack canary is corrupted, not after. + int addr=(int)pxStackStart; + addr=(addr+31)&(~31); + esp_set_watchpoint(1, (char*)addr, 32, ESP_WATCHPOINT_STORE); +} + +#if defined(CONFIG_SPIRAM_SUPPORT) +/* + * Compare & set (S32C1) does not work in external RAM. Instead, this routine uses a mux (in internal memory) to fake it. + */ +static portMUX_TYPE extram_mux = portMUX_INITIALIZER_UNLOCKED; + +void uxPortCompareSetExtram(volatile uint32_t *addr, uint32_t compare, uint32_t *set) { + uint32_t prev; +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG + vPortCPUAcquireMutexIntsDisabled(&extram_mux, portMUX_NO_TIMEOUT, __FUNCTION__, __LINE__); +#else + vPortCPUAcquireMutexIntsDisabled(&extram_mux, portMUX_NO_TIMEOUT); +#endif + prev=*addr; + if (prev==compare) { + *addr=*set; + } + *set=prev; +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG + vPortCPUReleaseMutexIntsDisabled(&extram_mux, __FUNCTION__, __LINE__); +#else + vPortCPUReleaseMutexIntsDisabled(&extram_mux); +#endif +} +#endif //defined(CONFIG_SPIRAM_SUPPORT) + + + +uint32_t xPortGetTickRateHz(void) { + return (uint32_t)configTICK_RATE_HZ; +} diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/portasm.S b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/portasm.S new file mode 100755 index 0000000..f5b280f --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/portasm.S @@ -0,0 +1,653 @@ +/* +//----------------------------------------------------------------------------- +// Copyright (c) 2003-2015 Cadence Design Systems, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +//----------------------------------------------------------------------------- +*/ + +#include "xtensa_rtos.h" +#include "sdkconfig.h" + +#define TOPOFSTACK_OFFS 0x00 /* StackType_t *pxTopOfStack */ +#define CP_TOPOFSTACK_OFFS 0x04 /* xMPU_SETTINGS.coproc_area */ + +.extern pxCurrentTCB + +/* +******************************************************************************* +* Interrupt stack. The size of the interrupt stack is determined by the config +* parameter "configISR_STACK_SIZE" in FreeRTOSConfig.h +******************************************************************************* +*/ + + .data + .align 16 + .global port_IntStack + .global port_IntStackTop + .global port_switch_flag +port_IntStack: + .space configISR_STACK_SIZE*portNUM_PROCESSORS /* This allocates stacks for each individual CPU. */ +port_IntStackTop: + .word 0 +port_switch_flag: + .space portNUM_PROCESSORS*4 /* One flag for each individual CPU. */ + + .text + +/* +******************************************************************************* +* _frxt_setup_switch +* void _frxt_setup_switch(void); +* +* Sets an internal flag indicating that a task switch is required on return +* from interrupt handling. +* +******************************************************************************* +*/ + .global _frxt_setup_switch + .type _frxt_setup_switch,@function + .align 4 +_frxt_setup_switch: + + ENTRY(16) + + getcoreid a3 + movi a2, port_switch_flag + addx4 a2, a3, a2 + + movi a3, 1 + s32i a3, a2, 0 + + RET(16) + + + + + + +/* +******************************************************************************* +* _frxt_int_enter +* void _frxt_int_enter(void) +* +* Implements the Xtensa RTOS porting layer's XT_RTOS_INT_ENTER function for +* freeRTOS. Saves the rest of the interrupt context (not already saved). +* May only be called from assembly code by the 'call0' instruction, with +* interrupts disabled. +* See the detailed description of the XT_RTOS_ENTER macro in xtensa_rtos.h. +* +******************************************************************************* +*/ + .globl _frxt_int_enter + .type _frxt_int_enter,@function + .align 4 +_frxt_int_enter: + + /* Save a12-13 in the stack frame as required by _xt_context_save. */ + s32i a12, a1, XT_STK_A12 + s32i a13, a1, XT_STK_A13 + + /* Save return address in a safe place (free a0). */ + mov a12, a0 + + /* Save the rest of the interrupted context (preserves A12-13). */ + call0 _xt_context_save + + /* + Save interrupted task's SP in TCB only if not nesting. + Manage nesting directly rather than call the generic IntEnter() + (in windowed ABI we can't call a C function here anyway because PS.EXCM is still set). + */ + getcoreid a4 + movi a2, port_xSchedulerRunning + addx4 a2, a4, a2 + movi a3, port_interruptNesting + addx4 a3, a4, a3 + l32i a2, a2, 0 /* a2 = port_xSchedulerRunning */ + beqz a2, 1f /* scheduler not running, no tasks */ + l32i a2, a3, 0 /* a2 = port_interruptNesting */ + addi a2, a2, 1 /* increment nesting count */ + s32i a2, a3, 0 /* save nesting count */ + bnei a2, 1, .Lnested /* !=0 before incr, so nested */ + + movi a2, pxCurrentTCB + addx4 a2, a4, a2 + l32i a2, a2, 0 /* a2 = current TCB */ + beqz a2, 1f + s32i a1, a2, TOPOFSTACK_OFFS /* pxCurrentTCB->pxTopOfStack = SP */ + movi a1, port_IntStack+configISR_STACK_SIZE /* a1 = top of intr stack for CPU 0 */ + movi a2, configISR_STACK_SIZE /* add configISR_STACK_SIZE * cpu_num to arrive at top of stack for cpu_num */ + mull a2, a4, a2 + add a1, a1, a2 /* for current proc */ + +.Lnested: +1: + mov a0, a12 /* restore return addr and return */ + ret + +/* +******************************************************************************* +* _frxt_int_exit +* void _frxt_int_exit(void) +* +* Implements the Xtensa RTOS porting layer's XT_RTOS_INT_EXIT function for +* FreeRTOS. If required, calls vPortYieldFromInt() to perform task context +* switching, restore the (possibly) new task's context, and return to the +* exit dispatcher saved in the task's stack frame at XT_STK_EXIT. +* May only be called from assembly code by the 'call0' instruction. Does not +* return to caller. +* See the description of the XT_RTOS_ENTER macro in xtensa_rtos.h. +* +******************************************************************************* +*/ + .globl _frxt_int_exit + .type _frxt_int_exit,@function + .align 4 +_frxt_int_exit: + + getcoreid a4 + movi a2, port_xSchedulerRunning + addx4 a2, a4, a2 + movi a3, port_interruptNesting + addx4 a3, a4, a3 + rsil a0, XCHAL_EXCM_LEVEL /* lock out interrupts */ + l32i a2, a2, 0 /* a2 = port_xSchedulerRunning */ + beqz a2, .Lnoswitch /* scheduler not running, no tasks */ + l32i a2, a3, 0 /* a2 = port_interruptNesting */ + addi a2, a2, -1 /* decrement nesting count */ + s32i a2, a3, 0 /* save nesting count */ + bnez a2, .Lnesting /* !=0 after decr so still nested */ + + movi a2, pxCurrentTCB + addx4 a2, a4, a2 + l32i a2, a2, 0 /* a2 = current TCB */ + beqz a2, 1f /* no task ? go to dispatcher */ + l32i a1, a2, TOPOFSTACK_OFFS /* SP = pxCurrentTCB->pxTopOfStack */ + + movi a2, port_switch_flag /* address of switch flag */ + addx4 a2, a4, a2 /* point to flag for this cpu */ + l32i a3, a2, 0 /* a3 = port_switch_flag */ + beqz a3, .Lnoswitch /* flag = 0 means no switch reqd */ + movi a3, 0 + s32i a3, a2, 0 /* zero out the flag for next time */ + +1: + /* + Call0 ABI callee-saved regs a12-15 need to be saved before possible preemption. + However a12-13 were already saved by _frxt_int_enter(). + */ + #ifdef __XTENSA_CALL0_ABI__ + s32i a14, a1, XT_STK_A14 + s32i a15, a1, XT_STK_A15 + #endif + + #ifdef __XTENSA_CALL0_ABI__ + call0 vPortYieldFromInt /* call dispatch inside the function; never returns */ + #else + call4 vPortYieldFromInt /* this one returns */ + call0 _frxt_dispatch /* tail-call dispatcher */ + /* Never returns here. */ + #endif + +.Lnoswitch: + /* + If we came here then about to resume the interrupted task. + */ + +.Lnesting: + /* + We come here only if there was no context switch, that is if this + is a nested interrupt, or the interrupted task was not preempted. + In either case there's no need to load the SP. + */ + + /* Restore full context from interrupt stack frame */ + call0 _xt_context_restore + + /* + Must return via the exit dispatcher corresponding to the entrypoint from which + this was called. Interruptee's A0, A1, PS, PC are restored and the interrupt + stack frame is deallocated in the exit dispatcher. + */ + l32i a0, a1, XT_STK_EXIT + ret + + +/* +********************************************************************************************************** +* _frxt_timer_int +* void _frxt_timer_int(void) +* +* Implements the Xtensa RTOS porting layer's XT_RTOS_TIMER_INT function for FreeRTOS. +* Called every timer interrupt. +* Manages the tick timer and calls xPortSysTickHandler() every tick. +* See the detailed description of the XT_RTOS_ENTER macro in xtensa_rtos.h. +* +* Callable from C (obeys ABI conventions). Implemented in assmebly code for performance. +* +********************************************************************************************************** +*/ + .globl _frxt_timer_int + .type _frxt_timer_int,@function + .align 4 +_frxt_timer_int: + + /* + Xtensa timers work by comparing a cycle counter with a preset value. Once the match occurs + an interrupt is generated, and the handler has to set a new cycle count into the comparator. + To avoid clock drift due to interrupt latency, the new cycle count is computed from the old, + not the time the interrupt was serviced. However if a timer interrupt is ever serviced more + than one tick late, it is necessary to process multiple ticks until the new cycle count is + in the future, otherwise the next timer interrupt would not occur until after the cycle + counter had wrapped (2^32 cycles later). + + do { + ticks++; + old_ccompare = read_ccompare_i(); + write_ccompare_i( old_ccompare + divisor ); + service one tick; + diff = read_ccount() - old_ccompare; + } while ( diff > divisor ); + */ + + ENTRY(16) + + #ifdef CONFIG_PM_TRACE + movi a6, 1 /* = ESP_PM_TRACE_TICK */ + getcoreid a7 + call4 esp_pm_trace_enter + #endif // CONFIG_PM_TRACE + +.L_xt_timer_int_catchup: + + /* Update the timer comparator for the next tick. */ + #ifdef XT_CLOCK_FREQ + movi a2, XT_TICK_DIVISOR /* a2 = comparator increment */ + #else + movi a3, _xt_tick_divisor + l32i a2, a3, 0 /* a2 = comparator increment */ + #endif + rsr a3, XT_CCOMPARE /* a3 = old comparator value */ + add a4, a3, a2 /* a4 = new comparator value */ + wsr a4, XT_CCOMPARE /* update comp. and clear interrupt */ + esync + + #ifdef __XTENSA_CALL0_ABI__ + /* Preserve a2 and a3 across C calls. */ + s32i a2, sp, 4 + s32i a3, sp, 8 + #endif + + /* Call the FreeRTOS tick handler (see port.c). */ + #ifdef __XTENSA_CALL0_ABI__ + call0 xPortSysTickHandler + #else + call4 xPortSysTickHandler + #endif + + #ifdef __XTENSA_CALL0_ABI__ + /* Restore a2 and a3. */ + l32i a2, sp, 4 + l32i a3, sp, 8 + #endif + + /* Check if we need to process more ticks to catch up. */ + esync /* ensure comparator update complete */ + rsr a4, CCOUNT /* a4 = cycle count */ + sub a4, a4, a3 /* diff = ccount - old comparator */ + blt a2, a4, .L_xt_timer_int_catchup /* repeat while diff > divisor */ + +#ifdef CONFIG_PM_TRACE + movi a6, 1 /* = ESP_PM_TRACE_TICK */ + getcoreid a7 + call4 esp_pm_trace_exit +#endif // CONFIG_PM_TRACE + + RET(16) + + /* +********************************************************************************************************** +* _frxt_tick_timer_init +* void _frxt_tick_timer_init(void) +* +* Initialize timer and timer interrrupt handler (_xt_tick_divisor_init() has already been been called). +* Callable from C (obeys ABI conventions on entry). +* +********************************************************************************************************** +*/ + .globl _frxt_tick_timer_init + .type _frxt_tick_timer_init,@function + .align 4 +_frxt_tick_timer_init: + + ENTRY(16) + + + /* Set up the periodic tick timer (assume enough time to complete init). */ + #ifdef XT_CLOCK_FREQ + movi a3, XT_TICK_DIVISOR + #else + movi a2, _xt_tick_divisor + l32i a3, a2, 0 + #endif + rsr a2, CCOUNT /* current cycle count */ + add a2, a2, a3 /* time of first timer interrupt */ + wsr a2, XT_CCOMPARE /* set the comparator */ + + /* + Enable the timer interrupt at the device level. Don't write directly + to the INTENABLE register because it may be virtualized. + */ + #ifdef __XTENSA_CALL0_ABI__ + movi a2, XT_TIMER_INTEN + call0 xt_ints_on + #else + movi a6, XT_TIMER_INTEN + call4 xt_ints_on + #endif + + RET(16) + +/* +********************************************************************************************************** +* DISPATCH THE HIGH READY TASK +* void _frxt_dispatch(void) +* +* Switch context to the highest priority ready task, restore its state and dispatch control to it. +* +* This is a common dispatcher that acts as a shared exit path for all the context switch functions +* including vPortYield() and vPortYieldFromInt(), all of which tail-call this dispatcher +* (for windowed ABI vPortYieldFromInt() calls it indirectly via _frxt_int_exit() ). +* +* The Xtensa port uses different stack frames for solicited and unsolicited task suspension (see +* comments on stack frames in xtensa_context.h). This function restores the state accordingly. +* If restoring a task that solicited entry, restores the minimal state and leaves CPENABLE clear. +* If restoring a task that was preempted, restores all state including the task's CPENABLE. +* +* Entry: +* pxCurrentTCB points to the TCB of the task to suspend, +* Because it is tail-called without a true function entrypoint, it needs no 'entry' instruction. +* +* Exit: +* If incoming task called vPortYield() (solicited), this function returns as if from vPortYield(). +* If incoming task was preempted by an interrupt, this function jumps to exit dispatcher. +* +********************************************************************************************************** +*/ + .globl _frxt_dispatch + .type _frxt_dispatch,@function + .align 4 +_frxt_dispatch: + + #ifdef __XTENSA_CALL0_ABI__ + call0 vTaskSwitchContext // Get next TCB to resume + movi a2, pxCurrentTCB + getcoreid a3 + addx4 a2, a3, a2 + #else + call4 vTaskSwitchContext // Get next TCB to resume + movi a2, pxCurrentTCB + getcoreid a3 + addx4 a2, a3, a2 + #endif + l32i a3, a2, 0 + l32i sp, a3, TOPOFSTACK_OFFS /* SP = next_TCB->pxTopOfStack; */ + s32i a3, a2, 0 + + /* Determine the type of stack frame. */ + l32i a2, sp, XT_STK_EXIT /* exit dispatcher or solicited flag */ + bnez a2, .L_frxt_dispatch_stk + +.L_frxt_dispatch_sol: + + /* Solicited stack frame. Restore minimal context and return from vPortYield(). */ + l32i a3, sp, XT_SOL_PS + #ifdef __XTENSA_CALL0_ABI__ + l32i a12, sp, XT_SOL_A12 + l32i a13, sp, XT_SOL_A13 + l32i a14, sp, XT_SOL_A14 + l32i a15, sp, XT_SOL_A15 + #endif + l32i a0, sp, XT_SOL_PC + #if XCHAL_CP_NUM > 0 + /* Ensure wsr.CPENABLE is complete (should be, it was cleared on entry). */ + rsync + #endif + /* As soons as PS is restored, interrupts can happen. No need to sync PS. */ + wsr a3, PS + #ifdef __XTENSA_CALL0_ABI__ + addi sp, sp, XT_SOL_FRMSZ + ret + #else + retw + #endif + +.L_frxt_dispatch_stk: + + #if XCHAL_CP_NUM > 0 + /* Restore CPENABLE from task's co-processor save area. */ + movi a3, pxCurrentTCB /* cp_state = */ + getcoreid a2 + addx4 a3, a2, a3 + l32i a3, a3, 0 + l32i a2, a3, CP_TOPOFSTACK_OFFS /* StackType_t *pxStack; */ + l16ui a3, a2, XT_CPENABLE /* CPENABLE = cp_state->cpenable; */ + wsr a3, CPENABLE + #endif + + /* Interrupt stack frame. Restore full context and return to exit dispatcher. */ + call0 _xt_context_restore + + /* In Call0 ABI, restore callee-saved regs (A12, A13 already restored). */ + #ifdef __XTENSA_CALL0_ABI__ + l32i a14, sp, XT_STK_A14 + l32i a15, sp, XT_STK_A15 + #endif + + #if XCHAL_CP_NUM > 0 + /* Ensure wsr.CPENABLE has completed. */ + rsync + #endif + + /* + Must return via the exit dispatcher corresponding to the entrypoint from which + this was called. Interruptee's A0, A1, PS, PC are restored and the interrupt + stack frame is deallocated in the exit dispatcher. + */ + l32i a0, sp, XT_STK_EXIT + ret + + +/* +********************************************************************************************************** +* PERFORM A SOLICTED CONTEXT SWITCH (from a task) +* void vPortYield(void) +* +* This function saves the minimal state needed for a solicited task suspension, clears CPENABLE, +* then tail-calls the dispatcher _frxt_dispatch() to perform the actual context switch +* +* At Entry: +* pxCurrentTCB points to the TCB of the task to suspend +* Callable from C (obeys ABI conventions on entry). +* +* Does not return to caller. +* +********************************************************************************************************** +*/ + .globl vPortYield + .type vPortYield,@function + .align 4 +vPortYield: + + #ifdef __XTENSA_CALL0_ABI__ + addi sp, sp, -XT_SOL_FRMSZ + #else + entry sp, XT_SOL_FRMSZ + #endif + + rsr a2, PS + s32i a0, sp, XT_SOL_PC + s32i a2, sp, XT_SOL_PS + #ifdef __XTENSA_CALL0_ABI__ + s32i a12, sp, XT_SOL_A12 /* save callee-saved registers */ + s32i a13, sp, XT_SOL_A13 + s32i a14, sp, XT_SOL_A14 + s32i a15, sp, XT_SOL_A15 + #else + /* Spill register windows. Calling xthal_window_spill() causes extra */ + /* spills and reloads, so we will set things up to call the _nw version */ + /* instead to save cycles. */ + movi a6, ~(PS_WOE_MASK|PS_INTLEVEL_MASK) /* spills a4-a7 if needed */ + and a2, a2, a6 /* clear WOE, INTLEVEL */ + addi a2, a2, XCHAL_EXCM_LEVEL /* set INTLEVEL */ + wsr a2, PS + rsync + call0 xthal_window_spill_nw + l32i a2, sp, XT_SOL_PS /* restore PS */ + wsr a2, PS + #endif + + rsil a2, XCHAL_EXCM_LEVEL /* disable low/med interrupts */ + + #if XCHAL_CP_NUM > 0 + /* Save coprocessor callee-saved state (if any). At this point CPENABLE */ + /* should still reflect which CPs were in use (enabled). */ + call0 _xt_coproc_savecs + #endif + + movi a2, pxCurrentTCB + getcoreid a3 + addx4 a2, a3, a2 + l32i a2, a2, 0 /* a2 = pxCurrentTCB */ + movi a3, 0 + s32i a3, sp, XT_SOL_EXIT /* 0 to flag as solicited frame */ + s32i sp, a2, TOPOFSTACK_OFFS /* pxCurrentTCB->pxTopOfStack = SP */ + + #if XCHAL_CP_NUM > 0 + /* Clear CPENABLE, also in task's co-processor state save area. */ + l32i a2, a2, CP_TOPOFSTACK_OFFS /* a2 = pxCurrentTCB->cp_state */ + movi a3, 0 + wsr a3, CPENABLE + beqz a2, 1f + s16i a3, a2, XT_CPENABLE /* clear saved cpenable */ +1: + #endif + + /* Tail-call dispatcher. */ + call0 _frxt_dispatch + /* Never reaches here. */ + + +/* +********************************************************************************************************** +* PERFORM AN UNSOLICITED CONTEXT SWITCH (from an interrupt) +* void vPortYieldFromInt(void) +* +* This calls the context switch hook (removed), saves and clears CPENABLE, then tail-calls the dispatcher +* _frxt_dispatch() to perform the actual context switch. +* +* At Entry: +* Interrupted task context has been saved in an interrupt stack frame at pxCurrentTCB->pxTopOfStack. +* pxCurrentTCB points to the TCB of the task to suspend, +* Callable from C (obeys ABI conventions on entry). +* +* At Exit: +* Windowed ABI defers the actual context switch until the stack is unwound to interrupt entry. +* Call0 ABI tail-calls the dispatcher directly (no need to unwind) so does not return to caller. +* +********************************************************************************************************** +*/ + .globl vPortYieldFromInt + .type vPortYieldFromInt,@function + .align 4 +vPortYieldFromInt: + + ENTRY(16) + + #if XCHAL_CP_NUM > 0 + /* Save CPENABLE in task's co-processor save area, and clear CPENABLE. */ + movi a3, pxCurrentTCB /* cp_state = */ + getcoreid a2 + addx4 a3, a2, a3 + l32i a3, a3, 0 + + l32i a2, a3, CP_TOPOFSTACK_OFFS + + rsr a3, CPENABLE + s16i a3, a2, XT_CPENABLE /* cp_state->cpenable = CPENABLE; */ + movi a3, 0 + wsr a3, CPENABLE /* disable all co-processors */ + #endif + + #ifdef __XTENSA_CALL0_ABI__ + /* Tail-call dispatcher. */ + call0 _frxt_dispatch + /* Never reaches here. */ + #else + RET(16) + #endif + +/* +********************************************************************************************************** +* _frxt_task_coproc_state +* void _frxt_task_coproc_state(void) +* +* Implements the Xtensa RTOS porting layer's XT_RTOS_CP_STATE function for FreeRTOS. +* +* May only be called when a task is running, not within an interrupt handler (returns 0 in that case). +* May only be called from assembly code by the 'call0' instruction. Does NOT obey ABI conventions. +* Returns in A15 a pointer to the base of the co-processor state save area for the current task. +* See the detailed description of the XT_RTOS_ENTER macro in xtensa_rtos.h. +* +********************************************************************************************************** +*/ +#if XCHAL_CP_NUM > 0 + + .globl _frxt_task_coproc_state + .type _frxt_task_coproc_state,@function + .align 4 +_frxt_task_coproc_state: + + + /* We can use a3 as a scratchpad, the instances of code calling XT_RTOS_CP_STATE don't seem to need it saved. */ + getcoreid a3 + movi a15, port_xSchedulerRunning /* if (port_xSchedulerRunning */ + addx4 a15, a3,a15 + l32i a15, a15, 0 + beqz a15, 1f + movi a15, port_interruptNesting /* && port_interruptNesting == 0 */ + addx4 a15, a3, a15 + l32i a15, a15, 0 + bnez a15, 1f + + movi a15, pxCurrentTCB + addx4 a15, a3, a15 + l32i a15, a15, 0 /* && pxCurrentTCB != 0) { */ + + + beqz a15, 2f + l32i a15, a15, CP_TOPOFSTACK_OFFS + ret + +1: movi a15, 0 +2: ret + +#endif /* XCHAL_CP_NUM > 0 */ diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/portmux_impl.h b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/portmux_impl.h new file mode 100755 index 0000000..60bc996 --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/portmux_impl.h @@ -0,0 +1,111 @@ +/* + Copyright (C) 2016-2017 Espressif Shanghai PTE LTD + Copyright (C) 2015 Real Time Engineers Ltd. + + All rights reserved + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. + + *************************************************************************** + >>! NOTE: The modification to the GPL is included to allow you to !<< + >>! distribute a combined work that includes FreeRTOS without being !<< + >>! obliged to provide the source code for proprietary components !<< + >>! outside of the FreeRTOS kernel. !<< + *************************************************************************** + + FreeRTOS 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. Full license text is available on the following + link: http://www.freertos.org/a00114.html +*/ + +/* This header exists for performance reasons, in order to inline the + implementation of vPortCPUAcquireMutexIntsDisabled and + vPortCPUReleaseMutexIntsDisabled into the + vTaskEnterCritical/vTaskExitCritical functions in task.c as well as the + vPortCPUAcquireMutex/vPortCPUReleaseMutex implementations. + + Normally this kind of performance hack is over the top, but + vTaskEnterCritical/vTaskExitCritical is called a great + deal by FreeRTOS internals. + + It should be #included by freertos port.c or tasks.c, in esp-idf. + + The way it works is that it essentially uses portmux_impl.inc.h as a + generator template of sorts. When no external memory is used, this + template is only used to generate the vPortCPUAcquireMutexIntsDisabledInternal + and vPortCPUReleaseMutexIntsDisabledInternal functions, which use S32C1 to + do an atomic compare & swap. When external memory is used the functions + vPortCPUAcquireMutexIntsDisabledExtram and vPortCPUReleaseMutexIntsDisabledExtram + are also generated, which use uxPortCompareSetExtram to fake the S32C1 instruction. + The wrapper functions vPortCPUAcquireMutexIntsDisabled and + vPortCPUReleaseMutexIntsDisabled will then use the appropriate function to do the + actual lock/unlock. +*/ +#include "soc/cpu.h" +#include "portable.h" + +/* XOR one core ID with this value to get the other core ID */ +#define CORE_ID_XOR_SWAP (CORE_ID_PRO ^ CORE_ID_APP) + + + + +//Define the mux routines for use with muxes in internal RAM +#define PORTMUX_AQUIRE_MUX_FN_NAME vPortCPUAcquireMutexIntsDisabledInternal +#define PORTMUX_RELEASE_MUX_FN_NAME vPortCPUReleaseMutexIntsDisabledInternal +#define PORTMUX_COMPARE_SET_FN_NAME uxPortCompareSet +#include "portmux_impl.inc.h" +#undef PORTMUX_AQUIRE_MUX_FN_NAME +#undef PORTMUX_RELEASE_MUX_FN_NAME +#undef PORTMUX_COMPARE_SET_FN_NAME + + +#if defined(CONFIG_SPIRAM_SUPPORT) + +#define PORTMUX_AQUIRE_MUX_FN_NAME vPortCPUAcquireMutexIntsDisabledExtram +#define PORTMUX_RELEASE_MUX_FN_NAME vPortCPUReleaseMutexIntsDisabledExtram +#define PORTMUX_COMPARE_SET_FN_NAME uxPortCompareSetExtram +#include "portmux_impl.inc.h" +#undef PORTMUX_AQUIRE_MUX_FN_NAME +#undef PORTMUX_RELEASE_MUX_FN_NAME +#undef PORTMUX_COMPARE_SET_FN_NAME + +#endif + + +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG +#define PORTMUX_AQUIRE_MUX_FN_ARGS portMUX_TYPE *mux, int timeout_cycles, const char *fnName, int line +#define PORTMUX_RELEASE_MUX_FN_ARGS portMUX_TYPE *mux, const char *fnName, int line +#define PORTMUX_AQUIRE_MUX_FN_CALL_ARGS(x) x, timeout_cycles, fnName, line +#define PORTMUX_RELEASE_MUX_FN_CALL_ARGS(x) x, fnName, line +#else +#define PORTMUX_AQUIRE_MUX_FN_ARGS portMUX_TYPE *mux, int timeout_cycles +#define PORTMUX_RELEASE_MUX_FN_ARGS portMUX_TYPE *mux +#define PORTMUX_AQUIRE_MUX_FN_CALL_ARGS(x) x, timeout_cycles +#define PORTMUX_RELEASE_MUX_FN_CALL_ARGS(x) x +#endif + + +static inline bool __attribute__((always_inline)) vPortCPUAcquireMutexIntsDisabled(PORTMUX_AQUIRE_MUX_FN_ARGS) { +#if defined(CONFIG_SPIRAM_SUPPORT) + if (esp_ptr_external_ram(mux)) { + return vPortCPUAcquireMutexIntsDisabledExtram(PORTMUX_AQUIRE_MUX_FN_CALL_ARGS(mux)); + } +#endif + return vPortCPUAcquireMutexIntsDisabledInternal(PORTMUX_AQUIRE_MUX_FN_CALL_ARGS(mux)); +} + + +static inline void vPortCPUReleaseMutexIntsDisabled(PORTMUX_RELEASE_MUX_FN_ARGS) { +#if defined(CONFIG_SPIRAM_SUPPORT) + if (esp_ptr_external_ram(mux)) { + vPortCPUReleaseMutexIntsDisabledExtram(PORTMUX_RELEASE_MUX_FN_CALL_ARGS(mux)); + return; + } +#endif + vPortCPUReleaseMutexIntsDisabledInternal(PORTMUX_RELEASE_MUX_FN_CALL_ARGS(mux)); +} + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/portmux_impl.inc.h b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/portmux_impl.inc.h new file mode 100755 index 0000000..07a7ce9 --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/portmux_impl.inc.h @@ -0,0 +1,169 @@ +/* + Copyright (C) 2016-2017 Espressif Shanghai PTE LTD + Copyright (C) 2015 Real Time Engineers Ltd. + + All rights reserved + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. + + *************************************************************************** + >>! NOTE: The modification to the GPL is included to allow you to !<< + >>! distribute a combined work that includes FreeRTOS without being !<< + >>! obliged to provide the source code for proprietary components !<< + >>! outside of the FreeRTOS kernel. !<< + *************************************************************************** + + FreeRTOS 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. Full license text is available on the following + link: http://www.freertos.org/a00114.html +*/ + + +/* + Warning: funky preprocessor hackery ahead. Including these headers will generate two + functions, which names are defined by the preprocessor macros + PORTMUX_AQUIRE_MUX_FN_NAME and PORTMUX_RELEASE_MUX_FN_NAME. In order to do the compare + and exchange function, they will use whatever PORTMUX_COMPARE_SET_FN_NAME resolves to. + + In some scenarios, this header is included *twice* in portmux_impl.h: one time + for the 'normal' mux code which uses a compare&exchange routine, another time + to generate code for a second set of these routines that use a second mux + (in internal ram) to fake a compare&exchange on a variable in external memory. +*/ + + + +static inline bool __attribute__((always_inline)) +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG +PORTMUX_AQUIRE_MUX_FN_NAME(portMUX_TYPE *mux, int timeout_cycles, const char *fnName, int line) { +#else +PORTMUX_AQUIRE_MUX_FN_NAME(portMUX_TYPE *mux, int timeout_cycles) { +#endif + + +#if !CONFIG_FREERTOS_UNICORE + uint32_t res; + portBASE_TYPE coreID, otherCoreID; + uint32_t ccount_start; + bool set_timeout = timeout_cycles > portMUX_NO_TIMEOUT; +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG + if (!set_timeout) { + timeout_cycles = 10000; // Always set a timeout in debug mode + set_timeout = true; + } +#endif + if (set_timeout) { // Timeout + RSR(CCOUNT, ccount_start); + } + +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG + uint32_t owner = mux->owner; + if (owner != portMUX_FREE_VAL && owner != CORE_ID_PRO && owner != CORE_ID_APP) { + ets_printf("ERROR: vPortCPUAcquireMutex: mux %p is uninitialized (0x%X)! Called from %s line %d.\n", mux, owner, fnName, line); + mux->owner=portMUX_FREE_VAL; + } +#endif + + /* Spin until we own the core */ + + RSR(PRID, coreID); + /* Note: coreID is the full 32 bit core ID (CORE_ID_PRO/CORE_ID_APP), + not the 0/1 value returned by xPortGetCoreID() + */ + otherCoreID = CORE_ID_XOR_SWAP ^ coreID; + do { + /* mux->owner should be one of portMUX_FREE_VAL, CORE_ID_PRO, + CORE_ID_APP: + + - If portMUX_FREE_VAL, we want to atomically set to 'coreID'. + - If "our" coreID, we can drop through immediately. + - If "otherCoreID", we spin here. + */ + res = coreID; + PORTMUX_COMPARE_SET_FN_NAME(&mux->owner, portMUX_FREE_VAL, &res); + + if (res != otherCoreID) { + break; // mux->owner is "our" coreID + } + + if (set_timeout) { + uint32_t ccount_now; + RSR(CCOUNT, ccount_now); + if (ccount_now - ccount_start > (unsigned)timeout_cycles) { +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG + ets_printf("Timeout on mux! last non-recursive lock %s line %d, curr %s line %d\n", mux->lastLockedFn, mux->lastLockedLine, fnName, line); + ets_printf("Owner 0x%x count %d\n", mux->owner, mux->count); +#endif + return false; + } + } + } while (1); + + assert(res == coreID || res == portMUX_FREE_VAL); /* any other value implies memory corruption or uninitialized mux */ + assert((res == portMUX_FREE_VAL) == (mux->count == 0)); /* we're first to lock iff count is zero */ + assert(mux->count < 0xFF); /* Bad count value implies memory corruption */ + + /* now we own it, we can increment the refcount */ + mux->count++; + + +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG + if (res==portMUX_FREE_VAL) { //initial lock + mux->lastLockedFn=fnName; + mux->lastLockedLine=line; + } else { + ets_printf("Recursive lock: count=%d last non-recursive lock %s line %d, curr %s line %d\n", mux->count-1, + mux->lastLockedFn, mux->lastLockedLine, fnName, line); + } +#endif /* CONFIG_FREERTOS_PORTMUX_DEBUG */ +#endif /* CONFIG_FREERTOS_UNICORE */ + return true; +} + +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG +static inline void PORTMUX_RELEASE_MUX_FN_NAME(portMUX_TYPE *mux, const char *fnName, int line) { +#else +static inline void PORTMUX_RELEASE_MUX_FN_NAME(portMUX_TYPE *mux) { +#endif + + +#if !CONFIG_FREERTOS_UNICORE + portBASE_TYPE coreID; +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG + const char *lastLockedFn=mux->lastLockedFn; + int lastLockedLine=mux->lastLockedLine; + mux->lastLockedFn=fnName; + mux->lastLockedLine=line; + uint32_t owner = mux->owner; + if (owner != portMUX_FREE_VAL && owner != CORE_ID_PRO && owner != CORE_ID_APP) { + ets_printf("ERROR: vPortCPUReleaseMutex: mux %p is invalid (0x%x)!\n", mux, mux->owner); + } +#endif + +#if CONFIG_FREERTOS_PORTMUX_DEBUG || !defined(NDEBUG) + RSR(PRID, coreID); +#endif + +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG + if (coreID != mux->owner) { + ets_printf("ERROR: vPortCPUReleaseMutex: mux %p was already unlocked!\n", mux); + ets_printf("Last non-recursive unlock %s line %d, curr unlock %s line %d\n", lastLockedFn, lastLockedLine, fnName, line); + } +#endif + + assert(coreID == mux->owner); // This is a mutex we didn't lock, or it's corrupt + + mux->count--; + if(mux->count == 0) { + mux->owner = portMUX_FREE_VAL; + } else { + assert(mux->count < 0x100); // Indicates memory corruption +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG_RECURSIVE + ets_printf("Recursive unlock: count=%d last locked %s line %d, curr %s line %d\n", mux->count, lastLockedFn, lastLockedLine, fnName, line); +#endif + } +#endif //!CONFIG_FREERTOS_UNICORE +} diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_context.S b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_context.S new file mode 100755 index 0000000..a8a19be --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_context.S @@ -0,0 +1,648 @@ +/******************************************************************************* +Copyright (c) 2006-2015 Cadence Design Systems Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------------------- + + XTENSA CONTEXT SAVE AND RESTORE ROUTINES + +Low-level Call0 functions for handling generic context save and restore of +registers not specifically addressed by the interrupt vectors and handlers. +Those registers (not handled by these functions) are PC, PS, A0, A1 (SP). +Except for the calls to RTOS functions, this code is generic to Xtensa. + +Note that in Call0 ABI, interrupt handlers are expected to preserve the callee- +save regs (A12-A15), which is always the case if the handlers are coded in C. +However A12, A13 are made available as scratch registers for interrupt dispatch +code, so are presumed saved anyway, and are always restored even in Call0 ABI. +Only A14, A15 are truly handled as callee-save regs. + +Because Xtensa is a configurable architecture, this port supports all user +generated configurations (except restrictions stated in the release notes). +This is accomplished by conditional compilation using macros and functions +defined in the Xtensa HAL (hardware adaptation layer) for your configuration. +Only the processor state included in your configuration is saved and restored, +including any processor state added by user configuration options or TIE. + +*******************************************************************************/ + +/* Warn nicely if this file gets named with a lowercase .s instead of .S: */ +#define NOERROR # +NOERROR: .error "C preprocessor needed for this file: make sure its filename\ + ends in uppercase .S, or use xt-xcc's -x assembler-with-cpp option." + + +#include "xtensa_rtos.h" +#include "xtensa_context.h" + +#ifdef XT_USE_OVLY +#include +#endif + + .text + + + +/******************************************************************************* + +_xt_context_save + + !! MUST BE CALLED ONLY BY 'CALL0' INSTRUCTION !! + +Saves all Xtensa processor state except PC, PS, A0, A1 (SP), A12, A13, in the +interrupt stack frame defined in xtensa_rtos.h. +Its counterpart is _xt_context_restore (which also restores A12, A13). + +Caller is expected to have saved PC, PS, A0, A1 (SP), A12, A13 in the frame. +This function preserves A12 & A13 in order to provide the caller with 2 scratch +regs that need not be saved over the call to this function. The choice of which +2 regs to provide is governed by xthal_window_spill_nw and xthal_save_extra_nw, +to avoid moving data more than necessary. Caller can assign regs accordingly. + +Entry Conditions: + A0 = Return address in caller. + A1 = Stack pointer of interrupted thread or handler ("interruptee"). + Original A12, A13 have already been saved in the interrupt stack frame. + Other processor state except PC, PS, A0, A1 (SP), A12, A13, is as at the + point of interruption. + If windowed ABI, PS.EXCM = 1 (exceptions disabled). + +Exit conditions: + A0 = Return address in caller. + A1 = Stack pointer of interrupted thread or handler ("interruptee"). + A12, A13 as at entry (preserved). + If windowed ABI, PS.EXCM = 1 (exceptions disabled). + +*******************************************************************************/ + + .global _xt_context_save + .type _xt_context_save,@function + .align 4 + .literal_position + .align 4 +_xt_context_save: + + s32i a2, sp, XT_STK_A2 + s32i a3, sp, XT_STK_A3 + s32i a4, sp, XT_STK_A4 + s32i a5, sp, XT_STK_A5 + s32i a6, sp, XT_STK_A6 + s32i a7, sp, XT_STK_A7 + s32i a8, sp, XT_STK_A8 + s32i a9, sp, XT_STK_A9 + s32i a10, sp, XT_STK_A10 + s32i a11, sp, XT_STK_A11 + + /* + Call0 ABI callee-saved regs a12-15 do not need to be saved here. + a12-13 are the caller's responsibility so it can use them as scratch. + So only need to save a14-a15 here for Windowed ABI (not Call0). + */ + #ifndef __XTENSA_CALL0_ABI__ + s32i a14, sp, XT_STK_A14 + s32i a15, sp, XT_STK_A15 + #endif + + rsr a3, SAR + s32i a3, sp, XT_STK_SAR + + #if XCHAL_HAVE_LOOPS + rsr a3, LBEG + s32i a3, sp, XT_STK_LBEG + rsr a3, LEND + s32i a3, sp, XT_STK_LEND + rsr a3, LCOUNT + s32i a3, sp, XT_STK_LCOUNT + #endif + + #ifdef XT_USE_SWPRI + /* Save virtual priority mask */ + movi a3, _xt_vpri_mask + l32i a3, a3, 0 + s32i a3, sp, XT_STK_VPRI + #endif + + #if XCHAL_EXTRA_SA_SIZE > 0 || !defined(__XTENSA_CALL0_ABI__) + mov a9, a0 /* preserve ret addr */ + #endif + + #ifndef __XTENSA_CALL0_ABI__ + /* + To spill the reg windows, temp. need pre-interrupt stack ptr and a4-15. + Need to save a9,12,13 temporarily (in frame temps) and recover originals. + Interrupts need to be disabled below XCHAL_EXCM_LEVEL and window overflow + and underflow exceptions disabled (assured by PS.EXCM == 1). + */ + s32i a12, sp, XT_STK_TMP0 /* temp. save stuff in stack frame */ + s32i a13, sp, XT_STK_TMP1 + s32i a9, sp, XT_STK_TMP2 + + /* + Save the overlay state if we are supporting overlays. Since we just saved + three registers, we can conveniently use them here. Note that as of now, + overlays only work for windowed calling ABI. + */ + #ifdef XT_USE_OVLY + l32i a9, sp, XT_STK_PC /* recover saved PC */ + _xt_overlay_get_state a9, a12, a13 + s32i a9, sp, XT_STK_OVLY /* save overlay state */ + #endif + + l32i a12, sp, XT_STK_A12 /* recover original a9,12,13 */ + l32i a13, sp, XT_STK_A13 + l32i a9, sp, XT_STK_A9 + addi sp, sp, XT_STK_FRMSZ /* restore the interruptee's SP */ + call0 xthal_window_spill_nw /* preserves only a4,5,8,9,12,13 */ + addi sp, sp, -XT_STK_FRMSZ + l32i a12, sp, XT_STK_TMP0 /* recover stuff from stack frame */ + l32i a13, sp, XT_STK_TMP1 + l32i a9, sp, XT_STK_TMP2 + #endif + + #if XCHAL_EXTRA_SA_SIZE > 0 + /* + NOTE: Normally the xthal_save_extra_nw macro only affects address + registers a2-a5. It is theoretically possible for Xtensa processor + designers to write TIE that causes more address registers to be + affected, but it is generally unlikely. If that ever happens, + more registers need to be saved/restored around this macro invocation. + Here we assume a9,12,13 are preserved. + Future Xtensa tools releases might limit the regs that can be affected. + */ + addi a2, sp, XT_STK_EXTRA /* where to save it */ + # if XCHAL_EXTRA_SA_ALIGN > 16 + movi a3, -XCHAL_EXTRA_SA_ALIGN + and a2, a2, a3 /* align dynamically >16 bytes */ + # endif + call0 xthal_save_extra_nw /* destroys a0,2,3,4,5 */ + #endif + + #if XCHAL_EXTRA_SA_SIZE > 0 || !defined(__XTENSA_CALL0_ABI__) + mov a0, a9 /* retrieve ret addr */ + #endif + + ret + +/******************************************************************************* + +_xt_context_restore + + !! MUST BE CALLED ONLY BY 'CALL0' INSTRUCTION !! + +Restores all Xtensa processor state except PC, PS, A0, A1 (SP) (and in Call0 +ABI, A14, A15 which are preserved by all interrupt handlers) from an interrupt +stack frame defined in xtensa_rtos.h . +Its counterpart is _xt_context_save (whose caller saved A12, A13). + +Caller is responsible to restore PC, PS, A0, A1 (SP). + +Entry Conditions: + A0 = Return address in caller. + A1 = Stack pointer of interrupted thread or handler ("interruptee"). + +Exit conditions: + A0 = Return address in caller. + A1 = Stack pointer of interrupted thread or handler ("interruptee"). + Other processor state except PC, PS, A0, A1 (SP), is as at the point + of interruption. + +*******************************************************************************/ + + .global _xt_context_restore + .type _xt_context_restore,@function + .align 4 + .literal_position + .align 4 +_xt_context_restore: + + #if XCHAL_EXTRA_SA_SIZE > 0 + /* + NOTE: Normally the xthal_restore_extra_nw macro only affects address + registers a2-a5. It is theoretically possible for Xtensa processor + designers to write TIE that causes more address registers to be + affected, but it is generally unlikely. If that ever happens, + more registers need to be saved/restored around this macro invocation. + Here we only assume a13 is preserved. + Future Xtensa tools releases might limit the regs that can be affected. + */ + mov a13, a0 /* preserve ret addr */ + addi a2, sp, XT_STK_EXTRA /* where to find it */ + # if XCHAL_EXTRA_SA_ALIGN > 16 + movi a3, -XCHAL_EXTRA_SA_ALIGN + and a2, a2, a3 /* align dynamically >16 bytes */ + # endif + call0 xthal_restore_extra_nw /* destroys a0,2,3,4,5 */ + mov a0, a13 /* retrieve ret addr */ + #endif + + #if XCHAL_HAVE_LOOPS + l32i a2, sp, XT_STK_LBEG + l32i a3, sp, XT_STK_LEND + wsr a2, LBEG + l32i a2, sp, XT_STK_LCOUNT + wsr a3, LEND + wsr a2, LCOUNT + #endif + + #ifdef XT_USE_OVLY + /* + If we are using overlays, this is a good spot to check if we need + to restore an overlay for the incoming task. Here we have a bunch + of registers to spare. Note that this step is going to use a few + bytes of storage below SP (SP-20 to SP-32) if an overlay is going + to be restored. + */ + l32i a2, sp, XT_STK_PC /* retrieve PC */ + l32i a3, sp, XT_STK_PS /* retrieve PS */ + l32i a4, sp, XT_STK_OVLY /* retrieve overlay state */ + l32i a5, sp, XT_STK_A1 /* retrieve stack ptr */ + _xt_overlay_check_map a2, a3, a4, a5, a6 + s32i a2, sp, XT_STK_PC /* save updated PC */ + s32i a3, sp, XT_STK_PS /* save updated PS */ + #endif + + #ifdef XT_USE_SWPRI + /* Restore virtual interrupt priority and interrupt enable */ + movi a3, _xt_intdata + l32i a4, a3, 0 /* a4 = _xt_intenable */ + l32i a5, sp, XT_STK_VPRI /* a5 = saved _xt_vpri_mask */ + and a4, a4, a5 + wsr a4, INTENABLE /* update INTENABLE */ + s32i a5, a3, 4 /* restore _xt_vpri_mask */ + #endif + + l32i a3, sp, XT_STK_SAR + l32i a2, sp, XT_STK_A2 + wsr a3, SAR + l32i a3, sp, XT_STK_A3 + l32i a4, sp, XT_STK_A4 + l32i a5, sp, XT_STK_A5 + l32i a6, sp, XT_STK_A6 + l32i a7, sp, XT_STK_A7 + l32i a8, sp, XT_STK_A8 + l32i a9, sp, XT_STK_A9 + l32i a10, sp, XT_STK_A10 + l32i a11, sp, XT_STK_A11 + + /* + Call0 ABI callee-saved regs a12-15 do not need to be restored here. + However a12-13 were saved for scratch before XT_RTOS_INT_ENTER(), + so need to be restored anyway, despite being callee-saved in Call0. + */ + l32i a12, sp, XT_STK_A12 + l32i a13, sp, XT_STK_A13 + #ifndef __XTENSA_CALL0_ABI__ + l32i a14, sp, XT_STK_A14 + l32i a15, sp, XT_STK_A15 + #endif + + ret + + +/******************************************************************************* + +_xt_coproc_init + +Initializes global co-processor management data, setting all co-processors +to "unowned". Leaves CPENABLE as it found it (does NOT clear it). + +Called during initialization of the RTOS, before any threads run. + +This may be called from normal Xtensa single-threaded application code which +might use co-processors. The Xtensa run-time initialization enables all +co-processors. They must remain enabled here, else a co-processor exception +might occur outside of a thread, which the exception handler doesn't expect. + +Entry Conditions: + Xtensa single-threaded run-time environment is in effect. + No thread is yet running. + +Exit conditions: + None. + +Obeys ABI conventions per prototype: + void _xt_coproc_init(void) + +*******************************************************************************/ + +#if XCHAL_CP_NUM > 0 + + .global _xt_coproc_init + .type _xt_coproc_init,@function + .align 4 + .literal_position + .align 4 +_xt_coproc_init: + ENTRY0 + + /* Initialize thread co-processor ownerships to 0 (unowned). */ + movi a2, _xt_coproc_owner_sa /* a2 = base of owner array */ + addi a3, a2, (XCHAL_CP_MAX*portNUM_PROCESSORS) << 2 /* a3 = top+1 of owner array */ + movi a4, 0 /* a4 = 0 (unowned) */ +1: s32i a4, a2, 0 + addi a2, a2, 4 + bltu a2, a3, 1b + + RET0 + +#endif + + +/******************************************************************************* + +_xt_coproc_release + +Releases any and all co-processors owned by a given thread. The thread is +identified by it's co-processor state save area defined in xtensa_context.h . + +Must be called before a thread's co-proc save area is deleted to avoid +memory corruption when the exception handler tries to save the state. +May be called when a thread terminates or completes but does not delete +the co-proc save area, to avoid the exception handler having to save the +thread's co-proc state before another thread can use it (optimization). + +Needs to be called on the processor the thread was running on. Unpinned threads +won't have an entry here because they get pinned as soon they use a coprocessor. + +Entry Conditions: + A2 = Pointer to base of co-processor state save area. + +Exit conditions: + None. + +Obeys ABI conventions per prototype: + void _xt_coproc_release(void * coproc_sa_base) + +*******************************************************************************/ + +#if XCHAL_CP_NUM > 0 + + .global _xt_coproc_release + .type _xt_coproc_release,@function + .align 4 + .literal_position + .align 4 +_xt_coproc_release: + ENTRY0 /* a2 = base of save area */ + + getcoreid a5 + movi a3, XCHAL_CP_MAX << 2 + mull a5, a5, a3 + movi a3, _xt_coproc_owner_sa /* a3 = base of owner array */ + add a3, a3, a5 + + addi a4, a3, XCHAL_CP_MAX << 2 /* a4 = top+1 of owner array */ + movi a5, 0 /* a5 = 0 (unowned) */ + + rsil a6, XCHAL_EXCM_LEVEL /* lock interrupts */ + +1: l32i a7, a3, 0 /* a7 = owner at a3 */ + bne a2, a7, 2f /* if (coproc_sa_base == owner) */ + s32i a5, a3, 0 /* owner = unowned */ +2: addi a3, a3, 1<<2 /* a3 = next entry in owner array */ + bltu a3, a4, 1b /* repeat until end of array */ + +3: wsr a6, PS /* restore interrupts */ + + RET0 + +#endif + + +/******************************************************************************* +_xt_coproc_savecs + +If there is a current thread and it has a coprocessor state save area, then +save all callee-saved state into this area. This function is called from the +solicited context switch handler. It calls a system-specific function to get +the coprocessor save area base address. + +Entry conditions: + - The thread being switched out is still the current thread. + - CPENABLE state reflects which coprocessors are active. + - Registers have been saved/spilled already. + +Exit conditions: + - All necessary CP callee-saved state has been saved. + - Registers a2-a7, a13-a15 have been trashed. + +Must be called from assembly code only, using CALL0. +*******************************************************************************/ +#if XCHAL_CP_NUM > 0 + + .extern _xt_coproc_sa_offset /* external reference */ + + .global _xt_coproc_savecs + .type _xt_coproc_savecs,@function + .align 4 + .literal_position + .align 4 +_xt_coproc_savecs: + + /* At entry, CPENABLE should be showing which CPs are enabled. */ + + rsr a2, CPENABLE /* a2 = which CPs are enabled */ + beqz a2, .Ldone /* quick exit if none */ + mov a14, a0 /* save return address */ + call0 XT_RTOS_CP_STATE /* get address of CP save area */ + mov a0, a14 /* restore return address */ + beqz a15, .Ldone /* if none then nothing to do */ + s16i a2, a15, XT_CP_CS_ST /* save mask of CPs being stored */ + movi a13, _xt_coproc_sa_offset /* array of CP save offsets */ + l32i a15, a15, XT_CP_ASA /* a15 = base of aligned save area */ + +#if XCHAL_CP0_SA_SIZE + bbci.l a2, 0, 2f /* CP 0 not enabled */ + l32i a14, a13, 0 /* a14 = _xt_coproc_sa_offset[0] */ + add a3, a14, a15 /* a3 = save area for CP 0 */ + xchal_cp0_store a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +#if XCHAL_CP1_SA_SIZE + bbci.l a2, 1, 2f /* CP 1 not enabled */ + l32i a14, a13, 4 /* a14 = _xt_coproc_sa_offset[1] */ + add a3, a14, a15 /* a3 = save area for CP 1 */ + xchal_cp1_store a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +#if XCHAL_CP2_SA_SIZE + bbci.l a2, 2, 2f + l32i a14, a13, 8 + add a3, a14, a15 + xchal_cp2_store a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +#if XCHAL_CP3_SA_SIZE + bbci.l a2, 3, 2f + l32i a14, a13, 12 + add a3, a14, a15 + xchal_cp3_store a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +#if XCHAL_CP4_SA_SIZE + bbci.l a2, 4, 2f + l32i a14, a13, 16 + add a3, a14, a15 + xchal_cp4_store a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +#if XCHAL_CP5_SA_SIZE + bbci.l a2, 5, 2f + l32i a14, a13, 20 + add a3, a14, a15 + xchal_cp5_store a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +#if XCHAL_CP6_SA_SIZE + bbci.l a2, 6, 2f + l32i a14, a13, 24 + add a3, a14, a15 + xchal_cp6_store a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +#if XCHAL_CP7_SA_SIZE + bbci.l a2, 7, 2f + l32i a14, a13, 28 + add a3, a14, a15 + xchal_cp7_store a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +.Ldone: + ret +#endif + + +/******************************************************************************* +_xt_coproc_restorecs + +Restore any callee-saved coprocessor state for the incoming thread. +This function is called from coprocessor exception handling, when giving +ownership to a thread that solicited a context switch earlier. It calls a +system-specific function to get the coprocessor save area base address. + +Entry conditions: + - The incoming thread is set as the current thread. + - CPENABLE is set up correctly for all required coprocessors. + - a2 = mask of coprocessors to be restored. + +Exit conditions: + - All necessary CP callee-saved state has been restored. + - CPENABLE - unchanged. + - Registers a2-a7, a13-a15 have been trashed. + +Must be called from assembly code only, using CALL0. +*******************************************************************************/ +#if XCHAL_CP_NUM > 0 + + .global _xt_coproc_restorecs + .type _xt_coproc_restorecs,@function + .align 4 + .literal_position + .align 4 +_xt_coproc_restorecs: + + mov a14, a0 /* save return address */ + call0 XT_RTOS_CP_STATE /* get address of CP save area */ + mov a0, a14 /* restore return address */ + beqz a15, .Ldone2 /* if none then nothing to do */ + l16ui a3, a15, XT_CP_CS_ST /* a3 = which CPs have been saved */ + xor a3, a3, a2 /* clear the ones being restored */ + s32i a3, a15, XT_CP_CS_ST /* update saved CP mask */ + movi a13, _xt_coproc_sa_offset /* array of CP save offsets */ + l32i a15, a15, XT_CP_ASA /* a15 = base of aligned save area */ + +#if XCHAL_CP0_SA_SIZE + bbci.l a2, 0, 2f /* CP 0 not enabled */ + l32i a14, a13, 0 /* a14 = _xt_coproc_sa_offset[0] */ + add a3, a14, a15 /* a3 = save area for CP 0 */ + xchal_cp0_load a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +#if XCHAL_CP1_SA_SIZE + bbci.l a2, 1, 2f /* CP 1 not enabled */ + l32i a14, a13, 4 /* a14 = _xt_coproc_sa_offset[1] */ + add a3, a14, a15 /* a3 = save area for CP 1 */ + xchal_cp1_load a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +#if XCHAL_CP2_SA_SIZE + bbci.l a2, 2, 2f + l32i a14, a13, 8 + add a3, a14, a15 + xchal_cp2_load a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +#if XCHAL_CP3_SA_SIZE + bbci.l a2, 3, 2f + l32i a14, a13, 12 + add a3, a14, a15 + xchal_cp3_load a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +#if XCHAL_CP4_SA_SIZE + bbci.l a2, 4, 2f + l32i a14, a13, 16 + add a3, a14, a15 + xchal_cp4_load a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +#if XCHAL_CP5_SA_SIZE + bbci.l a2, 5, 2f + l32i a14, a13, 20 + add a3, a14, a15 + xchal_cp5_load a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +#if XCHAL_CP6_SA_SIZE + bbci.l a2, 6, 2f + l32i a14, a13, 24 + add a3, a14, a15 + xchal_cp6_load a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +#if XCHAL_CP7_SA_SIZE + bbci.l a2, 7, 2f + l32i a14, a13, 28 + add a3, a14, a15 + xchal_cp7_load a3, a4, a5, a6, a7 continue=0 ofs=-1 select=XTHAL_SAS_TIE|XTHAL_SAS_NOCC|XTHAL_SAS_CALE alloc=XTHAL_SAS_ALL +2: +#endif + +.Ldone2: + ret + +#endif + + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_init.c b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_init.c new file mode 100755 index 0000000..624f242 --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_init.c @@ -0,0 +1,55 @@ +/******************************************************************************* +// Copyright (c) 2003-2015 Cadence Design Systems, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------------------- + + XTENSA INITIALIZATION ROUTINES CODED IN C + +This file contains miscellaneous Xtensa RTOS-generic initialization functions +that are implemented in C. + +*******************************************************************************/ + + +#ifdef XT_BOARD +#include +#endif + +#include "xtensa_rtos.h" +#include "esp_clk.h" + +#ifdef XT_RTOS_TIMER_INT + +unsigned _xt_tick_divisor = 0; /* cached number of cycles per tick */ + +void _xt_tick_divisor_init(void) +{ + _xt_tick_divisor = esp_clk_cpu_freq() / XT_TICK_PER_SEC; +} + +/* Deprecated, to be removed */ +int xt_clock_freq(void) +{ + return esp_clk_cpu_freq(); +} + +#endif /* XT_RTOS_TIMER_INT */ + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_intr.c b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_intr.c new file mode 100755 index 0000000..856096d --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_intr.c @@ -0,0 +1,158 @@ +/******************************************************************************* +Copyright (c) 2006-2015 Cadence Design Systems Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + +/****************************************************************************** + Xtensa-specific interrupt and exception functions for RTOS ports. + Also see xtensa_intr_asm.S. +******************************************************************************/ + +#include + +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/xtensa_api.h" +#include "freertos/portable.h" + +#include "rom/ets_sys.h" + +#if XCHAL_HAVE_EXCEPTIONS + +/* Handler table is in xtensa_intr_asm.S */ + +extern xt_exc_handler _xt_exception_table[XCHAL_EXCCAUSE_NUM*portNUM_PROCESSORS]; + + +/* + Default handler for unhandled exceptions. + CHANGED: We do this in panic.c now +*/ + +//void xt_unhandled_exception(XtExcFrame *frame) +//{ + //exit(-1); +//} +extern void xt_unhandled_exception(XtExcFrame *frame); + + +/* + This function registers a handler for the specified exception. + The function returns the address of the previous handler. + On error, it returns 0. +*/ +xt_exc_handler xt_set_exception_handler(int n, xt_exc_handler f) +{ + xt_exc_handler old; + + if( n < 0 || n >= XCHAL_EXCCAUSE_NUM ) + return 0; /* invalid exception number */ + + /* Convert exception number to _xt_exception_table name */ + n = n * portNUM_PROCESSORS + xPortGetCoreID(); + old = _xt_exception_table[n]; + + if (f) { + _xt_exception_table[n] = f; + } + else { + _xt_exception_table[n] = &xt_unhandled_exception; + } + + return ((old == &xt_unhandled_exception) ? 0 : old); +} + +#endif + +#if XCHAL_HAVE_INTERRUPTS + +/* Handler table is in xtensa_intr_asm.S */ + +typedef struct xt_handler_table_entry { + void * handler; + void * arg; +} xt_handler_table_entry; + +extern xt_handler_table_entry _xt_interrupt_table[XCHAL_NUM_INTERRUPTS*portNUM_PROCESSORS]; + + +/* + Default handler for unhandled interrupts. +*/ +void xt_unhandled_interrupt(void * arg) +{ + ets_printf("Unhandled interrupt %d on cpu %d!\n", (int)arg, xPortGetCoreID()); +} + + +/* + This function registers a handler for the specified interrupt. The "arg" + parameter specifies the argument to be passed to the handler when it is + invoked. The function returns the address of the previous handler. + On error, it returns 0. +*/ +xt_handler xt_set_interrupt_handler(int n, xt_handler f, void * arg) +{ + xt_handler_table_entry * entry; + xt_handler old; + + if( n < 0 || n >= XCHAL_NUM_INTERRUPTS ) + return 0; /* invalid interrupt number */ + if( Xthal_intlevel[n] > XCHAL_EXCM_LEVEL ) + return 0; /* priority level too high to safely handle in C */ + + /* Convert exception number to _xt_exception_table name */ + n = n * portNUM_PROCESSORS + xPortGetCoreID(); + + entry = _xt_interrupt_table + n; + old = entry->handler; + + if (f) { + entry->handler = f; + entry->arg = arg; + } + else { + entry->handler = &xt_unhandled_interrupt; + entry->arg = (void*)n; + } + + return ((old == &xt_unhandled_interrupt) ? 0 : old); +} + +#if CONFIG_SYSVIEW_ENABLE +void * xt_get_interrupt_handler_arg(int n) +{ + xt_handler_table_entry * entry; + + if( n < 0 || n >= XCHAL_NUM_INTERRUPTS ) + return 0; /* invalid interrupt number */ + + /* Convert exception number to _xt_exception_table name */ + n = n * portNUM_PROCESSORS + xPortGetCoreID(); + + entry = _xt_interrupt_table + n; + return entry->arg; +} +#endif + +#endif /* XCHAL_HAVE_INTERRUPTS */ + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_intr_asm.S b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_intr_asm.S new file mode 100755 index 0000000..f2d2361 --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_intr_asm.S @@ -0,0 +1,225 @@ +/******************************************************************************* +Copyright (c) 2006-2015 Cadence Design Systems Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + +/****************************************************************************** + Xtensa interrupt handling data and assembly routines. + Also see xtensa_intr.c and xtensa_vectors.S. +******************************************************************************/ + +#include +#include + +#include "xtensa_context.h" +#include "FreeRTOSConfig.h" + +#if XCHAL_HAVE_INTERRUPTS + +/* +------------------------------------------------------------------------------- + INTENABLE virtualization information. +------------------------------------------------------------------------------- +*/ + + +#if XT_USE_SWPRI +/* Warning - this is not multicore-compatible. */ + .data + .global _xt_intdata + .align 8 +_xt_intdata: + .global _xt_intenable + .type _xt_intenable,@object + .size _xt_intenable,4 + .global _xt_vpri_mask + .type _xt_vpri_mask,@object + .size _xt_vpri_mask,4 + +_xt_intenable: .word 0 /* Virtual INTENABLE */ +_xt_vpri_mask: .word 0xFFFFFFFF /* Virtual priority mask */ +#endif + +/* +------------------------------------------------------------------------------- + Table of C-callable interrupt handlers for each interrupt. Note that not all + slots can be filled, because interrupts at level > EXCM_LEVEL will not be + dispatched to a C handler by default. + + Stored as: + int 0 cpu 0 + int 0 cpu 1 + ... + int 0 cpu n + int 1 cpu 0 + int 1 cpu 1 + etc +------------------------------------------------------------------------------- +*/ + + .data + .global _xt_interrupt_table + .align 8 + +_xt_interrupt_table: + + .set i, 0 + .rept XCHAL_NUM_INTERRUPTS*portNUM_PROCESSORS + .word xt_unhandled_interrupt /* handler address */ + .word i /* handler arg (default: intnum) */ + .set i, i+1 + .endr + +#endif /* XCHAL_HAVE_INTERRUPTS */ + + +#if XCHAL_HAVE_EXCEPTIONS + +/* +------------------------------------------------------------------------------- + Table of C-callable exception handlers for each exception. Note that not all + slots will be active, because some exceptions (e.g. coprocessor exceptions) + are always handled by the OS and cannot be hooked by user handlers. + + Stored as: + exc 0 cpu 0 + exc 0 cpu 1 + ... + exc 0 cpu n + exc 1 cpu 0 + exc 1 cpu 1 + etc +------------------------------------------------------------------------------- +*/ + + .data + .global _xt_exception_table + .align 4 + +_xt_exception_table: + .rept XCHAL_EXCCAUSE_NUM * portNUM_PROCESSORS + .word xt_unhandled_exception /* handler address */ + .endr + +#endif + + +/* +------------------------------------------------------------------------------- + unsigned int xt_ints_on ( unsigned int mask ) + + Enables a set of interrupts. Does not simply set INTENABLE directly, but + computes it as a function of the current virtual priority if XT_USE_SWPRI is + enabled. + Can be called from interrupt handlers. +------------------------------------------------------------------------------- +*/ + + .text + .align 4 + .global xt_ints_on + .type xt_ints_on,@function + +xt_ints_on: + + ENTRY0 + +#if XCHAL_HAVE_INTERRUPTS +#if XT_USE_SWPRI + movi a3, 0 + movi a4, _xt_intdata + xsr a3, INTENABLE /* Disables all interrupts */ + rsync + l32i a3, a4, 0 /* a3 = _xt_intenable */ + l32i a6, a4, 4 /* a6 = _xt_vpri_mask */ + or a5, a3, a2 /* a5 = _xt_intenable | mask */ + s32i a5, a4, 0 /* _xt_intenable |= mask */ + and a5, a5, a6 /* a5 = _xt_intenable & _xt_vpri_mask */ + wsr a5, INTENABLE /* Reenable interrupts */ + mov a2, a3 /* Previous mask */ +#else + movi a3, 0 + xsr a3, INTENABLE /* Disables all interrupts */ + rsync + or a2, a3, a2 /* set bits in mask */ + wsr a2, INTENABLE /* Re-enable ints */ + rsync + mov a2, a3 /* return prev mask */ +#endif +#else + movi a2, 0 /* Return zero */ +#endif + RET0 + + .size xt_ints_on, . - xt_ints_on + + +/* +------------------------------------------------------------------------------- + unsigned int xt_ints_off ( unsigned int mask ) + + Disables a set of interrupts. Does not simply set INTENABLE directly, + but computes it as a function of the current virtual priority if XT_USE_SWPRI is + enabled. + Can be called from interrupt handlers. +------------------------------------------------------------------------------- +*/ + + .text + .align 4 + .global xt_ints_off + .type xt_ints_off,@function + +xt_ints_off: + + ENTRY0 +#if XCHAL_HAVE_INTERRUPTS +#if XT_USE_SWPRI + movi a3, 0 + movi a4, _xt_intdata + xsr a3, INTENABLE /* Disables all interrupts */ + rsync + l32i a3, a4, 0 /* a3 = _xt_intenable */ + l32i a6, a4, 4 /* a6 = _xt_vpri_mask */ + or a5, a3, a2 /* a5 = _xt_intenable | mask */ + xor a5, a5, a2 /* a5 = _xt_intenable & ~mask */ + s32i a5, a4, 0 /* _xt_intenable &= ~mask */ + and a5, a5, a6 /* a5 = _xt_intenable & _xt_vpri_mask */ + wsr a5, INTENABLE /* Reenable interrupts */ + mov a2, a3 /* Previous mask */ +#else + movi a4, 0 + xsr a4, INTENABLE /* Disables all interrupts */ + rsync + or a3, a4, a2 /* set bits in mask */ + xor a3, a3, a2 /* invert bits in mask set in mask, essentially clearing them */ + wsr a3, INTENABLE /* Re-enable ints */ + rsync + mov a2, a4 /* return prev mask */ +#endif +#else + movi a2, 0 /* return zero */ +#endif + RET0 + + .size xt_ints_off, . - xt_ints_off + + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_overlay_os_hook.c b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_overlay_os_hook.c new file mode 100755 index 0000000..a5ca23c --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_overlay_os_hook.c @@ -0,0 +1,67 @@ +// xtensa_overlay_os_hook.c -- Overlay manager OS hooks for FreeRTOS. + +// Copyright (c) 2015-2015 Cadence Design Systems Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +#include "FreeRTOS.h" +#include "semphr.h" + +#if configUSE_MUTEX + +/* Mutex object that controls access to the overlay. Currently only one + * overlay region is supported so one mutex suffices. + */ +static SemaphoreHandle_t xt_overlay_mutex; + + +/* This function should be overridden to provide OS specific init such + * as the creation of a mutex lock that can be used for overlay locking. + * Typically this mutex would be set up with priority inheritance. See + * overlay manager documentation for more details. + */ +void xt_overlay_init_os(void) +{ + /* Create the mutex for overlay access. Priority inheritance is + * required. + */ + xt_overlay_mutex = xSemaphoreCreateMutex(); +} + + +/* This function locks access to shared overlay resources, typically + * by acquiring a mutex. + */ +void xt_overlay_lock(void) +{ + xSemaphoreTake(xt_overlay_mutex, 0); +} + + +/* This function releases access to shared overlay resources, typically + * by unlocking a mutex. + */ +void xt_overlay_unlock(void) +{ + xSemaphoreGive(xt_overlay_mutex); +} + +#endif diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_vector_defaults.S b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_vector_defaults.S new file mode 100755 index 0000000..592dc32 --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_vector_defaults.S @@ -0,0 +1,164 @@ +// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "xtensa_rtos.h" +#include "esp_panic.h" +#include "sdkconfig.h" +#include "soc/soc.h" + +/* +This file contains the default handlers for the high interrupt levels as well as some specialized exceptions. +The default behaviour is to just exit the interrupt or call the panic handler on the exceptions +*/ + + +#if XCHAL_HAVE_DEBUG + .global xt_debugexception + .weak xt_debugexception + .set xt_debugexception, _xt_debugexception + .section .iram1,"ax" + .type _xt_debugexception,@function + .align 4 + +_xt_debugexception: + movi a0,PANIC_RSN_DEBUGEXCEPTION + wsr a0,EXCCAUSE + /* _xt_panic assumes a level 1 exception. As we're + crashing anyhow, copy EPC & EXCSAVE from DEBUGLEVEL + to level 1. */ + rsr a0,(EPC + XCHAL_DEBUGLEVEL) + wsr a0,EPC_1 + rsr a0,(EXCSAVE + XCHAL_DEBUGLEVEL) + wsr a0,EXCSAVE_1 + call0 _xt_panic /* does not return */ + rfi XCHAL_DEBUGLEVEL + +#endif /* Debug exception */ + + +#if XCHAL_NUM_INTLEVELS >=2 && XCHAL_EXCM_LEVEL <2 && XCHAL_DEBUGLEVEL !=2 + .global xt_highint2 + .weak xt_highint2 + .set xt_highint2, _xt_highint2 + .section .iram1,"ax" + .type _xt_highint2,@function + .align 4 +_xt_highint2: + + /* Default handler does nothing; just returns */ + .align 4 +.L_xt_highint2_exit: + rsr a0, EXCSAVE_2 /* restore a0 */ + rfi 2 + +#endif /* Level 2 */ + +#if XCHAL_NUM_INTLEVELS >=3 && XCHAL_EXCM_LEVEL <3 && XCHAL_DEBUGLEVEL !=3 + + .global xt_highint3 + .weak xt_highint3 + .set xt_highint3, _xt_highint3 + .section .iram1,"ax" + .type _xt_highint3,@function + .align 4 +_xt_highint3: + + /* Default handler does nothing; just returns */ + + .align 4 +.L_xt_highint3_exit: + rsr a0, EXCSAVE_3 /* restore a0 */ + rfi 3 + +#endif /* Level 3 */ + +#if XCHAL_NUM_INTLEVELS >=4 && XCHAL_EXCM_LEVEL <4 && XCHAL_DEBUGLEVEL !=4 + + .global xt_highint4 + .weak xt_highint4 + .set xt_highint4, _xt_highint4 + .section .iram1,"ax" + .type _xt_highint4,@function + .align 4 +_xt_highint4: + + /* Default handler does nothing; just returns */ + + .align 4 +.L_xt_highint4_exit: + rsr a0, EXCSAVE_4 /* restore a0 */ + rfi 4 + +#endif /* Level 4 */ + +#if XCHAL_NUM_INTLEVELS >=5 && XCHAL_EXCM_LEVEL <5 && XCHAL_DEBUGLEVEL !=5 + + .global xt_highint5 + .weak xt_highint5 + .set xt_highint5, _xt_highint5 + .section .iram1,"ax" + .type _xt_highint5,@function + .align 4 +_xt_highint5: + + /* Default handler does nothing; just returns */ + + .align 4 +.L_xt_highint5_exit: + rsr a0, EXCSAVE_5 /* restore a0 */ + rfi 5 + + +#endif /* Level 5 */ + +#if XCHAL_NUM_INTLEVELS >=6 && XCHAL_EXCM_LEVEL <6 && XCHAL_DEBUGLEVEL !=6 + + .global _xt_highint6 + .global xt_highint6 + .weak xt_highint6 + .set xt_highint6, _xt_highint6 + .section .iram1,"ax" + .type _xt_highint6,@function + .align 4 +_xt_highint6: + + /* Default handler does nothing; just returns */ + + .align 4 +.L_xt_highint6_exit: + rsr a0, EXCSAVE_6 /* restore a0 */ + rfi 6 + +#endif /* Level 6 */ + +#if XCHAL_HAVE_NMI + + .global _xt_nmi + .global xt_nmi + .weak xt_nmi + .set xt_nmi, _xt_nmi + .section .iram1,"ax" + .type _xt_nmi,@function + .align 4 +_xt_nmi: + + /* Default handler does nothing; just returns */ + + .align 4 +.L_xt_nmi_exit: + rsr a0, EXCSAVE + XCHAL_NMILEVEL /* restore a0 */ + rfi XCHAL_NMILEVEL + +#endif /* NMI */ + diff --git a/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_vectors.S b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_vectors.S new file mode 100755 index 0000000..b023837 --- /dev/null +++ b/FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_vectors.S @@ -0,0 +1,1891 @@ +/******************************************************************************* +Copyright (c) 2006-2015 Cadence Design Systems Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------------------- + + XTENSA VECTORS AND LOW LEVEL HANDLERS FOR AN RTOS + + Xtensa low level exception and interrupt vectors and handlers for an RTOS. + + Interrupt handlers and user exception handlers support interaction with + the RTOS by calling XT_RTOS_INT_ENTER and XT_RTOS_INT_EXIT before and + after user's specific interrupt handlers. These macros are defined in + xtensa_.h to call suitable functions in a specific RTOS. + + Users can install application-specific interrupt handlers for low and + medium level interrupts, by calling xt_set_interrupt_handler(). These + handlers can be written in C, and must obey C calling convention. The + handler table is indexed by the interrupt number. Each handler may be + provided with an argument. + + Note that the system timer interrupt is handled specially, and is + dispatched to the RTOS-specific handler. This timer cannot be hooked + by application code. + + Optional hooks are also provided to install a handler per level at + run-time, made available by compiling this source file with + '-DXT_INTEXC_HOOKS' (useful for automated testing). + +!! This file is a template that usually needs to be modified to handle !! +!! application specific interrupts. Search USER_EDIT for helpful comments !! +!! on where to insert handlers and how to write them. !! + + Users can also install application-specific exception handlers in the + same way, by calling xt_set_exception_handler(). One handler slot is + provided for each exception type. Note that some exceptions are handled + by the porting layer itself, and cannot be taken over by application + code in this manner. These are the alloca, syscall, and coprocessor + exceptions. + + The exception handlers can be written in C, and must follow C calling + convention. Each handler is passed a pointer to an exception frame as + its single argument. The exception frame is created on the stack, and + holds the saved context of the thread that took the exception. If the + handler returns, the context will be restored and the instruction that + caused the exception will be retried. If the handler makes any changes + to the saved state in the exception frame, the changes will be applied + when restoring the context. + + Because Xtensa is a configurable architecture, this port supports all user + generated configurations (except restrictions stated in the release notes). + This is accomplished by conditional compilation using macros and functions + defined in the Xtensa HAL (hardware adaptation layer) for your configuration. + Only the relevant parts of this file will be included in your RTOS build. + For example, this file provides interrupt vector templates for all types and + all priority levels, but only the ones in your configuration are built. + + NOTES on the use of 'call0' for long jumps instead of 'j': + 1. This file should be assembled with the -mlongcalls option to xt-xcc. + 2. The -mlongcalls compiler option causes 'call0 dest' to be expanded to + a sequence 'l32r a0, dest' 'callx0 a0' which works regardless of the + distance from the call to the destination. The linker then relaxes + it back to 'call0 dest' if it determines that dest is within range. + This allows more flexibility in locating code without the performance + overhead of the 'l32r' literal data load in cases where the destination + is in range of 'call0'. There is an additional benefit in that 'call0' + has a longer range than 'j' due to the target being word-aligned, so + the 'l32r' sequence is less likely needed. + 3. The use of 'call0' with -mlongcalls requires that register a0 not be + live at the time of the call, which is always the case for a function + call but needs to be ensured if 'call0' is used as a jump in lieu of 'j'. + 4. This use of 'call0' is independent of the C function call ABI. + +*******************************************************************************/ + +#include "xtensa_rtos.h" +#include "esp_panic.h" +#include "sdkconfig.h" +#include "soc/soc.h" +#include "soc/dport_reg.h" + +/* + Define for workaround: pin no-cpu-affinity tasks to a cpu when fpu is used. + Please change this when the tcb structure is changed +*/ +#define TASKTCB_XCOREID_OFFSET (0x38+configMAX_TASK_NAME_LEN+3)&~3 +.extern pxCurrentTCB + +/* Enable stack backtrace across exception/interrupt - see below */ +#ifdef CONFIG_FREERTOS_INTERRUPT_BACKTRACE +#define XT_DEBUG_BACKTRACE 1 +#endif + + +/* +-------------------------------------------------------------------------------- + Defines used to access _xtos_interrupt_table. +-------------------------------------------------------------------------------- +*/ +#define XIE_HANDLER 0 +#define XIE_ARG 4 +#define XIE_SIZE 8 + + +/* + Macro get_percpu_entry_for - convert a per-core ID into a multicore entry. + Basically does reg=reg*portNUM_PROCESSORS+current_core_id + Multiple versions here to optimize for specific portNUM_PROCESSORS values. +*/ + .macro get_percpu_entry_for reg scratch +#if (portNUM_PROCESSORS == 1) + /* No need to do anything */ +#elif (portNUM_PROCESSORS == 2) + /* Optimized 2-core code. */ + getcoreid \scratch + addx2 \reg,\reg,\scratch +#else + /* Generalized n-core code. Untested! */ + movi \scratch,portNUM_PROCESSORS + mull \scratch,\reg,\scratch + getcoreid \reg + add \reg,\scratch,\reg +#endif + .endm +/* +-------------------------------------------------------------------------------- + Macro extract_msb - return the input with only the highest bit set. + + Input : "ain" - Input value, clobbered. + Output : "aout" - Output value, has only one bit set, MSB of "ain". + The two arguments must be different AR registers. +-------------------------------------------------------------------------------- +*/ + + .macro extract_msb aout ain +1: + addi \aout, \ain, -1 /* aout = ain - 1 */ + and \ain, \ain, \aout /* ain = ain & aout */ + bnez \ain, 1b /* repeat until ain == 0 */ + addi \aout, \aout, 1 /* return aout + 1 */ + .endm + +/* +-------------------------------------------------------------------------------- + Macro dispatch_c_isr - dispatch interrupts to user ISRs. + This will dispatch to user handlers (if any) that are registered in the + XTOS dispatch table (_xtos_interrupt_table). These handlers would have + been registered by calling _xtos_set_interrupt_handler(). There is one + exception - the timer interrupt used by the OS will not be dispatched + to a user handler - this must be handled by the caller of this macro. + + Level triggered and software interrupts are automatically deasserted by + this code. + + ASSUMPTIONS: + -- PS.INTLEVEL is set to "level" at entry + -- PS.EXCM = 0, C calling enabled + + NOTE: For CALL0 ABI, a12-a15 have not yet been saved. + + NOTE: This macro will use registers a0 and a2-a7. The arguments are: + level -- interrupt level + mask -- interrupt bitmask for this level +-------------------------------------------------------------------------------- +*/ + + .macro dispatch_c_isr level mask + + #ifdef CONFIG_PM_TRACE + movi a6, 0 /* = ESP_PM_TRACE_IDLE */ + getcoreid a7 + call4 esp_pm_trace_exit + #endif // CONFIG_PM_TRACE + + /* Get mask of pending, enabled interrupts at this level into a2. */ + +.L_xt_user_int_&level&: + rsr a2, INTENABLE + rsr a3, INTERRUPT + movi a4, \mask + and a2, a2, a3 + and a2, a2, a4 + beqz a2, 9f /* nothing to do */ + + /* This bit of code provides a nice debug backtrace in the debugger. + It does take a few more instructions, so undef XT_DEBUG_BACKTRACE + if you want to save the cycles. + */ + #ifdef XT_DEBUG_BACKTRACE + #ifndef __XTENSA_CALL0_ABI__ + rsr a0, EPC_1 + \level - 1 /* return address */ + movi a4, 0xC0000000 /* constant with top 2 bits set (call size) */ + or a0, a0, a4 /* set top 2 bits */ + addx2 a0, a4, a0 /* clear top bit -- simulating call4 size */ + #endif + #endif + + #ifdef CONFIG_PM_ENABLE + call4 esp_pm_impl_isr_hook + #endif + + #ifdef XT_INTEXC_HOOKS + /* Call interrupt hook if present to (pre)handle interrupts. */ + movi a4, _xt_intexc_hooks + l32i a4, a4, \level << 2 + beqz a4, 2f + #ifdef __XTENSA_CALL0_ABI__ + callx0 a4 + beqz a2, 9f + #else + mov a6, a2 + callx4 a4 + beqz a6, 9f + mov a2, a6 + #endif +2: + #endif + + /* Now look up in the dispatch table and call user ISR if any. */ + /* If multiple bits are set then MSB has highest priority. */ + + extract_msb a4, a2 /* a4 = MSB of a2, a2 trashed */ + + #ifdef XT_USE_SWPRI + /* Enable all interrupts at this level that are numerically higher + than the one we just selected, since they are treated as higher + priority. + */ + movi a3, \mask /* a3 = all interrupts at this level */ + add a2, a4, a4 /* a2 = a4 << 1 */ + addi a2, a2, -1 /* a2 = mask of 1's <= a4 bit */ + and a2, a2, a3 /* a2 = mask of all bits <= a4 at this level */ + movi a3, _xt_intdata + l32i a6, a3, 4 /* a6 = _xt_vpri_mask */ + neg a2, a2 + addi a2, a2, -1 /* a2 = mask to apply */ + and a5, a6, a2 /* mask off all bits <= a4 bit */ + s32i a5, a3, 4 /* update _xt_vpri_mask */ + rsr a3, INTENABLE + and a3, a3, a2 /* mask off all bits <= a4 bit */ + wsr a3, INTENABLE + rsil a3, \level - 1 /* lower interrupt level by 1 */ + #endif + + movi a3, XT_TIMER_INTEN /* a3 = timer interrupt bit */ + wsr a4, INTCLEAR /* clear sw or edge-triggered interrupt */ + beq a3, a4, 7f /* if timer interrupt then skip table */ + + find_ms_setbit a3, a4, a3, 0 /* a3 = interrupt number */ + + get_percpu_entry_for a3, a12 + movi a4, _xt_interrupt_table + addx8 a3, a3, a4 /* a3 = address of interrupt table entry */ + l32i a4, a3, XIE_HANDLER /* a4 = handler address */ + #ifdef __XTENSA_CALL0_ABI__ + mov a12, a6 /* save in callee-saved reg */ + l32i a2, a3, XIE_ARG /* a2 = handler arg */ + callx0 a4 /* call handler */ + mov a2, a12 + #else + mov a2, a6 /* save in windowed reg */ + l32i a6, a3, XIE_ARG /* a6 = handler arg */ + callx4 a4 /* call handler */ + #endif + + #ifdef XT_USE_SWPRI + j 8f + #else + j .L_xt_user_int_&level& /* check for more interrupts */ + #endif + +7: + + .ifeq XT_TIMER_INTPRI - \level +.L_xt_user_int_timer_&level&: + /* + Interrupt handler for the RTOS tick timer if at this level. + We'll be reading the interrupt state again after this call + so no need to preserve any registers except a6 (vpri_mask). + */ + + #ifdef __XTENSA_CALL0_ABI__ + mov a12, a6 + call0 XT_RTOS_TIMER_INT + mov a2, a12 + #else + mov a2, a6 + call4 XT_RTOS_TIMER_INT + #endif + .endif + + #ifdef XT_USE_SWPRI + j 8f + #else + j .L_xt_user_int_&level& /* check for more interrupts */ + #endif + + #ifdef XT_USE_SWPRI +8: + /* Restore old value of _xt_vpri_mask from a2. Also update INTENABLE from + virtual _xt_intenable which _could_ have changed during interrupt + processing. */ + + movi a3, _xt_intdata + l32i a4, a3, 0 /* a4 = _xt_intenable */ + s32i a2, a3, 4 /* update _xt_vpri_mask */ + and a4, a4, a2 /* a4 = masked intenable */ + wsr a4, INTENABLE /* update INTENABLE */ + #endif + +9: + /* done */ + + .endm + + +/* +-------------------------------------------------------------------------------- + Panic handler. + Should be reached by call0 (preferable) or jump only. If call0, a0 says where + from. If on simulator, display panic message and abort, else loop indefinitely. +-------------------------------------------------------------------------------- +*/ + + .section .iram1,"ax" + .global panicHandler + + .global _xt_panic + .type _xt_panic,@function + .align 4 + .literal_position + .align 4 + +_xt_panic: + /* Allocate exception frame and save minimal context. */ + mov a0, sp + addi sp, sp, -XT_STK_FRMSZ + s32i a0, sp, XT_STK_A1 + #if XCHAL_HAVE_WINDOWED + s32e a0, sp, -12 /* for debug backtrace */ + #endif + rsr a0, PS /* save interruptee's PS */ + s32i a0, sp, XT_STK_PS + rsr a0, EPC_1 /* save interruptee's PC */ + s32i a0, sp, XT_STK_PC + #if XCHAL_HAVE_WINDOWED + s32e a0, sp, -16 /* for debug backtrace */ + #endif + s32i a12, sp, XT_STK_A12 /* _xt_context_save requires A12- */ + s32i a13, sp, XT_STK_A13 /* A13 to have already been saved */ + call0 _xt_context_save + + /* Save exc cause and vaddr into exception frame */ + rsr a0, EXCCAUSE + s32i a0, sp, XT_STK_EXCCAUSE + rsr a0, EXCVADDR + s32i a0, sp, XT_STK_EXCVADDR + + /* _xt_context_save seems to save the current a0, but we need the interuptees a0. Fix this. */ + rsr a0, EXCSAVE_1 /* save interruptee's a0 */ + + s32i a0, sp, XT_STK_A0 + + /* Set up PS for C, disable all interrupts except NMI and debug, and clear EXCM. */ + movi a0, PS_INTLEVEL(5) | PS_UM | PS_WOE + wsr a0, PS + + //Call panic handler + mov a6,sp + call4 panicHandler + + + .align 4 +//Call using call0. Prints the hex char in a2. Kills a3, a4, a5 +panic_print_hex: + movi a3,0x60000000 + movi a4,8 +panic_print_hex_loop: + l32i a5, a3, 0x1c + extui a5, a5, 16, 8 + bgei a5,64,panic_print_hex_loop + + srli a5,a2,28 + bgei a5,10,panic_print_hex_a + addi a5,a5,'0' + j panic_print_hex_ok +panic_print_hex_a: + addi a5,a5,'A'-10 +panic_print_hex_ok: + s32i a5,a3,0 + slli a2,a2,4 + + addi a4,a4,-1 + bnei a4,0,panic_print_hex_loop + movi a5,' ' + s32i a5,a3,0 + + ret + + + + .section .rodata, "a" + .align 4 + + + +/* +-------------------------------------------------------------------------------- + Hooks to dynamically install handlers for exceptions and interrupts. + Allows automated regression frameworks to install handlers per test. + Consists of an array of function pointers indexed by interrupt level, + with index 0 containing the entry for user exceptions. + Initialized with all 0s, meaning no handler is installed at each level. + See comment in xtensa_rtos.h for more details. + + *WARNING* This array is for all CPUs, that is, installing a hook for + one CPU will install it for all others as well! +-------------------------------------------------------------------------------- +*/ + + #ifdef XT_INTEXC_HOOKS + .data + .global _xt_intexc_hooks + .type _xt_intexc_hooks,@object + .align 4 + +_xt_intexc_hooks: + .fill XT_INTEXC_HOOK_NUM, 4, 0 + #endif + + +/* +-------------------------------------------------------------------------------- + EXCEPTION AND LEVEL 1 INTERRUPT VECTORS AND LOW LEVEL HANDLERS + (except window exception vectors). + + Each vector goes at a predetermined location according to the Xtensa + hardware configuration, which is ensured by its placement in a special + section known to the Xtensa linker support package (LSP). It performs + the minimum necessary before jumping to the handler in the .text section. + + The corresponding handler goes in the normal .text section. It sets up + the appropriate stack frame, saves a few vector-specific registers and + calls XT_RTOS_INT_ENTER to save the rest of the interrupted context + and enter the RTOS, then sets up a C environment. It then calls the + user's interrupt handler code (which may be coded in C) and finally + calls XT_RTOS_INT_EXIT to transfer control to the RTOS for scheduling. + + While XT_RTOS_INT_EXIT does not return directly to the interruptee, + eventually the RTOS scheduler will want to dispatch the interrupted + task or handler. The scheduler will return to the exit point that was + saved in the interrupt stack frame at XT_STK_EXIT. +-------------------------------------------------------------------------------- +*/ + + +/* +-------------------------------------------------------------------------------- +Debug Exception. +-------------------------------------------------------------------------------- +*/ + +#if XCHAL_HAVE_DEBUG + + .begin literal_prefix .DebugExceptionVector + .section .DebugExceptionVector.text, "ax" + .global _DebugExceptionVector + .align 4 + .global xt_debugexception +_DebugExceptionVector: + wsr a0, EXCSAVE+XCHAL_DEBUGLEVEL /* preserve a0 */ + call0 xt_debugexception /* load exception handler */ + + .end literal_prefix + +#endif + +/* +-------------------------------------------------------------------------------- +Double Exception. +Double exceptions are not a normal occurrence. They indicate a bug of some kind. +-------------------------------------------------------------------------------- +*/ + +#ifdef XCHAL_DOUBLEEXC_VECTOR_VADDR + + .begin literal_prefix .DoubleExceptionVector + .section .DoubleExceptionVector.text, "ax" + .global _DoubleExceptionVector + .align 4 + +_DoubleExceptionVector: + + #if XCHAL_HAVE_DEBUG + break 1, 4 /* unhandled double exception */ + #endif + movi a0,PANIC_RSN_DOUBLEEXCEPTION + wsr a0,EXCCAUSE + call0 _xt_panic /* does not return */ + rfde /* make a0 point here not later */ + + .end literal_prefix + +#endif /* XCHAL_DOUBLEEXC_VECTOR_VADDR */ + +/* +-------------------------------------------------------------------------------- +Kernel Exception (including Level 1 Interrupt from kernel mode). +-------------------------------------------------------------------------------- +*/ + + .begin literal_prefix .KernelExceptionVector + .section .KernelExceptionVector.text, "ax" + .global _KernelExceptionVector + .align 4 + +_KernelExceptionVector: + + wsr a0, EXCSAVE_1 /* preserve a0 */ + call0 _xt_kernel_exc /* kernel exception handler */ + /* never returns here - call0 is used as a jump (see note at top) */ + + .end literal_prefix + + .section .iram1,"ax" + .align 4 + +_xt_kernel_exc: + #if XCHAL_HAVE_DEBUG + break 1, 0 /* unhandled kernel exception */ + #endif + movi a0,PANIC_RSN_KERNELEXCEPTION + wsr a0,EXCCAUSE + call0 _xt_panic /* does not return */ + rfe /* make a0 point here not there */ + + +/* +-------------------------------------------------------------------------------- +User Exception (including Level 1 Interrupt from user mode). +-------------------------------------------------------------------------------- +*/ + + .begin literal_prefix .UserExceptionVector + .section .UserExceptionVector.text, "ax" + .global _UserExceptionVector + .type _UserExceptionVector,@function + .align 4 + +_UserExceptionVector: + + wsr a0, EXCSAVE_1 /* preserve a0 */ + call0 _xt_user_exc /* user exception handler */ + /* never returns here - call0 is used as a jump (see note at top) */ + + .end literal_prefix + +/* +-------------------------------------------------------------------------------- + Insert some waypoints for jumping beyond the signed 8-bit range of + conditional branch instructions, so the conditional branchces to specific + exception handlers are not taken in the mainline. Saves some cycles in the + mainline. +-------------------------------------------------------------------------------- +*/ + + .section .iram1,"ax" + + #if XCHAL_HAVE_WINDOWED + .align 4 +_xt_to_alloca_exc: + call0 _xt_alloca_exc /* in window vectors section */ + /* never returns here - call0 is used as a jump (see note at top) */ + #endif + + .align 4 +_xt_to_syscall_exc: + call0 _xt_syscall_exc + /* never returns here - call0 is used as a jump (see note at top) */ + + #if XCHAL_CP_NUM > 0 + .align 4 +_xt_to_coproc_exc: + call0 _xt_coproc_exc + /* never returns here - call0 is used as a jump (see note at top) */ + #endif + + +/* +-------------------------------------------------------------------------------- + User exception handler. +-------------------------------------------------------------------------------- +*/ + + .type _xt_user_exc,@function + .align 4 + +_xt_user_exc: + + /* If level 1 interrupt then jump to the dispatcher */ + rsr a0, EXCCAUSE + beqi a0, EXCCAUSE_LEVEL1INTERRUPT, _xt_lowint1 + + /* Handle any coprocessor exceptions. Rely on the fact that exception + numbers above EXCCAUSE_CP0_DISABLED all relate to the coprocessors. + */ + #if XCHAL_CP_NUM > 0 + bgeui a0, EXCCAUSE_CP0_DISABLED, _xt_to_coproc_exc + #endif + + /* Handle alloca and syscall exceptions */ + #if XCHAL_HAVE_WINDOWED + beqi a0, EXCCAUSE_ALLOCA, _xt_to_alloca_exc + #endif + beqi a0, EXCCAUSE_SYSCALL, _xt_to_syscall_exc + + /* Handle all other exceptions. All can have user-defined handlers. */ + /* NOTE: we'll stay on the user stack for exception handling. */ + + /* Allocate exception frame and save minimal context. */ + mov a0, sp + addi sp, sp, -XT_STK_FRMSZ + s32i a0, sp, XT_STK_A1 + #if XCHAL_HAVE_WINDOWED + s32e a0, sp, -12 /* for debug backtrace */ + #endif + rsr a0, PS /* save interruptee's PS */ + s32i a0, sp, XT_STK_PS + rsr a0, EPC_1 /* save interruptee's PC */ + s32i a0, sp, XT_STK_PC + #if XCHAL_HAVE_WINDOWED + s32e a0, sp, -16 /* for debug backtrace */ + #endif + s32i a12, sp, XT_STK_A12 /* _xt_context_save requires A12- */ + s32i a13, sp, XT_STK_A13 /* A13 to have already been saved */ + call0 _xt_context_save + + /* Save exc cause and vaddr into exception frame */ + rsr a0, EXCCAUSE + s32i a0, sp, XT_STK_EXCCAUSE + rsr a0, EXCVADDR + s32i a0, sp, XT_STK_EXCVADDR + + /* _xt_context_save seems to save the current a0, but we need the interuptees a0. Fix this. */ + rsr a0, EXCSAVE_1 /* save interruptee's a0 */ + s32i a0, sp, XT_STK_A0 + + /* Set up PS for C, reenable hi-pri interrupts, and clear EXCM. */ + #ifdef __XTENSA_CALL0_ABI__ + movi a0, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM + #else + movi a0, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE + #endif + wsr a0, PS + + #ifdef XT_DEBUG_BACKTRACE + #ifndef __XTENSA_CALL0_ABI__ + rsr a0, EPC_1 /* return address for debug backtrace */ + movi a5, 0xC0000000 /* constant with top 2 bits set (call size) */ + rsync /* wait for WSR.PS to complete */ + or a0, a0, a5 /* set top 2 bits */ + addx2 a0, a5, a0 /* clear top bit -- thus simulating call4 size */ + #else + rsync /* wait for WSR.PS to complete */ + #endif + #endif + + rsr a2, EXCCAUSE /* recover exc cause */ + + #ifdef XT_INTEXC_HOOKS + /* + Call exception hook to pre-handle exceptions (if installed). + Pass EXCCAUSE in a2, and check result in a2 (if -1, skip default handling). + */ + movi a4, _xt_intexc_hooks + l32i a4, a4, 0 /* user exception hook index 0 */ + beqz a4, 1f +.Ln_xt_user_exc_call_hook: + #ifdef __XTENSA_CALL0_ABI__ + callx0 a4 + beqi a2, -1, .L_xt_user_done + #else + mov a6, a2 + callx4 a4 + beqi a6, -1, .L_xt_user_done + mov a2, a6 + #endif +1: + #endif + + rsr a2, EXCCAUSE /* recover exc cause */ + movi a3, _xt_exception_table + get_percpu_entry_for a2, a4 + addx4 a4, a2, a3 /* a4 = address of exception table entry */ + l32i a4, a4, 0 /* a4 = handler address */ + #ifdef __XTENSA_CALL0_ABI__ + mov a2, sp /* a2 = pointer to exc frame */ + callx0 a4 /* call handler */ + #else + mov a6, sp /* a6 = pointer to exc frame */ + callx4 a4 /* call handler */ + #endif + +.L_xt_user_done: + + /* Restore context and return */ + call0 _xt_context_restore + l32i a0, sp, XT_STK_PS /* retrieve interruptee's PS */ + wsr a0, PS + l32i a0, sp, XT_STK_PC /* retrieve interruptee's PC */ + wsr a0, EPC_1 + l32i a0, sp, XT_STK_A0 /* retrieve interruptee's A0 */ + l32i sp, sp, XT_STK_A1 /* remove exception frame */ + rsync /* ensure PS and EPC written */ + rfe /* PS.EXCM is cleared */ + + +/* +-------------------------------------------------------------------------------- + Exit point for dispatch. Saved in interrupt stack frame at XT_STK_EXIT + on entry and used to return to a thread or interrupted interrupt handler. +-------------------------------------------------------------------------------- +*/ + + .global _xt_user_exit + .type _xt_user_exit,@function + .align 4 +_xt_user_exit: + l32i a0, sp, XT_STK_PS /* retrieve interruptee's PS */ + wsr a0, PS + l32i a0, sp, XT_STK_PC /* retrieve interruptee's PC */ + wsr a0, EPC_1 + l32i a0, sp, XT_STK_A0 /* retrieve interruptee's A0 */ + l32i sp, sp, XT_STK_A1 /* remove interrupt stack frame */ + rsync /* ensure PS and EPC written */ + rfe /* PS.EXCM is cleared */ + + +/* + +-------------------------------------------------------------------------------- +Syscall Exception Handler (jumped to from User Exception Handler). +Syscall 0 is required to spill the register windows (no-op in Call 0 ABI). +Only syscall 0 is handled here. Other syscalls return -1 to caller in a2. +-------------------------------------------------------------------------------- +*/ + + .section .iram1,"ax" + .type _xt_syscall_exc,@function + .align 4 +_xt_syscall_exc: + + #ifdef __XTENSA_CALL0_ABI__ + /* + Save minimal regs for scratch. Syscall 0 does nothing in Call0 ABI. + Use a minimal stack frame (16B) to save A2 & A3 for scratch. + PS.EXCM could be cleared here, but unlikely to improve worst-case latency. + rsr a0, PS + addi a0, a0, -PS_EXCM_MASK + wsr a0, PS + */ + addi sp, sp, -16 + s32i a2, sp, 8 + s32i a3, sp, 12 + #else /* Windowed ABI */ + /* + Save necessary context and spill the register windows. + PS.EXCM is still set and must remain set until after the spill. + Reuse context save function though it saves more than necessary. + For this reason, a full interrupt stack frame is allocated. + */ + addi sp, sp, -XT_STK_FRMSZ /* allocate interrupt stack frame */ + s32i a12, sp, XT_STK_A12 /* _xt_context_save requires A12- */ + s32i a13, sp, XT_STK_A13 /* A13 to have already been saved */ + call0 _xt_context_save + #endif + + /* + Grab the interruptee's PC and skip over the 'syscall' instruction. + If it's at the end of a zero-overhead loop and it's not on the last + iteration, decrement loop counter and skip to beginning of loop. + */ + rsr a2, EPC_1 /* a2 = PC of 'syscall' */ + addi a3, a2, 3 /* ++PC */ + #if XCHAL_HAVE_LOOPS + rsr a0, LEND /* if (PC == LEND */ + bne a3, a0, 1f + rsr a0, LCOUNT /* && LCOUNT != 0) */ + beqz a0, 1f /* { */ + addi a0, a0, -1 /* --LCOUNT */ + rsr a3, LBEG /* PC = LBEG */ + wsr a0, LCOUNT /* } */ + #endif +1: wsr a3, EPC_1 /* update PC */ + + /* Restore interruptee's context and return from exception. */ + #ifdef __XTENSA_CALL0_ABI__ + l32i a2, sp, 8 + l32i a3, sp, 12 + addi sp, sp, 16 + #else + call0 _xt_context_restore + addi sp, sp, XT_STK_FRMSZ + #endif + movi a0, -1 + movnez a2, a0, a2 /* return -1 if not syscall 0 */ + rsr a0, EXCSAVE_1 + rfe + +/* +-------------------------------------------------------------------------------- +Co-Processor Exception Handler (jumped to from User Exception Handler). +These exceptions are generated by co-processor instructions, which are only +allowed in thread code (not in interrupts or kernel code). This restriction is +deliberately imposed to reduce the burden of state-save/restore in interrupts. +-------------------------------------------------------------------------------- +*/ +#if XCHAL_CP_NUM > 0 + + .section .rodata, "a" + +/* Offset to CP n save area in thread's CP save area. */ + .global _xt_coproc_sa_offset + .type _xt_coproc_sa_offset,@object + .align 16 /* minimize crossing cache boundaries */ +_xt_coproc_sa_offset: + .word XT_CP0_SA, XT_CP1_SA, XT_CP2_SA, XT_CP3_SA + .word XT_CP4_SA, XT_CP5_SA, XT_CP6_SA, XT_CP7_SA + +/* Bitmask for CP n's CPENABLE bit. */ + .type _xt_coproc_mask,@object + .align 16,,8 /* try to keep it all in one cache line */ + .set i, 0 +_xt_coproc_mask: + .rept XCHAL_CP_MAX + .long (i<<16) | (1<= 2 + + .begin literal_prefix .Level2InterruptVector + .section .Level2InterruptVector.text, "ax" + .global _Level2Vector + .type _Level2Vector,@function + .align 4 +_Level2Vector: + wsr a0, EXCSAVE_2 /* preserve a0 */ + call0 _xt_medint2 /* load interrupt handler */ + /* never returns here - call0 is used as a jump (see note at top) */ + + .end literal_prefix + + .section .iram1,"ax" + .type _xt_medint2,@function + .align 4 +_xt_medint2: + mov a0, sp /* sp == a1 */ + addi sp, sp, -XT_STK_FRMSZ /* allocate interrupt stack frame */ + s32i a0, sp, XT_STK_A1 /* save pre-interrupt SP */ + rsr a0, EPS_2 /* save interruptee's PS */ + s32i a0, sp, XT_STK_PS + rsr a0, EPC_2 /* save interruptee's PC */ + s32i a0, sp, XT_STK_PC + rsr a0, EXCSAVE_2 /* save interruptee's a0 */ + s32i a0, sp, XT_STK_A0 + movi a0, _xt_medint2_exit /* save exit point for dispatch */ + s32i a0, sp, XT_STK_EXIT + + /* Save rest of interrupt context and enter RTOS. */ + call0 XT_RTOS_INT_ENTER /* common RTOS interrupt entry */ + + /* !! We are now on the RTOS system stack !! */ + + /* Set up PS for C, enable interrupts above this level and clear EXCM. */ + #ifdef __XTENSA_CALL0_ABI__ + movi a0, PS_INTLEVEL(2) | PS_UM + #else + movi a0, PS_INTLEVEL(2) | PS_UM | PS_WOE + #endif + wsr a0, PS + rsync + + /* OK to call C code at this point, dispatch user ISRs */ + + dispatch_c_isr 2 XCHAL_INTLEVEL2_MASK + + /* Done handling interrupts, transfer control to OS */ + call0 XT_RTOS_INT_EXIT /* does not return directly here */ + + /* + Exit point for dispatch. Saved in interrupt stack frame at XT_STK_EXIT + on entry and used to return to a thread or interrupted interrupt handler. + */ + .global _xt_medint2_exit + .type _xt_medint2_exit,@function + .align 4 +_xt_medint2_exit: + /* Restore only level-specific regs (the rest were already restored) */ + l32i a0, sp, XT_STK_PS /* retrieve interruptee's PS */ + wsr a0, EPS_2 + l32i a0, sp, XT_STK_PC /* retrieve interruptee's PC */ + wsr a0, EPC_2 + l32i a0, sp, XT_STK_A0 /* retrieve interruptee's A0 */ + l32i sp, sp, XT_STK_A1 /* remove interrupt stack frame */ + rsync /* ensure EPS and EPC written */ + rfi 2 + +#endif /* Level 2 */ + +#if XCHAL_EXCM_LEVEL >= 3 + + .begin literal_prefix .Level3InterruptVector + .section .Level3InterruptVector.text, "ax" + .global _Level3Vector + .type _Level3Vector,@function + .align 4 +_Level3Vector: + wsr a0, EXCSAVE_3 /* preserve a0 */ + call0 _xt_medint3 /* load interrupt handler */ + /* never returns here - call0 is used as a jump (see note at top) */ + + .end literal_prefix + + .section .iram1,"ax" + .type _xt_medint3,@function + .align 4 +_xt_medint3: + mov a0, sp /* sp == a1 */ + addi sp, sp, -XT_STK_FRMSZ /* allocate interrupt stack frame */ + s32i a0, sp, XT_STK_A1 /* save pre-interrupt SP */ + rsr a0, EPS_3 /* save interruptee's PS */ + s32i a0, sp, XT_STK_PS + rsr a0, EPC_3 /* save interruptee's PC */ + s32i a0, sp, XT_STK_PC + rsr a0, EXCSAVE_3 /* save interruptee's a0 */ + s32i a0, sp, XT_STK_A0 + movi a0, _xt_medint3_exit /* save exit point for dispatch */ + s32i a0, sp, XT_STK_EXIT + + /* Save rest of interrupt context and enter RTOS. */ + call0 XT_RTOS_INT_ENTER /* common RTOS interrupt entry */ + + /* !! We are now on the RTOS system stack !! */ + + /* Set up PS for C, enable interrupts above this level and clear EXCM. */ + #ifdef __XTENSA_CALL0_ABI__ + movi a0, PS_INTLEVEL(3) | PS_UM + #else + movi a0, PS_INTLEVEL(3) | PS_UM | PS_WOE + #endif + wsr a0, PS + rsync + + /* OK to call C code at this point, dispatch user ISRs */ + + dispatch_c_isr 3 XCHAL_INTLEVEL3_MASK + + /* Done handling interrupts, transfer control to OS */ + call0 XT_RTOS_INT_EXIT /* does not return directly here */ + + /* + Exit point for dispatch. Saved in interrupt stack frame at XT_STK_EXIT + on entry and used to return to a thread or interrupted interrupt handler. + */ + .global _xt_medint3_exit + .type _xt_medint3_exit,@function + .align 4 +_xt_medint3_exit: + /* Restore only level-specific regs (the rest were already restored) */ + l32i a0, sp, XT_STK_PS /* retrieve interruptee's PS */ + wsr a0, EPS_3 + l32i a0, sp, XT_STK_PC /* retrieve interruptee's PC */ + wsr a0, EPC_3 + l32i a0, sp, XT_STK_A0 /* retrieve interruptee's A0 */ + l32i sp, sp, XT_STK_A1 /* remove interrupt stack frame */ + rsync /* ensure EPS and EPC written */ + rfi 3 + +#endif /* Level 3 */ + +#if XCHAL_EXCM_LEVEL >= 4 + + .begin literal_prefix .Level4InterruptVector + .section .Level4InterruptVector.text, "ax" + .global _Level4Vector + .type _Level4Vector,@function + .align 4 +_Level4Vector: + wsr a0, EXCSAVE_4 /* preserve a0 */ + call0 _xt_medint4 /* load interrupt handler */ + + .end literal_prefix + + .section .iram1,"ax" + .type _xt_medint4,@function + .align 4 +_xt_medint4: + mov a0, sp /* sp == a1 */ + addi sp, sp, -XT_STK_FRMSZ /* allocate interrupt stack frame */ + s32i a0, sp, XT_STK_A1 /* save pre-interrupt SP */ + rsr a0, EPS_4 /* save interruptee's PS */ + s32i a0, sp, XT_STK_PS + rsr a0, EPC_4 /* save interruptee's PC */ + s32i a0, sp, XT_STK_PC + rsr a0, EXCSAVE_4 /* save interruptee's a0 */ + s32i a0, sp, XT_STK_A0 + movi a0, _xt_medint4_exit /* save exit point for dispatch */ + s32i a0, sp, XT_STK_EXIT + + /* Save rest of interrupt context and enter RTOS. */ + call0 XT_RTOS_INT_ENTER /* common RTOS interrupt entry */ + + /* !! We are now on the RTOS system stack !! */ + + /* Set up PS for C, enable interrupts above this level and clear EXCM. */ + #ifdef __XTENSA_CALL0_ABI__ + movi a0, PS_INTLEVEL(4) | PS_UM + #else + movi a0, PS_INTLEVEL(4) | PS_UM | PS_WOE + #endif + wsr a0, PS + rsync + + /* OK to call C code at this point, dispatch user ISRs */ + + dispatch_c_isr 4 XCHAL_INTLEVEL4_MASK + + /* Done handling interrupts, transfer control to OS */ + call0 XT_RTOS_INT_EXIT /* does not return directly here */ + + /* + Exit point for dispatch. Saved in interrupt stack frame at XT_STK_EXIT + on entry and used to return to a thread or interrupted interrupt handler. + */ + .global _xt_medint4_exit + .type _xt_medint4_exit,@function + .align 4 +_xt_medint4_exit: + /* Restore only level-specific regs (the rest were already restored) */ + l32i a0, sp, XT_STK_PS /* retrieve interruptee's PS */ + wsr a0, EPS_4 + l32i a0, sp, XT_STK_PC /* retrieve interruptee's PC */ + wsr a0, EPC_4 + l32i a0, sp, XT_STK_A0 /* retrieve interruptee's A0 */ + l32i sp, sp, XT_STK_A1 /* remove interrupt stack frame */ + rsync /* ensure EPS and EPC written */ + rfi 4 + +#endif /* Level 4 */ + +#if XCHAL_EXCM_LEVEL >= 5 + + .begin literal_prefix .Level5InterruptVector + .section .Level5InterruptVector.text, "ax" + .global _Level5Vector + .type _Level5Vector,@function + .align 4 +_Level5Vector: + wsr a0, EXCSAVE_5 /* preserve a0 */ + call0 _xt_medint5 /* load interrupt handler */ + + .end literal_prefix + + .section .iram1,"ax" + .type _xt_medint5,@function + .align 4 +_xt_medint5: + mov a0, sp /* sp == a1 */ + addi sp, sp, -XT_STK_FRMSZ /* allocate interrupt stack frame */ + s32i a0, sp, XT_STK_A1 /* save pre-interrupt SP */ + rsr a0, EPS_5 /* save interruptee's PS */ + s32i a0, sp, XT_STK_PS + rsr a0, EPC_5 /* save interruptee's PC */ + s32i a0, sp, XT_STK_PC + rsr a0, EXCSAVE_5 /* save interruptee's a0 */ + s32i a0, sp, XT_STK_A0 + movi a0, _xt_medint5_exit /* save exit point for dispatch */ + s32i a0, sp, XT_STK_EXIT + + /* Save rest of interrupt context and enter RTOS. */ + call0 XT_RTOS_INT_ENTER /* common RTOS interrupt entry */ + + /* !! We are now on the RTOS system stack !! */ + + /* Set up PS for C, enable interrupts above this level and clear EXCM. */ + #ifdef __XTENSA_CALL0_ABI__ + movi a0, PS_INTLEVEL(5) | PS_UM + #else + movi a0, PS_INTLEVEL(5) | PS_UM | PS_WOE + #endif + wsr a0, PS + rsync + + /* OK to call C code at this point, dispatch user ISRs */ + + dispatch_c_isr 5 XCHAL_INTLEVEL5_MASK + + /* Done handling interrupts, transfer control to OS */ + call0 XT_RTOS_INT_EXIT /* does not return directly here */ + + /* + Exit point for dispatch. Saved in interrupt stack frame at XT_STK_EXIT + on entry and used to return to a thread or interrupted interrupt handler. + */ + .global _xt_medint5_exit + .type _xt_medint5_exit,@function + .align 4 +_xt_medint5_exit: + /* Restore only level-specific regs (the rest were already restored) */ + l32i a0, sp, XT_STK_PS /* retrieve interruptee's PS */ + wsr a0, EPS_5 + l32i a0, sp, XT_STK_PC /* retrieve interruptee's PC */ + wsr a0, EPC_5 + l32i a0, sp, XT_STK_A0 /* retrieve interruptee's A0 */ + l32i sp, sp, XT_STK_A1 /* remove interrupt stack frame */ + rsync /* ensure EPS and EPC written */ + rfi 5 + +#endif /* Level 5 */ + +#if XCHAL_EXCM_LEVEL >= 6 + + .begin literal_prefix .Level6InterruptVector + .section .Level6InterruptVector.text, "ax" + .global _Level6Vector + .type _Level6Vector,@function + .align 4 +_Level6Vector: + wsr a0, EXCSAVE_6 /* preserve a0 */ + call0 _xt_medint6 /* load interrupt handler */ + + .end literal_prefix + + .section .iram1,"ax" + .type _xt_medint6,@function + .align 4 +_xt_medint6: + mov a0, sp /* sp == a1 */ + addi sp, sp, -XT_STK_FRMSZ /* allocate interrupt stack frame */ + s32i a0, sp, XT_STK_A1 /* save pre-interrupt SP */ + rsr a0, EPS_6 /* save interruptee's PS */ + s32i a0, sp, XT_STK_PS + rsr a0, EPC_6 /* save interruptee's PC */ + s32i a0, sp, XT_STK_PC + rsr a0, EXCSAVE_6 /* save interruptee's a0 */ + s32i a0, sp, XT_STK_A0 + movi a0, _xt_medint6_exit /* save exit point for dispatch */ + s32i a0, sp, XT_STK_EXIT + + /* Save rest of interrupt context and enter RTOS. */ + call0 XT_RTOS_INT_ENTER /* common RTOS interrupt entry */ + + /* !! We are now on the RTOS system stack !! */ + + /* Set up PS for C, enable interrupts above this level and clear EXCM. */ + #ifdef __XTENSA_CALL0_ABI__ + movi a0, PS_INTLEVEL(6) | PS_UM + #else + movi a0, PS_INTLEVEL(6) | PS_UM | PS_WOE + #endif + wsr a0, PS + rsync + + /* OK to call C code at this point, dispatch user ISRs */ + + dispatch_c_isr 6 XCHAL_INTLEVEL6_MASK + + /* Done handling interrupts, transfer control to OS */ + call0 XT_RTOS_INT_EXIT /* does not return directly here */ + + /* + Exit point for dispatch. Saved in interrupt stack frame at XT_STK_EXIT + on entry and used to return to a thread or interrupted interrupt handler. + */ + .global _xt_medint6_exit + .type _xt_medint6_exit,@function + .align 4 +_xt_medint6_exit: + /* Restore only level-specific regs (the rest were already restored) */ + l32i a0, sp, XT_STK_PS /* retrieve interruptee's PS */ + wsr a0, EPS_6 + l32i a0, sp, XT_STK_PC /* retrieve interruptee's PC */ + wsr a0, EPC_6 + l32i a0, sp, XT_STK_A0 /* retrieve interruptee's A0 */ + l32i sp, sp, XT_STK_A1 /* remove interrupt stack frame */ + rsync /* ensure EPS and EPC written */ + rfi 6 + +#endif /* Level 6 */ + + +/******************************************************************************* + +HIGH PRIORITY (LEVEL > XCHAL_EXCM_LEVEL) INTERRUPT VECTORS AND HANDLERS + +High priority interrupts are by definition those with priorities greater +than XCHAL_EXCM_LEVEL. This includes non-maskable (NMI). High priority +interrupts cannot interact with the RTOS, that is they must save all regs +they use and not call any RTOS function. + +A further restriction imposed by the Xtensa windowed architecture is that +high priority interrupts must not modify the stack area even logically +"above" the top of the interrupted stack (they need to provide their +own stack or static save area). + +Cadence Design Systems recommends high priority interrupt handlers be coded in assembly +and used for purposes requiring very short service times. + +Here are templates for high priority (level 2+) interrupt vectors. +They assume only one interrupt per level to avoid the burden of identifying +which interrupts at this level are pending and enabled. This allows for +minimum latency and avoids having to save/restore a2 in addition to a0. +If more than one interrupt per high priority level is configured, this burden +is on the handler which in any case must provide a way to save and restore +registers it uses without touching the interrupted stack. + +Each vector goes at a predetermined location according to the Xtensa +hardware configuration, which is ensured by its placement in a special +section known to the Xtensa linker support package (LSP). It performs +the minimum necessary before jumping to the handler in the .text section. + +*******************************************************************************/ + +/* +These stubs just call xt_highintX/xt_nmi to handle the real interrupt. Please define +these in an external assembly source file. If these symbols are not defined anywhere +else, the defaults in xtensa_vector_defaults.S are used. +*/ + +#if XCHAL_NUM_INTLEVELS >=2 && XCHAL_EXCM_LEVEL <2 && XCHAL_DEBUGLEVEL !=2 + + .begin literal_prefix .Level2InterruptVector + .section .Level2InterruptVector.text, "ax" + .global _Level2Vector + .type _Level2Vector,@function + .global xt_highint2 + .align 4 +_Level2Vector: + wsr a0, EXCSAVE_2 /* preserve a0 */ + call0 xt_highint2 /* load interrupt handler */ + + .end literal_prefix + +#endif /* Level 2 */ + +#if XCHAL_NUM_INTLEVELS >=3 && XCHAL_EXCM_LEVEL <3 && XCHAL_DEBUGLEVEL !=3 + + .begin literal_prefix .Level3InterruptVector + .section .Level3InterruptVector.text, "ax" + .global _Level3Vector + .type _Level3Vector,@function + .global xt_highint3 + .align 4 +_Level3Vector: + wsr a0, EXCSAVE_3 /* preserve a0 */ + call0 xt_highint3 /* load interrupt handler */ + /* never returns here - call0 is used as a jump (see note at top) */ + + .end literal_prefix + +#endif /* Level 3 */ + +#if XCHAL_NUM_INTLEVELS >=4 && XCHAL_EXCM_LEVEL <4 && XCHAL_DEBUGLEVEL !=4 + + .begin literal_prefix .Level4InterruptVector + .section .Level4InterruptVector.text, "ax" + .global _Level4Vector + .type _Level4Vector,@function + .global xt_highint4 + .align 4 +_Level4Vector: + wsr a0, EXCSAVE_4 /* preserve a0 */ + call0 xt_highint4 /* load interrupt handler */ + /* never returns here - call0 is used as a jump (see note at top) */ + + .end literal_prefix + +#endif /* Level 4 */ + +#if XCHAL_NUM_INTLEVELS >=5 && XCHAL_EXCM_LEVEL <5 && XCHAL_DEBUGLEVEL !=5 + + .begin literal_prefix .Level5InterruptVector + .section .Level5InterruptVector.text, "ax" + .global _Level5Vector + .type _Level5Vector,@function + .global xt_highint5 + .align 4 +_Level5Vector: + wsr a0, EXCSAVE_5 /* preserve a0 */ + call0 xt_highint5 /* load interrupt handler */ + /* never returns here - call0 is used as a jump (see note at top) */ + + .end literal_prefix + +#endif /* Level 5 */ + +#if XCHAL_NUM_INTLEVELS >=6 && XCHAL_EXCM_LEVEL <6 && XCHAL_DEBUGLEVEL !=6 + + .begin literal_prefix .Level6InterruptVector + .section .Level6InterruptVector.text, "ax" + .global _Level6Vector + .type _Level6Vector,@function + .global xt_highint6 + .align 4 +_Level6Vector: + wsr a0, EXCSAVE_6 /* preserve a0 */ + call0 xt_highint6 /* load interrupt handler */ + /* never returns here - call0 is used as a jump (see note at top) */ + + .end literal_prefix + +#endif /* Level 6 */ + +#if XCHAL_HAVE_NMI + + .begin literal_prefix .NMIExceptionVector + .section .NMIExceptionVector.text, "ax" + .global _NMIExceptionVector + .type _NMIExceptionVector,@function + .global xt_nmi + .align 4 +_NMIExceptionVector: + wsr a0, EXCSAVE + XCHAL_NMILEVEL _ /* preserve a0 */ + call0 xt_nmi /* load interrupt handler */ + /* never returns here - call0 is used as a jump (see note at top) */ + + .end literal_prefix + +#endif /* NMI */ + + +/******************************************************************************* + +WINDOW OVERFLOW AND UNDERFLOW EXCEPTION VECTORS AND ALLOCA EXCEPTION HANDLER + +Here is the code for each window overflow/underflow exception vector and +(interspersed) efficient code for handling the alloca exception cause. +Window exceptions are handled entirely in the vector area and are very +tight for performance. The alloca exception is also handled entirely in +the window vector area so comes at essentially no cost in code size. +Users should never need to modify them and Cadence Design Systems recommends +they do not. + +Window handlers go at predetermined vector locations according to the +Xtensa hardware configuration, which is ensured by their placement in a +special section known to the Xtensa linker support package (LSP). Since +their offsets in that section are always the same, the LSPs do not define +a section per vector. + +These things are coded for XEA2 only (XEA1 is not supported). + +Note on Underflow Handlers: +The underflow handler for returning from call[i+1] to call[i] +must preserve all the registers from call[i+1]'s window. +In particular, a0 and a1 must be preserved because the RETW instruction +will be reexecuted (and may even underflow if an intervening exception +has flushed call[i]'s registers). +Registers a2 and up may contain return values. + +*******************************************************************************/ + +#if XCHAL_HAVE_WINDOWED + + .section .WindowVectors.text, "ax" + +/* +-------------------------------------------------------------------------------- +Window Overflow Exception for Call4. + +Invoked if a call[i] referenced a register (a4-a15) +that contains data from ancestor call[j]; +call[j] had done a call4 to call[j+1]. +On entry here: + window rotated to call[j] start point; + a0-a3 are registers to be saved; + a4-a15 must be preserved; + a5 is call[j+1]'s stack pointer. +-------------------------------------------------------------------------------- +*/ + + .org 0x0 + .global _WindowOverflow4 +_WindowOverflow4: + + s32e a0, a5, -16 /* save a0 to call[j+1]'s stack frame */ + s32e a1, a5, -12 /* save a1 to call[j+1]'s stack frame */ + s32e a2, a5, -8 /* save a2 to call[j+1]'s stack frame */ + s32e a3, a5, -4 /* save a3 to call[j+1]'s stack frame */ + rfwo /* rotates back to call[i] position */ + +/* +-------------------------------------------------------------------------------- +Window Underflow Exception for Call4 + +Invoked by RETW returning from call[i+1] to call[i] +where call[i]'s registers must be reloaded (not live in ARs); +where call[i] had done a call4 to call[i+1]. +On entry here: + window rotated to call[i] start point; + a0-a3 are undefined, must be reloaded with call[i].reg[0..3]; + a4-a15 must be preserved (they are call[i+1].reg[0..11]); + a5 is call[i+1]'s stack pointer. +-------------------------------------------------------------------------------- +*/ + + .org 0x40 + .global _WindowUnderflow4 +_WindowUnderflow4: + + l32e a0, a5, -16 /* restore a0 from call[i+1]'s stack frame */ + l32e a1, a5, -12 /* restore a1 from call[i+1]'s stack frame */ + l32e a2, a5, -8 /* restore a2 from call[i+1]'s stack frame */ + l32e a3, a5, -4 /* restore a3 from call[i+1]'s stack frame */ + rfwu + +/* +-------------------------------------------------------------------------------- +Handle alloca exception generated by interruptee executing 'movsp'. +This uses space between the window vectors, so is essentially "free". +All interruptee's regs are intact except a0 which is saved in EXCSAVE_1, +and PS.EXCM has been set by the exception hardware (can't be interrupted). +The fact the alloca exception was taken means the registers associated with +the base-save area have been spilled and will be restored by the underflow +handler, so those 4 registers are available for scratch. +The code is optimized to avoid unaligned branches and minimize cache misses. +-------------------------------------------------------------------------------- +*/ + + .align 4 + .global _xt_alloca_exc +_xt_alloca_exc: + + rsr a0, WINDOWBASE /* grab WINDOWBASE before rotw changes it */ + rotw -1 /* WINDOWBASE goes to a4, new a0-a3 are scratch */ + rsr a2, PS + extui a3, a2, XCHAL_PS_OWB_SHIFT, XCHAL_PS_OWB_BITS + xor a3, a3, a4 /* bits changed from old to current windowbase */ + rsr a4, EXCSAVE_1 /* restore original a0 (now in a4) */ + slli a3, a3, XCHAL_PS_OWB_SHIFT + xor a2, a2, a3 /* flip changed bits in old window base */ + wsr a2, PS /* update PS.OWB to new window base */ + rsync + + _bbci.l a4, 31, _WindowUnderflow4 + rotw -1 /* original a0 goes to a8 */ + _bbci.l a8, 30, _WindowUnderflow8 + rotw -1 + j _WindowUnderflow12 + +/* +-------------------------------------------------------------------------------- +Window Overflow Exception for Call8 + +Invoked if a call[i] referenced a register (a4-a15) +that contains data from ancestor call[j]; +call[j] had done a call8 to call[j+1]. +On entry here: + window rotated to call[j] start point; + a0-a7 are registers to be saved; + a8-a15 must be preserved; + a9 is call[j+1]'s stack pointer. +-------------------------------------------------------------------------------- +*/ + + .org 0x80 + .global _WindowOverflow8 +_WindowOverflow8: + + s32e a0, a9, -16 /* save a0 to call[j+1]'s stack frame */ + l32e a0, a1, -12 /* a0 <- call[j-1]'s sp + (used to find end of call[j]'s frame) */ + s32e a1, a9, -12 /* save a1 to call[j+1]'s stack frame */ + s32e a2, a9, -8 /* save a2 to call[j+1]'s stack frame */ + s32e a3, a9, -4 /* save a3 to call[j+1]'s stack frame */ + s32e a4, a0, -32 /* save a4 to call[j]'s stack frame */ + s32e a5, a0, -28 /* save a5 to call[j]'s stack frame */ + s32e a6, a0, -24 /* save a6 to call[j]'s stack frame */ + s32e a7, a0, -20 /* save a7 to call[j]'s stack frame */ + rfwo /* rotates back to call[i] position */ + +/* +-------------------------------------------------------------------------------- +Window Underflow Exception for Call8 + +Invoked by RETW returning from call[i+1] to call[i] +where call[i]'s registers must be reloaded (not live in ARs); +where call[i] had done a call8 to call[i+1]. +On entry here: + window rotated to call[i] start point; + a0-a7 are undefined, must be reloaded with call[i].reg[0..7]; + a8-a15 must be preserved (they are call[i+1].reg[0..7]); + a9 is call[i+1]'s stack pointer. +-------------------------------------------------------------------------------- +*/ + + .org 0xC0 + .global _WindowUnderflow8 +_WindowUnderflow8: + + l32e a0, a9, -16 /* restore a0 from call[i+1]'s stack frame */ + l32e a1, a9, -12 /* restore a1 from call[i+1]'s stack frame */ + l32e a2, a9, -8 /* restore a2 from call[i+1]'s stack frame */ + l32e a7, a1, -12 /* a7 <- call[i-1]'s sp + (used to find end of call[i]'s frame) */ + l32e a3, a9, -4 /* restore a3 from call[i+1]'s stack frame */ + l32e a4, a7, -32 /* restore a4 from call[i]'s stack frame */ + l32e a5, a7, -28 /* restore a5 from call[i]'s stack frame */ + l32e a6, a7, -24 /* restore a6 from call[i]'s stack frame */ + l32e a7, a7, -20 /* restore a7 from call[i]'s stack frame */ + rfwu + +/* +-------------------------------------------------------------------------------- +Window Overflow Exception for Call12 + +Invoked if a call[i] referenced a register (a4-a15) +that contains data from ancestor call[j]; +call[j] had done a call12 to call[j+1]. +On entry here: + window rotated to call[j] start point; + a0-a11 are registers to be saved; + a12-a15 must be preserved; + a13 is call[j+1]'s stack pointer. +-------------------------------------------------------------------------------- +*/ + + .org 0x100 + .global _WindowOverflow12 +_WindowOverflow12: + + s32e a0, a13, -16 /* save a0 to call[j+1]'s stack frame */ + l32e a0, a1, -12 /* a0 <- call[j-1]'s sp + (used to find end of call[j]'s frame) */ + s32e a1, a13, -12 /* save a1 to call[j+1]'s stack frame */ + s32e a2, a13, -8 /* save a2 to call[j+1]'s stack frame */ + s32e a3, a13, -4 /* save a3 to call[j+1]'s stack frame */ + s32e a4, a0, -48 /* save a4 to end of call[j]'s stack frame */ + s32e a5, a0, -44 /* save a5 to end of call[j]'s stack frame */ + s32e a6, a0, -40 /* save a6 to end of call[j]'s stack frame */ + s32e a7, a0, -36 /* save a7 to end of call[j]'s stack frame */ + s32e a8, a0, -32 /* save a8 to end of call[j]'s stack frame */ + s32e a9, a0, -28 /* save a9 to end of call[j]'s stack frame */ + s32e a10, a0, -24 /* save a10 to end of call[j]'s stack frame */ + s32e a11, a0, -20 /* save a11 to end of call[j]'s stack frame */ + rfwo /* rotates back to call[i] position */ + +/* +-------------------------------------------------------------------------------- +Window Underflow Exception for Call12 + +Invoked by RETW returning from call[i+1] to call[i] +where call[i]'s registers must be reloaded (not live in ARs); +where call[i] had done a call12 to call[i+1]. +On entry here: + window rotated to call[i] start point; + a0-a11 are undefined, must be reloaded with call[i].reg[0..11]; + a12-a15 must be preserved (they are call[i+1].reg[0..3]); + a13 is call[i+1]'s stack pointer. +-------------------------------------------------------------------------------- +*/ + + .org 0x140 + .global _WindowUnderflow12 +_WindowUnderflow12: + + l32e a0, a13, -16 /* restore a0 from call[i+1]'s stack frame */ + l32e a1, a13, -12 /* restore a1 from call[i+1]'s stack frame */ + l32e a2, a13, -8 /* restore a2 from call[i+1]'s stack frame */ + l32e a11, a1, -12 /* a11 <- call[i-1]'s sp + (used to find end of call[i]'s frame) */ + l32e a3, a13, -4 /* restore a3 from call[i+1]'s stack frame */ + l32e a4, a11, -48 /* restore a4 from end of call[i]'s stack frame */ + l32e a5, a11, -44 /* restore a5 from end of call[i]'s stack frame */ + l32e a6, a11, -40 /* restore a6 from end of call[i]'s stack frame */ + l32e a7, a11, -36 /* restore a7 from end of call[i]'s stack frame */ + l32e a8, a11, -32 /* restore a8 from end of call[i]'s stack frame */ + l32e a9, a11, -28 /* restore a9 from end of call[i]'s stack frame */ + l32e a10, a11, -24 /* restore a10 from end of call[i]'s stack frame */ + l32e a11, a11, -20 /* restore a11 from end of call[i]'s stack frame */ + rfwu + +#endif /* XCHAL_HAVE_WINDOWED */ + + .section .UserEnter.text, "ax" + .global call_user_start + .type call_user_start,@function + .align 4 + .literal_position + + + diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/port.c b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/port.c index de2c41d..371ccfa 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/port.c +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/port.c @@ -1,95 +1,54 @@ + /* - FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. - All rights reserved + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS 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. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -/******************************************************************************* -// Copyright (c) 2003-2015 Cadence Design Systems, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------- -*/ +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ #include #include diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portasm.S b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portasm.S index 88e91e2..03852d8 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portasm.S +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portasm.S @@ -1,27 +1,26 @@ + /* -//----------------------------------------------------------------------------- -// Copyright (c) 2003-2015 Cadence Design Systems, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -//----------------------------------------------------------------------------- -*/ + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ #include "xtensa_rtos.h" diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portbenchmark.h b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portbenchmark.h index 4ce41d3..f5f1899 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portbenchmark.h +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portbenchmark.h @@ -1,26 +1,26 @@ -/******************************************************************************* -// Copyright (c) 2003-2015 Cadence Design Systems, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------- -*/ + +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ /* * This utility helps benchmarking interrupt latency and context switches. diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portclib.c b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portclib.c index c648cb8..b602134 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portclib.c +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portclib.c @@ -1,26 +1,26 @@ -/******************************************************************************* -// Copyright (c) 2003-2015 Cadence Design Systems, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------- -*/ + +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ #include "FreeRTOS.h" diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portmacro.h b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portmacro.h index 2b47e66..e30db0b 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portmacro.h +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/portmacro.h @@ -1,67 +1,54 @@ + /* - FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. - All rights reserved + * FreeRTOS Kernel V10.0.0 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that has become a de facto standard. * - * * - * Help yourself get started quickly and support the FreeRTOS * - * project by purchasing a FreeRTOS tutorial book, reference * - * manual, or both from: http://www.FreeRTOS.org/Documentation * - * * - * Thank you! * - * * - *************************************************************************** - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - - FreeRTOS 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. Full license text is available from the following - link: http://www.freertos.org/a00114.html - - 1 tab == 4 spaces! - - *************************************************************************** - * * - * Having a problem? Start by reading the FAQ "My application does * - * not run, what could be wrong?" * - * * - * http://www.FreeRTOS.org/FAQHelp.html * - * * - *************************************************************************** - - http://www.FreeRTOS.org - Documentation, books, training, latest versions, - license and Real Time Engineers Ltd. contact details. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High - Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ #ifndef PORTMACRO_H #define PORTMACRO_H diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/porttrace.h b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/porttrace.h index bf2fb41..834b160 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/porttrace.h +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/porttrace.h @@ -1,32 +1,34 @@ -/******************************************************************************* -// Copyright (c) 2003-2015 Cadence Design Systems, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------- /* - * This utility helps tracing the entering and exiting from tasks. It maintains a circular buffer - * of tasks in the order they execute, and their execution time. - * In order to enable it, set configUSE_TRACE_FACILITY_2 to 1 in FreeRTOSConfig.h. - * You will also need to download the FreeRTOS_trace patch that contains - * porttrace.c and the complete version of porttrace.h + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * This utility helps tracing the entering and exiting from tasks. + * It maintains a circular buffer of tasks in the order they execute, + * and their execution time. To enable it, set configUSE_TRACE_FACILITY_2 + * to 1 in FreeRTOSConfig.h. You will also need to download the + * FreeRTOS_trace patch that contains porttrace.c and the complete version + * of porttrace.h. */ #ifndef PORTTRACE_H diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_api.h b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_api.h index 5d1ba84..8e2d8c9 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_api.h +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_api.h @@ -1,29 +1,30 @@ -/******************************************************************************* -Copyright (c) 2006-2015 Cadence Design Systems Inc. -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -******************************************************************************/ - -/****************************************************************************** - Xtensa-specific API for RTOS ports. -******************************************************************************/ +/* + * Xtensa-specific API for RTOS ports. + */ #ifndef __XTENSA_API_H__ #define __XTENSA_API_H__ diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_config.h b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_config.h index 448fe7e..43f3daa 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_config.h +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_config.h @@ -1,34 +1,35 @@ -/******************************************************************************* -// Copyright (c) 2003-2015 Cadence Design Systems, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------- - Configuration-specific information for Xtensa build. This file must be - included in FreeRTOSConfig.h to properly set up the config-dependent - parameters correctly. +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ - NOTE: To enable thread-safe C library support, XT_USE_THREAD_SAFE_CLIB must - be defined to be > 0 somewhere above or on the command line. - -*******************************************************************************/ +/* + * Configuration-specific information for Xtensa build. This file must be + * included in FreeRTOSConfig.h to properly set up the config-dependent + * parameters correctly. + * + * NOTE: To enable thread-safe C library support, XT_USE_THREAD_SAFE_CLIB must + * be defined to be > 0 somewhere above or on the command line. + */ #ifndef XTENSA_CONFIG_H #define XTENSA_CONFIG_H diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_context.S b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_context.S index 2e29d34..d3748c7 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_context.S +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_context.S @@ -1,47 +1,48 @@ -/******************************************************************************* -Copyright (c) 2006-2015 Cadence Design Systems Inc. -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------- - - XTENSA CONTEXT SAVE AND RESTORE ROUTINES - -Low-level Call0 functions for handling generic context save and restore of -registers not specifically addressed by the interrupt vectors and handlers. -Those registers (not handled by these functions) are PC, PS, A0, A1 (SP). -Except for the calls to RTOS functions, this code is generic to Xtensa. - -Note that in Call0 ABI, interrupt handlers are expected to preserve the callee- -save regs (A12-A15), which is always the case if the handlers are coded in C. -However A12, A13 are made available as scratch registers for interrupt dispatch -code, so are presumed saved anyway, and are always restored even in Call0 ABI. -Only A14, A15 are truly handled as callee-save regs. - -Because Xtensa is a configurable architecture, this port supports all user -generated configurations (except restrictions stated in the release notes). -This is accomplished by conditional compilation using macros and functions -defined in the Xtensa HAL (hardware adaptation layer) for your configuration. -Only the processor state included in your configuration is saved and restored, -including any processor state added by user configuration options or TIE. - -*******************************************************************************/ +/* + * XTENSA CONTEXT SAVE AND RESTORE ROUTINES + * + * Low-level Call0 functions for handling generic context save and restore of + * registers not specifically addressed by the interrupt vectors and handlers. + * Those registers (not handled by these functions) are PC, PS, A0, A1 (SP). + * Except for the calls to RTOS functions, this code is generic to Xtensa. + * + * Note that in Call0 ABI, interrupt handlers are expected to preserve the callee- + * save regs (A12-A15), which is always the case if the handlers are coded in C. + * However A12, A13 are made available as scratch registers for interrupt dispatch + * code, so are presumed saved anyway, and are always restored even in Call0 ABI. + * Only A14, A15 are truly handled as callee-save regs. + * + * Because Xtensa is a configurable architecture, this port supports all user + * generated configurations (except restrictions stated in the release notes). + * This is accomplished by conditional compilation using macros and functions + * defined in the Xtensa HAL (hardware adaptation layer) for your configuration. + * Only the processor state included in your configuration is saved and restored, + * including any processor state added by user configuration options or TIE. + */ /* Warn nicely if this file gets named with a lowercase .s instead of .S: */ #define NOERROR # diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_context.h b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_context.h index da32967..8898e11 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_context.h +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_context.h @@ -1,38 +1,39 @@ -/******************************************************************************* -Copyright (c) 2006-2015 Cadence Design Systems Inc. -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------- - - XTENSA CONTEXT FRAMES AND MACROS FOR RTOS ASSEMBLER SOURCES - -This header contains definitions and macros for use primarily by Xtensa -RTOS assembly coded source files. It includes and uses the Xtensa hardware -abstraction layer (HAL) to deal with config specifics. It may also be -included in C source files. - -!! Supports only Xtensa Exception Architecture 2 (XEA2). XEA1 not supported. !! - -NOTE: The Xtensa architecture requires stack pointer alignment to 16 bytes. - -*******************************************************************************/ +/* + * XTENSA CONTEXT FRAMES AND MACROS FOR RTOS ASSEMBLER SOURCES + * + * This header contains definitions and macros for use primarily by Xtensa + * RTOS assembly coded source files. It includes and uses the Xtensa hardware + * abstraction layer (HAL) to deal with config specifics. It may also be + * included in C source files. + * + * !! Supports only Xtensa Exception Architecture 2 (XEA2). XEA1 not supported. !! + * + * NOTE: The Xtensa architecture requires stack pointer alignment to 16 bytes. + */ #ifndef XTENSA_CONTEXT_H #define XTENSA_CONTEXT_H diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_init.c b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_init.c index ded8df1..2de1116 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_init.c +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_init.c @@ -1,32 +1,33 @@ -/******************************************************************************* -// Copyright (c) 2003-2015 Cadence Design Systems, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------- - XTENSA INITIALIZATION ROUTINES CODED IN C +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ -This file contains miscellaneous Xtensa RTOS-generic initialization functions -that are implemented in C. - -*******************************************************************************/ +/* + * XTENSA INITIALIZATION ROUTINES CODED IN C + * + * This file contains miscellaneous Xtensa RTOS-generic initialization functions + * that are implemented in C. + */ #ifdef XT_BOARD diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_intr.c b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_intr.c index 4bc6c35..524ebf6 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_intr.c +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_intr.c @@ -1,30 +1,31 @@ -/******************************************************************************* -Copyright (c) 2006-2015 Cadence Design Systems Inc. -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -******************************************************************************/ - -/****************************************************************************** - Xtensa-specific interrupt and exception functions for RTOS ports. - Also see xtensa_intr_asm.S. -******************************************************************************/ +/* + * Xtensa-specific interrupt and exception functions for RTOS ports. + * Also see xtensa_intr_asm.S. + */ #include diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_intr_asm.S b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_intr_asm.S index 5f9890d..bf3017d 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_intr_asm.S +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_intr_asm.S @@ -1,30 +1,31 @@ -/******************************************************************************* -Copyright (c) 2006-2015 Cadence Design Systems Inc. -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -******************************************************************************/ - -/****************************************************************************** - Xtensa interrupt handling data and assembly routines. - Also see xtensa_intr.c and xtensa_vectors.S. -******************************************************************************/ +/* + * Xtensa interrupt handling data and assembly routines. + * Also see xtensa_intr.c and xtensa_vectors.S. + */ #include #include diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_overlay_os_hook.c b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_overlay_os_hook.c index a5ca23c..004bfb5 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_overlay_os_hook.c +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_overlay_os_hook.c @@ -1,26 +1,30 @@ -// xtensa_overlay_os_hook.c -- Overlay manager OS hooks for FreeRTOS. -// Copyright (c) 2015-2015 Cadence Design Systems Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +/* + * xtensa_overlay_os_hook.c -- Overlay manager OS hooks for FreeRTOS. + */ #include "FreeRTOS.h" #include "semphr.h" diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_rtos.h b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_rtos.h index b0eeb17..ecf6b61 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_rtos.h +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_rtos.h @@ -1,43 +1,44 @@ -/******************************************************************************* -// Copyright (c) 2003-2015 Cadence Design Systems, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------- - RTOS-SPECIFIC INFORMATION FOR XTENSA RTOS ASSEMBLER SOURCES - (FreeRTOS Port) +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ -This header is the primary glue between generic Xtensa RTOS support -sources and a specific RTOS port for Xtensa. It contains definitions -and macros for use primarily by Xtensa assembly coded source files. - -Macros in this header map callouts from generic Xtensa files to specific -RTOS functions. It may also be included in C source files. - -Xtensa RTOS ports support all RTOS-compatible configurations of the Xtensa -architecture, using the Xtensa hardware abstraction layer (HAL) to deal -with configuration specifics. - -Should be included by all Xtensa generic and RTOS port-specific sources. - -*******************************************************************************/ +/* + * RTOS-SPECIFIC INFORMATION FOR XTENSA RTOS ASSEMBLER SOURCES + * (FreeRTOS Port) + * + * This header is the primary glue between generic Xtensa RTOS support + * sources and a specific RTOS port for Xtensa. It contains definitions + * and macros for use primarily by Xtensa assembly coded source files. + * + * Macros in this header map callouts from generic Xtensa files to specific + * RTOS functions. It may also be included in C source files. + * + * Xtensa RTOS ports support all RTOS-compatible configurations of the Xtensa + * architecture, using the Xtensa hardware abstraction layer (HAL) to deal + * with configuration specifics. + * + * Should be included by all Xtensa generic and RTOS port-specific sources. + */ #ifndef XTENSA_RTOS_H #define XTENSA_RTOS_H diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_timer.h b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_timer.h index 9bb8648..0fb2eff 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_timer.h +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_timer.h @@ -1,41 +1,42 @@ -/******************************************************************************* -// Copyright (c) 2003-2015 Cadence Design Systems, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------- - XTENSA INFORMATION FOR RTOS TICK TIMER AND CLOCK FREQUENCY +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ -This header contains definitions and macros for use primarily by Xtensa -RTOS assembly coded source files. It includes and uses the Xtensa hardware -abstraction layer (HAL) to deal with config specifics. It may also be -included in C source files. - -User may edit to modify timer selection and to specify clock frequency and -tick duration to match timer interrupt to the real-time tick duration. - -If the RTOS has no timer interrupt, then there is no tick timer and the -clock frequency is irrelevant, so all of these macros are left undefined -and the Xtensa core configuration need not have a timer. - -*******************************************************************************/ +/* + * XTENSA INFORMATION FOR RTOS TICK TIMER AND CLOCK FREQUENCY + * + * This header contains definitions and macros for use primarily by Xtensa + * RTOS assembly coded source files. It includes and uses the Xtensa hardware + * abstraction layer (HAL) to deal with config specifics. It may also be + * included in C source files. + * + * Edit this file to modify timer selection and to specify clock frequency and + * tick duration to match timer interrupt to the real-time tick duration. + * + * If the RTOS has no timer interrupt, then there is no tick timer and the + * clock frequency is irrelevant, so all of these macros are left undefined + * and the Xtensa core configuration need not have a timer. + */ #ifndef XTENSA_TIMER_H #define XTENSA_TIMER_H diff --git a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_vectors.S b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_vectors.S index ec48fb7..953205c 100755 --- a/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_vectors.S +++ b/FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_vectors.S @@ -1,26 +1,28 @@ -/******************************************************************************* -Copyright (c) 2006-2015 Cadence Design Systems Inc. -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------- +/* + * Copyright (c) 2015-2019 Cadence Design Systems, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +/* XTENSA VECTORS AND LOW LEVEL HANDLERS FOR AN RTOS Xtensa low level exception and interrupt vectors and handlers for an RTOS. @@ -88,7 +90,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. call but needs to be ensured if 'call0' is used as a jump in lieu of 'j'. 4. This use of 'call0' is independent of the C function call ABI. -*******************************************************************************/ + */ #include "xtensa_rtos.h" diff --git a/FreeRTOS/Source/portable/WizC/PIC18/Drivers/Tick/Tick.c b/FreeRTOS/Source/portable/WizC/PIC18/Drivers/Tick/Tick.c index fb1bc47..532b8f0 100755 --- a/FreeRTOS/Source/portable/WizC/PIC18/Drivers/Tick/Tick.c +++ b/FreeRTOS/Source/portable/WizC/PIC18/Drivers/Tick/Tick.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/WizC/PIC18/Drivers/Tick/isrTick.c b/FreeRTOS/Source/portable/WizC/PIC18/Drivers/Tick/isrTick.c index 371f361..7ce2f61 100755 --- a/FreeRTOS/Source/portable/WizC/PIC18/Drivers/Tick/isrTick.c +++ b/FreeRTOS/Source/portable/WizC/PIC18/Drivers/Tick/isrTick.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/WizC/PIC18/addFreeRTOS.h b/FreeRTOS/Source/portable/WizC/PIC18/addFreeRTOS.h index f1e69de..713ae70 100755 --- a/FreeRTOS/Source/portable/WizC/PIC18/addFreeRTOS.h +++ b/FreeRTOS/Source/portable/WizC/PIC18/addFreeRTOS.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/WizC/PIC18/port.c b/FreeRTOS/Source/portable/WizC/PIC18/port.c index eea644b..2417675 100755 --- a/FreeRTOS/Source/portable/WizC/PIC18/port.c +++ b/FreeRTOS/Source/portable/WizC/PIC18/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/WizC/PIC18/portmacro.h b/FreeRTOS/Source/portable/WizC/PIC18/portmacro.h index a8ac87b..1a69275 100755 --- a/FreeRTOS/Source/portable/WizC/PIC18/portmacro.h +++ b/FreeRTOS/Source/portable/WizC/PIC18/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/oWatcom/16BitDOS/Flsh186/port.c b/FreeRTOS/Source/portable/oWatcom/16BitDOS/Flsh186/port.c index d9bd5b3..ea6931f 100755 --- a/FreeRTOS/Source/portable/oWatcom/16BitDOS/Flsh186/port.c +++ b/FreeRTOS/Source/portable/oWatcom/16BitDOS/Flsh186/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/oWatcom/16BitDOS/Flsh186/portmacro.h b/FreeRTOS/Source/portable/oWatcom/16BitDOS/Flsh186/portmacro.h index fb6da90..2433c6b 100755 --- a/FreeRTOS/Source/portable/oWatcom/16BitDOS/Flsh186/portmacro.h +++ b/FreeRTOS/Source/portable/oWatcom/16BitDOS/Flsh186/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/oWatcom/16BitDOS/PC/port.c b/FreeRTOS/Source/portable/oWatcom/16BitDOS/PC/port.c index 276539d..09fcf9d 100755 --- a/FreeRTOS/Source/portable/oWatcom/16BitDOS/PC/port.c +++ b/FreeRTOS/Source/portable/oWatcom/16BitDOS/PC/port.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/oWatcom/16BitDOS/PC/portmacro.h b/FreeRTOS/Source/portable/oWatcom/16BitDOS/PC/portmacro.h index c177f87..811829d 100755 --- a/FreeRTOS/Source/portable/oWatcom/16BitDOS/PC/portmacro.h +++ b/FreeRTOS/Source/portable/oWatcom/16BitDOS/PC/portmacro.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/oWatcom/16BitDOS/common/portasm.h b/FreeRTOS/Source/portable/oWatcom/16BitDOS/common/portasm.h index e802e1b..587d2f7 100755 --- a/FreeRTOS/Source/portable/oWatcom/16BitDOS/common/portasm.h +++ b/FreeRTOS/Source/portable/oWatcom/16BitDOS/common/portasm.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/portable/oWatcom/16BitDOS/common/portcomn.c b/FreeRTOS/Source/portable/oWatcom/16BitDOS/common/portcomn.c index 20326fa..d51e3ae 100755 --- a/FreeRTOS/Source/portable/oWatcom/16BitDOS/common/portcomn.c +++ b/FreeRTOS/Source/portable/oWatcom/16BitDOS/common/portcomn.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/queue.c b/FreeRTOS/Source/queue.c index 3709835..d882bf6 100755 --- a/FreeRTOS/Source/queue.c +++ b/FreeRTOS/Source/queue.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/readme.txt b/FreeRTOS/Source/readme.txt deleted file mode 100755 index 58480c5..0000000 --- a/FreeRTOS/Source/readme.txt +++ /dev/null @@ -1,17 +0,0 @@ -Each real time kernel port consists of three files that contain the core kernel -components and are common to every port, and one or more files that are -specific to a particular microcontroller and or compiler. - -+ The FreeRTOS/Source directory contains the three files that are common to -every port - list.c, queue.c and tasks.c. The kernel is contained within these -three files. croutine.c implements the optional co-routine functionality - which -is normally only used on very memory limited systems. - -+ The FreeRTOS/Source/Portable directory contains the files that are specific to -a particular microcontroller and or compiler. - -+ The FreeRTOS/Source/include directory contains the real time kernel header -files. - -See the readme file in the FreeRTOS/Source/Portable directory for more -information. \ No newline at end of file diff --git a/FreeRTOS/Source/stream_buffer.c b/FreeRTOS/Source/stream_buffer.c index 23cb444..8551970 100755 --- a/FreeRTOS/Source/stream_buffer.c +++ b/FreeRTOS/Source/stream_buffer.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/FreeRTOS/Source/tasks.c b/FreeRTOS/Source/tasks.c index 3732279..660039c 100755 --- a/FreeRTOS/Source/tasks.c +++ b/FreeRTOS/Source/tasks.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -75,24 +75,7 @@ functions but without including stdio.h here. */ */ #define tskSTACK_FILL_BYTE ( 0xa5U ) -/* Sometimes the FreeRTOSConfig.h settings only allow a task to be created using -dynamically allocated RAM, in which case when any task is deleted it is known -that both the task's stack and TCB need to be freed. Sometimes the -FreeRTOSConfig.h settings only allow a task to be created using statically -allocated RAM, in which case when any task is deleted it is known that neither -the task's stack or TCB should be freed. Sometimes the FreeRTOSConfig.h -settings allow a task to be created using either statically or dynamically -allocated RAM, in which case a member of the TCB is used to record whether the -stack and/or TCB were allocated statically or dynamically, so when a task is -deleted the RAM that was allocated dynamically is freed again and no attempt is -made to free the RAM that was allocated statically. -tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE is only true if it is possible for a -task to be created using either statically or dynamically allocated RAM. Note -that if portUSING_MPU_WRAPPERS is 1 then a protected task can be created with -a statically allocated stack and a dynamically allocated TCB. -!!!NOTE!!! If the definition of tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE is -changed then the definition of StaticTask_t must also be updated. */ -#define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) +/* Bits used to recored how a task's stack and TCB were allocated. */ #define tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB ( ( uint8_t ) 0 ) #define tskSTATICALLY_ALLOCATED_STACK_ONLY ( ( uint8_t ) 1 ) #define tskSTATICALLY_ALLOCATED_STACK_AND_TCB ( ( uint8_t ) 2 ) @@ -326,7 +309,7 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to pr volatile uint8_t ucNotifyState; #endif - /* See the comments above the definition of + /* See the comments in FreeRTOS.h with the definition of tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE. */ #if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */ uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the task is a statically allocated to ensure no attempt is made to free the memory. */ @@ -383,7 +366,6 @@ the errno of the currently running task. */ /* Other file private variables. --------------------------------*/ PRIVILEGED_DATA static volatile UBaseType_t uxCurrentNumberOfTasks = ( UBaseType_t ) 0U; PRIVILEGED_DATA static volatile TickType_t xTickCount = ( TickType_t ) configINITIAL_TICK_COUNT; -PRIVILEGED_DATA static volatile TickType_t xIdleTickCount = (TickType_t)configINITIAL_TICK_COUNT; PRIVILEGED_DATA static volatile UBaseType_t uxTopReadyPriority = tskIDLE_PRIORITY; PRIVILEGED_DATA static volatile BaseType_t xSchedulerRunning = pdFALSE; PRIVILEGED_DATA static volatile UBaseType_t uxPendedTicks = ( UBaseType_t ) 0U; @@ -632,7 +614,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) PRIVILEGED_FUNCTION; task was created statically in case the task is later deleted. */ pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_AND_TCB; } - #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ + #endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE */ prvInitialiseNewTask( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, &xReturn, pxNewTCB, NULL ); prvAddNewTaskToReadyList( pxNewTCB ); @@ -674,7 +656,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) PRIVILEGED_FUNCTION; task was created statically in case the task is later deleted. */ pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_AND_TCB; } - #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ + #endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE */ prvInitialiseNewTask( pxTaskDefinition->pvTaskCode, pxTaskDefinition->pcName, @@ -715,14 +697,14 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) PRIVILEGED_FUNCTION; /* Store the stack location in the TCB. */ pxNewTCB->pxStack = pxTaskDefinition->puxStackBuffer; - #if( configSUPPORT_STATIC_ALLOCATION == 1 ) + #if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) { /* Tasks can be created statically or dynamically, so note this task had a statically allocated stack in case it is later deleted. The TCB was allocated dynamically. */ pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_ONLY; } - #endif + #endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE */ prvInitialiseNewTask( pxTaskDefinition->pvTaskCode, pxTaskDefinition->pcName, @@ -819,7 +801,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) PRIVILEGED_FUNCTION; task was created dynamically in case it is later deleted. */ pxNewTCB->ucStaticallyAllocated = tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB; } - #endif /* configSUPPORT_STATIC_ALLOCATION */ + #endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE */ prvInitialiseNewTask( pxTaskCode, pcName, ( uint32_t ) usStackDepth, pvParameters, uxPriority, pxCreatedTask, pxNewTCB, NULL ); prvAddNewTaskToReadyList( pxNewTCB ); @@ -1028,11 +1010,49 @@ UBaseType_t x; the top of stack variable is updated. */ #if( portUSING_MPU_WRAPPERS == 1 ) { - pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters, xRunPrivileged ); + /* If the port has capability to detect stack overflow, + pass the stack end address to the stack initialization + function as well. */ + #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + { + #if( portSTACK_GROWTH < 0 ) + { + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxNewTCB->pxStack, pxTaskCode, pvParameters, xRunPrivileged ); + } + #else /* portSTACK_GROWTH */ + { + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxNewTCB->pxEndOfStack, pxTaskCode, pvParameters, xRunPrivileged ); + } + #endif /* portSTACK_GROWTH */ + } + #else /* portHAS_STACK_OVERFLOW_CHECKING */ + { + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters, xRunPrivileged ); + } + #endif /* portHAS_STACK_OVERFLOW_CHECKING */ } #else /* portUSING_MPU_WRAPPERS */ { - pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters ); + /* If the port has capability to detect stack overflow, + pass the stack end address to the stack initialization + function as well. */ + #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + { + #if( portSTACK_GROWTH < 0 ) + { + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxNewTCB->pxStack, pxTaskCode, pvParameters ); + } + #else /* portSTACK_GROWTH */ + { + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxNewTCB->pxEndOfStack, pxTaskCode, pvParameters ); + } + #endif /* portSTACK_GROWTH */ + } + #else /* portHAS_STACK_OVERFLOW_CHECKING */ + { + pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters ); + } + #endif /* portHAS_STACK_OVERFLOW_CHECKING */ } #endif /* portUSING_MPU_WRAPPERS */ @@ -1353,7 +1373,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) #endif /* INCLUDE_vTaskDelay */ /*-----------------------------------------------------------*/ -#if( ( INCLUDE_eTaskGetState == 1 ) || ( configUSE_TRACE_FACILITY == 1 ) ) +#if( ( INCLUDE_eTaskGetState == 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_xTaskAbortDelay == 1 ) ) eTaskState eTaskGetState( TaskHandle_t xTask ) { @@ -2084,6 +2104,7 @@ void vTaskSuspendAll( void ) post in the FreeRTOS support forum before reporting this as a bug! - http://goo.gl/wu4acr */ ++uxSchedulerSuspended; + portMEMORY_BARRIER(); } /*----------------------------------------------------------*/ @@ -2275,22 +2296,6 @@ TickType_t xTicks; } /*-----------------------------------------------------------*/ -TickType_t xTaskGetIdleTickCount( void ) -{ -TickType_t xTicks; - - /* Critical section required if running on a 16 bit processor. */ - portTICK_TYPE_ENTER_CRITICAL(); - { - xTicks = xIdleTickCount; - } - portTICK_TYPE_EXIT_CRITICAL(); - - return xTicks; -} - -/*-----------------------------------------------------------*/ - TickType_t xTaskGetTickCountFromISR( void ) { TickType_t xReturn; @@ -2954,28 +2959,28 @@ void vTaskSwitchContext( void ) #if ( configGENERATE_RUN_TIME_STATS == 1 ) { - #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE - portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime ); - #else - ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE(); - #endif + #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE + portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime ); + #else + ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE(); + #endif - /* Add the amount of time the task has been running to the - accumulated time so far. The time the task started running was - stored in ulTaskSwitchedInTime. Note that there is no overflow - protection here so count values are only valid until the timer - overflows. The guard against negative values is to protect - against suspect run time stat counter implementations - which - are provided by the application, not the kernel. */ - if( ulTotalRunTime > ulTaskSwitchedInTime ) - { - pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - ulTaskSwitchedInTime = ulTotalRunTime; + /* Add the amount of time the task has been running to the + accumulated time so far. The time the task started running was + stored in ulTaskSwitchedInTime. Note that there is no overflow + protection here so count values are only valid until the timer + overflows. The guard against negative values is to protect + against suspect run time stat counter implementations - which + are provided by the application, not the kernel. */ + if( ulTotalRunTime > ulTaskSwitchedInTime ) + { + pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + ulTaskSwitchedInTime = ulTotalRunTime; } #endif /* configGENERATE_RUN_TIME_STATS */ @@ -3112,6 +3117,20 @@ BaseType_t xReturn; { ( void ) uxListRemove( &( pxUnblockedTCB->xStateListItem ) ); prvAddTaskToReadyList( pxUnblockedTCB ); + + #if( configUSE_TICKLESS_IDLE != 0 ) + { + /* If a task is blocked on a kernel object then xNextTaskUnblockTime + might be set to the blocked task's time out time. If the task is + unblocked for a reason other than a timeout xNextTaskUnblockTime is + normally left unchanged, because it is automatically reset to a new + value when the tick count equals xNextTaskUnblockTime. However if + tickless idling is used it might be more important to enter sleep mode + at the earliest possible time - so reset xNextTaskUnblockTime here to + ensure it is updated at the earliest possible time. */ + prvResetNextTaskUnblockTime(); + } + #endif } else { @@ -3136,20 +3155,6 @@ BaseType_t xReturn; xReturn = pdFALSE; } - #if( configUSE_TICKLESS_IDLE != 0 ) - { - /* If a task is blocked on a kernel object then xNextTaskUnblockTime - might be set to the blocked task's time out time. If the task is - unblocked for a reason other than a timeout xNextTaskUnblockTime is - normally left unchanged, because it is automatically reset to a new - value when the tick count equals xNextTaskUnblockTime. However if - tickless idling is used it might be more important to enter sleep mode - at the earliest possible time - so reset xNextTaskUnblockTime here to - ensure it is updated at the earliest possible time. */ - prvResetNextTaskUnblockTime(); - } - #endif - return xReturn; } /*-----------------------------------------------------------*/ @@ -3337,7 +3342,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) /* In case a task that has a secure context deletes itself, in which case the idle task is responsible for deleting the task's secure context, if any. */ - portTASK_CALLS_SECURE_FUNCTIONS(); + portALLOCATE_SECURE_CONTEXT( configMINIMAL_SECURE_STACK_SIZE ); for( ;; ) { @@ -5065,6 +5070,13 @@ TickType_t uxReturn; #endif /* configUSE_TASK_NOTIFICATIONS */ /*-----------------------------------------------------------*/ +#if( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) + TickType_t xTaskGetIdleRunTimeCounter( void ) + { + return xIdleTaskHandle->ulRunTimeCounter; + } +#endif +/*-----------------------------------------------------------*/ static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, const BaseType_t xCanBlockIndefinitely ) { diff --git a/FreeRTOS/Source/timers.c b/FreeRTOS/Source/timers.c index 848a4f7..ad18f3e 100755 --- a/FreeRTOS/Source/timers.c +++ b/FreeRTOS/Source/timers.c @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.1.1 - * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -166,7 +166,7 @@ static void prvCheckForValidListAndQueue( void ) PRIVILEGED_FUNCTION; * task. Other tasks communicate with the timer service task using the * xTimerQueue queue. */ -static void prvTimerTask( void *pvParameters ) PRIVILEGED_FUNCTION; +static portTASK_FUNCTION_PROTO( prvTimerTask, pvParameters ) PRIVILEGED_FUNCTION; /* * Called by the timer service task to interpret and process a command it @@ -301,7 +301,7 @@ BaseType_t xReturn = pdFAIL; return pxNewTimer; } -#endif /* configSUPPORT_STATIC_ALLOCATION */ +#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ /*-----------------------------------------------------------*/ #if( configSUPPORT_STATIC_ALLOCATION == 1 ) @@ -439,6 +439,26 @@ Timer_t *pxTimer = xTimer; } /*-----------------------------------------------------------*/ +void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) +{ +Timer_t * pxTimer = xTimer; + + configASSERT( xTimer ); + taskENTER_CRITICAL(); + { + if( uxAutoReload != pdFALSE ) + { + pxTimer->ucStatus |= tmrSTATUS_IS_AUTORELOAD; + } + else + { + pxTimer->ucStatus &= ~tmrSTATUS_IS_AUTORELOAD; + } + } + taskEXIT_CRITICAL(); +} +/*-----------------------------------------------------------*/ + TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) { Timer_t * pxTimer = xTimer; @@ -500,7 +520,7 @@ Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTi } /*-----------------------------------------------------------*/ -static void prvTimerTask( void *pvParameters ) +static portTASK_FUNCTION( prvTimerTask, pvParameters ) { TickType_t xNextExpireTime; BaseType_t xListWasEmpty; @@ -748,9 +768,9 @@ TickType_t xTimeNow; switch( xMessage.xMessageID ) { case tmrCOMMAND_START : - case tmrCOMMAND_START_FROM_ISR : - case tmrCOMMAND_RESET : - case tmrCOMMAND_RESET_FROM_ISR : + case tmrCOMMAND_START_FROM_ISR : + case tmrCOMMAND_RESET : + case tmrCOMMAND_RESET_FROM_ISR : case tmrCOMMAND_START_DONT_TRACE : /* Start or restart a timer. */ pxTimer->ucStatus |= tmrSTATUS_IS_ACTIVE; @@ -800,17 +820,29 @@ TickType_t xTimeNow; break; case tmrCOMMAND_DELETE : - /* The timer has already been removed from the active list, - just free up the memory if the memory was dynamically - allocated. */ - if( ( pxTimer->ucStatus & tmrSTATUS_IS_STATICALLY_ALLOCATED ) == ( uint8_t ) 0 ) + #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) { - vPortFree( pxTimer ); + /* The timer has already been removed from the active list, + just free up the memory if the memory was dynamically + allocated. */ + if( ( pxTimer->ucStatus & tmrSTATUS_IS_STATICALLY_ALLOCATED ) == ( uint8_t ) 0 ) + { + vPortFree( pxTimer ); + } + else + { + pxTimer->ucStatus &= ~tmrSTATUS_IS_ACTIVE; + } } - else + #else { + /* If dynamic allocation is not enabled, the memory + could not have been dynamically allocated. So there is + no need to free the memory - just mark the timer as + "not active". */ pxTimer->ucStatus &= ~tmrSTATUS_IS_ACTIVE; } + #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ break; default : diff --git a/New - FreeRTOS+TCP.url b/New - FreeRTOS+TCP.url deleted file mode 100755 index 6617b60..0000000 --- a/New - FreeRTOS+TCP.url +++ /dev/null @@ -1,5 +0,0 @@ -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 -[InternetShortcut] -URL=http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/index.html -IDList= diff --git a/New - Stream and Message Buffers.url b/New - Stream and Message Buffers.url deleted file mode 100755 index e6a8b23..0000000 --- a/New - Stream and Message Buffers.url +++ /dev/null @@ -1,6 +0,0 @@ -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 -[InternetShortcut] -URL=http://www.freertos.org/RTOS-stream-message-buffers.html -IDList= -HotKey=0 diff --git a/Quick_Start_Guide.url b/Quick_Start_Guide.url deleted file mode 100755 index 55caab7..0000000 --- a/Quick_Start_Guide.url +++ /dev/null @@ -1,5 +0,0 @@ -[InternetShortcut] -URL=http://www.freertos.org/FreeRTOS-quick-start-guide.html -IDList= -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 diff --git a/Upgrading-to-FreeRTOS-10.url b/Upgrading-to-FreeRTOS-10.url deleted file mode 100755 index ebcbc88..0000000 --- a/Upgrading-to-FreeRTOS-10.url +++ /dev/null @@ -1,6 +0,0 @@ -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 -[InternetShortcut] -URL=http://www.freertos.org/FreeRTOS-V10.html -IDList= -HotKey=0 diff --git a/Upgrading-to-FreeRTOS-9.url b/Upgrading-to-FreeRTOS-9.url deleted file mode 100755 index d5bf843..0000000 --- a/Upgrading-to-FreeRTOS-9.url +++ /dev/null @@ -1,5 +0,0 @@ -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 -[InternetShortcut] -URL=http://www.freertos.org/FreeRTOS-V9.html -IDList= diff --git a/readme.txt b/readme.txt index 29e94b6..1aab413 100755 --- a/readme.txt +++ b/readme.txt @@ -1,32 +1 @@ -Directories: - -+ FreeRTOS/source contains the FreeRTOS real time kernel source code. - -+ FreeRTOS/demo contains a pre-configured demo project for every official - FreeRTOS port. - -+ See http://www.freertos.org/a00017.html for full details of the FreeRTOS - directory structure and information on locating the files you require. - - + FreeRTOS-Plus contains additional FreeRTOS components and third party - complementary products. THESE ARE LICENSED SEPARATELY FROM FreeRTOS although - all contain open source options. See the license files in each respective - directory for information. - -+ FreeRTOS-Plus/Demo contains pre-configured demo projects for the FreeRTOS-Plus - components. Most demo projects run in a Windows environment using the - FreeRTOS windows simulator. These are documented on the FreeRTOS web site - http://www.FreeRTOS.org/plus - -Further readme files are contains in sub-directories as appropriate. - -The easiest way to use FreeRTOS is to start with one of the pre-configured demo -application projects (found in the FreeRTOS/Demo directory). That way you will -have the correct FreeRTOS source files included, and the correct include paths -configured. Once a demo application is building and executing you can remove -the demo application file, and start to add in your own application source -files. - -See also - -http://www.freertos.org/FreeRTOS-quick-start-guide.html -http://www.freertos.org/FAQHelp.html +The demo project is located in FreeRTOS-Plus\Demo\FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator \ No newline at end of file